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

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-DcFh-77r.d.ts +2889 -0
  4. package/dist/index.cjs +2349 -1107
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +79 -138
  7. package/dist/index.js +2344 -1101
  8. package/dist/index.js.map +1 -1
  9. package/dist/memoryStorage-BjUIqpYE.js +883 -0
  10. package/dist/memoryStorage-BjUIqpYE.js.map +1 -0
  11. package/dist/memoryStorage-DQ6qXJ8o.cjs +1021 -0
  12. package/dist/memoryStorage-DQ6qXJ8o.cjs.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 +8 -26
  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,34 @@
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-DcFh-77r.js";
5
3
 
6
- //#region ../../internals/utils/src/urlPath.d.ts
4
+ //#region ../../internals/utils/src/url.d.ts
7
5
  type URLObject = {
8
6
  /**
9
7
  * The resolved URL string (Express-style or template literal, depending on context).
10
8
  */
11
9
  url: string;
12
10
  /**
13
- * Extracted path parameters as a key-value map, or `undefined` when the path has none.
11
+ * Extracted path parameters as a key-value map, or `null` when the path has none.
14
12
  */
15
- params?: Record<string, string>;
13
+ params: Record<string, string> | null;
14
+ };
15
+ /**
16
+ * Supported identifier casing strategies for path parameters.
17
+ */
18
+ type PathCasing = 'camelcase';
19
+ type TemplateOptions = {
20
+ /**
21
+ * Literal text prepended inside the template literal, e.g. a base URL.
22
+ */
23
+ prefix?: string | null;
24
+ /**
25
+ * Transform applied to each extracted parameter name before interpolation.
26
+ */
27
+ replacer?: (pathParam: string) => string;
28
+ /**
29
+ * Casing strategy applied to path parameter names.
30
+ */
31
+ casing?: PathCasing;
16
32
  };
17
33
  type ObjectOptions = {
18
34
  /**
@@ -21,165 +37,90 @@ type ObjectOptions = {
21
37
  */
22
38
  type?: 'path' | 'template';
23
39
  /**
24
- * Optional transform applied to each extracted parameter name.
40
+ * Transform applied to each extracted parameter name.
25
41
  */
26
42
  replacer?: (pathParam: string) => string;
27
43
  /**
28
44
  * When `true`, the result is serialized to a string expression instead of a plain object.
29
45
  */
30
46
  stringify?: boolean;
31
- };
32
- /**
33
- * Supported identifier casing strategies for path parameters.
34
- */
35
- type PathCasing = 'camelcase';
36
- type Options = {
37
47
  /**
38
48
  * Casing strategy applied to path parameter names.
39
- * @default undefined (original identifier preserved)
40
49
  */
41
50
  casing?: PathCasing;
42
51
  };
43
52
  /**
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}`'
53
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
50
54
  */
51
- declare class URLPath {
52
- #private;
55
+ declare class Url {
53
56
  /**
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://`).
57
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
67
58
  *
68
59
  * @example
69
- * ```ts
70
- * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
71
- * new URLPath('/pet/{petId}').isURL // false
72
- * ```
60
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
73
61
  */
74
- get isURL(): boolean;
62
+ static toPath(path: string): string;
75
63
  /**
76
- * Converts the OpenAPI path to a TypeScript template literal string.
64
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
65
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
66
+ * and `casing` controls parameter identifier casing.
77
67
  *
78
68
  * @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.
69
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
84
70
  *
85
71
  * @example
86
- * ```ts
87
- * new URLPath('/pet/{petId}').object
88
- * // { url: '/pet/:petId', params: { petId: 'petId' } }
89
- * ```
72
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
90
73
  */
91
- get object(): URLObject | string;
92
- /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
74
+ static toTemplateString(path: string, {
75
+ prefix,
76
+ replacer,
77
+ casing
78
+ }?: TemplateOptions): string;
79
+ /**
80
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
81
+ * expression when `stringify` is set.
93
82
  *
94
83
  * @example
95
- * ```ts
96
- * new URLPath('/pet/{petId}').params // { petId: 'petId' }
97
- * new URLPath('/pet').params // undefined
98
- * ```
84
+ * Url.toObject('/pet/{petId}')
85
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
99
86
  */
100
- get params(): Record<string, string> | undefined;
101
- toObject({
87
+ static toObject(path: string, {
102
88
  type,
103
89
  replacer,
104
- stringify
90
+ stringify,
91
+ casing
105
92
  }?: 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
93
  }
141
94
  //#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
- };
95
+ //#region src/reporters/cliReporter.d.ts
162
96
  /**
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.
97
+ * The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
98
+ * of the live logger view. Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
99
+ */
100
+ declare const cliReporter: Reporter;
101
+ //#endregion
102
+ //#region src/reporters/fileReporter.d.ts
103
+ /**
104
+ * The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
105
+ * plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
106
+ * cli and json reporters expose, a `## Problems` section in the miette block format, and a
107
+ * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`).
165
108
  *
166
- * @internal
109
+ * @note It captures the collected diagnostics once a config finishes, not the live
110
+ * `kubb:info`/`kubb:plugin` event stream. Color is stripped so the file stays plain text even when
111
+ * the run is attached to a TTY.
167
112
  */
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
- }
113
+ declare const fileReporter: Reporter;
114
+ //#endregion
115
+ //#region src/reporters/jsonReporter.d.ts
116
+ /**
117
+ * The `json` reporter. `report` returns one config's {@link Report}, which {@link createReporter}
118
+ * buffers, and `drain` writes them as a single pretty-printed JSON array on `kubb:lifecycle:end`.
119
+ * Buffering keeps a multi-config run one valid JSON document on stdout instead of concatenated
120
+ * objects that would break `jq .`. The terminal reporter is suppressed while `json` is active so
121
+ * stdout stays valid JSON.
122
+ */
123
+ declare const jsonReporter: Reporter;
183
124
  //#endregion
184
125
  //#region src/storages/fsStorage.d.ts
185
126
  /**
@@ -189,11 +130,11 @@ declare class FileProcessor {
189
130
  * Keys are resolved against `process.cwd()`, so root-relative paths such as
190
131
  * `src/gen/api/getPets.ts` are written to the correct location without extra configuration.
191
132
  *
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
133
+ * Writes are deduplicated and directory-safe:
134
+ * - leading and trailing whitespace is trimmed before writing
135
+ * - the write is skipped when the file content is already identical
136
+ * - missing parent directories are created automatically
137
+ * - Bun's native file API is used when running under Bun
197
138
  *
198
139
  * @example
199
140
  * ```ts
@@ -231,5 +172,5 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
231
172
  */
232
173
  declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
233
174
  //#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 };
175
+ 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, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage };
235
176
  //# sourceMappingURL=index.d.ts.map