@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
|
@@ -18,8 +18,12 @@ export interface Card {
|
|
|
18
18
|
content?: string;
|
|
19
19
|
metadata?: CardMetadata;
|
|
20
20
|
parent?: string;
|
|
21
|
-
children:
|
|
21
|
+
children: string[];
|
|
22
22
|
attachments: CardAttachment[];
|
|
23
|
+
calculations?: unknown[];
|
|
24
|
+
}
|
|
25
|
+
export interface CardWithChildrenCards extends Card {
|
|
26
|
+
childrenCards: CardWithChildrenCards[];
|
|
23
27
|
}
|
|
24
28
|
export interface CardAttachment {
|
|
25
29
|
card: string;
|
|
@@ -126,6 +130,7 @@ export interface ProjectMetadata {
|
|
|
126
130
|
numberOfCards: number;
|
|
127
131
|
}
|
|
128
132
|
export interface ProjectSettings {
|
|
133
|
+
schemaVersion?: number;
|
|
129
134
|
cardKeyPrefix: string;
|
|
130
135
|
name: string;
|
|
131
136
|
modules: ModuleSetting[];
|
|
@@ -150,11 +155,8 @@ export interface ModuleSettingOptions {
|
|
|
150
155
|
credentials?: Credentials;
|
|
151
156
|
}
|
|
152
157
|
export type RemovableResourceTypes = 'attachment' | 'calculation' | 'card' | 'cardType' | 'fieldType' | 'graphModel' | 'graphView' | 'hub' | 'link' | 'linkType' | 'module' | 'report' | 'template' | 'workflow' | 'label';
|
|
153
|
-
export interface Resource {
|
|
154
|
-
name: string;
|
|
155
|
-
path: string;
|
|
156
|
-
}
|
|
157
158
|
export type ResourceFolderType = 'calculations' | 'cardTypes' | 'fieldTypes' | 'graphModels' | 'graphViews' | 'linkTypes' | 'modules' | 'reports' | 'templates' | 'workflows';
|
|
159
|
+
export type ResourceType = Exclude<ResourceFolderType, 'modules'>;
|
|
158
160
|
export type ResourceTypes = RemovableResourceTypes | ResourceFolderType | 'attachments' | 'calculation' | 'cards' | 'hubs' | 'importableModules' | 'label' | 'labels' | 'links' | 'modules' | 'project' | 'projects';
|
|
159
161
|
export { TemplateConfiguration };
|
|
160
162
|
export declare const CardNameRegEx: RegExp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/project-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;
|
|
1
|
+
{"version":3,"file":"project-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/project-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AA8CF,mGAAmG;AACnG,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,uCAAuB,CAAA;IACvB,uCAAuB,CAAA;AACzB,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AASD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAC;AAI9E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAsB,EAAE;IAC/D,OAAO,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC,CAAC;AA+LF,oGAAoG;AACpG,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
13
|
import type { CalculationContent, GraphModelContent, GraphViewContent, ReportContent } from './folder-content-interfaces.js';
|
|
14
|
+
import type { ResourceType } from './project-interfaces.js';
|
|
14
15
|
/**
|
|
15
16
|
* Each resource represents a file (or a folder in some cases) with metadata stored
|
|
16
17
|
* in JSON file. Name of the file is the name of the resource. Each resource is expected to be
|
|
@@ -34,10 +35,6 @@ export interface CardType extends ResourceBaseMetadata {
|
|
|
34
35
|
alwaysVisibleFields: string[];
|
|
35
36
|
optionallyVisibleFields: string[];
|
|
36
37
|
}
|
|
37
|
-
export interface ContentUpdateKey {
|
|
38
|
-
key: 'content';
|
|
39
|
-
subKey: string;
|
|
40
|
-
}
|
|
41
38
|
export interface CustomField {
|
|
42
39
|
name: string;
|
|
43
40
|
description?: string;
|
|
@@ -61,11 +58,6 @@ export interface GraphModel extends GraphModelMetadata {
|
|
|
61
58
|
content: GraphModelContent;
|
|
62
59
|
}
|
|
63
60
|
export type GraphModelContentPropertyName = 'model';
|
|
64
|
-
export interface GraphModelContentUpdateKey {
|
|
65
|
-
key: 'content';
|
|
66
|
-
subKey: GraphModelContentPropertyName;
|
|
67
|
-
}
|
|
68
|
-
export type GraphModelUpdateKey = string | GraphModelContentUpdateKey;
|
|
69
61
|
export interface GraphViewMetadata extends ResourceBaseMetadata {
|
|
70
62
|
category?: string;
|
|
71
63
|
}
|
|
@@ -73,11 +65,6 @@ export type GraphViewContentPropertyName = 'viewTemplate';
|
|
|
73
65
|
export interface GraphView extends GraphViewMetadata {
|
|
74
66
|
content: GraphViewContent;
|
|
75
67
|
}
|
|
76
|
-
export interface GraphViewContentUpdateKey {
|
|
77
|
-
key: 'content';
|
|
78
|
-
subKey: GraphViewContentPropertyName;
|
|
79
|
-
}
|
|
80
|
-
export type GraphViewUpdateKey = string | GraphViewContentUpdateKey;
|
|
81
68
|
export interface Link {
|
|
82
69
|
linkType: string;
|
|
83
70
|
cardKey: string;
|
|
@@ -90,15 +77,10 @@ export interface LinkType extends ResourceBaseMetadata {
|
|
|
90
77
|
destinationCardTypes: string[];
|
|
91
78
|
enableLinkDescription: boolean;
|
|
92
79
|
}
|
|
93
|
-
export interface Report extends
|
|
80
|
+
export interface Report extends ReportMetadata {
|
|
94
81
|
content: ReportContent;
|
|
95
82
|
}
|
|
96
83
|
export type ReportContentPropertyName = 'contentTemplate' | 'queryTemplate' | 'schema';
|
|
97
|
-
export interface ReportContentUpdateKey {
|
|
98
|
-
key: 'content';
|
|
99
|
-
subKey: ReportContentPropertyName;
|
|
100
|
-
}
|
|
101
|
-
export type ReportUpdateKey = string | ReportContentUpdateKey;
|
|
102
84
|
export interface ReportMetadata extends ResourceBaseMetadata {
|
|
103
85
|
category: string;
|
|
104
86
|
}
|
|
@@ -108,7 +90,19 @@ export interface ResourceBaseMetadata {
|
|
|
108
90
|
displayName: string;
|
|
109
91
|
usedIn?: string[];
|
|
110
92
|
}
|
|
111
|
-
export type
|
|
93
|
+
export type AnyResourceContent = Calculation | CardType | FieldType | GraphModel | GraphView | LinkType | Report | TemplateMetadata | Workflow;
|
|
94
|
+
export type ResourceContent<T extends ResourceType> = ResourceContentMap[T];
|
|
95
|
+
export type ResourceContentMap = {
|
|
96
|
+
calculations: Calculation;
|
|
97
|
+
cardTypes: CardType;
|
|
98
|
+
fieldTypes: FieldType;
|
|
99
|
+
graphModels: GraphModel;
|
|
100
|
+
graphViews: GraphView;
|
|
101
|
+
linkTypes: LinkType;
|
|
102
|
+
reports: Report;
|
|
103
|
+
templates: TemplateMetadata;
|
|
104
|
+
workflows: Workflow;
|
|
105
|
+
};
|
|
112
106
|
export interface TemplateConfiguration extends TemplateMetadata {
|
|
113
107
|
path: string;
|
|
114
108
|
numberOfCards: number;
|
|
@@ -116,7 +110,15 @@ export interface TemplateConfiguration extends TemplateMetadata {
|
|
|
116
110
|
export interface TemplateMetadata extends ResourceBaseMetadata {
|
|
117
111
|
category?: string;
|
|
118
112
|
}
|
|
119
|
-
|
|
113
|
+
type ContentUpdateKey = {
|
|
114
|
+
key: 'content';
|
|
115
|
+
subKey: string;
|
|
116
|
+
};
|
|
117
|
+
type PropertyUpdateKey<K extends string = string> = {
|
|
118
|
+
key: Exclude<K, 'content'>;
|
|
119
|
+
};
|
|
120
|
+
export type UpdateKey<K extends string = string> = ContentUpdateKey | PropertyUpdateKey<K>;
|
|
121
|
+
export declare function isContentKey(key: UpdateKey): key is ContentUpdateKey;
|
|
120
122
|
export interface Workflow extends ResourceBaseMetadata {
|
|
121
123
|
states: WorkflowState[];
|
|
122
124
|
transitions: WorkflowTransition[];
|
|
@@ -136,3 +138,4 @@ export interface WorkflowTransition {
|
|
|
136
138
|
fromState: string[];
|
|
137
139
|
toState: string;
|
|
138
140
|
}
|
|
141
|
+
export {};
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
details. You should have received a copy of the GNU Affero General Public
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
|
+
export function isContentKey(key) {
|
|
14
|
+
return key.key === 'content';
|
|
15
|
+
}
|
|
13
16
|
// Workflow state categories.
|
|
14
17
|
export var WorkflowCategory;
|
|
15
18
|
(function (WorkflowCategory) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/resource-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;
|
|
1
|
+
{"version":3,"file":"resource-interfaces.js","sourceRoot":"","sources":["../../src/interfaces/resource-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAgLF,MAAM,UAAU,YAAY,CAAC,GAAc;IACzC,OAAO,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC;AAC/B,CAAC;AAQD,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"}
|
package/dist/macros/common.d.ts
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
13
|
export declare const macroMetadata: {
|
|
14
|
-
createCards: import("../
|
|
15
|
-
graph: import("../
|
|
16
|
-
image: import("../
|
|
17
|
-
include: import("../
|
|
18
|
-
report: import("../
|
|
19
|
-
scoreCard: import("../
|
|
20
|
-
xref: import("../
|
|
21
|
-
percentage: import("../
|
|
22
|
-
vega: import("../
|
|
23
|
-
vegaLite: import("../
|
|
14
|
+
createCards: import("../index.js").MacroMetadata;
|
|
15
|
+
graph: import("../index.js").MacroMetadata;
|
|
16
|
+
image: import("../index.js").MacroMetadata;
|
|
17
|
+
include: import("../index.js").MacroMetadata;
|
|
18
|
+
report: import("../index.js").MacroMetadata;
|
|
19
|
+
scoreCard: import("../index.js").MacroMetadata;
|
|
20
|
+
xref: import("../index.js").MacroMetadata;
|
|
21
|
+
percentage: import("../index.js").MacroMetadata;
|
|
22
|
+
vega: import("../index.js").MacroMetadata;
|
|
23
|
+
vegaLite: import("../index.js").MacroMetadata;
|
|
24
24
|
};
|
|
@@ -12,19 +12,6 @@
|
|
|
12
12
|
import type { MacroGenerationContext } from '../../interfaces/macros.js';
|
|
13
13
|
import BaseMacro from '../base-macro.js';
|
|
14
14
|
import type TaskQueue from '../task-queue.js';
|
|
15
|
-
export interface CreateCardsOptions {
|
|
16
|
-
buttonLabel: string;
|
|
17
|
-
template: string;
|
|
18
|
-
cardKey?: string;
|
|
19
|
-
link?: {
|
|
20
|
-
linkType: string;
|
|
21
|
-
direction: string;
|
|
22
|
-
cardKey: string;
|
|
23
|
-
};
|
|
24
|
-
[key: string]: string | undefined | {
|
|
25
|
-
[key: string]: string | undefined;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
15
|
declare class CreateCardsMacro extends BaseMacro {
|
|
29
16
|
constructor(tasksQueue: TaskQueue);
|
|
30
17
|
handleValidate: (_: MacroGenerationContext, input: unknown) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/macros/createCards/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/macros/createCards/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI1E,OAAO,aAAa,MAAM,eAAe,CAAC;AAC1C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAGzC,MAAM,gBAAiB,SAAQ,SAAS;IACtC,YAAY,UAAqB;QAC/B,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,cAAc,GAAG,CAAC,CAAyB,EAAE,KAAc,EAAE,EAAE;QAC7D,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,KAAK,CAAC,YAAY;QAChB,0CAA0C;QAC1C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,YAAY,GAAG,KAAK,EAAE,CAAyB,EAAE,KAAc,EAAE,EAAE;QACjE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC,CAAC;IAEF,gBAAgB,GAAG,KAAK,IAAI,EAAE;QAC5B,2CAA2C;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IAEM,QAAQ,CAAC,KAAc;QAC7B,OAAO,oBAAoB,CAAqB,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
export interface CreateCardsOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Label of the button
|
|
17
|
+
*/
|
|
18
|
+
buttonLabel: string;
|
|
19
|
+
/**
|
|
20
|
+
* Template to create cards from
|
|
21
|
+
*/
|
|
22
|
+
template: string;
|
|
23
|
+
/**
|
|
24
|
+
* Allows forcing card creation under a certain card
|
|
25
|
+
*/
|
|
26
|
+
cardKey?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Allows creating a link at the same time
|
|
29
|
+
*/
|
|
30
|
+
link?: {
|
|
31
|
+
/**
|
|
32
|
+
* Type of the link to create
|
|
33
|
+
*/
|
|
34
|
+
linkType: string;
|
|
35
|
+
/**
|
|
36
|
+
* Direction of the link to create
|
|
37
|
+
*/
|
|
38
|
+
direction: string;
|
|
39
|
+
/**
|
|
40
|
+
* Card key of target card of the link
|
|
41
|
+
*/
|
|
42
|
+
cardKey: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/macros/createCards/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE"}
|
|
@@ -13,14 +13,10 @@
|
|
|
13
13
|
import BaseMacro from '../base-macro.js';
|
|
14
14
|
import type { MacroGenerationContext } from '../../interfaces/macros.js';
|
|
15
15
|
import type TaskQueue from '../task-queue.js';
|
|
16
|
-
|
|
17
|
-
model: string;
|
|
18
|
-
view: string;
|
|
19
|
-
}
|
|
20
|
-
declare class ReportMacro extends BaseMacro {
|
|
16
|
+
declare class GraphMacro extends BaseMacro {
|
|
21
17
|
constructor(tasksQueue: TaskQueue);
|
|
22
18
|
handleValidate: (context: MacroGenerationContext, input: unknown) => void;
|
|
23
19
|
handleStatic: (context: MacroGenerationContext, input: unknown) => Promise<string>;
|
|
24
20
|
private parseOptions;
|
|
25
21
|
}
|
|
26
|
-
export default
|
|
22
|
+
export default GraphMacro;
|
|
@@ -14,13 +14,8 @@ import BaseMacro from '../base-macro.js';
|
|
|
14
14
|
import { createImage, validateMacroContent } from '../index.js';
|
|
15
15
|
import Handlebars from 'handlebars';
|
|
16
16
|
import macroMetadata from './metadata.js';
|
|
17
|
-
import { pathExists } from '../../utils/file-utils.js';
|
|
18
|
-
import { readFile } from 'node:fs/promises';
|
|
19
|
-
import { readFileSync } from 'node:fs';
|
|
20
17
|
import { ClingoError } from '@cyberismo/node-clingo';
|
|
21
|
-
|
|
22
|
-
import { resourceName } from '../../utils/resource-utils.js';
|
|
23
|
-
class ReportMacro extends BaseMacro {
|
|
18
|
+
class GraphMacro extends BaseMacro {
|
|
24
19
|
constructor(tasksQueue) {
|
|
25
20
|
super(macroMetadata, tasksQueue);
|
|
26
21
|
}
|
|
@@ -29,28 +24,22 @@ class ReportMacro extends BaseMacro {
|
|
|
29
24
|
};
|
|
30
25
|
handleStatic = async (context, input) => {
|
|
31
26
|
const options = this.parseOptions(input, context);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
viewContent = await readFile(viewLocation, { encoding: 'utf-8' });
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
throw new Error(`Graph: View ${options.view} does not exist`);
|
|
27
|
+
const modelResource = context.project.resources.byType(options.model, 'graphModels');
|
|
28
|
+
const modelContent = modelResource.contentData();
|
|
29
|
+
const viewResource = context.project.resources.byType(options.view, 'graphViews');
|
|
30
|
+
const viewContent = viewResource.contentData();
|
|
31
|
+
if (!viewContent.viewTemplate) {
|
|
32
|
+
throw new Error(`Graph: View ${options.view} has no view template`);
|
|
43
33
|
}
|
|
44
34
|
const handlebarsContext = {
|
|
45
35
|
cardKey: context.cardKey,
|
|
46
36
|
...options,
|
|
47
37
|
};
|
|
48
38
|
const handlebars = Handlebars.create();
|
|
49
|
-
const view = handlebars.compile(viewContent)(handlebarsContext);
|
|
50
|
-
const modelContent = await readFile(modelLocation, { encoding: 'utf-8' });
|
|
39
|
+
const view = handlebars.compile(viewContent.viewTemplate)(handlebarsContext);
|
|
51
40
|
let result;
|
|
52
41
|
try {
|
|
53
|
-
result = await context.project.calculationEngine.runGraph(modelContent, view, context.context);
|
|
42
|
+
result = await context.project.calculationEngine.runGraph(modelContent.model, view, context.context);
|
|
54
43
|
}
|
|
55
44
|
catch (error) {
|
|
56
45
|
if (error instanceof ClingoError) {
|
|
@@ -65,18 +54,15 @@ class ReportMacro extends BaseMacro {
|
|
|
65
54
|
};
|
|
66
55
|
parseOptions(input, context) {
|
|
67
56
|
const options = validateMacroContent(this.metadata, input);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
catch (err) {
|
|
73
|
-
this.logger.trace(err, 'Graph schema not found or failed to read, skipping validation');
|
|
74
|
-
}
|
|
57
|
+
// Get schema from view resource content if available
|
|
58
|
+
const resource = context.project.resources.byType(options.view, 'graphViews');
|
|
59
|
+
const content = resource.contentData();
|
|
60
|
+
const schema = content.schema;
|
|
75
61
|
if (schema) {
|
|
76
62
|
validateMacroContent(this.metadata, input, schema);
|
|
77
63
|
}
|
|
78
64
|
return options;
|
|
79
65
|
}
|
|
80
66
|
}
|
|
81
|
-
export default
|
|
67
|
+
export default GraphMacro;
|
|
82
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -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,WAAW,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,UAAU,MAAM,YAAY,CAAC;
|
|
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,WAAW,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,aAAa,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAMrD,MAAM,UAAW,SAAQ,SAAS;IAChC,YAAY,UAAqB;QAC/B,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,cAAc,GAAG,CAAC,OAA+B,EAAE,KAAc,EAAE,EAAE;QACnE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC;IAEF,YAAY,GAAG,K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,IAAI,CAAC,EAAE,CAChH,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;QACJ,CAAC;QACD,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEM,YAAY,CAClB,KAAc,EACd,OAA+B;QAE/B,MAAM,OAAO,GAAG,oBAAoB,CAAe,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAEzE,qDAAqD;QACrD,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAC/C,OAAO,CAAC,IAAI,EACZ,YAAY,CACb,CAAC;QACF,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAE9B,IAAI,MAAM,EAAE,CAAC;YACX,oBAAoB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export interface GraphOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Reference to the model that defines graph
|
|
17
|
+
*/
|
|
18
|
+
model: string;
|
|
19
|
+
/**
|
|
20
|
+
* Reference to the view that defines the graph
|
|
21
|
+
*/
|
|
22
|
+
view: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/macros/graph/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE"}
|
|
@@ -10,30 +10,22 @@
|
|
|
10
10
|
details. You should have received a copy of the GNU Affero General Public
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
|
-
import type { MacroGenerationContext } from '../../interfaces/macros.js';
|
|
14
13
|
import BaseMacro from '../base-macro.js';
|
|
14
|
+
import type { MacroGenerationContext } from '../../interfaces/macros.js';
|
|
15
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
16
|
/**
|
|
30
17
|
* Macro for including images in the content
|
|
31
18
|
*/
|
|
32
19
|
export default class ImageMacro extends BaseMacro {
|
|
20
|
+
/**
|
|
21
|
+
* Constructs ImageMacro instance.
|
|
22
|
+
* @param tasksQueue Tasks queue
|
|
23
|
+
*/
|
|
33
24
|
constructor(tasksQueue: TaskQueue);
|
|
25
|
+
private attachment;
|
|
26
|
+
private buildImageAttributes;
|
|
27
|
+
private validate;
|
|
34
28
|
handleValidate: (_: MacroGenerationContext, input: unknown) => void;
|
|
35
29
|
handleStatic: (context: MacroGenerationContext, input: unknown) => Promise<string>;
|
|
36
30
|
handleInject: (context: MacroGenerationContext, input: unknown) => Promise<string>;
|
|
37
|
-
private buildImageAttributes;
|
|
38
|
-
private validate;
|
|
39
31
|
}
|
|
@@ -10,67 +10,70 @@
|
|
|
10
10
|
details. You should have received a copy of the GNU Affero General Public
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { readFileSync } from 'node:fs';
|
|
14
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
15
|
import BaseMacro from '../base-macro.js';
|
|
16
|
+
import macroMetadata from './metadata.js';
|
|
17
|
+
import { validateMacroContent } from '../index.js';
|
|
19
18
|
/**
|
|
20
19
|
* Macro for including images in the content
|
|
21
20
|
*/
|
|
22
21
|
export default class ImageMacro extends BaseMacro {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs ImageMacro instance.
|
|
24
|
+
* @param tasksQueue Tasks queue
|
|
25
|
+
*/
|
|
23
26
|
constructor(tasksQueue) {
|
|
24
27
|
super(macroMetadata, tasksQueue);
|
|
25
28
|
}
|
|
29
|
+
// Gets card attachment.
|
|
30
|
+
attachment(context, cardKey, filename) {
|
|
31
|
+
const card = context.project.findCard(cardKey);
|
|
32
|
+
const attachment = card.attachments?.find((a) => a.fileName === filename) ?? undefined;
|
|
33
|
+
if (!attachment) {
|
|
34
|
+
throw new Error(`Attachment file '${filename}' not found in card '${cardKey}'`);
|
|
35
|
+
}
|
|
36
|
+
return attachment;
|
|
37
|
+
}
|
|
38
|
+
buildImageAttributes(options) {
|
|
39
|
+
const attributes = [];
|
|
40
|
+
if (options.alt !== undefined) {
|
|
41
|
+
attributes.push(`alt="${options.alt}"`);
|
|
42
|
+
}
|
|
43
|
+
if (options.title !== undefined) {
|
|
44
|
+
attributes.push(`title="${options.title}"`);
|
|
45
|
+
}
|
|
46
|
+
return attributes.join(',');
|
|
47
|
+
}
|
|
48
|
+
validate(input) {
|
|
49
|
+
return validateMacroContent(this.metadata, input);
|
|
50
|
+
}
|
|
26
51
|
handleValidate = (_, input) => {
|
|
27
52
|
this.validate(input);
|
|
28
53
|
};
|
|
29
54
|
handleStatic = async (context, input) => {
|
|
30
55
|
const options = this.validate(input);
|
|
31
56
|
const cardKey = options.cardKey || context.cardKey;
|
|
32
|
-
// Get the attachment
|
|
33
|
-
const
|
|
34
|
-
//
|
|
35
|
-
const attachmentPath = join(
|
|
36
|
-
if (!existsSync(attachmentPath)) {
|
|
37
|
-
throw new Error(`Attachment file '${options.fileName}' not found in card '${cardKey}'`);
|
|
38
|
-
}
|
|
57
|
+
// Get the attachment
|
|
58
|
+
const cardAttachment = this.attachment(context, cardKey, options.fileName);
|
|
59
|
+
// Convert to base64
|
|
60
|
+
const attachmentPath = join(cardAttachment?.path, cardAttachment?.fileName);
|
|
39
61
|
const fileBuffer = readFileSync(attachmentPath);
|
|
40
62
|
const base64Data = fileBuffer.toString('base64');
|
|
41
|
-
// Get mime type
|
|
42
|
-
const mimeType = mime.lookup(attachmentPath) || 'application/octet-stream';
|
|
43
63
|
// Build image attributes
|
|
44
64
|
const attributes = this.buildImageAttributes(options);
|
|
45
65
|
// Return as data URI for static mode (for export/PDF generation)
|
|
46
|
-
return `image::data:${mimeType};base64,${base64Data}[${attributes}]`;
|
|
66
|
+
return `image::data:${cardAttachment.mimeType};base64,${base64Data}[${attributes}]`;
|
|
47
67
|
};
|
|
48
68
|
handleInject = async (context, input) => {
|
|
49
69
|
const options = this.validate(input);
|
|
50
70
|
const cardKey = options.cardKey || context.cardKey;
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
const attachmentPath = join(attachmentFolder, options.fileName);
|
|
54
|
-
if (!existsSync(attachmentPath)) {
|
|
55
|
-
throw new Error(`Attachment file '${options.fileName}' not found in card '${cardKey}'`);
|
|
56
|
-
}
|
|
71
|
+
// Just verify that the attachment exists.
|
|
72
|
+
this.attachment(context, cardKey, options.fileName);
|
|
57
73
|
// Build image attributes
|
|
58
74
|
const attributes = this.buildImageAttributes(options);
|
|
59
75
|
// In inject mode, always use the API path for consistency
|
|
60
76
|
return `image::/api/cards/${cardKey}/a/${options.fileName}[${attributes}]`;
|
|
61
77
|
};
|
|
62
|
-
buildImageAttributes(options) {
|
|
63
|
-
const attributes = [];
|
|
64
|
-
if (options.alt !== undefined) {
|
|
65
|
-
attributes.push(`alt="${options.alt}"`);
|
|
66
|
-
}
|
|
67
|
-
if (options.title !== undefined) {
|
|
68
|
-
attributes.push(`title="${options.title}"`);
|
|
69
|
-
}
|
|
70
|
-
return attributes.join(',');
|
|
71
|
-
}
|
|
72
|
-
validate(input) {
|
|
73
|
-
return validateMacroContent(this.metadata, input);
|
|
74
|
-
}
|
|
75
78
|
}
|
|
76
79
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/macros/image/index.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G,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;QAEnD,0CAA0C;QAC1C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEpD,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;CACH"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
* Options for the image macro.
|
|
16
|
+
* @param fileName - Name of the file to include.
|
|
17
|
+
* @param cardKey - Key of the card to include the file from.
|
|
18
|
+
* @param alt - Alternative text for the image.
|
|
19
|
+
* @param title - Title of the image.
|
|
20
|
+
*/
|
|
21
|
+
export interface ImageMacroOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Filename of the image
|
|
24
|
+
*/
|
|
25
|
+
fileName: string;
|
|
26
|
+
/**
|
|
27
|
+
* By default, image is assumed to be under the current card. You can override this behaviour
|
|
28
|
+
*/
|
|
29
|
+
cardKey?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Alt text
|
|
32
|
+
*/
|
|
33
|
+
alt?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Title for the image
|
|
36
|
+
*/
|
|
37
|
+
title?: string;
|
|
38
|
+
}
|