Skip to content

Commit

Permalink
feat(camunda8): support updateElementInstanceVariables
Browse files Browse the repository at this point in the history
fixes #249
  • Loading branch information
jwulf committed Sep 18, 2024
1 parent 3abe543 commit bb7bcf2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/c8/lib/C8RestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
NewUserInfo,
ProcessDeployment,
TaskChangeSet,
UpdateElementVariableRequest,
} from './C8Dto'
import { C8JobWorker, C8JobWorkerConfig } from './C8JobWorker'
import { getLogger } from './C8Logger'
Expand Down Expand Up @@ -278,6 +279,10 @@ export class C8RestClient {
return this.rest.then((rest) => rest.get(`license`).json())
}

/**
* Create a new polling Job Worker.
* You can pass in an optional winston.Logger instance as `logger`. This enables you to have distinct logging levels for different workers.
*/
public createJobWorker<
Variables extends LosslessDto,
CustomHeaders extends LosslessDto,
Expand Down Expand Up @@ -470,6 +475,9 @@ export class C8RestClient {
public async migrateProcessInstance(req: MigrationRequest) {
const headers = await this.getHeaders()
const { processInstanceKey, ...request } = req
this.log.debug(`Migrating process instance ${processInstanceKey}`, {
component: 'C8RestClient',
})
return this.rest.then((rest) =>
rest.post(`process-instances/${processInstanceKey}/migration`, {
headers,
Expand Down Expand Up @@ -500,6 +508,7 @@ export class C8RestClient {
formData.append('tenantId', tenantId ?? this.tenantId)
}

this.log.debug(`Deploying ${resources.length} resources`)
const res = await this.rest.then((rest) =>
rest
.post('deployments', {
Expand Down Expand Up @@ -662,6 +671,23 @@ export class C8RestClient {
}
}

/**
* Updates all the variables of a particular scope (for example, process instance, flow element instance) with the given variable data.
* Specify the element instance in the elementInstanceKey parameter.
*/
public async updateElementInstanceVariables(
req: UpdateElementVariableRequest
) {
const headers = await this.getHeaders()
const { elementInstanceKey, ...request } = req
return this.rest.then((rest) =>
rest.post(`element-instances/${elementInstanceKey}/variables`, {
headers,
body: stringify(request),
})
)
}

/**
* Helper method to add the default tenantIds if we are not passed explicit tenantIds
*/
Expand Down

0 comments on commit bb7bcf2

Please sign in to comment.