@lcap/nasl 3.8.0-beta.5 → 3.8.0-beta.7
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/.mocharc.js +1 -0
- package/out/common/BaseNode.d.ts +21 -5
- package/out/common/BaseNode.js +94 -12
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AbstractInterface__.js.map +1 -1
- package/out/concepts/Annotation__.js +1 -1
- package/out/concepts/Annotation__.js.map +1 -1
- package/out/concepts/App__.d.ts +3 -0
- package/out/concepts/App__.js +985 -6
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +3 -3
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +1 -1
- package/out/concepts/BatchAssignment__.js +2 -2
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +7 -7
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +3 -4
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.js +1 -1
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +2 -0
- package/out/concepts/BusinessComponent__.js +48 -0
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.d.ts +1 -0
- package/out/concepts/BusinessLogic__.js +10 -0
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallEvent__.d.ts +2 -0
- package/out/concepts/CallEvent__.js +75 -0
- package/out/concepts/CallEvent__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +1 -0
- package/out/concepts/CallInterface__.js +26 -15
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +4 -0
- package/out/concepts/CallLogic__.js +65 -5
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +3 -3
- package/out/concepts/Entity__.js +4 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +13 -0
- package/out/concepts/EnumItem__.js +31 -0
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Event__.d.ts +2 -0
- package/out/concepts/Event__.js +30 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +2 -0
- package/out/concepts/FrontendType__.js +32 -0
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -0
- package/out/concepts/Frontend__.js +48 -0
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/IfStatement__.js +6 -6
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.d.ts +1 -0
- package/out/concepts/InterfaceParam__.js +23 -4
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +2 -1
- package/out/concepts/Interface__.js +29 -5
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.d.ts +1 -0
- package/out/concepts/JSBlock__.js +6 -0
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicDeclaration__.d.ts +1 -0
- package/out/concepts/LogicDeclaration__.js +58 -7
- package/out/concepts/LogicDeclaration__.js.map +1 -1
- package/out/concepts/Logic__.js +46 -27
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +1 -2
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +3 -18
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +4 -4
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +4 -0
- package/out/concepts/Module__.js +92 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +1 -1
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NullLiteral__.js +6 -0
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/Paginate__.d.ts +1 -0
- package/out/concepts/Paginate__.js +15 -7
- package/out/concepts/Paginate__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +2 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +3 -4
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +13 -0
- package/out/concepts/StructureProperty__.js +31 -0
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +1 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +61 -41
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -0
- package/out/concepts/View__.js +55 -1
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/generator/genBundleFiles.js +36 -22
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genHash.d.ts +2 -2
- package/out/generator/genHash.js +30 -30
- package/out/generator/genHash.js.map +1 -1
- package/out/generator/genMetaData.js +7 -49
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/permission.d.ts +8 -1
- package/out/generator/permission.js +321 -23
- package/out/generator/permission.js.map +1 -1
- package/out/generator/release-body/body.d.ts +5 -0
- package/out/generator/release-body/body.js +62 -12
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/data.js +6 -2
- package/out/generator/release-body/data.js.map +1 -1
- package/out/generator/release-body/index.d.ts +1 -0
- package/out/generator/release-body/index.js +1 -0
- package/out/generator/release-body/index.js.map +1 -1
- package/out/generator/release-body/utils.js +3 -3
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/generator/release-body/validation.js +2 -2
- package/out/generator/release-body/validation.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +24 -56
- package/out/natural/genNaturalTS.js +116 -184
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/getUILib.js +2 -3
- package/out/natural/getContext/getUILib.js.map +1 -1
- package/out/natural/getContext/index.d.ts +26 -35
- package/out/natural/getContext/index.js +172 -311
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/index.d.ts +0 -1
- package/out/natural/index.js +0 -1
- package/out/natural/index.js.map +1 -1
- package/out/natural/transformTS2UI.js +31 -14
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.js +26 -10
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/entity2LogicNamespace.d.ts +2 -2
- package/out/server/entity2LogicNamespace.js +321 -310
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +25 -0
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +1 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/naslServer.d.ts +10 -4
- package/out/server/naslServer.js +77 -19
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +12 -0
- package/out/server/translator.js.map +1 -1
- package/out/templator/genCreateBlock.js +3 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +2 -2
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +5 -5
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +1 -1
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +3 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/translator/types.d.ts +2 -0
- package/package.json +5 -5
- package/sandbox/stdlib/nasl.processV2.ts +1 -1
- package/sandbox/stdlib/nasl.ui.definition.ts +0 -18
- package/src/common/BaseNode.ts +100 -16
- package/src/concepts/AbstractInterface__.ts +1 -0
- package/src/concepts/Annotation__.ts +1 -1
- package/src/concepts/App__.ts +126 -6
- package/src/concepts/Argument__.ts +3 -3
- package/src/concepts/BatchAssignment__.ts +2 -2
- package/src/concepts/BindAttribute__.ts +7 -7
- package/src/concepts/BindDirective__.ts +3 -4
- package/src/concepts/BindStyle__.ts +1 -1
- package/src/concepts/BusinessComponent__.ts +54 -1
- package/src/concepts/BusinessLogic__.ts +10 -1
- package/src/concepts/CallEvent__.ts +66 -0
- package/src/concepts/CallInterface__.ts +21 -9
- package/src/concepts/CallLogic__.ts +66 -5
- package/src/concepts/Entity__.ts +7 -1
- package/src/concepts/EnumItem__.ts +40 -1
- package/src/concepts/Event__.ts +32 -0
- package/src/concepts/FrontendType__.ts +34 -1
- package/src/concepts/Frontend__.ts +51 -0
- package/src/concepts/IfStatement__.ts +6 -6
- package/src/concepts/InterfaceParam__.ts +23 -4
- package/src/concepts/Interface__.ts +29 -5
- package/src/concepts/JSBlock__.ts +5 -0
- package/src/concepts/LogicDeclaration__.ts +65 -7
- package/src/concepts/Logic__.ts +49 -31
- package/src/concepts/MatchCase__.ts +1 -2
- package/src/concepts/Match__.ts +3 -21
- package/src/concepts/MemberExpression__.ts +4 -4
- package/src/concepts/Module__.ts +109 -0
- package/src/concepts/NewComposite__.ts +2 -2
- package/src/concepts/NullLiteral__.ts +7 -0
- package/src/concepts/Paginate__.ts +14 -7
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/StringLiteral__.ts +3 -4
- package/src/concepts/StructureProperty__.ts +41 -0
- package/src/concepts/TypeAnnotation__.ts +1 -0
- package/src/concepts/ViewElement__.ts +40 -19
- package/src/concepts/View__.ts +56 -1
- package/src/concepts/basics/stdlib/nasl.processV2.ts +1 -1
- package/src/generator/genBundleFiles.ts +39 -26
- package/src/generator/genHash.ts +32 -6
- package/src/generator/genMetaData.ts +11 -32
- package/src/generator/permission.ts +333 -23
- package/src/generator/release-body/body.ts +74 -15
- package/src/generator/release-body/data.ts +7 -2
- package/src/generator/release-body/index.ts +1 -0
- package/src/generator/release-body/utils.ts +3 -3
- package/src/generator/release-body/validation.ts +1 -1
- package/src/index.ts +13 -1
- package/src/natural/genNaturalTS.ts +148 -330
- package/src/natural/getContext/getUILib.ts +2 -3
- package/src/natural/getContext/index.ts +188 -357
- package/src/natural/index.ts +0 -1
- package/src/natural/transformTS2UI.ts +28 -14
- package/src/natural/transformTSCode.ts +25 -10
- package/src/server/entity2LogicNamespace.ts +13 -1
- package/src/server/extendBaseNode.ts +31 -0
- package/src/server/getLogics.ts +1 -1
- package/src/server/naslServer.ts +107 -27
- package/src/server/translator.ts +15 -0
- package/src/templator/genCreateBlock.ts +4 -4
- package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -2
- package/src/templator/genCurdMultipleKeyBlock.ts +8 -8
- package/src/templator/genEditTableBlock.ts +4 -4
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +2 -2
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +2 -2
- package/src/templator/genUpdateBlock.ts +6 -6
- package/src/templator/utils.ts +1 -1
- package/src/translator/types.ts +2 -0
- package/test/concepts/string-literal/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +6 -2
- package/out/natural/tools.d.ts +0 -11
- package/out/natural/tools.js +0 -155
- package/out/natural/tools.js.map +0 -1
- package/src/natural/tools.ts +0 -130
|
@@ -31,9 +31,9 @@ export async function getCallLogicData(app: App, validations: InputServerValidat
|
|
|
31
31
|
|
|
32
32
|
nasl.traverseStrictChildren((node) => {
|
|
33
33
|
if (
|
|
34
|
-
'uuid' in node &&
|
|
35
34
|
node.concept === 'CallLogic' &&
|
|
36
35
|
node.validation &&
|
|
36
|
+
'uuid' in node &&
|
|
37
37
|
map.has(node.uuid)
|
|
38
38
|
) {
|
|
39
39
|
const data = map.get(node.uuid)!;
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,19 @@ export * as utils from './utils';
|
|
|
8
8
|
export * from './config';
|
|
9
9
|
export * from './eventBus';
|
|
10
10
|
export * as breakpoint from './breakpoint';
|
|
11
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
getOperationRecords,
|
|
13
|
+
operationRecordInfoMap,
|
|
14
|
+
doOperationRecord,
|
|
15
|
+
operationRecordQuery,
|
|
16
|
+
operationRecordPlayback,
|
|
17
|
+
loadApp,
|
|
18
|
+
loadAppSync,
|
|
19
|
+
handleApp,
|
|
20
|
+
batchAction,
|
|
21
|
+
batchQuery,
|
|
22
|
+
mountDatabaseTypes,
|
|
23
|
+
} from './service/storage/init';
|
|
12
24
|
export { createService } from './service/creator';
|
|
13
25
|
export { stepRecorder } from './manager/stepRecorder';
|
|
14
26
|
export * from './natural';
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
getStructures,
|
|
10
10
|
getLogics,
|
|
11
11
|
getModuleInterfaces,
|
|
12
|
-
getConnections,
|
|
13
12
|
getConnectors,
|
|
14
13
|
getDependencies,
|
|
15
14
|
getFrontendVariables,
|
|
@@ -17,317 +16,228 @@ import {
|
|
|
17
16
|
getCurrentNodeContext,
|
|
18
17
|
getCurrentNodeContextForUI,
|
|
19
18
|
getNaslUIOld,
|
|
20
|
-
getNaslUICode,
|
|
21
|
-
getEnumsCode,
|
|
22
|
-
getEntitiesCode,
|
|
23
|
-
getStructuresCode,
|
|
24
|
-
getLogicsCode,
|
|
25
|
-
getModuleInterfacesCode,
|
|
26
|
-
getConnectorsCode,
|
|
27
|
-
getDependenciesCode,
|
|
28
|
-
getFrontendViewsCode,
|
|
29
|
-
wrapTSBlock,
|
|
30
19
|
} from './getContext';
|
|
31
20
|
import { createCompilerState } from '../translator';
|
|
32
21
|
|
|
33
|
-
export * as getNaturalContext from './getContext';
|
|
34
|
-
|
|
35
22
|
export function genNaturalTS(app: App, currentNode?: BaseNode, focusedNodePath?: string) {
|
|
36
23
|
if (currentNode?.concept === 'Logic') {
|
|
37
24
|
const logic = currentNode as Logic;
|
|
38
|
-
const code = logic?.toNaturalTS(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
);
|
|
25
|
+
const code = logic?.toNaturalTS(createCompilerState(undefined, {
|
|
26
|
+
focusedNodePath,
|
|
27
|
+
needNamespace: true,
|
|
28
|
+
autoPrefixName: true,
|
|
29
|
+
}));
|
|
45
30
|
return code;
|
|
46
31
|
}
|
|
47
32
|
return getCurrentNodeContextForUI(currentNode).code;
|
|
48
33
|
}
|
|
49
34
|
|
|
50
|
-
|
|
51
|
-
export function genNaturalTSContextJSONForLogic(
|
|
35
|
+
export function genNaturalTSContextForLogic(
|
|
52
36
|
app: App,
|
|
53
37
|
currentNode?: BaseNode,
|
|
54
38
|
focusedNodePath?: string,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
connectors: any;
|
|
58
|
-
dependencies: any;
|
|
59
|
-
}
|
|
39
|
+
requiredIndexes?: string[],
|
|
40
|
+
experimental?: boolean
|
|
60
41
|
) {
|
|
61
42
|
const frontend = currentNode?.getAncestor('Frontend') as Frontend;
|
|
62
43
|
const logicType = currentNode?.parentNode?.concept === 'App' ? 'global_logic' : 'view_logic';
|
|
63
|
-
const state = createCompilerState();
|
|
64
|
-
|
|
65
|
-
const { naslCore } = getNaslCore(logicType);
|
|
66
|
-
const { naslUtil } = getNaslUtil();
|
|
67
|
-
const { naslUI } = getNaslUIOld();
|
|
68
|
-
const { naslOql } = getNaslOQL();
|
|
69
|
-
const { enums } = getEnums(app, state);
|
|
70
|
-
const { entities } = getEntities(app, state);
|
|
71
|
-
const { structures } = getStructures(app, state);
|
|
72
|
-
const { appLogics } = getLogics(app, currentNode);
|
|
73
|
-
const { interfaceDependencies } = getModuleInterfaces(
|
|
74
|
-
material?.moduleInterfaces || app?.interfaceDependencies,
|
|
75
|
-
state
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
let connections = [];
|
|
79
|
-
if (material?.connectors?.length) {
|
|
80
|
-
connections = getConnectors(material.connectors, state).connectors;
|
|
81
|
-
} else {
|
|
82
|
-
connections = getConnections(material?.connectors || app.connections, state).connections;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const { dependencies } = getDependencies(
|
|
86
|
-
material?.dependencies || app?.dependencies,
|
|
87
|
-
state,
|
|
88
|
-
logicType,
|
|
89
|
-
frontend?.type
|
|
90
|
-
);
|
|
91
|
-
const { frontendVar, frontendVariables } = getFrontendVariables(
|
|
92
|
-
currentNode?.getAncestor('Frontend') as Frontend,
|
|
93
|
-
state
|
|
94
|
-
);
|
|
95
|
-
const { views } = getFrontendViews(frontend, state, currentNode, false);
|
|
96
|
-
const { currentLogic } = getCurrentNodeContext(currentNode, focusedNodePath);
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
naslCore,
|
|
100
|
-
naslUtil,
|
|
101
|
-
naslUI,
|
|
102
|
-
naslOql,
|
|
103
|
-
enums,
|
|
104
|
-
entities,
|
|
105
|
-
structures,
|
|
106
|
-
appLogics,
|
|
107
|
-
interfaceDependencies,
|
|
108
|
-
connections,
|
|
109
|
-
dependencies,
|
|
110
|
-
frontendVar, // @deprecated
|
|
111
|
-
frontendVariables,
|
|
112
|
-
views,
|
|
113
|
-
currentLogic,
|
|
114
|
-
logicType,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* 生成 Logic 的 TypeScript 上下文
|
|
120
|
-
* @param tsContextJSON: 通过 genNaturalTSContextForLogic 获得到 tsContextJSON
|
|
121
|
-
* @param codeType: 'detail' | 'short'。detail 为详细代码,short 为简短代码
|
|
122
|
-
* 'detail' 将所有的code都返回(拼接成详细的code)。RAG召回,分析和执行阶段使用
|
|
123
|
-
* 'short' 只返回简短的code。模型召回,对应的分析阶段使用
|
|
124
|
-
* @param requiredIndexes?: 通过索引获取对应的 code。可挑选需要的 code
|
|
125
|
-
**/
|
|
126
|
-
export const genNaturalTSContextFromJSONForLogic = (
|
|
127
|
-
tsContextJSON: any,
|
|
128
|
-
codeType: 'detail' | 'short',
|
|
129
|
-
requiredIndexes?: string[]
|
|
130
|
-
) => {
|
|
131
|
-
const {
|
|
132
|
-
naslCore,
|
|
133
|
-
naslUtil,
|
|
134
|
-
naslUI,
|
|
135
|
-
naslOql,
|
|
136
|
-
enums,
|
|
137
|
-
entities,
|
|
138
|
-
structures,
|
|
139
|
-
appLogics,
|
|
140
|
-
interfaceDependencies,
|
|
141
|
-
connections,
|
|
142
|
-
dependencies,
|
|
143
|
-
frontendVariables,
|
|
144
|
-
views,
|
|
145
|
-
currentLogic,
|
|
146
|
-
logicType,
|
|
147
|
-
} = tsContextJSON;
|
|
44
|
+
const state = createCompilerState('', { descriptionComment: true });
|
|
148
45
|
|
|
149
46
|
let code = '';
|
|
150
47
|
code += '### [1] 标准库\n';
|
|
151
|
-
code +=
|
|
48
|
+
code += getNaslCore(logicType).code;
|
|
152
49
|
|
|
153
50
|
code += '\n### [2] nasl.util\n';
|
|
154
|
-
code +=
|
|
51
|
+
code += getNaslUtil().code;
|
|
155
52
|
|
|
156
|
-
if (
|
|
53
|
+
if (frontend) {
|
|
157
54
|
code += '\n### [3] nasl.ui\n';
|
|
158
|
-
|
|
159
|
-
code += wrapTSBlock(naslUI);
|
|
160
|
-
} else {
|
|
161
|
-
code += getNaslUICode(naslUI, codeType, requiredIndexes);
|
|
162
|
-
}
|
|
55
|
+
code += getNaslUIOld().code;
|
|
163
56
|
}
|
|
164
57
|
|
|
165
|
-
if (
|
|
58
|
+
if (logicType === 'global_logic') {
|
|
166
59
|
code += '\n### [4] nasl.oql\n';
|
|
167
|
-
code +=
|
|
60
|
+
code += getNaslOQL().code;
|
|
168
61
|
}
|
|
169
62
|
|
|
170
63
|
code += '\n### [5] 全局上下文\n';
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
code += getEnumsCode(enums);
|
|
174
|
-
}
|
|
64
|
+
code += '\n#### [5-0] 枚举\n';
|
|
65
|
+
code += getEnums(app, state, requiredIndexes).code;
|
|
175
66
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
code += getEntitiesCode(entities);
|
|
179
|
-
}
|
|
67
|
+
code += '\n#### [5-1] 实体\n';
|
|
68
|
+
code += getEntities(app, state, requiredIndexes).code;
|
|
180
69
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
code += getStructuresCode(structures);
|
|
184
|
-
}
|
|
70
|
+
code += '\n#### [5-2] 可用的数据结构\n';
|
|
71
|
+
code += getStructures(app, state, requiredIndexes).code;
|
|
185
72
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
code += getLogicsCode(appLogics, codeType, requiredIndexes);
|
|
189
|
-
}
|
|
73
|
+
code += '\n### [6] 服务端逻辑\n';
|
|
74
|
+
code += getLogics(app, currentNode, requiredIndexes).code;
|
|
190
75
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
code += getModuleInterfacesCode(interfaceDependencies, codeType, requiredIndexes);
|
|
194
|
-
}
|
|
76
|
+
code += '\n### [7] 可调用的接口列表\n';
|
|
77
|
+
code += getModuleInterfaces(app, state, requiredIndexes).code;
|
|
195
78
|
|
|
196
|
-
if (logicType === 'global_logic'
|
|
79
|
+
if (app?.connections?.length > 0 && logicType === 'global_logic') {
|
|
197
80
|
code += '\n### [8] 连接器逻辑列表\n';
|
|
198
|
-
code +=
|
|
81
|
+
code += getConnectors(app, state, requiredIndexes).code;
|
|
199
82
|
}
|
|
200
|
-
|
|
83
|
+
|
|
84
|
+
if (app?.dependencies?.length > 0) {
|
|
201
85
|
code += '\n### [9] 依赖库逻辑列表\n';
|
|
202
|
-
code +=
|
|
86
|
+
code += getDependencies(app, state, requiredIndexes).code;
|
|
203
87
|
}
|
|
204
88
|
|
|
205
|
-
if (
|
|
89
|
+
if (frontend) {
|
|
206
90
|
code += '\n### [10] 页面上下文\n';
|
|
207
|
-
if (
|
|
91
|
+
if (frontend?.variables?.length > 0) {
|
|
208
92
|
code += '\n#### [10-0] 前端全局变量\n';
|
|
209
|
-
code +=
|
|
93
|
+
code += getFrontendVariables(frontend, state).code;
|
|
210
94
|
}
|
|
211
95
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
code += getFrontendViewsCode(views);
|
|
215
|
-
}
|
|
96
|
+
code += '\n#### [10-1] 前端页面列表\n';
|
|
97
|
+
code += getFrontendViews(frontend, state, currentNode, true).code;
|
|
216
98
|
}
|
|
217
99
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
100
|
+
if (focusedNodePath) {
|
|
101
|
+
code += '\n### 当前逻辑上下文\n';
|
|
102
|
+
code += getCurrentNodeContext(currentNode, focusedNodePath, experimental).code;
|
|
103
|
+
}
|
|
221
104
|
return code;
|
|
222
|
-
}
|
|
105
|
+
}
|
|
223
106
|
|
|
224
|
-
export
|
|
107
|
+
export const genNaturalTSContext = genNaturalTSContextForLogic;
|
|
108
|
+
|
|
109
|
+
export function genNaturalTSContextForUI(
|
|
225
110
|
app: App,
|
|
226
|
-
currentNode
|
|
111
|
+
currentNode: BaseNode,
|
|
227
112
|
focusedNodePath?: string,
|
|
228
113
|
requiredIndexes?: string[],
|
|
229
|
-
material?: {
|
|
230
|
-
moduleInterfaces: any;
|
|
231
|
-
connectors: any;
|
|
232
|
-
dependencies: any;
|
|
233
|
-
},
|
|
234
|
-
restParams?: {
|
|
235
|
-
codeType?: 'detail' | 'short';
|
|
236
|
-
}
|
|
114
|
+
material?: { basicMaterials: { json: any; tsDeclaration: string; }, extensionMaterials: { name: string; title: string; description: string; tsDescription: string; }[]; },
|
|
237
115
|
) {
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
currentNode,
|
|
241
|
-
focusedNodePath,
|
|
242
|
-
material
|
|
243
|
-
);
|
|
244
|
-
const code = genNaturalTSContextFromJSONForLogic(
|
|
245
|
-
tsContextJSON,
|
|
246
|
-
restParams.codeType,
|
|
247
|
-
requiredIndexes
|
|
248
|
-
);
|
|
249
|
-
return code;
|
|
250
|
-
}
|
|
116
|
+
const frontend = currentNode.getAncestor('Frontend') as Frontend;
|
|
117
|
+
const state = createCompilerState('', { descriptionComment: true });
|
|
251
118
|
|
|
252
|
-
|
|
253
|
-
|
|
119
|
+
let code = '';
|
|
120
|
+
code += '### [1] 标准库\n';
|
|
121
|
+
code += getNaslCore('view_logic').code;
|
|
254
122
|
|
|
255
|
-
|
|
123
|
+
code += '\n### [2] nasl.util\n';
|
|
124
|
+
code += getNaslUtil().code;
|
|
256
125
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
material?: {
|
|
262
|
-
basicMaterials: 'pc' | 'h5' | { json: any; tsDeclaration: string };
|
|
263
|
-
extensionMaterials: {
|
|
264
|
-
name: string;
|
|
265
|
-
title: string;
|
|
266
|
-
description: string;
|
|
267
|
-
tsDescription: string;
|
|
268
|
-
}[];
|
|
269
|
-
moduleInterfaces: any;
|
|
270
|
-
connectors: any;
|
|
271
|
-
dependencies: any;
|
|
126
|
+
if (frontend) {
|
|
127
|
+
code += '\n### [3] nasl.ui\n';
|
|
128
|
+
code += getNaslUI(app, frontend.type, material || frontend.type, requiredIndexes).code;
|
|
129
|
+
code += '\n';
|
|
272
130
|
}
|
|
131
|
+
|
|
132
|
+
code += '\n### [5] 全局上下文\n';
|
|
133
|
+
code += '\n#### [5-0] 枚举\n';
|
|
134
|
+
code += getEnums(app, state, requiredIndexes).code;
|
|
135
|
+
|
|
136
|
+
code += '\n#### [5-1] 实体\n';
|
|
137
|
+
code += getEntities(app, state, requiredIndexes).code;
|
|
138
|
+
|
|
139
|
+
code += '\n#### [5-2] 可用的数据结构\n';
|
|
140
|
+
code += getStructures(app, state, requiredIndexes).code;
|
|
141
|
+
|
|
142
|
+
code += '\n### [6] 服务端逻辑\n';
|
|
143
|
+
code += getLogics(app, currentNode, requiredIndexes).code;
|
|
144
|
+
|
|
145
|
+
code += '\n### [7] 可调用的接口列表\n';
|
|
146
|
+
code += getModuleInterfaces(app, state, requiredIndexes).code;
|
|
147
|
+
|
|
148
|
+
if (app?.dependencies?.length > 0) {
|
|
149
|
+
code += '\n### [9] 依赖库逻辑列表\n';
|
|
150
|
+
code += getDependencies(app, state, requiredIndexes).code;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (frontend) {
|
|
154
|
+
code += '\n### [10] 页面上下文\n';
|
|
155
|
+
if (frontend?.variables?.length > 0) {
|
|
156
|
+
code += '\n#### [10-0] 前端全局变量\n';
|
|
157
|
+
code += getFrontendVariables(frontend, state).code;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
code += '\n#### [10-1] 前端页面列表\n';
|
|
161
|
+
code += getFrontendViews(frontend, state, currentNode, true).code;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
code += '\n### 当前页面上下文\n';
|
|
165
|
+
code += getCurrentNodeContextForUI(currentNode).code;
|
|
166
|
+
return code;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function genNaturalTSContextJSONForLogic(
|
|
170
|
+
app: App,
|
|
171
|
+
currentNode?: BaseNode,
|
|
172
|
+
focusedNodePath?: string,
|
|
173
|
+
experimental?: boolean
|
|
273
174
|
) {
|
|
274
|
-
const frontend = currentNode
|
|
275
|
-
const
|
|
175
|
+
const frontend = currentNode?.getAncestor('Frontend') as Frontend;
|
|
176
|
+
const logicType = currentNode?.parentNode?.concept === 'App' ? 'global_logic' : 'view_logic';
|
|
177
|
+
const state = createCompilerState('', { descriptionComment: true });
|
|
276
178
|
|
|
277
|
-
const { naslCore } = getNaslCore(
|
|
179
|
+
const { naslCore } = getNaslCore(logicType);
|
|
278
180
|
const { naslUtil } = getNaslUtil();
|
|
279
|
-
const { naslUI } =
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
});
|
|
283
|
-
const {
|
|
284
|
-
const {
|
|
285
|
-
const {
|
|
286
|
-
const {
|
|
287
|
-
const {
|
|
288
|
-
|
|
181
|
+
const { naslUI } = getNaslUIOld();
|
|
182
|
+
const { naslOql } = getNaslOQL();
|
|
183
|
+
const { enums } = getEnums(app, state, []);
|
|
184
|
+
const { entities } = getEntities(app, state, []);
|
|
185
|
+
const { structures } = getStructures(app, state, []);
|
|
186
|
+
const { appLogics } = getLogics(app, currentNode, []);
|
|
187
|
+
const { interfaceDependencies } = getModuleInterfaces(app, state, []);
|
|
188
|
+
const { connections } = getConnectors(app, state, []);
|
|
189
|
+
const { dependencies } = getDependencies(app, state, []);
|
|
190
|
+
const { frontendVar, frontendVariables } = getFrontendVariables(
|
|
191
|
+
currentNode?.getAncestor('Frontend') as Frontend,
|
|
289
192
|
state
|
|
290
193
|
);
|
|
291
|
-
const { dependencies } = getDependencies(
|
|
292
|
-
material?.dependencies || app?.dependencies,
|
|
293
|
-
state,
|
|
294
|
-
'view_logic',
|
|
295
|
-
frontend?.type
|
|
296
|
-
);
|
|
297
|
-
const { frontendVariables } = getFrontendVariables(frontend, state);
|
|
298
194
|
const { views } = getFrontendViews(frontend, state, currentNode, false);
|
|
299
|
-
const { currentLogic } =
|
|
195
|
+
const { currentLogic } = getCurrentNodeContext(currentNode, focusedNodePath, experimental);
|
|
300
196
|
|
|
301
197
|
return {
|
|
302
198
|
naslCore,
|
|
303
199
|
naslUtil,
|
|
304
200
|
naslUI,
|
|
201
|
+
naslOql,
|
|
305
202
|
enums,
|
|
306
203
|
entities,
|
|
307
204
|
structures,
|
|
308
205
|
appLogics,
|
|
309
206
|
interfaceDependencies,
|
|
207
|
+
connections,
|
|
310
208
|
dependencies,
|
|
209
|
+
frontendVar, // @deprecated
|
|
311
210
|
frontendVariables,
|
|
312
211
|
views,
|
|
313
|
-
|
|
212
|
+
currentLogic,
|
|
314
213
|
};
|
|
315
214
|
}
|
|
316
215
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const {
|
|
216
|
+
export const genNaturalTsContextJson = genNaturalTSContextJSONForLogic;
|
|
217
|
+
|
|
218
|
+
export function genNaturalTSContextJSONForUI(
|
|
219
|
+
app: App,
|
|
220
|
+
currentNode: BaseNode,
|
|
221
|
+
material?: { basicMaterials: { json: any; tsDeclaration: string; }, extensionMaterials: { name: string; title: string; description: string; tsDescription: string; }[]; },
|
|
222
|
+
requiredIndexes?: string[],
|
|
223
|
+
) {
|
|
224
|
+
const frontend = currentNode.getAncestor('Frontend') as Frontend;
|
|
225
|
+
const state = createCompilerState();
|
|
226
|
+
|
|
227
|
+
const { naslCore } = getNaslCore('view_logic');
|
|
228
|
+
const { naslUtil } = getNaslUtil();
|
|
229
|
+
const { naslUI } = getNaslUI(app, frontend.type, material || frontend.type, requiredIndexes);
|
|
230
|
+
const { enums } = getEnums(app, state, requiredIndexes);
|
|
231
|
+
const { entities } = getEntities(app, state, requiredIndexes);
|
|
232
|
+
const { structures } = getStructures(app, state, requiredIndexes);
|
|
233
|
+
const { appLogics } = getLogics(app, currentNode, requiredIndexes);
|
|
234
|
+
const { interfaceDependencies } = getModuleInterfaces(app, state, requiredIndexes);
|
|
235
|
+
const { dependencies } = getDependencies(app, state, requiredIndexes);
|
|
236
|
+
const { frontendVariables } = getFrontendVariables(frontend, state);
|
|
237
|
+
const { views } = getFrontendViews(frontend, state, currentNode, true);
|
|
238
|
+
const { currentLogic } = getCurrentNodeContextForUI(currentNode);
|
|
239
|
+
|
|
240
|
+
return {
|
|
331
241
|
naslCore,
|
|
332
242
|
naslUtil,
|
|
333
243
|
naslUI,
|
|
@@ -339,100 +249,8 @@ export const genNaturalTSContextFromJSONForUI = (
|
|
|
339
249
|
dependencies,
|
|
340
250
|
frontendVariables,
|
|
341
251
|
views,
|
|
342
|
-
currentPage,
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
let code = '';
|
|
346
|
-
code += '### [1] 标准库\n';
|
|
347
|
-
code += wrapTSBlock(naslCore);
|
|
348
|
-
|
|
349
|
-
code += '\n### [2] nasl.util\n';
|
|
350
|
-
code += wrapTSBlock(naslUtil);
|
|
351
|
-
|
|
352
|
-
if (naslUI) {
|
|
353
|
-
code += '\n### [3] nasl.ui\n';
|
|
354
|
-
if (typeof naslUI === 'string') {
|
|
355
|
-
code += wrapTSBlock(naslUI);
|
|
356
|
-
} else {
|
|
357
|
-
code += getNaslUICode(naslUI, codeType, requiredIndexes);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
code += '\n### [5] 全局上下文\n';
|
|
362
|
-
if (enums.data?.length) {
|
|
363
|
-
code += '\n#### [5-0] 枚举\n';
|
|
364
|
-
code += getEnumsCode(enums);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (entities?.length) {
|
|
368
|
-
code += '\n#### [5-1] 实体\n';
|
|
369
|
-
code += getEntitiesCode(entities);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (structures.data?.length) {
|
|
373
|
-
code += '\n#### [5-2] 可用的数据结构\n';
|
|
374
|
-
code += getStructuresCode(structures);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
if (appLogics.data?.length) {
|
|
378
|
-
code += '\n### [6] 服务端逻辑\n';
|
|
379
|
-
code += getLogicsCode(appLogics, codeType, requiredIndexes);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
if (interfaceDependencies) {
|
|
383
|
-
code += '\n### [7] 可调用的接口列表\n';
|
|
384
|
-
code += getModuleInterfacesCode(interfaceDependencies, codeType, requiredIndexes);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (dependencies) {
|
|
388
|
-
code += '\n### [9] 依赖库逻辑列表\n';
|
|
389
|
-
code += getDependenciesCode(dependencies, codeType, requiredIndexes);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
code += '\n### [10] 页面上下文\n';
|
|
393
|
-
if (frontendVariables) {
|
|
394
|
-
code += '\n#### [10-0] 前端全局变量\n';
|
|
395
|
-
code += frontendVariables;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (views?.data?.length) {
|
|
399
|
-
code += '\n#### [10-1] 前端页面列表\n';
|
|
400
|
-
code += getFrontendViewsCode(views);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
code += '\n### 当前页面上下文\n';
|
|
404
|
-
code += wrapTSBlock(currentPage);
|
|
405
|
-
|
|
406
|
-
return code;
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
// 兼容各版本,统一调用 genNaturalTSContextForUI 方法
|
|
410
|
-
export function genNaturalTSContextForUI(
|
|
411
|
-
app: App,
|
|
412
|
-
currentNode: BaseNode,
|
|
413
|
-
focusedNodePath?: string,
|
|
414
|
-
requiredIndexes?: string[],
|
|
415
|
-
material?: {
|
|
416
|
-
basicMaterials: 'pc' | 'h5' | { json: any; tsDeclaration: string };
|
|
417
|
-
extensionMaterials: {
|
|
418
|
-
name: string;
|
|
419
|
-
title: string;
|
|
420
|
-
description: string;
|
|
421
|
-
tsDescription: string;
|
|
422
|
-
}[];
|
|
423
|
-
moduleInterfaces: any;
|
|
424
|
-
connectors: any;
|
|
425
|
-
dependencies: any;
|
|
426
|
-
},
|
|
427
|
-
restParams?: {
|
|
428
|
-
codeType?: 'detail' | 'short';
|
|
429
|
-
}
|
|
430
|
-
) {
|
|
431
|
-
const tsContextJSON = genNaturalTSContextJSONForUI(app, currentNode, material);
|
|
432
|
-
const code = genNaturalTSContextFromJSONForUI(
|
|
433
|
-
tsContextJSON,
|
|
434
|
-
restParams.codeType,
|
|
435
|
-
requiredIndexes
|
|
436
|
-
);
|
|
437
|
-
return code;
|
|
252
|
+
currentPage: currentLogic,
|
|
253
|
+
};
|
|
438
254
|
}
|
|
255
|
+
|
|
256
|
+
export * as getNaturalContext from './getContext';
|
|
@@ -104,10 +104,9 @@ export function getExtensionsDeclaration(viewComponent: any) {
|
|
|
104
104
|
code += `${indent(state.tabSize + 1)}}\n`;
|
|
105
105
|
code += `${indent(state.tabSize + 1)}class ${componentName}Options extends ViewComponentOptions {\n`;
|
|
106
106
|
// props
|
|
107
|
-
|
|
108
|
-
props?.forEach((prop: any) => {
|
|
107
|
+
viewComponent.props?.forEach((prop: any) => {
|
|
109
108
|
code += `${indent(state.tabSize + 2)}${utils.getDescription(prop.title, prop.description)}\n`;
|
|
110
|
-
code += `${indent(state.tabSize + 2)}${
|
|
109
|
+
code += `${indent(state.tabSize + 2)}${prop.name}?: ${prop?.type || prop?.tsType};\n`;
|
|
111
110
|
});
|
|
112
111
|
// events
|
|
113
112
|
viewComponent.events?.forEach((event: any) => {
|