@kubb/core 5.0.0-alpha.22 → 5.0.0-alpha.23
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-DZdEyCoa.d.ts → PluginDriver-P920mak9.d.ts} +50 -23
- package/dist/hooks.cjs +1 -3
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +2 -4
- package/dist/hooks.js +1 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +99 -224
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -58
- package/dist/index.js +100 -223
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/PluginDriver.ts +81 -145
- package/src/build.ts +2 -2
- package/src/constants.ts +0 -10
- package/src/defineGenerator.ts +7 -0
- package/src/defineResolver.ts +1 -10
- package/src/hooks/useDriver.ts +1 -3
- package/src/index.ts +0 -2
- package/src/renderNode.tsx +9 -6
- package/src/types.ts +29 -18
- package/src/utils/getConfigs.ts +1 -1
- package/src/utils/getPreset.ts +3 -3
- package/src/defineBuilder.ts +0 -26
- package/src/definePreset.ts +0 -27
|
@@ -219,7 +219,9 @@ type OperationsV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
219
219
|
config: Config;
|
|
220
220
|
plugin: Plugin<TPlugin>;
|
|
221
221
|
adapter: Adapter;
|
|
222
|
+
driver: PluginDriver;
|
|
222
223
|
options: Plugin<TPlugin>['options'];
|
|
224
|
+
resolver: TPlugin['resolver'];
|
|
223
225
|
nodes: Array<OperationNode>;
|
|
224
226
|
};
|
|
225
227
|
/**
|
|
@@ -228,8 +230,10 @@ type OperationsV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
228
230
|
type OperationV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
229
231
|
config: Config;
|
|
230
232
|
adapter: Adapter;
|
|
233
|
+
driver: PluginDriver;
|
|
231
234
|
plugin: Plugin<TPlugin>;
|
|
232
235
|
options: Plugin<TPlugin>['options'];
|
|
236
|
+
resolver: TPlugin['resolver'];
|
|
233
237
|
node: OperationNode;
|
|
234
238
|
};
|
|
235
239
|
/**
|
|
@@ -238,8 +242,10 @@ type OperationV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOption
|
|
|
238
242
|
type SchemaV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
239
243
|
config: Config;
|
|
240
244
|
adapter: Adapter;
|
|
245
|
+
driver: PluginDriver;
|
|
241
246
|
plugin: Plugin<TPlugin>;
|
|
242
247
|
options: Plugin<TPlugin>['options'];
|
|
248
|
+
resolver: TPlugin['resolver'];
|
|
243
249
|
node: SchemaNode;
|
|
244
250
|
};
|
|
245
251
|
/**
|
|
@@ -785,7 +791,7 @@ type Config<TInput = Input> = {
|
|
|
785
791
|
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
786
792
|
* If a plugin depends on another plugin, an error is returned if the required dependency is missing. See pre for more details.
|
|
787
793
|
*/
|
|
788
|
-
plugins
|
|
794
|
+
plugins: Array<Plugin>;
|
|
789
795
|
/**
|
|
790
796
|
* Devtools configuration for Kubb Studio integration.
|
|
791
797
|
*/
|
|
@@ -870,14 +876,6 @@ type Resolver = {
|
|
|
870
876
|
* ```
|
|
871
877
|
*/
|
|
872
878
|
type UserResolver = Omit<Resolver, 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>;
|
|
873
|
-
/**
|
|
874
|
-
* Base type for plugin builder objects.
|
|
875
|
-
* Concrete plugin builder types extend this with their own schema-building helpers.
|
|
876
|
-
* Use `defineBuilder` to define a builder object and export it alongside the plugin.
|
|
877
|
-
*/
|
|
878
|
-
type Builder = {
|
|
879
|
-
name: string;
|
|
880
|
-
};
|
|
881
879
|
type PluginFactoryOptions<
|
|
882
880
|
/**
|
|
883
881
|
* Name to be used for the plugin.
|
|
@@ -903,19 +901,13 @@ TResolvePathOptions extends object = object,
|
|
|
903
901
|
* Resolver object that encapsulates the naming and path-resolution helpers used by this plugin.
|
|
904
902
|
* Use `defineResolver` to define the resolver object and export it alongside the plugin.
|
|
905
903
|
*/
|
|
906
|
-
TResolver extends Resolver = Resolver
|
|
907
|
-
/**
|
|
908
|
-
* Builder object that encapsulates the schema-building helpers used by this plugin.
|
|
909
|
-
* Use `defineBuilder` to define the builder object and export it alongside the plugin.
|
|
910
|
-
*/
|
|
911
|
-
TBuilder extends Builder = Builder> = {
|
|
904
|
+
TResolver extends Resolver = Resolver> = {
|
|
912
905
|
name: TName;
|
|
913
906
|
options: TOptions;
|
|
914
907
|
resolvedOptions: TResolvedOptions;
|
|
915
908
|
context: TContext;
|
|
916
909
|
resolvePathOptions: TResolvePathOptions;
|
|
917
910
|
resolver: TResolver;
|
|
918
|
-
builder: TBuilder;
|
|
919
911
|
};
|
|
920
912
|
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
921
913
|
/**
|
|
@@ -928,6 +920,10 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
928
920
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
929
921
|
*/
|
|
930
922
|
options: TOptions['resolvedOptions'];
|
|
923
|
+
/**
|
|
924
|
+
* The resolver for this plugin, accessible via `driver.getPluginByName(name)?.resolver`.
|
|
925
|
+
*/
|
|
926
|
+
resolver?: TOptions['resolver'];
|
|
931
927
|
/**
|
|
932
928
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin is executed after these plugins.
|
|
933
929
|
* Can be used to validate dependent plugins.
|
|
@@ -960,6 +956,10 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
960
956
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
961
957
|
*/
|
|
962
958
|
options: TOptions['resolvedOptions'];
|
|
959
|
+
/**
|
|
960
|
+
* The resolver for this plugin, accessible via `driver.getPluginByName(name)?.resolver`.
|
|
961
|
+
*/
|
|
962
|
+
resolver: TOptions['resolver'];
|
|
963
963
|
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
964
964
|
/**
|
|
965
965
|
* Defines a context that can be used by other plugins, see `PluginDriver` where we convert from `UserPlugin` to `Plugin` (used when calling `createPlugin`).
|
|
@@ -1018,6 +1018,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
1018
1018
|
fabric: Fabric;
|
|
1019
1019
|
config: Config;
|
|
1020
1020
|
driver: PluginDriver;
|
|
1021
|
+
getPlugin: PluginDriver['getPlugin'];
|
|
1021
1022
|
/**
|
|
1022
1023
|
* Only add when the file does not exist yet
|
|
1023
1024
|
*/
|
|
@@ -1027,11 +1028,14 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
1027
1028
|
*/
|
|
1028
1029
|
upsertFile: (...file: Array<FabricFile.File>) => Promise<void>;
|
|
1029
1030
|
events: AsyncEventEmitter<KubbEvents>;
|
|
1030
|
-
mode: FabricFile.Mode;
|
|
1031
1031
|
/**
|
|
1032
1032
|
* Current plugin
|
|
1033
1033
|
*/
|
|
1034
1034
|
plugin: Plugin<TOptions>;
|
|
1035
|
+
/**
|
|
1036
|
+
* Resolver for the current plugin. Shorthand for `plugin.resolver`.
|
|
1037
|
+
*/
|
|
1038
|
+
resolver: TOptions['resolver'];
|
|
1035
1039
|
/**
|
|
1036
1040
|
* Opens the Kubb Studio URL for the current `rootNode` in the default browser.
|
|
1037
1041
|
* Falls back to printing the URL if the browser cannot be launched.
|
|
@@ -1079,7 +1083,7 @@ type Output<_TOptions = unknown> = {
|
|
|
1079
1083
|
*/
|
|
1080
1084
|
override?: boolean;
|
|
1081
1085
|
};
|
|
1082
|
-
type
|
|
1086
|
+
type UserGroup = {
|
|
1083
1087
|
/**
|
|
1084
1088
|
* Defines the type where to group the files.
|
|
1085
1089
|
* - 'tag' groups files by OpenAPI tags.
|
|
@@ -1094,6 +1098,21 @@ type Group = {
|
|
|
1094
1098
|
group: string;
|
|
1095
1099
|
}) => string;
|
|
1096
1100
|
};
|
|
1101
|
+
type Group = {
|
|
1102
|
+
/**
|
|
1103
|
+
* Defines the type where to group the files.
|
|
1104
|
+
* - 'tag' groups files by OpenAPI tags.
|
|
1105
|
+
* - 'path' groups files by OpenAPI paths.
|
|
1106
|
+
* @default undefined
|
|
1107
|
+
*/
|
|
1108
|
+
type: 'tag' | 'path';
|
|
1109
|
+
/**
|
|
1110
|
+
* Return the name of a group based on the group name, this is used for the file and name generation.
|
|
1111
|
+
*/
|
|
1112
|
+
name: (context: {
|
|
1113
|
+
group: string;
|
|
1114
|
+
}) => string;
|
|
1115
|
+
};
|
|
1097
1116
|
type LoggerOptions = {
|
|
1098
1117
|
/**
|
|
1099
1118
|
* @default 3
|
|
@@ -1333,10 +1352,13 @@ declare class PluginDriver {
|
|
|
1333
1352
|
*/
|
|
1334
1353
|
rootNode: RootNode | undefined;
|
|
1335
1354
|
adapter: Adapter | undefined;
|
|
1355
|
+
readonly plugins: Map<string, Plugin>;
|
|
1336
1356
|
constructor(config: Config, options: Options);
|
|
1337
1357
|
get events(): AsyncEventEmitter<KubbEvents>;
|
|
1338
1358
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, unknown>;
|
|
1339
|
-
|
|
1359
|
+
/**
|
|
1360
|
+
* @deprecated use resolvers context instead
|
|
1361
|
+
*/
|
|
1340
1362
|
getFile<TOptions = object>({
|
|
1341
1363
|
name,
|
|
1342
1364
|
mode,
|
|
@@ -1346,7 +1368,13 @@ declare class PluginDriver {
|
|
|
1346
1368
|
}: GetFileOptions<TOptions>): FabricFile.File<{
|
|
1347
1369
|
pluginName: string;
|
|
1348
1370
|
}>;
|
|
1371
|
+
/**
|
|
1372
|
+
* @deprecated use resolvers context instead
|
|
1373
|
+
*/
|
|
1349
1374
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => FabricFile.Path;
|
|
1375
|
+
/**
|
|
1376
|
+
* @deprecated use resolvers context instead
|
|
1377
|
+
*/
|
|
1350
1378
|
resolveName: (params: ResolveNameParams) => string;
|
|
1351
1379
|
/**
|
|
1352
1380
|
* Run a specific hookName for plugin x.
|
|
@@ -1416,9 +1444,8 @@ declare class PluginDriver {
|
|
|
1416
1444
|
hookName: H;
|
|
1417
1445
|
parameters?: PluginParameter<H>;
|
|
1418
1446
|
}): Promise<void>;
|
|
1419
|
-
|
|
1420
|
-
getPluginsByName(hookName: keyof PluginWithLifeCycle, pluginName: string): Plugin[];
|
|
1447
|
+
getPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions> | undefined;
|
|
1421
1448
|
}
|
|
1422
1449
|
//#endregion
|
|
1423
|
-
export { formatters as $,
|
|
1424
|
-
//# sourceMappingURL=PluginDriver-
|
|
1450
|
+
export { formatters as $, PrinterFactoryOptions as A, UserConfig as B, PluginLifecycle as C, Preset as D, PluginWithLifeCycle as E, ResolvePathParams as F, UserResolver as G, UserLogger as H, Resolver as I, Generator as J, KubbEvents as K, ResolverContext as L, ResolveNameParams as M, ResolveOptionsContext as N, Presets as O, ResolvePathOptions as P, createStorage as Q, ResolverFileParams as R, PluginFactoryOptions as S, PluginParameter as T, UserPlugin as U, UserGroup as V, UserPluginWithLifeCycle as W, defineGenerator as X, ReactGeneratorV2 as Y, Storage as Z, LoggerOptions as _, AdapterSource as a, Plugin as b, Config as c, Group as d, linters as et, Include as f, LoggerContext as g, Logger as h, AdapterFactoryOptions as i, ResolveBannerContext as j, Printer as k, DevtoolsOptions as l, InputPath as m, getMode as n, PossiblePromise as nt, BarrelType as o, InputData as p, CoreGeneratorV2 as q, Adapter as r, AsyncEventEmitter as rt, CompatibilityPreset as s, PluginDriver as t, logLevel as tt, Exclude as u, Output as v, PluginLifecycleHooks as w, PluginContext as x, Override as y, ResolverPathParams as z };
|
|
1451
|
+
//# sourceMappingURL=PluginDriver-P920mak9.d.ts.map
|
package/dist/hooks.cjs
CHANGED
|
@@ -3,9 +3,7 @@ require("./chunk-ByKO4r7w.cjs");
|
|
|
3
3
|
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
4
4
|
//#region src/hooks/useDriver.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Use this inside React generator components to access the driver, config, and adapter.
|
|
6
|
+
* @deprecated use `driver` from the generator component props instead
|
|
9
7
|
*/
|
|
10
8
|
function useDriver() {
|
|
11
9
|
const { meta } = (0, _kubb_react_fabric.useFabric)();
|
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 { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n * @deprecated use `driver` from the generator component props instead\n */\nexport function useDriver(): PluginDriver {\n const { meta } = useFabric<{ driver: PluginDriver }>()\n\n return meta.driver\n}\n","import type { FabricFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `mode` from the generator component props instead\n */\nexport function useMode(): FabricFile.Mode {\n const { meta } = useFabric<{ mode: FabricFile.Mode }>()\n\n return meta.mode\n}\n","import { useFabric } from '@kubb/react-fabric'\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 const { meta } = useFabric<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,YAA0B;CACxC,MAAM,EAAE,UAAA,GAAA,mBAAA,YAA8C;AAEtD,QAAO,KAAK;;;;;;;ACHd,SAAgB,UAA2B;CACzC,MAAM,EAAE,UAAA,GAAA,mBAAA,YAA+C;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,UAAA,GAAA,mBAAA,YAAkD;AAE1D,QAAO,KAAK"}
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
2
|
+
import { S as PluginFactoryOptions, b as Plugin, t as PluginDriver } from "./PluginDriver-P920mak9.js";
|
|
3
3
|
import { FabricFile } from "@kubb/fabric-core/types";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useDriver.d.ts
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Use this inside React generator components to access the driver, config, and adapter.
|
|
7
|
+
* @deprecated use `driver` from the generator component props instead
|
|
10
8
|
*/
|
|
11
9
|
declare function useDriver(): PluginDriver;
|
|
12
10
|
//#endregion
|
package/dist/hooks.js
CHANGED
|
@@ -2,9 +2,7 @@ import "./chunk--u3MIqq1.js";
|
|
|
2
2
|
import { useFabric } from "@kubb/react-fabric";
|
|
3
3
|
//#region src/hooks/useDriver.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Use this inside React generator components to access the driver, config, and adapter.
|
|
5
|
+
* @deprecated use `driver` from the generator component props instead
|
|
8
6
|
*/
|
|
9
7
|
function useDriver() {
|
|
10
8
|
const { meta } = useFabric();
|
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 { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n * @deprecated use `driver` from the generator component props instead\n */\nexport function useDriver(): PluginDriver {\n const { meta } = useFabric<{ driver: PluginDriver }>()\n\n return meta.driver\n}\n","import type { FabricFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `mode` from the generator component props instead\n */\nexport function useMode(): FabricFile.Mode {\n const { meta } = useFabric<{ mode: FabricFile.Mode }>()\n\n return meta.mode\n}\n","import { useFabric } from '@kubb/react-fabric'\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 const { meta } = useFabric<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n"],"mappings":";;;;;;AAMA,SAAgB,YAA0B;CACxC,MAAM,EAAE,SAAS,WAAqC;AAEtD,QAAO,KAAK;;;;;;;ACHd,SAAgB,UAA2B;CACzC,MAAM,EAAE,SAAS,WAAsC;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,WAAyC;AAE1D,QAAO,KAAK"}
|