@lcap/nasl 3.9.0-beta.2 → 3.9.0-beta.20
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.d.ts +0 -5
- package/out/automate/engine/utils.d.ts.map +1 -1
- package/out/automate/engine/utils.js +1 -123
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/upgrader/2.18.js +1 -1
- package/out/automate/upgrader/2.18.js.map +1 -1
- package/out/common/Command.js +1 -1
- package/out/common/Command.js.map +1 -1
- package/out/common/Messager.d.ts.map +1 -1
- package/out/common/Messager.js +15 -5
- package/out/common/Messager.js.map +1 -1
- package/out/config.d.ts +2 -0
- package/out/config.d.ts.map +1 -1
- package/out/config.js +5 -2
- package/out/config.js.map +1 -1
- package/out/generator/annotation/full.d.ts +6 -0
- package/out/generator/annotation/full.d.ts.map +1 -0
- package/out/generator/annotation/full.js +28 -0
- package/out/generator/annotation/full.js.map +1 -0
- package/out/generator/annotation/incremental.d.ts +7 -0
- package/out/generator/annotation/incremental.d.ts.map +1 -0
- package/out/generator/annotation/incremental.js +145 -0
- package/out/generator/annotation/incremental.js.map +1 -0
- package/out/generator/annotation/index.d.ts +5 -0
- package/out/generator/annotation/index.d.ts.map +1 -0
- package/out/generator/annotation/index.js +21 -0
- package/out/generator/annotation/index.js.map +1 -0
- package/out/generator/annotation/types.d.ts +14 -0
- package/out/generator/annotation/types.d.ts.map +1 -0
- package/out/generator/annotation/types.js +3 -0
- package/out/generator/annotation/types.js.map +1 -0
- package/out/generator/annotation/utils.d.ts +14 -0
- package/out/generator/annotation/utils.d.ts.map +1 -0
- package/out/generator/annotation/utils.js +51 -0
- package/out/generator/annotation/utils.js.map +1 -0
- package/out/generator/compileComponent.d.ts.map +1 -1
- package/out/generator/compileComponent.js +2 -0
- package/out/generator/compileComponent.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +5 -2
- package/out/generator/genBundleFiles.d.ts.map +1 -1
- package/out/generator/genBundleFiles.js +42 -31
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/index.d.ts +2 -0
- package/out/generator/index.d.ts.map +1 -1
- package/out/generator/index.js +2 -0
- package/out/generator/index.js.map +1 -1
- package/out/generator/permission.d.ts.map +1 -1
- package/out/generator/permission.js +25 -5
- package/out/generator/permission.js.map +1 -1
- package/out/generator/release-body/body.d.ts +3 -1
- package/out/generator/release-body/body.d.ts.map +1 -1
- package/out/generator/release-body/body.js +40 -28
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/data.d.ts +1 -0
- package/out/generator/release-body/data.d.ts.map +1 -1
- package/out/generator/release-body/data.js +10 -2
- package/out/generator/release-body/data.js.map +1 -1
- package/out/generator/release-body/internal.d.ts.map +1 -1
- package/out/generator/release-body/utils.d.ts +4 -3
- package/out/generator/release-body/utils.d.ts.map +1 -1
- package/out/generator/release-body/utils.js +60 -10
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/generator/ui-library-declaration/basic.d.ts +7 -0
- package/out/generator/ui-library-declaration/basic.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/basic.js +114 -0
- package/out/generator/ui-library-declaration/basic.js.map +1 -0
- package/out/generator/ui-library-declaration/custom.d.ts +11 -0
- package/out/generator/ui-library-declaration/custom.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/custom.js +149 -0
- package/out/generator/ui-library-declaration/custom.js.map +1 -0
- package/out/generator/ui-library-declaration/dependency.d.ts +8 -0
- package/out/generator/ui-library-declaration/dependency.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/dependency.js +169 -0
- package/out/generator/ui-library-declaration/dependency.js.map +1 -0
- package/out/generator/ui-library-declaration/format.d.ts +30 -0
- package/out/generator/ui-library-declaration/format.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/format.js +382 -0
- package/out/generator/ui-library-declaration/format.js.map +1 -0
- package/out/generator/ui-library-declaration/index.d.ts +3 -0
- package/out/generator/ui-library-declaration/index.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/index.js +19 -0
- package/out/generator/ui-library-declaration/index.js.map +1 -0
- package/out/generator/ui-library-declaration/manifest.d.ts +5 -0
- package/out/generator/ui-library-declaration/manifest.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/manifest.js +27 -0
- package/out/generator/ui-library-declaration/manifest.js.map +1 -0
- package/out/generator/ui-library-declaration/material.d.ts +6 -0
- package/out/generator/ui-library-declaration/material.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/material.js +90 -0
- package/out/generator/ui-library-declaration/material.js.map +1 -0
- package/out/generator/ui-library-declaration/types.d.ts +458 -0
- package/out/generator/ui-library-declaration/types.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/types.js +3 -0
- package/out/generator/ui-library-declaration/types.js.map +1 -0
- package/out/generator/ui-library-declaration/utils.d.ts +3 -0
- package/out/generator/ui-library-declaration/utils.d.ts.map +1 -0
- package/out/generator/ui-library-declaration/utils.js +20 -0
- package/out/generator/ui-library-declaration/utils.js.map +1 -0
- package/out/manager/diagnostic.d.ts +2 -0
- package/out/manager/diagnostic.d.ts.map +1 -1
- package/out/manager/diagnostic.js +9 -0
- package/out/manager/diagnostic.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +45 -10
- package/out/natural/genNaturalTS.d.ts.map +1 -1
- package/out/natural/genNaturalTS.js +57 -33
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/getUILib.d.ts.map +1 -1
- package/out/natural/getContext/getUILib.js +7 -3
- package/out/natural/getContext/getUILib.js.map +1 -1
- package/out/natural/getContext/index.d.ts +20 -7
- package/out/natural/getContext/index.d.ts.map +1 -1
- package/out/natural/getContext/index.js +150 -22
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/getContext/naslStdlibMap.js +8 -8
- package/out/natural/getContext/naslStdlibMap.js.map +1 -1
- package/out/natural/tools.d.ts +21 -0
- package/out/natural/tools.d.ts.map +1 -1
- package/out/natural/tools.js +143 -2
- package/out/natural/tools.js.map +1 -1
- package/out/natural/transformTS2UI.d.ts.map +1 -1
- package/out/natural/transformTS2UI.js +378 -307
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.d.ts +3 -5
- package/out/natural/transformTSCode.d.ts.map +1 -1
- package/out/natural/transformTSCode.js +30 -1089
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/natural/transforms/registerTransform.d.ts +8 -0
- package/out/natural/transforms/registerTransform.d.ts.map +1 -0
- package/out/natural/transforms/registerTransform.js +24 -0
- package/out/natural/transforms/registerTransform.js.map +1 -0
- package/out/natural/transforms/transform2LogicItem.d.ts +25 -0
- package/out/natural/transforms/transform2LogicItem.d.ts.map +1 -0
- package/out/natural/transforms/transform2LogicItem.js +1262 -0
- package/out/natural/transforms/transform2LogicItem.js.map +1 -0
- package/out/natural/transforms/transform2TypeAnnotation.d.ts +3 -0
- package/out/natural/transforms/transform2TypeAnnotation.d.ts.map +1 -0
- package/out/natural/transforms/transform2TypeAnnotation.js +86 -0
- package/out/natural/transforms/transform2TypeAnnotation.js.map +1 -0
- package/out/natural/transforms/utils.d.ts +9 -0
- package/out/natural/transforms/utils.d.ts.map +1 -0
- package/out/natural/transforms/utils.js +59 -0
- package/out/natural/transforms/utils.js.map +1 -0
- package/out/server/extendBaseNode.d.ts.map +1 -1
- package/out/server/extendBaseNode.js +3 -6
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/index.d.ts +1 -2
- package/out/server/index.d.ts.map +1 -1
- package/out/server/index.js +2 -2
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +10 -3
- package/out/server/naslServer.d.ts.map +1 -1
- package/out/server/naslServer.js +221 -126
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.d.ts +1 -1
- package/out/server/translator.d.ts.map +1 -1
- package/out/server/translator.js +89 -53
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -25
- package/out/service/storage/init.d.ts.map +1 -1
- package/out/service/storage/init.js +19 -36
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/types.d.ts +41 -0
- package/out/service/storage/types.d.ts.map +1 -0
- package/out/service/storage/types.js +10 -0
- package/out/service/storage/types.js.map +1 -0
- package/out/service/storage/utils.d.ts +15 -0
- package/out/service/storage/utils.d.ts.map +1 -0
- package/out/service/storage/utils.js +68 -0
- package/out/service/storage/utils.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/index.d.ts +6 -0
- package/out/templator/block2nasl/jsx2nasl/index.d.ts.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/index.js +15 -0
- package/out/templator/block2nasl/jsx2nasl/index.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.d.ts +4 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.d.ts.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.js +213 -0
- package/out/templator/block2nasl/jsx2nasl/transform-expression2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.d.ts +15 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.d.ts.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.js +201 -0
- package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.d.ts +5 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.d.ts.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.js +186 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tstype2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.d.ts +29 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.d.ts.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.js +336 -0
- package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.js.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/utils.d.ts +3 -0
- package/out/templator/block2nasl/jsx2nasl/utils.d.ts.map +1 -0
- package/out/templator/block2nasl/jsx2nasl/utils.js +26 -0
- package/out/templator/block2nasl/jsx2nasl/utils.js.map +1 -0
- package/out/templator/block2nasl/transformBlock2Nasl.d.ts +11 -0
- package/out/templator/block2nasl/transformBlock2Nasl.d.ts.map +1 -0
- package/out/templator/block2nasl/transformBlock2Nasl.js +122 -0
- package/out/templator/block2nasl/transformBlock2Nasl.js.map +1 -0
- package/out/templator/block2nasl/viewMergeBlock.d.ts +17 -0
- package/out/templator/block2nasl/viewMergeBlock.d.ts.map +1 -0
- package/out/templator/block2nasl/viewMergeBlock.js +185 -0
- package/out/templator/block2nasl/viewMergeBlock.js.map +1 -0
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/utils/node.d.ts.map +1 -1
- package/out/utils/node.js +0 -4
- package/out/utils/node.js.map +1 -1
- package/out/utils/uiPathId.d.ts +2 -0
- package/out/utils/uiPathId.d.ts.map +1 -0
- package/out/utils/uiPathId.js +34 -0
- package/out/utils/uiPathId.js.map +1 -0
- package/package.json +13 -25
- package/sandbox/stdlib/nasl.processV2.ts +19 -0
- package/sandbox/stdlib/nasl.ui.components.pc.ts +16 -0
- package/sandbox/stdlib/nasl.ui.definition.ts +41 -1
- package/sandbox/stdlib/nasl.ui.ts +24 -8
- package/sandbox/stdlib/nasl.util.ts +6 -15
- package/sandbox-natural/stdlib/nasl.core.d.ts +54 -0
- package/sandbox-natural/stdlib/nasl.oql.d.ts +22 -0
- package/sandbox-natural/stdlib/nasl.ui.d.ts +78 -0
- package/sandbox-natural/stdlib/nasl.ui.h5.d.ts +1684 -1643
- package/sandbox-natural/stdlib/nasl.ui.h5.json +15746 -15045
- package/sandbox-natural/stdlib/nasl.ui.pc.d.ts +5341 -5154
- package/sandbox-natural/stdlib/nasl.ui.pc.json +31176 -30681
- package/sandbox-natural/stdlib/{nasl.util.ts → nasl.util.d.ts} +50 -45
- package/ts-worker/bundle.js +2 -2
- package/ts-worker/lib/Messager.js +8 -1
- package/ts-worker/lib/tsserver.js +6 -6
- package/sandbox-natural/stdlib/nasl.core.ts +0 -36
- package/sandbox-natural/stdlib/nasl.oql.ts +0 -14
- package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +0 -90
- package/sandbox-natural/stdlib/nasl.ui.ts +0 -63
package/out/server/naslServer.js
CHANGED
|
@@ -54,7 +54,7 @@ const diagnostic_1 = require("../manager/diagnostic");
|
|
|
54
54
|
const naslStdlibMap_1 = __importDefault(require("./naslStdlibMap"));
|
|
55
55
|
const utils_1 = require("../utils");
|
|
56
56
|
const decorators_1 = require("../decorators");
|
|
57
|
-
const
|
|
57
|
+
const nasl_concepts_1 = require("@lcap/nasl-concepts");
|
|
58
58
|
const EmbeddedTSFileLineMap = {
|
|
59
59
|
Entity: 3,
|
|
60
60
|
};
|
|
@@ -129,16 +129,6 @@ function isFunctionWithFixedTimeZoneParam(calleeName) {
|
|
|
129
129
|
const fns = ['CurrDateTime', 'CurrDate', 'CurrTime', 'FormatDateTime'];
|
|
130
130
|
return fns.includes(calleeName);
|
|
131
131
|
}
|
|
132
|
-
const timeZoneArgumentIndexMap = new Map([
|
|
133
|
-
['ToString', 1],
|
|
134
|
-
['CurrDateTime', 0],
|
|
135
|
-
['CurrDate', 0],
|
|
136
|
-
['CurrTime', 0],
|
|
137
|
-
['FormatDateTime', 2],
|
|
138
|
-
['jsonSerialize', 1],
|
|
139
|
-
['GetDateCount', 2],
|
|
140
|
-
['GetSpecificDaysOfWeek', 3]
|
|
141
|
-
]);
|
|
142
132
|
const allComponent = {};
|
|
143
133
|
let NaslServer = NaslServer_1 = class NaslServer {
|
|
144
134
|
constructor(opt) {
|
|
@@ -163,6 +153,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
163
153
|
this.changeStackList = [];
|
|
164
154
|
// 包含组件逻辑调用的逻辑map
|
|
165
155
|
this.logicSetWithComponentLogic = new Set();
|
|
156
|
+
this.isFirstScreen = true;
|
|
166
157
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
167
158
|
if (globalThis.process)
|
|
168
159
|
// For TS build
|
|
@@ -195,7 +186,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
195
186
|
handleMessage: async ({ data }) => {
|
|
196
187
|
if (data && data.event === 'publishDiagnostics') {
|
|
197
188
|
const records = await this._resolveDiagnosticRecords(data.records, data.versions);
|
|
198
|
-
|
|
189
|
+
if (this.isFirstScreen) {
|
|
190
|
+
await this.diagnosticManager.setInitialDiagData(records);
|
|
191
|
+
this.isFirstScreen = false;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
await this.diagnosticManager.pushAll(records);
|
|
195
|
+
}
|
|
199
196
|
try {
|
|
200
197
|
// 结束诊断和标注
|
|
201
198
|
(0, common_1.invokeCommand)('naslServer:endWork');
|
|
@@ -224,6 +221,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
224
221
|
*/
|
|
225
222
|
try {
|
|
226
223
|
const changeEvent = item.originEvent;
|
|
224
|
+
// 设置国际化相关内容传标识过来,不需要进入语言服务
|
|
225
|
+
if (changeEvent?.field === 'setI18n')
|
|
226
|
+
return;
|
|
227
227
|
const changeNode = changeEvent.target;
|
|
228
228
|
const { fileNode } = this.getCurrentSource(changeNode);
|
|
229
229
|
// 这个方法是 5.0 加入标准库的,但是这里 ts 版本是 4.x,ci 会挂,所以需要忽略
|
|
@@ -260,7 +260,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
260
260
|
return this.messager.requestCommand('start');
|
|
261
261
|
}
|
|
262
262
|
terminate() {
|
|
263
|
-
this.worker.terminate();
|
|
263
|
+
return this.worker.terminate();
|
|
264
264
|
}
|
|
265
265
|
async createUiTs(components, optinos) {
|
|
266
266
|
const { standardUIComponents, // 标准组件(带有ts类型定义文件的组件)
|
|
@@ -269,6 +269,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
269
269
|
const { code, elementsLogic } = await (0, createUiTs_1.default)(allComponent);
|
|
270
270
|
// 处理一堆api.ts的类型
|
|
271
271
|
const convertTsCode = (code) => {
|
|
272
|
+
code = code || '';
|
|
272
273
|
code = code.replace(/nasl.core.Integer/g, 'nasl.core.Long');
|
|
273
274
|
// 匹配union类型的正则
|
|
274
275
|
const unionReg = /\s*['"].*['"](\s*\|\s*['"].*['"])+/g;
|
|
@@ -429,11 +430,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
429
430
|
}
|
|
430
431
|
async openApp(app, performance = false, needRegisterCommand = true) {
|
|
431
432
|
this.logger.time('生成 TS 文件');
|
|
433
|
+
this.logger.time('简单语义分析');
|
|
434
|
+
await utils.runGeneratorSync(nasl_concepts_1.semantics.collectAllSemanticCtx(app));
|
|
435
|
+
this.logger.timeEnd('简单语义分析');
|
|
436
|
+
// semantics.printSemanticDataInfo();
|
|
432
437
|
(0, common_1.invokeCommand)('naslServer:startWork');
|
|
433
438
|
app.naslServer = this;
|
|
434
439
|
const self = this;
|
|
435
440
|
this.performance = performance;
|
|
436
|
-
const results = await utils.
|
|
441
|
+
const results = await utils.runGeneratorAsync(getAllTsFiles());
|
|
437
442
|
const files = results.map((result) => ({
|
|
438
443
|
file: result.filePath,
|
|
439
444
|
fileContent: result.code,
|
|
@@ -454,6 +459,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
454
459
|
callback();
|
|
455
460
|
});
|
|
456
461
|
}
|
|
462
|
+
nasl_concepts_1.semantics.clearSemanticData();
|
|
457
463
|
this.logger.timeEnd('生成 TS 文件');
|
|
458
464
|
function* getAllTsFiles() {
|
|
459
465
|
const files = yield* self.contentToFile(app);
|
|
@@ -528,15 +534,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
528
534
|
const url = `/proxy/nasl-storage/api/App/debugEmbedded?id=${app.id}`;
|
|
529
535
|
/// #if process.env.NODE_ENV === 'development'
|
|
530
536
|
// 首次尝试请求
|
|
531
|
-
await this.http.post(
|
|
537
|
+
await this.http.post(url, openFiles[0]).catch(() => (this.openDebugEmbedded = false));
|
|
532
538
|
if (this.openDebugEmbedded && globalThis.window) {
|
|
533
539
|
// For TS build
|
|
534
540
|
try {
|
|
535
541
|
let canDebug = true;
|
|
536
|
-
await this.http.post(
|
|
542
|
+
await this.http.post(url, openFiles[0]).catch(() => (canDebug = false));
|
|
537
543
|
if (canDebug) {
|
|
538
544
|
await Promise.all(openFiles.map(async (file) => {
|
|
539
|
-
const res = await this.http.post(
|
|
545
|
+
const res = await this.http.post(url, file);
|
|
540
546
|
return res.data;
|
|
541
547
|
}));
|
|
542
548
|
}
|
|
@@ -547,7 +553,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
547
553
|
}
|
|
548
554
|
/// #endif
|
|
549
555
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
550
|
-
if (globalThis.process) {
|
|
556
|
+
if (globalThis.process && process.env.NODE_ENV === 'development') {
|
|
551
557
|
// For TS build
|
|
552
558
|
try {
|
|
553
559
|
await Promise.all(openFiles.map(async (file) => fs.outputFile(path.join(__dirname, '../debug/apps', app.id, file.file), file.fileContent)));
|
|
@@ -855,7 +861,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
855
861
|
if (!record || !record.node) {
|
|
856
862
|
return;
|
|
857
863
|
}
|
|
858
|
-
|
|
864
|
+
let { node } = record;
|
|
865
|
+
// @ts-ignore
|
|
866
|
+
let nodeRaw = node.__v_raw || node; // 暂时先这样提速
|
|
859
867
|
// 先获取原来的节点先清除一下之前有异常的节点,下面重新赋值
|
|
860
868
|
const oldRecord = self.diagnosticManager.getRecord?.(record.id);
|
|
861
869
|
// 处理旧数据
|
|
@@ -880,12 +888,12 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
880
888
|
}
|
|
881
889
|
// 语义诊断
|
|
882
890
|
if (isChangeInterface) {
|
|
883
|
-
yield* self.existStructureFix(record.semanticDiagnostics,
|
|
891
|
+
yield* self.existStructureFix(record.semanticDiagnostics, node, self);
|
|
884
892
|
}
|
|
885
893
|
// 单独处理 oql 语义错误提示
|
|
886
|
-
if (
|
|
894
|
+
if (nodeRaw instanceof concepts_1.Logic) {
|
|
887
895
|
yield* utils.wrapForEachToGenerator(record?.syntaxDiagnostics, function* test(item) {
|
|
888
|
-
const minRange = yield* self._findMinRangeWithGenerator(item,
|
|
896
|
+
const minRange = yield* self._findMinRangeWithGenerator(item, node);
|
|
889
897
|
if (minRange?.node instanceof concepts_1.OqlQueryComponent) {
|
|
890
898
|
if (item.text === 'Invalid character.') {
|
|
891
899
|
record.semanticDiagnostics.push(item);
|
|
@@ -898,7 +906,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
898
906
|
(0, translator_2.checkAStructure_)(diag.text);
|
|
899
907
|
});
|
|
900
908
|
record.semanticDiagnostics = (yield* utils.wrapMapToGenerator(record.semanticDiagnostics, function* (diag) {
|
|
901
|
-
return yield* self._resolveDiagnosticWithGenerator(diag,
|
|
909
|
+
return yield* self._resolveDiagnosticWithGenerator(diag, node, record);
|
|
902
910
|
})).filter((diag) => !!diag);
|
|
903
911
|
record.semanticDiagnostics.push(...(yield* self._attachDiagnosticsWithGenerator(node)));
|
|
904
912
|
// 报错降级逻辑
|
|
@@ -979,21 +987,21 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
979
987
|
`'__onlineConfigValueEmpty' is declared but its value is never read.`,
|
|
980
988
|
`'__UpdateNoProperty__' is declared but its value is never read.`,
|
|
981
989
|
].includes(diag.text)) {
|
|
982
|
-
return yield* self._resolveDiagnosticWithGenerator(diag,
|
|
990
|
+
return yield* self._resolveDiagnosticWithGenerator(diag, node, record);
|
|
983
991
|
}
|
|
984
992
|
if (diag.text.includes(` is declared but its value is never read.`)) {
|
|
985
993
|
// 局部变量和输入变量未使用的警告
|
|
986
|
-
const fromModule =
|
|
987
|
-
const fromConnector =
|
|
988
|
-
if ((concepts_1.asserts.isStrictView(
|
|
994
|
+
const fromModule = nodeRaw.parentNode.concept === 'Module' || nodeRaw.module;
|
|
995
|
+
const fromConnector = nodeRaw.parentNode.concept === 'Connector';
|
|
996
|
+
if ((concepts_1.asserts.isStrictView(nodeRaw) || concepts_1.asserts.isStrictLogic(nodeRaw)) && !(fromModule || fromConnector)) {
|
|
989
997
|
/**
|
|
990
998
|
* javalogic不用提示
|
|
991
999
|
*/
|
|
992
|
-
if (concepts_1.asserts.isStrictLogic(
|
|
1000
|
+
if (concepts_1.asserts.isStrictLogic(nodeRaw) && self._isJavalogic(nodeRaw)) {
|
|
993
1001
|
return null;
|
|
994
1002
|
}
|
|
995
|
-
concepts_1.asserts.assertFileNode(
|
|
996
|
-
const minRange = yield* self._findMinRangeWithGenerator(diag,
|
|
1003
|
+
concepts_1.asserts.assertFileNode(nodeRaw);
|
|
1004
|
+
const minRange = yield* self._findMinRangeWithGenerator(diag, node);
|
|
997
1005
|
if (minRange) {
|
|
998
1006
|
/**
|
|
999
1007
|
* 如果节点是入参类型
|
|
@@ -1510,13 +1518,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1510
1518
|
*/
|
|
1511
1519
|
*_attachDiagnosticsWithGenerator(fileNode) {
|
|
1512
1520
|
// 每次诊断前先清空这个Set
|
|
1521
|
+
// @ts-ignore
|
|
1522
|
+
let fileNodeRaw = fileNode.__v_raw || fileNode; // 暂时先这样提速
|
|
1513
1523
|
this.logicSetWithComponentLogic = new Set();
|
|
1514
1524
|
const self = this;
|
|
1515
1525
|
const diagnostics = [];
|
|
1516
|
-
if (
|
|
1517
|
-
yield* utils.wrapIteratorToGenerator(
|
|
1526
|
+
if (fileNodeRaw instanceof concepts_1.View || fileNodeRaw instanceof concepts_1.BusinessComponent) {
|
|
1527
|
+
yield* utils.wrapIteratorToGenerator(fileNodeRaw.sourceMap.entries(), function* attachView([node, value]) {
|
|
1518
1528
|
const likeComponent = node.getAncestor('View') || node.getAncestor('BusinessComponent');
|
|
1519
|
-
if (node instanceof concepts_1.ViewElement && likeComponent ===
|
|
1529
|
+
if (node instanceof concepts_1.ViewElement && likeComponent === fileNodeRaw) {
|
|
1520
1530
|
if (node.tag) {
|
|
1521
1531
|
yield* utils.wrapForEachToGenerator(node.bindAttrs, (bindAttr) => {
|
|
1522
1532
|
if ((bindAttr.model || bindAttr.sync) && bindAttr.expression) {
|
|
@@ -1560,14 +1570,14 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1560
1570
|
});
|
|
1561
1571
|
}
|
|
1562
1572
|
}
|
|
1563
|
-
else if ((node instanceof concepts_1.Variable || node instanceof concepts_1.Return) && likeComponent ===
|
|
1573
|
+
else if ((node instanceof concepts_1.Variable || node instanceof concepts_1.Return) && likeComponent === fileNodeRaw) {
|
|
1564
1574
|
if (!node.typeAnnotation && !node.__TypeAnnotation) {
|
|
1565
1575
|
const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
|
|
1566
1576
|
let msg;
|
|
1567
|
-
yield*
|
|
1577
|
+
yield* fileNodeRaw.traverseChildrenGenerator((nodeIn) => {
|
|
1568
1578
|
if (nodeIn && (nodeIn instanceof concepts_1.BatchAssignment || (nodeIn instanceof concepts_1.Assignment && nodeIn.left?.name))) {
|
|
1569
1579
|
// 子页面内部逻辑过滤
|
|
1570
|
-
if ((nodeIn.view || nodeIn.getAncestor('BusinessComponent')) !==
|
|
1580
|
+
if ((nodeIn.view || nodeIn.getAncestor('BusinessComponent')) !== fileNodeRaw)
|
|
1571
1581
|
return;
|
|
1572
1582
|
// 当局部变量、输出参数属于页面内逻辑时,需过滤同页面下不同逻辑下的同名变量
|
|
1573
1583
|
if (node.logic && node.logic !== nodeIn.logic)
|
|
@@ -1627,7 +1637,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1627
1637
|
node.tsErrorDetail = diagnostic;
|
|
1628
1638
|
diagnostics.push(diagnostic);
|
|
1629
1639
|
}
|
|
1630
|
-
const fileSourceCode = self.getNodeCode(
|
|
1640
|
+
const fileSourceCode = self.getNodeCode(fileNodeRaw, value);
|
|
1631
1641
|
if (fileSourceCode.includes('|') && fileSourceCode.includes('.metadataTypes.')) {
|
|
1632
1642
|
const typeAnnotation = node.typeAnnotation.toJSON();
|
|
1633
1643
|
yield* self._treeMetadataType2CoreType(typeAnnotation, node.rootNode);
|
|
@@ -1695,18 +1705,41 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1695
1705
|
node.tsErrorDetail = diagnostic;
|
|
1696
1706
|
}
|
|
1697
1707
|
}
|
|
1708
|
+
else if (node instanceof concepts_1.CallLogic) {
|
|
1709
|
+
const viewElement = node.getAncestor('ViewElement');
|
|
1710
|
+
if (viewElement && viewElement.tag === 'u-download' && node.parentNode.name === "dataSource") {
|
|
1711
|
+
// node.Pa
|
|
1712
|
+
const args = ['page', 'size'];
|
|
1713
|
+
const values = [];
|
|
1714
|
+
node.arguments && node.arguments.forEach((arg) => {
|
|
1715
|
+
const expression = arg.expression;
|
|
1716
|
+
if (expression && expression.concept === "Identifier" && expression.namespace === "backend") {
|
|
1717
|
+
values.push(expression.name);
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
if (args.length !== values.length || new Set(values).size !== values.length) {
|
|
1721
|
+
const diagnostic = {
|
|
1722
|
+
node,
|
|
1723
|
+
severity: 'error',
|
|
1724
|
+
message: `下载组件必须为page和size指定入参,且不能重复`,
|
|
1725
|
+
};
|
|
1726
|
+
diagnostics.push(diagnostic);
|
|
1727
|
+
node.tsErrorDetail = diagnostic;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1698
1731
|
else {
|
|
1699
1732
|
self.checkNodeError(node, diagnostics);
|
|
1700
1733
|
}
|
|
1701
1734
|
});
|
|
1702
1735
|
}
|
|
1703
|
-
else if (
|
|
1704
|
-
const dataSourceGroup =
|
|
1736
|
+
else if (fileNodeRaw instanceof concepts_1.DataSource) {
|
|
1737
|
+
const dataSourceGroup = fileNodeRaw.rootNode.configuration?.getGroup('dataSource');
|
|
1705
1738
|
if (dataSourceGroup) {
|
|
1706
|
-
const property = dataSourceGroup.getProperty(
|
|
1739
|
+
const property = dataSourceGroup.getProperty(fileNodeRaw.name);
|
|
1707
1740
|
if (property && property.values) {
|
|
1708
1741
|
yield* utils.wrapForEachToGenerator(property.values, (propertyValue) => {
|
|
1709
|
-
if (!propertyValue.value &&
|
|
1742
|
+
if (!propertyValue.value && fileNodeRaw.name !== 'defaultDS') {
|
|
1710
1743
|
// prod 环境数据源未配置数据信息 时,不再给出其他提示
|
|
1711
1744
|
// https://projectmanage.netease-official.lcap.163yun.com/dashboard/FeatureDetail?id=2782461488301056
|
|
1712
1745
|
if (propertyValue.env === 'online')
|
|
@@ -1727,7 +1760,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1727
1760
|
diagnostics.push(diagnostic);
|
|
1728
1761
|
}
|
|
1729
1762
|
else if (propertyValue.value) {
|
|
1730
|
-
const dataSource =
|
|
1763
|
+
const dataSource = fileNodeRaw;
|
|
1731
1764
|
// 数据源有连接错误
|
|
1732
1765
|
let envText;
|
|
1733
1766
|
if (propertyValue.env === 'dev') {
|
|
@@ -1768,18 +1801,18 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
1768
1801
|
}
|
|
1769
1802
|
}
|
|
1770
1803
|
// 检查实体重名
|
|
1771
|
-
const duplidateEntities = this._getDuplicateNames(
|
|
1804
|
+
const duplidateEntities = this._getDuplicateNames(fileNodeRaw, (dataSource) => dataSource.entities, (entity) => entity.name);
|
|
1772
1805
|
if (duplidateEntities.length) {
|
|
1773
1806
|
diagnostics.push({
|
|
1774
1807
|
node: fileNode,
|
|
1775
1808
|
severity: 'error',
|
|
1776
|
-
message: `数据源${
|
|
1809
|
+
message: `数据源${fileNodeRaw.name}存在重名实体:${duplidateEntities.join(', ')}`,
|
|
1777
1810
|
});
|
|
1778
1811
|
}
|
|
1779
1812
|
}
|
|
1780
1813
|
// 加上对实体属性存储类型的校验规则
|
|
1781
|
-
else if (
|
|
1782
|
-
const entity =
|
|
1814
|
+
else if (fileNodeRaw instanceof concepts_1.Entity) {
|
|
1815
|
+
const entity = fileNodeRaw;
|
|
1783
1816
|
const dbType = entity.dataSource.dataSourceSqlType;
|
|
1784
1817
|
const { origin, properties } = entity || {};
|
|
1785
1818
|
if (dbType && !['excel', 'table'].includes(origin) && Array.isArray(properties) && properties.length) {
|
|
@@ -2035,12 +2068,12 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2035
2068
|
});
|
|
2036
2069
|
}
|
|
2037
2070
|
}
|
|
2038
|
-
else if (
|
|
2039
|
-
const { isRefedByTrigger, fRefNames } = yield this.isRefedByTriggerAndReturnFirstRef(
|
|
2040
|
-
if (
|
|
2071
|
+
else if (fileNodeRaw instanceof concepts_1.Logic || fileNodeRaw instanceof concepts_1.OverriddenLogic) {
|
|
2072
|
+
const { isRefedByTrigger, fRefNames } = yield this.isRefedByTriggerAndReturnFirstRef(fileNodeRaw);
|
|
2073
|
+
if (fileNodeRaw instanceof concepts_1.Logic && fileNodeRaw?.exportInterface && fileNodeRaw.calleewholeKey.startsWith('app.logics')) {
|
|
2041
2074
|
let isSame = true;
|
|
2042
|
-
const itf =
|
|
2043
|
-
const { params: logicParams, returns: logicReturns } =
|
|
2075
|
+
const itf = fileNodeRaw.exportInterface;
|
|
2076
|
+
const { params: logicParams, returns: logicReturns } = fileNodeRaw;
|
|
2044
2077
|
const { params: itfParams, returns: itfReturns } = itf;
|
|
2045
2078
|
if (logicParams?.length !== itfParams?.length || logicReturns?.length !== itfReturns?.length) {
|
|
2046
2079
|
isSame = false;
|
|
@@ -2084,29 +2117,29 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2084
2117
|
diagnostics.push(diagnostic);
|
|
2085
2118
|
}
|
|
2086
2119
|
}
|
|
2087
|
-
if (
|
|
2088
|
-
const duplicateLogics = this._getDuplicateNames(
|
|
2089
|
-
if (duplicateLogics.includes(
|
|
2120
|
+
if (fileNodeRaw instanceof concepts_1.Logic && fileNodeRaw.calleewholeKey.startsWith('app.logics')) {
|
|
2121
|
+
const duplicateLogics = this._getDuplicateNames(fileNodeRaw.rootNode, (app) => app.logics, (logic) => logic.name);
|
|
2122
|
+
if (duplicateLogics.includes(fileNodeRaw.name)) {
|
|
2090
2123
|
const diagnostic = {
|
|
2091
2124
|
node: fileNode,
|
|
2092
2125
|
severity: 'error',
|
|
2093
|
-
message: `存在重名服务端逻辑${
|
|
2126
|
+
message: `存在重名服务端逻辑${fileNodeRaw.name}`,
|
|
2094
2127
|
};
|
|
2095
2128
|
diagnostics.push(diagnostic);
|
|
2096
2129
|
}
|
|
2097
2130
|
}
|
|
2098
2131
|
if (isRefedByTrigger) {
|
|
2099
|
-
const { isTriggerRule, errorFRefNames } = this.isTriggerRule(
|
|
2132
|
+
const { isTriggerRule, errorFRefNames } = this.isTriggerRule(fileNodeRaw, fRefNames);
|
|
2100
2133
|
if (!isTriggerRule) {
|
|
2101
2134
|
const diagnostic = {
|
|
2102
2135
|
node: fileNode,
|
|
2103
2136
|
severity: 'error',
|
|
2104
|
-
message: `${
|
|
2137
|
+
message: `${fileNodeRaw.name} 已被消息订阅配置 ${errorFRefNames.join(',')} 引用,但出入参数类型不匹配,或数量不一致`,
|
|
2105
2138
|
};
|
|
2106
2139
|
diagnostics.push(diagnostic);
|
|
2107
2140
|
}
|
|
2108
2141
|
}
|
|
2109
|
-
yield* utils.wrapIteratorToGenerator(
|
|
2142
|
+
yield* utils.wrapIteratorToGenerator(fileNodeRaw.sourceMap.entries(), function* wrapIterator([node, value]) {
|
|
2110
2143
|
if (node instanceof concepts_1.OqlQueryComponent) {
|
|
2111
2144
|
// 自动推导情况
|
|
2112
2145
|
const typeAnnotation = yield* (0, service_1.type2TypeAnnotation)(node.__nodeType);
|
|
@@ -2171,7 +2204,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2171
2204
|
else {
|
|
2172
2205
|
node.__aStructureError = null;
|
|
2173
2206
|
}
|
|
2174
|
-
const fileSourceCode = self.getNodeCode(
|
|
2207
|
+
const fileSourceCode = self.getNodeCode(fileNodeRaw, value);
|
|
2175
2208
|
if (fileSourceCode.includes('|') && fileSourceCode.includes('.metadataTypes.')) {
|
|
2176
2209
|
const typeAnnotation = node.typeAnnotation.toJSON();
|
|
2177
2210
|
yield* self._treeMetadataType2CoreType(typeAnnotation, node.rootNode);
|
|
@@ -2187,7 +2220,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2187
2220
|
}
|
|
2188
2221
|
}
|
|
2189
2222
|
else if (node instanceof concepts_1.Param) {
|
|
2190
|
-
const fileSourceCode = self.getNodeCode(
|
|
2223
|
+
const fileSourceCode = self.getNodeCode(fileNodeRaw, value);
|
|
2191
2224
|
if (fileSourceCode.includes('|') && fileSourceCode.includes('.metadataTypes.')) {
|
|
2192
2225
|
const typeAnnotation = node.typeAnnotation.toJSON();
|
|
2193
2226
|
yield* self._treeMetadataType2CoreType(typeAnnotation, node.rootNode);
|
|
@@ -2205,13 +2238,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2205
2238
|
self.checkNodeError(node, diagnostics);
|
|
2206
2239
|
});
|
|
2207
2240
|
}
|
|
2208
|
-
else if (
|
|
2209
|
-
yield* utils.wrapIteratorToGenerator(
|
|
2241
|
+
else if (fileNodeRaw instanceof concepts_1.Process) {
|
|
2242
|
+
yield* utils.wrapIteratorToGenerator(fileNodeRaw.sourceMap.entries(), ([node, value]) => {
|
|
2210
2243
|
this.checkNodeError(node, diagnostics);
|
|
2211
2244
|
});
|
|
2212
2245
|
}
|
|
2213
|
-
else if (
|
|
2214
|
-
yield* utils.wrapIteratorToGenerator(
|
|
2246
|
+
else if (fileNodeRaw instanceof concepts_1.ProcessV2) {
|
|
2247
|
+
yield* utils.wrapIteratorToGenerator(fileNodeRaw.sourceMap.entries(), function* wrapIterator([node, value]) {
|
|
2215
2248
|
if (node instanceof concepts_1.Return || node instanceof concepts_1.Variable) {
|
|
2216
2249
|
const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
|
|
2217
2250
|
if (!node.typeAnnotation && !node.__TypeAnnotation) {
|
|
@@ -2254,13 +2287,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2254
2287
|
}
|
|
2255
2288
|
});
|
|
2256
2289
|
}
|
|
2257
|
-
else if (
|
|
2258
|
-
const connectorPropertyNames = NaslServer_1.getPropertyNames(
|
|
2259
|
-
const connectionPropertyNames = NaslServer_1.getPropertyNames(
|
|
2290
|
+
else if (fileNodeRaw instanceof concepts_1.Connection) {
|
|
2291
|
+
const connectorPropertyNames = NaslServer_1.getPropertyNames(fileNodeRaw);
|
|
2292
|
+
const connectionPropertyNames = NaslServer_1.getPropertyNames(fileNodeRaw?.connector);
|
|
2260
2293
|
const diagnostic = {
|
|
2261
2294
|
node: fileNode,
|
|
2262
2295
|
severity: 'error',
|
|
2263
|
-
message: `连接器 ${
|
|
2296
|
+
message: `连接器 ${fileNodeRaw.name} 参数配置有更新`,
|
|
2264
2297
|
// 保留原来的内容方便查询一些问题
|
|
2265
2298
|
originalDiagnostic: {
|
|
2266
2299
|
fileName: '',
|
|
@@ -2286,12 +2319,12 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2286
2319
|
else if (!isSameConfig) {
|
|
2287
2320
|
diagnostics.push(diagnostic);
|
|
2288
2321
|
}
|
|
2289
|
-
else if (hasEmptyConfig(
|
|
2322
|
+
else if (hasEmptyConfig(fileNodeRaw)) {
|
|
2290
2323
|
diagnostics.push(diagnostic);
|
|
2291
2324
|
}
|
|
2292
2325
|
}
|
|
2293
|
-
else if (
|
|
2294
|
-
|
|
2326
|
+
else if (fileNodeRaw instanceof concepts_1.MetadataType) {
|
|
2327
|
+
fileNodeRaw?.sourceMap.forEach((value, node) => {
|
|
2295
2328
|
const rulesMap = {};
|
|
2296
2329
|
const { rules, typeAnnotation } = node;
|
|
2297
2330
|
if (Array.isArray(rules)) {
|
|
@@ -2336,19 +2369,19 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2336
2369
|
});
|
|
2337
2370
|
}
|
|
2338
2371
|
// TODO need reset when process support hoc & spread param & type annotation
|
|
2339
|
-
const isInProcess =
|
|
2340
|
-
|
|
2341
|
-
!!
|
|
2342
|
-
!!
|
|
2372
|
+
const isInProcess = fileNodeRaw instanceof concepts_1.Process ||
|
|
2373
|
+
fileNodeRaw instanceof concepts_1.ProcessV2 ||
|
|
2374
|
+
!!fileNodeRaw?.getAncestor('Process') ||
|
|
2375
|
+
!!fileNodeRaw?.getAncestor('ProcessV2');
|
|
2343
2376
|
if (isInProcess) {
|
|
2344
2377
|
// 查找计算过 subLogic 的节点。(目前只有 Logic、ProcessElement、ProcessElementV2)
|
|
2345
|
-
let targetNode =
|
|
2346
|
-
if ((0, asserts_1.isProcess)(
|
|
2347
|
-
(0, asserts_1.isProcessV2)(
|
|
2348
|
-
targetNode =
|
|
2378
|
+
let targetNode = fileNodeRaw;
|
|
2379
|
+
if ((0, asserts_1.isProcess)(fileNodeRaw) ||
|
|
2380
|
+
(0, asserts_1.isProcessV2)(fileNodeRaw)) {
|
|
2381
|
+
targetNode = fileNodeRaw;
|
|
2349
2382
|
}
|
|
2350
2383
|
else {
|
|
2351
|
-
targetNode =
|
|
2384
|
+
targetNode = fileNodeRaw.getAncestor('Process') || fileNodeRaw.getAncestor('ProcessV2');
|
|
2352
2385
|
}
|
|
2353
2386
|
if (targetNode?.subLogics?.length) {
|
|
2354
2387
|
const diagnostic = {
|
|
@@ -2627,7 +2660,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2627
2660
|
// calllogic 中别的类型会强校验,但是内置函数,不会强制校验,下面这几个其实是走的内置函数的实现,所以需要手动增加一下校验
|
|
2628
2661
|
const { calleeNamespace, calleeName } = node.parentNode.parentNode;
|
|
2629
2662
|
if ((calleeNamespace === 'nasl.ui' || calleeNamespace === 'nasl.util') &&
|
|
2630
|
-
(['showMessage', '
|
|
2663
|
+
(['showMessage', 'jsonDeserialize',
|
|
2631
2664
|
'jsonSerialize'].includes(calleeName))) {
|
|
2632
2665
|
showErr = true;
|
|
2633
2666
|
}
|
|
@@ -2790,7 +2823,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2790
2823
|
* 判断当前CallInterface 对应的 Interface 是否含有鉴权方式
|
|
2791
2824
|
*/
|
|
2792
2825
|
hasAuth(node) {
|
|
2793
|
-
const tInterface = (0,
|
|
2826
|
+
const tInterface = (0, service_1.getNodeByNodeCallee)(node.rootNode, node.calleewholeKey);
|
|
2794
2827
|
return tInterface instanceof concepts_1.AuthInterface;
|
|
2795
2828
|
}
|
|
2796
2829
|
/* 接口导入查找 */
|
|
@@ -2896,10 +2929,12 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2896
2929
|
*/
|
|
2897
2930
|
*_findMinRangeWithGenerator(diagnostic, fileNode) {
|
|
2898
2931
|
let minRange;
|
|
2899
|
-
|
|
2932
|
+
// @ts-ignore
|
|
2933
|
+
let fileNodeRaw = fileNode.__v_raw || fileNode; // 暂时先这样提速
|
|
2934
|
+
const { sourceMap } = fileNodeRaw;
|
|
2900
2935
|
// 是否找到了行内准确的,是的话,就不走多行的
|
|
2901
2936
|
let haveLineNode = false;
|
|
2902
|
-
for (
|
|
2937
|
+
for (let [node, item] of sourceMap.entries()) {
|
|
2903
2938
|
/**
|
|
2904
2939
|
* 当前内容的开始行 <= 诊断开始的行 &&
|
|
2905
2940
|
* 当前内容的结束行 >= 诊断结束的行
|
|
@@ -2957,7 +2992,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2957
2992
|
yield;
|
|
2958
2993
|
}
|
|
2959
2994
|
if (!minRange) {
|
|
2960
|
-
if (
|
|
2995
|
+
if (fileNodeRaw instanceof concepts_1.View || fileNodeRaw instanceof concepts_1.BusinessComponent) {
|
|
2961
2996
|
return { node: fileNode, item: sourceMap.get(fileNode) };
|
|
2962
2997
|
}
|
|
2963
2998
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -2994,7 +3029,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
2994
3029
|
refsList = [...newRefs.refs];
|
|
2995
3030
|
}
|
|
2996
3031
|
else if (node instanceof concepts_1.Module && !(node instanceof concepts_1.Connector)) {
|
|
2997
|
-
|
|
3032
|
+
// 数组有长度的情况下,才去查找
|
|
3033
|
+
const { logics, structures, enums, interfaces } = node;
|
|
3034
|
+
const lists = (logics?.length && logics) ||
|
|
3035
|
+
(structures?.length && structures) ||
|
|
3036
|
+
(enums?.length && enums) ||
|
|
3037
|
+
(interfaces?.length && interfaces);
|
|
3038
|
+
// const lists = node.logics || node.structures || node.enums;
|
|
2998
3039
|
const moduleName = fileNode.getEmbeddedFilePath();
|
|
2999
3040
|
if (lists.length) {
|
|
3000
3041
|
const item = lists[0];
|
|
@@ -4305,7 +4346,15 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4305
4346
|
// 总共要返回出去的
|
|
4306
4347
|
const types = new Map();
|
|
4307
4348
|
const newQuickInfoNodes = [];
|
|
4349
|
+
let nCount = 0;
|
|
4308
4350
|
yield* utils.wrapForEachToGenerator(nodes, function* getQuickInfoPosition(itemDetail, index) {
|
|
4351
|
+
++nCount;
|
|
4352
|
+
if (nCount === 30000) {
|
|
4353
|
+
// console.log('tick')
|
|
4354
|
+
nCount = 0;
|
|
4355
|
+
// 预留时间做 minor gc,减少峰值内存占用
|
|
4356
|
+
(async () => await new Promise(resolve => setTimeout(resolve, 55)))();
|
|
4357
|
+
}
|
|
4309
4358
|
const { node, filePath, item } = itemDetail;
|
|
4310
4359
|
// 先按照顺序占位
|
|
4311
4360
|
types.set(node, null);
|
|
@@ -4335,6 +4384,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4335
4384
|
'CallLogic',
|
|
4336
4385
|
'CallFunction',
|
|
4337
4386
|
'CallInterface',
|
|
4387
|
+
'CallMicroserviceInterface',
|
|
4338
4388
|
'MemberExpression',
|
|
4339
4389
|
'Return',
|
|
4340
4390
|
'Variable',
|
|
@@ -4342,6 +4392,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4342
4392
|
'NewComposite',
|
|
4343
4393
|
'NewList',
|
|
4344
4394
|
'NewMap',
|
|
4395
|
+
'NewStructure',
|
|
4345
4396
|
'OqlQueryComponent',
|
|
4346
4397
|
'QueryFieldExpression',
|
|
4347
4398
|
'QueryGroupByExpression',
|
|
@@ -4349,7 +4400,8 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4349
4400
|
'Paginate',
|
|
4350
4401
|
'BackendVariable',
|
|
4351
4402
|
'CallAuthInterface',
|
|
4352
|
-
'CallConnector'
|
|
4403
|
+
'CallConnector',
|
|
4404
|
+
'StructureProperty',
|
|
4353
4405
|
].includes(node.concept))
|
|
4354
4406
|
return;
|
|
4355
4407
|
// 要去ls那边获取的
|
|
@@ -4462,6 +4514,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4462
4514
|
else if (value.typeAnnotation) {
|
|
4463
4515
|
node.__TypeAnnotation = value.typeAnnotation;
|
|
4464
4516
|
}
|
|
4517
|
+
// 节点有函数返回时候 返回类型作为typeAnnotation
|
|
4518
|
+
const nodeType = node.__nodeType;
|
|
4519
|
+
if (nodeType) {
|
|
4520
|
+
if (nodeType.typeName === "__function" && nodeType.fnReturnType) {
|
|
4521
|
+
node.__TypeAnnotation = nodeType.fnReturnType;
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4465
4524
|
}
|
|
4466
4525
|
else {
|
|
4467
4526
|
// 清空原来已经赋值上去的类型,可能原来有现在没有了
|
|
@@ -4513,6 +4572,8 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4513
4572
|
// }
|
|
4514
4573
|
}
|
|
4515
4574
|
});
|
|
4575
|
+
// 预留时间做 minor gc,减少峰值内存占用
|
|
4576
|
+
(async () => await new Promise(resolve => setTimeout(resolve, 55)))();
|
|
4516
4577
|
return types;
|
|
4517
4578
|
}
|
|
4518
4579
|
*_getQuickInfoBindAttributeTypeWithGenerator(itemDetail) {
|
|
@@ -4555,45 +4616,82 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4555
4616
|
return utils.runGeneratorAsync(this._getQuickInfoNodesTypeMapWithGenerator(nodes));
|
|
4556
4617
|
}
|
|
4557
4618
|
// 全量标注并且返回json
|
|
4558
|
-
async getNaslAnnotatedJSON(
|
|
4619
|
+
async getNaslAnnotatedJSON(naslNode, releaseFlag) {
|
|
4620
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
4621
|
+
const isApp = concepts_1.asserts.isApp(naslNode);
|
|
4559
4622
|
if (this.changeStackList?.length) {
|
|
4560
4623
|
throw new Error(`当前还有${this.changeStackList.length}个文件还在执行更新操作`);
|
|
4561
4624
|
}
|
|
4562
|
-
this.logger.time('
|
|
4625
|
+
this.logger.time(`${isApp ? '全量' : '单文件'}标注`);
|
|
4563
4626
|
const nodes = [];
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
item,
|
|
4572
|
-
});
|
|
4627
|
+
if (!isApp) {
|
|
4628
|
+
const filePath = naslNode?.getEmbeddedFilePath();
|
|
4629
|
+
naslNode.sourceMap.forEach((item, node) => {
|
|
4630
|
+
nodes.push({
|
|
4631
|
+
filePath,
|
|
4632
|
+
node,
|
|
4633
|
+
item,
|
|
4573
4634
|
});
|
|
4574
|
-
}
|
|
4575
|
-
}
|
|
4635
|
+
});
|
|
4636
|
+
}
|
|
4637
|
+
else {
|
|
4638
|
+
this.file2NodeMap.forEach((fileNode, filePath) => {
|
|
4639
|
+
// 先不排除view,传递给后端的时候,去除views下的标注
|
|
4640
|
+
if (!['DataSource', 'Enum', 'Role'].includes(fileNode.concept)) {
|
|
4641
|
+
fileNode.sourceMap.forEach((item, node) => {
|
|
4642
|
+
nodes.push({
|
|
4643
|
+
filePath,
|
|
4644
|
+
node,
|
|
4645
|
+
item,
|
|
4646
|
+
});
|
|
4647
|
+
});
|
|
4648
|
+
}
|
|
4649
|
+
});
|
|
4650
|
+
}
|
|
4576
4651
|
const typesMap = await this.getQuickInfoNodesTypeMap(nodes, true);
|
|
4577
|
-
|
|
4652
|
+
this.logger.time('app to AnnotatedJSON');
|
|
4578
4653
|
const jsonMap = new Map();
|
|
4579
|
-
const json =
|
|
4654
|
+
const json = naslNode._toJSON((source, instance) => {
|
|
4580
4655
|
jsonMap.set(instance, source);
|
|
4581
4656
|
return source;
|
|
4582
4657
|
});
|
|
4583
|
-
|
|
4584
|
-
this.logger.timeEnd('
|
|
4658
|
+
this.logger.timeEnd('app to AnnotatedJSON');
|
|
4659
|
+
this.logger.timeEnd(`${isApp ? '全量' : '单文件'}标注`);
|
|
4585
4660
|
// 测试环境或者是调试模式打印数据
|
|
4586
4661
|
if (utils.isDebugMode || utils.isTestBrowser) {
|
|
4587
|
-
this.logger.info('
|
|
4662
|
+
this.logger.info(`${isApp ? '全量' : '单文件'}标注数据`, json);
|
|
4588
4663
|
}
|
|
4589
4664
|
if (releaseFlag) {
|
|
4590
|
-
|
|
4665
|
+
this.logger.time('annotationToJson');
|
|
4591
4666
|
// 全量标注后对json进行一些修改,为了服务端翻译处理
|
|
4592
4667
|
this.annotationToJson(typesMap, json, jsonMap);
|
|
4593
|
-
|
|
4668
|
+
this.logger.timeEnd('annotationToJson');
|
|
4594
4669
|
}
|
|
4595
4670
|
return json;
|
|
4596
4671
|
}
|
|
4672
|
+
/**
|
|
4673
|
+
* 标注指定文件
|
|
4674
|
+
*
|
|
4675
|
+
* @description 会进行 TS 翻译
|
|
4676
|
+
*/
|
|
4677
|
+
annotationFiles(fileNodes) {
|
|
4678
|
+
const nodes = [];
|
|
4679
|
+
const files = fileNodes.filter((node) => !(0, service_1.isIgnoreAnnotationFileNode)(node));
|
|
4680
|
+
for (const node of files) {
|
|
4681
|
+
if (!node.sourceMap) {
|
|
4682
|
+
continue;
|
|
4683
|
+
}
|
|
4684
|
+
const filePath = node.getEmbeddedFilePath();
|
|
4685
|
+
node.sourceMap.forEach((item, node) => {
|
|
4686
|
+
nodes.push({
|
|
4687
|
+
filePath: filePath,
|
|
4688
|
+
node,
|
|
4689
|
+
item,
|
|
4690
|
+
});
|
|
4691
|
+
});
|
|
4692
|
+
}
|
|
4693
|
+
return this.getQuickInfoNodesTypeMap(nodes, true);
|
|
4694
|
+
}
|
|
4597
4695
|
// 增量标注
|
|
4598
4696
|
*_incrementalAnnotationJSONWithGenerator(records) {
|
|
4599
4697
|
this.logger.time('增量标注');
|
|
@@ -4606,7 +4704,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4606
4704
|
}
|
|
4607
4705
|
record.id = fileNode.id;
|
|
4608
4706
|
record.node = fileNode;
|
|
4609
|
-
if (
|
|
4707
|
+
if ((0, service_1.isIgnoreAnnotationFileNode)(fileNode)) {
|
|
4610
4708
|
return;
|
|
4611
4709
|
}
|
|
4612
4710
|
yield* utils.wrapIteratorToGenerator(fileNode.sourceMap.entries(), ([nodeItem, item]) => {
|
|
@@ -4621,6 +4719,16 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
4621
4719
|
this.logger.timeEnd('增量标注');
|
|
4622
4720
|
}
|
|
4623
4721
|
annotationToJson(typesMap, json, jsonMap) {
|
|
4722
|
+
const timeZoneArgumentIndexMap = new Map([
|
|
4723
|
+
['ToString', 1],
|
|
4724
|
+
['CurrDateTime', 0],
|
|
4725
|
+
['CurrDate', 0],
|
|
4726
|
+
['CurrTime', 0],
|
|
4727
|
+
['FormatDateTime', 2],
|
|
4728
|
+
['jsonSerialize', 1],
|
|
4729
|
+
['GetDateCount', 2],
|
|
4730
|
+
['GetSpecificDaysOfWeek', 3]
|
|
4731
|
+
]);
|
|
4624
4732
|
typesMap.forEach((value, node) => {
|
|
4625
4733
|
// 如果节点本身有类型就不去在塞一遍了
|
|
4626
4734
|
// 有值而且没有类型再去设置
|
|
@@ -5169,6 +5277,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
5169
5277
|
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
5170
5278
|
const fileNodeItem = fileNodeChildren[i];
|
|
5171
5279
|
const result = await utils.timeSlicingWithGenerator(fileNodeItem.toEmbeddedTSFile());
|
|
5280
|
+
// @ts-ignore
|
|
5172
5281
|
fileNodeItem.sourceMap = result.sourceMap;
|
|
5173
5282
|
if (action === 'create') {
|
|
5174
5283
|
await this.handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
@@ -5186,6 +5295,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
5186
5295
|
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
5187
5296
|
const fileNodeItem = fileNodeChildren[i];
|
|
5188
5297
|
const result = await utils.timeSlicingWithGenerator(fileNodeItem.toEmbeddedTSFile());
|
|
5298
|
+
// @ts-ignore
|
|
5189
5299
|
fileNodeItem.sourceMap = result.sourceMap;
|
|
5190
5300
|
if (action === 'create') {
|
|
5191
5301
|
await this.handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
@@ -5211,6 +5321,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
5211
5321
|
for (let i = 0; i < fileNodeChildren.length; i++) {
|
|
5212
5322
|
const fileNodeItem = fileNodeChildren[i];
|
|
5213
5323
|
const result = await utils.timeSlicingWithGenerator(fileNodeItem.toEmbeddedTSFile());
|
|
5324
|
+
// @ts-ignore
|
|
5214
5325
|
fileNodeItem.sourceMap = result.sourceMap;
|
|
5215
5326
|
if (action === 'create') {
|
|
5216
5327
|
await this.handleChange(fileNodeItem, fileNodeItem, result, action);
|
|
@@ -5285,24 +5396,6 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
5285
5396
|
this.singleFileChangeIng = true;
|
|
5286
5397
|
// 行为
|
|
5287
5398
|
const { action, oldObject = {}, object = {} } = $event;
|
|
5288
|
-
// 根据行为跳过更新文件
|
|
5289
|
-
// 如果更新国际化key,不需要修改ts文件
|
|
5290
|
-
if (Object.keys(object || {}).length === 1 && Object.keys(oldObject).length === 1) {
|
|
5291
|
-
if (object.i18nKey && !oldObject.i18nKey) {
|
|
5292
|
-
return;
|
|
5293
|
-
}
|
|
5294
|
-
if (object.i18nInfo && !oldObject.i18nInfo) {
|
|
5295
|
-
return;
|
|
5296
|
-
}
|
|
5297
|
-
if (!object.i18nKey && oldObject.i18nKey) {
|
|
5298
|
-
// 撤销重做 也跳过更新
|
|
5299
|
-
return;
|
|
5300
|
-
}
|
|
5301
|
-
if (!object.i18nInfo && oldObject.i18nInfo) {
|
|
5302
|
-
// 撤销重做 也跳过更新
|
|
5303
|
-
return;
|
|
5304
|
-
}
|
|
5305
|
-
}
|
|
5306
5399
|
const targetNode = $event.target;
|
|
5307
5400
|
this.logger.info(targetNode, 'targetNode');
|
|
5308
5401
|
// 连接器namespace 没有真实文件,不需要走删除
|
|
@@ -5347,6 +5440,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
5347
5440
|
fileContent: result.code,
|
|
5348
5441
|
},
|
|
5349
5442
|
]);
|
|
5443
|
+
// @ts-ignore
|
|
5350
5444
|
fileNode.sourceMap = result.sourceMap;
|
|
5351
5445
|
if (action === 'update' || action === 'create') {
|
|
5352
5446
|
if ($event?.field !== 'name') {
|
|
@@ -5368,6 +5462,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
|
|
|
5368
5462
|
}
|
|
5369
5463
|
changeFileNext() {
|
|
5370
5464
|
if (!this.singleFileChangeIng) {
|
|
5465
|
+
// SHIFT IS O(n) AND SLOW
|
|
5371
5466
|
const item = this.changeStackList.shift();
|
|
5372
5467
|
this.receiveHandleChange(item)
|
|
5373
5468
|
.catch((err) => {
|