@kubb/core 5.0.0-alpha.5 → 5.0.0-alpha.50
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 +3 -2
- package/dist/PluginDriver-DtwggkXg.cjs +1082 -0
- package/dist/PluginDriver-DtwggkXg.cjs.map +1 -0
- package/dist/PluginDriver-mXeqWp-U.js +979 -0
- package/dist/PluginDriver-mXeqWp-U.js.map +1 -0
- package/dist/index.cjs +1013 -1829
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +274 -265
- package/dist/index.js +1003 -1799
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +138 -0
- package/dist/mocks.cjs.map +1 -0
- package/dist/mocks.d.ts +74 -0
- package/dist/mocks.js +133 -0
- package/dist/mocks.js.map +1 -0
- package/dist/types-DfEv9d_c.d.ts +1721 -0
- package/package.json +51 -57
- package/src/FileManager.ts +133 -0
- package/src/FileProcessor.ts +86 -0
- package/src/Kubb.ts +154 -101
- package/src/PluginDriver.ts +418 -0
- package/src/constants.ts +43 -47
- package/src/createAdapter.ts +25 -0
- package/src/createKubb.ts +614 -0
- package/src/createRenderer.ts +57 -0
- package/src/createStorage.ts +58 -0
- package/src/defineGenerator.ts +88 -100
- package/src/defineLogger.ts +13 -3
- package/src/defineParser.ts +45 -0
- package/src/definePlugin.ts +68 -7
- package/src/defineResolver.ts +501 -0
- package/src/devtools.ts +14 -14
- package/src/index.ts +12 -17
- package/src/mocks.ts +171 -0
- package/src/renderNode.ts +35 -0
- package/src/storages/fsStorage.ts +40 -11
- package/src/storages/memoryStorage.ts +4 -3
- package/src/types.ts +575 -205
- package/src/utils/TreeNode.ts +47 -9
- package/src/utils/diagnostics.ts +4 -1
- package/src/utils/getBarrelFiles.ts +94 -16
- package/src/utils/isInputPath.ts +10 -0
- package/src/utils/packageJSON.ts +99 -0
- package/dist/PluginManager-vZodFEMe.d.ts +0 -1056
- package/dist/chunk-ByKO4r7w.cjs +0 -38
- package/dist/hooks.cjs +0 -60
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.d.ts +0 -56
- package/dist/hooks.js +0 -56
- package/dist/hooks.js.map +0 -1
- package/src/BarrelManager.ts +0 -74
- package/src/PackageManager.ts +0 -180
- package/src/PluginManager.ts +0 -667
- package/src/PromiseManager.ts +0 -40
- package/src/build.ts +0 -419
- package/src/config.ts +0 -56
- package/src/defineAdapter.ts +0 -22
- package/src/defineStorage.ts +0 -56
- package/src/errors.ts +0 -1
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useKubb.ts +0 -46
- package/src/hooks/useMode.ts +0 -11
- package/src/hooks/usePlugin.ts +0 -11
- package/src/hooks/usePluginManager.ts +0 -11
- package/src/utils/FunctionParams.ts +0 -155
- package/src/utils/executeStrategies.ts +0 -81
- package/src/utils/formatters.ts +0 -56
- 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,161 +1,303 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { A as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { Node } from "@kubb/ast/types";
|
|
2
|
+
import { $ as AsyncEventEmitter, A as ResolverFileParams, B as createKubb, C as PluginFactoryOptions, D as ResolveOptionsContext, E as ResolveNameParams, F as Plugin, G as Generator, H as FileManager, I as definePlugin, J as createStorage, K as defineGenerator, L as Kubb, M as UserConfig, N as UserLogger, O as Resolver, P as FileMetaBase, Q as logLevel, R as KubbHooks, S as Override, T as ResolveBannerContext, U as Parser, V as PluginDriver, W as defineParser, X as RendererFactory, Y as Renderer, Z as createRenderer, _ as Logger, a as CLIOptions, b as NormalizedPlugin, c as Exclude, d as Include, f as InputData, g as KubbPluginSetupContext, h as KubbBuildStartContext, i as BarrelType, j as ResolverPathParams, k as ResolverContext, l as GeneratorContext, m as KubbBuildEndContext, n as AdapterFactoryOptions, o as Config, p as InputPath, q as Storage, r as AdapterSource, s as DevtoolsOptions, t as Adapter, u as Group, v as LoggerContext, w as PossibleConfig, x as Output, y as LoggerOptions, z as BuildOutput } from "./types-DfEv9d_c.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
|
-
pluginManager: PluginManager;
|
|
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
|
-
* }))
|
|
47
|
+
* const p = new URLPath('/pet/{petId}')
|
|
48
|
+
* p.URL // '/pet/:petId'
|
|
49
|
+
* p.template // '`/pet/${petId}`'
|
|
67
50
|
*/
|
|
68
|
-
declare
|
|
69
|
-
|
|
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
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/createAdapter.d.ts
|
|
70
143
|
/**
|
|
71
|
-
*
|
|
144
|
+
* Builder type for an {@link Adapter} — takes options and returns the adapter instance.
|
|
72
145
|
*/
|
|
73
|
-
declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/defineAdapter.d.ts
|
|
76
146
|
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
|
|
77
147
|
/**
|
|
78
|
-
*
|
|
148
|
+
* Creates an adapter factory. Call the returned function with optional options to get the adapter instance.
|
|
79
149
|
*
|
|
80
150
|
* @example
|
|
81
|
-
*
|
|
82
|
-
* export const adapterOas = defineAdapter<OasAdapter>((options) => {
|
|
83
|
-
* const { validate = true, dateType = 'string' } = options
|
|
151
|
+
* export const myAdapter = createAdapter<MyAdapter>((options) => {
|
|
84
152
|
* return {
|
|
85
|
-
* name:
|
|
86
|
-
* options
|
|
87
|
-
* parse(source) { ... },
|
|
153
|
+
* name: 'my-adapter',
|
|
154
|
+
* options,
|
|
155
|
+
* async parse(source) { ... },
|
|
88
156
|
* }
|
|
89
157
|
* })
|
|
90
|
-
*
|
|
158
|
+
*
|
|
159
|
+
* // instantiate
|
|
160
|
+
* const adapter = myAdapter({ validate: true })
|
|
91
161
|
*/
|
|
92
|
-
declare function
|
|
162
|
+
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
|
|
93
163
|
//#endregion
|
|
94
164
|
//#region src/defineLogger.d.ts
|
|
95
|
-
declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/definePlugin.d.ts
|
|
98
|
-
type PluginBuilder<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>;
|
|
99
165
|
/**
|
|
100
|
-
* Wraps a
|
|
166
|
+
* Wraps a logger definition into a typed {@link Logger}.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* export const myLogger = defineLogger({
|
|
170
|
+
* name: 'my-logger',
|
|
171
|
+
* install(context, options) {
|
|
172
|
+
* context.on('kubb:info', (message) => console.log('ℹ', message))
|
|
173
|
+
* context.on('kubb:error', (error) => console.error('✗', error.message))
|
|
174
|
+
* },
|
|
175
|
+
* })
|
|
101
176
|
*/
|
|
102
|
-
declare function
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/PackageManager.d.ts
|
|
105
|
-
type PackageJSON = {
|
|
106
|
-
dependencies?: Record<string, string>;
|
|
107
|
-
devDependencies?: Record<string, string>;
|
|
108
|
-
};
|
|
109
|
-
type DependencyName = string;
|
|
110
|
-
type DependencyVersion = string;
|
|
111
|
-
declare class PackageManager {
|
|
112
|
-
#private;
|
|
113
|
-
constructor(workspace?: string);
|
|
114
|
-
set workspace(workspace: string);
|
|
115
|
-
get workspace(): string | undefined;
|
|
116
|
-
normalizeDirectory(directory: string): string;
|
|
117
|
-
getLocation(path: string): string;
|
|
118
|
-
import(path: string): Promise<unknown>;
|
|
119
|
-
getPackageJSON(): Promise<PackageJSON | undefined>;
|
|
120
|
-
getPackageJSONSync(): PackageJSON | undefined;
|
|
121
|
-
static setVersion(dependency: DependencyName, version: DependencyVersion): void;
|
|
122
|
-
getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined>;
|
|
123
|
-
getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined;
|
|
124
|
-
isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean>;
|
|
125
|
-
isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean;
|
|
126
|
-
}
|
|
177
|
+
declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
|
|
127
178
|
//#endregion
|
|
128
|
-
//#region src/
|
|
129
|
-
type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
130
|
-
type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
|
|
131
|
-
type SeqOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>;
|
|
179
|
+
//#region src/defineResolver.d.ts
|
|
132
180
|
/**
|
|
133
|
-
*
|
|
181
|
+
* Builder type for the plugin-specific resolver fields.
|
|
182
|
+
*
|
|
183
|
+
* `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
|
|
184
|
+
* are optional — built-in fallbacks are injected when omitted.
|
|
134
185
|
*/
|
|
135
|
-
type
|
|
186
|
+
type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter' | 'name' | 'pluginName'> & Partial<Pick<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>> & {
|
|
187
|
+
name: string;
|
|
188
|
+
pluginName: T['name'];
|
|
189
|
+
} & ThisType<T['resolver']>;
|
|
136
190
|
/**
|
|
137
|
-
*
|
|
191
|
+
* Default option resolver — applies include/exclude filters and merges matching override options.
|
|
192
|
+
*
|
|
193
|
+
* Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.
|
|
194
|
+
*
|
|
195
|
+
* @example Include/exclude filtering
|
|
196
|
+
* ```ts
|
|
197
|
+
* const options = defaultResolveOptions(operationNode, {
|
|
198
|
+
* options: { output: 'types' },
|
|
199
|
+
* exclude: [{ type: 'tag', pattern: 'internal' }],
|
|
200
|
+
* })
|
|
201
|
+
* // → null when node has tag 'internal'
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @example Override merging
|
|
205
|
+
* ```ts
|
|
206
|
+
* const options = defaultResolveOptions(operationNode, {
|
|
207
|
+
* options: { enumType: 'asConst' },
|
|
208
|
+
* override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],
|
|
209
|
+
* })
|
|
210
|
+
* // → { enumType: 'enum' } when operationId matches
|
|
211
|
+
* ```
|
|
138
212
|
*/
|
|
139
|
-
type HookParallelOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>;
|
|
140
213
|
/**
|
|
141
|
-
*
|
|
214
|
+
* Defines a resolver for a plugin, injecting built-in defaults for name casing,
|
|
215
|
+
* include/exclude/override filtering, path resolution, and file construction.
|
|
216
|
+
*
|
|
217
|
+
* All four defaults can be overridden by providing them in the builder function:
|
|
218
|
+
* - `default` — name casing strategy (camelCase / PascalCase)
|
|
219
|
+
* - `resolveOptions` — include/exclude/override filtering
|
|
220
|
+
* - `resolvePath` — output path computation
|
|
221
|
+
* - `resolveFile` — full `FileNode` construction
|
|
222
|
+
*
|
|
223
|
+
* Methods in the builder have access to `this` (the full resolver object), so they
|
|
224
|
+
* can call other resolver methods without circular imports.
|
|
225
|
+
*
|
|
226
|
+
* @example Basic resolver with naming helpers
|
|
227
|
+
* ```ts
|
|
228
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
229
|
+
* name: 'default',
|
|
230
|
+
* resolveName(node) {
|
|
231
|
+
* return this.default(node.name, 'function')
|
|
232
|
+
* },
|
|
233
|
+
* resolveTypedName(node) {
|
|
234
|
+
* return this.default(node.name, 'type')
|
|
235
|
+
* },
|
|
236
|
+
* }))
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @example Override resolvePath for a custom output structure
|
|
240
|
+
* ```ts
|
|
241
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
242
|
+
* name: 'custom',
|
|
243
|
+
* resolvePath({ baseName }, { root, output }) {
|
|
244
|
+
* return path.resolve(root, output.path, 'generated', baseName)
|
|
245
|
+
* },
|
|
246
|
+
* }))
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @example Use this.default inside a helper
|
|
250
|
+
* ```ts
|
|
251
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
252
|
+
* name: 'default',
|
|
253
|
+
* resolveParamName(node, param) {
|
|
254
|
+
* return this.default(`${node.operationId} ${param.in} ${param.name}`, 'type')
|
|
255
|
+
* },
|
|
256
|
+
* }))
|
|
257
|
+
* ```
|
|
142
258
|
*/
|
|
143
|
-
|
|
144
|
-
type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = TStrategy extends 'first' ? HookFirstOutput<TInput, TValue> : TStrategy extends 'seq' ? SeqOutput<TInput, TValue> : TStrategy extends 'parallel' ? HookParallelOutput<TInput, TValue> : never;
|
|
259
|
+
declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
|
|
145
260
|
//#endregion
|
|
146
|
-
//#region src/
|
|
147
|
-
type
|
|
148
|
-
|
|
149
|
-
|
|
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;
|
|
150
280
|
};
|
|
151
|
-
|
|
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
|
+
* @internal
|
|
286
|
+
*/
|
|
287
|
+
declare class FileProcessor {
|
|
152
288
|
#private;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}?:
|
|
157
|
-
|
|
158
|
-
|
|
289
|
+
parse(file: FileNode, {
|
|
290
|
+
parsers,
|
|
291
|
+
extension
|
|
292
|
+
}?: ParseOptions): Promise<string>;
|
|
293
|
+
run(files: Array<FileNode>, {
|
|
294
|
+
parsers,
|
|
295
|
+
mode,
|
|
296
|
+
extension,
|
|
297
|
+
onStart,
|
|
298
|
+
onEnd,
|
|
299
|
+
onUpdate
|
|
300
|
+
}?: RunOptions): Promise<Array<FileNode>>;
|
|
159
301
|
}
|
|
160
302
|
//#endregion
|
|
161
303
|
//#region src/storages/fsStorage.d.ts
|
|
@@ -174,7 +316,8 @@ declare class PromiseManager<TState = unknown> {
|
|
|
174
316
|
*
|
|
175
317
|
* @example
|
|
176
318
|
* ```ts
|
|
177
|
-
* import {
|
|
319
|
+
* import { fsStorage } from '@kubb/core'
|
|
320
|
+
* import { defineConfig } from 'kubb'
|
|
178
321
|
*
|
|
179
322
|
* export default defineConfig({
|
|
180
323
|
* input: { path: './petStore.yaml' },
|
|
@@ -182,7 +325,7 @@ declare class PromiseManager<TState = unknown> {
|
|
|
182
325
|
* })
|
|
183
326
|
* ```
|
|
184
327
|
*/
|
|
185
|
-
declare const fsStorage: (options?: Record<string, never> | undefined) =>
|
|
328
|
+
declare const fsStorage: (options?: Record<string, never> | undefined) => Storage;
|
|
186
329
|
//#endregion
|
|
187
330
|
//#region src/storages/memoryStorage.d.ts
|
|
188
331
|
/**
|
|
@@ -194,7 +337,8 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Define
|
|
|
194
337
|
*
|
|
195
338
|
* @example
|
|
196
339
|
* ```ts
|
|
197
|
-
* import {
|
|
340
|
+
* import { memoryStorage } from '@kubb/core'
|
|
341
|
+
* import { defineConfig } from 'kubb'
|
|
198
342
|
*
|
|
199
343
|
* export default defineConfig({
|
|
200
344
|
* input: { path: './petStore.yaml' },
|
|
@@ -202,149 +346,14 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Define
|
|
|
202
346
|
* })
|
|
203
347
|
* ```
|
|
204
348
|
*/
|
|
205
|
-
declare const memoryStorage: (options?: Record<string, never> | undefined) =>
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/utils/FunctionParams.d.ts
|
|
208
|
-
type FunctionParamsASTWithoutType = {
|
|
209
|
-
name?: string;
|
|
210
|
-
type?: string;
|
|
211
|
-
/**
|
|
212
|
-
* @default true
|
|
213
|
-
*/
|
|
214
|
-
required?: boolean;
|
|
215
|
-
/**
|
|
216
|
-
* @default true
|
|
217
|
-
*/
|
|
218
|
-
enabled?: boolean;
|
|
219
|
-
default?: string;
|
|
220
|
-
};
|
|
221
|
-
type FunctionParamsASTWithType = {
|
|
222
|
-
name?: never;
|
|
223
|
-
type: string;
|
|
224
|
-
/**
|
|
225
|
-
* @default true
|
|
226
|
-
*/
|
|
227
|
-
required?: boolean;
|
|
228
|
-
/**
|
|
229
|
-
* @default true
|
|
230
|
-
*/
|
|
231
|
-
enabled?: boolean;
|
|
232
|
-
default?: string;
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* @deprecated
|
|
236
|
-
*/
|
|
237
|
-
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
238
|
-
/**
|
|
239
|
-
* @deprecated
|
|
240
|
-
*/
|
|
241
|
-
declare class FunctionParams {
|
|
242
|
-
#private;
|
|
243
|
-
get items(): FunctionParamsAST[];
|
|
244
|
-
add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams;
|
|
245
|
-
static toObject(items: FunctionParamsAST[]): FunctionParamsAST;
|
|
246
|
-
toObject(): FunctionParamsAST;
|
|
247
|
-
static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string;
|
|
248
|
-
toString(): string;
|
|
249
|
-
}
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/utils/formatters.d.ts
|
|
252
|
-
type Formatter = keyof typeof formatters;
|
|
253
|
-
/**
|
|
254
|
-
* Detect which formatter is available in the system.
|
|
255
|
-
*
|
|
256
|
-
* @returns Promise that resolves to the first available formatter or undefined if none are found
|
|
257
|
-
*
|
|
258
|
-
* @remarks
|
|
259
|
-
* Checks in order of preference: biome, oxfmt, prettier.
|
|
260
|
-
* Uses the `--version` flag to detect if each formatter command is available.
|
|
261
|
-
* This is a reliable method as all supported formatters implement this flag.
|
|
262
|
-
*
|
|
263
|
-
* @example
|
|
264
|
-
* ```typescript
|
|
265
|
-
* const formatter = await detectFormatter()
|
|
266
|
-
* if (formatter) {
|
|
267
|
-
* console.log(`Using ${formatter} for formatting`)
|
|
268
|
-
* } else {
|
|
269
|
-
* console.log('No formatter found')
|
|
270
|
-
* }
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
declare function detectFormatter(): Promise<Formatter | undefined>;
|
|
349
|
+
declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
|
|
274
350
|
//#endregion
|
|
275
|
-
//#region src/utils/
|
|
276
|
-
type FileMetaBase = {
|
|
277
|
-
pluginName?: string;
|
|
278
|
-
};
|
|
279
|
-
type AddIndexesProps = {
|
|
280
|
-
type: BarrelType | false | undefined;
|
|
281
|
-
/**
|
|
282
|
-
* Root based on root and output.path specified in the config
|
|
283
|
-
*/
|
|
284
|
-
root: string;
|
|
285
|
-
/**
|
|
286
|
-
* Output for plugin
|
|
287
|
-
*/
|
|
288
|
-
output: {
|
|
289
|
-
path: string;
|
|
290
|
-
};
|
|
291
|
-
group?: {
|
|
292
|
-
output: string;
|
|
293
|
-
exportAs: string;
|
|
294
|
-
};
|
|
295
|
-
meta?: FileMetaBase;
|
|
296
|
-
};
|
|
297
|
-
declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
|
|
298
|
-
type,
|
|
299
|
-
meta,
|
|
300
|
-
root,
|
|
301
|
-
output
|
|
302
|
-
}: AddIndexesProps): Promise<KubbFile.File[]>;
|
|
303
|
-
//#endregion
|
|
304
|
-
//#region src/utils/getConfigs.d.ts
|
|
305
|
-
/**
|
|
306
|
-
* Converting UserConfig to Config Array without a change in the object beside the JSON convert.
|
|
307
|
-
*/
|
|
308
|
-
declare function getConfigs(config: ConfigInput | UserConfig, args: CLIOptions): Promise<Array<Config>>;
|
|
309
|
-
//#endregion
|
|
310
|
-
//#region src/utils/linters.d.ts
|
|
311
|
-
type Linter = keyof typeof linters;
|
|
312
|
-
declare function detectLinter(): Promise<Linter | undefined>;
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region src/utils/resolveOptions.d.ts
|
|
315
|
-
type FilterItem = {
|
|
316
|
-
type: string;
|
|
317
|
-
pattern: string | RegExp;
|
|
318
|
-
};
|
|
319
|
-
type OverrideItem<TOptions> = FilterItem & {
|
|
320
|
-
options: Omit<Partial<TOptions>, 'override'>;
|
|
321
|
-
};
|
|
322
|
-
type ResolveOptionsContext<TOptions> = {
|
|
323
|
-
options: TOptions;
|
|
324
|
-
exclude?: Array<FilterItem>;
|
|
325
|
-
include?: Array<FilterItem>;
|
|
326
|
-
override?: Array<OverrideItem<TOptions>>;
|
|
327
|
-
};
|
|
351
|
+
//#region src/utils/isInputPath.d.ts
|
|
328
352
|
/**
|
|
329
|
-
*
|
|
330
|
-
* `exclude`, `include`, and `override` rules from the plugin configuration.
|
|
331
|
-
*
|
|
332
|
-
* Returns `null` when the node is excluded or not matched by `include`.
|
|
333
|
-
* Returns the merged options (base options merged with any matching `override`) otherwise.
|
|
334
|
-
*
|
|
335
|
-
* Supported filter types for `OperationNode`: `tag`, `operationId`, `path`, `method`.
|
|
336
|
-
* Supported filter types for `SchemaNode`: `schemaName`.
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* const resolved = resolveOptions(operationNode, { options, exclude, include, override })
|
|
340
|
-
* if (!resolved) return // excluded
|
|
353
|
+
* Type guard to check if a given config has an `input.path`.
|
|
341
354
|
*/
|
|
342
|
-
declare function
|
|
343
|
-
|
|
344
|
-
exclude,
|
|
345
|
-
include,
|
|
346
|
-
override
|
|
347
|
-
}: ResolveOptionsContext<TOptions>): TOptions | null;
|
|
355
|
+
declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
|
|
356
|
+
declare function isInputPath(config: Config | undefined): config is Config<InputPath>;
|
|
348
357
|
//#endregion
|
|
349
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType,
|
|
358
|
+
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, BuildOutput, CLIOptions, Config, DevtoolsOptions, Exclude, FileManager, FileMetaBase, FileProcessor, Generator, GeneratorContext, Group, Include, InputData, InputPath, Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbHooks, KubbPluginSetupContext, Logger, LoggerContext, LoggerOptions, 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, defineParser, definePlugin, defineResolver, fsStorage, isInputPath, logLevel, memoryStorage };
|
|
350
359
|
//# sourceMappingURL=index.d.ts.map
|