@kubb/core 2.0.0-alpha.9 → 2.0.0-beta.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/README.md +1 -1
- package/dist/index.cjs +10 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -11
- package/dist/index.d.ts +14 -11
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +9 -10
- package/src/FileManager.ts +7 -7
- package/src/PluginManager.ts +6 -22
- package/src/PromiseManager.ts +5 -1
- package/src/types.ts +2 -0
- package/src/utils/executeStrategies.ts +14 -2
package/dist/index.d.cts
CHANGED
|
@@ -355,7 +355,9 @@ type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions
|
|
|
355
355
|
} : {
|
|
356
356
|
/**
|
|
357
357
|
* Kind/type for the plugin
|
|
358
|
+
*
|
|
358
359
|
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
360
|
+
*
|
|
359
361
|
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
360
362
|
* @default undefined
|
|
361
363
|
*/
|
|
@@ -485,7 +487,7 @@ declare namespace KubbFile {
|
|
|
485
487
|
/**
|
|
486
488
|
* Import name to be used
|
|
487
489
|
* @example ["useState"]
|
|
488
|
-
* @
|
|
490
|
+
* @example "React"
|
|
489
491
|
*/
|
|
490
492
|
name: string | Array<string>;
|
|
491
493
|
/**
|
|
@@ -494,28 +496,28 @@ declare namespace KubbFile {
|
|
|
494
496
|
*/
|
|
495
497
|
path: string;
|
|
496
498
|
/**
|
|
497
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'
|
|
499
|
+
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
498
500
|
*/
|
|
499
501
|
isTypeOnly?: boolean;
|
|
500
502
|
};
|
|
501
503
|
type Export = {
|
|
502
504
|
/**
|
|
503
|
-
* Export name to be used
|
|
505
|
+
* Export name to be used.
|
|
504
506
|
* @example ["useState"]
|
|
505
|
-
* @
|
|
507
|
+
* @example "React"
|
|
506
508
|
*/
|
|
507
509
|
name?: string | Array<string>;
|
|
508
510
|
/**
|
|
509
|
-
* Path for the import
|
|
511
|
+
* Path for the import.
|
|
510
512
|
* @xample '@kubb/core'
|
|
511
513
|
*/
|
|
512
514
|
path: string;
|
|
513
515
|
/**
|
|
514
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'
|
|
516
|
+
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
515
517
|
*/
|
|
516
518
|
isTypeOnly?: boolean;
|
|
517
519
|
/**
|
|
518
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'
|
|
520
|
+
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
519
521
|
*/
|
|
520
522
|
asAlias?: boolean;
|
|
521
523
|
};
|
|
@@ -702,12 +704,13 @@ type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
702
704
|
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
703
705
|
declare const pluginName = "core";
|
|
704
706
|
|
|
705
|
-
type PromiseFunc$1<T = unknown, T2 = never> = (state
|
|
707
|
+
type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
706
708
|
type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
|
|
707
709
|
type SeqOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Array<Awaited<ValueOfPromiseFuncArray<TInput>>>;
|
|
708
710
|
type HookFirstOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>;
|
|
709
|
-
type
|
|
710
|
-
type
|
|
711
|
+
type HookParallelOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>;
|
|
712
|
+
type Strategy = 'seq' | 'first' | 'parallel';
|
|
713
|
+
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
714
|
|
|
712
715
|
type PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
713
716
|
type Options<TState = any> = {
|
|
@@ -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, KubbPluginKind, KubbPluginWithLifeCycle, KubbUnionPlugins, KubbUserConfig, KubbUserPlugin, KubbUserPluginWithLifeCycle, OptionsOfPlugin, OptionsPlugins, PackageManager, Plugin, PluginCache, PluginContext, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginUnion, Plugins, PromiseManager, ResolveNameParams, ResolvePathParams, SchemaGenerator, TransformResult, ValidationPluginError, Warning, _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
|
|
742
|
+
export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginKind, 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, SchemaGenerator, 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
|
@@ -355,7 +355,9 @@ type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions
|
|
|
355
355
|
} : {
|
|
356
356
|
/**
|
|
357
357
|
* Kind/type for the plugin
|
|
358
|
+
*
|
|
358
359
|
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
360
|
+
*
|
|
359
361
|
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
360
362
|
* @default undefined
|
|
361
363
|
*/
|
|
@@ -485,7 +487,7 @@ declare namespace KubbFile {
|
|
|
485
487
|
/**
|
|
486
488
|
* Import name to be used
|
|
487
489
|
* @example ["useState"]
|
|
488
|
-
* @
|
|
490
|
+
* @example "React"
|
|
489
491
|
*/
|
|
490
492
|
name: string | Array<string>;
|
|
491
493
|
/**
|
|
@@ -494,28 +496,28 @@ declare namespace KubbFile {
|
|
|
494
496
|
*/
|
|
495
497
|
path: string;
|
|
496
498
|
/**
|
|
497
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'
|
|
499
|
+
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
498
500
|
*/
|
|
499
501
|
isTypeOnly?: boolean;
|
|
500
502
|
};
|
|
501
503
|
type Export = {
|
|
502
504
|
/**
|
|
503
|
-
* Export name to be used
|
|
505
|
+
* Export name to be used.
|
|
504
506
|
* @example ["useState"]
|
|
505
|
-
* @
|
|
507
|
+
* @example "React"
|
|
506
508
|
*/
|
|
507
509
|
name?: string | Array<string>;
|
|
508
510
|
/**
|
|
509
|
-
* Path for the import
|
|
511
|
+
* Path for the import.
|
|
510
512
|
* @xample '@kubb/core'
|
|
511
513
|
*/
|
|
512
514
|
path: string;
|
|
513
515
|
/**
|
|
514
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'
|
|
516
|
+
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
515
517
|
*/
|
|
516
518
|
isTypeOnly?: boolean;
|
|
517
519
|
/**
|
|
518
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'
|
|
520
|
+
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
519
521
|
*/
|
|
520
522
|
asAlias?: boolean;
|
|
521
523
|
};
|
|
@@ -702,12 +704,13 @@ type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
702
704
|
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
703
705
|
declare const pluginName = "core";
|
|
704
706
|
|
|
705
|
-
type PromiseFunc$1<T = unknown, T2 = never> = (state
|
|
707
|
+
type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
706
708
|
type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
|
|
707
709
|
type SeqOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Array<Awaited<ValueOfPromiseFuncArray<TInput>>>;
|
|
708
710
|
type HookFirstOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>;
|
|
709
|
-
type
|
|
710
|
-
type
|
|
711
|
+
type HookParallelOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>;
|
|
712
|
+
type Strategy = 'seq' | 'first' | 'parallel';
|
|
713
|
+
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
714
|
|
|
712
715
|
type PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
713
716
|
type Options<TState = any> = {
|
|
@@ -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, KubbPluginKind, KubbPluginWithLifeCycle, KubbUnionPlugins, KubbUserConfig, KubbUserPlugin, KubbUserPluginWithLifeCycle, OptionsOfPlugin, OptionsPlugins, PackageManager, Plugin, PluginCache, PluginContext, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginUnion, Plugins, PromiseManager, ResolveNameParams, ResolvePathParams, SchemaGenerator, TransformResult, ValidationPluginError, Warning, _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
|
|
742
|
+
export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginKind, 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, SchemaGenerator, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
|
package/dist/index.js
CHANGED
|
@@ -1195,6 +1195,9 @@ function hookFirst(promises, nullCheck = (state) => state !== null) {
|
|
|
1195
1195
|
}
|
|
1196
1196
|
return promise;
|
|
1197
1197
|
}
|
|
1198
|
+
function hookParallel(promises) {
|
|
1199
|
+
return Promise.allSettled(promises.filter(Boolean).map((promise) => promise()));
|
|
1200
|
+
}
|
|
1198
1201
|
|
|
1199
1202
|
// src/PromiseManager.ts
|
|
1200
1203
|
var _options2;
|
|
@@ -1211,6 +1214,9 @@ var PromiseManager = class {
|
|
|
1211
1214
|
if (strategy === "first") {
|
|
1212
1215
|
return hookFirst(promises, __privateGet(this, _options2).nullCheck);
|
|
1213
1216
|
}
|
|
1217
|
+
if (strategy === "parallel") {
|
|
1218
|
+
return hookParallel(promises);
|
|
1219
|
+
}
|
|
1214
1220
|
throw new Error(`${strategy} not implemented`);
|
|
1215
1221
|
}
|
|
1216
1222
|
};
|
|
@@ -1415,14 +1421,10 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1415
1421
|
hookName,
|
|
1416
1422
|
parameters
|
|
1417
1423
|
}) {
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
parallelPromises.push(promise);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
const results = await Promise.allSettled(parallelPromises);
|
|
1424
|
+
const promises = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
|
|
1425
|
+
return () => __privateMethod(this, _execute, execute_fn).call(this, { strategy: "hookParallel", hookName, parameters, plugin });
|
|
1426
|
+
});
|
|
1427
|
+
const results = await __privateGet(this, _promiseManager).run("parallel", promises);
|
|
1426
1428
|
results.forEach((result, index) => {
|
|
1427
1429
|
if (isPromiseRejectedResult(result)) {
|
|
1428
1430
|
const plugin = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)[index];
|