@kubb/core 5.15.0 → 5.15.2
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/index.cjs +203 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -101
- package/dist/index.d.ts +3242 -8
- package/dist/index.js +3279 -146
- package/dist/index.js.map +1 -1
- package/package.json +2 -21
- package/dist/Hookable-BYr6s0lB.js +0 -3265
- package/dist/Hookable-BYr6s0lB.js.map +0 -1
- package/dist/createAdapter-CCe-Oddm.d.ts +0 -3294
- package/dist/mocks.d.ts +0 -105
- package/dist/mocks.js +0 -204
- package/dist/mocks.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -53,6 +53,10 @@ type PossiblePromise<T> = Promise<T> | T;
|
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
type LiteralUnion<T extends Base, Base = string> = T | (Base & {});
|
|
56
|
+
/**
|
|
57
|
+
* Union of the values of an object type, such as `ValueOf<typeof nodeKinds>` for an `as const` table.
|
|
58
|
+
*/
|
|
59
|
+
type ValueOf<T> = T[keyof T];
|
|
56
60
|
/**
|
|
57
61
|
* Converts a resolved {@link FileNode} into the final source string that gets
|
|
58
62
|
* written to disk. Kubb ships with TypeScript and TSX parsers. Add your own
|
|
@@ -344,7 +348,7 @@ declare const diagnosticCode: { readonly [K in keyof typeof diagnosticCatalog]:
|
|
|
344
348
|
/**
|
|
345
349
|
* Union of the stable {@link diagnosticCode} values.
|
|
346
350
|
*/
|
|
347
|
-
type DiagnosticCode =
|
|
351
|
+
type DiagnosticCode = ValueOf<typeof diagnosticCode>;
|
|
348
352
|
/**
|
|
349
353
|
* How {@link format} renders a diagnostic.
|
|
350
354
|
*/
|
|
@@ -508,7 +512,7 @@ type ReporterContext = {
|
|
|
508
512
|
* Output verbosity. Use the `logLevel` constants exported from `@kubb/core`
|
|
509
513
|
* (`silent`, `error`, `warn`, `info`, `verbose`).
|
|
510
514
|
*/
|
|
511
|
-
logLevel:
|
|
515
|
+
logLevel: ValueOf<typeof logLevel>;
|
|
512
516
|
};
|
|
513
517
|
/**
|
|
514
518
|
* Host-facing reporter, as installed onto a run. Unlike a Logger (the live TUI view), a reporter
|
|
@@ -821,12 +825,6 @@ export declare class Hookable<THooks extends { [K in keyof THooks]: Array<unknow
|
|
|
821
825
|
* ```
|
|
822
826
|
*/
|
|
823
827
|
listenerCount<THookName extends keyof THooks & string>(hookName: THookName): number;
|
|
824
|
-
/**
|
|
825
|
-
* No-op kept for callers written against the `EventEmitter`-backed version. Listeners are unbounded.
|
|
826
|
-
*
|
|
827
|
-
* @deprecated There is no listener ceiling anymore.
|
|
828
|
-
*/
|
|
829
|
-
setMaxListeners(_max: number): void;
|
|
830
828
|
/**
|
|
831
829
|
* Removes all listeners from every hook channel.
|
|
832
830
|
*
|
|
@@ -991,7 +989,7 @@ export declare class KubbDriver {
|
|
|
991
989
|
/** Reads `plugin.resolver`, falling back to a fresh default for a name that is not a registered plugin. */
|
|
992
990
|
getResolver<TName extends PluginName>(pluginName: TName): ResolvePluginOptions<TName>['resolver'];
|
|
993
991
|
memo<TKey extends MemoKey, TValue extends MemoValue<TKey>>(key: TKey, compute: () => TValue): TValue;
|
|
994
|
-
getContext<TOptions extends PluginType>(plugin: NormalizedPlugin<TOptions>): Omit<GeneratorContext<TOptions>, 'options'
|
|
992
|
+
getContext<TOptions extends PluginType>(plugin: NormalizedPlugin<TOptions>): Omit<GeneratorContext<TOptions>, 'options'>;
|
|
995
993
|
getPlugin<TName extends PluginName>(pluginName: TName): Plugin<ResolvePluginOptions<TName>> | undefined;
|
|
996
994
|
/**
|
|
997
995
|
* Like `getPlugin` but throws a descriptive error when the plugin is not found.
|
|
@@ -1402,10 +1400,10 @@ declare global {
|
|
|
1402
1400
|
'kubb:hook:start': [ctx: KubbHookStartContext];
|
|
1403
1401
|
'kubb:hook:line': [ctx: KubbHookLineContext];
|
|
1404
1402
|
'kubb:hook:end': [ctx: KubbHookEndContext];
|
|
1405
|
-
'kubb:info': [ctx:
|
|
1403
|
+
'kubb:info': [ctx: KubbMessageContext];
|
|
1406
1404
|
'kubb:error': [ctx: KubbErrorContext];
|
|
1407
|
-
'kubb:success': [ctx:
|
|
1408
|
-
'kubb:warn': [ctx:
|
|
1405
|
+
'kubb:success': [ctx: KubbMessageContext];
|
|
1406
|
+
'kubb:warn': [ctx: KubbMessageContext];
|
|
1409
1407
|
'kubb:diagnostic': [ctx: KubbDiagnosticContext];
|
|
1410
1408
|
'kubb:files:processing:start': [ctx: KubbFilesProcessingStartContext];
|
|
1411
1409
|
'kubb:files:processing:update': [ctx: KubbFilesProcessingUpdateContext];
|
|
@@ -1557,9 +1555,6 @@ export type KubbMessageContext = {
|
|
|
1557
1555
|
*/
|
|
1558
1556
|
info?: string;
|
|
1559
1557
|
};
|
|
1560
|
-
export type KubbInfoContext = KubbMessageContext;
|
|
1561
|
-
export type KubbSuccessContext = KubbMessageContext;
|
|
1562
|
-
export type KubbWarnContext = KubbMessageContext;
|
|
1563
1558
|
export type KubbErrorContext = {
|
|
1564
1559
|
/**
|
|
1565
1560
|
* The caught error.
|
|
@@ -2044,36 +2039,6 @@ export declare class Diagnostics {
|
|
|
2044
2039
|
*/
|
|
2045
2040
|
static format: typeof format;
|
|
2046
2041
|
}
|
|
2047
|
-
/**
|
|
2048
|
-
* Per-node memo shared by every plugin that generates from the same schema or operation node in
|
|
2049
|
-
* one generate pass. The driver creates one `NodeCache` per node during the walk and hands the
|
|
2050
|
-
* same instance to each plugin's generator context, so work derived purely from the node (its
|
|
2051
|
-
* resolved name, imports, parameters) is computed by the first plugin that needs it and reused by
|
|
2052
|
-
* the rest instead of being recomputed per plugin.
|
|
2053
|
-
*
|
|
2054
|
-
* Keys are namespaced by convention (`'plugin-ts:imports'`) so two plugins caching different
|
|
2055
|
-
* derivations of the same node never collide.
|
|
2056
|
-
*
|
|
2057
|
-
* @example Fill on first read, reuse afterwards
|
|
2058
|
-
* ```ts
|
|
2059
|
-
* const imports = ctx.cache.ensureItem('plugin-ts:imports', () => ctx.resolver.imports({ node, root, output }))
|
|
2060
|
-
* ```
|
|
2061
|
-
*/
|
|
2062
|
-
type NodeCache = {
|
|
2063
|
-
/**
|
|
2064
|
-
* Returns the value stored under `key`, or `undefined` when nothing is stored yet.
|
|
2065
|
-
*/
|
|
2066
|
-
readItem<TValue>(key: string): TValue | undefined;
|
|
2067
|
-
/**
|
|
2068
|
-
* Stores `value` under `key`, overwriting any previous value, and returns it.
|
|
2069
|
-
*/
|
|
2070
|
-
writeItem<TValue>(key: string, value: TValue): TValue;
|
|
2071
|
-
/**
|
|
2072
|
-
* Returns the value stored under `key`, computing and storing it with `factory` on the first
|
|
2073
|
-
* call. Later calls with the same key return the stored value without running `factory` again.
|
|
2074
|
-
*/
|
|
2075
|
-
ensureItem<TValue>(key: string, factory: () => TValue): TValue;
|
|
2076
|
-
};
|
|
2077
2042
|
/**
|
|
2078
2043
|
* Context passed to a generator's `schema`, `operation`, and `operations` methods.
|
|
2079
2044
|
*
|
|
@@ -2169,8 +2134,8 @@ type GeneratorContext<TOptions extends PluginType = PluginType> = {
|
|
|
2169
2134
|
*/
|
|
2170
2135
|
adapter: Adapter;
|
|
2171
2136
|
/**
|
|
2172
|
-
* Document metadata from the adapter: title, version, base URL, and
|
|
2173
|
-
* schema
|
|
2137
|
+
* Document metadata from the adapter: title, version, base URL, servers, and security schemes.
|
|
2138
|
+
* Derive schema indexes such as circular or enum names with `memo`.
|
|
2174
2139
|
*/
|
|
2175
2140
|
meta: InputMeta;
|
|
2176
2141
|
/**
|
|
@@ -2178,15 +2143,9 @@ type GeneratorContext<TOptions extends PluginType = PluginType> = {
|
|
|
2178
2143
|
*/
|
|
2179
2144
|
options: TOptions['resolvedOptions'];
|
|
2180
2145
|
/**
|
|
2181
|
-
* Cache
|
|
2182
|
-
*
|
|
2183
|
-
*
|
|
2184
|
-
* there is no single node, the cache is a fresh scratch scope for that call.
|
|
2185
|
-
*/
|
|
2186
|
-
cache: NodeCache;
|
|
2187
|
-
/**
|
|
2188
|
-
* Cache for the whole build, shared by every plugin, where `cache` is one node and `resolver.memo` is one
|
|
2189
|
-
* plugin. Prefix a key with the plugin name unless every plugin wants the same value.
|
|
2146
|
+
* Cache for the whole build, shared by every plugin, where `resolver.memo` is one plugin. Prefix a
|
|
2147
|
+
* key with the plugin name unless every plugin wants the same value, and name the node for
|
|
2148
|
+
* node-derived work, such as `plugin-ts:imports:${node.operationId}`.
|
|
2190
2149
|
*/
|
|
2191
2150
|
memo: Memo;
|
|
2192
2151
|
};
|
|
@@ -2780,36 +2739,33 @@ export declare function assertPluginOption({ plugin, option, value, allowed }: {
|
|
|
2780
2739
|
value: unknown;
|
|
2781
2740
|
allowed: ReadonlyArray<unknown>;
|
|
2782
2741
|
}): void;
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
* Tag name to match (case-sensitive). Can be a literal string or regex pattern.
|
|
2790
|
-
*/
|
|
2791
|
-
pattern: string | RegExp;
|
|
2792
|
-
};
|
|
2793
|
-
type ByOperationId = {
|
|
2794
|
-
/**
|
|
2795
|
-
* Filter by OpenAPI `operationId` field. Each operation (GET, POST, etc.) has a unique identifier.
|
|
2796
|
-
*/
|
|
2797
|
-
type: 'operationId';
|
|
2798
|
-
/**
|
|
2799
|
-
* Operation ID to match (case-sensitive). Can be a literal string or regex pattern.
|
|
2800
|
-
*/
|
|
2801
|
-
pattern: string | RegExp;
|
|
2802
|
-
};
|
|
2803
|
-
type ByPath = {
|
|
2742
|
+
/**
|
|
2743
|
+
* Pattern filter on one operation or schema field: a literal string or a regex, matched case-sensitive.
|
|
2744
|
+
* `tag` matches any of an operation's OpenAPI `tags`, `operationId` its id, `path` its full URL path,
|
|
2745
|
+
* `contentType` a request body content type, and `schemaName` a `#/components/schemas` name.
|
|
2746
|
+
*/
|
|
2747
|
+
type ByPattern<T extends 'tag' | 'operationId' | 'path' | 'schemaName' | 'contentType'> = {
|
|
2804
2748
|
/**
|
|
2805
|
-
*
|
|
2749
|
+
* Field to match: `'tag'`, `'operationId'`, `'path'`, `'schemaName'`, or `'contentType'`.
|
|
2806
2750
|
*/
|
|
2807
|
-
type:
|
|
2751
|
+
type: T;
|
|
2808
2752
|
/**
|
|
2809
|
-
*
|
|
2753
|
+
* Literal value or regular expression the field must match.
|
|
2810
2754
|
*/
|
|
2811
2755
|
pattern: string | RegExp;
|
|
2812
2756
|
};
|
|
2757
|
+
/**
|
|
2758
|
+
* Filter by OpenAPI `tags`.
|
|
2759
|
+
*/
|
|
2760
|
+
type ByTag = ByPattern<'tag'>;
|
|
2761
|
+
/**
|
|
2762
|
+
* Filter by OpenAPI `operationId`.
|
|
2763
|
+
*/
|
|
2764
|
+
type ByOperationId = ByPattern<'operationId'>;
|
|
2765
|
+
/**
|
|
2766
|
+
* Filter by OpenAPI `path` (URL endpoint), matched against the full path.
|
|
2767
|
+
*/
|
|
2768
|
+
type ByPath = ByPattern<'path'>;
|
|
2813
2769
|
type ByMethod = {
|
|
2814
2770
|
/**
|
|
2815
2771
|
* Filter by HTTP method: `'GET'`, `'POST'`, `'PUT'`, `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`, `'QUERY'`.
|
|
@@ -2821,26 +2777,14 @@ type ByMethod = {
|
|
|
2821
2777
|
*/
|
|
2822
2778
|
pattern: HttpMethod | RegExp;
|
|
2823
2779
|
};
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
pattern: string | RegExp;
|
|
2833
|
-
};
|
|
2834
|
-
type ByContentType = {
|
|
2835
|
-
/**
|
|
2836
|
-
* Filter by response or request content type: `'application/json'`, `'application/xml'`, etc.
|
|
2837
|
-
*/
|
|
2838
|
-
type: 'contentType';
|
|
2839
|
-
/**
|
|
2840
|
-
* Content type to match (case-sensitive). Can be a literal string or regex pattern.
|
|
2841
|
-
*/
|
|
2842
|
-
pattern: string | RegExp;
|
|
2843
|
-
};
|
|
2780
|
+
/**
|
|
2781
|
+
* Filter by schema component name in `#/components/schemas`.
|
|
2782
|
+
*/
|
|
2783
|
+
type BySchemaName = ByPattern<'schemaName'>;
|
|
2784
|
+
/**
|
|
2785
|
+
* Filter by request content type, such as `'application/json'`.
|
|
2786
|
+
*/
|
|
2787
|
+
type ByContentType = ByPattern<'contentType'>;
|
|
2844
2788
|
type ByExtension = {
|
|
2845
2789
|
/** Filter operations by a vendor extension (`x-*` key) on the source operation. Does not apply to schemas. */
|
|
2846
2790
|
type: 'extension';
|
|
@@ -3937,5 +3881,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
|
|
|
3937
3881
|
packages?: Iterable<string>;
|
|
3938
3882
|
resolveFrom?: Array<string>;
|
|
3939
3883
|
}): Promise<Array<InstalledPackage>>;
|
|
3940
|
-
export type { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, CreateKubbOptions, Diagnostic, DiagnosticDoc, DiagnosticFormatOptions, DiagnosticKind, DiagnosticLocation, DiagnosticSeverity, Exclude$1 as Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Filter, GenerateOptions, GenerateResult, GenerationResult, Generator, GeneratorContext, Group, HookResult, Include, InputKind, InstalledPackage, JSONValue, Kubb$1 as Kubb, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, Memo,
|
|
3884
|
+
export type { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, CreateKubbOptions, Diagnostic, DiagnosticDoc, DiagnosticFormatOptions, DiagnosticKind, DiagnosticLocation, DiagnosticSeverity, Exclude$1 as Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Filter, GenerateOptions, GenerateResult, GenerationResult, Generator, GeneratorContext, Group, HookResult, Include, InputKind, InstalledPackage, JSONValue, Kubb$1 as Kubb, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, Memo, NormalizedPlugin, Output, OutputManifest, OutputMode, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, PerformanceDiagnostic, Plugin, PluginDefinition, PluginFactory, PluginName, PluginType, ProblemCode, ProblemDiagnostic, RegistryArtifact, RegistryDetail, RegistryEntry, RegistryGuide, RegistryIndex, Renderer, RendererFactory, Reporter, ReporterContext, ReporterName, ReporterPluginFiles, ResolveBannerContext, ResolveBannerFile, ResolveFileOptions, ResolveImportsOptions, ResolveNameOptions, ResolveOptionsContext, ResolvePathOptions, ResolvePluginOptions, ResolverDefault, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, ResolverPathParams, RunHookOptions, RunOutputPassesOptions, SerializedDiagnostic, Storage, SummaryRenderer, UpdateDiagnostic, UserReporter };
|
|
3941
3885
|
//# sourceMappingURL=index.d.cts.map
|