Skip to content

Commit

Permalink
refactor: replace zeebe-node with @camunda8/sdk
Browse files Browse the repository at this point in the history
fixes #4109
  • Loading branch information
jwulf committed Apr 10, 2024
1 parent 24744b0 commit 56d9a23
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 146 deletions.
4 changes: 2 additions & 2 deletions app/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const path = require('path');

const fs = require('fs');

const ZeebeNode = require('zeebe-node');
const Camunda8 = require('@camunda8/sdk');

const Cli = require('./cli');
const Config = require('./config');
Expand Down Expand Up @@ -680,7 +680,7 @@ function bootstrap() {
errorTracking.setTag(Sentry, 'plugins', generatePluginsTag(plugins));

// (9) zeebe API
const zeebeAPI = new ZeebeAPI({ readFile }, ZeebeNode, flags);
const zeebeAPI = new ZeebeAPI({ readFile }, Camunda8.ZeebeGrpcApiClient, flags);

return {
config,
Expand Down
38 changes: 18 additions & 20 deletions app/lib/zeebe-api/zeebe-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ const RESOURCE_TYPES = {
*/

class ZeebeAPI {
constructor(fs, ZeebeNode, flags, log = createLog('app:zeebe-api')) {
constructor(fs, ZeebeGrpcApiClient, flags, log = createLog('app:zeebe-api')) {
this._fs = fs;

this._ZeebeNode = ZeebeNode;
this._ZeebeGrpcApiClient = ZeebeGrpcApiClient;
this._flags = flags;
this._log = log;

Expand Down Expand Up @@ -310,8 +310,9 @@ class ZeebeAPI {
url
} = endpoint;

/** @type {Camunda8PlatformConfiguration} */
let options = {
retry: false
zeebeGrpcSettings: { ZEEBE_GRPC_CLIENT_RETRY: false }
};

if (!values(ENDPOINT_TYPES).includes(type)) {
Expand All @@ -321,26 +322,23 @@ class ZeebeAPI {
if (type === ENDPOINT_TYPES.OAUTH) {
options = {
...options,
oAuth: {
url: endpoint.oauthURL,
audience: endpoint.audience,
scope: endpoint.scope,
clientId: endpoint.clientId,
clientSecret: endpoint.clientSecret,
cacheOnDisk: false
}
ZEEBE_ADDRESS: endpoint.oauthURL,
CAMUNDA_ZEEBE_OAUTH_AUDIENCE: endpoint.audience,
CAMUNDA_TOKEN_SCOPE: endpoint.scope,
CAMUNDA_ZEEBE_CLIENT_ID: endpoint.clientId,
CAMUNDA_ZEEBE_CLIENT_SECRET: endpoint.clientSecret,
CAMUNDA_TOKEN_DISK_CACHE_DISABLE: true
};
} else if (type === ENDPOINT_TYPES.CAMUNDA_CLOUD) {
options = {
...options,
camundaCloud: {
clientId: endpoint.clientId,
clientSecret: endpoint.clientSecret,
clusterId: endpoint.clusterId,
cacheOnDisk: false,
...(endpoint.clusterRegion ? { clusterRegion: endpoint.clusterRegion } : {})
},
useTLS: true
ZEEBE_ADDRESS: endpoint.camundaCloudClusterUrl,
CAMUNDA_ZEEBE_OAUTH_AUDIENCE: endpoint.audience,
CAMUNDA_TOKEN_SCOPE: endpoint.scope,
CAMUNDA_ZEEBE_CLIENT_ID: endpoint.clientId,
CAMUNDA_ZEEBE_CLIENT_SECRET: endpoint.clientSecret,
CAMUNDA_TOKEN_DISK_CACHE_DISABLE: true,
CAMUNDA_SECURE_CONNECTION: true
};
}

Expand All @@ -357,7 +355,7 @@ class ZeebeAPI {
])
});

return new this._ZeebeNode.ZBClient(url, options);
return new this._ZeebeGrpcApiClient({ config: options });
}

async _withTLSConfig(url, options) {
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"min-dash": "^4.1.1",
"mri": "^1.1.6",
"parents": "^1.0.1",
"zeebe-node": "^8.3.2"
"@camunda8/sdk": "^8.5.0"
},
"homepage": "https://github.com/camunda/camunda-modeler",
"repository": {
Expand Down
Loading

0 comments on commit 56d9a23

Please sign in to comment.