@cyberismo/data-handler 0.0.2

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 (306) hide show
  1. package/LICENSE +702 -0
  2. package/dist/card-metadata-updater.d.ts +33 -0
  3. package/dist/card-metadata-updater.js +121 -0
  4. package/dist/card-metadata-updater.js.map +1 -0
  5. package/dist/command-handler.d.ts +96 -0
  6. package/dist/command-handler.js +557 -0
  7. package/dist/command-handler.js.map +1 -0
  8. package/dist/command-manager.d.ts +43 -0
  9. package/dist/command-manager.js +73 -0
  10. package/dist/command-manager.js.map +1 -0
  11. package/dist/commands/calculate.d.ts +86 -0
  12. package/dist/commands/calculate.js +444 -0
  13. package/dist/commands/calculate.js.map +1 -0
  14. package/dist/commands/create.d.ts +114 -0
  15. package/dist/commands/create.js +389 -0
  16. package/dist/commands/create.js.map +1 -0
  17. package/dist/commands/edit.d.ts +37 -0
  18. package/dist/commands/edit.js +99 -0
  19. package/dist/commands/edit.js.map +1 -0
  20. package/dist/commands/export-site.d.ts +45 -0
  21. package/dist/commands/export-site.js +301 -0
  22. package/dist/commands/export-site.js.map +1 -0
  23. package/dist/commands/export.d.ts +53 -0
  24. package/dist/commands/export.js +251 -0
  25. package/dist/commands/export.js.map +1 -0
  26. package/dist/commands/import.d.ts +53 -0
  27. package/dist/commands/import.js +133 -0
  28. package/dist/commands/import.js.map +1 -0
  29. package/dist/commands/index.d.ts +26 -0
  30. package/dist/commands/index.js +27 -0
  31. package/dist/commands/index.js.map +1 -0
  32. package/dist/commands/move.d.ts +55 -0
  33. package/dist/commands/move.js +341 -0
  34. package/dist/commands/move.js.map +1 -0
  35. package/dist/commands/remove.d.ts +38 -0
  36. package/dist/commands/remove.js +192 -0
  37. package/dist/commands/remove.js.map +1 -0
  38. package/dist/commands/rename.d.ts +46 -0
  39. package/dist/commands/rename.js +289 -0
  40. package/dist/commands/rename.js.map +1 -0
  41. package/dist/commands/show.d.ts +124 -0
  42. package/dist/commands/show.js +345 -0
  43. package/dist/commands/show.js.map +1 -0
  44. package/dist/commands/transition.d.ts +27 -0
  45. package/dist/commands/transition.js +92 -0
  46. package/dist/commands/transition.js.map +1 -0
  47. package/dist/commands/update.d.ts +29 -0
  48. package/dist/commands/update.js +64 -0
  49. package/dist/commands/update.js.map +1 -0
  50. package/dist/commands/validate.d.ts +143 -0
  51. package/dist/commands/validate.js +689 -0
  52. package/dist/commands/validate.js.map +1 -0
  53. package/dist/containers/card-container.d.ts +44 -0
  54. package/dist/containers/card-container.js +282 -0
  55. package/dist/containers/card-container.js.map +1 -0
  56. package/dist/containers/project/project-paths.d.ts +46 -0
  57. package/dist/containers/project/project-paths.js +105 -0
  58. package/dist/containers/project/project-paths.js.map +1 -0
  59. package/dist/containers/project/resource-collector.d.ts +86 -0
  60. package/dist/containers/project/resource-collector.js +331 -0
  61. package/dist/containers/project/resource-collector.js.map +1 -0
  62. package/dist/containers/project.d.ts +351 -0
  63. package/dist/containers/project.js +896 -0
  64. package/dist/containers/project.js.map +1 -0
  65. package/dist/containers/template.d.ts +108 -0
  66. package/dist/containers/template.js +433 -0
  67. package/dist/containers/template.js.map +1 -0
  68. package/dist/exceptions/index.d.ts +19 -0
  69. package/dist/exceptions/index.js +26 -0
  70. package/dist/exceptions/index.js.map +1 -0
  71. package/dist/index.d.ts +16 -0
  72. package/dist/index.js +15 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/interfaces/adoc.d.ts +12 -0
  75. package/dist/interfaces/adoc.js +13 -0
  76. package/dist/interfaces/adoc.js.map +1 -0
  77. package/dist/interfaces/macros.d.ts +45 -0
  78. package/dist/interfaces/macros.js +13 -0
  79. package/dist/interfaces/macros.js.map +1 -0
  80. package/dist/interfaces/project-interfaces.d.ts +121 -0
  81. package/dist/interfaces/project-interfaces.js +21 -0
  82. package/dist/interfaces/project-interfaces.js.map +1 -0
  83. package/dist/interfaces/request-status-interfaces.d.ts +28 -0
  84. package/dist/interfaces/request-status-interfaces.js +20 -0
  85. package/dist/interfaces/request-status-interfaces.js.map +1 -0
  86. package/dist/interfaces/resource-interfaces.d.ts +117 -0
  87. package/dist/interfaces/resource-interfaces.js +20 -0
  88. package/dist/interfaces/resource-interfaces.js.map +1 -0
  89. package/dist/macros/base-macro.d.ts +31 -0
  90. package/dist/macros/base-macro.js +126 -0
  91. package/dist/macros/base-macro.js.map +1 -0
  92. package/dist/macros/common.d.ts +17 -0
  93. package/dist/macros/common.js +23 -0
  94. package/dist/macros/common.js.map +1 -0
  95. package/dist/macros/createCards/index.d.ts +36 -0
  96. package/dist/macros/createCards/index.js +35 -0
  97. package/dist/macros/createCards/index.js.map +1 -0
  98. package/dist/macros/createCards/metadata.d.ts +14 -0
  99. package/dist/macros/createCards/metadata.js +18 -0
  100. package/dist/macros/createCards/metadata.js.map +1 -0
  101. package/dist/macros/graph/index.d.ts +29 -0
  102. package/dist/macros/graph/index.js +91 -0
  103. package/dist/macros/graph/index.js.map +1 -0
  104. package/dist/macros/graph/metadata.d.ts +14 -0
  105. package/dist/macros/graph/metadata.js +18 -0
  106. package/dist/macros/graph/metadata.js.map +1 -0
  107. package/dist/macros/index.d.ts +93 -0
  108. package/dist/macros/index.js +237 -0
  109. package/dist/macros/index.js.map +1 -0
  110. package/dist/macros/report/index.d.ts +26 -0
  111. package/dist/macros/report/index.js +70 -0
  112. package/dist/macros/report/index.js.map +1 -0
  113. package/dist/macros/report/metadata.d.ts +14 -0
  114. package/dist/macros/report/metadata.js +18 -0
  115. package/dist/macros/report/metadata.js.map +1 -0
  116. package/dist/macros/scoreCard/index.d.ts +30 -0
  117. package/dist/macros/scoreCard/index.js +38 -0
  118. package/dist/macros/scoreCard/index.js.map +1 -0
  119. package/dist/macros/scoreCard/metadata.d.ts +14 -0
  120. package/dist/macros/scoreCard/metadata.js +18 -0
  121. package/dist/macros/scoreCard/metadata.js.map +1 -0
  122. package/dist/macros/task-queue.d.ts +46 -0
  123. package/dist/macros/task-queue.js +69 -0
  124. package/dist/macros/task-queue.js.map +1 -0
  125. package/dist/module-manager.d.ts +62 -0
  126. package/dist/module-manager.js +350 -0
  127. package/dist/module-manager.js.map +1 -0
  128. package/dist/permissions/action-guard.d.ts +28 -0
  129. package/dist/permissions/action-guard.js +61 -0
  130. package/dist/permissions/action-guard.js.map +1 -0
  131. package/dist/project-settings.d.ts +42 -0
  132. package/dist/project-settings.js +120 -0
  133. package/dist/project-settings.js.map +1 -0
  134. package/dist/resources/array-handler.d.ts +28 -0
  135. package/dist/resources/array-handler.js +116 -0
  136. package/dist/resources/array-handler.js.map +1 -0
  137. package/dist/resources/card-type-resource.d.ts +72 -0
  138. package/dist/resources/card-type-resource.js +334 -0
  139. package/dist/resources/card-type-resource.js.map +1 -0
  140. package/dist/resources/create-defaults.d.ts +81 -0
  141. package/dist/resources/create-defaults.js +184 -0
  142. package/dist/resources/create-defaults.js.map +1 -0
  143. package/dist/resources/field-type-resource.d.ts +88 -0
  144. package/dist/resources/field-type-resource.js +411 -0
  145. package/dist/resources/field-type-resource.js.map +1 -0
  146. package/dist/resources/file-resource.d.ts +50 -0
  147. package/dist/resources/file-resource.js +301 -0
  148. package/dist/resources/file-resource.js.map +1 -0
  149. package/dist/resources/folder-resource.d.ts +66 -0
  150. package/dist/resources/folder-resource.js +100 -0
  151. package/dist/resources/folder-resource.js.map +1 -0
  152. package/dist/resources/graph-model-resource.d.ts +78 -0
  153. package/dist/resources/graph-model-resource.js +164 -0
  154. package/dist/resources/graph-model-resource.js.map +1 -0
  155. package/dist/resources/graph-view-resource.d.ts +78 -0
  156. package/dist/resources/graph-view-resource.js +163 -0
  157. package/dist/resources/graph-view-resource.js.map +1 -0
  158. package/dist/resources/link-type-resource.d.ts +62 -0
  159. package/dist/resources/link-type-resource.js +150 -0
  160. package/dist/resources/link-type-resource.js.map +1 -0
  161. package/dist/resources/report-resource.d.ts +77 -0
  162. package/dist/resources/report-resource.js +171 -0
  163. package/dist/resources/report-resource.js.map +1 -0
  164. package/dist/resources/resource-object.d.ts +108 -0
  165. package/dist/resources/resource-object.js +147 -0
  166. package/dist/resources/resource-object.js.map +1 -0
  167. package/dist/resources/template-resource.d.ts +82 -0
  168. package/dist/resources/template-resource.js +173 -0
  169. package/dist/resources/template-resource.js.map +1 -0
  170. package/dist/resources/workflow-resource.d.ts +67 -0
  171. package/dist/resources/workflow-resource.js +156 -0
  172. package/dist/resources/workflow-resource.js.map +1 -0
  173. package/dist/types/queries.d.ts +142 -0
  174. package/dist/types/queries.js +16 -0
  175. package/dist/types/queries.js.map +1 -0
  176. package/dist/utils/card-utils.d.ts +34 -0
  177. package/dist/utils/card-utils.js +78 -0
  178. package/dist/utils/card-utils.js.map +1 -0
  179. package/dist/utils/clingo-fact-builder.d.ts +58 -0
  180. package/dist/utils/clingo-fact-builder.js +126 -0
  181. package/dist/utils/clingo-fact-builder.js.map +1 -0
  182. package/dist/utils/clingo-facts.d.ts +97 -0
  183. package/dist/utils/clingo-facts.js +352 -0
  184. package/dist/utils/clingo-facts.js.map +1 -0
  185. package/dist/utils/clingo-parser.d.ts +59 -0
  186. package/dist/utils/clingo-parser.js +403 -0
  187. package/dist/utils/clingo-parser.js.map +1 -0
  188. package/dist/utils/clingo-program-builder.d.ts +39 -0
  189. package/dist/utils/clingo-program-builder.js +57 -0
  190. package/dist/utils/clingo-program-builder.js.map +1 -0
  191. package/dist/utils/common-utils.d.ts +24 -0
  192. package/dist/utils/common-utils.js +47 -0
  193. package/dist/utils/common-utils.js.map +1 -0
  194. package/dist/utils/constants.d.ts +18 -0
  195. package/dist/utils/constants.js +27 -0
  196. package/dist/utils/constants.js.map +1 -0
  197. package/dist/utils/csv.d.ts +18 -0
  198. package/dist/utils/csv.js +45 -0
  199. package/dist/utils/csv.js.map +1 -0
  200. package/dist/utils/file-utils.d.ts +69 -0
  201. package/dist/utils/file-utils.js +158 -0
  202. package/dist/utils/file-utils.js.map +1 -0
  203. package/dist/utils/json.d.ts +61 -0
  204. package/dist/utils/json.js +108 -0
  205. package/dist/utils/json.js.map +1 -0
  206. package/dist/utils/lexorank.d.ts +59 -0
  207. package/dist/utils/lexorank.js +159 -0
  208. package/dist/utils/lexorank.js.map +1 -0
  209. package/dist/utils/log-utils.d.ts +40 -0
  210. package/dist/utils/log-utils.js +109 -0
  211. package/dist/utils/log-utils.js.map +1 -0
  212. package/dist/utils/random.d.ts +19 -0
  213. package/dist/utils/random.js +34 -0
  214. package/dist/utils/random.js.map +1 -0
  215. package/dist/utils/resource-utils.d.ts +45 -0
  216. package/dist/utils/resource-utils.js +137 -0
  217. package/dist/utils/resource-utils.js.map +1 -0
  218. package/dist/utils/sanitize-svg.d.ts +18 -0
  219. package/dist/utils/sanitize-svg.js +38 -0
  220. package/dist/utils/sanitize-svg.js.map +1 -0
  221. package/dist/utils/user-preferences.d.ts +64 -0
  222. package/dist/utils/user-preferences.js +106 -0
  223. package/dist/utils/user-preferences.js.map +1 -0
  224. package/dist/utils/validate.d.ts +26 -0
  225. package/dist/utils/validate.js +53 -0
  226. package/dist/utils/validate.js.map +1 -0
  227. package/dist/utils/value-utils.d.ts +58 -0
  228. package/dist/utils/value-utils.js +181 -0
  229. package/dist/utils/value-utils.js.map +1 -0
  230. package/package.json +67 -0
  231. package/src/card-metadata-updater.ts +182 -0
  232. package/src/command-handler.ts +686 -0
  233. package/src/command-manager.ts +99 -0
  234. package/src/commands/calculate.ts +591 -0
  235. package/src/commands/create.ts +559 -0
  236. package/src/commands/edit.ts +123 -0
  237. package/src/commands/export-site.ts +356 -0
  238. package/src/commands/export.ts +315 -0
  239. package/src/commands/import.ts +169 -0
  240. package/src/commands/index.ts +42 -0
  241. package/src/commands/move.ts +451 -0
  242. package/src/commands/remove.ts +244 -0
  243. package/src/commands/rename.ts +378 -0
  244. package/src/commands/show.ts +442 -0
  245. package/src/commands/transition.ts +127 -0
  246. package/src/commands/update.ts +76 -0
  247. package/src/commands/validate.ts +962 -0
  248. package/src/containers/card-container.ts +378 -0
  249. package/src/containers/project/project-paths.ts +127 -0
  250. package/src/containers/project/resource-collector.ts +379 -0
  251. package/src/containers/project.ts +1135 -0
  252. package/src/containers/template.ts +573 -0
  253. package/src/exceptions/index.ts +29 -0
  254. package/src/index.ts +33 -0
  255. package/src/interfaces/adoc.ts +18 -0
  256. package/src/interfaces/macros.ts +54 -0
  257. package/src/interfaces/project-interfaces.ts +208 -0
  258. package/src/interfaces/request-status-interfaces.ts +30 -0
  259. package/src/interfaces/resource-interfaces.ts +179 -0
  260. package/src/macros/base-macro.ts +176 -0
  261. package/src/macros/common.ts +24 -0
  262. package/src/macros/createCards/index.ts +57 -0
  263. package/src/macros/createCards/metadata.ts +21 -0
  264. package/src/macros/graph/index.ts +130 -0
  265. package/src/macros/graph/metadata.ts +21 -0
  266. package/src/macros/index.ts +321 -0
  267. package/src/macros/report/index.ts +88 -0
  268. package/src/macros/report/metadata.ts +21 -0
  269. package/src/macros/scoreCard/index.ts +55 -0
  270. package/src/macros/scoreCard/metadata.ts +21 -0
  271. package/src/macros/task-queue.ts +79 -0
  272. package/src/module-manager.ts +443 -0
  273. package/src/permissions/action-guard.ts +77 -0
  274. package/src/project-settings.ts +140 -0
  275. package/src/resources/array-handler.ts +141 -0
  276. package/src/resources/card-type-resource.ts +455 -0
  277. package/src/resources/create-defaults.ts +216 -0
  278. package/src/resources/field-type-resource.ts +533 -0
  279. package/src/resources/file-resource.ts +433 -0
  280. package/src/resources/folder-resource.ts +140 -0
  281. package/src/resources/graph-model-resource.ts +205 -0
  282. package/src/resources/graph-view-resource.ts +199 -0
  283. package/src/resources/link-type-resource.ts +191 -0
  284. package/src/resources/report-resource.ts +224 -0
  285. package/src/resources/resource-object.ts +246 -0
  286. package/src/resources/template-resource.ts +210 -0
  287. package/src/resources/workflow-resource.ts +205 -0
  288. package/src/types/queries.ts +149 -0
  289. package/src/utils/card-utils.ts +83 -0
  290. package/src/utils/clingo-fact-builder.ts +167 -0
  291. package/src/utils/clingo-facts.ts +550 -0
  292. package/src/utils/clingo-parser.ts +519 -0
  293. package/src/utils/clingo-program-builder.ts +71 -0
  294. package/src/utils/common-utils.ts +54 -0
  295. package/src/utils/constants.ts +32 -0
  296. package/src/utils/csv.ts +53 -0
  297. package/src/utils/file-utils.ts +182 -0
  298. package/src/utils/json.ts +118 -0
  299. package/src/utils/lexorank.ts +180 -0
  300. package/src/utils/log-utils.ts +127 -0
  301. package/src/utils/random.ts +37 -0
  302. package/src/utils/resource-utils.ts +180 -0
  303. package/src/utils/sanitize-svg.ts +46 -0
  304. package/src/utils/user-preferences.ts +126 -0
  305. package/src/utils/validate.ts +66 -0
  306. package/src/utils/value-utils.ts +189 -0
