@cyberismo/backend 0.0.8 → 0.0.10

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 (152) hide show
  1. package/dist/app.js +22 -8
  2. package/dist/app.js.map +1 -1
  3. package/dist/common/validationSchemas.js +39 -0
  4. package/dist/common/validationSchemas.js.map +1 -0
  5. package/dist/domain/calculations/index.js +102 -0
  6. package/dist/domain/calculations/index.js.map +1 -0
  7. package/dist/domain/calculations/schema.js +24 -0
  8. package/dist/domain/calculations/schema.js.map +1 -0
  9. package/dist/domain/calculations/service.js +21 -0
  10. package/dist/domain/calculations/service.js.map +1 -0
  11. package/dist/domain/cardTypes/index.js +86 -0
  12. package/dist/domain/cardTypes/index.js.map +1 -0
  13. package/dist/domain/cardTypes/schema.js +19 -0
  14. package/dist/domain/cardTypes/schema.js.map +1 -0
  15. package/dist/domain/cardTypes/service.js +20 -0
  16. package/dist/domain/cardTypes/service.js.map +1 -0
  17. package/dist/{routes/cards.js → domain/cards/index.js} +52 -223
  18. package/dist/domain/cards/index.js.map +1 -0
  19. package/dist/domain/cards/lib.js +80 -0
  20. package/dist/domain/cards/lib.js.map +1 -0
  21. package/dist/domain/cards/service.js +178 -0
  22. package/dist/domain/cards/service.js.map +1 -0
  23. package/dist/domain/fieldTypes/index.js +87 -0
  24. package/dist/domain/fieldTypes/index.js.map +1 -0
  25. package/dist/domain/fieldTypes/schema.js +30 -0
  26. package/dist/domain/fieldTypes/schema.js.map +1 -0
  27. package/dist/domain/fieldTypes/service.js +24 -0
  28. package/dist/domain/fieldTypes/service.js.map +1 -0
  29. package/dist/domain/graphModels/index.js +50 -0
  30. package/dist/domain/graphModels/index.js.map +1 -0
  31. package/dist/domain/graphModels/schema.js +18 -0
  32. package/dist/domain/graphModels/schema.js.map +1 -0
  33. package/dist/domain/graphModels/service.js +16 -0
  34. package/dist/domain/graphModels/service.js.map +1 -0
  35. package/dist/domain/graphViews/index.js +50 -0
  36. package/dist/domain/graphViews/index.js.map +1 -0
  37. package/dist/domain/graphViews/schema.js +6 -0
  38. package/dist/domain/graphViews/schema.js.map +1 -0
  39. package/dist/domain/graphViews/service.js +16 -0
  40. package/dist/domain/graphViews/service.js.map +1 -0
  41. package/dist/domain/linkTypes/index.js +76 -0
  42. package/dist/domain/linkTypes/index.js.map +1 -0
  43. package/dist/domain/linkTypes/schema.js +18 -0
  44. package/dist/domain/linkTypes/schema.js.map +1 -0
  45. package/dist/domain/linkTypes/service.js +24 -0
  46. package/dist/domain/linkTypes/service.js.map +1 -0
  47. package/dist/domain/logicPrograms/index.js +25 -0
  48. package/dist/domain/logicPrograms/index.js.map +1 -0
  49. package/dist/domain/logicPrograms/service.js +9 -0
  50. package/dist/domain/logicPrograms/service.js.map +1 -0
  51. package/dist/domain/reports/index.js +50 -0
  52. package/dist/domain/reports/index.js.map +1 -0
  53. package/dist/domain/reports/schema.js +18 -0
  54. package/dist/domain/reports/schema.js.map +1 -0
  55. package/dist/domain/reports/service.js +16 -0
  56. package/dist/domain/reports/service.js.map +1 -0
  57. package/dist/domain/resources/index.js +128 -0
  58. package/dist/domain/resources/index.js.map +1 -0
  59. package/dist/domain/resources/schema.js +9 -0
  60. package/dist/domain/resources/schema.js.map +1 -0
  61. package/dist/domain/resources/service.js +258 -0
  62. package/dist/domain/resources/service.js.map +1 -0
  63. package/dist/domain/templates/index.js +81 -0
  64. package/dist/domain/templates/index.js.map +1 -0
  65. package/dist/domain/templates/schema.js +18 -0
  66. package/dist/domain/templates/schema.js.map +1 -0
  67. package/dist/domain/templates/service.js +23 -0
  68. package/dist/domain/templates/service.js.map +1 -0
  69. package/dist/domain/tree/index.js +44 -0
  70. package/dist/domain/tree/index.js.map +1 -0
  71. package/dist/domain/tree/service.js +17 -0
  72. package/dist/domain/tree/service.js.map +1 -0
  73. package/dist/domain/workflows/index.js +50 -0
  74. package/dist/domain/workflows/index.js.map +1 -0
  75. package/dist/domain/workflows/schema.js +18 -0
  76. package/dist/domain/workflows/schema.js.map +1 -0
  77. package/dist/domain/workflows/service.js +16 -0
  78. package/dist/domain/workflows/service.js.map +1 -0
  79. package/dist/export.js +3 -3
  80. package/dist/export.js.map +1 -1
  81. package/dist/middleware/zvalidator.js +8 -0
  82. package/dist/middleware/zvalidator.js.map +1 -0
  83. package/dist/public/THIRD-PARTY.txt +2452 -296
  84. package/dist/public/assets/index-jhDO7xT5.js +161493 -0
  85. package/dist/public/cropped-favicon-180x180.png +0 -0
  86. package/dist/public/cropped-favicon-192x192.png +0 -0
  87. package/dist/public/cropped-favicon-270x270.png +0 -0
  88. package/dist/public/cropped-favicon-32x32.png +0 -0
  89. package/dist/public/index.html +8 -1
  90. package/dist/types.js +14 -0
  91. package/dist/types.js.map +1 -0
  92. package/dist/utils.js +3 -1
  93. package/dist/utils.js.map +1 -1
  94. package/package.json +7 -3
  95. package/src/app.ts +22 -8
  96. package/src/common/validationSchemas.ts +46 -0
  97. package/src/domain/calculations/index.ts +121 -0
  98. package/src/domain/calculations/schema.ts +27 -0
  99. package/src/domain/calculations/service.ts +32 -0
  100. package/src/domain/cardTypes/index.ts +96 -0
  101. package/src/domain/cardTypes/schema.ts +19 -0
  102. package/src/domain/cardTypes/service.ts +28 -0
  103. package/src/{routes/cards.ts → domain/cards/index.ts} +82 -270
  104. package/src/domain/cards/lib.ts +103 -0
  105. package/src/domain/cards/service.ts +254 -0
  106. package/src/domain/fieldTypes/index.ts +97 -0
  107. package/src/domain/fieldTypes/schema.ts +30 -0
  108. package/src/domain/fieldTypes/service.ts +38 -0
  109. package/src/domain/graphModels/index.ts +54 -0
  110. package/src/domain/graphModels/schema.ts +18 -0
  111. package/src/domain/graphModels/service.ts +21 -0
  112. package/src/domain/graphViews/index.ts +53 -0
  113. package/src/domain/graphViews/schema.ts +6 -0
  114. package/src/domain/graphViews/service.ts +20 -0
  115. package/src/domain/linkTypes/index.ts +84 -0
  116. package/src/domain/linkTypes/schema.ts +19 -0
  117. package/src/domain/linkTypes/service.ts +34 -0
  118. package/src/domain/logicPrograms/index.ts +35 -0
  119. package/src/domain/logicPrograms/service.ts +25 -0
  120. package/src/domain/reports/index.ts +54 -0
  121. package/src/domain/reports/schema.ts +19 -0
  122. package/src/domain/reports/service.ts +21 -0
  123. package/src/domain/resources/index.ts +166 -0
  124. package/src/domain/resources/schema.ts +19 -0
  125. package/src/domain/resources/service.ts +436 -0
  126. package/src/domain/templates/index.ts +89 -0
  127. package/src/domain/templates/schema.ts +19 -0
  128. package/src/domain/templates/service.ts +29 -0
  129. package/src/domain/tree/index.ts +50 -0
  130. package/src/domain/tree/service.ts +22 -0
  131. package/src/domain/workflows/index.ts +54 -0
  132. package/src/domain/workflows/schema.ts +19 -0
  133. package/src/domain/workflows/service.ts +21 -0
  134. package/src/export.ts +9 -5
  135. package/src/middleware/commandManager.ts +1 -1
  136. package/src/middleware/zvalidator.ts +17 -0
  137. package/src/types.ts +20 -0
  138. package/src/utils.ts +4 -2
  139. package/dist/public/assets/index-D5kiRHuF.js +0 -111171
  140. package/dist/routes/cards.js.map +0 -1
  141. package/dist/routes/fieldTypes.js +0 -42
  142. package/dist/routes/fieldTypes.js.map +0 -1
  143. package/dist/routes/linkTypes.js +0 -42
  144. package/dist/routes/linkTypes.js.map +0 -1
  145. package/dist/routes/templates.js +0 -46
  146. package/dist/routes/templates.js.map +0 -1
  147. package/dist/routes/tree.js +0 -40
  148. package/dist/routes/tree.js.map +0 -1
  149. package/src/routes/fieldTypes.ts +0 -53
  150. package/src/routes/linkTypes.ts +0 -53
  151. package/src/routes/templates.ts +0 -52
  152. package/src/routes/tree.ts +0 -45
