@kubb/plugin-oas 4.3.1 → 4.4.0

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.
Files changed (96) hide show
  1. package/dist/{Oas--cvTRMTA.cjs → Oas-BzrQ6RGC.cjs} +11 -11
  2. package/dist/Oas-BzrQ6RGC.cjs.map +1 -0
  3. package/dist/{Oas-DoN76W2_.js → Oas-CIeHKOo0.js} +3 -3
  4. package/dist/Oas-CIeHKOo0.js.map +1 -0
  5. package/dist/{OperationGenerator-ki8g970_.d.ts → OperationGenerator-BZPWkxw4.d.ts} +164 -92
  6. package/dist/{OperationGenerator-XkW6FZJh.d.cts → OperationGenerator-CJTAer7l.d.cts} +163 -91
  7. package/dist/{Schema-CHstINXC.d.ts → Schema-CjraJhJi.d.ts} +7 -6
  8. package/dist/{Schema-BXYfUkqN.d.cts → Schema-zcZF0UIp.d.cts} +6 -5
  9. package/dist/{SchemaGenerator-B07tXh1b.js → SchemaGenerator-7wBwdv8G.js} +21 -4
  10. package/dist/{SchemaGenerator-B07tXh1b.js.map → SchemaGenerator-7wBwdv8G.js.map} +1 -1
  11. package/dist/{SchemaGenerator-DsK0wuii.cjs → SchemaGenerator-DzVHk6OP.cjs} +22 -5
  12. package/dist/SchemaGenerator-DzVHk6OP.cjs.map +1 -0
  13. package/dist/{SchemaMapper-qjB3rBph.d.ts → SchemaMapper-CqBW0VOy.d.ts} +1 -1
  14. package/dist/{SchemaMapper-CM1eXksi.js → SchemaMapper-Cx4X1al6.js} +1 -1
  15. package/dist/{SchemaMapper-CM1eXksi.js.map → SchemaMapper-Cx4X1al6.js.map} +1 -1
  16. package/dist/{SchemaMapper-CpAbmGiH.cjs → SchemaMapper-DoL-a6qq.cjs} +1 -1
  17. package/dist/{SchemaMapper-CpAbmGiH.cjs.map → SchemaMapper-DoL-a6qq.cjs.map} +1 -1
  18. package/dist/chunk-BEV-X5tz.js +27 -0
  19. package/dist/components.cjs +1 -1
  20. package/dist/components.d.cts +7 -6
  21. package/dist/components.d.ts +8 -7
  22. package/dist/components.js +1 -1
  23. package/dist/generators-B27La9Vd.cjs +99 -0
  24. package/dist/generators-B27La9Vd.cjs.map +1 -0
  25. package/dist/generators-C61FxVIj.js +80 -0
  26. package/dist/generators-C61FxVIj.js.map +1 -0
  27. package/dist/generators.cjs +9 -3
  28. package/dist/generators.d.cts +2 -7
  29. package/dist/generators.d.ts +3 -8
  30. package/dist/generators.js +5 -4
  31. package/dist/{getFooter-pQXwqM81.cjs → getFooter-CwjCW4h5.cjs} +3 -3
  32. package/dist/{getFooter-pQXwqM81.cjs.map → getFooter-CwjCW4h5.cjs.map} +1 -1
  33. package/dist/{getFooter-CvTKkK7-.js → getFooter-D5MdeUVv.js} +2 -2
  34. package/dist/{getFooter-CvTKkK7-.js.map → getFooter-D5MdeUVv.js.map} +1 -1
  35. package/dist/{getSchemas-CvUX0jWa.js → getSchemas-Bdg6n9Qk.js} +1 -1
  36. package/dist/{getSchemas-CvUX0jWa.js.map → getSchemas-Bdg6n9Qk.js.map} +1 -1
  37. package/dist/{getSchemas-08CU8KWq.cjs → getSchemas-DY8s2CSl.cjs} +1 -1
  38. package/dist/{getSchemas-08CU8KWq.cjs.map → getSchemas-DY8s2CSl.cjs.map} +1 -1
  39. package/dist/hooks.cjs +12 -11
  40. package/dist/hooks.cjs.map +1 -1
  41. package/dist/hooks.d.cts +2 -2
  42. package/dist/hooks.d.ts +3 -3
  43. package/dist/hooks.js +6 -5
  44. package/dist/hooks.js.map +1 -1
  45. package/dist/index.cjs +37 -9
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +2 -8
  48. package/dist/index.d.ts +3 -9
  49. package/dist/index.js +33 -9
  50. package/dist/index.js.map +1 -1
  51. package/dist/mocks.cjs +1 -1
  52. package/dist/mocks.d.ts +1 -1
  53. package/dist/mocks.js +1 -1
  54. package/dist/{parseFromConfig-DSI6Meg0.js → parseFromConfig-CqiiLCPe.js} +1 -1
  55. package/dist/{parseFromConfig-DSI6Meg0.js.map → parseFromConfig-CqiiLCPe.js.map} +1 -1
  56. package/dist/{parseFromConfig-o3tU1XJt.cjs → parseFromConfig-RR31a98-.cjs} +1 -1
  57. package/dist/{parseFromConfig-o3tU1XJt.cjs.map → parseFromConfig-RR31a98-.cjs.map} +1 -1
  58. package/dist/utils-BnkB1ikY.js +99 -0
  59. package/dist/utils-BnkB1ikY.js.map +1 -0
  60. package/dist/utils-nzdccPlU.cjs +119 -0
  61. package/dist/utils-nzdccPlU.cjs.map +1 -0
  62. package/dist/utils.cjs +3 -3
  63. package/dist/utils.cjs.map +1 -1
  64. package/dist/utils.d.cts +3 -2
  65. package/dist/utils.d.ts +4 -3
  66. package/dist/utils.js +3 -3
  67. package/dist/utils.js.map +1 -1
  68. package/package.json +6 -7
  69. package/src/OperationGenerator.ts +36 -7
  70. package/src/SchemaGenerator.ts +25 -1
  71. package/src/components/Oas.tsx +5 -7
  72. package/src/components/Operation.tsx +3 -3
  73. package/src/components/Schema.tsx +3 -4
  74. package/src/generators/createGenerator.ts +34 -0
  75. package/src/generators/createReactGenerator.ts +41 -0
  76. package/src/generators/index.ts +4 -0
  77. package/src/generators/jsonGenerator.ts +1 -1
  78. package/src/generators/types.ts +35 -0
  79. package/src/generators/utils.tsx +114 -0
  80. package/src/hooks/useOas.ts +1 -1
  81. package/src/hooks/useOperation.ts +1 -1
  82. package/src/hooks/useOperationManager.ts +1 -1
  83. package/src/hooks/useOperations.ts +1 -1
  84. package/src/hooks/useSchema.ts +1 -1
  85. package/src/index.ts +3 -5
  86. package/src/plugin.ts +2 -0
  87. package/src/types.ts +1 -1
  88. package/src/utils/getParams.ts +1 -1
  89. package/dist/Oas--cvTRMTA.cjs.map +0 -1
  90. package/dist/Oas-DoN76W2_.js.map +0 -1
  91. package/dist/SchemaGenerator-DsK0wuii.cjs.map +0 -1
  92. package/dist/generators-BUNmB1lx.js +0 -154
  93. package/dist/generators-BUNmB1lx.js.map +0 -1
  94. package/dist/generators-CoiXCnDY.cjs +0 -175
  95. package/dist/generators-CoiXCnDY.cjs.map +0 -1
  96. package/src/generator.tsx +0 -139
