@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
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/public/index.html
CHANGED
|
@@ -4,7 +4,14 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Cyberismo App</title>
|
|
7
|
-
<
|
|
7
|
+
<link rel="icon" href="/cropped-favicon-32x32.png" sizes="32x32" />
|
|
8
|
+
<link rel="icon" href="/cropped-favicon-192x192.png" sizes="192x192" />
|
|
9
|
+
<link rel="apple-touch-icon" href="/cropped-favicon-180x180.png" />
|
|
10
|
+
<meta
|
|
11
|
+
name="msapplication-TileImage"
|
|
12
|
+
content="/cropped-favicon-270x270.png"
|
|
13
|
+
/>
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-jhDO7xT5.js"></script>
|
|
8
15
|
<link rel="stylesheet" crossorigin href="/assets/index-BngW8o1w.css">
|
|
9
16
|
</head>
|
|
10
17
|
<body>
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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 {};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE"}
|
package/dist/utils.js
CHANGED
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AACF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAoC,EACpC,gBAAwB,CAAC;IAEzB,MAAM,eAAe,GAA+B,EAAE,CAAC;IACvD,MAAM,eAAe,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE;QACtD,MAAM,EAAE,EAAE,CAAC;QACX,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,IAAI,EAAE,CAAC;QACf,CAAC;IACH,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MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YACvB,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QACH,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC,CAAC;QAC7D,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberismo/backend",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Express backend for Cyberismo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@asciidoctor/core": "^3.0.4",
|
|
11
11
|
"@hono/node-server": "^1.14.1",
|
|
12
|
+
"@hono/zod-validator": "^0.7.2",
|
|
12
13
|
"dotenv": "^16.5.0",
|
|
13
14
|
"hono": "^4.7.5",
|
|
14
15
|
"mime-types": "^3.0.1",
|
|
15
|
-
"
|
|
16
|
+
"zod": "^4.0.17",
|
|
17
|
+
"@cyberismo/data-handler": "0.0.10"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
18
20
|
"@types/mime-types": "^3.0.0",
|
|
@@ -31,8 +33,10 @@
|
|
|
31
33
|
"start": "tsx src/main.ts",
|
|
32
34
|
"start-e2e": "node dist/main.js",
|
|
33
35
|
"dev": "tsx watch src/main.ts",
|
|
36
|
+
"debug": "tsx --inspect-brk src/main.ts",
|
|
34
37
|
"export": "pnpm build && node dist/main.js --export",
|
|
35
38
|
"build": "tsc -p tsconfig.build.json && shx rm -rf ./dist/public && shx cp -r ../app/dist ./dist/public",
|
|
36
|
-
"test": "vitest run"
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"lint": "eslint ."
|
|
37
41
|
}
|
|
38
42
|
}
|
package/src/app.ts
CHANGED
|
@@ -15,14 +15,22 @@ import { staticFrontendDirRelative } from './utils.js';
|
|
|
15
15
|
import { cors } from 'hono/cors';
|
|
16
16
|
import { serveStatic } from '@hono/node-server/serve-static';
|
|
17
17
|
import { attachCommandManager } from './middleware/commandManager.js';
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
18
|
+
import calculationsRouter from './domain/calculations/index.js';
|
|
19
|
+
import cardsRouter from './domain/cards/index.js';
|
|
20
|
+
import cardTypesRouter from './domain/cardTypes/index.js';
|
|
21
|
+
import fieldTypesRouter from './domain/fieldTypes/index.js';
|
|
22
|
+
import graphModelsRouter from './domain/graphModels/index.js';
|
|
23
|
+
import graphViewsRouter from './domain/graphViews/index.js';
|
|
24
|
+
import linkTypesRouter from './domain/linkTypes/index.js';
|
|
25
|
+
import reportsRouter from './domain/reports/index.js';
|
|
26
|
+
import templatesRouter from './domain/templates/index.js';
|
|
27
|
+
import treeRouter from './domain/tree/index.js';
|
|
28
|
+
import workflowsRouter from './domain/workflows/index.js';
|
|
23
29
|
import { readFile } from 'node:fs/promises';
|
|
24
30
|
import path from 'node:path';
|
|
25
31
|
import { isSSGContext } from './export.js';
|
|
32
|
+
import resourcesRouter from './domain/resources/index.js';
|
|
33
|
+
import logicProgramsRouter from './domain/logicPrograms/index.js';
|
|
26
34
|
|
|
27
35
|
/**
|
|
28
36
|
* Create the Hono app for the backend
|
|
@@ -44,11 +52,19 @@ export function createApp(projectPath?: string) {
|
|
|
44
52
|
app.use(attachCommandManager(projectPath));
|
|
45
53
|
|
|
46
54
|
// Wire up routes
|
|
55
|
+
app.route('/api/calculations', calculationsRouter);
|
|
47
56
|
app.route('/api/cards', cardsRouter);
|
|
57
|
+
app.route('/api/cardTypes', cardTypesRouter);
|
|
48
58
|
app.route('/api/fieldTypes', fieldTypesRouter);
|
|
59
|
+
app.route('/api/graphModels', graphModelsRouter);
|
|
60
|
+
app.route('/api/graphViews', graphViewsRouter);
|
|
49
61
|
app.route('/api/linkTypes', linkTypesRouter);
|
|
62
|
+
app.route('/api/reports', reportsRouter);
|
|
50
63
|
app.route('/api/templates', templatesRouter);
|
|
51
64
|
app.route('/api/tree', treeRouter);
|
|
65
|
+
app.route('/api/workflows', workflowsRouter);
|
|
66
|
+
app.route('/api/resources', resourcesRouter);
|
|
67
|
+
app.route('/api/logicPrograms', logicProgramsRouter);
|
|
52
68
|
|
|
53
69
|
// serve index.html for all other routes
|
|
54
70
|
app.notFound(async (c) => {
|
|
@@ -67,9 +83,7 @@ export function createApp(projectPath?: string) {
|
|
|
67
83
|
}
|
|
68
84
|
return c.json(
|
|
69
85
|
{
|
|
70
|
-
error:
|
|
71
|
-
? err.message || 'Internal Server Error'
|
|
72
|
-
: 'Internal Server Error',
|
|
86
|
+
error: err.message || 'Internal Server Error',
|
|
73
87
|
},
|
|
74
88
|
500,
|
|
75
89
|
);
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { Validate } from '@cyberismo/data-handler';
|
|
15
|
+
|
|
16
|
+
export const resourceTypes = [
|
|
17
|
+
'calculations',
|
|
18
|
+
'cardTypes',
|
|
19
|
+
'fieldTypes',
|
|
20
|
+
'graphModels',
|
|
21
|
+
'graphViews',
|
|
22
|
+
'linkTypes',
|
|
23
|
+
'reports',
|
|
24
|
+
'templates',
|
|
25
|
+
'workflows',
|
|
26
|
+
] as const;
|
|
27
|
+
|
|
28
|
+
export const identifierSchema = z
|
|
29
|
+
.string()
|
|
30
|
+
.refine((value) => Validate.isValidIdentifierName(value), {
|
|
31
|
+
message: 'Invalid identifier',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const resourceParamsSchema = z.object({
|
|
35
|
+
prefix: z.string(),
|
|
36
|
+
type: z.enum(resourceTypes),
|
|
37
|
+
identifier: identifierSchema,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type ResourceParams = z.infer<typeof resourceParamsSchema>;
|
|
41
|
+
|
|
42
|
+
export const resourceParamsWithCard = resourceParamsSchema.extend({
|
|
43
|
+
type: z.enum([...resourceTypes, 'cards']),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type ResourceParamsWithCard = z.infer<typeof resourceParamsWithCard>;
|
|
@@ -0,0 +1,121 @@
|
|
|
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 calculationService from './service.js';
|
|
16
|
+
import {
|
|
17
|
+
createCalculationSchema,
|
|
18
|
+
updateCalculationParamsSchema,
|
|
19
|
+
updateCalculationBodySchema,
|
|
20
|
+
} from './schema.js';
|
|
21
|
+
import { zValidator } from '../../middleware/zvalidator.js';
|
|
22
|
+
|
|
23
|
+
const router = new Hono();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @swagger
|
|
27
|
+
* /api/calculations:
|
|
28
|
+
* post:
|
|
29
|
+
* summary: Create a new calculation
|
|
30
|
+
* description: Creates a new calculation file with the specified fileName
|
|
31
|
+
* requestBody:
|
|
32
|
+
* required: true
|
|
33
|
+
* content:
|
|
34
|
+
* application/json:
|
|
35
|
+
* schema:
|
|
36
|
+
* type: object
|
|
37
|
+
* properties:
|
|
38
|
+
* fileName:
|
|
39
|
+
* type: string
|
|
40
|
+
* required:
|
|
41
|
+
* - fileName
|
|
42
|
+
* responses:
|
|
43
|
+
* 200:
|
|
44
|
+
* description: Calculation created successfully
|
|
45
|
+
* 400:
|
|
46
|
+
* description: Invalid request body
|
|
47
|
+
* 500:
|
|
48
|
+
* description: Server error
|
|
49
|
+
*/
|
|
50
|
+
router.post('/', zValidator('json', createCalculationSchema), async (c) => {
|
|
51
|
+
const commands = c.get('commands');
|
|
52
|
+
const { fileName } = c.req.valid('json');
|
|
53
|
+
|
|
54
|
+
await calculationService.createCalculation(commands, fileName);
|
|
55
|
+
return c.json({ message: 'Calculation created successfully' });
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export default router;
|
|
59
|
+
/**
|
|
60
|
+
* @swagger
|
|
61
|
+
* /api/calculations/{prefix}/{identifier}:
|
|
62
|
+
* put:
|
|
63
|
+
* summary: Update a calculation content
|
|
64
|
+
* description: Updates the content of a calculation file
|
|
65
|
+
* parameters:
|
|
66
|
+
* - in: path
|
|
67
|
+
* name: prefix
|
|
68
|
+
* required: true
|
|
69
|
+
* schema:
|
|
70
|
+
* type: string
|
|
71
|
+
* description: Prefix of the calculation
|
|
72
|
+
* - in: path
|
|
73
|
+
* name: type
|
|
74
|
+
* required: true
|
|
75
|
+
* schema:
|
|
76
|
+
* type: string
|
|
77
|
+
* description: Resource type (must be 'calculations')
|
|
78
|
+
* - in: path
|
|
79
|
+
* name: identifier
|
|
80
|
+
* required: true
|
|
81
|
+
* schema:
|
|
82
|
+
* type: string
|
|
83
|
+
* description: Identifier of the calculation
|
|
84
|
+
* requestBody:
|
|
85
|
+
* required: true
|
|
86
|
+
* content:
|
|
87
|
+
* application/json:
|
|
88
|
+
* schema:
|
|
89
|
+
* type: object
|
|
90
|
+
* properties:
|
|
91
|
+
* content:
|
|
92
|
+
* type: string
|
|
93
|
+
* description: New content for the calculation
|
|
94
|
+
* responses:
|
|
95
|
+
* 200:
|
|
96
|
+
* description: Calculation updated successfully
|
|
97
|
+
* 400:
|
|
98
|
+
* description: Invalid request
|
|
99
|
+
* 404:
|
|
100
|
+
* description: Calculation not found
|
|
101
|
+
* 500:
|
|
102
|
+
* description: Server error
|
|
103
|
+
*/
|
|
104
|
+
router.put(
|
|
105
|
+
'/:prefix/:type/:identifier',
|
|
106
|
+
zValidator('param', updateCalculationParamsSchema),
|
|
107
|
+
zValidator('json', updateCalculationBodySchema),
|
|
108
|
+
async (c) => {
|
|
109
|
+
const commands = c.get('commands');
|
|
110
|
+
const { prefix, identifier } = c.req.valid('param');
|
|
111
|
+
const { content } = c.req.valid('json');
|
|
112
|
+
|
|
113
|
+
await calculationService.updateCalculation(
|
|
114
|
+
commands,
|
|
115
|
+
prefix,
|
|
116
|
+
identifier,
|
|
117
|
+
content,
|
|
118
|
+
);
|
|
119
|
+
return c.json({ message: 'Calculation updated successfully' });
|
|
120
|
+
},
|
|
121
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { resourceParamsSchema } from '../../common/validationSchemas.js';
|
|
16
|
+
|
|
17
|
+
export const createCalculationSchema = z.object({
|
|
18
|
+
fileName: z.string().min(1),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const updateCalculationBodySchema = z.object({
|
|
22
|
+
content: z.string(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const updateCalculationParamsSchema = resourceParamsSchema.extend({
|
|
26
|
+
type: z.literal('calculations'),
|
|
27
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { resourceName } from '@cyberismo/data-handler';
|
|
16
|
+
|
|
17
|
+
export async function createCalculation(
|
|
18
|
+
commands: CommandManager,
|
|
19
|
+
fileName: string,
|
|
20
|
+
) {
|
|
21
|
+
await commands.createCmd.createCalculation(fileName);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function updateCalculation(
|
|
25
|
+
commands: CommandManager,
|
|
26
|
+
prefix: string,
|
|
27
|
+
identifier: string,
|
|
28
|
+
content: string,
|
|
29
|
+
) {
|
|
30
|
+
const name = resourceName(`${prefix}/calculations/${identifier}`, true);
|
|
31
|
+
await commands.editCmd.editCalculation(name, content);
|
|
32
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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 cardTypeService from './service.js';
|
|
16
|
+
import { createCardTypeSchema } from './schema.js';
|
|
17
|
+
import { zValidator } from '../../middleware/zvalidator.js';
|
|
18
|
+
|
|
19
|
+
const router = new Hono();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @swagger
|
|
23
|
+
* /api/cardTypes:
|
|
24
|
+
* get:
|
|
25
|
+
* summary: Returns a list of all card types in the defined project.
|
|
26
|
+
* description: List of card types includes all card types in the project with all their details
|
|
27
|
+
* responses:
|
|
28
|
+
* 200:
|
|
29
|
+
* description: Object containing the project card types.
|
|
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 cardTypes = await cardTypeService.getCardTypes(commands);
|
|
40
|
+
return c.json(cardTypes);
|
|
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/cardTypes:
|
|
54
|
+
* post:
|
|
55
|
+
* summary: Create a new card type
|
|
56
|
+
* description: Creates a new card type with the specified workflow
|
|
57
|
+
* requestBody:
|
|
58
|
+
* required: true
|
|
59
|
+
* content:
|
|
60
|
+
* application/json:
|
|
61
|
+
* schema:
|
|
62
|
+
* type: object
|
|
63
|
+
* properties:
|
|
64
|
+
* cardTypeName:
|
|
65
|
+
* type: string
|
|
66
|
+
* workflowName:
|
|
67
|
+
* type: string
|
|
68
|
+
* required:
|
|
69
|
+
* - cardTypeName
|
|
70
|
+
* - workflowName
|
|
71
|
+
* responses:
|
|
72
|
+
* 200:
|
|
73
|
+
* description: Card type created successfully
|
|
74
|
+
* 400:
|
|
75
|
+
* description: Invalid request body
|
|
76
|
+
* 500:
|
|
77
|
+
* description: Server error
|
|
78
|
+
*/
|
|
79
|
+
router.post('/', zValidator('json', createCardTypeSchema), async (c) => {
|
|
80
|
+
const commands = c.get('commands');
|
|
81
|
+
const { identifier, workflowName } = c.req.valid('json');
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
await cardTypeService.createCardType(commands, identifier, workflowName);
|
|
85
|
+
return c.json({ message: 'Card type created successfully' });
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return c.json(
|
|
88
|
+
{
|
|
89
|
+
error: `${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
90
|
+
},
|
|
91
|
+
500,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
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
|
+
import { z } from 'zod';
|
|
14
|
+
import { identifierSchema } from '../../common/validationSchemas.js';
|
|
15
|
+
|
|
16
|
+
export const createCardTypeSchema = z.object({
|
|
17
|
+
identifier: identifierSchema,
|
|
18
|
+
workflowName: z.string(),
|
|
19
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
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 getCardTypes(commands: CommandManager) {
|
|
17
|
+
const cardTypesWithDetails =
|
|
18
|
+
await commands.showCmd.showCardTypesWithDetails();
|
|
19
|
+
return cardTypesWithDetails;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function createCardType(
|
|
23
|
+
commands: CommandManager,
|
|
24
|
+
cardTypeName: string,
|
|
25
|
+
workflowName: string,
|
|
26
|
+
) {
|
|
27
|
+
await commands.createCmd.createCardType(cardTypeName, workflowName);
|
|
28
|
+
}
|