From 5fa0bb3c64fba1af8e197325aef4be305620ddeb Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 30 Sep 2025 19:05:59 +0500 Subject: [PATCH] Empty array process function (#9977) Signed-off-by: Denis Bykhov --- models/process/src/functions.ts | 48 +++++++++++++++++++ models/server-process/src/index.ts | 21 ++++++++ plugins/process-assets/lang/cs.json | 5 +- plugins/process-assets/lang/de.json | 5 +- plugins/process-assets/lang/en.json | 5 +- plugins/process-assets/lang/es.json | 5 +- plugins/process-assets/lang/fr.json | 5 +- plugins/process-assets/lang/it.json | 5 +- plugins/process-assets/lang/ja.json | 5 +- plugins/process-assets/lang/pt.json | 5 +- plugins/process-assets/lang/ru.json | 5 +- plugins/process-assets/lang/zh.json | 5 +- plugins/process-resources/src/plugin.ts | 5 +- plugins/process-resources/src/utils.ts | 2 +- plugins/process/src/index.ts | 4 ++ .../process-resources/src/transform.ts | 25 ++++++++++ server-plugins/process/src/index.ts | 5 +- 17 files changed, 147 insertions(+), 13 deletions(-) diff --git a/models/process/src/functions.ts b/models/process/src/functions.ts index 3bd5bec397..1a6b4c74af 100644 --- a/models/process/src/functions.ts +++ b/models/process/src/functions.ts @@ -434,6 +434,54 @@ export function defineFunctions (builder: Builder): void { process.function.RoleContext ) + builder.createDoc( + process.class.ProcessFunction, + core.space.Model, + { + of: core.class.ArrOf, + category: 'array', + label: process.string.EmptyArray, + type: 'context' + }, + process.function.EmptyArray + ) + + builder.createDoc( + process.class.ProcessFunction, + core.space.Model, + { + of: contact.mixin.Employee, + category: 'attribute', + label: process.string.ExecutionInitiator, + type: 'context' + }, + process.function.ExecutionEmployeeInitiator + ) + + builder.createDoc( + process.class.ProcessFunction, + core.space.Model, + { + of: contact.class.Person, + category: 'attribute', + label: process.string.ExecutionInitiator, + type: 'context' + }, + process.function.ExecutionInitiator + ) + + builder.createDoc( + process.class.ProcessFunction, + core.space.Model, + { + of: core.class.TypeDate, + category: 'attribute', + label: process.string.ExecutionStarted, + type: 'context' + }, + process.function.ExecutionStarted + ) + builder.createDoc( process.class.ProcessFunction, core.space.Model, diff --git a/models/server-process/src/index.ts b/models/server-process/src/index.ts index 4c2d0902eb..0d9c6310fb 100644 --- a/models/server-process/src/index.ts +++ b/models/server-process/src/index.ts @@ -237,6 +237,27 @@ export function createModel (builder: Builder): void { func: serverProcess.transform.RemoveLast }) + builder.mixin(process.function.EmptyArray, process.class.ProcessFunction, serverProcess.mixin.FuncImpl, { + func: serverProcess.transform.EmptyArray + }) + + builder.mixin( + process.function.ExecutionEmployeeInitiator, + process.class.ProcessFunction, + serverProcess.mixin.FuncImpl, + { + func: serverProcess.transform.ExecutionInitiator + } + ) + + builder.mixin(process.function.ExecutionInitiator, process.class.ProcessFunction, serverProcess.mixin.FuncImpl, { + func: serverProcess.transform.ExecutionInitiator + }) + + builder.mixin(process.function.ExecutionStarted, process.class.ProcessFunction, serverProcess.mixin.FuncImpl, { + func: serverProcess.transform.ExecutionStarted + }) + builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverProcess.trigger.OnExecutionContinue, txMatch: { diff --git a/plugins/process-assets/lang/cs.json b/plugins/process-assets/lang/cs.json index 74b7335348..1c423e0dea 100644 --- a/plugins/process-assets/lang/cs.json +++ b/plugins/process-assets/lang/cs.json @@ -109,7 +109,10 @@ "ProcessRunned": "Proces \"{process}\" spuštěn", "ProcessStateChanged": "Stav procesu \"{process}\" změněn na \"{state}\"", "ProcessFinished": "Proces \"{process}\" dokončen ve stavu \"{state}\"", - "NewProcessToDo": "Nový Action Item procesu" + "NewProcessToDo": "Nový Action Item procesu", + "EmptyArray": "Prázdné pole", + "ExecutionInitiator": "Iniciátor provedení", + "ExecutionStarted": "Provedení spuštěno" }, "error": { "MethodNotFound": "Metoda nenalezena: {methodId}", diff --git a/plugins/process-assets/lang/de.json b/plugins/process-assets/lang/de.json index 73d5c344d3..ec45b94c9e 100644 --- a/plugins/process-assets/lang/de.json +++ b/plugins/process-assets/lang/de.json @@ -109,7 +109,10 @@ "ProcessRunned": "Prozess \"{process}\" gestartet", "ProcessStateChanged": "Prozess \"{process}\" Status geändert zu \"{state}\"", "ProcessFinished": "Prozess \"{process}\" beendet im Status \"{state}\"", - "NewProcessToDo": "Neuer Prozess Action Item" + "NewProcessToDo": "Neuer Prozess Action Item", + "EmptyArray": "Leeres Array", + "ExecutionInitiator": "Ausführungsinitiator", + "ExecutionStarted": "Ausführung gestartet" }, "error": { "MethodNotFound": "Methode nicht gefunden: {methodId}", diff --git a/plugins/process-assets/lang/en.json b/plugins/process-assets/lang/en.json index cf64a35ee1..c318777b9d 100644 --- a/plugins/process-assets/lang/en.json +++ b/plugins/process-assets/lang/en.json @@ -114,7 +114,10 @@ "ProcessRunned": "Process \"{process}\" started", "ProcessStateChanged": "Process \"{process}\" changed state to \"{state}\"", "ProcessFinished": "Process \"{process}\" finished in \"{state}\"", - "NewProcessToDo": "New process Action item" + "NewProcessToDo": "New process Action item", + "EmptyArray": "Empty array", + "ExecutionInitiator": "Execution initiator", + "ExecutionStarted": "Execution started" }, "error": { "MethodNotFound": "Method not found: {methodId}", diff --git a/plugins/process-assets/lang/es.json b/plugins/process-assets/lang/es.json index 7e58b9b1bf..5506fc4c3c 100644 --- a/plugins/process-assets/lang/es.json +++ b/plugins/process-assets/lang/es.json @@ -114,7 +114,10 @@ "ProcessRunned": "Proceso \"{process}\" iniciado", "ProcessStateChanged": "Estado del proceso \"{process}\" cambiado a \"{state}\"", "ProcessFinished": "Proceso \"{process}\" finalizado en estado \"{state}\"", - "NewProcessToDo": "Nueva acción de proceso" + "NewProcessToDo": "Nueva acción de proceso", + "EmptyArray": "Matriz vacía", + "ExecutionInitiator": "Iniciador de Ejecución", + "ExecutionStarted": "Ejecución Iniciada" }, "error": { "MethodNotFound": "Método no encontrado: {methodId}", diff --git a/plugins/process-assets/lang/fr.json b/plugins/process-assets/lang/fr.json index 83031af8c4..8577746340 100644 --- a/plugins/process-assets/lang/fr.json +++ b/plugins/process-assets/lang/fr.json @@ -114,7 +114,10 @@ "ProcessRunned": "Processus \"{process}\" démarré", "ProcessStateChanged": "État du processus \"{process}\" changé en \"{state}\"", "ProcessFinished": "Processus \"{process}\" terminé dans l'état \"{state}\"", - "NewProcessToDo": "Nouvel Action Item de processus" + "NewProcessToDo": "Nouvel Action Item de processus", + "EmptyArray": "Tableau vide", + "ExecutionInitiator": "Initiateur d'exécution", + "ExecutionStarted": "Exécution démarrée" }, "error": { "MethodNotFound": "Méthode introuvable : {methodId}", diff --git a/plugins/process-assets/lang/it.json b/plugins/process-assets/lang/it.json index e254f82323..15cab6aff7 100644 --- a/plugins/process-assets/lang/it.json +++ b/plugins/process-assets/lang/it.json @@ -114,7 +114,10 @@ "ProcessRunned": "Processo \"{process}\" avviato", "ProcessStateChanged": "Stato del processo \"{process}\" cambiato in \"{state}\"", "ProcessFinished": "Processo \"{process}\" terminato nello stato \"{state}\"", - "NewProcessToDo": "Nuovo Action Item di processo" + "NewProcessToDo": "Nuovo Action Item di processo", + "EmptyArray": "Array vuoto", + "ExecutionInitiator": "Iniziatore dell'esecuzione", + "ExecutionStarted": "Esecuzione avviata" }, "error": { "MethodNotFound": "Metodo non trovato: {methodId}", diff --git a/plugins/process-assets/lang/ja.json b/plugins/process-assets/lang/ja.json index 7f1d127655..48eb409c12 100644 --- a/plugins/process-assets/lang/ja.json +++ b/plugins/process-assets/lang/ja.json @@ -113,7 +113,10 @@ "ProcessRunned": "プロセス \"{process}\" が開始されました", "ProcessStateChanged": "プロセス \"{process}\" の状態が \"{state}\" に変更されました", "ProcessFinished": "プロセス \"{process}\" が状態 \"{state}\" で終了しました", - "NewProcessToDo": "新しいプロセスアクション" + "NewProcessToDo": "新しいプロセスアクション", + "EmptyArray": "空の配列", + "ExecutionInitiator": "実行の発起人", + "ExecutionStarted": "実行が開始されました" }, "error": { "MethodNotFound": "メソッドが見つかりません: {methodId}", diff --git a/plugins/process-assets/lang/pt.json b/plugins/process-assets/lang/pt.json index b5378cc7b8..8605d2ffdb 100644 --- a/plugins/process-assets/lang/pt.json +++ b/plugins/process-assets/lang/pt.json @@ -114,7 +114,10 @@ "ProcessRunned": "Processo \"{process}\" iniciado", "ProcessStateChanged": "Processo \"{process}\" mudou de estado para \"{state}\"", "ProcessFinished": "Processo \"{process}\" finalizado em \"{state}\"", - "NewProcessToDo": "Nova ação de processo" + "NewProcessToDo": "Nova ação de processo", + "EmptyArray": "Array vazio", + "ExecutionInitiator": "Iniciador de Execução", + "ExecutionStarted": "Execução Iniciada" }, "error": { "MethodNotFound": "Método não encontrado: {methodId}", diff --git a/plugins/process-assets/lang/ru.json b/plugins/process-assets/lang/ru.json index 8f4ab88822..c714675e54 100644 --- a/plugins/process-assets/lang/ru.json +++ b/plugins/process-assets/lang/ru.json @@ -114,7 +114,10 @@ "ProcessRunned": "Процесс \"{process}\" запущен", "ProcessStateChanged": "Состояние процесса \"{process}\" изменено на \"{state}\"", "ProcessFinished": "Процесс \"{process}\" завершен в состояние \"{state}\"", - "NewProcessToDo": "Новый Action Item процесса" + "NewProcessToDo": "Новый Action Item процесса", + "EmptyArray": "Пустой массив", + "ExecutionInitiator": "Инициатор выполнения", + "ExecutionStarted": "Выполнение начато" }, "error": { "MethodNotFound": "Метод не найден: {methodId}", diff --git a/plugins/process-assets/lang/zh.json b/plugins/process-assets/lang/zh.json index 2c204cc17b..9f30e3c71b 100644 --- a/plugins/process-assets/lang/zh.json +++ b/plugins/process-assets/lang/zh.json @@ -114,7 +114,10 @@ "ProcessRunned": "过程 \"{process}\" 已启动", "ProcessStateChanged": "过程 \"{process}\" 状态已更改为 \"{state}\"", "ProcessFinished": "过程 \"{process}\" 已在状态 \"{state}\" 中完成", - "NewProcessToDo": "新过程待办事项" + "NewProcessToDo": "新过程待办事项", + "EmptyArray": "空数组", + "ExecutionInitiator": "执行发起者", + "ExecutionStarted": "执行已启动" }, "error": { "MethodNotFound": "找不到方法:{methodId}", diff --git a/plugins/process-resources/src/plugin.ts b/plugins/process-resources/src/plugin.ts index b8e426bcd1..41f333df5d 100644 --- a/plugins/process-resources/src/plugin.ts +++ b/plugins/process-resources/src/plugin.ts @@ -198,6 +198,9 @@ export default mergeIds(processId, process, { AddResult: '' as IntlString, For: '' as IntlString, Attribute: '' as IntlString, - Context: '' as IntlString + Context: '' as IntlString, + EmptyArray: '' as IntlString, + ExecutionInitiator: '' as IntlString, + ExecutionStarted: '' as IntlString } }) diff --git a/plugins/process-resources/src/utils.ts b/plugins/process-resources/src/utils.ts index 5bec692a58..4d0da0d64c 100644 --- a/plugins/process-resources/src/utils.ts +++ b/plugins/process-resources/src/utils.ts @@ -297,7 +297,7 @@ function getContextFunctions ( switch (category) { case 'array': { if (func.category === 'array') { - if (hierarchy.isDerived(func.of, target)) { + if (hierarchy.isDerived(func.of, target) || func.of === core.class.ArrOf) { matched.push(func._id) } } diff --git a/plugins/process/src/index.ts b/plugins/process/src/index.ts index de396e951f..e53c38c111 100644 --- a/plugins/process/src/index.ts +++ b/plugins/process/src/index.ts @@ -309,6 +309,10 @@ export default plugin(processId, { RemoveLast: '' as Ref, CurrentEmployee: '' as Ref, CurrentUser: '' as Ref, + ExecutionStarted: '' as Ref, + ExecutionEmployeeInitiator: '' as Ref, + ExecutionInitiator: '' as Ref, + EmptyArray: '' as Ref, CurrentDate: '' as Ref } }) diff --git a/server-plugins/process-resources/src/transform.ts b/server-plugins/process-resources/src/transform.ts index cadd5b255b..b2b372ba4e 100644 --- a/server-plugins/process-resources/src/transform.ts +++ b/server-plugins/process-resources/src/transform.ts @@ -375,4 +375,29 @@ export async function CurrentDate (): Promise { return Date.now() } +export function EmptyArray (): any[] { + return [] +} + +export async function ExecutionInitiator ( + value: null, + props: Record, + control: ProcessControl, + execution: Execution +): Promise | undefined> { + const socialId = await control.client.findOne(contact.class.SocialIdentity, { + _id: (execution.createdBy ?? execution.modifiedBy) as any + }) + return socialId?.attachedTo +} + +export async function ExecutionStarted ( + value: null, + props: Record, + control: ProcessControl, + execution: Execution +): Promise { + return execution.createdOn ?? execution.modifiedOn +} + // #endregion diff --git a/server-plugins/process/src/index.ts b/server-plugins/process/src/index.ts index c0a7d9f4cf..89efa63e73 100644 --- a/server-plugins/process/src/index.ts +++ b/server-plugins/process/src/index.ts @@ -94,7 +94,10 @@ export default plugin(serverProcessId, { RemoveFirst: '' as Resource, RemoveLast: '' as Resource, CurrentUser: '' as Resource, - CurrentDate: '' as Resource + CurrentDate: '' as Resource, + EmptyArray: '' as Resource, + ExecutionInitiator: '' as Resource, + ExecutionStarted: '' as Resource }, trigger: { OnTransition: '' as Resource,