@cyberismo/data-handler 0.0.14 → 0.0.15

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 (240) hide show
  1. package/dist/card-metadata-updater.js +1 -3
  2. package/dist/card-metadata-updater.js.map +1 -1
  3. package/dist/command-handler.js +10 -16
  4. package/dist/command-handler.js.map +1 -1
  5. package/dist/command-manager.d.ts +1 -1
  6. package/dist/command-manager.js +4 -3
  7. package/dist/command-manager.js.map +1 -1
  8. package/dist/commands/create.js +13 -59
  9. package/dist/commands/create.js.map +1 -1
  10. package/dist/commands/edit.d.ts +1 -15
  11. package/dist/commands/edit.js +15 -89
  12. package/dist/commands/edit.js.map +1 -1
  13. package/dist/commands/export.js +4 -17
  14. package/dist/commands/export.js.map +1 -1
  15. package/dist/commands/import.js +3 -5
  16. package/dist/commands/import.js.map +1 -1
  17. package/dist/commands/move.d.ts +1 -2
  18. package/dist/commands/move.js +108 -146
  19. package/dist/commands/move.js.map +1 -1
  20. package/dist/commands/remove.js +9 -44
  21. package/dist/commands/remove.js.map +1 -1
  22. package/dist/commands/rename.js +2 -7
  23. package/dist/commands/rename.js.map +1 -1
  24. package/dist/commands/show.d.ts +7 -25
  25. package/dist/commands/show.js +38 -102
  26. package/dist/commands/show.js.map +1 -1
  27. package/dist/commands/transition.js +27 -30
  28. package/dist/commands/transition.js.map +1 -1
  29. package/dist/commands/update.d.ts +5 -3
  30. package/dist/commands/update.js +19 -5
  31. package/dist/commands/update.js.map +1 -1
  32. package/dist/commands/validate.d.ts +3 -3
  33. package/dist/commands/validate.js +19 -26
  34. package/dist/commands/validate.js.map +1 -1
  35. package/dist/containers/card-container.d.ts +87 -24
  36. package/dist/containers/card-container.js +183 -279
  37. package/dist/containers/card-container.js.map +1 -1
  38. package/dist/containers/project/calculation-engine.d.ts +6 -0
  39. package/dist/containers/project/calculation-engine.js +19 -12
  40. package/dist/containers/project/calculation-engine.js.map +1 -1
  41. package/dist/containers/project/card-cache.d.ts +146 -0
  42. package/dist/containers/project/card-cache.js +411 -0
  43. package/dist/containers/project/card-cache.js.map +1 -0
  44. package/dist/containers/project/resource-collector.d.ts +24 -1
  45. package/dist/containers/project/resource-collector.js +8 -1
  46. package/dist/containers/project/resource-collector.js.map +1 -1
  47. package/dist/containers/project.d.ts +117 -83
  48. package/dist/containers/project.js +418 -252
  49. package/dist/containers/project.js.map +1 -1
  50. package/dist/containers/template.d.ts +15 -31
  51. package/dist/containers/template.js +97 -104
  52. package/dist/containers/template.js.map +1 -1
  53. package/dist/index.d.ts +1 -0
  54. package/dist/index.js +1 -0
  55. package/dist/index.js.map +1 -1
  56. package/dist/interfaces/folder-content-interfaces.d.ts +2 -1
  57. package/dist/interfaces/folder-content-interfaces.js.map +1 -1
  58. package/dist/interfaces/macros.d.ts +1 -0
  59. package/dist/interfaces/macros.js +1 -1
  60. package/dist/interfaces/macros.js.map +1 -1
  61. package/dist/interfaces/project-interfaces.d.ts +5 -1
  62. package/dist/interfaces/project-interfaces.js.map +1 -1
  63. package/dist/interfaces/resource-interfaces.d.ts +11 -21
  64. package/dist/interfaces/resource-interfaces.js +3 -0
  65. package/dist/interfaces/resource-interfaces.js.map +1 -1
  66. package/dist/macros/common.d.ts +10 -10
  67. package/dist/macros/createCards/index.d.ts +0 -13
  68. package/dist/macros/createCards/index.js.map +1 -1
  69. package/dist/macros/createCards/types.d.ts +44 -0
  70. package/dist/macros/createCards/types.js +15 -0
  71. package/dist/macros/createCards/types.js.map +1 -0
  72. package/dist/macros/graph/index.d.ts +2 -6
  73. package/dist/macros/graph/index.js +2 -2
  74. package/dist/macros/graph/index.js.map +1 -1
  75. package/dist/macros/graph/types.d.ts +23 -0
  76. package/dist/macros/graph/types.js +15 -0
  77. package/dist/macros/graph/types.js.map +1 -0
  78. package/dist/macros/image/index.d.ts +8 -16
  79. package/dist/macros/image/index.js +36 -33
  80. package/dist/macros/image/index.js.map +1 -1
  81. package/dist/macros/image/types.d.ts +38 -0
  82. package/dist/macros/image/types.js +15 -0
  83. package/dist/macros/image/types.js.map +1 -0
  84. package/dist/macros/include/index.d.ts +1 -6
  85. package/dist/macros/include/index.js +4 -7
  86. package/dist/macros/include/index.js.map +1 -1
  87. package/dist/macros/include/types.d.ts +31 -0
  88. package/dist/macros/include/types.js +15 -0
  89. package/dist/macros/include/types.js.map +1 -0
  90. package/dist/macros/percentage/index.d.ts +0 -6
  91. package/dist/macros/percentage/index.js.map +1 -1
  92. package/dist/macros/percentage/types.d.ts +31 -0
  93. package/dist/macros/percentage/types.js +15 -0
  94. package/dist/macros/percentage/types.js.map +1 -0
  95. package/dist/macros/report/index.d.ts +0 -3
  96. package/dist/macros/report/index.js.map +1 -1
  97. package/dist/macros/report/types.d.ts +19 -0
  98. package/dist/macros/report/types.js +15 -0
  99. package/dist/macros/report/types.js.map +1 -0
  100. package/dist/macros/scoreCard/index.d.ts +0 -6
  101. package/dist/macros/scoreCard/index.js.map +1 -1
  102. package/dist/macros/scoreCard/types.d.ts +31 -0
  103. package/dist/macros/scoreCard/types.js +15 -0
  104. package/dist/macros/scoreCard/types.js.map +1 -0
  105. package/dist/macros/types.d.ts +25 -0
  106. package/dist/macros/types.js +2 -0
  107. package/dist/macros/types.js.map +1 -0
  108. package/dist/macros/vega/index.d.ts +0 -4
  109. package/dist/macros/vega/index.js.map +1 -1
  110. package/dist/macros/vega/types.d.ts +20 -0
  111. package/dist/macros/vega/types.js +2 -0
  112. package/dist/macros/vega/types.js.map +1 -0
  113. package/dist/macros/vegalite/index.d.ts +0 -4
  114. package/dist/macros/vegalite/index.js.map +1 -1
  115. package/dist/macros/vegalite/types.d.ts +20 -0
  116. package/dist/macros/vegalite/types.js +15 -0
  117. package/dist/macros/vegalite/types.js.map +1 -0
  118. package/dist/macros/xref/index.d.ts +0 -3
  119. package/dist/macros/xref/index.js +5 -14
  120. package/dist/macros/xref/index.js.map +1 -1
  121. package/dist/macros/xref/types.d.ts +19 -0
  122. package/dist/macros/xref/types.js +15 -0
  123. package/dist/macros/xref/types.js.map +1 -0
  124. package/dist/module-manager.js +4 -4
  125. package/dist/module-manager.js.map +1 -1
  126. package/dist/project-settings.js.map +1 -1
  127. package/dist/resources/calculation-resource.d.ts +4 -32
  128. package/dist/resources/calculation-resource.js +0 -55
  129. package/dist/resources/calculation-resource.js.map +1 -1
  130. package/dist/resources/card-type-resource.d.ts +4 -21
  131. package/dist/resources/card-type-resource.js +13 -44
  132. package/dist/resources/card-type-resource.js.map +1 -1
  133. package/dist/resources/field-type-resource.d.ts +4 -21
  134. package/dist/resources/field-type-resource.js +14 -38
  135. package/dist/resources/field-type-resource.js.map +1 -1
  136. package/dist/resources/file-resource.d.ts +12 -29
  137. package/dist/resources/file-resource.js +19 -293
  138. package/dist/resources/file-resource.js.map +1 -1
  139. package/dist/resources/folder-resource.d.ts +31 -50
  140. package/dist/resources/folder-resource.js +68 -96
  141. package/dist/resources/folder-resource.js.map +1 -1
  142. package/dist/resources/graph-model-resource.d.ts +5 -33
  143. package/dist/resources/graph-model-resource.js +8 -61
  144. package/dist/resources/graph-model-resource.js.map +1 -1
  145. package/dist/resources/graph-view-resource.d.ts +5 -28
  146. package/dist/resources/graph-view-resource.js +6 -45
  147. package/dist/resources/graph-view-resource.js.map +1 -1
  148. package/dist/resources/link-type-resource.d.ts +4 -21
  149. package/dist/resources/link-type-resource.js +6 -31
  150. package/dist/resources/link-type-resource.js.map +1 -1
  151. package/dist/resources/report-resource.d.ts +5 -17
  152. package/dist/resources/report-resource.js +6 -44
  153. package/dist/resources/report-resource.js.map +1 -1
  154. package/dist/resources/resource-object.d.ts +58 -23
  155. package/dist/resources/resource-object.js +293 -24
  156. package/dist/resources/resource-object.js.map +1 -1
  157. package/dist/resources/template-resource.d.ts +4 -15
  158. package/dist/resources/template-resource.js +10 -25
  159. package/dist/resources/template-resource.js.map +1 -1
  160. package/dist/resources/workflow-resource.d.ts +4 -23
  161. package/dist/resources/workflow-resource.js +12 -38
  162. package/dist/resources/workflow-resource.js.map +1 -1
  163. package/dist/utils/card-utils.d.ts +69 -19
  164. package/dist/utils/card-utils.js +179 -30
  165. package/dist/utils/card-utils.js.map +1 -1
  166. package/dist/utils/clingo-facts.js +11 -3
  167. package/dist/utils/clingo-facts.js.map +1 -1
  168. package/dist/utils/clingo-parser.js +1 -1
  169. package/dist/utils/clingo-parser.js.map +1 -1
  170. package/dist/utils/constants.d.ts +2 -0
  171. package/dist/utils/constants.js +4 -0
  172. package/dist/utils/constants.js.map +1 -1
  173. package/dist/utils/csv.js +1 -1
  174. package/dist/utils/csv.js.map +1 -1
  175. package/package.json +5 -5
  176. package/src/card-metadata-updater.ts +3 -5
  177. package/src/command-handler.ts +11 -18
  178. package/src/command-manager.ts +4 -3
  179. package/src/commands/create.ts +17 -83
  180. package/src/commands/edit.ts +16 -132
  181. package/src/commands/export.ts +8 -29
  182. package/src/commands/import.ts +4 -6
  183. package/src/commands/move.ts +144 -179
  184. package/src/commands/remove.ts +9 -52
  185. package/src/commands/rename.ts +2 -7
  186. package/src/commands/show.ts +50 -143
  187. package/src/commands/transition.ts +30 -33
  188. package/src/commands/update.ts +27 -9
  189. package/src/commands/validate.ts +21 -36
  190. package/src/containers/card-container.ts +200 -360
  191. package/src/containers/project/calculation-engine.ts +21 -13
  192. package/src/containers/project/card-cache.ts +497 -0
  193. package/src/containers/project/resource-collector.ts +9 -1
  194. package/src/containers/project.ts +529 -327
  195. package/src/containers/template.ts +109 -127
  196. package/src/index.ts +1 -0
  197. package/src/interfaces/folder-content-interfaces.ts +7 -1
  198. package/src/interfaces/macros.ts +2 -0
  199. package/src/interfaces/project-interfaces.ts +7 -1
  200. package/src/interfaces/resource-interfaces.ts +12 -24
  201. package/src/macros/createCards/index.ts +1 -12
  202. package/src/macros/createCards/types.ts +46 -0
  203. package/src/macros/graph/index.ts +3 -7
  204. package/src/macros/graph/types.ts +24 -0
  205. package/src/macros/image/index.ts +50 -61
  206. package/src/macros/image/types.ts +39 -0
  207. package/src/macros/include/index.ts +6 -15
  208. package/src/macros/include/types.ts +32 -0
  209. package/src/macros/percentage/index.ts +1 -7
  210. package/src/macros/percentage/types.ts +32 -0
  211. package/src/macros/report/index.ts +1 -4
  212. package/src/macros/report/types.ts +20 -0
  213. package/src/macros/scoreCard/index.ts +1 -7
  214. package/src/macros/scoreCard/types.ts +32 -0
  215. package/src/macros/types.ts +48 -0
  216. package/src/macros/vega/index.ts +1 -4
  217. package/src/macros/vega/types.ts +21 -0
  218. package/src/macros/vegalite/index.ts +1 -4
  219. package/src/macros/vegalite/types.ts +22 -0
  220. package/src/macros/xref/index.ts +6 -20
  221. package/src/macros/xref/types.ts +20 -0
  222. package/src/module-manager.ts +5 -5
  223. package/src/project-settings.ts +1 -1
  224. package/src/resources/calculation-resource.ts +6 -76
  225. package/src/resources/card-type-resource.ts +24 -59
  226. package/src/resources/field-type-resource.ts +22 -51
  227. package/src/resources/file-resource.ts +27 -409
  228. package/src/resources/folder-resource.ts +98 -124
  229. package/src/resources/graph-model-resource.ts +17 -74
  230. package/src/resources/graph-view-resource.ts +14 -54
  231. package/src/resources/link-type-resource.ts +13 -40
  232. package/src/resources/report-resource.ts +17 -57
  233. package/src/resources/resource-object.ts +435 -32
  234. package/src/resources/template-resource.ts +16 -29
  235. package/src/resources/workflow-resource.ts +26 -50
  236. package/src/utils/card-utils.ts +217 -31
  237. package/src/utils/clingo-facts.ts +13 -3
  238. package/src/utils/clingo-parser.ts +1 -1
  239. package/src/utils/constants.ts +6 -0
  240. package/src/utils/csv.ts +1 -1
