feat: Implement CancelSubProcess action, fix process execution flow. (#10530)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-02-20 10:23:03 +07:00
committed by GitHub
parent f446e036ee
commit bb6d4c74e9
28 changed files with 202 additions and 41 deletions
+7 -9
View File
@@ -488,10 +488,10 @@ async function executeTransition (
)
await client.tx(apply)
await sendEvent(control, execution, transition, card, isDone)
if (isDone && execution.parentId !== undefined) {
await checkParent(execution, control)
}
TxProcessor.applyUpdate(execution, executionUpdate)
if (execution.parentId !== undefined) {
await checkParent(execution, control, isDone)
}
currTransition = transition
transition = await checkNext(control, execution, context)
nested = true
@@ -734,28 +734,26 @@ async function fillParams<T extends Doc> (
return res
}
async function checkParent (execution: Execution, control: ProcessControl): Promise<void> {
async function checkParent (execution: Execution, control: ProcessControl, isDone: boolean): Promise<void> {
try {
const subProcesses = await control.client.findAll(process.class.Execution, {
parentId: execution.parentId,
status: ExecutionStatus.Active
})
const filtered = subProcesses.filter((it) => it._id !== execution._id)
if (filtered.length !== 0) return
const parent = (await control.client.findAll(process.class.Execution, { _id: execution.parentId }))[0]
if (parent === undefined) return
const _process = control.client.getModel().findObject(parent.process)
if (_process === undefined) return
if (parent.status !== ExecutionStatus.Active) return
const triggers: Ref<Trigger>[] = [process.trigger.OnSubProcessMatch]
if (filtered.length === 0 && isDone) triggers.push(process.trigger.OnSubProcessesDone)
const transitions = control.client.getModel().findAllSync(
process.class.Transition,
{
from: parent.currentState,
process: parent.process,
trigger:
filtered.length === 0
? { $in: [process.trigger.OnSubProcessesDone, process.trigger.OnSubProcessMatch] }
: process.trigger.OnSubProcessMatch
trigger: { $in: triggers }
},
{
sort: { rank: SortingOrder.Ascending }