@@ -0,0 +1,124 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2024
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import type { attachmentPayload } from '../interfaces/request-status-interfaces.js';
14
+ import type { CardAttachment, Card, CardListContainer, ModuleContent, ProjectFetchCardDetails, ProjectMetadata } from '../interfaces/project-interfaces.js';
15
+ import type { CardType, ResourceContent, TemplateConfiguration, Workflow } from '../interfaces/resource-interfaces.js';
16
+ import { Project } from '../containers/project.js';
17
+ /**
18
+ * Show command.
19
+ */
20
+ export declare class Show {
21
+ private project;
22
+ private resourceFunction;
23
+ constructor(project: Project);
24
+ private collectLabels;
25
+ private getAttachment;
26
+ private openUsingDefaultApplication;
27
+ /**
28
+ * Shows all attachments (either template or project attachments) from a project.
29
+ * @returns array of card attachments
30
+ */
31
+ showAttachments(): Promise<CardAttachment[]>;
32
+ /**
33
+ * Returns file buffer and mime type of an attachment. Used by app UI to download attachments.
34
+ * @param cardKey card key to find
35
+ * @param filename attachment filename
36
+ * @returns attachment details
37
+ */
38
+ showAttachment(cardKey: string, filename: string): Promise<attachmentPayload>;
39
+ /**
40
+ * Opens an attachment using a configured application or the operating system's default application.
41
+ * @param cardKey card key of the attachment
42
+ * @param filename attachment filename
43
+ * @param waitDelay amount of time to wait for the application to open the attachment
44
+ * @todo: Move away from Show.
45
+ */
46
+ openAttachment(cardKey: string, filename: string, waitDelay?: number): Promise<void>;
47
+ /**
48
+ * Shows details of a particular card (template card, or project card)
49
+ * @note Note that parameter 'cardKey' is optional due to technical limitations of class calling this class. It must be defined to get valid results.
50
+ * @param details card details to show
51
+ * @param cardKey card key to find
52
+ * @returns card details
53
+ */
54
+ showCardDetails(details: ProjectFetchCardDetails, cardKey?: string): Promise<Card>;
55
+ /**
56
+ * Shows all cards (either template or project cards) from a project.
57
+ * @returns cards list array
58
+ */
59
+ showCards(): Promise<CardListContainer[]>;
60
+ /**
61
+ * Shows all card types in a project.
62
+ * @returns array of card type details
63
+ */
64
+ showCardTypesWithDetails(): Promise<(CardType | undefined)[]>;
65
+ /**
66
+ * Returns all unique labels in a project
67
+ * @returns labels in a list
68
+ */
69
+ showLabels(): Promise<string[]>;
70
+ /**
71
+ * Shows details of a module.
72
+ * @param moduleName name of a module
73
+ * @returns details of a module.
74
+ */
75
+ showModule(moduleName: string): Promise<ModuleContent>;
76
+ /**
77
+ * Returns all project cards in the project. Cards don't have content and nor metadata.
78
+ * @note AppUi uses this method.
79
+ * @returns array of cards
80
+ */
81
+ showProjectCards(): Promise<Card[]>;
82
+ /**
83
+ * Shows all modules (if any) in a project.
84
+ * @returns all modules in a project.
85
+ */
86
+ showModules(): Promise<string[]>;
87
+ /**
88
+ * Shows details of a particular project.
89
+ * @returns project information
90
+ */
91
+ showProject(): Promise<ProjectMetadata>;
92
+ /**
93
+ * Shows report results for a given report name and card key.
94
+ * @param reportName Name of the report to show
95
+ * @param cardKey Card key to use for the report
96
+ * @param parameters Additional parameters for the report
97
+ * @param outputPath Optional output path for the report
98
+ * @returns Report results as a string
99
+ * @throws Error if the report does not exist
100
+ */
101
+ showReportResults(reportName: string, cardKey: string, parameters: object, outputPath?: string): Promise<string>;
102
+ /**
103
+ * Shows details of certain resource.
104
+ * @param name Name of resource.
105
+ * @returns resource metadata as JSON.
106
+ */
107
+ showResource(name: string, showUse?: boolean): Promise<ResourceContent | undefined>;
108
+ /**
109
+ * Shows all available resources of a given type.
110
+ * @param type Name of resources to return (in plural form, e.g. 'templates')
111
+ * @returns sorted array of resources
112
+ */
113
+ showResources(type: string): Promise<string[]>;
114
+ /**
115
+ * Shows all templates with full details in a project.
116
+ * @returns all templates in a project.
117
+ */
118
+ showTemplatesWithDetails(): Promise<TemplateConfiguration[]>;
119
+ /**
120
+ * Shows all workflows with full details in a project.
121
+ * @returns workflows with full details
122
+ */
123
+ showWorkflowsWithDetails(): Promise<(Workflow | undefined)[]>;
124
+ }
@@ -0,0 +1,345 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2024
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ // node
14
+ import { existsSync, readFileSync } from 'node:fs';
15
+ import { homedir } from 'node:os';
16
+ import { join, resolve } from 'node:path';
17
+ import { spawn } from 'node:child_process';
18
+ import { writeFile } from 'node:fs/promises';
19
+ import mime from 'mime-types';
20
+ import { Project } from '../containers/project.js';
21
+ import { resourceName } from '../utils/resource-utils.js';
22
+ import { TemplateResource } from '../resources/template-resource.js';
23
+ import { UserPreferences } from '../utils/user-preferences.js';
24
+ import ReportMacro from '../macros/report/index.js';
25
+ import TaskQueue from '../macros/task-queue.js';
26
+ /**
27
+ * Show command.
28
+ */
29
+ export class Show {
30
+ project;
31
+ resourceFunction;
32
+ constructor(project) {
33
+ this.project = project;
34
+ this.resourceFunction = new Map([
35
+ ['cardTypes', this.project.cardTypes.bind(this.project)],
36
+ ['fieldTypes', this.project.fieldTypes.bind(this.project)],
37
+ ['graphModels', this.project.graphModels.bind(this.project)],
38
+ ['graphViews', this.project.graphViews.bind(this.project)],
39
+ ['linkTypes', this.project.linkTypes.bind(this.project)],
40
+ ['reports', this.project.reports.bind(this.project)],
41
+ ['templates', this.project.templates.bind(this.project)],
42
+ ['workflows', this.project.workflows.bind(this.project)],
43
+ ]);
44
+ }
45
+ // Collect all labels from cards.
46
+ collectLabels = (cards) => {
47
+ return cards.reduce((labels, card) => {
48
+ // Add the labels from the current card
49
+ if (card.metadata?.labels) {
50
+ labels.push(...card.metadata.labels);
51
+ }
52
+ // Recursively collect labels from subcards, if they exist
53
+ if (card.children) {
54
+ labels.push(...this.collectLabels(card.children));
55
+ }
56
+ return labels;
57
+ }, []);
58
+ };
59
+ // Returns attachment details
60
+ async getAttachment(cardKey, filename) {
61
+ const details = {
62
+ content: false,
63
+ metadata: true,
64
+ children: false,
65
+ parent: false,
66
+ attachments: true,
67
+ };
68
+ const card = await this.project.cardDetailsById(cardKey, details);
69
+ if (card === undefined) {
70
+ throw new Error(`Card '${cardKey}' does not exist in the project`);
71
+ }
72
+ const attachment = card.attachments?.find((a) => a.fileName === filename) ?? undefined;
73
+ return attachment;
74
+ }
75
+ // Opens the given path using the operating system's default application. Doesn't block the main thread.
76
+ // @todo: Move away from Show.
77
+ openUsingDefaultApplication(path) {
78
+ if (process.platform === 'win32') {
79
+ // This is a workaround to get windows to open the file in foreground
80
+ spawn(`start`, ['cmd.exe', '/c', 'start', '""', `"${path}"`], {
81
+ shell: true,
82
+ });
83
+ }
84
+ else if (process.platform === 'darwin') {
85
+ spawn('open', [path]);
86
+ }
87
+ else {
88
+ spawn('xdg-open', [path]);
89
+ }
90
+ }
91
+ /**
92
+ * Shows all attachments (either template or project attachments) from a project.
93
+ * @returns array of card attachments
94
+ */
95
+ async showAttachments() {
96
+ const attachments = await this.project.attachments();
97
+ const templateAttachments = [];
98
+ const templates = await this.project.templates();
99
+ for (const template of templates) {
100
+ const templateResource = new TemplateResource(this.project, resourceName(template.name));
101
+ const templateObject = templateResource.templateObject();
102
+ if (templateObject) {
103
+ templateAttachments.push(...(await templateObject.attachments()));
104
+ }
105
+ }
106
+ attachments.push(...templateAttachments);
107
+ return attachments;
108
+ }
109
+ /**
110
+ * Returns file buffer and mime type of an attachment. Used by app UI to download attachments.
111
+ * @param cardKey card key to find
112
+ * @param filename attachment filename
113
+ * @returns attachment details
114
+ */
115
+ async showAttachment(cardKey, filename) {
116
+ if (!cardKey) {
117
+ throw new Error(`Mandatory parameter 'cardKey' missing`);
118
+ }
119
+ const attachment = await this.getAttachment(cardKey, filename);
120
+ let attachmentPath = '';
121
+ if (attachment) {
122
+ attachmentPath = `${attachment.path}/${attachment.fileName}`;
123
+ }
124
+ if (!attachment || !existsSync(attachmentPath)) {
125
+ throw new Error(`Attachment '${filename}' not found for card ${cardKey}`);
126
+ }
127
+ else {
128
+ const fileBuffer = readFileSync(attachmentPath);
129
+ let mimeType = mime.lookup(attachmentPath);
130
+ if (mimeType === false) {
131
+ mimeType = 'application/octet-stream';
132
+ }
133
+ const payload = { fileBuffer, mimeType };
134
+ return payload;
135
+ }
136
+ }
137
+ /**
138
+ * Opens an attachment using a configured application or the operating system's default application.
139
+ * @param cardKey card key of the attachment
140
+ * @param filename attachment filename
141
+ * @param waitDelay amount of time to wait for the application to open the attachment
142
+ * @todo: Move away from Show.
143
+ */
144
+ async openAttachment(cardKey, filename, waitDelay = 1000) {
145
+ const attachment = await this.getAttachment(cardKey, filename);
146
+ if (!attachment) {
147
+ throw new Error(`Attachment '${filename}' not found for card ${cardKey}`);
148
+ }
149
+ // Try to open the attachment using a configured application if one exists
150
+ const prefs = new UserPreferences(join(homedir(), '.cyberismo', 'cards.prefs.json')).getPreferences();
151
+ const attachmentEditors = prefs.attachmentEditors && process.platform in prefs.attachmentEditors
152
+ ? prefs.attachmentEditors[process.platform]
153
+ : [];
154
+ const editor = attachmentEditors.find((editor) => editor.mimeType === attachment.mimeType);
155
+ const path = resolve(attachment.path, attachment.fileName);
156
+ if (!editor) {
157
+ this.openUsingDefaultApplication(path);
158
+ return;
159
+ }
160
+ // We can safely assume that the editor command is safe to execute, since it is defined in the preferences file by the user
161
+ const processHandle = spawn(editor.command.replace('{{attachmentPath}}', path), [], {
162
+ shell: true,
163
+ });
164
+ // wait for the application to open the attachment
165
+ await new Promise((resolve) => setTimeout(resolve, waitDelay));
166
+ // If the application exists with a non-zero exit code, open the attachment using the operating system's default application
167
+ if (processHandle.exitCode !== 0 && processHandle.exitCode !== null) {
168
+ this.openUsingDefaultApplication(path);
169
+ }
170
+ }
171
+ /**
172
+ * Shows details of a particular card (template card, or project card)
173
+ * @note Note that parameter 'cardKey' is optional due to technical limitations of class calling this class. It must be defined to get valid results.
174
+ * @param details card details to show
175
+ * @param cardKey card key to find
176
+ * @returns card details
177
+ */
178
+ async showCardDetails(details, cardKey) {
179
+ if (!cardKey) {
180
+ throw new Error(`Mandatory parameter 'cardKey' missing`);
181
+ }
182
+ const cardDetails = await this.project.cardDetailsById(cardKey, details);
183
+ if (cardDetails === undefined) {
184
+ throw new Error(`Card '${cardKey}' does not exist in the project`);
185
+ }
186
+ return cardDetails;
187
+ }
188
+ /**
189
+ * Shows all cards (either template or project cards) from a project.
190
+ * @returns cards list array
191
+ */
192
+ async showCards() {
193
+ return this.project.listCards();
194
+ }
195
+ /**
196
+ * Shows all card types in a project.
197
+ * @returns array of card type details
198
+ */
199
+ async showCardTypesWithDetails() {
200
+ const promiseContainer = [];
201
+ for (const cardType of await this.project.cardTypes()) {
202
+ const cardTypeDetails = await this.project.resource(cardType.name);
203
+ if (cardTypeDetails) {
204
+ promiseContainer.push(cardTypeDetails);
205
+ }
206
+ }
207
+ const results = await Promise.all(promiseContainer);
208
+ return results.filter((item) => item);
209
+ }
210
+ /**
211
+ * Returns all unique labels in a project
212
+ * @returns labels in a list
213
+ */
214
+ async showLabels() {
215
+ const cards = await this.project.showProjectCards();
216
+ const templateCards = await this.project.allTemplateCards({
217
+ metadata: true,
218
+ children: true,
219
+ });
220
+ const labels = this.collectLabels([...cards, ...templateCards]);
221
+ return Array.from(new Set(labels));
222
+ }
223
+ /**
224
+ * Shows details of a module.
225
+ * @param moduleName name of a module
226
+ * @returns details of a module.
227
+ */
228
+ async showModule(moduleName) {
229
+ const moduleDetails = await this.project.module(moduleName);
230
+ if (!moduleDetails) {
231
+ throw new Error(`Module '${moduleName}' does not exist in the project`);
232
+ }
233
+ return moduleDetails;
234
+ }
235
+ /**
236
+ * Returns all project cards in the project. Cards don't have content and nor metadata.
237
+ * @note AppUi uses this method.
238
+ * @returns array of cards
239
+ */
240
+ async showProjectCards() {
241
+ const projectCards = await this.project.showProjectCards();
242
+ return projectCards;
243
+ }
244
+ /**
245
+ * Shows all modules (if any) in a project.
246
+ * @returns all modules in a project.
247
+ */
248
+ async showModules() {
249
+ return (await this.project.modules()).map((item) => item.name).sort();
250
+ }
251
+ /**
252
+ * Shows details of a particular project.
253
+ * @returns project information
254
+ */
255
+ async showProject() {
256
+ return this.project.show();
257
+ }
258
+ /**
259
+ * Shows report results for a given report name and card key.
260
+ * @param reportName Name of the report to show
261
+ * @param cardKey Card key to use for the report
262
+ * @param parameters Additional parameters for the report
263
+ * @param outputPath Optional output path for the report
264
+ * @returns Report results as a string
265
+ * @throws Error if the report does not exist
266
+ */
267
+ async showReportResults(reportName, cardKey, parameters, outputPath) {
268
+ if (!(await this.project.reports()).some((report) => report.name === reportName)) {
269
+ throw new Error(`Report '${reportName}' does not exist`);
270
+ }
271
+ const reportMacro = new ReportMacro(new TaskQueue());
272
+ const result = await reportMacro.handleInject({
273
+ projectPath: this.project.basePath,
274
+ cardKey: cardKey,
275
+ mode: 'static',
276
+ }, { name: reportName, ...parameters });
277
+ // Show the results either in the console or write to a file.
278
+ if (outputPath) {
279
+ try {
280
+ await writeFile(outputPath, result ?? '', 'utf-8');
281
+ }
282
+ catch (error) {
283
+ if (error instanceof Error) {
284
+ throw new Error(`Failed to write report to ${outputPath}: ${error.message}`);
285
+ }
286
+ }
287
+ }
288
+ return outputPath ? '' : (result ?? '');
289
+ }
290
+ /**
291
+ * Shows details of certain resource.
292
+ * @param name Name of resource.
293
+ * @returns resource metadata as JSON.
294
+ */
295
+ async showResource(name, showUse = false) {
296
+ const strictNameCheck = true;
297
+ const resource = Project.resourceObject(this.project, resourceName(name, strictNameCheck));
298
+ const [details, usage] = await Promise.all([
299
+ resource?.show(),
300
+ showUse ? resource?.usage() : [],
301
+ ]);
302
+ if (showUse) {
303
+ return {
304
+ ...details,
305
+ usedIn: [...usage],
306
+ };
307
+ }
308
+ else {
309
+ return details;
310
+ }
311
+ }
312
+ /**
313
+ * Shows all available resources of a given type.
314
+ * @param type Name of resources to return (in plural form, e.g. 'templates')
315
+ * @returns sorted array of resources
316
+ */
317
+ async showResources(type) {
318
+ const func = this.resourceFunction.get(type);
319
+ if (!func)
320
+ return [];
321
+ return (await func()).map((item) => item.name).sort();
322
+ }
323
+ /**
324
+ * Shows all templates with full details in a project.
325
+ * @returns all templates in a project.
326
+ */
327
+ async showTemplatesWithDetails() {
328
+ const promiseContainer = (await this.project.templates()).map((template) => new TemplateResource(this.project, resourceName(template.name)).show());
329
+ const result = await Promise.all(promiseContainer);
330
+ return result.filter(Boolean);
331
+ }
332
+ /**
333
+ * Shows all workflows with full details in a project.
334
+ * @returns workflows with full details
335
+ */
336
+ async showWorkflowsWithDetails() {
337
+ const promiseContainer = [];
338
+ for (const workflow of await this.project.workflows()) {
339
+ promiseContainer.push(this.project.resource(workflow.name));
340
+ }
341
+ const results = await Promise.all(promiseContainer);
342
+ return results.filter((item) => item);
343
+ }
344
+ }
345
+ //# sourceMappingURL=show.js.map
@@ -0,0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MAAM,CAAC,OAAO,CAA4B,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QACnC,MAAM,gBAAgB,GAAG,EAAE,CAAC;QAC5B,KAAK,MAAM,QAAQ,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;YACtD,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAW,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACpD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2024
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import type { Calculate } from './calculate.js';
14
+ import type { WorkflowState } from '../interfaces/resource-interfaces.js';
15
+ import type { Project } from '../containers/project.js';
16
+ export declare class Transition {
17
+ private project;
18
+ private calculateCmd;
19
+ constructor(project: Project, calculateCmd: Calculate);
20
+ /**
21
+ * Transitions a card from its current state to a new state.
22
+ * @param cardKey card key
23
+ * @param transition which transition to do
24
+ */
25
+ cardTransition(cardKey: string, transition: WorkflowState): Promise<void>;
26
+ private transitionChangesQuery;
27
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2024
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import { ActionGuard } from '../permissions/action-guard.js';
14
+ import { CardMetadataUpdater } from '../card-metadata-updater.js';
15
+ export class Transition {
16
+ project;
17
+ calculateCmd;
18
+ constructor(project, calculateCmd) {
19
+ this.project = project;
20
+ this.calculateCmd = calculateCmd;
21
+ }
22
+ /**
23
+ * Transitions a card from its current state to a new state.
24
+ * @param cardKey card key
25
+ * @param transition which transition to do
26
+ */
27
+ async cardTransition(cardKey, transition) {
28
+ // Card details
29
+ const details = await this.project.cardDetailsById(cardKey, {
30
+ metadata: true,
31
+ });
32
+ if (!details || !details.metadata) {
33
+ throw new Error(`Card ${cardKey} does not exist in the project`);
34
+ }
35
+ // Card type
36
+ const cardType = await this.project.resource(details.metadata?.cardType);
37
+ if (cardType === undefined) {
38
+ throw new Error(`Card's card type '${details.metadata?.cardType}' does not exist in the project`);
39
+ }
40
+ // Workflow
41
+ const workflow = await this.project.resource(cardType.workflow);
42
+ if (workflow === undefined) {
43
+ throw new Error(`Card's workflow '${cardType.workflow}' does not exist in the project`);
44
+ }
45
+ // Check that the state transition can be made "from".
46
+ const foundFrom = workflow.transitions.find((item) => (details.metadata &&
47
+ item.fromState.includes(details.metadata?.workflowState)) ||
48
+ item.fromState.includes('*'));
49
+ if (!foundFrom) {
50
+ throw new Error(`Card's workflow '${cardType.workflow}' does not contain transition from card's current state '${details.metadata?.workflowState}'`);
51
+ }
52
+ // Check that the state transition can be made "to".
53
+ const found = workflow.transitions.find((item) => item.name === transition.name);
54
+ if (!found) {
55
+ const transitionNames = workflow.transitions.map((item) => item.name);
56
+ throw new Error(`Card's workflow '${cardType.workflow}' does not contain state transition '${transition.name}'.
57
+ \nThe available transitions are: ${transitionNames.join(', ')}`);
58
+ }
59
+ if (!(found.fromState.includes(details.metadata?.workflowState) ||
60
+ found.fromState.includes('*'))) {
61
+ throw new Error(`Card's workflow '${cardType.workflow}' does not contain state transition from state '${details.metadata?.workflowState}' for '${transition.name}`);
62
+ }
63
+ const actionGuard = new ActionGuard(this.calculateCmd);
64
+ await actionGuard.checkPermission('transition', cardKey, transition.name);
65
+ details.metadata.workflowState = found.toState;
66
+ details.metadata.lastUpdated = new Date().toISOString();
67
+ details.metadata.lastTransitioned = new Date().toISOString();
68
+ return this.project
69
+ .updateCardMetadata(details, details.metadata)
70
+ .then(async () => this.transitionChangesQuery(cardKey, transition.name))
71
+ .then(async (queryResult) => {
72
+ if (!queryResult ||
73
+ queryResult.at(0) === undefined ||
74
+ queryResult.at(0)?.updateFields === undefined) {
75
+ return;
76
+ }
77
+ const fieldsToUpdate = queryResult.at(0).updateFields;
78
+ return CardMetadataUpdater.apply(this.project, fieldsToUpdate);
79
+ })
80
+ .catch((error) => console.error(error));
81
+ }
82
+ // Wrapper to run onTransition query.
83
+ async transitionChangesQuery(cardKey, transition) {
84
+ if (!cardKey || !transition)
85
+ return undefined;
86
+ return this.calculateCmd.runQuery('onTransition', {
87
+ cardKey,
88
+ transition,
89
+ });
90
+ }
91
+ }
92
+ //# sourceMappingURL=transition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transition.js","sourceRoot":"","sources":["../../src/commands/transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAO7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE,MAAM,OAAO,UAAU;IAEX;IACA;IAFV,YACU,OAAgB,EAChB,YAAuB;QADvB,YAAO,GAAP,OAAO,CAAS;QAChB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,CAAC,QAAQ,CAAC,gBAAgB,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC,OAAO;aAChB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC;aAC7C,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;aACvE,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;YAC1B,IACE,CAAC,WAAW;gBACZ,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS;gBAC/B,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,KAAK,SAAS,EAC7C,CAAC;gBACD,OAAO;YACT,CAAC;YACD,MAAM,cAAc,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC,YAAY,CAAC;YACvD,OAAO,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACjE,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,qCAAqC;IAC7B,KAAK,CAAC,sBAAsB,CAAC,OAAe,EAAE,UAAkB;QACtE,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU;YAAE,OAAO,SAAS,CAAC;QAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,cAAc,EAAE;YAChD,OAAO;YACP,UAAU;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2024
4
+
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
6
+
7
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
8
+
9
+ You should have received a copy of the GNU Affero General Public
10
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
11
+ */
12
+ import type { UpdateOperations } from '../resources/resource-object.js';
13
+ import { Project } from '../containers/project.js';
14
+ /**
15
+ * Class that handles 'update' commands.
16
+ */
17
+ export declare class Update {
18
+ private project;
19
+ constructor(project: Project);
20
+ /**
21
+ * Updates single resource property.
22
+ * @param name Name of the resource to operate on.
23
+ * @param operation Operation to perform ('add', 'remove', 'change', 'rank')
24
+ * @param key Property to change in resource JSON
25
+ * @param value Value for 'key'
26
+ * @param optionalDetail Additional detail needed for some operations. For example, 'update' needs a new value.
27
+ */
28
+ updateValue<Type>(name: string, operation: UpdateOperations, key: string, value: Type, optionalDetail?: Type): Promise<void>;
29
+ }