@lcap/nasl 3.7.3-beta.1 → 3.8.0-beta.2
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 +0 -1
- package/out/automate/engine/utils.js +6 -1
- package/out/automate/engine/utils.js.map +1 -1
- package/out/bak/translator.js +37 -0
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/shared/utils.d.ts +1 -0
- package/out/breakpoint/shared/utils.js +1 -1
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/BaseNode.d.ts +11 -0
- package/out/common/BaseNode.js +101 -5
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/Annotatable__.d.ts +109 -0
- package/out/concepts/Annotatable__.js +161 -0
- package/out/concepts/Annotatable__.js.map +1 -0
- package/out/concepts/AnnotationProperty__.d.ts +48 -0
- package/out/concepts/AnnotationProperty__.js +74 -0
- package/out/concepts/AnnotationProperty__.js.map +1 -0
- package/out/concepts/Annotation__.d.ts +128 -0
- package/out/concepts/Annotation__.js +248 -0
- package/out/concepts/Annotation__.js.map +1 -0
- package/out/concepts/App__.d.ts +14 -26
- package/out/concepts/App__.js +50 -20
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/ApplyAnnotation__.d.ts +87 -0
- package/out/concepts/ApplyAnnotation__.js +140 -0
- package/out/concepts/ApplyAnnotation__.js.map +1 -0
- package/out/concepts/Argument__.d.ts +19 -0
- package/out/concepts/Argument__.js +126 -0
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/AssigneeV2__.d.ts +169 -0
- package/out/concepts/AssigneeV2__.js +176 -1
- package/out/concepts/AssigneeV2__.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/AuthLogic__.js +1 -1
- package/out/concepts/AuthLogic__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +1 -0
- package/out/concepts/BooleanLiteral__.js +9 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +1 -1
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallFunction__.js +1 -1
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +15 -0
- package/out/concepts/CallLogic__.js +149 -17
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/ConnectorLogic__.js +1 -1
- package/out/concepts/ConnectorLogic__.js.map +1 -1
- package/out/concepts/DatabaseTypeAnnotation__.d.ts +0 -2
- package/out/concepts/DatabaseTypeAnnotation__.js +0 -20
- package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
- package/out/concepts/DepartmentManagerV2__.d.ts +29 -0
- package/out/concepts/DepartmentManagerV2__.js +56 -0
- package/out/concepts/DepartmentManagerV2__.js.map +1 -0
- package/out/concepts/DepartmentV2__.d.ts +33 -0
- package/out/concepts/DepartmentV2__.js +63 -0
- package/out/concepts/DepartmentV2__.js.map +1 -0
- package/out/concepts/DirectManagerV2__.d.ts +25 -0
- package/out/concepts/DirectManagerV2__.js +53 -0
- package/out/concepts/DirectManagerV2__.js.map +1 -0
- package/out/concepts/End__.js +9 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +0 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +2 -2
- package/out/concepts/Entity__.js +4 -7
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +1 -12
- package/out/concepts/EnumItem__.js +17 -49
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/EnumSelectSetter__.d.ts +4 -0
- package/out/concepts/EnumSelectSetter__.js +7 -0
- package/out/concepts/EnumSelectSetter__.js.map +1 -1
- package/out/concepts/Enum__.js +1 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +1 -1
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +52 -48
- package/out/concepts/FrontendLibrary__.js +45 -36
- package/out/concepts/FrontendLibrary__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +4 -0
- package/out/concepts/FrontendType__.js +7 -0
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -0
- package/out/concepts/Frontend__.js +21 -2
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/HistoryProcessV2__.js +4 -1
- package/out/concepts/HistoryProcessV2__.js.map +1 -1
- package/out/concepts/I18nInfo__.d.ts +0 -1
- package/out/concepts/I18nInfo__.js +0 -7
- package/out/concepts/I18nInfo__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +2 -0
- package/out/concepts/Identifier__.js +31 -0
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +1 -4
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +16 -1
- package/out/concepts/Logic__.js +133 -15
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/ManagerV2__.d.ts +34 -0
- package/out/concepts/ManagerV2__.js +61 -0
- package/out/concepts/ManagerV2__.js.map +1 -0
- package/out/concepts/MatchCase__.d.ts +2 -2
- package/out/concepts/MatchCase__.js +7 -7
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -0
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +88 -0
- package/out/concepts/Module__.js +85 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/OperatePermissionV2__.d.ts +1 -1
- package/out/concepts/OperatePermissionV2__.js.map +1 -1
- package/out/concepts/Param__.d.ts +4 -0
- package/out/concepts/Param__.js +13 -21
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElementV2__.d.ts +6 -1
- package/out/concepts/ProcessElementV2__.js +20 -0
- package/out/concepts/ProcessElementV2__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +7 -0
- package/out/concepts/ProcessElement__.js +47 -0
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessV2__.d.ts +1 -34
- package/out/concepts/ProcessV2__.js +3 -70
- package/out/concepts/ProcessV2__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +2 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +2 -2
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/StaticString__.d.ts +0 -4
- package/out/concepts/StaticString__.js +0 -11
- package/out/concepts/StaticString__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +1 -0
- package/out/concepts/StructureProperty__.js +14 -5
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +4 -0
- package/out/concepts/Structure__.js +6 -9
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SubLogic__.d.ts +418 -0
- package/out/concepts/SubLogic__.js +992 -0
- package/out/concepts/SubLogic__.js.map +1 -0
- package/out/concepts/Theme__.d.ts +9 -0
- package/out/concepts/Theme__.js +10 -0
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.d.ts +0 -1
- package/out/concepts/Transactional__.js +0 -7
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +18 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +1 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +6 -1
- package/out/concepts/ValidationRule__.js +6 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +8 -2
- package/out/concepts/ViewElement__.js +213 -32
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +10 -2
- package/out/concepts/View__.js +129 -17
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.processV2.js +50 -4
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -1
- package/out/concepts/basics/types/index.js +2 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +9 -0
- package/out/concepts/index__.js +9 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +409 -0
- package/out/concepts/utils/asserts.js +564 -14
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +33 -2
- package/out/generator/genBundleFiles.d.ts +13 -9
- package/out/generator/genBundleFiles.js +383 -63
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +2 -0
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/release-body/body.js +1 -0
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/utils.d.ts +15 -7
- package/out/generator/release-body/utils.js +50 -7
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/natural/genNaturalTS.js +2 -4
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/index.js +0 -2
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.d.ts +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +9 -0
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +10 -6
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +6 -0
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcessesV2.d.ts +3 -2
- package/out/server/getProcessesV2.js +15 -6
- package/out/server/getProcessesV2.js.map +1 -1
- package/out/server/naslServer.d.ts +5 -1
- package/out/server/naslServer.js +120 -30
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +4 -0
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.d.ts +2 -1
- package/out/service/storage/init.js +28 -71
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.d.ts +6 -2
- package/out/templator/genCreateBlock.js +25 -8
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.d.ts +22 -0
- package/out/templator/genCurdEditMultipleKeyBlock.js +60 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.d.ts +13 -3
- package/out/templator/genCurdMultipleKeyBlock.js +29 -23
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.d.ts +1 -1
- package/out/templator/genGetBlock.js +3 -2
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genListViewBlock.d.ts +1 -1
- package/out/templator/genListViewBlock.js +3 -2
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.d.ts +1 -1
- package/out/templator/genSelectBlock.js +3 -2
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +9 -4
- package/out/templator/genTableBlock.js +31 -17
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.d.ts +2 -2
- package/out/templator/genUpdateBlock.js +11 -11
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/translator/types.d.ts +0 -4
- package/out/translator/utils.d.ts +0 -1
- package/out/translator/utils.js +1 -6
- package/out/translator/utils.js.map +1 -1
- package/out/utils/delay/index.d.ts +0 -0
- package/out/utils/delay/index.js +1 -0
- package/out/utils/delay/index.js.map +1 -0
- package/out/utils/env.d.ts +0 -4
- package/out/utils/env.js +3 -6
- package/out/utils/env.js.map +1 -1
- package/out/utils/index.d.ts +3 -2
- package/out/utils/index.js +18 -14
- package/out/utils/index.js.map +1 -1
- package/out/utils/time-slicing/controller.js.map +1 -1
- package/out/utils/types.d.ts +0 -17
- package/package.json +27 -20
- package/sandbox/stdlib/extension.component.ts +29 -0
- package/sandbox/stdlib/nasl.process.ts +17 -0
- package/sandbox/stdlib/nasl.processV2.ts +10 -5
- package/sandbox/stdlib/nasl.util.ts +3 -1
- package/src/automate/engine/utils.js +7 -2
- package/src/bak/translator.js +42 -1
- package/src/breakpoint/shared/utils.ts +2 -1
- package/src/common/BaseNode.ts +117 -5
- package/src/concepts/Annotatable__.ts +263 -0
- package/src/concepts/AnnotationProperty__.ts +102 -0
- package/src/concepts/Annotation__.ts +344 -0
- package/src/concepts/App__.ts +917 -26
- package/src/concepts/ApplyAnnotation__.ts +198 -0
- package/src/concepts/Argument__.ts +145 -1
- package/src/concepts/AssigneeV2__.ts +387 -1
- package/src/concepts/AuthLogicForCallInterface__.ts +1 -1
- package/src/concepts/AuthLogic__.ts +1 -1
- package/src/concepts/BooleanLiteral__.ts +9 -1
- package/src/concepts/BusinessLogic__.ts +1 -1
- package/src/concepts/CallFunction__.ts +1 -1
- package/src/concepts/CallLogic__.ts +153 -16
- package/src/concepts/ConnectorLogic__.ts +1 -1
- package/src/concepts/DatabaseTypeAnnotation__.ts +0 -11
- package/src/concepts/DepartmentManagerV2__.ts +70 -0
- package/src/concepts/DepartmentV2__.ts +75 -0
- package/src/concepts/DirectManagerV2__.ts +65 -0
- package/src/concepts/End__.ts +10 -1
- package/src/concepts/EntityProperty__.ts +0 -5
- package/src/concepts/Entity__.ts +5 -9
- package/src/concepts/EnumItem__.ts +16 -65
- package/src/concepts/EnumSelectSetter__.ts +6 -0
- package/src/concepts/Enum__.ts +1 -6
- package/src/concepts/ForEachStatement__.ts +1 -1
- package/src/concepts/FrontendLibrary__.ts +88 -80
- package/src/concepts/FrontendType__.ts +6 -0
- package/src/concepts/Frontend__.ts +26 -3
- package/src/concepts/HistoryProcessV2__.ts +5 -0
- package/src/concepts/I18nInfo__.ts +0 -5
- package/src/concepts/Identifier__.ts +32 -0
- package/src/concepts/IfStatement__.ts +2 -2
- package/src/concepts/Interface__.ts +1 -6
- package/src/concepts/LogicItem__.ts +1 -0
- package/src/concepts/Logic__.ts +140 -17
- package/src/concepts/ManagerV2__.ts +78 -0
- package/src/concepts/MatchCase__.ts +9 -8
- package/src/concepts/MemberExpression__.ts +1 -0
- package/src/concepts/Module__.ts +194 -0
- package/src/concepts/OperatePermissionV2__.ts +1 -1
- package/src/concepts/Param__.ts +17 -20
- package/src/concepts/ProcessElementV2__.ts +23 -0
- package/src/concepts/ProcessElement__.ts +18 -0
- package/src/concepts/ProcessV2__.ts +4 -70
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/StaticString__.ts +0 -13
- package/src/concepts/StructureProperty__.ts +16 -7
- package/src/concepts/Structure__.ts +10 -11
- package/src/concepts/SubLogic__.ts +1516 -0
- package/src/concepts/Theme__.ts +9 -0
- package/src/concepts/Transactional__.ts +0 -5
- package/src/concepts/TriggerLauncher__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +17 -0
- package/src/concepts/TypeParam__.ts +3 -0
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/ViewElement__.ts +224 -34
- package/src/concepts/View__.ts +135 -22
- package/src/concepts/basics/stdlib/nasl.processV2.ts +56 -3
- package/src/concepts/basics/types/index.ts +1 -1
- package/src/concepts/index__.ts +9 -0
- package/src/concepts/utils/asserts.ts +595 -0
- package/src/concepts/utils/types.ts +53 -0
- package/src/generator/genBundleFiles.ts +408 -68
- package/src/generator/genMetaData.ts +3 -0
- package/src/generator/release-body/body.ts +1 -0
- package/src/generator/release-body/utils.ts +159 -55
- package/src/natural/genNaturalTS.ts +3 -5
- package/src/natural/getContext/index.ts +0 -2
- package/src/natural/transformTS2UI.ts +5 -2
- package/src/natural/transformTSCode.ts +2 -2
- package/src/server/extendBaseNode.ts +11 -2
- package/src/server/getLogics.ts +9 -7
- package/src/server/getMemberIdentifier.ts +7 -0
- package/src/server/getProcessesV2.ts +16 -6
- package/src/server/naslServer.ts +133 -30
- package/src/server/translator.ts +4 -0
- package/src/service/storage/init.ts +52 -97
- package/src/templator/genCreateBlock.ts +35 -14
- package/src/templator/genCurdEditMultipleKeyBlock.ts +65 -1
- package/src/templator/genCurdMultipleKeyBlock.ts +42 -23
- package/src/templator/genGetBlock.ts +4 -3
- package/src/templator/genListViewBlock.ts +3 -3
- package/src/templator/genSelectBlock.ts +4 -2
- package/src/templator/genTableBlock.ts +32 -17
- package/src/templator/genUpdateBlock.ts +21 -18
- package/src/translator/types.ts +0 -4
- package/src/translator/utils.ts +0 -6
- package/src/utils/delay/index.ts +0 -0
- package/src/utils/env.ts +4 -5
- package/src/utils/index.ts +16 -4
- package/src/utils/time-slicing/controller.ts +1 -0
- package/src/utils/types.ts +0 -20
- package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +2 -1
- package/ts-worker/bundle.js +1 -1
- package/ts-worker/src/index.js +1 -0
- package/out/utils/language-cache/constant.d.ts +0 -18
- package/out/utils/language-cache/constant.js +0 -35
- package/out/utils/language-cache/constant.js.map +0 -1
- package/out/utils/language-cache/index.d.ts +0 -2
- package/out/utils/language-cache/index.js +0 -19
- package/out/utils/language-cache/index.js.map +0 -1
- package/out/utils/language-cache/nasl.d.ts +0 -10
- package/out/utils/language-cache/nasl.js +0 -98
- package/out/utils/language-cache/nasl.js.map +0 -1
- package/out/utils/language-cache/types.d.ts +0 -44
- package/out/utils/language-cache/types.js +0 -4
- package/out/utils/language-cache/types.js.map +0 -1
- package/src/utils/language-cache/constant.ts +0 -37
- package/src/utils/language-cache/index.ts +0 -2
- package/src/utils/language-cache/nasl.ts +0 -83
- package/src/utils/language-cache/types.ts +0 -48
package/src/server/naslServer.ts
CHANGED
|
@@ -99,6 +99,7 @@ import {
|
|
|
99
99
|
FrontendType,
|
|
100
100
|
InterfaceParam,
|
|
101
101
|
ProcessBindV2,
|
|
102
|
+
SubLogic,
|
|
102
103
|
} from '../concepts';
|
|
103
104
|
|
|
104
105
|
import * as utils from '../utils';
|
|
@@ -398,8 +399,14 @@ class NaslServer {
|
|
|
398
399
|
this.worker.terminate();
|
|
399
400
|
}
|
|
400
401
|
|
|
401
|
-
async createUiTs(components: any,
|
|
402
|
-
|
|
402
|
+
async createUiTs(components: any, optinos: {
|
|
403
|
+
basicUITsCode: string,
|
|
404
|
+
withTypeLibraryTsCode: string,
|
|
405
|
+
standardUIComponents: Record<string, any>
|
|
406
|
+
}) {
|
|
407
|
+
const {
|
|
408
|
+
standardUIComponents, // 标准组件(带有ts类型定义文件的组件)
|
|
409
|
+
} = optinos;
|
|
403
410
|
|
|
404
411
|
Object.assign(allComponent, components)
|
|
405
412
|
const { code, elementsLogic } = await formatUiTs(allComponent);
|
|
@@ -437,17 +444,27 @@ class NaslServer {
|
|
|
437
444
|
);
|
|
438
445
|
|
|
439
446
|
// 添加基础组件的方法到elementsLogic
|
|
440
|
-
Object.assign(elementsLogic, createEleLogins(
|
|
447
|
+
Object.assign(elementsLogic, createEleLogins(standardUIComponents));
|
|
441
448
|
|
|
442
449
|
// 基础组件
|
|
443
450
|
await this.addFile(
|
|
444
451
|
{
|
|
445
452
|
file: 'nasl.ui.component.ts',
|
|
446
|
-
fileContent:
|
|
453
|
+
fileContent: optinos.basicUITsCode,
|
|
454
|
+
},
|
|
455
|
+
{ cache: true }
|
|
456
|
+
)
|
|
457
|
+
|
|
458
|
+
// 带有类型的依赖库组件
|
|
459
|
+
await this.addFile(
|
|
460
|
+
{
|
|
461
|
+
file: 'extension.component.ts',
|
|
462
|
+
fileContent: optinos.withTypeLibraryTsCode,
|
|
447
463
|
},
|
|
448
464
|
{ cache: true }
|
|
449
465
|
)
|
|
450
466
|
|
|
467
|
+
// 内置标准库类型
|
|
451
468
|
Object.keys(naslStdlibMap).forEach(async (libFileName: string) => {
|
|
452
469
|
await this.addFile(
|
|
453
470
|
{
|
|
@@ -457,6 +474,7 @@ class NaslServer {
|
|
|
457
474
|
{ cache: true }
|
|
458
475
|
);
|
|
459
476
|
});
|
|
477
|
+
|
|
460
478
|
this.elementsLogic = elementsLogic;
|
|
461
479
|
}
|
|
462
480
|
|
|
@@ -481,7 +499,7 @@ class NaslServer {
|
|
|
481
499
|
node.sourceMap = result.sourceMap;
|
|
482
500
|
self.file2NodeMap.set(result.filePath, node);
|
|
483
501
|
} catch (err) {
|
|
484
|
-
if (
|
|
502
|
+
if (process.env.NODE_ENV === 'development') {
|
|
485
503
|
self.logger.warn(node.nodePath ? node.nodePath : name, '代码转换失败', err);
|
|
486
504
|
}
|
|
487
505
|
}
|
|
@@ -747,9 +765,7 @@ class NaslServer {
|
|
|
747
765
|
try {
|
|
748
766
|
await Promise.all(openFiles.map(async (file) => fs.outputFile(path.join(__dirname, '../debug/apps', app.id, file.file), file.fileContent)));
|
|
749
767
|
} catch (e) {
|
|
750
|
-
|
|
751
|
-
this.logger.error(e);
|
|
752
|
-
}
|
|
768
|
+
this.logger.error(e);
|
|
753
769
|
}
|
|
754
770
|
}
|
|
755
771
|
/// #endif
|
|
@@ -861,8 +877,10 @@ class NaslServer {
|
|
|
861
877
|
const quickInfo = await this._getTypeQuickinfo({
|
|
862
878
|
file: (fileNode as FileNode).getEmbeddedFilePath(),
|
|
863
879
|
line: lsp2tspNumber(currentSource.start.line),
|
|
880
|
+
// TODO 适配依赖库的extension.xxx
|
|
864
881
|
offset: lsp2tspNumber(currentSource.start.character) + `new nasl.ui.`.length,
|
|
865
882
|
});
|
|
883
|
+
|
|
866
884
|
if (quickInfo.responseRequired) {
|
|
867
885
|
const displayString = quickInfo?.response?.displayString || '';
|
|
868
886
|
|
|
@@ -1810,9 +1828,7 @@ class NaslServer {
|
|
|
1810
1828
|
try {
|
|
1811
1829
|
jsCode = nodeIn.toJS();
|
|
1812
1830
|
} catch (err) {
|
|
1813
|
-
|
|
1814
|
-
self.logger.error(err);
|
|
1815
|
-
}
|
|
1831
|
+
self.logger.error(err);
|
|
1816
1832
|
}
|
|
1817
1833
|
if (!jsCode.startsWith(`${node.name} = `)) return;
|
|
1818
1834
|
// 页面局部变量
|
|
@@ -1841,7 +1857,7 @@ class NaslServer {
|
|
|
1841
1857
|
const diagnostic = {
|
|
1842
1858
|
node: nodeIn,
|
|
1843
1859
|
severity: 'error',
|
|
1844
|
-
message: `${nodeIn.label}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
|
|
1860
|
+
message: `${nodeIn.label || ''}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
|
|
1845
1861
|
};
|
|
1846
1862
|
nodeIn.tsErrorDetail = diagnostic;
|
|
1847
1863
|
diagnostics.push(diagnostic);
|
|
@@ -2350,7 +2366,7 @@ class NaslServer {
|
|
|
2350
2366
|
const diagnostic = {
|
|
2351
2367
|
node: nodeIn,
|
|
2352
2368
|
severity: 'error',
|
|
2353
|
-
message: `${nodeIn.label}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
|
|
2369
|
+
message: `${nodeIn.label || ''}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
|
|
2354
2370
|
};
|
|
2355
2371
|
nodeIn.tsErrorDetail = diagnostic;
|
|
2356
2372
|
diagnostics.push(diagnostic);
|
|
@@ -2783,6 +2799,49 @@ class NaslServer {
|
|
|
2783
2799
|
}
|
|
2784
2800
|
}
|
|
2785
2801
|
}
|
|
2802
|
+
if (node instanceof CallLogic) {
|
|
2803
|
+
// 处理依赖库高阶函数,函数签名和函数调用参数要完全一一对应
|
|
2804
|
+
if (node.calleeNamespace?.startsWith('extensions.')) {
|
|
2805
|
+
const logicNode = node.getCallNode();
|
|
2806
|
+
const params = logicNode?.params?.slice();
|
|
2807
|
+
const findFunction = params.find(param => param?.typeAnnotation?.typeKind === 'function');
|
|
2808
|
+
if (findFunction) {
|
|
2809
|
+
node.arguments?.forEach((argument, index) => {
|
|
2810
|
+
const expression = argument?.expression;
|
|
2811
|
+
const paramType = params[index]?.typeAnnotation;
|
|
2812
|
+
if (!expression?.tsErrorDetail && paramType?.typeKind === 'function' && paramType?.typeArguments?.length) {
|
|
2813
|
+
let hasLengthErrorDetail = {
|
|
2814
|
+
flag: false,
|
|
2815
|
+
message: '',
|
|
2816
|
+
};
|
|
2817
|
+
const isSubLogic = expression instanceof SubLogic;
|
|
2818
|
+
const isCallLogic = expression instanceof Identifier && expression?.namespace?.endsWith('logics');
|
|
2819
|
+
if (isSubLogic) {
|
|
2820
|
+
if (expression?.params?.length !== paramType.typeArguments.length) {
|
|
2821
|
+
hasLengthErrorDetail.flag = true;
|
|
2822
|
+
hasLengthErrorDetail.message = `高阶函数: 参数个数不匹配,期望 ${paramType.typeArguments.length} 个, 实际传入 ${expression.params?.length || 0} 个!`;
|
|
2823
|
+
}
|
|
2824
|
+
} else if (isCallLogic) {
|
|
2825
|
+
const getIdentCallLogic = expression.getFunctionCallNode();
|
|
2826
|
+
if (getIdentCallLogic?.params?.length !== paramType.typeArguments.length) {
|
|
2827
|
+
hasLengthErrorDetail.flag = true;
|
|
2828
|
+
hasLengthErrorDetail.message = `高阶函数: 参数个数不匹配,期望 ${paramType.typeArguments.length} 个, 实际传入 ${getIdentCallLogic.params?.length || 0} 个!`;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
if (hasLengthErrorDetail.flag) {
|
|
2832
|
+
const diagnostic = {
|
|
2833
|
+
node: expression,
|
|
2834
|
+
severity: 'error',
|
|
2835
|
+
message: hasLengthErrorDetail.message,
|
|
2836
|
+
};
|
|
2837
|
+
expression.tsErrorDetail = diagnostic;
|
|
2838
|
+
diagnostics.push(diagnostic);
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
})
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2786
2845
|
|
|
2787
2846
|
// if(node instanceof CallLogic) {
|
|
2788
2847
|
// const logic = node.getCallNode();
|
|
@@ -3189,9 +3248,7 @@ class NaslServer {
|
|
|
3189
3248
|
}
|
|
3190
3249
|
}
|
|
3191
3250
|
} catch (e) {
|
|
3192
|
-
|
|
3193
|
-
this.logger.error('naslServer实体引用', e);
|
|
3194
|
-
}
|
|
3251
|
+
this.logger.error('naslServer实体引用', e);
|
|
3195
3252
|
}
|
|
3196
3253
|
}
|
|
3197
3254
|
}
|
|
@@ -3618,9 +3675,7 @@ class NaslServer {
|
|
|
3618
3675
|
minRange.setTypeMethods = 'setValue';
|
|
3619
3676
|
}
|
|
3620
3677
|
} catch (error) {
|
|
3621
|
-
|
|
3622
|
-
this.logger.error(error);
|
|
3623
|
-
}
|
|
3678
|
+
console.error(error)
|
|
3624
3679
|
}
|
|
3625
3680
|
} else if (minRange.node instanceof Identifier) {
|
|
3626
3681
|
minRange.newValue = utils.firstLowerCase(newValue);
|
|
@@ -3957,6 +4012,7 @@ class NaslServer {
|
|
|
3957
4012
|
App.emit('collect:start', {
|
|
3958
4013
|
actionMsg: '增加逻辑参数',
|
|
3959
4014
|
});
|
|
4015
|
+
console.log('-----增加逻辑参数-----')
|
|
3960
4016
|
const index = node.getIndexOfParent();
|
|
3961
4017
|
node.create({
|
|
3962
4018
|
index,
|
|
@@ -3965,6 +4021,7 @@ class NaslServer {
|
|
|
3965
4021
|
});
|
|
3966
4022
|
this._addParamsEffect(refsList, node as Param);
|
|
3967
4023
|
// 结束修改 ,批量操作
|
|
4024
|
+
console.log('-----增加逻辑参数 结束-----')
|
|
3968
4025
|
App.emit('collect:end');
|
|
3969
4026
|
return node;
|
|
3970
4027
|
}
|
|
@@ -4004,9 +4061,7 @@ class NaslServer {
|
|
|
4004
4061
|
result = this.handleTreeMap(resMap);
|
|
4005
4062
|
}
|
|
4006
4063
|
} catch (err) {
|
|
4007
|
-
|
|
4008
|
-
this.logger.error(err);
|
|
4009
|
-
}
|
|
4064
|
+
this.logger.error(err);
|
|
4010
4065
|
}
|
|
4011
4066
|
return result;
|
|
4012
4067
|
}
|
|
@@ -4032,9 +4087,7 @@ class NaslServer {
|
|
|
4032
4087
|
result.add(minRange.node);
|
|
4033
4088
|
});
|
|
4034
4089
|
} catch (err) {
|
|
4035
|
-
|
|
4036
|
-
this.logger.error(err);
|
|
4037
|
-
}
|
|
4090
|
+
this.logger.error(err);
|
|
4038
4091
|
}
|
|
4039
4092
|
return [...result];
|
|
4040
4093
|
}
|
|
@@ -4531,6 +4584,49 @@ class NaslServer {
|
|
|
4531
4584
|
} else {
|
|
4532
4585
|
// 清空原来已经赋值上去的类型,可能原来有现在没有了
|
|
4533
4586
|
delete node.__TypeAnnotation;
|
|
4587
|
+
// 给一些泛型标注的推导泛型
|
|
4588
|
+
delete (node as any).__TypeArguments;
|
|
4589
|
+
/**
|
|
4590
|
+
* 特殊处理,calllogic 有泛型的情况,拿到的类型是错误的编译不出来的类型,所以要特殊处理一下
|
|
4591
|
+
* 不想去查两次类型, 因为是从函数签名上拿类型,所以直接合并在一起,先这样
|
|
4592
|
+
*/
|
|
4593
|
+
if (
|
|
4594
|
+
node instanceof CallLogic &&
|
|
4595
|
+
node.completeTypeParams?.length &&
|
|
4596
|
+
(node as any)?.__nodeType
|
|
4597
|
+
) {
|
|
4598
|
+
const logicNode = node.getCallNode();
|
|
4599
|
+
const autoTypeArguments = (node as any).__nodeType?.typeArguments || [];
|
|
4600
|
+
const newAutoTypeArguments = [...autoTypeArguments];
|
|
4601
|
+
if (logicNode.returns?.length) {
|
|
4602
|
+
let returnType = newAutoTypeArguments.shift();
|
|
4603
|
+
if (node.handleError && returnType.typeName === 'Union') {
|
|
4604
|
+
const returnTypeArguments = returnType.typeArguments || [];
|
|
4605
|
+
const typeArguments = [...returnTypeArguments];
|
|
4606
|
+
const errorType = typeArguments.find((t: any) => t.typeName === 'Error');
|
|
4607
|
+
if (errorType) {
|
|
4608
|
+
if (typeArguments.length === 2) {
|
|
4609
|
+
returnType = typeArguments.filter((t: any) => t !== errorType)[0];
|
|
4610
|
+
} else {
|
|
4611
|
+
returnType.typeArguments = typeArguments.filter((t: any) => t !== errorType);
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
node.__TypeAnnotation = utils.runGeneratorSync(type2TypeAnnotation(returnType));
|
|
4616
|
+
}
|
|
4617
|
+
|
|
4618
|
+
const typeArgs: any[] = [];
|
|
4619
|
+
const typeArguments = node.typeArguments;
|
|
4620
|
+
node.completeTypeParams.forEach((typeArg, typeIndex) => {
|
|
4621
|
+
if (typeArg.needChoose) {
|
|
4622
|
+
typeArgs.push(typeArguments?.[typeIndex])
|
|
4623
|
+
} else {
|
|
4624
|
+
const newType = utils.runGeneratorSync(type2TypeAnnotation(newAutoTypeArguments.shift()));
|
|
4625
|
+
typeArgs.push(newType)
|
|
4626
|
+
}
|
|
4627
|
+
});
|
|
4628
|
+
node.__TypeArguments = typeArgs;
|
|
4629
|
+
}
|
|
4534
4630
|
}
|
|
4535
4631
|
} catch (err) {
|
|
4536
4632
|
// if (globalThis.window) {
|
|
@@ -4574,8 +4670,8 @@ class NaslServer {
|
|
|
4574
4670
|
|
|
4575
4671
|
this.logger.timeEnd('全量标注');
|
|
4576
4672
|
|
|
4577
|
-
//
|
|
4578
|
-
if (utils.
|
|
4673
|
+
// 测试环境打印数据
|
|
4674
|
+
if (utils.isTestBrowser) {
|
|
4579
4675
|
this.logger.info('全量标注数据', json);
|
|
4580
4676
|
}
|
|
4581
4677
|
|
|
@@ -4745,6 +4841,15 @@ class NaslServer {
|
|
|
4745
4841
|
node.arguments.pop();
|
|
4746
4842
|
}
|
|
4747
4843
|
}
|
|
4844
|
+
|
|
4845
|
+
/**
|
|
4846
|
+
* 特殊处理,不想去查两次类型, 因为是从函数签名上拿类型,所以直接合并在一起,先这样
|
|
4847
|
+
*/
|
|
4848
|
+
if (node instanceof CallLogic && node.__TypeArguments?.length) {
|
|
4849
|
+
const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
4850
|
+
jsonNode.typeArguments = node.__TypeArguments;
|
|
4851
|
+
jsonNode.typeAnnotation = node.__TypeAnnotation;
|
|
4852
|
+
}
|
|
4748
4853
|
}
|
|
4749
4854
|
|
|
4750
4855
|
// 服务端需要默认值节点有类型来判断父节点是否是日期类型
|
|
@@ -4811,9 +4916,7 @@ class NaslServer {
|
|
|
4811
4916
|
}
|
|
4812
4917
|
return new Promise((resolve, reject) => {
|
|
4813
4918
|
const myTimer = setTimeout(() => {
|
|
4814
|
-
|
|
4815
|
-
this.logger.warn(node, '没有获取到类型');
|
|
4816
|
-
}
|
|
4919
|
+
this.logger.warn(node, '没有获取到类型');
|
|
4817
4920
|
clearTimeout(myTimer);
|
|
4818
4921
|
clearInterval(mySetInterval);
|
|
4819
4922
|
if (node.__isCorrectTypeAnnotation) {
|
package/src/server/translator.ts
CHANGED
|
@@ -4,16 +4,16 @@ import { addBreakpointNodesFromApp } from '../../breakpoint';
|
|
|
4
4
|
import { getConceptConstructor } from '../../decorators';
|
|
5
5
|
import { config } from '../../config';
|
|
6
6
|
import storageService from './service';
|
|
7
|
-
import { LsCache, BreakpointStatus, FullResponse, isDebugMode, BatchInstructResult } from '../../utils';
|
|
8
7
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
8
|
import stepRecorder from '../../manager/stepRecorder';
|
|
10
9
|
import * as jsoner from './jsoner';
|
|
11
10
|
/// #if !process.env.NODE_ENV || process.env.BUILD_TARGET === 'node'
|
|
12
11
|
import * as fs from 'fs-extra';
|
|
13
12
|
import type { NaslServer } from 'src/server/naslServer';
|
|
14
|
-
import { NaslCacheData, NaslData } from 'src/utils/language-cache';
|
|
15
13
|
/// #endif
|
|
16
14
|
|
|
15
|
+
|
|
16
|
+
|
|
17
17
|
export const batchQuery = storageService.batchQuery;
|
|
18
18
|
export const batchAction = storageService.batchAction;
|
|
19
19
|
export const batchInstruct = storageService.batchInstruct;
|
|
@@ -58,12 +58,12 @@ export function doOperationRecord(operation: Operation) {
|
|
|
58
58
|
transaction.oncomplete = () => {
|
|
59
59
|
db.close();
|
|
60
60
|
};
|
|
61
|
-
} catch
|
|
61
|
+
} catch(err) {
|
|
62
62
|
console.log(err);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
request.onerror = function
|
|
66
|
+
request.onerror = function(event) {
|
|
67
67
|
console.log('Failed to open database');
|
|
68
68
|
};
|
|
69
69
|
}
|
|
@@ -228,7 +228,7 @@ export async function operationRecordPlayback(app: any, operationRecordAction: '
|
|
|
228
228
|
const pathArr = path?.split('.') || [];
|
|
229
229
|
const lastPathItem = pathArr?.pop();
|
|
230
230
|
if (lastPathItem) {
|
|
231
|
-
|
|
231
|
+
pathArr.push(lastPathItem.replace(/(name=)[^\]]+/, `$1${object?.name}`));
|
|
232
232
|
}
|
|
233
233
|
newPath = pathArr.join('.');
|
|
234
234
|
}
|
|
@@ -254,7 +254,7 @@ export async function operationRecordPlayback(app: any, operationRecordAction: '
|
|
|
254
254
|
case 'update':
|
|
255
255
|
for (const key in oldObject) {
|
|
256
256
|
if (node) {
|
|
257
|
-
|
|
257
|
+
(node as any)[key] = oldObject[key] ?? null;
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
break;
|
|
@@ -427,7 +427,7 @@ async function doAction(app: any, actionItem: any) {
|
|
|
427
427
|
let hasBackEnd = false;
|
|
428
428
|
const actionList: any[] = [];
|
|
429
429
|
const allRiskList: any[] = [];
|
|
430
|
-
const { list, actionMsg, action, extra
|
|
430
|
+
const { list, actionMsg, action, extra} = actionItem || {};
|
|
431
431
|
handleAIPoint(app, actionItem);
|
|
432
432
|
const itemloop = (_i: LogicItem, app: any, diffArr: string[]) => {
|
|
433
433
|
const _l = getStatement(_i, app, diffArr);
|
|
@@ -543,9 +543,9 @@ async function doAction(app: any, actionItem: any) {
|
|
|
543
543
|
const isDelete = event?.originEvent?.action === 'delete';
|
|
544
544
|
const isAuthView = (emitTarget as View).auth && event?.originEvent?.object?.name;
|
|
545
545
|
const isUpdateAuth = event?.originEvent?.action === 'update' && "auth" in (event?.originEvent?.object || {});
|
|
546
|
-
const isUpdateAuthDes =
|
|
546
|
+
const isUpdateAuthDes = event?.originEvent?.action === 'update' && "authDescription" in (event?.originEvent?.object || {});
|
|
547
547
|
const isUpdateBindRoles = event?.originEvent?.action === 'update' && event?.originEvent?.object && event?.originEvent?.object?.bindRoles;
|
|
548
|
-
if (isDelete || isUpdateAuth || isUpdateBindRoles || isAuthView
|
|
548
|
+
if (isDelete || isUpdateAuth || isUpdateBindRoles || isAuthView||isUpdateAuthDes) {
|
|
549
549
|
hasBackEnd = true;
|
|
550
550
|
// const app = emitTarget.app;
|
|
551
551
|
// const diffArr: string[] = [];
|
|
@@ -566,7 +566,7 @@ async function doAction(app: any, actionItem: any) {
|
|
|
566
566
|
hasFrontEnd = true;
|
|
567
567
|
}
|
|
568
568
|
if (emitTarget.concept === 'ViewElement') {
|
|
569
|
-
if
|
|
569
|
+
if(event?.originEvent?.action === 'update' || event?.originEvent?.action === 'delete'){
|
|
570
570
|
if ('authDescription' in (event?.originEvent?.object ?? {})) {
|
|
571
571
|
hasBackEnd = true;
|
|
572
572
|
}
|
|
@@ -597,7 +597,7 @@ async function doAction(app: any, actionItem: any) {
|
|
|
597
597
|
}
|
|
598
598
|
if (emitTarget.concept === 'BindAttribute' && emitTarget.name === 'url') {
|
|
599
599
|
const needUpdateBackEnd =
|
|
600
|
-
|
|
600
|
+
(emitTarget as BindAttribute)?.value?.endsWith('/import') || (emitTarget as BindAttribute)?.value?.includes('/upload/')
|
|
601
601
|
if (!(emitTarget as BindAttribute).view.parentAuth && needUpdateBackEnd) {
|
|
602
602
|
hasBackEnd = true
|
|
603
603
|
}
|
|
@@ -888,7 +888,7 @@ function ensureSafe(instructList: any[]) {
|
|
|
888
888
|
instruct?.actions?.forEach((actionItem: any) => {
|
|
889
889
|
const { path, action, object } = actionItem || {};
|
|
890
890
|
if (path === 'app') {
|
|
891
|
-
switch
|
|
891
|
+
switch(action) {
|
|
892
892
|
case 'create':
|
|
893
893
|
riskList.push('重复创建App');
|
|
894
894
|
break;
|
|
@@ -918,8 +918,7 @@ async function _saveNasl(options: TaskOption) {
|
|
|
918
918
|
} else if (hasBackEnd) {
|
|
919
919
|
ChangedNASLType = 'backend';
|
|
920
920
|
}
|
|
921
|
-
|
|
922
|
-
let res: BatchInstructResult;
|
|
921
|
+
let res: any;
|
|
923
922
|
let err: any;
|
|
924
923
|
|
|
925
924
|
if (config.storage.protocol === 'http') {
|
|
@@ -997,13 +996,6 @@ async function _saveNasl(options: TaskOption) {
|
|
|
997
996
|
});
|
|
998
997
|
}
|
|
999
998
|
app.emit?.('saved', err);
|
|
1000
|
-
|
|
1001
|
-
// 更新缓存
|
|
1002
|
-
await LsCache.updateNaslCache(app.id, {
|
|
1003
|
-
...res,
|
|
1004
|
-
getData: () => cloneDeep(app.toJSON()),
|
|
1005
|
-
});
|
|
1006
|
-
|
|
1007
999
|
return err;
|
|
1008
1000
|
}
|
|
1009
1001
|
|
|
@@ -1019,6 +1011,7 @@ export interface ProxyApp extends App {
|
|
|
1019
1011
|
_action: string;
|
|
1020
1012
|
_extra?: any;
|
|
1021
1013
|
naslServer: NaslServer;
|
|
1014
|
+
_historyName?: string,
|
|
1022
1015
|
}
|
|
1023
1016
|
|
|
1024
1017
|
export function handleApp(app: ProxyApp) {
|
|
@@ -1026,6 +1019,7 @@ export function handleApp(app: ProxyApp) {
|
|
|
1026
1019
|
app._collectingList = [];
|
|
1027
1020
|
app._historyList = [];
|
|
1028
1021
|
app._historyIndex = 0;
|
|
1022
|
+
app._historyName = 'IDE';
|
|
1029
1023
|
app._historying = false;
|
|
1030
1024
|
app._timer = null;
|
|
1031
1025
|
|
|
@@ -1146,104 +1140,65 @@ export function handleApp(app: ProxyApp) {
|
|
|
1146
1140
|
});
|
|
1147
1141
|
}
|
|
1148
1142
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
],
|
|
1156
|
-
headers: {
|
|
1157
|
-
appId,
|
|
1158
|
-
checkTabOpenTime: 'true',
|
|
1159
|
-
},
|
|
1160
|
-
config: {
|
|
1161
|
-
shortResponse: false
|
|
1162
|
-
},
|
|
1163
|
-
});
|
|
1164
|
-
|
|
1165
|
-
return {
|
|
1166
|
-
globalChangedTime,
|
|
1167
|
-
tabTimestamp: headers['tabtimestamp'],
|
|
1168
|
-
};
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
async function getNaslFromServer(appId: string, globalChangedTime: number | null) {
|
|
1172
|
-
const [naslData] = await storageService.batchQuery({
|
|
1173
|
-
body: [
|
|
1174
|
-
{
|
|
1175
|
-
path: 'app',
|
|
1176
|
-
},
|
|
1177
|
-
],
|
|
1178
|
-
headers: {
|
|
1179
|
-
appId,
|
|
1180
|
-
},
|
|
1181
|
-
});
|
|
1182
|
-
|
|
1183
|
-
// 后端没有此值时,表示为存量应用,不可缓存
|
|
1184
|
-
if (!globalChangedTime) {
|
|
1185
|
-
return naslData;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
await LsCache.updateNaslCache(appId, {
|
|
1189
|
-
getData: () => naslData,
|
|
1190
|
-
// 初次缓存时此值无用,故赋值为 0
|
|
1191
|
-
preGlobalChangedTime: 0,
|
|
1192
|
-
globalChangedTime: globalChangedTime,
|
|
1193
|
-
});
|
|
1194
|
-
|
|
1195
|
-
return naslData as NaslData;
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
async function getNaslFromCache(appId: string) {
|
|
1199
|
-
return LsCache.getNaslCacheWithoutCheck(appId).then((data) => data.data);
|
|
1200
|
-
}
|
|
1143
|
+
type BreakpointItem =
|
|
1144
|
+
| any
|
|
1145
|
+
| {
|
|
1146
|
+
path: string
|
|
1147
|
+
breakpointStatus: null | 'ENABLED' | 'DISABLED'
|
|
1148
|
+
}
|
|
1201
1149
|
|
|
1202
1150
|
/**
|
|
1203
1151
|
* 加载 app
|
|
1204
1152
|
* @param appId 如果是从文件读,就不需要传
|
|
1205
1153
|
* @returns app 对象
|
|
1206
1154
|
*/
|
|
1207
|
-
export async function loadApp(appId
|
|
1155
|
+
export async function loadApp(appId?: string) {
|
|
1208
1156
|
try {
|
|
1209
1157
|
// 删除失效数据
|
|
1210
1158
|
deleteExpiredRecords();
|
|
1211
|
-
} catch
|
|
1159
|
+
} catch(err) { }
|
|
1212
1160
|
let app: App;
|
|
1213
1161
|
if (config.storage.protocol === 'http') {
|
|
1214
1162
|
console.time('batchQuery');
|
|
1215
|
-
const additionalData = await getBatchAdditionalData(appId);
|
|
1216
|
-
const useCache = await LsCache.canUseNaslCache(appId, additionalData.globalChangedTime);
|
|
1217
1163
|
const promises = [
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1164
|
+
storageService.batchQuery({
|
|
1165
|
+
body: [
|
|
1166
|
+
{
|
|
1167
|
+
path: 'app'
|
|
1168
|
+
// excludes: ['views'],
|
|
1169
|
+
}
|
|
1170
|
+
],
|
|
1171
|
+
headers: {
|
|
1172
|
+
appId,
|
|
1173
|
+
checkTabOpenTime: 'true'
|
|
1174
|
+
// 其他封装在 storageService 里了
|
|
1175
|
+
},
|
|
1176
|
+
config: {
|
|
1177
|
+
shortResponse: false
|
|
1178
|
+
}
|
|
1179
|
+
}),
|
|
1221
1180
|
storageService.breakpoint({
|
|
1222
1181
|
body: { appId }
|
|
1223
|
-
})
|
|
1224
|
-
|
|
1225
|
-
] as [Promise<LsCache.NaslCacheData>, Promise<BreakpointStatus[]>, Promise<void>];
|
|
1226
|
-
|
|
1227
|
-
if (isDebugMode) {
|
|
1228
|
-
if (useCache) {
|
|
1229
|
-
console.log('命中 Nasl 前端缓存');
|
|
1230
|
-
}
|
|
1231
|
-
else {
|
|
1232
|
-
console.log('未命中 Nasl 前端缓存');
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1182
|
+
})
|
|
1183
|
+
]
|
|
1235
1184
|
|
|
1236
1185
|
const [batchQueryRes, breakpointRes] = await Promise.all(promises)
|
|
1237
1186
|
|
|
1238
1187
|
// 请求
|
|
1239
1188
|
console.timeEnd('batchQuery');
|
|
1240
|
-
tabTimestamp = additionalData.tabTimestamp;
|
|
1241
1189
|
|
|
1242
|
-
|
|
1243
|
-
|
|
1190
|
+
tabTimestamp = batchQueryRes?.headers?.tabtimestamp;
|
|
1191
|
+
const data = batchQueryRes?.data?.result;
|
|
1244
1192
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1193
|
+
console.time('new App');
|
|
1194
|
+
app = new App(Object.assign(data?.[0] || {}, { id: appId }));
|
|
1195
|
+
app.frontendTypes.forEach(ft => {
|
|
1196
|
+
if(!ft.frameworkKind) {
|
|
1197
|
+
ft.frameworkKind = 'vue2';
|
|
1198
|
+
}
|
|
1199
|
+
})
|
|
1200
|
+
breakpointRes?.forEach?.((item: BreakpointItem = {}) => {
|
|
1201
|
+
const { path, breakpointStatus } = item
|
|
1247
1202
|
|
|
1248
1203
|
if (breakpointStatus) {
|
|
1249
1204
|
const node = app.findNodeByPath(path)
|
|
@@ -430,7 +430,12 @@ function genProcessV2LaunchLogic(module: any, entity: Entity, process: ProcessV2
|
|
|
430
430
|
* 生成创建页区块
|
|
431
431
|
* @param resolver 实体创建 Action
|
|
432
432
|
*/
|
|
433
|
-
export function genCreateBlock(entity: Entity, oldNode: ViewElement, appointKeys: string[] = [],frontendType: string, process: ProcessV2, extra: IBlockExtra = {}
|
|
433
|
+
export function genCreateBlock(entity: Entity, oldNode: ViewElement, appointKeys: string[] = [],frontendType: string, process: ProcessV2, extra: IBlockExtra = {}, useViewVriable = true,
|
|
434
|
+
localTemplate: {
|
|
435
|
+
genCreateTemplate: (entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>, appointKeys: string[], process: ProcessV2, extra: IBlockExtra) => string,
|
|
436
|
+
genSubmitLogicLocal: (createLogic: Logic, nameGroup: NameGroup, extendConsequents: any[]) => any,
|
|
437
|
+
genCreatedHandler: (entity: Entity, nameGroup: NameGroup) => string
|
|
438
|
+
}) {
|
|
434
439
|
const likeComponent = oldNode?.likeComponent;
|
|
435
440
|
const dataSource = entity.parentNode as DataSource;
|
|
436
441
|
const module = dataSource.app;
|
|
@@ -490,35 +495,51 @@ export function genCreateBlock(entity: Entity, oldNode: ViewElement, appointKeys
|
|
|
490
495
|
})
|
|
491
496
|
);
|
|
492
497
|
}
|
|
498
|
+
let viewBindEvents = '';
|
|
499
|
+
let viewLoadLogic;
|
|
500
|
+
if(localTemplate.genCreatedHandler) {
|
|
501
|
+
nameGroup.viewLogicCreated = likeComponent.getLogicUniqueName('load');
|
|
502
|
+
viewLoadLogic = localTemplate.genCreatedHandler(entity, nameGroup)
|
|
503
|
+
viewBindEvents = `
|
|
504
|
+
,"viewBindEvents": [
|
|
505
|
+
{
|
|
506
|
+
"concept": "BindEvent",
|
|
507
|
+
"arguments": [],
|
|
508
|
+
"name": "created",
|
|
509
|
+
"calleeNamespace": "",
|
|
510
|
+
"calleeName": "${nameGroup.viewLogicCreated}"
|
|
511
|
+
}
|
|
512
|
+
]`
|
|
513
|
+
}
|
|
493
514
|
|
|
494
|
-
const submitLogic = genSubmitLogic(createLogic, nameGroup, extendConsequent);
|
|
495
|
-
|
|
515
|
+
const submitLogic = (localTemplate.genSubmitLogicLocal || genSubmitLogic)(createLogic, nameGroup, extendConsequent);
|
|
516
|
+
const genTemplate = localTemplate.genCreateTemplate || ((frontendType || config.scope) === 'h5' ? genH5CreateFormTemplate : genCreateFormTemplate);
|
|
496
517
|
return `<template>
|
|
497
|
-
${(
|
|
498
|
-
? genH5CreateFormTemplate(entity, nameGroup, selectNameGroupMap, appointKeys, process, extra)
|
|
499
|
-
: genCreateFormTemplate(entity, nameGroup, selectNameGroupMap, appointKeys, process, extra)
|
|
500
|
-
}
|
|
518
|
+
${genTemplate(entity, nameGroup, selectNameGroupMap, appointKeys, process, extra)}
|
|
501
519
|
</template>
|
|
502
520
|
|
|
503
521
|
<definition>
|
|
504
522
|
{
|
|
505
523
|
"viewVariables": [
|
|
506
|
-
|
|
524
|
+
${useViewVriable ? `{
|
|
507
525
|
"concept": "Variable",
|
|
508
526
|
"name": "${nameGroup.viewVariableEntity}",
|
|
509
527
|
"typeAnnotation": ${JSON.stringify(
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
528
|
+
NaslTypeAnnotation.Reference({
|
|
529
|
+
typeNamespace: entity.getNamespace(),
|
|
530
|
+
typeName: entity.name,
|
|
531
|
+
})
|
|
532
|
+
)}}` : ''
|
|
533
|
+
}
|
|
534
|
+
|
|
516
535
|
]
|
|
517
536
|
${appointKeys.length ? '' : `,"viewLogics": [
|
|
518
537
|
${JSON.stringify(submitLogic)}
|
|
519
538
|
${newLoadSelectLogics.map((logic) => `,${JSON.stringify(logic)}`).join('\n')}
|
|
539
|
+
${viewLoadLogic ? ',' + JSON.stringify(viewLoadLogic) : ''}
|
|
520
540
|
],
|
|
521
541
|
"logics": ${JSON.stringify(newLogics)}`}
|
|
542
|
+
${viewBindEvents}
|
|
522
543
|
}
|
|
523
544
|
</definition>
|
|
524
545
|
`;
|