@lcap/nasl 3.8.2-beta.2 → 3.8.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.js +1 -0
- package/out/common/BaseNode.d.ts +19 -3
- package/out/common/BaseNode.js +85 -7
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AbstractInterface__.js.map +1 -1
- package/out/concepts/Annotation__.js +1 -1
- package/out/concepts/Annotation__.js.map +1 -1
- package/out/concepts/App__.d.ts +3 -0
- package/out/concepts/App__.js +964 -4
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +3 -3
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +1 -1
- package/out/concepts/BatchAssignment__.js +3 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +5 -6
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +3 -4
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +2 -0
- package/out/concepts/BusinessComponent__.js +48 -0
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.d.ts +1 -0
- package/out/concepts/BusinessLogic__.js +10 -0
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallEvent__.d.ts +2 -0
- package/out/concepts/CallEvent__.js +75 -0
- package/out/concepts/CallEvent__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +1 -0
- package/out/concepts/CallInterface__.js +26 -15
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +4 -0
- package/out/concepts/CallLogic__.js +61 -5
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +3 -3
- package/out/concepts/Entity__.js +4 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Event__.d.ts +2 -0
- package/out/concepts/Event__.js +30 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +2 -0
- package/out/concepts/FrontendType__.js +32 -0
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -0
- package/out/concepts/Frontend__.js +48 -0
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/IfStatement__.js +6 -6
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.d.ts +1 -0
- package/out/concepts/InterfaceParam__.js +23 -4
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +2 -1
- package/out/concepts/Interface__.js +29 -5
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.d.ts +1 -0
- package/out/concepts/JSBlock__.js +6 -0
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicDeclaration__.d.ts +1 -0
- package/out/concepts/LogicDeclaration__.js +58 -7
- package/out/concepts/LogicDeclaration__.js.map +1 -1
- package/out/concepts/Logic__.js +43 -24
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +1 -2
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +3 -18
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +2 -0
- package/out/concepts/Module__.js +64 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +1 -1
- package/out/concepts/NewComposite__.js +3 -3
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NullLiteral__.js +6 -0
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/Paginate__.d.ts +1 -0
- package/out/concepts/Paginate__.js +15 -7
- package/out/concepts/Paginate__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +2 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +3 -4
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +1 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +10 -7
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -0
- package/out/concepts/View__.js +55 -1
- package/out/concepts/View__.js.map +1 -1
- package/out/generator/genBundleFiles.js +61 -51
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genHash.d.ts +2 -2
- package/out/generator/genHash.js +30 -30
- package/out/generator/genHash.js.map +1 -1
- package/out/generator/permission.d.ts +8 -1
- package/out/generator/permission.js +321 -23
- package/out/generator/permission.js.map +1 -1
- package/out/generator/release-body/body.d.ts +4 -0
- package/out/generator/release-body/body.js +20 -6
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/data.js +6 -2
- package/out/generator/release-body/data.js.map +1 -1
- package/out/generator/release-body/index.d.ts +1 -0
- package/out/generator/release-body/index.js +1 -0
- package/out/generator/release-body/index.js.map +1 -1
- package/out/generator/release-body/utils.js +3 -3
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/generator/release-body/validation.js +2 -2
- package/out/generator/release-body/validation.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +2 -2
- package/out/natural/genNaturalTS.js +5 -5
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/index.d.ts +1 -1
- package/out/natural/getContext/index.js +15 -9
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/transformTS2UI.js +26 -10
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.js +26 -10
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/entity2LogicNamespace.d.ts +2 -2
- package/out/server/entity2LogicNamespace.js +321 -310
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +29 -18
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -1
- package/out/server/naslServer.js +35 -21
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +12 -0
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.d.ts +2 -0
- package/out/service/storage/init.js +20 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +3 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +2 -2
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +1 -1
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +3 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/package.json +5 -5
- package/sandbox/stdlib/nasl.util.ts +4 -1
- package/src/common/BaseNode.ts +91 -11
- package/src/concepts/AbstractInterface__.ts +1 -0
- package/src/concepts/Annotation__.ts +1 -1
- package/src/concepts/App__.ts +104 -4
- package/src/concepts/Argument__.ts +3 -3
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +5 -6
- package/src/concepts/BindDirective__.ts +3 -4
- package/src/concepts/BusinessComponent__.ts +54 -1
- package/src/concepts/BusinessLogic__.ts +10 -1
- package/src/concepts/CallEvent__.ts +66 -0
- package/src/concepts/CallInterface__.ts +21 -9
- package/src/concepts/CallLogic__.ts +61 -5
- package/src/concepts/Entity__.ts +7 -1
- package/src/concepts/Event__.ts +32 -0
- package/src/concepts/FrontendType__.ts +34 -1
- package/src/concepts/Frontend__.ts +51 -0
- package/src/concepts/IfStatement__.ts +6 -6
- package/src/concepts/InterfaceParam__.ts +23 -4
- package/src/concepts/Interface__.ts +29 -5
- package/src/concepts/JSBlock__.ts +5 -0
- package/src/concepts/LogicDeclaration__.ts +65 -7
- package/src/concepts/Logic__.ts +45 -27
- package/src/concepts/MatchCase__.ts +1 -2
- package/src/concepts/Match__.ts +3 -21
- package/src/concepts/MemberExpression__.ts +1 -1
- package/src/concepts/Module__.ts +75 -0
- package/src/concepts/NewComposite__.ts +3 -3
- package/src/concepts/NullLiteral__.ts +7 -0
- package/src/concepts/Paginate__.ts +14 -7
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/StringLiteral__.ts +3 -4
- package/src/concepts/TypeAnnotation__.ts +1 -0
- package/src/concepts/ViewElement__.ts +11 -7
- package/src/concepts/View__.ts +56 -1
- package/src/generator/genBundleFiles.ts +67 -54
- package/src/generator/genHash.ts +32 -6
- package/src/generator/permission.ts +333 -23
- package/src/generator/release-body/body.ts +31 -12
- package/src/generator/release-body/data.ts +7 -2
- package/src/generator/release-body/index.ts +1 -0
- package/src/generator/release-body/utils.ts +3 -3
- package/src/generator/release-body/validation.ts +1 -1
- package/src/index.ts +13 -1
- package/src/natural/genNaturalTS.ts +5 -2
- package/src/natural/getContext/index.ts +17 -11
- package/src/natural/transformTS2UI.ts +25 -10
- package/src/natural/transformTSCode.ts +25 -10
- package/src/server/entity2LogicNamespace.ts +13 -1
- package/src/server/extendBaseNode.ts +32 -22
- package/src/server/naslServer.ts +45 -28
- package/src/server/translator.ts +15 -0
- package/src/service/storage/init.ts +26 -0
- package/src/templator/genCreateBlock.ts +4 -4
- package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -2
- package/src/templator/genCurdMultipleKeyBlock.ts +7 -7
- package/src/templator/genEditTableBlock.ts +4 -4
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +2 -2
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +2 -2
- package/src/templator/genUpdateBlock.ts +6 -6
- package/src/templator/utils.ts +1 -1
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +1 -1
- package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +1 -1
- package/test/concepts/string-literal/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +75 -75
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +6 -2
package/src/concepts/Logic__.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
withGenerator,
|
|
19
19
|
TranslatorGenerator,
|
|
20
20
|
createDescriptionComment,
|
|
21
|
+
createDecoratorCode,
|
|
21
22
|
} from '../translator';
|
|
22
23
|
import type App from './App__';
|
|
23
24
|
import type Namespace from './Namespace__';
|
|
@@ -2323,13 +2324,16 @@ export class Logic extends Annotatable {
|
|
|
2323
2324
|
toTextualNASL(state = createCompilerState(), prefix?: string, logicName?: string, currentNode?: BaseNode): string {
|
|
2324
2325
|
// 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
|
|
2325
2326
|
let code = '';
|
|
2327
|
+
|
|
2328
|
+
code += createDecoratorCode(state, this, ['title', 'description', 'triggerType', 'cron', 'transactional', 'overridable']);
|
|
2329
|
+
if (state.declaration) code += 'declare ';
|
|
2326
2330
|
// 有参数长度
|
|
2327
2331
|
code += `logic ${this.name}`;
|
|
2328
2332
|
|
|
2329
2333
|
if (this.typeParams?.length) {
|
|
2330
2334
|
code += '<';
|
|
2331
2335
|
this.typeParams.forEach((typeParam, typeParamIndex) => {
|
|
2332
|
-
code += typeParam.
|
|
2336
|
+
code += typeParam.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
2333
2337
|
if (typeParamIndex !== this.typeParams.length - 1) code += ', ';
|
|
2334
2338
|
});
|
|
2335
2339
|
code += '>';
|
|
@@ -2352,30 +2356,35 @@ export class Logic extends Annotatable {
|
|
|
2352
2356
|
});
|
|
2353
2357
|
}
|
|
2354
2358
|
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
code +=
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
partialCode =
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2359
|
+
if (state.declaration) {
|
|
2360
|
+
code += ';';
|
|
2361
|
+
} else {
|
|
2362
|
+
code += ' {\n';
|
|
2363
|
+
|
|
2364
|
+
this.variables.forEach((variable) => {
|
|
2365
|
+
code += `${indent(state.tabSize + 1)}let `;
|
|
2366
|
+
code += variable.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
2367
|
+
code += ';\n';
|
|
2368
|
+
});
|
|
2369
|
+
if (this.variables.length) code += '\n';
|
|
2370
|
+
|
|
2371
|
+
this.body.forEach((item) => {
|
|
2372
|
+
let partialCode = '';
|
|
2373
|
+
|
|
2374
|
+
// if (!state.focusedNodePath && item.concept === 'End') code += `${indent(state.tabSize + 1)}/* 当前位置 */\n`;
|
|
2375
|
+
if (item.toTextualNASL) {
|
|
2376
|
+
partialCode = item.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
2377
|
+
} else if (item.toEmbeddedTS) {
|
|
2378
|
+
partialCode = runSync(item.toEmbeddedTS(shiftState(state, code, { tabSize: state.tabSize + 1 })));
|
|
2379
|
+
}
|
|
2380
|
+
partialCode = partialCode.trimEnd();
|
|
2381
|
+
if (partialCode) {
|
|
2382
|
+
code += partialCode;
|
|
2383
|
+
code += '\n';
|
|
2384
|
+
}
|
|
2385
|
+
});
|
|
2386
|
+
code += `${indent(state.tabSize)}}`;
|
|
2387
|
+
}
|
|
2379
2388
|
return code;
|
|
2380
2389
|
}
|
|
2381
2390
|
|
|
@@ -2402,8 +2411,17 @@ export class Logic extends Annotatable {
|
|
|
2402
2411
|
// 调用服务端逻辑,参数替换成 null
|
|
2403
2412
|
if (asserts.isCallLogic(rightNode) && rightNode.calleeNamespace === 'app.logics') {
|
|
2404
2413
|
const calleeName = rightNode?.calleeName;
|
|
2405
|
-
|
|
2406
|
-
|
|
2414
|
+
if (calleeName) {
|
|
2415
|
+
/**
|
|
2416
|
+
* 若calleeName非空,即便所调用的逻辑不存在,也仍然要忠实地翻译这个CallLogic表达式
|
|
2417
|
+
* @link {https://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=2855540189054208}
|
|
2418
|
+
*
|
|
2419
|
+
* 对于CallInterface则不需要
|
|
2420
|
+
*/
|
|
2421
|
+
const calleeLogic: Logic | undefined = this.app.logics.find((l) => l.name === calleeName);
|
|
2422
|
+
return `app.logics.${calleeName}(${calleeLogic?.params.map(() => 'null').join(',') ?? ''})`;
|
|
2423
|
+
}
|
|
2424
|
+
return null;
|
|
2407
2425
|
}
|
|
2408
2426
|
// 调用依赖库逻辑可能会有子逻辑,子逻辑拼接可能有ts忽略先去掉
|
|
2409
2427
|
if (asserts.isCallLogic(rightNode) && rightNode.calleeNamespace?.startsWith('extensions.')) {
|
|
@@ -937,8 +937,7 @@ export class MatchCase extends LogicItem {
|
|
|
937
937
|
} else {
|
|
938
938
|
code += '{\n';
|
|
939
939
|
this.body.forEach((logicItem) => {
|
|
940
|
-
code +=
|
|
941
|
-
code += `${logicItem.toTextualNASL(shiftState(state, code, { inline: true }))}\n`;
|
|
940
|
+
code += `${logicItem.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1, inline: false }))}\n`;
|
|
942
941
|
});
|
|
943
942
|
code += `${indent(state.tabSize)}}\n`;
|
|
944
943
|
}
|
package/src/concepts/Match__.ts
CHANGED
|
@@ -731,11 +731,9 @@ export class Match extends LogicItem {
|
|
|
731
731
|
if (this.parentNode?.concept === 'Logic') {
|
|
732
732
|
code += '\n';
|
|
733
733
|
}
|
|
734
|
-
code +=
|
|
735
|
-
code += '(function match(_value) { \n';
|
|
734
|
+
code += '(function match(_value) {\n';
|
|
736
735
|
let parentCode: string;
|
|
737
736
|
if (this.expression) {
|
|
738
|
-
code += indent((state?.tabSize || 0) + 1);
|
|
739
737
|
// Identifier会使用自己本身的类型,来推导,因为右侧放的内容关系关系到内部类型推断
|
|
740
738
|
if (asserts.isIdentifier(this.expression) || asserts.isMemberExpression(this.expression)) {
|
|
741
739
|
parentCode = this.expression?.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
@@ -748,30 +746,14 @@ export class Match extends LogicItem {
|
|
|
748
746
|
this.cases.forEach((item, index) => {
|
|
749
747
|
// 如果是最后一项
|
|
750
748
|
code += item.toNaturalTS(
|
|
751
|
-
shiftState(state, code, { tabSize:
|
|
749
|
+
shiftState(state, code, { tabSize: state.tabSize + 1 }),
|
|
752
750
|
index,
|
|
753
751
|
parentCode,
|
|
754
752
|
);
|
|
755
753
|
});
|
|
756
|
-
code += `${indent(state
|
|
754
|
+
code += `${indent(state.tabSize)}})(${this.expression?.toNaturalTS(
|
|
757
755
|
shiftState(state, code, { inline: true }),
|
|
758
756
|
)})`;
|
|
759
|
-
|
|
760
|
-
if (
|
|
761
|
-
this.parentNode?.concept !== 'Argument' &&
|
|
762
|
-
this.parentKey !== 'test' &&
|
|
763
|
-
this.parentKey !== 'patterns' &&
|
|
764
|
-
this.parentNode?.concept !== 'Assignment' &&
|
|
765
|
-
this.parentNode?.concept !== 'ForEachStatement' &&
|
|
766
|
-
this.parentNode?.concept !== 'SelectMembers' &&
|
|
767
|
-
this.parentNode?.concept !== 'BinaryExpression' &&
|
|
768
|
-
this.parentNode?.concept !== 'StringInterpolation' &&
|
|
769
|
-
this.parentNode?.concept !== 'MemberExpression' &&
|
|
770
|
-
!['NewMap', 'NewList'].includes(this.parentNode?.concept) &&
|
|
771
|
-
this.parentKey !== 'returnExpression'
|
|
772
|
-
) {
|
|
773
|
-
code += '\n';
|
|
774
|
-
}
|
|
775
757
|
return code;
|
|
776
758
|
}
|
|
777
759
|
|
|
@@ -144,7 +144,7 @@ export class MemberExpression extends LogicItem {
|
|
|
144
144
|
) {
|
|
145
145
|
const { prop } = ComponentCompletionPropertyMap[elementTag][this.property.name];
|
|
146
146
|
if (!['data'].includes(this.property.name)) {
|
|
147
|
-
return `__${elementName}_params && __${elementName}_params.${this.property.name}`;
|
|
147
|
+
return `this && this.__${elementName}_params && this.__${elementName}_params.${this.property.name}`;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
return `__${elementName}_${prop}`;
|
package/src/concepts/Module__.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
type PropertyType = 'structures' | 'enums' | 'entities' | 'interfaces' | 'processes' | 'views';
|
|
2
|
+
import {
|
|
3
|
+
withSourceMap,
|
|
4
|
+
createCompilerState,
|
|
5
|
+
createDecoratorCode,
|
|
6
|
+
indent,
|
|
7
|
+
shiftState,
|
|
8
|
+
} from '../translator';
|
|
2
9
|
const moduleNameSpace = {
|
|
3
10
|
dependencies: 'extensions',
|
|
4
11
|
interfaceDependencies: 'apis',
|
|
5
12
|
componentDependencies: 'components',
|
|
6
13
|
connectorDependencies: 'connector',
|
|
7
14
|
};
|
|
15
|
+
const typeNameSpace: Record<Module['type'], string> = {
|
|
16
|
+
extension: 'extensions',
|
|
17
|
+
interface: 'apis',
|
|
18
|
+
component: 'components',
|
|
19
|
+
connector: 'connector',
|
|
20
|
+
customInterface: 'apis',
|
|
21
|
+
};
|
|
8
22
|
type ModuleKeyType = 'dependencies' | 'interfaceDependencies' | 'componentDependencies' | 'connectorDependencies';
|
|
9
23
|
import type { AuthInterface } from './AuthInterface__';
|
|
10
24
|
import type ConfigProperty from './ConfigProperty__';
|
|
@@ -3048,6 +3062,67 @@ export class Module extends BaseNode {
|
|
|
3048
3062
|
});
|
|
3049
3063
|
}
|
|
3050
3064
|
|
|
3065
|
+
@withSourceMap()
|
|
3066
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
3067
|
+
let code = '';
|
|
3068
|
+
|
|
3069
|
+
code += `namespace ${typeNameSpace[this.type]}.${this.name} {\n`;
|
|
3070
|
+
|
|
3071
|
+
this.dataSources?.forEach((dataSource) => {
|
|
3072
|
+
code += dataSource.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3073
|
+
});
|
|
3074
|
+
this.structures?.forEach((structure) => {
|
|
3075
|
+
code += structure.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3076
|
+
});
|
|
3077
|
+
this.enums?.forEach((enumeration) => {
|
|
3078
|
+
code += enumeration.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3079
|
+
});
|
|
3080
|
+
this.metadataTypes?.forEach((metadataType) => {
|
|
3081
|
+
code += metadataType.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3082
|
+
});
|
|
3083
|
+
if (this.metadataTypes.length)
|
|
3084
|
+
code += '\n';
|
|
3085
|
+
this.logics?.forEach((logic) => {
|
|
3086
|
+
code += logic.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1, declaration: true })) + '\n\n';
|
|
3087
|
+
});
|
|
3088
|
+
this.interfaces?.forEach((inter) => {
|
|
3089
|
+
code += inter.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3090
|
+
});
|
|
3091
|
+
|
|
3092
|
+
return code;
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
@withSourceMap()
|
|
3096
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
3097
|
+
let code = '';
|
|
3098
|
+
code += createDecoratorCode(state, this, ['type', 'version', 'title', 'description', 'provider', 'externalDependencyMap', 'compilerInfoMap']);
|
|
3099
|
+
|
|
3100
|
+
code += `module ${this.name} {\n`;
|
|
3101
|
+
|
|
3102
|
+
this.dataSources?.forEach((dataSource) => {
|
|
3103
|
+
code += dataSource.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3104
|
+
});
|
|
3105
|
+
this.structures?.forEach((structure) => {
|
|
3106
|
+
code += structure.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3107
|
+
});
|
|
3108
|
+
this.enums?.forEach((enumeration) => {
|
|
3109
|
+
code += enumeration.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3110
|
+
});
|
|
3111
|
+
this.metadataTypes?.forEach((metadataType) => {
|
|
3112
|
+
code += metadataType.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3113
|
+
});
|
|
3114
|
+
this.logics?.forEach((logic) => {
|
|
3115
|
+
code += logic.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1, declaration: true })) + '\n\n';
|
|
3116
|
+
});
|
|
3117
|
+
this.interfaces?.forEach((inter) => {
|
|
3118
|
+
code += inter.toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 })) + '\n';
|
|
3119
|
+
});
|
|
3120
|
+
|
|
3121
|
+
code += `${indent(state.tabSize)}}`;
|
|
3122
|
+
|
|
3123
|
+
return code;
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3051
3126
|
//================================================================================
|
|
3052
3127
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
3053
3128
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -758,7 +758,7 @@ export class NewComposite extends LogicItem {
|
|
|
758
758
|
return this.assignmentLines.length;
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
|
|
761
|
+
newConnection(addRightIndex?: number) {
|
|
762
762
|
const leftLineSet = new Set();
|
|
763
763
|
const lineArr: Array<AssignmentLine> = [];
|
|
764
764
|
const AssignmentLine = getConceptConstructor('AssignmentLine');
|
|
@@ -782,7 +782,7 @@ export class NewComposite extends LogicItem {
|
|
|
782
782
|
this.rights.forEach((selectMember, rightFirstIndex) => {
|
|
783
783
|
const { members, expression } = selectMember;
|
|
784
784
|
if (leftLineSet.has(leftSecondIndex)) return;
|
|
785
|
-
if (
|
|
785
|
+
if (![-1, null, undefined].includes(addRightIndex) && addRightIndex !== rightFirstIndex) return;
|
|
786
786
|
// 右侧父节点也不允许自动连线
|
|
787
787
|
const rightLineSet = new Set();
|
|
788
788
|
for (let i = 0; i < members.length - 1; i++) {
|
|
@@ -813,7 +813,7 @@ export class NewComposite extends LogicItem {
|
|
|
813
813
|
|
|
814
814
|
if (leftName === rightName) {
|
|
815
815
|
const rightTypeAnnotation = rightMember.__TypeAnnotation;
|
|
816
|
-
if (!isAnnotation && leftTypeAnnotation.
|
|
816
|
+
if (!isAnnotation && leftTypeAnnotation.typeName !== rightTypeAnnotation.typeName) return;
|
|
817
817
|
const leftIndex = [0, leftSecondIndex];
|
|
818
818
|
const rightIndex = [rightFirstIndex, rightSecondIndex];
|
|
819
819
|
const Line: AssignmentLine = new AssignmentLine({ leftIndex, rightIndex });
|
|
@@ -81,6 +81,13 @@ export class NullLiteral extends LogicItem {
|
|
|
81
81
|
|
|
82
82
|
@withSourceMapGenerator
|
|
83
83
|
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
84
|
+
// 特殊翻译,处理异常报错
|
|
85
|
+
// 匹配红框误报 http://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=2854094336746752
|
|
86
|
+
// 如果表达式,槽位直接放null ,会报any类型错误,所以这里加上as any, 就不会报错了
|
|
87
|
+
if (this?.parentNode?.concept === 'Match' && this?.parentKey === 'expression') {
|
|
88
|
+
return '(null) as any';
|
|
89
|
+
}
|
|
90
|
+
|
|
84
91
|
return 'null';
|
|
85
92
|
}
|
|
86
93
|
|
|
@@ -138,20 +138,27 @@ export class Paginate extends LogicItem {
|
|
|
138
138
|
//================================================================================
|
|
139
139
|
@withSourceMap()
|
|
140
140
|
toNaturalTS(state = createCompilerState()): string {
|
|
141
|
-
const self = this;
|
|
142
141
|
let code = 'PAGINATE(';
|
|
143
|
-
|
|
144
|
-
code += list;
|
|
142
|
+
code += this.list ? this.list.toNaturalTS(shiftState(state, code)) : '__IDENTIFIER__';
|
|
145
143
|
code += ', ';
|
|
146
|
-
|
|
147
|
-
code += page;
|
|
144
|
+
code += this.page ? this.page.toNaturalTS(shiftState(state, code)) : '__IDENTIFIER__';
|
|
148
145
|
code += ', ';
|
|
149
|
-
|
|
150
|
-
code += size;
|
|
146
|
+
code += this.size ? this.size.toNaturalTS(shiftState(state, code)) : '__IDENTIFIER__';
|
|
151
147
|
code += `)\n`;
|
|
152
148
|
return code;
|
|
153
149
|
}
|
|
154
150
|
|
|
151
|
+
@withSourceMap()
|
|
152
|
+
toTextualNASL(state = createCompilerState()): string {
|
|
153
|
+
let code = '';
|
|
154
|
+
code += this.list ? this.list.toTextualNASL(shiftState(state, code)) : '__IDENTIFIER__';
|
|
155
|
+
code += ' paginate ';
|
|
156
|
+
code += this.page ? this.page.toTextualNASL(shiftState(state, code)) : '__IDENTIFIER__';
|
|
157
|
+
code += ', ';
|
|
158
|
+
code += this.size ? this.size.toTextualNASL(shiftState(state, code)) : '__IDENTIFIER__';
|
|
159
|
+
return code;
|
|
160
|
+
}
|
|
161
|
+
|
|
155
162
|
@withSourceMapGenerator
|
|
156
163
|
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
157
164
|
const self = this;
|
|
@@ -281,7 +281,7 @@ export class QueryFromExpression extends LogicItem {
|
|
|
281
281
|
|
|
282
282
|
if (this.joinParts.length) {
|
|
283
283
|
this.joinParts.forEach((joinPart) => {
|
|
284
|
-
code +=
|
|
284
|
+
code += `\n${indent(state.tabSize)}`;
|
|
285
285
|
code += joinPart.toNaturalSQL(state);
|
|
286
286
|
});
|
|
287
287
|
}
|
|
@@ -296,7 +296,7 @@ export class QueryFromExpression extends LogicItem {
|
|
|
296
296
|
|
|
297
297
|
if (this.joinParts.length) {
|
|
298
298
|
this.joinParts.forEach((joinPart) => {
|
|
299
|
-
code +=
|
|
299
|
+
code += `\n${indent(state.tabSize)}`;
|
|
300
300
|
code += joinPart.toTextualNASL(state);
|
|
301
301
|
});
|
|
302
302
|
}
|
|
@@ -86,10 +86,9 @@ export class StringLiteral extends LogicItem {
|
|
|
86
86
|
}
|
|
87
87
|
code = `\`${this.value.replace(/['"`\\]/g, (m) => {
|
|
88
88
|
let escape = '\\\\';
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/// #endif
|
|
89
|
+
if (options?.isGeneratorExport) {
|
|
90
|
+
escape = '\\';
|
|
91
|
+
}
|
|
93
92
|
if (m === '\\') {
|
|
94
93
|
return `${escape}${escape}`;
|
|
95
94
|
}
|
|
@@ -80,6 +80,8 @@ function genArgumentMemberExpression(arr: string[]) {
|
|
|
80
80
|
}
|
|
81
81
|
export interface ElementToVueOptions {
|
|
82
82
|
filterAttr?: Array<string>;
|
|
83
|
+
/** 生成器镜像的导出流程 */
|
|
84
|
+
isGeneratorExport?: boolean;
|
|
83
85
|
isExport?: boolean;
|
|
84
86
|
isRelease?: boolean;
|
|
85
87
|
isRoot?: boolean;
|
|
@@ -287,7 +289,7 @@ function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
|
|
|
287
289
|
function transAstNodeToNaslTypeNode(astNode: any, namespace?: string): any {
|
|
288
290
|
let node = null;
|
|
289
291
|
// 单独特殊处理枚举因为他不是MemberExpression,而是Identifier_
|
|
290
|
-
if (astNode?.value?.startsWith('__enumTypeAnnotation_')) {
|
|
292
|
+
if (astNode?.value?.startsWith?.('__enumTypeAnnotation_')) {
|
|
291
293
|
const valueArr = astNode.value.replace('__enumTypeAnnotation_', '')?.split('.');
|
|
292
294
|
const name = valueArr.pop();
|
|
293
295
|
const namespace = valueArr.join('.');
|
|
@@ -1634,7 +1636,7 @@ export class ViewElement extends Annotatable {
|
|
|
1634
1636
|
let levelIndex = parentLevel || 0;
|
|
1635
1637
|
code += `${self.name}: () => {\n`;
|
|
1636
1638
|
|
|
1637
|
-
const
|
|
1639
|
+
const getPropInitialValue = (name: string) => {
|
|
1638
1640
|
let v = 'new nasl.core.BooleanFalse()';
|
|
1639
1641
|
const attr = self.bindAttrs?.find((attr) => attr.name === name);
|
|
1640
1642
|
if (['static', 'string'].includes(attr?.type)) {
|
|
@@ -1775,26 +1777,27 @@ export class ViewElement extends Annotatable {
|
|
|
1775
1777
|
if (hasDataSource && V && !T1) {
|
|
1776
1778
|
const valueFieldAttr = self.bindAttrs?.find((attr) => attr.name === 'valueField');
|
|
1777
1779
|
if (dataSourceSetted && ['static', 'string'].includes(valueFieldAttr?.type)) {
|
|
1778
|
-
valueType = `typeof __item.${valueFieldAttr.value}
|
|
1780
|
+
valueType = `nasl.util._formatEnum<typeof __item.${valueFieldAttr.value}>`;
|
|
1779
1781
|
} else {
|
|
1780
|
-
valueType = `typeof __staticItem
|
|
1782
|
+
valueType = `nasl.util._formatEnum<typeof __staticItem>`;
|
|
1781
1783
|
}
|
|
1782
1784
|
}
|
|
1783
1785
|
// 分页
|
|
1784
1786
|
let pageableDefaultValue: string;
|
|
1785
1787
|
if (hasDataSource && P && !T1) {
|
|
1786
|
-
pageableDefaultValue =
|
|
1788
|
+
pageableDefaultValue = getPropInitialValue('pageable');
|
|
1787
1789
|
code += `let __pageable = ${pageableDefaultValue};\n`;
|
|
1788
1790
|
}
|
|
1789
1791
|
// 多选
|
|
1790
1792
|
let multipleDefaultValue: string;
|
|
1791
1793
|
if (hasDataSource && M && !T1) {
|
|
1792
|
-
|
|
1794
|
+
const name = config?.allNodesAPI?.[self.tag]?.props?.find((prop) => ['M'].includes(prop.tsType))?.name;
|
|
1795
|
+
multipleDefaultValue = getPropInitialValue(name || 'multiple');
|
|
1793
1796
|
code += `let __multiple = ${multipleDefaultValue};\n`;
|
|
1794
1797
|
}
|
|
1795
1798
|
if (hasDataSource && V && !T1) {
|
|
1796
1799
|
code += `// @ts-ignore
|
|
1797
|
-
let __value: typeof __multiple extends nasl.core.BooleanTrue ?
|
|
1800
|
+
let __value: typeof __multiple extends nasl.core.BooleanTrue ? nasl.collection.List<${valueType}> : ${valueType};\n`;
|
|
1798
1801
|
code += `// @ts-ignore
|
|
1799
1802
|
let __V: ${valueType};\n`;
|
|
1800
1803
|
}
|
|
@@ -2914,6 +2917,7 @@ export class ViewElement extends Annotatable {
|
|
|
2914
2917
|
return `:${name}="${value.replace(/"/g, "'")}"`;
|
|
2915
2918
|
}
|
|
2916
2919
|
} catch (e) {
|
|
2920
|
+
if (apiOfAttr && apiOfAttr.type && !apiOfAttr.type.includes('string')) return '';
|
|
2917
2921
|
if (apiOfAttr && apiOfAttr.tsType && !apiOfAttr.tsType.includes('nasl.core.String')) return '';
|
|
2918
2922
|
}
|
|
2919
2923
|
value = value
|
package/src/concepts/View__.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
withSourceMapGenerator,
|
|
16
16
|
withGenerator,
|
|
17
17
|
TranslatorGenerator,
|
|
18
|
+
createDecoratorCode,
|
|
18
19
|
} from '../translator';
|
|
19
20
|
import translator from '../bak/translator';
|
|
20
21
|
import { ElementToVueOptions } from './ViewElement__';
|
|
@@ -2559,11 +2560,11 @@ export class View extends Annotatable {
|
|
|
2559
2560
|
code += variable.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
2560
2561
|
code += ';\n';
|
|
2561
2562
|
});
|
|
2563
|
+
if (this.variables.length) code += '\n';
|
|
2562
2564
|
|
|
2563
2565
|
if (callback) {
|
|
2564
2566
|
code += callback.call(this, state);
|
|
2565
2567
|
} else {
|
|
2566
|
-
code += '\n';
|
|
2567
2568
|
code += this.elements[0].toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
2568
2569
|
}
|
|
2569
2570
|
|
|
@@ -2573,6 +2574,60 @@ export class View extends Annotatable {
|
|
|
2573
2574
|
return code;
|
|
2574
2575
|
}
|
|
2575
2576
|
|
|
2577
|
+
@withSourceMap()
|
|
2578
|
+
toTextualNASL(state = createCompilerState(), callback?: (this: View, state: TranslatorState) => string): string {
|
|
2579
|
+
const viewName = state.rename ?? this.tsName;
|
|
2580
|
+
let code = '';
|
|
2581
|
+
code += createDecoratorCode(state, this, ['pageTemplateId', 'uuid', 'title', 'crumb', 'auth', 'authDescription', 'isIndex']);
|
|
2582
|
+
|
|
2583
|
+
if (state.declaration) {
|
|
2584
|
+
code += `declare view ${viewName}`;
|
|
2585
|
+
// 有参数长度
|
|
2586
|
+
code += '(';
|
|
2587
|
+
this.params.forEach((param, index) => {
|
|
2588
|
+
code += param.toTextualNASL(shiftState(state, code, { tabSize: 0 }));
|
|
2589
|
+
if (index !== this.params.length - 1) code += ', ';
|
|
2590
|
+
});
|
|
2591
|
+
code += ') {';
|
|
2592
|
+
if (state.convertChildren && this.children?.length) {
|
|
2593
|
+
this.children.forEach((child) => {
|
|
2594
|
+
code += child.toTextualNASL(shiftState(state, code, { tabSize: state?.tabSize || 0 + 1 }), callback);
|
|
2595
|
+
code += '\n';
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
code += '}';
|
|
2599
|
+
} else {
|
|
2600
|
+
code += `view ${viewName}`;
|
|
2601
|
+
|
|
2602
|
+
// 有参数长度
|
|
2603
|
+
code += '(';
|
|
2604
|
+
this.params.forEach((param, index) => {
|
|
2605
|
+
code += param.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
2606
|
+
if (index !== this.params.length - 1) code += ', ';
|
|
2607
|
+
});
|
|
2608
|
+
code += ')';
|
|
2609
|
+
|
|
2610
|
+
code += ' {\n';
|
|
2611
|
+
|
|
2612
|
+
this.variables.forEach((variable) => {
|
|
2613
|
+
code += `${indent(state.tabSize + 1)}let `;
|
|
2614
|
+
code += variable.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
2615
|
+
code += ';\n';
|
|
2616
|
+
});
|
|
2617
|
+
if (this.variables.length) code += '\n';
|
|
2618
|
+
|
|
2619
|
+
if (callback) {
|
|
2620
|
+
code += callback.call(this, state);
|
|
2621
|
+
} else {
|
|
2622
|
+
code += this.elements[0].toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
code += `\n${indent(state.tabSize)}}\n`;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
return code;
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2576
2631
|
*toEmbeddedTSFile(): EmbeddedTSFileGenerator {
|
|
2577
2632
|
let code = `namespace ${this.getTsNamespace()} {\n`;
|
|
2578
2633
|
const state = createCompilerState(code, {
|