sovrium 0.1.0 → 0.2.0
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/README.md +65 -185
- package/package.json +6 -6
- package/src/application/use-cases/server/static-content-generators.ts +18 -2
- package/src/domain/models/api/activity.ts +87 -0
- package/src/domain/models/api/comments.ts +131 -0
- package/src/domain/models/api/index.ts +9 -0
- package/src/domain/models/api/params.ts +83 -0
- package/src/infrastructure/server/route-setup/openapi-routes/activity-routes.ts +72 -0
- package/src/infrastructure/server/route-setup/openapi-routes/analytics-routes.ts +176 -0
- package/src/infrastructure/server/route-setup/openapi-routes/batch-routes.ts +215 -0
- package/src/infrastructure/server/route-setup/openapi-routes/health-routes.ts +38 -0
- package/src/infrastructure/server/route-setup/openapi-routes/record-routes.ts +444 -0
- package/src/infrastructure/server/route-setup/openapi-routes/table-routes.ts +100 -0
- package/src/infrastructure/server/route-setup/openapi-routes/view-routes.ts +104 -0
- package/src/infrastructure/server/route-setup/openapi-schema.ts +40 -40
- package/src/presentation/styling/parse-style.ts +17 -9
- package/schemas/0.0.1/app.openapi.json +0 -70
- package/schemas/0.0.1/app.schema.json +0 -7961
- package/schemas/0.0.2/app.openapi.json +0 -70
- package/schemas/0.0.2/app.schema.json +0 -7456
- package/schemas/0.1.0/app.openapi.json +0 -80
- package/schemas/0.1.0/app.schema.json +0 -8829
|
@@ -5,8 +5,17 @@
|
|
|
5
5
|
* found in the LICENSE.md file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { OpenAPIHono
|
|
9
|
-
import {
|
|
8
|
+
import { OpenAPIHono } from '@hono/zod-openapi'
|
|
9
|
+
import { registerActivityRoutes } from './openapi-routes/activity-routes'
|
|
10
|
+
import { registerAnalyticsRoutes } from './openapi-routes/analytics-routes'
|
|
11
|
+
import { registerBatchRoutes } from './openapi-routes/batch-routes'
|
|
12
|
+
import { registerHealthRoutes } from './openapi-routes/health-routes'
|
|
13
|
+
import { registerRecordRoutes } from './openapi-routes/record-routes'
|
|
14
|
+
import { registerTableRoutes } from './openapi-routes/table-routes'
|
|
15
|
+
import { registerViewRoutes } from './openapi-routes/view-routes'
|
|
16
|
+
|
|
17
|
+
// Read version from package.json at module load (avoids JSON import lint issues)
|
|
18
|
+
const { version: APP_VERSION } = await Bun.file('package.json').json()
|
|
10
19
|
|
|
11
20
|
/**
|
|
12
21
|
* OpenAPI Schema Generator
|
|
@@ -25,7 +34,7 @@ import { healthResponseSchema } from '@/domain/models/api/health'
|
|
|
25
34
|
* **Usage**:
|
|
26
35
|
* 1. Runtime: Server uses regular Hono routes from api-routes.ts
|
|
27
36
|
* 2. Docs: Server exposes this schema at `/api/openapi.json` and `/api/scalar`
|
|
28
|
-
* 3. Export: Script exports this schema to `schemas/
|
|
37
|
+
* 3. Export: Script exports this schema to `schemas/{version}/app.openapi.json`
|
|
29
38
|
*/
|
|
30
39
|
|
|
31
40
|
/**
|
|
@@ -38,42 +47,13 @@ import { healthResponseSchema } from '@/domain/models/api/health'
|
|
|
38
47
|
const createOpenApiApp = () => {
|
|
39
48
|
const app = new OpenAPIHono()
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
operationId: 'healthCheck',
|
|
49
|
-
tags: ['infrastructure'],
|
|
50
|
-
responses: {
|
|
51
|
-
200: {
|
|
52
|
-
content: {
|
|
53
|
-
'application/json': {
|
|
54
|
-
schema: healthResponseSchema,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
description: 'Server is healthy',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
// Mount route with dummy handler (only for schema generation)
|
|
63
|
-
|
|
64
|
-
app.openapi(healthRoute, (c) => {
|
|
65
|
-
return c.json({
|
|
66
|
-
status: 'ok',
|
|
67
|
-
timestamp: new Date().toISOString(),
|
|
68
|
-
app: {
|
|
69
|
-
name: 'Sovrium',
|
|
70
|
-
},
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
// Future routes will be added here:
|
|
75
|
-
// app.openapi(listTablesRoute, ...)
|
|
76
|
-
// app.openapi(getTableRoute, ...)
|
|
50
|
+
registerHealthRoutes(app)
|
|
51
|
+
registerTableRoutes(app)
|
|
52
|
+
registerRecordRoutes(app)
|
|
53
|
+
registerBatchRoutes(app)
|
|
54
|
+
registerViewRoutes(app)
|
|
55
|
+
registerActivityRoutes(app)
|
|
56
|
+
registerAnalyticsRoutes(app)
|
|
77
57
|
|
|
78
58
|
return app
|
|
79
59
|
}
|
|
@@ -96,7 +76,7 @@ export const getOpenAPIDocument = () => {
|
|
|
96
76
|
openapi: '3.1.0',
|
|
97
77
|
info: {
|
|
98
78
|
title: 'Sovrium API',
|
|
99
|
-
version:
|
|
79
|
+
version: APP_VERSION as string,
|
|
100
80
|
description:
|
|
101
81
|
'REST API specification for Sovrium application.\n\n' +
|
|
102
82
|
'**Generated Schema**: This schema is automatically generated from the runtime implementation. ' +
|
|
@@ -115,6 +95,26 @@ export const getOpenAPIDocument = () => {
|
|
|
115
95
|
name: 'infrastructure',
|
|
116
96
|
description: 'Infrastructure endpoints (health, metrics)',
|
|
117
97
|
},
|
|
98
|
+
{
|
|
99
|
+
name: 'tables',
|
|
100
|
+
description: 'Table management endpoints',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'records',
|
|
104
|
+
description: 'Record CRUD, comments, and history endpoints',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'views',
|
|
108
|
+
description: 'View management and filtered record access',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'activity',
|
|
112
|
+
description: 'Activity log and audit trail endpoints',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'analytics',
|
|
116
|
+
description: 'Analytics collection and reporting endpoints',
|
|
117
|
+
},
|
|
118
118
|
],
|
|
119
119
|
})
|
|
120
120
|
}
|
|
@@ -196,18 +196,26 @@ export function parseStyle(styleString: string): Record<string, string> {
|
|
|
196
196
|
|
|
197
197
|
// Use reduce for immutable accumulation instead of for-of loop with mutations
|
|
198
198
|
return declarations.reduce<Record<string, string>>((acc, declaration) => {
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
201
|
-
// Convert kebab-case to camelCase (e.g., background-color → backgroundColor)
|
|
202
|
-
const camelCaseProperty = property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
199
|
+
const colonIndex = declaration.indexOf(':')
|
|
200
|
+
if (colonIndex === -1) return acc
|
|
203
201
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
const property = declaration.slice(0, colonIndex).trim()
|
|
203
|
+
const value = declaration.slice(colonIndex + 1).trim()
|
|
204
|
+
if (!property || !value) return acc
|
|
207
205
|
|
|
208
|
-
|
|
206
|
+
// CSS custom properties (--*) must be preserved as-is, not converted to camelCase
|
|
207
|
+
if (property.startsWith('--')) {
|
|
208
|
+
return { ...acc, [property]: value }
|
|
209
209
|
}
|
|
210
|
-
|
|
210
|
+
|
|
211
|
+
// Convert kebab-case to camelCase (e.g., background-color → backgroundColor)
|
|
212
|
+
const camelCaseProperty = property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
213
|
+
|
|
214
|
+
// Normalize animation names to kebab-case
|
|
215
|
+
const normalizedValue =
|
|
216
|
+
camelCaseProperty === 'animation' ? normalizeAnimationValue(value) : value
|
|
217
|
+
|
|
218
|
+
return { ...acc, [camelCaseProperty]: normalizedValue }
|
|
211
219
|
}, {})
|
|
212
220
|
}
|
|
213
221
|
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"openapi": "3.1.0",
|
|
3
|
-
"info": {
|
|
4
|
-
"title": "Sovrium API",
|
|
5
|
-
"version": "0.0.1",
|
|
6
|
-
"description": "REST API specification for Sovrium application.\n\n**Generated Schema**: This schema is automatically generated from the runtime implementation. It reflects the currently implemented endpoints and their schemas.\n\n**Design Specs**: Hand-written OpenAPI specs in `docs/specifications/app/` define the complete API design. Comparing this generated schema with the design specs shows implementation progress."
|
|
7
|
-
},
|
|
8
|
-
"servers": [
|
|
9
|
-
{
|
|
10
|
-
"url": "http://localhost:3000",
|
|
11
|
-
"description": "Development server"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"tags": [
|
|
15
|
-
{
|
|
16
|
-
"name": "infrastructure",
|
|
17
|
-
"description": "Infrastructure endpoints (health, metrics)"
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"components": {
|
|
21
|
-
"schemas": {},
|
|
22
|
-
"parameters": {}
|
|
23
|
-
},
|
|
24
|
-
"paths": {
|
|
25
|
-
"/api/health": {
|
|
26
|
-
"get": {
|
|
27
|
-
"summary": "Health check endpoint",
|
|
28
|
-
"description": "Returns server health status. Used by monitoring tools and E2E tests to verify server is running.",
|
|
29
|
-
"operationId": "healthCheck",
|
|
30
|
-
"tags": ["infrastructure"],
|
|
31
|
-
"responses": {
|
|
32
|
-
"200": {
|
|
33
|
-
"description": "Server is healthy",
|
|
34
|
-
"content": {
|
|
35
|
-
"application/json": {
|
|
36
|
-
"schema": {
|
|
37
|
-
"type": "object",
|
|
38
|
-
"properties": {
|
|
39
|
-
"status": {
|
|
40
|
-
"type": "string",
|
|
41
|
-
"enum": ["ok"],
|
|
42
|
-
"description": "Server health status indicator"
|
|
43
|
-
},
|
|
44
|
-
"timestamp": {
|
|
45
|
-
"type": "string",
|
|
46
|
-
"format": "date-time",
|
|
47
|
-
"description": "ISO 8601 timestamp of the health check"
|
|
48
|
-
},
|
|
49
|
-
"app": {
|
|
50
|
-
"type": "object",
|
|
51
|
-
"properties": {
|
|
52
|
-
"name": {
|
|
53
|
-
"type": "string",
|
|
54
|
-
"description": "Application name from configuration"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"required": ["name"],
|
|
58
|
-
"description": "Application metadata"
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"required": ["status", "timestamp", "app"]
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|