Prozess-Instanzen
Funktionen zur Abfrage und Steuerung von Prozessinstanzen.
import {
getProcessInstanceById,
getActiveProcessInstances,
retryProcessInstance,
terminateProcessInstance,
waitForProcessEnd,
getFlowNodeInstancesByProcessInstanceId,
getFlowNodeInstancesTriggeredByFlowNodeInstanceIds,
} from '@5minds/processcube_app_sdk/server';getProcessInstanceById
Gibt die Prozessinstanz mit der angegebenen ID zurück (inkl. BPMN-XML).
const instance = await getProcessInstanceById('process-instance-id');getActiveProcessInstances
Gibt alle laufenden Prozessinstanzen zurück. Unterstützt Filterung und Paginierung.
// Alle laufenden Instanzen
const result = await getActiveProcessInstances();
// Mit Filter
const filtered = await getActiveProcessInstances({
query: { processModelId: 'OrderProcess' },
options: { limit: 10, offset: 0 },
});retryProcessInstance
Startet eine Prozessinstanz von einem bestimmten FlowNode neu.
// Gesamten Prozess neu starten
await retryProcessInstance('process-instance-id');
// Ab einem bestimmten FlowNode
await retryProcessInstance('process-instance-id', 'flow-node-instance-id');
// Mit neuem Start-Token
await retryProcessInstance('process-instance-id', 'flow-node-instance-id', {
orderId: 'new-123',
});terminateProcessInstance
Beendet eine Prozessinstanz sofort.
await terminateProcessInstance('process-instance-id');waitForProcessEnd
Blocking: Diese Funktion blockiert, bis die Prozessinstanz beendet ist (Event-Subscription). Nicht in Server Components verwenden, die schnell rendern sollen.
Wartet, bis eine Prozessinstanz beendet, terminiert oder fehlerhaft ist. Nutzt Engine-Notifications (kein Polling).
const finishedInstance = await waitForProcessEnd({
processInstanceId: 'process-instance-id',
});getFlowNodeInstancesByProcessInstanceId
Gibt alle FlowNode-Instanzen einer Prozessinstanz zurück (sortiert nach Erstellungsdatum).
const flowNodes = await getFlowNodeInstancesByProcessInstanceId('process-instance-id');getFlowNodeInstancesTriggeredByFlowNodeInstanceIds
Gibt FlowNode-Instanzen zurück, die von den angegebenen FlowNode-Instanzen ausgelöst wurden.
const triggered = await getFlowNodeInstancesTriggeredByFlowNodeInstanceIds([
'fni-1',
'fni-2',
]);