@lcap/nasl 1.0.2 → 2.12.0-beta
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.js +11 -0
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.js +1 -1
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +89 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/concepts/App__.d.ts +51 -49
- package/out/concepts/App__.js +86 -54
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +1 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.js +1 -1
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +1 -1
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +3 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +11 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +8 -3
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +1 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +23 -21
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +9 -8
- package/out/concepts/CallQueryComponent__.js +89 -79
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +2 -2
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +1 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +8 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigPropertyValue__.js +1 -1
- package/out/concepts/ConfigPropertyValue__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +4 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +4 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataElement__.js +1 -1
- package/out/concepts/DataElement__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +316 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +8 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +3 -3
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +7 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +20 -3
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -0
- package/out/concepts/Entity__.js +21 -11
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +11 -5
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +3 -3
- 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 +3 -13
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +9 -9
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +1 -1
- 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 +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.js +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +41 -42
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +1 -85
- package/out/concepts/Module__.js +6 -107
- 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/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/Param__.d.ts +2 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Point__.js +1 -1
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +26 -11
- 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/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__.js +9 -2
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +14 -3
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.js +1 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +15 -4
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.js +1 -1
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +11 -4
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/Slot__.js +1 -1
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +10 -0
- package/out/concepts/SqlQueryComponent__.js +32 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +20 -13
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +6 -6
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.js +1 -1
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.js +1 -1
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +46 -4
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +1 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.js +1 -1
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +1 -1
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.js +18 -18
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +25 -23
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +5 -5
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +278 -0
- package/out/concepts/basics/stdlib/nasl.util.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/generator/genBundleFiles.js +8 -3
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +13 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +9 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getProcesses.d.ts +3 -0
- package/out/server/getProcesses.js +61 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +128 -6
- 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.js +19 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +2 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +15 -11
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +25 -21
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +12 -12
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +21 -20
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +6 -3
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +5 -5
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +8 -7
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +17 -15
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +15 -11
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- 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 +4 -0
- package/out/utils/index.js +32 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/automate/engine/index.js +12 -1
- package/src/automate/engine/uniqueName.js +1 -1
- package/src/automate/engine/utils.js +92 -67
- package/src/concepts/App__.ts +165 -95
- package/src/concepts/Argument__.ts +1 -1
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/Attribute__.ts +1 -1
- package/src/concepts/BinaryExpression__.ts +1 -1
- package/src/concepts/BindAttribute__.ts +3 -3
- package/src/concepts/BindDirective__.ts +1 -1
- package/src/concepts/BindEvent__.ts +10 -6
- package/src/concepts/BooleanLiteral__.ts +1 -1
- package/src/concepts/CallFunction__.ts +19 -16
- package/src/concepts/CallInterface__.ts +1 -1
- package/src/concepts/CallLogic__.ts +23 -23
- package/src/concepts/CallQueryComponent__.ts +96 -113
- package/src/concepts/Comment__.ts +2 -2
- package/src/concepts/CompletionProperty__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +4 -2
- package/src/concepts/ConfigPropertyValue__.ts +1 -1
- package/src/concepts/ConfigProperty__.ts +5 -1
- package/src/concepts/Configuration__.ts +4 -1
- package/src/concepts/Constant__.ts +1 -1
- package/src/concepts/DataElement__.ts +1 -1
- package/src/concepts/DataSource__.ts +389 -0
- package/src/concepts/Destination__.ts +24 -8
- package/src/concepts/End__.ts +3 -3
- package/src/concepts/EntityIndex__.ts +8 -1
- package/src/concepts/EntityProperty__.ts +21 -3
- package/src/concepts/Entity__.ts +24 -12
- package/src/concepts/EnumItem__.ts +1 -1
- package/src/concepts/Enum__.ts +24 -5
- package/src/concepts/Event__.ts +1 -1
- package/src/concepts/ForEachStatement__.ts +3 -3
- package/src/concepts/Function__.ts +97 -3
- package/src/concepts/Identifier__.ts +12 -13
- package/src/concepts/IfStatement__.ts +10 -10
- package/src/concepts/InterfaceParam__.ts +1 -1
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +1 -1
- package/src/concepts/LogicItem__.ts +1 -1
- package/src/concepts/Logic__.ts +41 -39
- package/src/concepts/MemberExpression__.ts +1 -1
- package/src/concepts/Module__.ts +9 -204
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/NullLiteral__.ts +1 -1
- package/src/concepts/NumericLiteral__.ts +1 -1
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/Point__.ts +1 -1
- package/src/concepts/ProcessComponent__.ts +1 -1
- package/src/concepts/ProcessElement__.ts +29 -13
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/Process__.ts +17 -11
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +10 -2
- package/src/concepts/QueryFromExpression__.ts +14 -3
- package/src/concepts/QueryGroupByExpression__.ts +1 -1
- package/src/concepts/QueryJoinExpression__.ts +15 -4
- package/src/concepts/QueryLimitExpression__.ts +1 -1
- package/src/concepts/QueryOrderByExpression__.ts +1 -1
- package/src/concepts/QuerySelectExpression__.ts +1 -1
- package/src/concepts/Rect__.ts +1 -1
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +11 -5
- package/src/concepts/Slot__.ts +1 -1
- package/src/concepts/SqlQueryComponent__.ts +30 -11
- package/src/concepts/Start__.ts +1 -1
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +1 -1
- package/src/concepts/Structure__.ts +20 -12
- package/src/concepts/SwitchCase__.ts +6 -6
- package/src/concepts/SwitchStatement__.ts +1 -1
- package/src/concepts/Theme__.ts +1 -1
- package/src/concepts/Transactional__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +45 -23
- package/src/concepts/TypeParam__.ts +1 -1
- package/src/concepts/UnaryExpression__.ts +1 -1
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/UseComponent__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +1 -1
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewComponent__.ts +1 -1
- package/src/concepts/ViewElement__.ts +19 -19
- package/src/concepts/View__.ts +25 -23
- package/src/concepts/WhileStatement__.ts +5 -5
- package/src/concepts/basics/stdlib/nasl.util.ts +279 -0
- package/src/concepts/index__.ts +1 -0
- package/src/generator/genBundleFiles.ts +8 -3
- package/src/generator/genMetaData.ts +13 -13
- package/src/server/createUiTs.ts +1 -0
- package/src/server/getLogics.ts +11 -3
- package/src/server/getProcesses.ts +61 -0
- package/src/server/naslServer.ts +124 -6
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +22 -1
- package/src/service/storage/init.ts +2 -2
- package/src/templator/genCreateBlock.ts +16 -13
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
- package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
- package/src/templator/genEditTableBlock.ts +14 -13
- package/src/templator/genGridViewBlock.ts +22 -21
- package/src/templator/genListViewBlock.ts +9 -5
- package/src/templator/genQueryComponent.ts +6 -6
- package/src/templator/genSelectBlock.ts +9 -8
- package/src/templator/genTableBlock.ts +18 -16
- package/src/templator/genUpdateBlock.ts +16 -12
- package/src/templator/utils.ts +2 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +32 -0
|
@@ -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
|
}
|
|
@@ -2522,7 +2319,7 @@ export class Namespace extends BaseNode {
|
|
|
2522
2319
|
//================================================================================
|
|
2523
2320
|
}
|
|
2524
2321
|
|
|
2525
|
-
classMap
|
|
2322
|
+
classMap.Namespace = Namespace;
|
|
2526
2323
|
export default Namespace;
|
|
2527
2324
|
//================================================================================
|
|
2528
2325
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -76,7 +76,7 @@ export class NullLiteral extends LogicItem {
|
|
|
76
76
|
//================================================================================
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
classMap
|
|
79
|
+
classMap.NullLiteral = NullLiteral;
|
|
80
80
|
export default NullLiteral;
|
|
81
81
|
//================================================================================
|
|
82
82
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -187,7 +187,7 @@ export class NumericLiteral extends LogicItem {
|
|
|
187
187
|
//================================================================================
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
classMap
|
|
190
|
+
classMap.NumericLiteral = NumericLiteral;
|
|
191
191
|
export default NumericLiteral;
|
|
192
192
|
//================================================================================
|
|
193
193
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
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;
|
|
@@ -393,7 +394,7 @@ export class Param extends BaseNode {
|
|
|
393
394
|
//================================================================================
|
|
394
395
|
}
|
|
395
396
|
|
|
396
|
-
classMap
|
|
397
|
+
classMap.Param = Param;
|
|
397
398
|
export default Param;
|
|
398
399
|
//================================================================================
|
|
399
400
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
package/src/concepts/Point__.ts
CHANGED
|
@@ -77,7 +77,7 @@ export class Point extends BaseNode {
|
|
|
77
77
|
//================================================================================
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
classMap
|
|
80
|
+
classMap.Point = Point;
|
|
81
81
|
export default Point;
|
|
82
82
|
//================================================================================
|
|
83
83
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -495,7 +495,7 @@ export class ProcessComponent extends BaseNode {
|
|
|
495
495
|
//================================================================================
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
classMap
|
|
498
|
+
classMap.ProcessComponent = ProcessComponent;
|
|
499
499
|
export default ProcessComponent;
|
|
500
500
|
//================================================================================
|
|
501
501
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -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 } 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,7 +1346,7 @@ 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
1350
|
if (this.type === 'UserTask'
|
|
1351
1351
|
|| this.type === 'ExclusiveGateway'
|
|
1352
1352
|
|| this.type === 'AutoTask') {
|
|
@@ -1373,7 +1373,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1373
1373
|
code += `${tab1}logics: {\n`;
|
|
1374
1374
|
this.bindAttrs.forEach((attr) => {
|
|
1375
1375
|
if (attr.name === 'destination') {
|
|
1376
|
-
code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state
|
|
1376
|
+
code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode)},\n`;
|
|
1377
1377
|
}
|
|
1378
1378
|
if (attr.name === 'assignee') {
|
|
1379
1379
|
code += `assignee: function(): string[] {\n`
|
|
@@ -1385,17 +1385,33 @@ export class ProcessElement extends BaseNode {
|
|
|
1385
1385
|
// sourceMap 映射
|
|
1386
1386
|
logic.parentNode = this.process;
|
|
1387
1387
|
|
|
1388
|
-
code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state
|
|
1388
|
+
code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }));
|
|
1389
1389
|
code += ',\n';
|
|
1390
|
-
code += `${tab1}}`;
|
|
1390
|
+
code += `${tab1}},\n`;
|
|
1391
1391
|
}
|
|
1392
1392
|
|
|
1393
1393
|
if(this.type === 'ExclusiveGateway' || this.type === 'AutoTask') {
|
|
1394
1394
|
prevCode += `\n${tab5}${this.name}: elements.${this.name},\n`
|
|
1395
1395
|
prevCode += `${tab3}}\n`;
|
|
1396
|
-
code += `${tab1}logic:
|
|
1396
|
+
code += `${tab1}logic: `;
|
|
1397
|
+
code += `${this.logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode, true)},\n`;
|
|
1397
1398
|
}
|
|
1398
1399
|
}
|
|
1400
|
+
if(this.type === 'UserTask' || this.type === 'AutoTask' || this.type === 'StartNoneEvent') {
|
|
1401
|
+
code += '_constraints: function() {\n'
|
|
1402
|
+
code += `${tab1}nasl.process.oneOutcomeFlow(${afterLinks.map(l => `'${l.name}'`).join(',')})\n`
|
|
1403
|
+
code += '},\n'
|
|
1404
|
+
}
|
|
1405
|
+
if(this.type === 'ExclusiveGateway' || this.type === 'ParallelGateway') {
|
|
1406
|
+
code += '_constraints: function() {\n'
|
|
1407
|
+
code += `${tab1}nasl.process.atLeastTwoOutcomeFlow(${afterLinks.map(l => `'${l.name}'`).join(',')})\n`
|
|
1408
|
+
code += '},\n'
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
if(!isFromStartNode(this)){
|
|
1412
|
+
code += '__outOfProcess__,';
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1399
1415
|
code += `${tab0}\n},`;
|
|
1400
1416
|
// let code = '';
|
|
1401
1417
|
// this.variables.forEach((property) => {
|
|
@@ -1454,7 +1470,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1454
1470
|
//================================================================================
|
|
1455
1471
|
}
|
|
1456
1472
|
|
|
1457
|
-
classMap
|
|
1473
|
+
classMap.ProcessElement = ProcessElement;
|
|
1458
1474
|
export default ProcessElement;
|
|
1459
1475
|
//================================================================================
|
|
1460
1476
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -84,7 +84,7 @@ export class ProcessOutcome extends LogicItem {
|
|
|
84
84
|
//================================================================================
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
classMap
|
|
87
|
+
classMap.ProcessOutcome = ProcessOutcome;
|
|
88
88
|
export default ProcessOutcome;
|
|
89
89
|
//================================================================================
|
|
90
90
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -955,9 +955,15 @@ export class Process extends BaseNode {
|
|
|
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`;
|
|
@@ -1114,7 +1120,7 @@ export class Process extends BaseNode {
|
|
|
1114
1120
|
//================================================================================
|
|
1115
1121
|
}
|
|
1116
1122
|
|
|
1117
|
-
classMap
|
|
1123
|
+
classMap.Process = Process;
|
|
1118
1124
|
export default Process;
|
|
1119
1125
|
//================================================================================
|
|
1120
1126
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -156,7 +156,7 @@ export class QueryAggregateExpression extends LogicItem {
|
|
|
156
156
|
//================================================================================
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
classMap
|
|
159
|
+
classMap.QueryAggregateExpression = QueryAggregateExpression;
|
|
160
160
|
export default QueryAggregateExpression;
|
|
161
161
|
//================================================================================
|
|
162
162
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -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
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -115,7 +116,14 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
115
116
|
@withSourceMap()
|
|
116
117
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
117
118
|
const { entityAsName, propertyName } = this;
|
|
118
|
-
|
|
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__';
|
|
119
127
|
}
|
|
120
128
|
|
|
121
129
|
//================================================================================
|
|
@@ -124,7 +132,7 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
124
132
|
//================================================================================
|
|
125
133
|
}
|
|
126
134
|
|
|
127
|
-
classMap
|
|
135
|
+
classMap.QueryFieldExpression = QueryFieldExpression;
|
|
128
136
|
export default QueryFieldExpression;
|
|
129
137
|
//================================================================================
|
|
130
138
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -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
|
|
|
@@ -248,7 +259,7 @@ export class QueryFromExpression extends LogicItem {
|
|
|
248
259
|
//================================================================================
|
|
249
260
|
}
|
|
250
261
|
|
|
251
|
-
classMap
|
|
262
|
+
classMap.QueryFromExpression = QueryFromExpression;
|
|
252
263
|
export default QueryFromExpression;
|
|
253
264
|
//================================================================================
|
|
254
265
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -154,7 +154,7 @@ export class QueryGroupByExpression extends LogicItem {
|
|
|
154
154
|
//================================================================================
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
classMap
|
|
157
|
+
classMap.QueryGroupByExpression = QueryGroupByExpression;
|
|
158
158
|
export default QueryGroupByExpression;
|
|
159
159
|
//================================================================================
|
|
160
160
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -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) {
|
|
@@ -435,7 +446,7 @@ export class QueryJoinExpression extends LogicItem {
|
|
|
435
446
|
//================================================================================
|
|
436
447
|
}
|
|
437
448
|
|
|
438
|
-
classMap
|
|
449
|
+
classMap.QueryJoinExpression = QueryJoinExpression;
|
|
439
450
|
export default QueryJoinExpression;
|
|
440
451
|
//================================================================================
|
|
441
452
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -180,7 +180,7 @@ export class QueryLimitExpression extends LogicItem {
|
|
|
180
180
|
//================================================================================
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
classMap
|
|
183
|
+
classMap.QueryLimitExpression = QueryLimitExpression;
|
|
184
184
|
export default QueryLimitExpression;
|
|
185
185
|
//================================================================================
|
|
186
186
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -194,7 +194,7 @@ export class QueryOrderByExpression extends LogicItem {
|
|
|
194
194
|
//================================================================================
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
classMap
|
|
197
|
+
classMap.QueryOrderByExpression = QueryOrderByExpression;
|
|
198
198
|
export default QueryOrderByExpression;
|
|
199
199
|
//================================================================================
|
|
200
200
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -272,7 +272,7 @@ export class QuerySelectExpression extends LogicItem {
|
|
|
272
272
|
//================================================================================
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
classMap
|
|
275
|
+
classMap.QuerySelectExpression = QuerySelectExpression;
|
|
276
276
|
export default QuerySelectExpression;
|
|
277
277
|
//================================================================================
|
|
278
278
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
package/src/concepts/Rect__.ts
CHANGED
|
@@ -89,7 +89,7 @@ export class Rect extends BaseNode {
|
|
|
89
89
|
//================================================================================
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
classMap
|
|
92
|
+
classMap.Rect = Rect;
|
|
93
93
|
export default Rect;
|
|
94
94
|
//================================================================================
|
|
95
95
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
package/src/concepts/Return__.ts
CHANGED
|
@@ -368,7 +368,7 @@ export class Return extends BaseNode {
|
|
|
368
368
|
//================================================================================
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
classMap
|
|
371
|
+
classMap.Return = Return;
|
|
372
372
|
export default Return;
|
|
373
373
|
//================================================================================
|
|
374
374
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|