@cyberismo/data-handler 0.0.7 → 0.0.9

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 (265) 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 +7 -4
  10. package/dist/commands/create.js +42 -15
  11. package/dist/commands/create.js.map +1 -1
  12. package/dist/commands/edit.d.ts +9 -3
  13. package/dist/commands/edit.js +33 -9
  14. package/dist/commands/edit.js.map +1 -1
  15. package/dist/commands/export.d.ts +13 -11
  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 +21 -2
  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 +2 -4
  25. package/dist/commands/remove.js +8 -16
  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 +85 -7
  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 -8
  40. package/dist/commands/validate.js +30 -35
  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.d.ts +2 -1
  49. package/dist/containers/project/resource-collector.js +41 -33
  50. package/dist/containers/project/resource-collector.js.map +1 -1
  51. package/dist/containers/project.d.ts +18 -6
  52. package/dist/containers/project.js +37 -72
  53. package/dist/containers/project.js.map +1 -1
  54. package/dist/containers/template.d.ts +5 -0
  55. package/dist/containers/template.js +9 -0
  56. package/dist/containers/template.js.map +1 -1
  57. package/dist/exceptions/index.d.ts +20 -0
  58. package/dist/exceptions/index.js +16 -0
  59. package/dist/exceptions/index.js.map +1 -1
  60. package/dist/index.d.ts +5 -2
  61. package/dist/index.js +5 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/interfaces/macros.d.ts +7 -2
  64. package/dist/interfaces/project-interfaces.d.ts +21 -0
  65. package/dist/interfaces/project-interfaces.js +4 -0
  66. package/dist/interfaces/project-interfaces.js.map +1 -1
  67. package/dist/interfaces/resource-interfaces.d.ts +1 -1
  68. package/dist/interfaces/resource-interfaces.js.map +1 -1
  69. package/dist/macros/base-macro.d.ts +2 -0
  70. package/dist/macros/base-macro.js +66 -19
  71. package/dist/macros/base-macro.js.map +1 -1
  72. package/dist/macros/common.d.ts +16 -9
  73. package/dist/macros/common.js +22 -9
  74. package/dist/macros/common.js.map +1 -1
  75. package/dist/macros/createCards/index.d.ts +1 -2
  76. package/dist/macros/createCards/index.js.map +1 -1
  77. package/dist/macros/graph/index.d.ts +1 -3
  78. package/dist/macros/graph/index.js +11 -9
  79. package/dist/macros/graph/index.js.map +1 -1
  80. package/dist/macros/image/index.d.ts +39 -0
  81. package/dist/macros/image/index.js +78 -0
  82. package/dist/macros/image/index.js.map +1 -0
  83. package/dist/macros/image/metadata.d.ts +18 -0
  84. package/dist/macros/image/metadata.js +22 -0
  85. package/dist/macros/image/metadata.js.map +1 -0
  86. package/dist/macros/include/index.d.ts +32 -0
  87. package/dist/macros/include/index.js +97 -0
  88. package/dist/macros/include/index.js.map +1 -0
  89. package/dist/macros/include/metadata.d.ts +15 -0
  90. package/dist/macros/include/metadata.js +19 -0
  91. package/dist/macros/include/metadata.js.map +1 -0
  92. package/dist/macros/index.d.ts +39 -31
  93. package/dist/macros/index.js +167 -73
  94. package/dist/macros/index.js.map +1 -1
  95. package/dist/macros/percentage/index.d.ts +29 -0
  96. package/dist/macros/percentage/index.js +36 -0
  97. package/dist/macros/percentage/index.js.map +1 -0
  98. package/dist/macros/percentage/metadata.d.ts +15 -0
  99. package/dist/macros/percentage/metadata.js +19 -0
  100. package/dist/macros/percentage/metadata.js.map +1 -0
  101. package/dist/macros/report/index.d.ts +2 -5
  102. package/dist/macros/report/index.js +20 -12
  103. package/dist/macros/report/index.js.map +1 -1
  104. package/dist/macros/scoreCard/index.d.ts +15 -15
  105. package/dist/macros/scoreCard/index.js +16 -17
  106. package/dist/macros/scoreCard/index.js.map +1 -1
  107. package/dist/macros/vega/index.d.ts +28 -0
  108. package/dist/macros/vega/index.js +27 -0
  109. package/dist/macros/vega/index.js.map +1 -0
  110. package/dist/macros/vega/metadata.d.ts +15 -0
  111. package/dist/macros/vega/metadata.js +7 -0
  112. package/dist/macros/vega/metadata.js.map +1 -0
  113. package/dist/macros/vegalite/index.d.ts +27 -0
  114. package/dist/macros/vegalite/index.js +27 -0
  115. package/dist/macros/vegalite/index.js.map +1 -0
  116. package/dist/macros/vegalite/metadata.d.ts +15 -0
  117. package/dist/macros/vegalite/metadata.js +7 -0
  118. package/dist/macros/vegalite/metadata.js.map +1 -0
  119. package/dist/macros/xref/index.d.ts +26 -0
  120. package/dist/macros/xref/index.js +53 -0
  121. package/dist/macros/xref/index.js.map +1 -0
  122. package/dist/macros/xref/metadata.d.ts +15 -0
  123. package/dist/macros/xref/metadata.js +19 -0
  124. package/dist/macros/xref/metadata.js.map +1 -0
  125. package/dist/module-manager.d.ts +17 -4
  126. package/dist/module-manager.js +192 -58
  127. package/dist/module-manager.js.map +1 -1
  128. package/dist/permissions/action-guard.d.ts +2 -2
  129. package/dist/permissions/action-guard.js +1 -1
  130. package/dist/permissions/action-guard.js.map +1 -1
  131. package/dist/project-settings.js +2 -8
  132. package/dist/project-settings.js.map +1 -1
  133. package/dist/resources/card-type-resource.d.ts +2 -0
  134. package/dist/resources/card-type-resource.js +63 -0
  135. package/dist/resources/card-type-resource.js.map +1 -1
  136. package/dist/resources/file-resource.d.ts +2 -0
  137. package/dist/resources/file-resource.js +12 -4
  138. package/dist/resources/file-resource.js.map +1 -1
  139. package/dist/resources/folder-resource.d.ts +19 -0
  140. package/dist/resources/folder-resource.js +51 -2
  141. package/dist/resources/folder-resource.js.map +1 -1
  142. package/dist/resources/graph-model-resource.js +1 -1
  143. package/dist/resources/graph-model-resource.js.map +1 -1
  144. package/dist/resources/graph-view-resource.js +1 -1
  145. package/dist/resources/graph-view-resource.js.map +1 -1
  146. package/dist/resources/report-resource.js +1 -1
  147. package/dist/resources/report-resource.js.map +1 -1
  148. package/dist/resources/resource-object.d.ts +8 -0
  149. package/dist/resources/resource-object.js +9 -0
  150. package/dist/resources/resource-object.js.map +1 -1
  151. package/dist/resources/template-resource.js +1 -1
  152. package/dist/resources/template-resource.js.map +1 -1
  153. package/dist/resources/workflow-resource.d.ts +2 -0
  154. package/dist/resources/workflow-resource.js +53 -9
  155. package/dist/resources/workflow-resource.js.map +1 -1
  156. package/dist/svg/index.d.ts +15 -0
  157. package/dist/svg/index.js +16 -0
  158. package/dist/svg/index.js.map +1 -0
  159. package/dist/svg/lib.d.ts +9 -0
  160. package/dist/svg/lib.js +26 -0
  161. package/dist/svg/lib.js.map +1 -0
  162. package/dist/svg/percentage.d.ts +25 -0
  163. package/dist/svg/percentage.js +90 -0
  164. package/dist/svg/percentage.js.map +1 -0
  165. package/dist/svg/scoreCard.d.ts +19 -0
  166. package/dist/svg/scoreCard.js +55 -0
  167. package/dist/svg/scoreCard.js.map +1 -0
  168. package/dist/types/queries.d.ts +8 -7
  169. package/dist/types/queries.js.map +1 -1
  170. package/dist/utils/card-utils.d.ts +6 -0
  171. package/dist/utils/card-utils.js +12 -0
  172. package/dist/utils/card-utils.js.map +1 -1
  173. package/dist/utils/clingo-facts.d.ts +2 -1
  174. package/dist/utils/clingo-facts.js +19 -2
  175. package/dist/utils/clingo-facts.js.map +1 -1
  176. package/dist/utils/clingo-parser.d.ts +1 -0
  177. package/dist/utils/clingo-parser.js +22 -100
  178. package/dist/utils/clingo-parser.js.map +1 -1
  179. package/dist/utils/constants.d.ts +7 -0
  180. package/dist/utils/constants.js +14 -0
  181. package/dist/utils/constants.js.map +1 -1
  182. package/dist/utils/csv.js.map +1 -1
  183. package/dist/utils/report.d.ts +17 -3
  184. package/dist/utils/report.js +38 -2
  185. package/dist/utils/report.js.map +1 -1
  186. package/dist/utils/resource-utils.d.ts +1 -0
  187. package/dist/utils/resource-utils.js +9 -0
  188. package/dist/utils/resource-utils.js.map +1 -1
  189. package/dist/utils/user-preferences.d.ts +1 -11
  190. package/dist/utils/user-preferences.js +30 -13
  191. package/dist/utils/user-preferences.js.map +1 -1
  192. package/dist/utils/validate.d.ts +2 -3
  193. package/dist/utils/validate.js +2 -2
  194. package/dist/utils/validate.js.map +1 -1
  195. package/package.json +8 -6
  196. package/src/command-handler.ts +96 -17
  197. package/src/command-manager.ts +8 -8
  198. package/src/commands/calculate.ts +11 -525
  199. package/src/commands/create.ts +53 -16
  200. package/src/commands/edit.ts +53 -11
  201. package/src/commands/export.ts +108 -34
  202. package/src/commands/import.ts +31 -2
  203. package/src/commands/move.ts +12 -15
  204. package/src/commands/remove.ts +10 -19
  205. package/src/commands/rename.ts +3 -12
  206. package/src/commands/show.ts +121 -8
  207. package/src/commands/transition.ts +3 -7
  208. package/src/commands/update.ts +6 -0
  209. package/src/commands/validate.ts +39 -47
  210. package/src/containers/card-container.ts +74 -0
  211. package/src/containers/project/calculation-engine.ts +535 -0
  212. package/src/containers/project/resource-collector.ts +45 -26
  213. package/src/containers/project.ts +66 -84
  214. package/src/containers/template.ts +16 -0
  215. package/src/exceptions/index.ts +36 -0
  216. package/src/index.ts +13 -2
  217. package/src/interfaces/macros.ts +7 -1
  218. package/src/interfaces/project-interfaces.ts +27 -0
  219. package/src/interfaces/resource-interfaces.ts +1 -0
  220. package/src/macros/base-macro.ts +89 -25
  221. package/src/macros/common.ts +22 -9
  222. package/src/macros/createCards/index.ts +1 -2
  223. package/src/macros/graph/index.ts +17 -12
  224. package/src/macros/image/index.ts +121 -0
  225. package/src/macros/image/metadata.ts +25 -0
  226. package/src/macros/include/index.ts +147 -0
  227. package/src/macros/include/metadata.ts +22 -0
  228. package/src/macros/index.ts +179 -100
  229. package/src/macros/percentage/index.ts +54 -0
  230. package/src/macros/percentage/metadata.ts +22 -0
  231. package/src/macros/report/index.ts +22 -17
  232. package/src/macros/scoreCard/index.ts +23 -23
  233. package/src/macros/vega/index.ts +55 -0
  234. package/src/macros/vega/metadata.ts +21 -0
  235. package/src/macros/vegalite/index.ts +50 -0
  236. package/src/macros/vegalite/metadata.ts +21 -0
  237. package/src/macros/xref/index.ts +73 -0
  238. package/src/macros/xref/metadata.ts +22 -0
  239. package/src/module-manager.ts +241 -69
  240. package/src/permissions/action-guard.ts +3 -3
  241. package/src/project-settings.ts +2 -11
  242. package/src/resources/card-type-resource.ts +100 -0
  243. package/src/resources/file-resource.ts +16 -4
  244. package/src/resources/folder-resource.ts +59 -2
  245. package/src/resources/graph-model-resource.ts +1 -1
  246. package/src/resources/graph-view-resource.ts +1 -1
  247. package/src/resources/report-resource.ts +1 -1
  248. package/src/resources/resource-object.ts +14 -0
  249. package/src/resources/template-resource.ts +1 -1
  250. package/src/resources/workflow-resource.ts +68 -13
  251. package/src/svg/index.ts +15 -0
  252. package/src/svg/lib.ts +31 -0
  253. package/src/svg/percentage.ts +97 -0
  254. package/src/svg/scoreCard.ts +88 -0
  255. package/src/types/queries.ts +8 -7
  256. package/src/types/string-pixel-width.d.ts +23 -0
  257. package/src/utils/card-utils.ts +13 -0
  258. package/src/utils/clingo-facts.ts +65 -3
  259. package/src/utils/clingo-parser.ts +31 -144
  260. package/src/utils/constants.ts +16 -0
  261. package/src/utils/csv.ts +1 -1
  262. package/src/utils/report.ts +45 -4
  263. package/src/utils/resource-utils.ts +9 -0
  264. package/src/utils/user-preferences.ts +32 -14
  265. package/src/utils/validate.ts +3 -3
