@getvision/server 0.3.5 → 0.4.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/.env.example +0 -7
- package/CHANGELOG.md +34 -0
- package/package.json +2 -2
- package/src/service.ts +19 -13
package/.env.example
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
# Inngest Configuration
|
|
2
|
-
INNGEST_DEV=0
|
|
3
|
-
INNGEST_BASE_URL=http://localhost:8288
|
|
4
|
-
INNGEST_REDIS_URI=redis://localhost:6379/8
|
|
5
|
-
INNGEST_EVENT_KEY=a1b2c3d4e5f6789012345678901234567890abcdefabcdef1234567890abcd
|
|
6
|
-
INNGEST_SIGNING_KEY=fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321
|
|
7
|
-
|
|
8
1
|
# Vision Server
|
|
9
2
|
VISION_PORT=9500
|
|
10
3
|
NODE_ENV=development
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @getvision/server
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6e5c887: Migrate all adapters to use UniversalValidator supporting Zod, Valibot, and Standard Schema v1. The new validation system provides:
|
|
8
|
+
- Unified `validator()` function that works with any validation library
|
|
9
|
+
- Automatic error response formatting with proper issue paths
|
|
10
|
+
- Schema introspection for template generation
|
|
11
|
+
- Backward compatibility with existing zValidator (deprecated)
|
|
12
|
+
|
|
13
|
+
**Breaking changes:**
|
|
14
|
+
- `zValidator` is now deprecated in favor of universal `validator()`
|
|
15
|
+
- Error response format has been standardized across all adapters
|
|
16
|
+
- Some internal types have changed to support multiple validation libraries
|
|
17
|
+
|
|
18
|
+
Migration guide:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// Before
|
|
22
|
+
import { zValidator } from "@getvision/adapter-hono";
|
|
23
|
+
app.post("/users", zValidator("json", userSchema));
|
|
24
|
+
|
|
25
|
+
// After (works with Zod, Valibot, or Standard Schema)
|
|
26
|
+
import { validator } from "@getvision/adapter-hono";
|
|
27
|
+
app.post("/users", validator("json", userSchema));
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 0.3.6
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [d5bfbe0]
|
|
35
|
+
- @getvision/core@0.1.0
|
|
36
|
+
|
|
3
37
|
## 0.3.5
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getvision/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vision Server - Meta-framework with built-in observability, pub/sub, and type-safe APIs",
|
|
6
6
|
"exports": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@getvision/core": "0.0
|
|
16
|
+
"@getvision/core": "0.1.0",
|
|
17
17
|
"@hono/node-server": "^1.19.6",
|
|
18
18
|
"bullmq": "^5.62.0",
|
|
19
19
|
"hono-rate-limiter": "^0.4.2",
|
package/src/service.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Hono, Context, MiddlewareHandler, Env, Input } from 'hono'
|
|
2
2
|
import type { z } from 'zod'
|
|
3
|
-
import { VisionCore,
|
|
3
|
+
import { VisionCore, generateTemplate } from '@getvision/core'
|
|
4
|
+
import {
|
|
5
|
+
ValidationError,
|
|
6
|
+
createValidationErrorResponse,
|
|
7
|
+
UniversalValidator
|
|
8
|
+
} from '@getvision/core'
|
|
4
9
|
import type { EndpointConfig, Handler } from './types'
|
|
5
10
|
import { getVisionContext } from './vision-app'
|
|
6
11
|
import { eventRegistry } from './event-registry'
|
|
@@ -152,11 +157,11 @@ export class ServiceBuilder<
|
|
|
152
157
|
this.endpoints.forEach((ep) => {
|
|
153
158
|
let requestBody = undefined
|
|
154
159
|
if (ep.schema.input && ['POST', 'PUT', 'PATCH'].includes(ep.method)) {
|
|
155
|
-
requestBody =
|
|
160
|
+
requestBody = generateTemplate(ep.schema.input)
|
|
156
161
|
}
|
|
157
162
|
let responseBody = undefined
|
|
158
163
|
if (ep.schema.output) {
|
|
159
|
-
responseBody =
|
|
164
|
+
responseBody = generateTemplate(ep.schema.output)
|
|
160
165
|
}
|
|
161
166
|
routes.push({
|
|
162
167
|
method: ep.method,
|
|
@@ -382,13 +387,13 @@ export class ServiceBuilder<
|
|
|
382
387
|
// Generate requestBody schema (input)
|
|
383
388
|
let requestBody = undefined
|
|
384
389
|
if (ep.schema.input && ['POST', 'PUT', 'PATCH'].includes(ep.method)) {
|
|
385
|
-
requestBody =
|
|
390
|
+
requestBody = generateTemplate(ep.schema.input)
|
|
386
391
|
}
|
|
387
392
|
|
|
388
393
|
// Generate responseBody schema (output) - NEW!
|
|
389
394
|
let responseBody = undefined
|
|
390
395
|
if (ep.schema.output) {
|
|
391
|
-
responseBody =
|
|
396
|
+
responseBody = generateTemplate(ep.schema.output)
|
|
392
397
|
}
|
|
393
398
|
|
|
394
399
|
return {
|
|
@@ -517,15 +522,15 @@ export class ServiceBuilder<
|
|
|
517
522
|
|
|
518
523
|
const input = { ...params, ...query, ...body }
|
|
519
524
|
|
|
520
|
-
// Validate input with Zod
|
|
521
|
-
const validated = ep.schema.input
|
|
525
|
+
// Validate input with UniversalValidator (supports Zod, Valibot, etc.)
|
|
526
|
+
const validated = UniversalValidator.parse(ep.schema.input, input)
|
|
522
527
|
|
|
523
528
|
// Execute handler
|
|
524
529
|
const result = await ep.handler(validated, c as any)
|
|
525
530
|
|
|
526
531
|
// If an output schema exists, validate and return JSON
|
|
527
532
|
if (ep.schema.output) {
|
|
528
|
-
const validatedOutput = ep.schema.output
|
|
533
|
+
const validatedOutput = UniversalValidator.parse(ep.schema.output, result)
|
|
529
534
|
return c.json(validatedOutput)
|
|
530
535
|
}
|
|
531
536
|
|
|
@@ -535,11 +540,12 @@ export class ServiceBuilder<
|
|
|
535
540
|
}
|
|
536
541
|
return c.json(result)
|
|
537
542
|
} catch (error) {
|
|
538
|
-
if (
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
+
if (error instanceof ValidationError) {
|
|
544
|
+
const requestId = c.req.header('x-request-id')
|
|
545
|
+
return c.json(
|
|
546
|
+
createValidationErrorResponse(error.issues, requestId),
|
|
547
|
+
400
|
|
548
|
+
)
|
|
543
549
|
}
|
|
544
550
|
throw error
|
|
545
551
|
}
|