@lcap/nasl 0.3.10 → 0.3.11

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 (194) hide show
  1. package/out/service/app/api.d.ts +1 -15
  2. package/out/service/app/api.js +7 -17
  3. package/out/service/app/api.js.map +1 -1
  4. package/out/service/create/errHandles.js +19 -2
  5. package/out/service/create/errHandles.js.map +1 -1
  6. package/out/service/create/index.js +5 -0
  7. package/out/service/create/index.js.map +1 -1
  8. package/out/service/logic/logic.d.ts +50 -14
  9. package/out/service/logic/logic.js +26 -0
  10. package/out/service/logic/logic.js.map +1 -1
  11. package/out/service/page/element.d.ts +9 -0
  12. package/out/service/page/element.js +6 -0
  13. package/out/service/page/element.js.map +1 -1
  14. package/out/service/permission/api.d.ts +57 -0
  15. package/out/service/permission/api.js +41 -0
  16. package/out/service/permission/api.js.map +1 -0
  17. package/out/service/permission/index.d.ts +2 -0
  18. package/out/service/permission/index.js +17 -0
  19. package/out/service/permission/index.js.map +1 -0
  20. package/out/service/webFile/index.js +5 -0
  21. package/out/service/webFile/index.js.map +1 -1
  22. package/out/types/app/App.d.ts +13 -0
  23. package/out/types/app/App.js +55 -1
  24. package/out/types/app/App.js.map +1 -1
  25. package/out/types/app/History.js +3 -2
  26. package/out/types/app/History.js.map +1 -1
  27. package/out/types/app/Service.d.ts +5 -2
  28. package/out/types/app/Service.js +42 -9
  29. package/out/types/app/Service.js.map +1 -1
  30. package/out/types/cache.d.ts +6 -0
  31. package/out/types/cache.js +54 -0
  32. package/out/types/cache.js.map +1 -0
  33. package/out/types/cacheData.js.map +1 -1
  34. package/out/types/common/Vertex.d.ts +25 -0
  35. package/out/types/common/Vertex.js +42 -1
  36. package/out/types/common/Vertex.js.map +1 -1
  37. package/out/types/data/Entity.d.ts +4 -0
  38. package/out/types/data/Entity.js +9 -0
  39. package/out/types/data/Entity.js.map +1 -1
  40. package/out/types/data/EntityProperty.d.ts +5 -0
  41. package/out/types/data/EntityProperty.js +16 -0
  42. package/out/types/data/EntityProperty.js.map +1 -1
  43. package/out/types/data/Enum.d.ts +5 -0
  44. package/out/types/data/Enum.js +5 -0
  45. package/out/types/data/Enum.js.map +1 -1
  46. package/out/types/data/GlobalLogicNode.js +8 -1
  47. package/out/types/data/GlobalLogicNode.js.map +1 -1
  48. package/out/types/data/Interface.js +5 -3
  49. package/out/types/data/Interface.js.map +1 -1
  50. package/out/types/data/dataTypes.js +1 -1
  51. package/out/types/data/dataTypes.js.map +1 -1
  52. package/out/types/data/genBlock/genCreateBlock.js +5 -5
  53. package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
  54. package/out/types/data/genBlock/genCurdBlock.js +3 -3
  55. package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
  56. package/out/types/data/genBlock/genCurdEditTableBlock.d.ts +3 -0
  57. package/out/types/data/genBlock/genCurdEditTableBlock.js +578 -0
  58. package/out/types/data/genBlock/genCurdEditTableBlock.js.map +1 -0
  59. package/out/types/data/genBlock/genEditTableBlock.d.ts +234 -0
  60. package/out/types/data/genBlock/genEditTableBlock.js +419 -0
  61. package/out/types/data/genBlock/genEditTableBlock.js.map +1 -0
  62. package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
  63. package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
  64. package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
  65. package/out/types/data/genBlock/genGridViewBlock.js +12 -1
  66. package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
  67. package/out/types/data/genBlock/genListViewBlock.js +2 -2
  68. package/out/types/data/genBlock/genQueryComponent.d.ts +20 -0
  69. package/out/types/data/genBlock/genQueryComponent.js +57 -1
  70. package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
  71. package/out/types/data/genBlock/genSelectBlock.js +2 -2
  72. package/out/types/data/genBlock/genTableBlock.js +23 -8
  73. package/out/types/data/genBlock/genTableBlock.js.map +1 -1
  74. package/out/types/data/genBlock/genUpdateBlock.js +5 -5
  75. package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
  76. package/out/types/data/genBlock/index.d.ts +2 -0
  77. package/out/types/data/genBlock/index.js +2 -0
  78. package/out/types/data/genBlock/index.js.map +1 -1
  79. package/out/types/data/genBlock/utils.d.ts +7 -0
  80. package/out/types/data/genBlock/utils.js +38 -1
  81. package/out/types/data/genBlock/utils.js.map +1 -1
  82. package/out/types/data/systemTypes.js +47 -0
  83. package/out/types/data/systemTypes.js.map +1 -1
  84. package/out/types/enum.d.ts +6 -0
  85. package/out/types/enum.js +11 -0
  86. package/out/types/enum.js.map +1 -0
  87. package/out/types/generator/hotReload.d.ts +2 -0
  88. package/out/types/generator/hotReload.js +12 -1
  89. package/out/types/generator/hotReload.js.map +1 -1
  90. package/out/types/index.d.ts +5 -1
  91. package/out/types/index.js +8 -2
  92. package/out/types/index.js.map +1 -1
  93. package/out/types/logic/Logic.d.ts +32 -0
  94. package/out/types/logic/Logic.js +151 -41
  95. package/out/types/logic/Logic.js.map +1 -1
  96. package/out/types/logic/LogicItem.d.ts +1 -0
  97. package/out/types/logic/LogicItem.js +49 -32
  98. package/out/types/logic/LogicItem.js.map +1 -1
  99. package/out/types/logic/Param.d.ts +1 -0
  100. package/out/types/logic/Param.js +43 -33
  101. package/out/types/logic/Param.js.map +1 -1
  102. package/out/types/logic/Return.js +17 -30
  103. package/out/types/logic/Return.js.map +1 -1
  104. package/out/types/logic/Variable.js +17 -25
  105. package/out/types/logic/Variable.js.map +1 -1
  106. package/out/types/logic/translator.js +39 -10
  107. package/out/types/logic/translator.js.map +1 -1
  108. package/out/types/nuims/Nuims.d.ts +1 -1
  109. package/out/types/nuims/Nuims.js +11 -4
  110. package/out/types/nuims/Nuims.js.map +1 -1
  111. package/out/types/page/Element.d.ts +24 -0
  112. package/out/types/page/Element.js +198 -134
  113. package/out/types/page/Element.js.map +1 -1
  114. package/out/types/page/Event.js.map +1 -1
  115. package/out/types/page/Page.d.ts +5 -0
  116. package/out/types/page/Page.js +66 -27
  117. package/out/types/page/Page.js.map +1 -1
  118. package/out/types/page/View.d.ts +19 -1
  119. package/out/types/page/View.js +150 -40
  120. package/out/types/page/View.js.map +1 -1
  121. package/out/types/page/ViewParam.d.ts +1 -0
  122. package/out/types/page/ViewParam.js +23 -4
  123. package/out/types/page/ViewParam.js.map +1 -1
  124. package/out/types/page/ViewVariable.js +13 -24
  125. package/out/types/page/ViewVariable.js.map +1 -1
  126. package/out/types/permission/Permission.d.ts +41 -0
  127. package/out/types/permission/Permission.js +122 -0
  128. package/out/types/permission/Permission.js.map +1 -0
  129. package/out/types/process/ProcessParam.js +3 -1
  130. package/out/types/process/ProcessParam.js.map +1 -1
  131. package/out/types/utils/index.d.ts +1 -0
  132. package/out/types/utils/index.js +16 -7
  133. package/out/types/utils/index.js.map +1 -1
  134. package/package.json +1 -2
  135. package/src/service/app/api.js +8 -17
  136. package/src/service/create/errHandles.js +18 -2
  137. package/src/service/create/index.js +6 -0
  138. package/src/service/developPermission/api.js +37 -0
  139. package/src/service/developPermission/index.js +13 -0
  140. package/src/service/logic/logic.js +26 -0
  141. package/src/service/page/element.js +6 -0
  142. package/src/service/permission/api.js +38 -0
  143. package/src/service/permission/index.js +13 -0
  144. package/src/service/webFile/index.js +6 -1
  145. package/src/types/app/App.ts +58 -2
  146. package/src/types/app/History.ts +3 -2
  147. package/src/types/app/Service.ts +48 -10
  148. package/src/types/cache.ts +50 -0
  149. package/src/types/cacheData.ts +7 -7
  150. package/src/types/common/Vertex.ts +32 -1
  151. package/src/types/data/Entity.ts +8 -0
  152. package/src/types/data/EntityProperty.ts +12 -0
  153. package/src/types/data/Enum.ts +5 -0
  154. package/src/types/data/GlobalLogicNode.ts +8 -1
  155. package/src/types/data/Interface.ts +4 -3
  156. package/src/types/data/dataTypes.ts +1 -1
  157. package/src/types/data/genBlock/genCreateBlock.ts +5 -5
  158. package/src/types/data/genBlock/genCurdBlock.ts +3 -3
  159. package/src/types/data/genBlock/genCurdEditTableBlock.ts +581 -0
  160. package/src/types/data/genBlock/genEditTableBlock.ts +470 -0
  161. package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
  162. package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
  163. package/src/types/data/genBlock/genListViewBlock.ts +2 -2
  164. package/src/types/data/genBlock/genQueryComponent.ts +56 -0
  165. package/src/types/data/genBlock/genSelectBlock.ts +2 -2
  166. package/src/types/data/genBlock/genTableBlock.ts +28 -13
  167. package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
  168. package/src/types/data/genBlock/index.ts +2 -0
  169. package/src/types/data/genBlock/utils.ts +38 -0
  170. package/src/types/data/systemTypes.ts +47 -0
  171. package/src/types/enum.ts +6 -0
  172. package/src/types/generator/hotReload.ts +10 -0
  173. package/src/types/index.ts +5 -1
  174. package/src/types/logic/Logic.ts +148 -39
  175. package/src/types/logic/LogicItem.ts +55 -38
  176. package/src/types/logic/Param.ts +43 -35
  177. package/src/types/logic/Return.ts +21 -34
  178. package/src/types/logic/Variable.ts +21 -27
  179. package/src/types/logic/translator.js +41 -14
  180. package/src/types/logic/translator_backup.js +5 -16
  181. package/src/types/nuims/Nuims.ts +11 -5
  182. package/src/types/page/Element.ts +212 -138
  183. package/src/types/page/Event.ts +0 -3
  184. package/src/types/page/Page.ts +80 -40
  185. package/src/types/page/View.ts +154 -39
  186. package/src/types/page/ViewParam.ts +22 -3
  187. package/src/types/page/ViewVariable.ts +16 -26
  188. package/src/types/page/dist/View.js +727 -0
  189. package/src/types/permission/Permission.ts +112 -0
  190. package/src/types/process/ProcessParam.ts +4 -1
  191. package/src/types/utils/index.ts +16 -7
  192. package/out/test/units/config.spec.d.ts +0 -1
  193. package/out/test/units/config.spec.js +0 -12
  194. package/out/test/units/config.spec.js.map +0 -1
