@lcap/nasl 3.8.2-alpha.2 → 3.8.2-alpha.4
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/ComponentAPI.d.ts +9 -0
- package/out/concepts/AuthLogicForCallInterface__.js +21 -6
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +11 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BusinessComponent__.js +24 -8
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +21 -6
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallInterface__.js +2 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +1 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Logic__.js +43 -16
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +19 -13
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +21 -6
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.js +5 -4
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Structure__.js +4 -4
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/ViewElement__.js +0 -5
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +50 -19
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js +78 -0
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/generator/genBundleFiles.js +1 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +10 -5
- package/out/natural/genNaturalTS.js +34 -25
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/getUILib.js +6 -3
- package/out/natural/getContext/getUILib.js.map +1 -1
- package/out/natural/getContext/index.d.ts +5 -2
- package/out/natural/getContext/index.js +105 -12
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/getContext/naslStdlibMap.js +8 -8
- package/out/natural/getContext/naslStdlibMap.js.map +1 -1
- package/out/natural/tools.d.ts +16 -0
- package/out/natural/tools.js +103 -1
- package/out/natural/tools.js.map +1 -1
- package/out/server/getMemberIdentifier.js +11 -17
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.js +1 -1
- package/out/server/naslServer.js.map +1 -1
- package/out/translator/types.d.ts +2 -0
- package/package.json +1 -1
- package/sandbox/stdlib/nasl.processV2.ts +19 -0
- package/sandbox-natural/stdlib/nasl.core.d.ts +54 -0
- package/sandbox-natural/stdlib/nasl.oql.d.ts +22 -0
- package/sandbox-natural/stdlib/{nasl.ui.pre.d.ts → nasl.ui.d.ts} +20 -44
- package/sandbox-natural/stdlib/nasl.ui.h5.d.ts +1684 -1643
- package/sandbox-natural/stdlib/nasl.ui.h5.json +15746 -15045
- package/sandbox-natural/stdlib/nasl.ui.pc.d.ts +5341 -5154
- package/sandbox-natural/stdlib/nasl.ui.pc.json +31176 -30681
- package/sandbox-natural/stdlib/{nasl.util.ts → nasl.util.d.ts} +43 -37
- package/src/common/ComponentAPI.ts +7 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +23 -6
- package/src/concepts/BindAttribute__.ts +17 -12
- package/src/concepts/BusinessComponent__.ts +26 -8
- package/src/concepts/BusinessLogic__.ts +23 -6
- package/src/concepts/CallInterface__.ts +2 -2
- package/src/concepts/CallLogic__.ts +1 -1
- package/src/concepts/Logic__.ts +58 -32
- package/src/concepts/MemberExpression__.ts +20 -13
- package/src/concepts/OverriddenLogic__.ts +23 -6
- package/src/concepts/Param__.ts +5 -4
- package/src/concepts/Structure__.ts +4 -4
- package/src/concepts/ViewElement__.ts +1 -7
- package/src/concepts/View__.ts +55 -21
- package/src/concepts/basics/stdlib/nasl.processV2.ts +79 -0
- package/src/generator/genBundleFiles.ts +1 -1
- package/src/natural/genNaturalTS.ts +43 -27
- package/src/natural/getContext/getUILib.ts +6 -3
- package/src/natural/getContext/index.ts +85 -10
- package/src/natural/getContext/naslStdlibMap.ts +8 -8
- package/src/natural/tools.ts +100 -1
- package/src/server/getMemberIdentifier.ts +14 -14
- package/src/server/naslServer.ts +1 -1
- package/src/translator/types.ts +2 -0
- package/test/concepts/member-expression/__snapshots__/toJS.spec.ts.snap +1 -1
- package/test/concepts/member-expression/__snapshots__/toVue.spec.ts.snap +1 -1
- package/sandbox-natural/stdlib/nasl.core.ts +0 -47
- package/sandbox-natural/stdlib/nasl.oql.ts +0 -14
- package/sandbox-natural/stdlib/nasl.ui.ts +0 -63
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
withGenerator,
|
|
9
9
|
TranslatorGenerator,
|
|
10
10
|
} from '../translator';
|
|
11
|
-
import {
|
|
11
|
+
import { Enum, TypeAnnotation, BusinessComponent, View } from '..';
|
|
12
12
|
import { ElementToVueOptions } from './ViewElement__';
|
|
13
13
|
import type Identifier from './Identifier__';
|
|
14
14
|
import BindAttribute, { attrConvertCamelCase } from './BindAttribute__';
|
|
15
15
|
import type Assignment from './Assignment__';
|
|
16
16
|
import type BatchAssignment from './BatchAssignment__';
|
|
17
17
|
import DefaultValue from './DefaultValue__';
|
|
18
|
+
import { config } from '../config';
|
|
18
19
|
|
|
19
20
|
const Identifier_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
20
21
|
|
|
@@ -138,11 +139,13 @@ export class MemberExpression extends LogicItem {
|
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
if (
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
config?.allNodesAPI &&
|
|
143
|
+
config?.allNodesAPI[elementTag] &&
|
|
144
|
+
config?.allNodesAPI[elementTag].readablePropsMap &&
|
|
145
|
+
config?.allNodesAPI[elementTag].readablePropsMap[this.property.name] &&
|
|
146
|
+
config?.allNodesAPI[elementTag].readablePropsMap[this.property.name].state
|
|
144
147
|
) {
|
|
145
|
-
const { prop } =
|
|
148
|
+
const { prop } = config?.allNodesAPI[elementTag].readablePropsMap[this.property.name];
|
|
146
149
|
if (!['data'].includes(this.property.name)) {
|
|
147
150
|
return `this && this.__${elementName}_params && this.__${elementName}_params.${this.property.name}`;
|
|
148
151
|
}
|
|
@@ -263,11 +266,13 @@ export class MemberExpression extends LogicItem {
|
|
|
263
266
|
}
|
|
264
267
|
|
|
265
268
|
if (
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
+
config?.allNodesAPI &&
|
|
270
|
+
config?.allNodesAPI[elementTag] &&
|
|
271
|
+
config?.allNodesAPI[elementTag].readablePropsMap &&
|
|
272
|
+
config?.allNodesAPI[elementTag].readablePropsMap[this.property.name] &&
|
|
273
|
+
config?.allNodesAPI[elementTag].readablePropsMap[this.property.name].state
|
|
269
274
|
) {
|
|
270
|
-
const { prop } =
|
|
275
|
+
const { prop } = config?.allNodesAPI[elementTag].readablePropsMap[this.property.name];
|
|
271
276
|
|
|
272
277
|
if (!['data'].includes(this.property.name)) {
|
|
273
278
|
return `this['__${elementName}_params'] && this['__${elementName}_params'].${this.property.name}`;
|
|
@@ -422,11 +427,13 @@ export class MemberExpression extends LogicItem {
|
|
|
422
427
|
const prefix = type === 'toVue' ? '' : 'this.';
|
|
423
428
|
|
|
424
429
|
if (
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
430
|
+
config?.allNodesAPI &&
|
|
431
|
+
config?.allNodesAPI[elementTag] &&
|
|
432
|
+
config?.allNodesAPI[elementTag].readablePropsMap &&
|
|
433
|
+
config?.allNodesAPI[elementTag].readablePropsMap[this.property.name] &&
|
|
434
|
+
config?.allNodesAPI[elementTag].readablePropsMap[this.property.name].state
|
|
428
435
|
) {
|
|
429
|
-
const { prop } =
|
|
436
|
+
const { prop } = config?.allNodesAPI[elementTag].readablePropsMap[this.property.name];
|
|
430
437
|
|
|
431
438
|
if (!['data'].includes(this.property.name)) {
|
|
432
439
|
return `${prefix}__${elementName}_params && ${prefix}__${elementName}_params.${this.property.name}`;
|
|
@@ -1769,22 +1769,39 @@ export class OverriddenLogic extends BaseNode {
|
|
|
1769
1769
|
],
|
|
1770
1770
|
function* warpForEachGenerator({ key, node: itemNode }) {
|
|
1771
1771
|
if (itemNode) {
|
|
1772
|
-
code += `
|
|
1772
|
+
code += `let __${key}_${node?.name}`;
|
|
1773
1773
|
let itemCode = '';
|
|
1774
|
+
// 匿名数据结构 / 未设置类型的List/map 才进getInitCode
|
|
1774
1775
|
if (
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1776
|
+
(
|
|
1777
|
+
asserts.isNewComposite(itemNode)
|
|
1778
|
+
&& itemNode.typeAnnotation?.typeKind === 'anonymousStructure'
|
|
1779
|
+
)
|
|
1780
|
+
|| (
|
|
1781
|
+
(asserts.isNewList(itemNode) || asserts.isNewMap(itemNode))
|
|
1782
|
+
&& !(itemNode?.typeAnnotation)
|
|
1783
|
+
)
|
|
1778
1784
|
) {
|
|
1779
|
-
|
|
1785
|
+
code += ' = ';
|
|
1786
|
+
itemCode += yield* itemNode?.getInitCode?.(shiftState(state, code, {
|
|
1780
1787
|
inline: true
|
|
1781
1788
|
})) ??
|
|
1782
1789
|
returnOrigin('');
|
|
1790
|
+
} else if (asserts.isNewComposite(itemNode) && itemNode.typeAnnotation?.typeKind === 'generic') { // new 带泛型的数据结构/实体 进这里
|
|
1791
|
+
code += ' = ';
|
|
1792
|
+
itemCode += (yield* itemNode?.getNewCompositeCode?.(shiftState(state, code, { inline: true }))) || 'null';
|
|
1793
|
+
} else if ((itemNode as any)?.typeAnnotation && !(asserts.isCallQueryComponent(itemNode) && !itemNode.isAutoInfer())) {
|
|
1794
|
+
code += ': ';
|
|
1795
|
+
code += yield* (itemNode as any)?.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
1796
|
+
returnOrigin('');
|
|
1783
1797
|
} else {
|
|
1798
|
+
code += ' = ';
|
|
1784
1799
|
itemCode = yield* itemNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
1785
1800
|
returnOrigin('');
|
|
1786
1801
|
}
|
|
1787
|
-
|
|
1802
|
+
if (itemCode) {
|
|
1803
|
+
code += yield* self.getRightCode(itemCode, assignment, itemNode);
|
|
1804
|
+
}
|
|
1788
1805
|
code += ';\n';
|
|
1789
1806
|
}
|
|
1790
1807
|
},
|
package/src/concepts/Param__.ts
CHANGED
|
@@ -329,12 +329,13 @@ export class Param extends BaseNode {
|
|
|
329
329
|
if (asserts.isFunction(this.defaultExpression) || asserts.isAnonymousFunction(this.defaultExpression)) {
|
|
330
330
|
code += this.defaultValue?.expression || this.defaultExpression ? '?: ' : ': ';
|
|
331
331
|
code += runSync(this.defaultExpression.toEmbeddedTSDefinition(shiftState(state, code)));
|
|
332
|
-
} else if (!dontType && this.typeAnnotation) {
|
|
332
|
+
} else if (!dontType && (this.typeAnnotation || this.__TypeAnnotation)) {
|
|
333
|
+
const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
|
|
333
334
|
code += ': ';
|
|
334
|
-
code +=
|
|
335
|
-
if (
|
|
335
|
+
code += typeAnnotation.toNaturalTS(shiftState(state, code));
|
|
336
|
+
if (typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
|
|
336
337
|
if (this.isEnum()) {
|
|
337
|
-
code += `= ${
|
|
338
|
+
code += `= ${typeAnnotation.typeKey}['${this.defaultValue}']`;
|
|
338
339
|
}
|
|
339
340
|
}
|
|
340
341
|
}
|
|
@@ -573,10 +573,10 @@ export class Structure extends BaseNode {
|
|
|
573
573
|
.join(', ')}>`;
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
-
code += ` {`;
|
|
577
|
-
if (state.descriptionComment && this.description)
|
|
578
|
-
|
|
579
|
-
code += '\n';
|
|
576
|
+
code += ` {\n`;
|
|
577
|
+
// if (state.descriptionComment && this.description)
|
|
578
|
+
// code += `/* ${this.description} */`;
|
|
579
|
+
// code += '\n';
|
|
580
580
|
|
|
581
581
|
// code += `${indent(state.tabSize + 1)}__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
582
582
|
this.properties.forEach((property) => {
|
|
@@ -27,7 +27,6 @@ import type Identifier from './Identifier__';
|
|
|
27
27
|
import { PAGE_COMPONENT_INCLUDE_TAG_MAP } from './View__';
|
|
28
28
|
import type BusinessComponent from './BusinessComponent__';
|
|
29
29
|
import type FrontendType from './FrontendType__';
|
|
30
|
-
import { ComponentCompletionPropertyMap } from './View__';
|
|
31
30
|
|
|
32
31
|
import { kebab2Camel } from '../utils';
|
|
33
32
|
export interface ParseContext {
|
|
@@ -2460,12 +2459,7 @@ export class ViewElement extends Annotatable {
|
|
|
2460
2459
|
|
|
2461
2460
|
if (['u-button', 'u-form', 'u-modal', 'u-table-view', 'u-select', 'u-input', 'u-number-input'].includes(this.tag)) {
|
|
2462
2461
|
code += indent(state.tabSize + 1);
|
|
2463
|
-
|
|
2464
|
-
// if (this.toHump(this.tag) === 'lcapLogin' || this.staticClass === 'login-form') {
|
|
2465
|
-
// code += `${this.name}: nasl.ui.div;\n`;
|
|
2466
|
-
// } else {
|
|
2467
|
-
code += `${this.name}: nasl.ui.${kebab2Camel(this.tag.replace(/^\w-/, ''))},\n`;
|
|
2468
|
-
// }
|
|
2462
|
+
code += `${this.name}: nasl.ui.${kebab2Camel(this.tag.replace(/^\w-/, ''))},\n`;
|
|
2469
2463
|
}
|
|
2470
2464
|
|
|
2471
2465
|
if (Array.isArray(this.children)) {
|
package/src/concepts/View__.ts
CHANGED
|
@@ -46,6 +46,8 @@ const removedViewElementCache: {
|
|
|
46
46
|
[key: string]: number | bigint;
|
|
47
47
|
} = {};
|
|
48
48
|
|
|
49
|
+
import { config } from '../config';
|
|
50
|
+
|
|
49
51
|
//================================================================================
|
|
50
52
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
51
53
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -1857,7 +1859,7 @@ export class View extends Annotatable {
|
|
|
1857
1859
|
document.addEventListener('keydown', this.onKeyDown);
|
|
1858
1860
|
document.addEventListener('keyup', this.onKeyUp);
|
|
1859
1861
|
},
|
|
1860
|
-
|
|
1862
|
+
beforeDestroy() {
|
|
1861
1863
|
document.removeEventListener('keydown', this.onKeyDown);
|
|
1862
1864
|
document.removeEventListener('keyup', this.onKeyUp);
|
|
1863
1865
|
},
|
|
@@ -2125,7 +2127,7 @@ export class View extends Annotatable {
|
|
|
2125
2127
|
if (item.tag === 'template' && item.haveScope()) {
|
|
2126
2128
|
index += 1;
|
|
2127
2129
|
}
|
|
2128
|
-
if (
|
|
2130
|
+
if (config?.allNodesAPI && config?.allNodesAPI[item.tag]?.readablePropsMap) {
|
|
2129
2131
|
componentList.push(item);
|
|
2130
2132
|
}
|
|
2131
2133
|
item.currentIndex = index;
|
|
@@ -2359,22 +2361,39 @@ export class View extends Annotatable {
|
|
|
2359
2361
|
],
|
|
2360
2362
|
function* warpForEachGenerator({ key, node: itemNode }) {
|
|
2361
2363
|
if (itemNode) {
|
|
2362
|
-
code += `
|
|
2364
|
+
code += `let __${key}_${node?.name}`;
|
|
2363
2365
|
let itemCode = '';
|
|
2366
|
+
// 匿名数据结构 / 未设置类型的List/map 才进getInitCode
|
|
2364
2367
|
if (
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
+
(
|
|
2369
|
+
asserts.isNewComposite(itemNode)
|
|
2370
|
+
&& itemNode.typeAnnotation?.typeKind === 'anonymousStructure'
|
|
2371
|
+
)
|
|
2372
|
+
|| (
|
|
2373
|
+
(asserts.isNewList(itemNode) || asserts.isNewMap(itemNode))
|
|
2374
|
+
&& !(itemNode?.typeAnnotation)
|
|
2375
|
+
)
|
|
2368
2376
|
) {
|
|
2369
|
-
|
|
2377
|
+
code += ' = ';
|
|
2378
|
+
itemCode += yield* itemNode?.getInitCode?.(shiftState(state, code, {
|
|
2370
2379
|
inline: true
|
|
2371
2380
|
})) ??
|
|
2372
2381
|
returnOrigin('');
|
|
2382
|
+
} else if (asserts.isNewComposite(itemNode) && itemNode.typeAnnotation?.typeKind === 'generic') { // new 带泛型的数据结构/实体 进这里
|
|
2383
|
+
code += ' = ';
|
|
2384
|
+
itemCode += (yield* itemNode?.getNewCompositeCode?.(shiftState(state, code, { inline: true }))) || 'null';
|
|
2385
|
+
} else if ((itemNode as any)?.typeAnnotation && !(asserts.isCallQueryComponent(itemNode) && !itemNode.isAutoInfer())) {
|
|
2386
|
+
code += ': ';
|
|
2387
|
+
code += yield* (itemNode as any)?.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
2388
|
+
returnOrigin('');
|
|
2373
2389
|
} else {
|
|
2390
|
+
code += ' = ';
|
|
2374
2391
|
itemCode = yield* itemNode?.toEmbeddedTS(shiftState(state, code, { inline: true })) ??
|
|
2375
2392
|
returnOrigin('');
|
|
2376
2393
|
}
|
|
2377
|
-
|
|
2394
|
+
if (itemCode) {
|
|
2395
|
+
code += yield* self.getRightCode(itemCode, assignment, itemNode);
|
|
2396
|
+
}
|
|
2378
2397
|
code += ';\n';
|
|
2379
2398
|
}
|
|
2380
2399
|
},
|
|
@@ -2572,20 +2591,35 @@ export class View extends Annotatable {
|
|
|
2572
2591
|
code += ';\n';
|
|
2573
2592
|
});
|
|
2574
2593
|
if (this.variables.length) code += '\n';
|
|
2594
|
+
if (!callback) {
|
|
2595
|
+
this.bindEvents.forEach((bindEvent) => {
|
|
2596
|
+
bindEvent.logics.forEach((logic) => {
|
|
2597
|
+
const logicCode = logic.toNaturalTS(
|
|
2598
|
+
shiftState(state, code, {
|
|
2599
|
+
tabSize: state.tabSize + 1,
|
|
2600
|
+
// declaration: true,
|
|
2601
|
+
autoPrefixName: true,
|
|
2602
|
+
})
|
|
2603
|
+
);
|
|
2604
|
+
code += logicCode.replace('function ', 'private function ');
|
|
2605
|
+
code += '\n';
|
|
2606
|
+
});
|
|
2607
|
+
if (bindEvent.logics.length) code += '\n';
|
|
2608
|
+
});
|
|
2575
2609
|
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2610
|
+
this.logics.forEach((logic) => {
|
|
2611
|
+
const logicCode = logic.toNaturalTS(
|
|
2612
|
+
shiftState(state, code, {
|
|
2613
|
+
tabSize: state.tabSize + 1,
|
|
2614
|
+
declaration: true,
|
|
2615
|
+
autoPrefixName: true,
|
|
2616
|
+
})
|
|
2617
|
+
);
|
|
2618
|
+
code += logicCode.replace('declare function', 'function');
|
|
2619
|
+
code += '\n';
|
|
2620
|
+
});
|
|
2621
|
+
if (this.logics.length) code += '\n';
|
|
2622
|
+
}
|
|
2589
2623
|
if (callback) {
|
|
2590
2624
|
code += callback.call(this, state);
|
|
2591
2625
|
} else {
|
|
@@ -378,6 +378,51 @@ export function initialize() {
|
|
|
378
378
|
}),
|
|
379
379
|
],
|
|
380
380
|
}),
|
|
381
|
+
new Structure({
|
|
382
|
+
name: 'TaskInst',
|
|
383
|
+
properties: [
|
|
384
|
+
new StructureProperty({
|
|
385
|
+
name: 'processDefUniqueKey',
|
|
386
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
387
|
+
}),
|
|
388
|
+
new StructureProperty({
|
|
389
|
+
name: 'processDefinitionId',
|
|
390
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
391
|
+
}),
|
|
392
|
+
new StructureProperty({
|
|
393
|
+
name: 'processInstanceId',
|
|
394
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
395
|
+
}),
|
|
396
|
+
new StructureProperty({
|
|
397
|
+
name: 'taskDefName',
|
|
398
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
399
|
+
}),
|
|
400
|
+
new StructureProperty({
|
|
401
|
+
name: 'taskTitle',
|
|
402
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
403
|
+
}),
|
|
404
|
+
new StructureProperty({
|
|
405
|
+
name: 'taskId',
|
|
406
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
407
|
+
}),
|
|
408
|
+
new StructureProperty({
|
|
409
|
+
name: 'completeBy',
|
|
410
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
411
|
+
}),
|
|
412
|
+
new StructureProperty({
|
|
413
|
+
name: 'finished',
|
|
414
|
+
typeAnnotation: TypeAnnotation.createPrimitive('Boolean'),
|
|
415
|
+
}),
|
|
416
|
+
new StructureProperty({
|
|
417
|
+
name: 'createTime',
|
|
418
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
419
|
+
}),
|
|
420
|
+
new StructureProperty({
|
|
421
|
+
name: 'completeTime',
|
|
422
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
423
|
+
}),
|
|
424
|
+
],
|
|
425
|
+
}),
|
|
381
426
|
);
|
|
382
427
|
|
|
383
428
|
processV2TypeList.push(
|
|
@@ -820,6 +865,24 @@ export function initialize() {
|
|
|
820
865
|
],
|
|
821
866
|
returns: [],
|
|
822
867
|
}),
|
|
868
|
+
new Logic({
|
|
869
|
+
name: 'getUsersForAddSign',
|
|
870
|
+
description: '查询可加签用户列表',
|
|
871
|
+
params: [
|
|
872
|
+
new Param({
|
|
873
|
+
name: 'taskId',
|
|
874
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
875
|
+
}),
|
|
876
|
+
],
|
|
877
|
+
returns: [
|
|
878
|
+
new Return({
|
|
879
|
+
name: 'result',
|
|
880
|
+
typeAnnotation: TypeAnnotation.createGeneric('List', {
|
|
881
|
+
typeArguments: [TypeAnnotation.createReference('LCAPUser', { typeNamespace: 'nasl.processV2' })],
|
|
882
|
+
}),
|
|
883
|
+
}),
|
|
884
|
+
],
|
|
885
|
+
}),
|
|
823
886
|
new Logic({
|
|
824
887
|
name: 'terminateProcess',
|
|
825
888
|
description: '终止',
|
|
@@ -919,6 +982,22 @@ export function initialize() {
|
|
|
919
982
|
}),
|
|
920
983
|
],
|
|
921
984
|
}),
|
|
985
|
+
new Logic({
|
|
986
|
+
name: 'getTaskInfo',
|
|
987
|
+
description: '查询流程任务信息',
|
|
988
|
+
params: [
|
|
989
|
+
new Param({
|
|
990
|
+
name: 'taskId',
|
|
991
|
+
typeAnnotation: TypeAnnotation.createPrimitive('String'),
|
|
992
|
+
}),
|
|
993
|
+
],
|
|
994
|
+
returns: [
|
|
995
|
+
new Return({
|
|
996
|
+
name: 'result',
|
|
997
|
+
typeAnnotation: TypeAnnotation.createReference('TaskInst', { typeNamespace: 'nasl.processV2' }),
|
|
998
|
+
}),
|
|
999
|
+
],
|
|
1000
|
+
}),
|
|
922
1001
|
];
|
|
923
1002
|
|
|
924
1003
|
const processComponents = [
|
|
@@ -860,7 +860,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
860
860
|
if (window.annotationAllData) {
|
|
861
861
|
resolve(window.annotationAllData);
|
|
862
862
|
} else {
|
|
863
|
-
let sysPrefixPath =
|
|
863
|
+
let sysPrefixPath = ${ config?.sysPrefixPath ? "'" + config?.sysPrefixPath + "'" : "'" + "'" } ||'';
|
|
864
864
|
let urlEntity = sysPrefixPath + '/api/system/annotation/entityAll'
|
|
865
865
|
let urlLogic = sysPrefixPath + '/api/system/annotation/logicAll'
|
|
866
866
|
Promise.all([
|
|
@@ -27,10 +27,10 @@ import {
|
|
|
27
27
|
getConnectorsCode,
|
|
28
28
|
getDependenciesCode,
|
|
29
29
|
getFrontendViewsCode,
|
|
30
|
+
getCurrentComponentDeclaration,
|
|
30
31
|
wrapTSBlock,
|
|
31
32
|
} from './getContext';
|
|
32
33
|
import { createCompilerState } from '../translator';
|
|
33
|
-
import { fr } from 'date-fns/locale';
|
|
34
34
|
|
|
35
35
|
export * as getNaturalContext from './getContext';
|
|
36
36
|
|
|
@@ -66,11 +66,12 @@ export function genNaturalTSContextJSONForLogic(
|
|
|
66
66
|
description: string;
|
|
67
67
|
tsDescription: string;
|
|
68
68
|
}[];
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
|
+
restParams?: any
|
|
70
71
|
) {
|
|
71
72
|
const frontend = currentNode?.getAncestor('Frontend') as Frontend;
|
|
72
73
|
const logicType = currentNode?.parentNode?.concept === 'App' ? 'global_logic' : 'view_logic';
|
|
73
|
-
const state = createCompilerState('', { descriptionComment: true });
|
|
74
|
+
const state = createCompilerState('', { descriptionComment: true, typeMap: restParams?.typeMap });
|
|
74
75
|
|
|
75
76
|
const { naslCore } = getNaslCore(logicType);
|
|
76
77
|
const { naslUtil } = getNaslUtil();
|
|
@@ -113,8 +114,8 @@ export function genNaturalTSContextJSONForLogic(
|
|
|
113
114
|
const { backendVariables } = getServerVariables(app, state);
|
|
114
115
|
|
|
115
116
|
const { views } = getFrontendViews(frontend, state, currentNode, false);
|
|
116
|
-
const { currentLogic } = getCurrentNodeContext(currentNode, focusedNodePath, experimental);
|
|
117
|
-
|
|
117
|
+
const { currentLogic } = getCurrentNodeContext(currentNode, focusedNodePath, experimental, restParams?.typeMap);
|
|
118
|
+
const { componentDeclaration } = getCurrentComponentDeclaration(currentNode, components);
|
|
118
119
|
return {
|
|
119
120
|
naslCore,
|
|
120
121
|
naslUtil,
|
|
@@ -133,6 +134,7 @@ export function genNaturalTSContextJSONForLogic(
|
|
|
133
134
|
views,
|
|
134
135
|
currentLogic,
|
|
135
136
|
logicType,
|
|
137
|
+
componentDeclaration
|
|
136
138
|
};
|
|
137
139
|
}
|
|
138
140
|
|
|
@@ -166,13 +168,14 @@ export const genNaturalTSContextFromJSONForLogic = (
|
|
|
166
168
|
views,
|
|
167
169
|
currentLogic,
|
|
168
170
|
logicType,
|
|
171
|
+
componentDeclaration
|
|
169
172
|
} = tsContextJSON;
|
|
170
173
|
|
|
171
174
|
let code = '';
|
|
172
|
-
code += '### [1]
|
|
175
|
+
code += '### [1]标准库与类型定义\n';
|
|
173
176
|
code += wrapTSBlock(naslCore);
|
|
174
177
|
|
|
175
|
-
code += '\n### [2]
|
|
178
|
+
code += '\n### [2]平台内置函数库\n';
|
|
176
179
|
code += wrapTSBlock(naslUtil);
|
|
177
180
|
|
|
178
181
|
if (naslUI && logicType === 'view_logic') {
|
|
@@ -182,10 +185,14 @@ export const genNaturalTSContextFromJSONForLogic = (
|
|
|
182
185
|
} else {
|
|
183
186
|
code += getNaslUICode(naslUI, codeType, requiredIndexes);
|
|
184
187
|
}
|
|
188
|
+
if (componentDeclaration) {
|
|
189
|
+
code += '\n#### [3-1] 组件声明\n';
|
|
190
|
+
code += wrapTSBlock(`declare namespace nasl.ui {\n${componentDeclaration}}`);
|
|
191
|
+
}
|
|
185
192
|
}
|
|
186
193
|
|
|
187
194
|
if (naslOql && logicType === 'global_logic') {
|
|
188
|
-
code += '\n### [4]
|
|
195
|
+
code += '\n### [4]数据查询定义\n';
|
|
189
196
|
code += wrapTSBlock(naslOql);
|
|
190
197
|
}
|
|
191
198
|
|
|
@@ -265,7 +272,8 @@ export function genNaturalTSContextForLogic(
|
|
|
265
272
|
}[];
|
|
266
273
|
},
|
|
267
274
|
restParams?: {
|
|
268
|
-
codeType
|
|
275
|
+
codeType: 'detail' | 'short';
|
|
276
|
+
typeMap?: any;
|
|
269
277
|
}
|
|
270
278
|
) {
|
|
271
279
|
const tsContextJSON = genNaturalTSContextJSONForLogic(
|
|
@@ -273,11 +281,12 @@ export function genNaturalTSContextForLogic(
|
|
|
273
281
|
currentNode,
|
|
274
282
|
focusedNodePath,
|
|
275
283
|
experimental,
|
|
276
|
-
material
|
|
284
|
+
material,
|
|
285
|
+
restParams
|
|
277
286
|
);
|
|
278
287
|
const code = genNaturalTSContextFromJSONForLogic(
|
|
279
288
|
tsContextJSON,
|
|
280
|
-
restParams
|
|
289
|
+
restParams?.codeType || 'short',
|
|
281
290
|
requiredIndexes
|
|
282
291
|
);
|
|
283
292
|
return code;
|
|
@@ -303,17 +312,19 @@ export function genNaturalTSContextJSONForUI(
|
|
|
303
312
|
moduleInterfaces: any;
|
|
304
313
|
connectors: any;
|
|
305
314
|
dependencies: any;
|
|
306
|
-
}
|
|
315
|
+
},
|
|
316
|
+
restParams?: any
|
|
307
317
|
) {
|
|
308
318
|
const frontend = currentNode.getAncestor('Frontend') as Frontend;
|
|
309
|
-
const state = createCompilerState('', { descriptionComment: true, needNamespace: true });
|
|
319
|
+
const state = createCompilerState('', { descriptionComment: true, needNamespace: true, typeMap: restParams?.typeMap });
|
|
310
320
|
|
|
311
321
|
const { naslCore } = getNaslCore('view_logic');
|
|
312
322
|
const { naslUtil } = getNaslUtil();
|
|
313
|
-
const { naslUI } =
|
|
323
|
+
const { naslUI } = getNaslUIOld();
|
|
324
|
+
const components = getNaslUI(app, frontend.type, {
|
|
314
325
|
basicMaterials: material?.basicMaterials,
|
|
315
326
|
extensionMaterials: material?.extensionMaterials,
|
|
316
|
-
});
|
|
327
|
+
}).naslUI;
|
|
317
328
|
const { enums } = getEnums(app, state);
|
|
318
329
|
const { entities } = getEntities(app, state);
|
|
319
330
|
const { structures } = getStructures(app, state);
|
|
@@ -330,12 +341,15 @@ export function genNaturalTSContextJSONForUI(
|
|
|
330
341
|
);
|
|
331
342
|
const { frontendVariables } = getFrontendVariables(frontend, state);
|
|
332
343
|
const { views } = getFrontendViews(frontend, state, currentNode, false);
|
|
333
|
-
const { currentLogic } = getCurrentNodeContextForUI(currentNode);
|
|
344
|
+
const { currentLogic } = getCurrentNodeContextForUI(currentNode, restParams?.typeMap);
|
|
345
|
+
const { componentDeclaration } = getCurrentComponentDeclaration(currentNode, components);
|
|
334
346
|
|
|
335
347
|
return {
|
|
336
348
|
naslCore,
|
|
337
349
|
naslUtil,
|
|
338
350
|
naslUI,
|
|
351
|
+
components,
|
|
352
|
+
componentDeclaration,
|
|
339
353
|
enums,
|
|
340
354
|
entities,
|
|
341
355
|
structures,
|
|
@@ -364,7 +378,8 @@ export const genNaturalTSContextFromJSONForUI = (
|
|
|
364
378
|
const {
|
|
365
379
|
naslCore,
|
|
366
380
|
naslUtil,
|
|
367
|
-
|
|
381
|
+
components,
|
|
382
|
+
componentDeclaration,
|
|
368
383
|
enums,
|
|
369
384
|
entities,
|
|
370
385
|
structures,
|
|
@@ -377,18 +392,18 @@ export const genNaturalTSContextFromJSONForUI = (
|
|
|
377
392
|
} = tsContextJSON;
|
|
378
393
|
|
|
379
394
|
let code = '';
|
|
380
|
-
code += '### [1]
|
|
395
|
+
code += '### [1] 标准库与类型定义\n';
|
|
381
396
|
code += wrapTSBlock(naslCore);
|
|
382
397
|
|
|
383
|
-
code += '\n### [2]
|
|
398
|
+
code += '\n### [2] 平台内置函数库\n';
|
|
384
399
|
code += wrapTSBlock(naslUtil);
|
|
385
400
|
|
|
386
|
-
if (
|
|
401
|
+
if (components) {
|
|
387
402
|
code += '\n### [3] nasl.ui\n';
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
code +=
|
|
403
|
+
code += getNaslUICode(components, codeType, requiredIndexes);
|
|
404
|
+
if (componentDeclaration) {
|
|
405
|
+
code += '\n#### [3-1] 组件声明\n';
|
|
406
|
+
code += wrapTSBlock(`declare namespace nasl.ui {\n${componentDeclaration}\n}`);
|
|
392
407
|
}
|
|
393
408
|
}
|
|
394
409
|
|
|
@@ -459,13 +474,14 @@ export function genNaturalTSContextForUI(
|
|
|
459
474
|
dependencies: any;
|
|
460
475
|
},
|
|
461
476
|
restParams?: {
|
|
462
|
-
codeType
|
|
477
|
+
codeType: 'detail' | 'short';
|
|
478
|
+
typeMap?: any;
|
|
463
479
|
}
|
|
464
480
|
) {
|
|
465
|
-
const tsContextJSON = genNaturalTSContextJSONForUI(app, currentNode, material);
|
|
481
|
+
const tsContextJSON = genNaturalTSContextJSONForUI(app, currentNode, material, restParams);
|
|
466
482
|
const code = genNaturalTSContextFromJSONForUI(
|
|
467
483
|
tsContextJSON,
|
|
468
|
-
restParams
|
|
484
|
+
restParams?.codeType || 'short',
|
|
469
485
|
requiredIndexes
|
|
470
486
|
);
|
|
471
487
|
return code;
|
|
@@ -50,7 +50,10 @@ export function handleMaterial({ json, tsDeclaration }: { json: Array<{ name: st
|
|
|
50
50
|
snippets.forEach((code) => {
|
|
51
51
|
const cap = code.match(/class ([a-zA-Z]+).+?extends ViewComponent/);
|
|
52
52
|
if (cap) {
|
|
53
|
-
|
|
53
|
+
const newCode = code
|
|
54
|
+
.replace(/nasl\.core\./g, "")
|
|
55
|
+
.replace(/Integer/g, "Long");
|
|
56
|
+
snippetMap[cap[1]] = `declare namespace nasl.ui${newCode}`;
|
|
54
57
|
}
|
|
55
58
|
});
|
|
56
59
|
json.forEach((item) => {
|
|
@@ -79,12 +82,12 @@ export function getPreDeclaration() {
|
|
|
79
82
|
/// #if process.env.BUILD_TARGET === 'node'
|
|
80
83
|
if (globalThis.process) { // For TS build
|
|
81
84
|
const fs = require('fs');
|
|
82
|
-
code = fs.readFileSync(require.resolve(`../../../sandbox-natural/stdlib/nasl.ui.
|
|
85
|
+
code = fs.readFileSync(require.resolve(`../../../sandbox-natural/stdlib/nasl.ui.d.ts`), 'utf8');
|
|
83
86
|
}
|
|
84
87
|
/// #endif
|
|
85
88
|
/// #if process.env.BUILD_TARGET !== 'node'
|
|
86
89
|
if (globalThis.window) { // For TS build
|
|
87
|
-
code = require('!!raw-loader!../../../sandbox-natural/stdlib/nasl.ui.
|
|
90
|
+
code = require('!!raw-loader!../../../sandbox-natural/stdlib/nasl.ui.d.ts').default;
|
|
88
91
|
}
|
|
89
92
|
/// #endif
|
|
90
93
|
return code;
|