@kubb/core 5.0.0-alpha.35 → 5.0.0-alpha.38

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
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";
2
+ import { $ as FileManager, A as PluginParameter, B as ResolverFileParams, C as Output, D as PluginFactoryOptions, E as PluginContext, F as ResolveOptionsContext, G as UserPlugin, H as SchemaHook, I as ResolvePathOptions, J as Kubb, K as UserPluginWithLifeCycle, L as ResolvePathParams, M as PossibleConfig, N as ResolveBannerContext, O as PluginLifecycle, P as ResolveNameParams, Q as PluginDriver, R as Resolver, S as OperationsHook, T as Plugin, U as UserGroup, V as ResolverPathParams, W as UserLogger, X as BuildOutput, Y as KubbHooks, Z as createKubb, _ as KubbPluginSetupContext, a as CLIOptions, at as Generator, b as LoggerOptions, c as DevtoolsOptions, ct as createStorage, d as Group, dt as createRenderer, et as HookStylePlugin, f as Include, ft as logLevel, g as KubbBuildStartContext, h as KubbBuildEndContext, i as BarrelType, it as defineParser, j as PluginWithLifeCycle, k as PluginLifecycleHooks, l as Exclude, lt as Renderer, m as InputPath, n as AdapterFactoryOptions, nt as definePlugin, o as CompatibilityPreset, ot as defineGenerator, p as InputData, pt as AsyncEventEmitter, q as FileMetaBase, r as AdapterSource, rt as Parser, s as Config, st as Storage, t as Adapter, tt as PluginHooks, u as GeneratorContext, ut as RendererFactory, v as Logger, w as Override, x as OperationHook, y as LoggerContext, z as ResolverContext } from "./types-DUc5lEUp.js";
3
3
  import * as ast from "@kubb/ast";
4
- import { FileNode, InputNode, Node, composeTransformers, definePrinter } from "@kubb/ast";
4
+ import { FileNode, InputNode, Node } from "@kubb/ast";
5
5
 
6
6
  //#region ../../internals/utils/src/urlPath.d.ts
