@lcap/nasl 3.3.0-alpha.1 → 3.3.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/automate/upgrader/2.20.js.map +1 -1
- package/out/bak/translator.js +52 -1
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/shared/utils.js +0 -2
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/Command.d.ts +1 -0
- package/out/common/Command.js +9 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/Abort__.js +2 -1
- package/out/concepts/Abort__.js.map +1 -1
- package/out/concepts/Anchor__.js +1 -1
- package/out/concepts/Anchor__.js.map +1 -1
- package/out/concepts/AnonymousFunction__.js +2 -2
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/Argument__.js +1 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.js +1 -1
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +2 -2
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +1 -1
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/Backend__.js +1 -1
- package/out/concepts/Backend__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +2 -2
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +2 -2
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +2 -0
- package/out/concepts/BindAttribute__.js +79 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +2 -1
- package/out/concepts/BindEvent__.js +44 -37
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.js +1 -1
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.js +1 -1
- package/out/concepts/CallAuthInterface__.js.map +1 -1
- package/out/concepts/CallConnector__.js +1 -1
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallFunction__.js +2 -2
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +2 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +69 -12
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Connection__.js +9 -10
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.js +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.js +2 -2
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +1 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.js +1 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +2 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.js +2 -2
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js +2 -2
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +2 -2
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +27 -37
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.js +1 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +2 -2
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- 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 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/JavaLogic__.js +1 -1
- package/out/concepts/JavaLogic__.js.map +1 -1
- package/out/concepts/LogicItem__.js +3 -2
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +2 -1
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +1 -1
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +2 -2
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -0
- package/out/concepts/MemberExpression__.js +117 -2
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +1 -1
- package/out/concepts/Module__.js +34 -35
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +2 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.js +2 -2
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/New__.js +1 -1
- package/out/concepts/New__.js.map +1 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +2 -2
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +1 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.js +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js +1 -1
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +1 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/Return__.js +2 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +1 -1
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SelectMembers__.js +1 -1
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +2 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +2 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +2 -2
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +2 -2
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +2 -2
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TriggerLauncher__.js +1 -1
- package/out/concepts/TriggerLauncher__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +4 -3
- package/out/concepts/TypeAnnotation__.js +116 -75
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +2 -2
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +14 -14
- package/out/concepts/ValidationRule__.js +28 -24
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +2 -2
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +88 -87
- package/out/concepts/ViewElement__.js +268 -204
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +6 -0
- package/out/concepts/View__.js +254 -11
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +2 -2
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.browser.js +1 -0
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.event.js +2 -0
- package/out/concepts/basics/stdlib/nasl.event.js.map +1 -1
- package/out/generator/genBundleFiles.js +90 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +1 -1
- 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/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/natural/genNaturalTS.js +7 -3
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/knowledgeMap.js +12 -12
- package/out/natural/knowledgeMap.js.map +1 -1
- package/out/natural/transformTSCode.d.ts +1 -1
- package/out/natural/transformTSCode.js +115 -141
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +69 -44
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +72 -63
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +20 -23
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +149 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +3 -3
- package/out/server/naslServer.js +182 -132
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +43 -33
- package/out/server/translator.js.map +1 -1
- package/out/service/defaultErrorMessage.json +6 -6
- package/out/service/storage/init.js +16 -0
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +5 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +12 -8
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +8 -7
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.d.ts +1 -1
- package/out/templator/genEditTableBlock.js +12 -6
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +2 -2
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.d.ts +2 -2
- package/out/templator/genGridViewBlock.js +20 -7
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.d.ts +2 -2
- package/out/templator/genListViewBlock.js +13 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.d.ts +2 -2
- package/out/templator/genSelectBlock.js +8 -6
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +1 -1
- package/out/templator/genTableBlock.js +10 -5
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +5 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/package.json +3 -1
- package/sandbox/stdlib/nasl.auth.ts +40 -44
- package/sandbox/stdlib/nasl.core.ts +8 -1
- package/sandbox/stdlib/nasl.http.ts +22 -22
- package/sandbox-natural/stdlib/nasl.util.ts +74 -15
- package/src/automate/upgrader/2.20.js +17 -13
- package/src/bak/translator.js +50 -1
- package/src/breakpoint/shared/utils.ts +0 -2
- package/src/common/Command.ts +8 -0
- package/src/concepts/Abort__.ts +2 -2
- package/src/concepts/Anchor__.ts +2 -2
- package/src/concepts/AnonymousFunction__.ts +3 -3
- package/src/concepts/Argument__.ts +2 -2
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/AssignmentLine__.ts +2 -2
- package/src/concepts/Assignment__.ts +3 -3
- package/src/concepts/BackendVariable__.ts +2 -2
- package/src/concepts/Backend__.ts +1 -1
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BinaryExpression__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +69 -4
- package/src/concepts/BindDirective__.ts +2 -2
- package/src/concepts/BindEvent__.ts +44 -64
- package/src/concepts/BindStyle__.ts +2 -2
- package/src/concepts/BooleanLiteral__.ts +2 -2
- package/src/concepts/CallAuthInterface__.ts +2 -2
- package/src/concepts/CallConnector__.ts +2 -2
- package/src/concepts/CallFunction__.ts +3 -3
- package/src/concepts/CallInterface__.ts +3 -3
- package/src/concepts/CallLogic__.ts +69 -13
- package/src/concepts/CallQueryComponent__.ts +2 -2
- package/src/concepts/Comment__.ts +2 -2
- package/src/concepts/ConfigProperty__.ts +2 -2
- package/src/concepts/Connection__.ts +15 -21
- package/src/concepts/Constant__.ts +2 -2
- package/src/concepts/DataSource__.ts +1 -1
- package/src/concepts/Destination__.ts +3 -3
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +2 -2
- package/src/concepts/EntityProperty__.ts +3 -3
- package/src/concepts/Entity__.ts +2 -2
- package/src/concepts/EnumItem__.ts +3 -3
- package/src/concepts/Enum__.ts +2 -2
- package/src/concepts/ForEachStatement__.ts +35 -46
- package/src/concepts/Frontend__.ts +1 -1
- package/src/concepts/Function__.ts +3 -3
- package/src/concepts/Identifier__.ts +2 -2
- package/src/concepts/IfStatement__.ts +3 -3
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/JSBlock__.ts +2 -2
- package/src/concepts/JavaLogic__.ts +2 -2
- package/src/concepts/LogicItem__.ts +3 -3
- package/src/concepts/Logic__.ts +2 -1
- package/src/concepts/MatchCase__.ts +2 -2
- package/src/concepts/Match__.ts +3 -3
- package/src/concepts/MemberExpression__.ts +112 -4
- package/src/concepts/Module__.ts +41 -58
- package/src/concepts/NewComposite__.ts +3 -3
- package/src/concepts/NewList__.ts +3 -3
- package/src/concepts/NewMap__.ts +3 -3
- package/src/concepts/New__.ts +2 -2
- package/src/concepts/NullLiteral__.ts +2 -2
- package/src/concepts/NumericLiteral__.ts +2 -2
- package/src/concepts/OqlQueryComponent__.ts +3 -3
- package/src/concepts/Param__.ts +2 -2
- package/src/concepts/ProcessElement__.ts +2 -2
- package/src/concepts/ProcessOutcome__.ts +2 -2
- package/src/concepts/ProcessOutcomes__.ts +2 -2
- package/src/concepts/Process__.ts +1 -1
- package/src/concepts/QueryAggregateExpression__.ts +2 -2
- package/src/concepts/QueryFieldExpression__.ts +2 -2
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/QueryLimitExpression__.ts +2 -2
- package/src/concepts/QueryOrderByExpression__.ts +2 -2
- package/src/concepts/Return__.ts +3 -3
- package/src/concepts/Role__.ts +1 -1
- package/src/concepts/SelectMembers__.ts +2 -2
- package/src/concepts/SqlQueryComponent__.ts +3 -3
- package/src/concepts/Start__.ts +2 -2
- package/src/concepts/StringInterpolation__.ts +3 -3
- package/src/concepts/StringLiteral__.ts +2 -2
- package/src/concepts/StructureProperty__.ts +3 -3
- package/src/concepts/Structure__.ts +2 -2
- package/src/concepts/SwitchCase__.ts +2 -2
- package/src/concepts/SwitchStatement__.ts +3 -3
- package/src/concepts/TriggerLauncher__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +145 -125
- package/src/concepts/TypeParam__.ts +2 -2
- package/src/concepts/UnaryExpression__.ts +3 -3
- package/src/concepts/ValidationRule__.ts +554 -524
- package/src/concepts/Variable__.ts +3 -3
- package/src/concepts/ViewElement__.ts +2445 -2498
- package/src/concepts/View__.ts +258 -10
- package/src/concepts/WhileStatement__.ts +3 -3
- package/src/concepts/basics/stdlib/nasl.browser.ts +1 -0
- package/src/concepts/basics/stdlib/nasl.event.ts +2 -0
- package/src/generator/genBundleFiles.ts +91 -1
- package/src/generator/genReleaseBody.ts +1 -1
- package/src/generator/permission.ts +3 -3
- package/src/index.ts +1 -0
- package/src/natural/genNaturalTS.ts +8 -4
- package/src/natural/knowledgeMap.ts +12 -12
- package/src/natural/transformTSCode.ts +139 -151
- package/src/server/extendBaseNode.ts +71 -45
- package/src/server/formatTsUtils.ts +64 -64
- package/src/server/getLogics.ts +23 -30
- package/src/server/getMemberIdentifier.ts +143 -0
- package/src/server/naslServer.ts +174 -148
- package/src/server/translator.ts +40 -39
- package/src/service/defaultErrorMessage.json +6 -6
- package/src/service/storage/init.ts +17 -0
- package/src/templator/genCreateBlock.ts +5 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +12 -8
- package/src/templator/genCurdMultipleKeyBlock.ts +8 -7
- package/src/templator/genEditTableBlock.ts +12 -7
- package/src/templator/genEnumSelectBlock.ts +2 -2
- package/src/templator/genGetBlock.ts +6 -6
- package/src/templator/genGridViewBlock.ts +22 -9
- package/src/templator/genListViewBlock.ts +14 -5
- package/src/templator/genSelectBlock.ts +8 -6
- package/src/templator/genTableBlock.ts +10 -9
- package/src/templator/genUpdateBlock.ts +5 -3
- package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +11 -0
- package/test/concepts/validation-rule/__snapshots__/toJS.spec.ts.snap +10 -0
- package/test/concepts/validation-rule/fixtures/argument-without-keyword.json +34 -0
- package/test/concepts/validation-rule/fixtures/empty-rule.json +9 -0
- package/test/concepts/validation-rule/validation-rule.spec.ts +15 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as tsProtocol from 'typescript/lib/protocol';
|
|
2
1
|
import { FileNode, NaslServer } from './naslServer';
|
|
2
|
+
import * as tsProtocol from 'typescript/lib/protocol';
|
|
3
3
|
import { MinRange } from './translator';
|
|
4
4
|
import {
|
|
5
5
|
BaseNode,
|
|
@@ -48,17 +48,19 @@ BaseNode.prototype.findReadOnlyLogicUsage = function () {
|
|
|
48
48
|
targetNode = logic;
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
|
-
} else
|
|
52
|
-
if (logic
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
} else {
|
|
52
|
+
if (logic instanceof Logic)
|
|
53
|
+
if (logic.calleewholeKey === (this.parentNode as Logic).calleewholeKey) {
|
|
54
|
+
targetNode = logic;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
56
58
|
}
|
|
57
59
|
} else if (this.parentNode.concept === 'Module') {
|
|
58
60
|
// 父级是模块的还是用它本身去查找引用
|
|
59
61
|
targetNode = this;
|
|
60
62
|
} else {
|
|
61
|
-
const
|
|
63
|
+
const sourceMap = this.parentNode.sourceMap;
|
|
62
64
|
for (const item of sourceMap) {
|
|
63
65
|
const logic = item[0] as Logic;
|
|
64
66
|
if (logic.calleewholeKey && logic.calleewholeKey === (this as Logic).calleewholeKey) {
|
|
@@ -152,14 +154,16 @@ BaseNode.prototype.changeName = async function changeName(newValue: string, upda
|
|
|
152
154
|
} else {
|
|
153
155
|
itemNode.setName?.(item.newValue);
|
|
154
156
|
}
|
|
155
|
-
} else if (_this.concept === 'AuthLogicForCallInterface' && itemNode.concept === 'CallAuthInterface') {
|
|
156
|
-
const { calleewholeKey } = itemNode;
|
|
157
|
-
const targetItf: AuthInterface = getNodeByNodeCallee(App, calleewholeKey);
|
|
158
|
-
targetItf.setAuthLogic(newValue);
|
|
159
|
-
// 需要触发更新,否则对应的ts文件不会更新会导致鉴权方式找不到报错
|
|
160
|
-
itemNode.update({});
|
|
161
157
|
} else {
|
|
162
|
-
|
|
158
|
+
if (_this.concept === 'AuthLogicForCallInterface' && itemNode.concept === 'CallAuthInterface') {
|
|
159
|
+
const { calleewholeKey } = itemNode;
|
|
160
|
+
const targetItf: AuthInterface = getNodeByNodeCallee(App, calleewholeKey);
|
|
161
|
+
targetItf.setAuthLogic(newValue);
|
|
162
|
+
// 需要触发更新,否则对应的ts文件不会更新会导致鉴权方式找不到报错
|
|
163
|
+
itemNode.update({});
|
|
164
|
+
} else {
|
|
165
|
+
item.setTypeMethods ? itemNode[item.setTypeMethods](newValue) : itemNode.setName?.(newValue);
|
|
166
|
+
}
|
|
163
167
|
}
|
|
164
168
|
});
|
|
165
169
|
// 结束修改 ,批量操作
|
|
@@ -181,19 +185,21 @@ BaseNode.prototype.changeName = async function changeName(newValue: string, upda
|
|
|
181
185
|
const closeCallBack = () => {
|
|
182
186
|
if (this.concept === 'EnumItem') {
|
|
183
187
|
const oldValue = (this as EnumItem).value;
|
|
184
|
-
(this as EnumItem).value =
|
|
188
|
+
(this as EnumItem).value = oldValue + ' ';
|
|
185
189
|
setTimeout(() => {
|
|
186
190
|
(this as EnumItem).value = oldValue;
|
|
187
191
|
}, 0);
|
|
188
192
|
} else {
|
|
189
193
|
const oldValue = this.name;
|
|
190
|
-
this.name =
|
|
194
|
+
this.name = oldValue + ' ';
|
|
191
195
|
setTimeout(() => {
|
|
192
196
|
this.name = oldValue;
|
|
193
197
|
}, 0);
|
|
194
198
|
}
|
|
195
199
|
};
|
|
196
200
|
updateAll ? callback(true) : invokeCommand('tsConfirm.open', confirmParms, callback, closeCallBack);
|
|
201
|
+
|
|
202
|
+
return;
|
|
197
203
|
}
|
|
198
204
|
} catch (err) {
|
|
199
205
|
console.log(err);
|
|
@@ -233,6 +239,11 @@ BaseNode.prototype.prepareDelete = async function prepareDelete(cb?: Function) {
|
|
|
233
239
|
return;
|
|
234
240
|
}
|
|
235
241
|
callback = () => {
|
|
242
|
+
// 外部接口删除时,只需要删除自己,不需要删除数据结构
|
|
243
|
+
if (node instanceof Interface && node.parentNode.concept === 'App') {
|
|
244
|
+
this.delete();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
236
247
|
// Structure 和 Interface是内部有delete方法
|
|
237
248
|
if (node instanceof Structure || node instanceof Interface) {
|
|
238
249
|
(this as any).deleteLogincAndModule();
|
|
@@ -275,32 +286,33 @@ BaseNode.prototype.prepareDelete = async function prepareDelete(cb?: Function) {
|
|
|
275
286
|
}
|
|
276
287
|
}
|
|
277
288
|
return;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
} else {
|
|
290
|
+
if (node instanceof Frontend) {
|
|
291
|
+
let viewPath = (this as FileNode).getEmbeddedFilePath();
|
|
292
|
+
viewPath = viewPath.slice(0, viewPath.length - 3);
|
|
293
|
+
const refsTempList = refsList.filter((record) => !record.file.includes(viewPath));
|
|
294
|
+
// 删除流程节点绑定的该端的页面跳转
|
|
295
|
+
const result = refsTempList
|
|
296
|
+
.map((record) => {
|
|
297
|
+
const fileNode = naslServer.file2NodeMap.get(record.file);
|
|
298
|
+
if (fileNode) {
|
|
299
|
+
const minRange = naslServer._findMinRange(record, fileNode as FileNode);
|
|
300
|
+
if (minRange?.node?.parentNode?.parentNode?.concept === 'ProcessElement') {
|
|
301
|
+
return minRange.node.parentNode;
|
|
302
|
+
}
|
|
291
303
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
return null;
|
|
305
|
+
})
|
|
306
|
+
.filter((record) => !!record);
|
|
307
|
+
const App = this.rootNode;
|
|
308
|
+
App.emit('collect:start', {
|
|
309
|
+
actionMsg: `删除端${node.name}`,
|
|
310
|
+
});
|
|
311
|
+
await Promise.all(result.map((ele) => ele.delete()));
|
|
312
|
+
this.delete();
|
|
313
|
+
App.emit('collect:end');
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
304
316
|
}
|
|
305
317
|
}
|
|
306
318
|
callback = async () => {
|
|
@@ -308,7 +320,7 @@ BaseNode.prototype.prepareDelete = async function prepareDelete(cb?: Function) {
|
|
|
308
320
|
// 跟rename 还不太一样,部分修改依赖修改好的值,然后在下面的修改需要把自己传递进去
|
|
309
321
|
if (node instanceof Param) {
|
|
310
322
|
const App = this.rootNode;
|
|
311
|
-
const
|
|
323
|
+
const parentNode = this.parentNode;
|
|
312
324
|
// 收集修改
|
|
313
325
|
App.emit('collect:start', {
|
|
314
326
|
actionMsg: '删除参数',
|
|
@@ -401,6 +413,12 @@ BaseNode.prototype.prepareDelete = async function prepareDelete(cb?: Function) {
|
|
|
401
413
|
App.emit('collect:end');
|
|
402
414
|
}
|
|
403
415
|
|
|
416
|
+
// 外部接口删除时,只需要删除自己,不需要删除数据结构
|
|
417
|
+
if (node instanceof Interface && node.parentNode.concept === 'App') {
|
|
418
|
+
this.delete();
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
|
|
404
422
|
if (node instanceof Connection) {
|
|
405
423
|
delConnection(node);
|
|
406
424
|
if (cb) {
|
|
@@ -429,6 +447,14 @@ function delConnection(node: Connection) {
|
|
|
429
447
|
app.emit('collect:start', {
|
|
430
448
|
actionMsg: '删除连接器',
|
|
431
449
|
});
|
|
450
|
+
if (node.connector?.connectorKind === 'kafka') {
|
|
451
|
+
// 删除相关的触发器
|
|
452
|
+
app.triggerLaunchers.forEach((launcher) => {
|
|
453
|
+
if ((launcher as MsgTriggerLauncher).calleeConnectionName === node.name) {
|
|
454
|
+
launcher.delete();
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
}
|
|
432
458
|
node.delete();
|
|
433
459
|
app.emit('collect:end');
|
|
434
460
|
}
|
|
@@ -460,7 +486,7 @@ BaseNode.prototype.getCurrentTypeAnnotation = async function getCurrentTypeAnnot
|
|
|
460
486
|
*/
|
|
461
487
|
const app = this.getAncestor('App');
|
|
462
488
|
const naslServer = (app as any).naslServer as NaslServer;
|
|
463
|
-
return
|
|
489
|
+
return naslServer.getCurrentTypeAnnotation(this, outTime || 2000);
|
|
464
490
|
} catch (err) {
|
|
465
491
|
console.log(err);
|
|
466
492
|
}
|
|
@@ -496,7 +522,7 @@ BaseNode.prototype.getSelectRef = function getSelectRef(newTypeAnnotation: TypeA
|
|
|
496
522
|
} else {
|
|
497
523
|
app = this.rootNode || typeAnnotation.app;
|
|
498
524
|
}
|
|
499
|
-
const node = newNode(getNodeByNodeCallee(app,
|
|
525
|
+
const node = newNode(getNodeByNodeCallee(app, typeNamespace + '.' + typeName), parentNode, needNewStructure);
|
|
500
526
|
const properties = node?.properties || [];
|
|
501
527
|
completionChildren = properties;
|
|
502
528
|
}
|
|
@@ -508,7 +534,7 @@ BaseNode.prototype.getSelectRef = function getSelectRef(newTypeAnnotation: TypeA
|
|
|
508
534
|
if (item?.typeAnnotation?.typeKind === 'typeParam') {
|
|
509
535
|
if (item.name === 'columnItem' && typeArguments[1]) {
|
|
510
536
|
item.typeAnnotation = TypeAnnotation.from(typeArguments[1].toJSON(), node, 'typeAnnotation');
|
|
511
|
-
} else {
|
|
537
|
+
} else if (typeArguments[0]) {
|
|
512
538
|
item.typeAnnotation = TypeAnnotation.from(typeArguments[0].toJSON(), node, 'typeAnnotation');
|
|
513
539
|
}
|
|
514
540
|
properties[i];
|
|
@@ -239,8 +239,7 @@ export function getPlatformType(type: string): string {
|
|
|
239
239
|
const namespacePrefix = ['app', 'extensions', 'apis', 'components', 'nasl'];
|
|
240
240
|
if (tsType === 'String') {
|
|
241
241
|
return 'nasl.core.String';
|
|
242
|
-
}
|
|
243
|
-
if (tsType === 'Boolean') {
|
|
242
|
+
} else if (tsType === 'Boolean') {
|
|
244
243
|
return 'nasl.core.Boolean';
|
|
245
244
|
}
|
|
246
245
|
|
|
@@ -249,7 +248,7 @@ export function getPlatformType(type: string): string {
|
|
|
249
248
|
const first = strTypes[0];
|
|
250
249
|
// 如果不是这几个前缀就加一个namespace
|
|
251
250
|
if (!namespacePrefix.includes(first)) {
|
|
252
|
-
return
|
|
251
|
+
return 'app.' + tsType;
|
|
253
252
|
}
|
|
254
253
|
}
|
|
255
254
|
return tsType;
|
|
@@ -358,7 +357,7 @@ function getAStructureScopeType(type: string, parent: any, node: SynatxNode) {
|
|
|
358
357
|
const name = itemArr[0];
|
|
359
358
|
let typeKey = itemArr[1];
|
|
360
359
|
if (typeKey && typeKey.startsWith('dataSources')) {
|
|
361
|
-
typeKey =
|
|
360
|
+
typeKey = 'app.' + typeKey;
|
|
362
361
|
}
|
|
363
362
|
// 如果ls传过来的名字是不合法的就隐藏
|
|
364
363
|
if (!isValidName(name)) {
|
|
@@ -393,8 +392,9 @@ function getAStructureScopeType(type: string, parent: any, node: SynatxNode) {
|
|
|
393
392
|
});
|
|
394
393
|
completionProperty.children = res;
|
|
395
394
|
return completionProperty;
|
|
395
|
+
} else {
|
|
396
|
+
return completionProperty;
|
|
396
397
|
}
|
|
397
|
-
return completionProperty;
|
|
398
398
|
});
|
|
399
399
|
parentItem.children = newChildren;
|
|
400
400
|
}
|
|
@@ -512,36 +512,34 @@ function getNodeTypeVariableData(nodeType: any, item: any, node: SynatxNode) {
|
|
|
512
512
|
const app = node.rootNode as App;
|
|
513
513
|
let structure: any = {};
|
|
514
514
|
|
|
515
|
-
//
|
|
516
|
-
if (
|
|
517
|
-
|
|
518
|
-
|
|
515
|
+
// 有类型在进行下一步运算
|
|
516
|
+
if (typeAnnotation) {
|
|
517
|
+
// 数据查询没有输出参数,特殊处理
|
|
518
|
+
if (typeAnnotation.typeKind === 'anonymousStructure') {
|
|
519
|
+
structure = { properties: typeAnnotation.properties };
|
|
520
|
+
} else if (typeAnnotation.typeArguments) {
|
|
521
|
+
structure = { properties: app.getSelectRef(typeAnnotation, true) };
|
|
522
|
+
} else {
|
|
523
|
+
structure = app.findNodeByCompleteName(typeAnnotation.typeNamespace + '.' + typeAnnotation.typeName);
|
|
524
|
+
}
|
|
525
|
+
structure?.properties?.forEach((structureProperty: StructureProperty) => {
|
|
526
|
+
const { name, typeAnnotation } = structureProperty;
|
|
527
|
+
const expression = new MemberExpression({
|
|
528
|
+
object: parentExpression,
|
|
529
|
+
property: new Identifier({ name }),
|
|
530
|
+
});
|
|
531
|
+
const completionData = new CompletionProperty({
|
|
532
|
+
name,
|
|
533
|
+
value: name,
|
|
534
|
+
expression,
|
|
535
|
+
children: [],
|
|
536
|
+
});
|
|
537
|
+
completionData.icon = 'refProperty';
|
|
519
538
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
structure = { properties: typeAnnotation.properties };
|
|
523
|
-
} else if (typeAnnotation.typeArguments) {
|
|
524
|
-
structure = { properties: app.getSelectRef(typeAnnotation, true) };
|
|
525
|
-
} else {
|
|
526
|
-
structure = app.findNodeByCompleteName(`${typeAnnotation.typeNamespace}.${typeAnnotation.typeName}`);
|
|
527
|
-
}
|
|
528
|
-
structure?.properties?.forEach((structureProperty: StructureProperty) => {
|
|
529
|
-
const { name, typeAnnotation } = structureProperty;
|
|
530
|
-
const expression = new MemberExpression({
|
|
531
|
-
object: parentExpression,
|
|
532
|
-
property: new Identifier({ name }),
|
|
539
|
+
item.children.push(completionData);
|
|
540
|
+
recursionProperty(typeAnnotation, completionData, node, typeKeyMap);
|
|
533
541
|
});
|
|
534
|
-
|
|
535
|
-
name,
|
|
536
|
-
value: name,
|
|
537
|
-
expression,
|
|
538
|
-
children: [],
|
|
539
|
-
});
|
|
540
|
-
completionData.icon = 'refProperty';
|
|
541
|
-
|
|
542
|
-
item.children.push(completionData);
|
|
543
|
-
recursionProperty(typeAnnotation, completionData, node, typeKeyMap);
|
|
544
|
-
});
|
|
542
|
+
}
|
|
545
543
|
}
|
|
546
544
|
|
|
547
545
|
const completionData = new CompletionProperty(item);
|
|
@@ -559,10 +557,12 @@ function recursionProperty(
|
|
|
559
557
|
let structure;
|
|
560
558
|
if (structureTypeAnnotation.typeArguments) {
|
|
561
559
|
structure = { properties: app.getSelectRef(structureTypeAnnotation, true) };
|
|
562
|
-
} else if (structureTypeAnnotation.typeKind === 'anonymousStructure') {
|
|
563
|
-
structure = { properties: structureTypeAnnotation.properties };
|
|
564
560
|
} else {
|
|
565
|
-
|
|
561
|
+
if (structureTypeAnnotation.typeKind === 'anonymousStructure') {
|
|
562
|
+
structure = { properties: structureTypeAnnotation.properties };
|
|
563
|
+
} else {
|
|
564
|
+
structure = app.findNodeByCompleteName(structureTypeAnnotation.typeNamespace + '.' + structureTypeAnnotation.typeName);
|
|
565
|
+
}
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
structure?.properties?.forEach((structureProperty: StructureProperty) => {
|
|
@@ -590,8 +590,7 @@ function getNextFlag(typeKey: string, typeKeyMap: Map<string, number>) {
|
|
|
590
590
|
if (['nasl.core.String', 'nasl.collection.List', 'nasl.collection.Map'].includes(typeKey)) return true;
|
|
591
591
|
if (typeKeyMap.get(typeKey) === 3) {
|
|
592
592
|
return false;
|
|
593
|
-
}
|
|
594
|
-
if (typeKeyMap.get(typeKey) > 0) {
|
|
593
|
+
} else if (typeKeyMap.get(typeKey) > 0) {
|
|
595
594
|
typeKeyMap.set(typeKey, typeKeyMap.get(typeKey) + 1);
|
|
596
595
|
} else {
|
|
597
596
|
typeKeyMap.set(typeKey, 1);
|
|
@@ -609,29 +608,28 @@ export function formatVariableData(data: unknown | variableItem[], node: SynatxN
|
|
|
609
608
|
if (item.completionDetail?.hasOwnProperty('nodeType') || item.completionDetail?.hasOwnProperty('newNodeType')) {
|
|
610
609
|
const completionProperty = getNodeTypeVariableData(item.completionDetail?.nodeType || item.completionDetail?.newNodeType, item, node);
|
|
611
610
|
return completionProperty;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
currentType = 'nasl.collection.List<nasl.core.Any>';
|
|
611
|
+
} else {
|
|
612
|
+
// 当前节点的完整类型,主要是在有T的内容使用 nasl.list<Enum1> 内部匹配内容给里面子集的T赋值类型
|
|
613
|
+
let currentType: string = formatTs2TypeString(item.completionDetail.displayParts as Array<{ text: string; kind: string }>);
|
|
614
|
+
if (currentType) {
|
|
615
|
+
if (currentType?.includes(': ')) {
|
|
616
|
+
const indexOf = currentType.indexOf(': ');
|
|
617
|
+
const newCurrentType = currentType.substring(indexOf + 2, currentType.length);
|
|
618
|
+
// 如果是对象形式的就单独处理
|
|
619
|
+
if (newCurrentType.startsWith('{') && newCurrentType.endsWith('}')) {
|
|
620
|
+
const completionProperty = getAStructureObjectStringType(newCurrentType, item, node);
|
|
621
|
+
return completionProperty;
|
|
622
|
+
} else if (newCurrentType.startsWith('nasl.ui.Current<{')) {
|
|
623
|
+
const completionProperty = getAStructureScopeType(newCurrentType, item, node);
|
|
624
|
+
return completionProperty;
|
|
625
|
+
} else if (newCurrentType.startsWith('nasl.collection.List<{') && newCurrentType.endsWith('}>')) {
|
|
626
|
+
currentType = 'nasl.collection.List<nasl.core.Any>';
|
|
627
|
+
}
|
|
630
628
|
}
|
|
631
629
|
}
|
|
630
|
+
typeKey = getPlatformType(currentType);
|
|
631
|
+
item.typeAnnotation = displayString2TypeAnnotation(typeKey);
|
|
632
632
|
}
|
|
633
|
-
typeKey = getPlatformType(currentType);
|
|
634
|
-
item.typeAnnotation = displayString2TypeAnnotation(typeKey);
|
|
635
633
|
} else if (item instanceof StructureProperty || item instanceof EntityProperty) {
|
|
636
634
|
typeKey = item?.typeAnnotation?.typeKey;
|
|
637
635
|
}
|
|
@@ -733,15 +731,17 @@ function getNodeiconFromLogic(completionProperty: CompletionProperty, node: Syna
|
|
|
733
731
|
if (params.find((item) => item.name === completionProperty.name)) return 'api-auth-params';
|
|
734
732
|
} else if (logic instanceof AuthLogic) {
|
|
735
733
|
if (params.find((item) => item.name === completionProperty.name)) return 'api-auth-params';
|
|
736
|
-
} else
|
|
734
|
+
} else {
|
|
735
|
+
if (params.find((item) => item.name === completionProperty.name)) return 'param';
|
|
736
|
+
}
|
|
737
737
|
|
|
738
738
|
if (params.find((item) => item.name === propName)) {
|
|
739
739
|
return 'param';
|
|
740
|
-
}
|
|
741
|
-
if (returns.find((item) => item.name === propName)) {
|
|
740
|
+
} else if (returns.find((item) => item.name === propName)) {
|
|
742
741
|
return 'return';
|
|
742
|
+
} else {
|
|
743
|
+
return 'variable';
|
|
743
744
|
}
|
|
744
|
-
return 'variable';
|
|
745
745
|
}
|
|
746
746
|
|
|
747
747
|
const bindAttr = node.getAncestor<BindAttribute>('BindAttribute');
|
|
@@ -768,8 +768,8 @@ function getNodeiconFromLogic(completionProperty: CompletionProperty, node: Syna
|
|
|
768
768
|
*/
|
|
769
769
|
function sortFirstVariableData(result: CompletionProperty[], node: BaseNode) {
|
|
770
770
|
const newResult: CompletionProperty[] = [];
|
|
771
|
-
const
|
|
772
|
-
const
|
|
771
|
+
const logic = (node as Param).logic;
|
|
772
|
+
const view = (node as Param).view;
|
|
773
773
|
if (view) {
|
|
774
774
|
const { params, variables } = view;
|
|
775
775
|
const list = [...params, ...variables];
|
package/src/server/getLogics.ts
CHANGED
|
@@ -127,7 +127,7 @@ export async function getLogics(node: CallLogic | BindEvent | Identifier | Logic
|
|
|
127
127
|
pItem.originConcept = 'Process';
|
|
128
128
|
return pItem;
|
|
129
129
|
});
|
|
130
|
-
const
|
|
130
|
+
const dependencies = app.dependencies; //.filter((d) => d.enable);
|
|
131
131
|
const extensions = app.dependencies
|
|
132
132
|
.map((dep) => moduleToLogicNamesapce(dep, app.overriddenLogics))
|
|
133
133
|
.filter((item) => item.logics && item.logics.length);
|
|
@@ -213,8 +213,8 @@ export async function getLogics(node: CallLogic | BindEvent | Identifier | Logic
|
|
|
213
213
|
elements.forEach((item) => {
|
|
214
214
|
const itemTag = toHump(item.tag);
|
|
215
215
|
const app = node.getAncestor('App');
|
|
216
|
-
const
|
|
217
|
-
const
|
|
216
|
+
const naslServer = (app as any).naslServer;
|
|
217
|
+
const elementsLogic = naslServer.elementsLogic;
|
|
218
218
|
const elementsLogicName = itemTag;
|
|
219
219
|
const eleLogis = elementsLogic[elementsLogicName];
|
|
220
220
|
// 看是不是有已经有有参数的函数了
|
|
@@ -292,32 +292,26 @@ export async function getLogics(node: CallLogic | BindEvent | Identifier | Logic
|
|
|
292
292
|
* 在绑定事件中,且event中支持事件逻辑时
|
|
293
293
|
*/
|
|
294
294
|
// FIXME 先用白名单的方式支持
|
|
295
|
-
const { parentNode } = node;
|
|
296
|
-
const grandParentNode = parentNode?.parentNode;
|
|
297
|
-
if (
|
|
298
|
-
grandParentNode.concept === 'BindEvent' &&
|
|
299
|
-
parentNode.concept === 'Logic' &&
|
|
300
|
-
parentNode.virtualParams?.length &&
|
|
301
|
-
['KeyboardEvent'].includes(parentNode.virtualParams[0]?.__TypeAnnotation?.typeName)
|
|
302
|
-
) {
|
|
303
|
-
systemTree.children[1].logics.push(compareKeyboardInput);
|
|
304
|
-
}
|
|
305
295
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
['
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
296
|
+
// 查找祖先节点
|
|
297
|
+
const bindEventNode = node.getAncestor('BindEvent');
|
|
298
|
+
if (bindEventNode && (bindEventNode as BindEvent).logics.length) {
|
|
299
|
+
const logicNode = (bindEventNode as BindEvent).logics[0];
|
|
300
|
+
if (logicNode.virtualParams?.length && ['KeyboardEvent'].includes(logicNode.virtualParams[0]?.__TypeAnnotation?.typeName)) {
|
|
301
|
+
systemTree.children[1].logics.push(compareKeyboardInput);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (logicNode.virtualParams?.length && ['MouseEvent', 'KeyboardEvent'].includes(logicNode.virtualParams[0]?.__TypeAnnotation?.typeName)) {
|
|
305
|
+
systemTree.children.push(
|
|
306
|
+
new Namespace({
|
|
307
|
+
name: 'category',
|
|
308
|
+
path: `event`,
|
|
309
|
+
title: '事件逻辑',
|
|
310
|
+
logics: stdlibNamespace.findChild('event').logics,
|
|
311
|
+
expanded: false,
|
|
312
|
+
})
|
|
313
|
+
);
|
|
314
|
+
}
|
|
321
315
|
}
|
|
322
316
|
/**
|
|
323
317
|
* end
|
|
@@ -402,8 +396,7 @@ export async function getLogics(node: CallLogic | BindEvent | Identifier | Logic
|
|
|
402
396
|
result.push(systemTree);
|
|
403
397
|
}
|
|
404
398
|
return result;
|
|
405
|
-
}
|
|
406
|
-
if (node?.concept === 'Identifier') {
|
|
399
|
+
} else if (node?.concept === 'Identifier') {
|
|
407
400
|
const extensions = app.dependencies
|
|
408
401
|
.map((dep) => moduleToLogicNamesapce(dep, app.overriddenLogics))
|
|
409
402
|
.filter((item) => item.logics && item.logics.length);
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
Frontend,
|
|
13
13
|
View,
|
|
14
14
|
SynatxNode,
|
|
15
|
+
ViewElement,
|
|
16
|
+
PAGE_COMPONENT_INCLUDE_TAG_MAP,
|
|
15
17
|
} from '..';
|
|
16
18
|
import { formatVariableData, formatFrontEndVariables, formatConfigProperties, formatBackendVariables } from './formatTsUtils';
|
|
17
19
|
|
|
@@ -225,6 +227,9 @@ export async function getMemberIdentifier(node: SynatxNode) {
|
|
|
225
227
|
// 获取前端全局变量
|
|
226
228
|
const frontEndVariable = getFrontEndVariablesIdentifier((node as Identifier).view || (node as Identifier).frontend);
|
|
227
229
|
result.push({ name: '前端全局变量', children: frontEndVariable, expanded: true, icon: 'category' });
|
|
230
|
+
// 获取页面组件
|
|
231
|
+
const pageComponents = await getPageComponentsIdentifier(node);
|
|
232
|
+
result.push({ name: '页面组件', children: pageComponents, expanded: true, icon: 'category' });
|
|
228
233
|
} else if (!(node as Identifier).frontend) {
|
|
229
234
|
// 端事件里既不能调用前端变量 也不能调用后端变量
|
|
230
235
|
const BackEndglobalVariable = getBackendVariablesIdentifier(node);
|
|
@@ -348,3 +353,141 @@ export function getConfigsIdentifier(node: BaseNode): CompletionProperty[] {
|
|
|
348
353
|
});
|
|
349
354
|
return newProperties.concat(extensionConfigProperties);
|
|
350
355
|
}
|
|
356
|
+
function flatElements(elements: ViewElement[], componentList: CompletionProperty[], nodeParentElement: string, currentAttriBute: string) {
|
|
357
|
+
elements.forEach((item) => {
|
|
358
|
+
if (PAGE_COMPONENT_INCLUDE_TAG_MAP?.[item.tag]) {
|
|
359
|
+
console.log('componentItem', item)
|
|
360
|
+
const current = item.name === nodeParentElement
|
|
361
|
+
const stashItem: any = {
|
|
362
|
+
name: `${item.name}${current ? '(当前组件)' : ''}`,
|
|
363
|
+
value: item.name,
|
|
364
|
+
expression: new Identifier({
|
|
365
|
+
name: current ? '当前组件' : item.name,
|
|
366
|
+
namespace: `elements.${current ? '$ce' : item.name}.property`
|
|
367
|
+
}),
|
|
368
|
+
children: [],
|
|
369
|
+
};
|
|
370
|
+
const attrsList = item.bindAttrs.filter((attr) => {
|
|
371
|
+
if (PAGE_COMPONENT_INCLUDE_TAG_MAP[item.tag]?.[attr.name]) {
|
|
372
|
+
if (current && attr.name === currentAttriBute) {
|
|
373
|
+
return false
|
|
374
|
+
} else {
|
|
375
|
+
return true
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
})
|
|
379
|
+
attrsList.forEach((attr) => {
|
|
380
|
+
const currentAttrInfo = PAGE_COMPONENT_INCLUDE_TAG_MAP[ item.tag]?.[attr.name]
|
|
381
|
+
if (attr.name !== 'sorting') {
|
|
382
|
+
const stashAttr: any = {
|
|
383
|
+
...attr,
|
|
384
|
+
name: attr.name,
|
|
385
|
+
value: `${item.name}.${attr.name}`,
|
|
386
|
+
expression: new MemberExpression({
|
|
387
|
+
object: stashItem.expression,
|
|
388
|
+
property: new Identifier({
|
|
389
|
+
name: currentAttrInfo.value,
|
|
390
|
+
namespace: attr.name
|
|
391
|
+
}),
|
|
392
|
+
}),
|
|
393
|
+
};
|
|
394
|
+
const completionProperty = new CompletionProperty(stashAttr);
|
|
395
|
+
completionProperty.name = currentAttrInfo ? `${currentAttrInfo.value}(${currentAttrInfo.label})` : attr.name;
|
|
396
|
+
completionProperty.icon = 'attr'
|
|
397
|
+
stashItem.children.push(completionProperty)
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
if (['u-select', 'van-pickerson'].includes(item.tag)) {
|
|
401
|
+
const pageAttr: any = {
|
|
402
|
+
name: 'page-number',
|
|
403
|
+
value: `${item.name}.page-number`,
|
|
404
|
+
expression: new MemberExpression({
|
|
405
|
+
object: stashItem.expression,
|
|
406
|
+
property: new Identifier({
|
|
407
|
+
name: 'page',
|
|
408
|
+
namespace: 'page-number'
|
|
409
|
+
}),
|
|
410
|
+
}),
|
|
411
|
+
};
|
|
412
|
+
const completionProperty = new CompletionProperty(pageAttr);
|
|
413
|
+
completionProperty.name = 'page(当前页数)';
|
|
414
|
+
completionProperty.icon = 'attr'
|
|
415
|
+
stashItem.children.push(completionProperty)
|
|
416
|
+
} else if (['u-list-view', 'u-grid-view', 'u-table-view', 'van-list-view', 'van-grid-view'].includes(item.tag)) {
|
|
417
|
+
const sortAttr: any = {
|
|
418
|
+
name: 'sort',
|
|
419
|
+
value: `${item.name}.sort`,
|
|
420
|
+
expression: new MemberExpression({
|
|
421
|
+
object: stashItem.expression,
|
|
422
|
+
property: new Identifier({
|
|
423
|
+
name: 'sort',
|
|
424
|
+
namespace: 'sorting.field'
|
|
425
|
+
}),
|
|
426
|
+
}),
|
|
427
|
+
};
|
|
428
|
+
const sortCompletionProperty = new CompletionProperty(sortAttr);
|
|
429
|
+
sortCompletionProperty.name = 'sort(排序属性)';
|
|
430
|
+
sortCompletionProperty.icon = 'attr'
|
|
431
|
+
stashItem.children.push(sortCompletionProperty)
|
|
432
|
+
const orderAttr: any = {
|
|
433
|
+
name: 'order',
|
|
434
|
+
value: `${item.name}.order`,
|
|
435
|
+
expression: new MemberExpression({
|
|
436
|
+
object: stashItem.expression,
|
|
437
|
+
property: new Identifier({
|
|
438
|
+
name: 'order',
|
|
439
|
+
namespace: 'sorting.order'
|
|
440
|
+
}),
|
|
441
|
+
}),
|
|
442
|
+
};
|
|
443
|
+
const orderCompletionProperty = new CompletionProperty(orderAttr);
|
|
444
|
+
orderCompletionProperty.name = 'order(排序顺序)';
|
|
445
|
+
orderCompletionProperty.icon = 'attr'
|
|
446
|
+
stashItem.children.push(orderCompletionProperty)
|
|
447
|
+
}
|
|
448
|
+
const completionProperty = new CompletionProperty(stashItem);
|
|
449
|
+
completionProperty.icon = 'element';
|
|
450
|
+
if (current) {
|
|
451
|
+
componentList.unshift(completionProperty)
|
|
452
|
+
} else {
|
|
453
|
+
componentList.push(completionProperty)
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (item.children.length > 0) {
|
|
457
|
+
flatElements(item.children, componentList, nodeParentElement, currentAttriBute)
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
}
|
|
461
|
+
// 获取页面组件
|
|
462
|
+
export function getPageComponentsIdentifier(node: SynatxNode): CompletionProperty[] {
|
|
463
|
+
const { fileNode } = node.getCurrentSource();
|
|
464
|
+
const stashElements = (fileNode as View).elements;
|
|
465
|
+
const componentList: CompletionProperty[] = []
|
|
466
|
+
const nodeParentElement = getCurrentElement(node)?.name
|
|
467
|
+
const currentAttriBute = getCurrentAttriBute(node)?.name
|
|
468
|
+
flatElements(stashElements, componentList, nodeParentElement, currentAttriBute)
|
|
469
|
+
return componentList
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function getCurrentElement(item: any): ViewElement | undefined {
|
|
473
|
+
if (!item?.parentNode) return undefined
|
|
474
|
+
if (item.parentNode?.concept === 'ViewElement') {
|
|
475
|
+
return item.parentNode
|
|
476
|
+
} else if (item.parentNode?.concept === 'View') {
|
|
477
|
+
return undefined
|
|
478
|
+
} else {
|
|
479
|
+
return getCurrentElement(item.parentNode)
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function getCurrentAttriBute(item: any): BindAttribute | undefined {
|
|
484
|
+
if (item.concept === 'BindAttribute') {
|
|
485
|
+
return item
|
|
486
|
+
} else {
|
|
487
|
+
if (item?.parentNode && item.parentNode?.concept !== 'View') {
|
|
488
|
+
return getCurrentAttriBute(item.parentNode)
|
|
489
|
+
} else {
|
|
490
|
+
return undefined
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|