@lcap/nasl 3.5.0-beta.3 → 3.5.0-beta.5
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/out/breakpoint/store/core.js +1 -1
- package/out/breakpoint/store/core.js.map +1 -1
- package/out/common/BaseNode.d.ts +7 -0
- package/out/common/BaseNode.js +15 -2
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +34 -16
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +1 -0
- package/out/concepts/Argument__.js +28 -8
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignment__.js +5 -7
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +5 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +1 -0
- package/out/concepts/BinaryExpression__.js +30 -13
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +11 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +3 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +2 -2
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +1 -0
- package/out/concepts/BooleanLiteral__.js +6 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +4 -2
- package/out/concepts/BusinessComponent__.js +128 -89
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/CallConnector__.d.ts +1 -0
- package/out/concepts/CallConnector__.js +6 -0
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallEvent__.d.ts +4 -0
- package/out/concepts/CallEvent__.js +19 -2
- package/out/concepts/CallEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +1 -0
- package/out/concepts/CallFunction__.js +62 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +31 -22
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +49 -38
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +2 -0
- package/out/concepts/CallQueryComponent__.js +94 -8
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/DefaultValue__.d.ts +1 -0
- package/out/concepts/DefaultValue__.js +7 -1
- package/out/concepts/DefaultValue__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +34 -22
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +1 -0
- package/out/concepts/EntityProperty__.js +26 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -0
- package/out/concepts/Entity__.js +25 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +1 -0
- package/out/concepts/EnumItem__.js +12 -0
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +16 -2
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.d.ts +4 -0
- package/out/concepts/Event__.js +12 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +10 -16
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendType__.js +1 -0
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +2 -0
- package/out/concepts/Identifier__.js +21 -0
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +6 -0
- package/out/concepts/LogicItem__.js +11 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +24 -23
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +5 -5
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +1 -1
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -0
- package/out/concepts/MemberExpression__.js +13 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js +3 -3
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +4 -4
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -1
- package/out/concepts/NewMap__.js +6 -5
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/NullLiteral__.d.ts +2 -0
- package/out/concepts/NullLiteral__.js +12 -0
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.d.ts +1 -0
- package/out/concepts/NumericLiteral__.js +7 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +4 -2
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -0
- package/out/concepts/Param__.js +41 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +9 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.d.ts +2 -0
- package/out/concepts/QueryAggregateExpression__.js +16 -0
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +2 -0
- package/out/concepts/QueryFieldExpression__.js +33 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +2 -0
- package/out/concepts/QueryFromExpression__.js +27 -0
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +2 -0
- package/out/concepts/QueryGroupByExpression__.js +13 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +2 -0
- package/out/concepts/QueryJoinExpression__.js +37 -0
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.d.ts +2 -0
- package/out/concepts/QueryLimitExpression__.js +16 -0
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +2 -0
- package/out/concepts/QueryOrderByExpression__.js +22 -0
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +3 -0
- package/out/concepts/QuerySelectExpression__.js +41 -0
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +1 -0
- package/out/concepts/SelectMembers__.js +7 -0
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +4 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringInterpolation__.d.ts +1 -0
- package/out/concepts/StringInterpolation__.js +20 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -0
- package/out/concepts/StringLiteral__.js +21 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +1 -0
- package/out/concepts/StructureProperty__.js +19 -0
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +1 -0
- package/out/concepts/Structure__.js +22 -7
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +1 -0
- package/out/concepts/TypeAnnotation__.js +42 -1
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +2 -1
- package/out/concepts/TypeParam__.js +7 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +2 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +72 -59
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +2 -1
- package/out/concepts/View__.js +6 -19
- package/out/concepts/View__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +4 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +4 -1
- package/out/natural/genNaturalTS.js +38 -1
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/transformTSCode.js +52 -41
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/formatTsUtils.js +10 -9
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getFunctions.js +3 -3
- package/out/server/getFunctions.js.map +1 -1
- package/out/server/getProcesses.js +3 -3
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +52 -17
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +8 -0
- package/out/server/translator.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +2 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -1
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +3 -3
- package/out/templator/utils.js.map +1 -1
- package/out/translator/types.d.ts +2 -0
- package/out/translator/utils.d.ts +2 -1
- package/out/translator/utils.js +44 -7
- package/out/translator/utils.js.map +1 -1
- package/out/utils/string.js +2 -2
- package/out/utils/string.js.map +1 -1
- package/out/utils/time-slicing/performance.js +3 -3
- package/out/utils/time-slicing/performance.js.map +1 -1
- package/package.json +2 -2
- package/src/breakpoint/store/core.ts +1 -1
- package/src/common/BaseNode.ts +17 -3
- package/src/concepts/AnonymousFunction__.ts +24 -9
- package/src/concepts/Argument__.ts +28 -6
- package/src/concepts/Assignment__.ts +5 -7
- package/src/concepts/BatchAssignment__.ts +6 -3
- package/src/concepts/BinaryExpression__.ts +30 -13
- package/src/concepts/BindAttribute__.ts +10 -3
- package/src/concepts/BindDirective__.ts +3 -3
- package/src/concepts/BindEvent__.ts +2 -2
- package/src/concepts/BooleanLiteral__.ts +5 -0
- package/src/concepts/BusinessComponent__.ts +144 -100
- package/src/concepts/CallConnector__.ts +5 -0
- package/src/concepts/CallEvent__.ts +20 -3
- package/src/concepts/CallFunction__.ts +54 -8
- package/src/concepts/CallInterface__.ts +31 -24
- package/src/concepts/CallLogic__.ts +48 -37
- package/src/concepts/CallQueryComponent__.ts +101 -8
- package/src/concepts/DefaultValue__.ts +6 -1
- package/src/concepts/Destination__.ts +32 -22
- package/src/concepts/EntityProperty__.ts +30 -2
- package/src/concepts/Entity__.ts +29 -0
- package/src/concepts/EnumItem__.ts +17 -0
- package/src/concepts/Enum__.ts +19 -2
- package/src/concepts/Event__.ts +13 -0
- package/src/concepts/ForEachStatement__.ts +10 -20
- package/src/concepts/FrontendType__.ts +1 -0
- package/src/concepts/Identifier__.ts +19 -0
- package/src/concepts/JSBlock__.ts +1 -1
- package/src/concepts/LogicItem__.ts +13 -1
- package/src/concepts/Logic__.ts +24 -24
- package/src/concepts/MatchCase__.ts +5 -5
- package/src/concepts/Match__.ts +1 -1
- package/src/concepts/MemberExpression__.ts +12 -3
- package/src/concepts/NewComposite__.ts +7 -9
- package/src/concepts/NewList__.ts +4 -4
- package/src/concepts/NewMap__.ts +6 -5
- package/src/concepts/NullLiteral__.ts +10 -0
- package/src/concepts/NumericLiteral__.ts +6 -1
- package/src/concepts/OqlQueryComponent__.ts +4 -2
- package/src/concepts/Param__.ts +39 -0
- package/src/concepts/ProcessElement__.ts +8 -1
- package/src/concepts/QueryAggregateExpression__.ts +15 -0
- package/src/concepts/QueryFieldExpression__.ts +34 -0
- package/src/concepts/QueryFromExpression__.ts +29 -0
- package/src/concepts/QueryGroupByExpression__.ts +11 -1
- package/src/concepts/QueryJoinExpression__.ts +39 -0
- package/src/concepts/QueryLimitExpression__.ts +14 -0
- package/src/concepts/QueryOrderByExpression__.ts +23 -0
- package/src/concepts/QuerySelectExpression__.ts +55 -0
- package/src/concepts/SelectMembers__.ts +7 -0
- package/src/concepts/SqlQueryComponent__.ts +4 -2
- package/src/concepts/StringInterpolation__.ts +18 -2
- package/src/concepts/StringLiteral__.ts +20 -1
- package/src/concepts/StructureProperty__.ts +22 -0
- package/src/concepts/Structure__.ts +24 -7
- package/src/concepts/SwitchCase__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +37 -1
- package/src/concepts/TypeParam__.ts +6 -1
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/ViewElement__.ts +74 -58
- package/src/concepts/View__.ts +6 -19
- package/src/generator/genBundleFiles.ts +6 -1
- package/src/natural/genNaturalTS.ts +41 -0
- package/src/natural/transformTSCode.ts +50 -42
- package/src/server/formatTsUtils.ts +16 -11
- package/src/server/getFunctions.ts +3 -3
- package/src/server/getProcesses.ts +3 -3
- package/src/server/naslServer.ts +56 -18
- package/src/server/translator.ts +7 -0
- package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -1
- package/src/templator/genGetBlock.ts +2 -1
- package/src/templator/genUpdateBlock.ts +2 -1
- package/src/templator/utils.ts +3 -3
- package/src/translator/types.ts +4 -0
- package/src/translator/utils.ts +73 -34
- package/src/utils/string.ts +2 -2
- package/src/utils/time-slicing/performance.ts +3 -3
- package/test/concepts/call-interface/__snapshots__/getQuickInfoOffset.spec.ts.snap +3 -3
- package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
- package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +199 -0
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +127 -6
- package/test/concepts/view-element/fixtures/table-data-source-calllogic-with-server-validation.json +2074 -0
- package/test/concepts/view-element/toVue.spec.ts +0 -1
- package/ts-worker/package.json +1 -1
- package/ts-worker/src/index.js +1 -0
|
@@ -274,6 +274,25 @@ export class Identifier extends LogicItem {
|
|
|
274
274
|
return self.namespace ? `${self.namespace}.${self.name}` : self.name || '__IDENTIFIER__';
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
@withSourceMap()
|
|
278
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
279
|
+
if (this.name === undefined)
|
|
280
|
+
console.log(this.toJSON(), this.parentNode.toJSON(), this.nodePath)
|
|
281
|
+
|
|
282
|
+
if (this.namespace) {
|
|
283
|
+
const namespace = this.namespace.replace(/^app\.frontendTypes\.(.+?\.)variables\.$/, '$1');
|
|
284
|
+
const name = Number.isInteger(Number(this.name)) ? `[${this.name}]` : this.name.includes('-') ? `['${this.name}']` : `.${this.name}`;
|
|
285
|
+
return `${namespace}${name}`;
|
|
286
|
+
} else {
|
|
287
|
+
return this.name;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@withSourceMap()
|
|
292
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
293
|
+
return this.namespace ? `${this.namespace}.${this.name}` : this.name;
|
|
294
|
+
}
|
|
295
|
+
|
|
277
296
|
// 方便快速取值
|
|
278
297
|
getValue() {
|
|
279
298
|
// 实体逻辑 deleteBy/updateBy 的 filter 参数的回调函数的参数:_
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
createCompilerState,
|
|
5
5
|
withSourceMapGenerator,
|
|
6
6
|
withGenerator,
|
|
7
|
+
withSourceMap,
|
|
7
8
|
TranslatorGenerator,
|
|
8
9
|
} from '../translator';
|
|
9
10
|
import { ElementToVueOptions } from './ViewElement__';
|
|
@@ -342,8 +343,19 @@ export class LogicItem extends BaseNode {
|
|
|
342
343
|
* @param state 编译状态
|
|
343
344
|
* @returns 生成的代码
|
|
344
345
|
*/
|
|
346
|
+
// @withSourceMap()
|
|
345
347
|
toNaturalTS(state = createCompilerState()): string {
|
|
346
|
-
return
|
|
348
|
+
return this.toTS(state);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* 生成文本化代码
|
|
353
|
+
* @param state 编译状态
|
|
354
|
+
* @returns 生成的代码
|
|
355
|
+
*/
|
|
356
|
+
// @withSourceMap()
|
|
357
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
358
|
+
return '[编译方法未实现]';
|
|
347
359
|
}
|
|
348
360
|
|
|
349
361
|
delete() {
|
package/src/concepts/Logic__.ts
CHANGED
|
@@ -2066,11 +2066,11 @@ export class Logic extends BaseNode {
|
|
|
2066
2066
|
toNaturalTS(state = createCompilerState(), prefix?: string, logicName?: string, currentNode?: BaseNode): string {
|
|
2067
2067
|
// 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
|
|
2068
2068
|
let code = '';
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
${indent(state.tabSize)} * 当前逻辑
|
|
2072
|
-
${indent(state.tabSize)} */\n`;
|
|
2073
|
-
|
|
2069
|
+
// if (currentNode === this) {
|
|
2070
|
+
// code += `\n${indent(state.tabSize)}/**
|
|
2071
|
+
// ${indent(state.tabSize)} * 当前逻辑
|
|
2072
|
+
// ${indent(state.tabSize)} */\n`;
|
|
2073
|
+
// }
|
|
2074
2074
|
if (!logicName) {
|
|
2075
2075
|
const { name, parentNode } = this;
|
|
2076
2076
|
if (parentNode?.concept === 'View') {
|
|
@@ -2107,22 +2107,22 @@ ${indent(state.tabSize)} */\n`;
|
|
|
2107
2107
|
code += ')';
|
|
2108
2108
|
|
|
2109
2109
|
// 需要类型推导的局部变量/返回值需要调整申明顺序
|
|
2110
|
-
const advanceMap: Map<Return | Variable, Assignment | BatchAssignment> = new Map();
|
|
2111
|
-
this.traverseChildren((el) => {
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
});
|
|
2110
|
+
// const advanceMap: Map<Return | Variable, Assignment | BatchAssignment> = new Map();
|
|
2111
|
+
// this.traverseChildren((el) => {
|
|
2112
|
+
// if (el && (asserts.isBatchAssignment(el) || (asserts.isAssignment(el) && el.left?.name))) {
|
|
2113
|
+
// const jsCode = el.toJS();
|
|
2114
|
+
// const advanceVar = this.variables?.find(
|
|
2115
|
+
// (variable) => !variable.typeAnnotation && jsCode.includes(`${variable.name} = `),
|
|
2116
|
+
// );
|
|
2117
|
+
// if (advanceVar && !advanceMap.get(advanceVar)) {
|
|
2118
|
+
// advanceMap.set(advanceVar, el);
|
|
2119
|
+
// }
|
|
2120
|
+
// const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && jsCode.includes(`${ret.name} = `));
|
|
2121
|
+
// if (advanceRn && !advanceMap.get(advanceRn)) {
|
|
2122
|
+
// advanceMap.set(advanceRn, el);
|
|
2123
|
+
// }
|
|
2124
|
+
// }
|
|
2125
|
+
// });
|
|
2126
2126
|
|
|
2127
2127
|
// 兼容 return 没有类型情况
|
|
2128
2128
|
if (this.returns.length && this.returns[0].typeAnnotation) {
|
|
@@ -2146,14 +2146,14 @@ ${indent(state.tabSize)} */\n`;
|
|
|
2146
2146
|
});
|
|
2147
2147
|
|
|
2148
2148
|
if (!this.body.length && this.returns.length) {
|
|
2149
|
-
if (!state.focusedNodePath || `${this.nodePath}.body[0]` === state.focusedNodePath)
|
|
2150
|
-
|
|
2149
|
+
// if (!state.focusedNodePath || `${this.nodePath}.body[0]` === state.focusedNodePath)
|
|
2150
|
+
// code += `${indent(state.tabSize + 1)}// 当前位置\n`;
|
|
2151
2151
|
code += `${indent(state.tabSize + 1)}return ${this.returns[0].name};\n`;
|
|
2152
2152
|
} else {
|
|
2153
2153
|
this.body.forEach((item) => {
|
|
2154
2154
|
let partialCode = '';
|
|
2155
2155
|
|
|
2156
|
-
if (!state.focusedNodePath && item.concept === 'End') code += `${indent(state.tabSize + 1)}// 当前位置\n`;
|
|
2156
|
+
// if (!state.focusedNodePath && item.concept === 'End') code += `${indent(state.tabSize + 1)}// 当前位置\n`;
|
|
2157
2157
|
if (item.toNaturalTS) {
|
|
2158
2158
|
partialCode = item.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
2159
2159
|
} else if (item.toEmbeddedTS) {
|
|
@@ -880,11 +880,11 @@ export class MatchCase extends LogicItem {
|
|
|
880
880
|
}
|
|
881
881
|
|
|
882
882
|
@withSourceMap()
|
|
883
|
-
toNaturalTS(state = createCompilerState(), index
|
|
883
|
+
toNaturalTS(state = createCompilerState(), index = 0, parentCode?: string): string {
|
|
884
884
|
let code = '\n';
|
|
885
885
|
|
|
886
886
|
const parentNode = this.parentNode as Match;
|
|
887
|
-
const length = parentNode?.cases?.length;
|
|
887
|
+
const length = parentNode?.cases?.length || 0;
|
|
888
888
|
|
|
889
889
|
if (length > 1) {
|
|
890
890
|
if (index !== length - 1) {
|
|
@@ -923,7 +923,7 @@ export class MatchCase extends LogicItem {
|
|
|
923
923
|
|
|
924
924
|
if (Array.isArray(this.body)) {
|
|
925
925
|
this.body.forEach((logicItem, bodyIndex) => {
|
|
926
|
-
if (bodyIndex === this.body.length - 1 &&
|
|
926
|
+
if (bodyIndex === this.body.length - 1 && (this.parentNode as Match)?.isExpression) {
|
|
927
927
|
code += indent(state.tabSize);
|
|
928
928
|
code += `return `;
|
|
929
929
|
}
|
|
@@ -941,7 +941,7 @@ export class MatchCase extends LogicItem {
|
|
|
941
941
|
code += indent(state.tabSize);
|
|
942
942
|
code += 'else {\n';
|
|
943
943
|
this.body.forEach((logicItem, bodyIndex) => {
|
|
944
|
-
if (bodyIndex === this.body.length - 1 &&
|
|
944
|
+
if (bodyIndex === this.body.length - 1 && (this.parentNode as Match)?.isExpression) {
|
|
945
945
|
code += indent(state.tabSize);
|
|
946
946
|
code += `return `;
|
|
947
947
|
}
|
|
@@ -957,7 +957,7 @@ export class MatchCase extends LogicItem {
|
|
|
957
957
|
}
|
|
958
958
|
} else {
|
|
959
959
|
this.body.forEach((logicItem, bodyIndex) => {
|
|
960
|
-
if (bodyIndex === this.body.length - 1 &&
|
|
960
|
+
if (bodyIndex === this.body.length - 1 && (this.parentNode as Match)?.isExpression) {
|
|
961
961
|
code += indent(state.tabSize);
|
|
962
962
|
code += `return `;
|
|
963
963
|
}
|
package/src/concepts/Match__.ts
CHANGED
|
@@ -532,9 +532,9 @@ export class MemberExpression extends LogicItem {
|
|
|
532
532
|
@withSourceMap()
|
|
533
533
|
toNaturalTS(state = createCompilerState()): string {
|
|
534
534
|
let code = '';
|
|
535
|
-
const leftCode = this.object ? `${this.object.toNaturalTS(shiftState(state, code, { inline: true }))}.` : '';
|
|
536
|
-
code += this.object ? `${this.object.toNaturalTS(shiftState(state, code, { inline: true }))}.` : '';
|
|
537
|
-
code += this.property ? this.property.toNaturalTS(shiftState(state, code, { inline: true })) : '';
|
|
535
|
+
const leftCode = this.object ? `${this.object.toNaturalTS(shiftState(state, code, { inline: true }))}.` : '__IDENTIFIER__';
|
|
536
|
+
code += this.object ? `${this.object.toNaturalTS(shiftState(state, code, { inline: true }))}.` : '__IDENTIFIER__';
|
|
537
|
+
code += this.property ? this.property.toNaturalTS(shiftState(state, code, { inline: true })) : '__IDENTIFIER__';
|
|
538
538
|
// 就说明这是一个枚举取值操作,直接啊app.enums.color.red 要转成字符串
|
|
539
539
|
// 解决枚举可能全是数字的问题
|
|
540
540
|
// app.enums.color || extensions.tool.enums.color
|
|
@@ -546,6 +546,15 @@ export class MemberExpression extends LogicItem {
|
|
|
546
546
|
return code;
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
@withSourceMap()
|
|
550
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
551
|
+
let code = '';
|
|
552
|
+
// const leftCode = this.object ? `${this.object.toTextualNASL(shiftState(state, code, { inline: true }))}.` : '';
|
|
553
|
+
code += this.object ? `${this.object.toTextualNASL(shiftState(state, code, { inline: true }))}.` : '__IDENTIFIER__';
|
|
554
|
+
code += this.property ? this.property.toTextualNASL(shiftState(state, code, { inline: true })) : '__IDENTIFIER__';
|
|
555
|
+
return code;
|
|
556
|
+
}
|
|
557
|
+
|
|
549
558
|
get lastObject() {
|
|
550
559
|
let tempNode: any = this;
|
|
551
560
|
while (tempNode?.object?.concept === 'MemberExpression') {
|
|
@@ -1179,13 +1179,11 @@ export class NewComposite extends LogicItem {
|
|
|
1179
1179
|
} else if (typeAnnotation.typeKind !== 'anonymousStructure') {
|
|
1180
1180
|
// 实体、数据结构默认值使用new时需要改成vue.prototype才能获取到方法
|
|
1181
1181
|
if (state?.getVuePrototype) {
|
|
1182
|
-
code += `const obj = Vue.prototype.$genInitFromSchema('${
|
|
1183
|
-
typeAnnotation.
|
|
1184
|
-
}', Vue.prototype.$utils['New'](${typeAnnotation.toJS(state)}));\n`;
|
|
1182
|
+
code += `const obj = Vue.prototype.$genInitFromSchema('${typeAnnotation.sortedTypeKey
|
|
1183
|
+
}', Vue.prototype.$utils['New'](${typeAnnotation.toJS(state)}));\n`;
|
|
1185
1184
|
} else {
|
|
1186
|
-
code += `const obj = this.$genInitFromSchema('${
|
|
1187
|
-
typeAnnotation.
|
|
1188
|
-
}', this.$utils['New'](${typeAnnotation.toJS(state)}));\n`;
|
|
1185
|
+
code += `const obj = this.$genInitFromSchema('${typeAnnotation.sortedTypeKey
|
|
1186
|
+
}', this.$utils['New'](${typeAnnotation.toJS(state)}));\n`;
|
|
1189
1187
|
}
|
|
1190
1188
|
const rightMap = new Map();
|
|
1191
1189
|
this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
@@ -1432,18 +1430,18 @@ export class NewComposite extends LogicItem {
|
|
|
1432
1430
|
let code = 'nasl.util.';
|
|
1433
1431
|
code +=
|
|
1434
1432
|
this?.typeAnnotation?.typeKind === 'anonymousStructure'
|
|
1435
|
-
? '
|
|
1433
|
+
? 'NewAnonymousStructure'
|
|
1436
1434
|
: `NewEntity<${this?.typeAnnotation?.typeName || '__IDENTIFIER__'}>`;
|
|
1437
1435
|
let params = '';
|
|
1438
1436
|
this?.properties?.forEach((item, index) => {
|
|
1439
1437
|
if (item) {
|
|
1440
1438
|
params += `${item?.toNaturalTS()}: ${this?.rights?.[index]?.expression?.toNaturalTS()}`;
|
|
1441
1439
|
if (index !== this.properties.length - 1) {
|
|
1442
|
-
params += '
|
|
1440
|
+
params += ', ';
|
|
1443
1441
|
}
|
|
1444
1442
|
}
|
|
1445
1443
|
});
|
|
1446
|
-
code += `(${params ? `{${params}}` : '
|
|
1444
|
+
code += `(${params ? `{ ${params} }` : ''})`;
|
|
1447
1445
|
return code;
|
|
1448
1446
|
}
|
|
1449
1447
|
|
|
@@ -508,16 +508,16 @@ export class NewList extends LogicItem {
|
|
|
508
508
|
let code = '';
|
|
509
509
|
const typeAnnotation =
|
|
510
510
|
this?.typeAnnotation?.typeArguments?.map((item) => item?.toNaturalTS())?.join(', ') || '__IDENTIFIER__';
|
|
511
|
-
let
|
|
511
|
+
let paramStr = '';
|
|
512
512
|
this?.items?.forEach((item, index) => {
|
|
513
513
|
if (item) {
|
|
514
|
-
|
|
514
|
+
paramStr += item.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
515
515
|
if (index !== this.items.length - 1) {
|
|
516
|
-
|
|
516
|
+
paramStr += ', ';
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
});
|
|
520
|
-
code += `nasl.util.NewList<${typeAnnotation}>(${
|
|
520
|
+
code += `nasl.util.NewList<${typeAnnotation}>(${paramStr ? `[${paramStr}]` : '[]'})`;
|
|
521
521
|
return code;
|
|
522
522
|
}
|
|
523
523
|
|
package/src/concepts/NewMap__.ts
CHANGED
|
@@ -742,20 +742,21 @@ export class NewMap extends LogicItem {
|
|
|
742
742
|
}
|
|
743
743
|
|
|
744
744
|
@withSourceMap()
|
|
745
|
-
toNaturalTS(): string {
|
|
745
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
746
746
|
let code = '';
|
|
747
747
|
const typeAnnotation =
|
|
748
|
-
this?.typeAnnotation?.typeArguments?.map((item) => item?.toNaturalTS())?.join(', ') || '__IDENTIFIER__';
|
|
748
|
+
this?.typeAnnotation?.typeArguments?.map((item) => item?.toNaturalTS(shiftState(state, code, { inline: true })))?.join(', ') || '__IDENTIFIER__';
|
|
749
749
|
let params = '';
|
|
750
750
|
this?.keys?.forEach((item, index) => {
|
|
751
751
|
if (item) {
|
|
752
|
-
|
|
752
|
+
const key = item?.toNaturalTS(shiftState(state, code, { inline: true, tabSize: state.tabSize + 1 })) || '__IDENTIFIER__';
|
|
753
|
+
params += `${item?.concept.endsWith('Literal') ? key : `[${key}]`}: ${this?.values?.[index]?.toNaturalTS(shiftState(state, code, { inline: true }))}`;
|
|
753
754
|
if (index !== this.keys.length - 1) {
|
|
754
|
-
params += '
|
|
755
|
+
params += ', ';
|
|
755
756
|
}
|
|
756
757
|
}
|
|
757
758
|
});
|
|
758
|
-
code += `nasl.util.NewMap<${typeAnnotation}>(${params ? `{${params}}` : '
|
|
759
|
+
code += `nasl.util.NewMap<${typeAnnotation}>(${params ? `{ ${params} }` : '{}'})`;
|
|
759
760
|
return code;
|
|
760
761
|
}
|
|
761
762
|
|
|
@@ -78,6 +78,16 @@ export class NullLiteral extends LogicItem {
|
|
|
78
78
|
return 'null';
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
@withSourceMap()
|
|
82
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
83
|
+
return 'null';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@withSourceMap()
|
|
87
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
88
|
+
return 'null';
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
getValue() {
|
|
82
92
|
return 'null';
|
|
83
93
|
}
|
|
@@ -158,7 +158,12 @@ export class NumericLiteral extends LogicItem {
|
|
|
158
158
|
|
|
159
159
|
@withSourceMap()
|
|
160
160
|
toNaturalTS(): string {
|
|
161
|
-
return this.value;
|
|
161
|
+
return '' + this.value;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@withSourceMap()
|
|
165
|
+
toTextualNASL(): string {
|
|
166
|
+
return '' + this.value;
|
|
162
167
|
}
|
|
163
168
|
|
|
164
169
|
changeType(value: string | number) {
|
|
@@ -319,8 +319,10 @@ export class OqlQueryComponent extends LogicItem {
|
|
|
319
319
|
|
|
320
320
|
@withSourceMap()
|
|
321
321
|
toNaturalTS(state = createCompilerState()): string {
|
|
322
|
-
const code
|
|
323
|
-
|
|
322
|
+
const code = this.code
|
|
323
|
+
.replace(/\.(\d+)\}/g, '[$1]}')
|
|
324
|
+
.replace(/`/g, '\\`'); // 处理枚举 TS 转不回来的情况 ${app.enums.NetStatusEnum.1}
|
|
325
|
+
return `nasl.oql.query(\`${code}\`)`;
|
|
324
326
|
}
|
|
325
327
|
|
|
326
328
|
// 从服务端获取 SQL -> TS 的翻译和 sourceMap
|
package/src/concepts/Param__.ts
CHANGED
|
@@ -480,6 +480,45 @@ export class Param extends BaseNode {
|
|
|
480
480
|
return code;
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
+
@withSourceMap()
|
|
484
|
+
toTextualNASL(state = createCompilerState(), dontType?: boolean): string {
|
|
485
|
+
let code = this.name;
|
|
486
|
+
// 回调函数类的参数
|
|
487
|
+
if (this?.typeAnnotation?.typeKind === 'function') {
|
|
488
|
+
code += ':{(';
|
|
489
|
+
const paramTypes = this.typeAnnotation?.typeArguments || [];
|
|
490
|
+
paramTypes.forEach((type, index) => {
|
|
491
|
+
code += `type${index + 1}:${type.toTextualNASL(shiftState(state, code))}`;
|
|
492
|
+
if (index !== paramTypes.length - 1) {
|
|
493
|
+
code += ',';
|
|
494
|
+
} else {
|
|
495
|
+
code += ')';
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
code += ':';
|
|
499
|
+
const returnTypes = this.typeAnnotation?.returnType || [];
|
|
500
|
+
returnTypes.forEach((type) => {
|
|
501
|
+
code += type.toTextualNASL(shiftState(state, code));
|
|
502
|
+
});
|
|
503
|
+
code += '}';
|
|
504
|
+
return code;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (asserts.isFunction(this.defaultExpression) || asserts.isAnonymousFunction(this.defaultExpression)) {
|
|
508
|
+
code += this.required ? ': ' : '?: ';
|
|
509
|
+
code += runSync(this.defaultExpression.toEmbeddedTSDefinition(shiftState(state, code)));
|
|
510
|
+
} else if (!dontType && this.typeAnnotation) {
|
|
511
|
+
code += ': ';
|
|
512
|
+
code += this.typeAnnotation.toTextualNASL(shiftState(state, code));
|
|
513
|
+
if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
|
|
514
|
+
if (this.isEnum()) {
|
|
515
|
+
code += `= ${this.typeAnnotation.typeKey}['${this.defaultValue}']`;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return code;
|
|
520
|
+
}
|
|
521
|
+
|
|
483
522
|
@withSourceMapGenerator
|
|
484
523
|
*toEmbeddedNameTS(state?: TranslatorState) {
|
|
485
524
|
return `${this.name}`;
|
|
@@ -1915,7 +1915,14 @@ export class ProcessElement extends BaseNode {
|
|
|
1915
1915
|
if (Array.isArray(self.bindEvents)) {
|
|
1916
1916
|
yield* wrapForEach(self.bindEvents, function* warpForEachGenerator(bindEvent) {
|
|
1917
1917
|
// 任务完成时可以拿到输出参数
|
|
1918
|
-
|
|
1918
|
+
let currentPrevCode: any;
|
|
1919
|
+
if(bindEvent.name !== 'OnClose') {
|
|
1920
|
+
currentPrevCode = prevCode;
|
|
1921
|
+
// 除了任务完成时的逻辑,其他逻辑拿不到自己任务下的输出参数,所以不需要__ProcessIdentification__标注
|
|
1922
|
+
currentPrevCode = currentPrevCode.replace('__ProcessIdentification__', '');
|
|
1923
|
+
} else {
|
|
1924
|
+
currentPrevCode = prevCodeClose;
|
|
1925
|
+
}
|
|
1919
1926
|
code += `${tab1}${bindEvent.name}: () => [\n`;
|
|
1920
1927
|
yield* wrapForEach(bindEvent.logics, function* warpForEachGenerator(logic) {
|
|
1921
1928
|
code += `${yield* logic.toEmbeddedTSInProcess(
|
|
@@ -166,6 +166,21 @@ export class QueryAggregateExpression extends LogicItem {
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
@withSourceMap()
|
|
170
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
171
|
+
let code = `${this.asName}: ${this.aggregateName}(${this.aggregateParam.toTextualNASL(state)})`;
|
|
172
|
+
return code;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@withSourceMap()
|
|
176
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
177
|
+
let code = `${this.aggregateName}(${this.aggregateParam.toTextualNASL(state)})`;
|
|
178
|
+
if (this.asName)
|
|
179
|
+
code += ` AS ${this.asName}`;
|
|
180
|
+
|
|
181
|
+
return code;
|
|
182
|
+
}
|
|
183
|
+
|
|
169
184
|
//================================================================================
|
|
170
185
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
171
186
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
TranslatorGenerator,
|
|
9
9
|
} from '../translator';
|
|
10
10
|
import type CallQueryComponent from './CallQueryComponent__';
|
|
11
|
+
import { firstLowerCase } from '../utils';
|
|
11
12
|
//================================================================================
|
|
12
13
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
13
14
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -158,6 +159,39 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
158
159
|
return '__QueryFieldExpression__';
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
@withSourceMap()
|
|
163
|
+
toNaturalTS(state = createCompilerState(), genAs: boolean = false): string {
|
|
164
|
+
let code = '';
|
|
165
|
+
|
|
166
|
+
if (genAs) {
|
|
167
|
+
if (this.isDotStar)
|
|
168
|
+
code += `${this.asName || firstLowerCase(this.entityAsName) || '__IDENTIFIER__'}: ${this.entityAsName || '__IDENTIFIER__'}`;
|
|
169
|
+
else
|
|
170
|
+
code += `${this.asName || this.propertyName || '__IDENTIFIER__'}: ${this.entityAsName || '__IDENTIFIER__'}.${this.propertyName || '__IDENTIFIER__'}`;
|
|
171
|
+
} else {
|
|
172
|
+
if (this.isDotStar)
|
|
173
|
+
code += `${this.entityAsName || '__IDENTIFIER__'}`;
|
|
174
|
+
else
|
|
175
|
+
code += `${this.entityAsName || '__IDENTIFIER__'}.${this.propertyName || '__IDENTIFIER__'}`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return code;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@withSourceMap()
|
|
182
|
+
toTextualNASL(state = createCompilerState(), genAs: boolean = false): string {
|
|
183
|
+
let code = '';
|
|
184
|
+
if (this.isDotStar)
|
|
185
|
+
code += `${this.entityAsName}.*`;
|
|
186
|
+
else
|
|
187
|
+
code += `${this.entityAsName}.${this.propertyName}`;
|
|
188
|
+
|
|
189
|
+
if (this.asName && genAs)
|
|
190
|
+
code += ` AS ${this.asName}`;
|
|
191
|
+
|
|
192
|
+
return code;
|
|
193
|
+
}
|
|
194
|
+
|
|
161
195
|
toBrief(): string {
|
|
162
196
|
return this.getValue();
|
|
163
197
|
}
|
|
@@ -286,6 +286,35 @@ export class QueryFromExpression extends LogicItem {
|
|
|
286
286
|
return code;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
@withSourceMap()
|
|
290
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
291
|
+
const simpleEntityKey = this.entityName + 'Entity';
|
|
292
|
+
let code = `FROM(${simpleEntityKey}, ${this.asName || this.entityName} => $`;
|
|
293
|
+
|
|
294
|
+
if (this.joinParts.length) {
|
|
295
|
+
this.joinParts.forEach((joinPart) => {
|
|
296
|
+
code += '\n';
|
|
297
|
+
code += joinPart.toNaturalTS(state);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return code;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
@withSourceMap()
|
|
305
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
306
|
+
let code = `FROM ${this.entityKey}`;
|
|
307
|
+
|
|
308
|
+
if (this.joinParts.length) {
|
|
309
|
+
this.joinParts.forEach((joinPart) => {
|
|
310
|
+
code += '\n';
|
|
311
|
+
code += joinPart.toTextualNASL(state);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return code;
|
|
316
|
+
}
|
|
317
|
+
|
|
289
318
|
//================================================================================
|
|
290
319
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
291
320
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -158,13 +158,23 @@ export class QueryGroupByExpression extends LogicItem {
|
|
|
158
158
|
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
159
159
|
const self = this;
|
|
160
160
|
// 判断老应用
|
|
161
|
-
if ((self.parentNode as CallQueryComponent)
|
|
161
|
+
if ((self.parentNode as CallQueryComponent)?.isAutoInfer()) {
|
|
162
162
|
// 2.11版本后 分组使用别名
|
|
163
163
|
return `__${(self.groupElement as QueryFieldExpression).asName || 'EMPTY_GROUP_BY_ALIAS__'}`;
|
|
164
164
|
}
|
|
165
165
|
return yield* (self.groupElement as QueryFieldExpression).toEmbeddedTS();
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
@withSourceMap()
|
|
169
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
170
|
+
return (this.groupElement as QueryFieldExpression).toNaturalTS(state);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@withSourceMap()
|
|
174
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
175
|
+
return (this.groupElement as QueryFieldExpression).toTextualNASL(state);
|
|
176
|
+
}
|
|
177
|
+
|
|
168
178
|
//================================================================================
|
|
169
179
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
170
180
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -509,6 +509,45 @@ export class QueryJoinExpression extends LogicItem {
|
|
|
509
509
|
return code;
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
+
@withSourceMap()
|
|
513
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
514
|
+
const simpleEntityKey = this.entityName + 'Entity';
|
|
515
|
+
let code = `.${this.joinType}_JOIN(${simpleEntityKey}, ${this.asName || this.entityName} => ON(() => `;
|
|
516
|
+
this.onExpressions.forEach((on) => {
|
|
517
|
+
code += on.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
518
|
+
});
|
|
519
|
+
code += ')';
|
|
520
|
+
|
|
521
|
+
if (this.joinParts.length) {
|
|
522
|
+
this.joinParts.forEach((joinPart) => {
|
|
523
|
+
code += '\n';
|
|
524
|
+
code += joinPart.toNaturalTS(state);
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return code;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
@withSourceMap()
|
|
532
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
533
|
+
let code = `${this.joinType} JOIN ${this.entityKey}`;
|
|
534
|
+
if (this.asName)
|
|
535
|
+
code += ` AS ${this.asName}`;
|
|
536
|
+
code += ' ON ';
|
|
537
|
+
this.onExpressions.forEach((on) => {
|
|
538
|
+
code += on.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
if (this.joinParts.length) {
|
|
542
|
+
this.joinParts.forEach((joinPart) => {
|
|
543
|
+
code += '\n';
|
|
544
|
+
code += joinPart.toTextualNASL(state);
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return code;
|
|
549
|
+
}
|
|
550
|
+
|
|
512
551
|
//================================================================================
|
|
513
552
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
514
553
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -194,6 +194,20 @@ export class QueryLimitExpression extends LogicItem {
|
|
|
194
194
|
return code;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
@withSourceMap()
|
|
198
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
199
|
+
let pageElement = this.pageElement.toTextualNASL(state);
|
|
200
|
+
let pageSizeElement = this.pageSizeElement.toTextualNASL(state);
|
|
201
|
+
return `[${pageElement}, ${pageSizeElement}]`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@withSourceMap()
|
|
205
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
206
|
+
let pageElement = this.pageElement.concept === 'Identifier' ? `\${${this.pageElement.toTextualNASL(state)}}` : this.pageElement.toTextualNASL(state);
|
|
207
|
+
let pageSizeElement = this.pageSizeElement.concept === 'Identifier' ? `\${${this.pageSizeElement.toTextualNASL(state)}}` : this.pageSizeElement.toTextualNASL(state);
|
|
208
|
+
return `${pageElement}, ${pageSizeElement}`;
|
|
209
|
+
}
|
|
210
|
+
|
|
197
211
|
//================================================================================
|
|
198
212
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
199
213
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|