@lcap/nasl 2.22.0-beta.5 → 3.0.0-beta.1

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 (304) hide show
  1. package/README.md +13 -0
  2. package/docs/classes/Module.html +15 -15
  3. package/docs/classes/Namespace.html +15 -15
  4. package/docs/classes/ViewComponent.html +19 -19
  5. package/out/automate/engine/utils.js +4 -0
  6. package/out/automate/engine/utils.js.map +1 -1
  7. package/out/breakpoint/generator/AfterStartNode.d.ts +7 -0
  8. package/out/breakpoint/generator/AfterStartNode.js +27 -0
  9. package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
  10. package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
  11. package/out/breakpoint/generator/BeforeEndNode.js +27 -0
  12. package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
  13. package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
  14. package/out/breakpoint/generator/BreakpointNode.js +166 -0
  15. package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
  16. package/out/breakpoint/generator/index.d.ts +4 -0
  17. package/out/breakpoint/generator/index.js +98 -0
  18. package/out/breakpoint/generator/index.js.map +1 -0
  19. package/out/breakpoint/index.d.ts +3 -0
  20. package/out/breakpoint/index.js +20 -0
  21. package/out/breakpoint/index.js.map +1 -0
  22. package/out/breakpoint/shared/constants.d.ts +30 -0
  23. package/out/breakpoint/shared/constants.js +87 -0
  24. package/out/breakpoint/shared/constants.js.map +1 -0
  25. package/out/breakpoint/shared/index.d.ts +3 -0
  26. package/out/breakpoint/shared/index.js +33 -0
  27. package/out/breakpoint/shared/index.js.map +1 -0
  28. package/out/breakpoint/shared/operations.d.ts +10 -0
  29. package/out/breakpoint/shared/operations.js +25 -0
  30. package/out/breakpoint/shared/operations.js.map +1 -0
  31. package/out/breakpoint/shared/socket.d.ts +47 -0
  32. package/out/breakpoint/shared/socket.js +210 -0
  33. package/out/breakpoint/shared/socket.js.map +1 -0
  34. package/out/breakpoint/shared/utils.d.ts +20 -0
  35. package/out/breakpoint/shared/utils.js +133 -0
  36. package/out/breakpoint/shared/utils.js.map +1 -0
  37. package/out/breakpoint/store/core.d.ts +30 -0
  38. package/out/breakpoint/store/core.js +341 -0
  39. package/out/breakpoint/store/core.js.map +1 -0
  40. package/out/breakpoint/store/dock.d.ts +1 -0
  41. package/out/breakpoint/store/dock.js +127 -0
  42. package/out/breakpoint/store/dock.js.map +1 -0
  43. package/out/breakpoint/store/index.d.ts +2 -0
  44. package/out/breakpoint/store/index.js +19 -0
  45. package/out/breakpoint/store/index.js.map +1 -0
  46. package/out/common/BaseNode.d.ts +8 -0
  47. package/out/common/BaseNode.js +19 -0
  48. package/out/common/BaseNode.js.map +1 -1
  49. package/out/concepts/App__.d.ts +365 -16
  50. package/out/concepts/App__.js +431 -10
  51. package/out/concepts/App__.js.map +1 -1
  52. package/out/concepts/Assignment__.js +1 -1
  53. package/out/concepts/Assignment__.js.map +1 -1
  54. package/out/concepts/AuthInterface__.d.ts +37 -0
  55. package/out/concepts/AuthInterface__.js +141 -0
  56. package/out/concepts/AuthInterface__.js.map +1 -0
  57. package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
  58. package/out/concepts/AuthLogicForCallInterface__.js +493 -0
  59. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
  60. package/out/concepts/AuthLogic__.d.ts +66 -0
  61. package/out/concepts/AuthLogic__.js +206 -0
  62. package/out/concepts/AuthLogic__.js.map +1 -0
  63. package/out/concepts/BackendVariable__.d.ts +137 -0
  64. package/out/concepts/BackendVariable__.js +422 -0
  65. package/out/concepts/BackendVariable__.js.map +1 -0
  66. package/out/concepts/Backend__.d.ts +134 -0
  67. package/out/concepts/Backend__.js +274 -0
  68. package/out/concepts/Backend__.js.map +1 -0
  69. package/out/concepts/BindAttribute__.d.ts +1 -1
  70. package/out/concepts/BindAttribute__.js +3 -1
  71. package/out/concepts/BindAttribute__.js.map +1 -1
  72. package/out/concepts/BindEvent__.d.ts +12 -0
  73. package/out/concepts/BindEvent__.js +68 -0
  74. package/out/concepts/BindEvent__.js.map +1 -1
  75. package/out/concepts/CallAuthInterface__.d.ts +126 -0
  76. package/out/concepts/CallAuthInterface__.js +408 -0
  77. package/out/concepts/CallAuthInterface__.js.map +1 -0
  78. package/out/concepts/CallInterface__.d.ts +6 -1
  79. package/out/concepts/CallInterface__.js +9 -1
  80. package/out/concepts/CallInterface__.js.map +1 -1
  81. package/out/concepts/CallLogic__.js +3 -1
  82. package/out/concepts/CallLogic__.js.map +1 -1
  83. package/out/concepts/CallQueryComponent__.js +9 -7
  84. package/out/concepts/CallQueryComponent__.js.map +1 -1
  85. package/out/concepts/Destination__.js +1 -1
  86. package/out/concepts/Destination__.js.map +1 -1
  87. package/out/concepts/End__.js +29 -2
  88. package/out/concepts/End__.js.map +1 -1
  89. package/out/concepts/EntityProperty__.js.map +1 -1
  90. package/out/concepts/Entity__.d.ts +1 -2
  91. package/out/concepts/Entity__.js +1 -31
  92. package/out/concepts/Entity__.js.map +1 -1
  93. package/out/concepts/ForEachStatement__.js +9 -4
  94. package/out/concepts/ForEachStatement__.js.map +1 -1
  95. package/out/concepts/FrontendLibrary__.d.ts +29 -29
  96. package/out/concepts/FrontendLibrary__.js +2 -2
  97. package/out/concepts/FrontendVariable__.d.ts +21 -0
  98. package/out/concepts/FrontendVariable__.js +64 -0
  99. package/out/concepts/FrontendVariable__.js.map +1 -0
  100. package/out/concepts/Frontend__.d.ts +151 -47
  101. package/out/concepts/Frontend__.js +188 -32
  102. package/out/concepts/Frontend__.js.map +1 -1
  103. package/out/concepts/Function__.js +1 -1
  104. package/out/concepts/Function__.js.map +1 -1
  105. package/out/concepts/Identifier__.js +1 -1
  106. package/out/concepts/Identifier__.js.map +1 -1
  107. package/out/concepts/Interface__.d.ts +1 -1
  108. package/out/concepts/Interface__.js.map +1 -1
  109. package/out/concepts/LogicItem__.d.ts +18 -3
  110. package/out/concepts/LogicItem__.js +22 -4
  111. package/out/concepts/LogicItem__.js.map +1 -1
  112. package/out/concepts/Logic__.d.ts +14 -9
  113. package/out/concepts/Logic__.js +43 -5
  114. package/out/concepts/Logic__.js.map +1 -1
  115. package/out/concepts/Module__.js.map +1 -1
  116. package/out/concepts/Namespace__.d.ts +29 -29
  117. package/out/concepts/Namespace__.js +2 -2
  118. package/out/concepts/NewComposite__.js +2 -2
  119. package/out/concepts/NewComposite__.js.map +1 -1
  120. package/out/concepts/OverriddenLogic__.d.ts +643 -0
  121. package/out/concepts/OverriddenLogic__.js +1602 -0
  122. package/out/concepts/OverriddenLogic__.js.map +1 -0
  123. package/out/concepts/Param__.d.ts +6 -0
  124. package/out/concepts/Param__.js +10 -0
  125. package/out/concepts/Param__.js.map +1 -1
  126. package/out/concepts/QueryFieldExpression__.d.ts +2 -0
  127. package/out/concepts/QueryFieldExpression__.js +9 -0
  128. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  129. package/out/concepts/QuerySelectExpression__.d.ts +2 -2
  130. package/out/concepts/QuerySelectExpression__.js +2 -2
  131. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  132. package/out/concepts/TypeAnnotation__.js +6 -6
  133. package/out/concepts/TypeAnnotation__.js.map +1 -1
  134. package/out/concepts/Variable__.d.ts +10 -0
  135. package/out/concepts/Variable__.js +12 -0
  136. package/out/concepts/Variable__.js.map +1 -1
  137. package/out/concepts/ViewComponent__.d.ts +33 -33
  138. package/out/concepts/ViewComponent__.js +7 -7
  139. package/out/concepts/ViewElement__.d.ts +6 -0
  140. package/out/concepts/ViewElement__.js +104 -1
  141. package/out/concepts/ViewElement__.js.map +1 -1
  142. package/out/concepts/View__.js +2 -2
  143. package/out/concepts/View__.js.map +1 -1
  144. package/out/concepts/basics/stdlib/index.js +2 -1
  145. package/out/concepts/basics/stdlib/index.js.map +1 -1
  146. package/out/concepts/basics/stdlib/nasl.auth.js +24 -0
  147. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  148. package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
  149. package/out/concepts/basics/stdlib/nasl.http.js +167 -0
  150. package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
  151. package/out/concepts/basics/stdlib/nasl.process.js +68 -0
  152. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  153. package/out/concepts/basics/stdlib/nasl.ui.js +4 -19
  154. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  155. package/out/concepts/basics/stdlib/nasl.util.js +83 -17
  156. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  157. package/out/concepts/basics/types/index.d.ts +1 -0
  158. package/out/concepts/basics/types/index.js +4 -1
  159. package/out/concepts/basics/types/index.js.map +1 -1
  160. package/out/concepts/index__.d.ts +8 -0
  161. package/out/concepts/index__.js +8 -0
  162. package/out/concepts/index__.js.map +1 -1
  163. package/out/enums/KEYWORDS.js +0 -1
  164. package/out/enums/KEYWORDS.js.map +1 -1
  165. package/out/generator/genBundleFiles.d.ts +1 -0
  166. package/out/generator/genBundleFiles.js +27 -0
  167. package/out/generator/genBundleFiles.js.map +1 -1
  168. package/out/generator/genMetaData.d.ts +4 -1
  169. package/out/generator/genMetaData.js +14 -0
  170. package/out/generator/genMetaData.js.map +1 -1
  171. package/out/generator/genReleaseBody.d.ts +2 -1
  172. package/out/generator/genReleaseBody.js +2 -1
  173. package/out/generator/genReleaseBody.js.map +1 -1
  174. package/out/index.d.ts +2 -1
  175. package/out/index.js +3 -1
  176. package/out/index.js.map +1 -1
  177. package/out/server/extendBaseNode.js +16 -4
  178. package/out/server/extendBaseNode.js.map +1 -1
  179. package/out/server/formatTsUtils.d.ts +2 -1
  180. package/out/server/formatTsUtils.js +39 -4
  181. package/out/server/formatTsUtils.js.map +1 -1
  182. package/out/server/getExtensionModules.d.ts +2 -2
  183. package/out/server/getExtensionModules.js +16 -2
  184. package/out/server/getExtensionModules.js.map +1 -1
  185. package/out/server/getLogics.js +5 -5
  186. package/out/server/getLogics.js.map +1 -1
  187. package/out/server/getMemberIdentifier.d.ts +1 -0
  188. package/out/server/getMemberIdentifier.js +34 -7
  189. package/out/server/getMemberIdentifier.js.map +1 -1
  190. package/out/server/naslServer.d.ts +64 -64
  191. package/out/server/naslServer.js +249 -121
  192. package/out/server/naslServer.js.map +1 -1
  193. package/out/server/naslStdlibMap.js +2 -0
  194. package/out/server/naslStdlibMap.js.map +1 -1
  195. package/out/server/translator.d.ts +1 -0
  196. package/out/server/translator.js +67 -2
  197. package/out/server/translator.js.map +1 -1
  198. package/out/service/defaultErrorMessage.json +1 -0
  199. package/out/service/storage/api.d.ts +10 -1
  200. package/out/service/storage/api.js +6 -0
  201. package/out/service/storage/api.js.map +1 -1
  202. package/out/service/storage/init.d.ts +4 -0
  203. package/out/service/storage/init.js +55 -35
  204. package/out/service/storage/init.js.map +1 -1
  205. package/out/service/storage/service.d.ts +3 -0
  206. package/out/service/storage/service.js +14 -0
  207. package/out/service/storage/service.js.map +1 -1
  208. package/out/utils/sortTsString.d.ts +1 -0
  209. package/out/utils/sortTsString.js +36 -0
  210. package/out/utils/sortTsString.js.map +1 -0
  211. package/out/utils/traverse.js +2 -2
  212. package/out/utils/traverse.js.map +1 -1
  213. package/package.json +7 -2
  214. package/sandbox/stdlib/nasl.auth.ts +8 -4
  215. package/sandbox/stdlib/nasl.core.d.ts +206 -0
  216. package/sandbox/stdlib/nasl.core.js +1 -0
  217. package/sandbox/stdlib/nasl.core.js.map +1 -0
  218. package/sandbox/stdlib/nasl.http.ts +35 -0
  219. package/sandbox/stdlib/nasl.process.ts +13 -0
  220. package/sandbox/stdlib/nasl.ui.ts +0 -5
  221. package/src/automate/engine/utils.js +4 -1
  222. package/src/breakpoint/generator/AfterStartNode.ts +27 -0
  223. package/src/breakpoint/generator/BeforeEndNode.ts +27 -0
  224. package/src/breakpoint/generator/BreakpointNode.ts +228 -0
  225. package/src/breakpoint/generator/index.ts +114 -0
  226. package/src/breakpoint/index.ts +3 -0
  227. package/src/breakpoint/shared/constants.ts +95 -0
  228. package/src/breakpoint/shared/index.ts +3 -0
  229. package/src/breakpoint/shared/operations.ts +25 -0
  230. package/src/breakpoint/shared/socket.ts +326 -0
  231. package/src/breakpoint/shared/utils.ts +195 -0
  232. package/src/breakpoint/store/core.ts +411 -0
  233. package/src/breakpoint/store/dock.ts +166 -0
  234. package/src/breakpoint/store/index.ts +2 -0
  235. package/src/breakpoint/types/index.d.ts +19 -0
  236. package/src/common/BaseNode.ts +19 -1
  237. package/src/concepts/App__.ts +828 -26
  238. package/src/concepts/Assignment__.ts +1 -1
  239. package/src/concepts/AuthInterface__.ts +148 -0
  240. package/src/concepts/AuthLogicForCallInterface__.ts +573 -0
  241. package/src/concepts/AuthLogic__.ts +225 -0
  242. package/src/concepts/BackendVariable__.ts +466 -0
  243. package/src/concepts/Backend__.ts +347 -0
  244. package/src/concepts/BindAttribute__.ts +4 -3
  245. package/src/concepts/BindEvent__.ts +71 -2
  246. package/src/concepts/CallAuthInterface__.ts +490 -0
  247. package/src/concepts/CallInterface__.ts +10 -2
  248. package/src/concepts/CallLogic__.ts +3 -1
  249. package/src/concepts/CallQueryComponent__.ts +67 -7
  250. package/src/concepts/Destination__.ts +19 -1
  251. package/src/concepts/End__.ts +31 -3
  252. package/src/concepts/EntityProperty__.ts +6 -0
  253. package/src/concepts/Entity__.ts +8 -31
  254. package/src/concepts/ForEachStatement__.ts +9 -4
  255. package/src/concepts/FrontendLibrary__.ts +30 -30
  256. package/src/concepts/FrontendVariable__.ts +76 -0
  257. package/src/concepts/Frontend__.ts +352 -89
  258. package/src/concepts/Function__.ts +1 -1
  259. package/src/concepts/Identifier__.ts +5 -5
  260. package/src/concepts/Interface__.ts +1 -1
  261. package/src/concepts/LogicItem__.ts +26 -6
  262. package/src/concepts/Logic__.ts +86 -8
  263. package/src/concepts/Module__.ts +32 -2
  264. package/src/concepts/Namespace__.ts +30 -30
  265. package/src/concepts/NewComposite__.ts +2 -3
  266. package/src/concepts/OverriddenLogic__.ts +2165 -0
  267. package/src/concepts/Param__.ts +13 -3
  268. package/src/concepts/QueryFieldExpression__.ts +18 -0
  269. package/src/concepts/QuerySelectExpression__.ts +11 -3
  270. package/src/concepts/TypeAnnotation__.ts +45 -6
  271. package/src/concepts/Variable__.ts +14 -0
  272. package/src/concepts/ViewComponent__.ts +35 -35
  273. package/src/concepts/ViewElement__.ts +104 -1
  274. package/src/concepts/View__.ts +24 -2
  275. package/src/concepts/basics/stdlib/index.ts +2 -1
  276. package/src/concepts/basics/stdlib/nasl.auth.ts +24 -0
  277. package/src/concepts/basics/stdlib/nasl.http.ts +166 -0
  278. package/src/concepts/basics/stdlib/nasl.process.ts +68 -0
  279. package/src/concepts/basics/stdlib/nasl.ui.ts +4 -19
  280. package/src/concepts/basics/stdlib/nasl.util.ts +83 -17
  281. package/src/concepts/basics/types/index.ts +5 -4
  282. package/src/concepts/index__.ts +8 -0
  283. package/src/enums/KEYWORDS.ts +0 -1
  284. package/src/generator/genBundleFiles.ts +36 -2
  285. package/src/generator/genMetaData.ts +16 -1
  286. package/src/generator/genReleaseBody.ts +4 -1
  287. package/src/index.ts +2 -1
  288. package/src/server/extendBaseNode.ts +18 -7
  289. package/src/server/formatTsUtils.ts +37 -5
  290. package/src/server/getExtensionModules.ts +18 -3
  291. package/src/server/getLogics.ts +6 -6
  292. package/src/server/getMemberIdentifier.ts +35 -9
  293. package/src/server/naslServer.ts +250 -124
  294. package/src/server/naslStdlibMap.ts +2 -0
  295. package/src/server/translator.ts +67 -1
  296. package/src/service/defaultErrorMessage.json +1 -0
  297. package/src/service/storage/api.js +7 -1
  298. package/src/service/storage/init.ts +66 -35
  299. package/src/service/storage/service.ts +18 -2
  300. package/src/utils/sortTsString.ts +32 -0
  301. package/src/utils/traverse.ts +2 -2
  302. package/test/examples/app-simple.json +73635 -0
  303. package/ts-worker/lib/tsserver.js +3 -3
  304. package/ts-worker/package.json +1 -1
