@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.
Files changed (289) hide show
  1. package/out/breakpoint/store/core.js +1 -1
  2. package/out/breakpoint/store/core.js.map +1 -1
  3. package/out/common/BaseNode.d.ts +7 -0
  4. package/out/common/BaseNode.js +15 -2
  5. package/out/common/BaseNode.js.map +1 -1
  6. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  7. package/out/concepts/AnonymousFunction__.js +34 -16
  8. package/out/concepts/AnonymousFunction__.js.map +1 -1
  9. package/out/concepts/Argument__.d.ts +1 -0
  10. package/out/concepts/Argument__.js +28 -8
  11. package/out/concepts/Argument__.js.map +1 -1
  12. package/out/concepts/Assignment__.js +5 -7
  13. package/out/concepts/Assignment__.js.map +1 -1
  14. package/out/concepts/BatchAssignment__.js +5 -3
  15. package/out/concepts/BatchAssignment__.js.map +1 -1
  16. package/out/concepts/BinaryExpression__.d.ts +1 -0
  17. package/out/concepts/BinaryExpression__.js +30 -13
  18. package/out/concepts/BinaryExpression__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.js +11 -3
  20. package/out/concepts/BindAttribute__.js.map +1 -1
  21. package/out/concepts/BindDirective__.js +3 -3
  22. package/out/concepts/BindDirective__.js.map +1 -1
  23. package/out/concepts/BindEvent__.js +2 -2
  24. package/out/concepts/BindEvent__.js.map +1 -1
  25. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  26. package/out/concepts/BooleanLiteral__.js +6 -0
  27. package/out/concepts/BooleanLiteral__.js.map +1 -1
  28. package/out/concepts/BusinessComponent__.d.ts +4 -2
  29. package/out/concepts/BusinessComponent__.js +128 -89
  30. package/out/concepts/BusinessComponent__.js.map +1 -1
  31. package/out/concepts/CallConnector__.d.ts +1 -0
  32. package/out/concepts/CallConnector__.js +6 -0
  33. package/out/concepts/CallConnector__.js.map +1 -1
  34. package/out/concepts/CallEvent__.d.ts +4 -0
  35. package/out/concepts/CallEvent__.js +19 -2
  36. package/out/concepts/CallEvent__.js.map +1 -1
  37. package/out/concepts/CallFunction__.d.ts +1 -0
  38. package/out/concepts/CallFunction__.js +62 -8
  39. package/out/concepts/CallFunction__.js.map +1 -1
  40. package/out/concepts/CallInterface__.js +31 -22
  41. package/out/concepts/CallInterface__.js.map +1 -1
  42. package/out/concepts/CallLogic__.js +49 -38
  43. package/out/concepts/CallLogic__.js.map +1 -1
  44. package/out/concepts/CallQueryComponent__.d.ts +2 -0
  45. package/out/concepts/CallQueryComponent__.js +94 -8
  46. package/out/concepts/CallQueryComponent__.js.map +1 -1
  47. package/out/concepts/DefaultValue__.d.ts +1 -0
  48. package/out/concepts/DefaultValue__.js +7 -1
  49. package/out/concepts/DefaultValue__.js.map +1 -1
  50. package/out/concepts/Destination__.d.ts +1 -1
  51. package/out/concepts/Destination__.js +34 -22
  52. package/out/concepts/Destination__.js.map +1 -1
  53. package/out/concepts/EntityProperty__.d.ts +1 -0
  54. package/out/concepts/EntityProperty__.js +26 -2
  55. package/out/concepts/EntityProperty__.js.map +1 -1
  56. package/out/concepts/Entity__.d.ts +1 -0
  57. package/out/concepts/Entity__.js +25 -0
  58. package/out/concepts/Entity__.js.map +1 -1
  59. package/out/concepts/EnumItem__.d.ts +1 -0
  60. package/out/concepts/EnumItem__.js +12 -0
  61. package/out/concepts/EnumItem__.js.map +1 -1
  62. package/out/concepts/Enum__.d.ts +1 -0
  63. package/out/concepts/Enum__.js +16 -2
  64. package/out/concepts/Enum__.js.map +1 -1
  65. package/out/concepts/Event__.d.ts +4 -0
  66. package/out/concepts/Event__.js +12 -0
  67. package/out/concepts/Event__.js.map +1 -1
  68. package/out/concepts/ForEachStatement__.js +10 -16
  69. package/out/concepts/ForEachStatement__.js.map +1 -1
  70. package/out/concepts/FrontendType__.js +1 -0
  71. package/out/concepts/FrontendType__.js.map +1 -1
  72. package/out/concepts/Identifier__.d.ts +2 -0
  73. package/out/concepts/Identifier__.js +21 -0
  74. package/out/concepts/Identifier__.js.map +1 -1
  75. package/out/concepts/JSBlock__.js +1 -1
  76. package/out/concepts/JSBlock__.js.map +1 -1
  77. package/out/concepts/LogicItem__.d.ts +6 -0
  78. package/out/concepts/LogicItem__.js +11 -1
  79. package/out/concepts/LogicItem__.js.map +1 -1
  80. package/out/concepts/Logic__.js +24 -23
  81. package/out/concepts/Logic__.js.map +1 -1
  82. package/out/concepts/MatchCase__.js +5 -5
  83. package/out/concepts/MatchCase__.js.map +1 -1
  84. package/out/concepts/Match__.js +1 -1
  85. package/out/concepts/Match__.js.map +1 -1
  86. package/out/concepts/MemberExpression__.d.ts +1 -0
  87. package/out/concepts/MemberExpression__.js +13 -3
  88. package/out/concepts/MemberExpression__.js.map +1 -1
  89. package/out/concepts/NewComposite__.js +3 -3
  90. package/out/concepts/NewComposite__.js.map +1 -1
  91. package/out/concepts/NewList__.js +4 -4
  92. package/out/concepts/NewList__.js.map +1 -1
  93. package/out/concepts/NewMap__.d.ts +1 -1
  94. package/out/concepts/NewMap__.js +6 -5
  95. package/out/concepts/NewMap__.js.map +1 -1
  96. package/out/concepts/NullLiteral__.d.ts +2 -0
  97. package/out/concepts/NullLiteral__.js +12 -0
  98. package/out/concepts/NullLiteral__.js.map +1 -1
  99. package/out/concepts/NumericLiteral__.d.ts +1 -0
  100. package/out/concepts/NumericLiteral__.js +7 -1
  101. package/out/concepts/NumericLiteral__.js.map +1 -1
  102. package/out/concepts/OqlQueryComponent__.js +4 -2
  103. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  104. package/out/concepts/Param__.d.ts +1 -0
  105. package/out/concepts/Param__.js +41 -0
  106. package/out/concepts/Param__.js.map +1 -1
  107. package/out/concepts/ProcessElement__.js +9 -1
  108. package/out/concepts/ProcessElement__.js.map +1 -1
  109. package/out/concepts/QueryAggregateExpression__.d.ts +2 -0
  110. package/out/concepts/QueryAggregateExpression__.js +16 -0
  111. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  112. package/out/concepts/QueryFieldExpression__.d.ts +2 -0
  113. package/out/concepts/QueryFieldExpression__.js +33 -0
  114. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  115. package/out/concepts/QueryFromExpression__.d.ts +2 -0
  116. package/out/concepts/QueryFromExpression__.js +27 -0
  117. package/out/concepts/QueryFromExpression__.js.map +1 -1
  118. package/out/concepts/QueryGroupByExpression__.d.ts +2 -0
  119. package/out/concepts/QueryGroupByExpression__.js +13 -1
  120. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  121. package/out/concepts/QueryJoinExpression__.d.ts +2 -0
  122. package/out/concepts/QueryJoinExpression__.js +37 -0
  123. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  124. package/out/concepts/QueryLimitExpression__.d.ts +2 -0
  125. package/out/concepts/QueryLimitExpression__.js +16 -0
  126. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  127. package/out/concepts/QueryOrderByExpression__.d.ts +2 -0
  128. package/out/concepts/QueryOrderByExpression__.js +22 -0
  129. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  130. package/out/concepts/QuerySelectExpression__.d.ts +3 -0
  131. package/out/concepts/QuerySelectExpression__.js +41 -0
  132. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  133. package/out/concepts/SelectMembers__.d.ts +1 -0
  134. package/out/concepts/SelectMembers__.js +7 -0
  135. package/out/concepts/SelectMembers__.js.map +1 -1
  136. package/out/concepts/SqlQueryComponent__.js +4 -2
  137. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  138. package/out/concepts/StringInterpolation__.d.ts +1 -0
  139. package/out/concepts/StringInterpolation__.js +20 -2
  140. package/out/concepts/StringInterpolation__.js.map +1 -1
  141. package/out/concepts/StringLiteral__.d.ts +1 -0
  142. package/out/concepts/StringLiteral__.js +21 -1
  143. package/out/concepts/StringLiteral__.js.map +1 -1
  144. package/out/concepts/StructureProperty__.d.ts +1 -0
  145. package/out/concepts/StructureProperty__.js +19 -0
  146. package/out/concepts/StructureProperty__.js.map +1 -1
  147. package/out/concepts/Structure__.d.ts +1 -0
  148. package/out/concepts/Structure__.js +22 -7
  149. package/out/concepts/Structure__.js.map +1 -1
  150. package/out/concepts/SwitchCase__.js +1 -1
  151. package/out/concepts/SwitchCase__.js.map +1 -1
  152. package/out/concepts/TypeAnnotation__.d.ts +1 -0
  153. package/out/concepts/TypeAnnotation__.js +42 -1
  154. package/out/concepts/TypeAnnotation__.js.map +1 -1
  155. package/out/concepts/TypeParam__.d.ts +2 -1
  156. package/out/concepts/TypeParam__.js +7 -1
  157. package/out/concepts/TypeParam__.js.map +1 -1
  158. package/out/concepts/Unparsed__.js +1 -1
  159. package/out/concepts/Unparsed__.js.map +1 -1
  160. package/out/concepts/ValidationRule__.js +2 -1
  161. package/out/concepts/ValidationRule__.js.map +1 -1
  162. package/out/concepts/ViewElement__.d.ts +1 -0
  163. package/out/concepts/ViewElement__.js +72 -59
  164. package/out/concepts/ViewElement__.js.map +1 -1
  165. package/out/concepts/View__.d.ts +2 -1
  166. package/out/concepts/View__.js +6 -19
  167. package/out/concepts/View__.js.map +1 -1
  168. package/out/generator/genBundleFiles.d.ts +1 -0
  169. package/out/generator/genBundleFiles.js +4 -1
  170. package/out/generator/genBundleFiles.js.map +1 -1
  171. package/out/natural/genNaturalTS.d.ts +4 -1
  172. package/out/natural/genNaturalTS.js +38 -1
  173. package/out/natural/genNaturalTS.js.map +1 -1
  174. package/out/natural/transformTSCode.js +52 -41
  175. package/out/natural/transformTSCode.js.map +1 -1
  176. package/out/server/formatTsUtils.js +10 -9
  177. package/out/server/formatTsUtils.js.map +1 -1
  178. package/out/server/getFunctions.js +3 -3
  179. package/out/server/getFunctions.js.map +1 -1
  180. package/out/server/getProcesses.js +3 -3
  181. package/out/server/getProcesses.js.map +1 -1
  182. package/out/server/naslServer.js +52 -17
  183. package/out/server/naslServer.js.map +1 -1
  184. package/out/server/translator.js +8 -0
  185. package/out/server/translator.js.map +1 -1
  186. package/out/templator/genCurdEditMultipleKeyBlock.js +1 -1
  187. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  188. package/out/templator/genGetBlock.js +2 -1
  189. package/out/templator/genGetBlock.js.map +1 -1
  190. package/out/templator/genUpdateBlock.js +2 -1
  191. package/out/templator/genUpdateBlock.js.map +1 -1
  192. package/out/templator/utils.js +3 -3
  193. package/out/templator/utils.js.map +1 -1
  194. package/out/translator/types.d.ts +2 -0
  195. package/out/translator/utils.d.ts +2 -1
  196. package/out/translator/utils.js +44 -7
  197. package/out/translator/utils.js.map +1 -1
  198. package/out/utils/string.js +2 -2
  199. package/out/utils/string.js.map +1 -1
  200. package/out/utils/time-slicing/performance.js +3 -3
  201. package/out/utils/time-slicing/performance.js.map +1 -1
  202. package/package.json +2 -2
  203. package/src/breakpoint/store/core.ts +1 -1
  204. package/src/common/BaseNode.ts +17 -3
  205. package/src/concepts/AnonymousFunction__.ts +24 -9
  206. package/src/concepts/Argument__.ts +28 -6
  207. package/src/concepts/Assignment__.ts +5 -7
  208. package/src/concepts/BatchAssignment__.ts +6 -3
  209. package/src/concepts/BinaryExpression__.ts +30 -13
  210. package/src/concepts/BindAttribute__.ts +10 -3
  211. package/src/concepts/BindDirective__.ts +3 -3
  212. package/src/concepts/BindEvent__.ts +2 -2
  213. package/src/concepts/BooleanLiteral__.ts +5 -0
  214. package/src/concepts/BusinessComponent__.ts +144 -100
  215. package/src/concepts/CallConnector__.ts +5 -0
  216. package/src/concepts/CallEvent__.ts +20 -3
  217. package/src/concepts/CallFunction__.ts +54 -8
  218. package/src/concepts/CallInterface__.ts +31 -24
  219. package/src/concepts/CallLogic__.ts +48 -37
  220. package/src/concepts/CallQueryComponent__.ts +101 -8
  221. package/src/concepts/DefaultValue__.ts +6 -1
  222. package/src/concepts/Destination__.ts +32 -22
  223. package/src/concepts/EntityProperty__.ts +30 -2
  224. package/src/concepts/Entity__.ts +29 -0
  225. package/src/concepts/EnumItem__.ts +17 -0
  226. package/src/concepts/Enum__.ts +19 -2
  227. package/src/concepts/Event__.ts +13 -0
  228. package/src/concepts/ForEachStatement__.ts +10 -20
  229. package/src/concepts/FrontendType__.ts +1 -0
  230. package/src/concepts/Identifier__.ts +19 -0
  231. package/src/concepts/JSBlock__.ts +1 -1
  232. package/src/concepts/LogicItem__.ts +13 -1
  233. package/src/concepts/Logic__.ts +24 -24
  234. package/src/concepts/MatchCase__.ts +5 -5
  235. package/src/concepts/Match__.ts +1 -1
  236. package/src/concepts/MemberExpression__.ts +12 -3
  237. package/src/concepts/NewComposite__.ts +7 -9
  238. package/src/concepts/NewList__.ts +4 -4
  239. package/src/concepts/NewMap__.ts +6 -5
  240. package/src/concepts/NullLiteral__.ts +10 -0
  241. package/src/concepts/NumericLiteral__.ts +6 -1
  242. package/src/concepts/OqlQueryComponent__.ts +4 -2
  243. package/src/concepts/Param__.ts +39 -0
  244. package/src/concepts/ProcessElement__.ts +8 -1
  245. package/src/concepts/QueryAggregateExpression__.ts +15 -0
  246. package/src/concepts/QueryFieldExpression__.ts +34 -0
  247. package/src/concepts/QueryFromExpression__.ts +29 -0
  248. package/src/concepts/QueryGroupByExpression__.ts +11 -1
  249. package/src/concepts/QueryJoinExpression__.ts +39 -0
  250. package/src/concepts/QueryLimitExpression__.ts +14 -0
  251. package/src/concepts/QueryOrderByExpression__.ts +23 -0
  252. package/src/concepts/QuerySelectExpression__.ts +55 -0
  253. package/src/concepts/SelectMembers__.ts +7 -0
  254. package/src/concepts/SqlQueryComponent__.ts +4 -2
  255. package/src/concepts/StringInterpolation__.ts +18 -2
  256. package/src/concepts/StringLiteral__.ts +20 -1
  257. package/src/concepts/StructureProperty__.ts +22 -0
  258. package/src/concepts/Structure__.ts +24 -7
  259. package/src/concepts/SwitchCase__.ts +1 -1
  260. package/src/concepts/TypeAnnotation__.ts +37 -1
  261. package/src/concepts/TypeParam__.ts +6 -1
  262. package/src/concepts/Unparsed__.ts +1 -1
  263. package/src/concepts/ValidationRule__.ts +6 -1
  264. package/src/concepts/ViewElement__.ts +74 -58
  265. package/src/concepts/View__.ts +6 -19
  266. package/src/generator/genBundleFiles.ts +6 -1
  267. package/src/natural/genNaturalTS.ts +41 -0
  268. package/src/natural/transformTSCode.ts +50 -42
  269. package/src/server/formatTsUtils.ts +16 -11
  270. package/src/server/getFunctions.ts +3 -3
  271. package/src/server/getProcesses.ts +3 -3
  272. package/src/server/naslServer.ts +56 -18
  273. package/src/server/translator.ts +7 -0
  274. package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -1
  275. package/src/templator/genGetBlock.ts +2 -1
  276. package/src/templator/genUpdateBlock.ts +2 -1
  277. package/src/templator/utils.ts +3 -3
  278. package/src/translator/types.ts +4 -0
  279. package/src/translator/utils.ts +73 -34
  280. package/src/utils/string.ts +2 -2
  281. package/src/utils/time-slicing/performance.ts +3 -3
  282. package/test/concepts/call-interface/__snapshots__/getQuickInfoOffset.spec.ts.snap +3 -3
  283. package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
  284. package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +199 -0
  285. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +127 -6
  286. package/test/concepts/view-element/fixtures/table-data-source-calllogic-with-server-validation.json +2074 -0
  287. package/test/concepts/view-element/toVue.spec.ts +0 -1
  288. package/ts-worker/package.json +1 -1
  289. 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 += 'this.';
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(code))
1394
- calleeKey = calleeKey.replace(/^app.+?\.entities\.(.+?)\.logics/, '$1');
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
- code += arg.toNaturalTS(shiftState(state, code, { tabSize: 0 }), paramRequired);
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
- code += arg.toNaturalTS(shiftState(state, code, { tabSize: 0 }), arg?.paramRequired);
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
- code += '(() =>{\nconst wrapper = ';
1466
+ // if (useIife) {
1467
+ // code += '(() =>{\nconst wrapper = ';
1460
1468
 
