@cyberismo/data-handler 0.0.8 → 0.0.10

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 (258) hide show
  1. package/dist/command-handler.d.ts +11 -2
  2. package/dist/command-handler.js +61 -18
  3. package/dist/command-handler.js.map +1 -1
  4. package/dist/command-manager.js +8 -8
  5. package/dist/command-manager.js.map +1 -1
  6. package/dist/commands/calculate.d.ts +7 -44
  7. package/dist/commands/calculate.js +8 -389
  8. package/dist/commands/calculate.js.map +1 -1
  9. package/dist/commands/create.d.ts +6 -3
  10. package/dist/commands/create.js +27 -5
  11. package/dist/commands/create.js.map +1 -1
  12. package/dist/commands/edit.d.ts +15 -3
  13. package/dist/commands/edit.js +52 -9
  14. package/dist/commands/edit.js.map +1 -1
  15. package/dist/commands/export.d.ts +11 -9
  16. package/dist/commands/export.js +80 -28
  17. package/dist/commands/export.js.map +1 -1
  18. package/dist/commands/import.d.ts +7 -0
  19. package/dist/commands/import.js +13 -0
  20. package/dist/commands/import.js.map +1 -1
  21. package/dist/commands/move.d.ts +11 -12
  22. package/dist/commands/move.js +12 -13
  23. package/dist/commands/move.js.map +1 -1
  24. package/dist/commands/remove.d.ts +1 -3
  25. package/dist/commands/remove.js +4 -6
  26. package/dist/commands/remove.js.map +1 -1
  27. package/dist/commands/rename.d.ts +1 -3
  28. package/dist/commands/rename.js +3 -6
  29. package/dist/commands/rename.js.map +1 -1
  30. package/dist/commands/show.d.ts +37 -5
  31. package/dist/commands/show.js +89 -8
  32. package/dist/commands/show.js.map +1 -1
  33. package/dist/commands/transition.d.ts +1 -3
  34. package/dist/commands/transition.js +3 -5
  35. package/dist/commands/transition.js.map +1 -1
  36. package/dist/commands/update.d.ts +5 -1
  37. package/dist/commands/update.js +7 -1
  38. package/dist/commands/update.js.map +1 -1
  39. package/dist/commands/validate.d.ts +7 -0
  40. package/dist/commands/validate.js +31 -4
  41. package/dist/commands/validate.js.map +1 -1
  42. package/dist/containers/card-container.d.ts +6 -0
  43. package/dist/containers/card-container.js +61 -0
  44. package/dist/containers/card-container.js.map +1 -1
  45. package/dist/containers/project/calculation-engine.d.ts +90 -0
  46. package/dist/containers/project/calculation-engine.js +402 -0
  47. package/dist/containers/project/calculation-engine.js.map +1 -0
  48. package/dist/containers/project/resource-collector.js +9 -13
  49. package/dist/containers/project/resource-collector.js.map +1 -1
  50. package/dist/containers/project.d.ts +18 -1
  51. package/dist/containers/project.js +28 -55
  52. package/dist/containers/project.js.map +1 -1
  53. package/dist/containers/template.d.ts +5 -0
  54. package/dist/containers/template.js +9 -0
  55. package/dist/containers/template.js.map +1 -1
  56. package/dist/index.d.ts +5 -2
  57. package/dist/index.js +5 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/interfaces/macros.d.ts +4 -2
  60. package/dist/interfaces/project-interfaces.d.ts +21 -0
  61. package/dist/interfaces/project-interfaces.js +4 -0
  62. package/dist/interfaces/project-interfaces.js.map +1 -1
  63. package/dist/interfaces/resource-interfaces.d.ts +4 -2
  64. package/dist/interfaces/resource-interfaces.js.map +1 -1
  65. package/dist/macros/base-macro.d.ts +2 -1
  66. package/dist/macros/base-macro.js +14 -2
  67. package/dist/macros/base-macro.js.map +1 -1
  68. package/dist/macros/common.d.ts +16 -9
  69. package/dist/macros/common.js +22 -9
  70. package/dist/macros/common.js.map +1 -1
  71. package/dist/macros/createCards/index.d.ts +2 -2
  72. package/dist/macros/createCards/index.js +4 -0
  73. package/dist/macros/createCards/index.js.map +1 -1
  74. package/dist/macros/graph/index.d.ts +1 -3
  75. package/dist/macros/graph/index.js +1 -6
  76. package/dist/macros/graph/index.js.map +1 -1
  77. package/dist/macros/image/index.d.ts +39 -0
  78. package/dist/macros/image/index.js +82 -0
  79. package/dist/macros/image/index.js.map +1 -0
  80. package/dist/macros/image/metadata.d.ts +18 -0
  81. package/dist/macros/image/metadata.js +22 -0
  82. package/dist/macros/image/metadata.js.map +1 -0
  83. package/dist/macros/include/index.d.ts +31 -0
  84. package/dist/macros/include/index.js +94 -0
  85. package/dist/macros/include/index.js.map +1 -0
  86. package/dist/macros/include/metadata.d.ts +15 -0
  87. package/dist/macros/include/metadata.js +19 -0
  88. package/dist/macros/include/metadata.js.map +1 -0
  89. package/dist/macros/index.d.ts +33 -31
  90. package/dist/macros/index.js +142 -71
  91. package/dist/macros/index.js.map +1 -1
  92. package/dist/macros/percentage/index.d.ts +28 -0
  93. package/dist/macros/percentage/index.js +33 -0
  94. package/dist/macros/percentage/index.js.map +1 -0
  95. package/dist/macros/percentage/metadata.d.ts +15 -0
  96. package/dist/macros/percentage/metadata.js +19 -0
  97. package/dist/macros/percentage/metadata.js.map +1 -0
  98. package/dist/macros/report/index.d.ts +2 -6
  99. package/dist/macros/report/index.js +3 -7
  100. package/dist/macros/report/index.js.map +1 -1
  101. package/dist/macros/scoreCard/index.d.ts +14 -15
  102. package/dist/macros/scoreCard/index.js +14 -18
  103. package/dist/macros/scoreCard/index.js.map +1 -1
  104. package/dist/macros/vega/index.d.ts +28 -0
  105. package/dist/macros/vega/index.js +27 -0
  106. package/dist/macros/vega/index.js.map +1 -0
  107. package/dist/macros/vega/metadata.d.ts +15 -0
  108. package/dist/macros/vega/metadata.js +7 -0
  109. package/dist/macros/vega/metadata.js.map +1 -0
  110. package/dist/macros/vegalite/index.d.ts +26 -0
  111. package/dist/macros/vegalite/index.js +24 -0
  112. package/dist/macros/vegalite/index.js.map +1 -0
  113. package/dist/macros/vegalite/metadata.d.ts +15 -0
  114. package/dist/macros/vegalite/metadata.js +7 -0
  115. package/dist/macros/vegalite/metadata.js.map +1 -0
  116. package/dist/macros/xref/index.d.ts +26 -0
  117. package/dist/macros/xref/index.js +53 -0
  118. package/dist/macros/xref/index.js.map +1 -0
  119. package/dist/macros/xref/metadata.d.ts +15 -0
  120. package/dist/macros/xref/metadata.js +19 -0
  121. package/dist/macros/xref/metadata.js.map +1 -0
  122. package/dist/module-manager.d.ts +1 -0
  123. package/dist/module-manager.js +14 -4
  124. package/dist/module-manager.js.map +1 -1
  125. package/dist/permissions/action-guard.d.ts +2 -2
  126. package/dist/permissions/action-guard.js +1 -1
  127. package/dist/permissions/action-guard.js.map +1 -1
  128. package/dist/resources/card-type-resource.d.ts +2 -0
  129. package/dist/resources/card-type-resource.js +63 -0
  130. package/dist/resources/card-type-resource.js.map +1 -1
  131. package/dist/resources/file-resource.d.ts +2 -0
  132. package/dist/resources/file-resource.js +12 -4
  133. package/dist/resources/file-resource.js.map +1 -1
  134. package/dist/resources/folder-resource.d.ts +19 -0
  135. package/dist/resources/folder-resource.js +51 -2
  136. package/dist/resources/folder-resource.js.map +1 -1
  137. package/dist/resources/graph-model-resource.js +1 -1
  138. package/dist/resources/graph-model-resource.js.map +1 -1
  139. package/dist/resources/graph-view-resource.js +1 -1
  140. package/dist/resources/graph-view-resource.js.map +1 -1
  141. package/dist/resources/report-resource.js +1 -1
  142. package/dist/resources/report-resource.js.map +1 -1
  143. package/dist/resources/resource-object.d.ts +8 -0
  144. package/dist/resources/resource-object.js +10 -1
  145. package/dist/resources/resource-object.js.map +1 -1
  146. package/dist/resources/template-resource.js +1 -1
  147. package/dist/resources/template-resource.js.map +1 -1
  148. package/dist/resources/workflow-resource.d.ts +2 -0
  149. package/dist/resources/workflow-resource.js +53 -9
  150. package/dist/resources/workflow-resource.js.map +1 -1
  151. package/dist/svg/index.d.ts +15 -0
  152. package/dist/svg/index.js +16 -0
  153. package/dist/svg/index.js.map +1 -0
  154. package/dist/svg/lib.d.ts +9 -0
  155. package/dist/svg/lib.js +26 -0
  156. package/dist/svg/lib.js.map +1 -0
  157. package/dist/svg/percentage.d.ts +25 -0
  158. package/dist/svg/percentage.js +90 -0
  159. package/dist/svg/percentage.js.map +1 -0
  160. package/dist/svg/scoreCard.d.ts +19 -0
  161. package/dist/svg/scoreCard.js +55 -0
  162. package/dist/svg/scoreCard.js.map +1 -0
  163. package/dist/types/queries.d.ts +8 -7
  164. package/dist/types/queries.js.map +1 -1
  165. package/dist/utils/card-utils.d.ts +6 -0
  166. package/dist/utils/card-utils.js +12 -0
  167. package/dist/utils/card-utils.js.map +1 -1
  168. package/dist/utils/clingo-facts.d.ts +2 -1
  169. package/dist/utils/clingo-facts.js +19 -2
  170. package/dist/utils/clingo-facts.js.map +1 -1
  171. package/dist/utils/clingo-parser.d.ts +1 -0
  172. package/dist/utils/clingo-parser.js +22 -100
  173. package/dist/utils/clingo-parser.js.map +1 -1
  174. package/dist/utils/constants.d.ts +7 -0
  175. package/dist/utils/constants.js +14 -0
  176. package/dist/utils/constants.js.map +1 -1
  177. package/dist/utils/csv.js.map +1 -1
  178. package/dist/utils/report.d.ts +17 -3
  179. package/dist/utils/report.js +38 -2
  180. package/dist/utils/report.js.map +1 -1
  181. package/dist/utils/resource-utils.d.ts +2 -1
  182. package/dist/utils/resource-utils.js +12 -3
  183. package/dist/utils/resource-utils.js.map +1 -1
  184. package/dist/utils/user-preferences.d.ts +1 -11
  185. package/dist/utils/user-preferences.js +30 -13
  186. package/dist/utils/user-preferences.js.map +1 -1
  187. package/dist/utils/validate.d.ts +2 -3
  188. package/dist/utils/validate.js +2 -2
  189. package/dist/utils/validate.js.map +1 -1
  190. package/package.json +8 -6
  191. package/src/command-handler.ts +96 -17
  192. package/src/command-manager.ts +8 -8
  193. package/src/commands/calculate.ts +11 -525
  194. package/src/commands/create.ts +35 -6
  195. package/src/commands/edit.ts +94 -11
  196. package/src/commands/export.ts +104 -31
  197. package/src/commands/import.ts +16 -0
  198. package/src/commands/move.ts +12 -15
  199. package/src/commands/remove.ts +4 -8
  200. package/src/commands/rename.ts +3 -12
  201. package/src/commands/show.ts +126 -9
  202. package/src/commands/transition.ts +3 -7
  203. package/src/commands/update.ts +6 -0
  204. package/src/commands/validate.ts +41 -13
  205. package/src/containers/card-container.ts +74 -0
  206. package/src/containers/project/calculation-engine.ts +535 -0
  207. package/src/containers/project/resource-collector.ts +13 -15
  208. package/src/containers/project.ts +30 -66
  209. package/src/containers/template.ts +16 -0
  210. package/src/index.ts +13 -2
  211. package/src/interfaces/macros.ts +4 -1
  212. package/src/interfaces/project-interfaces.ts +27 -0
  213. package/src/interfaces/resource-interfaces.ts +5 -2
  214. package/src/macros/base-macro.ts +19 -4
  215. package/src/macros/common.ts +22 -9
  216. package/src/macros/createCards/index.ts +6 -2
  217. package/src/macros/graph/index.ts +6 -10
  218. package/src/macros/image/index.ts +128 -0
  219. package/src/macros/image/metadata.ts +25 -0
  220. package/src/macros/include/index.ts +143 -0
  221. package/src/macros/include/metadata.ts +22 -0
  222. package/src/macros/index.ts +150 -98
  223. package/src/macros/percentage/index.ts +50 -0
  224. package/src/macros/percentage/metadata.ts +22 -0
  225. package/src/macros/report/index.ts +4 -12
  226. package/src/macros/scoreCard/index.ts +21 -25
  227. package/src/macros/vega/index.ts +55 -0
  228. package/src/macros/vega/metadata.ts +21 -0
  229. package/src/macros/vegalite/index.ts +46 -0
  230. package/src/macros/vegalite/metadata.ts +21 -0
  231. package/src/macros/xref/index.ts +73 -0
  232. package/src/macros/xref/metadata.ts +22 -0
  233. package/src/module-manager.ts +15 -5
  234. package/src/permissions/action-guard.ts +3 -3
  235. package/src/resources/card-type-resource.ts +100 -0
  236. package/src/resources/file-resource.ts +16 -4
  237. package/src/resources/folder-resource.ts +59 -2
  238. package/src/resources/graph-model-resource.ts +1 -1
  239. package/src/resources/graph-view-resource.ts +1 -1
  240. package/src/resources/report-resource.ts +1 -1
  241. package/src/resources/resource-object.ts +19 -1
  242. package/src/resources/template-resource.ts +1 -1
  243. package/src/resources/workflow-resource.ts +68 -13
  244. package/src/svg/index.ts +15 -0
  245. package/src/svg/lib.ts +31 -0
  246. package/src/svg/percentage.ts +97 -0
  247. package/src/svg/scoreCard.ts +88 -0
  248. package/src/types/queries.ts +8 -7
  249. package/src/types/string-pixel-width.d.ts +23 -0
  250. package/src/utils/card-utils.ts +13 -0
  251. package/src/utils/clingo-facts.ts +65 -3
  252. package/src/utils/clingo-parser.ts +31 -144
  253. package/src/utils/constants.ts +16 -0
  254. package/src/utils/csv.ts +1 -1
  255. package/src/utils/report.ts +45 -4
  256. package/src/utils/resource-utils.ts +12 -2
  257. package/src/utils/user-preferences.ts +32 -14
  258. package/src/utils/validate.ts +3 -3
