@kubb/core 2.18.4 → 2.18.6

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 (69) hide show
  1. package/dist/chunk-7TB4GNKF.cjs +1268 -0
  2. package/dist/chunk-7TB4GNKF.cjs.map +1 -0
  3. package/dist/{chunk-TIYJPVUG.js → chunk-7UMWFPXG.js} +1 -9
  4. package/dist/chunk-7UMWFPXG.js.map +1 -0
  5. package/dist/{chunk-GRBLCGB5.cjs → chunk-BE4KSMB4.cjs} +5 -5
  6. package/dist/chunk-EPAC7V2R.js +597 -0
  7. package/dist/chunk-EPAC7V2R.js.map +1 -0
  8. package/dist/{chunk-YTLMG2AN.cjs → chunk-FWUA552W.cjs} +29 -29
  9. package/dist/{chunk-NP7GXHZS.cjs → chunk-JI763CHT.cjs} +18 -18
  10. package/dist/{chunk-GG3XRJX3.cjs → chunk-M6VNU2SJ.cjs} +12 -20
  11. package/dist/chunk-M6VNU2SJ.cjs.map +1 -0
  12. package/dist/{chunk-XUCU53HT.cjs → chunk-TCFN5BZ6.cjs} +3 -11
  13. package/dist/chunk-TCFN5BZ6.cjs.map +1 -0
  14. package/dist/index.cjs +1297 -10
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +26 -148
  17. package/dist/index.d.ts +26 -148
  18. package/dist/index.js +991 -22
  19. package/dist/index.js.map +1 -1
  20. package/dist/logger.cjs +3 -4
  21. package/dist/logger.js +1 -2
  22. package/dist/mocks.cjs +15 -14
  23. package/dist/mocks.cjs.map +1 -1
  24. package/dist/mocks.d.cts +4 -2
  25. package/dist/mocks.d.ts +4 -2
  26. package/dist/mocks.js +7 -6
  27. package/dist/mocks.js.map +1 -1
  28. package/dist/transformers.cjs +4 -4
  29. package/dist/utils.cjs +4 -4
  30. package/package.json +8 -18
  31. package/src/BarrelManager.ts +1 -1
  32. package/src/FileManager.ts +36 -167
  33. package/src/PackageManager.ts +1 -1
  34. package/src/PluginManager.ts +5 -5
  35. package/src/build.ts +6 -8
  36. package/src/index.ts +2 -3
  37. package/src/logger.ts +0 -7
  38. package/src/types.ts +3 -2
  39. package/src/utils/TreeNode.ts +1 -1
  40. package/dist/chunk-2F7E62RD.js +0 -85
  41. package/dist/chunk-2F7E62RD.js.map +0 -1
  42. package/dist/chunk-6NMPKKGV.js +0 -1597
  43. package/dist/chunk-6NMPKKGV.js.map +0 -1
  44. package/dist/chunk-7PBKI3OR.cjs +0 -2584
  45. package/dist/chunk-7PBKI3OR.cjs.map +0 -1
  46. package/dist/chunk-AQJCCWPW.cjs +0 -75
  47. package/dist/chunk-AQJCCWPW.cjs.map +0 -1
  48. package/dist/chunk-GG3XRJX3.cjs.map +0 -1
  49. package/dist/chunk-MDO6MCFJ.js +0 -65
  50. package/dist/chunk-MDO6MCFJ.js.map +0 -1
  51. package/dist/chunk-TIYJPVUG.js.map +0 -1
  52. package/dist/chunk-X5IJHUXJ.cjs +0 -2332
  53. package/dist/chunk-X5IJHUXJ.cjs.map +0 -1
  54. package/dist/chunk-XUCU53HT.cjs.map +0 -1
  55. package/dist/fs.cjs +0 -23
  56. package/dist/fs.cjs.map +0 -1
  57. package/dist/fs.d.cts +0 -5
  58. package/dist/fs.d.ts +0 -5
  59. package/dist/fs.js +0 -18
  60. package/dist/fs.js.map +0 -1
  61. package/dist/write-CN8f7bYv.d.cts +0 -10
  62. package/dist/write-CN8f7bYv.d.ts +0 -10
  63. package/src/fs/clean.ts +0 -5
  64. package/src/fs/index.ts +0 -3
  65. package/src/fs/read.ts +0 -68
  66. package/src/fs/write.ts +0 -83
  67. /package/dist/{chunk-GRBLCGB5.cjs.map → chunk-BE4KSMB4.cjs.map} +0 -0
  68. /package/dist/{chunk-YTLMG2AN.cjs.map → chunk-FWUA552W.cjs.map} +0 -0
  69. /package/dist/{chunk-NP7GXHZS.cjs.map → chunk-JI763CHT.cjs.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import PQueue from 'p-queue';
2
- import { w as write, r as read } from './write-CN8f7bYv.js';
2
+ import { write, read } from '@kubb/fs';
3
+ import * as KubbFile from '@kubb/fs/types';
4
+ import { BaseName, File, UUID } from '@kubb/fs/src/types.ts';
3
5
  import { PossiblePromise, TupleToUnion, ObjValueTuple, GreaterThan } from '@kubb/types';
4
6
  import { DirectoryTreeOptions } from 'directory-tree';
5
7
  import { E as EventEmitter, L as Logger } from './logger-DChjnJMn.js';
@@ -39,7 +41,7 @@ type Options$2 = {
39
41
  /**
40
42
  * Task for the FileManager
41
43
  */
42
- task: (file: KubbFile.ResolvedFile) => Promise<KubbFile.ResolvedFile>;
44
+ task: (file: ResolvedFile) => Promise<ResolvedFile>;
43
45
  };
44
46
  type Events = {
45
47
  execute: [executer: Executer];
@@ -135,17 +137,7 @@ type Plugins = _Register;
135
137
  type OptionsPlugins = {
136
138
  [K in keyof Plugins]: Plugins[K]['options'];
137
139
  };
138
- type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
139
140
  type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
140
- type Plugin$1 = keyof Plugins;
141
-
142
- type kubb_OptionsOfPlugin<K extends keyof Plugins> = OptionsOfPlugin<K>;
143
- type kubb_OptionsPlugins = OptionsPlugins;
144
- type kubb_PluginUnion = PluginUnion;
145
- type kubb_Plugins = Plugins;
146
- declare namespace kubb {
147
- export type { kubb_OptionsOfPlugin as OptionsOfPlugin, kubb_OptionsPlugins as OptionsPlugins, Plugin$1 as Plugin, kubb_PluginUnion as PluginUnion, kubb_Plugins as Plugins };
148
- }
149
141
 
150
142
  interface Cache<TStore extends object = object> {
151
143
  delete(id: keyof TStore): boolean;
@@ -364,7 +356,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
364
356
  * Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
365
357
  * @type hookParallel
366
358
  */
367
- writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string | undefined, path: KubbFile.Path) => PossiblePromise<string | void>;
359
+ writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path, source: string | undefined) => PossiblePromise<string | void>;
368
360
  /**
369
361
  * End of the plugin lifecycle.
370
362
  * @type hookParallel
@@ -413,136 +405,22 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
413
405
  };
414
406
  type TransformResult = string | null;
415
407
 
416
- type BasePath<T extends string = string> = `${T}/`;
417
- declare namespace KubbFile {
418
- type Import = {
419
- /**
420
- * Import name to be used
421
- * @example ["useState"]
422
- * @example "React"
423
- */
424
- name: string | Array<string | {
425
- propertyName: string;
426
- name?: string;
427
- }>;
428
- /**
429
- * Path for the import
430
- * @xample '@kubb/core'
431
- */
432
- path: string;
433
- /**
434
- * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
435
- */
436
- isTypeOnly?: boolean;
437
- /**
438
- * Add `* as` prefix to the import, this will result in: `import * as path from './path'`.
439
- */
440
- isNameSpace?: boolean;
441
- /**
442
- * When root is set it will get the path with relative getRelativePath(root, path).
443
- */
444
- root?: string;
445
- };
446
- type Export = {
447
- /**
448
- * Export name to be used.
449
- * @example ["useState"]
450
- * @example "React"
451
- */
452
- name?: string | Array<string>;
453
- /**
454
- * Path for the import.
455
- * @xample '@kubb/core'
456
- */
457
- path: string;
458
- /**
459
- * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
460
- */
461
- isTypeOnly?: boolean;
462
- /**
463
- * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
464
- */
465
- asAlias?: boolean;
466
- };
467
- const dataTagSymbol: unique symbol;
468
- type DataTag<Type, Value> = Type & {
469
- [dataTagSymbol]: Value;
470
- };
471
- type UUID = string;
472
- type Source = string;
473
- type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
474
- type Mode = 'single' | 'split';
408
+ type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = File<TMeta, TBaseName> & {
475
409
  /**
476
- * Name to be used to dynamicly create the baseName(based on input.path)
477
- * Based on UNIX basename
478
- * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
410
+ * @default crypto.randomUUID()
479
411
  */
480
- type BaseName = `${string}${Extname}`;
412
+ id: UUID;
481
413
  /**
482
- * Path will be full qualified path to a specified file
414
+ * Contains the first part of the baseName, generated based on baseName
415
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
483
416
  */
484
- type Path = string;
485
- type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
486
- type OptionalPath = Path | undefined | null;
487
- type FileMetaBase = {
488
- pluginKey?: Plugin['key'];
489
- };
490
- type File<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = {
491
- /**
492
- * Unique identifier to reuse later
493
- * @default crypto.randomUUID()
494
- */
495
- id?: string;
496
- /**
497
- * Name to be used to create the path
498
- * Based on UNIX basename, `${name}.extName`
499
- * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
500
- */
501
- baseName: TBaseName;
502
- /**
503
- * Path will be full qualified path to a specified file
504
- */
505
- path: AdvancedPath<TBaseName> | Path;
506
- source: Source;
507
- imports?: Import[];
508
- exports?: Export[];
509
- /**
510
- * This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists
511
- * This will also ignore the combinefiles utils
512
- * @default `false`
513
- */
514
- override?: boolean;
515
- /**
516
- * Use extra meta, this is getting used to generate the barrel/index files.
517
- */
518
- meta?: TMeta;
519
- /**
520
- * Override if a file can be exported by the BarrelManager
521
- * @default true
522
- */
523
- exportable?: boolean;
524
- /**
525
- * This will override `process.env[key]` inside the `source`, see `getFileSource`.
526
- */
527
- env?: NodeJS.ProcessEnv;
528
- /**
529
- * The name of the language being used. This can be TypeScript, JavaScript and still have another ext.
530
- */
531
- language?: string;
532
- };
533
- type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = KubbFile.File<TMeta, TBaseName> & {
534
- /**
535
- * @default crypto.randomUUID()
536
- */
537
- id: UUID;
538
- /**
539
- * Contains the first part of the baseName, generated based on baseName
540
- * @link https://nodejs.org/api/path.html#pathformatpathobject
541
- */
542
- name: string;
543
- };
544
- }
545
- type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
417
+ name: string;
418
+ };
419
+ type FileMetaBase = {
420
+ pluginKey?: Plugin['key'];
421
+ };
422
+ type FileWithMeta<TMeta extends FileMetaBase = FileMetaBase> = KubbFile.File<TMeta>;
423
+ type AddResult<T extends Array<FileWithMeta>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
546
424
  type AddIndexesProps = {
547
425
  /**
548
426
  * Root based on root and output.path specified in the config
@@ -559,26 +437,26 @@ type AddIndexesProps = {
559
437
  };
560
438
  logger: Logger;
561
439
  options?: BarrelManagerOptions;
562
- meta?: KubbFile.File['meta'];
440
+ meta?: FileWithMeta['meta'];
563
441
  };
564
442
  type Options$1 = {
565
443
  queue?: PQueue;
566
- task?: (file: KubbFile.ResolvedFile) => Promise<KubbFile.ResolvedFile>;
444
+ task?: (file: ResolvedFile) => Promise<ResolvedFile>;
567
445
  };
568
446
  declare class FileManager {
569
447
  #private;
570
448
  constructor({ task, queue }?: Options$1);
571
- get files(): Array<KubbFile.File>;
449
+ get files(): Array<FileWithMeta>;
572
450
  get isExecuting(): boolean;
573
- add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
451
+ add<T extends Array<FileWithMeta> = Array<FileWithMeta>>(...files: T): AddResult<T>;
574
452
  addIndexes({ root, output, meta, logger, options }: AddIndexesProps): Promise<void>;
575
- getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
576
- get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
453
+ getCacheByUUID(UUID: KubbFile.UUID): FileWithMeta | undefined;
454
+ get(path: KubbFile.Path): Array<FileWithMeta> | undefined;
577
455
  remove(path: KubbFile.Path): void;
578
456
  write(...params: Parameters<typeof write>): Promise<string | undefined>;
579
457
  read(...params: Parameters<typeof read>): Promise<string>;
580
- static getSource<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(file: KubbFile.File<TMeta>): Promise<string>;
581
- static combineFiles<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(files: Array<KubbFile.File<TMeta> | null>): Array<KubbFile.File<TMeta>>;
458
+ static getSource<TMeta extends FileMetaBase = FileMetaBase>(file: FileWithMeta<TMeta>): Promise<string>;
459
+ static combineFiles<TMeta extends FileMetaBase = FileMetaBase>(files: Array<FileWithMeta<TMeta> | null>): Array<FileWithMeta<TMeta>>;
582
460
  static getMode(path: string | undefined | null): KubbFile.Mode;
583
461
  static get extensions(): Array<KubbFile.Extname>;
584
462
  static isJavascript(baseName: string): boolean;
@@ -707,4 +585,4 @@ declare class PromiseManager<TState = any> {
707
585
  interface _Register {
708
586
  }
709
587
 
710
- export { type Config, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, kubb as Kubb, KubbFile, type ObjectPlugin, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginKey, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginWithLifeCycle, PromiseManager, type ResolveNameParams, type ResolvePathParams, type TransformResult, type UnionPlugins, type UserConfig, type UserPlugin, type UserPluginWithLifeCycle, Warning, type _Register, build, createPlugin, build as default, defineConfig, isInputPath, safeBuild };
588
+ export { type Config, FileManager, type FileMetaBase, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type ObjectPlugin, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginKey, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginWithLifeCycle, PromiseManager, type ResolveNameParams, type ResolvePathParams, type TransformResult, type UnionPlugins, type UserConfig, type UserPlugin, type UserPluginWithLifeCycle, Warning, type _Register, build, createPlugin, build as default, defineConfig, isInputPath, safeBuild };