aviator-expression-builder 0.1.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/AviatorExpressionBuilderLegacyModal.vue_vue_type_script_setup_true_lang-CRZlHClr.cjs +9 -0
- package/AviatorExpressionBuilderLegacyModal.vue_vue_type_script_setup_true_lang-CjWgNhEl.js +7608 -0
- package/LICENSE +202 -0
- package/PUBLIC_API.md +50 -0
- package/README.md +368 -0
- package/headless.cjs +2 -0
- package/headless.d.ts +167 -0
- package/headless.js +2317 -0
- package/index.cjs +2 -0
- package/index.d.ts +44 -0
- package/index.js +26 -0
- package/legacy.cjs +2 -0
- package/legacy.d.ts +7 -0
- package/legacy.js +5 -0
- package/package.json +69 -0
- package/plugin-DErT8PJK.cjs +2 -0
- package/plugin-DJOcRfv1.js +38 -0
- package/style.css +182 -0
- package/vue.cjs +2 -0
- package/vue.d.ts +39 -0
- package/vue.js +11 -0
package/headless.js
ADDED
|
@@ -0,0 +1,2317 @@
|
|
|
1
|
+
const K = Object.freeze([
|
|
2
|
+
{
|
|
3
|
+
name: "sysdate",
|
|
4
|
+
category: "system",
|
|
5
|
+
displayName: "当前日期",
|
|
6
|
+
description: "返回当前日期对象",
|
|
7
|
+
parameters: [],
|
|
8
|
+
returnType: "date",
|
|
9
|
+
example: "sysdate()"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "now",
|
|
13
|
+
category: "system",
|
|
14
|
+
displayName: "当前时间戳",
|
|
15
|
+
description: "返回当前毫秒时间戳",
|
|
16
|
+
parameters: [],
|
|
17
|
+
returnType: "number",
|
|
18
|
+
example: "now()"
|
|
19
|
+
}
|
|
20
|
+
]), Q = Object.freeze([
|
|
21
|
+
{
|
|
22
|
+
name: "assert",
|
|
23
|
+
category: "system",
|
|
24
|
+
displayName: "断言函数",
|
|
25
|
+
description: "当predicate结果为false时抛出异常",
|
|
26
|
+
parameters: [
|
|
27
|
+
{ name: "predicate", type: "value", required: !0, description: "断言条件", valueType: "boolean" },
|
|
28
|
+
{ name: "msg", type: "value", required: !1, description: "错误信息", valueType: "string" }
|
|
29
|
+
],
|
|
30
|
+
returnType: "boolean",
|
|
31
|
+
example: 'assert(user.age > 18, "用户未成年")'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "rand",
|
|
35
|
+
category: "system",
|
|
36
|
+
displayName: "随机数",
|
|
37
|
+
description: "返回[0,1)或[0,n)的随机数",
|
|
38
|
+
parameters: [
|
|
39
|
+
{ name: "n", type: "value", required: !1, description: "上限值", valueType: "number" }
|
|
40
|
+
],
|
|
41
|
+
returnType: "number",
|
|
42
|
+
example: "rand() 或 rand(100)"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "cmp",
|
|
46
|
+
category: "system",
|
|
47
|
+
displayName: "比较函数",
|
|
48
|
+
description: "比较x和y大小,返回0(相等)、1(x>y)或-1(x<y)",
|
|
49
|
+
parameters: [
|
|
50
|
+
{ name: "x", type: "value", required: !0, description: "比较值1", valueType: "any" },
|
|
51
|
+
{ name: "y", type: "value", required: !0, description: "比较值2", valueType: "any" }
|
|
52
|
+
],
|
|
53
|
+
returnType: "number",
|
|
54
|
+
example: "cmp(request.size, response.size)"
|
|
55
|
+
}
|
|
56
|
+
]), J = Object.freeze([
|
|
57
|
+
{
|
|
58
|
+
name: "print",
|
|
59
|
+
category: "system",
|
|
60
|
+
displayName: "打印对象",
|
|
61
|
+
description: "打印对象到输出流",
|
|
62
|
+
parameters: [
|
|
63
|
+
{ name: "obj", type: "value", required: !0, description: "要打印的对象", valueType: "any" }
|
|
64
|
+
],
|
|
65
|
+
returnType: "any",
|
|
66
|
+
example: "print(user.name)"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "println",
|
|
70
|
+
category: "system",
|
|
71
|
+
displayName: "打印并换行",
|
|
72
|
+
description: "打印对象并换行",
|
|
73
|
+
parameters: [
|
|
74
|
+
{ name: "obj", type: "value", required: !0, description: "要打印的对象", valueType: "any" }
|
|
75
|
+
],
|
|
76
|
+
returnType: "any",
|
|
77
|
+
example: "println(user.name)"
|
|
78
|
+
}
|
|
79
|
+
]), X = Object.freeze([
|
|
80
|
+
{
|
|
81
|
+
name: "long",
|
|
82
|
+
category: "system",
|
|
83
|
+
displayName: "转换为long",
|
|
84
|
+
description: "将值转为long类型",
|
|
85
|
+
parameters: [
|
|
86
|
+
{ name: "v", type: "value", required: !0, description: "要转换的值", valueType: "any" }
|
|
87
|
+
],
|
|
88
|
+
returnType: "number",
|
|
89
|
+
example: "long(user.age)"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "double",
|
|
93
|
+
category: "system",
|
|
94
|
+
displayName: "转换为double",
|
|
95
|
+
description: "将值转为double类型",
|
|
96
|
+
parameters: [
|
|
97
|
+
{ name: "v", type: "value", required: !0, description: "要转换的值", valueType: "any" }
|
|
98
|
+
],
|
|
99
|
+
returnType: "number",
|
|
100
|
+
example: "double(user.salary)"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "boolean",
|
|
104
|
+
category: "system",
|
|
105
|
+
displayName: "转换为boolean",
|
|
106
|
+
description: "将值转为boolean类型",
|
|
107
|
+
parameters: [
|
|
108
|
+
{ name: "v", type: "value", required: !0, description: "要转换的值", valueType: "any" }
|
|
109
|
+
],
|
|
110
|
+
returnType: "boolean",
|
|
111
|
+
example: "boolean(user.active)"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "str",
|
|
115
|
+
category: "system",
|
|
116
|
+
displayName: "转换为string",
|
|
117
|
+
description: "将值转为string类型",
|
|
118
|
+
parameters: [
|
|
119
|
+
{ name: "v", type: "value", required: !0, description: "要转换的值", valueType: "any" }
|
|
120
|
+
],
|
|
121
|
+
returnType: "string",
|
|
122
|
+
example: "str(user.id)"
|
|
123
|
+
}
|
|
124
|
+
]), Z = Object.freeze([
|
|
125
|
+
{
|
|
126
|
+
name: "type",
|
|
127
|
+
category: "system",
|
|
128
|
+
displayName: "获取类型",
|
|
129
|
+
description: "返回参数的类型",
|
|
130
|
+
parameters: [
|
|
131
|
+
{ name: "x", type: "value", required: !0, description: "要检查的值", valueType: "any" }
|
|
132
|
+
],
|
|
133
|
+
returnType: "string",
|
|
134
|
+
example: "type(user.age)"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "is_def",
|
|
138
|
+
category: "system",
|
|
139
|
+
displayName: "是否已定义",
|
|
140
|
+
description: "返回变量是否已定义",
|
|
141
|
+
parameters: [
|
|
142
|
+
{ name: "x", type: "value", required: !0, description: "要检查的变量", valueType: "any" }
|
|
143
|
+
],
|
|
144
|
+
returnType: "boolean",
|
|
145
|
+
example: "is_def(user.email)"
|
|
146
|
+
}
|
|
147
|
+
]), ee = Object.freeze([
|
|
148
|
+
{
|
|
149
|
+
name: "max",
|
|
150
|
+
category: "system",
|
|
151
|
+
displayName: "最大值",
|
|
152
|
+
description: "取所有参数中的最大值",
|
|
153
|
+
parameters: [
|
|
154
|
+
{ name: "x1", type: "value", required: !0, description: "数值1", valueType: "number" },
|
|
155
|
+
{ name: "x2", type: "value", required: !0, description: "数值2", valueType: "number" }
|
|
156
|
+
],
|
|
157
|
+
returnType: "number",
|
|
158
|
+
example: "max(request.size, response.size)"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "min",
|
|
162
|
+
category: "system",
|
|
163
|
+
displayName: "最小值",
|
|
164
|
+
description: "取所有参数中的最小值",
|
|
165
|
+
parameters: [
|
|
166
|
+
{ name: "x1", type: "value", required: !0, description: "数值1", valueType: "number" },
|
|
167
|
+
{ name: "x2", type: "value", required: !0, description: "数值2", valueType: "number" }
|
|
168
|
+
],
|
|
169
|
+
returnType: "number",
|
|
170
|
+
example: "min(request.size, response.size)"
|
|
171
|
+
}
|
|
172
|
+
]), re = Object.freeze([
|
|
173
|
+
{
|
|
174
|
+
name: "load",
|
|
175
|
+
category: "system",
|
|
176
|
+
displayName: "加载模块",
|
|
177
|
+
description: "加载指定路径的模块,每次重新编译",
|
|
178
|
+
parameters: [
|
|
179
|
+
{ name: "path", type: "value", required: !0, description: "模块路径", valueType: "string" }
|
|
180
|
+
],
|
|
181
|
+
returnType: "any",
|
|
182
|
+
example: 'load("myModule.av")'
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "require",
|
|
186
|
+
category: "system",
|
|
187
|
+
displayName: "引入模块",
|
|
188
|
+
description: "加载指定路径的模块,有缓存机制",
|
|
189
|
+
parameters: [
|
|
190
|
+
{ name: "path", type: "value", required: !0, description: "模块路径", valueType: "string" }
|
|
191
|
+
],
|
|
192
|
+
returnType: "any",
|
|
193
|
+
example: 'require("myModule.av")'
|
|
194
|
+
}
|
|
195
|
+
]), te = Object.freeze([
|
|
196
|
+
...K,
|
|
197
|
+
...Q,
|
|
198
|
+
...J,
|
|
199
|
+
...X,
|
|
200
|
+
...Z,
|
|
201
|
+
...ee,
|
|
202
|
+
...re
|
|
203
|
+
]), ne = Object.freeze([
|
|
204
|
+
{
|
|
205
|
+
name: "date_to_string",
|
|
206
|
+
category: "string",
|
|
207
|
+
displayName: "日期转字符串",
|
|
208
|
+
description: "将Date对象转化为特定格式的字符串",
|
|
209
|
+
parameters: [
|
|
210
|
+
{ name: "date", type: "value", required: !0, description: "日期对象", valueType: "any" },
|
|
211
|
+
{ name: "format", type: "value", required: !0, description: "格式字符串", valueType: "string" }
|
|
212
|
+
],
|
|
213
|
+
returnType: "string",
|
|
214
|
+
example: 'date_to_string(event.time, "yyyy-MM-dd HH:mm:ss")'
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "string_to_date",
|
|
218
|
+
category: "string",
|
|
219
|
+
displayName: "字符串转日期",
|
|
220
|
+
description: "将特定格式的字符串转化为Date对象",
|
|
221
|
+
parameters: [
|
|
222
|
+
{ name: "source", type: "value", required: !0, description: "日期字符串", valueType: "string" },
|
|
223
|
+
{ name: "format", type: "value", required: !0, description: "格式字符串", valueType: "string" }
|
|
224
|
+
],
|
|
225
|
+
returnType: "date",
|
|
226
|
+
example: 'string_to_date(event.created, "yyyy-MM-dd HH:mm:ss")'
|
|
227
|
+
}
|
|
228
|
+
]), ae = Object.freeze([
|
|
229
|
+
{
|
|
230
|
+
name: "string.contains",
|
|
231
|
+
category: "string",
|
|
232
|
+
displayName: "包含字符串",
|
|
233
|
+
description: "判断s1是否包含s2",
|
|
234
|
+
parameters: [
|
|
235
|
+
{ name: "s1", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
236
|
+
{ name: "s2", type: "value", required: !0, description: "要查找的字符串", valueType: "string" }
|
|
237
|
+
],
|
|
238
|
+
returnType: "boolean",
|
|
239
|
+
example: 'string.contains(request.uri, "/login")'
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "string.startsWith",
|
|
243
|
+
category: "string",
|
|
244
|
+
displayName: "开头匹配",
|
|
245
|
+
description: "s1是否以s2开始",
|
|
246
|
+
parameters: [
|
|
247
|
+
{ name: "s1", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
248
|
+
{ name: "s2", type: "value", required: !0, description: "前缀字符串", valueType: "string" }
|
|
249
|
+
],
|
|
250
|
+
returnType: "boolean",
|
|
251
|
+
example: 'string.startsWith(request.uri, "/sso/public")'
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "string.endsWith",
|
|
255
|
+
category: "string",
|
|
256
|
+
displayName: "结尾匹配",
|
|
257
|
+
description: "s1是否以s2结尾",
|
|
258
|
+
parameters: [
|
|
259
|
+
{ name: "s1", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
260
|
+
{ name: "s2", type: "value", required: !0, description: "后缀字符串", valueType: "string" }
|
|
261
|
+
],
|
|
262
|
+
returnType: "boolean",
|
|
263
|
+
example: 'string.endsWith(request.uri, ".gif")'
|
|
264
|
+
}
|
|
265
|
+
]), ie = Object.freeze([
|
|
266
|
+
{
|
|
267
|
+
name: "string.length",
|
|
268
|
+
category: "string",
|
|
269
|
+
displayName: "字符串长度",
|
|
270
|
+
description: "求字符串长度",
|
|
271
|
+
parameters: [
|
|
272
|
+
{ name: "s", type: "value", required: !0, description: "字符串", valueType: "string" }
|
|
273
|
+
],
|
|
274
|
+
returnType: "number",
|
|
275
|
+
example: "string.length(request.uri)"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: "string.indexOf",
|
|
279
|
+
category: "string",
|
|
280
|
+
displayName: "查找位置",
|
|
281
|
+
description: "求s2在s1中的起始索引位置",
|
|
282
|
+
parameters: [
|
|
283
|
+
{ name: "s1", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
284
|
+
{ name: "s2", type: "value", required: !0, description: "要查找的字符串", valueType: "string" }
|
|
285
|
+
],
|
|
286
|
+
returnType: "number",
|
|
287
|
+
example: 'string.indexOf(request.uri, "/api")'
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: "string.lastIndexOf",
|
|
291
|
+
category: "string",
|
|
292
|
+
displayName: "最后查找位置",
|
|
293
|
+
description: "查找字符串最后出现的位置",
|
|
294
|
+
parameters: [
|
|
295
|
+
{ name: "str", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
296
|
+
{ name: "searchStr", type: "value", required: !0, description: "搜索字符串", valueType: "string" }
|
|
297
|
+
],
|
|
298
|
+
returnType: "number",
|
|
299
|
+
example: 'string.lastIndexOf(request.uri, "/")'
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "string.substring",
|
|
303
|
+
category: "string",
|
|
304
|
+
displayName: "截取字符串",
|
|
305
|
+
description: "截取字符串s,从begin到end",
|
|
306
|
+
parameters: [
|
|
307
|
+
{ name: "s", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
308
|
+
{ name: "begin", type: "value", required: !0, description: "开始位置", valueType: "number" },
|
|
309
|
+
{ name: "end", type: "value", required: !1, description: "结束位置", valueType: "number" }
|
|
310
|
+
],
|
|
311
|
+
returnType: "string",
|
|
312
|
+
example: "string.substring(request.uri, 0, 10)"
|
|
313
|
+
}
|
|
314
|
+
]), se = Object.freeze([
|
|
315
|
+
{
|
|
316
|
+
name: "string.split",
|
|
317
|
+
category: "string",
|
|
318
|
+
displayName: "字符串分割",
|
|
319
|
+
description: "Java里的String.split方法",
|
|
320
|
+
parameters: [
|
|
321
|
+
{ name: "target", type: "value", required: !0, description: "目标字符串", valueType: "string" },
|
|
322
|
+
{ name: "regex", type: "value", required: !0, description: "分割正则", valueType: "string" },
|
|
323
|
+
{ name: "limit", type: "value", required: !1, description: "限制数量", valueType: "number" }
|
|
324
|
+
],
|
|
325
|
+
returnType: "array",
|
|
326
|
+
example: 'string.split(request.uri, "/")'
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: "string.join",
|
|
330
|
+
category: "string",
|
|
331
|
+
displayName: "字符串连接",
|
|
332
|
+
description: "将集合里的元素以分隔符连接起来形成字符串",
|
|
333
|
+
parameters: [
|
|
334
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" },
|
|
335
|
+
{ name: "separator", type: "value", required: !0, description: "分隔符", valueType: "string" }
|
|
336
|
+
],
|
|
337
|
+
returnType: "string",
|
|
338
|
+
example: 'string.join(headers, ",")'
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: "string.replace_first",
|
|
342
|
+
category: "string",
|
|
343
|
+
displayName: "替换首次匹配",
|
|
344
|
+
description: "Java里的String.replaceFirst方法",
|
|
345
|
+
parameters: [
|
|
346
|
+
{ name: "s", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
347
|
+
{ name: "regex", type: "value", required: !0, description: "正则表达式", valueType: "string" },
|
|
348
|
+
{ name: "replacement", type: "value", required: !0, description: "替换字符串", valueType: "string" }
|
|
349
|
+
],
|
|
350
|
+
returnType: "string",
|
|
351
|
+
example: 'string.replace_first(request.uri, "/api/", "/new/")'
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: "string.replace_all",
|
|
355
|
+
category: "string",
|
|
356
|
+
displayName: "替换所有匹配",
|
|
357
|
+
description: "Java里的String.replaceAll方法",
|
|
358
|
+
parameters: [
|
|
359
|
+
{ name: "s", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
360
|
+
{ name: "regex", type: "value", required: !0, description: "正则表达式", valueType: "string" },
|
|
361
|
+
{ name: "replacement", type: "value", required: !0, description: "替换字符串", valueType: "string" }
|
|
362
|
+
],
|
|
363
|
+
returnType: "string",
|
|
364
|
+
example: 'string.replace_all(request.uri, "/api/", "/new/")'
|
|
365
|
+
}
|
|
366
|
+
]), ue = Object.freeze([
|
|
367
|
+
{
|
|
368
|
+
name: "string.match",
|
|
369
|
+
category: "string",
|
|
370
|
+
displayName: "正则匹配",
|
|
371
|
+
description: "字符串正则匹配函数,返回匹配到的字符串内容,匹配失败时返回nil",
|
|
372
|
+
parameters: [
|
|
373
|
+
{ name: "regex", type: "value", required: !0, description: "正则表达式", valueType: "string" },
|
|
374
|
+
{ name: "str", type: "value", required: !0, description: "源字符串", valueType: "string" },
|
|
375
|
+
{ name: "flags", type: "value", required: !1, description: "匹配标志", valueType: "string" }
|
|
376
|
+
],
|
|
377
|
+
returnType: "string",
|
|
378
|
+
example: 'string.match("^/api/.*", request.uri, 0)'
|
|
379
|
+
}
|
|
380
|
+
]), le = Object.freeze([
|
|
381
|
+
...ne,
|
|
382
|
+
...ae,
|
|
383
|
+
...ie,
|
|
384
|
+
...se,
|
|
385
|
+
...ue
|
|
386
|
+
]), oe = Object.freeze([
|
|
387
|
+
{
|
|
388
|
+
name: "math.abs",
|
|
389
|
+
category: "math",
|
|
390
|
+
displayName: "绝对值",
|
|
391
|
+
description: "求d的绝对值",
|
|
392
|
+
parameters: [
|
|
393
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
394
|
+
],
|
|
395
|
+
returnType: "number",
|
|
396
|
+
example: "math.abs(response.latency)"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: "math.round",
|
|
400
|
+
category: "math",
|
|
401
|
+
displayName: "四舍五入",
|
|
402
|
+
description: "四舍五入",
|
|
403
|
+
parameters: [
|
|
404
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
405
|
+
],
|
|
406
|
+
returnType: "number",
|
|
407
|
+
example: "math.round(response.latency)"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "math.floor",
|
|
411
|
+
category: "math",
|
|
412
|
+
displayName: "向下取整",
|
|
413
|
+
description: "向下取整",
|
|
414
|
+
parameters: [
|
|
415
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
416
|
+
],
|
|
417
|
+
returnType: "number",
|
|
418
|
+
example: "math.floor(response.latency)"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
name: "math.ceil",
|
|
422
|
+
category: "math",
|
|
423
|
+
displayName: "向上取整",
|
|
424
|
+
description: "向上取整",
|
|
425
|
+
parameters: [
|
|
426
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
427
|
+
],
|
|
428
|
+
returnType: "number",
|
|
429
|
+
example: "math.ceil(response.latency)"
|
|
430
|
+
}
|
|
431
|
+
]), pe = Object.freeze([
|
|
432
|
+
{
|
|
433
|
+
name: "math.sqrt",
|
|
434
|
+
category: "math",
|
|
435
|
+
displayName: "平方根",
|
|
436
|
+
description: "求d的平方根",
|
|
437
|
+
parameters: [
|
|
438
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
439
|
+
],
|
|
440
|
+
returnType: "number",
|
|
441
|
+
example: "math.sqrt(request.size)"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
name: "math.pow",
|
|
445
|
+
category: "math",
|
|
446
|
+
displayName: "幂运算",
|
|
447
|
+
description: "求d1的d2次方",
|
|
448
|
+
parameters: [
|
|
449
|
+
{ name: "d1", type: "value", required: !0, description: "底数", valueType: "number" },
|
|
450
|
+
{ name: "d2", type: "value", required: !0, description: "指数", valueType: "number" }
|
|
451
|
+
],
|
|
452
|
+
returnType: "number",
|
|
453
|
+
example: "math.pow(request.size, 2)"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
name: "math.log",
|
|
457
|
+
category: "math",
|
|
458
|
+
displayName: "自然对数",
|
|
459
|
+
description: "求d的自然对数",
|
|
460
|
+
parameters: [
|
|
461
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
462
|
+
],
|
|
463
|
+
returnType: "number",
|
|
464
|
+
example: "math.log(request.size)"
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
name: "math.log10",
|
|
468
|
+
category: "math",
|
|
469
|
+
displayName: "常用对数",
|
|
470
|
+
description: "求d以10为底的对数",
|
|
471
|
+
parameters: [
|
|
472
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
473
|
+
],
|
|
474
|
+
returnType: "number",
|
|
475
|
+
example: "math.log10(request.size)"
|
|
476
|
+
}
|
|
477
|
+
]), ce = Object.freeze([
|
|
478
|
+
{
|
|
479
|
+
name: "math.sin",
|
|
480
|
+
category: "math",
|
|
481
|
+
displayName: "正弦函数",
|
|
482
|
+
description: "正弦函数",
|
|
483
|
+
parameters: [
|
|
484
|
+
{ name: "d", type: "value", required: !0, description: "角度(弧度)", valueType: "number" }
|
|
485
|
+
],
|
|
486
|
+
returnType: "number",
|
|
487
|
+
example: "math.sin(angle)"
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: "math.cos",
|
|
491
|
+
category: "math",
|
|
492
|
+
displayName: "余弦函数",
|
|
493
|
+
description: "余弦函数",
|
|
494
|
+
parameters: [
|
|
495
|
+
{ name: "d", type: "value", required: !0, description: "角度(弧度)", valueType: "number" }
|
|
496
|
+
],
|
|
497
|
+
returnType: "number",
|
|
498
|
+
example: "math.cos(angle)"
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
name: "math.tan",
|
|
502
|
+
category: "math",
|
|
503
|
+
displayName: "正切函数",
|
|
504
|
+
description: "正切函数",
|
|
505
|
+
parameters: [
|
|
506
|
+
{ name: "d", type: "value", required: !0, description: "角度(弧度)", valueType: "number" }
|
|
507
|
+
],
|
|
508
|
+
returnType: "number",
|
|
509
|
+
example: "math.tan(angle)"
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
name: "math.atan",
|
|
513
|
+
category: "math",
|
|
514
|
+
displayName: "反正切函数",
|
|
515
|
+
description: "反正切函数",
|
|
516
|
+
parameters: [
|
|
517
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
518
|
+
],
|
|
519
|
+
returnType: "number",
|
|
520
|
+
example: "math.atan(value)"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
name: "math.acos",
|
|
524
|
+
category: "math",
|
|
525
|
+
displayName: "反余弦函数",
|
|
526
|
+
description: "反余弦函数",
|
|
527
|
+
parameters: [
|
|
528
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
529
|
+
],
|
|
530
|
+
returnType: "number",
|
|
531
|
+
example: "math.acos(value)"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
name: "math.asin",
|
|
535
|
+
category: "math",
|
|
536
|
+
displayName: "反正弦函数",
|
|
537
|
+
description: "反正弦函数",
|
|
538
|
+
parameters: [
|
|
539
|
+
{ name: "d", type: "value", required: !0, description: "数值", valueType: "number" }
|
|
540
|
+
],
|
|
541
|
+
returnType: "number",
|
|
542
|
+
example: "math.asin(value)"
|
|
543
|
+
}
|
|
544
|
+
]), ye = Object.freeze([
|
|
545
|
+
...oe,
|
|
546
|
+
...pe,
|
|
547
|
+
...ce
|
|
548
|
+
]), L = Object.freeze([
|
|
549
|
+
{
|
|
550
|
+
name: "seq.list",
|
|
551
|
+
category: "sequence",
|
|
552
|
+
displayName: "创建列表",
|
|
553
|
+
description: "创建一个ArrayList实例",
|
|
554
|
+
parameters: [
|
|
555
|
+
{ name: "items", type: "value", required: !0, description: "列表元素(逗号分隔)", valueType: "array" }
|
|
556
|
+
],
|
|
557
|
+
returnType: "list",
|
|
558
|
+
example: 'seq.list("GET", "POST", "PUT")'
|
|
559
|
+
}
|
|
560
|
+
]), U = Object.freeze([
|
|
561
|
+
{
|
|
562
|
+
name: "seq.array",
|
|
563
|
+
category: "sequence",
|
|
564
|
+
displayName: "创建数组",
|
|
565
|
+
description: "创建指定类型的数组",
|
|
566
|
+
parameters: [
|
|
567
|
+
{ name: "clazz", type: "value", required: !0, description: "数组类型", valueType: "string" },
|
|
568
|
+
{ name: "elements", type: "value", required: !1, description: "数组元素", valueType: "array" }
|
|
569
|
+
],
|
|
570
|
+
returnType: "array",
|
|
571
|
+
example: 'seq.array("String", "a", "b", "c")'
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
name: "seq.set",
|
|
575
|
+
category: "sequence",
|
|
576
|
+
displayName: "创建集合",
|
|
577
|
+
description: "创建HashSet实例",
|
|
578
|
+
parameters: [
|
|
579
|
+
{ name: "elements", type: "value", required: !1, description: "集合元素", valueType: "array" }
|
|
580
|
+
],
|
|
581
|
+
returnType: "set",
|
|
582
|
+
example: 'seq.set("admin", "user", "guest")'
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
name: "seq.map",
|
|
586
|
+
category: "sequence",
|
|
587
|
+
displayName: "创建映射",
|
|
588
|
+
description: "创建HashMap实例",
|
|
589
|
+
parameters: [
|
|
590
|
+
{ name: "pairs", type: "value", required: !1, description: "键值对", valueType: "array" }
|
|
591
|
+
],
|
|
592
|
+
returnType: "map",
|
|
593
|
+
example: 'seq.map("key1", "value1", "key2", "value2")'
|
|
594
|
+
}
|
|
595
|
+
]);
|
|
596
|
+
Object.freeze([
|
|
597
|
+
...L,
|
|
598
|
+
...U
|
|
599
|
+
]);
|
|
600
|
+
const me = Object.freeze([
|
|
601
|
+
{
|
|
602
|
+
name: "seq.contains_key",
|
|
603
|
+
category: "sequence",
|
|
604
|
+
displayName: "包含键",
|
|
605
|
+
description: "当map中存在key时返回true",
|
|
606
|
+
parameters: [
|
|
607
|
+
{ name: "map", type: "value", required: !0, description: "映射对象", valueType: "any" },
|
|
608
|
+
{ name: "key", type: "value", required: !0, description: "键", valueType: "string" }
|
|
609
|
+
],
|
|
610
|
+
returnType: "boolean",
|
|
611
|
+
example: 'seq.contains_key(request.headers, "authorization")'
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
name: "seq.get",
|
|
615
|
+
category: "sequence",
|
|
616
|
+
displayName: "获取元素",
|
|
617
|
+
description: "从list、数组或hash-map获取对应的元素值",
|
|
618
|
+
parameters: [
|
|
619
|
+
{ name: "coll", type: "value", required: !0, description: "集合", valueType: "any" },
|
|
620
|
+
{ name: "element", type: "value", required: !0, description: "索引或键", valueType: "string" }
|
|
621
|
+
],
|
|
622
|
+
returnType: "any",
|
|
623
|
+
example: 'seq.get(request.headers, "user-agent")'
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
name: "include",
|
|
627
|
+
category: "sequence",
|
|
628
|
+
displayName: "包含元素",
|
|
629
|
+
description: "判断element是否在集合seq中",
|
|
630
|
+
parameters: [
|
|
631
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "list" },
|
|
632
|
+
{ name: "element", type: "value", required: !0, description: "要查找的元素", valueType: "string" }
|
|
633
|
+
],
|
|
634
|
+
returnType: "boolean",
|
|
635
|
+
example: 'include(seq.list("admin", "user"), user.role)'
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
name: "count",
|
|
639
|
+
category: "sequence",
|
|
640
|
+
displayName: "集合大小",
|
|
641
|
+
description: "返回集合大小",
|
|
642
|
+
parameters: [
|
|
643
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" }
|
|
644
|
+
],
|
|
645
|
+
returnType: "number",
|
|
646
|
+
example: "count(request.headers)"
|
|
647
|
+
}
|
|
648
|
+
]), de = Object.freeze([
|
|
649
|
+
{
|
|
650
|
+
name: "seq.keys",
|
|
651
|
+
category: "sequence",
|
|
652
|
+
displayName: "获取键集合",
|
|
653
|
+
description: "返回map的key集合",
|
|
654
|
+
parameters: [
|
|
655
|
+
{ name: "m", type: "value", required: !0, description: "映射对象", valueType: "any" }
|
|
656
|
+
],
|
|
657
|
+
returnType: "set",
|
|
658
|
+
example: "seq.keys(request.headers)"
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: "seq.vals",
|
|
662
|
+
category: "sequence",
|
|
663
|
+
displayName: "获取值集合",
|
|
664
|
+
description: "返回map的value集合",
|
|
665
|
+
parameters: [
|
|
666
|
+
{ name: "m", type: "value", required: !0, description: "映射对象", valueType: "any" }
|
|
667
|
+
],
|
|
668
|
+
returnType: "list",
|
|
669
|
+
example: "seq.vals(request.headers)"
|
|
670
|
+
}
|
|
671
|
+
]), fe = Object.freeze([
|
|
672
|
+
{
|
|
673
|
+
name: "seq.add",
|
|
674
|
+
category: "sequence",
|
|
675
|
+
displayName: "添加元素",
|
|
676
|
+
description: "往集合添加元素",
|
|
677
|
+
parameters: [
|
|
678
|
+
{ name: "coll", type: "value", required: !0, description: "集合", valueType: "any" },
|
|
679
|
+
{ name: "element", type: "value", required: !0, description: "要添加的元素", valueType: "string" }
|
|
680
|
+
],
|
|
681
|
+
returnType: "any",
|
|
682
|
+
example: 'seq.add(userList, "newUser")'
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
name: "seq.remove",
|
|
686
|
+
category: "sequence",
|
|
687
|
+
displayName: "删除元素",
|
|
688
|
+
description: "从集合删除元素",
|
|
689
|
+
parameters: [
|
|
690
|
+
{ name: "coll", type: "value", required: !0, description: "集合", valueType: "any" },
|
|
691
|
+
{ name: "element", type: "value", required: !0, description: "要删除的元素", valueType: "string" }
|
|
692
|
+
],
|
|
693
|
+
returnType: "any",
|
|
694
|
+
example: 'seq.remove(userList, "oldUser")'
|
|
695
|
+
}
|
|
696
|
+
]), ge = Object.freeze([
|
|
697
|
+
{
|
|
698
|
+
name: "map",
|
|
699
|
+
category: "sequence",
|
|
700
|
+
displayName: "映射函数",
|
|
701
|
+
description: "将函数作用到集合每个元素",
|
|
702
|
+
parameters: [
|
|
703
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" },
|
|
704
|
+
{ name: "fun", type: "value", required: !0, description: "函数", valueType: "string" }
|
|
705
|
+
],
|
|
706
|
+
returnType: "list",
|
|
707
|
+
example: "map(numbers, lambda(x) -> x * 2) end"
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
name: "filter",
|
|
711
|
+
category: "sequence",
|
|
712
|
+
displayName: "过滤函数",
|
|
713
|
+
description: "过滤集合中满足条件的元素",
|
|
714
|
+
parameters: [
|
|
715
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" },
|
|
716
|
+
{ name: "predicate", type: "value", required: !0, description: "谓词函数", valueType: "string" }
|
|
717
|
+
],
|
|
718
|
+
returnType: "list",
|
|
719
|
+
example: "filter(numbers, lambda(x) -> x > 10) end"
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
name: "sort",
|
|
723
|
+
category: "sequence",
|
|
724
|
+
displayName: "排序",
|
|
725
|
+
description: "排序集合,仅对数组和List有效",
|
|
726
|
+
parameters: [
|
|
727
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" },
|
|
728
|
+
{ name: "comparator", type: "value", required: !1, description: "比较器", valueType: "string" }
|
|
729
|
+
],
|
|
730
|
+
returnType: "list",
|
|
731
|
+
example: "sort(numbers) 或 sort(users, comparator(lambda(a, b) -> a.age - b.age end))"
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
name: "reverse",
|
|
735
|
+
category: "sequence",
|
|
736
|
+
displayName: "逆序",
|
|
737
|
+
description: "将集合元素逆序",
|
|
738
|
+
parameters: [
|
|
739
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" }
|
|
740
|
+
],
|
|
741
|
+
returnType: "list",
|
|
742
|
+
example: "reverse(numbers)"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
name: "distinct",
|
|
746
|
+
category: "sequence",
|
|
747
|
+
displayName: "去重",
|
|
748
|
+
description: "返回去重后的结果集合",
|
|
749
|
+
parameters: [
|
|
750
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" }
|
|
751
|
+
],
|
|
752
|
+
returnType: "list",
|
|
753
|
+
example: "distinct(numbers)"
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
name: "concat",
|
|
757
|
+
category: "sequence",
|
|
758
|
+
displayName: "连接集合",
|
|
759
|
+
description: "连接两个集合",
|
|
760
|
+
parameters: [
|
|
761
|
+
{ name: "seq1", type: "value", required: !0, description: "集合1", valueType: "any" },
|
|
762
|
+
{ name: "seq2", type: "value", required: !0, description: "集合2", valueType: "any" }
|
|
763
|
+
],
|
|
764
|
+
returnType: "list",
|
|
765
|
+
example: "concat(list1, list2)"
|
|
766
|
+
}
|
|
767
|
+
]), ve = Object.freeze([
|
|
768
|
+
{
|
|
769
|
+
name: "repeat",
|
|
770
|
+
category: "sequence",
|
|
771
|
+
displayName: "重复元素",
|
|
772
|
+
description: "返回将元素x重复n次的List",
|
|
773
|
+
parameters: [
|
|
774
|
+
{ name: "n", type: "value", required: !0, description: "重复次数", valueType: "number" },
|
|
775
|
+
{ name: "x", type: "value", required: !0, description: "要重复的元素", valueType: "string" }
|
|
776
|
+
],
|
|
777
|
+
returnType: "list",
|
|
778
|
+
example: 'repeat(3, "hello")'
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
name: "repeatedly",
|
|
782
|
+
category: "sequence",
|
|
783
|
+
displayName: "重复调用函数",
|
|
784
|
+
description: "返回将函数f重复调用n次结果的List",
|
|
785
|
+
parameters: [
|
|
786
|
+
{ name: "n", type: "value", required: !0, description: "调用次数", valueType: "number" },
|
|
787
|
+
{ name: "f", type: "value", required: !0, description: "要调用的函数", valueType: "string" }
|
|
788
|
+
],
|
|
789
|
+
returnType: "list",
|
|
790
|
+
example: "repeatedly(3, lambda() -> rand() end)"
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
name: "reduce",
|
|
794
|
+
category: "sequence",
|
|
795
|
+
displayName: "归约函数",
|
|
796
|
+
description: "将函数作用在结果值和集合每个元素上",
|
|
797
|
+
parameters: [
|
|
798
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" },
|
|
799
|
+
{ name: "fun", type: "value", required: !0, description: "归约函数", valueType: "string" },
|
|
800
|
+
{ name: "init", type: "value", required: !0, description: "初始值", valueType: "number" }
|
|
801
|
+
],
|
|
802
|
+
returnType: "any",
|
|
803
|
+
example: "reduce(numbers, lambda(acc, x) -> acc + x end, 0)"
|
|
804
|
+
}
|
|
805
|
+
]), Te = Object.freeze([
|
|
806
|
+
...ge,
|
|
807
|
+
...ve
|
|
808
|
+
]), be = Object.freeze([
|
|
809
|
+
{
|
|
810
|
+
name: "is_empty",
|
|
811
|
+
category: "sequence",
|
|
812
|
+
displayName: "集合是否为空",
|
|
813
|
+
description: "当集合为空或nil时返回true",
|
|
814
|
+
parameters: [
|
|
815
|
+
{ name: "seq", type: "value", required: !0, description: "集合或数组", valueType: "list" }
|
|
816
|
+
],
|
|
817
|
+
returnType: "boolean",
|
|
818
|
+
example: "is_empty(userList)"
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
name: "is_distinct",
|
|
822
|
+
category: "sequence",
|
|
823
|
+
displayName: "是否无重复",
|
|
824
|
+
description: "当seq没有重复元素时返回true",
|
|
825
|
+
parameters: [
|
|
826
|
+
{ name: "seq", type: "value", required: !0, description: "集合", valueType: "any" }
|
|
827
|
+
],
|
|
828
|
+
returnType: "boolean",
|
|
829
|
+
example: "is_distinct(userIds)"
|
|
830
|
+
}
|
|
831
|
+
]), Ne = Object.freeze([
|
|
832
|
+
...L,
|
|
833
|
+
...me,
|
|
834
|
+
...U,
|
|
835
|
+
...de,
|
|
836
|
+
...fe,
|
|
837
|
+
...Te,
|
|
838
|
+
...be
|
|
839
|
+
]), he = Object.freeze([
|
|
840
|
+
{
|
|
841
|
+
name: "datetime.dateStrToMilliSecond",
|
|
842
|
+
category: "datetime",
|
|
843
|
+
displayName: "日期转毫秒",
|
|
844
|
+
description: "将日期字符串转换为毫秒时间戳",
|
|
845
|
+
parameters: [
|
|
846
|
+
{ name: "dateStr", type: "value", required: !0, description: "日期字符串", valueType: "string" },
|
|
847
|
+
{ name: "format", type: "value", required: !1, description: "日期格式", valueType: "string" },
|
|
848
|
+
{ name: "timezone", type: "value", required: !1, description: "时区", valueType: "string" }
|
|
849
|
+
],
|
|
850
|
+
returnType: "number",
|
|
851
|
+
example: 'datetime.dateStrToMilliSecond(event.created, "yyyy-MM-dd HH:mm:ss")'
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
name: "datetime.milliSecondToDate",
|
|
855
|
+
category: "datetime",
|
|
856
|
+
displayName: "毫秒转日期",
|
|
857
|
+
description: "将毫秒时间戳转换为LocalDate",
|
|
858
|
+
parameters: [
|
|
859
|
+
{ name: "milliSecond", type: "value", required: !0, description: "毫秒时间戳", valueType: "number" }
|
|
860
|
+
],
|
|
861
|
+
returnType: "date",
|
|
862
|
+
example: "datetime.milliSecondToDate(event.timestamp)"
|
|
863
|
+
}
|
|
864
|
+
]), Ee = Object.freeze([
|
|
865
|
+
{
|
|
866
|
+
name: "datetime.isSameDay",
|
|
867
|
+
category: "datetime",
|
|
868
|
+
displayName: "同一天判断",
|
|
869
|
+
description: "判断两个时间戳是否是同一天",
|
|
870
|
+
parameters: [
|
|
871
|
+
{ name: "second1", type: "value", required: !0, description: "时间戳1(秒)", valueType: "number" },
|
|
872
|
+
{ name: "second2", type: "value", required: !0, description: "时间戳2(秒)", valueType: "number" }
|
|
873
|
+
],
|
|
874
|
+
returnType: "boolean",
|
|
875
|
+
example: "datetime.isSameDay(event.created, event.updated)"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
name: "datetime.isAfterDay",
|
|
879
|
+
category: "datetime",
|
|
880
|
+
displayName: "日期晚于判断",
|
|
881
|
+
description: "判断第一个日期是否晚于第二个日期",
|
|
882
|
+
parameters: [
|
|
883
|
+
{ name: "date1", type: "value", required: !0, description: "日期1", valueType: "any" },
|
|
884
|
+
{ name: "date2", type: "value", required: !0, description: "日期2", valueType: "any" }
|
|
885
|
+
],
|
|
886
|
+
returnType: "boolean",
|
|
887
|
+
example: "datetime.isAfterDay(event.created, event.baseline)"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
name: "datetime.isBeforeDay",
|
|
891
|
+
category: "datetime",
|
|
892
|
+
displayName: "日期早于判断",
|
|
893
|
+
description: "判断第一个日期是否早于第二个日期",
|
|
894
|
+
parameters: [
|
|
895
|
+
{ name: "date1", type: "value", required: !0, description: "日期1", valueType: "any" },
|
|
896
|
+
{ name: "date2", type: "value", required: !0, description: "日期2", valueType: "any" }
|
|
897
|
+
],
|
|
898
|
+
returnType: "boolean",
|
|
899
|
+
example: "datetime.isBeforeDay(event.created, event.deadline)"
|
|
900
|
+
}
|
|
901
|
+
]), qe = Object.freeze([
|
|
902
|
+
{
|
|
903
|
+
name: "datetime.strToLocalDate",
|
|
904
|
+
category: "datetime",
|
|
905
|
+
displayName: "字符串转LocalDate",
|
|
906
|
+
description: "将日期字符串转换为LocalDate",
|
|
907
|
+
parameters: [
|
|
908
|
+
{ name: "dateStr", type: "value", required: !0, description: "日期字符串", valueType: "string" }
|
|
909
|
+
],
|
|
910
|
+
returnType: "date",
|
|
911
|
+
example: "datetime.strToLocalDate(event.dateString)"
|
|
912
|
+
}
|
|
913
|
+
]), xe = Object.freeze([
|
|
914
|
+
...he,
|
|
915
|
+
...Ee,
|
|
916
|
+
...qe
|
|
917
|
+
]), Ie = Object.freeze([
|
|
918
|
+
{
|
|
919
|
+
name: "user.getUserStatus",
|
|
920
|
+
category: "custom",
|
|
921
|
+
displayName: "获取用户状态",
|
|
922
|
+
description: "根据员工ID获取用户状态",
|
|
923
|
+
parameters: [
|
|
924
|
+
{ name: "emplid", type: "value", required: !0, description: "员工ID", valueType: "string" }
|
|
925
|
+
],
|
|
926
|
+
returnType: "number",
|
|
927
|
+
example: "user.getUserStatus(user.emplid)"
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
name: "user.getUserEmplidByEmail",
|
|
931
|
+
category: "custom",
|
|
932
|
+
displayName: "邮箱获取员工ID",
|
|
933
|
+
description: "根据邮箱获取员工ID",
|
|
934
|
+
parameters: [
|
|
935
|
+
{ name: "email", type: "value", required: !0, description: "邮箱地址", valueType: "string" }
|
|
936
|
+
],
|
|
937
|
+
returnType: "string",
|
|
938
|
+
example: "user.getUserEmplidByEmail(user.email)"
|
|
939
|
+
}
|
|
940
|
+
]), Se = Object.freeze([
|
|
941
|
+
{
|
|
942
|
+
name: "ipUser.getUser",
|
|
943
|
+
category: "custom",
|
|
944
|
+
displayName: "获取IP用户信息",
|
|
945
|
+
description: "根据IP获取用户信息",
|
|
946
|
+
parameters: [
|
|
947
|
+
{ name: "ip", type: "value", required: !0, description: "IP地址", valueType: "string" },
|
|
948
|
+
{ name: "timestamp", type: "value", required: !1, description: "时间戳(秒)", valueType: "number" }
|
|
949
|
+
],
|
|
950
|
+
returnType: "object",
|
|
951
|
+
example: "ipUser.getUser(client_ip, event.timestamp)"
|
|
952
|
+
}
|
|
953
|
+
]), Oe = Object.freeze([
|
|
954
|
+
{
|
|
955
|
+
name: "intelligence.ifWhiteIp",
|
|
956
|
+
category: "custom",
|
|
957
|
+
displayName: "IP白名单检查",
|
|
958
|
+
description: "检查IP是否在白名单中",
|
|
959
|
+
parameters: [
|
|
960
|
+
{ name: "ip", type: "value", required: !0, description: "IP地址", valueType: "string" }
|
|
961
|
+
],
|
|
962
|
+
returnType: "boolean",
|
|
963
|
+
example: "intelligence.ifWhiteIp(client_ip)"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
name: "intelligence.ifBlackIp",
|
|
967
|
+
category: "custom",
|
|
968
|
+
displayName: "IP黑名单检查",
|
|
969
|
+
description: "检查IP是否在黑名单中",
|
|
970
|
+
parameters: [
|
|
971
|
+
{ name: "ip", type: "value", required: !0, description: "IP地址", valueType: "string" }
|
|
972
|
+
],
|
|
973
|
+
returnType: "boolean",
|
|
974
|
+
example: "intelligence.ifBlackIp(client_ip)"
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
name: "intelligence.ifBlackDomain",
|
|
978
|
+
category: "custom",
|
|
979
|
+
displayName: "域名黑名单检查",
|
|
980
|
+
description: "检查域名是否在黑名单中",
|
|
981
|
+
parameters: [
|
|
982
|
+
{ name: "domain", type: "value", required: !0, description: "域名", valueType: "string" }
|
|
983
|
+
],
|
|
984
|
+
returnType: "boolean",
|
|
985
|
+
example: "intelligence.ifBlackDomain(request.host)"
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
name: "intelligence.ifBlackUrl",
|
|
989
|
+
category: "custom",
|
|
990
|
+
displayName: "URL黑名单检查",
|
|
991
|
+
description: "检查URL是否在黑名单中",
|
|
992
|
+
parameters: [
|
|
993
|
+
{ name: "url", type: "value", required: !0, description: "URL地址", valueType: "string" }
|
|
994
|
+
],
|
|
995
|
+
returnType: "boolean",
|
|
996
|
+
example: "intelligence.ifBlackUrl(request.uri)"
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
name: "intelligence.ifBlackHash",
|
|
1000
|
+
category: "custom",
|
|
1001
|
+
displayName: "Hash黑名单检查",
|
|
1002
|
+
description: "检查Hash是否在黑名单中",
|
|
1003
|
+
parameters: [
|
|
1004
|
+
{ name: "hash", type: "value", required: !0, description: "Hash值", valueType: "string" }
|
|
1005
|
+
],
|
|
1006
|
+
returnType: "boolean",
|
|
1007
|
+
example: "intelligence.ifBlackHash(file.hash)"
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
name: "intelligence.checkIfInnerIp",
|
|
1011
|
+
category: "custom",
|
|
1012
|
+
displayName: "内网IP检查",
|
|
1013
|
+
description: "检查IP是否为内网IP",
|
|
1014
|
+
parameters: [
|
|
1015
|
+
{ name: "ip", type: "value", required: !0, description: "IP地址", valueType: "string" }
|
|
1016
|
+
],
|
|
1017
|
+
returnType: "boolean",
|
|
1018
|
+
example: "intelligence.checkIfInnerIp(client_ip)"
|
|
1019
|
+
}
|
|
1020
|
+
]), Ce = Object.freeze([
|
|
1021
|
+
{
|
|
1022
|
+
name: "isTimeInRange.isTimestampInRange",
|
|
1023
|
+
category: "custom",
|
|
1024
|
+
displayName: "时间范围检查",
|
|
1025
|
+
description: "检查时间戳是否在指定时间范围内",
|
|
1026
|
+
parameters: [
|
|
1027
|
+
{ name: "country", type: "value", required: !0, description: "国家", valueType: "string" },
|
|
1028
|
+
{ name: "timestamp", type: "value", required: !0, description: "时间戳", valueType: "number" },
|
|
1029
|
+
{ name: "startTime", type: "value", required: !0, description: "开始时间", valueType: "number" },
|
|
1030
|
+
{ name: "endTime", type: "value", required: !0, description: "结束时间", valueType: "number" }
|
|
1031
|
+
],
|
|
1032
|
+
returnType: "boolean",
|
|
1033
|
+
example: 'isTimeInRange.isTimestampInRange("CN", event.timestamp, 9, 18)'
|
|
1034
|
+
}
|
|
1035
|
+
]), _e = Object.freeze([
|
|
1036
|
+
{
|
|
1037
|
+
name: "IPScene.isIpInNetmaskList",
|
|
1038
|
+
category: "custom",
|
|
1039
|
+
displayName: "IP网段列表检查",
|
|
1040
|
+
description: "检查IP是否在指定网段列表中的任意一个",
|
|
1041
|
+
parameters: [
|
|
1042
|
+
{ name: "ip", type: "value", required: !0, description: "IP地址", valueType: "string" },
|
|
1043
|
+
{ name: "netmaskList", type: "value", required: !0, description: "网段列表", valueType: "list" }
|
|
1044
|
+
],
|
|
1045
|
+
returnType: "boolean",
|
|
1046
|
+
example: 'IPScene.isIpInNetmaskList(client_ip, seq.list("10.128.16.0/20", "10.128.16.0/23"))'
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
name: "IPScene.isIoaIP",
|
|
1050
|
+
category: "custom",
|
|
1051
|
+
displayName: "IOA IP检查",
|
|
1052
|
+
description: "检查是否为IOA IP",
|
|
1053
|
+
parameters: [
|
|
1054
|
+
{ name: "ip", type: "value", required: !0, description: "IP地址", valueType: "string" }
|
|
1055
|
+
],
|
|
1056
|
+
returnType: "boolean",
|
|
1057
|
+
example: "IPScene.isIoaIP(client_ip)"
|
|
1058
|
+
}
|
|
1059
|
+
]), Fe = Object.freeze([
|
|
1060
|
+
{
|
|
1061
|
+
name: "filter.checkInWhiteList",
|
|
1062
|
+
category: "custom",
|
|
1063
|
+
displayName: "白名单检查",
|
|
1064
|
+
description: "检查值是否在白名单中",
|
|
1065
|
+
parameters: [
|
|
1066
|
+
{ name: "whiteType", type: "value", required: !0, description: "白名单类型", valueType: "string" },
|
|
1067
|
+
{ name: "value", type: "value", required: !0, description: "检查值", valueType: "string" }
|
|
1068
|
+
],
|
|
1069
|
+
returnType: "boolean",
|
|
1070
|
+
example: 'filter.checkInWhiteList("domain", request.host)'
|
|
1071
|
+
}
|
|
1072
|
+
]), Ae = Object.freeze([
|
|
1073
|
+
{
|
|
1074
|
+
name: "enhance.getValue",
|
|
1075
|
+
category: "custom",
|
|
1076
|
+
displayName: "获取路径值",
|
|
1077
|
+
description: "获取包含特殊字符的路径字段值",
|
|
1078
|
+
parameters: [
|
|
1079
|
+
{ name: "path", type: "value", required: !0, description: "字段路径", valueType: "string" }
|
|
1080
|
+
],
|
|
1081
|
+
returnType: "any",
|
|
1082
|
+
example: 'enhance.getValue("a-b.c-d")'
|
|
1083
|
+
}
|
|
1084
|
+
]), Re = Object.freeze([
|
|
1085
|
+
...Ie,
|
|
1086
|
+
...Se,
|
|
1087
|
+
...Oe,
|
|
1088
|
+
...Ce,
|
|
1089
|
+
..._e,
|
|
1090
|
+
...Fe,
|
|
1091
|
+
...Ae
|
|
1092
|
+
]), f = Object.freeze([
|
|
1093
|
+
...te,
|
|
1094
|
+
...le,
|
|
1095
|
+
...ye,
|
|
1096
|
+
...Ne,
|
|
1097
|
+
...xe,
|
|
1098
|
+
...Re
|
|
1099
|
+
]), Ot = Object.freeze({
|
|
1100
|
+
boolean: [
|
|
1101
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1102
|
+
{ label: "!=", value: "!=", symbol: "!=" }
|
|
1103
|
+
],
|
|
1104
|
+
string: [
|
|
1105
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1106
|
+
{ label: "!=", value: "!=", symbol: "!=" },
|
|
1107
|
+
{ label: "== nil", value: "== nil", symbol: "== nil" },
|
|
1108
|
+
{ label: "!= nil", value: "!= nil", symbol: "!= nil" },
|
|
1109
|
+
{ label: "== ''", value: "== ''", symbol: "== ''" },
|
|
1110
|
+
{ label: "!= ''", value: "!= ''", symbol: "!= ''" },
|
|
1111
|
+
{ label: "contains", value: "contains", symbol: "contains" },
|
|
1112
|
+
{ label: "regex", value: "match", symbol: "regex" },
|
|
1113
|
+
{ label: "startsWith", value: "startsWith", symbol: "startsWith" },
|
|
1114
|
+
{ label: "endsWith", value: "endsWith", symbol: "endsWith" }
|
|
1115
|
+
],
|
|
1116
|
+
number: [
|
|
1117
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1118
|
+
{ label: "!=", value: "!=", symbol: "!=" },
|
|
1119
|
+
{ label: ">", value: ">", symbol: ">" },
|
|
1120
|
+
{ label: ">=", value: ">=", symbol: ">=" },
|
|
1121
|
+
{ label: "<", value: "<", symbol: "<" },
|
|
1122
|
+
{ label: "<=", value: "<=", symbol: "<=" },
|
|
1123
|
+
{ label: "== nil", value: "== nil", symbol: "== nil" },
|
|
1124
|
+
{ label: "!= nil", value: "!= nil", symbol: "!= nil" }
|
|
1125
|
+
],
|
|
1126
|
+
ip: [
|
|
1127
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1128
|
+
{ label: "!=", value: "!=", symbol: "!=" },
|
|
1129
|
+
{ label: "== nil", value: "== nil", symbol: "== nil" },
|
|
1130
|
+
{ label: "!= nil", value: "!= nil", symbol: "!= nil" },
|
|
1131
|
+
{ label: "== ''", value: "== ''", symbol: "== ''" },
|
|
1132
|
+
{ label: "!= ''", value: "!= ''", symbol: "!= ''" },
|
|
1133
|
+
{ label: "contains", value: "contains", symbol: "contains" },
|
|
1134
|
+
{ label: "regex", value: "match", symbol: "regex" },
|
|
1135
|
+
{ label: "startsWith", value: "startsWith", symbol: "startsWith" },
|
|
1136
|
+
{ label: "endsWith", value: "endsWith", symbol: "endsWith" },
|
|
1137
|
+
{ label: "isIpInNetmaskList", value: "isIpInNetmaskList", symbol: "isIpInNetmaskList" }
|
|
1138
|
+
],
|
|
1139
|
+
url: [
|
|
1140
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1141
|
+
{ label: "!=", value: "!=", symbol: "!=" },
|
|
1142
|
+
{ label: "== nil", value: "== nil", symbol: "== nil" },
|
|
1143
|
+
{ label: "!= nil", value: "!= nil", symbol: "!= nil" }
|
|
1144
|
+
],
|
|
1145
|
+
email: [
|
|
1146
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1147
|
+
{ label: "!=", value: "!=", symbol: "!=" },
|
|
1148
|
+
{ label: "== nil", value: "== nil", symbol: "== nil" },
|
|
1149
|
+
{ label: "!= nil", value: "!= nil", symbol: "!= nil" }
|
|
1150
|
+
],
|
|
1151
|
+
uuid: [
|
|
1152
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1153
|
+
{ label: "!=", value: "!=", symbol: "!=" },
|
|
1154
|
+
{ label: "== nil", value: "== nil", symbol: "== nil" },
|
|
1155
|
+
{ label: "!= nil", value: "!= nil", symbol: "!= nil" }
|
|
1156
|
+
],
|
|
1157
|
+
datetime: [
|
|
1158
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1159
|
+
{ label: "!=", value: "!=", symbol: "!=" },
|
|
1160
|
+
{ label: ">", value: ">", symbol: ">" },
|
|
1161
|
+
{ label: ">=", value: ">=", symbol: ">=" },
|
|
1162
|
+
{ label: "<", value: "<", symbol: "<" },
|
|
1163
|
+
{ label: "<=", value: "<=", symbol: "<=" }
|
|
1164
|
+
],
|
|
1165
|
+
array: [
|
|
1166
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1167
|
+
{ label: "!=", value: "!=", symbol: "!=" },
|
|
1168
|
+
{ label: "belong", value: "belong", symbol: "belong" }
|
|
1169
|
+
],
|
|
1170
|
+
object: [
|
|
1171
|
+
{ label: "==", value: "==", symbol: "==" },
|
|
1172
|
+
{ label: "!=", value: "!=", symbol: "!=" }
|
|
1173
|
+
]
|
|
1174
|
+
});
|
|
1175
|
+
function k() {
|
|
1176
|
+
return `node_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
1177
|
+
}
|
|
1178
|
+
function g(e, r = 0) {
|
|
1179
|
+
return {
|
|
1180
|
+
id: k(),
|
|
1181
|
+
type: "condition",
|
|
1182
|
+
level: r,
|
|
1183
|
+
parentId: e,
|
|
1184
|
+
field: "",
|
|
1185
|
+
comparison: "==",
|
|
1186
|
+
value: ""
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
function _(e, r = 0) {
|
|
1190
|
+
return {
|
|
1191
|
+
id: k(),
|
|
1192
|
+
type: "group",
|
|
1193
|
+
level: r,
|
|
1194
|
+
parentId: e,
|
|
1195
|
+
operator: "AND",
|
|
1196
|
+
children: [],
|
|
1197
|
+
expanded: !0
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
function Le(e, r, t) {
|
|
1201
|
+
if ([
|
|
1202
|
+
{ func: "map", param: "fun" },
|
|
1203
|
+
{ func: "filter", param: "predicate" },
|
|
1204
|
+
{ func: "sort", param: "comparator" },
|
|
1205
|
+
{ func: "repeatedly", param: "f" },
|
|
1206
|
+
{ func: "reduce", param: "fun" }
|
|
1207
|
+
].some((a) => a.func === e && a.param === r))
|
|
1208
|
+
return !0;
|
|
1209
|
+
if (t) {
|
|
1210
|
+
const a = t.toLowerCase();
|
|
1211
|
+
if (a.includes("函数") || a.includes("谓词") || a.includes("比较器") || a.includes("lambda") || a.includes("匿名函数") || a.includes("匿名") || a.includes("回调"))
|
|
1212
|
+
return !0;
|
|
1213
|
+
}
|
|
1214
|
+
if (r) {
|
|
1215
|
+
const a = r.toLowerCase();
|
|
1216
|
+
if (a === "fun" || a === "predicate" || a === "comparator" || a === "callback" || a === "f" || a === "fn")
|
|
1217
|
+
return !0;
|
|
1218
|
+
}
|
|
1219
|
+
return !1;
|
|
1220
|
+
}
|
|
1221
|
+
function Ue(e) {
|
|
1222
|
+
return !e || typeof e != "object" || Array.isArray(e) ? !1 : Object.keys(e).length > 1;
|
|
1223
|
+
}
|
|
1224
|
+
function ke(e) {
|
|
1225
|
+
return e == null ? "null" : Array.isArray(e) ? "array" : typeof e == "object" ? "object" : typeof e == "number" ? "number" : typeof e == "boolean" ? "boolean" : typeof e == "string" ? /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e) ? "datetime" : /^\d+\.\d+\.\d+\.\d+$/.test(e) ? "ip" : e.includes("@") && e.includes(".") && !e.includes(" ") ? "email" : /^https?:\/\//.test(e) ? "url" : /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e) ? "uuid" : e.length > 50 && /^[A-Z0-9+/=.]+$/i.test(e) ? "token" : "string" : "unknown";
|
|
1226
|
+
}
|
|
1227
|
+
function Me(e) {
|
|
1228
|
+
return e == null ? "nil" : Array.isArray(e) ? `[${e.length} items]` : typeof e == "object" ? "{object}" : typeof e == "string" && e.length > 20 ? `"${e.substring(0, 20)}..."` : String(e);
|
|
1229
|
+
}
|
|
1230
|
+
const F = [
|
|
1231
|
+
"ip_user",
|
|
1232
|
+
"token_user",
|
|
1233
|
+
"client_ip",
|
|
1234
|
+
"uuid",
|
|
1235
|
+
"response.status",
|
|
1236
|
+
"request.method",
|
|
1237
|
+
"request.uri",
|
|
1238
|
+
"request.url",
|
|
1239
|
+
"service_id",
|
|
1240
|
+
"upstream",
|
|
1241
|
+
"latency",
|
|
1242
|
+
"start_time",
|
|
1243
|
+
"user",
|
|
1244
|
+
"username",
|
|
1245
|
+
"id",
|
|
1246
|
+
"status",
|
|
1247
|
+
"time",
|
|
1248
|
+
"timestamp"
|
|
1249
|
+
];
|
|
1250
|
+
function Pe(e) {
|
|
1251
|
+
return e.sort((r, t) => {
|
|
1252
|
+
const n = F.findIndex(
|
|
1253
|
+
(u) => r.value === u || r.value.toLowerCase().includes(u.toLowerCase())
|
|
1254
|
+
), a = F.findIndex(
|
|
1255
|
+
(u) => t.value === u || t.value.toLowerCase().includes(u.toLowerCase())
|
|
1256
|
+
);
|
|
1257
|
+
if (n !== -1 && a !== -1)
|
|
1258
|
+
return n - a;
|
|
1259
|
+
if (n !== -1)
|
|
1260
|
+
return -1;
|
|
1261
|
+
if (a !== -1)
|
|
1262
|
+
return 1;
|
|
1263
|
+
const s = r.value.split(".").length, i = t.value.split(".").length;
|
|
1264
|
+
return s !== i ? s - i : r.value.localeCompare(t.value);
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
function q(e, r = "", t = 8, n = 0) {
|
|
1268
|
+
if (n >= t || e === null || e === void 0)
|
|
1269
|
+
return [];
|
|
1270
|
+
const a = [];
|
|
1271
|
+
if (Array.isArray(e))
|
|
1272
|
+
return e.length > 0 ? q(e[0], r, t, n + 1) : a;
|
|
1273
|
+
if (typeof e == "object") {
|
|
1274
|
+
const s = e;
|
|
1275
|
+
Object.keys(s).forEach((i) => {
|
|
1276
|
+
const u = r ? `${r}.${i}` : i, l = s[i];
|
|
1277
|
+
if (Ue(l) || a.push({
|
|
1278
|
+
label: u,
|
|
1279
|
+
value: u,
|
|
1280
|
+
type: ke(l),
|
|
1281
|
+
example: Me(l)
|
|
1282
|
+
}), l && typeof l == "object") {
|
|
1283
|
+
const p = q(l, u, t, n + 1);
|
|
1284
|
+
a.push(...p);
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
return a;
|
|
1289
|
+
}
|
|
1290
|
+
function Ct(e) {
|
|
1291
|
+
if (!e || e.trim() === "" || e.trim() === "{}")
|
|
1292
|
+
return [];
|
|
1293
|
+
try {
|
|
1294
|
+
const r = JSON.parse(e), n = q(r).filter((a) => a.type !== "object" && a.type !== "null");
|
|
1295
|
+
return Pe(n);
|
|
1296
|
+
} catch {
|
|
1297
|
+
return [];
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
function $e(e, r, t) {
|
|
1301
|
+
return e === "contains" ? `string.contains(${r}, ${t})` : e === "startsWith" ? `string.startsWith(${r}, ${t})` : e === "endsWith" ? `string.endsWith(${r}, ${t})` : null;
|
|
1302
|
+
}
|
|
1303
|
+
function De(e, r) {
|
|
1304
|
+
const t = r.parameterDataTypes.get(e.id);
|
|
1305
|
+
return (t == null ? void 0 : t.get("condition_value")) || "string";
|
|
1306
|
+
}
|
|
1307
|
+
function I(e, r) {
|
|
1308
|
+
return De(e, r);
|
|
1309
|
+
}
|
|
1310
|
+
function je(e) {
|
|
1311
|
+
const r = e.match(/^([a-z_][\w.]*)\s*\(/i);
|
|
1312
|
+
return r ? f.some((t) => t.name === r[1]) : !1;
|
|
1313
|
+
}
|
|
1314
|
+
function we(e, r) {
|
|
1315
|
+
const t = e.value, n = I(e, r);
|
|
1316
|
+
if (typeof t == "string" && t !== "nil" && t !== "") {
|
|
1317
|
+
if (e.valueIsLiteral === !0)
|
|
1318
|
+
return n === "number" || n === "boolean" ? t : !t.startsWith('"') && !t.startsWith("'") ? `"${t}"` : t;
|
|
1319
|
+
const a = r.availableFields.some((i) => i.value === t), s = e.valueIsField === !0;
|
|
1320
|
+
return a || je(t) || s || n === "number" || n === "boolean" ? t : !t.startsWith('"') && !t.startsWith("'") ? `"${t}"` : t;
|
|
1321
|
+
}
|
|
1322
|
+
return typeof t == "number" ? n === "string" ? `"${t}"` : String(t) : typeof t == "boolean" ? String(t) : t;
|
|
1323
|
+
}
|
|
1324
|
+
function ze(e) {
|
|
1325
|
+
if (Array.isArray(e))
|
|
1326
|
+
return e;
|
|
1327
|
+
if (typeof e != "string")
|
|
1328
|
+
return [];
|
|
1329
|
+
try {
|
|
1330
|
+
const r = JSON.parse(e);
|
|
1331
|
+
return Array.isArray(r) ? r : [e];
|
|
1332
|
+
} catch {
|
|
1333
|
+
return [e];
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
function We(e, r) {
|
|
1337
|
+
return e.map((t) => r === "number" || r === "boolean" ? String(t) : typeof t == "string" ? `"${t}"` : `"${String(t)}"`).join(", ");
|
|
1338
|
+
}
|
|
1339
|
+
function M(e, r) {
|
|
1340
|
+
return We(ze(e), r);
|
|
1341
|
+
}
|
|
1342
|
+
function Be(e, r) {
|
|
1343
|
+
const t = I(e, r), n = M(e.value, t), a = `seq.some(${e.field}, lambda(x) -> include(seq.list(${n}), x) end)`;
|
|
1344
|
+
return e.isNegated ? `${a} == nil` : `${a} != nil`;
|
|
1345
|
+
}
|
|
1346
|
+
function Ve(e, r) {
|
|
1347
|
+
const t = I(e, r), n = M(e.value, t), a = `IPScene.isIpInNetmaskList(${e.field}, seq.list(${n}))`;
|
|
1348
|
+
return e.isNegated ? `!${a}` : a;
|
|
1349
|
+
}
|
|
1350
|
+
function Ge(e, r, t) {
|
|
1351
|
+
const n = `string.match(${e}, ${r}, 0)`;
|
|
1352
|
+
return t ? `${n} == nil` : `${n} != nil`;
|
|
1353
|
+
}
|
|
1354
|
+
function He(e) {
|
|
1355
|
+
const { node: r, context: t, formattedValue: n } = e;
|
|
1356
|
+
return r.comparison === "isIpInNetmaskList" ? Ve(r, t) : r.comparison === "belong" ? Be(r, t) : r.comparison === "match" ? Ge(n, r.field || "", r.isNegated) : null;
|
|
1357
|
+
}
|
|
1358
|
+
function Ye(e, r) {
|
|
1359
|
+
if (!e.field || !e.comparison)
|
|
1360
|
+
return "";
|
|
1361
|
+
if (e.value === void 0 || e.value === null) {
|
|
1362
|
+
const i = `${e.field} ${e.comparison}`;
|
|
1363
|
+
return e.isNegated ? `!(${i})` : i;
|
|
1364
|
+
}
|
|
1365
|
+
const t = we(e, r), n = He({
|
|
1366
|
+
node: e,
|
|
1367
|
+
context: r,
|
|
1368
|
+
formattedValue: t
|
|
1369
|
+
});
|
|
1370
|
+
if (n)
|
|
1371
|
+
return n;
|
|
1372
|
+
const s = $e(e.comparison, e.field, t) ?? `${e.field} ${e.comparison} ${t}`;
|
|
1373
|
+
return e.isNegated ? `!(${s})` : s;
|
|
1374
|
+
}
|
|
1375
|
+
const Ke = /* @__PURE__ */ new Set(["== nil", "!= nil", "== ''", "!= ''"]);
|
|
1376
|
+
function Qe(e) {
|
|
1377
|
+
return typeof e == "string" && e.includes("lambda(") && e.includes("end");
|
|
1378
|
+
}
|
|
1379
|
+
function Je(e) {
|
|
1380
|
+
return e.isNested && e.nestedNode ? !0 : e.value !== void 0 && e.value !== "";
|
|
1381
|
+
}
|
|
1382
|
+
function Xe(e, r) {
|
|
1383
|
+
let t = e.type || "value";
|
|
1384
|
+
try {
|
|
1385
|
+
t === "value" && typeof e.value == "string" && e.value && r.availableFields.some((n) => n.value === e.value) && (t = "field");
|
|
1386
|
+
} catch (n) {
|
|
1387
|
+
const a = n instanceof Error ? n.message : String(n);
|
|
1388
|
+
console.warn("⚠️ 字段检测失败:", a);
|
|
1389
|
+
}
|
|
1390
|
+
return t;
|
|
1391
|
+
}
|
|
1392
|
+
function Ze(e, r, t, n, a) {
|
|
1393
|
+
if (r.isNested && r.nestedNode)
|
|
1394
|
+
return n(r.nestedNode, t);
|
|
1395
|
+
const s = Xe(r, t);
|
|
1396
|
+
if (r.value === void 0 || r.value === "" || s !== "value" || Qe(r.value) || Array.isArray(r.value) && a.expandArrayValueParameters)
|
|
1397
|
+
return r.value;
|
|
1398
|
+
const i = t.parameterDataTypes.get(e.id), u = (i == null ? void 0 : i.get(r.name || "")) || r.valueType || "string";
|
|
1399
|
+
return typeof r.value == "string" ? u === "number" || u === "boolean" ? r.value : !r.value.startsWith('"') && !r.value.startsWith("'") ? `"${r.value}"` : r.value : typeof r.value == "number" ? u === "string" ? `"${r.value}"` : String(r.value) : typeof r.value == "boolean" ? String(r.value) : r.value;
|
|
1400
|
+
}
|
|
1401
|
+
function er(e) {
|
|
1402
|
+
const r = [];
|
|
1403
|
+
return e.forEach((t) => {
|
|
1404
|
+
if (Array.isArray(t)) {
|
|
1405
|
+
t.forEach((n) => {
|
|
1406
|
+
typeof n == "string" ? r.push(`"${n}"`) : r.push(String(n));
|
|
1407
|
+
});
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
r.push(String(t));
|
|
1411
|
+
}), r.join(", ");
|
|
1412
|
+
}
|
|
1413
|
+
function rr(e, r) {
|
|
1414
|
+
return r.expandArrayValueParameters ? er(e) : e.join(", ");
|
|
1415
|
+
}
|
|
1416
|
+
function tr(e, r, t, n = {}) {
|
|
1417
|
+
if (!e.functionName || !e.parameters)
|
|
1418
|
+
return "";
|
|
1419
|
+
const a = e.parameters.filter(Je).map((s) => Ze(e, s, r, t, n));
|
|
1420
|
+
return `${e.functionName}(${rr(a, n)})`;
|
|
1421
|
+
}
|
|
1422
|
+
function nr(e) {
|
|
1423
|
+
return e ? Ke.has(e) : !1;
|
|
1424
|
+
}
|
|
1425
|
+
function ar(e) {
|
|
1426
|
+
const { userSelectedDataType: r, treatAsField: t = !1 } = e;
|
|
1427
|
+
let { value: n } = e;
|
|
1428
|
+
return typeof n == "string" && n !== "nil" && n !== "" ? (t || r === "number" || r === "boolean" || !n.startsWith('"') && !n.startsWith("'") && (n = `"${n}"`), n) : typeof n == "number" ? r === "string" ? `"${n}"` : String(n) : typeof n == "boolean" ? String(n) : n;
|
|
1429
|
+
}
|
|
1430
|
+
const ir = new Map(f.map((e) => [e.name, e.returnType]));
|
|
1431
|
+
function sr(e) {
|
|
1432
|
+
return e ? ir.get(e) === "boolean" : !1;
|
|
1433
|
+
}
|
|
1434
|
+
function A(e, r, t) {
|
|
1435
|
+
return r.isNegated ? t === "boolean-only" ? `!${e}` : t === "wrap-final" ? `!(${e})` : e : e;
|
|
1436
|
+
}
|
|
1437
|
+
function P(e, r, t, n = {}) {
|
|
1438
|
+
if (!e.functionName || !e.parameters)
|
|
1439
|
+
return "";
|
|
1440
|
+
const a = tr(e, r, t, n.call);
|
|
1441
|
+
if (sr(e.functionName))
|
|
1442
|
+
return A(a, e, n.negationStrategy);
|
|
1443
|
+
let i = a;
|
|
1444
|
+
if (e.comparison) {
|
|
1445
|
+
if (nr(e.comparison))
|
|
1446
|
+
i = `${a} ${e.comparison}`;
|
|
1447
|
+
else if (e.value !== void 0 && e.value !== "") {
|
|
1448
|
+
const u = r.parameterDataTypes.get(e.id), l = e.functionName || "condition_value", p = (u == null ? void 0 : u.get(l)) || "string", y = ar({
|
|
1449
|
+
value: e.value,
|
|
1450
|
+
userSelectedDataType: p,
|
|
1451
|
+
treatAsField: n.treatComparisonValueAsField
|
|
1452
|
+
});
|
|
1453
|
+
i = `${a} ${e.comparison} ${y}`;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
return n.negationStrategy === "wrap-final" ? A(i, e, n.negationStrategy) : i;
|
|
1457
|
+
}
|
|
1458
|
+
function ur(e, r, t) {
|
|
1459
|
+
return P(e, r, t, {
|
|
1460
|
+
call: {
|
|
1461
|
+
expandArrayValueParameters: !0
|
|
1462
|
+
},
|
|
1463
|
+
treatComparisonValueAsField: e.valueIsField === !0,
|
|
1464
|
+
negationStrategy: "wrap-final"
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
function lr(e, r, t) {
|
|
1468
|
+
return e.functionName ? ur(e, r, t) : Ye(e, r);
|
|
1469
|
+
}
|
|
1470
|
+
function or(e, r, t) {
|
|
1471
|
+
return P(e, r, t, {
|
|
1472
|
+
negationStrategy: "boolean-only"
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
function pr(e, r, t) {
|
|
1476
|
+
if (!e.children || e.children.length === 0)
|
|
1477
|
+
return "";
|
|
1478
|
+
const n = e.children.map((s) => t(s, r)).filter((s) => s);
|
|
1479
|
+
if (n.length === 0)
|
|
1480
|
+
return "";
|
|
1481
|
+
const a = e.operator === "OR" ? " || " : " && ";
|
|
1482
|
+
if (e.isNegated)
|
|
1483
|
+
return `!(${n.join(a)})`;
|
|
1484
|
+
if (n.length === 1)
|
|
1485
|
+
return e.level > 0 ? `(${n[0]})` : n[0];
|
|
1486
|
+
{
|
|
1487
|
+
const s = n.join(a);
|
|
1488
|
+
return e.level > 0 ? `(${s})` : e.operator === "OR" && n.some((u) => u.includes(" && ")) ? `(${s})` : s;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
const v = (e, r) => {
|
|
1492
|
+
switch (e.type) {
|
|
1493
|
+
case "condition":
|
|
1494
|
+
return lr(e, r, v);
|
|
1495
|
+
case "function":
|
|
1496
|
+
return or(e, r, v);
|
|
1497
|
+
case "group":
|
|
1498
|
+
return pr(e, r, v);
|
|
1499
|
+
default:
|
|
1500
|
+
return "";
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
function cr(e, r) {
|
|
1504
|
+
if (e.length === 0)
|
|
1505
|
+
return "";
|
|
1506
|
+
const t = e.map((n) => v(n, r)).filter((n) => n);
|
|
1507
|
+
return t.length === 1 ? t[0] : t.join(" && ");
|
|
1508
|
+
}
|
|
1509
|
+
function yr(e) {
|
|
1510
|
+
return {
|
|
1511
|
+
input: e,
|
|
1512
|
+
position: 0,
|
|
1513
|
+
current: e[0] || ""
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
function c(e) {
|
|
1517
|
+
e.position += 1, e.current = e.input[e.position] || "";
|
|
1518
|
+
}
|
|
1519
|
+
function $(e, r = 1) {
|
|
1520
|
+
return e.input[e.position + r] || "";
|
|
1521
|
+
}
|
|
1522
|
+
function mr(e) {
|
|
1523
|
+
for (; e.current && /\s/.test(e.current); )
|
|
1524
|
+
c(e);
|
|
1525
|
+
}
|
|
1526
|
+
function dr(e, r) {
|
|
1527
|
+
return e.current === "(" || e.current === ")" ? (r.push({ type: "PAREN", value: e.current }), c(e), !0) : e.current === "[" || e.current === "]" ? (r.push({ type: "BRACKET", value: e.current }), c(e), !0) : e.current === "," ? (r.push({ type: "COMMA", value: e.current }), c(e), !0) : !1;
|
|
1528
|
+
}
|
|
1529
|
+
const fr = /* @__PURE__ */ new Set(["nil", "null", "true", "false"]);
|
|
1530
|
+
function gr(e) {
|
|
1531
|
+
return fr.has(e) ? { type: "KEYWORD", value: e } : e === "lambda" ? { type: "LAMBDA", value: e } : e === "end" ? { type: "END", value: e } : { type: "IDENTIFIER", value: e };
|
|
1532
|
+
}
|
|
1533
|
+
function vr(e, r) {
|
|
1534
|
+
let t = "";
|
|
1535
|
+
for (c(e); e.current && e.current !== r; )
|
|
1536
|
+
t += e.current, c(e);
|
|
1537
|
+
return e.current === r && c(e), t;
|
|
1538
|
+
}
|
|
1539
|
+
function Tr(e) {
|
|
1540
|
+
let r = "";
|
|
1541
|
+
for (; e.current && /[0-9.]/.test(e.current); )
|
|
1542
|
+
r += e.current, c(e);
|
|
1543
|
+
return r;
|
|
1544
|
+
}
|
|
1545
|
+
function br(e) {
|
|
1546
|
+
let r = "";
|
|
1547
|
+
for (; e.current && /[\w.]/.test(e.current); )
|
|
1548
|
+
r += e.current, c(e);
|
|
1549
|
+
return r;
|
|
1550
|
+
}
|
|
1551
|
+
function Nr(e, r) {
|
|
1552
|
+
if (e.current === '"' || e.current === "'") {
|
|
1553
|
+
const t = vr(e, e.current);
|
|
1554
|
+
return r.push({ type: "STRING", value: t }), !0;
|
|
1555
|
+
}
|
|
1556
|
+
if (/\d/.test(e.current)) {
|
|
1557
|
+
const t = Tr(e);
|
|
1558
|
+
return r.push({ type: "NUMBER", value: Number.parseFloat(t) }), !0;
|
|
1559
|
+
}
|
|
1560
|
+
if (/[a-z_]/i.test(e.current)) {
|
|
1561
|
+
const t = br(e);
|
|
1562
|
+
return r.push(gr(t)), !0;
|
|
1563
|
+
}
|
|
1564
|
+
return !1;
|
|
1565
|
+
}
|
|
1566
|
+
function hr(e, r, t) {
|
|
1567
|
+
if (`${e.current}${$(e)}` !== t)
|
|
1568
|
+
return !1;
|
|
1569
|
+
if (t === "&&" || t === "||")
|
|
1570
|
+
r.push({ type: "LOGICAL", value: t });
|
|
1571
|
+
else if (t === "!=" || t === "==" || t === ">=" || t === "<=")
|
|
1572
|
+
r.push({ type: "COMPARISON", value: t });
|
|
1573
|
+
else if (t === "->")
|
|
1574
|
+
r.push({ type: "ARROW", value: t });
|
|
1575
|
+
else
|
|
1576
|
+
return !1;
|
|
1577
|
+
return c(e), c(e), !0;
|
|
1578
|
+
}
|
|
1579
|
+
function Er(e, r) {
|
|
1580
|
+
const t = ["&&", "||", "!=", "==", ">=", "<=", "->"];
|
|
1581
|
+
for (const a of t)
|
|
1582
|
+
if (hr(e, r, a))
|
|
1583
|
+
return !0;
|
|
1584
|
+
const n = $(e);
|
|
1585
|
+
return e.current === "!" && n !== "=" && n !== "~" ? (r.push({ type: "UNARY", value: e.current }), c(e), !0) : !1;
|
|
1586
|
+
}
|
|
1587
|
+
function qr(e, r) {
|
|
1588
|
+
return e.current === ">" || e.current === "<" ? (r.push({ type: "COMPARISON", value: e.current }), c(e), !0) : e.current === "-" ? (r.push({ type: "OPERATOR", value: e.current }), c(e), !0) : !1;
|
|
1589
|
+
}
|
|
1590
|
+
function xr(e, r) {
|
|
1591
|
+
Nr(e, r) || Er(e, r) || dr(e, r) || qr(e, r) || c(e);
|
|
1592
|
+
}
|
|
1593
|
+
function Ir(e) {
|
|
1594
|
+
const r = [], t = yr(e);
|
|
1595
|
+
for (; t.position < e.length && (mr(t), !!t.current); )
|
|
1596
|
+
xr(t, r);
|
|
1597
|
+
return r;
|
|
1598
|
+
}
|
|
1599
|
+
const D = { type: "EOF", value: "" };
|
|
1600
|
+
function Sr(e) {
|
|
1601
|
+
return {
|
|
1602
|
+
position: 0,
|
|
1603
|
+
currentToken: e[0] || D,
|
|
1604
|
+
tokens: e
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
function o(e) {
|
|
1608
|
+
e.position += 1, e.currentToken = e.tokens[e.position] || D;
|
|
1609
|
+
}
|
|
1610
|
+
function Or(e) {
|
|
1611
|
+
if (e === "nil" || e === "null" || e === "true" || e === "false")
|
|
1612
|
+
return e;
|
|
1613
|
+
throw new Error(`Unsupported keyword literal: ${e}`);
|
|
1614
|
+
}
|
|
1615
|
+
function Cr(e) {
|
|
1616
|
+
if (e === "&&" || e === "||")
|
|
1617
|
+
return e;
|
|
1618
|
+
throw new Error(`Unsupported logical operator: ${e}`);
|
|
1619
|
+
}
|
|
1620
|
+
function _r() {
|
|
1621
|
+
return {
|
|
1622
|
+
type: "Literal",
|
|
1623
|
+
value: "nil",
|
|
1624
|
+
dataType: "keyword"
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
function Fr(e, r) {
|
|
1628
|
+
let t = r();
|
|
1629
|
+
for (; e.currentToken.type === "LOGICAL"; ) {
|
|
1630
|
+
const n = Cr(String(e.currentToken.value));
|
|
1631
|
+
o(e);
|
|
1632
|
+
const a = r();
|
|
1633
|
+
t = { type: "LogicalExpression", operator: n, left: t, right: a };
|
|
1634
|
+
}
|
|
1635
|
+
return t;
|
|
1636
|
+
}
|
|
1637
|
+
function Ar(e, r) {
|
|
1638
|
+
let t = r();
|
|
1639
|
+
for (; e.currentToken.type === "COMPARISON"; ) {
|
|
1640
|
+
const n = String(e.currentToken.value);
|
|
1641
|
+
o(e);
|
|
1642
|
+
const a = r();
|
|
1643
|
+
t = { type: "BinaryExpression", operator: n, left: t, right: a };
|
|
1644
|
+
}
|
|
1645
|
+
return t;
|
|
1646
|
+
}
|
|
1647
|
+
function j(e, r) {
|
|
1648
|
+
return e.currentToken.type === "UNARY" && e.currentToken.value === "!" ? (o(e), { type: "UnaryExpression", operator: "!", argument: j(e, r), prefix: !0 }) : r();
|
|
1649
|
+
}
|
|
1650
|
+
function Rr(e, r) {
|
|
1651
|
+
o(e);
|
|
1652
|
+
const t = r.parseLogical();
|
|
1653
|
+
return e.currentToken.type === "PAREN" && e.currentToken.value === ")" && o(e), { type: "GroupExpression", expression: t };
|
|
1654
|
+
}
|
|
1655
|
+
function Lr(e, r) {
|
|
1656
|
+
const t = [];
|
|
1657
|
+
for (; e.currentToken.type !== "EOF" && !(e.currentToken.type === "PAREN" && e.currentToken.value === ")"); ) {
|
|
1658
|
+
if (t.length > 0)
|
|
1659
|
+
if (e.currentToken.type === "COMMA")
|
|
1660
|
+
o(e);
|
|
1661
|
+
else
|
|
1662
|
+
break;
|
|
1663
|
+
const n = r.parseLogical();
|
|
1664
|
+
t.push(n);
|
|
1665
|
+
}
|
|
1666
|
+
return e.currentToken.type === "PAREN" && e.currentToken.value === ")" && o(e), t;
|
|
1667
|
+
}
|
|
1668
|
+
function Ur(e, r, t) {
|
|
1669
|
+
let n = { type: "Identifier", name: t };
|
|
1670
|
+
for (; e.currentToken.type === "BRACKET" && e.currentToken.value === "["; ) {
|
|
1671
|
+
o(e);
|
|
1672
|
+
const a = r.parseLogical();
|
|
1673
|
+
e.currentToken.type === "BRACKET" && e.currentToken.value === "]" && o(e), n = {
|
|
1674
|
+
type: "MemberExpression",
|
|
1675
|
+
object: n,
|
|
1676
|
+
property: a,
|
|
1677
|
+
computed: !0
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
return n;
|
|
1681
|
+
}
|
|
1682
|
+
function kr(e, r) {
|
|
1683
|
+
const t = String(e.currentToken.value);
|
|
1684
|
+
return o(e), e.currentToken.type === "PAREN" && e.currentToken.value === "(" ? (o(e), {
|
|
1685
|
+
type: "CallExpression",
|
|
1686
|
+
callee: { type: "Identifier", name: t },
|
|
1687
|
+
arguments: Lr(e, r)
|
|
1688
|
+
}) : Ur(e, r, t);
|
|
1689
|
+
}
|
|
1690
|
+
function Mr(e) {
|
|
1691
|
+
if (e.currentToken.type === "STRING") {
|
|
1692
|
+
const r = String(e.currentToken.value);
|
|
1693
|
+
return o(e), { type: "Literal", value: r, dataType: "string" };
|
|
1694
|
+
}
|
|
1695
|
+
if (e.currentToken.type === "KEYWORD") {
|
|
1696
|
+
const r = Or(String(e.currentToken.value));
|
|
1697
|
+
return o(e), { type: "Literal", value: r, dataType: "keyword" };
|
|
1698
|
+
}
|
|
1699
|
+
if (e.currentToken.type === "NUMBER") {
|
|
1700
|
+
const r = Number(e.currentToken.value);
|
|
1701
|
+
return o(e), { type: "Literal", value: r, dataType: "number" };
|
|
1702
|
+
}
|
|
1703
|
+
return null;
|
|
1704
|
+
}
|
|
1705
|
+
function Pr(e, r) {
|
|
1706
|
+
if (e.currentToken.type === "LAMBDA")
|
|
1707
|
+
return r.parseLambda();
|
|
1708
|
+
if (e.currentToken.type === "PAREN" && e.currentToken.value === "(")
|
|
1709
|
+
return Rr(e, r);
|
|
1710
|
+
if (e.currentToken.type === "IDENTIFIER")
|
|
1711
|
+
return kr(e, r);
|
|
1712
|
+
const t = Mr(e);
|
|
1713
|
+
if (t)
|
|
1714
|
+
return t;
|
|
1715
|
+
throw new Error(`Unexpected token: ${e.currentToken.type} (${e.currentToken.value})`);
|
|
1716
|
+
}
|
|
1717
|
+
function $r(e, r) {
|
|
1718
|
+
const t = [];
|
|
1719
|
+
for (; e.currentToken.type !== "EOF" && e.currentToken.type !== "END"; ) {
|
|
1720
|
+
const n = r.parseLogical();
|
|
1721
|
+
if (t.push(n), e.currentToken.type === "COMMA")
|
|
1722
|
+
o(e);
|
|
1723
|
+
else
|
|
1724
|
+
break;
|
|
1725
|
+
}
|
|
1726
|
+
if (t.length === 1)
|
|
1727
|
+
return t[0];
|
|
1728
|
+
if (t.length > 1) {
|
|
1729
|
+
const [n, ...a] = t;
|
|
1730
|
+
return a.reduce((s, i) => ({
|
|
1731
|
+
type: "LogicalExpression",
|
|
1732
|
+
operator: "&&",
|
|
1733
|
+
left: s,
|
|
1734
|
+
right: i
|
|
1735
|
+
}), n);
|
|
1736
|
+
}
|
|
1737
|
+
return _r();
|
|
1738
|
+
}
|
|
1739
|
+
function Dr(e, r) {
|
|
1740
|
+
o(e), e.currentToken.type === "PAREN" && e.currentToken.value === "(" && o(e);
|
|
1741
|
+
const t = [];
|
|
1742
|
+
for (; e.currentToken.type !== "EOF" && !(e.currentToken.type === "PAREN" && e.currentToken.value === ")"); ) {
|
|
1743
|
+
if (t.length > 0)
|
|
1744
|
+
if (e.currentToken.type === "COMMA")
|
|
1745
|
+
o(e);
|
|
1746
|
+
else
|
|
1747
|
+
break;
|
|
1748
|
+
if (e.currentToken.type === "IDENTIFIER")
|
|
1749
|
+
t.push({ type: "Identifier", name: String(e.currentToken.value) }), o(e);
|
|
1750
|
+
else
|
|
1751
|
+
break;
|
|
1752
|
+
}
|
|
1753
|
+
e.currentToken.type === "PAREN" && e.currentToken.value === ")" && o(e), e.currentToken.type === "ARROW" && o(e);
|
|
1754
|
+
const n = $r(e, r);
|
|
1755
|
+
return e.currentToken.type === "END" && o(e), {
|
|
1756
|
+
type: "LambdaExpression",
|
|
1757
|
+
parameters: t,
|
|
1758
|
+
body: n
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
function jr(e) {
|
|
1762
|
+
const r = Sr(e);
|
|
1763
|
+
function t() {
|
|
1764
|
+
return Fr(r, n);
|
|
1765
|
+
}
|
|
1766
|
+
function n() {
|
|
1767
|
+
return Ar(r, a);
|
|
1768
|
+
}
|
|
1769
|
+
function a() {
|
|
1770
|
+
return j(r, s);
|
|
1771
|
+
}
|
|
1772
|
+
function s() {
|
|
1773
|
+
return Pr(r, { parseLogical: t, parseLambda: i });
|
|
1774
|
+
}
|
|
1775
|
+
function i() {
|
|
1776
|
+
return Dr(r, { parseLogical: t });
|
|
1777
|
+
}
|
|
1778
|
+
return {
|
|
1779
|
+
ast: t(),
|
|
1780
|
+
position: r.position
|
|
1781
|
+
};
|
|
1782
|
+
}
|
|
1783
|
+
function w(e) {
|
|
1784
|
+
throw new Error(`Unsupported AST node type: ${JSON.stringify(e)}`);
|
|
1785
|
+
}
|
|
1786
|
+
function S(e) {
|
|
1787
|
+
if (e.type === "MemberExpression") {
|
|
1788
|
+
const r = e.object.type === "Identifier" ? e.object.name : S(e.object), t = m(e.property);
|
|
1789
|
+
return `${r}[${t}]`;
|
|
1790
|
+
}
|
|
1791
|
+
return e.type === "Identifier" ? e.name : w(e);
|
|
1792
|
+
}
|
|
1793
|
+
function m(e) {
|
|
1794
|
+
switch (e.type) {
|
|
1795
|
+
case "CallExpression": {
|
|
1796
|
+
const r = e.callee.name, t = e.arguments.map((n) => m(n));
|
|
1797
|
+
return `${r}(${t.join(", ")})`;
|
|
1798
|
+
}
|
|
1799
|
+
case "Identifier":
|
|
1800
|
+
return e.name;
|
|
1801
|
+
case "MemberExpression":
|
|
1802
|
+
return S(e);
|
|
1803
|
+
case "Literal":
|
|
1804
|
+
return e.dataType === "string" ? `"${e.value}"` : String(e.value);
|
|
1805
|
+
case "BinaryExpression": {
|
|
1806
|
+
const r = m(e.left), t = m(e.right);
|
|
1807
|
+
return `${r} ${e.operator} ${t}`;
|
|
1808
|
+
}
|
|
1809
|
+
case "LogicalExpression": {
|
|
1810
|
+
const r = m(e.left), t = m(e.right);
|
|
1811
|
+
return `${r} ${e.operator} ${t}`;
|
|
1812
|
+
}
|
|
1813
|
+
case "UnaryExpression": {
|
|
1814
|
+
const r = m(e.argument);
|
|
1815
|
+
return `${e.operator}${r}`;
|
|
1816
|
+
}
|
|
1817
|
+
case "GroupExpression":
|
|
1818
|
+
return `(${m(e.expression)})`;
|
|
1819
|
+
case "LambdaExpression": {
|
|
1820
|
+
const r = e.parameters.map((n) => n.name).join(", "), t = m(e.body);
|
|
1821
|
+
return `lambda(${r}) -> ${t} end`;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
return w(e);
|
|
1825
|
+
}
|
|
1826
|
+
function O(e) {
|
|
1827
|
+
return e !== null;
|
|
1828
|
+
}
|
|
1829
|
+
function z(e) {
|
|
1830
|
+
return e.dataType === "number" ? "number" : e.dataType === "keyword" && (e.value === "true" || e.value === "false") ? "boolean" : "string";
|
|
1831
|
+
}
|
|
1832
|
+
function b(e) {
|
|
1833
|
+
return e.type === "Literal" && e.dataType === "keyword" && (e.value === "nil" || e.value === "null");
|
|
1834
|
+
}
|
|
1835
|
+
function W(e, r) {
|
|
1836
|
+
return e.type === "Literal" && e.value === "" && (r === "==" || r === "!=");
|
|
1837
|
+
}
|
|
1838
|
+
function N(e, r, t, n) {
|
|
1839
|
+
const a = e.parameterDataTypes.get(r) || /* @__PURE__ */ new Map();
|
|
1840
|
+
a.set(t, n), e.parameterDataTypes.set(r, a);
|
|
1841
|
+
}
|
|
1842
|
+
function d(e) {
|
|
1843
|
+
if (e.type === "Identifier")
|
|
1844
|
+
return e.name;
|
|
1845
|
+
if (e.type === "MemberExpression")
|
|
1846
|
+
return S(e);
|
|
1847
|
+
if (e.type === "Literal")
|
|
1848
|
+
return String(e.value);
|
|
1849
|
+
}
|
|
1850
|
+
function C(e) {
|
|
1851
|
+
return e.type === "Literal" ? e.value : e.type === "Identifier" ? e.name : null;
|
|
1852
|
+
}
|
|
1853
|
+
function wr(e) {
|
|
1854
|
+
if (e.left.type !== "CallExpression" || e.left.callee.name !== "seq.some" || e.left.arguments.length !== 2)
|
|
1855
|
+
return !1;
|
|
1856
|
+
const r = e.left.arguments[1];
|
|
1857
|
+
if (r.type !== "LambdaExpression")
|
|
1858
|
+
return !1;
|
|
1859
|
+
const t = r.body;
|
|
1860
|
+
if (!(t.type === "CallExpression" && t.callee.name === "include" && t.arguments.length === 2))
|
|
1861
|
+
return !1;
|
|
1862
|
+
const n = t.arguments[0];
|
|
1863
|
+
return n.type === "CallExpression" && n.callee.name === "seq.list";
|
|
1864
|
+
}
|
|
1865
|
+
function zr(e) {
|
|
1866
|
+
const { node: r, level: t, parentId: n, convert: a } = e;
|
|
1867
|
+
if (!wr(r))
|
|
1868
|
+
return null;
|
|
1869
|
+
const s = a(r.left, t, n);
|
|
1870
|
+
return b(r.right) && r.operator === "==" && (s.isNegated = !0), s;
|
|
1871
|
+
}
|
|
1872
|
+
const Wr = {
|
|
1873
|
+
name: "belong-nil-comparison",
|
|
1874
|
+
priority: 100,
|
|
1875
|
+
handler: zr
|
|
1876
|
+
};
|
|
1877
|
+
function Br(e) {
|
|
1878
|
+
const { node: r, level: t, parentId: n, convert: a } = e;
|
|
1879
|
+
if (r.left.type !== "CallExpression")
|
|
1880
|
+
return null;
|
|
1881
|
+
if ((/* @__PURE__ */ new Set(["string.contains", "string.startsWith", "string.endsWith"])).has(r.left.callee.name))
|
|
1882
|
+
return a(r.left, t, n);
|
|
1883
|
+
if (r.left.callee.name === "string.match") {
|
|
1884
|
+
const i = a(r.left, t, n);
|
|
1885
|
+
return i.comparison = "match", b(r.right) && r.operator === "==" && (i.isNegated = !0), i;
|
|
1886
|
+
}
|
|
1887
|
+
return null;
|
|
1888
|
+
}
|
|
1889
|
+
const Vr = {
|
|
1890
|
+
name: "string-condition-comparison",
|
|
1891
|
+
priority: 90,
|
|
1892
|
+
handler: Br
|
|
1893
|
+
};
|
|
1894
|
+
function B(e) {
|
|
1895
|
+
const r = e.map((t, n) => ({
|
|
1896
|
+
name: t.name,
|
|
1897
|
+
priority: t.priority ?? 0,
|
|
1898
|
+
order: n,
|
|
1899
|
+
handler: t.handler
|
|
1900
|
+
}));
|
|
1901
|
+
return r.sort((t, n) => t.priority !== n.priority ? n.priority - t.priority : t.order - n.order), {
|
|
1902
|
+
rules: Object.freeze(r)
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
function V(e, r) {
|
|
1906
|
+
for (const t of e.rules) {
|
|
1907
|
+
const n = t.handler(r);
|
|
1908
|
+
if (n)
|
|
1909
|
+
return n;
|
|
1910
|
+
}
|
|
1911
|
+
return null;
|
|
1912
|
+
}
|
|
1913
|
+
const Gr = B([
|
|
1914
|
+
Wr,
|
|
1915
|
+
Vr
|
|
1916
|
+
]);
|
|
1917
|
+
function Hr(e) {
|
|
1918
|
+
const { node: r, level: t, parentId: n, context: a } = e, s = g(n, t);
|
|
1919
|
+
if (r.left.type === "Identifier" || r.left.type === "MemberExpression") {
|
|
1920
|
+
const i = d(r.left);
|
|
1921
|
+
s.field = i, i && (s.fieldType = a.getFieldTypeForNode(i));
|
|
1922
|
+
}
|
|
1923
|
+
return r.right.type === "Literal" ? b(r.right) ? (s.comparison = `${r.operator} nil`, s.value = void 0) : W(r.right, r.operator) ? (s.comparison = `${r.operator} ''`, s.value = void 0) : (s.comparison = r.operator, s.value = r.right.value, s.valueIsLiteral = !0, N(a, s.id, "condition_value", z(r.right))) : r.right.type === "Identifier" || r.right.type === "MemberExpression" ? (s.comparison = r.operator, s.value = d(r.right), s.valueIsField = !0) : (s.comparison = r.operator, s.value = void 0), s;
|
|
1924
|
+
}
|
|
1925
|
+
function Yr(e) {
|
|
1926
|
+
const { node: r, level: t, parentId: n, context: a, convert: s } = e;
|
|
1927
|
+
if (r.left.type !== "CallExpression")
|
|
1928
|
+
return null;
|
|
1929
|
+
const i = s(r.left, t, n);
|
|
1930
|
+
return i.comparison = r.operator, r.right.type === "Literal" ? b(r.right) ? (i.comparison = `${r.operator} nil`, i.value = void 0) : W(r.right, r.operator) ? (i.comparison = `${r.operator} ''`, i.value = void 0) : (i.value = r.right.value, N(
|
|
1931
|
+
a,
|
|
1932
|
+
i.id,
|
|
1933
|
+
i.functionName || "condition_value",
|
|
1934
|
+
z(r.right)
|
|
1935
|
+
)) : (r.right.type === "Identifier" || r.right.type === "MemberExpression") && (i.value = d(r.right), i.valueIsField = !0), i;
|
|
1936
|
+
}
|
|
1937
|
+
function Kr(e) {
|
|
1938
|
+
const r = V(Gr, e);
|
|
1939
|
+
if (r)
|
|
1940
|
+
return r;
|
|
1941
|
+
const t = Yr(e);
|
|
1942
|
+
return t || Hr(e);
|
|
1943
|
+
}
|
|
1944
|
+
function h(e, r, t) {
|
|
1945
|
+
e.value = r, e.isNested = !1, e.type = t;
|
|
1946
|
+
}
|
|
1947
|
+
function Qr(e) {
|
|
1948
|
+
const { arg: r, index: t, parameters: n } = e;
|
|
1949
|
+
return r.type !== "Identifier" ? !1 : (h(n[t], r.name, "field"), !0);
|
|
1950
|
+
}
|
|
1951
|
+
function Jr(e) {
|
|
1952
|
+
const { arg: r, index: t, parameters: n } = e;
|
|
1953
|
+
return r.type !== "LambdaExpression" ? !1 : (h(n[t], m(r), "lambda"), !0);
|
|
1954
|
+
}
|
|
1955
|
+
function Xr(e) {
|
|
1956
|
+
const { arg: r, index: t, parameters: n } = e;
|
|
1957
|
+
return r.type !== "Literal" ? !1 : (h(n[t], r.value, "value"), !0);
|
|
1958
|
+
}
|
|
1959
|
+
function Zr(e) {
|
|
1960
|
+
const { arg: r, index: t, parameters: n } = e;
|
|
1961
|
+
return r.type !== "MemberExpression" ? !1 : (h(n[t], d(r), "field"), !0);
|
|
1962
|
+
}
|
|
1963
|
+
function et(e, r) {
|
|
1964
|
+
return e === "any" || r === e || e === "list" && r === "list" || e === "array" && r === "list" || e === "list" && r === "array";
|
|
1965
|
+
}
|
|
1966
|
+
function rt(e) {
|
|
1967
|
+
const { arg: r, index: t, functionNode: n, options: a, parameters: s } = e, i = a.convert(r, a.level + 1, n.id);
|
|
1968
|
+
if (i.type === "condition" && i.functionName) {
|
|
1969
|
+
const u = f.find((y) => y.name === i.functionName), l = u == null ? void 0 : u.returnType, p = s[t].valueType;
|
|
1970
|
+
et(p, l) && (i.comparison = void 0, i.value = void 0), s[t].type = "condition";
|
|
1971
|
+
} else
|
|
1972
|
+
i.type === "condition" && (i.comparison = void 0, i.value = void 0, s[t].type = "condition");
|
|
1973
|
+
return s[t].nestedNode = i, s[t].isNested = !0, s[t].value = void 0, !0;
|
|
1974
|
+
}
|
|
1975
|
+
const tt = [
|
|
1976
|
+
Xr,
|
|
1977
|
+
Qr,
|
|
1978
|
+
Zr,
|
|
1979
|
+
Jr,
|
|
1980
|
+
rt
|
|
1981
|
+
];
|
|
1982
|
+
function nt(e) {
|
|
1983
|
+
for (const r of tt)
|
|
1984
|
+
if (r(e))
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1987
|
+
function at(e) {
|
|
1988
|
+
const { node: r, level: t, parentId: n } = e, a = g(n, t);
|
|
1989
|
+
a.functionName = r.callee.name, delete a.field;
|
|
1990
|
+
const s = f.find((l) => l.name === r.callee.name);
|
|
1991
|
+
if (!s)
|
|
1992
|
+
return a;
|
|
1993
|
+
a.functionCategory = s.category;
|
|
1994
|
+
const i = s.parameters.map((l) => ({
|
|
1995
|
+
...l,
|
|
1996
|
+
value: void 0,
|
|
1997
|
+
type: Le(s.name, l.name, l.description) ? "lambda" : l.type
|
|
1998
|
+
}));
|
|
1999
|
+
return i.length === 1 && (i[0].name === "items" || i[0].description.includes("多个") || i[0].description.includes("列表")) && r.arguments.length > 1 ? (i[0].value = r.arguments.map((l) => C(l)).filter(O), i[0].isNested = !1, i[0].type = "value", a.comparison = void 0, a.value = void 0) : r.arguments.forEach((l, p) => {
|
|
2000
|
+
p >= i.length || nt({
|
|
2001
|
+
arg: l,
|
|
2002
|
+
index: p,
|
|
2003
|
+
functionNode: a,
|
|
2004
|
+
options: e,
|
|
2005
|
+
parameters: i
|
|
2006
|
+
});
|
|
2007
|
+
}), a.parameters = i, s.returnType === "boolean" ? (a.comparison = void 0, a.value = void 0) : a.comparison !== void 0 && (a.comparison = "==", a.value = ""), a;
|
|
2008
|
+
}
|
|
2009
|
+
function T(e, r, t) {
|
|
2010
|
+
r && (e.field = d(r), e.field && (e.fieldType = t.context.getFieldTypeForNode(e.field)));
|
|
2011
|
+
}
|
|
2012
|
+
function it(e, r) {
|
|
2013
|
+
return e !== "string" ? e : r.dataType === "number" ? "number" : r.dataType === "keyword" && (r.value === "true" || r.value === "false") ? "boolean" : "string";
|
|
2014
|
+
}
|
|
2015
|
+
function st(e) {
|
|
2016
|
+
const { node: r, level: t, parentId: n, context: a } = e;
|
|
2017
|
+
if (r.callee.name !== "seq.some" || r.arguments.length !== 2)
|
|
2018
|
+
return null;
|
|
2019
|
+
const s = r.arguments[1];
|
|
2020
|
+
if (s.type !== "LambdaExpression")
|
|
2021
|
+
return null;
|
|
2022
|
+
const i = s.body;
|
|
2023
|
+
if (!(i.type === "CallExpression" && i.callee.name === "include" && i.arguments.length === 2))
|
|
2024
|
+
return null;
|
|
2025
|
+
const u = i.arguments[0];
|
|
2026
|
+
if (!(u.type === "CallExpression" && u.callee.name === "seq.list"))
|
|
2027
|
+
return null;
|
|
2028
|
+
const l = g(n, t);
|
|
2029
|
+
l.comparison = "belong", T(l, r.arguments[0], e);
|
|
2030
|
+
let p = "string";
|
|
2031
|
+
const y = u.arguments.map((E) => (E.type === "Literal" && (p = it(p, E)), C(E))).filter(O);
|
|
2032
|
+
return l.value = y, N(a, l.id, "condition_value", p), l;
|
|
2033
|
+
}
|
|
2034
|
+
const ut = {
|
|
2035
|
+
name: "belong-call",
|
|
2036
|
+
priority: 100,
|
|
2037
|
+
handler: st
|
|
2038
|
+
};
|
|
2039
|
+
function lt(e) {
|
|
2040
|
+
const { node: r, level: t, parentId: n, context: a } = e;
|
|
2041
|
+
if (r.callee.name !== "IPScene.isIpInNetmaskList" || r.arguments.length !== 2)
|
|
2042
|
+
return null;
|
|
2043
|
+
const s = r.arguments[1];
|
|
2044
|
+
if (!(s.type === "CallExpression" && s.callee.name === "seq.list"))
|
|
2045
|
+
return null;
|
|
2046
|
+
const i = g(n, t);
|
|
2047
|
+
i.comparison = "isIpInNetmaskList", T(i, r.arguments[0], e);
|
|
2048
|
+
let u = "string";
|
|
2049
|
+
const l = s.arguments.map((p) => (p.type === "Literal" && (p.dataType === "string" || typeof p.value == "string") && (u = "string"), C(p))).filter(O);
|
|
2050
|
+
return i.value = l, N(a, i.id, "condition_value", u), i;
|
|
2051
|
+
}
|
|
2052
|
+
const ot = {
|
|
2053
|
+
name: "ip-in-netmask-call",
|
|
2054
|
+
priority: 110,
|
|
2055
|
+
handler: lt
|
|
2056
|
+
};
|
|
2057
|
+
function pt(e) {
|
|
2058
|
+
const { node: r, level: t, parentId: n } = e, s = {
|
|
2059
|
+
"string.contains": "contains",
|
|
2060
|
+
"string.startsWith": "startsWith",
|
|
2061
|
+
"string.endsWith": "endsWith",
|
|
2062
|
+
"string.match": "match"
|
|
2063
|
+
}[r.callee.name];
|
|
2064
|
+
if (!s)
|
|
2065
|
+
return null;
|
|
2066
|
+
const i = g(n, t);
|
|
2067
|
+
if (i.comparison = s, r.callee.name === "string.match") {
|
|
2068
|
+
T(i, r.arguments[1], e);
|
|
2069
|
+
const l = r.arguments[0];
|
|
2070
|
+
return l && (l.type === "Literal" ? (i.value = l.value, i.valueIsLiteral = !0) : (l.type === "Identifier" || l.type === "MemberExpression") && (i.value = d(l))), i;
|
|
2071
|
+
}
|
|
2072
|
+
T(i, r.arguments[0], e);
|
|
2073
|
+
const u = r.arguments[1];
|
|
2074
|
+
return (u == null ? void 0 : u.type) === "Literal" ? (i.value = u.value, i.valueIsLiteral = !0) : u && (u.type === "Identifier" || u.type === "MemberExpression") && (i.value = d(u)), i;
|
|
2075
|
+
}
|
|
2076
|
+
const ct = {
|
|
2077
|
+
name: "string-condition-call",
|
|
2078
|
+
priority: 90,
|
|
2079
|
+
handler: pt
|
|
2080
|
+
}, yt = B([
|
|
2081
|
+
ot,
|
|
2082
|
+
ut,
|
|
2083
|
+
ct
|
|
2084
|
+
]);
|
|
2085
|
+
function mt(e) {
|
|
2086
|
+
const r = V(yt, e);
|
|
2087
|
+
return r || at(e);
|
|
2088
|
+
}
|
|
2089
|
+
function x(e, r) {
|
|
2090
|
+
return e.type === "LogicalExpression" && e.operator === r ? [
|
|
2091
|
+
...x(e.left, r),
|
|
2092
|
+
...x(e.right, r)
|
|
2093
|
+
] : [e];
|
|
2094
|
+
}
|
|
2095
|
+
function dt(e, r) {
|
|
2096
|
+
const t = (a, s = 0, i) => {
|
|
2097
|
+
switch (a.type) {
|
|
2098
|
+
case "LogicalExpression": {
|
|
2099
|
+
const u = _(i, s);
|
|
2100
|
+
u.operator = a.operator === "&&" ? "AND" : "OR";
|
|
2101
|
+
const l = x(a, a.operator);
|
|
2102
|
+
return u.children = l.map((p) => t(p, s + 1, u.id)), u;
|
|
2103
|
+
}
|
|
2104
|
+
case "BinaryExpression":
|
|
2105
|
+
return Kr({
|
|
2106
|
+
node: a,
|
|
2107
|
+
level: s,
|
|
2108
|
+
parentId: i,
|
|
2109
|
+
context: r,
|
|
2110
|
+
convert: t
|
|
2111
|
+
});
|
|
2112
|
+
case "UnaryExpression": {
|
|
2113
|
+
const u = t(a.argument, s, i);
|
|
2114
|
+
return u.isNegated = !0, u;
|
|
2115
|
+
}
|
|
2116
|
+
case "CallExpression":
|
|
2117
|
+
return mt({
|
|
2118
|
+
node: a,
|
|
2119
|
+
level: s,
|
|
2120
|
+
parentId: i,
|
|
2121
|
+
context: r,
|
|
2122
|
+
convert: t
|
|
2123
|
+
});
|
|
2124
|
+
case "GroupExpression":
|
|
2125
|
+
return t(a.expression, s, i);
|
|
2126
|
+
default:
|
|
2127
|
+
throw new Error(`Unsupported AST node type: ${a.type}`);
|
|
2128
|
+
}
|
|
2129
|
+
}, n = t(e, 0);
|
|
2130
|
+
if (n.type !== "group") {
|
|
2131
|
+
const a = _(void 0, 0);
|
|
2132
|
+
return a.operator = "AND", a.children = [n], n.parentId = a.id, n.level = 1, [a];
|
|
2133
|
+
}
|
|
2134
|
+
return [n];
|
|
2135
|
+
}
|
|
2136
|
+
function ft(e, r) {
|
|
2137
|
+
return G(e, r).nodes;
|
|
2138
|
+
}
|
|
2139
|
+
function G(e, r) {
|
|
2140
|
+
try {
|
|
2141
|
+
const t = Ir(e), n = jr(t);
|
|
2142
|
+
if (n.position < t.length) {
|
|
2143
|
+
const s = t.slice(n.position);
|
|
2144
|
+
throw new Error(`无法解析 '${s.map((i) => i.value).join(" ")}'`);
|
|
2145
|
+
}
|
|
2146
|
+
return { success: !0, nodes: dt(n.ast, r) };
|
|
2147
|
+
} catch (t) {
|
|
2148
|
+
const n = t instanceof Error ? t.message : "未知错误";
|
|
2149
|
+
return {
|
|
2150
|
+
success: !1,
|
|
2151
|
+
nodes: [],
|
|
2152
|
+
error: `表达式解析失败,${n}`
|
|
2153
|
+
};
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
const gt = /* @__PURE__ */ new Set(["== nil", "!= nil", "== ''", "!= ''"]);
|
|
2157
|
+
function H(e) {
|
|
2158
|
+
return e !== void 0 && e !== "";
|
|
2159
|
+
}
|
|
2160
|
+
function vt(e) {
|
|
2161
|
+
if (!e)
|
|
2162
|
+
return !1;
|
|
2163
|
+
const r = e.value !== void 0 && e.value !== "", t = !!(e.isNested && e.nestedNode);
|
|
2164
|
+
return r || t;
|
|
2165
|
+
}
|
|
2166
|
+
function Y(e) {
|
|
2167
|
+
return !gt.has(e);
|
|
2168
|
+
}
|
|
2169
|
+
function Tt(e, r) {
|
|
2170
|
+
if (e.field || r.push({ nodeId: e.id, message: "条件节点缺少字段选择" }), !e.comparison) {
|
|
2171
|
+
r.push({ nodeId: e.id, message: "条件节点缺少比较操作符" });
|
|
2172
|
+
return;
|
|
2173
|
+
}
|
|
2174
|
+
Y(e.comparison) && !H(e.value) && r.push({ nodeId: e.id, message: "条件节点缺少比较值" });
|
|
2175
|
+
}
|
|
2176
|
+
function bt() {
|
|
2177
|
+
return new Map(f.map((e) => [e.name, e]));
|
|
2178
|
+
}
|
|
2179
|
+
function R(e, r, t, n = {}) {
|
|
2180
|
+
if (n.requireFunctionName && !e.functionName) {
|
|
2181
|
+
r.push({ nodeId: e.id, message: "函数节点缺少函数选择" });
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
if (!e.functionName)
|
|
2185
|
+
return;
|
|
2186
|
+
const a = t.get(e.functionName);
|
|
2187
|
+
if (a && (a.parameters.forEach((s) => {
|
|
2188
|
+
var i;
|
|
2189
|
+
if (s.required) {
|
|
2190
|
+
const u = (i = e.parameters) == null ? void 0 : i.find((l) => l.name === s.name);
|
|
2191
|
+
vt(u) || r.push({
|
|
2192
|
+
nodeId: e.id,
|
|
2193
|
+
message: `函数 ${a.displayName} 缺少必填参数: ${s.description}`
|
|
2194
|
+
});
|
|
2195
|
+
}
|
|
2196
|
+
}), a.returnType !== "boolean")) {
|
|
2197
|
+
if (!e.comparison) {
|
|
2198
|
+
r.push({ nodeId: e.id, message: `函数 ${a.displayName} 缺少比较操作符` });
|
|
2199
|
+
return;
|
|
2200
|
+
}
|
|
2201
|
+
Y(e.comparison) && !H(e.value) && r.push({ nodeId: e.id, message: `函数 ${a.displayName} 缺少比较值` });
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
function Nt(e, r, t) {
|
|
2205
|
+
var n;
|
|
2206
|
+
if (e.expanded && (!e.children || e.children.length === 0)) {
|
|
2207
|
+
r.push({ nodeId: e.id, message: "分组节点为空,请添加子条件" });
|
|
2208
|
+
return;
|
|
2209
|
+
}
|
|
2210
|
+
(n = e.children) == null || n.forEach(t);
|
|
2211
|
+
}
|
|
2212
|
+
function ht(e) {
|
|
2213
|
+
const r = [], t = bt(), n = (a) => {
|
|
2214
|
+
if (a.type === "group") {
|
|
2215
|
+
Nt(
|
|
2216
|
+
{
|
|
2217
|
+
id: a.id,
|
|
2218
|
+
expanded: a.expanded,
|
|
2219
|
+
children: a.children
|
|
2220
|
+
},
|
|
2221
|
+
r,
|
|
2222
|
+
n
|
|
2223
|
+
);
|
|
2224
|
+
return;
|
|
2225
|
+
}
|
|
2226
|
+
if (a.type === "condition") {
|
|
2227
|
+
a.functionName ? R(a, r, t) : Tt(a, r);
|
|
2228
|
+
return;
|
|
2229
|
+
}
|
|
2230
|
+
a.type === "function" && R(a, r, t, { requireFunctionName: !0 });
|
|
2231
|
+
};
|
|
2232
|
+
return e.forEach((a) => n(a)), r;
|
|
2233
|
+
}
|
|
2234
|
+
class Et {
|
|
2235
|
+
parse(r, t) {
|
|
2236
|
+
return ft(r, {
|
|
2237
|
+
availableFields: t.availableFields,
|
|
2238
|
+
parameterDataTypes: t.parameterDataTypes,
|
|
2239
|
+
getFieldTypeForNode: t.getFieldTypeForNode
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
generate(r, t) {
|
|
2243
|
+
return cr(r, {
|
|
2244
|
+
availableFields: t.availableFields,
|
|
2245
|
+
parameterDataTypes: t.parameterDataTypes
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
validate(r) {
|
|
2249
|
+
return ht(r);
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
function qt(e, r) {
|
|
2253
|
+
return r || ((t) => {
|
|
2254
|
+
const n = e().find((a) => a.value === t);
|
|
2255
|
+
return (n == null ? void 0 : n.type) || "string";
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
function xt(e) {
|
|
2259
|
+
let r = [...e || []];
|
|
2260
|
+
return {
|
|
2261
|
+
getAvailableFields: () => r,
|
|
2262
|
+
setAvailableFields: (t) => {
|
|
2263
|
+
r = [...t || []];
|
|
2264
|
+
}
|
|
2265
|
+
};
|
|
2266
|
+
}
|
|
2267
|
+
function It() {
|
|
2268
|
+
const e = /* @__PURE__ */ new Map();
|
|
2269
|
+
return {
|
|
2270
|
+
parameterDataTypes: e,
|
|
2271
|
+
getParameterDataTypes: () => e,
|
|
2272
|
+
setParameterDataType: (r, t, n) => {
|
|
2273
|
+
const a = e.get(r) || /* @__PURE__ */ new Map();
|
|
2274
|
+
a.set(t, n), e.set(r, a);
|
|
2275
|
+
},
|
|
2276
|
+
clearParameterDataTypes: () => {
|
|
2277
|
+
e.clear();
|
|
2278
|
+
}
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2281
|
+
function St(e) {
|
|
2282
|
+
return !e || !e.trim();
|
|
2283
|
+
}
|
|
2284
|
+
function _t(e) {
|
|
2285
|
+
const r = e.engine || new Et(), t = xt(e.availableFields || []), n = It(), a = qt(t.getAvailableFields, e.getFieldTypeForNode), s = () => ({
|
|
2286
|
+
availableFields: t.getAvailableFields(),
|
|
2287
|
+
parameterDataTypes: n.parameterDataTypes,
|
|
2288
|
+
getFieldTypeForNode: a
|
|
2289
|
+
}), i = (y) => St(y) ? { success: !0, nodes: [] } : G(y, s());
|
|
2290
|
+
return {
|
|
2291
|
+
parseDetailed: i,
|
|
2292
|
+
parse: (y) => i(y).nodes,
|
|
2293
|
+
generate: (y) => r.generate(y, s()),
|
|
2294
|
+
validate: (y) => r.validate(y),
|
|
2295
|
+
getAvailableFields: t.getAvailableFields,
|
|
2296
|
+
setAvailableFields: t.setAvailableFields,
|
|
2297
|
+
getParameterDataTypes: n.getParameterDataTypes,
|
|
2298
|
+
setParameterDataType: n.setParameterDataType,
|
|
2299
|
+
clearParameterDataTypes: n.clearParameterDataTypes
|
|
2300
|
+
};
|
|
2301
|
+
}
|
|
2302
|
+
export {
|
|
2303
|
+
f as AVIATOR_FUNCTIONS,
|
|
2304
|
+
Ot as COMPARISON_OPERATORS,
|
|
2305
|
+
_t as createAviatorExpressionService,
|
|
2306
|
+
g as createConditionNode,
|
|
2307
|
+
_ as createGroupNode,
|
|
2308
|
+
q as extractFieldPaths,
|
|
2309
|
+
Ct as extractFieldsFromJson,
|
|
2310
|
+
cr as generateExpression,
|
|
2311
|
+
k as generateNodeId,
|
|
2312
|
+
G as parseExpression,
|
|
2313
|
+
ft as parseExpressionNodes,
|
|
2314
|
+
Le as shouldBeLambdaParameter,
|
|
2315
|
+
ht as validateExpression
|
|
2316
|
+
};
|
|
2317
|
+
//# sourceMappingURL=headless.js.map
|