@cyberismo/data-handler 0.0.20 → 0.0.22
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/command-handler.js +13 -24
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +21 -6
- package/dist/command-manager.js +34 -32
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/calculate.js +101 -46
- package/dist/commands/calculate.js.map +1 -1
- package/dist/commands/create.js +420 -320
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/edit.js +117 -68
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.js +301 -252
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/fetch.js +205 -156
- package/dist/commands/fetch.js.map +1 -1
- package/dist/commands/import.js +189 -134
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/migrate.js +91 -45
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/move.js +347 -267
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.d.ts +1 -0
- package/dist/commands/remove.js +202 -135
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.js +233 -187
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +8 -8
- package/dist/commands/show.js +477 -372
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.js +119 -73
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.js +8 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.js +1 -1
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/project/calculation-engine.js +0 -1
- package/dist/containers/project/calculation-engine.js.map +1 -1
- package/dist/containers/project/card-cache.js +1 -1
- package/dist/containers/project/card-cache.js.map +1 -1
- package/dist/containers/project.d.ts +16 -0
- package/dist/containers/project.js +59 -1
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.js +1 -1
- package/dist/containers/template.js.map +1 -1
- package/dist/interfaces/command-options.d.ts +1 -0
- package/dist/interfaces/resource-interfaces.d.ts +5 -12
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/base-macro.js +1 -1
- package/dist/macros/base-macro.js.map +1 -1
- package/dist/macros/graph/index.js +3 -1
- package/dist/macros/graph/index.js.map +1 -1
- package/dist/macros/include/index.js +16 -1
- package/dist/macros/include/index.js.map +1 -1
- package/dist/macros/include/types.d.ts +15 -12
- package/dist/macros/index.js +4 -1
- package/dist/macros/index.js.map +1 -1
- package/dist/macros/report/index.js +1 -1
- package/dist/macros/report/index.js.map +1 -1
- package/dist/module-manager.js +5 -3
- package/dist/module-manager.js.map +1 -1
- package/dist/project-settings.js +2 -2
- package/dist/project-settings.js.map +1 -1
- package/dist/resources/card-type-resource.js +1 -1
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/create-defaults.js +0 -1
- package/dist/resources/create-defaults.js.map +1 -1
- package/dist/resources/field-type-resource.js +2 -5
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.js +4 -1
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +1 -1
- package/dist/resources/folder-resource.js +4 -1
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +1 -8
- package/dist/resources/graph-model-resource.js +0 -14
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +1 -8
- package/dist/resources/graph-view-resource.js +0 -14
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.js +1 -1
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +1 -8
- package/dist/resources/report-resource.js +0 -14
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +11 -1
- package/dist/resources/resource-object.js +19 -2
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +1 -9
- package/dist/resources/template-resource.js +0 -15
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +6 -0
- package/dist/resources/workflow-resource.js +29 -13
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/utils/card-utils.js +1 -1
- package/dist/utils/card-utils.js.map +1 -1
- package/dist/utils/commit-context.d.ts +23 -0
- package/dist/utils/commit-context.js +30 -0
- package/dist/utils/commit-context.js.map +1 -0
- package/dist/utils/csv.d.ts +8 -0
- package/dist/utils/csv.js +11 -0
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/file-utils.js +3 -1
- package/dist/utils/file-utils.js.map +1 -1
- package/dist/utils/git-manager.d.ts +29 -0
- package/dist/utils/git-manager.js +76 -0
- package/dist/utils/git-manager.js.map +1 -0
- package/dist/utils/handlebars-helpers.d.ts +22 -0
- package/dist/utils/handlebars-helpers.js +78 -0
- package/dist/utils/handlebars-helpers.js.map +1 -0
- package/dist/utils/json.d.ts +17 -10
- package/dist/utils/json.js +27 -14
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/log-utils.d.ts +7 -2
- package/dist/utils/log-utils.js +28 -3
- package/dist/utils/log-utils.js.map +1 -1
- package/dist/utils/report.d.ts +0 -19
- package/dist/utils/report.js +4 -63
- package/dist/utils/report.js.map +1 -1
- package/dist/utils/rw-lock.d.ts +71 -0
- package/dist/utils/rw-lock.js +220 -0
- package/dist/utils/rw-lock.js.map +1 -0
- package/dist/utils/user-preferences.js +3 -3
- package/dist/utils/user-preferences.js.map +1 -1
- package/package.json +10 -10
- package/src/command-handler.ts +14 -22
- package/src/command-manager.ts +43 -37
- package/src/commands/calculate.ts +8 -1
- package/src/commands/create.ts +39 -6
- package/src/commands/edit.ts +3 -0
- package/src/commands/export.ts +8 -2
- package/src/commands/fetch.ts +3 -0
- package/src/commands/import.ts +5 -0
- package/src/commands/migrate.ts +2 -0
- package/src/commands/move.ts +34 -0
- package/src/commands/remove.ts +24 -2
- package/src/commands/rename.ts +2 -0
- package/src/commands/show.ts +63 -34
- package/src/commands/transition.ts +2 -0
- package/src/commands/update.ts +9 -3
- package/src/commands/validate.ts +1 -1
- package/src/containers/project/calculation-engine.ts +0 -1
- package/src/containers/project/card-cache.ts +1 -0
- package/src/containers/project.ts +75 -1
- package/src/containers/template.ts +1 -1
- package/src/interfaces/command-options.ts +1 -0
- package/src/interfaces/resource-interfaces.ts +5 -12
- package/src/macros/base-macro.ts +1 -1
- package/src/macros/graph/index.ts +3 -0
- package/src/macros/include/index.ts +19 -1
- package/src/macros/include/types.ts +15 -12
- package/src/macros/index.ts +4 -1
- package/src/macros/report/index.ts +1 -0
- package/src/module-manager.ts +5 -2
- package/src/project-settings.ts +2 -1
- package/src/resources/card-type-resource.ts +1 -1
- package/src/resources/create-defaults.ts +0 -1
- package/src/resources/field-type-resource.ts +2 -4
- package/src/resources/file-resource.ts +3 -1
- package/src/resources/folder-resource.ts +7 -2
- package/src/resources/graph-model-resource.ts +1 -25
- package/src/resources/graph-view-resource.ts +1 -25
- package/src/resources/link-type-resource.ts +1 -1
- package/src/resources/report-resource.ts +1 -25
- package/src/resources/resource-object.ts +22 -1
- package/src/resources/template-resource.ts +0 -23
- package/src/resources/workflow-resource.ts +45 -16
- package/src/utils/card-utils.ts +1 -1
- package/src/utils/commit-context.ts +45 -0
- package/src/utils/csv.ts +12 -0
- package/src/utils/file-utils.ts +3 -1
- package/src/utils/git-manager.ts +87 -0
- package/src/utils/handlebars-helpers.ts +95 -0
- package/src/utils/json.ts +29 -15
- package/src/utils/log-utils.ts +33 -4
- package/src/utils/report.ts +8 -74
- package/src/utils/rw-lock.ts +279 -0
- package/src/utils/user-preferences.ts +3 -0
package/dist/commands/show.js
CHANGED
|
@@ -10,6 +10,40 @@
|
|
|
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
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
14
|
+
var useValue = arguments.length > 2;
|
|
15
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
16
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
17
|
+
}
|
|
18
|
+
return useValue ? value : void 0;
|
|
19
|
+
};
|
|
20
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
21
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
22
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
23
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
24
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
25
|
+
var _, done = false;
|
|
26
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
27
|
+
var context = {};
|
|
28
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
29
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
30
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
31
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
32
|
+
if (kind === "accessor") {
|
|
33
|
+
if (result === void 0) continue;
|
|
34
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
35
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
36
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
37
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
38
|
+
}
|
|
39
|
+
else if (_ = accept(result)) {
|
|
40
|
+
if (kind === "field") initializers.unshift(_);
|
|
41
|
+
else descriptor[key] = _;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
45
|
+
done = true;
|
|
46
|
+
};
|
|
13
47
|
// node
|
|
14
48
|
import { readFileSync } from 'node:fs';
|
|
15
49
|
import { homedir } from 'node:os';
|
|
@@ -18,6 +52,7 @@ import { spawn } from 'node:child_process';
|
|
|
18
52
|
import { writeFile } from 'node:fs/promises';
|
|
19
53
|
import { MODULE_LIST_FULL_PATH } from './fetch.js';
|
|
20
54
|
import { UserPreferences } from '../utils/user-preferences.js';
|
|
55
|
+
import { read, write } from '../utils/rw-lock.js';
|
|
21
56
|
import ReportMacro from '../macros/report/index.js';
|
|
22
57
|
import TaskQueue from '../macros/task-queue.js';
|
|
23
58
|
import { evaluateMacros } from '../macros/index.js';
|
|
@@ -27,407 +62,477 @@ import { buildCardHierarchy, flattenCardArray } from '../utils/card-utils.js';
|
|
|
27
62
|
/**
|
|
28
63
|
* Show command.
|
|
29
64
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
else if (process.platform === 'darwin') {
|
|
97
|
-
spawn('open', [path]);
|
|
65
|
+
let Show = (() => {
|
|
66
|
+
let _instanceExtraInitializers = [];
|
|
67
|
+
let _showAllTemplateCards_decorators;
|
|
68
|
+
let _showAttachments_decorators;
|
|
69
|
+
let _showAttachment_decorators;
|
|
70
|
+
let _openAttachment_decorators;
|
|
71
|
+
let _showCardDetails_decorators;
|
|
72
|
+
let _showCards_decorators;
|
|
73
|
+
let _showCardLogicProgram_decorators;
|
|
74
|
+
let _showCardTypesWithDetails_decorators;
|
|
75
|
+
let _showImportableModules_decorators;
|
|
76
|
+
let _showLabels_decorators;
|
|
77
|
+
let _showLogicProgram_decorators;
|
|
78
|
+
let _showModule_decorators;
|
|
79
|
+
let _showHubs_decorators;
|
|
80
|
+
let _showProjectCards_decorators;
|
|
81
|
+
let _showModules_decorators;
|
|
82
|
+
let _showProject_decorators;
|
|
83
|
+
let _showReportResults_decorators;
|
|
84
|
+
let _showResources_decorators;
|
|
85
|
+
let _showTemplatesWithDetails_decorators;
|
|
86
|
+
let _showWorkflowsWithDetails_decorators;
|
|
87
|
+
return class Show {
|
|
88
|
+
static {
|
|
89
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
90
|
+
_showAllTemplateCards_decorators = [read];
|
|
91
|
+
_showAttachments_decorators = [read];
|
|
92
|
+
_showAttachment_decorators = [read];
|
|
93
|
+
_openAttachment_decorators = [read];
|
|
94
|
+
_showCardDetails_decorators = [read];
|
|
95
|
+
_showCards_decorators = [read];
|
|
96
|
+
_showCardLogicProgram_decorators = [read];
|
|
97
|
+
_showCardTypesWithDetails_decorators = [read];
|
|
98
|
+
_showImportableModules_decorators = [write()];
|
|
99
|
+
_showLabels_decorators = [read];
|
|
100
|
+
_showLogicProgram_decorators = [read];
|
|
101
|
+
_showModule_decorators = [read];
|
|
102
|
+
_showHubs_decorators = [write()];
|
|
103
|
+
_showProjectCards_decorators = [read];
|
|
104
|
+
_showModules_decorators = [read];
|
|
105
|
+
_showProject_decorators = [read];
|
|
106
|
+
_showReportResults_decorators = [read];
|
|
107
|
+
_showResources_decorators = [read];
|
|
108
|
+
_showTemplatesWithDetails_decorators = [read];
|
|
109
|
+
_showWorkflowsWithDetails_decorators = [read];
|
|
110
|
+
__esDecorate(this, null, _showAllTemplateCards_decorators, { kind: "method", name: "showAllTemplateCards", static: false, private: false, access: { has: obj => "showAllTemplateCards" in obj, get: obj => obj.showAllTemplateCards }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
111
|
+
__esDecorate(this, null, _showAttachments_decorators, { kind: "method", name: "showAttachments", static: false, private: false, access: { has: obj => "showAttachments" in obj, get: obj => obj.showAttachments }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
112
|
+
__esDecorate(this, null, _showAttachment_decorators, { kind: "method", name: "showAttachment", static: false, private: false, access: { has: obj => "showAttachment" in obj, get: obj => obj.showAttachment }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
113
|
+
__esDecorate(this, null, _openAttachment_decorators, { kind: "method", name: "openAttachment", static: false, private: false, access: { has: obj => "openAttachment" in obj, get: obj => obj.openAttachment }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
114
|
+
__esDecorate(this, null, _showCardDetails_decorators, { kind: "method", name: "showCardDetails", static: false, private: false, access: { has: obj => "showCardDetails" in obj, get: obj => obj.showCardDetails }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
115
|
+
__esDecorate(this, null, _showCards_decorators, { kind: "method", name: "showCards", static: false, private: false, access: { has: obj => "showCards" in obj, get: obj => obj.showCards }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
116
|
+
__esDecorate(this, null, _showCardLogicProgram_decorators, { kind: "method", name: "showCardLogicProgram", static: false, private: false, access: { has: obj => "showCardLogicProgram" in obj, get: obj => obj.showCardLogicProgram }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
117
|
+
__esDecorate(this, null, _showCardTypesWithDetails_decorators, { kind: "method", name: "showCardTypesWithDetails", static: false, private: false, access: { has: obj => "showCardTypesWithDetails" in obj, get: obj => obj.showCardTypesWithDetails }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
118
|
+
__esDecorate(this, null, _showImportableModules_decorators, { kind: "method", name: "showImportableModules", static: false, private: false, access: { has: obj => "showImportableModules" in obj, get: obj => obj.showImportableModules }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
119
|
+
__esDecorate(this, null, _showLabels_decorators, { kind: "method", name: "showLabels", static: false, private: false, access: { has: obj => "showLabels" in obj, get: obj => obj.showLabels }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
120
|
+
__esDecorate(this, null, _showLogicProgram_decorators, { kind: "method", name: "showLogicProgram", static: false, private: false, access: { has: obj => "showLogicProgram" in obj, get: obj => obj.showLogicProgram }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
121
|
+
__esDecorate(this, null, _showModule_decorators, { kind: "method", name: "showModule", static: false, private: false, access: { has: obj => "showModule" in obj, get: obj => obj.showModule }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
122
|
+
__esDecorate(this, null, _showHubs_decorators, { kind: "method", name: "showHubs", static: false, private: false, access: { has: obj => "showHubs" in obj, get: obj => obj.showHubs }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
123
|
+
__esDecorate(this, null, _showProjectCards_decorators, { kind: "method", name: "showProjectCards", static: false, private: false, access: { has: obj => "showProjectCards" in obj, get: obj => obj.showProjectCards }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
124
|
+
__esDecorate(this, null, _showModules_decorators, { kind: "method", name: "showModules", static: false, private: false, access: { has: obj => "showModules" in obj, get: obj => obj.showModules }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
125
|
+
__esDecorate(this, null, _showProject_decorators, { kind: "method", name: "showProject", static: false, private: false, access: { has: obj => "showProject" in obj, get: obj => obj.showProject }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
126
|
+
__esDecorate(this, null, _showReportResults_decorators, { kind: "method", name: "showReportResults", static: false, private: false, access: { has: obj => "showReportResults" in obj, get: obj => obj.showReportResults }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
127
|
+
__esDecorate(this, null, _showResources_decorators, { kind: "method", name: "showResources", static: false, private: false, access: { has: obj => "showResources" in obj, get: obj => obj.showResources }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
128
|
+
__esDecorate(this, null, _showTemplatesWithDetails_decorators, { kind: "method", name: "showTemplatesWithDetails", static: false, private: false, access: { has: obj => "showTemplatesWithDetails" in obj, get: obj => obj.showTemplatesWithDetails }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
129
|
+
__esDecorate(this, null, _showWorkflowsWithDetails_decorators, { kind: "method", name: "showWorkflowsWithDetails", static: false, private: false, access: { has: obj => "showWorkflowsWithDetails" in obj, get: obj => obj.showWorkflowsWithDetails }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
130
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
98
131
|
}
|
|
99
|
-
|
|
100
|
-
|
|
132
|
+
project = __runInitializers(this, _instanceExtraInitializers);
|
|
133
|
+
fetchCmd;
|
|
134
|
+
resourceFunctions = {
|
|
135
|
+
calculations: (from) => this.resourceNames('calculations', from),
|
|
136
|
+
cardTypes: (from) => this.resourceNames('cardTypes', from),
|
|
137
|
+
fieldTypes: (from) => this.resourceNames('fieldTypes', from),
|
|
138
|
+
graphModels: (from) => this.resourceNames('graphModels', from),
|
|
139
|
+
graphViews: (from) => this.resourceNames('graphViews', from),
|
|
140
|
+
linkTypes: (from) => this.resourceNames('linkTypes', from),
|
|
141
|
+
reports: (from) => this.resourceNames('reports', from),
|
|
142
|
+
templates: (from) => this.resourceNames('templates', from),
|
|
143
|
+
workflows: (from) => this.resourceNames('workflows', from),
|
|
144
|
+
};
|
|
145
|
+
constructor(project, fetchCmd) {
|
|
146
|
+
this.project = project;
|
|
147
|
+
this.fetchCmd = fetchCmd;
|
|
101
148
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*/
|
|
107
|
-
showAllTemplateCards() {
|
|
108
|
-
return this.project.resources.templates().map((template) => {
|
|
109
|
-
const cards = template.templateObject().listCards();
|
|
110
|
-
const buildCards = buildCardHierarchy(cards);
|
|
111
|
-
return {
|
|
112
|
-
name: template.data?.name || '',
|
|
113
|
-
cards: buildCards,
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Shows all attachments (either template or project attachments) from a project.
|
|
119
|
-
* @returns array of card attachments
|
|
120
|
-
*/
|
|
121
|
-
async showAttachments() {
|
|
122
|
-
const attachments = this.project.attachments();
|
|
123
|
-
const templateAttachments = await this.attachmentsFromTemplates();
|
|
124
|
-
attachments.push(...templateAttachments);
|
|
125
|
-
return attachments;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Returns file buffer and mime type of an attachment. Used by app UI to download attachments.
|
|
129
|
-
* @param cardKey card key to find
|
|
130
|
-
* @param filename attachment filename
|
|
131
|
-
* @returns attachment details
|
|
132
|
-
*/
|
|
133
|
-
showAttachment(cardKey, filename) {
|
|
134
|
-
if (!cardKey) {
|
|
135
|
-
throw new Error(`Mandatory parameter 'cardKey' missing`);
|
|
149
|
+
get logger() {
|
|
150
|
+
return getChildLogger({
|
|
151
|
+
module: 'show',
|
|
152
|
+
});
|
|
136
153
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
154
|
+
// Gets all template attachments
|
|
155
|
+
async attachmentsFromTemplates() {
|
|
156
|
+
const templateAttachments = [];
|
|
157
|
+
const templates = this.project.resources.templates();
|
|
158
|
+
for (const template of templates) {
|
|
159
|
+
const templateObject = template.templateObject();
|
|
160
|
+
if (templateObject) {
|
|
161
|
+
templateAttachments.push(...templateObject.attachments());
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return templateAttachments;
|
|
140
165
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Opens an attachment using a configured application or the operating system's default application.
|
|
149
|
-
* @param cardKey card key of the attachment
|
|
150
|
-
* @param filename attachment filename
|
|
151
|
-
* @param waitDelay amount of time to wait for the application to open the attachment
|
|
152
|
-
* @todo: Move away from Show.
|
|
153
|
-
*/
|
|
154
|
-
async openAttachment(cardKey, filename, waitDelay = 1000) {
|
|
155
|
-
const attachment = this.getAttachment(cardKey, filename);
|
|
156
|
-
if (!attachment) {
|
|
157
|
-
throw new Error(`Attachment '${filename}' not found for card ${cardKey}`);
|
|
166
|
+
// Fetch resource names as a list
|
|
167
|
+
resourceNames(resourceType, from) {
|
|
168
|
+
return this.project.resources
|
|
169
|
+
.resourceTypes(resourceType, from)
|
|
170
|
+
.map((item) => item.data?.name || '');
|
|
158
171
|
}
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
// Collect all labels from cards.
|
|
173
|
+
collectLabels = (cards) => {
|
|
174
|
+
return cards.reduce((labels, card) => {
|
|
175
|
+
// Add the labels from the current card
|
|
176
|
+
if (card.metadata?.labels) {
|
|
177
|
+
labels.push(...card.metadata.labels);
|
|
178
|
+
}
|
|
179
|
+
return labels;
|
|
180
|
+
}, []);
|
|
181
|
+
};
|
|
182
|
+
// Returns attachment details
|
|
183
|
+
getAttachment(cardKey, filename) {
|
|
184
|
+
const card = this.project.findCard(cardKey);
|
|
185
|
+
const attachment = card.attachments?.find((a) => a.fileName === filename) ?? undefined;
|
|
186
|
+
return attachment;
|
|
169
187
|
}
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
188
|
+
// Opens the given path using the operating system's default application. Doesn't block the main thread.
|
|
189
|
+
// @todo: Move away from Show.
|
|
190
|
+
openUsingDefaultApplication(path) {
|
|
191
|
+
if (process.platform === 'win32') {
|
|
192
|
+
// This is a workaround to get windows to open the file in foreground
|
|
193
|
+
spawn(`start`, ['cmd.exe', '/c', 'start', '""', `"${path}"`], {
|
|
194
|
+
shell: true,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
else if (process.platform === 'darwin') {
|
|
198
|
+
spawn('open', [path]);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
spawn('xdg-open', [path]);
|
|
202
|
+
}
|
|
179
203
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Shows all template cards in a project.
|
|
206
|
+
* @returns all template cards in a project.
|
|
207
|
+
*/
|
|
208
|
+
async showAllTemplateCards() {
|
|
209
|
+
return this.project.resources.templates().map((template) => {
|
|
210
|
+
const cards = template.templateObject().listCards();
|
|
211
|
+
const buildCards = buildCardHierarchy(cards);
|
|
212
|
+
return {
|
|
213
|
+
name: template.data?.name || '',
|
|
214
|
+
cards: buildCards,
|
|
215
|
+
};
|
|
216
|
+
});
|
|
191
217
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
attachments
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
details.contentType = contentType;
|
|
218
|
+
/**
|
|
219
|
+
* Shows all attachments (either template or project attachments) from a project.
|
|
220
|
+
* @returns array of card attachments
|
|
221
|
+
*/
|
|
222
|
+
async showAttachments() {
|
|
223
|
+
const attachments = this.project.attachments();
|
|
224
|
+
const templateAttachments = await this.attachmentsFromTemplates();
|
|
225
|
+
attachments.push(...templateAttachments);
|
|
226
|
+
return attachments;
|
|
202
227
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* @returns the content of the logic program.
|
|
217
|
-
*/
|
|
218
|
-
async showCardLogicProgram(cardKey) {
|
|
219
|
-
return this.project.calculationEngine.cardLogicProgram(cardKey);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Shows all card types in a project.
|
|
223
|
-
* @returns array of card type details
|
|
224
|
-
*/
|
|
225
|
-
async showCardTypesWithDetails() {
|
|
226
|
-
const container = [];
|
|
227
|
-
for (const cardType of this.project.resources.cardTypes()) {
|
|
228
|
-
if (cardType.data) {
|
|
229
|
-
container.push(cardType.data);
|
|
228
|
+
/**
|
|
229
|
+
* Returns file buffer and mime type of an attachment. Used by app UI to download attachments.
|
|
230
|
+
* @param cardKey card key to find
|
|
231
|
+
* @param filename attachment filename
|
|
232
|
+
* @returns attachment details
|
|
233
|
+
*/
|
|
234
|
+
async showAttachment(cardKey, filename) {
|
|
235
|
+
if (!cardKey) {
|
|
236
|
+
throw new Error(`Mandatory parameter 'cardKey' missing`);
|
|
237
|
+
}
|
|
238
|
+
const attachment = this.getAttachment(cardKey, filename);
|
|
239
|
+
if (!attachment) {
|
|
240
|
+
throw new Error(`Attachment '${filename}' not found for card ${cardKey}`);
|
|
230
241
|
}
|
|
242
|
+
const attachmentPath = `${attachment.path}/${attachment.fileName}`;
|
|
243
|
+
const fileBuffer = readFileSync(attachmentPath);
|
|
244
|
+
const mimeType = attachment.mimeType || 'application/octet-stream';
|
|
245
|
+
const payload = { fileBuffer, mimeType };
|
|
246
|
+
return payload;
|
|
231
247
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
*/
|
|
244
|
-
async showImportableModules(showAll, showDetails) {
|
|
245
|
-
try {
|
|
246
|
-
// Ensure module list is up to date before showing
|
|
247
|
-
await this.fetchCmd.ensureModuleListUpToDate();
|
|
248
|
-
const moduleList = (await readJsonFile(resolve(this.project.basePath, MODULE_LIST_FULL_PATH))).modules;
|
|
249
|
-
const currentModules = this.project.resources.moduleNames();
|
|
250
|
-
const nonImportedModules = moduleList.filter((item) => {
|
|
251
|
-
return !currentModules.some((module) => item.name === module);
|
|
252
|
-
});
|
|
253
|
-
if (showAll && showDetails) {
|
|
254
|
-
return moduleList;
|
|
248
|
+
/**
|
|
249
|
+
* Opens an attachment using a configured application or the operating system's default application.
|
|
250
|
+
* @param cardKey card key of the attachment
|
|
251
|
+
* @param filename attachment filename
|
|
252
|
+
* @param waitDelay amount of time to wait for the application to open the attachment
|
|
253
|
+
* @todo: Move away from Show.
|
|
254
|
+
*/
|
|
255
|
+
async openAttachment(cardKey, filename, waitDelay = 1000) {
|
|
256
|
+
const attachment = this.getAttachment(cardKey, filename);
|
|
257
|
+
if (!attachment) {
|
|
258
|
+
throw new Error(`Attachment '${filename}' not found for card ${cardKey}`);
|
|
255
259
|
}
|
|
256
|
-
if
|
|
257
|
-
|
|
260
|
+
// Try to open the attachment using a configured application if one exists
|
|
261
|
+
const prefs = new UserPreferences(join(homedir(), '.cyberismo', 'cards.prefs.json')).getPreferences();
|
|
262
|
+
const attachmentEditors = prefs.attachmentEditors && process.platform in prefs.attachmentEditors
|
|
263
|
+
? prefs.attachmentEditors[process.platform]
|
|
264
|
+
: [];
|
|
265
|
+
const editor = attachmentEditors.find((editor) => editor.mimeType === attachment.mimeType);
|
|
266
|
+
const path = resolve(attachment.path, attachment.fileName);
|
|
267
|
+
if (!editor) {
|
|
268
|
+
this.openUsingDefaultApplication(path);
|
|
269
|
+
return;
|
|
258
270
|
}
|
|
259
|
-
|
|
260
|
-
|
|
271
|
+
// We can safely assume that the editor command is safe to execute, since it is defined in the preferences file by the user
|
|
272
|
+
const processHandle = spawn(editor.command.replace('{{attachmentPath}}', path), [], {
|
|
273
|
+
shell: true,
|
|
274
|
+
});
|
|
275
|
+
// wait for the application to open the attachment
|
|
276
|
+
await new Promise((resolve) => setTimeout(resolve, waitDelay));
|
|
277
|
+
// If the application exists with a non-zero exit code, open the attachment using the operating system's default application
|
|
278
|
+
if (processHandle.exitCode !== 0 && processHandle.exitCode !== null) {
|
|
279
|
+
this.openUsingDefaultApplication(path);
|
|
261
280
|
}
|
|
262
|
-
// By default return the non-imported modules
|
|
263
|
-
return nonImportedModules.map((item) => item?.name);
|
|
264
281
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Shows details of a particular card (template card, or project card)
|
|
284
|
+
* @note Note that parameter 'cardKey' is optional due to technical limitations of class calling this class. It must be defined to get valid results.
|
|
285
|
+
* @param cardKey card key to find
|
|
286
|
+
* @param contentType Content format in which content is to be shown
|
|
287
|
+
* @returns card details
|
|
288
|
+
*/
|
|
289
|
+
async showCardDetails(cardKey, contentType) {
|
|
290
|
+
if (!cardKey) {
|
|
291
|
+
throw new Error(`Mandatory parameter 'cardKey' missing`);
|
|
268
292
|
}
|
|
269
|
-
//
|
|
270
|
-
|
|
293
|
+
// todo: Make a constant about this
|
|
294
|
+
const details = {
|
|
295
|
+
parent: true,
|
|
296
|
+
metadata: true,
|
|
297
|
+
children: true,
|
|
298
|
+
attachments: true,
|
|
299
|
+
content: true,
|
|
300
|
+
};
|
|
301
|
+
if (contentType) {
|
|
302
|
+
details.contentType = contentType;
|
|
303
|
+
}
|
|
304
|
+
return this.project.findCard(cardKey, details);
|
|
271
305
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const templateCards = this.project.allTemplateCards();
|
|
280
|
-
const labels = this.collectLabels([...cards, ...templateCards]);
|
|
281
|
-
return Array.from(new Set(labels));
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Shows the content of a logic program.
|
|
285
|
-
* @param resource Name of the resource.
|
|
286
|
-
* @returns the content of the logic program.
|
|
287
|
-
*/
|
|
288
|
-
async showLogicProgram(resource) {
|
|
289
|
-
return this.project.calculationEngine.resourceLogicProgram(resource);
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Shows details of a module.
|
|
293
|
-
* @param moduleName name of a module
|
|
294
|
-
* @returns details of a module.
|
|
295
|
-
*/
|
|
296
|
-
async showModule(moduleName) {
|
|
297
|
-
const moduleDetails = await this.project.module(moduleName);
|
|
298
|
-
if (!moduleDetails) {
|
|
299
|
-
throw new Error(`Module '${moduleName}' does not exist in the project`);
|
|
306
|
+
/**
|
|
307
|
+
* Shows all cards (either template or project cards) from a project.
|
|
308
|
+
* @param cardsFrom - The location from which to look for cards. Either from the project, templates or both.
|
|
309
|
+
* @returns cards list array
|
|
310
|
+
*/
|
|
311
|
+
async showCards(cardsFrom) {
|
|
312
|
+
return this.project.listCards(cardsFrom);
|
|
300
313
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
* @returns all modules in a project.
|
|
322
|
-
*/
|
|
323
|
-
showModules() {
|
|
324
|
-
return this.project.resources.moduleNames().sort();
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Shows details of a particular project.
|
|
328
|
-
* @returns project information
|
|
329
|
-
*/
|
|
330
|
-
async showProject() {
|
|
331
|
-
return this.project.show();
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Shows report results for a given report name and card key.
|
|
335
|
-
* @param reportName Name of the report to show
|
|
336
|
-
* @param cardKey Card key to use for the report
|
|
337
|
-
* @param parameters Additional parameters for the report
|
|
338
|
-
* @param context Context for resource (includes a project instance)
|
|
339
|
-
* @param outputPath Optional output path for the report
|
|
340
|
-
* @returns Report results as a string
|
|
341
|
-
* @throws Error if the report does not exist
|
|
342
|
-
*/
|
|
343
|
-
async showReportResults(reportName, cardKey, parameters, context, outputPath) {
|
|
344
|
-
if (!this.project.resources
|
|
345
|
-
.reports()
|
|
346
|
-
.some((report) => report.data?.name === reportName)) {
|
|
347
|
-
throw new Error(`Report '${reportName}' does not exist`);
|
|
314
|
+
/**
|
|
315
|
+
* Shows the content of a logic program.
|
|
316
|
+
* @param cardKey The key of the card.
|
|
317
|
+
* @returns the content of the logic program.
|
|
318
|
+
*/
|
|
319
|
+
async showCardLogicProgram(cardKey) {
|
|
320
|
+
return this.project.calculationEngine.cardLogicProgram(cardKey);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Shows all card types in a project.
|
|
324
|
+
* @returns array of card type details
|
|
325
|
+
*/
|
|
326
|
+
async showCardTypesWithDetails() {
|
|
327
|
+
const container = [];
|
|
328
|
+
for (const cardType of this.project.resources.cardTypes()) {
|
|
329
|
+
if (cardType.data) {
|
|
330
|
+
container.push(cardType.data);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return container;
|
|
348
334
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
mode: 'static',
|
|
361
|
-
context,
|
|
362
|
-
});
|
|
363
|
-
// Show the results either in the console or write to a file.
|
|
364
|
-
if (outputPath) {
|
|
335
|
+
/**
|
|
336
|
+
* Shows importable modules.
|
|
337
|
+
* @param showAll - When true, shows all importable modules, even if they have already been imported
|
|
338
|
+
* @param showDetails - When true, shows all properties of modules, not just name.
|
|
339
|
+
* @returns list of modules; the list content depends on the parameters provided
|
|
340
|
+
* by default it is a list of module names that could be imported into the project,
|
|
341
|
+
* with 'showDetails' true, instead of name, the list consists of full details of the modules
|
|
342
|
+
* with 'showAll' true, the list consists of all modules in the hubs, even if they have already been imported
|
|
343
|
+
* Note that the two boolean options can be combined.
|
|
344
|
+
*/
|
|
345
|
+
async showImportableModules(showAll, showDetails) {
|
|
365
346
|
try {
|
|
366
|
-
|
|
347
|
+
// Ensure module list is up to date before showing
|
|
348
|
+
await this.fetchCmd.ensureModuleListUpToDate();
|
|
349
|
+
const moduleList = (await readJsonFile(resolve(this.project.basePath, MODULE_LIST_FULL_PATH))).modules;
|
|
350
|
+
const currentModules = this.project.resources.moduleNames();
|
|
351
|
+
const nonImportedModules = moduleList.filter((item) => {
|
|
352
|
+
return !currentModules.some((module) => item.name === module);
|
|
353
|
+
});
|
|
354
|
+
if (showAll && showDetails) {
|
|
355
|
+
return moduleList;
|
|
356
|
+
}
|
|
357
|
+
if (showAll) {
|
|
358
|
+
return moduleList?.map((item) => item?.name);
|
|
359
|
+
}
|
|
360
|
+
if (showDetails) {
|
|
361
|
+
return nonImportedModules;
|
|
362
|
+
}
|
|
363
|
+
// By default return the non-imported modules
|
|
364
|
+
return nonImportedModules.map((item) => item?.name);
|
|
367
365
|
}
|
|
368
366
|
catch (error) {
|
|
369
367
|
if (error instanceof Error) {
|
|
370
|
-
|
|
368
|
+
this.logger.error(error.message);
|
|
371
369
|
}
|
|
370
|
+
// Module list doesn't exist, return empty list
|
|
371
|
+
return [];
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Returns all unique labels in a project
|
|
376
|
+
* @returns labels in a list
|
|
377
|
+
*/
|
|
378
|
+
async showLabels() {
|
|
379
|
+
const cards = flattenCardArray(this.project.showProjectCards(), this.project);
|
|
380
|
+
const templateCards = this.project.allTemplateCards();
|
|
381
|
+
const labels = this.collectLabels([...cards, ...templateCards]);
|
|
382
|
+
return Array.from(new Set(labels));
|
|
383
383
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return
|
|
391
|
-
...details,
|
|
392
|
-
usedIn: [...usage],
|
|
393
|
-
};
|
|
384
|
+
/**
|
|
385
|
+
* Shows the content of a logic program.
|
|
386
|
+
* @param resource Name of the resource.
|
|
387
|
+
* @returns the content of the logic program.
|
|
388
|
+
*/
|
|
389
|
+
async showLogicProgram(resource) {
|
|
390
|
+
return this.project.calculationEngine.resourceLogicProgram(resource);
|
|
394
391
|
}
|
|
395
|
-
|
|
396
|
-
|
|
392
|
+
/**
|
|
393
|
+
* Shows details of a module.
|
|
394
|
+
* @param moduleName name of a module
|
|
395
|
+
* @returns details of a module.
|
|
396
|
+
*/
|
|
397
|
+
async showModule(moduleName) {
|
|
398
|
+
const moduleDetails = await this.project.module(moduleName);
|
|
399
|
+
if (!moduleDetails) {
|
|
400
|
+
throw new Error(`Module '${moduleName}' does not exist in the project`);
|
|
401
|
+
}
|
|
402
|
+
return moduleDetails;
|
|
397
403
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (!func)
|
|
407
|
-
return [];
|
|
408
|
-
return func().sort();
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Shows all templates with full details in a project.
|
|
412
|
-
* @returns all templates in a project.
|
|
413
|
-
*/
|
|
414
|
-
async showTemplatesWithDetails() {
|
|
415
|
-
const templates = [];
|
|
416
|
-
for (const template of this.project.resources.templates()) {
|
|
417
|
-
templates.push(template.show());
|
|
404
|
+
/**
|
|
405
|
+
* Shows hubs of the project.
|
|
406
|
+
* @returns list of hubs.
|
|
407
|
+
*/
|
|
408
|
+
async showHubs() {
|
|
409
|
+
// Ensure module list is up to date before showing
|
|
410
|
+
await this.fetchCmd.ensureModuleListUpToDate();
|
|
411
|
+
return this.project.configuration.hubs;
|
|
418
412
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
showWorkflowsWithDetails() {
|
|
426
|
-
const workflows = [];
|
|
427
|
-
for (const workflow of this.project.resources.workflows()) {
|
|
428
|
-
workflows.push(workflow.data);
|
|
413
|
+
/**
|
|
414
|
+
* Returns all project cards in the project. Cards don't have content and nor metadata.
|
|
415
|
+
* @returns array of cards
|
|
416
|
+
*/
|
|
417
|
+
async showProjectCards() {
|
|
418
|
+
return this.project.showProjectCards();
|
|
429
419
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
420
|
+
/**
|
|
421
|
+
* Shows all modules (if any) in a project.
|
|
422
|
+
* @returns all modules in a project.
|
|
423
|
+
*/
|
|
424
|
+
async showModules() {
|
|
425
|
+
return this.project.resources.moduleNames().sort();
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Shows details of a particular project.
|
|
429
|
+
* @returns project information
|
|
430
|
+
*/
|
|
431
|
+
async showProject() {
|
|
432
|
+
return this.project.show();
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Shows report results for a given report name and card key.
|
|
436
|
+
* @param reportName Name of the report to show
|
|
437
|
+
* @param cardKey Card key to use for the report
|
|
438
|
+
* @param parameters Additional parameters for the report
|
|
439
|
+
* @param context Context for resource (includes a project instance)
|
|
440
|
+
* @param outputPath Optional output path for the report
|
|
441
|
+
* @returns Report results as a string
|
|
442
|
+
* @throws Error if the report does not exist
|
|
443
|
+
*/
|
|
444
|
+
async showReportResults(reportName, cardKey, parameters, context, outputPath) {
|
|
445
|
+
if (!this.project.resources
|
|
446
|
+
.reports()
|
|
447
|
+
.some((report) => report.data?.name === reportName)) {
|
|
448
|
+
throw new Error(`Report '${reportName}' does not exist`);
|
|
449
|
+
}
|
|
450
|
+
await this.project.calculationEngine.generate();
|
|
451
|
+
const reportMacro = new ReportMacro(new TaskQueue());
|
|
452
|
+
let result = await reportMacro.handleStatic({
|
|
453
|
+
project: this.project,
|
|
454
|
+
cardKey: cardKey,
|
|
455
|
+
mode: 'static',
|
|
456
|
+
context,
|
|
457
|
+
}, { name: reportName, ...parameters });
|
|
458
|
+
result = await evaluateMacros(result, {
|
|
459
|
+
project: this.project,
|
|
460
|
+
cardKey: cardKey,
|
|
461
|
+
mode: 'static',
|
|
462
|
+
context,
|
|
463
|
+
});
|
|
464
|
+
// Show the results either in the console or write to a file.
|
|
465
|
+
if (outputPath) {
|
|
466
|
+
try {
|
|
467
|
+
await writeFile(outputPath, result ?? '', 'utf-8');
|
|
468
|
+
}
|
|
469
|
+
catch (error) {
|
|
470
|
+
if (error instanceof Error) {
|
|
471
|
+
throw new Error(`Failed to write report to ${outputPath}: ${error.message}`, { cause: error });
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return outputPath ? '' : (result ?? '');
|
|
476
|
+
}
|
|
477
|
+
async showResource(name, arg2, arg3) {
|
|
478
|
+
return this.project.lock.read(async () => {
|
|
479
|
+
const hasResourceType = typeof arg2 === 'string';
|
|
480
|
+
const resourceType = hasResourceType ? arg2 : null;
|
|
481
|
+
const showUse = hasResourceType ? arg3 : arg2;
|
|
482
|
+
const type = this.project.resources.extractType(name);
|
|
483
|
+
if (resourceType !== null && resourceType !== type) {
|
|
484
|
+
throw new Error(`While fetching '${name}': Expected type '${resourceType}', but got '${type}' instead`);
|
|
485
|
+
}
|
|
486
|
+
const resource = this.project.resources.byType(name, type);
|
|
487
|
+
const [details, usage] = await Promise.all([
|
|
488
|
+
resource?.show(),
|
|
489
|
+
showUse ? resource?.usage() : [],
|
|
490
|
+
]);
|
|
491
|
+
if (showUse) {
|
|
492
|
+
return {
|
|
493
|
+
...details,
|
|
494
|
+
usedIn: [...usage],
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
return details;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Shows all available resources of a given type.
|
|
504
|
+
* @param type Name of resources to return (in plural form, e.g. 'templates')
|
|
505
|
+
* @returns sorted array of resources
|
|
506
|
+
*/
|
|
507
|
+
async showResources(type) {
|
|
508
|
+
const func = this.resourceFunctions[type];
|
|
509
|
+
if (!func)
|
|
510
|
+
return [];
|
|
511
|
+
return func().sort();
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Shows all templates with full details in a project.
|
|
515
|
+
* @returns all templates in a project.
|
|
516
|
+
*/
|
|
517
|
+
async showTemplatesWithDetails() {
|
|
518
|
+
const templates = [];
|
|
519
|
+
for (const template of this.project.resources.templates()) {
|
|
520
|
+
templates.push(template.show());
|
|
521
|
+
}
|
|
522
|
+
return templates;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Shows all workflows with full details in a project.
|
|
526
|
+
* @returns workflows with full details
|
|
527
|
+
*/
|
|
528
|
+
async showWorkflowsWithDetails() {
|
|
529
|
+
const workflows = [];
|
|
530
|
+
for (const workflow of this.project.resources.workflows()) {
|
|
531
|
+
workflows.push(workflow.data);
|
|
532
|
+
}
|
|
533
|
+
return workflows;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
})();
|
|
537
|
+
export { Show };
|
|
433
538
|
//# sourceMappingURL=show.js.map
|