Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
add stub support for tenantId to some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jwulf committed Aug 9, 2023
1 parent 477867c commit 654cebf
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Version 8.2.6

## Chores

_Things that shouldn't have a visible impact._

- Camunda Platform 8.3-alpha4 introduces new work to support multi-tenancy. To support the development for this feature, the Node.js client adds a `tenantId` parameter to `DeployResource`, `DeployProcess`, `CreateProcessInstance`, and `CreateProcessInstanceWithResult`. At this point, the `tenantId` parameter does not do anything. It is for development purposes. See [#330](https://github.com/camunda-community-hub/zeebe-client-node-js/issues/330) for more details.

# Version 8.2.5

## New Features
Expand Down
26 changes: 26 additions & 0 deletions proto/zeebe.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ option go_package = "./;pb";
// For a more complete documentation, refer to Zeebe documentation at:
// https://docs.camunda.io/docs/reference/grpc

message StreamActivatedJobsRequest {
// the job type, as defined in the BPMN process (e.g. <zeebe:taskDefinition
// type="payment-service" />)
string type = 1;
// the name of the worker activating the jobs, mostly used for logging purposes
string worker = 2;
// a job returned after this call will not be activated by another call until the
// timeout (in ms) has been reached
int64 timeout = 3;
// a list of variables to fetch as the job variables; if empty, all visible variables at
// the time of activation for the scope of the job will be returned
repeated string fetchVariable = 5;
}

message ActivateJobsRequest {
// the job type, as defined in the BPMN process (e.g. <zeebe:taskDefinition
// type="payment-service" />)
Expand Down Expand Up @@ -588,6 +602,18 @@ service Gateway {
rpc ActivateJobs (ActivateJobsRequest) returns (stream ActivateJobsResponse) {
}

/*
Registers client to a job stream that will stream jobs back to the client as
they become activatable.
Errors:
INVALID_ARGUMENT:
- type is blank (empty string, null)
- timeout less than 1
*/
rpc StreamActivatedJobs (StreamActivatedJobsRequest) returns (stream ActivatedJob) {
}

/*
Cancels a running process instance
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/integration/Client-ThrowError.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ test('Can set variables when throwing a BPMN Error', async () => {
const result = await zbc.createProcessInstanceWithResult(processId, {
timeout: 20000,
})
console.log(result.variables)
expect(result.variables.bpmnErrorCaught).toBe(true)
// expect(result.variables.something).toBe("someValue")
})
4 changes: 3 additions & 1 deletion src/lib/interfaces-1.0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export interface CreateProcessBaseRequest<V extends JSONDoc> {
/** JSON document that will instantiate the variables for the root variable scope of the
* process instance.
*/
variables: V
variables: V,
/** EXPERIMENTAL. NOT IMPLEMENTED. The tenantId for a multi-tenant enabled cluster. */
tenantId?: string
}

export interface CreateProcessInstanceReq<V extends JSONDoc> extends CreateProcessBaseRequest<V> {
Expand Down
27 changes: 23 additions & 4 deletions src/zb/ZBClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ export class ZBClient extends TypedEmitter<typeof ConnectionStatusEvent> {
): conf is ZB.CreateProcessInstanceReq<Variables> =>
typeof conf === 'object'

if (isConfigObject(configOrbpmnProcessId) && !!configOrbpmnProcessId.tenantId) {
this.logger.logInfo('Multi-tenancy is not yet implemented. The tenantId parameter is provided for development purposes.')
}

const request: ZB.CreateProcessInstanceReq<Variables> = isConfigObject(configOrbpmnProcessId)
? {
bpmnProcessId: configOrbpmnProcessId.bpmnProcessId,
Expand Down Expand Up @@ -734,6 +738,10 @@ export class ZBClient extends TypedEmitter<typeof ConnectionStatusEvent> {
): config is ZB.CreateProcessInstanceWithResultReq<Variables> =>
typeof config === 'object'

if (isConfigObject(configOrBpmnProcessId) && !!configOrBpmnProcessId.tenantId) {
this.logger.logInfo('Multi-tenancy is not yet implemented. The tenantId parameter is provided for development purposes.')
}

const request = isConfigObject(configOrBpmnProcessId)
? {
bpmnProcessId: configOrBpmnProcessId.bpmnProcessId,
Expand Down Expand Up @@ -782,26 +790,32 @@ export class ZBClient extends TypedEmitter<typeof ConnectionStatusEvent> {
public async deployResource(
resource:
| { processFilename: string }
| { name: string; process: Buffer }
| { name: string; process: Buffer },
tenantId?: string
): Promise<Grpc.DeployResourceResponse<Grpc.ProcessDeployment>>
public async deployResource(
resource:
| { decisionFilename: string }
| { name: string; decision: Buffer }
| { name: string; decision: Buffer },
tenantId?: string
): Promise<Grpc.DeployResourceResponse<Grpc.DecisionDeployment>>
async deployResource(
resource:
| { processFilename: string }
| { name: string; process: Buffer }
| { name: string; decision: Buffer }
| { decisionFilename: string }
| { decisionFilename: string },
tenantId?: string
): Promise<
Grpc.DeployResourceResponse<
| Grpc.ProcessDeployment
| Grpc.DecisionDeployment
| Grpc.DecisionRequirementsDeployment
>
> {
if (!!tenantId) {
this.logger.logInfo('Multi-tenancy is not yet implemented. The tenantId parameter is provided for development purposes.')
}
const isProcess = (
maybeProcess: any
): maybeProcess is { process: Buffer; name: string } =>
Expand Down Expand Up @@ -889,8 +903,13 @@ export class ZBClient extends TypedEmitter<typeof ConnectionStatusEvent> {
* ```
*/
public async deployProcess(
process: ZB.DeployProcessFiles | ZB.DeployProcessBuffer
process: ZB.DeployProcessFiles | ZB.DeployProcessBuffer,
tenantId?: string
): Promise<Grpc.DeployProcessResponse> {

if (!!tenantId) {
this.logger.logInfo('Multi-tenancy is not yet implemented. The tenantId parameter is provided for development purposes.')
}
const deploy = (processes: Grpc.ProcessRequestObject[]) =>
this.executeOperation('deployWorkflow', () =>
this.grpc.deployProcessSync({
Expand Down

0 comments on commit 654cebf

Please sign in to comment.