@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
@@ -45,12 +45,17 @@ const DataSource__1 = __importDefault(require("./DataSource__"));
45
45
  const Structure__1 = __importDefault(require("./Structure__"));
46
46
  const Enum__1 = __importDefault(require("./Enum__"));
47
47
  const Logic__1 = __importDefault(require("./Logic__"));
48
+ const OverriddenLogic__1 = __importDefault(require("./OverriddenLogic__"));
48
49
  const Interface__1 = __importDefault(require("./Interface__"));
50
+ const AuthInterface__1 = __importDefault(require("./AuthInterface__"));
49
51
  const Frontend__1 = __importDefault(require("./Frontend__"));
52
+ const Backend__1 = __importDefault(require("./Backend__"));
50
53
  const Process__1 = __importDefault(require("./Process__"));
51
54
  const Role__1 = __importDefault(require("./Role__"));
52
55
  const Configuration__1 = __importDefault(require("./Configuration__"));
53
56
  const Module__1 = __importDefault(require("./Module__"));
57
+ const AuthLogic__1 = __importDefault(require("./AuthLogic__"));
58
+ const AuthLogicForCallInterface__1 = __importDefault(require("./AuthLogicForCallInterface__"));
54
59
  /**
55
60
  * 应用
56
61
  */
@@ -112,13 +117,21 @@ let App = App_1 = class App extends BaseNode_1.default {
112
117
  */
113
118
  logics = [];
114
119
  /**
115
- * 接口列表
120
+ * 逻辑列表
121
+ */
122
+ overriddenLogics = [];
123
+ /**
124
+ * interfaces
116
125
  */
117
126
  interfaces = [];
118
127
  /**
119
128
  * 端列表
120
129
  */
121
130
  frontends = [];
131
+ /**
132
+ * 后端
133
+ */
134
+ backend = new Backend__1.default();
122
135
  /**
123
136
  * 流程列表
124
137
  */
@@ -143,6 +156,14 @@ let App = App_1 = class App extends BaseNode_1.default {
143
156
  * 集成
144
157
  */
145
158
  integration = undefined;
159
+ /**
160
+ * 暴露接口的接口鉴权
161
+ */
162
+ authLogics = [];
163
+ /**
164
+ * 调用接口的鉴权模板
165
+ */
166
+ authLogicsForCallInterface = [];
146
167
  /**
147
168
  * @param source 需要合并的部分参数
148
169
  */
@@ -418,6 +439,119 @@ let App = App_1 = class App extends BaseNode_1.default {
418
439
  });
419
440
  return node;
420
441
  }
