@cyberismo/data-handler 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card-metadata-updater.js +1 -3
- package/dist/card-metadata-updater.js.map +1 -1
- package/dist/command-handler.js +13 -17
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +1 -1
- package/dist/command-manager.js +4 -3
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/create.d.ts +3 -3
- package/dist/commands/create.js +20 -81
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/edit.d.ts +12 -25
- package/dist/commands/edit.js +25 -74
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.js +4 -17
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/fetch.js +2 -1
- package/dist/commands/fetch.js.map +1 -1
- package/dist/commands/import.js +3 -5
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/move.d.ts +1 -2
- package/dist/commands/move.js +108 -146
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.js +15 -49
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.d.ts +1 -0
- package/dist/commands/rename.js +13 -7
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +7 -25
- package/dist/commands/show.js +39 -113
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.js +27 -30
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.d.ts +5 -3
- package/dist/commands/update.js +19 -5
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.d.ts +3 -3
- package/dist/commands/validate.js +20 -27
- 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 +6 -0
- package/dist/containers/project/calculation-engine.js +36 -29
- 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/resource-collector.d.ts +24 -1
- package/dist/containers/project/resource-collector.js +8 -1
- package/dist/containers/project/resource-collector.js.map +1 -1
- package/dist/containers/project.d.ts +119 -84
- package/dist/containers/project.js +423 -253
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.d.ts +15 -31
- package/dist/containers/template.js +97 -104
- 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 +12 -5
- package/dist/interfaces/folder-content-interfaces.js +5 -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 +16 -10
- package/dist/interfaces/project-interfaces.js +10 -8
- package/dist/interfaces/project-interfaces.js.map +1 -1
- package/dist/interfaces/resource-interfaces.d.ts +21 -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 +2 -2
- 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/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.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.js +4 -4
- package/dist/module-manager.js.map +1 -1
- package/dist/project-settings.js.map +1 -1
- package/dist/resources/calculation-resource.d.ts +43 -0
- package/dist/resources/calculation-resource.js +75 -0
- package/dist/resources/calculation-resource.js.map +1 -0
- package/dist/resources/card-type-resource.d.ts +4 -21
- package/dist/resources/card-type-resource.js +13 -44
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/create-defaults.d.ts +13 -6
- package/dist/resources/create-defaults.js +19 -5
- package/dist/resources/create-defaults.js.map +1 -1
- package/dist/resources/field-type-resource.d.ts +4 -21
- package/dist/resources/field-type-resource.js +14 -38
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.d.ts +12 -29
- package/dist/resources/file-resource.js +19 -287
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +32 -51
- package/dist/resources/folder-resource.js +68 -96
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +5 -33
- package/dist/resources/graph-model-resource.js +8 -61
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +5 -28
- package/dist/resources/graph-view-resource.js +6 -45
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.d.ts +4 -21
- package/dist/resources/link-type-resource.js +6 -31
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +5 -17
- package/dist/resources/report-resource.js +6 -44
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +58 -23
- package/dist/resources/resource-object.js +307 -26
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +4 -15
- package/dist/resources/template-resource.js +10 -25
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +4 -23
- package/dist/resources/workflow-resource.js +12 -38
- 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-facts.js +11 -3
- 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 +5 -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/error-utils.d.ts +34 -0
- package/dist/utils/error-utils.js +56 -0
- package/dist/utils/error-utils.js.map +1 -0
- package/dist/utils/log-utils.d.ts +0 -27
- package/dist/utils/log-utils.js +0 -58
- package/dist/utils/log-utils.js.map +1 -1
- package/dist/utils/user-preferences.js +6 -3
- package/dist/utils/user-preferences.js.map +1 -1
- package/package.json +5 -5
- package/src/card-metadata-updater.ts +3 -5
- package/src/command-handler.ts +14 -19
- package/src/command-manager.ts +4 -3
- package/src/commands/create.ts +28 -112
- package/src/commands/edit.ts +27 -118
- package/src/commands/export.ts +8 -29
- package/src/commands/fetch.ts +2 -1
- package/src/commands/import.ts +4 -6
- package/src/commands/move.ts +144 -179
- package/src/commands/remove.ts +12 -54
- package/src/commands/rename.ts +22 -7
- package/src/commands/show.ts +51 -156
- package/src/commands/transition.ts +30 -33
- package/src/commands/update.ts +27 -9
- package/src/commands/validate.ts +22 -37
- package/src/containers/card-container.ts +200 -360
- package/src/containers/project/calculation-engine.ts +43 -33
- package/src/containers/project/card-cache.ts +497 -0
- package/src/containers/project/resource-collector.ts +9 -1
- package/src/containers/project.ts +533 -328
- package/src/containers/template.ts +109 -127
- package/src/index.ts +1 -0
- package/src/interfaces/folder-content-interfaces.ts +23 -5
- package/src/interfaces/macros.ts +2 -0
- package/src/interfaces/project-interfaces.ts +19 -10
- package/src/interfaces/resource-interfaces.ts +22 -24
- package/src/macros/createCards/index.ts +1 -12
- package/src/macros/createCards/types.ts +46 -0
- package/src/macros/graph/index.ts +3 -7
- 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/percentage/index.ts +1 -7
- package/src/macros/percentage/types.ts +32 -0
- package/src/macros/report/index.ts +1 -4
- 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 +5 -5
- package/src/project-settings.ts +1 -1
- package/src/resources/calculation-resource.ts +101 -0
- package/src/resources/card-type-resource.ts +24 -59
- package/src/resources/create-defaults.ts +21 -5
- package/src/resources/field-type-resource.ts +22 -51
- package/src/resources/file-resource.ts +27 -403
- package/src/resources/folder-resource.ts +99 -125
- package/src/resources/graph-model-resource.ts +17 -74
- package/src/resources/graph-view-resource.ts +14 -54
- package/src/resources/link-type-resource.ts +13 -40
- package/src/resources/report-resource.ts +17 -57
- package/src/resources/resource-object.ts +454 -39
- package/src/resources/template-resource.ts +16 -29
- package/src/resources/workflow-resource.ts +26 -50
- package/src/utils/card-utils.ts +217 -31
- package/src/utils/clingo-facts.ts +13 -3
- package/src/utils/clingo-parser.ts +1 -1
- package/src/utils/constants.ts +7 -0
- package/src/utils/csv.ts +1 -1
- package/src/utils/error-utils.ts +62 -0
- package/src/utils/log-utils.ts +0 -68
- package/src/utils/user-preferences.ts +7 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-view-resource.js","sourceRoot":"","sources":["../../src/resources/graph-view-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQ1C,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB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AM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAsB,CAAC;YACnE,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,EAAE,CAAW,CAAC;YAEpD,MAAM,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;YAC/C,OAAO;QACT,CAAC;QAED,MAAM,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,KAAK,CAAC,KAAc;QAC/B,MAAM,QAAQ,GAAG,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QACxC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACtD,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;YACrB,KAAK,CAAC,YAAY,EAAE;SACrB,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { Card, Operation, Project, ResourceName } from './file-resource.js';
|
|
13
13
|
import { FileResource } from './folder-resource.js';
|
|
14
|
-
import type { LinkType } from '../interfaces/resource-interfaces.js';
|
|
14
|
+
import type { LinkType, UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
15
15
|
/**
|
|
16
16
|
* Link Type resource class.
|
|
17
17
|
*/
|
|
18
|
-
export declare class LinkTypeResource extends FileResource {
|
|
18
|
+
export declare class LinkTypeResource extends FileResource<LinkType> {
|
|
19
19
|
constructor(project: Project, name: ResourceName);
|
|
20
20
|
private handleNameChange;
|
|
21
21
|
/**
|
|
@@ -23,30 +23,17 @@ export declare class LinkTypeResource extends FileResource {
|
|
|
23
23
|
* @param newContent Content for the link type.
|
|
24
24
|
*/
|
|
25
25
|
create(newContent?: LinkType): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Returns content data.
|
|
28
|
-
*/
|
|
29
|
-
get data(): LinkType;
|
|
30
|
-
/**
|
|
31
|
-
* Deletes file(s) from disk and clears out the memory resident object.
|
|
32
|
-
*/
|
|
33
|
-
delete(): Promise<void>;
|
|
34
26
|
/**
|
|
35
27
|
* Renames resource metadata file and renames memory resident object 'name'.
|
|
36
28
|
* @param newName New name for the resource.
|
|
37
29
|
*/
|
|
38
30
|
rename(newName: ResourceName): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Shows metadata of the resource.
|
|
41
|
-
* @returns link type metadata.
|
|
42
|
-
*/
|
|
43
|
-
show(): Promise<LinkType>;
|
|
44
31
|
/**
|
|
45
32
|
* Updates link type resource.
|
|
46
|
-
* @param
|
|
33
|
+
* @param updateKey Key to modify
|
|
47
34
|
* @param op Operation to perform on 'key'
|
|
48
35
|
*/
|
|
49
|
-
update<Type>(
|
|
36
|
+
update<Type, K extends string>(updateKey: UpdateKey<K>, op: Operation<Type>): Promise<void>;
|
|
50
37
|
/**
|
|
51
38
|
* List where link type is used.
|
|
52
39
|
* Always returns card key references first, then calculation references.
|
|
@@ -55,8 +42,4 @@ export declare class LinkTypeResource extends FileResource {
|
|
|
55
42
|
* @returns array of card keys calculation filenames that refer this resource.
|
|
56
43
|
*/
|
|
57
44
|
usage(cards?: Card[]): Promise<string[]>;
|
|
58
|
-
/**
|
|
59
|
-
* Validates the resource. If object is invalid, throws.
|
|
60
|
-
*/
|
|
61
|
-
validate(content?: object): Promise<void>;
|
|
62
45
|
}
|
|
@@ -18,7 +18,6 @@ export class LinkTypeResource extends FileResource {
|
|
|
18
18
|
super(project, name, 'linkTypes');
|
|
19
19
|
this.contentSchemaId = 'linkTypeSchema';
|
|
20
20
|
this.contentSchema = super.contentSchemaContent(this.contentSchemaId);
|
|
21
|
-
this.initialize();
|
|
22
21
|
}
|
|
23
22
|
// When resource name changes.
|
|
24
23
|
async handleNameChange(existingName) {
|
|
@@ -50,18 +49,6 @@ export class LinkTypeResource extends FileResource {
|
|
|
50
49
|
}
|
|
51
50
|
return super.create(newContent);
|
|
52
51
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Returns content data.
|
|
55
|
-
*/
|
|
56
|
-
get data() {
|
|
57
|
-
return super.data;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Deletes file(s) from disk and clears out the memory resident object.
|
|
61
|
-
*/
|
|
62
|
-
async delete() {
|
|
63
|
-
return super.delete();
|
|
64
|
-
}
|
|
65
52
|
/**
|
|
66
53
|
* Renames resource metadata file and renames memory resident object 'name'.
|
|
67
54
|
* @param newName New name for the resource.
|
|
@@ -71,22 +58,16 @@ export class LinkTypeResource extends FileResource {
|
|
|
71
58
|
await super.rename(newName);
|
|
72
59
|
return this.handleNameChange(existingName);
|
|
73
60
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Shows metadata of the resource.
|
|
76
|
-
* @returns link type metadata.
|
|
77
|
-
*/
|
|
78
|
-
async show() {
|
|
79
|
-
return super.show();
|
|
80
|
-
}
|
|
81
61
|
/**
|
|
82
62
|
* Updates link type resource.
|
|
83
|
-
* @param
|
|
63
|
+
* @param updateKey Key to modify
|
|
84
64
|
* @param op Operation to perform on 'key'
|
|
85
65
|
*/
|
|
86
|
-
async update(
|
|
66
|
+
async update(updateKey, op) {
|
|
67
|
+
const { key } = updateKey;
|
|
87
68
|
const nameChange = key === 'name';
|
|
88
69
|
const existingName = this.content.name;
|
|
89
|
-
await super.update(
|
|
70
|
+
await super.update(updateKey, op);
|
|
90
71
|
const content = structuredClone(this.content);
|
|
91
72
|
if (key === 'name') {
|
|
92
73
|
content.name = super.handleScalar(op);
|
|
@@ -109,7 +90,7 @@ export class LinkTypeResource extends FileResource {
|
|
|
109
90
|
else {
|
|
110
91
|
throw new Error(`Unknown property '${key}' for FieldType`);
|
|
111
92
|
}
|
|
112
|
-
await super.postUpdate(content,
|
|
93
|
+
await super.postUpdate(content, updateKey, op);
|
|
113
94
|
// Renaming this card type causes that references to its name must be updated.
|
|
114
95
|
if (nameChange) {
|
|
115
96
|
await this.handleNameChange(existingName);
|
|
@@ -124,7 +105,7 @@ export class LinkTypeResource extends FileResource {
|
|
|
124
105
|
*/
|
|
125
106
|
async usage(cards) {
|
|
126
107
|
const resourceName = resourceNameToString(this.resourceName);
|
|
127
|
-
const allCards = cards ||
|
|
108
|
+
const allCards = cards || super.cards();
|
|
128
109
|
const cardsThatUseLinkType = allCards
|
|
129
110
|
.filter((card) => card.metadata?.links.find((item) => item.linkType === resourceName))
|
|
130
111
|
.filter(Boolean)
|
|
@@ -140,11 +121,5 @@ export class LinkTypeResource extends FileResource {
|
|
|
140
121
|
// Using Set to avoid duplicate cards
|
|
141
122
|
return [...new Set([...cardReferences, ...calculations])];
|
|
142
123
|
}
|
|
143
|
-
/**
|
|
144
|
-
* Validates the resource. If object is invalid, throws.
|
|
145
|
-
*/
|
|
146
|
-
async validate(content) {
|
|
147
|
-
return super.validate(content);
|
|
148
|
-
}
|
|
149
124
|
}
|
|
150
125
|
//# sourceMappingURL=link-type-resource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-type-resource.js","sourceRoot":"","sources":["../../src/resources/link-type-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAQF,OAAO,EACL,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,
|
|
1
|
+
{"version":3,"file":"link-type-resource.js","sourceRoot":"","sources":["../../src/resources/link-type-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAQF,OAAO,EACL,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAsB;IAC1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CAAC;QAE3B,MAAM,CAAC,qBAAqB,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC9D,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;YACrB,KAAK,CAAC,YAAY,EAAE;SACrB,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG;YACrB,GAAG,oBAAoB;YACvB,GAAG,qBAAqB;SACzB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAElB,qCAAqC;QACrC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { FolderResource } from './folder-resource.js';
|
|
15
15
|
import type { Card, Operation, Project, ResourceName } from './folder-resource.js';
|
|
16
|
-
import
|
|
16
|
+
import { type ReportMetadata, type UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
17
|
+
import type { ReportContent } from '../interfaces/folder-content-interfaces.js';
|
|
17
18
|
/**
|
|
18
19
|
* Report resource class.
|
|
19
20
|
*/
|
|
20
|
-
export declare class ReportResource extends FolderResource {
|
|
21
|
+
export declare class ReportResource extends FolderResource<ReportMetadata, ReportContent> {
|
|
21
22
|
private reportSchema;
|
|
22
23
|
constructor(project: Project, name: ResourceName);
|
|
23
24
|
private defaultReportLocation;
|
|
@@ -33,14 +34,6 @@ export declare class ReportResource extends FolderResource {
|
|
|
33
34
|
* @throws if 'newContent' is not valid.
|
|
34
35
|
*/
|
|
35
36
|
createReport(): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Returns resource content.
|
|
38
|
-
*/
|
|
39
|
-
get data(): ReportMetadata;
|
|
40
|
-
/**
|
|
41
|
-
* Deletes file and folder that this resource is based on.
|
|
42
|
-
*/
|
|
43
|
-
delete(): Promise<void>;
|
|
44
37
|
/**
|
|
45
38
|
* Returns list of handlebar filenames that this report has.
|
|
46
39
|
* @returns list of handlebar filenames that this report has.
|
|
@@ -51,17 +44,12 @@ export declare class ReportResource extends FolderResource {
|
|
|
51
44
|
* @param newName New name for the resource.
|
|
52
45
|
*/
|
|
53
46
|
rename(newName: ResourceName): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Shows metadata of the resource.
|
|
56
|
-
* @returns report metadata.
|
|
57
|
-
*/
|
|
58
|
-
show(): Promise<Report>;
|
|
59
47
|
/**
|
|
60
48
|
* Updates report resource.
|
|
61
|
-
* @param
|
|
49
|
+
* @param updateKey Key to modify
|
|
62
50
|
* @param op Operation to perform on 'key'
|
|
63
51
|
*/
|
|
64
|
-
update<Type>(
|
|
52
|
+
update<Type, K extends string>(updateKey: UpdateKey<K>, op: Operation<Type>): Promise<void>;
|
|
65
53
|
/**
|
|
66
54
|
* List where this resource is used.
|
|
67
55
|
* Always returns card key references first, then calculation references.
|
|
@@ -17,7 +17,6 @@ import { extname, join } from 'node:path';
|
|
|
17
17
|
import { copyDir } from '../utils/file-utils.js';
|
|
18
18
|
import { DefaultContent, FolderResource, resourceNameToString, sortCards, } from './folder-resource.js';
|
|
19
19
|
import { getStaticDirectoryPath } from '@cyberismo/assets';
|
|
20
|
-
import { filename } from '../interfaces/folder-content-interfaces.js';
|
|
21
20
|
import { Validate } from '../commands/validate.js';
|
|
22
21
|
const REPORT_SCHEMA_FILE = 'parameterSchema.json';
|
|
23
22
|
const PARAMETER_SCHEMA_ID = 'jsonSchema';
|
|
@@ -31,7 +30,6 @@ export class ReportResource extends FolderResource {
|
|
|
31
30
|
super(project, name, 'reports');
|
|
32
31
|
this.contentSchemaId = 'reportSchema';
|
|
33
32
|
this.contentSchema = super.contentSchemaContent(this.contentSchemaId);
|
|
34
|
-
this.initialize();
|
|
35
33
|
const schemaPath = join(this.internalFolder, REPORT_SCHEMA_FILE);
|
|
36
34
|
this.reportSchema = this.readSchemaFile(schemaPath);
|
|
37
35
|
}
|
|
@@ -71,18 +69,6 @@ export class ReportResource extends FolderResource {
|
|
|
71
69
|
// Copy report default structure to destination.
|
|
72
70
|
await copyDir(this.defaultReportLocation, this.internalFolder);
|
|
73
71
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Returns resource content.
|
|
76
|
-
*/
|
|
77
|
-
get data() {
|
|
78
|
-
return super.data;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Deletes file and folder that this resource is based on.
|
|
82
|
-
*/
|
|
83
|
-
async delete() {
|
|
84
|
-
return super.delete();
|
|
85
|
-
}
|
|
86
72
|
/**
|
|
87
73
|
* Returns list of handlebar filenames that this report has.
|
|
88
74
|
* @returns list of handlebar filenames that this report has.
|
|
@@ -104,43 +90,19 @@ export class ReportResource extends FolderResource {
|
|
|
104
90
|
await super.rename(newName);
|
|
105
91
|
return this.onNameChange(existingName);
|
|
106
92
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Shows metadata of the resource.
|
|
109
|
-
* @returns report metadata.
|
|
110
|
-
*/
|
|
111
|
-
async show() {
|
|
112
|
-
const baseData = (await super.show());
|
|
113
|
-
const fileContents = await super.contentData();
|
|
114
|
-
const content = {
|
|
115
|
-
contentTemplate: fileContents.contentTemplate,
|
|
116
|
-
queryTemplate: fileContents.queryTemplate,
|
|
117
|
-
schema: fileContents.schema ? fileContents.schema : undefined,
|
|
118
|
-
};
|
|
119
|
-
return {
|
|
120
|
-
...baseData,
|
|
121
|
-
content: content,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
93
|
/**
|
|
125
94
|
* Updates report resource.
|
|
126
|
-
* @param
|
|
95
|
+
* @param updateKey Key to modify
|
|
127
96
|
* @param op Operation to perform on 'key'
|
|
128
97
|
*/
|
|
129
|
-
async update(
|
|
130
|
-
if (
|
|
131
|
-
key.key === 'content' &&
|
|
132
|
-
key.subKey === 'schema') {
|
|
133
|
-
const fileContent = JSON.stringify(super.handleScalar(op), null, 2);
|
|
134
|
-
await this.updateFile(filename(key.subKey), fileContent);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (key === 'category') {
|
|
98
|
+
async update(updateKey, op) {
|
|
99
|
+
if (updateKey.key === 'category') {
|
|
138
100
|
const content = structuredClone(this.content);
|
|
139
101
|
content.category = super.handleScalar(op);
|
|
140
|
-
await super.postUpdate(content,
|
|
102
|
+
await super.postUpdate(content, updateKey, op);
|
|
141
103
|
return;
|
|
142
104
|
}
|
|
143
|
-
await super.update(
|
|
105
|
+
await super.update(updateKey, op);
|
|
144
106
|
}
|
|
145
107
|
/**
|
|
146
108
|
* List where this resource is used.
|
|
@@ -150,7 +112,7 @@ export class ReportResource extends FolderResource {
|
|
|
150
112
|
* @returns array of card keys and calculation filenames that refer this resource.
|
|
151
113
|
*/
|
|
152
114
|
async usage(cards) {
|
|
153
|
-
const allCards = cards ??
|
|
115
|
+
const allCards = cards ?? super.cards();
|
|
154
116
|
const [relevantCards, calculations] = await Promise.all([
|
|
155
117
|
super.usage(allCards),
|
|
156
118
|
super.calculations(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-resource.js","sourceRoot":"","sources":["../../src/resources/report-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"report-resource.js","sourceRoot":"","sources":["../../src/resources/report-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE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mBAAmB,CACpB,CAAC;YACF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,EAAE,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { Card, ResourceFolderType } from '../interfaces/project-interfaces.js';
|
|
13
13
|
import type { Logger } from 'pino';
|
|
14
|
-
import {
|
|
15
|
-
import type {
|
|
16
|
-
import type
|
|
14
|
+
import type { Project } from '../containers/project.js';
|
|
15
|
+
import type { ResourceBaseMetadata, UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
16
|
+
import { type ResourceName } from '../utils/resource-utils.js';
|
|
17
17
|
export type UpdateOperations = 'add' | 'change' | 'rank' | 'remove';
|
|
18
18
|
type BaseOperation<T> = {
|
|
19
19
|
name: 'add' | 'change' | 'rank' | 'remove';
|
|
@@ -45,53 +45,64 @@ export type OperationMap<T> = {
|
|
|
45
45
|
remove: RemoveOperation<T>;
|
|
46
46
|
};
|
|
47
47
|
export type OperationFor<T, N extends UpdateOperations> = OperationMap<T>[N];
|
|
48
|
+
export type ShowReturnType<T extends ResourceBaseMetadata, U = never> = Omit<T, 'content'> & {
|
|
49
|
+
[K in 'content' as [U] extends [never] ? never : K]: U;
|
|
50
|
+
};
|
|
48
51
|
/**
|
|
49
52
|
* Abstract class for resources.
|
|
50
53
|
*/
|
|
51
|
-
export declare abstract class AbstractResource {
|
|
54
|
+
export declare abstract class AbstractResource<T extends ResourceBaseMetadata, U = never> {
|
|
52
55
|
protected abstract calculate(): Promise<void>;
|
|
53
|
-
protected abstract create(content?:
|
|
56
|
+
protected abstract create(content?: T): Promise<void>;
|
|
54
57
|
protected abstract delete(): Promise<void>;
|
|
55
58
|
protected abstract read(): Promise<void>;
|
|
56
59
|
protected abstract rename(newName: ResourceName): Promise<void>;
|
|
57
|
-
protected abstract show(): Promise<
|
|
58
|
-
protected abstract update<Type>(
|
|
60
|
+
protected abstract show(): Promise<ShowReturnType<T, U>>;
|
|
61
|
+
protected abstract update<Type, K extends string>(updateKey: UpdateKey<K>, operation: Operation<Type>): Promise<void>;
|
|
59
62
|
protected abstract usage(cards?: Card[]): Promise<string[]>;
|
|
60
63
|
protected abstract validate(content?: object): Promise<void>;
|
|
61
64
|
protected abstract write(): Promise<void>;
|
|
62
65
|
protected abstract get getType(): string;
|
|
63
66
|
protected abstract getLogger(loggerName: string): Logger;
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
* Base class for all resources.
|
|
67
|
-
*/
|
|
68
|
-
export declare class ResourceObject extends AbstractResource {
|
|
68
|
+
export declare abstract class ResourceObject<T extends ResourceBaseMetadata, U> extends AbstractResource<T, U> {
|
|
69
69
|
protected project: Project;
|
|
70
70
|
protected resourceName: ResourceName;
|
|
71
|
+
private cache;
|
|
72
|
+
private static validateInstancePromise?;
|
|
73
|
+
protected content: T;
|
|
71
74
|
protected moduleResource: boolean;
|
|
72
75
|
protected contentSchema: JSON;
|
|
73
76
|
protected contentSchemaId: string;
|
|
74
77
|
protected type: ResourceFolderType;
|
|
75
78
|
protected resourceFolder: string;
|
|
76
|
-
|
|
79
|
+
protected logger: Logger;
|
|
80
|
+
/**
|
|
81
|
+
* Path to the resource metadata file (the .json file).
|
|
82
|
+
*/
|
|
83
|
+
fileName: string;
|
|
84
|
+
constructor(project: Project, resourceName: ResourceName, type: ResourceFolderType);
|
|
85
|
+
private static getValidate;
|
|
86
|
+
private resourceObjectToResource;
|
|
87
|
+
private resourceType;
|
|
88
|
+
private toCache;
|
|
89
|
+
/**
|
|
90
|
+
* Checks if resource exists
|
|
91
|
+
* @throws if resource does not exist
|
|
92
|
+
*/
|
|
93
|
+
protected assertResourceExists(): void;
|
|
77
94
|
protected calculate(): Promise<void>;
|
|
78
|
-
protected
|
|
79
|
-
protected
|
|
80
|
-
protected read(): Promise<void>;
|
|
81
|
-
protected rename(_name: ResourceName): Promise<void>;
|
|
82
|
-
protected show(): Promise<ResourceContent>;
|
|
83
|
-
protected get getType(): string;
|
|
84
|
-
protected getLogger(loggerName: string): Logger;
|
|
85
|
-
protected update<Type>(_key: string, _op: Operation<Type>): Promise<void>;
|
|
86
|
-
protected usage(_cards?: Card[]): Promise<string[]>;
|
|
87
|
-
protected validate(_content?: object): Promise<void>;
|
|
88
|
-
protected write(): Promise<void>;
|
|
95
|
+
protected calculations(): Promise<string[]>;
|
|
96
|
+
protected cards(): Card[];
|
|
89
97
|
/**
|
|
90
98
|
* Returns .schema content file.
|
|
91
99
|
* @param schemaId schema id
|
|
92
100
|
* @returns .schema content.
|
|
93
101
|
*/
|
|
94
102
|
protected contentSchemaContent(schemaId: string): JSON;
|
|
103
|
+
protected create(newContent?: T): Promise<void>;
|
|
104
|
+
protected getLogger(loggerName: string): Logger;
|
|
105
|
+
protected get getType(): string;
|
|
95
106
|
/**
|
|
96
107
|
* Handles operation to an array.
|
|
97
108
|
* @param operation Operation to perform on array.
|
|
@@ -106,6 +117,11 @@ export declare class ResourceObject extends AbstractResource {
|
|
|
106
117
|
* @returns What the scalar should be changed to.
|
|
107
118
|
*/
|
|
108
119
|
protected handleScalar<Type>(operation: Operation<Type>): Type;
|
|
120
|
+
protected initialize(): void;
|
|
121
|
+
protected postUpdate<Type, K extends string>(content: T, updateKey: UpdateKey<K>, op: Operation<Type>): Promise<void>;
|
|
122
|
+
protected update<Type, K extends string>(key: UpdateKey<K>, _op: Operation<Type>): Promise<void>;
|
|
123
|
+
protected read(): Promise<void>;
|
|
124
|
+
protected rename(newName: ResourceName): Promise<void>;
|
|
109
125
|
/**
|
|
110
126
|
* Update calculation files.
|
|
111
127
|
* @param from Resource name to update
|
|
@@ -119,5 +135,24 @@ export declare class ResourceObject extends AbstractResource {
|
|
|
119
135
|
* @param handleBarFiles Optional. List of handlebar files. If omitted, affects all handlebar files in the project.
|
|
120
136
|
*/
|
|
121
137
|
protected updateHandleBars(from: string, to: string, handleBarFiles?: string[]): Promise<void>;
|
|
138
|
+
protected usage(cards?: Card[]): Promise<string[]>;
|
|
139
|
+
protected validName(newName: ResourceName): Promise<string>;
|
|
140
|
+
protected write(): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Returns memory resident data as JSON.
|
|
143
|
+
* This is basically same as 'show' but doesn't do any checks; just returns the current content.
|
|
144
|
+
* @returns metadata content or undefined if resource does not exist.
|
|
145
|
+
*/
|
|
146
|
+
get data(): T | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Deletes the file and removes the resource from project.
|
|
149
|
+
* @throws if resource is a module resource or does not exist or is used by other resources.
|
|
150
|
+
*/
|
|
151
|
+
delete(): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Validates the content of the resource.
|
|
154
|
+
* @param content Content to be validated.
|
|
155
|
+
*/
|
|
156
|
+
validate(content?: object): Promise<void>;
|
|
122
157
|
}
|
|
123
158
|
export {};
|