@kubb/plugin-ts 4.3.1 → 4.4.1

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.
@@ -4,8 +4,10 @@ import { Operation, Operation as Operation$1 } from "oas/operation";
4
4
  import { OpenAPIV3 } from "openapi-types";
5
5
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
6
  import BaseOas from "oas";
7
+ import { KubbNode } from "@kubb/react-fabric/types";
8
+ import { KubbFile } from "@kubb/fabric-core/types";
9
+ import { Fabric, FileManager } from "@kubb/react-fabric";
7
10
  import { ConsolaInstance, LogLevel } from "consola";
8
- import { FileManager } from "@kubb/fabric-core";
9
11
  import ts from "typescript";
10
12
 
11
13
  //#region ../oas/src/types.d.ts
@@ -48,130 +50,15 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
48
50
  * Abstract class that contains the building blocks for plugins to create their own Generator
49
51
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
50
52
  */
51
- declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
53
+ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
52
54
  #private;
53
- constructor(options?: TOptions$1, context?: TContext);
54
- get options(): TOptions$1;
55
+ constructor(options?: TOptions, context?: TContext);
56
+ get options(): TOptions;
55
57
  get context(): TContext;
56
- set options(options: TOptions$1);
58
+ set options(options: TOptions);
57
59
  abstract build(...params: unknown[]): unknown;
58
60
  }
59
61
  //#endregion
60
- //#region ../core/src/fs/types.d.ts
61
- type BasePath<T$1 extends string = string> = `${T$1}/`;
62
- type Import = {
63
- /**
64
- * Import name to be used
65
- * @example ["useState"]
66
- * @example "React"
67
- */
68
- name: string | Array<string | {
69
- propertyName: string;
70
- name?: string;
71
- }>;
72
- /**
73
- * Path for the import
74
- * @example '@kubb/core'
75
- */
76
- path: string;
77
- /**
78
- * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
79
- */
80
- isTypeOnly?: boolean;
81
- isNameSpace?: boolean;
82
- /**
83
- * When root is set it will get the path with relative getRelativePath(root, path).
84
- */
85
- root?: string;
86
- };
87
- type Source = {
88
- name?: string;
89
- value?: string;
90
- isTypeOnly?: boolean;
91
- /**
92
- * Has const or type 'export'
93
- * @default false
94
- */
95
- isExportable?: boolean;
96
- /**
97
- * When set, barrel generation will add this
98
- * @default false
99
- */
100
- isIndexable?: boolean;
101
- };
102
- type Export = {
103
- /**
104
- * Export name to be used.
105
- * @example ["useState"]
106
- * @example "React"
107
- */
108
- name?: string | Array<string>;
109
- /**
110
- * Path for the import.
111
- * @example '@kubb/core'
112
- */
113
- path: string;
114
- /**
115
- * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
116
- */
117
- isTypeOnly?: boolean;
118
- /**
119
- * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
120
- */
121
- asAlias?: boolean;
122
- };
123
- type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
124
- type Mode = 'single' | 'split';
125
- /**
126
- * Name to be used to dynamicly create the baseName(based on input.path)
127
- * Based on UNIX basename
128
- * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
129
- */
130
- type BaseName = `${string}.${string}`;
131
- /**
132
- * Path will be full qualified path to a specified file
133
- */
134
- type Path = string;
135
- type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
136
- type OptionalPath = Path | undefined | null;
137
- type File<TMeta extends object = object> = {
138
- /**
139
- * Name to be used to create the path
140
- * Based on UNIX basename, `${name}.extname`
141
- * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
142
- */
143
- baseName: BaseName;
144
- /**
145
- * Path will be full qualified path to a specified file
146
- */
147
- path: AdvancedPath<BaseName> | Path;
148
- sources: Array<Source>;
149
- imports?: Array<Import>;
150
- exports?: Array<Export>;
151
- /**
152
- * Use extra meta, this is getting used to generate the barrel/index files.
153
- */
154
- meta?: TMeta;
155
- banner?: string;
156
- footer?: string;
157
- };
158
- type ResolvedImport = Import;
159
- type ResolvedExport = Export;
160
- type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
161
- /**
162
- * @default object-hash
163
- */
164
- id: string;
165
- /**
166
- * Contains the first part of the baseName, generated based on baseName
167
- * @link https://nodejs.org/api/path.html#pathformatpathobject
168
- */
169
- name: string;
170
- extname: Extname;
171
- imports: Array<ResolvedImport>;
172
- exports: Array<ResolvedExport>;
173
- };
174
- //#endregion
175
62
  //#region ../core/src/utils/EventEmitter.d.ts
