@lcap/nasl 3.8.2-beta.9 → 3.8.3-beta.2
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.d.ts +9 -4
- package/out/common/BaseNode.js +43 -10
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js +2 -50
- 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 +2 -42
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +2 -50
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +1 -1
- package/out/concepts/CallFunction__.js +1 -1
- package/out/concepts/CallLogic__.js +7 -1
- 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/Identifier__.d.ts +2 -0
- package/out/concepts/Identifier__.js +51 -5
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/Interface__.js +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.js +33 -111
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -1
- package/out/concepts/MemberExpression__.js +15 -3
- 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 +2 -50
- 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/ProcessElementV2__.js +4 -0
- package/out/concepts/ProcessElementV2__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +4 -0
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessV2__.js +4 -0
- package/out/concepts/ProcessV2__.js.map +1 -1
- package/out/concepts/Process__.js +4 -0
- package/out/concepts/Process__.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/SubLogic__.js +5 -50
- package/out/concepts/SubLogic__.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 +16 -6
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +48 -49
- package/out/concepts/View__.js.map +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 +343 -292
- 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/naslServer.d.ts +2 -2
- package/out/server/naslServer.js +48 -18
- package/out/server/naslServer.js.map +1 -1
- package/out/server/semanticData.d.ts +32 -0
- package/out/server/semanticData.js +371 -0
- package/out/server/semanticData.js.map +1 -0
- 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 +111 -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-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 +50 -8
- package/src/concepts/AuthLogicForCallInterface__.ts +3 -56
- 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 +6 -51
- package/src/concepts/BusinessLogic__.ts +4 -56
- package/src/concepts/CallFunction__.ts +1 -1
- package/src/concepts/CallLogic__.ts +21 -16
- 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/Identifier__.ts +57 -6
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/Logic__.ts +44 -134
- package/src/concepts/MemberExpression__.ts +21 -7
- package/src/concepts/OqlQueryComponent__.ts +29 -5
- package/src/concepts/OverriddenLogic__.ts +4 -56
- package/src/concepts/Param__.ts +5 -4
- package/src/concepts/ProcessElementV2__.ts +4 -0
- package/src/concepts/ProcessElement__.ts +4 -0
- package/src/concepts/ProcessV2__.ts +5 -0
- package/src/concepts/Process__.ts +4 -0
- package/src/concepts/QueryOrderByExpression__.ts +0 -1
- package/src/concepts/Structure__.ts +5 -7
- package/src/concepts/SubLogic__.ts +6 -56
- package/src/concepts/Variable__.ts +9 -5
- package/src/concepts/ViewElement__.ts +24 -7
- package/src/concepts/View__.ts +75 -76
- 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 +190 -137
- 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/naslServer.ts +54 -19
- package/src/server/semanticData.ts +447 -0
- 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 +150 -0
- package/src/translator/types.ts +2 -0
- package/src/translator/utils.ts +2 -2
- 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/logic/__snapshots__/toEmbeddedTS.spec.ts.snap +182 -0
- package/test/concepts/logic/constant.ts +5 -0
- package/test/concepts/logic/fixtures/variable-host-call-logic-member-expression.json +267 -0
- package/test/concepts/logic/fixtures/variable-host-call-logic-nested-member-expression copy.json +457 -0
- package/test/concepts/logic/fixtures/variable-host-call-logic-with-handle-error-member-expression.json +267 -0
- package/test/concepts/logic/toEmbeddedTS.spec.ts +15 -0
- 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
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs-extra');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
requirement: `请完成 transform2LogicItem 文件中,数据查询相关的 transformCall2DataQuery 函数。
|
|
6
|
+
|
|
7
|
+
其中 naslTypes 有以下类:
|
|
8
|
+
|
|
9
|
+
- CallQueryComponent 数据查询
|
|
10
|
+
|
|
11
|
+
class CallQueryComponent extends LogicItem {
|
|
12
|
+
typeAnnotation?: TypeAnnotation;
|
|
13
|
+
select: QuerySelectExpression;
|
|
14
|
+
from: QueryFromExpression;
|
|
15
|
+
where?: LogicItem;
|
|
16
|
+
wherePlayground?: Array<LogicItem>;
|
|
17
|
+
groupBy?: Array<QueryGroupByExpression>;
|
|
18
|
+
having?: LogicItem;
|
|
19
|
+
havingPlayground?: Array<LogicItem>;
|
|
20
|
+
orderBy?: Array<QueryOrderByExpression>;
|
|
21
|
+
limit?: QueryLimitExpression;
|
|
22
|
+
ideVersion?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- QuerySelectExpression 查询选择子句
|
|
26
|
+
|
|
27
|
+
class QuerySelectExpression extends LogicItem {
|
|
28
|
+
distinct: boolean = false;
|
|
29
|
+
star: boolean = true;
|
|
30
|
+
selectElements: Array<QueryAggregateExpression | QueryFieldExpression> = [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- QueryFromExpression 查询 From 子句
|
|
34
|
+
|
|
35
|
+
class QueryFromExpression extends LogicItem {
|
|
36
|
+
entityNamespace: string;
|
|
37
|
+
entityName: string;
|
|
38
|
+
asName: string;
|
|
39
|
+
joinParts: Array<QueryJoinExpression>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- QueryJoinExpression 查询 Join 子句
|
|
43
|
+
|
|
44
|
+
class QueryJoinExpression extends LogicItem {
|
|
45
|
+
entityNamespace: string;
|
|
46
|
+
entityName: string;
|
|
47
|
+
asName: string;
|
|
48
|
+
joinType: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL';
|
|
49
|
+
onExpressions: Array<BinaryExpression>;
|
|
50
|
+
joinParts: Array<QueryJoinExpression>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- QueryFieldExpression 查询属性
|
|
54
|
+
|
|
55
|
+
class QueryFieldExpression extends LogicItem {
|
|
56
|
+
isDotStar: boolean = false;
|
|
57
|
+
asName: string;
|
|
58
|
+
entityAsName: string;
|
|
59
|
+
propertyName: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- QueryAggregateExpression 查询聚合函数
|
|
63
|
+
|
|
64
|
+
class QueryAggregateExpression extends LogicItem {
|
|
65
|
+
asName: string;
|
|
66
|
+
aggregateName: 'COUNT' | 'COUNTD' | 'SUM' | 'AVG' | 'MAX' | 'MIN';
|
|
67
|
+
aggregateParam: QueryFieldExpression;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
- QueryOrderByExpression 查询排序子句
|
|
71
|
+
|
|
72
|
+
class QueryOrderByExpression extends LogicItem {
|
|
73
|
+
orderElement: LogicItem;
|
|
74
|
+
order: LogicItem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
- QueryGroupByExpression 查询分组
|
|
78
|
+
|
|
79
|
+
class QueryGroupByExpression extends LogicItem {
|
|
80
|
+
groupElement: LogicItem;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
- Paginate 分页
|
|
84
|
+
|
|
85
|
+
class Paginate extends LogicItem {
|
|
86
|
+
list: LogicItem;
|
|
87
|
+
page: LogicItem;
|
|
88
|
+
size: LogicItem;
|
|
89
|
+
typeAnnotation?: TypeAnnotation;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
babelTypes 是著名的 babel.js 库,用于解析 JS/TS 的。naslTypes 是我们自定义的数据结构,在 src/concepts 目录中。
|
|
93
|
+
|
|
94
|
+
transformCall2DataQuery 的 node 参数是根据 babel 解析出来的:
|
|
95
|
+
|
|
96
|
+
原来 case1/natural.ts 文件的内容是:
|
|
97
|
+
|
|
98
|
+
FROM(app.dataSources.defaultDS.entities.OrderProductEntity, OrderProduct => $
|
|
99
|
+
.INNER_JOIN(app.dataSources.defaultDS.entities.OrderFormEntity, OrderForm => ON(() => OrderProduct.orderId == OrderForm.id)
|
|
100
|
+
.INNER_JOIN(app.dataSources.defaultDS.entities.ProductEntity, Product => ON(() => OrderProduct.productId == Product.id)
|
|
101
|
+
.WHERE(() => OrderProduct.createdBy == '张三' && OrderProduct.createdTime > startDateTime)
|
|
102
|
+
.GROUP_BY(() => OrderProduct.productId, Product.name)
|
|
103
|
+
.ORDER_BY(() => [productName, 'ASC'])
|
|
104
|
+
.SELECT(() => ({
|
|
105
|
+
orderProduct: OrderProduct,
|
|
106
|
+
orderForm: OrderForm,
|
|
107
|
+
product: Product,
|
|
108
|
+
totalAmount: SUM(OrderProduct.amount),
|
|
109
|
+
productId: OrderProduct.productId,
|
|
110
|
+
productName: Product.name,
|
|
111
|
+
})))))
|
|
112
|
+
|
|
113
|
+
经过 babel parse 之后的结果用 JSON 表示是:
|
|
114
|
+
|
|
115
|
+
{
|
|
116
|
+
"type": "CallExpression",
|
|
117
|
+
"callee": { "type": "Identifier", "name": "FROM" },
|
|
118
|
+
"arguments": [
|
|
119
|
+
{
|
|
120
|
+
"type": "MemberExpression",
|
|
121
|
+
"object": {
|
|
122
|
+
"type": "MemberExpression",
|
|
123
|
+
"object": {
|
|
124
|
+
"type": "MemberExpression",
|
|
125
|
+
"object": {
|
|
126
|
+
"type": "MemberExpression",
|
|
127
|
+
"object": { "type": "Identifier", "name": "app" },
|
|
128
|
+
"computed": false,
|
|
129
|
+
"property": { "type": "Identifier", "name": "dataSources" }
|
|
130
|
+
},
|
|
131
|
+
"computed": false,
|
|
132
|
+
"property": { "type": "Identifier", "name": "defaultDS" }
|
|
133
|
+
},
|
|
134
|
+
"computed": false,
|
|
135
|
+
"property": { "type": "Identifier", "name": "entities" }
|
|
136
|
+
},
|
|
137
|
+
"computed": false,
|
|
138
|
+
"property": { "type": "Identifier", "name": "OrderProductEntity" }
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "ArrowFunctionExpression",
|
|
142
|
+
"id": null,
|
|
143
|
+
"generator": false,
|
|
144
|
+
"async": false,
|
|
145
|
+
"params": [{ "type": "Identifier", "name": "OrderProduct" }],
|
|
146
|
+
"body": {
|
|
147
|
+
"type": "CallExpression",
|
|
148
|
+
"callee": {
|
|
149
|
+
"type": "MemberExpression",
|
|
150
|
+
"object": { "type": "Identifier", "name": "$" },
|
|
151
|
+
"computed": false,
|
|
152
|
+
"property": { "type": "Identifier", "name": "INNER_JOIN" }
|
|
153
|
+
},
|
|
154
|
+
"arguments": [
|
|
155
|
+
{
|
|
156
|
+
"type": "MemberExpression",
|
|
157
|
+
"object": {
|
|
158
|
+
"type": "MemberExpression",
|
|
159
|
+
"object": {
|
|
160
|
+
"type": "MemberExpression",
|
|
161
|
+
"object": {
|
|
162
|
+
"type": "MemberExpression",
|
|
163
|
+
"object": { "type": "Identifier", "name": "app" },
|
|
164
|
+
"computed": false,
|
|
165
|
+
"property": { "type": "Identifier", "name": "dataSources" }
|
|
166
|
+
},
|
|
167
|
+
"computed": false,
|
|
168
|
+
"property": { "type": "Identifier", "name": "defaultDS" }
|
|
169
|
+
},
|
|
170
|
+
"computed": false,
|
|
171
|
+
"property": { "type": "Identifier", "name": "entities" }
|
|
172
|
+
},
|
|
173
|
+
"computed": false,
|
|
174
|
+
"property": { "type": "Identifier", "name": "OrderFormEntity" }
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"type": "ArrowFunctionExpression",
|
|
178
|
+
"id": null,
|
|
179
|
+
"generator": false,
|
|
180
|
+
"async": false,
|
|
181
|
+
"params": [{ "type": "Identifier", "name": "OrderForm" }],
|
|
182
|
+
"body": {
|
|
183
|
+
"type": "CallExpression",
|
|
184
|
+
"callee": {
|
|
185
|
+
"type": "MemberExpression",
|
|
186
|
+
"object": {
|
|
187
|
+
"type": "CallExpression",
|
|
188
|
+
"callee": { "type": "Identifier", "name": "ON" },
|
|
189
|
+
"arguments": [
|
|
190
|
+
{
|
|
191
|
+
"type": "ArrowFunctionExpression",
|
|
192
|
+
"id": null,
|
|
193
|
+
"generator": false,
|
|
194
|
+
"async": false,
|
|
195
|
+
"params": [],
|
|
196
|
+
"body": {
|
|
197
|
+
"type": "BinaryExpression",
|
|
198
|
+
"left": {
|
|
199
|
+
"type": "MemberExpression",
|
|
200
|
+
"object": {
|
|
201
|
+
"type": "Identifier",
|
|
202
|
+
"name": "OrderProduct"
|
|
203
|
+
},
|
|
204
|
+
"computed": false,
|
|
205
|
+
"property": {
|
|
206
|
+
"type": "Identifier",
|
|
207
|
+
"name": "orderId"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"operator": "==",
|
|
211
|
+
"right": {
|
|
212
|
+
"type": "MemberExpression",
|
|
213
|
+
"object": {
|
|
214
|
+
"type": "Identifier",
|
|
215
|
+
"name": "OrderForm"
|
|
216
|
+
},
|
|
217
|
+
"computed": false,
|
|
218
|
+
"property": { "type": "Identifier", "name": "id" }
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
"computed": false,
|
|
225
|
+
"property": { "type": "Identifier", "name": "INNER_JOIN" }
|
|
226
|
+
},
|
|
227
|
+
"arguments": [
|
|
228
|
+
{
|
|
229
|
+
"type": "MemberExpression",
|
|
230
|
+
"object": {
|
|
231
|
+
"type": "MemberExpression",
|
|
232
|
+
"object": {
|
|
233
|
+
"type": "MemberExpression",
|
|
234
|
+
"object": {
|
|
235
|
+
"type": "MemberExpression",
|
|
236
|
+
"object": { "type": "Identifier", "name": "app" },
|
|
237
|
+
"computed": false,
|
|
238
|
+
"property": {
|
|
239
|
+
"type": "Identifier",
|
|
240
|
+
"name": "dataSources"
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
"computed": false,
|
|
244
|
+
"property": { "type": "Identifier", "name": "defaultDS" }
|
|
245
|
+
},
|
|
246
|
+
"computed": false,
|
|
247
|
+
"property": { "type": "Identifier", "name": "entities" }
|
|
248
|
+
},
|
|
249
|
+
"computed": false,
|
|
250
|
+
"property": { "type": "Identifier", "name": "ProductEntity" }
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"type": "ArrowFunctionExpression",
|
|
254
|
+
"id": null,
|
|
255
|
+
"generator": false,
|
|
256
|
+
"async": false,
|
|
257
|
+
"params": [{ "type": "Identifier", "name": "Product" }],
|
|
258
|
+
"body": {
|
|
259
|
+
"type": "CallExpression",
|
|
260
|
+
"callee": {
|
|
261
|
+
"type": "MemberExpression",
|
|
262
|
+
"object": {
|
|
263
|
+
"type": "CallExpression",
|
|
264
|
+
"callee": {
|
|
265
|
+
"type": "MemberExpression",
|
|
266
|
+
"object": {
|
|
267
|
+
"type": "CallExpression",
|
|
268
|
+
"callee": {
|
|
269
|
+
"type": "MemberExpression",
|
|
270
|
+
"object": {
|
|
271
|
+
"type": "CallExpression",
|
|
272
|
+
"callee": {
|
|
273
|
+
"type": "MemberExpression",
|
|
274
|
+
"object": {
|
|
275
|
+
"type": "CallExpression",
|
|
276
|
+
"callee": {
|
|
277
|
+
"type": "Identifier",
|
|
278
|
+
"name": "ON"
|
|
279
|
+
},
|
|
280
|
+
"arguments": [
|
|
281
|
+
{
|
|
282
|
+
"type": "ArrowFunctionExpression",
|
|
283
|
+
"id": null,
|
|
284
|
+
"generator": false,
|
|
285
|
+
"async": false,
|
|
286
|
+
"params": [],
|
|
287
|
+
"body": {
|
|
288
|
+
"type": "BinaryExpression",
|
|
289
|
+
"left": {
|
|
290
|
+
"type": "MemberExpression",
|
|
291
|
+
"object": {
|
|
292
|
+
"type": "Identifier",
|
|
293
|
+
"name": "OrderProduct"
|
|
294
|
+
},
|
|
295
|
+
"computed": false,
|
|
296
|
+
"property": {
|
|
297
|
+
"type": "Identifier",
|
|
298
|
+
"name": "productId"
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
"operator": "==",
|
|
302
|
+
"right": {
|
|
303
|
+
"type": "MemberExpression",
|
|
304
|
+
"object": {
|
|
305
|
+
"type": "Identifier",
|
|
306
|
+
"name": "Product"
|
|
307
|
+
},
|
|
308
|
+
"computed": false,
|
|
309
|
+
"property": {
|
|
310
|
+
"type": "Identifier",
|
|
311
|
+
"name": "id"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
]
|
|
317
|
+
},
|
|
318
|
+
"computed": false,
|
|
319
|
+
"property": {
|
|
320
|
+
"type": "Identifier",
|
|
321
|
+
"name": "WHERE"
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
"arguments": [
|
|
325
|
+
{
|
|
326
|
+
"type": "ArrowFunctionExpression",
|
|
327
|
+
"id": null,
|
|
328
|
+
"generator": false,
|
|
329
|
+
"async": false,
|
|
330
|
+
"params": [],
|
|
331
|
+
"body": {
|
|
332
|
+
"type": "LogicalExpression",
|
|
333
|
+
"left": {
|
|
334
|
+
"type": "BinaryExpression",
|
|
335
|
+
"left": {
|
|
336
|
+
"type": "MemberExpression",
|
|
337
|
+
"object": {
|
|
338
|
+
"type": "Identifier",
|
|
339
|
+
"name": "OrderProduct"
|
|
340
|
+
},
|
|
341
|
+
"computed": false,
|
|
342
|
+
"property": {
|
|
343
|
+
"type": "Identifier",
|
|
344
|
+
"name": "createdBy"
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
"operator": "==",
|
|
348
|
+
"right": {
|
|
349
|
+
"type": "StringLiteral",
|
|
350
|
+
"value": "张三"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"operator": "&&",
|
|
354
|
+
"right": {
|
|
355
|
+
"type": "BinaryExpression",
|
|
356
|
+
"left": {
|
|
357
|
+
"type": "MemberExpression",
|
|
358
|
+
"object": {
|
|
359
|
+
"type": "Identifier",
|
|
360
|
+
"name": "OrderProduct"
|
|
361
|
+
},
|
|
362
|
+
"computed": false,
|
|
363
|
+
"property": {
|
|
364
|
+
"type": "Identifier",
|
|
365
|
+
"name": "createdTime"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"operator": ">",
|
|
369
|
+
"right": {
|
|
370
|
+
"type": "Identifier",
|
|
371
|
+
"name": "startDateTime"
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
"computed": false,
|
|
379
|
+
"property": {
|
|
380
|
+
"type": "Identifier",
|
|
381
|
+
"name": "GROUP_BY"
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
"arguments": [
|
|
385
|
+
{
|
|
386
|
+
"type": "ArrowFunctionExpression",
|
|
387
|
+
"id": null,
|
|
388
|
+
"generator": false,
|
|
389
|
+
"async": false,
|
|
390
|
+
"params": [],
|
|
391
|
+
"body": {
|
|
392
|
+
"type": "MemberExpression",
|
|
393
|
+
"object": {
|
|
394
|
+
"type": "Identifier",
|
|
395
|
+
"name": "OrderProduct"
|
|
396
|
+
},
|
|
397
|
+
"computed": false,
|
|
398
|
+
"property": {
|
|
399
|
+
"type": "Identifier",
|
|
400
|
+
"name": "productId"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"type": "MemberExpression",
|
|
406
|
+
"object": {
|
|
407
|
+
"type": "Identifier",
|
|
408
|
+
"name": "Product"
|
|
409
|
+
},
|
|
410
|
+
"computed": false,
|
|
411
|
+
"property": {
|
|
412
|
+
"type": "Identifier",
|
|
413
|
+
"name": "name"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
},
|
|
418
|
+
"computed": false,
|
|
419
|
+
"property": {
|
|
420
|
+
"type": "Identifier",
|
|
421
|
+
"name": "ORDER_BY"
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
"arguments": [
|
|
425
|
+
{
|
|
426
|
+
"type": "ArrowFunctionExpression",
|
|
427
|
+
"id": null,
|
|
428
|
+
"generator": false,
|
|
429
|
+
"async": false,
|
|
430
|
+
"params": [],
|
|
431
|
+
"body": {
|
|
432
|
+
"type": "ArrayExpression",
|
|
433
|
+
"elements": [
|
|
434
|
+
{ "type": "Identifier", "name": "productName" },
|
|
435
|
+
{ "type": "StringLiteral", "value": "ASC" }
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
},
|
|
441
|
+
"computed": false,
|
|
442
|
+
"property": { "type": "Identifier", "name": "SELECT" }
|
|
443
|
+
},
|
|
444
|
+
"arguments": [
|
|
445
|
+
{
|
|
446
|
+
"type": "ArrowFunctionExpression",
|
|
447
|
+
"id": null,
|
|
448
|
+
"generator": false,
|
|
449
|
+
"async": false,
|
|
450
|
+
"params": [],
|
|
451
|
+
"body": {
|
|
452
|
+
"type": "ObjectExpression",
|
|
453
|
+
"properties": [
|
|
454
|
+
{
|
|
455
|
+
"type": "ObjectProperty",
|
|
456
|
+
"method": false,
|
|
457
|
+
"key": {
|
|
458
|
+
"type": "Identifier",
|
|
459
|
+
"name": "orderProduct"
|
|
460
|
+
},
|
|
461
|
+
"computed": false,
|
|
462
|
+
"shorthand": false,
|
|
463
|
+
"value": {
|
|
464
|
+
"type": "Identifier",
|
|
465
|
+
"name": "OrderProduct"
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"type": "ObjectProperty",
|
|
470
|
+
"method": false,
|
|
471
|
+
"key": {
|
|
472
|
+
"type": "Identifier",
|
|
473
|
+
"name": "orderForm"
|
|
474
|
+
},
|
|
475
|
+
"computed": false,
|
|
476
|
+
"shorthand": false,
|
|
477
|
+
"value": {
|
|
478
|
+
"type": "Identifier",
|
|
479
|
+
"name": "OrderForm"
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"type": "ObjectProperty",
|
|
484
|
+
"method": false,
|
|
485
|
+
"key": {
|
|
486
|
+
"type": "Identifier",
|
|
487
|
+
"name": "product"
|
|
488
|
+
},
|
|
489
|
+
"computed": false,
|
|
490
|
+
"shorthand": false,
|
|
491
|
+
"value": {
|
|
492
|
+
"type": "Identifier",
|
|
493
|
+
"name": "Product"
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
"type": "ObjectProperty",
|
|
498
|
+
"method": false,
|
|
499
|
+
"key": {
|
|
500
|
+
"type": "Identifier",
|
|
501
|
+
"name": "totalAmount"
|
|
502
|
+
},
|
|
503
|
+
"computed": false,
|
|
504
|
+
"shorthand": false,
|
|
505
|
+
"value": {
|
|
506
|
+
"type": "CallExpression",
|
|
507
|
+
"callee": {
|
|
508
|
+
"type": "Identifier",
|
|
509
|
+
"name": "SUM"
|
|
510
|
+
},
|
|
511
|
+
"arguments": [
|
|
512
|
+
{
|
|
513
|
+
"type": "MemberExpression",
|
|
514
|
+
"object": {
|
|
515
|
+
"type": "Identifier",
|
|
516
|
+
"name": "OrderProduct"
|
|
517
|
+
},
|
|
518
|
+
"computed": false,
|
|
519
|
+
"property": {
|
|
520
|
+
"type": "Identifier",
|
|
521
|
+
"name": "amount"
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
]
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"type": "ObjectProperty",
|
|
529
|
+
"method": false,
|
|
530
|
+
"key": {
|
|
531
|
+
"type": "Identifier",
|
|
532
|
+
"name": "productId"
|
|
533
|
+
},
|
|
534
|
+
"computed": false,
|
|
535
|
+
"shorthand": false,
|
|
536
|
+
"value": {
|
|
537
|
+
"type": "MemberExpression",
|
|
538
|
+
"object": {
|
|
539
|
+
"type": "Identifier",
|
|
540
|
+
"name": "OrderProduct"
|
|
541
|
+
},
|
|
542
|
+
"computed": false,
|
|
543
|
+
"property": {
|
|
544
|
+
"type": "Identifier",
|
|
545
|
+
"name": "productId"
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"type": "ObjectProperty",
|
|
551
|
+
"method": false,
|
|
552
|
+
"key": {
|
|
553
|
+
"type": "Identifier",
|
|
554
|
+
"name": "productName"
|
|
555
|
+
},
|
|
556
|
+
"computed": false,
|
|
557
|
+
"shorthand": false,
|
|
558
|
+
"value": {
|
|
559
|
+
"type": "MemberExpression",
|
|
560
|
+
"object": {
|
|
561
|
+
"type": "Identifier",
|
|
562
|
+
"name": "Product"
|
|
563
|
+
},
|
|
564
|
+
"computed": false,
|
|
565
|
+
"property": {
|
|
566
|
+
"type": "Identifier",
|
|
567
|
+
"name": "name"
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
]
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
]
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
]
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
这部分会传入 transformCall2DataQuery 的第一个 node 参数中。
|
|
587
|
+
|
|
588
|
+
babel parse 后 json 是用 type 字段来表示 babelTypes 的类型的。 expected JSON 中是用 concept 字段来表示 naslTypes 类型的。
|
|
589
|
+
|
|
590
|
+
flatMemberExpression 你不要实现了..已经有了!! 另外你不要省略实现,就是让你来写代码的!!
|
|
591
|
+
|
|
592
|
+
transformCall2DataQuery 不完善,需要你这边修改。理解和补充 transformCall2DataQuery 中 flatCallExpressionAndArrowFunctionExpression 和 flatted.forEach 中的部分
|
|
593
|
+
你是一个 Agent,你可以多次执行 action,直到 current state 中没有错误。
|
|
594
|
+
`,
|
|
595
|
+
command: 'npm run test:tdd-transform',
|
|
596
|
+
includes: ['src/concepts', 'src/natural', 'test/tdd/transform'],
|
|
597
|
+
excludes: ['node_modules', 'out', 'src/concepts/basics', 'src/concepts/utils'],
|
|
598
|
+
waitBeforeRun: 1500,
|
|
599
|
+
watchFiles: [async () => {
|
|
600
|
+
const content = await fs.readFile(path.join(__dirname, 'ts.log'), 'utf-8');
|
|
601
|
+
|
|
602
|
+
const separator = 'Starting incremental compilation...';
|
|
603
|
+
if (content.includes(separator)) {
|
|
604
|
+
const index = content.lastIndexOf(separator);
|
|
605
|
+
return content.slice(index);
|
|
606
|
+
}
|
|
607
|
+
return content;
|
|
608
|
+
}],
|
|
609
|
+
referenceExamples: [
|
|
610
|
+
'src/natural/transforms/transform2LogicItem.ts#transform2NumericLiteral',
|
|
611
|
+
'src/natural/transforms/transform2LogicItem.ts#transformCall2Logging',
|
|
612
|
+
],
|
|
613
|
+
currentCode: [
|
|
614
|
+
'src/natural/transforms/transform2LogicItem.ts#flatMemberExpression',
|
|
615
|
+
'src/natural/transforms/transform2LogicItem.ts#transformCall2DataQuery',
|
|
616
|
+
],
|
|
617
|
+
}
|
package/out/common/BaseNode.d.ts
CHANGED
|
@@ -338,11 +338,16 @@ export declare class BaseNode extends EventEmitter {
|
|
|
338
338
|
*/
|
|
339
339
|
traverseStrictChildren(cb: (el: types.SyntaxNode) => void, whitelist?: string[]): void;
|
|
340
340
|
/**
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
341
|
+
* 迭代所有子节点
|
|
342
|
+
*
|
|
343
|
+
* @description 严格迭代所有子节点!排除属性!条件满足时整个遍历全部终止!
|
|
344
|
+
*/
|
|
345
345
|
traverseStrictChildrenStopWhen(cb: (el: types.SyntaxNode) => void, setStopFlag: (el: types.SyntaxNode) => boolean, whitelist?: string[]): void;
|
|
346
|
+
/**
|
|
347
|
+
* 迭代所有子节点
|
|
348
|
+
* @description 严格迭代所有子节点,排除属性;多函数特化版本,不做额外检查
|
|
349
|
+
*/
|
|
350
|
+
traverseStrictChildrenDoMultiTasks(tasks: Array<(_: BaseNode) => Generator<any, any, any>>, cleanups: Array<(_: BaseNode) => Generator<any, any, any>>): Generator<any, any, any>;
|
|
346
351
|
/**
|
|
347
352
|
* 获取当前节点在nasl标注节点上的节点
|
|
348
353
|
*/
|