@lcap/nasl 2.20.1-beta.1 → 2.20.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/bak/translator.js +3 -3
- package/out/bak/translator.js.map +1 -1
- package/out/concepts/BindAttribute__.js +7 -6
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +7 -6
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.js +10 -10
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/CallLogic__.js +1 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/DataSource__.js +11 -3
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.js +1 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/Logic__.js +2 -2
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +3 -0
- package/out/concepts/Match__.js +73 -2
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +1 -0
- package/out/concepts/NewComposite__.js +20 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +7 -0
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +8 -3
- package/out/concepts/View__.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +1 -0
- package/out/generator/genReleaseBody.js +1 -0
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.d.ts +1 -0
- package/out/generator/permission.js +17 -8
- package/out/generator/permission.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/server/naslServer.js +13 -6
- package/out/server/naslServer.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +2 -2
- package/out/templator/genCurdMultipleKeyBlock.js +2 -2
- package/out/translator/index.js +4 -1
- package/out/translator/index.js.map +1 -1
- package/package.json +1 -1
- package/sandbox/stdlib/nasl.oql.ts +4 -0
- package/src/bak/translator.js +3 -3
- package/src/concepts/BindAttribute__.ts +7 -5
- package/src/concepts/BindDirective__.ts +7 -5
- package/src/concepts/BindStyle__.ts +7 -6
- package/src/concepts/CallLogic__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +2 -2
- package/src/concepts/DataSource__.ts +11 -7
- package/src/concepts/Destination__.ts +1 -1
- package/src/concepts/Logic__.ts +2 -2
- package/src/concepts/Match__.ts +77 -2
- package/src/concepts/NewComposite__.ts +20 -2
- package/src/concepts/ViewElement__.ts +9 -1
- package/src/concepts/View__.ts +11 -8
- package/src/generator/genReleaseBody.ts +2 -1
- package/src/generator/permission.ts +17 -7
- package/src/index.ts +1 -1
- package/src/server/naslServer.ts +11 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -2
- package/src/templator/genCurdMultipleKeyBlock.ts +2 -2
- package/src/translator/index.ts +3 -1
|
@@ -295,12 +295,16 @@ declare namespace nasl.oql {
|
|
|
295
295
|
export function MAX(value: nasl.core.Double): nasl.core.Double;
|
|
296
296
|
export function MAX(value: nasl.core.Decimal): nasl.core.Decimal;
|
|
297
297
|
export function MAX(value: nasl.core.Date): nasl.core.Date;
|
|
298
|
+
export function MAX(value: nasl.core.DateTime): nasl.core.DateTime;
|
|
299
|
+
export function MAX(value: nasl.core.Time): nasl.core.Time;
|
|
298
300
|
export function MAX(value: nasl.core.Boolean): nasl.core.Boolean;
|
|
299
301
|
export function MIN(value: nasl.core.Integer): nasl.core.Integer;
|
|
300
302
|
export function MIN(value: nasl.core.Long): nasl.core.Long;
|
|
301
303
|
export function MIN(value: nasl.core.Double): nasl.core.Double;
|
|
302
304
|
export function MIN(value: nasl.core.Decimal): nasl.core.Decimal;
|
|
303
305
|
export function MIN(value: nasl.core.Date): nasl.core.Date;
|
|
306
|
+
export function MIN(value: nasl.core.DateTime): nasl.core.DateTime;
|
|
307
|
+
export function MIN(value: nasl.core.Time): nasl.core.Time;
|
|
304
308
|
export function MIN(value: nasl.core.Boolean): nasl.core.Boolean;
|
|
305
309
|
|
|
306
310
|
// self
|
package/src/bak/translator.js
CHANGED
|
@@ -76,9 +76,9 @@ export default function (definition) {
|
|
|
76
76
|
|
|
77
77
|
let viewExpressionMethods;
|
|
78
78
|
if (hasViewExpressions) {
|
|
79
|
-
viewExpressions.forEach((viewExpression) => {
|
|
80
|
-
|
|
81
|
-
});
|
|
79
|
+
//viewExpressions.forEach((viewExpression) => {
|
|
80
|
+
// viewVariablesData.push(`${safeCodeAsKey(viewExpression.expressionNameInView)}: undefined`);
|
|
81
|
+
//});
|
|
82
82
|
viewExpressionMethods = (viewExpressions).map((viewExpression) =>
|
|
83
83
|
viewExpression.getInViewMethod({
|
|
84
84
|
tabSize: 1,
|
|
@@ -815,12 +815,13 @@ export class BindAttribute extends BaseNode {
|
|
|
815
815
|
let memberExpressionNode = node?.parentNode;
|
|
816
816
|
while (memberExpressionNode?.concept === 'MemberExpression') {
|
|
817
817
|
expressionNode = memberExpressionNode;
|
|
818
|
+
// 为了处理MemberExpression里面存在CallLogic、CallFunction等的情况
|
|
818
819
|
const { concept: objConcept } = memberExpressionNode.object || {};
|
|
819
820
|
if (!['MemberExpression', 'Identifier'].includes(objConcept)) {
|
|
820
821
|
memberExpressionNode = null;
|
|
821
822
|
expressionNode = null;
|
|
822
823
|
} else {
|
|
823
|
-
memberExpressionNode = memberExpressionNode.
|
|
824
|
+
memberExpressionNode = memberExpressionNode.parentNode;
|
|
824
825
|
}
|
|
825
826
|
}
|
|
826
827
|
if (expressionNode) {
|
|
@@ -926,10 +927,11 @@ export class BindAttribute extends BaseNode {
|
|
|
926
927
|
let value = this.value;
|
|
927
928
|
if (this.type === 'dynamic' || (this.name === 'rules' && this.rules)) {
|
|
928
929
|
// 需要用标识符替换
|
|
929
|
-
if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
} else
|
|
930
|
+
//if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
|
|
931
|
+
// const argsList = this.getArgsList();
|
|
932
|
+
// value = `${this.expressionBuilderName}(${argsList.join(', ')})`;
|
|
933
|
+
//} else
|
|
934
|
+
if (this.name === 'rules' && this.rules) {
|
|
933
935
|
const ruleStrs = this.rules.map((rule) => rule.toVue(options));
|
|
934
936
|
value = `[${ruleStrs.join(' , ')}]`;
|
|
935
937
|
} else if (['destination', 'externalDestination'].includes(this.name)) {
|
|
@@ -416,12 +416,13 @@ export class BindDirective extends BaseNode {
|
|
|
416
416
|
let memberExpressionNode = node?.parentNode;
|
|
417
417
|
while (memberExpressionNode?.concept === 'MemberExpression') {
|
|
418
418
|
expressionNode = memberExpressionNode;
|
|
419
|
+
// 为了处理MemberExpression里面存在CallLogic、CallFunction等的情况
|
|
419
420
|
const { concept: objConcept } = memberExpressionNode.object || {};
|
|
420
421
|
if (!['MemberExpression', 'Identifier'].includes(objConcept)) {
|
|
421
422
|
memberExpressionNode = null;
|
|
422
423
|
expressionNode = null;
|
|
423
424
|
} else {
|
|
424
|
-
memberExpressionNode = memberExpressionNode.
|
|
425
|
+
memberExpressionNode = memberExpressionNode.parentNode;
|
|
425
426
|
}
|
|
426
427
|
}
|
|
427
428
|
if (expressionNode) {
|
|
@@ -518,10 +519,11 @@ export class BindDirective extends BaseNode {
|
|
|
518
519
|
// eslint-disable-next-line no-nested-ternary
|
|
519
520
|
let value = (this.type ?? 'string') !== 'string' ? this.value : this.value ? `'${this.value}'` : '';
|
|
520
521
|
// 需要用标识符替换
|
|
521
|
-
if (options.finalCode !== false && this.needReplaceWithIdentifier) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
} else
|
|
522
|
+
//if (options.finalCode !== false && this.needReplaceWithIdentifier) {
|
|
523
|
+
// const argsList = this.getArgsList();
|
|
524
|
+
// value = `${this.expressionBuilderName}(${argsList.join(', ')})`;
|
|
525
|
+
//} else
|
|
526
|
+
if (this.expression) {
|
|
525
527
|
value = this.expression.toVue(options);
|
|
526
528
|
if (this.expression.concept === 'StringLiteral') {
|
|
527
529
|
value = `${value}`;
|
|
@@ -372,12 +372,13 @@ export class BindStyle extends BaseNode {
|
|
|
372
372
|
let memberExpressionNode = node?.parentNode;
|
|
373
373
|
while (memberExpressionNode?.concept === 'MemberExpression') {
|
|
374
374
|
expressionNode = memberExpressionNode;
|
|
375
|
+
// 为了处理MemberExpression里面存在CallLogic、CallFunction等的情况
|
|
375
376
|
const { concept: objConcept } = memberExpressionNode.object || {};
|
|
376
377
|
if (!['MemberExpression', 'Identifier'].includes(objConcept)) {
|
|
377
378
|
memberExpressionNode = null;
|
|
378
379
|
expressionNode = null;
|
|
379
380
|
} else {
|
|
380
|
-
memberExpressionNode = memberExpressionNode.
|
|
381
|
+
memberExpressionNode = memberExpressionNode.parentNode;
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
384
|
if (expressionNode) {
|
|
@@ -472,14 +473,14 @@ export class BindStyle extends BaseNode {
|
|
|
472
473
|
toVue(options?: ElementToVueOptions) {
|
|
473
474
|
let value: string;
|
|
474
475
|
// 需要用标识符替换
|
|
475
|
-
if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
} else {
|
|
476
|
+
//if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
|
|
477
|
+
// const argsList = this.getArgsList();
|
|
478
|
+
// value = `${this.expressionBuilderName} (${argsList.join(', ')})`;
|
|
479
|
+
//} else {
|
|
479
480
|
value = this.expression?.toVue(options);
|
|
480
481
|
if (this.name?.endsWith('background-image') && value)
|
|
481
482
|
value = `\`url(\${${value}})\``;
|
|
482
|
-
}
|
|
483
|
+
//}
|
|
483
484
|
return value && `'${this.name}': ${value}`;
|
|
484
485
|
}
|
|
485
486
|
|
|
@@ -534,7 +534,7 @@ export class CallLogic extends LogicItem {
|
|
|
534
534
|
if (typeof argIndex === 'number') {
|
|
535
535
|
if (!this.arguments[argIndex]?.expression) {
|
|
536
536
|
// 如果本身没有值就直接删除
|
|
537
|
-
return this.arguments[argIndex]
|
|
537
|
+
return this.arguments[argIndex]?.delete();
|
|
538
538
|
}
|
|
539
539
|
if (argIndex !== this.arguments.length - 1) {
|
|
540
540
|
this.arguments[argIndex]?.moveNode({
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import Namespace from './Namespace__';
|
|
2
|
+
|
|
1
3
|
//================================================================================
|
|
2
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
3
5
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -11,8 +13,6 @@ import BaseNode from '../common/BaseNode';
|
|
|
11
13
|
import classMap from '../common/classMap';
|
|
12
14
|
import ConfigProperty from './ConfigProperty__';
|
|
13
15
|
import App from './App__';
|
|
14
|
-
import Namespace from './Namespace__';
|
|
15
|
-
import Configuration from './Configuration__';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* 配置组
|
|
@@ -94,7 +94,7 @@ export class DataSource extends BaseNode {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
getEntityExistingNames(excludedList: Array<Entity> = []) {
|
|
98
98
|
const excludedSet = new Set(excludedList);
|
|
99
99
|
return ((this.entities as Entity[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
100
100
|
}
|
|
@@ -235,9 +235,6 @@ export class DataSource extends BaseNode {
|
|
|
235
235
|
return node;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
238
|
/**
|
|
242
239
|
* 删除实体
|
|
243
240
|
* @param name 实体名称
|
|
@@ -422,13 +419,20 @@ export class DataSource extends BaseNode {
|
|
|
422
419
|
if (!prop.value) {
|
|
423
420
|
return;
|
|
424
421
|
}
|
|
425
|
-
|
|
422
|
+
let isRecycled = false;
|
|
423
|
+
try {
|
|
424
|
+
const value = JSON.parse(prop.value);
|
|
425
|
+
// 被回收的数据库不需要 Ping
|
|
426
|
+
if (value.dataBaseMode === 'Platform_Generation' && value.status === 1) {
|
|
427
|
+
isRecycled = true;
|
|
428
|
+
}
|
|
429
|
+
} catch (e) {}
|
|
426
430
|
const env = prop.env;
|
|
427
|
-
return datasourceService.pingDatabase({
|
|
431
|
+
return isRecycled ? Promise.resolve() : datasourceService.pingDatabase({
|
|
428
432
|
body: {
|
|
429
433
|
category: 'sql',
|
|
430
434
|
appId: this.app.id,
|
|
431
|
-
dataSource,
|
|
435
|
+
dataSource: configProperty.name,
|
|
432
436
|
env,
|
|
433
437
|
},
|
|
434
438
|
}).then(() => {
|
|
@@ -599,7 +599,7 @@ export class Destination extends LogicItem {
|
|
|
599
599
|
*/
|
|
600
600
|
if (typeof argIndex === 'number') {
|
|
601
601
|
if (!this.arguments[argIndex]?.expression) {
|
|
602
|
-
return this.arguments[argIndex]
|
|
602
|
+
return this.arguments[argIndex]?.delete();
|
|
603
603
|
}
|
|
604
604
|
if (argIndex !== this.arguments.length - 1) {
|
|
605
605
|
// 如果本身没有值就直接删除
|
package/src/concepts/Logic__.ts
CHANGED
|
@@ -1712,11 +1712,11 @@ export class Logic extends BaseNode {
|
|
|
1712
1712
|
}
|
|
1713
1713
|
}
|
|
1714
1714
|
});
|
|
1715
|
-
} else if (['NewList', 'NewMap'].includes(assignment.right
|
|
1715
|
+
} else if (['NewList', 'NewMap'].includes(assignment.right?.concept) && !(assignment.right as any)?.typeAnnotation) {
|
|
1716
1716
|
const rightNode: any = assignment.right;
|
|
1717
1717
|
code += ' = ';
|
|
1718
1718
|
code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
|
|
1719
|
-
} else if (assignment.right
|
|
1719
|
+
} else if (assignment.right?.concept === 'NewComposite' && (assignment.right as any)?.typeAnnotation?.typeKind === 'anonymousStructure') {
|
|
1720
1720
|
const rightNode: any = assignment.right;
|
|
1721
1721
|
code += ' = ';
|
|
1722
1722
|
code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
|
package/src/concepts/Match__.ts
CHANGED
|
@@ -438,10 +438,69 @@ export class Match extends LogicItem {
|
|
|
438
438
|
this.emit('change', $event);
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
+
|
|
442
|
+
// 获取在页面中的名字
|
|
443
|
+
get expressionNameInView() {
|
|
444
|
+
const nameList: string[] = [];
|
|
445
|
+
let node: BaseNode = this;
|
|
446
|
+
while (node) {
|
|
447
|
+
if (node === this) {
|
|
448
|
+
nameList.unshift('viewMatchExpression');
|
|
449
|
+
} else {
|
|
450
|
+
nameList.unshift(node.name);
|
|
451
|
+
}
|
|
452
|
+
if (node.concept === 'ViewElement') {
|
|
453
|
+
node = null;
|
|
454
|
+
} else {
|
|
455
|
+
nameList.unshift(node.parentKey);
|
|
456
|
+
node = node.parentNode;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return nameList.join('_').replace(/-/g, '_');
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
getViewMatchExpressionBuilder() {
|
|
463
|
+
return `gen${this.expressionNameInView}`;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
getInViewMethod(state?: TranslatorState) {
|
|
467
|
+
const viewElement = this?.getAncestor('ViewElement');
|
|
468
|
+
const argsList = [];
|
|
469
|
+
let parent = viewElement?.parentNode;
|
|
470
|
+
let index = 0;
|
|
471
|
+
while (parent && parent.concept !== 'View') {
|
|
472
|
+
if ((parent as ViewElement).slotScope) {
|
|
473
|
+
argsList.unshift(index === 0 ? 'current' : 'current' + index);
|
|
474
|
+
index++;
|
|
475
|
+
}
|
|
476
|
+
parent = parent.parentNode;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
let code = '';
|
|
480
|
+
code += `${this.getViewMatchExpressionBuilder()} (${argsList.join(', ')}) {\n`;
|
|
481
|
+
code += `return ${this.toJS()}`;
|
|
482
|
+
code += `;\n`;
|
|
483
|
+
code += '}';
|
|
484
|
+
return code;
|
|
485
|
+
}
|
|
486
|
+
|
|
441
487
|
toVue(state?: TranslatorState): string {
|
|
442
488
|
if (state?.finalCode === false) {
|
|
443
489
|
return this.toUI();
|
|
444
490
|
} else {
|
|
491
|
+
const viewElement = this?.getAncestor('ViewElement');
|
|
492
|
+
const argsList = [];
|
|
493
|
+
let parent = viewElement?.parentNode;
|
|
494
|
+
let index = 0;
|
|
495
|
+
while (parent && parent.concept !== 'View') {
|
|
496
|
+
if ((parent as ViewElement).slotScope) {
|
|
497
|
+
argsList.unshift(index === 0 ? 'current' : 'current' + index);
|
|
498
|
+
index++;
|
|
499
|
+
}
|
|
500
|
+
parent = parent.parentNode;
|
|
501
|
+
}
|
|
502
|
+
return `${this.getViewMatchExpressionBuilder()}(${argsList.join(', ')})`;
|
|
503
|
+
|
|
445
504
|
// let code = 'await (async () => {\n';
|
|
446
505
|
// if (this.expression && Array.isArray(this.cases)) {
|
|
447
506
|
// this.cases.forEach((item, index) => {
|
|
@@ -469,13 +528,29 @@ export class Match extends LogicItem {
|
|
|
469
528
|
}
|
|
470
529
|
|
|
471
530
|
toJS(state?: TranslatorState): string {
|
|
472
|
-
let code = 'await (async () => {\n';
|
|
531
|
+
//let code = 'await (async () => {\n';
|
|
532
|
+
//if (this.expression && Array.isArray(this.cases)) {
|
|
533
|
+
// this.cases.forEach((item, index) => {
|
|
534
|
+
// code += item?.toJS?.(this.expression, index, this.cases.length);
|
|
535
|
+
// });
|
|
536
|
+
//}
|
|
537
|
+
//code += `})()`;
|
|
538
|
+
//return code;
|
|
539
|
+
|
|
540
|
+
let code = '';
|
|
541
|
+
// 祖先逻辑
|
|
542
|
+
const ancestorLogic = this.getAncestor('Logic');
|
|
543
|
+
if (ancestorLogic) {
|
|
544
|
+
code += 'await (async () => {\n';
|
|
545
|
+
} else {
|
|
546
|
+
code += '(() => {\n';
|
|
547
|
+
}
|
|
473
548
|
if (this.expression && Array.isArray(this.cases)) {
|
|
474
549
|
this.cases.forEach((item, index) => {
|
|
475
550
|
code += item?.toJS?.(this.expression, index, this.cases.length);
|
|
476
551
|
});
|
|
477
552
|
}
|
|
478
|
-
code +=
|
|
553
|
+
code += '})()';
|
|
479
554
|
return code;
|
|
480
555
|
}
|
|
481
556
|
|
|
@@ -3,6 +3,7 @@ import { ElementToVueOptions } from './ViewElement__';
|
|
|
3
3
|
import MemberExpression from './MemberExpression__';
|
|
4
4
|
import StructureProperty from './StructureProperty__';
|
|
5
5
|
import App from './App__';
|
|
6
|
+
import { genHash } from '../generator';
|
|
6
7
|
//================================================================================
|
|
7
8
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
8
9
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -1215,7 +1216,7 @@ export class NewComposite extends LogicItem {
|
|
|
1215
1216
|
}
|
|
1216
1217
|
});
|
|
1217
1218
|
code += 'return {\n';
|
|
1218
|
-
code += `__name: "AStructure_${this
|
|
1219
|
+
code += `__name: "AStructure_${genHash(JSON.stringify(this))}" as const,\n`;
|
|
1219
1220
|
this.properties.forEach((property) => {
|
|
1220
1221
|
code += `${property.name},\n`;
|
|
1221
1222
|
});
|
|
@@ -1266,7 +1267,7 @@ export class NewComposite extends LogicItem {
|
|
|
1266
1267
|
}
|
|
1267
1268
|
});
|
|
1268
1269
|
code += '\nreturn {\n';
|
|
1269
|
-
code += `__name: "AStructure_${this
|
|
1270
|
+
code += `__name: "AStructure_${genHash(JSON.stringify(this))}" as const,\n`;
|
|
1270
1271
|
this.properties.forEach((property) => {
|
|
1271
1272
|
code += `${property.name},\n`;
|
|
1272
1273
|
});
|
|
@@ -1279,9 +1280,23 @@ export class NewComposite extends LogicItem {
|
|
|
1279
1280
|
return code;
|
|
1280
1281
|
}
|
|
1281
1282
|
|
|
1283
|
+
__addIdentifier() {
|
|
1284
|
+
this.app.emit('collect:start', {
|
|
1285
|
+
actionMsg: '添加匿名数据结构属性',
|
|
1286
|
+
});
|
|
1287
|
+
const node = this.addIdentifier({ name: this.getIdentifierUniqueName('property1') });
|
|
1288
|
+
const struct = StructureProperty.from({
|
|
1289
|
+
name: node.name,
|
|
1290
|
+
typeAnnotation: null,
|
|
1291
|
+
});
|
|
1292
|
+
this.typeAnnotation.addStructureProperty(struct);
|
|
1293
|
+
this.app.emit('collect:end');
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1282
1296
|
__deleteIdentifier(property: Identifier) {
|
|
1283
1297
|
const index = this.properties.findIndex((p) => p === property);
|
|
1284
1298
|
const newLines: AssignmentLine[] = [];
|
|
1299
|
+
const newProperties = this.typeAnnotation.properties.filter((item) => item.name !== property.name);
|
|
1285
1300
|
this.assignmentLines.forEach((line) => {
|
|
1286
1301
|
const { leftIndex } = line;
|
|
1287
1302
|
if (leftIndex[1] < index) {
|
|
@@ -1295,6 +1310,9 @@ export class NewComposite extends LogicItem {
|
|
|
1295
1310
|
actionMsg: '删除匿名数据结属性',
|
|
1296
1311
|
});
|
|
1297
1312
|
this.setAssignmentLines(newLines);
|
|
1313
|
+
this.typeAnnotation.update({
|
|
1314
|
+
properties: newProperties,
|
|
1315
|
+
});
|
|
1298
1316
|
property.delete();
|
|
1299
1317
|
this.app.emit('collect:end');
|
|
1300
1318
|
}
|
|
@@ -1079,7 +1079,7 @@ export class ViewElement extends BaseNode {
|
|
|
1079
1079
|
}
|
|
1080
1080
|
|
|
1081
1081
|
|
|
1082
|
-
|
|
1082
|
+
|
|
1083
1083
|
|
|
1084
1084
|
/**
|
|
1085
1085
|
* 删除元素绑定属性
|
|
@@ -1348,6 +1348,10 @@ export class ViewElement extends BaseNode {
|
|
|
1348
1348
|
return `${this.view.path}/${this.name}`;
|
|
1349
1349
|
}
|
|
1350
1350
|
|
|
1351
|
+
get auth() {
|
|
1352
|
+
return this.bindDirectives.find((directive) => directive.name === 'auth');
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1351
1355
|
getViewElementUniqueName(name = 'viewElement1') {
|
|
1352
1356
|
return this.view?.getViewElementUniqueName(name);
|
|
1353
1357
|
}
|
|
@@ -2141,6 +2145,10 @@ export class ViewElement extends BaseNode {
|
|
|
2141
2145
|
}
|
|
2142
2146
|
});
|
|
2143
2147
|
}
|
|
2148
|
+
// 部分组件增加 key 唯一标识,防止 vue 判断重复节点,导致渲染异常
|
|
2149
|
+
if (this.name && ['u-table-view', 'u-list-view', 'u-grid-view', 'u-list-components', 'u-form', 'u-select'].includes(this.tag)) {
|
|
2150
|
+
this.name && parts.push(`key="${this.name}"`);
|
|
2151
|
+
}
|
|
2144
2152
|
|
|
2145
2153
|
let partsLength = 0;
|
|
2146
2154
|
let partsString = '';
|
package/src/concepts/View__.ts
CHANGED
|
@@ -2021,12 +2021,15 @@ export class View extends BaseNode {
|
|
|
2021
2021
|
this.elements.forEach((item) => {
|
|
2022
2022
|
utils.traverse((current) => {
|
|
2023
2023
|
const { node } = current as any;
|
|
2024
|
-
|
|
2025
|
-
if (
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
) {
|
|
2029
|
-
|
|
2024
|
+
//// 处理三种情况
|
|
2025
|
+
//if (
|
|
2026
|
+
// ['BindAttribute', 'BindDirective', 'BindStyle'].includes(node.concept)
|
|
2027
|
+
// && node.needReplaceWithIdentifier
|
|
2028
|
+
//) {
|
|
2029
|
+
// bindExpressions.push(node);
|
|
2030
|
+
//}
|
|
2031
|
+
if (node.concept === 'Match') {
|
|
2032
|
+
bindExpressions.push(node as Match);
|
|
2030
2033
|
}
|
|
2031
2034
|
}, {
|
|
2032
2035
|
node: item,
|
|
@@ -2237,8 +2240,8 @@ export class View extends BaseNode {
|
|
|
2237
2240
|
return code;
|
|
2238
2241
|
}
|
|
2239
2242
|
|
|
2240
|
-
getViewCallLogics():string[] {
|
|
2241
|
-
const callbackLogics
|
|
2243
|
+
getViewCallLogics(): string[] {
|
|
2244
|
+
const callbackLogics: string[] = [];
|
|
2242
2245
|
this.traverseChildren((el) => {
|
|
2243
2246
|
if (el instanceof Identifier && el.namespace?.endsWith('logics')) {
|
|
2244
2247
|
callbackLogics.push(el.namespace + '.' + el.name);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { App, Assignment, BatchAssignment, CallFunction, CallInterface, CallLogic, ForEachStatement, IfStatement, Logic, LogicItem, Match, MatchCase, MemberExpression, Role, SwitchCase, SwitchStatement, View, ViewElement, WhileStatement, StringInterpolation, Frontend, ExternalDestination, NewComposite, SelectMembers, NewList } from '../concepts';
|
|
2
2
|
import { genFrontendBundleFiles } from './genBundleFiles';
|
|
3
|
-
import { genPermissionData } from './permission';
|
|
3
|
+
import { genPermissionData, genLogicAuthFlag } from './permission';
|
|
4
4
|
import * as utils from '../utils';
|
|
5
5
|
|
|
6
6
|
export async function genReleaseBody(app: App, {
|
|
@@ -47,6 +47,7 @@ export async function genReleaseBody(app: App, {
|
|
|
47
47
|
const body = {
|
|
48
48
|
...authReport, // 如果发布需要上报权限,导出源码不需要
|
|
49
49
|
logicPageResourceDtoList,
|
|
50
|
+
logicAuthFlag: genLogicAuthFlag(app),
|
|
50
51
|
noAuthApiPathList: getAuthApiPathList(app, frontends),
|
|
51
52
|
reportIdList: findAllReportIdList(app, frontends),
|
|
52
53
|
appId: app.id,
|
|
@@ -102,13 +102,11 @@ function findResourcesOfUI(view: View | ViewElement) {
|
|
|
102
102
|
path: node.authPath,
|
|
103
103
|
type: 'page',
|
|
104
104
|
});
|
|
105
|
-
else if (node instanceof ViewElement) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
type: 'component',
|
|
111
|
-
});
|
|
105
|
+
else if (node instanceof ViewElement && node.auth) {
|
|
106
|
+
res.push({
|
|
107
|
+
path: node.authPath,
|
|
108
|
+
type: 'component',
|
|
109
|
+
});
|
|
112
110
|
}
|
|
113
111
|
node = node.parentNode;
|
|
114
112
|
}
|
|
@@ -275,3 +273,15 @@ export async function genPermissionData(app: App) {
|
|
|
275
273
|
// console.timeEnd('xxx');
|
|
276
274
|
return logicPageResourceDtoList;
|
|
277
275
|
}
|
|
276
|
+
|
|
277
|
+
export function genLogicAuthFlag(app: App) {
|
|
278
|
+
let flag = false;
|
|
279
|
+
app.traverseChildren((node) => {
|
|
280
|
+
if(flag) return;
|
|
281
|
+
|
|
282
|
+
if((node instanceof View || node instanceof ViewElement) && node.auth)
|
|
283
|
+
flag = true;
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
return flag;
|
|
287
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { EventEmitter, EventPayload, BaseNode } from './common';
|
|
2
2
|
export * from './concepts';
|
|
3
|
-
export { genBundleFiles, genFrontendBundleFiles, genMetaData, genReleaseBody, genPermissionData } from './generator';
|
|
3
|
+
export { genBundleFiles, genFrontendBundleFiles, genMetaData, genReleaseBody, genPermissionData, genLogicAuthFlag } from './generator';
|
|
4
4
|
export * from './translator';
|
|
5
5
|
// export { default as diagnosticManager } from './manager/diagnostic';
|
|
6
6
|
export { default as server, NaslServer } from './server';
|
package/src/server/naslServer.ts
CHANGED
|
@@ -1679,8 +1679,8 @@ export class NaslServer {
|
|
|
1679
1679
|
const diagnostic = {
|
|
1680
1680
|
node,
|
|
1681
1681
|
severity: 'error',
|
|
1682
|
-
message: '
|
|
1683
|
-
titleTip: '
|
|
1682
|
+
message: '匹配分支:返回内容不能为空',
|
|
1683
|
+
titleTip: '返回内容不能为空',
|
|
1684
1684
|
};
|
|
1685
1685
|
node.tsErrorDetail = diagnostic;
|
|
1686
1686
|
diagnostics.push(diagnostic);
|
|
@@ -1792,11 +1792,12 @@ export class NaslServer {
|
|
|
1792
1792
|
'nasl.collection.Map<nasl.core.String, nasl.core.String>',
|
|
1793
1793
|
'nasl.collection.Map<nasl.core.String, nasl.core.Text>',
|
|
1794
1794
|
'nasl.collection.Map<nasl.core.String, nasl.core.Email>',
|
|
1795
|
-
'nasl.collection.List<>',
|
|
1796
1795
|
];
|
|
1797
1796
|
// 先特殊处理等 类型合并后就可以去掉了
|
|
1798
1797
|
if (excludeList.includes(leftType.sortedTypeKey) && excludeList.includes(rightType.sortedTypeKey)) {
|
|
1799
1798
|
return null;
|
|
1799
|
+
} else if (['nasl.collection.List<>'].includes(leftType.sortedTypeKey) || ['nasl.collection.List<>'].includes(rightType.sortedTypeKey)) {
|
|
1800
|
+
return null;
|
|
1800
1801
|
}
|
|
1801
1802
|
const diagnostic = {
|
|
1802
1803
|
node: node.right,
|
|
@@ -3056,7 +3057,11 @@ export class NaslServer {
|
|
|
3056
3057
|
}
|
|
3057
3058
|
} else if (node.concept === 'Match') {
|
|
3058
3059
|
// 去查return 后面的返回值,变成函数调用
|
|
3059
|
-
|
|
3060
|
+
if (item.code?.endsWith(';\n')) {
|
|
3061
|
+
fileDetail.line = item.range.end.line - 1;
|
|
3062
|
+
} else {
|
|
3063
|
+
fileDetail.line = item.range.end.line;
|
|
3064
|
+
}
|
|
3060
3065
|
const indexOf = item.code.indexOf('return __MatchExpressionFuntion');
|
|
3061
3066
|
let newCode = item.code.substring(0, indexOf);
|
|
3062
3067
|
newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
|
|
@@ -3108,8 +3113,8 @@ export class NaslServer {
|
|
|
3108
3113
|
// 直接从最后一项的返回值取,有就有没有就没有
|
|
3109
3114
|
if (node.body?.length) {
|
|
3110
3115
|
const last = node.body[node.body.length - 1];
|
|
3111
|
-
if (last
|
|
3112
|
-
types.set(node, last
|
|
3116
|
+
if (types.get(last)) {
|
|
3117
|
+
types.set(node, types.get(last));
|
|
3113
3118
|
}
|
|
3114
3119
|
}
|
|
3115
3120
|
}
|
|
@@ -31,7 +31,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
31
31
|
|
|
32
32
|
return `
|
|
33
33
|
<u-linear-layout justify="space-between">
|
|
34
|
-
<u-form layout="inline"
|
|
34
|
+
<u-form layout="inline">
|
|
35
35
|
${properties
|
|
36
36
|
.map((property) => {
|
|
37
37
|
const vModel = `${nameGroup.viewVariableFilter}.${property.name}`;
|
|
@@ -97,7 +97,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
97
97
|
})
|
|
98
98
|
.join('')}
|
|
99
99
|
|
|
100
|
-
<u-form-item layout="center">
|
|
100
|
+
<u-form-item layout="center" label-size="auto">
|
|
101
101
|
<u-button color="primary" @click="${nameGroup.viewLogicReload}">查询</u-button>
|
|
102
102
|
</u-form-item>
|
|
103
103
|
</u-form>
|
|
@@ -22,7 +22,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
22
22
|
const properties = entity.properties.filter(filterProperty('inFilter'));
|
|
23
23
|
return `
|
|
24
24
|
<u-linear-layout justify="space-between">
|
|
25
|
-
<u-form layout="inline"
|
|
25
|
+
<u-form layout="inline">
|
|
26
26
|
${properties
|
|
27
27
|
.map((property) => {
|
|
28
28
|
const vModel = `${nameGroup.viewVariableFilter}.${property.name}`;
|
|
@@ -91,7 +91,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
91
91
|
})
|
|
92
92
|
.join('')}
|
|
93
93
|
|
|
94
|
-
<u-form-item layout="center">
|
|
94
|
+
<u-form-item layout="center" label-size="auto">
|
|
95
95
|
<u-button color="primary" @click="${nameGroup.viewLogicReload}">查询</u-button>
|
|
96
96
|
</u-form-item>
|
|
97
97
|
</u-form>
|
package/src/translator/index.ts
CHANGED
|
@@ -89,7 +89,9 @@ export function withSourceMap() {
|
|
|
89
89
|
descriptor.value = function (this: BaseNode, state?: TranslatorState, ...args: any[]) {
|
|
90
90
|
// 重新生成ts代码就先把类型清除掉
|
|
91
91
|
// 注意排查错误的时候,调用了这个方法,就会把节点上缓存的__TypeAnnotation清除
|
|
92
|
-
|
|
92
|
+
try {
|
|
93
|
+
this.__isCorrectTypeAnnotation = false;
|
|
94
|
+
} catch (err) {}
|
|
93
95
|
if (!state) {
|
|
94
96
|
// 没有状态不生成 SourceMap
|
|
95
97
|
return oldMethod.call(this);
|