@@ -5,11 +5,10 @@ import { Operation, Operation as Operation$1 } from "oas/operation";
5
5
  import { OpenAPIV3, OpenAPIV3 as OpenAPIV3$1, OpenAPIV3_1 } from "openapi-types";
6
6
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
7
7
  import BaseOas from "oas";
8
+ import { KubbNode } from "@kubb/react-fabric/types";
9
+ import { Fabric, FileManager } from "@kubb/react-fabric";
8
10
  import { ConsolaInstance, LogLevel } from "consola";
9
- import { FileManager } from "@kubb/fabric-core";
10
11
 
11
- //#region rolldown:runtime
12
- //#endregion
13
12
  //#region ../oas/src/types.d.ts
14
13
  type contentType = 'application/json' | (string & {});
15
14
  type SchemaObject$1 = OasTypes.SchemaObject & {
@@ -44,19 +43,18 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
44
43
  getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
45
44
  valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
46
45
  }
47
- import * as import___kubb_react_fabric_types from "@kubb/react-fabric/types";
48
46
  //#endregion
49
47
  //#region ../core/src/BaseGenerator.d.ts
50
48
  /**
51
49
  * Abstract class that contains the building blocks for plugins to create their own Generator
52
50
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
53
51
  */
54
- declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
52
+ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
55
53
  #private;
