@kubb/core 2.0.0-alpha.9 → 2.0.0-beta.10
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/README.md +1 -1
- package/dist/index.cjs +302 -248
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -69
- package/dist/index.d.ts +72 -69
- package/dist/index.js +299 -244
- package/dist/index.js.map +1 -1
- package/dist/transformers.cjs +222 -0
- package/dist/transformers.cjs.map +1 -0
- package/dist/transformers.d.cts +55 -0
- package/dist/transformers.d.ts +55 -0
- package/dist/transformers.js +207 -0
- package/dist/transformers.js.map +1 -0
- package/dist/utils.cjs +302 -274
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +515 -67
- package/dist/utils.d.ts +515 -67
- package/dist/utils.js +303 -274
- package/dist/utils.js.map +1 -1
- package/package.json +19 -15
- package/src/BarrelManager.ts +55 -65
- package/src/FileManager.ts +100 -31
- package/src/PluginManager.ts +41 -39
- package/src/PromiseManager.ts +5 -1
- package/src/build.ts +1 -11
- package/src/index.ts +0 -1
- package/src/plugin.ts +4 -4
- package/src/transformers/casing.ts +9 -0
- package/src/transformers/createJSDocBlockText.ts +9 -0
- package/src/transformers/index.ts +36 -0
- package/src/transformers/trim.ts +7 -0
- package/src/types.ts +22 -39
- package/src/utils/FunctionParams.ts +3 -2
- package/src/utils/TreeNode.ts +6 -3
- package/src/utils/URLPath.ts +5 -5
- package/src/utils/executeStrategies.ts +14 -2
- package/src/utils/index.ts +0 -1
- package/src/SchemaGenerator.ts +0 -8
- package/src/utils/transformers/createJSDocBlockText.ts +0 -15
- package/src/utils/transformers/index.ts +0 -22
- package/src/utils/transformers/trim.ts +0 -3
- /package/src/{utils/transformers → transformers}/combineCodes.ts +0 -0
- /package/src/{utils/transformers → transformers}/escape.ts +0 -0
- /package/src/{utils/transformers → transformers}/indent.ts +0 -0
- /package/src/{utils/transformers → transformers}/nameSorter.ts +0 -0
- /package/src/{utils/transformers → transformers}/searchAndReplace.ts +0 -0
- /package/src/{utils/transformers → transformers}/transformReservedWord.ts +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -9,10 +9,10 @@ declare function write(data: string, path: string): Promise<string | undefined>;
|
|
|
9
9
|
type BarrelManagerOptions = {
|
|
10
10
|
treeNode?: DirectoryTreeOptions;
|
|
11
11
|
isTypeOnly?: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Add .ts or .js
|
|
14
|
+
*/
|
|
15
|
+
extName?: KubbFile.Extname;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
@@ -167,7 +167,7 @@ declare class PluginManager {
|
|
|
167
167
|
}): Promise<void>;
|
|
168
168
|
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
|
|
169
169
|
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;
|
|
170
|
-
static get hooks(): readonly ["
|
|
170
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
interface Cache<TStore extends object = object> {
|
|
@@ -282,7 +282,6 @@ type CLIOptions = {
|
|
|
282
282
|
*/
|
|
283
283
|
logLevel?: LogLevel;
|
|
284
284
|
};
|
|
285
|
-
type KubbPluginKind = 'schema' | 'controller';
|
|
286
285
|
type KubbUnionPlugins = PluginUnion;
|
|
287
286
|
type KubbObjectPlugin = keyof OptionsPlugins;
|
|
288
287
|
type PluginFactoryOptions<
|
|
@@ -290,10 +289,6 @@ type PluginFactoryOptions<
|
|
|
290
289
|
* Name to be used for the plugin, this will also be used for they key.
|
|
291
290
|
*/
|
|
292
291
|
TName extends string = string,
|
|
293
|
-
/**
|
|
294
|
-
* @type "schema" | "controller"
|
|
295
|
-
*/
|
|
296
|
-
TKind extends KubbPluginKind = KubbPluginKind,
|
|
297
292
|
/**
|
|
298
293
|
* Options of the plugin.
|
|
299
294
|
*/
|
|
@@ -316,53 +311,47 @@ TResolvePathOptions extends object = object,
|
|
|
316
311
|
*/
|
|
317
312
|
TAppMeta = unknown> = {
|
|
318
313
|
name: TName;
|
|
319
|
-
kind: TKind;
|
|
320
314
|
/**
|
|
321
315
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
322
316
|
*/
|
|
323
|
-
key: [
|
|
317
|
+
key: [name: TName | string, identifier?: string | number];
|
|
324
318
|
options: TOptions;
|
|
325
319
|
resolvedOptions: TResolvedOptions;
|
|
326
320
|
api: TAPI;
|
|
327
321
|
resolvePathOptions: TResolvePathOptions;
|
|
328
322
|
appMeta: {
|
|
329
323
|
pluginManager: PluginManager;
|
|
330
|
-
plugin: KubbPlugin<PluginFactoryOptions<TName,
|
|
324
|
+
plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
|
|
331
325
|
} & TAppMeta;
|
|
332
326
|
};
|
|
333
327
|
type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
|
|
334
328
|
type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
335
329
|
/**
|
|
336
330
|
* Unique name used for the plugin
|
|
331
|
+
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
337
332
|
* @example @kubb/typescript
|
|
338
333
|
*/
|
|
339
334
|
name: TOptions['name'];
|
|
340
|
-
/**
|
|
341
|
-
* Internal key used when a developer uses more than one of the same plugin
|
|
342
|
-
* @private
|
|
343
|
-
*/
|
|
344
|
-
key?: TOptions['key'];
|
|
345
335
|
/**
|
|
346
336
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
347
337
|
*/
|
|
348
338
|
options: TOptions['resolvedOptions'];
|
|
339
|
+
/**
|
|
340
|
+
* 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.
|
|
341
|
+
* Can be used to validate depended plugins.
|
|
342
|
+
*/
|
|
343
|
+
pre?: Array<string>;
|
|
344
|
+
/**
|
|
345
|
+
* 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.
|
|
346
|
+
*/
|
|
347
|
+
post?: Array<string>;
|
|
349
348
|
} & (TOptions['api'] extends never ? {
|
|
350
349
|
api?: never;
|
|
351
350
|
} : {
|
|
352
351
|
api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
|
|
353
|
-
}) & (TOptions['kind'] extends never ? {
|
|
354
|
-
kind?: never;
|
|
355
|
-
} : {
|
|
356
|
-
/**
|
|
357
|
-
* Kind/type for the plugin
|
|
358
|
-
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
359
|
-
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
360
|
-
* @default undefined
|
|
361
|
-
*/
|
|
362
|
-
kind: TOptions['kind'];
|
|
363
352
|
});
|
|
364
353
|
type KubbUserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbUserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
365
|
-
type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any
|
|
354
|
+
type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
|
|
366
355
|
type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
367
356
|
/**
|
|
368
357
|
* Unique name used for the plugin
|
|
@@ -375,16 +364,18 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
375
364
|
*/
|
|
376
365
|
key: TOptions['key'];
|
|
377
366
|
/**
|
|
378
|
-
*
|
|
367
|
+
* 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.
|
|
368
|
+
* Can be used to validate depended plugins.
|
|
379
369
|
*/
|
|
380
|
-
|
|
370
|
+
pre?: Array<string>;
|
|
381
371
|
/**
|
|
382
|
-
*
|
|
383
|
-
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
384
|
-
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
385
|
-
* @default undefined
|
|
372
|
+
* 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.
|
|
386
373
|
*/
|
|
387
|
-
|
|
374
|
+
post?: Array<string>;
|
|
375
|
+
/**
|
|
376
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
377
|
+
*/
|
|
378
|
+
options: TOptions['resolvedOptions'];
|
|
388
379
|
} & (TOptions['api'] extends never ? {
|
|
389
380
|
api?: never;
|
|
390
381
|
} : {
|
|
@@ -392,11 +383,6 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
392
383
|
});
|
|
393
384
|
type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
394
385
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
395
|
-
/**
|
|
396
|
-
* Valdiate all plugins to see if their depended plugins are installed and configured.
|
|
397
|
-
* @type hookParallel
|
|
398
|
-
*/
|
|
399
|
-
validate?: (this: Omit<PluginContext<TOptions>, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise<true>;
|
|
400
386
|
/**
|
|
401
387
|
* Start of the lifecycle of a plugin.
|
|
402
388
|
* @type hookParallel
|
|
@@ -485,37 +471,48 @@ declare namespace KubbFile {
|
|
|
485
471
|
/**
|
|
486
472
|
* Import name to be used
|
|
487
473
|
* @example ["useState"]
|
|
488
|
-
* @
|
|
474
|
+
* @example "React"
|
|
489
475
|
*/
|
|
490
|
-
name: string | Array<string
|
|
476
|
+
name: string | Array<string | {
|
|
477
|
+
propertyName: string;
|
|
478
|
+
name?: string;
|
|
479
|
+
}>;
|
|
491
480
|
/**
|
|
492
481
|
* Path for the import
|
|
493
482
|
* @xample '@kubb/core'
|
|
494
483
|
*/
|
|
495
484
|
path: string;
|
|
496
485
|
/**
|
|
497
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'
|
|
486
|
+
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
498
487
|
*/
|
|
499
488
|
isTypeOnly?: boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Add `* as` prefix to the import, this will result in: `import * as path from './path'`.
|
|
491
|
+
*/
|
|
492
|
+
isNameSpace?: boolean;
|
|
493
|
+
/**
|
|
494
|
+
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
495
|
+
*/
|
|
496
|
+
root?: string;
|
|
500
497
|
};
|
|
501
498
|
type Export = {
|
|
502
499
|
/**
|
|
503
|
-
* Export name to be used
|
|
500
|
+
* Export name to be used.
|
|
504
501
|
* @example ["useState"]
|
|
505
|
-
* @
|
|
502
|
+
* @example "React"
|
|
506
503
|
*/
|
|
507
504
|
name?: string | Array<string>;
|
|
508
505
|
/**
|
|
509
|
-
* Path for the import
|
|
506
|
+
* Path for the import.
|
|
510
507
|
* @xample '@kubb/core'
|
|
511
508
|
*/
|
|
512
509
|
path: string;
|
|
513
510
|
/**
|
|
514
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'
|
|
511
|
+
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
515
512
|
*/
|
|
516
513
|
isTypeOnly?: boolean;
|
|
517
514
|
/**
|
|
518
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'
|
|
515
|
+
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
519
516
|
*/
|
|
520
517
|
asAlias?: boolean;
|
|
521
518
|
};
|
|
@@ -549,8 +546,8 @@ declare namespace KubbFile {
|
|
|
549
546
|
*/
|
|
550
547
|
id?: string;
|
|
551
548
|
/**
|
|
552
|
-
* Name to be used to
|
|
553
|
-
* Based on UNIX basename
|
|
549
|
+
* Name to be used to create the path
|
|
550
|
+
* Based on UNIX basename, `${name}.extName`
|
|
554
551
|
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
555
552
|
*/
|
|
556
553
|
baseName: TBaseName;
|
|
@@ -575,22 +572,34 @@ declare namespace KubbFile {
|
|
|
575
572
|
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
|
576
573
|
*/
|
|
577
574
|
env?: NodeJS.ProcessEnv;
|
|
578
|
-
/**
|
|
579
|
-
* @deprecated
|
|
580
|
-
*/
|
|
581
|
-
validate?: boolean;
|
|
582
575
|
};
|
|
583
576
|
type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = KubbFile.File<TMeta, TBaseName> & {
|
|
584
577
|
/**
|
|
585
578
|
* @default crypto.randomUUID()
|
|
586
579
|
*/
|
|
587
580
|
id: UUID;
|
|
581
|
+
/**
|
|
582
|
+
* Contains the first part of the baseName, generated based on baseName
|
|
583
|
+
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
584
|
+
*/
|
|
585
|
+
name: string;
|
|
588
586
|
};
|
|
589
587
|
}
|
|
590
588
|
type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
|
|
591
589
|
type AddIndexesProps = {
|
|
592
|
-
|
|
593
|
-
|
|
590
|
+
/**
|
|
591
|
+
* Root based on root and output.path specified in the config
|
|
592
|
+
*/
|
|
593
|
+
root: string;
|
|
594
|
+
/**
|
|
595
|
+
* Output for plugin
|
|
596
|
+
*/
|
|
597
|
+
output: {
|
|
598
|
+
path: string;
|
|
599
|
+
exportAs?: string;
|
|
600
|
+
extName?: KubbFile.Extname;
|
|
601
|
+
exportType?: 'barrel' | false;
|
|
602
|
+
};
|
|
594
603
|
options?: BarrelManagerOptions;
|
|
595
604
|
meta?: KubbFile.File['meta'];
|
|
596
605
|
};
|
|
@@ -608,7 +617,7 @@ declare class FileManager {
|
|
|
608
617
|
get files(): Array<KubbFile.File>;
|
|
609
618
|
get isExecuting(): boolean;
|
|
610
619
|
add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
|
|
611
|
-
addIndexes({ root,
|
|
620
|
+
addIndexes({ root, output, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
|
|
612
621
|
getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
|
|
613
622
|
get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
|
|
614
623
|
remove(path: KubbFile.Path): void;
|
|
@@ -702,12 +711,13 @@ type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
702
711
|
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
703
712
|
declare const pluginName = "core";
|
|
704
713
|
|
|
705
|
-
type PromiseFunc$1<T = unknown, T2 = never> = (state
|
|
714
|
+
type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
706
715
|
type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
|
|
707
716
|
type SeqOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Array<Awaited<ValueOfPromiseFuncArray<TInput>>>;
|
|
708
717
|
type HookFirstOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>;
|
|
709
|
-
type
|
|
710
|
-
type
|
|
718
|
+
type HookParallelOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>;
|
|
719
|
+
type Strategy = 'seq' | 'first' | 'parallel';
|
|
720
|
+
type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = TStrategy extends 'first' ? HookFirstOutput<TInput, TValue> : TStrategy extends 'seq' ? SeqOutput<TInput, TValue> : TStrategy extends 'parallel' ? HookParallelOutput<TInput, TValue> : never;
|
|
711
721
|
|
|
712
722
|
type PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
713
723
|
type Options<TState = any> = {
|
|
@@ -719,13 +729,6 @@ declare class PromiseManager<TState = any> {
|
|
|
719
729
|
run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(strategy: TStrategy, promises: TInput): TOutput;
|
|
720
730
|
}
|
|
721
731
|
|
|
722
|
-
/**
|
|
723
|
-
* Abstract class that contains the building blocks for plugins to create their own SchemaGenerator
|
|
724
|
-
*/
|
|
725
|
-
declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput> extends Generator<TOptions> {
|
|
726
|
-
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
732
|
interface _Register {
|
|
730
733
|
}
|
|
731
734
|
type Plugins = _Register;
|
|
@@ -736,4 +739,4 @@ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
|
|
|
736
739
|
type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
|
|
737
740
|
type Plugin = keyof Plugins;
|
|
738
741
|
|
|
739
|
-
export { CLIOptions, FileManager, Generator, GetPluginFactoryOptions, InputData, InputPath, KubbConfig, KubbFile, KubbObjectPlugin, KubbPlugin,
|
|
742
|
+
export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginWithLifeCycle, type KubbUnionPlugins, type KubbUserConfig, type KubbUserPlugin, type KubbUserPluginWithLifeCycle, type OptionsOfPlugin, type OptionsPlugins, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginUnion, type Plugins, PromiseManager, type ResolveNameParams, type ResolvePathParams, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ declare function write(data: string, path: string): Promise<string | undefined>;
|
|
|
9
9
|
type BarrelManagerOptions = {
|
|
10
10
|
treeNode?: DirectoryTreeOptions;
|
|
11
11
|
isTypeOnly?: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Add .ts or .js
|
|
14
|
+
*/
|
|
15
|
+
extName?: KubbFile.Extname;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
@@ -167,7 +167,7 @@ declare class PluginManager {
|
|
|
167
167
|
}): Promise<void>;
|
|
168
168
|
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
|
|
169
169
|
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;
|
|
170
|
-
static get hooks(): readonly ["
|
|
170
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
interface Cache<TStore extends object = object> {
|
|
@@ -282,7 +282,6 @@ type CLIOptions = {
|
|
|
282
282
|
*/
|
|
283
283
|
logLevel?: LogLevel;
|
|
284
284
|
};
|
|
285
|
-
type KubbPluginKind = 'schema' | 'controller';
|
|
286
285
|
type KubbUnionPlugins = PluginUnion;
|
|
287
286
|
type KubbObjectPlugin = keyof OptionsPlugins;
|
|
288
287
|
type PluginFactoryOptions<
|
|
@@ -290,10 +289,6 @@ type PluginFactoryOptions<
|
|
|
290
289
|
* Name to be used for the plugin, this will also be used for they key.
|
|
291
290
|
*/
|
|
292
291
|
TName extends string = string,
|
|
293
|
-
/**
|
|
294
|
-
* @type "schema" | "controller"
|
|
295
|
-
*/
|
|
296
|
-
TKind extends KubbPluginKind = KubbPluginKind,
|
|
297
292
|
/**
|
|
298
293
|
* Options of the plugin.
|
|
299
294
|
*/
|
|
@@ -316,53 +311,47 @@ TResolvePathOptions extends object = object,
|
|
|
316
311
|
*/
|
|
317
312
|
TAppMeta = unknown> = {
|
|
318
313
|
name: TName;
|
|
319
|
-
kind: TKind;
|
|
320
314
|
/**
|
|
321
315
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
322
316
|
*/
|
|
323
|
-
key: [
|
|
317
|
+
key: [name: TName | string, identifier?: string | number];
|
|
324
318
|
options: TOptions;
|
|
325
319
|
resolvedOptions: TResolvedOptions;
|
|
326
320
|
api: TAPI;
|
|
327
321
|
resolvePathOptions: TResolvePathOptions;
|
|
328
322
|
appMeta: {
|
|
329
323
|
pluginManager: PluginManager;
|
|
330
|
-
plugin: KubbPlugin<PluginFactoryOptions<TName,
|
|
324
|
+
plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
|
|
331
325
|
} & TAppMeta;
|
|
332
326
|
};
|
|
333
327
|
type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
|
|
334
328
|
type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
335
329
|
/**
|
|
336
330
|
* Unique name used for the plugin
|
|
331
|
+
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
337
332
|
* @example @kubb/typescript
|
|
338
333
|
*/
|
|
339
334
|
name: TOptions['name'];
|
|
340
|
-
/**
|
|
341
|
-
* Internal key used when a developer uses more than one of the same plugin
|
|
342
|
-
* @private
|
|
343
|
-
*/
|
|
344
|
-
key?: TOptions['key'];
|
|
345
335
|
/**
|
|
346
336
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
347
337
|
*/
|
|
348
338
|
options: TOptions['resolvedOptions'];
|
|
339
|
+
/**
|
|
340
|
+
* 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.
|
|
341
|
+
* Can be used to validate depended plugins.
|
|
342
|
+
*/
|
|
343
|
+
pre?: Array<string>;
|
|
344
|
+
/**
|
|
345
|
+
* 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.
|
|
346
|
+
*/
|
|
347
|
+
post?: Array<string>;
|
|
349
348
|
} & (TOptions['api'] extends never ? {
|
|
350
349
|
api?: never;
|
|
351
350
|
} : {
|
|
352
351
|
api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
|
|
353
|
-
}) & (TOptions['kind'] extends never ? {
|
|
354
|
-
kind?: never;
|
|
355
|
-
} : {
|
|
356
|
-
/**
|
|
357
|
-
* Kind/type for the plugin
|
|
358
|
-
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
359
|
-
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
360
|
-
* @default undefined
|
|
361
|
-
*/
|
|
362
|
-
kind: TOptions['kind'];
|
|
363
352
|
});
|
|
364
353
|
type KubbUserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbUserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
365
|
-
type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any
|
|
354
|
+
type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
|
|
366
355
|
type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
367
356
|
/**
|
|
368
357
|
* Unique name used for the plugin
|
|
@@ -375,16 +364,18 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
375
364
|
*/
|
|
376
365
|
key: TOptions['key'];
|
|
377
366
|
/**
|
|
378
|
-
*
|
|
367
|
+
* 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.
|
|
368
|
+
* Can be used to validate depended plugins.
|
|
379
369
|
*/
|
|
380
|
-
|
|
370
|
+
pre?: Array<string>;
|
|
381
371
|
/**
|
|
382
|
-
*
|
|
383
|
-
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
384
|
-
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
385
|
-
* @default undefined
|
|
372
|
+
* 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.
|
|
386
373
|
*/
|
|
387
|
-
|
|
374
|
+
post?: Array<string>;
|
|
375
|
+
/**
|
|
376
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
377
|
+
*/
|
|
378
|
+
options: TOptions['resolvedOptions'];
|
|
388
379
|
} & (TOptions['api'] extends never ? {
|
|
389
380
|
api?: never;
|
|
390
381
|
} : {
|
|
@@ -392,11 +383,6 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
392
383
|
});
|
|
393
384
|
type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
394
385
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
395
|
-
/**
|
|
396
|
-
* Valdiate all plugins to see if their depended plugins are installed and configured.
|
|
397
|
-
* @type hookParallel
|
|
398
|
-
*/
|
|
399
|
-
validate?: (this: Omit<PluginContext<TOptions>, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise<true>;
|
|
400
386
|
/**
|
|
401
387
|
* Start of the lifecycle of a plugin.
|
|
402
388
|
* @type hookParallel
|
|
@@ -485,37 +471,48 @@ declare namespace KubbFile {
|
|
|
485
471
|
/**
|
|
486
472
|
* Import name to be used
|
|
487
473
|
* @example ["useState"]
|
|
488
|
-
* @
|
|
474
|
+
* @example "React"
|
|
489
475
|
*/
|
|
490
|
-
name: string | Array<string
|
|
476
|
+
name: string | Array<string | {
|
|
477
|
+
propertyName: string;
|
|
478
|
+
name?: string;
|
|
479
|
+
}>;
|
|
491
480
|
/**
|
|
492
481
|
* Path for the import
|
|
493
482
|
* @xample '@kubb/core'
|
|
494
483
|
*/
|
|
495
484
|
path: string;
|
|
496
485
|
/**
|
|
497
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'
|
|
486
|
+
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
498
487
|
*/
|
|
499
488
|
isTypeOnly?: boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Add `* as` prefix to the import, this will result in: `import * as path from './path'`.
|
|
491
|
+
*/
|
|
492
|
+
isNameSpace?: boolean;
|
|
493
|
+
/**
|
|
494
|
+
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
495
|
+
*/
|
|
496
|
+
root?: string;
|
|
500
497
|
};
|
|
501
498
|
type Export = {
|
|
502
499
|
/**
|
|
503
|
-
* Export name to be used
|
|
500
|
+
* Export name to be used.
|
|
504
501
|
* @example ["useState"]
|
|
505
|
-
* @
|
|
502
|
+
* @example "React"
|
|
506
503
|
*/
|
|
507
504
|
name?: string | Array<string>;
|
|
508
505
|
/**
|
|
509
|
-
* Path for the import
|
|
506
|
+
* Path for the import.
|
|
510
507
|
* @xample '@kubb/core'
|
|
511
508
|
*/
|
|
512
509
|
path: string;
|
|
513
510
|
/**
|
|
514
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'
|
|
511
|
+
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
515
512
|
*/
|
|
516
513
|
isTypeOnly?: boolean;
|
|
517
514
|
/**
|
|
518
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'
|
|
515
|
+
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
519
516
|
*/
|
|
520
517
|
asAlias?: boolean;
|
|
521
518
|
};
|
|
@@ -549,8 +546,8 @@ declare namespace KubbFile {
|
|
|
549
546
|
*/
|
|
550
547
|
id?: string;
|
|
551
548
|
/**
|
|
552
|
-
* Name to be used to
|
|
553
|
-
* Based on UNIX basename
|
|
549
|
+
* Name to be used to create the path
|
|
550
|
+
* Based on UNIX basename, `${name}.extName`
|
|
554
551
|
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
555
552
|
*/
|
|
556
553
|
baseName: TBaseName;
|
|
@@ -575,22 +572,34 @@ declare namespace KubbFile {
|
|
|
575
572
|
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
|
576
573
|
*/
|
|
577
574
|
env?: NodeJS.ProcessEnv;
|
|
578
|
-
/**
|
|
579
|
-
* @deprecated
|
|
580
|
-
*/
|
|
581
|
-
validate?: boolean;
|
|
582
575
|
};
|
|
583
576
|
type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = KubbFile.File<TMeta, TBaseName> & {
|
|
584
577
|
/**
|
|
585
578
|
* @default crypto.randomUUID()
|
|
586
579
|
*/
|
|
587
580
|
id: UUID;
|
|
581
|
+
/**
|
|
582
|
+
* Contains the first part of the baseName, generated based on baseName
|
|
583
|
+
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
584
|
+
*/
|
|
585
|
+
name: string;
|
|
588
586
|
};
|
|
589
587
|
}
|
|
590
588
|
type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
|
|
591
589
|
type AddIndexesProps = {
|
|
592
|
-
|
|
593
|
-
|
|
590
|
+
/**
|
|
591
|
+
* Root based on root and output.path specified in the config
|
|
592
|
+
*/
|
|
593
|
+
root: string;
|
|
594
|
+
/**
|
|
595
|
+
* Output for plugin
|
|
596
|
+
*/
|
|
597
|
+
output: {
|
|
598
|
+
path: string;
|
|
599
|
+
exportAs?: string;
|
|
600
|
+
extName?: KubbFile.Extname;
|
|
601
|
+
exportType?: 'barrel' | false;
|
|
602
|
+
};
|
|
594
603
|
options?: BarrelManagerOptions;
|
|
595
604
|
meta?: KubbFile.File['meta'];
|
|
596
605
|
};
|
|
@@ -608,7 +617,7 @@ declare class FileManager {
|
|
|
608
617
|
get files(): Array<KubbFile.File>;
|
|
609
618
|
get isExecuting(): boolean;
|
|
610
619
|
add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
|
|
611
|
-
addIndexes({ root,
|
|
620
|
+
addIndexes({ root, output, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
|
|
612
621
|
getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
|
|
613
622
|
get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
|
|
614
623
|
remove(path: KubbFile.Path): void;
|
|
@@ -702,12 +711,13 @@ type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
702
711
|
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
703
712
|
declare const pluginName = "core";
|
|
704
713
|
|
|
705
|
-
type PromiseFunc$1<T = unknown, T2 = never> = (state
|
|
714
|
+
type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
706
715
|
type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
|
|
707
716
|
type SeqOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Array<Awaited<ValueOfPromiseFuncArray<TInput>>>;
|
|
708
717
|
type HookFirstOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>;
|
|
709
|
-
type
|
|
710
|
-
type
|
|
718
|
+
type HookParallelOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>;
|
|
719
|
+
type Strategy = 'seq' | 'first' | 'parallel';
|
|
720
|
+
type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = TStrategy extends 'first' ? HookFirstOutput<TInput, TValue> : TStrategy extends 'seq' ? SeqOutput<TInput, TValue> : TStrategy extends 'parallel' ? HookParallelOutput<TInput, TValue> : never;
|
|
711
721
|
|
|
712
722
|
type PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
713
723
|
type Options<TState = any> = {
|
|
@@ -719,13 +729,6 @@ declare class PromiseManager<TState = any> {
|
|
|
719
729
|
run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(strategy: TStrategy, promises: TInput): TOutput;
|
|
720
730
|
}
|
|
721
731
|
|
|
722
|
-
/**
|
|
723
|
-
* Abstract class that contains the building blocks for plugins to create their own SchemaGenerator
|
|
724
|
-
*/
|
|
725
|
-
declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput> extends Generator<TOptions> {
|
|
726
|
-
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
732
|
interface _Register {
|
|
730
733
|
}
|
|
731
734
|
type Plugins = _Register;
|
|
@@ -736,4 +739,4 @@ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
|
|
|
736
739
|
type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
|
|
737
740
|
type Plugin = keyof Plugins;
|
|
738
741
|
|
|
739
|
-
export { CLIOptions, FileManager, Generator, GetPluginFactoryOptions, InputData, InputPath, KubbConfig, KubbFile, KubbObjectPlugin, KubbPlugin,
|
|
742
|
+
export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginWithLifeCycle, type KubbUnionPlugins, type KubbUserConfig, type KubbUserPlugin, type KubbUserPluginWithLifeCycle, type OptionsOfPlugin, type OptionsPlugins, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginUnion, type Plugins, PromiseManager, type ResolveNameParams, type ResolvePathParams, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
|