@kubb/kit 5.8.1 → 5.8.3
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 -11
- package/dist/index.cjs +6 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
### Authoring toolkit for Kubb plugins
|
|
26
26
|
|
|
27
|
-
`@kubb/kit` gathers the helpers you call when you author a plugin, generator, adapter, resolver, or renderer: `
|
|
27
|
+
`@kubb/kit` gathers the helpers you call when you author a plugin, generator, adapter, resolver, parser, or renderer: `defineExtension`, `defineGenerator`, `createResolver`, `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
28
|
|
|
29
29
|
## Installation
|
|
30
30
|
|
|
@@ -41,25 +41,36 @@ npm install kubb
|
|
|
41
41
|
## Usage
|
|
42
42
|
|
|
43
43
|
```typescript
|
|
44
|
-
import { ast,
|
|
44
|
+
import { ast, defineExtension, defineGenerator } from 'kubb/kit'
|
|
45
45
|
|
|
46
|
-
export const pluginExample =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
export const pluginExample = defineExtension({
|
|
47
|
+
kind: 'plugin',
|
|
48
|
+
meta: { name: 'plugin-example' },
|
|
49
|
+
setup(_options, kubb) {
|
|
50
|
+
kubb.addGenerator(
|
|
50
51
|
defineGenerator({
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
name: 'example',
|
|
53
|
+
schema(node) {
|
|
54
|
+
return [
|
|
55
|
+
ast.factory.createFile({
|
|
56
|
+
path: `${node.name}.ts`,
|
|
57
|
+
baseName: `${node.name}.ts`,
|
|
58
|
+
sources: [ast.factory.createSource({ nodes: [ast.factory.createText(`// ${node.name}\n`)] })],
|
|
59
|
+
imports: [],
|
|
60
|
+
exports: [],
|
|
61
|
+
}),
|
|
62
|
+
]
|
|
53
63
|
},
|
|
54
64
|
}),
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
)
|
|
66
|
+
return {}
|
|
67
|
+
},
|
|
57
68
|
})
|
|
58
69
|
```
|
|
59
70
|
|
|
60
71
|
## What is in the box
|
|
61
72
|
|
|
62
|
-
`
|
|
73
|
+
`defineExtension` wraps a plugin, an adapter, or a parser into the shape the build engine expects. Set `kind` to `'plugin'`, `'adapter'`, or `'parser'`. `definePlugin`, `defineParser`, and `createAdapter` still work but are deprecated in favor of it. `defineGenerator` and `createResolver` wrap a generator or a resolver. `createRenderer` and `createStorage` are the matching factories for a custom output renderer or storage backend.
|
|
63
74
|
|
|
64
75
|
`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
76
|
|
package/dist/index.cjs
CHANGED
|
@@ -627,6 +627,12 @@ Object.defineProperty(exports, "createStorage", {
|
|
|
627
627
|
return _kubb_core.createStorage;
|
|
628
628
|
}
|
|
629
629
|
});
|
|
630
|
+
Object.defineProperty(exports, "defineExtension", {
|
|
631
|
+
enumerable: true,
|
|
632
|
+
get: function() {
|
|
633
|
+
return _kubb_core.defineExtension;
|
|
634
|
+
}
|
|
635
|
+
});
|
|
630
636
|
Object.defineProperty(exports, "defineGenerator", {
|
|
631
637
|
enumerable: true,
|
|
632
638
|
get: function() {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
import { SchemaNode, ast, ast as ast$1 } from "@kubb/ast";
|
|
3
|
-
import { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostic, Diagnostics, Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Generator as Generator$1, GeneratorContext, Group, Hookable, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, NormalizedPlugin, Output, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, Plugin, PluginDefinition, PluginFactory, PluginFactoryOptions, PluginType, Renderer, RendererFactory, ResolveFileOptions, ResolveImportsOptions, ResolvePathOptions, Resolver, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, Storage, addGenerator, addMacro, assertPluginOption, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions } from "@kubb/core";
|
|
3
|
+
import { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostic, Diagnostics, Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Generator as Generator$1, GeneratorContext, Group, Hookable, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, NormalizedPlugin, Output, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, Plugin, PluginDefinition, PluginFactory, PluginFactoryOptions, PluginType, Renderer, RendererFactory, ResolveFileOptions, ResolveImportsOptions, ResolvePathOptions, Resolver, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, Storage, addGenerator, addMacro, assertPluginOption, createAdapter, createRenderer, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions } from "@kubb/core";
|
|
4
4
|
//#region src/Url.d.ts
|
|
5
5
|
type URLObject = {
|
|
6
6
|
/**
|
|
@@ -232,5 +232,5 @@ export declare function containsCircularRef(node: SchemaNode | undefined, { circ
|
|
|
232
232
|
excludeName?: string;
|
|
233
233
|
}): boolean;
|
|
234
234
|
//#endregion
|
|
235
|
-
export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, type Diagnostic, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, type Generator$1 as Generator, type GeneratorContext, type Group, Hookable, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type NodeCache, type NormalizedPlugin, type Output, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type Plugin, type PluginDefinition, type PluginFactory, type PluginFactoryOptions, type PluginType, type Renderer, type RendererFactory, type ResolveFileOptions, type ResolveImportsOptions, type ResolvePathOptions, Resolver, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type Storage, addGenerator, addMacro, assertPluginOption, ast, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
235
|
+
export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, type Diagnostic, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, type Generator$1 as Generator, type GeneratorContext, type Group, Hookable, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type NodeCache, type NormalizedPlugin, type Output, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type Plugin, type PluginDefinition, type PluginFactory, type PluginFactoryOptions, type PluginType, type Renderer, type RendererFactory, type ResolveFileOptions, type ResolveImportsOptions, type ResolvePathOptions, Resolver, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type Storage, addGenerator, addMacro, assertPluginOption, ast, createAdapter, createRenderer, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
236
236
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
import { ast, ast as ast$1 } from "@kubb/ast";
|
|
3
|
-
import { Diagnostics, Hookable, Resolver, addGenerator, addMacro, assertPluginOption, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions } from "@kubb/core";
|
|
3
|
+
import { Diagnostics, Hookable, Resolver, addGenerator, addMacro, assertPluginOption, createAdapter, createRenderer, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions } from "@kubb/core";
|
|
4
4
|
//#region ../../internals/utils/src/casing.ts
|
|
5
5
|
/**
|
|
6
6
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -557,6 +557,6 @@ function containsCircularRef(node, { circularSchemas, excludeName }) {
|
|
|
557
557
|
return false;
|
|
558
558
|
}
|
|
559
559
|
//#endregion
|
|
560
|
-
export { Diagnostics, Hookable, Resolver, Url, addGenerator, addMacro, assertPluginOption, ast, childName, containsCircularRef, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, enumPropName, extractRefName, fsStorage, injectFile, isExtensionManifest, isStringType, kubbContext, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion, manifestProblems, memoryStorage, mergeAdjacentObjectsLazy, requirePlugin, setMacros, setOptions, setResolver, syncSchemaRef, tryUseKubb, useConfig, useKubb, useOptions };
|
|
560
|
+
export { Diagnostics, Hookable, Resolver, Url, addGenerator, addMacro, assertPluginOption, ast, childName, containsCircularRef, createAdapter, createRenderer, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, enumPropName, extractRefName, fsStorage, injectFile, isExtensionManifest, isStringType, kubbContext, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion, manifestProblems, memoryStorage, mergeAdjacentObjectsLazy, requirePlugin, setMacros, setOptions, setResolver, syncSchemaRef, tryUseKubb, useConfig, useKubb, useOptions };
|
|
561
561
|
|
|
562
562
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/kit",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.3",
|
|
4
4
|
"description": "Authoring toolkit for Kubb plugins, generators, adapters, resolvers, and renderers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"registry": "https://registry.npmjs.org/"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@kubb/ast": "5.8.
|
|
67
|
-
"@kubb/core": "5.8.
|
|
66
|
+
"@kubb/ast": "5.8.3",
|
|
67
|
+
"@kubb/core": "5.8.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@internals/utils": "0.0.1"
|