@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,64 @@
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
+ export interface UserPreferencesObject {
13
+ editCommand: {
14
+ [platform: string]: {
15
+ command: string;
16
+ args: string[];
17
+ };
18
+ };
19
+ attachmentEditors: {
20
+ [platform: string]: {
21
+ mimeType: string;
22
+ command: string;
23
+ }[];
24
+ };
25
+ }
26
+ /**
27
+ * The class checks if the preferences file exists when instantiated, and if not, creates it with a default JSON object.
28
+ * The getPreferences() method simply reads and parses the file to return the preferences object.
29
+ */
30
+ export declare class UserPreferences {
31
+ private prefsFilePath;
32
+ static defaults: {
33
+ editCommand: {
34
+ darwin: {
35
+ command: string;
36
+ args: string[];
37
+ };
38
+ linux: {
39
+ command: string;
40
+ args: string[];
41
+ };
42
+ win32: {
43
+ command: string;
44
+ args: string[];
45
+ };
46
+ };
47
+ attachmentEditors: {
48
+ darwin: {
49
+ mimeType: string;
50
+ command: string;
51
+ }[];
52
+ linux: {
53
+ mimeType: string;
54
+ command: string;
55
+ }[];
56
+ win32: {
57
+ mimeType: string;
58
+ command: string;
59
+ }[];
60
+ };
61
+ };
62
+ constructor(prefsFilePath: string);
63
+ getPreferences(): UserPreferencesObject;
64
+ }
@@ -0,0 +1,106 @@
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 { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
13
+ import { formatJson } from './json.js';
14
+ import { dirname } from 'path';
15
+ /**
16
+ * The class checks if the preferences file exists when instantiated, and if not, creates it with a default JSON object.
17
+ * The getPreferences() method simply reads and parses the file to return the preferences object.
18
+ */
19
+ export class UserPreferences {
20
+ prefsFilePath;
21
+ // If preferences do not exist, they are initialised
22
+ // with these defaults.
23
+ static defaults = {
24
+ editCommand: {
25
+ darwin: {
26
+ command: 'code',
27
+ args: ['{{cardContentPath}}', '{{cardJsonPath}}'],
28
+ },
29
+ linux: {
30
+ command: 'vi',
31
+ args: ['{{cardContentPath}}', '{{cardJsonPath}}'],
32
+ },
33
+ win32: {
34
+ command: 'notepad.exe',
35
+ args: ['{{cardContentPath}}', '{{cardJsonPath}}'],
36
+ },
37
+ },
38
+ attachmentEditors: {
39
+ darwin: [
40
+ {
41
+ mimeType: 'image/png',
42
+ command: "open -a draw.io '{{attachmentPath}}'",
43
+ },
44
+ {
45
+ mimeType: 'image/svg+xml',
46
+ command: "open -a draw.io '{{attachmentPath}}'",
47
+ },
48
+ {
49
+ mimeType: 'application/pdf',
50
+ command: 'open -a Preview "{{attachmentPath}}"',
51
+ },
52
+ ],
53
+ linux: [
54
+ {
55
+ mimeType: 'image/png',
56
+ command: 'drawio {{attachmentPath}}',
57
+ },
58
+ {
59
+ mimeType: 'image/svg+xml',
60
+ command: 'drawio {{attachmentPath}}',
61
+ },
62
+ ],
63
+ win32: [
64
+ {
65
+ mimeType: 'text/plain',
66
+ command: 'notepad.exe {{attachmentPath}}',
67
+ },
68
+ {
69
+ mimeType: 'image/png',
70
+ command: '"C:\\Program Files\\draw.io\\draw.io.exe" "{{attachmentPath}}"',
71
+ },
72
+ {
73
+ mimeType: 'image/svg+xml',
74
+ command: '"C:\\Program Files\\draw.io\\draw.io.exe" "{{attachmentPath}}"',
75
+ },
76
+ ],
77
+ },
78
+ };
79
+ constructor(prefsFilePath) {
80
+ this.prefsFilePath = prefsFilePath;
81
+ if (!existsSync(this.prefsFilePath)) {
82
+ // Create the preferences directory based on prefsFilePath dirname
83
+ const prefsDir = dirname(this.prefsFilePath);
84
+ try {
85
+ if (!existsSync(prefsDir)) {
86
+ mkdirSync(prefsDir, { recursive: true });
87
+ }
88
+ // File does not exist, create it with default content
89
+ writeFileSync(this.prefsFilePath, formatJson(UserPreferences.defaults));
90
+ }
91
+ catch (error) {
92
+ throw new Error(`Error creating preferences file '${this.prefsFilePath}': ${error}`);
93
+ }
94
+ }
95
+ }
96
+ getPreferences() {
97
+ // Read and parse the preferences file
98
+ try {
99
+ return JSON.parse(readFileSync(this.prefsFilePath, 'utf8'));
100
+ }
101
+ catch (error) {
102
+ throw new Error(`Error reading preferences file '${this.prefsFilePath}': ${error}`);
103
+ }
104
+ }
105
+ }
106
+ //# sourceMappingURL=user-preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-preferences.js","sourceRoot":"","sources":["../../src/utils/user-preferences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,I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IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YACpC,kEAAkE;YAClE,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAE7C,IAAI,CAAC;gBACH,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC1B,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC3C,CAAC;gBACD,sDAAsD;gBACtD,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC1E,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CACb,oCAAoC,IAAI,CAAC,aAAa,MAAM,KAAK,EAAE,CACpE,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAEM,cAAc;QACnB,sCAAsC;QACtC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;QAC9D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,mCAAmC,IAAI,CAAC,aAAa,MAAM,KAAK,EAAE,CACnE,CAAC;QACJ,CAAC;IACH,CAAC"}
@@ -0,0 +1,26 @@
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 Schema, Validator } from 'jsonschema';
13
+ /**
14
+ * Validates a JSON object against a schema
15
+ * @param object The object to validate
16
+ * @param schemaId The id of the schema to validate against
17
+ * @param validator An optional validator to use. If validator is not provided or does not contain any schemas, project schemas will be used
18
+ * @returns The object casted to the type T if it is valid
19
+ * @throws DHValidationError if the object is not valid
20
+ * @throws SchemaNotFound if the schema with the given id is not found
21
+ */
22
+ export declare function validateJson<T>(object: unknown, options: {
23
+ schemaId?: string;
24
+ schema?: Schema;
25
+ validator?: Validator;
26
+ }): T;
@@ -0,0 +1,53 @@
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 { Validator } from 'jsonschema';
13
+ import { DHValidationError, SchemaNotFound } from '../exceptions/index.js';
14
+ import { schemas } from '@cyberismocom/resources';
15
+ /**
16
+ * Validates a JSON object against a schema
17
+ * @param object The object to validate
18
+ * @param schemaId The id of the schema to validate against
19
+ * @param validator An optional validator to use. If validator is not provided or does not contain any schemas, project schemas will be used
20
+ * @returns The object casted to the type T if it is valid
21
+ * @throws DHValidationError if the object is not valid
22
+ * @throws SchemaNotFound if the schema with the given id is not found
23
+ */
24
+ export function validateJson(object, options) {
25
+ const { schemaId, schema } = options;
26
+ let validator = options.validator;
27
+ if (!schema && !schemaId) {
28
+ throw new Error('Must either specify schema or schemaId');
29
+ }
30
+ if (!validator) {
31
+ validator = new Validator();
32
+ for (const schema of schemas) {
33
+ validator.addSchema(schema, schema.$id);
34
+ }
35
+ }
36
+ let jsonSchema;
37
+ if (schema) {
38
+ jsonSchema = schema;
39
+ }
40
+ else {
41
+ jsonSchema = Object.values(validator.schemas).find((s) => s.$id === schemaId);
42
+ }
43
+ if (!jsonSchema) {
44
+ throw new SchemaNotFound(`Schema with id ${schemaId} not found`);
45
+ }
46
+ const result = validator.validate(object, jsonSchema);
47
+ if (!result.valid) {
48
+ throw new DHValidationError('Validation failed', result.errors);
49
+ }
50
+ // we know that the object is valid, so we can safely cast it to T
51
+ return object;
52
+ }
53
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAe,SAAS,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAe,EACf,OAIC;IAED,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACrC,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAElC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,IAAI,UAA8B,CAAC;IAEnC,IAAI,MAAM,EAAE,CAAC;QACX,UAAU,GAAG,MAAM,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,CAChD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,QAAQ,CAC1B,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,cAAc,CAAC,kBAAkB,QAAQ,YAAY,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,iBAAiB,CAAC,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAClE,CAAC;IACD,kEAAkE;IAClE,OAAO,MAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
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 { DataType } from '../interfaces/resource-interfaces.js';
14
+ /**
15
+ * Checks if conversion 'from' 'to' can be done.
16
+ * @param from Data type to convert from
17
+ * @param to Data type to convert to
18
+ * @returns true if conversion can be done, false otherwise.
19
+ */
20
+ export declare function allowed(from: DataType, to: DataType): boolean;
21
+ /**
22
+ * Converts number value to other data types.
23
+ * @param value Value to convert
24
+ * @param to Date type to which value is converted to
25
+ * @returns converted value, or null if cannot convert
26
+ * Allowed conversions are
27
+ * date -> dateTime
28
+ * dateTime -> date
29
+ * date/dateTime -> shortText/longText
30
+ */
31
+ export declare function fromDate<T>(value: T, to: DataType): string | null;
32
+ /**
33
+ * Converts number value to other data types.
34
+ * @param value Value to convert
35
+ * @param to Date type to which value is converted to
36
+ * @returns converted value, or null if cannot convert
37
+ * Allowed conversions are
38
+ * integer -> number
39
+ * number -> integer
40
+ * number/integer -> shortText
41
+ * number/integer -> longText
42
+ */
43
+ export declare function fromNumber<T>(value: T, to: DataType): string | number | null;
44
+ /**
45
+ * Converts string value to other data types.
46
+ * @param value Value to convert
47
+ * @param to Date type to which value is converted to
48
+ * @returns converted value, or null if cannot convert
49
+ * Allowed conversions are
50
+ * longText -> shortText
51
+ * shortText -> longText
52
+ * longText/shortText -> integer
53
+ * longText/shortText -> number
54
+ * longText/shortText -> list
55
+ * longText/shortText -> date/dateTime
56
+ * longText/shortText -> boolean
57
+ */
58
+ export declare function fromString<T>(value: T, to: DataType): string | number | bigint | boolean | string[] | T | null;
@@ -0,0 +1,181 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
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 { isBigInt } from '../utils/common-utils.js';
14
+ import * as EmailValidator from 'email-validator';
15
+ const SHORT_TEXT_MAX_LENGTH = 80;
16
+ /**
17
+ * Checks if conversion 'from' 'to' can be done.
18
+ * @param from Data type to convert from
19
+ * @param to Data type to convert to
20
+ * @returns true if conversion can be done, false otherwise.
21
+ */
22
+ export function allowed(from, to) {
23
+ // Converting from strings is fine, except to enum.
24
+ if (from === 'longText' || from === 'shortText') {
25
+ switch (to) {
26
+ case 'boolean':
27
+ case 'date':
28
+ case 'dateTime':
29
+ case 'integer':
30
+ case 'list':
31
+ case 'longText':
32
+ case 'number':
33
+ case 'person':
34
+ case 'shortText':
35
+ return true;
36
+ default:
37
+ return false;
38
+ }
39
+ }
40
+ // Converting from<->to number formats is fine
41
+ if ((from === 'number' && to === 'integer') ||
42
+ (from === 'integer' && to === 'number')) {
43
+ return true;
44
+ }
45
+ // Converting to strings is fine
46
+ if (to === 'shortText' || to === 'longText') {
47
+ return true;
48
+ }
49
+ // Converting from<->to date formats is fine
50
+ if ((from === 'dateTime' && to === 'date') ||
51
+ (from === 'date' && to === 'dateTime')) {
52
+ return true;
53
+ }
54
+ // Everything else is forbidden.
55
+ return false;
56
+ }
57
+ /**
58
+ * Converts number value to other data types.
59
+ * @param value Value to convert
60
+ * @param to Date type to which value is converted to
61
+ * @returns converted value, or null if cannot convert
62
+ * Allowed conversions are
63
+ * date -> dateTime
64
+ * dateTime -> date
65
+ * date/dateTime -> shortText/longText
66
+ */
67
+ export function fromDate(value, to) {
68
+ if (to === 'date') {
69
+ const tempDate = new Date(value);
70
+ return new Date(tempDate).toISOString().slice(0, 10);
71
+ }
72
+ if (to === 'dateTime') {
73
+ const tempDate = new Date(value);
74
+ return new Date(tempDate).toISOString();
75
+ }
76
+ if (to === 'longText' || to === 'shortText') {
77
+ return String(value);
78
+ }
79
+ return null;
80
+ }
81
+ /**
82
+ * Converts number value to other data types.
83
+ * @param value Value to convert
84
+ * @param to Date type to which value is converted to
85
+ * @returns converted value, or null if cannot convert
86
+ * Allowed conversions are
87
+ * integer -> number
88
+ * number -> integer
89
+ * number/integer -> shortText
90
+ * number/integer -> longText
91
+ */
92
+ export function fromNumber(value, to) {
93
+ if (to === 'integer') {
94
+ return Math.trunc(value);
95
+ }
96
+ if (to === 'longText') {
97
+ return String(value);
98
+ }
99
+ if (to === 'number') {
100
+ return Number(value);
101
+ }
102
+ if (to === 'shortText') {
103
+ const tempString = String(value);
104
+ return tempString.length > SHORT_TEXT_MAX_LENGTH ? null : tempString;
105
+ }
106
+ return null;
107
+ }
108
+ /**
109
+ * Converts string value to other data types.
110
+ * @param value Value to convert
111
+ * @param to Date type to which value is converted to
112
+ * @returns converted value, or null if cannot convert
113
+ * Allowed conversions are
114
+ * longText -> shortText
115
+ * shortText -> longText
116
+ * longText/shortText -> integer
117
+ * longText/shortText -> number
118
+ * longText/shortText -> list
119
+ * longText/shortText -> date/dateTime
120
+ * longText/shortText -> boolean
121
+ */
122
+ export function fromString(value, to) {
123
+ switch (to) {
124
+ case 'boolean': {
125
+ if (value === 'true')
126
+ return true;
127
+ if (value === 'false')
128
+ return false;
129
+ return null;
130
+ }
131
+ case 'date': {
132
+ try {
133
+ const tempDate = new Date(value + 'Z').toUTCString();
134
+ return new Date(tempDate).toISOString().slice(0, 10);
135
+ }
136
+ catch {
137
+ return null;
138
+ }
139
+ }
140
+ case 'dateTime': {
141
+ try {
142
+ const tempDate = new Date(value + 'Z').toUTCString();
143
+ return new Date(tempDate).toISOString();
144
+ }
145
+ catch {
146
+ return null;
147
+ }
148
+ }
149
+ case 'integer': {
150
+ if (isBigInt(value)) {
151
+ return BigInt(value);
152
+ }
153
+ const tempInt = parseInt(value);
154
+ return isNaN(tempInt) ? null : tempInt;
155
+ }
156
+ case 'list': {
157
+ return value.split(',');
158
+ }
159
+ case 'longText': {
160
+ return value;
161
+ }
162
+ case 'number': {
163
+ if (isBigInt(value)) {
164
+ return BigInt(value);
165
+ }
166
+ const tempNumber = parseFloat(value);
167
+ return isNaN(tempNumber) ? null : tempNumber;
168
+ }
169
+ case 'person': {
170
+ if (EmailValidator.validate(value)) {
171
+ return String(value);
172
+ }
173
+ return null;
174
+ }
175
+ case 'shortText': {
176
+ return value.length > SHORT_TEXT_MAX_LENGTH ? null : value;
177
+ }
178
+ }
179
+ return null;
180
+ }
181
+ //# sourceMappingURL=value-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-utils.js","sourceRoot":"","sources":["../../src/utils/value-utils.ts"],"names":[],"mappings":"AAA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C;QACD,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,IAAI,QAAQ,CAAC,KAAe,CAAC,EAAE,CAAC;gBAC9B,OAAO,MAAM,CAAC,KAAe,CAAC,CAAC;YACjC,CAAC;YACD,MAAM,UAAU,GAAG,UAAU,CAAC,KAAe,CAAC,CAAC;YAC/C,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;QAC/C,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAe,CAAC,EAAE,CAAC;gBAC7C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,OAAQ,KAAgB,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QACzE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@cyberismo/data-handler",
3
+ "description": "Command handler for cards and web service",
4
+ "version": "0.0.2",
5
+ "author": "sami.merila@cyberismo.com",
6
+ "license": "AGPL-3.0",
7
+ "homepage": "https://github.com/CyberismoCom/cyberismo",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/CyberismoCom/cyberismo.git"
11
+ },
12
+ "bugs": "https://github.com/CyberismoCom/cyberismo/issues",
13
+ "exports": {
14
+ ".": "./dist/index.js",
15
+ "./interfaces/*": "./dist/interfaces/*.js",
16
+ "./types/*": "./dist/types/*.js",
17
+ "./macros/*": "./dist/macros/*.js"
18
+ },
19
+ "devDependencies": {
20
+ "@types/dompurify": "^3.2.0",
21
+ "@types/js-yaml": "^4.0.9",
22
+ "@types/jsdom": "^21.1.7",
23
+ "@types/json-schema": "^7.0.15",
24
+ "@types/mime-types": "^2.1.4",
25
+ "@types/sinon": "^17.0.4",
26
+ "c8": "^10.1.3",
27
+ "pino-pretty": "^13.0.0",
28
+ "sinon": "^20.0.0"
29
+ },
30
+ "dependencies": {
31
+ "@asciidoctor/core": "^3.0.4",
32
+ "antora": "^3.1.10",
33
+ "async-mutex": "^0.5.0",
34
+ "csv-parse": "^5.6.0",
35
+ "directory-schema-validator": "^1.0.17",
36
+ "dompurify": "^3.2.5",
37
+ "email-validator": "^2.0.4",
38
+ "handlebars": "^4.7.8",
39
+ "isomorphic-git": "^1.30.1",
40
+ "js-yaml": "^4.1.0",
41
+ "jsdom": "^26.1.0",
42
+ "json-schema": "^0.4.0",
43
+ "jsonschema": "^1.5.0",
44
+ "mime-types": "^3.0.1",
45
+ "pino": "^9.6.0",
46
+ "tslib": "^2.6.2",
47
+ "write-json-file": "^6.0.0",
48
+ "@cyberismo/resources": "0.0.2",
49
+ "@cyberismo/node-clingo": "1.0.1"
50
+ },
51
+ "type": "module",
52
+ "files": [
53
+ "dist",
54
+ "src"
55
+ ],
56
+ "scripts": {
57
+ "preinstall": "npx only-allow pnpm",
58
+ "build": "tsc -p tsconfig.build.json",
59
+ "clean": "rm -rf node_modules",
60
+ "lint": "eslint .",
61
+ "posttest": "pnpm lint",
62
+ "test": "mocha --require mocha-suppress-logs --disable-warning=ExperimentalWarning --forbid-only \"./test/**/*.test.ts\"",
63
+ "test-coverage": "c8 pnpm test",
64
+ "dev": "tsc --watch -p tsconfig.build.json",
65
+ "watch": "pnpm dev"
66
+ }
67
+ }