@lcap/nasl 0.3.9-beta → 0.3.10-beta.5

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.
Files changed (152) hide show
  1. package/out/service/create/errHandles.js +7 -2
  2. package/out/service/create/errHandles.js.map +1 -1
  3. package/out/service/logic/logic.d.ts +50 -14
  4. package/out/service/logic/logic.js +26 -0
  5. package/out/service/logic/logic.js.map +1 -1
  6. package/out/service/page/element.d.ts +9 -0
  7. package/out/service/page/element.js +6 -0
  8. package/out/service/page/element.js.map +1 -1
  9. package/out/service/permission/api.d.ts +57 -0
  10. package/out/service/permission/api.js +41 -0
  11. package/out/service/permission/api.js.map +1 -0
  12. package/out/service/permission/index.d.ts +2 -0
  13. package/out/service/permission/index.js +17 -0
  14. package/out/service/permission/index.js.map +1 -0
  15. package/out/service/webFile/index.js +5 -0
  16. package/out/service/webFile/index.js.map +1 -1
  17. package/out/types/app/App.d.ts +4 -0
  18. package/out/types/app/App.js +30 -0
  19. package/out/types/app/App.js.map +1 -1
  20. package/out/types/app/Service.d.ts +2 -2
  21. package/out/types/app/Service.js +28 -3
  22. package/out/types/app/Service.js.map +1 -1
  23. package/out/types/cache.d.ts +6 -0
  24. package/out/types/cache.js +54 -0
  25. package/out/types/cache.js.map +1 -0
  26. package/out/types/cacheData.js.map +1 -1
  27. package/out/types/common/Vertex.d.ts +25 -0
  28. package/out/types/common/Vertex.js +40 -0
  29. package/out/types/common/Vertex.js.map +1 -1
  30. package/out/types/data/Entity.js +1 -0
  31. package/out/types/data/Entity.js.map +1 -1
  32. package/out/types/data/Enum.d.ts +5 -0
  33. package/out/types/data/Enum.js +5 -0
  34. package/out/types/data/Enum.js.map +1 -1
  35. package/out/types/data/Interface.js +5 -3
  36. package/out/types/data/Interface.js.map +1 -1
  37. package/out/types/data/dataTypes.js +1 -1
  38. package/out/types/data/dataTypes.js.map +1 -1
  39. package/out/types/data/genBlock/genCreateBlock.js +5 -5
  40. package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
  41. package/out/types/data/genBlock/genCurdBlock.js +3 -3
  42. package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
  43. package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
  44. package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
  45. package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
  46. package/out/types/data/genBlock/genGridViewBlock.js +12 -1
  47. package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
  48. package/out/types/data/genBlock/genListViewBlock.js +2 -2
  49. package/out/types/data/genBlock/genSelectBlock.js +2 -2
  50. package/out/types/data/genBlock/genTableBlock.js +14 -3
  51. package/out/types/data/genBlock/genTableBlock.js.map +1 -1
  52. package/out/types/data/genBlock/genUpdateBlock.js +5 -5
  53. package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
  54. package/out/types/data/systemTypes.js +47 -0
  55. package/out/types/data/systemTypes.js.map +1 -1
  56. package/out/types/enum.d.ts +6 -0
  57. package/out/types/enum.js +11 -0
  58. package/out/types/enum.js.map +1 -0
  59. package/out/types/generator/hotReload.d.ts +2 -0
  60. package/out/types/generator/hotReload.js +12 -1
  61. package/out/types/generator/hotReload.js.map +1 -1
  62. package/out/types/index.d.ts +5 -1
  63. package/out/types/index.js +8 -2
  64. package/out/types/index.js.map +1 -1
  65. package/out/types/logic/Logic.d.ts +32 -0
  66. package/out/types/logic/Logic.js +142 -31
  67. package/out/types/logic/Logic.js.map +1 -1
  68. package/out/types/logic/LogicItem.d.ts +1 -0
  69. package/out/types/logic/LogicItem.js +43 -24
  70. package/out/types/logic/LogicItem.js.map +1 -1
  71. package/out/types/logic/Param.d.ts +1 -0
  72. package/out/types/logic/Param.js +40 -20
  73. package/out/types/logic/Param.js.map +1 -1
  74. package/out/types/logic/Return.js +14 -19
  75. package/out/types/logic/Return.js.map +1 -1
  76. package/out/types/logic/Variable.js +14 -19
  77. package/out/types/logic/Variable.js.map +1 -1
  78. package/out/types/logic/translator.js +39 -10
  79. package/out/types/logic/translator.js.map +1 -1
  80. package/out/types/nuims/Nuims.d.ts +1 -1
  81. package/out/types/nuims/Nuims.js +11 -4
  82. package/out/types/nuims/Nuims.js.map +1 -1
  83. package/out/types/page/Element.d.ts +16 -0
  84. package/out/types/page/Element.js +192 -129
  85. package/out/types/page/Element.js.map +1 -1
  86. package/out/types/page/Event.js.map +1 -1
  87. package/out/types/page/Page.d.ts +1 -0
  88. package/out/types/page/Page.js +71 -37
  89. package/out/types/page/Page.js.map +1 -1
  90. package/out/types/page/View.d.ts +9 -1
  91. package/out/types/page/View.js +86 -42
  92. package/out/types/page/View.js.map +1 -1
  93. package/out/types/page/ViewParam.d.ts +1 -0
  94. package/out/types/page/ViewParam.js +23 -4
  95. package/out/types/page/ViewParam.js.map +1 -1
  96. package/out/types/page/ViewVariable.js +13 -18
  97. package/out/types/page/ViewVariable.js.map +1 -1
  98. package/out/types/permission/Permission.d.ts +41 -0
  99. package/out/types/permission/Permission.js +122 -0
  100. package/out/types/permission/Permission.js.map +1 -0
  101. package/out/types/process/ProcessParam.js +3 -1
  102. package/out/types/process/ProcessParam.js.map +1 -1
  103. package/package.json +2 -3
  104. package/src/service/create/errHandles.js +6 -2
  105. package/src/service/developPermission/api.js +37 -0
  106. package/src/service/developPermission/index.js +13 -0
  107. package/src/service/logic/logic.js +26 -0
  108. package/src/service/page/element.js +6 -0
  109. package/src/service/permission/api.js +38 -0
  110. package/src/service/permission/index.js +13 -0
  111. package/src/service/webFile/index.js +6 -1
  112. package/src/types/app/App.ts +36 -1
  113. package/src/types/app/Service.ts +32 -3
  114. package/src/types/cache.ts +50 -0
  115. package/src/types/cacheData.ts +7 -7
  116. package/src/types/common/Vertex.ts +30 -0
  117. package/src/types/data/Entity.ts +1 -0
  118. package/src/types/data/Enum.ts +5 -0
  119. package/src/types/data/Interface.ts +4 -3
  120. package/src/types/data/dataTypes.ts +1 -1
  121. package/src/types/data/genBlock/genCreateBlock.ts +5 -5
  122. package/src/types/data/genBlock/genCurdBlock.ts +3 -3
  123. package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
  124. package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
  125. package/src/types/data/genBlock/genListViewBlock.ts +2 -2
  126. package/src/types/data/genBlock/genSelectBlock.ts +2 -2
  127. package/src/types/data/genBlock/genTableBlock.ts +14 -3
  128. package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
  129. package/src/types/data/systemTypes.ts +47 -0
  130. package/src/types/enum.ts +6 -0
  131. package/src/types/generator/hotReload.ts +10 -0
  132. package/src/types/index.ts +5 -1
  133. package/src/types/logic/Logic.ts +138 -28
  134. package/src/types/logic/LogicItem.ts +48 -28
  135. package/src/types/logic/Param.ts +39 -18
  136. package/src/types/logic/Return.ts +4 -9
  137. package/src/types/logic/Variable.ts +4 -8
  138. package/src/types/logic/translator.js +41 -13
  139. package/src/types/logic/translator_backup.js +5 -16
  140. package/src/types/nuims/Nuims.ts +11 -5
  141. package/src/types/page/Element.ts +211 -133
  142. package/src/types/page/Event.ts +0 -3
  143. package/src/types/page/Page.ts +86 -49
  144. package/src/types/page/View.ts +90 -42
  145. package/src/types/page/ViewParam.ts +22 -3
  146. package/src/types/page/ViewVariable.ts +4 -8
  147. package/src/types/page/dist/View.js +727 -0
  148. package/src/types/permission/Permission.ts +112 -0
  149. package/src/types/process/ProcessParam.ts +4 -1
  150. package/out/test/units/config.spec.d.ts +0 -1
  151. package/out/test/units/config.spec.js +0 -12
  152. package/out/test/units/config.spec.js.map +0 -1
