Skip to content

Commit

Permalink
feat(camunda8): add C8RestClient
Browse files Browse the repository at this point in the history
support 8.6 unified C8 REST API, deprecate ZeebeRestClient

fixes #235
  • Loading branch information
jwulf committed Aug 30, 2024
1 parent 532b36e commit 70c8f09
Show file tree
Hide file tree
Showing 4 changed files with 420 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/c8/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { OptimizeApiClient } from '../optimize'
import { TasklistApiClient } from '../tasklist'
import { ZeebeGrpcClient, ZeebeRestClient } from '../zeebe'

import { C8RestClient } from './lib/C8RestClient'

/**
* A single point of configuration for all Camunda Platform 8 clients.
*
Expand All @@ -23,12 +25,12 @@ import { ZeebeGrpcClient, ZeebeRestClient } from '../zeebe'
*
* const c8 = new Camunda8()
* const zeebe = c8.getZeebeGrpcApiClient()
* const zeebeRest = c8.getZeebeRestClient()
* const operate = c8.getOperateApiClient()
* const optimize = c8.getOptimizeApiClient()
* const tasklist = c8.getTasklistApiClient()
* const modeler = c8.getModelerApiClient()
* const admin = c8.getAdminApiClient()
* const c8Rest = c8.getC8RestClient()
* ```
*/
export class Camunda8 {
Expand All @@ -41,6 +43,7 @@ export class Camunda8 {
private zeebeRestClient?: ZeebeRestClient
private configuration: CamundaPlatform8Configuration
private oAuthProvider: IOAuthProvider
private c8RestClient?: C8RestClient

constructor(config: DeepPartial<CamundaPlatform8Configuration> = {}) {
this.configuration =
Expand Down Expand Up @@ -108,6 +111,9 @@ export class Camunda8 {
return this.zeebeGrpcApiClient
}

/**
* @deprecated from 8.6. Please use getC8RestClient() instead.
*/
public getZeebeRestClient(): ZeebeRestClient {
if (!this.zeebeRestClient) {
this.zeebeRestClient = new ZeebeRestClient({
Expand All @@ -117,4 +123,14 @@ export class Camunda8 {
}
return this.zeebeRestClient
}

public getC8RestClient(): C8RestClient {
if (!this.c8RestClient) {
this.c8RestClient = new C8RestClient({
config: this.configuration,
oAuthProvider: this.oAuthProvider,
})
}
return this.c8RestClient
}
}
57 changes: 57 additions & 0 deletions src/c8/lib/C8Dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { LosslessNumber } from 'lossless-json'

import { Int64String, LosslessDto } from '../../lib'
import { JSONDoc } from '../../zeebe/types'

export class Job<T = LosslessDto> extends LosslessDto {
@Int64String
key!: string
type!: string
@Int64String
processInstanceKey!: LosslessNumber
bpmnProcessId!: string
processDefinitionVersion!: number
@Int64String
processDefinitionKey!: LosslessNumber
elementId!: string
@Int64String
elementInstanceKey!: LosslessNumber
customHeaders!: T
worker!: string
retries!: number
@Int64String
deadline!: LosslessNumber
variables!: JSONDoc
tenantId!: string
}

/**
* JSON object with changed task attribute values.
*/
export interface TaskChangeSet {
/* The due date of the task. Reset by providing an empty String. */
dueDate?: Date | string
/* The follow-up date of the task. Reset by providing an empty String. */
followUpDate?: Date | string
/* The list of candidate users of the task. Reset by providing an empty list. */
candidateUsers?: string[]
/* The list of candidate groups of the task. Reset by providing an empty list. */
candidateGroups?: string[]
}

/** JSON object with changed job attribute values. */
export interface JobUpdateChangeset {
/* The new amount of retries for the job; must be a positive number. */
retries?: number
/** The duration of the new timeout in ms, starting from the current moment. */
timeout?: number
}

export interface NewUserInfo {
password: string
id: number
username: string
name: string
email: string
enabled: boolean
}
Loading

0 comments on commit 70c8f09

Please sign in to comment.