@getvision/adapter-fastify 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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @getvision/adapter-fastify
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,EACL,UAAU,EASX,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAIV,KAAK,EACL,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,iBAAiB,CAAA;AAGxB,UAAU,aAAa;IACrB,MAAM,EAAE,UAAU,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAMhD;AAED,wBAAgB,aAAa,KAInB,CAAC,EACP,MAAM,MAAM,EACZ,YAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EACpC,IAAI,MAAM,CAAC,KACV,CAAC,CAgCL;AAKD,wBAAgB,iBAAiB,IAAI,UAAU,GAAG,IAAI,CAErD;AAyQD,eAAO,MAAM,YAAY,0CAGvB,CAAA;AAEF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAC3C,IAAI,CAsEN;AA+FD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,EACL,UAAU,EASX,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAIV,KAAK,EACL,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,iBAAiB,CAAA;AAGxB,UAAU,aAAa;IACrB,MAAM,EAAE,UAAU,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAMhD;AAED,wBAAgB,aAAa,KAInB,CAAC,EACP,MAAM,MAAM,EACZ,YAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EACpC,IAAI,MAAM,CAAC,KACV,CAAC,CAgCL;AAKD,wBAAgB,iBAAiB,IAAI,UAAU,GAAG,IAAI,CAErD;AAoRD,eAAO,MAAM,YAAY,0CAGvB,CAAA;AAEF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAC3C,IAAI,CAqFN;AA+FD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -131,13 +131,20 @@ const visionPluginImpl = async (fastify, options) => {
131
131
  const captured = fastify[CAPTURE_KEY];
132
132
  const methods = Array.isArray(routeOpts.method) ? routeOpts.method : [routeOpts.method];
133
133
  // Extract schema from preHandler validator if present
134
- let visionSchema = undefined;
134
+ let bodySchema = undefined;
135
+ let querySchema = undefined;
135
136
  if (routeOpts.preHandler) {
136
137
  const handlers = Array.isArray(routeOpts.preHandler) ? routeOpts.preHandler : [routeOpts.preHandler];
137
138
  for (const handler of handlers) {
138
139
  if (handler.__visionSchema) {
139
- visionSchema = handler.__visionSchema;
140
- break;
140
+ const visionSchema = handler.__visionSchema;
141
+ const visionTarget = handler.__visionTarget;
142
+ if (visionTarget === 'querystring') {
143
+ querySchema = visionSchema;
144
+ }
145
+ else if (visionTarget === 'body' || !visionTarget) {
146
+ bodySchema = visionSchema;
147
+ }
141
148
  }
142
149
  }
143
150
  }
@@ -146,8 +153,11 @@ const visionPluginImpl = async (fastify, options) => {
146
153
  if (!method || method === 'HEAD' || method === 'OPTIONS')
147
154
  continue;
148
155
  const schema = routeOpts.schema ? { ...routeOpts.schema } : {};
149
- if (visionSchema) {
150
- schema.__visionSchema = visionSchema;
156
+ if (bodySchema) {
157
+ schema.__visionSchema = bodySchema;
158
+ }
159
+ if (querySchema) {
160
+ schema.__visionQuerySchema = querySchema;
151
161
  }
152
162
  captured.push({
153
163
  method,
@@ -281,7 +291,7 @@ export function enableAutoDiscovery(fastify, options) {
281
291
  path: route.url,
282
292
  handler: route.handlerName || 'anonymous',
283
293
  };
284
- // Try to get schema from route
294
+ // Try to get body schema from route
285
295
  if (route.schema?.__visionSchema) {
286
296
  try {
287
297
  routeMeta.requestBody = generateTemplate(route.schema.__visionSchema);
@@ -298,6 +308,23 @@ export function enableAutoDiscovery(fastify, options) {
298
308
  // Ignore schema conversion errors
299
309
  }
300
310
  }
311
+ // Try to get query schema from route
312
+ if (route.schema?.__visionQuerySchema) {
313
+ try {
314
+ routeMeta.queryParams = generateTemplate(route.schema.__visionQuerySchema);
315
+ }
316
+ catch (e) {
317
+ console.error(`[Vision] Query template generation error for ${route.method} ${route.url}:`, e);
318
+ }
319
+ }
320
+ else if (route.schema?.querystring) {
321
+ try {
322
+ routeMeta.queryParams = jsonSchemaToTemplate(route.schema.querystring);
323
+ }
324
+ catch (e) {
325
+ // Ignore schema conversion errors
326
+ }
327
+ }
301
328
  // Try to get response schema (Fastify supports response: { 200: { ... } })
302
329
  if (route.schema?.response) {
303
330
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getvision/adapter-fastify",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Fastify adapter for Vision Dashboard",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/index.ts CHANGED
@@ -199,13 +199,21 @@ const visionPluginImpl: FastifyPluginAsync<VisionFastifyOptions> = async (fastif
199
199
  const methods = Array.isArray(routeOpts.method) ? routeOpts.method : [routeOpts.method]
200
200
 
201
201
  // Extract schema from preHandler validator if present
202
- let visionSchema: any = undefined
202
+ let bodySchema: any = undefined
203
+ let querySchema: any = undefined
204
+
203
205
  if (routeOpts.preHandler) {
204
206
  const handlers = Array.isArray(routeOpts.preHandler) ? routeOpts.preHandler : [routeOpts.preHandler]
205
207
  for (const handler of handlers) {
206
208
  if ((handler as any).__visionSchema) {
207
- visionSchema = (handler as any).__visionSchema
208
- break
209
+ const visionSchema = (handler as any).__visionSchema
210
+ const visionTarget = (handler as any).__visionTarget
211
+
212
+ if (visionTarget === 'querystring') {
213
+ querySchema = visionSchema
214
+ } else if (visionTarget === 'body' || !visionTarget) {
215
+ bodySchema = visionSchema
216
+ }
209
217
  }
210
218
  }
211
219
  }
@@ -215,8 +223,11 @@ const visionPluginImpl: FastifyPluginAsync<VisionFastifyOptions> = async (fastif
215
223
  if (!method || method === 'HEAD' || method === 'OPTIONS') continue
216
224
 
217
225
  const schema: any = routeOpts.schema ? { ...routeOpts.schema } : {}
218
- if (visionSchema) {
219
- schema.__visionSchema = visionSchema
226
+ if (bodySchema) {
227
+ schema.__visionSchema = bodySchema
228
+ }
229
+ if (querySchema) {
230
+ schema.__visionQuerySchema = querySchema
220
231
  }
221
232
 
222
233
  captured.push({
@@ -378,7 +389,7 @@ export function enableAutoDiscovery(
378
389
  handler: route.handlerName || 'anonymous',
379
390
  }
380
391
 
381
- // Try to get schema from route
392
+ // Try to get body schema from route
382
393
  if (route.schema?.__visionSchema) {
383
394
  try {
384
395
  routeMeta.requestBody = generateTemplate(route.schema.__visionSchema)
@@ -392,6 +403,21 @@ export function enableAutoDiscovery(
392
403
  // Ignore schema conversion errors
393
404
  }
394
405
  }
406
+
407
+ // Try to get query schema from route
408
+ if (route.schema?.__visionQuerySchema) {
409
+ try {
410
+ routeMeta.queryParams = generateTemplate(route.schema.__visionQuerySchema)
411
+ } catch (e) {
412
+ console.error(`[Vision] Query template generation error for ${route.method} ${route.url}:`, e)
413
+ }
414
+ } else if (route.schema?.querystring) {
415
+ try {
416
+ routeMeta.queryParams = jsonSchemaToTemplate(route.schema.querystring)
417
+ } catch (e) {
418
+ // Ignore schema conversion errors
419
+ }
420
+ }
395
421
 
396
422
  // Try to get response schema (Fastify supports response: { 200: { ... } })
397
423
  if (route.schema?.response) {