@kubb/core 5.0.0-beta.8 → 5.0.0-beta.80

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 (44) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +20 -123
  3. package/dist/diagnostics-CQYd4UQZ.d.ts +2888 -0
  4. package/dist/index.cjs +2350 -1102
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +80 -138
  7. package/dist/index.js +2344 -1101
  8. package/dist/index.js.map +1 -1
  9. package/dist/memoryStorage-9cOBg7bL.cjs +1022 -0
  10. package/dist/memoryStorage-9cOBg7bL.cjs.map +1 -0
  11. package/dist/memoryStorage-C-3NpTDQ.js +884 -0
  12. package/dist/memoryStorage-C-3NpTDQ.js.map +1 -0
  13. package/dist/mocks.cjs +84 -24
  14. package/dist/mocks.cjs.map +1 -1
  15. package/dist/mocks.d.ts +37 -11
  16. package/dist/mocks.js +86 -28
  17. package/dist/mocks.js.map +1 -1
  18. package/package.json +9 -23
  19. package/dist/PluginDriver-Cu1Kj9S-.cjs +0 -1075
  20. package/dist/PluginDriver-Cu1Kj9S-.cjs.map +0 -1
  21. package/dist/PluginDriver-D8Z0Htid.js +0 -978
  22. package/dist/PluginDriver-D8Z0Htid.js.map +0 -1
  23. package/dist/createKubb-Cagd4PIe.d.ts +0 -2082
  24. package/src/FileManager.ts +0 -115
  25. package/src/FileProcessor.ts +0 -86
  26. package/src/PluginDriver.ts +0 -457
  27. package/src/constants.ts +0 -35
  28. package/src/createAdapter.ts +0 -108
  29. package/src/createKubb.ts +0 -1268
  30. package/src/createRenderer.ts +0 -57
  31. package/src/createStorage.ts +0 -70
  32. package/src/defineGenerator.ts +0 -175
  33. package/src/defineLogger.ts +0 -58
  34. package/src/defineMiddleware.ts +0 -62
  35. package/src/defineParser.ts +0 -44
  36. package/src/definePlugin.ts +0 -379
  37. package/src/defineResolver.ts +0 -654
  38. package/src/devtools.ts +0 -66
  39. package/src/index.ts +0 -20
  40. package/src/mocks.ts +0 -177
  41. package/src/storages/fsStorage.ts +0 -90
  42. package/src/storages/memoryStorage.ts +0 -55
  43. package/src/types.ts +0 -41
  44. /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,18 +1,35 @@
