@kubb/core 5.0.0-alpha.34 → 5.0.0-alpha.36
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-B_65W4fv.js +1677 -0
- package/dist/PluginDriver-B_65W4fv.js.map +1 -0
- package/dist/{PluginDriver-BBi_41VF.d.ts → PluginDriver-C9iBgYbk.d.ts} +743 -376
- package/dist/PluginDriver-CCdkwR14.cjs +1806 -0
- package/dist/PluginDriver-CCdkwR14.cjs.map +1 -0
- package/dist/hooks.d.ts +1 -1
- package/dist/index.cjs +272 -1666
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +62 -141
- package/dist/index.js +231 -1623
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +165 -0
- package/dist/mocks.cjs.map +1 -0
- package/dist/mocks.d.ts +74 -0
- package/dist/mocks.js +159 -0
- package/dist/mocks.js.map +1 -0
- package/package.json +11 -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 +7 -6
- package/src/mocks.ts +234 -0
- package/src/renderNode.ts +35 -0
- package/src/types.ts +275 -210
- 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 FileMetaBase, A as Override, B as ResolveNameParams, C as KubbPluginSetupContext, D as OperationHook, E as LoggerOptions, F as PluginLifecycleHooks, G as ResolverContext, H as ResolvePathOptions, I as PluginParameter, J as SchemaHook, K as ResolverFileParams, L as PluginWithLifeCycle, M as PluginContext, N as PluginFactoryOptions, O as OperationsHook, P as PluginLifecycle, Q as UserPluginWithLifeCycle, R as PossibleConfig, S as KubbBuildStartContext, T as LoggerContext, U as ResolvePathParams, V as ResolveOptionsContext, W as Resolver, X as UserLogger, Y as UserGroup, Z as UserPlugin, _ as Group, _t as RendererFactory, a as defineGenerator, at as Kubb, b as InputPath, c as AdapterSource, ct as createKubb, d as CompatibilityPreset, dt as Storage, et as getBarrelFiles, f as Config, ft as createStorage, g as GeneratorContext, gt as Renderer, h as Exclude, ht as logLevel, i as Generator, it as definePlugin, j as Plugin, k as Output, l as BarrelType, lt as Parser, m as DevtoolsOptions, mt as linters, n as getMode, nt as HookStylePlugin, o as Adapter, ot as KubbHooks, p as ConfigInput, pt as formatters, q as ResolverPathParams, r as FileManager, rt as PluginHooks, s as AdapterFactoryOptions, st as BuildOutput, t as PluginDriver, tt as FunctionParamsAST, u as CLIOptions, ut as defineParser, v as Include, vt as createRenderer, w as Logger, x as KubbBuildEndContext, y as InputData, yt as AsyncEventEmitter, z as ResolveBannerContext } from "./PluginDriver-C9iBgYbk.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.
|
|
@@ -537,6 +455,46 @@ declare function defaultResolveFooter(node: InputNode | undefined, {
|
|
|
537
455
|
*/
|
|
538
456
|
declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
|
|
539
457
|
//#endregion
|
|
458
|
+
//#region src/FileProcessor.d.ts
|
|
459
|
+
type ParseOptions = {
|
|
460
|
+
parsers?: Map<FileNode['extname'], Parser>;
|
|
461
|
+
extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
|
|
462
|
+
};
|
|
463
|
+
type RunOptions = ParseOptions & {
|
|
464
|
+
/**
|
|
465
|
+
* @default 'sequential'
|
|
466
|
+
*/
|
|
467
|
+
mode?: 'sequential' | 'parallel';
|
|
468
|
+
onStart?: (files: Array<FileNode>) => Promise<void> | void;
|
|
469
|
+
onEnd?: (files: Array<FileNode>) => Promise<void> | void;
|
|
470
|
+
onUpdate?: (params: {
|
|
471
|
+
file: FileNode;
|
|
472
|
+
source?: string;
|
|
473
|
+
processed: number;
|
|
474
|
+
total: number;
|
|
475
|
+
percentage: number;
|
|
476
|
+
}) => Promise<void> | void;
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* Converts a single file to a string using the registered parsers.
|
|
480
|
+
* Falls back to joining source values when no matching parser is found.
|
|
481
|
+
*/
|
|
482
|
+
declare class FileProcessor {
|
|
483
|
+
#private;
|
|
484
|
+
parse(file: FileNode, {
|
|
485
|
+
parsers,
|
|
486
|
+
extension
|
|
487
|
+
}?: ParseOptions): Promise<string>;
|
|
488
|
+
run(files: Array<FileNode>, {
|
|
489
|
+
parsers,
|
|
490
|
+
mode,
|
|
491
|
+
extension,
|
|
492
|
+
onStart,
|
|
493
|
+
onEnd,
|
|
494
|
+
onUpdate
|
|
495
|
+
}?: RunOptions): Promise<Array<FileNode>>;
|
|
496
|
+
}
|
|
497
|
+
//#endregion
|
|
540
498
|
//#region src/storages/fsStorage.d.ts
|
|
541
499
|
/**
|
|
542
500
|
* Built-in filesystem storage driver.
|
|
@@ -601,35 +559,32 @@ type Formatter = keyof typeof formatters;
|
|
|
601
559
|
*/
|
|
602
560
|
declare function detectFormatter(): Promise<Formatter | null>;
|
|
603
561
|
//#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
562
|
//#region src/utils/getFunctionParams.d.ts
|
|
615
563
|
type Param = {
|
|
616
564
|
/**
|
|
617
|
-
*
|
|
565
|
+
* Controls how path parameters are emitted in the function signature.
|
|
566
|
+
* - `'object'` groups them as a single destructured parameter.
|
|
567
|
+
* - `'inline'` spreads them as individual comma-separated parameters.
|
|
568
|
+
* - `'inlineSpread'` emits a single rest parameter.
|
|
618
569
|
*
|
|
619
|
-
*
|
|
620
|
-
* @
|
|
621
|
-
* @private
|
|
570
|
+
* @default 'inline'
|
|
571
|
+
* @internal
|
|
622
572
|
*/
|
|
623
573
|
mode?: 'object' | 'inline' | 'inlineSpread';
|
|
624
574
|
type?: 'string' | 'number' | (string & {});
|
|
625
575
|
optional?: boolean;
|
|
626
576
|
/**
|
|
627
|
-
*
|
|
577
|
+
* Default value expression for the parameter.
|
|
578
|
+
*
|
|
579
|
+
* @example Assignment syntax
|
|
580
|
+
* `test = "default"`
|
|
628
581
|
*/
|
|
629
582
|
default?: string;
|
|
630
583
|
/**
|
|
631
|
-
* Used for no TypeScript(with mode object)
|
|
632
|
-
*
|
|
584
|
+
* Used for no TypeScript (with mode object).
|
|
585
|
+
*
|
|
586
|
+
* @example Value syntax
|
|
587
|
+
* `test: "default"`
|
|
633
588
|
*/
|
|
634
589
|
value?: string;
|
|
635
590
|
children?: Params;
|
|
@@ -663,45 +618,11 @@ declare class FunctionParams {
|
|
|
663
618
|
toConstructor(): string;
|
|
664
619
|
}
|
|
665
620
|
//#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
621
|
//#region src/utils/isInputPath.d.ts
|
|
701
622
|
/**
|
|
702
623
|
* Type guard to check if a given config has an `input.path`.
|
|
703
624
|
*/
|
|
704
|
-
declare function isInputPath(config:
|
|
625
|
+
declare function isInputPath(config: Config | undefined): config is Config<InputPath>;
|
|
705
626
|
//#endregion
|
|
706
627
|
//#region src/utils/linters.d.ts
|
|
707
628
|
type Linter = keyof typeof linters;
|
|
@@ -741,5 +662,5 @@ type DependencyVersion = string;
|
|
|
741
662
|
*/
|
|
742
663
|
declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
|
|
743
664
|
//#endregion
|
|
744
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, CLIOptions, CompatibilityPreset, Config, ConfigInput, DevtoolsOptions, Exclude, FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, GeneratorContext, Group, Include, InputData, InputPath,
|
|
665
|
+
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, BuildOutput, CLIOptions, CompatibilityPreset, Config, ConfigInput, DevtoolsOptions, Exclude, FileManager, FileMetaBase, FileProcessor, 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
666
|
//# sourceMappingURL=index.d.ts.map
|