@cyberismo/data-handler 0.0.14 → 0.0.16
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.
- package/dist/card-metadata-updater.js +8 -4
- package/dist/card-metadata-updater.js.map +1 -1
- package/dist/command-handler.d.ts +4 -0
- package/dist/command-handler.js +29 -19
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +25 -2
- package/dist/command-manager.js +30 -5
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/create.d.ts +1 -1
- package/dist/commands/create.js +45 -93
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/edit.d.ts +1 -15
- package/dist/commands/edit.js +15 -89
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.d.ts +11 -2
- package/dist/commands/export.js +58 -58
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/import.d.ts +9 -1
- package/dist/commands/import.js +17 -11
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/move.d.ts +1 -2
- package/dist/commands/move.js +107 -146
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.d.ts +8 -1
- package/dist/commands/remove.js +17 -48
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.d.ts +4 -9
- package/dist/commands/rename.js +34 -108
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +22 -34
- package/dist/commands/show.js +103 -151
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.d.ts +9 -2
- package/dist/commands/transition.js +49 -44
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.d.ts +18 -12
- package/dist/commands/update.js +34 -18
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.d.ts +18 -10
- package/dist/commands/validate.js +101 -47
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/card-container.d.ts +87 -24
- package/dist/containers/card-container.js +183 -279
- package/dist/containers/card-container.js.map +1 -1
- package/dist/containers/project/calculation-engine.d.ts +13 -4
- package/dist/containers/project/calculation-engine.js +79 -77
- package/dist/containers/project/calculation-engine.js.map +1 -1
- package/dist/containers/project/card-cache.d.ts +146 -0
- package/dist/containers/project/card-cache.js +411 -0
- package/dist/containers/project/card-cache.js.map +1 -0
- package/dist/containers/project/project-paths.d.ts +5 -4
- package/dist/containers/project/project-paths.js +16 -12
- package/dist/containers/project/project-paths.js.map +1 -1
- package/dist/containers/project/resource-cache.d.ts +169 -0
- package/dist/containers/project/resource-cache.js +507 -0
- package/dist/containers/project/resource-cache.js.map +1 -0
- package/dist/containers/project/resource-handler.d.ts +129 -0
- package/dist/containers/project/resource-handler.js +206 -0
- package/dist/containers/project/resource-handler.js.map +1 -0
- package/dist/containers/project.d.ts +114 -195
- package/dist/containers/project.js +425 -535
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.d.ts +22 -32
- package/dist/containers/template.js +113 -115
- package/dist/containers/template.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/folder-content-interfaces.d.ts +7 -4
- package/dist/interfaces/folder-content-interfaces.js +3 -3
- package/dist/interfaces/folder-content-interfaces.js.map +1 -1
- package/dist/interfaces/macros.d.ts +1 -0
- package/dist/interfaces/macros.js +1 -1
- package/dist/interfaces/macros.js.map +1 -1
- package/dist/interfaces/project-interfaces.d.ts +7 -5
- package/dist/interfaces/project-interfaces.js.map +1 -1
- package/dist/interfaces/resource-interfaces.d.ts +25 -22
- package/dist/interfaces/resource-interfaces.js +3 -0
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/common.d.ts +10 -10
- package/dist/macros/createCards/index.d.ts +0 -13
- package/dist/macros/createCards/index.js.map +1 -1
- package/dist/macros/createCards/types.d.ts +44 -0
- package/dist/macros/createCards/types.js +15 -0
- package/dist/macros/createCards/types.js.map +1 -0
- package/dist/macros/graph/index.d.ts +2 -6
- package/dist/macros/graph/index.js +14 -28
- package/dist/macros/graph/index.js.map +1 -1
- package/dist/macros/graph/types.d.ts +23 -0
- package/dist/macros/graph/types.js +15 -0
- package/dist/macros/graph/types.js.map +1 -0
- package/dist/macros/image/index.d.ts +8 -16
- package/dist/macros/image/index.js +36 -33
- package/dist/macros/image/index.js.map +1 -1
- package/dist/macros/image/types.d.ts +38 -0
- package/dist/macros/image/types.js +15 -0
- package/dist/macros/image/types.js.map +1 -0
- package/dist/macros/include/index.d.ts +1 -6
- package/dist/macros/include/index.js +4 -7
- package/dist/macros/include/index.js.map +1 -1
- package/dist/macros/include/types.d.ts +31 -0
- package/dist/macros/include/types.js +15 -0
- package/dist/macros/include/types.js.map +1 -0
- package/dist/macros/index.d.ts +1 -1
- package/dist/macros/index.js +2 -2
- package/dist/macros/index.js.map +1 -1
- package/dist/macros/percentage/index.d.ts +0 -6
- package/dist/macros/percentage/index.js.map +1 -1
- package/dist/macros/percentage/types.d.ts +31 -0
- package/dist/macros/percentage/types.js +15 -0
- package/dist/macros/percentage/types.js.map +1 -0
- package/dist/macros/report/index.d.ts +0 -3
- package/dist/macros/report/index.js +3 -6
- package/dist/macros/report/index.js.map +1 -1
- package/dist/macros/report/types.d.ts +19 -0
- package/dist/macros/report/types.js +15 -0
- package/dist/macros/report/types.js.map +1 -0
- package/dist/macros/scoreCard/index.d.ts +0 -6
- package/dist/macros/scoreCard/index.js.map +1 -1
- package/dist/macros/scoreCard/types.d.ts +31 -0
- package/dist/macros/scoreCard/types.js +15 -0
- package/dist/macros/scoreCard/types.js.map +1 -0
- package/dist/macros/types.d.ts +25 -0
- package/dist/macros/types.js +2 -0
- package/dist/macros/types.js.map +1 -0
- package/dist/macros/vega/index.d.ts +0 -4
- package/dist/macros/vega/index.js.map +1 -1
- package/dist/macros/vega/types.d.ts +20 -0
- package/dist/macros/vega/types.js +2 -0
- package/dist/macros/vega/types.js.map +1 -0
- package/dist/macros/vegalite/index.d.ts +0 -4
- package/dist/macros/vegalite/index.js.map +1 -1
- package/dist/macros/vegalite/types.d.ts +20 -0
- package/dist/macros/vegalite/types.js +15 -0
- package/dist/macros/vegalite/types.js.map +1 -0
- package/dist/macros/xref/index.d.ts +0 -3
- package/dist/macros/xref/index.js +5 -14
- package/dist/macros/xref/index.js.map +1 -1
- package/dist/macros/xref/types.d.ts +19 -0
- package/dist/macros/xref/types.js +15 -0
- package/dist/macros/xref/types.js.map +1 -0
- package/dist/module-manager.d.ts +16 -3
- package/dist/module-manager.js +55 -23
- package/dist/module-manager.js.map +1 -1
- package/dist/project-settings.d.ts +16 -3
- package/dist/project-settings.js +79 -14
- package/dist/project-settings.js.map +1 -1
- package/dist/resources/calculation-resource.d.ts +6 -33
- package/dist/resources/calculation-resource.js +11 -60
- package/dist/resources/calculation-resource.js.map +1 -1
- package/dist/resources/card-type-resource.d.ts +10 -22
- package/dist/resources/card-type-resource.js +46 -66
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/create-defaults.d.ts +3 -2
- package/dist/resources/create-defaults.js +3 -2
- package/dist/resources/create-defaults.js.map +1 -1
- package/dist/resources/field-type-resource.d.ts +8 -22
- package/dist/resources/field-type-resource.js +35 -60
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.d.ts +14 -35
- package/dist/resources/file-resource.js +22 -301
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +44 -66
- package/dist/resources/folder-resource.js +102 -149
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +9 -34
- package/dist/resources/graph-model-resource.js +18 -64
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +9 -29
- package/dist/resources/graph-view-resource.js +13 -48
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.d.ts +9 -23
- package/dist/resources/link-type-resource.js +11 -33
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +10 -23
- package/dist/resources/report-resource.js +20 -67
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +143 -23
- package/dist/resources/resource-object.js +369 -48
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +10 -17
- package/dist/resources/template-resource.js +19 -27
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +9 -25
- package/dist/resources/workflow-resource.js +25 -55
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/utils/card-utils.d.ts +69 -19
- package/dist/utils/card-utils.js +179 -30
- package/dist/utils/card-utils.js.map +1 -1
- package/dist/utils/clingo-fact-builder.d.ts +25 -14
- package/dist/utils/clingo-fact-builder.js +27 -5
- package/dist/utils/clingo-fact-builder.js.map +1 -1
- package/dist/utils/clingo-facts.js +14 -7
- package/dist/utils/clingo-facts.js.map +1 -1
- package/dist/utils/clingo-parser.js +1 -1
- package/dist/utils/clingo-parser.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -0
- package/dist/utils/constants.js +4 -0
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/csv.js +1 -1
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/resource-utils.d.ts +1 -0
- package/dist/utils/resource-utils.js +2 -1
- package/dist/utils/resource-utils.js.map +1 -1
- package/package.json +11 -11
- package/src/card-metadata-updater.ts +9 -7
- package/src/command-handler.ts +35 -23
- package/src/command-manager.ts +32 -19
- package/src/commands/create.ts +59 -160
- package/src/commands/edit.ts +16 -132
- package/src/commands/export.ts +71 -81
- package/src/commands/import.ts +26 -18
- package/src/commands/move.ts +143 -179
- package/src/commands/remove.ts +20 -59
- package/src/commands/rename.ts +45 -156
- package/src/commands/show.ts +153 -211
- package/src/commands/transition.ts +53 -58
- package/src/commands/update.ts +44 -23
- package/src/commands/validate.ts +108 -82
- package/src/containers/card-container.ts +200 -360
- package/src/containers/project/calculation-engine.ts +81 -105
- package/src/containers/project/card-cache.ts +497 -0
- package/src/containers/project/project-paths.ts +21 -13
- package/src/containers/project/resource-cache.ts +648 -0
- package/src/containers/project/resource-handler.ts +265 -0
- package/src/containers/project.ts +551 -693
- package/src/containers/template.ts +129 -142
- package/src/index.ts +1 -0
- package/src/interfaces/folder-content-interfaces.ts +14 -7
- package/src/interfaces/macros.ts +2 -0
- package/src/interfaces/project-interfaces.ts +14 -7
- package/src/interfaces/resource-interfaces.ts +30 -27
- package/src/macros/createCards/index.ts +1 -12
- package/src/macros/createCards/types.ts +46 -0
- package/src/macros/graph/index.ts +27 -52
- package/src/macros/graph/types.ts +24 -0
- package/src/macros/image/index.ts +50 -61
- package/src/macros/image/types.ts +39 -0
- package/src/macros/include/index.ts +6 -15
- package/src/macros/include/types.ts +32 -0
- package/src/macros/index.ts +2 -2
- package/src/macros/percentage/index.ts +1 -7
- package/src/macros/percentage/types.ts +32 -0
- package/src/macros/report/index.ts +4 -13
- package/src/macros/report/types.ts +20 -0
- package/src/macros/scoreCard/index.ts +1 -7
- package/src/macros/scoreCard/types.ts +32 -0
- package/src/macros/types.ts +48 -0
- package/src/macros/vega/index.ts +1 -4
- package/src/macros/vega/types.ts +21 -0
- package/src/macros/vegalite/index.ts +1 -4
- package/src/macros/vegalite/types.ts +22 -0
- package/src/macros/xref/index.ts +6 -20
- package/src/macros/xref/types.ts +20 -0
- package/src/module-manager.ts +79 -22
- package/src/project-settings.ts +84 -15
- package/src/resources/calculation-resource.ts +21 -91
- package/src/resources/card-type-resource.ts +74 -109
- package/src/resources/create-defaults.ts +3 -2
- package/src/resources/field-type-resource.ts +61 -104
- package/src/resources/file-resource.ts +33 -441
- package/src/resources/folder-resource.ts +130 -207
- package/src/resources/graph-model-resource.ts +36 -95
- package/src/resources/graph-view-resource.ts +28 -70
- package/src/resources/link-type-resource.ts +23 -53
- package/src/resources/report-resource.ts +34 -96
- package/src/resources/resource-object.ts +511 -66
- package/src/resources/template-resource.ts +32 -44
- package/src/resources/workflow-resource.ts +42 -85
- package/src/utils/card-utils.ts +217 -31
- package/src/utils/clingo-fact-builder.ts +28 -16
- package/src/utils/clingo-facts.ts +16 -7
- package/src/utils/clingo-parser.ts +1 -1
- package/src/utils/constants.ts +6 -0
- package/src/utils/csv.ts +1 -1
- package/src/utils/resource-utils.ts +2 -1
- package/dist/containers/project/resource-collector.d.ts +0 -87
- package/dist/containers/project/resource-collector.js +0 -337
- package/dist/containers/project/resource-collector.js.map +0 -1
- package/src/containers/project/resource-collector.ts +0 -396
|
@@ -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
|
+
}
|
|
@@ -18,14 +18,9 @@ import macroMetadata from './metadata.js';
|
|
|
18
18
|
import BaseMacro from '../base-macro.js';
|
|
19
19
|
import { validateJson } from '../../utils/validate.js';
|
|
20
20
|
import type TaskQueue from '../task-queue.js';
|
|
21
|
-
import { ReportResource } from '../../resources/report-resource.js';
|
|
22
|
-
import { resourceName } from '../../utils/resource-utils.js';
|
|
23
21
|
import { generateReportContent } from '../../utils/report.js';
|
|
24
22
|
import { ClingoError } from '@cyberismo/node-clingo';
|
|
25
|
-
|
|
26
|
-
export interface ReportOptions {
|
|
27
|
-
name: string;
|
|
28
|
-
}
|
|
23
|
+
import type { ReportOptions } from './types.js';
|
|
29
24
|
|
|
30
25
|
class ReportMacro extends BaseMacro {
|
|
31
26
|
constructor(tasks: TaskQueue) {
|
|
@@ -37,13 +32,9 @@ class ReportMacro extends BaseMacro {
|
|
|
37
32
|
|
|
38
33
|
handleStatic = async (context: MacroGenerationContext, data: unknown) => {
|
|
39
34
|
const options = this.validate(data);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
44
|
-
const report = await resource.show();
|
|
45
|
-
|
|
46
|
-
if (!report) throw new Error(`Report ${options.name} does not exist`);
|
|
35
|
+
const report = context.project.resources
|
|
36
|
+
.byType(options.name, 'reports')
|
|
37
|
+
.show();
|
|
47
38
|
|
|
48
39
|
if (report.content.schema) {
|
|
49
40
|
validateJson(options, {
|
|
@@ -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
|
+
};
|
package/src/macros/vega/index.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/macros/xref/index.ts
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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
|
|
61
|
-
|
|
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
|
+
}
|
package/src/module-manager.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { Project } from './containers/project.js';
|
|
|
26
26
|
import type { ProjectConfiguration } from './project-settings.js';
|
|
27
27
|
import { ProjectPaths } from './containers/project/project-paths.js';
|
|
28
28
|
import { readJsonFile } from './utils/json.js';
|
|
29
|
-
import { Validate } from './commands/
|
|
29
|
+
import { Validate } from './commands/validate.js';
|
|
30
30
|
|
|
31
31
|
const FILE_PROTOCOL = 'file:';
|
|
32
32
|
const HTTPS_PROTOCOL = 'https:';
|
|
@@ -54,7 +54,7 @@ export class ModuleManager {
|
|
|
54
54
|
await copyDir(sourcePath, destinationPath);
|
|
55
55
|
|
|
56
56
|
// Update the resources.
|
|
57
|
-
|
|
57
|
+
this.project.resources.changedModules();
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Creates a map of what dependencies each module depend from.
|
|
@@ -213,13 +213,11 @@ export class ModuleManager {
|
|
|
213
213
|
|
|
214
214
|
// Fetches direct dependencies of a module.
|
|
215
215
|
private async dependencies(moduleName: string): Promise<Set<string>> {
|
|
216
|
-
const
|
|
217
|
-
if (!allModules) return new Set();
|
|
218
|
-
const module = allModules.find((m) => m.name === moduleName);
|
|
216
|
+
const module = await this.project.module(moduleName);
|
|
219
217
|
if (!module) {
|
|
220
218
|
throw new Error(`Module '${moduleName}' not found`);
|
|
221
219
|
}
|
|
222
|
-
const modulePath = join(module.path,
|
|
220
|
+
const modulePath = join(module.path, 'cardsConfig.json');
|
|
223
221
|
const moduleConfiguration = (await readJsonFile(
|
|
224
222
|
modulePath,
|
|
225
223
|
)) as ProjectConfiguration;
|
|
@@ -287,7 +285,7 @@ export class ModuleManager {
|
|
|
287
285
|
|
|
288
286
|
// Imports from a given folder. Is used both for .temp/<module name> and file locations.
|
|
289
287
|
private async importFromFolder(path: string, name: string) {
|
|
290
|
-
await this.importFileModule(path);
|
|
288
|
+
await this.importFileModule(path, undefined, true); // Skip validation during updates
|
|
291
289
|
console.log(
|
|
292
290
|
`... Imported module '${name}' to '${this.project.configuration.name}'`,
|
|
293
291
|
);
|
|
@@ -309,10 +307,10 @@ export class ModuleManager {
|
|
|
309
307
|
|
|
310
308
|
// Collect modules that could be removed from .cards/modules when
|
|
311
309
|
// 'moduleName' is removed.
|
|
312
|
-
private
|
|
310
|
+
private orphanedModules(
|
|
313
311
|
dependencies: DependencyGraph,
|
|
314
312
|
moduleName: string,
|
|
315
|
-
):
|
|
313
|
+
): string[] {
|
|
316
314
|
const projectModules = this.project.configuration.modules;
|
|
317
315
|
const removableTransientModules: string[] = [];
|
|
318
316
|
if (dependencies.has(moduleName)) {
|
|
@@ -361,6 +359,9 @@ export class ModuleManager {
|
|
|
361
359
|
try {
|
|
362
360
|
await this.removeModuleFiles(module.name);
|
|
363
361
|
console.log(`... Removed imported module '${module.name}'`);
|
|
362
|
+
|
|
363
|
+
// Refresh module resources in cache after filesystem removal to avoid stale prefixes
|
|
364
|
+
this.project.resources.changedModules();
|
|
364
365
|
} catch (error) {
|
|
365
366
|
if (error instanceof Error)
|
|
366
367
|
console.error(
|
|
@@ -479,7 +480,11 @@ export class ModuleManager {
|
|
|
479
480
|
}
|
|
480
481
|
|
|
481
482
|
// Updates modules in the project.
|
|
482
|
-
private async update(
|
|
483
|
+
private async update(
|
|
484
|
+
module?: ModuleSetting,
|
|
485
|
+
credentials?: Credentials,
|
|
486
|
+
skipModules?: Set<string>,
|
|
487
|
+
) {
|
|
483
488
|
// Prints dots every half second so that user knows that something is ongoing
|
|
484
489
|
function start() {
|
|
485
490
|
console.log('... Collecting unique modules. This takes a moment.');
|
|
@@ -514,22 +519,46 @@ export class ModuleManager {
|
|
|
514
519
|
uniqueModules.map((item) => item.name),
|
|
515
520
|
);
|
|
516
521
|
|
|
522
|
+
// Filter out modules that are already imported
|
|
523
|
+
const modulesToImport = skipModules
|
|
524
|
+
? uniqueModules.filter((module) => !skipModules.has(module.name))
|
|
525
|
+
: uniqueModules;
|
|
526
|
+
|
|
527
|
+
if (
|
|
528
|
+
skipModules &&
|
|
529
|
+
skipModules.size > 0 &&
|
|
530
|
+
modulesToImport.length < uniqueModules.length
|
|
531
|
+
) {
|
|
532
|
+
const skippedModules = uniqueModules
|
|
533
|
+
.filter((module) => skipModules.has(module.name))
|
|
534
|
+
.map((m) => m.name)
|
|
535
|
+
.join(', ');
|
|
536
|
+
console.log(
|
|
537
|
+
`... Skipping already imported module(s): ${skippedModules}`,
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
517
541
|
// Update modules parallel.
|
|
518
542
|
const promises: Promise<void>[] = [];
|
|
519
|
-
|
|
543
|
+
modulesToImport.forEach((module) =>
|
|
520
544
|
promises.push(this.handleModule(module)),
|
|
521
545
|
);
|
|
522
546
|
await Promise.all(promises);
|
|
523
547
|
await deleteDir(this.tempModulesDir);
|
|
524
|
-
|
|
548
|
+
this.project.resources.changedModules();
|
|
525
549
|
}
|
|
526
550
|
}
|
|
527
551
|
|
|
528
552
|
// Checks that module prefix is not in use in the project
|
|
529
|
-
|
|
553
|
+
// Optionally skip check for modules that are already imported (during updates)
|
|
554
|
+
private validatePrefix(modulePrefix: string, skipIfExists = false) {
|
|
530
555
|
// Do not allow modules with same prefixes.
|
|
531
|
-
const currentlyUsedPrefixes =
|
|
556
|
+
const currentlyUsedPrefixes = this.project.projectPrefixes();
|
|
532
557
|
if (currentlyUsedPrefixes.includes(modulePrefix)) {
|
|
558
|
+
// If skipIfExists is true, allow re-importing modules that are already present
|
|
559
|
+
if (skipIfExists) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
533
562
|
throw new Error(
|
|
534
563
|
`Imported project has a prefix '${modulePrefix}' that is already used in the project. Cannot import from module.`,
|
|
535
564
|
);
|
|
@@ -540,8 +569,14 @@ export class ModuleManager {
|
|
|
540
569
|
* Imports module from local file path.
|
|
541
570
|
* @param source Path to import from.
|
|
542
571
|
* @param destination is this really needed???
|
|
572
|
+
* @param skipValidation Skip prefix validation (used during updates)
|
|
573
|
+
* @returns Module prefix of the imported module.
|
|
543
574
|
*/
|
|
544
|
-
public async importFileModule(
|
|
575
|
+
public async importFileModule(
|
|
576
|
+
source: string,
|
|
577
|
+
destination?: string,
|
|
578
|
+
skipValidation = false,
|
|
579
|
+
) {
|
|
545
580
|
if (!Validate.validateFolder(source)) {
|
|
546
581
|
throw new Error(
|
|
547
582
|
`Input validation error: folder name is invalid '${source}'`,
|
|
@@ -558,6 +593,7 @@ export class ModuleManager {
|
|
|
558
593
|
);
|
|
559
594
|
}
|
|
560
595
|
const sourceProject = new Project(source);
|
|
596
|
+
await sourceProject.populateCaches();
|
|
561
597
|
const modulePrefix = sourceProject.projectPrefix;
|
|
562
598
|
const destinationPath = join(
|
|
563
599
|
this.project.paths.modulesFolder,
|
|
@@ -565,7 +601,7 @@ export class ModuleManager {
|
|
|
565
601
|
);
|
|
566
602
|
const sourcePath = sourceProject.paths.resourcesFolder;
|
|
567
603
|
|
|
568
|
-
|
|
604
|
+
this.validatePrefix(modulePrefix, skipValidation);
|
|
569
605
|
|
|
570
606
|
// Copy files.
|
|
571
607
|
await this.addFileContents(sourcePath, destinationPath);
|
|
@@ -577,12 +613,14 @@ export class ModuleManager {
|
|
|
577
613
|
* @param source Git URL to import from.
|
|
578
614
|
* @param options Modules setting options.
|
|
579
615
|
* @param credentials Credentials for private repositories.
|
|
616
|
+
* @param skipValidation Skip prefix validation (used during updates)
|
|
580
617
|
* @returns module prefix as defined in its CardsConfig.json
|
|
581
618
|
*/
|
|
582
619
|
public async importGitModule(
|
|
583
620
|
source: string,
|
|
584
621
|
options?: ModuleSettingOptions,
|
|
585
622
|
credentials?: Credentials,
|
|
623
|
+
skipValidation = false,
|
|
586
624
|
) {
|
|
587
625
|
const clonedName = await this.clone(
|
|
588
626
|
{
|
|
@@ -595,7 +633,7 @@ export class ModuleManager {
|
|
|
595
633
|
);
|
|
596
634
|
const clonePath = join(this.tempModulesDir, clonedName);
|
|
597
635
|
const modulePrefix = (await this.configuration(clonePath)).cardKeyPrefix;
|
|
598
|
-
|
|
636
|
+
this.validatePrefix(modulePrefix, skipValidation);
|
|
599
637
|
|
|
600
638
|
const sourcePath = new ProjectPaths(clonePath).resourcesFolder;
|
|
601
639
|
const destinationPath = join(
|
|
@@ -611,6 +649,7 @@ export class ModuleManager {
|
|
|
611
649
|
* If module is not used by any other modules, then will remove the module from disk as well.
|
|
612
650
|
* Otherwise, only updates project configuration.
|
|
613
651
|
* @param moduleName Name of the module to remove
|
|
652
|
+
* @throws If module was not found.
|
|
614
653
|
*/
|
|
615
654
|
public async removeModule(moduleName: string) {
|
|
616
655
|
const projectModules = this.project.configuration.modules;
|
|
@@ -625,7 +664,7 @@ export class ModuleManager {
|
|
|
625
664
|
// but modules under .cards/modules must be checked not to be used by
|
|
626
665
|
// other modules.
|
|
627
666
|
if (this.canBeRemoved(dependencies, moduleName)) {
|
|
628
|
-
const orphans =
|
|
667
|
+
const orphans = this.orphanedModules(dependencies, moduleName);
|
|
629
668
|
await deleteDir(module.path);
|
|
630
669
|
for (const moduleToDelete of orphans) {
|
|
631
670
|
const modulePath = join(
|
|
@@ -634,19 +673,37 @@ export class ModuleManager {
|
|
|
634
673
|
);
|
|
635
674
|
await deleteDir(modulePath);
|
|
636
675
|
}
|
|
637
|
-
await this.project.collectModuleResources();
|
|
638
676
|
}
|
|
639
|
-
await this.project.
|
|
677
|
+
await this.project.removeModule(moduleName);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Updates dependencies for a module without re-importing the module itself.
|
|
682
|
+
* Used during module import to fetch dependencies after the main module is already imported.
|
|
683
|
+
* @param module Module whose dependencies should be updated.
|
|
684
|
+
* @param credentials Optional credentials for private repositories.
|
|
685
|
+
* @returns Module prefix as defined in its CardsConfig.json
|
|
686
|
+
*/
|
|
687
|
+
public async updateDependencies(
|
|
688
|
+
module: ModuleSetting,
|
|
689
|
+
credentials?: Credentials,
|
|
690
|
+
) {
|
|
691
|
+
return this.update(module, credentials, new Set([module.name]));
|
|
640
692
|
}
|
|
641
693
|
|
|
642
694
|
/**
|
|
643
695
|
* Imports module from a local file path or a git URL.
|
|
644
696
|
* @param module Module to update. If not provided, updates all modules.
|
|
645
697
|
* @param credentials Optional credentials for private repositories.
|
|
698
|
+
* @param skipModules Optional set of module names to skip during import.
|
|
646
699
|
* @returns Module prefix as defined in its CardsConfig.json
|
|
647
700
|
*/
|
|
648
|
-
public async updateModule(
|
|
649
|
-
|
|
701
|
+
public async updateModule(
|
|
702
|
+
module: ModuleSetting,
|
|
703
|
+
credentials?: Credentials,
|
|
704
|
+
skipModules?: Set<string>,
|
|
705
|
+
) {
|
|
706
|
+
return this.update(module, credentials, skipModules);
|
|
650
707
|
}
|
|
651
708
|
|
|
652
709
|
/**
|