@lcap/nasl 2.22.0-beta.0 → 2.22.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 (276) hide show
  1. package/out/automate/engine/operators.d.ts +9 -0
  2. package/out/automate/engine/viewCache.d.ts +1 -0
  3. package/out/automate/template/myProcess.d.ts +1 -0
  4. package/out/common/BaseNode.d.ts +1 -0
  5. package/out/common/BaseNode.js +7 -1
  6. package/out/common/BaseNode.js.map +1 -1
  7. package/out/common/Command.d.ts +1 -1
  8. package/out/common/EventEmitter.d.ts +1 -1
  9. package/out/concepts/Abort__.js.map +1 -1
  10. package/out/concepts/Anchor__.js.map +1 -1
  11. package/out/concepts/AnonymousFunction__.js.map +1 -1
  12. package/out/concepts/App__.d.ts +22 -0
  13. package/out/concepts/App__.js +78 -12
  14. package/out/concepts/App__.js.map +1 -1
  15. package/out/concepts/Argument__.js.map +1 -1
  16. package/out/concepts/Assignee__.js.map +1 -1
  17. package/out/concepts/AssignmentLine__.js.map +1 -1
  18. package/out/concepts/Assignment__.js.map +1 -1
  19. package/out/concepts/Attribute__.js.map +1 -1
  20. package/out/concepts/BatchAssignment__.js.map +1 -1
  21. package/out/concepts/BinaryExpression__.js.map +1 -1
  22. package/out/concepts/BindAttribute__.js.map +1 -1
  23. package/out/concepts/BindDirective__.js.map +1 -1
  24. package/out/concepts/BindEvent__.js.map +1 -1
  25. package/out/concepts/BindStyle__.js.map +1 -1
  26. package/out/concepts/BooleanLiteral__.js.map +1 -1
  27. package/out/concepts/CallFunction__.js.map +1 -1
  28. package/out/concepts/CallInterface__.js +9 -1
  29. package/out/concepts/CallInterface__.js.map +1 -1
  30. package/out/concepts/CallLogic__.js +2 -1
  31. package/out/concepts/CallLogic__.js.map +1 -1
  32. package/out/concepts/CallQueryComponent__.d.ts +2 -0
  33. package/out/concepts/CallQueryComponent__.js +76 -24
  34. package/out/concepts/CallQueryComponent__.js.map +1 -1
  35. package/out/concepts/Comment__.js.map +1 -1
  36. package/out/concepts/CompletionProperty__.js.map +1 -1
  37. package/out/concepts/ConfigGroup__.js.map +1 -1
  38. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  39. package/out/concepts/ConfigProperty__.d.ts +4 -0
  40. package/out/concepts/ConfigProperty__.js +18 -1
  41. package/out/concepts/ConfigProperty__.js.map +1 -1
  42. package/out/concepts/Configuration__.js.map +1 -1
  43. package/out/concepts/Constant__.js.map +1 -1
  44. package/out/concepts/DataElement__.js.map +1 -1
  45. package/out/concepts/DataSource__.js.map +1 -1
  46. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  47. package/out/concepts/Destination__.js +2 -2
  48. package/out/concepts/Destination__.js.map +1 -1
  49. package/out/concepts/End__.js.map +1 -1
  50. package/out/concepts/EntityIndex__.d.ts +1 -1
  51. package/out/concepts/EntityIndex__.js.map +1 -1
  52. package/out/concepts/EntityProperty__.d.ts +7 -2
  53. package/out/concepts/EntityProperty__.js +100 -1
  54. package/out/concepts/EntityProperty__.js.map +1 -1
  55. package/out/concepts/Entity__.d.ts +2 -1
  56. package/out/concepts/Entity__.js +30 -1
  57. package/out/concepts/Entity__.js.map +1 -1
  58. package/out/concepts/EnumItem__.js.map +1 -1
  59. package/out/concepts/Enum__.js.map +1 -1
  60. package/out/concepts/Event__.js.map +1 -1
  61. package/out/concepts/ExternalDestination__.js.map +1 -1
  62. package/out/concepts/ForEachStatement__.js.map +1 -1
  63. package/out/concepts/FrontendLibrary__.js.map +1 -1
  64. package/out/concepts/Frontend__.js.map +1 -1
  65. package/out/concepts/Function__.js.map +1 -1
  66. package/out/concepts/Identifier__.js +7 -0
  67. package/out/concepts/Identifier__.js.map +1 -1
  68. package/out/concepts/IfStatement__.js +2 -2
  69. package/out/concepts/IfStatement__.js.map +1 -1
  70. package/out/concepts/Integration__.d.ts +53 -0
  71. package/out/concepts/Integration__.js +143 -0
  72. package/out/concepts/Integration__.js.map +1 -0
  73. package/out/concepts/InterfaceParam__.js.map +1 -1
  74. package/out/concepts/Interface__.js.map +1 -1
  75. package/out/concepts/JSBlock__.js.map +1 -1
  76. package/out/concepts/JavaLogic__.d.ts +42 -0
  77. package/out/concepts/JavaLogic__.js +122 -0
  78. package/out/concepts/JavaLogic__.js.map +1 -0
  79. package/out/concepts/LogicItem__.d.ts +1 -1
  80. package/out/concepts/LogicItem__.js.map +1 -1
  81. package/out/concepts/Logic__.js +12 -7
  82. package/out/concepts/Logic__.js.map +1 -1
  83. package/out/concepts/MatchCase__.js.map +1 -1
  84. package/out/concepts/Match__.js +11 -6
  85. package/out/concepts/Match__.js.map +1 -1
  86. package/out/concepts/MemberExpression__.js +1 -1
  87. package/out/concepts/MemberExpression__.js.map +1 -1
  88. package/out/concepts/MicroApp__.d.ts +51 -0
  89. package/out/concepts/MicroApp__.js +113 -0
  90. package/out/concepts/MicroApp__.js.map +1 -0
  91. package/out/concepts/Module__.d.ts +20 -9
  92. package/out/concepts/Module__.js +72 -14
  93. package/out/concepts/Module__.js.map +1 -1
  94. package/out/concepts/Namespace__.js.map +1 -1
  95. package/out/concepts/NewComposite__.d.ts +1 -1
  96. package/out/concepts/NewComposite__.js +25 -11
  97. package/out/concepts/NewComposite__.js.map +1 -1
  98. package/out/concepts/NewList__.js.map +1 -1
  99. package/out/concepts/NewMap__.js.map +1 -1
  100. package/out/concepts/New__.js.map +1 -1
  101. package/out/concepts/NullLiteral__.js.map +1 -1
  102. package/out/concepts/NumericLiteral__.js.map +1 -1
  103. package/out/concepts/OqlQueryComponent__.js +1 -1
  104. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  105. package/out/concepts/Param__.d.ts +1 -0
  106. package/out/concepts/Param__.js +5 -0
  107. package/out/concepts/Param__.js.map +1 -1
  108. package/out/concepts/Point__.js.map +1 -1
  109. package/out/concepts/ProcessComponent__.js.map +1 -1
  110. package/out/concepts/ProcessElement__.js.map +1 -1
  111. package/out/concepts/ProcessOutcome__.js.map +1 -1
  112. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  113. package/out/concepts/Process__.js.map +1 -1
  114. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  115. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  116. package/out/concepts/QueryFromExpression__.js.map +1 -1
  117. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  118. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  119. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  120. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  121. package/out/concepts/QuerySelectExpression__.d.ts +104 -16
  122. package/out/concepts/QuerySelectExpression__.js +99 -9
  123. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  124. package/out/concepts/Rect__.js.map +1 -1
  125. package/out/concepts/Return__.js.map +1 -1
  126. package/out/concepts/Role__.js.map +1 -1
  127. package/out/concepts/SelectMembers__.js.map +1 -1
  128. package/out/concepts/Slot__.js.map +1 -1
  129. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  130. package/out/concepts/Start__.js.map +1 -1
  131. package/out/concepts/StringInterpolation__.js.map +1 -1
  132. package/out/concepts/StringLiteral__.js.map +1 -1
  133. package/out/concepts/StructureProperty__.js.map +1 -1
  134. package/out/concepts/Structure__.js.map +1 -1
  135. package/out/concepts/SwitchCase__.js +2 -2
  136. package/out/concepts/SwitchCase__.js.map +1 -1
  137. package/out/concepts/SwitchStatement__.js.map +1 -1
  138. package/out/concepts/Theme__.js.map +1 -1
  139. package/out/concepts/Transactional__.js.map +1 -1
  140. package/out/concepts/TypeAnnotation__.js +8 -3
  141. package/out/concepts/TypeAnnotation__.js.map +1 -1
  142. package/out/concepts/TypeParam__.js.map +1 -1
  143. package/out/concepts/UnaryExpression__.js.map +1 -1
  144. package/out/concepts/Unparsed__.js.map +1 -1
  145. package/out/concepts/UseComponent__.js.map +1 -1
  146. package/out/concepts/ValidationRule__.js.map +1 -1
  147. package/out/concepts/Variable__.js.map +1 -1
  148. package/out/concepts/ViewBlock__.js.map +1 -1
  149. package/out/concepts/ViewComponent__.js.map +1 -1
  150. package/out/concepts/ViewElement__.js +26 -6
  151. package/out/concepts/ViewElement__.js.map +1 -1
  152. package/out/concepts/View__.d.ts +1 -1
  153. package/out/concepts/View__.js +3 -1
  154. package/out/concepts/View__.js.map +1 -1
  155. package/out/concepts/WhileStatement__.js.map +1 -1
  156. package/out/concepts/basics/stdlib/nasl.ui.js +15 -0
  157. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  158. package/out/concepts/basics/stdlib/nasl.util.js +94 -0
  159. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  160. package/out/concepts/index__.d.ts +3 -0
  161. package/out/concepts/index__.js +3 -0
  162. package/out/concepts/index__.js.map +1 -1
  163. package/out/config.d.ts +1 -1
  164. package/out/decorators/index.d.ts +2 -2
  165. package/out/generator/genBundleFiles.js +20 -3
  166. package/out/generator/genBundleFiles.js.map +1 -1
  167. package/out/generator/genReleaseBody.js +2 -2
  168. package/out/generator/genReleaseBody.js.map +1 -1
  169. package/out/generator/icestark.d.ts +2 -0
  170. package/out/generator/icestark.js +48 -0
  171. package/out/generator/icestark.js.map +1 -0
  172. package/out/generator/microApp.d.ts +2 -0
  173. package/out/generator/microApp.js +35 -0
  174. package/out/generator/microApp.js.map +1 -0
  175. package/out/generator/permission.d.ts +1 -1
  176. package/out/generator/permission.js +0 -13
  177. package/out/generator/permission.js.map +1 -1
  178. package/out/generator/qiankun.d.ts +2 -0
  179. package/out/generator/qiankun.js +52 -0
  180. package/out/generator/qiankun.js.map +1 -0
  181. package/out/index.d.ts +1 -0
  182. package/out/index.js +1 -0
  183. package/out/index.js.map +1 -1
  184. package/out/manager/stepRecorder.d.ts +20 -0
  185. package/out/manager/stepRecorder.js +110 -0
  186. package/out/manager/stepRecorder.js.map +1 -0
  187. package/out/sentry/index.d.ts +5 -4
  188. package/out/sentry/index.js +9 -2
  189. package/out/sentry/index.js.map +1 -1
  190. package/out/server/formatTsUtils.d.ts +1 -1
  191. package/out/server/formatTsUtils.js +40 -14
  192. package/out/server/formatTsUtils.js.map +1 -1
  193. package/out/server/getLogics.js +38 -6
  194. package/out/server/getLogics.js.map +1 -1
  195. package/out/server/getMemberIdentifier.js +5 -4
  196. package/out/server/getMemberIdentifier.js.map +1 -1
  197. package/out/server/getProcesses.d.ts +3 -3
  198. package/out/server/getScope.d.ts +1 -1
  199. package/out/server/naslServer.d.ts +7 -3
  200. package/out/server/naslServer.js +270 -102
  201. package/out/server/naslServer.js.map +1 -1
  202. package/out/server/translator.js +25 -7
  203. package/out/server/translator.js.map +1 -1
  204. package/out/service/storage/init.d.ts +3 -3
  205. package/out/service/storage/init.js +6 -0
  206. package/out/service/storage/init.js.map +1 -1
  207. package/out/templator/genCreateBlock.js +6 -1
  208. package/out/templator/genCreateBlock.js.map +1 -1
  209. package/out/templator/genQueryComponent.js +20 -6
  210. package/out/templator/genQueryComponent.js.map +1 -1
  211. package/out/templator/genUpdateBlock.js +7 -1
  212. package/out/templator/genUpdateBlock.js.map +1 -1
  213. package/out/templator/utils.d.ts +16 -0
  214. package/out/templator/utils.js +2 -0
  215. package/out/templator/utils.js.map +1 -1
  216. package/out/translator/index.d.ts +1 -1
  217. package/out/translator/lsp.d.ts +3 -3
  218. package/out/utils/index.d.ts +4 -4
  219. package/package.json +1 -1
  220. package/sandbox/stdlib/nasl.ui.ts +16 -11
  221. package/sandbox/stdlib/nasl.util.ts +4 -0
  222. package/sandbox/stdlib/nasl.validation.ts +2 -2
  223. package/src/automate/upgrader/2.17.js +1 -1
  224. package/src/common/BaseNode.ts +10 -2
  225. package/src/concepts/App__.ts +90 -46
  226. package/src/concepts/CallInterface__.ts +9 -1
  227. package/src/concepts/CallLogic__.ts +2 -1
  228. package/src/concepts/CallQueryComponent__.ts +73 -82
  229. package/src/concepts/ConfigProperty__.ts +18 -1
  230. package/src/concepts/Destination__.ts +2 -20
  231. package/src/concepts/EntityProperty__.ts +102 -8
  232. package/src/concepts/Entity__.ts +31 -8
  233. package/src/concepts/Identifier__.ts +9 -2
  234. package/src/concepts/IfStatement__.ts +2 -2
  235. package/src/concepts/Integration__.ts +162 -0
  236. package/src/concepts/JavaLogic__.ts +129 -0
  237. package/src/concepts/LogicItem__.ts +1 -1
  238. package/src/concepts/Logic__.ts +12 -45
  239. package/src/concepts/Match__.ts +10 -5
  240. package/src/concepts/MemberExpression__.ts +1 -1
  241. package/src/concepts/MicroApp__.ts +118 -0
  242. package/src/concepts/Module__.ts +106 -79
  243. package/src/concepts/NewComposite__.ts +23 -11
  244. package/src/concepts/OqlQueryComponent__.ts +1 -1
  245. package/src/concepts/Param__.ts +3 -0
  246. package/src/concepts/QueryFieldExpression__.ts +0 -7
  247. package/src/concepts/QuerySelectExpression__.ts +206 -30
  248. package/src/concepts/SwitchCase__.ts +2 -2
  249. package/src/concepts/TypeAnnotation__.ts +8 -42
  250. package/src/concepts/ViewElement__.ts +24 -6
  251. package/src/concepts/View__.ts +3 -24
  252. package/src/concepts/basics/stdlib/nasl.ui.ts +15 -0
  253. package/src/concepts/basics/stdlib/nasl.util.ts +94 -0
  254. package/src/concepts/index__.ts +3 -0
  255. package/src/generator/genBundleFiles.ts +22 -4
  256. package/src/generator/genReleaseBody.ts +2 -2
  257. package/src/generator/icestark.ts +45 -0
  258. package/src/generator/microApp.ts +32 -0
  259. package/src/generator/permission.ts +1 -15
  260. package/src/generator/qiankun.ts +49 -0
  261. package/src/index.ts +1 -0
  262. package/src/manager/stepRecorder.ts +112 -0
  263. package/src/sentry/index.ts +8 -2
  264. package/src/server/formatTsUtils.ts +42 -14
  265. package/src/server/getLogics.ts +41 -6
  266. package/src/server/getMemberIdentifier.ts +5 -4
  267. package/src/server/naslServer.ts +270 -101
  268. package/src/server/translator.ts +25 -7
  269. package/src/service/storage/init.ts +7 -0
  270. package/src/templator/genCreateBlock.ts +6 -1
  271. package/src/templator/genQueryComponent.ts +22 -8
  272. package/src/templator/genUpdateBlock.ts +7 -1
  273. package/src/templator/utils.ts +2 -0
  274. package/ts-worker/src/index.js +1 -4
  275. package/src/manager/history.ts +0 -0
  276. package/src/manager/problem.ts +0 -0
