@kubb/core 5.9.3 → 5.9.5
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/{KubbDriver-C0hejO6L.js → Hookable-Cs4D9tMH.js} +147 -293
- package/dist/Hookable-Cs4D9tMH.js.map +1 -0
- package/dist/{KubbDriver-CrzfVOkH.cjs → Hookable-D0nxPjEd.cjs} +144 -308
- package/dist/Hookable-D0nxPjEd.cjs.map +1 -0
- package/dist/{createAdapter-DfbfcqcJ.d.ts → createAdapter-D55JE9lX.d.ts} +16 -76
- package/dist/index.cjs +91 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -28
- package/dist/index.js +33 -81
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +9 -9
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +2 -2
- package/dist/KubbDriver-C0hejO6L.js.map +0 -1
- package/dist/KubbDriver-CrzfVOkH.cjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
-
import { $ as NodeCache, $t as
|
|
2
|
+
import { $ as NodeCache, $t as UpdateDiagnostic, A as PluginFactory, At as RunHookOptions, B as ResolveImportsOptions, Bt as UserReporter, C as NormalizedPlugin, Ct as KubbPluginsEndContext, D as Override, Dt as PostGenerateCommand, E as OutputOptions, Et as PossibleConfig, F as definePlugin, Ft as GenerationResult, G as ResolverFile, Gt as DiagnosticKind, H as ResolvePathOptions, Ht as logLevel, I as BannerMeta, It as Reporter, J as ResolverPatch, Jt as Diagnostics, K as ResolverFileParams, Kt as DiagnosticLocation, L as ResolveBannerContext, Lt as ReporterContext, M as PluginType, Mt as KubbDriver, N as ResolvePluginOptions, Nt as Storage, O as Plugin, Ot as UserConfig, P as assertPluginOption, Pt as createStorage, Q as defineGenerator, Qt as SerializedDiagnostic, R as ResolveBannerFile, Rt as ReporterName, S as KubbPluginStartContext, St as KubbMessageContext, T as OutputMode, Tt as KubbWarnContext, U as Resolver, Ut as Diagnostic, V as ResolveOptionsContext, Vt as createReporter, W as ResolverDefault, Wt as DiagnosticDoc, X as Generator, Xt as ProblemCode, Y as ResolverPathParams, Yt as PerformanceDiagnostic, Z as GeneratorContext, Zt as ProblemDiagnostic, _ as Filter, _t as KubbHookLineContext, a as AdapterSource, an as ParserDefinition, at as KubbBuildEndContext, b as KubbPluginEndContext, bt as KubbInfoContext, c as ExtensionDependency, ct as KubbErrorContext, d as ExtensionKind, dt as KubbFilesProcessingStartContext, en as Hookable, et as BuildOutput, f as ExtensionMeta, ft as KubbFilesProcessingUpdateContext, g as Exclude, gt as KubbHookEndContext, h as resolveMeta, ht as KubbGenerationSummaryContext, i as AdapterFactoryOptions, in as Parser, it as Input, j as PluginName, jt as runHook, k as PluginDefinition, kt as HookResult, l as ExtensionDependencyRecord, lt as KubbFileProcessingUpdate, m as defineExtension, mt as KubbGenerationStartContext, n as AdapterDefinition, nn as RendererFactory, nt as Config, o as createAdapter, on as ParserFactory, ot as KubbBuildStartContext, p as checkCompatibility, pt as KubbGenerationEndContext, q as ResolverFilePathParams, qt as DiagnosticSeverity, r as AdapterFactory, rn as createRenderer, rt as FilesContext, s as ExtensionDependencies, sn as defineParser, st as KubbDiagnosticContext, t as Adapter, tn as Renderer, tt as CLIOptions, u as ExtensionFactory, ut as KubbFilesProcessingEndContext, v as Group, vt as KubbHookStartContext, w as Output, wt as KubbSuccessContext, x as KubbPluginSetupContext, xt as KubbLifecycleStartContext, y as Include, yt as KubbHooks, z as ResolveFileOptions, zt as ReporterPluginFiles } from "./createAdapter-D55JE9lX.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { FileNode, Macro, UserFileNode } from "@kubb/ast";
|
|
5
|
-
//#region src/applyConfigDefaults.d.ts
|
|
6
|
-
type ApplyConfigDefaultsOptions<TOutput> = {
|
|
7
|
-
defaultAdapter: Adapter;
|
|
8
|
-
barrelPlugin: Plugin;
|
|
9
|
-
barrelPluginName: string;
|
|
10
|
-
/** Output fields to fill in when the user's config leaves them unset. */
|
|
11
|
-
defaultOutput: Partial<TOutput>;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Fills in the config defaults shared by `defineConfig` and the unplugin factory: the fallback
|
|
15
|
-
* adapter, `defaultOutput`'s fields, and appending the barrel plugin when it's not already
|
|
16
|
-
* registered. Both entry points construct their own adapter, barrel plugin, and output defaults
|
|
17
|
-
* (`barrel` is a `@kubb/plugin-barrel` extension field core doesn't know about) and pass them in,
|
|
18
|
-
* so `@kubb/core` doesn't need to depend on `@kubb/adapter-oas` or `@kubb/plugin-barrel`.
|
|
19
|
-
*/
|
|
20
|
-
export declare function applyConfigDefaults<TOutput extends Config['output'] = Config['output']>(config: {
|
|
21
|
-
adapter?: Adapter;
|
|
22
|
-
output: TOutput;
|
|
23
|
-
plugins?: Array<Plugin>;
|
|
24
|
-
}, { defaultAdapter, barrelPlugin, barrelPluginName, defaultOutput }: ApplyConfigDefaultsOptions<TOutput>): {
|
|
25
|
-
adapter: Adapter;
|
|
26
|
-
output: TOutput;
|
|
27
|
-
plugins: Array<Plugin>;
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
5
|
//#region src/composables.d.ts
|
|
31
6
|
/**
|
|
32
7
|
* Holds the setup context of the plugin whose `setup` or `kubb:plugin:setup` is running. `KubbDriver` sets it for each plugin.
|
|
@@ -408,7 +383,6 @@ export declare const cacheStorage: (options?: CacheStorageOptions | undefined) =
|
|
|
408
383
|
* - the write is skipped when the file already holds that content, ignoring any trailing newline
|
|
409
384
|
* a formatter left behind
|
|
410
385
|
* - missing parent directories are created automatically
|
|
411
|
-
* - Bun's native file API is used when running under Bun
|
|
412
386
|
* - `FileManager.write` bounds in-flight writes, so this driver does not pace itself
|
|
413
387
|
*
|
|
414
388
|
* @example
|
|
@@ -643,5 +617,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
|
|
|
643
617
|
resolveFrom?: Array<string>;
|
|
644
618
|
}): Promise<Array<InstalledPackage>>;
|
|
645
619
|
//#endregion
|
|
646
|
-
export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta,
|
|
620
|
+
export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, FilesContext, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, type HookResult, Hookable, type Include, Input, type InputKind, type InstalledPackage, type JSONValue, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbMessageContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type PerformanceDiagnostic, type Plugin, type PluginDefinition, type PluginFactory, type PluginName, type PluginType, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type RegistryArtifact, type RegistryDetail, type RegistryEntry, type RegistryGuide, type RegistryIndex, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, Resolver, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type RunHookOptions, type RunOutputPassesOptions, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, UserConfig, type UserReporter, assertPluginOption, checkCompatibility, createAdapter, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
|
|
647
621
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as inParallel, C as useOptions, D as Diagnostics, E as resolveMeta, F as toError, M as read, N as toPosixPath, O as formatMs, P as write, S as useKubb, T as defineExtension, _ as setMacros, b as tryUseKubb, c as Resolver, d as definePlugin, f as addGenerator, g as requirePlugin, h as kubbContext, j as isPathInside, k as getElapsedMs, l as getInputKind, m as injectFile, n as KubbDriver, o as _usingCtx, p as addMacro, s as createResolver, t as Hookable, u as assertPluginOption, v as setOptions, w as checkCompatibility, x as useConfig, y as setResolver } from "./Hookable-Cs4D9tMH.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { isValid } from "verkit";
|
|
5
5
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
@@ -153,37 +153,23 @@ function tokenize(command) {
|
|
|
153
153
|
}
|
|
154
154
|
//#endregion
|
|
155
155
|
//#region src/createAdapter.ts
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Defines a custom adapter that translates a spec format into Kubb's universal
|
|
158
|
+
* AST, for example GraphQL, gRPC, or AsyncAPI. The built-in `@kubb/adapter-oas`
|
|
159
|
+
* handles OpenAPI/Swagger documents.
|
|
160
|
+
*
|
|
161
|
+
* Adapters must return an `InputNode` from `parse`. That node is what every
|
|
162
|
+
* plugin in the build consumes.
|
|
163
|
+
*
|
|
164
|
+
* @deprecated Use `defineExtension` with `kind: 'adapter'` instead.
|
|
165
|
+
*/
|
|
166
|
+
function createAdapter(definition) {
|
|
161
167
|
return defineExtension({
|
|
162
168
|
kind: "adapter",
|
|
163
|
-
...
|
|
169
|
+
...definition
|
|
164
170
|
});
|
|
165
171
|
}
|
|
166
172
|
//#endregion
|
|
167
|
-
//#region src/applyConfigDefaults.ts
|
|
168
|
-
/**
|
|
169
|
-
* Fills in the config defaults shared by `defineConfig` and the unplugin factory: the fallback
|
|
170
|
-
* adapter, `defaultOutput`'s fields, and appending the barrel plugin when it's not already
|
|
171
|
-
* registered. Both entry points construct their own adapter, barrel plugin, and output defaults
|
|
172
|
-
* (`barrel` is a `@kubb/plugin-barrel` extension field core doesn't know about) and pass them in,
|
|
173
|
-
* so `@kubb/core` doesn't need to depend on `@kubb/adapter-oas` or `@kubb/plugin-barrel`.
|
|
174
|
-
*/
|
|
175
|
-
function applyConfigDefaults(config, { defaultAdapter, barrelPlugin, barrelPluginName, defaultOutput }) {
|
|
176
|
-
const plugins = config.plugins?.some((plugin) => plugin.name === barrelPluginName) ? config.plugins ?? [] : [...config.plugins ?? [], barrelPlugin];
|
|
177
|
-
return {
|
|
178
|
-
adapter: config.adapter ?? defaultAdapter,
|
|
179
|
-
plugins,
|
|
180
|
-
output: {
|
|
181
|
-
...defaultOutput,
|
|
182
|
-
...config.output
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
//#endregion
|
|
187
173
|
//#region src/outputManifest.ts
|
|
188
174
|
/**
|
|
189
175
|
* Bumped when the stored shape changes, so an older cache is discarded instead of misread.
|
|
@@ -263,9 +249,6 @@ async function createOutputManifest({ storage, cache }) {
|
|
|
263
249
|
*
|
|
264
250
|
* return {
|
|
265
251
|
* name: 'memory',
|
|
266
|
-
* async existsItem(key) {
|
|
267
|
-
* return store.has(key)
|
|
268
|
-
* },
|
|
269
252
|
* async readItem(key) {
|
|
270
253
|
* return store.get(key) ?? null
|
|
271
254
|
* },
|
|
@@ -286,9 +269,7 @@ async function createOutputManifest({ storage, cache }) {
|
|
|
286
269
|
* })
|
|
287
270
|
* ```
|
|
288
271
|
*/
|
|
289
|
-
|
|
290
|
-
return (options) => build(options ?? {});
|
|
291
|
-
}
|
|
272
|
+
const createStorage = (build) => (options) => build(options ?? {});
|
|
292
273
|
//#endregion
|
|
293
274
|
//#region src/storages/fsStorage.ts
|
|
294
275
|
/**
|
|
@@ -303,7 +284,6 @@ function createStorage(build) {
|
|
|
303
284
|
* - the write is skipped when the file already holds that content, ignoring any trailing newline
|
|
304
285
|
* a formatter left behind
|
|
305
286
|
* - missing parent directories are created automatically
|
|
306
|
-
* - Bun's native file API is used when running under Bun
|
|
307
287
|
* - `FileManager.write` bounds in-flight writes, so this driver does not pace itself
|
|
308
288
|
*
|
|
309
289
|
* @example
|
|
@@ -320,9 +300,6 @@ function createStorage(build) {
|
|
|
320
300
|
*/
|
|
321
301
|
const fsStorage = createStorage(() => ({
|
|
322
302
|
name: "fs",
|
|
323
|
-
async existsItem(key) {
|
|
324
|
-
return exists(resolve(key));
|
|
325
|
-
},
|
|
326
303
|
async readItem(key) {
|
|
327
304
|
try {
|
|
328
305
|
return await readFile(resolve(key), "utf8");
|
|
@@ -352,7 +329,10 @@ const fsStorage = createStorage(() => ({
|
|
|
352
329
|
},
|
|
353
330
|
async empty(base) {
|
|
354
331
|
if (!base) return;
|
|
355
|
-
await
|
|
332
|
+
await rm(resolve(base), {
|
|
333
|
+
recursive: true,
|
|
334
|
+
force: true
|
|
335
|
+
});
|
|
356
336
|
}
|
|
357
337
|
}));
|
|
358
338
|
//#endregion
|
|
@@ -384,29 +364,15 @@ function resolveCacheDir(root) {
|
|
|
384
364
|
*/
|
|
385
365
|
const cacheStorage = createStorage(({ root = process.cwd() }) => {
|
|
386
366
|
const dir = resolveCacheDir(root);
|
|
387
|
-
const
|
|
367
|
+
const fs = fsStorage();
|
|
388
368
|
const toPath = (key) => join(dir, key);
|
|
389
369
|
return {
|
|
390
370
|
name: "cache",
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
},
|
|
397
|
-
async writeItem(key, value) {
|
|
398
|
-
return storage.writeItem(toPath(key), value);
|
|
399
|
-
},
|
|
400
|
-
async removeItem(key) {
|
|
401
|
-
return storage.removeItem(toPath(key));
|
|
402
|
-
},
|
|
403
|
-
async readKeys(base) {
|
|
404
|
-
return storage.readKeys(base ? toPath(base) : dir);
|
|
405
|
-
},
|
|
406
|
-
async empty(base) {
|
|
407
|
-
if (!base) return;
|
|
408
|
-
return storage.empty(toPath(base));
|
|
409
|
-
}
|
|
371
|
+
readItem: (key) => fs.readItem(toPath(key)),
|
|
372
|
+
writeItem: (key, value) => fs.writeItem(toPath(key), value),
|
|
373
|
+
removeItem: (key) => fs.removeItem(toPath(key)),
|
|
374
|
+
readKeys: (base) => fs.readKeys(base ? toPath(base) : dir),
|
|
375
|
+
empty: async (base) => base ? fs.empty(toPath(base)) : void 0
|
|
410
376
|
};
|
|
411
377
|
});
|
|
412
378
|
//#endregion
|
|
@@ -604,8 +570,6 @@ async function runOutputPasses({ config, outputPath, hooks, signal }) {
|
|
|
604
570
|
}
|
|
605
571
|
//#endregion
|
|
606
572
|
//#region src/createKubb.ts
|
|
607
|
-
/** Upper bound of listeners one plugin adds to a hook, sizing the emitter ceiling for large plugin sets. */
|
|
608
|
-
const HOOK_LISTENERS_PER_PLUGIN = 4;
|
|
609
573
|
function resolveConfig(userConfig) {
|
|
610
574
|
return {
|
|
611
575
|
...userConfig,
|
|
@@ -682,7 +646,6 @@ var Kubb = class {
|
|
|
682
646
|
storage: config.storage,
|
|
683
647
|
cache: cacheStorage({ root: config.root })
|
|
684
648
|
}) : void 0;
|
|
685
|
-
this.hooks.setMaxListeners(Math.max(10, config.plugins.length * HOOK_LISTENERS_PER_PLUGIN));
|
|
686
649
|
const cleanPath = config.output.clean ? resolve(config.root, config.output.path) : void 0;
|
|
687
650
|
if (cleanPath && isPathInside(config.root, cleanPath)) throw new Diagnostics.Error({
|
|
688
651
|
code: Diagnostics.code.cleanRoot,
|
|
@@ -886,9 +849,6 @@ function createReporter(reporter) {
|
|
|
886
849
|
async drain(context) {
|
|
887
850
|
await reporter.drain?.(context, [...reports]);
|
|
888
851
|
reports.length = 0;
|
|
889
|
-
},
|
|
890
|
-
[Symbol.dispose]() {
|
|
891
|
-
reports.length = 0;
|
|
892
852
|
}
|
|
893
853
|
};
|
|
894
854
|
}
|
|
@@ -1209,21 +1169,16 @@ function defineGenerator(generator) {
|
|
|
1209
1169
|
}
|
|
1210
1170
|
//#endregion
|
|
1211
1171
|
//#region src/defineParser.ts
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
meta: resolveMeta(parser)
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
});
|
|
1172
|
+
/**
|
|
1173
|
+
* Defines a parser from one object and returns a factory that takes the user's options.
|
|
1174
|
+
* Register the result in the `parsers` array on `defineConfig`.
|
|
1175
|
+
*
|
|
1176
|
+
* @deprecated Use `defineExtension` with `kind: 'parser'` instead.
|
|
1177
|
+
*/
|
|
1178
|
+
function defineParser(definition) {
|
|
1223
1179
|
return defineExtension({
|
|
1224
1180
|
kind: "parser",
|
|
1225
|
-
|
|
1226
|
-
build: "build" in input ? input.build : input.setup
|
|
1181
|
+
...definition
|
|
1227
1182
|
});
|
|
1228
1183
|
}
|
|
1229
1184
|
//#endregion
|
|
@@ -1251,9 +1206,6 @@ const memoryStorage = createStorage(() => {
|
|
|
1251
1206
|
const store = /* @__PURE__ */ new Map();
|
|
1252
1207
|
return {
|
|
1253
1208
|
name: "memory",
|
|
1254
|
-
async existsItem(key) {
|
|
1255
|
-
return store.has(key);
|
|
1256
|
-
},
|
|
1257
1209
|
async readItem(key) {
|
|
1258
1210
|
return store.get(key) ?? null;
|
|
1259
1211
|
},
|
|
@@ -1402,6 +1354,6 @@ async function readInstalledPackages({ root, packages = [], resolveFrom = [] })
|
|
|
1402
1354
|
}));
|
|
1403
1355
|
}
|
|
1404
1356
|
//#endregion
|
|
1405
|
-
export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro,
|
|
1357
|
+
export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, checkCompatibility, cliReporter, createAdapter, createCliReporter, createKubb, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, injectFile, isExtensionManifest, isPackageName, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memoryStorage, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
1406
1358
|
|
|
1407
1359
|
//# sourceMappingURL=index.js.map
|