@kubb/kit 5.0.0-beta.100

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stijn Van Hulle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ <div align="center">
2
+ <a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
3
+ <img src="https://kubb.dev/og.png" alt="Kubb banner">
4
+ </a>
5
+
6
+ [![npm version][npm-version-src]][npm-version-href]
7
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
8
+ [![Stars][stars-src]][stars-href]
9
+ [![License][license-src]][license-href]
10
+ [![Node][node-src]][node-href]
11
+
12
+ <h4>
13
+ <a href="https://kubb.dev" target="_blank">Documentation</a>
14
+ <span> · </span>
15
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
16
+ <span> · </span>
17
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
18
+ </h4>
19
+ </div>
20
+
21
+ <br />
22
+
23
+ # @kubb/kit
24
+
25
+ ### Authoring toolkit for Kubb plugins
26
+
27
+ `@kubb/kit` gathers the helpers you call when you author a plugin, generator, adapter, resolver, or renderer: `definePlugin`, `defineGenerator`, `defineResolver`, `defineParser`, `createAdapter`, `createRenderer`, the `ast` namespace and `factory` node builders, and the option and hook types that go with them. It sits next to the `kubb` package, which is where end users configure and run builds. `kubb/kit` re-exports this package, so most consumers reach it through `kubb/kit` rather than installing `@kubb/kit` directly.
28
+
29
+ ## Installation
30
+
31
+ Install `kubb` and import from the `kubb/kit` subpath, rather than depending on `@kubb/kit` directly.
32
+
33
+ ```bash
34
+ bun add kubb
35
+ # or
36
+ pnpm add kubb
37
+ # or
38
+ npm install kubb
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```typescript
44
+ import { ast, definePlugin, defineGenerator } from 'kubb/kit'
45
+
46
+ export const pluginExample = definePlugin(() => {
47
+ return {
48
+ name: 'example',
49
+ generators: [
50
+ defineGenerator({
51
+ schema({ schema }) {
52
+ return ast.factory.createSchema(schema)
53
+ },
54
+ }),
55
+ ],
56
+ }
57
+ })
58
+ ```
59
+
60
+ ## What is in the box
61
+
62
+ `definePlugin`, `defineGenerator`, `defineResolver`, and `defineParser` wrap a plugin, a generator, a resolver, or a parser into the shape the build engine expects. `createAdapter`, `createRenderer`, and `createStorage` are the matching factories for a custom spec adapter, output renderer, or storage backend.
63
+
64
+ `ast` and `factory` are the node builders a generator calls to construct the file, schema, and operation nodes it returns. `Diagnostics` is the structured error a plugin throws to report a problem with a location and a fix suggestion, and `memoryStorage` and `fsStorage` are the built-in storage backends, useful in tests and custom configs.
65
+
66
+ `macroDiscriminatorEnum`, `macroEnumName`, `macroRenameSchema`, and `macroSimplifyUnion` are the built-in macro presets, ready to pass to `ast.applyMacros` or a plugin's `setMacros`. Build a custom macro with `ast.defineMacro` instead.
67
+
68
+ `childName`, `enumPropName`, `extractRefName`, `isStringType`, `mergeAdjacentObjectsLazy`, `syncSchemaRef`, and `containsCircularRef` are schema-name and schema-graph helpers a generator or macro calls while shaping output, complementing the ref and graph helpers (`resolveRefName`, `findCircularSchemas`, `collectUsedSchemaNames`) that stay on `ast`.
69
+
70
+ Rounding out the package are the option and hook types every plugin, generator, adapter, resolver, and renderer author references, among them `PluginFactoryOptions`, `GeneratorContext`, `ResolveFileOptions`, `AdapterFactoryOptions`, `RendererFactory`, and `KubbHooks`.
71
+
72
+ ## Testing helpers
73
+
74
+ `kubb/kit/testing` holds the Vitest-backed test helpers (`createMockedPlugin`, `createMockedAdapter`, `renderGeneratorOperation`, `matchFiles`) used to unit test a plugin or generator without running a full build. It is a separate entry point so the main `kubb/kit` import never pulls in Vitest.
75
+
76
+ ```typescript
77
+ import { createMockedPlugin, renderGeneratorSchema } from 'kubb/kit/testing'
78
+ ```
79
+
80
+ ## Why a separate package from `@kubb/core`
81
+
82
+ `@kubb/core` also runs the build engine: the plugin driver, the file manager, and the CLI reporters. None of that is part of authoring a plugin. `@kubb/kit` keeps the two apart, the same way the surrounding `kubb/ast` and `kubb/jsx` subpaths separate the AST layer and the JSX renderer from the engine that drives them.
83
+
84
+ ## Supporting Kubb
85
+
86
+ Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
87
+
88
+ - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
89
+ - [See sponsorship tiers and our sponsors](https://kubb.dev/sponsors)
90
+
91
+ <p align="center">
92
+ <a href="https://github.com/sponsors/stijnvanhulle">
93
+ <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
94
+ </a>
95
+ </p>
96
+
97
+ ## License
98
+
99
+ [MIT](https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT)
100
+
101
+ <!-- Badges -->
102
+
103
+ [npm-version-src]: https://shieldcn.dev/npm/v/@kubb/kit.svg?variant=secondary&size=xs&theme=zinc&mode=dark
104
+ [npm-version-href]: https://npmx.dev/package/@kubb/kit
105
+ [npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/kit.svg?variant=secondary&size=xs&theme=zinc&mode=dark
106
+ [npm-downloads-href]: https://npmx.dev/package/@kubb/kit
107
+ [stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
108
+ [stars-href]: https://github.com/kubb-labs/kubb
109
+ [license-src]: https://shieldcn.dev/npm/license/@kubb/kit.svg?variant=secondary&size=xs&theme=zinc
110
+ [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
111
+ [node-src]: https://shieldcn.dev/npm/node/@kubb/kit.svg?variant=secondary&size=xs&theme=zinc&mode=dark
112
+ [node-href]: https://npmx.dev/package/@kubb/kit