@kubb/core 5.0.0-beta.17 → 5.0.0-beta.19
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/dist/{PluginDriver-C5hyNJfM.cjs → PluginDriver-DXp767s2.cjs} +77 -27
- package/dist/PluginDriver-DXp767s2.cjs.map +1 -0
- package/dist/{PluginDriver-CT33kVoQ.js → PluginDriver-uNex0SAr.js} +77 -27
- package/dist/PluginDriver-uNex0SAr.js.map +1 -0
- package/dist/{createKubb-ZgT1MTxG.d.ts → createKubb-BJGymYhe.d.ts} +224 -92
- package/dist/index.cjs +409 -291
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +409 -291
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +25 -13
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +25 -13
- package/dist/mocks.js.map +1 -1
- package/package.json +5 -5
- package/src/FileManager.ts +4 -0
- package/src/FileProcessor.ts +15 -16
- package/src/PluginDriver.ts +37 -10
- package/src/createKubb.ts +371 -179
- package/src/createRenderer.ts +23 -22
- package/src/defineParser.ts +1 -1
- package/src/defineResolver.ts +62 -60
- package/src/mocks.ts +3 -3
- package/dist/PluginDriver-C5hyNJfM.cjs.map +0 -1
- package/dist/PluginDriver-CT33kVoQ.js.map +0 -1
|
@@ -33,7 +33,7 @@ declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[
|
|
|
33
33
|
* await emitter.emit('build', 'petstore')
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void
|
|
36
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> | void;
|
|
37
37
|
/**
|
|
38
38
|
* Registers a persistent listener for `eventName`.
|
|
39
39
|
*
|
|
@@ -245,35 +245,44 @@ declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryO
|
|
|
245
245
|
/**
|
|
246
246
|
* Minimal interface any Kubb renderer must satisfy.
|
|
247
247
|
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* This allows core to drive rendering without a hard dependency on
|
|
254
|
-
* `@kubb/renderer-jsx` or any specific renderer implementation.
|
|
248
|
+
* `TElement` is the type the renderer accepts, for example `KubbReactElement`
|
|
249
|
+
* for `@kubb/renderer-jsx` or a custom type for your own renderer. Defaults to
|
|
250
|
+
* `unknown` so generators that don't care about the element type work without
|
|
251
|
+
* specifying it.
|
|
255
252
|
*/
|
|
256
253
|
type Renderer<TElement = unknown> = {
|
|
254
|
+
/**
|
|
255
|
+
* Renders `element` and populates {@link files} with the resulting {@link FileNode} objects.
|
|
256
|
+
* Called once per render cycle; must resolve before {@link files} is read.
|
|
257
|
+
*/
|
|
257
258
|
render(element: TElement): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Tears down the renderer and releases any held resources.
|
|
261
|
+
* Pass an `Error` to signal a failure, a number for an exit code, or omit for a clean shutdown.
|
|
262
|
+
*/
|
|
258
263
|
unmount(error?: Error | number | null): void;
|
|
264
|
+
/**
|
|
265
|
+
* Accumulated {@link FileNode} results produced by the last {@link render} call.
|
|
266
|
+
* Not populated when {@link stream} is implemented.
|
|
267
|
+
*/
|
|
259
268
|
readonly files: Array<FileNode>;
|
|
269
|
+
/**
|
|
270
|
+
* When present, core calls this instead of {@link render} and {@link files},
|
|
271
|
+
* forwarding each file to `FileManager` as soon as it is ready.
|
|
272
|
+
*/
|
|
273
|
+
stream?(element: TElement): Iterable<FileNode>;
|
|
260
274
|
};
|
|
261
275
|
/**
|
|
262
|
-
* A factory function that produces a fresh {@link Renderer} per render.
|
|
276
|
+
* A factory function that produces a fresh {@link Renderer} per render cycle.
|
|
263
277
|
*
|
|
264
278
|
* Generators use this to declare which renderer handles their output.
|
|
265
279
|
*/
|
|
266
280
|
type RendererFactory<TElement = unknown> = () => Renderer<TElement>;
|
|
267
281
|
/**
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
* Wrap your renderer factory function with this helper to register it as the
|
|
271
|
-
* renderer for a generator. Core will call this factory once per render cycle
|
|
272
|
-
* to obtain a fresh renderer instance.
|
|
282
|
+
* Wraps a renderer factory for use in generator definitions.
|
|
273
283
|
*
|
|
274
284
|
* @example
|
|
275
285
|
* ```ts
|
|
276
|
-
* // packages/renderer-jsx/src/index.ts
|
|
277
286
|
* export const jsxRenderer = createRenderer(() => {
|
|
278
287
|
* const runtime = new Runtime()
|
|
279
288
|
* return {
|
|
@@ -282,14 +291,6 @@ type RendererFactory<TElement = unknown> = () => Renderer<TElement>;
|
|
|
282
291
|
* unmount(error) { runtime.unmount(error) },
|
|
283
292
|
* }
|
|
284
293
|
* })
|
|
285
|
-
*
|
|
286
|
-
* // packages/plugin-zod/src/generators/zodGenerator.tsx
|
|
287
|
-
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
288
|
-
* export const zodGenerator = defineGenerator<PluginZod>({
|
|
289
|
-
* name: 'zod',
|
|
290
|
-
* renderer: jsxRenderer,
|
|
291
|
-
* schema(node, options) { return <File ...>...</File> },
|
|
292
|
-
* })
|
|
293
294
|
* ```
|
|
294
295
|
*/
|
|
295
296
|
declare function createRenderer<TElement = unknown>(factory: RendererFactory<TElement>): RendererFactory<TElement>;
|
|
@@ -389,7 +390,7 @@ type Parser<TMeta extends object = any> = {
|
|
|
389
390
|
/**
|
|
390
391
|
* Convert a resolved file to a string.
|
|
391
392
|
*/
|
|
392
|
-
parse(file: FileNode<TMeta>, options?: PrintOptions):
|
|
393
|
+
parse(file: FileNode<TMeta>, options?: PrintOptions): string;
|
|
393
394
|
};
|
|
394
395
|
/**
|
|
395
396
|
* Defines a parser with type safety. Creates parsers that transform generated files to strings based on their extension.
|
|
@@ -446,15 +447,8 @@ declare class FileProcessor {
|
|
|
446
447
|
parse(file: FileNode, {
|
|
447
448
|
parsers,
|
|
448
449
|
extension
|
|
449
|
-
}?: ParseOptions):
|
|
450
|
-
|
|
451
|
-
* Streams parsed files one at a time as each is processed.
|
|
452
|
-
*
|
|
453
|
-
* Unlike `run()`, files are yielded immediately after parsing rather than batched.
|
|
454
|
-
* Storage writes can begin as soon as the first file is ready, keeping peak
|
|
455
|
-
* memory proportional to one file at a time instead of the full batch.
|
|
456
|
-
*/
|
|
457
|
-
stream(files: ReadonlyArray<FileNode>, options?: ParseOptions): AsyncGenerator<ParsedFile>;
|
|
450
|
+
}?: ParseOptions): string;
|
|
451
|
+
stream(files: ReadonlyArray<FileNode>, options?: ParseOptions): Generator<ParsedFile>;
|
|
458
452
|
run(files: Array<FileNode>, options?: ParseOptions): Promise<Array<FileNode>>;
|
|
459
453
|
}
|
|
460
454
|
//#endregion
|
|
@@ -718,29 +712,6 @@ type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<T['resolver'],
|
|
|
718
712
|
name: string;
|
|
719
713
|
pluginName: T['name'];
|
|
720
714
|
} & ThisType<T['resolver']>;
|
|
721
|
-
/**
|
|
722
|
-
* Default option resolver — applies include/exclude filters and merges matching override options.
|
|
723
|
-
*
|
|
724
|
-
* Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.
|
|
725
|
-
*
|
|
726
|
-
* @example Include/exclude filtering
|
|
727
|
-
* ```ts
|
|
728
|
-
* const options = defaultResolveOptions(operationNode, {
|
|
729
|
-
* options: { output: 'types' },
|
|
730
|
-
* exclude: [{ type: 'tag', pattern: 'internal' }],
|
|
731
|
-
* })
|
|
732
|
-
* // → null when node has tag 'internal'
|
|
733
|
-
* ```
|
|
734
|
-
*
|
|
735
|
-
* @example Override merging
|
|
736
|
-
* ```ts
|
|
737
|
-
* const options = defaultResolveOptions(operationNode, {
|
|
738
|
-
* options: { enumType: 'asConst' },
|
|
739
|
-
* override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],
|
|
740
|
-
* })
|
|
741
|
-
* // → { enumType: 'enum' } when operationId matches
|
|
742
|
-
* ```
|
|
743
|
-
*/
|
|
744
715
|
/**
|
|
745
716
|
* Defines a resolver for a plugin, injecting built-in defaults for name casing,
|
|
746
717
|
* include/exclude/override filtering, path resolution, and file construction.
|
|
@@ -985,7 +956,7 @@ type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactor
|
|
|
985
956
|
* Register a generator dynamically. Generators fire during the AST walk (schema/operation/operations)
|
|
986
957
|
* just like generators declared statically on `createPlugin`.
|
|
987
958
|
*/
|
|
988
|
-
addGenerator<TElement = unknown>(generator: Generator<TFactory, TElement>): void;
|
|
959
|
+
addGenerator<TElement = unknown>(generator: Generator$1<TFactory, TElement>): void;
|
|
989
960
|
/**
|
|
990
961
|
* Set or override the resolver for this plugin.
|
|
991
962
|
* The resolver controls file naming and path resolution.
|
|
@@ -1076,7 +1047,7 @@ type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
1076
1047
|
resolver: TOptions['resolver'];
|
|
1077
1048
|
transformer?: Visitor;
|
|
1078
1049
|
renderer?: RendererFactory;
|
|
1079
|
-
generators?: Array<Generator>;
|
|
1050
|
+
generators?: Array<Generator$1>;
|
|
1080
1051
|
apply?: (config: Config) => boolean;
|
|
1081
1052
|
version?: string;
|
|
1082
1053
|
};
|
|
@@ -1162,6 +1133,7 @@ declare class FileManager {
|
|
|
1162
1133
|
* free the per-plugin FileNode caches for the rest of the process lifetime.
|
|
1163
1134
|
*/
|
|
1164
1135
|
dispose(): void;
|
|
1136
|
+
[Symbol.dispose](): void;
|
|
1165
1137
|
/**
|
|
1166
1138
|
* All stored files, sorted by path length (shorter paths first).
|
|
1167
1139
|
*/
|
|
@@ -1243,7 +1215,7 @@ declare class PluginDriver {
|
|
|
1243
1215
|
*
|
|
1244
1216
|
* Call this method inside `addGenerator()` (in `kubb:plugin:setup`) to wire up a generator.
|
|
1245
1217
|
*/
|
|
1246
|
-
registerGenerator(pluginName: string, gen: Generator): void;
|
|
1218
|
+
registerGenerator(pluginName: string, gen: Generator$1): void;
|
|
1247
1219
|
/**
|
|
1248
1220
|
* Returns `true` when at least one generator was registered for the given plugin
|
|
1249
1221
|
* via `addGenerator()` in `kubb:plugin:setup` (event-based path).
|
|
@@ -1259,6 +1231,7 @@ declare class PluginDriver {
|
|
|
1259
1231
|
* @internal
|
|
1260
1232
|
*/
|
|
1261
1233
|
dispose(): void;
|
|
1234
|
+
[Symbol.dispose](): void;
|
|
1262
1235
|
/**
|
|
1263
1236
|
* Merges `partial` with the plugin's default resolver and stores the result.
|
|
1264
1237
|
* Also mirrors it onto `plugin.resolver` so callers using `getPlugin(name).resolver`
|
|
@@ -1394,7 +1367,7 @@ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
1394
1367
|
* })
|
|
1395
1368
|
* ```
|
|
1396
1369
|
*/
|
|
1397
|
-
type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown> = {
|
|
1370
|
+
type Generator$1<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown> = {
|
|
1398
1371
|
/**
|
|
1399
1372
|
* Used in diagnostic messages and debug output.
|
|
1400
1373
|
*/
|
|
@@ -1444,7 +1417,7 @@ type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TEl
|
|
|
1444
1417
|
* `applyHookResult` handles renderer elements and `File[]` uniformly using
|
|
1445
1418
|
* the generator's declared `renderer` factory.
|
|
1446
1419
|
*/
|
|
1447
|
-
declare function defineGenerator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown>(generator: Generator<TOptions, TElement>): Generator<TOptions, TElement>;
|
|
1420
|
+
declare function defineGenerator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown>(generator: Generator$1<TOptions, TElement>): Generator$1<TOptions, TElement>;
|
|
1448
1421
|
//#endregion
|
|
1449
1422
|
//#region src/createKubb.d.ts
|
|
1450
1423
|
/**
|
|
@@ -1899,21 +1872,16 @@ declare global {
|
|
|
1899
1872
|
}
|
|
1900
1873
|
/**
|
|
1901
1874
|
* Lifecycle events emitted during Kubb code generation.
|
|
1902
|
-
*
|
|
1875
|
+
* Attach listeners before calling `setup()` or `build()` to observe and react to build progress.
|
|
1903
1876
|
*
|
|
1904
1877
|
* @example
|
|
1905
|
-
* ```
|
|
1906
|
-
*
|
|
1907
|
-
* import type { KubbHooks } from '@kubb/core'
|
|
1908
|
-
*
|
|
1909
|
-
* const hooks: AsyncEventEmitter<KubbHooks> = new AsyncEventEmitter()
|
|
1910
|
-
*
|
|
1911
|
-
* hooks.on('kubb:lifecycle:start', () => {
|
|
1878
|
+
* ```ts
|
|
1879
|
+
* kubb.hooks.on('kubb:lifecycle:start', () => {
|
|
1912
1880
|
* console.log('Starting Kubb generation')
|
|
1913
1881
|
* })
|
|
1914
1882
|
*
|
|
1915
|
-
* hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
1916
|
-
* console.log(
|
|
1883
|
+
* kubb.hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
1884
|
+
* console.log(`${plugin.name} completed in ${duration}ms`)
|
|
1917
1885
|
* })
|
|
1918
1886
|
* ```
|
|
1919
1887
|
*/
|
|
@@ -1953,45 +1921,90 @@ interface KubbHooks {
|
|
|
1953
1921
|
'kubb:generate:operations': [nodes: Array<OperationNode>, ctx: GeneratorContext];
|
|
1954
1922
|
}
|
|
1955
1923
|
type KubbBuildStartContext = {
|
|
1924
|
+
/**
|
|
1925
|
+
* Resolved configuration for this build.
|
|
1926
|
+
*/
|
|
1956
1927
|
config: Config;
|
|
1928
|
+
/**
|
|
1929
|
+
* Adapter that parsed the input into the universal AST.
|
|
1930
|
+
*/
|
|
1957
1931
|
adapter: Adapter;
|
|
1932
|
+
/**
|
|
1933
|
+
* Parsed input node. For streaming builds the node is a synthetic empty shell
|
|
1934
|
+
* with only `meta` populated — use `kubb:generate:schema` / `kubb:generate:operation` to observe individual nodes.
|
|
1935
|
+
*/
|
|
1958
1936
|
inputNode: InputNode;
|
|
1937
|
+
/**
|
|
1938
|
+
* Looks up a registered plugin by name, typed by the plugin registry.
|
|
1939
|
+
*/
|
|
1959
1940
|
getPlugin<TName extends keyof Kubb$1.PluginRegistry>(name: TName): Plugin<Kubb$1.PluginRegistry[TName]> | undefined;
|
|
1960
1941
|
getPlugin(name: string): Plugin | undefined;
|
|
1942
|
+
/**
|
|
1943
|
+
* Snapshot of all files accumulated so far.
|
|
1944
|
+
*/
|
|
1961
1945
|
readonly files: ReadonlyArray<FileNode>;
|
|
1946
|
+
/**
|
|
1947
|
+
* Adds or merges one or more files into the file manager.
|
|
1948
|
+
*/
|
|
1962
1949
|
upsertFile: (...files: Array<FileNode>) => void;
|
|
1963
1950
|
};
|
|
1964
1951
|
type KubbPluginsEndContext = {
|
|
1952
|
+
/**
|
|
1953
|
+
* Resolved configuration for this build.
|
|
1954
|
+
*/
|
|
1965
1955
|
config: Config;
|
|
1956
|
+
/**
|
|
1957
|
+
* Snapshot of all files accumulated across all plugins.
|
|
1958
|
+
*/
|
|
1966
1959
|
readonly files: ReadonlyArray<FileNode>;
|
|
1960
|
+
/**
|
|
1961
|
+
* Adds or merges one or more files into the file manager.
|
|
1962
|
+
*/
|
|
1967
1963
|
upsertFile: (...files: Array<FileNode>) => void;
|
|
1968
1964
|
};
|
|
1969
1965
|
type KubbBuildEndContext = {
|
|
1966
|
+
/**
|
|
1967
|
+
* All files generated during this build.
|
|
1968
|
+
*/
|
|
1970
1969
|
files: Array<FileNode>;
|
|
1970
|
+
/**
|
|
1971
|
+
* Resolved configuration for this build.
|
|
1972
|
+
*/
|
|
1971
1973
|
config: Config;
|
|
1974
|
+
/**
|
|
1975
|
+
* Absolute path to the output directory.
|
|
1976
|
+
*/
|
|
1972
1977
|
outputDir: string;
|
|
1973
1978
|
};
|
|
1974
1979
|
type KubbLifecycleStartContext = {
|
|
1980
|
+
/**
|
|
1981
|
+
* Current Kubb version string.
|
|
1982
|
+
*/
|
|
1975
1983
|
version: string;
|
|
1976
1984
|
};
|
|
1977
1985
|
type KubbConfigEndContext = {
|
|
1986
|
+
/**
|
|
1987
|
+
* All resolved configs after defaults are applied.
|
|
1988
|
+
*/
|
|
1978
1989
|
configs: Array<Config>;
|
|
1979
1990
|
};
|
|
1980
1991
|
type KubbGenerationStartContext = {
|
|
1992
|
+
/**
|
|
1993
|
+
* Resolved configuration for this generation run.
|
|
1994
|
+
*/
|
|
1981
1995
|
config: Config;
|
|
1982
1996
|
};
|
|
1983
1997
|
type KubbGenerationEndContext = {
|
|
1998
|
+
/**
|
|
1999
|
+
* Resolved configuration for this generation run.
|
|
2000
|
+
*/
|
|
1984
2001
|
config: Config;
|
|
1985
2002
|
/**
|
|
1986
|
-
* Read-only view of the files
|
|
1987
|
-
*
|
|
1988
|
-
* Keys are scoped to this run; files from earlier builds are not included.
|
|
1989
|
-
* Reads go directly to `config.storage`, so nothing is buffered in memory.
|
|
2003
|
+
* Read-only view of the files written during this build.
|
|
2004
|
+
* Reads go directly to `config.storage` — nothing extra is held in memory.
|
|
1990
2005
|
*
|
|
1991
2006
|
* @example Read a generated file
|
|
1992
|
-
*
|
|
1993
|
-
* const code = await storage.getItem('/src/gen/pet.ts')
|
|
1994
|
-
* ```
|
|
2007
|
+
* `const code = await storage.getItem('/src/gen/pet.ts')`
|
|
1995
2008
|
*
|
|
1996
2009
|
* @example Walk every generated file
|
|
1997
2010
|
* ```ts
|
|
@@ -2003,73 +2016,189 @@ type KubbGenerationEndContext = {
|
|
|
2003
2016
|
storage: Storage;
|
|
2004
2017
|
};
|
|
2005
2018
|
type KubbGenerationSummaryContext = {
|
|
2019
|
+
/**
|
|
2020
|
+
* Resolved configuration for this generation run.
|
|
2021
|
+
*/
|
|
2006
2022
|
config: Config;
|
|
2023
|
+
/**
|
|
2024
|
+
* Plugins that threw during generation, paired with their errors.
|
|
2025
|
+
*/
|
|
2007
2026
|
failedPlugins: Set<{
|
|
2008
2027
|
plugin: Plugin;
|
|
2009
2028
|
error: Error;
|
|
2010
2029
|
}>;
|
|
2030
|
+
/**
|
|
2031
|
+
* `'success'` when all plugins completed without errors, `'failed'` otherwise.
|
|
2032
|
+
*/
|
|
2011
2033
|
status: 'success' | 'failed';
|
|
2034
|
+
/**
|
|
2035
|
+
* High-resolution start time from `process.hrtime()`.
|
|
2036
|
+
*/
|
|
2012
2037
|
hrStart: [number, number];
|
|
2038
|
+
/**
|
|
2039
|
+
* Total number of files created during this run.
|
|
2040
|
+
*/
|
|
2013
2041
|
filesCreated: number;
|
|
2042
|
+
/**
|
|
2043
|
+
* Elapsed milliseconds per plugin, keyed by plugin name.
|
|
2044
|
+
*/
|
|
2014
2045
|
pluginTimings?: Map<Plugin['name'], number>;
|
|
2015
2046
|
};
|
|
2016
2047
|
type KubbVersionNewContext = {
|
|
2048
|
+
/**
|
|
2049
|
+
* The installed Kubb version.
|
|
2050
|
+
*/
|
|
2017
2051
|
currentVersion: string;
|
|
2052
|
+
/**
|
|
2053
|
+
* The newest available version on npm.
|
|
2054
|
+
*/
|
|
2018
2055
|
latestVersion: string;
|
|
2019
2056
|
};
|
|
2020
2057
|
type KubbInfoContext = {
|
|
2058
|
+
/**
|
|
2059
|
+
* Human-readable info message.
|
|
2060
|
+
*/
|
|
2021
2061
|
message: string;
|
|
2062
|
+
/**
|
|
2063
|
+
* Optional supplementary detail.
|
|
2064
|
+
*/
|
|
2022
2065
|
info?: string;
|
|
2023
2066
|
};
|
|
2024
2067
|
type KubbErrorContext = {
|
|
2068
|
+
/**
|
|
2069
|
+
* The caught error.
|
|
2070
|
+
*/
|
|
2025
2071
|
error: Error;
|
|
2072
|
+
/**
|
|
2073
|
+
* Optional structured metadata for additional context.
|
|
2074
|
+
*/
|
|
2026
2075
|
meta?: Record<string, unknown>;
|
|
2027
2076
|
};
|
|
2028
2077
|
type KubbSuccessContext = {
|
|
2078
|
+
/**
|
|
2079
|
+
* Human-readable success message.
|
|
2080
|
+
*/
|
|
2029
2081
|
message: string;
|
|
2082
|
+
/**
|
|
2083
|
+
* Optional supplementary detail.
|
|
2084
|
+
*/
|
|
2030
2085
|
info?: string;
|
|
2031
2086
|
};
|
|
2032
2087
|
type KubbWarnContext = {
|
|
2088
|
+
/**
|
|
2089
|
+
* Human-readable warning message.
|
|
2090
|
+
*/
|
|
2033
2091
|
message: string;
|
|
2092
|
+
/**
|
|
2093
|
+
* Optional supplementary detail.
|
|
2094
|
+
*/
|
|
2034
2095
|
info?: string;
|
|
2035
2096
|
};
|
|
2036
2097
|
type KubbDebugContext = {
|
|
2098
|
+
/**
|
|
2099
|
+
* Timestamp when the debug entry was created.
|
|
2100
|
+
*/
|
|
2037
2101
|
date: Date;
|
|
2102
|
+
/**
|
|
2103
|
+
* One or more log lines to emit.
|
|
2104
|
+
*/
|
|
2038
2105
|
logs: Array<string>;
|
|
2106
|
+
/**
|
|
2107
|
+
* Optional source file name associated with this entry.
|
|
2108
|
+
*/
|
|
2039
2109
|
fileName?: string;
|
|
2040
2110
|
};
|
|
2041
2111
|
type KubbFilesProcessingStartContext = {
|
|
2112
|
+
/**
|
|
2113
|
+
* Files about to be serialised and written.
|
|
2114
|
+
*/
|
|
2042
2115
|
files: Array<FileNode>;
|
|
2043
2116
|
};
|
|
2044
2117
|
type KubbFileProcessingUpdateContext = {
|
|
2118
|
+
/**
|
|
2119
|
+
* Number of files processed so far in this batch.
|
|
2120
|
+
*/
|
|
2045
2121
|
processed: number;
|
|
2122
|
+
/**
|
|
2123
|
+
* Total number of files in this batch.
|
|
2124
|
+
*/
|
|
2046
2125
|
total: number;
|
|
2126
|
+
/**
|
|
2127
|
+
* Completion percentage (`0`–`100`).
|
|
2128
|
+
*/
|
|
2047
2129
|
percentage: number;
|
|
2130
|
+
/**
|
|
2131
|
+
* Serialised file content, or `undefined` when the file produced no output.
|
|
2132
|
+
*/
|
|
2048
2133
|
source?: string;
|
|
2134
|
+
/**
|
|
2135
|
+
* The file that was just processed.
|
|
2136
|
+
*/
|
|
2049
2137
|
file: FileNode;
|
|
2138
|
+
/**
|
|
2139
|
+
* Resolved configuration for this build.
|
|
2140
|
+
*/
|
|
2050
2141
|
config: Config;
|
|
2051
2142
|
};
|
|
2052
2143
|
type KubbFilesProcessingEndContext = {
|
|
2144
|
+
/**
|
|
2145
|
+
* All files that were serialised in this batch.
|
|
2146
|
+
*/
|
|
2053
2147
|
files: Array<FileNode>;
|
|
2054
2148
|
};
|
|
2055
2149
|
type KubbHookStartContext = {
|
|
2150
|
+
/**
|
|
2151
|
+
* Optional identifier for correlating start/end events.
|
|
2152
|
+
*/
|
|
2056
2153
|
id?: string;
|
|
2154
|
+
/**
|
|
2155
|
+
* The shell command that is about to run.
|
|
2156
|
+
*/
|
|
2057
2157
|
command: string;
|
|
2158
|
+
/**
|
|
2159
|
+
* Parsed argument list, when available.
|
|
2160
|
+
*/
|
|
2058
2161
|
args?: readonly string[];
|
|
2059
2162
|
};
|
|
2060
2163
|
type KubbHookEndContext = {
|
|
2164
|
+
/**
|
|
2165
|
+
* Optional identifier matching the corresponding `kubb:hook:start` event.
|
|
2166
|
+
*/
|
|
2061
2167
|
id?: string;
|
|
2168
|
+
/**
|
|
2169
|
+
* The shell command that ran.
|
|
2170
|
+
*/
|
|
2062
2171
|
command: string;
|
|
2172
|
+
/**
|
|
2173
|
+
* Parsed argument list, when available.
|
|
2174
|
+
*/
|
|
2063
2175
|
args?: readonly string[];
|
|
2176
|
+
/**
|
|
2177
|
+
* `true` when the command exited with code `0`.
|
|
2178
|
+
*/
|
|
2064
2179
|
success: boolean;
|
|
2180
|
+
/**
|
|
2181
|
+
* Error thrown by the command, or `null` on success.
|
|
2182
|
+
*/
|
|
2065
2183
|
error: Error | null;
|
|
2066
2184
|
};
|
|
2067
2185
|
/**
|
|
2068
2186
|
* CLI options derived from command-line flags.
|
|
2069
2187
|
*/
|
|
2070
2188
|
type CLIOptions = {
|
|
2189
|
+
/**
|
|
2190
|
+
* Path to the Kubb config file.
|
|
2191
|
+
*/
|
|
2071
2192
|
config?: string;
|
|
2072
|
-
|
|
2193
|
+
/**
|
|
2194
|
+
* Re-run generation whenever input files change.
|
|
2195
|
+
*/
|
|
2196
|
+
watch?: boolean;
|
|
2197
|
+
/**
|
|
2198
|
+
* Controls how much output the CLI prints.
|
|
2199
|
+
*
|
|
2200
|
+
* @default 'silent'
|
|
2201
|
+
*/
|
|
2073
2202
|
logLevel?: 'silent' | 'info' | 'debug';
|
|
2074
2203
|
};
|
|
2075
2204
|
/**
|
|
@@ -2082,34 +2211,37 @@ type PossibleConfig<TCliOptions = undefined> = PossiblePromise<Config | Config[]
|
|
|
2082
2211
|
*/
|
|
2083
2212
|
type BuildOutput = {
|
|
2084
2213
|
/**
|
|
2085
|
-
* Plugins that threw during
|
|
2214
|
+
* Plugins that threw during generation, paired with their errors.
|
|
2086
2215
|
*/
|
|
2087
2216
|
failedPlugins: Set<{
|
|
2088
2217
|
plugin: Plugin;
|
|
2089
2218
|
error: Error;
|
|
2090
2219
|
}>;
|
|
2220
|
+
/**
|
|
2221
|
+
* All files generated during this build.
|
|
2222
|
+
*/
|
|
2091
2223
|
files: Array<FileNode>;
|
|
2224
|
+
/**
|
|
2225
|
+
* The plugin driver that orchestrated this build.
|
|
2226
|
+
*/
|
|
2092
2227
|
driver: PluginDriver;
|
|
2093
2228
|
/**
|
|
2094
|
-
* Elapsed
|
|
2229
|
+
* Elapsed milliseconds per plugin, keyed by plugin name.
|
|
2095
2230
|
*/
|
|
2096
2231
|
pluginTimings: Map<string, number>;
|
|
2232
|
+
/**
|
|
2233
|
+
* Top-level error when the build threw before completing, otherwise `undefined`.
|
|
2234
|
+
*/
|
|
2097
2235
|
error?: Error;
|
|
2098
2236
|
/**
|
|
2099
2237
|
* Read-only view of every file written during this build.
|
|
2100
|
-
*
|
|
2101
|
-
* Keys are limited to this run. Reads go straight to `config.storage`,
|
|
2102
|
-
* so nothing extra is held in memory.
|
|
2238
|
+
* Reads go straight to `config.storage` — nothing extra is held in memory.
|
|
2103
2239
|
*
|
|
2104
2240
|
* @example Read a generated file
|
|
2105
|
-
*
|
|
2106
|
-
* const code = await buildOutput.storage.getItem('/src/gen/pet.ts')
|
|
2107
|
-
* ```
|
|
2241
|
+
* `const code = await buildOutput.storage.getItem('/src/gen/pet.ts')`
|
|
2108
2242
|
*
|
|
2109
2243
|
* @example List all generated file paths
|
|
2110
|
-
*
|
|
2111
|
-
* const paths = await buildOutput.storage.getKeys()
|
|
2112
|
-
* ```
|
|
2244
|
+
* `const paths = await buildOutput.storage.getKeys()`
|
|
2113
2245
|
*/
|
|
2114
2246
|
storage: Storage;
|
|
2115
2247
|
};
|
|
@@ -2199,5 +2331,5 @@ type CreateKubbOptions = {
|
|
|
2199
2331
|
*/
|
|
2200
2332
|
declare function createKubb(userConfig: UserConfig, options?: CreateKubbOptions): Kubb$1;
|
|
2201
2333
|
//#endregion
|
|
2202
|
-
export { ResolverPathParams as $, isInputPath as A, KubbPluginSetupContext as B, KubbPluginsEndContext as C, logLevel as Ct, PossibleConfig as D, KubbWarnContext as E, FileManager as F, Plugin as G, NormalizedPlugin as H, Exclude as I, ResolveBannerContext as J, PluginFactoryOptions as K, Group as L, GeneratorContext as M, defineGenerator as N, UserConfig as O, PluginDriver as P, ResolverFileParams as Q, Include as R, KubbLifecycleStartContext as S, createAdapter as St, KubbVersionNewContext as T, Output as U, KubbPluginStartContext as V, Override as W, Resolver as X, ResolveOptionsContext as Y, ResolverContext as Z, KubbGenerationSummaryContext as _, RendererFactory as _t, InputPath as a, LoggerOptions as at, KubbHooks as b, AdapterFactoryOptions as bt, KubbBuildStartContext as c, FileProcessor as ct, KubbErrorContext as d, Parser as dt, defineResolver as et, KubbFileProcessingUpdateContext as f, defineParser as ft, KubbGenerationStartContext as g, Renderer as gt, KubbGenerationEndContext as h, createStorage as ht, InputData as i, LoggerContext as it, Generator as j, createKubb as k, KubbConfigEndContext as l, FileProcessorEvents as lt, KubbFilesProcessingStartContext as m, Storage as mt, CLIOptions as n, defineMiddleware as nt, Kubb$1 as o, UserLogger as ot, KubbFilesProcessingEndContext as p, DevtoolsOptions as pt, definePlugin as q, Config as r, Logger as rt, KubbBuildEndContext as s, defineLogger as st, BuildOutput as t, Middleware as tt, KubbDebugContext as u, ParsedFile as ut, KubbHookEndContext as v, createRenderer as vt, KubbSuccessContext as w, AsyncEventEmitter as wt, KubbInfoContext as x, AdapterSource as xt, KubbHookStartContext as y, Adapter as yt, KubbPluginEndContext as z };
|
|
2203
|
-
//# sourceMappingURL=createKubb-
|
|
2334
|
+
export { ResolverPathParams as $, isInputPath as A, KubbPluginSetupContext as B, KubbPluginsEndContext as C, logLevel as Ct, PossibleConfig as D, KubbWarnContext as E, FileManager as F, Plugin as G, NormalizedPlugin as H, Exclude as I, ResolveBannerContext as J, PluginFactoryOptions as K, Group as L, GeneratorContext as M, defineGenerator as N, UserConfig as O, PluginDriver as P, ResolverFileParams as Q, Include as R, KubbLifecycleStartContext as S, createAdapter as St, KubbVersionNewContext as T, Output as U, KubbPluginStartContext as V, Override as W, Resolver as X, ResolveOptionsContext as Y, ResolverContext as Z, KubbGenerationSummaryContext as _, RendererFactory as _t, InputPath as a, LoggerOptions as at, KubbHooks as b, AdapterFactoryOptions as bt, KubbBuildStartContext as c, FileProcessor as ct, KubbErrorContext as d, Parser as dt, defineResolver as et, KubbFileProcessingUpdateContext as f, defineParser as ft, KubbGenerationStartContext as g, Renderer as gt, KubbGenerationEndContext as h, createStorage as ht, InputData as i, LoggerContext as it, Generator$1 as j, createKubb as k, KubbConfigEndContext as l, FileProcessorEvents as lt, KubbFilesProcessingStartContext as m, Storage as mt, CLIOptions as n, defineMiddleware as nt, Kubb$1 as o, UserLogger as ot, KubbFilesProcessingEndContext as p, DevtoolsOptions as pt, definePlugin as q, Config as r, Logger as rt, KubbBuildEndContext as s, defineLogger as st, BuildOutput as t, Middleware as tt, KubbDebugContext as u, ParsedFile as ut, KubbHookEndContext as v, createRenderer as vt, KubbSuccessContext as w, AsyncEventEmitter as wt, KubbInfoContext as x, AdapterSource as xt, KubbHookStartContext as y, Adapter as yt, KubbPluginEndContext as z };
|
|
2335
|
+
//# sourceMappingURL=createKubb-BJGymYhe.d.ts.map
|