From 5c22f3e58265f20cf2e9091779c672d941fa6fc1 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 24 Feb 2026 22:06:56 +0500 Subject: [PATCH 1/2] Fix fieldChangesCheck Signed-off-by: Denis Bykhov --- foundations/core/packages/core/src/tx.ts | 5 ++++- plugins/process-resources/src/utils.ts | 13 ++++++++----- server-plugins/process-resources/src/functions.ts | 5 +++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/foundations/core/packages/core/src/tx.ts b/foundations/core/packages/core/src/tx.ts index af3cea4f178..493c29b3607 100644 --- a/foundations/core/packages/core/src/tx.ts +++ b/foundations/core/packages/core/src/tx.ts @@ -436,7 +436,10 @@ export abstract class TxProcessor implements WithTx { } static txHasUpdate(tx: TxUpdateDoc, attribute: string): boolean { - const ops = tx.operations + return TxProcessor.hasUpdate(tx.operations, attribute) + } + + static hasUpdate(ops: DocumentUpdate, attribute: string): boolean { if ((ops as any)[attribute] !== undefined) return true for (const op in ops) { if (op.startsWith('$')) { diff --git a/plugins/process-resources/src/utils.ts b/plugins/process-resources/src/utils.ts index 3e8e2a33bae..8ba9db9b73a 100644 --- a/plugins/process-resources/src/utils.ts +++ b/plugins/process-resources/src/utils.ts @@ -20,12 +20,14 @@ import core, { type Client, type Doc, type DocumentQuery, + DocumentUpdate, generateId, matchQuery, type Ref, type RefTo, type Space, type TxOperations, + TxProcessor, type Type } from '@hcengineering/core' import { getResource, type IntlString, PlatformError, Severity, Status } from '@hcengineering/platform' @@ -207,9 +209,9 @@ export function getContext ( } } const allRelations = client.getModel().findAllSync(core.class.Association, {}) - const descendants = new Set(client.getHierarchy().getDescendants(process.masterTag)) + const ancestors = new Set(client.getHierarchy().getAncestors(process.masterTag)) - const relationsA = allRelations.filter((it) => descendants.has(it.classA)) + const relationsA = allRelations.filter((it) => ancestors.has(it.classA)) for (const rel of relationsA) { if (['object', 'array'].includes(category) && client.getHierarchy().isDerived(rel.classB, target)) { relations[rel.nameB] = { @@ -231,7 +233,7 @@ export function getContext ( } } - const relationsB = allRelations.filter((it) => descendants.has(it.classB)) + const relationsB = allRelations.filter((it) => ancestors.has(it.classB)) for (const rel of relationsB) { if (['object', 'array'].includes(category) && client.getHierarchy().isDerived(rel.classA, target)) { relations[rel.nameA] = { @@ -683,8 +685,9 @@ export function fieldChangesCheck ( ): boolean { const doc = context.card if (doc === undefined) return false - const param = Object.keys(params)[0] - if (!Object.keys(context.operations ?? {}).includes(param)) return false + const operations = (context.operations ?? {}) as DocumentUpdate + const target = Object.keys(params)[0] + if (!TxProcessor.hasUpdate(operations, target)) return false const res = matchQuery([doc], params, doc._class, client.getHierarchy(), true) return res.length > 0 } diff --git a/server-plugins/process-resources/src/functions.ts b/server-plugins/process-resources/src/functions.ts index 403da49ddc0..7f40a593677 100644 --- a/server-plugins/process-resources/src/functions.ts +++ b/server-plugins/process-resources/src/functions.ts @@ -20,6 +20,7 @@ import core, { Class, Data, Doc, + DocumentUpdate, fillDefaults, findProperty, generateId, @@ -169,9 +170,9 @@ export function FieldChangedCheck ( const process = control.client.getModel().findObject(execution.process) if (process === undefined) return false if (context.operations === undefined) return false - const changedFields = Object.keys(context.operations) + const operations = context.operations as DocumentUpdate const target = Object.keys(params)[0] - if (!changedFields.includes(target)) return false + if (!TxProcessor.hasUpdate(operations, target)) return false const res = matchQuery([context.card], params, process.masterTag, control.client.getHierarchy(), true) return res.length > 0 } From 4fa74e6b0a9746008e5615de4df6f277d3cbf17d Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 24 Feb 2026 23:43:22 +0500 Subject: [PATCH 2/2] Fix formatting Signed-off-by: Denis Bykhov --- plugins/process-resources/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/process-resources/src/utils.ts b/plugins/process-resources/src/utils.ts index 8ba9db9b73a..6437ebce6f7 100644 --- a/plugins/process-resources/src/utils.ts +++ b/plugins/process-resources/src/utils.ts @@ -20,7 +20,7 @@ import core, { type Client, type Doc, type DocumentQuery, - DocumentUpdate, + type DocumentUpdate, generateId, matchQuery, type Ref,