@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,114 @@
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 './index.js';
14
+ import { Project } from '../containers/project.js';
15
+ import type { DataType } from '../interfaces/resource-interfaces.js';
16
+ import type { Card, ProjectFile } from '../interfaces/project-interfaces.js';
17
+ /**
18
+ * Handles all create commands.
19
+ */
20
+ export declare class Create {
21
+ private project;
22
+ private calculateCmd;
23
+ constructor(project: Project, calculateCmd: Calculate);
24
+ static JSONFileContent: ProjectFile[];
25
+ static gitIgnoreContent: string;
26
+ /**
27
+ * Adds new cards to a template.
28
+ * @param cardTypeName Card type for new cards.
29
+ * @param templateName Template name to add cards into.
30
+ * @param card Optional, if defined adds a new child-card under the card.
31
+ * @param count How many cards to add. By default one.
32
+ * @returns non-empty string array with ids of added cards
33
+ */
34
+ addCards(cardTypeName: string, templateName: string, card?: string, count?: number): Promise<string[]>;
35
+ /**
36
+ * Adds an attachment to a card.
37
+ * @param cardKey card ID
38
+ * @param attachment path to an attachment file or attachment name if buffer is defined
39
+ * @param buffer (Optional) attachment buffer
40
+ */
41
+ createAttachment(cardKey: string, attachment: string, buffer?: Buffer): Promise<void>;
42
+ /**
43
+ * Creates card(s) to a project. All cards from template are instantiated to the project.
44
+ * @param templateName name of a template to use
45
+ * @param parentCardKey (Optional) card-key of a parent card. If missing, cards are added to the card root.
46
+ * @returns array of card keys that were created. Cards are sorted by their parent key and rank. Template root cards are first but the order between other card groups is not guaranteed. However, the order of cards within a group is guaranteed to be ordered by rank.
47
+ */
48
+ createCard(templateName: string, parentCardKey?: string): Promise<Card[]>;
49
+ /**
50
+ * Creates a card type.
51
+ * @param cardTypeName name for the card type.
52
+ * @param workflowName workflow name to use in the card type.
53
+ */
54
+ createCardType(cardTypeName: string, workflowName: string): Promise<void>;
55
+ /**
56
+ * Creates a new field type.
57
+ * @param fieldTypeName name for the field type.
58
+ * @param dataType data type for the field type
59
+ */
60
+ createFieldType(fieldTypeName: string, dataType: DataType): Promise<void>;
61
+ /**
62
+ * Creates a new graph model.
63
+ * @param graphModelName name for the graph model.
64
+ */
65
+ createGraphModel(graphModelName: string): Promise<void>;
66
+ /**
67
+ * Creates a new graph view.
68
+ * @param graphModelName name for the graph view.
69
+ */
70
+ createGraphView(graphViewName: string): Promise<void>;
71
+ /**
72
+ * Creates a label in the given card
73
+ * @param cardKey The card to which the label is added to
74
+ * @param label The label being added
75
+ */
76
+ createLabel(cardKey: string, label: string): Promise<void>;
77
+ /**
78
+ * Creates a new link type.
79
+ * @param linkTypeName name for the link type.
80
+ */
81
+ createLinkType(linkTypeName: string): Promise<void>;
82
+ /**
83
+ * Creates a link between two cards.
84
+ * @param cardKey The card to update
85
+ * @param destinationCardKey The card to link to
86
+ * @param linkType The type of link to add
87
+ * @param linkDescription Optional description of the link
88
+ */
89
+ createLink(cardKey: string, destinationCardKey: string, linkType: string, linkDescription?: string): Promise<void>;
90
+ /**
91
+ * Creates a new project.
92
+ * @param projectPath where to create the project.
93
+ * @param projectPrefix prefix for the project.
94
+ * @param projectName name for the project.
95
+ */
96
+ static createProject(projectPath: string, projectPrefix: string, projectName: string): Promise<void>;
97
+ /**
98
+ * Creates a report
99
+ * @param name name of the report
100
+ */
101
+ createReport(name: string): Promise<void>;
102
+ /**
103
+ * Creates a new template to a project.
104
+ * @param templateName Name of the template.
105
+ * @param templateContent JSON content for the template file.
106
+ */
107
+ createTemplate(templateName: string, templateContent: string): Promise<void>;
108
+ /**
109
+ * Creates a workflow.
110
+ * @param workflowName workflow name
111
+ * @param workflowContent workflow content JSON
112
+ */
113
+ createWorkflow(workflowName: string, workflowContent: string): Promise<void>;
114
+ }
@@ -0,0 +1,389 @@
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 { basename, join, resolve, sep } from 'node:path';
15
+ import { constants as fsConstants, copyFile, mkdir, writeFile, } from 'node:fs/promises';
16
+ import { Validate } from './index.js';
17
+ import { errorFunction } from '../utils/log-utils.js';
18
+ import { Project } from '../containers/project.js';
19
+ import { EMPTY_RANK, sortItems } from '../utils/lexorank.js';
20
+ import { pathExists } from '../utils/file-utils.js';
21
+ import { resourceName, resourceNameToString } from '../utils/resource-utils.js';
22
+ import { writeJsonFile } from '../utils/json.js';
23
+ import { CardTypeResource } from '../resources/card-type-resource.js';
24
+ import { FieldTypeResource } from '../resources/field-type-resource.js';
25
+ import { GraphModelResource } from '../resources/graph-model-resource.js';
26
+ import { GraphViewResource } from '../resources/graph-view-resource.js';
27
+ import { LinkTypeResource } from '../resources/link-type-resource.js';
28
+ import { ReportResource } from '../resources/report-resource.js';
29
+ import { TemplateResource } from '../resources/template-resource.js';
30
+ import { WorkflowResource } from '../resources/workflow-resource.js';
31
+ // todo: Is there a easy to way to make JSON schema into a TypeScript interface/type?
32
+ // Check this out: https://www.npmjs.com/package/json-schema-to-ts
33
+ /**
34
+ * Handles all create commands.
35
+ */
36
+ export class Create {
37
+ project;
38
+ calculateCmd;
39
+ constructor(project, calculateCmd) {
40
+ this.project = project;
41
+ this.calculateCmd = calculateCmd;
42
+ }
43
+ static JSONFileContent = [
44
+ {
45
+ path: '.cards/local',
46
+ content: [{ id: 'cardsConfigSchema', version: 1 }],
47
+ name: Project.schemaContentFile,
48
+ },
49
+ {
50
+ path: '.cards/local',
51
+ content: {
52
+ cardKeyPrefix: '$PROJECT-PREFIX',
53
+ name: '$PROJECT-NAME',
54
+ modules: [],
55
+ },
56
+ name: Project.projectConfigFileName,
57
+ },
58
+ ];
59
+ static gitIgnoreContent = `.calc\n
60
+ .asciidoctor\n
61
+ .vscode\n
62
+ *.html\n
63
+ *.pdf\n
64
+ *.puml\n
65
+ **/.DS_Store\n
66
+ *-debug.log\n
67
+ *-error.log\n`;
68
+ /**
69
+ * Adds new cards to a template.
70
+ * @param cardTypeName Card type for new cards.
71
+ * @param templateName Template name to add cards into.
72
+ * @param card Optional, if defined adds a new child-card under the card.
73
+ * @param count How many cards to add. By default one.
74
+ * @returns non-empty string array with ids of added cards
75
+ */
76
+ async addCards(cardTypeName, templateName, card, count = 1) {
77
+ if (!templateName ||
78
+ !Validate.validateFolder(join(this.project.basePath, templateName))) {
79
+ throw new Error(`Input validation error: template name is invalid '${templateName}'`);
80
+ }
81
+ if (cardTypeName === undefined) {
82
+ throw new Error(`Input validation error: card type cannot be empty`);
83
+ }
84
+ // Use slice to get a copy of a string.
85
+ const origTemplateName = templateName.slice(0);
86
+ const templateResource = new TemplateResource(this.project, resourceName(templateName));
87
+ const templateObject = templateResource.templateObject();
88
+ const specificCard = card
89
+ ? await templateObject.findSpecificCard(card)
90
+ : undefined;
91
+ if (card && !specificCard) {
92
+ throw Error(`Card '${card}' was not found from template '${origTemplateName}'`);
93
+ }
94
+ if (templateObject.templateFolder().includes(`${sep}modules${sep}`)) {
95
+ throw Error(`Cannot add cards to imported module templates`);
96
+ }
97
+ // Collect all add-card promises and settle them in parallel.
98
+ const promiseContainer = [];
99
+ const cardsContainer = [];
100
+ for (let cardCount = 0; cardCount < count; ++cardCount) {
101
+ promiseContainer.push(templateObject.addCard(cardTypeName, specificCard));
102
+ }
103
+ const promisesResult = await Promise.allSettled(promiseContainer).then((results) => {
104
+ for (const result of results) {
105
+ if (result.status !== 'fulfilled') {
106
+ throw new Error(result.reason);
107
+ }
108
+ cardsContainer.push(result.value);
109
+ }
110
+ });
111
+ if (cardsContainer.length === 0) {
112
+ throw new Error(`Invalid value for 'repeat:' "${count}"`);
113
+ }
114
+ if (promisesResult === undefined) {
115
+ return cardsContainer;
116
+ }
117
+ else {
118
+ throw new Error('Unknown error');
119
+ }
120
+ }
121
+ /**
122
+ * Adds an attachment to a card.
123
+ * @param cardKey card ID
124
+ * @param attachment path to an attachment file or attachment name if buffer is defined
125
+ * @param buffer (Optional) attachment buffer
126
+ */
127
+ async createAttachment(cardKey, attachment, buffer) {
128
+ if (!buffer && !pathExists(attachment)) {
129
+ throw new Error(`Input validation error: cannot find attachment '${attachment}'`);
130
+ }
131
+ const attachmentFolder = await this.project.cardAttachmentFolder(cardKey);
132
+ if (!attachmentFolder) {
133
+ throw new Error(`Attachment folder for '${cardKey}' not found`);
134
+ }
135
+ // Imported templates cannot be modified.
136
+ if (attachmentFolder.includes(`${sep}modules${sep}`)) {
137
+ throw new Error(`Cannot modify imported module`);
138
+ }
139
+ try {
140
+ await mkdir(attachmentFolder, { recursive: true }).then(async () => {
141
+ if (!buffer) {
142
+ return copyFile(attachment, join(attachmentFolder, basename(attachment)), fsConstants.COPYFILE_EXCL);
143
+ }
144
+ return writeFile(join(attachmentFolder, basename(attachment)), buffer, {
145
+ flag: 'wx',
146
+ });
147
+ });
148
+ }
149
+ catch (error) {
150
+ throw new Error(errorFunction(error));
151
+ }
152
+ }
153
+ /**
154
+ * Creates card(s) to a project. All cards from template are instantiated to the project.
155
+ * @param templateName name of a template to use
156
+ * @param parentCardKey (Optional) card-key of a parent card. If missing, cards are added to the card root.
157
+ * @returns array of card keys that were created. Cards are sorted by their parent key and rank. Template root cards are first but the order between other card groups is not guaranteed. However, the order of cards within a group is guaranteed to be ordered by rank.
158
+ */
159
+ async createCard(templateName, parentCardKey) {
160
+ const templateResource = new TemplateResource(this.project, resourceName(templateName));
161
+ await Validate.getInstance().validResourceName('templates', resourceNameToString(resourceName(templateName)), await this.project.projectPrefixes());
162
+ await templateResource.validate();
163
+ const specificCard = parentCardKey
164
+ ? await this.project.findSpecificCard(parentCardKey, {
165
+ metadata: true,
166
+ children: true,
167
+ })
168
+ : undefined;
169
+ if (parentCardKey && !specificCard) {
170
+ throw new Error(`Card '${parentCardKey}' not found from project`);
171
+ }
172
+ const templateObject = templateResource.templateObject();
173
+ if (!templateObject || !templateObject.isCreated()) {
174
+ throw new Error(`Template '${templateName}' not found from project`);
175
+ }
176
+ const createdCards = await templateObject.createCards(specificCard);
177
+ if (createdCards.length > 0) {
178
+ await this.calculateCmd.handleNewCards(createdCards);
179
+ // Note: This assumes that parent keys will be ahead of 'a' in the sort order.
180
+ const sorted = sortItems(createdCards, (item) => {
181
+ return `${item.parent === 'root' ? 'a' : item.parent}${item.metadata?.rank || EMPTY_RANK}`;
182
+ });
183
+ return sorted;
184
+ }
185
+ return [];
186
+ }
187
+ /**
188
+ * Creates a card type.
189
+ * @param cardTypeName name for the card type.
190
+ * @param workflowName workflow name to use in the card type.
191
+ */
192
+ async createCardType(cardTypeName, workflowName) {
193
+ const cardType = new CardTypeResource(this.project, resourceName(cardTypeName));
194
+ await cardType.createCardType(workflowName);
195
+ }
196
+ /**
197
+ * Creates a new field type.
198
+ * @param fieldTypeName name for the field type.
199
+ * @param dataType data type for the field type
200
+ */
201
+ async createFieldType(fieldTypeName, dataType) {
202
+ const fieldType = new FieldTypeResource(this.project, resourceName(fieldTypeName));
203
+ await fieldType.createFieldType(dataType);
204
+ }
205
+ /**
206
+ * Creates a new graph model.
207
+ * @param graphModelName name for the graph model.
208
+ */
209
+ async createGraphModel(graphModelName) {
210
+ const graphModel = new GraphModelResource(this.project, resourceName(graphModelName));
211
+ await graphModel.create();
212
+ }
213
+ /**
214
+ * Creates a new graph view.
215
+ * @param graphModelName name for the graph view.
216
+ */
217
+ async createGraphView(graphViewName) {
218
+ const graphView = new GraphViewResource(this.project, resourceName(graphViewName));
219
+ await graphView.create();
220
+ }
221
+ /**
222
+ * Creates a label in the given card
223
+ * @param cardKey The card to which the label is added to
224
+ * @param label The label being added
225
+ */
226
+ async createLabel(cardKey, label) {
227
+ if (!Validate.isValidLabelName(label)) {
228
+ throw new Error(`Not a valid label name'`);
229
+ }
230
+ const card = await this.project.findSpecificCard(cardKey, {
231
+ metadata: true,
232
+ });
233
+ if (!card) {
234
+ throw new Error(`Card '${cardKey}' does not exist in the project`);
235
+ }
236
+ const labels = card.metadata?.labels ?? [];
237
+ if (labels.includes(label)) {
238
+ throw new Error('Label already exists');
239
+ }
240
+ labels.push(label);
241
+ return this.project.updateCardMetadataKey(cardKey, 'labels', labels);
242
+ }
243
+ /**
244
+ * Creates a new link type.
245
+ * @param linkTypeName name for the link type.
246
+ */
247
+ async createLinkType(linkTypeName) {
248
+ const linkType = new LinkTypeResource(this.project, resourceName(linkTypeName));
249
+ await linkType.create();
250
+ }
251
+ /**
252
+ * Creates a link between two cards.
253
+ * @param cardKey The card to update
254
+ * @param destinationCardKey The card to link to
255
+ * @param linkType The type of link to add
256
+ * @param linkDescription Optional description of the link
257
+ */
258
+ async createLink(cardKey, destinationCardKey, linkType, linkDescription) {
259
+ if (cardKey === destinationCardKey) {
260
+ throw new Error('Cannot link card to itself');
261
+ }
262
+ // Determine the card path
263
+ const card = await this.project.findSpecificCard(cardKey, {
264
+ metadata: true,
265
+ });
266
+ if (!card) {
267
+ throw new Error(`Card '${cardKey}' does not exist in the project`);
268
+ }
269
+ const destinationCard = await this.project.findSpecificCard(destinationCardKey, {
270
+ metadata: true,
271
+ });
272
+ if (!destinationCard) {
273
+ throw new Error(`Card '${destinationCardKey}' does not exist in the project`);
274
+ }
275
+ // make sure the link type exists
276
+ const linkTypeObject = await this.project.resource(linkType);
277
+ if (!linkTypeObject) {
278
+ throw new Error(`Link type '${linkType}' does not exist in the project`);
279
+ }
280
+ // make sure that if linkDescription is not enabled, linkDescription is not provided
281
+ if (!linkTypeObject.enableLinkDescription &&
282
+ linkDescription !== undefined) {
283
+ throw new Error(`Link type '${linkType}' does not allow link description`);
284
+ }
285
+ // make sure source card key exists in the link type sourceCardTypes
286
+ // if sourceCardTypes is empty, any card can be linked
287
+ if (linkTypeObject.sourceCardTypes.length > 0 &&
288
+ !linkTypeObject.sourceCardTypes.includes(card.metadata.cardType)) {
289
+ throw new Error(`Card type '${card.metadata?.cardType}' cannot be linked with link type '${linkType}'`);
290
+ }
291
+ // make sure destination card key exists in the link type destinationCardTypes
292
+ // if destinationCardTypes is empty, any card can be linked
293
+ if (linkTypeObject.destinationCardTypes.length > 0 &&
294
+ !linkTypeObject.destinationCardTypes.includes(destinationCard.metadata.cardType)) {
295
+ throw new Error(`Card type '${destinationCard.metadata.cardType}' cannot be linked with link type '${linkType}'`);
296
+ }
297
+ // if contains the same link, do not add it again
298
+ const existingLink = card.metadata?.links.find((l) => l.linkType === linkType &&
299
+ l.cardKey === destinationCardKey &&
300
+ l.linkDescription === linkDescription);
301
+ if (existingLink) {
302
+ throw new Error(`Link from card '${cardKey}' to card '${destinationCardKey}' already exists`);
303
+ }
304
+ const links = card.metadata?.links || [];
305
+ links.push({
306
+ linkType,
307
+ cardKey: destinationCardKey,
308
+ linkDescription,
309
+ });
310
+ await this.project.updateCardMetadataKey(cardKey, 'links', links);
311
+ }
312
+ /**
313
+ * Creates a new project.
314
+ * @param projectPath where to create the project.
315
+ * @param projectPrefix prefix for the project.
316
+ * @param projectName name for the project.
317
+ */
318
+ static async createProject(projectPath, projectPrefix, projectName) {
319
+ projectPath = resolve(projectPath);
320
+ if (!projectPath) {
321
+ throw new Error('Cannot create project without a path');
322
+ }
323
+ const projectFolders = ['.cards/local', 'cardRoot'];
324
+ if (projectPrefix === undefined ||
325
+ projectPrefix.length < 3 ||
326
+ projectPrefix.length > 10) {
327
+ throw new Error(`Input validation error: prefix must be from 3 to 10 characters long. '${projectPrefix}' does not fulfill the condition.`);
328
+ }
329
+ if (!Validate.isValidProjectName(projectName)) {
330
+ throw new Error(`Input validation error: invalid project name '${projectName}'`);
331
+ }
332
+ if (!Validate.validatePrefix(projectPrefix)) {
333
+ throw new Error(`Input validation error: invalid prefix '${projectPrefix}'`);
334
+ }
335
+ if (Project.isCreated(projectPath)) {
336
+ throw new Error('Project already exists');
337
+ }
338
+ if (!Validate.isValidProjectName(projectName)) {
339
+ throw new Error(`Input validation error: invalid project name '${projectName}'`);
340
+ }
341
+ await mkdir(projectPath, { recursive: true }).then(async () => {
342
+ return await Promise.all(projectFolders.map((folder) => mkdir(`${projectPath}/${folder}`, { recursive: true })));
343
+ });
344
+ Create.JSONFileContent.forEach(async (entry) => {
345
+ if ('cardKeyPrefix' in entry.content) {
346
+ if (entry.content.cardKeyPrefix.includes('$PROJECT-PREFIX')) {
347
+ entry.content.cardKeyPrefix = projectPrefix.toLowerCase();
348
+ }
349
+ if (entry.content.name.includes('$PROJECT-NAME')) {
350
+ entry.content.name = projectName;
351
+ }
352
+ }
353
+ await writeJsonFile(join(projectPath, entry.path, entry.name), entry.content);
354
+ });
355
+ try {
356
+ await writeFile(join(projectPath, '.gitignore'), this.gitIgnoreContent);
357
+ }
358
+ catch {
359
+ console.error('Failed to create project');
360
+ }
361
+ }
362
+ /**
363
+ * Creates a report
364
+ * @param name name of the report
365
+ */
366
+ async createReport(name) {
367
+ const report = new ReportResource(this.project, resourceName(name));
368
+ await report.createReport();
369
+ }
370
+ /**
371
+ * Creates a new template to a project.
372
+ * @param templateName Name of the template.
373
+ * @param templateContent JSON content for the template file.
374
+ */
375
+ async createTemplate(templateName, templateContent) {
376
+ const template = new TemplateResource(this.project, resourceName(templateName));
377
+ await template.create(templateContent ? JSON.parse(templateContent) : undefined);
378
+ }
379
+ /**
380
+ * Creates a workflow.
381
+ * @param workflowName workflow name
382
+ * @param workflowContent workflow content JSON
383
+ */
384
+ async createWorkflow(workflowName, workflowContent) {
385
+ const workflow = new WorkflowResource(this.project, resourceName(workflowName));
386
+ await workflow.create(workflowContent ? JSON.parse(workflowContent) : undefined);
387
+ }
388
+ }
389
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO;AACP,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,SAAS,IAAI,WAAW,EACxB,QAAQ,EACR,KAAK,EACL,SAAS,GACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAkB,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAM7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO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,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CACnC,IAAI,CAAC,OAAO,EACZ,YAAY,CAAC,YAAY,CAAC,CAC3B,CAAC;QAEF,MAAM,QAAQ,CAAC,MAAM,CACnB,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAC1D,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,YAAoB,EAAE,eAAuB;QACvE,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CACnC,IAAI,CAAC,OAAO,EACZ,YAAY,CAAC,YAAY,CAAC,CAC3B,CAAC;QAEF,MAAM,QAAQ,CAAC,MAAM,CACnB,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAC1D,CAAC;IACJ,CAAC"}
@@ -0,0 +1,37 @@
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 { Calculate } from './index.js';
13
+ import type { MetadataContent } from '../interfaces/project-interfaces.js';
14
+ import { Project } from '../containers/project.js';
15
+ export declare class Edit {
16
+ private project;
17
+ private calculateCmd;
18
+ constructor(project: Project, calculateCmd: Calculate);
19
+ /**
20
+ * Opens the content and metadata files for a card in the code editor
21
+ * @param cardKey - The key of the card to open. Required.
22
+ */
23
+ editCard(cardKey: string): Promise<void>;
24
+ /**
25
+ * Updates card content (index.adoc) with incoming content.
26
+ * @param cardKey The card to update.
27
+ * @param changedContent New content for the card.
28
+ */
29
+ editCardContent(cardKey: string, changedContent: string): Promise<void>;
30
+ /**
31
+ * Updates card metadata.
32
+ * @param cardKey The card to update
33
+ * @param changedKey Which metadata property was changed
34
+ * @param newValue New value for the metadata property
35
+ */
36
+ editCardMetadata(cardKey: string, changedKey: string, newValue: MetadataContent): Promise<void>;
37
+ }
@@ -0,0 +1,99 @@
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
+ // node
13
+ import { join } from 'node:path';
14
+ import { homedir } from 'node:os';
15
+ import { spawnSync } from 'node:child_process';
16
+ import { ActionGuard } from '../permissions/action-guard.js';
17
+ import { Project } from '../containers/project.js';
18
+ import { UserPreferences } from '../utils/user-preferences.js';
19
+ export class Edit {
20
+ project;
21
+ calculateCmd;
22
+ constructor(project, calculateCmd) {
23
+ this.project = project;
24
+ this.calculateCmd = calculateCmd;
25
+ }
26
+ /**
27
+ * Opens the content and metadata files for a card in the code editor
28
+ * @param cardKey - The key of the card to open. Required.
29
+ */
30
+ async editCard(cardKey) {
31
+ // Determine the card path
32
+ const cardPath = this.project.pathToCard(cardKey);
33
+ if (!cardPath) {
34
+ throw new Error(`Card '${cardKey}' does not exist in the project`);
35
+ }
36
+ // Read the user preferences
37
+ const prefs = new UserPreferences(join(homedir(), '.cyberismo', 'cards.prefs.json')).getPreferences();
38
+ // Construct paths for the card components (json and adoc)
39
+ const cardDirPath = join(this.project.paths.cardRootFolder, cardPath);
40
+ const cardContentPath = join(cardDirPath, Project.cardContentFile);
41
+ const cardJsonPath = join(cardDirPath, Project.cardMetadataFile);
42
+ // Extract the editor settings from the preferences.
43
+ const editorPrefs = prefs.editCommand[process.platform];
44
+ const editorCommand = editorPrefs.command;
45
+ const editorArgPrefs = editorPrefs.args; // Coarces the args to string[] for map() below
46
+ // Poor man's handlebars/moustache replacements
47
+ const editorArgs = editorArgPrefs.map((arg) => {
48
+ arg = arg.replace(/\{\{\s*cardContentPath\s*\}\}/, cardContentPath);
49
+ arg = arg.replace(/\{\{\s*cardJsonPath\s*\}\}/, cardJsonPath);
50
+ arg = arg.replace(/\{\{\s*cardDirPath\s*\}\}/, cardDirPath);
51
+ return arg;
52
+ });
53
+ // Execute the editor synchronously and set it to inherit the parent process stdio.
54
+ // This enables terminal editors such as vim to grab the screen I/O
55
+ // from the command line cards process.
56
+ const result = spawnSync(editorCommand, editorArgs, {
57
+ stdio: 'inherit',
58
+ });
59
+ if (result.status === null) {
60
+ throw new Error(`Cannot launch editor: ${result.error}`);
61
+ }
62
+ }
63
+ /**
64
+ * Updates card content (index.adoc) with incoming content.
65
+ * @param cardKey The card to update.
66
+ * @param changedContent New content for the card.
67
+ */
68
+ async editCardContent(cardKey, changedContent) {
69
+ // Determine the card path
70
+ const cardPath = this.project.pathToCard(cardKey);
71
+ if (!cardPath) {
72
+ throw new Error(`Card '${cardKey}' does not exist in the project`);
73
+ }
74
+ const actionGuard = new ActionGuard(this.calculateCmd);
75
+ await actionGuard.checkPermission('editContent', cardKey);
76
+ await this.project.updateCardContent(cardKey, changedContent);
77
+ }
78
+ /**
79
+ * Updates card metadata.
80
+ * @param cardKey The card to update
81
+ * @param changedKey Which metadata property was changed
82
+ * @param newValue New value for the metadata property
83
+ */
84
+ async editCardMetadata(cardKey, changedKey, newValue) {
85
+ // Determine the card path
86
+ const cardPath = this.project.pathToCard(cardKey);
87
+ if (!cardPath) {
88
+ throw new Error(`Card '${cardKey}' does not exist in the project`);
89
+ }
90
+ if (!changedKey) {
91
+ throw new Error(`Changed key cannot be empty`);
92
+ }
93
+ // check for editing rights
94
+ const actionGuard = new ActionGuard(this.calculateCmd);
95
+ await actionGuard.checkPermission('editField', cardKey, changedKey);
96
+ await this.project.updateCardMetadataKey(cardKey, changedKey, newValue);
97
+ }
98
+ }
99
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/commands/edit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO;AACP,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,MAAM,OAAO,IAAI;IACP,OAAO,CAAU;IACjB,YAAY,CAAY;IAEhC,YAAY,OAAgB,EAAE,YAAuB;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,QAAQ,CAAC,OAAe;QACnC,0BAA0B;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,iCAAiC,CAAC,CAAC;QACrE,CAAC;QAED,4BAA4B;QAC5B,MAAM,KAAK,GAAG,IAAI,eAAe,CAC/B,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAClD,CAAC,cAAc,EAAE,CAAC;QAEnB,0DAA0D;QAC1D,MAAM,WAAW,GAAG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