@lcap/nasl 3.5.0-beta.4 → 3.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/bak/translator.js +39 -119
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/generator/BreakpointNode.d.ts +0 -3
- package/out/breakpoint/generator/BreakpointNode.js +0 -9
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
- package/out/breakpoint/shared/constants.js +0 -1
- package/out/breakpoint/shared/constants.js.map +1 -1
- package/out/breakpoint/shared/utils.js +7 -31
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/BaseNode.d.ts +13 -1
- package/out/common/BaseNode.js +52 -23
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.js +1 -0
- package/out/common/Command.js.map +1 -1
- package/out/common/EventEmitter.d.ts +1 -1
- package/out/common/EventEmitter.js +0 -4
- package/out/common/EventEmitter.js.map +1 -1
- package/out/concepts/App__.d.ts +76 -51
- package/out/concepts/App__.js +190 -87
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +2 -10
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +6 -16
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +0 -1
- package/out/concepts/BindDirective__.js +4 -19
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +1 -3
- package/out/concepts/BindEvent__.js +13 -38
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.js +2 -10
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +0 -2
- package/out/concepts/CallLogic__.js +27 -38
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Constant__.js +6 -7
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +4 -6
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +1 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -1
- package/out/concepts/Entity__.js +2 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Event__.d.ts +0 -14
- package/out/concepts/Event__.js +0 -61
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +88 -0
- package/out/concepts/Frontend__.js +143 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +0 -5
- package/out/concepts/Identifier__.js +9 -19
- package/out/concepts/Identifier__.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 +1 -3
- package/out/concepts/Logic__.js +13 -16
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -1
- package/out/concepts/MemberExpression__.js +3 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/Param__.js +3 -11
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +1 -9
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Return__.js +9 -17
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Variable__.js +8 -17
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -17
- package/out/concepts/ViewElement__.js +31 -143
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +6 -6
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -5
- package/out/concepts/index__.js +0 -5
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +3 -258
- package/out/concepts/utils/asserts.js +13 -351
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +3 -20
- package/out/generator/genBundleFiles.js +11 -25
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +3 -12
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/natural/transformTSCode.js +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +22 -6
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +27 -62
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +1 -6
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.js +11 -28
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +1 -6
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +26 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.d.ts +27 -0
- package/out/templator/genCurdMultipleKeyBlock.js +709 -37
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -4
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +12 -12
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +4 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +3 -3
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +2 -0
- package/out/templator/genTableBlock.js +124 -11
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +8 -8
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/translator/utils.js +18 -0
- package/out/translator/utils.js.map +1 -1
- package/out/utils/i18nInfo.js +2 -7
- package/out/utils/i18nInfo.js.map +1 -1
- package/package.json +2 -2
- package/src/bak/translator.js +43 -121
- package/src/breakpoint/generator/BreakpointNode.ts +0 -12
- package/src/breakpoint/shared/constants.ts +0 -1
- package/src/breakpoint/shared/utils.ts +10 -37
- package/src/common/BaseNode.ts +60 -22
- package/src/common/Command.ts +1 -0
- package/src/common/EventEmitter.ts +1 -6
- package/src/concepts/App__.ts +251 -139
- package/src/concepts/BackendVariable__.ts +2 -10
- package/src/concepts/BindAttribute__.ts +6 -15
- package/src/concepts/BindDirective__.ts +4 -19
- package/src/concepts/BindEvent__.ts +12 -40
- package/src/concepts/CallFunction__.ts +2 -10
- package/src/concepts/CallLogic__.ts +32 -45
- package/src/concepts/Constant__.ts +7 -5
- package/src/concepts/Destination__.ts +4 -6
- package/src/concepts/End__.ts +0 -1
- package/src/concepts/Entity__.ts +3 -1
- package/src/concepts/Event__.ts +0 -70
- package/src/concepts/Frontend__.ts +251 -3
- package/src/concepts/Identifier__.ts +13 -29
- package/src/concepts/LogicItem__.ts +0 -1
- package/src/concepts/Logic__.ts +14 -21
- package/src/concepts/MemberExpression__.ts +3 -3
- package/src/concepts/NewComposite__.ts +6 -4
- package/src/concepts/Param__.ts +3 -11
- package/src/concepts/ProcessElement__.ts +1 -8
- package/src/concepts/Return__.ts +12 -15
- package/src/concepts/Variable__.ts +9 -17
- package/src/concepts/ViewElement__.ts +54 -166
- package/src/concepts/View__.ts +6 -8
- package/src/concepts/index__.ts +0 -5
- package/src/concepts/utils/asserts.ts +4 -367
- package/src/concepts/utils/types.ts +0 -28
- package/src/generator/genBundleFiles.ts +15 -33
- package/src/generator/genReleaseBody.ts +3 -14
- package/src/generator/permission.ts +6 -8
- package/src/natural/transformTSCode.ts +1 -1
- package/src/server/extendBaseNode.ts +41 -22
- package/src/server/getLogics.ts +41 -79
- package/src/server/getMemberIdentifier.ts +1 -7
- package/src/server/naslServer.ts +12 -30
- package/src/server/translator.ts +1 -7
- package/src/service/storage/init.ts +33 -2
- package/src/templator/genCreateBlock.ts +6 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
- package/src/templator/genCurdMultipleKeyBlock.ts +817 -93
- package/src/templator/genGetBlock.ts +4 -4
- package/src/templator/genGridViewBlock.ts +12 -12
- package/src/templator/genListViewBlock.ts +4 -4
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +137 -12
- package/src/templator/genUpdateBlock.ts +8 -8
- package/src/templator/utils.ts +2 -2
- package/src/translator/utils.ts +20 -0
- package/src/utils/i18nInfo.ts +2 -7
- package/test/concepts/call-function/fixtures/from-string.json +59 -68
- package/test/concepts/call-function/fixtures/to-string-global-tz.json +58 -67
- package/test/concepts/call-function/fixtures/to-string-no-tz.json +48 -57
- package/test/concepts/call-function/fixtures/to-string-user-tz.json +60 -69
- package/test/concepts/call-function/fixtures/to-string-utc-tz.json +60 -69
- package/test/concepts/call-interface/fixtures/only-interface.json +72 -81
- package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +214 -223
- package/test/concepts/call-interface/fixtures/with-body-no-argument.json +76 -85
- package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +91 -100
- package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +79 -88
- package/test/concepts/call-interface/fixtures/with-headers.json +81 -90
- package/test/concepts/call-interface/fixtures/with-query-no-argument.json +79 -88
- package/test/concepts/call-interface/fixtures/with-query.json +81 -90
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +2 -4
- package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +95 -104
- package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +200 -209
- package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +88 -97
- package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +115 -124
- package/test/concepts/call-logic/fixtures/json-deserialize.json +111 -120
- package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +115 -124
- package/test/concepts/call-logic/fixtures/json-serialize.json +115 -124
- package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +82 -91
- package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +79 -88
- package/test/concepts/call-logic/fixtures/view-component-with-validation.json +135 -144
- package/test/concepts/identifier/fixtures/view-variable.json +136 -145
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/fixtures/default-login.json +212 -221
- package/test/concepts/view-element/fixtures/default-not-found.json +174 -183
- package/test/concepts/view-element/fixtures/with-role-auth.json +82 -91
- package/test/concepts/view-element/fixtures/with-table.json +1834 -1843
- package/test/concepts/view-element/toVue.spec.ts +0 -1
- package/ts-worker/package.json +1 -1
- package/out/concepts/BusinessComponent__.d.ts +0 -641
- package/out/concepts/BusinessComponent__.js +0 -1901
- package/out/concepts/BusinessComponent__.js.map +0 -1
- package/out/concepts/BusinessLogic__.d.ts +0 -38
- package/out/concepts/BusinessLogic__.js +0 -358
- package/out/concepts/BusinessLogic__.js.map +0 -1
- package/out/concepts/CallEvent__.d.ts +0 -97
- package/out/concepts/CallEvent__.js +0 -263
- package/out/concepts/CallEvent__.js.map +0 -1
- package/out/concepts/FrontendType__.d.ts +0 -308
- package/out/concepts/FrontendType__.js +0 -605
- package/out/concepts/FrontendType__.js.map +0 -1
- package/out/concepts/ParamWithGroup__.d.ts +0 -39
- package/out/concepts/ParamWithGroup__.js +0 -85
- package/out/concepts/ParamWithGroup__.js.map +0 -1
- package/src/concepts/BusinessComponent__.ts +0 -2669
- package/src/concepts/BusinessLogic__.ts +0 -376
- package/src/concepts/CallEvent__.ts +0 -334
- package/src/concepts/FrontendType__.ts +0 -919
- package/src/concepts/ParamWithGroup__.ts +0 -101
|
@@ -1080,20 +1080,15 @@ export class BindAttribute extends BaseNode {
|
|
|
1080
1080
|
return str;
|
|
1081
1081
|
}
|
|
1082
1082
|
|
|
1083
|
-
|
|
1084
1083
|
@withSourceMapGenerator
|
|
1085
1084
|
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
1086
1085
|
const self = this;
|
|
1087
1086
|
const { name, type, value, rules, expression, playground } = self;
|
|
1088
1087
|
let code = '';
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
if (isBusinessComponent) {
|
|
1092
|
-
code += `${name}: `;
|
|
1093
|
-
} else if (self?.name === 'data-source' && self?.expression?.concept === 'CallLogic') {
|
|
1094
|
-
code += `() => {\n`;
|
|
1088
|
+
if (self?.name === 'data-source' && self?.expression?.concept === 'CallLogic') {
|
|
1089
|
+
code = `() => {`;
|
|
1095
1090
|
} else {
|
|
1096
|
-
code
|
|
1091
|
+
code = '() => {';
|
|
1097
1092
|
}
|
|
1098
1093
|
if (['destination', 'externalDestination'].includes(name) && type === 'dynamic') {
|
|
1099
1094
|
code += yield* (self as any)[name].toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
@@ -1105,7 +1100,7 @@ export class BindAttribute extends BaseNode {
|
|
|
1105
1100
|
});
|
|
1106
1101
|
} else if (expression) {
|
|
1107
1102
|
code += yield* expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1108
|
-
code += '
|
|
1103
|
+
code += ';\n';
|
|
1109
1104
|
} else if (name === 'url' && value) {
|
|
1110
1105
|
/**
|
|
1111
1106
|
* ls定制化处理
|
|
@@ -1131,15 +1126,13 @@ export class BindAttribute extends BaseNode {
|
|
|
1131
1126
|
code += ';\n';
|
|
1132
1127
|
}
|
|
1133
1128
|
}
|
|
1134
|
-
if (type === 'dynamic'
|
|
1129
|
+
if (type === 'dynamic') {
|
|
1135
1130
|
yield* wrapForEach(playground, function* warpForEachGenerator(item, index) {
|
|
1136
1131
|
code += yield* item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1137
1132
|
code += ';\n';
|
|
1138
1133
|
});
|
|
1139
1134
|
}
|
|
1140
|
-
|
|
1141
|
-
code += '\n}';
|
|
1142
|
-
}
|
|
1135
|
+
code += '}';
|
|
1143
1136
|
return code;
|
|
1144
1137
|
}
|
|
1145
1138
|
|
|
@@ -1175,8 +1168,6 @@ export class BindAttribute extends BaseNode {
|
|
|
1175
1168
|
type = `${self.value}`.includes('.') ? 'nasl.core.Decimal' : 'nasl.core.Long';
|
|
1176
1169
|
} else if (typeof self.value === 'boolean') {
|
|
1177
1170
|
type = 'nasl.core.Boolean';
|
|
1178
|
-
} else if (['page-size', 'page-number'].includes(self.name) && self.value === null) {
|
|
1179
|
-
type = 'nasl.core.Long'
|
|
1180
1171
|
}
|
|
1181
1172
|
code += `${type}`;
|
|
1182
1173
|
} else {
|
|
@@ -629,36 +629,21 @@ export class BindDirective extends BaseNode {
|
|
|
629
629
|
return str;
|
|
630
630
|
}
|
|
631
631
|
|
|
632
|
-
get viewElement() {
|
|
633
|
-
return this.getAncestor('ViewElement') as ViewElement;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
632
|
@withSourceMapGenerator
|
|
637
633
|
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
638
634
|
const self = this;
|
|
639
|
-
|
|
640
|
-
const isBusinessComponent = self.viewElement?.correspondingBusinessComponent;
|
|
641
|
-
let code = '';
|
|
642
|
-
if (!isBusinessComponent) {
|
|
643
|
-
code += '()=>{';
|
|
644
|
-
}
|
|
635
|
+
let code = '()=>{';
|
|
645
636
|
if (self.expression) {
|
|
646
637
|
code += yield* self.expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
647
|
-
code += '
|
|
638
|
+
code += ';\n';
|
|
648
639
|
}
|
|
649
640
|
if (self.type === 'dynamic') {
|
|
650
641
|
yield* wrapForEach(self.playground, function* warpForEachGenerator(item, index) {
|
|
651
642
|
code += yield* item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
652
|
-
if (index !== self.playground.length - 1) code += '
|
|
643
|
+
if (index !== self.playground.length - 1) code += ';\n';
|
|
653
644
|
});
|
|
654
645
|
}
|
|
655
|
-
|
|
656
|
-
if (code) {
|
|
657
|
-
code = `${self.name === 'if' ? '__NASLIF' : self.name}: ${code}`;
|
|
658
|
-
}
|
|
659
|
-
} else {
|
|
660
|
-
code += '}';
|
|
661
|
-
}
|
|
646
|
+
code += '}';
|
|
662
647
|
return code;
|
|
663
648
|
}
|
|
664
649
|
|
|
@@ -16,7 +16,6 @@ import { elementsEventsMap } from '../server/createUiTs';
|
|
|
16
16
|
import type Param from './Param__';
|
|
17
17
|
import type TypeAnnotation from './TypeAnnotation__';
|
|
18
18
|
import type Process from './Process__';
|
|
19
|
-
import type BusinessComponent from './BusinessComponent__';
|
|
20
19
|
|
|
21
20
|
//================================================================================
|
|
22
21
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -607,7 +606,7 @@ export class BindEvent extends BaseNode {
|
|
|
607
606
|
if (isPageCycle) {
|
|
608
607
|
if (['keydown', 'keyup'].includes(self.name)) {
|
|
609
608
|
code = `const ${self.toHump(self.name) || '__IDENTIFIER__'} = (event: `;
|
|
610
|
-
code +=
|
|
609
|
+
code += self.getEventTypeString();
|
|
611
610
|
code += ') => [\n';
|
|
612
611
|
yield* wrapForEach(self.logics, function* warpForEachGenerator(logic) {
|
|
613
612
|
// 一些默认的逻辑不翻译 排除掉
|
|
@@ -646,7 +645,7 @@ export class BindEvent extends BaseNode {
|
|
|
646
645
|
} else {
|
|
647
646
|
yield* wrapForEach(self.logics, function* warpForEachGenerator(logic, index) {
|
|
648
647
|
const logicName = logic.name;
|
|
649
|
-
logic.name = logic.
|
|
648
|
+
logic.name = logic.view.name + logic.name + index;
|
|
650
649
|
code += yield* logic.toEmbeddedTS(
|
|
651
650
|
shiftState(state, code, {
|
|
652
651
|
tabSize: (state?.tabSize || 0) + 2,
|
|
@@ -662,7 +661,7 @@ export class BindEvent extends BaseNode {
|
|
|
662
661
|
}
|
|
663
662
|
code = `${self.toHump(self.name) || '__IDENTIFIER__'}: (event: `;
|
|
664
663
|
// event的类型
|
|
665
|
-
code +=
|
|
664
|
+
code += self.getEventTypeString();
|
|
666
665
|
code += ') => [\n';
|
|
667
666
|
yield* wrapForEach(self.logics, function* warpForEachGenerator(logic) {
|
|
668
667
|
// 一些默认的逻辑不翻译 排除掉
|
|
@@ -697,7 +696,7 @@ export class BindEvent extends BaseNode {
|
|
|
697
696
|
code += indent(state?.tabSize || 0);
|
|
698
697
|
code += ',\n';
|
|
699
698
|
});
|
|
700
|
-
if (self.view
|
|
699
|
+
if (self.view) code += '],\n';
|
|
701
700
|
else code += ']\n';
|
|
702
701
|
return code;
|
|
703
702
|
}
|
|
@@ -770,11 +769,9 @@ export class BindEvent extends BaseNode {
|
|
|
770
769
|
return code;
|
|
771
770
|
}
|
|
772
771
|
|
|
773
|
-
|
|
772
|
+
getEventTypeString() {
|
|
774
773
|
let code = '';
|
|
775
774
|
if (!Object.keys(elementsEventsMap).length) return;
|
|
776
|
-
// 业务组件
|
|
777
|
-
const businessComponent = this.element.correspondingBusinessComponent;
|
|
778
775
|
// 已有的点击事件,已知类型的,就直接取值
|
|
779
776
|
if (
|
|
780
777
|
[
|
|
@@ -795,20 +792,6 @@ export class BindEvent extends BaseNode {
|
|
|
795
792
|
const ref = eventInfo.params[0].schema.$ref;
|
|
796
793
|
const type = ref.replace('#/systemTypes/', 'nasl.ui.');
|
|
797
794
|
code = `${type}`;
|
|
798
|
-
} else if (businessComponent) {
|
|
799
|
-
code = '{\n';
|
|
800
|
-
// 目标事件
|
|
801
|
-
const targetEvent = businessComponent.events?.find((event) => {
|
|
802
|
-
return event.name === this.name;
|
|
803
|
-
});
|
|
804
|
-
if (Array.isArray(targetEvent?.params)) {
|
|
805
|
-
yield* wrapForEach(targetEvent.params, function* warpForEachGenerator(param, index) {
|
|
806
|
-
code += `${param.name}?: `;
|
|
807
|
-
code += yield* param.typeAnnotation.toEmbeddedTS(shiftState(state, code));
|
|
808
|
-
code += ',\n';
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
code += '\n}';
|
|
812
795
|
} else {
|
|
813
796
|
code = 'nasl.ui.BaseEvent';
|
|
814
797
|
}
|
|
@@ -865,13 +848,8 @@ export class BindEvent extends BaseNode {
|
|
|
865
848
|
});
|
|
866
849
|
}
|
|
867
850
|
|
|
868
|
-
get likeComponent(): View | BusinessComponent {
|
|
869
|
-
return this.view || (this?.getAncestor('BusinessComponent') as BusinessComponent);
|
|
870
|
-
}
|
|
871
|
-
|
|
872
851
|
getNamespace(ns: string) {
|
|
873
|
-
if (this.
|
|
874
|
-
return `${this.likeComponent.getNamespace()}.${this.likeComponent.name}.bindEvents.${this.name}.logics`;
|
|
852
|
+
if (this.view) return `${this.view.getNamespace()}.${this.view.name}.bindEvents.${this.name}.logics`;
|
|
875
853
|
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
876
854
|
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
877
855
|
const parentName = this.parentNode.name;
|
|
@@ -983,21 +961,16 @@ export class BindEvent extends BaseNode {
|
|
|
983
961
|
getPageViewEventChineseName() {
|
|
984
962
|
const parent = this.parentNode;
|
|
985
963
|
const suffixRE = /时|前|后$/;
|
|
986
|
-
if (asserts.isView(parent)
|
|
987
|
-
const conceptTitleMap = {
|
|
988
|
-
View: '页面',
|
|
989
|
-
BusinessComponent: '业务组件',
|
|
990
|
-
};
|
|
991
|
-
const conceptTitle = conceptTitleMap[parent.concept];
|
|
964
|
+
if (asserts.isView(parent)) {
|
|
992
965
|
const event = elementsEventsMap[this.name];
|
|
993
966
|
|
|
994
967
|
if (['keydown', 'keyup'].includes(event.name)) {
|
|
995
|
-
return `“${parent.title || parent.name}
|
|
968
|
+
return `“${parent.title || parent.name}”页面${event.title}`;
|
|
996
969
|
}
|
|
997
970
|
|
|
998
971
|
const cap = suffixRE.exec(event?.title);
|
|
999
|
-
if (cap) return `${event.title.replace(suffixRE, '')}“${parent.title || parent.name}
|
|
1000
|
-
else return `${event.title}“${parent.title || parent.name}
|
|
972
|
+
if (cap) return `${event.title.replace(suffixRE, '')}“${parent.title || parent.name}”页面${cap[0]}`;
|
|
973
|
+
else return `${event.title}“${parent.title || parent.name}”页面`;
|
|
1001
974
|
} else if (asserts.isViewElement(parent)) {
|
|
1002
975
|
const eventName = `${parent.tag}-${this.name}`;
|
|
1003
976
|
if (elementsEventsMap[eventName]) {
|
|
@@ -1093,7 +1066,7 @@ export class BindEvent extends BaseNode {
|
|
|
1093
1066
|
if (asserts.isViewElement(parentNode)) {
|
|
1094
1067
|
return `${parentNode.name}_${newName}`;
|
|
1095
1068
|
} else if (asserts.isView(parentNode)) {
|
|
1096
|
-
return `${this.
|
|
1069
|
+
return `${this.view.name}_${newName}`;
|
|
1097
1070
|
} else {
|
|
1098
1071
|
// 这里编译成这个名字了 后续pctemplate 里也得按这个调用?
|
|
1099
1072
|
// 或者说因为会编译在不同的端里 直接 name好了
|
|
@@ -1162,8 +1135,7 @@ export class BindEvent extends BaseNode {
|
|
|
1162
1135
|
parent = parent.parentNode;
|
|
1163
1136
|
}
|
|
1164
1137
|
}
|
|
1165
|
-
return `/embedded/${this.
|
|
1166
|
-
}/bindEvents/${pathName}.ts`;
|
|
1138
|
+
return `/embedded/${this.app.name}/frontends/${this.frontend.name}/bindEvents/${pathName}.ts`;
|
|
1167
1139
|
}
|
|
1168
1140
|
|
|
1169
1141
|
//================================================================================
|
|
@@ -527,18 +527,10 @@ export class CallFunction extends LogicItem {
|
|
|
527
527
|
|
|
528
528
|
code += ')';
|
|
529
529
|
const tyAnno = (this as any).typeAnnotation || this.__TypeAnnotation;
|
|
530
|
-
let { sortedTypeKey, typeKind, typeName, typeNamespace } = tyAnno || {};
|
|
531
|
-
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
532
|
-
const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
|
|
533
|
-
const typeAn = referenceNode.typeAnnotation || {};
|
|
534
|
-
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
535
|
-
typeKind = typeAn.typeKind;
|
|
536
|
-
typeName = typeAn.typeName;
|
|
537
|
-
}
|
|
538
530
|
const needGenInitFromSchema =
|
|
539
|
-
tyAnno && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
531
|
+
tyAnno && (!['primitive', 'union'].includes(tyAnno.typeKind) || tyAnno.typeName === 'DateTime');
|
|
540
532
|
if (needGenInitFromSchema) {
|
|
541
|
-
code = `this.$genInitFromSchema('${sortedTypeKey}', ${code})`;
|
|
533
|
+
code = `this.$genInitFromSchema('${tyAnno?.sortedTypeKey}', ${code})`;
|
|
542
534
|
}
|
|
543
535
|
return code;
|
|
544
536
|
}
|
|
@@ -591,7 +591,7 @@ export class CallLogic extends LogicItem {
|
|
|
591
591
|
_setCallee(logic: Logic) {
|
|
592
592
|
const BaseNode = getBaseNode();
|
|
593
593
|
this.calleeNamespace = logic.getNamespace();
|
|
594
|
-
if (asserts.isView(logic.parentNode)
|
|
594
|
+
if (asserts.isView(logic.parentNode)) {
|
|
595
595
|
this.calleeNamespace = '';
|
|
596
596
|
}
|
|
597
597
|
this.calleeName = logic.name;
|
|
@@ -615,7 +615,7 @@ export class CallLogic extends LogicItem {
|
|
|
615
615
|
|
|
616
616
|
setCallee(logic: Logic) {
|
|
617
617
|
let calleeNamespace = logic?.getNamespace() || '';
|
|
618
|
-
if (asserts.isView(logic.parentNode)
|
|
618
|
+
if (asserts.isView(logic.parentNode)) {
|
|
619
619
|
calleeNamespace = '';
|
|
620
620
|
}
|
|
621
621
|
const calleeName = logic.name;
|
|
@@ -773,23 +773,23 @@ export class CallLogic extends LogicItem {
|
|
|
773
773
|
code += calleeName;
|
|
774
774
|
}
|
|
775
775
|
return code;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
776
|
+
} else if (bindAttr?.name === 'text') {
|
|
777
|
+
if (calleeName === 'jsonSerialize') {
|
|
778
|
+
if (
|
|
779
|
+
this.arguments[0]?.expression?.__TypeAnnotation?.typeName === 'String' &&
|
|
780
|
+
this.arguments[0]?.expression?.__TypeAnnotation?.typeNamespace === 'nasl.core'
|
|
781
|
+
) {
|
|
782
|
+
code += options?.finalCode === false ? 'JSON 序列化' : 'JSON.stringify';
|
|
783
|
+
} else {
|
|
784
|
+
code += options?.finalCode === false ? 'JSON 序列化' : `$utils['JsonSerialize']`;
|
|
785
|
+
}
|
|
786
|
+
setArguments();
|
|
787
|
+
return code;
|
|
788
|
+
} else if (calleeName === 'jsonDeserialize') {
|
|
789
|
+
code += options?.finalCode === false ? 'JSON 反序列化' : 'JSON.parse';
|
|
790
|
+
setArguments();
|
|
791
|
+
return code;
|
|
785
792
|
}
|
|
786
|
-
setArguments();
|
|
787
|
-
return code;
|
|
788
|
-
}
|
|
789
|
-
if (calleeName === 'jsonDeserialize') {
|
|
790
|
-
code += options?.finalCode === false ? 'JSON 反序列化' : 'JSON.parse';
|
|
791
|
-
setArguments();
|
|
792
|
-
return code;
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
795
|
|
|
@@ -815,11 +815,12 @@ export class CallLogic extends LogicItem {
|
|
|
815
815
|
|
|
816
816
|
if (bindAttr?.name === 'data-source') {
|
|
817
817
|
return this.calleeName;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
818
|
+
} else if (bindAttr?.name === 'text') {
|
|
819
|
+
if (calleeName === 'jsonSerialize') {
|
|
820
|
+
return 'JSON 序列化';
|
|
821
|
+
} else if (calleeName === 'jsonDeserialize') {
|
|
822
|
+
return 'JSON 反序列化';
|
|
823
|
+
}
|
|
823
824
|
}
|
|
824
825
|
}
|
|
825
826
|
|
|
@@ -906,8 +907,9 @@ export class CallLogic extends LogicItem {
|
|
|
906
907
|
const args = logic?.params || [];
|
|
907
908
|
const keywordEntitiesIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'entities');
|
|
908
909
|
|
|
909
|
-
code += `this.$logics['${
|
|
910
|
-
}
|
|
910
|
+
code += `this.$logics['${
|
|
911
|
+
this.calleeNamespace ? `${this.calleeNamespace}.${this.calleeName}` : this.calleeName
|
|
912
|
+
}']`;
|
|
911
913
|
code += `({
|
|
912
914
|
config: {
|
|
913
915
|
download: false,
|
|
@@ -1191,17 +1193,11 @@ export class CallLogic extends LogicItem {
|
|
|
1191
1193
|
};
|
|
1192
1194
|
}
|
|
1193
1195
|
const typeAnnotation = (this as any).typeAnnotation || this.__TypeAnnotation;
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
const typeAn = referenceNode.typeAnnotation || {};
|
|
1198
|
-
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
1199
|
-
typeKind = typeAn.typeKind;
|
|
1200
|
-
typeName = typeAn.typeName;
|
|
1201
|
-
}
|
|
1202
|
-
const needGenInitFromSchema = typeAnnotation && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
1196
|
+
const needGenInitFromSchema =
|
|
1197
|
+
typeAnnotation &&
|
|
1198
|
+
(!['primitive', 'union'].includes(typeAnnotation.typeKind) || typeAnnotation.typeName === 'DateTime');
|
|
1203
1199
|
if (needGenInitFromSchema) {
|
|
1204
|
-
code = `this.$genInitFromSchema('${sortedTypeKey}', ${code})`;
|
|
1200
|
+
code = `this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}', ${code})`;
|
|
1205
1201
|
}
|
|
1206
1202
|
code += ')';
|
|
1207
1203
|
return code;
|
|
@@ -1221,10 +1217,6 @@ export class CallLogic extends LogicItem {
|
|
|
1221
1217
|
return Boolean(this.handleError || this.useValidation);
|
|
1222
1218
|
}
|
|
1223
1219
|
|
|
1224
|
-
get businessComponent() {
|
|
1225
|
-
return this.getAncestor('BusinessComponent');
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
1220
|
@withSourceMapGenerator
|
|
1229
1221
|
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
1230
1222
|
const self = this;
|
|
@@ -1359,11 +1351,6 @@ export class CallLogic extends LogicItem {
|
|
|
1359
1351
|
yield* setInputParam();
|
|
1360
1352
|
code += ';\n})()';
|
|
1361
1353
|
} else {
|
|
1362
|
-
// 属于业务组件
|
|
1363
|
-
const belongBusinessComponent = !!this.businessComponent;
|
|
1364
|
-
if (belongBusinessComponent && !self.calleeNamespace) {
|
|
1365
|
-
code += `(this as ${this.businessComponent.name}).`;
|
|
1366
|
-
}
|
|
1367
1354
|
code += calleeKey;
|
|
1368
1355
|
yield* setTypeArguments();
|
|
1369
1356
|
yield* setInputParam();
|
|
@@ -1521,7 +1508,7 @@ export class CallLogic extends LogicItem {
|
|
|
1521
1508
|
state: Array.isArray(t) ? 2 : 1,
|
|
1522
1509
|
};
|
|
1523
1510
|
});
|
|
1524
|
-
} catch (err) {
|
|
1511
|
+
} catch (err) {}
|
|
1525
1512
|
}
|
|
1526
1513
|
return node;
|
|
1527
1514
|
}
|
|
@@ -347,13 +347,15 @@ export class Constant extends BaseNode {
|
|
|
347
347
|
}
|
|
348
348
|
if (this.typeAnnotation) {
|
|
349
349
|
code += `: `;
|
|
350
|
-
if (
|
|
351
|
-
|
|
350
|
+
if (
|
|
351
|
+
this.defaultValue?.expression &&
|
|
352
|
+
!(this.typeAnnotation && ['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey))
|
|
353
|
+
) {
|
|
354
|
+
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
355
|
+
} else {
|
|
356
|
+
if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey)) {
|
|
352
357
|
code += yield* this.defaultValue.toEmbeddedTS(shiftState(state, code), true);
|
|
353
|
-
} else {
|
|
354
|
-
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
355
358
|
}
|
|
356
|
-
} else {
|
|
357
359
|
code += 'undefined';
|
|
358
360
|
}
|
|
359
361
|
code += ' as ';
|
|
@@ -367,7 +367,7 @@ export class Destination extends LogicItem {
|
|
|
367
367
|
let code = '';
|
|
368
368
|
const viewArr = this.genViewArr();
|
|
369
369
|
if (Array.isArray(viewArr) && viewArr.length) {
|
|
370
|
-
code += `let url = '${this.viewNode
|
|
370
|
+
code += `let url = '${this.viewNode.frontend.prefixPath ? this.viewNode.frontend.prefixPath : ''}/${viewArr.join(
|
|
371
371
|
'/',
|
|
372
372
|
)}';\n`;
|
|
373
373
|
const { completeArguments } = this;
|
|
@@ -691,21 +691,19 @@ export class Destination extends LogicItem {
|
|
|
691
691
|
});
|
|
692
692
|
}
|
|
693
693
|
if (this.viewNode) {
|
|
694
|
-
return `${this.viewNode
|
|
694
|
+
return `${this.viewNode.frontend.prefixPath}/${viewNameAttr.join('/')}`;
|
|
695
695
|
}
|
|
696
696
|
return `/${viewNameAttr.join('/')}`;
|
|
697
697
|
}
|
|
698
698
|
|
|
699
699
|
@withSourceMapGenerator
|
|
700
|
-
*toEmbeddedTSInProcess(state = createCompilerState(),
|
|
700
|
+
*toEmbeddedTSInProcess(state = createCompilerState(), prependCode: string): TranslatorGenerator {
|
|
701
701
|
const self = this;
|
|
702
702
|
// const tab = indent((state?.tabSize || 0));
|
|
703
703
|
if (self.tsCalleeNamespace && self.tsName) {
|
|
704
704
|
const destinationName = self.parentNode.name.replace('-', '_');
|
|
705
|
-
// 跳转页面拿不到自己任务下的输出参数,所以不需要__ProcessIdentification__标注
|
|
706
|
-
prevCode = prevCode.replace('__ProcessIdentification__', '');
|
|
707
705
|
let code = `${destinationName}: function() {\n`;
|
|
708
|
-
code +=
|
|
706
|
+
code += prependCode;
|
|
709
707
|
code += '\n';
|
|
710
708
|
if (self.tsCalleeNamespace && self.viewName) {
|
|
711
709
|
code += `${self.tsCalleeNamespace}.${self.viewName}.$destination({`;
|
package/src/concepts/End__.ts
CHANGED
|
@@ -99,7 +99,6 @@ export class End extends LogicItem {
|
|
|
99
99
|
// 旧逻辑默认走这里,
|
|
100
100
|
// 期望后期可以直接走完整的case, default 直接抛出异常好更明确定位错误
|
|
101
101
|
logic =
|
|
102
|
-
self.getAncestor('BusinessLogic') ||
|
|
103
102
|
self.parentNode.getAncestor('Logic') ||
|
|
104
103
|
self.parentNode.getAncestor('AuthLogic') ||
|
|
105
104
|
self.parentNode.getAncestor('AuthLogicForCallInterface') ||
|
package/src/concepts/Entity__.ts
CHANGED
|
@@ -77,7 +77,7 @@ export class Entity extends BaseNode {
|
|
|
77
77
|
* 实体来源
|
|
78
78
|
*/
|
|
79
79
|
@property()
|
|
80
|
-
origin: 'ide' | 'sql' | 'table' | 'excel' = 'ide';
|
|
80
|
+
origin: 'ide' | 'sql' | 'table' | 'excel' | 'form' = 'ide';
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* 实体属性列表
|
|
@@ -951,6 +951,8 @@ export class Entity extends BaseNode {
|
|
|
951
951
|
ns.path = this.getNamespace();
|
|
952
952
|
return ns;
|
|
953
953
|
}
|
|
954
|
+
// @excludedInJSON()
|
|
955
|
+
// nslogic: Namespace;
|
|
954
956
|
|
|
955
957
|
get logics() {
|
|
956
958
|
return this.ns.logics;
|
package/src/concepts/Event__.ts
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
wrapForEachToGenerator as wrapForEach,
|
|
3
|
-
wrapIteratorToGenerator as wrapIterator,
|
|
4
|
-
runGeneratorSync as runSync,
|
|
5
|
-
returnOrigin,
|
|
6
|
-
} from '../utils/time-slicing';
|
|
7
|
-
import {
|
|
8
|
-
TranslatorState,
|
|
9
|
-
shiftState,
|
|
10
|
-
withSourceMap,
|
|
11
|
-
indent,
|
|
12
|
-
createCompilerState,
|
|
13
|
-
embeddedTSEmitter,
|
|
14
|
-
withSourceMapGenerator,
|
|
15
|
-
withGenerator,
|
|
16
|
-
TranslatorGenerator,
|
|
17
|
-
} from '../translator';
|
|
18
1
|
//================================================================================
|
|
19
2
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
20
3
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -133,30 +116,6 @@ export class Event extends BaseNode {
|
|
|
133
116
|
}
|
|
134
117
|
return params;
|
|
135
118
|
}
|
|
136
|
-
/**
|
|
137
|
-
* 设置组件事件名称
|
|
138
|
-
*/
|
|
139
|
-
setName(name: string) {
|
|
140
|
-
const object = {
|
|
141
|
-
name,
|
|
142
|
-
};
|
|
143
|
-
this.update({
|
|
144
|
-
...object,
|
|
145
|
-
field: 'name',
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* 设置组件事件描述
|
|
151
|
-
*/
|
|
152
|
-
setDescription(description: string) {
|
|
153
|
-
const object = {
|
|
154
|
-
description,
|
|
155
|
-
};
|
|
156
|
-
this.update({
|
|
157
|
-
...object,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
119
|
|
|
161
120
|
getParamExistingNames(excludedList: Array<Param> = []) {
|
|
162
121
|
const excludedSet = new Set(excludedList);
|
|
@@ -372,36 +331,7 @@ export class Event extends BaseNode {
|
|
|
372
331
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
373
332
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
374
333
|
//================================================================================
|
|
375
|
-
static getDefaultOptions() {
|
|
376
|
-
return {
|
|
377
|
-
description: '自定义事件',
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
334
|
|
|
381
|
-
getVarExistingNames(excludedList: Array<Param> = []) {
|
|
382
|
-
const excludedSet = new Set(excludedList);
|
|
383
|
-
return (this.params || []).filter((item) => !excludedSet.has(item)).map((item) => item?.name);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
@withSourceMapGenerator
|
|
387
|
-
*toEmbeddedTS(state = createCompilerState(), prefix?: string, hideDefaultValue?: boolean): TranslatorGenerator {
|
|
388
|
-
const self = this;
|
|
389
|
-
let code = `${self.name}`;
|
|
390
|
-
// 有参数长度
|
|
391
|
-
if (self.params.length) {
|
|
392
|
-
code += '(';
|
|
393
|
-
yield* wrapForEach(self.params, function* warpForEachGenerator(param, index) {
|
|
394
|
-
code += yield* param.toEmbeddedTS(shiftState(state, code));
|
|
395
|
-
if (index !== self.params.length - 1) code += ', ';
|
|
396
|
-
});
|
|
397
|
-
code += ')';
|
|
398
|
-
} else {
|
|
399
|
-
// 没有参数的
|
|
400
|
-
code += '()';
|
|
401
|
-
}
|
|
402
|
-
code += '{};\n';
|
|
403
|
-
return code;
|
|
404
|
-
}
|
|
405
335
|
//================================================================================
|
|
406
336
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
407
337
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|