@getvision/adapter-hono 0.1.0 → 0.1.1
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/CHANGELOG.md +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -3
- package/dist/validator.d.ts.map +1 -1
- package/dist/validator.js +20 -1
- package/package.json +1 -1
- package/src/index.ts +12 -3
- package/src/validator.ts +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @getvision/adapter-hono
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5b7cb0a: feat(web): add query parameters support, custom query params, and polished UI
|
|
8
|
+
|
|
9
|
+
Introduced support for API query parameters in the API Explorer, including the ability to add and manage custom query parameters. Refactored UI components to use a new `Checkbox` component and replaced `Card` with `SectionCard` for better consistency. Enhanced request body handling with JSON5 parsing.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [5b7cb0a]
|
|
12
|
+
- @getvision/core@0.1.1
|
|
13
|
+
|
|
3
14
|
## 0.1.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,iBAAiB,EAAE,MAAM,MAAM,CAAA;AACtD,OAAO,EACL,UAAU,EAQX,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAiB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAK1F,UAAU,aAAa;IACrB,MAAM,EAAE,UAAU,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAMhD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,qFAG5B;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,iBAAiB,EAAE,MAAM,MAAM,CAAA;AACtD,OAAO,EACL,UAAU,EAQX,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAiB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAK1F,UAAU,aAAa;IACrB,MAAM,EAAE,UAAU,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAMhD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,qFAG5B;AAkJD,wBAAgB,aAAa,CAAC,OAAO,GAAE,iBAAsB,GAAG,iBAAiB,CA2OhF;AAqGD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,QAGzF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,GAAG,IAAI,CAErD;AAED,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -84,13 +84,22 @@ function patchHonoApp(app, options) {
|
|
|
84
84
|
const original = app[method];
|
|
85
85
|
if (original) {
|
|
86
86
|
app[method] = function (path, ...handlers) {
|
|
87
|
-
// Try to extract
|
|
87
|
+
// Try to extract schemas from validator middleware
|
|
88
88
|
let requestBodySchema = undefined;
|
|
89
|
+
let queryParamsSchema = undefined;
|
|
89
90
|
for (const handler of handlers) {
|
|
90
91
|
const schema = extractSchema(handler);
|
|
91
92
|
if (schema) {
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
// Check if this is a query validator or body validator
|
|
94
|
+
// Query validators are typically used with 'query' target
|
|
95
|
+
const validatorTarget = handler.__visionValidatorTarget;
|
|
96
|
+
if (validatorTarget === 'query') {
|
|
97
|
+
queryParamsSchema = generateTemplate(schema);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// Default to request body for json/form validators
|
|
101
|
+
requestBodySchema = generateTemplate(schema);
|
|
102
|
+
}
|
|
94
103
|
}
|
|
95
104
|
}
|
|
96
105
|
// Register route with Vision
|
|
@@ -99,6 +108,7 @@ function patchHonoApp(app, options) {
|
|
|
99
108
|
path,
|
|
100
109
|
handler: handlers[handlers.length - 1]?.name || 'anonymous',
|
|
101
110
|
middleware: [],
|
|
111
|
+
queryParams: queryParamsSchema,
|
|
102
112
|
requestBody: requestBodySchema,
|
|
103
113
|
});
|
|
104
114
|
// Call original method
|
package/dist/validator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAOzE;;GAEG;AACH,KAAK,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEzE,wBAAgB,SAAS,CAAC,MAAM,SAAS,mBAAmB,EAAE,CAAC,SAAS,UAAU,EAChF,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,GACR,iBAAiB,CAClB,GAAG,EACH,GAAG,EACH;IACE,EAAE,EAAE;SAAG,CAAC,IAAI,MAAM,GAAG,OAAO,KAAK,EAAE,KAAK,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
|
|
38
|
+
// Attach schema and target for Vision introspection
|
|
39
|
+
// Use Object.defineProperty to avoid potential setter issues
|
|
40
|
+
try {
|
|
41
|
+
Object.defineProperty(middleware, '__visionSchema', {
|
|
42
|
+
value: schema,
|
|
43
|
+
enumerable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
configurable: true
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(middleware, '__visionValidatorTarget', {
|
|
48
|
+
value: target,
|
|
49
|
+
enumerable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.error('Failed to attach schema to middleware:', e);
|
|
56
|
+
console.log('Schema type:', typeof schema);
|
|
57
|
+
}
|
|
39
58
|
return middleware;
|
|
40
59
|
}
|
|
41
60
|
/**
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -107,14 +107,22 @@ function patchHonoApp(app: any, options?: { services?: ServiceDefinition[] }) {
|
|
|
107
107
|
const original = app[method]
|
|
108
108
|
if (original) {
|
|
109
109
|
app[method] = function(path: string, ...handlers: any[]) {
|
|
110
|
-
// Try to extract
|
|
110
|
+
// Try to extract schemas from validator middleware
|
|
111
111
|
let requestBodySchema = undefined
|
|
112
|
+
let queryParamsSchema = undefined
|
|
112
113
|
|
|
113
114
|
for (const handler of handlers) {
|
|
114
115
|
const schema = extractSchema(handler)
|
|
115
116
|
if (schema) {
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
// Check if this is a query validator or body validator
|
|
118
|
+
// Query validators are typically used with 'query' target
|
|
119
|
+
const validatorTarget = (handler as any).__visionValidatorTarget
|
|
120
|
+
if (validatorTarget === 'query') {
|
|
121
|
+
queryParamsSchema = generateTemplate(schema)
|
|
122
|
+
} else {
|
|
123
|
+
// Default to request body for json/form validators
|
|
124
|
+
requestBodySchema = generateTemplate(schema)
|
|
125
|
+
}
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
128
|
|
|
@@ -124,6 +132,7 @@ function patchHonoApp(app: any, options?: { services?: ServiceDefinition[] }) {
|
|
|
124
132
|
path,
|
|
125
133
|
handler: handlers[handlers.length - 1]?.name || 'anonymous',
|
|
126
134
|
middleware: [],
|
|
135
|
+
queryParams: queryParamsSchema,
|
|
127
136
|
requestBody: requestBodySchema,
|
|
128
137
|
})
|
|
129
138
|
|
package/src/validator.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { zValidator as originalZValidator } from '@hono/zod-validator'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ZodTypeAny } from 'zod'
|
|
3
3
|
import type { MiddlewareHandler } from 'hono'
|
|
4
4
|
import type { StandardSchemaV1, ValidationSchema } from '@getvision/core'
|
|
5
5
|
import {
|
|
@@ -92,7 +92,25 @@ export function validator<Target extends ValidationTargetKey>(
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
// Attach schema and target for Vision introspection
|
|
96
|
+
// Use Object.defineProperty to avoid potential setter issues
|
|
97
|
+
try {
|
|
98
|
+
Object.defineProperty(middleware, '__visionSchema', {
|
|
99
|
+
value: schema,
|
|
100
|
+
enumerable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
configurable: true
|
|
103
|
+
})
|
|
104
|
+
Object.defineProperty(middleware, '__visionValidatorTarget', {
|
|
105
|
+
value: target,
|
|
106
|
+
enumerable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
configurable: true
|
|
109
|
+
})
|
|
110
|
+
} catch (e) {
|
|
111
|
+
console.error('Failed to attach schema to middleware:', e)
|
|
112
|
+
console.log('Schema type:', typeof schema)
|
|
113
|
+
}
|
|
96
114
|
|
|
97
115
|
return middleware
|
|
98
116
|
}
|