@lcap/nasl 4.1.0-beta.8 → 4.1.0-creator.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 (125) hide show
  1. package/out/generator/genBundleFiles.d.ts +1 -0
  2. package/out/generator/genBundleFiles.d.ts.map +1 -1
  3. package/out/generator/genBundleFiles.js +21 -96
  4. package/out/generator/genBundleFiles.js.map +1 -1
  5. package/out/generator/genSimpleBundleFile.d.ts +19 -0
  6. package/out/generator/genSimpleBundleFile.d.ts.map +1 -0
  7. package/out/generator/genSimpleBundleFile.js +114 -0
  8. package/out/generator/genSimpleBundleFile.js.map +1 -0
  9. package/out/generator/index.d.ts +1 -0
  10. package/out/generator/index.d.ts.map +1 -1
  11. package/out/generator/index.js +1 -0
  12. package/out/generator/index.js.map +1 -1
  13. package/out/generator/permission.d.ts.map +1 -1
  14. package/out/generator/permission.js +70 -34
  15. package/out/generator/permission.js.map +1 -1
  16. package/out/generator/release-body/body.d.ts.map +1 -1
  17. package/out/generator/release-body/body.js +3 -4
  18. package/out/generator/release-body/body.js.map +1 -1
  19. package/out/generator/release-body/memory-optimization.d.ts.map +1 -1
  20. package/out/generator/release-body/memory-optimization.js +3 -2
  21. package/out/generator/release-body/memory-optimization.js.map +1 -1
  22. package/out/generator/release-body/utils.d.ts +7 -3
  23. package/out/generator/release-body/utils.d.ts.map +1 -1
  24. package/out/generator/release-body/utils.js +7 -5
  25. package/out/generator/release-body/utils.js.map +1 -1
  26. package/out/index.d.ts +1 -1
  27. package/out/index.d.ts.map +1 -1
  28. package/out/index.js +2 -1
  29. package/out/index.js.map +1 -1
  30. package/out/natural/index.d.ts +1 -0
  31. package/out/natural/index.d.ts.map +1 -1
  32. package/out/natural/index.js +1 -0
  33. package/out/natural/index.js.map +1 -1
  34. package/out/natural/parseNaturalTS.d.ts +1 -1
  35. package/out/natural/parseNaturalTS.d.ts.map +1 -1
  36. package/out/natural/parseNaturalTS.js +150 -4
  37. package/out/natural/parseNaturalTS.js.map +1 -1
  38. package/out/natural/parseNaturalTSXView.d.ts +6 -0
  39. package/out/natural/parseNaturalTSXView.d.ts.map +1 -0
  40. package/out/natural/parseNaturalTSXView.js +536 -0
  41. package/out/natural/parseNaturalTSXView.js.map +1 -0
  42. package/out/natural/transformTS2UI.d.ts.map +1 -1
  43. package/out/natural/transformTS2UI.js +6 -9
  44. package/out/natural/transformTS2UI.js.map +1 -1
  45. package/out/natural/transformTSCode.d.ts.map +1 -1
  46. package/out/natural/transformTSCode.js +1 -1
  47. package/out/natural/transformTSCode.js.map +1 -1
  48. package/out/natural/transforms/transform2Entity.d.ts.map +1 -1
  49. package/out/natural/transforms/transform2Entity.js +3 -1
  50. package/out/natural/transforms/transform2Entity.js.map +1 -1
  51. package/out/natural/transforms/transform2Enum.js +1 -1
  52. package/out/natural/transforms/transform2Enum.js.map +1 -1
  53. package/out/natural/transforms/transform2Logic.d.ts +3 -1
  54. package/out/natural/transforms/transform2Logic.d.ts.map +1 -1
  55. package/out/natural/transforms/transform2Logic.js +37 -6
  56. package/out/natural/transforms/transform2Logic.js.map +1 -1
  57. package/out/natural/transforms/transform2LogicItem.d.ts +34 -6
  58. package/out/natural/transforms/transform2LogicItem.d.ts.map +1 -1
  59. package/out/natural/transforms/transform2LogicItem.js +333 -151
  60. package/out/natural/transforms/transform2LogicItem.js.map +1 -1
  61. package/out/natural/transforms/transform2MetadataType.d.ts +3 -0
  62. package/out/natural/transforms/transform2MetadataType.d.ts.map +1 -0
  63. package/out/natural/transforms/transform2MetadataType.js +14 -0
  64. package/out/natural/transforms/transform2MetadataType.js.map +1 -0
  65. package/out/natural/transforms/transform2ValidationRule.d.ts +3 -0
  66. package/out/natural/transforms/transform2ValidationRule.d.ts.map +1 -0
  67. package/out/natural/transforms/transform2ValidationRule.js +19 -0
  68. package/out/natural/transforms/transform2ValidationRule.js.map +1 -0
  69. package/out/natural/transforms/transform2Variable.d.ts +1 -0
  70. package/out/natural/transforms/transform2Variable.d.ts.map +1 -1
  71. package/out/natural/transforms/transform2Variable.js +25 -1
  72. package/out/natural/transforms/transform2Variable.js.map +1 -1
  73. package/out/natural/transforms/transformThemeAndStyle.d.ts +24 -0
  74. package/out/natural/transforms/transformThemeAndStyle.d.ts.map +1 -0
  75. package/out/natural/transforms/transformThemeAndStyle.js +269 -0
  76. package/out/natural/transforms/transformThemeAndStyle.js.map +1 -0
  77. package/out/natural/transforms/utils.d.ts +16 -2
  78. package/out/natural/transforms/utils.d.ts.map +1 -1
  79. package/out/natural/transforms/utils.js +67 -11
  80. package/out/natural/transforms/utils.js.map +1 -1
  81. package/out/server/OQL/sqlCategory.json +410 -0
  82. package/out/server/OQL/sqlFunctions.json +695 -7
  83. package/out/server/client/nasl-server-client.d.ts +7 -0
  84. package/out/server/client/nasl-server-client.d.ts.map +1 -0
  85. package/out/server/client/nasl-server-client.js +9 -0
  86. package/out/server/client/nasl-server-client.js.map +1 -0
  87. package/out/server/extendBaseNode.d.ts.map +1 -1
  88. package/out/server/extendBaseNode.js +18 -9
  89. package/out/server/extendBaseNode.js.map +1 -1
  90. package/out/server/index.d.ts +1 -0
  91. package/out/server/index.d.ts.map +1 -1
  92. package/out/server/index.js +1 -0
  93. package/out/server/index.js.map +1 -1
  94. package/out/server/naslServer.d.ts +10 -1
  95. package/out/server/naslServer.d.ts.map +1 -1
  96. package/out/server/naslServer.js +125 -64
  97. package/out/server/naslServer.js.map +1 -1
  98. package/out/service/initial/form-designer.d.ts +1 -1
  99. package/out/service/initial/form-designer.d.ts.map +1 -1
  100. package/out/service/initial/form-designer.js +4 -1
  101. package/out/service/initial/form-designer.js.map +1 -1
  102. package/out/service/initial/processV2.d.ts +1 -1
  103. package/out/service/initial/processV2.d.ts.map +1 -1
  104. package/out/service/initial/processV2.js +4 -1
  105. package/out/service/initial/processV2.js.map +1 -1
  106. package/out/service/initial/types.d.ts +1 -0
  107. package/out/service/initial/types.d.ts.map +1 -1
  108. package/out/service/storage/api.d.ts +16 -7
  109. package/out/service/storage/api.js +6 -0
  110. package/out/service/storage/api.js.map +1 -1
  111. package/out/service/storage/cache/index.d.ts +3 -15
  112. package/out/service/storage/cache/index.d.ts.map +1 -1
  113. package/out/service/storage/cache/index.js +14 -299
  114. package/out/service/storage/cache/index.js.map +1 -1
  115. package/out/service/storage/cache/split.d.ts +0 -21
  116. package/out/service/storage/cache/split.d.ts.map +1 -1
  117. package/out/service/storage/cache/split.js +24 -33
  118. package/out/service/storage/cache/split.js.map +1 -1
  119. package/out/service/storage/init.d.ts +9 -0
  120. package/out/service/storage/init.d.ts.map +1 -1
  121. package/out/service/storage/init.js +61 -90
  122. package/out/service/storage/init.js.map +1 -1
  123. package/out/service/storage/service.js +1 -1
  124. package/out/service/storage/service.js.map +1 -1
  125. package/package.json +15 -13