@@ -2,6 +2,7 @@ import { dataTypesMap } from './basics/types';
2
2
  import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
3
3
  import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
4
4
  type changeType = 'up' | 'down';
5
+ import CallQueryComponent from './CallQueryComponent__';
5
6
  import StructureProperty from './StructureProperty__';
6
7
  import Structure from './Structure__';
7
8
  //================================================================================
@@ -285,10 +286,6 @@ export class EntityProperty extends BaseNode {
285
286
  });
286
287
  }
287
288
 
288
-
289
-
290
-
291
-
292
289
  /**
293
290
  * 删除类型标注
294
291
  * @param name 类型标注名称
@@ -337,8 +334,6 @@ export class EntityProperty extends BaseNode {
337
334
  return params;
338
335
  }
339
336
 
340
-
341
-
342
337
  /**
343
338
  * 删除数据库存储类型
344
339
  * @param name 数据库存储类型名称
@@ -395,7 +390,7 @@ export class EntityProperty extends BaseNode {
395
390
  /**
396
391
  * 设置实体属性名称
397
392
  */
398
- setName(name: string) {
393
+ async setName(name: string) {
399
394
  const object: any = {
400
395
  name,
401
396
  };
@@ -426,10 +421,13 @@ export class EntityProperty extends BaseNode {
426
421
 
427
422
  this.name = oldName;
428
423
  this.columnName = oldColumnName;
424
+ this.app?.emit('collect:start', { actionMsg: '修改实体属性名' });
429
425
  this.update({
430
426
  ...object,
431
427
  field: 'name',
432
428
  });
429
+ await this._effect();
430
+ this.app?.emit('collect:end');
433
431
  }
434
432
 
435
433
  /**
@@ -443,6 +441,46 @@ export class EntityProperty extends BaseNode {
443
441
  ...object,
444
442
  });
445
443
  }
444
+ async delete() {
445
+ let actionMsg = '删除实体属性';
446
+ if (this.name)
447
+ actionMsg += `“${this.name}”`;
448
+ this.app?.emit('collect:start', { actionMsg });
449
+ // 副作用
450
+ await this._effect({ action: 'delete' });
451
+ super.delete();
452
+ this.app?.emit('collect:end');
453
+ }
454
+
455
+ async _effect(options: { action?: 'delete' } = {}) {
456
+ // 处理选中的此字段的 CallQueryComponent
457
+ const callQueryComponents: Set<CallQueryComponent> = new Set();
458
+ const refs = await this.findUsage();
459
+ refs.forEach((val: any) => {
460
+ const loopFindNode = (item: any) => {
461
+ if (item.children) {
462
+ item.children.forEach((i: any) => loopFindNode(i));
463
+ } else {
464
+ const target = item.node?.getAncestor('CallQueryComponent');
465
+ if (target) {
466
+ callQueryComponents.add(target);
467
+ }
468
+ }
469
+ };
470
+ loopFindNode(val);
471
+ });
472
+ callQueryComponents.forEach((node) => {
473
+ const targetField = node.select.selectFieldElements.find((item) => item.entityAsName === this.parentNode.name && item.propertyName === this.name);
474
+ if (targetField) {
475
+ if (options.action === 'delete') {
476
+ // 删除字段对应的 QueryFieldExpression
477
+ targetField.delete();
478
+ }
479
+ // 更新数据结构
480
+ node.saveStructure();
481
+ }
482
+ });
483
+ }
446
484
  /**
447
485
  * 是否展开
448
486
  */
@@ -680,7 +718,6 @@ export class EntityProperty extends BaseNode {
680
718
  return !!this.module || this.generationRule !== 'manual';
681
719
  }
682
720
 
683
-
684
721
  // 存储类型信息
685
722
  get databaseTypeInfo() {
686
723
  const dataSourceSqlType = (this.getAncestor('DataSource') as DataSource)?.dataSourceSqlType;
@@ -717,10 +754,67 @@ export class EntityProperty extends BaseNode {
717
754
  const typeName = this.databaseTypeAnnotation.typeName;
718
755
  return databaseTypeMap[typeName];
719
756
  } else {
757
+ const { typeName } = this.typeAnnotation;
758
+ if (typeName === 'String') {
759
+ const defaultDataBaseName = this.inferredDefaultDataBaseName;
760
+ if (defaultDataBaseName && defaultDataBaseName !== this.defaultDataBaseType?.type) {
761
+ return {
762
+ ...(this.dataBaseTypeMap[defaultDataBaseName] || {}),
763
+ };
764
+ }
765
+ }
720
766
  return this.defaultDataBaseType;
721
767
  }
722
768
  }
723
769
 
770
+ // 根据最大长度推断的默认数据库类型
771
+ get inferredDefaultDataBaseName() {
772
+ let defaultDataBaseName;
773
+ const { typeName } = this.typeAnnotation;
774
+ if (typeName === 'String') {
775
+ const dataSourceSqlType = (this.getAncestor('DataSource') as DataSource)?.dataSourceSqlType;
776
+ let maxLength: any;
777
+ const rules = this.rules;
778
+ if (Array.isArray(rules)) {
779
+ // 是否需要更新规则
780
+ rules.forEach((rule) => {
781
+ const match = rule.match(/^([^()]+)\(([\d\-.]+)\)$/);
782
+ if (match) {
783
+ const [, key, value] = match;
784
+ if (key === 'maxLength') {
785
+ maxLength = value;
786
+ }
787
+ }
788
+ });
789
+ }
790
+ // 不同数据库 最大长度 短、中、长 对应的默认储存类型
791
+ const sqlMap: any = {
792
+ mysql: {
793
+ 255: 'varchar',
794
+ 4000: 'text',
795
+ 16777215: 'mediumtext',
796
+ },
797
+ oracle: {
798
+ 255: 'varchar2',
799
+ 4000: 'clob',
800
+ 16777215: 'clob',
801
+ },
802
+ dameng: {
803
+ 255: 'varchar2',
804
+ 4000: 'text',
805
+ 16777215: 'text',
806
+ },
807
+ db2: {
808
+ 255: 'varchar',
809
+ 4000: 'clob',
810
+ 16777215: 'clob',
811
+ },
812
+ };
813
+ defaultDataBaseName = sqlMap?.[dataSourceSqlType]?.[maxLength];
814
+ }
815
+ return defaultDataBaseName;
816
+ }
817
+
724
818
  __showAdvanced: boolean = false;
725
819
 
726
820
  //================================================================================
@@ -1,6 +1,7 @@
1
1
  import Namespace from './Namespace__';
2
2
  import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
3
3
  import { entity2LogicNamespace } from '../server/entity2LogicNamespace';
4
+ import CallQueryComponent from './CallQueryComponent__';
4
5
  //================================================================================
5
6
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
6
7
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -129,7 +130,7 @@ export class Entity extends BaseNode {
129
130
  });
130
131
  }
