@kubb/core 4.32.4 → 4.33.1

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 (85) hide show
  1. package/dist/hooks.d.ts +1 -1
  2. package/dist/index.cjs +1695 -82
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +150 -20
  5. package/dist/index.js +1673 -65
  6. package/dist/index.js.map +1 -1
  7. package/dist/{types-f_no0d7G.d.ts → types-DfjjJb2r.d.ts} +70 -27
  8. package/package.json +3 -24
  9. package/src/BarrelManager.ts +10 -31
  10. package/src/PackageManager.ts +13 -21
  11. package/src/PluginManager.ts +65 -87
  12. package/src/PromiseManager.ts +3 -5
  13. package/src/build.ts +61 -47
  14. package/src/config.ts +1 -1
  15. package/src/constants.ts +60 -0
  16. package/src/errors.ts +1 -14
  17. package/src/index.ts +6 -3
  18. package/src/types.ts +5 -14
  19. package/src/utils/FunctionParams.ts +7 -8
  20. package/src/utils/TreeNode.ts +12 -23
  21. package/src/utils/executeStrategies.ts +5 -3
  22. package/src/utils/formatters.ts +3 -20
  23. package/src/utils/getBarrelFiles.ts +8 -2
  24. package/src/utils/getConfigs.ts +6 -15
  25. package/src/utils/getPlugins.ts +7 -7
  26. package/src/utils/linters.ts +3 -20
  27. package/dist/fs-D4eqq6bR.cjs +0 -103
  28. package/dist/fs-D4eqq6bR.cjs.map +0 -1
  29. package/dist/fs-TVBCPkE-.js +0 -67
  30. package/dist/fs-TVBCPkE-.js.map +0 -1
  31. package/dist/fs.cjs +0 -8
  32. package/dist/fs.d.ts +0 -23
  33. package/dist/fs.js +0 -2
  34. package/dist/packageManager-_7I0WFQU.d.ts +0 -82
  35. package/dist/packageManager-jzjuEj2U.cjs +0 -1103
  36. package/dist/packageManager-jzjuEj2U.cjs.map +0 -1
  37. package/dist/packageManager-wMCQlgd6.js +0 -1024
  38. package/dist/packageManager-wMCQlgd6.js.map +0 -1
  39. package/dist/transformers-BwSpAhvT.js +0 -267
  40. package/dist/transformers-BwSpAhvT.js.map +0 -1
  41. package/dist/transformers-BweFhqh-.cjs +0 -380
  42. package/dist/transformers-BweFhqh-.cjs.map +0 -1
  43. package/dist/transformers.cjs +0 -24
  44. package/dist/transformers.d.ts +0 -108
  45. package/dist/transformers.js +0 -2
  46. package/dist/utils.cjs +0 -430
  47. package/dist/utils.cjs.map +0 -1
  48. package/dist/utils.d.ts +0 -290
  49. package/dist/utils.js +0 -402
  50. package/dist/utils.js.map +0 -1
  51. package/src/BaseGenerator.ts +0 -34
  52. package/src/fs/clean.ts +0 -5
  53. package/src/fs/exists.ts +0 -16
  54. package/src/fs/index.ts +0 -5
  55. package/src/fs/read.ts +0 -13
  56. package/src/fs/utils.ts +0 -32
  57. package/src/fs/write.ts +0 -46
  58. package/src/transformers/casing.ts +0 -62
  59. package/src/transformers/combineCodes.ts +0 -3
  60. package/src/transformers/createJSDocBlockText.ts +0 -9
  61. package/src/transformers/escape.ts +0 -31
  62. package/src/transformers/indent.ts +0 -3
  63. package/src/transformers/index.ts +0 -46
  64. package/src/transformers/nameSorter.ts +0 -9
  65. package/src/transformers/searchAndReplace.ts +0 -25
  66. package/src/transformers/stringify.ts +0 -25
  67. package/src/transformers/toRegExp.ts +0 -22
  68. package/src/transformers/transformReservedWord.ts +0 -106
  69. package/src/transformers/trim.ts +0 -18
  70. package/src/utils/AsyncEventEmitter.ts +0 -48
  71. package/src/utils/Cache.ts +0 -31
  72. package/src/utils/URLPath.ts +0 -146
  73. package/src/utils/buildJSDoc.ts +0 -34
  74. package/src/utils/checkOnlineStatus.ts +0 -40
  75. package/src/utils/formatHrtime.ts +0 -33
  76. package/src/utils/getNestedAccessor.ts +0 -25
  77. package/src/utils/index.ts +0 -26
  78. package/src/utils/packageManager.ts +0 -58
  79. package/src/utils/promise.ts +0 -13
  80. package/src/utils/renderTemplate.ts +0 -31
  81. package/src/utils/serializePluginOptions.ts +0 -29
  82. package/src/utils/timeout.ts +0 -11
  83. package/src/utils/tokenize.ts +0 -23
  84. package/src/utils/types.ts +0 -1
  85. package/src/utils/uniqueName.ts +0 -20
