@lcap/nasl 2.18.0-beta.4 → 2.18.0

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 (46) hide show
  1. package/out/concepts/MatchExpression__.d.ts +97 -0
  2. package/out/concepts/MatchExpression__.js +281 -0
  3. package/out/concepts/MatchExpression__.js.map +1 -0
  4. package/out/concepts/Param__.js +1 -1
  5. package/out/concepts/Param__.js.map +1 -1
  6. package/out/concepts/Return__.js +1 -1
  7. package/out/concepts/Return__.js.map +1 -1
  8. package/out/concepts/Variable__.js +1 -1
  9. package/out/concepts/Variable__.js.map +1 -1
  10. package/out/server/naslServer.js +27 -31
  11. package/out/server/naslServer.js.map +1 -1
  12. package/out/templator/sql-parser/index.d.ts +1 -0
  13. package/out/templator/sql-parser/index.js +228 -0
  14. package/out/templator/sql-parser/index.js.map +1 -0
  15. package/out/templator/sql-parser/parser.js +26664 -0
  16. package/out/templator/sql-parser/parser.js.map +1 -0
  17. package/package.json +2 -2
  18. package/src/automate/engine/dist/index.dev.js +517 -0
  19. package/src/common/dist/BaseNode.js +1101 -0
  20. package/src/concepts/Param__.ts +1 -1
  21. package/src/concepts/Return__.ts +1 -1
  22. package/src/concepts/Variable__.ts +1 -1
  23. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
  24. package/src/concepts/dist/Anchor__.js +179 -0
  25. package/src/concepts/dist/Assignment__.js +301 -0
  26. package/src/concepts/dist/CallFunction__.js +473 -0
  27. package/src/concepts/dist/CallInterface__.js +533 -0
  28. package/src/concepts/dist/CallLogic__.js +864 -0
  29. package/src/concepts/dist/ForEachStatement__.js +426 -0
  30. package/src/concepts/dist/MatchCase__.js +587 -0
  31. package/src/concepts/dist/MemberExpression__.js +348 -0
  32. package/src/concepts/dist/Param__.js +537 -0
  33. package/src/concepts/dist/Return__.js +493 -0
  34. package/src/generator/dist/genBundleFiles.js +414 -0
  35. package/src/server/dist/formatTsUtils.js +683 -0
  36. package/src/server/dist/naslServer.js +3396 -0
  37. package/src/server/naslServer.ts +28 -31
  38. package/src/service/storage/dist/init.js +541 -0
  39. package/ts-worker/dist/webpack.config.dev.js +104 -0
  40. package/ts-worker/lib/dist/tsserver.dev.js +22953 -0
  41. package/ts-worker/sources/lib/dist/tsserver.dev.js +22912 -0
  42. package/dist/bundle.js +0 -3962
  43. package/dist/bundle.js.LICENSE.txt +0 -16
  44. package/out/generator/release.d.ts +0 -1
  45. package/out/generator/release.js +0 -51
  46. package/out/generator/release.js.map +0 -1
