
Security News
Deno Goes the Way of the Dinosaur
Cloudflare is acquiring Deno’s team, which will provide another year of bug fixes and security updates before ending support for the runtime.
@kubb/ast
Advanced tools
Spec-agnostic AST layer for Kubb. Defines the node tree, visitor pattern, factory functions, and type guards used across all code generation plugins.
Defines the node tree, visitor pattern, factory functions, and type guards used across every Kubb code generation plugin.
| Path | Contents |
|---|---|
@kubb/ast | Runtime: node definitions, guards, visitor, macro engine, constants |
ast.factory (via @kubb/ast) | Node constructors (createSchema, createFile, and friends), the ts.factory analogue |
kubb/kit | Re-exports the ast and factory namespaces, the way most Kubb code reaches the AST without a direct dependency |
@kubb/ast is an internal library. Inside the Kubb ecosystem the whole surface travels on the ast namespace from kubb/kit, so plugins and generators reach it there instead of depending on this package directly. The examples below import from @kubb/ast for clarity; through kubb/kit the same calls read as ast.transform, ast.factory.createSchema, and so on.
InputNode
├── schemas: SchemaNode[]
└── operations: OperationNode[]
├── parameters: ParameterNode[] → SchemaNode
├── requestBody?: SchemaNode
└── responses: ResponseNode[] → SchemaNode?
SchemaNode (discriminated union)
object → properties: PropertyNode[] → SchemaNode
array | tuple → items: SchemaNode[]
union | intersection → members: SchemaNode[]
enum | ref | string | number | integer | bigint
boolean | null | any | unknown | void
date | datetime | time | uuid | email | url | blob
Constructors are available as ast.factory from @kubb/ast, mirroring ts.factory.createX.
import { ast } from '@kubb/ast'
const { createInput, createSchema, createProperty } = ast.factory
const root = createInput({
schemas: [
createSchema({
name: 'Pet',
type: 'object',
properties: [
createProperty({
name: 'id',
schema: createSchema({ type: 'integer' }),
required: true,
}),
createProperty({
name: 'name',
schema: createSchema({ type: 'string' }),
required: true,
}),
],
}),
],
})
import { collectSync, transform } from '@kubb/ast'
// Immutable transformation
const updated = transform(root, {
schema(node) {
return { ...node, description: 'generated' }
},
})
// Extraction
const types = collectSync<string>(root, {
schema(node) {
return node.type
},
})
import { narrowSchema } from '@kubb/ast'
import type { Node } from '@kubb/ast'
function process(node: Node) {
if (node.kind === 'Schema') {
const obj = narrowSchema(node, 'object')
obj?.properties?.forEach((p) => console.log(p.name))
}
}
import { resolveRefName } from '@kubb/ast'
resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'
Adding a node touches three files.
createFoo function in its own src/nodes/*.ts file, and add the kind to NodeKind in src/nodes/base.ts.Node union and re-export createFoo in src/nodes/index.ts, and export the type from src/types.ts.VISITOR_KEYS and VISITOR_KEY_BY_KIND in src/visitor.ts.Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
FAQs
Spec-agnostic AST layer for Kubb. Defines the node tree, visitor pattern, factory functions, and type guards used across all code generation plugins.
The npm package @kubb/ast receives a total of 0 weekly downloads. As such, @kubb/ast popularity was classified as not popular.
We found that @kubb/ast demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Cloudflare is acquiring Deno’s team, which will provide another year of bug fixes and security updates before ending support for the runtime.

Security News
Anthropic’s free OSS Scanner uses Mythos and other Claude models to find open source vulnerabilities and send maintainers reports with proposed fixes.

Security News
On Front Lines’ Early Adopters: CISO podcast, Andrew Becherer shares lessons from Datadog, weighs the long-term costs of AI-built tools, and explains how founders can actually gain a CISO’s trust.