@lcap/nasl 1.0.0 → 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 (422) hide show
  1. package/out/automate/engine/index.js +39 -127
  2. package/out/automate/engine/index.js.map +1 -1
  3. package/out/automate/engine/operators.d.ts +13 -0
  4. package/out/automate/engine/operators.js +63 -0
  5. package/out/automate/engine/operators.js.map +1 -0
  6. package/out/automate/engine/uniqueName.d.ts +6 -0
  7. package/out/automate/engine/uniqueName.js +39 -0
  8. package/out/automate/engine/uniqueName.js.map +1 -0
  9. package/out/automate/engine/utils.d.ts +1 -0
  10. package/out/automate/engine/utils.js +105 -67
  11. package/out/automate/engine/utils.js.map +1 -1
  12. package/out/common/BaseNode.d.ts +1 -1
  13. package/out/common/BaseNode.js +13 -3
  14. package/out/common/BaseNode.js.map +1 -1
  15. package/out/concepts/App__.d.ts +52 -49
  16. package/out/concepts/App__.js +95 -60
  17. package/out/concepts/App__.js.map +1 -1
  18. package/out/concepts/Argument__.js +1 -1
  19. package/out/concepts/Argument__.js.map +1 -1
  20. package/out/concepts/Assignee__.d.ts +11 -0
  21. package/out/concepts/Assignee__.js +36 -2
  22. package/out/concepts/Assignee__.js.map +1 -1
  23. package/out/concepts/Assignment__.js +1 -1
  24. package/out/concepts/Assignment__.js.map +1 -1
  25. package/out/concepts/Attribute__.js +1 -1
  26. package/out/concepts/Attribute__.js.map +1 -1
  27. package/out/concepts/BinaryExpression__.js +1 -1
  28. package/out/concepts/BinaryExpression__.js.map +1 -1
  29. package/out/concepts/BindAttribute__.js +4 -4
  30. package/out/concepts/BindAttribute__.js.map +1 -1
  31. package/out/concepts/BindDirective__.js +2 -2
  32. package/out/concepts/BindDirective__.js.map +1 -1
  33. package/out/concepts/BindEvent__.js +11 -6
  34. package/out/concepts/BindEvent__.js.map +1 -1
  35. package/out/concepts/BooleanLiteral__.js +1 -1
  36. package/out/concepts/BooleanLiteral__.js.map +1 -1
  37. package/out/concepts/CallFunction__.js +25 -5
  38. package/out/concepts/CallFunction__.js.map +1 -1
  39. package/out/concepts/CallInterface__.js +1 -1
  40. package/out/concepts/CallInterface__.js.map +1 -1
  41. package/out/concepts/CallLogic__.js +24 -22
  42. package/out/concepts/CallLogic__.js.map +1 -1
  43. package/out/concepts/CallQueryComponent__.d.ts +35 -5
  44. package/out/concepts/CallQueryComponent__.js +344 -99
  45. package/out/concepts/CallQueryComponent__.js.map +1 -1
  46. package/out/concepts/Comment__.js +2 -2
  47. package/out/concepts/Comment__.js.map +1 -1
  48. package/out/concepts/CompletionProperty__.js +1 -1
  49. package/out/concepts/CompletionProperty__.js.map +1 -1
  50. package/out/concepts/ConfigGroup__.d.ts +1 -0
  51. package/out/concepts/ConfigGroup__.js +9 -2
  52. package/out/concepts/ConfigGroup__.js.map +1 -1
  53. package/out/concepts/ConfigPropertyValue__.js +1 -1
  54. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  55. package/out/concepts/ConfigProperty__.d.ts +1 -0
  56. package/out/concepts/ConfigProperty__.js +5 -2
  57. package/out/concepts/ConfigProperty__.js.map +1 -1
  58. package/out/concepts/Configuration__.d.ts +1 -0
  59. package/out/concepts/Configuration__.js +5 -2
  60. package/out/concepts/Configuration__.js.map +1 -1
  61. package/out/concepts/Constant__.js +7 -7
  62. package/out/concepts/Constant__.js.map +1 -1
  63. package/out/concepts/DataElement__.js +1 -1
  64. package/out/concepts/DataElement__.js.map +1 -1
  65. package/out/concepts/DataSource__.d.ts +143 -0
  66. package/out/concepts/DataSource__.js +316 -0
  67. package/out/concepts/DataSource__.js.map +1 -0
  68. package/out/concepts/Destination__.js +26 -9
  69. package/out/concepts/Destination__.js.map +1 -1
  70. package/out/concepts/End__.js +3 -3
  71. package/out/concepts/End__.js.map +1 -1
  72. package/out/concepts/EntityIndex__.d.ts +5 -0
  73. package/out/concepts/EntityIndex__.js +11 -3
  74. package/out/concepts/EntityIndex__.js.map +1 -1
  75. package/out/concepts/EntityProperty__.d.ts +9 -0
  76. package/out/concepts/EntityProperty__.js +23 -8
  77. package/out/concepts/EntityProperty__.js.map +1 -1
  78. package/out/concepts/Entity__.d.ts +6 -3
  79. package/out/concepts/Entity__.js +28 -24
  80. package/out/concepts/Entity__.js.map +1 -1
  81. package/out/concepts/EnumItem__.js +1 -1
  82. package/out/concepts/EnumItem__.js.map +1 -1
  83. package/out/concepts/Enum__.d.ts +1 -0
  84. package/out/concepts/Enum__.js +15 -5
  85. package/out/concepts/Enum__.js.map +1 -1
  86. package/out/concepts/Event__.js +2 -2
  87. package/out/concepts/Event__.js.map +1 -1
  88. package/out/concepts/ForEachStatement__.d.ts +1 -1
  89. package/out/concepts/ForEachStatement__.js +5 -5
  90. package/out/concepts/ForEachStatement__.js.map +1 -1
  91. package/out/concepts/Function__.d.ts +18 -0
  92. package/out/concepts/Function__.js +100 -5
  93. package/out/concepts/Function__.js.map +1 -1
  94. package/out/concepts/Identifier__.js +2 -12
  95. package/out/concepts/Identifier__.js.map +1 -1
  96. package/out/concepts/IfStatement__.js +9 -9
  97. package/out/concepts/IfStatement__.js.map +1 -1
  98. package/out/concepts/InterfaceParam__.js +10 -5
  99. package/out/concepts/InterfaceParam__.js.map +1 -1
  100. package/out/concepts/Interface__.js +21 -14
  101. package/out/concepts/Interface__.js.map +1 -1
  102. package/out/concepts/JSBlock__.js +1 -1
  103. package/out/concepts/JSBlock__.js.map +1 -1
  104. package/out/concepts/LogicItem__.js +1 -1
  105. package/out/concepts/LogicItem__.js.map +1 -1
  106. package/out/concepts/Logic__.d.ts +4 -0
  107. package/out/concepts/Logic__.js +59 -46
  108. package/out/concepts/Logic__.js.map +1 -1
  109. package/out/concepts/MemberExpression__.js +1 -2
  110. package/out/concepts/MemberExpression__.js.map +1 -1
  111. package/out/concepts/Module__.d.ts +1 -85
  112. package/out/concepts/Module__.js +13 -114
  113. package/out/concepts/Module__.js.map +1 -1
  114. package/out/concepts/Namespace__.d.ts +0 -86
  115. package/out/concepts/Namespace__.js +12 -119
  116. package/out/concepts/Namespace__.js.map +1 -1
  117. package/out/concepts/NullLiteral__.js +1 -1
  118. package/out/concepts/NullLiteral__.js.map +1 -1
  119. package/out/concepts/NumericLiteral__.js +1 -1
  120. package/out/concepts/NumericLiteral__.js.map +1 -1
  121. package/out/concepts/Param__.d.ts +3 -2
  122. package/out/concepts/Param__.js +15 -8
  123. package/out/concepts/Param__.js.map +1 -1
  124. package/out/concepts/Point__.js +1 -1
  125. package/out/concepts/Point__.js.map +1 -1
  126. package/out/concepts/ProcessComponent__.js +3 -3
  127. package/out/concepts/ProcessComponent__.js.map +1 -1
  128. package/out/concepts/ProcessElement__.js +39 -18
  129. package/out/concepts/ProcessElement__.js.map +1 -1
  130. package/out/concepts/ProcessOutcome__.js +1 -1
  131. package/out/concepts/ProcessOutcome__.js.map +1 -1
  132. package/out/concepts/Process__.js +21 -14
  133. package/out/concepts/Process__.js.map +1 -1
  134. package/out/concepts/QueryAggregateExpression__.js +2 -2
  135. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  136. package/out/concepts/QueryFieldExpression__.d.ts +1 -0
  137. package/out/concepts/QueryFieldExpression__.js +12 -2
  138. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  139. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  140. package/out/concepts/QueryFromExpression__.js +14 -3
  141. package/out/concepts/QueryFromExpression__.js.map +1 -1
  142. package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
  143. package/out/concepts/QueryGroupByExpression__.js +21 -1
  144. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  145. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  146. package/out/concepts/QueryJoinExpression__.js +16 -5
  147. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  148. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  149. package/out/concepts/QueryOrderByExpression__.js +1 -1
  150. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  151. package/out/concepts/QuerySelectExpression__.js +2 -2
  152. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  153. package/out/concepts/Rect__.js +1 -1
  154. package/out/concepts/Rect__.js.map +1 -1
  155. package/out/concepts/Return__.d.ts +1 -1
  156. package/out/concepts/Return__.js +16 -11
  157. package/out/concepts/Return__.js.map +1 -1
  158. package/out/concepts/Role__.js +11 -4
  159. package/out/concepts/Role__.js.map +1 -1
  160. package/out/concepts/Slot__.js +1 -1
  161. package/out/concepts/Slot__.js.map +1 -1
  162. package/out/concepts/SqlQueryComponent__.d.ts +10 -0
  163. package/out/concepts/SqlQueryComponent__.js +32 -5
  164. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  165. package/out/concepts/Start__.js +1 -1
  166. package/out/concepts/Start__.js.map +1 -1
  167. package/out/concepts/StringLiteral__.js +2 -9
  168. package/out/concepts/StringLiteral__.js.map +1 -1
  169. package/out/concepts/StructureProperty__.js +6 -6
  170. package/out/concepts/StructureProperty__.js.map +1 -1
  171. package/out/concepts/Structure__.js +22 -15
  172. package/out/concepts/Structure__.js.map +1 -1
  173. package/out/concepts/SwitchCase__.js +6 -6
  174. package/out/concepts/SwitchCase__.js.map +1 -1
  175. package/out/concepts/SwitchStatement__.js +1 -1
  176. package/out/concepts/SwitchStatement__.js.map +1 -1
  177. package/out/concepts/Theme__.js +1 -1
  178. package/out/concepts/Theme__.js.map +1 -1
  179. package/out/concepts/Transactional__.js +1 -1
  180. package/out/concepts/Transactional__.js.map +1 -1
  181. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  182. package/out/concepts/TypeAnnotation__.js +56 -6
  183. package/out/concepts/TypeAnnotation__.js.map +1 -1
  184. package/out/concepts/TypeParam__.js +1 -1
  185. package/out/concepts/TypeParam__.js.map +1 -1
  186. package/out/concepts/UnaryExpression__.js +1 -1
  187. package/out/concepts/UnaryExpression__.js.map +1 -1
  188. package/out/concepts/Unparsed__.js +1 -1
  189. package/out/concepts/Unparsed__.js.map +1 -1
  190. package/out/concepts/UseComponent__.js +1 -1
  191. package/out/concepts/UseComponent__.js.map +1 -1
  192. package/out/concepts/ValidationRule__.js +1 -1
  193. package/out/concepts/ValidationRule__.js.map +1 -1
  194. package/out/concepts/Variable__.d.ts +1 -1
  195. package/out/concepts/Variable__.js +16 -11
  196. package/out/concepts/Variable__.js.map +1 -1
  197. package/out/concepts/ViewComponent__.js +6 -6
  198. package/out/concepts/ViewComponent__.js.map +1 -1
  199. package/out/concepts/ViewElement__.js +21 -21
  200. package/out/concepts/ViewElement__.js.map +1 -1
  201. package/out/concepts/View__.d.ts +3 -1
  202. package/out/concepts/View__.js +53 -32
  203. package/out/concepts/View__.js.map +1 -1
  204. package/out/concepts/WhileStatement__.js +5 -5
  205. package/out/concepts/WhileStatement__.js.map +1 -1
  206. package/out/concepts/basics/stdlib/nasl.configuration.js +1 -1
  207. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
  208. package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
  209. package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
  210. package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
  211. package/out/concepts/basics/stdlib/nasl.util.js +268 -6
  212. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  213. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
  214. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
  215. package/out/concepts/basics/types/index.d.ts +1 -0
  216. package/out/concepts/basics/types/index.js +3 -1
  217. package/out/concepts/basics/types/index.js.map +1 -1
  218. package/out/concepts/index__.d.ts +1 -0
  219. package/out/concepts/index__.js +1 -0
  220. package/out/concepts/index__.js.map +1 -1
  221. package/out/enums/KEYWORDS.js +0 -9
  222. package/out/enums/KEYWORDS.js.map +1 -1
  223. package/out/generator/genBundleFiles.js +8 -3
  224. package/out/generator/genBundleFiles.js.map +1 -1
  225. package/out/generator/genMetaData.js +13 -12
  226. package/out/generator/genMetaData.js.map +1 -1
  227. package/out/manager/diagnostic.d.ts +1 -1
  228. package/out/server/createUiTs.js +1 -0
  229. package/out/server/createUiTs.js.map +1 -1
  230. package/out/server/extendBaseNode.d.ts +1 -0
  231. package/out/server/extendBaseNode.js +323 -0
  232. package/out/server/extendBaseNode.js.map +1 -0
  233. package/out/server/getLogics.js +31 -2
  234. package/out/server/getLogics.js.map +1 -1
  235. package/out/server/getMemberIdentifier.js +47 -2
  236. package/out/server/getMemberIdentifier.js.map +1 -1
  237. package/out/server/getProcesses.d.ts +7 -2
  238. package/out/server/getProcesses.js +220 -20
  239. package/out/server/getProcesses.js.map +1 -1
  240. package/out/server/getScope.d.ts +3 -1
  241. package/out/server/getScope.js +30 -14
  242. package/out/server/getScope.js.map +1 -1
  243. package/out/server/index.d.ts +1 -0
  244. package/out/server/index.js +1 -0
  245. package/out/server/index.js.map +1 -1
  246. package/out/server/naslServer.d.ts +7 -5
  247. package/out/server/naslServer.js +249 -372
  248. package/out/server/naslServer.js.map +1 -1
  249. package/out/server/process2LogicNamespace.js +10 -1
  250. package/out/server/process2LogicNamespace.js.map +1 -1
  251. package/out/server/translator.d.ts +1 -1
  252. package/out/server/translator.js +22 -2
  253. package/out/server/translator.js.map +1 -1
  254. package/out/service/storage/init.js +32 -11
  255. package/out/service/storage/init.js.map +1 -1
  256. package/out/templator/genCreateBlock.js +15 -11
  257. package/out/templator/genCreateBlock.js.map +1 -1
  258. package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
  259. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  260. package/out/templator/genCurdMultipleKeyBlock.js +25 -21
  261. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  262. package/out/templator/genEditTableBlock.js +12 -12
  263. package/out/templator/genEditTableBlock.js.map +1 -1
  264. package/out/templator/genGetBlock.js +1 -1
  265. package/out/templator/genGetBlock.js.map +1 -1
  266. package/out/templator/genGridViewBlock.js +21 -20
  267. package/out/templator/genGridViewBlock.js.map +1 -1
  268. package/out/templator/genListViewBlock.js +6 -3
  269. package/out/templator/genListViewBlock.js.map +1 -1
  270. package/out/templator/genQueryComponent.js +11 -8
  271. package/out/templator/genQueryComponent.js.map +1 -1
  272. package/out/templator/genSelectBlock.js +13 -22
  273. package/out/templator/genSelectBlock.js.map +1 -1
  274. package/out/templator/genTableBlock.js +17 -15
  275. package/out/templator/genTableBlock.js.map +1 -1
  276. package/out/templator/genUpdateBlock.js +16 -12
  277. package/out/templator/genUpdateBlock.js.map +1 -1
  278. package/out/templator/utils.d.ts +5 -3
  279. package/out/templator/utils.js +2 -1
  280. package/out/templator/utils.js.map +1 -1
  281. package/out/test/integration/connect-file.js +6 -6
  282. package/out/test/integration/connect-file.js.map +1 -1
  283. package/out/translator/index.js +1 -1
  284. package/out/translator/index.js.map +1 -1
  285. package/out/utils/index.d.ts +4 -0
  286. package/out/utils/index.js +38 -2
  287. package/out/utils/index.js.map +1 -1
  288. package/out/utils/string.d.ts +1 -1
  289. package/out/utils/string.js +38 -9
  290. package/out/utils/string.js.map +1 -1
  291. package/package.json +1 -2
  292. package/src/automate/engine/index.js +38 -128
  293. package/src/automate/engine/operators.js +63 -0
  294. package/src/automate/engine/uniqueName.js +36 -0
  295. package/src/automate/engine/utils.js +108 -69
  296. package/src/common/BaseNode.ts +14 -3
  297. package/src/concepts/App__.ts +138 -101
  298. package/src/concepts/Argument__.ts +1 -1
  299. package/src/concepts/Assignee__.ts +32 -2
  300. package/src/concepts/Assignment__.ts +1 -1
  301. package/src/concepts/Attribute__.ts +1 -1
  302. package/src/concepts/BinaryExpression__.ts +1 -1
  303. package/src/concepts/BindAttribute__.ts +4 -4
  304. package/src/concepts/BindDirective__.ts +2 -2
  305. package/src/concepts/BindEvent__.ts +10 -6
  306. package/src/concepts/BooleanLiteral__.ts +1 -1
  307. package/src/concepts/CallFunction__.ts +36 -18
  308. package/src/concepts/CallInterface__.ts +1 -1
  309. package/src/concepts/CallLogic__.ts +55 -24
  310. package/src/concepts/CallQueryComponent__.ts +357 -134
  311. package/src/concepts/Comment__.ts +2 -2
  312. package/src/concepts/CompletionProperty__.ts +1 -1
  313. package/src/concepts/ConfigGroup__.ts +5 -3
  314. package/src/concepts/ConfigPropertyValue__.ts +1 -1
  315. package/src/concepts/ConfigProperty__.ts +6 -2
  316. package/src/concepts/Configuration__.ts +5 -2
  317. package/src/concepts/Constant__.ts +7 -7
  318. package/src/concepts/DataElement__.ts +1 -1
  319. package/src/concepts/DataSource__.ts +389 -0
  320. package/src/concepts/Destination__.ts +28 -10
  321. package/src/concepts/End__.ts +3 -3
  322. package/src/concepts/EntityIndex__.ts +12 -3
  323. package/src/concepts/EntityProperty__.ts +24 -8
  324. package/src/concepts/Entity__.ts +39 -27
  325. package/src/concepts/EnumItem__.ts +1 -1
  326. package/src/concepts/Enum__.ts +16 -5
  327. package/src/concepts/Event__.ts +2 -2
  328. package/src/concepts/ForEachStatement__.ts +5 -5
  329. package/src/concepts/Function__.ts +101 -7
  330. package/src/concepts/Identifier__.ts +2 -12
  331. package/src/concepts/IfStatement__.ts +10 -10
  332. package/src/concepts/InterfaceParam__.ts +10 -5
  333. package/src/concepts/Interface__.ts +22 -14
  334. package/src/concepts/JSBlock__.ts +1 -1
  335. package/src/concepts/LogicItem__.ts +1 -1
  336. package/src/concepts/Logic__.ts +60 -43
  337. package/src/concepts/MemberExpression__.ts +1 -2
  338. package/src/concepts/Module__.ts +16 -211
  339. package/src/concepts/Namespace__.ts +12 -215
  340. package/src/concepts/NullLiteral__.ts +1 -1
  341. package/src/concepts/NumericLiteral__.ts +1 -1
  342. package/src/concepts/Param__.ts +17 -9
  343. package/src/concepts/Point__.ts +1 -1
  344. package/src/concepts/ProcessComponent__.ts +3 -3
  345. package/src/concepts/ProcessElement__.ts +43 -21
  346. package/src/concepts/ProcessOutcome__.ts +1 -1
  347. package/src/concepts/Process__.ts +21 -15
  348. package/src/concepts/QueryAggregateExpression__.ts +2 -2
  349. package/src/concepts/QueryFieldExpression__.ts +14 -2
  350. package/src/concepts/QueryFromExpression__.ts +14 -3
  351. package/src/concepts/QueryGroupByExpression__.ts +24 -1
  352. package/src/concepts/QueryJoinExpression__.ts +16 -5
  353. package/src/concepts/QueryLimitExpression__.ts +9 -0
  354. package/src/concepts/QueryOrderByExpression__.ts +1 -1
  355. package/src/concepts/QuerySelectExpression__.ts +2 -2
  356. package/src/concepts/Rect__.ts +1 -1
  357. package/src/concepts/Return__.ts +16 -11
  358. package/src/concepts/Role__.ts +11 -5
  359. package/src/concepts/Slot__.ts +1 -1
  360. package/src/concepts/SqlQueryComponent__.ts +30 -11
  361. package/src/concepts/Start__.ts +1 -1
  362. package/src/concepts/StringLiteral__.ts +2 -9
  363. package/src/concepts/StructureProperty__.ts +6 -6
  364. package/src/concepts/Structure__.ts +22 -14
  365. package/src/concepts/SwitchCase__.ts +6 -6
  366. package/src/concepts/SwitchStatement__.ts +1 -1
  367. package/src/concepts/Theme__.ts +1 -1
  368. package/src/concepts/Transactional__.ts +1 -1
  369. package/src/concepts/TypeAnnotation__.ts +55 -25
  370. package/src/concepts/TypeParam__.ts +1 -1
  371. package/src/concepts/UnaryExpression__.ts +1 -1
  372. package/src/concepts/Unparsed__.ts +1 -1
  373. package/src/concepts/UseComponent__.ts +1 -1
  374. package/src/concepts/ValidationRule__.ts +1 -1
  375. package/src/concepts/Variable__.ts +16 -11
  376. package/src/concepts/ViewComponent__.ts +6 -6
  377. package/src/concepts/ViewElement__.ts +21 -21
  378. package/src/concepts/View__.ts +54 -32
  379. package/src/concepts/WhileStatement__.ts +5 -5
  380. package/src/concepts/basics/stdlib/nasl.configuration.ts +1 -1
  381. package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
  382. package/src/concepts/basics/stdlib/nasl.util.ts +269 -6
  383. package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
  384. package/src/concepts/basics/types/index.ts +1 -0
  385. package/src/concepts/index__.ts +1 -0
  386. package/src/enums/KEYWORDS.ts +0 -9
  387. package/src/generator/genBundleFiles.ts +8 -3
  388. package/src/generator/genMetaData.ts +13 -13
  389. package/src/manager/diagnostic.ts +1 -1
  390. package/src/server/createUiTs.ts +1 -0
  391. package/src/server/extendBaseNode.ts +318 -0
  392. package/src/server/getLogics.ts +33 -4
  393. package/src/server/getMemberIdentifier.ts +49 -2
  394. package/src/server/getProcesses.ts +231 -21
  395. package/src/server/getScope.ts +41 -24
  396. package/src/server/index.ts +1 -0
  397. package/src/server/naslServer.ts +248 -366
  398. package/src/server/process2LogicNamespace.ts +29 -19
  399. package/src/server/translator.ts +25 -2
  400. package/src/service/storage/init.ts +32 -12
  401. package/src/templator/genCreateBlock.ts +16 -13
  402. package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
  403. package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
  404. package/src/templator/genEditTableBlock.ts +14 -13
  405. package/src/templator/genGetBlock.ts +1 -1
  406. package/src/templator/genGridViewBlock.ts +22 -21
  407. package/src/templator/genListViewBlock.ts +9 -5
  408. package/src/templator/genQueryComponent.ts +12 -9
  409. package/src/templator/genSelectBlock.ts +14 -23
  410. package/src/templator/genTableBlock.ts +18 -16
  411. package/src/templator/genUpdateBlock.ts +17 -13
  412. package/src/templator/utils.ts +5 -2
  413. package/src/test/integration/connect-file.ts +6 -6
  414. package/src/translator/index.ts +1 -1
  415. package/src/utils/index.ts +38 -1
  416. package/src/utils/string.ts +39 -9
  417. package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +0 -3
  418. package/out/concepts/basics/stdlib/nasl.browser copy.js +0 -70
  419. package/out/concepts/basics/stdlib/nasl.browser copy.js.map +0 -1
  420. package/out/terms/LEVEL_NAME_MAP.d.ts +0 -26
  421. package/out/terms/LEVEL_NAME_MAP.js +0 -30
  422. package/out/terms/LEVEL_NAME_MAP.js.map +0 -1
