@kubb/core 2.0.0-beta.6 → 2.0.0-beta.7

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/utils.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { Ora } from 'ora';
2
- import { PossiblePromise } from '@kubb/types';
1
+ import { PossiblePromise, GreaterThan } from '@kubb/types';
3
2
  import { DirectoryTreeOptions } from 'directory-tree';
3
+ import { Ora } from 'ora';
4
4
  export { default as pc } from 'picocolors';
5
5
 
6
6
  declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
@@ -9,6 +9,25 @@ declare function readSync(path: string): string;
9
9
 
10
10
  declare function write(data: string, path: string): Promise<string | undefined>;
11
11
 
12
+ type TreeNodeOptions = DirectoryTreeOptions;
13
+ type BarrelData = {
14
+ type: KubbFile.Mode;
15
+ path: KubbFile.Path;
16
+ name: string;
17
+ };
18
+ declare class TreeNode<T = BarrelData> {
19
+ data: T;
20
+ parent?: TreeNode<T>;
21
+ children: Array<TreeNode<T>>;
22
+ constructor(data: T, parent?: TreeNode<T>);
23
+ addChild(data: T): TreeNode<T>;
24
+ find(data?: T): TreeNode<T> | null;
25
+ get leaves(): TreeNode<T>[];
26
+ get root(): TreeNode<T>;
27
+ forEach(callback: (treeNode: TreeNode<T>) => void): this;
28
+ static build(path: string, options?: TreeNodeOptions): TreeNode | null;
29
+ }
30
+
12
31
  declare class EventEmitter<TEvents extends Record<string, any>> {
13
32
  #private;
14
33
  constructor();
@@ -26,13 +45,13 @@ type RunOptions = {
26
45
  name?: string;
27
46
  description?: string;
28
47
  };
29
- type Events = {
48
+ type Events$1 = {
30
49
  jobDone: [result: unknown];
31
50
  jobFailed: [error: Error];
32
51
  };
33
52
  declare class Queue {
34
53
  #private;
35
- readonly eventEmitter: EventEmitter<Events>;
54
+ readonly eventEmitter: EventEmitter<Events$1>;
36
55
  constructor(maxParallel: number, debug?: boolean);
37
56
  run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
38
57
  runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
@@ -66,7 +85,497 @@ type Props = {
66
85
  };
67
86
  declare function createLogger({ logLevel, name, spinner }: Props): Logger;
68
87
 
88
+ type RequiredPluginLifecycle = Required<PluginLifecycle>;
89
+ /**
90
+ * Get the type of the first argument in a function.
91
+ * @example Arg0<(a: string, b: number) => void> -> string
92
+ */
93
+ type Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0];
94
+ type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq';
95
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
96
+ strategy: Strategy;
97
+ hookName: H;
98
+ plugin: KubbPlugin;
99
+ parameters?: unknown[] | undefined;
100
+ output?: unknown;
101
+ };
102
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
103
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
104
+ result: Result;
105
+ plugin: KubbPlugin;
106
+ };
107
+ type Options$1 = {
108
+ logger: Logger;
109
+ /**
110
+ * Task for the FileManager
111
+ */
112
+ task: QueueJob<KubbFile.ResolvedFile>;
113
+ /**
114
+ * Timeout between writes in the FileManager
115
+ */
116
+ writeTimeout?: number;
117
+ };
118
+ type Events = {
119
+ execute: [executer: Executer];
120
+ executed: [executer: Executer];
121
+ error: [error: Error];
122
+ };
123
+ declare class PluginManager {
124
+ #private;
125
+ readonly plugins: KubbPluginWithLifeCycle[];
126
+ readonly fileManager: FileManager;
127
+ readonly eventEmitter: EventEmitter<Events>;
128
+ readonly queue: Queue;
129
+ readonly config: KubbConfig;
130
+ readonly executed: Executer[];
131
+ readonly logger: Logger;
132
+ constructor(config: KubbConfig, options: Options$1);
133
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
134
+ resolveName: (params: ResolveNameParams) => string;
135
+ on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
136
+ /**
137
+ * Run only hook for a specific plugin name
138
+ */
139
+ hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
140
+ pluginKey: KubbPlugin['key'];
141
+ hookName: H;
142
+ parameters: PluginParameter<H>;
143
+ }): Promise<Array<ReturnType<ParseResult<H>> | null>> | null;
144
+ hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
145
+ pluginKey: KubbPlugin['key'];
146
+ hookName: H;
147
+ parameters: PluginParameter<H>;
148
+ }): Array<ReturnType<ParseResult<H>>> | null;
149
+ /**
150
+ * Chains, first non-null result stops and returns
151
+ */
152
+ hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
153
+ hookName: H;
154
+ parameters: PluginParameter<H>;
155
+ skipped?: ReadonlySet<KubbPlugin> | null;
156
+ }): Promise<SafeParseResult<H>>;
157
+ /**
158
+ * Chains, first non-null result stops and returns
159
+ */
160
+ hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
161
+ hookName: H;
162
+ parameters: PluginParameter<H>;
163
+ skipped?: ReadonlySet<KubbPlugin> | null;
164
+ }): SafeParseResult<H>;
165
+ /**
166
+ * Parallel, runs all plugins
167
+ */
168
+ hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, }: {
169
+ hookName: H;
170
+ parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
171
+ }): Promise<Awaited<TOuput>[]>;
172
+ /**
173
+ * Chains, reduces returned value, handling the reduced value as the first hook argument
174
+ */
175
+ hookReduceArg0<H extends PluginLifecycleHooks>({ hookName, parameters, reduce, }: {
176
+ hookName: H;
177
+ parameters: PluginParameter<H>;
178
+ reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise<Argument0<H> | null>;
179
+ }): Promise<Argument0<H>>;
180
+ /**
181
+ * Chains plugins
182
+ */
183
+ hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: {
184
+ hookName: H;
185
+ parameters?: PluginParameter<H>;
186
+ }): Promise<void>;
187
+ getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
188
+ static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? T2 extends never ? [T1: KubbPlugin<T1>] : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>] : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>, T3: KubbPlugin<T3>]>(plugins: Array<KubbPlugin>, dependedPluginNames: string | string[]): TOutput;
189
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
190
+ }
191
+
192
+ type BarrelManagerOptions = {
193
+ treeNode?: DirectoryTreeOptions;
194
+ isTypeOnly?: boolean;
195
+ /**
196
+ * Add .ts or .js
197
+ */
198
+ includeExt?: boolean;
199
+ };
200
+
201
+ type BasePath<T extends string = string> = `${T}/`;
202
+ declare namespace KubbFile {
203
+ type Import = {
204
+ /**
205
+ * Import name to be used
206
+ * @example ["useState"]
207
+ * @example "React"
208
+ */
209
+ name: string | Array<string | {
210
+ propertyName: string;
211
+ name?: string;
212
+ }>;
213
+ /**
214
+ * Path for the import
215
+ * @xample '@kubb/core'
216
+ */
217
+ path: string;
218
+ /**
219
+ * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
220
+ */
221
+ isTypeOnly?: boolean;
222
+ /**
223
+ * Add `* as` prefix to the import, this will result in: `import * as path from './path'`.
224
+ */
225
+ isNameSpace?: boolean;
226
+ /**
227
+ * When root is set it will get the path with relative getRelativePath(root, path).
228
+ */
229
+ root?: string;
230
+ };
231
+ type Export = {
232
+ /**
233
+ * Export name to be used.
234
+ * @example ["useState"]
235
+ * @example "React"
236
+ */
237
+ name?: string | Array<string>;
238
+ /**
239
+ * Path for the import.
240
+ * @xample '@kubb/core'
241
+ */
242
+ path: string;
243
+ /**
244
+ * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
245
+ */
246
+ isTypeOnly?: boolean;
247
+ /**
248
+ * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
249
+ */
250
+ asAlias?: boolean;
251
+ };
252
+ const dataTagSymbol: unique symbol;
253
+ type DataTag<Type, Value> = Type & {
254
+ [dataTagSymbol]: Value;
255
+ };
256
+ type UUID = string;
257
+ type Source = string;
258
+ type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
259
+ type Mode = 'file' | 'directory';
260
+ /**
261
+ * Name to be used to dynamicly create the baseName(based on input.path)
262
+ * Based on UNIX basename
263
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
264
+ */
265
+ type BaseName = `${string}${Extname}`;
266
+ /**
267
+ * Path will be full qualified path to a specified file
268
+ */
269
+ type Path = string;
270
+ type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
271
+ type OptionalPath = Path | undefined | null;
272
+ type FileMetaBase = {
273
+ pluginKey?: KubbPlugin['key'];
274
+ };
275
+ type File<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = {
276
+ /**
277
+ * Unique identifier to reuse later
278
+ * @default crypto.randomUUID()
279
+ */
280
+ id?: string;
281
+ /**
282
+ * Name to be used to create the path
283
+ * Based on UNIX basename, `${name}.extName`
284
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
285
+ */
286
+ baseName: TBaseName;
287
+ /**
288
+ * Path will be full qualified path to a specified file
289
+ */
290
+ path: AdvancedPath<TBaseName> | Path;
291
+ source: Source;
292
+ imports?: Import[];
293
+ exports?: Export[];
294
+ /**
295
+ * This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists
296
+ * This will also ignore the combinefiles utils
297
+ * @default `false`
298
+ */
299
+ override?: boolean;
300
+ /**
301
+ * Use extra meta, this is getting used to generate the barrel/index files.
302
+ */
303
+ meta?: TMeta;
304
+ /**
305
+ * This will override `process.env[key]` inside the `source`, see `getFileSource`.
306
+ */
307
+ env?: NodeJS.ProcessEnv;
308
+ };
309
+ type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = KubbFile.File<TMeta, TBaseName> & {
310
+ /**
311
+ * @default crypto.randomUUID()
312
+ */
313
+ id: UUID;
314
+ /**
315
+ * Contains the first part of the baseName, generated based on baseName
316
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
317
+ */
318
+ name: string;
319
+ };
320
+ }
321
+ type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
322
+ type AddIndexesProps = {
323
+ /**
324
+ * Root based on root and output.path specified in the config
325
+ */
326
+ root: string;
327
+ /**
328
+ * Output for plugin
329
+ */
330
+ output: string | {
331
+ path: string;
332
+ exportAs?: string;
333
+ };
334
+ extName?: KubbFile.Extname;
335
+ options?: BarrelManagerOptions;
336
+ meta?: KubbFile.File['meta'];
337
+ };
338
+ type Options = {
339
+ queue?: Queue;
340
+ task?: QueueJob<KubbFile.ResolvedFile>;
341
+ /**
342
+ * Timeout between writes
343
+ */
344
+ timeout?: number;
345
+ };
346
+ declare class FileManager {
347
+ #private;
348
+ constructor(options?: Options);
349
+ get files(): Array<KubbFile.File>;
350
+ get isExecuting(): boolean;
351
+ add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
352
+ addIndexes({ root, output, extName, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
353
+ getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
354
+ get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
355
+ remove(path: KubbFile.Path): void;
356
+ write(...params: Parameters<typeof write>): Promise<string | undefined>;
357
+ read(...params: Parameters<typeof read>): Promise<string>;
358
+ static getSource<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(file: KubbFile.File<TMeta>): string;
359
+ static combineFiles<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(files: Array<KubbFile.File<TMeta> | null>): Array<KubbFile.File<TMeta>>;
360
+ static getMode(path: string | undefined | null): KubbFile.Mode;
361
+ static get extensions(): Array<KubbFile.Extname>;
362
+ static isExtensionAllowed(baseName: string): boolean;
363
+ }
364
+
365
+ type InputPath = {
366
+ /**
367
+ * Path to be used as the input. This can be an absolute path or a path relative to the `root`.
368
+ */
369
+ path: string;
370
+ };
371
+ type InputData = {
372
+ /**
373
+ * `string` or `object` containing the data.
374
+ */
375
+ data: string | unknown;
376
+ };
377
+ type Input = InputPath | InputData;
378
+ /**
379
+ * @private
380
+ */
381
+ type KubbConfig<TInput = Input> = {
382
+ /**
383
+ * Optional config name to show in CLI output
384
+ */
385
+ name?: string;
386
+ /**
387
+ * Project root directory. Can be an absolute path, or a path relative from
388
+ * the location of the config file itself.
389
+ * @default process.cwd()
390
+ */
391
+ root: string;
392
+ input: TInput;
393
+ output: {
394
+ /**
395
+ * Path to be used to export all generated files.
396
+ * This can be an absolute path, or a path relative based of the defined `root` option.
397
+ */
398
+ path: string;
399
+ /**
400
+ * Clean output directory before each build.
401
+ */
402
+ clean?: boolean;
403
+ /**
404
+ * Write files to the fileSystem
405
+ * This is being used for the playground.
406
+ * @default true
407
+ */
408
+ write?: boolean;
409
+ };
410
+ /**
411
+ * Array of Kubb plugins to use.
412
+ * The plugin/package can forsee some options that you need to pass through.
413
+ * Sometimes a plugin is depended on another plugin, if that's the case you will get an error back from the plugin you installed.
414
+ */
415
+ plugins?: Array<KubbPlugin>;
416
+ /**
417
+ * Hooks that will be called when a specific action is triggered in Kubb.
418
+ */
419
+ hooks?: {
420
+ /**
421
+ * Hook that will be triggered at the end of all executions.
422
+ * Useful for running Prettier or ESLint to format/lint your code.
423
+ */
424
+ done?: string | Array<string>;
425
+ };
426
+ };
427
+ type PluginFactoryOptions<
428
+ /**
429
+ * Name to be used for the plugin, this will also be used for they key.
430
+ */
431
+ TName extends string = string,
432
+ /**
433
+ * Options of the plugin.
434
+ */
435
+ TOptions extends object = object,
436
+ /**
437
+ * Options of the plugin that can be used later on, see `options` inside your plugin config.
438
+ */
439
+ TResolvedOptions extends object = TOptions,
440
+ /**
441
+ * API that you want to expose to other plugins.
442
+ */
443
+ TAPI = any,
444
+ /**
445
+ * When calling `resolvePath` you can specify better types.
446
+ */
447
+ TResolvePathOptions extends object = object,
448
+ /**
449
+ * When using @kubb/react(based on React) you can specify here which types should be used when calling render.
450
+ * Always extend from `AppMeta` of the core.
451
+ */
452
+ TAppMeta = unknown> = {
453
+ name: TName;
454
+ /**
455
+ * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
456
+ */
457
+ key: [name: TName | string, identifier?: string | number];
458
+ options: TOptions;
459
+ resolvedOptions: TResolvedOptions;
460
+ api: TAPI;
461
+ resolvePathOptions: TResolvePathOptions;
462
+ appMeta: {
463
+ pluginManager: PluginManager;
464
+ plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
465
+ } & TAppMeta;
466
+ };
467
+ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
468
+ /**
469
+ * Unique name used for the plugin
470
+ * @example @kubb/typescript
471
+ */
472
+ name: TOptions['name'];
473
+ /**
474
+ * Internal key used when a developer uses more than one of the same plugin
475
+ * @private
476
+ */
477
+ key: TOptions['key'];
478
+ /**
479
+ * 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.
480
+ * Can be used to validate depended plugins.
481
+ */
482
+ pre?: Array<string>;
483
+ /**
484
+ * 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.
485
+ */
486
+ post?: Array<string>;
487
+ /**
488
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
489
+ */
490
+ options: TOptions['resolvedOptions'];
491
+ } & (TOptions['api'] extends never ? {
492
+ api?: never;
493
+ } : {
494
+ api: TOptions['api'];
495
+ });
496
+ type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
497
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
498
+ /**
499
+ * Start of the lifecycle of a plugin.
500
+ * @type hookParallel
501
+ */
502
+ buildStart?: (this: PluginContext<TOptions>, kubbConfig: KubbConfig) => PossiblePromise<void>;
503
+ /**
504
+ * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
505
+ * Options can als be included.
506
+ * @type hookFirst
507
+ * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
508
+ */
509
+ resolvePath?: (this: PluginContext<TOptions>, baseName: string, directory?: string, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
510
+ /**
511
+ * Resolve to a name based on a string.
512
+ * Useful when converting to PascalCase or camelCase.
513
+ * @type hookFirst
514
+ * @example ('pet') => 'Pet'
515
+ */
516
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
517
+ /**
518
+ * Makes it possible to run async logic to override the path defined previously by `resolvePath`.
519
+ * @type hookFirst
520
+ */
521
+ load?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>;
522
+ /**
523
+ * Transform the source-code.
524
+ * @type hookReduceArg0
525
+ */
526
+ transform?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>;
527
+ /**
528
+ * Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
529
+ * @type hookParallel
530
+ */
531
+ writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string | undefined, path: KubbFile.Path) => PossiblePromise<string | void>;
532
+ /**
533
+ * End of the plugin lifecycle.
534
+ * @type hookParallel
535
+ */
536
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
537
+ };
538
+ type PluginLifecycleHooks = keyof PluginLifecycle;
539
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
69
540
  type PluginCache = Record<string, [number, unknown]>;
