@lcap/nasl 2.14.0-beta.5 → 2.15.1
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/template/process.js +10298 -9487
- package/out/automate/template/process.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +170 -0
- package/out/concepts/AnonymousFunction__.js +439 -0
- package/out/concepts/AnonymousFunction__.js.map +1 -0
- package/out/concepts/AssignmentLine__.d.ts +40 -0
- package/out/concepts/AssignmentLine__.js +109 -0
- package/out/concepts/AssignmentLine__.js.map +1 -0
- package/out/concepts/BatchAssignment__.d.ts +248 -0
- package/out/concepts/BatchAssignment__.js +742 -0
- package/out/concepts/BatchAssignment__.js.map +1 -0
- package/out/concepts/BindDirective__.js +2 -2
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +126 -0
- package/out/concepts/BindStyle__.js +233 -0
- package/out/concepts/BindStyle__.js.map +1 -0
- package/out/concepts/ConstructArgument__.d.ts +40 -0
- package/out/concepts/ConstructArgument__.js +108 -0
- package/out/concepts/ConstructArgument__.js.map +1 -0
- package/out/concepts/Construct__.d.ts +189 -0
- package/out/concepts/Construct__.js +340 -0
- package/out/concepts/Construct__.js.map +1 -0
- package/out/concepts/Interface__.d.ts +1 -0
- package/out/concepts/Interface__.js +17 -5
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +256 -0
- package/out/concepts/MatchCase__.js +584 -0
- package/out/concepts/MatchCase__.js.map +1 -0
- package/out/concepts/Match__.d.ts +117 -0
- package/out/concepts/Match__.js +434 -0
- package/out/concepts/Match__.js.map +1 -0
- package/out/concepts/OqlQueryComponent__.d.ts +73 -0
- package/out/concepts/OqlQueryComponent__.js +395 -0
- package/out/concepts/OqlQueryComponent__.js.map +1 -0
- package/out/concepts/ProcessElement__.js +6 -4
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +141 -0
- package/out/concepts/SelectMembers__.js +290 -0
- package/out/concepts/SelectMembers__.js.map +1 -0
- package/out/concepts/SqlQueryComponent__.d.ts +4 -0
- package/out/concepts/SqlQueryComponent__.js +144 -2
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Variable__.js +0 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +10 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/generator/genMetaData.d.ts +10 -1
- package/out/generator/genMetaData.js +28 -34
- package/out/generator/genMetaData.js.map +1 -1
- package/out/server/extendBaseNode.js +17 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/naslServer.js +14 -0
- package/out/server/naslServer.js.map +1 -1
- package/out/server/stdlib/nasl.annotation.d.ts +4 -0
- package/out/server/stdlib/nasl.annotation.js +1 -0
- package/out/server/stdlib/nasl.annotation.js.map +1 -0
- package/out/server/stdlib/nasl.auth.d.ts +30 -0
- package/out/server/stdlib/nasl.auth.js +1 -0
- package/out/server/stdlib/nasl.auth.js.map +1 -0
- package/out/server/stdlib/nasl.browser.d.ts +5 -0
- package/out/server/stdlib/nasl.browser.js +1 -0
- package/out/server/stdlib/nasl.browser.js.map +1 -0
- package/out/server/stdlib/nasl.collection.d.ts +22 -0
- package/out/server/stdlib/nasl.collection.js +1 -0
- package/out/server/stdlib/nasl.collection.js.map +1 -0
- package/out/server/stdlib/nasl.configuration.d.ts +3 -0
- package/out/server/stdlib/nasl.configuration.js +1 -0
- package/out/server/stdlib/nasl.configuration.js.map +1 -0
- package/out/server/stdlib/nasl.core.d.ts +104 -0
- package/out/server/stdlib/nasl.core.js +1 -0
- package/out/server/stdlib/nasl.core.js.map +1 -0
- package/out/server/stdlib/nasl.interface.d.ts +7 -0
- package/out/server/stdlib/nasl.interface.js +1 -0
- package/out/server/stdlib/nasl.interface.js.map +1 -0
- package/out/server/stdlib/nasl.langUtil.d.ts +28 -0
- package/out/server/stdlib/nasl.langUtil.js +1 -0
- package/out/server/stdlib/nasl.langUtil.js.map +1 -0
- package/out/server/stdlib/nasl.process.d.ts +50 -0
- package/out/server/stdlib/nasl.process.js +1 -0
- package/out/server/stdlib/nasl.process.js.map +1 -0
- package/out/server/stdlib/nasl.ui.d.ts +186 -0
- package/out/server/stdlib/nasl.ui.definition.d.ts +1072 -0
- package/out/server/stdlib/nasl.ui.definition.js +632 -0
- package/out/server/stdlib/nasl.ui.definition.js.map +1 -0
- package/out/server/stdlib/nasl.ui.js +1 -0
- package/out/server/stdlib/nasl.ui.js.map +1 -0
- package/out/server/stdlib/nasl.util.d.ts +74 -0
- package/out/server/stdlib/nasl.util.js +4 -0
- package/out/server/stdlib/nasl.util.js.map +1 -0
- package/out/server/stdlib/nasl.validation.d.ts +32 -0
- package/out/server/stdlib/nasl.validation.js +1 -0
- package/out/server/stdlib/nasl.validation.js.map +1 -0
- package/out/server/translator.js +4 -0
- package/out/server/translator.js.map +1 -1
- package/out/service/logic/api.d.ts +9 -0
- package/out/service/logic/api.js +11 -0
- package/out/service/logic/api.js.map +1 -0
- package/out/service/logic/index.d.ts +2 -0
- package/out/service/logic/index.js +10 -0
- package/out/service/logic/index.js.map +1 -0
- package/out/templator/genCreateBlock.js +1 -1
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +4 -5
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +5 -3
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +3 -2
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +4 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +1 -1
- package/out/templator/genUpdateBlock.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 +1 -1
- package/src/concepts/BindDirective__.ts +2 -17
- package/src/concepts/Interface__.ts +31 -16
- package/src/concepts/ProcessElement__.ts +8 -6
- package/src/concepts/SqlQueryComponent__.ts +143 -2
- package/src/concepts/Variable__.ts +0 -1
- package/src/concepts/ViewElement__.ts +12 -20
- package/src/generator/genMetaData.ts +55 -37
- package/src/server/extendBaseNode.ts +16 -4
- package/src/server/naslServer.ts +14 -0
- package/src/server/translator.ts +4 -0
- package/src/templator/genCreateBlock.ts +1 -1
- package/src/templator/genCurdEditMultipleKeyBlock.ts +4 -7
- package/src/templator/genCurdMultipleKeyBlock.ts +4 -4
- package/src/templator/genEditTableBlock.ts +5 -3
- package/src/templator/genGetBlock.ts +3 -2
- package/src/templator/genTableBlock.ts +4 -2
- package/src/templator/genUpdateBlock.ts +1 -1
package/package.json
CHANGED
|
@@ -140,10 +140,6 @@ export class BindDirective extends BaseNode {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
143
|
/**
|
|
148
144
|
* 插入逻辑项
|
|
149
145
|
* @internal
|
|
@@ -176,8 +172,6 @@ export class BindDirective extends BaseNode {
|
|
|
176
172
|
return logicItem;
|
|
177
173
|
}
|
|
178
174
|
|
|
179
|
-
|
|
180
|
-
|
|
181
175
|
/**
|
|
182
176
|
* 插入逻辑项
|
|
183
177
|
* @param logicItemOptions 逻辑项参数
|
|
@@ -200,8 +194,6 @@ export class BindDirective extends BaseNode {
|
|
|
200
194
|
return node;
|
|
201
195
|
}
|
|
202
196
|
|
|
203
|
-
|
|
204
|
-
|
|
205
197
|
/**
|
|
206
198
|
* 添加逻辑项
|
|
207
199
|
* @internal
|
|
@@ -221,8 +213,6 @@ export class BindDirective extends BaseNode {
|
|
|
221
213
|
return this._insertItemInPlaygroundAt(options as any, index);
|
|
222
214
|
}
|
|
223
215
|
|
|
224
|
-
|
|
225
|
-
|
|
226
216
|
/**
|
|
227
217
|
* 添加逻辑项
|
|
228
218
|
* @param logicItemOptions 逻辑项参数
|
|
@@ -246,9 +236,6 @@ export class BindDirective extends BaseNode {
|
|
|
246
236
|
return node;
|
|
247
237
|
}
|
|
248
238
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
239
|
/**
|
|
253
240
|
* 删除逻辑项
|
|
254
241
|
* @param name 逻辑项名称
|
|
@@ -274,8 +261,6 @@ export class BindDirective extends BaseNode {
|
|
|
274
261
|
return expression.delete();
|
|
275
262
|
}
|
|
276
263
|
|
|
277
|
-
|
|
278
|
-
|
|
279
264
|
/**
|
|
280
265
|
* 删除逻辑项
|
|
281
266
|
* @param logicItem 已有的逻辑项实例
|
|
@@ -283,7 +268,7 @@ export class BindDirective extends BaseNode {
|
|
|
283
268
|
removeItemInPlayground(logicItem: LogicItem): void;
|
|
284
269
|
|
|
285
270
|
removeItemInPlayground(options: LogicItem) {
|
|
286
|
-
|
|
271
|
+
const logicItem: LogicItem = options;
|
|
287
272
|
return logicItem.delete();
|
|
288
273
|
}
|
|
289
274
|
|
|
@@ -345,7 +330,7 @@ export class BindDirective extends BaseNode {
|
|
|
345
330
|
modifiersString += '.' + key;
|
|
346
331
|
});
|
|
347
332
|
// eslint-disable-next-line no-nested-ternary
|
|
348
|
-
let value = this.type !== 'string' ? this.value : this.value ? `'${this.value}'` : '';
|
|
333
|
+
let value = (this.type ?? 'string') !== 'string' ? this.value : this.value ? `'${this.value}'` : '';
|
|
349
334
|
if (this.expression) {
|
|
350
335
|
value = this.expression.toVue(options);
|
|
351
336
|
if (this.expression.concept === 'StringLiteral') {
|
|
@@ -541,9 +541,25 @@ export class Interface extends BaseNode {
|
|
|
541
541
|
|
|
542
542
|
/* 删除空数据模块 */
|
|
543
543
|
deleteLogincAndModule() {
|
|
544
|
+
this.rootNode.emit('collect:start', {
|
|
545
|
+
actionMsg: `删除接口“${this.name}”`,
|
|
546
|
+
});
|
|
547
|
+
|
|
544
548
|
this.delete();
|
|
549
|
+
this.deleteStructures();
|
|
550
|
+
|
|
551
|
+
if (this.module && this.module.interfaces.length === 0 && this.module.structures.length === 0) {
|
|
552
|
+
this.app.removeModuleInInterfaceDependencies(this.module);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// 结束修改 ,批量操作
|
|
556
|
+
this.rootNode.emit('collect:end');
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/* 删除接口引用的数据结构 */
|
|
560
|
+
deleteStructures() {
|
|
561
|
+
// 需要过滤被其他接口同时引用的数据结构
|
|
545
562
|
|
|
546
|
-
// 删除接口引用的数据结构,需过滤被其他接口同时引用的数据结构
|
|
547
563
|
const structures = (this.parentNode as Module).structures;
|
|
548
564
|
// 递归找出 response/request 的 Body/Returns 引用的数据结构
|
|
549
565
|
const getStructures = (typeAnnotation: TypeAnnotation, result: Array<Structure> = []) => {
|
|
@@ -566,19 +582,22 @@ export class Interface extends BaseNode {
|
|
|
566
582
|
};
|
|
567
583
|
|
|
568
584
|
const otherStructureMap: Record<string, number> = {};
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
585
|
+
// 找出其他接口引用的数据结构
|
|
586
|
+
(this.parentNode as Module).interfaces
|
|
587
|
+
.filter((itf) => itf !== this)
|
|
588
|
+
.forEach((itf) => {
|
|
589
|
+
const params = itf.params || [];
|
|
590
|
+
const returns = itf.returns || [];
|
|
591
|
+
[...params, ...returns].forEach((p) => {
|
|
592
|
+
const strus = getStructures(p.typeAnnotation);
|
|
593
|
+
strus.forEach((s) => {
|
|
594
|
+
if (!(s.name in otherStructureMap)) {
|
|
595
|
+
otherStructureMap[s.name] = 0;
|
|
596
|
+
}
|
|
597
|
+
otherStructureMap[s.name]++;
|
|
598
|
+
});
|
|
579
599
|
});
|
|
580
600
|
});
|
|
581
|
-
});
|
|
582
601
|
const params = this.params || [];
|
|
583
602
|
const returns = this.returns || [];
|
|
584
603
|
[...params, ...returns].forEach((p) => {
|
|
@@ -589,10 +608,6 @@ export class Interface extends BaseNode {
|
|
|
589
608
|
}
|
|
590
609
|
});
|
|
591
610
|
});
|
|
592
|
-
|
|
593
|
-
if (this.module && this.module.interfaces.length === 0 && this.module.structures.length === 0) {
|
|
594
|
-
this.app.removeModuleInInterfaceDependencies(this.module);
|
|
595
|
-
}
|
|
596
611
|
}
|
|
597
612
|
/**
|
|
598
613
|
* 设置逻辑名称
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
2
2
|
import { genUserTaskLogic, getPreviousTask, syncMemberExpression, getFlowAfterElements, isFromStartNode, getFlowBeforeElements } from '../server/getProcesses';
|
|
3
|
-
import naslServer from '@nasl/server';
|
|
4
3
|
import Namespace from './Namespace__';
|
|
5
4
|
import View from './View__';
|
|
6
5
|
//================================================================================
|
|
@@ -258,7 +257,7 @@ export class ProcessElement extends BaseNode {
|
|
|
258
257
|
});
|
|
259
258
|
}
|
|
260
259
|
|
|
261
|
-
|
|
260
|
+
getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
|
|
262
261
|
const excludedSet = new Set(excludedList);
|
|
263
262
|
return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
264
263
|
}
|
|
@@ -1110,7 +1109,7 @@ export class ProcessElement extends BaseNode {
|
|
|
1110
1109
|
}
|
|
1111
1110
|
|
|
1112
1111
|
|
|
1113
|
-
|
|
1112
|
+
|
|
1114
1113
|
|
|
1115
1114
|
/**
|
|
1116
1115
|
* 删除元素绑定事件
|
|
@@ -1560,9 +1559,12 @@ export class ProcessElement extends BaseNode {
|
|
|
1560
1559
|
const view = destination.viewNode;
|
|
1561
1560
|
const name = this.uniqueTaskId(view);
|
|
1562
1561
|
const node = view.params.find((param: any) => param.name === name);
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1562
|
+
if (!node)
|
|
1563
|
+
return;
|
|
1564
|
+
const UsageMap = await node.findUsage();
|
|
1565
|
+
const usageNodes = UsageMap.get(this.process);
|
|
1566
|
+
// console.log(UsageMap, usageNodes)
|
|
1567
|
+
if (!UsageMap.size || (UsageMap.size === 1 && usageNodes && (!usageNodes.children || usageNodes.children.length === 1)))
|
|
1566
1568
|
view.removeParam(name);
|
|
1567
1569
|
}
|
|
1568
1570
|
}));
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
2
|
+
import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
|
|
3
|
+
import StructureProperty from './StructureProperty__';
|
|
4
|
+
|
|
2
5
|
//================================================================================
|
|
3
6
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
4
7
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -151,6 +154,142 @@ export class SqlQueryComponent extends LogicItem {
|
|
|
151
154
|
});
|
|
152
155
|
}
|
|
153
156
|
|
|
157
|
+
getVariableTs(state?: TranslatorState) {
|
|
158
|
+
const str = this.code;
|
|
159
|
+
const variables = [];
|
|
160
|
+
let code = '';
|
|
161
|
+
let temp: any;
|
|
162
|
+
const re = /(\#|\$)\{(.+?)\}/g;
|
|
163
|
+
while (temp = re.exec(str)) {
|
|
164
|
+
variables.push(temp[2]);
|
|
165
|
+
}
|
|
166
|
+
variables.forEach((variable: String) => {
|
|
167
|
+
const content = variable.replaceAll(' ', '');
|
|
168
|
+
code += indent((state?.tabSize || 0) + 2);
|
|
169
|
+
code += content + ';\n';
|
|
170
|
+
});
|
|
171
|
+
return code;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
getTypeBanError() {
|
|
175
|
+
let sqlTypeBan = false;
|
|
176
|
+
if (this.typeAnnotation) {
|
|
177
|
+
const getSqlTypeBan = (typeAnnotation: TypeAnnotation) => {
|
|
178
|
+
const ref = this.getSelectRef(typeAnnotation);
|
|
179
|
+
if (ref?.length) {
|
|
180
|
+
ref.forEach((item: StructureProperty) => {
|
|
181
|
+
// 如果有类型但是类型不是基本类型,就需要打开开关,注入变量
|
|
182
|
+
if (item?.typeAnnotation && item.typeAnnotation.typeNamespace !== 'nasl.core' && !(item.typeAnnotation.typeNamespace.endsWith('.enums'))) {
|
|
183
|
+
sqlTypeBan = true;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
if (this.typeAnnotation.typeArguments?.length) {
|
|
189
|
+
// list 就去校验一下内部的类型
|
|
190
|
+
if (this.typeAnnotation.typeName === 'List') {
|
|
191
|
+
this.typeAnnotation.typeArguments.forEach((item) => {
|
|
192
|
+
getSqlTypeBan(item);
|
|
193
|
+
});
|
|
194
|
+
} else {
|
|
195
|
+
// 别的都不放开
|
|
196
|
+
sqlTypeBan = true;
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
getSqlTypeBan(this.typeAnnotation);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return sqlTypeBan;
|
|
203
|
+
}
|
|
204
|
+
getQueryComponentTsCode(state?: TranslatorState):string {
|
|
205
|
+
let tsCode = '';
|
|
206
|
+
// let sqlParser: null | any = null;
|
|
207
|
+
// let sqlParserErr: null | any = null;
|
|
208
|
+
|
|
209
|
+
if (!this.code)
|
|
210
|
+
return tsCode;
|
|
211
|
+
/**
|
|
212
|
+
* 处理变量,因为解析code,因为sql中不支持
|
|
213
|
+
* #{变量}这种写法
|
|
214
|
+
* 而且不支持a.b.c这种写法保留前两个,翻译的时候补上去
|
|
215
|
+
* 如果是多个.链接的变量就转换成nasl变量,让他可以翻译,等后面在把值换回来
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
try {
|
|
220
|
+
const newCode = this.code.replace(/\#|\$\{(.+?)\}/g, (value, content) => {
|
|
221
|
+
console.log(content)
|
|
222
|
+
const len = content.split('.').length;
|
|
223
|
+
console.log(len, content, content.split('.'), content, content.split('.').length)
|
|
224
|
+
if (len > 2) {
|
|
225
|
+
return '__NASL__SQL__' + content.replaceAll('.', '_');
|
|
226
|
+
}
|
|
227
|
+
return content;
|
|
228
|
+
});
|
|
229
|
+
console.log(newCode);
|
|
230
|
+
// 生成对应的sqlts 和 产生sourceMap对应
|
|
231
|
+
sqlParser = SQLParser(newCode || '', 0, this.dataSource);
|
|
232
|
+
} catch (err) {
|
|
233
|
+
sqlParserErr = err;
|
|
234
|
+
}
|
|
235
|
+
console.log(sqlParser, sqlParserErr);
|
|
236
|
+
if (sqlParserErr) {
|
|
237
|
+
tsCode += '__SQL_GRAMMAR_ERROR__';
|
|
238
|
+
} else if (sqlParser) {
|
|
239
|
+
// 解析内部变量,先看是不是未知变量
|
|
240
|
+
// 使用 tableList 和 columnList
|
|
241
|
+
tsCode += this.getContentVariable(sqlParser, state);
|
|
242
|
+
}
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
try {
|
|
246
|
+
tsCode += this.getVariableTs(state);
|
|
247
|
+
} catch (err) {
|
|
248
|
+
console.log(err);
|
|
249
|
+
}
|
|
250
|
+
return tsCode;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
getSelectRef(newTypeAnnotation: TypeAnnotation) {
|
|
254
|
+
try {
|
|
255
|
+
const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
|
|
256
|
+
let completionChildren;
|
|
257
|
+
if (typeKind === 'reference') {
|
|
258
|
+
if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
|
|
259
|
+
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
260
|
+
const properties = node.properties || [];
|
|
261
|
+
completionChildren = properties;
|
|
262
|
+
} else if (typeNamespace.endsWith('.enums')) {
|
|
263
|
+
completionChildren = undefined;
|
|
264
|
+
} else {
|
|
265
|
+
const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
|
|
266
|
+
const properties = node.properties || [];
|
|
267
|
+
completionChildren = properties;
|
|
268
|
+
}
|
|
269
|
+
} else if (typeKind === 'generic') {
|
|
270
|
+
// if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
|
|
271
|
+
// }
|
|
272
|
+
const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
|
|
273
|
+
const properties = [...node.properties] || [];
|
|
274
|
+
for (let i = 0; i < properties.length; i++) {
|
|
275
|
+
const item = properties[i];
|
|
276
|
+
if (item?.typeAnnotation?.typeKind === 'typeParam') {
|
|
277
|
+
const newItem = StructureProperty.from(item.toJSON());
|
|
278
|
+
newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
|
|
279
|
+
newItem.parentNode = this;
|
|
280
|
+
properties[i] = newItem;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
completionChildren = properties;
|
|
284
|
+
} else {
|
|
285
|
+
completionChildren = undefined;
|
|
286
|
+
}
|
|
287
|
+
return completionChildren;
|
|
288
|
+
} catch (err) {
|
|
289
|
+
console.log(err);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
154
293
|
@withSourceMap()
|
|
155
294
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
156
295
|
let code;
|
|
@@ -164,11 +303,13 @@ export class SqlQueryComponent extends LogicItem {
|
|
|
164
303
|
// app.dataSources.defaultDS;
|
|
165
304
|
if (this.dataSource) {
|
|
166
305
|
code += indent((state?.tabSize || 0) + 1);
|
|
167
|
-
code += `const dataSource = app.dataSources.${this.dataSource}
|
|
306
|
+
code += `const dataSource = app.dataSources.${this.dataSource};\n`;
|
|
168
307
|
}
|
|
308
|
+
// 生成内部的ts内容
|
|
309
|
+
code += this.getQueryComponentTsCode(state);
|
|
169
310
|
code += '\n';
|
|
170
311
|
code += indent((state?.tabSize || 0) + 1) + 'return;\n';
|
|
171
|
-
code += indent((state?.tabSize || 0)) + '})()
|
|
312
|
+
code += indent((state?.tabSize || 0)) + '})()';
|
|
172
313
|
return code;
|
|
173
314
|
}
|
|
174
315
|
|
|
@@ -301,8 +301,6 @@ export class ViewElement extends BaseNode {
|
|
|
301
301
|
super.subConstructor(source);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
|
|
305
|
-
|
|
306
304
|
/**
|
|
307
305
|
* 从父级删除该节点
|
|
308
306
|
* @internal
|
|
@@ -351,7 +349,7 @@ export class ViewElement extends BaseNode {
|
|
|
351
349
|
});
|
|
352
350
|
}
|
|
353
351
|
|
|
354
|
-
|
|
352
|
+
getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
|
|
355
353
|
const excludedSet = new Set(excludedList);
|
|
356
354
|
return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
357
355
|
}
|
|
@@ -492,7 +490,6 @@ export class ViewElement extends BaseNode {
|
|
|
492
490
|
return node;
|
|
493
491
|
}
|
|
494
492
|
|
|
495
|
-
|
|
496
493
|
getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
|
|
497
494
|
const excludedSet = new Set(excludedList);
|
|
498
495
|
return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -634,7 +631,6 @@ export class ViewElement extends BaseNode {
|
|
|
634
631
|
return node;
|
|
635
632
|
}
|
|
636
633
|
|
|
637
|
-
|
|
638
634
|
getBindDirectiveExistingNames(excludedList: Array<BindDirective> = []) {
|
|
639
635
|
const excludedSet = new Set(excludedList);
|
|
640
636
|
return (this.bindDirectives || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
@@ -776,11 +772,6 @@ export class ViewElement extends BaseNode {
|
|
|
776
772
|
return node;
|
|
777
773
|
}
|
|
778
774
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
775
|
/**
|
|
785
776
|
* 插入页面元素
|
|
786
777
|
* @internal
|
|
@@ -914,9 +905,6 @@ export class ViewElement extends BaseNode {
|
|
|
914
905
|
return node;
|
|
915
906
|
}
|
|
916
907
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
908
|
/**
|
|
921
909
|
* 删除元素绑定属性
|
|
922
910
|
* @param name 元素绑定属性名称
|
|
@@ -965,8 +953,6 @@ export class ViewElement extends BaseNode {
|
|
|
965
953
|
return params;
|
|
966
954
|
}
|
|
967
955
|
|
|
968
|
-
|
|
969
|
-
|
|
970
956
|
/**
|
|
971
957
|
* 删除元素绑定事件
|
|
972
958
|
* @param name 元素绑定事件名称
|
|
@@ -1015,8 +1001,6 @@ export class ViewElement extends BaseNode {
|
|
|
1015
1001
|
return params;
|
|
1016
1002
|
}
|
|
1017
1003
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
1004
|
/**
|
|
1021
1005
|
* 删除元素指令
|
|
1022
1006
|
* @param name 元素指令名称
|
|
@@ -1065,8 +1049,6 @@ export class ViewElement extends BaseNode {
|
|
|
1065
1049
|
return params;
|
|
1066
1050
|
}
|
|
1067
1051
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
1052
|
/**
|
|
1071
1053
|
* 删除页面元素
|
|
1072
1054
|
* @param name 页面元素名称
|
|
@@ -1715,7 +1697,9 @@ export class ViewElement extends BaseNode {
|
|
|
1715
1697
|
const emptySlot = api && api.slots && api.slots.find((slot) => slot.name === 'default' && slot['empty-background']);
|
|
1716
1698
|
const hasSupport = api && api.slots && api.slots.some((slot) => slot.support);
|
|
1717
1699
|
if (emptySlot || hasSupport) {
|
|
1718
|
-
|
|
1700
|
+
// 有些限制的组件如侧边栏分组有title插槽但要限制子元素放入
|
|
1701
|
+
const validChildren = el.children.filter((elem) => !(elem.tag === 'template' && elem.slotTarget !== 'default'));
|
|
1702
|
+
let childEmpty = !validChildren.length;
|
|
1719
1703
|
const defaultSlot = el.children.find((elem) => elem.tag === 'template' && elem.slotTarget === 'default');
|
|
1720
1704
|
if (defaultSlot) {
|
|
1721
1705
|
childEmpty = !defaultSlot.children.length;
|
|
@@ -1803,6 +1787,14 @@ export class ViewElement extends BaseNode {
|
|
|
1803
1787
|
});
|
|
1804
1788
|
newOptions.getExtraParts(this).forEach((part) => parts.push(part));
|
|
1805
1789
|
|
|
1790
|
+
if (['u-modal', 'u-drawer'].includes(this.tag)) {
|
|
1791
|
+
this.children.forEach((citem) => {
|
|
1792
|
+
if (citem.tag === 'template' && !citem.children.length) {
|
|
1793
|
+
parts.push(`:is-${citem.slotTarget}-slot-empty=true`);
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1806
1798
|
let partsLength = 0;
|
|
1807
1799
|
let partsString = '';
|
|
1808
1800
|
parts.forEach((part) => {
|
|
@@ -1,42 +1,61 @@
|
|
|
1
|
-
import { App,
|
|
1
|
+
import { App, View, BaseNode, Module, Interface, Entity, Structure, Enum, uiStructures, collectionStructures, processStructures, Logic, Process, DataSource } from '../concepts';
|
|
2
2
|
|
|
3
|
-
export function genMetaData(app: App
|
|
3
|
+
export function genMetaData(app: App,
|
|
4
|
+
config: {
|
|
5
|
+
tenant: string;
|
|
6
|
+
env: string;
|
|
7
|
+
nuimsDomain: string;
|
|
8
|
+
envNuimsDomain: Object;
|
|
9
|
+
STATIC_URL: string;
|
|
10
|
+
USER_STATIC_URL: string;
|
|
11
|
+
extendedConfig: string;
|
|
12
|
+
lowcodeDomain: string;
|
|
13
|
+
}) {
|
|
4
14
|
const modules: Module[] = [];
|
|
5
15
|
const views: View[] = [];
|
|
6
|
-
const
|
|
16
|
+
const dataSources: DataSource[] = [];
|
|
7
17
|
const structures: Structure[] = [];
|
|
8
18
|
const enums: Enum[] = [];
|
|
9
19
|
const logics: Logic[] = [];
|
|
10
20
|
const interfaces: Interface[] = [];
|
|
11
21
|
const processes: Process[] = [];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
dataSources: appDataSources = [],
|
|
25
|
+
structures: appStructures = [],
|
|
26
|
+
enums: appEnums = [],
|
|
27
|
+
logics: appLogics = [],
|
|
28
|
+
interfaceDependencies: appInterfaceDependencies = [],
|
|
29
|
+
dependencies: appDependencies = [],
|
|
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);
|
|
18
42
|
}
|
|
19
|
-
app.structures && structures.push(...app.structures);
|
|
20
|
-
app.enums && enums.push(...app.enums);
|
|
21
|
-
app.logics && logics.push(...app.logics);
|
|
22
|
-
app.processes && processes.push(...app.processes);
|
|
23
|
-
app.dependencies && modules.push(...app.dependencies);
|
|
24
|
-
app.interfaceDependencies && modules.push(...app.interfaceDependencies);
|
|
25
43
|
modules.forEach((module: Module) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
const {
|
|
45
|
+
views: moduleViews = [],
|
|
46
|
+
structures: moduleStructures = [],
|
|
47
|
+
enums: moduleEnums = [],
|
|
48
|
+
logics: moduleLogics = [],
|
|
49
|
+
interfaces: moduleInterfaces = [],
|
|
50
|
+
} = module;
|
|
51
|
+
views.push(...moduleViews);
|
|
52
|
+
structures.push(...moduleStructures);
|
|
53
|
+
enums.push(...moduleEnums);
|
|
54
|
+
logics.push(...moduleLogics);
|
|
55
|
+
interfaces.push(...moduleInterfaces);
|
|
38
56
|
});
|
|
39
57
|
const dataTypes: (Entity | Structure | Enum)[] = [];
|
|
58
|
+
|
|
40
59
|
const dataTypesMap: {
|
|
41
60
|
[id: string]: BaseNode;
|
|
42
61
|
} = {};
|
|
@@ -61,7 +80,6 @@ export function genMetaData(app: App) {
|
|
|
61
80
|
[id: string]: any;
|
|
62
81
|
} = {};
|
|
63
82
|
const allLogics: Logic[] = [];
|
|
64
|
-
|
|
65
83
|
if (Array.isArray(enums)) {
|
|
66
84
|
dataTypes.push(...enums);
|
|
67
85
|
enums.forEach((node) => {
|
|
@@ -75,20 +93,20 @@ export function genMetaData(app: App) {
|
|
|
75
93
|
enumsMap[name] = enumObj;
|
|
76
94
|
});
|
|
77
95
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
if (Array.isArray(dataSources)) {
|
|
97
|
+
dataSources.forEach((dataSource) => {
|
|
98
|
+
dataSource.entities.forEach((entity) => {
|
|
99
|
+
dataTypes.push(entity);
|
|
100
|
+
const ns = entity.ns;
|
|
101
|
+
if (Array.isArray(ns?.logics)) {
|
|
102
|
+
allLogics.push(...ns.logics);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
86
105
|
});
|
|
87
106
|
}
|
|
88
107
|
if (Array.isArray(structures)) {
|
|
89
108
|
dataTypes.push(...structures);
|
|
90
109
|
}
|
|
91
|
-
// console.log(dataTypes);
|
|
92
110
|
|
|
93
111
|
dataTypes.forEach((node) => {
|
|
94
112
|
const namespace = node.getNamespace();
|
|
@@ -207,13 +207,20 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
207
207
|
// 如果没有别的文件的依赖,就直接delete
|
|
208
208
|
if (!find) {
|
|
209
209
|
if (node instanceof Process) {
|
|
210
|
-
|
|
210
|
+
const App = this.rootNode;
|
|
211
|
+
App.emit('collect:start', {
|
|
212
|
+
actionMsg: `删除流程${node.name}`,
|
|
213
|
+
});
|
|
214
|
+
await Promise.all(node.elements.map((ele) => ele.isUserTask && ele.cancelBindDelete(true)));
|
|
215
|
+
this.delete();
|
|
216
|
+
App.emit('collect:end');
|
|
217
|
+
} else {
|
|
218
|
+
this.delete();
|
|
211
219
|
}
|
|
212
|
-
this.delete();
|
|
213
220
|
return;
|
|
214
221
|
}
|
|
215
222
|
}
|
|
216
|
-
callback = () => {
|
|
223
|
+
callback = async () => {
|
|
217
224
|
// removeParam
|
|
218
225
|
// 跟rename 还不太一样,部分修改依赖修改好的值,然后在下面的修改需要把自己传递进去
|
|
219
226
|
if (node instanceof Param) {
|
|
@@ -299,8 +306,13 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
|
|
|
299
306
|
this.delete();
|
|
300
307
|
}
|
|
301
308
|
if (node instanceof Process) {
|
|
302
|
-
|
|
309
|
+
const App = this.rootNode;
|
|
310
|
+
App.emit('collect:start', {
|
|
311
|
+
actionMsg: `删除流程${node.name}`,
|
|
312
|
+
});
|
|
313
|
+
await Promise.all(node.elements.map((ele) => ele.isUserTask && ele.cancelBindDelete(true)));
|
|
303
314
|
this.delete();
|
|
315
|
+
App.emit('collect:end');
|
|
304
316
|
}
|
|
305
317
|
// 其余的都直接调用删除
|
|
306
318
|
// Structure 和 Interface是内部有delete方法
|
package/src/server/naslServer.ts
CHANGED
|
@@ -652,6 +652,20 @@ const naslServer = {
|
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
|
+
if (fileNode instanceof Logic) {
|
|
656
|
+
fileNode?.sourceMap.forEach((value, node) => {
|
|
657
|
+
// SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
|
|
658
|
+
if (node instanceof SqlQueryComponent && node.getTypeBanError()) {
|
|
659
|
+
const diagnostic = {
|
|
660
|
+
node,
|
|
661
|
+
severity: 'error',
|
|
662
|
+
message: 'SQL查询:返回类型内部,不支持复杂类型。',
|
|
663
|
+
};
|
|
664
|
+
node.tsErrorDetail = diagnostic;
|
|
665
|
+
diagnostics.push(diagnostic);
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
}
|
|
655
669
|
|
|
656
670
|
return diagnostics;
|
|
657
671
|
},
|
package/src/server/translator.ts
CHANGED
|
@@ -226,6 +226,10 @@ const TS_RULES: Array<{
|
|
|
226
226
|
re: /Cannot find name '__(?:EMPTY_AGGREGATE_ALIAS)__'/,
|
|
227
227
|
result: '数据查询:聚合函数别名不能为空。',
|
|
228
228
|
},
|
|
229
|
+
{
|
|
230
|
+
re: /Cannot find name '__(?:SQL_GRAMMAR_ERROR)__'/,
|
|
231
|
+
result: 'SQL查询:语句可能有异常。',
|
|
232
|
+
},
|
|
229
233
|
{
|
|
230
234
|
re: /Cannot find name '__UsersEmpty__'./,
|
|
231
235
|
result: '任务完成人为空',
|