@lcap/nasl 3.8.0-beta.6 → 3.8.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/.mocharc.js +1 -0
  2. package/out/common/BaseNode.d.ts +19 -3
  3. package/out/common/BaseNode.js +85 -7
  4. package/out/common/BaseNode.js.map +1 -1
  5. package/out/concepts/AbstractInterface__.js.map +1 -1
  6. package/out/concepts/Annotation__.js +1 -1
  7. package/out/concepts/Annotation__.js.map +1 -1
  8. package/out/concepts/App__.d.ts +3 -0
  9. package/out/concepts/App__.js +964 -4
  10. package/out/concepts/App__.js.map +1 -1
  11. package/out/concepts/Argument__.js +3 -3
  12. package/out/concepts/Argument__.js.map +1 -1
  13. package/out/concepts/BatchAssignment__.d.ts +1 -1
  14. package/out/concepts/BatchAssignment__.js +2 -2
  15. package/out/concepts/BatchAssignment__.js.map +1 -1
  16. package/out/concepts/BindAttribute__.js +3 -4
  17. package/out/concepts/BindAttribute__.js.map +1 -1
  18. package/out/concepts/BindDirective__.js +3 -4
  19. package/out/concepts/BindDirective__.js.map +1 -1
  20. package/out/concepts/BusinessComponent__.d.ts +2 -0
  21. package/out/concepts/BusinessComponent__.js +48 -0
  22. package/out/concepts/BusinessComponent__.js.map +1 -1
  23. package/out/concepts/BusinessLogic__.d.ts +1 -0
  24. package/out/concepts/BusinessLogic__.js +10 -0
  25. package/out/concepts/BusinessLogic__.js.map +1 -1
  26. package/out/concepts/CallEvent__.d.ts +2 -0
  27. package/out/concepts/CallEvent__.js +75 -0
  28. package/out/concepts/CallEvent__.js.map +1 -1
  29. package/out/concepts/CallInterface__.d.ts +1 -0
  30. package/out/concepts/CallInterface__.js +26 -15
  31. package/out/concepts/CallInterface__.js.map +1 -1
  32. package/out/concepts/CallLogic__.d.ts +4 -0
  33. package/out/concepts/CallLogic__.js +59 -3
  34. package/out/concepts/CallLogic__.js.map +1 -1
  35. package/out/concepts/Entity__.d.ts +3 -3
  36. package/out/concepts/Entity__.js +4 -0
  37. package/out/concepts/Entity__.js.map +1 -1
  38. package/out/concepts/Event__.d.ts +2 -0
  39. package/out/concepts/Event__.js +30 -0
  40. package/out/concepts/Event__.js.map +1 -1
  41. package/out/concepts/FrontendType__.d.ts +2 -0
  42. package/out/concepts/FrontendType__.js +32 -0
  43. package/out/concepts/FrontendType__.js.map +1 -1
  44. package/out/concepts/Frontend__.d.ts +2 -0
  45. package/out/concepts/Frontend__.js +48 -0
  46. package/out/concepts/Frontend__.js.map +1 -1
  47. package/out/concepts/IfStatement__.js +6 -6
  48. package/out/concepts/IfStatement__.js.map +1 -1
  49. package/out/concepts/InterfaceParam__.d.ts +1 -0
  50. package/out/concepts/InterfaceParam__.js +23 -4
  51. package/out/concepts/InterfaceParam__.js.map +1 -1
  52. package/out/concepts/Interface__.d.ts +2 -1
  53. package/out/concepts/Interface__.js +29 -5
  54. package/out/concepts/Interface__.js.map +1 -1
  55. package/out/concepts/JSBlock__.d.ts +1 -0
  56. package/out/concepts/JSBlock__.js +6 -0
  57. package/out/concepts/JSBlock__.js.map +1 -1
  58. package/out/concepts/LogicDeclaration__.d.ts +1 -0
  59. package/out/concepts/LogicDeclaration__.js +58 -7
  60. package/out/concepts/LogicDeclaration__.js.map +1 -1
  61. package/out/concepts/Logic__.js +32 -22
  62. package/out/concepts/Logic__.js.map +1 -1
  63. package/out/concepts/MatchCase__.js +1 -2
  64. package/out/concepts/MatchCase__.js.map +1 -1
  65. package/out/concepts/Match__.js +3 -18
  66. package/out/concepts/Match__.js.map +1 -1
  67. package/out/concepts/MemberExpression__.js +1 -1
  68. package/out/concepts/MemberExpression__.js.map +1 -1
  69. package/out/concepts/Module__.d.ts +2 -0
  70. package/out/concepts/Module__.js +64 -0
  71. package/out/concepts/Module__.js.map +1 -1
  72. package/out/concepts/NewComposite__.d.ts +1 -1
  73. package/out/concepts/NewComposite__.js +2 -2
  74. package/out/concepts/NewComposite__.js.map +1 -1
  75. package/out/concepts/Paginate__.d.ts +1 -0
  76. package/out/concepts/Paginate__.js +15 -7
  77. package/out/concepts/Paginate__.js.map +1 -1
  78. package/out/concepts/QueryFromExpression__.js +2 -2
  79. package/out/concepts/QueryFromExpression__.js.map +1 -1
  80. package/out/concepts/StringLiteral__.js +3 -4
  81. package/out/concepts/StringLiteral__.js.map +1 -1
  82. package/out/concepts/TypeAnnotation__.js +1 -0
  83. package/out/concepts/TypeAnnotation__.js.map +1 -1
  84. package/out/concepts/ViewElement__.d.ts +2 -0
  85. package/out/concepts/ViewElement__.js +8 -5
  86. package/out/concepts/ViewElement__.js.map +1 -1
  87. package/out/concepts/View__.d.ts +1 -0
  88. package/out/concepts/View__.js +55 -1
  89. package/out/concepts/View__.js.map +1 -1
  90. package/out/generator/genBundleFiles.js +14 -11
  91. package/out/generator/genBundleFiles.js.map +1 -1
  92. package/out/generator/genHash.d.ts +2 -2
  93. package/out/generator/genHash.js +30 -30
  94. package/out/generator/genHash.js.map +1 -1
  95. package/out/generator/permission.d.ts +8 -1
  96. package/out/generator/permission.js +321 -23
  97. package/out/generator/permission.js.map +1 -1
  98. package/out/generator/release-body/body.js +18 -4
  99. package/out/generator/release-body/body.js.map +1 -1
  100. package/out/generator/release-body/data.js +6 -2
  101. package/out/generator/release-body/data.js.map +1 -1
  102. package/out/generator/release-body/utils.js +3 -3
  103. package/out/generator/release-body/utils.js.map +1 -1
  104. package/out/generator/release-body/validation.js +2 -2
  105. package/out/generator/release-body/validation.js.map +1 -1
  106. package/out/index.d.ts +1 -1
  107. package/out/index.js.map +1 -1
  108. package/out/natural/genNaturalTS.d.ts +2 -2
  109. package/out/natural/genNaturalTS.js +7 -7
  110. package/out/natural/genNaturalTS.js.map +1 -1
  111. package/out/natural/getContext/index.d.ts +1 -1
  112. package/out/natural/getContext/index.js +15 -9
  113. package/out/natural/getContext/index.js.map +1 -1
  114. package/out/natural/transformTS2UI.js +30 -11
  115. package/out/natural/transformTS2UI.js.map +1 -1
  116. package/out/natural/transformTSCode.js +30 -11
  117. package/out/natural/transformTSCode.js.map +1 -1
  118. package/out/server/entity2LogicNamespace.d.ts +2 -2
  119. package/out/server/entity2LogicNamespace.js +321 -310
  120. package/out/server/entity2LogicNamespace.js.map +1 -1
  121. package/out/server/extendBaseNode.js +25 -0
  122. package/out/server/extendBaseNode.js.map +1 -1
  123. package/out/server/naslServer.d.ts +1 -1
  124. package/out/server/naslServer.js +23 -16
  125. package/out/server/naslServer.js.map +1 -1
  126. package/out/server/translator.js +12 -0
  127. package/out/server/translator.js.map +1 -1
  128. package/out/templator/genCreateBlock.js +3 -3
  129. package/out/templator/genCreateBlock.js.map +1 -1
  130. package/out/templator/genCurdEditMultipleKeyBlock.js +2 -2
  131. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  132. package/out/templator/genCurdMultipleKeyBlock.js +4 -4
  133. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  134. package/out/templator/genEditTableBlock.js +1 -1
  135. package/out/templator/genEditTableBlock.js.map +1 -1
  136. package/out/templator/genGetBlock.js.map +1 -1
  137. package/out/templator/genGridViewBlock.js.map +1 -1
  138. package/out/templator/genSelectBlock.js.map +1 -1
  139. package/out/templator/genTableBlock.js.map +1 -1
  140. package/out/templator/genUpdateBlock.js +3 -3
  141. package/out/templator/genUpdateBlock.js.map +1 -1
  142. package/out/templator/utils.js +1 -1
  143. package/out/templator/utils.js.map +1 -1
  144. package/package.json +5 -5
  145. package/src/common/BaseNode.ts +91 -11
  146. package/src/concepts/AbstractInterface__.ts +1 -0
  147. package/src/concepts/Annotation__.ts +1 -1
  148. package/src/concepts/App__.ts +104 -4
  149. package/src/concepts/Argument__.ts +3 -3
  150. package/src/concepts/BatchAssignment__.ts +2 -2
  151. package/src/concepts/BindAttribute__.ts +3 -4
  152. package/src/concepts/BindDirective__.ts +3 -4
  153. package/src/concepts/BusinessComponent__.ts +54 -1
  154. package/src/concepts/BusinessLogic__.ts +10 -1
  155. package/src/concepts/CallEvent__.ts +66 -0
  156. package/src/concepts/CallInterface__.ts +21 -9
  157. package/src/concepts/CallLogic__.ts +59 -3
  158. package/src/concepts/Entity__.ts +7 -1
  159. package/src/concepts/Event__.ts +32 -0
  160. package/src/concepts/FrontendType__.ts +34 -1
  161. package/src/concepts/Frontend__.ts +51 -0
  162. package/src/concepts/IfStatement__.ts +6 -6
  163. package/src/concepts/InterfaceParam__.ts +23 -4
  164. package/src/concepts/Interface__.ts +29 -5
  165. package/src/concepts/JSBlock__.ts +5 -0
  166. package/src/concepts/LogicDeclaration__.ts +65 -7
  167. package/src/concepts/Logic__.ts +34 -25
  168. package/src/concepts/MatchCase__.ts +1 -2
  169. package/src/concepts/Match__.ts +3 -21
  170. package/src/concepts/MemberExpression__.ts +1 -1
  171. package/src/concepts/Module__.ts +75 -0
  172. package/src/concepts/NewComposite__.ts +2 -2
  173. package/src/concepts/Paginate__.ts +14 -7
  174. package/src/concepts/QueryFromExpression__.ts +2 -2
  175. package/src/concepts/StringLiteral__.ts +3 -4
  176. package/src/concepts/TypeAnnotation__.ts +1 -0
  177. package/src/concepts/ViewElement__.ts +9 -5
  178. package/src/concepts/View__.ts +56 -1
  179. package/src/generator/genBundleFiles.ts +14 -11
  180. package/src/generator/genHash.ts +32 -6
  181. package/src/generator/permission.ts +333 -23
  182. package/src/generator/release-body/body.ts +24 -5
  183. package/src/generator/release-body/data.ts +7 -2
  184. package/src/generator/release-body/utils.ts +3 -3
  185. package/src/generator/release-body/validation.ts +1 -1
  186. package/src/index.ts +13 -1
  187. package/src/natural/genNaturalTS.ts +9 -7
  188. package/src/natural/getContext/index.ts +17 -11
  189. package/src/natural/transformTS2UI.ts +28 -11
  190. package/src/natural/transformTSCode.ts +28 -11
  191. package/src/server/entity2LogicNamespace.ts +13 -1
  192. package/src/server/extendBaseNode.ts +31 -0
  193. package/src/server/naslServer.ts +32 -23
  194. package/src/server/translator.ts +15 -0
  195. package/src/templator/genCreateBlock.ts +4 -4
  196. package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -2
  197. package/src/templator/genCurdMultipleKeyBlock.ts +7 -7
  198. package/src/templator/genEditTableBlock.ts +4 -4
  199. package/src/templator/genGetBlock.ts +1 -1
  200. package/src/templator/genGridViewBlock.ts +2 -2
  201. package/src/templator/genSelectBlock.ts +3 -3
  202. package/src/templator/genTableBlock.ts +2 -2
  203. package/src/templator/genUpdateBlock.ts +6 -6
  204. package/src/templator/utils.ts +1 -1
  205. package/test/concepts/string-literal/__snapshots__/toVue.spec.ts.snap +1 -1
  206. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +6 -2
