@lcap/nasl 2.19.0-beta.1 → 2.19.0-beta.3

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 (178) hide show
  1. package/out/common/BaseNode.js +4 -1
  2. package/out/common/BaseNode.js.map +1 -1
  3. package/out/concepts/Abort__.d.ts +25 -0
  4. package/out/concepts/Abort__.js +80 -0
  5. package/out/concepts/Abort__.js.map +1 -0
  6. package/out/concepts/App__.js.map +1 -1
  7. package/out/concepts/BatchAssignment__.js +3 -3
  8. package/out/concepts/BatchAssignment__.js.map +1 -1
  9. package/out/concepts/CallFunction__.js +23 -7
  10. package/out/concepts/CallFunction__.js.map +1 -1
  11. package/out/concepts/CallInterface__.js +1 -1
  12. package/out/concepts/CallInterface__.js.map +1 -1
  13. package/out/concepts/CallLogic__.js +9 -65
  14. package/out/concepts/CallLogic__.js.map +1 -1
  15. package/out/concepts/DatabaseTypeAnnotation__.d.ts +31 -0
  16. package/out/concepts/DatabaseTypeAnnotation__.js +78 -0
  17. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -0
  18. package/out/concepts/EnumItem__.d.ts +5 -5
  19. package/out/concepts/EnumItem__.js +6 -6
  20. package/out/concepts/Enum__.d.ts +20 -19
  21. package/out/concepts/Enum__.js +28 -1
  22. package/out/concepts/Enum__.js.map +1 -1
  23. package/out/concepts/ForEachStatement__.js +1 -1
  24. package/out/concepts/ForEachStatement__.js.map +1 -1
  25. package/out/concepts/FrontendLibrary__.d.ts +213 -0
  26. package/out/concepts/FrontendLibrary__.js +352 -0
  27. package/out/concepts/FrontendLibrary__.js.map +1 -0
  28. package/out/concepts/Frontend__.d.ts +373 -0
  29. package/out/concepts/Frontend__.js +685 -0
  30. package/out/concepts/Frontend__.js.map +1 -0
  31. package/out/concepts/Integration__.d.ts +53 -0
  32. package/out/concepts/Integration__.js +143 -0
  33. package/out/concepts/Integration__.js.map +1 -0
  34. package/out/concepts/JavaLogic__.d.ts +42 -0
  35. package/out/concepts/JavaLogic__.js +122 -0
  36. package/out/concepts/JavaLogic__.js.map +1 -0
  37. package/out/concepts/Logic__.js +3 -0
  38. package/out/concepts/Logic__.js.map +1 -1
  39. package/out/concepts/MicroApp__.d.ts +51 -0
  40. package/out/concepts/MicroApp__.js +113 -0
  41. package/out/concepts/MicroApp__.js.map +1 -0
  42. package/out/concepts/NewComposite__.js +14 -14
  43. package/out/concepts/NewComposite__.js.map +1 -1
  44. package/out/concepts/NewList__.d.ts +1 -0
  45. package/out/concepts/NewList__.js +17 -1
  46. package/out/concepts/NewList__.js.map +1 -1
  47. package/out/concepts/NewMap__.d.ts +1 -0
  48. package/out/concepts/NewMap__.js +18 -1
  49. package/out/concepts/NewMap__.js.map +1 -1
  50. package/out/concepts/OqlQueryComponent__.js +2 -0
  51. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  52. package/out/concepts/StringInterpolation__.js +2 -0
  53. package/out/concepts/StringInterpolation__.js.map +1 -1
  54. package/out/concepts/TypeAnnotation__.js +3 -3
  55. package/out/concepts/TypeAnnotation__.js.map +1 -1
  56. package/out/concepts/ViewBlock__.d.ts +35 -0
  57. package/out/concepts/ViewBlock__.js +85 -0
  58. package/out/concepts/ViewBlock__.js.map +1 -0
  59. package/out/concepts/ViewElement__.js +1 -1
  60. package/out/concepts/ViewElement__.js.map +1 -1
  61. package/out/concepts/View__.js +1 -0
  62. package/out/concepts/View__.js.map +1 -1
  63. package/out/concepts/basics/stdlib/nasl.util.js +4 -2
  64. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  65. package/out/generator/genBundleFiles.js +10 -1
  66. package/out/generator/genBundleFiles.js.map +1 -1
  67. package/out/generator/genReleaseBody.js +3 -0
  68. package/out/generator/genReleaseBody.js.map +1 -1
  69. package/out/generator/icestark.d.ts +2 -0
  70. package/out/generator/icestark.js +48 -0
  71. package/out/generator/icestark.js.map +1 -0
  72. package/out/generator/microApp.d.ts +2 -0
  73. package/out/generator/microApp.js +35 -0
  74. package/out/generator/microApp.js.map +1 -0
  75. package/out/generator/qiankun.d.ts +2 -0
  76. package/out/generator/qiankun.js +52 -0
  77. package/out/generator/qiankun.js.map +1 -0
  78. package/out/manager/stepRecorder.d.ts +20 -0
  79. package/out/manager/stepRecorder.js +110 -0
  80. package/out/manager/stepRecorder.js.map +1 -0
  81. package/out/sentry/index.d.ts +29 -0
  82. package/out/sentry/index.js +111 -0
  83. package/out/sentry/index.js.map +1 -0
  84. package/out/server/extendBaseNode.js +5 -1
  85. package/out/server/extendBaseNode.js.map +1 -1
  86. package/out/server/formatTsUtils.js +11 -8
  87. package/out/server/formatTsUtils.js.map +1 -1
  88. package/out/server/naslServer.js +118 -9
  89. package/out/server/naslServer.js.map +1 -1
  90. package/out/server/translator.js +43 -10
  91. package/out/server/translator.js.map +1 -1
  92. package/out/service/creator/add.configs.js +2 -0
  93. package/out/service/creator/add.configs.js.map +1 -1
  94. package/out/service/creator/errHandles.js +5 -0
  95. package/out/service/creator/errHandles.js.map +1 -1
  96. package/out/service/creator/index.js +2 -0
  97. package/out/service/creator/index.js.map +1 -1
  98. package/out/service/storage/api.d.ts +18 -0
  99. package/out/service/storage/api.js +12 -0
  100. package/out/service/storage/api.js.map +1 -1
  101. package/out/service/storage/init.d.ts +41 -1
  102. package/out/service/storage/init.js +175 -30
  103. package/out/service/storage/init.js.map +1 -1
  104. package/out/service/storage/service.d.ts +9 -1
  105. package/out/service/storage/service.js +27 -1
  106. package/out/service/storage/service.js.map +1 -1
  107. package/out/templator/genGetBlock.js +1 -1
  108. package/out/templator/genGetBlock.js.map +1 -1
  109. package/out/templator/genListViewBlock.js +6 -0
  110. package/out/templator/genListViewBlock.js.map +1 -1
  111. package/package.json +2 -2
  112. package/sandbox/stdlib/nasl.core.ts +2 -0
  113. package/sandbox/stdlib/nasl.oql.ts +16 -4
  114. package/sandbox/stdlib/nasl.util.ts +2 -1
  115. package/src/common/BaseNode.ts +3 -1
  116. package/src/concepts/App__.ts +41 -1
  117. package/src/concepts/BatchAssignment__.ts +3 -3
  118. package/src/concepts/CallFunction__.ts +34 -20
  119. package/src/concepts/CallInterface__.ts +19 -1
  120. package/src/concepts/CallLogic__.ts +8 -65
  121. package/src/concepts/EnumItem__.ts +6 -6
  122. package/src/concepts/Enum__.ts +22 -19
  123. package/src/concepts/ForEachStatement__.ts +1 -1
  124. package/src/concepts/Logic__.ts +13 -10
  125. package/src/concepts/NewComposite__.ts +14 -14
  126. package/src/concepts/NewList__.ts +18 -1
  127. package/src/concepts/NewMap__.ts +19 -1
  128. package/src/concepts/OqlQueryComponent__.ts +2 -0
  129. package/src/concepts/StringInterpolation__.ts +6 -4
  130. package/src/concepts/TypeAnnotation__.ts +41 -3
  131. package/src/concepts/ViewElement__.ts +1 -1
  132. package/src/concepts/View__.ts +3 -2
  133. package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
  134. package/src/generator/genBundleFiles.ts +10 -1
  135. package/src/generator/genReleaseBody.ts +3 -1
  136. package/src/server/extendBaseNode.ts +4 -1
  137. package/src/server/formatTsUtils.ts +11 -8
  138. package/src/server/naslServer.ts +124 -11
  139. package/src/server/translator.ts +37 -10
  140. package/src/service/creator/add.configs.js +3 -0
  141. package/src/service/creator/errHandles.js +6 -0
  142. package/src/service/creator/index.js +3 -0
  143. package/src/service/storage/api.js +12 -0
  144. package/src/service/storage/init.ts +207 -29
  145. package/src/service/storage/service.ts +29 -1
  146. package/src/templator/genGetBlock.ts +1 -1
  147. package/src/templator/genListViewBlock.ts +6 -0
  148. package/ts-worker/lib/tsserver.js +10 -2
  149. package/ts-worker/package.json +1 -0
  150. package/ts-worker/webpack.config.js +11 -2
  151. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  152. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  153. package/src/automate/engine/dist/index.dev.js +0 -517
  154. package/src/common/dist/BaseNode.js +0 -1101
  155. package/src/concepts/basics/stdlib/dist/nasl.util.js +0 -1602
  156. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
  157. package/src/concepts/dist/BindAttribute__.js +0 -760
  158. package/src/concepts/dist/BindEvent__.js +0 -732
  159. package/src/concepts/dist/CallFunction__.js +0 -527
  160. package/src/concepts/dist/CallLogic__.js +0 -932
  161. package/src/concepts/dist/Identifier__.js +0 -311
  162. package/src/concepts/dist/StringInterpolation__.js +0 -231
  163. package/src/concepts/dist/TypeAnnotation__.js +0 -834
  164. package/src/concepts/dist/ViewElement__.js +0 -1692
  165. package/src/concepts/dist/View__.js +0 -1601
  166. package/src/generator/dist/genBundleFiles.js +0 -261
  167. package/src/generator/dist/genMetaData.js +0 -245
  168. package/src/generator/dist/permission.js +0 -392
  169. package/src/server/dist/naslServer.js +0 -3590
  170. package/src/service/storage/dist/init.js +0 -579
  171. package/src/templator/dist/genEditTableBlock.js +0 -204
  172. package/src/templator/dist/genGridViewBlock.js +0 -265
  173. package/src/templator/dist/genListViewBlock.js +0 -84
  174. package/src/templator/dist/genTableBlock.js +0 -209
  175. package/src/templator/dist/utils.js +0 -527
  176. package/ts-worker/dist/webpack.config.dev.js +0 -106
  177. /package/src/service/{dataSource → datasource}/api.js +0 -0
  178. /package/src/service/{dataSource → datasource}/index.js +0 -0
@@ -1,392 +0,0 @@
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;