@cyberismo/backend 0.0.8 → 0.0.9

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 +50 -0
  6. package/dist/domain/calculations/index.js.map +1 -0
  7. package/dist/domain/calculations/schema.js +17 -0
  8. package/dist/domain/calculations/schema.js.map +1 -0
  9. package/dist/domain/calculations/service.js +16 -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 +125 -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-CXcBl8RN.js +161392 -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 +54 -0
  98. package/src/domain/calculations/schema.ts +18 -0
  99. package/src/domain/calculations/service.ts +21 -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 +164 -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,19 @@
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 { z } from 'zod';
15
+ import { identifierSchema } from '../../common/validationSchemas.js';
16
+
17
+ export const createLinkTypeSchema = z.object({
18
+ identifier: identifierSchema,
19
+ });
@@ -0,0 +1,34 @@
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 getLinkTypes(commands: CommandManager) {
17
+ const response = await commands.showCmd.showResources('linkTypes');
18
+ if (!response) {
19
+ throw new Error('No link types found');
20
+ }
21
+
22
+ const linkTypes = await Promise.all(
23
+ response.map((linkType: string) => commands.showCmd.showResource(linkType)),
24
+ );
25
+
26
+ return linkTypes;
27
+ }
28
+
29
+ export async function createLinkType(
30
+ commands: CommandManager,
31
+ linkTypeName: string,
32
+ ) {
33
+ await commands.createCmd.createLinkType(linkTypeName);
34
+ }
@@ -0,0 +1,35 @@
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 { Hono } from 'hono';
14
+
15
+ import { zValidator } from '../../middleware/zvalidator.js';
16
+ import { resourceParamsWithCard } from '../../common/validationSchemas.js';
17
+ import * as logicProgramService from './service.js';
18
+
19
+ const router = new Hono();
20
+
21
+ router.get(
22
+ '/:prefix/:type/:identifier',
23
+ zValidator('param', resourceParamsWithCard),
24
+ async (c) => {
25
+ const commands = c.get('commands');
26
+ const params = c.req.valid('param');
27
+ const logicProgram = await logicProgramService.getLogicProgram(
28
+ commands,
29
+ params,
30
+ );
31
+ return c.json({ logicProgram });
32
+ },
33
+ );
34
+
35
+ export default router;
@@ -0,0 +1,25 @@
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 { CommandManager } from '@cyberismo/data-handler';
14
+ import type { ResourceParamsWithCard } from '../../common/validationSchemas.js';
15
+
16
+ export async function getLogicProgram(
17
+ commands: CommandManager,
18
+ resource: ResourceParamsWithCard,
19
+ ) {
20
+ if (resource.type === 'cards') {
21
+ return commands.showCmd.showCardLogicProgram(resource.identifier);
22
+ } else {
23
+ return commands.showCmd.showLogicProgram(resource);
24
+ }
25
+ }
@@ -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 reportService from './service.js';
16
+ import { createReportSchema } from './schema.js';
17
+ import { zValidator } from '../../middleware/zvalidator.js';
18
+
19
+ const router = new Hono();
20
+
21
+ /**
22
+ * @swagger
23
+ * /api/reports:
24
+ * post:
25
+ * summary: Create a new report
26
+ * description: Creates a new report 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: Report created successfully
41
+ * 400:
42
+ * description: Invalid request body
43
+ * 500:
44
+ * description: Server error
45
+ */
46
+ router.post('/', zValidator('json', createReportSchema), async (c) => {
47
+ const commands = c.get('commands');
48
+ const { identifier } = c.req.valid('json');
49
+
50
+ await reportService.createReport(commands, identifier);
51
+ return c.json({ message: 'Report created successfully' });
52
+ });
53
+
54
+ export default router;
@@ -0,0 +1,19 @@
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 { z } from 'zod';
15
+ import { identifierSchema } from '../../common/validationSchemas.js';
16
+
17
+ export const createReportSchema = z.object({
18
+ identifier: identifierSchema,
19
+ });
@@ -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 createReport(
17
+ commands: CommandManager,
18
+ reportName: string,
19
+ ) {
20
+ await commands.createCmd.createReport(reportName);
21
+ }
@@ -0,0 +1,164 @@
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 resourceService from './service.js';
16
+ import type {
17
+ ResourceFileContentResponse,
18
+ ResourceValidationResponse,
19
+ } from '../../types.js';
20
+ import { resourceParamsSchema } from '../../common/validationSchemas.js';
21
+ import { zValidator } from '../../middleware/zvalidator.js';
22
+ import { validateResourceParamsSchema } from './schema.js';
23
+
24
+ const router = new Hono();
25
+
26
+ /**
27
+ * @swagger
28
+ * /api/resources/tree:
29
+ * get:
30
+ * summary: Returns a complete tree structure of all project resources
31
+ * description: Returns a hierarchical tree of all resources including their full data from showResource calls
32
+ * responses:
33
+ * 200:
34
+ * description: Tree structure containing all resources with their complete data
35
+ * 500:
36
+ * description: project_path not set or other internal error
37
+ */
38
+ router.get('/tree', async (c) => {
39
+ const commands = c.get('commands');
40
+
41
+ try {
42
+ const tree = await resourceService.buildResourceTree(commands);
43
+ return c.json(tree);
44
+ } catch (error) {
45
+ return c.json(
46
+ {
47
+ error: `Failed to build resource tree: ${error instanceof Error ? error.message : 'Unknown error'}`,
48
+ },
49
+ 500,
50
+ );
51
+ }
52
+ });
53
+
54
+ /**
55
+ * @swagger
56
+ * /api/resources/{prefix}/{type}/{identifier}/validate:
57
+ * get:
58
+ * summary: Validates a single resource
59
+ * description: Returns validation errors for a specific resource
60
+ * parameters:
61
+ * - in: path
62
+ * name: prefix
63
+ * required: true
64
+ * schema:
65
+ * type: string
66
+ * description: Prefix of the resource
67
+ * - in: path
68
+ * name: type
69
+ * required: true
70
+ * schema:
71
+ * type: string
72
+ * description: Resource type (e.g., 'cardTypes', 'fieldTypes')
73
+ * - in: path
74
+ * name: identifier
75
+ * required: true
76
+ * schema:
77
+ * type: string
78
+ * description: Identifier of the resource
79
+ * responses:
80
+ * 200:
81
+ * description: Validation result
82
+ * content:
83
+ * application/json:
84
+ * schema:
85
+ * type: object
86
+ * properties:
87
+ * errors:
88
+ * type: array
89
+ * description: Validation errors (empty array if valid)
90
+ * items:
91
+ * type: string
92
+ * description: Validation error message
93
+ * 404:
94
+ * description: Resource not found
95
+ * 500:
96
+ * description: Internal server error
97
+ */
98
+ router.get(
99
+ '/:prefix/:type/:identifier/validate',
100
+ zValidator('param', validateResourceParamsSchema),
101
+ async (c) => {
102
+ const commands = c.get('commands');
103
+ const resourceParams = c.req.valid('param');
104
+
105
+ try {
106
+ return c.json(
107
+ await resourceService.validateResource(commands, resourceParams),
108
+ );
109
+ } catch (error) {
110
+ if (error instanceof Error && error.message.includes('not found')) {
111
+ return c.json({ error: error.message }, 404);
112
+ }
113
+ throw error;
114
+ }
115
+ },
116
+ );
117
+
118
+ router.get('/:module/:type/:resource/:file', async (c) => {
119
+ const commands = c.get('commands');
120
+ const { module, type, resource, file } = c.req.param();
121
+ const content = await resourceService.getFileContent(
122
+ commands,
123
+ module,
124
+ type,
125
+ resource,
126
+ file,
127
+ );
128
+ const response: ResourceFileContentResponse = { content };
129
+ return c.json(response);
130
+ });
131
+
132
+ router.put('/:module/:type/:resource/:file', async (c) => {
133
+ const commands = c.get('commands');
134
+ const { module, type, resource, file } = c.req.param();
135
+ const changedContent = await c.req.json();
136
+ if (
137
+ changedContent.content === undefined ||
138
+ typeof changedContent.content !== 'string'
139
+ ) {
140
+ return c.json({ error: 'Content is required' }, 400);
141
+ }
142
+ await resourceService.updateFile(
143
+ commands,
144
+ module,
145
+ type,
146
+ resource,
147
+ file,
148
+ changedContent.content,
149
+ );
150
+ return c.json({ content: changedContent.content });
151
+ });
152
+
153
+ router.delete(
154
+ '/:prefix/:type/:identifier',
155
+ zValidator('param', resourceParamsSchema),
156
+ async (c) => {
157
+ const commands = c.get('commands');
158
+ const resourceParams = c.req.valid('param');
159
+ await resourceService.deleteResource(commands, resourceParams);
160
+ return c.json({ message: 'Resource deleted' });
161
+ },
162
+ );
163
+
164
+ export default router;
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import {
3
+ resourceParamsSchema,
4
+ resourceTypes,
5
+ } from '../../common/validationSchemas.js';
6
+
7
+ export const resourceFileParamsSchema = resourceParamsSchema.extend({
8
+ file: z.string(),
9
+ });
10
+
11
+ export type ResourceFileParams = z.infer<typeof resourceFileParamsSchema>;
12
+
13
+ export const validateResourceParamsSchema = resourceParamsSchema.extend({
14
+ type: z.enum(resourceTypes.filter((type) => type !== 'calculations')),
15
+ });
16
+
17
+ export type ValidateResourceParams = z.infer<
18
+ typeof validateResourceParamsSchema
19
+ >;