@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.
Files changed (355) hide show
  1. package/out/automate/engine/index.js +11 -0
  2. package/out/automate/engine/index.js.map +1 -1
  3. package/out/automate/engine/uniqueName.js +1 -1
  4. package/out/automate/engine/uniqueName.js.map +1 -1
  5. package/out/automate/engine/utils.d.ts +1 -0
  6. package/out/automate/engine/utils.js +89 -67
  7. package/out/automate/engine/utils.js.map +1 -1
  8. package/out/concepts/App__.d.ts +51 -49
  9. package/out/concepts/App__.js +86 -54
  10. package/out/concepts/App__.js.map +1 -1
  11. package/out/concepts/Argument__.js +1 -1
  12. package/out/concepts/Argument__.js.map +1 -1
  13. package/out/concepts/Assignee__.js +1 -1
  14. package/out/concepts/Assignee__.js.map +1 -1
  15. package/out/concepts/Assignment__.js +1 -1
  16. package/out/concepts/Assignment__.js.map +1 -1
  17. package/out/concepts/Attribute__.js +1 -1
  18. package/out/concepts/Attribute__.js.map +1 -1
  19. package/out/concepts/BinaryExpression__.js +1 -1
  20. package/out/concepts/BinaryExpression__.js.map +1 -1
  21. package/out/concepts/BindAttribute__.js +3 -3
  22. package/out/concepts/BindAttribute__.js.map +1 -1
  23. package/out/concepts/BindDirective__.js +1 -1
  24. package/out/concepts/BindDirective__.js.map +1 -1
  25. package/out/concepts/BindEvent__.js +11 -6
  26. package/out/concepts/BindEvent__.js.map +1 -1
  27. package/out/concepts/BooleanLiteral__.js +1 -1
  28. package/out/concepts/BooleanLiteral__.js.map +1 -1
  29. package/out/concepts/CallFunction__.js +8 -3
  30. package/out/concepts/CallFunction__.js.map +1 -1
  31. package/out/concepts/CallInterface__.js +1 -1
  32. package/out/concepts/CallInterface__.js.map +1 -1
  33. package/out/concepts/CallLogic__.js +23 -21
  34. package/out/concepts/CallLogic__.js.map +1 -1
  35. package/out/concepts/CallQueryComponent__.d.ts +9 -8
  36. package/out/concepts/CallQueryComponent__.js +89 -79
  37. package/out/concepts/CallQueryComponent__.js.map +1 -1
  38. package/out/concepts/Comment__.js +2 -2
  39. package/out/concepts/Comment__.js.map +1 -1
  40. package/out/concepts/CompletionProperty__.js +1 -1
  41. package/out/concepts/CompletionProperty__.js.map +1 -1
  42. package/out/concepts/ConfigGroup__.d.ts +1 -0
  43. package/out/concepts/ConfigGroup__.js +8 -1
  44. package/out/concepts/ConfigGroup__.js.map +1 -1
  45. package/out/concepts/ConfigPropertyValue__.js +1 -1
  46. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  47. package/out/concepts/ConfigProperty__.d.ts +1 -0
  48. package/out/concepts/ConfigProperty__.js +4 -1
  49. package/out/concepts/ConfigProperty__.js.map +1 -1
  50. package/out/concepts/Configuration__.d.ts +1 -0
  51. package/out/concepts/Configuration__.js +4 -1
  52. package/out/concepts/Configuration__.js.map +1 -1
  53. package/out/concepts/Constant__.js +1 -1
  54. package/out/concepts/Constant__.js.map +1 -1
  55. package/out/concepts/DataElement__.js +1 -1
  56. package/out/concepts/DataElement__.js.map +1 -1
  57. package/out/concepts/DataSource__.d.ts +143 -0
  58. package/out/concepts/DataSource__.js +316 -0
  59. package/out/concepts/DataSource__.js.map +1 -0
  60. package/out/concepts/Destination__.js +8 -8
  61. package/out/concepts/Destination__.js.map +1 -1
  62. package/out/concepts/End__.js +3 -3
  63. package/out/concepts/End__.js.map +1 -1
  64. package/out/concepts/EntityIndex__.d.ts +5 -0
  65. package/out/concepts/EntityIndex__.js +7 -1
  66. package/out/concepts/EntityIndex__.js.map +1 -1
  67. package/out/concepts/EntityProperty__.d.ts +9 -0
  68. package/out/concepts/EntityProperty__.js +20 -3
  69. package/out/concepts/EntityProperty__.js.map +1 -1
  70. package/out/concepts/Entity__.d.ts +5 -0
  71. package/out/concepts/Entity__.js +21 -11
  72. package/out/concepts/Entity__.js.map +1 -1
  73. package/out/concepts/EnumItem__.js +1 -1
  74. package/out/concepts/EnumItem__.js.map +1 -1
  75. package/out/concepts/Enum__.js +11 -5
  76. package/out/concepts/Enum__.js.map +1 -1
  77. package/out/concepts/Event__.js +1 -1
  78. package/out/concepts/Event__.js.map +1 -1
  79. package/out/concepts/ForEachStatement__.js +3 -3
  80. package/out/concepts/ForEachStatement__.js.map +1 -1
  81. package/out/concepts/Function__.d.ts +18 -0
  82. package/out/concepts/Function__.js +96 -1
  83. package/out/concepts/Function__.js.map +1 -1
  84. package/out/concepts/Identifier__.js +3 -13
  85. package/out/concepts/Identifier__.js.map +1 -1
  86. package/out/concepts/IfStatement__.js +9 -9
  87. package/out/concepts/IfStatement__.js.map +1 -1
  88. package/out/concepts/InterfaceParam__.js +1 -1
  89. package/out/concepts/InterfaceParam__.js.map +1 -1
  90. package/out/concepts/Interface__.js +19 -12
  91. package/out/concepts/Interface__.js.map +1 -1
  92. package/out/concepts/JSBlock__.js +1 -1
  93. package/out/concepts/JSBlock__.js.map +1 -1
  94. package/out/concepts/LogicItem__.js +1 -1
  95. package/out/concepts/LogicItem__.js.map +1 -1
  96. package/out/concepts/Logic__.js +41 -42
  97. package/out/concepts/Logic__.js.map +1 -1
  98. package/out/concepts/MemberExpression__.js +1 -1
  99. package/out/concepts/MemberExpression__.js.map +1 -1
  100. package/out/concepts/Module__.d.ts +1 -85
  101. package/out/concepts/Module__.js +6 -107
  102. package/out/concepts/Module__.js.map +1 -1
  103. package/out/concepts/Namespace__.d.ts +0 -86
  104. package/out/concepts/Namespace__.js +1 -108
  105. package/out/concepts/Namespace__.js.map +1 -1
  106. package/out/concepts/NullLiteral__.js +1 -1
  107. package/out/concepts/NullLiteral__.js.map +1 -1
  108. package/out/concepts/NumericLiteral__.js +1 -1
  109. package/out/concepts/NumericLiteral__.js.map +1 -1
  110. package/out/concepts/Param__.d.ts +2 -1
  111. package/out/concepts/Param__.js +1 -1
  112. package/out/concepts/Param__.js.map +1 -1
  113. package/out/concepts/Point__.js +1 -1
  114. package/out/concepts/Point__.js.map +1 -1
  115. package/out/concepts/ProcessComponent__.js +1 -1
  116. package/out/concepts/ProcessComponent__.js.map +1 -1
  117. package/out/concepts/ProcessElement__.js +26 -11
  118. package/out/concepts/ProcessElement__.js.map +1 -1
  119. package/out/concepts/ProcessOutcome__.js +1 -1
  120. package/out/concepts/ProcessOutcome__.js.map +1 -1
  121. package/out/concepts/Process__.js +17 -10
  122. package/out/concepts/Process__.js.map +1 -1
  123. package/out/concepts/QueryAggregateExpression__.js +1 -1
  124. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  125. package/out/concepts/QueryFieldExpression__.js +9 -2
  126. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  127. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  128. package/out/concepts/QueryFromExpression__.js +14 -3
  129. package/out/concepts/QueryFromExpression__.js.map +1 -1
  130. package/out/concepts/QueryGroupByExpression__.js +1 -1
  131. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  132. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  133. package/out/concepts/QueryJoinExpression__.js +15 -4
  134. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  135. package/out/concepts/QueryLimitExpression__.js +1 -1
  136. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  137. package/out/concepts/QueryOrderByExpression__.js +1 -1
  138. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  139. package/out/concepts/QuerySelectExpression__.js +1 -1
  140. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  141. package/out/concepts/Rect__.js +1 -1
  142. package/out/concepts/Rect__.js.map +1 -1
  143. package/out/concepts/Return__.js +1 -1
  144. package/out/concepts/Return__.js.map +1 -1
  145. package/out/concepts/Role__.js +11 -4
  146. package/out/concepts/Role__.js.map +1 -1
  147. package/out/concepts/Slot__.js +1 -1
  148. package/out/concepts/Slot__.js.map +1 -1
  149. package/out/concepts/SqlQueryComponent__.d.ts +10 -0
  150. package/out/concepts/SqlQueryComponent__.js +32 -5
  151. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  152. package/out/concepts/Start__.js +1 -1
  153. package/out/concepts/Start__.js.map +1 -1
  154. package/out/concepts/StringLiteral__.js +1 -1
  155. package/out/concepts/StringLiteral__.js.map +1 -1
  156. package/out/concepts/StructureProperty__.js +1 -1
  157. package/out/concepts/StructureProperty__.js.map +1 -1
  158. package/out/concepts/Structure__.js +20 -13
  159. package/out/concepts/Structure__.js.map +1 -1
  160. package/out/concepts/SwitchCase__.js +6 -6
  161. package/out/concepts/SwitchCase__.js.map +1 -1
  162. package/out/concepts/SwitchStatement__.js +1 -1
  163. package/out/concepts/SwitchStatement__.js.map +1 -1
  164. package/out/concepts/Theme__.js +1 -1
  165. package/out/concepts/Theme__.js.map +1 -1
  166. package/out/concepts/Transactional__.js +1 -1
  167. package/out/concepts/Transactional__.js.map +1 -1
  168. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  169. package/out/concepts/TypeAnnotation__.js +46 -4
  170. package/out/concepts/TypeAnnotation__.js.map +1 -1
  171. package/out/concepts/TypeParam__.js +1 -1
  172. package/out/concepts/TypeParam__.js.map +1 -1
  173. package/out/concepts/UnaryExpression__.js +1 -1
  174. package/out/concepts/UnaryExpression__.js.map +1 -1
  175. package/out/concepts/Unparsed__.js +1 -1
  176. package/out/concepts/Unparsed__.js.map +1 -1
  177. package/out/concepts/UseComponent__.js +1 -1
  178. package/out/concepts/UseComponent__.js.map +1 -1
  179. package/out/concepts/ValidationRule__.js +1 -1
  180. package/out/concepts/ValidationRule__.js.map +1 -1
  181. package/out/concepts/Variable__.js +1 -1
  182. package/out/concepts/Variable__.js.map +1 -1
  183. package/out/concepts/ViewComponent__.js +1 -1
  184. package/out/concepts/ViewComponent__.js.map +1 -1
  185. package/out/concepts/ViewElement__.js +18 -18
  186. package/out/concepts/ViewElement__.js.map +1 -1
  187. package/out/concepts/View__.js +25 -23
  188. package/out/concepts/View__.js.map +1 -1
  189. package/out/concepts/WhileStatement__.js +5 -5
  190. package/out/concepts/WhileStatement__.js.map +1 -1
  191. package/out/concepts/basics/stdlib/nasl.util.js +278 -0
  192. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  193. package/out/concepts/index__.d.ts +1 -0
  194. package/out/concepts/index__.js +1 -0
  195. package/out/concepts/index__.js.map +1 -1
  196. package/out/generator/genBundleFiles.js +8 -3
  197. package/out/generator/genBundleFiles.js.map +1 -1
  198. package/out/generator/genMetaData.js +13 -12
  199. package/out/generator/genMetaData.js.map +1 -1
  200. package/out/server/createUiTs.js +1 -0
  201. package/out/server/createUiTs.js.map +1 -1
  202. package/out/server/getLogics.js +9 -1
  203. package/out/server/getLogics.js.map +1 -1
  204. package/out/server/getProcesses.d.ts +3 -0
  205. package/out/server/getProcesses.js +61 -1
  206. package/out/server/getProcesses.js.map +1 -1
  207. package/out/server/naslServer.js +128 -6
  208. package/out/server/naslServer.js.map +1 -1
  209. package/out/server/process2LogicNamespace.js +10 -1
  210. package/out/server/process2LogicNamespace.js.map +1 -1
  211. package/out/server/translator.js +19 -1
  212. package/out/server/translator.js.map +1 -1
  213. package/out/service/storage/init.js +2 -2
  214. package/out/service/storage/init.js.map +1 -1
  215. package/out/templator/genCreateBlock.js +15 -11
  216. package/out/templator/genCreateBlock.js.map +1 -1
  217. package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
  218. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  219. package/out/templator/genCurdMultipleKeyBlock.js +25 -21
  220. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  221. package/out/templator/genEditTableBlock.js +12 -12
  222. package/out/templator/genEditTableBlock.js.map +1 -1
  223. package/out/templator/genGridViewBlock.js +21 -20
  224. package/out/templator/genGridViewBlock.js.map +1 -1
  225. package/out/templator/genListViewBlock.js +6 -3
  226. package/out/templator/genListViewBlock.js.map +1 -1
  227. package/out/templator/genQueryComponent.js +5 -5
  228. package/out/templator/genQueryComponent.js.map +1 -1
  229. package/out/templator/genSelectBlock.js +8 -7
  230. package/out/templator/genSelectBlock.js.map +1 -1
  231. package/out/templator/genTableBlock.js +17 -15
  232. package/out/templator/genTableBlock.js.map +1 -1
  233. package/out/templator/genUpdateBlock.js +15 -11
  234. package/out/templator/genUpdateBlock.js.map +1 -1
  235. package/out/templator/utils.d.ts +2 -2
  236. package/out/templator/utils.js.map +1 -1
  237. package/out/test/integration/connect-file.js +6 -6
  238. package/out/test/integration/connect-file.js.map +1 -1
  239. package/out/translator/index.js +1 -1
  240. package/out/translator/index.js.map +1 -1
  241. package/out/utils/index.d.ts +4 -0
  242. package/out/utils/index.js +32 -1
  243. package/out/utils/index.js.map +1 -1
  244. package/package.json +1 -1
  245. package/src/automate/engine/index.js +12 -1
  246. package/src/automate/engine/uniqueName.js +1 -1
  247. package/src/automate/engine/utils.js +92 -67
  248. package/src/concepts/App__.ts +165 -95
  249. package/src/concepts/Argument__.ts +1 -1
  250. package/src/concepts/Assignee__.ts +1 -1
  251. package/src/concepts/Assignment__.ts +1 -1
  252. package/src/concepts/Attribute__.ts +1 -1
  253. package/src/concepts/BinaryExpression__.ts +1 -1
  254. package/src/concepts/BindAttribute__.ts +3 -3
  255. package/src/concepts/BindDirective__.ts +1 -1
  256. package/src/concepts/BindEvent__.ts +10 -6
  257. package/src/concepts/BooleanLiteral__.ts +1 -1
  258. package/src/concepts/CallFunction__.ts +19 -16
  259. package/src/concepts/CallInterface__.ts +1 -1
  260. package/src/concepts/CallLogic__.ts +23 -23
  261. package/src/concepts/CallQueryComponent__.ts +96 -113
  262. package/src/concepts/Comment__.ts +2 -2
  263. package/src/concepts/CompletionProperty__.ts +1 -1
  264. package/src/concepts/ConfigGroup__.ts +4 -2
  265. package/src/concepts/ConfigPropertyValue__.ts +1 -1
  266. package/src/concepts/ConfigProperty__.ts +5 -1
  267. package/src/concepts/Configuration__.ts +4 -1
  268. package/src/concepts/Constant__.ts +1 -1
  269. package/src/concepts/DataElement__.ts +1 -1
  270. package/src/concepts/DataSource__.ts +389 -0
  271. package/src/concepts/Destination__.ts +24 -8
  272. package/src/concepts/End__.ts +3 -3
  273. package/src/concepts/EntityIndex__.ts +8 -1
  274. package/src/concepts/EntityProperty__.ts +21 -3
  275. package/src/concepts/Entity__.ts +24 -12
  276. package/src/concepts/EnumItem__.ts +1 -1
  277. package/src/concepts/Enum__.ts +24 -5
  278. package/src/concepts/Event__.ts +1 -1
  279. package/src/concepts/ForEachStatement__.ts +3 -3
  280. package/src/concepts/Function__.ts +97 -3
  281. package/src/concepts/Identifier__.ts +12 -13
  282. package/src/concepts/IfStatement__.ts +10 -10
  283. package/src/concepts/InterfaceParam__.ts +1 -1
  284. package/src/concepts/Interface__.ts +20 -12
  285. package/src/concepts/JSBlock__.ts +1 -1
  286. package/src/concepts/LogicItem__.ts +1 -1
  287. package/src/concepts/Logic__.ts +41 -39
  288. package/src/concepts/MemberExpression__.ts +1 -1
  289. package/src/concepts/Module__.ts +9 -204
  290. package/src/concepts/Namespace__.ts +1 -204
  291. package/src/concepts/NullLiteral__.ts +1 -1
  292. package/src/concepts/NumericLiteral__.ts +1 -1
  293. package/src/concepts/Param__.ts +3 -2
  294. package/src/concepts/Point__.ts +1 -1
  295. package/src/concepts/ProcessComponent__.ts +1 -1
  296. package/src/concepts/ProcessElement__.ts +29 -13
  297. package/src/concepts/ProcessOutcome__.ts +1 -1
  298. package/src/concepts/Process__.ts +17 -11
  299. package/src/concepts/QueryAggregateExpression__.ts +1 -1
  300. package/src/concepts/QueryFieldExpression__.ts +10 -2
  301. package/src/concepts/QueryFromExpression__.ts +14 -3
  302. package/src/concepts/QueryGroupByExpression__.ts +1 -1
  303. package/src/concepts/QueryJoinExpression__.ts +15 -4
  304. package/src/concepts/QueryLimitExpression__.ts +1 -1
  305. package/src/concepts/QueryOrderByExpression__.ts +1 -1
  306. package/src/concepts/QuerySelectExpression__.ts +1 -1
  307. package/src/concepts/Rect__.ts +1 -1
  308. package/src/concepts/Return__.ts +1 -1
  309. package/src/concepts/Role__.ts +11 -5
  310. package/src/concepts/Slot__.ts +1 -1
  311. package/src/concepts/SqlQueryComponent__.ts +30 -11
  312. package/src/concepts/Start__.ts +1 -1
  313. package/src/concepts/StringLiteral__.ts +1 -1
  314. package/src/concepts/StructureProperty__.ts +1 -1
  315. package/src/concepts/Structure__.ts +20 -12
  316. package/src/concepts/SwitchCase__.ts +6 -6
  317. package/src/concepts/SwitchStatement__.ts +1 -1
  318. package/src/concepts/Theme__.ts +1 -1
  319. package/src/concepts/Transactional__.ts +1 -1
  320. package/src/concepts/TypeAnnotation__.ts +45 -23
  321. package/src/concepts/TypeParam__.ts +1 -1
  322. package/src/concepts/UnaryExpression__.ts +1 -1
  323. package/src/concepts/Unparsed__.ts +1 -1
  324. package/src/concepts/UseComponent__.ts +1 -1
  325. package/src/concepts/ValidationRule__.ts +1 -1
  326. package/src/concepts/Variable__.ts +1 -1
  327. package/src/concepts/ViewComponent__.ts +1 -1
  328. package/src/concepts/ViewElement__.ts +19 -19
  329. package/src/concepts/View__.ts +25 -23
  330. package/src/concepts/WhileStatement__.ts +5 -5
  331. package/src/concepts/basics/stdlib/nasl.util.ts +279 -0
  332. package/src/concepts/index__.ts +1 -0
  333. package/src/generator/genBundleFiles.ts +8 -3
  334. package/src/generator/genMetaData.ts +13 -13
  335. package/src/server/createUiTs.ts +1 -0
  336. package/src/server/getLogics.ts +11 -3
  337. package/src/server/getProcesses.ts +61 -0
  338. package/src/server/naslServer.ts +124 -6
  339. package/src/server/process2LogicNamespace.ts +29 -19
  340. package/src/server/translator.ts +22 -1
  341. package/src/service/storage/init.ts +2 -2
  342. package/src/templator/genCreateBlock.ts +16 -13
  343. package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
  344. package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
  345. package/src/templator/genEditTableBlock.ts +14 -13
  346. package/src/templator/genGridViewBlock.ts +22 -21
  347. package/src/templator/genListViewBlock.ts +9 -5
  348. package/src/templator/genQueryComponent.ts +6 -6
  349. package/src/templator/genSelectBlock.ts +9 -8
  350. package/src/templator/genTableBlock.ts +18 -16
  351. package/src/templator/genUpdateBlock.ts +16 -12
  352. package/src/templator/utils.ts +2 -2
  353. package/src/test/integration/connect-file.ts +6 -6
  354. package/src/translator/index.ts +1 -1
  355. package/src/utils/index.ts +32 -0
