@bpmn-sdk/feel
v0.0.8
Published
Complete FEEL (Friendly Enough Expression Language) implementation — parser, evaluator, and highlighter
Maintainers
Readme
Documentation · GitHub · Changelog
Overview
@bpmn-sdk/feel is a complete implementation of the FEEL expression language used in DMN decision tables and BPMN condition expressions. 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 — 50+ standard FEEL functions (string, list, numeric, date, context)
- 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 @bpmn-sdk/feelQuick Start
Evaluate an expression
import { parseExpression, evaluate } from "@bpmn-sdk/feel"
const parsed = parseExpression("amount * 1.2 + fee")
if (!parsed.errors.length) {
const result = evaluate(parsed.ast!, { amount: 100, fee: 5 })
console.log(result) // 125
}Evaluate unary tests (DMN input expressions)
import { parseUnaryTests, evaluateUnaryTests } from "@bpmn-sdk/feel"
// Does input value match any listed condition?
const parsed = parseUnaryTests('"gold","silver"')
const matches = evaluateUnaryTests(parsed.ast!, "gold", { /* context */ })
console.log(matches) // trueSyntax highlighting
import { highlightFeel } from "@bpmn-sdk/feel"
const tokens = highlightFeel('if x > 10 then "high" else "low"')
for (const token of tokens) {
console.log(token.type, token.value) // keyword, number, string, ...
}API Reference
| Export | Description |
|--------|-------------|
| parseExpression(src) | Parse a FEEL expression → ParseResult |
| parseUnaryTests(src) | Parse unary tests → ParseResult |
| evaluate(ast, ctx) | Evaluate a parsed expression |
| evaluateUnaryTests(ast, input, ctx) | Test input against unary tests |
| formatFeel(src) | Pretty-print a FEEL expression |
| highlightFeel(src) | Tokenize with semantic types for highlighting |
| tokenize(src) | Raw token stream |
| annotate(src) | Full AST with position metadata |
ParseResult
interface ParseResult {
ast: FeelNode | null
errors: ParseError[] // { message, position }
}Related Packages
| Package | Description |
|---------|-------------|
| @bpmn-sdk/core | BPMN/DMN/Form parser, builder, layout engine |
| @bpmn-sdk/canvas | Zero-dependency SVG BPMN viewer |
| @bpmn-sdk/editor | Full-featured interactive BPMN editor |
| @bpmn-sdk/engine | Lightweight BPMN process execution engine |
| @bpmn-sdk/plugins | 22 composable canvas plugins |
| @bpmn-sdk/api | Camunda 8 REST API TypeScript client |
| @bpmn-sdk/ascii | Render BPMN diagrams as Unicode ASCII art |
| @bpmn-sdk/profiles | Shared auth, profile storage, and client factories for CLI & proxy |
| @bpmn-sdk/operate | Monitoring & operations frontend for Camunda clusters |
License
MIT © bpmn-sdk