package/dist/index.d.ts CHANGED
@@ -1,23 +1,8 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { A as AsyncEventEmitter, C as UserLogger, D as KubbEvents, O as PluginManager, S as UserConfig, T as UserPluginWithLifeCycle, _ as PluginLifecycleHooks, a as InputData, b as ResolveNameParams, c as Logger, d as Output, f as Plugin, g as PluginLifecycle, h as PluginKey, i as Group, k as getMode, l as LoggerContext, m as PluginFactoryOptions, n as Config, o as InputPath, p as PluginContext, r as GetPluginFactoryOptions, s as LogLevel, t as BarrelType, u as LoggerOptions, v as PluginParameter, w as UserPlugin, x as ResolvePathParams, y as PluginWithLifeCycle } from "./types-f_no0d7G.js";
3
- import { a as getBarrelFiles, c as isInputPath, i as FileMetaBase, n as PackageManagerName, o as CLIOptions, r as detectPackageManager, s as defineConfig, t as PackageManagerInfo } from "./packageManager-_7I0WFQU.js";
2
+ import { A as linters, C as UserLogger, D as PluginManager, E as KubbEvents, M as AsyncEventEmitter, O as getMode, S as UserConfig, T as UserPluginWithLifeCycle, _ as PluginParameter, a as InputData, b as ResolvePathParams, c as LoggerContext, d as Plugin, f as PluginContext, g as PluginLifecycleHooks, h as PluginLifecycle, i as Group, j as logLevel, k as formatters, l as LoggerOptions, m as PluginKey, n as Config, o as InputPath, p as PluginFactoryOptions, r as GetPluginFactoryOptions, s as Logger, t as BarrelType, u as Output, v as PluginWithLifeCycle, w as UserPlugin, x as UnknownUserPlugin, y as ResolveNameParams } from "./types-DfjjJb2r.js";
4
3
  import { Fabric } from "@kubb/react-fabric";
5
4
  import { KubbFile } from "@kubb/fabric-core/types";
6
5
 
7
- //#region src/BaseGenerator.d.ts
8
- /**
9
- * Abstract class that contains the building blocks for plugins to create their own Generator
10
- * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
11
- */
12
- declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
13
- #private;
14
- constructor(options?: TOptions, context?: TContext);
15
- get options(): TOptions;
16
- get context(): TContext;
17
- set options(options: TOptions);
18
- abstract build(...params: unknown[]): unknown;
19
- }
20
- //#endregion
21
6
  //#region src/build.d.ts
