@lcap/nasl 0.3.12-beta.1 → 0.3.12-beta.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.
Files changed (70) hide show
  1. package/out/service/logic/checktypeSocket.d.ts +5 -0
  2. package/out/service/logic/checktypeSocket.js +55 -0
  3. package/out/service/logic/checktypeSocket.js.map +1 -0
  4. package/out/service/logic/index.d.ts +3 -0
  5. package/out/service/logic/index.js +4 -1
  6. package/out/service/logic/index.js.map +1 -1
  7. package/out/types/app/App.d.ts +3 -1
  8. package/out/types/app/App.js +17 -0
  9. package/out/types/app/App.js.map +1 -1
  10. package/out/types/app/Service.d.ts +1 -0
  11. package/out/types/app/Service.js +36 -3
  12. package/out/types/app/Service.js.map +1 -1
  13. package/out/types/data/Entity.d.ts +5 -0
  14. package/out/types/data/Entity.js +13 -0
  15. package/out/types/data/Entity.js.map +1 -1
  16. package/out/types/data/Enum.d.ts +4 -0
  17. package/out/types/data/Enum.js +7 -0
  18. package/out/types/data/Enum.js.map +1 -1
  19. package/out/types/data/Module.d.ts +34 -0
  20. package/out/types/data/Module.js +53 -0
  21. package/out/types/data/Module.js.map +1 -0
  22. package/out/types/data/Structure.d.ts +4 -0
  23. package/out/types/data/Structure.js +7 -0
  24. package/out/types/data/Structure.js.map +1 -1
  25. package/out/types/data/dataTypes.js +21 -4
  26. package/out/types/data/dataTypes.js.map +1 -1
  27. package/out/types/data/genBlock/index.d.ts +0 -2
  28. package/out/types/data/genBlock/index.js +0 -2
  29. package/out/types/data/genBlock/index.js.map +1 -1
  30. package/out/types/data/systemTypes.js +73 -0
  31. package/out/types/data/systemTypes.js.map +1 -1
  32. package/out/types/index.d.ts +2 -0
  33. package/out/types/index.js +5 -2
  34. package/out/types/index.js.map +1 -1
  35. package/out/types/logic/Logic.d.ts +4 -0
  36. package/out/types/logic/Logic.js +7 -0
  37. package/out/types/logic/Logic.js.map +1 -1
  38. package/out/types/logic/LogicItem.js +18 -10
  39. package/out/types/logic/LogicItem.js.map +1 -1
  40. package/out/types/logic/Param.js +1 -1
  41. package/out/types/logic/Param.js.map +1 -1
  42. package/out/types/logic/translator.js +75 -51
  43. package/out/types/logic/translator.js.map +1 -1
  44. package/out/types/process/ProcessParam.js +1 -1
  45. package/out/types/process/ProcessParam.js.map +1 -1
  46. package/out/types/typeCheck.js +2 -1
  47. package/out/types/typeCheck.js.map +1 -1
  48. package/package.json +2 -1
  49. package/src/service/logic/checktypeSocket.js +49 -0
  50. package/src/service/logic/index.js +3 -0
  51. package/src/service/modules/api.js +20 -0
  52. package/src/service/modules/index.js +6 -0
  53. package/src/types/app/App.ts +17 -2
  54. package/src/types/app/Service.ts +39 -4
  55. package/src/types/data/Entity.ts +17 -6
  56. package/src/types/data/Enum.ts +5 -0
  57. package/src/types/data/Module.ts +51 -0
  58. package/src/types/data/Structure.ts +5 -0
  59. package/src/types/data/dataTypes.ts +24 -4
  60. package/src/types/data/genBlock/index.ts +0 -2
  61. package/src/types/data/systemTypes.ts +73 -0
  62. package/src/types/index.ts +2 -0
  63. package/src/types/logic/Logic.ts +5 -0
  64. package/src/types/logic/LogicItem.ts +21 -13
  65. package/src/types/logic/Param.ts +1 -1
  66. package/src/types/logic/translator.js +73 -51
  67. package/src/types/process/ProcessParam.ts +1 -1
  68. package/src/types/typeCheck.ts +5 -4
  69. package/src/types/data/genBlock/genCurdBlock.ts +0 -654
  70. package/src/types/data/genBlock/genCurdEditTableBlock.ts +0 -581
