@lcap/nasl 1.0.2 → 2.12.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.
- package/out/automate/engine/index.d.ts +1 -0
- package/out/automate/engine/index.js +34 -12
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/operators.d.ts +10 -2
- package/out/automate/engine/operators.js +105 -7
- package/out/automate/engine/operators.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +8 -2
- package/out/automate/engine/uniqueName.js +72 -4
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +92 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/process.d.ts +9 -0
- package/out/automate/template/process.js +10976 -0
- package/out/automate/template/process.js.map +1 -0
- package/out/bak/translator.js +1 -0
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +5 -0
- package/out/common/BaseNode.js +24 -3
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +51 -49
- package/out/concepts/App__.js +86 -53
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +2 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +10 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +15 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +4 -0
- package/out/concepts/BooleanLiteral__.js +11 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +8 -2
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.js +48 -30
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +8 -7
- package/out/concepts/CallQueryComponent__.js +86 -76
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +7 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +3 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +3 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +318 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +8 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +6 -0
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +19 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -0
- package/out/concepts/Entity__.js +20 -10
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +12 -6
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -2
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +96 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +6 -15
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +8 -8
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +3 -5
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.js +44 -44
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.d.ts +116 -194
- package/out/concepts/Module__.js +31 -114
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +1 -108
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/Param__.d.ts +2 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +30 -10
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -1
- package/out/concepts/Process__.js +17 -10
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +8 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +13 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +10 -3
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +14 -0
- package/out/concepts/SqlQueryComponent__.js +48 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StructureProperty__.js +6 -5
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +19 -12
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -1
- package/out/concepts/SwitchCase__.js +23 -25
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -6
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +44 -2
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +25 -20
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +0 -2
- package/out/concepts/View__.js +27 -32
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +4 -4
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
- package/out/concepts/basics/stdlib/nasl.process.js +410 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +280 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +4 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +3 -1
- package/out/generator/genBundleFiles.js +23 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -0
- package/out/generator/genMetaData.js +20 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +27 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +5 -0
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +4 -0
- package/out/server/getProcesses.js +69 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -0
- package/out/server/naslServer.js +223 -26
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +10 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +37 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -0
- package/out/service/storage/init.js +95 -84
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +34 -24
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +45 -29
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +15 -13
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +1 -1
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +29 -24
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +25 -26
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +8 -7
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +31 -21
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +34 -24
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/connect-file.js +6 -6
- package/out/test/integration/connect-file.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +5 -0
- package/out/utils/index.js +50 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/automate/engine/index.js +33 -8
- package/src/automate/engine/operators.js +114 -17
- package/src/automate/engine/uniqueName.js +77 -9
- package/src/automate/engine/utils.js +95 -68
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +21 -4
- package/src/concepts/App__.ts +128 -94
- package/src/concepts/BindAttribute__.ts +2 -2
- package/src/concepts/BindDirective__.ts +9 -7
- package/src/concepts/BindEvent__.ts +14 -6
- package/src/concepts/BooleanLiteral__.ts +12 -0
- package/src/concepts/CallFunction__.ts +6 -2
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +92 -81
- package/src/concepts/Comment__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +3 -1
- package/src/concepts/ConfigProperty__.ts +4 -0
- package/src/concepts/Configuration__.ts +3 -0
- package/src/concepts/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +24 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +7 -0
- package/src/concepts/EntityProperty__.ts +20 -2
- package/src/concepts/Entity__.ts +23 -11
- package/src/concepts/Enum__.ts +25 -6
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +15 -15
- package/src/concepts/IfStatement__.ts +9 -9
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +3 -12
- package/src/concepts/Logic__.ts +45 -79
- package/src/concepts/Module__.ts +141 -342
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/ProcessElement__.ts +33 -12
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryFieldExpression__.ts +9 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +6 -9
- package/src/concepts/Structure__.ts +19 -11
- package/src/concepts/SwitchCase__.ts +23 -27
- package/src/concepts/SwitchStatement__.ts +1 -5
- package/src/concepts/TypeAnnotation__.ts +43 -2
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +29 -34
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
- package/src/concepts/basics/stdlib/nasl.util.ts +281 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/index__.ts +1 -0
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/getLogics.ts +29 -4
- package/src/server/getMemberIdentifier.ts +4 -0
- package/src/server/getProcesses.ts +68 -0
- package/src/server/naslServer.ts +227 -30
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +39 -1
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +97 -86
- package/src/templator/genCreateBlock.ts +35 -26
- package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
- package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
- package/src/templator/genEditTableBlock.ts +17 -14
- package/src/templator/genEnumSelectBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +28 -27
- package/src/templator/genSelectBlock.ts +9 -8
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +35 -25
- package/src/templator/utils.ts +2 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +51 -0
package/src/concepts/Enum__.ts
CHANGED
|
@@ -125,6 +125,10 @@ export class Enum extends BaseNode {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
128
132
|
/**
|
|
129
133
|
* 插入枚举项
|
|
130
134
|
* @internal
|
|
@@ -157,6 +161,8 @@ export class Enum extends BaseNode {
|
|
|
157
161
|
return enumItem;
|
|
158
162
|
}
|
|
159
163
|
|
|
164
|
+
|
|
165
|
+
|
|
160
166
|
/**
|
|
161
167
|
* 插入枚举项
|
|
162
168
|
* @param enumItemOptions 枚举项参数
|
|
@@ -179,6 +185,8 @@ export class Enum extends BaseNode {
|
|
|
179
185
|
return node;
|
|
180
186
|
}
|
|
181
187
|
|
|
188
|
+
|
|
189
|
+
|
|
182
190
|
/**
|
|
183
191
|
* 添加枚举项
|
|
184
192
|
* @internal
|
|
@@ -198,6 +206,8 @@ export class Enum extends BaseNode {
|
|
|
198
206
|
return this._insertEnumItemAt(options as any, index);
|
|
199
207
|
}
|
|
200
208
|
|
|
209
|
+
|
|
210
|
+
|
|
201
211
|
/**
|
|
202
212
|
* 添加枚举项
|
|
203
213
|
* @param enumItemOptions 枚举项参数
|
|
@@ -221,6 +231,9 @@ export class Enum extends BaseNode {
|
|
|
221
231
|
return node;
|
|
222
232
|
}
|
|
223
233
|
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
224
237
|
/**
|
|
225
238
|
* 删除枚举项
|
|
226
239
|
* @param enumItem 已有的枚举项实例
|
|
@@ -228,7 +241,7 @@ export class Enum extends BaseNode {
|
|
|
228
241
|
removeEnumItem(enumItem: EnumItem): void;
|
|
229
242
|
|
|
230
243
|
removeEnumItem(options: EnumItem) {
|
|
231
|
-
|
|
244
|
+
let enumItem: EnumItem = options;
|
|
232
245
|
return enumItem.delete();
|
|
233
246
|
}
|
|
234
247
|
|
|
@@ -282,9 +295,9 @@ export class Enum extends BaseNode {
|
|
|
282
295
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
283
296
|
let code = `export class ${this.name} extends nasl.core.Enums {\n`;
|
|
284
297
|
// 增加一个单独的标签
|
|
285
|
-
code += indent(state
|
|
298
|
+
code += indent((state?.tabSize || 0) + 1) + `__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
286
299
|
this.enumItems.forEach((property) => {
|
|
287
|
-
code += indent(state
|
|
300
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
288
301
|
code += property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
|
|
289
302
|
code += ';\n';
|
|
290
303
|
});
|
|
@@ -298,14 +311,20 @@ export class Enum extends BaseNode {
|
|
|
298
311
|
return str;
|
|
299
312
|
}
|
|
300
313
|
`;
|
|
301
|
-
code += indent(state
|
|
314
|
+
code += indent((state?.tabSize || 0)) + '}\n';
|
|
302
315
|
|
|
303
316
|
return code;
|
|
304
317
|
}
|
|
305
318
|
|
|
306
319
|
getNamespace() {
|
|
307
320
|
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
308
|
-
|
|
321
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
322
|
+
const parentName = this.parentNode.name;
|
|
323
|
+
const arr = [parentNamespace];
|
|
324
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
325
|
+
arr.push(parentName);
|
|
326
|
+
}
|
|
327
|
+
return `${arr.join('.')}.enums`;
|
|
309
328
|
} else
|
|
310
329
|
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
311
330
|
}
|
|
@@ -343,7 +362,7 @@ export class Enum extends BaseNode {
|
|
|
343
362
|
//================================================================================
|
|
344
363
|
}
|
|
345
364
|
|
|
346
|
-
classMap
|
|
365
|
+
classMap['Enum'] = Enum;
|
|
347
366
|
export default Enum;
|
|
348
367
|
//================================================================================
|
|
349
368
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -548,11 +548,11 @@ export class ForEachStatement extends LogicItem {
|
|
|
548
548
|
this.body.forEach((logicItem) => {
|
|
549
549
|
code
|
|
550
550
|
+= logicItem.toEmbeddedTS(shiftState(state, code, {
|
|
551
|
-
tabSize: state
|
|
551
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
552
552
|
})) + '\n';
|
|
553
553
|
});
|
|
554
554
|
}
|
|
555
|
-
code += indent(state
|
|
555
|
+
code += indent((state?.tabSize || 0)) + '})\n';
|
|
556
556
|
|
|
557
557
|
return code;
|
|
558
558
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import Namespace from './Namespace__';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
3
|
+
import LogicItem from './LogicItem__';
|
|
4
|
+
|
|
2
5
|
//================================================================================
|
|
3
6
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
4
7
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -886,7 +889,72 @@ export class Function extends BaseNode {
|
|
|
886
889
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
887
890
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
888
891
|
//================================================================================
|
|
892
|
+
/**
|
|
893
|
+
* returnExpression 输出的Lambda 表达式
|
|
894
|
+
*/
|
|
895
|
+
@property('LogicItem')
|
|
896
|
+
returnExpression: LogicItem = undefined;
|
|
889
897
|
|
|
898
|
+
/**
|
|
899
|
+
* 设置returnExpression 输出的Lambda 表达式
|
|
900
|
+
*/
|
|
901
|
+
setReturnExpression(expression: LogicItem) {
|
|
902
|
+
expression._delete();
|
|
903
|
+
const relationOptions = { parentNode: this, parentKey: 'returnExpression' };
|
|
904
|
+
Object.assign(expression, relationOptions);
|
|
905
|
+
const object = {
|
|
906
|
+
returnExpression: expression,
|
|
907
|
+
};
|
|
908
|
+
this.update({
|
|
909
|
+
...object,
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
toJS(state?: TranslatorState): String {
|
|
914
|
+
let code = '';
|
|
915
|
+
code += '(';
|
|
916
|
+
this.params.forEach((param, index) => {
|
|
917
|
+
code += param.toJS(shiftState(state, code));
|
|
918
|
+
if (index !== this.params.length - 1) {
|
|
919
|
+
code += ',';
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
code += ')';
|
|
923
|
+
code += ' => (';
|
|
924
|
+
if (this.returnExpression) {
|
|
925
|
+
code += this.returnExpression.toJS(shiftState(state, code));
|
|
926
|
+
}
|
|
927
|
+
code += ')';
|
|
928
|
+
return code;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* 刪除LogicItem
|
|
933
|
+
* @param logicItem
|
|
934
|
+
* @returns
|
|
935
|
+
*/
|
|
936
|
+
__removeLogicItem(logicItem: LogicItem) {
|
|
937
|
+
const parentKey = logicItem.parentKey;
|
|
938
|
+
const params: Params = {
|
|
939
|
+
parentNode: this,
|
|
940
|
+
parentKey,
|
|
941
|
+
index: -1,
|
|
942
|
+
object: null,
|
|
943
|
+
oldObject: logicItem,
|
|
944
|
+
};
|
|
945
|
+
if (parentKey) {
|
|
946
|
+
params.parentKey = parentKey;
|
|
947
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
948
|
+
const index = (this as any)[parentKey].indexOf(logicItem);
|
|
949
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
950
|
+
params.index = index;
|
|
951
|
+
} else if ((this as any)[parentKey] === logicItem) {
|
|
952
|
+
params.index = 0;
|
|
953
|
+
(this as any)[parentKey] = undefined;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
return params;
|
|
957
|
+
}
|
|
890
958
|
getVarExistingNames(excludedList: Array<Param | Return | Variable> = []) {
|
|
891
959
|
const excludedSet = new Set(excludedList);
|
|
892
960
|
return [...this.params, ...this.returns, ...this.variables].filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -895,13 +963,39 @@ export class Function extends BaseNode {
|
|
|
895
963
|
if (this.parentNode) {
|
|
896
964
|
let parentNodeNamespace = '';
|
|
897
965
|
if ((this.parentNode as Namespace).getNamespace) {
|
|
898
|
-
parentNodeNamespace = (this.parentNode as Namespace).getNamespace();
|
|
966
|
+
parentNodeNamespace = [(this.parentNode as Namespace).getNamespace(), this.parentNode.name].join('.');
|
|
899
967
|
}
|
|
900
968
|
return `${parentNodeNamespace}`;
|
|
901
969
|
} else
|
|
902
970
|
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
903
971
|
}
|
|
972
|
+
@withSourceMap()
|
|
973
|
+
toEmbeddedTS(state?: TranslatorState): string {
|
|
974
|
+
let code = '';
|
|
975
|
+
if (this.returnExpression) {
|
|
976
|
+
code += `(`;
|
|
977
|
+
this.params.forEach((param, index) => {
|
|
978
|
+
code += param.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
979
|
+
if (index !== this.params.length - 1)
|
|
980
|
+
code += ', ';
|
|
981
|
+
});
|
|
982
|
+
code += `)`;
|
|
983
|
+
if (this.returns.length) {
|
|
984
|
+
code += ': ';
|
|
985
|
+
code += this.returns[0].typeAnnotation.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
986
|
+
}
|
|
987
|
+
code += ` => (`;
|
|
904
988
|
|
|
989
|
+
if (this.returnExpression) {
|
|
990
|
+
code += this.returnExpression.toEmbeddedTS && this.returnExpression.toEmbeddedTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
991
|
+
}
|
|
992
|
+
code += indent(state.tabSize) + ')';
|
|
993
|
+
} else {
|
|
994
|
+
code += '__IDENTIFIER__';
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
return code;
|
|
998
|
+
}
|
|
905
999
|
get calleeKey() {
|
|
906
1000
|
const calleeNamespace = this.getNamespace();
|
|
907
1001
|
const calleeName = this.name;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
2
2
|
import { BindAttribute, CallFunction, CallLogic, Argument, MemberExpression, TypeAnnotation } from '..';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
|
+
import { findConceptKeyWordByNamespace } from '../utils';
|
|
4
5
|
|
|
5
6
|
//================================================================================
|
|
6
7
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -38,6 +39,8 @@ export class Identifier extends LogicItem {
|
|
|
38
39
|
@property()
|
|
39
40
|
name: string = undefined;
|
|
40
41
|
|
|
42
|
+
|
|
43
|
+
|
|
41
44
|
/**
|
|
42
45
|
* @param source 需要合并的部分参数
|
|
43
46
|
*/
|
|
@@ -51,6 +54,13 @@ export class Identifier extends LogicItem {
|
|
|
51
54
|
return super.from(source, parentNode, parentKey) as Identifier;
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
54
64
|
//================================================================================
|
|
55
65
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
56
66
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
@@ -68,25 +78,14 @@ export class Identifier extends LogicItem {
|
|
|
68
78
|
};
|
|
69
79
|
|
|
70
80
|
isEnum() {
|
|
71
|
-
|
|
72
|
-
if (namespace) {
|
|
73
|
-
const namespaceArr = namespace.split('.');
|
|
74
|
-
const start = namespaceArr.shift();
|
|
75
|
-
if (start === 'app' || start === 'extensions') {
|
|
76
|
-
const mod = start === 'app' ? 0 : 1;
|
|
77
|
-
const keywordViews = namespaceArr.filter((namespaceItem, index) => index % 2 === mod);
|
|
78
|
-
const last = keywordViews.pop();
|
|
79
|
-
return last === 'enums';
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return false;
|
|
81
|
+
return findConceptKeyWordByNamespace(this.namespace) === 'enums';
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
toVue(options?: ElementToVueOptions): string {
|
|
86
85
|
let name = this.name;
|
|
87
86
|
const namespace = this.namespace;
|
|
88
87
|
if (namespace) {
|
|
89
|
-
if ((this.namespace.endsWith('nasl.browser') || this.namespace.endsWith('nasl.auth') || this.namespace.endsWith('nasl.configuration'))) {
|
|
88
|
+
if ((this.namespace.endsWith('nasl.browser') || this.namespace.endsWith('nasl.auth') || this.namespace.endsWith('nasl.configuration') || this.namespace.endsWith('nasl.process'))) {
|
|
90
89
|
name = `$global.${this.name}`;
|
|
91
90
|
} else if (this.isEnum()) {
|
|
92
91
|
name = `$utils.EnumList("${this.name}")`;
|
|
@@ -127,7 +126,7 @@ export class Identifier extends LogicItem {
|
|
|
127
126
|
let name = this.name;
|
|
128
127
|
const namespace = this.namespace;
|
|
129
128
|
if (namespace) {
|
|
130
|
-
if (namespace.endsWith('nasl.browser') || namespace.endsWith('nasl.auth') || namespace.endsWith('nasl.configuration')) {
|
|
129
|
+
if (namespace.endsWith('nasl.browser') || namespace.endsWith('nasl.auth') || namespace.endsWith('nasl.configuration') || this.namespace.endsWith('nasl.process')) {
|
|
131
130
|
name = `$global.${this.name}`;
|
|
132
131
|
} else if (this.isEnum()) {
|
|
133
132
|
name = `$utils.EnumList("${this.name}")`;
|
|
@@ -138,6 +137,7 @@ export class Identifier extends LogicItem {
|
|
|
138
137
|
|| namespace?.endsWith('nasl.browser')
|
|
139
138
|
|| namespace?.endsWith('nasl.auth')
|
|
140
139
|
|| namespace?.endsWith('nasl.configuration')
|
|
140
|
+
|| namespace?.endsWith('nasl.process')
|
|
141
141
|
|| this.isEnum())
|
|
142
142
|
&& !isMemberExpressionProperty ? `this.${name}` : name;
|
|
143
143
|
}
|
|
@@ -215,7 +215,7 @@ export class Identifier extends LogicItem {
|
|
|
215
215
|
//================================================================================
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
classMap
|
|
218
|
+
classMap['Identifier'] = Identifier;
|
|
219
219
|
export default Identifier;
|
|
220
220
|
//================================================================================
|
|
221
221
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -367,13 +367,13 @@ export class IfStatement extends LogicItem {
|
|
|
367
367
|
public static getDefaultOptions() {
|
|
368
368
|
return {
|
|
369
369
|
label: '条件分支',
|
|
370
|
-
}
|
|
370
|
+
};
|
|
371
371
|
}
|
|
372
372
|
toJS(state?: TranslatorState) {
|
|
373
373
|
let code = '';
|
|
374
374
|
code += 'if (';
|
|
375
375
|
code += this.test ? this.test.toJS(shiftState(state, code, {
|
|
376
|
-
tabSize: state
|
|
376
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
377
377
|
})) : '';
|
|
378
378
|
|
|
379
379
|
code += ') {\n';
|
|
@@ -382,17 +382,17 @@ export class IfStatement extends LogicItem {
|
|
|
382
382
|
this.consequent.forEach((logicItem) => {
|
|
383
383
|
code
|
|
384
384
|
+= logicItem.toJS(shiftState(state, code, {
|
|
385
|
-
tabSize: state
|
|
385
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
386
386
|
})) + '\n';
|
|
387
387
|
});
|
|
388
388
|
}
|
|
389
389
|
code += '}';
|
|
390
390
|
if (Array.isArray(this.alternate)) {
|
|
391
|
-
code += indent(state
|
|
391
|
+
code += indent((state?.tabSize || 0)) + ' else {\n';
|
|
392
392
|
this.alternate.forEach((logicItem) => {
|
|
393
393
|
code
|
|
394
394
|
+= logicItem.toJS(shiftState(state, code, {
|
|
395
|
-
tabSize: state
|
|
395
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
396
396
|
})) + '\n';
|
|
397
397
|
});
|
|
398
398
|
code += '}\n';
|
|
@@ -414,21 +414,21 @@ export class IfStatement extends LogicItem {
|
|
|
414
414
|
this.consequent.forEach((logicItem) => {
|
|
415
415
|
code
|
|
416
416
|
+= logicItem.toEmbeddedTS(shiftState(state, code, {
|
|
417
|
-
tabSize: state
|
|
417
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
418
418
|
})) + '\n';
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
code += indent(state
|
|
422
|
+
code += indent((state?.tabSize || 0)) + '}';
|
|
423
423
|
if (Array.isArray(this.alternate)) {
|
|
424
424
|
code += ' else {\n';
|
|
425
425
|
this.alternate.forEach((logicItem) => {
|
|
426
426
|
code
|
|
427
427
|
+= logicItem.toEmbeddedTS(shiftState(state, code, {
|
|
428
|
-
tabSize: state
|
|
428
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
429
429
|
})) + '\n';
|
|
430
430
|
});
|
|
431
|
-
code += indent(state
|
|
431
|
+
code += indent((state?.tabSize || 0)) + '}\n';
|
|
432
432
|
}
|
|
433
433
|
return code;
|
|
434
434
|
}
|
|
@@ -581,7 +581,7 @@ export class Interface extends BaseNode {
|
|
|
581
581
|
}
|
|
582
582
|
|
|
583
583
|
get calleeKey(): string {
|
|
584
|
-
return `${this.getTsNamespace()}.${this.name}
|
|
584
|
+
return `${this.getTsNamespace()}.${this.name}`;
|
|
585
585
|
}
|
|
586
586
|
|
|
587
587
|
get calleewholeKey() {
|
|
@@ -726,21 +726,29 @@ export class Interface extends BaseNode {
|
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
getNamespace() {
|
|
729
|
-
if (this.parentNode && (this.parentNode as Namespace).getNamespace)
|
|
730
|
-
|
|
731
|
-
|
|
729
|
+
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
730
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
731
|
+
const parentName = this.parentNode.name;
|
|
732
|
+
const arr = [parentNamespace];
|
|
733
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
734
|
+
arr.push(parentName);
|
|
735
|
+
}
|
|
736
|
+
return `${arr.join('.')}.interfaces`;
|
|
737
|
+
} else
|
|
732
738
|
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
733
739
|
}
|
|
740
|
+
|
|
734
741
|
getTsNamespace() {
|
|
735
|
-
if (this.parentNode.
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
742
|
+
if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
|
|
743
|
+
const parentNamespace = (this.parentNode as Namespace).getTsNamespace();
|
|
744
|
+
const parentName = this.parentNode.tsName || this.parentNode.name;
|
|
745
|
+
const arr = [parentNamespace];
|
|
746
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
747
|
+
arr.push(parentName);
|
|
742
748
|
}
|
|
743
|
-
|
|
749
|
+
return `${arr.join('.')}.interfaces`;
|
|
750
|
+
} else
|
|
751
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
744
752
|
}
|
|
745
753
|
|
|
746
754
|
getVarExistingNames(excludedList: Array<InterfaceParam | Return> = []) {
|
|
@@ -35,8 +35,6 @@ export class JSBlock extends LogicItem {
|
|
|
35
35
|
@property()
|
|
36
36
|
code: string = undefined;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
38
|
/**
|
|
41
39
|
* @param source 需要合并的部分参数
|
|
42
40
|
*/
|
|
@@ -50,7 +48,6 @@ export class JSBlock extends LogicItem {
|
|
|
50
48
|
return super.from(source, parentNode, parentKey) as JSBlock;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
|
|
54
51
|
/**
|
|
55
52
|
* 设置代码内容
|
|
56
53
|
*/
|
|
@@ -63,10 +60,6 @@ export class JSBlock extends LogicItem {
|
|
|
63
60
|
});
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
63
|
//================================================================================
|
|
71
64
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
72
65
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
@@ -76,11 +69,9 @@ export class JSBlock extends LogicItem {
|
|
|
76
69
|
/**
|
|
77
70
|
* 生成 JS 脚本
|
|
78
71
|
*/
|
|
79
|
-
return `
|
|
72
|
+
return `await (async () => {
|
|
80
73
|
${this.code}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
await jsBlock_number();`;
|
|
74
|
+
})();`;
|
|
84
75
|
}
|
|
85
76
|
|
|
86
77
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
@@ -93,7 +84,7 @@ export class JSBlock extends LogicItem {
|
|
|
93
84
|
//================================================================================
|
|
94
85
|
}
|
|
95
86
|
|
|
96
|
-
classMap
|
|
87
|
+
classMap.JSBlock = JSBlock;
|
|
97
88
|
export default JSBlock;
|
|
98
89
|
//================================================================================
|
|
99
90
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|