@kubb/core 5.0.0-alpha.52 → 5.0.0-alpha.54
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-6E8zd8MW.cjs → PluginDriver-BGZHmzqu.cjs} +5 -5
- package/dist/PluginDriver-BGZHmzqu.cjs.map +1 -0
- package/dist/{PluginDriver-D6wQFD4r.js → PluginDriver-BU7faPiI.js} +5 -5
- package/dist/PluginDriver-BU7faPiI.js.map +1 -0
- package/dist/index.cjs +11 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{types-B4z-z0tn.d.ts → types-CeLqzzAf.d.ts} +126 -76
- package/package.json +4 -4
- package/src/Kubb.ts +45 -73
- package/src/PluginDriver.ts +3 -3
- package/src/createKubb.ts +9 -7
- package/src/defineResolver.ts +1 -1
- package/src/types.ts +119 -0
- package/dist/PluginDriver-6E8zd8MW.cjs.map +0 -1
- package/dist/PluginDriver-D6wQFD4r.js.map +0 -1
package/dist/mocks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
2
|
+
import { R as NormalizedPlugin, V as PluginFactoryOptions, at as PluginDriver, lt as Generator, n as AdapterFactoryOptions, o as Config, t as Adapter } from "./types-CeLqzzAf.js";
|
|
3
3
|
import { OperationNode, SchemaNode, Visitor } from "@kubb/ast";
|
|
4
4
|
|
|
5
5
|
//#region src/mocks.d.ts
|
package/dist/mocks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as applyHookResult, r as FileManager, t as PluginDriver } from "./PluginDriver-
|
|
2
|
+
import { n as applyHookResult, r as FileManager, t as PluginDriver } from "./PluginDriver-BU7faPiI.js";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { transform } from "@kubb/ast";
|
|
5
5
|
//#region src/mocks.ts
|
|
@@ -535,7 +535,7 @@ type CreateKubbOptions = {
|
|
|
535
535
|
* ```ts
|
|
536
536
|
* const kubb = createKubb(userConfig)
|
|
537
537
|
*
|
|
538
|
-
* kubb.hooks.on('kubb:plugin:end', (plugin,
|
|
538
|
+
* kubb.hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
539
539
|
* console.log(`${plugin.name} completed in ${duration}ms`)
|
|
540
540
|
* })
|
|
541
541
|
*
|
|
@@ -545,11 +545,6 @@ type CreateKubbOptions = {
|
|
|
545
545
|
declare function createKubb(userConfig: UserConfig, options?: CreateKubbOptions): Kubb$1;
|
|
546
546
|
//#endregion
|
|
547
547
|
//#region src/Kubb.d.ts
|
|
548
|
-
type DebugInfo = {
|
|
549
|
-
date: Date;
|
|
550
|
-
logs: Array<string>;
|
|
551
|
-
fileName?: string;
|
|
552
|
-
};
|
|
553
548
|
/**
|
|
554
549
|
* The instance returned by {@link createKubb}.
|
|
555
550
|
*/
|
|
@@ -605,7 +600,7 @@ type Kubb$1 = {
|
|
|
605
600
|
* console.log('Starting Kubb generation')
|
|
606
601
|
* })
|
|
607
602
|
*
|
|
608
|
-
* hooks.on('kubb:plugin:end', (plugin,
|
|
603
|
+
* hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
609
604
|
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
610
605
|
* })
|
|
611
606
|
* ```
|
|
@@ -614,7 +609,7 @@ interface KubbHooks {
|
|
|
614
609
|
/**
|
|
615
610
|
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
616
611
|
*/
|
|
617
|
-
'kubb:lifecycle:start': [
|
|
612
|
+
'kubb:lifecycle:start': [ctx: KubbLifecycleStartContext];
|
|
618
613
|
/**
|
|
619
614
|
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
620
615
|
*/
|
|
@@ -626,29 +621,20 @@ interface KubbHooks {
|
|
|
626
621
|
/**
|
|
627
622
|
* Emitted when configuration loading is complete.
|
|
628
623
|
*/
|
|
629
|
-
'kubb:config:end': [
|
|
624
|
+
'kubb:config:end': [ctx: KubbConfigEndContext];
|
|
630
625
|
/**
|
|
631
626
|
* Emitted when code generation phase starts.
|
|
632
627
|
*/
|
|
633
|
-
'kubb:generation:start': [
|
|
628
|
+
'kubb:generation:start': [ctx: KubbGenerationStartContext];
|
|
634
629
|
/**
|
|
635
630
|
* Emitted when code generation phase completes.
|
|
636
631
|
*/
|
|
637
|
-
'kubb:generation:end': [
|
|
632
|
+
'kubb:generation:end': [ctx: KubbGenerationEndContext];
|
|
638
633
|
/**
|
|
639
634
|
* Emitted with a summary of the generation results.
|
|
640
635
|
* Contains summary lines, title, and success status.
|
|
641
636
|
*/
|
|
642
|
-
'kubb:generation:summary': [
|
|
643
|
-
failedPlugins: Set<{
|
|
644
|
-
plugin: Plugin;
|
|
645
|
-
error: Error;
|
|
646
|
-
}>;
|
|
647
|
-
status: 'success' | 'failed';
|
|
648
|
-
hrStart: [number, number];
|
|
649
|
-
filesCreated: number;
|
|
650
|
-
pluginTimings?: Map<Plugin['name'], number>;
|
|
651
|
-
}];
|
|
637
|
+
'kubb:generation:summary': [ctx: KubbGenerationSummaryContext];
|
|
652
638
|
/**
|
|
653
639
|
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
654
640
|
*/
|
|
@@ -677,100 +663,60 @@ interface KubbHooks {
|
|
|
677
663
|
* Emitted when a single hook execution starts (e.g., format or lint).
|
|
678
664
|
* The callback should be invoked when the command completes.
|
|
679
665
|
*/
|
|
680
|
-
'kubb:hook:start': [
|
|
681
|
-
id?: string;
|
|
682
|
-
command: string;
|
|
683
|
-
args?: readonly string[];
|
|
684
|
-
}];
|
|
666
|
+
'kubb:hook:start': [ctx: KubbHookStartContext];
|
|
685
667
|
/**
|
|
686
668
|
* Emitted when a single hook execution completes.
|
|
687
669
|
*/
|
|
688
|
-
'kubb:hook:end': [
|
|
689
|
-
id?: string;
|
|
690
|
-
command: string;
|
|
691
|
-
args?: readonly string[];
|
|
692
|
-
success: boolean;
|
|
693
|
-
error: Error | null;
|
|
694
|
-
}];
|
|
670
|
+
'kubb:hook:end': [ctx: KubbHookEndContext];
|
|
695
671
|
/**
|
|
696
672
|
* Emitted when a new version of Kubb is available.
|
|
697
673
|
*/
|
|
698
|
-
'kubb:version:new': [
|
|
674
|
+
'kubb:version:new': [ctx: KubbVersionNewContext];
|
|
699
675
|
/**
|
|
700
676
|
* Informational message event.
|
|
701
677
|
*/
|
|
702
|
-
'kubb:info': [
|
|
678
|
+
'kubb:info': [ctx: KubbInfoContext];
|
|
703
679
|
/**
|
|
704
680
|
* Error event. Emitted when an error occurs during code generation.
|
|
705
681
|
*/
|
|
706
|
-
'kubb:error': [
|
|
682
|
+
'kubb:error': [ctx: KubbErrorContext];
|
|
707
683
|
/**
|
|
708
684
|
* Success message event.
|
|
709
685
|
*/
|
|
710
|
-
'kubb:success': [
|
|
686
|
+
'kubb:success': [ctx: KubbSuccessContext];
|
|
711
687
|
/**
|
|
712
688
|
* Warning message event.
|
|
713
689
|
*/
|
|
714
|
-
'kubb:warn': [
|
|
690
|
+
'kubb:warn': [ctx: KubbWarnContext];
|
|
715
691
|
/**
|
|
716
692
|
* Debug event for detailed logging.
|
|
717
693
|
* Contains timestamp, log messages, and optional filename.
|
|
718
694
|
*/
|
|
719
|
-
'kubb:debug': [
|
|
695
|
+
'kubb:debug': [ctx: KubbDebugContext];
|
|
720
696
|
/**
|
|
721
697
|
* Emitted when file processing starts.
|
|
722
698
|
* Contains the list of files to be processed.
|
|
723
699
|
*/
|
|
724
|
-
'kubb:files:processing:start': [
|
|
700
|
+
'kubb:files:processing:start': [ctx: KubbFilesProcessingStartContext];
|
|
725
701
|
/**
|
|
726
702
|
* Emitted for each file being processed, providing progress updates.
|
|
727
703
|
* Contains processed count, total count, percentage, and file details.
|
|
728
704
|
*/
|
|
729
|
-
'kubb:file:processing:update': [
|
|
730
|
-
/**
|
|
731
|
-
* Number of files processed so far.
|
|
732
|
-
*/
|
|
733
|
-
processed: number;
|
|
734
|
-
/**
|
|
735
|
-
* Total number of files to process.
|
|
736
|
-
*/
|
|
737
|
-
total: number;
|
|
738
|
-
/**
|
|
739
|
-
* Processing percentage (0–100).
|
|
740
|
-
*/
|
|
741
|
-
percentage: number;
|
|
742
|
-
/**
|
|
743
|
-
* Optional source identifier.
|
|
744
|
-
*/
|
|
745
|
-
source?: string;
|
|
746
|
-
/**
|
|
747
|
-
* The file being processed.
|
|
748
|
-
*/
|
|
749
|
-
file: FileNode;
|
|
750
|
-
/**
|
|
751
|
-
* Kubb configuration
|
|
752
|
-
* Provides access to the current config during file processing.
|
|
753
|
-
*/
|
|
754
|
-
config: Config;
|
|
755
|
-
}];
|
|
705
|
+
'kubb:file:processing:update': [ctx: KubbFileProcessingUpdateContext];
|
|
756
706
|
/**
|
|
757
707
|
* Emitted when file processing completes.
|
|
758
708
|
* Contains the list of processed files.
|
|
759
709
|
*/
|
|
760
|
-
'kubb:files:processing:end': [
|
|
710
|
+
'kubb:files:processing:end': [ctx: KubbFilesProcessingEndContext];
|
|
761
711
|
/**
|
|
762
712
|
* Emitted when a plugin starts executing.
|
|
763
713
|
*/
|
|
764
|
-
'kubb:plugin:start': [
|
|
714
|
+
'kubb:plugin:start': [ctx: KubbPluginStartContext];
|
|
765
715
|
/**
|
|
766
716
|
* Emitted when a plugin completes execution.
|
|
767
717
|
* Duration in ms.
|
|
768
718
|
*/
|
|
769
|
-
'kubb:plugin:end': [
|
|
770
|
-
duration: number;
|
|
771
|
-
success: boolean;
|
|
772
|
-
error?: Error;
|
|
773
|
-
}];
|
|
719
|
+
'kubb:plugin:end': [ctx: KubbPluginEndContext];
|
|
774
720
|
/**
|
|
775
721
|
* Fired once — before any plugin's `buildStart` runs — so that hook-style plugins
|
|
776
722
|
* can register generators, configure resolvers/transformers/renderers, or inject
|
|
@@ -1545,6 +1491,110 @@ type KubbBuildEndContext = {
|
|
|
1545
1491
|
config: Config;
|
|
1546
1492
|
outputDir: string;
|
|
1547
1493
|
};
|
|
1494
|
+
type KubbLifecycleStartContext = {
|
|
1495
|
+
version: string;
|
|
1496
|
+
};
|
|
1497
|
+
type KubbConfigEndContext = {
|
|
1498
|
+
configs: Array<Config>;
|
|
1499
|
+
};
|
|
1500
|
+
type KubbGenerationStartContext = {
|
|
1501
|
+
config: Config;
|
|
1502
|
+
};
|
|
1503
|
+
type KubbGenerationEndContext = {
|
|
1504
|
+
config: Config;
|
|
1505
|
+
files: Array<FileNode>;
|
|
1506
|
+
sources: Map<string, string>;
|
|
1507
|
+
};
|
|
1508
|
+
type KubbGenerationSummaryContext = {
|
|
1509
|
+
config: Config;
|
|
1510
|
+
failedPlugins: Set<{
|
|
1511
|
+
plugin: Plugin;
|
|
1512
|
+
error: Error;
|
|
1513
|
+
}>;
|
|
1514
|
+
status: 'success' | 'failed';
|
|
1515
|
+
hrStart: [number, number];
|
|
1516
|
+
filesCreated: number;
|
|
1517
|
+
pluginTimings?: Map<Plugin['name'], number>;
|
|
1518
|
+
};
|
|
1519
|
+
type KubbVersionNewContext = {
|
|
1520
|
+
currentVersion: string;
|
|
1521
|
+
latestVersion: string;
|
|
1522
|
+
};
|
|
1523
|
+
type KubbInfoContext = {
|
|
1524
|
+
message: string;
|
|
1525
|
+
info?: string;
|
|
1526
|
+
};
|
|
1527
|
+
type KubbErrorContext = {
|
|
1528
|
+
error: Error;
|
|
1529
|
+
meta?: Record<string, unknown>;
|
|
1530
|
+
};
|
|
1531
|
+
type KubbSuccessContext = {
|
|
1532
|
+
message: string;
|
|
1533
|
+
info?: string;
|
|
1534
|
+
};
|
|
1535
|
+
type KubbWarnContext = {
|
|
1536
|
+
message: string;
|
|
1537
|
+
info?: string;
|
|
1538
|
+
};
|
|
1539
|
+
type KubbDebugContext = {
|
|
1540
|
+
date: Date;
|
|
1541
|
+
logs: Array<string>;
|
|
1542
|
+
fileName?: string;
|
|
1543
|
+
};
|
|
1544
|
+
type KubbFilesProcessingStartContext = {
|
|
1545
|
+
files: Array<FileNode>;
|
|
1546
|
+
};
|
|
1547
|
+
type KubbFileProcessingUpdateContext = {
|
|
1548
|
+
/**
|
|
1549
|
+
* Number of files processed so far.
|
|
1550
|
+
*/
|
|
1551
|
+
processed: number;
|
|
1552
|
+
/**
|
|
1553
|
+
* Total number of files to process.
|
|
1554
|
+
*/
|
|
1555
|
+
total: number;
|
|
1556
|
+
/**
|
|
1557
|
+
* Processing percentage (0–100).
|
|
1558
|
+
*/
|
|
1559
|
+
percentage: number;
|
|
1560
|
+
/**
|
|
1561
|
+
* Optional source identifier.
|
|
1562
|
+
*/
|
|
1563
|
+
source?: string;
|
|
1564
|
+
/**
|
|
1565
|
+
* The file being processed.
|
|
1566
|
+
*/
|
|
1567
|
+
file: FileNode;
|
|
1568
|
+
/**
|
|
1569
|
+
* Kubb configuration.
|
|
1570
|
+
* Provides access to the current config during file processing.
|
|
1571
|
+
*/
|
|
1572
|
+
config: Config;
|
|
1573
|
+
};
|
|
1574
|
+
type KubbFilesProcessingEndContext = {
|
|
1575
|
+
files: Array<FileNode>;
|
|
1576
|
+
};
|
|
1577
|
+
type KubbPluginStartContext = {
|
|
1578
|
+
plugin: Plugin;
|
|
1579
|
+
};
|
|
1580
|
+
type KubbPluginEndContext = {
|
|
1581
|
+
plugin: Plugin;
|
|
1582
|
+
duration: number;
|
|
1583
|
+
success: boolean;
|
|
1584
|
+
error?: Error;
|
|
1585
|
+
};
|
|
1586
|
+
type KubbHookStartContext = {
|
|
1587
|
+
id?: string;
|
|
1588
|
+
command: string;
|
|
1589
|
+
args?: readonly string[];
|
|
1590
|
+
};
|
|
1591
|
+
type KubbHookEndContext = {
|
|
1592
|
+
id?: string;
|
|
1593
|
+
command: string;
|
|
1594
|
+
args?: readonly string[];
|
|
1595
|
+
success: boolean;
|
|
1596
|
+
error: Error | null;
|
|
1597
|
+
};
|
|
1548
1598
|
type ByTag = {
|
|
1549
1599
|
type: 'tag';
|
|
1550
1600
|
pattern: string | RegExp;
|
|
@@ -1707,5 +1757,5 @@ type CLIOptions = {
|
|
|
1707
1757
|
*/
|
|
1708
1758
|
type PossibleConfig<TCliOptions = undefined> = PossiblePromise<Config | Config[]> | ((...args: [TCliOptions] extends [undefined] ? [] : [TCliOptions]) => PossiblePromise<Config | Config[]>);
|
|
1709
1759
|
//#endregion
|
|
1710
|
-
export {
|
|
1711
|
-
//# sourceMappingURL=types-
|
|
1760
|
+
export { Plugin as $, KubbPluginSetupContext as A, Override as B, KubbGenerationStartContext as C, KubbInfoContext as D, KubbHookStartContext as E, Logger as F, ResolveOptionsContext as G, PossibleConfig as H, LoggerContext as I, ResolverFileParams as J, Resolver as K, LoggerOptions as L, KubbSuccessContext as M, KubbVersionNewContext as N, KubbLifecycleStartContext as O, KubbWarnContext as P, FileMetaBase as Q, NormalizedPlugin as R, KubbGenerationEndContext as S, KubbHookEndContext as T, ResolveBannerContext as U, PluginFactoryOptions as V, ResolveNameParams as W, UserConfig as X, ResolverPathParams as Y, UserLogger as Z, KubbDebugContext as _, AsyncEventEmitter as _t, CLIOptions as a, PluginDriver as at, KubbFilesProcessingEndContext as b, Exclude$1 as c, defineParser as ct, Include as d, Storage as dt, definePlugin as et, InputData as f, createStorage as ft, KubbConfigEndContext as g, logLevel as gt, KubbBuildStartContext as h, createRenderer as ht, BarrelType as i, createKubb as it, KubbPluginStartContext as j, KubbPluginEndContext as k, GeneratorContext as l, Generator as lt, KubbBuildEndContext as m, RendererFactory as mt, AdapterFactoryOptions as n, KubbHooks as nt, Config as o, FileManager as ot, InputPath as p, Renderer as pt, ResolverContext as q, AdapterSource as r, BuildOutput as rt, DevtoolsOptions as s, Parser as st, Adapter as t, Kubb$1 as tt, Group as u, defineGenerator as ut, KubbErrorContext as v, KubbGenerationSummaryContext as w, KubbFilesProcessingStartContext as x, KubbFileProcessingUpdateContext as y, Output as z };
|
|
1761
|
+
//# sourceMappingURL=types-CeLqzzAf.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.54",
|
|
4
4
|
"description": "Core functionality for Kubb's plugin-based code generation system, providing the foundation for transforming OpenAPI specifications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"fflate": "^0.8.2",
|
|
67
67
|
"tinyexec": "^1.1.1",
|
|
68
|
-
"@kubb/ast": "5.0.0-alpha.
|
|
68
|
+
"@kubb/ast": "5.0.0-alpha.54"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"p-limit": "^7.3.0",
|
|
72
72
|
"@internals/utils": "0.0.0",
|
|
73
|
-
"@kubb/renderer-jsx": "5.0.0-alpha.
|
|
73
|
+
"@kubb/renderer-jsx": "5.0.0-alpha.54"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@kubb/renderer-jsx": "5.0.0-alpha.
|
|
76
|
+
"@kubb/renderer-jsx": "5.0.0-alpha.54"
|
|
77
77
|
},
|
|
78
78
|
"size-limit": [
|
|
79
79
|
{
|
package/src/Kubb.ts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import type { AsyncEventEmitter } from '@internals/utils'
|
|
2
|
-
import type {
|
|
2
|
+
import type { OperationNode, SchemaNode } from '@kubb/ast'
|
|
3
3
|
import type { BuildOutput } from './createKubb.ts'
|
|
4
|
-
import type { Plugin } from './definePlugin.ts'
|
|
5
4
|
import type { PluginDriver } from './PluginDriver.ts'
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
KubbSuccessContext,
|
|
27
|
+
KubbVersionNewContext,
|
|
28
|
+
KubbWarnContext,
|
|
29
|
+
} from './types'
|
|
13
30
|
|
|
14
31
|
/**
|
|
15
32
|
* The instance returned by {@link createKubb}.
|
|
@@ -67,7 +84,7 @@ export type Kubb = {
|
|
|
67
84
|
* console.log('Starting Kubb generation')
|
|
68
85
|
* })
|
|
69
86
|
*
|
|
70
|
-
* hooks.on('kubb:plugin:end', (plugin,
|
|
87
|
+
* hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
71
88
|
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
72
89
|
* })
|
|
73
90
|
* ```
|
|
@@ -76,7 +93,7 @@ export interface KubbHooks {
|
|
|
76
93
|
/**
|
|
77
94
|
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
78
95
|
*/
|
|
79
|
-
'kubb:lifecycle:start': [
|
|
96
|
+
'kubb:lifecycle:start': [ctx: KubbLifecycleStartContext]
|
|
80
97
|
/**
|
|
81
98
|
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
82
99
|
*/
|
|
@@ -89,30 +106,21 @@ export interface KubbHooks {
|
|
|
89
106
|
/**
|
|
90
107
|
* Emitted when configuration loading is complete.
|
|
91
108
|
*/
|
|
92
|
-
'kubb:config:end': [
|
|
109
|
+
'kubb:config:end': [ctx: KubbConfigEndContext]
|
|
93
110
|
|
|
94
111
|
/**
|
|
95
112
|
* Emitted when code generation phase starts.
|
|
96
113
|
*/
|
|
97
|
-
'kubb:generation:start': [
|
|
114
|
+
'kubb:generation:start': [ctx: KubbGenerationStartContext]
|
|
98
115
|
/**
|
|
99
116
|
* Emitted when code generation phase completes.
|
|
100
117
|
*/
|
|
101
|
-
'kubb:generation:end': [
|
|
118
|
+
'kubb:generation:end': [ctx: KubbGenerationEndContext]
|
|
102
119
|
/**
|
|
103
120
|
* Emitted with a summary of the generation results.
|
|
104
121
|
* Contains summary lines, title, and success status.
|
|
105
122
|
*/
|
|
106
|
-
'kubb:generation:summary': [
|
|
107
|
-
config: Config,
|
|
108
|
-
{
|
|
109
|
-
failedPlugins: Set<{ plugin: Plugin; error: Error }>
|
|
110
|
-
status: 'success' | 'failed'
|
|
111
|
-
hrStart: [number, number]
|
|
112
|
-
filesCreated: number
|
|
113
|
-
pluginTimings?: Map<Plugin['name'], number>
|
|
114
|
-
},
|
|
115
|
-
]
|
|
123
|
+
'kubb:generation:summary': [ctx: KubbGenerationSummaryContext]
|
|
116
124
|
|
|
117
125
|
/**
|
|
118
126
|
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
@@ -145,100 +153,64 @@ export interface KubbHooks {
|
|
|
145
153
|
* Emitted when a single hook execution starts (e.g., format or lint).
|
|
146
154
|
* The callback should be invoked when the command completes.
|
|
147
155
|
*/
|
|
148
|
-
'kubb:hook:start': [
|
|
156
|
+
'kubb:hook:start': [ctx: KubbHookStartContext]
|
|
149
157
|
/**
|
|
150
158
|
* Emitted when a single hook execution completes.
|
|
151
159
|
*/
|
|
152
|
-
'kubb:hook:end': [
|
|
153
|
-
{
|
|
154
|
-
id?: string
|
|
155
|
-
command: string
|
|
156
|
-
args?: readonly string[]
|
|
157
|
-
success: boolean
|
|
158
|
-
error: Error | null
|
|
159
|
-
},
|
|
160
|
-
]
|
|
160
|
+
'kubb:hook:end': [ctx: KubbHookEndContext]
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* Emitted when a new version of Kubb is available.
|
|
164
164
|
*/
|
|
165
|
-
'kubb:version:new': [
|
|
165
|
+
'kubb:version:new': [ctx: KubbVersionNewContext]
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* Informational message event.
|
|
169
169
|
*/
|
|
170
|
-
'kubb:info': [
|
|
170
|
+
'kubb:info': [ctx: KubbInfoContext]
|
|
171
171
|
/**
|
|
172
172
|
* Error event. Emitted when an error occurs during code generation.
|
|
173
173
|
*/
|
|
174
|
-
'kubb:error': [
|
|
174
|
+
'kubb:error': [ctx: KubbErrorContext]
|
|
175
175
|
/**
|
|
176
176
|
* Success message event.
|
|
177
177
|
*/
|
|
178
|
-
'kubb:success': [
|
|
178
|
+
'kubb:success': [ctx: KubbSuccessContext]
|
|
179
179
|
/**
|
|
180
180
|
* Warning message event.
|
|
181
181
|
*/
|
|
182
|
-
'kubb:warn': [
|
|
182
|
+
'kubb:warn': [ctx: KubbWarnContext]
|
|
183
183
|
/**
|
|
184
184
|
* Debug event for detailed logging.
|
|
185
185
|
* Contains timestamp, log messages, and optional filename.
|
|
186
186
|
*/
|
|
187
|
-
'kubb:debug': [
|
|
187
|
+
'kubb:debug': [ctx: KubbDebugContext]
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
190
|
* Emitted when file processing starts.
|
|
191
191
|
* Contains the list of files to be processed.
|
|
192
192
|
*/
|
|
193
|
-
'kubb:files:processing:start': [
|
|
193
|
+
'kubb:files:processing:start': [ctx: KubbFilesProcessingStartContext]
|
|
194
194
|
/**
|
|
195
195
|
* Emitted for each file being processed, providing progress updates.
|
|
196
196
|
* Contains processed count, total count, percentage, and file details.
|
|
197
197
|
*/
|
|
198
|
-
'kubb:file:processing:update': [
|
|
199
|
-
{
|
|
200
|
-
/**
|
|
201
|
-
* Number of files processed so far.
|
|
202
|
-
*/
|
|
203
|
-
processed: number
|
|
204
|
-
/**
|
|
205
|
-
* Total number of files to process.
|
|
206
|
-
*/
|
|
207
|
-
total: number
|
|
208
|
-
/**
|
|
209
|
-
* Processing percentage (0–100).
|
|
210
|
-
*/
|
|
211
|
-
percentage: number
|
|
212
|
-
/**
|
|
213
|
-
* Optional source identifier.
|
|
214
|
-
*/
|
|
215
|
-
source?: string
|
|
216
|
-
/**
|
|
217
|
-
* The file being processed.
|
|
218
|
-
*/
|
|
219
|
-
file: FileNode
|
|
220
|
-
/**
|
|
221
|
-
* Kubb configuration
|
|
222
|
-
* Provides access to the current config during file processing.
|
|
223
|
-
*/
|
|
224
|
-
config: Config
|
|
225
|
-
},
|
|
226
|
-
]
|
|
198
|
+
'kubb:file:processing:update': [ctx: KubbFileProcessingUpdateContext]
|
|
227
199
|
/**
|
|
228
200
|
* Emitted when file processing completes.
|
|
229
201
|
* Contains the list of processed files.
|
|
230
202
|
*/
|
|
231
|
-
'kubb:files:processing:end': [
|
|
203
|
+
'kubb:files:processing:end': [ctx: KubbFilesProcessingEndContext]
|
|
232
204
|
|
|
233
205
|
/**
|
|
234
206
|
* Emitted when a plugin starts executing.
|
|
235
207
|
*/
|
|
236
|
-
'kubb:plugin:start': [
|
|
208
|
+
'kubb:plugin:start': [ctx: KubbPluginStartContext]
|
|
237
209
|
/**
|
|
238
210
|
* Emitted when a plugin completes execution.
|
|
239
211
|
* Duration in ms.
|
|
240
212
|
*/
|
|
241
|
-
'kubb:plugin:end': [
|
|
213
|
+
'kubb:plugin:end': [ctx: KubbPluginEndContext]
|
|
242
214
|
|
|
243
215
|
/**
|
|
244
216
|
* Fired once — before any plugin's `buildStart` runs — so that hook-style plugins
|
package/src/PluginDriver.ts
CHANGED
|
@@ -365,13 +365,13 @@ export class PluginDriver {
|
|
|
365
365
|
return plugin.transformer
|
|
366
366
|
},
|
|
367
367
|
warn(message: string) {
|
|
368
|
-
driver.hooks.emit('kubb:warn', message)
|
|
368
|
+
driver.hooks.emit('kubb:warn', { message })
|
|
369
369
|
},
|
|
370
370
|
error(error: string | Error) {
|
|
371
|
-
driver.hooks.emit('kubb:error', typeof error === 'string' ? new Error(error) : error)
|
|
371
|
+
driver.hooks.emit('kubb:error', { error: typeof error === 'string' ? new Error(error) : error })
|
|
372
372
|
},
|
|
373
373
|
info(message: string) {
|
|
374
|
-
driver.hooks.emit('kubb:info', message)
|
|
374
|
+
driver.hooks.emit('kubb:info', { message })
|
|
375
375
|
},
|
|
376
376
|
openInStudio(options?: DevtoolsOptions) {
|
|
377
377
|
if (!driver.config.devtools || driver.#studioIsOpen) {
|
package/src/createKubb.ts
CHANGED
|
@@ -58,7 +58,7 @@ async function setup(userConfig: UserConfig, options: SetupOptions = {}): Promis
|
|
|
58
58
|
const diagnosticInfo = getDiagnosticInfo()
|
|
59
59
|
|
|
60
60
|
if (Array.isArray(userConfig.input)) {
|
|
61
|
-
await hooks.emit('kubb:warn', 'This feature is still under development — use with caution')
|
|
61
|
+
await hooks.emit('kubb:warn', { message: 'This feature is still under development — use with caution' })
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
await hooks.emit('kubb:debug', {
|
|
@@ -284,7 +284,7 @@ async function safeBuild(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
284
284
|
try {
|
|
285
285
|
const timestamp = new Date()
|
|
286
286
|
|
|
287
|
-
await hooks.emit('kubb:plugin:start', plugin)
|
|
287
|
+
await hooks.emit('kubb:plugin:start', { plugin })
|
|
288
288
|
|
|
289
289
|
await hooks.emit('kubb:debug', {
|
|
290
290
|
date: timestamp,
|
|
@@ -308,7 +308,8 @@ async function safeBuild(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
308
308
|
const duration = getElapsedMs(hrStart)
|
|
309
309
|
pluginTimings.set(plugin.name, duration)
|
|
310
310
|
|
|
311
|
-
await hooks.emit('kubb:plugin:end',
|
|
311
|
+
await hooks.emit('kubb:plugin:end', {
|
|
312
|
+
plugin,
|
|
312
313
|
duration,
|
|
313
314
|
success: true,
|
|
314
315
|
})
|
|
@@ -322,7 +323,8 @@ async function safeBuild(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
322
323
|
const errorTimestamp = new Date()
|
|
323
324
|
const duration = getElapsedMs(hrStart)
|
|
324
325
|
|
|
325
|
-
await hooks.emit('kubb:plugin:end',
|
|
326
|
+
await hooks.emit('kubb:plugin:end', {
|
|
327
|
+
plugin,
|
|
326
328
|
duration,
|
|
327
329
|
success: false,
|
|
328
330
|
error,
|
|
@@ -412,7 +414,7 @@ async function safeBuild(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
412
414
|
parsers: parsersMap,
|
|
413
415
|
extension: config.output.extension,
|
|
414
416
|
onStart: async (processingFiles) => {
|
|
415
|
-
await hooks.emit('kubb:files:processing:start', processingFiles)
|
|
417
|
+
await hooks.emit('kubb:files:processing:start', { files: processingFiles })
|
|
416
418
|
},
|
|
417
419
|
onUpdate: async ({ file, source, processed, total, percentage }) => {
|
|
418
420
|
await hooks.emit('kubb:file:processing:update', {
|
|
@@ -429,7 +431,7 @@ async function safeBuild(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
429
431
|
}
|
|
430
432
|
},
|
|
431
433
|
onEnd: async (processedFiles) => {
|
|
432
|
-
await hooks.emit('kubb:files:processing:end', processedFiles)
|
|
434
|
+
await hooks.emit('kubb:files:processing:end', { files: processedFiles })
|
|
433
435
|
await hooks.emit('kubb:debug', {
|
|
434
436
|
date: new Date(),
|
|
435
437
|
logs: [`✓ File write process completed for ${processedFiles.length} files`],
|
|
@@ -569,7 +571,7 @@ type CreateKubbOptions = {
|
|
|
569
571
|
* ```ts
|
|
570
572
|
* const kubb = createKubb(userConfig)
|
|
571
573
|
*
|
|
572
|
-
* kubb.hooks.on('kubb:plugin:end', (plugin,
|
|
574
|
+
* kubb.hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
573
575
|
* console.log(`${plugin.name} completed in ${duration}ms`)
|
|
574
576
|
* })
|
|
575
577
|
*
|
package/src/defineResolver.ts
CHANGED
|
@@ -64,7 +64,7 @@ function matchesOperationPattern(node: OperationNode, type: string, pattern: str
|
|
|
64
64
|
case 'method':
|
|
65
65
|
return testPattern(node.method.toLowerCase(), pattern)
|
|
66
66
|
case 'contentType':
|
|
67
|
-
return node.requestBody?.
|
|
67
|
+
return node.requestBody?.content?.some((c) => testPattern(c.contentType, pattern)) ?? false
|
|
68
68
|
default:
|
|
69
69
|
return false
|
|
70
70
|
}
|