@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.
Files changed (177) hide show
  1. package/dist/command-handler.js +13 -24
  2. package/dist/command-handler.js.map +1 -1
  3. package/dist/command-manager.d.ts +21 -6
  4. package/dist/command-manager.js +34 -32
  5. package/dist/command-manager.js.map +1 -1
  6. package/dist/commands/calculate.js +101 -46
  7. package/dist/commands/calculate.js.map +1 -1
  8. package/dist/commands/create.js +420 -320
  9. package/dist/commands/create.js.map +1 -1
  10. package/dist/commands/edit.js +117 -68
  11. package/dist/commands/edit.js.map +1 -1
  12. package/dist/commands/export.js +301 -252
  13. package/dist/commands/export.js.map +1 -1
  14. package/dist/commands/fetch.js +205 -156
  15. package/dist/commands/fetch.js.map +1 -1
  16. package/dist/commands/import.js +189 -134
  17. package/dist/commands/import.js.map +1 -1
  18. package/dist/commands/migrate.js +91 -45
  19. package/dist/commands/migrate.js.map +1 -1
  20. package/dist/commands/move.js +347 -267
  21. package/dist/commands/move.js.map +1 -1
  22. package/dist/commands/remove.d.ts +1 -0
  23. package/dist/commands/remove.js +202 -135
  24. package/dist/commands/remove.js.map +1 -1
  25. package/dist/commands/rename.js +233 -187
  26. package/dist/commands/rename.js.map +1 -1
  27. package/dist/commands/show.d.ts +8 -8
  28. package/dist/commands/show.js +477 -372
  29. package/dist/commands/show.js.map +1 -1
  30. package/dist/commands/transition.js +119 -73
  31. package/dist/commands/transition.js.map +1 -1
  32. package/dist/commands/update.js +8 -3
  33. package/dist/commands/update.js.map +1 -1
  34. package/dist/commands/validate.js +1 -1
  35. package/dist/commands/validate.js.map +1 -1
  36. package/dist/containers/project/calculation-engine.js +0 -1
  37. package/dist/containers/project/calculation-engine.js.map +1 -1
  38. package/dist/containers/project/card-cache.js +1 -1
  39. package/dist/containers/project/card-cache.js.map +1 -1
  40. package/dist/containers/project.d.ts +16 -0
  41. package/dist/containers/project.js +59 -1
  42. package/dist/containers/project.js.map +1 -1
  43. package/dist/containers/template.js +1 -1
  44. package/dist/containers/template.js.map +1 -1
  45. package/dist/interfaces/command-options.d.ts +1 -0
  46. package/dist/interfaces/resource-interfaces.d.ts +5 -12
  47. package/dist/interfaces/resource-interfaces.js.map +1 -1
  48. package/dist/macros/base-macro.js +1 -1
  49. package/dist/macros/base-macro.js.map +1 -1
  50. package/dist/macros/graph/index.js +3 -1
  51. package/dist/macros/graph/index.js.map +1 -1
  52. package/dist/macros/include/index.js +16 -1
  53. package/dist/macros/include/index.js.map +1 -1
  54. package/dist/macros/include/types.d.ts +15 -12
  55. package/dist/macros/index.js +4 -1
  56. package/dist/macros/index.js.map +1 -1
  57. package/dist/macros/report/index.js +1 -1
  58. package/dist/macros/report/index.js.map +1 -1
  59. package/dist/module-manager.js +5 -3
  60. package/dist/module-manager.js.map +1 -1
  61. package/dist/project-settings.js +2 -2
  62. package/dist/project-settings.js.map +1 -1
  63. package/dist/resources/card-type-resource.js +1 -1
  64. package/dist/resources/card-type-resource.js.map +1 -1
  65. package/dist/resources/create-defaults.js +0 -1
  66. package/dist/resources/create-defaults.js.map +1 -1
  67. package/dist/resources/field-type-resource.js +2 -5
  68. package/dist/resources/field-type-resource.js.map +1 -1
  69. package/dist/resources/file-resource.js +4 -1
  70. package/dist/resources/file-resource.js.map +1 -1
  71. package/dist/resources/folder-resource.d.ts +1 -1
  72. package/dist/resources/folder-resource.js +4 -1
  73. package/dist/resources/folder-resource.js.map +1 -1
  74. package/dist/resources/graph-model-resource.d.ts +1 -8
  75. package/dist/resources/graph-model-resource.js +0 -14
  76. package/dist/resources/graph-model-resource.js.map +1 -1
  77. package/dist/resources/graph-view-resource.d.ts +1 -8
  78. package/dist/resources/graph-view-resource.js +0 -14
  79. package/dist/resources/graph-view-resource.js.map +1 -1
  80. package/dist/resources/link-type-resource.js +1 -1
  81. package/dist/resources/link-type-resource.js.map +1 -1
  82. package/dist/resources/report-resource.d.ts +1 -8
  83. package/dist/resources/report-resource.js +0 -14
  84. package/dist/resources/report-resource.js.map +1 -1
  85. package/dist/resources/resource-object.d.ts +11 -1
  86. package/dist/resources/resource-object.js +19 -2
  87. package/dist/resources/resource-object.js.map +1 -1
  88. package/dist/resources/template-resource.d.ts +1 -9
  89. package/dist/resources/template-resource.js +0 -15
  90. package/dist/resources/template-resource.js.map +1 -1
  91. package/dist/resources/workflow-resource.d.ts +6 -0
  92. package/dist/resources/workflow-resource.js +29 -13
  93. package/dist/resources/workflow-resource.js.map +1 -1
  94. package/dist/utils/card-utils.js +1 -1
  95. package/dist/utils/card-utils.js.map +1 -1
  96. package/dist/utils/commit-context.d.ts +23 -0
  97. package/dist/utils/commit-context.js +30 -0
  98. package/dist/utils/commit-context.js.map +1 -0
  99. package/dist/utils/csv.d.ts +8 -0
  100. package/dist/utils/csv.js +11 -0
  101. package/dist/utils/csv.js.map +1 -1
  102. package/dist/utils/file-utils.js +3 -1
  103. package/dist/utils/file-utils.js.map +1 -1
  104. package/dist/utils/git-manager.d.ts +29 -0
  105. package/dist/utils/git-manager.js +76 -0
  106. package/dist/utils/git-manager.js.map +1 -0
  107. package/dist/utils/handlebars-helpers.d.ts +22 -0
  108. package/dist/utils/handlebars-helpers.js +78 -0
  109. package/dist/utils/handlebars-helpers.js.map +1 -0
  110. package/dist/utils/json.d.ts +17 -10
  111. package/dist/utils/json.js +27 -14
  112. package/dist/utils/json.js.map +1 -1
  113. package/dist/utils/log-utils.d.ts +7 -2
  114. package/dist/utils/log-utils.js +28 -3
  115. package/dist/utils/log-utils.js.map +1 -1
  116. package/dist/utils/report.d.ts +0 -19
  117. package/dist/utils/report.js +4 -63
  118. package/dist/utils/report.js.map +1 -1
  119. package/dist/utils/rw-lock.d.ts +71 -0
  120. package/dist/utils/rw-lock.js +220 -0
  121. package/dist/utils/rw-lock.js.map +1 -0
  122. package/dist/utils/user-preferences.js +3 -3
  123. package/dist/utils/user-preferences.js.map +1 -1
  124. package/package.json +10 -10
  125. package/src/command-handler.ts +14 -22
  126. package/src/command-manager.ts +43 -37
  127. package/src/commands/calculate.ts +8 -1
  128. package/src/commands/create.ts +39 -6
  129. package/src/commands/edit.ts +3 -0
  130. package/src/commands/export.ts +8 -2
  131. package/src/commands/fetch.ts +3 -0
  132. package/src/commands/import.ts +5 -0
  133. package/src/commands/migrate.ts +2 -0
  134. package/src/commands/move.ts +34 -0
  135. package/src/commands/remove.ts +24 -2
  136. package/src/commands/rename.ts +2 -0
  137. package/src/commands/show.ts +63 -34
  138. package/src/commands/transition.ts +2 -0
  139. package/src/commands/update.ts +9 -3
  140. package/src/commands/validate.ts +1 -1
  141. package/src/containers/project/calculation-engine.ts +0 -1
  142. package/src/containers/project/card-cache.ts +1 -0
  143. package/src/containers/project.ts +75 -1
  144. package/src/containers/template.ts +1 -1
  145. package/src/interfaces/command-options.ts +1 -0
  146. package/src/interfaces/resource-interfaces.ts +5 -12
  147. package/src/macros/base-macro.ts +1 -1
  148. package/src/macros/graph/index.ts +3 -0
  149. package/src/macros/include/index.ts +19 -1
  150. package/src/macros/include/types.ts +15 -12
  151. package/src/macros/index.ts +4 -1
  152. package/src/macros/report/index.ts +1 -0
  153. package/src/module-manager.ts +5 -2
  154. package/src/project-settings.ts +2 -1
  155. package/src/resources/card-type-resource.ts +1 -1
  156. package/src/resources/create-defaults.ts +0 -1
  157. package/src/resources/field-type-resource.ts +2 -4
  158. package/src/resources/file-resource.ts +3 -1
  159. package/src/resources/folder-resource.ts +7 -2
  160. package/src/resources/graph-model-resource.ts +1 -25
  161. package/src/resources/graph-view-resource.ts +1 -25
  162. package/src/resources/link-type-resource.ts +1 -1
  163. package/src/resources/report-resource.ts +1 -25
  164. package/src/resources/resource-object.ts +22 -1
  165. package/src/resources/template-resource.ts +0 -23
  166. package/src/resources/workflow-resource.ts +45 -16
  167. package/src/utils/card-utils.ts +1 -1
  168. package/src/utils/commit-context.ts +45 -0
  169. package/src/utils/csv.ts +12 -0
  170. package/src/utils/file-utils.ts +3 -1
  171. package/src/utils/git-manager.ts +87 -0
  172. package/src/utils/handlebars-helpers.ts +95 -0
  173. package/src/utils/json.ts +29 -15
  174. package/src/utils/log-utils.ts +33 -4
  175. package/src/utils/report.ts +8 -74
  176. package/src/utils/rw-lock.ts +279 -0
  177. package/src/utils/user-preferences.ts +3 -0
