@lcap/nasl 2.19.0-beta.1 → 2.19.0-beta.3
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.
- package/out/common/BaseNode.js +4 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/Abort__.d.ts +25 -0
- package/out/concepts/Abort__.js +80 -0
- package/out/concepts/Abort__.js.map +1 -0
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +3 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/CallFunction__.js +23 -7
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +1 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +9 -65
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/DatabaseTypeAnnotation__.d.ts +31 -0
- package/out/concepts/DatabaseTypeAnnotation__.js +78 -0
- package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -0
- package/out/concepts/EnumItem__.d.ts +5 -5
- package/out/concepts/EnumItem__.js +6 -6
- package/out/concepts/Enum__.d.ts +20 -19
- package/out/concepts/Enum__.js +28 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +1 -1
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +213 -0
- package/out/concepts/FrontendLibrary__.js +352 -0
- package/out/concepts/FrontendLibrary__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +373 -0
- package/out/concepts/Frontend__.js +685 -0
- package/out/concepts/Frontend__.js.map +1 -0
- package/out/concepts/Integration__.d.ts +53 -0
- package/out/concepts/Integration__.js +143 -0
- package/out/concepts/Integration__.js.map +1 -0
- package/out/concepts/JavaLogic__.d.ts +42 -0
- package/out/concepts/JavaLogic__.js +122 -0
- package/out/concepts/JavaLogic__.js.map +1 -0
- package/out/concepts/Logic__.js +3 -0
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MicroApp__.d.ts +51 -0
- package/out/concepts/MicroApp__.js +113 -0
- package/out/concepts/MicroApp__.js.map +1 -0
- package/out/concepts/NewComposite__.js +14 -14
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +1 -0
- package/out/concepts/NewList__.js +17 -1
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -0
- package/out/concepts/NewMap__.js +18 -1
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +2 -0
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +2 -0
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +3 -3
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ViewBlock__.d.ts +35 -0
- package/out/concepts/ViewBlock__.js +85 -0
- package/out/concepts/ViewBlock__.js.map +1 -0
- package/out/concepts/ViewElement__.js +1 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +1 -0
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +4 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/generator/genBundleFiles.js +10 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +3 -0
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/icestark.d.ts +2 -0
- package/out/generator/icestark.js +48 -0
- package/out/generator/icestark.js.map +1 -0
- package/out/generator/microApp.d.ts +2 -0
- package/out/generator/microApp.js +35 -0
- package/out/generator/microApp.js.map +1 -0
- package/out/generator/qiankun.d.ts +2 -0
- package/out/generator/qiankun.js +52 -0
- package/out/generator/qiankun.js.map +1 -0
- package/out/manager/stepRecorder.d.ts +20 -0
- package/out/manager/stepRecorder.js +110 -0
- package/out/manager/stepRecorder.js.map +1 -0
- package/out/sentry/index.d.ts +29 -0
- package/out/sentry/index.js +111 -0
- package/out/sentry/index.js.map +1 -0
- package/out/server/extendBaseNode.js +5 -1
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +11 -8
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/naslServer.js +118 -9
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +43 -10
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/add.configs.js +2 -0
- package/out/service/creator/add.configs.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/creator/index.js +2 -0
- package/out/service/creator/index.js.map +1 -1
- package/out/service/storage/api.d.ts +18 -0
- package/out/service/storage/api.js +12 -0
- package/out/service/storage/api.js.map +1 -1
- package/out/service/storage/init.d.ts +41 -1
- package/out/service/storage/init.js +175 -30
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts +9 -1
- package/out/service/storage/service.js +27 -1
- package/out/service/storage/service.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +6 -0
- package/out/templator/genListViewBlock.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/nasl.core.ts +2 -0
- package/sandbox/stdlib/nasl.oql.ts +16 -4
- package/sandbox/stdlib/nasl.util.ts +2 -1
- package/src/common/BaseNode.ts +3 -1
- package/src/concepts/App__.ts +41 -1
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/CallFunction__.ts +34 -20
- package/src/concepts/CallInterface__.ts +19 -1
- package/src/concepts/CallLogic__.ts +8 -65
- package/src/concepts/EnumItem__.ts +6 -6
- package/src/concepts/Enum__.ts +22 -19
- package/src/concepts/ForEachStatement__.ts +1 -1
- package/src/concepts/Logic__.ts +13 -10
- package/src/concepts/NewComposite__.ts +14 -14
- package/src/concepts/NewList__.ts +18 -1
- package/src/concepts/NewMap__.ts +19 -1
- package/src/concepts/OqlQueryComponent__.ts +2 -0
- package/src/concepts/StringInterpolation__.ts +6 -4
- package/src/concepts/TypeAnnotation__.ts +41 -3
- package/src/concepts/ViewElement__.ts +1 -1
- package/src/concepts/View__.ts +3 -2
- package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
- package/src/generator/genBundleFiles.ts +10 -1
- package/src/generator/genReleaseBody.ts +3 -1
- package/src/server/extendBaseNode.ts +4 -1
- package/src/server/formatTsUtils.ts +11 -8
- package/src/server/naslServer.ts +124 -11
- package/src/server/translator.ts +37 -10
- package/src/service/creator/add.configs.js +3 -0
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/creator/index.js +3 -0
- package/src/service/storage/api.js +12 -0
- package/src/service/storage/init.ts +207 -29
- package/src/service/storage/service.ts +29 -1
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genListViewBlock.ts +6 -0
- package/ts-worker/lib/tsserver.js +10 -2
- package/ts-worker/package.json +1 -0
- package/ts-worker/webpack.config.js +11 -2
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/src/automate/engine/dist/index.dev.js +0 -517
- package/src/common/dist/BaseNode.js +0 -1101
- package/src/concepts/basics/stdlib/dist/nasl.util.js +0 -1602
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
- package/src/concepts/dist/BindAttribute__.js +0 -760
- package/src/concepts/dist/BindEvent__.js +0 -732
- package/src/concepts/dist/CallFunction__.js +0 -527
- package/src/concepts/dist/CallLogic__.js +0 -932
- package/src/concepts/dist/Identifier__.js +0 -311
- package/src/concepts/dist/StringInterpolation__.js +0 -231
- package/src/concepts/dist/TypeAnnotation__.js +0 -834
- package/src/concepts/dist/ViewElement__.js +0 -1692
- package/src/concepts/dist/View__.js +0 -1601
- package/src/generator/dist/genBundleFiles.js +0 -261
- package/src/generator/dist/genMetaData.js +0 -245
- package/src/generator/dist/permission.js +0 -392
- package/src/server/dist/naslServer.js +0 -3590
- package/src/service/storage/dist/init.js +0 -579
- package/src/templator/dist/genEditTableBlock.js +0 -204
- package/src/templator/dist/genGridViewBlock.js +0 -265
- package/src/templator/dist/genListViewBlock.js +0 -84
- package/src/templator/dist/genTableBlock.js +0 -209
- package/src/templator/dist/utils.js +0 -527
- package/ts-worker/dist/webpack.config.dev.js +0 -106
- /package/src/service/{dataSource → datasource}/api.js +0 -0
- /package/src/service/{dataSource → datasource}/index.js +0 -0
|
@@ -121,6 +121,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
121
121
|
@property()
|
|
122
122
|
ruleMap: Object = undefined;
|
|
123
123
|
|
|
124
|
+
|
|
125
|
+
|
|
124
126
|
/**
|
|
125
127
|
* @param source 需要合并的部分参数
|
|
126
128
|
*/
|
|
@@ -157,6 +159,10 @@ export class TypeAnnotation extends BaseNode {
|
|
|
157
159
|
});
|
|
158
160
|
}
|
|
159
161
|
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
160
166
|
/**
|
|
161
167
|
* 插入类型标注
|
|
162
168
|
* @internal
|
|
@@ -189,6 +195,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
189
195
|
return typeAnnotation;
|
|
190
196
|
}
|
|
191
197
|
|
|
198
|
+
|
|
199
|
+
|
|
192
200
|
/**
|
|
193
201
|
* 插入类型标注
|
|
194
202
|
* @param typeAnnotationOptions 类型标注参数
|
|
@@ -211,6 +219,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
211
219
|
return node;
|
|
212
220
|
}
|
|
213
221
|
|
|
222
|
+
|
|
223
|
+
|
|
214
224
|
/**
|
|
215
225
|
* 添加类型标注
|
|
216
226
|
* @internal
|
|
@@ -230,6 +240,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
230
240
|
return this._insertTypeAnnotationInTypeArgumentsAt(options as any, index);
|
|
231
241
|
}
|
|
232
242
|
|
|
243
|
+
|
|
244
|
+
|
|
233
245
|
/**
|
|
234
246
|
* 添加类型标注
|
|
235
247
|
* @param typeAnnotationOptions 类型标注参数
|
|
@@ -253,6 +265,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
253
265
|
return node;
|
|
254
266
|
}
|
|
255
267
|
|
|
268
|
+
|
|
269
|
+
|
|
256
270
|
/**
|
|
257
271
|
* 插入类型标注
|
|
258
272
|
* @internal
|
|
@@ -285,6 +299,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
285
299
|
return typeAnnotation;
|
|
286
300
|
}
|
|
287
301
|
|
|
302
|
+
|
|
303
|
+
|
|
288
304
|
/**
|
|
289
305
|
* 插入类型标注
|
|
290
306
|
* @param typeAnnotationOptions 类型标注参数
|
|
@@ -307,6 +323,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
307
323
|
return node;
|
|
308
324
|
}
|
|
309
325
|
|
|
326
|
+
|
|
327
|
+
|
|
310
328
|
/**
|
|
311
329
|
* 添加类型标注
|
|
312
330
|
* @internal
|
|
@@ -326,6 +344,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
326
344
|
return this._insertTypeAnnotationInReturnTypeAt(options as any, index);
|
|
327
345
|
}
|
|
328
346
|
|
|
347
|
+
|
|
348
|
+
|
|
329
349
|
/**
|
|
330
350
|
* 添加类型标注
|
|
331
351
|
* @param typeAnnotationOptions 类型标注参数
|
|
@@ -349,6 +369,11 @@ export class TypeAnnotation extends BaseNode {
|
|
|
349
369
|
return node;
|
|
350
370
|
}
|
|
351
371
|
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
352
377
|
/**
|
|
353
378
|
* 插入数据结构属性
|
|
354
379
|
* @internal
|
|
@@ -381,6 +406,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
381
406
|
return structureProperty;
|
|
382
407
|
}
|
|
383
408
|
|
|
409
|
+
|
|
410
|
+
|
|
384
411
|
/**
|
|
385
412
|
* 插入数据结构属性
|
|
386
413
|
* @param structurePropertyOptions 数据结构属性参数
|
|
@@ -403,6 +430,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
403
430
|
return node;
|
|
404
431
|
}
|
|
405
432
|
|
|
433
|
+
|
|
434
|
+
|
|
406
435
|
/**
|
|
407
436
|
* 添加数据结构属性
|
|
408
437
|
* @internal
|
|
@@ -422,6 +451,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
422
451
|
return this._insertStructurePropertyAt(options as any, index);
|
|
423
452
|
}
|
|
424
453
|
|
|
454
|
+
|
|
455
|
+
|
|
425
456
|
/**
|
|
426
457
|
* 添加数据结构属性
|
|
427
458
|
* @param structurePropertyOptions 数据结构属性参数
|
|
@@ -445,6 +476,9 @@ export class TypeAnnotation extends BaseNode {
|
|
|
445
476
|
return node;
|
|
446
477
|
}
|
|
447
478
|
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
448
482
|
/**
|
|
449
483
|
* 删除类型标注
|
|
450
484
|
* @param typeAnnotation 已有的类型标注实例
|
|
@@ -452,10 +486,12 @@ export class TypeAnnotation extends BaseNode {
|
|
|
452
486
|
removeTypeAnnotationInTypeArguments(typeAnnotation: TypeAnnotation): void;
|
|
453
487
|
|
|
454
488
|
removeTypeAnnotationInTypeArguments(options: TypeAnnotation) {
|
|
455
|
-
|
|
489
|
+
let typeAnnotation: TypeAnnotation = options;
|
|
456
490
|
return typeAnnotation.delete();
|
|
457
491
|
}
|
|
458
492
|
|
|
493
|
+
|
|
494
|
+
|
|
459
495
|
/**
|
|
460
496
|
* 删除类型标注
|
|
461
497
|
* @param typeAnnotation 已有的类型标注实例
|
|
@@ -463,7 +499,7 @@ export class TypeAnnotation extends BaseNode {
|
|
|
463
499
|
removeTypeAnnotationInReturnType(typeAnnotation: TypeAnnotation): void;
|
|
464
500
|
|
|
465
501
|
removeTypeAnnotationInReturnType(options: TypeAnnotation) {
|
|
466
|
-
|
|
502
|
+
let typeAnnotation: TypeAnnotation = options;
|
|
467
503
|
return typeAnnotation.delete();
|
|
468
504
|
}
|
|
469
505
|
|
|
@@ -490,6 +526,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
490
526
|
return params;
|
|
491
527
|
}
|
|
492
528
|
|
|
529
|
+
|
|
530
|
+
|
|
493
531
|
/**
|
|
494
532
|
* 删除数据结构属性
|
|
495
533
|
* @param structureProperty 已有的数据结构属性实例
|
|
@@ -497,7 +535,7 @@ export class TypeAnnotation extends BaseNode {
|
|
|
497
535
|
removeStructureProperty(structureProperty: StructureProperty): void;
|
|
498
536
|
|
|
499
537
|
removeStructureProperty(options: StructureProperty) {
|
|
500
|
-
|
|
538
|
+
let structureProperty: StructureProperty = options;
|
|
501
539
|
return structureProperty.delete();
|
|
502
540
|
}
|
|
503
541
|
|
|
@@ -1501,7 +1501,7 @@ export class ViewElement extends BaseNode {
|
|
|
1501
1501
|
this.children.forEach((element) => {
|
|
1502
1502
|
code += element.toEmbeddedTS(shiftState(state, code, {
|
|
1503
1503
|
tabSize: (state?.tabSize || 0),
|
|
1504
|
-
}));
|
|
1504
|
+
}), levelIndex);
|
|
1505
1505
|
});
|
|
1506
1506
|
code += indent((state?.tabSize || 0) + 2);
|
|
1507
1507
|
code += ']';
|
package/src/concepts/View__.ts
CHANGED
|
@@ -259,7 +259,7 @@ export class View extends BaseNode {
|
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
|
|
262
|
+
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* 插入页面元素
|
|
@@ -1095,7 +1095,7 @@ export class View extends BaseNode {
|
|
|
1095
1095
|
}
|
|
1096
1096
|
|
|
1097
1097
|
|
|
1098
|
-
|
|
1098
|
+
|
|
1099
1099
|
|
|
1100
1100
|
/**
|
|
1101
1101
|
* 删除页面元素
|
|
@@ -2101,6 +2101,7 @@ export class View extends BaseNode {
|
|
|
2101
2101
|
}
|
|
2102
2102
|
|
|
2103
2103
|
getRightCode(code: string, assignment: Assignment | BatchAssignment, rightNode: any): string {
|
|
2104
|
+
code = code.replaceAll('\n', ' ');
|
|
2104
2105
|
const logic = assignment.logic;
|
|
2105
2106
|
const logicRtn = logic?.returns[0];
|
|
2106
2107
|
// 调用接口,参数替换成 null
|
|
@@ -1078,7 +1078,8 @@ export default new Namespace({
|
|
|
1078
1078
|
}),
|
|
1079
1079
|
new Param({
|
|
1080
1080
|
name: 'formatter',
|
|
1081
|
-
|
|
1081
|
+
description: '格式化规则,默认为yyyy-MM-dd,即年月日格式',
|
|
1082
|
+
defaultValue: 'yyyy-MM-dd',
|
|
1082
1083
|
defaultExpression: new StringLiteral({ value: 'yyyy-MM-dd' }),
|
|
1083
1084
|
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
1084
1085
|
}),
|
|
@@ -1100,8 +1101,9 @@ export default new Namespace({
|
|
|
1100
1101
|
}),
|
|
1101
1102
|
new Param({
|
|
1102
1103
|
name: 'formatter',
|
|
1104
|
+
description: '格式化规则,默认为yyyy-MM-dd',
|
|
1103
1105
|
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
1104
|
-
defaultValue: '
|
|
1106
|
+
defaultValue: 'yyyy-MM-dd HH:mm:ss',
|
|
1105
1107
|
defaultExpression: new StringLiteral({ value: 'yyyy-MM-dd HH:mm:ss' }),
|
|
1106
1108
|
}),
|
|
1107
1109
|
],
|
|
@@ -370,9 +370,18 @@ export function genBundleFiles(app: App,
|
|
|
370
370
|
sourceMap: {
|
|
371
371
|
url: bundleSourceMapPath,
|
|
372
372
|
},
|
|
373
|
+
compress: {
|
|
374
|
+
// @ts-ignore
|
|
375
|
+
awaits: false,
|
|
376
|
+
},
|
|
373
377
|
});
|
|
374
378
|
} else {
|
|
375
|
-
minifyObj = UglifyJS.minify(content
|
|
379
|
+
minifyObj = UglifyJS.minify(content, {
|
|
380
|
+
compress: {
|
|
381
|
+
// @ts-ignore
|
|
382
|
+
awaits: false,
|
|
383
|
+
},
|
|
384
|
+
});
|
|
376
385
|
}
|
|
377
386
|
const outputs = [
|
|
378
387
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App, Assignment, BatchAssignment, CallFunction, CallInterface, CallLogic, ForEachStatement, IfStatement, Logic, LogicItem, Match, MatchCase, MemberExpression, Role, SwitchCase, SwitchStatement, View, ViewElement, WhileStatement, StringInterpolation } from '../concepts';
|
|
1
|
+
import { App, Assignment, BatchAssignment, CallFunction, CallInterface, CallLogic, ForEachStatement, IfStatement, Logic, LogicItem, Match, MatchCase, MemberExpression, Role, SwitchCase, SwitchStatement, View, ViewElement, WhileStatement, StringInterpolation, ExternalDestination } from '../concepts';
|
|
2
2
|
import { genBundleFiles } from './genBundleFiles';
|
|
3
3
|
import { genPermissionData } from './permission';
|
|
4
4
|
|
|
@@ -265,6 +265,8 @@ function getAuthApiPathList(app: App) {
|
|
|
265
265
|
logicItems = [state.object, state.property];
|
|
266
266
|
} else if (state instanceof StringInterpolation) {
|
|
267
267
|
logicItems = [...state.expressions];
|
|
268
|
+
} else if (state instanceof ExternalDestination) {
|
|
269
|
+
logicItems = [state.anchor, state.link];
|
|
268
270
|
}
|
|
269
271
|
|
|
270
272
|
return logicItems.filter((item) => !!item);
|
|
@@ -87,7 +87,10 @@ BaseNode.prototype.changeName = async function changeName(newValue: string, upda
|
|
|
87
87
|
*/
|
|
88
88
|
const res = naslServer._renamePrepare(this, refsList, newValue);
|
|
89
89
|
if (res.length <= 1) {
|
|
90
|
-
(this
|
|
90
|
+
if (this.concept === 'enumItem') {
|
|
91
|
+
(this as any).setValue(newValue);
|
|
92
|
+
} else
|
|
93
|
+
(this as SetNameNode).setName(newValue);
|
|
91
94
|
} else {
|
|
92
95
|
const callback = (value: boolean) => {
|
|
93
96
|
if (value) {
|
|
@@ -45,16 +45,19 @@ export function type2TypeAnnotation(oldType: Array<any> | {}): TypeAnnotation {
|
|
|
45
45
|
let typeAnnotation: TypeAnnotation;
|
|
46
46
|
try {
|
|
47
47
|
const { typeName, typeNamespace, typeArguments, typeKind, properties } = type as any;
|
|
48
|
-
if (typeKind === 'anonymousStructure'
|
|
48
|
+
if (typeKind === 'anonymousStructure') {
|
|
49
49
|
// 自定义类型
|
|
50
50
|
const newProperties: StructureProperty[] = [];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
if (Array.isArray(properties) && properties.length) {
|
|
52
|
+
properties.forEach((item) => {
|
|
53
|
+
if (!item?.name?.startsWith('__')) {
|
|
54
|
+
// 如果没有获取到类型,就默认塞一个string
|
|
55
|
+
const itemType = type2TypeAnnotation(item.typeInfo) || TypeAnnotation.createPrimitive('String');
|
|
56
|
+
const structureProperty = StructureProperty.from({ name: item.name, typeAnnotation: itemType }, typeAnnotation, 'properties');
|
|
57
|
+
newProperties.push(structureProperty);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
58
61
|
typeAnnotation = TypeAnnotation.createTypeAnonymousStructure(newProperties);
|
|
59
62
|
} else if (!typeName || typeName === 'Promise' || typeName === 'nasl' || typeName === '___IDENTIFIER__') {
|
|
60
63
|
return null;
|
package/src/server/naslServer.ts
CHANGED
|
@@ -61,6 +61,8 @@ import {
|
|
|
61
61
|
BooleanLiteral,
|
|
62
62
|
BatchAssignment,
|
|
63
63
|
ForEachStatement,
|
|
64
|
+
NewList,
|
|
65
|
+
NewMap,
|
|
64
66
|
} from '../concepts';
|
|
65
67
|
import { lsp2tspNumber, SourceMap, SourceMapItem } from '../translator';
|
|
66
68
|
import axios from '../service/storage';
|
|
@@ -844,8 +846,8 @@ export class NaslServer {
|
|
|
844
846
|
// record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
|
|
845
847
|
// }
|
|
846
848
|
record.suggestionDiagnostics = record.suggestionDiagnostics
|
|
847
|
-
.filter((item) => [`'__LogicEmpty' is declared but its value is never read.`, `'__destinationEmpty__' is declared but its value is never read
|
|
848
|
-
|
|
849
|
+
.filter((item) => [`'__LogicEmpty' is declared but its value is never read.`, `'__destinationEmpty__' is declared but its value is never read.`,
|
|
850
|
+
`'__UpdateNoProperty__' is declared but its value is never read.`].includes(item.text))
|
|
849
851
|
.map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, node as FileNode, record))
|
|
850
852
|
.filter((diag) => !!diag);
|
|
851
853
|
|
|
@@ -1000,6 +1002,114 @@ export class NaslServer {
|
|
|
1000
1002
|
}
|
|
1001
1003
|
}
|
|
1002
1004
|
}
|
|
1005
|
+
} else if (node instanceof NewList && !node.typeAnnotation) {
|
|
1006
|
+
const { items } = node || {};
|
|
1007
|
+
const typeAnnotationMap: any = {};
|
|
1008
|
+
// 最多数的类型
|
|
1009
|
+
let maxTypeAnnotationInfo: any = {
|
|
1010
|
+
typeAnnotation: null,
|
|
1011
|
+
count: 0,
|
|
1012
|
+
};
|
|
1013
|
+
if (Array.isArray(items)) {
|
|
1014
|
+
items.forEach((item) => {
|
|
1015
|
+
const typeAnnotation = item.__TypeAnnotation;
|
|
1016
|
+
// 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
|
|
1017
|
+
if (typeAnnotation) {
|
|
1018
|
+
const sortedTypeKey = typeAnnotation.sortedTypeKey;
|
|
1019
|
+
if (!typeAnnotationMap[sortedTypeKey]) {
|
|
1020
|
+
typeAnnotationMap[sortedTypeKey] = {
|
|
1021
|
+
typeAnnotation,
|
|
1022
|
+
items: [],
|
|
1023
|
+
count: 0,
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
const typeAnnotationInfo = typeAnnotationMap[sortedTypeKey];
|
|
1027
|
+
typeAnnotationInfo.items.push(item);
|
|
1028
|
+
typeAnnotationInfo.count++;
|
|
1029
|
+
const { count } = typeAnnotationInfo;
|
|
1030
|
+
if (maxTypeAnnotationInfo.count < count) {
|
|
1031
|
+
maxTypeAnnotationInfo = {
|
|
1032
|
+
typeAnnotation,
|
|
1033
|
+
count,
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
const {
|
|
1040
|
+
typeAnnotation: maxTypeAnnotation,
|
|
1041
|
+
} = maxTypeAnnotationInfo;
|
|
1042
|
+
for (const sortedTypeKey in typeAnnotationMap) {
|
|
1043
|
+
const { typeAnnotation, items } = typeAnnotationMap[sortedTypeKey];
|
|
1044
|
+
if (maxTypeAnnotation?.sortedTypeKey !== typeAnnotation?.sortedTypeKey) {
|
|
1045
|
+
if (Array.isArray(items)) {
|
|
1046
|
+
items.forEach((item) => {
|
|
1047
|
+
const diagnostic = {
|
|
1048
|
+
node: item,
|
|
1049
|
+
severity: 'warning',
|
|
1050
|
+
message: `NewList期望的类型是${maxTypeAnnotation?.headTitle}`,
|
|
1051
|
+
};
|
|
1052
|
+
item.tsErrorDetail = diagnostic;
|
|
1053
|
+
diagnostics.push(diagnostic);
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
} else if (node instanceof NewMap && !node.typeAnnotation) {
|
|
1059
|
+
const { values } = node || {};
|
|
1060
|
+
const typeAnnotationMap: any = {};
|
|
1061
|
+
// 最多数的类型
|
|
1062
|
+
let maxTypeAnnotationInfo: any = {
|
|
1063
|
+
typeAnnotation: null,
|
|
1064
|
+
count: 0,
|
|
1065
|
+
};
|
|
1066
|
+
if (Array.isArray(values)) {
|
|
1067
|
+
values.forEach((value) => {
|
|
1068
|
+
if (!value)
|
|
1069
|
+
return;
|
|
1070
|
+
const typeAnnotation = value.__TypeAnnotation;
|
|
1071
|
+
// 仅处理有类型的情况,返回类型为void的情况由其他地方处理成报错
|
|
1072
|
+
if (typeAnnotation) {
|
|
1073
|
+
const sortedTypeKey = typeAnnotation.sortedTypeKey;
|
|
1074
|
+
if (!typeAnnotationMap[sortedTypeKey]) {
|
|
1075
|
+
typeAnnotationMap[sortedTypeKey] = {
|
|
1076
|
+
typeAnnotation,
|
|
1077
|
+
values: [],
|
|
1078
|
+
count: 0,
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
const typeAnnotationInfo = typeAnnotationMap[sortedTypeKey];
|
|
1082
|
+
typeAnnotationInfo.values.push(value);
|
|
1083
|
+
typeAnnotationInfo.count++;
|
|
1084
|
+
const { count } = typeAnnotationInfo;
|
|
1085
|
+
if (maxTypeAnnotationInfo.count < count) {
|
|
1086
|
+
maxTypeAnnotationInfo = {
|
|
1087
|
+
typeAnnotation,
|
|
1088
|
+
count,
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
const {
|
|
1095
|
+
typeAnnotation: maxTypeAnnotation,
|
|
1096
|
+
} = maxTypeAnnotationInfo;
|
|
1097
|
+
for (const sortedTypeKey in typeAnnotationMap) {
|
|
1098
|
+
const { typeAnnotation, values } = typeAnnotationMap[sortedTypeKey];
|
|
1099
|
+
if (maxTypeAnnotation?.sortedTypeKey !== typeAnnotation?.sortedTypeKey) {
|
|
1100
|
+
if (Array.isArray(values)) {
|
|
1101
|
+
values.forEach((value) => {
|
|
1102
|
+
const diagnostic = {
|
|
1103
|
+
node: value,
|
|
1104
|
+
severity: 'warning',
|
|
1105
|
+
message: `NewMap中values值所期望的类型是${maxTypeAnnotation?.headTitle}`,
|
|
1106
|
+
};
|
|
1107
|
+
value.tsErrorDetail = diagnostic;
|
|
1108
|
+
diagnostics.push(diagnostic);
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1003
1113
|
}
|
|
1004
1114
|
});
|
|
1005
1115
|
}
|
|
@@ -1297,15 +1407,18 @@ export class NaslServer {
|
|
|
1297
1407
|
}
|
|
1298
1408
|
});
|
|
1299
1409
|
}
|
|
1300
|
-
if (node instanceof MatchCase && (node.getAncestor('Match') as Match)?.isExpression && node.body.length === 0
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1410
|
+
if (node instanceof MatchCase && (node.getAncestor('Match') as Match)?.isExpression && node.body.length === 0) {
|
|
1411
|
+
// 如果不是其他就标红
|
|
1412
|
+
if ((node?.getIndexOfParent() !== ((node.getAncestor('Match') as Match)?.cases?.length || 0) - 1)) {
|
|
1413
|
+
const diagnostic = {
|
|
1414
|
+
node,
|
|
1415
|
+
severity: 'error',
|
|
1416
|
+
message: '匹配分支:表达式不能为空',
|
|
1417
|
+
titleTip: '表达式不能为空',
|
|
1418
|
+
};
|
|
1419
|
+
node.tsErrorDetail = diagnostic;
|
|
1420
|
+
diagnostics.push(diagnostic);
|
|
1421
|
+
}
|
|
1309
1422
|
}
|
|
1310
1423
|
// 如果节点是match的patterns 里的
|
|
1311
1424
|
if (node?.parentKey === 'patterns' && node.parentNode instanceof MatchCase) {
|
package/src/server/translator.ts
CHANGED
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
OqlQueryComponent,
|
|
50
50
|
NewMap,
|
|
51
51
|
NewList,
|
|
52
|
+
NewComposite,
|
|
52
53
|
} from '../concepts';
|
|
53
54
|
import { SourceMapItem } from '../translator';
|
|
54
55
|
import { Diagnostic } from '../manager/diagnostic';
|
|
@@ -377,7 +378,7 @@ const TS_RULES: Array<{
|
|
|
377
378
|
},
|
|
378
379
|
{
|
|
379
380
|
re: /Variable '(.+?)' implicitly has an 'any' type./,
|
|
380
|
-
result: '$1
|
|
381
|
+
result: '$1推导不出类型!请连线或手动设置',
|
|
381
382
|
transforms: [transformType],
|
|
382
383
|
},
|
|
383
384
|
];
|
|
@@ -532,8 +533,14 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
532
533
|
// node = node.getAncestor('CallLogic');
|
|
533
534
|
tsErrorDetail.message = tsErrorDetail.message.replace('参数类型不一致!传入类型:', '赋值:类型不一致!右边类型:').replace('接收类型:', '左边类型:');
|
|
534
535
|
}
|
|
535
|
-
} else if (node.parentNode instanceof NewMap
|
|
536
|
-
|
|
536
|
+
} else if (node.parentNode instanceof NewMap) {
|
|
537
|
+
if (text.includes(`is not assignable to parameter of type 'None'`)) {
|
|
538
|
+
tsErrorDetail.message = tsErrorDetail.message = `'参数类型不一致!', 'map的key类型只能是String | Integer | Boolean | Long | Decimal'的其中一种`;
|
|
539
|
+
} else if (text.includes(`parameter of type 'never'`)) {
|
|
540
|
+
tsErrorDetail.message = '自动推导不出类型!newMap中有未知类型';
|
|
541
|
+
}
|
|
542
|
+
} else if (node.parentNode instanceof NewList && text.includes(`parameter of type 'never'`)) {
|
|
543
|
+
tsErrorDetail.message = '自动推导不出类型!newList中有未知类型';
|
|
537
544
|
}
|
|
538
545
|
}
|
|
539
546
|
if (node instanceof Argument || node instanceof Anchor) {
|
|
@@ -567,7 +574,6 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
567
574
|
if (node instanceof OqlQueryComponent) {
|
|
568
575
|
console.log(minRange, tsErrorDetail);
|
|
569
576
|
}
|
|
570
|
-
console.log(node, text)
|
|
571
577
|
// 类型报错的,需要放到上一级
|
|
572
578
|
if (/'(.+?)' has no exported member(?: named)? '(.+?)'/.exec(text) || /Property '(.+?)' does not exist on type '(.+?)'./.exec(text)) {
|
|
573
579
|
if (node instanceof TypeAnnotation) {
|
|
@@ -605,9 +611,9 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
605
611
|
} else if (node instanceof ProcessOutcome || node instanceof Function || node instanceof MatchCase) {
|
|
606
612
|
tsErrorDetail.message = (node as any).constructor.nodeTitle + ':不能为空!';
|
|
607
613
|
} else if (node instanceof NewMap) {
|
|
608
|
-
tsErrorDetail.message = 'Map
|
|
614
|
+
tsErrorDetail.message = 'Map推导不出类型!请手动设置!';
|
|
609
615
|
} else if (node instanceof NewList) {
|
|
610
|
-
tsErrorDetail.message = 'List
|
|
616
|
+
tsErrorDetail.message = 'List推导不出类型!请手动设置!';
|
|
611
617
|
} else if (node instanceof Argument) {
|
|
612
618
|
let str = tsErrorDetail.message;
|
|
613
619
|
str = (node.parentNode as any).constructor.nodeTitle + ':' + str;
|
|
@@ -659,7 +665,7 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
659
665
|
.replace('左边类型', '接收类型')
|
|
660
666
|
.replace('右边类型', '传入类型');
|
|
661
667
|
} else if (text === `Type 'void' is not assignable to type 'never'.`) {
|
|
662
|
-
tsErrorDetail.message = `${node.name}
|
|
668
|
+
tsErrorDetail.message = `${node.name}推导不出类型!请连线或手动设置`;
|
|
663
669
|
}
|
|
664
670
|
}
|
|
665
671
|
// 参数类型不一致!
|
|
@@ -690,12 +696,33 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
690
696
|
}
|
|
691
697
|
}
|
|
692
698
|
if (/Variable '(.+?)' implicitly has an 'any' type./.exec(text) || /Variable '(.+?)' implicitly has an 'any\[\]' type./.exec(text)) {
|
|
693
|
-
if (node instanceof
|
|
699
|
+
if (node.parentNode instanceof NewComposite) {
|
|
700
|
+
//
|
|
701
|
+
} else if (node.parentNode instanceof NewList) {
|
|
702
|
+
tsErrorDetail.message = tsErrorDetail.message.replace('!请连线或手动设置', '');
|
|
703
|
+
} else if (node.parentNode instanceof NewMap) {
|
|
704
|
+
tsErrorDetail.message = tsErrorDetail.message.replace('!请连线或手动设置', '');
|
|
705
|
+
} else {
|
|
694
706
|
return;
|
|
707
|
+
}
|
|
695
708
|
}
|
|
696
709
|
for (const rule of POST_RULES) {
|
|
697
|
-
if (rule.re.test(tsErrorDetail.message))
|
|
698
|
-
tsErrorDetail.message = tsErrorDetail.message.replace(rule.re,
|
|
710
|
+
if (rule.re.test(tsErrorDetail.message)) {
|
|
711
|
+
tsErrorDetail.message = tsErrorDetail.message.replace(rule.re, (value, index, oldStr) => {
|
|
712
|
+
// 处理匹配到的值的左右的内容,是不是还是字母,要是字母就原样输出,防止展示问题
|
|
713
|
+
try {
|
|
714
|
+
const leftCode = index - 1 < 0 ? '' : oldStr[index - 1];
|
|
715
|
+
const rightCode = oldStr[index + value.length] || '';
|
|
716
|
+
if (/^[A-Za-z]+$/.test(leftCode) || /^[A-Za-z]+$/.test(rightCode)) {
|
|
717
|
+
return value;
|
|
718
|
+
} else {
|
|
719
|
+
return rule.result;
|
|
720
|
+
}
|
|
721
|
+
} catch (err) {
|
|
722
|
+
return value;
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
}
|
|
699
726
|
}
|
|
700
727
|
node.tsErrorDetail = tsErrorDetail;
|
|
701
728
|
// 如果logic中有报错就把标识置为true
|
|
@@ -22,6 +22,9 @@ function httpCode(response, params, requestInfo) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function shortResponse(response, params, requestInfo) {
|
|
25
|
+
if(params === false)
|
|
26
|
+
return response;
|
|
27
|
+
|
|
25
28
|
if (response.data && response.data.result !== undefined) {
|
|
26
29
|
return response.data.result;
|
|
27
30
|
} else {
|
|
@@ -32,6 +32,12 @@ export default {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// 检测到当前应用已在新 tab 页打开
|
|
36
|
+
if(err.code === 500502) {
|
|
37
|
+
eventBus.emit('multiTabOpened');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
if (versionStatus[err.code])
|
|
36
42
|
eventBus.emit('updateVersionStatus', {
|
|
37
43
|
status: versionStatus[err.code],
|
|
@@ -48,6 +48,9 @@ const requester = function (requestInfo) {
|
|
|
48
48
|
withCredentials: !baseURL,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
+
if(config.timeout)
|
|
52
|
+
requestOptions.timeout = config.timeout;
|
|
53
|
+
|
|
51
54
|
if (aslConfig.debugRequestAll || (aslConfig.debugRequest && requestOptions.method !== 'GET')) {
|
|
52
55
|
console.debug('[Request Debug]', requestOptions);
|
|
53
56
|
}
|
|
@@ -11,4 +11,16 @@ export default {
|
|
|
11
11
|
path: '/proxy/nasl-storage/api/storage/batchAction',
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
|
+
batchInstruct: {
|
|
15
|
+
url: {
|
|
16
|
+
method: 'post',
|
|
17
|
+
path: '/proxy/nasl-storage/api/storage/batchInstruct',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
saveFrontendNasl: {
|
|
21
|
+
url: {
|
|
22
|
+
method: 'post',
|
|
23
|
+
path: '/proxy/nasl-storage/api/storage/saveFrontendNasl',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
14
26
|
};
|