@kubb/core 5.0.0-alpha.33 → 5.0.0-alpha.35
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/dist/{PluginDriver-BBi_41VF.d.ts → PluginDriver-D8lWvtUg.d.ts} +743 -375
- package/dist/hooks.d.ts +1 -1
- package/dist/index.cjs +1203 -932
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +22 -141
- package/dist/index.js +1220 -942
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/FileManager.ts +1 -1
- package/src/FileProcessor.ts +1 -1
- package/src/Kubb.ts +145 -38
- package/src/PluginDriver.ts +318 -40
- package/src/constants.ts +1 -1
- package/src/{build.ts → createKubb.ts} +180 -122
- package/src/createPlugin.ts +1 -0
- package/src/createRenderer.ts +57 -0
- package/src/defineGenerator.ts +57 -84
- package/src/defineLogger.ts +2 -2
- package/src/defineParser.ts +3 -2
- package/src/definePlugin.ts +95 -0
- package/src/defineResolver.ts +1 -1
- package/src/devtools.ts +1 -1
- package/src/index.ts +5 -6
- package/src/renderNode.ts +35 -0
- package/src/types.ts +275 -209
- package/src/utils/TreeNode.ts +1 -1
- package/src/utils/getBarrelFiles.ts +3 -3
- package/src/utils/getFunctionParams.ts +14 -7
- package/src/utils/isInputPath.ts +2 -2
- package/src/utils/packageJSON.ts +2 -3
- package/src/defineConfig.ts +0 -51
- package/src/definePresets.ts +0 -16
- package/src/renderNode.tsx +0 -28
- package/src/utils/getConfigs.ts +0 -16
- package/src/utils/getPreset.ts +0 -78
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { $ as
|
|
3
|
-
import
|
|
4
|
-
import { FileNode, InputNode, Node,
|
|
2
|
+
import { $ as getBarrelFiles, A as Plugin, B as ResolveOptionsContext, C as Logger, D as OperationsHook, E as OperationHook, F as PluginParameter, G as ResolverFileParams, H as ResolvePathParams, I as PluginWithLifeCycle, J as UserGroup, K as ResolverPathParams, L as PossibleConfig, M as PluginFactoryOptions, N as PluginLifecycle, O as Output, P as PluginLifecycleHooks, Q as FileMetaBase, R as ResolveBannerContext, S as KubbPluginSetupContext, T as LoggerOptions, U as Resolver, V as ResolvePathOptions, W as ResolverContext, X as UserPlugin, Y as UserLogger, Z as UserPluginWithLifeCycle, _ as Include, _t as createRenderer, a as Adapter, at as KubbHooks, b as KubbBuildEndContext, c as BarrelType, ct as Parser, d as Config, dt as createStorage, et as FunctionParamsAST, f as ConfigInput, ft as formatters, g as Group, gt as RendererFactory, h as GeneratorContext, ht as Renderer, i as defineGenerator, it as Kubb, j as PluginContext, k as Override, l as CLIOptions, lt as defineParser, m as Exclude, mt as logLevel, n as getMode, nt as PluginHooks, o as AdapterFactoryOptions, ot as BuildOutput, p as DevtoolsOptions, pt as linters, q as SchemaHook, r as Generator, rt as definePlugin, s as AdapterSource, st as createKubb, t as PluginDriver, tt as HookStylePlugin, u as CompatibilityPreset, ut as Storage, v as InputData, vt as AsyncEventEmitter, w as LoggerContext, x as KubbBuildStartContext, y as InputPath, z as ResolveNameParams } from "./PluginDriver-D8lWvtUg.js";
|
|
3
|
+
import * as ast from "@kubb/ast";
|
|
4
|
+
import { FileNode, InputNode, Node, composeTransformers, definePrinter } from "@kubb/ast";
|
|
5
5
|
|
|
6
6
|
//#region ../../internals/utils/src/urlPath.d.ts
|
|
7
7
|
type URLObject = {
|
|
@@ -139,75 +139,6 @@ declare class URLPath {
|
|
|
139
139
|
toURLPath(): string;
|
|
140
140
|
}
|
|
141
141
|
//#endregion
|
|
142
|
-
//#region src/build.d.ts
|
|
143
|
-
type BuildOptions = {
|
|
144
|
-
config: UserConfig;
|
|
145
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Full output produced by a successful or failed build.
|
|
149
|
-
*/
|
|
150
|
-
type BuildOutput = {
|
|
151
|
-
/**
|
|
152
|
-
* Plugins that threw during installation, paired with the caught error.
|
|
153
|
-
*/
|
|
154
|
-
failedPlugins: Set<{
|
|
155
|
-
plugin: Plugin;
|
|
156
|
-
error: Error;
|
|
157
|
-
}>;
|
|
158
|
-
files: Array<FileNode>;
|
|
159
|
-
driver: PluginDriver;
|
|
160
|
-
/**
|
|
161
|
-
* Elapsed time in milliseconds for each plugin, keyed by plugin name.
|
|
162
|
-
*/
|
|
163
|
-
pluginTimings: Map<string, number>;
|
|
164
|
-
error?: Error;
|
|
165
|
-
/**
|
|
166
|
-
* Raw generated source, keyed by absolute file path.
|
|
167
|
-
*/
|
|
168
|
-
sources: Map<string, string>;
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Intermediate result returned by {@link setup} and accepted by {@link safeBuild}.
|
|
172
|
-
*/
|
|
173
|
-
type SetupResult = {
|
|
174
|
-
events: AsyncEventEmitter<KubbEvents>;
|
|
175
|
-
driver: PluginDriver;
|
|
176
|
-
sources: Map<string, string>;
|
|
177
|
-
config: Config;
|
|
178
|
-
storage: Storage | null;
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Initializes all Kubb infrastructure for a build without executing any plugins.
|
|
182
|
-
*
|
|
183
|
-
* - Validates the input path (when applicable).
|
|
184
|
-
* - Applies config defaults (`root`, `output.*`, `devtools`).
|
|
185
|
-
* - Runs the adapter (if configured) to produce the universal `InputNode`.
|
|
186
|
-
* When no adapter is supplied and `@kubb/adapter-oas` is installed as an
|
|
187
|
-
*
|
|
188
|
-
* Pass the returned {@link SetupResult} directly to {@link safeBuild} or {@link build}
|
|
189
|
-
* via the `overrides` argument to reuse the same infrastructure across multiple runs.
|
|
190
|
-
*/
|
|
191
|
-
declare function setup(options: BuildOptions): Promise<SetupResult>;
|
|
192
|
-
/**
|
|
193
|
-
* Runs a full Kubb build and throws on any error or plugin failure.
|
|
194
|
-
*
|
|
195
|
-
* Internally delegates to {@link safeBuild} and rethrows collected errors.
|
|
196
|
-
* Pass an existing {@link SetupResult} via `overrides` to skip the setup phase.
|
|
197
|
-
*/
|
|
198
|
-
declare function build(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
|
|
199
|
-
/**
|
|
200
|
-
* Runs a full Kubb build and captures errors instead of throwing.
|
|
201
|
-
*
|
|
202
|
-
* - Installs each plugin in order, recording failures in `failedPlugins`.
|
|
203
|
-
* - Generates the root barrel file when `output.barrelType` is set.
|
|
204
|
-
* - Writes all files through the driver's FileManager and FileProcessor.
|
|
205
|
-
*
|
|
206
|
-
* Returns a {@link BuildOutput} even on failure — inspect `error` and
|
|
207
|
-
* `failedPlugins` to determine whether the build succeeded.
|
|
208
|
-
*/
|
|
209
|
-
declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
|
|
210
|
-
//#endregion
|
|
211
142
|
//#region src/createAdapter.d.ts
|
|
212
143
|
/**
|
|
213
144
|
* Builder type for an {@link Adapter} — takes options and returns the adapter instance.
|
|
@@ -252,6 +183,7 @@ type PluginBuilder<T extends PluginFactoryOptions = PluginFactoryOptions> = (opt
|
|
|
252
183
|
* // instantiate
|
|
253
184
|
* const plugin = myPlugin({ output: { path: 'src/gen' } })
|
|
254
185
|
* ```
|
|
186
|
+
* @deprecated use definePlugin instead
|
|
255
187
|
*/
|
|
256
188
|
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(build: PluginBuilder<T>): (options?: T['options']) => UserPluginWithLifeCycle<T>;
|
|
257
189
|
//#endregion
|
|
@@ -263,27 +195,13 @@ declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOpti
|
|
|
263
195
|
* export const myLogger = defineLogger({
|
|
264
196
|
* name: 'my-logger',
|
|
265
197
|
* install(context, options) {
|
|
266
|
-
* context.on('info', (message) => console.log('ℹ', message))
|
|
267
|
-
* context.on('error', (error) => console.error('✗', error.message))
|
|
198
|
+
* context.on('kubb:info', (message) => console.log('ℹ', message))
|
|
199
|
+
* context.on('kubb:error', (error) => console.error('✗', error.message))
|
|
268
200
|
* },
|
|
269
201
|
* })
|
|
270
202
|
*/
|
|
271
203
|
declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
|
|
272
204
|
//#endregion
|
|
273
|
-
//#region src/definePresets.d.ts
|
|
274
|
-
/**
|
|
275
|
-
* Creates a typed presets registry object — a named collection of {@link Preset} entries.
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
* import { definePreset, definePresets } from '@kubb/core'
|
|
279
|
-
* import { resolverTsLegacy } from '@kubb/plugin-ts'
|
|
280
|
-
*
|
|
281
|
-
* export const myPresets = definePresets({
|
|
282
|
-
* kubbV4: definePreset('kubbV4', { resolvers: [resolverTsLegacy] }),
|
|
283
|
-
* })
|
|
284
|
-
*/
|
|
285
|
-
declare function definePresets<TResolver extends Resolver = Resolver>(presets: Presets<TResolver>): Presets<TResolver>;
|
|
286
|
-
//#endregion
|
|
287
205
|
//#region src/defineResolver.d.ts
|
|
288
206
|
/**
|
|
289
207
|
* Builder type for the plugin-specific resolver fields.
|
|
@@ -601,35 +519,32 @@ type Formatter = keyof typeof formatters;
|
|
|
601
519
|
*/
|
|
602
520
|
declare function detectFormatter(): Promise<Formatter | null>;
|
|
603
521
|
//#endregion
|
|
604
|
-
//#region src/utils/getConfigs.d.ts
|
|
605
|
-
/**
|
|
606
|
-
* Resolves a {@link ConfigInput} into a normalized array of {@link Config} objects.
|
|
607
|
-
*
|
|
608
|
-
* - Awaits the config when it is a `Promise`.
|
|
609
|
-
* - Calls the factory function with `args` when the config is a function.
|
|
610
|
-
* - Wraps a single config object in an array for uniform downstream handling.
|
|
611
|
-
*/
|
|
612
|
-
declare function getConfigs(config: ConfigInput | UserConfig, args: CLIOptions): Promise<Array<Config>>;
|
|
613
|
-
//#endregion
|
|
614
522
|
//#region src/utils/getFunctionParams.d.ts
|
|
615
523
|
type Param = {
|
|
616
524
|
/**
|
|
617
|
-
*
|
|
525
|
+
* Controls how path parameters are emitted in the function signature.
|
|
526
|
+
* - `'object'` groups them as a single destructured parameter.
|
|
527
|
+
* - `'inline'` spreads them as individual comma-separated parameters.
|
|
528
|
+
* - `'inlineSpread'` emits a single rest parameter.
|
|
618
529
|
*
|
|
619
|
-
*
|
|
620
|
-
* @
|
|
621
|
-
* @private
|
|
530
|
+
* @default 'inline'
|
|
531
|
+
* @internal
|
|
622
532
|
*/
|
|
623
533
|
mode?: 'object' | 'inline' | 'inlineSpread';
|
|
624
534
|
type?: 'string' | 'number' | (string & {});
|
|
625
535
|
optional?: boolean;
|
|
626
536
|
/**
|
|
627
|
-
*
|
|
537
|
+
* Default value expression for the parameter.
|
|
538
|
+
*
|
|
539
|
+
* @example Assignment syntax
|
|
540
|
+
* `test = "default"`
|
|
628
541
|
*/
|
|
629
542
|
default?: string;
|
|
630
543
|
/**
|
|
631
|
-
* Used for no TypeScript(with mode object)
|
|
632
|
-
*
|
|
544
|
+
* Used for no TypeScript (with mode object).
|
|
545
|
+
*
|
|
546
|
+
* @example Value syntax
|
|
547
|
+
* `test: "default"`
|
|
633
548
|
*/
|
|
634
549
|
value?: string;
|
|
635
550
|
children?: Params;
|
|
@@ -663,45 +578,11 @@ declare class FunctionParams {
|
|
|
663
578
|
toConstructor(): string;
|
|
664
579
|
}
|
|
665
580
|
//#endregion
|
|
666
|
-
//#region src/utils/getPreset.d.ts
|
|
667
|
-
type GetPresetParams<TResolver extends Resolver> = {
|
|
668
|
-
preset: CompatibilityPreset;
|
|
669
|
-
presets: Presets<TResolver>;
|
|
670
|
-
/**
|
|
671
|
-
* Optional single resolver whose methods override the preset resolver.
|
|
672
|
-
* When a method returns `null` or `undefined` the preset resolver's method is used instead.
|
|
673
|
-
*/
|
|
674
|
-
resolver?: Partial<TResolver> & ThisType<TResolver>;
|
|
675
|
-
/**
|
|
676
|
-
* User-supplied generators to append after the preset's generators.
|
|
677
|
-
*/
|
|
678
|
-
generators?: Array<Generator<any>>;
|
|
679
|
-
/**
|
|
680
|
-
* Optional single transformer visitor whose methods override the preset transformer.
|
|
681
|
-
* When a method returns `null` or `undefined` the preset transformer's method is used instead.
|
|
682
|
-
*/
|
|
683
|
-
transformer?: Visitor;
|
|
684
|
-
};
|
|
685
|
-
type GetPresetResult<TResolver extends Resolver> = {
|
|
686
|
-
resolver: TResolver;
|
|
687
|
-
transformer: Visitor | undefined;
|
|
688
|
-
generators: Array<Generator<any>>;
|
|
689
|
-
preset: Preset<TResolver> | undefined;
|
|
690
|
-
};
|
|
691
|
-
/**
|
|
692
|
-
* Resolves a named preset into a resolver, transformer, and generators.
|
|
693
|
-
*
|
|
694
|
-
* - Selects the preset resolver; wraps it with user overrides using null/undefined fallback.
|
|
695
|
-
* - Composes the preset's transformers into a single visitor; wraps it with the user transformer using null/undefined fallback.
|
|
696
|
-
* - Combines preset generators with user-supplied generators; falls back to the `default` preset's generators when neither provides any.
|
|
697
|
-
*/
|
|
698
|
-
declare function getPreset<TResolver extends Resolver = Resolver>(params: GetPresetParams<TResolver>): GetPresetResult<TResolver>;
|
|
699
|
-
//#endregion
|
|
700
581
|
//#region src/utils/isInputPath.d.ts
|
|
701
582
|
/**
|
|
702
583
|
* Type guard to check if a given config has an `input.path`.
|
|
703
584
|
*/
|
|
704
|
-
declare function isInputPath(config:
|
|
585
|
+
declare function isInputPath(config: Config | undefined): config is Config<InputPath>;
|
|
705
586
|
//#endregion
|
|
706
587
|
//#region src/utils/linters.d.ts
|
|
707
588
|
type Linter = keyof typeof linters;
|
|
@@ -741,5 +622,5 @@ type DependencyVersion = string;
|
|
|
741
622
|
*/
|
|
742
623
|
declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
|
|
743
624
|
//#endregion
|
|
744
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, CLIOptions, CompatibilityPreset, Config, ConfigInput, DevtoolsOptions, Exclude, FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, GeneratorContext, Group, Include, InputData, InputPath,
|
|
625
|
+
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, BuildOutput, CLIOptions, CompatibilityPreset, Config, ConfigInput, DevtoolsOptions, Exclude, FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, GeneratorContext, Group, HookStylePlugin, Include, InputData, InputPath, Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbHooks, KubbPluginSetupContext, Logger, LoggerContext, LoggerOptions, OperationHook, OperationsHook, Output, Override, type Param, type Params, Parser, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginHooks, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, PossibleConfig, Renderer, RendererFactory, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, ResolvePathOptions, ResolvePathParams, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, SchemaHook, Storage, URLPath, UserGroup, UserLogger, UserPlugin, UserPluginWithLifeCycle, ast, buildDefaultBanner, composeTransformers, createAdapter, createFunctionParams, createKubb, createPlugin, createRenderer, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineGenerator, defineLogger, defineParser, definePlugin, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getFunctionParams, getMode, isInputPath, linters, logLevel, memoryStorage, satisfiesDependency };
|
|
745
626
|
//# sourceMappingURL=index.d.ts.map
|