@lcap/nasl 2.18.0-beta.5 → 2.18.0-beta.7

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 (88) hide show
  1. package/out/common/BaseNode.js +1 -0
  2. package/out/common/BaseNode.js.map +1 -1
  3. package/out/concepts/BatchAssignment__.js +63 -46
  4. package/out/concepts/BatchAssignment__.js.map +1 -1
  5. package/out/concepts/CallLogic__.d.ts +2 -1
  6. package/out/concepts/CallLogic__.js +26 -11
  7. package/out/concepts/CallLogic__.js.map +1 -1
  8. package/out/concepts/Destination__.d.ts +2 -1
  9. package/out/concepts/Destination__.js +90 -22
  10. package/out/concepts/Destination__.js.map +1 -1
  11. package/out/concepts/Logic__.js +6 -7
  12. package/out/concepts/Logic__.js.map +1 -1
  13. package/out/concepts/MatchExpression__.d.ts +97 -0
  14. package/out/concepts/MatchExpression__.js +281 -0
  15. package/out/concepts/MatchExpression__.js.map +1 -0
  16. package/out/concepts/ViewElement__.js +1 -1
  17. package/out/concepts/ViewElement__.js.map +1 -1
  18. package/out/concepts/View__.js +4 -0
  19. package/out/concepts/View__.js.map +1 -1
  20. package/out/generator/genBundleFiles.js +32 -182
  21. package/out/generator/genBundleFiles.js.map +1 -1
  22. package/out/generator/genMetaData.d.ts +1 -10
  23. package/out/generator/genMetaData.js +189 -50
  24. package/out/generator/genMetaData.js.map +1 -1
  25. package/out/generator/genReleaseBody.js +11 -2
  26. package/out/generator/genReleaseBody.js.map +1 -1
  27. package/out/server/extendBaseNode.js +4 -18
  28. package/out/server/extendBaseNode.js.map +1 -1
  29. package/out/server/formatTsUtils.d.ts +1 -2
  30. package/out/server/formatTsUtils.js +30 -47
  31. package/out/server/formatTsUtils.js.map +1 -1
  32. package/out/server/getProcesses.js +1 -1
  33. package/out/server/getProcesses.js.map +1 -1
  34. package/out/server/naslServer.js +8 -7
  35. package/out/server/naslServer.js.map +1 -1
  36. package/out/server/translator.js +19 -4
  37. package/out/server/translator.js.map +1 -1
  38. package/out/templator/sql-parser/index.d.ts +1 -0
  39. package/out/templator/sql-parser/index.js +228 -0
  40. package/out/templator/sql-parser/index.js.map +1 -0
  41. package/out/templator/sql-parser/parser.js +26664 -0
  42. package/out/templator/sql-parser/parser.js.map +1 -0
  43. package/package.json +2 -2
  44. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  45. package/sandbox/stdlib/nasl.util.ts +1 -1
  46. package/src/automate/engine/dist/index.dev.js +517 -0
  47. package/src/common/BaseNode.ts +1 -0
  48. package/src/common/dist/BaseNode.js +1101 -0
  49. package/src/concepts/BatchAssignment__.ts +66 -50
  50. package/src/concepts/CallLogic__.ts +26 -11
  51. package/src/concepts/Destination__.ts +92 -22
  52. package/src/concepts/Logic__.ts +6 -7
  53. package/src/concepts/ViewElement__.ts +8 -29
  54. package/src/concepts/View__.ts +4 -0
  55. package/src/concepts/basics/stdlib/dist/nasl.util.js +1503 -0
  56. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
  57. package/src/concepts/dist/Anchor__.js +179 -0
  58. package/src/concepts/dist/Assignment__.js +301 -0
  59. package/src/concepts/dist/CallFunction__.js +513 -0
  60. package/src/concepts/dist/CallInterface__.js +533 -0
  61. package/src/concepts/dist/CallLogic__.js +892 -0
  62. package/src/concepts/dist/ForEachStatement__.js +426 -0
  63. package/src/concepts/dist/MatchCase__.js +587 -0
  64. package/src/concepts/dist/Match__.js +631 -0
  65. package/src/concepts/dist/MemberExpression__.js +348 -0
  66. package/src/concepts/dist/Param__.js +538 -0
  67. package/src/concepts/dist/Return__.js +494 -0
  68. package/src/concepts/dist/Variable__.js +537 -0
  69. package/src/concepts/dist/ViewElement__.js +1680 -0
  70. package/src/generator/dist/genBundleFiles.js +261 -0
  71. package/src/generator/dist/genMetaData.js +249 -0
  72. package/src/generator/genBundleFiles.ts +34 -219
  73. package/src/generator/genMetaData.ts +182 -77
  74. package/src/generator/genReleaseBody.ts +10 -3
  75. package/src/server/dist/formatTsUtils.js +683 -0
  76. package/src/server/dist/naslServer.js +3474 -0
  77. package/src/server/extendBaseNode.ts +4 -19
  78. package/src/server/formatTsUtils.ts +30 -46
  79. package/src/server/getProcesses.ts +1 -1
  80. package/src/server/naslServer.ts +8 -7
  81. package/src/server/translator.ts +18 -4
  82. package/src/service/storage/dist/init.js +572 -0
  83. package/ts-worker/dist/webpack.config.dev.js +108 -0
  84. package/dist/bundle.js +0 -3962
  85. package/dist/bundle.js.LICENSE.txt +0 -16
  86. package/out/generator/release.d.ts +0 -1
  87. package/out/generator/release.js +0 -51
  88. package/out/generator/release.js.map +0 -1
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.genBundleFiles = void 0;
4
+ var utils = require("../utils");
5
+ var _1 = require(".");
6
+ var compileComponent_1 = require("./compileComponent");
7
+ var JSON5 = require("json5");
8
+ var prettier = require("prettier");
9
+ // @ts-ignore:next-line
10
+ var parserBabel = require("prettier/parser-babel");
11
+ var UglifyJS = require("uglify-js-export");
12
+ var genMetaData_1 = require("./genMetaData");
13
+ function genBundleFiles(app, config) {
14
+ var _a;
15
+ var _b, _c, _d;
16
+ var fnNuimsDomain = ((_b = config === null || config === void 0 ? void 0 : config.envNuimsDomain) === null || _b === void 0 ? void 0 : _b[config === null || config === void 0 ? void 0 : config.env]) || (config === null || config === void 0 ? void 0 : config.nuimsDomain);
17
+ var fnLowcodeDomain = ((_d = (_c = config === null || config === void 0 ? void 0 : config.envLcpDomain) === null || _c === void 0 ? void 0 : _c[config === null || config === void 0 ? void 0 : config.env]) === null || _d === void 0 ? void 0 : _d.lcpDomain) || (config === null || config === void 0 ? void 0 : config.lowcodeDomain);
18
+ var modules = [];
19
+ var views = [];
20
+ app.dependencies && modules.push.apply(modules, app.dependencies);
21
+ app.interfaceDependencies && modules.push.apply(modules, app.interfaceDependencies);
22
+ app.views && views.push.apply(views, app.views);
23
+ modules.forEach(function (module) {
24
+ module.views && views.push.apply(views, module.views);
25
+ });
26
+ var componentMap = {};
27
+ utils.traverse(function (current) {
28
+ if (current.node.toVueOptions)
29
+ componentMap[current.node.id] = current.node.toVueOptions();
30
+ }, {
31
+ node: {
32
+ children: views
33
+ }
34
+ });
35
+ /**
36
+ * vue.config.js page options
37
+ */
38
+ var routes = [];
39
+ // 开启了权限的页面
40
+ var authResourceViews = [];
41
+ var baseResourcePaths = [];
42
+ var rootViewData = [];
43
+ var defaultRoute = '';
44
+ // 遍历页面
45
+ var traverseViews = function (view, isParentViewAuth) {
46
+ var parentNode = view.parentNode || {};
47
+ var isRootView = parentNode.concept !== 'View';
48
+ var viewName = view.name;
49
+ // 页面是否需要权限,如果父页面需要权限,子页面也一定需要
50
+ var isViewAuth = isParentViewAuth || view.auth;
51
+ // 路由地址
52
+ var routePath = viewName;
53
+ if (isRootView) {
54
+ rootViewData.push({ name: viewName, title: view.title || viewName, isIndex: view.isIndex });
55
+ routePath = "/" + viewName;
56
+ if (!isViewAuth) {
57
+ if (viewName === 'notFound') {
58
+ defaultRoute = routePath;
59
+ }
60
+ if (view.isIndex) {
61
+ if (!defaultRoute) {
62
+ defaultRoute = routePath;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ var route = {
68
+ path: routePath,
69
+ component: compileComponent_1.compileComponent(componentMap[view.id]),
70
+ children: []
71
+ };
72
+ var viewChildren = view.children;
73
+ if (Array.isArray(viewChildren) && viewChildren.length) {
74
+ for (var i = 0; i < viewChildren.length; i++) {
75
+ var subView = viewChildren[i];
76
+ var subViewRoute = traverseViews(subView, isViewAuth).route;
77
+ route.children.push(subViewRoute);
78
+ if (subView.isIndex) {
79
+ route.children.push({
80
+ path: '',
81
+ redirect: "'" + subView.name + "'"
82
+ });
83
+ }
84
+ }
85
+ }
86
+ var viewPath = view.path;
87
+ if (isViewAuth) {
88
+ authResourceViews.push(view);
89
+ }
90
+ if (!isViewAuth) {
91
+ baseResourcePaths.push(viewPath);
92
+ }
93
+ return {
94
+ route: route,
95
+ isViewAuth: isViewAuth
96
+ };
97
+ };
98
+ // 页面
99
+ views.forEach(function (view) {
100
+ var route = traverseViews(view).route;
101
+ routes.push(route);
102
+ if (view.isIndex) {
103
+ routes.push({
104
+ path: '/',
105
+ redirect: "'/" + view.name + "'"
106
+ });
107
+ }
108
+ });
109
+ var authResourcePathMap = {};
110
+ // 默认跳转子页面开启权限的情况,需要把父页面也都加入权限校验列表
111
+ if (Array.isArray(authResourceViews)) {
112
+ authResourceViews.forEach(function (authResourceView) {
113
+ if (authResourceView) {
114
+ authResourcePathMap[authResourceView.path] = true;
115
+ var viewNode = authResourceView;
116
+ while (viewNode.concept === 'View' && viewNode.isIndex) {
117
+ var parentViewNode = viewNode.parentNode;
118
+ if (parentViewNode.concept === 'View') {
119
+ authResourcePathMap[parentViewNode.path] = true;
120
+ }
121
+ else { // viewNode是根页面
122
+ authResourcePathMap['/'] = true;
123
+ }
124
+ viewNode = parentViewNode;
125
+ }
126
+ }
127
+ });
128
+ }
129
+ var authResourcePaths = Object.keys(authResourcePathMap);
130
+ function routeToString(route) {
131
+ var _a, _b;
132
+ var content = "{\n path: '" + route.path + "',\n";
133
+ if ((_a = route === null || route === void 0 ? void 0 : route.component) === null || _a === void 0 ? void 0 : _a.script) {
134
+ var template = route.component.template;
135
+ if (config.env !== 'dev') {
136
+ template = template.replace(/[\t\r\n]/g, '');
137
+ }
138
+ content += "component: (function(){\n var componentOptions = " + (route.component.script ? '(function(){\n' + route.component.script.trim().replace(/export default |module\.exports +=/, 'return ') + '\n})()' : '{}') + ";\n Object.assign(componentOptions, {\n template: `" + template.replace(/[`$]/g, function (m) { return '\\' + m; }) + "`,\n });\n return componentOptions;\n })(),\n";
139
+ }
140
+ if ((_b = route === null || route === void 0 ? void 0 : route.children) === null || _b === void 0 ? void 0 : _b.length) {
141
+ content += "children: [\n " + route.children.map(routeToString).join(',\n') + "\n ],\n";
142
+ }
143
+ if (route === null || route === void 0 ? void 0 : route.redirect) {
144
+ content += "redirect: " + (route === null || route === void 0 ? void 0 : route.redirect) + ",\n";
145
+ }
146
+ content += '}';
147
+ return content;
148
+ }
149
+ var routesStr = '[';
150
+ routes.forEach(function (route) {
151
+ routesStr += routeToString(route) + ",\n";
152
+ });
153
+ if (defaultRoute) {
154
+ routesStr += "{\n path: '*',\n redirect: '" + defaultRoute + "',\n }\n";
155
+ }
156
+ routesStr += ']';
157
+ var platformConfig = JSON5.stringify({
158
+ appConfig: {
159
+ project: app.name,
160
+ domainName: app.name,
161
+ nuimsDomain: fnNuimsDomain,
162
+ envNuimsDomain: config.envNuimsDomain,
163
+ tenantType: config.tenantType,
164
+ tenantLevel: config.tenantLevel,
165
+ extendedConfig: config.extendedConfig,
166
+ envConfig: {
167
+ lowcodeDomain: fnLowcodeDomain
168
+ },
169
+ tenant: config.tenant,
170
+ documentTitle: app.documentTitle,
171
+ rootViewData: rootViewData
172
+ },
173
+ dnsAddr: app.dnsAddr,
174
+ devDnsAddr: config.devDnsAddr,
175
+ tenant: config.tenant,
176
+ env: config.env,
177
+ hasUserCenter: app.hasUserCenter,
178
+ hasAuth: app.hasAuth,
179
+ authResourcePaths: authResourcePaths,
180
+ baseResourcePaths: baseResourcePaths,
181
+ miniEnable: config.miniEnable
182
+ }, null, 4);
183
+ var metaData = genMetaData_1.genMetaData(app);
184
+ var metaDataStr = JSON5.stringify(metaData);
185
+ var assetsInfo = app.genAllAssetsInfo(config.STATIC_URL);
186
+ var customNames = JSON5.stringify(assetsInfo.custom.names);
187
+ var content = "(function(){\n ";
188
+ var themeCSS = app.genThemeCSS();
189
+ if (themeCSS) {
190
+ content += "{\n const el = document.createElement('style');\n el.id = 'theme';\n el.innerHTML = `" + themeCSS + "`;\n document.head.appendChild(el);\n }\n ";
191
+ }
192
+ if (app.documentIcon) {
193
+ content += "{\n const link = document.createElement('link');\n link.rel = 'shortcut icon';\n link.href = `" + app.documentIcon + "`;\n document.head.appendChild(link);\n }";
194
+ }
195
+ content += "\n var customNames = " + customNames + ";\n for(var i=0;i<customNames.length;i++){\n var name = window.kebab2Camel(customNames[i]);\n if(window[name]){\n window.CloudUI.install(window.Vue, window[name]);\n }\n }";
196
+ content += "\n var platformConfig = " + platformConfig + ";\n var metaData = " + metaDataStr + ";\n var routes = " + routesStr + ";\n\n window.createLcapApp = () => window.appVM = window.cloudAdminDesigner.init(platformConfig.appConfig, platformConfig, routes, metaData);\n window.createLcapApp();\n })();";
197
+ if (config.env === 'dev') {
198
+ // 加载资源js
199
+ // const domain = fnLowcodeDomain.slice(fnLowcodeDomain.indexOf('.') + 1);
200
+ // const targetUrl = `${typeof location !== 'undefined' ? location.origin : `http://${config.tenant}.${fnLowcodeDomain}`}/empty?url=${domain}&appid=${config.appid}`;
201
+ // if(!document.querySelector("iframe[name='iframeEmpty']")){
202
+ // var el = document.createElement('iframe');
203
+ // el.setAttribute('src', "${targetUrl}");
204
+ // el.setAttribute('name', 'iframeEmpty');
205
+ // el.setAttribute('width', 0);
206
+ // el.setAttribute('height', 0);
207
+ // el.style.borderWidth = 0
208
+ // el.style.display= "block"
209
+ // document.getElementsByTagName('body')[0].appendChild(el);
210
+ // document.domain = '${domain}'
211
+ var str = "\n var _div = document.createElement('div');\n _div.classList = \"div-load\"\n _div.innerHTML = \"<div class='loading-container'></div><div>\u6B63\u5728\u66F4\u65B0\u6700\u65B0\u53D1\u5E03\u5185\u5BB9...</div>\"\n document.getElementsByTagName('body')[0].appendChild(_div);\n window.showLoading = function(){\n document.querySelector(\".div-load\").style.display =\"flex\"\n }\n window.hideLoading = function(){\n document.querySelector(\".div-load\").style.display =\"none\"\n }\n var style = document.createElement('style');\n style.innerHTML=`.div-load{\n width: 208px;\n height: 40px;\n background: rgba(48, 48, 48, 0.8);\n box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n position: fixed;\n top: 120px;\n left: 50%;\n margin-left: -104px;\n color: #FFFFFF;\n font-size: 14px;\n display: none;\n justify-content: center;\n align-items: center;\n }\n\n .loading-container{\n width: 12px;\n height: 12px;\n margin-right: 10px;\n animation: loading-animation 0.8s infinite linear;\n border: 2px solid #f3f3f3;\n border-top: 2px solid rgb(109, 108, 108);\n border-right: 2px solid rgb(109, 108, 108);\n border-bottom: 2px solid rgb(109, 108, 108);\n border-radius: 50%;\n }\n\n @keyframes loading-animation{\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }`\n document.getElementsByTagName('body')[0].appendChild(style);\n window.addEventListener('message', function (e) {\n console.log('message:',e)\n if(e.data ===\"release-start\"){\n showLoading()\n }\n if(e.data===\"release-end\"){\n hideLoading()\n window.location.reload();\n }\n })\n ";
212
+ content += str;
213
+ }
214
+ var bundlePath = config.USER_STATIC_URL + "/" + config.tenant + "/" + app.id + "/" + config.env + "/bundle." + _1.genHash(content) + ".js";
215
+ var bundleSourceMapPath = bundlePath + ".map";
216
+ var bundleMinPath = config.USER_STATIC_URL + "/" + config.tenant + "/" + app.id + "/" + config.env + "/bundle." + _1.genHash(content) + ".min.js";
217
+ var otherJsList = config.miniEnable ? ['//res.wx.qq.com/open/js/jweixin-1.3.2.js'] : [];
218
+ var assetsContent = "(function() {\n LazyLoad.js(" + JSON5.stringify(assetsInfo.basic.js.concat(assetsInfo.custom.js, otherJsList).concat([bundleMinPath])) + ");\n LazyLoad.css(" + JSON5.stringify(assetsInfo.basic.css.concat(assetsInfo.custom.css)) + ");\n})()\n";
219
+ var minifyObj;
220
+ // 开发环境加上sourceMap
221
+ if (config.env === 'dev') {
222
+ content = prettier.format(content, {
223
+ parser: 'babel',
224
+ plugins: [parserBabel],
225
+ tabWidth: 4
226
+ });
227
+ minifyObj = UglifyJS.minify((_a = {},
228
+ _a[bundlePath] = content,
229
+ _a), {
230
+ sourceMap: {
231
+ url: bundleSourceMapPath
232
+ }
233
+ });
234
+ }
235
+ else {
236
+ minifyObj = UglifyJS.minify(content);
237
+ }
238
+ var outputs = [
239
+ {
240
+ name: bundleMinPath,
241
+ content: minifyObj.code
242
+ },
243
+ {
244
+ name: config.USER_STATIC_URL + "/" + config.tenant + "/" + app.id + "/" + config.env + "/client.js",
245
+ content: assetsContent
246
+ },
247
+ ];
248
+ // 开发环境加上sourceMap
249
+ if (config.env === 'dev') {
250
+ // map和源文件
251
+ outputs.push({
252
+ name: bundlePath,
253
+ content: content
254
+ }, {
255
+ name: bundleSourceMapPath,
256
+ content: minifyObj.map
257
+ });
258
+ }
259
+ return outputs;
260
+ }
261
+ exports.genBundleFiles = genBundleFiles;
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.genMetaData = void 0;
4
+ var concepts_1 = require("../concepts");
5
+ var utils = require("../utils");
6
+ // 生成typeKey
7
+ function genSortedTypeKey(typeAnnotation) {
8
+ var _a = typeAnnotation || {}, typeKind = _a.typeKind, typeNamespace = _a.typeNamespace, typeName = _a.typeName, typeArguments = _a.typeArguments, properties = _a.properties;
9
+ var typeKeyArr = [];
10
+ if (typeKind === 'union') { // 联合类型
11
+ if (Array.isArray(typeArguments)) {
12
+ // 按返回的每个具体项排序
13
+ var childTypeArgs = typeArguments.map(function (typeArg) { return genSortedTypeKey(typeArg); }).sort(function (name1, name2) { return name1 > name2 ? 1 : -1; });
14
+ typeKeyArr.push(childTypeArgs.join(' | '));
15
+ }
16
+ }
17
+ else if (typeKind === 'anonymousStructure') { // 匿名数据结构
18
+ typeKeyArr.push('{');
19
+ if (Array.isArray(properties)) {
20
+ // 按匿名数据结构的key排序
21
+ var childTypeArgs = properties.sort(function (_a, _b) {
22
+ var name1 = _a.name;
23
+ var name2 = _b.name;
24
+ return name1 > name2 ? 1 : -1;
25
+ }).map(function (typeArg) {
26
+ var _a = typeArg || {}, typeArgName = _a.name, typeArgTypeAnnotation = _a.typeAnnotation;
27
+ return typeArgName + ": " + genSortedTypeKey(typeArgTypeAnnotation);
28
+ });
29
+ typeKeyArr.push(childTypeArgs.join(', '));
30
+ }
31
+ typeKeyArr.push('}');
32
+ }
33
+ else {
34
+ var typeArr = [];
35
+ typeNamespace && typeArr.push(typeNamespace);
36
+ typeName && typeArr.push(typeName);
37
+ var typeKey = typeArr.join('.');
38
+ typeKey && typeKeyArr.push(typeKey);
39
+ if (typeKind === 'generic') {
40
+ typeKeyArr.push('<');
41
+ if (Array.isArray(typeArguments)) {
42
+ // 必须按typeArguments定义的顺序,否则实参位置不对
43
+ var childTypeArgs = typeArguments.map(function (typeArg) { return genSortedTypeKey(typeArg); });
44
+ typeKeyArr.push(childTypeArgs.join(', '));
45
+ }
46
+ typeKeyArr.push('>');
47
+ }
48
+ }
49
+ return typeKeyArr.join('');
50
+ }
51
+ function genMetaData(app) {
52
+ var modules = [];
53
+ var views = [];
54
+ var entities = [];
55
+ var structures = [];
56
+ var enums = [];
57
+ var logics = [];
58
+ var interfaces = [];
59
+ var processes = [];
60
+ app.views && views.push.apply(views, app.views);
61
+ if (Array.isArray(app.dataSources)) {
62
+ app.dataSources.forEach(function (dataSource) {
63
+ if (Array.isArray(dataSource.entities)) {
64
+ entities.push.apply(entities, dataSource.entities);
65
+ }
66
+ });
67
+ }
68
+ app.structures && structures.push.apply(structures, app.structures);
69
+ app.enums && enums.push.apply(enums, app.enums);
70
+ app.logics && logics.push.apply(logics, app.logics);
71
+ app.processes && processes.push.apply(processes, app.processes);
72
+ app.dependencies && modules.push.apply(modules, app.dependencies);
73
+ app.interfaceDependencies && modules.push.apply(modules, app.interfaceDependencies);
74
+ modules.forEach(function (module) {
75
+ module.views && views.push.apply(views, module.views);
76
+ module.structures && structures.push.apply(structures, module.structures);
77
+ module.enums && enums.push.apply(enums, module.enums);
78
+ module.logics && logics.push.apply(logics, module.logics);
79
+ module.interfaces && interfaces.push.apply(interfaces, module.interfaces);
80
+ if (Array.isArray(module.dataSources)) {
81
+ module.dataSources.forEach(function (dataSource) {
82
+ if (Array.isArray(dataSource.entities)) {
83
+ entities.push.apply(entities, dataSource.entities);
84
+ }
85
+ });
86
+ }
87
+ });
88
+ var dataTypes = [];
89
+ var dataTypesMap = {};
90
+ var frontendVariables = app.frontendVariables;
91
+ var enumsMap = {};
92
+ var logicsMap = {};
93
+ var _custom = {};
94
+ var allLogics = [];
95
+ if (Array.isArray(enums)) {
96
+ dataTypes.push.apply(dataTypes, enums);
97
+ enums.forEach(function (node) {
98
+ var _a = node || {}, name = _a.name, enumItems = _a.enumItems;
99
+ if (node.module) {
100
+ name = "extensions." + node.module.name + ".enums." + name;
101
+ }
102
+ var enumObj = {};
103
+ enumItems.forEach(function (_a) {
104
+ var label = _a.label, value = _a.value;
105
+ enumObj[value] = label;
106
+ });
107
+ enumsMap[name] = enumObj;
108
+ });
109
+ }
110
+ if (Array.isArray(entities)) {
111
+ dataTypes.push.apply(dataTypes, entities);
112
+ entities.forEach(function (entity) {
113
+ var ns = entity.ns;
114
+ if (Array.isArray(ns === null || ns === void 0 ? void 0 : ns.logics)) {
115
+ allLogics.push.apply(allLogics, ns.logics);
116
+ }
117
+ });
118
+ }
119
+ if (Array.isArray(structures)) {
120
+ dataTypes.push.apply(dataTypes, structures);
121
+ }
122
+ dataTypes.forEach(function (node) {
123
+ var _a;
124
+ var namespace = node.getNamespace();
125
+ var id = namespace + "." + node.name;
126
+ dataTypesMap[id] = (_a = node.toJSON) === null || _a === void 0 ? void 0 : _a.call(node);
127
+ var properties = (node).properties;
128
+ if (Array.isArray(properties)) {
129
+ properties.forEach(function (property) {
130
+ collectTypeAnnotation(property === null || property === void 0 ? void 0 : property.typeAnnotation);
131
+ });
132
+ }
133
+ });
134
+ [
135
+ {
136
+ namespace: 'nasl.ui',
137
+ list: concepts_1.uiStructures
138
+ },
139
+ {
140
+ namespace: 'nasl.collection',
141
+ list: concepts_1.collectionStructures
142
+ },
143
+ {
144
+ namespace: 'nasl.interface',
145
+ list: concepts_1.interfaceStructures
146
+ },
147
+ {
148
+ namespace: 'nasl.process',
149
+ list: concepts_1.processStructures
150
+ },
151
+ ].forEach(function (item) {
152
+ var _a = item || {}, namespace = _a.namespace, list = _a.list;
153
+ if (Array.isArray(list)) {
154
+ list.forEach(function (node) {
155
+ var _a;
156
+ var id = namespace + "." + node.name;
157
+ dataTypesMap[id] = (_a = node.toJSON) === null || _a === void 0 ? void 0 : _a.call(node);
158
+ var properties = (node).properties;
159
+ if (Array.isArray(properties)) {
160
+ properties.forEach(function (property) {
161
+ collectTypeAnnotation(property === null || property === void 0 ? void 0 : property.typeAnnotation);
162
+ });
163
+ }
164
+ });
165
+ }
166
+ });
167
+ if (Array.isArray(logics)) {
168
+ allLogics.push.apply(allLogics, logics);
169
+ }
170
+ allLogics.forEach(function (node) {
171
+ var namespace = node.getNamespace();
172
+ var id = namespace ? namespace + "." + node.name : node.name;
173
+ logicsMap[id] = node.toService();
174
+ });
175
+ processes.forEach(function (process) {
176
+ if (Array.isArray(process.logics)) {
177
+ process.logics.forEach(function (node) {
178
+ var namespace = node.getNamespace();
179
+ var id = namespace ? namespace + "." + node.name : node.name;
180
+ logicsMap[id] = node.toProcessService();
181
+ });
182
+ }
183
+ });
184
+ interfaces.forEach(function (interfaceItem) {
185
+ _custom[interfaceItem.getNamespace() + "." + interfaceItem.name] = interfaceItem.toService();
186
+ });
187
+ utils.traverse(function (current) {
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
+ }
194
+ collectTypeAnnotation(typeAnnotation);
195
+ }, {
196
+ node: {
197
+ children: views
198
+ }
199
+ }, {
200
+ mode: 'anyObject',
201
+ excludedKeySet: new Set([
202
+ 'parentNode',
203
+ 'sourceMap',
204
+ 'storageJSON',
205
+ 'tsErrorDetail',
206
+ 'NaslAnnotatedJSON',
207
+ 'calledFrom',
208
+ '_events',
209
+ '_collectingList',
210
+ '_historyList',
211
+ ])
212
+ });
213
+ if (Array.isArray(frontendVariables)) {
214
+ frontendVariables.forEach(function (frontendVariable) {
215
+ var typeAnnotation = frontendVariable.typeAnnotation || frontendVariable.__TypeAnnotation;
216
+ collectTypeAnnotation(typeAnnotation);
217
+ });
218
+ }
219
+ function collectTypeAnnotation(typeAnnotation) {
220
+ var _a, _b;
221
+ if (typeAnnotation) {
222
+ var sortedTypeKey = genSortedTypeKey(typeAnnotation);
223
+ if (!dataTypesMap[sortedTypeKey]) {
224
+ dataTypesMap[sortedTypeKey] = (_b = (_a = typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.toJSON) === null || _a === void 0 ? void 0 : _a.call(typeAnnotation)) !== null && _b !== void 0 ? _b : typeAnnotation;
225
+ var _c = (dataTypesMap[sortedTypeKey] || {}), properties = _c.properties, typeArguments = _c.typeArguments;
226
+ if (Array.isArray(properties)) {
227
+ properties.forEach(function (property) {
228
+ collectTypeAnnotation(property === null || property === void 0 ? void 0 : property.typeAnnotation);
229
+ });
230
+ }
231
+ if (Array.isArray(typeArguments)) {
232
+ typeArguments.forEach(function (typeArg) {
233
+ collectTypeAnnotation(typeArg);
234
+ });
235
+ }
236
+ }
237
+ }
238
+ }
239
+ return {
240
+ frontendVariables: frontendVariables,
241
+ dataTypesMap: dataTypesMap,
242
+ enumsMap: enumsMap,
243
+ logicsMap: logicsMap,
244
+ servicesMap: {
245
+ _custom: _custom
246
+ }
247
+ };
248
+ }
249
+ exports.genMetaData = genMetaData;