@kubb/core 5.0.0-alpha.13 → 5.0.0-alpha.14
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/{PluginDriver-BkFepPdm.d.ts → PluginDriver-By5lhDKP.d.ts} +2 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/index.cjs +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/defineResolver.ts +4 -4
- package/src/index.ts +1 -0
- package/src/types.ts +1 -0
- package/src/utils/executeStrategies.ts +7 -7
- package/src/utils/mergeResolvers.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.14",
|
|
4
4
|
"description": "Core functionality for Kubb's plugin-based code generation system, providing the foundation for transforming OpenAPI specifications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"remeda": "^2.33.6",
|
|
72
72
|
"semver": "^7.7.4",
|
|
73
73
|
"tinyexec": "^1.0.4",
|
|
74
|
-
"@kubb/ast": "5.0.0-alpha.
|
|
74
|
+
"@kubb/ast": "5.0.0-alpha.14"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/semver": "^7.7.1",
|
package/src/defineResolver.ts
CHANGED
|
@@ -5,11 +5,10 @@ import type { PluginFactoryOptions, ResolveNameParams, ResolveOptionsContext } f
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Builder type for the plugin-specific resolver fields.
|
|
8
|
-
* `default` and `
|
|
8
|
+
* `default`, `resolveOptions`, and `name` are optional — built-in fallbacks are used when omitted.
|
|
9
9
|
*/
|
|
10
|
-
type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<T['resolver'], 'default' | 'resolveOptions'> &
|
|
11
|
-
Partial<Pick<T['resolver'], 'default' | 'resolveOptions'>> &
|
|
12
|
-
ThisType<T['resolver']>
|
|
10
|
+
type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<T['resolver'], 'default' | 'resolveOptions' | 'name'> &
|
|
11
|
+
Partial<Pick<T['resolver'], 'default' | 'resolveOptions'>> & { name: string } & ThisType<T['resolver']>
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Checks if an operation matches a pattern for a given filter type (`tag`, `operationId`, `path`, `method`).
|
|
@@ -111,6 +110,7 @@ export function defaultResolveOptions<TOptions>(
|
|
|
111
110
|
*
|
|
112
111
|
* @example
|
|
113
112
|
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
113
|
+
* name: 'default',
|
|
114
114
|
* resolveName(name) {
|
|
115
115
|
* return this.default(name, 'function')
|
|
116
116
|
* },
|
package/src/index.ts
CHANGED
|
@@ -20,4 +20,5 @@ export type { FileMetaBase } from './utils/getBarrelFiles.ts'
|
|
|
20
20
|
export { getBarrelFiles } from './utils/getBarrelFiles.ts'
|
|
21
21
|
export { getConfigs } from './utils/getConfigs.ts'
|
|
22
22
|
export { detectLinter } from './utils/linters.ts'
|
|
23
|
+
export { mergeResolvers } from './utils/mergeResolvers.ts'
|
|
23
24
|
export { satisfiesDependency } from './utils/packageJSON.ts'
|
package/src/types.ts
CHANGED
|
@@ -284,6 +284,7 @@ export type ResolveOptionsContext<TOptions> = {
|
|
|
284
284
|
* Concrete plugin resolver types extend this with their own helper methods.
|
|
285
285
|
*/
|
|
286
286
|
export type Resolver = {
|
|
287
|
+
name: string
|
|
287
288
|
default(name: ResolveNameParams['name'], type?: ResolveNameParams['type']): string
|
|
288
289
|
resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null
|
|
289
290
|
}
|
|
@@ -72,10 +72,10 @@ export function hookParallel<TInput extends Array<PromiseFunc<TValue, null>>, TV
|
|
|
72
72
|
|
|
73
73
|
export type Strategy = 'seq' | 'first' | 'parallel'
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
type StrategyOutputMap<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = {
|
|
76
|
+
first: HookFirstOutput<TInput, TValue>
|
|
77
|
+
seq: SeqOutput<TInput, TValue>
|
|
78
|
+
parallel: HookParallelOutput<TInput, TValue>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc<TValue, null>>, TValue> = StrategyOutputMap<TInput, TValue>[TStrategy]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Resolver } from '../types.ts'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merges an array of resolvers into a single resolver. Later entries override earlier ones (last wins).
|
|
5
|
+
*/
|
|
6
|
+
export function mergeResolvers<T extends Resolver>(...resolvers: Array<T>): T {
|
|
7
|
+
return resolvers.reduce<T>((acc, curr) => ({ ...acc, ...curr }), resolvers[0]!)
|
|
8
|
+
}
|