@lcap/nasl 3.9.0-beta.4 → 3.9.0-beta.5

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 (78) hide show
  1. package/out/automate/engine/utils.d.ts +0 -5
  2. package/out/automate/engine/utils.d.ts.map +1 -1
  3. package/out/automate/engine/utils.js +1 -123
  4. package/out/automate/engine/utils.js.map +1 -1
  5. package/out/common/Command.js +1 -1
  6. package/out/common/Command.js.map +1 -1
  7. package/out/common/Messager.d.ts.map +1 -1
  8. package/out/common/Messager.js +11 -2
  9. package/out/common/Messager.js.map +1 -1
  10. package/out/generator/annotation/full.d.ts +5 -0
  11. package/out/generator/annotation/full.d.ts.map +1 -0
  12. package/out/generator/annotation/full.js +30 -0
  13. package/out/generator/annotation/full.js.map +1 -0
  14. package/out/generator/annotation/incremental.d.ts +6 -0
  15. package/out/generator/annotation/incremental.d.ts.map +1 -0
  16. package/out/generator/annotation/incremental.js +145 -0
  17. package/out/generator/annotation/incremental.js.map +1 -0
  18. package/out/generator/annotation/index.d.ts +5 -0
  19. package/out/generator/annotation/index.d.ts.map +1 -0
  20. package/out/generator/annotation/index.js +21 -0
  21. package/out/generator/annotation/index.js.map +1 -0
  22. package/out/generator/annotation/types.d.ts +12 -0
  23. package/out/generator/annotation/types.d.ts.map +1 -0
  24. package/out/generator/annotation/types.js +3 -0
  25. package/out/generator/annotation/types.js.map +1 -0
  26. package/out/generator/annotation/utils.d.ts +11 -0
  27. package/out/generator/annotation/utils.d.ts.map +1 -0
  28. package/out/generator/annotation/utils.js +42 -0
  29. package/out/generator/annotation/utils.js.map +1 -0
  30. package/out/generator/genBundleFiles.d.ts.map +1 -1
  31. package/out/generator/genBundleFiles.js +2 -1
  32. package/out/generator/genBundleFiles.js.map +1 -1
  33. package/out/generator/index.d.ts +1 -0
  34. package/out/generator/index.d.ts.map +1 -1
  35. package/out/generator/index.js +1 -0
  36. package/out/generator/index.js.map +1 -1
  37. package/out/generator/release-body/body.d.ts +2 -1
  38. package/out/generator/release-body/body.d.ts.map +1 -1
  39. package/out/generator/release-body/body.js +28 -24
  40. package/out/generator/release-body/body.js.map +1 -1
  41. package/out/generator/release-body/internal.d.ts.map +1 -1
  42. package/out/generator/ui-library-declaration/index.d.ts +2 -0
  43. package/out/generator/ui-library-declaration/index.d.ts.map +1 -0
  44. package/out/generator/ui-library-declaration/index.js +18 -0
  45. package/out/generator/ui-library-declaration/index.js.map +1 -0
  46. package/out/generator/ui-library-declaration/types.d.ts +419 -0
  47. package/out/generator/ui-library-declaration/types.d.ts.map +1 -0
  48. package/out/generator/ui-library-declaration/types.js +3 -0
  49. package/out/generator/ui-library-declaration/types.js.map +1 -0
  50. package/out/server/index.d.ts +1 -2
  51. package/out/server/index.d.ts.map +1 -1
  52. package/out/server/index.js +2 -2
  53. package/out/server/index.js.map +1 -1
  54. package/out/server/naslServer.d.ts +7 -1
  55. package/out/server/naslServer.d.ts.map +1 -1
  56. package/out/server/naslServer.js +39 -14
  57. package/out/server/naslServer.js.map +1 -1
  58. package/out/server/translator.d.ts +1 -1
  59. package/out/server/translator.d.ts.map +1 -1
  60. package/out/server/translator.js +53 -53
  61. package/out/server/translator.js.map +1 -1
  62. package/out/service/storage/init.d.ts +1 -25
  63. package/out/service/storage/init.d.ts.map +1 -1
  64. package/out/service/storage/init.js +11 -36
  65. package/out/service/storage/init.js.map +1 -1
  66. package/out/service/storage/types.d.ts +41 -0
  67. package/out/service/storage/types.d.ts.map +1 -0
  68. package/out/service/storage/types.js +10 -0
  69. package/out/service/storage/types.js.map +1 -0
  70. package/out/service/storage/utils.d.ts +15 -0
  71. package/out/service/storage/utils.d.ts.map +1 -0
  72. package/out/service/storage/utils.js +72 -0
  73. package/out/service/storage/utils.js.map +1 -0
  74. package/out/utils/node.d.ts.map +1 -1
  75. package/out/utils/node.js +0 -4
  76. package/out/utils/node.js.map +1 -1
  77. package/package.json +13 -18
  78. package/ts-worker/lib/tsserver.js +6 -6