1
- import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { $ as ResolverPathParams, A as isInputPath, B as KubbPluginSetupContext, C as KubbPluginsEndContext, D as PossibleConfig, E as KubbWarnContext, F as FileManager, G as Plugin, H as NormalizedPlugin, I as Exclude, J as ResolveBannerContext, K as PluginFactoryOptions, L as Group, M as GeneratorContext, N as defineGenerator, O as UserConfig, P as PluginDriver, Q as ResolverFileParams, R as Include, S as KubbLifecycleStartContext, T as KubbVersionNewContext, U as Output, V as KubbPluginStartContext, W as Override, X as Resolver, Y as ResolveOptionsContext, Z as ResolverContext, _ as KubbGenerationSummaryContext, _t as AdapterFactoryOptions, a as InputPath, at as Logger, b as KubbHooks, bt as logLevel, c as KubbBuildStartContext, ct as UserLogger, d as KubbErrorContext, dt as Storage, et as defineResolver, f as KubbFileProcessingUpdateContext, ft as createStorage, g as KubbGenerationStartContext, gt as Adapter, h as KubbGenerationEndContext, ht as createRenderer, i as InputData, it as defineMiddleware, j as Generator, k as createKubb, l as KubbConfigEndContext, lt as defineLogger, m as KubbFilesProcessingStartContext, mt as RendererFactory, n as CLIOptions, nt as defineParser, o as Kubb, ot as LoggerContext, p as KubbFilesProcessingEndContext, pt as Renderer, q as definePlugin, r as Config, rt as Middleware, s as KubbBuildEndContext, st as LoggerOptions, t as BuildOutput, tt as Parser, u as KubbDebugContext, ut as DevtoolsOptions, v as KubbHookEndContext, vt as AdapterSource, w as KubbSuccessContext, x as KubbInfoContext, xt as AsyncEventEmitter, y as KubbHookStartContext, yt as createAdapter, z as KubbPluginEndContext } from "./createKubb-Cagd4PIe.js";
3
- import * as ast from "@kubb/ast";
4
- import { FileNode } from "@kubb/ast";
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { $ as KubbPluginSetupContext, A as KubbHookStartContext, At as Adapter, B as ParsedFile, C as KubbFilesProcessingEndContext, Ct as GenerationResult, D as KubbGenerationStartContext, Dt as UserReporter, E as KubbGenerationEndContext, Et as ReporterName, F as KubbSuccessContext, G as Generator, H as createKubb, I as KubbWarnContext, J as KubbDriver, K as GeneratorContext, L as PossibleConfig, M as KubbInfoContext, Mt as AdapterSource, N as KubbLifecycleStartContext, Nt as createAdapter, O as KubbHookEndContext, Ot as createReporter, P as KubbPluginsEndContext, Pt as AsyncEventEmitter, Q as KubbPluginEndContext, R as UserConfig, S as KubbFileProcessingUpdate, St as createStorage, T as KubbFilesProcessingUpdateContext, Tt as ReporterContext, U as Parser, V as Kubb, W as defineParser, X as Group, Y as Exclude, Z as Include, _ as InputPath, _t as defineResolver, a as DiagnosticLocation, at as Override, b as KubbDiagnosticContext, bt as createRenderer, c as PerformanceDiagnostic, ct as definePlugin, d as SerializedDiagnostic, dt as ResolveBannerFile, et as KubbPluginStartContext, f as UpdateDiagnostic, ft as ResolveOptionsContext, g as InputData, gt as ResolverPathParams, h as Config, ht as ResolverFileParams, i as DiagnosticKind, it as OutputOptions, j as KubbHooks, jt as AdapterFactoryOptions, k as KubbHookLineContext, kt as logLevel, l as ProblemCode, lt as BannerMeta, m as CLIOptions, mt as ResolverContext, n as DiagnosticByCode, nt as Output, o as DiagnosticSeverity, ot as Plugin, p as BuildOutput, pt as Resolver, q as defineGenerator, r as DiagnosticDoc, rt as OutputMode, s as Diagnostics, st as PluginFactoryOptions, t as Diagnostic, tt as NormalizedPlugin, u as ProblemDiagnostic, ut as ResolveBannerContext, v as KubbBuildEndContext, vt as Renderer, w as KubbFilesProcessingStartContext, wt as Reporter, x as KubbErrorContext, xt as Storage, y as KubbBuildStartContext, yt as RendererFactory, z as FileProcessorHooks } from "./diagnostics-CQYd4UQZ.js";
3
+ import { ast } from "@kubb/ast";
5
4
 
6
- //#region ../../internals/utils/src/urlPath.d.ts
5
+ //#region ../../internals/utils/src/url.d.ts
7
6
  type URLObject = {
8
7
  /**
9
8
  * The resolved URL string (Express-style or template literal, depending on context).
10
9
  */
11
10
  url: string;
12
11
  /**
13
- * Extracted path parameters as a key-value map, or `undefined` when the path has none.
12
+ * Extracted path parameters as a key-value map, or `null` when the path has none.
14
13
  */
15
- params?: Record<string, string>;
14
+ params: Record<string, string> | null;
15
+ };
16
+ /**
17
+ * Supported identifier casing strategies for path parameters.
18
+ */
19
+ type PathCasing = 'camelcase';
20
+ type TemplateOptions = {
21
+ /**
22
+ * Literal text prepended inside the template literal, e.g. a base URL.
23
+ */
24
+ prefix?: string | null;
25
+ /**
26
+ * Transform applied to each extracted parameter name before interpolation.
27
+ */
28
+ replacer?: (pathParam: string) => string;
29
+ /**
30
+ * Casing strategy applied to path parameter names.
31
+ */
32
+ casing?: PathCasing;
16
33
  };
17
34
  type ObjectOptions = {
18
35
  /**
@@ -21,165 +38,90 @@ type ObjectOptions = {
21
38
  */
22
39
  type?: 'path' | 'template';
23
40
  /**
24
- * Optional transform applied to each extracted parameter name.
41
+ * Transform applied to each extracted parameter name.
25
42
  */
26
43
  replacer?: (pathParam: string) => string;
27
44
  /**
28
45
  * When `true`, the result is serialized to a string expression instead of a plain object.
29
46
  */
30
47
  stringify?: boolean;
31
- };
32
- /**
33
- * Supported identifier casing strategies for path parameters.
34
- */
35
- type PathCasing = 'camelcase';
36
- type Options = {
37
48
  /**
38
49
  * Casing strategy applied to path parameter names.
39
- * @default undefined (original identifier preserved)
40
50
  */
41
51
  casing?: PathCasing;
42
52
  };
