Empty array process function (#9977)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2025-09-30 21:05:59 +07:00
committed by GitHub
parent 80886e8201
commit 5fa0bb3c64
17 changed files with 147 additions and 13 deletions
+48
View File
@@ -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,
+21
View File
@@ -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: {
+4 -1
View File
@@ -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}",
+4 -1
View File
@@ -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}",
+4 -1
View File
@@ -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}",
+4 -1
View File
@@ -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}",
+4 -1
View File
@@ -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}",
+4 -1
View File
@@ -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}",
+4 -1
View File
@@ -113,7 +113,10 @@
"ProcessRunned": "プロセス \"{process}\" が開始されました",
"ProcessStateChanged": "プロセス \"{process}\" の状態が \"{state}\" に変更されました",
"ProcessFinished": "プロセス \"{process}\" が状態 \"{state}\" で終了しました",
"NewProcessToDo": "新しいプロセスアクション"
"NewProcessToDo": "新しいプロセスアクション",
"EmptyArray": "空の配列",
"ExecutionInitiator": "実行の発起人",
"ExecutionStarted": "実行が開始されました"
},
"error": {
"MethodNotFound": "メソッドが見つかりません: {methodId}",
+4 -1
View File
@@ -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}",
+4 -1
View File
@@ -114,7 +114,10 @@
"ProcessRunned": "Процесс \"{process}\" запущен",
"ProcessStateChanged": "Состояние процесса \"{process}\" изменено на \"{state}\"",
"ProcessFinished": "Процесс \"{process}\" завершен в состояние \"{state}\"",
"NewProcessToDo": "Новый Action Item процесса"
"NewProcessToDo": "Новый Action Item процесса",
"EmptyArray": "Пустой массив",
"ExecutionInitiator": "Инициатор выполнения",
"ExecutionStarted": "Выполнение начато"
},
"error": {
"MethodNotFound": "Метод не найден: {methodId}",
+4 -1
View File
@@ -114,7 +114,10 @@
"ProcessRunned": "过程 \"{process}\" 已启动",
"ProcessStateChanged": "过程 \"{process}\" 状态已更改为 \"{state}\"",
"ProcessFinished": "过程 \"{process}\" 已在状态 \"{state}\" 中完成",
"NewProcessToDo": "新过程待办事项"
"NewProcessToDo": "新过程待办事项",
"EmptyArray": "空数组",
"ExecutionInitiator": "执行发起者",
"ExecutionStarted": "执行已启动"
},
"error": {
"MethodNotFound": "找不到方法:{methodId}",
+4 -1
View File
@@ -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
}
})
+1 -1
View File
@@ -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)
}
}
+4
View File
@@ -309,6 +309,10 @@ export default plugin(processId, {
RemoveLast: '' as Ref<ProcessFunction>,
CurrentEmployee: '' as Ref<ProcessFunction>,
CurrentUser: '' as Ref<ProcessFunction>,
ExecutionStarted: '' as Ref<ProcessFunction>,
ExecutionEmployeeInitiator: '' as Ref<ProcessFunction>,
ExecutionInitiator: '' as Ref<ProcessFunction>,
EmptyArray: '' as Ref<ProcessFunction>,
CurrentDate: '' as Ref<ProcessFunction>
}
})
@@ -375,4 +375,29 @@ export async function CurrentDate (): Promise<Timestamp> {
return Date.now()
}
export function EmptyArray (): any[] {
return []
}
export async function ExecutionInitiator (
value: null,
props: Record<string, any>,
control: ProcessControl,
execution: Execution
): Promise<Ref<Person> | 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<string, any>,
control: ProcessControl,
execution: Execution
): Promise<Timestamp> {
return execution.createdOn ?? execution.modifiedOn
}
// #endregion
+4 -1
View File
@@ -94,7 +94,10 @@ export default plugin(serverProcessId, {
RemoveFirst: '' as Resource<TransformFunc>,
RemoveLast: '' as Resource<TransformFunc>,
CurrentUser: '' as Resource<TransformFunc>,
CurrentDate: '' as Resource<TransformFunc>
CurrentDate: '' as Resource<TransformFunc>,
EmptyArray: '' as Resource<TransformFunc>,
ExecutionInitiator: '' as Resource<TransformFunc>,
ExecutionStarted: '' as Resource<TransformFunc>
},
trigger: {
OnTransition: '' as Resource<TriggerFunc>,