@kubb/core 5.0.0-alpha.10 → 5.0.0-alpha.12
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/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +81 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +47 -2
- package/dist/index.js +80 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/build.ts +5 -1
- package/src/hooks/useKubb.ts +1 -0
- package/src/index.ts +1 -0
- package/src/renderNode.tsx +108 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { A as UserConfig, B as Storage, C as PluginWithLifeCycle, D as ResolveOptionsContext, E as ResolveNameParams, F as CoreGeneratorV2, G as AsyncEventEmitter, H as formatters, I as Generator, L as ReactGeneratorV2, M as UserPlugin, N as UserPluginWithLifeCycle, O as ResolvePathParams, P as UserResolver, R as defineGenerator, S as PluginParameter, T as PrinterFactoryOptions, U as linters, V as createStorage, W as logLevel, _ as Plugin, a as AdapterFactoryOptions, b as PluginLifecycle, c as Config, d as InputData, f as InputPath, g as Output, h as LoggerOptions, i as Adapter, j as UserLogger, k as Resolver, l as DevtoolsOptions, m as LoggerContext, n as PluginDriver, o as AdapterSource, p as Logger, r as getMode, s as BarrelType, u as Group, v as PluginContext, w as Printer, x as PluginLifecycleHooks, y as PluginFactoryOptions, z as KubbEvents } from "./PluginDriver-BkFepPdm.js";
|
|
3
3
|
import { definePrinter } from "@kubb/ast";
|
|
4
|
-
import { Node } from "@kubb/ast/types";
|
|
4
|
+
import { Node, OperationNode, SchemaNode } from "@kubb/ast/types";
|
|
5
5
|
import { Fabric, KubbFile } from "@kubb/fabric-core/types";
|
|
6
|
+
import { Fabric as Fabric$1 } from "@kubb/react-fabric/types";
|
|
6
7
|
|
|
7
8
|
//#region src/build.d.ts
|
|
8
9
|
type BuildOptions = {
|
|
@@ -167,6 +168,50 @@ declare function defaultResolveOptions<TOptions>(node: Node, {
|
|
|
167
168
|
*/
|
|
168
169
|
declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
|
|
169
170
|
//#endregion
|
|
171
|
+
//#region src/renderNode.d.ts
|
|
172
|
+
type BuildOperationsV2Options<TOptions extends PluginFactoryOptions> = {
|
|
173
|
+
config: Config;
|
|
174
|
+
fabric: Fabric$1;
|
|
175
|
+
plugin: Plugin<TOptions>;
|
|
176
|
+
Component: ReactGeneratorV2<TOptions>['Operations'] | undefined;
|
|
177
|
+
adapter: Adapter;
|
|
178
|
+
driver: PluginDriver;
|
|
179
|
+
mode: KubbFile.Mode;
|
|
180
|
+
options: TOptions['resolvedOptions'];
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Renders a React component for a list of operation nodes (V2 generators).
|
|
184
|
+
*/
|
|
185
|
+
declare function renderOperations<TOptions extends PluginFactoryOptions>(nodes: Array<OperationNode>, options: BuildOperationsV2Options<TOptions>): Promise<void>;
|
|
186
|
+
type BuildOperationV2Options<TOptions extends PluginFactoryOptions> = {
|
|
187
|
+
config: Config;
|
|
188
|
+
fabric: Fabric$1;
|
|
189
|
+
plugin: Plugin<TOptions>;
|
|
190
|
+
Component: ReactGeneratorV2<TOptions>['Operation'] | undefined;
|
|
191
|
+
adapter: Adapter;
|
|
192
|
+
driver: PluginDriver;
|
|
193
|
+
mode: KubbFile.Mode;
|
|
194
|
+
options: TOptions['resolvedOptions'];
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Renders a React component for a single operation node (V2 generators).
|
|
198
|
+
*/
|
|
199
|
+
declare function renderOperation<TOptions extends PluginFactoryOptions>(node: OperationNode, options: BuildOperationV2Options<TOptions>): Promise<void>;
|
|
200
|
+
type BuildSchemaV2Options<TOptions extends PluginFactoryOptions> = {
|
|
201
|
+
config: Config;
|
|
202
|
+
fabric: Fabric$1;
|
|
203
|
+
plugin: Plugin<TOptions>;
|
|
204
|
+
Component: ReactGeneratorV2<TOptions>['Schema'] | undefined;
|
|
205
|
+
adapter: Adapter;
|
|
206
|
+
driver: PluginDriver;
|
|
207
|
+
mode: KubbFile.Mode;
|
|
208
|
+
options: TOptions['resolvedOptions'];
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Renders a React component for a single schema node (V2 generators).
|
|
212
|
+
*/
|
|
213
|
+
declare function renderSchema<TOptions extends PluginFactoryOptions>(node: SchemaNode, options: BuildSchemaV2Options<TOptions>): Promise<void>;
|
|
214
|
+
//#endregion
|
|
170
215
|
//#region src/storages/fsStorage.d.ts
|
|
171
216
|
/**
|
|
172
217
|
* Built-in filesystem storage driver.
|
|
@@ -325,5 +370,5 @@ type DependencyName = string;
|
|
|
325
370
|
type DependencyVersion = string;
|
|
326
371
|
declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
|
|
327
372
|
//#endregion
|
|
328
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, BarrelType, type CLIOptions, Config, type ConfigInput, CoreGeneratorV2, DevtoolsOptions, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, Group, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Printer, PrinterFactoryOptions, ReactGeneratorV2, ResolveNameParams, ResolveOptionsContext, ResolvePathParams, Resolver, Storage, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, createAdapter, createPlugin, createStorage, defaultResolveOptions, defineConfig, defineGenerator, defineLogger, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, isInputPath, linters, logLevel, memoryStorage, safeBuild, satisfiesDependency, setup };
|
|
373
|
+
export { Adapter, AdapterFactoryOptions, AdapterSource, BarrelType, type CLIOptions, Config, type ConfigInput, CoreGeneratorV2, DevtoolsOptions, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, Group, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Printer, PrinterFactoryOptions, ReactGeneratorV2, ResolveNameParams, ResolveOptionsContext, ResolvePathParams, Resolver, Storage, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, createAdapter, createPlugin, createStorage, defaultResolveOptions, defineConfig, defineGenerator, defineLogger, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, isInputPath, linters, logLevel, memoryStorage, renderOperation, renderOperations, renderSchema, safeBuild, satisfiesDependency, setup };
|
|
329
374
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,14 @@ import { EventEmitter } from "node:events";
|
|
|
5
5
|
import { parseArgs, styleText } from "node:util";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import { access, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
8
|
-
import { createFabric } from "@kubb/react-fabric";
|
|
8
|
+
import { Fabric, createFabric, createReactFabric } from "@kubb/react-fabric";
|
|
9
9
|
import { typescriptParser } from "@kubb/react-fabric/parsers";
|
|
10
10
|
import { fsPlugin } from "@kubb/react-fabric/plugins";
|
|
11
11
|
import { performance } from "node:perf_hooks";
|
|
12
12
|
import { deflateSync } from "fflate";
|
|
13
13
|
import { x } from "tinyexec";
|
|
14
14
|
import { version } from "node:process";
|
|
15
|
+
import { jsx } from "@kubb/react-fabric/jsx-runtime";
|
|
15
16
|
import { sortBy } from "remeda";
|
|
16
17
|
import * as pkg from "empathic/package";
|
|
17
18
|
import { coerce, satisfies } from "semver";
|
|
@@ -111,9 +112,12 @@ function toCamelOrPascal(text, pascal) {
|
|
|
111
112
|
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
112
113
|
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
113
114
|
* Segments are joined with `/` to form a file path.
|
|
115
|
+
*
|
|
116
|
+
* Only splits on dots followed by a letter so that version numbers
|
|
117
|
+
* embedded in operationIds (e.g. `v2025.0`) are kept intact.
|
|
114
118
|
*/
|
|
115
119
|
function applyToFileParts(text, transformPart) {
|
|
116
|
-
const parts = text.split(
|
|
120
|
+
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
117
121
|
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
118
122
|
}
|
|
119
123
|
/**
|
|
@@ -1437,7 +1441,7 @@ const fsStorage = createStorage(() => ({
|
|
|
1437
1441
|
}));
|
|
1438
1442
|
//#endregion
|
|
1439
1443
|
//#region package.json
|
|
1440
|
-
var version$1 = "5.0.0-alpha.
|
|
1444
|
+
var version$1 = "5.0.0-alpha.12";
|
|
1441
1445
|
//#endregion
|
|
1442
1446
|
//#region src/utils/diagnostics.ts
|
|
1443
1447
|
/**
|
|
@@ -1738,12 +1742,16 @@ function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, dri
|
|
|
1738
1742
|
function inputToAdapterSource(config) {
|
|
1739
1743
|
if (Array.isArray(config.input)) return {
|
|
1740
1744
|
type: "paths",
|
|
1741
|
-
paths: config.input.map((i) => resolve(config.root, i.path))
|
|
1745
|
+
paths: config.input.map((i) => new URLPath(i.path).isURL ? i.path : resolve(config.root, i.path))
|
|
1742
1746
|
};
|
|
1743
1747
|
if ("data" in config.input) return {
|
|
1744
1748
|
type: "data",
|
|
1745
1749
|
data: config.input.data
|
|
1746
1750
|
};
|
|
1751
|
+
if (new URLPath(config.input.path).isURL) return {
|
|
1752
|
+
type: "path",
|
|
1753
|
+
path: config.input.path
|
|
1754
|
+
};
|
|
1747
1755
|
return {
|
|
1748
1756
|
type: "path",
|
|
1749
1757
|
path: resolve(config.root, config.input.path)
|
|
@@ -1923,6 +1931,73 @@ function defineResolver(build) {
|
|
|
1923
1931
|
};
|
|
1924
1932
|
}
|
|
1925
1933
|
//#endregion
|
|
1934
|
+
//#region src/renderNode.tsx
|
|
1935
|
+
/**
|
|
1936
|
+
* Renders a React component for a list of operation nodes (V2 generators).
|
|
1937
|
+
*/
|
|
1938
|
+
async function renderOperations(nodes, options) {
|
|
1939
|
+
const { config, fabric, plugin, Component, adapter } = options;
|
|
1940
|
+
if (!Component) return;
|
|
1941
|
+
const fabricChild = createReactFabric();
|
|
1942
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
1943
|
+
meta: { plugin },
|
|
1944
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
1945
|
+
config,
|
|
1946
|
+
adapter,
|
|
1947
|
+
nodes,
|
|
1948
|
+
options: options.options
|
|
1949
|
+
})
|
|
1950
|
+
}));
|
|
1951
|
+
fabric.context.fileManager.upsert(...fabricChild.files);
|
|
1952
|
+
fabricChild.unmount();
|
|
1953
|
+
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Renders a React component for a single operation node (V2 generators).
|
|
1956
|
+
*/
|
|
1957
|
+
async function renderOperation(node, options) {
|
|
1958
|
+
const { config, fabric, plugin, Component, adapter, driver, mode } = options;
|
|
1959
|
+
if (!Component) return;
|
|
1960
|
+
const fabricChild = createReactFabric();
|
|
1961
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
1962
|
+
meta: {
|
|
1963
|
+
plugin,
|
|
1964
|
+
driver,
|
|
1965
|
+
mode
|
|
1966
|
+
},
|
|
1967
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
1968
|
+
config,
|
|
1969
|
+
adapter,
|
|
1970
|
+
node,
|
|
1971
|
+
options: options.options
|
|
1972
|
+
})
|
|
1973
|
+
}));
|
|
1974
|
+
fabric.context.fileManager.upsert(...fabricChild.files);
|
|
1975
|
+
fabricChild.unmount();
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Renders a React component for a single schema node (V2 generators).
|
|
1979
|
+
*/
|
|
1980
|
+
async function renderSchema(node, options) {
|
|
1981
|
+
const { config, fabric, plugin, Component, adapter, driver, mode } = options;
|
|
1982
|
+
if (!Component) return;
|
|
1983
|
+
const fabricChild = createReactFabric();
|
|
1984
|
+
await fabricChild.render(/* @__PURE__ */ jsx(Fabric, {
|
|
1985
|
+
meta: {
|
|
1986
|
+
plugin,
|
|
1987
|
+
driver,
|
|
1988
|
+
mode
|
|
1989
|
+
},
|
|
1990
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
1991
|
+
config,
|
|
1992
|
+
adapter,
|
|
1993
|
+
node,
|
|
1994
|
+
options: options.options
|
|
1995
|
+
})
|
|
1996
|
+
}));
|
|
1997
|
+
fabric.context.fileManager.upsert(...fabricChild.files);
|
|
1998
|
+
fabricChild.unmount();
|
|
1999
|
+
}
|
|
2000
|
+
//#endregion
|
|
1926
2001
|
//#region src/storages/memoryStorage.ts
|
|
1927
2002
|
/**
|
|
1928
2003
|
* In-memory storage driver. Useful for testing and dry-run scenarios where
|
|
@@ -2339,6 +2414,6 @@ function satisfiesDependency(dependency, version, cwd) {
|
|
|
2339
2414
|
return satisfies(semVer, version);
|
|
2340
2415
|
}
|
|
2341
2416
|
//#endregion
|
|
2342
|
-
export { FunctionParams, PluginDriver, build, build as default, createAdapter, createPlugin, createStorage, defaultResolveOptions, defineConfig, defineGenerator, defineLogger, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, isInputPath, linters, logLevel, memoryStorage, safeBuild, satisfiesDependency, setup };
|
|
2417
|
+
export { FunctionParams, PluginDriver, build, build as default, createAdapter, createPlugin, createStorage, defaultResolveOptions, defineConfig, defineGenerator, defineLogger, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, isInputPath, linters, logLevel, memoryStorage, renderOperation, renderOperations, renderSchema, safeBuild, satisfiesDependency, setup };
|
|
2343
2418
|
|
|
2344
2419
|
//# sourceMappingURL=index.js.map
|