@bpmnkit/api 0.0.8

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.
Files changed (48) hide show
  1. package/README.md +150 -0
  2. package/dist/generated/admin-resources.d.ts +199 -0
  3. package/dist/generated/admin-resources.js +381 -0
  4. package/dist/generated/admin-types.d.ts +283 -0
  5. package/dist/generated/admin-types.js +4 -0
  6. package/dist/generated/resources.d.ts +1519 -0
  7. package/dist/generated/resources.js +2650 -0
  8. package/dist/generated/types.d.ts +11946 -0
  9. package/dist/generated/types.js +4 -0
  10. package/dist/index.d.ts +11 -0
  11. package/dist/index.js +10 -0
  12. package/dist/runtime/auth.d.ts +31 -0
  13. package/dist/runtime/auth.js +136 -0
  14. package/dist/runtime/cache.d.ts +13 -0
  15. package/dist/runtime/cache.js +48 -0
  16. package/dist/runtime/cache.test.d.ts +2 -0
  17. package/dist/runtime/cache.test.js +38 -0
  18. package/dist/runtime/client.d.ts +25 -0
  19. package/dist/runtime/client.js +33 -0
  20. package/dist/runtime/config.d.ts +15 -0
  21. package/dist/runtime/config.js +371 -0
  22. package/dist/runtime/errors.d.ts +53 -0
  23. package/dist/runtime/errors.js +101 -0
  24. package/dist/runtime/errors.test.d.ts +2 -0
  25. package/dist/runtime/errors.test.js +40 -0
  26. package/dist/runtime/events.d.ts +12 -0
  27. package/dist/runtime/events.js +48 -0
  28. package/dist/runtime/events.test.d.ts +2 -0
  29. package/dist/runtime/events.test.js +57 -0
  30. package/dist/runtime/http.d.ts +15 -0
  31. package/dist/runtime/http.js +210 -0
  32. package/dist/runtime/logger.d.ts +9 -0
  33. package/dist/runtime/logger.js +34 -0
  34. package/dist/runtime/relations.d.ts +43 -0
  35. package/dist/runtime/relations.js +54 -0
  36. package/dist/runtime/retry.d.ts +14 -0
  37. package/dist/runtime/retry.js +41 -0
  38. package/dist/runtime/retry.test.d.ts +2 -0
  39. package/dist/runtime/retry.test.js +46 -0
  40. package/dist/runtime/token-cache.d.ts +42 -0
  41. package/dist/runtime/token-cache.js +104 -0
  42. package/dist/runtime/types.d.ts +191 -0
  43. package/dist/runtime/types.js +2 -0
  44. package/dist/runtime/yaml.d.ts +14 -0
  45. package/dist/runtime/yaml.js +234 -0
  46. package/dist/runtime/yaml.test.d.ts +2 -0
  47. package/dist/runtime/yaml.test.js +93 -0
  48. package/package.json +31 -0
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/bpmn-sdk/monorepo/main/doc/logos/logo-2-gateway.svg" width="72" height="72" alt="BPMN Kit logo">
3
+ <h1>@bpmnkit/api</h1>
4
+ <p>TypeScript client for the Camunda 8 REST API — 180 typed operations, OAuth2, retries, and caching</p>
5
+
6
+ [![npm](https://img.shields.io/npm/v/@bpmnkit/api?style=flat-square&color=6244d7)](https://www.npmjs.com/package/@bpmnkit/api)
7
+ [![license](https://img.shields.io/npm/l/@bpmnkit/api?style=flat-square)](https://github.com/bpmnkit/monorepo/blob/main/LICENSE)
8
+ [![typescript](https://img.shields.io/badge/TypeScript-strict-6244d7?style=flat-square&logo=typescript&logoColor=white)](https://github.com/bpmnkit/monorepo)
9
+
10
+ [Documentation](https://bpmn-sdk-docs.pages.dev) · [GitHub](https://github.com/bpmnkit/monorepo) · [Changelog](https://github.com/bpmnkit/monorepo/blob/main/packages/api/CHANGELOG.md)
11
+ </div>
12
+
13
+ ---
14
+
15
+ ## Overview
16
+
17
+ `@bpmnkit/api` is a fully typed TypeScript SDK for the [Camunda 8 Orchestration Cluster REST API v2](https://docs.camunda.io/docs/apis-tools/camunda-api-rest/camunda-api-rest-overview/). Every endpoint, request body, and response shape is typed end-to-end.
18
+
19
+ ## Features
20
+
21
+ - **180 typed operations** across 30+ resource namespaces
22
+ - **502 TypeScript types** generated from the official OpenAPI spec
23
+ - **Authentication** — Bearer token, OAuth2 (auto-refresh), HTTP Basic
24
+ - **Retries** — configurable exponential backoff with jitter
25
+ - **Caching** — in-memory LRU + TTL cache for read operations
26
+ - **Events** — subscribe to request, response, error, retry, and cache events
27
+ - **Structured logging** — pluggable logger with configurable levels
28
+ - **Config resolution** — constructor → YAML file → environment variables
29
+ - **Token persistence** — disk cache for OAuth2 access tokens
30
+ - **Zero runtime dependencies**
31
+
32
+ ## Installation
33
+
34
+ ```sh
35
+ npm install @bpmnkit/api
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ```typescript
41
+ import { CamundaClient } from "@bpmnkit/api"
42
+
43
+ const client = new CamundaClient({
44
+ baseUrl: "https://cluster.camunda.io",
45
+ auth: {
46
+ type: "oauth2",
47
+ clientId: process.env.CAMUNDA_CLIENT_ID!,
48
+ clientSecret: process.env.CAMUNDA_CLIENT_SECRET!,
49
+ tokenUrl: "https://login.cloud.camunda.io/oauth/token",
50
+ audience: "zeebe.camunda.io",
51
+ },
52
+ })
53
+
54
+ // Deploy a process
55
+ await client.deployment.create({
56
+ resources: [{ name: "order.bpmn", content: bpmnXml }],
57
+ })
58
+
59
+ // Start a process instance
60
+ const instance = await client.processInstance.create({
61
+ processDefinitionId: "order-process",
62
+ variables: { orderId: "ORD-001", amount: 99.99 },
63
+ })
64
+
65
+ // Complete a user task
66
+ const tasks = await client.userTask.search({
67
+ filter: { processInstanceKey: instance.processInstanceKey },
68
+ })
69
+ await client.userTask.complete(tasks.items[0].userTaskKey, {
70
+ variables: { approved: true },
71
+ })
72
+ ```
73
+
74
+ ## Authentication
75
+
76
+ ```typescript
77
+ // OAuth2 (recommended for Camunda Cloud)
78
+ const client = new CamundaClient({
79
+ baseUrl: "...",
80
+ auth: { type: "oauth2", clientId: "...", clientSecret: "...", tokenUrl: "...", audience: "..." },
81
+ })
82
+
83
+ // Bearer token (static)
84
+ const client = new CamundaClient({
85
+ baseUrl: "...",
86
+ auth: { type: "bearer", token: "..." },
87
+ })
88
+
89
+ // HTTP Basic
90
+ const client = new CamundaClient({
91
+ baseUrl: "...",
92
+ auth: { type: "basic", username: "...", password: "..." },
93
+ })
94
+ ```
95
+
96
+ ## Resource Namespaces
97
+
98
+ | Namespace | Description |
99
+ |-----------|-------------|
100
+ | `client.processInstance` | CRUD + cancel + variables |
101
+ | `client.processDefinition` | Definitions, XML, start forms |
102
+ | `client.deployment` | Create, list, delete deployments |
103
+ | `client.job` | Activate, complete, fail, update |
104
+ | `client.userTask` | Search, complete, assign, update |
105
+ | `client.decisionDefinition` | List, XML, evaluate |
106
+ | `client.decisionInstance` | Search, get |
107
+ | `client.message` | Publish, correlate |
108
+ | `client.signal` | Broadcast |
109
+ | `client.incident` | Search, resolve |
110
+ | `client.variable` | Search, get |
111
+ | `client.flowNodeInstance` | Search, get |
112
+ | `client.user` | Search, create, update |
113
+ | `client.role` | Search, create, assign |
114
+ | `client.group` | Search, create, assign |
115
+ | `client.authorization` | Manage permissions |
116
+ | `client.tenant` | Multi-tenant management |
117
+ | `client.clock` | Time manipulation (testing) |
118
+
119
+ ## Error Handling
120
+
121
+ ```typescript
122
+ import { CamundaNotFoundError, CamundaRateLimitError } from "@bpmnkit/api"
123
+
124
+ try {
125
+ await client.processInstance.get(key)
126
+ } catch (err) {
127
+ if (err instanceof CamundaNotFoundError) console.log("Not found")
128
+ if (err instanceof CamundaRateLimitError) console.log("Rate limited")
129
+ }
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Related Packages
135
+
136
+ | Package | Description |
137
+ |---------|-------------|
138
+ | [`@bpmnkit/core`](https://www.npmjs.com/package/@bpmnkit/core) | BPMN/DMN/Form parser, builder, layout engine |
139
+ | [`@bpmnkit/canvas`](https://www.npmjs.com/package/@bpmnkit/canvas) | Zero-dependency SVG BPMN viewer |
140
+ | [`@bpmnkit/editor`](https://www.npmjs.com/package/@bpmnkit/editor) | Full-featured interactive BPMN editor |
141
+ | [`@bpmnkit/engine`](https://www.npmjs.com/package/@bpmnkit/engine) | Lightweight BPMN process execution engine |
142
+ | [`@bpmnkit/feel`](https://www.npmjs.com/package/@bpmnkit/feel) | FEEL expression language parser & evaluator |
143
+ | [`@bpmnkit/plugins`](https://www.npmjs.com/package/@bpmnkit/plugins) | 22 composable canvas plugins |
144
+ | [`@bpmnkit/ascii`](https://www.npmjs.com/package/@bpmnkit/ascii) | Render BPMN diagrams as Unicode ASCII art |
145
+ | [`@bpmnkit/profiles`](https://www.npmjs.com/package/@bpmnkit/profiles) | Shared auth, profile storage, and client factories for CLI & proxy |
146
+ | [`@bpmnkit/operate`](https://www.npmjs.com/package/@bpmnkit/operate) | Monitoring & operations frontend for Camunda clusters |
147
+
148
+ ## License
149
+
150
+ [MIT](https://github.com/bpmnkit/monorepo/blob/main/LICENSE) © bpmn-sdk
@@ -0,0 +1,199 @@
1
+ import type { CamundaClientInput } from "../runtime/types.js";
2
+ import { CamundaBaseClient } from "../runtime/client.js";
3
+ import { ResourceBase } from "../runtime/client.js";
4
+ import type * as Types from "./admin-types.js";
5
+ export declare class MetaResource extends ResourceBase {
6
+ /**
7
+ *
8
+ * This endpoint only exposes egress IP addresses for the related services.
9
+ * Expected changes will be published through the API at least 24 hours in advance.
10
+ * We expect interested customers to periodically read this list from the API and reflect the changes in their systems.
11
+ * @see GET /meta/ip-ranges
12
+ */
13
+ getMeta(): Promise<Types.MetaDto>;
14
+ }
15
+ export declare class MembersResource extends ResourceBase {
16
+ getMembers(): Promise<Array<Types.Member>>;
17
+ updateMembers(email: string, body: Types.PostMemberBody): Promise<void>;
18
+ deleteMember(email: string): Promise<void>;
19
+ }
20
+ export declare class ClustersResource extends ResourceBase {
21
+ /**
22
+ *
23
+ * Get Secure Connectivity status for a cluster
24
+ * @see GET /clusters/{clusterUuid}/secure-connectivity
25
+ */
26
+ getSecureConnectivityStatus(clusterUuid: string): Promise<{
27
+ status: Types.SecureConnectivityDto | unknown;
28
+ }>;
29
+ /**
30
+ *
31
+ * Activates Secure Connectivity for a cluster
32
+ * @see POST /clusters/{clusterUuid}/secure-connectivity
33
+ */
34
+ activateSecureConnectivity(clusterUuid: string, body: {
35
+ allowedPrincipals: Array<string>;
36
+ allowedRegions: Array<string>;
37
+ }): Promise<void>;
38
+ /**
39
+ *
40
+ * Deactivates Secure Connectivity for a cluster
41
+ * @see DELETE /clusters/{clusterUuid}/secure-connectivity
42
+ */
43
+ deactivateSecureConnectivity(clusterUuid: string): Promise<void>;
44
+ getSecrets(clusterUuid: string): Promise<Types.ClusterSecrets>;
45
+ /**
46
+ *
47
+ * Creates a new secret
48
+ * @see POST /clusters/{clusterUuid}/secrets
49
+ */
50
+ createSecret(clusterUuid: string, body: Types.CreateSecretBody): Promise<void>;
51
+ /**
52
+ *
53
+ * Updates a secret
54
+ * @see PUT /clusters/{clusterUuid}/secrets/{secretName}
55
+ */
56
+ updateSecret(clusterUuid: string, secretName: string, body: Types.UpdateSecretBody): Promise<void>;
57
+ /**
58
+ *
59
+ * Irreversibly deletes a secret
60
+ * @see DELETE /clusters/{clusterUuid}/secrets/{secretName}
61
+ */
62
+ deleteSecret(clusterUuid: string, secretName: string): Promise<void>;
63
+ getClusters(): Promise<Array<Types.Cluster>>;
64
+ createCluster(body: Types.CreateClusterBody & {
65
+ identityBackendChecksEnabled?: boolean;
66
+ }): Promise<{
67
+ clusterId: string;
68
+ }>;
69
+ getCluster(clusterUuid: string): Promise<Types.Cluster>;
70
+ /**
71
+ *
72
+ * Updates name or labels of a cluster identified by the given clusterUuid.
73
+ * @see PATCH /clusters/{clusterUuid}
74
+ */
75
+ updateCluster(clusterUuid: string, body: Types.UpdateClusterBody): Promise<void>;
76
+ /**
77
+ *
78
+ * Irreversibly deletes a cluster identified by the given clusterUuid.
79
+ * @see DELETE /clusters/{clusterUuid}
80
+ */
81
+ deleteCluster(clusterUuid: string): Promise<void>;
82
+ /**
83
+ *
84
+ * upgrades a cluster identified by the given clusterUuid to the latest generation available.
85
+ * @see PUT /clusters/{clusterUuid}/upgrade
86
+ */
87
+ upgradeCluster(clusterUuid: string): Promise<Types.GenerationUpgradeForClusterDto>;
88
+ /**
89
+ *
90
+ * Gets all possible options to create a Camunda cluster.
91
+ * @see GET /clusters/parameters
92
+ */
93
+ getParameters(): Promise<Types.Parameters>;
94
+ /**
95
+ *
96
+ * Updates the IP Allowlist rules for your cluster. Each entry in the array must be a valid comma separated list of CIDRs.
97
+ * @see PUT /clusters/{clusterUuid}/ipallowlist
98
+ */
99
+ updateIpAllowlist(clusterUuid: string, body: Types.IpAllowListBody): Promise<void>;
100
+ /**
101
+ *
102
+ * Updates the IP Whitelist rules for your cluster. Each entry in the array must be a valid comma separated list of CIDRs.
103
+ * THIS IS DEPRECATED AND WILL BE REMOVED FROM THE API IN JUNE 2025. USE /clusters/:clusterUuid/ipallowlist INSTEAD.
104
+ * @see PUT /clusters/{clusterUuid}/ipwhitelist
105
+ */
106
+ updateIpWhitelist(clusterUuid: string, body: Types.IpWhiteListBody): Promise<void>;
107
+ /**
108
+ *
109
+ * Resumes a 'Suspended' Cluster.
110
+ * @see PUT /clusters/{clusterUuid}/wake
111
+ */
112
+ wake(clusterUuid: string): Promise<void>;
113
+ getClients(clusterUuid: string): Promise<Array<Types.ClusterClient>>;
114
+ createClient(clusterUuid: string, body: Types.CreateClusterClientBody): Promise<Types.CreatedClusterClient>;
115
+ getClient(clusterUuid: string, clientId: string): Promise<Types.ClusterClientConnectionDetails>;
116
+ /**
117
+ *
118
+ * Irreversibly deletes a cluster client.
119
+ * @see DELETE /clusters/{clusterUuid}/clients/{clientId}
120
+ */
121
+ deleteClient(clusterUuid: string, clientId: string): Promise<void>;
122
+ /**
123
+ *
124
+ * Activates External Monitoring for a cluster
125
+ * @see POST /clusters/{clusterUuid}/monitoring
126
+ */
127
+ activateMonitoring(clusterUuid: string): Promise<void>;
128
+ /**
129
+ *
130
+ * Deactivates External Monitoring for a cluster
131
+ * @see DELETE /clusters/{clusterUuid}/monitoring
132
+ */
133
+ deactivateMonitoring(clusterUuid: string): Promise<void>;
134
+ /**
135
+ *
136
+ * Get all External Monitoring clients for a cluster
137
+ * @see GET /clusters/{clusterUuid}/monitoring/clients
138
+ */
139
+ getMonitoringClients(clusterUuid: string): Promise<{
140
+ clients: Array<Types.ByomClientDto>;
141
+ status: Types.ByomStatus | unknown;
142
+ }>;
143
+ /**
144
+ *
145
+ * Creates a new External Monitoring client
146
+ * @see POST /clusters/{clusterUuid}/monitoring/clients
147
+ */
148
+ createMonitoringClient(clusterUuid: string, body: {
149
+ username: string;
150
+ }): Promise<Types.ByomClientDto & {
151
+ password: string;
152
+ }>;
153
+ /**
154
+ *
155
+ * Rotates the password for an External Monitoring client
156
+ * @see POST /clusters/{clusterUuid}/monitoring/clients/{clientUuid}/rotate
157
+ */
158
+ rotateMonitoringClientPassword(clusterUuid: string, clientUuid: string): Promise<Types.ByomClientDto & {
159
+ password: string;
160
+ }>;
161
+ /**
162
+ *
163
+ * Deletes an External Monitoring client
164
+ * @see DELETE /clusters/{clusterUuid}/monitoring/clients/{clientUuid}
165
+ */
166
+ deleteMonitoringClient(clusterUuid: string, clientUuid: string): Promise<void>;
167
+ getBackups(clusterUuid: string): Promise<Array<Types.BackupDto>>;
168
+ /**
169
+ *
170
+ * Creates a new backup
171
+ * @see POST /clusters/{clusterUuid}/backups
172
+ */
173
+ createBackup(clusterUuid: string): Promise<Types.BackupDto>;
174
+ /**
175
+ *
176
+ * Irreversibly deletes a cluster
177
+ * @see DELETE /clusters/{clusterUuid}/backups/{backupId}
178
+ */
179
+ deleteBackup(clusterUuid: string, backupId: string): Promise<Types.BackupDto>;
180
+ }
181
+ export declare class ActivityResource extends ResourceBase {
182
+ getJson(): Promise<Array<Types.AuditDto>>;
183
+ getCsv(): Promise<string>;
184
+ }
185
+ /**
186
+ * Camunda Admin API client.
187
+ */
188
+ export declare class AdminApiClient extends CamundaBaseClient {
189
+ /** Meta operations */
190
+ readonly meta: MetaResource;
191
+ /** Members operations */
192
+ readonly members: MembersResource;
193
+ /** Clusters operations */
194
+ readonly clusters: ClustersResource;
195
+ /** Activity operations */
196
+ readonly activity: ActivityResource;
197
+ constructor(config?: CamundaClientInput);
198
+ }
199
+ //# sourceMappingURL=admin-resources.d.ts.map