56
- constructor(options?: TOptions$1, context?: TContext);
57
- get options(): TOptions$1;
54
+ constructor(options?: TOptions, context?: TContext);
55
+ get options(): TOptions;
58
56
  get context(): TContext;
59
- set options(options: TOptions$1);
57
+ set options(options: TOptions);
60
58
  abstract build(...params: unknown[]): unknown;
61
59
  }
62
60
  //#endregion
@@ -109,7 +107,7 @@ type Logger = {
109
107
  };
110
108
  //#endregion
111
109
  //#region ../core/src/utils/types.d.ts
112
- type PossiblePromise<T$1> = Promise<T$1> | T$1;
110
+ type PossiblePromise<T> = Promise<T> | T;
113
111
  //#endregion
114
112
  //#region ../core/src/types.d.ts
115
113
  type InputPath = {
@@ -222,11 +220,11 @@ TName extends string = string,
222
220
  /**
223
221
  * Options of the plugin.
224
222
  */
225
- TOptions$1 extends object = object,
223
+ TOptions extends object = object,
226
224
  /**
227
225
  * Options of the plugin that can be used later on, see `options` inside your plugin config.
228
226
  */
229
- TResolvedOptions extends object = TOptions$1,
227
+ TResolvedOptions extends object = TOptions,
230
228
  /**
231
229
  * Context that you want to expose to other plugins.
232
230
  */
@@ -240,23 +238,23 @@ TResolvePathOptions extends object = object> = {
240
238
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
241
239
  */
242
240
  key: PluginKey<TName | string>;
243
- options: TOptions$1;
241
+ options: TOptions;
244
242
  resolvedOptions: TResolvedOptions;
245
243
  context: TContext;
246
244
  resolvePathOptions: TResolvePathOptions;
247
245
  };
248
246
  type PluginKey<TName> = [name: TName, identifier?: string | number];
249
- type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
247
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
250
248
  /**
251
249
  * Unique name used for the plugin
252
250
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
253
251
  * @example @kubb/typescript
254
252
  */
255
- name: TOptions$1['name'];
253
+ name: TOptions['name'];
256
254
  /**
257
255
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
258
256
  */
259
- options: TOptions$1['resolvedOptions'];
257
+ options: TOptions['resolvedOptions'];
260
258
  /**
261
259
  * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
262
260
  * Can be used to validate dependent plugins.
@@ -266,23 +264,23 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
266
264
  * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
267
265
  */
268
266
  post?: Array<string>;
269
- } & (TOptions$1['context'] extends never ? {
267
+ } & (TOptions['context'] extends never ? {
270
268
  context?: never;
271
269
  } : {
272
- context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
270
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
273
271
  });
274
- type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
275
- type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
272
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
273
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
276
274
  /**
277
275
  * Unique name used for the plugin
278
276
  * @example @kubb/typescript
279
277
  */
280
- name: TOptions$1['name'];
278
+ name: TOptions['name'];
281
279
  /**
282
280
  * Internal key used when a developer uses more than one of the same plugin
283
281
  * @private
284
282
  */
285
- key: TOptions$1['key'];
283
+ key: TOptions['key'];
286
284
  /**
287
285
  * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
288
286
  * Can be used to validate dependent plugins.
@@ -295,49 +293,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
295
293
  /**
296
294
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
297
295
  */
298
- options: TOptions$1['resolvedOptions'];
299
- } & (TOptions$1['context'] extends never ? {
296
+ options: TOptions['resolvedOptions'];
297
+ } & (TOptions['context'] extends never ? {
300
298
  context?: never;
301
299
  } : {
302
- context: TOptions$1['context'];
300
+ context: TOptions['context'];
303
301
  });
304
- type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
305
- type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
302
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
303
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
306
304
  /**
307
305
  * Start of the lifecycle of a plugin.
308
306
  * @type hookParallel
309
307
  */
310
- buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
308
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
311
309
  /**
312
310
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
313
311
  * Options can als be included.
314
312
  * @type hookFirst
315
313
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
316
314
  */
317
- resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
315
+ resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
318
316
  /**
319
317
  * Resolve to a name based on a string.
320
318
  * Useful when converting to PascalCase or camelCase.
321
319
  * @type hookFirst
322
320
  * @example ('pet') => 'Pet'
323
321
  */
324
- resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
322
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
325
323
  /**
326
324
  * End of the plugin lifecycle.
327
325
  * @type hookParallel
328
326
  */
329
- buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
327
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
330
328
  };