@@ -1,11 +1,12 @@
1
- import { immutable, excludedInJSON, circular, action } from '../decorators';
2
- import { config, history, typeCheck, utils, Vertex, Service, LEVEL_ENUM, Interface, Param, Return, Variable, Logic, View, Schema, ActionOptions, ACTION_MODE } from '..';
1
+ import { immutable, excludedInJSON, action } from '../decorators';
2
+ import { config, typeCheck, utils, Vertex, LEVEL_ENUM, Logic, Schema, ActionOptions, ACTION_MODE } from '..';
3
3
  import { logicService } from '../../service/logic';
4
- import { assert } from 'console';
5
4
  import { traverse } from '../utils';
6
5
  import { vertexsMap } from '../cacheData';
7
6
  import { getSchemaOfExpressionNode } from './tools';
8
7
  import Structure from '../data/Structure';
8
+ import { refreshLogic } from '../cache';
9
+ import { BusinessCode } from '../enum';
9
10
 
10
11
  export enum LOGIC_TYPE {
11
12
  // LogicNode
@@ -56,6 +57,18 @@ export enum LOGIC_TYPE {
56
57
  QueryAggregateExpression = 'QueryAggregateExpression',
57
58
  }
58
59
 
60
+ const atomicList = [
61
+ LOGIC_TYPE.Identifier,
62
+ LOGIC_TYPE.NumericLiteral,
63
+ LOGIC_TYPE.BooleanLiteral,
64
+ LOGIC_TYPE.StringLiteral,
65
+ LOGIC_TYPE.NullLiteral,
66
+ LOGIC_TYPE.UnaryExpression,
67
+ LOGIC_TYPE.MemberExpression,
68
+ LOGIC_TYPE.Unparsed,
69
+ LOGIC_TYPE.BuiltInFunction,
70
+ ];
71
+
59
72
  export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): string {
60
73
  if (!node)
61
74
  return '';
@@ -76,11 +89,11 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
76
89
 
77
90
  if (node.type === 'BinaryExpression') {
78
91
  let left: string = evaluate(<LogicNode>node.left, finalCode);
79
- if (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression)
92
+ if (!atomicList.includes((node.left as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
80
93
  left = `(${left})`;
81
94
 
82
95
  let right: string = evaluate(<LogicNode>node.right, finalCode);
83
- if (!finalCode && node.right?.type === LOGIC_TYPE.MemberExpression)
96
+ if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
84
97
  right = `(${right})`;
85
98
 
86
99
  return `${left} ${node.operator} ${right}`;
@@ -88,13 +101,11 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
88
101
 
89
102
  if (node.type === 'LogicalExpression') {
90
103
  let left: string = evaluate(<LogicNode>node.left, finalCode);
91
- if (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression)
104
+ if (!atomicList.includes((node.left as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
92
105
  left = `(${left})`;
93
-
94
106
  let right: string = evaluate(<LogicNode>node.right, finalCode);
95
- if (!finalCode && node.right?.type === LOGIC_TYPE.MemberExpression)
107
+ if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
96
108
  right = `(${right})`;
97
-
98
109
  return `${left} ${node.operator} ${right}`;
99
110
  }
100
111
 
@@ -209,6 +220,18 @@ export const logicItemArrayKeyOfLogicItem: string[] = ['body', 'consequent', 'al
209
220
  'groupBy', 'orderBy', 'selectElementList', 'joinPartList', 'onExpressionList', 'where', 'having',
210
221
  ];
211
222
 
223
+ export function catchFn(logic: Logic) {
224
+ return async (err: any) => {
225
+ if (err.code !== BusinessCode.HasReferenced) // 节点被引用,不用刷新数据
226
+ await refreshLogic(logic);
227
+ else
228
+ config.defaultApp?.emit('saved', err);
229
+
230
+ config.defaultApp?.history.load();
231
+ throw err;
232
+ };
233
+ }
234
+
212
235
  /**
213
236
  * 逻辑项类
214
237
  */
@@ -432,7 +455,7 @@ export class LogicItem extends Vertex {
432
455
  operationIgnore: actionOptions?.actionIgnore,
433
456
  },
434
457
  body,
435
- });
458
+ }).catch(catchFn(this.logic));
436
459
  this.deepPick(result, ['id', 'parentId', 'parentAttr', 'joinPartRef', 'structureRef']);
437
460
  }
438
461
 
@@ -548,7 +571,7 @@ export class LogicItem extends Vertex {
548
571
  offsetY,
549
572
  },
550
573
  },
551
- });
574
+ }).catch(catchFn(this.logic));
552
575
  }