@@ -40,12 +40,15 @@ const Messager_1 = __importDefault(require("../common/Messager"));
40
40
  const oql_cache_1 = require("./OQL/oql-cache");
41
41
  const initial_1 = require("../service/initial");
42
42
  const set_1 = require("mnemonist/set");
43
+ const sqlFunctions_json_1 = __importDefault(require("./OQL/sqlFunctions.json"));
44
+ const sqlCategory_json_1 = __importDefault(require("./OQL/sqlCategory.json"));
43
45
  /// #if process.env.BUILD_TARGET === 'node'
44
46
  const fs = __importStar(require("fs-extra"));
45
47
  const path = __importStar(require("path"));
46
48
  const worker_threads_1 = require("worker_threads");
47
49
  /// #endif
48
50
  const concepts_1 = require("../concepts");
51
+ // import { validator, VusionValidator } from '@lcap/nasl-concepts';
49
52
  const asserts_1 = require("@lcap/nasl-concepts/asserts");
50
53
  const service_1 = require("@lcap/nasl-concepts/service");
51
54
  const utils = __importStar(require("../utils"));
@@ -60,25 +63,7 @@ const decorators_1 = require("../decorators");
60
63
  const nasl_concepts_1 = require("@lcap/nasl-concepts");
61
64
  const nasl_language_server_core_1 = require("@lcap/nasl-language-server-core");