@@ -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
- export class Show {
31
- project;
32
- fetchCmd;
33
- resourceFunctions = {
34
- calculations: (from) => this.resourceNames('calculations', from),
35
- cardTypes: (from) => this.resourceNames('cardTypes', from),
36
- fieldTypes: (from) => this.resourceNames('fieldTypes', from),
37
- graphModels: (from) => this.resourceNames('graphModels', from),
38
- graphViews: (from) => this.resourceNames('graphViews', from),
39
- linkTypes: (from) => this.resourceNames('linkTypes', from),
40
- reports: (from) => this.resourceNames('reports', from),
41
- templates: (from) => this.resourceNames('templates', from),
42
- workflows: (from) => this.resourceNames('workflows', from),
43
- };
44
- constructor(project, fetchCmd) {
45
- this.project = project;
46
- this.fetchCmd = fetchCmd;
47
- }
48
- get logger() {
49
- return getChildLogger({
50
- module: 'show',
51
- });
52
- }
53
- // Gets all template attachments
54
- async attachmentsFromTemplates() {
55
- const templateAttachments = [];
56
- const templates = this.project.resources.templates();
57
- for (const template of templates) {
58
- const templateObject = template.templateObject();
59
- if (templateObject) {
60
- templateAttachments.push(...templateObject.attachments());
61
- }
62
- }
63
- return templateAttachments;
64
- }
65
- // Fetch resource names as a list
66
- resourceNames(resourceType, from) {
67
- return this.project.resources
68
- .resourceTypes(resourceType, from)
69
- .map((item) => item.data?.name || '');
70
- }
71
- // Collect all labels from cards.
72
- collectLabels = (cards) => {
73
- return cards.reduce((labels, card) => {
74
- // Add the labels from the current card
75
- if (card.metadata?.labels) {
76
- labels.push(...card.metadata.labels);
77
- }
78
- return labels;
79
- }, []);
80
- };
81
- // Returns attachment details
82
- getAttachment(cardKey, filename) {
83
- const card = this.project.findCard(cardKey);
84
- const attachment = card.attachments?.find((a) => a.fileName === filename) ?? undefined;
85
- return attachment;
86
- }
87
- // Opens the given path using the operating system's default application. Doesn't block the main thread.
88
- // @todo: Move away from Show.
89
- openUsingDefaultApplication(path) {
90
- if (process.platform === 'win32') {
91
- // This is a workaround to get windows to open the file in foreground
92
- spawn(`start`, ['cmd.exe', '/c', 'start', '""', `"${path}"`], {
93
- shell: true,
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
- else {
100
- spawn('xdg-open', [path]);
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
- * Shows all template cards in a project.
105
- * @returns all template cards in a project.
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
- const attachment = this.getAttachment(cardKey, filename);
138
- if (!attachment) {
139
- throw new Error(`Attachment '${filename}' not found for card ${cardKey}`);
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
- const attachmentPath = `${attachment.path}/${attachment.fileName}`;
142
- const fileBuffer = readFileSync(attachmentPath);
143
- const mimeType = attachment.mimeType || 'application/octet-stream';
144
- const payload = { fileBuffer, mimeType };
145
- return payload;
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
- // Try to open the attachment using a configured application if one exists
160
- const prefs = new UserPreferences(join(homedir(), '.cyberismo', 'cards.prefs.json')).getPreferences();
161
- const attachmentEditors = prefs.attachmentEditors && process.platform in prefs.attachmentEditors
162
- ? prefs.attachmentEditors[process.platform]
163
- : [];
164
- const editor = attachmentEditors.find((editor) => editor.mimeType === attachment.mimeType);
165
- const path = resolve(attachment.path, attachment.fileName);
166
- if (!editor) {
167
- this.openUsingDefaultApplication(path);
168
- return;
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
- // We can safely assume that the editor command is safe to execute, since it is defined in the preferences file by the user
171
- const processHandle = spawn(editor.command.replace('{{attachmentPath}}', path), [], {
172
- shell: true,
173
- });
174
- // wait for the application to open the attachment
175
- await new Promise((resolve) => setTimeout(resolve, waitDelay));
176
- // If the application exists with a non-zero exit code, open the attachment using the operating system's default application
177
- if (processHandle.exitCode !== 0 && processHandle.exitCode !== null) {
178
- this.openUsingDefaultApplication(path);
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
- * Shows details of a particular card (template card, or project card)
183
- * @note Note that parameter 'cardKey' is optional due to technical limitations of class calling this class. It must be defined to get valid results.
184
- * @param cardKey card key to find
185
- * @param contentType Content format in which content is to be shown
186
- * @returns card details
187
- */
188
- showCardDetails(cardKey, contentType) {
189
- if (!cardKey) {
190
- throw new Error(`Mandatory parameter 'cardKey' missing`);
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
- // todo: Make a constant about this
193
- const details = {
194
- parent: true,
195
- metadata: true,
196
- children: true,
197
- attachments: true,
198
- content: true,
199
- };
200
- if (contentType) {
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
- return this.project.findCard(cardKey, details);
204
- }
205
- /**
206
- * Shows all cards (either template or project cards) from a project.
207
- * @param cardsFrom - The location from which to look for cards. Either from the project, templates or both.
208
- * @returns cards list array
209
- */
210
- async showCards(cardsFrom) {
211
- return this.project.listCards(cardsFrom);
212
- }
213
- /**
214
- * Shows the content of a logic program.
215
- * @param cardKey The key of the card.
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
- return container;
233
- }
234
- /**
235
- * Shows importable modules.
236
- * @param showAll - When true, shows all importable modules, even if they have already been imported
237
- * @param showDetails - When true, shows all properties of modules, not just name.
238
- * @returns list of modules; the list content depends on the parameters provided
239
- * by default it is a list of module names that could be imported into the project,
240
- * with 'showDetails' true, instead of name, the list consists of full details of the modules
241
- * with 'showAll' true, the list consists of all modules in the hubs, even if they have already been imported
242
- * Note that the two boolean options can be combined.
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 (showAll) {
257
- return moduleList?.map((item) => item?.name);
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
- if (showDetails) {
260
- return nonImportedModules;
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
- catch (error) {
266
- if (error instanceof Error) {
267
- this.logger.error(error.message);
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
- // Module list doesn't exist, return empty list
270
- return [];
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
- * Returns all unique labels in a project
275
- * @returns labels in a list
276
- */
277
- showLabels() {
278
- const cards = flattenCardArray(this.project.showProjectCards(), this.project);
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
- return moduleDetails;
302
- }
303
- /**
304
- * Shows hubs of the project.
305
- * @returns list of hubs.
306
- */
307
- async showHubs() {
308
- // Ensure module list is up to date before showing
309
- await this.fetchCmd.ensureModuleListUpToDate();
310
- return this.project.configuration.hubs;
311
- }
312
- /**
313
- * Returns all project cards in the project. Cards don't have content and nor metadata.
314
- * @returns array of cards
315
- */
316
- showProjectCards() {
317
- return this.project.showProjectCards();
318
- }
319
- /**
320
- * Shows all modules (if any) in a project.
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
- await this.project.calculationEngine.generate();
350
- const reportMacro = new ReportMacro(new TaskQueue());
351
- let result = await reportMacro.handleStatic({
352
- project: this.project,
353
- cardKey: cardKey,
354
- mode: 'static',
355
- context,
356
- }, { name: reportName, ...parameters });
357
- result = await evaluateMacros(result, {
358
- project: this.project,
359
- cardKey: cardKey,
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
- await writeFile(outputPath, result ?? '', 'utf-8');
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
- throw new Error(`Failed to write report to ${outputPath}: ${error.message}`);
368
+ this.logger.error(error.message);
371
369
  }
370
+ // Module list doesn't exist, return empty list
371
+ return [];
372
372
  }
373
373
  }
374
- return outputPath ? '' : (result ?? '');
375
- }
376
- async showResource(name, arg2, arg3) {
377
- const hasResourceType = typeof arg2 === 'string';
378
- const resourceType = hasResourceType ? arg2 : null;
379
- const showUse = hasResourceType ? arg3 : arg2;
380
- const type = this.project.resources.extractType(name);
381
- if (resourceType !== null && resourceType !== type) {
382
- throw new Error(`While fetching '${name}': Expected type '${resourceType}', but got '${type}' instead`);
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
- const resource = this.project.resources.byType(name, type);
385
- const [details, usage] = await Promise.all([
386
- resource?.show(),
387
- showUse ? resource?.usage() : [],
388
- ]);
389
- if (showUse) {
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
- else {
396
- return details;
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
- * Shows all available resources of a given type.
401
- * @param type Name of resources to return (in plural form, e.g. 'templates')
402
- * @returns sorted array of resources
403
- */
404
- async showResources(type) {
405
- const func = this.resourceFunctions[type];
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
- return templates;
420
- }
421
- /**
422
- * Shows all workflows with full details in a project.
423
- * @returns workflows with full details
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
- return workflows;
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