@kubb/core 5.0.0-alpha.3 → 5.0.0-alpha.30

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.
Files changed (54) hide show
  1. package/dist/PluginDriver-D110FoJ-.d.ts +1632 -0
  2. package/dist/hooks.cjs +12 -27
  3. package/dist/hooks.cjs.map +1 -1
  4. package/dist/hooks.d.ts +11 -36
  5. package/dist/hooks.js +13 -27
  6. package/dist/hooks.js.map +1 -1
  7. package/dist/index.cjs +1410 -823
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +597 -95
  10. package/dist/index.js +1391 -818
  11. package/dist/index.js.map +1 -1
  12. package/package.json +7 -7
  13. package/src/Kubb.ts +40 -58
  14. package/src/{PluginManager.ts → PluginDriver.ts} +165 -177
  15. package/src/build.ts +167 -44
  16. package/src/config.ts +9 -8
  17. package/src/constants.ts +40 -7
  18. package/src/createAdapter.ts +25 -0
  19. package/src/createPlugin.ts +30 -0
  20. package/src/createStorage.ts +58 -0
  21. package/src/defineGenerator.ts +126 -0
  22. package/src/defineLogger.ts +13 -3
  23. package/src/definePresets.ts +16 -0
  24. package/src/defineResolver.ts +457 -0
  25. package/src/hooks/index.ts +1 -6
  26. package/src/hooks/useDriver.ts +11 -0
  27. package/src/hooks/useMode.ts +5 -5
  28. package/src/hooks/usePlugin.ts +3 -3
  29. package/src/index.ts +18 -7
  30. package/src/renderNode.tsx +25 -0
  31. package/src/storages/fsStorage.ts +2 -2
  32. package/src/storages/memoryStorage.ts +2 -2
  33. package/src/types.ts +589 -52
  34. package/src/utils/FunctionParams.ts +2 -2
  35. package/src/utils/TreeNode.ts +45 -7
  36. package/src/utils/diagnostics.ts +4 -1
  37. package/src/utils/executeStrategies.ts +29 -10
  38. package/src/utils/formatters.ts +10 -21
  39. package/src/utils/getBarrelFiles.ts +83 -10
  40. package/src/utils/getConfigs.ts +8 -22
  41. package/src/utils/getPreset.ts +78 -0
  42. package/src/utils/linters.ts +23 -3
  43. package/src/utils/packageJSON.ts +76 -0
  44. package/dist/types-CiPWLv-5.d.ts +0 -1001
  45. package/src/BarrelManager.ts +0 -74
  46. package/src/PackageManager.ts +0 -180
  47. package/src/PromiseManager.ts +0 -40
  48. package/src/defineAdapter.ts +0 -22
  49. package/src/definePlugin.ts +0 -12
  50. package/src/defineStorage.ts +0 -56
  51. package/src/errors.ts +0 -1
  52. package/src/hooks/useKubb.ts +0 -22
  53. package/src/hooks/usePluginManager.ts +0 -11
  54. package/src/utils/getPlugins.ts +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/core",
3
- "version": "5.0.0-alpha.3",
3
+ "version": "5.0.0-alpha.30",
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
  "typescript",
@@ -64,14 +64,14 @@
64
64
  }
65
65
  ],
66
66
  "dependencies": {
67
- "@kubb/fabric-core": "0.13.3",
68
- "@kubb/react-fabric": "0.13.3",
67
+ "@kubb/fabric-core": "0.15.1",
68
+ "@kubb/react-fabric": "0.15.1",
69
69
  "empathic": "^2.0.0",
70
70
  "fflate": "^0.8.2",
71
- "remeda": "^2.33.6",
71
+ "remeda": "^2.33.7",
72
72
  "semver": "^7.7.4",
73
73
  "tinyexec": "^1.0.4",
74
- "@kubb/ast": "5.0.0-alpha.3"
74
+ "@kubb/ast": "5.0.0-alpha.30"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/semver": "^7.7.1",
@@ -79,8 +79,8 @@
79
79
  "@internals/utils": "0.0.0"
80
80
  },
81
81
  "peerDependencies": {
82
- "@kubb/fabric-core": "0.13.3",
83
- "@kubb/react-fabric": "0.13.3"
82
+ "@kubb/fabric-core": "0.14.0",
83
+ "@kubb/react-fabric": "0.14.0"
84
84
  },