176
63
  declare class EventEmitter<TEvents extends Record<string, any>> {
177
64
  #private;
@@ -221,7 +108,7 @@ type Logger = {
221
108
  };
222
109
  //#endregion
223
110
  //#region ../core/src/utils/types.d.ts
224
- type PossiblePromise<T$1> = Promise<T$1> | T$1;
111
+ type PossiblePromise<T> = Promise<T> | T;
225
112
  //#endregion
226
113
  //#region ../core/src/types.d.ts
227
114
  type InputPath = {
@@ -295,7 +182,7 @@ type Config<TInput = Input> = {
295
182
  * Override the extension to the generated imports and exports, by default each plugin will add an extension
296
183
  * @default { '.ts': '.ts'}
297
184
  */
298
- extension?: Record<Extname, Extname | ''>;
185
+ extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
299
186
  /**
300
187
  * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
301
188
  * @default 'named'
@@ -334,11 +221,11 @@ TName extends string = string,
334
221
  /**
335
222
  * Options of the plugin.
336
223
  */
337
- TOptions$1 extends object = object,
224
+ TOptions extends object = object,
338
225
  /**
339
226
  * Options of the plugin that can be used later on, see `options` inside your plugin config.
340
227
  */
341
- TResolvedOptions extends object = TOptions$1,
228
+ TResolvedOptions extends object = TOptions,
342
229
  /**
343
230
  * Context that you want to expose to other plugins.
344
231
  */
@@ -352,23 +239,23 @@ TResolvePathOptions extends object = object> = {
352
239
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
353
240
  */
354
241
  key: PluginKey<TName | string>;
355
- options: TOptions$1;
242
+ options: TOptions;
356
243
  resolvedOptions: TResolvedOptions;
357
244
  context: TContext;
358
245
  resolvePathOptions: TResolvePathOptions;
359
246
  };
360
247
  type PluginKey<TName> = [name: TName, identifier?: string | number];
361
- type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
248
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
362
249
  /**
363
250
  * Unique name used for the plugin
364
251
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
365
252
  * @example @kubb/typescript
366
253
  */
367
- name: TOptions$1['name'];
254
+ name: TOptions['name'];
368
255
  /**
369
256
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
370
257
  */
371
- options: TOptions$1['resolvedOptions'];
258
+ options: TOptions['resolvedOptions'];
372
259
  /**
373
260
  * 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.
374
261
  * Can be used to validate dependent plugins.
@@ -378,23 +265,23 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
378
265
  * 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.
379
266
  */
380
267
  post?: Array<string>;
381
- } & (TOptions$1['context'] extends never ? {
268
+ } & (TOptions['context'] extends never ? {
382
269
  context?: never;
383
270
  } : {
384
- context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
271
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
385
272
  });
386
- type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
387
- type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
273
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
274
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
388
275
  /**
389
276
  * Unique name used for the plugin
390
277
  * @example @kubb/typescript
391
278
  */
392
- name: TOptions$1['name'];
279
+ name: TOptions['name'];
393
280
  /**
394
281
  * Internal key used when a developer uses more than one of the same plugin
395
282
  * @private
396
283
  */
397
- key: TOptions$1['key'];
284
+ key: TOptions['key'];
398
285
  /**
399
286
  * 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.
400
287
  * Can be used to validate dependent plugins.
@@ -407,49 +294,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
407
294
  /**
408
295
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
409
296
  */
410
- options: TOptions$1['resolvedOptions'];
411
- } & (TOptions$1['context'] extends never ? {
297
+ options: TOptions['resolvedOptions'];
298
+ } & (TOptions['context'] extends never ? {
412
299
  context?: never;
413
300
  } : {
414
- context: TOptions$1['context'];
301
+ context: TOptions['context'];
415
302
  });
416
- type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
417
- type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
303
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
304
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
418
305
  /**
419
306
  * Start of the lifecycle of a plugin.
420
307
  * @type hookParallel
421
308
  */
422
- buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
309
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
423
310
  /**
424
311
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
425
312
  * Options can als be included.
426
313
  * @type hookFirst
427
314
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
428
315
  */
429
- resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
316
+ resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
430
317
  /**
431
318
  * Resolve to a name based on a string.
432
319
  * Useful when converting to PascalCase or camelCase.
433
320
  * @type hookFirst
434
321
  * @example ('pet') => 'Pet'
435
322
  */
436
- resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
323
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
437
324
  /**
438
325
  * End of the plugin lifecycle.
439
326
  * @type hookParallel
440
327
  */
441
- buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
328
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
442
329
  };
443
330
  type PluginLifecycleHooks = keyof PluginLifecycle;
444
- type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
445
- type ResolvePathParams<TOptions$1 = object> = {
331
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
332
+ type ResolvePathParams<TOptions = object> = {
446
333
  pluginKey?: Plugin['key'];
447
- baseName: BaseName;
448
- mode?: Mode;
334
+ baseName: KubbFile.BaseName;
335
+ mode?: KubbFile.Mode;
449
336
  /**
450
337
  * Options to be passed to 'resolvePath' 3th parameter
451
338
  */
452
- options?: TOptions$1;
339
+ options?: TOptions;
453
340
  };
454
341
  type ResolveNameParams = {
455
342
  name: string;
@@ -462,15 +349,16 @@ type ResolveNameParams = {
462
349
  */
463
350
  type?: 'file' | 'function' | 'type' | 'const';
464
351
  };
465
- type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
352
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
353
+ fabric: Fabric;
466
354
  config: Config;
467
355
  /**
468
356
  * @deprecated
469
357
  */
470
358
  fileManager: FileManager;
471
359
  pluginManager: PluginManager;
472
- addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
473
- resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
360
+ addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
361
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
474
362
  resolveName: (params: ResolveNameParams) => string;
475
363
  logger: Logger;
476
364
  /**
@@ -480,12 +368,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
480
368
  /**
481
369
  * Current plugin
482
370
  */
483
- plugin: Plugin<TOptions$1>;
371
+ plugin: Plugin<TOptions>;
484
372
  };
485
373
  /**
486
374
  * Specify the export location for the files and define the behavior of the output
487
375
  */
488
- type Output<TOptions$1> = {
376
+ type Output<TOptions> = {
489
377
  /**
490
378
  * Path to the output folder or file that will contain the generated code
491
379
  */
@@ -498,11 +386,11 @@ type Output<TOptions$1> = {
498
386
  /**
499
387
  * Add a banner text in the beginning of every file
500
388
  */
501
- banner?: string | ((options: TOptions$1) => string);
389
+ banner?: string | ((options: TOptions) => string);
502
390
  /**
503
391
  * Add a footer text in the beginning of every file
504
392
  */
505
- footer?: string | ((options: TOptions$1) => string);
393
+ footer?: string | ((options: TOptions) => string);
506
394
  };
507
395
  type GroupContext = {
508
396
  group: string;
@@ -521,20 +409,21 @@ type Group = {
521
409
  //#region ../core/src/PluginManager.d.ts
522
410
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
523
411
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
524
- type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
412
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
525
413
  message: string;
526
414
  strategy: Strategy;
527
- hookName: H$1;
415
+ hookName: H;
528
416
  plugin: Plugin;
529
417
  parameters?: unknown[] | undefined;
530
418
  output?: unknown;
531
419
  };
532
- type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
533
- type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
420
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
421
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
534
422
  result: Result;
535
423
  plugin: Plugin;
536
424
  };
537
425
  type Options$2 = {
426
+ fabric: Fabric;
538
427
  logger: Logger;
539
428
  /**
540
429
  * @default Number.POSITIVE_INFINITY
@@ -546,20 +435,16 @@ type Events = {
546
435
  executed: [executer: Executer];
547
436
  error: [error: Error];
548
437
  };
549
- type GetFileProps<TOptions$1 = object> = {
438
+ type GetFileProps<TOptions = object> = {
550
439
  name: string;
551
- mode?: Mode;
552
- extname: Extname;
440
+ mode?: KubbFile.Mode;
441
+ extname: KubbFile.Extname;
553
442
  pluginKey: Plugin['key'];
554
- options?: TOptions$1;
443
+ options?: TOptions;
555
444
  };
556
445
  declare class PluginManager {
557
446
  #private;
558
447
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
559
- /**
560
- * @deprecated do not use from pluginManager
561
- */
562
- readonly fileManager: FileManager;
563
448
  readonly events: EventEmitter<Events>;
564
449
  readonly config: Config;
565
450
  readonly executed: Array<Executer>;
@@ -572,10 +457,10 @@ declare class PluginManager {
572
457
  extname,
573
458
  pluginKey,
574
459
  options
575
- }: GetFileProps<TOptions>): File<{
460
+ }: GetFileProps<TOptions>): KubbFile.File<{
576
461
  pluginKey: Plugin['key'];
577
462
  }>;
578
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
463
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
579
464
  resolveName: (params: ResolveNameParams) => string;
580
465
  /**
581
466
  * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
@@ -672,6 +557,170 @@ type FileMetaBase = {
672
557
  pluginKey?: Plugin['key'];
673
558
  };
674
559
  //#endregion
560
+ //#region ../plugin-oas/src/generators/createReactGenerator.d.ts
561
+ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
562
+ name: string;
563
+ type: 'react';
564
+ Operations: (props: OperationsProps<TOptions>) => KubbNode;
565
+ Operation: (props: OperationProps<TOptions>) => KubbNode;
566
+ Schema: (props: SchemaProps$1<TOptions>) => KubbNode;
567
+ };
568
+ //#endregion
569
+ //#region ../plugin-oas/src/generators/types.d.ts
570
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
571
+ /**
572
+ * @deprecated
573
+ */
574
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
575
+ options: TOptions['resolvedOptions'];
576
+ operations: Array<Operation$1>;
577
+ };
578
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
579
+ /**
580
+ * @deprecated
581
+ */
582
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
583
+ options: TOptions['resolvedOptions'];
584
+ operation: Operation$1;
585
+ };
586
+ type SchemaProps$1<TOptions extends PluginFactoryOptions> = {
587
+ instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
588
+ options: TOptions['resolvedOptions'];
589
+ schema: {
590
+ name: string;
591
+ tree: Array<Schema>;
592
+ value: SchemaObject$1;
593
+ };
594
+ };
595
+ type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
596
+ //#endregion
597
+ //#region ../plugin-oas/src/generators/createGenerator.d.ts
598
+ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
599
+ name: string;
600
+ type: 'core';
601
+ operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
602
+ operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
603
+ schema: (props: SchemaProps$1<TOptions>) => Promise<KubbFile.File[]>;
604
+ };
605
+ //#endregion
606
+ //#region ../plugin-oas/src/types.d.ts
607
+ type ResolvePathOptions = {
608
+ pluginKey?: Plugin['key'];
609
+ group?: {
610
+ tag?: string;
611
+ path?: string;
612
+ };
613
+ type?: ResolveNameParams['type'];
614
+ };
615
+ /**
616
+ * `propertyName` is the ref name + resolved with the nameResolver
617
+ * @example import { Pet } from './Pet'
618
+ *
619
+ * `originalName` is the original name used(in PascalCase), only used to remove duplicates
620
+ *
621
+ * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
622
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
623
+ */
624
+ type Ref = {
625
+ propertyName: string;
626
+ originalName: string;
627
+ path: KubbFile.OptionalPath;
628
+ pluginKey?: Plugin['key'];
629
+ };
630
+ type Refs = Record<string, Ref>;
631
+ type OperationSchema = {
632
+ /**
633
+ * Converted name, contains already `PathParams`, `QueryParams`, ...
634
+ */
635
+ name: string;
636
+ schema: SchemaObject$1;
637
+ operation?: Operation$1;
638
+ /**
639
+ * OperationName in PascalCase, only being used in OperationGenerator
640
+ */
641
+ operationName: string;
642
+ description?: string;
643
+ statusCode?: number;
644
+ keys?: string[];
645
+ keysToOmit?: string[];
646
+ withData?: boolean;
647
+ };
648
+ type OperationSchemas = {
649
+ pathParams?: OperationSchema & {
650
+ keysToOmit?: never;
651
+ };
652
+ queryParams?: OperationSchema & {
653
+ keysToOmit?: never;
654
+ };
655
+ headerParams?: OperationSchema & {
656
+ keysToOmit?: never;
657
+ };
658
+ request?: OperationSchema;
659
+ response: OperationSchema;
660
+ responses: Array<OperationSchema>;
661
+ statusCodes?: Array<OperationSchema>;
662
+ errors?: Array<OperationSchema>;
663
+ };
664
+ type ByTag = {
665
+ type: 'tag';
666
+ pattern: string | RegExp;
667
+ };
668
+ type ByOperationId = {
669
+ type: 'operationId';
670
+ pattern: string | RegExp;
671
+ };
672
+ type ByPath = {
673
+ type: 'path';
674
+ pattern: string | RegExp;
675
+ };
676
+ type ByMethod = {
677
+ type: 'method';
678
+ pattern: HttpMethod | RegExp;
679
+ };
680
+ type BySchemaName = {
681
+ type: 'schemaName';
682
+ pattern: string | RegExp;
683
+ };
684
+ type ByContentType = {
685
+ type: 'contentType';
686
+ pattern: string | RegExp;
687
+ };
688
+ type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
689
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
690
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
691
+ options: Partial<TOptions>;
692
+ };
693
+ //#endregion
694
+ //#region ../plugin-oas/src/OperationGenerator.d.ts
695
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
696
+ fabric: Fabric;
697
+ oas: Oas;
698
+ exclude: Array<Exclude$1> | undefined;
699
+ include: Array<Include> | undefined;
700
+ override: Array<Override<TOptions>> | undefined;
701
+ contentType: contentType | undefined;
702
+ pluginManager: PluginManager;
703
+ /**
704
+ * Current plugin
705
+ */
706
+ plugin: Plugin<TPluginOptions>;
707
+ mode: KubbFile.Mode;
708
+ };
709
+ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
710
+ #private;
711
+ getSchemas(operation: Operation$1, {
712
+ resolveName
713
+ }?: {
714
+ resolveName?: (name: string) => string;
715
+ }): OperationSchemas;
716
+ getOperations(): Promise<Array<{
717
+ path: string;
718
+ method: HttpMethod;
719
+ operation: Operation$1;
720
+ }>>;
721
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
722
+ }
723
+ //#endregion
675
724
  //#region ../plugin-oas/src/SchemaMapper.d.ts
