@kubb/core 5.0.0-alpha.24 → 5.0.0-alpha.25

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { $ as formatters, A as PrinterFactoryOptions, B as UserConfig, C as PluginLifecycle, D as Preset, E as PluginWithLifeCycle, F as ResolvePathParams, G as UserResolver, H as UserLogger, I as Resolver, J as Generator, K as KubbEvents, L as ResolverContext, M as ResolveNameParams, N as ResolveOptionsContext, O as Presets, P as ResolvePathOptions, Q as createStorage, R as ResolverFileParams, S as PluginFactoryOptions, T as PluginParameter, U as UserPlugin, V as UserGroup, W as UserPluginWithLifeCycle, X as defineGenerator, Y as ReactGeneratorV2, Z as Storage, _ as LoggerOptions, a as AdapterSource, b as Plugin, c as Config, d as Group, et as linters, f as Include, g as LoggerContext, h as Logger, i as AdapterFactoryOptions, j as ResolveBannerContext, k as Printer, l as DevtoolsOptions, m as InputPath, n as getMode, nt as PossiblePromise, o as BarrelType, p as InputData, q as CoreGeneratorV2, r as Adapter, rt as AsyncEventEmitter, s as CompatibilityPreset, t as PluginDriver, tt as logLevel, u as Exclude, v as Output, w as PluginLifecycleHooks, x as PluginContext, y as Override, z as ResolverPathParams } from "./PluginDriver-P920mak9.js";
2
+ import { $ as formatters, A as PrinterFactoryOptions, B as UserConfig, C as PluginLifecycle, D as Preset, E as PluginWithLifeCycle, F as ResolvePathParams, G as UserResolver, H as UserLogger, I as Resolver, J as Generator, K as KubbEvents, L as ResolverContext, M as ResolveNameParams, N as ResolveOptionsContext, O as Presets, P as ResolvePathOptions, Q as createStorage, R as ResolverFileParams, S as PluginFactoryOptions, T as PluginParameter, U as UserPlugin, V as UserGroup, W as UserPluginWithLifeCycle, X as defineGenerator, Y as ReactGeneratorV2, Z as Storage, _ as LoggerOptions, a as AdapterSource, b as Plugin, c as Config, d as Group, et as linters, f as Include, g as LoggerContext, h as Logger, i as AdapterFactoryOptions, j as ResolveBannerContext, k as Printer, l as DevtoolsOptions, m as InputPath, n as getMode, nt as PossiblePromise, o as BarrelType, p as InputData, q as CoreGeneratorV2, r as Adapter, rt as AsyncEventEmitter, s as CompatibilityPreset, t as PluginDriver, tt as logLevel, u as Exclude, v as Output, w as PluginLifecycleHooks, x as PluginContext, y as Override, z as ResolverPathParams } from "./PluginDriver-BGRDpPpK.js";
3
3
  import { definePrinter } from "@kubb/ast";
4
4
  import { Node, OperationNode, RootNode, SchemaNode, Visitor } from "@kubb/ast/types";
5
5
  import { Fabric, FabricFile } from "@kubb/fabric-core/types";
