@kubb/core 5.0.0-alpha.32 → 5.0.0-alpha.34
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/{PluginDriver-nm7tvGs9.d.ts → PluginDriver-BBi_41VF.d.ts} +16 -36
- package/dist/hooks.cjs +4 -7
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +4 -7
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +132 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +56 -5
- package/dist/index.js +132 -95
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/FileProcessor.ts +4 -3
- package/src/Kubb.ts +1 -1
- package/src/build.ts +0 -1
- package/src/defineGenerator.ts +4 -8
- package/src/defineParser.ts +4 -17
- package/src/hooks/useDriver.ts +2 -4
- package/src/hooks/useMode.ts +2 -4
- package/src/hooks/usePlugin.ts +2 -4
- package/src/index.ts +3 -1
- package/src/renderNode.tsx +11 -9
- package/src/types.ts +8 -8
- package/src/utils/getBarrelFiles.ts +0 -2
- package/src/utils/getFunctionParams.ts +247 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { FileNode, ImportNode, InputNode, Node, OperationNode, Printer, Printer as Printer$1, PrinterFactoryOptions, PrinterPartial, SchemaNode, Visitor } from "@kubb/ast/types";
|
|
3
3
|
import { HttpMethod } from "@kubb/oas";
|
|
4
|
-
import {
|
|
4
|
+
import { KubbReactNode } from "@kubb/renderer-jsx/types";
|
|
5
5
|
|
|
6
6
|
//#region ../../internals/utils/src/asyncEventEmitter.d.ts
|
|
7
7
|
/**
|
|
@@ -280,17 +280,17 @@ type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
280
280
|
* `this` is the parent plugin's context with `adapter` and `inputNode` guaranteed present.
|
|
281
281
|
* `options` contains the per-node resolved options (after exclude/include/override).
|
|
282
282
|
*/
|
|
283
|
-
schema?: (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<
|
|
283
|
+
schema?: (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<KubbReactNode | Array<FileNode> | void>;
|
|
284
284
|
/**
|
|
285
285
|
* Called for each operation node in the AST walk.
|
|
286
286
|
* `this` is the parent plugin's context with `adapter` and `inputNode` guaranteed present.
|
|
287
287
|
*/
|
|
288
|
-
operation?: (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<
|
|
288
|
+
operation?: (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<KubbReactNode | Array<FileNode> | void>;
|
|
289
289
|
/**
|
|
290
290
|
* Called once after all operations have been walked.
|
|
291
291
|
* `this` is the parent plugin's context with `adapter` and `inputNode` guaranteed present.
|
|
292
292
|
*/
|
|
293
|
-
operations?: (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<
|
|
293
|
+
operations?: (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<KubbReactNode | Array<FileNode> | void>;
|
|
294
294
|
};
|
|
295
295
|
/**
|
|
296
296
|
* Defines a generator. Returns the object as-is with correct `this` typings.
|
|
@@ -328,7 +328,6 @@ type PrintOptions = {
|
|
|
328
328
|
};
|
|
329
329
|
type Parser<TMeta extends object = any> = {
|
|
330
330
|
name: string;
|
|
331
|
-
type: 'parser';
|
|
332
331
|
/**
|
|
333
332
|
* File extensions this parser handles.
|
|
334
333
|
* Use `undefined` to create a catch-all fallback parser.
|
|
@@ -336,19 +335,11 @@ type Parser<TMeta extends object = any> = {
|
|
|
336
335
|
* @example ['.ts', '.js']
|
|
337
336
|
*/
|
|
338
337
|
extNames: Array<FileNode['extname']> | undefined;
|
|
339
|
-
/**
|
|
340
|
-
* @deprecated Will be removed once Fabric no longer requires it.
|
|
341
|
-
* @default () => {}
|
|
342
|
-
*/
|
|
343
|
-
install(...args: unknown[]): void | Promise<void>;
|
|
344
338
|
/**
|
|
345
339
|
* Convert a resolved file to a string.
|
|
346
340
|
*/
|
|
347
341
|
parse(file: FileNode<TMeta>, options?: PrintOptions): Promise<string> | string;
|
|
348
342
|
};
|
|
349
|
-
type UserParser<TMeta extends object = any> = Omit<Parser<TMeta>, 'type' | 'install'> & {
|
|
350
|
-
install?(...args: unknown[]): void | Promise<void>;
|
|
351
|
-
};
|
|
352
343
|
/**
|
|
353
344
|
* Defines a parser with type safety.
|
|
354
345
|
*
|
|
@@ -363,12 +354,13 @@ type UserParser<TMeta extends object = any> = Omit<Parser<TMeta>, 'type' | 'inst
|
|
|
363
354
|
* name: 'json',
|
|
364
355
|
* extNames: ['.json'],
|
|
365
356
|
* parse(file) {
|
|
366
|
-
*
|
|
357
|
+
* const { extractStringsFromNodes } = await import('@kubb/ast')
|
|
358
|
+
* return file.sources.map((s) => extractStringsFromNodes(s.nodes ?? [])).join('\n')
|
|
367
359
|
* },
|
|
368
360
|
* })
|
|
369
361
|
* ```
|
|
370
362
|
*/
|
|
371
|
-
declare function defineParser<TMeta extends object = any>(parser:
|
|
363
|
+
declare function defineParser<TMeta extends object = any>(parser: Parser<TMeta>): Parser<TMeta>;
|
|
372
364
|
//#endregion
|
|
373
365
|
//#region src/Kubb.d.ts
|
|
374
366
|
type DebugInfo = {
|
|
@@ -553,7 +545,7 @@ interface KubbEvents {
|
|
|
553
545
|
*/
|
|
554
546
|
file: FileNode;
|
|
555
547
|
/**
|
|
556
|
-
* Kubb configuration
|
|
548
|
+
* Kubb configuration
|
|
557
549
|
* Provides access to the current config during file processing.
|
|
558
550
|
*/
|
|
559
551
|
config: Config;
|
|
@@ -676,18 +668,6 @@ type FunctionParamsASTWithType = {
|
|
|
676
668
|
* @deprecated use ast package instead
|
|
677
669
|
*/
|
|
678
670
|
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
679
|
-
/**
|
|
680
|
-
* @deprecated use ast package instead
|
|
681
|
-
*/
|
|
682
|
-
declare class FunctionParams {
|
|
683
|
-
#private;
|
|
684
|
-
get items(): FunctionParamsAST[];
|
|
685
|
-
add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams;
|
|
686
|
-
static toObject(items: FunctionParamsAST[]): FunctionParamsAST;
|
|
687
|
-
toObject(): FunctionParamsAST;
|
|
688
|
-
static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string;
|
|
689
|
-
toString(): string;
|
|
690
|
-
}
|
|
691
671
|
//#endregion
|
|
692
672
|
//#region src/utils/getBarrelFiles.d.ts
|
|
693
673
|
type FileMetaBase = {
|
|
@@ -771,9 +751,9 @@ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'par
|
|
|
771
751
|
*
|
|
772
752
|
* A catch-all fallback parser is always appended last for any unhandled extension.
|
|
773
753
|
*
|
|
774
|
-
* When omitted, `
|
|
754
|
+
* When omitted, `parserTsx` from `@kubb/parser-ts` is used automatically as the
|
|
775
755
|
* default (requires `@kubb/parser-ts` to be installed as an optional dependency).
|
|
776
|
-
* @default [
|
|
756
|
+
* @default [parserTsx] — from `@kubb/parser-ts`
|
|
777
757
|
* @example
|
|
778
758
|
* ```ts
|
|
779
759
|
* import { parserTs, tsxParser } from '@kubb/parser-ts'
|
|
@@ -1218,15 +1198,15 @@ type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<string, object, object,
|
|
|
1218
1198
|
/**
|
|
1219
1199
|
* Handler for a single schema node. Used by the `schema` hook on a plugin.
|
|
1220
1200
|
*/
|
|
1221
|
-
type SchemaHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<
|
|
1201
|
+
type SchemaHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<KubbReactNode | Array<FileNode> | void>;
|
|
1222
1202
|
/**
|
|
1223
1203
|
* Handler for a single operation node. Used by the `operation` hook on a plugin.
|
|
1224
1204
|
*/
|
|
1225
|
-
type OperationHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<
|
|
1205
|
+
type OperationHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<KubbReactNode | Array<FileNode> | void>;
|
|
1226
1206
|
/**
|
|
1227
1207
|
* Handler for all collected operation nodes. Used by the `operations` hook on a plugin.
|
|
1228
1208
|
*/
|
|
1229
|
-
type OperationsHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<
|
|
1209
|
+
type OperationsHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<KubbReactNode | Array<FileNode> | void>;
|
|
1230
1210
|
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
1231
1211
|
/**
|
|
1232
1212
|
* Unique name used for the plugin
|
|
@@ -1548,7 +1528,7 @@ type LoggerOptions = {
|
|
|
1548
1528
|
logLevel: (typeof logLevel)[keyof typeof logLevel];
|
|
1549
1529
|
};
|
|
1550
1530
|
/**
|
|
1551
|
-
* Shared context passed to all plugins, parsers, and
|
|
1531
|
+
* Shared context passed to all plugins, parsers, and other internals.
|
|
1552
1532
|
*/
|
|
1553
1533
|
type LoggerContext = AsyncEventEmitter<KubbEvents>;
|
|
1554
1534
|
type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
|
|
@@ -1891,5 +1871,5 @@ declare class PluginDriver {
|
|
|
1891
1871
|
requirePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions>;
|
|
1892
1872
|
}
|
|
1893
1873
|
//#endregion
|
|
1894
|
-
export {
|
|
1895
|
-
//# sourceMappingURL=PluginDriver-
|
|
1874
|
+
export { FunctionParamsAST as $, Preset as A, Resolver as B, Plugin as C, PluginLifecycleHooks as D, PluginLifecycle as E, ResolveBannerContext as F, UserConfig as G, ResolverFileParams as H, ResolveNameParams as I, UserPlugin as J, UserGroup as K, ResolveOptionsContext as L, Printer$1 as M, PrinterFactoryOptions as N, PluginParameter as O, PrinterPartial as P, getBarrelFiles as Q, ResolvePathOptions as R, Override as S, PluginFactoryOptions as T, ResolverPathParams as U, ResolverContext as V, SchemaHook as W, UserResolver as X, UserPluginWithLifeCycle as Y, FileMetaBase as Z, LoggerContext as _, AdapterSource as a, defineParser as at, OperationsHook as b, Config as c, mergeGenerators as ct, GeneratorContext as d, formatters as dt, CLIOptions as et, Group as f, linters as ft, Logger as g, InputPath as h, AdapterFactoryOptions as i, Parser as it, Presets as j, PluginWithLifeCycle as k, DevtoolsOptions as l, Storage as lt, InputData as m, AsyncEventEmitter as mt, getMode as n, defineConfig as nt, BarrelType as o, Generator as ot, Include as p, logLevel as pt, UserLogger as q, Adapter as r, KubbEvents as rt, CompatibilityPreset as s, defineGenerator as st, PluginDriver as t, ConfigInput as tt, Exclude as u, createStorage as ut, LoggerOptions as v, PluginContext as w, Output as x, OperationHook as y, ResolvePathParams as z };
|
|
1875
|
+
//# sourceMappingURL=PluginDriver-BBi_41VF.d.ts.map
|
package/dist/hooks.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./chunk-ByKO4r7w.cjs");
|
|
3
|
-
let
|
|
3
|
+
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
4
4
|
//#region src/hooks/useDriver.ts
|
|
5
5
|
/**
|
|
6
6
|
* @deprecated use `driver` from the generator component props instead
|
|
7
7
|
*/
|
|
8
8
|
function useDriver() {
|
|
9
|
-
|
|
10
|
-
return meta.driver;
|
|
9
|
+
return (0, _kubb_renderer_jsx.inject)(_kubb_renderer_jsx.KubbContext).driver;
|
|
11
10
|
}
|
|
12
11
|
//#endregion
|
|
13
12
|
//#region src/hooks/useMode.ts
|
|
@@ -15,8 +14,7 @@ function useDriver() {
|
|
|
15
14
|
* @deprecated use `mode` from the generator component props instead
|
|
16
15
|
*/
|
|
17
16
|
function useMode() {
|
|
18
|
-
|
|
19
|
-
return meta.mode;
|
|
17
|
+
return (0, _kubb_renderer_jsx.inject)(_kubb_renderer_jsx.KubbContext).mode;
|
|
20
18
|
}
|
|
21
19
|
//#endregion
|
|
22
20
|
//#region src/hooks/usePlugin.ts
|
|
@@ -24,8 +22,7 @@ function useMode() {
|
|
|
24
22
|
* @deprecated use `plugin` from the generator component props instead
|
|
25
23
|
*/
|
|
26
24
|
function usePlugin() {
|
|
27
|
-
|
|
28
|
-
return meta.plugin;
|
|
25
|
+
return (0, _kubb_renderer_jsx.inject)(_kubb_renderer_jsx.KubbContext).plugin;
|
|
29
26
|
}
|
|
30
27
|
//#endregion
|
|
31
28
|
exports.useDriver = useDriver;
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"hooks.cjs","names":["KubbContext","KubbContext","KubbContext"],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import { inject, KubbContext } from '@kubb/renderer-jsx'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n * @deprecated use `driver` from the generator component props instead\n */\nexport function useDriver(): PluginDriver {\n return inject(KubbContext)!.driver as PluginDriver\n}\n","import { inject, KubbContext } from '@kubb/renderer-jsx'\n\n/**\n * @deprecated use `mode` from the generator component props instead\n */\nexport function useMode(): 'single' | 'split' {\n return inject(KubbContext)!.mode\n}\n","import { inject, KubbContext } from '@kubb/renderer-jsx'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use `plugin` from the generator component props instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n return inject(KubbContext)!.plugin as Plugin<TOptions>\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,YAA0B;AACxC,SAAA,GAAA,mBAAA,QAAcA,mBAAAA,YAAY,CAAE;;;;;;;ACF9B,SAAgB,UAA8B;AAC5C,SAAA,GAAA,mBAAA,QAAcC,mBAAAA,YAAY,CAAE;;;;;;;ACA9B,SAAgB,YAA4F;AAC1G,SAAA,GAAA,mBAAA,QAAcC,mBAAAA,YAAY,CAAE"}
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { C as Plugin, T as PluginFactoryOptions, t as PluginDriver } from "./PluginDriver-
|
|
2
|
+
import { C as Plugin, T as PluginFactoryOptions, t as PluginDriver } from "./PluginDriver-BBi_41VF.js";
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/useDriver.d.ts
|
|
5
5
|
/**
|
package/dist/hooks.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
2
|
+
import { KubbContext, inject } from "@kubb/renderer-jsx";
|
|
3
3
|
//#region src/hooks/useDriver.ts
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated use `driver` from the generator component props instead
|
|
6
6
|
*/
|
|
7
7
|
function useDriver() {
|
|
8
|
-
|
|
9
|
-
return meta.driver;
|
|
8
|
+
return inject(KubbContext).driver;
|
|
10
9
|
}
|
|
11
10
|
//#endregion
|
|
12
11
|
//#region src/hooks/useMode.ts
|
|
@@ -14,8 +13,7 @@ function useDriver() {
|
|
|
14
13
|
* @deprecated use `mode` from the generator component props instead
|
|
15
14
|
*/
|
|
16
15
|
function useMode() {
|
|
17
|
-
|
|
18
|
-
return meta.mode;
|
|
16
|
+
return inject(KubbContext).mode;
|
|
19
17
|
}
|
|
20
18
|
//#endregion
|
|
21
19
|
//#region src/hooks/usePlugin.ts
|
|
@@ -23,8 +21,7 @@ function useMode() {
|
|
|
23
21
|
* @deprecated use `plugin` from the generator component props instead
|
|
24
22
|
*/
|
|
25
23
|
function usePlugin() {
|
|
26
|
-
|
|
27
|
-
return meta.plugin;
|
|
24
|
+
return inject(KubbContext).plugin;
|
|
28
25
|
}
|
|
29
26
|
//#endregion
|
|
30
27
|
export { useDriver, useMode, usePlugin };
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import { inject, KubbContext } from '@kubb/renderer-jsx'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n * @deprecated use `driver` from the generator component props instead\n */\nexport function useDriver(): PluginDriver {\n return inject(KubbContext)!.driver as PluginDriver\n}\n","import { inject, KubbContext } from '@kubb/renderer-jsx'\n\n/**\n * @deprecated use `mode` from the generator component props instead\n */\nexport function useMode(): 'single' | 'split' {\n return inject(KubbContext)!.mode\n}\n","import { inject, KubbContext } from '@kubb/renderer-jsx'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use `plugin` from the generator component props instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n return inject(KubbContext)!.plugin as Plugin<TOptions>\n}\n"],"mappings":";;;;;;AAMA,SAAgB,YAA0B;AACxC,QAAO,OAAO,YAAY,CAAE;;;;;;;ACF9B,SAAgB,UAA8B;AAC5C,QAAO,OAAO,YAAY,CAAE;;;;;;;ACA9B,SAAgB,YAA4F;AAC1G,QAAO,OAAO,YAAY,CAAE"}
|
package/dist/index.cjs
CHANGED
|
@@ -12,8 +12,8 @@ let _kubb_ast = require("@kubb/ast");
|
|
|
12
12
|
let node_perf_hooks = require("node:perf_hooks");
|
|
13
13
|
let fflate = require("fflate");
|
|
14
14
|
let tinyexec = require("tinyexec");
|
|
15
|
-
let
|
|
16
|
-
let
|
|
15
|
+
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
16
|
+
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
17
17
|
let node_process = require("node:process");
|
|
18
18
|
let remeda = require("remeda");
|
|
19
19
|
let empathic_package = require("empathic/package");
|
|
@@ -857,7 +857,7 @@ function validateConcurrency(concurrency) {
|
|
|
857
857
|
//#endregion
|
|
858
858
|
//#region src/FileProcessor.ts
|
|
859
859
|
function joinSources(file) {
|
|
860
|
-
return file.sources.map((item) => item.
|
|
860
|
+
return file.sources.map((item) => (0, _kubb_ast.extractStringsFromNodes)(item.nodes)).filter(Boolean).join("\n\n");
|
|
861
861
|
}
|
|
862
862
|
/**
|
|
863
863
|
* Converts a single file to a string using the registered parsers.
|
|
@@ -1510,7 +1510,7 @@ var PluginDriver = class {
|
|
|
1510
1510
|
/**
|
|
1511
1511
|
* Handles the return value of a plugin AST hook or generator method.
|
|
1512
1512
|
*
|
|
1513
|
-
* - React element → rendered via
|
|
1513
|
+
* - React element → rendered via renderer-jsx, files stored in `driver.fileManager`
|
|
1514
1514
|
* - `Array<FileNode>` → upserted directly into `driver.fileManager`
|
|
1515
1515
|
* - `void` / `null` / `undefined` → no-op (plugin handled it via `this.upsertFile`)
|
|
1516
1516
|
*/
|
|
@@ -1520,10 +1520,10 @@ async function applyHookResult(result, driver) {
|
|
|
1520
1520
|
driver.fileManager.upsert(...result);
|
|
1521
1521
|
return;
|
|
1522
1522
|
}
|
|
1523
|
-
const
|
|
1524
|
-
await
|
|
1525
|
-
driver.fileManager.upsert(...
|
|
1526
|
-
|
|
1523
|
+
const renderer = (0, _kubb_renderer_jsx.createRenderer)();
|
|
1524
|
+
await renderer.render(/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: result }));
|
|
1525
|
+
driver.fileManager.upsert(...renderer.files);
|
|
1526
|
+
renderer.unmount();
|
|
1527
1527
|
}
|
|
1528
1528
|
//#endregion
|
|
1529
1529
|
//#region src/createStorage.ts
|
|
@@ -1623,7 +1623,7 @@ const fsStorage = createStorage(() => ({
|
|
|
1623
1623
|
}));
|
|
1624
1624
|
//#endregion
|
|
1625
1625
|
//#region package.json
|
|
1626
|
-
var version = "5.0.0-alpha.
|
|
1626
|
+
var version = "5.0.0-alpha.34";
|
|
1627
1627
|
//#endregion
|
|
1628
1628
|
//#region src/utils/diagnostics.ts
|
|
1629
1629
|
/**
|
|
@@ -1827,7 +1827,6 @@ function getBarrelFilesByRoot(root, files) {
|
|
|
1827
1827
|
barrelFile.sources.push((0, _kubb_ast.createSource)({
|
|
1828
1828
|
name: source.name,
|
|
1829
1829
|
isTypeOnly: source.isTypeOnly,
|
|
1830
|
-
value: "",
|
|
1831
1830
|
isExportable: false,
|
|
1832
1831
|
isIndexable: false
|
|
1833
1832
|
}));
|
|
@@ -1891,7 +1890,6 @@ function isInputPath(config) {
|
|
|
1891
1890
|
*
|
|
1892
1891
|
* - Validates the input path (when applicable).
|
|
1893
1892
|
* - Applies config defaults (`root`, `output.*`, `devtools`).
|
|
1894
|
-
* - Creates the Fabric instance and wires storage, format, and lint hooks.
|
|
1895
1893
|
* - Runs the adapter (if configured) to produce the universal `InputNode`.
|
|
1896
1894
|
* When no adapter is supplied and `@kubb/adapter-oas` is installed as an
|
|
1897
1895
|
*
|
|
@@ -2405,17 +2403,14 @@ function defineLogger(logger) {
|
|
|
2405
2403
|
* name: 'json',
|
|
2406
2404
|
* extNames: ['.json'],
|
|
2407
2405
|
* parse(file) {
|
|
2408
|
-
*
|
|
2406
|
+
* const { extractStringsFromNodes } = await import('@kubb/ast')
|
|
2407
|
+
* return file.sources.map((s) => extractStringsFromNodes(s.nodes ?? [])).join('\n')
|
|
2409
2408
|
* },
|
|
2410
2409
|
* })
|
|
2411
2410
|
* ```
|
|
2412
2411
|
*/
|
|
2413
2412
|
function defineParser(parser) {
|
|
2414
|
-
return
|
|
2415
|
-
install() {},
|
|
2416
|
-
type: "parser",
|
|
2417
|
-
...parser
|
|
2418
|
-
};
|
|
2413
|
+
return parser;
|
|
2419
2414
|
}
|
|
2420
2415
|
//#endregion
|
|
2421
2416
|
//#region src/definePresets.ts
|
|
@@ -2819,82 +2814,6 @@ const memoryStorage = createStorage(() => {
|
|
|
2819
2814
|
};
|
|
2820
2815
|
});
|
|
2821
2816
|
//#endregion
|
|
2822
|
-
//#region src/utils/FunctionParams.ts
|
|
2823
|
-
/**
|
|
2824
|
-
* @deprecated use ast package instead
|
|
2825
|
-
*/
|
|
2826
|
-
var FunctionParams = class FunctionParams {
|
|
2827
|
-
#items = [];
|
|
2828
|
-
get items() {
|
|
2829
|
-
return this.#items.flat();
|
|
2830
|
-
}
|
|
2831
|
-
add(item) {
|
|
2832
|
-
if (!item) return this;
|
|
2833
|
-
if (Array.isArray(item)) {
|
|
2834
|
-
item.filter((x) => x !== void 0).forEach((it) => {
|
|
2835
|
-
this.#items.push(it);
|
|
2836
|
-
});
|
|
2837
|
-
return this;
|
|
2838
|
-
}
|
|
2839
|
-
this.#items.push(item);
|
|
2840
|
-
return this;
|
|
2841
|
-
}
|
|
2842
|
-
static #orderItems(items) {
|
|
2843
|
-
return (0, remeda.sortBy)(items.filter(Boolean), [(item) => Array.isArray(item), "desc"], [(item) => !Array.isArray(item) && item.default !== void 0, "asc"], [(item) => Array.isArray(item) || (item.required ?? true), "desc"]);
|
|
2844
|
-
}
|
|
2845
|
-
static #addParams(acc, item) {
|
|
2846
|
-
const { enabled = true, name, type, required = true, ...rest } = item;
|
|
2847
|
-
if (!enabled) return acc;
|
|
2848
|
-
if (!name) {
|
|
2849
|
-
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
2850
|
-
return acc;
|
|
2851
|
-
}
|
|
2852
|
-
const parameterName = name.startsWith("{") ? name : camelCase(name);
|
|
2853
|
-
if (type) if (required) acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
2854
|
-
else acc.push(`${parameterName}?: ${type}`);
|
|
2855
|
-
else acc.push(`${parameterName}`);
|
|
2856
|
-
return acc;
|
|
2857
|
-
}
|
|
2858
|
-
static toObject(items) {
|
|
2859
|
-
let type = [];
|
|
2860
|
-
let name = [];
|
|
2861
|
-
const enabled = items.every((item) => item.enabled) ? items.at(0)?.enabled : true;
|
|
2862
|
-
const required = items.every((item) => item.required) ?? true;
|
|
2863
|
-
items.forEach((item) => {
|
|
2864
|
-
name = FunctionParams.#addParams(name, {
|
|
2865
|
-
...item,
|
|
2866
|
-
type: void 0
|
|
2867
|
-
});
|
|
2868
|
-
if (items.some((item) => item.type)) type = FunctionParams.#addParams(type, item);
|
|
2869
|
-
});
|
|
2870
|
-
return {
|
|
2871
|
-
name: `{ ${name.join(", ")} }`,
|
|
2872
|
-
type: type.length ? `{ ${type.join("; ")} }` : void 0,
|
|
2873
|
-
enabled,
|
|
2874
|
-
required
|
|
2875
|
-
};
|
|
2876
|
-
}
|
|
2877
|
-
toObject() {
|
|
2878
|
-
const items = FunctionParams.#orderItems(this.#items).flat();
|
|
2879
|
-
return FunctionParams.toObject(items);
|
|
2880
|
-
}
|
|
2881
|
-
static toString(items) {
|
|
2882
|
-
return FunctionParams.#orderItems(items).reduce((acc, item) => {
|
|
2883
|
-
if (Array.isArray(item)) {
|
|
2884
|
-
if (item.length <= 0) return acc;
|
|
2885
|
-
const subItems = FunctionParams.#orderItems(item);
|
|
2886
|
-
const objectItem = FunctionParams.toObject(subItems);
|
|
2887
|
-
return FunctionParams.#addParams(acc, objectItem);
|
|
2888
|
-
}
|
|
2889
|
-
return FunctionParams.#addParams(acc, item);
|
|
2890
|
-
}, []).join(", ");
|
|
2891
|
-
}
|
|
2892
|
-
toString() {
|
|
2893
|
-
const items = FunctionParams.#orderItems(this.#items);
|
|
2894
|
-
return FunctionParams.toString(items);
|
|
2895
|
-
}
|
|
2896
|
-
};
|
|
2897
|
-
//#endregion
|
|
2898
2817
|
//#region src/utils/formatters.ts
|
|
2899
2818
|
/**
|
|
2900
2819
|
* Returns `true` when the given formatter is installed and callable.
|
|
@@ -2950,6 +2869,124 @@ async function getConfigs(config, args) {
|
|
|
2950
2869
|
}));
|
|
2951
2870
|
}
|
|
2952
2871
|
//#endregion
|
|
2872
|
+
//#region src/utils/getFunctionParams.ts
|
|
2873
|
+
function order(items) {
|
|
2874
|
+
return (0, remeda.sortBy)(items.filter(Boolean), ([_key, item]) => {
|
|
2875
|
+
if (item?.children) return 0;
|
|
2876
|
+
if (item?.optional) return 1;
|
|
2877
|
+
if (item?.default) return 2;
|
|
2878
|
+
return 0;
|
|
2879
|
+
});
|
|
2880
|
+
}
|
|
2881
|
+
function parseChild(key, item, options) {
|
|
2882
|
+
const entries = order(Object.entries(item.children));
|
|
2883
|
+
const types = [];
|
|
2884
|
+
const names = [];
|
|
2885
|
+
const optional = entries.every(([_key, item]) => item?.optional || !!item?.default);
|
|
2886
|
+
entries.forEach(([key, entryItem]) => {
|
|
2887
|
+
if (entryItem) {
|
|
2888
|
+
const name = parseItem(key, {
|
|
2889
|
+
...entryItem,
|
|
2890
|
+
type: void 0
|
|
2891
|
+
}, options);
|
|
2892
|
+
if (entryItem.children) {
|
|
2893
|
+
const subTypes = Object.entries(entryItem.children).map(([key]) => {
|
|
2894
|
+
return key;
|
|
2895
|
+
}).join(", ");
|
|
2896
|
+
if (subTypes) names.push(`${name}: { ${subTypes} }`);
|
|
2897
|
+
else names.push(name);
|
|
2898
|
+
} else if (options.type === "call" && options.transformName) names.push(`${key}: ${name}`);
|
|
2899
|
+
else names.push(name);
|
|
2900
|
+
if (entries.some(([_key, item]) => item?.type)) types.push(parseItem(key, {
|
|
2901
|
+
...entryItem,
|
|
2902
|
+
default: void 0
|
|
2903
|
+
}, options));
|
|
2904
|
+
}
|
|
2905
|
+
});
|
|
2906
|
+
const name = item.mode === "inline" ? key : names.length ? `{ ${names.join(", ")} }` : void 0;
|
|
2907
|
+
const type = item.type ? item.type : types.length ? `{ ${types.join("; ")} }` : void 0;
|
|
2908
|
+
if (!name) return null;
|
|
2909
|
+
return parseItem(name, {
|
|
2910
|
+
type,
|
|
2911
|
+
default: item.default,
|
|
2912
|
+
optional: !item.default ? optional : void 0
|
|
2913
|
+
}, options);
|
|
2914
|
+
}
|
|
2915
|
+
function parseItem(name, item, options) {
|
|
2916
|
+
const acc = [];
|
|
2917
|
+
const transformedName = options.transformName ? options.transformName(name) : name;
|
|
2918
|
+
const transformedType = options.transformType && item.type ? options.transformType(item.type) : item.type;
|
|
2919
|
+
if (options.type === "object") return transformedName;
|
|
2920
|
+
if (options.type === "objectValue") return item.value ? `${transformedName}: ${item.value}` : transformedName;
|
|
2921
|
+
if (item.type && options.type === "constructor") if (item.optional) if (transformedName.startsWith("{")) acc.push(`${transformedName}: ${transformedType} = {}`);
|
|
2922
|
+
else acc.push(`${transformedName}?: ${transformedType}`);
|
|
2923
|
+
else acc.push(`${transformedName}: ${transformedType}${item.default ? ` = ${item.default}` : ""}`);
|
|
2924
|
+
else if (item.default && options.type === "constructor") acc.push(`${transformedName} = ${item.default}`);
|
|
2925
|
+
else if (item.value) acc.push(`${transformedName} : ${item.value}`);
|
|
2926
|
+
else if (item.mode === "inlineSpread") acc.push(`... ${transformedName}`);
|
|
2927
|
+
else acc.push(transformedName);
|
|
2928
|
+
return acc[0];
|
|
2929
|
+
}
|
|
2930
|
+
function getFunctionParams(params, options) {
|
|
2931
|
+
return order(Object.entries(params)).reduce((acc, [key, item]) => {
|
|
2932
|
+
if (!item) return acc;
|
|
2933
|
+
if (item.children) {
|
|
2934
|
+
if (Object.keys(item.children).length === 0) return acc;
|
|
2935
|
+
if (item.mode === "inlineSpread") return [...acc, getFunctionParams(item.children, options)];
|
|
2936
|
+
const parsedItem = parseChild(key, item, options);
|
|
2937
|
+
if (!parsedItem) return acc;
|
|
2938
|
+
return [...acc, parsedItem];
|
|
2939
|
+
}
|
|
2940
|
+
const parsedItem = parseItem(key, item, options);
|
|
2941
|
+
return [...acc, parsedItem];
|
|
2942
|
+
}, []).join(", ");
|
|
2943
|
+
}
|
|
2944
|
+
/**
|
|
2945
|
+
* @deprecated use @kubb/ast
|
|
2946
|
+
*/
|
|
2947
|
+
function createFunctionParams(params) {
|
|
2948
|
+
return params;
|
|
2949
|
+
}
|
|
2950
|
+
/**
|
|
2951
|
+
* @deprecated use @kubb/ast
|
|
2952
|
+
*/
|
|
2953
|
+
var FunctionParams = class FunctionParams {
|
|
2954
|
+
#params;
|
|
2955
|
+
static factory(params) {
|
|
2956
|
+
return new FunctionParams(params);
|
|
2957
|
+
}
|
|
2958
|
+
constructor(params) {
|
|
2959
|
+
this.#params = params;
|
|
2960
|
+
}
|
|
2961
|
+
get params() {
|
|
2962
|
+
return this.#params;
|
|
2963
|
+
}
|
|
2964
|
+
get flatParams() {
|
|
2965
|
+
const flatter = (acc, [key, item]) => {
|
|
2966
|
+
if (item?.children) return Object.entries(item.children).reduce(flatter, acc);
|
|
2967
|
+
if (item) acc[key] = item;
|
|
2968
|
+
return acc;
|
|
2969
|
+
};
|
|
2970
|
+
return Object.entries(this.#params).reduce(flatter, {});
|
|
2971
|
+
}
|
|
2972
|
+
toCall({ transformName, transformType } = {}) {
|
|
2973
|
+
return getFunctionParams(this.#params, {
|
|
2974
|
+
type: "call",
|
|
2975
|
+
transformName,
|
|
2976
|
+
transformType
|
|
2977
|
+
});
|
|
2978
|
+
}
|
|
2979
|
+
toObject() {
|
|
2980
|
+
return getFunctionParams(this.#params, { type: "object" });
|
|
2981
|
+
}
|
|
2982
|
+
toObjectValue() {
|
|
2983
|
+
return getFunctionParams(this.#params, { type: "objectValue" });
|
|
2984
|
+
}
|
|
2985
|
+
toConstructor() {
|
|
2986
|
+
return getFunctionParams(this.#params, { type: "constructor" });
|
|
2987
|
+
}
|
|
2988
|
+
};
|
|
2989
|
+
//#endregion
|
|
2953
2990
|
//#region src/utils/getPreset.ts
|
|
2954
2991
|
/**
|
|
2955
2992
|
* Returns a copy of `defaults` where each function in `userOverrides` is wrapped
|
|
@@ -3086,6 +3123,7 @@ Object.defineProperty(exports, "composeTransformers", {
|
|
|
3086
3123
|
}
|
|
3087
3124
|
});
|
|
3088
3125
|
exports.createAdapter = createAdapter;
|
|
3126
|
+
exports.createFunctionParams = createFunctionParams;
|
|
3089
3127
|
exports.createPlugin = createPlugin;
|
|
3090
3128
|
exports.createStorage = createStorage;
|
|
3091
3129
|
exports.default = build;
|
|
@@ -3112,6 +3150,7 @@ exports.formatters = formatters;
|
|
|
3112
3150
|
exports.fsStorage = fsStorage;
|
|
3113
3151
|
exports.getBarrelFiles = getBarrelFiles;
|
|
3114
3152
|
exports.getConfigs = getConfigs;
|
|
3153
|
+
exports.getFunctionParams = getFunctionParams;
|
|
3115
3154
|
exports.getMode = getMode;
|
|
3116
3155
|
exports.getPreset = getPreset;
|
|
3117
3156
|
exports.isInputPath = isInputPath;
|