85
85
  "engines": {
86
86
  "node": ">=22"
package/src/Kubb.ts CHANGED
@@ -1,36 +1,32 @@
1
- import type { KubbFile } from '@kubb/fabric-core/types'
2
- import type { Strategy } from './PluginManager.ts'
1
+ import type { FabricFile } from '@kubb/fabric-core/types'
2
+ import type { Strategy } from './PluginDriver.ts'
3
3
  import type { Config, Plugin, PluginLifecycleHooks } from './types'
4
4
 
5
- type DebugEvent = {
5
+ type DebugInfo = {
6
6
  date: Date
7
- logs: string[]
7
+ logs: Array<string>
8
8
  fileName?: string
9
9
  }
10
10
 
11
- type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
11
+ type HookProgress<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
12
12
  hookName: H
13
13
  plugins: Array<Plugin>
14
14
  }
15
15
 
16
- type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
17
- hookName: H
18
- }
19
-
20
- type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
16
+ type HookExecution<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
21
17
  strategy: Strategy
22
18
  hookName: H
23
19
  plugin: Plugin
24
- parameters?: unknown[] | undefined
20
+ parameters?: Array<unknown>
25
21
  output?: unknown
26
22
  }
27
23
 
28
- type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
24
+ type HookResult<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
29
25
  duration: number
30
26
  strategy: Strategy
31
27
  hookName: H
32
28
  plugin: Plugin
33
- parameters?: unknown[] | undefined
29
+ parameters?: Array<unknown>
34
30
  output?: unknown
35
31
  }
36
32
 
@@ -40,7 +36,7 @@ type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
40
36
  *
41
37
  * @example
