@kubb/plugin-zod 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 (36) hide show
  1. package/dist/chunk-DMmIE7y6.js +28 -0
  2. package/dist/{components-MHUlEVjU.cjs → components-BiOh-7_I.cjs} +19 -19
  3. package/dist/components-BiOh-7_I.cjs.map +1 -0
  4. package/dist/{components-BUkyR7lK.js → components-DUJ6Xkpc.js} +3 -3
  5. package/dist/components-DUJ6Xkpc.js.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.cts +4 -3
  8. package/dist/components.d.ts +4 -3
  9. package/dist/components.js +1 -1
  10. package/dist/{generators-Bo3q-m_p.cjs → generators-B2hD7k6l.cjs} +25 -24
  11. package/dist/generators-B2hD7k6l.cjs.map +1 -0
  12. package/dist/{generators-8AD8PdD3.js → generators-CwEOtNXG.js} +6 -5
  13. package/dist/generators-CwEOtNXG.js.map +1 -0
  14. package/dist/generators.cjs +2 -2
  15. package/dist/generators.d.cts +3 -3
  16. package/dist/generators.d.ts +3 -3
  17. package/dist/generators.js +2 -2
  18. package/dist/index.cjs +4 -2
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +4 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/{types-CjFerqx4.d.cts → types-CENqfJvI.d.cts} +93 -74
  25. package/dist/{types-DfzoyARl.d.ts → types-DRKJPaUn.d.ts} +99 -80
  26. package/package.json +9 -9
  27. package/src/components/Operations.tsx +4 -4
  28. package/src/components/Zod.tsx +3 -2
  29. package/src/generators/operationsGenerator.tsx +1 -1
  30. package/src/generators/zodGenerator.tsx +3 -2
  31. package/src/plugin.ts +2 -0
  32. package/src/types.ts +2 -1
  33. package/dist/components-BUkyR7lK.js.map +0 -1
  34. package/dist/components-MHUlEVjU.cjs.map +0 -1
  35. package/dist/generators-8AD8PdD3.js.map +0 -1
  36. package/dist/generators-Bo3q-m_p.cjs.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { Fabric, FileManager } from "@kubb/react-fabric";
1
2
  import * as OasTypes from "oas/types";
2
3
  import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
3
4
  import { Operation, Operation as Operation$1 } from "oas/operation";
@@ -5,7 +6,7 @@ import { OpenAPIV3 } from "openapi-types";
5
6
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
7
  import BaseOas from "oas";
7
8
  import { ConsolaInstance, LogLevel } from "consola";
8
- import { FileManager } from "@kubb/fabric-core";
9
+ import { KubbNode } from "@kubb/react-fabric/types";
9
10
 
10
11
  //#region ../oas/src/types.d.ts
11
12
  type contentType = 'application/json' | (string & {});
@@ -47,17 +48,17 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
47
48
  * Abstract class that contains the building blocks for plugins to create their own Generator
48
49
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
49
50
  */
50
- declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
51
+ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
51
52
  #private;
52
- constructor(options?: TOptions$1, context?: TContext);
53
- get options(): TOptions$1;
53
+ constructor(options?: TOptions, context?: TContext);
54
+ get options(): TOptions;
54
55
  get context(): TContext;
55
- set options(options: TOptions$1);
56
+ set options(options: TOptions);
56
57
  abstract build(...params: unknown[]): unknown;
57
58
  }
58
59
  //#endregion
59
60
  //#region ../core/src/fs/types.d.ts
