@lcap/nasl 3.8.0-beta.3 → 3.8.0-beta.5
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/engine/utils.js +1 -2
- package/out/automate/engine/utils.js.map +1 -1
- package/out/bak/translator.js +1 -1
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +7 -2
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.js +6 -1
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +11 -5
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js +3 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +49 -2
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +4 -3
- package/out/concepts/BindAttribute__.js +121 -42
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.js +5 -42
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +1 -0
- package/out/concepts/BusinessComponent__.js +16 -0
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +3 -0
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallConnector__.js +1 -1
- package/out/concepts/CallConnector__.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 +6 -1
- package/out/concepts/CallLogic__.js +58 -17
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Connection__.d.ts +4 -0
- package/out/concepts/Connection__.js +15 -0
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/DatabaseTypeAnnotation__.d.ts +2 -0
- package/out/concepts/DatabaseTypeAnnotation__.js +20 -0
- package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
- package/out/concepts/End__.js +5 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +2 -0
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -0
- package/out/concepts/Entity__.js +24 -1
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +12 -0
- package/out/concepts/EnumItem__.js +49 -5
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +4 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +1 -1
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +46 -46
- package/out/concepts/FrontendLibrary__.js +34 -36
- package/out/concepts/FrontendLibrary__.js.map +1 -1
- package/out/concepts/I18nInfo__.d.ts +1 -0
- package/out/concepts/I18nInfo__.js +7 -0
- package/out/concepts/I18nInfo__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +4 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +2 -3
- package/out/concepts/Logic__.js +33 -8
- package/out/concepts/Logic__.js.map +1 -1
- 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/NewComposite__.js +2 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +2 -1
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.js +2 -1
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +3 -11
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +7 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.js +2 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElementV2__.d.ts +4 -5
- package/out/concepts/ProcessElementV2__.js +12 -17
- package/out/concepts/ProcessElementV2__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +3 -4
- package/out/concepts/ProcessElement__.js +44 -46
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessV2__.d.ts +5 -0
- package/out/concepts/ProcessV2__.js +30 -2
- package/out/concepts/ProcessV2__.js.map +1 -1
- package/out/concepts/Process__.d.ts +5 -0
- package/out/concepts/Process__.js +28 -0
- package/out/concepts/Process__.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/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +2 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StaticString__.d.ts +4 -0
- package/out/concepts/StaticString__.js +11 -0
- package/out/concepts/StaticString__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +5 -2
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +9 -3
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SubLogic__.d.ts +1 -3
- package/out/concepts/SubLogic__.js +14 -8
- package/out/concepts/SubLogic__.js.map +1 -1
- package/out/concepts/Transactional__.d.ts +1 -0
- package/out/concepts/Transactional__.js +7 -0
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +4 -0
- package/out/concepts/TypeParam__.js +3 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -6
- package/out/concepts/ValidationRule__.js +9 -6
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -1
- package/out/concepts/Variable__.js +7 -2
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +130 -47
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +8 -0
- package/out/concepts/View__.js +123 -7
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js +2 -2
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.js +110 -4
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +2 -0
- package/out/generator/genBundleFiles.js +51 -37
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +20 -26
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/release-body/body.js +8 -6
- package/out/generator/release-body/body.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 +1 -1
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +56 -24
- package/out/natural/genNaturalTS.js +182 -112
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/getUILib.js +4 -2
- package/out/natural/getContext/getUILib.js.map +1 -1
- package/out/natural/getContext/index.d.ts +34 -25
- package/out/natural/getContext/index.js +304 -157
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/index.d.ts +1 -0
- package/out/natural/index.js +1 -0
- package/out/natural/index.js.map +1 -1
- package/out/natural/tools.d.ts +11 -0
- package/out/natural/tools.js +155 -0
- package/out/natural/tools.js.map +1 -0
- package/out/natural/transformTS2UI.js +84 -22
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.js +83 -22
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/formatTsUtils.js +17 -1
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +1 -4
- package/out/server/getLogics.js.map +1 -1
- package/out/server/naslServer.js +285 -32
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +5 -1
- package/out/server/translator.js.map +1 -1
- package/out/templator/genCreateBlock.js +5 -18
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +11 -32
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -2
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +6 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +82 -59
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +4 -4
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -15
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/translator/types.d.ts +4 -0
- package/out/translator/utils.d.ts +1 -0
- package/out/translator/utils.js +6 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/env.d.ts +4 -0
- package/out/utils/env.js +6 -3
- package/out/utils/env.js.map +1 -1
- package/out/utils/index.d.ts +19 -0
- package/out/utils/index.js +61 -1
- package/out/utils/index.js.map +1 -1
- package/out/utils/language-cache/constant.d.ts +18 -0
- package/out/utils/language-cache/constant.js +35 -0
- package/out/utils/language-cache/constant.js.map +1 -0
- package/out/utils/language-cache/index.d.ts +2 -0
- package/out/utils/language-cache/index.js +19 -0
- package/out/utils/language-cache/index.js.map +1 -0
- package/out/utils/language-cache/nasl.d.ts +10 -0
- package/out/utils/language-cache/nasl.js +98 -0
- package/out/utils/language-cache/nasl.js.map +1 -0
- package/out/utils/language-cache/types.d.ts +44 -0
- package/out/utils/language-cache/types.js +4 -0
- package/out/utils/language-cache/types.js.map +1 -0
- package/out/utils/time-slicing/controller.js.map +1 -1
- package/out/utils/types.d.ts +17 -0
- package/package.json +3 -2
- package/sandbox/stdlib/nasl.core.ts +15 -11
- package/sandbox/stdlib/nasl.oql.ts +5 -1
- package/sandbox/stdlib/nasl.processV2.ts +5 -4
- package/sandbox/stdlib/nasl.ui.components.pc.ts +225 -225
- package/sandbox/stdlib/nasl.ui.ts +10 -0
- package/sandbox/stdlib/nasl.util.ts +11 -0
- package/sandbox/stdlib/nasl.validation.ts +3 -2
- package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +1 -1
- package/sandbox-natural/stdlib/nasl.ui.ts +2 -2
- package/sandbox-natural/stdlib/nasl.util.ts +2 -2
- package/src/automate/engine/utils.js +1 -2
- package/src/bak/translator.js +1 -1
- package/src/common/BaseNode.ts +7 -3
- package/src/concepts/App__.ts +9 -1
- package/src/concepts/Argument__.ts +10 -5
- package/src/concepts/AuthLogicForCallInterface__.ts +3 -0
- package/src/concepts/BinaryExpression__.ts +46 -2
- package/src/concepts/BindAttribute__.ts +144 -46
- package/src/concepts/BindEvent__.ts +8 -47
- package/src/concepts/BusinessComponent__.ts +17 -0
- package/src/concepts/BusinessLogic__.ts +3 -0
- package/src/concepts/CallConnector__.ts +1 -1
- package/src/concepts/CallFunction__.ts +1 -1
- package/src/concepts/CallLogic__.ts +63 -17
- package/src/concepts/Connection__.ts +16 -0
- package/src/concepts/DatabaseTypeAnnotation__.ts +11 -0
- package/src/concepts/End__.ts +5 -1
- package/src/concepts/EntityProperty__.ts +5 -0
- package/src/concepts/Entity__.ts +29 -1
- package/src/concepts/EnumItem__.ts +64 -1
- package/src/concepts/Enum__.ts +6 -1
- package/src/concepts/ForEachStatement__.ts +1 -1
- package/src/concepts/FrontendLibrary__.ts +78 -80
- package/src/concepts/I18nInfo__.ts +5 -0
- package/src/concepts/IfStatement__.ts +2 -2
- package/src/concepts/Interface__.ts +6 -1
- package/src/concepts/Logic__.ts +39 -10
- package/src/concepts/MatchCase__.ts +8 -9
- package/src/concepts/NewComposite__.ts +2 -1
- package/src/concepts/NewList__.ts +2 -1
- package/src/concepts/NewMap__.ts +2 -1
- package/src/concepts/OqlQueryComponent__.ts +3 -11
- package/src/concepts/OverriddenLogic__.ts +7 -0
- package/src/concepts/Param__.ts +1 -0
- package/src/concepts/ProcessElementV2__.ts +14 -16
- package/src/concepts/ProcessElement__.ts +16 -16
- package/src/concepts/ProcessV2__.ts +39 -3
- package/src/concepts/Process__.ts +36 -0
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/Return__.ts +2 -1
- package/src/concepts/StaticString__.ts +12 -0
- package/src/concepts/StructureProperty__.ts +7 -2
- package/src/concepts/Structure__.ts +11 -3
- package/src/concepts/SubLogic__.ts +15 -9
- package/src/concepts/Transactional__.ts +5 -0
- package/src/concepts/TypeParam__.ts +6 -0
- package/src/concepts/ValidationRule__.ts +7 -6
- package/src/concepts/Variable__.ts +7 -2
- package/src/concepts/ViewElement__.ts +130 -47
- package/src/concepts/View__.ts +157 -8
- package/src/concepts/basics/stdlib/nasl.processV2.ts +2 -2
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.validation.ts +111 -4
- package/src/generator/genBundleFiles.ts +53 -39
- package/src/generator/genMetaData.ts +21 -26
- package/src/generator/release-body/body.ts +9 -6
- package/src/generator/release-body/index.ts +1 -0
- package/src/generator/release-body/utils.ts +4 -2
- package/src/natural/genNaturalTS.ts +327 -141
- package/src/natural/getContext/getUILib.ts +4 -2
- package/src/natural/getContext/index.ts +348 -171
- package/src/natural/index.ts +1 -0
- package/src/natural/tools.ts +130 -0
- package/src/natural/transformTS2UI.ts +84 -22
- package/src/natural/transformTSCode.ts +83 -22
- package/src/server/formatTsUtils.ts +21 -1
- package/src/server/getLogics.ts +1 -4
- package/src/server/naslServer.ts +302 -33
- package/src/server/translator.ts +5 -1
- package/src/templator/genCreateBlock.ts +5 -18
- package/src/templator/genCurdMultipleKeyBlock.ts +14 -32
- package/src/templator/genGetBlock.ts +2 -4
- package/src/templator/genListViewBlock.ts +6 -4
- package/src/templator/genSelectBlock.ts +88 -61
- package/src/templator/genTableBlock.ts +4 -4
- package/src/templator/genUpdateBlock.ts +2 -15
- package/src/templator/utils.ts +1 -1
- package/src/translator/types.ts +4 -0
- package/src/translator/utils.ts +6 -0
- package/src/utils/env.ts +5 -4
- package/src/utils/index.ts +50 -1
- package/src/utils/language-cache/constant.ts +37 -0
- package/src/utils/language-cache/index.ts +2 -0
- package/src/utils/language-cache/nasl.ts +83 -0
- package/src/utils/language-cache/types.ts +48 -0
- package/src/utils/time-slicing/controller.ts +0 -1
- package/src/utils/types.ts +20 -0
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +13 -13
- package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +12 -12
- package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +1 -2
- package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +221 -217
- package/ts-worker/bundle.js +1 -1
- package/ts-worker/src/index.js +0 -1
- package/out/utils/delay/index.d.ts +0 -0
- package/out/utils/delay/index.js +0 -1
- package/out/utils/delay/index.js.map +0 -1
- package/src/utils/delay/index.ts +0 -0
package/src/server/naslServer.ts
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
EnumItem,
|
|
37
37
|
Param,
|
|
38
38
|
Process,
|
|
39
|
+
ProcessV2,
|
|
39
40
|
Interface,
|
|
40
41
|
Argument,
|
|
41
42
|
ViewElement,
|
|
@@ -99,6 +100,7 @@ import {
|
|
|
99
100
|
FrontendType,
|
|
100
101
|
InterfaceParam,
|
|
101
102
|
ProcessBindV2,
|
|
103
|
+
ValidationRule,
|
|
102
104
|
SubLogic,
|
|
103
105
|
} from '../concepts';
|
|
104
106
|
|
|
@@ -119,7 +121,7 @@ import { EventEmitter } from '../common/EventEmitter';
|
|
|
119
121
|
import { traverse, FileNode } from '../utils';
|
|
120
122
|
import { withQueueExecute } from '../decorators';
|
|
121
123
|
import { getNodeByNodeCallee } from '../automate/engine/utils';
|
|
122
|
-
import { isConnection, isConnector, isMsgTriggerEvent } from '../concepts/utils/asserts';
|
|
124
|
+
import { isConnection, isConnector, isMsgTriggerEvent, isProcess, isProcessV2, isStrictLogic } from '../concepts/utils/asserts';
|
|
123
125
|
|
|
124
126
|
const EmbeddedTSFileLineMap: { [name: string]: number } = {
|
|
125
127
|
Entity: 3,
|
|
@@ -411,6 +413,24 @@ class NaslServer {
|
|
|
411
413
|
Object.assign(allComponent, components)
|
|
412
414
|
const { code, elementsLogic } = await formatUiTs(allComponent);
|
|
413
415
|
|
|
416
|
+
// 处理一堆api.ts的类型
|
|
417
|
+
const convertTsCode = (code: string) => {
|
|
418
|
+
code = code.replace(/nasl.core.Integer/g, 'nasl.core.Long')
|
|
419
|
+
// 匹配union类型的正则
|
|
420
|
+
const unionReg = /\s*['"].*['"](\s*\|\s*['"].*['"])+/g;
|
|
421
|
+
code = code.replace(unionReg, 'nasl.core.String');
|
|
422
|
+
|
|
423
|
+
const extendsBooleanReg = /extends\s+(true|false)/g;
|
|
424
|
+
code = code.replace(extendsBooleanReg, ($0, $1) => {
|
|
425
|
+
return $1 === 'true' ? 'extends nasl.core.BooleanTrue' : 'extends nasl.core.BooleanFalse';
|
|
426
|
+
})
|
|
427
|
+
|
|
428
|
+
const extendsStringReg = /extends\s+(['"](.*)['"])/g;
|
|
429
|
+
code = code.replace(extendsStringReg, ($0, $1, $2) => `extends nasl.core.StringLiteral<\`${$2}\`>`)
|
|
430
|
+
|
|
431
|
+
return code;
|
|
432
|
+
}
|
|
433
|
+
|
|
414
434
|
/// process.env.BUILD_TARGET !== 'node'
|
|
415
435
|
if (!utils.isNode) {
|
|
416
436
|
await this.addFile(
|
|
@@ -425,10 +445,11 @@ class NaslServer {
|
|
|
425
445
|
/// #endif
|
|
426
446
|
|
|
427
447
|
if (utils.isNode) {
|
|
448
|
+
let content = await fs.readFile(path.join(__dirname, '../../sandbox/stdlib/nasl.ui.definition.ts'), 'utf-8');
|
|
428
449
|
await this.addFile(
|
|
429
450
|
{
|
|
430
451
|
file: 'nasl.ui.definition.ts',
|
|
431
|
-
fileContent:
|
|
452
|
+
fileContent: content,
|
|
432
453
|
},
|
|
433
454
|
{ cache: true }
|
|
434
455
|
);
|
|
@@ -450,7 +471,8 @@ class NaslServer {
|
|
|
450
471
|
await this.addFile(
|
|
451
472
|
{
|
|
452
473
|
file: 'nasl.ui.component.ts',
|
|
453
|
-
|
|
474
|
+
// FIXME 临时解决方式将union类型转换为string类型
|
|
475
|
+
fileContent: convertTsCode(optinos.basicUITsCode),
|
|
454
476
|
},
|
|
455
477
|
{ cache: true }
|
|
456
478
|
)
|
|
@@ -459,7 +481,7 @@ class NaslServer {
|
|
|
459
481
|
await this.addFile(
|
|
460
482
|
{
|
|
461
483
|
file: 'extension.component.ts',
|
|
462
|
-
fileContent: optinos.withTypeLibraryTsCode,
|
|
484
|
+
fileContent: convertTsCode(optinos.withTypeLibraryTsCode),
|
|
463
485
|
},
|
|
464
486
|
{ cache: true }
|
|
465
487
|
)
|
|
@@ -499,7 +521,7 @@ class NaslServer {
|
|
|
499
521
|
node.sourceMap = result.sourceMap;
|
|
500
522
|
self.file2NodeMap.set(result.filePath, node);
|
|
501
523
|
} catch (err) {
|
|
502
|
-
if (
|
|
524
|
+
if (utils.isDebugMode) {
|
|
503
525
|
self.logger.warn(node.nodePath ? node.nodePath : name, '代码转换失败', err);
|
|
504
526
|
}
|
|
505
527
|
}
|
|
@@ -765,7 +787,9 @@ class NaslServer {
|
|
|
765
787
|
try {
|
|
766
788
|
await Promise.all(openFiles.map(async (file) => fs.outputFile(path.join(__dirname, '../debug/apps', app.id, file.file), file.fileContent)));
|
|
767
789
|
} catch (e) {
|
|
768
|
-
|
|
790
|
+
if (utils.isDebugMode) {
|
|
791
|
+
this.logger.error(e);
|
|
792
|
+
}
|
|
769
793
|
}
|
|
770
794
|
}
|
|
771
795
|
/// #endif
|
|
@@ -890,6 +914,9 @@ class NaslServer {
|
|
|
890
914
|
// 从 {entity1:Entity1(defaultDS);},unknown,unknown,unknown 取出{entity1:Entity1(defaultDS);}
|
|
891
915
|
typeStr = typeStr?.split(',')[0];
|
|
892
916
|
|
|
917
|
+
// 将Long转换为Integer
|
|
918
|
+
typeStr = typeStr?.replace('Long', 'Integer');
|
|
919
|
+
|
|
893
920
|
if (flag) {
|
|
894
921
|
// 自定义结构的展示
|
|
895
922
|
if (typeStr.includes('__name: "AStructure_')) {
|
|
@@ -1163,7 +1190,8 @@ class NaslServer {
|
|
|
1163
1190
|
if (diagnostic.severity === 'warning') {
|
|
1164
1191
|
record.suggestionDiagnostics.push(diagnostic);
|
|
1165
1192
|
return null;
|
|
1166
|
-
}
|
|
1193
|
+
}
|
|
1194
|
+
if (asserts.isStrictOqlQueryComponent(currentNode)) {
|
|
1167
1195
|
// OQL别名错误降级为警告
|
|
1168
1196
|
if (diagnostic.originalDiagnostic && diagnostic.originalDiagnostic?.text.includes('__OQL_ALIAS_WARNING__')) {
|
|
1169
1197
|
// 重置 图标和错误等级
|
|
@@ -1176,6 +1204,26 @@ class NaslServer {
|
|
|
1176
1204
|
return null;
|
|
1177
1205
|
}
|
|
1178
1206
|
}
|
|
1207
|
+
// 组件部分属性错误降级
|
|
1208
|
+
if (asserts.isBindAttribute(currentNode) && asserts.isViewElement(currentNode.parentNode)) {
|
|
1209
|
+
const element = currentNode.parentNode as ViewElement;
|
|
1210
|
+
const tags: Record<string, string[]> = {
|
|
1211
|
+
'u-number-input': ['value', 'min', 'max'],
|
|
1212
|
+
'u-input': ['value'],
|
|
1213
|
+
'van-fieldinput': ['value'],
|
|
1214
|
+
'van-stepper-new': ['value', 'min', 'max'],
|
|
1215
|
+
}
|
|
1216
|
+
if (tags[element.tag] && tags[element.tag].includes(currentNode.name)) {
|
|
1217
|
+
diagnostic.severity = 'warning';
|
|
1218
|
+
if (diagnostic.node?.tsErrorDetail) {
|
|
1219
|
+
// 重置组件节点上的错误信息
|
|
1220
|
+
diagnostic.node.tsErrorDetail.severity = 'warning';
|
|
1221
|
+
}
|
|
1222
|
+
record.suggestionDiagnostics.push(diagnostic);
|
|
1223
|
+
return null;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1179
1227
|
while (currentNode && currentNode?.parentNode?.concept !== 'App') {
|
|
1180
1228
|
if (currentNode.parentKey?.toLowerCase()?.includes('playground')) {
|
|
1181
1229
|
// 草稿区降级
|
|
@@ -1828,7 +1876,9 @@ class NaslServer {
|
|
|
1828
1876
|
try {
|
|
1829
1877
|
jsCode = nodeIn.toJS();
|
|
1830
1878
|
} catch (err) {
|
|
1831
|
-
|
|
1879
|
+
if (utils.isDebugMode) {
|
|
1880
|
+
self.logger.error(err);
|
|
1881
|
+
}
|
|
1832
1882
|
}
|
|
1833
1883
|
if (!jsCode.startsWith(`${node.name} = `)) return;
|
|
1834
1884
|
// 页面局部变量
|
|
@@ -2187,6 +2237,20 @@ class NaslServer {
|
|
|
2187
2237
|
typeAnnotationErrorDetail.errorPos.scale = errorMsg;
|
|
2188
2238
|
}
|
|
2189
2239
|
}
|
|
2240
|
+
if(property.defaultValue?.expression?.concept === 'NumericLiteral') {
|
|
2241
|
+
const numeric = property.defaultValue.expression as NumericLiteral;
|
|
2242
|
+
const value = numeric.value;
|
|
2243
|
+
const decimalPlaces = value?.split('.')[1]?.length || 0;
|
|
2244
|
+
if(decimalPlaces > +scale) {
|
|
2245
|
+
const diag: any = {
|
|
2246
|
+
node: property,
|
|
2247
|
+
severity: 'error',
|
|
2248
|
+
message: `实体字段${property.name}默认值的小数位数不能大于设置的小数位数${scale}`,
|
|
2249
|
+
};
|
|
2250
|
+
diagnostics.push(diag);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2190
2254
|
break;
|
|
2191
2255
|
}
|
|
2192
2256
|
}
|
|
@@ -2363,6 +2427,13 @@ class NaslServer {
|
|
|
2363
2427
|
if (jsCode.startsWith(`${node.name} = `)) {
|
|
2364
2428
|
used = true;
|
|
2365
2429
|
if (!nodeIn.tsErrorDetail) {
|
|
2430
|
+
// 如果要加报错的时候,当前赋值或者批量复制,属于子逻辑的
|
|
2431
|
+
// 但是没有类型的参数 或者返回值,不是 属于他的
|
|
2432
|
+
// 就不加了,只有是子逻辑,而且是自己的参数没类型才加
|
|
2433
|
+
const isSubLogic = nodeIn?.getAncestor('SubLogic');
|
|
2434
|
+
if (isSubLogic && isSubLogic !== node.parentNode) {
|
|
2435
|
+
return;
|
|
2436
|
+
}
|
|
2366
2437
|
const diagnostic = {
|
|
2367
2438
|
node: nodeIn,
|
|
2368
2439
|
severity: 'error',
|
|
@@ -2423,6 +2494,47 @@ class NaslServer {
|
|
|
2423
2494
|
yield* utils.wrapIteratorToGenerator(fileNode.sourceMap.entries(), ([node, value]) => {
|
|
2424
2495
|
this.checkNodeError(node, diagnostics);
|
|
2425
2496
|
});
|
|
2497
|
+
} else if (fileNode instanceof ProcessV2) {
|
|
2498
|
+
yield* utils.wrapIteratorToGenerator(fileNode.sourceMap.entries(), function* wrapIterator([node, value]) {
|
|
2499
|
+
if (node instanceof Return || node instanceof Variable) {
|
|
2500
|
+
const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
|
|
2501
|
+
if (!node.typeAnnotation && !node.__TypeAnnotation) {
|
|
2502
|
+
let used = false;
|
|
2503
|
+
fileNode?.sourceMap.forEach((valueIn, nodeIn) => {
|
|
2504
|
+
if (!used && nodeIn && (nodeIn instanceof BatchAssignment || (nodeIn instanceof Assignment && nodeIn.left?.name))) {
|
|
2505
|
+
let jsCode = '';
|
|
2506
|
+
try {
|
|
2507
|
+
jsCode = nodeIn.toJS();
|
|
2508
|
+
} catch (err) {
|
|
2509
|
+
self.logger.error(err);
|
|
2510
|
+
}
|
|
2511
|
+
if (jsCode.startsWith(`${node.name} = `)) {
|
|
2512
|
+
used = true;
|
|
2513
|
+
if (!nodeIn.tsErrorDetail) {
|
|
2514
|
+
const diagnostic = {
|
|
2515
|
+
node: nodeIn,
|
|
2516
|
+
severity: 'error',
|
|
2517
|
+
message: `${nodeIn.label || ''}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
|
|
2518
|
+
};
|
|
2519
|
+
nodeIn.tsErrorDetail = diagnostic;
|
|
2520
|
+
diagnostics.push(diagnostic);
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
});
|
|
2525
|
+
const msg = used ? '必须赋值有返回值的内容。' : '未设置类型或未赋值。直接赋值系统可以自动推断类型。';
|
|
2526
|
+
const diagnostic = {
|
|
2527
|
+
node,
|
|
2528
|
+
severity: 'error',
|
|
2529
|
+
message: `${nodeTypeName} ${node.name} ${msg}`,
|
|
2530
|
+
};
|
|
2531
|
+
node.__aStructureError = diagnostic;
|
|
2532
|
+
diagnostics.push(diagnostic);
|
|
2533
|
+
} else {
|
|
2534
|
+
node.__aStructureError = null;
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
});
|
|
2426
2538
|
} else if (fileNode instanceof Connection) {
|
|
2427
2539
|
const connectorPropertyNames = NaslServer.getPropertyNames(fileNode);
|
|
2428
2540
|
const connectionPropertyNames = NaslServer.getPropertyNames(fileNode?.connector);
|
|
@@ -2502,6 +2614,74 @@ class NaslServer {
|
|
|
2502
2614
|
})
|
|
2503
2615
|
}
|
|
2504
2616
|
|
|
2617
|
+
// TODO need reset when process support hoc & spread param & type annotation
|
|
2618
|
+
const isInProcess = fileNode instanceof Process ||
|
|
2619
|
+
fileNode instanceof ProcessV2 ||
|
|
2620
|
+
!!fileNode?.getAncestor('Process') ||
|
|
2621
|
+
!!fileNode?.getAncestor('ProcessV2');
|
|
2622
|
+
if (isInProcess) {
|
|
2623
|
+
// 查找计算过 subLogic 的节点。(目前只有 Logic、ProcessElement、ProcessElementV2)
|
|
2624
|
+
let targetNode: Process | ProcessV2 = fileNode as | Process | ProcessV2;
|
|
2625
|
+
if (
|
|
2626
|
+
isProcess(fileNode) ||
|
|
2627
|
+
isProcessV2(fileNode)
|
|
2628
|
+
) {
|
|
2629
|
+
targetNode = fileNode;
|
|
2630
|
+
} else {
|
|
2631
|
+
targetNode = fileNode.getAncestor('Process') as Process || fileNode.getAncestor('ProcessV2') as ProcessV2;
|
|
2632
|
+
}
|
|
2633
|
+
if (targetNode?.subLogics?.length) {
|
|
2634
|
+
const diagnostic = {
|
|
2635
|
+
node: fileNode,
|
|
2636
|
+
severity: 'error',
|
|
2637
|
+
message: `流程暂不支持子逻辑`,
|
|
2638
|
+
// 保留原来的内容方便查询一些问题
|
|
2639
|
+
originalDiagnostic: {
|
|
2640
|
+
fileName: '',
|
|
2641
|
+
start: <any>null,
|
|
2642
|
+
end: <any>null,
|
|
2643
|
+
category: 'error',
|
|
2644
|
+
text: `process not support subLogic`,
|
|
2645
|
+
},
|
|
2646
|
+
};
|
|
2647
|
+
diagnostics.push(diagnostic);
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
if (targetNode.includeSpreadCallLogic) {
|
|
2651
|
+
const diagnostic = {
|
|
2652
|
+
node: fileNode,
|
|
2653
|
+
severity: 'error',
|
|
2654
|
+
message: `流程暂不支持可变参数`,
|
|
2655
|
+
// 保留原来的内容方便查询一些问题
|
|
2656
|
+
originalDiagnostic: {
|
|
2657
|
+
fileName: '',
|
|
2658
|
+
start: <any>null,
|
|
2659
|
+
end: <any>null,
|
|
2660
|
+
category: 'error',
|
|
2661
|
+
text: `process not support spread call`,
|
|
2662
|
+
},
|
|
2663
|
+
};
|
|
2664
|
+
diagnostics.push(diagnostic);
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
if (targetNode.includeTypeArgs) {
|
|
2668
|
+
const diagnostic = {
|
|
2669
|
+
node: fileNode,
|
|
2670
|
+
severity: 'error',
|
|
2671
|
+
message: `流程暂不支持范型参数`,
|
|
2672
|
+
// 保留原来的内容方便查询一些问题
|
|
2673
|
+
originalDiagnostic: {
|
|
2674
|
+
fileName: '',
|
|
2675
|
+
start: <any>null,
|
|
2676
|
+
end: <any>null,
|
|
2677
|
+
category: 'error',
|
|
2678
|
+
text: `process not support type args`,
|
|
2679
|
+
},
|
|
2680
|
+
};
|
|
2681
|
+
diagnostics.push(diagnostic);
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2505
2685
|
return diagnostics;
|
|
2506
2686
|
}
|
|
2507
2687
|
|
|
@@ -2799,11 +2979,27 @@ class NaslServer {
|
|
|
2799
2979
|
}
|
|
2800
2980
|
}
|
|
2801
2981
|
}
|
|
2982
|
+
|
|
2983
|
+
// 加上信用卡验证规则的静态检查
|
|
2984
|
+
if (node instanceof ValidationRule && node.calleeName === 'creditCard') {
|
|
2985
|
+
const typesArg = node.arguments?.find((arg) => {
|
|
2986
|
+
return arg?.keyword === 'types';
|
|
2987
|
+
});
|
|
2988
|
+
if (typesArg?.expression?.concept !== 'NewList' || !((typesArg?.expression as NewList)?.items?.length)) {
|
|
2989
|
+
const diagnostic = {
|
|
2990
|
+
node: typesArg?.expression,
|
|
2991
|
+
severity: 'error',
|
|
2992
|
+
message: '至少选择1项验证信用卡',
|
|
2993
|
+
};
|
|
2994
|
+
typesArg.expression.tsErrorDetail = diagnostic;
|
|
2995
|
+
diagnostics.push(diagnostic);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2802
2998
|
if (node instanceof CallLogic) {
|
|
2803
2999
|
// 处理依赖库高阶函数,函数签名和函数调用参数要完全一一对应
|
|
2804
3000
|
if (node.calleeNamespace?.startsWith('extensions.')) {
|
|
2805
3001
|
const logicNode = node.getCallNode();
|
|
2806
|
-
const params = logicNode?.params?.slice();
|
|
3002
|
+
const params = logicNode?.params?.slice() || [];
|
|
2807
3003
|
const findFunction = params.find(param => param?.typeAnnotation?.typeKind === 'function');
|
|
2808
3004
|
if (findFunction) {
|
|
2809
3005
|
node.arguments?.forEach((argument, index) => {
|
|
@@ -3248,7 +3444,9 @@ class NaslServer {
|
|
|
3248
3444
|
}
|
|
3249
3445
|
}
|
|
3250
3446
|
} catch (e) {
|
|
3251
|
-
|
|
3447
|
+
if (utils.isDebugMode) {
|
|
3448
|
+
this.logger.error('naslServer实体引用', e);
|
|
3449
|
+
}
|
|
3252
3450
|
}
|
|
3253
3451
|
}
|
|
3254
3452
|
}
|
|
@@ -3571,8 +3769,12 @@ class NaslServer {
|
|
|
3571
3769
|
// return null;
|
|
3572
3770
|
// }
|
|
3573
3771
|
}
|
|
3574
|
-
//
|
|
3772
|
+
// 如果匹配到的节点是Identifier表达式
|
|
3575
3773
|
if (minRange.node instanceof Identifier) {
|
|
3774
|
+
// 如果参数修改影响了Identifier, 就说明是上一级逻辑的引用,所以就直接过滤掉就好了
|
|
3775
|
+
if (node instanceof Param && minRange.node?.namespace?.endsWith('logics')) {
|
|
3776
|
+
return null;
|
|
3777
|
+
}
|
|
3576
3778
|
// 匹配到的内容,当前这一行的内容;
|
|
3577
3779
|
// 因为要用下面的点位信息
|
|
3578
3780
|
const {name} = minRange.node;
|
|
@@ -3675,7 +3877,9 @@ class NaslServer {
|
|
|
3675
3877
|
minRange.setTypeMethods = 'setValue';
|
|
3676
3878
|
}
|
|
3677
3879
|
} catch (error) {
|
|
3678
|
-
|
|
3880
|
+
if (utils.isDebugMode) {
|
|
3881
|
+
this.logger.error(error);
|
|
3882
|
+
}
|
|
3679
3883
|
}
|
|
3680
3884
|
} else if (minRange.node instanceof Identifier) {
|
|
3681
3885
|
minRange.newValue = utils.firstLowerCase(newValue);
|
|
@@ -4061,7 +4265,9 @@ class NaslServer {
|
|
|
4061
4265
|
result = this.handleTreeMap(resMap);
|
|
4062
4266
|
}
|
|
4063
4267
|
} catch (err) {
|
|
4064
|
-
|
|
4268
|
+
if (utils.isDebugMode) {
|
|
4269
|
+
this.logger.error(err);
|
|
4270
|
+
}
|
|
4065
4271
|
}
|
|
4066
4272
|
return result;
|
|
4067
4273
|
}
|
|
@@ -4087,7 +4293,9 @@ class NaslServer {
|
|
|
4087
4293
|
result.add(minRange.node);
|
|
4088
4294
|
});
|
|
4089
4295
|
} catch (err) {
|
|
4090
|
-
|
|
4296
|
+
if (utils.isDebugMode) {
|
|
4297
|
+
this.logger.error(err);
|
|
4298
|
+
}
|
|
4091
4299
|
}
|
|
4092
4300
|
return [...result];
|
|
4093
4301
|
}
|
|
@@ -4595,25 +4803,22 @@ class NaslServer {
|
|
|
4595
4803
|
node.completeTypeParams?.length &&
|
|
4596
4804
|
(node as any)?.__nodeType
|
|
4597
4805
|
) {
|
|
4598
|
-
const logicNode = node.getCallNode();
|
|
4599
4806
|
const autoTypeArguments = (node as any).__nodeType?.typeArguments || [];
|
|
4600
4807
|
const newAutoTypeArguments = [...autoTypeArguments];
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
if (
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
returnType.typeArguments = typeArguments.filter((t: any) => t !== errorType);
|
|
4612
|
-
}
|
|
4808
|
+
let returnType = newAutoTypeArguments.shift();
|
|
4809
|
+
if (node.handleError && returnType.typeName === 'Union') {
|
|
4810
|
+
const returnTypeArguments = returnType.typeArguments || [];
|
|
4811
|
+
const typeArguments = [...returnTypeArguments];
|
|
4812
|
+
const errorType = typeArguments.find((t: any) => t.typeName === 'Error');
|
|
4813
|
+
if (errorType) {
|
|
4814
|
+
if (typeArguments.length === 2) {
|
|
4815
|
+
returnType = typeArguments.filter((t: any) => t !== errorType)[0];
|
|
4816
|
+
} else {
|
|
4817
|
+
returnType.typeArguments = typeArguments.filter((t: any) => t !== errorType);
|
|
4613
4818
|
}
|
|
4614
4819
|
}
|
|
4615
|
-
node.__TypeAnnotation = utils.runGeneratorSync(type2TypeAnnotation(returnType));
|
|
4616
4820
|
}
|
|
4821
|
+
node.__TypeAnnotation = utils.runGeneratorSync(type2TypeAnnotation(returnType));
|
|
4617
4822
|
|
|
4618
4823
|
const typeArgs: any[] = [];
|
|
4619
4824
|
const typeArguments = node.typeArguments;
|
|
@@ -4670,8 +4875,8 @@ class NaslServer {
|
|
|
4670
4875
|
|
|
4671
4876
|
this.logger.timeEnd('全量标注');
|
|
4672
4877
|
|
|
4673
|
-
//
|
|
4674
|
-
if (utils.isTestBrowser) {
|
|
4878
|
+
// 测试环境或者是调试模式打印数据
|
|
4879
|
+
if (utils.isDebugMode || utils.isTestBrowser) {
|
|
4675
4880
|
this.logger.info('全量标注数据', json);
|
|
4676
4881
|
}
|
|
4677
4882
|
|
|
@@ -4847,8 +5052,70 @@ class NaslServer {
|
|
|
4847
5052
|
*/
|
|
4848
5053
|
if (node instanceof CallLogic && node.__TypeArguments?.length) {
|
|
4849
5054
|
const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
4850
|
-
jsonNode.typeArguments = node.__TypeArguments;
|
|
4851
|
-
jsonNode.typeAnnotation = node.__TypeAnnotation;
|
|
5055
|
+
jsonNode.typeArguments = node.__TypeArguments.map((type) => type?.toJSON());
|
|
5056
|
+
jsonNode.typeAnnotation = node.__TypeAnnotation?.toJSON();
|
|
5057
|
+
}
|
|
5058
|
+
|
|
5059
|
+
// 根据 https://projectmanage.netease-official.lcap.163yun.com/dashboard/FeatureDetail?id=2737356895760128&id1=null&iterationId=null&versionid=null&tab=info
|
|
5060
|
+
// 对CallFunction节点,若其callee为部分List/Map内置函数,则修改其argument类型标注以让服务端据此插入显式的类型转换。规则如下:
|
|
5061
|
+
// - 对argument.expression.typeAnnotation 无需做修改,保持为其实际类型
|
|
5062
|
+
// - 对argument.typeAnnotation,为根据对应Collection的泛型参数的类型填写其类型
|
|
5063
|
+
if (node instanceof CallFunction) {
|
|
5064
|
+
if (node.calleeNamespace === 'nasl.util') {
|
|
5065
|
+
const calleeName = node.calleeName;
|
|
5066
|
+
const listFunctionParamIndexMaps = new Map(
|
|
5067
|
+
Object.entries({
|
|
5068
|
+
Add: { collection: 0, item: 1 },
|
|
5069
|
+
Insert: { collection: 0, item: 2 },
|
|
5070
|
+
Remove: { collection: 0, item: 1 },
|
|
5071
|
+
Contains: { collection: 0, item: 1 },
|
|
5072
|
+
})
|
|
5073
|
+
);
|
|
5074
|
+
const mapFunctionParamIndexMaps = new Map(
|
|
5075
|
+
Object.entries({
|
|
5076
|
+
MapPut: { collection: 0, key: 1, value: 2 },
|
|
5077
|
+
MapGet: { collection: 0, key: 1, },
|
|
5078
|
+
MapRemove: { collection: 0, key: 1 },
|
|
5079
|
+
MapContains: { collection: 0, key: 1 },
|
|
5080
|
+
})
|
|
5081
|
+
);
|
|
5082
|
+
const listParamIndex = listFunctionParamIndexMaps.get(calleeName);
|
|
5083
|
+
if (listParamIndex) {
|
|
5084
|
+
const list = node.arguments[listParamIndex.collection];
|
|
5085
|
+
const item = node.arguments[listParamIndex.item];
|
|
5086
|
+
const itemExpression = item?.expression;
|
|
5087
|
+
if (itemExpression) {
|
|
5088
|
+
const listTypeArgument = list.__TypeAnnotation?.typeArguments?.[0]?.toJSON();
|
|
5089
|
+
if (listTypeArgument) {
|
|
5090
|
+
const jsonNode = jsoner.queryNodeByPath(json, item.getNodePath(false));
|
|
5091
|
+
jsonNode.typeAnnotation = listTypeArgument;
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5094
|
+
} else {
|
|
5095
|
+
const mapParamIndex = mapFunctionParamIndexMaps.get(calleeName);
|
|
5096
|
+
if(mapParamIndex){
|
|
5097
|
+
const map = node.arguments[mapParamIndex.collection];
|
|
5098
|
+
const key = node.arguments[mapParamIndex.key];
|
|
5099
|
+
const value = node.arguments[mapParamIndex.value];
|
|
5100
|
+
const keyExpression = key?.expression;
|
|
5101
|
+
const valueExpression = value?.expression;
|
|
5102
|
+
if (keyExpression) {
|
|
5103
|
+
const mapKeyTypeArgument = map.__TypeAnnotation?.typeArguments?.[0]?.toJSON();
|
|
5104
|
+
if (mapKeyTypeArgument) {
|
|
5105
|
+
const jsonNode = jsoner.queryNodeByPath(json, key.getNodePath(false));
|
|
5106
|
+
jsonNode.typeAnnotation = mapKeyTypeArgument;
|
|
5107
|
+
}
|
|
5108
|
+
}
|
|
5109
|
+
if (valueExpression) {
|
|
5110
|
+
const mapValueTypeArgument = map.__TypeAnnotation?.typeArguments?.[1]?.toJSON();
|
|
5111
|
+
if (mapValueTypeArgument) {
|
|
5112
|
+
const jsonNode = jsoner.queryNodeByPath(json, value.getNodePath(false));
|
|
5113
|
+
jsonNode.typeAnnotation = mapValueTypeArgument;
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
4852
5119
|
}
|
|
4853
5120
|
}
|
|
4854
5121
|
|
|
@@ -4916,7 +5183,9 @@ class NaslServer {
|
|
|
4916
5183
|
}
|
|
4917
5184
|
return new Promise((resolve, reject) => {
|
|
4918
5185
|
const myTimer = setTimeout(() => {
|
|
4919
|
-
|
|
5186
|
+
if (utils.isDebugMode) {
|
|
5187
|
+
this.logger.warn(node, '没有获取到类型');
|
|
5188
|
+
}
|
|
4920
5189
|
clearTimeout(myTimer);
|
|
4921
5190
|
clearInterval(mySetInterval);
|
|
4922
5191
|
if (node.__isCorrectTypeAnnotation) {
|
package/src/server/translator.ts
CHANGED
|
@@ -73,7 +73,7 @@ export interface MinRange {
|
|
|
73
73
|
const mapAstString = new Map();
|
|
74
74
|
|
|
75
75
|
function transformType(tsType: string): string {
|
|
76
|
-
if (tsType === 'string' || tsType === 'String') return '字符串';
|
|
76
|
+
if (tsType === 'string' || tsType === 'String' || /StringLiteral<['"].*['"]>/.test(tsType)) return '字符串';
|
|
77
77
|
else if (tsType === 'number') return '数字';
|
|
78
78
|
else if (tsType === 'Integer') return '整数';
|
|
79
79
|
else if (tsType === 'Double') return '小数';
|
|
@@ -324,6 +324,10 @@ const TS_RULES: Array<{
|
|
|
324
324
|
re: /Cannot find name '__ValidationRule__'./,
|
|
325
325
|
result: '校验规则不能为空',
|
|
326
326
|
},
|
|
327
|
+
{
|
|
328
|
+
re: /Cannot find name '__UNCERTAIN__INTERMEDIATE__FIELDS__'./,
|
|
329
|
+
result: '来自不确定结构或实体的字段',
|
|
330
|
+
},
|
|
327
331
|
{
|
|
328
332
|
re: /No value exists in scope for the shorthand property '__(?:IDENTIFIER|LEFT|RIGHT)__'. Either declare one or provide an initializer./,
|
|
329
333
|
result: '用户任务未关联页面',
|
|
@@ -246,25 +246,12 @@ function genSubmitLogic(createLogic: Logic, nameGroup: NameGroup, extendConseque
|
|
|
246
246
|
name: nameGroup.viewLogicSubmit,
|
|
247
247
|
params: [],
|
|
248
248
|
returns: [],
|
|
249
|
-
variables: [
|
|
250
|
-
NaslNode.Variable({
|
|
251
|
-
name: 'validateResult',
|
|
252
|
-
typeAnnotation: NaslUITypeAnnotation.ValidateEvent,
|
|
253
|
-
}),
|
|
254
|
-
],
|
|
249
|
+
variables: [],
|
|
255
250
|
body: [
|
|
256
251
|
NaslLogicItem.Start,
|
|
257
|
-
NaslLogicItem.Assignment({
|
|
258
|
-
left: NaslLogicItem.Identifier({
|
|
259
|
-
name: 'validateResult',
|
|
260
|
-
}),
|
|
261
|
-
right: genCallComponentLogic(nameGroup.viewElementMainView, 'validate'),
|
|
262
|
-
}),
|
|
263
252
|
NaslLogicItem.IfStatement({
|
|
264
253
|
test: NaslLogicItem.MemberExpression({
|
|
265
|
-
object:
|
|
266
|
-
name: 'validateResult',
|
|
267
|
-
}),
|
|
254
|
+
object: genCallComponentLogic(nameGroup.viewElementMainView, 'validate'),
|
|
268
255
|
property: NaslLogicItem.Identifier({
|
|
269
256
|
name: 'valid',
|
|
270
257
|
}),
|
|
@@ -497,7 +484,7 @@ export function genCreateBlock(entity: Entity, oldNode: ViewElement, appointKeys
|
|
|
497
484
|
}
|
|
498
485
|
let viewBindEvents = '';
|
|
499
486
|
let viewLoadLogic;
|
|
500
|
-
if(localTemplate
|
|
487
|
+
if(localTemplate?.genCreatedHandler) {
|
|
501
488
|
nameGroup.viewLogicCreated = likeComponent.getLogicUniqueName('load');
|
|
502
489
|
viewLoadLogic = localTemplate.genCreatedHandler(entity, nameGroup)
|
|
503
490
|
viewBindEvents = `
|
|
@@ -512,8 +499,8 @@ export function genCreateBlock(entity: Entity, oldNode: ViewElement, appointKeys
|
|
|
512
499
|
]`
|
|
513
500
|
}
|
|
514
501
|
|
|
515
|
-
const submitLogic = (localTemplate
|
|
516
|
-
const genTemplate = localTemplate
|
|
502
|
+
const submitLogic = (localTemplate?.genSubmitLogicLocal || genSubmitLogic)(createLogic, nameGroup, extendConsequent);
|
|
503
|
+
const genTemplate = localTemplate?.genCreateTemplate || ((frontendType || config.scope) === 'h5' ? genH5CreateFormTemplate : genCreateFormTemplate);
|
|
517
504
|
return `<template>
|
|
518
505
|
${genTemplate(entity, nameGroup, selectNameGroupMap, appointKeys, process, extra)}
|
|
519
506
|
</template>
|
|
@@ -324,25 +324,12 @@ export function genSubmitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
324
324
|
name: nameGroup.viewLogicSubmit,
|
|
325
325
|
params: [] as any[],
|
|
326
326
|
returns: [] as any[],
|
|
327
|
-
variables: [
|
|
328
|
-
NaslNode.Variable({
|
|
329
|
-
name: 'validateResult',
|
|
330
|
-
typeAnnotation: NaslUITypeAnnotation.ValidateEvent,
|
|
331
|
-
}),
|
|
332
|
-
],
|
|
327
|
+
variables: [],
|
|
333
328
|
body: [
|
|
334
329
|
NaslLogicItem.Start,
|
|
335
|
-
NaslLogicItem.Assignment({
|
|
336
|
-
left: NaslLogicItem.Identifier({
|
|
337
|
-
name: 'validateResult',
|
|
338
|
-
}),
|
|
339
|
-
right: genCallComponentLogic(nameGroup.viewElementSaveModalForm, 'validate'),
|
|
340
|
-
}),
|
|
341
330
|
NaslLogicItem.IfStatement({
|
|
342
331
|
test: NaslLogicItem.MemberExpression({
|
|
343
|
-
object:
|
|
344
|
-
name: 'validateResult',
|
|
345
|
-
}),
|
|
332
|
+
object: genCallComponentLogic(nameGroup.viewElementSaveModalForm, 'validate'),
|
|
346
333
|
property: NaslLogicItem.Identifier({
|
|
347
334
|
name: 'valid',
|
|
348
335
|
}),
|
|
@@ -372,25 +359,12 @@ export function genUpdateSubmitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
372
359
|
name: nameGroup.viewLogicUpdateSubmit,
|
|
373
360
|
params: [] as any[],
|
|
374
361
|
returns: [] as any[],
|
|
375
|
-
variables: [
|
|
376
|
-
NaslNode.Variable({
|
|
377
|
-
name: 'validateResult',
|
|
378
|
-
typeAnnotation: NaslUITypeAnnotation.ValidateEvent,
|
|
379
|
-
}),
|
|
380
|
-
],
|
|
362
|
+
variables: [],
|
|
381
363
|
body: [
|
|
382
364
|
NaslLogicItem.Start,
|
|
383
|
-
NaslLogicItem.Assignment({
|
|
384
|
-
left: NaslLogicItem.Identifier({
|
|
385
|
-
name: 'validateResult',
|
|
386
|
-
}),
|
|
387
|
-
right: genCallComponentLogic(nameGroup.viewElementSaveModalForm, 'validate'),
|
|
388
|
-
}),
|
|
389
365
|
NaslLogicItem.IfStatement({
|
|
390
366
|
test: NaslLogicItem.MemberExpression({
|
|
391
|
-
object:
|
|
392
|
-
name: 'validateResult',
|
|
393
|
-
}),
|
|
367
|
+
object: genCallComponentLogic(nameGroup.viewElementSaveModalForm, 'validate'),
|
|
394
368
|
property: NaslLogicItem.Identifier({
|
|
395
369
|
name: 'valid',
|
|
396
370
|
}),
|
|
@@ -994,10 +968,10 @@ function genDelModalSubmitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
994
968
|
export function genFilterTemplateTableDesigner(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>, optionsMap?: any, dataSourcesMap?: any) {
|
|
995
969
|
const dataSource = entity.parentNode as DataSource;
|
|
996
970
|
const properties = entity.properties.filter(filterProperty('inFilter')).filter((it) => it?.typeAnnotation?.typeName !== 'List');
|
|
997
|
-
const getCol = (code: string) => `<u-grid-layout-column span="6" style="padding: 10px 0;">${code}</u-grid-layout-column>`;
|
|
971
|
+
const getCol = (code: string) => `<u-grid-layout-column :span="6" style="padding: 10px 0;">${code}</u-grid-layout-column>`;
|
|
998
972
|
return `<u-form style="margin-bottom: 6px;padding: 15px 15px 5px 15px;background: #fff;">
|
|
999
973
|
<u-grid-layout>
|
|
1000
|
-
<u-grid-layout-row repeat="24">
|
|
974
|
+
<u-grid-layout-row :repeat="24">
|
|
1001
975
|
${properties
|
|
1002
976
|
.map((property) => {
|
|
1003
977
|
const vModel = `${nameGroup.viewVariableFilter}.${property.name}`;
|
|
@@ -1209,6 +1183,14 @@ function genSaveModalTemplateDesigner(
|
|
|
1209
1183
|
'<u-form',
|
|
1210
1184
|
`<u-form ref="${nameGroup.viewElementSaveModalForm}" :preview="${nameGroup.viewVariablePreview}" `
|
|
1211
1185
|
);
|
|
1186
|
+
const hasUploader = SaveModalFormTemplate && SaveModalFormTemplate.indexOf('u-uploader') > -1;
|
|
1187
|
+
if (hasUploader) {
|
|
1188
|
+
// 文件上传组件绑定预览属性, todo: 表单中各类组件的预览属性绑定
|
|
1189
|
+
SaveModalFormTemplate = SaveModalFormTemplate.replaceAll(
|
|
1190
|
+
'<u-uploader',
|
|
1191
|
+
'<u-uploader :preview="preview"'
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1212
1194
|
}
|
|
1213
1195
|
|
|
1214
1196
|
return `
|