@kubb/core 5.0.0-alpha.9 → 5.0.0-beta.10
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 +13 -40
- package/dist/PluginDriver-Cu1Kj9S-.cjs +1075 -0
- package/dist/PluginDriver-Cu1Kj9S-.cjs.map +1 -0
- package/dist/PluginDriver-D8Z0Htid.js +978 -0
- package/dist/PluginDriver-D8Z0Htid.js.map +1 -0
- package/dist/createKubb-ALdb8lmq.d.ts +2082 -0
- package/dist/index.cjs +747 -1667
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +175 -269
- package/dist/index.js +734 -1638
- 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/package.json +47 -60
- package/src/FileManager.ts +115 -0
- package/src/FileProcessor.ts +86 -0
- package/src/PluginDriver.ts +355 -561
- package/src/constants.ts +21 -48
- package/src/createAdapter.ts +88 -5
- package/src/createKubb.ts +1266 -0
- package/src/createRenderer.ts +57 -0
- package/src/createStorage.ts +13 -1
- package/src/defineGenerator.ts +160 -119
- package/src/defineLogger.ts +46 -5
- package/src/defineMiddleware.ts +62 -0
- package/src/defineParser.ts +44 -0
- package/src/definePlugin.ts +379 -0
- package/src/defineResolver.ts +548 -25
- package/src/devtools.ts +22 -15
- package/src/index.ts +13 -15
- package/src/mocks.ts +177 -0
- package/src/storages/fsStorage.ts +13 -8
- package/src/storages/memoryStorage.ts +4 -2
- package/src/types.ts +40 -547
- package/dist/PluginDriver-BkFepPdm.d.ts +0 -1054
- package/dist/chunk-ByKO4r7w.cjs +0 -38
- package/dist/hooks.cjs +0 -103
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.d.ts +0 -77
- package/dist/hooks.js +0 -98
- package/dist/hooks.js.map +0 -1
- package/src/Kubb.ts +0 -224
- package/src/build.ts +0 -418
- package/src/config.ts +0 -56
- package/src/createPlugin.ts +0 -28
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useKubb.ts +0 -143
- 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/diagnostics.ts +0 -15
- 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 -12
- package/src/utils/linters.ts +0 -25
- package/src/utils/packageJSON.ts +0 -61
package/src/types.ts
CHANGED
|
@@ -1,548 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
// inject needs to be omitted because else we have a clash with the PluginDriver instance
|
|
36
|
-
plugins?: Array<Omit<UnknownUserPlugin, 'inject'>>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type InputPath = {
|
|
40
|
-
/**
|
|
41
|
-
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
42
|
-
*/
|
|
43
|
-
path: string
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type InputData = {
|
|
47
|
-
/**
|
|
48
|
-
* A `string` or `object` that contains your Swagger/OpenAPI data.
|
|
49
|
-
*/
|
|
50
|
-
data: string | unknown
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
type Input = InputPath | InputData | Array<InputPath>
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* The raw source passed to an adapter's `parse` function.
|
|
57
|
-
* Mirrors the shape of `Config['input']` with paths already resolved to absolute.
|
|
58
|
-
*/
|
|
59
|
-
export type AdapterSource = { type: 'path'; path: string } | { type: 'data'; data: string | unknown } | { type: 'paths'; paths: Array<string> }
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Type parameters for an adapter definition.
|
|
63
|
-
*
|
|
64
|
-
* Mirrors `PluginFactoryOptions` but scoped to the adapter lifecycle:
|
|
65
|
-
* - `TName` — unique string identifier (e.g. `'oas'`, `'asyncapi'`)
|
|
66
|
-
* - `TOptions` — raw user-facing options passed to the adapter factory
|
|
67
|
-
* - `TResolvedOptions` — defaults applied; what the adapter stores as `options`
|
|
68
|
-
*/
|
|
69
|
-
export type AdapterFactoryOptions<TName extends string = string, TOptions extends object = object, TResolvedOptions extends object = TOptions> = {
|
|
70
|
-
name: TName
|
|
71
|
-
options: TOptions
|
|
72
|
-
resolvedOptions: TResolvedOptions
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* An adapter converts a source file or data into a `@kubb/ast` `RootNode`.
|
|
77
|
-
*
|
|
78
|
-
* Adapters are the single entry-point for different schema formats
|
|
79
|
-
* (OpenAPI, AsyncAPI, Drizzle, …) and produce the universal `RootNode`
|
|
80
|
-
* that all Kubb plugins consume.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* import { oasAdapter } from '@kubb/adapter-oas'
|
|
85
|
-
*
|
|
86
|
-
* export default defineConfig({
|
|
87
|
-
* adapter: adapterOas(), // default — OpenAPI / Swagger
|
|
88
|
-
* input: { path: './openapi.yaml' },
|
|
89
|
-
* plugins: [pluginTs(), pluginZod()],
|
|
90
|
-
* })
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
export type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
94
|
-
/** Human-readable identifier, e.g. `'oas'`, `'drizzle'`, `'asyncapi'`. */
|
|
95
|
-
name: TOptions['name']
|
|
96
|
-
/** Resolved options (after defaults have been applied). */
|
|
97
|
-
options: TOptions['resolvedOptions']
|
|
98
|
-
/** Convert the raw source into a universal `RootNode`. */
|
|
99
|
-
parse: (source: AdapterSource) => PossiblePromise<RootNode>
|
|
100
|
-
/**
|
|
101
|
-
* Extracts `KubbFile.Import` entries needed by a `SchemaNode` tree.
|
|
102
|
-
* Populated after the first `parse()` call. Returns an empty array before that.
|
|
103
|
-
*
|
|
104
|
-
* The `resolve` callback receives the collision-corrected schema name and must
|
|
105
|
-
* return the `{ name, path }` pair for the import, or `undefined` to skip it.
|
|
106
|
-
*/
|
|
107
|
-
getImports: (node: SchemaNode, resolve: (schemaName: string) => { name: string; path: string }) => Array<KubbFile.Import>
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export type BarrelType = 'all' | 'named' | 'propagate'
|
|
111
|
-
|
|
112
|
-
export type DevtoolsOptions = {
|
|
113
|
-
/**
|
|
114
|
-
* Open the AST inspector view (`/ast`) in Kubb Studio.
|
|
115
|
-
* When `false`, opens the main Studio page instead.
|
|
116
|
-
* @default false
|
|
117
|
-
*/
|
|
118
|
-
ast?: boolean
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @private
|
|
123
|
-
*/
|
|
124
|
-
export type Config<TInput = Input> = {
|
|
125
|
-
/**
|
|
126
|
-
* The name to display in the CLI output.
|
|
127
|
-
*/
|
|
128
|
-
name?: string
|
|
129
|
-
/**
|
|
130
|
-
* The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
|
|
131
|
-
* @default process.cwd()
|
|
132
|
-
*/
|
|
133
|
-
root: string
|
|
134
|
-
/**
|
|
135
|
-
* Adapter that converts the input file into a `@kubb/ast` `RootNode` — the universal
|
|
136
|
-
* intermediate representation consumed by all Kubb plugins.
|
|
137
|
-
*
|
|
138
|
-
* - Omit (or pass `undefined`) to use the built-in OpenAPI/Swagger adapter.
|
|
139
|
-
* - Use `@kubb/adapter-oas` for explicit OpenAPI configuration (validate, contentType, …).
|
|
140
|
-
* - Use `@kubb/adapter-drizzle` or `@kubb/adapter-asyncapi` for other formats.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* import { drizzleAdapter } from '@kubb/adapter-drizzle'
|
|
145
|
-
* export default defineConfig({
|
|
146
|
-
* adapter: drizzleAdapter(),
|
|
147
|
-
* input: { path: './src/schema.ts' },
|
|
148
|
-
* })
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
adapter?: Adapter
|
|
152
|
-
/**
|
|
153
|
-
* You can use either `input.path` or `input.data`, depending on your specific needs.
|
|
154
|
-
*/
|
|
155
|
-
input: TInput
|
|
156
|
-
output: {
|
|
157
|
-
/**
|
|
158
|
-
* The path where all generated files receives exported.
|
|
159
|
-
* This can be an absolute path or a path relative to the specified root option.
|
|
160
|
-
*/
|
|
161
|
-
path: string
|
|
162
|
-
/**
|
|
163
|
-
* Clean the output directory before each build.
|
|
164
|
-
*/
|
|
165
|
-
clean?: boolean
|
|
166
|
-
/**
|
|
167
|
-
* Save files to the file system.
|
|
168
|
-
* @default true
|
|
169
|
-
* @deprecated Use `storage` to control where files are written.
|
|
170
|
-
*/
|
|
171
|
-
write?: boolean
|
|
172
|
-
/**
|
|
173
|
-
* Storage backend for generated files.
|
|
174
|
-
* Defaults to `fsStorage()` — the built-in filesystem driver.
|
|
175
|
-
* Accepts any object implementing the {@link Storage} interface.
|
|
176
|
-
* Keys are root-relative paths (e.g. `src/gen/api/getPets.ts`).
|
|
177
|
-
* @default fsStorage()
|
|
178
|
-
* @example
|
|
179
|
-
* ```ts
|
|
180
|
-
* import { memoryStorage } from '@kubb/core'
|
|
181
|
-
* storage: memoryStorage()
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
storage?: Storage
|
|
185
|
-
/**
|
|
186
|
-
* Specifies the formatting tool to be used.
|
|
187
|
-
* - 'auto' automatically detects and uses biome or prettier (in that order of preference).
|
|
188
|
-
* - 'prettier' uses Prettier for code formatting.
|
|
189
|
-
* - 'biome' uses Biome for code formatting.
|
|
190
|
-
* - 'oxfmt' uses Oxfmt for code formatting.
|
|
191
|
-
* - false disables code formatting.
|
|
192
|
-
* @default 'prettier'
|
|
193
|
-
*/
|
|
194
|
-
format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false
|
|
195
|
-
/**
|
|
196
|
-
* Specifies the linter that should be used to analyze the code.
|
|
197
|
-
* - 'auto' automatically detects and uses biome, oxlint, or eslint (in that order of preference).
|
|
198
|
-
* - 'eslint' uses ESLint for linting.
|
|
199
|
-
* - 'biome' uses Biome for linting.
|
|
200
|
-
* - 'oxlint' uses Oxlint for linting.
|
|
201
|
-
* - false disables linting.
|
|
202
|
-
* @default 'auto'
|
|
203
|
-
*/
|
|
204
|
-
lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false
|
|
205
|
-
/**
|
|
206
|
-
* Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
|
|
207
|
-
* @default { '.ts': '.ts'}
|
|
208
|
-
*/
|
|
209
|
-
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>
|
|
210
|
-
/**
|
|
211
|
-
* Configures how `index.ts` files are created, including disabling barrel file generation. Each plugin has its own `barrelType` option; this setting controls the root barrel file (e.g., `src/gen/index.ts`).
|
|
212
|
-
* @default 'named'
|
|
213
|
-
*/
|
|
214
|
-
barrelType?: Exclude<BarrelType, 'propagate'> | false
|
|
215
|
-
/**
|
|
216
|
-
* Adds a default banner to the start of every generated file indicating it was generated by Kubb.
|
|
217
|
-
* - 'simple' adds banner with link to Kubb.
|
|
218
|
-
* - 'full' adds source, title, description, and OpenAPI version.
|
|
219
|
-
* - false disables banner generation.
|
|
220
|
-
* @default 'simple'
|
|
221
|
-
*/
|
|
222
|
-
defaultBanner?: 'simple' | 'full' | false
|
|
223
|
-
/**
|
|
224
|
-
* Whether to override existing external files if they already exist.
|
|
225
|
-
* When setting the option in the global configuration, all plugins inherit the same behavior by default.
|
|
226
|
-
* However, all plugins also have an `output.override` option, which can be used to override the behavior for a specific plugin.
|
|
227
|
-
* @default false
|
|
228
|
-
*/
|
|
229
|
-
override?: boolean
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* An array of Kubb plugins that used in the generation.
|
|
233
|
-
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
234
|
-
* If a plugin depends on another plugin, an error is returned if the required dependency is missing. See pre for more details.
|
|
235
|
-
*/
|
|
236
|
-
plugins?: Array<Plugin>
|
|
237
|
-
/**
|
|
238
|
-
* Devtools configuration for Kubb Studio integration.
|
|
239
|
-
*/
|
|
240
|
-
devtools?:
|
|
241
|
-
| true
|
|
242
|
-
| {
|
|
243
|
-
/**
|
|
244
|
-
* Override the Kubb Studio base URL.
|
|
245
|
-
* @default 'https://studio.kubb.dev'
|
|
246
|
-
*/
|
|
247
|
-
studioUrl?: typeof DEFAULT_STUDIO_URL | (string & {})
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Hooks triggered when a specific action occurs in Kubb.
|
|
251
|
-
*/
|
|
252
|
-
hooks?: {
|
|
253
|
-
/**
|
|
254
|
-
* Hook that triggers at the end of all executions.
|
|
255
|
-
* Useful for running Prettier or ESLint to format/lint your code.
|
|
256
|
-
*/
|
|
257
|
-
done?: string | Array<string>
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// plugin
|
|
262
|
-
|
|
263
|
-
type PatternFilter = {
|
|
264
|
-
type: string
|
|
265
|
-
pattern: string | RegExp
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
type PatternOverride<TOptions> = PatternFilter & {
|
|
269
|
-
options: Omit<Partial<TOptions>, 'override'>
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export type ResolveOptionsContext<TOptions> = {
|
|
273
|
-
options: TOptions
|
|
274
|
-
exclude?: Array<PatternFilter>
|
|
275
|
-
include?: Array<PatternFilter>
|
|
276
|
-
override?: Array<PatternOverride<TOptions>>
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Base constraint for all plugin resolver objects.
|
|
281
|
-
*
|
|
282
|
-
* `default` and `resolveOptions` are injected automatically by `defineResolver` — plugin
|
|
283
|
-
* authors may override them but never need to implement them from scratch.
|
|
284
|
-
* Concrete plugin resolver types extend this with their own helper methods.
|
|
285
|
-
*/
|
|
286
|
-
export type Resolver = {
|
|
287
|
-
default(name: ResolveNameParams['name'], type?: ResolveNameParams['type']): string
|
|
288
|
-
resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* The user-facing subset of a `Resolver` — everything except the methods injected by
|
|
293
|
-
* `defineResolver` (`default` and `resolveOptions`).
|
|
294
|
-
*
|
|
295
|
-
* When you pass a `UserResolver` to `defineResolver`, the standard `default` and
|
|
296
|
-
* `resolveOptions` implementations are injected automatically so plugin authors never
|
|
297
|
-
* need to define them by hand. Both can still be overridden by providing them explicitly.
|
|
298
|
-
*/
|
|
299
|
-
export type UserResolver = Omit<Resolver, 'default' | 'resolveOptions'>
|
|
300
|
-
|
|
301
|
-
export type PluginFactoryOptions<
|
|
302
|
-
/**
|
|
303
|
-
* Name to be used for the plugin.
|
|
304
|
-
*/
|
|
305
|
-
TName extends string = string,
|
|
306
|
-
/**
|
|
307
|
-
* Options of the plugin.
|
|
308
|
-
*/
|
|
309
|
-
TOptions extends object = object,
|
|
310
|
-
/**
|
|
311
|
-
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
312
|
-
*/
|
|
313
|
-
TResolvedOptions extends object = TOptions,
|
|
314
|
-
/**
|
|
315
|
-
* Context that you want to expose to other plugins.
|
|
316
|
-
*/
|
|
317
|
-
TContext = unknown,
|
|
318
|
-
/**
|
|
319
|
-
* When calling `resolvePath` you can specify better types.
|
|
320
|
-
*/
|
|
321
|
-
TResolvePathOptions extends object = object,
|
|
322
|
-
/**
|
|
323
|
-
* Resolver object that encapsulates the naming and path-resolution helpers used by this plugin.
|
|
324
|
-
* Use `defineResolver` to define the resolver object and export it alongside the plugin.
|
|
325
|
-
*/
|
|
326
|
-
TResolver extends Resolver = Resolver,
|
|
327
|
-
> = {
|
|
328
|
-
name: TName
|
|
329
|
-
options: TOptions
|
|
330
|
-
resolvedOptions: TResolvedOptions
|
|
331
|
-
context: TContext
|
|
332
|
-
resolvePathOptions: TResolvePathOptions
|
|
333
|
-
resolver: TResolver
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
337
|
-
/**
|
|
338
|
-
* Unique name used for the plugin
|
|
339
|
-
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
340
|
-
* @example @kubb/typescript
|
|
341
|
-
*/
|
|
342
|
-
name: TOptions['name']
|
|
343
|
-
/**
|
|
344
|
-
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
345
|
-
*/
|
|
346
|
-
options: TOptions['resolvedOptions']
|
|
347
|
-
/**
|
|
348
|
-
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin is executed after these plugins.
|
|
349
|
-
* Can be used to validate dependent plugins.
|
|
350
|
-
*/
|
|
351
|
-
pre?: Array<string>
|
|
352
|
-
/**
|
|
353
|
-
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin is executed before these plugins.
|
|
354
|
-
*/
|
|
355
|
-
post?: Array<string>
|
|
356
|
-
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context']
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>
|
|
360
|
-
|
|
361
|
-
type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<string, object, object, unknown, object>>
|
|
362
|
-
|
|
363
|
-
export type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
364
|
-
/**
|
|
365
|
-
* Unique name used for the plugin
|
|
366
|
-
* @example @kubb/typescript
|
|
367
|
-
*/
|
|
368
|
-
name: TOptions['name']
|
|
369
|
-
/**
|
|
370
|
-
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin is executed after these plugins.
|
|
371
|
-
* Can be used to validate dependent plugins.
|
|
372
|
-
*/
|
|
373
|
-
pre?: Array<string>
|
|
374
|
-
/**
|
|
375
|
-
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin is executed before these plugins.
|
|
376
|
-
*/
|
|
377
|
-
post?: Array<string>
|
|
378
|
-
/**
|
|
379
|
-
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
380
|
-
*/
|
|
381
|
-
options: TOptions['resolvedOptions']
|
|
382
|
-
|
|
383
|
-
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>
|
|
384
|
-
/**
|
|
385
|
-
* Defines a context that can be used by other plugins, see `PluginDriver` where we convert from `UserPlugin` to `Plugin` (used when calling `createPlugin`).
|
|
386
|
-
*/
|
|
387
|
-
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context']
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
export type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>
|
|
391
|
-
|
|
392
|
-
export type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
393
|
-
/**
|
|
394
|
-
* Start of the lifecycle of a plugin.
|
|
395
|
-
* @type hookParallel
|
|
396
|
-
*/
|
|
397
|
-
install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>
|
|
398
|
-
/**
|
|
399
|
-
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
400
|
-
* Options can als be included.
|
|
401
|
-
* @type hookFirst
|
|
402
|
-
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
403
|
-
*/
|
|
404
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path
|
|
405
|
-
/**
|
|
406
|
-
* Resolve to a name based on a string.
|
|
407
|
-
* Useful when converting to PascalCase or camelCase.
|
|
408
|
-
* @type hookFirst
|
|
409
|
-
* @example ('pet') => 'Pet'
|
|
410
|
-
*/
|
|
411
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
export type PluginLifecycleHooks = keyof PluginLifecycle
|
|
415
|
-
|
|
416
|
-
export type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>
|
|
417
|
-
|
|
418
|
-
export type ResolvePathParams<TOptions = object> = {
|
|
419
|
-
pluginName?: string
|
|
420
|
-
baseName: KubbFile.BaseName
|
|
421
|
-
mode?: KubbFile.Mode
|
|
422
|
-
/**
|
|
423
|
-
* Options to be passed to 'resolvePath' 3th parameter
|
|
424
|
-
*/
|
|
425
|
-
options?: TOptions
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
export type ResolveNameParams = {
|
|
429
|
-
name: string
|
|
430
|
-
pluginName?: string
|
|
431
|
-
/**
|
|
432
|
-
* Specifies the type of entity being named.
|
|
433
|
-
* - 'file' customizes the name of the created file (uses camelCase).
|
|
434
|
-
* - 'function' customizes the exported function names (uses camelCase).
|
|
435
|
-
* - 'type' customizes TypeScript types (uses PascalCase).
|
|
436
|
-
* - 'const' customizes variable names (uses camelCase).
|
|
437
|
-
* @default undefined
|
|
438
|
-
*/
|
|
439
|
-
type?: 'file' | 'function' | 'type' | 'const'
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
export type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
443
|
-
fabric: FabricType
|
|
444
|
-
config: Config
|
|
445
|
-
driver: PluginDriver
|
|
446
|
-
/**
|
|
447
|
-
* Only add when the file does not exist yet
|
|
448
|
-
*/
|
|
449
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<void>
|
|
450
|
-
/**
|
|
451
|
-
* merging multiple sources into the same output file
|
|
452
|
-
*/
|
|
453
|
-
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>
|
|
454
|
-
events: AsyncEventEmitter<KubbEvents>
|
|
455
|
-
mode: KubbFile.Mode
|
|
456
|
-
/**
|
|
457
|
-
* Current plugin
|
|
458
|
-
*/
|
|
459
|
-
plugin: Plugin<TOptions>
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Opens the Kubb Studio URL for the current `rootNode` in the default browser.
|
|
463
|
-
* Falls back to printing the URL if the browser cannot be launched.
|
|
464
|
-
* No-ops silently when no adapter has set a `rootNode`.
|
|
465
|
-
*/
|
|
466
|
-
openInStudio: (options?: DevtoolsOptions) => Promise<void>
|
|
467
|
-
} & (
|
|
468
|
-
| {
|
|
469
|
-
/**
|
|
470
|
-
* Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.
|
|
471
|
-
* Returns `undefined` when no adapter was set (legacy OAS-only usage).
|
|
472
|
-
*/
|
|
473
|
-
rootNode: RootNode
|
|
474
|
-
/**
|
|
475
|
-
* Return the adapter from `@kubb/ast`
|
|
476
|
-
*/
|
|
477
|
-
adapter: Adapter
|
|
478
|
-
}
|
|
479
|
-
| {
|
|
480
|
-
rootNode?: never
|
|
481
|
-
adapter?: never
|
|
482
|
-
}
|
|
483
|
-
) &
|
|
484
|
-
Kubb.PluginContext
|
|
485
|
-
/**
|
|
486
|
-
* Specify the export location for the files and define the behavior of the output
|
|
487
|
-
*/
|
|
488
|
-
export type Output<TOptions> = {
|
|
489
|
-
/**
|
|
490
|
-
* Path to the output folder or file that will contain the generated code
|
|
491
|
-
*/
|
|
492
|
-
path: string
|
|
493
|
-
/**
|
|
494
|
-
* Define what needs to be exported, here you can also disable the export of barrel files
|
|
495
|
-
* @default 'named'
|
|
496
|
-
*/
|
|
497
|
-
barrelType?: BarrelType | false
|
|
498
|
-
/**
|
|
499
|
-
* Add a banner text in the beginning of every file
|
|
500
|
-
*/
|
|
501
|
-
banner?: string | ((options: TOptions) => string)
|
|
502
|
-
/**
|
|
503
|
-
* Add a footer text in the beginning of every file
|
|
504
|
-
*/
|
|
505
|
-
footer?: string | ((options: TOptions) => string)
|
|
506
|
-
/**
|
|
507
|
-
* Whether to override existing external files if they already exist.
|
|
508
|
-
* @default false
|
|
509
|
-
*/
|
|
510
|
-
override?: boolean
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
export type Group = {
|
|
514
|
-
/**
|
|
515
|
-
* Defines the type where to group the files.
|
|
516
|
-
* - 'tag' groups files by OpenAPI tags.
|
|
517
|
-
* - 'path' groups files by OpenAPI paths.
|
|
518
|
-
* @default undefined
|
|
519
|
-
*/
|
|
520
|
-
type: 'tag' | 'path'
|
|
521
|
-
/**
|
|
522
|
-
* Return the name of a group based on the group name, this is used for the file and name generation.
|
|
523
|
-
*/
|
|
524
|
-
name?: (context: { group: string }) => string
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
export type LoggerOptions = {
|
|
528
|
-
/**
|
|
529
|
-
* @default 3
|
|
530
|
-
*/
|
|
531
|
-
logLevel: (typeof logLevel)[keyof typeof logLevel]
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* Shared context passed to all plugins, parsers, and Fabric internals.
|
|
536
|
-
*/
|
|
537
|
-
export type LoggerContext = AsyncEventEmitter<KubbEvents>
|
|
538
|
-
|
|
539
|
-
export type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
|
|
540
|
-
name: string
|
|
541
|
-
install: (context: LoggerContext, options?: TOptions) => void | Promise<void>
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
export type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Logger<TOptions>
|
|
545
|
-
|
|
1
|
+
export type { DevtoolsOptions } from './devtools.ts'
|
|
2
|
+
export type { Adapter, AdapterFactoryOptions, AdapterSource } from './createAdapter.ts'
|
|
3
|
+
export type {
|
|
4
|
+
BuildOutput,
|
|
5
|
+
CLIOptions,
|
|
6
|
+
Config,
|
|
7
|
+
InputData,
|
|
8
|
+
InputPath,
|
|
9
|
+
Kubb,
|
|
10
|
+
KubbBuildEndContext,
|
|
11
|
+
KubbBuildStartContext,
|
|
12
|
+
KubbConfigEndContext,
|
|
13
|
+
KubbDebugContext,
|
|
14
|
+
KubbErrorContext,
|
|
15
|
+
KubbFileProcessingUpdateContext,
|
|
16
|
+
KubbFilesProcessingEndContext,
|
|
17
|
+
KubbFilesProcessingStartContext,
|
|
18
|
+
KubbGenerationEndContext,
|
|
19
|
+
KubbGenerationStartContext,
|
|
20
|
+
KubbGenerationSummaryContext,
|
|
21
|
+
KubbHookEndContext,
|
|
22
|
+
KubbHookStartContext,
|
|
23
|
+
KubbHooks,
|
|
24
|
+
KubbInfoContext,
|
|
25
|
+
KubbLifecycleStartContext,
|
|
26
|
+
KubbPluginsEndContext,
|
|
27
|
+
KubbSuccessContext,
|
|
28
|
+
KubbVersionNewContext,
|
|
29
|
+
KubbWarnContext,
|
|
30
|
+
PossibleConfig,
|
|
31
|
+
UserConfig,
|
|
32
|
+
} from './createKubb.ts'
|
|
33
|
+
export type { Renderer, RendererFactory } from './createRenderer.ts'
|
|
546
34
|
export type { Storage } from './createStorage.ts'
|
|
547
|
-
export type {
|
|
548
|
-
export type {
|
|
35
|
+
export type { Generator, GeneratorContext } from './defineGenerator.ts'
|
|
36
|
+
export type { Logger, LoggerContext, LoggerOptions, UserLogger } from './defineLogger.ts'
|
|
37
|
+
export type { Middleware } from './defineMiddleware.ts'
|
|
38
|
+
export type { Parser } from './defineParser.ts'
|
|
39
|
+
export type { Exclude, Group, Include, Output, Override } from './definePlugin.ts'
|
|
40
|
+
export type { KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NormalizedPlugin, Plugin, PluginFactoryOptions } from './definePlugin.ts'
|
|
41
|
+
export type { ResolveBannerContext, ResolveOptionsContext, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams } from './defineResolver.ts'
|