60
- type BasePath<T$1 extends string = string> = `${T$1}/`;
61
+ type BasePath<T extends string = string> = `${T}/`;
61
62
  type Import = {
62
63
  /**
63
64
  * Import name to be used
@@ -131,9 +132,9 @@ type BaseName = `${string}.${string}`;
131
132
  * Path will be full qualified path to a specified file
132
133
  */
133
134
  type Path = string;
134
- type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
135
+ type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
135
136
  type OptionalPath = Path | undefined | null;
136
- type File<TMeta extends object = object> = {
137
+ type File$1<TMeta extends object = object> = {
137
138
  /**
138
139
  * Name to be used to create the path
139
140
  * Based on UNIX basename, `${name}.extname`
@@ -156,7 +157,7 @@ type File<TMeta extends object = object> = {
156
157
  };
157
158
  type ResolvedImport = Import;
158
159
  type ResolvedExport = Export;
159
- type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
160
+ type ResolvedFile<TMeta extends object = object> = File$1<TMeta> & {
160
161
  /**
161
162
  * @default object-hash
162
163
  */
@@ -220,7 +221,7 @@ type Logger = {
220
221
  };
221
222
  //#endregion
222
223
  //#region ../core/src/utils/types.d.ts
223
- type PossiblePromise<T$1> = Promise<T$1> | T$1;
224
+ type PossiblePromise<T> = Promise<T> | T;
224
225
  //#endregion
225
226
  //#region ../core/src/types.d.ts
226
227
  type InputPath = {
@@ -333,11 +334,11 @@ TName extends string = string,
333
334
  /**
334
335
  * Options of the plugin.
335
336
  */
336
- TOptions$1 extends object = object,
337
+ TOptions extends object = object,
337
338
  /**
338
339
  * Options of the plugin that can be used later on, see `options` inside your plugin config.
339
340
  */
340
- TResolvedOptions extends object = TOptions$1,
341
+ TResolvedOptions extends object = TOptions,
341
342
  /**
342
343
  * Context that you want to expose to other plugins.
343
344
  */
@@ -351,23 +352,23 @@ TResolvePathOptions extends object = object> = {
351
352
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
352
353
  */
353
354
  key: PluginKey<TName | string>;
354
- options: TOptions$1;
355
+ options: TOptions;
355
356
  resolvedOptions: TResolvedOptions;
356
357
  context: TContext;
357
358
  resolvePathOptions: TResolvePathOptions;
358
359
  };
359
360
  type PluginKey<TName> = [name: TName, identifier?: string | number];
360
- type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
361
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
361
362
  /**
362
363
  * Unique name used for the plugin
363
364
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
364
365
  * @example @kubb/typescript
365
366
  */
366
- name: TOptions$1['name'];
367
+ name: TOptions['name'];
367
368
  /**
368
369
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
369
370
  */
370
- options: TOptions$1['resolvedOptions'];
371
+ options: TOptions['resolvedOptions'];
371
372
  /**
372
373
  * 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.
373
374
  * Can be used to validate dependent plugins.
@@ -377,23 +378,23 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
377
378
  * 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.
378
379
  */
379
380
  post?: Array<string>;
380
- } & (TOptions$1['context'] extends never ? {
381
+ } & (TOptions['context'] extends never ? {
381
382
  context?: never;
382
383
  } : {
383
- context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
384
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
384
385
  });
385
- type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
386
- type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
386
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
387
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
387
388
  /**
388
389
  * Unique name used for the plugin
389
390
  * @example @kubb/typescript
390
391
  */
391
- name: TOptions$1['name'];
392
+ name: TOptions['name'];
392
393
  /**
393
394
  * Internal key used when a developer uses more than one of the same plugin
394
395
  * @private
395
396
  */
396
- key: TOptions$1['key'];
397
+ key: TOptions['key'];
397
398
  /**
398
399
  * 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.
399
400
  * Can be used to validate dependent plugins.
@@ -406,49 +407,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
406
407
  /**
407
408
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
408
409
  */
409
- options: TOptions$1['resolvedOptions'];
410
- } & (TOptions$1['context'] extends never ? {
410
+ options: TOptions['resolvedOptions'];
411
+ } & (TOptions['context'] extends never ? {
411
412
  context?: never;
412
413
  } : {
413
- context: TOptions$1['context'];
414
+ context: TOptions['context'];
414
415
  });
415
- type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
416
- type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
416
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
417
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
417
418
  /**
418
419
  * Start of the lifecycle of a plugin.
419
420
  * @type hookParallel
420
421
  */
421
- buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
422
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
422
423
  /**
423
424
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
424
425
  * Options can als be included.
425
426
  * @type hookFirst
426
427
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
427
428
  */
428
- resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
429
+ resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
429
430
  /**
430
431
  * Resolve to a name based on a string.
431
432
  * Useful when converting to PascalCase or camelCase.
432
433
  * @type hookFirst
433
434
  * @example ('pet') => 'Pet'
434
435
  */
435
- resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
436
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
436
437
  /**
437
438
  * End of the plugin lifecycle.
438
439
  * @type hookParallel
439
440
  */
440
- buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
441
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
441
442
  };
442
443
  type PluginLifecycleHooks = keyof PluginLifecycle;
443
- type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
444
- type ResolvePathParams<TOptions$1 = object> = {
444
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
445
+ type ResolvePathParams<TOptions = object> = {
445
446
  pluginKey?: Plugin['key'];
446
447
  baseName: BaseName;
447
448
  mode?: Mode;
448
449
  /**
449
450
  * Options to be passed to 'resolvePath' 3th parameter
450
451
  */
451
- options?: TOptions$1;
452
+ options?: TOptions;
452
453
  };
453
454
  type ResolveNameParams = {
454
455
  name: string;
@@ -461,15 +462,16 @@ type ResolveNameParams = {
461
462
  */
462
463
  type?: 'file' | 'function' | 'type' | 'const';
463
464
  };
464
- type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
465
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
466
+ fabric: Fabric;
465
467
  config: Config;
466
468
  /**
467
469
  * @deprecated
468
470
  */
469
471
  fileManager: FileManager;
470
472
  pluginManager: PluginManager;
471
- addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
472
- resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
473
+ addFile: (...file: Array<File$1>) => Promise<Array<ResolvedFile>>;
474
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
473
475
  resolveName: (params: ResolveNameParams) => string;
474
476
  logger: Logger;
475
477
  /**
@@ -479,12 +481,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
479
481
  /**
480
482
  * Current plugin
481
483
  */
482
- plugin: Plugin<TOptions$1>;
484
+ plugin: Plugin<TOptions>;
483
485
  };
484
486
  /**
485
487
  * Specify the export location for the files and define the behavior of the output
486
488
  */
487
- type Output<TOptions$1> = {
489
+ type Output<TOptions> = {
488
490
  /**
489
491
  * Path to the output folder or file that will contain the generated code
490
492
  */
@@ -497,11 +499,11 @@ type Output<TOptions$1> = {
497
499
  /**
498
500
  * Add a banner text in the beginning of every file
499
501
  */
500
- banner?: string | ((options: TOptions$1) => string);
502
+ banner?: string | ((options: TOptions) => string);
501
503
  /**
502
504
  * Add a footer text in the beginning of every file
503
505
  */
504
- footer?: string | ((options: TOptions$1) => string);
506
+ footer?: string | ((options: TOptions) => string);
505
507
  };
506
508
  type GroupContext = {
507
509
  group: string;
@@ -520,20 +522,21 @@ type Group = {
520
522
  //#region ../core/src/PluginManager.d.ts
521
523
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
522
524
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
523
- type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
525
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
524
526
  message: string;
525
527
  strategy: Strategy;
526
- hookName: H$1;
528
+ hookName: H;
527
529
  plugin: Plugin;
528
530
  parameters?: unknown[] | undefined;
529
531
  output?: unknown;
530
532
  };
531
- type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
532
- type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
533
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
534
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
533
535
  result: Result;
534
536
  plugin: Plugin;
535
537
  };
536
538
  type Options$2 = {
539
+ fabric: Fabric;
537
540
  logger: Logger;
538
541
  /**
539
542
  * @default Number.POSITIVE_INFINITY
@@ -545,20 +548,16 @@ type Events = {
545
548
  executed: [executer: Executer];
546
549
  error: [error: Error];
547
550
  };
548
- type GetFileProps<TOptions$1 = object> = {
551
+ type GetFileProps<TOptions = object> = {
549
552
  name: string;
550
553
  mode?: Mode;
551
554
  extname: Extname;
552
555
  pluginKey: Plugin['key'];
553
- options?: TOptions$1;
556
+ options?: TOptions;
554
557
  };
555
558
  declare class PluginManager {
556
559
  #private;
557
560
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
558
- /**
559
- * @deprecated do not use from pluginManager
560
- */
561
- readonly fileManager: FileManager;
562
561
  readonly events: EventEmitter<Events>;
563
562
  readonly config: Config;
564
563
  readonly executed: Array<Executer>;
@@ -571,7 +570,7 @@ declare class PluginManager {
571
570
  extname,
572
571
  pluginKey,
573
572
  options
574
- }: GetFileProps<TOptions>): File<{
573
+ }: GetFileProps<TOptions>): File$1<{
575
574
  pluginKey: Plugin['key'];
576
575
  }>;
577
576
  resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
@@ -671,12 +670,31 @@ type FileMetaBase = {
671
670
  pluginKey?: Plugin['key'];
672
671
  };
673
672
  //#endregion
673
+ //#region ../plugin-oas/src/generators/createGenerator.d.ts
674
+ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
675
+ name: string;
676
+ type: 'core';
677
+ operations: (props: OperationsProps<TOptions>) => Promise<File$1[]>;
678
+ operation: (props: OperationProps<TOptions>) => Promise<File$1[]>;
679
+ schema: (props: SchemaProps<TOptions>) => Promise<File$1[]>;
680
+ };
681
+ //#endregion
682
+ //#region ../plugin-oas/src/generators/createReactGenerator.d.ts
683
+ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
684
+ name: string;
685
+ type: 'react';
686
+ Operations: (props: OperationsProps<TOptions>) => KubbNode;
687
+ Operation: (props: OperationProps<TOptions>) => KubbNode;
688
+ Schema: (props: SchemaProps<TOptions>) => KubbNode;
689
+ };
690
+ //#endregion
674
691
  //#region ../plugin-oas/src/OperationGenerator.d.ts
675
- type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
692
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
693
+ fabric: Fabric;
676
694
  oas: Oas;
677
695
  exclude: Array<Exclude$1> | undefined;
678
696
  include: Array<Include> | undefined;
679
- override: Array<Override<TOptions$1>> | undefined;
697
+ override: Array<Override<TOptions>> | undefined;
680
698
  contentType: contentType | undefined;
681
699
  pluginManager: PluginManager;
682
700
  /**
@@ -697,7 +715,7 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
697
715
  method: HttpMethod;
698
716
  operation: Operation$1;
699
717
  }>>;
700
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
718
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File$1<TFileMeta>>>;
701
719
  }
702
720
  //#endregion
703
721
  //#region ../plugin-oas/src/SchemaMapper.d.ts
@@ -918,7 +936,8 @@ type Schema = {
918
936
  } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
919
937
  //#endregion
920
938
  //#region ../plugin-oas/src/SchemaGenerator.d.ts
921
- type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
939
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
940
+ fabric: Fabric;
922
941
  oas: Oas;
923
942
  pluginManager: PluginManager;
924
943
  /**
@@ -927,7 +946,7 @@ type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
927
946
  plugin: Plugin<TPluginOptions>;
928
947
  mode: Mode;
929
948
  include?: Array<'schemas' | 'responses' | 'requestBodies'>;
930
- override: Array<Override<TOptions$1>> | undefined;
949
+ override: Array<Override<TOptions>> | undefined;
931
950
  contentType?: contentType;
932
951
  output?: string;
933
952
  };
@@ -958,7 +977,7 @@ type SchemaProps$1 = {
958
977
  name?: string;
959
978
  parentName?: string;
960
979
  };
961
- declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context<TOptions$1, TPluginOptions>> {
980
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
962
981
  #private;
963
982
  refs: Refs;
964
983
  /**
@@ -973,36 +992,36 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
973
992
  static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
974
993
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
975
994
  static combineObjects(tree: Schema[] | undefined): Schema[];
976
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
995
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File$1<TFileMeta>>>;
977
996
  }
978
997
  //#endregion
979
- //#region ../plugin-oas/src/generator.d.ts
980
- type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
981
- instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
982
- options: TOptions$1['resolvedOptions'];
998
+ //#region ../plugin-oas/src/generators/types.d.ts
999
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
1000
+ /**
1001
+ * @deprecated
1002
+ */
1003
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
1004
+ options: TOptions['resolvedOptions'];
983
1005
  operations: Array<Operation$1>;
984
1006
  };
985
- type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
986
- instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
987
- options: TOptions$1['resolvedOptions'];
1007
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
1008
+ /**
1009
+ * @deprecated
1010
+ */
1011
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
1012
+ options: TOptions['resolvedOptions'];
988
1013
  operation: Operation$1;
989
1014
  };
990
- type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
991
- instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
992
- options: TOptions$1['resolvedOptions'];
1015
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
1016
+ instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
1017
+ options: TOptions['resolvedOptions'];
993
1018
  schema: {
994
1019
  name: string;
995
1020
  tree: Array<Schema>;
996
1021
  value: SchemaObject$1;
997
1022
  };
998
1023
  };
