@lcap/nasl 2.18.0-beta.7 → 2.19.0-beta.1

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 (265) hide show
  1. package/out/automate/template/myProcess.js +1 -1
  2. package/out/automate/template/myProcess.js.map +1 -1
  3. package/out/bak/translator.js +2 -1
  4. package/out/bak/translator.js.map +1 -1
  5. package/out/common/Command.d.ts +1 -0
  6. package/out/common/Command.js +5 -1
  7. package/out/common/Command.js.map +1 -1
  8. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  9. package/out/concepts/AnonymousFunction__.js +40 -2
  10. package/out/concepts/AnonymousFunction__.js.map +1 -1
  11. package/out/concepts/App__.d.ts +10 -0
  12. package/out/concepts/App__.js +132 -0
  13. package/out/concepts/App__.js.map +1 -1
  14. package/out/concepts/Assignee__.js +4 -3
  15. package/out/concepts/Assignee__.js.map +1 -1
  16. package/out/concepts/BatchAssignment__.d.ts +2 -0
  17. package/out/concepts/BatchAssignment__.js +45 -1
  18. package/out/concepts/BatchAssignment__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.js +8 -1
  20. package/out/concepts/BindAttribute__.js.map +1 -1
  21. package/out/concepts/CallFunction__.js +51 -18
  22. package/out/concepts/CallFunction__.js.map +1 -1
  23. package/out/concepts/CallInterface__.js +6 -4
  24. package/out/concepts/CallInterface__.js.map +1 -1
  25. package/out/concepts/CallLogic__.js +87 -15
  26. package/out/concepts/CallLogic__.js.map +1 -1
  27. package/out/concepts/CallQueryComponent__.js +4 -1
  28. package/out/concepts/CallQueryComponent__.js.map +1 -1
  29. package/out/concepts/DataSource__.d.ts +2 -0
  30. package/out/concepts/DataSource__.js +55 -1
  31. package/out/concepts/DataSource__.js.map +1 -1
  32. package/out/concepts/ForEachStatement__.js +2 -0
  33. package/out/concepts/ForEachStatement__.js.map +1 -1
  34. package/out/concepts/Identifier__.d.ts +1 -0
  35. package/out/concepts/Identifier__.js +18 -7
  36. package/out/concepts/Identifier__.js.map +1 -1
  37. package/out/concepts/LogicItem__.d.ts +1 -1
  38. package/out/concepts/LogicItem__.js.map +1 -1
  39. package/out/concepts/Logic__.d.ts +1 -0
  40. package/out/concepts/Logic__.js +27 -14
  41. package/out/concepts/Logic__.js.map +1 -1
  42. package/out/concepts/Match__.js +13 -8
  43. package/out/concepts/Match__.js.map +1 -1
  44. package/out/concepts/NewComposite__.d.ts +345 -0
  45. package/out/concepts/NewComposite__.js +1067 -0
  46. package/out/concepts/NewComposite__.js.map +1 -0
  47. package/out/concepts/NewList__.d.ts +130 -0
  48. package/out/concepts/NewList__.js +353 -0
  49. package/out/concepts/NewList__.js.map +1 -0
  50. package/out/concepts/NewMap__.d.ts +221 -0
  51. package/out/concepts/NewMap__.js +492 -0
  52. package/out/concepts/NewMap__.js.map +1 -0
  53. package/out/concepts/New__.d.ts +19 -0
  54. package/out/concepts/New__.js +66 -0
  55. package/out/concepts/New__.js.map +1 -0
  56. package/out/concepts/Param__.d.ts +2 -0
  57. package/out/concepts/Param__.js +40 -3
  58. package/out/concepts/Param__.js.map +1 -1
  59. package/out/concepts/ProcessElement__.js +31 -10
  60. package/out/concepts/ProcessElement__.js.map +1 -1
  61. package/out/concepts/ProcessOutcome__.js +1 -1
  62. package/out/concepts/ProcessOutcome__.js.map +1 -1
  63. package/out/concepts/ProcessOutcomes__.d.ts +30 -0
  64. package/out/concepts/{ConstructArgument__.js → ProcessOutcomes__.js} +27 -48
  65. package/out/concepts/ProcessOutcomes__.js.map +1 -0
  66. package/out/concepts/Return__.js +2 -1
  67. package/out/concepts/Return__.js.map +1 -1
  68. package/out/concepts/SelectMembers__.js +3 -3
  69. package/out/concepts/SelectMembers__.js.map +1 -1
  70. package/out/concepts/StringInterpolation__.js +12 -2
  71. package/out/concepts/StringInterpolation__.js.map +1 -1
  72. package/out/concepts/TypeAnnotation__.d.ts +4 -0
  73. package/out/concepts/TypeAnnotation__.js +66 -12
  74. package/out/concepts/TypeAnnotation__.js.map +1 -1
  75. package/out/concepts/ValidationRule__.js +1 -1
  76. package/out/concepts/ValidationRule__.js.map +1 -1
  77. package/out/concepts/Variable__.js +2 -1
  78. package/out/concepts/Variable__.js.map +1 -1
  79. package/out/concepts/ViewElement__.js +12 -0
  80. package/out/concepts/ViewElement__.js.map +1 -1
  81. package/out/concepts/View__.d.ts +1 -0
  82. package/out/concepts/View__.js +9 -0
  83. package/out/concepts/View__.js.map +1 -1
  84. package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
  85. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  86. package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
  87. package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
  88. package/out/concepts/basics/stdlib/nasl.ui.js +2 -0
  89. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  90. package/out/concepts/basics/stdlib/nasl.util.js +151 -19
  91. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  92. package/out/concepts/index__.d.ts +5 -0
  93. package/out/concepts/index__.js +5 -0
  94. package/out/concepts/index__.js.map +1 -1
  95. package/out/enums/KEYWORDS.js +1 -0
  96. package/out/enums/KEYWORDS.js.map +1 -1
  97. package/out/generator/genMetaData.js +1 -6
  98. package/out/generator/genMetaData.js.map +1 -1
  99. package/out/generator/genReleaseBody.d.ts +2 -0
  100. package/out/generator/genReleaseBody.js +18 -1
  101. package/out/generator/genReleaseBody.js.map +1 -1
  102. package/out/generator/index.d.ts +1 -0
  103. package/out/generator/index.js +1 -0
  104. package/out/generator/index.js.map +1 -1
  105. package/out/generator/permission.d.ts +9 -0
  106. package/out/generator/permission.js +235 -0
  107. package/out/generator/permission.js.map +1 -0
  108. package/out/index.d.ts +1 -1
  109. package/out/index.js +2 -1
  110. package/out/index.js.map +1 -1
  111. package/out/server/entity2LogicNamespace.js +69 -9
  112. package/out/server/entity2LogicNamespace.js.map +1 -1
  113. package/out/server/extendBaseNode.js +7 -3
  114. package/out/server/extendBaseNode.js.map +1 -1
  115. package/out/server/formatTsUtils.js +6 -0
  116. package/out/server/formatTsUtils.js.map +1 -1
  117. package/out/server/getLogics.d.ts +2 -1
  118. package/out/server/getLogics.js +11 -0
  119. package/out/server/getLogics.js.map +1 -1
  120. package/out/server/getMemberIdentifier.js +1 -1
  121. package/out/server/getMemberIdentifier.js.map +1 -1
  122. package/out/server/naslServer.d.ts +1 -1
  123. package/out/server/naslServer.js +161 -22
  124. package/out/server/naslServer.js.map +1 -1
  125. package/out/server/process2LogicNamespace.js +8 -0
  126. package/out/server/process2LogicNamespace.js.map +1 -1
  127. package/out/server/translator.js +53 -8
  128. package/out/server/translator.js.map +1 -1
  129. package/out/service/creator/add.configs.js +4 -0
  130. package/out/service/creator/add.configs.js.map +1 -1
  131. package/out/service/datasource/api.d.ts +12 -0
  132. package/out/service/datasource/api.js +14 -0
  133. package/out/service/datasource/api.js.map +1 -0
  134. package/out/service/datasource/index.d.ts +2 -0
  135. package/out/service/datasource/index.js +10 -0
  136. package/out/service/datasource/index.js.map +1 -0
  137. package/out/service/storage/init.js +8 -1
  138. package/out/service/storage/init.js.map +1 -1
  139. package/out/templator/genEditTableBlock.js +4 -5
  140. package/out/templator/genEditTableBlock.js.map +1 -1
  141. package/out/templator/genGetBlock.js +4 -3
  142. package/out/templator/genGetBlock.js.map +1 -1
  143. package/out/templator/genGridViewBlock.js +16 -14
  144. package/out/templator/genGridViewBlock.js.map +1 -1
  145. package/out/templator/genListViewBlock.js +5 -5
  146. package/out/templator/genListViewBlock.js.map +1 -1
  147. package/out/templator/genTableBlock.js +6 -10
  148. package/out/templator/genTableBlock.js.map +1 -1
  149. package/package.json +1 -1
  150. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  151. package/sandbox/stdlib/nasl.auth.ts +1 -1
  152. package/sandbox/stdlib/nasl.core.ts +4 -0
  153. package/sandbox/stdlib/nasl.logging.ts +4 -4
  154. package/sandbox/stdlib/nasl.util.ts +13 -4
  155. package/src/automate/template/myProcess.js +1 -1
  156. package/src/bak/translator.js +4 -1
  157. package/src/common/Command.ts +4 -0
  158. package/src/concepts/AnonymousFunction__.ts +48 -2
  159. package/src/concepts/App__.ts +140 -41
  160. package/src/concepts/Assignee__.ts +4 -3
  161. package/src/concepts/BatchAssignment__.ts +45 -1
  162. package/src/concepts/BindAttribute__.ts +9 -2
  163. package/src/concepts/CallFunction__.ts +65 -31
  164. package/src/concepts/CallInterface__.ts +6 -22
  165. package/src/concepts/CallLogic__.ts +62 -13
  166. package/src/concepts/CallQueryComponent__.ts +4 -1
  167. package/src/concepts/DataSource__.ts +56 -1
  168. package/src/concepts/ForEachStatement__.ts +2 -0
  169. package/src/concepts/Identifier__.ts +18 -7
  170. package/src/concepts/LogicItem__.ts +1 -1
  171. package/src/concepts/Logic__.ts +48 -32
  172. package/src/concepts/Match__.ts +12 -8
  173. package/src/concepts/NewComposite__.ts +1356 -0
  174. package/src/concepts/NewList__.ts +444 -0
  175. package/src/concepts/NewMap__.ts +678 -0
  176. package/src/concepts/New__.ts +73 -0
  177. package/src/concepts/Param__.ts +238 -199
  178. package/src/concepts/ProcessElement__.ts +32 -10
  179. package/src/concepts/ProcessOutcome__.ts +1 -1
  180. package/src/concepts/ProcessOutcomes__.ts +90 -0
  181. package/src/concepts/Return__.ts +4 -1
  182. package/src/concepts/SelectMembers__.ts +3 -3
  183. package/src/concepts/StringInterpolation__.ts +21 -11
  184. package/src/concepts/TypeAnnotation__.ts +71 -50
  185. package/src/concepts/ValidationRule__.ts +19 -1
  186. package/src/concepts/Variable__.ts +4 -1
  187. package/src/concepts/ViewElement__.ts +38 -1
  188. package/src/concepts/View__.ts +12 -2
  189. package/src/concepts/basics/stdlib/dist/nasl.util.js +133 -34
  190. package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
  191. package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
  192. package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
  193. package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
  194. package/src/concepts/dist/BindAttribute__.js +760 -0
  195. package/src/concepts/dist/BindEvent__.js +732 -0
  196. package/src/concepts/dist/CallFunction__.js +21 -7
  197. package/src/concepts/dist/CallLogic__.js +50 -10
  198. package/src/concepts/dist/Identifier__.js +311 -0
  199. package/src/concepts/dist/StringInterpolation__.js +231 -0
  200. package/src/concepts/dist/TypeAnnotation__.js +834 -0
  201. package/src/concepts/dist/ViewElement__.js +12 -0
  202. package/src/concepts/dist/View__.js +1601 -0
  203. package/src/concepts/index__.ts +5 -0
  204. package/src/enums/KEYWORDS.ts +1 -0
  205. package/src/generator/dist/genMetaData.js +1 -5
  206. package/src/generator/dist/permission.js +392 -0
  207. package/src/generator/genMetaData.ts +1 -6
  208. package/src/generator/genReleaseBody.ts +21 -3
  209. package/src/generator/index.ts +1 -0
  210. package/src/generator/permission.ts +271 -0
  211. package/src/index.ts +1 -1
  212. package/src/server/dist/naslServer.js +385 -269
  213. package/src/server/entity2LogicNamespace.ts +70 -10
  214. package/src/server/extendBaseNode.ts +7 -3
  215. package/src/server/formatTsUtils.ts +6 -0
  216. package/src/server/getLogics.ts +13 -1
  217. package/src/server/getMemberIdentifier.ts +1 -1
  218. package/src/server/naslServer.ts +162 -29
  219. package/src/server/process2LogicNamespace.ts +8 -0
  220. package/src/server/translator.ts +52 -9
  221. package/src/service/creator/add.configs.js +4 -0
  222. package/src/service/dataSource/api.js +11 -0
  223. package/src/service/dataSource/index.js +6 -0
  224. package/src/service/storage/dist/init.js +8 -1
  225. package/src/service/storage/init.ts +9 -2
  226. package/src/service/video/VideoTranscribe.js +1 -0
  227. package/src/templator/dist/genEditTableBlock.js +204 -0
  228. package/src/templator/dist/genGridViewBlock.js +265 -0
  229. package/src/templator/dist/genListViewBlock.js +84 -0
  230. package/src/templator/dist/genTableBlock.js +209 -0
  231. package/src/templator/dist/utils.js +527 -0
  232. package/src/templator/genEditTableBlock.ts +8 -16
  233. package/src/templator/genGetBlock.ts +18 -19
  234. package/src/templator/genGridViewBlock.ts +18 -18
  235. package/src/templator/genListViewBlock.ts +8 -11
  236. package/src/templator/genTableBlock.ts +6 -10
  237. package/ts-worker/dist/webpack.config.dev.js +1 -3
  238. package/ts-worker/lib/tsserver.js +8 -1
  239. package/out/automate/engine/2.14-components.d.ts +0 -1115
  240. package/out/automate/engine/2.14-components.js +0 -1087
  241. package/out/automate/engine/2.14-components.js.map +0 -1
  242. package/out/concepts/ConstructArgument__.d.ts +0 -40
  243. package/out/concepts/ConstructArgument__.js.map +0 -1
  244. package/out/concepts/Construct__.d.ts +0 -189
  245. package/out/concepts/Construct__.js +0 -340
  246. package/out/concepts/Construct__.js.map +0 -1
  247. package/out/concepts/MatchExpression__.d.ts +0 -97
  248. package/out/concepts/MatchExpression__.js +0 -281
  249. package/out/concepts/MatchExpression__.js.map +0 -1
  250. package/out/templator/sql-parser/index.d.ts +0 -1
  251. package/out/templator/sql-parser/index.js +0 -228
  252. package/out/templator/sql-parser/index.js.map +0 -1
  253. package/out/templator/sql-parser/parser.js +0 -26664
  254. package/out/templator/sql-parser/parser.js.map +0 -1
  255. package/src/concepts/dist/Anchor__.js +0 -179
  256. package/src/concepts/dist/Assignment__.js +0 -301
  257. package/src/concepts/dist/CallInterface__.js +0 -533
  258. package/src/concepts/dist/ForEachStatement__.js +0 -426
  259. package/src/concepts/dist/MatchCase__.js +0 -587
  260. package/src/concepts/dist/Match__.js +0 -631
  261. package/src/concepts/dist/MemberExpression__.js +0 -348
  262. package/src/concepts/dist/Param__.js +0 -538
  263. package/src/concepts/dist/Return__.js +0 -494
  264. package/src/concepts/dist/Variable__.js +0 -537
  265. package/src/server/dist/formatTsUtils.js +0 -683
