Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@5minds/processcube_engine_client
Advanced tools
Contains a typescript based client for accessing the Engine.
A client for communicating with the Engine
.
It is written in TypeScript and implemented in NodeJS.
import {EngineClient} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const client = new EngineClient(engineUri);
const processInstances = await client.processInstances.query({});
console.log(processInstances);
}
run();
You only need to provide an url to the Engine
you want to access.
After that, the client is ready to use.
You can either create a single EngineClient, which exposes references to all other clients,
import {EngineClient} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const client = new EngineClient(engineUri);
const processInstances = await client.processInstances.query({}, null, 0, 100);
console.log(processInstances);
}
run();
or create multiple specific clients with the ClientFactory:
import {ClientFactory} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const processInstanceClient = ClientFactory.createProcessInstanceClient(engineUri);
const processInstances = await processInstanceClient.query({}, null, 0, 100);
console.log(processInstances);
}
run();
You can start new Process Instances through processDefinitionsClient.startProcessInstance(parameters)
-
Resolves right after the Process Instance was started
Where parameters
is an object that collects all startup parameters.
The following parameters are required:
processModelId
: The ID of the Process Model to executestartEventId
: The ID of the Start Event by which to start the Process Model. Optional, if the Process Model only has one Start Event.In addition, the following optional parameters are available:
correlationId
: The ID of the correlation to which this Process Instance belongs. If not provided, it will be auto-generatedinitialToken
: The initial process token with which to start the Process InstanceparentProcessInstanceId
: When the Process Instance is supposed to be the Subprocess of another Process Instance,
this contains the ID of the parent Process Instanceor through
processDefinitionsClient.startProcessInstanceAndAwaitEndEvent(parameters)
-
Resolves when the Process Instance has finished with any End Event
or through
processDefinitionsClient.startProcessInstanceAndAwaitSpecificEndEvent(parameters, endEventId)
-
Resolves after the ProcessInstance has reached a specific End Event
and has additionally the required endEventId parameter:
endEventId
: The ID of the End Event to wait forExamples:
import {EngineClient} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const client = new EngineClient(engineUri);
await client.processDefinitions.startProcessInstance({processModelId: 'myProcessModelId'});
}
run();
import {EngineClient} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const client = new EngineClient(engineUri);
await client.processDefinitions.startProcessInstanceAndAwaitEndEvent({processModelId: 'myProcessModelId'});
}
run();
import {EngineClient} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const client = new EngineClient(engineUri);
await client.processDefinitions.startProcessInstanceAndAwaitSpecificEndEvent({processModelId: 'myProcessModelId'}, 'My_End_Event_1');
}
run();
import {EngineClient} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const client = new EngineClient(engineUri);
await client.processDefinitions.startProcessInstance({
processModelId: 'myProcessModelId',
correlationId: 'my_custom_correlation_id',
initialToken: {
hello: 'world',
},
});
}
run();
import {EngineClient} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const client = new EngineClient(engineUri);
await client.processDefinitions.startProcessInstance({
processModelId: 'myProcessModelId',
parentProcessInstanceId: 'Some-Other-Process-Instance-Id',
});
}
run();
You can find executable code samples here and here.
import {EngineClient, DataModels} from '@5minds/processcube_engine_client';
const engineUri = 'http://localhost:10560';
async function run() {
const client = new EngineClient(engineUri);
const userTasks = await client.userTasks.query({
processModelId: 'myProcessModelId',
state: DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended,
});
console.log(userTasks);
}
run();
An External Task worker is designed to process External Tasks associated with a BPMN ServiceTask.
You need to provide three arguments to a worker:
import {EngineClient, DataModels} from '@5minds/processcube_engine_client';
interface AddPayload {
number1: number;
number2: number;
}
interface AddResult {
sum: number;
}
const engineUri = 'http://localhost:10560';
const topic = 'sum_numbers';
async function run() {
const client = new EngineClient(engineUri);
const externalTaskWorker = await client.externalTasks.subscribeToExternalTaskTopic(topic, doAdd);
externalTaskWorker.start();
}
async function doAdd(
payload: AddPayload,
externalTask: DataModels.ExternalTasks.ExternalTask<AddPayload>,
): Promise<AddResult> {
const result: AddResult = {
sum: payload.number1 + payload.number2,
};
console.log('Receive payload from process instance');
console.log(JSON.stringify(payload));
return Promise.resolve(result);
}
run();
Note that by subscribing to a single topic, you create a specific worker for this topic.
Start the worker with:
externalTaskWorker.start();
And stop it with:
externalTaskWorker.stop();
You can find executable code samples here and here.
FAQs
Contains a typescript based client for accessing the Engine.
The npm package @5minds/processcube_engine_client receives a total of 1,064 weekly downloads. As such, @5minds/processcube_engine_client popularity was classified as popular.
We found that @5minds/processcube_engine_client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 29 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.