@lcap/nasl 1.0.2 → 2.12.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/automate/engine/index.js +11 -0
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.js +1 -1
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +89 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/concepts/App__.d.ts +51 -49
- package/out/concepts/App__.js +86 -54
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +1 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.js +1 -1
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +1 -1
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +3 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +11 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +8 -3
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +1 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +23 -21
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +9 -8
- package/out/concepts/CallQueryComponent__.js +89 -79
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +2 -2
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +1 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +8 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigPropertyValue__.js +1 -1
- package/out/concepts/ConfigPropertyValue__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +4 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +4 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataElement__.js +1 -1
- package/out/concepts/DataElement__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +316 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +8 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +3 -3
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +7 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +20 -3
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -0
- package/out/concepts/Entity__.js +21 -11
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +11 -5
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +3 -3
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +96 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +3 -13
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +9 -9
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.js +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +41 -42
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +1 -85
- package/out/concepts/Module__.js +6 -107
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +1 -108
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/Param__.d.ts +2 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Point__.js +1 -1
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +26 -11
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/Process__.js +17 -10
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +9 -2
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +14 -3
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.js +1 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +15 -4
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.js +1 -1
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +11 -4
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/Slot__.js +1 -1
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +10 -0
- package/out/concepts/SqlQueryComponent__.js +32 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +20 -13
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +6 -6
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.js +1 -1
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.js +1 -1
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +46 -4
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +1 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.js +1 -1
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +1 -1
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.js +18 -18
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +25 -23
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +5 -5
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +278 -0
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/generator/genBundleFiles.js +8 -3
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +13 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +9 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getProcesses.d.ts +3 -0
- package/out/server/getProcesses.js +61 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +128 -6
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +10 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +19 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +2 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +15 -11
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +25 -21
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +12 -12
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +21 -20
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +6 -3
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +5 -5
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +8 -7
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +17 -15
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +15 -11
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/connect-file.js +6 -6
- package/out/test/integration/connect-file.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +4 -0
- package/out/utils/index.js +32 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/automate/engine/index.js +12 -1
- package/src/automate/engine/uniqueName.js +1 -1
- package/src/automate/engine/utils.js +92 -67
- package/src/concepts/App__.ts +165 -95
- package/src/concepts/Argument__.ts +1 -1
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/Attribute__.ts +1 -1
- package/src/concepts/BinaryExpression__.ts +1 -1
- package/src/concepts/BindAttribute__.ts +3 -3
- package/src/concepts/BindDirective__.ts +1 -1
- package/src/concepts/BindEvent__.ts +10 -6
- package/src/concepts/BooleanLiteral__.ts +1 -1
- package/src/concepts/CallFunction__.ts +19 -16
- package/src/concepts/CallInterface__.ts +1 -1
- package/src/concepts/CallLogic__.ts +23 -23
- package/src/concepts/CallQueryComponent__.ts +96 -113
- package/src/concepts/Comment__.ts +2 -2
- package/src/concepts/CompletionProperty__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +4 -2
- package/src/concepts/ConfigPropertyValue__.ts +1 -1
- package/src/concepts/ConfigProperty__.ts +5 -1
- package/src/concepts/Configuration__.ts +4 -1
- package/src/concepts/Constant__.ts +1 -1
- package/src/concepts/DataElement__.ts +1 -1
- package/src/concepts/DataSource__.ts +389 -0
- package/src/concepts/Destination__.ts +24 -8
- package/src/concepts/End__.ts +3 -3
- package/src/concepts/EntityIndex__.ts +8 -1
- package/src/concepts/EntityProperty__.ts +21 -3
- package/src/concepts/Entity__.ts +24 -12
- package/src/concepts/EnumItem__.ts +1 -1
- package/src/concepts/Enum__.ts +24 -5
- package/src/concepts/Event__.ts +1 -1
- package/src/concepts/ForEachStatement__.ts +3 -3
- package/src/concepts/Function__.ts +97 -3
- package/src/concepts/Identifier__.ts +12 -13
- package/src/concepts/IfStatement__.ts +10 -10
- package/src/concepts/InterfaceParam__.ts +1 -1
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +1 -1
- package/src/concepts/LogicItem__.ts +1 -1
- package/src/concepts/Logic__.ts +41 -39
- package/src/concepts/MemberExpression__.ts +1 -1
- package/src/concepts/Module__.ts +9 -204
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/NullLiteral__.ts +1 -1
- package/src/concepts/NumericLiteral__.ts +1 -1
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/Point__.ts +1 -1
- package/src/concepts/ProcessComponent__.ts +1 -1
- package/src/concepts/ProcessElement__.ts +29 -13
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/Process__.ts +17 -11
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +10 -2
- package/src/concepts/QueryFromExpression__.ts +14 -3
- package/src/concepts/QueryGroupByExpression__.ts +1 -1
- package/src/concepts/QueryJoinExpression__.ts +15 -4
- package/src/concepts/QueryLimitExpression__.ts +1 -1
- package/src/concepts/QueryOrderByExpression__.ts +1 -1
- package/src/concepts/QuerySelectExpression__.ts +1 -1
- package/src/concepts/Rect__.ts +1 -1
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +11 -5
- package/src/concepts/Slot__.ts +1 -1
- package/src/concepts/SqlQueryComponent__.ts +30 -11
- package/src/concepts/Start__.ts +1 -1
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +1 -1
- package/src/concepts/Structure__.ts +20 -12
- package/src/concepts/SwitchCase__.ts +6 -6
- package/src/concepts/SwitchStatement__.ts +1 -1
- package/src/concepts/Theme__.ts +1 -1
- package/src/concepts/Transactional__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +45 -23
- package/src/concepts/TypeParam__.ts +1 -1
- package/src/concepts/UnaryExpression__.ts +1 -1
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/UseComponent__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +1 -1
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewComponent__.ts +1 -1
- package/src/concepts/ViewElement__.ts +19 -19
- package/src/concepts/View__.ts +25 -23
- package/src/concepts/WhileStatement__.ts +5 -5
- package/src/concepts/basics/stdlib/nasl.util.ts +279 -0
- package/src/concepts/index__.ts +1 -0
- package/src/generator/genBundleFiles.ts +8 -3
- package/src/generator/genMetaData.ts +13 -13
- package/src/server/createUiTs.ts +1 -0
- package/src/server/getLogics.ts +11 -3
- package/src/server/getProcesses.ts +61 -0
- package/src/server/naslServer.ts +124 -6
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +22 -1
- package/src/service/storage/init.ts +2 -2
- package/src/templator/genCreateBlock.ts +16 -13
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
- package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
- package/src/templator/genEditTableBlock.ts +14 -13
- package/src/templator/genGridViewBlock.ts +22 -21
- package/src/templator/genListViewBlock.ts +9 -5
- package/src/templator/genQueryComponent.ts +6 -6
- package/src/templator/genSelectBlock.ts +9 -8
- package/src/templator/genTableBlock.ts +18 -16
- package/src/templator/genUpdateBlock.ts +16 -12
- package/src/templator/utils.ts +2 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +32 -0
package/src/concepts/Logic__.ts
CHANGED
|
@@ -1391,7 +1391,7 @@ export class Logic extends BaseNode {
|
|
|
1391
1391
|
// params
|
|
1392
1392
|
if (Array.isArray(this.params)) {
|
|
1393
1393
|
this.params.forEach((param) => {
|
|
1394
|
-
code += indent(state
|
|
1394
|
+
code += indent((state?.tabSize || 0) + 1) + '';
|
|
1395
1395
|
code += param.toJS(shiftState(state, code, { inline: true }));
|
|
1396
1396
|
code += ';\n';
|
|
1397
1397
|
});
|
|
@@ -1399,7 +1399,7 @@ export class Logic extends BaseNode {
|
|
|
1399
1399
|
// variables
|
|
1400
1400
|
if (Array.isArray(this.variables)) {
|
|
1401
1401
|
this.variables.forEach((variable) => {
|
|
1402
|
-
code += indent(state
|
|
1402
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1403
1403
|
code += variable.toJS(shiftState(state, code, { inline: true }));
|
|
1404
1404
|
code += ';\n';
|
|
1405
1405
|
});
|
|
@@ -1408,19 +1408,19 @@ export class Logic extends BaseNode {
|
|
|
1408
1408
|
// returns
|
|
1409
1409
|
if (Array.isArray(this.returns)) {
|
|
1410
1410
|
this.returns.forEach((ret) => {
|
|
1411
|
-
code += indent(state
|
|
1411
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1412
1412
|
code += ret.toJS(shiftState(state, code, { inline: true }));
|
|
1413
1413
|
code += ';\n';
|
|
1414
1414
|
});
|
|
1415
1415
|
}
|
|
1416
1416
|
if (Array.isArray(this.body)) {
|
|
1417
1417
|
this.body.forEach((item) => {
|
|
1418
|
-
code += item.toJS && item.toJS(shiftState(state, code, { tabSize: state
|
|
1418
|
+
code += item.toJS && item.toJS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1419
1419
|
code += '\n';
|
|
1420
1420
|
});
|
|
1421
1421
|
}
|
|
1422
1422
|
|
|
1423
|
-
code += indent(state
|
|
1423
|
+
code += indent((state?.tabSize || 0)) + '}\n';
|
|
1424
1424
|
|
|
1425
1425
|
return code;
|
|
1426
1426
|
}
|
|
@@ -1448,10 +1448,14 @@ export class Logic extends BaseNode {
|
|
|
1448
1448
|
path = `/api/${entityName.replace('-', '_')}/${logicName}`;
|
|
1449
1449
|
} else if (concept === 'Namespace') {
|
|
1450
1450
|
serviceType = 'entity';
|
|
1451
|
-
|
|
1451
|
+
let entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
|
|
1452
1452
|
const lowerChar = char.toLowerCase();
|
|
1453
1453
|
return index === 0 ? lowerChar : `-${lowerChar}`;
|
|
1454
1454
|
});
|
|
1455
|
+
// 默认数据源不动,其他数据源需要拼接数据源信息
|
|
1456
|
+
if (parentNode.parentNode.parentNode.concept === 'DataSource' && parentNode.parentNode.parentNode.name !== 'defaultDS') {
|
|
1457
|
+
entityPath = parentNode.parentNode.parentNode.name + '/' + entityPath;
|
|
1458
|
+
}
|
|
1455
1459
|
path = `/api/${entityPath}`;
|
|
1456
1460
|
switch (this.name) {
|
|
1457
1461
|
case 'get':
|
|
@@ -1513,33 +1517,33 @@ export class Logic extends BaseNode {
|
|
|
1513
1517
|
code += prependCode || '';
|
|
1514
1518
|
code += '\n';
|
|
1515
1519
|
this.variables.forEach((variable) => {
|
|
1516
|
-
code += indent(state
|
|
1520
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1517
1521
|
code += variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1518
1522
|
code += ';\n';
|
|
1519
1523
|
});
|
|
1520
1524
|
|
|
1521
1525
|
this.returns.forEach((ret) => {
|
|
1522
|
-
code += indent(state
|
|
1526
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1523
1527
|
code += ret.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1524
1528
|
code += ';\n';
|
|
1525
1529
|
});
|
|
1526
1530
|
|
|
1527
1531
|
if (!this.body.length && this.returns.length) {
|
|
1528
|
-
code += indent(state
|
|
1532
|
+
code += indent((state?.tabSize || 0) + 1) + `return ${this.returns[0].name};\n`;
|
|
1529
1533
|
} else {
|
|
1530
1534
|
this.body.forEach((item) => {
|
|
1531
|
-
code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
1535
|
+
code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1532
1536
|
code += '\n';
|
|
1533
1537
|
});
|
|
1534
1538
|
}
|
|
1535
1539
|
|
|
1536
1540
|
// 在body渲染完成之后把其余的节点放到下面
|
|
1537
1541
|
this.playground.forEach((item) => {
|
|
1538
|
-
code += item.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
1542
|
+
code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1539
1543
|
code += '\n';
|
|
1540
1544
|
});
|
|
1541
1545
|
|
|
1542
|
-
code += indent(state
|
|
1546
|
+
code += indent((state?.tabSize || 0)) + '}';
|
|
1543
1547
|
code += '\n';
|
|
1544
1548
|
return code;
|
|
1545
1549
|
}
|
|
@@ -1572,33 +1576,33 @@ export class Logic extends BaseNode {
|
|
|
1572
1576
|
code += '{\n';
|
|
1573
1577
|
|
|
1574
1578
|
this.variables.forEach((variable) => {
|
|
1575
|
-
code += indent(state
|
|
1579
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1576
1580
|
code += variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1577
1581
|
code += ';\n';
|
|
1578
1582
|
});
|
|
1579
1583
|
|
|
1580
1584
|
this.returns.forEach((ret) => {
|
|
1581
|
-
code += indent(state
|
|
1585
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1582
1586
|
code += ret.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1583
1587
|
code += ';\n';
|
|
1584
1588
|
});
|
|
1585
1589
|
|
|
1586
1590
|
if (!this.body.length && this.returns.length) {
|
|
1587
|
-
code += indent(state
|
|
1591
|
+
code += indent((state?.tabSize || 0) + 1) + `return ${this.returns[0].name};\n`;
|
|
1588
1592
|
} else {
|
|
1589
1593
|
this.body.forEach((item) => {
|
|
1590
|
-
code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
1594
|
+
code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1591
1595
|
code += '\n';
|
|
1592
1596
|
});
|
|
1593
1597
|
}
|
|
1594
1598
|
|
|
1595
1599
|
// 在body渲染完成之后把其余的节点放到下面
|
|
1596
1600
|
this.playground.forEach((item) => {
|
|
1597
|
-
code += item.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
1601
|
+
code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1598
1602
|
code += '\n';
|
|
1599
1603
|
});
|
|
1600
1604
|
|
|
1601
|
-
code += indent(state
|
|
1605
|
+
code += indent((state?.tabSize || 0)) + '}';
|
|
1602
1606
|
if (prefix === 'inObject') {
|
|
1603
1607
|
code += `,`;
|
|
1604
1608
|
}
|
|
@@ -1608,36 +1612,34 @@ export class Logic extends BaseNode {
|
|
|
1608
1612
|
|
|
1609
1613
|
getNamespace(): string {
|
|
1610
1614
|
if (this.parentNode) {
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1615
|
+
const parentNamespace = (this.parentNode as any)?.getNamespace();
|
|
1616
|
+
const parentName = this.parentNode.name;
|
|
1617
|
+
const arr = [parentNamespace];
|
|
1618
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
1619
|
+
arr.push(parentName);
|
|
1614
1620
|
}
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
=
|
|
1618
|
-
if (this.parentNode instanceof View) {
|
|
1619
|
-
return (parentNodeNamespace = '');
|
|
1621
|
+
let namespace = arr.join('.');
|
|
1622
|
+
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration'].includes(namespace) && !namespace.includes('.logics')) {
|
|
1623
|
+
namespace = `${namespace}.logics`;
|
|
1620
1624
|
}
|
|
1621
|
-
return
|
|
1625
|
+
return namespace;
|
|
1622
1626
|
} else
|
|
1623
1627
|
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
1624
1628
|
}
|
|
1625
1629
|
|
|
1626
1630
|
getTsNamespace(): string {
|
|
1627
1631
|
if (this.parentNode) {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1632
|
+
const parentNamespace = (this.parentNode as any)?.getTsNamespace();
|
|
1633
|
+
const parentName = this.parentNode.tsName || this.parentNode.name;
|
|
1634
|
+
const arr = [parentNamespace];
|
|
1635
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
1636
|
+
arr.push(parentName);
|
|
1633
1637
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
=
|
|
1637
|
-
if (this.parentNode instanceof View) {
|
|
1638
|
-
return (parentNodeNamespace = '');
|
|
1638
|
+
let namespace = arr.join('.');
|
|
1639
|
+
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration'].includes(namespace) && !namespace.includes('.logics')) {
|
|
1640
|
+
namespace = `${namespace}.logics`;
|
|
1639
1641
|
}
|
|
1640
|
-
return
|
|
1642
|
+
return namespace;
|
|
1641
1643
|
} else
|
|
1642
1644
|
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
1643
1645
|
}
|
|
@@ -1736,7 +1738,7 @@ export class Logic extends BaseNode {
|
|
|
1736
1738
|
//================================================================================
|
|
1737
1739
|
}
|
|
1738
1740
|
|
|
1739
|
-
classMap
|
|
1741
|
+
classMap.Logic = Logic;
|
|
1740
1742
|
export default Logic;
|
|
1741
1743
|
//================================================================================
|
|
1742
1744
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -279,7 +279,7 @@ export class MemberExpression extends LogicItem {
|
|
|
279
279
|
//================================================================================
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
classMap
|
|
282
|
+
classMap.MemberExpression = MemberExpression;
|
|
283
283
|
export default MemberExpression;
|
|
284
284
|
//================================================================================
|
|
285
285
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
package/src/concepts/Module__.ts
CHANGED
|
@@ -16,7 +16,6 @@ import * as utils from '../utils';
|
|
|
16
16
|
import { v4 as uuidv4 } from 'uuid';
|
|
17
17
|
import BaseNode from '../common/BaseNode';
|
|
18
18
|
import classMap from '../common/classMap';
|
|
19
|
-
import Entity from './Entity__';
|
|
20
19
|
import Structure from './Structure__';
|
|
21
20
|
import Enum from './Enum__';
|
|
22
21
|
import Logic from './Logic__';
|
|
@@ -73,12 +72,6 @@ export class Module extends BaseNode {
|
|
|
73
72
|
@property()
|
|
74
73
|
externalDependencyMap: { maven?: Array<{ groupId: string, artifactId: string, version: string }> } = undefined;
|
|
75
74
|
|
|
76
|
-
/**
|
|
77
|
-
* 实体列表
|
|
78
|
-
*/
|
|
79
|
-
@property('Entity')
|
|
80
|
-
entities: Array<Entity> = [];
|
|
81
|
-
|
|
82
75
|
/**
|
|
83
76
|
* 数据结构列表
|
|
84
77
|
*/
|
|
@@ -154,149 +147,7 @@ export class Module extends BaseNode {
|
|
|
154
147
|
}
|
|
155
148
|
|
|
156
149
|
|
|
157
|
-
|
|
158
|
-
const excludedSet = new Set(excludedList);
|
|
159
|
-
return (this.entities || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
160
|
-
}
|
|
161
|
-
getEntityUniqueName(name = 'Entity1') {
|
|
162
|
-
return utils.unique(name, this.getEntityExistingNames(), undefined, false);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* 插入实体
|
|
167
|
-
* @internal
|
|
168
|
-
* @param name 实体名称,如果不填会自动生成一个唯一名称
|
|
169
|
-
*/
|
|
170
|
-
_insertEntityAt(name: string, index: number): Entity;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 插入实体
|
|
174
|
-
* @internal
|
|
175
|
-
* @param entityOptions 实体参数
|
|
176
|
-
*/
|
|
177
|
-
_insertEntityAt(entityOptions: Partial<Entity>, index: number): Entity;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 插入实体
|
|
181
|
-
* @internal
|
|
182
|
-
* @param entity 已有的实体实例
|
|
183
|
-
*/
|
|
184
|
-
_insertEntityAt(entity: Entity, index: number): Entity;
|
|
185
|
-
|
|
186
|
-
_insertEntityAt(options: string | Partial<Entity> | Entity, index: number) {
|
|
187
|
-
const entityOptions: any = {};
|
|
188
|
-
const relationOptions = { parentNode: this, parentKey: 'entities' };
|
|
189
|
-
let entity: Entity;
|
|
190
|
-
if (!options) {
|
|
191
|
-
entity = Entity.from({
|
|
192
|
-
...entityOptions,
|
|
193
|
-
name: this.getEntityUniqueName(),
|
|
194
|
-
}, this, 'entities');
|
|
195
|
-
} else if (typeof options === 'string') {
|
|
196
|
-
entity = Entity.from({
|
|
197
|
-
...entityOptions,
|
|
198
|
-
name: options,
|
|
199
|
-
}, this, 'entities');
|
|
200
|
-
} else if (options instanceof Entity) {
|
|
201
|
-
options.ensureDelete(); // 同一实例不支持多处存在
|
|
202
|
-
entity = options;
|
|
203
|
-
Object.assign(entity, relationOptions);
|
|
204
|
-
} else {
|
|
205
|
-
entity = Entity.from({
|
|
206
|
-
...entityOptions,
|
|
207
|
-
...options,
|
|
208
|
-
}, this, 'entities');
|
|
209
|
-
}
|
|
210
|
-
this.entities.splice(index, 0, entity);
|
|
211
|
-
return entity;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* 插入实体
|
|
216
|
-
* @param name 实体名称,如果不填会自动生成一个唯一名称
|
|
217
|
-
*/
|
|
218
|
-
insertEntityAt(name: string, index: number): Entity;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* 插入实体
|
|
222
|
-
* @param entityOptions 实体参数
|
|
223
|
-
*/
|
|
224
|
-
insertEntityAt(entityOptions: Partial<Entity>, index: number): Entity;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* 插入实体
|
|
228
|
-
* @param entity 已有的实体实例
|
|
229
|
-
*/
|
|
230
|
-
insertEntityAt(entity: Entity, index: number): Entity;
|
|
231
|
-
|
|
232
|
-
insertEntityAt(options: string | Partial<Entity> | Entity, index: number) {
|
|
233
|
-
const node = this._insertEntityAt(options as any, index);
|
|
234
|
-
node.create({
|
|
235
|
-
index,
|
|
236
|
-
parentNode: this,
|
|
237
|
-
parentKey: 'entities',
|
|
238
|
-
});
|
|
239
|
-
return node;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* 添加实体
|
|
244
|
-
* @internal
|
|
245
|
-
* @param name 实体名称,如果不填会自动生成一个唯一名称
|
|
246
|
-
*/
|
|
247
|
-
_addEntity(name?: string): Entity;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* 添加实体
|
|
251
|
-
* @internal
|
|
252
|
-
* @param entityOptions 实体参数
|
|
253
|
-
*/
|
|
254
|
-
_addEntity(entityOptions: Partial<Entity>): Entity;
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* 添加实体
|
|
258
|
-
* @internal
|
|
259
|
-
* @param entity 已有的实体实例
|
|
260
|
-
*/
|
|
261
|
-
_addEntity(entity: Entity): Entity;
|
|
262
|
-
|
|
263
|
-
_addEntity(options?: string | Partial<Entity> | Entity) {
|
|
264
|
-
const index = 0;
|
|
265
|
-
return this._insertEntityAt(options as any, index);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* 添加实体
|
|
270
|
-
* @internal
|
|
271
|
-
* @param name 实体名称,如果不填会自动生成一个唯一名称
|
|
272
|
-
*/
|
|
273
|
-
addEntity(name?: string): Entity;
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* 添加实体
|
|
277
|
-
* @param entityOptions 实体参数
|
|
278
|
-
*/
|
|
279
|
-
addEntity(entityOptions: Partial<Entity>): Entity;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* 添加实体
|
|
283
|
-
* @param entity 已有的实体实例
|
|
284
|
-
*/
|
|
285
|
-
addEntity(entity: Entity): Entity;
|
|
286
|
-
|
|
287
|
-
addEntity(options?: string | Partial<Entity> | Entity) {
|
|
288
|
-
const node = this._addEntity(options as any);
|
|
289
|
-
const index = this.entities.indexOf(node);
|
|
290
|
-
node.create({
|
|
291
|
-
index,
|
|
292
|
-
parentNode: this,
|
|
293
|
-
parentKey: 'entities',
|
|
294
|
-
});
|
|
295
|
-
return node;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
getStructureExistingNames(excludedList: Array<Structure> = []) {
|
|
150
|
+
getStructureExistingNames(excludedList: Array<Structure> = []) {
|
|
300
151
|
const excludedSet = new Set(excludedList);
|
|
301
152
|
return (this.structures || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
302
153
|
}
|
|
@@ -1292,56 +1143,6 @@ export class Module extends BaseNode {
|
|
|
1292
1143
|
|
|
1293
1144
|
|
|
1294
1145
|
|
|
1295
|
-
/**
|
|
1296
|
-
* 删除实体
|
|
1297
|
-
* @param name 实体名称
|
|
1298
|
-
*/
|
|
1299
|
-
removeEntity(name: string): void;
|
|
1300
|
-
|
|
1301
|
-
/**
|
|
1302
|
-
* 删除实体
|
|
1303
|
-
* @param entity 已有的实体实例
|
|
1304
|
-
*/
|
|
1305
|
-
removeEntity(entity: Entity): void;
|
|
1306
|
-
|
|
1307
|
-
removeEntity(options: string | Entity) {
|
|
1308
|
-
let entity: Entity;
|
|
1309
|
-
if (typeof options === 'string') {
|
|
1310
|
-
entity = this.entities.find((item) => item.name === options);
|
|
1311
|
-
if (!entity) {
|
|
1312
|
-
throw new Error('找不到实体 ' + options);
|
|
1313
|
-
}
|
|
1314
|
-
} else {
|
|
1315
|
-
entity = options;
|
|
1316
|
-
}
|
|
1317
|
-
return entity.delete();
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
__removeEntity(entity: Entity) {
|
|
1321
|
-
const parentKey = entity.parentKey;
|
|
1322
|
-
const params: Params = {
|
|
1323
|
-
parentNode: this,
|
|
1324
|
-
parentKey,
|
|
1325
|
-
index: -1,
|
|
1326
|
-
object: null,
|
|
1327
|
-
oldObject: entity,
|
|
1328
|
-
};
|
|
1329
|
-
if (parentKey) {
|
|
1330
|
-
params.parentKey = parentKey;
|
|
1331
|
-
if (Array.isArray((this as any)[parentKey])) {
|
|
1332
|
-
const index = (this as any)[parentKey].indexOf(entity);
|
|
1333
|
-
~index && (this as any)[parentKey].splice(index, 1);
|
|
1334
|
-
params.index = index;
|
|
1335
|
-
} else if ((this as any)[parentKey] === entity) {
|
|
1336
|
-
params.index = 0;
|
|
1337
|
-
(this as any)[parentKey] = undefined;
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
return params;
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
1146
|
/**
|
|
1346
1147
|
* 删除数据结构
|
|
1347
1148
|
* @param name 数据结构名称
|
|
@@ -1707,11 +1508,15 @@ export class Module extends BaseNode {
|
|
|
1707
1508
|
* 暂时不考虑 Module 嵌套的情况
|
|
1708
1509
|
*/
|
|
1709
1510
|
getNamespace() {
|
|
1710
|
-
return `${moduleNameSpace[this.parentKey as ModuleKeyType]}
|
|
1511
|
+
return `${moduleNameSpace[this.parentKey as ModuleKeyType]}`;
|
|
1711
1512
|
}
|
|
1712
1513
|
|
|
1713
1514
|
getTsNamespace() {
|
|
1714
|
-
return `${moduleNameSpace[this.parentKey as ModuleKeyType]}
|
|
1515
|
+
return `${moduleNameSpace[this.parentKey as ModuleKeyType]}`;
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
findEnumByName(name: string) {
|
|
1519
|
+
return this.enums.find((enumItem) => enumItem.name === name);
|
|
1715
1520
|
}
|
|
1716
1521
|
|
|
1717
1522
|
/**
|
|
@@ -1719,7 +1524,7 @@ export class Module extends BaseNode {
|
|
|
1719
1524
|
*/
|
|
1720
1525
|
|
|
1721
1526
|
findProperty(name: string, propertyType: PropertyType): any {
|
|
1722
|
-
return (this[propertyType] as Array<any>).find((item) => item.name === name);
|
|
1527
|
+
return ((this as any)[propertyType] as Array<any>).find((item) => item.name === name);
|
|
1723
1528
|
}
|
|
1724
1529
|
|
|
1725
1530
|
//================================================================================
|
|
@@ -1728,7 +1533,7 @@ export class Module extends BaseNode {
|
|
|
1728
1533
|
//================================================================================
|
|
1729
1534
|
}
|
|
1730
1535
|
|
|
1731
|
-
classMap
|
|
1536
|
+
classMap.Module = Module;
|
|
1732
1537
|
export default Module;
|
|
1733
1538
|
//================================================================================
|
|
1734
1539
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|