探员: 读取
node_modules/@bpmnkit/core/AGENTS.md,则node_modules/@bpmnkit/core/agent-cards/<bpmn|dmn|form>.md(~1k令牌)取而代之的是这个README.
核心层. Semver at 1.0:没有大放送,没有突破. 见 产品级。 。 。 .
概览
@bpmnkit/core 是BPMN Kit的基础。 它给你一切与BPMN 2.0,DMN 1.3,和Camunda Form定义在纯TypeScript中的工作——没有XML摔跤,没有运行时间依赖.
Parse → Modify → Validate → Export
特征
- BPMN 2.0 (英语) 分析、创建和导出全Zeebe/Camunda 8扩展支持的流程图
- 流利构建器 API ——在程序上构建有效的进程,永远不要触摸原始 XML
- 杉山布局引擎 ——有清洁正交边缘路由的自动定位元素
- 电话1.3 决策表,包括感觉表达支持
- Camunda 表格定义 – 类型安全形式建构器
- 优化器 ——内置规则引擎以检测和自动固定反标
- 压缩格式 - 在AI/LLM工作流程中,70%的代号效率较低的JSON代表
- 连接器目录 全部Camunda 8 箱外连接器模板,经确定后应用(
@bpmnkit/core/connectors(中文(简体) ) - 无依赖 ——以浏览器,节点.js,Deno,Bun,和边缘运行时间运行
安装
npm install @bpmnkit/core
pnpm add @bpmnkit/core
快速启动
从代码构建进程
每个元素都要 (id, options)。在网关外的分会与
.branch(),而不是通过手接接线流——构建者创造出序列流.
import { Bpmn } from "@bpmnkit/core"
const defs = Bpmn.createProcess("order-flow")
.name("Order Flow")
.startEvent("start", { name: "Order Received" })
.serviceTask("validate", {
name: "Validate Order",
taskType: "order-validator",
ioMapping: {
inputs: [{ source: "=order", target: "order" }],
outputs: [{ source: "=valid", target: "isValid" }],
},
})
.exclusiveGateway("check", { name: "Order Valid?" })
.branch("valid", (b) =>
b
.condition("=isValid = true")
.serviceTask("fulfill", { name: "Fulfill Order", taskType: "fulfillment-service" })
.endEvent("end", { name: "Order Complete" }),
)
.branch("invalid", (b) =>
b.defaultFlow().endEvent("reject-end", { name: "Order Rejected" }),
)
.withAutoLayout()
.build()
const xml = Bpmn.export(defs)
分进程、边界事件和多事件
这些是最常接触到和最常被猜测的构造,所以
确切的形状是值得描述的. subProcess 把身体当作一个 回调
(第二个论点)和备选案文三。 边界事件需要活动的ID
它附属于; withBoundary 从前面的活动中供给它.
import { Bpmn } from "@bpmnkit/core"
const defs = Bpmn.createProcess("fulfilment")
.name("Fulfilment")
.startEvent("start")
// Sub-process: id, content callback, then options.
// multiInstance runs the body once per item in the collection.
.subProcess(
"provision",
(sub) => {
sub
.startEvent("p-start")
.serviceTask("provision-line", { name: "Provision Line", taskType: "provision" })
.endEvent("p-end")
},
{
name: "Provision Each Line",
multiInstance: { collection: "=order.lines", elementVariable: "line", isSequential: false },
},
)
// withBoundary attaches to the activity just added — no id repeated.
.serviceTask("charge", { name: "Charge Payment", taskType: "payment" })
.withBoundary("charge-failed", { errorCode: "PAYMENT_FAILED" }, (b) => {
b.serviceTask("retry-charge", { name: "Retry Charge", taskType: "payment" }).endEvent("gave-up")
})
// Wait for whichever event arrives first.
.eventBasedGateway("await-payment", { name: "Paid?" })
.branch("paid", (b) =>
b
.intermediateCatchEvent("payment-confirmed", {
messageName: "PaymentConfirmed",
correlationKey: "=orderId",
})
.endEvent("done"),
)
.branch("timeout", (b) =>
b.intermediateCatchEvent("payment-timeout", { timerDuration: "P14D" }).endEvent("written-off"),
)
.withAutoLayout()
.build()
在不是前项活动时明确附上边界事件——两者均 下面的表单被接受,一个没有主机抛出而不是 导出无法读取的 BPMN :
.boundaryEvent("timeout", { attachedTo: "charge", timerDuration: "PT30M" })
.boundaryEvent("timeout", "charge", { timerDuration: "PT30M" })
事件定义是命名选项,而不是嵌入对象—— timerDuration, (中文(简体) ),
timerDate, (中文(简体) ), timerCycle, (中文(简体) ), messageName (与 correlationKey, (中文(简体) ),
errorCode, (中文(简体) ), signalName, (中文(简体) ), compensation。构建者不选择
知道被悄悄放弃了 所以 timer: { duration: "P7D" } 生成边界
没有计时器的事件.
分析并修改现有的 BPMN
import { Bpmn } from "@bpmnkit/core"
const defs = Bpmn.parse(xml)
const process = defs.processes[0]
// Access flow elements
for (const el of process.flowElements) {
console.log(el.type, el.id, el.name)
}
// Serialize back to XML
const updated = Bpmn.export(defs)
自动播放进程
import { applyAutoLayout, Bpmn } from "@bpmnkit/core"
// Lays out every process and writes the diagram interchange back onto the model.
const laid = Bpmn.export(applyAutoLayout(Bpmn.parse(xml)))
优化图表
import { Bpmn, optimize } from "@bpmnkit/core"
const defs = Bpmn.parse(xml)
const report = optimize(defs)
console.log(`${report.summary.total} findings`)
for (const finding of report.findings) {
console.log(`[${finding.severity}] ${finding.message}`)
if (finding.applyFix) {
const { description } = finding.applyFix(defs)
console.log("Fixed:", description)
}
}
AI/LLM工作流程的压缩格式
import { Bpmn, compactify, expand } from "@bpmnkit/core"
// Shrink for AI prompt
const defs = Bpmn.parse(xml)
const compact = compactify(defs) // ~70% smaller JSON
const json = JSON.stringify(compact) // send to LLM
// Restore full BPMN from AI response
const restored = expand(JSON.parse(json))
const outXml = Bpmn.export(restored)
模型还在写的时候渲染
一个模型一次发出一个符号,最外层 } - 那个
JSON.parse 等待——是它发送的最后一个字符. createCompactStream
将文字中的元素读取为自己的文字相近,所以
在文档完成前很久要绘制的东西 :
import { createCompactStream } from "@bpmnkit/core"
// `base` is the diagram being edited, so a frame shows the whole thing rather
// than the fragment the model is adding to it. Omit it to build from nothing.
const diagramStream = createCompactStream({ base: null })
function onModelChunk(chunk: string): void {
const frame = diagramStream.push(chunk) // null until the frame changes
if (frame) console.log("elements so far:", frame.processes[0]?.flowElements.length)
}
框架是对未完成文档的猜测 : push 不扔,不丢
无法放置,并期望呼叫者有权威结果.
API 参考
不丹
| 导出 | 说明 |
|---|---|
Bpmn.parse(xml) | 解析 BPMN XML — BpmnDefinitions |
Bpmn.export(defs) | 序列化 BpmnDefinitions • XML(XML) |
Bpmn.createProcess(id) | 开始 a ProcessBuilder; 设置名称为 .name(…) |
Bpmn.makeEmpty(processId?, name?) | 最小 BPMN XML 有一次启动事件 |
Bpmn.SAMPLE_XML | 3- 节点样本图字符串 |
进程构建器
每个元素方法都是 (id, options) 并返回建设者。 同样的方法
内有 .branch() 在一个子进程体内.
| 方法 | 说明 |
|---|---|
.name(name) 编号 : .versionTag(v) | 进程一级元数据 |
.startEvent(id?, options?) 编号 : .endEvent(id?, options?) | 活动; options.name 标签 |
.serviceTask(id, { taskType, ioMapping?, taskHeaders? }) | Zeebe 工作任务 |
.userTask(id, opts) 编号 : .businessRuleTask(id, { decisionRef }) 编号 : .scriptTask(id, opts) | 其他任务类型 |
.receiveTask(id, { message }) 编号 : .sendTask(id, opts) 编号 : .callActivity(id, opts) | 信息和呼叫活动 |
.restConnector(id, { method, url, … }) | Camunda 8 HTTP 连接器任务 |
.exclusiveGateway(id, opts) 编号 : .parallelGateway 编号 : .inclusiveGateway 编号 : .eventBasedGateway | 网关 |
.branch(name, b => …) | 离开前一个网关的一条道 |
b.condition(feel) 编号 : b.defaultFlow() | 标记分支的状态, 或者让它成为默认 |
.connectTo(id) | 流到现有或后期元素——合并和循环 |
.subProcess(id, content, options?) | 嵌入子进程; content 是一个召回 |
.transaction(id, content, options?) 编号 : .eventSubProcess 编号 : .adHocSubProcess | 其他集装箱 |
.withBoundary(id, options, handler) | 关于上述活动的边界事件及其路径 |
.boundaryEvent(id, options) | 命名其主机的边界事件 options.attachedTo |
.intermediateCatchEvent(id, opts) 编号 : .intermediateThrowEvent(id, opts) | 中间事件 |
.withAutoLayout() | 计算坐标 build() ——无用手取出x/y |
.build() | 生产 BpmnDefinitions; 传递给 Bpmn.export |
事件定义是该要素的选项: timerDuration, (中文(简体) ), timerDate, (中文(简体) ),
timerCycle, (中文(简体) ), messageName + 键 correlationKey, (中文(简体) ), errorCode, (中文(简体) ), signalName, (中文(简体) ),
compensation. 多方参与是 options.multiInstance = { collection, elementVariable, isSequential? }。 。 。 .
语义
| 导出 | 说明 |
|---|---|
semanticHash(defs) | 模型的SHA-256,不包括图. 未根据布局更改 |
projectSemantics(defs) | 空洞的散列投影 |
diffSemantics(a, b) | 两个模型之间发生什么变化,按元素 id 键 |
输入代码生成
| 导出 | 说明 |
|---|---|
generateProcessTypes(defs | defs[], options?) | TypeScript源打字工作类型(可变,输出,头部,出错),进程ID,消息,信号,出错和升级代码. 决定性 |
extractProcessContract(defs | defs[]) | 与数据相同的合同——什么 casen gen types 建立和建立 --check-workers 比较 |
编辑
| 导出 | 说明 |
|---|---|
applyBpmnOperations(defs, ops) | 将编辑操作应用到完整的模型中。 严格: 未解决的 ID 抛出 |
reconcileCompact(defs, compact) | 将紧凑图作为更改应用, 保留紧凑不能携带的 |
compactify(defs) | LLM 提示只读符号高效视图 。 丢失 — 不是编辑路径 |
写入文件( E)@bpmnkit/core/node(中文(简体) )
| 导出 | 说明 |
|---|---|
writeBpmn(defs, opts) | 序列化,读回,验证模型存活下来,然后写解剖 |
import { writeBpmn } from "@bpmnkit/core/node"
// Refuses rather than overwrite; pass force: true to replace.
const { semanticHash, changes } = await writeBpmn(defs, { output: "flow.bpmn" })
连接器( E)@bpmnkit/core/connectors(中文(简体) )
Camunda 8 出盒连接器目录, 隐藏在它的子路径后面, 所以它的数据只是
被输入密码捆绑 模板将图标、组、工具提示和
占位符; @bpmnkit/connectors
增加这些回 对于一个财产面板.
| 导出 | 说明 |
|---|---|
listConnectors() 编号 : searchConnectors(query) | 摘要:任务类型、方向、要求和可选投入 |
applyConnectorTemplate(id, values) | 捆绑模板的构建器选项,加问题 |
applyTemplateToElement(defs, id, template, values) | 对现有元素应用模板 |
validateElementTemplate(value) | 元素模板的结构检查 |
findConnectorCards(query) 编号 : formatConnectorCard(card) | 单张卡片,只限输入 模型的快取 |
applyConnectorLines(defs, lines) | 应用 with 线条格式的模型 |
selectConnectors({ text, tasks }) | 为图中的每个任务选择一个模型看到的牌 |
import { applyConnectorTemplate } from "@bpmnkit/core/connectors"
const { serviceTask, problems } = applyConnectorTemplate("io.camunda.connectors.HttpJson.v2", {
url: "https://api.example.com/orders",
})
丹麦
| 导出 | 说明 |
|---|---|
Dmn.parse(xml) | 分析 DMN XML — DmnDefinitions |
Dmn.export(defs) | 序列化 — XML |
Dmn.createDecisionTable(id, name?) | 开始 a DecisionTableBuilder |
Dmn.makeEmpty() | 带有一个空决定表的最小 DMN |
表单
| 导出 | 说明 |
|---|---|
Form.create() | 开始 a FormBuilder |
Form.parse(json) | 分析窗体方案 |
Form.export(schema) | 序列化 — JSON 字符串 |
布局优化( O)
| 导出 | 说明 |
|---|---|
layoutProcess(process) | 自动放出所有元素; 返回 LayoutResult |
optimize(defs) | 运行所有优化规则; 返回 OptimizeReport |
analyzeCamundaCompat(defs, version?) | 目标Camunda 8版本无法运行或需要的,例如 compat/* 调查结果——卡蒙达建模公司 @camunda/linting 规则 |
compactify(defs) | 转换为紧凑 CompactDiagram |
expand(compact) | 完全恢复 BpmnDefinitions |
createCompactStream(opts?) | 从模型的符号流中读取一个图表, 框架逐帧 |
parseProcessText(text) | 读取一个以行格式书写的模型的过程 (PROCESS_TEXT_GUIDE; 从未投掷 |
createProcessTextStream() | 流出时读取行格式, 一次完成一行 |
writeProcessText(defs) | 以行格式写出已存在的图表, 供模型读取; 返回文本和别名 ~ 元素 id 映射 |
parseProcessDelta(text) | 读取更改脚本( E)PROCESS_DELTA_GUIDE: 只有什么变化, 通过 id; 从不扔 |
generateId(prefix) | 生成一个独特的短ID |
流程文件
| 导出 | 说明 |
|---|---|
renderDocumentationHtml(defs, options?) | 自成一体,可打印的HTML:图,内容,按流程顺序排列的每个元素,链接的DMN表格和表格. 打印 → 另存为 PDF |
renderDocumentationMarkdown(defs, options?) | 与 Markdown 相同的内容, 对于 wikis 和 Collection |
renderDocumentationDocx(defs, options?) | 和一个字一样的内容 .docx (字节),图为 SVG |
buildProcessDocumentation(defs, options?) | 结构化的内容,为您自己的渲染器 |
options 带 decisions (单位:千美元)DmnDefinitions[], (中文(简体) ), forms (单位:千美元)FormDefinition[], (中文(简体) ), title, (中文(简体) ), subtitle 财务报告和审定财务报表 diagram。输出是决定性的,所有模型文本都逃脱.
相关软件包
| 软件包 | 说明 |
|---|---|
@bpmnkit/canvas | 零依赖 SVG BPMN 查看器 |
@bpmnkit/editor | 全功能交互式 BPMN 编辑器 |
@bpmnkit/engine | 用于测试和演示的轻量级 BPMN 流程模拟器 |
@bpmnkit/feel | 感觉表达式语言解析器和评估器 |
@bpmnkit/plugins | 34个可堆肥画布插件 |
@bpmnkit/api | Camunda 8 REST API TypeScript 客户端 |
@bpmnkit/ascii | 作为 Unicode ASCII 艺术的 Render BPMN 图表 |
@bpmnkit/markdown | Markdown中的 BPMN 图表—— 注释、 标记下和 README 预发 |
@bpmnkit/docspack | 不丹 Kit Docs 作为AI 代理的离线文件包 |
@bpmnkit/camunda-docspack | Camunda 8 个文件作为AI 代理的离线文件包 |
@bpmnkit/ui | 共享设计符和UI组件 |
@bpmnkit/profiles | CLI 代理共享认证、 配置文件存储和客户端工厂 |
@bpmnkit/operate | Camunda集群的监测与业务前端 |
@bpmnkit/connector-gen | 从 OpenAPI 规格生成连接器模板 |
@bpmnkit/connectors | Camunda 8 OOTB 连接器目录和确定模板应用程序 |
@bpmnkit/cli | Camunda 8 命令行接口( casen) |
@bpmnkit/proxy | 本地 AI 桥和 Camunda API 代理服务器 |
@bpmnkit/patterns | BPMNKit AIKit 域进程模式 |
@bpmnkit/reebe-wasm | WebAssembly BPMN 浏览器模拟引擎 |
@bpmnkit/worker-client | 独立工人的Thin Zeebe REST客户端 |
@bpmnkit/flow | 源自BPMN、工作类型和工人的代码第一持久流动 |
@bpmnkit/user-tasks | Camunda 8 可嵌入的用户任务部件 |
@bpmnkit/cli-sdk | 为 casen CLI 创建 SDK 插件 |
@bpmnkit/create-casen-plugin | 脚手架, 在秒内新建一个 clin CLI 插件 |
@bpmnkit/casen-report | 来自 Camunda 8 事件的 HTML 报告和 SLA 数据 |
@bpmnkit/casen-worker-http | 示例 HTTP 工人插件 – 用活的 JSONPlaceholders API 数据完成工作 |
@bpmnkit/casen-worker-ai | AI任务工作人员——分类、总结、提取和决定使用克洛德 |
许可证
麻省理工学院 BPMN Kit—— 制片人: u11g (单位:千克)