62
65
  const findReference_1 = require("./findReference");
63
- const NEED_SYNC_BIND_ATTRIBUTE = [
64
- 'textField',
65
- 'valueField',
66
- 'iconField',
67
- 'toField',
68
- 'parentField',
69
- 'childrenField',
70
- 'hasChildrenField',
71
- 'field',
72
- 'idField',
73
- 'titleField',
74
- 'closableField',
75
- 'descriptionField',
76
- 'expandedField',
77
- 'disabledField',
78
- 'nameField',
79
- 'labelField',
80
- 'sortField'
81
- ];
66
+ const nasl_server_client_1 = require("./client/nasl-server-client");
82
67
  const SentryMessager = (0, nasl_sentry_1.sentryMonitorTSWorkerMessager)(Messager_1.default);
83
68
  // naslStdlib文件缓存;作为全局变量给多实例用复用
84
69
  const __naslStdlibFileCacheMap = new Map();
@@ -184,6 +169,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
184
169
  // 当前重命名模式:rename-only: 只重命名,update: 更新引用
185
170
  this.currentRenameMode = null;
186
171
  this.oqlDisaster = false;
172
+ this.useCache = false; // 是否使用本地缓存文件,目前用于AI沙箱无法调用接口的环境
187
173
  this.isFirstScreen = true; // 优化首屏 getAncestor 热点代码
188
174
  /**
189
175
  * 语言服务运行完毕
@@ -327,6 +313,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
327
313
  this.http = opt.http;
328
314
  this.isAnnotationMode = opt?.isAnnotationMode ?? false;
329
315
  this.logger = opt.logger ?? utils.internalLogger;
316
+ this.useCache = opt.useCache ?? false;
330
317
  this.diagnosticManager = new diagnostic_1.DiagnosticManager();
331
318
  this.messager = new SentryMessager({
332
319
  protocol: 'ts-worker',
@@ -388,13 +375,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
388
375
  const diagAppStartTime = performance.now();
389
376
  await utils.runGeneratorAsync(this.semEnv.errorDiagnoser.diagnosticApp());
390
377
  const diagAppEndTime = performance.now();
391
- console.error(`\x1b[44m\x1b[97m Diagnostic App \x1b[0m: ${((diagAppEndTime - diagAppStartTime) / 1000).toFixed(3)}s`);
378
+ console.info(`\x1b[44m\x1b[97m Diagnostic App \x1b[0m: ${((diagAppEndTime - diagAppStartTime) / 1000).toFixed(3)}s`);
392
379
  const diagnosticMap = this.semEnv.errorDiagnoser.getAllDiagnostics();
393
380
  const transformStartTime = performance.now();
394
381
  const records = transformDiagnosticMapToRecords(diagnosticMap);
395
382
  await this.diagnosticManager.setInitialDiagData(records);
396
383
  const transformEndTime = performance.now();
397
- console.error(`\x1b[44m\x1b[97m Transform Diagnostic Map To Records \x1b[0m: ${((transformEndTime - transformStartTime) / 1000).toFixed(3)}s`);
384
+ console.info(`\x1b[44m\x1b[97m Transform Diagnostic Map To Records \x1b[0m: ${((transformEndTime - transformStartTime) / 1000).toFixed(3)}s`);
398
385
  // 首屏和增量通路不同,首屏时需要手动调用lsRunEndSwitch;增量时则在增量代码中调用
399
386
  this._lsRunEndSwitch();
400
387
  this.isFirstScreen = false;
@@ -406,7 +393,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
406
393
  rawApp.emit('collect:end');
407
394
  this.semData.isFirstScreen = false;
408
395
  this.semEnv.allocatedVEQNames.forEach(n => {
409
- this.semEnv.refMgr.qNameDefs.delete(n);
396
+ this.semEnv.refMgr.gQNameDefs.delete(n);
410
397
  });
411
398
  this.semEnv.allocatedVEQNames.length = 0;
412
399
  for (const value of this.cachedEventPayloadValues) {
@@ -418,6 +405,12 @@ let NaslServer = NaslServer_1 = class NaslServer {
418
405
  }
419
406
  utils.isDebugMode && console.timeEnd('\x1b[44m\x1b[97m 用户体感首屏检查耗时 \x1b[0m');
420
407
  }
408
+ /**
409
+ * @warning 不放在这里无法起到加速效果,且读到的 cache 为空,抛出 undefined 值
410
+ * 放在这里的话好像是有些“时序”问题?
411
+ */
412
+ this.semData.recoverSlowGetters();
413
+ this.semData.clearSemanticData();
421
414
  (0, nasl_language_server_core_1.clearFileNodeCache)();
422
415
  }