@@ -0,0 +1,414 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.genBundleFiles = void 0;
4
+ var concepts_1 = require("../concepts");
5
+ var utils = require("../utils");
6
+ var _1 = require(".");
7
+ var compileComponent_1 = require("./compileComponent");
8
+ var JSON5 = require("json5");
9
+ var prettier = require("prettier");
10
+ // @ts-ignore:next-line
11
+ var parserBabel = require("prettier/parser-babel");
12
+ var UglifyJS = require("uglify-js-export");
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
+ var entities = [];
21
+ var structures = [];
22
+ var enums = [];
23
+ var logics = [];
24
+ var interfaces = [];
25
+ var processes = [];
26
+ app.views && views.push.apply(views, app.views);
27
+ if (Array.isArray(app.dataSources)) {
28
+ app.dataSources.forEach(function (dataSource) {
29
+ if (Array.isArray(dataSource.entities)) {
30
+ entities.push.apply(entities, dataSource.entities);
31
+ }
32
+ });
33
+ }
34
+ app.structures && structures.push.apply(structures, app.structures);
35
+ app.enums && enums.push.apply(enums, app.enums);
36
+ app.logics && logics.push.apply(logics, app.logics);
37
+ app.processes && processes.push.apply(processes, app.processes);
38
+ app.dependencies && modules.push.apply(modules, app.dependencies);
39
+ app.interfaceDependencies && modules.push.apply(modules, app.interfaceDependencies);
40
+ modules.forEach(function (module) {
41
+ module.views && views.push.apply(views, module.views);
42
+ module.structures && structures.push.apply(structures, module.structures);
43
+ module.enums && enums.push.apply(enums, module.enums);
44
+ module.logics && logics.push.apply(logics, module.logics);
45
+ module.interfaces && interfaces.push.apply(interfaces, module.interfaces);
46
+ if (Array.isArray(module.dataSources)) {
47
+ module.dataSources.forEach(function (dataSource) {
48
+ if (Array.isArray(dataSource.entities)) {
49
+ entities.push.apply(entities, dataSource.entities);
50
+ }
51
+ });
52
+ }
53
+ });
54
+ var componentMap = {};
55
+ utils.traverse(function (current) {
56
+ if (current.node.toVueOptions)
57
+ componentMap[current.node.id] = current.node.toVueOptions();
58
+ }, {
59
+ node: {
60
+ children: views
61
+ }
62
+ });
63
+ /**
64
+ * vue.config.js page options
65
+ */
66
+ var routes = [];
67
+ var dataTypes = [];
68
+ var dataTypesMap = {};
69
+ var frontendVariables = app.frontendVariables;
70
+ var enumsMap = {};
71
+ var logicsMap = {};
72
+ var _custom = {};
73
+ var allLogics = [];
74
+ // 开启了权限的页面
75
+ var authResourceViews = [];
76
+ var baseResourcePaths = [];
77
+ var rootViewData = [];
78
+ var defaultRoute = '';
79
+ // 遍历页面
80
+ var traverseViews = function (view, isParentViewAuth) {
81
+ var parentNode = view.parentNode || {};
82
+ var isRootView = parentNode.concept !== 'View';
83
+ var viewName = view.name;
84
+ // 页面是否需要权限,如果父页面需要权限,子页面也一定需要
85
+ var isViewAuth = isParentViewAuth || view.auth;
86
+ // 路由地址
87
+ var routePath = viewName;
88
+ if (isRootView) {
89
+ rootViewData.push({ name: viewName, title: view.title || viewName, isIndex: view.isIndex });
90
+ routePath = "/" + viewName;
91
+ if (!isViewAuth) {
92
+ if (viewName === 'notFound') {
93
+ defaultRoute = routePath;
94
+ }
95
+ if (view.isIndex) {
96
+ if (!defaultRoute) {
97
+ defaultRoute = routePath;
98
+ }
99
+ }
100
+ }
101
+ }
102
+ var route = {
103
+ path: routePath,
104
+ component: compileComponent_1.compileComponent(componentMap[view.id]),
105
+ children: []
106
+ };
107
+ var viewChildren = view.children;
108
+ if (Array.isArray(viewChildren) && viewChildren.length) {
109
+ for (var i = 0; i < viewChildren.length; i++) {
110
+ var subView = viewChildren[i];
111
+ var subViewRoute = traverseViews(subView, isViewAuth).route;
112
+ route.children.push(subViewRoute);
113
+ if (subView.isIndex) {
114
+ route.children.push({
115
+ path: '',
116
+ redirect: "'" + subView.name + "'"
117
+ });
118
+ }
119
+ }
120
+ }
121
+ var viewPath = view.path;
122
+ if (isViewAuth) {
123
+ authResourceViews.push(view);
124
+ }
125
+ if (!isViewAuth) {
126
+ baseResourcePaths.push(viewPath);
127
+ }
128
+ return {
129
+ route: route,
130
+ isViewAuth: isViewAuth
131
+ };
132
+ };
133
+ // 页面
134
+ views.forEach(function (view) {
135
+ var route = traverseViews(view).route;
136
+ routes.push(route);
137
+ if (view.isIndex) {
138
+ routes.push({
139
+ path: '/',
140
+ redirect: "'/" + view.name + "'"
141
+ });
142
+ }
143
+ });
144
+ var authResourcePathMap = {};
145
+ // 默认跳转子页面开启权限的情况,需要把父页面也都加入权限校验列表
146
+ if (Array.isArray(authResourceViews)) {
147
+ authResourceViews.forEach(function (authResourceView) {
148
+ if (authResourceView) {
149
+ authResourcePathMap[authResourceView.path] = true;
150
+ var viewNode = authResourceView;
151
+ while (viewNode.concept === 'View' && viewNode.isIndex) {
152
+ var parentViewNode = viewNode.parentNode;
153
+ if (parentViewNode.concept === 'View') {
154
+ authResourcePathMap[parentViewNode.path] = true;
155
+ }
156
+ else { // viewNode是根页面
157
+ authResourcePathMap['/'] = true;
158
+ }
159
+ viewNode = parentViewNode;
160
+ }
161
+ }
162
+ });
163
+ }
164
+ var authResourcePaths = Object.keys(authResourcePathMap);
165
+ function routeToString(route) {
166
+ var _a, _b;
167
+ var content = "{\n path: '" + route.path + "',\n";
168
+ if ((_a = route === null || route === void 0 ? void 0 : route.component) === null || _a === void 0 ? void 0 : _a.script) {
169
+ 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: `" + route.component.template.replace(/[`$]/g, function (m) { return '\\' + m; }) + "`,\n });\n return componentOptions;\n })(),\n";
170
+ }
171
+ if ((_b = route === null || route === void 0 ? void 0 : route.children) === null || _b === void 0 ? void 0 : _b.length) {
172
+ content += "children: [\n " + route.children.map(routeToString).join(',\n') + "\n ],\n";
173
+ }
174
+ if (route === null || route === void 0 ? void 0 : route.redirect) {
175
+ content += "redirect: " + (route === null || route === void 0 ? void 0 : route.redirect) + ",\n";
176
+ }
177
+ content += '}';
178
+ return content;
179
+ }
180
+ var routesStr = '[';
181
+ routes.forEach(function (route) {
182
+ routesStr += routeToString(route) + ",\n";
183
+ });
184
+ if (defaultRoute) {
185
+ routesStr += "{\n path: '*',\n redirect: '" + defaultRoute + "',\n }\n";
186
+ }
187
+ routesStr += ']';
188
+ if (Array.isArray(enums)) {
189
+ dataTypes.push.apply(dataTypes, enums);
190
+ enums.forEach(function (node) {
191
+ var _a = node || {}, name = _a.name, enumItems = _a.enumItems;
192
+ if (node.module) {
193
+ name = "extensions." + node.module.name + ".enums." + name;
194
+ }
195
+ var enumObj = {};
196
+ enumItems.forEach(function (_a) {
197
+ var label = _a.label, value = _a.value;
198
+ enumObj[value] = label;
199
+ });
200
+ enumsMap[name] = enumObj;
201
+ });
202
+ }
203
+ if (Array.isArray(entities)) {
204
+ dataTypes.push.apply(dataTypes, entities);
205
+ entities.forEach(function (entity) {
206
+ var ns = entity.ns;
207
+ if (Array.isArray(ns === null || ns === void 0 ? void 0 : ns.logics)) {
208
+ allLogics.push.apply(allLogics, ns.logics);
209
+ }
210
+ });
211
+ }
212
+ if (Array.isArray(structures)) {
213
+ dataTypes.push.apply(dataTypes, structures);
214
+ }
215
+ dataTypes.forEach(function (node) {
216
+ var _a;
217
+ var namespace = node.getNamespace();
218
+ var id = namespace + "." + node.name;
219
+ dataTypesMap[id] = (_a = node.toJSON) === null || _a === void 0 ? void 0 : _a.call(node);
220
+ });
221
+ [
222
+ {
223
+ namespace: 'nasl.ui',
224
+ list: concepts_1.uiStructures
225
+ },
226
+ {
227
+ namespace: 'nasl.collection',
228
+ list: concepts_1.collectionStructures
229
+ },
230
+ {
231
+ namespace: 'nasl.interface',
232
+ list: concepts_1.interfaceStructures
233
+ },
234
+ {
235
+ namespace: 'nasl.process',
236
+ list: concepts_1.processStructures
237
+ },
238
+ ].forEach(function (item) {
239
+ var _a = item || {}, namespace = _a.namespace, list = _a.list;
240
+ if (Array.isArray(list)) {
241
+ list.forEach(function (node) {
242
+ var _a;
243
+ var id = namespace + "." + node.name;
244
+ dataTypesMap[id] = (_a = node.toJSON) === null || _a === void 0 ? void 0 : _a.call(node);
245
+ });
246
+ }
247
+ });
248
+ if (Array.isArray(logics)) {
249
+ allLogics.push.apply(allLogics, logics);
250
+ }
251
+ allLogics.forEach(function (node) {
252
+ var namespace = node.getNamespace();
253
+ var id = namespace ? namespace + "." + node.name : node.name;
254
+ logicsMap[id] = node.toService();
255
+ });
256
+ processes.forEach(function (process) {
257
+ if (Array.isArray(process.logics)) {
258
+ process.logics.forEach(function (node) {
259
+ var namespace = node.getNamespace();
260
+ var id = namespace ? namespace + "." + node.name : node.name;
261
+ logicsMap[id] = node.toProcessService();
262
+ });
263
+ }
264
+ });
265
+ interfaces.forEach(function (interfaceItem) {
266
+ _custom[interfaceItem.getNamespace() + "." + interfaceItem.name] = interfaceItem.toService();
267
+ });
268
+ var platformConfig = JSON5.stringify({
269
+ appConfig: {
270
+ project: app.name,
271
+ domainName: app.name,
272
+ nuimsDomain: fnNuimsDomain,
273
+ envNuimsDomain: config.envNuimsDomain,
274
+ tenantType: config.tenantType,
275
+ tenantLevel: config.tenantLevel,
276
+ extendedConfig: config.extendedConfig,
277
+ envConfig: {
278
+ lowcodeDomain: fnLowcodeDomain
279
+ },
280
+ tenant: config.tenant,
281
+ documentTitle: app.documentTitle,
282
+ rootViewData: rootViewData
283
+ },
284
+ dnsAddr: app.dnsAddr,
285
+ devDnsAddr: config.devDnsAddr,
286
+ tenant: config.tenant,
287
+ env: config.env,
288
+ hasUserCenter: app.hasUserCenter,
289
+ hasAuth: app.hasAuth,
290
+ authResourcePaths: authResourcePaths,
291
+ baseResourcePaths: baseResourcePaths,
292
+ miniEnable: config.miniEnable
293
+ }, null, 4);
294
+ function collectTypeAnnotation(typeAnnotation) {
295
+ var _a;
296
+ if (typeAnnotation) {
297
+ var _b = typeAnnotation || {}, sortedTypeKey = _b.sortedTypeKey, properties = _b.properties, typeArguments = _b.typeArguments;
298
+ if (!dataTypesMap[sortedTypeKey]) {
299
+ dataTypesMap[sortedTypeKey] = (_a = typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.toJSON) === null || _a === void 0 ? void 0 : _a.call(typeAnnotation);
300
+ }
301
+ if (Array.isArray(properties)) {
302
+ properties.forEach(function (property) {
303
+ collectTypeAnnotation(property === null || property === void 0 ? void 0 : property.typeAnnotation);
304
+ });
305
+ }
306
+ if (Array.isArray(typeArguments)) {
307
+ typeArguments.forEach(function (typeArg) {
308
+ collectTypeAnnotation(typeArg);
309
+ });
310
+ }
311
+ }
312
+ }
313
+ utils.traverse(function (current) {
314
+ var node = (current || {}).node;
315
+ var concept = (node || {}).concept;
316
+ var typeAnnotation;
317
+ if (['Param', 'Variable', 'Return', 'CallFunction', 'CallInterface', 'CallLogic'].includes(concept)) {
318
+ typeAnnotation = node.typeAnnotation || node.__TypeAnnotation;
319
+ }
320
+ collectTypeAnnotation(typeAnnotation);
321
+ }, {
322
+ node: {
323
+ children: views
324
+ }
325
+ }, {
326
+ mode: 'anyObject',
327
+ excludedKeySet: new Set([
328
+ 'parentNode',
329
+ 'sourceMap',
330
+ 'storageJSON',
331
+ 'tsErrorDetail',
332
+ 'NaslAnnotatedJSON',
333
+ 'calledFrom',
334
+ '_events',
335
+ '_collectingList',
336
+ '_historyList',
337
+ ])
338
+ });
339
+ var metaData = JSON5.stringify({
340
+ frontendVariables: frontendVariables,
341
+ dataTypesMap: dataTypesMap,
342
+ enumsMap: enumsMap,
343
+ logicsMap: logicsMap,
344
+ servicesMap: {
345
+ _custom: _custom
346
+ }
347
+ });
348
+ var assetsInfo = app.genAllAssetsInfo(config.STATIC_URL);
349
+ var customNames = JSON5.stringify(assetsInfo.custom.names);
350
+ var content = "(function(){\n ";
351
+ var themeCSS = app.genThemeCSS();
352
+ if (themeCSS) {
353
+ content += "{\n const el = document.createElement('style');\n el.id = 'theme';\n el.innerHTML = `" + themeCSS + "`;\n document.head.appendChild(el);\n }\n ";
354
+ }
355
+ if (app.documentIcon) {
356
+ content += "{\n const link = document.createElement('link');\n link.rel = 'shortcut icon';\n link.href = `" + app.documentIcon + "`;\n document.head.appendChild(link);\n }";
357
+ }
358
+ 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 }";
359
+ content += "\n var platformConfig = " + platformConfig + ";\n var metaData = " + metaData + ";\n var routes = " + routesStr + ";\n\n window.createLcapApp = () => window.appVM = window.cloudAdminDesigner.init(platformConfig.appConfig, platformConfig, routes, metaData);\n window.createLcapApp();\n })();";
360
+ if (config.env === 'dev') {
361
+ // 加载资源js
362
+ var domain = fnLowcodeDomain.slice(fnLowcodeDomain.indexOf('.') + 1);
363
+ var targetUrl = location.origin + "/empty?url=" + domain + "&appid=" + config.appid;
364
+ var str = "\n if(!document.querySelector(\"iframe[name='iframeEmpty']\")){\n var el = document.createElement('iframe');\n el.setAttribute('src', \"" + targetUrl + "\");\n el.setAttribute('name', 'iframeEmpty');\n el.setAttribute('width', 0);\n el.setAttribute('height', 0);\n el.style.borderWidth = 0\n el.style.display= \"block\"\n document.getElementsByTagName('body')[0].appendChild(el);\n document.domain = '" + domain + "'\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 }\n ";
365
+ content += str;
366
+ }
367
+ var bundlePath = config.USER_STATIC_URL + "/" + config.tenant + "/" + app.id + "/" + config.env + "/bundle." + _1.genHash(content) + ".js";
368
+ var bundleSourceMapPath = bundlePath + ".map";
369
+ var bundleMinPath = config.USER_STATIC_URL + "/" + config.tenant + "/" + app.id + "/" + config.env + "/bundle." + _1.genHash(content) + ".min.js";
370
+ var otherJsList = config.miniEnable ? ['//res.wx.qq.com/open/js/jweixin-1.3.2.js'] : [];
371
+ 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";
372
+ var minifyObj;
373
+ // 开发环境加上sourceMap
374
+ if (config.env === 'dev') {
375
+ content = prettier.format(content, {
376
+ parser: 'babel',
377
+ plugins: [parserBabel],
378
+ tabWidth: 4
379
+ });
380
+ minifyObj = UglifyJS.minify((_a = {},
381
+ _a[bundlePath] = content,
382
+ _a), {
383
+ sourceMap: {
384
+ url: bundleSourceMapPath
385
+ }
386
+ });
387
+ }
388
+ else {
389
+ minifyObj = UglifyJS.minify(content);
390
+ }
391
+ var outputs = [
392
+ {
393
+ name: bundleMinPath,
394
+ content: minifyObj.code
395
+ },
396
+ {
397
+ name: config.USER_STATIC_URL + "/" + config.tenant + "/" + app.id + "/" + config.env + "/client.js",
398
+ content: assetsContent
399
+ },
400
+ ];
401
+ // 开发环境加上sourceMap
402
+ if (config.env === 'dev') {
403
+ // map和源文件
404
+ outputs.push({
405
+ name: bundlePath,
406
+ content: content
407
+ }, {
408
+ name: bundleSourceMapPath,
409
+ content: minifyObj.map
410
+ });
411
+ }
412
+ return outputs;
413
+ }
414
+ exports.genBundleFiles = genBundleFiles;