@kubb/core 5.0.0-beta.1 → 5.0.0-beta.11
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/README.md +9 -39
- package/dist/{PluginDriver-BXibeQk-.cjs → PluginDriver-C1OsqGBJ.cjs} +106 -56
- package/dist/PluginDriver-C1OsqGBJ.cjs.map +1 -0
- package/dist/{PluginDriver-DV3p2Hky.js → PluginDriver-CGypdXHg.js} +101 -57
- package/dist/PluginDriver-CGypdXHg.js.map +1 -0
- package/dist/{types-CuNocrbJ.d.ts → createKubb-BSfMDBwR.d.ts} +1533 -1505
- package/dist/index.cjs +249 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -185
- package/dist/index.js +249 -209
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/mocks.js.map +1 -1
- package/package.json +5 -12
- package/src/FileManager.ts +8 -0
- package/src/FileProcessor.ts +12 -7
- package/src/PluginDriver.ts +49 -7
- package/src/constants.ts +6 -2
- package/src/createAdapter.ts +77 -1
- package/src/createKubb.ts +973 -141
- package/src/defineGenerator.ts +92 -4
- package/src/defineLogger.ts +42 -3
- package/src/defineMiddleware.ts +1 -1
- package/src/definePlugin.ts +304 -8
- package/src/defineResolver.ts +185 -52
- package/src/devtools.ts +8 -1
- package/src/index.ts +1 -1
- package/src/mocks.ts +1 -2
- package/src/storages/fsStorage.ts +6 -31
- package/src/types.ts +38 -1292
- package/dist/PluginDriver-BXibeQk-.cjs.map +0 -1
- package/dist/PluginDriver-DV3p2Hky.js.map +0 -1
- package/src/Kubb.ts +0 -300
- package/src/renderNode.ts +0 -35
- package/src/utils/diagnostics.ts +0 -18
- package/src/utils/isInputPath.ts +0 -10
- package/src/utils/packageJSON.ts +0 -99
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as ResolverPathParams, A as isInputPath, B as KubbPluginSetupContext, C as KubbPluginsEndContext, Ct as AsyncEventEmitter, D as PossibleConfig, E as KubbWarnContext, F as FileManager, G as Plugin, H as NormalizedPlugin, I as Exclude, J as ResolveBannerContext, K as PluginFactoryOptions, L as Group, M as GeneratorContext, N as defineGenerator, O as UserConfig, P as PluginDriver, Q as ResolverFileParams, R as Include, S as KubbLifecycleStartContext, St as logLevel, T as KubbVersionNewContext, U as Output, V as KubbPluginStartContext, W as Override, X as Resolver, Y as ResolveOptionsContext, Z as ResolverContext, _ as KubbGenerationSummaryContext, _t as createRenderer, a as InputPath, at as LoggerOptions, b as KubbHooks, bt as AdapterSource, c as KubbBuildStartContext, ct as FileProcessor, d as KubbErrorContext, dt as defineParser, et as defineResolver, f as KubbFileProcessingUpdateContext, ft as DevtoolsOptions, g as KubbGenerationStartContext, gt as RendererFactory, h as KubbGenerationEndContext, ht as Renderer, i as InputData, it as LoggerContext, j as Generator, k as createKubb, l as KubbConfigEndContext, lt as FileProcessorEvents, m as KubbFilesProcessingStartContext, mt as createStorage, n as CLIOptions, nt as defineMiddleware, o as Kubb, ot as UserLogger, p as KubbFilesProcessingEndContext, pt as Storage, q as definePlugin, r as Config, rt as Logger, s as KubbBuildEndContext, st as defineLogger, t as BuildOutput, tt as Middleware, u as KubbDebugContext, ut as Parser, v as KubbHookEndContext, vt as Adapter, w as KubbSuccessContext, x as KubbInfoContext, xt as createAdapter, y as KubbHookStartContext, yt as AdapterFactoryOptions, z as KubbPluginEndContext } from "./createKubb-BSfMDBwR.js";
|
|
3
3
|
import * as ast from "@kubb/ast";
|
|
4
|
-
import { FileNode, InputNode, Node } from "@kubb/ast";
|
|
5
4
|
|
|
6
5
|
//#region ../../internals/utils/src/urlPath.d.ts
|
|
7
6
|
type URLObject = {
|
|
@@ -139,181 +138,6 @@ declare class URLPath {
|
|
|
139
138
|
toURLPath(): string;
|
|
140
139
|
}
|
|
141
140
|
//#endregion
|
|
142
|
-
//#region src/createAdapter.d.ts
|
|
143
|
-
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
|
|
144
|
-
/**
|
|
145
|
-
* Factory for implementing custom adapters that translate non-OpenAPI specs into Kubb's AST.
|
|
146
|
-
*
|
|
147
|
-
* Use this to support GraphQL schemas, gRPC definitions, AsyncAPI, or custom domain-specific languages.
|
|
148
|
-
* Built-in adapters include `@kubb/adapter-oas` for OpenAPI and Swagger documents.
|
|
149
|
-
*
|
|
150
|
-
* @note Adapters must parse their input format to Kubb's `InputNode` structure.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```ts
|
|
154
|
-
* export const myAdapter = createAdapter<MyAdapter>((options) => {
|
|
155
|
-
* return {
|
|
156
|
-
* name: 'my-adapter',
|
|
157
|
-
* options,
|
|
158
|
-
* async parse(source) {
|
|
159
|
-
* // Transform source format to InputNode
|
|
160
|
-
* return { ... }
|
|
161
|
-
* },
|
|
162
|
-
* }
|
|
163
|
-
* })
|
|
164
|
-
*
|
|
165
|
-
* // Instantiate:
|
|
166
|
-
* const adapter = myAdapter({ validate: true })
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/defineLogger.d.ts
|
|
172
|
-
/**
|
|
173
|
-
* Wraps a logger definition into a typed {@link Logger}.
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```ts
|
|
177
|
-
* export const myLogger = defineLogger({
|
|
178
|
-
* name: 'my-logger',
|
|
179
|
-
* install(context, options) {
|
|
180
|
-
* context.on('kubb:info', (message) => console.log('ℹ', message))
|
|
181
|
-
* context.on('kubb:error', (error) => console.error('✗', error.message))
|
|
182
|
-
* },
|
|
183
|
-
* })
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region src/defineResolver.d.ts
|
|
189
|
-
/**
|
|
190
|
-
* Builder type for the plugin-specific resolver fields.
|
|
191
|
-
*
|
|
192
|
-
* `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
|
|
193
|
-
* are optional — built-in fallbacks are injected when omitted.
|
|
194
|
-
*
|
|
195
|
-
* The builder receives `ctx` — a reference to the fully assembled resolver — so methods can
|
|
196
|
-
* call sibling resolver methods without using `this`. Because `ctx` is captured by the closure
|
|
197
|
-
* and the resolver is populated after the builder runs, `ctx` correctly reflects any overrides
|
|
198
|
-
* that were applied by the builder itself.
|
|
199
|
-
*/
|
|
200
|
-
type ResolverBuilder<T extends PluginFactoryOptions> = (ctx: T['resolver']) => Omit<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter' | 'name' | 'pluginName'> & Partial<Pick<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>> & {
|
|
201
|
-
name: string;
|
|
202
|
-
pluginName: T['name'];
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Default option resolver — applies include/exclude filters and merges matching override options.
|
|
206
|
-
*
|
|
207
|
-
* Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.
|
|
208
|
-
*
|
|
209
|
-
* @example Include/exclude filtering
|
|
210
|
-
* ```ts
|
|
211
|
-
* const options = defaultResolveOptions(operationNode, {
|
|
212
|
-
* options: { output: 'types' },
|
|
213
|
-
* exclude: [{ type: 'tag', pattern: 'internal' }],
|
|
214
|
-
* })
|
|
215
|
-
* // → null when node has tag 'internal'
|
|
216
|
-
* ```
|
|
217
|
-
*
|
|
218
|
-
* @example Override merging
|
|
219
|
-
* ```ts
|
|
220
|
-
* const options = defaultResolveOptions(operationNode, {
|
|
221
|
-
* options: { enumType: 'asConst' },
|
|
222
|
-
* override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],
|
|
223
|
-
* })
|
|
224
|
-
* // → { enumType: 'enum' } when operationId matches
|
|
225
|
-
* ```
|
|
226
|
-
*/
|
|
227
|
-
/**
|
|
228
|
-
* Defines a resolver for a plugin, injecting built-in defaults for name casing,
|
|
229
|
-
* include/exclude/override filtering, path resolution, and file construction.
|
|
230
|
-
*
|
|
231
|
-
* All four defaults can be overridden by providing them in the builder function:
|
|
232
|
-
* - `default` — name casing strategy (camelCase / PascalCase)
|
|
233
|
-
* - `resolveOptions` — include/exclude/override filtering
|
|
234
|
-
* - `resolvePath` — output path computation
|
|
235
|
-
* - `resolveFile` — full `FileNode` construction
|
|
236
|
-
*
|
|
237
|
-
* The builder receives `ctx` — a reference to the assembled resolver — so methods can
|
|
238
|
-
* call sibling resolver methods using `ctx` instead of `this`.
|
|
239
|
-
*
|
|
240
|
-
* @example Basic resolver with naming helpers
|
|
241
|
-
* ```ts
|
|
242
|
-
* export const resolver = defineResolver<PluginTs>((ctx) => ({
|
|
243
|
-
* name: 'default',
|
|
244
|
-
* resolveName(node) {
|
|
245
|
-
* return ctx.default(node.name, 'function')
|
|
246
|
-
* },
|
|
247
|
-
* resolveTypedName(node) {
|
|
248
|
-
* return ctx.default(node.name, 'type')
|
|
249
|
-
* },
|
|
250
|
-
* }))
|
|
251
|
-
* ```
|
|
252
|
-
*
|
|
253
|
-
* @example Override resolvePath for a custom output structure
|
|
254
|
-
* ```ts
|
|
255
|
-
* export const resolver = defineResolver<PluginTs>((_ctx) => ({
|
|
256
|
-
* name: 'custom',
|
|
257
|
-
* resolvePath({ baseName }, { root, output }) {
|
|
258
|
-
* return path.resolve(root, output.path, 'generated', baseName)
|
|
259
|
-
* },
|
|
260
|
-
* }))
|
|
261
|
-
* ```
|
|
262
|
-
*
|
|
263
|
-
* @example Use ctx.default inside a helper
|
|
264
|
-
* ```ts
|
|
265
|
-
* export const resolver = defineResolver<PluginTs>((ctx) => ({
|
|
266
|
-
* name: 'default',
|
|
267
|
-
* resolveParamName(node, param) {
|
|
268
|
-
* return ctx.default(`${node.operationId} ${param.in} ${param.name}`, 'type')
|
|
269
|
-
* },
|
|
270
|
-
* }))
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/FileProcessor.d.ts
|
|
276
|
-
type ParseOptions = {
|
|
277
|
-
parsers?: Map<FileNode['extname'], Parser>;
|
|
278
|
-
extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
|
|
279
|
-
};
|
|
280
|
-
type RunOptions = ParseOptions & {
|
|
281
|
-
/**
|
|
282
|
-
* @default 'sequential'
|
|
283
|
-
*/
|
|
284
|
-
mode?: 'sequential' | 'parallel';
|
|
285
|
-
onStart?: (files: Array<FileNode>) => Promise<void> | void;
|
|
286
|
-
onEnd?: (files: Array<FileNode>) => Promise<void> | void;
|
|
287
|
-
onUpdate?: (params: {
|
|
288
|
-
file: FileNode;
|
|
289
|
-
source?: string;
|
|
290
|
-
processed: number;
|
|
291
|
-
total: number;
|
|
292
|
-
percentage: number;
|
|
293
|
-
}) => Promise<void> | void;
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* Converts a single file to a string using the registered parsers.
|
|
297
|
-
* Falls back to joining source values when no matching parser is found.
|
|
298
|
-
*
|
|
299
|
-
* @internal
|
|
300
|
-
*/
|
|
301
|
-
declare class FileProcessor {
|
|
302
|
-
#private;
|
|
303
|
-
parse(file: FileNode, {
|
|
304
|
-
parsers,
|
|
305
|
-
extension
|
|
306
|
-
}?: ParseOptions): Promise<string>;
|
|
307
|
-
run(files: Array<FileNode>, {
|
|
308
|
-
parsers,
|
|
309
|
-
mode,
|
|
310
|
-
extension,
|
|
311
|
-
onStart,
|
|
312
|
-
onEnd,
|
|
313
|
-
onUpdate
|
|
314
|
-
}?: RunOptions): Promise<Array<FileNode>>;
|
|
315
|
-
}
|
|
316
|
-
//#endregion
|
|
317
141
|
//#region src/storages/fsStorage.d.ts
|
|
318
142
|
/**
|
|
319
143
|
* Built-in filesystem storage driver.
|
|
@@ -364,12 +188,5 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
|
|
|
364
188
|
*/
|
|
365
189
|
declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
|
|
366
190
|
//#endregion
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Type guard to check if a given config has an `input.path`.
|
|
370
|
-
*/
|
|
371
|
-
declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
|
|
372
|
-
declare function isInputPath(config: Config | undefined): config is Config<InputPath>;
|
|
373
|
-
//#endregion
|
|
374
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BuildOutput, CLIOptions, Config, DevtoolsOptions, Exclude, FileManager, FileProcessor, Generator, GeneratorContext, Group, Include, InputData, InputPath, Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbConfigEndContext, KubbDebugContext, KubbErrorContext, KubbFileProcessingUpdateContext, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbVersionNewContext, KubbWarnContext, Logger, LoggerContext, LoggerOptions, Middleware, NormalizedPlugin, Output, Override, Parser, Plugin, PluginDriver, PluginFactoryOptions, PossibleConfig, Renderer, RendererFactory, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, URLPath, UserConfig, UserLogger, ast, createAdapter, createKubb, createRenderer, createStorage, defineGenerator, defineLogger, defineMiddleware, defineParser, definePlugin, defineResolver, fsStorage, isInputPath, logLevel, memoryStorage };
|
|
191
|
+
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BuildOutput, CLIOptions, Config, DevtoolsOptions, Exclude, FileManager, FileProcessor, FileProcessorEvents, Generator, GeneratorContext, Group, Include, InputData, InputPath, Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbConfigEndContext, KubbDebugContext, KubbErrorContext, KubbFileProcessingUpdateContext, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbVersionNewContext, KubbWarnContext, Logger, LoggerContext, LoggerOptions, Middleware, NormalizedPlugin, Output, Override, Parser, Plugin, PluginDriver, PluginFactoryOptions, PossibleConfig, Renderer, RendererFactory, ResolveBannerContext, ResolveOptionsContext, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, URLPath, UserConfig, UserLogger, ast, createAdapter, createKubb, createRenderer, createStorage, defineGenerator, defineLogger, defineMiddleware, defineParser, definePlugin, defineResolver, fsStorage, isInputPath, logLevel, memoryStorage };
|
|
375
192
|
//# sourceMappingURL=index.d.ts.map
|