@bpmnkit/feel 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![license](https://img.shields.io/npm/l/@bpmnkit/feel?style=flat-square)](https://github.com/bpmnkit/monorepo/blob/main/LICENSE)
8
8
  [![typescript](https://img.shields.io/badge/TypeScript-strict-6244d7?style=flat-square&logo=typescript&logoColor=white)](https://github.com/bpmnkit/monorepo)
9
9
  [![ai-assisted](https://img.shields.io/badge/AI--assisted-claude-8b5cf6?style=flat-square)](https://github.com/bpmnkit/monorepo)
10
- [![experimental](https://img.shields.io/badge/status-experimental-f59e0b?style=flat-square)](https://github.com/bpmnkit/monorepo)
10
+ [![stable](https://img.shields.io/badge/status-stable-16a34a?style=flat-square)](https://bpmnkit.com/docs/getting-started/stability)
11
11
 
12
12
  [Website](https://bpmnkit.com) · [Documentation](https://bpmnkit.com/docs) · [GitHub](https://github.com/bpmnkit/monorepo) · [Changelog](https://github.com/bpmnkit/monorepo/blob/main/packages/feel/CHANGELOG.md)
13
13
  </div>
@@ -23,7 +23,7 @@
23
23
  - **Full FEEL grammar** — arithmetic, comparisons, logic, function calls, paths, filters
24
24
  - **Temporal types** — date, time, datetime, duration (ISO 8601, full spec compliance)
25
25
  - **Unary tests** — DMN input expression syntax (`> 5`, `"gold", "silver"`, `[1..10]`)
26
- - **Built-in functions** — 50+ standard FEEL functions (string, list, numeric, date, context)
26
+ - **Built-in functions** — 88 standard FEEL functions (string, list, numeric, date, context, range)
27
27
  - **Range expressions** — `[1..10]`, `(0..1)`, `[today..end]`
28
28
  - **Context literals** — `{ key: value, nested: { x: 1 } }`
29
29
  - **Syntax highlighting** — semantic token classification for editors
@@ -44,7 +44,8 @@ import { parseExpression, evaluate } from "@bpmnkit/feel"
44
44
 
45
45
  const parsed = parseExpression("amount * 1.2 + fee")
46
46
  if (!parsed.errors.length) {
47
- const result = evaluate(parsed.ast!, { amount: 100, fee: 5 })
47
+ // `evaluate` takes an EvalContext variables live under `vars`.
48
+ const result = evaluate(parsed.ast!, { vars: { amount: 100, fee: 5 } })
48
49
  console.log(result) // 125
49
50
  }
50
51
  ```
@@ -56,19 +57,20 @@ import { parseUnaryTests, evaluateUnaryTests } from "@bpmnkit/feel"
56
57
 
57
58
  // Does input value match any listed condition?
58
59
  const parsed = parseUnaryTests('"gold","silver"')
59
- const matches = evaluateUnaryTests(parsed.ast!, "gold", { /* context */ })
60
+ const matches = evaluateUnaryTests(parsed.ast!, "gold", { vars: {} })
60
61
  console.log(matches) // true
61
62
  ```
62
63
 
63
64
  ### Syntax highlighting
64
65
 
65
66
  ```typescript
66
- import { highlightFeel } from "@bpmnkit/feel"
67
+ import { annotate, highlightToHtml } from "@bpmnkit/feel"
67
68
 
68
- const tokens = highlightFeel('if x > 10 then "high" else "low"')
69
- for (const token of tokens) {
70
- console.log(token.type, token.value) // keyword, number, string, ...
71
- }
69
+ // Classified tokens, for an editor to style itself.
70
+ annotate("x > 1")[0] // { kind: "variable", value: "x", start: 0, end: 1 }
71
+
72
+ // Or the same tokens already wrapped in <span class="feel-…"> elements.
73
+ highlightToHtml('if x > 10 then "high" else "low"')
72
74
  ```
73
75
 
74
76
  ## API Reference
@@ -77,19 +79,20 @@ for (const token of tokens) {
77
79
  |--------|-------------|
78
80
  | `parseExpression(src)` | Parse a FEEL expression → `ParseResult` |
79
81
  | `parseUnaryTests(src)` | Parse unary tests → `ParseResult` |
80
- | `evaluate(ast, ctx)` | Evaluate a parsed expression |
82
+ | `evaluate(ast, ctx)` | Evaluate a parsed expression; `ctx` is `{ vars }` |
81
83
  | `evaluateUnaryTests(ast, input, ctx)` | Test input against unary tests |
82
- | `formatFeel(src)` | Pretty-print a FEEL expression |
83
- | `highlightFeel(src)` | Tokenize with semantic types for highlighting |
84
+ | `formatFeel(node, opts?)` | Pretty-print a **parsed node**, not source text |
85
+ | `highlightToHtml(src)` | Tokens wrapped in `<span class="feel-…">` elements |
86
+ | `highlightFeel(src)` | Alias for `highlightToHtml` |
84
87
  | `tokenize(src)` | Raw token stream |
85
- | `annotate(src)` | Full AST with position metadata |
88
+ | `annotate(src)` | Tokens classified for highlighting (`kind`, `value`, `start`, `end`) |
86
89
 
87
90
  ### ParseResult
88
91
 
89
92
  ```typescript
90
93
  interface ParseResult {
91
94
  ast: FeelNode | null
92
- errors: ParseError[] // { message, position }
95
+ errors: ParseError[] // { message, start, end }
93
96
  }
94
97
  ```
95
98
 
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { evaluate, evaluateUnaryTests, evaluateUnaryTest } from "./evaluator.js"
9
9
  export type { EvalContext } from "./evaluator.js";
10
10
  export { formatFeel } from "./formatter.js";
11
11
  export type { FormatOptions } from "./formatter.js";
12
+ export { builtinNames, getBuiltin } from "./builtins.js";
12
13
  export { annotate, highlightToHtml, highlightFeel } from "./highlighter.js";
13
14
  export type { AnnotatedToken, HighlightKind } from "./highlighter.js";
14
15
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ export { parseExpression, parseUnaryTests } from "./parser.js";
7
7
  export { evaluate, evaluateUnaryTests, evaluateUnaryTest } from "./evaluator.js";
8
8
  // Formatter
9
9
  export { formatFeel } from "./formatter.js";
10
+ // Built-ins
11
+ export { builtinNames, getBuiltin } from "./builtins.js";
10
12
  // Highlighter
11
13
  export { annotate, highlightToHtml, highlightFeel } from "./highlighter.js";
12
14
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmnkit/feel",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,6 +17,9 @@
17
17
  "dist/**/*.js",
18
18
  "dist/**/*.d.ts"
19
19
  ],
20
+ "engines": {
21
+ "node": ">=20"
22
+ },
20
23
  "dependencies": {},
21
24
  "description": "Complete FEEL (Friendly Enough Expression Language) implementation — parser, evaluator, and highlighter",
22
25
  "keywords": [