331
329
  type PluginLifecycleHooks = keyof PluginLifecycle;
332
- type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
333
- type ResolvePathParams<TOptions$1 = object> = {
330
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
331
+ type ResolvePathParams<TOptions = object> = {
334
332
  pluginKey?: Plugin['key'];
335
333
  baseName: BaseName;
336
334
  mode?: Mode;
337
335
  /**
338
336
  * Options to be passed to 'resolvePath' 3th parameter
339
337
  */
340
- options?: TOptions$1;
338
+ options?: TOptions;
341
339
  };
342
340
  type ResolveNameParams = {
343
341
  name: string;
@@ -350,7 +348,8 @@ type ResolveNameParams = {
350
348
  */
351
349
  type?: 'file' | 'function' | 'type' | 'const';
352
350
  };
353
- type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
351
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
352
+ fabric: Fabric;
354
353
  config: Config;
355
354
  /**
356
355
  * @deprecated
@@ -358,7 +357,7 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
358
357
  fileManager: FileManager;
359
358
  pluginManager: PluginManager;
360
359
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
361
- resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
360
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
362
361
  resolveName: (params: ResolveNameParams) => string;
363
362
  logger: Logger;
364
363
  /**
@@ -368,12 +367,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
368
367
  /**
369
368
  * Current plugin
370
369
  */
371
- plugin: Plugin<TOptions$1>;
370
+ plugin: Plugin<TOptions>;
372
371
  };
373
372
  /**
374
373
  * Specify the export location for the files and define the behavior of the output
375
374
  */
376
- type Output<TOptions$1> = {
375
+ type Output<TOptions> = {
377
376
  /**
378
377
  * Path to the output folder or file that will contain the generated code
379
378
  */
@@ -386,11 +385,11 @@ type Output<TOptions$1> = {
386
385
  /**
387
386
  * Add a banner text in the beginning of every file
388
387
  */
389
- banner?: string | ((options: TOptions$1) => string);
388
+ banner?: string | ((options: TOptions) => string);
390
389
  /**
391
390
  * Add a footer text in the beginning of every file
392
391
  */
393
- footer?: string | ((options: TOptions$1) => string);
392
+ footer?: string | ((options: TOptions) => string);
394
393
  };
395
394
  type GroupContext = {
396
395
  group: string;
@@ -409,20 +408,21 @@ type Group = {
409
408
  //#region ../core/src/PluginManager.d.ts
410
409
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
411
410
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
412
- type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
411
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
413
412
  message: string;
414
413
  strategy: Strategy;
415
- hookName: H$1;
414
+ hookName: H;
416
415
  plugin: Plugin;
417
416
  parameters?: unknown[] | undefined;
418
417
  output?: unknown;
419
418
  };
420
- type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
421
- type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
419
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
420
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
422
421
  result: Result;
423
422
  plugin: Plugin;
424
423
  };
425
424
  type Options$2 = {
425
+ fabric: Fabric;
426
426
  logger: Logger;
427
427
  /**
428
428
  * @default Number.POSITIVE_INFINITY
@@ -434,20 +434,16 @@ type Events = {
434
434
  executed: [executer: Executer];
435
435
  error: [error: Error];
436
436
  };
437
- type GetFileProps<TOptions$1 = object> = {
437
+ type GetFileProps<TOptions = object> = {
438
438
  name: string;
439
439
  mode?: Mode;
440
440
  extname: Extname;
441
441
  pluginKey: Plugin['key'];
442
- options?: TOptions$1;
442
+ options?: TOptions;
443
443
  };
444
444
  declare class PluginManager {
445
445
  #private;
446
446
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
447
- /**
448
- * @deprecated do not use from pluginManager
449
- */
450
- readonly fileManager: FileManager;
451
447
  readonly events: EventEmitter<Events>;
452
448
  readonly config: Config;
453
449
  readonly executed: Array<Executer>;
@@ -560,6 +556,45 @@ type FileMetaBase = {
560
556
  pluginKey?: Plugin['key'];
561
557
  };
562
558
  //#endregion
559
+ //#region src/generators/createGenerator.d.ts
560
+ type UserGenerator$1<TOptions extends PluginFactoryOptions> = {
561
+ name: string;
562
+ operations?: (props: OperationsProps<TOptions>) => Promise<File[]>;
563
+ operation?: (props: OperationProps<TOptions>) => Promise<File[]>;
564
+ schema?: (props: SchemaProps<TOptions>) => Promise<File[]>;
565
+ };
566
+ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
567
+ name: string;
568
+ type: 'core';
569
+ operations: (props: OperationsProps<TOptions>) => Promise<File[]>;
570
+ operation: (props: OperationProps<TOptions>) => Promise<File[]>;
571
+ schema: (props: SchemaProps<TOptions>) => Promise<File[]>;
572
+ };
573
+ declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator$1<TOptions>): CoreGenerator<TOptions>;
574
+ //#endregion
575
+ //#region src/generators/createReactGenerator.d.ts
576
+ type UserGenerator<TOptions extends PluginFactoryOptions> = {
577
+ name: string;
578
+ Operations?: (props: OperationsProps<TOptions>) => KubbNode;
579
+ Operation?: (props: OperationProps<TOptions>) => KubbNode;
580
+ Schema?: (props: SchemaProps<TOptions>) => KubbNode;
581
+ };
582
+ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
583
+ name: string;
584
+ type: 'react';
585
+ Operations: (props: OperationsProps<TOptions>) => KubbNode;
586
+ Operation: (props: OperationProps<TOptions>) => KubbNode;
587
+ Schema: (props: SchemaProps<TOptions>) => KubbNode;
588
+ };
589
+ /****
590
+ * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
591
+ *
592
+ * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
593
+ *
594
+ * @returns A generator object with async methods for operations, operation, and schema file generation.
595
+ */
596
+ declare function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions>;
597
+ //#endregion
563
598
  //#region src/types.d.ts
564
599
  type ResolvePathOptions = {
565
600
  pluginKey?: Plugin['key'];
@@ -704,18 +739,22 @@ type ByContentType = {
704
739
  };
705
740
  type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
706
741
  type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
707
- type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
708
- options: Partial<TOptions$1>;
742
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
743
+ options: Partial<TOptions>;
709
744
  };
710
745
  type ResolvedOptions = Options$1 & {
711
746
  output: Output<Oas>;
712
747
  };
713
748
  type PluginOas = PluginFactoryOptions<'plugin-oas', Options$1, ResolvedOptions, API, ResolvePathOptions>;
714
749
  //#endregion
750
+ //#region src/generators/jsonGenerator.d.ts
751
+ declare const jsonGenerator: CoreGenerator<PluginOas>;
752
+ //#endregion
715
753
  //#region src/SchemaGenerator.d.ts
716
- type GetSchemaGeneratorOptions<T$1 extends SchemaGenerator<any, any, any>> = T$1 extends SchemaGenerator<infer Options, any, any> ? Options : never;
754
+ type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
717
755
  type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<File<TFileMeta> | Array<File<TFileMeta>> | null>;
718
- type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
756
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
757
+ fabric: Fabric;
719
758
  oas: Oas;
720
759
  pluginManager: PluginManager;
721
760
  /**
@@ -724,7 +763,7 @@ type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
724
763
  plugin: Plugin<TPluginOptions>;
725
764
  mode: Mode;
726
765
  include?: Array<'schemas' | 'responses' | 'requestBodies'>;
727
- override: Array<Override<TOptions$1>> | undefined;
766
+ override: Array<Override<TOptions>> | undefined;
728
767
  contentType?: contentType;
729
768
  output?: string;
730
769
  };
@@ -756,7 +795,7 @@ type SchemaProps$1 = {
756
795
  name?: string;
757
796
  parentName?: string;
758
797
  };
759
- declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context$1<TOptions$1, TPluginOptions>> {
798
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
760
799
  #private;
761
800
  refs: Refs;
762
801
  /**
@@ -774,56 +813,89 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
774
813
  build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
775
814
  }
776
815
  //#endregion
777
- //#region src/generator.d.ts
778
- type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
779
- instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
780
- options: TOptions$1['resolvedOptions'];
816
+ //#region src/generators/utils.d.ts
817
+ type BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {
818
+ fabric: Fabric;
819
+ generator: ReactGenerator<any>;
820
+ /**
821
+ * @deprecated
822
+ */
823
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
824
+ options: TOptions['resolvedOptions'];
825
+ };
826
+ declare function buildOperations<TOptions extends PluginFactoryOptions>(operations: Array<Operation$1>, {
827
+ fabric,
828
+ options,
829
+ instance,
830
+ generator
831
+ }: BuildOperationsOptions<TOptions>): Promise<void>;
832
+ type BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>;
833
+ declare function buildOperation<TOptions extends PluginFactoryOptions>(operation: Operation$1, {
834
+ fabric,
835
+ options,
836
+ instance,
837
+ generator
838
+ }: BuildOperationOptions<TOptions>): Promise<void>;
839
+ type BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {
840
+ fabric: Fabric;
841
+ generator: ReactGenerator<any>;
842
+ /**
843
+ * @deprecated
844
+ */
845
+ instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
846
+ options: TOptions['resolvedOptions'];
847
+ };
848
+ declare function buildSchema<TOptions extends PluginFactoryOptions>(schema: {
849
+ name: string;
850
+ tree: Array<Schema>;
851
+ value: SchemaObject$1;
852
+ }, {
853
+ fabric,
854
+ options,
855
+ instance,
856
+ generator
857
+ }: BuildSchemaOptions<TOptions>): Promise<void>;
858
+ //#endregion
859
+ //#region src/plugin.d.ts
860
+ declare const pluginOasName = "plugin-oas";
861
+ declare const pluginOas: (options?: Options$1 | undefined) => UserPluginWithLifeCycle<PluginOas>;
862
+ //#endregion
863
+ //#region src/generators/types.d.ts
864
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
865
+ /**
866
+ * @deprecated
867
+ */
868
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
869
+ options: TOptions['resolvedOptions'];
781
870
  operations: Array<Operation$1>;
