@bpmnkit/feel

中文文档
1.1.1发布于 2026/10/08MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2403

FEEL (Friendly Enough Expression Language) parser, evaluator, formatter and highlighter — 94% DMN TCK conformance

原始使用文档
文档目录11 节
  1. Overview
  2. Features
  3. Installation
  4. Quick Start
  5. Evaluate an expression
  6. Evaluate unary tests (DMN input expressions)
  7. Syntax highlighting
  8. API Reference
  9. ParseResult
  10. Related Packages
  11. License
BPMN Kit logo

@bpmnkit/feel

FEEL (Friendly Enough Expression Language) parser, evaluator, formatter and highlighter — 94% DMN TCK conformance

npm license typescript ai-assisted tier: core

Website · Documentation · GitHub · Changelog

Core tier. Semver at 1.0: nothing breaks without a major release. See product tiers.


Overview

@bpmnkit/feel implements the FEEL expression language used in DMN decision tables and BPMN condition expressions, and passes 1,941 of the 2,053 FEEL cases in the DMN TCK (94.5%) — the remaining cases are listed with their reasons in tests/tck.test.ts. It implements Camunda 8's extensions to FEEL too, and matches 375 of the 378 runnable examples in Camunda's FEEL documentation (tests/camunda-parity.test.ts). It includes a tokenizer, recursive-descent parser, AST evaluator, formatter, and syntax highlighter.

Features

  • Full FEEL grammar — arithmetic, comparisons, logic, function calls, paths, filters
  • Temporal types — date, time, datetime, duration (ISO 8601, full spec compliance)
  • Unary tests — DMN input expression syntax (> 5, "gold", "silver", [1..10])
  • Built-in functions — 101 FEEL functions (string, list, numeric, date, context, range), including Camunda's extensions (assert, partition, to json, fromAi, …)
  • Range expressions — [1..10], (0..1), [today..end]
  • Context literals — { key: value, nested: { x: 1 } }
  • Syntax highlighting — semantic token classification for editors
  • Zero dependencies

Installation

npm install @bpmnkit/feel

Quick Start

Evaluate an expression

import { parseExpression, evaluate } from "@bpmnkit/feel"

const parsed = parseExpression("amount * 1.2 + fee")
if (!parsed.errors.length) {
  // `evaluate` takes an EvalContext — variables live under `vars`.
  const result = evaluate(parsed.ast!, { vars: { amount: 100, fee: 5 } })
  console.log(result) // 125
}

Evaluate unary tests (DMN input expressions)

import { parseUnaryTests, evaluateUnaryTests } from "@bpmnkit/feel"

// Does input value match any listed condition?
const parsed = parseUnaryTests('"gold","silver"')
const matches = evaluateUnaryTests(parsed.ast!, "gold", { vars: {} })
console.log(matches) // true

Syntax highlighting

import { annotate, highlightToHtml } from "@bpmnkit/feel"

// Classified tokens, for an editor to style itself.
annotate("x > 1")[0] // { kind: "variable", value: "x", start: 0, end: 1 }

// Or the same tokens already wrapped in <span class="feel-…"> elements.
highlightToHtml('if x > 10 then "high" else "low"')

API Reference

ExportDescription
parseExpression(src)Parse a FEEL expression → ParseResult
parseUnaryTests(src)Parse unary tests → ParseResult
evaluate(ast, ctx)Evaluate a parsed expression; ctx is { vars }
evaluateUnaryTests(ast, input, ctx)Test input against unary tests
formatFeel(node, opts?)Pretty-print a parsed node, not source text
highlightToHtml(src)Tokens wrapped in <span class="feel-…"> elements
highlightFeel(src)Alias for highlightToHtml
tokenize(src)Raw token stream
annotate(src)Tokens classified for highlighting (kind, value, start, end)

ParseResult

interface ParseResult {
  ast: FeelNode | null
  errors: ParseError[]   // { message, start, end }
}

PackageDescription
@bpmnkit/coreBPMN/DMN/Form parser, builder, layout engine
@bpmnkit/canvasZero-dependency SVG BPMN viewer
@bpmnkit/editorFull-featured interactive BPMN editor
@bpmnkit/engineLightweight BPMN process simulator for tests and demos
@bpmnkit/plugins34 composable canvas plugins
@bpmnkit/apiCamunda 8 REST API TypeScript client
@bpmnkit/asciiRender BPMN diagrams as Unicode ASCII art
@bpmnkit/markdownBPMN diagrams in Markdown — remark, markdown-it and README pre-rendering
@bpmnkit/docspackBPMN Kit docs as an offline docspack package for AI agents
@bpmnkit/camunda-docspackCamunda 8 docs as an offline docspack package for AI agents
@bpmnkit/uiShared design tokens and UI components
@bpmnkit/profilesShared auth, profile storage, and client factories for CLI & proxy
@bpmnkit/operateMonitoring & operations frontend for Camunda clusters
@bpmnkit/connector-genGenerate connector templates from OpenAPI specs
@bpmnkit/connectorsCamunda 8 OOTB connector catalog and deterministic template application
@bpmnkit/cliCamunda 8 command-line interface (casen)
@bpmnkit/proxyLocal AI bridge and Camunda API proxy server
@bpmnkit/patternsDomain process patterns for BPMNKit AIKit
@bpmnkit/reebe-wasmWebAssembly BPMN engine for browser simulation
@bpmnkit/worker-clientThin Zeebe REST client for standalone workers
@bpmnkit/flowCode-first durable flows that derive BPMN, job types and workers
@bpmnkit/user-tasksEmbeddable user task widget for Camunda 8
@bpmnkit/cli-sdkPlugin authoring SDK for the casen CLI
@bpmnkit/create-casen-pluginScaffold a new casen CLI plugin in seconds
@bpmnkit/casen-reportHTML reports from Camunda 8 incident and SLA data
@bpmnkit/casen-worker-httpExample HTTP worker plugin — completes jobs with live JSONPlaceholder API data
@bpmnkit/casen-worker-aiAI task worker — classify, summarize, extract, and decide using Claude

License

MIT © BPMN Kit — made by u11g

BPMN Kit

版本与发布记录

@bpmnkit/feel 共发布 16 个版本,首次发布于 2026/03/15;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.1latest2026/10/081 个月前
1.1.02026/09/281 个月前
1.0.02026/09/191 个月前
0.1.02026/09/161 个月前
0.0.212026/09/151 个月前
0.0.202026/08/222 个月前

关于 @bpmnkit/feel 的常见问题

@bpmnkit/feel 是什么?

FEEL (Friendly Enough Expression Language) parser, evaluator, formatter and highlighter — 94% DMN TCK conformance

如何安装 @bpmnkit/feel?

在项目目录运行 npm install @bpmnkit/feel,或使用 pnpm add / yarn add / bun add。

@bpmnkit/feel 支持 TypeScript 吗?

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

@bpmnkit/feel 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bpmnkit/feel 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bpmnkit/feel 可以商用吗?

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

@bpmnkit/feel 的下载量有多少?

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

@bpmnkit/feel 还在维护吗?

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