Skip to content
On this page

数据模型

设计器产物为声明式 ProcessFlow。本页描述类型、默认配置与包导出。节点语义与端口见 节点与连线

ProcessFlow

ts
type ProcessFlowStatus = 'draft' | 'published'

type ProcessFlow = {
  version: 1
  id: string
  name: string
  status: ProcessFlowStatus
  nodes: ProcessFlowNode[]
  edges: ProcessFlowEdge[]
  updatedAt?: string
}
字段说明
version固定为 1
id / name流标识与展示名
status草稿 / 已发布;工具栏仅展示
nodes / edges流程图;边引用节点 id
updatedAtISO 字符串;每次 commit 刷新

设计期 vs 运行时

当前包只负责编排与序列化 ProcessFlow。实例推进、待办、消息发送等运行时能力尚未内置。

节点与边

ts
type ProcessNodeCategory =
  | 'human' | 'event' | 'system' | 'state' | 'decision' | 'branch'

type ProcessNodeType =
  | 'countersign' | 'add-sign' | 'approver' | 'cc' | 'handler'
  | 'start' | 'start-message' | 'start-timer'
  | 'end-event' | 'terminate' | 'message-notify'
  | 'service-task' | 'subprocess'
  | 'state'
  | 'script-task' | 'business-rule-task'
  | 'condition-branch' | 'parallel-branch'

type ProcessFlowNode<T extends ProcessNodeType = ProcessNodeType> = {
  id: string
  type: T
  name: string
  position: { x: number; y: number }
  config: ProcessNodeConfigMap[T]
}

type ProcessTransitionKind = 'forward' | 'rollback' | 'jump'

type ProcessFlowEdge = {
  id: string
  source: string
  target: string
  sourceHandle?: string | null
  targetHandle?: string | null
  label?: string
  transitionKind?: ProcessTransitionKind
  condition?: string
  priority?: number
  remark?: string
}
边字段说明
transitionKind正向流转 / 回退 / 跳转(默认 forward
condition连线级条件表达式(可选)
priority条件分支多出口时的优先级
Handle默认 out-bottomin-top;分支为 out-b-{armId}

人员指派

ts
type ProcessAssigneeType =
  | 'user' | 'initiator' | 'initiator-select' | 'role'
  | 'direct-supervisor' | 'dept-manager' | 'multi-level-supervisor'
  | 'dept' | 'expression' | 'initiator-leader' // 后三项偏兼容

type ProcessPersonAssignExtras = {
  selectScope?: 'all' | 'same-dept' | 'role' | 'users'
  selectScopeValue?: string
  selectMin?: number
  selectMax?: number // 0=不限
  relativeTo?: 'initiator' | 'previous' | 'form-field'
  relativeField?: string
  deptFrom?: 'initiator' | 'form-field' | 'specified'
  deptFromValue?: string
  deptLevel?: 'current' | 'parent' | 'grandparent' | 'level-n'
  deptLevelN?: number
  includeDeputy?: boolean
  supervisorEnd?: 'levels' | 'top' | 'until-role'
  supervisorLevels?: number
  supervisorUntilRole?: string
  supervisorMode?: 'sequential' | 'parallel'
  skipDuplicate?: boolean
  skipIfInitiator?: boolean
  emptyFallback?: 'skip' | 'error' | 'to-user' | 'to-role'
  emptyFallbackValue?: string
}

type ProcessHumanCommon = {
  description?: string
  enableWhen?: string
  skipWhen?: string
  timeoutAction?: 'none' | 'auto-pass' | 'auto-reject' | 'notify' | 'escalate'
  escalateTo?: string
}

UI 主选项见 PERSON_ASSIGNEE_TYPE_OPTIONS(指定成员 / 发起人 / 自选 / 角色 / 直属主管 / 部门主管 / 连续多级主管)。

节点 config 摘要

完整字段以源码 types.ts 为准;此处按类别列出要点。

人工

type关键字段
countersignassigneeType / assignees / passRule(all/any/percent/sequential)/ passPercent / onReject
add-signmode(before/after/parallel)/ assignee / returnToOrigin
approverapprovers + ProcessPersonAssignExtras / rejectStrategy / sequential
ccrecipients / timing(on-enter/on-leave)/ channel
handlerhandlers / resultOptions / priority

事件

type关键字段
startinitiatorType / formKey / bizType / initVariables
start-messagemessageName / correlationKey / payloadMap
start-timerscheduleType(cron/delay/rate)/ schedule / misfirePolicy
end-eventoutcome / terminateAll / bizStatus
terminatereason / audit / notifyInitiator
message-notifychannel / recipients / webhookUrl / failOnError

系统 / 状态 / 决策

type关键字段
service-taskprotocol / endpoint / method / retry / authType / resultVariable
subprocessprocessRef / sync / inputMap / outputMap / multiInstance
statestateKey / allowRollbackTo / allowJumpTo / isTerminal / bizField
script-tasklanguage / script / resultVariable
business-rule-taskruleSetId / hitPolicy(first/collect)/ failOnMiss

分支

ts
type ProcessConditionArm = {
  id: string
  label: string
  logic?: 'and' | 'or'
  conditions?: Array<{ field: string; op: string; value: string }>
  expression?: string
}

type ProcessConditionBranchConfig = {
  branches?: ProcessConditionArm[] // 不含固定默认出口
  remark?: string
}

type ProcessParallelBranchConfig = {
  branches?: Array<{ id: string; label: string }>
  joinMode?: 'all' | 'any' | 'count'
  joinCount?: number
  remark?: string
}

条件分支画布固定默认锚点 out-b-defaultCONDITION_DEFAULT_ARM_ID = 'default'),不进入可编辑 branches 列表。条件出口约 1–10 条;并行出口约 2–10 条。

工厂与导出

ts
import {
  GrowProcessDesigner,
  createProcessFlow,
  createProcessFlowNode,
  createProcessFlowEdge,
  cloneProcessFlow,
  defaultConfigForType,
  CATEGORY_META,
  NODE_TYPE_META,
  PALETTE_GROUPS,
  PERSON_ASSIGNEE_TYPE_OPTIONS,
  TRANSITION_KIND_OPTIONS,
  RULE_OP_OPTIONS,
  canConnectNodes,
  isStartNodeType,
  isEndNodeType,
  type ProcessFlow,
  type ProcessFlowNode,
  type ProcessNodeType,
} from '@grow-admin-rock/process-engine'
API说明
createProcessFlow({ name, ... })新建流;默认 status: 'draft'
createProcessFlowNode(type, patch?)按类型填默认名与 config
createProcessFlowEdge({ source, target, ... })默认 handle:out-bottomin-top
cloneProcessFlow(flow)JSON 深拷贝
defaultConfigForType(type)该类型默认 config
canConnectNodes / isStartNodeType / isEndNodeType连线与起止判定
resolveSourceHandle / resolveTargetHandleHandle 归一化(兼容旧横向 id)

另导出大量 UI 选项常量(超时动作、驳回策略、协议、脚本语言、汇聚模式等),见包入口与 nodeCatalog.ts

相关文档