@@ -10,6 +10,7 @@ if (globalThis.process) { // For TS build
10
10
  'nasl.ui.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.ui.ts'), 'utf8'),
11
11
  'nasl.browser.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.browser.ts'), 'utf8'),
12
12
  'nasl.auth.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.auth.ts'), 'utf8'),
13
+ 'nasl.http.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.http.ts'), 'utf8'),
13
14
  'nasl.configuration.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.configuration.ts'), 'utf8'),
14
15
  'nasl.langUtil.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.langUtil.ts'), 'utf8'),
15
16
  'nasl.annotation.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.annotation.ts'), 'utf8'),
@@ -31,6 +32,7 @@ if (globalThis.window) { // For TS build
31
32
  'nasl.ui.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.ui.ts').default,
32
33
  'nasl.browser.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.browser.ts').default,
33
34
  'nasl.auth.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.auth.ts').default,
35
+ 'nasl.http.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.http.ts').default,
34
36
  'nasl.configuration.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.configuration.ts').default,
35
37
  'nasl.langUtil.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.langUtil.ts').default,
36
38
  'nasl.annotation.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.annotation.ts').default,
@@ -53,11 +53,15 @@ import {
53
53
  } from '../concepts';
54
54
  import { SourceMapItem } from '../translator';
55
55
  import { Diagnostic } from '../manager/diagnostic';