442
+ _insertAuthLogicInAuthLogicsAt(options, index) {
443
+ const authLogicOptions = {};
444
+ const relationOptions = { parentNode: this, parentKey: 'authLogics' };
445
+ let authLogic;
446
+ if (!options) {
447
+ authLogic = AuthLogic__1.default.from({
448
+ ...authLogicOptions,
449
+ name: this.getAuthLogicUniqueName(),
450
+ }, this, 'authLogics');
451
+ }
452
+ else if (typeof options === 'string') {
453
+ authLogic = AuthLogic__1.default.from({
454
+ ...authLogicOptions,
455
+ name: options,
456
+ }, this, 'authLogics');
457
+ }
458
+ else if (options instanceof AuthLogic__1.default) {
459
+ options.ensureDelete(); // 同一实例不支持多处存在
460
+ authLogic = options;
461
+ Object.assign(authLogic, relationOptions);
462
+ }
463
+ else {
464
+ authLogic = AuthLogic__1.default.from({
465
+ ...authLogicOptions,
466
+ ...options,
467
+ }, this, 'authLogics');
468
+ }
469
+ this.authLogics.splice(index, 0, authLogic);
470
+ return authLogic;
471
+ }
472
+ insertAuthLogicInAuthLogicsAt(options, index) {
473
+ const node = this._insertAuthLogicInAuthLogicsAt(options, index);
474
+ node.create({
475
+ index,
476
+ parentNode: this,
477
+ parentKey: 'authLogics',
478
+ });
479
+ return node;
480
+ }
481
+ _addAuthLogicInAuthLogics(options) {
482
+ const index = this.authLogics.length;
483
+ return this._insertAuthLogicInAuthLogicsAt(options, index);
484
+ }
485
+ addAuthLogicInAuthLogics(options) {
486
+ const node = this._addAuthLogicInAuthLogics(options);
487
+ const index = this.authLogics.indexOf(node);
488
+ node.create({
489
+ index,
490
+ parentNode: this,
491
+ parentKey: 'authLogics',
492
+ });
493
+ return node;
494
+ }
495
+ getOverriddenLogicExistingNames(excludedList = []) {
496
+ const excludedSet = new Set(excludedList);
497
+ return (this.overriddenLogics || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
498
+ }
499
+ getOverriddenLogicUniqueName(name = 'overriddenLogic1') {
500
+ return utils.unique(name, this.getOverriddenLogicExistingNames(), undefined, true);
501
+ }
502
+ _insertOverriddenLogicAt(options, index) {
503
+ const overriddenLogicOptions = {};
504
+ const relationOptions = { parentNode: this, parentKey: 'overriddenLogics' };
505
+ let overriddenLogic;
506
+ if (!options) {
507
+ overriddenLogic = OverriddenLogic__1.default.from({
508
+ ...overriddenLogicOptions,
509
+ name: this.getOverriddenLogicUniqueName(),
510
+ }, this, 'overriddenLogics');
511
+ }
512
+ else if (typeof options === 'string') {
513
+ overriddenLogic = OverriddenLogic__1.default.from({
514
+ ...overriddenLogicOptions,
515
+ name: options,
516
+ }, this, 'overriddenLogics');
517
+ }
518
+ else if (options instanceof OverriddenLogic__1.default) {
519
+ options.ensureDelete(); // 同一实例不支持多处存在
520
+ overriddenLogic = options;
521
+ Object.assign(overriddenLogic, relationOptions);
522
+ }
523
+ else {
524
+ overriddenLogic = OverriddenLogic__1.default.from({
525
+ ...overriddenLogicOptions,
526
+ ...options,
527
+ }, this, 'overriddenLogics');
528
+ }
529
+ this.overriddenLogics.splice(index, 0, overriddenLogic);
530
+ return overriddenLogic;
531
+ }
532
+ insertOverriddenLogicAt(options, index) {
533
+ const node = this._insertOverriddenLogicAt(options, index);
534
+ node.create({
535
+ index,
536
+ parentNode: this,
537
+ parentKey: 'overriddenLogics',
538
+ });
539
+ return node;
540
+ }
541
+ _addOverriddenLogic(options) {
542
+ const index = 0;
543
+ return this._insertOverriddenLogicAt(options, index);
544
+ }
545
+ addOverriddenLogic(options) {
546
+ const node = this._addOverriddenLogic(options);
547
+ const index = this.overriddenLogics.indexOf(node);
548
+ node.create({
549
+ index,
550
+ parentNode: this,
551
+ parentKey: 'overriddenLogics',
552
+ });
553
+ return node;
554
+ }
421
555
  getInterfaceExistingNames(excludedList = []) {
422
556
  const excludedSet = new Set(excludedList);
423
557
  return (this.interfaces || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -425,7 +559,7 @@ let App = App_1 = class App extends BaseNode_1.default {
425
559
  getInterfaceUniqueName(name = 'Interface1') {
426
560
  return utils.unique(name, this.getInterfaceExistingNames(), undefined, true);
427
561
  }
428
- _insertInterfaceAt(options, index) {
562
+ _insertInterfaceInInterfacesAt(options, index) {
429
563
  const itfaceOptions = {};
430
564
  const relationOptions = { parentNode: this, parentKey: 'interfaces' };
431
565
  let itface;
@@ -455,8 +589,61 @@ let App = App_1 = class App extends BaseNode_1.default {
455
589
  this.interfaces.splice(index, 0, itface);
456
590
  return itface;
457
591
  }
458
- insertInterfaceAt(options, index) {
459
- const node = this._insertInterfaceAt(options, index);
592
+ insertInterfaceInInterfacesAt(options, index) {
593
+ const node = this._insertInterfaceInInterfacesAt(options, index);
594
+ node.create({
595
+ index,
596
+ parentNode: this,
597
+ parentKey: 'interfaces',
598
+ });
599
+ return node;
600
+ }
601
+ _addInterfaceInInterfaces(options) {
602
+ const index = 0;
603
+ return this._insertInterfaceInInterfacesAt(options, index);
604
+ }
605
+ addInterfaceInInterfaces(options) {
606
+ const node = this._addInterfaceInInterfaces(options);
607
+ const index = this.interfaces.indexOf(node);
608
+ node.create({
609
+ index,
610
+ parentNode: this,
611
+ parentKey: 'interfaces',
612
+ });
613
+ return node;
614
+ }
615
+ _insertAuthInterfaceInInterfacesAt(options, index) {
616
+ const itfaceOptions = {};
617
+ const relationOptions = { parentNode: this, parentKey: 'interfaces' };
618
+ let itface;
619
+ if (!options) {
620
+ itface = AuthInterface__1.default.from({
621
+ ...itfaceOptions,
622
+ name: this.getAuthInterfaceUniqueName(),
623
+ }, this, 'interfaces');
624
+ }
625
+ else if (typeof options === 'string') {
626
+ itface = AuthInterface__1.default.from({
627
+ ...itfaceOptions,
628
+ name: options,
629
+ }, this, 'interfaces');
630
+ }
631
+ else if (options instanceof AuthInterface__1.default) {
632
+ options.ensureDelete(); // 同一实例不支持多处存在
633
+ itface = options;
634
+ Object.assign(itface, relationOptions);
635
+ }
636
+ else {
637
+ itface = AuthInterface__1.default.from({
638
+ ...itfaceOptions,
639
+ ...options,
640
+ }, this, 'interfaces');
641
+ }
642
+ this.interfaces.splice(index, 0, itface);
643
+ return itface;
644
+ }
645
+ insertAuthInterfaceInInterfacesAt(options, index) {
646
+ const node = this._insertAuthInterfaceInInterfacesAt(options, index);
460
647
  node.create({
461
648
  index,
462
649
  parentNode: this,
@@ -464,12 +651,12 @@ let App = App_1 = class App extends BaseNode_1.default {
464
651
  });
465
652
  return node;
466
653
  }
467
- _addInterface(options) {
654
+ _addAuthInterfaceInInterfaces(options) {
468
655
  const index = 0;
469
- return this._insertInterfaceAt(options, index);
656
+ return this._insertAuthInterfaceInInterfacesAt(options, index);
470
657
  }
471
- addInterface(options) {
472
- const node = this._addInterface(options);
658
+ addAuthInterfaceInInterfaces(options) {
659
+ const node = this._addAuthInterfaceInInterfaces(options);
473
660
  const index = this.interfaces.indexOf(node);
474
661
  node.create({
475
662
  index,
@@ -771,6 +958,66 @@ let App = App_1 = class App extends BaseNode_1.default {
771
958
  });
772
959
  return node;
773
960
  }
961
+ getAuthLogicForCallInterfaceExistingNames(excludedList = []) {
962
+ const excludedSet = new Set(excludedList);
963
+ return (this.authLogicsForCallInterface || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
964
+ }
965
+ getAuthLogicForCallInterfaceUniqueName(name = 'authLogicForCallInterface1') {
966
+ return utils.unique(name, this.getAuthLogicForCallInterfaceExistingNames(), undefined, false);
967
+ }
968
+ _insertAuthLogicForCallInterfaceAt(options, index) {
969
+ const authLogicForCallInterfaceOptions = {};
970
+ const relationOptions = { parentNode: this, parentKey: 'authLogicsForCallInterface' };
971
+ let authLogicForCallInterface;
972
+ if (!options) {
973
+ authLogicForCallInterface = AuthLogicForCallInterface__1.default.from({
974
+ ...authLogicForCallInterfaceOptions,
975
+ name: this.getAuthLogicForCallInterfaceUniqueName(),
976
+ }, this, 'authLogicsForCallInterface');
977
+ }
978
+ else if (typeof options === 'string') {
979
+ authLogicForCallInterface = AuthLogicForCallInterface__1.default.from({
980
+ ...authLogicForCallInterfaceOptions,
981
+ name: options,
982
+ }, this, 'authLogicsForCallInterface');
983
+ }
984
+ else if (options instanceof AuthLogicForCallInterface__1.default) {
985
+ options.ensureDelete(); // 同一实例不支持多处存在
986
+ authLogicForCallInterface = options;
987
+ Object.assign(authLogicForCallInterface, relationOptions);
988
+ }
989
+ else {
990
+ authLogicForCallInterface = AuthLogicForCallInterface__1.default.from({
991
+ ...authLogicForCallInterfaceOptions,
992
+ ...options,
993
+ }, this, 'authLogicsForCallInterface');
994
+ }
995
+ this.authLogicsForCallInterface.splice(index, 0, authLogicForCallInterface);
996
+ return authLogicForCallInterface;
997
+ }
998
+ insertAuthLogicForCallInterfaceAt(options, index) {
999
+ const node = this._insertAuthLogicForCallInterfaceAt(options, index);
1000
+ node.create({
1001
+ index,
1002
+ parentNode: this,
1003
+ parentKey: 'authLogicsForCallInterface',
1004
+ });
1005
+ return node;
1006
+ }
1007
+ _addAuthLogicForCallInterface(options) {
1008
+ const index = this.authLogicsForCallInterface.length;
1009
+ return this._insertAuthLogicForCallInterfaceAt(options, index);
1010
+ }
1011
+ addAuthLogicForCallInterface(options) {
1012
+ const node = this._addAuthLogicForCallInterface(options);
1013
+ const index = this.authLogicsForCallInterface.indexOf(node);
1014
+ node.create({
1015
+ index,
1016
+ parentNode: this,
1017
+ parentKey: 'authLogicsForCallInterface',
1018
+ });
1019
+ return node;
1020
+ }
774
1021
  removeDataSource(options) {
775
1022
  let dataSource;
776
1023
  if (typeof options === 'string') {
@@ -892,6 +1139,19 @@ let App = App_1 = class App extends BaseNode_1.default {
892
1139
  }
893
1140
  return logic.delete();
894
1141
  }
1142
+ removeAuthLogicInAuthLogics(options) {
1143
+ let authLogic;
1144
+ if (typeof options === 'string') {
1145
+ authLogic = this.authLogics.find((item) => item.name === options);
1146
+ if (!authLogic) {
1147
+ throw new Error('找不到开放接口的鉴权逻辑 ' + options);
1148
+ }
1149
+ }
1150
+ else {
1151
+ authLogic = options;
1152
+ }
1153
+ return authLogic.delete();
1154
+ }
895
1155
  __removeLogic(logic) {
896
1156
  const parentKey = logic.parentKey;
897
1157
  const params = {
@@ -915,7 +1175,56 @@ let App = App_1 = class App extends BaseNode_1.default {
915
1175
  }
916
1176
  return params;
917
1177
  }
918
- removeInterface(options) {
1178
+ removeOverriddenLogic(options) {
1179
+ let overriddenLogic;
1180
+ if (typeof options === 'string') {
1181
+ overriddenLogic = this.overriddenLogics.find((item) => item.name === options);
1182
+ if (!overriddenLogic) {
1183
+ throw new Error('找不到逻辑 ' + options);
1184
+ }
1185
+ }
1186
+ else {
1187
+ overriddenLogic = options;
1188
+ }
1189
+ return overriddenLogic.delete();
1190
+ }
1191
+ __removeOverriddenLogic(overriddenLogic) {
1192
+ const parentKey = overriddenLogic.parentKey;
1193
+ const params = {
1194
+ parentNode: this,
1195
+ parentKey,
1196
+ index: -1,
1197
+ object: null,
1198
+ oldObject: overriddenLogic,
1199
+ };
1200
+ if (parentKey) {
1201
+ params.parentKey = parentKey;
1202
+ if (Array.isArray(this[parentKey])) {
1203
+ const index = this[parentKey].indexOf(overriddenLogic);
1204
+ ~index && this[parentKey].splice(index, 1);
1205
+ params.index = index;
1206
+ }
1207
+ else if (this[parentKey] === overriddenLogic) {
1208
+ params.index = 0;
1209
+ this[parentKey] = undefined;
1210
+ }
1211
+ }
1212
+ return params;
1213
+ }
1214
+ removeInterfaceInInterfaces(options) {
1215
+ let itface;
1216
+ if (typeof options === 'string') {
1217
+ itface = this.interfaces.find((item) => item.name === options);
1218
+ if (!itface) {
1219
+ throw new Error('找不到接口 ' + options);
1220
+ }
1221
+ }
1222
+ else {
1223
+ itface = options;
1224
+ }
1225
+ return itface.delete();
1226
+ }
1227
+ removeAuthInterfaceInInterfaces(options) {
919
1228
  let itface;
920
1229
  if (typeof options === 'string') {
921
1230
  itface = this.interfaces.find((item) => item.name === options);
@@ -987,6 +1296,42 @@ let App = App_1 = class App extends BaseNode_1.default {
987
1296
  }
988
1297
  return params;
989
1298
  }
1299
+ removeBackend(options) {
1300
+ let backend;
1301
+ if (typeof options === 'string') {
1302
+ backend = this.backend;
1303
+ if (!backend) {
1304
+ throw new Error('找不到后端 ' + options);
1305
+ }
1306
+ }
1307
+ else {
1308
+ backend = options;
1309
+ }
1310
+ return backend.delete();
1311
+ }
1312
+ __removeBackend(backend) {
1313
+ const parentKey = backend.parentKey;
1314
+ const params = {
1315
+ parentNode: this,
1316
+ parentKey,
1317
+ index: -1,
1318
+ object: null,
1319
+ oldObject: backend,
1320
+ };
1321
+ if (parentKey) {
1322
+ params.parentKey = parentKey;
1323
+ if (Array.isArray(this[parentKey])) {
1324
+ const index = this[parentKey].indexOf(backend);
1325
+ ~index && this[parentKey].splice(index, 1);
1326
+ params.index = index;
1327
+ }
1328
+ else if (this[parentKey] === backend) {
1329
+ params.index = 0;
1330
+ this[parentKey] = undefined;
1331
+ }
1332
+ }
1333
+ return params;
1334
+ }
990
1335
  removeProcess(options) {
991
1336
  let process;
992
1337
  if (typeof options === 'string') {
@@ -1180,6 +1525,42 @@ let App = App_1 = class App extends BaseNode_1.default {
1180
1525
  }
1181
1526
  return params;
1182
1527
  }
1528
+ removeAuthLogicForCallInterface(options) {
1529
+ let authLogicForCallInterface;
1530
+ if (typeof options === 'string') {
1531
+ authLogicForCallInterface = this.authLogicsForCallInterface.find((item) => item.name === options);
1532
+ if (!authLogicForCallInterface) {
1533
+ throw new Error('找不到调用的鉴权逻辑 ' + options);
1534
+ }
1535
+ }
1536
+ else {
1537
+ authLogicForCallInterface = options;
1538
+ }
1539
+ return authLogicForCallInterface.delete();
1540
+ }
1541
+ __removeAuthLogic(authLogic) {
1542
+ const parentKey = authLogic.parentKey;
1543
+ const params = {
1544
+ parentNode: this,
1545
+ parentKey,
1546
+ index: -1,
1547
+ object: null,
1548
+ oldObject: authLogic,
1549
+ };
1550
+ if (parentKey) {
1551
+ params.parentKey = parentKey;
1552
+ if (Array.isArray(this[parentKey])) {
1553
+ const index = this[parentKey].indexOf(authLogic);
1554
+ ~index && this[parentKey].splice(index, 1);
1555
+ params.index = index;
1556
+ }
1557
+ else if (this[parentKey] === authLogic) {
1558
+ params.index = 0;
1559
+ this[parentKey] = undefined;
1560
+ }
1561
+ }
1562
+ return params;
1563
+ }
1183
1564
  //================================================================================
1184
1565
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1185
1566
  // 自动生成的代码已结束。下面可以手动编写。
@@ -1390,7 +1771,25 @@ let App = App_1 = class App extends BaseNode_1.default {
1390
1771
  // 同名的依赖库 只启用第一个
1391
1772
  // (options as Module).enable = hasSameVersion;
1392
1773
  }
1774
+ // 导入依赖库的时候如果有logic 且logic 可以被覆写 需要在app overideLogic 新增一个
1775
+ // 但是导入局部模板的时候已经手动新增了 这里就不需要了
1776
+ // 当依赖库被删除 的时候同样要删除 overideLogic
1777
+ // 支持局部模板导出导入overideLogic
1778
+ // 只复制 depLogic 输入输出参数
1393
1779
  const node = this.addModuleInDependencies(options);
1780
+ if (node?.logics && node?.logics.length > 0) {
1781
+ node.logics.forEach((logic) => {
1782
+ if (logic?.overridable) {
1783
+ const existing = this.overriddenLogics.find((ol) => ol.name === logic.name);
1784
+ !existing && this.addOverriddenLogic({
1785
+ name: logic.name,
1786
+ overriddenModule: node.name,
1787
+ returns: logic.returns.map((r) => r.toJSON()),
1788
+ params: logic.params.map((r) => r.toJSON()),
1789
+ });
1790
+ }
1791
+ });
1792
+ }
1394
1793
  // 启用的依赖库才创建数据源
1395
1794
  // if (node.enable && node.dataSources) {
1396
1795
  if (node.dataSources) {
@@ -1658,6 +2057,16 @@ let App = App_1 = class App extends BaseNode_1.default {
1658
2057
  return sysPrefixPath;
1659
2058
  }
1660
2059
  __databaseTypeMap = {};
2060
+ getAuthLogicExistingNames(excludedList = []) {
2061
+ const excludedSet = new Set(excludedList);
2062
+ return (this.authLogics || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
2063
+ }
2064
+ getAuthLogicUniqueName(name = 'authentication1') {
2065
+ return utils.unique(name, this.getAuthLogicExistingNames(), undefined, true);
2066
+ }
2067
+ getAuthInterfaceUniqueName(name = 'authInterface1') {
2068
+ // never used
2069
+ }
1661
2070
  };
1662
2071
  __decorate([
1663
2072
  (0, decorators_1.property)()
@@ -1702,11 +2111,17 @@ __decorate([
1702
2111
  (0, decorators_1.property)('Logic')
1703
2112
  ], App.prototype, "logics", void 0);
1704
2113
  __decorate([
1705
- (0, decorators_1.property)('Interface')
2114
+ (0, decorators_1.property)('OverriddenLogic')
2115
+ ], App.prototype, "overriddenLogics", void 0);
2116
+ __decorate([
2117
+ (0, decorators_1.property)('Interface | AuthInterface')
1706
2118
  ], App.prototype, "interfaces", void 0);
1707
2119
  __decorate([
1708
2120
  (0, decorators_1.property)('Frontend')
1709
2121
  ], App.prototype, "frontends", void 0);
2122
+ __decorate([
2123
+ (0, decorators_1.property)('Backend')
2124
+ ], App.prototype, "backend", void 0);
1710
2125
  __decorate([
1711
2126
  (0, decorators_1.property)('Process')
1712
2127
  ], App.prototype, "processes", void 0);
@@ -1725,6 +2140,12 @@ __decorate([
1725
2140
  __decorate([
1726
2141
  (0, decorators_1.property)('Integration')
1727
2142
  ], App.prototype, "integration", void 0);
2143
+ __decorate([
2144
+ (0, decorators_1.property)('AuthLogic')
2145
+ ], App.prototype, "authLogics", void 0);
2146
+ __decorate([
2147
+ (0, decorators_1.property)('AuthLogicForCallInterface')
2148
+ ], App.prototype, "authLogicsForCallInterface", void 0);
1728
2149
  __decorate([
1729
2150
  (0, decorators_1.excludedInJSON)()
1730
2151
  ], App.prototype, "officialType", void 0);