553
576
 
554
577
  if (!(this.parentId === parentId && this.parentId === this.logic.playgroundId && this.parentAttr === parentAttr)) {
@@ -612,6 +635,8 @@ export class LogicItem extends Vertex {
612
635
  * @param targetId
613
636
  */
614
637
  static async paste(logicItems: LogicItem[] | LogicItem, targetType: 'logic' | 'html' | 'processComponent', targetId: string) {
638
+ config.defaultApp?.emit('saving');
639
+
615
640
  if (!Array.isArray(logicItems))
616
641
  logicItems = [logicItems];
617
642
 
@@ -630,7 +655,7 @@ export class LogicItem extends Vertex {
630
655
  operationAction: 'LogicItem.paste',
631
656
  operationDesc: `粘贴逻辑项"${logicItems[0].label || logicItems[0].type}"`,
632
657
  },
633
- });
658
+ }).catch(catchFn(vertexsMap.get(targetId) as Logic));
634
659
 
635
660
  LogicItem.redoPaste(res);
636
661
  }
@@ -778,21 +803,16 @@ export class LogicItem extends Vertex {
778
803
  delete body.index;
779
804
  ///
780
805
 
781
- try {
782
- await logicService.removeItem({
783
- headers: {
784
- appId: config.defaultApp?.id,
785
- serviceId: this.logic?.interface?.serviceId,
786
- operationAction: 'LogicItem.delete',
787
- operationDesc: `删除逻辑项"${this.label || this.type}"`,
788
-
789
- },
790
- body,
791
- });
792
- } catch (err) {
793
- await config.defaultApp?.history.load();
794
- throw err;
795
- }
806
+ await logicService.removeItem({
807
+ headers: {
808
+ appId: config.defaultApp?.id,
809
+ serviceId: this.logic?.interface?.serviceId,
810
+ operationAction: 'LogicItem.delete',
811
+ operationDesc: `删除逻辑项"${this.label || this.type}"`,
812
+
813
+ },
814
+ body,
815
+ }).catch(catchFn(this.logic));
796
816
  }