676
725
  type SchemaKeywordMapper = {
677
726
  object: {
@@ -785,7 +834,7 @@ type SchemaKeywordMapper = {
785
834
  /**
786
835
  * Full qualified path.
787
836
  */
788
- path: OptionalPath;
837
+ path: KubbFile.OptionalPath;
789
838
  /**
790
839
  * When true `File.Import` will be used.
791
840
  * When false a reference will be used inside the current file.
@@ -889,105 +938,18 @@ type Schema = {
889
938
  keyword: string;
890
939
  } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
891
940
  //#endregion
892
- //#region ../plugin-oas/src/types.d.ts
893
- type ResolvePathOptions = {
894
- pluginKey?: Plugin['key'];
895
- group?: {
896
- tag?: string;
897
- path?: string;
898
- };
899
- type?: ResolveNameParams['type'];
900
- };
901
- /**
902
- * `propertyName` is the ref name + resolved with the nameResolver
903
- * @example import { Pet } from './Pet'
904
- *
905
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
906
- *
907
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
908
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
909
- */
910
- type Ref = {
911
- propertyName: string;
912
- originalName: string;
913
- path: OptionalPath;
914
- pluginKey?: Plugin['key'];
915
- };
916
- type Refs = Record<string, Ref>;
917
- type OperationSchema = {
918
- /**
919
- * Converted name, contains already `PathParams`, `QueryParams`, ...
920
- */
921
- name: string;
922
- schema: SchemaObject$1;
923
- operation?: Operation$1;
924
- /**
925
- * OperationName in PascalCase, only being used in OperationGenerator
926
- */
927
- operationName: string;
928
- description?: string;
929
- statusCode?: number;
930
- keys?: string[];
931
- keysToOmit?: string[];
932
- withData?: boolean;
933
- };
934
- type OperationSchemas = {
935
- pathParams?: OperationSchema & {
936
- keysToOmit?: never;
937
- };
938
- queryParams?: OperationSchema & {
939
- keysToOmit?: never;
940
- };
941
- headerParams?: OperationSchema & {
942
- keysToOmit?: never;
943
- };
944
- request?: OperationSchema;
945
- response: OperationSchema;
946
- responses: Array<OperationSchema>;
947
- statusCodes?: Array<OperationSchema>;
948
- errors?: Array<OperationSchema>;
949
- };
950
- type ByTag = {
951
- type: 'tag';
952
- pattern: string | RegExp;
953
- };
954
- type ByOperationId = {
955
- type: 'operationId';
956
- pattern: string | RegExp;
957
- };
958
- type ByPath = {
959
- type: 'path';
960
- pattern: string | RegExp;
961
- };
962
- type ByMethod = {
963
- type: 'method';
964
- pattern: HttpMethod | RegExp;
965
- };
966
- type BySchemaName = {
967
- type: 'schemaName';
968
- pattern: string | RegExp;
969
- };
970
- type ByContentType = {
971
- type: 'contentType';
972
- pattern: string | RegExp;
973
- };
974
- type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
975
- type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
976
- type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
977
- options: Partial<TOptions$1>;
978
- };
979
- //#endregion
980
941
  //#region ../plugin-oas/src/SchemaGenerator.d.ts
981
- type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
942
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
943
+ fabric: Fabric;
982
944
  oas: Oas;
983
945
  pluginManager: PluginManager;
984
946
  /**
985
947
  * Current plugin
986
948
  */
987
949
  plugin: Plugin<TPluginOptions>;
988
- mode: Mode;
950
+ mode: KubbFile.Mode;
989
951
  include?: Array<'schemas' | 'responses' | 'requestBodies'>;
990
- override: Array<Override<TOptions$1>> | undefined;
952
+ override: Array<Override<TOptions>> | undefined;
991
953
  contentType?: contentType;
992
954
  output?: string;
993
955
  };
@@ -1010,15 +972,15 @@ type SchemaGeneratorOptions = {
1010
972
  * TODO TODO add docs
1011
973
  * @beta
1012
974
  */
1013
- schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
975
+ schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
1014
976
  };
1015
977
  };
