@emaarco/dmn-js-simulation

中文文档
0.4.1发布于 2026/11/12MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 1.2万

Simulate DMN decision tables directly in a dmn-js modeler — see which rules match and what the decision returns.

原始使用文档
文档目录8 节
  1. The idea behind this project
  2. Features
  3. Installation
  4. Usage
  5. Evaluate without a modeler
  6. Contributing
  7. Credits
  8. License

@emaarco/dmn-js-simulation

npm version license live demo

Simulate DMN decision tables directly in a dmn-js modeler — feed in concrete inputs and instantly see which rules match, which don't, and what the decision returns.

Drilling from the DRD into the Recommend Bike table, entering Road and 2500, then simulating highlights rule 3 and shows Model = Road Pro

The idea behind this project

@emaarco/dmn-js-simulation is to DMN what bpmn-js-token-simulation is to BPMN: it lets you validate decision logic while you model it, instead of discovering mistakes later in process code, tests, or production. It supports all DMN hit policies (UNIQUE, FIRST, ANY, PRIORITY, COLLECT with SUM/MIN/MAX/COUNT, RULE ORDER, OUTPUT ORDER) and multi-decision DRD chaining.

Features

  • Decision-table simulation — an input form appears above the table; run it to highlight the matched rule(s) and read off the result. Rules dropped by the hit policy (e.g. under FIRST/PRIORITY) are shown as dimmed candidates, so the policy's effect is visible.
  • All hit policies, including COLLECT aggregations and policy-violation warnings (e.g. UNIQUE matched twice).
  • DRD chaining — simulate a whole decision requirement graph: set the input-data leaves once, and every decision is evaluated in dependency order. Fired decisions are highlighted and annotated with their result; drilling into a decision reflects that run's row highlights.
  • Drop-in — installs like any dmn-js module via additionalModules; dmn-js is a peer dependency, so it drives the modeler you already use.
  • Themeable — all UI is class-namespaced and driven by CSS variables you can override.

Installation

npm install @emaarco/dmn-js-simulation

dmn-js (>= 17) is a peer dependency — install it if you haven't already.

Usage

import DmnModeler from 'dmn-js/lib/Modeler'
import DmnSimulationModule from '@emaarco/dmn-js-simulation'
import '@emaarco/dmn-js-simulation/assets/dmn-js-simulation.css'

const modeler = new DmnModeler({
  container: '#canvas',
  decisionTable: { additionalModules: [DmnSimulationModule.decisionTable] },
  drd: { additionalModules: [DmnSimulationModule.decisionRequirementsDiagram] },
})

await modeler.importXML(dmnXml)

Register only the view(s) you need. The modules are also exported individually:

import { DmnSimulationTableModule, DmnSimulationDecisionRequirementsDiagramModule } from '@emaarco/dmn-js-simulation'

DRD view: make sure your app imports dmn-js's icon font (dmn-js/dist/assets/dmn-font/css/dmn-embedded.css) alongside its other stylesheets — otherwise the DRD editor palette icons render blank.

Evaluate without a modeler

The framework-free evaluation core is exported too, for tests or headless use:

import { DmnXmlReader, DecisionTableEvaluator } from '@emaarco/dmn-js-simulation'

const model = new DmnXmlReader().readDecisionTable(dmnXml)
const result = new DecisionTableEvaluator(model).evaluate(['Fall', 8])
// → { matchedRuleIndices, reportedRuleIndices, outputs, aggregation?, violation? }

new DmnModdleReader().readDecisionRequirementsDiagram(definitions) + new DecisionRequirementsDiagramEvaluator(model).evaluate(inputValues) do the same for a whole DRD graph.

Contributing

Contributions are welcome — see CONTRIBUTING.md for the monorepo layout, scripts, and how to build, test and run the example locally.

Credits

License

MIT © Marco Schäck

版本与发布记录

@emaarco/dmn-js-simulation 共发布 8 个版本,首次发布于 2026/08/03;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.1latest2026/11/121 天前
0.4.02026/10/2519 天前
0.3.22026/10/051 个月前
0.3.12026/09/211 个月前
0.3.02026/09/211 个月前
0.2.02026/08/073 个月前

关于 @emaarco/dmn-js-simulation 的常见问题

@emaarco/dmn-js-simulation 是什么?

Simulate DMN decision tables directly in a dmn-js modeler — see which rules match and what the decision returns.

如何安装 @emaarco/dmn-js-simulation?

在项目目录运行 npm install @emaarco/dmn-js-simulation,或使用 pnpm add / yarn add / bun add。

@emaarco/dmn-js-simulation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@emaarco/dmn-js-simulation 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@emaarco/dmn-js-simulation 可以商用吗?

@emaarco/dmn-js-simulation 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@emaarco/dmn-js-simulation 的下载量有多少?

根据 npm 官方下载统计,@emaarco/dmn-js-simulation 在 2026/10/14 – 2026/11/12 这 30 天内被下载 11,676 次,日均约 389 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@emaarco/dmn-js-simulation 还在维护吗?

最新版本 0.4.1 发布于 2026/11/12(1 天前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/08/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。