@lcap/nasl 3.5.0-beta.3 → 3.5.0-beta.5
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/breakpoint/store/core.js +1 -1
- package/out/breakpoint/store/core.js.map +1 -1
- package/out/common/BaseNode.d.ts +7 -0
- package/out/common/BaseNode.js +15 -2
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +34 -16
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +1 -0
- package/out/concepts/Argument__.js +28 -8
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignment__.js +5 -7
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +5 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +1 -0
- package/out/concepts/BinaryExpression__.js +30 -13
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +11 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +3 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +2 -2
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +1 -0
- package/out/concepts/BooleanLiteral__.js +6 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +4 -2
- package/out/concepts/BusinessComponent__.js +128 -89
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/CallConnector__.d.ts +1 -0
- package/out/concepts/CallConnector__.js +6 -0
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallEvent__.d.ts +4 -0
- package/out/concepts/CallEvent__.js +19 -2
- package/out/concepts/CallEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +1 -0
- package/out/concepts/CallFunction__.js +62 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +31 -22
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +49 -38
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +2 -0
- package/out/concepts/CallQueryComponent__.js +94 -8
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/DefaultValue__.d.ts +1 -0
- package/out/concepts/DefaultValue__.js +7 -1
- package/out/concepts/DefaultValue__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +34 -22
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +1 -0
- package/out/concepts/EntityProperty__.js +26 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -0
- package/out/concepts/Entity__.js +25 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +1 -0
- package/out/concepts/EnumItem__.js +12 -0
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +16 -2
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.d.ts +4 -0
- package/out/concepts/Event__.js +12 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +10 -16
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendType__.js +1 -0
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +2 -0
- package/out/concepts/Identifier__.js +21 -0
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +6 -0
- package/out/concepts/LogicItem__.js +11 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +24 -23
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +5 -5
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +1 -1
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -0
- package/out/concepts/MemberExpression__.js +13 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js +3 -3
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +4 -4
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -1
- package/out/concepts/NewMap__.js +6 -5
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/NullLiteral__.d.ts +2 -0
- package/out/concepts/NullLiteral__.js +12 -0
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.d.ts +1 -0
- package/out/concepts/NumericLiteral__.js +7 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +4 -2
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -0
- package/out/concepts/Param__.js +41 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +9 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.d.ts +2 -0
- package/out/concepts/QueryAggregateExpression__.js +16 -0
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +2 -0
- package/out/concepts/QueryFieldExpression__.js +33 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +2 -0
- package/out/concepts/QueryFromExpression__.js +27 -0
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +2 -0
- package/out/concepts/QueryGroupByExpression__.js +13 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +2 -0
- package/out/concepts/QueryJoinExpression__.js +37 -0
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.d.ts +2 -0
- package/out/concepts/QueryLimitExpression__.js +16 -0
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +2 -0
- package/out/concepts/QueryOrderByExpression__.js +22 -0
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +3 -0
- package/out/concepts/QuerySelectExpression__.js +41 -0
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +1 -0
- package/out/concepts/SelectMembers__.js +7 -0
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +4 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringInterpolation__.d.ts +1 -0
- package/out/concepts/StringInterpolation__.js +20 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -0
- package/out/concepts/StringLiteral__.js +21 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +1 -0
- package/out/concepts/StructureProperty__.js +19 -0
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +1 -0
- package/out/concepts/Structure__.js +22 -7
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +1 -0
- package/out/concepts/TypeAnnotation__.js +42 -1
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +2 -1
- package/out/concepts/TypeParam__.js +7 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +2 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +72 -59
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +2 -1
- package/out/concepts/View__.js +6 -19
- package/out/concepts/View__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +4 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +4 -1
- package/out/natural/genNaturalTS.js +38 -1
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/transformTSCode.js +52 -41
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/formatTsUtils.js +10 -9
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getFunctions.js +3 -3
- package/out/server/getFunctions.js.map +1 -1
- package/out/server/getProcesses.js +3 -3
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +52 -17
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +8 -0
- package/out/server/translator.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +2 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -1
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +3 -3
- package/out/templator/utils.js.map +1 -1
- package/out/translator/types.d.ts +2 -0
- package/out/translator/utils.d.ts +2 -1
- package/out/translator/utils.js +44 -7
- package/out/translator/utils.js.map +1 -1
- package/out/utils/string.js +2 -2
- package/out/utils/string.js.map +1 -1
- package/out/utils/time-slicing/performance.js +3 -3
- package/out/utils/time-slicing/performance.js.map +1 -1
- package/package.json +2 -2
- package/src/breakpoint/store/core.ts +1 -1
- package/src/common/BaseNode.ts +17 -3
- package/src/concepts/AnonymousFunction__.ts +24 -9
- package/src/concepts/Argument__.ts +28 -6
- package/src/concepts/Assignment__.ts +5 -7
- package/src/concepts/BatchAssignment__.ts +6 -3
- package/src/concepts/BinaryExpression__.ts +30 -13
- package/src/concepts/BindAttribute__.ts +10 -3
- package/src/concepts/BindDirective__.ts +3 -3
- package/src/concepts/BindEvent__.ts +2 -2
- package/src/concepts/BooleanLiteral__.ts +5 -0
- package/src/concepts/BusinessComponent__.ts +144 -100
- package/src/concepts/CallConnector__.ts +5 -0
- package/src/concepts/CallEvent__.ts +20 -3
- package/src/concepts/CallFunction__.ts +54 -8
- package/src/concepts/CallInterface__.ts +31 -24
- package/src/concepts/CallLogic__.ts +48 -37
- package/src/concepts/CallQueryComponent__.ts +101 -8
- package/src/concepts/DefaultValue__.ts +6 -1
- package/src/concepts/Destination__.ts +32 -22
- package/src/concepts/EntityProperty__.ts +30 -2
- package/src/concepts/Entity__.ts +29 -0
- package/src/concepts/EnumItem__.ts +17 -0
- package/src/concepts/Enum__.ts +19 -2
- package/src/concepts/Event__.ts +13 -0
- package/src/concepts/ForEachStatement__.ts +10 -20
- package/src/concepts/FrontendType__.ts +1 -0
- package/src/concepts/Identifier__.ts +19 -0
- package/src/concepts/JSBlock__.ts +1 -1
- package/src/concepts/LogicItem__.ts +13 -1
- package/src/concepts/Logic__.ts +24 -24
- package/src/concepts/MatchCase__.ts +5 -5
- package/src/concepts/Match__.ts +1 -1
- package/src/concepts/MemberExpression__.ts +12 -3
- package/src/concepts/NewComposite__.ts +7 -9
- package/src/concepts/NewList__.ts +4 -4
- package/src/concepts/NewMap__.ts +6 -5
- package/src/concepts/NullLiteral__.ts +10 -0
- package/src/concepts/NumericLiteral__.ts +6 -1
- package/src/concepts/OqlQueryComponent__.ts +4 -2
- package/src/concepts/Param__.ts +39 -0
- package/src/concepts/ProcessElement__.ts +8 -1
- package/src/concepts/QueryAggregateExpression__.ts +15 -0
- package/src/concepts/QueryFieldExpression__.ts +34 -0
- package/src/concepts/QueryFromExpression__.ts +29 -0
- package/src/concepts/QueryGroupByExpression__.ts +11 -1
- package/src/concepts/QueryJoinExpression__.ts +39 -0
- package/src/concepts/QueryLimitExpression__.ts +14 -0
- package/src/concepts/QueryOrderByExpression__.ts +23 -0
- package/src/concepts/QuerySelectExpression__.ts +55 -0
- package/src/concepts/SelectMembers__.ts +7 -0
- package/src/concepts/SqlQueryComponent__.ts +4 -2
- package/src/concepts/StringInterpolation__.ts +18 -2
- package/src/concepts/StringLiteral__.ts +20 -1
- package/src/concepts/StructureProperty__.ts +22 -0
- package/src/concepts/Structure__.ts +24 -7
- package/src/concepts/SwitchCase__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +37 -1
- package/src/concepts/TypeParam__.ts +6 -1
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/ViewElement__.ts +74 -58
- package/src/concepts/View__.ts +6 -19
- package/src/generator/genBundleFiles.ts +6 -1
- package/src/natural/genNaturalTS.ts +41 -0
- package/src/natural/transformTSCode.ts +50 -42
- package/src/server/formatTsUtils.ts +16 -11
- package/src/server/getFunctions.ts +3 -3
- package/src/server/getProcesses.ts +3 -3
- package/src/server/naslServer.ts +56 -18
- package/src/server/translator.ts +7 -0
- package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -1
- package/src/templator/genGetBlock.ts +2 -1
- package/src/templator/genUpdateBlock.ts +2 -1
- package/src/templator/utils.ts +3 -3
- package/src/translator/types.ts +4 -0
- package/src/translator/utils.ts +73 -34
- package/src/utils/string.ts +2 -2
- package/src/utils/time-slicing/performance.ts +3 -3
- package/test/concepts/call-interface/__snapshots__/getQuickInfoOffset.spec.ts.snap +3 -3
- package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
- package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +199 -0
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +127 -6
- package/test/concepts/view-element/fixtures/table-data-source-calllogic-with-server-validation.json +2074 -0
- package/test/concepts/view-element/toVue.spec.ts +0 -1
- package/ts-worker/package.json +1 -1
- package/ts-worker/src/index.js +1 -0
|
@@ -1335,7 +1335,7 @@ export class CallLogic extends LogicItem {
|
|
|
1335
1335
|
code += ';';
|
|
1336
1336
|
}
|
|
1337
1337
|
};
|
|
1338
|
-
if (useIife) {
|
|
1338
|
+
if (!state.callLogicNoIife && useIife) {
|
|
1339
1339
|
code += '(() =>{\nconst wrapper = ';
|
|
1340
1340
|
if (handleError) {
|
|
1341
1341
|
code += 'nasl.util.autoHandleError(';
|
|
@@ -1362,7 +1362,7 @@ export class CallLogic extends LogicItem {
|
|
|
1362
1362
|
// 属于业务组件
|
|
1363
1363
|
const belongBusinessComponent = !!this.businessComponent;
|
|
1364
1364
|
if (belongBusinessComponent && !self.calleeNamespace) {
|
|
1365
|
-
code +=
|
|
1365
|
+
code += `(this as ${this.businessComponent.name}).`;
|
|
1366
1366
|
}
|
|
1367
1367
|
code += calleeKey;
|
|
1368
1368
|
yield* setTypeArguments();
|
|
@@ -1390,8 +1390,8 @@ export class CallLogic extends LogicItem {
|
|
|
1390
1390
|
|
|
1391
1391
|
let code = '';
|
|
1392
1392
|
let calleeKey = this.calleeKey.replace('__elements', '$refs');
|
|
1393
|
-
if (/^app.+?\.entities\..+?logics/.test(
|
|
1394
|
-
calleeKey = calleeKey.replace(/^app.+?\.entities\.(.+?)\.logics/, '$
|
|
1393
|
+
if (/^app.+?\.entities\..+?logics/.test(calleeKey))
|
|
1394
|
+
calleeKey = calleeKey.replace(/^app.+?\.entities\.(.+?)\.logics/, '$1Entity');
|
|
1395
1395
|
/** 设置函数范型参数 */
|
|
1396
1396
|
const setTypeArguments = () => {
|
|
1397
1397
|
if (Array.isArray(typeArguments) && typeArguments.length) {
|
|
@@ -1415,16 +1415,24 @@ export class CallLogic extends LogicItem {
|
|
|
1415
1415
|
) {
|
|
1416
1416
|
code += '(';
|
|
1417
1417
|
logicArgs.forEach((arg, index) => {
|
|
1418
|
-
|
|
1419
|
-
|
|
1418
|
+
if (!arg) {
|
|
1419
|
+
code += '__IDENTIFIER__';
|
|
1420
|
+
} else {
|
|
1421
|
+
// 页面逻辑先都非必填
|
|
1422
|
+
code += arg.toNaturalTS(shiftState(state, code, { tabSize: 0 }), paramRequired);
|
|
1423
|
+
}
|
|
1420
1424
|
if (index !== logicArgs.length - 1) code += ', ';
|
|
1421
1425
|
});
|
|
1422
1426
|
code += ')';
|
|
1423
1427
|
} else if (completeArguments.length) {
|
|
1424
1428
|
code += '(';
|
|
1425
1429
|
completeArguments.forEach((arg, index) => {
|
|
1426
|
-
|
|
1427
|
-
|
|
1430
|
+
if (!arg) {
|
|
1431
|
+
code += '__IDENTIFIER__';
|
|
1432
|
+
} else {
|
|
1433
|
+
// 取到是不是必填放入参数中
|
|
1434
|
+
code += arg.toNaturalTS(shiftState(state, code, { tabSize: 0 }), arg?.paramRequired);
|
|
1435
|
+
}
|
|
1428
1436
|
if (index !== logicArgs.length - 1) code += ', ';
|
|
1429
1437
|
});
|
|
1430
1438
|
code += ')';
|
|
@@ -1455,42 +1463,42 @@ export class CallLogic extends LogicItem {
|
|
|
1455
1463
|
}
|
|
1456
1464
|
};
|
|
1457
1465
|
|
|
1458
|
-
if (useIife) {
|
|
1459
|
-
|
|
1466
|
+
// if (useIife) {
|
|
1467
|
+
// code += '(() =>{\nconst wrapper = ';
|
|
1460
1468
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1469
|
+
// if (handleError) {
|
|
1470
|
+
// code += 'nasl.util.autoHandleError(';
|
|
1471
|
+
// }
|
|
1464
1472
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1473
|
+
// if (useValidation) {
|
|
1474
|
+
// code += 'nasl.util.callLogicWithChecker(';
|
|
1475
|
+
// }
|
|
1468
1476
|
|
|
1469
|
-
|
|
1470
|
-
|
|
1477
|
+
// code += calleeKey;
|
|
1478
|
+
// setTypeArguments();
|
|
1471
1479
|
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1480
|
+
// if (useValidation) {
|
|
1481
|
+
// code += ', (';
|
|
1482
|
+
// code += completeArguments.map((item) => item.keyword).join(', ');
|
|
1483
|
+
// code += ') => {\n';
|
|
1484
|
+
// code += validation.toNaturalTS(shiftState(state, code));
|
|
1485
|
+
// code += ';\n})';
|
|
1486
|
+
// }
|
|
1479
1487
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1488
|
+
// if (handleError) {
|
|
1489
|
+
// code += ')';
|
|
1490
|
+
// }
|
|
1483
1491
|
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
} else {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
}
|
|
1492
|
+
// code += ';\nreturn wrapper';
|
|
1493
|
+
// setInputParam();
|
|
1494
|
+
// code += ';\n})()';
|
|
1495
|
+
// } else {
|
|
1496
|
+
code += calleeKey;
|
|
1497
|
+
setTypeArguments();
|
|
1498
|
+
setInputParam();
|
|
1499
|
+
// }
|
|
1492
1500
|
|
|
1493
|
-
setEndSemi();
|
|
1501
|
+
// setEndSemi();
|
|
1494
1502
|
|
|
1495
1503
|
return code;
|
|
1496
1504
|
}
|
|
@@ -1562,6 +1570,9 @@ export class CallLogic extends LogicItem {
|
|
|
1562
1570
|
const logicParams = node?.params ?? [];
|
|
1563
1571
|
|
|
1564
1572
|
callArguments.forEach((arg, index) => {
|
|
1573
|
+
if (!arg)
|
|
1574
|
+
return;
|
|
1575
|
+
|
|
1565
1576
|
const param = logicParams[index] || ({} as Param);
|
|
1566
1577
|
arg.paramRequired = Boolean(!param?.defaultValue?.expression);
|
|
1567
1578
|
arg.paramTypeAnnotation = undefined;
|
|
@@ -950,14 +950,14 @@ export class CallQueryComponent extends LogicItem {
|
|
|
950
950
|
const n = logicItem.__v_raw || logicItem;
|
|
951
951
|
if (Array.isArray((t as any)[parentKey])) {
|
|
952
952
|
// @ts-ignore
|
|
953
|
-
const index = (t as any)[parentKey]
|
|
954
|
-
~index && (this as any)[parentKey]
|
|
953
|
+
const index = (t as any)[parentKey]?.findIndex((el) => ((el.__v_raw || el) === n));
|
|
954
|
+
~index && (this as any)[parentKey]?.splice(index, 1);
|
|
955
955
|
params.index = index;
|
|
956
956
|
} else {
|
|
957
957
|
const q = (t as any)[parentKey];
|
|
958
|
-
if ((q
|
|
958
|
+
if ((q?.__v_raw || q) === n) {
|
|
959
959
|
params.index = 0;
|
|
960
|
-
(this as any)[parentKey] = undefined;
|
|
960
|
+
this && ((this as any)[parentKey] = undefined);
|
|
961
961
|
}
|
|
962
962
|
}
|
|
963
963
|
}
|
|
@@ -1317,7 +1317,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1317
1317
|
return;
|
|
1318
1318
|
}
|
|
1319
1319
|
const entityNamespace = this.from?.entityNamespace;
|
|
1320
|
-
const entities = this.app
|
|
1320
|
+
const entities = this.app?.findNodeByCompleteName?.(entityNamespace);
|
|
1321
1321
|
if (!this.isAutoInfer()) {
|
|
1322
1322
|
// 存量应用走之前的逻辑
|
|
1323
1323
|
return this.saveStructureNoInfer(entities);
|
|
@@ -1361,8 +1361,8 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1361
1361
|
// 1.1 单分组无聚合:`{ list: List<列的类型>, total: Long }`
|
|
1362
1362
|
const { entityAsName, propertyName } = groupBy[0].groupElement as QueryFieldExpression;
|
|
1363
1363
|
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
1364
|
-
const property = entity?.properties
|
|
1365
|
-
const propertyTypeAnnotation = property
|
|
1364
|
+
const property = entity?.properties?.find((item: any) => item.name === propertyName);
|
|
1365
|
+
const propertyTypeAnnotation = property?.typeAnnotation;
|
|
1366
1366
|
|
|
1367
1367
|
typeAnnotation = TypeAnnotation.from(
|
|
1368
1368
|
{
|
|
@@ -1673,7 +1673,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1673
1673
|
});
|
|
1674
1674
|
completionProperty.icon = 'property';
|
|
1675
1675
|
// 标记实体属性是否是符合类型
|
|
1676
|
-
Object.assign(completionProperty, { isComplexType: property.typeAnnotation.isComplexType() });
|
|
1676
|
+
Object.assign(completionProperty, { isComplexType: property.typeAnnotation.isComplexType?.() });
|
|
1677
1677
|
return completionProperty;
|
|
1678
1678
|
}),
|
|
1679
1679
|
}));
|
|
@@ -1779,6 +1779,99 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1779
1779
|
};
|
|
1780
1780
|
loop(node.from);
|
|
1781
1781
|
}
|
|
1782
|
+
|
|
1783
|
+
@withSourceMap()
|
|
1784
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
1785
|
+
let code = '';
|
|
1786
|
+
// return '__IDENTIFIER__';
|
|
1787
|
+
|
|
1788
|
+
code += this.from ? this.from.toNaturalTS(shiftState(state, code)) : '$';
|
|
1789
|
+
|
|
1790
|
+
const re = /FROM\(|JOIN\(/g;
|
|
1791
|
+
let count = 0;
|
|
1792
|
+
while(re.exec(code)) count++;
|
|
1793
|
+
|
|
1794
|
+
if (this.where) {
|
|
1795
|
+
code += `\n${indent(state.tabSize)}.WHERE(() => `;
|
|
1796
|
+
code += this.where.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1797
|
+
code += ')';
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
if (this.groupBy.length) {
|
|
1801
|
+
code += `\n${indent(state.tabSize)}.GROUP_BY(() => `;
|
|
1802
|
+
this.groupBy.forEach((groupExpression, index) => {
|
|
1803
|
+
code += groupExpression.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1804
|
+
if (index !== this.groupBy.length - 1) code += ', ';
|
|
1805
|
+
});
|
|
1806
|
+
code += ')';
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
if (this.having) {
|
|
1810
|
+
code += `\n${indent(state.tabSize)}.HAVING(() => `;
|
|
1811
|
+
code += this.having.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1812
|
+
code += ')';
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
if (this.orderBy.length) {
|
|
1816
|
+
code += `\n${indent(state.tabSize)}.ORDER_BY(() => `;
|
|
1817
|
+
this.orderBy.forEach((orderExpression, index) => {
|
|
1818
|
+
code += orderExpression.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1819
|
+
if (index !== this.orderBy.length - 1) code += ', ';
|
|
1820
|
+
});
|
|
1821
|
+
code += ')';
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
code += this.select.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize }));
|
|
1825
|
+
|
|
1826
|
+
if (this.limit) {
|
|
1827
|
+
code += `\n${indent(state.tabSize)}.PAGINATE(() => `;
|
|
1828
|
+
code += this.limit.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1829
|
+
code += `)\n`;
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
code += indent(state.tabSize) + ')'.repeat(count);
|
|
1833
|
+
|
|
1834
|
+
return code;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
@withSourceMap()
|
|
1838
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
1839
|
+
let code = '';
|
|
1840
|
+
|
|
1841
|
+
code += this.select.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
1842
|
+
if (this.groupBy.length) {
|
|
1843
|
+
this.groupBy.forEach((groupElement, index) => {
|
|
1844
|
+
code += ', ';
|
|
1845
|
+
code += (groupElement.groupElement as QueryFieldExpression).toTextualNASL(state);
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
code += ' ';
|
|
1850
|
+
code += this.from.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
1851
|
+
|
|
1852
|
+
if (this.where)
|
|
1853
|
+
code += '\nWHERE ' + this.where.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
1854
|
+
if (this.groupBy.length) {
|
|
1855
|
+
code += '\nGROUP BY ';
|
|
1856
|
+
this.groupBy.forEach((groupExpression, index) => {
|
|
1857
|
+
code += groupExpression.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
1858
|
+
if (index !== this.groupBy.length - 1) code += ', ';
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
if (this.having)
|
|
1862
|
+
code += '\nHAVING ' + this.having.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
1863
|
+
if (this.orderBy.length) {
|
|
1864
|
+
code += '\nORDER BY ';
|
|
1865
|
+
this.orderBy.forEach((orderExpression, index) => {
|
|
1866
|
+
code += orderExpression.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
1867
|
+
if (index !== this.orderBy.length - 1) code += ', ';
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
if (this.limit)
|
|
1871
|
+
code += '\nLIMIT ' + this.limit.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
1872
|
+
|
|
1873
|
+
return code;
|
|
1874
|
+
}
|
|
1782
1875
|
//================================================================================
|
|
1783
1876
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
1784
1877
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -248,7 +248,7 @@ export class DefaultValue extends BaseNode {
|
|
|
248
248
|
params.index = index;
|
|
249
249
|
} else {
|
|
250
250
|
const q = (t as any)[parentKey];
|
|
251
|
-
if ((q
|
|
251
|
+
if ((q?.__v_raw || q) === n) {
|
|
252
252
|
params.index = 0;
|
|
253
253
|
(this as any)[parentKey] = undefined;
|
|
254
254
|
}
|
|
@@ -300,6 +300,11 @@ export class DefaultValue extends BaseNode {
|
|
|
300
300
|
code += yield* this.expression?.toEmbeddedTS?.(shiftState(state, code)) ?? returnOrigin('undefined');
|
|
301
301
|
return code;
|
|
302
302
|
}
|
|
303
|
+
|
|
304
|
+
@withSourceMap()
|
|
305
|
+
toNaturalTS(state?: TranslatorState): string {
|
|
306
|
+
return this.expression.toNaturalTS(state);
|
|
307
|
+
}
|
|
303
308
|
//================================================================================
|
|
304
309
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
305
310
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -358,7 +358,8 @@ export class Destination extends LogicItem {
|
|
|
358
358
|
if (this.viewName) {
|
|
359
359
|
viewArr.push(this.viewName);
|
|
360
360
|
}
|
|
361
|
-
//
|
|
361
|
+
// 端名和端类型名都需要去掉
|
|
362
|
+
viewArr.shift();
|
|
362
363
|
viewArr.shift();
|
|
363
364
|
return viewArr;
|
|
364
365
|
}
|
|
@@ -690,6 +691,7 @@ export class Destination extends LogicItem {
|
|
|
690
691
|
}
|
|
691
692
|
});
|
|
692
693
|
}
|
|
694
|
+
console.log(viewNameAttr);
|
|
693
695
|
if (this.viewNode) {
|
|
694
696
|
return `${this.viewNode?.frontend?.prefixPath}/${viewNameAttr.join('/')}`;
|
|
695
697
|
}
|
|
@@ -697,13 +699,13 @@ export class Destination extends LogicItem {
|
|
|
697
699
|
}
|
|
698
700
|
|
|
699
701
|
@withSourceMapGenerator
|
|
700
|
-
*toEmbeddedTSInProcess(state = createCompilerState(),
|
|
702
|
+
*toEmbeddedTSInProcess(state = createCompilerState(), prevCode: string): TranslatorGenerator {
|
|
701
703
|
const self = this;
|
|
702
704
|
// const tab = indent((state?.tabSize || 0));
|
|
703
705
|
if (self.tsCalleeNamespace && self.tsName) {
|
|
704
706
|
const destinationName = self.parentNode.name.replace('-', '_');
|
|
705
707
|
let code = `${destinationName}: function() {\n`;
|
|
706
|
-
code +=
|
|
708
|
+
code += prevCode;
|
|
707
709
|
code += '\n';
|
|
708
710
|
if (self.tsCalleeNamespace && self.viewName) {
|
|
709
711
|
code += `${self.tsCalleeNamespace}.${self.viewName}.$destination({`;
|
|
@@ -787,12 +789,16 @@ export class Destination extends LogicItem {
|
|
|
787
789
|
code += `${this.tsCalleeNamespace}.${this.tsName}.$destination({`;
|
|
788
790
|
if (Array.isArray(this.arguments)) {
|
|
789
791
|
this.arguments.slice(0, logicParamLength).forEach((argument: Argument, index) => {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
792
|
+
if (!argument) {
|
|
793
|
+
code += `__unknown__: __IDENTIFIER__, `;
|
|
794
|
+
} else {
|
|
795
|
+
const oldName = argument.keyword;
|
|
796
|
+
if (index >= logicParamLength) {
|
|
797
|
+
argument.keyword = '__unknown__';
|
|
798
|
+
}
|
|
799
|
+
code += `${argument.toNaturalTS(shiftState(state, code), false, true)}, `;
|
|
800
|
+
argument.keyword = oldName;
|
|
793
801
|
}
|
|
794
|
-
code += `${argument.toNaturalTS(shiftState(state, code), false, true)}, `;
|
|
795
|
-
argument.keyword = oldName;
|
|
796
802
|
});
|
|
797
803
|
}
|
|
798
804
|
|
|
@@ -803,22 +809,26 @@ export class Destination extends LogicItem {
|
|
|
803
809
|
return code;
|
|
804
810
|
}
|
|
805
811
|
if (this.tsCalleeNamespace && this.tsName) {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
argument.keyword =
|
|
815
|
-
|
|
816
|
-
|
|
812
|
+
const viewPath = `${this.tsCalleeNamespace}.${this.tsName}`.replace(/^app\..+?.views\./, '').replace(/\.views\./g, '_view.') + '_view';
|
|
813
|
+
code += `nasl.ui.destination('${viewPath}'`;
|
|
814
|
+
this.arguments.slice(0, logicParamLength).forEach((argument: Argument, index) => {
|
|
815
|
+
if (!argument) {
|
|
816
|
+
code += `, __IDENTIFIER__`;
|
|
817
|
+
} else {
|
|
818
|
+
// const oldName = argument.keyword;
|
|
819
|
+
// if (index >= logicParamLength) {
|
|
820
|
+
// argument.keyword = '__unknown__';
|
|
821
|
+
// }
|
|
822
|
+
code += `, `;
|
|
823
|
+
code += argument.toNaturalTS(shiftState(state, code, { inline: true }), false, false);
|
|
824
|
+
// argument.keyword = oldName;
|
|
825
|
+
}
|
|
826
|
+
});
|
|
817
827
|
|
|
818
|
-
code += this.anchor?.toNaturalTS(shiftState(state, code, { inline: true }), true) || '';
|
|
819
|
-
code += `,
|
|
828
|
+
// code += this.anchor?.toNaturalTS(shiftState(state, code, { inline: true }), true) || '';
|
|
829
|
+
// code += `, '${this.target}'`;
|
|
820
830
|
|
|
821
|
-
code += `
|
|
831
|
+
code += `);\n`;
|
|
822
832
|
} else {
|
|
823
833
|
code += '__IDENTIFIER__';
|
|
824
834
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
withSourceMapGenerator,
|
|
10
10
|
withGenerator,
|
|
11
11
|
TranslatorGenerator,
|
|
12
|
+
createDecoratorCode,
|
|
12
13
|
} from '../translator';
|
|
13
14
|
import type CallQueryComponent from './CallQueryComponent__';
|
|
14
15
|
|
|
@@ -546,10 +547,10 @@ export class EntityProperty extends BaseNode {
|
|
|
546
547
|
// 处理选中的此字段的 CallQueryComponent
|
|
547
548
|
const callQueryComponents: Set<CallQueryComponent> = new Set();
|
|
548
549
|
const refs = await this.findUsage();
|
|
549
|
-
refs
|
|
550
|
+
refs?.forEach((val: any) => {
|
|
550
551
|
const loopFindNode = (item: any) => {
|
|
551
552
|
if (item.children) {
|
|
552
|
-
item.children
|
|
553
|
+
item.children?.forEach((i: any) => loopFindNode(i));
|
|
553
554
|
} else {
|
|
554
555
|
const target = item.node?.getAncestor('CallQueryComponent');
|
|
555
556
|
if (target) {
|
|
@@ -672,6 +673,33 @@ export class EntityProperty extends BaseNode {
|
|
|
672
673
|
return code;
|
|
673
674
|
}
|
|
674
675
|
|
|
676
|
+
@withSourceMap()
|
|
677
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
678
|
+
let code = '';
|
|
679
|
+
|
|
680
|
+
const index = (this.parentNode as Entity)?.properties.indexOf(this);
|
|
681
|
+
if (index > 0) code += `\n${indent(state.tabSize)}`;
|
|
682
|
+
|
|
683
|
+
code += createDecoratorCode(state, this, ['label', 'description', 'uuid', 'columnName', 'required', 'primaryKey', 'generationRule', 'sequence']);
|
|
684
|
+
|
|
685
|
+
// , 'display'
|
|
686
|
+
|
|
687
|
+
// if (this.relationNamespace && this.relationEntity && this.relationProperty) {
|
|
688
|
+
// code += `@EntityRelation(() => new ${this.relationEntity}().${this.relationProperty})\n`;
|
|
689
|
+
// code += indent(state.tabSize);
|
|
690
|
+
// }
|
|
691
|
+
|
|
692
|
+
code += this.name;
|
|
693
|
+
if (this.typeAnnotation) {
|
|
694
|
+
code += ': ';
|
|
695
|
+
code += this.typeAnnotation.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
696
|
+
}
|
|
697
|
+
if (this.defaultValue) {
|
|
698
|
+
code += ` = ${this.defaultValue}`;
|
|
699
|
+
}
|
|
700
|
+
return code;
|
|
701
|
+
}
|
|
702
|
+
|
|
675
703
|
/**
|
|
676
704
|
* 设置数据类型
|
|
677
705
|
* @param typeAnnotation 类型标注对象
|
package/src/concepts/Entity__.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
withSourceMapGenerator,
|
|
11
11
|
withGenerator,
|
|
12
12
|
TranslatorGenerator,
|
|
13
|
+
createDecoratorCode,
|
|
13
14
|
} from '../translator';
|
|
14
15
|
import { entity2LogicNamespace } from '../server/entity2LogicNamespace';
|
|
15
16
|
import type CallQueryComponent from './CallQueryComponent__';
|
|
@@ -931,6 +932,34 @@ export class Entity extends BaseNode {
|
|
|
931
932
|
return code;
|
|
932
933
|
}
|
|
933
934
|
|
|
935
|
+
@withSourceMap()
|
|
936
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
937
|
+
let code = '';
|
|
938
|
+
|
|
939
|
+
code += createDecoratorCode(state, this, ['description', 'uuid', 'tableName', 'origin']);
|
|
940
|
+
|
|
941
|
+
code += `entity ${this.name} {\n`;
|
|
942
|
+
// code += `${indent(state.tabSize + 1)}__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
943
|
+
this.properties.forEach((property) => {
|
|
944
|
+
code += `${property.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 }))};\n`;
|
|
945
|
+
});
|
|
946
|
+
// if (this.indexes && this.indexes.length) {
|
|
947
|
+
// code += indent(state.tabSize + 1);
|
|
948
|
+
// code += `__IndexList() {\n`;
|
|
949
|
+
// code += ` return [`;
|
|
950
|
+
// this.indexes.forEach((entityIndex) => {
|
|
951
|
+
// code += indent(state.tabSize + 1);
|
|
952
|
+
// code += '\n ';
|
|
953
|
+
// code += runSync(entityIndex.toEmbeddedTS(shiftState(state, code, { inline: true })));
|
|
954
|
+
// });
|
|
955
|
+
// code += `${indent(state.tabSize)}\n ];\n }\n`;
|
|
956
|
+
// }
|
|
957
|
+
|
|
958
|
+
code += `${indent(state.tabSize)}}\n`;
|
|
959
|
+
|
|
960
|
+
return code;
|
|
961
|
+
}
|
|
962
|
+
|
|
934
963
|
getNamespace() {
|
|
935
964
|
if (this.parentNode && (this.parentNode as DataSource).getNamespace)
|
|
936
965
|
return `${(this.parentNode as DataSource).getNamespace()}.${this.parentNode.name}.entities`;
|
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
withSourceMapGenerator,
|
|
7
7
|
withGenerator,
|
|
8
8
|
TranslatorGenerator,
|
|
9
|
+
indent,
|
|
10
|
+
createDecoratorCode,
|
|
11
|
+
shiftState,
|
|
9
12
|
} from '../translator';
|
|
10
13
|
//================================================================================
|
|
11
14
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -141,6 +144,20 @@ export class EnumItem extends BaseNode {
|
|
|
141
144
|
return `'${this.value}' = '${this.label}'`;
|
|
142
145
|
}
|
|
143
146
|
|
|
147
|
+
@withSourceMap()
|
|
148
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
149
|
+
let code = '';
|
|
150
|
+
|
|
151
|
+
const index = (this.parentNode as Enum)?.enumItems.indexOf(this);
|
|
152
|
+
if (index > 0) code += `\n${indent(state.tabSize)}`;
|
|
153
|
+
|
|
154
|
+
code += createDecoratorCode(state, this, ['label']);
|
|
155
|
+
|
|
156
|
+
code += `${this.value}`;
|
|
157
|
+
|
|
158
|
+
return code;
|
|
159
|
+
}
|
|
160
|
+
|
|
144
161
|
setName(value: string) {
|
|
145
162
|
this.setValue(value);
|
|
146
163
|
}
|
package/src/concepts/Enum__.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
withSourceMapGenerator,
|
|
10
10
|
withGenerator,
|
|
11
11
|
TranslatorGenerator,
|
|
12
|
+
createDecoratorCode,
|
|
12
13
|
} from '../translator';
|
|
13
14
|
import type Namespace from './Namespace__';
|
|
14
15
|
import type Identifier from './Identifier__';
|
|
@@ -343,9 +344,9 @@ export class Enum extends BaseNode {
|
|
|
343
344
|
@withSourceMap()
|
|
344
345
|
toNaturalTS(state = createCompilerState()): string {
|
|
345
346
|
let code = `enum ${this.name} {\n`;
|
|
346
|
-
this.enumItems.forEach((
|
|
347
|
+
this.enumItems.forEach((item) => {
|
|
347
348
|
code += indent(state.tabSize + 1);
|
|
348
|
-
code +=
|
|
349
|
+
code += item.toNaturalTS(shiftState(state, code, { tabSize: 0 }));
|
|
349
350
|
code += ',\n';
|
|
350
351
|
});
|
|
351
352
|
code += `${indent(state?.tabSize || 0)}}\n`;
|
|
@@ -353,6 +354,22 @@ export class Enum extends BaseNode {
|
|
|
353
354
|
return code;
|
|
354
355
|
}
|
|
355
356
|
|
|
357
|
+
@withSourceMap()
|
|
358
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
359
|
+
let code = '';
|
|
360
|
+
|
|
361
|
+
code += createDecoratorCode(state, this, ['label', 'description']);
|
|
362
|
+
|
|
363
|
+
code += `enum ${this.name} {\n`;
|
|
364
|
+
this.enumItems.forEach((item) => {
|
|
365
|
+
code += item.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
366
|
+
code += '\n';
|
|
367
|
+
});
|
|
368
|
+
code += `${indent(state?.tabSize || 0)}}\n`;
|
|
369
|
+
|
|
370
|
+
return code;
|
|
371
|
+
}
|
|
372
|
+
|
|
356
373
|
getNamespace() {
|
|
357
374
|
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
358
375
|
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
package/src/concepts/Event__.ts
CHANGED
|
@@ -133,6 +133,19 @@ export class Event extends BaseNode {
|
|
|
133
133
|
}
|
|
134
134
|
return params;
|
|
135
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* 设置组件事件名称
|
|
138
|
+
*/
|
|
139
|
+
setName(name: string) {
|
|
140
|
+
const object = {
|
|
141
|
+
name,
|
|
142
|
+
};
|
|
143
|
+
this.update({
|
|
144
|
+
...object,
|
|
145
|
+
field: 'name',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
136
149
|
/**
|
|
137
150
|
* 设置组件事件描述
|
|
138
151
|
*/
|
|
@@ -595,47 +595,37 @@ export class ForEachStatement extends LogicItem {
|
|
|
595
595
|
yield* wrapForEach(self.body, function* warpForEachGenerator(logicItem) {
|
|
596
596
|
code += `${yield* logicItem.toEmbeddedTS(
|
|
597
597
|
shiftState(state, code, {
|
|
598
|
-
tabSize:
|
|
598
|
+
tabSize: state.tabSize + 1,
|
|
599
599
|
}),
|
|
600
600
|
)};\n`;
|
|
601
601
|
});
|
|
602
602
|
}
|
|
603
|
-
code += `${indent(state
|
|
603
|
+
code += `${indent(state.tabSize)}})\n`;
|
|
604
604
|
return code;
|
|
605
605
|
}
|
|
606
606
|
|
|
607
607
|
@withSourceMap()
|
|
608
608
|
toNaturalTS(state = createCompilerState()): string {
|
|
609
609
|
let code = 'ForEach(';
|
|
610
|
-
code += this.each
|
|
611
|
-
? this.each?.toNaturalTS(
|
|
612
|
-
shiftState(state, code, {
|
|
613
|
-
tabSize: 0,
|
|
614
|
-
}),
|
|
615
|
-
)
|
|
616
|
-
: '__IDENTIFIER__';
|
|
610
|
+
code += this.each?.toNaturalTS(shiftState(state, code, { tabSize: 0 })) || '__IDENTIFIER__';
|
|
617
611
|
code += ', ';
|
|
618
|
-
code += this.start
|
|
612
|
+
code += this.start?.toNaturalTS(shiftState(state, code, { tabSize: 0 })) || '__IDENTIFIER__';
|
|
619
613
|
code += ', ';
|
|
620
|
-
code += this.end
|
|
614
|
+
code += this.end?.toNaturalTS(shiftState(state, code, { tabSize: 0 })) || '__IDENTIFIER__';
|
|
621
615
|
code += ', (';
|
|
622
|
-
code += this.item
|
|
616
|
+
code += this.item?.toNaturalTS(shiftState(state, code, { tabSize: 0 }), true) || '__IDENTIFIER__';
|
|
623
617
|
code += ', ';
|
|
624
|
-
code += this.index
|
|
625
|
-
code += ') => {\n
|
|
618
|
+
code += this.index?.toNaturalTS(shiftState(state, code, { tabSize: 0 }), true) || '__IDENTIFIER__';
|
|
619
|
+
code += ') => {\n';
|
|
626
620
|
|
|
627
621
|
if (Array.isArray(this.body)) {
|
|
628
622
|
this.body.forEach((logicItem) => {
|
|
629
|
-
code += `${logicItem?.toNaturalTS(
|
|
630
|
-
shiftState(state, code, {
|
|
631
|
-
tabSize: (state?.tabSize || 0) + 1,
|
|
632
|
-
}),
|
|
633
|
-
)};\n`;
|
|
623
|
+
code += `${logicItem?.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }))};\n`;
|
|
634
624
|
});
|
|
635
625
|
if (state?.focusedNodePath === `${this?.nodePath}.body[${this.body?.length}]`)
|
|
636
626
|
code += `${indent((state?.tabSize || 0) + 1)}// 当前位置\n`;
|
|
637
627
|
}
|
|
638
|
-
code += `${indent(state
|
|
628
|
+
code += `${indent(state.tabSize)}})\n`;
|
|
639
629
|
|
|
640
630
|
return code;
|
|
641
631
|
}
|
|
@@ -769,6 +769,7 @@ export class FrontendType extends BaseNode {
|
|
|
769
769
|
let code = `export namespace ${self.name} {\n`;
|
|
770
770
|
code += 'const name = ';
|
|
771
771
|
code += `"${self.name}";\n`;
|
|
772
|
+
code += 'export namespace businessComponents { }\n';
|
|
772
773
|
code += '}\n';
|
|
773
774
|
return code;
|
|
774
775
|
}
|