@@ -205,35 +205,43 @@ export default function (source) {
205
205
  if (node.type === 'CallLogic') {
206
206
  if (node.calleeCode.startsWith('callInterface_')) {
207
207
  const getParams = (key) => {
208
- // 过滤掉 null 的 param
209
- const nodeParams = (node.params || []).filter((param) => param !== null && param !== 'null' && param !== '');
210
- if (key === 'body') {
211
- let inBody = '';
212
- const bodyStr = [];
213
- nodeParams.filter((t) => t.callInterParamValue)
214
- .forEach((b) => {
215
- const refTarget = Vertex.getVertexByRef(b.callInterParam);
216
- if (refTarget.in === 'body') {
217
- inBody = generateNode(b.callInterParamValue);
218
- } else if (refTarget.in === '') {
219
- bodyStr.push(`["${refTarget.name}"]: ${generateNode(b.callInterParamValue)}`);
220
- }
221
- });
222
-
223
- return inBody || `{${bodyStr.join(',')}}`;
224
- } else {
225
- return nodeParams
226
- .filter((param) => {
227
- const refTarget = Vertex.getVertexByRef(param.callInterParam);
228
- return refTarget && refTarget.in === key;
229
- })
230
- .map((param) => {
231
- const refTarget = Vertex.getVertexByRef(param.callInterParam);
232
- const callInterParamValue = nameToCodeForMemberExpression(param.callInterParamValue);
233
- const value = generateNode(callInterParamValue);
234
-
235
- return `${safeCodeAsKey(refTarget)}: ${value}`;
236
- });
208
+ // 增加参数拼接日志信息
209
+ try {
210
+ // 过滤掉 null param
211
+ const nodeParams = (node.params || []).filter((param) => param !== null && param !== 'null' && param !== '');
212
+ if (key === 'body') {
213
+ let inBody = '';
214
+ const bodyStr = [];
215
+ nodeParams.filter((t) => t.callInterParamValue)
216
+ .forEach((b) => {
217
+ const refTarget = Vertex.getVertexByRef(b.callInterParam);
218
+ if (refTarget.in === 'body') {
219
+ inBody = generateNode(b.callInterParamValue);
220
+ } else if (refTarget.in === '') {
221
+ bodyStr.push(`["${refTarget.name}"]: ${generateNode(b.callInterParamValue)}`);
222
+ }
223
+ });
224
+
225
+ return inBody || `{${bodyStr.join(',')}}`;
226
+ } else {
227
+ return nodeParams
228
+ .filter((param) => {
229
+ const refTarget = Vertex.getVertexByRef(param.callInterParam);
230
+ return refTarget && refTarget.in === key;
231
+ })
232
+ .map((param) => {
233
+ const refTarget = Vertex.getVertexByRef(param.callInterParam);
234
+ const callInterParamValue = nameToCodeForMemberExpression(param.callInterParamValue);
235
+ const value = generateNode(callInterParamValue);
236
+
237
+ return `${safeCodeAsKey(refTarget)}: ${value}`;
238
+ });
239
+ }
240
+ } catch (error) {
241
+ console.log('CallLogic calleeCode: ', node.calleeCode);
242
+ console.log('CallLogic key: ', node.interfaceKey || node.callee || '');
243
+ console.log('params type: ', key);
244
+ throw error;
237
245
  }
238
246
  };
239
247
  const key = node.interfaceKey || node.callee || '';
@@ -264,30 +272,37 @@ export default function (source) {
264
272
  const key = node.interfaceKey || '';
265
273
  const arr = key.split('/');
266
274
  const getParams = (key) => {
267
- // 过滤掉 null 的 param
268
- const nodeParams = (node.params || []).filter((param) => param !== null && param !== 'null' && param !== '');
269
- if (key === 'body') {
270
- const body = (nodeParams || []).find((param) => {
271
- const refTarget = Vertex.getVertexByRef(param.callInterParam);
272
- return refTarget && refTarget.in === key;
273
- });
274
- if (body) {
275
- return generateNode(body.callInterParamValue);
276
- }
277
- return '{}';
278
- } else {
279
- return nodeParams
280
- .filter((param) => {
275
+ // 增加参数拼接日志信息
276
+ try {
277
+ // 过滤掉 null param
278
+ const nodeParams = (node.params || []).filter((param) => param !== null && param !== 'null' && param !== '');
279
+ if (key === 'body') {
280
+ const body = (nodeParams || []).find((param) => {
281
281
  const refTarget = Vertex.getVertexByRef(param.callInterParam);
282
282
  return refTarget && refTarget.in === key;
283
- })
284
- .map((param) => {
285
- const refTarget = Vertex.getVertexByRef(param.callInterParam);
286
- const callInterParamValue = nameToCodeForMemberExpression(param.callInterParamValue);
287
- const value = generateNode(callInterParamValue);
288
-
289
- return `${safeCodeAsKey(refTarget)}: ${value}`;
290
283
  });
284
+ if (body) {
285
+ return generateNode(body.callInterParamValue);
286
+ }
287
+ return '{}';
288
+ } else {
289
+ return nodeParams
290
+ .filter((param) => {
291
+ const refTarget = Vertex.getVertexByRef(param.callInterParam);
292
+ return refTarget && refTarget.in === key;
293
+ })
294
+ .map((param) => {
295
+ const refTarget = Vertex.getVertexByRef(param.callInterParam);
296
+ const callInterParamValue = nameToCodeForMemberExpression(param.callInterParamValue);
297
+ const value = generateNode(callInterParamValue);
298
+
299
+ return `${safeCodeAsKey(refTarget)}: ${value}`;
300
+ });
301
+ }
302
+ } catch (error) {
303
+ console.log('CallInterface key: ', node.interfaceKey || '');
304
+ console.log('params type: ', key);
305
+ throw error;
291
306
  }
292
307
  };
293
308
 
@@ -604,7 +619,14 @@ export default function (source) {
604
619
  }
605
620
 
606
621
  if (node.type === 'BuiltInFunction') {
607
- const params = (node.builtInFuncParams || []).map((param) => generateNode(param.builtInFuncParamValue));
622
+ let params = (node.builtInFuncParams || []).map((param) => generateNode(param.builtInFuncParamValue));
623
+ if (node.calleeCode === 'Split') {
624
+ // Bug-34789: 参考 url 转义规则对 ' 转义
625
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
626
+ params = params.map((param) => (param.replace(/'(.*)'/, (match, p1) => `'${p1.replace(/'/g, '%27')}'`)));
627
+ if (params.find((param) => param.includes('%27')))
628
+ return `this.$utils['${node.calleeCode}'](${params.join(',')}).map((item) => item.replace(/%27/g, "'"))`;
629
+ }
608
630
  return `this.$utils['${node.calleeCode}'](${params.join(',')})`;
609
631
  }
610
632
 
@@ -68,7 +68,7 @@ export class ProcessParam extends Param {
68
68
  config.defaultApp?.emit('saved');
69
69
 
70
70
  // 更新所有调用此Logic的LogicItem
71
- // await this.process.launchProcessInterface.logic.callLogicUpdate();
71
+ await this.process.launchProcessInterface.logic.callLogicUpdate();
72
72
  return this;
73
73
  }
74
74
  /**
@@ -25,14 +25,15 @@ export default {
25
25
  push(record: TypeCheckRecord) {
26
26
  const pos = this.deleteOwn(record.id);
27
27
 
28
- if(record.typeCheckNote?.message?.filter)
28
+ if (record.typeCheckNote?.message?.filter)
29
29
  record.typeCheckNote.message = record.typeCheckNote.message.filter((item) => !!item);
30
30
 
31
- if(!record.typeCheckNote || record.typeCheckNote.status === 'success'
32
- || (record.typeCheckNote && record.typeCheckNote.message && record.typeCheckNote.message.length === 0))
31
+ // typeCheckNote.message 不存在时,视为误报
32
+ if (!record.typeCheckNote || record.typeCheckNote.status === 'success'
33
+ || !record.typeCheckNote.message || record.typeCheckNote.message.length === 0)
33
34
  return;
34
35
 
35
- if(pos === -1)
36
+ if (pos === -1)
36
37
  this.records.unshift(record);
37
38
  else
38
39
  this.records.splice(pos, 0, record);