@kubb/plugin-mcp 5.0.0-beta.56 → 5.0.0-beta.73
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 +2 -2
- package/dist/index.cjs +298 -262
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +126 -119
- package/dist/index.js +298 -261
- package/dist/index.js.map +1 -1
- package/package.json +10 -11
- package/src/components/McpHandler.tsx +0 -157
- package/src/components/Server.tsx +0 -159
- package/src/generators/mcpGenerator.tsx +0 -89
- package/src/generators/serverGenerator.tsx +0 -149
- package/src/index.ts +0 -11
- package/src/plugin.ts +0 -142
- package/src/resolvers/resolverMcp.ts +0 -35
- package/src/types.ts +0 -90
- package/src/utils.ts +0 -48
- /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/src/utils.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { ast } from '@kubb/core'
|
|
2
|
-
|
|
3
|
-
export type ZodParam = {
|
|
4
|
-
name: string
|
|
5
|
-
schemaName: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Render a group param value — compose individual schemas into `z.object({ ... })`,
|
|
10
|
-
* or use a schema name string directly.
|
|
11
|
-
*/
|
|
12
|
-
export function zodGroupExpr(entry: string | Array<ZodParam>): string {
|
|
13
|
-
if (typeof entry === 'string') {
|
|
14
|
-
return entry
|
|
15
|
-
}
|
|
16
|
-
const entries = entry.map((p) => `${JSON.stringify(p.name)}: ${p.schemaName}`)
|
|
17
|
-
return `z.object({ ${entries.join(', ')} })`
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Convert a SchemaNode type to an inline Zod expression string.
|
|
22
|
-
* Used as fallback when no named zod schema is available for a path parameter.
|
|
23
|
-
*/
|
|
24
|
-
export function zodExprFromSchemaNode(schema: ast.SchemaNode): string {
|
|
25
|
-
const baseExpr = (() => {
|
|
26
|
-
if (schema.type === 'enum') {
|
|
27
|
-
const rawValues: Array<string | number | boolean> = schema.namedEnumValues?.length
|
|
28
|
-
? schema.namedEnumValues.map((v) => v.value)
|
|
29
|
-
: (schema.enumValues ?? []).filter((v): v is string | number | boolean => v !== null)
|
|
30
|
-
|
|
31
|
-
if (rawValues.length > 0 && rawValues.every((v) => typeof v === 'string')) {
|
|
32
|
-
return `z.enum([${rawValues.map((v) => JSON.stringify(v)).join(', ')}])`
|
|
33
|
-
}
|
|
34
|
-
if (rawValues.length > 0) {
|
|
35
|
-
const literals = rawValues.map((v) => `z.literal(${JSON.stringify(v)})`)
|
|
36
|
-
return literals.length === 1 ? literals[0]! : `z.union([${literals.join(', ')}])`
|
|
37
|
-
}
|
|
38
|
-
return 'z.string()'
|
|
39
|
-
}
|
|
40
|
-
if (schema.type === 'integer') return 'z.coerce.number()'
|
|
41
|
-
if (schema.type === 'number') return 'z.number()'
|
|
42
|
-
if (schema.type === 'boolean') return 'z.boolean()'
|
|
43
|
-
if (schema.type === 'array') return 'z.array(z.unknown())'
|
|
44
|
-
return 'z.string()'
|
|
45
|
-
})()
|
|
46
|
-
|
|
47
|
-
return schema.nullable ? `${baseExpr}.nullable()` : baseExpr
|
|
48
|
-
}
|
|
File without changes
|