@@ -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.tabSize + 1) + '';
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.tabSize + 1) + 'let ';
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.tabSize + 1) + 'let ';
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.tabSize + 1 }));
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.tabSize) + '}\n';
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
- const entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
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.tabSize + 1) + 'let ';
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.tabSize + 1) + 'let ';
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.tabSize + 1) + `return ${this.returns[0].name};\n`;
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.tabSize + 1 }));
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.tabSize + 1 }));
1542
+ code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1539
1543
  code += '\n';
1540
1544
  });
1541
1545
 
1542
- code += indent(state.tabSize) + '}';
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.tabSize + 1) + 'let ';
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.tabSize + 1) + 'let ';
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.tabSize + 1) + `return ${this.returns[0].name};\n`;
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.tabSize + 1 }));
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.tabSize + 1 }));
1601
+ code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1598
1602
  code += '\n';
1599
1603
  });
1600
1604
 
1601
- code += indent(state.tabSize) + '}';
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
- let parentNodeNamespace = '';
1612
- if (this.parentNode instanceof Namespace || this.parentNode instanceof App || this.parentNode instanceof Module) {
1613
- parentNodeNamespace = this.parentNode.getNamespace();
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
- parentNodeNamespace
1617
- = ['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration'].includes(parentNodeNamespace) || parentNodeNamespace.includes('.logics') ? parentNodeNamespace : `${parentNodeNamespace}.logics`;
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 parentNodeNamespace;
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
- let parentNodeNamespace = '';
1629
- if (this.parentNode instanceof Namespace || this.parentNode instanceof App) {
1630
- parentNodeNamespace = this.parentNode.getNamespace();
1631
- } else if (this.parentNode instanceof Module) {
1632
- parentNodeNamespace = this.parentNode.getTsNamespace();
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
- parentNodeNamespace
1636
- = ['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration'].includes(parentNodeNamespace) || parentNodeNamespace.includes('.logics') ? parentNodeNamespace : `${parentNodeNamespace}.logics`;
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 parentNodeNamespace;
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['Logic'] = Logic;
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['MemberExpression'] = MemberExpression;
282
+ classMap.MemberExpression = MemberExpression;
283
283
  export default MemberExpression;
284
284
  //================================================================================
285
285
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -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
- getEntityExistingNames(excludedList: Array<Entity> = []) {
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]}.${this.name}`;
1511
+ return `${moduleNameSpace[this.parentKey as ModuleKeyType]}`;
1711
1512
  }
1712
1513
 
1713
1514
  getTsNamespace() {
1714
- return `${moduleNameSpace[this.parentKey as ModuleKeyType]}.${this.tsName}`;
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['Module'] = Module;
1536
+ classMap.Module = Module;
1732
1537
  export default Module;
1733
1538
  //================================================================================
1734
1539
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