@@ -1,5 +1,4 @@
1
- import generate from '@babel/generator';
2
- import { Vertex } from '..';
1
+ import { Vertex, utils } from '..';
3
2
 
4
3
  function switchCase2If(cases) {
5
4
  const cas = cases.shift();
@@ -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 = utils.getGlobalEnv() === '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,13 @@ 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
+
462
481
  if (node.type === 'Destination') {
463
482
  const params = (node.params || [])
464
483
  .filter((param) => param.pageParamKey && param.pageParamKeyValue)
@@ -479,16 +498,27 @@ export default function (source) {
479
498
  if (Array.isArray(node.consequent)) {
480
499
  node.consequent = {
481
500
  type: 'BlockStatement',
482
- body: node.consequent,
501
+ body: [
502
+ {
503
+ type: 'CallConsoleInfo',
504
+ content: 'IF',
505
+ },
506
+ ...node.consequent,
507
+ ],
483
508
  };
484
509
  }
485
- if (Array.isArray(node.alternate)) {
510
+ if (Array.isArray(node.alternate) && node.alternate.length > 0) {
486
511
  node.alternate = {
487
512
  type: 'BlockStatement',
488
- body: node.alternate,
513
+ body: [
514
+ {
515
+ type: 'CallConsoleInfo',
516
+ content: 'ELSE',
517
+ },
518
+ ...node.alternate,
519
+ ],
489
520
  };
490
521
  }
491
-
492
522
  let alternateScript = '';
493
523
  if (node.alternate) {
494
524
  alternateScript = generateNode(node.alternate);
@@ -597,13 +627,10 @@ export default function (source) {
597
627
  script += `${generateNode(node, index)}${newLine()}`;
598
628
  });
599
629
 
600
- // console.info("JSON generate:", JSON.stringify(logic.body));
601
- // console.log(generate({ type: 'Program', body: logic.body }).code);
602
-
603
630
  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)});
631
+ ${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') + '' : ''}
632
+ ${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') + '' : ''}
633
+ let ${returnObj.name} = this.$genInitFromSchema(${JSON.stringify(returnObj.schema)}, ${JSON.stringify(returnObj.defaultValue)});` + (isGONGHANG ? `console.info(${returnObj.name})` : '') + `
607
634
  ${script}
608
635
  }`;
609
636
  });
@@ -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);