@kubb/core 5.0.0-alpha.36 → 5.0.0-alpha.39

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.
Files changed (42) hide show
  1. package/dist/{PluginDriver-CCdkwR14.cjs → PluginDriver-BQwm8hDd.cjs} +70 -147
  2. package/dist/PluginDriver-BQwm8hDd.cjs.map +1 -0
  3. package/dist/{PluginDriver-B_65W4fv.js → PluginDriver-CgXFtmNP.js} +36 -96
  4. package/dist/PluginDriver-CgXFtmNP.js.map +1 -0
  5. package/dist/index.cjs +23 -341
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +5 -317
  8. package/dist/index.js +23 -311
  9. package/dist/index.js.map +1 -1
  10. package/dist/mocks.cjs +2 -3
  11. package/dist/mocks.cjs.map +1 -1
  12. package/dist/mocks.d.ts +2 -2
  13. package/dist/mocks.js +2 -2
  14. package/dist/mocks.js.map +1 -1
  15. package/dist/{PluginDriver-C9iBgYbk.d.ts → types-DUc5lEUp.d.ts} +596 -714
  16. package/package.json +4 -11
  17. package/src/PluginDriver.ts +18 -17
  18. package/src/constants.ts +0 -48
  19. package/src/createKubb.ts +1 -1
  20. package/src/defineResolver.ts +3 -3
  21. package/src/index.ts +3 -20
  22. package/src/mocks.ts +3 -3
  23. package/src/storages/fsStorage.ts +27 -7
  24. package/src/types.ts +3 -11
  25. package/src/utils/TreeNode.ts +3 -3
  26. package/src/utils/executeStrategies.ts +0 -16
  27. package/dist/PluginDriver-B_65W4fv.js.map +0 -1
  28. package/dist/PluginDriver-CCdkwR14.cjs.map +0 -1
  29. package/dist/chunk-ByKO4r7w.cjs +0 -38
  30. package/dist/hooks.cjs +0 -32
  31. package/dist/hooks.cjs.map +0 -1
  32. package/dist/hooks.d.ts +0 -23
  33. package/dist/hooks.js +0 -29
  34. package/dist/hooks.js.map +0 -1
  35. package/src/hooks/index.ts +0 -3
  36. package/src/hooks/useDriver.ts +0 -9
  37. package/src/hooks/useMode.ts +0 -8
  38. package/src/hooks/usePlugin.ts +0 -9
  39. package/src/utils/FunctionParams.ts +0 -155
  40. package/src/utils/formatters.ts +0 -45
  41. package/src/utils/getFunctionParams.ts +0 -254
  42. package/src/utils/linters.ts +0 -45
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
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";
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.
@@ -541,126 +344,11 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
541
344
  */
542
345
  declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
543
346
  //#endregion
544
- //#region src/utils/formatters.d.ts
545
- type Formatter = keyof typeof formatters;
546
- /**
547
- * Detects the first available code formatter on the current system.
548
- *
549
- * - Checks in preference order: `biome`, `oxfmt`, `prettier`.
550
- * - Returns `null` when none are found.
551
- *
552
- * @example
553
- * ```ts
554
- * const formatter = await detectFormatter()
555
- * if (formatter) {
556
- * console.log(`Using ${formatter} for formatting`)
557
- * }
558
- * ```
559
- */
560
- declare function detectFormatter(): Promise<Formatter | null>;
561
- //#endregion
562
- //#region src/utils/getFunctionParams.d.ts
563
- type Param = {
564
- /**
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.
569
- *
570
- * @default 'inline'
571
- * @internal
572
- */
573
- mode?: 'object' | 'inline' | 'inlineSpread';
574
- type?: 'string' | 'number' | (string & {});
575
- optional?: boolean;
576
- /**
577
- * Default value expression for the parameter.
578
- *
579
- * @example Assignment syntax
580
- * `test = "default"`
581
- */
582
- default?: string;
583
- /**
584
- * Used for no TypeScript (with mode object).
585
- *
586
- * @example Value syntax
587
- * `test: "default"`
588
- */
589
- value?: string;
590
- children?: Params;
591
- };
592
- type Params = Record<string, Param | undefined>;
593
- type Options = {
594
- type: 'constructor' | 'call' | 'object' | 'objectValue';
595
- transformName?: (name: string) => string;
596
- transformType?: (type: string) => string;
597
- };
598
- declare function getFunctionParams(params: Params, options: Options): string;
599
- /**
600
- * @deprecated use @kubb/ast
601
- */
602
- declare function createFunctionParams(params: Params): Params;
603
- /**
604
- * @deprecated use @kubb/ast
605
- */
606
- declare class FunctionParams {
607
- #private;
608
- static factory(params: Params): FunctionParams;
609
- constructor(params: Params);
610
- get params(): Params;
611
- get flatParams(): Params;
612
- toCall({
613
- transformName,
614
- transformType
615
- }?: Pick<Options, 'transformName' | 'transformType'>): string;
616
- toObject(): string;
617
- toObjectValue(): string;
618
- toConstructor(): string;
619
- }
620
- //#endregion
621
347
  //#region src/utils/isInputPath.d.ts
622
348
  /**
623
349
  * Type guard to check if a given config has an `input.path`.
624
350
  */
625
351
  declare function isInputPath(config: Config | undefined): config is Config<InputPath>;
626
352
  //#endregion
627
- //#region src/utils/linters.d.ts
628
- type Linter = keyof typeof linters;
629
- /**
630
- * Detects the first available linter on the current system.
631
- *
632
- * - Checks in preference order: `biome`, `oxlint`, `eslint`.
633
- * - Returns `null` when none are found.
634
- *
635
- * @example
636
- * ```ts
637
- * const linter = await detectLinter()
638
- * if (linter) {
639
- * console.log(`Using ${linter} for linting`)
640
- * }
641
- * ```
642
- */
643
- declare function detectLinter(): Promise<Linter | null>;
644
- //#endregion
645
- //#region src/utils/packageJSON.d.ts
646
- type DependencyName = string;
647
- type DependencyVersion = string;
648
- /**
649
- * Returns `true` when the nearest `package.json` declares a dependency that
650
- * satisfies the given semver range.
651
- *
652
- * - Searches both `dependencies` and `devDependencies`.
653
- * - Accepts a string package name or a `RegExp` to match scoped/pattern packages.
654
- * - Uses `semver.satisfies` for range comparison; returns `false` when the
655
- * version string cannot be coerced into a valid semver.
656
- *
657
- * @example
658
- * ```ts
659
- * satisfiesDependency('react', '>=18') // true when react@18.x is installed
660
- * satisfiesDependency(/^@tanstack\//, '>=5') // true when any @tanstack/* >=5 is found
661
- * ```
662
- */
663
- declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
664
- //#endregion
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 };
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 };
666
354
  //# sourceMappingURL=index.d.ts.map