@@ -1,6 +1,6 @@
1
1
  import { config } from '../config';
2
2
  import * as utils from '../utils';
3
- import { App, Module, Namespace, Entity, EntityProperty, View, DataSource, ViewElement } from '../concepts';
3
+ import { App, Module, Namespace, Entity, EntityProperty, View, DataSource, ViewElement, Logic } from '../concepts';
4
4
  import { NameGroup, genUniqueQueryNameGroup, getFirstDisplayedProperty, genQueryLogic, genLogicParam, genCallComponentLogic } from '.';
5
5
  import { NaslUITypeAnnotation, NaslCollectionTypeAnnotation, NaslLogicItem, NaslTypeAnnotation, NaslNode } from './utils';
6
6
 
@@ -103,7 +103,7 @@ export function genLoadSelectLogic(entity: Entity, nameGroup: NameGroup, newLogi
103
103
  * @param view
104
104
  * @returns
105
105
  */
106
- export function genSelectBlock(entity: Entity, oldNode: ViewElement,
106
+ export function genSelectBlock(entity: Entity, oldNode: ViewElement,
107
107
  genSelectTemplateLocal?: (property: EntityProperty, nameGroup: NameGroup, newLogic: any) => string ) {
108
108
  const likeComponent = oldNode?.likeComponent;
109
109
  const dataSource = entity.parentNode as DataSource;
@@ -304,7 +304,7 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
304
304
  );
305
305
  if (entity && entity.concept === 'Entity') {
306
306
  const { ns } = entity;
307
- const createLogic = ns?.logics?.find((logic) => logic.name === `create`);
307
+ const createLogic = ns?.logics?.find((logic : Logic) => logic.name === `create`);
308
308
  callLogics.push(
309
309
  NaslLogicItem.Assignment({
310
310
  left: NaslLogicItem.Identifier({
@@ -1,5 +1,5 @@
1
1
  import * as utils from '../utils';
2
- import { App, Module, Namespace, Entity, EntityProperty, View, DataSource, ViewElement } from '../concepts';
2
+ import { App, Module, Namespace, Entity, EntityProperty, View, DataSource, ViewElement, Logic } from '../concepts';
3
3
  import {
4
4
  filterProperty,
5
5
  NameGroup,
@@ -165,7 +165,7 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
165
165
  const currentName = nameGroup.currentName || 'current';
166
166
 
167
167
  const { ns } = entity;
168
- const deleteLogic = ns?.logics?.find((logic) => logic.name === 'delete');
168
+ const deleteLogic = ns?.logics?.find((logic : Logic) => logic.name === 'delete');
169
169
  const idPropertys = entity.properties.filter((property) => property.primaryKey);
170
170
  return NaslNode.Logic({
171
171
  name: nameGroup.viewLogicRemove,
@@ -87,7 +87,7 @@ export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
87
87
  } else if (propertyTypeName === 'DateTime') {
88
88
  formItem += `<u-date-time-picker :clearable="true" :value.sync="${vModel}" placeholder="请输入${label}"></u-date-time-picker>`;
89
89
  } else {
90
- const namespaceArr = propertyTypeNamespace.split('.');
90
+ const namespaceArr = propertyTypeNamespace?.split?.('.') || [];
91
91
  const type = namespaceArr.pop();
92
92
  if (type === 'enums') {
93
93
  const Enum = dataSource.app.findNodeByCompleteName(propertyTypeNamespace + '.' + propertyTypeName) as Enum;
@@ -196,7 +196,7 @@ export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, se
196
196
  } else if (propertyTypeName === 'DateTime') {
197
197
  formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-datetime-picker type="datetime" v-model="${vModel}" title="请选择${label}" labelField="" inputAlign="left"></van-datetime-picker></van-linear-layout></template>`;
198
198
  } else {
199
- const namespaceArr = propertyTypeNamespace.split('.');
199
+ const namespaceArr = propertyTypeNamespace?.split?.('.') || [];
200
200
  const type = namespaceArr.pop();
201
201
  if (type === 'enums') {
202
202
  formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal">${genEnumSelectBlock(
@@ -295,7 +295,7 @@ function genLoadLogic(getLogic: Logic, nameGroup: NameGroup) {
295
295
 
296
296
  // 生成修改区块
297
297
  export function genUpdateBlock(entity: Entity, oldNode: ViewElement, useViewVariable = true,
298
- genUpdateTemplate?: (entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) => string,
298
+ genUpdateTemplate?: (entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) => string,
299
299
  genLoadLogicLocal?: (getLogic: Logic, nameGroup: NameGroup, entity?: Entity) => any,
300
300
  genSubmitLogicLocal?: (updateLogic: Logic, nameGroup: NameGroup) => any) {
301
301
  const likeComponent = oldNode?.likeComponent;
@@ -303,8 +303,8 @@ export function genUpdateBlock(entity: Entity, oldNode: ViewElement, useViewVari
303
303
  const dataSource = entity.parentNode as DataSource;
304
304
  const module = dataSource.app;
305
305
  const { ns } = entity;
306
- const getLogic = ns?.logics?.find((logic) => logic.name === `get`);
307
- const updateLogic = ns?.logics?.find((logic) => logic.name === `update`);
306
+ const getLogic = ns?.logics?.find((logic : Logic) => logic.name === `get`);
307
+ const updateLogic = ns?.logics?.find((logic : Logic) => logic.name === `update`);
308
308
 
309
309
  const nameGroup: NameGroup = {};
310
310
  nameGroup.viewElementMainView = likeComponent.getViewElementUniqueName('form1');
@@ -364,7 +364,7 @@ export function genUpdateBlock(entity: Entity, oldNode: ViewElement, useViewVari
364
364
  )}
365
365
  }` : ''
366
366
  }
367
-
367
+
368
368
  ],
369
369
  "viewLogics": [
370
370
  ${JSON.stringify((genLoadLogicLocal || genLoadLogic)(getLogic, nameGroup, entity))},
@@ -19,7 +19,7 @@ export function getExpression(property: EntityProperty, expression: string) {
19
19
  if (propertyTypeName === 'DateTime') return `$utils['FormatDateTime'](${expression}, 'YYYY-MM-DD HH:mm:ss')`;
20
20
  if (propertyTypeName === 'Date') return `$utils['FormatDate'](${expression}, 'YYYY-MM-DD')`;
21
21
 
22
- const namespaceArr = propertyTypeNamespace.split('.');
22
+ const namespaceArr = propertyTypeNamespace?.split?.('.') || [];
23
23
  const type = namespaceArr.pop();
24
24
  if (type === 'enums') {
25
25
  return `$utils['EnumValueToText'](${expression}, '__enumTypeAnnotation_${propertyTypeNamespace}.${propertyTypeName}')`;
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`string-literal:toVue escape 1`] = `
4
- "<template>\`\\\\\\"123\\\\\\"123\\\\\\\\123\\\\\`\`</template>
4
+ "<template>\`\\\\\\\\\\"123\\\\\\\\\\"123\\\\\\\\\\\\\\\\123\\\\\\\\\`\`</template>
5
5
  "
6
6
  `;
7
7
 
@@ -103,7 +103,9 @@ exports[`view-element:toVue table-data-source-calllogic-with-server-validation 1
103
103
  >
104
104
  <u-table-view
105
105
  :ref=\\"\`tableView_1\`\\"
106
- :data-source=\\"(params) => __tableView_1_handleDataSourceLoad(params)\\"
106
+ :data-source=\\"
107
+ $global.useDatabaseCallback()(__tableView_1_handleDataSourceLoad)
108
+ \\"
107
109
  :data-schema=\\"\`LoadTestTableView_1Structure\`\\"
108
110
  :value-field=\\"\`entity1.id\`\\"
109
111
  :pagination=\\"true\\"
@@ -271,7 +273,9 @@ exports[`view-element:toVue with-table 1`] = `
271
273
  </u-linear-layout>
272
274
  <u-table-view
273
275
  :ref=\\"\`tableView\`\\"
274
- :data-source=\\"(params) => __tableView_handleDataSourceLoad(params)\\"
276
+ :data-source=\\"
277
+ $global.useDatabaseCallback()(__tableView_handleDataSourceLoad)
278
+ \\"
275
279
  :data-schema=\\"\`LoadTestTableView2Structure\`\\"
276
280
  :value-field=\\"\`entity2.id\`\\"
277
281
  :pagination=\\"true\\"