423
416
  this.notifyPublishDiagnosticsEnd(tsDiagnostics);
@@ -698,8 +691,14 @@ let NaslServer = NaslServer_1 = class NaslServer {
698
691
  return results;
699
692
  }
700
693
  async requestDatabaseConfigs(http, app) {
701
- const res = await http.get('/api/v1/app/config/list?category=sql');
702
- const data = res.data?.result || [];
694
+ let data = [];
695
+ if (this.useCache) {
696
+ data = JSON.parse(JSON.stringify(sqlCategory_json_1.default));
697
+ }
698
+ else {
699
+ const res = await http.get('/api/v1/app/config/list?category=sql');
700
+ data = res.data?.result || [];
701
+ }
703
702
  const map = data.filter((item) => item.category === 'sql' && item.available)
704
703
  ?.reduce((acc, item) => ({
705
704
  ...acc,
@@ -708,8 +707,14 @@ let NaslServer = NaslServer_1 = class NaslServer {
708
707
  app.saveDatabaseConfigIdToTypeMap(map);
709
708
  }
710
709
  async requestSqlFunctions(http, appName) {
711
- const res = await http.get('/api/v1/app/config/database/functions');
712
- const data = res.data?.result?.result || [];
710
+ let data = [];
711
+ if (this.useCache) {
712
+ data = JSON.parse(JSON.stringify(sqlFunctions_json_1.default));
713
+ }
714
+ else {
715
+ const res = await http.get('/api/v1/app/config/database/functions');
716
+ data = res.data?.result?.result || [];
717
+ }
713
718
  const files = data
714
719
  .filter((item) => !!item.signature)
715
720
  .map((item) => {
@@ -755,9 +760,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
755
760
  provider: item.provider,
756
761
  version: item.version,
757
762
  }));
758
- const res = await this.http.post('/api/v1/share/center/imported/changed/list', params);
759
- this._latestVersionsOfSharedApp = res.data;
760
- this.semEnv?.errorDiagnoser?.setLatestVersionsOfSharedApp(res.data);
763
+ // const res = await this.http.post('/api/v1/share/center/imported/changed/list', params);
764
+ // this._latestVersionsOfSharedApp = res.data;
765
+ // this.semEnv?.errorDiagnoser?.setLatestVersionsOfSharedApp(res.data);
761
766
  }
762
767
  getStatusOfSharedApp(sharedApp) {
763
768
  const version = this._latestVersionsOfSharedApp.find((item) => item.name === sharedApp.name && item.provider === sharedApp.provider);
@@ -819,7 +824,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
819
824
  this.logger.info('运行在自动化测试模式下...');
820
825
  }
821
826
  // 初始化 App 配置
822
- await (0, initial_1.initialize)({ app, axios: this.http });
827
+ await (0, initial_1.initialize)({ app, axios: this.http, useCache: this.useCache });
823
828
  this.logger.time('全量生成并写入 TS 文件——总计');
824
829
  const toEmbeddedTSStartTime = new Date().getTime();
825
830
  this.logger.time('全量生成 TS——翻译');
@@ -843,6 +848,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
843
848
  catch (err) {
844
849
  this.logger.error('请求数据库配置列表失败', err);
845
850
  }
851
+ let sqlSignatureFiles = [];
846
852
  try {
847
853
  this.sqlSignatureFiles = await this.requestSqlFunctions(this.http, app.name);
848
854
  }
@@ -853,8 +859,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
853
859
  await this.waitOqlQueryComponentChildrenFinish(app);
854
860
  // 翻译 ts 文件
855
861
  const results = await utils.runGeneratorAsync(getAllTsFiles());
856
- this.semData.recoverSlowGetters();
857
- this.semData.clearSemanticData();
858
862
  const files = results.map((result) => ({
859
863
  file: result.filePath,
860
864
  fileContent: result.code,
@@ -1322,13 +1326,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
1322
1326
  nodeType = '连接';
1323
1327
  }
1324
1328
  timeoutConfig.values.forEach((value) => {
1325
- const { env, envDisplayLabel } = value;
1329
+ const env = value.env;
1326
1330
  const timeout = Number(value.value);
1327
1331
  if (timeout * 1000 < retryInterval * retryTimes) {
1328
1332
  const diagnostic = {
1329
1333
  node: fileNode,
1330
1334
  severity: 'warning',
1331
- message: `${nodeType}"${fileNodeRaw.title ?? fileNodeRaw.name}"配置的重试间隔时间乘以重试次数大于${envDisplayLabel}接口超时时间,可能导致重试失败`,
1335
+ message: `${nodeType}"${fileNodeRaw.title ?? fileNodeRaw.name}"配置的重试间隔时间乘以重试次数大于${env === 'dev' ? '开发环境' : '生产环境'}接口超时时间,可能导致重试失败`,
1332
1336
  text: config_1.HTTP_TIMEOUT_ORIGIN_MESSAGE,
1333
1337
  };
1334
1338
  diagnostics.push(diagnostic);
@@ -1641,17 +1645,10 @@ let NaslServer = NaslServer_1 = class NaslServer {
1641
1645
  return result;
1642
1646
  };
1643
1647
  const nd = NaslServer_1.toRaw(__node);
1644
- if (concepts_1.asserts.isDirectory(__node)) {
1645
- return [];
1646
- }
1647
1648
  const { parentNode } = nd;
1648
1649
  const semEnv = NaslServer_1.toRaw(this.semEnv);
1649
1650
  let result = wrapRefs(semEnv.refMgr.getReferences(semEnv, nd));
1650
- if (nd.concept === 'ViewElement') {
1651
- const refMemAddrs = semEnv.refMgr.getViewElementRefs(semEnv, nd);
1652
- result.push(...wrapRefs(refMemAddrs));
1653
- }
1654
- else if (nd.concept === 'ProcessElementV2') {
1651
+ if (nd.concept === 'ProcessElementV2') {
1655
1652
  const refMemAddrs = semEnv.refMgr.getProcessElementRefs(semEnv, nd);
1656
1653
  result.push(...wrapRefs(refMemAddrs));
1657
1654
  }
@@ -1664,10 +1661,18 @@ let NaslServer = NaslServer_1 = class NaslServer {
1664
1661
  }
1665
1662
  }
1666
1663
  }
1667
- else if (concepts_1.asserts.isStrictParam(nd)) {
1664
+ else if (nd.concept === 'BindEvent') {
1665
+ // v4.1 新增 绑定事件 改类型,需要把 事件逻辑的引用,全部迁移过去
1666
+ // v4.1 修改:logics 其实只能有一个
1667
+ if (nd.logics[0].concept === 'Logic') {
1668
+ const eventLogicRefs = semEnv.refMgr.getReferences(semEnv, nd.logics[0]);
1669
+ result.push(...wrapRefs(eventLogicRefs));
1670
+ }
1671
+ }
1672
+ else if (nd.concept === 'Param' || nd.concept === 'ParamWithGroup') {
1668
1673
  // 调用处的 keyword = XXX 等也要修改,所以查 Logic、View 等的引用
1669
1674
  const pNode = NaslServer_1.toRaw(parentNode);
1670
- if ((0, nasl_language_server_core_1.isCallableNaslLogic)(pNode) || concepts_1.asserts.isStrictView(pNode)) {
1675
+ if ((0, service_1.isCallableNaslLogic)(pNode) || concepts_1.asserts.isStrictView(pNode)) {
1671
1676
  const refs = semEnv.refMgr.getReferences(semEnv, pNode);
1672
1677
  result.push(...wrapRefs(refs));
1673
1678
  }
@@ -1711,6 +1716,22 @@ let NaslServer = NaslServer_1 = class NaslServer {
1711
1716
  const minRange = {
1712
1717
  ...record,
1713
1718
  };
1719
+ // 搞事情:v4.1 新增 绑定事件 改类型,需要把 事件逻辑的引用,全部迁移过去
1720
+ if (nd.concept === 'BindEvent') {
1721
+ if (minRange.node.concept === 'Identifier') {
1722
+ /**
1723
+ * 使用正则替换倒数第二个点和倒数第一个点之间的内容
1724
+ * 例如 elements.button_1.bindEvents.XXX.logics -> elements.button_1.bindEvents.YYY.logics
1725
+ */
1726
+ minRange.newValue = minRange.node.namespace.replace(/(\.bindEvents\.)([^.]+)(\.logics)$/, `$1${newValue}$3`);
1727
+ minRange.setTypeMethods = 'setNamespace';
1728
+ }
1729
+ else if (minRange.node === nd) {
1730
+ // 自己
1731
+ minRange.newValue = newValue;
1732
+ minRange.setTypeMethods = 'setName';
1733
+ }
1734
+ }
1714
1735
  // 节点上ts临时变量标识,如果有这个就不rename
1715
1736
  if (minRange.node?.noTsReName) {
1716
1737
  return null;
@@ -1744,6 +1765,22 @@ let NaslServer = NaslServer_1 = class NaslServer {
1744
1765
  }
1745
1766
  // 如果匹配到的节点是Identifier表达式
1746
1767
  if (minRange.node instanceof concepts_1.Identifier) {
1768
+ /**
1769
+ * v4.1 新增 Identifier 可能是 页面元素 的事件逻辑 Logic 的引用 或 逻辑的引用
1770
+ * 页面元素 改名后,这个 Identifier 的 namespace 中间的元素名需要修改
1771
+ */
1772
+ if (nd.concept === 'ViewElement') {
1773
+ minRange.setTypeMethods = 'setNamespace';
1774
+ /**
1775
+ * 使用正则替换第二个点和第三个点之间的内容
1776
+ * 例如 elements.XXX.bindEvents.click.logics -> elements.YYY.bindEvents.click.logics
1777
+ */
1778
+ const parts = minRange.node.namespace.split('.');
1779
+ if (parts.length >= 1) {
1780
+ parts[1] = newValue;
1781
+ minRange.newValue = parts.join('.');
1782
+ }
1783
+ }
1747
1784
  // 如果参数修改影响了Identifier, 就说明是上一级逻辑的引用,所以就直接过滤掉就好了
1748
1785
  if (nd instanceof concepts_1.Param && minRange.node?.namespace?.endsWith('logics')) {
1749
1786
  return null;
@@ -1822,7 +1859,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
1822
1859
  minRange.setTypeMethods = 'setUrlValue';
1823
1860
  minRange.newValue = newTextValue;
1824
1861
  }
1825
- else if (minRange.node instanceof concepts_1.BindAttribute && NEED_SYNC_BIND_ATTRIBUTE.includes(minRange.node.name)) {
1862
+ else if (minRange.node instanceof concepts_1.BindAttribute && nasl_language_server_core_1.specialStringRefs.includes(minRange.node.name)) {
1826
1863
  // eslint-disable-next-line no-confusing-arrow
1827
1864
  minRange.newValue = (minRange.node.value ?? '').split('.').map((v, i) => i ? v : newValue.charAt(0).toLowerCase() + newValue.slice(1)).join('.');
1828
1865
  minRange.setTypeMethods = 'setValue';
@@ -1861,7 +1898,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
1861
1898
  // 如果要修改实体属性
1862
1899
  if (nd instanceof concepts_1.EntityProperty) {
1863
1900
  // 如果是修改实体属性,要同步绑定属性(属性名为 valueField / textField)
1864
- if (minRange.node instanceof concepts_1.BindAttribute && NEED_SYNC_BIND_ATTRIBUTE.includes(minRange.node.name)) {
1901
+ if (minRange.node instanceof concepts_1.BindAttribute && nasl_language_server_core_1.specialStringRefs.includes(minRange.node.name)) {
1865
1902
  // eslint-disable-next-line no-confusing-arrow
1866
1903
  minRange.newValue = (minRange.node.value ?? '').split('.').slice(0, -1).concat(newValue).join('.');
1867
1904
  minRange.setTypeMethods = 'setValue';
@@ -2126,7 +2163,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
2126
2163
  // 增加参数的副作用,用于更新logic和view
2127
2164
  _addParamsEffect(refsList, nd) {
2128
2165
  const parentNode = nd?.parentNode;
2129
- refsList.forEach(({ node: minRangeNode }) => {
2166
+ // node.nodePath 降序排列,保证父级或更深层的引用先处理
2167
+ const sortedRefs = (refsList || []).slice().sort((a, b) => {
2168
+ const pa = a?.node?.nodePath ?? '';
2169
+ const pb = b?.node?.nodePath ?? '';
2170
+ return pb.localeCompare(pa);
2171
+ });
2172
+ // 考虑 CallA(CallA(null))
2173
+ // 如果 不按 nodePath 降序排列,那么更新了第一个 CallA 后,第二个的 CallA 的 nodePath 中会有 -1
2174
+ // 推测可能是 CallA 变成了新节点,所以存的 node 变了
2175
+ sortedRefs.forEach(({ node: minRangeNode }) => {
2130
2176
  // 如果找到节点是callLogic就去更新
2131
2177
  if (nd instanceof concepts_1.Param) {
2132
2178
  if (minRangeNode instanceof concepts_1.CallLogic || minRangeNode instanceof concepts_1.CallAuthInterface) {
@@ -2305,13 +2351,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
2305
2351
  }
2306
2352
  // Convert和new都是自身携带类型的,就不进行修改
2307
2353
  if (node instanceof concepts_1.CallFunction && node.calleeNamespace === 'nasl.util' && ['Convert', 'New', 'FromString'].includes(node.calleeName)) {
2308
- if (node.typeArguments.length) {
2354
+ if (node.typeArguments?.length) {
2309
2355
  return node.typeArguments[0];
2310
2356
  }
2311
2357
  }
2312
2358
  // Convert和new都是自身携带类型的,就不进行修改
2313
2359
  if (node instanceof concepts_1.CallLogic && node.calleeNamespace === 'nasl.util' && node.calleeName === 'jsonDeserialize') {
2314
- if (node.typeArguments.length) {
2360
+ if (node.typeArguments?.length) {
2315
2361
  return node.typeArguments[0];
2316
2362
  }
2317
2363
  }
@@ -2354,6 +2400,8 @@ let NaslServer = NaslServer_1 = class NaslServer {
2354
2400
  utils.delay(55);
2355
2401
  }
2356
2402
  const { node, filePath, item } = itemDetail;
2403
+ if (!item)
2404
+ return;
2357
2405
  // 先按照顺序占位
2358
2406
  types.set(node, null);
2359
2407
  // 获取已知节点类型的类型
@@ -2384,6 +2432,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
2384
2432
  'CallFunction',
2385
2433
  'CallInterface',
2386
2434
  'CallMicroserviceInterface',
2435
+ 'CallGatewayInterface',
2387
2436
  'MemberExpression',
2388
2437
  'Return',
2389
2438
  'Variable',
@@ -2676,14 +2725,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
2676
2725
  // 集成内存优化:在标注过程中直接优化JSON,减少内存使用和处理时间
2677
2726
  (0, memory_optimization_1.optimizeJsonDuringAnnotation)(newJson);
2678
2727
  let tyAnn = tyAnnToJSON(this.semEnv.getType(oldNd));
2679
- if ((oldNd.concept === 'Variable' || oldNd.concept === 'Return' || oldNd.concept === 'Param')
2728
+ if ((oldNd.concept === 'Variable' || oldNd.concept === 'Return' || oldNd.concept === 'Param' || oldNd.concept === 'ParamWithGroup')
2680
2729
  && !oldNd.typeAnnotation
2681
2730
  && tyAnn?.typeKind !== 'typeParam') {
2682
2731
  newJson.typeAnnotation = tyAnn;
2683
2732
  }
2684
2733
  // 原来的标注环节复制粘贴过来改写的,调整了顺序
2685
2734
  // jsonSerializer 是 CallLogic,其余是 CallFunction。CallLogic 有好几个子类。
2686
- if (oldNd.concept === 'CallFunction' || oldNd instanceof concepts_1.CallLogic) {
2735
+ const isCallType1 = oldNd.concept === 'CallLogic' || oldNd.concept === 'CallConnector';
2736
+ const isCallFn = oldNd.concept === 'CallFunction';
2737
+ if (isCallType1 || isCallFn) {
2687
2738
  const tzArgIdx = timeZoneArgumentIndexMap.get(oldNd.calleeName);
2688
2739
  const args = oldNd.arguments;
2689
2740
  const tzArg = args ? args[tzArgIdx] : undefined;
@@ -2696,9 +2747,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
2696
2747
  /**
2697
2748
  * 特殊处理,不想去查两次类型, 因为是从函数签名上拿类型,所以直接合并在一起,先这样
2698
2749
  * 应该主要是 Java 扩展库逻辑调用
2699
- */
2700
- if (oldNd instanceof concepts_1.CallLogic && oldNd.__TypeArguments?.length) { // @ts-ignore
2701
- newJson.typeArguments = oldNd.__TypeArguments.map(tyAnnToJSON); // @ts-ignore
2750
+ */ // @ts-ignore
2751
+ if (oldNd.__TypeArguments?.length && isCallType1) { // @ts-ignore
2752
+ newJson.typeArguments = oldNd.__TypeArguments.map(tyAnnToJSON);
2702
2753
  newJson.typeAnnotation = tyAnn;
2703
2754
  }
2704
2755
  // 根据 https://projectmanage.netease-official.lcap.163yun.com/dashboard/FeatureDetail?id=2737356895760128&id1=null&iterationId=null&versionid=null&tab=info
@@ -2706,7 +2757,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
2706
2757
  // - 对argument.expression.typeAnnotation 无需做修改,保持为其实际类型
2707
2758
  // - 对argument.typeAnnotation,为根据对应Collection的泛型参数的类型填写其类型
2708
2759
  // 先不动这里,有空再调整
2709
- if (newJson.concept === 'CallFunction') {
2760
+ if (isCallFn) {
2710
2761
  if (oldNd.calleeNamespace === 'nasl.util') {
2711
2762
  const calleeName = oldNd.calleeName;
2712
2763
  const listFunctionParamIndexMaps = new Map(Object.entries({
@@ -2762,34 +2813,41 @@ let NaslServer = NaslServer_1 = class NaslServer {
2762
2813
  }
2763
2814
  }
2764
2815
  if (!tyAnn) {
2816
+ const isCallItfc = oldNd.concept === 'CallInterface' ||
2817
+ oldNd.concept === 'CallAuthInterface' ||
2818
+ oldNd.concept === 'CallMicroserviceInterface' ||
2819
+ oldNd.concept === 'CallGatewayInterface';
2820
+ if (isCallType1 || isCallFn || isCallItfc) {
2821
+ newJson.typeAnnotation = nasl_language_server_core_1.naslVoidTy.toJSON();
2822
+ }
2765
2823
  return newJson;
2766
2824
  }
2767
- if (oldNd.concept === 'CallQueryComponent' /* && !oldNd.isAutoInfer() 直接覆盖得了,老版的 typeAnnotation 问题有点多 */) { // @ts-ignore
2825
+ if (oldNd.concept === 'CallQueryComponent' /* && !oldNd.isAutoInfer() 直接覆盖得了,老版的 typeAnnotation 问题有点多 */) {
2768
2826
  newJson.typeAnnotation = tyAnn;
2769
2827
  // 新类型标注标的是对的,所以不再需要原来的改法(即,把 T 变为 { list:T, total: Long }
2770
2828
  }
2771
2829
  // 如果节点本身有类型就不去在塞一遍了
2772
2830
  // 有值而且没有类型再去设置
2773
2831
  // 但是Identifier 和 MemberExpression 都用标注出来的因为本身是变量,有类型也需要覆盖一下
2774
- else if (tyAnn && (oldNd.concept === 'Argument') && oldNd.getAncestor('Connector')?.concept === 'Connector') { // @ts-ignore
2832
+ else if (tyAnn && (oldNd.concept === 'Argument') && oldNd.getAncestor('Connector')?.concept === 'Connector') {
2775
2833
  newJson.typeAnnotation = tyAnn;
2776
2834
  }
2777
2835
  else if (oldNd.concept === 'Identifier' || oldNd.concept === 'MemberExpression') {
2778
2836
  // @ts-ignore 处理 Match,还是需要,因为后端翻译比较特殊
2779
- const iName = getNameOfIdAndMemExpr(newJson); // @ts-ignore
2837
+ const iName = getNameOfIdAndMemExpr(newJson);
2780
2838
  newJson.typeAnnotation = matchExprTyAnnMap.has(iName) ? matchExprTyAnnMap.get(iName) : tyAnn;
2781
2839
  }
2782
2840
  else if ((oldNd.concept === 'NewComposite') &&
2783
- (oldNd.typeAnnotation?.typeKind === 'anonymousStructure' || oldNd.typeAnnotation?.typeKind === 'generic')) { // @ts-ignore
2841
+ (oldNd.typeAnnotation?.typeKind === 'anonymousStructure' || oldNd.typeAnnotation?.typeKind === 'generic')) {
2784
2842
  newJson.typeAnnotation = tyAnn;
2785
2843
  }
2786
2844
  // 服务端需要默认值节点有类型来判断父节点是否是日期类型
2787
2845
  else if (newJson.concept === 'DefaultValue') {
2788
- // @ts-ignore v3.14.x 先改成这样,应该直接拿就行
2846
+ // v3.14.x 先改成这样,应该直接拿就行
2789
2847
  newJson.typeAnnotation = tyAnn;
2790
2848
  }
2791
2849
  // 定义上不挂类型
2792
- else if ((!oldNd.typeAnnotation) && !nasl_language_server_core_1.ReferenceManager.defConcept.includes(oldNd.concept)) { // @ts-ignore
2850
+ else if ((!oldNd.typeAnnotation) && !nasl_language_server_core_1.ReferenceManager.defConcept.includes(oldNd.concept)) {
2793
2851
  newJson.typeAnnotation = tyAnn;
2794
2852
  }
2795
2853
  return newJson;
@@ -3254,7 +3312,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
3254
3312
  this.logger.timeEnd('语言服务变更');
3255
3313
  }
3256
3314
  catch (e) {
3257
- console.log('error', e);
3258
3315
  console.error('error', e);
3259
3316
  this.logger.info('no "naslServer:nodeChange" event received');
3260
3317
  }
@@ -3309,7 +3366,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
3309
3366
  this.typerErrRecords.length = 0;
3310
3367
  this.oqlRemoveNodesTsPath.clear();
3311
3368
  this.semEnv.allocatedVEQNames.forEach(n => {
3312
- this.semEnv.refMgr.qNameDefs.delete(n);
3369
+ this.semEnv.refMgr.gQNameDefs.delete(n);
3313
3370
  });
3314
3371
  this.semEnv.allocatedVEQNames.length = 0;
3315
3372
  this.originProxyTargetNodes.clear();
@@ -3549,7 +3606,8 @@ let NaslServer = NaslServer_1 = class NaslServer {
3549
3606
  };
3550
3607
  proxyApp.frontendTypes.forEach((fet) => {
3551
3608
  fet.frontends.forEach((fe) => {
3552
- fe.views.forEach((view) => {
3609
+ // 兼容 null 是为了看从服务端发布 json 恢复出来的内容,基本前端都是 null 而不是标准的空数组 []
3610
+ fe.views?.forEach((view) => {
3553
3611
  traverseChildrenGetElementLogicRoot(view);
3554
3612
  });
3555
3613
  });
@@ -3596,6 +3654,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
3596
3654
  ctxProcessV2?.getSubLogics();
3597
3655
  });
3598
3656
  }
3657
+ async getClient() {
3658
+ return (0, nasl_server_client_1.getNaslServerClient)(this);
3659
+ }
3599
3660
  };
3600
3661
  exports.NaslServer = NaslServer;
3601
3662
  __decorate([