@lcap/nasl 2.22.0-beta.5 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/docs/classes/Module.html +15 -15
- package/docs/classes/Namespace.html +15 -15
- package/docs/classes/ViewComponent.html +19 -19
- package/out/automate/engine/utils.js +4 -0
- package/out/automate/engine/utils.js.map +1 -1
- package/out/breakpoint/generator/AfterStartNode.d.ts +7 -0
- package/out/breakpoint/generator/AfterStartNode.js +27 -0
- package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
- package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
- package/out/breakpoint/generator/BeforeEndNode.js +27 -0
- package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
- package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
- package/out/breakpoint/generator/BreakpointNode.js +166 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
- package/out/breakpoint/generator/index.d.ts +4 -0
- package/out/breakpoint/generator/index.js +98 -0
- package/out/breakpoint/generator/index.js.map +1 -0
- package/out/breakpoint/index.d.ts +3 -0
- package/out/breakpoint/index.js +20 -0
- package/out/breakpoint/index.js.map +1 -0
- package/out/breakpoint/shared/constants.d.ts +30 -0
- package/out/breakpoint/shared/constants.js +87 -0
- package/out/breakpoint/shared/constants.js.map +1 -0
- package/out/breakpoint/shared/index.d.ts +3 -0
- package/out/breakpoint/shared/index.js +33 -0
- package/out/breakpoint/shared/index.js.map +1 -0
- package/out/breakpoint/shared/operations.d.ts +10 -0
- package/out/breakpoint/shared/operations.js +25 -0
- package/out/breakpoint/shared/operations.js.map +1 -0
- package/out/breakpoint/shared/socket.d.ts +47 -0
- package/out/breakpoint/shared/socket.js +210 -0
- package/out/breakpoint/shared/socket.js.map +1 -0
- package/out/breakpoint/shared/utils.d.ts +20 -0
- package/out/breakpoint/shared/utils.js +133 -0
- package/out/breakpoint/shared/utils.js.map +1 -0
- package/out/breakpoint/store/core.d.ts +30 -0
- package/out/breakpoint/store/core.js +341 -0
- package/out/breakpoint/store/core.js.map +1 -0
- package/out/breakpoint/store/dock.d.ts +1 -0
- package/out/breakpoint/store/dock.js +127 -0
- package/out/breakpoint/store/dock.js.map +1 -0
- package/out/breakpoint/store/index.d.ts +2 -0
- package/out/breakpoint/store/index.js +19 -0
- package/out/breakpoint/store/index.js.map +1 -0
- package/out/common/BaseNode.d.ts +8 -0
- package/out/common/BaseNode.js +19 -0
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +365 -16
- package/out/concepts/App__.js +431 -10
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/AuthInterface__.d.ts +37 -0
- package/out/concepts/AuthInterface__.js +141 -0
- package/out/concepts/AuthInterface__.js.map +1 -0
- package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
- package/out/concepts/AuthLogicForCallInterface__.js +493 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
- package/out/concepts/AuthLogic__.d.ts +66 -0
- package/out/concepts/AuthLogic__.js +206 -0
- package/out/concepts/AuthLogic__.js.map +1 -0
- package/out/concepts/BackendVariable__.d.ts +137 -0
- package/out/concepts/BackendVariable__.js +422 -0
- package/out/concepts/BackendVariable__.js.map +1 -0
- package/out/concepts/Backend__.d.ts +134 -0
- package/out/concepts/Backend__.js +274 -0
- package/out/concepts/Backend__.js.map +1 -0
- package/out/concepts/BindAttribute__.d.ts +1 -1
- package/out/concepts/BindAttribute__.js +3 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +12 -0
- package/out/concepts/BindEvent__.js +68 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.d.ts +126 -0
- package/out/concepts/CallAuthInterface__.js +408 -0
- package/out/concepts/CallAuthInterface__.js.map +1 -0
- package/out/concepts/CallInterface__.d.ts +6 -1
- package/out/concepts/CallInterface__.js +9 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +3 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +9 -7
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Destination__.js +1 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +29 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -2
- package/out/concepts/Entity__.js +1 -31
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +9 -4
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +29 -29
- package/out/concepts/FrontendLibrary__.js +2 -2
- package/out/concepts/FrontendVariable__.d.ts +21 -0
- package/out/concepts/FrontendVariable__.js +64 -0
- package/out/concepts/FrontendVariable__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +151 -47
- package/out/concepts/Frontend__.js +188 -32
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +18 -3
- package/out/concepts/LogicItem__.js +22 -4
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +14 -9
- package/out/concepts/Logic__.js +43 -5
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +29 -29
- package/out/concepts/Namespace__.js +2 -2
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.d.ts +643 -0
- package/out/concepts/OverriddenLogic__.js +1602 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -0
- package/out/concepts/Param__.d.ts +6 -0
- package/out/concepts/Param__.js +10 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +2 -0
- package/out/concepts/QueryFieldExpression__.js +9 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +2 -2
- package/out/concepts/QuerySelectExpression__.js +2 -2
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +6 -6
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +10 -0
- package/out/concepts/Variable__.js +12 -0
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.d.ts +33 -33
- package/out/concepts/ViewComponent__.js +7 -7
- package/out/concepts/ViewElement__.d.ts +6 -0
- package/out/concepts/ViewElement__.js +104 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +2 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +24 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
- package/out/concepts/basics/stdlib/nasl.http.js +167 -0
- package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.process.js +68 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +4 -19
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +83 -17
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +4 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +8 -0
- package/out/concepts/index__.js +8 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +27 -0
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +4 -1
- package/out/generator/genMetaData.js +14 -0
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -1
- package/out/generator/genReleaseBody.js +2 -1
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/index.d.ts +2 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +39 -4
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getExtensionModules.d.ts +2 -2
- package/out/server/getExtensionModules.js +16 -2
- package/out/server/getExtensionModules.js.map +1 -1
- package/out/server/getLogics.js +5 -5
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +34 -7
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +64 -64
- package/out/server/naslServer.js +249 -121
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +2 -0
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/translator.d.ts +1 -0
- package/out/server/translator.js +67 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/defaultErrorMessage.json +1 -0
- package/out/service/storage/api.d.ts +10 -1
- package/out/service/storage/api.js +6 -0
- package/out/service/storage/api.js.map +1 -1
- package/out/service/storage/init.d.ts +4 -0
- package/out/service/storage/init.js +55 -35
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts +3 -0
- package/out/service/storage/service.js +14 -0
- package/out/service/storage/service.js.map +1 -1
- package/out/utils/sortTsString.d.ts +1 -0
- package/out/utils/sortTsString.js +36 -0
- package/out/utils/sortTsString.js.map +1 -0
- package/out/utils/traverse.js +2 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +7 -2
- package/sandbox/stdlib/nasl.auth.ts +8 -4
- package/sandbox/stdlib/nasl.core.d.ts +206 -0
- package/sandbox/stdlib/nasl.core.js +1 -0
- package/sandbox/stdlib/nasl.core.js.map +1 -0
- package/sandbox/stdlib/nasl.http.ts +35 -0
- package/sandbox/stdlib/nasl.process.ts +13 -0
- package/sandbox/stdlib/nasl.ui.ts +0 -5
- package/src/automate/engine/utils.js +4 -1
- package/src/breakpoint/generator/AfterStartNode.ts +27 -0
- package/src/breakpoint/generator/BeforeEndNode.ts +27 -0
- package/src/breakpoint/generator/BreakpointNode.ts +228 -0
- package/src/breakpoint/generator/index.ts +114 -0
- package/src/breakpoint/index.ts +3 -0
- package/src/breakpoint/shared/constants.ts +95 -0
- package/src/breakpoint/shared/index.ts +3 -0
- package/src/breakpoint/shared/operations.ts +25 -0
- package/src/breakpoint/shared/socket.ts +326 -0
- package/src/breakpoint/shared/utils.ts +195 -0
- package/src/breakpoint/store/core.ts +411 -0
- package/src/breakpoint/store/dock.ts +166 -0
- package/src/breakpoint/store/index.ts +2 -0
- package/src/breakpoint/types/index.d.ts +19 -0
- package/src/common/BaseNode.ts +19 -1
- package/src/concepts/App__.ts +828 -26
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/AuthInterface__.ts +148 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +573 -0
- package/src/concepts/AuthLogic__.ts +225 -0
- package/src/concepts/BackendVariable__.ts +466 -0
- package/src/concepts/Backend__.ts +347 -0
- package/src/concepts/BindAttribute__.ts +4 -3
- package/src/concepts/BindEvent__.ts +71 -2
- package/src/concepts/CallAuthInterface__.ts +490 -0
- package/src/concepts/CallInterface__.ts +10 -2
- package/src/concepts/CallLogic__.ts +3 -1
- package/src/concepts/CallQueryComponent__.ts +67 -7
- package/src/concepts/Destination__.ts +19 -1
- package/src/concepts/End__.ts +31 -3
- package/src/concepts/EntityProperty__.ts +6 -0
- package/src/concepts/Entity__.ts +8 -31
- package/src/concepts/ForEachStatement__.ts +9 -4
- package/src/concepts/FrontendLibrary__.ts +30 -30
- package/src/concepts/FrontendVariable__.ts +76 -0
- package/src/concepts/Frontend__.ts +352 -89
- package/src/concepts/Function__.ts +1 -1
- package/src/concepts/Identifier__.ts +5 -5
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/LogicItem__.ts +26 -6
- package/src/concepts/Logic__.ts +86 -8
- package/src/concepts/Module__.ts +32 -2
- package/src/concepts/Namespace__.ts +30 -30
- package/src/concepts/NewComposite__.ts +2 -3
- package/src/concepts/OverriddenLogic__.ts +2165 -0
- package/src/concepts/Param__.ts +13 -3
- package/src/concepts/QueryFieldExpression__.ts +18 -0
- package/src/concepts/QuerySelectExpression__.ts +11 -3
- package/src/concepts/TypeAnnotation__.ts +45 -6
- package/src/concepts/Variable__.ts +14 -0
- package/src/concepts/ViewComponent__.ts +35 -35
- package/src/concepts/ViewElement__.ts +104 -1
- package/src/concepts/View__.ts +24 -2
- package/src/concepts/basics/stdlib/index.ts +2 -1
- package/src/concepts/basics/stdlib/nasl.auth.ts +24 -0
- package/src/concepts/basics/stdlib/nasl.http.ts +166 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +68 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +4 -19
- package/src/concepts/basics/stdlib/nasl.util.ts +83 -17
- package/src/concepts/basics/types/index.ts +5 -4
- package/src/concepts/index__.ts +8 -0
- package/src/enums/KEYWORDS.ts +0 -1
- package/src/generator/genBundleFiles.ts +36 -2
- package/src/generator/genMetaData.ts +16 -1
- package/src/generator/genReleaseBody.ts +4 -1
- package/src/index.ts +2 -1
- package/src/server/extendBaseNode.ts +18 -7
- package/src/server/formatTsUtils.ts +37 -5
- package/src/server/getExtensionModules.ts +18 -3
- package/src/server/getLogics.ts +6 -6
- package/src/server/getMemberIdentifier.ts +35 -9
- package/src/server/naslServer.ts +250 -124
- package/src/server/naslStdlibMap.ts +2 -0
- package/src/server/translator.ts +67 -1
- package/src/service/defaultErrorMessage.json +1 -0
- package/src/service/storage/api.js +7 -1
- package/src/service/storage/init.ts +66 -35
- package/src/service/storage/service.ts +18 -2
- package/src/utils/sortTsString.ts +32 -0
- package/src/utils/traverse.ts +2 -2
- package/test/examples/app-simple.json +73635 -0
- package/ts-worker/lib/tsserver.js +3 -3
- package/ts-worker/package.json +1 -1
|
@@ -10,6 +10,7 @@ if (globalThis.process) { // For TS build
|
|
|
10
10
|
'nasl.ui.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.ui.ts'), 'utf8'),
|
|
11
11
|
'nasl.browser.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.browser.ts'), 'utf8'),
|
|
12
12
|
'nasl.auth.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.auth.ts'), 'utf8'),
|
|
13
|
+
'nasl.http.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.http.ts'), 'utf8'),
|
|
13
14
|
'nasl.configuration.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.configuration.ts'), 'utf8'),
|
|
14
15
|
'nasl.langUtil.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.langUtil.ts'), 'utf8'),
|
|
15
16
|
'nasl.annotation.ts': fs.readFileSync(require.resolve('../../sandbox/stdlib/nasl.annotation.ts'), 'utf8'),
|
|
@@ -31,6 +32,7 @@ if (globalThis.window) { // For TS build
|
|
|
31
32
|
'nasl.ui.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.ui.ts').default,
|
|
32
33
|
'nasl.browser.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.browser.ts').default,
|
|
33
34
|
'nasl.auth.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.auth.ts').default,
|
|
35
|
+
'nasl.http.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.http.ts').default,
|
|
34
36
|
'nasl.configuration.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.configuration.ts').default,
|
|
35
37
|
'nasl.langUtil.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.langUtil.ts').default,
|
|
36
38
|
'nasl.annotation.ts': require('!!raw-loader!../../sandbox/stdlib/nasl.annotation.ts').default,
|
package/src/server/translator.ts
CHANGED
|
@@ -53,11 +53,15 @@ import {
|
|
|
53
53
|
} from '../concepts';
|
|
54
54
|
import { SourceMapItem } from '../translator';
|
|
55
55
|
import { Diagnostic } from '../manager/diagnostic';
|
|
56
|
+
import { sortTsString } from '../utils/sortTsString';
|
|
57
|
+
import { getNodeByNodeCallee } from '@nasl/automate/engine/utils';
|
|
56
58
|
export interface MinRange {
|
|
57
59
|
node: BaseNode;
|
|
58
60
|
item: SourceMapItem;
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
const mapAstString = new Map();
|
|
64
|
+
|
|
61
65
|
function transformType(tsType: string): string {
|
|
62
66
|
if (tsType === 'string' || tsType === 'String')
|
|
63
67
|
return '字符串';
|
|
@@ -171,6 +175,14 @@ function transformIdentifier(identifier: string): string {
|
|
|
171
175
|
export function outOriginalvalue(value: string) {
|
|
172
176
|
return value;
|
|
173
177
|
}
|
|
178
|
+
const TS_RULES_TYPE_INCONSISTENCY: Array<RegExp> = [
|
|
179
|
+
/This condition will always return '(.+?)' since the types '(.+?)' and '(.+?)' have no overlap/,
|
|
180
|
+
/Property '(.+?)' is missing in type '(.+?)' but required in type '(.+?)'/,
|
|
181
|
+
/Argument of type '(.+?)' is not assignable to parameter of type '(.+?)'/,
|
|
182
|
+
/Type '(.+?)' is not assignable to type '(.+?)'/,
|
|
183
|
+
/Type '(.+?)' does not satisfy the constraint '(.+?)'/,
|
|
184
|
+
/Type '(.+?)' is missing the following properties from type '(.+?)'/,
|
|
185
|
+
];
|
|
174
186
|
|
|
175
187
|
const TS_RULES: Array<{
|
|
176
188
|
re: RegExp;
|
|
@@ -317,7 +329,7 @@ const TS_RULES: Array<{
|
|
|
317
329
|
},
|
|
318
330
|
{
|
|
319
331
|
re: /'(.+?)' has no exported member(?: named)? '(.+?)'/,
|
|
320
|
-
result: '
|
|
332
|
+
result: '找不到接口$1 $2。',
|
|
321
333
|
transforms: [transformNamespace, transformType],
|
|
322
334
|
},
|
|
323
335
|
{
|
|
@@ -474,6 +486,10 @@ export function translateDiagnosticMessage(message: string) {
|
|
|
474
486
|
export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diagnostic) {
|
|
475
487
|
const text = tsErrorDetail?.originalDiagnostic?.text;
|
|
476
488
|
let node = minRange?.node;
|
|
489
|
+
const logicAncestor = node.getAncestor('Logic') || {} as any;
|
|
490
|
+
const { parentNode = { concept: '' } } = logicAncestor;
|
|
491
|
+
const isFELogic = ['BindEvent', 'View'].includes(parentNode.concept);
|
|
492
|
+
|
|
477
493
|
// 有一些节点报错信息不向外暴露,缺失一些原生标签等等的展示
|
|
478
494
|
if (node instanceof View || node instanceof ViewElement) {
|
|
479
495
|
if (text.startsWith(`'nasl.ui' has no exported member named `)) {
|
|
@@ -569,6 +585,20 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
569
585
|
tsErrorDetail.message = '自动推导不出类型!newList中有未知类型';
|
|
570
586
|
}
|
|
571
587
|
}
|
|
588
|
+
|
|
589
|
+
// 针对前端逻辑,有可能原因是找接口被增加鉴权方式导致
|
|
590
|
+
if (/Property '(.+?)' does not exist on type 'typeof (.+?)'/.exec(text) && isFELogic) {
|
|
591
|
+
// 如果存在 则 目标 Interface 更新为了 鉴权相关的,需要给出对应提示
|
|
592
|
+
const app = node.rootNode;
|
|
593
|
+
const modulePathList = (node as CallInterface)?.calleeNamespace?.split('.') || [];
|
|
594
|
+
modulePathList?.pop();
|
|
595
|
+
const targetInterface = getNodeByNodeCallee(app, (node as CallInterface).calleeKey);
|
|
596
|
+
console.log(targetInterface);
|
|
597
|
+
// const hasInterface = targetModule?.interfaces?.findIndex?.((item: Interface) => item.name === (node as CallInterface).calleeName) > -1;
|
|
598
|
+
if (targetInterface) {
|
|
599
|
+
tsErrorDetail.message = `${(node as CallInterface)?.calleeName}接口有鉴权,不支持在前端调用`;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
572
602
|
if (node instanceof Argument || node instanceof Anchor) {
|
|
573
603
|
// if (/Type '(.+?)' is not assignable to type '(.+?)'./.exec(text)) {
|
|
574
604
|
// }
|
|
@@ -747,6 +777,9 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
747
777
|
return;
|
|
748
778
|
}
|
|
749
779
|
}
|
|
780
|
+
if (checkAStructure_(text)) {
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
750
783
|
for (const rule of POST_RULES) {
|
|
751
784
|
if (rule.re.test(tsErrorDetail.message)) {
|
|
752
785
|
tsErrorDetail.message = tsErrorDetail.message.replace(rule.re, (value, index, oldStr) => {
|
|
@@ -774,3 +807,36 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
774
807
|
...tsErrorDetail,
|
|
775
808
|
};
|
|
776
809
|
}
|
|
810
|
+
|
|
811
|
+
export function checkAStructure_(errorText: string): any {
|
|
812
|
+
const index = TS_RULES_TYPE_INCONSISTENCY.findIndex((item) => item.exec(errorText));
|
|
813
|
+
if (index !== -1) {
|
|
814
|
+
const rule = TS_RULES_TYPE_INCONSISTENCY[index];
|
|
815
|
+
const cap = rule.exec(errorText);
|
|
816
|
+
if (rule === TS_RULES_TYPE_INCONSISTENCY[0] || rule === TS_RULES_TYPE_INCONSISTENCY[1]) {
|
|
817
|
+
cap.splice(1, 1);
|
|
818
|
+
}
|
|
819
|
+
if (((cap[1].startsWith('{') && cap[1].endsWith('}')) || (cap[1].startsWith('{') && cap[1].endsWith('...')))
|
|
820
|
+
&& ((cap[2].startsWith('{') && cap[2].endsWith('}')) || (cap[2].startsWith('{') && cap[2].endsWith('...')))
|
|
821
|
+
&& (cap[1].includes('__name: "AStructure_') && cap[2].includes('__name: "AStructure_'))) {
|
|
822
|
+
const x = sortTsString(transformType(cap[1]));
|
|
823
|
+
const y = sortTsString(transformType(cap[2]));
|
|
824
|
+
if (x === y) {
|
|
825
|
+
return true;
|
|
826
|
+
} else if (mapAstString.get(x) === y || mapAstString.get(y) === x) {
|
|
827
|
+
return true;
|
|
828
|
+
} else {
|
|
829
|
+
const regex = /Type '"AStructure_(.*)' is not assignable to type '"AStructure_(.*)'/;
|
|
830
|
+
const nameError = regex.exec(errorText);
|
|
831
|
+
const length1 = x.match(/:/g) ? x.match(/:/g).length : -1;
|
|
832
|
+
const length2 = y.match(/:/g) ? y.match(/:/g).length : -2;
|
|
833
|
+
if (nameError && length1 === length2) {
|
|
834
|
+
mapAstString.set(x, y);
|
|
835
|
+
mapAstString.set(y, x);
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return false;
|
|
842
|
+
}
|
|
@@ -21,7 +21,13 @@ export default {
|
|
|
21
21
|
url: {
|
|
22
22
|
method: 'post',
|
|
23
23
|
path: '/proxy/nasl-storage/api/storage/saveFrontendNasl',
|
|
24
|
-
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
breakpoint: {
|
|
27
|
+
url: {
|
|
28
|
+
method: 'get',
|
|
29
|
+
path: '/proxy/nasl-storage/api/breakpoint',
|
|
30
|
+
},
|
|
25
31
|
},
|
|
26
32
|
// 获取存储类型列表
|
|
27
33
|
databaseTypes: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { App, LogicItem, Logic, Module, View, ViewElement, Argument, SelectMembers } from '../../concepts';
|
|
2
|
+
import { addBreakpointNodesFromApp } from '../../breakpoint';
|
|
2
3
|
import { getConceptConstructor } from '../../decorators';
|
|
3
4
|
import { config } from '../../config';
|
|
4
5
|
import Vue from 'vue';
|
|
@@ -13,6 +14,7 @@ import * as jsoner from './jsoner';
|
|
|
13
14
|
export const batchQuery = storageService.batchQuery;
|
|
14
15
|
export const batchAction = storageService.batchAction;
|
|
15
16
|
export const batchInstruct = storageService.batchInstruct;
|
|
17
|
+
export const breakpoint = storageService.breakpoint;
|
|
16
18
|
|
|
17
19
|
let tabTimestamp: string;
|
|
18
20
|
export const databaseTypes = storageService.databaseTypes;
|
|
@@ -177,7 +179,7 @@ async function doAction(app: any, actionItem: any) {
|
|
|
177
179
|
const emitTarget = event?.originEvent?.target;
|
|
178
180
|
const _path: string = event.originEvent.path;
|
|
179
181
|
const _root = _path.split('.')?.[1] || '';
|
|
180
|
-
if (['dataSources', 'processes', 'logics', 'enums', 'structures', 'interfaces', 'interfaceDependencies', 'configuration', 'dependencies'].some((item) => _root.startsWith(item))) {
|
|
182
|
+
if (['backend', 'overriddenLogics', 'dataSources', 'processes', 'logics', 'enums', 'structures', 'interfaces', 'interfaceDependencies', 'configuration', 'dependencies', 'authLogics', 'authLogicsForCallInterface'].some((item) => _root.startsWith(item))) {
|
|
181
183
|
hasBackEnd = true;
|
|
182
184
|
}
|
|
183
185
|
if (emitTarget.concept === 'Logic') {
|
|
@@ -202,21 +204,22 @@ async function doAction(app: any, actionItem: any) {
|
|
|
202
204
|
const isDelete = event?.originEvent?.action === 'delete';
|
|
203
205
|
const isUpdateAuth = event?.originEvent?.action === 'update' && event?.originEvent?.object && 'auth' in event?.originEvent?.object;
|
|
204
206
|
if (isDelete || isUpdateAuth) {
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
emitTarget.
|
|
207
|
+
hasBackEnd = true;
|
|
208
|
+
// const app = emitTarget.app;
|
|
209
|
+
// const diffArr: string[] = [];
|
|
210
|
+
// emitTarget.logics.forEach((logic: Logic) => {
|
|
211
|
+
// if (logic.body.length > 2) {
|
|
212
|
+
// logic.body.forEach((it: LogicItem) => {
|
|
213
|
+
// itemloop(it, app, diffArr);
|
|
214
|
+
// });
|
|
215
|
+
// }
|
|
216
|
+
// });
|
|
217
|
+
// const result = diffArr.filter((item) => item.startsWith('app') || item.startsWith('extensions'));
|
|
218
|
+
// if (result.length) {
|
|
219
|
+
// hasBackEnd = true;
|
|
220
|
+
// }
|
|
221
|
+
// emitTarget.children.forEach((item: View | ViewElement) => loopEle(item, isDelete));
|
|
222
|
+
// emitTarget.elements.forEach((item: View | ViewElement) => loopEle(item, isDelete));
|
|
220
223
|
}
|
|
221
224
|
hasFrontEnd = true;
|
|
222
225
|
}
|
|
@@ -612,6 +615,11 @@ export function handleApp(app: any) {
|
|
|
612
615
|
});
|
|
613
616
|
}
|
|
614
617
|
|
|
618
|
+
type BreakpointItem = any | {
|
|
619
|
+
path: string,
|
|
620
|
+
breakpointStatus: null | 'ENABLED' | 'DISABLED',
|
|
621
|
+
};
|
|
622
|
+
|
|
615
623
|
/**
|
|
616
624
|
* 加载 app
|
|
617
625
|
* @param appId 如果是从文件读,就不需要传
|
|
@@ -621,34 +629,57 @@ export async function loadApp(appId?: string) {
|
|
|
621
629
|
let app: App;
|
|
622
630
|
if (config.storage.protocol === 'http') {
|
|
623
631
|
console.time('batchQuery');
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
632
|
+
const promises = [
|
|
633
|
+
storageService.batchQuery({
|
|
634
|
+
body: [
|
|
635
|
+
{
|
|
636
|
+
path: 'app',
|
|
637
|
+
// excludes: ['views'],
|
|
638
|
+
},
|
|
639
|
+
],
|
|
640
|
+
headers: {
|
|
641
|
+
appId,
|
|
642
|
+
checkTabOpenTime: 'true',
|
|
643
|
+
// 其他封装在 storageService 里了
|
|
630
644
|
},
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
645
|
+
config: {
|
|
646
|
+
shortResponse: false,
|
|
647
|
+
},
|
|
648
|
+
}),
|
|
649
|
+
storageService.breakpoint({
|
|
650
|
+
body: { appId },
|
|
651
|
+
}),
|
|
652
|
+
];
|
|
653
|
+
|
|
654
|
+
const [batchQueryRes, breakpointRes] = await Promise.all(promises);
|
|
655
|
+
|
|
656
|
+
// 请求
|
|
641
657
|
console.timeEnd('batchQuery');
|
|
642
658
|
|
|
643
|
-
tabTimestamp =
|
|
644
|
-
const data =
|
|
659
|
+
tabTimestamp = batchQueryRes?.headers?.tabtimestamp;
|
|
660
|
+
const data = batchQueryRes?.data?.result;
|
|
645
661
|
|
|
646
662
|
console.time('new App');
|
|
647
663
|
app = new App(Object.assign(data?.[0], { id: appId }));
|
|
664
|
+
|
|
665
|
+
breakpointRes?.forEach((item: BreakpointItem = {}) => {
|
|
666
|
+
const { path, breakpointStatus } = item;
|
|
667
|
+
|
|
668
|
+
if (breakpointStatus) {
|
|
669
|
+
const node = app.findNodeByPath(path);
|
|
670
|
+
|
|
671
|
+
if (node) {
|
|
672
|
+
node.breakpoint = breakpointStatus;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
});
|
|
648
676
|
console.timeEnd('new App');
|
|
677
|
+
|
|
649
678
|
if (!app.id) {
|
|
650
679
|
app.id = appId;
|
|
651
680
|
}
|
|
681
|
+
|
|
682
|
+
addBreakpointNodesFromApp(app);
|
|
652
683
|
} else if (config.storage.protocol === 'mock') {
|
|
653
684
|
app = new App({
|
|
654
685
|
id: appId,
|
|
@@ -681,7 +712,7 @@ export async function loadApp(appId?: string) {
|
|
|
681
712
|
}
|
|
682
713
|
|
|
683
714
|
// 在app上挂载所有的数据库类型
|
|
684
|
-
async function mountDatabaseTypes(app: App) {
|
|
715
|
+
export async function mountDatabaseTypes(app: App) {
|
|
685
716
|
if (!app.__databaseTypeMap) {
|
|
686
717
|
app.__databaseTypeMap = {};
|
|
687
718
|
}
|
|
@@ -49,8 +49,8 @@ export default {
|
|
|
49
49
|
},
|
|
50
50
|
saveFrontendNasl({ body }: { body: any }) {
|
|
51
51
|
const appData = (window as any).appData;
|
|
52
|
-
|
|
53
|
-
return service.saveFrontendNasl({
|
|
52
|
+
|
|
53
|
+
return service.saveFrontendNasl({
|
|
54
54
|
body,
|
|
55
55
|
headers: {
|
|
56
56
|
appId: appData?.appId,
|
|
@@ -59,8 +59,24 @@ export default {
|
|
|
59
59
|
});
|
|
60
60
|
},
|
|
61
61
|
databaseTypes({ query }: { query: any }) {
|
|
62
|
+
const appData = (window as any).appData;
|
|
63
|
+
|
|
62
64
|
return service.databaseTypes({
|
|
65
|
+
headers: {
|
|
66
|
+
appId: appData?.appId,
|
|
67
|
+
},
|
|
63
68
|
query,
|
|
64
69
|
});
|
|
65
70
|
},
|
|
71
|
+
breakpoint({ body }: { body: any }) {
|
|
72
|
+
const appData = (window as any).appData;
|
|
73
|
+
|
|
74
|
+
return service.breakpoint({
|
|
75
|
+
body,
|
|
76
|
+
headers: {
|
|
77
|
+
appId: appData?.appId,
|
|
78
|
+
skipVersionCheck: true,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
},
|
|
66
82
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const babel = require('@babel/core');
|
|
2
|
+
const generate = require('@babel/generator').default;
|
|
3
|
+
const traverse = require('@babel/traverse').default;
|
|
4
|
+
const t = require('@babel/types');
|
|
5
|
+
|
|
6
|
+
export function sortTsString(tsString: string): string {
|
|
7
|
+
const str = `type a = ${tsString}`;
|
|
8
|
+
const ast = babel.parseSync(str, {
|
|
9
|
+
filename: 'result.ts',
|
|
10
|
+
presets: [require('@babel/preset-typescript')],
|
|
11
|
+
});
|
|
12
|
+
const visitor = {
|
|
13
|
+
TSTypeLiteral(path: any) {
|
|
14
|
+
path.node.members.sort((a: any, b: any) => {
|
|
15
|
+
if (a.type === 'TSPropertySignature' && b.type === 'TSPropertySignature') {
|
|
16
|
+
return a.key.name.localeCompare(b.key.name);
|
|
17
|
+
}
|
|
18
|
+
return 0;
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
ArrayExpression(path: any) {
|
|
22
|
+
path.node.elements.sort((a: any, b: any) => {
|
|
23
|
+
if (a.type === 'ObjectExpression' && b.type === 'ObjectExpression') {
|
|
24
|
+
return t.isIdentifier(a.properties[0].key) && t.isIdentifier(b.properties[0].key) ? a.properties[0].key.name.localeCompare(b.properties[0].key.name) : 0;
|
|
25
|
+
}
|
|
26
|
+
return 0;
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
traverse(ast, visitor);
|
|
31
|
+
return generate(ast).code;
|
|
32
|
+
}
|
package/src/utils/traverse.ts
CHANGED
|
@@ -129,9 +129,9 @@ function handleNext<T extends INode>(func: (next: INodeInfo<T>) => any, current:
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
function checkCircular<T>(next: INodeInfo<T>) {
|
|
132
|
-
if (next.stack.length > 100 || next.key > 10000 || next.index > 10000)
|
|
132
|
+
if (next.stack.length > 100 || Number(next.key) > 10000 || next.index > 10000)
|
|
133
133
|
console.error(next);
|
|
134
|
-
if (next.stack.length > 110 || next.key > 10010 || next.index > 10010)
|
|
134
|
+
if (next.stack.length > 110 || Number(next.key) > 10010 || next.index > 10010)
|
|
135
135
|
throw new Error('Circular traverse!');
|
|
136
136
|
return next.stack.includes(next.node);
|
|
137
137
|
}
|