@kubb/core 5.0.0-beta.67 → 5.0.0-beta.69
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/README.md +1 -1
- package/dist/{diagnostics-M8ckppMO.d.ts → diagnostics-CJtO1uSM.d.ts} +10 -25
- package/dist/index.cjs +8 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -166
- package/dist/index.js.map +1 -1
- package/dist/{memoryStorage-D0gb5tRV.js → memoryStorage-B4VTTIpQ.js} +198 -7
- package/dist/memoryStorage-B4VTTIpQ.js.map +1 -0
- package/dist/{memoryStorage-67VG6jZn.cjs → memoryStorage-CfycFGzX.cjs} +227 -6
- package/dist/memoryStorage-CfycFGzX.cjs.map +1 -0
- package/dist/mocks.cjs +2 -2
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +2 -2
- package/dist/mocks.js.map +1 -1
- package/package.json +6 -6
- package/dist/memoryStorage-67VG6jZn.cjs.map +0 -1
- package/dist/memoryStorage-D0gb5tRV.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
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-CJtO1uSM.js";
|
|
3
3
|
import { ast } from "@kubb/ast";
|
|
4
4
|
|
|
5
5
|
//#region ../../internals/utils/src/url.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { a as createStorage, c as
|
|
3
|
-
import { hash } from "node:crypto";
|
|
2
|
+
import { _ as getErrorMessage, a as createStorage, c as clean, d as write, f as runtime, g as BuildError, h as AsyncEventEmitter, i as FileManager, l as toFilePath, m as pascalCase, n as _usingCtx, o as OPERATION_FILTER_TYPES, p as camelCase, r as FileProcessor, s as diagnosticCode, t as memoryStorage, u as toPosixPath } from "./memoryStorage-B4VTTIpQ.js";
|
|
4
3
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
4
|
+
import { hash } from "node:crypto";
|
|
5
|
+
import { access, glob, readFile, rm } from "node:fs/promises";
|
|
6
|
+
import path, { join, relative, resolve } from "node:path";
|
|
7
7
|
import { ast, ast as ast$1, composeMacros, operationDef, schemaDef, transform } from "@kubb/ast";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
9
|
import { collectUsedSchemaNames } from "@kubb/ast/utils";
|
|
@@ -94,167 +94,6 @@ function randomCliColor(text) {
|
|
|
94
94
|
return styleText(randomColors[hash("sha256", text, "buffer").readUInt32BE(0) % randomColors.length] ?? "white", text);
|
|
95
95
|
}
|
|
96
96
|
//#endregion
|
|
97
|
-
//#region ../../internals/utils/src/runtime.ts
|
|
98
|
-
/**
|
|
99
|
-
* Detects the JavaScript runtime executing the current process and exposes its name and version.
|
|
100
|
-
*
|
|
101
|
-
* Prefer the shared {@link runtime} instance over constructing your own.
|
|
102
|
-
*/
|
|
103
|
-
var Runtime = class {
|
|
104
|
-
/**
|
|
105
|
-
* `true` when the current process is running under Bun.
|
|
106
|
-
*
|
|
107
|
-
* Detection keys off the global `Bun` object rather than `process.versions`,
|
|
108
|
-
* because Bun polyfills `process.versions.node` for Node compatibility and would
|
|
109
|
-
* otherwise look like Node.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```ts
|
|
113
|
-
* if (runtime.isBun) {
|
|
114
|
-
* await Bun.write(path, data)
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
get isBun() {
|
|
119
|
-
return typeof Bun !== "undefined";
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* `true` when the current process is running under Deno.
|
|
123
|
-
*/
|
|
124
|
-
get isDeno() {
|
|
125
|
-
return typeof globalThis.Deno !== "undefined";
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* `true` when the current process is running under Node.
|
|
129
|
-
*
|
|
130
|
-
* Bun and Deno are excluded first so a polyfilled `process` does not register as Node.
|
|
131
|
-
*/
|
|
132
|
-
get isNode() {
|
|
133
|
-
return !this.isBun && !this.isDeno && typeof process !== "undefined" && process.versions?.node != null;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Name of the runtime executing the current process.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
get name() {
|
|
144
|
-
if (this.isBun) return "bun";
|
|
145
|
-
if (this.isDeno) return "deno";
|
|
146
|
-
return "node";
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Version of the active runtime, or an empty string when it cannot be read.
|
|
150
|
-
*
|
|
151
|
-
* @example
|
|
152
|
-
* ```ts
|
|
153
|
-
* runtime.version // '1.3.11' under Bun, '22.22.2' under Node
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
|
-
get version() {
|
|
157
|
-
if (this.isBun) return process.versions.bun ?? "";
|
|
158
|
-
if (this.isDeno) return globalThis.Deno?.version?.deno ?? "";
|
|
159
|
-
return process.versions?.node ?? "";
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.
|
|
164
|
-
*/
|
|
165
|
-
const runtime = new Runtime();
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region ../../internals/utils/src/fs.ts
|
|
168
|
-
/**
|
|
169
|
-
* Writes `data` to `path`, trimming leading/trailing whitespace before saving.
|
|
170
|
-
* Skips the write when the trimmed content is empty or identical to what is already on disk.
|
|
171
|
-
* Creates any missing parent directories automatically.
|
|
172
|
-
* When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* ```ts
|
|
176
|
-
* await write('./src/Pet.ts', source) // writes and returns trimmed content
|
|
177
|
-
* await write('./src/Pet.ts', source) // null — file unchanged
|
|
178
|
-
* await write('./src/Pet.ts', ' ') // null — empty content skipped
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
async function write(path, data, options = {}) {
|
|
182
|
-
const trimmed = data.trim();
|
|
183
|
-
if (trimmed === "") return null;
|
|
184
|
-
const resolved = resolve(path);
|
|
185
|
-
if (runtime.isBun) {
|
|
186
|
-
const file = Bun.file(resolved);
|
|
187
|
-
if ((await file.exists() ? await file.text() : null) === trimmed) return null;
|
|
188
|
-
await Bun.write(resolved, trimmed);
|
|
189
|
-
return trimmed;
|
|
190
|
-
}
|
|
191
|
-
try {
|
|
192
|
-
if (await readFile(resolved, { encoding: "utf-8" }) === trimmed) return null;
|
|
193
|
-
} catch {}
|
|
194
|
-
await mkdir(dirname(resolved), { recursive: true });
|
|
195
|
-
await writeFile(resolved, trimmed, { encoding: "utf-8" });
|
|
196
|
-
if (options.sanity) {
|
|
197
|
-
const savedData = await readFile(resolved, { encoding: "utf-8" });
|
|
198
|
-
if (savedData !== trimmed) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
199
|
-
return savedData;
|
|
200
|
-
}
|
|
201
|
-
return trimmed;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Recursively removes `path`. Silently succeeds when `path` does not exist.
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```ts
|
|
208
|
-
* await clean('./dist')
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
async function clean(path) {
|
|
212
|
-
return rm(path, {
|
|
213
|
-
recursive: true,
|
|
214
|
-
force: true
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Converts a filesystem path to use POSIX (`/`) separators.
|
|
219
|
-
*
|
|
220
|
-
* Most of the codebase compares and composes paths as strings (prefix matching, joining for
|
|
221
|
-
* import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated
|
|
222
|
-
* paths, but on Windows it returns `\`-separated paths, which breaks every such comparison.
|
|
223
|
-
*
|
|
224
|
-
* Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the
|
|
225
|
-
* code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is
|
|
226
|
-
* exercisable from POSIX CI.
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* toPosixPath('C:\\repo\\src\\pet.ts') // 'C:/repo/src/pet.ts'
|
|
230
|
-
*/
|
|
231
|
-
function toPosixPath(filePath) {
|
|
232
|
-
return filePath.replaceAll("\\", "/");
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Builds a nested file path from a dotted name. Splits on dots that precede a letter
|
|
236
|
-
* (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases
|
|
237
|
-
* every earlier segment, applies `caseLast` to the final segment, and joins with `/`.
|
|
238
|
-
*
|
|
239
|
-
* Empty segments are dropped before joining. They arise when the name starts with a dot
|
|
240
|
-
* followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to
|
|
241
|
-
* an empty string). Without this a leading `/` would form, which `path.resolve` reads as an
|
|
242
|
-
* absolute path, letting generated files escape the configured output directory.
|
|
243
|
-
*
|
|
244
|
-
* @example Nested path from a dotted name
|
|
245
|
-
* `toFilePath('pet.petId') // 'pet/petId'`
|
|
246
|
-
*
|
|
247
|
-
* @example PascalCase the final segment
|
|
248
|
-
* `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`
|
|
249
|
-
*
|
|
250
|
-
* @example Suffix applied to the final segment only
|
|
251
|
-
* `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`
|
|
252
|
-
*/
|
|
253
|
-
function toFilePath(name, caseLast = camelCase) {
|
|
254
|
-
const parts = name.split(/\.(?=[a-zA-Z])/);
|
|
255
|
-
return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : camelCase(part)).filter(Boolean).join("/");
|
|
256
|
-
}
|
|
257
|
-
//#endregion
|
|
258
97
|
//#region ../../internals/utils/src/promise.ts
|
|
259
98
|
function* chunks(arr, size) {
|
|
260
99
|
for (let i = 0; i < arr.length; i += size) yield arr.slice(i, i + size);
|
|
@@ -606,7 +445,7 @@ function createAdapter(build) {
|
|
|
606
445
|
/**
|
|
607
446
|
* Docs major version, derived from the package version so the link tracks the published major.
|
|
608
447
|
*/
|
|
609
|
-
const docsMajor = "5.0.0-beta.
|
|
448
|
+
const docsMajor = "5.0.0-beta.69".split(".")[0] ?? "5";
|
|
610
449
|
/**
|
|
611
450
|
* Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
|
|
612
451
|
*
|