797
817
  }
798
818
 
@@ -883,7 +903,7 @@ export class LogicItem extends Vertex {
883
903
  operationIgnore: actionOptions?.actionIgnore,
884
904
  },
885
905
  body,
886
- });
906
+ }).catch(catchFn(this.logic));
887
907
  // this.deepPick(result, ['id', 'parentId', 'parentAttr']);
888
908
 
889
909
  // 合并params里的id
@@ -4,6 +4,29 @@ import { paramService } from '../../service/logic';
4
4
  import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
5
5
  import { getBasicTypeDefaultValue } from '../data/basicTypes';
6
6
  import { schemaService } from '../../service/common';
7
+ import { refreshLogic, refreshInterfaces, refreshView } from '../cache';
8
+ import { BusinessCode } from '../enum';
9
+
10
+ export function catchFn(logic: Logic) {
11
+ return async (err: any) => {
12
+ const code = err?.code;
13
+ // 节点已存在; 节点不存在
14
+ if ([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
15
+ await refreshLogic(logic);
16
+ } else if (code === BusinessCode.ParentElementNotExist) { // 父节点不存在,即逻辑不存在
17
+ if (logic.interface) {
18
+ await refreshInterfaces();
19
+ } else if (logic.view) {
20
+ await refreshView(logic.view);
21
+ }
22
+ } else
23
+ config.defaultApp?.emit('saved', err);
24
+
25
+ config.defaultApp?.history.load();
26
+
27
+ throw err;
28
+ };
29
+ }
7
30
 
8
31
  /**
9
32
  * 逻辑输入参数
@@ -60,7 +83,7 @@ export class Param extends BaseVariable {
60
83
  operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.logic.name}"输入参数"${this.name}"`,
61
84
  },
62
85
  body,
63
- });
86
+ }).catch(catchFn(this.logic));
64
87
  // convert2RefType(result.schema);
65
88
  this.deepPick(result, ['id']);
66
89
  this.assign({ code: this.genCode() });
@@ -75,6 +98,9 @@ export class Param extends BaseVariable {
75
98
 
76
99
  await config.defaultApp?.history.load();
77
100
  config.defaultApp?.emit('saved');
101
+
102
+ // 更新所有调用此Logic的LogicItem
103
+ await this.logic.callLogicUpdate();
78
104
  return this;
79
105
  }
80
106
  /**
@@ -85,22 +111,17 @@ export class Param extends BaseVariable {
85
111
  config.defaultApp?.emit('saving');
86
112
 
87
113
  if (this.id) {
88
- try {
89
- await paramService.delete({
90
- headers: {
91
- appId: config.defaultApp?.id,
92
- operationAction: actionOptions?.actionName || 'Param.create',
93
- operationDesc: actionOptions?.actionDesc || `删除逻辑"${this.logic.name}"输入参数"${this.name}"`,
94
- },
95
- query: {
96
- loValId: this.id,
97
- logicId: this.logic.id,
98
- },
99
- });
100
- } catch(err) {
101
- await config.defaultApp?.history.load();
102
- throw err;
103
- }
114
+ await paramService.delete({
115
+ headers: {
116
+ appId: config.defaultApp?.id,
117
+ operationAction: actionOptions?.actionName || 'Param.create',
118
+ operationDesc: actionOptions?.actionDesc || `删除逻辑"${this.logic.name}"输入参数"${this.name}"`,
119
+ },
120
+ query: {
121
+ loValId: this.id,
122
+ logicId: this.logic.id,
123
+ },
124
+ }).catch(catchFn(this.logic));
104
125
  }
105
126
 
106
127
  const index = this.logic.params.indexOf(this);
@@ -133,7 +154,7 @@ export class Param extends BaseVariable {
133
154
  operationDesc: actionOptions?.actionDesc || `修改逻辑输入参数"${this.name}"`,
134
155
  },
135
156
  body,
136
- });
157
+ }).catch(catchFn(this.logic));
137
158
  this.schema.id = result.schema.id;
138
159
  // convert2RefType(result.schema);
139
160
  // this.plainAssign(result);
@@ -4,7 +4,7 @@ import { paramService } from '../../service/logic';
4
4
  import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
5
5
  import { getBasicTypeDefaultValue } from '../data/basicTypes';
6
6
  import { schemaService } from '../../service/common';
7
-
7
+ import { catchFn } from './Param';
8
8
  /**
9
9
  * 逻辑输出参数
10
10
  */
@@ -50,7 +50,7 @@ export class Return extends BaseVariable {
50
50
  operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.logic.name}"输出参数"${this.name}"`,
51
51
  },
