@kubb/core 5.0.0-alpha.8 → 5.0.0-beta.75
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 +23 -20
- package/dist/PluginDriver-BXibeQk-.cjs +1036 -0
- package/dist/PluginDriver-BXibeQk-.cjs.map +1 -0
- package/dist/PluginDriver-DV3p2Hky.js +945 -0
- package/dist/PluginDriver-DV3p2Hky.js.map +1 -0
- package/dist/index.cjs +756 -1693
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +297 -239
- package/dist/index.js +743 -1661
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +145 -0
- package/dist/mocks.cjs.map +1 -0
- package/dist/mocks.d.ts +80 -0
- package/dist/mocks.js +140 -0
- package/dist/mocks.js.map +1 -0
- package/dist/types-CuNocrbJ.d.ts +2148 -0
- package/package.json +51 -57
- package/src/FileManager.ts +115 -0
- package/src/FileProcessor.ts +86 -0
- package/src/Kubb.ts +208 -160
- package/src/PluginDriver.ts +326 -565
- package/src/constants.ts +20 -47
- package/src/createAdapter.ts +16 -6
- package/src/createKubb.ts +548 -0
- package/src/createRenderer.ts +57 -0
- package/src/createStorage.ts +40 -26
- package/src/defineGenerator.ts +87 -0
- package/src/defineLogger.ts +19 -0
- package/src/defineMiddleware.ts +62 -0
- package/src/defineParser.ts +44 -0
- package/src/definePlugin.ts +83 -0
- package/src/defineResolver.ts +521 -0
- package/src/devtools.ts +14 -14
- package/src/index.ts +14 -17
- package/src/mocks.ts +178 -0
- package/src/renderNode.ts +35 -0
- package/src/storages/fsStorage.ts +41 -11
- package/src/storages/memoryStorage.ts +4 -2
- package/src/types.ts +1054 -270
- package/src/utils/diagnostics.ts +4 -1
- package/src/utils/isInputPath.ts +10 -0
- package/src/utils/packageJSON.ts +99 -0
- package/dist/PluginDriver-DRfJIbG1.d.ts +0 -1056
- package/dist/chunk-ByKO4r7w.cjs +0 -38
- package/dist/hooks.cjs +0 -102
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.d.ts +0 -75
- package/dist/hooks.js +0 -97
- package/dist/hooks.js.map +0 -1
- package/src/PackageManager.ts +0 -180
- package/src/build.ts +0 -419
- package/src/config.ts +0 -56
- package/src/createGenerator.ts +0 -106
- package/src/createLogger.ts +0 -7
- package/src/createPlugin.ts +0 -12
- package/src/errors.ts +0 -1
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useKubb.ts +0 -138
- package/src/hooks/useMode.ts +0 -11
- package/src/hooks/usePlugin.ts +0 -11
- package/src/hooks/usePluginDriver.ts +0 -11
- package/src/utils/FunctionParams.ts +0 -155
- package/src/utils/TreeNode.ts +0 -215
- package/src/utils/executeStrategies.ts +0 -81
- package/src/utils/formatters.ts +0 -56
- package/src/utils/getBarrelFiles.ts +0 -141
- package/src/utils/getConfigs.ts +0 -30
- package/src/utils/getPlugins.ts +0 -23
- package/src/utils/linters.ts +0 -25
- package/src/utils/resolveOptions.ts +0 -93
package/dist/index.d.ts
CHANGED
|
@@ -1,135 +1,324 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { A as
|
|
3
|
-
import
|
|
4
|
-
import { Node } from "@kubb/ast
|
|
5
|
-
import { Fabric, KubbFile } from "@kubb/fabric-core/types";
|
|
2
|
+
import { $ as defineParser, A as KubbPluginStartContext, B as Override, C as KubbGenerationSummaryContext, D as KubbLifecycleStartContext, E as KubbInfoContext, F as Logger, G as ResolveOptionsContext, H as PossibleConfig, I as LoggerContext, J as ResolverFileParams, K as Resolver, L as LoggerOptions, M as KubbSuccessContext, N as KubbVersionNewContext, O as KubbPluginEndContext, P as KubbWarnContext, Q as Parser, R as NormalizedPlugin, S as KubbGenerationStartContext, T as KubbHookStartContext, U as ResolveBannerContext, V as PluginFactoryOptions, W as ResolveNameParams, X as UserConfig, Y as ResolverPathParams, Z as UserLogger, _ as KubbErrorContext, _t as logLevel, a as Config, at as createKubb, b as KubbFilesProcessingStartContext, c as GeneratorContext, ct as Plugin, d as InputData, dt as defineGenerator, et as Middleware, f as InputPath, ft as Storage, g as KubbDebugContext, gt as createRenderer, h as KubbConfigEndContext, ht as RendererFactory, i as CLIOptions, it as BuildOutput, j as KubbPluginsEndContext, k as KubbPluginSetupContext, l as Group, lt as definePlugin, m as KubbBuildStartContext, mt as Renderer, n as AdapterFactoryOptions, nt as Kubb, o as DevtoolsOptions, ot as PluginDriver, p as KubbBuildEndContext, pt as createStorage, q as ResolverContext, r as AdapterSource, rt as KubbHooks, s as Exclude, st as FileManager, t as Adapter, tt as defineMiddleware, u as Include, ut as Generator, v as KubbFileProcessingUpdateContext, vt as AsyncEventEmitter, w as KubbHookEndContext, x as KubbGenerationEndContext, y as KubbFilesProcessingEndContext, z as Output } from "./types-CuNocrbJ.js";
|
|
3
|
+
import * as ast from "@kubb/ast";
|
|
4
|
+
import { FileNode, InputNode, Node } from "@kubb/ast";
|
|
6
5
|
|
|
7
|
-
//#region src/
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
fabric: Fabric;
|
|
18
|
-
files: Array<KubbFile.ResolvedFile>;
|
|
19
|
-
driver: PluginDriver;
|
|
20
|
-
pluginTimings: Map<string, number>;
|
|
21
|
-
error?: Error;
|
|
22
|
-
sources: Map<KubbFile.Path, string>;
|
|
6
|
+
//#region ../../internals/utils/src/urlPath.d.ts
|
|
7
|
+
type URLObject = {
|
|
8
|
+
/**
|
|
9
|
+
* The resolved URL string (Express-style or template literal, depending on context).
|
|
10
|
+
*/
|
|
11
|
+
url: string;
|
|
12
|
+
/**
|
|
13
|
+
* Extracted path parameters as a key-value map, or `undefined` when the path has none.
|
|
14
|
+
*/
|
|
15
|
+
params?: Record<string, string>;
|
|
23
16
|
};
|
|
24
|
-
type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
type ObjectOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Controls whether the `url` is rendered as an Express path or a template literal.
|
|
20
|
+
* @default 'path'
|
|
21
|
+
*/
|
|
22
|
+
type?: 'path' | 'template';
|
|
23
|
+
/**
|
|
24
|
+
* Optional transform applied to each extracted parameter name.
|
|
25
|
+
*/
|
|
26
|
+
replacer?: (pathParam: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* When `true`, the result is serialized to a string expression instead of a plain object.
|
|
29
|
+
*/
|
|
30
|
+
stringify?: boolean;
|
|
29
31
|
};
|
|
30
|
-
declare function setup(options: BuildOptions): Promise<SetupResult>;
|
|
31
|
-
declare function build(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
|
|
32
|
-
declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/config.d.ts
|
|
35
32
|
/**
|
|
36
|
-
*
|
|
33
|
+
* Supported identifier casing strategies for path parameters.
|
|
37
34
|
*/
|
|
38
|
-
type
|
|
39
|
-
|
|
40
|
-
watch?: boolean;
|
|
35
|
+
type PathCasing = 'camelcase';
|
|
36
|
+
type Options = {
|
|
41
37
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* - `silent`: hide non-essential logs
|
|
45
|
-
* - `info`: show general logs (non-plugin-related)
|
|
46
|
-
* - `debug`: include detailed plugin lifecycle logs
|
|
47
|
-
* @default 'silent'
|
|
38
|
+
* Casing strategy applied to path parameter names.
|
|
39
|
+
* @default undefined (original identifier preserved)
|
|
48
40
|
*/
|
|
49
|
-
|
|
50
|
-
bun?: boolean;
|
|
41
|
+
casing?: PathCasing;
|
|
51
42
|
};
|
|
52
|
-
/** All accepted forms of a Kubb configuration. */
|
|
53
|
-
type ConfigInput = PossiblePromise<UserConfig | UserConfig[]> | ((cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>);
|
|
54
43
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* Accepts either:
|
|
58
|
-
* - A config object or array of configs
|
|
59
|
-
* - A function returning the config(s), optionally async,
|
|
60
|
-
* receiving the CLI options as argument
|
|
44
|
+
* Parses and transforms an OpenAPI/Swagger path string into various URL formats.
|
|
61
45
|
*
|
|
62
46
|
* @example
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* }))
|
|
67
|
-
*/
|
|
68
|
-
declare function defineConfig(config: (cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>): typeof config;
|
|
69
|
-
declare function defineConfig(config: PossiblePromise<UserConfig | UserConfig[]>): typeof config;
|
|
70
|
-
/**
|
|
71
|
-
* Type guard to check if a given config has an `input.path`.
|
|
47
|
+
* const p = new URLPath('/pet/{petId}')
|
|
48
|
+
* p.URL // '/pet/:petId'
|
|
49
|
+
* p.template // '`/pet/${petId}`'
|
|
72
50
|
*/
|
|
73
|
-
declare
|
|
51
|
+
declare class URLPath {
|
|
52
|
+
#private;
|
|
53
|
+
/**
|
|
54
|
+
* The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
|
|
55
|
+
*/
|
|
56
|
+
path: string;
|
|
57
|
+
constructor(path: string, options?: Options);
|
|
58
|
+
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* new URLPath('/pet/{petId}').URL // '/pet/:petId'
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
get URL(): string;
|
|
66
|
+
/** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
|
|
71
|
+
* new URLPath('/pet/{petId}').isURL // false
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
get isURL(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
|
|
80
|
+
* new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
|
|
81
|
+
*/
|
|
82
|
+
get template(): string;
|
|
83
|
+
/** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* new URLPath('/pet/{petId}').object
|
|
88
|
+
* // { url: '/pet/:petId', params: { petId: 'petId' } }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
get object(): URLObject | string;
|
|
92
|
+
/** Returns a map of path parameter names, or `undefined` when the path has no parameters.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* new URLPath('/pet/{petId}').params // { petId: 'petId' }
|
|
97
|
+
* new URLPath('/pet').params // undefined
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
get params(): Record<string, string> | undefined;
|
|
101
|
+
toObject({
|
|
102
|
+
type,
|
|
103
|
+
replacer,
|
|
104
|
+
stringify
|
|
105
|
+
}?: ObjectOptions): URLObject | string;
|
|
106
|
+
/**
|
|
107
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
108
|
+
* An optional `replacer` can transform each extracted parameter name before interpolation.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
|
|
112
|
+
*/
|
|
113
|
+
toTemplateString({
|
|
114
|
+
prefix,
|
|
115
|
+
replacer
|
|
116
|
+
}?: {
|
|
117
|
+
prefix?: string;
|
|
118
|
+
replacer?: (pathParam: string) => string;
|
|
119
|
+
}): string;
|
|
120
|
+
/**
|
|
121
|
+
* Extracts all `{param}` segments from the path and returns them as a key-value map.
|
|
122
|
+
* An optional `replacer` transforms each parameter name in both key and value positions.
|
|
123
|
+
* Returns `undefined` when no path parameters are found.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* new URLPath('/pet/{petId}/tag/{tagId}').getParams()
|
|
128
|
+
* // { petId: 'petId', tagId: 'tagId' }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
132
|
+
/** Converts the OpenAPI path to Express-style colon syntax.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
toURLPath(): string;
|
|
140
|
+
}
|
|
74
141
|
//#endregion
|
|
75
142
|
//#region src/createAdapter.d.ts
|
|
76
143
|
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
|
|
77
144
|
/**
|
|
78
|
-
*
|
|
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.
|
|
79
151
|
*
|
|
80
152
|
* @example
|
|
81
153
|
* ```ts
|
|
82
|
-
* export const
|
|
83
|
-
* const { validate = true, dateType = 'string' } = options
|
|
154
|
+
* export const myAdapter = createAdapter<MyAdapter>((options) => {
|
|
84
155
|
* return {
|
|
85
|
-
* name:
|
|
86
|
-
* options
|
|
87
|
-
* parse(source) {
|
|
156
|
+
* name: 'my-adapter',
|
|
157
|
+
* options,
|
|
158
|
+
* async parse(source) {
|
|
159
|
+
* // Transform source format to InputNode
|
|
160
|
+
* return { ... }
|
|
161
|
+
* },
|
|
88
162
|
* }
|
|
89
163
|
* })
|
|
164
|
+
*
|
|
165
|
+
* // Instantiate:
|
|
166
|
+
* const adapter = myAdapter({ validate: true })
|
|
90
167
|
* ```
|
|
91
168
|
*/
|
|
92
169
|
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
|
|
93
170
|
//#endregion
|
|
94
|
-
//#region src/
|
|
95
|
-
|
|
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>;
|
|
96
187
|
//#endregion
|
|
97
|
-
//#region src/
|
|
98
|
-
|
|
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
|
+
};
|
|
99
204
|
/**
|
|
100
|
-
*
|
|
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
|
+
* ```
|
|
101
226
|
*/
|
|
102
|
-
|
|
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'];
|
|
103
274
|
//#endregion
|
|
104
|
-
//#region src/
|
|
105
|
-
type
|
|
106
|
-
|
|
107
|
-
|
|
275
|
+
//#region src/FileProcessor.d.ts
|
|
276
|
+
type ParseOptions = {
|
|
277
|
+
parsers?: Map<FileNode['extname'], Parser>;
|
|
278
|
+
extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
|
|
108
279
|
};
|
|
109
|
-
type
|
|
110
|
-
|
|
111
|
-
|
|
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 {
|
|
112
302
|
#private;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean;
|
|
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>>;
|
|
126
315
|
}
|
|
127
316
|
//#endregion
|
|
128
317
|
//#region src/storages/fsStorage.d.ts
|
|
129
318
|
/**
|
|
130
319
|
* Built-in filesystem storage driver.
|
|
131
320
|
*
|
|
132
|
-
* This is the default storage when no `storage` option is configured in
|
|
321
|
+
* This is the default storage when no `storage` option is configured in the root config.
|
|
133
322
|
* Keys are resolved against `process.cwd()`, so root-relative paths such as
|
|
134
323
|
* `src/gen/api/getPets.ts` are written to the correct location without extra configuration.
|
|
135
324
|
*
|
|
@@ -141,15 +330,17 @@ declare class PackageManager {
|
|
|
141
330
|
*
|
|
142
331
|
* @example
|
|
143
332
|
* ```ts
|
|
144
|
-
* import {
|
|
333
|
+
* import { fsStorage } from '@kubb/core'
|
|
334
|
+
* import { defineConfig } from 'kubb'
|
|
145
335
|
*
|
|
146
336
|
* export default defineConfig({
|
|
147
337
|
* input: { path: './petStore.yaml' },
|
|
148
|
-
* output: { path: './src/gen'
|
|
338
|
+
* output: { path: './src/gen' },
|
|
339
|
+
* storage: fsStorage(),
|
|
149
340
|
* })
|
|
150
341
|
* ```
|
|
151
342
|
*/
|
|
152
|
-
declare const fsStorage: (options?: Record<string, never> | undefined) =>
|
|
343
|
+
declare const fsStorage: (options?: Record<string, never> | undefined) => Storage;
|
|
153
344
|
//#endregion
|
|
154
345
|
//#region src/storages/memoryStorage.d.ts
|
|
155
346
|
/**
|
|
@@ -161,157 +352,24 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Define
|
|
|
161
352
|
*
|
|
162
353
|
* @example
|
|
163
354
|
* ```ts
|
|
164
|
-
* import {
|
|
355
|
+
* import { memoryStorage } from '@kubb/core'
|
|
356
|
+
* import { defineConfig } from 'kubb'
|
|
165
357
|
*
|
|
166
358
|
* export default defineConfig({
|
|
167
359
|
* input: { path: './petStore.yaml' },
|
|
168
|
-
* output: { path: './src/gen'
|
|
360
|
+
* output: { path: './src/gen' },
|
|
361
|
+
* storage: memoryStorage(),
|
|
169
362
|
* })
|
|
170
363
|
* ```
|
|
171
364
|
*/
|
|
172
|
-
declare const memoryStorage: (options?: Record<string, never> | undefined) =>
|
|
173
|
-
//#endregion
|
|
174
|
-
//#region src/utils/FunctionParams.d.ts
|
|
175
|
-
type FunctionParamsASTWithoutType = {
|
|
176
|
-
name?: string;
|
|
177
|
-
type?: string;
|
|
178
|
-
/**
|
|
179
|
-
* @default true
|
|
180
|
-
*/
|
|
181
|
-
required?: boolean;
|
|
182
|
-
/**
|
|
183
|
-
* @default true
|
|
184
|
-
*/
|
|
185
|
-
enabled?: boolean;
|
|
186
|
-
default?: string;
|
|
187
|
-
};
|
|
188
|
-
type FunctionParamsASTWithType = {
|
|
189
|
-
name?: never;
|
|
190
|
-
type: string;
|
|
191
|
-
/**
|
|
192
|
-
* @default true
|
|
193
|
-
*/
|
|
194
|
-
required?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* @default true
|
|
197
|
-
*/
|
|
198
|
-
enabled?: boolean;
|
|
199
|
-
default?: string;
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* @deprecated
|
|
203
|
-
*/
|
|
204
|
-
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
205
|
-
/**
|
|
206
|
-
* @deprecated
|
|
207
|
-
*/
|
|
208
|
-
declare class FunctionParams {
|
|
209
|
-
#private;
|
|
210
|
-
get items(): FunctionParamsAST[];
|
|
211
|
-
add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams;
|
|
212
|
-
static toObject(items: FunctionParamsAST[]): FunctionParamsAST;
|
|
213
|
-
toObject(): FunctionParamsAST;
|
|
214
|
-
static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string;
|
|
215
|
-
toString(): string;
|
|
216
|
-
}
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/utils/formatters.d.ts
|
|
219
|
-
type Formatter = keyof typeof formatters;
|
|
220
|
-
/**
|
|
221
|
-
* Detect which formatter is available in the system.
|
|
222
|
-
*
|
|
223
|
-
* @returns Promise that resolves to the first available formatter or undefined if none are found
|
|
224
|
-
*
|
|
225
|
-
* @remarks
|
|
226
|
-
* Checks in order of preference: biome, oxfmt, prettier.
|
|
227
|
-
* Uses the `--version` flag to detect if each formatter command is available.
|
|
228
|
-
* This is a reliable method as all supported formatters implement this flag.
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```typescript
|
|
232
|
-
* const formatter = await detectFormatter()
|
|
233
|
-
* if (formatter) {
|
|
234
|
-
* console.log(`Using ${formatter} for formatting`)
|
|
235
|
-
* } else {
|
|
236
|
-
* console.log('No formatter found')
|
|
237
|
-
* }
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
declare function detectFormatter(): Promise<Formatter | undefined>;
|
|
365
|
+
declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
|
|
241
366
|
//#endregion
|
|
242
|
-
//#region src/utils/
|
|
243
|
-
type FileMetaBase = {
|
|
244
|
-
pluginName?: string;
|
|
245
|
-
};
|
|
246
|
-
type AddIndexesProps = {
|
|
247
|
-
type: BarrelType | false | undefined;
|
|
248
|
-
/**
|
|
249
|
-
* Root based on root and output.path specified in the config
|
|
250
|
-
*/
|
|
251
|
-
root: string;
|
|
252
|
-
/**
|
|
253
|
-
* Output for plugin
|
|
254
|
-
*/
|
|
255
|
-
output: {
|
|
256
|
-
path: string;
|
|
257
|
-
};
|
|
258
|
-
group?: {
|
|
259
|
-
output: string;
|
|
260
|
-
exportAs: string;
|
|
261
|
-
};
|
|
262
|
-
meta?: FileMetaBase;
|
|
263
|
-
};
|
|
264
|
-
declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
|
|
265
|
-
type,
|
|
266
|
-
meta,
|
|
267
|
-
root,
|
|
268
|
-
output
|
|
269
|
-
}: AddIndexesProps): Promise<Array<KubbFile.File>>;
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region src/utils/getConfigs.d.ts
|
|
272
|
-
/**
|
|
273
|
-
* Converting UserConfig to Config Array without a change in the object beside the JSON convert.
|
|
274
|
-
*/
|
|
275
|
-
declare function getConfigs(config: ConfigInput | UserConfig, args: CLIOptions): Promise<Array<Config>>;
|
|
276
|
-
//#endregion
|
|
277
|
-
//#region src/utils/linters.d.ts
|
|
278
|
-
type Linter = keyof typeof linters;
|
|
279
|
-
declare function detectLinter(): Promise<Linter | undefined>;
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/utils/resolveOptions.d.ts
|
|
282
|
-
type FilterItem = {
|
|
283
|
-
type: string;
|
|
284
|
-
pattern: string | RegExp;
|
|
285
|
-
};
|
|
286
|
-
type OverrideItem<TOptions> = FilterItem & {
|
|
287
|
-
options: Omit<Partial<TOptions>, 'override'>;
|
|
288
|
-
};
|
|
289
|
-
type ResolveOptionsContext<TOptions> = {
|
|
290
|
-
options: TOptions;
|
|
291
|
-
exclude?: Array<FilterItem>;
|
|
292
|
-
include?: Array<FilterItem>;
|
|
293
|
-
override?: Array<OverrideItem<TOptions>>;
|
|
294
|
-
};
|
|
367
|
+
//#region src/utils/isInputPath.d.ts
|
|
295
368
|
/**
|
|
296
|
-
*
|
|
297
|
-
* `exclude`, `include`, and `override` rules from the plugin configuration.
|
|
298
|
-
*
|
|
299
|
-
* Returns `null` when the node is excluded or not matched by `include`.
|
|
300
|
-
* Returns the merged options (base options merged with any matching `override`) otherwise.
|
|
301
|
-
*
|
|
302
|
-
* Supported filter types for `OperationNode`: `tag`, `operationId`, `path`, `method`.
|
|
303
|
-
* Supported filter types for `SchemaNode`: `schemaName`.
|
|
304
|
-
*
|
|
305
|
-
* @example
|
|
306
|
-
* const resolved = resolveOptions(operationNode, { options, exclude, include, override })
|
|
307
|
-
* if (!resolved) return // excluded
|
|
369
|
+
* Type guard to check if a given config has an `input.path`.
|
|
308
370
|
*/
|
|
309
|
-
declare function
|
|
310
|
-
|
|
311
|
-
exclude,
|
|
312
|
-
include,
|
|
313
|
-
override
|
|
314
|
-
}: ResolveOptionsContext<TOptions>): TOptions | null;
|
|
371
|
+
declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
|
|
372
|
+
declare function isInputPath(config: Config | undefined): config is Config<InputPath>;
|
|
315
373
|
//#endregion
|
|
316
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter,
|
|
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 };
|
|
317
375
|
//# sourceMappingURL=index.d.ts.map
|