131
132
 
132
- getPropertyExistingNames(excludedList: Array<EntityProperty> = []) {
133
+ getPropertyExistingNames(excludedList: Array<EntityProperty> = []) {
133
134
  const excludedSet = new Set(excludedList);
134
135
  return ((this.properties as EntityProperty[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
135
136
  }
@@ -270,7 +271,6 @@ export class Entity extends BaseNode {
270
271
  return node;
271
272
  }
272
273
 
273
-
274
274
  getEntityIndexExistingNames(excludedList: Array<EntityIndex> = []) {
275
275
  const excludedSet = new Set(excludedList);
276
276
  return ((this.indexes as EntityIndex[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -412,9 +412,6 @@ export class Entity extends BaseNode {
412
412
  return node;
413
413
  }
414
414
 
415
-
416
-
417
-
418
415
  /**
419
416
  * 删除实体属性
420
417
  * @param name 实体属性名称
@@ -463,8 +460,6 @@ export class Entity extends BaseNode {
463
460
  return params;
464
461
  }
465
462
 
466
-
467
-
468
463
  /**
469
464
  * 删除实体索引
470
465
  * @param name 实体索引名称
@@ -535,7 +530,7 @@ export class Entity extends BaseNode {
535
530
  /**
536
531
  * 设置实体表名并修改表名
537
532
  */
538
- setName(name: string) {
533
+ async setName(name: string) {
539
534
  const object: any = {
540
535
  name,
541
536
  };
@@ -552,10 +547,14 @@ export class Entity extends BaseNode {
552
547
 
553
548
  this.name = oldName;
554
549
  this.tableName = oldTableName;
550
+ this.app?.emit('collect:start', { actionMsg: '修改实体名' });
551
+ const refs = await this.findUsage();
555
552
  this.update({
556
553
  ...object,
557
554
  field: 'name',
558
555
  });
556
+ this._effect(refs);
557
+ this.app?.emit('collect:end');
559
558
  }
560
559
  /**
561
560
  * 设置实体表名
@@ -671,6 +670,30 @@ export class Entity extends BaseNode {
671
670
  // 重命名 properties columnName
672
671
  this.formatPropertyColumnName();
673
672
  }
673
+ async _effect(refs: any = []) {
674
+ // 处理选中的此实体的 CallQueryComponent
675
+ const callQueryComponents: Set<CallQueryComponent> = new Set();
676
+ refs.forEach((val: any) => {
677
+ const loopFindNode = (item: any) => {
678
+ if (item.children) {
679
+ item.children.forEach((i: any) => loopFindNode(i));
680
+ } else {
681
+ const target = item.node?.getAncestor('CallQueryComponent');
682
+ if (target) {
683
+ callQueryComponents.add(target);
684
+ }
685
+ }
686
+ };
687
+ loopFindNode(val);
688
+ });
689
+ callQueryComponents.forEach((node) => {
690
+ const targetField = node.select.selectFieldElements.find((item) => item.entityAsName === this.name);
691
+ if (targetField) {
692
+ // 更新数据结构
693
+ node.saveStructure();
694
+ }
695
+ });
696
+ }
674
697
 
675
698
  public static getDefaultOptions() {
676
699
  return {
@@ -1,5 +1,5 @@
1
1
  import { TranslatorState, withSourceMap } from '../translator';
2
- import { BindAttribute, TypeAnnotation } from '..';
2
+ import { BindAttribute, CallLogic, TypeAnnotation } from '..';
3
3
  import { ElementToVueOptions } from './ViewElement__';
4
4
  import { findConceptKeyWordByNamespace } from '../utils';
5
5
 
@@ -229,7 +229,14 @@ export class Identifier extends LogicItem {
229
229
  if (this.namespace === 'inner' && this.getAncestor('CallQueryComponent')) {
230
230
  return `__${this.name}` || '__IDENTIFIER__';
231
231
  }
232
-
232
+ const logicAncestor = this.getAncestor('CallLogic') as CallLogic;
233
+
234
+ if (logicAncestor && logicAncestor.calleeName === "getCustomConfig" && logicAncestor.calleeNamespace === "nasl.configuration") {
235
+ if (!!this.view) {
236
+ return this.namespace ? `${this.namespace}.Custom${this.name}.FrontEnd${this.name}` : this.name || '__IDENTIFIER__';
237
+ }
238
+ return this.namespace ? `${this.namespace}.Custom${this.name}.BackEnd${this.name}` : this.name || '__IDENTIFIER__';
239
+ }
233
240
  return this.namespace ? this.namespace + '.' + this.name : this.name || '__IDENTIFIER__';
234
241
  }
235
242
 
@@ -442,7 +442,7 @@ export class IfStatement extends LogicItem {
442
442
  code
443
443
  += logicItem.toEmbeddedTS(shiftState(state, code, {
444
444
  tabSize: (state?.tabSize || 0) + 1,
445
- })) + '\n';
445
+ })) + ';\n';
446
446
  });
447
447
  }
448
448
 
@@ -453,7 +453,7 @@ export class IfStatement extends LogicItem {
453
453
  code
454
454
  += logicItem.toEmbeddedTS(shiftState(state, code, {
455
455
  tabSize: (state?.tabSize || 0) + 1,
456
- })) + '\n';
456
+ })) + ';\n';
457
457
  });
458
458
  code += indent((state?.tabSize || 0)) + '}\n';
459
459
  }
@@ -0,0 +1,162 @@
1
+ //================================================================================
2
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
3
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
4
+ //================================================================================
5
+ import { EventPayload, Params } from '../common/EventEmitter';
6
+ import { concept, excludedInJSON, property } from '../decorators';
7
+
8
+ import * as utils from '../utils';
9
+ import { v4 as uuidv4 } from 'uuid';
10
+ import BaseNode from '../common/BaseNode';
11
+ import classMap from '../common/classMap';
12
+ import MicroApp from './MicroApp__';
13
+ import App from './App__';
14
+
15
+ /**
16
+ * 集成
17
+ */
18
+ @concept('集成')
19
+ export class Integration extends BaseNode {
20
+ /**
21
+ * 产品概念
22
+ */
23
+ @property()
24
+ concept: 'Integration' = 'Integration';
25
+
26
+ /**
27
+ * 微应用
28
+ */
29
+ @property('MicroApp')
30
+ microApp: MicroApp = undefined;
31
+
32
+ /**
33
+ * 祖先 App
34
+ */
35
+ get app() {
36
+ return this.getAncestor('App') as App;
37
+ }
38
+
39
+ /**
40
+ * @param source 需要合并的部分参数
41
+ */
42
+ constructor(source?: Partial<Integration>) {
43
+ source = Object.assign({}, Integration.getDefaultOptions(), source);
44
+ super(source);
45
+ super.subConstructor(source);
46
+ }
47
+ getClassName() {
48
+ return 'Integration';
49
+ }
50
+
51
+ static from(source: any, parentNode?: any, parentKey?: string): Integration {
52
+ return super.from(source, parentNode, parentKey) as Integration;
53
+ }
54
+
55
+ /**
56
+ * 从父级删除该节点
57
+ * @internal
58
+ */
59
+ _delete() {
60
+ let params: Params = null;
61
+ if (this.parentNode) {
62
+ params = (this.parentNode as any)?.__removeIntegration?.(this);
63
+ }
64
+ return params;
65
+ }
66
+ /**
67
+ * 设置微应用
68
+ */
69
+ setMicroApp(microApp: MicroApp) {
70
+ microApp._delete();
71
+ const relationOptions = { parentNode: this, parentKey: 'microApp' };
72
+ Object.assign(microApp, relationOptions);
73
+ const object = {
74
+ microApp,
75
+ };
76
+ this.update({
77
+ ...object,
78
+ });
79
+ }
80
+
81
+
82
+
83
+
84
+
85
+ /**
86
+ * 删除微应用
87
+ * @param name 微应用名称
88
+ */
89
+ removeMicroApp(name: string): void;
90
+
91
+ /**
92
+ * 删除微应用
93
+ * @param microApp 已有的微应用实例
94
+ */
95
+ removeMicroApp(microApp: MicroApp): void;
96
+
97
+ removeMicroApp(options: string | MicroApp) {
98
+ let microApp: MicroApp;
99
+ if (typeof options === 'string') {
100
+ microApp = this.microApp;
101
+ if (!microApp) {
102
+ throw new Error('找不到微应用 ' + options);
103
+ }
104
+ } else {
105
+ microApp = options;
106
+ }
107
+ return microApp.delete();
108
+ }
109
+
110
+ __removeMicroApp(microApp: MicroApp) {
111
+ const parentKey = microApp.parentKey;
112
+ const params: Params = {
113
+ parentNode: this,
114
+ parentKey,
115
+ index: -1,
116
+ object: null,
117
+ oldObject: microApp,
118
+ };
119
+ if (parentKey) {
120
+ params.parentKey = parentKey;
121
+ if (Array.isArray((this as any)[parentKey])) {
122
+ const index = (this as any)[parentKey].indexOf(microApp);
123
+ ~index && (this as any)[parentKey].splice(index, 1);
124
+ params.index = index;
125
+ } else if ((this as any)[parentKey] === microApp) {
126
+ params.index = 0;
127
+ (this as any)[parentKey] = undefined;
128
+ }
129
+ }
130
+ return params;
131
+ }
132
+
133
+ //================================================================================
134
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
135
+ // 自动生成的代码已结束。下面可以手动编写。
136
+ //================================================================================
137
+
138
+ /**
139
+ * 获取添加时的默认选项
140
+ * @returns
141
+ */
142
+ public static getDefaultOptions(): any {
143
+ return {
144
+ concept: 'Integration',
145
+ microApp: {
146
+ concept: 'MicroApp',
147
+ },
148
+ };
149
+ }
150
+
151
+ //================================================================================
152
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
153
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
154
+ //================================================================================
155
+ }
156
+
157
+ classMap.Integration = Integration;
158
+ export default Integration;
159
+ //================================================================================
160
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
161
+ // 自动生成的代码已结束。下面可以手动编写。
162
+ //================================================================================
@@ -0,0 +1,129 @@
1
+ import { TranslatorState, indent } from '../translator';
2
+ //================================================================================
3
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
4
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
5
+ //================================================================================
6
+ import { EventPayload, Params } from '../common/EventEmitter';
7
+ import { concept, excludedInJSON, property } from '../decorators';
8
+
9
+ import * as utils from '../utils';
10
+ import { v4 as uuidv4 } from 'uuid';
11
+ import BaseNode from '../common/BaseNode';
12
+ import classMap from '../common/classMap';
13
+ import LogicItem from './LogicItem__';
14
+
15
+ /**
16
+ * Java 扩展逻辑
17
+ */
18
+ @concept('Java 扩展逻辑')
19
+ export class JavaLogic extends LogicItem {
20
+ /**
21
+ * 产品概念
22
+ */
23
+ @property()
24
+ concept: 'JavaLogic' = 'JavaLogic';
25
+
26
+ /**
27
+ * packageName
28
+ */
29
+ @property()
30
+ packageName: string = undefined;
31
+
32
+ /**
33
+ * className
34
+ */
35
+ @property()
36
+ className: string = undefined;
37
+
38
+ /**
39
+ * 代码内容
40
+ */
41
+ @property()
42
+ code: string = undefined;
43
+
44
+
45
+
46
+ /**
47
+ * @param source 需要合并的部分参数
48
+ */
49
+ constructor(source?: Partial<JavaLogic>) {
50
+ source = Object.assign({}, JavaLogic.getDefaultOptions(), source);
51
+ super(source);
52
+ super.subConstructor(source);
53
+ }
54
+ getClassName() {
55
+ return 'JavaLogic';
56
+ }
57
+
58
+ static from(source: any, parentNode?: any, parentKey?: string): JavaLogic {
59
+ return super.from(source, parentNode, parentKey) as JavaLogic;
60
+ }
61
+
62
+
63
+ /**
64
+ * 设置代码内容
65
+ */
66
+ setCode(code: string) {
67
+ const object = {
68
+ code,
69
+ };
70
+ this.update({
71
+ ...object,
72
+ });
73
+ }
74
+
75
+
76
+
77
+
78
+
79
+ //================================================================================
80
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
81
+ // 自动生成的代码已结束。下面可以手动编写。
82
+ //================================================================================
83
+
84
+ /**
85
+ * 生成 TS 宿主语言代码
86
+ * @param state 编译状态
87
+ * @returns 生成的代码
88
+ */
89
+ toEmbeddedTS(state?: TranslatorState): string {
90
+ let code = '';
91
+ const ret = this.logic.returns[0];
92
+ if (ret) {
93
+ code += indent((state?.tabSize || 0)) + 'return ' + ret.name + ';';
94
+ } else {
95
+ code += indent((state?.tabSize || 0)) + 'return;';
96
+ }
97
+ return code;
98
+ }
99
+
100
+ setPackageName(packageName: string) {
101
+ const object = {
102
+ packageName,
103
+ };
104
+ this.update({
105
+ ...object
106
+ });
107
+ }
108
+
109
+ setClassName(className: string) {
110
+ const object = {
111
+ className,
112
+ };
113
+ this.update({
114
+ ...object
115
+ });
116
+ }
117
+
118
+ //================================================================================
119
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
120
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
121
+ //================================================================================
122
+ }
123
+
124
+ classMap.JavaLogic = JavaLogic;
125
+ export default JavaLogic;
126
+ //================================================================================
127
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
128
+ // 自动生成的代码已结束。下面可以手动编写。
129
+ //================================================================================
@@ -31,7 +31,7 @@ export class LogicItem extends BaseNode {
31
31
  * 产品概念
32
32
  */
33
33
  @property()
34
- concept: 'LogicItem' | 'Abort' | 'Start' | 'End' | 'IfStatement' | 'SwitchStatement' | 'SwitchCase' | 'ForEachStatement' | 'WhileStatement' | 'Assignment' | 'BatchAssignment' | 'Comment' | 'CallLogic' | 'CallFunction' | 'CallInterface' | 'Destination' | 'ExternalDestination' | 'ValidationRule' | 'Argument' | 'Anchor' | 'JSBlock' | 'Identifier' | 'NullLiteral' | 'BooleanLiteral' | 'StringLiteral' | 'StringInterpolation' | 'NumericLiteral' | 'BinaryExpression' | 'MatchCase' | 'Match' | 'UnaryExpression' | 'MemberExpression' | 'Unparsed' | 'New' | 'NewComposite' | 'NewList' | 'NewMap' | 'CallQueryComponent' | 'QueryFromExpression' | 'QueryJoinExpression' | 'QueryFieldExpression' | 'QueryAggregateExpression' | 'QueryOrderByExpression' | 'QueryGroupByExpression' | 'QuerySelectExpression' | 'QueryLimitExpression' | 'SqlQueryComponent' | 'OqlQueryComponent' | 'ProcessOutcome' | 'Assignee' | 'ProcessOutcomes' = 'LogicItem';
34
+ concept: 'LogicItem' | 'Abort' | 'Start' | 'End' | 'IfStatement' | 'SwitchStatement' | 'SwitchCase' | 'ForEachStatement' | 'WhileStatement' | 'Assignment' | 'BatchAssignment' | 'Comment' | 'CallLogic' | 'CallFunction' | 'CallInterface' | 'Destination' | 'ExternalDestination' | 'ValidationRule' | 'Argument' | 'Anchor' | 'JSBlock' | 'JavaLogic' | 'Identifier' | 'NullLiteral' | 'BooleanLiteral' | 'StringLiteral' | 'StringInterpolation' | 'NumericLiteral' | 'BinaryExpression' | 'MatchCase' | 'Match' | 'UnaryExpression' | 'MemberExpression' | 'Unparsed' | 'New' | 'NewComposite' | 'NewList' | 'NewMap' | 'CallQueryComponent' | 'QueryFromExpression' | 'QueryJoinExpression' | 'QueryFieldExpression' | 'QueryAggregateExpression' | 'QueryOrderByExpression' | 'QueryGroupByExpression' | 'QuerySelectExpression' | 'QueryLimitExpression' | 'SqlQueryComponent' | 'OqlQueryComponent' | 'ProcessOutcome' | 'Assignee' | 'ProcessOutcomes' = 'LogicItem';
35
35
 
36
36
  /**
37
37
  * 逻辑项标题