@kubb/plugin-mcp 5.0.0-beta.10 → 5.0.0-beta.103
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 +22 -25
- package/dist/index.cjs +520 -679
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +171 -134
- package/dist/index.js +498 -656
- package/dist/index.js.map +1 -1
- package/package.json +11 -24
- package/extension.yaml +0 -463
- package/src/components/McpHandler.tsx +0 -167
- package/src/components/Server.tsx +0 -154
- package/src/generators/mcpGenerator.tsx +0 -79
- package/src/generators/serverGenerator.tsx +0 -146
- package/src/index.ts +0 -11
- package/src/plugin.ts +0 -122
- package/src/resolvers/resolverMcp.ts +0 -31
- package/src/types.ts +0 -88
- package/src/utils.ts +0 -64
- /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/src/utils.ts
DELETED
|
@@ -1,64 +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
|
-
let expr: string
|
|
26
|
-
switch (schema.type) {
|
|
27
|
-
case 'enum': {
|
|
28
|
-
// namedEnumValues takes priority over enumValues
|
|
29
|
-
const rawValues: Array<string | number | boolean> = schema.namedEnumValues?.length
|
|
30
|
-
? schema.namedEnumValues.map((v) => v.value)
|
|
31
|
-
: (schema.enumValues ?? []).filter((v): v is string | number | boolean => v !== null)
|
|
32
|
-
|
|
33
|
-
if (rawValues.length > 0 && rawValues.every((v) => typeof v === 'string')) {
|
|
34
|
-
expr = `z.enum([${rawValues.map((v) => JSON.stringify(v)).join(', ')}])`
|
|
35
|
-
} else if (rawValues.length > 0) {
|
|
36
|
-
const literals = rawValues.map((v) => `z.literal(${JSON.stringify(v)})`)
|
|
37
|
-
expr = literals.length === 1 ? literals[0]! : `z.union([${literals.join(', ')}])`
|
|
38
|
-
} else {
|
|
39
|
-
expr = 'z.string()'
|
|
40
|
-
}
|
|
41
|
-
break
|
|
42
|
-
}
|
|
43
|
-
case 'integer':
|
|
44
|
-
expr = 'z.coerce.number()'
|
|
45
|
-
break
|
|
46
|
-
case 'number':
|
|
47
|
-
expr = 'z.number()'
|
|
48
|
-
break
|
|
49
|
-
case 'boolean':
|
|
50
|
-
expr = 'z.boolean()'
|
|
51
|
-
break
|
|
52
|
-
case 'array':
|
|
53
|
-
expr = 'z.array(z.unknown())'
|
|
54
|
-
break
|
|
55
|
-
default:
|
|
56
|
-
expr = 'z.string()'
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (schema.nullable) {
|
|
60
|
-
expr = `${expr}.nullable()`
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return expr
|
|
64
|
-
}
|
|
File without changes
|