@kubb/core 5.0.0-beta.6 → 5.0.0-beta.61
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/LICENSE +17 -10
- package/README.md +25 -158
- package/dist/diagnostics-DiaUv_iK.d.ts +2904 -0
- package/dist/index.cjs +2523 -1071
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +80 -273
- package/dist/index.js +2513 -1067
- package/dist/index.js.map +1 -1
- package/dist/memoryStorage-CUj1hrxa.cjs +823 -0
- package/dist/memoryStorage-CUj1hrxa.cjs.map +1 -0
- package/dist/memoryStorage-CWFzAz4o.js +714 -0
- package/dist/memoryStorage-CWFzAz4o.js.map +1 -0
- package/dist/mocks.cjs +83 -23
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +36 -10
- package/dist/mocks.js +85 -27
- package/dist/mocks.js.map +1 -1
- package/package.json +8 -28
- package/src/FileManager.ts +86 -64
- package/src/FileProcessor.ts +170 -44
- package/src/KubbDriver.ts +909 -0
- package/src/Transform.ts +105 -0
- package/src/constants.ts +111 -20
- package/src/createAdapter.ts +112 -17
- package/src/createKubb.ts +140 -517
- package/src/createRenderer.ts +43 -28
- package/src/createReporter.ts +134 -0
- package/src/createStorage.ts +36 -23
- package/src/defineGenerator.ts +140 -17
- package/src/defineParser.ts +30 -12
- package/src/definePlugin.ts +375 -21
- package/src/defineResolver.ts +402 -212
- package/src/diagnostics.ts +662 -0
- package/src/index.ts +8 -8
- package/src/mocks.ts +97 -26
- package/src/reporters/cliReporter.ts +89 -0
- package/src/reporters/fileReporter.ts +103 -0
- package/src/reporters/jsonReporter.ts +20 -0
- package/src/reporters/report.ts +85 -0
- package/src/storages/fsStorage.ts +23 -55
- package/src/types.ts +411 -887
- package/dist/PluginDriver-BkTRD2H2.js +0 -946
- package/dist/PluginDriver-BkTRD2H2.js.map +0 -1
- package/dist/PluginDriver-Cadu4ORh.cjs +0 -1037
- package/dist/PluginDriver-Cadu4ORh.cjs.map +0 -1
- package/dist/types-DVPKmzw_.d.ts +0 -2159
- package/src/Kubb.ts +0 -300
- package/src/PluginDriver.ts +0 -426
- package/src/defineLogger.ts +0 -19
- package/src/defineMiddleware.ts +0 -62
- package/src/devtools.ts +0 -59
- 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/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
package/src/Kubb.ts
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import type { AsyncEventEmitter } from '@internals/utils'
|
|
2
|
-
import type { OperationNode, SchemaNode } from '@kubb/ast'
|
|
3
|
-
import type { BuildOutput } from './createKubb.ts'
|
|
4
|
-
import type { PluginDriver } from './PluginDriver.ts'
|
|
5
|
-
import type {
|
|
6
|
-
Config,
|
|
7
|
-
GeneratorContext,
|
|
8
|
-
KubbBuildEndContext,
|
|
9
|
-
KubbBuildStartContext,
|
|
10
|
-
KubbConfigEndContext,
|
|
11
|
-
KubbDebugContext,
|
|
12
|
-
KubbErrorContext,
|
|
13
|
-
KubbFileProcessingUpdateContext,
|
|
14
|
-
KubbFilesProcessingEndContext,
|
|
15
|
-
KubbFilesProcessingStartContext,
|
|
16
|
-
KubbGenerationEndContext,
|
|
17
|
-
KubbGenerationStartContext,
|
|
18
|
-
KubbGenerationSummaryContext,
|
|
19
|
-
KubbHookEndContext,
|
|
20
|
-
KubbHookStartContext,
|
|
21
|
-
KubbInfoContext,
|
|
22
|
-
KubbLifecycleStartContext,
|
|
23
|
-
KubbPluginEndContext,
|
|
24
|
-
KubbPluginSetupContext,
|
|
25
|
-
KubbPluginStartContext,
|
|
26
|
-
KubbPluginsEndContext,
|
|
27
|
-
KubbSuccessContext,
|
|
28
|
-
KubbVersionNewContext,
|
|
29
|
-
KubbWarnContext,
|
|
30
|
-
} from './types'
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Kubb code generation instance returned by {@link createKubb}.
|
|
34
|
-
*
|
|
35
|
-
* Use this when orchestrating multiple builds, inspecting plugin timings, or integrating Kubb into a larger toolchain.
|
|
36
|
-
* For a single one-off build, chain directly: `await createKubb(config).build()`.
|
|
37
|
-
*/
|
|
38
|
-
export type Kubb = {
|
|
39
|
-
/**
|
|
40
|
-
* Shared event emitter for lifecycle and status events. Attach listeners before calling `setup()` or `build()`.
|
|
41
|
-
*/
|
|
42
|
-
readonly hooks: AsyncEventEmitter<KubbHooks>
|
|
43
|
-
/**
|
|
44
|
-
* Generated source code keyed by absolute file path. Available after `build()` or `safeBuild()` completes.
|
|
45
|
-
*/
|
|
46
|
-
readonly sources: Map<string, string>
|
|
47
|
-
/**
|
|
48
|
-
* Plugin driver managing all plugins. Available after `setup()` completes.
|
|
49
|
-
*/
|
|
50
|
-
readonly driver: PluginDriver | undefined
|
|
51
|
-
/**
|
|
52
|
-
* Resolved configuration with defaults applied. Available after `setup()` completes.
|
|
53
|
-
*/
|
|
54
|
-
readonly config: Config | undefined
|
|
55
|
-
/**
|
|
56
|
-
* Resolves config and initializes the driver. `build()` calls this automatically.
|
|
57
|
-
*/
|
|
58
|
-
setup(): Promise<void>
|
|
59
|
-
/**
|
|
60
|
-
* Runs the full pipeline and throws on any plugin error. Automatically calls `setup()` if needed.
|
|
61
|
-
*/
|
|
62
|
-
build(): Promise<BuildOutput>
|
|
63
|
-
/**
|
|
64
|
-
* Runs the full pipeline and captures errors in `BuildOutput` instead of throwing. Automatically calls `setup()` if needed.
|
|
65
|
-
*/
|
|
66
|
-
safeBuild(): Promise<BuildOutput>
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Lifecycle events emitted during Kubb code generation.
|
|
71
|
-
* Use these for logging, progress tracking, and custom integrations.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* import type { AsyncEventEmitter } from '@internals/utils'
|
|
76
|
-
* import type { KubbHooks } from '@kubb/core'
|
|
77
|
-
*
|
|
78
|
-
* const hooks: AsyncEventEmitter<KubbHooks> = new AsyncEventEmitter()
|
|
79
|
-
*
|
|
80
|
-
* hooks.on('kubb:lifecycle:start', () => {
|
|
81
|
-
* console.log('Starting Kubb generation')
|
|
82
|
-
* })
|
|
83
|
-
*
|
|
84
|
-
* hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
85
|
-
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
86
|
-
* })
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
export interface KubbHooks {
|
|
90
|
-
/**
|
|
91
|
-
* Fires at the start of the Kubb lifecycle, before code generation begins.
|
|
92
|
-
*/
|
|
93
|
-
'kubb:lifecycle:start': [ctx: KubbLifecycleStartContext]
|
|
94
|
-
/**
|
|
95
|
-
* Fires at the end of the Kubb lifecycle, after all code generation completes.
|
|
96
|
-
*/
|
|
97
|
-
'kubb:lifecycle:end': []
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Fires when configuration loading starts.
|
|
101
|
-
*/
|
|
102
|
-
'kubb:config:start': []
|
|
103
|
-
/**
|
|
104
|
-
* Fires when configuration loading completes.
|
|
105
|
-
*/
|
|
106
|
-
'kubb:config:end': [ctx: KubbConfigEndContext]
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Fires when code generation starts.
|
|
110
|
-
*/
|
|
111
|
-
'kubb:generation:start': [ctx: KubbGenerationStartContext]
|
|
112
|
-
/**
|
|
113
|
-
* Fires when code generation completes.
|
|
114
|
-
*/
|
|
115
|
-
'kubb:generation:end': [ctx: KubbGenerationEndContext]
|
|
116
|
-
/**
|
|
117
|
-
* Fires with a generation summary including summary lines, title, and success status.
|
|
118
|
-
*/
|
|
119
|
-
'kubb:generation:summary': [ctx: KubbGenerationSummaryContext]
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Fires when code formatting starts (e.g., Biome or Prettier).
|
|
123
|
-
*/
|
|
124
|
-
'kubb:format:start': []
|
|
125
|
-
/**
|
|
126
|
-
* Fires when code formatting completes.
|
|
127
|
-
*/
|
|
128
|
-
'kubb:format:end': []
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Fires when linting starts.
|
|
132
|
-
*/
|
|
133
|
-
'kubb:lint:start': []
|
|
134
|
-
/**
|
|
135
|
-
* Fires when linting completes.
|
|
136
|
-
*/
|
|
137
|
-
'kubb:lint:end': []
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Fires when plugin hooks execution starts.
|
|
141
|
-
*/
|
|
142
|
-
'kubb:hooks:start': []
|
|
143
|
-
/**
|
|
144
|
-
* Fires when plugin hooks execution completes.
|
|
145
|
-
*/
|
|
146
|
-
'kubb:hooks:end': []
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Fires when a single hook executes (e.g., format or lint). The callback is invoked when the command finishes.
|
|
150
|
-
*/
|
|
151
|
-
'kubb:hook:start': [ctx: KubbHookStartContext]
|
|
152
|
-
/**
|
|
153
|
-
* Fires when a single hook execution completes.
|
|
154
|
-
*/
|
|
155
|
-
'kubb:hook:end': [ctx: KubbHookEndContext]
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Fires when a new Kubb version is available.
|
|
159
|
-
*/
|
|
160
|
-
'kubb:version:new': [ctx: KubbVersionNewContext]
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Informational message event.
|
|
164
|
-
*/
|
|
165
|
-
'kubb:info': [ctx: KubbInfoContext]
|
|
166
|
-
/**
|
|
167
|
-
* Error event, fired when an error occurs during generation.
|
|
168
|
-
*/
|
|
169
|
-
'kubb:error': [ctx: KubbErrorContext]
|
|
170
|
-
/**
|
|
171
|
-
* Success message event.
|
|
172
|
-
*/
|
|
173
|
-
'kubb:success': [ctx: KubbSuccessContext]
|
|
174
|
-
/**
|
|
175
|
-
* Warning message event.
|
|
176
|
-
*/
|
|
177
|
-
'kubb:warn': [ctx: KubbWarnContext]
|
|
178
|
-
/**
|
|
179
|
-
* Debug event for detailed logging with timestamp and optional filename.
|
|
180
|
-
*/
|
|
181
|
-
'kubb:debug': [ctx: KubbDebugContext]
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Fires when file processing starts with the list of files to process.
|
|
185
|
-
*/
|
|
186
|
-
'kubb:files:processing:start': [ctx: KubbFilesProcessingStartContext]
|
|
187
|
-
/**
|
|
188
|
-
* Fires for each file with progress updates: processed count, total, percentage, and file details.
|
|
189
|
-
*/
|
|
190
|
-
'kubb:file:processing:update': [ctx: KubbFileProcessingUpdateContext]
|
|
191
|
-
/**
|
|
192
|
-
* Fires when file processing completes with the list of processed files.
|
|
193
|
-
*/
|
|
194
|
-
'kubb:files:processing:end': [ctx: KubbFilesProcessingEndContext]
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Fires when a plugin starts execution.
|
|
198
|
-
*/
|
|
199
|
-
'kubb:plugin:start': [ctx: KubbPluginStartContext]
|
|
200
|
-
/**
|
|
201
|
-
* Fires when a plugin completes execution. Duration measured in milliseconds.
|
|
202
|
-
*/
|
|
203
|
-
'kubb:plugin:end': [ctx: KubbPluginEndContext]
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Fires once before plugins execute — allowing plugins to register generators, configure resolvers/transformers/renderers, or inject files.
|
|
207
|
-
*/
|
|
208
|
-
'kubb:plugin:setup': [ctx: KubbPluginSetupContext]
|
|
209
|
-
/**
|
|
210
|
-
* Fires before the plugin execution loop begins. The adapter has already parsed the source and `inputNode` is available.
|
|
211
|
-
*/
|
|
212
|
-
'kubb:build:start': [ctx: KubbBuildStartContext]
|
|
213
|
-
/**
|
|
214
|
-
* Fires after all plugins run and per-plugin barrels generate, but before files write to disk.
|
|
215
|
-
* Use this to inject final files that must persist in the same write pass as plugin output.
|
|
216
|
-
*/
|
|
217
|
-
'kubb:plugins:end': [ctx: KubbPluginsEndContext]
|
|
218
|
-
/**
|
|
219
|
-
* Fires after all files write to disk.
|
|
220
|
-
*/
|
|
221
|
-
'kubb:build:end': [ctx: KubbBuildEndContext]
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Fires for each schema node during AST traversal. Generator listeners respond to this.
|
|
225
|
-
*/
|
|
226
|
-
'kubb:generate:schema': [node: SchemaNode, ctx: GeneratorContext]
|
|
227
|
-
/**
|
|
228
|
-
* Fires for each operation node during AST traversal. Generator listeners respond to this.
|
|
229
|
-
*/
|
|
230
|
-
'kubb:generate:operation': [node: OperationNode, ctx: GeneratorContext]
|
|
231
|
-
/**
|
|
232
|
-
* Fires once after all operations traverse with the full collected array. Batch generator listeners respond to this.
|
|
233
|
-
*/
|
|
234
|
-
'kubb:generate:operations': [nodes: Array<OperationNode>, ctx: GeneratorContext]
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
declare global {
|
|
238
|
-
namespace Kubb {
|
|
239
|
-
/**
|
|
240
|
-
* Registry that maps plugin names to their `PluginFactoryOptions`.
|
|
241
|
-
* Augment this interface in each plugin's `types.ts` to enable automatic
|
|
242
|
-
* typing for `getPlugin` and `requirePlugin`.
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* ```ts
|
|
246
|
-
* // packages/plugin-ts/src/types.ts
|
|
247
|
-
* declare global {
|
|
248
|
-
* namespace Kubb {
|
|
249
|
-
* interface PluginRegistry {
|
|
250
|
-
* 'plugin-ts': PluginTs
|
|
251
|
-
* }
|
|
252
|
-
* }
|
|
253
|
-
* }
|
|
254
|
-
* ```
|
|
255
|
-
*/
|
|
256
|
-
interface PluginRegistry {}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Extension point for root `Config['output']` options.
|
|
260
|
-
* Augment the `output` key in middleware or plugin packages to add extra fields
|
|
261
|
-
* to the global output configuration without touching core types.
|
|
262
|
-
*
|
|
263
|
-
* @example
|
|
264
|
-
* ```ts
|
|
265
|
-
* // packages/middleware-barrel/src/types.ts
|
|
266
|
-
* declare global {
|
|
267
|
-
* namespace Kubb {
|
|
268
|
-
* interface ConfigOptionsRegistry {
|
|
269
|
-
* output: {
|
|
270
|
-
* barrel?: import('./types.ts').BarrelConfig | false
|
|
271
|
-
* }
|
|
272
|
-
* }
|
|
273
|
-
* }
|
|
274
|
-
* }
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
interface ConfigOptionsRegistry {}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Extension point for per-plugin `Output` options.
|
|
281
|
-
* Augment the `output` key in middleware or plugin packages to add extra fields
|
|
282
|
-
* to the per-plugin output configuration without touching core types.
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```ts
|
|
286
|
-
* // packages/middleware-barrel/src/types.ts
|
|
287
|
-
* declare global {
|
|
288
|
-
* namespace Kubb {
|
|
289
|
-
* interface PluginOptionsRegistry {
|
|
290
|
-
* output: {
|
|
291
|
-
* barrel?: import('./types.ts').PluginBarrelConfig | false
|
|
292
|
-
* }
|
|
293
|
-
* }
|
|
294
|
-
* }
|
|
295
|
-
* }
|
|
296
|
-
* ```
|
|
297
|
-
*/
|
|
298
|
-
interface PluginOptionsRegistry {}
|
|
299
|
-
}
|
|
300
|
-
}
|