@lcap/nasl 3.8.2-beta.8 → 3.8.3-beta.1
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/ai-engineer.config.js +617 -0
- package/out/common/BaseNode.js +5 -3
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/ComponentAPI.d.ts +9 -0
- package/out/concepts/AuthLogicForCallInterface__.js +21 -6
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +16 -1
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +12 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.js +1 -1
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BusinessComponent__.js +24 -8
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +21 -6
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallInterface__.js +2 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +1 -0
- package/out/concepts/CallLogic__.js +32 -11
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +1 -0
- package/out/concepts/CallQueryComponent__.js +23 -12
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Destination__.js +11 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +3 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.js +1 -1
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Interface__.js +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.js +49 -17
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +19 -13
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +37 -12
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +21 -6
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.js +5 -4
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +0 -1
- package/out/concepts/QueryOrderByExpression__.js +0 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/Structure__.js +5 -7
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/Variable__.js +5 -0
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +17 -7
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +70 -14
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js +78 -0
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +40 -40
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/generator/genBundleFiles.js +1 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/release-body/utils.js +1 -1
- package/out/natural/genNaturalTS.d.ts +45 -10
- package/out/natural/genNaturalTS.js +57 -33
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/getUILib.js +6 -3
- package/out/natural/getContext/getUILib.js.map +1 -1
- package/out/natural/getContext/index.d.ts +20 -7
- package/out/natural/getContext/index.js +143 -23
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/getContext/naslStdlibMap.js +8 -8
- package/out/natural/getContext/naslStdlibMap.js.map +1 -1
- package/out/natural/tools.d.ts +16 -0
- package/out/natural/tools.js +110 -2
- package/out/natural/tools.js.map +1 -1
- package/out/natural/transformTS2UI.js +361 -304
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.d.ts +3 -5
- package/out/natural/transformTSCode.js +30 -1089
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/natural/transforms/registerTransform.d.ts +7 -0
- package/out/natural/transforms/registerTransform.js +24 -0
- package/out/natural/transforms/registerTransform.js.map +1 -0
- package/out/natural/transforms/transform2LogicItem.d.ts +24 -0
- package/out/natural/transforms/transform2LogicItem.js +1240 -0
- package/out/natural/transforms/transform2LogicItem.js.map +1 -0
- package/out/natural/transforms/transform2TypeAnnotation.d.ts +2 -0
- package/out/natural/transforms/transform2TypeAnnotation.js +86 -0
- package/out/natural/transforms/transform2TypeAnnotation.js.map +1 -0
- package/out/natural/transforms/utils.d.ts +8 -0
- package/out/natural/transforms/utils.js +59 -0
- package/out/natural/transforms/utils.js.map +1 -0
- package/out/server/getLogics.js +12 -12
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +11 -17
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +2 -2
- package/out/server/naslServer.js +38 -18
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +5 -0
- package/out/server/translator.js.map +1 -1
- package/out/templator/block2nasl/jsx2nasl/index.d.ts +5 -0
- package/out/templator/block2nasl/jsx2nasl/index.js +15 -0
- package/out/templator/block2nasl/jsx2nasl/index.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.d.ts +3 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.js +213 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.d.ts +14 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.js +201 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.d.ts +4 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.js +186 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.d.ts +28 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.js +336 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/utils.d.ts +2 -0
- package/out/templator/block2nasl/jsx2nasl/utils.js +26 -0
- package/out/templator/block2nasl/jsx2nasl/utils.js.map +1 -0
- package/out/templator/block2nasl/transformBlock2Nasl.d.ts +10 -0
- package/out/templator/block2nasl/transformBlock2Nasl.js +122 -0
- package/out/templator/block2nasl/transformBlock2Nasl.js.map +1 -0
- package/out/templator/block2nasl/viewMergeBlock.d.ts +9 -0
- package/out/templator/block2nasl/viewMergeBlock.js +110 -0
- package/out/templator/block2nasl/viewMergeBlock.js.map +1 -0
- package/out/translator/types.d.ts +2 -0
- package/out/translator/utils.js +1 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/index.js +0 -4
- package/out/utils/index.js.map +1 -1
- package/out/utils/language-cache/constant.d.ts +2 -1
- package/out/utils/language-cache/constant.js +1 -0
- package/out/utils/language-cache/constant.js.map +1 -1
- package/out/utils/language-cache/nasl.d.ts +1 -0
- package/out/utils/language-cache/nasl.js +9 -1
- package/out/utils/language-cache/nasl.js.map +1 -1
- package/package.json +6 -2
- package/sandbox/stdlib/nasl.processV2.ts +19 -0
- package/sandbox/stdlib/nasl.ui.ts +8 -8
- package/sandbox-natural/stdlib/nasl.core.d.ts +54 -0
- package/sandbox-natural/stdlib/nasl.oql.d.ts +22 -0
- package/sandbox-natural/stdlib/nasl.ui.d.ts +78 -0
- package/sandbox-natural/stdlib/nasl.ui.h5.d.ts +1684 -1643
- package/sandbox-natural/stdlib/nasl.ui.h5.json +15746 -15045
- package/sandbox-natural/stdlib/nasl.ui.pc.d.ts +5341 -5154
- package/sandbox-natural/stdlib/nasl.ui.pc.json +31176 -30681
- package/sandbox-natural/stdlib/{nasl.util.ts → nasl.util.d.ts} +49 -43
- package/src/common/BaseNode.ts +5 -3
- package/src/common/ComponentAPI.ts +7 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +23 -6
- package/src/concepts/BackendVariable__.ts +16 -1
- package/src/concepts/BindAttribute__.ts +18 -13
- package/src/concepts/BindDirective__.ts +1 -1
- package/src/concepts/BindStyle__.ts +1 -1
- package/src/concepts/BusinessComponent__.ts +26 -8
- package/src/concepts/BusinessLogic__.ts +23 -6
- package/src/concepts/CallInterface__.ts +2 -2
- package/src/concepts/CallLogic__.ts +50 -24
- package/src/concepts/CallQueryComponent__.ts +26 -12
- package/src/concepts/Destination__.ts +14 -12
- package/src/concepts/EntityProperty__.ts +5 -5
- package/src/concepts/Entity__.ts +1 -1
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/Logic__.ts +62 -33
- package/src/concepts/MemberExpression__.ts +20 -13
- package/src/concepts/OqlQueryComponent__.ts +29 -5
- package/src/concepts/OverriddenLogic__.ts +23 -6
- package/src/concepts/Param__.ts +5 -4
- package/src/concepts/QueryOrderByExpression__.ts +0 -1
- package/src/concepts/Structure__.ts +5 -7
- package/src/concepts/Variable__.ts +9 -5
- package/src/concepts/ViewElement__.ts +25 -9
- package/src/concepts/View__.ts +97 -37
- package/src/concepts/basics/stdlib/nasl.processV2.ts +79 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +40 -40
- package/src/generator/genBundleFiles.ts +1 -1
- package/src/generator/release-body/utils.ts +1 -1
- package/src/natural/genNaturalTS.ts +88 -39
- package/src/natural/getContext/getUILib.ts +6 -3
- package/src/natural/getContext/index.ts +125 -23
- package/src/natural/getContext/naslStdlibMap.ts +8 -8
- package/src/natural/tools.ts +107 -2
- package/src/natural/transformTS2UI.ts +205 -147
- package/src/natural/transformTSCode.ts +29 -1055
- package/src/natural/transforms/registerTransform.ts +34 -0
- package/src/natural/transforms/transform2LogicItem.ts +1335 -0
- package/src/natural/transforms/transform2TypeAnnotation.ts +77 -0
- package/src/natural/transforms/utils.ts +25 -0
- package/src/server/getLogics.ts +12 -12
- package/src/server/getMemberIdentifier.ts +14 -14
- package/src/server/naslServer.ts +39 -19
- package/src/server/translator.ts +5 -0
- package/src/templator/block2nasl/jsx2nasl/index.ts +11 -0
- package/src/templator/block2nasl/jsx2nasl/transform-expression2nasl.ts +238 -0
- package/src/templator/block2nasl/jsx2nasl/transform-func2nasl.ts +241 -0
- package/src/templator/block2nasl/jsx2nasl/transform-tstype2nasl.ts +213 -0
- package/src/templator/block2nasl/jsx2nasl/transform-tsx2nasl.ts +422 -0
- package/src/templator/block2nasl/jsx2nasl/utils.ts +19 -0
- package/src/templator/block2nasl/transformBlock2Nasl.ts +99 -0
- package/src/templator/block2nasl/viewMergeBlock.ts +149 -0
- package/src/translator/types.ts +2 -0
- package/src/translator/utils.ts +1 -1
- package/src/utils/index.ts +0 -4
- package/src/utils/language-cache/constant.ts +1 -0
- package/src/utils/language-cache/nasl.ts +6 -0
- package/test/concepts/member-expression/__snapshots__/toJS.spec.ts.snap +1 -1
- package/test/concepts/member-expression/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/tdd/dataQuery/QueryFieldExpression/case1/ast.json +7 -0
- package/test/tdd/dataQuery/QueryFieldExpression/case1/natural.ts.txt +1 -0
- package/test/tdd/dataQuery/QueryFieldExpression/case2/ast.json +7 -0
- package/test/tdd/dataQuery/QueryFieldExpression/case2/natural.ts.txt +1 -0
- package/test/tdd/transform/case1/ast.json +243 -0
- package/test/tdd/transform/case1/natural.ts.md +20 -0
- package/test/tdd/transform/case2/ast.json +207 -0
- package/test/tdd/transform/case2/natural.ts.md +12 -0
- package/test/tdd.test.js +10 -0
- package/test/tdd.transform.test.js +38 -0
- package/test/utils.js +40 -0
- package/sandbox-natural/stdlib/nasl.core.ts +0 -36
- package/sandbox-natural/stdlib/nasl.oql.ts +0 -14
- package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +0 -90
- package/sandbox-natural/stdlib/nasl.ui.ts +0 -63
|
@@ -1,19 +1,27 @@
|
|
|
1
|
+
/** 循环函数ForEach
|
|
2
|
+
* 这是唯一一个可以在逻辑中使用的循环函数,用于遍历列表中的元素,禁止使用for、forEach等其他循环语句。
|
|
3
|
+
*/
|
|
4
|
+
declare function ForEach<T>(list: List<T>, start: Integer, end: Integer, fn: (item: T, index: Integer) => void): void;
|
|
5
|
+
|
|
6
|
+
/* 基本运算函数,用于数学计算 */
|
|
7
|
+
declare function plus(left: Decimal, right: Decimal): Decimal;
|
|
8
|
+
declare function minus(left: Decimal, right: Decimal): Decimal;
|
|
9
|
+
declare function multiply(left: Decimal, right: Decimal): Decimal;
|
|
10
|
+
declare function divide(left: Decimal, right: Decimal): Decimal;
|
|
11
|
+
declare function remainder(left: Decimal, right: Decimal): Decimal;
|
|
12
|
+
|
|
1
13
|
declare namespace nasl.util {
|
|
2
|
-
|
|
14
|
+
/* 类型转换与格式化函数 */
|
|
3
15
|
export function Convert(value: null): <T extends never>() => T;
|
|
4
|
-
export function FormatNumber(doubleValue: Decimal |
|
|
5
|
-
|
|
6
|
-
* @example nasl.util.FormatDateTime(dataTime1, 'yyyy-MM-dd HH:mm:ss', 'global')
|
|
7
|
-
*/
|
|
16
|
+
export function FormatNumber(doubleValue: Decimal | Long, digits: Long, showGroups: Boolean): String;
|
|
17
|
+
// @example nasl.util.FormatDateTime(dataTime1, 'yyyy-MM-dd HH:mm:ss', 'global')
|
|
8
18
|
export function FormatDateTime(dateTime: DateTime, formatter: String, timeZone: string): String;
|
|
9
19
|
export function FormatDate(date: Date, formatter: String): String;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
export function FromString<T extends Decimal | Date | Time | DateTime | Integer | Boolean>(value: String): T;
|
|
20
|
+
// @example nasl.util.FromString<Date>(variable1)
|
|
21
|
+
export function FromString<T extends Decimal | Date | Time | DateTime | Long | Boolean>(value: String): T;
|
|
14
22
|
export function ToString(value: Any): String;
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
/* 字符串函数 */
|
|
17
25
|
export function Length(str1: String): Decimal;
|
|
18
26
|
export function Length<K, V>(str1: Map<K, V>): Decimal;
|
|
19
27
|
export function Length<T>(str1: List<T>): Decimal;
|
|
@@ -22,24 +30,28 @@ declare namespace nasl.util {
|
|
|
22
30
|
export function LastIndexOf(str: String, search: String, ignoreCase: Boolean): Decimal;
|
|
23
31
|
export function Replace(str: String, search: String, replace: String): String;
|
|
24
32
|
export function Split(str: String, seperator: String): List<String>;
|
|
25
|
-
export function SubString(str: String, start: Decimal, length:
|
|
33
|
+
export function SubString(str: String, start: Decimal, length: Long): String;
|
|
26
34
|
export function ToLower(str1: String): String;
|
|
27
35
|
export function ToUpper(str1: String): String;
|
|
28
36
|
export function Trim(str1: String): String;
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
/* 日期与时间函数 */
|
|
31
39
|
export function CurrDate(): Date;
|
|
32
40
|
export function CurrDateTime(): DateTime;
|
|
33
41
|
export function CurrTime(): Time;
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
// 计算两个日期时间之间的差值,calcType 支持年、季度、月、周、天、时分秒,默认为 'd'
|
|
43
|
+
export function DateDiff<T extends Date | Time | DateTime>(dateTime1: T, dateTime2: T, calcType: 'y' | 'q' | 'M' | 'w' | 'd' | 'h' | 'm' | 's', isAbs: Boolean): Decimal;
|
|
44
|
+
// 为指定日期时间调整增加(减少)时间
|
|
36
45
|
export function AlterDateTime<T extends Date | DateTime>(dateTime: T, option: 'Increase' | 'Decrease', amount: Long, unit: 'day' | 'week' | 'month' | 'quarter' | 'year'): T;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
/** 按指定维度计算日期的序号。当输入为 DateTime 类型时,会把数据转到提供的时区的当地时间进行计算
|
|
47
|
+
* @param dateTime: 日期或日期时间
|
|
48
|
+
* @param metric: 计算维度,格式为'小日期单位-大日期单位'。日期单位包括:'year'、'quarter'、'month'、'week'、'day'。如设置 'week-year',则返回当前日期是所在年的第几周, 'day-week',则返回当前日期是所在周的第几天。
|
|
49
|
+
*/
|
|
50
|
+
export function GetDateCount<T extends Date | DateTime>(dateTime: T, metric: 'week-year'): Time;
|
|
51
|
+
// 按“星期几”获取指定日期范围内的日子。当输入为 DateTime 类型时,会把数据转到提供的时区的当地时间进行计算。target 取值范围 [1,2,3,4,5,6,7]
|
|
52
|
+
export function GetSpecificDaysOfWeek<T extends Date | DateTime>(startDate: T, endDate: T, target: List<Long>): List<T>;
|
|
41
53
|
|
|
42
|
-
|
|
54
|
+
/* 列表(List)函数 */
|
|
43
55
|
export function Add<T, K extends T>(list: List<T>, item: K): void;
|
|
44
56
|
export function AddAll<T>(list: List<T>, addList: List<T>): Decimal;
|
|
45
57
|
export function Contains<T, K extends T>(list: List<T>, item: K): Boolean;
|
|
@@ -58,15 +70,15 @@ declare namespace nasl.util {
|
|
|
58
70
|
export function ListReverse<T>(list: List<T>): void;
|
|
59
71
|
export function ListSlice<T>(list: List<T>, start: Decimal, end: Decimal): List<T>;
|
|
60
72
|
export function ListSort<T>(list: List<T>, by: (item: T) => any, sort: Boolean): void;
|
|
61
|
-
export function ListSum<T extends
|
|
73
|
+
export function ListSum<T extends Long | Decimal>(list: List<T>): T;
|
|
62
74
|
export function ListToMap<T, K extends Boolean | Decimal | Decimal | String, V>(map: List<T>, byKey: (elem: T) => K, byVal: (elem: T) => V): Map<K, V>;
|
|
63
75
|
export function ListTransform<T0, T>(list: List<T0>, by: (elem: T0) => T): List<T>;
|
|
64
76
|
export function Get<T>(list: List<T>, index: Decimal): T;
|
|
65
77
|
export function Remove<T, K extends T>(list: List<T>, item: K): void;
|
|
66
|
-
export function RemoveAt<T>(list: List<T>, index:
|
|
78
|
+
export function RemoveAt<T>(list: List<T>, index: Long): T;
|
|
67
79
|
export function Set<T, K extends T>(list: List<T>, index: Decimal, item: K): T;
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
/* 映射(Map)函数 */
|
|
70
82
|
export function MapContains<K, V>(map: Map<K, V>, key: K): Boolean;
|
|
71
83
|
export function MapGet<K, V>(map: Map<K, V>, key: K): V;
|
|
72
84
|
export function MapPut<K, V>(map: Map<K, V>, key: K, value: V): void;
|
|
@@ -74,62 +86,56 @@ declare namespace nasl.util {
|
|
|
74
86
|
export function MapRemove<K, V>(map: Map<K, V>, key: K): void;
|
|
75
87
|
export function MapValues<K, V>(map: Map<K, V>): List<V>;
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @example nasl.util.EnumToList<app.enums.
|
|
89
|
+
/* 枚举函数,项目中可使用的枚举类型均定义在 app.enums 中 */
|
|
90
|
+
/** 将指定枚举转换枚举value和text的List集合
|
|
91
|
+
* @example nasl.util.EnumToList<app.enums.UserSourceEnum>();
|
|
80
92
|
*/
|
|
81
93
|
export function EnumToList<T extends Enums>(): List<{ text: String, value: String; }>;
|
|
82
|
-
//
|
|
94
|
+
// 返回枚举指定value的标题字符串
|
|
83
95
|
export function EnumValueToText<T extends Enums>(value: any): String;
|
|
84
96
|
// 在指定枚举中找到与参数相同的枚举值并返回
|
|
85
97
|
export function StringToEnumValue<T extends Enums>(value: String): T;
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 整数/小数 操作
|
|
99
|
+
/* 数学函数 */
|
|
100
|
+
/** 整数/小数 操作
|
|
90
101
|
* @param mode: 'HalfUp' | 'TowardsZero' | 'TowardsInfinity' === '四舍五入' | '截断、向零取整,如 -2.6 取整为 -2' | '进位、向正负无穷取整,如 -1.1 取整为 -2'
|
|
91
102
|
*/
|
|
92
103
|
export function Round(value: Decimal, mode: 'HalfUp' | 'TowardsZero' | 'TowardsInfinity'): Decimal;
|
|
93
|
-
|
|
94
|
-
// 其他函数
|
|
104
|
+
/* 其他函数 */
|
|
95
105
|
export function Clear<T>(struct: T): T;
|
|
96
106
|
export function Clone<T>(struct: T): T;
|
|
107
|
+
// 判断参数是否为有效值,null、空字符串、纯空格、长度为0的集合均不被视为有效值,传入多个参数时,判断是否全部都是有效值 */
|
|
97
108
|
export function HasValue(...args: Any[]): Boolean;
|
|
98
109
|
// RandomInt 生成的数字为整数,如果需要指定位数的随机数,需要在数字前按照位数要求补 0
|
|
99
|
-
export function RandomInt(start:
|
|
110
|
+
export function RandomInt(start: Long, end: Long): Long;
|
|
100
111
|
|
|
101
112
|
// New 系列函数使用
|
|
102
|
-
/**
|
|
103
|
-
* T 类型必填
|
|
113
|
+
/** 生成新的列表,T 类型必填
|
|
104
114
|
* @example const variable1 = nasl.util.NewList<Boolean | Long>([true, false, 1])
|
|
105
115
|
*/
|
|
106
116
|
export function NewList<T>(args: T[]): List<T>;
|
|
107
|
-
/**
|
|
108
|
-
* T 类型必填
|
|
117
|
+
/** 生成新的映射,K、T 类型必填
|
|
109
118
|
* @example const variable1 = nasl.util.NewMap<String, Long>({'123': 456})
|
|
110
119
|
*/
|
|
111
120
|
export function NewMap<K, T>(args: any): Map<K, T>;
|
|
112
|
-
/**
|
|
113
|
-
* T 类型必填
|
|
121
|
+
/** 生成新的数据实体,T 类型必填
|
|
114
122
|
* class Entity1 { id: Long; property1: String; property2: String;}
|
|
115
123
|
* @example const variable1 = nasl.util.NewEntity<Entity1>({id: 123, property1: '123', property2: '456'})
|
|
116
124
|
*/
|
|
117
125
|
export function NewEntity<T>(arg: T): T;
|
|
118
|
-
/**
|
|
119
|
-
* T 类型必填
|
|
126
|
+
/** 生成新的结构体,T 类型必填
|
|
120
127
|
* class Structure1 { id: Long; property1: String; property2: String;}
|
|
121
128
|
* @example const variable1 = nasl.util.NewStructure<Structure1>({id: 123, property1: '123', property2: '456'})
|
|
122
129
|
*/
|
|
123
130
|
export function NewStructure<T>(arg: T): T;
|
|
124
|
-
/**
|
|
131
|
+
/** 生成新的匿名结构体, 无需定义类型
|
|
125
132
|
* @example const variable1 = nasl.util.NewAnonymousStructure({property1: '123', property2: '456'})
|
|
126
133
|
*/
|
|
127
134
|
export function NewAnonymousStructure(arg: Any): Any;
|
|
128
135
|
|
|
129
136
|
export function consoleLog(arg: Any): void;
|
|
130
137
|
export function jsonSerialize(arg: Any): String;
|
|
131
|
-
/**
|
|
132
|
-
* T 为返回值类型,必填
|
|
138
|
+
/** JSON 反序列化, T 为返回值类型,必填
|
|
133
139
|
* @example nasl.util.jsonDeserialize<Boolean>(variable1);
|
|
134
140
|
*/
|
|
135
141
|
export function jsonDeserialize<T>(arg: String): T;
|
package/src/common/BaseNode.ts
CHANGED
|
@@ -812,7 +812,7 @@ export class BaseNode extends EventEmitter {
|
|
|
812
812
|
const Ctor = classMap.get(source?.concept) || this;
|
|
813
813
|
if (Ctor && source instanceof Ctor) {
|
|
814
814
|
if (utils.isDebugMode) {
|
|
815
|
-
console.warn('传入的对象已经是一个实例,请确认逻辑是否存在问题!');
|
|
815
|
+
// console.warn('传入的对象已经是一个实例,请确认逻辑是否存在问题!');
|
|
816
816
|
}
|
|
817
817
|
if (parentNode) {
|
|
818
818
|
source.parentNode = parentNode;
|
|
@@ -1729,9 +1729,11 @@ export class BaseNode extends EventEmitter {
|
|
|
1729
1729
|
const results: types.SyntaxNode[] = []; // 创建一个数组存储匹配的结果
|
|
1730
1730
|
|
|
1731
1731
|
queue.push(this as unknown as types.SyntaxNode); // 将初始节点加入队列
|
|
1732
|
+
let point = 0; // 创建一个指针,指向当前遍历的节点
|
|
1732
1733
|
|
|
1733
|
-
while (queue
|
|
1734
|
-
const node = queue
|
|
1734
|
+
while (queue[point]) {
|
|
1735
|
+
const node = queue[point]; // 从队列中取出一个节点
|
|
1736
|
+
point++; // 指针后移
|
|
1735
1737
|
|
|
1736
1738
|
if (node) {
|
|
1737
1739
|
let result = false;
|
|
@@ -542,22 +542,39 @@ export class AuthLogicForCallInterface extends AuthLogic {
|
|
|
542
542
|
],
|
|
543
543
|
function* warpForEachGenerator({ key, node: itemNode }) {
|
|
544
544
|
if (itemNode) {
|
|
545
|
-
code += `
|
|
545
|
+
code += `let __${key}_${node?.name}`;
|
|
546
546
|
let itemCode = '';
|
|
547
|
+
// 匿名数据结构 / 未设置类型的List/map 才进getInitCode
|
|
547
548
|
if (
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
549
|
+
(
|
|
550
|
+
asserts.isNewComposite(itemNode)
|
|
551
|
+
&& itemNode.typeAnnotation?.typeKind === 'anonymousStructure'
|
|
552
|
+
)
|
|
553
|
+
|| (
|
|
554
|
+
(asserts.isNewList(itemNode) || asserts.isNewMap(itemNode))
|
|
555
|
+
&& !(itemNode?.typeAnnotation)
|
|
556
|
+
)
|
|
551
557
|
) {
|
|
552
|
-
|
|
558
|
+
code += ' = ';
|
|
559
|
+
itemCode += yield* itemNode?.getInitCode?.(shiftState(state, code, {
|
|
553
560
|
inline: true
|
|
554
561
|
})) ??
|
|
555
562
|
returnOrigin('');
|
|
563
|
+
} else if (asserts.isNewComposite(itemNode) && itemNode.typeAnnotation?.typeKind === 'generic') { // new 带泛型的数据结构/实体 进这里
|
|
564
|
+
code += ' = ';
|
|
565
|
+
itemCode += (yield* itemNode?.getNewCompositeCode?.(shiftState(state, code, { inline: true }))) || 'null';
|
|
566
|
+
} else if ((itemNode as any)?.typeAnnotation && !(asserts.isCallQueryComponent(itemNode) && !itemNode.isAutoInfer())) {
|
|
567
|
+
code += ': ';
|
|
568
|
+
code += yield* (itemNode as any)?.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
569
|
+
returnOrigin('');
|
|
556
570
|
} else {
|
|
571
|
+
code += ' = ';
|
|
557
572
|
itemCode = yield* itemNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
558
573
|
returnOrigin('');
|
|
559
574
|
}
|
|
560
|
-
|
|
575
|
+
if (itemCode) {
|
|
576
|
+
code += yield* self.getRightCode(itemCode, assignment, itemNode);
|
|
577
|
+
}
|
|
561
578
|
code += ';\n';
|
|
562
579
|
}
|
|
563
580
|
},
|
|
@@ -438,7 +438,22 @@ export class BackendVariable extends BaseNode {
|
|
|
438
438
|
|
|
439
439
|
@withSourceMap()
|
|
440
440
|
toNaturalTS(state = createCompilerState()): string {
|
|
441
|
-
|
|
441
|
+
let code = this.name;
|
|
442
|
+
if (state?.needNamespace) {
|
|
443
|
+
const namespace = this.getNamespace();
|
|
444
|
+
const prefix = ['Backend']?.includes(this?.parentNode?.concept) ? `${namespace}.` : '';
|
|
445
|
+
code = `${prefix}${code}`;
|
|
446
|
+
}
|
|
447
|
+
if (this?.typeAnnotation) {
|
|
448
|
+
code += ': ';
|
|
449
|
+
code += this.typeAnnotation?.toNaturalTS(shiftState(state, code));
|
|
450
|
+
if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
|
|
451
|
+
if (this.isEnum()) {
|
|
452
|
+
code += `= ${this.typeAnnotation?.typeKey}['${this.defaultValue}']`;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return code;
|
|
442
457
|
}
|
|
443
458
|
//================================================================================
|
|
444
459
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -165,7 +165,7 @@ export class BindAttribute extends BaseNode {
|
|
|
165
165
|
* @param source 需要合并的部分参数
|
|
166
166
|
*/
|
|
167
167
|
constructor(source?: Partial<BindAttribute>) {
|
|
168
|
-
source = { ...BindAttribute.getDefaultOptions(), ...source};
|
|
168
|
+
source = { ...BindAttribute.getDefaultOptions(), ...source };
|
|
169
169
|
super(source);
|
|
170
170
|
super.subConstructor(source);
|
|
171
171
|
}
|
|
@@ -546,7 +546,7 @@ export class BindAttribute extends BaseNode {
|
|
|
546
546
|
if (typeof options === 'string') {
|
|
547
547
|
validationRule = (this.rules as ValidationRule[]).find((item) => item.name === options);
|
|
548
548
|
if (!validationRule) {
|
|
549
|
-
throw new Error(`找不到验证规则 ${
|
|
549
|
+
throw new Error(`找不到验证规则 ${options}`);
|
|
550
550
|
}
|
|
551
551
|
} else {
|
|
552
552
|
validationRule = options;
|
|
@@ -938,7 +938,7 @@ export class BindAttribute extends BaseNode {
|
|
|
938
938
|
transfromUnionTypeAnnotation(expTypeAnnotation, this.app);
|
|
939
939
|
if (expTypeAnnotation?.typeNamespace?.endsWith('.metadataTypes')) {
|
|
940
940
|
const referenceNode =
|
|
941
|
-
this.app.findNodeByCompleteName(`${expTypeAnnotation.typeNamespace
|
|
941
|
+
this.app.findNodeByCompleteName(`${expTypeAnnotation.typeNamespace}.${expTypeAnnotation.typeName}`)
|
|
942
942
|
?.typeAnnotation || {};
|
|
943
943
|
value = `$utils['ToString']('${referenceNode?.typeNamespace}.${referenceNode.typeName}', ${value})`;
|
|
944
944
|
} else {
|
|
@@ -970,7 +970,7 @@ export class BindAttribute extends BaseNode {
|
|
|
970
970
|
}
|
|
971
971
|
|
|
972
972
|
@withSourceMapGenerator
|
|
973
|
-
*toEmbeddedTS(state = createCompilerState(), options: { carryName: boolean } = { carryName: false }): TranslatorGenerator {
|
|
973
|
+
*toEmbeddedTS(state = createCompilerState(), options: { carryName: boolean; } = { carryName: false }): TranslatorGenerator {
|
|
974
974
|
const self = this;
|
|
975
975
|
const { name, type, value, rules, expression, playground } = self;
|
|
976
976
|
const humpName = self.toHump(name);
|
|
@@ -1037,7 +1037,7 @@ export class BindAttribute extends BaseNode {
|
|
|
1037
1037
|
|
|
1038
1038
|
'dataSource',
|
|
1039
1039
|
'converter',
|
|
1040
|
-
]
|
|
1040
|
+
];
|
|
1041
1041
|
|
|
1042
1042
|
// @ts-ignore
|
|
1043
1043
|
if (prop?.implicitToString) {
|
|
@@ -1185,19 +1185,24 @@ export class BindAttribute extends BaseNode {
|
|
|
1185
1185
|
) {
|
|
1186
1186
|
return node.parentNode;
|
|
1187
1187
|
}
|
|
1188
|
-
|
|
1188
|
+
return this.findCurrentElementParent(node.parentNode);
|
|
1189
1189
|
|
|
1190
1190
|
}
|
|
1191
|
-
|
|
1191
|
+
return undefined;
|
|
1192
1192
|
|
|
1193
1193
|
}
|
|
1194
1194
|
|
|
1195
1195
|
@withSourceMap()
|
|
1196
1196
|
toNaturalTS(state = createCompilerState()): string {
|
|
1197
1197
|
let code = `${utils.firstLowerCase(utils.kebab2Camel(this.name))}: `;
|
|
1198
|
-
|
|
1198
|
+
if (['dataSchema'].includes(this.name)) {
|
|
1199
|
+
if (state?.typeMap?.[this.nodePath]) {
|
|
1200
|
+
code += `'${state?.typeMap?.[this.nodePath]}'`;
|
|
1201
|
+
return code;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1199
1204
|
if (['destination', 'externalDestination'].includes(this.name) && this.type === 'dynamic') {
|
|
1200
|
-
code += (this as any)[this.name]
|
|
1205
|
+
code += (this as any)?.[this.name]?.toNaturalTS(
|
|
1201
1206
|
shiftState(state, code, { tabSize: state.tabSize + 1, inline: true }),
|
|
1202
1207
|
);
|
|
1203
1208
|
} else if (this.name === 'rules') {
|
|
@@ -1208,9 +1213,9 @@ export class BindAttribute extends BaseNode {
|
|
|
1208
1213
|
});
|
|
1209
1214
|
code += `\n${indent(state.tabSize)}]`;
|
|
1210
1215
|
} else if (this.type === 'dynamic' && this.sync) {
|
|
1211
|
-
code
|
|
1212
|
-
code +=
|
|
1213
|
-
code +=
|
|
1216
|
+
const value = this.expression?.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize, inline: true }));
|
|
1217
|
+
if (value) code += `sync(${value})`;
|
|
1218
|
+
else code += value;
|
|
1214
1219
|
} else {
|
|
1215
1220
|
if (this.type === 'string') code += `'${this.value?.replace(/'/g, "\\'")}'`;
|
|
1216
1221
|
else if (this.type === 'static') code += `${this.value}`;
|
|
@@ -1275,7 +1280,7 @@ export function attrConvertCamelCase(str: string) {
|
|
|
1275
1280
|
if (index === 0) {
|
|
1276
1281
|
return strItem;
|
|
1277
1282
|
}
|
|
1278
|
-
|
|
1283
|
+
return `${strItem.slice(0, 1).toUpperCase()}${strItem.slice(1)}`;
|
|
1279
1284
|
|
|
1280
1285
|
});
|
|
1281
1286
|
return strList.join('');
|
|
@@ -570,7 +570,7 @@ export class BindDirective extends BaseNode {
|
|
|
570
570
|
|
|
571
571
|
@withSourceMap()
|
|
572
572
|
toNaturalTS(state = createCompilerState()): string {
|
|
573
|
-
let code =
|
|
573
|
+
let code = `_${this.name}: `;
|
|
574
574
|
|
|
575
575
|
code += this.expression?.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize, inline: true }));
|
|
576
576
|
|
|
@@ -471,7 +471,7 @@ export class BindStyle extends BaseNode {
|
|
|
471
471
|
|
|
472
472
|
@withSourceMap()
|
|
473
473
|
toNaturalTS(state = createCompilerState()): string {
|
|
474
|
-
let code =
|
|
474
|
+
let code = `_${this.name}: `;
|
|
475
475
|
|
|
476
476
|
code += this.expression?.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize, inline: true }));
|
|
477
477
|
|
|
@@ -15,7 +15,7 @@ import type Match from './Match__';
|
|
|
15
15
|
import type Logic from './Logic__';
|
|
16
16
|
import type Param from './Param__';
|
|
17
17
|
import { ElementToVueOptions } from './ViewElement__';
|
|
18
|
-
import {
|
|
18
|
+
import { config } from '../config';
|
|
19
19
|
import translator from '../bak/translator';
|
|
20
20
|
|
|
21
21
|
type AttrObject = {
|
|
@@ -1903,7 +1903,8 @@ export class BusinessComponent extends BaseNode {
|
|
|
1903
1903
|
if (item.tag === 'template' && item.haveScope()) {
|
|
1904
1904
|
index += 1;
|
|
1905
1905
|
}
|
|
1906
|
-
if (
|
|
1906
|
+
if (config?.allNodesAPI && config?.allNodesAPI[item.tag] &&
|
|
1907
|
+
config?.allNodesAPI[item.tag].readablePropsMap) {
|
|
1907
1908
|
componentList.push(item);
|
|
1908
1909
|
}
|
|
1909
1910
|
item.currentIndex = index;
|
|
@@ -2145,22 +2146,39 @@ export class BusinessComponent extends BaseNode {
|
|
|
2145
2146
|
],
|
|
2146
2147
|
function* warpForEachGenerator({ key, node: itemNode }) {
|
|
2147
2148
|
if (itemNode) {
|
|
2148
|
-
code += `
|
|
2149
|
+
code += `let __${key}_${node?.name}`;
|
|
2149
2150
|
let itemCode = '';
|
|
2151
|
+
// 匿名数据结构 / 未设置类型的List/map 才进getInitCode
|
|
2150
2152
|
if (
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2153
|
+
(
|
|
2154
|
+
asserts.isNewComposite(itemNode)
|
|
2155
|
+
&& itemNode.typeAnnotation?.typeKind === 'anonymousStructure'
|
|
2156
|
+
)
|
|
2157
|
+
|| (
|
|
2158
|
+
(asserts.isNewList(itemNode) || asserts.isNewMap(itemNode))
|
|
2159
|
+
&& !(itemNode?.typeAnnotation)
|
|
2160
|
+
)
|
|
2154
2161
|
) {
|
|
2155
|
-
|
|
2162
|
+
code += ' = ';
|
|
2163
|
+
itemCode += yield* itemNode?.getInitCode?.(shiftState(state, code, {
|
|
2156
2164
|
inline: true
|
|
2157
2165
|
})) ??
|
|
2158
2166
|
returnOrigin('');
|
|
2167
|
+
} else if (asserts.isNewComposite(itemNode) && itemNode.typeAnnotation?.typeKind === 'generic') { // new 带泛型的数据结构/实体 进这里
|
|
2168
|
+
code += ' = ';
|
|
2169
|
+
itemCode += (yield* itemNode?.getNewCompositeCode?.(shiftState(state, code, { inline: true }))) || 'null';
|
|
2170
|
+
} else if ((itemNode as any)?.typeAnnotation && !(asserts.isCallQueryComponent(itemNode) && !itemNode.isAutoInfer())) {
|
|
2171
|
+
code += ': ';
|
|
2172
|
+
code += yield* (itemNode as any)?.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
2173
|
+
returnOrigin('');
|
|
2159
2174
|
} else {
|
|
2175
|
+
code += ' = ';
|
|
2160
2176
|
itemCode = yield* itemNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
2161
2177
|
returnOrigin('');
|
|
2162
2178
|
}
|
|
2163
|
-
|
|
2179
|
+
if (itemCode) {
|
|
2180
|
+
code += yield* self.getRightCode(itemCode, assignment, itemNode);
|
|
2181
|
+
}
|
|
2164
2182
|
code += ';\n';
|
|
2165
2183
|
}
|
|
2166
2184
|
},
|
|
@@ -351,22 +351,39 @@ export class BusinessLogic extends Logic {
|
|
|
351
351
|
],
|
|
352
352
|
function* warpForEachGenerator({ key, node: itemNode }) {
|
|
353
353
|
if (itemNode) {
|
|
354
|
-
code += `
|
|
354
|
+
code += `let __${key}_${node?.name}`;
|
|
355
355
|
let itemCode = '';
|
|
356
|
+
// 匿名数据结构 / 未设置类型的List/map 才进getInitCode
|
|
356
357
|
if (
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
(
|
|
359
|
+
asserts.isNewComposite(itemNode)
|
|
360
|
+
&& itemNode.typeAnnotation?.typeKind === 'anonymousStructure'
|
|
361
|
+
)
|
|
362
|
+
|| (
|
|
363
|
+
(asserts.isNewList(itemNode) || asserts.isNewMap(itemNode))
|
|
364
|
+
&& !(itemNode?.typeAnnotation)
|
|
365
|
+
)
|
|
360
366
|
) {
|
|
361
|
-
|
|
367
|
+
code += ' = ';
|
|
368
|
+
itemCode += yield* itemNode?.getInitCode?.(shiftState(state, code, {
|
|
362
369
|
inline: true
|
|
363
370
|
})) ??
|
|
364
371
|
returnOrigin('');
|
|
372
|
+
} else if (asserts.isNewComposite(itemNode) && itemNode.typeAnnotation?.typeKind === 'generic') { // new 带泛型的数据结构/实体 进这里
|
|
373
|
+
code += ' = ';
|
|
374
|
+
itemCode += (yield* itemNode?.getNewCompositeCode?.(shiftState(state, code, { inline: true }))) || 'null';
|
|
375
|
+
} else if ((itemNode as any)?.typeAnnotation && !(asserts.isCallQueryComponent(itemNode) && !itemNode.isAutoInfer())) {
|
|
376
|
+
code += ': ';
|
|
377
|
+
code += yield* (itemNode as any)?.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
378
|
+
returnOrigin('');
|
|
365
379
|
} else {
|
|
380
|
+
code += ' = ';
|
|
366
381
|
itemCode = yield* itemNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
367
382
|
returnOrigin('');
|
|
368
383
|
}
|
|
369
|
-
|
|
384
|
+
if (itemCode) {
|
|
385
|
+
code += yield* self.getRightCode(itemCode, assignment, itemNode);
|
|
386
|
+
}
|
|
370
387
|
code += ';\n';
|
|
371
388
|
}
|
|
372
389
|
},
|
|
@@ -716,8 +716,8 @@ export class CallInterface extends LogicItem {
|
|
|
716
716
|
if (!arg) return;
|
|
717
717
|
const idx = logicParam.findIndex((params) => arg.keyword === params.name);
|
|
718
718
|
const param = logicParam[idx];
|
|
719
|
-
|
|
720
|
-
arg.paramRequired = param?.required;
|
|
719
|
+
const hasDefaultValue = Boolean(param?.defaultValue?.expression);
|
|
720
|
+
arg.paramRequired = hasDefaultValue ? false : param?.required;
|
|
721
721
|
arg.paramTypeAnnotation = undefined;
|
|
722
722
|
arg.paramDefaultValue = undefined;
|
|
723
723
|
// 取到是不是必填放入参数中
|