@@ -54,7 +54,6 @@ const diagnostic_1 = require("../manager/diagnostic");
54
54
  const naslStdlibMap_1 = __importDefault(require("./naslStdlibMap"));
55
55
  const utils_1 = require("../utils");
56
56
  const decorators_1 = require("../decorators");
57
- const utils_2 = require("../automate/engine/utils");
58
57
  const EmbeddedTSFileLineMap = {
59
58
  Entity: 3,
60
59
  };
@@ -260,7 +259,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
260
259
  return this.messager.requestCommand('start');
261
260
  }
262
261
  terminate() {
263
- this.worker.terminate();
262
+ return this.worker.terminate();
264
263
  }
265
264
  async createUiTs(components, optinos) {
266
265
  const { standardUIComponents, // 标准组件(带有ts类型定义文件的组件)
@@ -529,15 +528,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
529
528
  const url = `/proxy/nasl-storage/api/App/debugEmbedded?id=${app.id}`;
530
529
  /// #if process.env.NODE_ENV === 'development'
531
530
  // 首次尝试请求
532
- await this.http.post(`/proxy/nasl-storage/api/App/debugEmbedded?id=${app.id}`, openFiles[0]).catch(() => (this.openDebugEmbedded = false));
531
+ await this.http.post(url, openFiles[0]).catch(() => (this.openDebugEmbedded = false));
533
532
  if (this.openDebugEmbedded && globalThis.window) {
534
533
  // For TS build
535
534
  try {
536
535
  let canDebug = true;
537
- await this.http.post(`/proxy/nasl-storage/api/App/debugEmbedded?id=${app.id}`, openFiles[0]).catch(() => (canDebug = false));
536
+ await this.http.post(url, openFiles[0]).catch(() => (canDebug = false));
538
537
  if (canDebug) {
539
538
  await Promise.all(openFiles.map(async (file) => {
540
- const res = await this.http.post(`/proxy/nasl-storage/api/App/debugEmbedded?id=${app.id}`, file);
539
+ const res = await this.http.post(url, file);
541
540
  return res.data;
542
541
  }));
543
542
  }
@@ -548,7 +547,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
548
547
  }
549
548
  /// #endif
550
549
  /// #if process.env.BUILD_TARGET === 'node'
551
- if (globalThis.process) {
550
+ if (globalThis.process && process.env.NODE_ENV === 'development') {
552
551
  // For TS build
553
552
  try {
554
553
  await Promise.all(openFiles.map(async (file) => fs.outputFile(path.join(__dirname, '../debug/apps', app.id, file.file), file.fileContent)));
@@ -2814,7 +2813,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
2814
2813
  * 判断当前CallInterface 对应的 Interface 是否含有鉴权方式
2815
2814
  */
2816
2815
  hasAuth(node) {
2817
- const tInterface = (0, utils_2.getNodeByNodeCallee)(node.rootNode, node.calleewholeKey);
2816
+ const tInterface = (0, service_1.getNodeByNodeCallee)(node.rootNode, node.calleewholeKey);
2818
2817
  return tInterface instanceof concepts_1.AuthInterface;
2819
2818
  }
2820
2819
  /* 接口导入查找 */
@@ -4596,8 +4595,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
4596
4595
  this.logger.time('全量标注');
4597
4596
  const nodes = [];
4598
4597
  this.file2NodeMap.forEach((fileNode, filePath) => {
4599
- // 先不排除view,传递给后端的时候,去除views下的标注
4600
- if (!['DataSource', 'Enum', 'Role'].includes(fileNode.concept)) {
4598
+ if (!(0, service_1.isIgnoreAnnotationFileNode)(fileNode)) {
4601
4599
  fileNode.sourceMap.forEach((item, node) => {
4602
4600
  nodes.push({
4603
4601
  filePath,
@@ -4608,26 +4606,49 @@ let NaslServer = NaslServer_1 = class NaslServer {
4608
4606
  }
4609
4607
  });
4610
4608
  const typesMap = await this.getQuickInfoNodesTypeMap(nodes, true);
4611
- console.time('app toJSON');
4609
+ this.logger.time('app to AnnotatedJSON');
4612
4610
  const jsonMap = new Map();
4613
4611
  const json = app._toJSON((source, instance) => {
4614
4612
  jsonMap.set(instance, source);
4615
4613
  return source;
4616
4614
  });
4617
- console.timeEnd('app toJSON');
4615
+ this.logger.timeEnd('app to AnnotatedJSON');
4618
4616
  this.logger.timeEnd('全量标注');
4619
4617
  // 测试环境或者是调试模式打印数据
4620
4618
  if (utils.isDebugMode || utils.isTestBrowser) {
4621
4619
  this.logger.info('全量标注数据', json);
4622
4620
  }
4623
4621
  if (releaseFlag) {
4624
- console.time('annotationToJson');
4622
+ this.logger.time('annotationToJson');
4625
4623
  // 全量标注后对json进行一些修改,为了服务端翻译处理
4626
4624
  this.annotationToJson(typesMap, json, jsonMap);
4627
- console.timeEnd('annotationToJson');
4625
+ this.logger.timeEnd('annotationToJson');
4628
4626
  }
4629
4627
  return json;
4630
4628
  }
4629
+ /**
4630
+ * 标注指定文件
4631
+ *
4632
+ * @description 会进行 TS 翻译
4633
+ */
4634
+ annotationFiles(fileNodes) {
4635
+ const nodes = [];
4636
+ const files = fileNodes.filter((node) => !(0, service_1.isIgnoreAnnotationFileNode)(node));
4637
+ for (const node of files) {
4638
+ if (!node.sourceMap) {
4639
+ continue;
4640
+ }
4641
+ const filePath = node.getEmbeddedFilePath();
4642
+ node.sourceMap.forEach((item, node) => {
4643
+ nodes.push({
4644
+ filePath: filePath,
4645
+ node,
4646
+ item,
4647
+ });
4648
+ });
4649
+ }
4650
+ return this.getQuickInfoNodesTypeMap(nodes, true);
4651
+ }
4631
4652
  // 增量标注
4632
4653
  *_incrementalAnnotationJSONWithGenerator(records) {
4633
4654
  this.logger.time('增量标注');
@@ -4640,7 +4661,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
4640
4661
  }
4641
4662
  record.id = fileNode.id;
4642
4663
  record.node = fileNode;
4643
- if (['Structure', 'DataSource', 'Entity', 'Enum', 'Role', 'MetadataType'].includes(fileNode.concept) || !fileNode.sourceMap) {
4664
+ if ((0, service_1.isIgnoreAnnotationFileNode)(fileNode)) {
4644
4665
  return;
4645
4666
  }
4646
4667
  yield* utils.wrapIteratorToGenerator(fileNode.sourceMap.entries(), ([nodeItem, item]) => {
@@ -5203,6 +5224,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
5203
5224
  for (let i = 0; i < fileNodeChildren.length; i++) {
5204
5225
  const fileNodeItem = fileNodeChildren[i];
5205
5226
  const result = await utils.timeSlicingWithGenerator(fileNodeItem.toEmbeddedTSFile());
5227
+ // @ts-ignore
5206
5228
  fileNodeItem.sourceMap = result.sourceMap;
5207
5229
  if (action === 'create') {
5208
5230
  await this.handleChange(fileNodeItem, fileNodeItem, result, action);
@@ -5220,6 +5242,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
5220
5242
  for (let i = 0; i < fileNodeChildren.length; i++) {
5221
5243
  const fileNodeItem = fileNodeChildren[i];
5222
5244
  const result = await utils.timeSlicingWithGenerator(fileNodeItem.toEmbeddedTSFile());
5245
+ // @ts-ignore
5223
5246
  fileNodeItem.sourceMap = result.sourceMap;
5224
5247
  if (action === 'create') {
5225
5248
  await this.handleChange(fileNodeItem, fileNodeItem, result, action);
@@ -5245,6 +5268,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
5245
5268
  for (let i = 0; i < fileNodeChildren.length; i++) {
5246
5269
  const fileNodeItem = fileNodeChildren[i];
5247
5270
  const result = await utils.timeSlicingWithGenerator(fileNodeItem.toEmbeddedTSFile());
5271
+ // @ts-ignore
5248
5272
  fileNodeItem.sourceMap = result.sourceMap;
5249
5273
  if (action === 'create') {
5250
5274
  await this.handleChange(fileNodeItem, fileNodeItem, result, action);
@@ -5381,6 +5405,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
5381
5405
  fileContent: result.code,
5382
5406
  },
5383
5407
  ]);
5408
+ // @ts-ignore
5384
5409
  fileNode.sourceMap = result.sourceMap;
5385
5410
  if (action === 'update' || action === 'create') {
5386
5411
  if ($event?.field !== 'name') {