@lcap/nasl 4.5.0-beta.1 → 4.5.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/automate/upgrader/2.12.d.ts.map +1 -1
- package/out/automate/upgrader/2.12.js +1 -0
- package/out/automate/upgrader/2.12.js.map +1 -1
- package/out/automate/upgrader/2.14.d.ts.map +1 -1
- package/out/automate/upgrader/2.14.js +1 -0
- package/out/automate/upgrader/2.14.js.map +1 -1
- package/out/automate/upgrader/2.16.d.ts.map +1 -1
- package/out/automate/upgrader/2.16.js +1 -0
- package/out/automate/upgrader/2.16.js.map +1 -1
- package/out/automate/upgrader/2.17.d.ts.map +1 -1
- package/out/automate/upgrader/2.17.js +1 -0
- package/out/automate/upgrader/2.17.js.map +1 -1
- package/out/automate/upgrader/2.18.d.ts.map +1 -1
- package/out/automate/upgrader/2.18.js +1 -0
- package/out/automate/upgrader/2.18.js.map +1 -1
- package/out/automate/upgrader/2.20.d.ts.map +1 -1
- package/out/automate/upgrader/2.20.js +1 -0
- package/out/automate/upgrader/2.20.js.map +1 -1
- package/out/concepts/index.mini.d.ts +10 -0
- package/out/concepts/index.mini.d.ts.map +1 -0
- package/out/concepts/index.mini.js +26 -0
- package/out/concepts/index.mini.js.map +1 -0
- package/out/generator/genBundleFiles.d.ts.map +1 -1
- package/out/generator/genBundleFiles.js +161 -24
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/permission.js +2 -2
- package/out/generator/permission.js.map +1 -1
- package/out/generator/release-body/utils.d.ts +1 -1
- package/out/generator/release-body/utils.d.ts.map +1 -1
- package/out/generator/release-body/utils.js +8 -6
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/generator/rspack-broswer/bundle.d.ts +24 -0
- package/out/generator/rspack-broswer/bundle.d.ts.map +1 -0
- package/out/generator/rspack-broswer/bundle.js +442 -0
- package/out/generator/rspack-broswer/bundle.js.map +1 -0
- package/out/generator/rspack-broswer/container/client-lazyload-template.d.ts +9 -0
- package/out/generator/rspack-broswer/container/client-lazyload-template.d.ts.map +1 -0
- package/out/generator/rspack-broswer/container/client-lazyload-template.js +88 -0
- package/out/generator/rspack-broswer/container/client-lazyload-template.js.map +1 -0
- package/out/generator/rspack-broswer/container/file-system.d.ts +12 -0
- package/out/generator/rspack-broswer/container/file-system.d.ts.map +1 -0
- package/out/generator/rspack-broswer/container/file-system.js +58 -0
- package/out/generator/rspack-broswer/container/file-system.js.map +1 -0
- package/out/generator/rspack-broswer/container/index.d.ts +3 -0
- package/out/generator/rspack-broswer/container/index.d.ts.map +1 -0
- package/out/generator/rspack-broswer/container/index.js +15 -0
- package/out/generator/rspack-broswer/container/index.js.map +1 -0
- package/out/generator/rspack-broswer/index.d.ts +3 -0
- package/out/generator/rspack-broswer/index.d.ts.map +1 -0
- package/out/generator/rspack-broswer/index.js +19 -0
- package/out/generator/rspack-broswer/index.js.map +1 -0
- package/out/generator/rspack-broswer/loaders/vue/index.d.ts +2 -0
- package/out/generator/rspack-broswer/loaders/vue/index.d.ts.map +1 -0
- package/out/generator/rspack-broswer/loaders/vue/index.js +228 -0
- package/out/generator/rspack-broswer/loaders/vue/index.js.map +1 -0
- package/out/generator/rspack-broswer/plugins/lcap/constant.d.ts +3 -0
- package/out/generator/rspack-broswer/plugins/lcap/constant.d.ts.map +1 -0
- package/out/generator/rspack-broswer/plugins/lcap/constant.js +213 -0
- package/out/generator/rspack-broswer/plugins/lcap/constant.js.map +1 -0
- package/out/generator/rspack-broswer/plugins/lcap/index.d.ts +6 -0
- package/out/generator/rspack-broswer/plugins/lcap/index.d.ts.map +1 -0
- package/out/generator/rspack-broswer/plugins/lcap/index.js +175 -0
- package/out/generator/rspack-broswer/plugins/lcap/index.js.map +1 -0
- package/out/generator/rspack-broswer/plugins/missing-css-fallback/index.d.ts +10 -0
- package/out/generator/rspack-broswer/plugins/missing-css-fallback/index.d.ts.map +1 -0
- package/out/generator/rspack-broswer/plugins/missing-css-fallback/index.js +50 -0
- package/out/generator/rspack-broswer/plugins/missing-css-fallback/index.js.map +1 -0
- package/out/generator/ui-library-declaration/dependency.d.ts +20 -0
- package/out/generator/ui-library-declaration/dependency.d.ts.map +1 -1
- package/out/generator/ui-library-declaration/dependency.js +3 -2
- package/out/generator/ui-library-declaration/dependency.js.map +1 -1
- package/out/generator/ui-library-declaration/index.d.ts +1 -0
- package/out/generator/ui-library-declaration/index.d.ts.map +1 -1
- package/out/generator/ui-library-declaration/index.js +1 -0
- package/out/generator/ui-library-declaration/index.js.map +1 -1
- package/out/generator/ui-library-declaration/material.d.ts +2 -2
- package/out/generator/ui-library-declaration/material.d.ts.map +1 -1
- package/out/generator/ui-library-declaration/material.js +7 -3
- package/out/generator/ui-library-declaration/material.js.map +1 -1
- package/out/index.d.ts +2 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +7 -1
- package/out/index.js.map +1 -1
- package/out/index.mini.d.ts +42 -0
- package/out/index.mini.d.ts.map +1 -0
- package/out/index.mini.js +89 -0
- package/out/index.mini.js.map +1 -0
- package/out/manager/diagnostic.d.ts +5 -5
- package/out/manager/diagnostic.d.ts.map +1 -1
- package/out/natural/exports/doctor/doctorView.d.ts +24 -0
- package/out/natural/exports/doctor/doctorView.d.ts.map +1 -0
- package/out/natural/exports/doctor/doctorView.js +351 -0
- package/out/natural/exports/doctor/doctorView.js.map +1 -0
- package/out/natural/exports/doctor/index.d.ts +4 -0
- package/out/natural/exports/doctor/index.d.ts.map +1 -0
- package/out/natural/exports/doctor/index.js +10 -0
- package/out/natural/exports/doctor/index.js.map +1 -0
- package/out/natural/exports/doctor/types.d.ts +109 -0
- package/out/natural/exports/doctor/types.d.ts.map +1 -0
- package/out/natural/exports/doctor/types.js +6 -0
- package/out/natural/exports/doctor/types.js.map +1 -0
- package/out/natural/exports/doctor/viewGraph.d.ts +20 -0
- package/out/natural/exports/doctor/viewGraph.d.ts.map +1 -0
- package/out/natural/exports/doctor/viewGraph.js +448 -0
- package/out/natural/exports/doctor/viewGraph.js.map +1 -0
- package/out/natural/exports/nasl2Files.d.ts.map +1 -1
- package/out/natural/exports/nasl2Files.js +113 -9
- package/out/natural/exports/nasl2Files.js.map +1 -1
- package/out/natural/exports/transform2BatchActions/apply.d.ts +11 -0
- package/out/natural/exports/transform2BatchActions/apply.d.ts.map +1 -0
- package/out/natural/exports/transform2BatchActions/apply.js +68 -0
- package/out/natural/exports/transform2BatchActions/apply.js.map +1 -0
- package/out/natural/exports/transform2BatchActions/diff/directories.d.ts +17 -0
- package/out/natural/exports/transform2BatchActions/diff/directories.d.ts.map +1 -0
- package/out/natural/exports/transform2BatchActions/diff/directories.js +215 -0
- package/out/natural/exports/transform2BatchActions/diff/directories.js.map +1 -0
- package/out/natural/exports/transform2BatchActions/diff/index.d.ts +21 -0
- package/out/natural/exports/transform2BatchActions/diff/index.d.ts.map +1 -0
- package/out/natural/exports/transform2BatchActions/diff/index.js +20 -0
- package/out/natural/exports/transform2BatchActions/diff/index.js.map +1 -0
- package/out/natural/exports/transform2BatchActions/diff/nodes.d.ts +186 -0
- package/out/natural/exports/transform2BatchActions/diff/nodes.d.ts.map +1 -0
- package/out/natural/exports/transform2BatchActions/diff/nodes.js +498 -0
- package/out/natural/exports/transform2BatchActions/diff/nodes.js.map +1 -0
- package/out/natural/exports/transform2BatchActions/diff/roles.d.ts +18 -0
- package/out/natural/exports/transform2BatchActions/diff/roles.d.ts.map +1 -0
- package/out/natural/exports/transform2BatchActions/diff/roles.js +61 -0
- package/out/natural/exports/transform2BatchActions/diff/roles.js.map +1 -0
- package/out/natural/exports/transform2BatchActions/index.d.ts +41 -0
- package/out/natural/exports/transform2BatchActions/index.d.ts.map +1 -0
- package/out/natural/exports/transform2BatchActions/index.js +61 -0
- package/out/natural/exports/transform2BatchActions/index.js.map +1 -0
- package/out/natural/exports/transform2BatchActions/parse.d.ts +24 -0
- package/out/natural/exports/transform2BatchActions/parse.d.ts.map +1 -0
- package/out/natural/exports/transform2BatchActions/parse.js +257 -0
- package/out/natural/exports/transform2BatchActions/parse.js.map +1 -0
- package/out/natural/exports/transform2BatchActions/types.d.ts +147 -0
- package/out/natural/exports/transform2BatchActions/types.d.ts.map +1 -0
- package/out/natural/exports/transform2BatchActions/types.js +7 -0
- package/out/natural/exports/transform2BatchActions/types.js.map +1 -0
- package/out/natural/index.d.ts +1 -0
- package/out/natural/index.d.ts.map +1 -1
- package/out/natural/index.js +1 -0
- package/out/natural/index.js.map +1 -1
- package/out/natural/old/parser/transformTS2UI.d.ts.map +1 -1
- package/out/natural/old/parser/transformTS2UI.js +4 -1
- package/out/natural/old/parser/transformTS2UI.js.map +1 -1
- package/out/natural/old/parser/transformTSCode.js +1 -1
- package/out/natural/old/parser/transformTSCode.js.map +1 -1
- package/out/natural/parser/parseNaturalTS.d.ts.map +1 -1
- package/out/natural/parser/parseNaturalTS.js +106 -2
- package/out/natural/parser/parseNaturalTS.js.map +1 -1
- package/out/natural/parser/parseNaturalTSXView.d.ts.map +1 -1
- package/out/natural/parser/parseNaturalTSXView.js +60 -7
- package/out/natural/parser/parseNaturalTSXView.js.map +1 -1
- package/out/natural/transforms/checker/checkIdentifierName.d.ts +6 -0
- package/out/natural/transforms/checker/checkIdentifierName.d.ts.map +1 -0
- package/out/natural/transforms/checker/checkIdentifierName.js +15 -0
- package/out/natural/transforms/checker/checkIdentifierName.js.map +1 -0
- package/out/natural/transforms/checker/checkKeywords.d.ts +33 -0
- package/out/natural/transforms/checker/checkKeywords.d.ts.map +1 -0
- package/out/natural/transforms/checker/checkKeywords.js +85 -0
- package/out/natural/transforms/checker/checkKeywords.js.map +1 -0
- package/out/natural/transforms/checker/checkViewElement.d.ts +10 -0
- package/out/natural/transforms/checker/checkViewElement.d.ts.map +1 -1
- package/out/natural/transforms/checker/checkViewElement.js +28 -1
- package/out/natural/transforms/checker/checkViewElement.js.map +1 -1
- package/out/natural/transforms/checker/index.d.ts +3 -1
- package/out/natural/transforms/checker/index.d.ts.map +1 -1
- package/out/natural/transforms/checker/index.js +10 -1
- package/out/natural/transforms/checker/index.js.map +1 -1
- package/out/natural/transforms/transform2AuthLogic.d.ts +4 -0
- package/out/natural/transforms/transform2AuthLogic.d.ts.map +1 -0
- package/out/natural/transforms/transform2AuthLogic.js +116 -0
- package/out/natural/transforms/transform2AuthLogic.js.map +1 -0
- package/out/natural/transforms/transform2Config.d.ts +17 -0
- package/out/natural/transforms/transform2Config.d.ts.map +1 -0
- package/out/natural/transforms/transform2Config.js +114 -0
- package/out/natural/transforms/transform2Config.js.map +1 -0
- package/out/natural/transforms/transform2Entity.d.ts +2 -2
- package/out/natural/transforms/transform2Entity.d.ts.map +1 -1
- package/out/natural/transforms/transform2Entity.js +11 -2
- package/out/natural/transforms/transform2Entity.js.map +1 -1
- package/out/natural/transforms/transform2Enum.d.ts.map +1 -1
- package/out/natural/transforms/transform2Enum.js +8 -1
- package/out/natural/transforms/transform2Enum.js.map +1 -1
- package/out/natural/transforms/transform2ExportInterface.d.ts +3 -0
- package/out/natural/transforms/transform2ExportInterface.d.ts.map +1 -0
- package/out/natural/transforms/transform2ExportInterface.js +96 -0
- package/out/natural/transforms/transform2ExportInterface.js.map +1 -0
- package/out/natural/transforms/transform2GlobalLogicDeclaration.d.ts.map +1 -1
- package/out/natural/transforms/transform2GlobalLogicDeclaration.js +4 -1
- package/out/natural/transforms/transform2GlobalLogicDeclaration.js.map +1 -1
- package/out/natural/transforms/transform2Logic.d.ts.map +1 -1
- package/out/natural/transforms/transform2Logic.js +8 -38
- package/out/natural/transforms/transform2Logic.js.map +1 -1
- package/out/natural/transforms/transform2LogicItem.d.ts +9 -2
- package/out/natural/transforms/transform2LogicItem.d.ts.map +1 -1
- package/out/natural/transforms/transform2LogicItem.js +169 -61
- package/out/natural/transforms/transform2LogicItem.js.map +1 -1
- package/out/natural/transforms/transform2OverriddenLogic.d.ts +3 -0
- package/out/natural/transforms/transform2OverriddenLogic.d.ts.map +1 -0
- package/out/natural/transforms/transform2OverriddenLogic.js +83 -0
- package/out/natural/transforms/transform2OverriddenLogic.js.map +1 -0
- package/out/natural/transforms/transform2Param.d.ts +1 -1
- package/out/natural/transforms/transform2Param.d.ts.map +1 -1
- package/out/natural/transforms/transform2Param.js +19 -1
- package/out/natural/transforms/transform2Param.js.map +1 -1
- package/out/natural/transforms/transform2Roles.d.ts +3 -0
- package/out/natural/transforms/transform2Roles.d.ts.map +1 -0
- package/out/natural/transforms/transform2Roles.js +34 -0
- package/out/natural/transforms/transform2Roles.js.map +1 -0
- package/out/natural/transforms/transform2Structure.d.ts.map +1 -1
- package/out/natural/transforms/transform2Structure.js +2 -0
- package/out/natural/transforms/transform2Structure.js.map +1 -1
- package/out/natural/transforms/transform2TypeAnnotation.d.ts.map +1 -1
- package/out/natural/transforms/transform2TypeAnnotation.js +8 -4
- package/out/natural/transforms/transform2TypeAnnotation.js.map +1 -1
- package/out/natural/transforms/transform2Variable.d.ts.map +1 -1
- package/out/natural/transforms/transform2Variable.js +4 -0
- package/out/natural/transforms/transform2Variable.js.map +1 -1
- package/out/natural/transforms/utils/createComponentLookupMap.js +3 -3
- package/out/natural/transforms/utils/createComponentLookupMap.js.map +1 -1
- package/out/natural/transforms/utils/ensureBindRoles.d.ts +9 -0
- package/out/natural/transforms/utils/ensureBindRoles.d.ts.map +1 -0
- package/out/natural/transforms/utils/ensureBindRoles.js +25 -0
- package/out/natural/transforms/utils/ensureBindRoles.js.map +1 -0
- package/out/natural/transforms/utils/flattenStatementsWithComments.d.ts +11 -0
- package/out/natural/transforms/utils/flattenStatementsWithComments.d.ts.map +1 -0
- package/out/natural/transforms/utils/flattenStatementsWithComments.js +36 -0
- package/out/natural/transforms/utils/flattenStatementsWithComments.js.map +1 -0
- package/out/natural/transforms/utils/parseDecorator.d.ts +4 -4
- package/out/natural/transforms/utils/parseDecorator.d.ts.map +1 -1
- package/out/natural/transforms/utils/parseDecorator.js +40 -24
- package/out/natural/transforms/utils/parseDecorator.js.map +1 -1
- package/out/natural/transforms/utils/parseLogicBody.d.ts +17 -0
- package/out/natural/transforms/utils/parseLogicBody.d.ts.map +1 -0
- package/out/natural/transforms/utils/parseLogicBody.js +47 -0
- package/out/natural/transforms/utils/parseLogicBody.js.map +1 -0
- package/out/natural/utils/index.d.ts +5 -0
- package/out/natural/utils/index.d.ts.map +1 -1
- package/out/natural/utils/index.js +11 -1
- package/out/natural/utils/index.js.map +1 -1
- package/out/natural/utils/nasl-file-types.d.ts +6 -1
- package/out/natural/utils/nasl-file-types.d.ts.map +1 -1
- package/out/natural/utils/nasl-file-types.js +77 -2
- package/out/natural/utils/nasl-file-types.js.map +1 -1
- package/out/server/extendBaseNode.d.ts.map +1 -1
- package/out/server/extendBaseNode.js +9 -3
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/naslServer.d.ts +18 -0
- package/out/server/naslServer.d.ts.map +1 -1
- package/out/server/naslServer.js +89 -0
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslUiComponentTs.d.ts +1 -2
- package/out/server/naslUiComponentTs.d.ts.map +1 -1
- package/out/server/naslUiComponentTs.default.d.ts +47 -0
- package/out/server/naslUiComponentTs.js +25 -49
- package/out/server/naslUiComponentTs.js.map +1 -1
- package/out/service/autofix/types.d.ts +2 -2
- package/out/service/autofix/types.d.ts.map +1 -1
- package/out/service/instruct-ruler/ruler.d.ts +3 -1
- package/out/service/instruct-ruler/ruler.d.ts.map +1 -1
- package/out/service/instruct-ruler/ruler.js +2 -1
- package/out/service/instruct-ruler/ruler.js.map +1 -1
- package/out/service/storage/init.d.ts +6 -0
- package/out/service/storage/init.d.ts.map +1 -1
- package/out/service/storage/init.js +22 -9
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/operation.d.ts +9 -1
- package/out/service/storage/operation.d.ts.map +1 -1
- package/out/service/storage/operation.js +220 -100
- package/out/service/storage/operation.js.map +1 -1
- package/out/service/storage/specTools.d.ts.map +1 -1
- package/out/service/storage/specTools.js +25 -13
- package/out/service/storage/specTools.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +13 -1
- package/out/templator/genQueryComponent.d.ts.map +1 -1
- package/out/templator/genQueryComponent.js +18 -14
- package/out/templator/genQueryComponent.js.map +1 -1
- package/package.json +16 -10
- package/sandbox/stdlib/nasl.util.ts +16 -15
- package/out/natural/exports/transform2BatchActions.d.ts +0 -114
- package/out/natural/exports/transform2BatchActions.d.ts.map +0 -1
- package/out/natural/exports/transform2BatchActions.js +0 -1233
- package/out/natural/exports/transform2BatchActions.js.map +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 标准节点 diff
|
|
3
|
+
* 处理 entity/structure/enum/logic/view/variables/theme 节点的增删改
|
|
4
|
+
* 含:类型守卫、TypeHandler 工厂、节点处理函数、节点遍历主循环
|
|
5
|
+
*/
|
|
6
|
+
import { type ItemType, type Operators, type SingleNodeHandler, type ViewHandler, type GlobalVariablesHandler, type ThemeHandler, type ConfigurationHandler, type TypeHandler } from '../types';
|
|
7
|
+
export declare const isSingleNodeHandler: (handler: TypeHandler) => handler is SingleNodeHandler;
|
|
8
|
+
export declare const isViewHandler: (handler: TypeHandler) => handler is ViewHandler;
|
|
9
|
+
export declare const isGlobalVariablesHandler: (handler: TypeHandler) => handler is GlobalVariablesHandler;
|
|
10
|
+
export declare const isThemeHandler: (handler: TypeHandler) => handler is ThemeHandler;
|
|
11
|
+
export declare const isConfigurationHandler: (handler: TypeHandler) => handler is ConfigurationHandler;
|
|
12
|
+
/**
|
|
13
|
+
* 构建嵌套视图的 NASL 路径
|
|
14
|
+
*/
|
|
15
|
+
export declare const buildNestedViewPath: (parentViewNames: string[], viewName: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* 创建视图查找函数
|
|
18
|
+
*/
|
|
19
|
+
export declare const createViewFinder: (instance: any) => (name: string, parentViewNames?: string[]) => any;
|
|
20
|
+
/**
|
|
21
|
+
* 创建各类型节点的处理器(工厂函数)
|
|
22
|
+
*/
|
|
23
|
+
export declare const createTypeHandlers: (appInstance: any, app: any) => {
|
|
24
|
+
entity: {
|
|
25
|
+
type: "entity";
|
|
26
|
+
path: string;
|
|
27
|
+
findMethod: (name: string) => any;
|
|
28
|
+
findExisting: (name: string) => any;
|
|
29
|
+
};
|
|
30
|
+
structure: {
|
|
31
|
+
type: "structure";
|
|
32
|
+
path: string;
|
|
33
|
+
findMethod: (name: string) => any;
|
|
34
|
+
findExisting: (name: string) => any;
|
|
35
|
+
};
|
|
36
|
+
enum: {
|
|
37
|
+
type: "enum";
|
|
38
|
+
path: string;
|
|
39
|
+
findMethod: (name: string) => any;
|
|
40
|
+
findExisting: (name: string) => any;
|
|
41
|
+
};
|
|
42
|
+
logic: {
|
|
43
|
+
type: "logic";
|
|
44
|
+
path: string;
|
|
45
|
+
findMethod: (name: string) => any;
|
|
46
|
+
findExisting: (name: string) => any;
|
|
47
|
+
};
|
|
48
|
+
authLogicForExportInterface: {
|
|
49
|
+
type: "authLogicForExportInterface";
|
|
50
|
+
path: string;
|
|
51
|
+
findMethod: (name: string) => any;
|
|
52
|
+
findExisting: (name: string) => any;
|
|
53
|
+
};
|
|
54
|
+
authLogicForCallInterface: {
|
|
55
|
+
type: "authLogicForCallInterface";
|
|
56
|
+
path: string;
|
|
57
|
+
findMethod: (name: string) => any;
|
|
58
|
+
findExisting: (name: string) => any;
|
|
59
|
+
};
|
|
60
|
+
exportInterface: {
|
|
61
|
+
type: "exportInterface";
|
|
62
|
+
path: string;
|
|
63
|
+
findMethod: (name: string) => any;
|
|
64
|
+
findExisting: (name: string) => any;
|
|
65
|
+
};
|
|
66
|
+
overriddenLogic: {
|
|
67
|
+
type: "overriddenLogic";
|
|
68
|
+
path: string;
|
|
69
|
+
findMethod: (compositeKey: string) => any;
|
|
70
|
+
findExisting: (compositeKey: string) => any;
|
|
71
|
+
};
|
|
72
|
+
view: {
|
|
73
|
+
type: "view";
|
|
74
|
+
path: string;
|
|
75
|
+
findMethod: (name: string, parentViewNames?: string[]) => any;
|
|
76
|
+
findExisting: (name: string, parentViewNames?: string[]) => any;
|
|
77
|
+
};
|
|
78
|
+
backendVariables: {
|
|
79
|
+
type: "backendVariables";
|
|
80
|
+
path: string;
|
|
81
|
+
findMethod: (name?: string) => any;
|
|
82
|
+
findExisting: (name?: string) => any;
|
|
83
|
+
};
|
|
84
|
+
frontendVariables: {
|
|
85
|
+
type: "frontendVariables";
|
|
86
|
+
path: string;
|
|
87
|
+
findMethod: (name?: string) => any;
|
|
88
|
+
findExisting: (name?: string) => any;
|
|
89
|
+
};
|
|
90
|
+
theme: {
|
|
91
|
+
type: "theme";
|
|
92
|
+
path: string;
|
|
93
|
+
findMethod: () => any;
|
|
94
|
+
findExisting: () => any;
|
|
95
|
+
};
|
|
96
|
+
configuration: {
|
|
97
|
+
type: "configuration";
|
|
98
|
+
path: (groupName: string) => string;
|
|
99
|
+
findMethod: (groupName: string, propName?: string) => any;
|
|
100
|
+
findExisting: (groupName: string, propName?: string) => any;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* 通用删除操作处理
|
|
105
|
+
*/
|
|
106
|
+
export declare const handleDeleteOperation: (params: {
|
|
107
|
+
handler: SingleNodeHandler | ViewHandler | GlobalVariablesHandler;
|
|
108
|
+
itemName: string;
|
|
109
|
+
itemType: ItemType;
|
|
110
|
+
batchActions: Operators;
|
|
111
|
+
errors: Array<{
|
|
112
|
+
item: string;
|
|
113
|
+
type: string;
|
|
114
|
+
error: Error;
|
|
115
|
+
level: number;
|
|
116
|
+
}>;
|
|
117
|
+
parentViewNames?: string[];
|
|
118
|
+
errorMessageTemplate?: string;
|
|
119
|
+
}) => void;
|
|
120
|
+
/**
|
|
121
|
+
* 处理全局变量类型(一个文件对应多个节点)
|
|
122
|
+
*/
|
|
123
|
+
export declare const processGlobalVariables: (params: {
|
|
124
|
+
handler: GlobalVariablesHandler;
|
|
125
|
+
action: string;
|
|
126
|
+
itemType: ItemType;
|
|
127
|
+
batchActions: Operators;
|
|
128
|
+
errors: Array<{
|
|
129
|
+
item: string;
|
|
130
|
+
type: string;
|
|
131
|
+
error: Error;
|
|
132
|
+
level: number;
|
|
133
|
+
}>;
|
|
134
|
+
}) => void;
|
|
135
|
+
/**
|
|
136
|
+
* 处理配置类型(一个文件对应多个 ConfigProperty 节点)
|
|
137
|
+
*/
|
|
138
|
+
export declare const processConfigurationProperties: (params: {
|
|
139
|
+
handler: ConfigurationHandler;
|
|
140
|
+
groupName: string;
|
|
141
|
+
action: string;
|
|
142
|
+
itemType: ItemType;
|
|
143
|
+
batchActions: Operators;
|
|
144
|
+
errors: Array<{
|
|
145
|
+
item: string;
|
|
146
|
+
type: string;
|
|
147
|
+
error: Error;
|
|
148
|
+
level: number;
|
|
149
|
+
}>;
|
|
150
|
+
}) => void;
|
|
151
|
+
/**
|
|
152
|
+
* 处理单节点类型(一个文件对应一个节点)
|
|
153
|
+
*/
|
|
154
|
+
export declare const processSingleNode: (params: {
|
|
155
|
+
handler: SingleNodeHandler | ViewHandler;
|
|
156
|
+
itemName: string;
|
|
157
|
+
itemType: ItemType;
|
|
158
|
+
action: string;
|
|
159
|
+
parentViewNames?: string[];
|
|
160
|
+
batchActions: Operators;
|
|
161
|
+
errors: Array<{
|
|
162
|
+
item: string;
|
|
163
|
+
type: string;
|
|
164
|
+
error: Error;
|
|
165
|
+
level: number;
|
|
166
|
+
}>;
|
|
167
|
+
}) => void;
|
|
168
|
+
/**
|
|
169
|
+
* 检查项目类型是否允许空名称
|
|
170
|
+
*/
|
|
171
|
+
export declare const isNameOptional: (itemType: ItemType) => boolean;
|
|
172
|
+
/**
|
|
173
|
+
* 遍历 itemTypes,为每个节点生成对应的 BatchAction
|
|
174
|
+
*/
|
|
175
|
+
export declare const processNodeItems: (appInstance: any, app: any, itemTypes: Array<{
|
|
176
|
+
type: ItemType;
|
|
177
|
+
name: string;
|
|
178
|
+
action: string;
|
|
179
|
+
parentViewNames?: string[];
|
|
180
|
+
}>, batchActions: Operators, errors: Array<{
|
|
181
|
+
item: string;
|
|
182
|
+
type: string;
|
|
183
|
+
error: Error;
|
|
184
|
+
level: number;
|
|
185
|
+
}>) => void;
|
|
186
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../src/natural/exports/transform2BatchActions/diff/nodes.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 标准节点 diff
|
|
4
|
+
* 处理 entity/structure/enum/logic/view/variables/theme 节点的增删改
|
|
5
|
+
* 含:类型守卫、TypeHandler 工厂、节点处理函数、节点遍历主循环
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.processNodeItems = exports.isNameOptional = exports.processSingleNode = exports.processConfigurationProperties = exports.processGlobalVariables = exports.handleDeleteOperation = exports.createTypeHandlers = exports.createViewFinder = exports.buildNestedViewPath = exports.isConfigurationHandler = exports.isThemeHandler = exports.isGlobalVariablesHandler = exports.isViewHandler = exports.isSingleNodeHandler = void 0;
|
|
9
|
+
// ─── 类型守卫(跟使用者走) ────────────────────────────────────────────────────
|
|
10
|
+
const isSingleNodeHandler = (handler) => {
|
|
11
|
+
return ['entity', 'structure', 'enum', 'logic', 'authLogicForExportInterface', 'authLogicForCallInterface', 'exportInterface', 'overriddenLogic'].includes(handler.type);
|
|
12
|
+
};
|
|
13
|
+
exports.isSingleNodeHandler = isSingleNodeHandler;
|
|
14
|
+
const isViewHandler = (handler) => {
|
|
15
|
+
return handler.type === 'view';
|
|
16
|
+
};
|
|
17
|
+
exports.isViewHandler = isViewHandler;
|
|
18
|
+
const isGlobalVariablesHandler = (handler) => {
|
|
19
|
+
return ['backendVariables', 'frontendVariables'].includes(handler.type);
|
|
20
|
+
};
|
|
21
|
+
exports.isGlobalVariablesHandler = isGlobalVariablesHandler;
|
|
22
|
+
const isThemeHandler = (handler) => {
|
|
23
|
+
return handler.type === 'theme';
|
|
24
|
+
};
|
|
25
|
+
exports.isThemeHandler = isThemeHandler;
|
|
26
|
+
const isConfigurationHandler = (handler) => {
|
|
27
|
+
return handler.type === 'configuration';
|
|
28
|
+
};
|
|
29
|
+
exports.isConfigurationHandler = isConfigurationHandler;
|
|
30
|
+
// ─── 视图路径构建(diff 阶段使用) ────────────────────────────────────────────
|
|
31
|
+
/**
|
|
32
|
+
* 构建嵌套视图的 NASL 路径
|
|
33
|
+
*/
|
|
34
|
+
const buildNestedViewPath = (parentViewNames, viewName) => {
|
|
35
|
+
const basePath = 'app.frontendTypes[name=pc].frontends[name=pc].views';
|
|
36
|
+
if (!parentViewNames || parentViewNames.length === 0) {
|
|
37
|
+
return `${basePath}[name=${viewName}]`;
|
|
38
|
+
}
|
|
39
|
+
const pathParts = [`${basePath}[name=${parentViewNames[0]}]`];
|
|
40
|
+
for (let i = 1; i < parentViewNames.length; i++) {
|
|
41
|
+
pathParts.push(`children[name=${parentViewNames[i]}]`);
|
|
42
|
+
}
|
|
43
|
+
pathParts.push(`children[name=${viewName}]`);
|
|
44
|
+
return pathParts.join('.');
|
|
45
|
+
};
|
|
46
|
+
exports.buildNestedViewPath = buildNestedViewPath;
|
|
47
|
+
/**
|
|
48
|
+
* 创建视图查找函数
|
|
49
|
+
*/
|
|
50
|
+
const createViewFinder = (instance) => (name, parentViewNames = []) => {
|
|
51
|
+
const viewPath = (0, exports.buildNestedViewPath)(parentViewNames, name);
|
|
52
|
+
return instance?.findNodeByPath(viewPath);
|
|
53
|
+
};
|
|
54
|
+
exports.createViewFinder = createViewFinder;
|
|
55
|
+
// ─── TypeHandler 工厂 ─────────────────────────────────────────────────────────
|
|
56
|
+
/**
|
|
57
|
+
* 创建各类型节点的处理器(工厂函数)
|
|
58
|
+
*/
|
|
59
|
+
const createTypeHandlers = (appInstance, app) => ({
|
|
60
|
+
entity: {
|
|
61
|
+
type: 'entity',
|
|
62
|
+
path: 'app.dataSources[name=defaultDS].entities[0]',
|
|
63
|
+
findMethod: (name) => appInstance?.dataSources?.[0]?.findEntityByName(name),
|
|
64
|
+
findExisting: (name) => app.dataSources?.[0]?.findEntityByName(name),
|
|
65
|
+
},
|
|
66
|
+
structure: {
|
|
67
|
+
type: 'structure',
|
|
68
|
+
path: 'app.structures[0]',
|
|
69
|
+
findMethod: (name) => appInstance?.findStructureByName(name),
|
|
70
|
+
findExisting: (name) => app.findStructureByName(name),
|
|
71
|
+
},
|
|
72
|
+
enum: {
|
|
73
|
+
type: 'enum',
|
|
74
|
+
path: 'app.enums[0]',
|
|
75
|
+
findMethod: (name) => appInstance?.findEnumByName(name),
|
|
76
|
+
findExisting: (name) => app.findEnumByName(name),
|
|
77
|
+
},
|
|
78
|
+
logic: {
|
|
79
|
+
type: 'logic',
|
|
80
|
+
path: 'app.logics[0]',
|
|
81
|
+
findMethod: (name) => appInstance?.findLogicByName(name),
|
|
82
|
+
findExisting: (name) => app.findLogicByName(name),
|
|
83
|
+
},
|
|
84
|
+
authLogicForExportInterface: {
|
|
85
|
+
type: 'authLogicForExportInterface',
|
|
86
|
+
path: 'app.authLogics[0]',
|
|
87
|
+
findMethod: (name) => appInstance?.authLogics?.find((l) => l.name === name),
|
|
88
|
+
findExisting: (name) => app.authLogics?.find((l) => l.name === name),
|
|
89
|
+
},
|
|
90
|
+
authLogicForCallInterface: {
|
|
91
|
+
type: 'authLogicForCallInterface',
|
|
92
|
+
path: 'app.authLogicsForCallInterface[0]',
|
|
93
|
+
findMethod: (name) => appInstance?.authLogicsForCallInterface?.find((l) => l.name === name),
|
|
94
|
+
findExisting: (name) => app.authLogicsForCallInterface?.find((l) => l.name === name),
|
|
95
|
+
},
|
|
96
|
+
exportInterface: {
|
|
97
|
+
type: 'exportInterface',
|
|
98
|
+
path: 'app.interfaces[0]',
|
|
99
|
+
findMethod: (name) => appInstance?.interfaces?.find((i) => i.name === name),
|
|
100
|
+
findExisting: (name) => app.interfaces?.find((i) => i.name === name),
|
|
101
|
+
},
|
|
102
|
+
overriddenLogic: {
|
|
103
|
+
type: 'overriddenLogic',
|
|
104
|
+
path: 'app.overriddenLogics[0]',
|
|
105
|
+
findMethod: (compositeKey) => {
|
|
106
|
+
const dotIdx = compositeKey.indexOf('.');
|
|
107
|
+
const module = dotIdx >= 0 ? compositeKey.slice(0, dotIdx) : '';
|
|
108
|
+
const name = dotIdx >= 0 ? compositeKey.slice(dotIdx + 1) : compositeKey;
|
|
109
|
+
return appInstance?.overriddenLogics?.find((l) => l.overriddenModule === module && l.name === name);
|
|
110
|
+
},
|
|
111
|
+
findExisting: (compositeKey) => {
|
|
112
|
+
const dotIdx = compositeKey.indexOf('.');
|
|
113
|
+
const module = dotIdx >= 0 ? compositeKey.slice(0, dotIdx) : '';
|
|
114
|
+
const name = dotIdx >= 0 ? compositeKey.slice(dotIdx + 1) : compositeKey;
|
|
115
|
+
return app.overriddenLogics?.find((l) => l.overriddenModule === module && l.name === name);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
view: {
|
|
119
|
+
type: 'view',
|
|
120
|
+
path: 'app.frontendTypes[name=pc].frontends[name=pc].views[0]',
|
|
121
|
+
findMethod: (0, exports.createViewFinder)(appInstance),
|
|
122
|
+
findExisting: (0, exports.createViewFinder)(app),
|
|
123
|
+
},
|
|
124
|
+
backendVariables: {
|
|
125
|
+
type: 'backendVariables',
|
|
126
|
+
path: 'app.backend.variables[0]',
|
|
127
|
+
findMethod: (name) => {
|
|
128
|
+
if (!name)
|
|
129
|
+
return appInstance?.backend;
|
|
130
|
+
return appInstance?.findNodeByPath(`app.backend.variables[name=${name}]`);
|
|
131
|
+
},
|
|
132
|
+
findExisting: (name) => {
|
|
133
|
+
if (!name)
|
|
134
|
+
return app.backend;
|
|
135
|
+
return app.findNodeByPath(`app.backend.variables[name=${name}]`);
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
frontendVariables: {
|
|
139
|
+
type: 'frontendVariables',
|
|
140
|
+
path: 'app.frontendTypes[name=pc].frontends[name=pc].variables[0]',
|
|
141
|
+
findMethod: (name) => {
|
|
142
|
+
if (!name)
|
|
143
|
+
return appInstance?.frontendTypes?.[0]?.frontends?.[0];
|
|
144
|
+
return appInstance?.findNodeByPath(`app.frontendTypes[name=pc].frontends[name=pc].variables[name=${name}]`);
|
|
145
|
+
},
|
|
146
|
+
findExisting: (name) => {
|
|
147
|
+
if (!name)
|
|
148
|
+
return app.frontendTypes?.[0]?.frontends?.[0];
|
|
149
|
+
return app.findNodeByPath(`app.frontendTypes[name=pc].frontends[name=pc].variables[name=${name}]`);
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
theme: {
|
|
153
|
+
type: 'theme',
|
|
154
|
+
path: 'app.frontendTypes[name=pc].frontends[name=pc].theme',
|
|
155
|
+
findMethod: () => appInstance?.frontendTypes?.[0]?.frontends?.[0]?.theme,
|
|
156
|
+
findExisting: () => app.frontendTypes?.[0]?.frontends?.[0]?.theme,
|
|
157
|
+
},
|
|
158
|
+
configuration: {
|
|
159
|
+
type: 'configuration',
|
|
160
|
+
path: (groupName) => `app.configuration.groups[name=${groupName}].properties[0]`,
|
|
161
|
+
findMethod: (groupName, propName) => {
|
|
162
|
+
const group = appInstance?.configuration?.groups?.find((g) => g.name === groupName);
|
|
163
|
+
if (!propName)
|
|
164
|
+
return group;
|
|
165
|
+
return group?.properties?.find((p) => p.name === propName);
|
|
166
|
+
},
|
|
167
|
+
findExisting: (groupName, propName) => {
|
|
168
|
+
const group = app.configuration?.groups?.find((g) => g.name === groupName);
|
|
169
|
+
if (!propName)
|
|
170
|
+
return group;
|
|
171
|
+
return group?.properties?.find((p) => p.name === propName);
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
exports.createTypeHandlers = createTypeHandlers;
|
|
176
|
+
// ─── 节点操作函数 ─────────────────────────────────────────────────────────────
|
|
177
|
+
/**
|
|
178
|
+
* 通用删除操作处理
|
|
179
|
+
*/
|
|
180
|
+
const handleDeleteOperation = (params) => {
|
|
181
|
+
const { handler, itemName, itemType, batchActions, errors, parentViewNames, errorMessageTemplate = `要删除的对象不存在: ${itemName}`, } = params;
|
|
182
|
+
let existingNode;
|
|
183
|
+
if ((0, exports.isViewHandler)(handler)) {
|
|
184
|
+
existingNode = handler.findExisting(itemName, parentViewNames);
|
|
185
|
+
}
|
|
186
|
+
else if ((0, exports.isSingleNodeHandler)(handler)) {
|
|
187
|
+
existingNode = handler.findExisting(itemName);
|
|
188
|
+
}
|
|
189
|
+
else if ((0, exports.isGlobalVariablesHandler)(handler)) {
|
|
190
|
+
existingNode = handler.findExisting(itemName);
|
|
191
|
+
}
|
|
192
|
+
if (existingNode) {
|
|
193
|
+
batchActions.actions.push({ action: 'delete', path: existingNode.nodePath, object: null });
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
errors.push({ item: itemName, type: itemType, error: new Error(errorMessageTemplate), level: 1 });
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
exports.handleDeleteOperation = handleDeleteOperation;
|
|
200
|
+
/**
|
|
201
|
+
* 处理变量创建或更新操作
|
|
202
|
+
*/
|
|
203
|
+
const handleVariableCreateOrUpdate = (handler, variable, variableName, batchActions) => {
|
|
204
|
+
const existingVar = handler.findExisting(variableName);
|
|
205
|
+
const variableObject = variable.toJSON();
|
|
206
|
+
if (existingVar) {
|
|
207
|
+
batchActions.actions.push({ action: 'update', path: existingVar.nodePath, object: variableObject });
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
batchActions.actions.push({ action: 'create', path: handler.path, object: variableObject });
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* 处理全局变量类型(一个文件对应多个节点)
|
|
215
|
+
*/
|
|
216
|
+
const processGlobalVariables = (params) => {
|
|
217
|
+
const { handler, action, itemType, batchActions, errors } = params;
|
|
218
|
+
const RESERVED_VARIABLES = new Set(['httpRequest', 'httpResponse', 'currentUser']);
|
|
219
|
+
const container = handler.findMethod();
|
|
220
|
+
if (!container || !container.variables) {
|
|
221
|
+
errors.push({
|
|
222
|
+
item: itemType,
|
|
223
|
+
type: itemType,
|
|
224
|
+
error: new Error(`未找到${itemType}容器或variables属性`),
|
|
225
|
+
level: 2,
|
|
226
|
+
});
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (action === 'delete') {
|
|
230
|
+
for (const variable of container.variables) {
|
|
231
|
+
const variableName = variable.name;
|
|
232
|
+
if (!variableName || RESERVED_VARIABLES.has(variableName))
|
|
233
|
+
continue;
|
|
234
|
+
try {
|
|
235
|
+
(0, exports.handleDeleteOperation)({
|
|
236
|
+
handler,
|
|
237
|
+
itemName: variableName,
|
|
238
|
+
itemType,
|
|
239
|
+
batchActions,
|
|
240
|
+
errors,
|
|
241
|
+
errorMessageTemplate: `要删除的变量不存在: ${variableName}`,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
errors.push({ item: variableName, type: itemType, error: error, level: 3 });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const existingContainer = handler.findExisting();
|
|
251
|
+
const newVariableNames = existingContainer?.variables ? new Set() : null;
|
|
252
|
+
for (const variable of container.variables) {
|
|
253
|
+
const variableName = variable.name;
|
|
254
|
+
if (!variableName || RESERVED_VARIABLES.has(variableName))
|
|
255
|
+
continue;
|
|
256
|
+
newVariableNames?.add(variableName);
|
|
257
|
+
try {
|
|
258
|
+
handleVariableCreateOrUpdate(handler, variable, variableName, batchActions);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
errors.push({ item: variableName, type: itemType, error: error, level: 3 });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (existingContainer?.variables && newVariableNames) {
|
|
265
|
+
for (const existingVariable of existingContainer.variables) {
|
|
266
|
+
const existingVariableName = existingVariable.name;
|
|
267
|
+
if (!existingVariableName ||
|
|
268
|
+
RESERVED_VARIABLES.has(existingVariableName) ||
|
|
269
|
+
newVariableNames.has(existingVariableName)) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
(0, exports.handleDeleteOperation)({
|
|
274
|
+
handler,
|
|
275
|
+
itemName: existingVariableName,
|
|
276
|
+
itemType,
|
|
277
|
+
batchActions,
|
|
278
|
+
errors,
|
|
279
|
+
errorMessageTemplate: `要删除的变量不存在: ${existingVariableName}`,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
errors.push({ item: existingVariableName, type: itemType, error: error, level: 3 });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
exports.processGlobalVariables = processGlobalVariables;
|
|
289
|
+
/**
|
|
290
|
+
* 处理配置类型(一个文件对应多个 ConfigProperty 节点)
|
|
291
|
+
*/
|
|
292
|
+
const processConfigurationProperties = (params) => {
|
|
293
|
+
const { handler, groupName, action, itemType, batchActions, errors } = params;
|
|
294
|
+
const group = handler.findMethod(groupName);
|
|
295
|
+
if (!group || !group.properties) {
|
|
296
|
+
errors.push({
|
|
297
|
+
item: groupName,
|
|
298
|
+
type: itemType,
|
|
299
|
+
error: new Error(`未找到配置组 ${groupName} 或其 properties 属性`),
|
|
300
|
+
level: 2,
|
|
301
|
+
});
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (action === 'delete') {
|
|
305
|
+
for (const prop of group.properties) {
|
|
306
|
+
const existingProp = handler.findExisting(groupName, prop.name);
|
|
307
|
+
if (existingProp) {
|
|
308
|
+
batchActions.actions.push({ action: 'delete', path: existingProp.nodePath, object: null });
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
errors.push({
|
|
312
|
+
item: prop.name,
|
|
313
|
+
type: itemType,
|
|
314
|
+
error: new Error(`要删除的配置属性不存在: ${prop.name}`),
|
|
315
|
+
level: 1,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const existingGroup = handler.findExisting(groupName);
|
|
322
|
+
const newPropNames = existingGroup?.properties ? new Set() : null;
|
|
323
|
+
for (const prop of group.properties) {
|
|
324
|
+
newPropNames?.add(prop.name);
|
|
325
|
+
try {
|
|
326
|
+
const existingProp = handler.findExisting(groupName, prop.name);
|
|
327
|
+
const propObject = prop.toJSON();
|
|
328
|
+
if (existingProp) {
|
|
329
|
+
batchActions.actions.push({ action: 'update', path: existingProp.nodePath, object: propObject });
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
batchActions.actions.push({ action: 'create', path: handler.path(groupName), object: propObject });
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
errors.push({ item: prop.name, type: itemType, error: error, level: 3 });
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (existingGroup?.properties && newPropNames) {
|
|
340
|
+
for (const existingProp of existingGroup.properties) {
|
|
341
|
+
if (newPropNames.has(existingProp.name))
|
|
342
|
+
continue;
|
|
343
|
+
try {
|
|
344
|
+
batchActions.actions.push({ action: 'delete', path: existingProp.nodePath, object: null });
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
errors.push({ item: existingProp.name, type: itemType, error: error, level: 3 });
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
exports.processConfigurationProperties = processConfigurationProperties;
|
|
353
|
+
/**
|
|
354
|
+
* 计算 view 类型的路径
|
|
355
|
+
*/
|
|
356
|
+
const calculateViewPath = (naslObject) => {
|
|
357
|
+
let type = 'views';
|
|
358
|
+
if (naslObject.parentNode?.concept === 'View')
|
|
359
|
+
type = 'children';
|
|
360
|
+
const parentChildren = naslObject.parentNode?.[type] || [];
|
|
361
|
+
const childIndex = parentChildren.findIndex((child) => child === naslObject);
|
|
362
|
+
const index = childIndex !== -1 ? childIndex : 0;
|
|
363
|
+
return `${naslObject.parentNode.nodePath}.${type}[${index}]`;
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* 处理 view 类型的 children 属性
|
|
367
|
+
*/
|
|
368
|
+
const handleViewChildren = (object, action) => {
|
|
369
|
+
if (action === 'create') {
|
|
370
|
+
object.children = [];
|
|
371
|
+
}
|
|
372
|
+
else if (action === 'update' && object.children) {
|
|
373
|
+
delete object.children;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* 处理单节点创建或更新操作
|
|
378
|
+
*/
|
|
379
|
+
const handleSingleNodeCreateOrUpdate = (handler, itemName, itemType, parentViewNames, batchActions, errors) => {
|
|
380
|
+
let naslObject;
|
|
381
|
+
if ((0, exports.isViewHandler)(handler)) {
|
|
382
|
+
naslObject = handler.findMethod(itemName, parentViewNames);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
naslObject = handler.findMethod(itemName);
|
|
386
|
+
}
|
|
387
|
+
if (!naslObject) {
|
|
388
|
+
errors.push({
|
|
389
|
+
item: itemName,
|
|
390
|
+
type: itemType,
|
|
391
|
+
error: new Error(`未找到对应的 NASL 对象: ${handler.path} - ${itemName}`),
|
|
392
|
+
level: 2,
|
|
393
|
+
});
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
let finalAction = 'create';
|
|
397
|
+
let path = '';
|
|
398
|
+
let object = naslObject.toJSON();
|
|
399
|
+
if (itemType === 'view' && naslObject.parentNode) {
|
|
400
|
+
path = calculateViewPath(naslObject);
|
|
401
|
+
}
|
|
402
|
+
let existingNode;
|
|
403
|
+
if ((0, exports.isViewHandler)(handler)) {
|
|
404
|
+
existingNode = handler.findExisting(itemName, parentViewNames);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
existingNode = handler.findExisting(itemName);
|
|
408
|
+
}
|
|
409
|
+
if (existingNode) {
|
|
410
|
+
finalAction = 'update';
|
|
411
|
+
path = existingNode.nodePath;
|
|
412
|
+
}
|
|
413
|
+
if (itemType === 'view') {
|
|
414
|
+
handleViewChildren(object, finalAction);
|
|
415
|
+
}
|
|
416
|
+
batchActions.actions.push({ action: finalAction, path: path || handler.path, object });
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* 处理单节点类型(一个文件对应一个节点)
|
|
420
|
+
*/
|
|
421
|
+
const processSingleNode = (params) => {
|
|
422
|
+
const { handler, itemName, itemType, action, parentViewNames, batchActions, errors } = params;
|
|
423
|
+
if (action === 'delete') {
|
|
424
|
+
(0, exports.handleDeleteOperation)({
|
|
425
|
+
handler,
|
|
426
|
+
itemName,
|
|
427
|
+
itemType,
|
|
428
|
+
batchActions,
|
|
429
|
+
errors,
|
|
430
|
+
parentViewNames,
|
|
431
|
+
errorMessageTemplate: `要删除的对象不存在: ${handler.path} - ${itemName}`,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
handleSingleNodeCreateOrUpdate(handler, itemName, itemType, parentViewNames, batchActions, errors);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
exports.processSingleNode = processSingleNode;
|
|
439
|
+
// ─── 节点遍历主循环(diff 阶段入口) ─────────────────────────────────────────
|
|
440
|
+
/**
|
|
441
|
+
* 检查项目类型是否允许空名称
|
|
442
|
+
*/
|
|
443
|
+
const isNameOptional = (itemType) => {
|
|
444
|
+
return ['backendVariables', 'frontendVariables', 'theme'].includes(itemType);
|
|
445
|
+
};
|
|
446
|
+
exports.isNameOptional = isNameOptional;
|
|
447
|
+
/**
|
|
448
|
+
* 遍历 itemTypes,为每个节点生成对应的 BatchAction
|
|
449
|
+
*/
|
|
450
|
+
const processNodeItems = (appInstance, app, itemTypes, batchActions, errors) => {
|
|
451
|
+
const typeHandlers = (0, exports.createTypeHandlers)(appInstance, app);
|
|
452
|
+
const deletedViewNames = new Set(itemTypes
|
|
453
|
+
.filter(({ type, action }) => type === 'view' && action === 'delete')
|
|
454
|
+
.map(({ name }) => name));
|
|
455
|
+
for (const { type: itemType, name: itemName, action, parentViewNames } of itemTypes) {
|
|
456
|
+
if (itemType === 'unknown' || (!(0, exports.isNameOptional)(itemType) && !itemName))
|
|
457
|
+
continue;
|
|
458
|
+
if (itemType === 'view' &&
|
|
459
|
+
action === 'delete' &&
|
|
460
|
+
parentViewNames?.some((p) => deletedViewNames.has(p))) {
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
try {
|
|
464
|
+
const handler = typeHandlers[itemType];
|
|
465
|
+
if (!handler)
|
|
466
|
+
continue;
|
|
467
|
+
if ((0, exports.isThemeHandler)(handler)) {
|
|
468
|
+
const naslObject = handler.findMethod();
|
|
469
|
+
if (naslObject) {
|
|
470
|
+
const existingNode = handler.findExisting();
|
|
471
|
+
batchActions.actions.push({
|
|
472
|
+
action: 'update',
|
|
473
|
+
path: existingNode?.nodePath || handler.path,
|
|
474
|
+
object: {
|
|
475
|
+
...existingNode.toJSON(),
|
|
476
|
+
scopeVariableMap: naslObject.scopeVariableMap,
|
|
477
|
+
cssRules: naslObject.cssRules,
|
|
478
|
+
},
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else if ((0, exports.isGlobalVariablesHandler)(handler)) {
|
|
483
|
+
(0, exports.processGlobalVariables)({ handler, action, itemType, batchActions, errors });
|
|
484
|
+
}
|
|
485
|
+
else if ((0, exports.isConfigurationHandler)(handler)) {
|
|
486
|
+
(0, exports.processConfigurationProperties)({ handler, groupName: itemName, action, itemType, batchActions, errors });
|
|
487
|
+
}
|
|
488
|
+
else if ((0, exports.isViewHandler)(handler) || (0, exports.isSingleNodeHandler)(handler)) {
|
|
489
|
+
(0, exports.processSingleNode)({ handler, itemName, itemType, action, parentViewNames, batchActions, errors });
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
catch (error) {
|
|
493
|
+
errors.push({ item: itemName, type: itemType, error: error, level: 3 });
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
exports.processNodeItems = processNodeItems;
|
|
498
|
+
//# sourceMappingURL=nodes.js.map
|