@lcap/nasl 2.20.0-beta.2 → 2.20.0-beta.4
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/automate/engine/index.d.ts +1 -1
- package/out/automate/engine/index.js +2 -3
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +1 -1
- package/out/automate/engine/uniqueName.js +2 -2
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.js +4 -1
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/myProcess.d.ts +1 -1
- package/out/automate/template/myProcess.js +2 -2
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +14 -22
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +4 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.d.ts +1 -0
- package/out/common/Command.js +5 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/App__.d.ts +4 -0
- package/out/concepts/App__.js +30 -6
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js +4 -3
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +3 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +7 -0
- package/out/concepts/BindAttribute__.js +270 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +7 -0
- package/out/concepts/BindDirective__.js +215 -17
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +7 -0
- package/out/concepts/BindStyle__.js +194 -4
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/CallFunction__.js +22 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +3 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +3 -0
- package/out/concepts/CallLogic__.js +78 -89
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +20 -3
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +13 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +19 -0
- package/out/concepts/ConfigProperty__.js +61 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +13 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -0
- package/out/concepts/Destination__.js +61 -7
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +9 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +5 -5
- package/out/concepts/EnumItem__.js +6 -6
- package/out/concepts/Enum__.d.ts +20 -19
- package/out/concepts/Enum__.js +28 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ExternalDestination__.d.ts +1 -0
- package/out/concepts/ExternalDestination__.js +21 -3
- package/out/concepts/ExternalDestination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -0
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.js +16 -5
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/JSBlock__.js +5 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +79 -79
- package/out/concepts/Logic__.js +16 -3
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +0 -3
- package/out/concepts/Match__.js +11 -66
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +9 -0
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +16 -0
- package/out/concepts/Module__.js +43 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +2 -4
- package/out/concepts/NewComposite__.js +91 -126
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +1 -0
- package/out/concepts/NewList__.js +22 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -0
- package/out/concepts/NewMap__.js +43 -11
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +40 -12
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +10 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +2 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.js +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js +1 -0
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/Return__.js +10 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +14 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +6 -6
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +9 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +6 -3
- package/out/concepts/TypeAnnotation__.js +67 -13
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -0
- package/out/concepts/ValidationRule__.js +53 -0
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +9 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +17 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +22 -11
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.collection.js +6 -1
- package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.core.js +34 -0
- package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +4 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +3 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -1
- package/out/concepts/index__.js +0 -1
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +8 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.js +24 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -3
- package/out/generator/genReleaseBody.js +97 -23
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.d.ts +2 -10
- package/out/generator/permission.js +27 -14
- package/out/generator/permission.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +2 -20
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -5
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +40 -10
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -2
- package/out/server/getLogics.js +3 -3
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +27 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -1
- package/out/server/naslServer.js +519 -46
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +109 -33
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +21 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +1 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +1 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +2 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +2 -2
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -1
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +2 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/utils/traverse.js +8 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/sandbox/stdlib/nasl.collection.ts +1 -0
- package/sandbox/stdlib/nasl.core.ts +34 -0
- package/sandbox/stdlib/nasl.oql.ts +71 -15
- package/sandbox/stdlib/nasl.util.ts +9 -3
- package/src/automate/engine/dist/index.dev.js +517 -0
- package/src/automate/engine/index.js +2 -3
- package/src/automate/engine/uniqueName.js +2 -2
- package/src/automate/engine/utils.js +4 -2
- package/src/automate/template/myProcess.js +2 -2
- package/src/bak/translator.js +16 -25
- package/src/common/BaseNode.ts +3 -1
- package/src/common/Command.ts +4 -0
- package/src/common/dist/BaseNode.js +1101 -0
- package/src/concepts/App__.ts +36 -7
- package/src/concepts/Assignee__.ts +4 -3
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +299 -38
- package/src/concepts/BindDirective__.ts +204 -31
- package/src/concepts/BindStyle__.ts +187 -24
- package/src/concepts/CallFunction__.ts +55 -10
- package/src/concepts/CallInterface__.ts +3 -2
- package/src/concepts/CallLogic__.ts +110 -90
- package/src/concepts/CallQueryComponent__.ts +18 -3
- package/src/concepts/ConfigGroup__.ts +17 -4
- package/src/concepts/ConfigProperty__.ts +70 -4
- package/src/concepts/Configuration__.ts +14 -5
- package/src/concepts/DataSource__.ts +4 -1
- package/src/concepts/Destination__.ts +61 -7
- package/src/concepts/EntityProperty__.ts +7 -1
- package/src/concepts/EnumItem__.ts +6 -6
- package/src/concepts/Enum__.ts +22 -19
- package/src/concepts/ExternalDestination__.ts +28 -8
- package/src/concepts/ForEachStatement__.ts +2 -0
- package/src/concepts/Frontend__.ts +2 -1
- package/src/concepts/Identifier__.ts +16 -5
- package/src/concepts/InterfaceParam__.ts +7 -1
- package/src/concepts/JSBlock__.ts +3 -2
- package/src/concepts/Logic__.ts +95 -83
- package/src/concepts/Match__.ts +31 -67
- package/src/concepts/MemberExpression__.ts +6 -0
- package/src/concepts/Module__.ts +57 -0
- package/src/concepts/NewComposite__.ts +95 -140
- package/src/concepts/NewList__.ts +23 -2
- package/src/concepts/NewMap__.ts +48 -24
- package/src/concepts/OqlQueryComponent__.ts +40 -20
- package/src/concepts/Param__.ts +178 -176
- package/src/concepts/ProcessElement__.ts +2 -1
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/ProcessOutcomes__.ts +1 -1
- package/src/concepts/Process__.ts +1 -0
- package/src/concepts/Return__.ts +8 -2
- package/src/concepts/StringInterpolation__.ts +19 -7
- package/src/concepts/StringLiteral__.ts +7 -6
- package/src/concepts/StructureProperty__.ts +7 -1
- package/src/concepts/TypeAnnotation__.ts +101 -14
- package/src/concepts/ValidationRule__.ts +58 -9
- package/src/concepts/Variable__.ts +11 -1
- package/src/concepts/ViewElement__.ts +39 -2
- package/src/concepts/View__.ts +26 -14
- package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
- package/src/concepts/basics/stdlib/nasl.collection.ts +6 -1
- package/src/concepts/basics/stdlib/nasl.configuration.ts +3 -0
- package/src/concepts/basics/stdlib/nasl.core.ts +33 -2
- package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/dist/BindAttribute__.js +795 -0
- package/src/concepts/dist/BindEvent__.js +732 -0
- package/src/concepts/dist/CallFunction__.js +527 -0
- package/src/concepts/dist/CallLogic__.js +932 -0
- package/src/concepts/dist/Destination__.js +708 -0
- package/src/concepts/dist/ExternalDestination__.js +298 -0
- package/src/concepts/dist/Identifier__.js +311 -0
- package/src/concepts/dist/StringInterpolation__.js +231 -0
- package/src/concepts/dist/TypeAnnotation__.js +834 -0
- package/src/concepts/dist/ViewElement__.js +1692 -0
- package/src/concepts/dist/View__.js +1601 -0
- package/src/concepts/index__.ts +0 -1
- package/src/enums/KEYWORDS.ts +8 -0
- package/src/generator/dist/genBundleFiles.js +261 -0
- package/src/generator/dist/genMetaData.js +245 -0
- package/src/generator/dist/permission.js +405 -0
- package/src/generator/genBundleFiles.ts +24 -5
- package/src/generator/genReleaseBody.ts +75 -30
- package/src/generator/permission.ts +31 -15
- package/src/server/entity2LogicNamespace.ts +2 -20
- package/src/server/extendBaseNode.ts +15 -5
- package/src/server/formatTsUtils.ts +41 -10
- package/src/server/getLogics.ts +4 -4
- package/src/server/getMemberIdentifier.ts +27 -1
- package/src/server/index.ts +2 -0
- package/src/server/naslServer.ts +520 -48
- package/src/server/translator.ts +96 -34
- package/src/service/storage/dist/init.js +579 -0
- package/src/service/storage/init.ts +22 -2
- package/src/templator/dist/genEditTableBlock.js +204 -0
- package/src/templator/dist/genGridViewBlock.js +265 -0
- package/src/templator/dist/genListViewBlock.js +84 -0
- package/src/templator/dist/genTableBlock.js +209 -0
- package/src/templator/dist/utils.js +527 -0
- package/src/templator/genCreateBlock.ts +1 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +2 -4
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +3 -4
- package/src/templator/genListViewBlock.ts +9 -3
- package/src/templator/genSelectBlock.ts +1 -1
- package/src/templator/genTableBlock.ts +3 -3
- package/src/templator/genUpdateBlock.ts +2 -3
- package/src/utils/traverse.ts +10 -2
- package/ts-worker/lib/tsserver.js +10 -2
- package/ts-worker/package.json +1 -0
- package/ts-worker/webpack.config.js +11 -2
- package/out/concepts/ConstructArgument__.d.ts +0 -40
- package/out/concepts/ConstructArgument__.js +0 -108
- package/out/concepts/ConstructArgument__.js.map +0 -1
- package/out/concepts/Construct__.d.ts +0 -189
- package/out/concepts/Construct__.js +0 -340
- package/out/concepts/Construct__.js.map +0 -1
- package/out/templator/sql-parser/index.d.ts +0 -1
- package/out/templator/sql-parser/index.js +0 -228
- package/out/templator/sql-parser/index.js.map +0 -1
- package/out/templator/sql-parser/parser.js +0 -26664
- package/out/templator/sql-parser/parser.js.map +0 -1
|
@@ -54,8 +54,6 @@ export class OqlQueryComponent extends LogicItem {
|
|
|
54
54
|
@property()
|
|
55
55
|
dataSource: string = undefined;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
57
|
/**
|
|
60
58
|
* @param source 需要合并的部分参数
|
|
61
59
|
*/
|
|
@@ -69,7 +67,6 @@ export class OqlQueryComponent extends LogicItem {
|
|
|
69
67
|
return super.from(source, parentNode, parentKey) as OqlQueryComponent;
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
|
|
73
70
|
/**
|
|
74
71
|
* 设置SQL 查询
|
|
75
72
|
*/
|
|
@@ -82,10 +79,6 @@ export class OqlQueryComponent extends LogicItem {
|
|
|
82
79
|
});
|
|
83
80
|
}
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
82
|
/**
|
|
90
83
|
* 删除类型标注
|
|
91
84
|
* @param name 类型标注名称
|
|
@@ -272,24 +265,44 @@ export class OqlQueryComponent extends LogicItem {
|
|
|
272
265
|
@withSourceMap()
|
|
273
266
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
274
267
|
let code: string;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
268
|
+
const typeAnnotation = this.typeAnnotation;
|
|
269
|
+
if (typeAnnotation) {
|
|
270
|
+
code = `(function(): ${typeAnnotation.toEmbeddedTS()} {\n`;
|
|
271
|
+
} else {
|
|
272
|
+
code = `(function __oqlQueryFn${String(this.id).slice(0, 8)} () {\n`;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const indent1 = indent((state?.tabSize || 0) + 1);
|
|
276
|
+
// this.dataSource: 'app.dataSources.defaultDS';
|
|
278
277
|
if (this.dataSource) {
|
|
279
|
-
code +=
|
|
278
|
+
code += indent1;
|
|
280
279
|
code += `const dataSource = ${this.dataSource || 'app.dataSources.defaultDS'};\n`;
|
|
281
280
|
}
|
|
281
|
+
const hasSyntaxErrors = !!this.codeSourceMap?.oqlSyntaxError?.syntaxErrors?.length;
|
|
282
282
|
// 生成内部的ts内容
|
|
283
|
-
if (this.
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
283
|
+
if (!this.code) {
|
|
284
|
+
// SQL 为空
|
|
285
|
+
code += `${indent1}__OQL_EMPTY_ERROR__;\n`;
|
|
286
|
+
} else if (hasSyntaxErrors) {
|
|
287
|
+
const syntaxErrors = this.codeSourceMap?.oqlSyntaxError?.syntaxErrors || [];
|
|
288
|
+
const warningList = syntaxErrors.filter((err: any) => err.errorMsg.includes('别名不符合规范'));
|
|
289
|
+
if (warningList.length === syntaxErrors.length) {
|
|
290
|
+
// SQL 别名警告
|
|
291
|
+
code += `${indent1}__OQL_ALIAS_WARNING__;\n`;
|
|
292
|
+
} else {
|
|
293
|
+
if (warningList.length > 0) {
|
|
294
|
+
// SQL 别名警告
|
|
295
|
+
code += `${indent1}__OQL_ALIAS_WARNING__;\n`;
|
|
296
|
+
}
|
|
289
297
|
// SQL 语法错误
|
|
290
|
-
code +=
|
|
298
|
+
code += `${indent1}__OQL_GRAMMAR_ERROR__;\n`;
|
|
291
299
|
}
|
|
292
300
|
}
|
|
301
|
+
// insert typescript code
|
|
302
|
+
const typescript = this.codeSourceMap?.typescript;
|
|
303
|
+
if (typescript) {
|
|
304
|
+
code += `${indent1}const __oqlQueryResult = ${typescript};`;
|
|
305
|
+
}
|
|
293
306
|
|
|
294
307
|
// 临时方案拼接字符串
|
|
295
308
|
this.getTextVariables();
|
|
@@ -300,7 +313,12 @@ export class OqlQueryComponent extends LogicItem {
|
|
|
300
313
|
code += ';\n';
|
|
301
314
|
});
|
|
302
315
|
code += '\n';
|
|
303
|
-
|
|
316
|
+
|
|
317
|
+
if (typescript && !typeAnnotation) {
|
|
318
|
+
code += `${indent1}return __oqlQueryResult;\n`;
|
|
319
|
+
} else {
|
|
320
|
+
code += `${indent1}return;\n`;
|
|
321
|
+
}
|
|
304
322
|
code += indent((state?.tabSize || 0)) + '})()';
|
|
305
323
|
return code;
|
|
306
324
|
}
|
|
@@ -314,6 +332,8 @@ export class OqlQueryComponent extends LogicItem {
|
|
|
314
332
|
oqlIdentifier: 'myoqlIdentifier',
|
|
315
333
|
dataSourceName: this.dataSource,
|
|
316
334
|
oql: this.code,
|
|
335
|
+
ideVersion: this.app.ideVersion,
|
|
336
|
+
dataSourceNasl: this.app.findNodeByCompleteName(this.dataSource).toJSON(),
|
|
317
337
|
typeScriptStartLine: 1,
|
|
318
338
|
typeScriptStartLineColumn: 1,
|
|
319
339
|
},
|
|
@@ -335,7 +355,7 @@ export class OqlQueryComponent extends LogicItem {
|
|
|
335
355
|
};
|
|
336
356
|
}
|
|
337
357
|
|
|
338
|
-
_TsVariables: Array<Identifier | MemberExpression
|
|
358
|
+
_TsVariables: Array<Identifier | MemberExpression> = [];
|
|
339
359
|
|
|
340
360
|
// 节点的sourcemap
|
|
341
361
|
codeSourceMap: any = undefined;
|
package/src/concepts/Param__.ts
CHANGED
|
@@ -9,13 +9,13 @@ import Function from './Function__';
|
|
|
9
9
|
import AnonymousFunction from './AnonymousFunction__';
|
|
10
10
|
|
|
11
11
|
function tryJSONParse(str: string) {
|
|
12
|
-
|
|
12
|
+
let result;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
try {
|
|
15
|
+
result = JSON.parse(str);
|
|
16
|
+
} catch (e) { }
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
return result;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
//================================================================================
|
|
@@ -195,10 +195,6 @@ export class Param extends BaseNode {
|
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
198
|
/**
|
|
203
199
|
* 删除类型标注
|
|
204
200
|
* @param name 类型标注名称
|
|
@@ -271,97 +267,97 @@ export class Param extends BaseNode {
|
|
|
271
267
|
completionChildren: Array<EntityProperty | StructureProperty> = undefined;
|
|
272
268
|
|
|
273
269
|
toJS(state?: TranslatorState): string {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
270
|
+
if (this.view) {
|
|
271
|
+
const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
|
|
272
|
+
const needGenInitFromSchema = typeAnnotation && (
|
|
273
|
+
!['primitive', 'union'].includes(typeAnnotation.typeKind)
|
|
278
274
|
|| typeAnnotation.typeName === 'DateTime'
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
275
|
+
);
|
|
276
|
+
let code = `${this.name} = `;
|
|
277
|
+
if (needGenInitFromSchema) {
|
|
278
|
+
code += `this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}',`;
|
|
279
|
+
}
|
|
280
|
+
const defaultValue = this.defaultValue;
|
|
281
|
+
const defaultValueType = Object.prototype.toString.call(defaultValue);
|
|
282
|
+
const { typeKind, typeNamespace, typeName } = typeAnnotation || {};
|
|
283
|
+
// 设置成null,才能同步给后端清除该值,但是null对checkbox组件是一种特殊状态
|
|
284
|
+
let parsedValue = defaultValue ?? undefined;
|
|
285
|
+
if (
|
|
286
|
+
defaultValueType === '[object String]'
|
|
291
287
|
&& (
|
|
292
|
-
|
|
288
|
+
!(typeKind === 'primitive' && typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName))
|
|
293
289
|
&& !(this.isEnum())
|
|
294
290
|
&& !['union'].includes(typeKind)
|
|
295
291
|
)
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
292
|
+
) {
|
|
293
|
+
// 一些特殊情况,特殊处理成undefined
|
|
294
|
+
// 1.defaultValue在nasl节点上错误得赋值给了空制符串
|
|
295
|
+
if ([''].includes(defaultValue)) {
|
|
296
|
+
parsedValue = undefined;
|
|
297
|
+
} else {
|
|
298
|
+
parsedValue = tryJSONParse(defaultValue) ?? defaultValue;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
code += `${this.name} || (this.$route.query.hasOwnProperty('${this.name}') ? this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}', this.$route.query.${this.name}) : ${JSON.stringify(this.defaultValue)})`;
|
|
306
302
|
|
|
307
|
-
|
|
308
|
-
|
|
303
|
+
if (needGenInitFromSchema) {
|
|
304
|
+
code += `)`;
|
|
305
|
+
}
|
|
306
|
+
return code;
|
|
307
|
+
} else {
|
|
308
|
+
return '';
|
|
309
309
|
}
|
|
310
|
-
return code;
|
|
311
|
-
} else {
|
|
312
|
-
return '';
|
|
313
|
-
}
|
|
314
310
|
}
|
|
315
311
|
|
|
316
312
|
isEnum() {
|
|
317
|
-
|
|
313
|
+
return this.typeAnnotation?.typeNamespace?.endsWith('.enums');
|
|
318
314
|
}
|
|
319
315
|
|
|
320
316
|
@withSourceMap()
|
|
321
317
|
toEmbeddedTS(state?: TranslatorState, dontType?: boolean): string {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
318
|
+
let code = this.name;
|
|
319
|
+
// 回调函数类的参数
|
|
320
|
+
if (this?.typeAnnotation?.typeKind === 'function') {
|
|
321
|
+
code += ':{(';
|
|
322
|
+
const paramTypes = this.typeAnnotation?.typeArguments || [];
|
|
323
|
+
paramTypes.forEach((type, index) => {
|
|
324
|
+
code += `type${index + 1}:` + type.toEmbeddedTS(shiftState(state, code));
|
|
325
|
+
if (index !== paramTypes.length - 1) {
|
|
326
|
+
code += ',';
|
|
327
|
+
} else {
|
|
328
|
+
code += ')';
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
code += ':';
|
|
332
|
+
const returnTypes = (this.typeAnnotation?.returnType || []);
|
|
333
|
+
returnTypes.forEach((type) => {
|
|
334
|
+
code += type.toEmbeddedTS(shiftState(state, code));
|
|
335
|
+
});
|
|
336
|
+
code += '}';
|
|
337
|
+
return code;
|
|
338
|
+
}
|
|
343
339
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
340
|
+
if (this.defaultExpression instanceof Function || this.defaultExpression instanceof AnonymousFunction) {
|
|
341
|
+
code += this.required ? ': ' : '?: ';
|
|
342
|
+
code += this.defaultExpression.toEmbeddedTSDefinition(shiftState(state, code));
|
|
343
|
+
} else if (!dontType && this.typeAnnotation) {
|
|
344
|
+
code += ': ';
|
|
345
|
+
code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
|
|
346
|
+
// toTS暂时只需要翻译引用数据类型的,因为值都是字符串
|
|
347
|
+
// 就不在这里赋值了,这里单纯就为了快速查找
|
|
348
|
+
// 并且屏蔽了一些异常的错误
|
|
349
|
+
if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
|
|
350
|
+
if (this.isEnum()) {
|
|
351
|
+
code += `= ${this.typeAnnotation.typeKey}['${this.defaultValue}']`;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
357
354
|
}
|
|
358
|
-
|
|
359
|
-
return code;
|
|
355
|
+
return code;
|
|
360
356
|
}
|
|
361
357
|
|
|
362
358
|
@withSourceMap()
|
|
363
359
|
toEmbeddedNameTS(state?: TranslatorState): string {
|
|
364
|
-
|
|
360
|
+
return `${this.name}`;
|
|
365
361
|
}
|
|
366
362
|
/**
|
|
367
363
|
* 设置数据类型
|
|
@@ -374,47 +370,47 @@ export class Param extends BaseNode {
|
|
|
374
370
|
*/
|
|
375
371
|
async setDataType(typeKey: string): Promise<void>;
|
|
376
372
|
async setDataType(typeAnnotation: TypeAnnotation | string) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
373
|
+
if (typeof typeAnnotation === 'string') {
|
|
374
|
+
typeAnnotation = dataTypesMap[typeAnnotation];
|
|
375
|
+
if (!typeAnnotation)
|
|
376
|
+
// eslint-disable-next-line prefer-rest-params
|
|
377
|
+
throw new Error('找不到类型:' + arguments[0]);
|
|
378
|
+
} else {
|
|
379
|
+
typeAnnotation._delete?.();
|
|
380
|
+
const relationOptions = { parentId: this.id, parentConcept: this.concept, parentNode: this };
|
|
381
|
+
Object.assign(typeAnnotation, relationOptions);
|
|
382
|
+
}
|
|
383
|
+
const object: any = {
|
|
384
|
+
typeAnnotation,
|
|
385
|
+
};
|
|
390
386
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
387
|
+
// 切换类型的时候如果有默认值就清除掉
|
|
388
|
+
if (this.defaultValue) {
|
|
389
|
+
object.defaultValue = '';
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
this.completionChildren = this.getSelectRef(typeAnnotation);
|
|
393
|
+
} catch (err) {
|
|
394
|
+
this.completionChildren = [];
|
|
395
|
+
console.log(err);
|
|
396
|
+
}
|
|
397
|
+
// 处理下拉属性
|
|
398
|
+
return this.update({
|
|
399
|
+
...object,
|
|
400
|
+
});
|
|
405
401
|
}
|
|
406
402
|
|
|
407
403
|
public static getDefaultOptions() {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
404
|
+
return {
|
|
405
|
+
required: true,
|
|
406
|
+
defaultValue: '',
|
|
407
|
+
typeAnnotation: {
|
|
408
|
+
concept: 'TypeAnnotation',
|
|
409
|
+
typeKind: 'primitive',
|
|
410
|
+
typeNamespace: 'nasl.core',
|
|
411
|
+
typeName: 'String',
|
|
412
|
+
},
|
|
413
|
+
};
|
|
418
414
|
}
|
|
419
415
|
|
|
420
416
|
_readonly: boolean = false;
|
|
@@ -422,86 +418,92 @@ export class Param extends BaseNode {
|
|
|
422
418
|
* 是否可编辑
|
|
423
419
|
* */
|
|
424
420
|
get readonly() {
|
|
425
|
-
|
|
421
|
+
return !!this.module || this._readonly;
|
|
426
422
|
}
|
|
427
423
|
|
|
428
424
|
set readonly(val) {
|
|
429
|
-
|
|
425
|
+
this._readonly = val;
|
|
430
426
|
}
|
|
431
427
|
get hasChildren() {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
428
|
+
const { typeKind, typeNamespace, typeName } = this.typeAnnotation;
|
|
429
|
+
if (typeKind === 'reference' || typeKind === 'generic') {
|
|
430
|
+
if (typeNamespace.endsWith('.enums'))
|
|
431
|
+
return null;
|
|
432
|
+
return [{}];
|
|
433
|
+
} else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
|
|
434
|
+
return [{}];
|
|
435
|
+
}
|
|
436
|
+
return null;
|
|
439
437
|
}
|
|
440
438
|
get isTreeLeaf() {
|
|
441
|
-
|
|
439
|
+
return !this.hasChildren;
|
|
442
440
|
}
|
|
443
441
|
getSelectRef(newTypeAnnotation: TypeAnnotation) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
442
|
+
try {
|
|
443
|
+
const { typeName, typeKind, typeNamespace, sortedTypeKey } = newTypeAnnotation || this.typeAnnotation;
|
|
444
|
+
let completionChildren;
|
|
445
|
+
if (typeKind === 'reference') {
|
|
446
|
+
if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process' || typeNamespace === 'nasl.auth') {
|
|
447
|
+
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
448
|
+
const properties = (node as Structure)?.properties || [];
|
|
449
|
+
completionChildren = properties;
|
|
450
|
+
} else if (typeNamespace.endsWith('.enums')) {
|
|
451
|
+
completionChildren = [];
|
|
452
|
+
} else {
|
|
453
|
+
const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
|
|
454
|
+
const properties = node?.properties || [];
|
|
455
|
+
completionChildren = properties;
|
|
456
|
+
}
|
|
457
|
+
} else if (typeKind === 'generic') {
|
|
458
|
+
// if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
|
|
459
|
+
// }
|
|
460
|
+
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
461
|
+
const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
|
|
462
|
+
for (let i = 0; i < properties.length; i++) {
|
|
463
|
+
const item = properties[i];
|
|
464
|
+
if (item?.typeAnnotation?.typeKind === 'typeParam') {
|
|
465
|
+
const newItem = StructureProperty.from(item.toJSON());
|
|
466
|
+
newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
|
|
467
|
+
newItem.parentNode = this;
|
|
468
|
+
properties[i] = newItem;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
completionChildren = properties;
|
|
472
|
+
} else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
|
|
473
|
+
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
474
|
+
const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
|
|
475
|
+
completionChildren = properties;
|
|
476
|
+
} else {
|
|
477
|
+
completionChildren = [];
|
|
471
478
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
completionChildren = [];
|
|
479
|
+
return completionChildren;
|
|
480
|
+
} catch (err) {
|
|
481
|
+
console.log(err);
|
|
476
482
|
}
|
|
477
|
-
return completionChildren;
|
|
478
|
-
} catch (err) {
|
|
479
|
-
console.log(err);
|
|
480
|
-
}
|
|
481
483
|
}
|
|
482
484
|
|
|
483
485
|
setnNewTypeAnnotation(oldTypeAnnotation: TypeAnnotation) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
486
|
+
const json = oldTypeAnnotation.toJSON();
|
|
487
|
+
const typeAnnotation = TypeAnnotation.from(json);
|
|
488
|
+
this.typeAnnotation = typeAnnotation;
|
|
487
489
|
}
|
|
488
490
|
get isFunction() {
|
|
489
|
-
|
|
491
|
+
return this.typeAnnotation.typeKind === 'function';
|
|
490
492
|
}
|
|
491
493
|
|
|
492
494
|
get getFunctionSign() {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
495
|
+
if (this.isFunction) {
|
|
496
|
+
const paramTypes = this.typeAnnotation.typeArguments || [];
|
|
497
|
+
const returnTypes = this.typeAnnotation.returnType || [];
|
|
498
|
+
const paramTypeNames = paramTypes.map((item) => item.sign);
|
|
499
|
+
const returnTypeNames = returnTypes.map((item) => item.sign);
|
|
500
|
+
return `(${paramTypeNames.toString()}) → ${returnTypeNames.toString()}`;
|
|
501
|
+
} else {
|
|
502
|
+
return '';
|
|
503
|
+
}
|
|
502
504
|
}
|
|
503
505
|
|
|
504
|
-
|
|
506
|
+
//================================================================================
|
|
505
507
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
506
508
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
507
509
|
//================================================================================
|
|
@@ -1598,7 +1598,8 @@ export class ProcessElement extends BaseNode {
|
|
|
1598
1598
|
|| this.type === 'AutoTask'
|
|
1599
1599
|
|| this.type === 'InclusiveGateway') {
|
|
1600
1600
|
const prevTasks = getPreviousTask(this);
|
|
1601
|
-
let prevCode = `${tab4}
|
|
1601
|
+
let prevCode = `${tab4}__ProcessIdentification__;\n`;
|
|
1602
|
+
prevCode += `${tab4}const ${this.process.name} = {\n`;
|
|
1602
1603
|
const processName = this.process.name;
|
|
1603
1604
|
this.process.params.forEach((p) => {
|
|
1604
1605
|
prevCode += `${tab5}${p.name}: app.processes.${processName}.${p.name},\n`;
|
|
@@ -1227,6 +1227,7 @@ export class Process extends BaseNode {
|
|
|
1227
1227
|
const tab3 = indent((state?.tabSize || 0) + 3);
|
|
1228
1228
|
// code += `${tab1}namespace variables{\n`;
|
|
1229
1229
|
|
|
1230
|
+
code += `${tab1}let __ProcessIdentification__: string;\n`;
|
|
1230
1231
|
code += `${tab1}export namespace logics {\n`;
|
|
1231
1232
|
const logic = genLaunchProcess(this);
|
|
1232
1233
|
// sourceMap 映射
|
package/src/concepts/Return__.ts
CHANGED
|
@@ -372,11 +372,13 @@ export class Return extends BaseNode {
|
|
|
372
372
|
get hasChildren() {
|
|
373
373
|
if (!this.typeAnnotation)
|
|
374
374
|
return null;
|
|
375
|
-
const { typeKind, typeNamespace } = this.typeAnnotation;
|
|
375
|
+
const { typeKind, typeNamespace, typeName } = this.typeAnnotation;
|
|
376
376
|
if (typeKind === 'reference' || typeKind === 'generic') {
|
|
377
377
|
if (typeNamespace.endsWith('.enums'))
|
|
378
378
|
return null;
|
|
379
379
|
return [{}];
|
|
380
|
+
} else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
|
|
381
|
+
return [{}];
|
|
380
382
|
}
|
|
381
383
|
return null;
|
|
382
384
|
}
|
|
@@ -385,7 +387,7 @@ export class Return extends BaseNode {
|
|
|
385
387
|
}
|
|
386
388
|
getSelectRef(newTypeAnnotation: TypeAnnotation) {
|
|
387
389
|
try {
|
|
388
|
-
const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
|
|
390
|
+
const { typeName, typeKind, typeNamespace, sortedTypeKey } = newTypeAnnotation || this.typeAnnotation;
|
|
389
391
|
let completionChildren;
|
|
390
392
|
if (typeKind === 'reference') {
|
|
391
393
|
if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process' || typeNamespace === 'nasl.auth') {
|
|
@@ -412,6 +414,10 @@ export class Return extends BaseNode {
|
|
|
412
414
|
}
|
|
413
415
|
}
|
|
414
416
|
completionChildren = properties;
|
|
417
|
+
} else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
|
|
418
|
+
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
419
|
+
const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
|
|
420
|
+
completionChildren = properties;
|
|
415
421
|
} else {
|
|
416
422
|
completionChildren = [];
|
|
417
423
|
}
|