541
+ type ResolvePathParams<TOptions = object> = {
542
+ pluginKey?: KubbPlugin['key'];
543
+ baseName: string;
544
+ directory?: string | undefined;
545
+ /**
546
+ * Options to be passed to 'resolvePath' 3th parameter
547
+ */
548
+ options?: TOptions;
549
+ };
550
+ type ResolveNameParams = {
551
+ name: string;
552
+ pluginKey?: KubbPlugin['key'];
553
+ /**
554
+ * `file` will be used to customize the name of the created file(use of camelCase)
555
+ * `function` can be used used to customize the exported functions(use of camelCase)
556
+ * `type` is a special type for TypeScript(use of PascalCase)
557
+ */
558
+ type?: 'file' | 'function' | 'type';
559
+ };
560
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
561
+ config: KubbConfig;
562
+ cache: Cache<PluginCache>;
563
+ fileManager: FileManager;
564
+ pluginManager: PluginManager;
565
+ addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.File>>;
566
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
567
+ resolveName: (params: ResolveNameParams) => string;
568
+ logger: Logger;
569
+ /**
570
+ * All plugins
571
+ */
572
+ plugins: KubbPlugin[];
573
+ /**
574
+ * Current plugin
575
+ */
576
+ plugin: KubbPlugin<TOptions>;
577
+ };
578
+ type TransformResult = string | null;
70
579
 
71
580
  interface Cache<TStore extends object = object> {
72
581
  delete(id: keyof TStore): boolean;
@@ -128,20 +637,6 @@ declare const throttle: <R, A extends any[]>(fn: (...args: A) => R, delay: numbe
128
637
 
129
638
  declare function timeout(ms: number): Promise<unknown>;
130
639
 
131
- type TreeNodeOptions = DirectoryTreeOptions;
132
- declare class TreeNode<T = unknown> {
133
- data: T;
134
- parent?: TreeNode<T>;
135
- children: Array<TreeNode<T>>;
136
- constructor(data: T, parent?: TreeNode<T>);
137
- addChild(data: T): TreeNode<T>;
138
- find(data?: T): TreeNode<T> | null;
139
- get leaves(): TreeNode<T>[];
140
- get root(): TreeNode<T>;
141
- forEach(callback: (treeNode: TreeNode<T>) => void): this;
142
- static build<T = unknown>(path: string, options?: TreeNodeOptions): TreeNode<T> | null;
143
- }
144
-
145
640
  declare function getUniqueName(originalName: string, data: Record<string, number>): string;
146
641
  declare function setUniqueName(originalName: string, data: Record<string, number>): string;
147
642