@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.
- package/dist/app.js +22 -8
- package/dist/app.js.map +1 -1
- package/dist/common/validationSchemas.js +39 -0
- package/dist/common/validationSchemas.js.map +1 -0
- package/dist/domain/calculations/index.js +102 -0
- package/dist/domain/calculations/index.js.map +1 -0
- package/dist/domain/calculations/schema.js +24 -0
- package/dist/domain/calculations/schema.js.map +1 -0
- package/dist/domain/calculations/service.js +21 -0
- package/dist/domain/calculations/service.js.map +1 -0
- package/dist/domain/cardTypes/index.js +86 -0
- package/dist/domain/cardTypes/index.js.map +1 -0
- package/dist/domain/cardTypes/schema.js +19 -0
- package/dist/domain/cardTypes/schema.js.map +1 -0
- package/dist/domain/cardTypes/service.js +20 -0
- package/dist/domain/cardTypes/service.js.map +1 -0
- package/dist/{routes/cards.js → domain/cards/index.js} +52 -223
- package/dist/domain/cards/index.js.map +1 -0
- package/dist/domain/cards/lib.js +80 -0
- package/dist/domain/cards/lib.js.map +1 -0
- package/dist/domain/cards/service.js +178 -0
- package/dist/domain/cards/service.js.map +1 -0
- package/dist/domain/fieldTypes/index.js +87 -0
- package/dist/domain/fieldTypes/index.js.map +1 -0
- package/dist/domain/fieldTypes/schema.js +30 -0
- package/dist/domain/fieldTypes/schema.js.map +1 -0
- package/dist/domain/fieldTypes/service.js +24 -0
- package/dist/domain/fieldTypes/service.js.map +1 -0
- package/dist/domain/graphModels/index.js +50 -0
- package/dist/domain/graphModels/index.js.map +1 -0
- package/dist/domain/graphModels/schema.js +18 -0
- package/dist/domain/graphModels/schema.js.map +1 -0
- package/dist/domain/graphModels/service.js +16 -0
- package/dist/domain/graphModels/service.js.map +1 -0
- package/dist/domain/graphViews/index.js +50 -0
- package/dist/domain/graphViews/index.js.map +1 -0
- package/dist/domain/graphViews/schema.js +6 -0
- package/dist/domain/graphViews/schema.js.map +1 -0
- package/dist/domain/graphViews/service.js +16 -0
- package/dist/domain/graphViews/service.js.map +1 -0
- package/dist/domain/linkTypes/index.js +76 -0
- package/dist/domain/linkTypes/index.js.map +1 -0
- package/dist/domain/linkTypes/schema.js +18 -0
- package/dist/domain/linkTypes/schema.js.map +1 -0
- package/dist/domain/linkTypes/service.js +24 -0
- package/dist/domain/linkTypes/service.js.map +1 -0
- package/dist/domain/logicPrograms/index.js +25 -0
- package/dist/domain/logicPrograms/index.js.map +1 -0
- package/dist/domain/logicPrograms/service.js +9 -0
- package/dist/domain/logicPrograms/service.js.map +1 -0
- package/dist/domain/reports/index.js +50 -0
- package/dist/domain/reports/index.js.map +1 -0
- package/dist/domain/reports/schema.js +18 -0
- package/dist/domain/reports/schema.js.map +1 -0
- package/dist/domain/reports/service.js +16 -0
- package/dist/domain/reports/service.js.map +1 -0
- package/dist/domain/resources/index.js +128 -0
- package/dist/domain/resources/index.js.map +1 -0
- package/dist/domain/resources/schema.js +9 -0
- package/dist/domain/resources/schema.js.map +1 -0
- package/dist/domain/resources/service.js +258 -0
- package/dist/domain/resources/service.js.map +1 -0
- package/dist/domain/templates/index.js +81 -0
- package/dist/domain/templates/index.js.map +1 -0
- package/dist/domain/templates/schema.js +18 -0
- package/dist/domain/templates/schema.js.map +1 -0
- package/dist/domain/templates/service.js +23 -0
- package/dist/domain/templates/service.js.map +1 -0
- package/dist/domain/tree/index.js +44 -0
- package/dist/domain/tree/index.js.map +1 -0
- package/dist/domain/tree/service.js +17 -0
- package/dist/domain/tree/service.js.map +1 -0
- package/dist/domain/workflows/index.js +50 -0
- package/dist/domain/workflows/index.js.map +1 -0
- package/dist/domain/workflows/schema.js +18 -0
- package/dist/domain/workflows/schema.js.map +1 -0
- package/dist/domain/workflows/service.js +16 -0
- package/dist/domain/workflows/service.js.map +1 -0
- package/dist/export.js +3 -3
- package/dist/export.js.map +1 -1
- package/dist/middleware/zvalidator.js +8 -0
- package/dist/middleware/zvalidator.js.map +1 -0
- package/dist/public/THIRD-PARTY.txt +2452 -296
- package/dist/public/assets/index-jhDO7xT5.js +161493 -0
- package/dist/public/cropped-favicon-180x180.png +0 -0
- package/dist/public/cropped-favicon-192x192.png +0 -0
- package/dist/public/cropped-favicon-270x270.png +0 -0
- package/dist/public/cropped-favicon-32x32.png +0 -0
- package/dist/public/index.html +8 -1
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.js +3 -1
- package/dist/utils.js.map +1 -1
- package/package.json +7 -3
- package/src/app.ts +22 -8
- package/src/common/validationSchemas.ts +46 -0
- package/src/domain/calculations/index.ts +121 -0
- package/src/domain/calculations/schema.ts +27 -0
- package/src/domain/calculations/service.ts +32 -0
- package/src/domain/cardTypes/index.ts +96 -0
- package/src/domain/cardTypes/schema.ts +19 -0
- package/src/domain/cardTypes/service.ts +28 -0
- package/src/{routes/cards.ts → domain/cards/index.ts} +82 -270
- package/src/domain/cards/lib.ts +103 -0
- package/src/domain/cards/service.ts +254 -0
- package/src/domain/fieldTypes/index.ts +97 -0
- package/src/domain/fieldTypes/schema.ts +30 -0
- package/src/domain/fieldTypes/service.ts +38 -0
- package/src/domain/graphModels/index.ts +54 -0
- package/src/domain/graphModels/schema.ts +18 -0
- package/src/domain/graphModels/service.ts +21 -0
- package/src/domain/graphViews/index.ts +53 -0
- package/src/domain/graphViews/schema.ts +6 -0
- package/src/domain/graphViews/service.ts +20 -0
- package/src/domain/linkTypes/index.ts +84 -0
- package/src/domain/linkTypes/schema.ts +19 -0
- package/src/domain/linkTypes/service.ts +34 -0
- package/src/domain/logicPrograms/index.ts +35 -0
- package/src/domain/logicPrograms/service.ts +25 -0
- package/src/domain/reports/index.ts +54 -0
- package/src/domain/reports/schema.ts +19 -0
- package/src/domain/reports/service.ts +21 -0
- package/src/domain/resources/index.ts +166 -0
- package/src/domain/resources/schema.ts +19 -0
- package/src/domain/resources/service.ts +436 -0
- package/src/domain/templates/index.ts +89 -0
- package/src/domain/templates/schema.ts +19 -0
- package/src/domain/templates/service.ts +29 -0
- package/src/domain/tree/index.ts +50 -0
- package/src/domain/tree/service.ts +22 -0
- package/src/domain/workflows/index.ts +54 -0
- package/src/domain/workflows/schema.ts +19 -0
- package/src/domain/workflows/service.ts +21 -0
- package/src/export.ts +9 -5
- package/src/middleware/commandManager.ts +1 -1
- package/src/middleware/zvalidator.ts +17 -0
- package/src/types.ts +20 -0
- package/src/utils.ts +4 -2
- package/dist/public/assets/index-D5kiRHuF.js +0 -111171
- package/dist/routes/cards.js.map +0 -1
- package/dist/routes/fieldTypes.js +0 -42
- package/dist/routes/fieldTypes.js.map +0 -1
- package/dist/routes/linkTypes.js +0 -42
- package/dist/routes/linkTypes.js.map +0 -1
- package/dist/routes/templates.js +0 -46
- package/dist/routes/templates.js.map +0 -1
- package/dist/routes/tree.js +0 -40
- package/dist/routes/tree.js.map +0 -1
- package/src/routes/fieldTypes.ts +0 -53
- package/src/routes/linkTypes.ts +0 -53
- package/src/routes/templates.ts +0 -52
- 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,166 @@
|
|
|
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
|
+
const response: ResourceValidationResponse =
|
|
107
|
+
await resourceService.validateResource(commands, resourceParams);
|
|
108
|
+
return c.json(response);
|
|
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({
|
|
161
|
+
message: 'Resource deleted',
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
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
|
+
>;
|