@cyberismo/backend 0.0.9 → 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/domain/calculations/index.js +53 -1
- package/dist/domain/calculations/index.js.map +1 -1
- package/dist/domain/calculations/schema.js +7 -0
- package/dist/domain/calculations/schema.js.map +1 -1
- package/dist/domain/calculations/service.js +5 -0
- package/dist/domain/calculations/service.js.map +1 -1
- package/dist/domain/cards/lib.js +1 -1
- package/dist/domain/cards/lib.js.map +1 -1
- package/dist/domain/resources/index.js +5 -2
- package/dist/domain/resources/index.js.map +1 -1
- package/dist/public/THIRD-PARTY.txt +1 -1
- package/dist/public/assets/{index-CXcBl8RN.js → index-jhDO7xT5.js} +21778 -21677
- package/dist/public/index.html +1 -1
- package/package.json +2 -2
- package/src/domain/calculations/index.ts +68 -1
- package/src/domain/calculations/schema.ts +9 -0
- package/src/domain/calculations/service.ts +11 -0
- package/src/domain/cards/lib.ts +1 -1
- package/src/domain/resources/index.ts +6 -4
package/dist/public/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
name="msapplication-TileImage"
|
|
12
12
|
content="/cropped-favicon-270x270.png"
|
|
13
13
|
/>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-jhDO7xT5.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-BngW8o1w.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
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": [],
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"hono": "^4.7.5",
|
|
15
15
|
"mime-types": "^3.0.1",
|
|
16
16
|
"zod": "^4.0.17",
|
|
17
|
-
"@cyberismo/data-handler": "0.0.
|
|
17
|
+
"@cyberismo/data-handler": "0.0.10"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/mime-types": "^3.0.0",
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
|
|
14
14
|
import { Hono } from 'hono';
|
|
15
15
|
import * as calculationService from './service.js';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
createCalculationSchema,
|
|
18
|
+
updateCalculationParamsSchema,
|
|
19
|
+
updateCalculationBodySchema,
|
|
20
|
+
} from './schema.js';
|
|
17
21
|
import { zValidator } from '../../middleware/zvalidator.js';
|
|
18
22
|
|
|
19
23
|
const router = new Hono();
|
|
@@ -52,3 +56,66 @@ router.post('/', zValidator('json', createCalculationSchema), async (c) => {
|
|
|
52
56
|
});
|
|
53
57
|
|
|
54
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
|
+
);
|
|
@@ -12,7 +12,16 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
+
import { resourceParamsSchema } from '../../common/validationSchemas.js';
|
|
15
16
|
|
|
16
17
|
export const createCalculationSchema = z.object({
|
|
17
18
|
fileName: z.string().min(1),
|
|
18
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
|
+
});
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type { CommandManager } from '@cyberismo/data-handler';
|
|
15
|
+
import { resourceName } from '@cyberismo/data-handler';
|
|
15
16
|
|
|
16
17
|
export async function createCalculation(
|
|
17
18
|
commands: CommandManager,
|
|
@@ -19,3 +20,13 @@ export async function createCalculation(
|
|
|
19
20
|
) {
|
|
20
21
|
await commands.createCmd.createCalculation(fileName);
|
|
21
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
|
+
}
|
package/src/domain/cards/lib.ts
CHANGED
|
@@ -64,7 +64,7 @@ export async function getCardDetails(
|
|
|
64
64
|
try {
|
|
65
65
|
asciidocContent = await evaluateMacros(cardDetailsResponse.content || '', {
|
|
66
66
|
context: staticMode ? 'exportedSite' : 'localApp',
|
|
67
|
-
mode: staticMode ? '
|
|
67
|
+
mode: staticMode ? 'staticSite' : 'inject',
|
|
68
68
|
project: commands.project,
|
|
69
69
|
cardKey: key,
|
|
70
70
|
});
|
|
@@ -103,9 +103,9 @@ router.get(
|
|
|
103
103
|
const resourceParams = c.req.valid('param');
|
|
104
104
|
|
|
105
105
|
try {
|
|
106
|
-
|
|
107
|
-
await resourceService.validateResource(commands, resourceParams)
|
|
108
|
-
);
|
|
106
|
+
const response: ResourceValidationResponse =
|
|
107
|
+
await resourceService.validateResource(commands, resourceParams);
|
|
108
|
+
return c.json(response);
|
|
109
109
|
} catch (error) {
|
|
110
110
|
if (error instanceof Error && error.message.includes('not found')) {
|
|
111
111
|
return c.json({ error: error.message }, 404);
|
|
@@ -157,7 +157,9 @@ router.delete(
|
|
|
157
157
|
const commands = c.get('commands');
|
|
158
158
|
const resourceParams = c.req.valid('param');
|
|
159
159
|
await resourceService.deleteResource(commands, resourceParams);
|
|
160
|
-
return c.json({
|
|
160
|
+
return c.json({
|
|
161
|
+
message: 'Resource deleted',
|
|
162
|
+
});
|
|
161
163
|
},
|
|
162
164
|
);
|
|
163
165
|
|