@lcap/nasl 1.0.2 → 2.12.0
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 +92 -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 +5 -0
- package/out/common/BaseNode.js +24 -3
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +51 -49
- package/out/concepts/App__.js +86 -53
- package/out/concepts/App__.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 +8 -2
- 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 +8 -7
- package/out/concepts/CallQueryComponent__.js +86 -76
- 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/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 +8 -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 +6 -0
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +19 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -0
- package/out/concepts/Entity__.js +20 -10
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +12 -6
- 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 +6 -15
- 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/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 +2 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +30 -10
- 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/QueryFieldExpression__.js +8 -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/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- 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 +1 -1
- package/out/concepts/StructureProperty__.js +6 -5
- 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 +44 -2
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- 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 +0 -2
- package/out/concepts/View__.js +27 -32
- 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.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 +280 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +4 -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/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/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +27 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +5 -0
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +4 -0
- package/out/server/getProcesses.js +69 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -0
- package/out/server/naslServer.js +223 -26
- 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 +37 -1
- 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 +95 -84
- 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/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 +25 -26
- 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 +31 -21
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +34 -24
- 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 +5 -0
- package/out/utils/index.js +50 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
- 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 +95 -68
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +21 -4
- package/src/concepts/App__.ts +128 -94
- 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 +6 -2
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +92 -81
- 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/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +24 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +7 -0
- package/src/concepts/EntityProperty__.ts +20 -2
- package/src/concepts/Entity__.ts +23 -11
- package/src/concepts/Enum__.ts +25 -6
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +15 -15
- package/src/concepts/IfStatement__.ts +9 -9
- 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 +3 -2
- package/src/concepts/ProcessElement__.ts +33 -12
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryFieldExpression__.ts +9 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +6 -9
- 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 +43 -2
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +29 -34
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- 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 +281 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/index__.ts +1 -0
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/getLogics.ts +29 -4
- package/src/server/getMemberIdentifier.ts +4 -0
- package/src/server/getProcesses.ts +68 -0
- package/src/server/naslServer.ts +227 -30
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +39 -1
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +97 -86
- 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/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +28 -27
- package/src/templator/genSelectBlock.ts +9 -8
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +35 -25
- 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 +51 -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
|
}
|
|
@@ -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;
|
|
@@ -355,7 +356,7 @@ export class Param extends BaseNode {
|
|
|
355
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;
|
|
@@ -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,7 +1346,8 @@ 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
1352
|
|| this.type === 'ExclusiveGateway'
|
|
1352
1353
|
|| this.type === 'AutoTask') {
|
|
@@ -1373,7 +1374,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1373
1374
|
code += `${tab1}logics: {\n`;
|
|
1374
1375
|
this.bindAttrs.forEach((attr) => {
|
|
1375
1376
|
if (attr.name === 'destination') {
|
|
1376
|
-
code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state
|
|
1377
|
+
code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode)},\n`;
|
|
1377
1378
|
}
|
|
1378
1379
|
if (attr.name === 'assignee') {
|
|
1379
1380
|
code += `assignee: function(): string[] {\n`
|
|
@@ -1385,17 +1386,37 @@ export class ProcessElement extends BaseNode {
|
|
|
1385
1386
|
// sourceMap 映射
|
|
1386
1387
|
logic.parentNode = this.process;
|
|
1387
1388
|
|
|
1388
|
-
code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state
|
|
1389
|
+
code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }));
|
|
1389
1390
|
code += ',\n';
|
|
1390
|
-
code += `${tab1}}`;
|
|
1391
|
+
code += `${tab1}},\n`;
|
|
1391
1392
|
}
|
|
1392
1393
|
|
|
1393
1394
|
if(this.type === 'ExclusiveGateway' || this.type === 'AutoTask') {
|
|
1394
1395
|
prevCode += `\n${tab5}${this.name}: elements.${this.name},\n`
|
|
1395
1396
|
prevCode += `${tab3}}\n`;
|
|
1396
|
-
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`
|
|
1397
1412
|
}
|
|
1413
|
+
code += '},\n'
|
|
1398
1414
|
}
|
|
1415
|
+
|
|
1416
|
+
if(!isFromStartNode(this)){
|
|
1417
|
+
code += '__outOfProcess__,';
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1399
1420
|
code += `${tab0}\n},`;
|
|
1400
1421
|
// let code = '';
|
|
1401
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`;
|
|
@@ -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
|
//================================================================================
|
|
@@ -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
|
|
|
@@ -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
|
@@ -332,7 +332,7 @@ export class Return extends BaseNode {
|
|
|
332
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;
|
package/src/concepts/Role__.ts
CHANGED
|
@@ -104,7 +104,7 @@ export class Role extends BaseNode {
|
|
|
104
104
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
105
105
|
let code = `export enum ${this.tsName} {\n`;
|
|
106
106
|
code += ` ${this.tsName}='${this.tsName}'\n`;
|
|
107
|
-
code += indent(state
|
|
107
|
+
code += indent((state?.tabSize || 0)) + '}\n';
|
|
108
108
|
|
|
109
109
|
return code;
|
|
110
110
|
}
|
|
@@ -117,9 +117,15 @@ export class Role extends BaseNode {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
getNamespace() {
|
|
120
|
-
if (this.parentNode && (this.parentNode as Namespace).getNamespace)
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
121
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
122
|
+
const parentName = this.parentNode.name;
|
|
123
|
+
const arr = [parentNamespace];
|
|
124
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
125
|
+
arr.push(parentName);
|
|
126
|
+
}
|
|
127
|
+
return `${arr.join('.')}.roles`;
|
|
128
|
+
} else
|
|
123
129
|
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
124
130
|
}
|
|
125
131
|
|
|
@@ -42,7 +42,11 @@ export class SqlQueryComponent extends LogicItem {
|
|
|
42
42
|
@property('TypeAnnotation')
|
|
43
43
|
typeAnnotation: TypeAnnotation = undefined;
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* 局部版本
|
|
47
|
+
*/
|
|
48
|
+
@property()
|
|
49
|
+
ideVersion: string = undefined;
|
|
46
50
|
|
|
47
51
|
/**
|
|
48
52
|
* @param source 需要合并的部分参数
|
|
@@ -57,7 +61,6 @@ export class SqlQueryComponent extends LogicItem {
|
|
|
57
61
|
return super.from(source, parentNode, parentKey) as SqlQueryComponent;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
|
|
61
64
|
/**
|
|
62
65
|
* 设置SQL 查询
|
|
63
66
|
*/
|
|
@@ -70,10 +73,6 @@ export class SqlQueryComponent extends LogicItem {
|
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
76
|
/**
|
|
78
77
|
* 删除类型标注
|
|
79
78
|
* @param name 类型标注名称
|
|
@@ -126,22 +125,59 @@ export class SqlQueryComponent extends LogicItem {
|
|
|
126
125
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
127
126
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
128
127
|
//================================================================================
|
|
128
|
+
|
|
129
|
+
@property()
|
|
130
|
+
dataSource: string = undefined;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 设置SQL 查询
|
|
134
|
+
*/
|
|
135
|
+
setDataSource(dataSource: string) {
|
|
136
|
+
const object = {
|
|
137
|
+
dataSource,
|
|
138
|
+
};
|
|
139
|
+
this.update({
|
|
140
|
+
...object,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
129
144
|
@withSourceMap()
|
|
130
145
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
131
|
-
let code
|
|
132
|
-
|
|
146
|
+
let code;
|
|
147
|
+
if (this.ideVersion === '2.11') {
|
|
148
|
+
code = `(function(): `;
|
|
149
|
+
code += `${this.typeAnnotation ? this.typeAnnotation.toEmbeddedTS(shiftState(state, code)) : '__IDENTIFIER__'} {\n`;
|
|
150
|
+
} else {
|
|
151
|
+
code = `(function(): nasl.collection.List<`;
|
|
152
|
+
code += `${this.typeAnnotation ? this.typeAnnotation.toEmbeddedTS(shiftState(state, code)) : '__IDENTIFIER__'}> {\n`;
|
|
153
|
+
}
|
|
154
|
+
// app.dataSources.defaultDS;
|
|
155
|
+
if (this.dataSource) {
|
|
156
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
157
|
+
code += `const dataSource = app.dataSources.${this.dataSource};`;
|
|
158
|
+
}
|
|
133
159
|
code += '\n';
|
|
134
|
-
code += indent(state
|
|
135
|
-
code += indent(state
|
|
160
|
+
code += indent((state?.tabSize || 0) + 1) + 'return;\n';
|
|
161
|
+
code += indent((state?.tabSize || 0)) + '})();\n';
|
|
136
162
|
return code;
|
|
137
163
|
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 获取添加时的默认选项
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
public static getDefaultOptions(): any {
|
|
170
|
+
return {
|
|
171
|
+
dataSource: 'defaultDS',
|
|
172
|
+
};
|
|
173
|
+
}
|
|
138
174
|
//================================================================================
|
|
139
175
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
140
176
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
141
177
|
//================================================================================
|
|
142
178
|
}
|
|
143
179
|
|
|
144
|
-
classMap
|
|
180
|
+
classMap.SqlQueryComponent = SqlQueryComponent;
|
|
145
181
|
export default SqlQueryComponent;
|
|
146
182
|
//================================================================================
|
|
147
183
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|