@lcap/nasl 2.18.0-beta.6 → 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.
- package/out/common/BaseNode.js +1 -0
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +63 -46
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -1
- package/out/concepts/CallLogic__.js +26 -11
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +2 -1
- package/out/concepts/Destination__.js +90 -22
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/Logic__.js +6 -7
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchExpression__.d.ts +97 -0
- package/out/concepts/MatchExpression__.js +281 -0
- package/out/concepts/MatchExpression__.js.map +1 -0
- package/out/concepts/ViewElement__.js +1 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +4 -0
- package/out/concepts/View__.js.map +1 -1
- package/out/generator/genBundleFiles.js +27 -181
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -10
- package/out/generator/genMetaData.js +189 -50
- package/out/generator/genMetaData.js.map +1 -1
- package/out/server/extendBaseNode.js +4 -18
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +2 -1
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/naslServer.js +5 -6
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +19 -4
- package/out/server/translator.js.map +1 -1
- package/out/templator/sql-parser/index.d.ts +1 -0
- package/out/templator/sql-parser/index.js +228 -0
- package/out/templator/sql-parser/index.js.map +1 -0
- package/out/templator/sql-parser/parser.js +26664 -0
- package/out/templator/sql-parser/parser.js.map +1 -0
- package/package.json +2 -2
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/nasl.util.ts +1 -1
- package/src/automate/engine/dist/index.dev.js +517 -0
- package/src/common/BaseNode.ts +1 -0
- package/src/common/dist/BaseNode.js +1101 -0
- package/src/concepts/BatchAssignment__.ts +66 -50
- package/src/concepts/CallLogic__.ts +26 -11
- package/src/concepts/Destination__.ts +92 -22
- package/src/concepts/Logic__.ts +6 -7
- package/src/concepts/ViewElement__.ts +8 -29
- package/src/concepts/View__.ts +4 -0
- package/src/concepts/basics/stdlib/dist/nasl.util.js +1503 -0
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
- package/src/concepts/dist/Anchor__.js +179 -0
- package/src/concepts/dist/Assignment__.js +301 -0
- package/src/concepts/dist/CallFunction__.js +513 -0
- package/src/concepts/dist/CallInterface__.js +533 -0
- package/src/concepts/dist/CallLogic__.js +892 -0
- package/src/concepts/dist/ForEachStatement__.js +426 -0
- package/src/concepts/dist/MatchCase__.js +587 -0
- package/src/concepts/dist/Match__.js +631 -0
- package/src/concepts/dist/MemberExpression__.js +348 -0
- package/src/concepts/dist/Param__.js +538 -0
- package/src/concepts/dist/Return__.js +494 -0
- package/src/concepts/dist/Variable__.js +537 -0
- package/src/concepts/dist/ViewElement__.js +1680 -0
- package/src/generator/dist/genBundleFiles.js +261 -0
- package/src/generator/dist/genMetaData.js +249 -0
- package/src/generator/genBundleFiles.ts +29 -218
- package/src/generator/genMetaData.ts +182 -77
- package/src/server/dist/formatTsUtils.js +683 -0
- package/src/server/dist/naslServer.js +3474 -0
- package/src/server/extendBaseNode.ts +4 -19
- package/src/server/formatTsUtils.ts +2 -1
- package/src/server/naslServer.ts +5 -6
- package/src/server/translator.ts +18 -4
- package/src/service/storage/dist/init.js +572 -0
- package/ts-worker/dist/webpack.config.dev.js +108 -0
- package/dist/bundle.js +0 -3962
- package/dist/bundle.js.LICENSE.txt +0 -16
- package/out/generator/release.d.ts +0 -1
- package/out/generator/release.js +0 -51
- package/out/generator/release.js.map +0 -1
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
App, Module, View, Entity, Structure, Enum,
|
|
3
|
-
uiStructures, collectionStructures, interfaceStructures, processStructures,
|
|
4
|
-
Logic, Interface, Process,
|
|
5
|
-
} from '../concepts';
|
|
1
|
+
import { App, Module, View } from '../concepts';
|
|
6
2
|
import * as utils from '../utils';
|
|
7
3
|
import { genHash, RawOptions } from '.';
|
|
8
4
|
import { compileComponent } from './compileComponent';
|
|
@@ -13,6 +9,8 @@ import parserBabel = require('prettier/parser-babel');
|
|
|
13
9
|
|
|
14
10
|
import * as UglifyJS from 'uglify-js-export';
|
|
15
11
|
|
|
12
|
+
import { genMetaData } from './genMetaData';
|
|
13
|
+
|
|
16
14
|
export interface Route {
|
|
17
15
|
path?: string;
|
|
18
16
|
component?: RawOptions; // ExtendedVue<Vue, unknown, unknown, unknown, Record<never, any>>;
|
|
@@ -41,42 +39,11 @@ export function genBundleFiles(app: App,
|
|
|
41
39
|
const fnLowcodeDomain = config?.envLcpDomain?.[config?.env]?.lcpDomain || config?.lowcodeDomain;
|
|
42
40
|
const modules: Module[] = [];
|
|
43
41
|
const views: View[] = [];
|
|
44
|
-
const entities: Entity[] = [];
|
|
45
|
-
const structures: Structure[] = [];
|
|
46
|
-
const enums: Enum[] = [];
|
|
47
|
-
const logics: Logic[] = [];
|
|
48
|
-
const interfaces: Interface[] = [];
|
|
49
|
-
const processes: Process[] = [];
|
|
50
|
-
|
|
51
|
-
app.views && views.push(...app.views);
|
|
52
|
-
if (Array.isArray(app.dataSources)) {
|
|
53
|
-
app.dataSources.forEach((dataSource) => {
|
|
54
|
-
if (Array.isArray(dataSource.entities)) {
|
|
55
|
-
entities.push(...dataSource.entities);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
app.structures && structures.push(...app.structures);
|
|
60
|
-
app.enums && enums.push(...app.enums);
|
|
61
|
-
app.logics && logics.push(...app.logics);
|
|
62
|
-
app.processes && processes.push(...app.processes);
|
|
63
|
-
|
|
64
42
|
app.dependencies && modules.push(...app.dependencies);
|
|
65
43
|
app.interfaceDependencies && modules.push(...app.interfaceDependencies);
|
|
66
|
-
|
|
44
|
+
app.views && views.push(...app.views);
|
|
67
45
|
modules.forEach((module: Module) => {
|
|
68
46
|
module.views && views.push(...module.views);
|
|
69
|
-
module.structures && structures.push(...module.structures);
|
|
70
|
-
module.enums && enums.push(...module.enums);
|
|
71
|
-
module.logics && logics.push(...module.logics);
|
|
72
|
-
module.interfaces && interfaces.push(...module.interfaces);
|
|
73
|
-
if (Array.isArray(module.dataSources)) {
|
|
74
|
-
module.dataSources.forEach((dataSource) => {
|
|
75
|
-
if (Array.isArray(dataSource.entities)) {
|
|
76
|
-
entities.push(...dataSource.entities);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
47
|
});
|
|
81
48
|
|
|
82
49
|
const componentMap: {
|
|
@@ -95,31 +62,6 @@ export function genBundleFiles(app: App,
|
|
|
95
62
|
* vue.config.js page options
|
|
96
63
|
*/
|
|
97
64
|
const routes: Route[] = [];
|
|
98
|
-
const dataTypes: (Entity | Structure | Enum)[] = [];
|
|
99
|
-
const dataTypesMap: {
|
|
100
|
-
[id: string]: Object;
|
|
101
|
-
} = {};
|
|
102
|
-
const frontendVariables = app.frontendVariables;
|
|
103
|
-
const enumsMap: {
|
|
104
|
-
[name: string]: {
|
|
105
|
-
[label: string]: string;
|
|
106
|
-
};
|
|
107
|
-
} = {};
|
|
108
|
-
const logicsMap: {
|
|
109
|
-
[id: string]: {
|
|
110
|
-
config: {
|
|
111
|
-
serviceType: string;
|
|
112
|
-
};
|
|
113
|
-
url: {
|
|
114
|
-
method: string;
|
|
115
|
-
path: string;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
} = {};
|
|
119
|
-
const _custom: {
|
|
120
|
-
[id: string]: any;
|
|
121
|
-
} = {};
|
|
122
|
-
const allLogics: Logic[] = [];
|
|
123
65
|
// 开启了权限的页面
|
|
124
66
|
const authResourceViews: View[] = [];
|
|
125
67
|
const baseResourcePaths: string[] = [];
|
|
@@ -254,93 +196,6 @@ export function genBundleFiles(app: App,
|
|
|
254
196
|
}
|
|
255
197
|
routesStr += ']';
|
|
256
198
|
|
|
257
|
-
if (Array.isArray(enums)) {
|
|
258
|
-
dataTypes.push(...enums);
|
|
259
|
-
enums.forEach((node) => {
|
|
260
|
-
let { name, enumItems } = node || {};
|
|
261
|
-
if (node.module) {
|
|
262
|
-
name = `extensions.${node.module.name}.enums.${name}`;
|
|
263
|
-
}
|
|
264
|
-
const enumObj: {
|
|
265
|
-
[value: string]: string;
|
|
266
|
-
} = {};
|
|
267
|
-
enumItems.forEach(({ label, value }) => {
|
|
268
|
-
enumObj[value] = label;
|
|
269
|
-
});
|
|
270
|
-
enumsMap[name] = enumObj;
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (Array.isArray(entities)) {
|
|
275
|
-
dataTypes.push(...entities);
|
|
276
|
-
entities.forEach((entity) => {
|
|
277
|
-
const ns = entity.ns;
|
|
278
|
-
if (Array.isArray(ns?.logics)) {
|
|
279
|
-
allLogics.push(...ns.logics);
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
if (Array.isArray(structures)) {
|
|
284
|
-
dataTypes.push(...structures);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
dataTypes.forEach((node) => {
|
|
288
|
-
const namespace = node.getNamespace();
|
|
289
|
-
const id = `${namespace}.${node.name}`;
|
|
290
|
-
dataTypesMap[id] = node.toJSON?.();
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
[
|
|
294
|
-
{
|
|
295
|
-
namespace: 'nasl.ui',
|
|
296
|
-
list: uiStructures,
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
namespace: 'nasl.collection',
|
|
300
|
-
list: collectionStructures,
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
namespace: 'nasl.interface',
|
|
304
|
-
list: interfaceStructures,
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
namespace: 'nasl.process',
|
|
308
|
-
list: processStructures,
|
|
309
|
-
},
|
|
310
|
-
].forEach((item) => {
|
|
311
|
-
const { namespace, list } = item || {};
|
|
312
|
-
if (Array.isArray(list)) {
|
|
313
|
-
list.forEach((node) => {
|
|
314
|
-
const id = `${namespace}.${node.name}`;
|
|
315
|
-
dataTypesMap[id] = node.toJSON?.();
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
if (Array.isArray(logics)) {
|
|
321
|
-
allLogics.push(...logics);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
allLogics.forEach((node) => {
|
|
325
|
-
const namespace = node.getNamespace();
|
|
326
|
-
const id = namespace ? `${namespace}.${node.name}` : node.name;
|
|
327
|
-
logicsMap[id] = node.toService();
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
processes.forEach((process) => {
|
|
331
|
-
if (Array.isArray(process.logics)) {
|
|
332
|
-
process.logics.forEach((node) => {
|
|
333
|
-
const namespace = node.getNamespace();
|
|
334
|
-
const id = namespace ? `${namespace}.${node.name}` : node.name;
|
|
335
|
-
logicsMap[id] = node.toProcessService();
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
interfaces.forEach((interfaceItem: Interface) => {
|
|
341
|
-
_custom[`${interfaceItem.getNamespace()}.${interfaceItem.name}`] = interfaceItem.toService();
|
|
342
|
-
});
|
|
343
|
-
|
|
344
199
|
const platformConfig = JSON5.stringify({
|
|
345
200
|
appConfig: {
|
|
346
201
|
project: app.name,
|
|
@@ -368,61 +223,8 @@ export function genBundleFiles(app: App,
|
|
|
368
223
|
miniEnable: config.miniEnable,
|
|
369
224
|
}, null, 4);
|
|
370
225
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
const { sortedTypeKey, properties, typeArguments } = typeAnnotation || {};
|
|
374
|
-
if (!dataTypesMap[sortedTypeKey]) {
|
|
375
|
-
dataTypesMap[sortedTypeKey] = typeAnnotation?.toJSON?.();
|
|
376
|
-
}
|
|
377
|
-
if (Array.isArray(properties)) {
|
|
378
|
-
properties.forEach((property) => {
|
|
379
|
-
collectTypeAnnotation(property?.typeAnnotation);
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
if (Array.isArray(typeArguments)) {
|
|
383
|
-
typeArguments.forEach((typeArg) => {
|
|
384
|
-
collectTypeAnnotation(typeArg);
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
utils.traverse((current) => {
|
|
391
|
-
const { node } = current || {};
|
|
392
|
-
const { concept } = node || {};
|
|
393
|
-
let typeAnnotation;
|
|
394
|
-
if (['Param', 'Variable', 'Return', 'CallFunction', 'CallInterface', 'CallLogic'].includes(concept)) {
|
|
395
|
-
typeAnnotation = node.typeAnnotation || node.__TypeAnnotation;
|
|
396
|
-
}
|
|
397
|
-
collectTypeAnnotation(typeAnnotation);
|
|
398
|
-
}, {
|
|
399
|
-
node: {
|
|
400
|
-
children: views,
|
|
401
|
-
} as any,
|
|
402
|
-
}, {
|
|
403
|
-
mode: 'anyObject',
|
|
404
|
-
excludedKeySet: new Set([
|
|
405
|
-
'parentNode',
|
|
406
|
-
'sourceMap',
|
|
407
|
-
'storageJSON',
|
|
408
|
-
'tsErrorDetail',
|
|
409
|
-
'NaslAnnotatedJSON',
|
|
410
|
-
'calledFrom',
|
|
411
|
-
'_events',
|
|
412
|
-
'_collectingList',
|
|
413
|
-
'_historyList',
|
|
414
|
-
]),
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
const metaData = JSON5.stringify({
|
|
418
|
-
frontendVariables,
|
|
419
|
-
dataTypesMap,
|
|
420
|
-
enumsMap,
|
|
421
|
-
logicsMap,
|
|
422
|
-
servicesMap: {
|
|
423
|
-
_custom,
|
|
424
|
-
},
|
|
425
|
-
});
|
|
226
|
+
const metaData = genMetaData(app);
|
|
227
|
+
const metaDataStr = JSON5.stringify(metaData);
|
|
426
228
|
|
|
427
229
|
const assetsInfo = app.genAllAssetsInfo(config.STATIC_URL);
|
|
428
230
|
const customNames = JSON5.stringify(assetsInfo.custom.names);
|
|
@@ -460,7 +262,7 @@ export function genBundleFiles(app: App,
|
|
|
460
262
|
|
|
461
263
|
content += `
|
|
462
264
|
var platformConfig = ${platformConfig};
|
|
463
|
-
var metaData = ${
|
|
265
|
+
var metaData = ${metaDataStr};
|
|
464
266
|
var routes = ${routesStr};
|
|
465
267
|
|
|
466
268
|
window.createLcapApp = () => window.appVM = window.cloudAdminDesigner.init(platformConfig.appConfig, platformConfig, routes, metaData);
|
|
@@ -469,19 +271,19 @@ export function genBundleFiles(app: App,
|
|
|
469
271
|
|
|
470
272
|
if (config.env === 'dev') {
|
|
471
273
|
// 加载资源js
|
|
472
|
-
const domain = fnLowcodeDomain.slice(fnLowcodeDomain.indexOf('.') + 1);
|
|
473
|
-
const targetUrl = `${typeof location !== 'undefined' ? location.origin : `http://${config.tenant}.${fnLowcodeDomain}`}/empty?url=${domain}&appid=${config.appid}`;
|
|
274
|
+
// const domain = fnLowcodeDomain.slice(fnLowcodeDomain.indexOf('.') + 1);
|
|
275
|
+
// const targetUrl = `${typeof location !== 'undefined' ? location.origin : `http://${config.tenant}.${fnLowcodeDomain}`}/empty?url=${domain}&appid=${config.appid}`;
|
|
276
|
+
// if(!document.querySelector("iframe[name='iframeEmpty']")){
|
|
277
|
+
// var el = document.createElement('iframe');
|
|
278
|
+
// el.setAttribute('src', "${targetUrl}");
|
|
279
|
+
// el.setAttribute('name', 'iframeEmpty');
|
|
280
|
+
// el.setAttribute('width', 0);
|
|
281
|
+
// el.setAttribute('height', 0);
|
|
282
|
+
// el.style.borderWidth = 0
|
|
283
|
+
// el.style.display= "block"
|
|
284
|
+
// document.getElementsByTagName('body')[0].appendChild(el);
|
|
285
|
+
// document.domain = '${domain}'
|
|
474
286
|
const str = `
|
|
475
|
-
if(!document.querySelector("iframe[name='iframeEmpty']")){
|
|
476
|
-
var el = document.createElement('iframe');
|
|
477
|
-
el.setAttribute('src', "${targetUrl}");
|
|
478
|
-
el.setAttribute('name', 'iframeEmpty');
|
|
479
|
-
el.setAttribute('width', 0);
|
|
480
|
-
el.setAttribute('height', 0);
|
|
481
|
-
el.style.borderWidth = 0
|
|
482
|
-
el.style.display= "block"
|
|
483
|
-
document.getElementsByTagName('body')[0].appendChild(el);
|
|
484
|
-
document.domain = '${domain}'
|
|
485
287
|
var _div = document.createElement('div');
|
|
486
288
|
_div.classList = "div-load"
|
|
487
289
|
_div.innerHTML = "<div class='loading-container'></div><div>正在更新最新发布内容...</div>"
|
|
@@ -531,7 +333,16 @@ export function genBundleFiles(app: App,
|
|
|
531
333
|
}
|
|
532
334
|
}\`
|
|
533
335
|
document.getElementsByTagName('body')[0].appendChild(style);
|
|
534
|
-
|
|
336
|
+
window.addEventListener('message', function (e) {
|
|
337
|
+
console.log('message:',e)
|
|
338
|
+
if(e.data ==="release-start"){
|
|
339
|
+
showLoading()
|
|
340
|
+
}
|
|
341
|
+
if(e.data==="release-end"){
|
|
342
|
+
hideLoading()
|
|
343
|
+
window.location.reload();
|
|
344
|
+
}
|
|
345
|
+
})
|
|
535
346
|
`;
|
|
536
347
|
content += str;
|
|
537
348
|
}
|
|
@@ -1,58 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
App, Module, View, Entity, Structure, Enum,
|
|
3
|
+
uiStructures, collectionStructures, interfaceStructures, processStructures,
|
|
4
|
+
Logic, Interface, Process, BaseNode,
|
|
5
|
+
} from '../concepts';
|
|
6
|
+
import * as utils from '../utils';
|
|
7
|
+
|
|
8
|
+
// 生成typeKey
|
|
9
|
+
function genSortedTypeKey(typeAnnotation: any) {
|
|
10
|
+
const {
|
|
11
|
+
typeKind, typeNamespace, typeName,
|
|
12
|
+
typeArguments, properties,
|
|
13
|
+
} = typeAnnotation || {};
|
|
14
|
+
const typeKeyArr = [];
|
|
15
|
+
if (typeKind === 'union') { // 联合类型
|
|
16
|
+
if (Array.isArray(typeArguments)) {
|
|
17
|
+
// 按返回的每个具体项排序
|
|
18
|
+
const childTypeArgs: any = typeArguments.map((typeArg) => genSortedTypeKey(typeArg)).sort((name1, name2) => name1 > name2 ? 1 : -1);
|
|
19
|
+
typeKeyArr.push(childTypeArgs.join(' | '));
|
|
20
|
+
}
|
|
21
|
+
} else if (typeKind === 'anonymousStructure') { // 匿名数据结构
|
|
22
|
+
typeKeyArr.push('{');
|
|
23
|
+
if (Array.isArray(properties)) {
|
|
24
|
+
// 按匿名数据结构的key排序
|
|
25
|
+
const childTypeArgs: any = properties.sort(({ name: name1 }, { name: name2 }) => name1 > name2 ? 1 : -1).map((typeArg) => {
|
|
26
|
+
const { name: typeArgName, typeAnnotation: typeArgTypeAnnotation } = typeArg || {};
|
|
27
|
+
return `${typeArgName}: ${genSortedTypeKey(typeArgTypeAnnotation)}`;
|
|
28
|
+
});
|
|
29
|
+
typeKeyArr.push(childTypeArgs.join(', '));
|
|
30
|
+
}
|
|
31
|
+
typeKeyArr.push('}');
|
|
32
|
+
} else {
|
|
33
|
+
const typeArr = [];
|
|
34
|
+
typeNamespace && typeArr.push(typeNamespace);
|
|
35
|
+
typeName && typeArr.push(typeName);
|
|
36
|
+
const typeKey = typeArr.join('.');
|
|
37
|
+
typeKey && typeKeyArr.push(typeKey);
|
|
38
|
+
if (typeKind === 'generic') {
|
|
39
|
+
typeKeyArr.push('<');
|
|
40
|
+
if (Array.isArray(typeArguments)) {
|
|
41
|
+
// 必须按typeArguments定义的顺序,否则实参位置不对
|
|
42
|
+
const childTypeArgs: any = typeArguments.map((typeArg) => genSortedTypeKey(typeArg));
|
|
43
|
+
typeKeyArr.push(childTypeArgs.join(', '));
|
|
44
|
+
}
|
|
45
|
+
typeKeyArr.push('>');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return typeKeyArr.join('');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function genMetaData(app: App) {
|
|
14
52
|
const modules: Module[] = [];
|
|
15
53
|
const views: View[] = [];
|
|
16
|
-
const
|
|
54
|
+
const entities: Entity[] = [];
|
|
17
55
|
const structures: Structure[] = [];
|
|
18
56
|
const enums: Enum[] = [];
|
|
19
57
|
const logics: Logic[] = [];
|
|
20
58
|
const interfaces: Interface[] = [];
|
|
21
59
|
const processes: Process[] = [];
|
|
22
60
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
processes: appProcesses = [],
|
|
31
|
-
} = app || {};
|
|
32
|
-
dataSources.push(...appDataSources);
|
|
33
|
-
structures.push(...appStructures);
|
|
34
|
-
enums.push(...appEnums);
|
|
35
|
-
logics.push(...appLogics);
|
|
36
|
-
processes.push(...appProcesses);
|
|
37
|
-
if (Array.isArray(appDependencies)) {
|
|
38
|
-
modules.push(...appDependencies);
|
|
39
|
-
}
|
|
40
|
-
if (Array.isArray(appInterfaceDependencies)) {
|
|
41
|
-
modules.push(...appInterfaceDependencies);
|
|
61
|
+
app.views && views.push(...app.views);
|
|
62
|
+
if (Array.isArray(app.dataSources)) {
|
|
63
|
+
app.dataSources.forEach((dataSource) => {
|
|
64
|
+
if (Array.isArray(dataSource.entities)) {
|
|
65
|
+
entities.push(...dataSource.entities);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
42
68
|
}
|
|
69
|
+
app.structures && structures.push(...app.structures);
|
|
70
|
+
app.enums && enums.push(...app.enums);
|
|
71
|
+
app.logics && logics.push(...app.logics);
|
|
72
|
+
app.processes && processes.push(...app.processes);
|
|
73
|
+
|
|
74
|
+
app.dependencies && modules.push(...app.dependencies);
|
|
75
|
+
app.interfaceDependencies && modules.push(...app.interfaceDependencies);
|
|
76
|
+
|
|
43
77
|
modules.forEach((module: Module) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
78
|
+
module.views && views.push(...module.views);
|
|
79
|
+
module.structures && structures.push(...module.structures);
|
|
80
|
+
module.enums && enums.push(...module.enums);
|
|
81
|
+
module.logics && logics.push(...module.logics);
|
|
82
|
+
module.interfaces && interfaces.push(...module.interfaces);
|
|
83
|
+
if (Array.isArray(module.dataSources)) {
|
|
84
|
+
module.dataSources.forEach((dataSource) => {
|
|
85
|
+
if (Array.isArray(dataSource.entities)) {
|
|
86
|
+
entities.push(...dataSource.entities);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
56
90
|
});
|
|
57
91
|
const dataTypes: (Entity | Structure | Enum)[] = [];
|
|
58
92
|
|
|
@@ -80,6 +114,7 @@ export function genMetaData(app: App,
|
|
|
80
114
|
[id: string]: any;
|
|
81
115
|
} = {};
|
|
82
116
|
const allLogics: Logic[] = [];
|
|
117
|
+
|
|
83
118
|
if (Array.isArray(enums)) {
|
|
84
119
|
dataTypes.push(...enums);
|
|
85
120
|
enums.forEach((node) => {
|
|
@@ -96,17 +131,17 @@ export function genMetaData(app: App,
|
|
|
96
131
|
enumsMap[name] = enumObj;
|
|
97
132
|
});
|
|
98
133
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
134
|
+
|
|
135
|
+
if (Array.isArray(entities)) {
|
|
136
|
+
dataTypes.push(...entities);
|
|
137
|
+
entities.forEach((entity) => {
|
|
138
|
+
const ns = entity.ns;
|
|
139
|
+
if (Array.isArray(ns?.logics)) {
|
|
140
|
+
allLogics.push(...ns.logics);
|
|
141
|
+
}
|
|
108
142
|
});
|
|
109
143
|
}
|
|
144
|
+
|
|
110
145
|
if (Array.isArray(structures)) {
|
|
111
146
|
dataTypes.push(...structures);
|
|
112
147
|
}
|
|
@@ -114,31 +149,47 @@ export function genMetaData(app: App,
|
|
|
114
149
|
dataTypes.forEach((node) => {
|
|
115
150
|
const namespace = node.getNamespace();
|
|
116
151
|
const id = `${namespace}.${node.name}`;
|
|
117
|
-
dataTypesMap[id] = node;
|
|
152
|
+
dataTypesMap[id] = node.toJSON?.();
|
|
153
|
+
const { properties } = (node) as any;
|
|
154
|
+
if (Array.isArray(properties)) {
|
|
155
|
+
properties.forEach((property) => {
|
|
156
|
+
collectTypeAnnotation(property?.typeAnnotation);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
118
159
|
});
|
|
119
|
-
if (Array.isArray(uiStructures)) {
|
|
120
|
-
const namespace = 'nasl.ui';
|
|
121
|
-
uiStructures.forEach((node) => {
|
|
122
|
-
const id = `${namespace}.${node.name}`;
|
|
123
|
-
dataTypesMap[id] = node;
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
160
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
161
|
+
[
|
|
162
|
+
{
|
|
163
|
+
namespace: 'nasl.ui',
|
|
164
|
+
list: uiStructures,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
namespace: 'nasl.collection',
|
|
168
|
+
list: collectionStructures,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
namespace: 'nasl.interface',
|
|
172
|
+
list: interfaceStructures,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
namespace: 'nasl.process',
|
|
176
|
+
list: processStructures,
|
|
177
|
+
},
|
|
178
|
+
].forEach((item) => {
|
|
179
|
+
const { namespace, list } = item || {};
|
|
180
|
+
if (Array.isArray(list)) {
|
|
181
|
+
list.forEach((node) => {
|
|
182
|
+
const id = `${namespace}.${node.name}`;
|
|
183
|
+
dataTypesMap[id] = node.toJSON?.();
|
|
184
|
+
const { properties } = (node) as any;
|
|
185
|
+
if (Array.isArray(properties)) {
|
|
186
|
+
properties.forEach((property) => {
|
|
187
|
+
collectTypeAnnotation(property?.typeAnnotation);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
});
|
|
142
193
|
|
|
143
194
|
if (Array.isArray(logics)) {
|
|
144
195
|
allLogics.push(...logics);
|
|
@@ -164,6 +215,60 @@ export function genMetaData(app: App,
|
|
|
164
215
|
_custom[`${interfaceItem.getNamespace()}.${interfaceItem.name}`] = interfaceItem.toService();
|
|
165
216
|
});
|
|
166
217
|
|
|
218
|
+
utils.traverse((current) => {
|
|
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);
|
|
226
|
+
}, {
|
|
227
|
+
node: {
|
|
228
|
+
children: views,
|
|
229
|
+
} as any,
|
|
230
|
+
}, {
|
|
231
|
+
mode: 'anyObject',
|
|
232
|
+
excludedKeySet: new Set([
|
|
233
|
+
'parentNode',
|
|
234
|
+
'sourceMap',
|
|
235
|
+
'storageJSON',
|
|
236
|
+
'tsErrorDetail',
|
|
237
|
+
'NaslAnnotatedJSON',
|
|
238
|
+
'calledFrom',
|
|
239
|
+
'_events',
|
|
240
|
+
'_collectingList',
|
|
241
|
+
'_historyList',
|
|
242
|
+
]),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
if (Array.isArray(frontendVariables)) {
|
|
246
|
+
frontendVariables.forEach((frontendVariable) => {
|
|
247
|
+
const typeAnnotation = frontendVariable.typeAnnotation || frontendVariable.__TypeAnnotation;
|
|
248
|
+
collectTypeAnnotation(typeAnnotation);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function collectTypeAnnotation(typeAnnotation: any) {
|
|
253
|
+
if (typeAnnotation) {
|
|
254
|
+
const sortedTypeKey = genSortedTypeKey(typeAnnotation);
|
|
255
|
+
if (!dataTypesMap[sortedTypeKey]) {
|
|
256
|
+
dataTypesMap[sortedTypeKey] = typeAnnotation?.toJSON?.() ?? typeAnnotation;
|
|
257
|
+
const { properties, typeArguments } = (dataTypesMap[sortedTypeKey] || {}) as any;
|
|
258
|
+
if (Array.isArray(properties)) {
|
|
259
|
+
properties.forEach((property) => {
|
|
260
|
+
collectTypeAnnotation(property?.typeAnnotation);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
if (Array.isArray(typeArguments)) {
|
|
264
|
+
typeArguments.forEach((typeArg) => {
|
|
265
|
+
collectTypeAnnotation(typeArg);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
167
272
|
return {
|
|
168
273
|
frontendVariables,
|
|
169
274
|
dataTypesMap,
|