@kubb/plugin-mcp 3.16.1 → 3.16.3

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 (41) hide show
  1. package/dist/OperationGenerator-BMJ9Szu5.d.cts +1111 -0
  2. package/dist/OperationGenerator-D1X1O_-A.d.ts +1111 -0
  3. package/dist/Server-BX80OVzu.js +90 -0
  4. package/dist/Server-BX80OVzu.js.map +1 -0
  5. package/dist/Server-Bh-nULhJ.cjs +124 -0
  6. package/dist/Server-Bh-nULhJ.cjs.map +1 -0
  7. package/dist/components.cjs +2 -11
  8. package/dist/components.d.cts +31 -25
  9. package/dist/components.d.ts +31 -25
  10. package/dist/components.js +3 -3
  11. package/dist/generators-CFdUB1k-.js +225 -0
  12. package/dist/generators-CFdUB1k-.js.map +1 -0
  13. package/dist/generators-UZiEnnoX.cjs +236 -0
  14. package/dist/generators-UZiEnnoX.cjs.map +1 -0
  15. package/dist/generators.cjs +4 -16
  16. package/dist/generators.d.cts +9 -9
  17. package/dist/generators.d.ts +9 -9
  18. package/dist/generators.js +4 -4
  19. package/dist/index.cjs +82 -101
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +7 -8
  22. package/dist/index.d.ts +7 -8
  23. package/dist/index.js +82 -95
  24. package/dist/index.js.map +1 -1
  25. package/dist/types-DLgrsgaK.d.ts +168 -0
  26. package/dist/types-Dg5mHzgC.d.cts +168 -0
  27. package/package.json +21 -36
  28. package/dist/chunk-JTYWPGT3.js +0 -178
  29. package/dist/chunk-JTYWPGT3.js.map +0 -1
  30. package/dist/chunk-MTZE6GGJ.cjs +0 -181
  31. package/dist/chunk-MTZE6GGJ.cjs.map +0 -1
  32. package/dist/chunk-ODMTYF4L.cjs +0 -97
  33. package/dist/chunk-ODMTYF4L.cjs.map +0 -1
  34. package/dist/chunk-YP4TIQ5F.js +0 -95
  35. package/dist/chunk-YP4TIQ5F.js.map +0 -1
  36. package/dist/components.cjs.map +0 -1
  37. package/dist/components.js.map +0 -1
  38. package/dist/generators.cjs.map +0 -1
  39. package/dist/generators.js.map +0 -1
  40. package/dist/types-B4DlUSkU.d.cts +0 -54
  41. package/dist/types-B4DlUSkU.d.ts +0 -54