999
- type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
1000
- name: string;
1001
- operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
1002
- operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
1003
- schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
1004
- };
1005
- type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
1024
+ type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
1006
1025
  //#endregion
1007
1026
  //#region ../plugin-oas/src/types.d.ts
1008
1027
  type ResolvePathOptions = {
@@ -1088,8 +1107,8 @@ type ByContentType = {
1088
1107
  };
1089
1108
  type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
1090
1109
  type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
1091
- type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
1092
- options: Partial<TOptions$1>;
1110
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
1111
+ options: Partial<TOptions>;
1093
1112
  };
1094
1113
  //#endregion
1095
1114
  //#region src/types.d.ts
@@ -1218,5 +1237,5 @@ type ResolvedOptions = {
1218
1237
  };
1219
1238
  type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1220
1239
  //#endregion
1221
- export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, Generator as r, SchemaObject$1 as s, Options$1 as t };
1222
- //# sourceMappingURL=types-DfzoyARl.d.ts.map
1240
+ export { UserPluginWithLifeCycle as a, ReactGenerator as i, PluginZod as n, Operation$1 as o, Schema as r, SchemaObject$1 as s, Options$1 as t };
1241
+ //# sourceMappingURL=types-DRKJPaUn.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
5
5
  "keywords": [
6
6
  "zod",
@@ -69,21 +69,21 @@
69
69
  "!/**/__tests__/**"
70
70
  ],