42
38
  * ```typescript
43
- * import type { AsyncEventEmitter } from '@kubb/core'
39
+ * import type { AsyncEventEmitter } from '@internals/utils'
44
40
  * import type { KubbEvents } from '@kubb/core'
45
41
  *
46
42
  * const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
@@ -59,7 +55,6 @@ export interface KubbEvents {
59
55
  * Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
60
56
  */
61
57
  'lifecycle:start': [version: string]
62
-
63
58
  /**
64
59
  * Emitted at the end of the Kubb lifecycle, after all code generation is complete.
65
60
  */
@@ -69,7 +64,6 @@ export interface KubbEvents {
69
64
  * Emitted when configuration loading starts.
70
65
  */
71
66
  'config:start': []
72
-
73
67
  /**
74
68
  * Emitted when configuration loading is complete.
75
69
  */
@@ -79,24 +73,22 @@ export interface KubbEvents {
79
73
  * Emitted when code generation phase starts.
80
74
  */
81
75
  'generation:start': [config: Config]
82
-
83
76
  /**
84
77
  * Emitted when code generation phase completes.
85
78
  */
86
- 'generation:end': [Config: Config, files: Array<KubbFile.ResolvedFile>, sources: Map<KubbFile.Path, string>]
87
-
79
+ 'generation:end': [config: Config, files: Array<FabricFile.ResolvedFile>, sources: Map<FabricFile.Path, string>]
88
80
  /**
89
81
  * Emitted with a summary of the generation results.
90
82
  * Contains summary lines, title, and success status.
91
83
  */
92
84
  'generation:summary': [
93
- Config: Config,
85
+ config: Config,
94
86
  {
95
87
  failedPlugins: Set<{ plugin: Plugin; error: Error }>
96
88
  status: 'success' | 'failed'
97
89
  hrStart: [number, number]
98
90
  filesCreated: number
99
- pluginTimings?: Map<string, number>
91
+ pluginTimings?: Map<Plugin['name'], number>
100
92
  },
101
93
  ]
102
94
 
@@ -104,7 +96,6 @@ export interface KubbEvents {
104
96
  * Emitted when code formatting starts (e.g., running Biome or Prettier).
105
97
  */
106
98
  'format:start': []
107
-
108
99
  /**
109
100
  * Emitted when code formatting completes.
110
101
  */
@@ -114,7 +105,6 @@ export interface KubbEvents {
114
105
  * Emitted when linting starts.
115
106
  */
116
107
  'lint:start': []
117
-
118
108
  /**
119
109
  * Emitted when linting completes.
120
110
  */
@@ -124,29 +114,20 @@ export interface KubbEvents {
124
114
  * Emitted when plugin hooks execution starts.
125
115
  */
126
116
  'hooks:start': []
127
-
128
117
  /**
129
118
  * Emitted when plugin hooks execution completes.
130
119
  */
131
120
  'hooks:end': []
132
121
 
133
122
  /**
134
- * Emitted when a single hook execution starts. (e.g., format or lint).
123
+ * Emitted when a single hook execution starts (e.g., format or lint).
135
124
  * The callback should be invoked when the command completes.
136
125
  */
137
126
  'hook:start': [{ id?: string; command: string; args?: readonly string[] }]
138
127
  /**
139
128
  * Emitted when a single hook execution completes.
140
129
  */
141
- 'hook:end': [
142
- {
143
- id?: string
144
- command: string
145
- args?: readonly string[]
146
- success: boolean
147
- error: Error | null
148
- },
149
- ]
130
+ 'hook:end': [{ id?: string; command: string; args?: readonly string[]; success: boolean; error: Error | null }]
150
131
 
151
132
  /**
152
133
  * Emitted when a new version of Kubb is available.
@@ -157,50 +138,55 @@ export interface KubbEvents {
157
138
  * Informational message event.
158
139
  */
159
140
  info: [message: string, info?: string]
160
-
161
141
  /**
162
142
  * Error event. Emitted when an error occurs during code generation.
163
143
  */
164
144
  error: [error: Error, meta?: Record<string, unknown>]
165
-
166
145
  /**
167
146
  * Success message event.
168
147
  */
169
148
  success: [message: string, info?: string]
170
-
171
149
  /**
172
150
  * Warning message event.
173
151
  */
174
152
  warn: [message: string, info?: string]
175
-
176
153
  /**
177
154
  * Debug event for detailed logging.
178
155
  * Contains timestamp, log messages, and optional filename.
179
156
  */
180
- debug: [meta: DebugEvent]
157
+ debug: [info: DebugInfo]
181
158
 
182
159
  /**
183
160
  * Emitted when file processing starts.
184
161
  * Contains the list of files to be processed.
185
162
  */
186
- 'files:processing:start': [files: Array<KubbFile.ResolvedFile>]
187
-
163
+ 'files:processing:start': [files: Array<FabricFile.ResolvedFile>]
188
164
  /**
189
165
  * Emitted for each file being processed, providing progress updates.
190
166
  * Contains processed count, total count, percentage, and file details.
191
167
  */
192
168
  'file:processing:update': [
193
169
  {
194
- /** Number of files processed so far */
170
+ /**
171
+ * Number of files processed so far.
172
+ */
195
173
  processed: number
196
- /** Total number of files to process */
174
+ /**
175
+ * Total number of files to process.
176
+ */
197
177
  total: number
198
- /** Processing percentage (0-100) */
178
+ /**
179
+ * Processing percentage (0–100).
180
+ */
199
181
  percentage: number
200
- /** Optional source identifier */
182
+ /**
183
+ * Optional source identifier.
184
+ */
201
185
  source?: string
202
- /** The file being processed */
203
- file: KubbFile.ResolvedFile
186
+ /**
187
+ * The file being processed.
188
+ */
189
+ file: FabricFile.ResolvedFile
204
190
  /**
205
191
  * Kubb configuration (not present in Fabric).
206
192
  * Provides access to the current config during file processing.
@@ -208,45 +194,41 @@ export interface KubbEvents {
208
194
  config: Config
209
195
  },
210
196
  ]
211
-
212
197
  /**
213
198
  * Emitted when file processing completes.
214
199
  * Contains the list of processed files.
215
200
  */
216
- 'files:processing:end': [files: KubbFile.ResolvedFile[]]
201
+ 'files:processing:end': [files: Array<FabricFile.ResolvedFile>]
217
202
 
218
203
  /**
219
204
  * Emitted when a plugin starts executing.
220
205
  */
221
206
  'plugin:start': [plugin: Plugin]
222
-
223
207
  /**
224
208
  * Emitted when a plugin completes execution.
225
- * Duration in ms
209
+ * Duration in ms.
226
210
  */
227
- 'plugin:end': [plugin: Plugin, meta: { duration: number; success: boolean; error?: Error }]
211
+ 'plugin:end': [plugin: Plugin, result: { duration: number; success: boolean; error?: Error }]
228
212
 
229
213
  /**
230
214
  * Emitted when plugin hook progress tracking starts.
231
215
  * Contains the hook name and list of plugins to execute.
232
216
  */
233
- 'plugins:hook:progress:start': [meta: ProgressStartMeta]
234
-
217
+ 'plugins:hook:progress:start': [progress: HookProgress]
235
218
  /**
236
219
  * Emitted when plugin hook progress tracking ends.
237
220
  * Contains the hook name that completed.
238
221
  */
239
- 'plugins:hook:progress:end': [meta: ProgressStopMeta]
222
+ 'plugins:hook:progress:end': [{ hookName: PluginLifecycleHooks }]
240
223
 
241
224
  /**
242
225
  * Emitted when a plugin hook starts processing.
243
226
  * Contains strategy, hook name, plugin, parameters, and output.
244
227
  */
245
- 'plugins:hook:processing:start': [meta: ExecutingMeta]
246
-
228
+ 'plugins:hook:processing:start': [execution: HookExecution]
247
229
  /**
248
230
  * Emitted when a plugin hook completes processing.
249
231
  * Contains duration, strategy, hook name, plugin, parameters, and output.
250
232
  */
251
- 'plugins:hook:processing:end': [meta: ExecutedMeta]
233
+ 'plugins:hook:processing:end': [result: HookResult]
252
234
  }