@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
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
2
|
import Logic from './Logic__';
|
|
3
3
|
import Param from './Param__';
|
|
4
|
+
import View from './View__';
|
|
4
5
|
import { ElementToVueOptions } from './ViewElement__';
|
|
5
6
|
import { getNodeByNodeCallee } from '../automate/engine/utils';
|
|
7
|
+
import { findConceptKeyWordIndexFromNamespace } from '../utils';
|
|
6
8
|
|
|
7
9
|
//================================================================================
|
|
8
10
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -387,6 +389,10 @@ export class CallLogic extends LogicItem {
|
|
|
387
389
|
|
|
388
390
|
// 用于logic回填
|
|
389
391
|
get calleewholeKey(): string {
|
|
392
|
+
if (!this.calleeNamespace && this.calleeName && this.view) {
|
|
393
|
+
// 页面逻辑单独处理
|
|
394
|
+
return `${this.view.getNamespace()}.${this.view.name}.logics.${this.calleeName}`;
|
|
395
|
+
}
|
|
390
396
|
return this.calleeNamespace + '.' + this.calleeName;
|
|
391
397
|
}
|
|
392
398
|
get calleeKey(): string {
|
|
@@ -437,6 +443,9 @@ export class CallLogic extends LogicItem {
|
|
|
437
443
|
|
|
438
444
|
_setCallee(logic: Logic) {
|
|
439
445
|
this.calleeNamespace = logic.getNamespace();
|
|
446
|
+
if (logic.parentNode instanceof View) {
|
|
447
|
+
this.calleeNamespace = '';
|
|
448
|
+
}
|
|
440
449
|
this.calleeName = logic.name;
|
|
441
450
|
this.arguments = [];
|
|
442
451
|
logic.params.forEach((param) => {
|
|
@@ -453,7 +462,10 @@ export class CallLogic extends LogicItem {
|
|
|
453
462
|
}
|
|
454
463
|
|
|
455
464
|
setCallee(logic: Logic) {
|
|
456
|
-
|
|
465
|
+
let calleeNamespace = logic.getNamespace();
|
|
466
|
+
if (logic.parentNode instanceof View) {
|
|
467
|
+
calleeNamespace = '';
|
|
468
|
+
}
|
|
457
469
|
const calleeName = logic.name;
|
|
458
470
|
const params = logic.params.map((param) => {
|
|
459
471
|
const relationOptions = { parentNode: this, parentKey: 'arguments' };
|
|
@@ -482,7 +494,10 @@ export class CallLogic extends LogicItem {
|
|
|
482
494
|
}
|
|
483
495
|
|
|
484
496
|
setCalleeArgName(logic: Logic) {
|
|
485
|
-
|
|
497
|
+
let calleeNamespace = logic.getNamespace();
|
|
498
|
+
if (logic.parentNode instanceof View) {
|
|
499
|
+
calleeNamespace = '';
|
|
500
|
+
}
|
|
486
501
|
const calleeName = logic.name;
|
|
487
502
|
/**
|
|
488
503
|
* a: logic.params b: this.arguments
|
|
@@ -528,7 +543,7 @@ export class CallLogic extends LogicItem {
|
|
|
528
543
|
|
|
529
544
|
toVue(options?: ElementToVueOptions): string {
|
|
530
545
|
let code = '';
|
|
531
|
-
if (this.calleeNamespace === 'nasl.browser' || this.calleeNamespace === 'nasl.auth' || this.calleeNamespace === 'nasl.configuration') {
|
|
546
|
+
if (this.calleeNamespace === 'nasl.browser' || this.calleeNamespace === 'nasl.auth' || this.calleeNamespace === 'nasl.configuration' || this.calleeNamespace === 'nasl.process') {
|
|
532
547
|
code += '$global.';
|
|
533
548
|
}
|
|
534
549
|
code += this.calleeName;
|
|
@@ -563,21 +578,20 @@ export class CallLogic extends LogicItem {
|
|
|
563
578
|
let isComponentLogic = false;
|
|
564
579
|
let componentName = '';
|
|
565
580
|
const calleeNamespace = this.calleeNamespace;
|
|
566
|
-
const
|
|
567
|
-
|
|
581
|
+
const keywordProcessIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'processes');
|
|
582
|
+
const isProcessLogic = keywordProcessIndex !== -1;
|
|
568
583
|
// calleeNamespace不存在,一定是页面逻辑
|
|
569
584
|
if (calleeNamespace) {
|
|
570
585
|
const namespaceArr = calleeNamespace.split('.');
|
|
571
|
-
const start = namespaceArr
|
|
586
|
+
const start = namespaceArr[0];
|
|
572
587
|
if (start === 'app' || start === 'extensions') {
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
if (!keywordViews) {
|
|
588
|
+
const keywordViewsIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'views');
|
|
589
|
+
if (keywordViewsIndex === -1) {
|
|
576
590
|
isViewLogic = false;
|
|
577
591
|
}
|
|
578
|
-
} else if (start === 'elements' && namespaceArr.length ===
|
|
592
|
+
} else if (start === 'elements' && namespaceArr.length === 3 && namespaceArr[2] === 'logics') {
|
|
579
593
|
isComponentLogic = true;
|
|
580
|
-
componentName = namespaceArr[
|
|
594
|
+
componentName = namespaceArr[1];
|
|
581
595
|
}
|
|
582
596
|
}
|
|
583
597
|
// 全局逻辑
|
|
@@ -598,17 +612,7 @@ export class CallLogic extends LogicItem {
|
|
|
598
612
|
};
|
|
599
613
|
});
|
|
600
614
|
const args = logic?.params || [];
|
|
601
|
-
|
|
602
|
-
// 去掉app
|
|
603
|
-
namespaceArr.shift();
|
|
604
|
-
const keywordEntities = namespaceArr
|
|
605
|
-
.map((namespaceItem, index) => ({
|
|
606
|
-
key: namespaceItem,
|
|
607
|
-
index,
|
|
608
|
-
}))
|
|
609
|
-
.filter((namespaceItem, index) => index % 2 === 0)
|
|
610
|
-
.find((namespaceItem) => namespaceItem.key === 'entities');
|
|
611
|
-
const entityName = namespaceArr[keywordEntities?.index + 1];
|
|
615
|
+
const keywordEntitiesIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'entities');
|
|
612
616
|
code += `this.$logics['${this.calleeNamespace ? `${this.calleeNamespace}.${this.calleeName}` : this.calleeName}']`;
|
|
613
617
|
code += `({
|
|
614
618
|
config: {
|
|
@@ -629,7 +633,7 @@ export class CallLogic extends LogicItem {
|
|
|
629
633
|
headers: {},
|
|
630
634
|
`;
|
|
631
635
|
|
|
632
|
-
if (
|
|
636
|
+
if (keywordEntitiesIndex !== -1) {
|
|
633
637
|
let logicArgs = this.arguments;
|
|
634
638
|
switch (this.calleeName) {
|
|
635
639
|
case 'get':
|
|
@@ -688,19 +692,30 @@ export class CallLogic extends LogicItem {
|
|
|
688
692
|
code += `JSON.parse`;
|
|
689
693
|
break;
|
|
690
694
|
}
|
|
691
|
-
} else if (calleeNamespace === 'nasl.browser' || calleeNamespace === 'nasl.auth' || calleeNamespace === 'nasl.configuration') {
|
|
695
|
+
} else if (calleeNamespace === 'nasl.browser' || calleeNamespace === 'nasl.auth' || calleeNamespace === 'nasl.configuration' || calleeNamespace === 'nasl.process') {
|
|
692
696
|
code += `this.$global.${this.calleeName}`;
|
|
693
697
|
} else {
|
|
694
698
|
code += `this.${this.calleeName}`;
|
|
695
699
|
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
.
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
700
|
+
if (calleeNamespace === 'nasl.process') {
|
|
701
|
+
code += '({';
|
|
702
|
+
this.arguments?.filter((arg) => arg?.expression)
|
|
703
|
+
.forEach((arg, index) => {
|
|
704
|
+
code += `${arg.keyword}: ${arg?.toJS(shiftState(state, code))}`;
|
|
705
|
+
if (index !== this.arguments?.length - 1)
|
|
706
|
+
code += ', ';
|
|
707
|
+
});
|
|
708
|
+
code += '})';
|
|
709
|
+
} else {
|
|
710
|
+
code += '(';
|
|
711
|
+
this.arguments?.filter((arg) => arg?.expression)
|
|
712
|
+
.forEach((arg, index) => {
|
|
713
|
+
code += arg?.toJS(shiftState(state, code));
|
|
714
|
+
if (index !== this.arguments?.length - 1)
|
|
715
|
+
code += ', ';
|
|
716
|
+
});
|
|
717
|
+
code += ')';
|
|
718
|
+
}
|
|
704
719
|
}
|
|
705
720
|
return code;
|
|
706
721
|
}
|
|
@@ -751,16 +751,16 @@ export class CallQueryComponent extends LogicItem {
|
|
|
751
751
|
if (list.length === 0)
|
|
752
752
|
return code;
|
|
753
753
|
|
|
754
|
-
code += indent(state
|
|
754
|
+
code += indent((state?.tabSize || 0) + 1) + `.${key}(() => `;
|
|
755
755
|
list.forEach((item, index) => {
|
|
756
756
|
if (index > 0)
|
|
757
|
-
code += `,\n${indent(state
|
|
757
|
+
code += `,\n${indent((state?.tabSize || 0) + 2)}() => `;
|
|
758
758
|
code += item?.toEmbeddedTS?.(shiftState(state, code, { tabSize: 0 }));
|
|
759
759
|
});
|
|
760
760
|
if (list.length > 1) {
|
|
761
761
|
if (multipleErrorType)
|
|
762
|
-
code += `,\n${indent(state
|
|
763
|
-
code += `\n${indent(state
|
|
762
|
+
code += `,\n${indent((state?.tabSize || 0) + 2)}() => ${multipleErrorType}`;
|
|
763
|
+
code += `\n${indent((state?.tabSize || 0) + 1)}`;
|
|
764
764
|
}
|
|
765
765
|
code += ')\n';
|
|
766
766
|
|
|
@@ -819,7 +819,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
819
819
|
}
|
|
820
820
|
// 聚合属性别名
|
|
821
821
|
this.select.selectElements.forEach((item, index, array) => {
|
|
822
|
-
code += indent(state
|
|
822
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
823
823
|
const { asName, aggregateName, aggregateParam } = item;
|
|
824
824
|
if (asName)
|
|
825
825
|
code += `const __${asName} = `;
|
|
@@ -835,9 +835,9 @@ export class CallQueryComponent extends LogicItem {
|
|
|
835
835
|
});
|
|
836
836
|
|
|
837
837
|
if (this.from)
|
|
838
|
-
code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
838
|
+
code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
839
839
|
else
|
|
840
|
-
code += `${indent(state
|
|
840
|
+
code += `${indent((state?.tabSize || 0) + 1)}nasl.langUtil.FROM()\n`;
|
|
841
841
|
|
|
842
842
|
// where 子句
|
|
843
843
|
code = this.toEmbeddedTSOfSubPart('WHERE', this.where ? [this.where] : [], {
|
|
@@ -878,8 +878,8 @@ export class CallQueryComponent extends LogicItem {
|
|
|
878
878
|
});
|
|
879
879
|
|
|
880
880
|
code += '\n';
|
|
881
|
-
code += indent(state
|
|
882
|
-
code += indent(state
|
|
881
|
+
code += indent((state?.tabSize || 0) + 1) + 'return;\n';
|
|
882
|
+
code += indent((state?.tabSize || 0)) + '})();\n';
|
|
883
883
|
return code;
|
|
884
884
|
}
|
|
885
885
|
|
|
@@ -888,6 +888,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
888
888
|
return [];
|
|
889
889
|
|
|
890
890
|
const entityName = node.entityName;
|
|
891
|
+
const entityNamespace = node.entityNamespace;
|
|
891
892
|
entities.push({
|
|
892
893
|
concept: 'StructureProperty',
|
|
893
894
|
name: utils.firstLowerCase(entityName),
|
|
@@ -895,7 +896,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
895
896
|
concept: 'TypeAnnotation',
|
|
896
897
|
typeKind: 'reference',
|
|
897
898
|
typeName: entityName,
|
|
898
|
-
typeNamespace:
|
|
899
|
+
typeNamespace: entityNamespace,
|
|
899
900
|
},
|
|
900
901
|
});
|
|
901
902
|
|
|
@@ -906,7 +907,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
906
907
|
return entities;
|
|
907
908
|
}
|
|
908
909
|
|
|
909
|
-
genPropertyListOfAggregate(node: CallQueryComponent) {
|
|
910
|
+
genPropertyListOfAggregate(node: CallQueryComponent, entities: Entity[]) {
|
|
910
911
|
return node.select.selectElements
|
|
911
912
|
.filter((item) => item.aggregateName && item.asName)
|
|
912
913
|
.map((item) => {
|
|
@@ -917,9 +918,9 @@ export class CallQueryComponent extends LogicItem {
|
|
|
917
918
|
typeName = 'Double';
|
|
918
919
|
} else {
|
|
919
920
|
const { entityAsName, propertyName } = item.aggregateParam;
|
|
920
|
-
const entity =
|
|
921
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
921
922
|
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
922
|
-
typeName = property?.typeAnnotation
|
|
923
|
+
typeName = property?.typeAnnotation?.typeName;
|
|
923
924
|
}
|
|
924
925
|
return {
|
|
925
926
|
concept: 'StructureProperty',
|
|
@@ -934,22 +935,23 @@ export class CallQueryComponent extends LogicItem {
|
|
|
934
935
|
});
|
|
935
936
|
}
|
|
936
937
|
|
|
937
|
-
genPropertyListOfGroupBy(node: CallQueryComponent) {
|
|
938
|
+
genPropertyListOfGroupBy(node: CallQueryComponent, entities: Entity[]) {
|
|
938
939
|
return node.groupBy
|
|
939
940
|
.filter((item) => item.groupElement && (item.groupElement as QueryFieldExpression).propertyName && (item.groupElement as QueryFieldExpression).asName)
|
|
940
941
|
.map((item) => {
|
|
941
942
|
const { entityAsName, propertyName, asName } = item.groupElement as QueryFieldExpression;
|
|
942
|
-
const entity =
|
|
943
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
943
944
|
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
944
|
-
const
|
|
945
|
+
const propertyTypeAnnotation = property.typeAnnotation;
|
|
946
|
+
|
|
945
947
|
return {
|
|
946
948
|
concept: 'StructureProperty',
|
|
947
949
|
name: asName,
|
|
948
950
|
typeAnnotation: {
|
|
949
|
-
concept:
|
|
950
|
-
typeKind:
|
|
951
|
-
typeName,
|
|
952
|
-
typeNamespace:
|
|
951
|
+
concept: propertyTypeAnnotation.concept,
|
|
952
|
+
typeKind: propertyTypeAnnotation.typeKind,
|
|
953
|
+
typeName: propertyTypeAnnotation.typeName,
|
|
954
|
+
typeNamespace: propertyTypeAnnotation.typeNamespace,
|
|
953
955
|
},
|
|
954
956
|
};
|
|
955
957
|
});
|
|
@@ -966,13 +968,14 @@ export class CallQueryComponent extends LogicItem {
|
|
|
966
968
|
|
|
967
969
|
saveStructure() {
|
|
968
970
|
// 没有数据源时不初始化数据结构
|
|
969
|
-
if (!this.
|
|
971
|
+
if (!this.entityInfos.length) {
|
|
970
972
|
return;
|
|
971
973
|
}
|
|
972
|
-
|
|
974
|
+
const entityNamespace = this.from?.entityNamespace;
|
|
975
|
+
const entities = this.app.findNodeByCompleteName(entityNamespace);
|
|
973
976
|
if (!this.isAutoInfer()) {
|
|
974
977
|
// 存量应用走之前的逻辑
|
|
975
|
-
return this.saveStructureNoInfer();
|
|
978
|
+
return this.saveStructureNoInfer(entities);
|
|
976
979
|
}
|
|
977
980
|
|
|
978
981
|
const groupBy = this.groupBy;
|
|
@@ -999,35 +1002,35 @@ export class CallQueryComponent extends LogicItem {
|
|
|
999
1002
|
const groupByLength = groupBy.filter((item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName).length;
|
|
1000
1003
|
const aggregateLength = selectElements.filter((item) => item.aggregateName && item.asName).length;
|
|
1001
1004
|
|
|
1005
|
+
|
|
1006
|
+
|
|
1002
1007
|
// 1. 有分组
|
|
1003
1008
|
if (groupByLength) {
|
|
1004
1009
|
if (!aggregateLength && groupByLength === 1) {
|
|
1005
1010
|
// 1.1 单分组无聚合:`PageOf<列的类型>`
|
|
1006
|
-
const { entityAsName, propertyName } = groupBy[0].groupElement as
|
|
1007
|
-
const entity =
|
|
1008
|
-
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
1009
|
-
const
|
|
1011
|
+
const { entityAsName, propertyName } = groupBy[0].groupElement as QueryFieldExpression;
|
|
1012
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
1013
|
+
const property = entity?.properties.find((item: any) => item.name === propertyName);
|
|
1014
|
+
const propertyTypeAnnotation = property.typeAnnotation;
|
|
1010
1015
|
|
|
1011
1016
|
typeAnnotation = TypeAnnotation.from({
|
|
1012
|
-
text: `PageOf<${typeName}>`,
|
|
1017
|
+
text: `PageOf<${propertyTypeAnnotation.typeName}>`,
|
|
1013
1018
|
concept: 'TypeAnnotation',
|
|
1014
1019
|
typeKind: 'generic',
|
|
1015
1020
|
typeName: 'PageOf',
|
|
1016
1021
|
typeNamespace: `nasl.collection`,
|
|
1017
|
-
typeArguments: [
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
}, this.typeAnnotation, 'typeAnnotation'),
|
|
1024
|
-
],
|
|
1022
|
+
typeArguments: [TypeAnnotation.from({
|
|
1023
|
+
concept: propertyTypeAnnotation.concept,
|
|
1024
|
+
typeKind: propertyTypeAnnotation.typeKind,
|
|
1025
|
+
typeName: propertyTypeAnnotation.typeName,
|
|
1026
|
+
typeNamespace: propertyTypeAnnotation.typeNamespace,
|
|
1027
|
+
}, this.typeAnnotation, 'typeAnnotation')],
|
|
1025
1028
|
}, this, 'typeAnnotation');
|
|
1026
1029
|
} else {
|
|
1027
1030
|
// 1.2 多分组:`PageOf<Structure>`
|
|
1028
1031
|
const structure = this.genStructure(structureName, [
|
|
1029
|
-
...this.genPropertyListOfGroupBy(this),
|
|
1030
|
-
...this.genPropertyListOfAggregate(this),
|
|
1032
|
+
...this.genPropertyListOfGroupBy(this, entities),
|
|
1033
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1031
1034
|
]);
|
|
1032
1035
|
this.app.addStructure(structure);
|
|
1033
1036
|
|
|
@@ -1061,9 +1064,9 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1061
1064
|
} else {
|
|
1062
1065
|
// 2.1.3. 其他返回列类型,包含:`Integer`、`Long`、`Double`
|
|
1063
1066
|
const { entityAsName, propertyName } = selectElements[0].aggregateParam;
|
|
1064
|
-
const entity =
|
|
1065
|
-
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
1066
|
-
typeName = property?.typeAnnotation
|
|
1067
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
1068
|
+
const property = entity?.properties.find((item: any) => item.name === propertyName);
|
|
1069
|
+
typeName = property?.typeAnnotation?.typeName;
|
|
1067
1070
|
}
|
|
1068
1071
|
typeAnnotation = TypeAnnotation.from({
|
|
1069
1072
|
concept: 'TypeAnnotation',
|
|
@@ -1074,7 +1077,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1074
1077
|
} else {
|
|
1075
1078
|
// 2.2. 多聚合:`Structure`(自动创建 `Structure`)
|
|
1076
1079
|
const structure = this.genStructure(structureName, [
|
|
1077
|
-
...this.genPropertyListOfAggregate(this),
|
|
1080
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1078
1081
|
]);
|
|
1079
1082
|
this.app.addStructure(structure);
|
|
1080
1083
|
|
|
@@ -1089,7 +1092,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1089
1092
|
// 2.3. 无聚合(默认情况):`PageOf<Structure>`(自动创建 `Structure`)
|
|
1090
1093
|
const structure = this.genStructure(structureName, [
|
|
1091
1094
|
...this.genPropertyListOfFrom(this.from),
|
|
1092
|
-
...this.genPropertyListOfAggregate(this),
|
|
1095
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1093
1096
|
]);
|
|
1094
1097
|
this.app.addStructure(structure);
|
|
1095
1098
|
|
|
@@ -1114,10 +1117,10 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1114
1117
|
this.update({ typeAnnotation });
|
|
1115
1118
|
}
|
|
1116
1119
|
|
|
1117
|
-
saveStructureNoInfer() {
|
|
1120
|
+
saveStructureNoInfer(entities: any[] = []) {
|
|
1118
1121
|
const source = this.genStructure(null, [
|
|
1119
1122
|
...this.genPropertyListOfFrom(this.from),
|
|
1120
|
-
...this.genPropertyListOfAggregate(this),
|
|
1123
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1121
1124
|
]);
|
|
1122
1125
|
if (this.typeAnnotation) {
|
|
1123
1126
|
const structure = this.app.structures.find((item) => item.name === this.typeAnnotation.typeName);
|
|
@@ -1162,53 +1165,61 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1162
1165
|
} catch {}
|
|
1163
1166
|
}
|
|
1164
1167
|
|
|
1165
|
-
|
|
1168
|
+
getEntityInfos(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
|
|
1166
1169
|
if (node?.entityName)
|
|
1167
|
-
set.add(
|
|
1170
|
+
set.add({
|
|
1171
|
+
namespace: node.entityNamespace,
|
|
1172
|
+
name: node.entityName,
|
|
1173
|
+
});
|
|
1168
1174
|
|
|
1169
1175
|
node?.joinParts?.forEach((child) => {
|
|
1170
|
-
this.
|
|
1176
|
+
this.getEntityInfos(child, set);
|
|
1171
1177
|
});
|
|
1172
1178
|
return Array.from(set);
|
|
1173
1179
|
}
|
|
1174
1180
|
|
|
1175
|
-
get
|
|
1176
|
-
return this.
|
|
1181
|
+
get entityInfos() {
|
|
1182
|
+
return this.getEntityInfos(this.from);
|
|
1177
1183
|
}
|
|
1178
1184
|
|
|
1179
1185
|
getCompletionPropertyOfEntities() {
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
.
|
|
1184
|
-
.
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
concept: '
|
|
1190
|
-
name:
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1186
|
+
const firstEntityInfo: any = this.entityInfos[0];
|
|
1187
|
+
if (firstEntityInfo) {
|
|
1188
|
+
const namespace = firstEntityInfo.namespace;
|
|
1189
|
+
const entities: Entity[] = this.app.findNodeByCompleteName(namespace);
|
|
1190
|
+
if (Array.isArray(entities)) {
|
|
1191
|
+
const children = this.entityInfos
|
|
1192
|
+
.map(({ name }) => entities.find((item) => item.name === name))
|
|
1193
|
+
.filter((item) => item)
|
|
1194
|
+
.map((entity) => ({
|
|
1195
|
+
concept: 'Entity',
|
|
1196
|
+
name: entity.name,
|
|
1197
|
+
children: entity.properties.map((property) => {
|
|
1198
|
+
const completionProperty = new CompletionProperty({
|
|
1199
|
+
concept: 'CompletionProperty',
|
|
1200
|
+
name: property.name,
|
|
1201
|
+
value: `${entity.name}.${property.name}`,
|
|
1202
|
+
expression: LogicItem.from({
|
|
1203
|
+
concept: 'QueryFieldExpression',
|
|
1204
|
+
name: property.name,
|
|
1205
|
+
value: `${entity.name}.${property.name}`,
|
|
1206
|
+
entityAsName: entity.name,
|
|
1207
|
+
propertyName: property.name,
|
|
1208
|
+
}),
|
|
1209
|
+
});
|
|
1210
|
+
completionProperty.icon = 'property';
|
|
1211
|
+
return completionProperty;
|
|
1198
1212
|
}),
|
|
1199
|
-
});
|
|
1200
|
-
|
|
1201
|
-
return
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
icon: 'category',
|
|
1210
|
-
children,
|
|
1211
|
-
};
|
|
1213
|
+
}));
|
|
1214
|
+
if (children.length) {
|
|
1215
|
+
return {
|
|
1216
|
+
name: '实体',
|
|
1217
|
+
icon: 'category',
|
|
1218
|
+
children,
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1212
1223
|
}
|
|
1213
1224
|
|
|
1214
1225
|
getCompletionPropertyOfAggregateAsNames() {
|
|
@@ -275,7 +275,9 @@ export class ConfigGroup extends BaseNode {
|
|
|
275
275
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
276
276
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
277
277
|
//================================================================================
|
|
278
|
-
|
|
278
|
+
getProperty(name = '') {
|
|
279
|
+
return this.properties.find((item) => item.name === name);
|
|
280
|
+
}
|
|
279
281
|
//================================================================================
|
|
280
282
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
281
283
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -292,6 +292,10 @@ export class ConfigProperty extends BaseNode {
|
|
|
292
292
|
...object,
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
|
+
|
|
296
|
+
getPropertyEnv(env = '') {
|
|
297
|
+
return this.values.find((item) => item.env === env);
|
|
298
|
+
}
|
|
295
299
|
//================================================================================
|
|
296
300
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
297
301
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -271,6 +271,9 @@ export class Configuration extends BaseNode {
|
|
|
271
271
|
],
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
|
+
getGroup(name = '') {
|
|
275
|
+
return this.groups.find((item) => item.name === name);
|
|
276
|
+
}
|
|
274
277
|
|
|
275
278
|
//================================================================================
|
|
276
279
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|