@camunda8/orchestration-cluster-api 8.9.0-alpha.2 → 8.9.0-alpha.20
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 +108 -0
- package/README.md +270 -20
- package/dist/{chunk-W6JB7JZH.js → chunk-2N2LUTZ2.js} +1 -15
- package/dist/{chunk-W6JB7JZH.js.map → chunk-2N2LUTZ2.js.map} +1 -1
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/{chunk-FME2NOSH.js → chunk-G7UMORVU.js} +4456 -10816
- package/dist/chunk-G7UMORVU.js.map +1 -0
- package/dist/fp/index.cjs +14373 -12453
- package/dist/fp/index.cjs.map +1 -1
- package/dist/fp/index.d.cts +3 -2
- package/dist/fp/index.d.ts +3 -2
- package/dist/fp/index.js +3 -2
- package/dist/{index--_MHI263.d.ts → index-qu7HG5VS.d.cts} +3667 -3148
- package/dist/{index-DMLBPJ8A.d.cts → index-wP_plePI.d.ts} +3667 -3148
- package/dist/index.cjs +13724 -11741
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +97 -40
- package/dist/index.js.map +1 -1
- package/dist/logger-D-p21VHo.d.cts +31 -0
- package/dist/logger-D-p21VHo.d.ts +31 -0
- package/dist/logger.d.cts +1 -31
- package/dist/logger.d.ts +1 -31
- package/dist/logger.js +2 -1
- package/dist/threadWorkerEntry.cjs +146 -0
- package/dist/threadWorkerEntry.cjs.map +1 -0
- package/dist/threadWorkerEntry.js +144 -0
- package/dist/threadWorkerEntry.js.map +1 -0
- package/dist/zod.gen-7H2NP5CB.js +8280 -0
- package/dist/zod.gen-7H2NP5CB.js.map +1 -0
- package/package.json +26 -21
- package/dist/chunk-FME2NOSH.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,111 @@
|
|
|
1
|
+
# [8.9.0-alpha.20](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.19...v8.9.0-alpha.20) (2026-03-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* remove unused p-retry dependency ([4065fa2](https://github.com/camunda/orchestration-cluster-api-js/commit/4065fa2dcd7074c457c2b1cf2b349177e9b26780))
|
|
7
|
+
|
|
8
|
+
# [8.9.0-alpha.19](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.18...v8.9.0-alpha.19) (2026-03-23)
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
- address PR review comments ([028f361](https://github.com/camunda/orchestration-cluster-api-js/commit/028f361e31a6b84e0446eda095f67c0c9b9b68eb))
|
|
13
|
+
- address review feedback for Node 20 compat and type imports ([de1000c](https://github.com/camunda/orchestration-cluster-api-js/commit/de1000cde930a4bd0f55d5d538a1622a6800c824))
|
|
14
|
+
- correct type errors in readme examples ([ddea9ad](https://github.com/camunda/orchestration-cluster-api-js/commit/ddea9ad241cdce0bbe99917319dd2c9d9722645e))
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- add compilable README examples with snippet sync ([a687a47](https://github.com/camunda/orchestration-cluster-api-js/commit/a687a47bf628c5da9f2a94677cdf79b5fcaf0671))
|
|
19
|
+
|
|
20
|
+
# [8.9.0-alpha.18](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.17...v8.9.0-alpha.18) (2026-03-21)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- prevent fetch wrapper accumulation and abort listener leak ([b5658d6](https://github.com/camunda/orchestration-cluster-api-js/commit/b5658d6ec8567d4dc5215400a3d154b9caa47f7f))
|
|
25
|
+
|
|
26
|
+
# [8.9.0-alpha.17](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.16...v8.9.0-alpha.17) (2026-03-20)
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
- lazy-load zod validation schemas to reduce baseline memory footprint ([3d598ef](https://github.com/camunda/orchestration-cluster-api-js/commit/3d598effb41fa31a25eaf743160858f9eee18d83))
|
|
31
|
+
|
|
32
|
+
# [8.9.0-alpha.16](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.15...v8.9.0-alpha.16) (2026-03-19)
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
- threaded worker performance regression fix ([dad2fa8](https://github.com/camunda/orchestration-cluster-api-js/commit/dad2fa88f5598bc9530745e44628fefa417e6e23))
|
|
37
|
+
- use correct default port in docker-compose ([3cb1641](https://github.com/camunda/orchestration-cluster-api-js/commit/3cb16417f97bb3f64f646bc85857ae4ed38708c1))
|
|
38
|
+
|
|
39
|
+
# [8.9.0-alpha.15](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.14...v8.9.0-alpha.15) (2026-03-19)
|
|
40
|
+
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
|
|
43
|
+
- respawn worker threads after error/exit ([0155eff](https://github.com/camunda/orchestration-cluster-api-js/commit/0155eff714ba0fb6c7b81e3883977da87008972a))
|
|
44
|
+
|
|
45
|
+
# [8.9.0-alpha.14](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.13...v8.9.0-alpha.14) (2026-03-18)
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
- address PR review comments for threaded worker ([3eabf5d](https://github.com/camunda/orchestration-cluster-api-js/commit/3eabf5dfc2424a875a498978acec7a865a0d151b))
|
|
50
|
+
- emit threadWorkerEntry to dist and resolve path in ESM ([3f00041](https://github.com/camunda/orchestration-cluster-api-js/commit/3f0004199040fbc904426520efccdd9528b2afcd))
|
|
51
|
+
- fix constraint validation for unicode regex ([8347376](https://github.com/camunda/orchestration-cluster-api-js/commit/834737664db9a76177cd9f7c652141bc20a45ddb))
|
|
52
|
+
|
|
53
|
+
### Features
|
|
54
|
+
|
|
55
|
+
- add performance test, rebuild latest ([1984ad3](https://github.com/camunda/orchestration-cluster-api-js/commit/1984ad38a83f1c652e1f30b2e9751e9800b8cf2e))
|
|
56
|
+
- add threadedJobWorker ([1e6b049](https://github.com/camunda/orchestration-cluster-api-js/commit/1e6b049c09cd7078c70b020cc4f9370f527a444d))
|
|
57
|
+
- build from latest stable/8.9 ([2798004](https://github.com/camunda/orchestration-cluster-api-js/commit/279800491c202f46b0fea7efc8a7a3ced328a339))
|
|
58
|
+
- rebuild from latest stable/8.9 ([e2c8d04](https://github.com/camunda/orchestration-cluster-api-js/commit/e2c8d04280f4991eb5e2564688bc9dbce3c748a8))
|
|
59
|
+
|
|
60
|
+
# [8.9.0-alpha.13](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.12...v8.9.0-alpha.13) (2026-03-09)
|
|
61
|
+
|
|
62
|
+
### Features
|
|
63
|
+
|
|
64
|
+
- add backoff-at-floor to backpressure algorithm ([a0504bc](https://github.com/camunda/orchestration-cluster-api-js/commit/a0504bcdfd3e24c47e168cddc59aeae957bfc8dd))
|
|
65
|
+
|
|
66
|
+
# [8.9.0-alpha.12](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.11...v8.9.0-alpha.12) (2026-03-08)
|
|
67
|
+
|
|
68
|
+
### Features
|
|
69
|
+
|
|
70
|
+
- build from hardened contract in 8.9 ([03ef35a](https://github.com/camunda/orchestration-cluster-api-js/commit/03ef35a9cda1913bf11bd42b07ae95829d4118cc))
|
|
71
|
+
|
|
72
|
+
# [8.9.0-alpha.11](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.10...v8.9.0-alpha.11) (2026-03-06)
|
|
73
|
+
|
|
74
|
+
### Features
|
|
75
|
+
|
|
76
|
+
- add per-operation retry config. New tuning for backpressure ([9dd921a](https://github.com/camunda/orchestration-cluster-api-js/commit/9dd921a0eae67d56d0e8a7d6423ac7d8a3edd3b4))
|
|
77
|
+
|
|
78
|
+
# [8.9.0-alpha.10](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.9...v8.9.0-alpha.10) (2026-03-05)
|
|
79
|
+
|
|
80
|
+
### Features
|
|
81
|
+
|
|
82
|
+
- tune backpressure ([b64c6f1](https://github.com/camunda/orchestration-cluster-api-js/commit/b64c6f14a5b4755881cb1c79c804a5cd8403145f))
|
|
83
|
+
|
|
84
|
+
# [8.9.0-alpha.9](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.8...v8.9.0-alpha.9) (2026-03-05)
|
|
85
|
+
|
|
86
|
+
### Features
|
|
87
|
+
|
|
88
|
+
- add startup jitter for workers ([95b431d](https://github.com/camunda/orchestration-cluster-api-js/commit/95b431d97fc42aaddfde0b744a8ad94bf82ce401))
|
|
89
|
+
- regenerate from stable/8.9 ([390a04e](https://github.com/camunda/orchestration-cluster-api-js/commit/390a04e6ea06b462ffd6d77d4ed10a3bf31dffda))
|
|
90
|
+
|
|
91
|
+
# [8.9.0-alpha.8](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.7...v8.9.0-alpha.8) (2026-03-02)
|
|
92
|
+
|
|
93
|
+
### Features
|
|
94
|
+
|
|
95
|
+
- support deprecated enums ([a1a2290](https://github.com/camunda/orchestration-cluster-api-js/commit/a1a22908fef6ca75ce353b851d4b6aabd7aa4522))
|
|
96
|
+
|
|
97
|
+
# [8.9.0-alpha.7](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.6...v8.9.0-alpha.7) (2026-03-02)
|
|
98
|
+
|
|
99
|
+
### Bug Fixes
|
|
100
|
+
|
|
101
|
+
- rebuild from upstream spec ([efd13cb](https://github.com/camunda/orchestration-cluster-api-js/commit/efd13cbaec2e3fa2c0a8c0578f5d5b0fa0101715))
|
|
102
|
+
|
|
103
|
+
# [8.9.0-alpha.6](https://github.com/camunda/orchestration-cluster-api-js/compare/v8.9.0-alpha.5...v8.9.0-alpha.6) (2026-02-17)
|
|
104
|
+
|
|
105
|
+
### Features
|
|
106
|
+
|
|
107
|
+
- regenerate from latest schema ([c2d9dff](https://github.com/camunda/orchestration-cluster-api-js/commit/c2d9dffe96f645d2043f62335ef97bdc381b37b1))
|
|
108
|
+
|
|
1
109
|
## [1.2.4-alpha.1](https://github.com/camunda/orchestration-cluster-api-js/compare/v1.2.3...v1.2.4-alpha.1) (2026-01-22)
|
|
2
110
|
|
|
3
111
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Camunda 8 Orchestration Cluster TypeScript SDK
|
|
2
2
|
|
|
3
|
+
<!-- WARNING: The content and specific structure of this file drives Docusaurus generation in camunda-docs. Also, code examples are injected during build. Please refer to MAINTAINER.md before editing. -->
|
|
4
|
+
|
|
3
5
|
Type‑safe, promise‑based client for the Camunda 8 Orchestration Cluster REST API.
|
|
4
6
|
|
|
5
7
|
## Highlights
|
|
@@ -13,7 +15,8 @@ Type‑safe, promise‑based client for the Camunda 8 Orchestration Cluster REST
|
|
|
13
15
|
- Eventual consistency helper for polling endpoints
|
|
14
16
|
- Immutable, deep‑frozen configuration accessible through a factory‑created client instance
|
|
15
17
|
- Automatic body-level tenantId defaulting: if a request body supports an optional tenantId and you omit it, the SDK fills it from CAMUNDA_DEFAULT_TENANT_ID (path params are never auto-filled)
|
|
16
|
-
- Automatic transient HTTP retry (429, 503, network) with exponential backoff + full jitter (configurable via CAMUNDA_SDK_HTTP_RETRY\*). Non-retryable 500s fail fast.
|
|
18
|
+
- Automatic transient HTTP retry (429, 503, network) with exponential backoff + full jitter (configurable via CAMUNDA_SDK_HTTP_RETRY\*). Non-retryable 500s fail fast.
|
|
19
|
+
- Per-method retry override: disable or customize retry policy on any individual API call without changing global settings
|
|
17
20
|
|
|
18
21
|
## Install
|
|
19
22
|
|
|
@@ -28,10 +31,31 @@ Runtime support:
|
|
|
28
31
|
|
|
29
32
|
For older Node versions supply a fetch ponyfill AND a `File` shim (or upgrade). For legacy browsers, add a fetch polyfill (e.g. `whatwg-fetch`).
|
|
30
33
|
|
|
34
|
+
### Versioning
|
|
35
|
+
|
|
36
|
+
This SDK has a different release cadence from the Camunda server. Features and fixes land in the SDK during a server release.
|
|
37
|
+
|
|
38
|
+
The major version of the SDK signals a 1:1 type coherence with the server API for a Camunda minor release.
|
|
39
|
+
|
|
40
|
+
SDK version `n.y.z` -> server version `8.n`, so the type surface of SDK version 9.y.z matches the API surface of Camunda 8.9.
|
|
41
|
+
|
|
42
|
+
Using a later SDK version, for example: SDK version 10.y.z with Camunda 8.9, means that the SDK contains additive surfaces that are not guaranteed at runtime, and the compiler cannot warn of unsupported operations.
|
|
43
|
+
|
|
44
|
+
Using an earlier SDK version, for example: SDK version 9.y.z with Camunda 8.10, results in slightly degraded compiler reasoning: exhaustiveness checks cannot be guaranteed by the compiler for any extended surfaces (principally, enums with added members).
|
|
45
|
+
|
|
46
|
+
In the vast majority of use-cases, this will not be an issue; but you should be aware that using the matching SDK major version for the server minor version provides the strongest compiler guarantees about runtime reliability.
|
|
47
|
+
|
|
48
|
+
**Recommended approach**:
|
|
49
|
+
|
|
50
|
+
- Check the [CHANGELOG](https://github.com/camunda/orchestration-cluster-api-js/releases).
|
|
51
|
+
- As a sanity check during server version upgrade, rebuild applications with the matching SDK major version to identify any affected runtime surfaces.
|
|
52
|
+
|
|
31
53
|
## Quick Start (Zero‑Config – Recommended)
|
|
32
54
|
|
|
33
55
|
Keep configuration out of application code. Let the factory read `CAMUNDA_*` variables from the environment (12‑factor style). This makes rotation, secret management, and environment promotion safer & simpler.
|
|
34
56
|
|
|
57
|
+
<!-- snippet:ReadmeDefaultImport+ReadmeQuickStart -->
|
|
58
|
+
|
|
35
59
|
```ts
|
|
36
60
|
import createCamundaClient from '@camunda8/orchestration-cluster-api';
|
|
37
61
|
|
|
@@ -72,6 +96,8 @@ CAMUNDA_SDK_HTTP_RETRY_MAX_DELAY_MS=2000 # optional: cap (ms)
|
|
|
72
96
|
|
|
73
97
|
Use only when you must supply or mutate configuration dynamically (e.g. multi‑tenant routing, tests, ephemeral preview environments) or in the browser. Keys mirror their `CAMUNDA_*` env names.
|
|
74
98
|
|
|
99
|
+
<!-- snippet:ReadmeOverrides -->
|
|
100
|
+
|
|
75
101
|
```ts
|
|
76
102
|
const camunda = createCamundaClient({
|
|
77
103
|
config: {
|
|
@@ -87,6 +113,8 @@ const camunda = createCamundaClient({
|
|
|
87
113
|
|
|
88
114
|
Inject a custom `fetch` to add tracing, mock responses, instrumentation, circuit breakers, etc.
|
|
89
115
|
|
|
116
|
+
<!-- snippet:ReadmeCustomFetch -->
|
|
117
|
+
|
|
90
118
|
```ts
|
|
91
119
|
const camunda = createCamundaClient({
|
|
92
120
|
fetch: (input, init) => {
|
|
@@ -132,15 +160,63 @@ Behavior:
|
|
|
132
160
|
- `strict` - fail on type mismatch or missing required fields
|
|
133
161
|
- `fanatical` - fail on type mismatch, missing required fields, or unknown additional fields
|
|
134
162
|
|
|
163
|
+
## Per-Method Retry Override
|
|
164
|
+
|
|
165
|
+
Every API method accepts an optional trailing `options` parameter that lets you override or disable the global retry policy for that single call.
|
|
166
|
+
|
|
167
|
+
### Disable Retry for a Single Call
|
|
168
|
+
|
|
169
|
+
<!-- snippet:ReadmeDisableRetry -->
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
// This call will not retry on transient errors
|
|
173
|
+
await camunda.completeJob({ jobKey }, { retry: false });
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Override Specific Retry Settings
|
|
177
|
+
|
|
178
|
+
Pass a partial `HttpRetryPolicy` to override individual fields. Unspecified fields inherit from the global configuration.
|
|
179
|
+
|
|
180
|
+
<!-- snippet:ReadmeRetryOverride -->
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
// More aggressive retry for this operation only
|
|
184
|
+
await camunda.createProcessInstance(
|
|
185
|
+
{ processDefinitionId: ProcessDefinitionId.assumeExists('payment-process') },
|
|
186
|
+
{ retry: { maxAttempts: 8, maxDelayMs: 5000 } }
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
// Minimal retry: single retry with short backoff
|
|
190
|
+
await camunda.getTopology({ retry: { maxAttempts: 2, baseDelayMs: 50 } });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### How It Works
|
|
194
|
+
|
|
195
|
+
| `options.retry` value | Behavior |
|
|
196
|
+
| --------------------- | -------------------------------------------------------------------- |
|
|
197
|
+
| omitted / `undefined` | Uses global policy (`CAMUNDA_SDK_HTTP_RETRY_*` env vars) |
|
|
198
|
+
| `false` | Disables retry entirely (single attempt, no backoff) |
|
|
199
|
+
| `{ maxAttempts: 5 }` | Merges with global policy — only the specified fields are overridden |
|
|
200
|
+
|
|
201
|
+
The `HttpRetryPolicy` fields available for override:
|
|
202
|
+
|
|
203
|
+
| Field | Type | Description |
|
|
204
|
+
| ------------- | -------- | --------------------------------------- |
|
|
205
|
+
| `maxAttempts` | `number` | Total attempts (initial + retries) |
|
|
206
|
+
| `baseDelayMs` | `number` | Base delay for exponential backoff (ms) |
|
|
207
|
+
| `maxDelayMs` | `number` | Maximum delay cap (ms) |
|
|
208
|
+
|
|
135
209
|
## Advanced HTTP Retry: Cockatiel Adapter (Optional)
|
|
136
210
|
|
|
137
|
-
|
|
211
|
+
For advanced resilience patterns beyond per-method overrides — circuit breakers, timeouts, custom classification, combining policies — you can integrate [cockatiel](https://github.com/connor4312/cockatiel).
|
|
212
|
+
|
|
213
|
+
> **Tip:** For most use cases, per-method retry override (above) is sufficient. Reach for Cockatiel when you need circuit breaking, hedging, or bulkhead controls.
|
|
138
214
|
|
|
139
215
|
### When To Use Cockatiel
|
|
140
216
|
|
|
141
|
-
- You need different retry policies per operation (e.g. idempotent GET vs mutating POST)
|
|
142
217
|
- You want circuit breaking, hedging, timeout, or bulkhead controls
|
|
143
218
|
- You want to add custom classification (e.g. retry certain 5xx only on safe verbs)
|
|
219
|
+
- You need to compose multiple resilience policies together
|
|
144
220
|
|
|
145
221
|
### Disable Built‑In HTTP Retries
|
|
146
222
|
|
|
@@ -275,7 +351,7 @@ const policy = retry(classify, {
|
|
|
275
351
|
- Keep SDK retries disabled to prevent duplicate layers.
|
|
276
352
|
- SDK synthesizes `Error` objects with a `status` for retry-significant HTTP responses (429, 503, 500), enabling classification.
|
|
277
353
|
- You can tag errors (e.g. assign `err.__opVerb`) in a wrapper if verb-level logic is needed.
|
|
278
|
-
-
|
|
354
|
+
- For per-operation retry customization without external dependencies, use the built-in [per-method retry override](#per-method-retry-override) instead.
|
|
279
355
|
|
|
280
356
|
> Combine cockatiel retry with a circuit breaker, timeout, or bulkhead policy for more robust behavior in partial outages.
|
|
281
357
|
|
|
@@ -377,12 +453,29 @@ Factors use integer percentages to avoid floating point drift in env parsing; th
|
|
|
377
453
|
|
|
378
454
|
If you have concrete tuning needs, open an issue describing workload patterns (operation mix, baseline concurrency, observed broker limits) to help prioritize which knobs to surface.
|
|
379
455
|
|
|
456
|
+
### What Should I Set?
|
|
457
|
+
|
|
458
|
+
If you're unsure about your workload shape, **don't set anything**. The default BALANCED profile activates automatically and outperforms no-gating (LEGACY) in most scenarios — on raw throughput alone, not just error reduction.
|
|
459
|
+
|
|
460
|
+
Benchmark results against a single-node local cluster with multiple independent clients (no shared state between them):
|
|
461
|
+
|
|
462
|
+
| Scenario | BALANCED | LEGACY (no gating) |
|
|
463
|
+
| ----------------------------- | --------------- | ------------------ |
|
|
464
|
+
| Single-client (1K processes) | **80.1 ops/s** | 67.8 ops/s |
|
|
465
|
+
| Single-client sustained (10K) | **119.6 ops/s** | 87.8 ops/s |
|
|
466
|
+
| Multi-client 3+2 spike | **86.3 ops/s** | 48.0 ops/s |
|
|
467
|
+
| Stress 8 clients ×1000 | 76.3 ops/s | **106.4 ops/s** |
|
|
468
|
+
|
|
469
|
+
BALANCED wins 3 of 4 on pure throughput. The only scenario where LEGACY is faster is extreme overload (800 concurrent requests against a single broker) — and in that case LEGACY accumulates 44,505 errors vs BALANCED's 15,527. The default just works.
|
|
470
|
+
|
|
380
471
|
## Job Workers (Polling API)
|
|
381
472
|
|
|
382
473
|
The SDK provides a lightweight polling job worker for service task job types using `createJobWorker`. It activates jobs in batches (respecting a concurrency limit), validates variables (optional), and offers action helpers on each job.
|
|
383
474
|
|
|
384
475
|
### Minimal Example
|
|
385
476
|
|
|
477
|
+
<!-- snippet:ReadmeJobWorkerImport+ReadmeJobWorkerMinimal -->
|
|
478
|
+
|
|
386
479
|
```ts
|
|
387
480
|
import createCamundaClient from '@camunda8/orchestration-cluster-api';
|
|
388
481
|
import { z } from 'zod';
|
|
@@ -396,7 +489,7 @@ const Output = z.object({ processed: z.boolean() });
|
|
|
396
489
|
const worker = client.createJobWorker({
|
|
397
490
|
jobType: 'process-order',
|
|
398
491
|
maxParallelJobs: 10,
|
|
399
|
-
|
|
492
|
+
jobTimeoutMs: 15_000, // long‑poll timeout (server side requestTimeout)
|
|
400
493
|
pollIntervalMs: 100, // delay between polls when no jobs / at capacity
|
|
401
494
|
// Optional: only fetch specific variables during activation
|
|
402
495
|
fetchVariables: ['orderId'],
|
|
@@ -404,9 +497,11 @@ const worker = client.createJobWorker({
|
|
|
404
497
|
outputSchema: Output, // validates variables passed to complete(...)
|
|
405
498
|
validateSchemas: true, // set false for max throughput (skip Zod)
|
|
406
499
|
autoStart: true, // default true; start polling immediately
|
|
500
|
+
startupJitterMaxSeconds: 5, // random delay up to 5s before first poll (default 0)
|
|
407
501
|
jobHandler: (job) => {
|
|
408
502
|
// Access typed variables
|
|
409
503
|
const vars = job.variables; // inferred from Input schema
|
|
504
|
+
console.log(`Processing order: ${vars.orderId}`);
|
|
410
505
|
// Do work...
|
|
411
506
|
return job.complete({ variables: { processed: true } });
|
|
412
507
|
},
|
|
@@ -426,6 +521,8 @@ TypeScript inference:
|
|
|
426
521
|
|
|
427
522
|
- When you provide `inputSchema`, the type of `fetchVariables` is constrained to the keys of the inferred `variables` type from that schema. Example:
|
|
428
523
|
|
|
524
|
+
<!-- snippet:ReadmeJobWorkerInference -->
|
|
525
|
+
|
|
429
526
|
```ts
|
|
430
527
|
const Input = z.object({ orderId: z.string(), amount: z.number() });
|
|
431
528
|
client.createJobWorker({
|
|
@@ -503,6 +600,8 @@ If `validateSchemas` is true:
|
|
|
503
600
|
|
|
504
601
|
Use `await worker.stopGracefully({ waitUpToMs?, checkIntervalMs? })` to drain without force‑cancelling the current activation request.
|
|
505
602
|
|
|
603
|
+
<!-- snippet:ReadmeJobWorkerGraceful -->
|
|
604
|
+
|
|
506
605
|
```ts
|
|
507
606
|
// Attempt graceful drain for up to 8 seconds
|
|
508
607
|
const { remainingJobs, timedOut } = await worker.stopGracefully({ waitUpToMs: 8000 });
|
|
@@ -526,12 +625,33 @@ Activation cancellations during stop are logged at debug (`activation.cancelled`
|
|
|
526
625
|
|
|
527
626
|
You can register multiple workers on a single client instance—one per job type is typical. The client exposes `client.getWorkers()` for inspection and `client.stopAllWorkers()` for coordinated shutdown.
|
|
528
627
|
|
|
628
|
+
### Startup Jitter
|
|
629
|
+
|
|
630
|
+
When deploying multiple application instances simultaneously (e.g. a rolling restart or scale-up), all workers start polling at the same time and can saturate the server with activation requests. Set `startupJitterMaxSeconds` to spread out the initial poll across a random window:
|
|
631
|
+
|
|
632
|
+
<!-- snippet:ReadmeJobWorkerJitter -->
|
|
633
|
+
|
|
634
|
+
```ts
|
|
635
|
+
client.createJobWorker({
|
|
636
|
+
jobType: 'process-order',
|
|
637
|
+
maxParallelJobs: 10,
|
|
638
|
+
jobTimeoutMs: 30_000,
|
|
639
|
+
startupJitterMaxSeconds: 5, // each instance delays 0–5s before first poll
|
|
640
|
+
jobHandler: async (job) => job.complete(),
|
|
641
|
+
});
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
A value of `0` (the default) means no delay.
|
|
645
|
+
|
|
529
646
|
### Receipt Type (Unique Symbol)
|
|
530
647
|
|
|
531
648
|
Action methods return a unique symbol (not a string) to avoid accidental misuse and allow internal metrics. If you store the receipt, annotate its type as `JobActionReceipt` to preserve uniqueness:
|
|
532
649
|
|
|
650
|
+
<!-- snippet:ReadmeReceiptImport+ReadmeReceipt -->
|
|
651
|
+
|
|
533
652
|
```ts
|
|
534
|
-
import { JobActionReceipt } from '@camunda8/orchestration-cluster-api';
|
|
653
|
+
import type { JobActionReceipt } from '@camunda8/orchestration-cluster-api';
|
|
654
|
+
|
|
535
655
|
const receipt: JobActionReceipt = await job.complete({ variables: { processed: true } });
|
|
536
656
|
```
|
|
537
657
|
|
|
@@ -575,6 +695,110 @@ Call `client.getBackpressureState()` to obtain:
|
|
|
575
695
|
}
|
|
576
696
|
```
|
|
577
697
|
|
|
698
|
+
### Threaded Job Workers (Node.js Only)
|
|
699
|
+
|
|
700
|
+
For CPU-intensive job handlers, `createThreadedJobWorker` offloads handler execution to a pool of Node.js `worker_threads`. Polling and I/O remain on the main event loop, while handler logic runs in parallel threads — dramatically improving throughput when the handler does CPU-bound work (JSON processing, validation, transformation, cryptography).
|
|
701
|
+
|
|
702
|
+
#### When to use
|
|
703
|
+
|
|
704
|
+
- Your handler spends significant time on CPU work (not just waiting for HTTP responses)
|
|
705
|
+
- You observe that a single-threaded worker saturates one CPU core while throughput plateaus
|
|
706
|
+
- You need to process more jobs per second without deploying additional instances
|
|
707
|
+
|
|
708
|
+
If your handler is mostly I/O-bound (HTTP calls, database queries), the standard `createJobWorker` is sufficient.
|
|
709
|
+
|
|
710
|
+
#### Handler module
|
|
711
|
+
|
|
712
|
+
The handler must be a **separate file** (not an inline function) that exports a default async function:
|
|
713
|
+
|
|
714
|
+
```ts
|
|
715
|
+
// my-handler.ts (or my-handler.js)
|
|
716
|
+
import type { ThreadedJobHandler } from '@camunda8/orchestration-cluster-api';
|
|
717
|
+
|
|
718
|
+
const handler: ThreadedJobHandler = async (job, client) => {
|
|
719
|
+
const { orderId } = job.variables;
|
|
720
|
+
// CPU-intensive work here...
|
|
721
|
+
const result = heavyComputation(orderId);
|
|
722
|
+
return job.complete({ result });
|
|
723
|
+
};
|
|
724
|
+
export default handler;
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
Typing your handler as `ThreadedJobHandler` gives full intellisense for `job` (variables, action methods like `complete()`, `fail()`, `error()`) and `client` (every `CamundaClient` API method).
|
|
728
|
+
|
|
729
|
+
The handler receives two arguments:
|
|
730
|
+
|
|
731
|
+
1. **`job`** — a proxy with the same shape as a regular job worker job (`variables`, `customHeaders`, `jobKey`, plus action methods: `complete()`, `fail()`, `error()`, `cancelWorkflow()`, `ignore()`)
|
|
732
|
+
2. **`client`** — a proxy to the `CamundaClient` on the main thread. You can call any SDK method (e.g. `client.publishMessage(...)`, `client.createProcessInstance(...)`) and it will be forwarded to the main thread and executed there.
|
|
733
|
+
|
|
734
|
+
#### Minimal example
|
|
735
|
+
|
|
736
|
+
<!-- snippet:ReadmeThreadedWorkerImport+ReadmeThreadedWorker -->
|
|
737
|
+
|
|
738
|
+
```ts
|
|
739
|
+
import createCamundaClient from '@camunda8/orchestration-cluster-api';
|
|
740
|
+
import path from 'node:path';
|
|
741
|
+
import { fileURLToPath } from 'node:url';
|
|
742
|
+
|
|
743
|
+
const client = createCamundaClient();
|
|
744
|
+
|
|
745
|
+
const worker = client.createThreadedJobWorker({
|
|
746
|
+
jobType: 'cpu-heavy-task',
|
|
747
|
+
handlerModule: path.join(path.dirname(fileURLToPath(import.meta.url)), 'my-handler.js'),
|
|
748
|
+
maxParallelJobs: 32,
|
|
749
|
+
jobTimeoutMs: 30_000,
|
|
750
|
+
});
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
#### Configuration
|
|
754
|
+
|
|
755
|
+
`createThreadedJobWorker` accepts all the same options as `createJobWorker` (except `jobHandler`), plus:
|
|
756
|
+
|
|
757
|
+
| Option | Type | Default | Description |
|
|
758
|
+
| ---------------- | -------- | --------------------------- | ---------------------------------------------------------------- |
|
|
759
|
+
| `handlerModule` | `string` | (required) | Path to handler module (absolute or relative to `process.cwd()`) |
|
|
760
|
+
| `threadPoolSize` | `number` | `os.availableParallelism()` | Number of worker threads in the pool |
|
|
761
|
+
|
|
762
|
+
Other familiar options: `jobType`, `maxParallelJobs`, `jobTimeoutMs`, `pollIntervalMs`, `pollTimeoutMs`, `fetchVariables`, `inputSchema`, `outputSchema`, `customHeadersSchema`, `validateSchemas`, `autoStart`, `startupJitterMaxSeconds`, `workerName`.
|
|
763
|
+
|
|
764
|
+
#### Lifecycle
|
|
765
|
+
|
|
766
|
+
Threaded workers integrate with the same lifecycle as regular workers:
|
|
767
|
+
|
|
768
|
+
```ts
|
|
769
|
+
// Returned by getWorkers()
|
|
770
|
+
const allWorkers = client.getWorkers();
|
|
771
|
+
|
|
772
|
+
// Stopped by stopAllWorkers()
|
|
773
|
+
client.stopAllWorkers();
|
|
774
|
+
|
|
775
|
+
// Graceful shutdown (waits for in-flight jobs to finish)
|
|
776
|
+
const { timedOut, remainingJobs } = await worker.stopGracefully({ waitUpToMs: 10_000 });
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
#### Pool stats
|
|
780
|
+
|
|
781
|
+
```ts
|
|
782
|
+
worker.poolSize; // number of threads
|
|
783
|
+
worker.busyThreads; // threads currently processing a job
|
|
784
|
+
worker.activeJobs; // total jobs dispatched but not yet completed
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
#### How it works
|
|
788
|
+
|
|
789
|
+
1. The main thread polls `activateJobs` using the same mechanism as `createJobWorker`
|
|
790
|
+
2. Activated jobs are serialized and dispatched to an idle thread via `MessageChannel`
|
|
791
|
+
3. The thread loads the handler module (lazy, on first job), creates a proxy for `job` action methods and `client` API calls
|
|
792
|
+
4. Action methods (`job.complete()`, `job.fail()`, etc.) and client calls are forwarded back to the main thread over the `MessagePort` and executed there
|
|
793
|
+
5. The result is relayed back, and the thread is marked idle for the next job
|
|
794
|
+
|
|
795
|
+
#### Constraints
|
|
796
|
+
|
|
797
|
+
- **Node.js only**: `worker_threads` is not available in browsers or Deno
|
|
798
|
+
- **Handler must be a file module**: Inline functions cannot be transferred to threads
|
|
799
|
+
- **Job variables must be JSON-serializable**: Functions and class instances on the job are stripped during transfer
|
|
800
|
+
- **Client calls are async round-trips**: Each `client.xyz()` call crosses a thread boundary, adding a small amount of latency per call
|
|
801
|
+
|
|
578
802
|
---
|
|
579
803
|
|
|
580
804
|
## Authentication
|
|
@@ -661,8 +885,10 @@ If both cert & key are available an https.Agent is attached to all outbound call
|
|
|
661
885
|
|
|
662
886
|
Import branded key helpers directly:
|
|
663
887
|
|
|
888
|
+
<!-- snippet:ReadmeBrandedKeysImport+ReadmeBrandedKeys -->
|
|
889
|
+
|
|
664
890
|
```ts
|
|
665
|
-
import { ProcessDefinitionKey, ProcessInstanceKey } from '@camunda8/orchestration-cluster';
|
|
891
|
+
import { ProcessDefinitionKey, ProcessInstanceKey } from '@camunda8/orchestration-cluster-api';
|
|
666
892
|
|
|
667
893
|
const defKey = ProcessDefinitionKey.assumeExists('2251799813686749');
|
|
668
894
|
// @ts-expect-error – cannot assign def key to instance key
|
|
@@ -675,8 +901,13 @@ They are zero‑cost runtime strings with compile‑time separation.
|
|
|
675
901
|
|
|
676
902
|
All methods return a `CancelablePromise<T>`:
|
|
677
903
|
|
|
904
|
+
<!-- snippet:ReadmeCancelable -->
|
|
905
|
+
|
|
678
906
|
```ts
|
|
679
|
-
const p = camunda.searchProcessInstances(
|
|
907
|
+
const p = camunda.searchProcessInstances(
|
|
908
|
+
{ filter: { processDefinitionKey: defKey } },
|
|
909
|
+
{ consistency: { waitUpToMs: 0 } }
|
|
910
|
+
);
|
|
680
911
|
setTimeout(() => p.cancel(), 100); // best‑effort cancel
|
|
681
912
|
try {
|
|
682
913
|
await p; // resolves if not cancelled
|
|
@@ -774,16 +1005,22 @@ Use this to understand convergence speed and data shape evolution during tests o
|
|
|
774
1005
|
|
|
775
1006
|
### Example
|
|
776
1007
|
|
|
1008
|
+
<!-- snippet:ReadmeEventualConsistency -->
|
|
1009
|
+
|
|
777
1010
|
```ts
|
|
778
|
-
const jobs = await camunda.searchJobs(
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
waitUpToMs: 5000,
|
|
782
|
-
pollIntervalMs: 200,
|
|
783
|
-
trace: true,
|
|
784
|
-
predicate: (r) => Array.isArray(r.items) && r.items.some((j) => j.state === 'CREATED'),
|
|
1011
|
+
const jobs = await camunda.searchJobs(
|
|
1012
|
+
{
|
|
1013
|
+
filter: { type: 'payment' },
|
|
785
1014
|
},
|
|
786
|
-
|
|
1015
|
+
{
|
|
1016
|
+
consistency: {
|
|
1017
|
+
waitUpToMs: 5000,
|
|
1018
|
+
pollIntervalMs: 200,
|
|
1019
|
+
trace: true,
|
|
1020
|
+
predicate: (r) => Array.isArray(r.items) && r.items.some((j) => j.state === 'CREATED'),
|
|
1021
|
+
},
|
|
1022
|
+
}
|
|
1023
|
+
);
|
|
787
1024
|
```
|
|
788
1025
|
|
|
789
1026
|
On timeout an `EventualConsistencyTimeoutError` includes diagnostic fields: `{ attempts, elapsedMs, lastStatus, lastResponse, operationId }`.
|
|
@@ -792,6 +1029,8 @@ On timeout an `EventualConsistencyTimeoutError` includes diagnostic fields: `{ a
|
|
|
792
1029
|
|
|
793
1030
|
Per‑client logger; no global singleton. The level defaults from `CAMUNDA_SDK_LOG_LEVEL` (default `error`).
|
|
794
1031
|
|
|
1032
|
+
<!-- snippet:ReadmeLogging -->
|
|
1033
|
+
|
|
795
1034
|
```ts
|
|
796
1035
|
const client = createCamundaClient({
|
|
797
1036
|
log: {
|
|
@@ -929,9 +1168,10 @@ May throw:
|
|
|
929
1168
|
|
|
930
1169
|
All SDK-thrown operational errors normalize to a discriminated union (`SdkError`) when they originate from HTTP, network, auth, or validation layers. Use the guard `isSdkError` to narrow inside a catch:
|
|
931
1170
|
|
|
1171
|
+
<!-- snippet:ReadmeErrorHandlingImport+ReadmeErrorHandling -->
|
|
1172
|
+
|
|
932
1173
|
```ts
|
|
933
|
-
import { createCamundaClient } from '@camunda8/orchestration-cluster-api';
|
|
934
|
-
import { isSdkError } from '@camunda8/orchestration-cluster-api/dist/runtime/errors';
|
|
1174
|
+
import { createCamundaClient, isSdkError } from '@camunda8/orchestration-cluster-api';
|
|
935
1175
|
|
|
936
1176
|
const client = createCamundaClient();
|
|
937
1177
|
|
|
@@ -978,13 +1218,15 @@ _Note that this feature is experimental and subject to change._
|
|
|
978
1218
|
|
|
979
1219
|
If you prefer FP‑style explicit error handling instead of exceptions, use the result client wrapper:
|
|
980
1220
|
|
|
1221
|
+
<!-- snippet:ReadmeResultClientImport+ReadmeResultClient -->
|
|
1222
|
+
|
|
981
1223
|
```ts
|
|
982
|
-
import { createCamundaResultClient, isOk } from '@camunda8/orchestration-cluster';
|
|
1224
|
+
import { createCamundaResultClient, isOk } from '@camunda8/orchestration-cluster-api';
|
|
983
1225
|
|
|
984
1226
|
const camundaR = createCamundaResultClient();
|
|
985
1227
|
const res = await camundaR.createDeployment({ resources: [file] });
|
|
986
1228
|
if (isOk(res)) {
|
|
987
|
-
console.log('Deployment key', res.value.
|
|
1229
|
+
console.log('Deployment key', res.value.deploymentKey);
|
|
988
1230
|
} else {
|
|
989
1231
|
console.error('Deployment failed', res.error);
|
|
990
1232
|
}
|
|
@@ -1063,6 +1305,8 @@ The deployment endpoint requires each resource to have a filename (extension use
|
|
|
1063
1305
|
|
|
1064
1306
|
### Browser
|
|
1065
1307
|
|
|
1308
|
+
<!-- snippet:ReadmeDeployBrowser -->
|
|
1309
|
+
|
|
1066
1310
|
```ts
|
|
1067
1311
|
const bpmnXml = `<definitions id="process" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">...</definitions>`;
|
|
1068
1312
|
const file = new File([bpmnXml], 'order-process.bpmn', { type: 'application/xml' });
|
|
@@ -1082,6 +1326,8 @@ await camunda.createDeployment({ resources: [file] });
|
|
|
1082
1326
|
|
|
1083
1327
|
Use the built-in helper `deployResourcesFromFiles(...)` to read local files and create `File` objects automatically. It returns the enriched `ExtendedDeploymentResult` (adds typed arrays: `processes`, `decisions`, `decisionRequirements`, `forms`, `resources`).
|
|
1084
1328
|
|
|
1329
|
+
<!-- snippet:ReadmeDeployNode -->
|
|
1330
|
+
|
|
1085
1331
|
```ts
|
|
1086
1332
|
const result = await camunda.deployResourcesFromFiles([
|
|
1087
1333
|
'./bpmn/order-process.bpmn',
|
|
@@ -1132,6 +1378,8 @@ Empty arrays are rejected. Always use correct extensions so the server can class
|
|
|
1132
1378
|
|
|
1133
1379
|
Create isolated clients per test file:
|
|
1134
1380
|
|
|
1381
|
+
<!-- snippet:ReadmeTestingClient -->
|
|
1382
|
+
|
|
1135
1383
|
```ts
|
|
1136
1384
|
const client = createCamundaClient({
|
|
1137
1385
|
config: { CAMUNDA_REST_ADDRESS: 'http://localhost:8080', CAMUNDA_AUTH_STRATEGY: 'NONE' },
|
|
@@ -1140,6 +1388,8 @@ const client = createCamundaClient({
|
|
|
1140
1388
|
|
|
1141
1389
|
Inject a mock fetch:
|
|
1142
1390
|
|
|
1391
|
+
<!-- snippet:ReadmeTestingMock -->
|
|
1392
|
+
|
|
1143
1393
|
```ts
|
|
1144
1394
|
const client = createCamundaClient({
|
|
1145
1395
|
fetch: async (input, init) => new Response(JSON.stringify({ ok: true }), { status: 200 }),
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
|
|
13
1
|
// src/runtime/logger.ts
|
|
14
2
|
var ORDER = {
|
|
15
3
|
silent: 0,
|
|
@@ -84,8 +72,6 @@ function createLogger(opts = {}) {
|
|
|
84
72
|
}
|
|
85
73
|
|
|
86
74
|
export {
|
|
87
|
-
__require,
|
|
88
|
-
__export,
|
|
89
75
|
createLogger
|
|
90
76
|
};
|
|
91
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-2N2LUTZ2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/logger.ts"],"sourcesContent":["// Per-client logger (no global singleton). Construct via createLogger.\n\n// Added 'silly' for deep diagnostics (unsafe: logs HTTP bodies when enabled elsewhere)\nexport type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silly';\nexport interface LogEvent {\n level: LogLevel;\n scope: string;\n ts: number;\n args: any[];\n code?: string;\n data?: any;\n}\nexport type LogTransport = (e: LogEvent) => void;\nconst ORDER: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n trace: 5,\n silly: 6,\n};\n\nexport interface Logger {\n level(): LogLevel;\n setLevel(level: LogLevel): void; // internal use\n setTransport(t?: LogTransport): void; // internal use\n error(...a: any[]): void;\n warn(...a: any[]): void;\n info(...a: any[]): void;\n debug(...a: any[]): void;\n trace(...a: any[]): void;\n silly(...a: any[]): void;\n scope(child: string): Logger;\n code(level: LogLevel, code: string, msg: string, data?: any): void;\n}\n\nexport interface CreateLoggerOptions {\n level?: LogLevel;\n transport?: LogTransport;\n scope?: string;\n}\n\nexport function createLogger(opts: CreateLoggerOptions = {}): Logger {\n let currentLevel: LogLevel = opts.level || 'error';\n let transport: LogTransport | undefined = opts.transport;\n const baseScope = opts.scope || '';\n\n function isEnabled(need: LogLevel) {\n return ORDER[currentLevel] >= ORDER[need];\n }\n function evalArgs(args: any[]): any[] {\n // Support lazy function args: if an arg is a function with zero arity, call it.\n return args.map((a) => (typeof a === 'function' && a.length === 0 ? a() : a)).flat();\n }\n function emit(level: LogLevel, scope: string, rawArgs: any[]) {\n if (!isEnabled(level)) return;\n const args = evalArgs(rawArgs);\n const evt: LogEvent = { level, scope, ts: Date.now(), args };\n if (transport) {\n try {\n transport(evt);\n } catch {\n /* ignore transport errors */\n }\n } else {\n const tag = `[camunda-sdk][${level}]${scope ? `[${scope}]` : ''}`;\n const method = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log';\n // eslint-disable-next-line no-console\n console[method](tag, ...args);\n }\n }\n function emitCode(level: LogLevel, scope: string, code: string, msg: string, data?: any) {\n if (!isEnabled(level)) return;\n const evt: LogEvent = { level, scope, ts: Date.now(), args: [msg], code, data };\n if (transport) {\n try {\n transport(evt);\n // eslint-disable-next-line no-empty\n } catch {}\n } else {\n const tag = `[camunda-sdk][${level}]${scope ? `[${scope}]` : ''}`;\n const method = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log';\n // eslint-disable-next-line no-console\n console[method](tag, code + ':', msg, data ?? '');\n }\n }\n const make = (scope: string): Logger => ({\n level: () => currentLevel,\n setLevel(l: LogLevel) {\n currentLevel = l;\n },\n setTransport(t?: LogTransport) {\n transport = t;\n },\n error: (...a: any[]) => emit('error', scope, a),\n warn: (...a: any[]) => emit('warn', scope, a),\n info: (...a: any[]) => emit('info', scope, a),\n debug: (...a: any[]) => emit('debug', scope, a),\n trace: (...a: any[]) => emit('trace', scope, a),\n silly: (...a: any[]) => emit('silly', scope, a),\n scope(child: string) {\n return make(scope ? `${scope}:${child}` : child);\n },\n code(l: LogLevel, code: string, msg: string, data?: any) {\n emitCode(l, scope, code, msg, data);\n },\n });\n return make(baseScope);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/runtime/logger.ts"],"sourcesContent":["// Per-client logger (no global singleton). Construct via createLogger.\n\n// Added 'silly' for deep diagnostics (unsafe: logs HTTP bodies when enabled elsewhere)\nexport type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silly';\nexport interface LogEvent {\n level: LogLevel;\n scope: string;\n ts: number;\n args: any[];\n code?: string;\n data?: any;\n}\nexport type LogTransport = (e: LogEvent) => void;\nconst ORDER: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n trace: 5,\n silly: 6,\n};\n\nexport interface Logger {\n level(): LogLevel;\n setLevel(level: LogLevel): void; // internal use\n setTransport(t?: LogTransport): void; // internal use\n error(...a: any[]): void;\n warn(...a: any[]): void;\n info(...a: any[]): void;\n debug(...a: any[]): void;\n trace(...a: any[]): void;\n silly(...a: any[]): void;\n scope(child: string): Logger;\n code(level: LogLevel, code: string, msg: string, data?: any): void;\n}\n\nexport interface CreateLoggerOptions {\n level?: LogLevel;\n transport?: LogTransport;\n scope?: string;\n}\n\nexport function createLogger(opts: CreateLoggerOptions = {}): Logger {\n let currentLevel: LogLevel = opts.level || 'error';\n let transport: LogTransport | undefined = opts.transport;\n const baseScope = opts.scope || '';\n\n function isEnabled(need: LogLevel) {\n return ORDER[currentLevel] >= ORDER[need];\n }\n function evalArgs(args: any[]): any[] {\n // Support lazy function args: if an arg is a function with zero arity, call it.\n return args.map((a) => (typeof a === 'function' && a.length === 0 ? a() : a)).flat();\n }\n function emit(level: LogLevel, scope: string, rawArgs: any[]) {\n if (!isEnabled(level)) return;\n const args = evalArgs(rawArgs);\n const evt: LogEvent = { level, scope, ts: Date.now(), args };\n if (transport) {\n try {\n transport(evt);\n } catch {\n /* ignore transport errors */\n }\n } else {\n const tag = `[camunda-sdk][${level}]${scope ? `[${scope}]` : ''}`;\n const method = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log';\n // eslint-disable-next-line no-console\n console[method](tag, ...args);\n }\n }\n function emitCode(level: LogLevel, scope: string, code: string, msg: string, data?: any) {\n if (!isEnabled(level)) return;\n const evt: LogEvent = { level, scope, ts: Date.now(), args: [msg], code, data };\n if (transport) {\n try {\n transport(evt);\n // eslint-disable-next-line no-empty\n } catch {}\n } else {\n const tag = `[camunda-sdk][${level}]${scope ? `[${scope}]` : ''}`;\n const method = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log';\n // eslint-disable-next-line no-console\n console[method](tag, code + ':', msg, data ?? '');\n }\n }\n const make = (scope: string): Logger => ({\n level: () => currentLevel,\n setLevel(l: LogLevel) {\n currentLevel = l;\n },\n setTransport(t?: LogTransport) {\n transport = t;\n },\n error: (...a: any[]) => emit('error', scope, a),\n warn: (...a: any[]) => emit('warn', scope, a),\n info: (...a: any[]) => emit('info', scope, a),\n debug: (...a: any[]) => emit('debug', scope, a),\n trace: (...a: any[]) => emit('trace', scope, a),\n silly: (...a: any[]) => emit('silly', scope, a),\n scope(child: string) {\n return make(scope ? `${scope}:${child}` : child);\n },\n code(l: LogLevel, code: string, msg: string, data?: any) {\n emitCode(l, scope, code, msg, data);\n },\n });\n return make(baseScope);\n}\n"],"mappings":";AAaA,IAAM,QAAkC;AAAA,EACtC,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;AAsBO,SAAS,aAAa,OAA4B,CAAC,GAAW;AACnE,MAAI,eAAyB,KAAK,SAAS;AAC3C,MAAI,YAAsC,KAAK;AAC/C,QAAM,YAAY,KAAK,SAAS;AAEhC,WAAS,UAAU,MAAgB;AACjC,WAAO,MAAM,YAAY,KAAK,MAAM,IAAI;AAAA,EAC1C;AACA,WAAS,SAAS,MAAoB;AAEpC,WAAO,KAAK,IAAI,CAAC,MAAO,OAAO,MAAM,cAAc,EAAE,WAAW,IAAI,EAAE,IAAI,CAAE,EAAE,KAAK;AAAA,EACrF;AACA,WAAS,KAAK,OAAiB,OAAe,SAAgB;AAC5D,QAAI,CAAC,UAAU,KAAK,EAAG;AACvB,UAAM,OAAO,SAAS,OAAO;AAC7B,UAAM,MAAgB,EAAE,OAAO,OAAO,IAAI,KAAK,IAAI,GAAG,KAAK;AAC3D,QAAI,WAAW;AACb,UAAI;AACF,kBAAU,GAAG;AAAA,MACf,QAAQ;AAAA,MAER;AAAA,IACF,OAAO;AACL,YAAM,MAAM,iBAAiB,KAAK,IAAI,QAAQ,IAAI,KAAK,MAAM,EAAE;AAC/D,YAAM,SAAS,UAAU,UAAU,UAAU,UAAU,SAAS,SAAS;AAEzE,cAAQ,MAAM,EAAE,KAAK,GAAG,IAAI;AAAA,IAC9B;AAAA,EACF;AACA,WAAS,SAAS,OAAiB,OAAe,MAAc,KAAa,MAAY;AACvF,QAAI,CAAC,UAAU,KAAK,EAAG;AACvB,UAAM,MAAgB,EAAE,OAAO,OAAO,IAAI,KAAK,IAAI,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,KAAK;AAC9E,QAAI,WAAW;AACb,UAAI;AACF,kBAAU,GAAG;AAAA,MAEf,QAAQ;AAAA,MAAC;AAAA,IACX,OAAO;AACL,YAAM,MAAM,iBAAiB,KAAK,IAAI,QAAQ,IAAI,KAAK,MAAM,EAAE;AAC/D,YAAM,SAAS,UAAU,UAAU,UAAU,UAAU,SAAS,SAAS;AAEzE,cAAQ,MAAM,EAAE,KAAK,OAAO,KAAK,KAAK,QAAQ,EAAE;AAAA,IAClD;AAAA,EACF;AACA,QAAM,OAAO,CAAC,WAA2B;AAAA,IACvC,OAAO,MAAM;AAAA,IACb,SAAS,GAAa;AACpB,qBAAe;AAAA,IACjB;AAAA,IACA,aAAa,GAAkB;AAC7B,kBAAY;AAAA,IACd;AAAA,IACA,OAAO,IAAI,MAAa,KAAK,SAAS,OAAO,CAAC;AAAA,IAC9C,MAAM,IAAI,MAAa,KAAK,QAAQ,OAAO,CAAC;AAAA,IAC5C,MAAM,IAAI,MAAa,KAAK,QAAQ,OAAO,CAAC;AAAA,IAC5C,OAAO,IAAI,MAAa,KAAK,SAAS,OAAO,CAAC;AAAA,IAC9C,OAAO,IAAI,MAAa,KAAK,SAAS,OAAO,CAAC;AAAA,IAC9C,OAAO,IAAI,MAAa,KAAK,SAAS,OAAO,CAAC;AAAA,IAC9C,MAAM,OAAe;AACnB,aAAO,KAAK,QAAQ,GAAG,KAAK,IAAI,KAAK,KAAK,KAAK;AAAA,IACjD;AAAA,IACA,KAAK,GAAa,MAAc,KAAa,MAAY;AACvD,eAAS,GAAG,OAAO,MAAM,KAAK,IAAI;AAAA,IACpC;AAAA,EACF;AACA,SAAO,KAAK,SAAS;AACvB;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-DGUM43GV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|