@bpmnkit/feel 0.0.8
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 +112 -0
- package/dist/ast.d.ts +111 -0
- package/dist/ast.js +2 -0
- package/dist/builtins.d.ts +10 -0
- package/dist/builtins.js +1194 -0
- package/dist/evaluator.d.ts +13 -0
- package/dist/evaluator.js +586 -0
- package/dist/formatter.d.ts +7 -0
- package/dist/formatter.js +120 -0
- package/dist/highlighter.d.ts +14 -0
- package/dist/highlighter.js +149 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +12 -0
- package/dist/lexer.d.ts +9 -0
- package/dist/lexer.js +161 -0
- package/dist/parser.d.ts +13 -0
- package/dist/parser.js +853 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.js +129 -0
- package/package.json +29 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export type FeelValue = null | number | string | boolean | FeelDate | FeelTime | FeelDateTime | FeelDayTimeDuration | FeelYearsMonthsDuration | FeelRange | FeelValue[] | FeelContext | FeelFunction;
|
|
2
|
+
export interface FeelDate {
|
|
3
|
+
type: "date";
|
|
4
|
+
year: number;
|
|
5
|
+
month: number;
|
|
6
|
+
day: number;
|
|
7
|
+
}
|
|
8
|
+
export interface FeelTime {
|
|
9
|
+
type: "time";
|
|
10
|
+
hour: number;
|
|
11
|
+
minute: number;
|
|
12
|
+
second: number;
|
|
13
|
+
offsetSeconds?: number;
|
|
14
|
+
timezone?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface FeelDateTime {
|
|
17
|
+
type: "date-time";
|
|
18
|
+
date: FeelDate;
|
|
19
|
+
time: FeelTime;
|
|
20
|
+
}
|
|
21
|
+
export interface FeelDayTimeDuration {
|
|
22
|
+
type: "days-time-duration";
|
|
23
|
+
seconds: number;
|
|
24
|
+
}
|
|
25
|
+
export interface FeelYearsMonthsDuration {
|
|
26
|
+
type: "years-months-duration";
|
|
27
|
+
months: number;
|
|
28
|
+
}
|
|
29
|
+
export interface FeelRange {
|
|
30
|
+
type: "range";
|
|
31
|
+
start: FeelValue;
|
|
32
|
+
startIncluded: boolean;
|
|
33
|
+
end: FeelValue;
|
|
34
|
+
endIncluded: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface FeelContext {
|
|
37
|
+
[key: string]: FeelValue;
|
|
38
|
+
}
|
|
39
|
+
export interface FeelFunction {
|
|
40
|
+
type: "function";
|
|
41
|
+
paramNames?: string[];
|
|
42
|
+
call: (args: FeelValue[]) => FeelValue;
|
|
43
|
+
}
|
|
44
|
+
export declare function isFeelDate(v: FeelValue): v is FeelDate;
|
|
45
|
+
export declare function isFeelTime(v: FeelValue): v is FeelTime;
|
|
46
|
+
export declare function isFeelDateTime(v: FeelValue): v is FeelDateTime;
|
|
47
|
+
export declare function isFeelDayTimeDuration(v: FeelValue): v is FeelDayTimeDuration;
|
|
48
|
+
export declare function isFeelYearsMonthsDuration(v: FeelValue): v is FeelYearsMonthsDuration;
|
|
49
|
+
export declare function isFeelRange(v: FeelValue): v is FeelRange;
|
|
50
|
+
export declare function isFeelFunction(v: FeelValue): v is FeelFunction;
|
|
51
|
+
export declare function isFeelDuration(v: FeelValue): v is FeelDayTimeDuration | FeelYearsMonthsDuration;
|
|
52
|
+
export declare function isFeelList(v: FeelValue): v is FeelValue[];
|
|
53
|
+
export declare function isFeelContext(v: FeelValue): v is FeelContext;
|
|
54
|
+
/** Gets a named property from a FeelValue for path expressions. Returns null if not found. */
|
|
55
|
+
export declare function getProperty(v: FeelValue, key: string): FeelValue;
|
|
56
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// Type guards
|
|
2
|
+
function objType(v) {
|
|
3
|
+
const t = v.type;
|
|
4
|
+
return typeof t === "string" ? t : undefined;
|
|
5
|
+
}
|
|
6
|
+
export function isFeelDate(v) {
|
|
7
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
8
|
+
return false;
|
|
9
|
+
return objType(v) === "date";
|
|
10
|
+
}
|
|
11
|
+
export function isFeelTime(v) {
|
|
12
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
13
|
+
return false;
|
|
14
|
+
return objType(v) === "time";
|
|
15
|
+
}
|
|
16
|
+
export function isFeelDateTime(v) {
|
|
17
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
18
|
+
return false;
|
|
19
|
+
return objType(v) === "date-time";
|
|
20
|
+
}
|
|
21
|
+
export function isFeelDayTimeDuration(v) {
|
|
22
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
23
|
+
return false;
|
|
24
|
+
return objType(v) === "days-time-duration";
|
|
25
|
+
}
|
|
26
|
+
export function isFeelYearsMonthsDuration(v) {
|
|
27
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
28
|
+
return false;
|
|
29
|
+
return objType(v) === "years-months-duration";
|
|
30
|
+
}
|
|
31
|
+
export function isFeelRange(v) {
|
|
32
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
33
|
+
return false;
|
|
34
|
+
return objType(v) === "range";
|
|
35
|
+
}
|
|
36
|
+
export function isFeelFunction(v) {
|
|
37
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
38
|
+
return false;
|
|
39
|
+
return objType(v) === "function";
|
|
40
|
+
}
|
|
41
|
+
export function isFeelDuration(v) {
|
|
42
|
+
return isFeelDayTimeDuration(v) || isFeelYearsMonthsDuration(v);
|
|
43
|
+
}
|
|
44
|
+
export function isFeelList(v) {
|
|
45
|
+
return Array.isArray(v);
|
|
46
|
+
}
|
|
47
|
+
export function isFeelContext(v) {
|
|
48
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
49
|
+
return false;
|
|
50
|
+
const t = objType(v);
|
|
51
|
+
return (t !== "date" &&
|
|
52
|
+
t !== "time" &&
|
|
53
|
+
t !== "date-time" &&
|
|
54
|
+
t !== "days-time-duration" &&
|
|
55
|
+
t !== "years-months-duration" &&
|
|
56
|
+
t !== "range" &&
|
|
57
|
+
t !== "function");
|
|
58
|
+
}
|
|
59
|
+
/** Gets a named property from a FeelValue for path expressions. Returns null if not found. */
|
|
60
|
+
export function getProperty(v, key) {
|
|
61
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
62
|
+
return null;
|
|
63
|
+
if (isFeelDate(v)) {
|
|
64
|
+
if (key === "year")
|
|
65
|
+
return v.year;
|
|
66
|
+
if (key === "month")
|
|
67
|
+
return v.month;
|
|
68
|
+
if (key === "day")
|
|
69
|
+
return v.day;
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
if (isFeelTime(v)) {
|
|
73
|
+
if (key === "hour")
|
|
74
|
+
return v.hour;
|
|
75
|
+
if (key === "minute")
|
|
76
|
+
return v.minute;
|
|
77
|
+
if (key === "second")
|
|
78
|
+
return v.second;
|
|
79
|
+
if (key === "time offset")
|
|
80
|
+
return v.offsetSeconds !== undefined ? v.offsetSeconds / 3600 : null;
|
|
81
|
+
if (key === "timezone")
|
|
82
|
+
return v.timezone ?? null;
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
if (isFeelDateTime(v)) {
|
|
86
|
+
if (key === "year")
|
|
87
|
+
return v.date.year;
|
|
88
|
+
if (key === "month")
|
|
89
|
+
return v.date.month;
|
|
90
|
+
if (key === "day")
|
|
91
|
+
return v.date.day;
|
|
92
|
+
if (key === "hour")
|
|
93
|
+
return v.time.hour;
|
|
94
|
+
if (key === "minute")
|
|
95
|
+
return v.time.minute;
|
|
96
|
+
if (key === "second")
|
|
97
|
+
return v.time.second;
|
|
98
|
+
if (key === "time offset")
|
|
99
|
+
return v.time.offsetSeconds !== undefined ? v.time.offsetSeconds / 3600 : null;
|
|
100
|
+
if (key === "timezone")
|
|
101
|
+
return v.time.timezone ?? null;
|
|
102
|
+
if (key === "time")
|
|
103
|
+
return v.time;
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
if (isFeelDayTimeDuration(v)) {
|
|
107
|
+
const total = v.seconds;
|
|
108
|
+
if (key === "days")
|
|
109
|
+
return Math.trunc(total / 86400);
|
|
110
|
+
if (key === "hours")
|
|
111
|
+
return Math.trunc((total % 86400) / 3600);
|
|
112
|
+
if (key === "minutes")
|
|
113
|
+
return Math.trunc((total % 3600) / 60);
|
|
114
|
+
if (key === "seconds")
|
|
115
|
+
return total % 60;
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
if (isFeelYearsMonthsDuration(v)) {
|
|
119
|
+
if (key === "years")
|
|
120
|
+
return Math.trunc(v.months / 12);
|
|
121
|
+
if (key === "months")
|
|
122
|
+
return v.months % 12;
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
// FeelContext
|
|
126
|
+
const val = v[key];
|
|
127
|
+
return val !== undefined ? val : null;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bpmnkit/feel",
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"files": ["dist/**/*.js", "dist/**/*.d.ts"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"check": "biome check .",
|
|
19
|
+
"test": "vitest run"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {},
|
|
22
|
+
"description": "Complete FEEL (Friendly Enough Expression Language) implementation — parser, evaluator, and highlighter",
|
|
23
|
+
"keywords": ["feel", "dmn", "expression", "camunda", "bpmn", "typescript"],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/bpmnkit/monorepo"
|
|
28
|
+
}
|
|
29
|
+
}
|