@@ -0,0 +1,254 @@
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
+
14
+ import Processor from '@asciidoctor/core';
15
+ import {
16
+ CardLocation,
17
+ type MetadataContent,
18
+ } from '@cyberismo/data-handler/interfaces/project-interfaces';
19
+ import { type CommandManager, evaluateMacros } from '@cyberismo/data-handler';
20
+ import { getCardDetails } from './lib.js';
21
+
22
+ export async function getProjectInfo(commands: CommandManager) {
23
+ const projectResponse = await commands.showCmd.showProject();
24
+
25
+ const workflowsResponse = await commands.showCmd.showWorkflowsWithDetails();
26
+ if (!workflowsResponse) {
27
+ throw new Error('No workflows found');
28
+ }
29
+
30
+ const cardTypesResponse = await commands.showCmd.showCardTypesWithDetails();
31
+ if (!cardTypesResponse) {
32
+ throw new Error('No card types found');
33
+ }
34
+
35
+ return {
36
+ name: projectResponse.name,
37
+ prefix: projectResponse.prefix,
38
+ workflows: workflowsResponse,
39
+ cardTypes: cardTypesResponse,
40
+ };
41
+ }
42
+
43
+ export async function updateCard(
44
+ commands: CommandManager,
45
+ key: string,
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ body: any,
48
+ ) {
49
+ const errors = [];
50
+
51
+ if (body.state) {
52
+ try {
53
+ await commands.transitionCmd.cardTransition(key, body.state);
54
+ } catch (error) {
55
+ if (error instanceof Error) errors.push(error.message);
56
+ }
57
+ }
58
+
59
+ if (body.content != null) {
60
+ try {
61
+ await commands.editCmd.editCardContent(key, body.content);
62
+ } catch (error) {
63
+ if (error instanceof Error) errors.push(error.message);
64
+ }
65
+ }
66
+
67
+ if (body.metadata) {
68
+ for (const [metadataKey, metadataValue] of Object.entries(body.metadata)) {
69
+ const value = metadataValue as MetadataContent;
70
+
71
+ try {
72
+ await commands.editCmd.editCardMetadata(key, metadataKey, value);
73
+ } catch (error) {
74
+ if (error instanceof Error) errors.push(error.message);
75
+ }
76
+ }
77
+ }
78
+
79
+ if (body.parent) {
80
+ try {
81
+ await commands.moveCmd.moveCard(key, body.parent);
82
+ } catch (error) {
83
+ if (error instanceof Error) errors.push(error.message);
84
+ }
85
+ }
86
+ if (body.index != null) {
87
+ try {
88
+ await commands.moveCmd.rankByIndex(key, body.index);
89
+ } catch (error) {
90
+ if (error instanceof Error) errors.push(error.message);
91
+ }
92
+ }
93
+
94
+ if (errors.length > 0) {
95
+ throw new Error(errors.join('\n'));
96
+ }
97
+
98
+ return await getCardDetails(commands, key);
99
+ }
100
+
101
+ export async function deleteCard(commands: CommandManager, key: string) {
102
+ await commands.removeCmd.remove('card', key);
103
+ }
104
+
105
+ export async function createCard(
106
+ commands: CommandManager,
107
+ template: string,
108
+ parentKey?: string,
109
+ ) {
110
+ const result = await commands.createCmd.createCard(
111
+ template,
112
+ parentKey === 'root' ? undefined : parentKey,
113
+ );
114
+
115
+ if (result.length === 0) {
116
+ throw new Error('No cards created');
117
+ }
118
+ return result;
119
+ }
120
+
121
+ export async function uploadAttachments(
122
+ commands: CommandManager,
123
+ key: string,
124
+ files: File[],
125
+ ) {
126
+ const succeeded = [];
127
+ for (const file of files) {
128
+ if (file instanceof File) {
129
+ const buffer = await file.arrayBuffer();
130
+ await commands.createCmd.createAttachment(
131
+ key,
132
+ file.name,
133
+ Buffer.from(buffer),
134
+ );
135
+ succeeded.push(file.name);
136
+ }
137
+ }
138
+
139
+ return {
140
+ message: 'Attachments uploaded successfully',
141
+ files: succeeded,
142
+ };
143
+ }
144
+
145
+ export async function removeAttachment(
146
+ commands: CommandManager,
147
+ key: string,
148
+ filename: string,
149
+ ) {
150
+ await commands.removeCmd.remove('attachment', key, filename);
151
+ return { message: 'Attachment removed successfully' };
152
+ }
153
+
154
+ export async function openAttachment(
155
+ commands: CommandManager,
156
+ key: string,
157
+ filename: string,
158
+ ) {
159
+ await commands.showCmd.openAttachment(key, filename);
160
+ return { message: 'Attachment opened successfully' };
161
+ }
162
+
163
+ export async function parseContent(
164
+ commands: CommandManager,
165
+ key: string,
166
+ content: string,
167
+ ) {
168
+ let asciidocContent = '';
169
+ try {
170
+ asciidocContent = await evaluateMacros(content, {
171
+ context: 'localApp',
172
+ mode: 'inject',
173
+ project: commands.project,
174
+ cardKey: key,
175
+ });
176
+ } catch (error) {
177
+ asciidocContent = `Macro error: ${error instanceof Error ? error.message : 'Unknown error'}\n\n${content}`;
178
+ }
179
+
180
+ const processor = Processor();
181
+ const parsedContent = processor
182
+ .convert(asciidocContent, {
183
+ safe: 'safe',
184
+ attributes: {
185
+ imagesdir: `/api/cards/${key}/a`,
186
+ icons: 'font',
187
+ },
188
+ })
189
+ .toString();
190
+
191
+ return { parsedContent };
192
+ }
193
+
194
+ export async function createLink(
195
+ commands: CommandManager,
196
+ key: string,
197
+ toCard: string,
198
+ linkType: string,
199
+ description?: string,
200
+ ) {
201
+ await commands.createCmd.createLink(key, toCard, linkType, description);
202
+ return { message: 'Link created successfully' };
203
+ }
204
+
205
+ export async function removeLink(
206
+ commands: CommandManager,
207
+ key: string,
208
+ toCard: string,
209
+ linkType: string,
210
+ description?: string,
211
+ ) {
212
+ await commands.removeCmd.remove('link', key, toCard, linkType, description);
213
+ return { message: 'Link removed successfully' };
214
+ }
215
+
216
+ export async function getAttachment(
217
+ commands: CommandManager,
218
+ key: string,
219
+ filename: string,
220
+ ) {
221
+ const attachmentResponse = await commands.showCmd.showAttachment(
222
+ key,
223
+ filename,
224
+ );
225
+
226
+ if (!attachmentResponse) {
227
+ throw new Error(
228
+ `No attachment found from card ${key} and filename ${filename}`,
229
+ );
230
+ }
231
+
232
+ return attachmentResponse;
233
+ }
234
+
235
+ export async function getAllCards(commands: CommandManager) {
236
+ const fetchedCards = await commands.showCmd.showCards(
237
+ CardLocation.projectOnly,
238
+ );
239
+ const projectCards = fetchedCards.find(
240
+ (cardContainer) => cardContainer.type === 'project',
241
+ );
242
+ if (!projectCards) {
243
+ throw new Error('Data handler did not return project cards');
244
+ }
245
+ return projectCards.cards;
246
+ }
247
+
248
+ export async function getAllAttachments(commands: CommandManager) {
249
+ const attachments = await commands.showCmd.showAttachments();
250
+ return attachments.map((attachment) => ({
251
+ key: attachment.card,
252
+ attachment: attachment.fileName,
253
+ }));
254
+ }
@@ -0,0 +1,97 @@
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
+
14
+ import { Hono } from 'hono';
15
+ import * as fieldTypeService from './service.js';
16
+ import { createFieldTypeSchema } from './schema.js';
17
+ import { zValidator } from '../../middleware/zvalidator.js';
18
+
19
+ const router = new Hono();
20
+
21
+ /**
22
+ * @swagger
23
+ * /api/fieldTypes:
24
+ * get:
25
+ * summary: Returns a list of all field types in the defined project.
26
+ * description: List of field types includes all field types in the project with all their details
27
+ * responses:
28
+ * 200:
29
+ * description: Object containing the project field types. See definitions.ts/FieldTypes for the structure.
30
+ * 400:
31
+ * description: Error in reading project details.
32
+ * 500:
33
+ * description: project_path not set or other internal error
34
+ */
35
+ router.get('/', async (c) => {
36
+ const commands = c.get('commands');
37
+
38
+ try {
39
+ const fieldTypes = await fieldTypeService.getFieldTypes(commands);
40
+ return c.json(fieldTypes);
41
+ } catch (error) {
42
+ return c.json(
43
+ {
44
+ error: `${error instanceof Error ? error.message : 'Unknown error'} from path ${c.get('projectPath')}`,
45
+ },
46
+ 500,
47
+ );
48
+ }
49
+ });
50
+
51
+ /**
52
+ * @swagger
53
+ * /api/fieldTypes:
54
+ * post:
55
+ * summary: Create a new field type
56
+ * description: Creates a new field type with the specified data type
57
+ * requestBody:
58
+ * required: true
59
+ * content:
60
+ * application/json:
61
+ * schema:
62
+ * type: object
63
+ * properties:
64
+ * fieldTypeName:
65
+ * type: string
66
+ * dataType:
67
+ * type: string
68
+ * enum: [boolean, date, dateTime, enum, integer, list, longText, number, person, shortText]
69
+ * required:
70
+ * - fieldTypeName
71
+ * - dataType
72
+ * responses:
73
+ * 200:
74
+ * description: Field type created successfully
75
+ * 400:
76
+ * description: Invalid request body
77
+ * 500:
78
+ * description: Server error
79
+ */
80
+ router.post('/', zValidator('json', createFieldTypeSchema), async (c) => {
81
+ const commands = c.get('commands');
82
+ const { identifier, dataType } = c.req.valid('json');
83
+
84
+ try {
85
+ await fieldTypeService.createFieldType(commands, identifier, dataType);
86
+ return c.json({ message: 'Field type created successfully' });
87
+ } catch (error) {
88
+ return c.json(
89
+ {
90
+ error: `${error instanceof Error ? error.message : 'Unknown error'}`,
91
+ },
92
+ 500,
93
+ );
94
+ }
95
+ });
96
+
97
+ export default router;
@@ -0,0 +1,30 @@
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 { z } from 'zod';
14
+ import { identifierSchema } from '../../common/validationSchemas.js';
15
+
16
+ export const createFieldTypeSchema = z.object({
17
+ dataType: z.enum([
18
+ 'boolean',
19
+ 'date',
20
+ 'dateTime',
21
+ 'enum',
22
+ 'integer',
23
+ 'list',
24
+ 'longText',
25
+ 'number',
26
+ 'person',
27
+ 'shortText',
28
+ ]),
29
+ identifier: identifierSchema,
30
+ });
@@ -0,0 +1,38 @@
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
+
14
+ import type { CommandManager } from '@cyberismo/data-handler';
15
+ import type { DataType } from '@cyberismo/data-handler/interfaces/resource-interfaces';
16
+
17
+ export async function getFieldTypes(commands: CommandManager) {
18
+ const response = await commands.showCmd.showResources('fieldTypes');
19
+ if (!response) {
20
+ throw new Error('No field types found');
21
+ }
22
+
23
+ const fieldTypes = await Promise.all(
24
+ response.map((fieldType: string) =>
25
+ commands.showCmd.showResource(fieldType),
26
+ ),
27
+ );
28
+
29
+ return fieldTypes;
30
+ }
31
+
32
+ export async function createFieldType(
33
+ commands: CommandManager,
34
+ identifier: string,
35
+ dataType: DataType,
36
+ ) {
37
+ await commands.createCmd.createFieldType(identifier, dataType);
38
+ }
@@ -0,0 +1,54 @@
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
+
14
+ import { Hono } from 'hono';
15
+ import * as graphModelService from './service.js';
16
+ import { createGraphModelSchema } from './schema.js';
17
+ import { zValidator } from '../../middleware/zvalidator.js';
18
+
19
+ const router = new Hono();
20
+
21
+ /**
22
+ * @swagger
23
+ * /api/graphModels:
24
+ * post:
25
+ * summary: Create a new graph model
26
+ * description: Creates a new graph model with the specified identifier
27
+ * requestBody:
28
+ * required: true
29
+ * content:
30
+ * application/json:
31
+ * schema:
32
+ * type: object
33
+ * properties:
34
+ * identifier:
35
+ * type: string
36
+ * required:
37
+ * - identifier
38
+ * responses:
39
+ * 200:
40
+ * description: Graph model created successfully
41
+ * 400:
42
+ * description: Invalid request body
43
+ * 500:
44
+ * description: Server error
45
+ */
46
+ router.post('/', zValidator('json', createGraphModelSchema), async (c) => {
47
+ const commands = c.get('commands');
48
+ const { identifier } = c.req.valid('json');
49
+
50
+ await graphModelService.createGraphModel(commands, identifier);
51
+ return c.json({ message: 'Graph model created successfully' });
52
+ });
53
+
54
+ export default router;
@@ -0,0 +1,18 @@
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 { z } from 'zod';
14
+ import { identifierSchema } from '../../common/validationSchemas.js';
15
+
16
+ export const createGraphModelSchema = z.object({
17
+ identifier: identifierSchema,
18
+ });
@@ -0,0 +1,21 @@
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
+
14
+ import type { CommandManager } from '@cyberismo/data-handler';
15
+
16
+ export async function createGraphModel(
17
+ commands: CommandManager,
18
+ graphModelName: string,
19
+ ) {
20
+ await commands.createCmd.createGraphModel(graphModelName);
21
+ }
@@ -0,0 +1,53 @@
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
+
14
+ import { Hono } from 'hono';
15
+ import * as graphViewService from './service.js';
16
+ import { createGraphViewSchema } from './schema.js';
17
+ import { zValidator } from '../../middleware/zvalidator.js';
18
+
19
+ const router = new Hono();
20
+
21
+ /**
22
+ * @swagger
23
+ * /api/graphViews:
24
+ * post:
25
+ * summary: Create a new graph view
26
+ * description: Creates a new graph view with the specified identifier
27
+ * requestBody:
28
+ * required: true
29
+ * content:
30
+ * application/json:
31
+ * schema:
32
+ * type: object
33
+ * properties:
34
+ * identifier:
35
+ * type: string
36
+ * required:
37
+ * - identifier
38
+ * responses:
39
+ * 200:
40
+ * description: Graph view created successfully
41
+ * 400:
42
+ * description: Invalid request body
43
+ * 500:
44
+ * description: Server error
45
+ */
46
+ router.post('/', zValidator('json', createGraphViewSchema), async (c) => {
47
+ const commands = c.get('commands');
48
+ const { identifier } = c.req.valid('json');
49
+ await graphViewService.createGraphView(commands, identifier);
50
+ return c.json({ message: 'Graph view created successfully' });
51
+ });
52
+
53
+ export default router;
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import { identifierSchema } from '../../common/validationSchemas.js';
3
+
4
+ export const createGraphViewSchema = z.object({
5
+ identifier: identifierSchema,
6
+ });
@@ -0,0 +1,20 @@
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
+
14
+ import type { CommandManager } from '@cyberismo/data-handler';
15
+ export async function createGraphView(
16
+ commands: CommandManager,
17
+ graphViewName: string,
18
+ ) {
19
+ await commands.createCmd.createGraphView(graphViewName);
20
+ }
@@ -0,0 +1,84 @@
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
+
14
+ import { Hono } from 'hono';
15
+ import * as linkTypeService from './service.js';
16
+ import { createLinkTypeSchema } from './schema.js';
17
+ import { zValidator } from '../../middleware/zvalidator.js';
18
+
19
+ const router = new Hono();
20
+
21
+ /**
22
+ * @swagger
23
+ * /api/linkTypes:
24
+ * get:
25
+ * summary: Returns a list of all link types in the defined project.
26
+ * description: List of link types includes all link types in the project with all their details
27
+ * responses:
28
+ * 200:
29
+ * description: Object containing the project link types. See definitions.ts/LinkTypes for the structure.
30
+ * 400:
31
+ * description: Error in reading project details.
32
+ * 500:
33
+ * description: project_path not set or other internal error
34
+ */
35
+ router.get('/', async (c) => {
36
+ const commands = c.get('commands');
37
+
38
+ try {
39
+ const linkTypes = await linkTypeService.getLinkTypes(commands);
40
+ return c.json(linkTypes);
41
+ } catch (error) {
42
+ return c.json(
43
+ {
44
+ error: `${error instanceof Error ? error.message : 'Unknown error'} from path ${c.get('projectPath')}`,
45
+ },
46
+ 500,
47
+ );
48
+ }
49
+ });
50
+
51
+ /**
52
+ * @swagger
53
+ * /api/linkTypes:
54
+ * post:
55
+ * summary: Create a new link type
56
+ * description: Creates a new link type with the specified identifier
57
+ * requestBody:
58
+ * required: true
59
+ * content:
60
+ * application/json:
61
+ * schema:
62
+ * type: object
63
+ * properties:
64
+ * identifier:
65
+ * type: string
66
+ * required:
67
+ * - identifier
68
+ * responses:
69
+ * 200:
70
+ * description: Link type created successfully
71
+ * 400:
72
+ * description: Invalid request body
73
+ * 500:
74
+ * description: Server error
75
+ */
76
+ router.post('/', zValidator('json', createLinkTypeSchema), async (c) => {
77
+ const commands = c.get('commands');
78
+ const { identifier } = c.req.valid('json');
79
+
80
+ await linkTypeService.createLinkType(commands, identifier);
81
+ return c.json({ message: 'Link type created successfully' });
82
+ });
83
+
84
+ export default router;