782
871
  };
783
- type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
784
- instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
785
- options: TOptions$1['resolvedOptions'];
872
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
873
+ /**
874
+ * @deprecated
875
+ */
876
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
877
+ options: TOptions['resolvedOptions'];
786
878
  operation: Operation$1;
787
879
  };
788
- type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
789
- instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
790
- options: TOptions$1['resolvedOptions'];
880
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
881
+ instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
882
+ options: TOptions['resolvedOptions'];
791
883
  schema: {
792
884
  name: string;
793
885
  tree: Array<Schema>;
794
886
  value: SchemaObject$1;
795
887
  };
796
888
  };
797
- type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
798
- name: string;
799
- operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
800
- operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
801
- schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
802
- };
803
- type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
804
- declare function createGenerator<TOptions$1 extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions$1>): Generator<TOptions$1>;
805
- type ReactGeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
806
- name: string;
807
- Operations?: (this: ReactGeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => types_d_exports$1.KubbNode;
808
- Operation?: (this: ReactGeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => types_d_exports$1.KubbNode;
809
- Schema?: (this: ReactGeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => types_d_exports$1.KubbNode;
810
- };
811
- /****
812
- * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
813
- *
814
- * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
815
- *
816
- * @returns A generator object with async methods for operations, operation, and schema file generation.
817
- */
818
- declare function createReactGenerator<TOptions$1 extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions$1>): Generator<TOptions$1>;
889
+ type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
819
890
  //#endregion
820
891
  //#region src/OperationGenerator.d.ts
821
892
  type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<File<TFileMeta> | Array<File<TFileMeta>> | null>;
822
- type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
893
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
894
+ fabric: Fabric;
823
895
  oas: Oas;
824
896
  exclude: Array<Exclude$1> | undefined;
825
897
  include: Array<Include> | undefined;
826
- override: Array<Override<TOptions$1>> | undefined;
898
+ override: Array<Override<TOptions>> | undefined;
827
899
  contentType: contentType | undefined;
828
900
  pluginManager: PluginManager;
829
901
  /**
@@ -847,5 +919,5 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
847
919
  build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
848
920
  }
849
921
  //#endregion
850
- export { UserPluginWithLifeCycle as A, ResolvePathOptions as C, Output as D, Config as E, OpenAPIV3$1 as F, OpenAPIV3_1 as I, Operation$1 as L, Oas as M, HttpMethod as N, Plugin as O, OasTypes as P, SchemaObject$1 as R, Refs as S, FileMetaBase as T, OperationSchemas as _, ReactGeneratorOptions as a, PluginOas as b, GetSchemaGeneratorOptions as c, SchemaGeneratorOptions as d, SchemaMethodResult as f, OperationSchema as g, Include as h, GeneratorOptions as i, types_d_exports$1 as j, ResolveNameParams as k, SchemaGenerator as l, Exclude$1 as m, OperationMethodResult as n, createGenerator as o, API as p, Generator as r, createReactGenerator as s, OperationGenerator as t, SchemaGeneratorBuildOptions as u, Options$1 as v, Resolver as w, Ref as x, Override as y, contentType as z };
851
- //# sourceMappingURL=OperationGenerator-XkW6FZJh.d.cts.map
922
+ export { Config as A, SchemaObject$1 as B, Ref as C, createReactGenerator as D, Resolver as E, HttpMethod as F, OasTypes as I, OpenAPIV3$1 as L, Plugin as M, ResolveNameParams as N, createGenerator as O, Oas as P, OpenAPIV3_1 as R, PluginOas as S, ResolvePathOptions as T, contentType as V, Include as _, pluginOasName as a, Options$1 as b, buildSchema as c, SchemaGeneratorBuildOptions as d, SchemaGeneratorOptions as f, Exclude$1 as g, API as h, pluginOas as i, Output as j, FileMetaBase as k, GetSchemaGeneratorOptions as l, jsonGenerator as m, OperationMethodResult as n, buildOperation as o, SchemaMethodResult as p, Generator as r, buildOperations as s, OperationGenerator as t, SchemaGenerator as u, OperationSchema as v, Refs as w, Override as x, OperationSchemas as y, Operation$1 as z };
923
+ //# sourceMappingURL=OperationGenerator-CJTAer7l.d.cts.map
@@ -1,5 +1,6 @@
1
- import { R as SchemaObject, j as types_d_exports } from "./OperationGenerator-ki8g970_.js";
2
- import { t as Schema } from "./SchemaMapper-qjB3rBph.js";
1
+ import { B as SchemaObject } from "./OperationGenerator-BZPWkxw4.js";
2
+ import { t as Schema } from "./SchemaMapper-CqBW0VOy.js";
3
+ import { Key, KubbNode } from "@kubb/react-fabric/types";
3
4
 
4
5
  //#region src/components/Schema.d.ts
5
6
  type SchemaContextProps = {
@@ -8,11 +9,11 @@ type SchemaContextProps = {
8
9
  tree: Array<Schema>;
9
10
  };
10
11
  type Props = {
11
- key?: types_d_exports.Key;
12
+ key?: Key;
12
13
  name: string;
13
14
  schemaObject?: SchemaObject;
14
15
  tree?: Array<Schema>;
15
- children?: types_d_exports.KubbNode;
16
+ children?: KubbNode;
16
17
  };
17
18
  /**
18
19
  * Provides schema-related context to descendant components.
@@ -28,10 +29,10 @@ declare function Schema$1({
28
29
  schemaObject,
29
30
  tree,
30
31
  children
31
- }: Props): any;
32
+ }: Props): KubbNode;
32
33
  declare namespace Schema$1 {
33
34
  var Context;
34
35
  }
35
36
  //#endregion
36
37
  export { SchemaContextProps as n, Schema$1 as t };
37
- //# sourceMappingURL=Schema-CHstINXC.d.ts.map
38
+ //# sourceMappingURL=Schema-CjraJhJi.d.ts.map
@@ -1,5 +1,6 @@
1
- import { R as SchemaObject, j as types_d_exports } from "./OperationGenerator-XkW6FZJh.cjs";
1
+ import { B as SchemaObject } from "./OperationGenerator-CJTAer7l.cjs";
2
2
  import { t as Schema } from "./SchemaMapper-MiRB5_Zp.cjs";
3
+ import { Key, KubbNode } from "@kubb/react-fabric/types";
3
4
 
4
5
  //#region src/components/Schema.d.ts
5
6
  type SchemaContextProps = {
@@ -8,11 +9,11 @@ type SchemaContextProps = {
8
9
  tree: Array<Schema>;
9
10
  };
10
11
  type Props = {
11
- key?: types_d_exports.Key;
12
+ key?: Key;
12
13
  name: string;
13
14
  schemaObject?: SchemaObject;
14
15
  tree?: Array<Schema>;
15
- children?: types_d_exports.KubbNode;
16
+ children?: KubbNode;
16
17
  };
17
18
  /**
18
19
  * Provides schema-related context to descendant components.
@@ -28,10 +29,10 @@ declare function Schema$1({
28
29
  schemaObject,
29
30
  tree,
30
31
  children
31
- }: Props): any;
32
+ }: Props): KubbNode;
32
33
  declare namespace Schema$1 {
33
34
  var Context;
34
35
  }
35
36
  //#endregion
36
37
  export { SchemaContextProps as n, Schema$1 as t };
37
- //# sourceMappingURL=Schema-BXYfUkqN.d.cts.map
38
+ //# sourceMappingURL=Schema-zcZF0UIp.d.cts.map
@@ -1,8 +1,9 @@
1
- import { n as schemaKeywords, t as isKeyword } from "./SchemaMapper-CM1eXksi.js";
2
- import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-CvUX0jWa.js";
3
- import { BaseGenerator } from "@kubb/core";
1
+ import { r as buildSchema } from "./utils-BnkB1ikY.js";
2
+ import { n as schemaKeywords, t as isKeyword } from "./SchemaMapper-Cx4X1al6.js";
3
+ import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-Bdg6n9Qk.js";
4
4
  import transformers, { pascalCase } from "@kubb/core/transformers";
5
5
  import { isDeepEqual, isNumber, uniqueWith } from "remeda";
6
+ import { BaseGenerator } from "@kubb/core";
6
7
  import { getUniqueName } from "@kubb/core/utils";
7
8
  import { isDiscriminator, isNullable, isReference } from "@kubb/oas";
8
9
 
@@ -908,6 +909,22 @@ var SchemaGenerator = class SchemaGenerator extends BaseGenerator {
908
909
  name,
909
910
  schemaObject
910
911
  });
912
+ if (generator.type === "react") {
913
+ await buildSchema({
914
+ name,
915
+ value: schemaObject,
916
+ tree
917
+ }, {
918
+ fabric: this.context.fabric,
919
+ generator,
920
+ instance: this,
921
+ options: {
922
+ ...this.options,
923
+ ...options
924
+ }
925
+ });
926
+ return [];
927
+ }
911
928
  return await generator.schema?.({
912
929
  instance: this,
913
930
  schema: {
@@ -929,4 +946,4 @@ var SchemaGenerator = class SchemaGenerator extends BaseGenerator {
929
946
 
930
947
  //#endregion
931
948
  export { pLimit as n, SchemaGenerator as t };
932
- //# sourceMappingURL=SchemaGenerator-B07tXh1b.js.map
949
+ //# sourceMappingURL=SchemaGenerator-7wBwdv8G.js.map