@cyberismo/data-handler 0.0.15 → 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 +7 -1
- package/dist/card-metadata-updater.js.map +1 -1
- package/dist/command-handler.d.ts +4 -0
- package/dist/command-handler.js +19 -3
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +24 -1
- package/dist/command-manager.js +27 -3
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/create.d.ts +1 -1
- package/dist/commands/create.js +34 -36
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/export.d.ts +11 -2
- package/dist/commands/export.js +54 -41
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/import.d.ts +9 -1
- package/dist/commands/import.js +15 -7
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/move.js +0 -1
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.d.ts +8 -1
- package/dist/commands/remove.js +8 -4
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.d.ts +4 -9
- package/dist/commands/rename.js +32 -101
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +16 -10
- package/dist/commands/show.js +71 -55
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.d.ts +9 -2
- package/dist/commands/transition.js +25 -17
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.d.ts +16 -12
- package/dist/commands/update.js +19 -17
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.d.ts +17 -9
- package/dist/commands/validate.js +96 -35
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/project/calculation-engine.d.ts +7 -4
- package/dist/containers/project/calculation-engine.js +61 -66
- package/dist/containers/project/calculation-engine.js.map +1 -1
- 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 +38 -153
- package/dist/containers/project.js +129 -405
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.d.ts +8 -2
- package/dist/containers/template.js +20 -15
- package/dist/containers/template.js.map +1 -1
- package/dist/interfaces/folder-content-interfaces.d.ts +5 -3
- package/dist/interfaces/folder-content-interfaces.js +3 -3
- package/dist/interfaces/folder-content-interfaces.js.map +1 -1
- package/dist/interfaces/project-interfaces.d.ts +2 -4
- package/dist/interfaces/project-interfaces.js.map +1 -1
- package/dist/interfaces/resource-interfaces.d.ts +14 -1
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/graph/index.js +12 -26
- package/dist/macros/graph/index.js.map +1 -1
- 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/report/index.js +3 -6
- package/dist/macros/report/index.js.map +1 -1
- package/dist/module-manager.d.ts +16 -3
- package/dist/module-manager.js +51 -19
- 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 +4 -3
- package/dist/resources/calculation-resource.js +11 -5
- package/dist/resources/calculation-resource.js.map +1 -1
- package/dist/resources/card-type-resource.d.ts +6 -1
- package/dist/resources/card-type-resource.js +34 -23
- 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 +4 -1
- package/dist/resources/field-type-resource.js +22 -23
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.d.ts +5 -9
- package/dist/resources/file-resource.js +6 -11
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +29 -32
- package/dist/resources/folder-resource.js +59 -78
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +4 -1
- package/dist/resources/graph-model-resource.js +11 -4
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +5 -2
- package/dist/resources/graph-view-resource.js +7 -3
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.d.ts +5 -2
- package/dist/resources/link-type-resource.js +5 -2
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +6 -7
- package/dist/resources/report-resource.js +14 -23
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +93 -8
- package/dist/resources/resource-object.js +162 -110
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +7 -3
- package/dist/resources/template-resource.js +10 -3
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +5 -2
- package/dist/resources/workflow-resource.js +18 -22
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/utils/card-utils.d.ts +2 -2
- package/dist/utils/card-utils.js +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 +3 -4
- package/dist/utils/clingo-facts.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 +8 -8
- package/src/card-metadata-updater.ts +6 -2
- package/src/command-handler.ts +24 -5
- package/src/command-manager.ts +29 -17
- package/src/commands/create.ts +43 -78
- package/src/commands/export.ts +63 -52
- package/src/commands/import.ts +24 -14
- package/src/commands/move.ts +0 -1
- package/src/commands/remove.ts +11 -7
- package/src/commands/rename.ts +43 -149
- package/src/commands/show.ts +113 -78
- package/src/commands/transition.ts +26 -28
- package/src/commands/update.ts +25 -22
- package/src/commands/validate.ts +108 -67
- package/src/containers/project/calculation-engine.ts +61 -93
- 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 +178 -522
- package/src/containers/template.ts +24 -19
- package/src/interfaces/folder-content-interfaces.ts +7 -6
- package/src/interfaces/project-interfaces.ts +7 -6
- package/src/interfaces/resource-interfaces.ts +18 -3
- package/src/macros/graph/index.ts +26 -47
- package/src/macros/index.ts +2 -2
- package/src/macros/report/index.ts +3 -9
- package/src/module-manager.ts +74 -17
- package/src/project-settings.ts +83 -14
- package/src/resources/calculation-resource.ts +18 -18
- package/src/resources/card-type-resource.ts +50 -50
- package/src/resources/create-defaults.ts +3 -2
- package/src/resources/field-type-resource.ts +41 -55
- package/src/resources/file-resource.ts +10 -36
- package/src/resources/folder-resource.ts +69 -120
- package/src/resources/graph-model-resource.ts +20 -22
- package/src/resources/graph-view-resource.ts +15 -17
- package/src/resources/link-type-resource.ts +10 -13
- package/src/resources/report-resource.ts +21 -43
- package/src/resources/resource-object.ts +194 -152
- package/src/resources/template-resource.ts +17 -16
- package/src/resources/workflow-resource.ts +25 -44
- package/src/utils/card-utils.ts +2 -2
- package/src/utils/clingo-fact-builder.ts +28 -16
- package/src/utils/clingo-facts.ts +3 -4
- package/src/utils/resource-utils.ts +2 -1
- package/dist/containers/project/resource-collector.d.ts +0 -110
- package/dist/containers/project/resource-collector.js +0 -344
- package/dist/containers/project/resource-collector.js.map +0 -1
- package/src/containers/project/resource-collector.ts +0 -404
|
@@ -11,23 +11,29 @@
|
|
|
11
11
|
You should have received a copy of the GNU Affero General Public
|
|
12
12
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
13
13
|
*/
|
|
14
|
-
import
|
|
15
|
-
import type {
|
|
16
|
-
import { type UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
17
|
-
import type { ResourceFolderType } from '../interfaces/project-interfaces.js';
|
|
18
|
-
import { DefaultContent, FileResource, Project, resourceNameToString, sortCards } from './file-resource.js';
|
|
14
|
+
import { ResourceObject } from './resource-object.js';
|
|
15
|
+
import type { UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
19
16
|
import type { FolderResourceContent } from '../interfaces/folder-content-interfaces.js';
|
|
17
|
+
import type { Operation } from './resource-object.js';
|
|
18
|
+
import type { Project } from '../containers/project.js';
|
|
19
|
+
import type { ResourceFolderType } from '../interfaces/project-interfaces.js';
|
|
20
|
+
import type { ResourceBaseMetadata } from '../interfaces/resource-interfaces.js';
|
|
21
|
+
import type { ResourceName } from '../utils/resource-utils.js';
|
|
20
22
|
import type { ShowReturnType } from './resource-object.js';
|
|
21
|
-
import { ResourceObject } from './resource-object.js';
|
|
22
|
-
export { type Card, DefaultContent, FileResource, type Operation, Project, ResourceName, resourceNameToString, sortCards, };
|
|
23
23
|
/**
|
|
24
|
-
* Folder type resource class.
|
|
24
|
+
* Folder type resource class.
|
|
25
|
+
* These are resources that have their own folders for content.
|
|
25
26
|
*/
|
|
26
27
|
export declare abstract class FolderResource<T extends ResourceBaseMetadata, U extends FolderResourceContent> extends ResourceObject<T, U> {
|
|
27
28
|
protected internalFolder: string;
|
|
28
|
-
private
|
|
29
|
+
private resourceContent;
|
|
30
|
+
/**
|
|
31
|
+
* Constructs a FolderResource object.
|
|
32
|
+
* @param project Project in which this resource exists.
|
|
33
|
+
* @param name Name for the resource.
|
|
34
|
+
* @param type Type for this resource.
|
|
35
|
+
*/
|
|
29
36
|
constructor(project: Project, name: ResourceName, type: ResourceFolderType);
|
|
30
|
-
private clearContentCache;
|
|
31
37
|
/**
|
|
32
38
|
* Creates a new folder type object. Base class writes the object to disk automatically.
|
|
33
39
|
* @param newContent Content for the type.
|
|
@@ -43,28 +49,19 @@ export declare abstract class FolderResource<T extends ResourceBaseMetadata, U e
|
|
|
43
49
|
*/
|
|
44
50
|
protected abstract onNameChange?(previousName: string): Promise<void>;
|
|
45
51
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @param newName New name for the resource.
|
|
48
|
-
*/
|
|
49
|
-
protected rename(newName: ResourceName): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Shows the content of a file in the resource.
|
|
52
|
-
* @param fileName Name of the file to show.
|
|
53
|
-
* @param json Content is JSON file.
|
|
54
|
-
* @returns the content of the file.
|
|
52
|
+
* Set content files. Should not be called by others than resource cache.
|
|
55
53
|
*/
|
|
56
|
-
|
|
54
|
+
setContentFiles(contentFiles: Map<string, string>): void;
|
|
57
55
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @returns all file names in the resource.
|
|
56
|
+
* Load all content files from the internal folder and set them.
|
|
60
57
|
*/
|
|
61
|
-
protected
|
|
58
|
+
protected loadContentFiles(): Promise<void>;
|
|
62
59
|
/**
|
|
63
60
|
* Updates a file in the resource.
|
|
64
61
|
* @param fileName The name of the file to update.
|
|
65
62
|
* @param changedContent The new content for the file.
|
|
66
63
|
*/
|
|
67
|
-
|
|
64
|
+
updateFile(fileName: string, changedContent: string): Promise<void>;
|
|
68
65
|
/**
|
|
69
66
|
* Writes resource content to disk.
|
|
70
67
|
*/
|
|
@@ -73,12 +70,18 @@ export declare abstract class FolderResource<T extends ResourceBaseMetadata, U e
|
|
|
73
70
|
* Gets content of all files to properties.
|
|
74
71
|
* @returns object with property names as keys and file contents as values.
|
|
75
72
|
*/
|
|
76
|
-
contentData():
|
|
73
|
+
contentData(): U;
|
|
77
74
|
/**
|
|
78
75
|
* Deletes file and content folder from disk and clears out the memory resident object.
|
|
79
|
-
* @throws if resource is a module resource or does not exist or is used by other resources.
|
|
80
76
|
*/
|
|
81
77
|
delete(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Shows metadata of the resource and content of the resource.
|
|
80
|
+
* @template T Resource type
|
|
81
|
+
* @template U Resource content
|
|
82
|
+
* @returns resource type's metadata and content.
|
|
83
|
+
*/
|
|
84
|
+
show(): ShowReturnType<T, U>;
|
|
82
85
|
/**
|
|
83
86
|
* Updates resource.
|
|
84
87
|
* @param updateKey Key to modify
|
|
@@ -86,10 +89,4 @@ export declare abstract class FolderResource<T extends ResourceBaseMetadata, U e
|
|
|
86
89
|
* @throws if key is unknown.
|
|
87
90
|
*/
|
|
88
91
|
update<Type, K extends string>(updateKey: UpdateKey<K>, op: Operation<Type>): Promise<void>;
|
|
89
|
-
/**
|
|
90
|
-
* Shows metadata of the resource and content of the resource.
|
|
91
|
-
* @returns resource type's metadata and content.
|
|
92
|
-
* @throws if resource does not exist.
|
|
93
|
-
*/
|
|
94
|
-
show(): Promise<ShowReturnType<T, U>>;
|
|
95
92
|
}
|
|
@@ -13,34 +13,37 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { basename, dirname, join, normalize } from 'node:path';
|
|
15
15
|
import { mkdir, readdir, readFile, rename, rm } from 'node:fs/promises';
|
|
16
|
-
import { isContentKey
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { formatJson, readJsonFile } from '../utils/json.js';
|
|
16
|
+
import { isContentKey } from '../interfaces/resource-interfaces.js';
|
|
17
|
+
import { filename, contentPropertyName, } from '../interfaces/folder-content-interfaces.js';
|
|
18
|
+
import { formatJson } from '../utils/json.js';
|
|
20
19
|
import { VALID_FOLDER_RESOURCE_FILES } from '../utils/constants.js';
|
|
21
20
|
import { writeFileSafe } from '../utils/file-utils.js';
|
|
22
21
|
import { ResourceObject } from './resource-object.js';
|
|
23
|
-
|
|
22
|
+
import { resourceName } from '../utils/resource-utils.js';
|
|
24
23
|
/**
|
|
25
|
-
* Folder type resource class.
|
|
24
|
+
* Folder type resource class.
|
|
25
|
+
* These are resources that have their own folders for content.
|
|
26
26
|
*/
|
|
27
27
|
export class FolderResource extends ResourceObject {
|
|
28
28
|
internalFolder = '';
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
resourceContent = {};
|
|
30
|
+
/**
|
|
31
|
+
* Constructs a FolderResource object.
|
|
32
|
+
* @param project Project in which this resource exists.
|
|
33
|
+
* @param name Name for the resource.
|
|
34
|
+
* @param type Type for this resource.
|
|
35
|
+
*/
|
|
31
36
|
constructor(project, name, type) {
|
|
32
37
|
super(project, name, type);
|
|
33
38
|
this.initialize();
|
|
34
39
|
}
|
|
35
|
-
// Clears the content files cache.
|
|
36
|
-
clearContentCache() {
|
|
37
|
-
this.contentFilesCache.clear();
|
|
38
|
-
}
|
|
39
40
|
/**
|
|
40
41
|
* Creates a new folder type object. Base class writes the object to disk automatically.
|
|
41
42
|
* @param newContent Content for the type.
|
|
42
43
|
*/
|
|
43
44
|
async create(newContent) {
|
|
45
|
+
// Validate resource identifier before creating on disk
|
|
46
|
+
this.validateResourceIdentifier();
|
|
44
47
|
await super.create(newContent);
|
|
45
48
|
await mkdir(this.internalFolder, { recursive: true });
|
|
46
49
|
}
|
|
@@ -52,51 +55,33 @@ export class FolderResource extends ResourceObject {
|
|
|
52
55
|
this.internalFolder = join(this.resourceFolder, this.resourceName.identifier);
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @param newName New name for the resource.
|
|
58
|
+
* Set content files. Should not be called by others than resource cache.
|
|
57
59
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*/
|
|
67
|
-
async showFile(fileName, json = false) {
|
|
68
|
-
// Always first check cache...
|
|
69
|
-
if (this.contentFilesCache.has(fileName)) {
|
|
70
|
-
const cached = this.contentFilesCache.get(fileName);
|
|
71
|
-
return json ? JSON.parse(cached) : cached;
|
|
60
|
+
setContentFiles(contentFiles) {
|
|
61
|
+
const content = {};
|
|
62
|
+
for (const [fileName, fileContent] of contentFiles.entries()) {
|
|
63
|
+
const key = contentPropertyName(fileName);
|
|
64
|
+
if (key) {
|
|
65
|
+
const isJson = key === 'schema';
|
|
66
|
+
content[key] = isJson ? JSON.parse(fileContent) : fileContent;
|
|
67
|
+
}
|
|
72
68
|
}
|
|
73
|
-
|
|
74
|
-
const filePath = join(this.internalFolder, fileName);
|
|
75
|
-
const content = json
|
|
76
|
-
? await readJsonFile(filePath)
|
|
77
|
-
: await readFile(filePath, 'utf8');
|
|
78
|
-
// Update cache
|
|
79
|
-
const contentStr = typeof content === 'string' ? content : formatJson(content);
|
|
80
|
-
this.contentFilesCache.set(fileName, contentStr);
|
|
81
|
-
return json ? content : contentStr;
|
|
69
|
+
this.resourceContent = content;
|
|
82
70
|
}
|
|
83
71
|
/**
|
|
84
|
-
*
|
|
85
|
-
* @returns all file names in the resource.
|
|
72
|
+
* Load all content files from the internal folder and set them.
|
|
86
73
|
*/
|
|
87
|
-
async
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for (const fileName of validFiles) {
|
|
97
|
-
await this.showFile(fileName);
|
|
74
|
+
async loadContentFiles() {
|
|
75
|
+
const contentFiles = new Map();
|
|
76
|
+
const files = await readdir(this.internalFolder, { withFileTypes: true });
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
if (file.isFile() && VALID_FOLDER_RESOURCE_FILES.includes(file.name)) {
|
|
79
|
+
const filePath = join(this.internalFolder, file.name);
|
|
80
|
+
const content = await readFile(filePath, 'utf-8');
|
|
81
|
+
contentFiles.set(file.name, content);
|
|
82
|
+
}
|
|
98
83
|
}
|
|
99
|
-
|
|
84
|
+
this.setContentFiles(contentFiles);
|
|
100
85
|
}
|
|
101
86
|
/**
|
|
102
87
|
* Updates a file in the resource.
|
|
@@ -120,8 +105,14 @@ export class FolderResource extends ResourceObject {
|
|
|
120
105
|
throw new Error(`File '${fileName}' is not allowed to be updated`);
|
|
121
106
|
}
|
|
122
107
|
await writeFileSafe(filePath, changedContent, { flag: 'w' });
|
|
123
|
-
// Update
|
|
124
|
-
|
|
108
|
+
// Update this resource's content
|
|
109
|
+
const key = contentPropertyName(fileName);
|
|
110
|
+
if (key) {
|
|
111
|
+
const isJson = key === 'schema';
|
|
112
|
+
this.resourceContent[key] = isJson
|
|
113
|
+
? JSON.parse(changedContent)
|
|
114
|
+
: changedContent;
|
|
115
|
+
}
|
|
125
116
|
}
|
|
126
117
|
/**
|
|
127
118
|
* Writes resource content to disk.
|
|
@@ -141,28 +132,30 @@ export class FolderResource extends ResourceObject {
|
|
|
141
132
|
* Gets content of all files to properties.
|
|
142
133
|
* @returns object with property names as keys and file contents as values.
|
|
143
134
|
*/
|
|
144
|
-
|
|
145
|
-
const fileNames = await this.showFileNames();
|
|
146
|
-
const content = {};
|
|
147
|
-
for (const fileName of fileNames) {
|
|
148
|
-
const name = propertyName(fileName);
|
|
149
|
-
if (name) {
|
|
150
|
-
const JSONFile = name === 'schema';
|
|
151
|
-
content[name] = await this.showFile(fileName, JSONFile);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
135
|
+
contentData() {
|
|
154
136
|
// TODO: Instead of casting, validate that content matches U
|
|
155
137
|
// This requires a runtime schema for U to be defined(via an abstract variable)
|
|
156
|
-
return
|
|
138
|
+
return this.resourceContent;
|
|
157
139
|
}
|
|
158
140
|
/**
|
|
159
141
|
* Deletes file and content folder from disk and clears out the memory resident object.
|
|
160
|
-
* @throws if resource is a module resource or does not exist or is used by other resources.
|
|
161
142
|
*/
|
|
162
143
|
async delete() {
|
|
163
144
|
await super.delete();
|
|
164
145
|
await rm(this.internalFolder, { recursive: true, force: true });
|
|
165
|
-
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Shows metadata of the resource and content of the resource.
|
|
149
|
+
* @template T Resource type
|
|
150
|
+
* @template U Resource content
|
|
151
|
+
* @returns resource type's metadata and content.
|
|
152
|
+
*/
|
|
153
|
+
show() {
|
|
154
|
+
this.assertResourceExists();
|
|
155
|
+
return {
|
|
156
|
+
...this.content,
|
|
157
|
+
content: this.contentData(),
|
|
158
|
+
};
|
|
166
159
|
}
|
|
167
160
|
/**
|
|
168
161
|
* Updates resource.
|
|
@@ -202,17 +195,5 @@ export class FolderResource extends ResourceObject {
|
|
|
202
195
|
await this.onNameChange?.(existingName);
|
|
203
196
|
}
|
|
204
197
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Shows metadata of the resource and content of the resource.
|
|
207
|
-
* @returns resource type's metadata and content.
|
|
208
|
-
* @throws if resource does not exist.
|
|
209
|
-
*/
|
|
210
|
-
async show() {
|
|
211
|
-
this.assertResourceExists();
|
|
212
|
-
return {
|
|
213
|
-
...this.content,
|
|
214
|
-
content: await this.contentData(),
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
198
|
}
|
|
218
199
|
//# sourceMappingURL=folder-resource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder-resource.js","sourceRoot":"","sources":["../../src/resources/folder-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"folder-resource.js","sourceRoot":"","sources":["../../src/resources/folder-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EACL,QAAQ,EACR,mBAAmB,GACpB,MAAM,4CAA4C,CAAC;AACpD,OAAO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,CAAC,IAAI,CAAC;QACvC,MAAM,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,EAAE,CAAW,CAAC;QAClD,CAAC;aAAM,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;YACjC,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,EAAE,CAAW,CAAC;QACzD,CAAC;aAAM,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;YACjC,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,EAAE,CAAW,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,uBAAuB,CAAC,CAAC;QACnE,CAAC;QAED,MAAM,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QAE/C,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -11,10 +11,13 @@
|
|
|
11
11
|
You should have received a copy of the GNU Affero General Public
|
|
12
12
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
13
13
|
*/
|
|
14
|
-
import type { Card, Operation, Project, ResourceName } from './folder-resource.js';
|
|
15
14
|
import { FolderResource } from './folder-resource.js';
|
|
15
|
+
import type { Card } from '../interfaces/project-interfaces.js';
|
|
16
16
|
import type { GraphModelMetadata, UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
17
17
|
import type { GraphModelContent } from '../interfaces/folder-content-interfaces.js';
|
|
18
|
+
import type { Operation } from './resource-object.js';
|
|
19
|
+
import type { Project } from '../containers/project.js';
|
|
20
|
+
import type { ResourceName } from '../utils/resource-utils.js';
|
|
18
21
|
/**
|
|
19
22
|
* Graph model resource class.
|
|
20
23
|
*/
|
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
13
13
|
*/
|
|
14
14
|
import { join } from 'node:path';
|
|
15
|
-
import { DefaultContent
|
|
15
|
+
import { DefaultContent } from './create-defaults.js';
|
|
16
|
+
import { FolderResource } from './folder-resource.js';
|
|
17
|
+
import { resourceNameToString } from '../utils/resource-utils.js';
|
|
18
|
+
import { sortCards } from '../utils/card-utils.js';
|
|
16
19
|
import { writeFileSafe } from '../utils/file-utils.js';
|
|
20
|
+
import { CONTENT_FILES } from '../interfaces/folder-content-interfaces.js';
|
|
17
21
|
/**
|
|
18
22
|
* Graph model resource class.
|
|
19
23
|
*/
|
|
@@ -30,7 +34,7 @@ export class GraphModelResource extends FolderResource {
|
|
|
30
34
|
async onNameChange(existingName) {
|
|
31
35
|
await Promise.all([
|
|
32
36
|
super.updateHandleBars(existingName, this.content.name, [
|
|
33
|
-
join(this.internalFolder,
|
|
37
|
+
join(this.internalFolder, CONTENT_FILES.model),
|
|
34
38
|
]),
|
|
35
39
|
super.updateCalculations(existingName, this.content.name),
|
|
36
40
|
]);
|
|
@@ -51,10 +55,13 @@ export class GraphModelResource extends FolderResource {
|
|
|
51
55
|
}
|
|
52
56
|
await super.create(newContent);
|
|
53
57
|
// Create the internal folder in 'create', instead of 'write'.
|
|
54
|
-
const
|
|
55
|
-
|
|
58
|
+
const modelContent = `% add your calculations here for '${this.resourceName.identifier}'`;
|
|
59
|
+
const modelFile = CONTENT_FILES.model;
|
|
60
|
+
const calculationsFile = join(this.internalFolder, modelFile);
|
|
61
|
+
await writeFileSafe(calculationsFile, modelContent, {
|
|
56
62
|
flag: 'wx',
|
|
57
63
|
});
|
|
64
|
+
await this.loadContentFiles();
|
|
58
65
|
}
|
|
59
66
|
/**
|
|
60
67
|
* Renames the object and the file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-model-resource.js","sourceRoot":"","sources":["../../src/resources/graph-model-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"graph-model-resource.js","sourceRoot":"","sources":["../../src/resources/graph-model-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AAEF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAY3E;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAGvC;IACC,YAAY,OAAgB,EAAE,IAAkB;QAC9C,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAEpC,IAAI,CAAC,eAAe,GAAG,kBAAkB,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACxE,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,YAAY,CAAC,YAAoB;QAC/C,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,KAAK,CAAC,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;gBACtD,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,KAAK,CAAC;aAC/C,CAAC;YACF,KAAK,CAAC,kBAAkB,CA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AO,CAAC,CAAC;YAC9C,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,10 +11,13 @@
|
|
|
11
11
|
You should have received a copy of the GNU Affero General Public
|
|
12
12
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
13
13
|
*/
|
|
14
|
-
import type { Card, Operation, Project, ResourceName } from './folder-resource.js';
|
|
15
14
|
import { FolderResource } from './folder-resource.js';
|
|
16
|
-
import type {
|
|
15
|
+
import type { Card } from '../interfaces/project-interfaces.js';
|
|
17
16
|
import type { GraphViewContent } from '../interfaces/folder-content-interfaces.js';
|
|
17
|
+
import type { GraphViewMetadata, UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
18
|
+
import type { Operation } from './resource-object.js';
|
|
19
|
+
import type { Project } from '../containers/project.js';
|
|
20
|
+
import type { ResourceName } from '../utils/resource-utils.js';
|
|
18
21
|
/**
|
|
19
22
|
* Graph view resource class.
|
|
20
23
|
*/
|
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
You should have received a copy of the GNU Affero General Public
|
|
12
12
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
13
13
|
*/
|
|
14
|
-
import { readdir } from 'node:fs/promises';
|
|
15
14
|
import { extname, join } from 'node:path';
|
|
16
|
-
import {
|
|
17
|
-
import { getStaticDirectoryPath } from '@cyberismo/assets';
|
|
15
|
+
import { readdir } from 'node:fs/promises';
|
|
18
16
|
import { copyDir } from '../utils/file-utils.js';
|
|
17
|
+
import { DefaultContent } from './create-defaults.js';
|
|
18
|
+
import { FolderResource } from './folder-resource.js';
|
|
19
|
+
import { getStaticDirectoryPath } from '@cyberismo/assets';
|
|
20
|
+
import { resourceNameToString } from '../utils/resource-utils.js';
|
|
21
|
+
import { sortCards } from '../utils/card-utils.js';
|
|
19
22
|
/**
|
|
20
23
|
* Graph view resource class.
|
|
21
24
|
*/
|
|
@@ -52,6 +55,7 @@ export class GraphViewResource extends FolderResource {
|
|
|
52
55
|
}
|
|
53
56
|
await super.create(newContent);
|
|
54
57
|
await copyDir(join(await getStaticDirectoryPath(), 'defaultGraphView'), this.internalFolder);
|
|
58
|
+
await this.loadContentFiles();
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
61
|
* Returns handlebar filename that this graph view has.
|
|
@@ -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,
|
|
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,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACj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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"}
|
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
You should have received a copy of the GNU Affero General Public
|
|
10
10
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
11
11
|
*/
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
12
|
+
import { FileResource } from './file-resource.js';
|
|
13
|
+
import type { Card } from '../interfaces/project-interfaces.js';
|
|
14
14
|
import type { LinkType, UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
15
|
+
import type { Operation } from './resource-object.js';
|
|
16
|
+
import type { Project } from '../containers/project.js';
|
|
17
|
+
import type { ResourceName } from '../utils/resource-utils.js';
|
|
15
18
|
/**
|
|
16
19
|
* Link Type resource class.
|
|
17
20
|
*/
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
You should have received a copy of the GNU Affero General Public
|
|
10
10
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
11
11
|
*/
|
|
12
|
-
import { DefaultContent
|
|
12
|
+
import { DefaultContent } from './create-defaults.js';
|
|
13
|
+
import { FileResource } from './file-resource.js';
|
|
14
|
+
import { resourceNameToString } from '../utils/resource-utils.js';
|
|
15
|
+
import { sortCards } from '../utils/card-utils.js';
|
|
13
16
|
/**
|
|
14
17
|
* Link Type resource class.
|
|
15
18
|
*/
|
|
@@ -22,7 +25,7 @@ export class LinkTypeResource extends FileResource {
|
|
|
22
25
|
// When resource name changes.
|
|
23
26
|
async handleNameChange(existingName) {
|
|
24
27
|
const current = this.content;
|
|
25
|
-
const prefixes =
|
|
28
|
+
const prefixes = this.project.projectPrefixes();
|
|
26
29
|
if (current.sourceCardTypes) {
|
|
27
30
|
current.sourceCardTypes = current.sourceCardTypes.map((item) => this.updatePrefixInResourceName(item, prefixes));
|
|
28
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-type-resource.js","sourceRoot":"","sources":["../../src/resources/link-type-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;
|
|
1
|
+
{"version":3,"file":"link-type-resource.js","sourceRoot":"","sources":["../../src/resources/link-type-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQnD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAsB;IAC1D,YAAY,OAAgB,EAAE,IAAkB;QAC9C,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QAElC,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACxE,CAAC;IAED,8BAA8B;IACtB,KAAK,CAAC,gBAAgB,CAAC,YAAoB;QACjD,MAAM,OAAO,GAAG,IAAI,CA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,IAAI,GAAG,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -12,17 +12,18 @@
|
|
|
12
12
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
13
13
|
*/
|
|
14
14
|
import { FolderResource } from './folder-resource.js';
|
|
15
|
-
import type { Card
|
|
16
|
-
import
|
|
15
|
+
import type { Card } from '../interfaces/project-interfaces.js';
|
|
16
|
+
import type { Operation } from './resource-object.js';
|
|
17
|
+
import type { Project } from '../containers/project.js';
|
|
17
18
|
import type { ReportContent } from '../interfaces/folder-content-interfaces.js';
|
|
19
|
+
import type { ReportMetadata, UpdateKey } from '../interfaces/resource-interfaces.js';
|
|
20
|
+
import type { ResourceName } from '../utils/resource-utils.js';
|
|
18
21
|
/**
|
|
19
22
|
* Report resource class.
|
|
20
23
|
*/
|
|
21
24
|
export declare class ReportResource extends FolderResource<ReportMetadata, ReportContent> {
|
|
22
|
-
private reportSchema;
|
|
23
25
|
constructor(project: Project, name: ResourceName);
|
|
24
|
-
private
|
|
25
|
-
private readSchemaFile;
|
|
26
|
+
private getDefaultReportLocation;
|
|
26
27
|
/**
|
|
27
28
|
* Handle name changes for reports
|
|
28
29
|
* @param existingName The previous name before the change
|
|
@@ -30,8 +31,6 @@ export declare class ReportResource extends FolderResource<ReportMetadata, Repor
|
|
|
30
31
|
protected onNameChange(existingName: string): Promise<void>;
|
|
31
32
|
/**
|
|
32
33
|
* Sets new metadata into the report object.
|
|
33
|
-
* @param newContent metadata content for the report.
|
|
34
|
-
* @throws if 'newContent' is not valid.
|
|
35
34
|
*/
|
|
36
35
|
createReport(): Promise<void>;
|
|
37
36
|
/**
|