@@ -32,15 +32,44 @@ exports.firstLowerCase = firstLowerCase;
32
32
  * @param set 数据集合,Array | Map | Set
33
33
  * @param start 数字起始
34
34
  */
35
- function unique(key, set, start = 1) {
36
- const has = (_key) => {
37
- if (set instanceof Set || set instanceof Map)
38
- return set.has(_key);
39
- else if (Array.isArray(set))
40
- return set.includes(_key);
41
- else
42
- return set[_key];
43
- };
35
+ function unique(key, set, start = 1, insensitive = false) {
36
+ let has;
37
+ if (insensitive) {
38
+ has = (_key) => {
39
+ const lkey = _key.toLowerCase();
40
+ if (set instanceof Set || set instanceof Map) {
41
+ // return set.has(_key);
42
+ const iterator = set.keys();
43
+ let i = iterator.next();
44
+ while (!i.done) {
45
+ const name = i.value;
46
+ if (name.toLowerCase() === lkey) {
47
+ return true;
48
+ }
49
+ i = iterator.next();
50
+ }
51
+ return false;
52
+ }
53
+ else if (Array.isArray(set))
54
+ // return set.includes(_key);
55
+ return set.some((s) => s.toLowerCase() === lkey);
56
+ else {
57
+ // return set[_key];
58
+ const keys = Object.keys(set);
59
+ return keys.some((k) => k.toLowerCase() === lkey);
60
+ }
61
+ };
62
+ }
63
+ else {
64
+ has = (_key) => {
65
+ if (set instanceof Set || set instanceof Map)
66
+ return set.has(_key);
67
+ else if (Array.isArray(set))
68
+ return set.includes(_key);
69
+ else
70
+ return set[_key];
71
+ };
72
+ }
44
73
  while (has(key))
45
74
  key = key.replace(/\d*$/, (m) => String(m === '' ? start : +m + 1));
46
75
  return key;
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAAnG,QAAA,WAAW,eAAwF;AAEhH;;;;GAIG;AACI,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CA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,EAAE,EAAE;IAC/E,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,sBAAsB,GAAG,GAAG,CAAC,CAAC;IACvF,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7C,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lcap/nasl",
3
3
  "description": "NetEase Application Specific Language",
4
- "version": "1.0.0",
4
+ "version": "2.12.0-beta",
5
5
  "author": "Forrest <rainforest92@126.com>",
6
6
  "scripts": {
7
7
  "dev": "tsc -watch -p ./",
@@ -38,7 +38,6 @@
38
38
  "fs-extra": "^10.1.0",
39
39
  "json-stringify-safe": "^5.0.1",
40
40
  "lodash": "^4.17.21",
41
- "module-alias": "^2.2.2",
42
41
  "pluralize": "^8.0.0",
43
42
  "postcss": "^8.4.14",
44
43
  "qs": "^6.10.1",
@@ -2,6 +2,10 @@ import { uniq, omit } from 'lodash';
2
2
  import { BaseNode } from '../../common/BaseNode';
3
3
  import { tracking, TRACK_TYPE, IGNORE_PROPERTY } from './utils';
4
4
  import { getConceptConstructor, getConceptMeta } from '../../decorators/index';
5
+ // import { unique, firstUpperCase } from '../../utils/string';
6
+ import uniqueNameModule from './uniqueName';
7
+ import operatorModule from './operators';
8
+
5
9
  let id = 0;
6
10
  class TemplateMeta {
7
11
  constructor(node) {
@@ -168,7 +172,7 @@ class TemplateMeta {
168
172
  // return `_set(${this.name}, "name", getGenUniqNameFunctionName(${this.name}, "${this.node.concept}"));`;
169
173
  // _setTableName(${this.name}, ${this.name}.name + '_' + app.id.slice(0,6));`;
170
174
  // }
171
- return `_set(${this.name}, "name", getGenUniqNameFunctionName(${this.name}, "${this.node.concept}", app), (updatedObj) => { ${this.name} = updatedObj; })`;
175
+ return `_set(${this.name}, "name", _uniqueName.getGenUniqNameFunctionName(${this.name}, "${this.node.concept}", app), (updatedObj) => { ${this.name} = updatedObj; })`;
172
176
  }
173
177
 
174
178
  genRoleBind() {
@@ -245,126 +249,7 @@ function autoScript(stack) {
245
249
 
246
250
  return `
247
251
  (function () {
248
- function unique(key, set, start = 1) {
249
- const has = (_key) => {
250
- if (set instanceof Set || set instanceof Map)
251
- return set.has(_key);
252
- else if (Array.isArray(set))
253
- return set.includes(_key);
254
- else
255
- return set[_key];
256
- };
257
-
258
- while (has(key))
259
- key = key.replace(/\\d*$/, (m) => String(m === '' ? start : (+m) + 1));
260
- return key;
261
- }
262
-
263
- function alphaUpper(name) {
264
- if (!name) {
265
- return '';
266
- }
267
- return name[0].toUpperCase() + name.substring(1);
268
- }
269
-
270
- const NamesWeakMap = new Map();
271
-
272
- function initAppUniqueNames(app) {
273
- NamesWeakMap.set('Entity', new Set(app.getEntityExistingNames()));
274
- NamesWeakMap.set('Structure', new Set(app.getStructureExistingNames()));
275
- NamesWeakMap.set('Enum', new Set(app.getEnumExistingNames()));
276
- NamesWeakMap.set('Logic', new Set(app.getLogicExistingNames()));
277
- NamesWeakMap.set('Interface', new Set(app.getInterfaceExistingNames()));
278
- NamesWeakMap.set('View', new Set(app.getViewExistingNames()));
279
- NamesWeakMap.set('Process', new Set(app.getProcessExistingNames()));
280
- NamesWeakMap.set('Role', new Set(app.getRoleExistingNames()));
281
- }
282
-
283
- function getGenUniqNameFunctionName(item, concept, app) {
284
- const p = item.parentNode;
285
- if(!p) {
286
- const nameSet = NamesWeakMap.get(concept);
287
- const n = unique(item.name, nameSet);
288
- nameSet.add(n);
289
- return n;
290
- }
291
- const f1 = p["get" + concept + "UniqueName"];
292
- const f2 = p["get" + concept + "ExistingNames"]
293
- if(f1 && f2) {
294
- const names = f2.call(p);
295
- const t = names.filter(n => n === item.name);
296
- if(t.length > 1) {
297
- return f1.call(p, item.name);
298
- }
299
- }
300
- return item.name;
301
- }
302
-
303
- let BaseNodeConstructor;
304
- let getConceptConstructor;
305
- let getConceptMeta;
306
-
307
- function instanceOfBaseNode(item) {
308
- return (item instanceof BaseNodeConstructor);
309
- }
310
-
311
- function _set(item, propertyName, value, callback) {
312
- if(instanceOfBaseNode(value)) {
313
- value.parentNode = item;
314
- value.parentKey = propertyName;
315
- }
316
- if(item[propertyName] !== value) {
317
- item.update({
318
- [propertyName]: value,
319
- });
320
-
321
- if(instanceOfBaseNode(value) && callback) {
322
- callback(item[propertyName]);
323
- }
324
- }
325
- }
326
-
327
- function _push(item, propertyName, value) {
328
- if(!item[propertyName]){
329
- item[propertyName] = [];
330
- }
331
- value.parentNode = item;
332
- value.parentKey = propertyName;
333
- item[propertyName].push(value);
334
- const index = item[propertyName].length;
335
- value.create({
336
- index,
337
- parentNode: item,
338
- parentKey: propertyName,
339
- });
340
- }
341
-
342
- function _create(concept) {
343
- const _ctor = getConceptConstructor(concept);
344
- const item = new _ctor();
345
- const { propertyMap } = getConceptMeta(concept);
346
- for(const p of propertyMap) {
347
- const [propertyName] = p;
348
- const t = item[propertyName];
349
- if(Array.isArray(t)) {
350
- _set(item, propertyName, []);
351
- }
352
- }
353
- return item;
354
- }
355
-
356
- function _addModule(app, name, belongs, data) {
357
- const ms = app[belongs];
358
- const exist = ms.find(m => m.name === name);
359
- if(!exist) {
360
- app["addModuleIn" + alphaUpper(belongs)](data);
361
- }
362
- }
363
-
364
- function _bindRoles(){
365
- return Array.prototype.map.call(arguments, r => r.name);
366
- }
367
- // let _tempConstructor;
252
+ const injectModule = {};
368
253
 
369
254
  const exportRoles = function() {
370
255
  return ${JSON.stringify(roleNASL)};
@@ -372,11 +257,17 @@ function autoScript(stack) {
372
257
 
373
258
  const execTemplate = function(app, getCtor, getCMeta, base, rootBindCallback, roleCallback, finalCallback) {
374
259
  let _templateObjects = [];
375
- BaseNodeConstructor = base;
376
- getConceptConstructor = getCtor;
377
- getConceptMeta = getCMeta;
260
+ const {
261
+ _set,
262
+ _push,
263
+ _create,
264
+ _addModule,
265
+ _bindRoles
266
+ } = injectModule.operators;
267
+
268
+ const _uniqueName = new injectModule.uniqueName();
378
269
 
379
- initAppUniqueNames(app);
270
+ _uniqueName.initAppUniqueNames(app);
380
271
 
381
272
  app.emit('collect:start', {
382
273
  actionMsg: '导入页面模板'
@@ -420,7 +311,10 @@ function autoScript(stack) {
420
311
 
421
312
  return {
422
313
  execTemplate,
423
- exportRoles
314
+ exportRoles,
315
+ importModule(key, m) {
316
+ injectModule[key] = m;
317
+ },
424
318
  }
425
319
  })();`;
426
320
  }
@@ -430,6 +324,7 @@ export function autoTemplate(node) {
430
324
  const stack = [];
431
325
  const startNode = node;
432
326
  let rootNode = true;
327
+ const finalOps = [];
433
328
  function iterator(node) {
434
329
  if (node && !visitedMap.has(node)) {
435
330
  const meta = new TemplateMeta(node);
@@ -447,12 +342,21 @@ export function autoTemplate(node) {
447
342
  break;
448
343
  case TRACK_TYPE.PROPERTY:
449
344
  case TRACK_TYPE.ARRAY:
450
- iterator(property);
345
+ iterator(property);
451
346
  const pmeta = visitedMap.get(property);
452
347
  meta.addBinds(type, propertyName, pmeta);
453
348
  break;
349
+ case TRACK_TYPE.ARRAY_NO_FURTHER:
350
+ finalOps.push(() => {
351
+ const pmeta = visitedMap.get(property);
352
+ if(pmeta) {
353
+ meta.addBinds(TRACK_TYPE.ARRAY, propertyName, pmeta);
354
+ }
355
+ })
356
+ break;
454
357
  case TRACK_TYPE.CALLEE:
455
358
  iterator(rootNode);
359
+ iterator(calleeNode);
456
360
  const cmeta = visitedMap.get(calleeNode);
457
361
  if (AppPropertyName) {
458
362
  meta.addRootBinds(AppPropertyName, visitedMap.get(rootNode));
@@ -505,6 +409,7 @@ export function autoTemplate(node) {
505
409
  }
506
410
 
507
411
  iterator(node);
412
+ finalOps.forEach(f => { f(); });
508
413
  return autoScript(stack);
509
414
  }
510
415
 
@@ -527,6 +432,11 @@ export function getRoles(script) {
527
432
  return exportRoles();
528
433
  }
529
434
  export function applyTemplate(script, app, rootBindCallback, roleCallback, finalCallback) {
530
- const { execTemplate } = eval(script);
435
+ const { execTemplate, importModule } = eval(script);
436
+ // 为了兼容 2.11 老模板
437
+ if(importModule) {
438
+ importModule('operators', operatorModule);
439
+ importModule('uniqueName', uniqueNameModule);
440
+ }
531
441
  execTemplate(app, getConceptConstructor, getConceptMeta, BaseNode, rootBindCallback, roleCallback, finalCallback);
532
442
  }
@@ -0,0 +1,63 @@
1
+ import { BaseNode } from '../../common/BaseNode';
2
+ import { getConceptConstructor, getConceptMeta } from '../../decorators/index';
3
+ import { firstUpperCase } from '../../utils/string';
4
+
5
+ function instanceOfBaseNode(item) {
6
+ return (item instanceof BaseNode);
7
+ }
8
+ const ops = {
9
+ _set(item, propertyName, value, callback) {
10
+ if(instanceOfBaseNode(value)) {
11
+ value.parentNode = item;
12
+ value.parentKey = propertyName;
13
+ }
14
+ if(item[propertyName] !== value) {
15
+ item.update({
16
+ [propertyName]: value,
17
+ });
18
+
19
+ if(instanceOfBaseNode(value) && callback) {
20
+ callback(item[propertyName]);
21
+ }
22
+ }
23
+ },
24
+ _push(item, propertyName, value) {
25
+ if(!item[propertyName]){
26
+ item[propertyName] = [];
27
+ }
28
+ value.parentNode = item;
29
+ value.parentKey = propertyName;
30
+ item[propertyName].push(value);
31
+ const index = item[propertyName].length;
32
+ value.create({
33
+ index,
34
+ parentNode: item,
35
+ parentKey: propertyName,
36
+ });
37
+ },
38
+ _create(concept) {
39
+ const _ctor = getConceptConstructor(concept);
40
+ const item = new _ctor();
41
+ const { propertyMap } = getConceptMeta(concept);
42
+ for(const p of propertyMap) {
43
+ const [propertyName] = p;
44
+ const t = item[propertyName];
45
+ if(Array.isArray(t)) {
46
+ ops._set(item, propertyName, []);
47
+ }
48
+ }
49
+ return item;
50
+ },
51
+ _addModule(app, name, belongs, data) {
52
+ const ms = app[belongs];
53
+ const exist = ms.find(m => m.name === name);
54
+ if(!exist) {
55
+ app["addModuleIn" + firstUpperCase(belongs)](data);
56
+ }
57
+ },
58
+ _bindRoles(){
59
+ return Array.prototype.map.call(arguments, r => r.name);
60
+ }
61
+ }
62
+
63
+ export default ops;
@@ -0,0 +1,36 @@
1
+ import { unique } from '../../utils/string';
2
+ class uniqueName {
3
+ NamesWeakMap = new Map();
4
+ initAppUniqueNames(app) {
5
+ const NamesWeakMap = this.NamesWeakMap;
6
+ NamesWeakMap.set('DataSource', new Set(app.getDataSourceExistingNames()));
7
+ NamesWeakMap.set('Structure', new Set(app.getStructureExistingNames()));
8
+ NamesWeakMap.set('Enum', new Set(app.getEnumExistingNames()));
9
+ NamesWeakMap.set('Logic', new Set(app.getLogicExistingNames()));
10
+ NamesWeakMap.set('Interface', new Set(app.getInterfaceExistingNames()));
11
+ NamesWeakMap.set('View', new Set(app.getViewExistingNames()));
12
+ NamesWeakMap.set('Process', new Set(app.getProcessExistingNames()));
13
+ NamesWeakMap.set('Role', new Set(app.getRoleExistingNames()));
14
+ }
15
+ getGenUniqNameFunctionName(item, concept) {
16
+ const p = item.parentNode;
17
+ const NamesWeakMap = this.NamesWeakMap;
18
+ if(!p) {
19
+ const nameSet = NamesWeakMap.get(concept);
20
+ const n = unique(item.name, nameSet, 1, true);
21
+ nameSet.add(n);
22
+ return n;
23
+ }
24
+ const f1 = p["get" + concept + "UniqueName"];
25
+ const f2 = p["get" + concept + "ExistingNames"]
26
+ if(f1 && f2) {
27
+ const names = f2.call(p);
28
+ const t = names.filter(n => n === item.name);
29
+ if(t.length > 1) {
30
+ return f1.call(p, item.name);
31
+ }
32
+ }
33
+ return item.name;
34
+ }
35
+ }
36
+ export default uniqueName;