@bpmnkit/feel 0.0.21 → 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
 
@@ -107,6 +110,7 @@ interface ParseResult {
107
110
  | [`@bpmnkit/api`](https://www.npmjs.com/package/@bpmnkit/api) | Camunda 8 REST API TypeScript client |
108
111
  | [`@bpmnkit/ascii`](https://www.npmjs.com/package/@bpmnkit/ascii) | Render BPMN diagrams as Unicode ASCII art |
109
112
  | [`@bpmnkit/docspack`](https://www.npmjs.com/package/@bpmnkit/docspack) | BPMN Kit docs as an offline docspack package for AI agents |
113
+ | [`@bpmnkit/camunda-docspack`](https://www.npmjs.com/package/@bpmnkit/camunda-docspack) | Camunda 8 docs as an offline docspack package for AI agents |
110
114
  | [`@bpmnkit/ui`](https://www.npmjs.com/package/@bpmnkit/ui) | Shared design tokens and UI components |
111
115
  | [`@bpmnkit/profiles`](https://www.npmjs.com/package/@bpmnkit/profiles) | Shared auth, profile storage, and client factories for CLI & proxy |
112
116
  | [`@bpmnkit/operate`](https://www.npmjs.com/package/@bpmnkit/operate) | Monitoring & operations frontend for Camunda clusters |
package/dist/ast.d.ts CHANGED
@@ -55,6 +55,10 @@ type FeelNodeKind = {
55
55
  kind: "call";
56
56
  callee: string;
57
57
  args: FeelNode[];
58
+ } | {
59
+ kind: "call-expr";
60
+ target: FeelNode;
61
+ args: FeelNode[];
58
62
  } | {
59
63
  kind: "call-named";
60
64
  callee: string;
@@ -1,6 +1,13 @@
1
1
  import type { FeelFunction, FeelValue } from "./types.js";
2
2
  declare function parseTemporal(raw: string): FeelValue;
3
3
  declare function compareValues(a: FeelValue, b: FeelValue): number | null;
4
+ /**
5
+ * Orders the arguments of a named invocation to match a built-in's signature.
6
+ * Returns, for each parameter position, the index of the argument supplying
7
+ * it, or null when no signature of the built-in accepts exactly these names —
8
+ * which FEEL treats as an invocation error rather than a positional call.
9
+ */
10
+ export declare function orderNamedArgs(name: string, argNames: string[]): number[] | null;
4
11
  /** Look up a built-in function by name. Returns undefined if not found. */
5
12
  export declare function getBuiltin(name: string): FeelFunction | undefined;
6
13
  /** All built-in names. */