1461
- if (handleError) {
1462
- code += 'nasl.util.autoHandleError(';
1463
- }
1469
+ // if (handleError) {
1470
+ // code += 'nasl.util.autoHandleError(';
1471
+ // }
1464
1472
 
1465
- if (useValidation) {
1466
- code += 'nasl.util.callLogicWithChecker(';
1467
- }
1473
+ // if (useValidation) {
1474
+ // code += 'nasl.util.callLogicWithChecker(';
1475
+ // }
1468
1476
 
1469
- code += calleeKey;
1470
- setTypeArguments();
1477
+ // code += calleeKey;
1478
+ // setTypeArguments();
1471
1479
 
1472
- if (useValidation) {
1473
- code += ', (';
1474
- code += completeArguments.map((item) => item.keyword).join(', ');
1475
- code += ') => {\n';
1476
- code += validation.toNaturalTS(shiftState(state, code));
1477
- code += ';\n})';
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
- if (handleError) {
1481
- code += ')';
1482
- }
1488
+ // if (handleError) {
1489
+ // code += ')';
1490
+ // }
1483
1491
 
1484
- code += ';\nreturn wrapper';
1485
- setInputParam();
1486
- code += ';\n})()';
1487
- } else {
1488
- code += calleeKey;
1489
- setTypeArguments();
1490
- setInputParam();
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].findIndex((el) => (el.__v_raw || el) === n);
954
- ~index && (this as any)[parentKey].splice(index, 1);
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.__v_raw || q) === n) {
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.findNodeByCompleteName(entityNamespace);
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.find((item: any) => item.name === propertyName);
1365
- const propertyTypeAnnotation = property.typeAnnotation;
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.__v_raw || q) === n) {
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(), prependCode: string): TranslatorGenerator {
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 += prependCode;
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
- const oldName = argument.keyword;
791
- if (index >= logicParamLength) {
792
- argument.keyword = '__unknown__';
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
- code += `${this.tsCalleeNamespace}.${this.tsName}.$destination({`;
807
- if (Array.isArray(this.arguments)) {
808
- this.arguments.slice(0, logicParamLength).forEach((argument: Argument, index) => {
809
- const oldName = argument.keyword;
810
- if (index >= logicParamLength) {
811
- argument.keyword = '__unknown__';
812
- }
813
- code += `${argument.toNaturalTS(shiftState(state, code, { inline: true }), false, true)}, `;
814
- argument.keyword = oldName;
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 += `, target: '${this.target}'`;
828
+ // code += this.anchor?.toNaturalTS(shiftState(state, code, { inline: true }), true) || '';
829
+ // code += `, '${this.target}'`;
820
830
 
821
- code += `});\n`;
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.forEach((val: any) => {
550
+ refs?.forEach((val: any) => {
550
551
  const loopFindNode = (item: any) => {
551
552
  if (item.children) {
552
- item.children.forEach((i: any) => loopFindNode(i));
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 类型标注对象
@@ -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
  }
@@ -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((property) => {
347
+ this.enumItems.forEach((item) => {
347
348
  code += indent(state.tabSize + 1);
348
- code += property.toNaturalTS(shiftState(state, code, { tabSize: 0 }));
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();
@@ -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: (state?.tabSize || 0) + 1,
598
+ tabSize: state.tabSize + 1,
599
599
  }),
600
600
  )};\n`;
601
601
  });
602
602
  }
603
- code += `${indent(state?.tabSize || 0)}})\n`;
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 ? this.start?.toNaturalTS(shiftState(state, code, { tabSize: 0 })) : '__IDENTIFIER__';
612
+ code += this.start?.toNaturalTS(shiftState(state, code, { tabSize: 0 })) || '__IDENTIFIER__';
619
613
  code += ', ';
620
- code += this.end ? this.end?.toNaturalTS(shiftState(state, code, { tabSize: 0 })) : '__IDENTIFIER__';
614
+ code += this.end?.toNaturalTS(shiftState(state, code, { tabSize: 0 })) || '__IDENTIFIER__';
621
615
  code += ', (';
622
- code += this.item ? this.item?.toNaturalTS(shiftState(state, code, { tabSize: 0 }), true) : '__IDENTIFIER__';
616
+ code += this.item?.toNaturalTS(shiftState(state, code, { tabSize: 0 }), true) || '__IDENTIFIER__';
623
617
  code += ', ';
624
- code += this.index ? this.index?.toNaturalTS(shiftState(state, code, { tabSize: 0 }), true) : '__IDENTIFIER__';
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?.tabSize || 0)}})\n`;
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
  }