@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
package/src/utils/index.ts
CHANGED
|
@@ -296,10 +296,6 @@ export function getAncestorExistingParamNames(baseNode: types.SyntaxNode) {
|
|
|
296
296
|
names.add(param.name);
|
|
297
297
|
});
|
|
298
298
|
break;
|
|
299
|
-
case 'ForEachStatement':
|
|
300
|
-
names.add((node as ForEachStatement).item?.name);
|
|
301
|
-
names.add((node as ForEachStatement).index?.name);
|
|
302
|
-
break;
|
|
303
299
|
case 'Interface':
|
|
304
300
|
case 'Logic':
|
|
305
301
|
case 'View':
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { isNode } from '../env';
|
|
2
2
|
import { StoreName, DbName, NaslCacheLimit, tabId } from './constant';
|
|
3
3
|
import { LanguageDatabase, NaslCacheData, NaslCacheUpdateData } from './types';
|
|
4
|
+
import localforage from 'localforage';
|
|
5
|
+
|
|
6
|
+
export const naslOQLCacheStore = localforage.createInstance({
|
|
7
|
+
description: 'OQL to TypeScript接口缓存',
|
|
8
|
+
storeName: StoreName.OQLToTypeScript
|
|
9
|
+
});
|
|
4
10
|
|
|
5
11
|
/** 缓存数据库 */
|
|
6
12
|
const database = isNode
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
OrderProduct
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
OrderProduct.amount
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
{
|
|
2
|
+
"concept": "Logic",
|
|
3
|
+
"name": "load1",
|
|
4
|
+
"params": [
|
|
5
|
+
{
|
|
6
|
+
"concept": "Param",
|
|
7
|
+
"name": "startDateTime",
|
|
8
|
+
"typeAnnotation": {
|
|
9
|
+
"concept": "TypeAnnotation",
|
|
10
|
+
"typeKind": "primitive",
|
|
11
|
+
"typeNamespace": "nasl.core",
|
|
12
|
+
"typeName": "DateTime"
|
|
13
|
+
},
|
|
14
|
+
"cascader": false
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"returns": [
|
|
18
|
+
{
|
|
19
|
+
"concept": "Return",
|
|
20
|
+
"name": "result"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"variables": [],
|
|
24
|
+
"body": [
|
|
25
|
+
{
|
|
26
|
+
"concept": "Start",
|
|
27
|
+
"folded": false
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"concept": "Assignment",
|
|
31
|
+
"left": {
|
|
32
|
+
"concept": "Identifier",
|
|
33
|
+
"name": "result",
|
|
34
|
+
"folded": false
|
|
35
|
+
},
|
|
36
|
+
"right": {
|
|
37
|
+
"concept": "CallQueryComponent",
|
|
38
|
+
"select": {
|
|
39
|
+
"concept": "QuerySelectExpression",
|
|
40
|
+
"distinct": false,
|
|
41
|
+
"star": true,
|
|
42
|
+
"selectElements": [
|
|
43
|
+
{
|
|
44
|
+
"concept": "QueryFieldExpression",
|
|
45
|
+
"isDotStar": true,
|
|
46
|
+
"entityAsName": "OrderProduct",
|
|
47
|
+
"propertyName": "",
|
|
48
|
+
"folded": false
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"concept": "QueryFieldExpression",
|
|
52
|
+
"isDotStar": true,
|
|
53
|
+
"entityAsName": "OrderForm",
|
|
54
|
+
"propertyName": "",
|
|
55
|
+
"folded": false
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"concept": "QueryFieldExpression",
|
|
59
|
+
"isDotStar": true,
|
|
60
|
+
"entityAsName": "Product",
|
|
61
|
+
"propertyName": "",
|
|
62
|
+
"folded": false
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"concept": "QueryAggregateExpression",
|
|
66
|
+
"asName": "totalAmount",
|
|
67
|
+
"aggregateName": "SUM",
|
|
68
|
+
"aggregateParam": {
|
|
69
|
+
"concept": "QueryFieldExpression",
|
|
70
|
+
"isDotStar": false,
|
|
71
|
+
"entityAsName": "OrderProduct",
|
|
72
|
+
"propertyName": "amount",
|
|
73
|
+
"folded": false
|
|
74
|
+
},
|
|
75
|
+
"folded": false
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"folded": false
|
|
79
|
+
},
|
|
80
|
+
"from": {
|
|
81
|
+
"concept": "QueryFromExpression",
|
|
82
|
+
"entityNamespace": "app.dataSources.defaultDS.entities",
|
|
83
|
+
"entityName": "OrderProduct",
|
|
84
|
+
"joinParts": [
|
|
85
|
+
{
|
|
86
|
+
"concept": "QueryJoinExpression",
|
|
87
|
+
"entityNamespace": "app.dataSources.defaultDS.entities",
|
|
88
|
+
"entityName": "OrderForm",
|
|
89
|
+
"joinType": "INNER",
|
|
90
|
+
"onExpressions": [
|
|
91
|
+
{
|
|
92
|
+
"concept": "BinaryExpression",
|
|
93
|
+
"left": {
|
|
94
|
+
"concept": "QueryFieldExpression",
|
|
95
|
+
"isDotStar": false,
|
|
96
|
+
"entityAsName": "OrderProduct",
|
|
97
|
+
"propertyName": "orderId",
|
|
98
|
+
"folded": false
|
|
99
|
+
},
|
|
100
|
+
"right": {
|
|
101
|
+
"concept": "QueryFieldExpression",
|
|
102
|
+
"isDotStar": false,
|
|
103
|
+
"entityAsName": "OrderForm",
|
|
104
|
+
"propertyName": "id",
|
|
105
|
+
"folded": false
|
|
106
|
+
},
|
|
107
|
+
"operator": "==",
|
|
108
|
+
"folded": false
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"joinParts": [],
|
|
112
|
+
"folded": false
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"concept": "QueryJoinExpression",
|
|
116
|
+
"entityNamespace": "app.dataSources.defaultDS.entities",
|
|
117
|
+
"entityName": "Product",
|
|
118
|
+
"joinType": "INNER",
|
|
119
|
+
"onExpressions": [
|
|
120
|
+
{
|
|
121
|
+
"concept": "BinaryExpression",
|
|
122
|
+
"left": {
|
|
123
|
+
"concept": "QueryFieldExpression",
|
|
124
|
+
"isDotStar": false,
|
|
125
|
+
"entityAsName": "OrderProduct",
|
|
126
|
+
"propertyName": "productId",
|
|
127
|
+
"folded": false
|
|
128
|
+
},
|
|
129
|
+
"right": {
|
|
130
|
+
"concept": "QueryFieldExpression",
|
|
131
|
+
"isDotStar": false,
|
|
132
|
+
"entityAsName": "Product",
|
|
133
|
+
"propertyName": "id",
|
|
134
|
+
"folded": false
|
|
135
|
+
},
|
|
136
|
+
"operator": "==",
|
|
137
|
+
"folded": false
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"joinParts": [],
|
|
141
|
+
"folded": false
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"folded": false
|
|
145
|
+
},
|
|
146
|
+
"where": {
|
|
147
|
+
"concept": "BinaryExpression",
|
|
148
|
+
"left": {
|
|
149
|
+
"concept": "BinaryExpression",
|
|
150
|
+
"left": {
|
|
151
|
+
"concept": "QueryFieldExpression",
|
|
152
|
+
"isDotStar": false,
|
|
153
|
+
"entityAsName": "OrderProduct",
|
|
154
|
+
"propertyName": "createdBy",
|
|
155
|
+
"folded": false
|
|
156
|
+
},
|
|
157
|
+
"right": {
|
|
158
|
+
"concept": "StringLiteral",
|
|
159
|
+
"value": "张三",
|
|
160
|
+
"folded": false
|
|
161
|
+
},
|
|
162
|
+
"operator": "==",
|
|
163
|
+
"folded": false
|
|
164
|
+
},
|
|
165
|
+
"right": {
|
|
166
|
+
"concept": "BinaryExpression",
|
|
167
|
+
"left": {
|
|
168
|
+
"concept": "QueryFieldExpression",
|
|
169
|
+
"isDotStar": false,
|
|
170
|
+
"entityAsName": "OrderProduct",
|
|
171
|
+
"propertyName": "createdTime",
|
|
172
|
+
"folded": false
|
|
173
|
+
},
|
|
174
|
+
"right": {
|
|
175
|
+
"concept": "Identifier",
|
|
176
|
+
"name": "startDateTime",
|
|
177
|
+
"folded": false
|
|
178
|
+
},
|
|
179
|
+
"operator": ">",
|
|
180
|
+
"folded": false
|
|
181
|
+
},
|
|
182
|
+
"operator": "&&",
|
|
183
|
+
"folded": false
|
|
184
|
+
},
|
|
185
|
+
"wherePlayground": [],
|
|
186
|
+
"groupBy": [
|
|
187
|
+
{
|
|
188
|
+
"concept": "QueryGroupByExpression",
|
|
189
|
+
"groupElement": {
|
|
190
|
+
"concept": "QueryFieldExpression",
|
|
191
|
+
"isDotStar": false,
|
|
192
|
+
"asName": "productId",
|
|
193
|
+
"entityAsName": "OrderProduct",
|
|
194
|
+
"propertyName": "productId",
|
|
195
|
+
"folded": false
|
|
196
|
+
},
|
|
197
|
+
"folded": false
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"concept": "QueryGroupByExpression",
|
|
201
|
+
"groupElement": {
|
|
202
|
+
"concept": "QueryFieldExpression",
|
|
203
|
+
"isDotStar": false,
|
|
204
|
+
"asName": "productName",
|
|
205
|
+
"entityAsName": "Product",
|
|
206
|
+
"propertyName": "name",
|
|
207
|
+
"folded": false
|
|
208
|
+
},
|
|
209
|
+
"folded": false
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
"having": null,
|
|
213
|
+
"havingPlayground": [],
|
|
214
|
+
"orderBy": [
|
|
215
|
+
{
|
|
216
|
+
"concept": "QueryOrderByExpression",
|
|
217
|
+
"orderElement": {
|
|
218
|
+
"concept": "Identifier",
|
|
219
|
+
"namespace": "inner",
|
|
220
|
+
"name": "productName",
|
|
221
|
+
"folded": false
|
|
222
|
+
},
|
|
223
|
+
"order": {
|
|
224
|
+
"concept": "StringLiteral",
|
|
225
|
+
"value": "ASC",
|
|
226
|
+
"folded": false
|
|
227
|
+
},
|
|
228
|
+
"folded": false
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"limit": null,
|
|
232
|
+
"ideVersion": "2.22",
|
|
233
|
+
"folded": false
|
|
234
|
+
},
|
|
235
|
+
"folded": false
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"concept": "End",
|
|
239
|
+
"folded": false
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"playground": []
|
|
243
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function load1(startDateTime: DateTime) {
|
|
3
|
+
let result;
|
|
4
|
+
result = FROM(app.dataSources.defaultDS.entities.OrderProductEntity, OrderProduct => $
|
|
5
|
+
.INNER_JOIN(app.dataSources.defaultDS.entities.OrderFormEntity, OrderForm => ON(OrderProduct.orderId == OrderForm.id)
|
|
6
|
+
.INNER_JOIN(app.dataSources.defaultDS.entities.ProductEntity, Product => ON(OrderProduct.productId == Product.id)
|
|
7
|
+
.WHERE(OrderProduct.createdBy == '张三' && OrderProduct.createdTime > startDateTime)
|
|
8
|
+
.GROUP_BY(OrderProduct.productId, Product.name)
|
|
9
|
+
.ORDER_BY([productName, 'ASC'])
|
|
10
|
+
.SELECT({
|
|
11
|
+
orderProduct: OrderProduct,
|
|
12
|
+
orderForm: OrderForm,
|
|
13
|
+
product: Product,
|
|
14
|
+
totalAmount: SUM(OrderProduct.amount),
|
|
15
|
+
productId: OrderProduct.productId,
|
|
16
|
+
productName: Product.name,
|
|
17
|
+
}))));
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
{
|
|
2
|
+
"concept": "Logic",
|
|
3
|
+
"name": "loadDashboardTableView_1",
|
|
4
|
+
"params": [
|
|
5
|
+
{
|
|
6
|
+
"concept": "Param",
|
|
7
|
+
"name": "page",
|
|
8
|
+
"typeAnnotation": {
|
|
9
|
+
"concept": "TypeAnnotation",
|
|
10
|
+
"typeKind": "primitive",
|
|
11
|
+
"typeNamespace": "nasl.core",
|
|
12
|
+
"typeName": "Long"
|
|
13
|
+
},
|
|
14
|
+
"cascader": false
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"concept": "Param",
|
|
18
|
+
"name": "size",
|
|
19
|
+
"typeAnnotation": {
|
|
20
|
+
"concept": "TypeAnnotation",
|
|
21
|
+
"typeKind": "primitive",
|
|
22
|
+
"typeNamespace": "nasl.core",
|
|
23
|
+
"typeName": "Long"
|
|
24
|
+
},
|
|
25
|
+
"cascader": false
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"concept": "Param",
|
|
29
|
+
"name": "sort",
|
|
30
|
+
"typeAnnotation": {
|
|
31
|
+
"concept": "TypeAnnotation",
|
|
32
|
+
"typeKind": "primitive",
|
|
33
|
+
"typeNamespace": "nasl.core",
|
|
34
|
+
"typeName": "String"
|
|
35
|
+
},
|
|
36
|
+
"cascader": false
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"concept": "Param",
|
|
40
|
+
"name": "order",
|
|
41
|
+
"typeAnnotation": {
|
|
42
|
+
"concept": "TypeAnnotation",
|
|
43
|
+
"typeKind": "primitive",
|
|
44
|
+
"typeNamespace": "nasl.core",
|
|
45
|
+
"typeName": "String"
|
|
46
|
+
},
|
|
47
|
+
"cascader": false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"concept": "Param",
|
|
51
|
+
"name": "filter",
|
|
52
|
+
"typeAnnotation": {
|
|
53
|
+
"concept": "TypeAnnotation",
|
|
54
|
+
"typeKind": "reference",
|
|
55
|
+
"typeNamespace": "app.dataSources.defaultDS.entities",
|
|
56
|
+
"typeName": "Student"
|
|
57
|
+
},
|
|
58
|
+
"cascader": false
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"returns": [
|
|
62
|
+
{
|
|
63
|
+
"concept": "Return",
|
|
64
|
+
"name": "result"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"variables": [],
|
|
68
|
+
"body": [
|
|
69
|
+
{
|
|
70
|
+
"concept": "Start",
|
|
71
|
+
"folded": false
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"concept": "Assignment",
|
|
75
|
+
"left": {
|
|
76
|
+
"concept": "Identifier",
|
|
77
|
+
"name": "result",
|
|
78
|
+
"folded": false
|
|
79
|
+
},
|
|
80
|
+
"right": {
|
|
81
|
+
"concept": "Paginate",
|
|
82
|
+
"list": {
|
|
83
|
+
"concept": "CallQueryComponent",
|
|
84
|
+
"select": {
|
|
85
|
+
"concept": "QuerySelectExpression",
|
|
86
|
+
"distinct": false,
|
|
87
|
+
"star": true,
|
|
88
|
+
"selectElements": [
|
|
89
|
+
{
|
|
90
|
+
"concept": "QueryFieldExpression",
|
|
91
|
+
"isDotStar": true,
|
|
92
|
+
"entityAsName": "Student",
|
|
93
|
+
"propertyName": "",
|
|
94
|
+
"folded": false
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"folded": false
|
|
98
|
+
},
|
|
99
|
+
"from": {
|
|
100
|
+
"concept": "QueryFromExpression",
|
|
101
|
+
"entityNamespace": "app.dataSources.defaultDS.entities",
|
|
102
|
+
"entityName": "Student",
|
|
103
|
+
"joinParts": [],
|
|
104
|
+
"folded": false
|
|
105
|
+
},
|
|
106
|
+
"where": {
|
|
107
|
+
"concept": "BinaryExpression",
|
|
108
|
+
"left": {
|
|
109
|
+
"concept": "BinaryExpression",
|
|
110
|
+
"left": {
|
|
111
|
+
"concept": "QueryFieldExpression",
|
|
112
|
+
"isDotStar": false,
|
|
113
|
+
"entityAsName": "Student",
|
|
114
|
+
"propertyName": "name",
|
|
115
|
+
"folded": false
|
|
116
|
+
},
|
|
117
|
+
"right": {
|
|
118
|
+
"concept": "MemberExpression",
|
|
119
|
+
"object": {
|
|
120
|
+
"concept": "Identifier",
|
|
121
|
+
"name": "filter",
|
|
122
|
+
"folded": false
|
|
123
|
+
},
|
|
124
|
+
"property": {
|
|
125
|
+
"concept": "Identifier",
|
|
126
|
+
"name": "name",
|
|
127
|
+
"folded": false
|
|
128
|
+
},
|
|
129
|
+
"folded": false
|
|
130
|
+
},
|
|
131
|
+
"operator": "like",
|
|
132
|
+
"folded": false
|
|
133
|
+
},
|
|
134
|
+
"right": {
|
|
135
|
+
"concept": "BinaryExpression",
|
|
136
|
+
"left": {
|
|
137
|
+
"concept": "QueryFieldExpression",
|
|
138
|
+
"isDotStar": false,
|
|
139
|
+
"entityAsName": "Student",
|
|
140
|
+
"propertyName": "age",
|
|
141
|
+
"folded": false
|
|
142
|
+
},
|
|
143
|
+
"right": {
|
|
144
|
+
"concept": "MemberExpression",
|
|
145
|
+
"object": {
|
|
146
|
+
"concept": "Identifier",
|
|
147
|
+
"name": "filter",
|
|
148
|
+
"folded": false
|
|
149
|
+
},
|
|
150
|
+
"property": {
|
|
151
|
+
"concept": "Identifier",
|
|
152
|
+
"name": "age",
|
|
153
|
+
"folded": false
|
|
154
|
+
},
|
|
155
|
+
"folded": false
|
|
156
|
+
},
|
|
157
|
+
"operator": "==",
|
|
158
|
+
"folded": false
|
|
159
|
+
},
|
|
160
|
+
"operator": "&&",
|
|
161
|
+
"folded": false
|
|
162
|
+
},
|
|
163
|
+
"wherePlayground": [],
|
|
164
|
+
"groupBy": [],
|
|
165
|
+
"having": null,
|
|
166
|
+
"havingPlayground": [],
|
|
167
|
+
"orderBy": [
|
|
168
|
+
{
|
|
169
|
+
"concept": "QueryOrderByExpression",
|
|
170
|
+
"orderElement": {
|
|
171
|
+
"concept": "Identifier",
|
|
172
|
+
"name": "sort",
|
|
173
|
+
"folded": false
|
|
174
|
+
},
|
|
175
|
+
"order": {
|
|
176
|
+
"concept": "Identifier",
|
|
177
|
+
"name": "order",
|
|
178
|
+
"folded": false
|
|
179
|
+
},
|
|
180
|
+
"folded": false
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
"limit": null,
|
|
184
|
+
"ideVersion": "2.22",
|
|
185
|
+
"folded": false
|
|
186
|
+
},
|
|
187
|
+
"page": {
|
|
188
|
+
"concept": "Identifier",
|
|
189
|
+
"name": "page",
|
|
190
|
+
"folded": false
|
|
191
|
+
},
|
|
192
|
+
"size": {
|
|
193
|
+
"concept": "Identifier",
|
|
194
|
+
"name": "size",
|
|
195
|
+
"folded": false
|
|
196
|
+
},
|
|
197
|
+
"folded": false
|
|
198
|
+
},
|
|
199
|
+
"folded": false
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"concept": "End",
|
|
203
|
+
"folded": false
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"playground": []
|
|
207
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
function loadDashboardTableView_1(page: Long, size: Long, sort: String, order: String, filter: app.dataSources.defaultDS.entities.Student) {
|
|
3
|
+
let result;
|
|
4
|
+
result = PAGINATE(FROM(app.dataSources.defaultDS.entities.StudentEntity, Student => $
|
|
5
|
+
.WHERE(LIKE(Student.name, filter.name) && Student.age == filter.age)
|
|
6
|
+
.ORDER_BY([sort, order])
|
|
7
|
+
.SELECT(({
|
|
8
|
+
student: Student,
|
|
9
|
+
}))), page, size)
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
```
|
package/test/tdd.test.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { loadCase, createTestTree } = require('./utils');
|
|
3
|
+
const { suite, test } = require('mocha');
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
const nasl = require('../out');
|
|
6
|
+
|
|
7
|
+
// createTestTree(path.join(__dirname, 'tdd'), (dir, fileName) => {
|
|
8
|
+
// const { astJSON, naturalTS } = loadCase(path.join(dir, fileName));
|
|
9
|
+
// expect(nasl.BaseNode.from(astJSON).toNaturalTS()).equals(naturalTS);
|
|
10
|
+
// })();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { loadCase, createTestTree } = require('./utils');
|
|
3
|
+
const { suite, test } = require('mocha');
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
const nasl = require('../out');
|
|
6
|
+
const fs = require('fs-extra')
|
|
7
|
+
|
|
8
|
+
suite('transform', () => {
|
|
9
|
+
test('case1', () => {
|
|
10
|
+
const { astJSON, naturalTS } = loadCase('transform/case1');
|
|
11
|
+
const expectedJSON = JSON.parse(JSON.stringify(nasl.BaseNode.from(astJSON)));
|
|
12
|
+
const actualJSON = JSON.parse(JSON.stringify(nasl.transformTSCode(naturalTS)));
|
|
13
|
+
fs.outputJSONSync(path.join(__dirname, '../tmp', 'case1.parsed.json'), actualJSON, { spaces: 4 });
|
|
14
|
+
fs.outputJSONSync(path.join(__dirname, '../tmp', 'case1.source.json'), expectedJSON, { spaces: 4 });
|
|
15
|
+
try {
|
|
16
|
+
expect(actualJSON).to.deep.equal(expectedJSON);
|
|
17
|
+
} catch(err) {
|
|
18
|
+
// console.log('expectedJSON:', JSON.stringify(expectedJSON, null, 2));
|
|
19
|
+
// console.log('actualJSON:', JSON.stringify(expectedJSON, null, 2));
|
|
20
|
+
throw err;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('case2', () => {
|
|
25
|
+
const { astJSON, naturalTS } = loadCase('transform/case2');
|
|
26
|
+
const expectedJSON = JSON.parse(JSON.stringify(nasl.BaseNode.from(astJSON)));
|
|
27
|
+
const actualJSON = JSON.parse(JSON.stringify(nasl.transformTSCode(naturalTS)));
|
|
28
|
+
fs.outputJSONSync(path.join(__dirname, '../tmp', 'case2.parsed.json'), actualJSON, { spaces: 4 });
|
|
29
|
+
fs.outputJSONSync(path.join(__dirname, '../tmp', 'case2.source.json'), expectedJSON, { spaces: 4 });
|
|
30
|
+
try {
|
|
31
|
+
expect(actualJSON).to.deep.equal(expectedJSON);
|
|
32
|
+
} catch(err) {
|
|
33
|
+
// console.log('expectedJSON:', JSON.stringify(expectedJSON, null, 2));
|
|
34
|
+
// console.log('actualJSON:', JSON.stringify(expectedJSON, null, 2));
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
package/test/utils.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { suite, test } = require('mocha');
|
|
4
|
+
|
|
5
|
+
function unwrapCodeBlock(code) {
|
|
6
|
+
return code.replace(/^\s*```ts\n/, '').replace(/\n```\s*$/, '');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
exports.loadCase = function loadCase(dirPath) {
|
|
10
|
+
dirPath = path.resolve(__dirname, 'tdd', dirPath);
|
|
11
|
+
|
|
12
|
+
const astJSON = fs.readJSONSync(path.join(dirPath, 'ast.json'), 'utf-8');
|
|
13
|
+
const naturalTS = unwrapCodeBlock(fs.readFileSync(path.join(dirPath, 'natural.ts.md'), 'utf-8'));
|
|
14
|
+
|
|
15
|
+
return { astJSON, naturalTS };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.createTestTree = function createTestTree(dirPath, cb) {
|
|
19
|
+
function createTestList(dir) {
|
|
20
|
+
const list = fs
|
|
21
|
+
.readdirSync(dir)
|
|
22
|
+
.filter((fileName) => !fileName.startsWith('.') && !['node_modules', 'out'].includes(fileName));
|
|
23
|
+
const hasCase = list.some((fileName) => fileName.startsWith('case'));
|
|
24
|
+
|
|
25
|
+
if (hasCase) {
|
|
26
|
+
return () => {
|
|
27
|
+
list.forEach((fileName) => {
|
|
28
|
+
test(fileName, () => cb(dir, fileName));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
return () => {
|
|
33
|
+
list.forEach((fileName) => {
|
|
34
|
+
suite(fileName, createTestList(path.join(dir, fileName)));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return createTestList(dirPath);
|
|
40
|
+
};
|