@@ -0,0 +1,1111 @@
1
+ import { ConsolaInstance, LogLevel } from "consola";
2
+ import * as OasTypes from "oas/types";
3
+ import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
4
+ import { Operation, Operation as Operation$1 } from "oas/operation";
5
+ import { OpenAPIV3 } from "openapi-types";
6
+ import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
7
+ import BaseOas from "oas";
8
+
9
+ //#region ../core/src/fs/types.d.ts
10
+ type BasePath<T extends string = string> = `${T}/`;
11
+ type Import = {
12
+ /**
13
+ * Import name to be used
14
+ * @example ["useState"]
15
+ * @example "React"
16
+ */
17
+ name: string | Array<string | {
18
+ propertyName: string;
19
+ name?: string;
20
+ }>;
21
+ /**
22
+ * Path for the import
23
+ * @example '@kubb/core'
24
+ */
25
+ path: string;
26
+ /**
27
+ * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
28
+ */
29
+ isTypeOnly?: boolean;
30
+ isNameSpace?: boolean;
31
+ /**
32
+ * When root is set it will get the path with relative getRelativePath(root, path).
33
+ */
34
+ root?: string;
35
+ };
36
+ type Source = {
37
+ name?: string;
38
+ value?: string;
39
+ isTypeOnly?: boolean;
40
+ /**
41
+ * Has const or type 'export'
42
+ * @default false
43
+ */
44
+ isExportable?: boolean;
45
+ /**
46
+ * When set, barrel generation will add this
47
+ * @default false
48
+ */
49
+ isIndexable?: boolean;
50
+ };
51
+ type Export = {
52
+ /**
53
+ * Export name to be used.
54
+ * @example ["useState"]
55
+ * @example "React"
56
+ */
57
+ name?: string | Array<string>;
58
+ /**
59
+ * Path for the import.
60
+ * @example '@kubb/core'
61
+ */
62
+ path: string;
63
+ /**
64
+ * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
65
+ */
66
+ isTypeOnly?: boolean;
67
+ /**
68
+ * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
69
+ */
70
+ asAlias?: boolean;
71
+ };
72
+ type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
73
+ type Mode = 'single' | 'split';
74
+ /**
75
+ * Name to be used to dynamicly create the baseName(based on input.path)
76
+ * Based on UNIX basename
77
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
78
+ */
79
+ type BaseName = `${string}.${string}`;
80
+ /**
81
+ * Path will be full qualified path to a specified file
82
+ */
83
+ type Path = string;
84
+ type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
85
+ type OptionalPath = Path | undefined | null;
86
+ type File<TMeta extends object = object> = {
87
+ /**
88
+ * Name to be used to create the path
89
+ * Based on UNIX basename, `${name}.extname`
90
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
91
+ */
92
+ baseName: BaseName;
93
+ /**
94
+ * Path will be full qualified path to a specified file
95
+ */
96
+ path: AdvancedPath<BaseName> | Path;
97
+ sources: Array<Source>;
98
+ imports?: Array<Import>;
99
+ exports?: Array<Export>;
100
+ /**
101
+ * Use extra meta, this is getting used to generate the barrel/index files.
102
+ */
103
+ meta?: TMeta;
104
+ banner?: string;
105
+ footer?: string;
106
+ };
107
+ type ResolvedImport = Import;
108
+ type ResolvedExport = Export;
109
+ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
110
+ /**
111
+ * @default object-hash
112
+ */
113
+ id: string;
114
+ /**
115
+ * Contains the first part of the baseName, generated based on baseName
116
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
117
+ */
118
+ name: string;
119
+ extname: Extname;
120
+ imports: Array<ResolvedImport>;
121
+ exports: Array<ResolvedExport>;
122
+ };
123
+ //#endregion
124
+ //#region ../core/src/BaseGenerator.d.ts
125
+ /**
126
+ * Abstract class that contains the building blocks for plugins to create their own Generator
127
+ * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
128
+ */
129
+ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
130
+ #private;
131
+ constructor(options?: TOptions, context?: TContext);
132
+ get options(): TOptions;
133
+ get context(): TContext;
134
+ set options(options: TOptions);
135
+ abstract build(...params: unknown[]): unknown;
136
+ }
137
+ //#endregion
138
+ //#region ../core/src/utils/EventEmitter.d.ts
139
+ declare class EventEmitter<TEvents extends Record<string, any>> {
140
+ #private;
141
+ constructor();
142
+ emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
143
+ on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
144
+ off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
145
+ removeAll(): void;
146
+ }
147
+ //#endregion
148
+ //#region ../core/src/logger.d.ts
149
+ type DebugEvent = {
150
+ date: Date;
151
+ logs: string[];
152
+ fileName?: string;
153
+ };
154
+ type Events$1 = {
155
+ start: [message: string];
156
+ success: [message: string];
157
+ error: [message: string, cause: Error];
158
+ warning: [message: string];
159
+ debug: [DebugEvent];
160
+ info: [message: string];
161
+ progress_start: [{
162
+ id: string;
163
+ size: number;
164
+ message?: string;
165
+ }];
166
+ progressed: [{
167
+ id: string;
168
+ message?: string;
169
+ }];
170
+ progress_stop: [{
171
+ id: string;
172
+ }];
173
+ };
174
+ type Logger = {
175
+ /**
176
+ * Optional config name to show in CLI output
177
+ */
178
+ name?: string;
179
+ logLevel: LogLevel;
180
+ consola?: ConsolaInstance;
181
+ on: EventEmitter<Events$1>['on'];
182
+ emit: EventEmitter<Events$1>['emit'];
183
+ writeLogs: () => Promise<string[]>;
184
+ };
185
+ //#endregion
186
+ //#region ../core/src/utils/types.d.ts
187
+ type PossiblePromise<T> = Promise<T> | T;
188
+ type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
189
+ type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
190
+ //#endregion
191
+ //#region ../core/src/types.d.ts
192
+ type InputPath = {
193
+ /**
194
+ * Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
195
+ */
196
+ path: string;
197
+ };
198
+ type InputData = {
199
+ /**
200
+ * A `string` or `object` that contains your Swagger/OpenAPI data.
201
+ */
202
+ data: string | unknown;
203
+ };
204
+ type Input = InputPath | InputData | Array<InputPath>;
205
+ type BarrelType = 'all' | 'named' | 'propagate';
206
+ /**
207
+ * @private
208
+ */
209
+ type Config<TInput = Input> = {
210
+ /**
211
+ * The name to display in the CLI output.
212
+ */
213
+ name?: string;
214
+ /**
215
+ * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
216
+ * @default process.cwd()
217
+ */
218
+ root: string;
219
+ /**
220
+ * You can use either `input.path` or `input.data`, depending on your specific needs.
221
+ */
222
+ input: TInput;
223
+ output: {
224
+ /**
225
+ * The path where all generated files will be exported.
226
+ * This can be an absolute path or a path relative to the specified root option.
227
+ */
228
+ path: string;
229
+ /**
230
+ * Clean the output directory before each build.
231
+ */
232
+ clean?: boolean;
233
+ /**
234
+ * Save files to the file system.
235
+ * @default true
236
+ */
237
+ write?: boolean;
238
+ /**
239
+ * Override the extension to the generated imports and exports, by default each plugin will add an extension
240
+ * @default { '.ts': '.ts'}
241
+ */
242
+ extension?: Record<Extname, Extname | ''>;
243
+ /**
244
+ * 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`.
245
+ * @default 'named'
246
+ */
247
+ barrelType?: Exclude<BarrelType, 'propagate'> | false;
248
+ /**
249
+ * Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
250
+ * - 'simple': will only add banner with link to Kubb
251
+ * - 'full': will add source, title, description and the OpenAPI version used
252
+ * @default 'simple'
253
+ */
254
+ defaultBanner?: 'simple' | 'full' | false;
255
+ };
256
+ /**
257
+ * An array of Kubb plugins that will be used in the generation.
258
+ * Each plugin may include additional configurable options(defined in the plugin itself).
259
+ * If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
260
+ */
261
+ plugins?: Array<Plugin>;
262
+ /**
263
+ * Hooks that will be called when a specific action is triggered in Kubb.
264
+ */
265
+ hooks?: {
266
+ /**
267
+ * Hook that will be triggered at the end of all executions.
268
+ * Useful for running Prettier or ESLint to format/lint your code.
269
+ */
270
+ done?: string | Array<string>;
271
+ };
272
+ };
273
+ type PluginFactoryOptions<
274
+ /**
275
+ * Name to be used for the plugin, this will also be used for they key.
276
+ */
277
+ TName extends string = string,
278
+ /**
279
+ * Options of the plugin.
280
+ */
281
+ TOptions extends object = object,
282
+ /**
283
+ * Options of the plugin that can be used later on, see `options` inside your plugin config.
284
+ */
285
+ TResolvedOptions extends object = TOptions,
286
+ /**
287
+ * Context that you want to expose to other plugins.
288
+ */
289
+ TContext = any,
290
+ /**
291
+ * When calling `resolvePath` you can specify better types.
292
+ */
293
+ TResolvePathOptions extends object = object> = {
294
+ name: TName;
295
+ /**
296
+ * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
297
+ */
298
+ key: PluginKey<TName | string>;
299
+ options: TOptions;
300
+ resolvedOptions: TResolvedOptions;
301
+ context: TContext;
302
+ resolvePathOptions: TResolvePathOptions;
303
+ };
304
+ type PluginKey<TName> = [name: TName, identifier?: string | number];
305
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
306
+ /**
307
+ * Unique name used for the plugin
308
+ * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
309
+ * @example @kubb/typescript
310
+ */
311
+ name: TOptions['name'];
312
+ /**
313
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
314
+ */
315
+ options: TOptions['resolvedOptions'];
316
+ /**
317
+ * 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.
318
+ * Can be used to validate dependent plugins.
319
+ */
320
+ pre?: Array<string>;
321
+ /**
322
+ * 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.
323
+ */
324
+ post?: Array<string>;
325
+ } & (TOptions['context'] extends never ? {
326
+ context?: never;
327
+ } : {
328
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
329
+ });
330
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
331
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
332
+ /**
333
+ * Unique name used for the plugin
334
+ * @example @kubb/typescript
335
+ */
336
+ name: TOptions['name'];
337
+ /**
338
+ * Internal key used when a developer uses more than one of the same plugin
339
+ * @private
340
+ */
341
+ key: TOptions['key'];
342
+ /**
343
+ * 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.
344
+ * Can be used to validate dependent plugins.
345
+ */
346
+ pre?: Array<string>;
347
+ /**
348
+ * 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.
349
+ */
350
+ post?: Array<string>;
351
+ /**
352
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
353
+ */
354
+ options: TOptions['resolvedOptions'];
355
+ } & (TOptions['context'] extends never ? {
356
+ context?: never;
357
+ } : {
358
+ context: TOptions['context'];
359
+ });
360
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
361
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
362
+ /**
363
+ * Start of the lifecycle of a plugin.
364
+ * @type hookParallel
365
+ */
366
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
367
+ /**
368
+ * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
369
+ * Options can als be included.
370
+ * @type hookFirst
371
+ * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
372
+ */
373
+ resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
374
+ /**
375
+ * Resolve to a name based on a string.
376
+ * Useful when converting to PascalCase or camelCase.
377
+ * @type hookFirst
378
+ * @example ('pet') => 'Pet'
379
+ */
380
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
381
+ /**
382
+ * End of the plugin lifecycle.
383
+ * @type hookParallel
384
+ */
385
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
386
+ };
387
+ type PluginLifecycleHooks = keyof PluginLifecycle;
388
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
389
+ type ResolvePathParams<TOptions = object> = {
390
+ pluginKey?: Plugin['key'];
391
+ baseName: BaseName;
392
+ mode?: Mode;
393
+ /**
394
+ * Options to be passed to 'resolvePath' 3th parameter
395
+ */
396
+ options?: TOptions;
397
+ };
398
+ type ResolveNameParams = {
399
+ name: string;
400
+ pluginKey?: Plugin['key'];
401
+ /**
402
+ * `file` will be used to customize the name of the created file(use of camelCase)
403
+ * `function` can be used to customize the exported functions(use of camelCase)
404
+ * `type` is a special type for TypeScript(use of PascalCase)
405
+ * `const` can be used for variables(use of camelCase)
406
+ */
407
+ type?: 'file' | 'function' | 'type' | 'const';
408
+ };
409
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
410
+ config: Config;
411
+ fileManager: FileManager;
412
+ pluginManager: PluginManager;
413
+ addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
414
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
415
+ resolveName: (params: ResolveNameParams) => string;
416
+ logger: Logger;
417
+ /**
418
+ * All plugins
419
+ */
420
+ plugins: Plugin[];
421
+ /**
422
+ * Current plugin
423
+ */
424
+ plugin: Plugin<TOptions>;
425
+ };
426
+ /**
427
+ * Specify the export location for the files and define the behavior of the output
428
+ */
429
+ type Output<TOptions> = {
430
+ /**
431
+ * Path to the output folder or file that will contain the generated code
432
+ */
433
+ path: string;
434
+ /**
435
+ * Define what needs to be exported, here you can also disable the export of barrel files
436
+ * @default 'named'
437
+ */
438
+ barrelType?: BarrelType | false;
439
+ /**
440
+ * Add a banner text in the beginning of every file
441
+ */
442
+ banner?: string | ((options: TOptions) => string);
443
+ /**
444
+ * Add a footer text in the beginning of every file
445
+ */
446
+ footer?: string | ((options: TOptions) => string);
447
+ };
448
+ type GroupContext = {
449
+ group: string;
450
+ };
451
+ type Group = {
452
+ /**
453
+ * Define a type where to group the files on
454
+ */
455
+ type: 'tag' | 'path';
456
+ /**
457
+ * Return the name of a group based on the group name, this will be used for the file and name generation
458
+ */
459
+ name?: (context: GroupContext) => string;
460
+ };
461
+ //#endregion
462
+ //#region ../core/src/FileManager.d.ts
463
+ type FileMetaBase = {
464
+ pluginKey?: Plugin['key'];
465
+ };
466
+ type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
467
+ type AddIndexesProps = {
468
+ type: BarrelType | false | undefined;
469
+ /**
470
+ * Root based on root and output.path specified in the config
471
+ */
472
+ root: string;
473
+ /**
474
+ * Output for plugin
475
+ */
476
+ output: {
477
+ path: string;
478
+ };
479
+ group?: {
480
+ output: string;
481
+ exportAs: string;
482
+ };
483
+ logger?: Logger;
484
+ meta?: FileMetaBase;
485
+ };
486
+ type WriteFilesProps = {
487
+ root: Config['root'];
488
+ extension?: Record<Extname, Extname | ''>;
489
+ logger?: Logger;
490
+ dryRun?: boolean;
491
+ };
492
+ declare class FileManager {
493
+ #private;
494
+ constructor();
495
+ add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
496
+ getByPath(path: Path): Promise<ResolvedFile | null>;
497
+ deleteByPath(path: Path): Promise<void>;
498
+ clear(): Promise<void>;
499
+ getFiles(): Promise<Array<ResolvedFile>>;
500
+ processFiles({
501
+ dryRun,
502
+ root,
503
+ extension,
504
+ logger
505
+ }: WriteFilesProps): Promise<Array<ResolvedFile>>;
506
+ getBarrelFiles({
507
+ type,
508
+ meta,
509
+ root,
510
+ output,
511
+ logger
512
+ }: AddIndexesProps): Promise<File[]>;
513
+ static getMode(path: string | undefined | null): Mode;
514
+ }
515
+ //#endregion
516
+ //#region ../core/src/PluginManager.d.ts
517
+ type RequiredPluginLifecycle = Required<PluginLifecycle>;
518
+ type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
519
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
520
+ message: string;
521
+ strategy: Strategy;
522
+ hookName: H;
523
+ plugin: Plugin;
524
+ parameters?: unknown[] | undefined;
525
+ output?: unknown;
526
+ };
527
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
528
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
529
+ result: Result;
530
+ plugin: Plugin;
531
+ };
532
+ type Options$2 = {
533
+ logger: Logger;
534
+ /**
535
+ * @default Number.POSITIVE_INFINITY
536
+ */
537
+ concurrency?: number;
538
+ };
539
+ type Events = {
540
+ executing: [executer: Executer];
541
+ executed: [executer: Executer];
542
+ error: [error: Error];
543
+ };
544
+ type GetFileProps<TOptions = object> = {
545
+ name: string;
546
+ mode?: Mode;
547
+ extname: Extname;
548
+ pluginKey: Plugin['key'];
549
+ options?: TOptions;
550
+ };
551
+ declare class PluginManager {
552
+ #private;
553
+ readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
554
+ readonly fileManager: FileManager;
555
+ readonly events: EventEmitter<Events>;
556
+ readonly config: Config;
557
+ readonly executed: Array<Executer>;
558
+ readonly logger: Logger;
559
+ readonly options: Options$2;
560
+ constructor(config: Config, options: Options$2);
561
+ getFile<TOptions = object>({
562
+ name,
563
+ mode,
564
+ extname,
565
+ pluginKey,
566
+ options
567
+ }: GetFileProps<TOptions>): File<{
568
+ pluginKey: Plugin['key'];
569
+ }>;
570
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
571
+ resolveName: (params: ResolveNameParams) => string;
572
+ /**
573
+ * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
574
+ */
575
+ on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
576
+ /**
577
+ * Run a specific hookName for plugin x.
578
+ */
579
+ hookForPlugin<H extends PluginLifecycleHooks>({
580
+ pluginKey,
581
+ hookName,
582
+ parameters,
583
+ message
584
+ }: {
585
+ pluginKey: Plugin['key'];
586
+ hookName: H;
587
+ parameters: PluginParameter<H>;
588
+ message: string;
589
+ }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
590
+ /**
591
+ * Run a specific hookName for plugin x.
592
+ */
593
+ hookForPluginSync<H extends PluginLifecycleHooks>({
594
+ pluginKey,
595
+ hookName,
596
+ parameters,
597
+ message
598
+ }: {
599
+ pluginKey: Plugin['key'];
600
+ hookName: H;
601
+ parameters: PluginParameter<H>;
602
+ message: string;
603
+ }): Array<ReturnType<ParseResult<H>>> | null;
604
+ /**
605
+ * First non-null result stops and will return it's value.
606
+ */
607
+ hookFirst<H extends PluginLifecycleHooks>({
608
+ hookName,
609
+ parameters,
610
+ skipped,
611
+ message
612
+ }: {
613
+ hookName: H;
614
+ parameters: PluginParameter<H>;
615
+ skipped?: ReadonlySet<Plugin> | null;
616
+ message: string;
617
+ }): Promise<SafeParseResult<H>>;
618
+ /**
619
+ * First non-null result stops and will return it's value.
620
+ */
621
+ hookFirstSync<H extends PluginLifecycleHooks>({
622
+ hookName,
623
+ parameters,
624
+ skipped,
625
+ message
626
+ }: {
627
+ hookName: H;
628
+ parameters: PluginParameter<H>;
629
+ skipped?: ReadonlySet<Plugin> | null;
630
+ message: string;
631
+ }): SafeParseResult<H>;
632
+ /**
633
+ * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
634
+ */
635
+ hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
636
+ hookName,
637
+ parameters,
638
+ message
639
+ }: {
640
+ hookName: H;
641
+ parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
642
+ message: string;
643
+ }): Promise<Awaited<TOuput>[]>;
644
+ /**
645
+ * Chains plugins
646
+ */
647
+ hookSeq<H extends PluginLifecycleHooks>({
648
+ hookName,
649
+ parameters,
650
+ message
651
+ }: {
652
+ hookName: H;
653
+ parameters?: PluginParameter<H>;
654
+ message: string;
655
+ }): Promise<void>;
656
+ getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
657
+ getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
658
+ static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
659
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
660
+ }
661
+ //#endregion
662
+ //#region ../oas/src/types.d.ts
663
+ type contentType = 'application/json' | (string & {});
664
+ type SchemaObject$1 = OasTypes.SchemaObject & {
665
+ 'x-nullable'?: boolean;
666
+ $ref?: string;
667
+ };
668
+ //#endregion
669
+ //#region ../oas/src/Oas.d.ts
670
+ type Options$1 = {
671
+ contentType?: contentType;
672
+ discriminator?: 'strict' | 'inherit';
673
+ };
674
+ declare class Oas<const TOAS = unknown> extends BaseOas {
675
+ #private;
676
+ document: TOAS;
677
+ constructor({
678
+ oas,
679
+ user
680
+ }: {
681
+ oas: TOAS | OASDocument | string;
682
+ user?: User;
683
+ });
684
+ setOptions(options: Options$1): void;
685
+ get options(): Options$1;
686
+ get($ref: string): any;
687
+ getKey($ref: string): string | undefined;
688
+ set($ref: string, value: unknown): false | undefined;
689
+ getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
690
+ dereferenceWithRef(schema?: unknown): any;
691
+ getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
692
+ getRequestSchema(operation: Operation): SchemaObject | undefined;
693
+ getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
694
+ valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
695
+ }
696
+ //#endregion
697
+ //#region ../plugin-oas/src/SchemaMapper.d.ts
698
+ type SchemaKeywordMapper = {
699
+ object: {
700
+ keyword: 'object';
701
+ args: {
702
+ properties: {
703
+ [x: string]: Schema[];
704
+ };
705
+ additionalProperties: Schema[];
706
+ strict?: boolean;
707
+ };
708
+ };
709
+ url: {
710
+ keyword: 'url';
711
+ };
712
+ readOnly: {
713
+ keyword: 'readOnly';
714
+ };
715
+ writeOnly: {
716
+ keyword: 'writeOnly';
717
+ };
718
+ uuid: {
719
+ keyword: 'uuid';
720
+ };
721
+ email: {
722
+ keyword: 'email';
723
+ };
724
+ firstName: {
725
+ keyword: 'firstName';
726
+ };
727
+ lastName: {
728
+ keyword: 'lastName';
729
+ };
730
+ phone: {
731
+ keyword: 'phone';
732
+ };
733
+ password: {
734
+ keyword: 'password';
735
+ };
736
+ date: {
737
+ keyword: 'date';
738
+ args: {
739
+ type?: 'date' | 'string';
740
+ };
741
+ };
742
+ time: {
743
+ keyword: 'time';
744
+ args: {
745
+ type?: 'date' | 'string';
746
+ };
747
+ };
748
+ datetime: {
749
+ keyword: 'datetime';
750
+ args: {
751
+ offset?: boolean;
752
+ local?: boolean;
753
+ };
754
+ };
755
+ tuple: {
756
+ keyword: 'tuple';
757
+ args: {
758
+ items: Schema[];
759
+ min?: number;
760
+ max?: number;
761
+ rest?: Schema;
762
+ };
763
+ };
764
+ array: {
765
+ keyword: 'array';
766
+ args: {
767
+ items: Schema[];
768
+ min?: number;
769
+ max?: number;
770
+ unique?: boolean;
771
+ };
772
+ };
773
+ enum: {
774
+ keyword: 'enum';
775
+ args: {
776
+ name: string;
777
+ typeName: string;
778
+ asConst: boolean;
779
+ items: Array<{
780
+ name: string | number;
781
+ format: 'string' | 'number' | 'boolean';
782
+ value?: string | number | boolean;
783
+ }>;
784
+ };
785
+ };
786
+ and: {
787
+ keyword: 'and';
788
+ args: Schema[];
789
+ };
790
+ const: {
791
+ keyword: 'const';
792
+ args: {
793
+ name: string | number;
794
+ format: 'string' | 'number' | 'boolean';
795
+ value?: string | number | boolean;
796
+ };
797
+ };
798
+ union: {
799
+ keyword: 'union';
800
+ args: Schema[];
801
+ };
802
+ ref: {
803
+ keyword: 'ref';
804
+ args: {
805
+ name: string;
806
+ $ref: string;
807
+ /**
808
+ * Full qualified path.
809
+ */
810
+ path: OptionalPath;
811
+ /**
812
+ * When true `File.Import` will be used.
813
+ * When false a reference will be used inside the current file.
814
+ */
815
+ isImportable: boolean;
816
+ };
817
+ };
818
+ matches: {
819
+ keyword: 'matches';
820
+ args?: string;
821
+ };
822
+ boolean: {
823
+ keyword: 'boolean';
824
+ };
825
+ default: {
826
+ keyword: 'default';
827
+ args: string | number | boolean;
828
+ };
829
+ string: {
830
+ keyword: 'string';
831
+ };
832
+ integer: {
833
+ keyword: 'integer';
834
+ };
835
+ number: {
836
+ keyword: 'number';
837
+ };
838
+ max: {
839
+ keyword: 'max';
840
+ args: number;
841
+ };
842
+ min: {
843
+ keyword: 'min';
844
+ args: number;
845
+ };
846
+ describe: {
847
+ keyword: 'describe';
848
+ args: string;
849
+ };
850
+ example: {
851
+ keyword: 'example';
852
+ args: string;
853
+ };
854
+ deprecated: {
855
+ keyword: 'deprecated';
856
+ };
857
+ optional: {
858
+ keyword: 'optional';
859
+ };
860
+ undefined: {
861
+ keyword: 'undefined';
862
+ };
863
+ nullish: {
864
+ keyword: 'nullish';
865
+ };
866
+ nullable: {
867
+ keyword: 'nullable';
868
+ };
869
+ null: {
870
+ keyword: 'null';
871
+ };
872
+ any: {
873
+ keyword: 'any';
874
+ };
875
+ unknown: {
876
+ keyword: 'unknown';
877
+ };
878
+ void: {
879
+ keyword: 'void';
880
+ };
881
+ blob: {
882
+ keyword: 'blob';
883
+ };
884
+ schema: {
885
+ keyword: 'schema';
886
+ args: {
887
+ type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
888
+ format?: string;
889
+ };
890
+ };
891
+ name: {
892
+ keyword: 'name';
893
+ args: string;
894
+ };
895
+ catchall: {
896
+ keyword: 'catchall';
897
+ };
898
+ interface: {
899
+ keyword: 'interface';
900
+ };
901
+ };
902
+ type Schema = {
903
+ keyword: string;
904
+ } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
905
+ //#endregion
906
+ //#region ../plugin-oas/src/types.d.ts
907
+ type ResolvePathOptions = {
908
+ pluginKey?: Plugin['key'];
909
+ group?: {
910
+ tag?: string;
911
+ path?: string;
912
+ };
913
+ type?: ResolveNameParams['type'];
914
+ };
915
+ /**
916
+ * `propertyName` is the ref name + resolved with the nameResolver
917
+ * @example import { Pet } from './Pet'
918
+ *
919
+ * `originalName` is the original name used(in PascalCase), only used to remove duplicates
920
+ *
921
+ * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
922
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
923
+ */
924
+ type Ref = {
925
+ propertyName: string;
926
+ originalName: string;
927
+ path: OptionalPath;
928
+ pluginKey?: Plugin['key'];
929
+ };
930
+ type Refs = Record<string, Ref>;
931
+ type OperationSchema = {
932
+ /**
933
+ * Converted name, contains already `PathParams`, `QueryParams`, ...
934
+ */
935
+ name: string;
936
+ schema: SchemaObject$1;
937
+ operation?: Operation$1;
938
+ /**
939
+ * OperationName in PascalCase, only being used in OperationGenerator
940
+ */
941
+ operationName: string;
942
+ description?: string;
943
+ statusCode?: number;
944
+ keys?: string[];
945
+ keysToOmit?: string[];
946
+ withData?: boolean;
947
+ };
948
+ type OperationSchemas = {
949
+ pathParams?: OperationSchema & {
950
+ keysToOmit?: never;
951
+ };
952
+ queryParams?: OperationSchema & {
953
+ keysToOmit?: never;
954
+ };
955
+ headerParams?: OperationSchema & {
956
+ keysToOmit?: never;
957
+ };
958
+ request?: OperationSchema;
959
+ response: OperationSchema;
960
+ responses: Array<OperationSchema>;
961
+ statusCodes?: Array<OperationSchema>;
962
+ errors?: Array<OperationSchema>;
963
+ };
964
+ type ByTag = {
965
+ type: 'tag';
966
+ pattern: string | RegExp;
967
+ };
968
+ type ByOperationId = {
969
+ type: 'operationId';
970
+ pattern: string | RegExp;
971
+ };
972
+ type ByPath = {
973
+ type: 'path';
974
+ pattern: string | RegExp;
975
+ };
976
+ type ByMethod = {
977
+ type: 'method';
978
+ pattern: HttpMethod | RegExp;
979
+ };
980
+ type BySchemaName = {
981
+ type: 'schemaName';
982
+ pattern: string | RegExp;
983
+ };
984
+ type ByContentType = {
985
+ type: 'contentType';
986
+ pattern: string | RegExp;
987
+ };
988
+ type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
989
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
990
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
991
+ options: Partial<TOptions>;
992
+ };
993
+ //#endregion
994
+ //#region ../plugin-oas/src/SchemaGenerator.d.ts
995
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
996
+ oas: Oas;
997
+ pluginManager: PluginManager;
998
+ /**
999
+ * Current plugin
1000
+ */
1001
+ plugin: Plugin<TPluginOptions>;
1002
+ mode: Mode;
1003
+ include?: Array<'schemas' | 'responses' | 'requestBodies'>;
1004
+ override: Array<Override<TOptions>> | undefined;
1005
+ contentType?: contentType;
1006
+ output?: string;
1007
+ };
1008
+ type SchemaGeneratorOptions = {
1009
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
1010
+ unknownType: 'any' | 'unknown' | 'void';
1011
+ emptySchemaType: 'any' | 'unknown' | 'void';
1012
+ enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
1013
+ enumSuffix?: string;
1014
+ usedEnumNames?: Record<string, number>;
1015
+ mapper?: Record<string, string>;
1016
+ typed?: boolean;
1017
+ transformers: {
1018
+ /**
1019
+ * Customize the names based on the type that is provided by the plugin.
1020
+ */
1021
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
1022
+ /**
1023
+ * Receive schema and name(propertName) and return FakerMeta array
1024
+ * TODO TODO add docs
1025
+ * @beta
1026
+ */
1027
+ schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
1028
+ };
1029
+ };
1030
+ type SchemaProps$1 = {
1031
+ schemaObject?: SchemaObject$1;
1032
+ name?: string;
1033
+ parentName?: string;
1034
+ };
1035
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
1036
+ #private;
1037
+ refs: Refs;
1038
+ /**
1039
+ * Creates a type node from a given schema.
1040
+ * Delegates to getBaseTypeFromSchema internally and
1041
+ * optionally adds a union with null.
1042
+ */
1043
+ parse(props: SchemaProps$1): Schema[];
1044
+ deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
1045
+ find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1046
+ static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
1047
+ static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1048
+ static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1049
+ static combineObjects(tree: Schema[] | undefined): Schema[];
1050
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
1051
+ }
1052
+ //#endregion
1053
+ //#region ../plugin-oas/src/generator.d.ts
1054
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
1055
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
1056
+ options: TOptions['resolvedOptions'];
1057
+ operations: Array<Operation$1>;
1058
+ };
1059
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
1060
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
1061
+ options: TOptions['resolvedOptions'];
1062
+ operation: Operation$1;
1063
+ };
1064
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
1065
+ instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
1066
+ options: TOptions['resolvedOptions'];
1067
+ schema: {
1068
+ name: string;
1069
+ tree: Array<Schema>;
1070
+ value: SchemaObject$1;
1071
+ };
1072
+ };
1073
+ type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
1074
+ name: string;
1075
+ operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
1076
+ operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
1077
+ schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
1078
+ };
1079
+ type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
1080
+ //#endregion
1081
+ //#region ../plugin-oas/src/OperationGenerator.d.ts
1082
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
1083
+ oas: Oas;
1084
+ exclude: Array<Exclude$1> | undefined;
1085
+ include: Array<Include> | undefined;
1086
+ override: Array<Override<TOptions>> | undefined;
1087
+ contentType: contentType | undefined;
1088
+ pluginManager: PluginManager;
1089
+ /**
1090
+ * Current plugin
1091
+ */
1092
+ plugin: Plugin<TPluginOptions>;
1093
+ mode: Mode;
1094
+ };
1095
+ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
1096
+ #private;
1097
+ getSchemas(operation: Operation$1, {
1098
+ resolveName
1099
+ }?: {
1100
+ resolveName?: (name: string) => string;
1101
+ }): OperationSchemas;
1102
+ getOperations(): Promise<Array<{
1103
+ path: string;
1104
+ method: HttpMethod;
1105
+ operation: Operation$1;
1106
+ }>>;
1107
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
1108
+ }
1109
+ //#endregion
1110
+ export { Exclude$1 as Exclude, File, Generator, Group, Include, Oas, OperationSchemas, Output, Override, PluginFactoryOptions, ResolveNameParams, ResolvePathOptions, UserPluginWithLifeCycle, contentType };
1111
+ //# sourceMappingURL=OperationGenerator-D1X1O_-A.d.ts.map