52
52
  body,
53
- });
53
+ }).catch(catchFn(this.logic));
54
54
  // convert2RefType(result.schema);
55
55
  this.deepPick(result, ['id']);
56
56
  this.assign({ code: this.genCode() });
@@ -75,7 +75,6 @@ export class Return extends BaseVariable {
75
75
  config.defaultApp?.emit('saving');
76
76
 
77
77
  if (this.id) {
78
- try {
79
78
  await paramService.delete({
80
79
  headers: {
81
80
  appId: config.defaultApp?.id,
@@ -86,11 +85,7 @@ export class Return extends BaseVariable {
86
85
  loValId: this.id,
87
86
  logicId: this.logic.id,
88
87
  },
89
- });
90
- } catch(err) {
91
- await config.defaultApp?.history.load();
92
- throw err;
93
- }
88
+ }).catch(catchFn(this.logic));
94
89
  }
95
90
 
96
91
  const index = this.logic.returns.indexOf(this);
@@ -123,7 +118,7 @@ export class Return extends BaseVariable {
123
118
  operationDesc: actionOptions?.actionDesc || `修改逻辑输出参数"${this.name}"`,
124
119
  },
125
120
  body,
126
- });
121
+ }).catch(catchFn(this.logic));
127
122
  this.schema.id = result.schema.id;
