@lcap/nasl 1.0.1 → 2.12.0-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/out/automate/engine/index.d.ts +1 -0
- package/out/automate/engine/index.js +34 -12
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/operators.d.ts +10 -2
- package/out/automate/engine/operators.js +105 -7
- package/out/automate/engine/operators.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +8 -2
- package/out/automate/engine/uniqueName.js +72 -4
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +108 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/process.d.ts +9 -0
- package/out/automate/template/process.js +10976 -0
- package/out/automate/template/process.js.map +1 -0
- package/out/bak/translator.js +1 -0
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +6 -1
- package/out/common/BaseNode.js +37 -6
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +52 -49
- package/out/concepts/App__.js +89 -53
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.d.ts +11 -0
- package/out/concepts/Assignee__.js +34 -0
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +2 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +10 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +15 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +4 -0
- package/out/concepts/BooleanLiteral__.js +11 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +9 -4
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.js +48 -30
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +34 -4
- package/out/concepts/CallQueryComponent__.js +340 -95
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +7 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +3 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +3 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js +6 -6
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +318 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +22 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +10 -2
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +22 -7
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +6 -0
- package/out/concepts/Entity__.js +27 -11
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +14 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -2
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +96 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +5 -14
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +8 -8
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -4
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +3 -5
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.js +44 -44
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.d.ts +116 -194
- package/out/concepts/Module__.js +31 -114
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +1 -108
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/Param__.d.ts +3 -2
- package/out/concepts/Param__.js +15 -8
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +38 -12
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -1
- package/out/concepts/Process__.js +17 -10
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +1 -0
- package/out/concepts/QueryFieldExpression__.js +11 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +13 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
- package/out/concepts/QueryGroupByExpression__.js +20 -0
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +16 -11
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +10 -3
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +14 -0
- package/out/concepts/SqlQueryComponent__.js +48 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +2 -9
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +11 -10
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +19 -12
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -1
- package/out/concepts/SwitchCase__.js +23 -25
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -6
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +53 -3
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -1
- package/out/concepts/Variable__.js +16 -11
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +25 -20
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +42 -36
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +4 -4
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
- package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
- package/out/concepts/basics/stdlib/nasl.process.js +410 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +270 -8
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +2 -0
- package/out/concepts/basics/types/index.js +6 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -7
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +3 -1
- package/out/generator/genBundleFiles.js +23 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -0
- package/out/generator/genMetaData.js +20 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/manager/diagnostic.d.ts +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/{test/integration/connect-file copy.d.ts → server/extendBaseNode.d.ts} +0 -0
- package/out/server/extendBaseNode.js +323 -0
- package/out/server/extendBaseNode.js.map +1 -0
- package/out/server/getLogics.js +49 -2
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +52 -2
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +8 -2
- package/out/server/getProcesses.js +228 -20
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getScope.d.ts +1 -0
- package/out/server/getScope.js +4 -0
- package/out/server/getScope.js.map +1 -1
- package/out/server/index.d.ts +1 -0
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +8 -5
- package/out/server/naslServer.js +314 -383
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +10 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.d.ts +1 -1
- package/out/server/translator.js +40 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -0
- package/out/service/storage/init.js +113 -94
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +34 -24
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +45 -29
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +15 -13
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +1 -1
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +29 -24
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +31 -29
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +13 -22
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +31 -21
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +35 -25
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +5 -3
- package/out/templator/utils.js +2 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/connect-file.js +6 -6
- package/out/test/integration/connect-file.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +5 -0
- package/out/utils/index.js +50 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/automate/engine/index.js +33 -8
- package/src/automate/engine/operators.js +114 -17
- package/src/automate/engine/uniqueName.js +77 -9
- package/src/automate/engine/utils.js +110 -69
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +35 -7
- package/src/concepts/App__.ts +132 -131
- package/src/concepts/Assignee__.ts +30 -0
- package/src/concepts/BindAttribute__.ts +2 -2
- package/src/concepts/BindDirective__.ts +9 -7
- package/src/concepts/BindEvent__.ts +14 -6
- package/src/concepts/BooleanLiteral__.ts +12 -0
- package/src/concepts/CallFunction__.ts +7 -4
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +352 -101
- package/src/concepts/Comment__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +3 -1
- package/src/concepts/ConfigProperty__.ts +4 -0
- package/src/concepts/Configuration__.ts +3 -0
- package/src/concepts/Constant__.ts +6 -6
- package/src/concepts/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +22 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +11 -2
- package/src/concepts/EntityProperty__.ts +23 -7
- package/src/concepts/Entity__.ts +38 -14
- package/src/concepts/Enum__.ts +15 -4
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +5 -14
- package/src/concepts/IfStatement__.ts +9 -9
- package/src/concepts/InterfaceParam__.ts +9 -4
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +3 -12
- package/src/concepts/Logic__.ts +45 -79
- package/src/concepts/Module__.ts +141 -342
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/Param__.ts +17 -9
- package/src/concepts/ProcessElement__.ts +42 -15
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +13 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryGroupByExpression__.ts +23 -0
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +16 -11
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +2 -9
- package/src/concepts/StructureProperty__.ts +11 -14
- package/src/concepts/Structure__.ts +19 -11
- package/src/concepts/SwitchCase__.ts +23 -27
- package/src/concepts/SwitchStatement__.ts +1 -5
- package/src/concepts/TypeAnnotation__.ts +52 -3
- package/src/concepts/Variable__.ts +16 -11
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +45 -38
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- package/src/concepts/basics/stdlib/nasl.configuration.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
- package/src/concepts/basics/stdlib/nasl.util.ts +271 -8
- package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
- package/src/concepts/basics/types/index.ts +2 -0
- package/src/concepts/index__.ts +1 -0
- package/src/enums/KEYWORDS.ts +0 -7
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- package/src/manager/diagnostic.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/extendBaseNode.ts +318 -0
- package/src/server/getLogics.ts +51 -5
- package/src/server/getMemberIdentifier.ts +53 -2
- package/src/server/getProcesses.ts +238 -21
- package/src/server/getScope.ts +5 -0
- package/src/server/index.ts +1 -0
- package/src/server/naslServer.ts +322 -380
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +42 -2
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +115 -97
- package/src/templator/genCreateBlock.ts +35 -26
- package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
- package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
- package/src/templator/genEditTableBlock.ts +17 -14
- package/src/templator/genEnumSelectBlock.ts +1 -1
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +34 -30
- package/src/templator/genSelectBlock.ts +14 -23
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +36 -26
- package/src/templator/utils.ts +5 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +51 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.browser copy.js +0 -70
- package/out/concepts/basics/stdlib/nasl.browser copy.js.map +0 -1
- package/out/terms/LEVEL_NAME_MAP.d.ts +0 -26
- package/out/terms/LEVEL_NAME_MAP.js +0 -30
- package/out/terms/LEVEL_NAME_MAP.js.map +0 -1
- package/out/test/integration/connect-file copy.js +0 -50
- package/out/test/integration/connect-file copy.js.map +0 -1
- package/out/test/integration/node-nasl-server.d.ts +0 -1
- package/out/test/integration/node-nasl-server.js +0 -41
- package/out/test/integration/node-nasl-server.js.map +0 -1
|
@@ -10,7 +10,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
10
10
|
import BaseNode from '../common/BaseNode';
|
|
11
11
|
import classMap from '../common/classMap';
|
|
12
12
|
import Process from './Process__';
|
|
13
|
-
import Entity from './Entity__';
|
|
14
13
|
import Structure from './Structure__';
|
|
15
14
|
import Enum from './Enum__';
|
|
16
15
|
import Logic from './Logic__';
|
|
@@ -68,12 +67,6 @@ export class Namespace extends BaseNode {
|
|
|
68
67
|
@property('Process')
|
|
69
68
|
processes: Array<Process> = [];
|
|
70
69
|
|
|
71
|
-
/**
|
|
72
|
-
* 实体列表
|
|
73
|
-
*/
|
|
74
|
-
@property('Entity')
|
|
75
|
-
entities: Array<Entity> = [];
|
|
76
|
-
|
|
77
70
|
/**
|
|
78
71
|
* 数据结构列表
|
|
79
72
|
*/
|
|
@@ -440,148 +433,6 @@ export class Namespace extends BaseNode {
|
|
|
440
433
|
}
|
|
441
434
|
|
|
442
435
|
|
|
443
|
-
getEntityExistingNames(excludedList: Array<Entity> = []) {
|
|
444
|
-
const excludedSet = new Set(excludedList);
|
|
445
|
-
return (this.entities || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
446
|
-
}
|
|
447
|
-
getEntityUniqueName(name = 'Entity1') {
|
|
448
|
-
return utils.unique(name, this.getEntityExistingNames(), undefined, false);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* 插入实体
|
|
453
|
-
* @internal
|
|
454
|
-
* @param name 实体名称,如果不填会自动生成一个唯一名称
|
|
455
|
-
*/
|
|
456
|
-
_insertEntityAt(name: string, index: number): Entity;
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* 插入实体
|
|
460
|
-
* @internal
|
|
461
|
-
* @param entityOptions 实体参数
|
|
462
|
-
*/
|
|
463
|
-
_insertEntityAt(entityOptions: Partial<Entity>, index: number): Entity;
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* 插入实体
|
|
467
|
-
* @internal
|
|
468
|
-
* @param entity 已有的实体实例
|
|
469
|
-
*/
|
|
470
|
-
_insertEntityAt(entity: Entity, index: number): Entity;
|
|
471
|
-
|
|
472
|
-
_insertEntityAt(options: string | Partial<Entity> | Entity, index: number) {
|
|
473
|
-
const entityOptions: any = {};
|
|
474
|
-
const relationOptions = { parentNode: this, parentKey: 'entities' };
|
|
475
|
-
let entity: Entity;
|
|
476
|
-
if (!options) {
|
|
477
|
-
entity = Entity.from({
|
|
478
|
-
...entityOptions,
|
|
479
|
-
name: this.getEntityUniqueName(),
|
|
480
|
-
}, this, 'entities');
|
|
481
|
-
} else if (typeof options === 'string') {
|
|
482
|
-
entity = Entity.from({
|
|
483
|
-
...entityOptions,
|
|
484
|
-
name: options,
|
|
485
|
-
}, this, 'entities');
|
|
486
|
-
} else if (options instanceof Entity) {
|
|
487
|
-
options.ensureDelete(); // 同一实例不支持多处存在
|
|
488
|
-
entity = options;
|
|
489
|
-
Object.assign(entity, relationOptions);
|
|
490
|
-
} else {
|
|
491
|
-
entity = Entity.from({
|
|
492
|
-
...entityOptions,
|
|
493
|
-
...options,
|
|
494
|
-
}, this, 'entities');
|
|
495
|
-
}
|
|
496
|
-
this.entities.splice(index, 0, entity);
|
|
497
|
-
return entity;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* 插入实体
|
|
502
|
-
* @param name 实体名称,如果不填会自动生成一个唯一名称
|
|
503
|
-
*/
|
|
504
|
-
insertEntityAt(name: string, index: number): Entity;
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* 插入实体
|
|
508
|
-
* @param entityOptions 实体参数
|
|
509
|
-
*/
|
|
510
|
-
insertEntityAt(entityOptions: Partial<Entity>, index: number): Entity;
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* 插入实体
|
|
514
|
-
* @param entity 已有的实体实例
|
|
515
|
-
*/
|
|
516
|
-
insertEntityAt(entity: Entity, index: number): Entity;
|
|
517
|
-
|
|
518
|
-
insertEntityAt(options: string | Partial<Entity> | Entity, index: number) {
|
|
519
|
-
const node = this._insertEntityAt(options as any, index);
|
|
520
|
-
node.create({
|
|
521
|
-
index,
|
|
522
|
-
parentNode: this,
|
|
523
|
-
parentKey: 'entities',
|
|
524
|
-
});
|
|
525
|
-
return node;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* 添加实体
|
|
530
|
-
* @internal
|
|
531
|
-
* @param name 实体名称,如果不填会自动生成一个唯一名称
|
|
532
|
-
*/
|
|
533
|
-
_addEntity(name?: string): Entity;
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* 添加实体
|
|
537
|
-
* @internal
|
|
538
|
-
* @param entityOptions 实体参数
|
|
539
|
-
*/
|
|
540
|
-
_addEntity(entityOptions: Partial<Entity>): Entity;
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* 添加实体
|
|
544
|
-
* @internal
|
|
545
|
-
* @param entity 已有的实体实例
|
|
546
|
-
*/
|
|
547
|
-
_addEntity(entity: Entity): Entity;
|
|
548
|
-
|
|
549
|
-
_addEntity(options?: string | Partial<Entity> | Entity) {
|
|
550
|
-
const index = 0;
|
|
551
|
-
return this._insertEntityAt(options as any, index);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* 添加实体
|
|
556
|
-
* @internal
|
|
557
|
-
* @param name 实体名称,如果不填会自动生成一个唯一名称
|
|
558
|
-
*/
|
|
559
|
-
addEntity(name?: string): Entity;
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* 添加实体
|
|
563
|
-
* @param entityOptions 实体参数
|
|
564
|
-
*/
|
|
565
|
-
addEntity(entityOptions: Partial<Entity>): Entity;
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* 添加实体
|
|
569
|
-
* @param entity 已有的实体实例
|
|
570
|
-
*/
|
|
571
|
-
addEntity(entity: Entity): Entity;
|
|
572
|
-
|
|
573
|
-
addEntity(options?: string | Partial<Entity> | Entity) {
|
|
574
|
-
const node = this._addEntity(options as any);
|
|
575
|
-
const index = this.entities.indexOf(node);
|
|
576
|
-
node.create({
|
|
577
|
-
index,
|
|
578
|
-
parentNode: this,
|
|
579
|
-
parentKey: 'entities',
|
|
580
|
-
});
|
|
581
|
-
return node;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
436
|
getStructureExistingNames(excludedList: Array<Structure> = []) {
|
|
586
437
|
const excludedSet = new Set(excludedList);
|
|
587
438
|
return (this.structures || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -1962,56 +1813,6 @@ export class Namespace extends BaseNode {
|
|
|
1962
1813
|
|
|
1963
1814
|
|
|
1964
1815
|
|
|
1965
|
-
/**
|
|
1966
|
-
* 删除实体
|
|
1967
|
-
* @param name 实体名称
|
|
1968
|
-
*/
|
|
1969
|
-
removeEntity(name: string): void;
|
|
1970
|
-
|
|
1971
|
-
/**
|
|
1972
|
-
* 删除实体
|
|
1973
|
-
* @param entity 已有的实体实例
|
|
1974
|
-
*/
|
|
1975
|
-
removeEntity(entity: Entity): void;
|
|
1976
|
-
|
|
1977
|
-
removeEntity(options: string | Entity) {
|
|
1978
|
-
let entity: Entity;
|
|
1979
|
-
if (typeof options === 'string') {
|
|
1980
|
-
entity = this.entities.find((item) => item.name === options);
|
|
1981
|
-
if (!entity) {
|
|
1982
|
-
throw new Error('找不到实体 ' + options);
|
|
1983
|
-
}
|
|
1984
|
-
} else {
|
|
1985
|
-
entity = options;
|
|
1986
|
-
}
|
|
1987
|
-
return entity.delete();
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
__removeEntity(entity: Entity) {
|
|
1991
|
-
const parentKey = entity.parentKey;
|
|
1992
|
-
const params: Params = {
|
|
1993
|
-
parentNode: this,
|
|
1994
|
-
parentKey,
|
|
1995
|
-
index: -1,
|
|
1996
|
-
object: null,
|
|
1997
|
-
oldObject: entity,
|
|
1998
|
-
};
|
|
1999
|
-
if (parentKey) {
|
|
2000
|
-
params.parentKey = parentKey;
|
|
2001
|
-
if (Array.isArray((this as any)[parentKey])) {
|
|
2002
|
-
const index = (this as any)[parentKey].indexOf(entity);
|
|
2003
|
-
~index && (this as any)[parentKey].splice(index, 1);
|
|
2004
|
-
params.index = index;
|
|
2005
|
-
} else if ((this as any)[parentKey] === entity) {
|
|
2006
|
-
params.index = 0;
|
|
2007
|
-
(this as any)[parentKey] = undefined;
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
return params;
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
1816
|
/**
|
|
2016
1817
|
* 删除数据结构
|
|
2017
1818
|
* @param name 数据结构名称
|
|
@@ -2465,10 +2266,6 @@ export class Namespace extends BaseNode {
|
|
|
2465
2266
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
2466
2267
|
//================================================================================
|
|
2467
2268
|
|
|
2468
|
-
findEntityByName(name: string) {
|
|
2469
|
-
return this.entities.find((entity) => entity.name === name);
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
2269
|
findEnumByName(name: string) {
|
|
2473
2270
|
return this.enums.find((enumItem) => enumItem.name === name);
|
|
2474
2271
|
}
|
|
@@ -2491,7 +2288,7 @@ export class Namespace extends BaseNode {
|
|
|
2491
2288
|
if (this.path)
|
|
2492
2289
|
return this.path;
|
|
2493
2290
|
else if (this.parentNode && (this.parentNode as Namespace).getNamespace)
|
|
2494
|
-
return `${(this.parentNode as Namespace).getNamespace()}
|
|
2291
|
+
return `${(this.parentNode as Namespace).getNamespace()}`;
|
|
2495
2292
|
else
|
|
2496
2293
|
throw new Error('无法获取命名空间,请设置 parentNode 或临时的 path!');
|
|
2497
2294
|
}
|
package/src/concepts/Param__.ts
CHANGED
|
@@ -7,6 +7,7 @@ import EntityProperty from './EntityProperty__';
|
|
|
7
7
|
import Structure from './Structure__';
|
|
8
8
|
import StructureProperty from './StructureProperty__';
|
|
9
9
|
import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
|
|
10
|
+
import Function from './Function__';
|
|
10
11
|
|
|
11
12
|
//================================================================================
|
|
12
13
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -237,7 +238,7 @@ export class Param extends BaseNode {
|
|
|
237
238
|
|
|
238
239
|
@excludedInJSON()
|
|
239
240
|
@property()
|
|
240
|
-
defaultExpression: LogicItem = undefined;
|
|
241
|
+
defaultExpression: LogicItem | Function = undefined;
|
|
241
242
|
@excludedInJSON()
|
|
242
243
|
@property()
|
|
243
244
|
options: Array<{ text?: string; value: string }> = undefined;
|
|
@@ -305,7 +306,7 @@ export class Param extends BaseNode {
|
|
|
305
306
|
typeAnnotation,
|
|
306
307
|
};
|
|
307
308
|
try {
|
|
308
|
-
this.completionChildren = this.getSelectRef();
|
|
309
|
+
this.completionChildren = this.getSelectRef(typeAnnotation);
|
|
309
310
|
} catch (err) {
|
|
310
311
|
this.completionChildren = [];
|
|
311
312
|
console.log(err);
|
|
@@ -350,12 +351,12 @@ export class Param extends BaseNode {
|
|
|
350
351
|
get isTreeLeaf() {
|
|
351
352
|
return !this.hasChildren;
|
|
352
353
|
}
|
|
353
|
-
getSelectRef() {
|
|
354
|
+
getSelectRef(newTypeAnnotation: TypeAnnotation) {
|
|
354
355
|
try {
|
|
355
|
-
const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
|
|
356
|
+
const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
|
|
356
357
|
let completionChildren;
|
|
357
358
|
if (typeKind === 'reference') {
|
|
358
|
-
if (typeNamespace === 'nasl.ui') {
|
|
359
|
+
if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
|
|
359
360
|
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
360
361
|
const properties = node.properties || [];
|
|
361
362
|
completionChildren = properties;
|
|
@@ -367,11 +368,18 @@ export class Param extends BaseNode {
|
|
|
367
368
|
completionChildren = properties;
|
|
368
369
|
}
|
|
369
370
|
} else if (typeKind === 'generic') {
|
|
370
|
-
if (typeNamespace === 'nasl.collection') {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
// if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
|
|
372
|
+
// }
|
|
373
|
+
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
374
|
+
const properties = node.properties || [];
|
|
375
|
+
for (let i = 0; i < properties.length; i++) {
|
|
376
|
+
const item = properties[i];
|
|
377
|
+
if (item?.typeAnnotation?.typeKind === 'typeParam') {
|
|
378
|
+
properties[i].typeAnnotation = this?.typeAnnotation?.typeArguments[0];
|
|
379
|
+
properties[i].parentNode = this;
|
|
380
|
+
}
|
|
374
381
|
}
|
|
382
|
+
completionChildren = properties;
|
|
375
383
|
} else {
|
|
376
384
|
completionChildren = undefined;
|
|
377
385
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState, embeddedTSEmitter } from '../translator';
|
|
2
|
-
import { constantToParam, genUserTaskLogic, returnToParam, getPreviousTask, syncMemberExpression } from '../server/getProcesses';
|
|
2
|
+
import { constantToParam, genUserTaskLogic, returnToParam, getPreviousTask, syncMemberExpression, getFlowAfterElements, isFromStartNode, getFlowBeforeElements } from '../server/getProcesses';
|
|
3
3
|
//================================================================================
|
|
4
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
5
5
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -1327,12 +1327,12 @@ export class ProcessElement extends BaseNode {
|
|
|
1327
1327
|
@withSourceMap()
|
|
1328
1328
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
1329
1329
|
// this.syncLogic();
|
|
1330
|
-
const tab0 = indent(state
|
|
1331
|
-
const tab1 = indent(state
|
|
1332
|
-
const tab3 = indent(state
|
|
1333
|
-
const tab4 = indent(state
|
|
1334
|
-
const tab5 = indent(state
|
|
1335
|
-
const tab6 = indent(state
|
|
1330
|
+
const tab0 = indent((state?.tabSize || 0));
|
|
1331
|
+
const tab1 = indent((state?.tabSize || 0) + 1);
|
|
1332
|
+
const tab3 = indent((state?.tabSize || 0) + 2);
|
|
1333
|
+
const tab4 = indent((state?.tabSize || 0) + 3);
|
|
1334
|
+
const tab5 = indent((state?.tabSize || 0) + 4);
|
|
1335
|
+
const tab6 = indent((state?.tabSize || 0) + 5);
|
|
1336
1336
|
let code = `${this.name}: {\n`;
|
|
1337
1337
|
this.variables.forEach((property) => {
|
|
1338
1338
|
code += `${tab1}`;
|
|
@@ -1346,9 +1346,11 @@ export class ProcessElement extends BaseNode {
|
|
|
1346
1346
|
code += `${tab1}`;
|
|
1347
1347
|
code += `${property.toEmbeddedTSInProcess(shiftState(state, code, { inline: true }))},\n`;
|
|
1348
1348
|
});
|
|
1349
|
-
|
|
1349
|
+
const afterLinks = getFlowAfterElements(this);
|
|
1350
|
+
const beforeLinks = getFlowBeforeElements(this);
|
|
1350
1351
|
if (this.type === 'UserTask'
|
|
1351
|
-
|| this.type === 'ExclusiveGateway'
|
|
1352
|
+
|| this.type === 'ExclusiveGateway'
|
|
1353
|
+
|| this.type === 'AutoTask') {
|
|
1352
1354
|
const prevTasks = getPreviousTask(this);
|
|
1353
1355
|
let prevCode = `${tab3}const ${this.process.name} = {\n`;
|
|
1354
1356
|
const processName = this.process.name;
|
|
@@ -1372,24 +1374,49 @@ export class ProcessElement extends BaseNode {
|
|
|
1372
1374
|
code += `${tab1}logics: {\n`;
|
|
1373
1375
|
this.bindAttrs.forEach((attr) => {
|
|
1374
1376
|
if (attr.name === 'destination') {
|
|
1375
|
-
code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state
|
|
1377
|
+
code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode)},\n`;
|
|
1378
|
+
}
|
|
1379
|
+
if (attr.name === 'assignee') {
|
|
1380
|
+
code += `assignee: function(): string[] {\n`
|
|
1381
|
+
code += `${attr.assignee.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state.tabSize + 3 }), prevCode)}\n`;
|
|
1382
|
+
code += `},\n`;
|
|
1376
1383
|
}
|
|
1377
1384
|
});
|
|
1378
1385
|
const logic = genUserTaskLogic(this);
|
|
1379
1386
|
// sourceMap 映射
|
|
1380
1387
|
logic.parentNode = this.process;
|
|
1381
1388
|
|
|
1382
|
-
code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state
|
|
1389
|
+
code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }));
|
|
1383
1390
|
code += ',\n';
|
|
1384
|
-
code += `${tab1}}`;
|
|
1391
|
+
code += `${tab1}},\n`;
|
|
1385
1392
|
}
|
|
1386
1393
|
|
|
1387
|
-
if
|
|
1388
|
-
prevCode += `\n${tab5}${this.name}: elements.${this.name},\n
|
|
1394
|
+
if(this.type === 'ExclusiveGateway' || this.type === 'AutoTask') {
|
|
1395
|
+
prevCode += `\n${tab5}${this.name}: elements.${this.name},\n`
|
|
1389
1396
|
prevCode += `${tab3}}\n`;
|
|
1390
|
-
code += `${tab1}logic:
|
|
1397
|
+
code += `${tab1}logic: `;
|
|
1398
|
+
code += `${this.logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode, true)},\n`;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
if(this.type === 'UserTask' || this.type === 'AutoTask' || this.type === 'StartNoneEvent') {
|
|
1402
|
+
code += '_constraints: function() {\n'
|
|
1403
|
+
code += `${tab1}nasl.process.oneOutcomeFlow(${afterLinks.map(l => `'${l.name}'`).join(',')})\n`
|
|
1404
|
+
code += '},\n'
|
|
1405
|
+
}
|
|
1406
|
+
if(this.type === 'ExclusiveGateway' || this.type === 'ParallelGateway') {
|
|
1407
|
+
code += '_constraints: function() {\n'
|
|
1408
|
+
code += `${tab1}nasl.process.atLeastOneOutcomeFlow(${afterLinks.map(l => `'${l.name}'`).join(',')})\n`
|
|
1409
|
+
code += `${tab1}nasl.process.atLeastOneOutcomeFlow(${beforeLinks.map(l => `'${l.name}'`).join(',')})\n`
|
|
1410
|
+
if(afterLinks.length > 0 && beforeLinks.length > 0) {
|
|
1411
|
+
code += `${tab1}nasl.process.atLeastThreeOutcomeFlow(${beforeLinks.concat(afterLinks).map(l => `'${l.name}'`).join(',')})\n`
|
|
1391
1412
|
}
|
|
1413
|
+
code += '},\n'
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
if(!isFromStartNode(this)){
|
|
1417
|
+
code += '__outOfProcess__,';
|
|
1392
1418
|
}
|
|
1419
|
+
|
|
1393
1420
|
code += `${tab0}\n},`;
|
|
1394
1421
|
// let code = '';
|
|
1395
1422
|
// this.variables.forEach((property) => {
|
|
@@ -949,15 +949,21 @@ export class Process extends BaseNode {
|
|
|
949
949
|
return params;
|
|
950
950
|
}
|
|
951
951
|
|
|
952
|
-
getVarExistingNames(excludedList: Array<Param | Return | Constant> = []) {
|
|
952
|
+
getVarExistingNames(excludedList: Array<Param | Return | Constant | ProcessElement> = []) {
|
|
953
953
|
const excludedSet = new Set(excludedList);
|
|
954
|
-
return [...this.params, ...this.returns, ...this.constants].filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
954
|
+
return [...this.params, ...this.returns, ...this.constants, ...this.elements].filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
955
955
|
}
|
|
956
956
|
|
|
957
957
|
getNamespace(ns: string) {
|
|
958
|
-
if (this.parentNode && (this.parentNode as Namespace).getNamespace)
|
|
959
|
-
|
|
960
|
-
|
|
958
|
+
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
959
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
960
|
+
const parentName = this.parentNode.name;
|
|
961
|
+
const arr = [parentNamespace];
|
|
962
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
963
|
+
arr.push(parentName);
|
|
964
|
+
}
|
|
965
|
+
return `${arr.join('.')}.${ns || 'processes'}`;
|
|
966
|
+
} else
|
|
961
967
|
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
962
968
|
}
|
|
963
969
|
|
|
@@ -1003,17 +1009,17 @@ export class Process extends BaseNode {
|
|
|
1003
1009
|
@withSourceMap()
|
|
1004
1010
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
1005
1011
|
let code = `export namespace ${this.name} {\n`;
|
|
1006
|
-
const tab0 = indent(state
|
|
1007
|
-
const tab1 = indent(state
|
|
1008
|
-
const tab2 = indent(state
|
|
1009
|
-
const tab3 = indent(state
|
|
1012
|
+
const tab0 = indent((state?.tabSize || 0));
|
|
1013
|
+
const tab1 = indent((state?.tabSize || 0) + 1);
|
|
1014
|
+
const tab2 = indent((state?.tabSize || 0) + 2);
|
|
1015
|
+
const tab3 = indent((state?.tabSize || 0) + 3);
|
|
1010
1016
|
// code += `${tab1}namespace variables{\n`;
|
|
1011
1017
|
|
|
1012
1018
|
code += `${tab1}export namespace logics {\n`;
|
|
1013
1019
|
const logic = genLaunchProcess(this);
|
|
1014
1020
|
// sourceMap 映射
|
|
1015
1021
|
logic.parentNode = this;
|
|
1016
|
-
code += logic.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
1022
|
+
code += logic.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 2 }));
|
|
1017
1023
|
code += `${tab1}}\n`;
|
|
1018
1024
|
|
|
1019
1025
|
this.params.forEach((property) => {
|
|
@@ -1037,8 +1043,8 @@ export class Process extends BaseNode {
|
|
|
1037
1043
|
|
|
1038
1044
|
this.elements.forEach((ele) => {
|
|
1039
1045
|
code += '\n';
|
|
1040
|
-
if (ele.type
|
|
1041
|
-
code += ele.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
1046
|
+
if (ele.type !== 'EndNoneEvent' && ele.type !== 'SequenceFlow') {
|
|
1047
|
+
code += ele.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1042
1048
|
}
|
|
1043
1049
|
});
|
|
1044
1050
|
code += `${tab1}}\n`;
|
|
@@ -138,7 +138,7 @@ export class QueryAggregateExpression extends LogicItem {
|
|
|
138
138
|
// code += `[__EMPTY_AGGREGATE_NAME__, '']`;
|
|
139
139
|
|
|
140
140
|
// return code;
|
|
141
|
-
return `__${this.asName || '
|
|
141
|
+
return `__${this.asName || 'EMPTY_AGGREGATE_ALIAS__'}`;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
setName(asName: string) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
|
+
import CallQueryComponent from './CallQueryComponent__';
|
|
2
3
|
//================================================================================
|
|
3
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
4
5
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -103,6 +104,10 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
103
104
|
};
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
setName(asName: string) {
|
|
108
|
+
this.update({ asName });
|
|
109
|
+
}
|
|
110
|
+
|
|
106
111
|
getValue() {
|
|
107
112
|
const { entityAsName, propertyName } = this;
|
|
108
113
|
return `${entityAsName}.${propertyName}`;
|
|
@@ -111,7 +116,14 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
111
116
|
@withSourceMap()
|
|
112
117
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
113
118
|
const { entityAsName, propertyName } = this;
|
|
114
|
-
|
|
119
|
+
const callQueryComponent = this.getAncestor('CallQueryComponent') as CallQueryComponent;
|
|
120
|
+
if (callQueryComponent) {
|
|
121
|
+
const entityNamespace = callQueryComponent?.from?.entityNamespace;
|
|
122
|
+
if (entityNamespace && entityAsName && propertyName) {
|
|
123
|
+
return `new ${entityNamespace}.${entityAsName}().${propertyName}`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return '__QueryFieldExpression__';
|
|
115
127
|
}
|
|
116
128
|
|
|
117
129
|
//================================================================================
|
|
@@ -224,6 +224,17 @@ export class QueryFromExpression extends LogicItem {
|
|
|
224
224
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
225
225
|
//================================================================================
|
|
226
226
|
|
|
227
|
+
/**
|
|
228
|
+
* 设置实体namespace字段
|
|
229
|
+
*/
|
|
230
|
+
setEntityNamespace(entityNamespace: string) {
|
|
231
|
+
const object = {
|
|
232
|
+
entityNamespace,
|
|
233
|
+
};
|
|
234
|
+
this.update({
|
|
235
|
+
...object,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
227
238
|
get entityKey(): string {
|
|
228
239
|
return `${this.entityNamespace}.${this.entityName}`;
|
|
229
240
|
}
|
|
@@ -235,10 +246,10 @@ export class QueryFromExpression extends LogicItem {
|
|
|
235
246
|
if (this.joinParts.length) {
|
|
236
247
|
code += '\n';
|
|
237
248
|
this.joinParts.forEach((joinPart) => {
|
|
238
|
-
code += joinPart.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
249
|
+
code += joinPart.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
239
250
|
});
|
|
240
251
|
}
|
|
241
|
-
code += `${indent(state
|
|
252
|
+
code += `${indent((state?.tabSize || 0))})\n`;
|
|
242
253
|
return code;
|
|
243
254
|
}
|
|
244
255
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { withSourceMap } from '../translator';
|
|
2
|
+
import type CallQueryComponent from './CallQueryComponent__';
|
|
3
|
+
import type QueryFieldExpression from './QueryFieldExpression__';
|
|
4
|
+
|
|
1
5
|
//================================================================================
|
|
2
6
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
3
7
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -125,6 +129,25 @@ export class QueryGroupByExpression extends LogicItem {
|
|
|
125
129
|
};
|
|
126
130
|
}
|
|
127
131
|
|
|
132
|
+
setEntityAsName(name: string) {
|
|
133
|
+
(this.groupElement as QueryFieldExpression).setEntityAsName(name);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
setPropertyName(name: string) {
|
|
137
|
+
(this.groupElement as QueryFieldExpression).setPropertyName(name);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@withSourceMap()
|
|
141
|
+
toEmbeddedTS(): string {
|
|
142
|
+
// 判断老应用
|
|
143
|
+
if ((this.parentNode as CallQueryComponent).isAutoInfer()) {
|
|
144
|
+
// 2.11版本后 分组使用别名
|
|
145
|
+
return `__${(this.groupElement as QueryFieldExpression).asName || 'EMPTY_GROUP_BY_ALIAS__'}`;
|
|
146
|
+
} else {
|
|
147
|
+
return (this.groupElement as QueryFieldExpression).toEmbeddedTS();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
128
151
|
//================================================================================
|
|
129
152
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
130
153
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -406,19 +406,30 @@ export class QueryJoinExpression extends LogicItem {
|
|
|
406
406
|
return `${this.entityNamespace}.${this.entityName}`;
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
+
/**
|
|
410
|
+
* 设置实体namespace字段
|
|
411
|
+
*/
|
|
412
|
+
setEntityNamespace(entityNamespace: string) {
|
|
413
|
+
const object = {
|
|
414
|
+
entityNamespace,
|
|
415
|
+
};
|
|
416
|
+
this.update({
|
|
417
|
+
...object,
|
|
418
|
+
});
|
|
419
|
+
}
|
|
409
420
|
@withSourceMap()
|
|
410
421
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
411
422
|
let code = '';
|
|
412
423
|
code += `.${this.joinType}_JOIN(new nasl.langUtil.Collection<[${this.entityKey}]>())\n`;
|
|
413
424
|
if (this.onExpressions.length > 0) {
|
|
414
|
-
code += indent(state
|
|
425
|
+
code += indent((state?.tabSize || 0)) + `.ON(() => `;
|
|
415
426
|
this.onExpressions.forEach((expression, index) => {
|
|
416
427
|
if (index > 0)
|
|
417
|
-
code += `\n${indent(state
|
|
428
|
+
code += `\n${indent((state?.tabSize || 0) + 1)}&& `;
|
|
418
429
|
code += expression.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
|
|
419
430
|
});
|
|
420
431
|
if (this.onExpressions.length > 1)
|
|
421
|
-
code += `\n${indent(state
|
|
432
|
+
code += `\n${indent((state?.tabSize || 0))}`;
|
|
422
433
|
code += ')\n';
|
|
423
434
|
}
|
|
424
435
|
if (this.joinParts.length > 0) {
|
package/src/concepts/Return__.ts
CHANGED
|
@@ -252,9 +252,9 @@ export class Return extends BaseNode {
|
|
|
252
252
|
code += ': undefined as ';
|
|
253
253
|
code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
|
|
254
254
|
}
|
|
255
|
-
if (this.defaultValue) {
|
|
256
|
-
|
|
257
|
-
}
|
|
255
|
+
// if (this.defaultValue) {
|
|
256
|
+
// code += `: ${this.defaultValue}`;
|
|
257
|
+
// }
|
|
258
258
|
return code;
|
|
259
259
|
}
|
|
260
260
|
|
|
@@ -284,7 +284,7 @@ export class Return extends BaseNode {
|
|
|
284
284
|
}
|
|
285
285
|
// 处理下拉属性
|
|
286
286
|
try {
|
|
287
|
-
this.completionChildren = this.getSelectRef();
|
|
287
|
+
this.completionChildren = this.getSelectRef(typeAnnotation);
|
|
288
288
|
} catch (err) {
|
|
289
289
|
this.completionChildren = [];
|
|
290
290
|
console.log(err);
|
|
@@ -327,12 +327,12 @@ export class Return extends BaseNode {
|
|
|
327
327
|
get isTreeLeaf() {
|
|
328
328
|
return !this.hasChildren;
|
|
329
329
|
}
|
|
330
|
-
getSelectRef() {
|
|
330
|
+
getSelectRef(newTypeAnnotation: TypeAnnotation) {
|
|
331
331
|
try {
|
|
332
|
-
const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
|
|
332
|
+
const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
|
|
333
333
|
let completionChildren;
|
|
334
334
|
if (typeKind === 'reference') {
|
|
335
|
-
if (typeNamespace === 'nasl.ui') {
|
|
335
|
+
if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
|
|
336
336
|
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
337
337
|
const properties = node.properties || [];
|
|
338
338
|
completionChildren = properties;
|
|
@@ -344,11 +344,16 @@ export class Return extends BaseNode {
|
|
|
344
344
|
completionChildren = properties;
|
|
345
345
|
}
|
|
346
346
|
} else if (typeKind === 'generic') {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
347
|
+
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
348
|
+
const properties = node.properties || [];
|
|
349
|
+
for (let i = 0; i < properties.length; i++) {
|
|
350
|
+
const item = properties[i];
|
|
351
|
+
if (item?.typeAnnotation?.typeKind === 'typeParam') {
|
|
352
|
+
properties[i].typeAnnotation = this?.typeAnnotation?.typeArguments[0];
|
|
353
|
+
properties[i].parentNode = this;
|
|
354
|
+
}
|
|
351
355
|
}
|
|
356
|
+
completionChildren = properties;
|
|
352
357
|
} else {
|
|
353
358
|
completionChildren = undefined;
|
|
354
359
|
}
|