@kubb/core 5.0.0-beta.54 → 5.0.0-beta.55
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/{diagnostics-D_LOtOCv.d.ts → diagnostics-Bf2bC8lV.d.ts} +10 -159
- package/dist/index.cjs +154 -459
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -143
- package/dist/index.js +157 -459
- package/dist/index.js.map +1 -1
- package/dist/{memoryStorage-Bdv42rxp.js → memoryStorage-B0W-w994.js} +14 -39
- package/dist/memoryStorage-B0W-w994.js.map +1 -0
- package/dist/{memoryStorage-CIEzDI6b.cjs → memoryStorage-skOz0dXZ.cjs} +14 -39
- package/dist/memoryStorage-skOz0dXZ.cjs.map +1 -0
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +4 -4
- package/src/KubbDriver.ts +7 -71
- package/src/createAdapter.ts +3 -3
- package/src/createKubb.ts +0 -3
- package/src/defineResolver.ts +4 -4
- package/src/index.ts +1 -3
- package/src/storages/fsStorage.ts +7 -7
- package/src/types.ts +1 -34
- package/dist/memoryStorage-Bdv42rxp.js.map +0 -1
- package/dist/memoryStorage-CIEzDI6b.cjs.map +0 -1
- package/src/Fingerprint.ts +0 -97
- package/src/caches/fsCache.ts +0 -185
- package/src/createCache.ts +0 -74
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-C0LytTxp.js";
|
|
2
|
-
import { FileNode, HttpMethod, ImportNode, InputMeta, InputNode,
|
|
2
|
+
import { FileNode, HttpMethod, ImportNode, InputMeta, InputNode, Node, OperationNode, SchemaNode, UserFileNode, Visitor } from "@kubb/ast";
|
|
3
3
|
|
|
4
4
|
//#region ../../internals/utils/src/asyncEventEmitter.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A function that can be registered as an event listener, synchronous or async.
|
|
7
7
|
*/
|
|
8
|
-
type AsyncListener<TArgs extends unknown
|
|
8
|
+
type AsyncListener<TArgs extends Array<unknown>> = (...args: TArgs) => void | Promise<void>;
|
|
9
9
|
/**
|
|
10
10
|
* Typed `EventEmitter` that awaits all async listeners before resolving.
|
|
11
11
|
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
@@ -17,7 +17,7 @@ type AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise
|
|
|
17
17
|
* await emitter.emit('build', 'petstore') // all listeners awaited
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown
|
|
20
|
+
declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: Array<unknown> }> {
|
|
21
21
|
#private;
|
|
22
22
|
/**
|
|
23
23
|
* Maximum number of listeners per event before Node emits a memory-leak warning.
|
|
@@ -199,11 +199,11 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
199
199
|
/**
|
|
200
200
|
* Memory-efficient streaming variant of `parse()`.
|
|
201
201
|
*
|
|
202
|
-
* Returns an `
|
|
202
|
+
* Returns an `InputNode<true>` whose `schemas` and `operations` are `AsyncIterable`.
|
|
203
203
|
* Each `for await` loop creates a fresh parse pass over the cached in-memory document.
|
|
204
204
|
* No pre-built arrays are held in memory.
|
|
205
205
|
*/
|
|
206
|
-
stream?: (source: AdapterSource) => Promise<
|
|
206
|
+
stream?: (source: AdapterSource) => Promise<InputNode<true>>;
|
|
207
207
|
};
|
|
208
208
|
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
|
|
209
209
|
/**
|
|
@@ -238,83 +238,6 @@ type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) =
|
|
|
238
238
|
*/
|
|
239
239
|
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
|
|
240
240
|
//#endregion
|
|
241
|
-
//#region src/createCache.d.ts
|
|
242
|
-
/**
|
|
243
|
-
* A snapshot of a completed build: the final rendered source of every generated
|
|
244
|
-
* file, keyed by its path relative to the output root. Restoring a snapshot writes
|
|
245
|
-
* those sources straight to storage, skipping generation entirely.
|
|
246
|
-
*
|
|
247
|
-
* Paths are relative, not absolute, so the snapshot never depends on where the
|
|
248
|
-
* project lives on disk.
|
|
249
|
-
*/
|
|
250
|
-
type CachedSnapshot = {
|
|
251
|
-
/**
|
|
252
|
-
* Final source per output file, keyed by the path relative to
|
|
253
|
-
* `resolve(config.root, config.output.path)`.
|
|
254
|
-
*/
|
|
255
|
-
files: Record<string, string>;
|
|
256
|
-
};
|
|
257
|
-
/**
|
|
258
|
-
* Backend that stores build snapshots for incremental ("hot") rebuilds. When the
|
|
259
|
-
* input fingerprint matches a stored key, Kubb restores the snapshot instead of
|
|
260
|
-
* regenerating. Kubb ships with `fsCache` (local disk). Implement this interface to
|
|
261
|
-
* back the cache with any other store.
|
|
262
|
-
*
|
|
263
|
-
* @see {@link createCache} to build a custom backend.
|
|
264
|
-
*/
|
|
265
|
-
type Cache = {
|
|
266
|
-
/**
|
|
267
|
-
* Identifier used in logs and diagnostics (`'fs'`, `'memory'`).
|
|
268
|
-
*/
|
|
269
|
-
readonly name: string;
|
|
270
|
-
/**
|
|
271
|
-
* Returns the snapshot stored under `key`, or `null` on a miss. A backend never
|
|
272
|
-
* throws on a miss or a transient failure. It returns `null` so the build falls
|
|
273
|
-
* through to regeneration.
|
|
274
|
-
*/
|
|
275
|
-
restore(params: {
|
|
276
|
-
key: string;
|
|
277
|
-
}): Promise<CachedSnapshot | null>;
|
|
278
|
-
/**
|
|
279
|
-
* Stores `snapshot` under `key`. Only called after a successful build with no
|
|
280
|
-
* error diagnostics.
|
|
281
|
-
*/
|
|
282
|
-
persist(params: {
|
|
283
|
-
key: string;
|
|
284
|
-
snapshot: CachedSnapshot;
|
|
285
|
-
}): Promise<void>;
|
|
286
|
-
/**
|
|
287
|
-
* Optional teardown called after the build. Use to flush buffers or close
|
|
288
|
-
* connections.
|
|
289
|
-
*/
|
|
290
|
-
dispose?(): Promise<void>;
|
|
291
|
-
};
|
|
292
|
-
/**
|
|
293
|
-
* Defines a custom cache backend. The builder receives user options and returns a
|
|
294
|
-
* {@link Cache}. Reach for this when the filesystem backend doesn't fit, for
|
|
295
|
-
* example to store snapshots in Redis or a database.
|
|
296
|
-
*
|
|
297
|
-
* @example In-memory cache (the built-in implementation)
|
|
298
|
-
* ```ts
|
|
299
|
-
* import { createCache } from '@kubb/core'
|
|
300
|
-
*
|
|
301
|
-
* export const memoryCache = createCache(() => {
|
|
302
|
-
* const store = new Map<string, CachedSnapshot>()
|
|
303
|
-
*
|
|
304
|
-
* return {
|
|
305
|
-
* name: 'memory',
|
|
306
|
-
* async restore({ key }) {
|
|
307
|
-
* return store.get(key) ?? null
|
|
308
|
-
* },
|
|
309
|
-
* async persist({ key, snapshot }) {
|
|
310
|
-
* store.set(key, snapshot)
|
|
311
|
-
* },
|
|
312
|
-
* }
|
|
313
|
-
* })
|
|
314
|
-
* ```
|
|
315
|
-
*/
|
|
316
|
-
declare function createCache<TOptions = Record<string, never>>(build: (options: TOptions) => Cache): (options?: TOptions) => Cache;
|
|
317
|
-
//#endregion
|
|
318
241
|
//#region src/constants.d.ts
|
|
319
242
|
/**
|
|
320
243
|
* Stable codes Kubb attaches to a `Diagnostic`. Each maps to a known failure mode
|
|
@@ -1406,10 +1329,9 @@ declare class KubbDriver {
|
|
|
1406
1329
|
readonly config: Config;
|
|
1407
1330
|
readonly options: Options;
|
|
1408
1331
|
/**
|
|
1409
|
-
* The streaming `
|
|
1410
|
-
* Always set after adapter setup, parse-only adapters are wrapped automatically.
|
|
1332
|
+
* The streaming `InputNode<true>` produced by the adapter. * Always set after adapter setup, parse-only adapters are wrapped automatically.
|
|
1411
1333
|
*/
|
|
1412
|
-
inputNode:
|
|
1334
|
+
inputNode: InputNode<true> | null;
|
|
1413
1335
|
adapter: Adapter | null;
|
|
1414
1336
|
/**
|
|
1415
1337
|
* Central file store for all generated files.
|
|
@@ -1774,47 +1696,6 @@ type Parser<TMeta extends object = object, TNode = unknown> = {
|
|
|
1774
1696
|
*/
|
|
1775
1697
|
declare function defineParser<T extends Parser>(parser: T): T;
|
|
1776
1698
|
//#endregion
|
|
1777
|
-
//#region src/caches/fsCache.d.ts
|
|
1778
|
-
/**
|
|
1779
|
-
* Options for {@link fsCache}.
|
|
1780
|
-
*/
|
|
1781
|
-
type FsCacheOptions = {
|
|
1782
|
-
/**
|
|
1783
|
-
* Directory that holds the cache. Resolved against `process.cwd()` when relative.
|
|
1784
|
-
*
|
|
1785
|
-
* @default 'node_modules/.cache/kubb'
|
|
1786
|
-
*/
|
|
1787
|
-
dir?: string;
|
|
1788
|
-
/**
|
|
1789
|
-
* Maximum number of build snapshots to keep. The least-recently-used entries are
|
|
1790
|
-
* evicted once the cache grows past it.
|
|
1791
|
-
*
|
|
1792
|
-
* @default 50
|
|
1793
|
-
*/
|
|
1794
|
-
maxEntries?: number;
|
|
1795
|
-
/**
|
|
1796
|
-
* Days a snapshot may go untouched before it is evicted.
|
|
1797
|
-
*
|
|
1798
|
-
* @default 7
|
|
1799
|
-
*/
|
|
1800
|
-
ttlDays?: number;
|
|
1801
|
-
};
|
|
1802
|
-
/**
|
|
1803
|
-
* Local filesystem cache. Stores each build snapshot as content blobs plus an index,
|
|
1804
|
-
* tracked by a manifest under `node_modules/.cache/kubb/` (the Nx and Vitest
|
|
1805
|
-
* convention). Least-recently-used and expired entries are pruned on every persist.
|
|
1806
|
-
*
|
|
1807
|
-
* @example
|
|
1808
|
-
* ```ts
|
|
1809
|
-
* import { fsCache } from '@kubb/core'
|
|
1810
|
-
*
|
|
1811
|
-
* export default defineConfig({
|
|
1812
|
-
* cache: fsCache(),
|
|
1813
|
-
* })
|
|
1814
|
-
* ```
|
|
1815
|
-
*/
|
|
1816
|
-
declare const fsCache: (options?: FsCacheOptions | undefined) => Cache;
|
|
1817
|
-
//#endregion
|
|
1818
1699
|
//#region src/createKubb.d.ts
|
|
1819
1700
|
type CreateKubbOptions = {
|
|
1820
1701
|
hooks?: AsyncEventEmitter<KubbHooks>;
|
|
@@ -2133,26 +2014,6 @@ type Config<TInput = Input> = {
|
|
|
2133
2014
|
* @see {@link Storage} interface for implementing custom backends.
|
|
2134
2015
|
*/
|
|
2135
2016
|
storage: Storage;
|
|
2136
|
-
/**
|
|
2137
|
-
* Incremental build cache. Kubb fingerprints the inputs (spec content, config, plugin options,
|
|
2138
|
-
* versions) and, on an unchanged "hot" run, restores the previously generated output instead of
|
|
2139
|
-
* regenerating it. Same idea as Nx's computation cache.
|
|
2140
|
-
*
|
|
2141
|
-
* `defineConfig` enables `fsCache()` (local disk under `node_modules/.cache/kubb`) by default.
|
|
2142
|
-
* Pass another backend to change where snapshots live, or `false` to turn caching off. A bare
|
|
2143
|
-
* `createKubb` leaves it off unless a cache is provided.
|
|
2144
|
-
*
|
|
2145
|
-
* @example
|
|
2146
|
-
* ```ts
|
|
2147
|
-
* import { fsCache } from '@kubb/core'
|
|
2148
|
-
*
|
|
2149
|
-
* cache: fsCache({ dir: '.kubb-cache' })
|
|
2150
|
-
* cache: false
|
|
2151
|
-
* ```
|
|
2152
|
-
*
|
|
2153
|
-
* @see {@link Cache} interface for implementing custom backends.
|
|
2154
|
-
*/
|
|
2155
|
-
cache?: Cache;
|
|
2156
2017
|
/**
|
|
2157
2018
|
* Plugins that run during the build to generate code and transform the AST. Each one processes
|
|
2158
2019
|
* the adapter's AST and can emit files for a different target (TypeScript, Zod, Faker). A plugin
|
|
@@ -2236,12 +2097,7 @@ type Config<TInput = Input> = {
|
|
|
2236
2097
|
* })
|
|
2237
2098
|
* ```
|
|
2238
2099
|
*/
|
|
2239
|
-
type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter' | 'storage' | 'reporters'
|
|
2240
|
-
/**
|
|
2241
|
-
* Incremental build cache. Defaults to `fsCache()` (local disk). Pass another {@link Cache}
|
|
2242
|
-
* backend, or `false` to turn caching off.
|
|
2243
|
-
*/
|
|
2244
|
-
cache?: Cache | false;
|
|
2100
|
+
type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter' | 'storage' | 'reporters'> & {
|
|
2245
2101
|
/**
|
|
2246
2102
|
* Project root directory, absolute or relative to the config file location.
|
|
2247
2103
|
* @default process.cwd()
|
|
@@ -2665,11 +2521,6 @@ type CLIOptions = {
|
|
|
2665
2521
|
* Reporters selected on the CLI via `--reporter`, overriding `config.reporters`.
|
|
2666
2522
|
*/
|
|
2667
2523
|
reporters?: Array<ReporterName>;
|
|
2668
|
-
/**
|
|
2669
|
-
* Turns off the incremental build cache for this run, forcing a full regeneration.
|
|
2670
|
-
* Set by the `--no-cache` flag.
|
|
2671
|
-
*/
|
|
2672
|
-
noCache?: boolean;
|
|
2673
2524
|
};
|
|
2674
2525
|
/**
|
|
2675
2526
|
* All accepted forms of a Kubb configuration.
|
|
@@ -3065,5 +2916,5 @@ declare class Diagnostics {
|
|
|
3065
2916
|
static formatLines(diagnostic: Diagnostic): Array<string>;
|
|
3066
2917
|
}
|
|
3067
2918
|
//#endregion
|
|
3068
|
-
export {
|
|
3069
|
-
//# sourceMappingURL=diagnostics-
|
|
2919
|
+
export { KubbPluginSetupContext as $, KubbHookStartContext as A, Adapter as At, ParsedFile as B, KubbFilesProcessingEndContext as C, GenerationResult as Ct, KubbGenerationStartContext as D, UserReporter as Dt, KubbGenerationEndContext as E, ReporterName as Et, KubbSuccessContext as F, Generator$1 as G, createKubb as H, KubbWarnContext as I, KubbDriver as J, GeneratorContext as K, PossibleConfig as L, KubbInfoContext as M, AdapterSource as Mt, KubbLifecycleStartContext as N, createAdapter as Nt, KubbHookEndContext as O, createReporter as Ot, KubbPluginsEndContext as P, AsyncEventEmitter as Pt, KubbPluginEndContext as Q, UserConfig as R, KubbFileProcessingUpdate as S, createStorage as St, KubbFilesProcessingUpdateContext as T, ReporterContext as Tt, Parser as U, Kubb$1 as V, defineParser as W, Group as X, Exclude$1 as Y, Include as Z, InputPath as _, defineResolver as _t, DiagnosticLocation as a, Override as at, KubbDiagnosticContext as b, createRenderer as bt, PerformanceDiagnostic as c, definePlugin as ct, SerializedDiagnostic as d, ResolveBannerFile as dt, KubbPluginStartContext as et, UpdateDiagnostic as f, ResolveOptionsContext as ft, InputData as g, ResolverPathParams as gt, Config as h, ResolverFileParams as ht, DiagnosticKind as i, OutputOptions as it, KubbHooks as j, AdapterFactoryOptions as jt, KubbHookLineContext as k, logLevel as kt, ProblemCode as l, BannerMeta as lt, CLIOptions as m, ResolverContext as mt, DiagnosticByCode as n, Output as nt, DiagnosticSeverity as o, Plugin as ot, BuildOutput as p, Resolver as pt, defineGenerator as q, DiagnosticDoc as r, OutputMode as rt, Diagnostics as s, PluginFactoryOptions as st, Diagnostic as t, NormalizedPlugin as tt, ProblemDiagnostic as u, ResolveBannerContext as ut, KubbBuildEndContext as v, Renderer as vt, KubbFilesProcessingStartContext as w, Reporter as wt, KubbErrorContext as x, Storage as xt, KubbBuildStartContext as y, RendererFactory as yt, FileProcessorHooks as z };
|
|
2920
|
+
//# sourceMappingURL=diagnostics-Bf2bC8lV.d.ts.map
|