43
53
  /**
44
- * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
45
- *
46
- * @example
47
- * const p = new URLPath('/pet/{petId}')
48
- * p.URL // '/pet/:petId'
49
- * p.template // '`/pet/${petId}`'
54
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
50
55
  */
51
- declare class URLPath {
52
- #private;
56
+ declare class Url {
53
57
  /**
54
- * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
55
- */
56
- path: string;
57
- constructor(path: string, options?: Options);
58
- /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
59
- *
60
- * @example
61
- * ```ts
62
- * new URLPath('/pet/{petId}').URL // '/pet/:petId'
63
- * ```
64
- */
65
- get URL(): string;
66
- /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
58
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
67
59
  *
68
60
  * @example
69
- * ```ts
70
- * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
71
- * new URLPath('/pet/{petId}').isURL // false
72
- * ```
61
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
73
62
  */
74
- get isURL(): boolean;
63
+ static toPath(path: string): string;
75
64
  /**
76
- * Converts the OpenAPI path to a TypeScript template literal string.
65
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
66
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
67
+ * and `casing` controls parameter identifier casing.
77
68
  *
78
69
  * @example
79
- * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
80
- * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
81
- */
82
- get template(): string;
83
- /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
70
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
84
71
  *
85
72
  * @example
86
- * ```ts
87
- * new URLPath('/pet/{petId}').object
88
- * // { url: '/pet/:petId', params: { petId: 'petId' } }
89
- * ```
73
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
90
74
  */
91
- get object(): URLObject | string;
92
- /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
75
+ static toTemplateString(path: string, {
76
+ prefix,
77
+ replacer,
78
+ casing
79
+ }?: TemplateOptions): string;
80
+ /**
81
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
82
+ * expression when `stringify` is set.
93
83
  *
94
84
  * @example
95
- * ```ts
96
- * new URLPath('/pet/{petId}').params // { petId: 'petId' }
97
- * new URLPath('/pet').params // undefined
98
- * ```
85
+ * Url.toObject('/pet/{petId}')
86
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
99
87
  */
100
- get params(): Record<string, string> | undefined;
101
- toObject({
88
+ static toObject(path: string, {
102
89
  type,
103
90
  replacer,
104
- stringify
91
+ stringify,
92
+ casing
105
93
  }?: ObjectOptions): URLObject | string;
106
- /**
107
- * Converts the OpenAPI path to a TypeScript template literal string.
108
- * An optional `replacer` can transform each extracted parameter name before interpolation.
109
- *
110
- * @example
111
- * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
112
- */
113
- toTemplateString({
114
- prefix,
115
- replacer
116
- }?: {
117
- prefix?: string;
118
- replacer?: (pathParam: string) => string;
119
- }): string;
120
- /**
121
- * Extracts all `{param}` segments from the path and returns them as a key-value map.
122
- * An optional `replacer` transforms each parameter name in both key and value positions.
123
- * Returns `undefined` when no path parameters are found.
124
- *
125
- * @example
126
- * ```ts
127
- * new URLPath('/pet/{petId}/tag/{tagId}').getParams()
128
- * // { petId: 'petId', tagId: 'tagId' }
129
- * ```
130
- */
131
- getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
132
- /** Converts the OpenAPI path to Express-style colon syntax.
133
- *
134
- * @example
135
- * ```ts
136
- * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
137
- * ```
138
- */
139
- toURLPath(): string;
140
94
  }
141
95
  //#endregion
142
- //#region src/FileProcessor.d.ts
143
- type ParseOptions = {
144
- parsers?: Map<FileNode['extname'], Parser>;
145
- extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
146
- };
147
- type RunOptions = ParseOptions & {
148
- /**
149
- * @default 'sequential'
150
- */
151
- mode?: 'sequential' | 'parallel';
152
- onStart?: (files: Array<FileNode>) => Promise<void> | void;
153
- onEnd?: (files: Array<FileNode>) => Promise<void> | void;
154
- onUpdate?: (params: {
155
- file: FileNode;
156
- source?: string;
157
- processed: number;
158
- total: number;
159
- percentage: number;
160
- }) => Promise<void> | void;
161
- };
96
+ //#region src/reporters/cliReporter.d.ts
162
97
  /**
163
- * Converts a single file to a string using the registered parsers.
164
- * Falls back to joining source values when no matching parser is found.
98
+ * The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
99
+ * of the live logger view. Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
100
+ */
101
+ declare const cliReporter: Reporter;
102
+ //#endregion
103
+ //#region src/reporters/fileReporter.d.ts
104
+ /**
105
+ * The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
106
+ * plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
107
+ * cli and json reporters expose, a `## Problems` section in the miette block format, and a
108
+ * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`).
165
109
  *
166
- * @internal
110
+ * @note It captures the collected diagnostics once a config finishes, not the live
111
+ * `kubb:info`/`kubb:plugin` event stream. Color is stripped so the file stays plain text even when
112
+ * the run is attached to a TTY.
167
113
  */
168
- declare class FileProcessor {
169
- #private;
170
- parse(file: FileNode, {
171
- parsers,
172
- extension
173
- }?: ParseOptions): Promise<string>;
174
- run(files: Array<FileNode>, {
175
- parsers,
176
- mode,
177
- extension,
178
- onStart,
179
- onEnd,
180
- onUpdate
181
- }?: RunOptions): Promise<Array<FileNode>>;
182
- }
114
+ declare const fileReporter: Reporter;
115
+ //#endregion
116
+ //#region src/reporters/jsonReporter.d.ts
117
+ /**
118
+ * The `json` reporter. `report` returns one config's {@link Report}, which {@link createReporter}
119
+ * buffers, and `drain` writes them as a single pretty-printed JSON array on `kubb:lifecycle:end`.
120
+ * Buffering keeps a multi-config run one valid JSON document on stdout instead of concatenated
121
+ * objects that would break `jq .`. The terminal reporter is suppressed while `json` is active so
122
+ * stdout stays valid JSON.
123
+ */
124
+ declare const jsonReporter: Reporter;
183
125
  //#endregion
184
126
  //#region src/storages/fsStorage.d.ts
185
127
  /**
@@ -189,11 +131,11 @@ declare class FileProcessor {
189
131
  * Keys are resolved against `process.cwd()`, so root-relative paths such as
190
132
  * `src/gen/api/getPets.ts` are written to the correct location without extra configuration.
191
133
  *
192
- * Internally uses the `write` utility from `@internals/utils`, which:
193
- * - trims leading/trailing whitespace before writing
194
- * - skips the write when file content is already identical (deduplication)
195
- * - creates missing parent directories automatically
196
- * - supports Bun's native file API when running under Bun
134
+ * Writes are deduplicated and directory-safe:
135
+ * - leading and trailing whitespace is trimmed before writing
136
+ * - the write is skipped when the file content is already identical
137
+ * - missing parent directories are created automatically
138
+ * - Bun's native file API is used when running under Bun
197
139
  *
198
140
  * @example
199
141
  * ```ts
@@ -231,5 +173,5 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
231
173
  */
232
174
  declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
233
175
  //#endregion
234
- export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BuildOutput, CLIOptions, Config, DevtoolsOptions, Exclude, FileManager, FileProcessor, Generator, GeneratorContext, Group, Include, InputData, InputPath, Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbConfigEndContext, KubbDebugContext, KubbErrorContext, KubbFileProcessingUpdateContext, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbVersionNewContext, KubbWarnContext, Logger, LoggerContext, LoggerOptions, Middleware, NormalizedPlugin, Output, Override, Parser, Plugin, PluginDriver, PluginFactoryOptions, PossibleConfig, Renderer, RendererFactory, ResolveBannerContext, ResolveOptionsContext, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, URLPath, UserConfig, UserLogger, ast, createAdapter, createKubb, createRenderer, createStorage, defineGenerator, defineLogger, defineMiddleware, defineParser, definePlugin, defineResolver, fsStorage, isInputPath, logLevel, memoryStorage };
176
+ export { type Adapter, type AdapterFactoryOptions, type AdapterSource, AsyncEventEmitter, type BannerMeta, BuildOutput, CLIOptions, Config, type Diagnostic, type DiagnosticByCode, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileProcessorHooks, type GenerationResult, type Generator, type GeneratorContext, type Group, type Include, InputData, InputPath, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type ParsedFile, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, PossibleConfig, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type SerializedDiagnostic, type Storage, type UpdateDiagnostic, Url, UserConfig, type UserReporter, ast, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage };
235
177
  //# sourceMappingURL=index.d.ts.map