71
71
  "dependencies": {
72
- "@kubb/core": "4.3.1",
73
- "@kubb/oas": "4.3.1",
74
- "@kubb/plugin-oas": "4.3.1",
75
- "@kubb/plugin-ts": "4.3.1",
76
- "@kubb/react": "4.3.1"
72
+ "@kubb/react-fabric": "0.2.8",
73
+ "@kubb/core": "4.4.0",
74
+ "@kubb/oas": "4.4.0",
75
+ "@kubb/plugin-oas": "4.4.0",
76
+ "@kubb/plugin-ts": "4.4.0"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@asteasolutions/zod-to-openapi": "^8.1.0",
80
80
  "@hono/zod-openapi": "0.19.2",
81
- "tsdown": "^0.15.9",
81
+ "tsdown": "^0.15.11",
82
82
  "zod": "^3.25.76",
83
- "@kubb/plugin-oas": "4.3.1"
83
+ "@kubb/plugin-oas": "4.4.0"
84
84
  },
85
85
  "peerDependencies": {
86
- "@kubb/react": "^4.3.0"
86
+ "@kubb/react-fabric": "0.2.8"
87
87
  },
88
88
  "engines": {
89
89
  "node": ">=20"
@@ -1,15 +1,15 @@
1
- import type { SchemaNames } from '@kubb/plugin-oas/hooks'
2
- import { Const, File, Type } from '@kubb/react'
3
-
4
1
  import transformers from '@kubb/core/transformers'
5
2
  import type { HttpMethod, Operation } from '@kubb/oas'
3
+ import type { SchemaNames } from '@kubb/plugin-oas/hooks'
4
+ import { Const, File, Type } from '@kubb/react-fabric'
5
+ import type { KubbNode } from '@kubb/react-fabric/types'
6
6
 
7
7
  type Props = {
8
8
  name: string
9
9
  operations: Array<{ operation: Operation; data: SchemaNames }>
10
10
  }
11
11
 
12
- export function Operations({ name, operations }: Props) {
12
+ export function Operations({ name, operations }: Props): KubbNode {
13
13
  const operationsJSON = operations.reduce(
14
14
  (prev, acc) => {
15
15
  prev[`"${acc.operation.getOperationId()}"`] = acc.data
@@ -1,7 +1,8 @@
1
1
  import transformers from '@kubb/core/transformers'
2
2
  import type { SchemaObject } from '@kubb/oas'
3
3
  import { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'
4
- import { Const, File, Type } from '@kubb/react'
4
+ import { Const, File, Type } from '@kubb/react-fabric'
5
+ import type { KubbNode } from '@kubb/react-fabric/types'
5
6
  import * as parserZod from '../parser.ts'
6
7
  import type { PluginZod } from '../types.ts'
7
8
 
@@ -33,7 +34,7 @@ export function Zod({
33
34
  wrapOutput,
34
35
  version,
35
36
  emptySchemaType,
36
- }: Props) {
37
+ }: Props): KubbNode {
37
38
  const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)
38
39
 
39
40
  const schemas = parserZod.sort(tree).filter((item) => {
@@ -2,7 +2,7 @@ import { usePlugin, usePluginManager } from '@kubb/core/hooks'
2
2
  import { createReactGenerator } from '@kubb/plugin-oas'
3
3
  import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
4
4
  import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
5
- import { File } from '@kubb/react'
5
+ import { File } from '@kubb/react-fabric'
6
6
  import { Operations } from '../components/Operations.tsx'
7
7
  import type { PluginZod } from '../types'
8
8
 
@@ -4,13 +4,13 @@ import { Oas } from '@kubb/plugin-oas/components'
4
4
  import { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'
5
5
  import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
6
6
  import { pluginTsName } from '@kubb/plugin-ts'
7
- import { File } from '@kubb/react'
7
+ import { File } from '@kubb/react-fabric'
8
8
  import { Zod } from '../components'
9
9
  import type { PluginZod } from '../types'
10
10
 
11
11
  export const zodGenerator = createReactGenerator<PluginZod>({
12
12
  name: 'zod',
13
- Operation({ operation, options }) {
13
+ Operation({ operation, options, instance }) {
14
14
  const { coercion: globalCoercion, inferred, typed, mapper, wrapOutput } = options
15
15
 
16
16
  const plugin = usePlugin<PluginZod>()
@@ -24,6 +24,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
24
24
  const file = getFile(operation)
25
25
  const schemas = getSchemas(operation)
26
26
  const schemaGenerator = new SchemaGenerator(options, {
27
+ fabric: instance.context.fabric,
27
28
  oas,
28
29
  plugin,
29
30
  pluginManager,
package/src/plugin.ts CHANGED
@@ -113,6 +113,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
113
113
  const mode = getMode(path.resolve(root, output.path))
114
114
 
115
115
  const schemaGenerator = new SchemaGenerator(this.plugin.options, {
116
+ fabric: this.fabric,
116
117
  oas,
117
118
  pluginManager: this.pluginManager,
118
119
  plugin: this.plugin,
@@ -127,6 +128,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
127
128
  await this.addFile(...schemaFiles)
128
129
 
129
130
  const operationGenerator = new OperationGenerator(this.plugin.options, {
131
+ fabric: this.fabric,
130
132
  oas,
131
133
  pluginManager: this.pluginManager,
132
134
  plugin: this.plugin,
package/src/types.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
2
  import type { contentType, Oas, SchemaObject } from '@kubb/oas'
3
- import type { Exclude, Generator, Include, Override, ResolvePathOptions, Schema } from '@kubb/plugin-oas'
3
+ import type { Exclude, Include, Override, ResolvePathOptions, Schema } from '@kubb/plugin-oas'
4
+ import type { Generator } from '@kubb/plugin-oas/generators'
4
5
 
5
6
  export type Options = {
6
7
  /**