128
123
  // convert2RefType(result.schema);
129
124
  // this.plainAssign(result);
@@ -4,6 +4,7 @@ import { paramService } from '../../service/logic';
4
4
  import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
5
5
  import { getBasicTypeDefaultValue } from '../data/basicTypes';
6
6
  import { schemaService } from '../../service/common';
7
+ import { catchFn } from './Param';
7
8
 
8
9
  /**
9
10
  * 逻辑局部变量
@@ -49,7 +50,7 @@ export class Variable extends BaseVariable {
49
50
  operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.logic.name}"局部变量"${this.name}"`,
50
51
  },
51
52
  body,
52
- });
53
+ }).catch(catchFn(this.logic));
53
54
  // convert2RefType(result.schema);
54
55
  this.deepPick(result, ['id']);
55
56
  this.assign({ code: this.genCode() });
@@ -73,7 +74,6 @@ export class Variable extends BaseVariable {
73
74
  config.defaultApp?.emit('saving');
74
75
 
75
76
  if (this.id) {
76
- try {
77
77
  await paramService.delete({
78
78
  headers: {
79
79
  appId: config.defaultApp?.id,
@@ -84,11 +84,7 @@ export class Variable extends BaseVariable {
84
84
  loValId: this.id,
85
85
  logicId: this.logic.id,
86
86
  },
87
- });
88
- } catch(err) {
89
- await config.defaultApp?.history.load();
90
- throw err;
91
- }
87
+ }).catch(catchFn(this.logic));
92
88
  }
93
89
 
94
90
  const index = this.logic.variables.indexOf(this);
@@ -120,7 +116,7 @@ export class Variable extends BaseVariable {
120
116
  operationDesc: actionOptions?.actionDesc || `修改逻辑局部变量"${this.name}"`,
121
117
  },
122
118
  body,
123
- });
119
+ }).catch(catchFn(this.logic));
124
120
  this.schema.id = result.schema.id;
125
121
  // convert2RefType(result.schema);
126
122
  // this.plainAssign(result);
@@ -1,4 +1,3 @@
1
- import generate from '@babel/generator';
2
1
  import { Vertex } from '..';
3
2
 
4
3
  function switchCase2If(cases) {
@@ -9,7 +8,13 @@ function switchCase2If(cases) {
9
8
  test: cas.test,
10
9
  consequent: {
11
10
  type: 'BlockStatement',
12
- body: cas.consequent || [],
11
+ body: [
12
+ {
13
+ type: 'CallConsoleInfo',
14
+ content: 'SWITCHCASE',
15
+ },
16
+ ...cas.consequent || [],
17
+ ]
13
18
  },
14
19
  alternate: null,
15
20
  };
@@ -19,7 +24,13 @@ function switchCase2If(cases) {
19
24
  } else {
20
25
  return {
21
26
  type: 'BlockStatement',
22
- body: cas.consequent || [],
27
+ body: [
28
+ {
29
+ type: 'CallConsoleInfo',
30
+ content: 'SWITCHDEFAULT',
31
+ },
32
+ ...cas.consequent || [],
33
+ ]
23
34
  };
24
35
  }
25
36
 
@@ -27,6 +38,7 @@ function switchCase2If(cases) {
27
38
  }
28
39
 
29
40
  export default function (source) {
41
+ const isGONGHANG = window.appInfo.env === 'gonghang' || global.appInfoEnv === 'gonghang';
30
42
  const definition = typeof source === 'string' ? JSON.parse(source) : source;
31
43
 
32
44
  function traverse(node, func, parent, index) {
@@ -459,6 +471,14 @@ export default function (source) {
459
471
  return `${newLine()}console.log(${generateNode(node.arguments[0])})${colon()}${newLine()}`;
460
472
  }
461
473
 
474
+ if(node.type === 'CallConsoleInfo') {
475
+ if(isGONGHANG) {
476
+ return `console.info(${node.content})${colon()}`;
477
+ }
478
+ return '';
479
+
480
+ }
481
+
462
482
  if (node.type === 'Destination') {
463
483
  const params = (node.params || [])
464
484
  .filter((param) => param.pageParamKey && param.pageParamKeyValue)
@@ -479,16 +499,27 @@ export default function (source) {
479
499
  if (Array.isArray(node.consequent)) {
480
500
  node.consequent = {
481
501
  type: 'BlockStatement',
482
- body: node.consequent,
502
+ body: [
503
+ {
504
+ type: 'CallConsoleInfo',
505
+ content: 'IF',
506
+ },
507
+ ...node.consequent,
508
+ ]
483
509
  };
484
510
  }
485
- if (Array.isArray(node.alternate)) {
511
+ if (Array.isArray(node.alternate) && node.alternate.length > 0) {
486
512
  node.alternate = {
487
513
  type: 'BlockStatement',
488
- body: node.alternate,
514
+ body: [
515
+ {
516
+ type: 'CallConsoleInfo',
517
+ content: 'ELSE',
518
+ },
519
+ ...node.alternate,
520
+ ]
489
521
  };
490
522
  }
491
-
492
523
  let alternateScript = '';
493
524
  if (node.alternate) {
494
525
  alternateScript = generateNode(node.alternate);
@@ -597,13 +628,10 @@ export default function (source) {
597
628
  script += `${generateNode(node, index)}${newLine()}`;
598
629
  });
599
630
 
600
- // console.info("JSON generate:", JSON.stringify(logic.body));
601
- // console.log(generate({ type: 'Program', body: logic.body }).code);
602
-
603
631
  return `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
604
- ${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});`).join('\n') + '' : ''}
605
- ${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`).join('\n') + '' : ''}
606
- let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});
632
+ ${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});` + (isGONGHANG ? `console.info(${param.name})` : '')).join('\n') + '' : ''}
633
+ ${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});` + (isGONGHANG ? `console.info(${variable.name})` : '')).join('\n') + '' : ''}
634
+ let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});` + (isGONGHANG ? `console.info(${returnObj.name})` : '') + `
607
635
  ${script}
608
636
  }`;
609
637
  });
@@ -1,8 +1,6 @@
1
1
  import generate from '@babel/generator';
2
2
  import * as babel from '@babel/core';
3
- import { TransforClientQuery as genQuery } from 'apollo-plugin-loader';
4
- import { Vertex, vertexesMap, utils } from '..';
5
- import { getQuerySchemaMap } from './tools';
3
+ import { Vertex, utils } from '..';
6
4
 
7
5
  function switchCase2If(cases) {
8
6
  const cas = cases.shift();
@@ -81,9 +79,7 @@ export default function (source) {
81
79
  } else if (node.type === 'MemberExpression') {
82
80
  return checkThis(node.object);
83
81
  } else if (node.type === 'CallExpression') {
84
- (node.arguments || []).forEach((arg) => {
85
- return checkThis(arg);
86
- });
82
+ (node.arguments || []).forEach((arg) => checkThis(arg));
87
83
  }
88
84
  }
89
85
  function safeGenerate(node) {
@@ -586,7 +582,7 @@ export default function (source) {
586
582
  const jsBlock_${index} = async () => {
587
583
  ${node.code}
588
584
  }
589
-
585
+
590
586
  await jsBlock_${index}();
591
587
  }`,
592
588
  {
@@ -600,16 +596,9 @@ export default function (source) {
600
596
  }
601
597
  });
602
598
 
603
- // console.info("JSON generate:", JSON.stringify(logic.body));
604
- // console.log(generate({ type: 'Program', body: logic.body }).code);
605
-
606
599
  return `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
607
- ${logic.params.length ? logic.params.map((param) => {
608
- return `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});`;
609
- }).join('\n') + '' : ''}
610
- ${logic.variables.length ? logic.variables.map((variable) => {
611
- return `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`;
612
- }).join('\n') + '' : ''}
600
+ ${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});`).join('\n') + '' : ''}
601
+ ${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`).join('\n') + '' : ''}
613
602
  let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});
614
603
  ${generate({ type: 'Program', body: logic.body }).code}
615
604
  }`;
@@ -17,7 +17,7 @@ interface RoleItem extends Role {
17
17
  toggling?: Boolean,
18
18
  }
19
19
 
20
- interface Permission{
20
+ interface Permission {
21
21
  DomainName: string,
22
22
  PermissionId: string,
23
23
  PermissionValue: string,
@@ -79,7 +79,7 @@ export class Nuims {
79
79
  }
80
80
  }
81
81
 
82
- async getInitRoles() {
82
+ async getInitRoles(auto: unknown) {
83
83
  let isCreated = false;
84
84
  let resource = await this.getResource();
85
85
  if (!resource) {
@@ -99,9 +99,15 @@ export class Nuims {
99
99
  await this.bindRolesAndPermissions(role, permission);
100
100
  }
101
101
  roleName2Permission.set(role.RoleName, permission);
102
- // 创建 /dashboard 资源时自动关联 DEV-AdminRole 权限
103
- if (isCreated && (ResourceValue === '/dashboard' || ((ResourceValue === '/index' || ResourceValue === '/user') && config.scope === 'h5')) && role.RoleName === 'DEV-AdminRole') {
104
- await this.attachPermissionResourceAction();
102
+ if (auto) {
103
+ if ((ResourceValue === '/dashboard' || ((ResourceValue === '/index' || ResourceValue === '/user') && config.scope === 'h5')) && role.RoleName === 'DEV-AdminRole') {
104
+ await this.attachPermissionResourceAction();
105
+ }
106
+ } else {
107
+ // 创建 /dashboard 资源时自动关联 DEV-AdminRole 权限
108
+ if (isCreated && (ResourceValue === '/dashboard' || ((ResourceValue === '/index' || ResourceValue === '/user') && config.scope === 'h5')) && role.RoleName === 'DEV-AdminRole') {
109
+ await this.attachPermissionResourceAction();
110
+ }
105
111
  }
106
112
  roleItem.permission = permission;
107
113
  const resources = await this.getResourcesFromPermission(permission);