@@ -618,6 +618,37 @@ type BuildSchemaV2Options<TOptions extends PluginFactoryOptions> = {
618
618
  * Renders a React component for a single schema node (V2 generators).
619
619
  */
620
620
  declare function renderSchema<TOptions extends PluginFactoryOptions>(node: SchemaNode, options: BuildSchemaV2Options<TOptions>): Promise<void>;
621
+ /**
622
+ * Shared context passed to every `runGenerator*` helper.
623
+ * Contains everything a generator needs to produce and write files.
624
+ */
625
+ type RunGeneratorContext<TOptions extends PluginFactoryOptions> = {
626
+ generators: Array<Generator<TOptions>>;
627
+ plugin: Plugin<TOptions>;
628
+ resolver: TOptions['resolver'];
629
+ exclude: Array<Exclude>;
630
+ include: Array<Include> | undefined;
631
+ override: Array<Override<TOptions['resolvedOptions']>>;
632
+ fabric: Fabric$1;
633
+ adapter: Adapter;
634
+ config: Config;
635
+ driver: PluginDriver;
636
+ };
637
+ /**
638
+ * Dispatches a single schema node to all generators (react + core).
639
+ * Resolves options per generator and skips excluded nodes.
640
+ */
641
+ declare function runGeneratorSchema<TOptions extends PluginFactoryOptions>(node: SchemaNode, ctx: RunGeneratorContext<TOptions>): Promise<void>;
642
+ /**
643
+ * Dispatches a single operation node to all generators (react + core).
644
+ * Resolves options per generator and skips excluded nodes.
645
+ */
646
+ declare function runGeneratorOperation<TOptions extends PluginFactoryOptions>(node: OperationNode, ctx: RunGeneratorContext<TOptions>): Promise<void>;
647
+ /**
648
+ * Batch-dispatches all collected operation nodes to every generator (react + core).
649
+ * Uses `plugin.options` directly — no per-node option resolution.
650
+ */
651
+ declare function runGeneratorOperations<TOptions extends PluginFactoryOptions>(nodes: Array<OperationNode>, ctx: Omit<RunGeneratorContext<TOptions>, 'exclude' | 'include' | 'override'>): Promise<void>;
621
652
  //#endregion
622
653
  //#region src/storages/fsStorage.d.ts
623
654
  /**
@@ -853,5 +884,5 @@ type DependencyVersion = string;
853
884
  */
854
885
  declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
855
886
  //#endregion
856
- export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, type CLIOptions, CompatibilityPreset, Config, type ConfigInput, CoreGeneratorV2, DevtoolsOptions, Exclude, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, Group, Include, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, Override, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Preset, Presets, Printer, PrinterFactoryOptions, ReactGeneratorV2, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, ResolvePathOptions, ResolvePathParams, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, URLPath, UserConfig, UserGroup, UserLogger, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, buildDefaultBanner, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineConfig, defineGenerator, defineLogger, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeResolvers, renderOperation, renderOperations, renderSchema, safeBuild, satisfiesDependency, setup };
887
+ export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, type CLIOptions, CompatibilityPreset, Config, type ConfigInput, CoreGeneratorV2, DevtoolsOptions, Exclude, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, Group, Include, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, Override, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Preset, Presets, Printer, PrinterFactoryOptions, ReactGeneratorV2, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, ResolvePathOptions, ResolvePathParams, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, URLPath, UserConfig, UserGroup, UserLogger, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, buildDefaultBanner, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineConfig, defineGenerator, defineLogger, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeResolvers, renderOperation, renderOperations, renderSchema, runGeneratorOperation, runGeneratorOperations, runGeneratorSchema, safeBuild, satisfiesDependency, setup };
857
888
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -70,7 +70,7 @@ var AsyncEventEmitter = class {
70
70
  }
71
71
  #emitter = new EventEmitter();