@@ -0,0 +1,24 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+
15
+ export interface GraphOptions {
16
+ /**
17
+ * Reference to the model that defines graph
18
+ */
19
+ model: string;
20
+ /**
21
+ * Reference to the view that defines the graph
22
+ */
23
+ view: string;
24
+ }
@@ -11,39 +11,64 @@
11
11
  License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
12
  */
13
13
 
14
- import { existsSync, readFileSync } from 'node:fs';
14
+ import { readFileSync } from 'node:fs';
15
15
  import { join } from 'node:path';
16
- import mime from 'mime-types';
17
16
 
17
+ import BaseMacro from '../base-macro.js';
18
+ import macroMetadata from './metadata.js';
18
19
  import { validateMacroContent } from '../index.js';
19
20
 
21
+ import type { ImageMacroOptions } from './types.js';
20
22
  import type { MacroGenerationContext } from '../../interfaces/macros.js';
21
- import macroMetadata from './metadata.js';
22
- import BaseMacro from '../base-macro.js';
23
23
  import type TaskQueue from '../task-queue.js';
24
24
 
25
- /**
26
- * Options for the image macro.
27
- * @param fileName - Name of the file to include.
28
- * @param cardKey - Key of the card to include the file from.
29
- * @param alt - Alternative text for the image.
30
- * @param title - Title of the image.
31
- */
32
- export interface ImageMacroOptions {
33
- fileName: string;
34
- cardKey?: string;
35
- alt?: string;
36
- title?: string;
37
- }
38
-
39
25
  /**
40
26
  * Macro for including images in the content
41
27
  */