@@ -65,6 +65,10 @@ export * from './Match__';
65
65
  export * from './UnaryExpression__';
66
66
  export * from './MemberExpression__';
67
67
  export * from './Unparsed__';
68
+ export * from './New__';
69
+ export * from './NewComposite__';
70
+ export * from './NewList__';
71
+ export * from './NewMap__';
68
72
  export * from './CallQueryComponent__';
69
73
  export * from './QueryFromExpression__';
70
74
  export * from './QueryJoinExpression__';
@@ -81,6 +85,7 @@ export * from './ProcessElement__';
81
85
  export * from './ProcessComponent__';
82
86
  export * from './ProcessOutcome__';
83
87
  export * from './Assignee__';
88
+ export * from './ProcessOutcomes__';
84
89
  export * from './Role__';
85
90
  export * from './Configuration__';
86
91
  export * from './ConfigGroup__';
@@ -1225,4 +1225,5 @@ export const USER_CUSTOM_KEYWORDS_PAGENAME = [
1225
1225
  'getCustomConfig',
1226
1226
  'getCurrentIp',
1227
1227
  'config',
1228
+ 'tenantExpiration',
1228
1229
  ];
@@ -186,11 +186,7 @@ function genMetaData(app) {
186
186
  });
187
187
  utils.traverse(function (current) {
188
188
  var node = (current || {}).node;
189
- var concept = (node || {}).concept;
190
- var typeAnnotation;
191
- if (['Param', 'Variable', 'Return', 'CallFunction', 'CallInterface', 'CallLogic'].includes(concept)) {
192
- typeAnnotation = node.typeAnnotation || node.__TypeAnnotation;
193
- }
189
+ var typeAnnotation = (node === null || node === void 0 ? void 0 : node.typeAnnotation) || (node === null || node === void 0 ? void 0 : node.__TypeAnnotation);
194
190
  collectTypeAnnotation(typeAnnotation);
195
191
  }, {
196
192
  node: {
@@ -0,0 +1,392 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
39
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
40
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
41
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
42
+ r[k] = a[j];
43
+ return r;
44
+ };
45
+ exports.__esModule = true;
46
+ exports.genPermissionData = void 0;
47
+ var concepts_1 = require("../concepts");
48
+ var process2LogicNamespace_1 = require("../server/process2LogicNamespace");
49
+ function isReadOnly(logic) {
50
+ var _a;
51
+ return !!logic.module
52
+ || ((_a = logic.parentNode) === null || _a === void 0 ? void 0 : _a.concept) === 'Namespace'
53
+ || logic.parentKey === 'readonly'; // process logic
54
+ }
55
+ var cache = new Map();
56
+ var useCache = false;
57
+ function findUsage(logic) {
58
+ return __awaiter(this, void 0, void 0, function () {
59
+ var res, _a;
60
+ return __generator(this, function (_b) {
61
+ switch (_b.label) {
62
+ case 0:
63
+ if (useCache && cache.has(logic))
64
+ return [2 /*return*/, cache.get(logic)];
65
+ if (!isReadOnly(logic)) return [3 /*break*/, 2];
66
+ return [4 /*yield*/, logic.findReadOnlyLogicUsage()];
67
+ case 1:
68
+ _a = _b.sent();
69
+ return [3 /*break*/, 4];
70
+ case 2: return [4 /*yield*/, logic.findUsage()];
71
+ case 3:
72
+ _a = _b.sent();
73
+ _b.label = 4;
74
+ case 4:
75
+ res = _a;
76
+ if (useCache)
77
+ cache.set(logic, res);
78
+ return [2 /*return*/, res];
79
+ }
80
+ });
81
+ });
82
+ }
83
+ function openCache() {
84
+ useCache = true;
85
+ cache.clear();
86
+ }
87
+ function closeCache() {
88
+ useCache = false;
89
+ cache.clear();
90
+ }
91
+ function findViewLogicReferences(logic, vis) {
92
+ if (vis === void 0) { vis = new Set(); }
93
+ return __awaiter(this, void 0, void 0, function () {
94
+ function dfs(usage) {
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ var logic_1, _i, _a, child;
97
+ return __generator(this, function (_b) {
98
+ switch (_b.label) {
99
+ case 0:
100
+ if (!(usage.node instanceof concepts_1.CallLogic)) return [3 /*break*/, 2];
101
+ logic_1 = usage.node.logic;
102
+ if (!(!vis.has(logic_1) && logic_1)) return [3 /*break*/, 2];
103
+ vis.add(logic_1);
104
+ return [4 /*yield*/, findViewLogicReferences(logic_1, vis)];
105
+ case 1:
106
+ _b.sent();
107
+ _b.label = 2;
108
+ case 2:
109
+ if (!usage.children) return [3 /*break*/, 6];
110
+ _i = 0, _a = usage.children;
111
+ _b.label = 3;
112
+ case 3:
113
+ if (!(_i < _a.length)) return [3 /*break*/, 6];
114
+ child = _a[_i];
115
+ return [4 /*yield*/, dfs(child)];
116
+ case 4:
117
+ _b.sent();
118
+ _b.label = 5;
119
+ case 5:
120
+ _i++;
121
+ return [3 /*break*/, 3];
122
+ case 6: return [2 /*return*/];
123
+ }
124
+ });
125
+ });
126
+ }
127
+ var usageMap, usages, _i, usages_1, usage;
128
+ return __generator(this, function (_a) {
129
+ switch (_a.label) {
130
+ case 0: return [4 /*yield*/, findUsage(logic)];
131
+ case 1:
132
+ usageMap = _a.sent();
133
+ usages = [];
134
+ usageMap.forEach(function (usage, node) {
135
+ if (node instanceof concepts_1.View)
136
+ usages.push(usage);
137
+ });
138
+ _i = 0, usages_1 = usages;
139
+ _a.label = 2;
140
+ case 2:
141
+ if (!(_i < usages_1.length)) return [3 /*break*/, 5];
142
+ usage = usages_1[_i];
143
+ return [4 /*yield*/, dfs(usage)];
144
+ case 3:
145
+ _a.sent();
146
+ _a.label = 4;
147
+ case 4:
148
+ _i++;
149
+ return [3 /*break*/, 2];
150
+ case 5: return [2 /*return*/, Array.from(vis)];
151
+ }
152
+ });
153
+ });
154
+ }
155
+ function findUIReferences(logic) {
156
+ return __awaiter(this, void 0, void 0, function () {
157
+ function dfs(usage, parent) {
158
+ var _a;
159
+ if (parent === void 0) { parent = null; }
160
+ if ((usage.node instanceof concepts_1.BindEvent || usage.node instanceof concepts_1.BindAttribute)
161
+ && (parent.node instanceof concepts_1.View || parent.node instanceof concepts_1.ViewElement))
162
+ res.push(parent.node);
163
+ (_a = usage.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
164
+ dfs(child, usage);
165
+ });
166
+ }
167
+ var usageMap, usages, res;
168
+ return __generator(this, function (_a) {
169
+ switch (_a.label) {
170
+ case 0: return [4 /*yield*/, findUsage(logic)];
171
+ case 1:
172
+ usageMap = _a.sent();
173
+ usages = [];
174
+ usageMap.forEach(function (usage, node) {
175
+ if (node instanceof concepts_1.View)
176
+ usages.push(usage);
177
+ });
178
+ res = [];
179
+ usages.forEach(function (usage) {
180
+ dfs(usage);
181
+ });
182
+ return [2 /*return*/, res];
183
+ }
184
+ });
185
+ });
186
+ }
187
+ function findResourcesOfUI(view) {
188
+ var res = [];
189
+ var node = view;
190
+ while (node) {
191
+ if (node instanceof concepts_1.View && node.auth)
192
+ res.push({
193
+ path: node.authPath,
194
+ type: 'page'
195
+ });
196
+ else if (node instanceof concepts_1.ViewElement) {
197
+ var hasAuth = node.bindDirectives.find(function (directive) { return directive.name === 'auth'; });
198
+ if (hasAuth)
199
+ res.push({
200
+ path: node.authPath,
201
+ type: 'component'
202
+ });
203
+ }
204
+ node = node.parentNode;
205
+ }
206
+ return res;
207
+ }
208
+ function optimizeResourceData(resources) {
209
+ var res = removeRedundantResourceData(resources);
210
+ res = removeRedundantResourceData2(res);
211
+ return res;
212
+ }
213
+ // [['b'], ['a' ,'b']] 只需要保留 [['b']]
214
+ function removeRedundantResourceData(resources) {
215
+ var wm = new WeakMap();
216
+ for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
217
+ var resource = resources_1[_i];
218
+ var hash = resource.map(function (_a) {
219
+ var path = _a.path, type = _a.type;
220
+ return path + "_" + type;
221
+ })
222
+ .join();
223
+ wm.set(resource, hash);
224
+ }
225
+ resources.sort(function (a, b) { return wm.get(a).length - wm.get(b).length; });
226
+ var res = [];
227
+ var hashs = [];
228
+ ;
229
+ var _loop_1 = function (resource) {
230
+ var hash = wm.get(resource);
231
+ if (hashs.some(function (h) { return hash.endsWith(h); }))
232
+ return "continue";
233
+ res.push(resource);
234
+ hashs.push(hash);
235
+ };
236
+ for (var _a = 0, resources_2 = resources; _a < resources_2.length; _a++) {
237
+ var resource = resources_2[_a];
238
+ _loop_1(resource);
239
+ }
240
+ return res;
241
+ }
242
+ // 子页面有权限,父页面默认也有权限,所以不需要记录父页面权限;
243
+ // 组件有权限,组件所在的页面默认也有权限,所以不需要记录页面权限
244
+ function removeRedundantResourceData2(resources) {
245
+ return resources.map(function (resource) {
246
+ if (resource.length <= 1)
247
+ return resource;
248
+ if (resource[0].type === 'page')
249
+ return resource.slice(0, 1);
250
+ else if (resource[0].type === 'component')
251
+ return resource.filter(function (item) { return item.type === 'component'; });
252
+ });
253
+ }
254
+ function findResourcesOfLogic(logic, uploaders) {
255
+ return __awaiter(this, void 0, void 0, function () {
256
+ var logics, UIs, _i, logics_1, logic_2, _a, _b, service, res;
257
+ return __generator(this, function (_c) {
258
+ switch (_c.label) {
259
+ case 0: return [4 /*yield*/, findViewLogicReferences(logic)];
260
+ case 1:
261
+ logics = _c.sent();
262
+ logics.push(logic);
263
+ UIs = [];
264
+ _i = 0, logics_1 = logics;
265
+ _c.label = 2;
266
+ case 2:
267
+ if (!(_i < logics_1.length)) return [3 /*break*/, 5];
268
+ logic_2 = logics_1[_i];
269
+ _b = (_a = UIs).concat;
270
+ return [4 /*yield*/, findUIReferences(logic_2)];
271
+ case 3:
272
+ UIs = _b.apply(_a, [_c.sent()]);
273
+ _c.label = 4;
274
+ case 4:
275
+ _i++;
276
+ return [3 /*break*/, 2];
277
+ case 5:
278
+ service = logic.toService();
279
+ if (uploaders.has(service.url.path)) {
280
+ UIs = UIs.concat(uploaders.get(service.url.path));
281
+ }
282
+ UIs = Array.from(new Set(UIs));
283
+ res = UIs.map(function (ui) { return findResourcesOfUI(ui); });
284
+ return [2 /*return*/, optimizeResourceData(res)];
285
+ }
286
+ });
287
+ });
288
+ }
289
+ function getAllLogics(app) {
290
+ var modules = [];
291
+ var entities = [];
292
+ var logics = [];
293
+ if (Array.isArray(app.dataSources)) {
294
+ app.dataSources.forEach(function (dataSource) {
295
+ if (Array.isArray(dataSource.entities)) {
296
+ entities.push.apply(entities, dataSource.entities);
297
+ }
298
+ });
299
+ }
300
+ app.logics && logics.push.apply(logics, app.logics);
301
+ app.dependencies && modules.push.apply(modules, app.dependencies);
302
+ app.interfaceDependencies && modules.push.apply(modules, app.interfaceDependencies);
303
+ modules.forEach(function (module) {
304
+ module.logics && logics.push.apply(logics, module.logics);
305
+ if (Array.isArray(module.dataSources)) {
306
+ module.dataSources.forEach(function (dataSource) {
307
+ if (Array.isArray(dataSource.entities)) {
308
+ entities.push.apply(entities, dataSource.entities);
309
+ }
310
+ });
311
+ }
312
+ });
313
+ var allLogics = [];
314
+ if (Array.isArray(entities)) {
315
+ entities.forEach(function (entity) {
316
+ var ns = entity.ns;
317
+ if (Array.isArray(ns === null || ns === void 0 ? void 0 : ns.logics)) {
318
+ allLogics.push.apply(allLogics, ns.logics);
319
+ }
320
+ });
321
+ }
322
+ if (Array.isArray(logics)) {
323
+ allLogics.push.apply(allLogics, logics);
324
+ }
325
+ var processLogics = [];
326
+ var processTreeFragments = (app.processes || [])
327
+ .map(process2LogicNamespace_1.processToTreeFragment);
328
+ processTreeFragments.forEach(function (tree) {
329
+ processLogics.push.apply(processLogics, tree.logics);
330
+ tree.elements.forEach(function (element) {
331
+ processLogics.push.apply(processLogics, element.logics);
332
+ });
333
+ });
334
+ return {
335
+ logics: allLogics,
336
+ processLogics: processLogics
337
+ };
338
+ }
339
+ function findUploaders(app) {
340
+ var map = new Map();
341
+ app.traverseChildren(function (node) {
342
+ var _a;
343
+ if (node instanceof concepts_1.ViewElement && ((_a = node.tag) === null || _a === void 0 ? void 0 : _a.includes('uploader'))) {
344
+ var urlAttr = node.bindAttrs.find(function (item) { return item.name === 'url'; });
345
+ var url = urlAttr === null || urlAttr === void 0 ? void 0 : urlAttr.value;
346
+ if (url) {
347
+ if (!map.has(url))
348
+ map.set(url, [node]);
349
+ else
350
+ map.get(url).push(node);
351
+ }
352
+ }
353
+ });
354
+ return map;
355
+ }
356
+ function genPermissionData(app) {
357
+ return __awaiter(this, void 0, void 0, function () {
358
+ var logicPageResourceDtoList, _a, logics, processLogics, uploaders, _i, _b, logic, resources, service, key;
359
+ return __generator(this, function (_c) {
360
+ switch (_c.label) {
361
+ case 0:
362
+ // console.time('xxx');
363
+ openCache();
364
+ logicPageResourceDtoList = {};
365
+ _a = getAllLogics(app), logics = _a.logics, processLogics = _a.processLogics;
366
+ uploaders = findUploaders(app);
367
+ _i = 0, _b = __spreadArrays(logics, processLogics);
368
+ _c.label = 1;
369
+ case 1:
370
+ if (!(_i < _b.length)) return [3 /*break*/, 4];
371
+ logic = _b[_i];
372
+ return [4 /*yield*/, findResourcesOfLogic(logic, uploaders)];
373
+ case 2:
374
+ resources = _c.sent();
375
+ if (resources.length === 0)
376
+ return [3 /*break*/, 3];
377
+ service = logics.includes(logic) ? logic.toService() : logic.toProcessService();
378
+ key = service.url.path + ":" + service.url.method;
379
+ logicPageResourceDtoList[key] = resources;
380
+ _c.label = 3;
381
+ case 3:
382
+ _i++;
383
+ return [3 /*break*/, 1];
384
+ case 4:
385
+ closeCache();
386
+ // console.timeEnd('xxx');
387
+ return [2 /*return*/, logicPageResourceDtoList];
388
+ }
389
+ });
390
+ });
391
+ }
392
+ exports.genPermissionData = genPermissionData;
@@ -217,12 +217,7 @@ export function genMetaData(app: App) {
217
217
 
218
218
  utils.traverse((current) => {
219
219
  const { node } = current || {};
220
- const { concept } = node || {};
221
- let typeAnnotation;
222
- if (['Param', 'Variable', 'Return', 'CallFunction', 'CallInterface', 'CallLogic'].includes(concept)) {
223
- typeAnnotation = node.typeAnnotation || node.__TypeAnnotation;
224
- }
225
- collectTypeAnnotation(typeAnnotation);
220
+ collectTypeAnnotation(node?.typeAnnotation || node?.__TypeAnnotation);
226
221
  }, {
227
222
  node: {
228
223
  children: views,
@@ -1,5 +1,6 @@
1
- import { App, Assignment, BatchAssignment, CallFunction, CallInterface, CallLogic, ForEachStatement, IfStatement, Logic, LogicItem, Match, MatchCase, Role, SwitchCase, SwitchStatement, View, ViewElement, WhileStatement } from '../concepts';
1
+ import { App, Assignment, BatchAssignment, CallFunction, CallInterface, CallLogic, ForEachStatement, IfStatement, Logic, LogicItem, Match, MatchCase, MemberExpression, Role, SwitchCase, SwitchStatement, View, ViewElement, WhileStatement, StringInterpolation } from '../concepts';
2
2
  import { genBundleFiles } from './genBundleFiles';
3
+ import { genPermissionData } from './permission';
3
4
 
4
5
  export async function genReleaseBody(app: App, {
5
6
  env,
@@ -27,16 +28,28 @@ export async function genReleaseBody(app: App, {
27
28
  },
28
29
  staticUrl?: string,
29
30
  }) {
31
+ let authReport: ReturnType<typeof getAuthReport>;
32
+ let logicPageResourceDtoList;
33
+ if (realRelease) {
34
+ authReport = getAuthReport(app);
35
+ logicPageResourceDtoList = await genPermissionData(app);
36
+ }
37
+
30
38
  const body = {
31
- ...(realRelease ? getAuthReport(app) : undefined), // 如果发布需要上报权限,导出源码不需要
39
+ ...authReport, // 如果发布需要上报权限,导出源码不需要
32
40
  noAuthApiPathList: getAuthApiPathList(app),
33
41
  reportIdList: findAllReportIdList(app),
34
42
  appId: app.id,
35
43
  env,
36
44
  replicas,
45
+ callbackLogicsName: app.getExtensionsCallbackLogics(),
37
46
  generateMini,
38
47
  files: [] as Array<{ name: string, content: string }>,
39
48
  };
49
+
50
+ if (logicPageResourceDtoList)
51
+ Object.assign(body, { logicPageResourceDtoList });
52
+
40
53
  let NaslAnnotatedJSON;
41
54
  try {
42
55
  NaslAnnotatedJSON = await (app as any).naslServer.getNaslAnnotatedJSON(app, true);
@@ -80,7 +93,7 @@ function getAuthReport(app: App) {
80
93
  const result = {
81
94
  roleList: [] as Array<Role>,
82
95
  resourceList: [] as Array<string>,
83
- resourceDataList: [] as Array<{ value: string, description: string }>,
96
+ resourceDataList: [] as Array<{ value: string, description: string, type: 'page' | 'component' | 'logic' }>,
84
97
  roleResourceMappingList: [] as Array<{ roleName: string, resourcePath: string }>,
85
98
  };
86
99
 
@@ -107,6 +120,7 @@ function getAuthReport(app: App) {
107
120
  result.resourceDataList.push({
108
121
  value: view.authPath,
109
122
  description: view.authDescription,
123
+ type: view.concept === 'View' ? 'page' : 'component',
110
124
  });
111
125
  if (view.bindRoles) {
112
126
  const _arr = view.bindRoles.map((it) => ({
@@ -247,6 +261,10 @@ function getAuthApiPathList(app: App) {
247
261
  logicItems = state.arguments?.map((item) => item.expression);
248
262
  } else if (state instanceof CallInterface) {
249
263
  logicItems = state.arguments?.map((item) => item.expression);
264
+ } else if (state instanceof MemberExpression) {
265
+ logicItems = [state.object, state.property];
266
+ } else if (state instanceof StringInterpolation) {
267
+ logicItems = [...state.expressions];
250
268
  }
251
269
 
252
270
  return logicItems.filter((item) => !!item);
@@ -4,3 +4,4 @@ export * from './styleReplacer';
4
4
  export * from './genBundleFiles';
5
5
  export * from './genMetaData';
6
6
  export * from './genReleaseBody';
7
+ export * from './permission';