@lcap/nasl 0.3.9 → 0.3.10-beta.nocache1

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 (147) 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 +27 -0
  4. package/out/service/logic/logic.js +20 -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/common/Vertex.d.ts +25 -0
  27. package/out/types/common/Vertex.js +40 -0
  28. package/out/types/common/Vertex.js.map +1 -1
  29. package/out/types/data/Entity.js +1 -0
  30. package/out/types/data/Entity.js.map +1 -1
  31. package/out/types/data/Enum.d.ts +5 -0
  32. package/out/types/data/Enum.js +5 -0
  33. package/out/types/data/Enum.js.map +1 -1
  34. package/out/types/data/Interface.js +5 -3
  35. package/out/types/data/Interface.js.map +1 -1
  36. package/out/types/data/dataTypes.js +1 -1
  37. package/out/types/data/dataTypes.js.map +1 -1
  38. package/out/types/data/genBlock/genCreateBlock.js +5 -5
  39. package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
  40. package/out/types/data/genBlock/genCurdBlock.js +3 -3
  41. package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
  42. package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
  43. package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
  44. package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
  45. package/out/types/data/genBlock/genGridViewBlock.js +12 -1
  46. package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
  47. package/out/types/data/genBlock/genListViewBlock.js +2 -2
  48. package/out/types/data/genBlock/genSelectBlock.js +2 -2
  49. package/out/types/data/genBlock/genTableBlock.js +14 -3
  50. package/out/types/data/genBlock/genTableBlock.js.map +1 -1
  51. package/out/types/data/genBlock/genUpdateBlock.js +5 -5
  52. package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
  53. package/out/types/data/systemTypes.js +47 -0
  54. package/out/types/data/systemTypes.js.map +1 -1
  55. package/out/types/enum.d.ts +6 -0
  56. package/out/types/enum.js +11 -0
  57. package/out/types/enum.js.map +1 -0
  58. package/out/types/generator/hotReload.d.ts +2 -0
  59. package/out/types/generator/hotReload.js +12 -1
  60. package/out/types/generator/hotReload.js.map +1 -1
  61. package/out/types/index.d.ts +5 -1
  62. package/out/types/index.js +8 -2
  63. package/out/types/index.js.map +1 -1
  64. package/out/types/logic/Logic.d.ts +28 -0
  65. package/out/types/logic/Logic.js +116 -31
  66. package/out/types/logic/Logic.js.map +1 -1
  67. package/out/types/logic/LogicItem.d.ts +1 -0
  68. package/out/types/logic/LogicItem.js +43 -24
  69. package/out/types/logic/LogicItem.js.map +1 -1
  70. package/out/types/logic/Param.d.ts +1 -0
  71. package/out/types/logic/Param.js +38 -20
  72. package/out/types/logic/Param.js.map +1 -1
  73. package/out/types/logic/Return.js +14 -19
  74. package/out/types/logic/Return.js.map +1 -1
  75. package/out/types/logic/Variable.js +14 -19
  76. package/out/types/logic/Variable.js.map +1 -1
  77. package/out/types/logic/translator.js +0 -2
  78. package/out/types/logic/translator.js.map +1 -1
  79. package/out/types/nuims/Nuims.d.ts +1 -1
  80. package/out/types/nuims/Nuims.js +11 -4
  81. package/out/types/nuims/Nuims.js.map +1 -1
  82. package/out/types/page/Element.d.ts +5 -0
  83. package/out/types/page/Element.js +115 -132
  84. package/out/types/page/Element.js.map +1 -1
  85. package/out/types/page/Event.js.map +1 -1
  86. package/out/types/page/Page.d.ts +1 -0
  87. package/out/types/page/Page.js +59 -27
  88. package/out/types/page/Page.js.map +1 -1
  89. package/out/types/page/View.d.ts +1 -1
  90. package/out/types/page/View.js +38 -33
  91. package/out/types/page/View.js.map +1 -1
  92. package/out/types/page/ViewParam.d.ts +1 -0
  93. package/out/types/page/ViewParam.js +23 -4
  94. package/out/types/page/ViewParam.js.map +1 -1
  95. package/out/types/page/ViewVariable.js +13 -18
  96. package/out/types/page/ViewVariable.js.map +1 -1
  97. package/out/types/permission/Permission.d.ts +41 -0
  98. package/out/types/permission/Permission.js +122 -0
  99. package/out/types/permission/Permission.js.map +1 -0
  100. package/package.json +1 -2
  101. package/src/service/create/errHandles.js +6 -2
  102. package/src/service/developPermission/api.js +37 -0
  103. package/src/service/developPermission/index.js +13 -0
  104. package/src/service/logic/logic.js +20 -0
  105. package/src/service/page/element.js +6 -0
  106. package/src/service/permission/api.js +38 -0
  107. package/src/service/permission/index.js +13 -0
  108. package/src/service/webFile/index.js +6 -1
  109. package/src/types/app/App.ts +34 -1
  110. package/src/types/app/Service.ts +32 -3
  111. package/src/types/cache.ts +50 -0
  112. package/src/types/common/Vertex.ts +30 -0
  113. package/src/types/data/Entity.ts +1 -0
  114. package/src/types/data/Enum.ts +5 -0
  115. package/src/types/data/Interface.ts +4 -3
  116. package/src/types/data/dataTypes.ts +1 -1
  117. package/src/types/data/genBlock/genCreateBlock.ts +5 -5
  118. package/src/types/data/genBlock/genCurdBlock.ts +3 -3
  119. package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
  120. package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
  121. package/src/types/data/genBlock/genListViewBlock.ts +2 -2
  122. package/src/types/data/genBlock/genSelectBlock.ts +2 -2
  123. package/src/types/data/genBlock/genTableBlock.ts +14 -3
  124. package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
  125. package/src/types/data/systemTypes.ts +47 -0
  126. package/src/types/enum.ts +6 -0
  127. package/src/types/generator/hotReload.ts +10 -0
  128. package/src/types/index.ts +5 -1
  129. package/src/types/logic/Logic.ts +109 -28
  130. package/src/types/logic/LogicItem.ts +48 -28
  131. package/src/types/logic/Param.ts +26 -8
  132. package/src/types/logic/Return.ts +4 -9
  133. package/src/types/logic/Variable.ts +4 -8
  134. package/src/types/logic/translator.js +0 -4
  135. package/src/types/logic/translator_backup.js +5 -16
  136. package/src/types/nuims/Nuims.ts +11 -5
  137. package/src/types/page/Element.ts +64 -77
  138. package/src/types/page/Event.ts +0 -3
  139. package/src/types/page/Page.ts +73 -40
  140. package/src/types/page/View.ts +18 -12
  141. package/src/types/page/ViewParam.ts +22 -3
  142. package/src/types/page/ViewVariable.ts +4 -8
  143. package/src/types/page/dist/View.js +727 -0
  144. package/src/types/permission/Permission.ts +112 -0
  145. package/out/test/units/config.spec.d.ts +0 -1
  146. package/out/test/units/config.spec.js +0 -12
  147. package/out/test/units/config.spec.js.map +0 -1