1016
- type SchemaProps$1 = {
978
+ type SchemaProps = {
1017
979
  schemaObject?: SchemaObject$1;
1018
980
  name?: string;
1019
981
  parentName?: string;
1020
982
  };
1021
- 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>> {
983
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
1022
984
  #private;
1023
985
  refs: Refs;
1024
986
  /**
@@ -1026,71 +988,14 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
1026
988
  * Delegates to getBaseTypeFromSchema internally and
1027
989
  * optionally adds a union with null.
1028
990
  */
1029
- parse(props: SchemaProps$1): Schema[];
991
+ parse(props: SchemaProps): Schema[];
1030
992
  deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
1031
993
  find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1032
994
  static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
1033
995
  static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1034
996
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1035
997
  static combineObjects(tree: Schema[] | undefined): Schema[];
1036
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
1037
- }
1038
- //#endregion
1039
- //#region ../plugin-oas/src/generator.d.ts
1040
- type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
1041
- instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
1042
- options: TOptions$1['resolvedOptions'];
1043
- operations: Array<Operation$1>;
1044
- };
1045
- type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
1046
- instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
1047
- options: TOptions$1['resolvedOptions'];
1048
- operation: Operation$1;
1049
- };
1050
- type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
1051
- instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
1052
- options: TOptions$1['resolvedOptions'];
1053
- schema: {
1054
- name: string;
1055
- tree: Array<Schema>;
1056
- value: SchemaObject$1;
1057
- };
1058
- };
1059
- type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
1060
- name: string;
1061
- operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
1062
- operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
1063
- schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
1064
- };
1065
- type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
1066
- //#endregion
1067
- //#region ../plugin-oas/src/OperationGenerator.d.ts
1068
- type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
1069
- oas: Oas;
1070
- exclude: Array<Exclude$1> | undefined;
1071
- include: Array<Include> | undefined;
1072
- override: Array<Override<TOptions$1>> | undefined;
1073
- contentType: contentType | undefined;
1074
- pluginManager: PluginManager;
1075
- /**
1076
- * Current plugin
1077
- */
1078
- plugin: Plugin<TPluginOptions>;
1079
- mode: Mode;
1080
- };
1081
- declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
1082
- #private;
1083
- getSchemas(operation: Operation$1, {
1084
- resolveName
1085
- }?: {
1086
- resolveName?: (name: string) => string;
1087
- }): OperationSchemas;
1088
- getOperations(): Promise<Array<{
1089
- path: string;
1090
- method: HttpMethod;
1091
- operation: Operation$1;
1092
- }>>;
1093
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
998
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
1094
999
  }
1095
1000
  //#endregion
1096
1001
  //#region src/types.d.ts
@@ -1205,5 +1110,5 @@ type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, {
1205
1110
  usedEnumNames: Record<string, number>;
1206
1111
  }, ResolvePathOptions>;
1207
1112
  //#endregion
1208
- export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, Generator as r, SchemaObject$1 as s, Options$1 as t };
1209
- //# sourceMappingURL=types-Djigz1rf.d.cts.map
1113
+ export { UserPluginWithLifeCycle as a, ReactGenerator as i, PluginTs as n, OasTypes as o, Schema as r, SchemaObject$1 as s, Options$1 as t };
1114
+ //# sourceMappingURL=types-DEsrThze.d.cts.map