56
+ import { sortTsString } from '../utils/sortTsString';
57
+ import { getNodeByNodeCallee } from '@nasl/automate/engine/utils';
56
58
  export interface MinRange {
57
59
  node: BaseNode;
58
60
  item: SourceMapItem;
59
61
  }
60
62
 
63
+ const mapAstString = new Map();
64
+
61
65
  function transformType(tsType: string): string {
62
66
  if (tsType === 'string' || tsType === 'String')
63
67
  return '字符串';
@@ -171,6 +175,14 @@ function transformIdentifier(identifier: string): string {
171
175
  export function outOriginalvalue(value: string) {
172
176
  return value;
173
177
  }
178
+ const TS_RULES_TYPE_INCONSISTENCY: Array<RegExp> = [
179
+ /This condition will always return '(.+?)' since the types '(.+?)' and '(.+?)' have no overlap/,
180
+ /Property '(.+?)' is missing in type '(.+?)' but required in type '(.+?)'/,
181
+ /Argument of type '(.+?)' is not assignable to parameter of type '(.+?)'/,
182
+ /Type '(.+?)' is not assignable to type '(.+?)'/,
183
+ /Type '(.+?)' does not satisfy the constraint '(.+?)'/,
184
+ /Type '(.+?)' is missing the following properties from type '(.+?)'/,
185
+ ];
174
186
 
175
187
  const TS_RULES: Array<{
176
188
  re: RegExp;
@@ -317,7 +329,7 @@ const TS_RULES: Array<{
317
329
  },
318
330
  {
319
331
  re: /'(.+?)' has no exported member(?: named)? '(.+?)'/,
320
- result: '找不到$1 $2。',
332
+ result: '找不到接口$1 $2。',
321
333
  transforms: [transformNamespace, transformType],
322
334
  },
323
335
  {
@@ -474,6 +486,10 @@ export function translateDiagnosticMessage(message: string) {
474
486
  export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diagnostic) {
475
487
  const text = tsErrorDetail?.originalDiagnostic?.text;
476
488
  let node = minRange?.node;
489
+ const logicAncestor = node.getAncestor('Logic') || {} as any;
490
+ const { parentNode = { concept: '' } } = logicAncestor;
491
+ const isFELogic = ['BindEvent', 'View'].includes(parentNode.concept);
492
+
477
493
  // 有一些节点报错信息不向外暴露,缺失一些原生标签等等的展示
478
494
  if (node instanceof View || node instanceof ViewElement) {
479
495
  if (text.startsWith(`'nasl.ui' has no exported member named `)) {
@@ -569,6 +585,20 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
569
585
  tsErrorDetail.message = '自动推导不出类型!newList中有未知类型';
570
586
  }
571
587
  }
588
+
589
+ // 针对前端逻辑,有可能原因是找接口被增加鉴权方式导致
590
+ if (/Property '(.+?)' does not exist on type 'typeof (.+?)'/.exec(text) && isFELogic) {
591
+ // 如果存在 则 目标 Interface 更新为了 鉴权相关的,需要给出对应提示
592
+ const app = node.rootNode;
593
+ const modulePathList = (node as CallInterface)?.calleeNamespace?.split('.') || [];
594
+ modulePathList?.pop();
595
+ const targetInterface = getNodeByNodeCallee(app, (node as CallInterface).calleeKey);
596
+ console.log(targetInterface);
597
+ // const hasInterface = targetModule?.interfaces?.findIndex?.((item: Interface) => item.name === (node as CallInterface).calleeName) > -1;
598
+ if (targetInterface) {
599
+ tsErrorDetail.message = `${(node as CallInterface)?.calleeName}接口有鉴权,不支持在前端调用`;
600
+ }
601
+ }
572
602
  if (node instanceof Argument || node instanceof Anchor) {
573
603
  // if (/Type '(.+?)' is not assignable to type '(.+?)'./.exec(text)) {
574
604
  // }
@@ -747,6 +777,9 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
747
777
  return;
748
778
  }
749
779
  }
780
+ if (checkAStructure_(text)) {
781
+ return null;
782
+ }
750
783
  for (const rule of POST_RULES) {
751
784
  if (rule.re.test(tsErrorDetail.message)) {
752
785
  tsErrorDetail.message = tsErrorDetail.message.replace(rule.re, (value, index, oldStr) => {
@@ -774,3 +807,36 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
774
807
  ...tsErrorDetail,
775
808
  };
776
809
  }
810
+
811
+ export function checkAStructure_(errorText: string): any {
812
+ const index = TS_RULES_TYPE_INCONSISTENCY.findIndex((item) => item.exec(errorText));
813
+ if (index !== -1) {
814
+ const rule = TS_RULES_TYPE_INCONSISTENCY[index];
815
+ const cap = rule.exec(errorText);
816
+ if (rule === TS_RULES_TYPE_INCONSISTENCY[0] || rule === TS_RULES_TYPE_INCONSISTENCY[1]) {
817
+ cap.splice(1, 1);
818
+ }
819
+ if (((cap[1].startsWith('{') && cap[1].endsWith('}')) || (cap[1].startsWith('{') && cap[1].endsWith('...')))
820
+ && ((cap[2].startsWith('{') && cap[2].endsWith('}')) || (cap[2].startsWith('{') && cap[2].endsWith('...')))
821
+ && (cap[1].includes('__name: "AStructure_') && cap[2].includes('__name: "AStructure_'))) {
822
+ const x = sortTsString(transformType(cap[1]));
823
+ const y = sortTsString(transformType(cap[2]));
824
+ if (x === y) {
825
+ return true;
826
+ } else if (mapAstString.get(x) === y || mapAstString.get(y) === x) {
827
+ return true;
828
+ } else {
829
+ const regex = /Type '"AStructure_(.*)' is not assignable to type '"AStructure_(.*)'/;
830
+ const nameError = regex.exec(errorText);
831
+ const length1 = x.match(/:/g) ? x.match(/:/g).length : -1;
832
+ const length2 = y.match(/:/g) ? y.match(/:/g).length : -2;
833
+ if (nameError && length1 === length2) {
834
+ mapAstString.set(x, y);
835
+ mapAstString.set(y, x);
836
+ return true;
837
+ }
838
+ }
839
+ }
840
+ }
841
+ return false;
842
+ }
@@ -52,6 +52,7 @@
52
52
  "^az09-.$": "以小写字母、数字、'-'或'.'组成",
53
53
  "^azAZ09$": "以字母或数字组成",
54
54
  "^azAZ09-$": "以字母、数字或'-'组成",
55
+ "^az09-_$": "以小写字母、数字、'-'或'_'组成",
55
56
  "^azAZ09_$": "以字母、数字或'_'组成",
56
57
  "^azAZ09-_$": "以字母、数字、'-'或'_'组成",
57
58
  "without--": "不能连续出现中划线",
@@ -21,7 +21,13 @@ export default {
21
21
  url: {
22
22
  method: 'post',
23
23
  path: '/proxy/nasl-storage/api/storage/saveFrontendNasl',
24
- },
24
+ },
25
+ },
26
+ breakpoint: {
27
+ url: {
28
+ method: 'get',
29
+ path: '/proxy/nasl-storage/api/breakpoint',
30
+ },
25
31
  },
26
32
  // 获取存储类型列表
27
33
  databaseTypes: {
@@ -1,4 +1,5 @@
1
1
  import { App, LogicItem, Logic, Module, View, ViewElement, Argument, SelectMembers } from '../../concepts';
2
+ import { addBreakpointNodesFromApp } from '../../breakpoint';
2
3
  import { getConceptConstructor } from '../../decorators';
3
4
  import { config } from '../../config';
4
5
  import Vue from 'vue';
@@ -13,6 +14,7 @@ import * as jsoner from './jsoner';
13
14
  export const batchQuery = storageService.batchQuery;
14
15
  export const batchAction = storageService.batchAction;
15
16
  export const batchInstruct = storageService.batchInstruct;
17
+ export const breakpoint = storageService.breakpoint;
16
18
 
17
19
  let tabTimestamp: string;
18
20
  export const databaseTypes = storageService.databaseTypes;
@@ -177,7 +179,7 @@ async function doAction(app: any, actionItem: any) {
177
179
  const emitTarget = event?.originEvent?.target;
178
180
  const _path: string = event.originEvent.path;
179
181
  const _root = _path.split('.')?.[1] || '';
180
- if (['dataSources', 'processes', 'logics', 'enums', 'structures', 'interfaces', 'interfaceDependencies', 'configuration', 'dependencies'].some((item) => _root.startsWith(item))) {
182
+ if (['backend', 'overriddenLogics', 'dataSources', 'processes', 'logics', 'enums', 'structures', 'interfaces', 'interfaceDependencies', 'configuration', 'dependencies', 'authLogics', 'authLogicsForCallInterface'].some((item) => _root.startsWith(item))) {
181
183
  hasBackEnd = true;
182
184
  }
183
185
  if (emitTarget.concept === 'Logic') {
@@ -202,21 +204,22 @@ async function doAction(app: any, actionItem: any) {
202
204
  const isDelete = event?.originEvent?.action === 'delete';
203
205
  const isUpdateAuth = event?.originEvent?.action === 'update' && event?.originEvent?.object && 'auth' in event?.originEvent?.object;
204
206
  if (isDelete || isUpdateAuth) {
205
- const app = emitTarget.app;
206
- const diffArr: string[] = [];
207
- emitTarget.logics.forEach((logic: Logic) => {
208
- if (logic.body.length > 2) {
209
- logic.body.forEach((it: LogicItem) => {
210
- itemloop(it, app, diffArr);
211
- });
212
- }
213
- });
214
- const result = diffArr.filter((item) => item.startsWith('app') || item.startsWith('extensions'));
215
- if (result.length) {
216
- hasBackEnd = true;
217
- }
218
- emitTarget.children.forEach((item: View | ViewElement) => loopEle(item, isDelete));
219
- emitTarget.elements.forEach((item: View | ViewElement) => loopEle(item, isDelete));
207
+ hasBackEnd = true;
208
+ // const app = emitTarget.app;
209
+ // const diffArr: string[] = [];
210
+ // emitTarget.logics.forEach((logic: Logic) => {
211
+ // if (logic.body.length > 2) {
212
+ // logic.body.forEach((it: LogicItem) => {
213
+ // itemloop(it, app, diffArr);
214
+ // });
215
+ // }
216
+ // });
217
+ // const result = diffArr.filter((item) => item.startsWith('app') || item.startsWith('extensions'));
218
+ // if (result.length) {
219
+ // hasBackEnd = true;
220
+ // }
221
+ // emitTarget.children.forEach((item: View | ViewElement) => loopEle(item, isDelete));
222
+ // emitTarget.elements.forEach((item: View | ViewElement) => loopEle(item, isDelete));
220
223
  }
221
224
  hasFrontEnd = true;
222
225
  }
@@ -612,6 +615,11 @@ export function handleApp(app: any) {
612
615
  });
613
616
  }
614
617
 
618
+ type BreakpointItem = any | {
619
+ path: string,
620
+ breakpointStatus: null | 'ENABLED' | 'DISABLED',
621
+ };
622
+
615
623
  /**
616
624
  * 加载 app
617
625
  * @param appId 如果是从文件读,就不需要传
@@ -621,34 +629,57 @@ export async function loadApp(appId?: string) {
621
629
  let app: App;
622
630
  if (config.storage.protocol === 'http') {
623
631
  console.time('batchQuery');
624
- // 请求
625
- const res = await storageService.batchQuery({
626
- body: [
627
- {
628
- path: 'app',
629
- // excludes: ['views'],
632
+ const promises = [
633
+ storageService.batchQuery({
634
+ body: [
635
+ {
636
+ path: 'app',
637
+ // excludes: ['views'],
638
+ },
639
+ ],
640
+ headers: {
641
+ appId,
642
+ checkTabOpenTime: 'true',
643
+ // 其他封装在 storageService 里了
630
644
  },
631
- ],
632
- headers: {
633
- appId,
634
- checkTabOpenTime: 'true',
635
- // 其他封装在 storageService 里了
636
- },
637
- config: {
638
- shortResponse: false,
639
- },
640
- });
645
+ config: {
646
+ shortResponse: false,
647
+ },
648
+ }),
649
+ storageService.breakpoint({
650
+ body: { appId },
651
+ }),
652
+ ];
653
+
654
+ const [batchQueryRes, breakpointRes] = await Promise.all(promises);
655
+
656
+ // 请求
641
657
  console.timeEnd('batchQuery');
642
658
 
643
- tabTimestamp = res?.headers?.tabtimestamp;
644
- const data = res?.data?.result;
659
+ tabTimestamp = batchQueryRes?.headers?.tabtimestamp;
660
+ const data = batchQueryRes?.data?.result;
645
661
 
646
662
  console.time('new App');
647
663
  app = new App(Object.assign(data?.[0], { id: appId }));
664
+
665
+ breakpointRes?.forEach((item: BreakpointItem = {}) => {
666
+ const { path, breakpointStatus } = item;
667
+
668
+ if (breakpointStatus) {
669
+ const node = app.findNodeByPath(path);
670
+
671
+ if (node) {
672
+ node.breakpoint = breakpointStatus;
673
+ }
674
+ }
675
+ });
648
676
  console.timeEnd('new App');
677
+
649
678
  if (!app.id) {
650
679
  app.id = appId;
651
680
  }
681
+
682
+ addBreakpointNodesFromApp(app);
652
683
  } else if (config.storage.protocol === 'mock') {
653
684
  app = new App({
654
685
  id: appId,
@@ -681,7 +712,7 @@ export async function loadApp(appId?: string) {
681
712
  }
682
713
 
683
714
  // 在app上挂载所有的数据库类型
684
- async function mountDatabaseTypes(app: App) {
715
+ export async function mountDatabaseTypes(app: App) {
685
716
  if (!app.__databaseTypeMap) {
686
717
  app.__databaseTypeMap = {};
687
718
  }
@@ -49,8 +49,8 @@ export default {
49
49
  },
50
50
  saveFrontendNasl({ body }: { body: any }) {
51
51
  const appData = (window as any).appData;
52
-
53
- return service.saveFrontendNasl({
52
+
53
+ return service.saveFrontendNasl({
54
54
  body,
55
55
  headers: {
56
56
  appId: appData?.appId,
@@ -59,8 +59,24 @@ export default {
59
59
  });
60
60
  },
61
61
  databaseTypes({ query }: { query: any }) {
62
+ const appData = (window as any).appData;
63
+
62
64
  return service.databaseTypes({
65
+ headers: {
66
+ appId: appData?.appId,
67
+ },
63
68
  query,
64
69
  });
65
70
  },
71
+ breakpoint({ body }: { body: any }) {
72
+ const appData = (window as any).appData;
73
+
74
+ return service.breakpoint({
75
+ body,
76
+ headers: {
77
+ appId: appData?.appId,
78
+ skipVersionCheck: true,
79
+ },
80
+ });
81
+ },
66
82
  };
@@ -0,0 +1,32 @@
1
+ const babel = require('@babel/core');
2
+ const generate = require('@babel/generator').default;
3
+ const traverse = require('@babel/traverse').default;
4
+ const t = require('@babel/types');
5
+
6
+ export function sortTsString(tsString: string): string {
7
+ const str = `type a = ${tsString}`;
8
+ const ast = babel.parseSync(str, {
9
+ filename: 'result.ts',
10
+ presets: [require('@babel/preset-typescript')],
11
+ });
12
+ const visitor = {
13
+ TSTypeLiteral(path: any) {
14
+ path.node.members.sort((a: any, b: any) => {
15
+ if (a.type === 'TSPropertySignature' && b.type === 'TSPropertySignature') {
16
+ return a.key.name.localeCompare(b.key.name);
17
+ }
18
+ return 0;
19
+ });
20
+ },
21
+ ArrayExpression(path: any) {
22
+ path.node.elements.sort((a: any, b: any) => {
23
+ if (a.type === 'ObjectExpression' && b.type === 'ObjectExpression') {
24
+ return t.isIdentifier(a.properties[0].key) && t.isIdentifier(b.properties[0].key) ? a.properties[0].key.name.localeCompare(b.properties[0].key.name) : 0;
25
+ }
26
+ return 0;
27
+ });
28
+ },
29
+ };
30
+ traverse(ast, visitor);
31
+ return generate(ast).code;
32
+ }
@@ -129,9 +129,9 @@ function handleNext<T extends INode>(func: (next: INodeInfo<T>) => any, current:
129
129
  }
130
130
 
131
131
  function checkCircular<T>(next: INodeInfo<T>) {
132
- if (next.stack.length > 100 || next.key > 10000 || next.index > 10000)
132
+ if (next.stack.length > 100 || Number(next.key) > 10000 || next.index > 10000)
133
133
  console.error(next);
134
- if (next.stack.length > 110 || next.key > 10010 || next.index > 10010)
134
+ if (next.stack.length > 110 || Number(next.key) > 10010 || next.index > 10010)
135
135
  throw new Error('Circular traverse!');
136
136
  return next.stack.includes(next.node);
137
137
  }