72
72
  /**
73
- * Emits `eventName` and awaits all registered listeners in parallel.
73
+ * Emits `eventName` and awaits all registered listeners sequentially.
74
74
  * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
75
75
  *
76
76
  * @example
@@ -81,19 +81,17 @@ var AsyncEventEmitter = class {
81
81
  async emit(eventName, ...eventArgs) {
82
82
  const listeners = this.#emitter.listeners(eventName);
83
83
  if (listeners.length === 0) return;
84
- await Promise.all(listeners.map(async (listener) => {
84
+ for (const listener of listeners) try {
85
+ await listener(...eventArgs);
86
+ } catch (err) {
87
+ let serializedArgs;
85
88
  try {
86
- return await listener(...eventArgs);
87
- } catch (err) {
88
- let serializedArgs;
89
- try {
90
- serializedArgs = JSON.stringify(eventArgs);
91
- } catch {
92
- serializedArgs = String(eventArgs);
93
- }
94
- throw new Error(`Error in async listener for "${eventName}" with eventArgs ${serializedArgs}`, { cause: toError(err) });
89
+ serializedArgs = JSON.stringify(eventArgs);
90
+ } catch {
91
+ serializedArgs = String(eventArgs);
95
92
  }
96
- }));
93
+ throw new Error(`Error in async listener for "${eventName}" with eventArgs ${serializedArgs}`, { cause: toError(err) });
94
+ }
97
95
  }
98
96
  /**
99
97
  * Registers a persistent listener for `eventName`.
@@ -1412,7 +1410,7 @@ const fsStorage = createStorage(() => ({
1412
1410
  }));
1413
1411
  //#endregion
1414
1412
  //#region package.json
1415
- var version$1 = "5.0.0-alpha.24";
1413
+ var version$1 = "5.0.0-alpha.25";
1416
1414
  //#endregion
1417
1415
  //#region src/utils/diagnostics.ts
1418
1416
  /**
@@ -2243,6 +2241,113 @@ async function renderSchema(node, options) {
2243
2241
  fabric.context.fileManager.upsert(...fabricChild.files);
2244
2242
  fabricChild.unmount();
2245
2243
  }
2244
+ /**
2245
+ * Dispatches a single schema node to all generators (react + core).
2246
+ * Resolves options per generator and skips excluded nodes.
2247
+ */
2248
+ async function runGeneratorSchema(node, ctx) {
2249
+ const { generators, plugin, resolver, exclude, include, override, fabric, adapter, config, driver } = ctx;
2250
+ for (const generator of generators) {
2251
+ const options = resolver.resolveOptions(node, {
2252
+ options: plugin.options,
2253
+ exclude,
2254
+ include,
2255
+ override
2256
+ });
2257
+ if (options === null) continue;
2258
+ if (generator.type === "react" && generator.version === "2") await renderSchema(node, {
2259
+ options,
2260
+ resolver,
2261
+ adapter,
2262
+ config,
2263
+ fabric,
2264
+ Component: generator.Schema,
2265
+ plugin,
2266
+ driver
2267
+ });
2268
+ if (generator.type === "core" && generator.version === "2") {
2269
+ const files = await generator.schema?.({
2270
+ node,
2271
+ options,
2272
+ resolver,
2273
+ adapter,
2274
+ config,
2275
+ plugin,
2276
+ driver
2277
+ }) ?? [];
2278
+ await fabric.upsertFile(...files);
2279
+ }
2280
+ }
2281
+ }
2282
+ /**
2283
+ * Dispatches a single operation node to all generators (react + core).
2284
+ * Resolves options per generator and skips excluded nodes.
2285
+ */
2286
+ async function runGeneratorOperation(node, ctx) {
2287
+ const { generators, plugin, resolver, exclude, include, override, fabric, adapter, config, driver } = ctx;
2288
+ for (const generator of generators) {
2289
+ const options = resolver.resolveOptions(node, {
2290
+ options: plugin.options,
2291
+ exclude,
2292
+ include,
2293
+ override
2294
+ });
2295
+ if (options === null) continue;
2296
+ if (generator.type === "react" && generator.version === "2") await renderOperation(node, {
2297
+ options,
2298
+ resolver,
2299
+ adapter,
2300
+ config,
2301
+ fabric,
2302
+ Component: generator.Operation,
2303
+ plugin,
2304
+ driver
2305
+ });
2306
+ if (generator.type === "core" && generator.version === "2") {
2307
+ const files = await generator.operation?.({
2308
+ node,
2309
+ options,
2310
+ resolver,
2311
+ adapter,
2312
+ config,
2313
+ plugin,
2314
+ driver
2315
+ }) ?? [];
2316
+ await fabric.upsertFile(...files);
2317
+ }
2318
+ }
2319
+ }
2320
+ /**
2321
+ * Batch-dispatches all collected operation nodes to every generator (react + core).
2322
+ * Uses `plugin.options` directly — no per-node option resolution.
2323
+ */
2324
+ async function runGeneratorOperations(nodes, ctx) {
2325
+ const { generators, plugin, resolver, fabric, adapter, config, driver } = ctx;
2326
+ for (const generator of generators) {
2327
+ if (generator.type === "react" && generator.version === "2") await renderOperations(nodes, {
2328
+ options: plugin.options,
2329
+ resolver,
2330
+ adapter,
2331
+ config,
2332
+ fabric,
2333
+ Component: generator.Operations,
2334
+ plugin,
2335
+ driver
2336
+ });
2337
+ if (generator.type === "core" && generator.version === "2") {
2338
+ const files = await generator.operations?.({
2339
+ nodes,
2340
+ options: plugin.options,
2341
+ resolver,
2342
+ adapter,
2343
+ config,
2344
+ plugin,
2345
+ driver
2346
+ }) ?? [];
2347
+ await fabric.upsertFile(...files);
2348
+ }
2349
+ }
2350
+ }
2246
2351
  //#endregion
2247
2352
  //#region src/storages/memoryStorage.ts
2248
2353
  /**
@@ -2784,6 +2889,6 @@ function satisfiesDependency(dependency, version, cwd) {
2784
2889
  return satisfies(semVer, version);
2785
2890
  }
2786
2891
  //#endregion
2787
- export { AsyncEventEmitter, FunctionParams, PluginDriver, URLPath, build, build as default, buildDefaultBanner, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineConfig, defineGenerator, defineLogger, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeResolvers, renderOperation, renderOperations, renderSchema, safeBuild, satisfiesDependency, setup };
2892
+ export { AsyncEventEmitter, FunctionParams, PluginDriver, URLPath, build, build as default, buildDefaultBanner, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineConfig, defineGenerator, defineLogger, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeResolvers, renderOperation, renderOperations, renderSchema, runGeneratorOperation, runGeneratorOperations, runGeneratorSchema, safeBuild, satisfiesDependency, setup };
2788
2893
 
2789
2894
  //# sourceMappingURL=index.js.map