7
7
  type URLObject = {
@@ -33,7 +33,7 @@ type ObjectOptions = {
33
33
  * Supported identifier casing strategies for path parameters.
34
34
  */
35
35
  type PathCasing = 'camelcase';
36
- type Options$1 = {
36
+ type Options = {
37
37
  /**
38
38
  * Casing strategy applied to path parameter names.
39
39
  * @default undefined (original identifier preserved)
@@ -54,7 +54,7 @@ declare class URLPath {
54
54
  * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
55
55
  */
56
56
  path: string;
57
- constructor(path: string, options?: Options$1);
57
+ constructor(path: string, options?: Options);
58
58
  /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
59
59
  *
60
60
  * @example
@@ -161,32 +161,6 @@ type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) =
161
161
  */
162
162
  declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
163
163
  //#endregion
164
- //#region src/createPlugin.d.ts
165
- /**
166
- * Builder type for a {@link UserPluginWithLifeCycle} — takes options and returns the plugin instance.
167
- */
168
- type PluginBuilder<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>;
169
- /**
170
- * Creates a plugin factory. Call the returned function with optional options to get the plugin instance.
171
- *
172
- * @example
173
- * ```ts
174
- * export const myPlugin = createPlugin<MyPlugin>((options) => {
175
- * return {
176
- * name: 'my-plugin',
177
- * get options() { return options },
178
- * resolvePath(baseName) { ... },
179
- * resolveName(name, type) { ... },
180
- * }
181
- * })
182
- *
183
- * // instantiate
184
- * const plugin = myPlugin({ output: { path: 'src/gen' } })
185
- * ```
186
- * @deprecated use definePlugin instead
187
- */
188
- declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(build: PluginBuilder<T>): (options?: T['options']) => UserPluginWithLifeCycle<T>;
189
- //#endregion
190
164
  //#region src/defineLogger.d.ts
191
165
  /**
192
166
  * Wraps a logger definition into a typed {@link Logger}.
@@ -236,177 +210,6 @@ type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<T['resolver'],
236
210
  * // → { enumType: 'enum' } when operationId matches
237
211
  * ```
238
212
  */
239
- declare function defaultResolveOptions<TOptions>(node: Node, {
240
- options,
241
- exclude,
242
- include,
243
- override
244
- }: ResolveOptionsContext<TOptions>): TOptions | null;
245
- /**
246
- * Default path resolver used by `defineResolver`.
247
- *
248
- * - Returns the output directory in `single` mode.
249
- * - Resolves into a tag- or path-based subdirectory when `group` and a `tag`/`path` value are provided.
250
- * - Falls back to a flat `output/baseName` path otherwise.
251
- *
252
- * A custom `group.name` function overrides the default subdirectory naming.
253
- * For `tag` groups the default is `${camelCase(tag)}Controller`.
254
- * For `path` groups the default is the first path segment after `/`.
255
- *
256
- * @example Flat output
257
- * ```ts
258
- * defaultResolvePath({ baseName: 'petTypes.ts' }, { root: '/src', output: { path: 'types' } })
259
- * // → '/src/types/petTypes.ts'
260
- * ```
261
- *
262
- * @example Tag-based grouping
263
- * ```ts
264
- * defaultResolvePath(
265
- * { baseName: 'petTypes.ts', tag: 'pets' },
266
- * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
267
- * )
268
- * // → '/src/types/petsController/petTypes.ts'
269
- * ```
270
- *
271
- * @example Path-based grouping
272
- * ```ts
273
- * defaultResolvePath(
274
- * { baseName: 'petTypes.ts', path: '/pets/list' },
275
- * { root: '/src', output: { path: 'types' }, group: { type: 'path' } },
276
- * )
277
- * // → '/src/types/pets/petTypes.ts'
278
- * ```
279
- *
280
- * @example Single-file mode
281
- * ```ts
282
- * defaultResolvePath(
283
- * { baseName: 'petTypes.ts', pathMode: 'single' },
284
- * { root: '/src', output: { path: 'types' } },
285
- * )
286
- * // → '/src/types'
287
- * ```
288
- */
289
- declare function defaultResolvePath({
290
- baseName,
291
- pathMode,
292
- tag,
293
- path: groupPath
294
- }: ResolverPathParams, {
295
- root,
296
- output,
297
- group
298
- }: ResolverContext): string;
299
- /**
300
- * Default file resolver used by `defineResolver`.
301
- *
302
- * Resolves a `FileNode` by combining name resolution (`resolver.default`) with
303
- * path resolution (`resolver.resolvePath`). The resolved file always has empty
304
- * `sources`, `imports`, and `exports` arrays — consumers populate those separately.
305
- *
306
- * In `single` mode the name is omitted and the file sits directly in the output directory.
307
- *
308
- * @example Resolve a schema file
309
- * ```ts
310
- * const file = defaultResolveFile.call(resolver,
311
- * { name: 'pet', extname: '.ts' },
312
- * { root: '/src', output: { path: 'types' } },
313
- * )
314
- * // → { baseName: 'pet.ts', path: '/src/types/pet.ts', sources: [], ... }
315
- * ```
316
- *
317
- * @example Resolve an operation file with tag grouping
318
- * ```ts
319
- * const file = defaultResolveFile.call(resolver,
320
- * { name: 'listPets', extname: '.ts', tag: 'pets' },
321
- * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
322
- * )
323
- * // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }
324
- * ```
325
- */
326
- declare function defaultResolveFile(this: Resolver, {
327
- name,
328
- extname,
329
- tag,
330
- path: groupPath
331
- }: ResolverFileParams, context: ResolverContext): FileNode;
332
- /**
333
- * Generates the default "Generated by Kubb" banner from config and optional node metadata.
334
- */
335
- declare function buildDefaultBanner({
336
- title,
337
- description,
338
- version,
339
- config
340
- }: {
341
- title?: string;
342
- description?: string;
343
- version?: string;
344
- config: Config;
345
- }): string;
346
- /**
347
- * Default banner resolver — returns the banner string for a generated file.
348
- *
349
- * A user-supplied `output.banner` overrides the default Kubb "Generated by Kubb" notice.
350
- * When no `output.banner` is set, the Kubb notice is used (including `title` and `version`
351
- * from the OAS spec when a `node` is provided).
352
- *
353
- * - When `output.banner` is a function and `node` is provided, returns `output.banner(node)`.
354
- * - When `output.banner` is a function and `node` is absent, falls back to the Kubb notice.
355
- * - When `output.banner` is a string, returns it directly.
356
- * - When `config.output.defaultBanner` is `false`, returns `undefined`.
357
- * - Otherwise returns the Kubb "Generated by Kubb" notice.
358
- *
359
- * @example String banner overrides default
360
- * ```ts
361
- * defaultResolveBanner(undefined, { output: { banner: '// my banner' }, config })
362
- * // → '// my banner'
363
- * ```
364
- *
365
- * @example Function banner with node
366
- * ```ts
367
- * defaultResolveBanner(inputNode, { output: { banner: (node) => `// v${node.version}` }, config })
368
- * // → '// v3.0.0'
369
- * ```
370
- *
371
- * @example No user banner — Kubb notice with OAS metadata
372
- * ```ts
373
- * defaultResolveBanner(inputNode, { config })
374
- * // → '/** Generated by Kubb ... Title: Pet Store ... *\/'
375
- * ```
376
- *
377
- * @example Disabled default banner
378
- * ```ts
379
- * defaultResolveBanner(undefined, { config: { output: { defaultBanner: false }, ...config } })
380
- * // → undefined
381
- * ```
382
- */
383
- declare function defaultResolveBanner(node: InputNode | undefined, {
384
- output,
385
- config
386
- }: ResolveBannerContext): string | undefined;
387
- /**
388
- * Default footer resolver — returns the footer string for a generated file.
389
- *
390
- * - When `output.footer` is a function and `node` is provided, calls it with the node.
391
- * - When `output.footer` is a function and `node` is absent, returns `undefined`.
392
- * - When `output.footer` is a string, returns it directly.
393
- * - Otherwise returns `undefined`.
394
- *
395
- * @example String footer
396
- * ```ts
397
- * defaultResolveFooter(undefined, { output: { footer: '// end of file' }, config })
398
- * // → '// end of file'
399
- * ```
400
- *
401
- * @example Function footer with node
402
- * ```ts
403
- * defaultResolveFooter(inputNode, { output: { footer: (node) => `// ${node.title}` }, config })
404
- * // → '// Pet Store'
405
- * ```
406
- */
407
- declare function defaultResolveFooter(node: InputNode | undefined, {
408
- output
409
- }: ResolveBannerContext): string | undefined;
410
213
  /**
411
214
  * Defines a resolver for a plugin, injecting built-in defaults for name casing,
412
215
  * include/exclude/override filtering, path resolution, and file construction.
@@ -455,6 +258,46 @@ declare function defaultResolveFooter(node: InputNode | undefined, {
455
258
  */
456
259
  declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
457
260
  //#endregion
261
+ //#region src/FileProcessor.d.ts
262
+ type ParseOptions = {
263
+ parsers?: Map<FileNode['extname'], Parser>;
264
+ extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
265
+ };
266
+ type RunOptions = ParseOptions & {
267
+ /**
268
+ * @default 'sequential'
269
+ */
270
+ mode?: 'sequential' | 'parallel';
271
+ onStart?: (files: Array<FileNode>) => Promise<void> | void;
272
+ onEnd?: (files: Array<FileNode>) => Promise<void> | void;
273
+ onUpdate?: (params: {
274
+ file: FileNode;
275
+ source?: string;
276
+ processed: number;
277
+ total: number;
278
+ percentage: number;
279
+ }) => Promise<void> | void;
280
+ };
281
+ /**
282
+ * Converts a single file to a string using the registered parsers.
283
+ * Falls back to joining source values when no matching parser is found.
284
+ */
285
+ declare class FileProcessor {
286
+ #private;
287
+ parse(file: FileNode, {
288
+ parsers,
289
+ extension
290
+ }?: ParseOptions): Promise<string>;
291
+ run(files: Array<FileNode>, {
292
+ parsers,
293
+ mode,
294
+ extension,
295
+ onStart,
296
+ onEnd,
297
+ onUpdate
298
+ }?: RunOptions): Promise<Array<FileNode>>;
299
+ }
300
+ //#endregion
458
301
  //#region src/storages/fsStorage.d.ts
459
302
  /**
460
303
  * Built-in filesystem storage driver.
@@ -501,126 +344,11 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
501
344
  */
502
345
  declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
503
346
  //#endregion
504
- //#region src/utils/formatters.d.ts
505
- type Formatter = keyof typeof formatters;
506
- /**
507
- * Detects the first available code formatter on the current system.
508
- *
509
- * - Checks in preference order: `biome`, `oxfmt`, `prettier`.
510
- * - Returns `null` when none are found.
511
- *
512
- * @example
513
- * ```ts
514
- * const formatter = await detectFormatter()
515
- * if (formatter) {
516
- * console.log(`Using ${formatter} for formatting`)
517
- * }
518
- * ```
519
- */
520
- declare function detectFormatter(): Promise<Formatter | null>;
521
- //#endregion
522
- //#region src/utils/getFunctionParams.d.ts
523
- type Param = {
524
- /**
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.
529
- *
530
- * @default 'inline'
531
- * @internal
532
- */
533
- mode?: 'object' | 'inline' | 'inlineSpread';
534
- type?: 'string' | 'number' | (string & {});
535
- optional?: boolean;
536
- /**
537
- * Default value expression for the parameter.
538
- *
539
- * @example Assignment syntax
540
- * `test = "default"`
541
- */
542
- default?: string;
543
- /**
544
- * Used for no TypeScript (with mode object).
545
- *
546
- * @example Value syntax
547
- * `test: "default"`
548
- */
549
- value?: string;
550
- children?: Params;
551
- };
552
- type Params = Record<string, Param | undefined>;
553
- type Options = {
554
- type: 'constructor' | 'call' | 'object' | 'objectValue';
555
- transformName?: (name: string) => string;
556
- transformType?: (type: string) => string;
557
- };
558
- declare function getFunctionParams(params: Params, options: Options): string;
559
- /**
560
- * @deprecated use @kubb/ast
561
- */
562
- declare function createFunctionParams(params: Params): Params;
563
- /**
564
- * @deprecated use @kubb/ast
565
- */
566
- declare class FunctionParams {
567
- #private;
568
- static factory(params: Params): FunctionParams;
569
- constructor(params: Params);
570
- get params(): Params;
571
- get flatParams(): Params;
572
- toCall({
573
- transformName,
574
- transformType
575
- }?: Pick<Options, 'transformName' | 'transformType'>): string;
576
- toObject(): string;
577
- toObjectValue(): string;
578
- toConstructor(): string;
579
- }
580
- //#endregion
581
347
  //#region src/utils/isInputPath.d.ts
582
348
  /**
583
349
  * Type guard to check if a given config has an `input.path`.
584
350
  */
585
351
  declare function isInputPath(config: Config | undefined): config is Config<InputPath>;
586
352
  //#endregion
587
- //#region src/utils/linters.d.ts
588
- type Linter = keyof typeof linters;
589
- /**
590
- * Detects the first available linter on the current system.
591
- *
592
- * - Checks in preference order: `biome`, `oxlint`, `eslint`.
593
- * - Returns `null` when none are found.
594
- *
595
- * @example
596
- * ```ts
597
- * const linter = await detectLinter()
598
- * if (linter) {
599
- * console.log(`Using ${linter} for linting`)
600
- * }
601
- * ```
602
- */
603
- declare function detectLinter(): Promise<Linter | null>;
604
- //#endregion
605
- //#region src/utils/packageJSON.d.ts
606
- type DependencyName = string;
607
- type DependencyVersion = string;
608
- /**
609
- * Returns `true` when the nearest `package.json` declares a dependency that
610
- * satisfies the given semver range.
611
- *
612
- * - Searches both `dependencies` and `devDependencies`.
613
- * - Accepts a string package name or a `RegExp` to match scoped/pattern packages.
614
- * - Uses `semver.satisfies` for range comparison; returns `false` when the
615
- * version string cannot be coerced into a valid semver.
616
- *
617
- * @example
618
- * ```ts
619
- * satisfiesDependency('react', '>=18') // true when react@18.x is installed
620
- * satisfiesDependency(/^@tanstack\//, '>=5') // true when any @tanstack/* >=5 is found
621
- * ```
622
- */
623
- declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
624
- //#endregion
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 };
353
+ export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, BuildOutput, CLIOptions, CompatibilityPreset, Config, DevtoolsOptions, Exclude, FileManager, FileMetaBase, FileProcessor, Generator, GeneratorContext, Group, HookStylePlugin, Include, InputData, InputPath, Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbHooks, KubbPluginSetupContext, Logger, LoggerContext, LoggerOptions, OperationHook, OperationsHook, Output, Override, 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, createAdapter, createKubb, createRenderer, createStorage, defineGenerator, defineLogger, defineParser, definePlugin, defineResolver, fsStorage, isInputPath, logLevel, memoryStorage };
626
354
  //# sourceMappingURL=index.d.ts.map