@@ -1,23 +1,36 @@
1
1
  /**
2
- Cyberismo
3
- Copyright © Cyberismo Ltd and contributors 2024
4
-
5
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
6
-
7
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
8
-
9
- You should have received a copy of the GNU Affero General Public
10
- License along with this program. If not, see <https://www.gnu.org/licenses/>.
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2024
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
11
12
  */
12
13
  // important that this file imports only the metadata
13
14
  import createCards from './createCards/metadata.js';
14
15
  import graph from './graph/metadata.js';
16
+ import image from './image/metadata.js';
17
+ import include from './include/metadata.js';
15
18
  import report from './report/metadata.js';
16
19
  import scoreCard from './scoreCard/metadata.js';
20
+ import xref from './xref/metadata.js';
21
+ import percentage from './percentage/metadata.js';
22
+ import vega from './vega/metadata.js';
23
+ import vegaLite from './vegalite/metadata.js';
17
24
  export const macroMetadata = {
18
25
  createCards,
19
26
  graph,
27
+ image,
28
+ include,
20
29
  report,
21
30
  scoreCard,
31
+ xref,
32
+ percentage,
33
+ vega,
34
+ vegaLite,
22
35
  };
23
36
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/macros/common.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,qDAAqD;AACrD,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,WAAW;IACX,KAAK;IACL,MAAM;IACN,SAAS;CACV,CAAC"}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/macros/common.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,qDAAqD;AACrD,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAChD,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,WAAW;IACX,KAAK;IACL,KAAK;IACL,OAAO;IACP,MAAM;IACN,SAAS;IACT,IAAI;IACJ,UAAU;IACV,IAAI;IACJ,QAAQ;CACT,CAAC"}
@@ -9,11 +9,10 @@
9
9
  You should have received a copy of the GNU Affero General Public
