@bpmnkit/feel
v1.1.1
Published
FEEL (Friendly Enough Expression Language) parser, evaluator, formatter and highlighter — 94% DMN TCK conformance
Downloads
2,832
Maintainers
Readme
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/feelQuick 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) // trueSyntax 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
| Export | Description |
|--------|-------------|
| 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 }
}Related Packages
| Package | Description |
|---------|-------------|
| @bpmnkit/core | BPMN/DMN/Form parser, builder, layout engine |
| @bpmnkit/canvas | Zero-dependency SVG BPMN viewer |
| @bpmnkit/editor | Full-featured interactive BPMN editor |
| @bpmnkit/engine | Lightweight BPMN process simulator for tests and demos |
| @bpmnkit/plugins | 34 composable canvas plugins |
| @bpmnkit/api | Camunda 8 REST API TypeScript client |
| @bpmnkit/ascii | Render BPMN diagrams as Unicode ASCII art |
| @bpmnkit/markdown | BPMN diagrams in Markdown — remark, markdown-it and README pre-rendering |
| @bpmnkit/docspack | BPMN Kit docs as an offline docspack package for AI agents |
| @bpmnkit/camunda-docspack | Camunda 8 docs as an offline docspack package for AI agents |
| @bpmnkit/ui | Shared design tokens and UI components |
| @bpmnkit/profiles | Shared auth, profile storage, and client factories for CLI & proxy |
| @bpmnkit/operate | Monitoring & operations frontend for Camunda clusters |
| @bpmnkit/connector-gen | Generate connector templates from OpenAPI specs |
| @bpmnkit/connectors | Camunda 8 OOTB connector catalog and deterministic template application |
| @bpmnkit/cli | Camunda 8 command-line interface (casen) |
| @bpmnkit/proxy | Local AI bridge and Camunda API proxy server |
| @bpmnkit/patterns | Domain process patterns for BPMNKit AIKit |
| @bpmnkit/reebe-wasm | WebAssembly BPMN engine for browser simulation |
| @bpmnkit/worker-client | Thin Zeebe REST client for standalone workers |
| @bpmnkit/flow | Code-first durable flows that derive BPMN, job types and workers |
| @bpmnkit/user-tasks | Embeddable user task widget for Camunda 8 |
| @bpmnkit/cli-sdk | Plugin authoring SDK for the casen CLI |
| @bpmnkit/create-casen-plugin | Scaffold a new casen CLI plugin in seconds |
| @bpmnkit/casen-report | HTML reports from Camunda 8 incident and SLA data |
| @bpmnkit/casen-worker-http | Example HTTP worker plugin — completes jobs with live JSONPlaceholder API data |
| @bpmnkit/casen-worker-ai | AI task worker — classify, summarize, extract, and decide using Claude |
