@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 +18 -14
- package/dist/ast.d.ts +4 -0
- package/dist/builtins.d.ts +7 -0
- package/dist/builtins.js +778 -164
- package/dist/evaluator.d.ts +4 -1
- package/dist/evaluator.js +251 -139
- package/dist/formatter.js +16 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/lexer.d.ts +7 -0
- package/dist/lexer.js +92 -5
- package/dist/parser.d.ts +11 -2
- package/dist/parser.js +315 -98
- package/dist/types.js +35 -2
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://github.com/bpmnkit/monorepo/blob/main/LICENSE)
|
|
8
8
|
[](https://github.com/bpmnkit/monorepo)
|
|
9
9
|
[](https://github.com/bpmnkit/monorepo)
|
|
10
|
-
[](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** —
|
|
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
|
-
|
|
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", {
|
|
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 {
|
|
67
|
+
import { annotate, highlightToHtml } from "@bpmnkit/feel"
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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(
|
|
83
|
-
| `
|
|
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)` |
|
|
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,
|
|
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
package/dist/builtins.d.ts
CHANGED
|
@@ -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. */
|