42
28
  export default class ImageMacro extends BaseMacro {
29
+ /**
30
+ * Constructs ImageMacro instance.
31
+ * @param tasksQueue Tasks queue
32
+ */
43
33
  constructor(tasksQueue: TaskQueue) {
44
34
  super(macroMetadata, tasksQueue);
45
35
  }
46
36
 
37
+ // Gets card attachment.
38
+ private attachment(
39
+ context: MacroGenerationContext,
40
+ cardKey: string,
41
+ filename: string,
42
+ ) {
43
+ const card = context.project.findCard(cardKey);
44
+ const attachment =
45
+ card.attachments?.find((a) => a.fileName === filename) ?? undefined;
46
+ if (!attachment) {
47
+ throw new Error(
48
+ `Attachment file '${filename}' not found in card '${cardKey}'`,
49
+ );
50
+ }
51
+ return attachment;
52
+ }
53
+
54
+ private buildImageAttributes(options: ImageMacroOptions): string {
55
+ const attributes: string[] = [];
56
+
57
+ if (options.alt !== undefined) {
58
+ attributes.push(`alt="${options.alt}"`);
59
+ }
60
+
61
+ if (options.title !== undefined) {
62
+ attributes.push(`title="${options.title}"`);
63
+ }
64
+
65
+ return attributes.join(',');
66
+ }
67
+
68
+ private validate(input: unknown): ImageMacroOptions {
69
+ return validateMacroContent<ImageMacroOptions>(this.metadata, input);
70
+ }
71
+
47
72
  handleValidate = (_: MacroGenerationContext, input: unknown) => {
48
73
  this.validate(input);
49
74
  };
@@ -55,45 +80,27 @@ export default class ImageMacro extends BaseMacro {
55
80
  const options = this.validate(input);
56
81
  const cardKey = options.cardKey || context.cardKey;
57
82
 
58
- // Get the attachment folder path
59
- const attachmentFolder =
60
- await context.project.cardAttachmentFolder(cardKey);
61
-
62
- // Read the file and convert to base64
63
- const attachmentPath = join(attachmentFolder, options.fileName);
64
- if (!existsSync(attachmentPath)) {
65
- throw new Error(
66
- `Attachment file '${options.fileName}' not found in card '${cardKey}'`,
67
- );
68
- }
83
+ // Get the attachment
84
+ const cardAttachment = this.attachment(context, cardKey, options.fileName);
69
85
 
86
+ // Convert to base64
87
+ const attachmentPath = join(cardAttachment?.path, cardAttachment?.fileName);
70
88
  const fileBuffer = readFileSync(attachmentPath);
71
89
  const base64Data = fileBuffer.toString('base64');
72
90
 
73
- // Get mime type
74
- const mimeType = mime.lookup(attachmentPath) || 'application/octet-stream';
75
-
76
91
  // Build image attributes
77
92
  const attributes = this.buildImageAttributes(options);
78
93
 
79
94
  // Return as data URI for static mode (for export/PDF generation)
80
- return `image::data:${mimeType};base64,${base64Data}[${attributes}]`;
95
+ return `image::data:${cardAttachment.mimeType};base64,${base64Data}[${attributes}]`;
81
96
  };
82
97
 
83
98
  handleInject = async (context: MacroGenerationContext, input: unknown) => {
84
99
  const options = this.validate(input);
85
100
  const cardKey = options.cardKey || context.cardKey;
86
101
 
87
- // Verify that the card and attachment folder exist
88
- const attachmentFolder =
89
- await context.project.cardAttachmentFolder(cardKey);
90
-
91
- const attachmentPath = join(attachmentFolder, options.fileName);
92
- if (!existsSync(attachmentPath)) {
93
- throw new Error(
94
- `Attachment file '${options.fileName}' not found in card '${cardKey}'`,
95
- );
96
- }
102
+ // Just verify that the attachment exists.
103
+ this.attachment(context, cardKey, options.fileName);
97
104
 
98
105
  // Build image attributes
99
106
  const attributes = this.buildImageAttributes(options);
@@ -101,22 +108,4 @@ export default class ImageMacro extends BaseMacro {
101
108
  // In inject mode, always use the API path for consistency
102
109
  return `image::/api/cards/${cardKey}/a/${options.fileName}[${attributes}]`;
103
110
  };
104
-
105
- private buildImageAttributes(options: ImageMacroOptions): string {
106
- const attributes: string[] = [];
107
-
108
- if (options.alt !== undefined) {
109
- attributes.push(`alt="${options.alt}"`);
110
- }
111
-
112
- if (options.title !== undefined) {
113
- attributes.push(`title="${options.title}"`);
114
- }
115
-
116
- return attributes.join(',');
117
- }
118
-
119
- private validate(input: unknown): ImageMacroOptions {
120
- return validateMacroContent<ImageMacroOptions>(this.metadata, input);
121
- }
122
111
  }
@@ -0,0 +1,39 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+
15
+ /**
16
+ * Options for the image macro.
17
+ * @param fileName - Name of the file to include.
18
+ * @param cardKey - Key of the card to include the file from.
19
+ * @param alt - Alternative text for the image.
20
+ * @param title - Title of the image.
21
+ */
22
+ export interface ImageMacroOptions {
23
+ /**
24
+ * Filename of the image
25
+ */
26
+ fileName: string;
27
+ /**
28
+ * By default, image is assumed to be under the current card. You can override this behaviour
29
+ */
30
+ cardKey?: string;
31
+ /**
32
+ * Alt text
33
+ */
34
+ alt?: string;
35
+ /**
36
+ * Title for the image
37
+ */
38
+ title?: string;
39
+ }
@@ -13,19 +13,13 @@
13
13
 
14
14
  import { evaluateMacros, validateMacroContent } from '../index.js';
15
15
 
16
+ import type { IncludeMacroOptions } from './types.js';
16
17
  import type { MacroGenerationContext } from '../../interfaces/macros.js';
17
18
  import macroMetadata from './metadata.js';
18
19
  import BaseMacro from '../base-macro.js';
19
20
  import type TaskQueue from '../task-queue.js';
20
21
  import { MAX_LEVEL_OFFSET } from '../../utils/constants.js';
21
22
 
22
- export interface IncludeMacroOptions {
23
- cardKey: string;
24
- levelOffset?: string;
25
- title?: 'include' | 'exclude' | 'only';
26
- pageTitles?: 'normal' | 'discrete';
27
- }
28
-
29
23
  export default class IncludeMacro extends BaseMacro {
30
24
  constructor(tasksQueue: TaskQueue) {
31
25
  super(macroMetadata, tasksQueue);
@@ -46,18 +40,11 @@ export default class IncludeMacro extends BaseMacro {
46
40
  if (!options.pageTitles) {
47
41
  options.pageTitles = 'normal';
48
42
  }
49
- const card = await context.project.cardDetailsById(options.cardKey, {
50
- content: true,
51
- metadata: true,
52
- });
53
- if (!card) {
54
- throw new Error(`Card key ${options.cardKey} not found`);
55
- }
56
43
  const newContext = {
57
44
  ...context,
58
45
  cardKey: options.cardKey,
59
46
  };
60
-
47
+ const card = this.getCard(options.cardKey, context);
61
48
  const anchor = this.generateAnchor(options);
62
49
  const title = this.generateTitle(options, card.metadata?.title);
63
50
  const cardContent = await this.generateCardContent(
@@ -118,6 +105,10 @@ export default class IncludeMacro extends BaseMacro {
118
105
  return '';
119
106
  }
120
107
 
108
+ private getCard(cardKey: string, context: MacroGenerationContext) {
109
+ return context.project.findCard(cardKey);
110
+ }
111
+
121
112
  // Adjust asciidoc titles to match the level offset
122
113
  private adjustTitles(
123
114
  content: string,
@@ -0,0 +1,32 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+
15
+ export interface IncludeMacroOptions {
16
+ /**
17
+ * Card key of the card being included
18
+ */
19
+ cardKey: string;
20
+ /**
21
+ * A positive number wil increase the level of headings and a negative alue will the level of headings in the included content
22
+ */
23
+ levelOffset?: string;
24
+ /**
25
+ * Determines behaviour with the title that is in card metadata
26
+ * include --> includes the title
27
+ * exclude --> excludes the title
28
+ * only --> includes title but does not import content
29
+ */
30
+ title?: 'include' | 'exclude' | 'only';
31
+ pageTitles?: 'normal' | 'discrete';
32
+ }
@@ -15,17 +15,11 @@ import { createImage, validateMacroContent } from '../index.js';
15
15
 
16
16
  import type { MacroGenerationContext } from '../../interfaces/macros.js';
17
17
  import macroMetadata from './metadata.js';
18
+ import type { PercentageOptions } from './types.js';
18
19
  import BaseMacro from '../base-macro.js';
19
20
  import type TaskQueue from '../task-queue.js';
20
21
  import { percentage } from '../../svg/index.js';
21
22
 
22
- export interface PercentageOptions {
23
- title: string;
24
- value: number;
25
- legend: string;
26
- colour?: 'blue' | 'green' | 'yellow' | 'red' | 'orange' | 'purple';
27
- }
28
-
29
23
  class PercentageMacro extends BaseMacro {
30
24
  constructor(tasksQueue: TaskQueue) {
31
25
  super(macroMetadata, tasksQueue);
@@ -0,0 +1,32 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+
15
+ export interface PercentageOptions {
16
+ /**
17
+ * Title of percentage macro
18
+ */
19
+ title: string;
20
+ /**
21
+ * Percentage value
22
+ */
23
+ value: number;
24
+ /**
25
+ * Legend text below the macro
26
+ */
27
+ legend: string;
28
+ /**
29
+ * Color of the bar the represents the percentage
30
+ */
31
+ colour?: 'blue' | 'green' | 'yellow' | 'red' | 'orange' | 'purple';
32
+ }
@@ -22,10 +22,7 @@ import { ReportResource } from '../../resources/report-resource.js';
22
22
  import { resourceName } from '../../utils/resource-utils.js';
23
23
  import { generateReportContent } from '../../utils/report.js';
24
24
  import { ClingoError } from '@cyberismo/node-clingo';
25
-
26
- export interface ReportOptions {
27
- name: string;
28
- }
25
+ import type { ReportOptions } from './types.js';
29
26
 
30
27
  class ReportMacro extends BaseMacro {
31
28
  constructor(tasks: TaskQueue) {
@@ -0,0 +1,20 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+
15
+ export interface ReportOptions {
16
+ /**
17
+ * Name of the report
18
+ */
19
+ name: string;
20
+ }
@@ -19,13 +19,7 @@ import macroMetadata from './metadata.js';
19
19
  import BaseMacro from '../base-macro.js';
20
20
  import type TaskQueue from '../task-queue.js';
21
21
  import { scoreCard } from '../../svg/index.js';
22
-
23
- export interface ScoreCardOptions {
24
- value: number;
25
- legend?: string;
26
- title?: string;
27
- unit?: string;
28
- }
22
+ import type { ScoreCardOptions } from './types.js';
29
23
 
30
24
  class ScoreCardMacro extends BaseMacro {
31
25
  constructor(tasksQueue: TaskQueue) {
@@ -0,0 +1,32 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+
15
+ export interface ScoreCardOptions {
16
+ /**
17
+ * Value shown in score card
18
+ */
19
+ value: number;
20
+ /**
21
+ * Optional legend text
22
+ */
23
+ legend?: string;
24
+ /**
25
+ * Option title text
26
+ */
27
+ title?: string;
28
+ /**
29
+ * Option unit that is next to the value
30
+ */
31
+ unit?: string;
32
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+ import { CreateCardsOptions } from './createCards/types.js';
15
+ import { GraphOptions } from './graph/types.js';
16
+ import { ImageMacroOptions } from './image/types.js';
17
+ import { IncludeMacroOptions } from './include/types.js';
18
+ import { PercentageOptions } from './percentage/types.js';
19
+ import { ReportOptions } from './report/types.js';
20
+ import { ScoreCardOptions } from './scoreCard/types.js';
21
+ import { VegaMacroInput } from './vega/types.js';
22
+ import { VegaLiteMacroInput } from './vegalite/types.js';
23
+ import { XrefMacroOptions } from './xref/types.js';
24
+
25
+ export type AnyMacroOption =
26
+ | CreateCardsOptions
27
+ | GraphOptions
28
+ | ImageMacroOptions
29
+ | IncludeMacroOptions
30
+ | PercentageOptions
31
+ | ReportOptions
32
+ | ScoreCardOptions
33
+ | VegaMacroInput
34
+ | VegaLiteMacroInput
35
+ | XrefMacroOptions;
36
+
37
+ export {
38
+ CreateCardsOptions,
39
+ GraphOptions,
40
+ ImageMacroOptions,
41
+ IncludeMacroOptions,
42
+ PercentageOptions,
43
+ ReportOptions,
44
+ ScoreCardOptions,
45
+ VegaMacroInput,
46
+ VegaLiteMacroInput,
47
+ XrefMacroOptions,
48
+ };
@@ -21,10 +21,7 @@ import {
21
21
  validateMacroContent,
22
22
  } from '../index.js';
23
23
  import * as vega from 'vega';
24
-
25
- export interface VegaMacroInput {
26
- spec: vega.Spec;
27
- }
24
+ import type { VegaMacroInput } from './types.js';
28
25
 
29
26
  class VegaMacro extends BaseMacro {
30
27
  constructor(tasksQueue: TaskQueue) {
@@ -0,0 +1,21 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+ import type { Spec } from 'vega';
15
+
16
+ export interface VegaMacroInput {
17
+ /**
18
+ * Defines spec for vega
19
+ */
20
+ spec: Spec;
21
+ }
@@ -16,10 +16,7 @@ import macroMetadata from './metadata.js';
16
16
  import type TaskQueue from '../task-queue.js';
17
17
  import * as vegaLite from 'vega-lite';
18
18
  import { createMacro, validateMacroContent } from '../index.js';
19
-
20
- export interface VegaLiteMacroInput {
21
- spec: vegaLite.TopLevelSpec;
22
- }
19
+ import type { VegaLiteMacroInput } from './types.js';
23
20
 
24
21
  class VegaLiteMacro extends BaseMacro {
25
22
  constructor(tasksQueue: TaskQueue) {
@@ -0,0 +1,22 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+
15
+ import type { TopLevelSpec } from 'vega-lite';
16
+
17
+ export interface VegaLiteMacroInput {
18
+ /**
19
+ * Defines spec for vega-lite
20
+ */
21
+ spec: TopLevelSpec;
22
+ }
@@ -17,10 +17,7 @@ import type { MacroGenerationContext } from '../../interfaces/macros.js';
17
17
  import macroMetadata from './metadata.js';
18
18
  import BaseMacro from '../base-macro.js';
19
19
  import type TaskQueue from '../task-queue.js';
20
-
21
- export interface XrefMacroOptions {
22
- cardKey: string;
23
- }
20
+ import type { XrefMacroOptions } from './types.js';
24
21
 
25
22
  export default class XrefMacro extends BaseMacro {
26
23
  constructor(tasksQueue: TaskQueue) {
@@ -36,7 +33,7 @@ export default class XrefMacro extends BaseMacro {
36
33
  input: unknown,
37
34
  ): Promise<string> => {
38
35
  const options = this.validate(input);
39
- const card = await this.getCard(options.cardKey, context);
36
+ const card = this.getCard(options.cardKey, context);
40
37
 
41
38
  if (!card || !card.metadata) {
42
39
  throw new Error(`Card key ${options.cardKey} not found`);
@@ -48,23 +45,12 @@ export default class XrefMacro extends BaseMacro {
48
45
 
49
46
  handleInject = async (context: MacroGenerationContext, input: unknown) => {
50
47
  const options = this.validate(input);
51
- const card = await this.getCard(options.cardKey, context);
52
-
53
- if (!card || !card.metadata) {
54
- throw new Error(`Card key ${options.cardKey} not found`);
55
- }
56
-
57
- return `xref:${options.cardKey}.adoc[${card.metadata.title}]`;
48
+ const card = this.getCard(options.cardKey, context);
49
+ return `xref:${options.cardKey}.adoc[${card?.metadata?.title}]`;
58
50
  };
59
51
 
60
- private async getCard(cardKey: string, context: MacroGenerationContext) {
61
- const card = await context.project.cardDetailsById(cardKey, {
62
- metadata: true,
63
- });
64
- if (!card || !card.metadata) {
65
- throw new Error(`Card key ${cardKey} not found`);
66
- }
67
- return card;
52
+ private getCard(cardKey: string, context: MacroGenerationContext) {
53
+ return context.project.findCard(cardKey);
68
54
  }
69
55
 
70
56
  private validate(input: unknown): XrefMacroOptions {
@@ -0,0 +1,20 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU Affero General Public License version 3 as published by
7
+ the Free Software Foundation. This program is distributed in the hope that it
8
+ will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ See the GNU Affero General Public License for more details.
11
+ You should have received a copy of the GNU Affero General Public
12
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
13
+ */
14
+
15
+ export interface XrefMacroOptions {
16
+ /**
17
+ * Card of the card being referenced
18
+ */
19
+ cardKey: string;
20
+ }
@@ -309,10 +309,10 @@ export class ModuleManager {
309
309
 
310
310
  // Collect modules that could be removed from .cards/modules when
311
311
  // 'moduleName' is removed.
312
- private async orphanedModules(
312
+ private orphanedModules(
313
313
  dependencies: DependencyGraph,
314
314
  moduleName: string,
315
- ): Promise<string[]> {
315
+ ): string[] {
316
316
  const projectModules = this.project.configuration.modules;
317
317
  const removableTransientModules: string[] = [];
318
318
  if (dependencies.has(moduleName)) {
@@ -558,6 +558,7 @@ export class ModuleManager {
558
558
  );
559
559
  }
560
560
  const sourceProject = new Project(source);
561
+ await sourceProject.populateCaches();
561
562
  const modulePrefix = sourceProject.projectPrefix;
562
563
  const destinationPath = join(
563
564
  this.project.paths.modulesFolder,
@@ -625,7 +626,7 @@ export class ModuleManager {
625
626
  // but modules under .cards/modules must be checked not to be used by
626
627
  // other modules.
627
628
  if (this.canBeRemoved(dependencies, moduleName)) {
628
- const orphans = await this.orphanedModules(dependencies, moduleName);
629
+ const orphans = this.orphanedModules(dependencies, moduleName);
629
630
  await deleteDir(module.path);
630
631
  for (const moduleToDelete of orphans) {
631
632
  const modulePath = join(
@@ -634,9 +635,8 @@ export class ModuleManager {
634
635
  );
635
636
  await deleteDir(modulePath);
636
637
  }
637
- await this.project.collectModuleResources();
638
638
  }
639
- await this.project.configuration.removeModule(moduleName);
639
+ await this.project.removeModule(moduleName);
640
640
  }
641
641
 
642
642
  /**