@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
@@ -0,0 +1,490 @@
1
+ import Param from './Param__';
2
+ import { TranslatorState, shiftState, withSourceMap } from '../translator';
3
+ import { getNodeByNodeCallee } from '@nasl/automate/engine/utils';
4
+ import AuthLogicForCallInterface from './AuthLogicForCallInterface__';
5
+ import LogicItem from './LogicItem__';
6
+
7
+ //================================================================================
8
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
9
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
10
+ //================================================================================
11
+ import { EventPayload, Params } from '../common/EventEmitter';
12
+ import { concept, excludedInJSON, property } from '../decorators';
13
+
14
+ import * as utils from '../utils';
15
+ import { v4 as uuidv4 } from 'uuid';
16
+ import BaseNode from '../common/BaseNode';
17
+ import classMap from '../common/classMap';
18
+ import Argument from './Argument__';
19
+ import CallInterface from './CallInterface__';
20
+
21
+ /**
22
+ * 调用接口
23
+ */
24
+ @concept('调用接口')
25
+ export class CallAuthInterface extends CallInterface {
26
+ /**
27
+ * 产品概念
28
+ */
29
+ @property()
30
+ concept: 'CallAuthInterface' = 'CallAuthInterface';
31
+
32
+ /**
33
+ * 鉴权逻辑所需参数
34
+ */
35
+ @property('Argument')
36
+ authArguments: Array<Argument> = [];
37
+
38
+ /**
39
+ * @param source 需要合并的部分参数
40
+ */
41
+ constructor(source?: Partial<CallAuthInterface>) {
42
+ source = Object.assign({}, CallAuthInterface.getDefaultOptions(), source);
43
+ super(source);
44
+ super.subConstructor(source);
45
+ }
46
+ getClassName() {
47
+ return 'CallAuthInterface';
48
+ }
49
+
50
+ static from(source: any, parentNode?: any, parentKey?: string): CallAuthInterface {
51
+ return super.from(source, parentNode, parentKey) as CallAuthInterface;
52
+ }
53
+
54
+ getArgumentExistingNames(excludedList: Array<Argument> = []) {
55
+ const excludedSet = new Set(excludedList);
56
+ return ((this.authArguments as Argument[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
57
+ }
58
+ getArgumentUniqueName(name = 'argument1') {
59
+ return utils.unique(name, this.getArgumentExistingNames(), undefined, false);
60
+ }
61
+
62
+ /**
63
+ * 插入实际参数
64
+ * @internal
65
+ * @param name 实际参数名称,如果不填会自动生成一个唯一名称
66
+ */
67
+ _insertArgumentAt(name: string, index: number): Argument;
68
+
69
+ /**
70
+ * 插入实际参数
71
+ * @internal
72
+ * @param argumentOptions 实际参数参数
73
+ */
74
+ _insertArgumentAt(argumentOptions: Partial<Argument>, index: number): Argument;
75
+
76
+ /**
77
+ * 插入实际参数
78
+ * @internal
79
+ * @param argument 已有的实际参数实例
80
+ */
81
+ _insertArgumentAt(argument: Argument, index: number): Argument;
82
+
83
+ _insertArgumentAt(options: string | Partial<Argument> | Argument, index: number) {
84
+ const argumentOptions: any = {};
85
+ const relationOptions = { parentNode: this, parentKey: 'authArguments' };
86
+ let argument: Argument;
87
+ if (!options) {
88
+ argument = Argument.from({
89
+ ...argumentOptions,
90
+ name: this.getArgumentUniqueName(),
91
+ }, this, 'authArguments');
92
+ } else if (typeof options === 'string') {
93
+ argument = Argument.from({
94
+ ...argumentOptions,
95
+ name: options,
96
+ }, this, 'authArguments');
97
+ } else if (options instanceof Argument) {
98
+ options.ensureDelete(); // 同一实例不支持多处存在
99
+ argument = options;
100
+ Object.assign(argument, relationOptions);
101
+ } else {
102
+ argument = Argument.from({
103
+ ...argumentOptions,
104
+ ...options,
105
+ }, this, 'authArguments');
106
+ }
107
+ this.authArguments.splice(index, 0, argument);
108
+ return argument;
109
+ }
110
+
111
+ /**
112
+ * 插入实际参数
113
+ * @param name 实际参数名称,如果不填会自动生成一个唯一名称
114
+ */
115
+ insertArgumentAt(name: string, index: number): Argument;
116
+
117
+ /**
118
+ * 插入实际参数
119
+ * @param argumentOptions 实际参数参数
120
+ */
121
+ insertArgumentAt(argumentOptions: Partial<Argument>, index: number): Argument;
122
+
123
+ /**
124
+ * 插入实际参数
125
+ * @param argument 已有的实际参数实例
126
+ */
127
+ insertArgumentAt(argument: Argument, index: number): Argument;
128
+
129
+ insertArgumentAt(options: string | Partial<Argument> | Argument, index: number) {
130
+ const node = this._insertArgumentAt(options as any, index);
131
+ node.create({
132
+ index,
133
+ parentNode: this,
134
+ parentKey: 'authArguments',
135
+ });
136
+ return node;
137
+ }
138
+
139
+ /**
140
+ * 添加实际参数
141
+ * @internal
142
+ * @param name 实际参数名称,如果不填会自动生成一个唯一名称
143
+ */
144
+ _addArgument(name?: string): Argument;
145
+
146
+ /**
147
+ * 添加实际参数
148
+ * @internal
149
+ * @param argumentOptions 实际参数参数
150
+ */
151
+ _addArgument(argumentOptions: Partial<Argument>): Argument;
152
+
153
+ /**
154
+ * 添加实际参数
155
+ * @internal
156
+ * @param argument 已有的实际参数实例
157
+ */
158
+ _addArgument(argument: Argument): Argument;
159
+
160
+ _addArgument(options?: string | Partial<Argument> | Argument) {
161
+ const index = this.authArguments.length;
162
+ return this._insertArgumentAt(options as any, index);
163
+ }
164
+
165
+ /**
166
+ * 添加实际参数
167
+ * @internal
168
+ * @param name 实际参数名称,如果不填会自动生成一个唯一名称
169
+ */
170
+ addArgument(name?: string): Argument;
171
+
172
+ /**
173
+ * 添加实际参数
174
+ * @param argumentOptions 实际参数参数
175
+ */
176
+ addArgument(argumentOptions: Partial<Argument>): Argument;
177
+
178
+ /**
179
+ * 添加实际参数
180
+ * @param argument 已有的实际参数实例
181
+ */
182
+ addArgument(argument: Argument): Argument;
183
+
184
+ addArgument(options?: string | Partial<Argument> | Argument) {
185
+ const node = this._addArgument(options as any);
186
+ const index = this.authArguments.indexOf(node);
187
+ node.create({
188
+ index,
189
+ parentNode: this,
190
+ parentKey: 'authArguments',
191
+ });
192
+ return node;
193
+ }
194
+
195
+ /**
196
+ * 删除实际参数
197
+ * @param name 实际参数名称
198
+ */
199
+ removeArgument(name: string): void;
200
+
201
+ /**
202
+ * 删除实际参数
203
+ * @param argument 已有的实际参数实例
204
+ */
205
+ removeArgument(argument: Argument): void;
206
+
207
+ removeArgument(options: string | Argument) {
208
+ let argument: Argument;
209
+ if (typeof options === 'string') {
210
+ argument = (this.authArguments as Argument[]).find((item) => item.name === options);
211
+ if (!argument) {
212
+ throw new Error('找不到实际参数 ' + options);
213
+ }
214
+ } else {
215
+ argument = options;
216
+ }
217
+ return argument.delete();
218
+ }
219
+
220
+ __removeLogicItem(logicItem: LogicItem) {
221
+ const parentKey = logicItem.parentKey;
222
+ const params: Params = {
223
+ parentNode: this,
224
+ parentKey,
225
+ index: -1,
226
+ object: null,
227
+ oldObject: logicItem,
228
+ };
229
+ if (parentKey) {
230
+ params.parentKey = parentKey;
231
+ if (Array.isArray((this as any)[parentKey])) {
232
+ const index = (this as any)[parentKey].indexOf(logicItem);
233
+ ~index && (this as any)[parentKey].splice(index, 1);
234
+ params.index = index;
235
+ } else if ((this as any)[parentKey] === logicItem) {
236
+ params.index = 0;
237
+ (this as any)[parentKey] = undefined;
238
+ }
239
+ }
240
+ return params;
241
+ }
242
+
243
+ //================================================================================
244
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
245
+ // 自动生成的代码已结束。下面可以手动编写。
246
+ //================================================================================
247
+ /**
248
+ *删除所有的 Argument
249
+ */
250
+ removeAllArgument():void {
251
+ const snapshot = this.authArguments.slice();
252
+ snapshot.forEach((argument) => {
253
+ this.removeArgument(argument);
254
+ });
255
+ }
256
+
257
+ /**
258
+ * 批量增加AuthArgument
259
+ */
260
+ batchAddArgument(args: Argument[]):void {
261
+ args.forEach((argument) => {
262
+ this.addArgument(argument);
263
+ });
264
+ }
265
+
266
+ _insertNormalArgumentAt(options: Partial<Argument> | Argument, index: number) {
267
+ const argumentOptions: any = {};
268
+ const relationOptions = { parentNode: this, parentKey: 'arguments' };
269
+ let argument: Argument;
270
+ if (options instanceof Argument) {
271
+ options.ensureDelete(); // 同一实例不支持多处存在
272
+ argument = options;
273
+ Object.assign(argument, relationOptions);
274
+ } else {
275
+ argument = Argument.from({
276
+ ...argumentOptions,
277
+ ...options,
278
+ }, this, 'arguments');
279
+ }
280
+ this.arguments.splice(index, 0, argument);
281
+ return argument;
282
+ }
283
+
284
+ _addNormalArgument(options?: string | Partial<Argument> | Argument) {
285
+ const index = this.arguments.length;
286
+ return this._insertNormalArgumentAt(options as any, index);
287
+ }
288
+
289
+ /**
290
+ * 批量增加Argument
291
+ */
292
+ addNormalArgument(options?: Partial<Argument> | Argument) {
293
+ const node = this._addNormalArgument(options as any);
294
+ const index = this.arguments.indexOf(node);
295
+ node.create({
296
+ index,
297
+ parentNode: this,
298
+ parentKey: 'arguments',
299
+ });
300
+ return node;
301
+ }
302
+
303
+ get tsAuthLogicKey() {
304
+ if (!this.calleeName) {
305
+ return '__IDENTIFIER__';
306
+ }
307
+ const tsAuthLogicNamespace = 'app.authLogicsForCallInterface';
308
+ const callee = getNodeByNodeCallee(this.app, this.calleewholeKey);
309
+ const authLogicName = callee.authLogic;
310
+ return authLogicName ? `${tsAuthLogicNamespace}.${authLogicName}` : '__IDENTIFIER__';
311
+ }
312
+
313
+ get tsCalleeKey(): string {
314
+ const tsCalleeNamespace = this.tsCalleeNamespace;
315
+ // http://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=2653024591642368
316
+ const calleeName = `${this.tsCalleeName}_auth_$_api`;
317
+ return calleeName ? `${tsCalleeNamespace}.${calleeName}` : '__IDENTIFIER__';
318
+ }
319
+
320
+ @withSourceMap()
321
+ toEmbeddedTS(state?: TranslatorState): string {
322
+ let code = this.tsAuthLogicKey;
323
+ // 目前没有任何其他范型,故这里先支持默认俩范型
324
+ // FIXME
325
+ code += `<Parameters<typeof ${this.tsCalleeKey}>[0], ReturnType<typeof ${this.tsCalleeKey}>>`;
326
+ code += '(';
327
+ const completeAuthArguments = this.completeAuthArguments;
328
+ if (completeAuthArguments?.length) {
329
+ code += '{';
330
+ completeAuthArguments?.forEach((arg, index) => {
331
+ code += arg?.toEmbeddedTS(shiftState(state, code), arg.paramRequired, true);
332
+ code += ',';
333
+ });
334
+ code += `api: `;
335
+ code += this.tsCalleeKey;
336
+ const completeArguments = this.completeArguments;
337
+ code += '(';
338
+ if (completeArguments?.length) {
339
+ code += '{';
340
+ completeArguments?.forEach((arg, index) => {
341
+ code += arg?.toEmbeddedTS(shiftState(state, code), arg.paramRequired, true);
342
+ if (index !== this.arguments?.length - 1)
343
+ code += ', ';
344
+ });
345
+ code += '}';
346
+ }
347
+ code += ')';
348
+ code += '}';
349
+ } else {
350
+ code += '{';
351
+ code += 'api: ';
352
+ code += this.tsCalleeKey;
353
+ const completeArguments = this.completeArguments;
354
+ code += '(';
355
+ if (completeArguments?.length) {
356
+ code += '{';
357
+ completeArguments?.forEach((arg, index) => {
358
+ code += arg?.toEmbeddedTS(shiftState(state, code), arg.paramRequired, true);
359
+ if (index !== this.arguments?.length - 1)
360
+ code += ', ';
361
+ });
362
+ code += '}';
363
+ }
364
+ code += ')';
365
+ code += '}';
366
+ }
367
+
368
+ code += ')';
369
+
370
+ if (this.parentNode.concept !== 'Argument'
371
+ && this.parentKey !== 'test'
372
+ && this.parentKey !== 'patterns'
373
+ && this.parentNode.concept !== 'Assignment'
374
+ && this.parentNode.concept !== 'ForEachStatement'
375
+ && this.parentNode.concept !== 'SelectMembers'
376
+ && this.parentNode.concept !== 'BinaryExpression'
377
+ && this.parentNode.concept !== 'MemberExpression'
378
+ && this.parentNode.concept !== 'StringInterpolation'
379
+ && !['NewMap', 'NewList'].includes(this.parentNode.concept)) {
380
+ code += ';';
381
+ }
382
+ code += '\n';
383
+ return code;
384
+ }
385
+
386
+ // @withSourceMap()
387
+ // toEmbeddedTSForApi(state?: TranslatorState): string {
388
+
389
+ // return code;
390
+ // }
391
+
392
+ get completeAuthArguments() {
393
+ const node = this.getCallNode(); //AuthInterface
394
+ const authLogic = node?.authLogic;
395
+ if (!authLogic) {
396
+ return [];
397
+ }
398
+ const targetAuthLogic = this.app.authLogicsForCallInterface.find((logic) => logic.name === authLogic);
399
+ const logicParam: Param[] = targetAuthLogic?.authParams || [];
400
+ const Arguments: Argument[] = [];
401
+
402
+ if (this.authArguments?.length) {
403
+ this.authArguments.forEach((arg) => {
404
+ const idx = logicParam.findIndex((params) => arg.keyword === params.name);
405
+ const param = logicParam[idx];
406
+
407
+ arg.paramRequired = param?.required;
408
+ arg.paramTypeAnnotation = undefined;
409
+ arg.paramDefaultValue = undefined;
410
+ // 取到是不是必填放入参数中
411
+ if (param && !arg.expression) {
412
+ // 非必填时 才会有默认值
413
+ // 因为之前接口这里的必填非必填,一直是有值的,而且不允许修改
414
+ arg.paramTypeAnnotation = param.typeAnnotation;
415
+ arg.paramDefaultValue = param.defaultValue;
416
+ }
417
+ Arguments.push(arg);
418
+ });
419
+ }
420
+ return Arguments;
421
+ }
422
+
423
+ deleteCalleeArg(argIndex: number) {
424
+ /**
425
+ * 传递过下标来,然后直接移动到最后结束
426
+ * 如果原来就是最后一个位置就不移动了
427
+ */
428
+ if (typeof argIndex === 'number') {
429
+ if (!this.authArguments[argIndex]?.expression) {
430
+ return this.authArguments[argIndex]?.delete();
431
+ }
432
+ if (argIndex !== this.authArguments.length - 1) {
433
+ // 如果本身没有值就直接删除
434
+ this.authArguments[argIndex]?.moveNode({
435
+ sourceNode: this.authArguments[this.arguments.length - 1],
436
+ position: 'insertAfter',
437
+ });
438
+ }
439
+ }
440
+ }
441
+
442
+ addCalleeArg(logic: AuthLogicForCallInterface) {
443
+ const newArgs = this.authArguments.map((argument) =>
444
+ Argument.from({
445
+ ...argument,
446
+ }, this));
447
+ const relationOptions = { parentNode: this, parentKey: 'authArguments' };
448
+ /**
449
+ * 当前两个参数对应上,添加的时候,logic会比参数位内容多,就添加一个 argment
450
+ */
451
+ if (logic.authParams.length >= newArgs.length) {
452
+ logic.authParams.forEach((param: Param, index: number) => {
453
+ const arg = newArgs[index];
454
+ if (!arg) {
455
+ const newParam = Argument.from({
456
+ keyword: param.name,
457
+ }, this);
458
+ Object.assign(newParam, relationOptions);
459
+ newArgs.push(newParam);
460
+ } else {
461
+ arg.keyword = param.name;
462
+ }
463
+ });
464
+ } else {
465
+ /**
466
+ * 当前calllogic上数量比logic参数还多,他就需要找一个arg使他变成可用的参数
467
+ */
468
+ newArgs.forEach((arg: Argument, index: number) => {
469
+ const param = logic.authParams[index];
470
+ if (param) {
471
+ arg.keyword = param.name;
472
+ }
473
+ });
474
+ }
475
+ this.update({
476
+ authArguments: newArgs,
477
+ });
478
+ }
479
+ //================================================================================
480
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
481
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
482
+ //================================================================================
483
+ }
484
+
485
+ classMap.CallAuthInterface = CallAuthInterface;
486
+ export default CallAuthInterface;
487
+ //================================================================================
488
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
489
+ // 自动生成的代码已结束。下面可以手动编写。
490
+ //================================================================================
@@ -30,7 +30,7 @@ export class CallInterface extends LogicItem {
30
30
  * 产品概念
31
31
  */
32
32
  @property()
33
- concept: 'CallInterface' = 'CallInterface';
33
+ concept: 'CallInterface' | 'CallAuthInterface' = 'CallInterface';
34
34
 
35
35
  /**
36
36
  * 调用接口标题
@@ -231,9 +231,16 @@ export class CallInterface extends LogicItem {
231
231
  // 自动生成的代码已结束。下面可以手动编写。
232
232
  //================================================================================
233
233
 
234
+ /**
235
+ * 标识当前删除是否为鉴权方式更新导致的删除。
236
+ * 针对此种删除,删除逻辑已经处理,需要再此走 deleteCallNode 逻辑
237
+ */
238
+ @property('Boolean')
239
+ __authDelete: Boolean = false;
240
+
234
241
  // 删除调用接口时且接口无引用,删除接口和数据结构
235
242
  async deleteCallNode() {
236
- if (this.calleeKey !== '__IDENTIFIER__') {
243
+ if (this.calleeKey !== '__IDENTIFIER__' && !this.__authDelete) {
237
244
  (this as any).__deleteCallNodeTimer = setTimeout(async () => {
238
245
  clearTimeout((this as any).__deleteCallNodeTimer);
239
246
  // 计算之前选择的接口的引用次数
@@ -541,6 +548,7 @@ export class CallInterface extends LogicItem {
541
548
  Object.assign(argument, relationOptions);
542
549
  return argument;
543
550
  });
551
+
544
552
  if (this.app) {
545
553
  this.app.emit('collect:start', {
546
554
  actionMsg: `切换调用逻辑`,
@@ -404,6 +404,7 @@ export class CallLogic extends LogicItem {
404
404
  // 页面逻辑单独处理
405
405
  return `${this.view.getNamespace()}.${this.view.name}.logics.${this.calleeName}`;
406
406
  }
407
+ // "app.logics"
407
408
  return this.calleeNamespace + '.' + this.calleeName;
408
409
  }
409
410
  get calleeKey(): string {
@@ -464,6 +465,7 @@ export class CallLogic extends LogicItem {
464
465
  }
465
466
 
466
467
  _setCallee(logic: Logic) {
468
+ console.trace();
467
469
  this.calleeNamespace = logic.getNamespace();
468
470
  if (logic.parentNode instanceof View) {
469
471
  this.calleeNamespace = '';
@@ -707,7 +709,7 @@ export class CallLogic extends LogicItem {
707
709
  }
708
710
  }
709
711
  const completeArguments = this.completeArguments;
710
- // 全局逻辑
712
+ // 服务端逻辑
711
713
  if (!this.isViewLogic) {
712
714
  const logic = getNodeByNodeCallee(this.app, this.calleewholeKey, (key: string, tempPoint: any) => {
713
715
  // 处理 NASL 中未定义的假的节点