@@ -79,7 +79,7 @@ export interface ResourceBaseMetadata {
79
79
  displayName: string;
80
80
  usedIn?: string[];
81
81
  }
82
- export type ResourceContent = CardType | FieldType | GraphModel | GraphView | LinkType | ReportMetadata | TemplateMetadata | Workflow;
82
+ export type ResourceContent = CalculationMetadata | CardType | FieldType | GraphModel | GraphView | LinkType | ReportMetadata | TemplateMetadata | Workflow;
83
83
  export interface TemplateConfiguration extends ResourceBaseMetadata {
84
84
  path: string;
85
85
  numberOfCards: number;
@@ -1 +1 @@
1
- {"version":3,"file":"resource-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/resource-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AA6IF,6BAA6B;AAC7B,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,iCAAa,CAAA;AACf,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B"}
1
+ {"version":3,"file":"resource-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/resource-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AA8IF,6BAA6B;AAC7B,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,iCAAa,CAAA;AACf,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B"}
@@ -16,6 +16,7 @@ declare abstract class BaseMacro {
16
16
  private readonly tasks;
17
17
  private globalId;
18
18
  private localCounter;
19
+ protected get logger(): import("pino").Logger;
19
20
  constructor(macroMetadata: MacroMetadata, tasks: TaskQueue);
20
21
  protected abstract handleInject(context: MacroGenerationContext, input: unknown): Promise<string>;
21
22
  protected abstract handleStatic(context: MacroGenerationContext, input: unknown): Promise<string>;
@@ -23,6 +24,7 @@ declare abstract class BaseMacro {
23
24
  get metadata(): MacroMetadata;
24
25
  private findDependencies;
25
26
  private generatePlaceholder;
27
+ private findTask;
26
28
  /**
27
29
  * Function responsible for starting the promise and storing it along with its localId.
28
30
  */
@@ -10,12 +10,21 @@
10
10
  License along with this program. If not, see <https://www.gnu.org/licenses/>.
11
11
  */
12
12
  import { generateRandomString } from '../utils/random.js';
13
- import { handleMacroError } from './index.js';
13
+ import { MacroError } from '../exceptions/index.js';
14
+ import { ClingoError } from '@cyberismo/node-clingo';
15
+ import { getChildLogger } from '../utils/log-utils.js';
14
16
  class BaseMacro {
15
17
  macroMetadata;
16
18
  tasks;
17
19
  globalId;
18
20
  localCounter = 0;
21
+ // Macros share the same logger
22
+ get logger() {
23
+ return getChildLogger({
24
+ module: 'macro',
25
+ macro: this.macroMetadata.name,
26
+ });
27
+ }
19
28
  constructor(macroMetadata, tasks) {
20
29
  this.macroMetadata = macroMetadata;
21
30
  this.tasks = tasks;
@@ -38,7 +47,7 @@ class BaseMacro {
38
47
  dependencies.push(task);
39
48
  }
40
49
  else {
41
- console.warn(`Dependency not found for placeholder: ${placeholder} (globalId: ${globalId}, localId: ${localId})`);
50
+ this.logger.warn(`Dependency not found for placeholder: ${placeholder} (globalId: ${globalId}, localId: ${localId})`);
42
51
  }
43
52
  }
44
53
  return dependencies;
@@ -50,6 +59,13 @@ class BaseMacro {
50
59
  placeholder: `<<macro::${this.globalId}::${localId}>>`,
51
60
  };
52
61
  }
62
+ findTask(globalId, localId) {
63
+ const task = this.tasks.find(globalId, localId);
64
+ if (!task) {
65
+ this.logger.warn(`Task not found for global id ${globalId}, local id ${localId}.`);
66
+ }
67
+ return task;
68
+ }
53
69
  /**
54
70
  * Function responsible for starting the promise and storing it along with its localId.
55
71
  */
@@ -74,39 +90,68 @@ class BaseMacro {
74
90
  // Extract dependencies
75
91
  const dependencies = this.findDependencies(rawInput);
76
92
  // Create a promise to resolve dependencies, execute the macro, and handle the results
77
- const promise = Promise.all(dependencies.map((dep) => dep.promise))
93
+ const promise = Promise.allSettled(dependencies.map((dep) => dep.promise))
78
94
  .then(() => {
79
95
  for (const dependency of dependencies) {
96
+ if (dependency.error) {
97
+ const task = this.findTask(this.globalId, localId);
98
+ if (task) {
99
+ // There could be a better way, but multi-nested macros are rare
100
+ task.error = new MacroError(dependency.error.message, context.cardKey, this.metadata.name, dependency.error.context.parameters, {
101
+ macroName: dependency.macro,
102
+ parameters: dependency.parameters,
103
+ });
104
+ }
105
+ return;
106
+ }
80
107
  input = input.replace(dependency.placeholder, dependency.promiseResult || '');
108
+ // parse json after each dep, so we know the exact macro which produced the error
109
+ try {
110
+ JSON.parse(input);
111
+ }
112
+ catch {
113
+ const task = this.findTask(this.globalId, localId);
114
+ if (task) {
115
+ task.error = new MacroError('Invalid JSON produced by macro dependency', context.cardKey, this.metadata.name, input, {
116
+ macroName: dependency.macro,
117
+ parameters: dependency.parameters,
118
+ output: input,
119
+ });
120
+ }
121
+ return;
122
+ }
81
123
  }
82
- let parsed;
83
- try {
84
- parsed = JSON.parse(input);
85
- }
86
- catch {
87
- return 'Invalid JSON';
88
- }
124
+ // This will never throw in practice, thus no need to catch
125
+ const parsed = JSON.parse(input);
89
126
  // Select the function to execute based on context mode
90
127
  const functionToCall = context.mode === 'inject' ? this.handleInject : this.handleStatic;
91
128
  // Execute the function and handle its result
92
129
  return functionToCall(context, parsed);
93
130
  })
94
131
  .then((result) => {
95
- const task = this.tasks.find(this.globalId, localId);
132
+ // undefined is used to indicate that the macro did not run for some reason
133
+ if (result === undefined) {
134
+ return;
135
+ }
136
+ const task = this.findTask(this.globalId, localId);
96
137
  if (task) {
97
138
  task.promiseResult = result;
98
139
  }
99
- else {
100
- console.error(`Task not found after execution: macro ${this.metadata.name}, local id ${localId}.`);
101
- }
102
140
  })
103
141
  .catch((err) => {
104
- const task = this.tasks.find(this.globalId, localId);
105
- if (task) {
106
- task.promiseResult = handleMacroError(err, this.metadata.name, context);
142
+ if (!(err instanceof Error)) {
143
+ this.logger.error(err, 'Unknown error');
144
+ err = new Error('Unknown error');
107
145
  }
108
- else {
109
- console.error(`Error handling task for macro ${this.metadata.name}, local id ${localId}:`, err);
146
+ const message = err instanceof ClingoError
147
+ ? err.details.errors.join('\n')
148
+ : err.message;
149
+ const error = err instanceof MacroError
150
+ ? err
151
+ : new MacroError(message, context.cardKey, this.metadata.name, input);
152
+ const task = this.findTask(this.globalId, localId);
153
+ if (task) {
154
+ task.error = error;
110
155
  }
111
156
  });
112
157
  // Store the task
@@ -117,6 +162,8 @@ class BaseMacro {
117
162
  placeholder,
118
163
  promiseResult: null,
119
164
  macro: this.macroMetadata.name,
165
+ parameters: rawInput,
166
+ error: null,
120
167
  });
121
168
  // Return the placeholder
122
169
  return placeholder;
@@ -1 +1 @@
1
- {"version":3,"file":"base-macro.js","sourceRoot":"","sources":["../../src/macros/base-macro.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAQF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,MAAe,SAAS;IAKV;IACO;IALX,QAAQ,CAAS;IACjB,YAAY,GAAW,CAAC,CAAC;IAEjC,YACY,aAA4B,EACrB,KAAgB;QADvB,kBAAa,GAAb,aAAa,CAAe;QACrB,UAAK,GAAL,KAAK,CAAW;QAEjC,wDAAwD;QACxD,IAAI,CAAC,QAAQ,GAAG,GAAG,oBAAoB,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,C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,EAAE,CAAC;gBAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;gBACxC,GAAG,GAAG,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;YACnC,CAAC;YACD,MAAM,OAAO,GACX,GAAG,YAAY,WAAW;gBACxB,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC/B,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;YAClB,MAAM,KAAK,GACT,GAAG,YAAY,UAAU;gBACvB,CAAC,CAAC,GAAG;gBACL,CAAC,CAAC,IAAI,UAAU,CACZ,OAAO,EACP,OAAO,CAAC,OAAO,EACf,IAAI,CAAC,QAAQ,CAAC,IAAI,EAClB,KAAK,CACN,CAAC;YAER,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACnD,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACrB,CAAC;QACH,CAAC,CAAC,CAAC;QAEL,iBAAiB;QACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACd,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO;YACP,OAAO;YACP,WAAW;YACX,aAAa,EAAE,IAAI;YACnB,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI;YAC9B,UAAU,EAAE,QAAQ;YACpB,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QACH,yBAAyB;QACzB,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;CACH;AAED,eAAe,SAAS,CAAC"}
@@ -1,17 +1,24 @@
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
  export declare const macroMetadata: {
13
14
  createCards: import("../interfaces/macros.js").MacroMetadata;
14
15
  graph: import("../interfaces/macros.js").MacroMetadata;
16
+ image: import("../interfaces/macros.js").MacroMetadata;
17
+ include: import("../interfaces/macros.js").MacroMetadata;
15
18
  report: import("../interfaces/macros.js").MacroMetadata;
16
19
  scoreCard: import("../interfaces/macros.js").MacroMetadata;
20
+ xref: import("../interfaces/macros.js").MacroMetadata;
21
+ percentage: import("../interfaces/macros.js").MacroMetadata;
22
+ vega: import("../interfaces/macros.js").MacroMetadata;
23
+ vegaLite: import("../interfaces/macros.js").MacroMetadata;
17
24
  };
@@ -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;
@@ -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,GA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AQ,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"}
@@ -11,15 +11,13 @@
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
  }
21
20
  declare class ReportMacro extends BaseMacro {
22
- private get logger();
23
21
  constructor(tasksQueue: TaskQueue);
24
22
  handleValidate: (input: unknown) => void;
25
23
  handleStatic: (context: MacroGenerationContext, input: unknown) => Promise<string>;
@@ -11,22 +11,16 @@
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';
18
- import { getChildLogger } from '../../utils/log-utils.js';
19
17
  import macroMetadata from './metadata.js';
20
18
  import { pathExists } from '../../utils/file-utils.js';
21
19
  import { readFile } from 'node:fs/promises';
22
20
  import { resourceName } from '../../utils/resource-utils.js';
23
21
  import { validateJson } from '../../utils/validate.js';
22
+ import { ClingoError } from '@cyberismo/node-clingo';
24
23
  class ReportMacro extends BaseMacro {
25
- get logger() {
26
- return getChildLogger({
27
- module: 'graphMacro',
28
- });
29
- }
30
24
  constructor(tasksQueue) {
31
25
  super(macroMetadata, tasksQueue);
32
26
  }
@@ -37,7 +31,6 @@ class ReportMacro extends BaseMacro {
37
31
  return this.handleInject(context, input);
38
32
  };
39
33
  handleInject = async (context, input) => {
40
- const calculate = new Calculate(context.project);
41
34
  const resourceNameToPath = (name, fileName) => {
42
35
  const { identifier, prefix, type } = resourceName(name);
43
36
  if (prefix === context.project.projectPrefix) {
@@ -77,7 +70,16 @@ class ReportMacro extends BaseMacro {
77
70
  const handlebars = Handlebars.create();
78
71
  const view = handlebars.compile(viewContent)(handlebarsContext);
79
72
  const modelContent = await readFile(modelLocation, { encoding: 'utf-8' });
80
- const result = await calculate.runGraph(modelContent, view);
73
+ let result;
74
+ try {
75
+ result = await context.project.calculationEngine.runGraph(modelContent, view, context.context);
76
+ }
77
+ catch (error) {
78
+ if (error instanceof ClingoError) {
79
+ throw new Error(`Error running graph in view '${options.view}' in model '${options.model}': ${error.details.errors.join('\n')}`);
80
+ }
81
+ throw error;
82
+ }
81
83
  if (typeof result !== 'string') {
82
84
  throw new Error('Graph macro expected a string from clingo, but received an object');
83
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/macros/graph/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,aAAa,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAQvD,MAAM,WAAY,SAAQ,SAAS;IACjC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,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,78 @@
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
+ // Build image attributes
60
+ const attributes = this.buildImageAttributes(options);
61
+ // In inject mode, always use the API path for consistency
62
+ return `image::/api/cards/${cardKey}/a/${options.fileName}[${attributes}]`;
63
+ };
64
+ buildImageAttributes(options) {
65
+ const attributes = [];
66
+ if (options.alt !== undefined) {
67
+ attributes.push(`alt="${options.alt}"`);
68
+ }
69
+ if (options.title !== undefined) {
70
+ attributes.push(`title="${options.title}"`);
71
+ }
72
+ return attributes.join(',');
73
+ }
74
+ validate(input) {
75
+ return validateMacroContent(this.metadata, input);
76
+ }
77
+ }
78
+ //# 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,CAA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OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;QAEnD,mDAAmD;QACnD,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,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,32 @@
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
+ handleInject: (context: MacroGenerationContext, input: unknown) => Promise<string>;
27
+ private validate;
28
+ private generateAnchor;
29
+ private generateTitle;
30
+ private generateCardContent;
31
+ private adjustTitles;
32
+ }