10
10
  License along with this program. If not, see <https://www.gnu.org/licenses/>.
11
11
  */
12
- import type { MacroOptions } from '../index.js';
13
12
  import type { MacroGenerationContext } from '../../interfaces/macros.js';
14
13
  import BaseMacro from '../base-macro.js';
15
14
  import type TaskQueue from '../task-queue.js';
16
- export interface CreateCardsOptions extends MacroOptions {
15
+ export interface CreateCardsOptions {
17
16
  buttonLabel: string;
18
17
  template: string;
19
18
  cardKey?: string;
@@ -31,6 +30,7 @@ declare class CreateCardsMacro extends BaseMacro {
31
30
  handleValidate: (input: unknown) => void;
32
31
  handleStatic(): Promise<string>;
33
32
  handleInject: (_: MacroGenerationContext, input: unknown) => Promise<string>;
33
+ handleStaticSite: () => Promise<string>;
34
34
  private validate;
35
35
  }
36
36
  export default CreateCardsMacro;
@@ -27,6 +27,10 @@ class CreateCardsMacro extends BaseMacro {
27
27
  const options = this.validate(input);
28
28
  return createHtmlPlaceholder(this.metadata, options);
29
29
  };
30
+ handleStaticSite = async () => {
31
+ // export site does not support createCards
32
+ return '';
33
+ };
30
34
  validate(input) {
31
35
  return validateMacroContent(this.metadata, input);
32
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/macros/createCards/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAGF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG1E,OAAO,aAAa,MAAM,eAAe,CAAC;AAC1C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAezC,MAAM,gBAAiB,SAAQ,SAAS;IACtC,YAAY,UAAqB;QAC/B,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,cAAc,GAAG,CAAC,KAAc,EAAE,EAAE;QAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,KAAK,CAAC,YAAY;QAChB,0CAA0C;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,YAAY,GAAG,KAAK,EAAE,CAAyB,EAAE,KAAc,EAAE,EAAE;QACjE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC,CAAC;IAEM,QAAQ,CAAC,KAAc;QAC7B,OAAO,oBAAoB,CAAqB,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/macros/createCards/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG1E,OAAO,aAAa,MAAM,eAAe,CAAC;AAC1C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAezC,MAAM,gBAAiB,SAAQ,SAAS;IACtC,YAAY,UAAqB;QAC/B,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,cAAc,GAAG,CAAC,KAAc,EAAE,EAAE;QAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,KAAK,CAAC,YAAY;QAChB,0CAA0C;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,YAAY,GAAG,KAAK,EAAE,CAAyB,EAAE,KAAc,EAAE,EAAE;QACjE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC,CAAC;IAEF,gBAAgB,GAAG,KAAK,IAAI,EAAE;QAC5B,2CAA2C;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IAEM,QAAQ,CAAC,KAAc;QAC7B,OAAO,oBAAoB,CAAqB,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
@@ -11,10 +11,9 @@
11
11
  License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
12
  */
13
13
  import BaseMacro from '../base-macro.js';
14
- import type { MacroOptions } from '../index.js';
15
14
  import type { MacroGenerationContext } from '../../interfaces/macros.js';
16
15
  import type TaskQueue from '../task-queue.js';
17
- export interface GraphOptions extends MacroOptions {
16
+ export interface GraphOptions {
18
17
  model: string;
19
18
  view: string;
20
19
  }
@@ -22,7 +21,6 @@ declare class ReportMacro extends BaseMacro {
22
21
  constructor(tasksQueue: TaskQueue);
23
22
  handleValidate: (input: unknown) => void;
24
23
  handleStatic: (context: MacroGenerationContext, input: unknown) => Promise<string>;
25
- handleInject: (context: MacroGenerationContext, input: unknown) => Promise<string>;
26
24
  private parseOptions;
27
25
  }
28
26
  export default ReportMacro;
@@ -11,7 +11,6 @@
11
11
  License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
12
  */
13
13
  import BaseMacro from '../base-macro.js';
14
- import { Calculate } from '../../commands/index.js';
15
14
  import { createImage, validateMacroContent } from '../index.js';
16
15
  import Handlebars from 'handlebars';
17
16
  import { join } from 'node:path';
@@ -29,10 +28,6 @@ class ReportMacro extends BaseMacro {
29
28
  this.parseOptions(input);
30
29
  };
31
30
  handleStatic = async (context, input) => {
32
- return this.handleInject(context, input);
33
- };
34
- handleInject = async (context, input) => {
35
- const calculate = new Calculate(context.project);
36
31
  const resourceNameToPath = (name, fileName) => {
37
32
  const { identifier, prefix, type } = resourceName(name);
38
33
  if (prefix === context.project.projectPrefix) {
@@ -74,7 +69,7 @@ class ReportMacro extends BaseMacro {
74
69
  const modelContent = await readFile(modelLocation, { encoding: 'utf-8' });
75
70
  let result;
76
71
  try {
77
- result = await calculate.runGraph(modelContent, view);
72
+ result = await context.project.calculationEngine.runGraph(modelContent, view, context.context);
78
73
  }
79
74
  catch (error) {
80
75
  if (error instanceof ClingoError) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/macros/graph/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OA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QAEF,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAAC;QAEhE,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1E,IAAI,MAAc,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CACvD,YAAY,EACZ,IAAI,EACJ,OAAO,CAAC,OAAO,CAChB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CACb,gCAAgC,OAAO,CAAC,IAAI,eAAe,OAAO,CAAC,KAAK,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChH,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEM,YAAY,CAAC,KAAc;QACjC,OAAO,oBAAoB,CAAe,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAClE,CAAC;CACF;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import type { MacroGenerationContext } from '../../interfaces/macros.js';
14
+ import BaseMacro from '../base-macro.js';
15
+ import type TaskQueue from '../task-queue.js';
16
+ /**
17
+ * Options for the image macro.
18
+ * @param fileName - Name of the file to include.
19
+ * @param cardKey - Key of the card to include the file from.
20
+ * @param alt - Alternative text for the image.
21
+ * @param title - Title of the image.
22
+ */
23
+ export interface ImageMacroOptions {
24
+ fileName: string;
25
+ cardKey?: string;
26
+ alt?: string;
27
+ title?: string;
28
+ }
29
+ /**
30
+ * Macro for including images in the content
31
+ */
32
+ export default class ImageMacro extends BaseMacro {
33
+ constructor(tasksQueue: TaskQueue);
34
+ handleValidate: (input: unknown) => void;
35
+ handleStatic: (context: MacroGenerationContext, input: unknown) => Promise<string>;
36
+ handleInject: (context: MacroGenerationContext, input: unknown) => Promise<string>;
37
+ private buildImageAttributes;
38
+ private validate;
39
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import { existsSync, readFileSync } from 'node:fs';
14
+ import { join } from 'node:path';
15
+ import mime from 'mime-types';
16
+ import { validateMacroContent } from '../index.js';
17
+ import macroMetadata from './metadata.js';
18
+ import BaseMacro from '../base-macro.js';
19
+ /**
20
+ * Macro for including images in the content
21
+ */
22
+ export default class ImageMacro extends BaseMacro {
23
+ constructor(tasksQueue) {
24
+ super(macroMetadata, tasksQueue);
25
+ }
26
+ handleValidate = (input) => {
27
+ this.validate(input);
28
+ };
29
+ handleStatic = async (context, input) => {
30
+ const options = this.validate(input);
31
+ const cardKey = options.cardKey || context.cardKey;
32
+ // Get the attachment folder path
33
+ const attachmentFolder = await context.project.cardAttachmentFolder(cardKey);
34
+ if (!attachmentFolder) {
35
+ throw new Error(`Card '${cardKey}' not found`);
36
+ }
37
+ // Read the file and convert to base64
38
+ const attachmentPath = join(attachmentFolder, options.fileName);
39
+ if (!existsSync(attachmentPath)) {
40
+ throw new Error(`Attachment file '${options.fileName}' not found in card '${cardKey}'`);
41
+ }
42
+ const fileBuffer = readFileSync(attachmentPath);
43
+ const base64Data = fileBuffer.toString('base64');
44
+ // Get mime type
45
+ const mimeType = mime.lookup(attachmentPath) || 'application/octet-stream';
46
+ // Build image attributes
47
+ const attributes = this.buildImageAttributes(options);
48
+ // Return as data URI for static mode (for export/PDF generation)
49
+ return `image::data:${mimeType};base64,${base64Data}[${attributes}]`;
50
+ };
51
+ handleInject = async (context, input) => {
52
+ const options = this.validate(input);
53
+ const cardKey = options.cardKey || context.cardKey;
54
+ // Verify that the card and attachment folder exist
55
+ const attachmentFolder = await context.project.cardAttachmentFolder(cardKey);
56
+ if (!attachmentFolder) {
57
+ throw new Error(`Card '${cardKey}' not found`);
58
+ }
59
+ const attachmentPath = join(attachmentFolder, options.fileName);
60
+ if (!existsSync(attachmentPath)) {
61
+ throw new Error(`Attachment file '${options.fileName}' not found in card '${cardKey}'`);
62
+ }
63
+ // Build image attributes
64
+ const attributes = this.buildImageAttributes(options);
65
+ // In inject mode, always use the API path for consistency
66
+ return `image::/api/cards/${cardKey}/a/${options.fileName}[${attributes}]`;
67
+ };
68
+ buildImageAttributes(options) {
69
+ const attributes = [];
70
+ if (options.alt !== undefined) {
71
+ attributes.push(`alt="${options.alt}"`);
72
+ }
73
+ if (options.title !== undefined) {
74
+ attributes.push(`title="${options.title}"`);
75
+ }
76
+ return attributes.join(',');
77
+ }
78
+ validate(input) {
79
+ return validateMacroContent(this.metadata, input);
80
+ }
81
+ }
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/macros/image/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,aAAa,MAAM,eAAe,CAAC;AAC1C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAiBzC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,SAAS;IAC/C,YAAY,UAAqB;QAC/B,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,cAAc,GAAG,CAAC,KAAc,EAAE,EAAE;QAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,YAAY,GAAG,KAAK,EAClB,OAA+B,EAC/B,KAAc,EACG,EAAE;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;QAEnD,iCAAiC;QACjC,MAAM,gBAAgB,GACpB,MAAM,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,aAAa,CAAC,CAAC;QACjD,CAAC;QAED,sCAAsC;QACtC,MAAM,cAAc,GAAG,IAAI,CAAC,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,CAAC;QACJ,CAAC;QAED,yBAAyB;QACzB,MAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAEtD,0DAA0D;QAC1D,OAAO,qBAAqB,OAAO,MAAM,OAAO,CAAC,QAAQ,IAAI,UAAU,GAAG,CAAC;IAC7E,CAAC,CAAC;IAEM,oBAAoB,CAAC,OAA0B;QACrD,MAAM,UAAU,GAAa,EAAE,CAAC;QAEhC,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YAC9B,UAAU,CAAC,IAAI,CAAC,QAAQ,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAChC,UAAU,CAAC,IAAI,CAAC,UAAU,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAEO,QAAQ,CAAC,KAAc;QAC7B,OAAO,oBAAoB,CAAoB,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import type { MacroMetadata } from '../../interfaces/macros.js';
14
+ /**
15
+ * Metadata for the image macro.
16
+ */
17
+ declare const macroMetadata: MacroMetadata;
18
+ export default macroMetadata;
@@ -0,0 +1,22 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ /**
14
+ * Metadata for the image macro.
15
+ */
16
+ const macroMetadata = {
17
+ name: 'image',
18
+ tagName: 'image',
19
+ schema: 'imageMacroSchema',
20
+ };
21
+ export default macroMetadata;
22
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/macros/image/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAIF;;GAEG;AACH,MAAM,aAAa,GAAkB;IACnC,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,kBAAkB;CAC3B,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import type { MacroGenerationContext } from '../../interfaces/macros.js';
14
+ import BaseMacro from '../base-macro.js';
15
+ import type TaskQueue from '../task-queue.js';
16
+ export interface IncludeMacroOptions {
17
+ cardKey: string;
18
+ levelOffset?: string;
19
+ title?: 'include' | 'exclude' | 'only';
20
+ pageTitles?: 'normal' | 'discrete';
21
+ }
22
+ export default class IncludeMacro extends BaseMacro {
23
+ constructor(tasksQueue: TaskQueue);
24
+ handleValidate: (input: unknown) => void;
25
+ handleStatic: (context: MacroGenerationContext, input: unknown) => Promise<string>;
26
+ private validate;
27
+ private generateAnchor;
28
+ private generateTitle;
29
+ private generateCardContent;
30
+ private adjustTitles;
31
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import { evaluateMacros, validateMacroContent } from '../index.js';
14
+ import macroMetadata from './metadata.js';
15
+ import BaseMacro from '../base-macro.js';
16
+ import { MAX_LEVEL_OFFSET } from '../../utils/constants.js';
17
+ export default class IncludeMacro extends BaseMacro {
18
+ constructor(tasksQueue) {
19
+ super(macroMetadata, tasksQueue);
20
+ }
21
+ handleValidate = (input) => {
22
+ this.validate(input);
23
+ };
24
+ handleStatic = async (context, input) => {
25
+ const options = this.validate(input);
26
+ if (!options.title) {
27
+ options.title = 'include';
28
+ }
29
+ if (!options.pageTitles) {
30
+ options.pageTitles = 'normal';
31
+ }
32
+ const card = await context.project.cardDetailsById(options.cardKey, {
33
+ content: true,
34
+ metadata: true,
35
+ });
36
+ if (!card) {
37
+ throw new Error(`Card key ${options.cardKey} not found`);
38
+ }
39
+ const newContext = {
40
+ ...context,
41
+ cardKey: options.cardKey,
42
+ };
43
+ const anchor = this.generateAnchor(options);
44
+ const title = this.generateTitle(options, card.metadata?.title);
45
+ const cardContent = await this.generateCardContent(options, card.content, newContext);
46
+ const content = `\n\n${anchor}${title}${cardContent}`;
47
+ let levelOffset = 0;
48
+ if (options.levelOffset) {
49
+ levelOffset = parseInt(options.levelOffset, 10);
50
+ if (isNaN(levelOffset)) {
51
+ throw new Error(`Invalid level offset: ${options.levelOffset}`);
52
+ }
53
+ levelOffset = Math.min(Math.max(levelOffset, -MAX_LEVEL_OFFSET), MAX_LEVEL_OFFSET);
54
+ }
55
+ const adjustedContent = this.adjustTitles(content, levelOffset, options.pageTitles === 'discrete');
56
+ return adjustedContent;
57
+ };
58
+ validate(input) {
59
+ return validateMacroContent(this.metadata, input);
60
+ }
61
+ generateAnchor(options) {
62
+ return options.title !== 'exclude' && options.pageTitles === 'normal'
63
+ ? `[[${options.cardKey}]]\n`
64
+ : '';
65
+ }
66
+ generateTitle(options, cardTitle) {
67
+ if (options.title === 'only' || options.title === 'include') {
68
+ return `= ${cardTitle}\n\n`;
69
+ }
70
+ return '';
71
+ }
72
+ async generateCardContent(options, cardContent, context) {
73
+ if (options.title !== 'only') {
74
+ return await evaluateMacros(cardContent ?? '', context, true);
75
+ }
76
+ return '';
77
+ }
78
+ // Adjust asciidoc titles to match the level offset
79
+ adjustTitles(content, levelOffset, discrete) {
80
+ const lines = content.split('\n');
81
+ const adjustedLines = lines.map((line) => {
82
+ const match = line.match(/^(\s*)([=#]+)(.*?)\s*$/);
83
+ if (match) {
84
+ const currentLevel = match[2].length;
85
+ const newLevel = Math.min(Math.max(1, currentLevel + levelOffset), MAX_LEVEL_OFFSET + 1);
86
+ const equals = '='.repeat(newLevel);
87
+ return `${discrete ? '[discrete]\n' : ''}${match[1]}${equals} ${match[3].trim()}`;
88
+ }
89
+ return line;
90
+ });
91
+ return adjustedLines.join('\n');
92
+ }
93
+ }
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["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CAAC,CAAC;QACH,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import type { MacroMetadata } from '../../interfaces/macros.js';
14
+ declare const macroMetadata: MacroMetadata;
15
+ export default macroMetadata;
@@ -0,0 +1,19 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ const macroMetadata = {
14
+ name: 'include',
15
+ tagName: 'include',
16
+ schema: 'includeMacroSchema',
17
+ };
18
+ export default macroMetadata;
19
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/macros/include/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAIF,MAAM,aAAa,GAAkB;IACnC,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,oBAAoB;CAC7B,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,21 +1,21 @@
1
1
  /**
2
- Cyberismo
3
- Copyright © Cyberismo Ltd and contributors 2024
4
-
5
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
6
-
7
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
8
-
9
- You should have received a copy of the GNU Affero General Public
10
- License along with this program. If not, see <https://www.gnu.org/licenses/>.
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2024
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
11
12
  */
12
13
  import Handlebars from 'handlebars';
13
14
  import type { AdmonitionType } from '../interfaces/adoc.js';
14
- import type { Validator } from 'jsonschema';
15
15
  import type { MacroGenerationContext, MacroMetadata, MacroName } from '../interfaces/macros.js';
16
16
  import type BaseMacro from './base-macro.js';
17
17
  import TaskQueue from './task-queue.js';
18
- import type { Calculate } from '../commands/index.js';
18
+ import type { Schema } from 'jsonschema';
19
19
  /**
20
20
  * Constructor for all macros except report macros
21
21
  */
@@ -26,7 +26,7 @@ export interface SimpleMacroConstructor {
26
26
  * Constructor for report macros
27
27
  */
28
28
  export interface ReportMacroConstructor {
29
- new (tasks: TaskQueue, calculate: Calculate): BaseMacro;
29
+ new (tasks: TaskQueue): BaseMacro;
30
30
  }
31
31
  /**
32
32
  * Constructor for all macros
@@ -39,15 +39,14 @@ export declare const macros: {
39
39
  * Validates the content inside a macro
40
40
  * @param macro - The macro to validate the content of
41
41
  * @param data - The data to validate
42
- * @param validator - The validator to use
43
42
  * @returns The validated data
44
43
  */
45
- export declare function validateMacroContent<T>(macro: MacroMetadata, data: unknown, validator?: Validator): T;
44
+ export declare function validateMacroContent<T>(macro: MacroMetadata, data: unknown, schema?: Schema): T;
46
45
  /**
47
46
  * Registers the macros with Handlebars
48
47
  * @param {Mode} mode - The mode to register the macros in
49
48
  */
50
- export declare function registerMacros(instance: typeof Handlebars, context: MacroGenerationContext, tasks: TaskQueue, calculate: Calculate): BaseMacro[];
49
+ export declare function registerMacros(instance: typeof Handlebars, context: MacroGenerationContext, tasks: TaskQueue): BaseMacro[];
51
50
  /**
52
51
  * Calculate amount of handlebars templates inside a string
53
52
  * @param input
@@ -63,9 +62,11 @@ export declare function registerEmptyMacros(instance: typeof Handlebars): void;
63
62
  /**
64
63
  * Handle the macros in the content
65
64
  * @param content - The content to handle the macros in
66
- * @param mode - The mode to handle the macros in. Inject mode will generate injectable placeholders for the macros while static mode will generate valid adoc. Validate mode will only validate the macros syntax and throw errors in case of issues.
65
+ * @param context - The context for macro generation
66
+ * @param calculate - The calculate function
67
+ * @param preserveRawBlocks - If true, don't unescape raw blocks at the end (for nested evaluations)
67
68
  */
68
- export declare function evaluateMacros(content: string, context: MacroGenerationContext, calculate: Calculate, maxTries?: number): Promise<string>;
69
+ export declare function evaluateMacros(content: string, context: MacroGenerationContext, preserveRawBlocks?: boolean): Promise<string>;
69
70
  /**
70
71
  * This function assumes that tasks, which were started by macros, are complete.
71
72
  * It replaces the placeholders of the tasks with the actual results
@@ -83,20 +84,14 @@ export declare function applyMacroResults(input: string, tasks: TaskQueue, conte
83
84
  * @returns The error message that is valid adoc
84
85
  */
85
86
  export declare function handleMacroError(error: unknown, macro: string, context: MacroGenerationContext): string;
86
- type Value = string | number | boolean | undefined;
87
- /**
88
- * Macro options can be a flat object or a nested object
89
- * The nested object will be flattened into dot notation attributes
90
- */
91
- export type MacroOptions = {
92
- [key: string]: Value | MacroOptions;
93
- };
94
87
  /**
95
- * Creates an injectable placeholder for a macro
96
- * @param macro - The macro to create the placeholder for
97
- * @param options - Options will be passed to the html element as attributes
88
+ * Creates a placeholder for a macro
89
+ * Options are encoded as base64
90
+ * @param macro - The macro to create a placeholder for
91
+ * @param options - The options for the macro
92
+ * @returns The placeholder for the macro
98
93
  */
99
- export declare function createHtmlPlaceholder(macro: MacroMetadata, options: MacroOptions): string;
94
+ export declare function createHtmlPlaceholder(macro: MacroMetadata, options: unknown): string;
100
95
  /**
101
96
  * Creates an adoc admonition
102
97
  * @param type - The type of admonition
@@ -116,5 +111,12 @@ export declare function createCodeBlock(content: string): string;
116
111
  * @param image base64 encoded image
117
112
  * @returns valid asciidoc with the image
118
113
  */
119
- export declare function createImage(image: string): string;
120
- export {};
114
+ export declare function createImage(image: string, controls?: boolean): string;
115
+ /**
116
+ * Creates a Handlebars macro block string with the given macro name and options.
117
+ *
118
+ * @param macro - The name of the macro to create (e.g., 'scoreCard', 'include').
119
+ * @param options - The options object to be stringified and inserted as macro content.
120
+ * @returns The Handlebars macro block as a string, e.g. {{#macro}}...{{/macro}}
121
+ */
122
+ export declare function createMacro(macro: MacroName, options: unknown): string;