@@ -16,6 +16,7 @@ import * as babel from '@babel/core';
16
16
  import view from '@/service/page/view';
17
17
  import Entity from '../data/Entity';
18
18
  import { postServiceType } from '../../service/common/preprocess';
19
+ import { catchFn } from './Page';
19
20
 
20
21
  /**
21
22
  * 子页面类,前端路由控制
@@ -199,26 +200,36 @@ export class View extends Block {
199
200
  } catch (err) { }
200
201
  })().finally(() => this.contentPromise = undefined);
201
202
  }
202
- loadAll() {
203
+ loadAll(enableCache = false) {
203
204
  // 如果有正在进行的 Promise,则直接返回它
204
205
  if (this.contentPromise)
205
206
  return this.contentPromise;
206
207
 
207
208
  return this.contentPromise = (async () => {
208
- try {
209
209
  const result: View = await viewService.load({
210
210
  path: {
211
211
  id: this.id,
212
212
  },
213
+ query: {
214
+ enableCache,
215
+ },
216
+ config: { noErrorTip: true },
213
217
  });
214
-
218
+ const oldLogics = this.$def.logics;
219
+ Object.assign(result, {
220
+ children: this.children,
221
+ })
215
222
  const temp = View.from(result, this.parent, this.page, this);
223
+ const newLogics = temp.$def.logics;
224
+ oldLogics.forEach((logic) => {
225
+ if(!newLogics.find((item) => item.id === logic.id))
226
+ logic.destroy();
227
+ });
216
228
  this.assign(temp);
217
229
  utils.traverse((current) => {
218
230
  current.node.attachNodePath(true);
219
231
  }, { node: this });
220
232
  return this;
221
- } catch (err) { }
222
233
  })().finally(() => this.contentPromise = undefined);
223
234
  }
224
235
  isContentLoaded() {
@@ -325,7 +336,7 @@ export class View extends Block {
325
336
  operationDesc: actionOptions?.actionDesc || `添加子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
326
337
  },
327
338
  body,
328
- });
339
+ }).catch(catchFn());
329
340
  this.deepPick(result.view, ['id']);
330
341
  // 添加数据
331
342
  this.addData(result);
@@ -406,7 +417,6 @@ export class View extends Block {
406
417
  if (!this.parent)
407
418
  throw Error('该子页面为根节点!');
408
419
 
409
- try {
410
420
  await viewService.delete({
411
421
  headers: {
412
422
  appId: config.defaultApp?.id,
@@ -416,11 +426,7 @@ export class View extends Block {
416
426
  path: {
417
427
  id: this.id,
418
428
  },
419
- });
420
- } catch (err) {
421
- await config.defaultApp?.history.load();
422
- throw err;
423
- }
429
+ }).catch(catchFn());
424
430
 
425
431
  const index = this.parent.children.indexOf(this);
426
432
  ~index && this.parent.children.splice(index, 1);
@@ -452,7 +458,7 @@ export class View extends Block {
452
458
  operationDesc: actionOptions?.actionDesc || `修改子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
453
459
  },
454
460
  body,
455
- });
461
+ }).catch(catchFn());
456
462
 
457
463
  await then?.();
458
464
  await config.defaultApp?.history.load();
@@ -5,6 +5,25 @@ import { getBasicTypeDefaultValue } from '../data/basicTypes';
5
5
  import { viewService } from '../../service/page';
6
6
  import { View } from './View';
7
7
  import { schemaService } from '../../service/common';
8
+ import { refreshPages, refreshView } from '../cache';
9
+ import { BusinessCode } from '../enum';
10
+
11
+ export function catchFn(view: View) {
12
+ return async (err: any) => {
13
+ const code = err?.code;
14
+ // 节点已存在; 节点不存在
15
+ if([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
16
+ await refreshView(view);
17
+ } else if(code === BusinessCode.ParentElementNotExist) { // 父节点不存在。视图添加变量,发现视图不存在
18
+ await refreshPages();
19
+ } else
20
+ config.defaultApp?.emit('saved', err);
21
+
22
+ config.defaultApp?.history.load();
23
+
24
+ throw err;
25
+ }
26
+ }
8
27
 
9
28
  /**
10
29
  * 页面输入参数
@@ -56,7 +75,7 @@ export class ViewParam extends Param {
56
75
  operationDesc: actionOptions?.actionDesc || `添加页面"${this.view.name}"输入参数"${this.name}"`,
57
76
  },
58
77
  body,
59
- });
78
+ }).catch(catchFn(this.view));
60
79
  // convert2RefType(result.schema);
61
80
  this.deepPick(result, ['id']);
62
81
  this.assign({ code: this.genCode() });
@@ -88,7 +107,7 @@ export class ViewParam extends Param {
88
107
  query: {
89
108
  id: this.id,
90
109
  },
91
- });
110
+ }).catch(catchFn(this.view));
92
111
  } catch(err) {
93
112
  await config.defaultApp?.history.load();
94
113
  throw err;
@@ -129,7 +148,7 @@ export class ViewParam extends Param {
129
148
  operationDesc: actionOptions?.actionDesc || `修改页面"${this.view.name}"输入参数"${this.name}"`,
130
149
  },
131
150
  body,
132
- });
151
+ }).catch(catchFn(this.view));
133
152
  // convert2RefType(result.schema);
134
153
  // this.plainAssign(result);
135
154
 
@@ -5,6 +5,7 @@ import { viewService } from '../../service/page';
5
5
  import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
6
6
  import { getBasicTypeDefaultValue } from '../data/basicTypes';
7
7
  import { schemaService } from '../../service/common';
8
+ import { catchFn } from './ViewParam';
8
9
 
9
10
  /**
10
11
  * 页面局部变量
@@ -51,7 +52,7 @@ export class ViewVariable extends Variable {
51
52
  operationDesc: actionOptions?.actionDesc || `添加页面"${this.view.name}"局部变量"${this.name}"`,
52
53
  },
53
54
  body,
54
- });
55
+ }).catch(catchFn(this.view));
55
56
  // convert2RefType(result.schema);
56
57
  this.deepPick(result, ['id']);
57
58
  this.assign({ code: this.genCode() });
@@ -73,7 +74,6 @@ export class ViewVariable extends Variable {
73
74
  config.defaultApp?.emit('saving');
74
75
 
75
76
  if (this.id) {
76
- try {
77
77
  await viewService.deleteViewVariable({
78
78
  headers: {
79
79
  appId: config.defaultApp?.id,
@@ -83,11 +83,7 @@ export class ViewVariable extends Variable {
83
83
  query: {
84
84
  id: this.id,
85
85
  },
86
- });
87
- } catch (err) {
88
- await config.defaultApp?.history.load();
89
- throw err;
90
- }
86
+ }).catch(catchFn(this.view));
91
87
  }
92
88
 
93
89
  const { variables } = this.view.$def;
@@ -122,7 +118,7 @@ export class ViewVariable extends Variable {
122
118
  operationDesc: actionOptions?.actionDesc || `修改页面"${this.view.name}"局部变量"${this.name}"`,
123
119
  },
124
120
  body,
125
- });
121
+ }).catch(catchFn(this.view));
126
122
  // convert2RefType(result.schema);
127
123
  // this.plainAssign(result);
128
124