@kubb/plugin-redoc 4.1.4 → 4.2.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.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ConsolaInstance, LogLevel } from "consola";
2
+ import { FileManager } from "@kubb/fabric-core";
2
3
  import * as OasTypes from "oas/types";
3
4
  import { OASDocument, SchemaObject, User } from "oas/types";
4
5
  import { Operation } from "oas/operation";
@@ -171,8 +172,6 @@ type Logger = {
171
172
  //#endregion
172
173
  //#region ../core/src/utils/types.d.ts
173
174
  type PossiblePromise<T> = Promise<T> | T;
174
- type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
175
- type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
176
175
  //#endregion
177
176
  //#region ../core/src/types.d.ts
178
177
  type InputPath = {
@@ -285,11 +284,11 @@ TName extends string = string,
285
284
  /**
286
285
  * Options of the plugin.
287
286
  */
288
- TOptions extends object = object,
287
+ TOptions$1 extends object = object,
289
288
  /**
290
289
  * Options of the plugin that can be used later on, see `options` inside your plugin config.
291
290
  */
292
- TResolvedOptions extends object = TOptions,
291
+ TResolvedOptions extends object = TOptions$1,
293
292
  /**
294
293
  * Context that you want to expose to other plugins.
295
294
  */
@@ -303,23 +302,23 @@ TResolvePathOptions extends object = object> = {
303
302
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
304
303
  */
305
304
  key: PluginKey<TName | string>;
306
- options: TOptions;
305
+ options: TOptions$1;
307
306
  resolvedOptions: TResolvedOptions;
308
307
  context: TContext;
309
308
  resolvePathOptions: TResolvePathOptions;
310
309
  };
311
310
  type PluginKey<TName> = [name: TName, identifier?: string | number];
312
- type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
311
+ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
313
312
  /**
314
313
  * Unique name used for the plugin
315
314
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
316
315
  * @example @kubb/typescript
317
316
  */
318
- name: TOptions['name'];
317
+ name: TOptions$1['name'];
319
318
  /**
320
319
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
321
320
  */
322
- options: TOptions['resolvedOptions'];
321
+ options: TOptions$1['resolvedOptions'];
323
322
  /**
324
323
  * 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.
325
324
  * Can be used to validate dependent plugins.
@@ -329,23 +328,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
329
328
  * 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.
330
329
  */
331
330
  post?: Array<string>;
332
- } & (TOptions['context'] extends never ? {
331
+ } & (TOptions$1['context'] extends never ? {
333
332
  context?: never;
334
333
  } : {
335
- context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
334
+ context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
336
335
  });
337
- type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
338
- type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
336
+ type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
337
+ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
339
338
  /**
340
339
  * Unique name used for the plugin
341
340
  * @example @kubb/typescript
342
341
  */
343
- name: TOptions['name'];
342
+ name: TOptions$1['name'];
344
343
  /**
345
344
  * Internal key used when a developer uses more than one of the same plugin
346
345
  * @private
347
346
  */
348
- key: TOptions['key'];
347
+ key: TOptions$1['key'];
349
348
  /**
350
349
  * 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.
351
350
  * Can be used to validate dependent plugins.
@@ -358,49 +357,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
358
357
  /**
359
358
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
360
359
  */
361
- options: TOptions['resolvedOptions'];
362
- } & (TOptions['context'] extends never ? {
360
+ options: TOptions$1['resolvedOptions'];
361
+ } & (TOptions$1['context'] extends never ? {
363
362
  context?: never;
364
363
  } : {
365
- context: TOptions['context'];
364
+ context: TOptions$1['context'];
366
365
  });
367
- type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
368
- type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
366
+ type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
367
+ type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
369
368
  /**
370
369
  * Start of the lifecycle of a plugin.
371
370
  * @type hookParallel
372
371
  */
373
- buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
372
+ buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
374
373
  /**
375
374
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
376
375
  * Options can als be included.
377
376
  * @type hookFirst
378
377
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
379
378
  */
380
- resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
379
+ resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
381
380
  /**
382
381
  * Resolve to a name based on a string.
383
382
  * Useful when converting to PascalCase or camelCase.
384
383
  * @type hookFirst
385
384
  * @example ('pet') => 'Pet'
386
385
  */
387
- resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
386
+ resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
388
387
  /**
389
388
  * End of the plugin lifecycle.
390
389
  * @type hookParallel
391
390
  */
392
- buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
391
+ buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
393
392
  };
394
393
  type PluginLifecycleHooks = keyof PluginLifecycle;
395
- type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
396
- type ResolvePathParams<TOptions = object> = {
394
+ type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
395
+ type ResolvePathParams<TOptions$1 = object> = {
397
396
  pluginKey?: Plugin['key'];
398
397
  baseName: BaseName;
399
398
  mode?: Mode;
400
399
  /**
401
400
  * Options to be passed to 'resolvePath' 3th parameter
402
401
  */
403
- options?: TOptions;
402
+ options?: TOptions$1;
404
403
  };
405
404
  type ResolveNameParams = {
406
405
  name: string;
@@ -413,12 +412,15 @@ type ResolveNameParams = {
413
412
  */
414
413
  type?: 'file' | 'function' | 'type' | 'const';
415
414
  };
416
- type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
415
+ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
417
416
  config: Config;
417
+ /**
418
+ * @deprecated
419
+ */
418
420
  fileManager: FileManager;
419
421
  pluginManager: PluginManager;
420
422
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
421
- resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
423
+ resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
422
424
  resolveName: (params: ResolveNameParams) => string;
423
425
  logger: Logger;
424
426
  /**
@@ -428,12 +430,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
428
430
  /**
429
431
  * Current plugin
430
432
  */
431
- plugin: Plugin<TOptions>;
433
+ plugin: Plugin<TOptions$1>;
432
434
  };
433
435
  /**
434
436
  * Specify the export location for the files and define the behavior of the output
435
437
  */
436
- type Output<TOptions> = {
438
+ type Output<TOptions$1> = {
437
439
  /**
438
440
  * Path to the output folder or file that will contain the generated code
439
441
  */
@@ -446,80 +448,26 @@ type Output<TOptions> = {
446
448
  /**
447
449
  * Add a banner text in the beginning of every file
448
450
  */
449
- banner?: string | ((options: TOptions) => string);
451
+ banner?: string | ((options: TOptions$1) => string);
450
452
  /**
451
453
  * Add a footer text in the beginning of every file
452
454
  */
453
- footer?: string | ((options: TOptions) => string);
455
+ footer?: string | ((options: TOptions$1) => string);
454
456
  };
455
457
  //#endregion
456
- //#region ../core/src/FileManager.d.ts
457
- type FileMetaBase = {
458
- pluginKey?: Plugin['key'];
459
- };
460
- type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
461
- type AddIndexesProps = {
462
- type: BarrelType | false | undefined;
463
- /**
464
- * Root based on root and output.path specified in the config
465
- */
466
- root: string;
467
- /**
468
- * Output for plugin
469
- */
470
- output: {
471
- path: string;
472
- };
473
- group?: {
474
- output: string;
475
- exportAs: string;
476
- };
477
- logger?: Logger;
478
- meta?: FileMetaBase;
479
- };
480
- type WriteFilesProps = {
481
- root: Config['root'];
482
- extension?: Record<Extname, Extname | ''>;
483
- logger?: Logger;
484
- dryRun?: boolean;
485
- };
486
- declare class FileManager {
487
- #private;
488
- constructor();
489
- add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
490
- getByPath(path: Path): Promise<ResolvedFile | null>;
491
- deleteByPath(path: Path): Promise<void>;
492
- clear(): Promise<void>;
493
- getFiles(): Promise<Array<ResolvedFile>>;
494
- processFiles({
495
- dryRun,
496
- root,
497
- extension,
498
- logger
499
- }: WriteFilesProps): Promise<Array<ResolvedFile>>;
500
- getBarrelFiles({
501
- type,
502
- meta,
503
- root,
504
- output,
505
- logger
506
- }: AddIndexesProps): Promise<File[]>;
507
- static getMode(path: string | undefined | null): Mode;
508
- }
509
- //#endregion
510
458
  //#region ../core/src/PluginManager.d.ts
511
459
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
512
460
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
513
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
461
+ type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
514
462
  message: string;
515
463
  strategy: Strategy;
516
- hookName: H;
464
+ hookName: H$1;
517
465
  plugin: Plugin;
518
466
  parameters?: unknown[] | undefined;
519
467
  output?: unknown;
520
468
  };
521
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
522
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
469
+ type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
470
+ type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
523
471
  result: Result;
524
472
  plugin: Plugin;
525
473
  };
@@ -535,16 +483,19 @@ type Events = {
535
483
  executed: [executer: Executer];
536
484
  error: [error: Error];
537
485
  };
538
- type GetFileProps<TOptions = object> = {
486
+ type GetFileProps<TOptions$1 = object> = {
539
487
  name: string;
540
488
  mode?: Mode;
541
489
  extname: Extname;
542
490
  pluginKey: Plugin['key'];
543
- options?: TOptions;
491
+ options?: TOptions$1;
544
492
  };
545
493
  declare class PluginManager {
546
494
  #private;
547
495
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
496
+ /**
497
+ * @deprecated do not use from pluginManager
498
+ */
548
499
  readonly fileManager: FileManager;
549
500
  readonly events: EventEmitter<Events>;
550
501
  readonly config: Config;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ConsolaInstance, LogLevel } from "consola";
2
+ import { FileManager } from "@kubb/fabric-core";
2
3
  import * as OasTypes from "oas/types";
3
4
  import { OASDocument, SchemaObject, User } from "oas/types";
4
5
  import { Operation } from "oas/operation";
@@ -171,8 +172,6 @@ type Logger = {
171
172
  //#endregion
172
173
  //#region ../core/src/utils/types.d.ts
173
174
  type PossiblePromise<T> = Promise<T> | T;
174
- type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
175
- type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
176
175
  //#endregion
177
176
  //#region ../core/src/types.d.ts
178
177
  type InputPath = {
@@ -285,11 +284,11 @@ TName extends string = string,
285
284
  /**
286
285
  * Options of the plugin.
287
286
  */
288
- TOptions extends object = object,
287
+ TOptions$1 extends object = object,
289
288
  /**
290
289
  * Options of the plugin that can be used later on, see `options` inside your plugin config.
291
290
  */
292
- TResolvedOptions extends object = TOptions,
291
+ TResolvedOptions extends object = TOptions$1,
293
292
  /**
294
293
  * Context that you want to expose to other plugins.
295
294
  */
@@ -303,23 +302,23 @@ TResolvePathOptions extends object = object> = {
303
302
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
304
303
  */
305
304
  key: PluginKey<TName | string>;
306
- options: TOptions;
305
+ options: TOptions$1;
307
306
  resolvedOptions: TResolvedOptions;
308
307
  context: TContext;
309
308
  resolvePathOptions: TResolvePathOptions;
310
309
  };
311
310
  type PluginKey<TName> = [name: TName, identifier?: string | number];
312
- type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
311
+ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
313
312
  /**
314
313
  * Unique name used for the plugin
315
314
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
316
315
  * @example @kubb/typescript
317
316
  */
318
- name: TOptions['name'];
317
+ name: TOptions$1['name'];
319
318
  /**
320
319
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
321
320
  */
322
- options: TOptions['resolvedOptions'];
321
+ options: TOptions$1['resolvedOptions'];
323
322
  /**
324
323
  * 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.
325
324
  * Can be used to validate dependent plugins.
@@ -329,23 +328,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
329
328
  * 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.
330
329
  */
331
330
  post?: Array<string>;
332
- } & (TOptions['context'] extends never ? {
331
+ } & (TOptions$1['context'] extends never ? {
333
332
  context?: never;
334
333
  } : {
335
- context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
334
+ context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
336
335
  });
337
- type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
338
- type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
336
+ type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
337
+ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
339
338
  /**
340
339
  * Unique name used for the plugin
341
340
  * @example @kubb/typescript
342
341
  */
343
- name: TOptions['name'];
342
+ name: TOptions$1['name'];
344
343
  /**
345
344
  * Internal key used when a developer uses more than one of the same plugin
346
345
  * @private
347
346
  */
348
- key: TOptions['key'];
347
+ key: TOptions$1['key'];
349
348
  /**
350
349
  * 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.
351
350
  * Can be used to validate dependent plugins.
@@ -358,49 +357,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
358
357
  /**
359
358
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
360
359
  */
361
- options: TOptions['resolvedOptions'];
362
- } & (TOptions['context'] extends never ? {
360
+ options: TOptions$1['resolvedOptions'];
361
+ } & (TOptions$1['context'] extends never ? {
363
362
  context?: never;
364
363
  } : {
365
- context: TOptions['context'];
364
+ context: TOptions$1['context'];
366
365
  });
367
- type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
368
- type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
366
+ type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
367
+ type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
369
368
  /**
370
369
  * Start of the lifecycle of a plugin.
371
370
  * @type hookParallel
372
371
  */
373
- buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
372
+ buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
374
373
  /**
375
374
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
376
375
  * Options can als be included.
377
376
  * @type hookFirst
378
377
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
379
378
  */
380
- resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
379
+ resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
381
380
  /**
382
381
  * Resolve to a name based on a string.
383
382
  * Useful when converting to PascalCase or camelCase.
384
383
  * @type hookFirst
385
384
  * @example ('pet') => 'Pet'
386
385
  */
387
- resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
386
+ resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
388
387
  /**
389
388
  * End of the plugin lifecycle.
390
389
  * @type hookParallel
391
390
  */
392
- buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
391
+ buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
393
392
  };
394
393
  type PluginLifecycleHooks = keyof PluginLifecycle;
395
- type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
396
- type ResolvePathParams<TOptions = object> = {
394
+ type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
395
+ type ResolvePathParams<TOptions$1 = object> = {
397
396
  pluginKey?: Plugin['key'];
398
397
  baseName: BaseName;
399
398
  mode?: Mode;
400
399
  /**
401
400
  * Options to be passed to 'resolvePath' 3th parameter
402
401
  */
403
- options?: TOptions;
402
+ options?: TOptions$1;
404
403
  };
405
404
  type ResolveNameParams = {
406
405
  name: string;
@@ -413,12 +412,15 @@ type ResolveNameParams = {
413
412
  */
414
413
  type?: 'file' | 'function' | 'type' | 'const';
415
414
  };
416
- type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
415
+ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
417
416
  config: Config;
417
+ /**
418
+ * @deprecated
419
+ */
418
420
  fileManager: FileManager;
419
421
  pluginManager: PluginManager;
420
422
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
421
- resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
423
+ resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
422
424
  resolveName: (params: ResolveNameParams) => string;
423
425
  logger: Logger;
424
426
  /**
@@ -428,12 +430,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
428
430
  /**
429
431
  * Current plugin
430
432
  */
431
- plugin: Plugin<TOptions>;
433
+ plugin: Plugin<TOptions$1>;
432
434
  };
433
435
  /**
434
436
  * Specify the export location for the files and define the behavior of the output
435
437
  */
436
- type Output<TOptions> = {
438
+ type Output<TOptions$1> = {
437
439
  /**
438
440
  * Path to the output folder or file that will contain the generated code
439
441
  */
@@ -446,80 +448,26 @@ type Output<TOptions> = {
446
448
  /**
447
449
  * Add a banner text in the beginning of every file
448
450
  */
449
- banner?: string | ((options: TOptions) => string);
451
+ banner?: string | ((options: TOptions$1) => string);
450
452
  /**
451
453
  * Add a footer text in the beginning of every file
452
454
  */
453
- footer?: string | ((options: TOptions) => string);
455
+ footer?: string | ((options: TOptions$1) => string);
454
456
  };
455
457
  //#endregion
456
- //#region ../core/src/FileManager.d.ts
457
- type FileMetaBase = {
458
- pluginKey?: Plugin['key'];
459
- };
460
- type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
461
- type AddIndexesProps = {
462
- type: BarrelType | false | undefined;
463
- /**
464
- * Root based on root and output.path specified in the config
465
- */
466
- root: string;
467
- /**
468
- * Output for plugin
469
- */
470
- output: {
471
- path: string;
472
- };
473
- group?: {
474
- output: string;
475
- exportAs: string;
476
- };
477
- logger?: Logger;
478
- meta?: FileMetaBase;
479
- };
480
- type WriteFilesProps = {
481
- root: Config['root'];
482
- extension?: Record<Extname, Extname | ''>;
483
- logger?: Logger;
484
- dryRun?: boolean;
485
- };
486
- declare class FileManager {
487
- #private;
488
- constructor();
489
- add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
490
- getByPath(path: Path): Promise<ResolvedFile | null>;
491
- deleteByPath(path: Path): Promise<void>;
492
- clear(): Promise<void>;
493
- getFiles(): Promise<Array<ResolvedFile>>;
494
- processFiles({
495
- dryRun,
496
- root,
497
- extension,
498
- logger
499
- }: WriteFilesProps): Promise<Array<ResolvedFile>>;
500
- getBarrelFiles({
501
- type,
502
- meta,
503
- root,
504
- output,
505
- logger
506
- }: AddIndexesProps): Promise<File[]>;
507
- static getMode(path: string | undefined | null): Mode;
508
- }
509
- //#endregion
510
458
  //#region ../core/src/PluginManager.d.ts
511
459
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
512
460
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
513
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
461
+ type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
514
462
  message: string;
515
463
  strategy: Strategy;
516
- hookName: H;
464
+ hookName: H$1;
517
465
  plugin: Plugin;
518
466
  parameters?: unknown[] | undefined;
519
467
  output?: unknown;
520
468
  };
521
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
522
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
469
+ type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
470
+ type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
523
471
  result: Result;
524
472
  plugin: Plugin;
525
473
  };
@@ -535,16 +483,19 @@ type Events = {
535
483
  executed: [executer: Executer];
536
484
  error: [error: Error];
537
485
  };
538
- type GetFileProps<TOptions = object> = {
486
+ type GetFileProps<TOptions$1 = object> = {
539
487
  name: string;
540
488
  mode?: Mode;
541
489
  extname: Extname;
542
490
  pluginKey: Plugin['key'];
543
- options?: TOptions;
491
+ options?: TOptions$1;
544
492
  };
545
493
  declare class PluginManager {
546
494
  #private;
547
495
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
496
+ /**
497
+ * @deprecated do not use from pluginManager
498
+ */
548
499
  readonly fileManager: FileManager;
549
500
  readonly events: EventEmitter<Events>;
550
501
  readonly config: Config;
package/dist/index.js CHANGED
@@ -13,9 +13,9 @@ var __esm = (fn, res) => function() {
13
13
  };
14
14
 
15
15
  //#endregion
16
- //#region ../../node_modules/.pnpm/tsdown@0.14.2_typescript@5.9.3/node_modules/tsdown/esm-shims.js
16
+ //#region ../../node_modules/.pnpm/tsdown@0.15.9_typescript@5.9.3/node_modules/tsdown/esm-shims.js
17
17
  var getFilename, getDirname, __dirname;
18
- var init_esm_shims = __esm({ "../../node_modules/.pnpm/tsdown@0.14.2_typescript@5.9.3/node_modules/tsdown/esm-shims.js": (() => {
18
+ var init_esm_shims = __esm({ "../../node_modules/.pnpm/tsdown@0.15.9_typescript@5.9.3/node_modules/tsdown/esm-shims.js": (() => {
19
19
  getFilename = () => fileURLToPath(import.meta.url);
20
20
  getDirname = () => path.dirname(getFilename());
21
21
  __dirname = /* @__PURE__ */ getDirname();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../node_modules/.pnpm/tsdown@0.14.2_typescript@5.9.3/node_modules/tsdown/esm-shims.js","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport type { OasTypes } from '@kubb/oas'\nimport pkg from 'handlebars'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\n\nexport async function getPageHTML(api: OasTypes.OASDocument, { title, disableGoogleFont, templateOptions }: BuildDocsOptions = {}) {\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n title: title || api.info.title || 'ReDoc documentation',\n redocHTML: `\n <script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"> </script>\n <div id=\"redoc-container\"></div>\n <script>\n const data = ${JSON.stringify(api, null, 2)};\n Redoc.init(data, {\n \"expandResponses\": \"200,400\"\n }, document.getElementById('redoc-container'))\n </script>\n `,\n disableGoogleFont,\n templateOptions,\n })\n}\n","import path from 'node:path'\n\nimport { PluginManager, createPlugin } from '@kubb/core'\nimport { pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport { trimExtName, write } from '@kubb/core/fs'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\nexport const pluginRedoc = createPlugin<PluginRedoc>((options) => {\n const { output = { path: 'docs.html' } } = options\n\n return {\n name: pluginRedocName,\n options: {\n output,\n name: trimExtName(output.path),\n },\n pre: [pluginOasName],\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n const oas = await swaggerPlugin.context.getOas()\n\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const pageHTML = await getPageHTML(oas.api)\n\n await write(path.resolve(root, output.path || './docs.html'), pageHTML)\n },\n }\n})\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;CAIM,oBAAoB,cAAc,OAAO,KAAK,IAAI;CAClD,mBAAmB,KAAK,QAAQ,aAAa,CAAC;CAEvC,YAA4B,4BAAY;;;;;;ACIrD,eAAsB,YAAY,KAA2B,EAAE,OAAO,mBAAmB,oBAAsC,EAAE,EAAE;CACjI,MAAM,mBAAmB,KAAK,KAAK,WAAW,sBAAsB;AAEpE,QADiB,IAAI,QAAQ,GAAG,aAAa,iBAAiB,CAAC,UAAU,CAAC,CAC1D;EACd,OAAO,SAAS,IAAI,KAAK,SAAS;EAClC,WAAW;;;;kBAIG,KAAK,UAAU,KAAK,MAAM,EAAE,CAAC;;;;;;EAM3C;EACA;EACD,CAAC;;;;;ACjBJ,MAAa,kBAAkB;AAE/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,KAAK;AAE3C,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,MAAM,YAAY,OAAO,KAAK;GAC/B;EACD,KAAK,CAAC,cAAc;EACpB,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAsC,cAAc,mBAA8B,KAAK,SAAS,CAAC,cAAc,CAAC;GACvH,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;AAEhD,SAAM,IAAI,aAAa;GAEvB,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,WAAW,MAAM,YAAY,IAAI,IAAI;AAE3C,SAAM,MAAM,KAAK,QAAQ,MAAM,OAAO,QAAQ,cAAc,EAAE,SAAS;;EAE1E;EACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../node_modules/.pnpm/tsdown@0.15.9_typescript@5.9.3/node_modules/tsdown/esm-shims.js","../src/redoc.tsx","../src/plugin.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport type { OasTypes } from '@kubb/oas'\nimport pkg from 'handlebars'\n\ntype BuildDocsOptions = {\n title?: string\n disableGoogleFont?: boolean\n templateOptions?: any\n}\n\nexport async function getPageHTML(api: OasTypes.OASDocument, { title, disableGoogleFont, templateOptions }: BuildDocsOptions = {}) {\n const templateFileName = path.join(__dirname, '../static/redoc.hbs')\n const template = pkg.compile(fs.readFileSync(templateFileName).toString())\n return template({\n title: title || api.info.title || 'ReDoc documentation',\n redocHTML: `\n <script src=\"https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js\"> </script>\n <div id=\"redoc-container\"></div>\n <script>\n const data = ${JSON.stringify(api, null, 2)};\n Redoc.init(data, {\n \"expandResponses\": \"200,400\"\n }, document.getElementById('redoc-container'))\n </script>\n `,\n disableGoogleFont,\n templateOptions,\n })\n}\n","import path from 'node:path'\n\nimport { PluginManager, createPlugin } from '@kubb/core'\nimport { pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport { trimExtName, write } from '@kubb/core/fs'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { getPageHTML } from './redoc.tsx'\nimport type { PluginRedoc } from './types.ts'\n\nexport const pluginRedocName = 'plugin-redoc' satisfies PluginRedoc['name']\n\nexport const pluginRedoc = createPlugin<PluginRedoc>((options) => {\n const { output = { path: 'docs.html' } } = options\n\n return {\n name: pluginRedocName,\n options: {\n output,\n name: trimExtName(output.path),\n },\n pre: [pluginOasName],\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n const oas = await swaggerPlugin.context.getOas()\n\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const pageHTML = await getPageHTML(oas.api)\n\n await write(path.resolve(root, output.path || './docs.html'), pageHTML)\n },\n }\n})\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;CAIM,oBAAoB,cAAc,OAAO,KAAK,IAAI;CAClD,mBAAmB,KAAK,QAAQ,aAAa,CAAC;CAEvC,YAA4B,4BAAY;;;;;;ACIrD,eAAsB,YAAY,KAA2B,EAAE,OAAO,mBAAmB,oBAAsC,EAAE,EAAE;CACjI,MAAM,mBAAmB,KAAK,KAAK,WAAW,sBAAsB;AAEpE,QADiB,IAAI,QAAQ,GAAG,aAAa,iBAAiB,CAAC,UAAU,CAAC,CAC1D;EACd,OAAO,SAAS,IAAI,KAAK,SAAS;EAClC,WAAW;;;;kBAIG,KAAK,UAAU,KAAK,MAAM,EAAE,CAAC;;;;;;EAM3C;EACA;EACD,CAAC;;;;;ACjBJ,MAAa,kBAAkB;AAE/B,MAAa,cAAc,cAA2B,YAAY;CAChE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,KAAK;AAE3C,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,MAAM,YAAY,OAAO,KAAK;GAC/B;EACD,KAAK,CAAC,cAAc;EACpB,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAsC,cAAc,mBAA8B,KAAK,SAAS,CAAC,cAAc,CAAC;GACvH,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;AAEhD,SAAM,IAAI,aAAa;GAEvB,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,WAAW,MAAM,YAAY,IAAI,IAAI;AAE3C,SAAM,MAAM,KAAK,QAAQ,MAAM,OAAO,QAAQ,cAAc,EAAE,SAAS;;EAE1E;EACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-redoc",
3
- "version": "4.1.4",
3
+ "version": "4.2.1",
4
4
  "description": "Beautiful docs with Redoc",
5
5
  "keywords": [
6
6
  "typescript",
@@ -40,12 +40,12 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "handlebars": "^4.7.8",
43
- "@kubb/core": "4.1.4",
44
- "@kubb/oas": "4.1.4",
45
- "@kubb/plugin-oas": "4.1.4"
43
+ "@kubb/core": "4.2.1",
44
+ "@kubb/oas": "4.2.1",
45
+ "@kubb/plugin-oas": "4.2.1"
46
46
  },
47
47
  "devDependencies": {
48
- "tsdown": "^0.14.2",
48
+ "tsdown": "^0.15.9",
49
49
  "typescript": "^5.9.3"
50
50
  },
51
51
  "peerDependencies": {