@kubb/ast 5.0.0-alpha.9 → 5.0.0-beta.75

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 CHANGED
@@ -23,10 +23,10 @@ Spec-agnostic AST layer for Kubb. Defines nodes, visitor pattern, factory functi
23
23
 
24
24
  ## Imports
25
25
 
26
- | Path | Contents |
27
- |---|---|
28
- | `@kubb/ast` | Runtime: factory functions, guards, visitor, ref helpers, constants |
29
- | `@kubb/ast/types` | Types only: all node interfaces, type aliases, visitor types |
26
+ | Path | Contents |
27
+ | ----------------- | ------------------------------------------------------------------- |
28
+ | `@kubb/ast` | Runtime: factory functions, guards, visitor, ref helpers, constants |
29
+ | `@kubb/ast/types` | Types only: all node interfaces, type aliases, visitor types |
30
30
 
31
31
  ## Node tree
32
32
 
@@ -60,8 +60,16 @@ const root = createRoot({
60
60
  name: 'Pet',
61
61
  type: 'object',
62
62
  properties: [
63
- createProperty({ name: 'id', schema: createSchema({ type: 'integer' }), required: true }),
64
- createProperty({ name: 'name', schema: createSchema({ type: 'string' }), required: true }),
63
+ createProperty({
64
+ name: 'id',
65
+ schema: createSchema({ type: 'integer' }),
66
+ required: true,
67
+ }),
68
+ createProperty({
69
+ name: 'name',
70
+ schema: createSchema({ type: 'string' }),
71
+ required: true,
72
+ }),
65
73
  ],
66
74
  }),
67
75
  ],
@@ -75,17 +83,23 @@ import { walk, transform, collect } from '@kubb/ast'
75
83
 
76
84
  // Side effects
77
85
  await walk(root, {
78
- schema(node) { console.log(node.type) },
86
+ schema(node) {
87
+ console.log(node.type)
88
+ },
79
89
  })
80
90
 
81
91
  // Immutable transformation
82
92
  const updated = transform(root, {
83
- schema(node) { return { ...node, description: 'generated' } },
93
+ schema(node) {
94
+ return { ...node, description: 'generated' }
95
+ },
84
96
  })
85
97
 
86
98
  // Extraction
87
99
  const types = collect<string>(root, {
88
- schema(node) { return node.type },
100
+ schema(node) {
101
+ return node.type
102
+ },
89
103
  })
90
104
  ```
91
105
 
@@ -98,7 +112,7 @@ import type { Node } from '@kubb/ast/types'
98
112
  function process(node: Node) {
99
113
  if (isSchemaNode(node)) {
100
114
  const obj = narrowSchema(node, 'object')
101
- obj?.properties?.forEach(p => console.log(p.name))
115
+ obj?.properties?.forEach((p) => console.log(p.name))
102
116
  }
103
117
  }
104
118
  ```