@lcap/nasl 2.14.0 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/automate/engine/index.js +2 -2
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/viewCache.js +5 -5
- package/out/automate/engine/viewCache.js.map +1 -1
- package/out/common/BaseNode.js +3 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +170 -0
- package/out/concepts/AnonymousFunction__.js +439 -0
- package/out/concepts/AnonymousFunction__.js.map +1 -0
- package/out/concepts/App__.js +7 -1
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.d.ts +40 -0
- package/out/concepts/AssignmentLine__.js +109 -0
- package/out/concepts/AssignmentLine__.js.map +1 -0
- package/out/concepts/BatchAssignment__.d.ts +248 -0
- package/out/concepts/BatchAssignment__.js +742 -0
- package/out/concepts/BatchAssignment__.js.map +1 -0
- package/out/concepts/BindAttribute__.js +2 -0
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.js +9 -4
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +126 -0
- package/out/concepts/BindStyle__.js +233 -0
- package/out/concepts/BindStyle__.js.map +1 -0
- package/out/concepts/CallLogic__.js +3 -4
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +1 -1
- package/out/concepts/ConstructArgument__.d.ts +40 -0
- package/out/concepts/ConstructArgument__.js +108 -0
- package/out/concepts/ConstructArgument__.js.map +1 -0
- package/out/concepts/Construct__.d.ts +189 -0
- package/out/concepts/Construct__.js +340 -0
- package/out/concepts/Construct__.js.map +1 -0
- package/out/concepts/EnumItem__.js +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +1 -0
- package/out/concepts/Interface__.js +58 -0
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.js +3 -3
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +256 -0
- package/out/concepts/MatchCase__.js +584 -0
- package/out/concepts/MatchCase__.js.map +1 -0
- package/out/concepts/Match__.d.ts +117 -0
- package/out/concepts/Match__.js +434 -0
- package/out/concepts/Match__.js.map +1 -0
- package/out/concepts/OqlQueryComponent__.d.ts +73 -0
- package/out/concepts/OqlQueryComponent__.js +395 -0
- package/out/concepts/OqlQueryComponent__.js.map +1 -0
- package/out/concepts/ProcessElement__.d.ts +2 -2
- package/out/concepts/ProcessElement__.js +30 -21
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +81 -0
- package/out/concepts/Process__.js +98 -2
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +141 -0
- package/out/concepts/SelectMembers__.js +290 -0
- package/out/concepts/SelectMembers__.js.map +1 -0
- package/out/concepts/SqlQueryComponent__.d.ts +4 -0
- package/out/concepts/SqlQueryComponent__.js +144 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Variable__.js +0 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +10 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +4 -1
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +26 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.process.js +98 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +54 -0
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +2 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.js +4 -0
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
- package/out/enums/KEYWORDS.js +1 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +2 -0
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/server/extendBaseNode.js +32 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +42 -14
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getProcesses.d.ts +2 -2
- package/out/server/getProcesses.js +47 -21
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +46 -19
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +1 -0
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/process2LogicNamespace.js +25 -21
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +35 -8
- package/out/server/translator.js.map +1 -1
- package/out/service/logic/api.d.ts +9 -0
- package/out/service/logic/api.js +11 -0
- package/out/service/logic/api.js.map +1 -0
- package/out/service/logic/index.d.ts +2 -0
- package/out/service/logic/index.js +10 -0
- package/out/service/logic/index.js.map +1 -0
- package/out/service/storage/init.js +18 -6
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +1 -1
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +4 -5
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +5 -3
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +3 -2
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +4 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +1 -1
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/sql-parser/index.d.ts +1 -0
- package/out/templator/sql-parser/index.js +228 -0
- package/out/templator/sql-parser/index.js.map +1 -0
- package/out/templator/sql-parser/parser.js +26664 -0
- package/out/templator/sql-parser/parser.js.map +1 -0
- package/package.json +1 -1
- package/src/automate/engine/index.js +1 -1
- package/src/automate/engine/viewCache.js +23 -23
- package/src/automate/template/myProcess.js +12295 -0
- package/src/common/BaseNode.ts +5 -1
- package/src/concepts/App__.ts +8 -1
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/BindAttribute__.ts +3 -1
- package/src/concepts/BindEvent__.ts +8 -4
- package/src/concepts/CallLogic__.ts +3 -4
- package/src/concepts/EnumItem__.ts +1 -1
- package/src/concepts/Interface__.ts +66 -7
- package/src/concepts/Logic__.ts +3 -3
- package/src/concepts/ProcessElement__.ts +34 -24
- package/src/concepts/Process__.ts +98 -2
- package/src/concepts/SqlQueryComponent__.ts +143 -2
- package/src/concepts/Variable__.ts +0 -1
- package/src/concepts/ViewElement__.ts +12 -20
- package/src/concepts/View__.ts +4 -1
- package/src/concepts/basics/stdlib/index.ts +2 -1
- package/src/concepts/basics/stdlib/nasl.auth.ts +25 -0
- package/src/concepts/basics/stdlib/nasl.io.ts +48 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +98 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +54 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +2 -2
- package/src/concepts/basics/stdlib/nasl.validation.ts +4 -0
- package/src/enums/KEYWORDS.ts +1 -0
- package/src/generator/genBundleFiles.ts +3 -0
- package/src/server/extendBaseNode.ts +31 -4
- package/src/server/getLogics.ts +43 -14
- package/src/server/getProcesses.ts +47 -21
- package/src/server/naslServer.ts +44 -21
- package/src/server/naslStdlibMap.ts +1 -0
- package/src/server/process2LogicNamespace.ts +27 -21
- package/src/server/translator.ts +35 -8
- package/src/service/storage/init.ts +18 -6
- package/src/templator/genCreateBlock.ts +1 -1
- package/src/templator/genCurdEditMultipleKeyBlock.ts +4 -7
- package/src/templator/genCurdMultipleKeyBlock.ts +4 -4
- package/src/templator/genEditTableBlock.ts +5 -3
- package/src/templator/genGetBlock.ts +3 -2
- package/src/templator/genTableBlock.ts +4 -2
- package/src/templator/genUpdateBlock.ts +1 -1
- package/src/automate/template/process.js +0 -11810
package/src/common/BaseNode.ts
CHANGED
|
@@ -804,6 +804,10 @@ export class BaseNode extends EventEmitter {
|
|
|
804
804
|
parentNode,
|
|
805
805
|
parentKey,
|
|
806
806
|
});
|
|
807
|
+
|
|
808
|
+
if(this.concept === 'ViewElement')
|
|
809
|
+
this.name = (this as unknown as ViewElement).getViewElementUniqueName(this.name);
|
|
810
|
+
|
|
807
811
|
list.splice(index, 0, this);
|
|
808
812
|
this.create({
|
|
809
813
|
index,
|
|
@@ -827,7 +831,7 @@ export class BaseNode extends EventEmitter {
|
|
|
827
831
|
function traverse(node: BaseNode) {
|
|
828
832
|
cb(node);
|
|
829
833
|
|
|
830
|
-
const propertyMap = getConceptPropertyMap(node
|
|
834
|
+
const propertyMap = getConceptPropertyMap(node?.concept);
|
|
831
835
|
if (!propertyMap)
|
|
832
836
|
return;
|
|
833
837
|
|
package/src/concepts/App__.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface AssetsInfo {
|
|
|
3
3
|
css: Array<string>;
|
|
4
4
|
names?: Array<string>;
|
|
5
5
|
}
|
|
6
|
+
import { getNaslNodeByNodeCallee } from '../automate/engine/utils';
|
|
7
|
+
|
|
6
8
|
//================================================================================
|
|
7
9
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
8
10
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -2664,8 +2666,13 @@ export class App extends BaseNode {
|
|
|
2664
2666
|
|
|
2665
2667
|
findNodeByCompleteName(completeName: string) {
|
|
2666
2668
|
const nameArr = completeName?.split('.') || [];
|
|
2667
|
-
const start = nameArr.shift();
|
|
2668
2669
|
let node: any = this;
|
|
2670
|
+
// 先处理平台的
|
|
2671
|
+
if (completeName.startsWith('nasl')) {
|
|
2672
|
+
node = getNaslNodeByNodeCallee(nameArr.splice(0, nameArr.length - 1).join('.'), nameArr[nameArr.length - 1]);
|
|
2673
|
+
return node;
|
|
2674
|
+
}
|
|
2675
|
+
const start = nameArr.shift();
|
|
2669
2676
|
const mod = 0;
|
|
2670
2677
|
const modulesMap: any = {
|
|
2671
2678
|
extensions: node.dependencies,
|
|
@@ -657,7 +657,7 @@ export class Assignee extends LogicItem {
|
|
|
657
657
|
// let code = `const plainuser = [];\n`
|
|
658
658
|
// code += `const dynamicuser = [];\n`
|
|
659
659
|
let code = prevCode;
|
|
660
|
-
if (!this.users.length && !this.dynamicUsers.length && !this.logicUsers.length)
|
|
660
|
+
if (!this.users.length && !this.dynamicUsers.length && !this.logicUsers.length && !this.roles.length)
|
|
661
661
|
code += tab + '__UsersEmpty__;\n';
|
|
662
662
|
if (Array.isArray(this.logicUsers)) {
|
|
663
663
|
this.logicUsers.forEach((logic) => {
|
|
@@ -677,7 +677,9 @@ export class BindAttribute extends BaseNode {
|
|
|
677
677
|
} else {
|
|
678
678
|
str += `:${name}${this.sync ? '.sync' : ''}="${value}"`;
|
|
679
679
|
}
|
|
680
|
-
}
|
|
680
|
+
} else if(this.type === 'string' && this.value === '')
|
|
681
|
+
str = `${name}="${this.value}"`;
|
|
682
|
+
|
|
681
683
|
return str;
|
|
682
684
|
}
|
|
683
685
|
}
|
|
@@ -579,10 +579,14 @@ export class BindEvent extends BaseNode {
|
|
|
579
579
|
const logicName = logic.name;
|
|
580
580
|
logic.name = '__' + logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
|
|
581
581
|
logic.name = logic.name.replace(/-/g, '');
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
582
|
+
try {
|
|
583
|
+
code += logic.toEmbeddedTS(shiftState(state, code, {
|
|
584
|
+
tabSize: (state?.tabSize || 0) + 2,
|
|
585
|
+
}), 'noExport');
|
|
586
|
+
} finally {
|
|
587
|
+
// 翻译logic可能出错
|
|
588
|
+
logic.name = logicName;
|
|
589
|
+
}
|
|
586
590
|
} else {
|
|
587
591
|
code += logic.toEmbeddedTS(shiftState(state, code, {
|
|
588
592
|
tabSize: (state?.tabSize || 0) + 2,
|
|
@@ -779,12 +779,12 @@ var __parseType = (root, prop) => {
|
|
|
779
779
|
code += `JSON.parse`;
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
782
|
-
} else if (calleeNamespace === 'nasl.browser' || calleeNamespace === 'nasl.auth' || calleeNamespace === 'nasl.configuration' || calleeNamespace === 'nasl.process') {
|
|
782
|
+
} else if (calleeNamespace === 'nasl.browser' || calleeNamespace === 'nasl.auth' || calleeNamespace === 'nasl.configuration' || calleeNamespace === 'nasl.process' || calleeNamespace === 'nasl.io') {
|
|
783
783
|
code += `this.$global.${this.calleeName}`;
|
|
784
784
|
} else {
|
|
785
785
|
code += `this.${this.calleeName}`;
|
|
786
786
|
}
|
|
787
|
-
if (calleeNamespace === 'nasl.process') {
|
|
787
|
+
if (calleeNamespace === 'nasl.process' || calleeNamespace === 'nasl.auth') {
|
|
788
788
|
code += '({';
|
|
789
789
|
this.arguments
|
|
790
790
|
?.filter((arg) => arg?.expression)
|
|
@@ -797,9 +797,8 @@ var __parseType = (root, prop) => {
|
|
|
797
797
|
} else {
|
|
798
798
|
code += '(';
|
|
799
799
|
this.arguments
|
|
800
|
-
?.filter((arg) => arg?.expression)
|
|
801
800
|
.forEach((arg, index) => {
|
|
802
|
-
code += arg?.toJS(shiftState(state, code));
|
|
801
|
+
code += arg?.toJS(shiftState(state, code)) || 'undefined';
|
|
803
802
|
if (index !== this.arguments?.length - 1)
|
|
804
803
|
code += ', ';
|
|
805
804
|
});
|
|
@@ -120,7 +120,7 @@ export class EnumItem extends BaseNode {
|
|
|
120
120
|
|
|
121
121
|
@withSourceMap()
|
|
122
122
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
123
|
-
return `static ${this.value}: ${this.enumeration.name}`;
|
|
123
|
+
return `static '${this.value}': ${this.enumeration.name}`;
|
|
124
124
|
}
|
|
125
125
|
setName(value: string) {
|
|
126
126
|
this.setValue(value);
|
|
@@ -15,6 +15,8 @@ import InterfaceParam from './InterfaceParam__';
|
|
|
15
15
|
import Return from './Return__';
|
|
16
16
|
import Module from './Module__';
|
|
17
17
|
import App from './App__';
|
|
18
|
+
import TypeAnnotation from './TypeAnnotation__';
|
|
19
|
+
import Structure from './Structure__';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* 接口
|
|
@@ -131,7 +133,7 @@ export class Interface extends BaseNode {
|
|
|
131
133
|
});
|
|
132
134
|
}
|
|
133
135
|
|
|
134
|
-
|
|
136
|
+
getInterfaceParamUniqueName(name = 'interfaceParam1') {
|
|
135
137
|
return utils.unique(name, this.getVarExistingNames(), undefined, false);
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -268,7 +270,6 @@ export class Interface extends BaseNode {
|
|
|
268
270
|
return node;
|
|
269
271
|
}
|
|
270
272
|
|
|
271
|
-
|
|
272
273
|
getReturnUniqueName(name = 'result') {
|
|
273
274
|
return utils.unique(name, this.getVarExistingNames(), undefined, false);
|
|
274
275
|
}
|
|
@@ -406,9 +407,6 @@ export class Interface extends BaseNode {
|
|
|
406
407
|
return node;
|
|
407
408
|
}
|
|
408
409
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
410
|
/**
|
|
413
411
|
* 删除接口参数
|
|
414
412
|
* @param name 接口参数名称
|
|
@@ -457,8 +455,6 @@ export class Interface extends BaseNode {
|
|
|
457
455
|
return params;
|
|
458
456
|
}
|
|
459
457
|
|
|
460
|
-
|
|
461
|
-
|
|
462
458
|
/**
|
|
463
459
|
* 删除输出参数
|
|
464
460
|
* @param name 输出参数名称
|
|
@@ -545,10 +541,73 @@ export class Interface extends BaseNode {
|
|
|
545
541
|
|
|
546
542
|
/* 删除空数据模块 */
|
|
547
543
|
deleteLogincAndModule() {
|
|
544
|
+
this.rootNode.emit('collect:start', {
|
|
545
|
+
actionMsg: `删除接口“${this.name}”`,
|
|
546
|
+
});
|
|
547
|
+
|
|
548
548
|
this.delete();
|
|
549
|
+
this.deleteStructures();
|
|
550
|
+
|
|
549
551
|
if (this.module && this.module.interfaces.length === 0 && this.module.structures.length === 0) {
|
|
550
552
|
this.app.removeModuleInInterfaceDependencies(this.module);
|
|
551
553
|
}
|
|
554
|
+
|
|
555
|
+
// 结束修改 ,批量操作
|
|
556
|
+
this.rootNode.emit('collect:end');
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/* 删除接口引用的数据结构 */
|
|
560
|
+
deleteStructures() {
|
|
561
|
+
// 需要过滤被其他接口同时引用的数据结构
|
|
562
|
+
|
|
563
|
+
const structures = (this.parentNode as Module).structures;
|
|
564
|
+
// 递归找出 response/request 的 Body/Returns 引用的数据结构
|
|
565
|
+
const getStructures = (typeAnnotation: TypeAnnotation, result: Array<Structure> = []) => {
|
|
566
|
+
if (!typeAnnotation)
|
|
567
|
+
return;
|
|
568
|
+
if (typeAnnotation.typeKind === 'reference') {
|
|
569
|
+
const targetStructure = structures.find((s) => s.name === typeAnnotation.typeName);
|
|
570
|
+
if (targetStructure) {
|
|
571
|
+
result.push(targetStructure);
|
|
572
|
+
targetStructure?.properties.forEach((prop) => {
|
|
573
|
+
getStructures(prop.typeAnnotation, result);
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
} else if (typeAnnotation.typeKind === 'generic') {
|
|
577
|
+
typeAnnotation.typeArguments.forEach((arg) => {
|
|
578
|
+
getStructures(arg, result);
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
return result;
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
const otherStructureMap: Record<string, number> = {};
|
|
585
|
+
// 找出其他接口引用的数据结构
|
|
586
|
+
(this.parentNode as Module).interfaces
|
|
587
|
+
.filter((itf) => itf !== this)
|
|
588
|
+
.forEach((itf) => {
|
|
589
|
+
const params = itf.params || [];
|
|
590
|
+
const returns = itf.returns || [];
|
|
591
|
+
[...params, ...returns].forEach((p) => {
|
|
592
|
+
const strus = getStructures(p.typeAnnotation);
|
|
593
|
+
strus.forEach((s) => {
|
|
594
|
+
if (!(s.name in otherStructureMap)) {
|
|
595
|
+
otherStructureMap[s.name] = 0;
|
|
596
|
+
}
|
|
597
|
+
otherStructureMap[s.name]++;
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
const params = this.params || [];
|
|
602
|
+
const returns = this.returns || [];
|
|
603
|
+
[...params, ...returns].forEach((p) => {
|
|
604
|
+
const strus = getStructures(p.typeAnnotation);
|
|
605
|
+
strus.forEach((s) => {
|
|
606
|
+
if (!(s.name in otherStructureMap)) {
|
|
607
|
+
(this.parentNode as Module).removeStructure(s);
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
});
|
|
552
611
|
}
|
|
553
612
|
/**
|
|
554
613
|
* 设置逻辑名称
|
package/src/concepts/Logic__.ts
CHANGED
|
@@ -1629,7 +1629,7 @@ export class Logic extends BaseNode {
|
|
|
1629
1629
|
this.virtualParams && Array.isArray(this.virtualParams) && this.virtualParams.forEach((param) => {
|
|
1630
1630
|
code += indent((state?.tabSize || 0) + 1);
|
|
1631
1631
|
code += param.toEmbeddedNameTS(shiftState(state, code, { inline: true }));
|
|
1632
|
-
code += '
|
|
1632
|
+
code += '\n';
|
|
1633
1633
|
});
|
|
1634
1634
|
this.variables.forEach((variable) => {
|
|
1635
1635
|
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
@@ -1680,7 +1680,7 @@ export class Logic extends BaseNode {
|
|
|
1680
1680
|
arr.push(parentName);
|
|
1681
1681
|
}
|
|
1682
1682
|
let namespace = arr.join('.');
|
|
1683
|
-
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging'].includes(namespace) && !namespace.includes('.logics')) {
|
|
1683
|
+
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace) && !namespace.includes('.logics')) {
|
|
1684
1684
|
namespace = `${namespace}.logics`;
|
|
1685
1685
|
}
|
|
1686
1686
|
return namespace;
|
|
@@ -1697,7 +1697,7 @@ export class Logic extends BaseNode {
|
|
|
1697
1697
|
arr.push(parentName);
|
|
1698
1698
|
}
|
|
1699
1699
|
let namespace = arr.join('.');
|
|
1700
|
-
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process'].includes(namespace) && !namespace.includes('.logics')) {
|
|
1700
|
+
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace) && !namespace.includes('.logics')) {
|
|
1701
1701
|
namespace = `${namespace}.logics`;
|
|
1702
1702
|
}
|
|
1703
1703
|
return namespace;
|
|
@@ -257,7 +257,7 @@ export class ProcessElement extends BaseNode {
|
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
|
|
261
261
|
const excludedSet = new Set(excludedList);
|
|
262
262
|
return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
263
263
|
}
|
|
@@ -1109,7 +1109,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1109
1109
|
}
|
|
1110
1110
|
|
|
1111
1111
|
|
|
1112
|
-
|
|
1112
|
+
|
|
1113
1113
|
|
|
1114
1114
|
/**
|
|
1115
1115
|
* 删除元素绑定事件
|
|
@@ -1518,8 +1518,12 @@ export class ProcessElement extends BaseNode {
|
|
|
1518
1518
|
return [...this.variables, ...this.returns, ...this.constants].filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
1519
1519
|
}
|
|
1520
1520
|
|
|
1521
|
+
get isUserTask() {
|
|
1522
|
+
return this.type === 'UserTask' || this.type === 'ApprovalTask' || this.type === 'InitiateTask';
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1521
1525
|
get logics() {
|
|
1522
|
-
return [genUserTaskLogic(this)];
|
|
1526
|
+
return [...genUserTaskLogic(this)];
|
|
1523
1527
|
// const ns = entity2LogicNamespace(this);
|
|
1524
1528
|
// ns.path = this.getNamespace() + '.' + ns.name;
|
|
1525
1529
|
// return ns;
|
|
@@ -1547,20 +1551,23 @@ export class ProcessElement extends BaseNode {
|
|
|
1547
1551
|
} else
|
|
1548
1552
|
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
1549
1553
|
}
|
|
1550
|
-
cancelBindDelete() {
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1554
|
+
async cancelBindDelete(processDelete: boolean) {
|
|
1555
|
+
if (!processDelete)
|
|
1556
|
+
this.delete();
|
|
1557
|
+
await Promise.all(this.bindAttrs.map(async ({ destination }) => {
|
|
1558
|
+
if (destination && destination.viewNode) {
|
|
1559
|
+
const view = destination.viewNode;
|
|
1560
|
+
const name = this.uniqueTaskId(view);
|
|
1561
|
+
const node = view.params.find((param: any) => param.name === name);
|
|
1562
|
+
if (!node)
|
|
1563
|
+
return;
|
|
1564
|
+
const UsageMap = await node.findUsage();
|
|
1565
|
+
const usageNodes = UsageMap.get(this.process);
|
|
1566
|
+
// console.log(UsageMap, usageNodes)
|
|
1567
|
+
if (!UsageMap.size || (UsageMap.size === 1 && usageNodes && (!usageNodes.children || usageNodes.children.length === 1)))
|
|
1568
|
+
view.removeParam(name);
|
|
1569
|
+
}
|
|
1570
|
+
}));
|
|
1564
1571
|
}
|
|
1565
1572
|
//获取当前页面类型为String的taskId参数
|
|
1566
1573
|
uniqueTaskId(view: View) {
|
|
@@ -1604,7 +1611,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1604
1611
|
});
|
|
1605
1612
|
const afterLinks = getFlowAfterElements(this);
|
|
1606
1613
|
const beforeLinks = getFlowBeforeElements(this);
|
|
1607
|
-
if (this.
|
|
1614
|
+
if (this.isUserTask
|
|
1608
1615
|
|| this.type === 'ExclusiveGateway'
|
|
1609
1616
|
|| this.type === 'AutoTask') {
|
|
1610
1617
|
const prevTasks = getPreviousTask(this);
|
|
@@ -1624,7 +1631,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1624
1631
|
|
|
1625
1632
|
// prevCode += `${tab4}}\n`
|
|
1626
1633
|
|
|
1627
|
-
if (this.
|
|
1634
|
+
if (this.isUserTask) {
|
|
1628
1635
|
//任务完成时可以拿到输出参数,prevCodeClose包含输出参数
|
|
1629
1636
|
let prevCodeClose = prevCode + `\n${tab5}${this.name}: { \n${this.constants.map((c) => `${tab6}${c.toEmbeddedTSInProcess(shiftState(state, code, { inline: true }))},`).join('\n')}`;
|
|
1630
1637
|
prevCodeClose += ` \n${this.returns.map((c) => `${tab6}${c.toEmbeddedTSInProcess(shiftState(state, code, { inline: true }))},`).join('\n')} \n${tab5}}\n`;
|
|
@@ -1653,12 +1660,15 @@ export class ProcessElement extends BaseNode {
|
|
|
1653
1660
|
code += `${tab3}},\n`;
|
|
1654
1661
|
}
|
|
1655
1662
|
});
|
|
1656
|
-
const
|
|
1663
|
+
const logics = genUserTaskLogic(this);
|
|
1657
1664
|
// sourceMap 映射
|
|
1658
|
-
logic.parentNode = this.process;
|
|
1659
1665
|
|
|
1660
|
-
|
|
1661
|
-
|
|
1666
|
+
logics.forEach((logic) => {
|
|
1667
|
+
logic.parentNode = this.process;
|
|
1668
|
+
|
|
1669
|
+
code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }));
|
|
1670
|
+
code += ',\n';
|
|
1671
|
+
});
|
|
1662
1672
|
code += `${tab1}},\n`;
|
|
1663
1673
|
}
|
|
1664
1674
|
|
|
@@ -1669,7 +1679,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1669
1679
|
code += `${this.logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode, true)},\n`;
|
|
1670
1680
|
}
|
|
1671
1681
|
}
|
|
1672
|
-
if (this.
|
|
1682
|
+
if (this.isUserTask || this.type === 'AutoTask' || this.type === 'StartNoneEvent') {
|
|
1673
1683
|
code += '_constraints: function() {\n';
|
|
1674
1684
|
code += `${tab1}nasl.process.oneOutcomeFlow(${afterLinks.map((l) => `'${l.name}'`).join(',')})\n`;
|
|
1675
1685
|
code += '},\n';
|
|
@@ -1212,7 +1212,7 @@ export class Process extends BaseNode {
|
|
|
1212
1212
|
});
|
|
1213
1213
|
});
|
|
1214
1214
|
this.elements.forEach((item) => {
|
|
1215
|
-
if (item.concept === 'ProcessElement' && item.
|
|
1215
|
+
if (item.concept === 'ProcessElement' && item.isUserTask) {
|
|
1216
1216
|
utils.traverse((current) => {
|
|
1217
1217
|
current.node.bindEvents.forEach((bindEvent) => {
|
|
1218
1218
|
bindEvent.logics.forEach((logic) => {
|
|
@@ -1308,6 +1308,36 @@ export class Process extends BaseNode {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
|
|
1310
1310
|
public static getDefaultOptions() {
|
|
1311
|
+
const userTaskAttr = {
|
|
1312
|
+
bindAttrs: [
|
|
1313
|
+
{
|
|
1314
|
+
concept: 'BindAttribute',
|
|
1315
|
+
name: 'assignee',
|
|
1316
|
+
assignee: {
|
|
1317
|
+
concept: 'Assignee',
|
|
1318
|
+
},
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
concept: 'BindAttribute',
|
|
1322
|
+
name: 'destination',
|
|
1323
|
+
destination: {
|
|
1324
|
+
concept: 'Destination',
|
|
1325
|
+
},
|
|
1326
|
+
},
|
|
1327
|
+
],
|
|
1328
|
+
constants: [
|
|
1329
|
+
{
|
|
1330
|
+
concept: 'Constant',
|
|
1331
|
+
name: 'taskId',
|
|
1332
|
+
typeAnnotation: {
|
|
1333
|
+
concept: 'TypeAnnotation',
|
|
1334
|
+
typeKind: 'primitive',
|
|
1335
|
+
typeNamespace: 'nasl.core',
|
|
1336
|
+
typeName: 'String',
|
|
1337
|
+
},
|
|
1338
|
+
},
|
|
1339
|
+
],
|
|
1340
|
+
};
|
|
1311
1341
|
return {
|
|
1312
1342
|
constants: [
|
|
1313
1343
|
{
|
|
@@ -1320,6 +1350,16 @@ export class Process extends BaseNode {
|
|
|
1320
1350
|
typeName: 'String',
|
|
1321
1351
|
},
|
|
1322
1352
|
},
|
|
1353
|
+
{
|
|
1354
|
+
concept: 'Constant',
|
|
1355
|
+
name: 'startBy',
|
|
1356
|
+
typeAnnotation: {
|
|
1357
|
+
concept: 'TypeAnnotation',
|
|
1358
|
+
typeKind: 'primitive',
|
|
1359
|
+
typeNamespace: 'nasl.core',
|
|
1360
|
+
typeName: 'String',
|
|
1361
|
+
},
|
|
1362
|
+
},
|
|
1323
1363
|
],
|
|
1324
1364
|
elements: [
|
|
1325
1365
|
{
|
|
@@ -1331,13 +1371,47 @@ export class Process extends BaseNode {
|
|
|
1331
1371
|
x: 0, y: 0,
|
|
1332
1372
|
},
|
|
1333
1373
|
},
|
|
1374
|
+
{
|
|
1375
|
+
concept: 'ProcessElement',
|
|
1376
|
+
name: 'InitiateTask',
|
|
1377
|
+
type: 'InitiateTask',
|
|
1378
|
+
title: '发起任务',
|
|
1379
|
+
...userTaskAttr,
|
|
1380
|
+
bounds: {
|
|
1381
|
+
concept: 'Rect',
|
|
1382
|
+
x: 0, y: 90,
|
|
1383
|
+
},
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
concept: 'ProcessElement',
|
|
1387
|
+
name: 'ApprovalTask',
|
|
1388
|
+
type: 'ApprovalTask',
|
|
1389
|
+
title: '审批任务',
|
|
1390
|
+
returns: [
|
|
1391
|
+
{
|
|
1392
|
+
concept: 'Return',
|
|
1393
|
+
description: '审批意见',
|
|
1394
|
+
name: 'approvalComment',
|
|
1395
|
+
},
|
|
1396
|
+
{
|
|
1397
|
+
concept: 'Return',
|
|
1398
|
+
description: '审批结果',
|
|
1399
|
+
name: 'approvalResult',
|
|
1400
|
+
},
|
|
1401
|
+
],
|
|
1402
|
+
...userTaskAttr,
|
|
1403
|
+
bounds: {
|
|
1404
|
+
concept: 'Rect',
|
|
1405
|
+
x: 0, y: 250,
|
|
1406
|
+
},
|
|
1407
|
+
},
|
|
1334
1408
|
{
|
|
1335
1409
|
concept: 'ProcessElement',
|
|
1336
1410
|
name: 'End',
|
|
1337
1411
|
type: 'EndNoneEvent',
|
|
1338
1412
|
bounds: {
|
|
1339
1413
|
concept: 'Rect',
|
|
1340
|
-
x: 0, y:
|
|
1414
|
+
x: 0, y: 500,
|
|
1341
1415
|
},
|
|
1342
1416
|
},
|
|
1343
1417
|
{
|
|
@@ -1345,6 +1419,28 @@ export class Process extends BaseNode {
|
|
|
1345
1419
|
name: 'SequenceFlow',
|
|
1346
1420
|
type: 'SequenceFlow',
|
|
1347
1421
|
sourceRef: 'Start',
|
|
1422
|
+
targetRef: 'InitiateTask',
|
|
1423
|
+
waypoints: [
|
|
1424
|
+
{ x: 0, y: 1 },
|
|
1425
|
+
{ x: 0, y: -1 },
|
|
1426
|
+
],
|
|
1427
|
+
},
|
|
1428
|
+
{
|
|
1429
|
+
concept: 'ProcessElement',
|
|
1430
|
+
name: 'SequenceFlow1',
|
|
1431
|
+
type: 'SequenceFlow',
|
|
1432
|
+
sourceRef: 'InitiateTask',
|
|
1433
|
+
targetRef: 'ApprovalTask',
|
|
1434
|
+
waypoints: [
|
|
1435
|
+
{ x: 0, y: 1 },
|
|
1436
|
+
{ x: 0, y: -1 },
|
|
1437
|
+
],
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
concept: 'ProcessElement',
|
|
1441
|
+
name: 'SequenceFlow2',
|
|
1442
|
+
type: 'SequenceFlow',
|
|
1443
|
+
sourceRef: 'ApprovalTask',
|
|
1348
1444
|
targetRef: 'End',
|
|
1349
1445
|
waypoints: [
|
|
1350
1446
|
{ x: 0, y: 1 },
|