22
7
  type BuildOptions = {
23
8
  config: UserConfig;
@@ -45,6 +30,44 @@ declare function setup(options: BuildOptions): Promise<SetupResult>;
45
30
  declare function build(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
46
31
  declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
47
32
  //#endregion
33
+ //#region src/config.d.ts
34
+ /**
35
+ * CLI options derived from command-line flags.
36
+ */
37
+ type CLIOptions = {
38
+ /** Path to `kubb.config.js` */config?: string; /** Enable watch mode for input files */
39
+ watch?: boolean;
40
+ /**
41
+ * Logging verbosity for CLI usage.
42
+ *
43
+ * - `silent`: hide non-essential logs
44
+ * - `info`: show general logs (non-plugin-related)
45
+ * - `debug`: include detailed plugin lifecycle logs
46
+ * @default 'silent'
47
+ */
48
+ logLevel?: 'silent' | 'info' | 'debug'; /** Run Kubb with Bun */
49
+ bun?: boolean;
50
+ };
51
+ /**
52
+ * Helper for defining a Kubb configuration.
53
+ *
54
+ * Accepts either:
55
+ * - A config object or array of configs
56
+ * - A function returning the config(s), optionally async,
57
+ * receiving the CLI options as argument
58
+ *
59
+ * @example
60
+ * export default defineConfig(({ logLevel }) => ({
61
+ * root: 'src',
62
+ * plugins: [myPlugin()],
63
+ * }))
64
+ */
65
+ declare function defineConfig(config: PossiblePromise<UserConfig | UserConfig[]> | ((cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>)): typeof config;
66
+ /**
67
+ * Type guard to check if a given config has an `input.path`.
68
+ */
69
+ declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
70
+ //#endregion
48
71
  //#region src/defineLogger.d.ts
49
72
  declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
50
73
  //#endregion
@@ -69,7 +92,7 @@ declare class PackageManager {
69
92
  get workspace(): string | undefined;
70
93
  normalizeDirectory(directory: string): string;
71
94
  getLocation(path: string): string;
72
- import(path: string): Promise<any | undefined>;
95
+ import(path: string): Promise<unknown>;
73
96
  getPackageJSON(): Promise<PackageJSON | undefined>;
74
97
  getPackageJSONSync(): PackageJSON | undefined;
75
98
  static setVersion(dependency: DependencyName, version: DependencyVersion): void;
@@ -99,10 +122,10 @@ type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc
99
122
  //#endregion
100
123
  //#region src/PromiseManager.d.ts
101
124
  type PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
102
- type Options<TState = any> = {
125
+ type Options<TState = unknown> = {
103
126
  nullCheck?: (state: TState) => boolean;
104
127
  };
105
- declare class PromiseManager<TState = any> {
128
+ declare class PromiseManager<TState = unknown> {
106
129
  #private;
107
130
  constructor(options?: Options<TState>);
108
131
  run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(strategy: TStrategy, promises: TInput, {
@@ -112,5 +135,112 @@ declare class PromiseManager<TState = any> {
112
135
  }): TOutput;
113
136
  }
114
137
  //#endregion
115
- export { BarrelType, BaseGenerator, type CLIOptions, Config, type FileMetaBase, GetPluginFactoryOptions, Group, InputData, InputPath, KubbEvents, LogLevel, Logger, LoggerContext, LoggerOptions, Output, PackageManager, type PackageManagerInfo, type PackageManagerName, Plugin, PluginContext, PluginFactoryOptions, PluginKey, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, PromiseManager, ResolveNameParams, ResolvePathParams, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, build, build as default, defineConfig, defineLogger, definePlugin, detectPackageManager, getBarrelFiles, getMode, isInputPath, safeBuild, setup };
138
+ //#region src/utils/FunctionParams.d.ts
139
+ type FunctionParamsASTWithoutType = {
140
+ name?: string;
141
+ type?: string;
142
+ /**
143
+ * @default true
144
+ */
145
+ required?: boolean;
146
+ /**
147
+ * @default true
148
+ */
149
+ enabled?: boolean;
150
+ default?: string;
151
+ };
152
+ type FunctionParamsASTWithType = {
153
+ name?: never;
154
+ type: string;
155
+ /**
156
+ * @default true
157
+ */
158
+ required?: boolean;
159
+ /**
160
+ * @default true
161
+ */
162
+ enabled?: boolean;
163
+ default?: string;
164
+ };
165
+ /**
166
+ * @deprecated
167
+ */
168
+ type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
169
+ /**
170
+ * @deprecated
171
+ */
172
+ declare class FunctionParams {
173
+ #private;
174
+ get items(): FunctionParamsAST[];
175
+ add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams;
176
+ static toObject(items: FunctionParamsAST[]): FunctionParamsAST;
177
+ toObject(): FunctionParamsAST;
178
+ static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string;
179
+ toString(): string;
180
+ }
181
+ //#endregion
182
+ //#region src/utils/formatters.d.ts
183
+ type Formatter = keyof typeof formatters;
184
+ /**
185
+ * Detect which formatter is available in the system.
186
+ *
187
+ * @returns Promise that resolves to the first available formatter or undefined if none are found
188
+ *
189
+ * @remarks
190
+ * Checks in order of preference: biome, oxfmt, prettier.
191
+ * Uses the `--version` flag to detect if each formatter command is available.
192
+ * This is a reliable method as all supported formatters implement this flag.
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const formatter = await detectFormatter()
197
+ * if (formatter) {
198
+ * console.log(`Using ${formatter} for formatting`)
199
+ * } else {
200
+ * console.log('No formatter found')
201
+ * }
202
+ * ```
203
+ */
204
+ declare function detectFormatter(): Promise<Formatter | undefined>;
205
+ //#endregion
206
+ //#region src/utils/getBarrelFiles.d.ts
207
+ type FileMetaBase = {
208
+ pluginKey?: Plugin['key'];
209
+ };
210
+ type AddIndexesProps = {
211
+ type: BarrelType | false | undefined;
212
+ /**
213
+ * Root based on root and output.path specified in the config
214
+ */
215
+ root: string;
216
+ /**
217
+ * Output for plugin
218
+ */
219
+ output: {
220
+ path: string;
221
+ };
222
+ group?: {
223
+ output: string;
224
+ exportAs: string;
225
+ };
226
+ meta?: FileMetaBase;
227
+ };
228
+ declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
229
+ type,
230
+ meta,
231
+ root,
232
+ output
233
+ }: AddIndexesProps): Promise<KubbFile.File[]>;
234
+ //#endregion
235
+ //#region src/utils/getConfigs.d.ts
236
+ /**
237
+ * Converting UserConfig to Config Array without a change in the object beside the JSON convert.
238
+ */
239
+ declare function getConfigs(config: ReturnType<typeof defineConfig> | UserConfig, args: CLIOptions): Promise<Array<Config>>;
240
+ //#endregion
241
+ //#region src/utils/linters.d.ts
242
+ type Linter = keyof typeof linters;
243
+ declare function detectLinter(): Promise<Linter | undefined>;
244
+ //#endregion
245
+ export { BarrelType, type CLIOptions, Config, type FileMetaBase, FunctionParams, type FunctionParamsAST, GetPluginFactoryOptions, Group, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, PackageManager, Plugin, PluginContext, PluginFactoryOptions, PluginKey, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, PromiseManager, ResolveNameParams, ResolvePathParams, UnknownUserPlugin, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, build, build as default, defineConfig, defineLogger, definePlugin, detectFormatter, detectLinter, formatters, getBarrelFiles, getConfigs, getMode, isInputPath, linters, logLevel, safeBuild, setup };
116
246
  //# sourceMappingURL=index.d.ts.map