@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 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/domain/reports/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAIF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAwB,EACxB,UAAkB;IAElB,MAAM,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,128 @@
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
+ import * as resourceService from './service.js';
15
+ import { resourceParamsSchema } from '../../common/validationSchemas.js';
16
+ import { zValidator } from '../../middleware/zvalidator.js';
17
+ import { validateResourceParamsSchema } from './schema.js';
18
+ const router = new Hono();
19
+ /**
20
+ * @swagger
21
+ * /api/resources/tree:
22
+ * get:
23
+ * summary: Returns a complete tree structure of all project resources
24
+ * description: Returns a hierarchical tree of all resources including their full data from showResource calls
25
+ * responses:
26
+ * 200:
27
+ * description: Tree structure containing all resources with their complete data
28
+ * 500:
29
+ * description: project_path not set or other internal error
30
+ */
31
+ router.get('/tree', async (c) => {
32
+ const commands = c.get('commands');
33
+ try {
34
+ const tree = await resourceService.buildResourceTree(commands);
35
+ return c.json(tree);
36
+ }
37
+ catch (error) {
38
+ return c.json({
39
+ error: `Failed to build resource tree: ${error instanceof Error ? error.message : 'Unknown error'}`,
40
+ }, 500);
41
+ }
42
+ });
43
+ /**
44
+ * @swagger
45
+ * /api/resources/{prefix}/{type}/{identifier}/validate:
46
+ * get:
47
+ * summary: Validates a single resource
48
+ * description: Returns validation errors for a specific resource
49
+ * parameters:
50
+ * - in: path
51
+ * name: prefix
52
+ * required: true
53
+ * schema:
54
+ * type: string
55
+ * description: Prefix of the resource
56
+ * - in: path
57
+ * name: type
58
+ * required: true
59
+ * schema:
60
+ * type: string
61
+ * description: Resource type (e.g., 'cardTypes', 'fieldTypes')
62
+ * - in: path
63
+ * name: identifier
64
+ * required: true
65
+ * schema:
66
+ * type: string
67
+ * description: Identifier of the resource
68
+ * responses:
69
+ * 200:
70
+ * description: Validation result
71
+ * content:
72
+ * application/json:
73
+ * schema:
74
+ * type: object
75
+ * properties:
76
+ * errors:
77
+ * type: array
78
+ * description: Validation errors (empty array if valid)
79
+ * items:
80
+ * type: string
81
+ * description: Validation error message
82
+ * 404:
83
+ * description: Resource not found
84
+ * 500:
85
+ * description: Internal server error
86
+ */
87
+ router.get('/:prefix/:type/:identifier/validate', zValidator('param', validateResourceParamsSchema), async (c) => {
88
+ const commands = c.get('commands');
89
+ const resourceParams = c.req.valid('param');
90
+ try {
91
+ const response = await resourceService.validateResource(commands, resourceParams);
92
+ return c.json(response);
93
+ }
94
+ catch (error) {
95
+ if (error instanceof Error && error.message.includes('not found')) {
96
+ return c.json({ error: error.message }, 404);
97
+ }
98
+ throw error;
99
+ }
100
+ });
101
+ router.get('/:module/:type/:resource/:file', async (c) => {
102
+ const commands = c.get('commands');
103
+ const { module, type, resource, file } = c.req.param();
104
+ const content = await resourceService.getFileContent(commands, module, type, resource, file);
105
+ const response = { content };
106
+ return c.json(response);
107
+ });
108
+ router.put('/:module/:type/:resource/:file', async (c) => {
109
+ const commands = c.get('commands');
110
+ const { module, type, resource, file } = c.req.param();
111
+ const changedContent = await c.req.json();
112
+ if (changedContent.content === undefined ||
113
+ typeof changedContent.content !== 'string') {
114
+ return c.json({ error: 'Content is required' }, 400);
115
+ }
116
+ await resourceService.updateFile(commands, module, type, resource, file, changedContent.content);
117
+ return c.json({ content: changedContent.content });
118
+ });
119
+ router.delete('/:prefix/:type/:identifier', zValidator('param', resourceParamsSchema), async (c) => {
120
+ const commands = c.get('commands');
121
+ const resourceParams = c.req.valid('param');
122
+ await resourceService.deleteResource(commands, resourceParams);
123
+ return c.json({
124
+ message: 'Resource deleted',
125
+ });
126
+ });
127
+ export default router;
128
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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AAI,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACvD,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1C,IACE,cAAc,CAAC,OAAO,KAAK,SAAS;QACpC,OAAO,cAAc,CAAC,OAAO,KAAK,QAAQ,EAC1C,CAAC;QACD,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,eAAe,CAAC,UAAU,CAC9B,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,cAAc,CAAC,OAAO,CACvB,CAAC;IACF,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,CACX,4BAA4B,EAC5B,UAAU,CAAC,OAAO,EAAE,oBAAoB,CAAC,EACzC,KAAK,EAAE,CAAC,EAAE,EAAE;IACV,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACnC,MAAM,cAAc,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,eAAe,CAAC,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC/D,OAAO,CAAC,CAAC,IAAI,CAAC;QACZ,OAAO,EAAE,kBAAkB;KAC5B,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { resourceParamsSchema, resourceTypes, } from '../../common/validationSchemas.js';
3
+ export const resourceFileParamsSchema = resourceParamsSchema.extend({
4
+ file: z.string(),
5
+ });
6
+ export const validateResourceParamsSchema = resourceParamsSchema.extend({
7
+ type: z.enum(resourceTypes.filter((type) => type !== 'calculations')),
8
+ });
9
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/domain/resources/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,aAAa,GACd,MAAM,mCAAmC,CAAC;AAE3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,MAAM,CAAC;IAClE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC,MAAM,CAAC;IACtE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC;CACtE,CAAC,CAAC"}
@@ -0,0 +1,258 @@
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 { isResourceFolderType, moduleNameFromCardKey, resourceName, resourceNameToString, } from '@cyberismo/data-handler';
14
+ const resourceTypes = [
15
+ 'calculations',
16
+ 'cardTypes',
17
+ 'fieldTypes',
18
+ 'graphModels',
19
+ 'graphViews',
20
+ 'linkTypes',
21
+ 'reports',
22
+ 'templates',
23
+ 'workflows',
24
+ ];
25
+ export async function buildResourceTree(commands) {
26
+ const project = await commands.showCmd.showProject();
27
+ const tree = [];
28
+ const allModuleResources = {};
29
+ // Process each resource type
30
+ for (const resourceType of resourceTypes) {
31
+ let rootResources;
32
+ let moduleResources;
33
+ if (resourceType === 'templates') {
34
+ ({ rootResources, moduleResources } = await processTemplates(commands, project.prefix));
35
+ }
36
+ else {
37
+ ({ rootResources, moduleResources } = await groupResourcesByPrefix(commands, resourceType, project.prefix));
38
+ }
39
+ // Add root level resources
40
+ if (rootResources.length > 0) {
41
+ tree.push({
42
+ id: resourceType,
43
+ type: 'resourceGroup',
44
+ name: resourceType,
45
+ children: rootResources,
46
+ });
47
+ }
48
+ // Collect module resources
49
+ Object.entries(moduleResources).forEach(([prefix, resources]) => {
50
+ if (!allModuleResources[prefix]) {
51
+ allModuleResources[prefix] = {};
52
+ }
53
+ allModuleResources[prefix][resourceType] = resources;
54
+ });
55
+ }
56
+ // Build modules section
57
+ if (Object.keys(allModuleResources).length > 0) {
58
+ const modules = Object.entries(allModuleResources).map(([prefix, resourcesByType]) => ({
59
+ id: `modules-${prefix}`,
60
+ type: 'module',
61
+ name: prefix,
62
+ children: Object.entries(resourcesByType).map(([type, resources]) => ({
63
+ id: `modules-${prefix}-${type}`,
64
+ type: 'resourceGroup',
65
+ name: type,
66
+ children: resources,
67
+ })),
68
+ }));
69
+ tree.push({
70
+ id: 'modules',
71
+ type: 'modulesGroup',
72
+ name: 'modules',
73
+ children: modules,
74
+ });
75
+ }
76
+ return tree;
77
+ }
78
+ // Helper function to parse resource prefix
79
+ function parseResourcePrefix(resource) {
80
+ const parts = resource.split('/');
81
+ if (parts.length !== 3) {
82
+ throw new Error(`Invalid resource name: ${resource}`);
83
+ }
84
+ return {
85
+ prefix: parts[0],
86
+ identifier: parts[2],
87
+ };
88
+ }
89
+ // Helper function to create resource node with all data from showResource
90
+ // TODO: The types should be shared between backend and frontend
91
+ async function createResourceNode(commands, resourceType, name, projectPrefix, children) {
92
+ const resourceData = await commands.showCmd.showResource(name);
93
+ const node = {
94
+ id: `${resourceType}-${name}`,
95
+ type: resourceType,
96
+ name: name,
97
+ data: resourceData,
98
+ readOnly: resourceName(name).prefix !== projectPrefix,
99
+ };
100
+ // Add file children for folder resources
101
+ if (isResourceFolderType(resourceType) && resourceType !== 'templates') {
102
+ try {
103
+ const fileNames = await commands.showCmd.showFileNames(resourceName(name));
104
+ const fileNodes = fileNames.map((fileName) => ({
105
+ id: `${resourceType}-${name}-${fileName}`,
106
+ type: 'file',
107
+ name: `${name}/${fileName}`,
108
+ displayName: fileName,
109
+ readOnly: resourceName(name).prefix !== projectPrefix,
110
+ }));
111
+ node.children = children ? [...children, ...fileNodes] : fileNodes;
112
+ }
113
+ catch (error) {
114
+ console.warn(`Failed to get file names for resource '${name}'`, error);
115
+ }
116
+ }
117
+ else if (children) {
118
+ node.children = children;
119
+ }
120
+ return node;
121
+ }
122
+ // Helper function to recursively create card nodes with children
123
+ function createCardNode(card, module, projectPrefix) {
124
+ // Destructure to separate children from other card data
125
+ const { children, ...cardData } = card;
126
+ const cardNode = {
127
+ id: `${card.key}`,
128
+ type: 'card',
129
+ name: `${module}/cards/${card.key}`,
130
+ data: cardData,
131
+ children: [],
132
+ readOnly: moduleNameFromCardKey(card.key) !== projectPrefix,
133
+ };
134
+ // Recursively process children if they exist
135
+ if (children && children.length > 0) {
136
+ cardNode.children = children.map((child) => createCardNode(child, module, projectPrefix));
137
+ }
138
+ return cardNode;
139
+ }
140
+ // Helper function to process templates using templateTree query
141
+ async function processTemplates(commands, projectPrefix) {
142
+ const templates = await commands.showCmd.showResources('templates');
143
+ const templateTree = await commands.showCmd.showAllTemplateCards();
144
+ const rootTemplates = {};
145
+ const moduleTemplates = {};
146
+ for (const { name, cards } of templateTree) {
147
+ for (const card of cards) {
148
+ const { prefix } = parseResourcePrefix(name);
149
+ const cardNode = createCardNode(card, prefix, projectPrefix);
150
+ if (prefix === projectPrefix || !prefix) {
151
+ if (!rootTemplates[name]) {
152
+ templates.splice(templates.indexOf(name), 1);
153
+ rootTemplates[name] = [];
154
+ }
155
+ rootTemplates[name].push(cardNode);
156
+ }
157
+ else {
158
+ if (!moduleTemplates[prefix]) {
159
+ moduleTemplates[prefix] = {};
160
+ }
161
+ if (!moduleTemplates[prefix][name]) {
162
+ templates.splice(templates.indexOf(name), 1);
163
+ moduleTemplates[prefix][name] = [];
164
+ }
165
+ moduleTemplates[prefix][name].push(cardNode);
166
+ }
167
+ }
168
+ }
169
+ const rootResources = await Promise.all(Object.entries(rootTemplates).map(([templateName, cards]) => createResourceNode(commands, 'templates', templateName, projectPrefix, cards)));
170
+ const moduleResources = {};
171
+ for (const [prefix, templates] of Object.entries(moduleTemplates)) {
172
+ moduleResources[prefix] = await Promise.all(Object.entries(templates).map(([templateName, cards]) => createResourceNode(commands, 'templates', templateName, projectPrefix, cards)));
173
+ }
174
+ // Add also templates that do not have any cards
175
+ for (const template of templates) {
176
+ const { prefix } = parseResourcePrefix(template);
177
+ if (prefix === projectPrefix) {
178
+ if (!rootResources.find((resource) => resource.name === template)) {
179
+ rootResources.push(await createResourceNode(commands, 'templates', template, projectPrefix));
180
+ }
181
+ }
182
+ else {
183
+ if (!moduleResources[prefix]) {
184
+ moduleResources[prefix] = [];
185
+ }
186
+ if (!moduleResources[prefix].find((resource) => resource.name === template)) {
187
+ moduleResources[prefix].push(await createResourceNode(commands, 'templates', template, projectPrefix));
188
+ }
189
+ }
190
+ }
191
+ return { rootResources, moduleResources };
192
+ }
193
+ // Helper function to group regular resources by prefix
194
+ async function groupResourcesByPrefix(commands, resourceType, projectPrefix) {
195
+ const resourceNames = await commands.showCmd.showResources(resourceType);
196
+ const resources = await Promise.all(resourceNames.map((name) => createResourceNode(commands, resourceType, name, projectPrefix)));
197
+ const rootResources = [];
198
+ const moduleResources = {};
199
+ resources.forEach((resource) => {
200
+ const { prefix } = parseResourcePrefix(resource.name);
201
+ if (prefix === projectPrefix || !prefix) {
202
+ rootResources.push(resource);
203
+ }
204
+ else {
205
+ if (!moduleResources[prefix]) {
206
+ moduleResources[prefix] = [];
207
+ }
208
+ moduleResources[prefix].push(resource);
209
+ }
210
+ });
211
+ return { rootResources, moduleResources };
212
+ }
213
+ /**
214
+ * Delete a resource.
215
+ * @param commands Command manager.
216
+ * @param resource Resource to delete.
217
+ */
218
+ export async function deleteResource(commands, resource) {
219
+ return commands.removeCmd.remove(resource.type.substring(0, resource.type.length - 1), resourceNameToString(resource));
220
+ }
221
+ /**
222
+ * Get the content of a file in a resource.
223
+ * @param commands Command manager.
224
+ * @param module Name of the module.
225
+ * @param type Name of the type.
226
+ * @param resource Name of the resource.
227
+ * @param fileName Name of the file.
228
+ * @returns The content of the file.
229
+ */
230
+ export async function getFileContent(commands, module, type, resource, fileName) {
231
+ return commands.showCmd.showFile(resourceName(`${module}/${type}/${resource}`), fileName);
232
+ }
233
+ /**
234
+ * Update a file of a folder resource. Cannot be used to create a new file.
235
+ * @param commands Command manager.
236
+ * @param module Name of the module.
237
+ * @param type Name of the type.
238
+ * @param resource Name of the resource.
239
+ * @param fileName Name of the file.
240
+ * @param changedContent The new content for the file.
241
+ * @returns The updated file content.
242
+ */
243
+ export async function updateFile(commands, module, type, resource, fileName, changedContent) {
244
+ return commands.editCmd.editResourceContent(resourceName(`${module}/${type}/${resource}`), fileName, changedContent);
245
+ }
246
+ /**
247
+ * Validate a single resource.
248
+ * @param commands Command manager.
249
+ * @param resource Resource to validate.
250
+ * @returns Validation result with errors and validity status.
251
+ */
252
+ export async function validateResource(commands, resource) {
253
+ const errors = await commands.validateCmd.validateResource(resource, commands.project);
254
+ return {
255
+ errors: errors.split('\n\n').filter((error) => error !== ''),
256
+ };
257
+ }
258
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/domain/resources/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAQF,OAAO,EAEL,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,aAAa,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yberismo 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
+ import { isSSGContext } from '../../export.js';
15
+ import * as templateService from './service.js';
16
+ import { createTemplateSchema } from './schema.js';
17
+ import { zValidator } from '../../middleware/zvalidator.js';
18
+ const router = new Hono();
19
+ /**
20
+ * @swagger
21
+ * /api/templates:
22
+ * get:
23
+ * summary: Returns a list of all templates in the defined project.
24
+ * description: List of templates includes only the names of the templates in the project.
25
+ * responses:
26
+ * 200:
27
+ * description: Array containing the names of the project templates.
28
+ * 400:
29
+ * description: Error in reading project details.
30
+ * 500:
31
+ * description: project_path not set or other internal error
32
+ */
33
+ router.get('/', async (c) => {
34
+ // We do not need templates in ssg context
35
+ if (isSSGContext(c)) {
36
+ return c.json([]);
37
+ }
38
+ const commands = c.get('commands');
39
+ try {
40
+ const response = await templateService.getTemplatesWithDetails(commands);
41
+ return c.json(response);
42
+ }
43
+ catch (error) {
44
+ return c.json({
45
+ error: `${error instanceof Error ? error.message : 'Unknown error'} from path ${c.get('projectPath')}`,
46
+ }, 500);
47
+ }
48
+ });
49
+ /**
50
+ * @swagger
51
+ * /api/templates:
52
+ * post:
53
+ * summary: Create a new template
54
+ * description: Creates a new template with the specified identifier
55
+ * requestBody:
56
+ * required: true
57
+ * content:
58
+ * application/json:
59
+ * schema:
60
+ * type: object
61
+ * properties:
62
+ * identifier:
63
+ * type: string
64
+ * required:
65
+ * - identifier
66
+ * responses:
67
+ * 200:
68
+ * description: Template created successfully
69
+ * 400:
70
+ * description: Invalid request body
71
+ * 500:
72
+ * description: Server error
73
+ */
74
+ router.post('/', zValidator('json', createTemplateSchema), async (c) => {
75
+ const commands = c.get('commands');
76
+ const { identifier } = c.req.valid('json');
77
+ await templateService.createTemplate(commands, identifier);
78
+ return c.json({ message: 'Template created successfully' });
79
+ });
80
+ export default router;
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,eAAe,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1B,0CAA0C;IAC1C,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;QACpB,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAEnC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QACzE,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,CAAC,IAAI,CACX;YACE,KAAK,EAAE,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,cAAc,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;SACvG,EACD,GAAG,CACJ,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACrE,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACnC,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3C,MAAM,eAAe,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC3D,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
@@ -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
+ export const createTemplateSchema = z.object({
16
+ identifier: identifierSchema,
17
+ });
18
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/domain/templates/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,UAAU,EAAE,gBAAgB;CAC7B,CAAC,CAAC"}
@@ -0,0 +1,23 @@
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
+ export async function getTemplatesWithDetails(commands) {
14
+ const response = await commands.showCmd.showTemplatesWithDetails();
15
+ if (!response) {
16
+ throw new Error('No templates found');
17
+ }
18
+ return response;
19
+ }
20
+ export async function createTemplate(commands, templateName) {
21
+ await commands.createCmd.createTemplate(templateName, '');
22
+ }
23
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/domain/templates/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAIF,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,QAAwB;IACpE,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC;IACnE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAwB,EACxB,YAAoB;IAEpB,MAAM,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,44 @@
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
+ import * as treeService from './service.js';
15
+ import { isSSGContext } from '../../export.js';
16
+ const router = new Hono();
17
+ /**
18
+ * @swagger
19
+ * /api/tree:
20
+ * get:
21
+ * summary: Returns a card tree of all cards in the defined project.
22
+ * description: List of cards displayed in hierarchical format as a tree
23
+ * responses:
24
+ * 200:
25
+ * description: Object containing the project cards in tree format. See definitions.ts/Card for the structure.
26
+ * 400:
27
+ * description: Error in reading project details.
28
+ * 500:
29
+ * description: project_path not set or other internal error
30
+ */
31
+ router.get('/', async (c) => {
32
+ const commands = c.get('commands');
33
+ try {
34
+ const response = await treeService.getCardTree(commands, isSSGContext(c));
35
+ return c.json(response);
36
+ }
37
+ catch (error) {
38
+ return c.json({
39
+ error: `${error instanceof Error ? error.message : 'Unknown error'} from path ${c.get('projectPath')}`,
40
+ }, 500);
41
+ }
42
+ });
43
+ export default router;
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/tree/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1B,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAEnC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,CAAC,IAAI,CACX;YACE,KAAK,EAAE,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,cAAc,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;SACvG,EACD,GAAG,CACJ,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
@@ -0,0 +1,17 @@
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
+ export async function getCardTree(commands, isSsg) {
14
+ await commands.calculateCmd.generate();
15
+ return commands.calculateCmd.runQuery('tree', isSsg ? 'exportedSite' : 'localApp');
16
+ }
17
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/domain/tree/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAIF,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAwB,EAAE,KAAc;IACxE,MAAM,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACvC,OAAO,QAAQ,CAAC,YAAY,CAAC,QAAQ,CACnC,MAAM,EACN,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CACpC,CAAC;AACJ,CAAC"}