@kubb/core 3.0.0-alpha.0 → 3.0.0-alpha.2
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/FileManager-BW--rO8q.d.ts +437 -0
- package/dist/FileManager-Bw-FNS3q.d.cts +437 -0
- package/dist/{chunk-XRC6KXC3.cjs → chunk-67C6RBGQ.cjs} +5 -5
- package/dist/{chunk-XRC6KXC3.cjs.map → chunk-67C6RBGQ.cjs.map} +1 -1
- package/dist/{chunk-Y3LLJA4H.cjs → chunk-ADC5UNZ5.cjs} +145 -145
- package/dist/{chunk-Y3LLJA4H.cjs.map → chunk-ADC5UNZ5.cjs.map} +1 -1
- package/dist/{chunk-XRUOSVKX.cjs → chunk-LM2YQC3T.cjs} +12 -12
- package/dist/{chunk-XRUOSVKX.cjs.map → chunk-LM2YQC3T.cjs.map} +1 -1
- package/dist/{chunk-DKW7IBJV.cjs → chunk-PZT4CTBV.cjs} +18 -18
- package/dist/{chunk-DKW7IBJV.cjs.map → chunk-PZT4CTBV.cjs.map} +1 -1
- package/dist/{chunk-LKXUCYWU.cjs → chunk-XCPFG6DO.cjs} +3 -3
- package/dist/chunk-XCPFG6DO.cjs.map +1 -0
- package/dist/{chunk-OPOT6TCT.cjs → chunk-YTSNYMHW.cjs} +28 -28
- package/dist/{chunk-OPOT6TCT.cjs.map → chunk-YTSNYMHW.cjs.map} +1 -1
- package/dist/index.cjs +152 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -465
- package/dist/index.d.ts +10 -465
- package/dist/index.js +11 -55
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +3 -3
- package/dist/mocks.cjs +8 -8
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/transformers.cjs +4 -4
- package/dist/utils.cjs +4 -4
- package/package.json +9 -12
- package/src/PluginManager.ts +10 -19
- package/src/build.ts +3 -52
- package/src/index.ts +0 -3
- package/src/plugin.ts +1 -1
- package/src/types.ts +12 -37
- package/dist/chunk-LKXUCYWU.cjs.map +0 -1
- package/globals.d.ts +0 -49
- package/src/kubb.ts +0 -11
package/src/build.ts
CHANGED
|
@@ -3,13 +3,12 @@ import c from 'tinyrainbow'
|
|
|
3
3
|
import { clean, read } from '@kubb/fs'
|
|
4
4
|
import { FileManager, type ResolvedFile } from './FileManager.ts'
|
|
5
5
|
import { PluginManager } from './PluginManager.ts'
|
|
6
|
-
import { isPromise } from './PromiseManager.ts'
|
|
7
6
|
import { isInputPath } from './config.ts'
|
|
8
7
|
import { LogLevel, createLogger, randomCliColour } from './logger.ts'
|
|
9
8
|
import { URLPath } from './utils/URLPath.ts'
|
|
10
9
|
|
|
11
10
|
import type { Logger } from './logger.ts'
|
|
12
|
-
import type {
|
|
11
|
+
import type { PluginContext, PluginParameter } from './types.ts'
|
|
13
12
|
|
|
14
13
|
type BuildOptions = {
|
|
15
14
|
config: PluginContext['config']
|
|
@@ -28,15 +27,6 @@ type BuildOutput = {
|
|
|
28
27
|
error?: Error
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
async function transformReducer(
|
|
32
|
-
this: PluginContext,
|
|
33
|
-
_previousCode: string,
|
|
34
|
-
result: TransformResult | Promise<TransformResult>,
|
|
35
|
-
_plugin: Plugin,
|
|
36
|
-
): Promise<string | null> {
|
|
37
|
-
return result
|
|
38
|
-
}
|
|
39
|
-
|
|
40
30
|
async function setup(options: BuildOptions): Promise<PluginManager> {
|
|
41
31
|
const { config, logger = createLogger({ logLevel: LogLevel.silent }) } = options
|
|
42
32
|
let count = 0
|
|
@@ -63,40 +53,11 @@ async function setup(options: BuildOptions): Promise<PluginManager> {
|
|
|
63
53
|
const task = async (file: ResolvedFile): Promise<ResolvedFile> => {
|
|
64
54
|
const { path } = file
|
|
65
55
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const { result: loadedResult } = await pluginManager.hookFirst({
|
|
69
|
-
hookName: 'load',
|
|
70
|
-
parameters: [path],
|
|
71
|
-
})
|
|
72
|
-
if (loadedResult && isPromise(loadedResult)) {
|
|
73
|
-
source = await loadedResult
|
|
74
|
-
}
|
|
75
|
-
if (loadedResult && !isPromise(loadedResult)) {
|
|
76
|
-
source = loadedResult
|
|
77
|
-
}
|
|
56
|
+
const source: string | null = await FileManager.getSource(file)
|
|
78
57
|
|
|
79
58
|
if (source) {
|
|
80
|
-
source = await pluginManager.hookReduceArg0({
|
|
81
|
-
hookName: 'transform',
|
|
82
|
-
parameters: [path, source],
|
|
83
|
-
reduce: transformReducer,
|
|
84
|
-
})
|
|
85
|
-
|
|
86
59
|
if (config.output.write || config.output.write === undefined) {
|
|
87
|
-
|
|
88
|
-
// run only for pluginKey defined in the meta of the file
|
|
89
|
-
await pluginManager.hookForPlugin({
|
|
90
|
-
pluginKey: file.meta?.pluginKey,
|
|
91
|
-
hookName: 'writeFile',
|
|
92
|
-
parameters: [path, source],
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
await pluginManager.hookFirst({
|
|
97
|
-
hookName: 'writeFile',
|
|
98
|
-
parameters: [path, source],
|
|
99
|
-
})
|
|
60
|
+
await pluginManager.fileManager.write(path, source, { sanity: false })
|
|
100
61
|
}
|
|
101
62
|
}
|
|
102
63
|
|
|
@@ -108,16 +69,6 @@ async function setup(options: BuildOptions): Promise<PluginManager> {
|
|
|
108
69
|
|
|
109
70
|
const pluginManager = new PluginManager(config, { logger, task })
|
|
110
71
|
|
|
111
|
-
pluginManager.on('execute', (executer) => {
|
|
112
|
-
const { hookName, parameters, plugin } = executer
|
|
113
|
-
|
|
114
|
-
if (hookName === 'writeFile') {
|
|
115
|
-
const [code] = parameters as PluginParameter<'writeFile'>
|
|
116
|
-
|
|
117
|
-
logger.emit('debug', [`PluginKey ${c.dim(JSON.stringify(plugin.key))} \nwith source\n\n${code}`])
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
|
|
121
72
|
pluginManager.queue.on('add', () => {
|
|
122
73
|
if (logger.logLevel !== LogLevel.info) {
|
|
123
74
|
return
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,3 @@ export { createPlugin } from './plugin.ts'
|
|
|
9
9
|
export { PluginManager } from './PluginManager.ts'
|
|
10
10
|
export { PromiseManager } from './PromiseManager.ts'
|
|
11
11
|
export type * from './types.ts'
|
|
12
|
-
|
|
13
|
-
// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
|
|
14
|
-
export interface _Register {}
|
package/src/plugin.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type * as KubbFile from '@kubb/fs/types'
|
|
|
2
2
|
import type { PossiblePromise } from '@kubb/types'
|
|
3
3
|
import type { FileManager } from './FileManager.ts'
|
|
4
4
|
import type { PluginManager } from './PluginManager.ts'
|
|
5
|
-
import type { OptionsPlugins, PluginUnion } from './kubb.ts'
|
|
6
5
|
import type { Logger } from './logger.ts'
|
|
7
6
|
import type { Cache } from './utils/cache.ts'
|
|
8
7
|
|
|
@@ -24,11 +23,9 @@ export type UserConfig = Omit<Config, 'root' | 'plugins'> & {
|
|
|
24
23
|
*/
|
|
25
24
|
root?: string
|
|
26
25
|
/**
|
|
27
|
-
* Plugin type
|
|
28
|
-
* Example: ['@kubb/plugin-oas', { output: false }]
|
|
29
|
-
* Or: pluginOas({ output: false })
|
|
26
|
+
* Plugin type should be a Kubb plugin
|
|
30
27
|
*/
|
|
31
|
-
plugins?: Array<Omit<UnknownUserPlugin, '
|
|
28
|
+
plugins?: Array<Omit<UnknownUserPlugin, 'context'>>
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
export type InputPath = {
|
|
@@ -99,10 +96,6 @@ export type Config<TInput = Input> = {
|
|
|
99
96
|
|
|
100
97
|
// plugin
|
|
101
98
|
|
|
102
|
-
export type UnionPlugins = PluginUnion
|
|
103
|
-
|
|
104
|
-
export type ObjectPlugin = keyof OptionsPlugins
|
|
105
|
-
|
|
106
99
|
export type PluginFactoryOptions<
|
|
107
100
|
/**
|
|
108
101
|
* Name to be used for the plugin, this will also be used for they key.
|
|
@@ -117,9 +110,9 @@ export type PluginFactoryOptions<
|
|
|
117
110
|
*/
|
|
118
111
|
TResolvedOptions extends object = TOptions,
|
|
119
112
|
/**
|
|
120
|
-
*
|
|
113
|
+
* Context that you want to expose to other plugins.
|
|
121
114
|
*/
|
|
122
|
-
|
|
115
|
+
TContext = any,
|
|
123
116
|
/**
|
|
124
117
|
* When calling `resolvePath` you can specify better types.
|
|
125
118
|
*/
|
|
@@ -132,7 +125,7 @@ export type PluginFactoryOptions<
|
|
|
132
125
|
key: PluginKey<TName | string>
|
|
133
126
|
options: TOptions
|
|
134
127
|
resolvedOptions: TResolvedOptions
|
|
135
|
-
|
|
128
|
+
context: TContext
|
|
136
129
|
resolvePathOptions: TResolvePathOptions
|
|
137
130
|
}
|
|
138
131
|
|
|
@@ -160,12 +153,12 @@ export type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOpti
|
|
|
160
153
|
* 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.
|
|
161
154
|
*/
|
|
162
155
|
post?: Array<string>
|
|
163
|
-
} & (TOptions['
|
|
156
|
+
} & (TOptions['context'] extends never
|
|
164
157
|
? {
|
|
165
|
-
|
|
158
|
+
context?: never
|
|
166
159
|
}
|
|
167
160
|
: {
|
|
168
|
-
|
|
161
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context']
|
|
169
162
|
})
|
|
170
163
|
|
|
171
164
|
export type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>
|
|
@@ -197,14 +190,14 @@ export type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
197
190
|
*/
|
|
198
191
|
options: TOptions['resolvedOptions']
|
|
199
192
|
/**
|
|
200
|
-
* Define
|
|
193
|
+
* Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `createPlugin`).
|
|
201
194
|
*/
|
|
202
|
-
} & (TOptions['
|
|
195
|
+
} & (TOptions['context'] extends never
|
|
203
196
|
? {
|
|
204
|
-
|
|
197
|
+
context?: never
|
|
205
198
|
}
|
|
206
199
|
: {
|
|
207
|
-
|
|
200
|
+
context: TOptions['context']
|
|
208
201
|
})
|
|
209
202
|
|
|
210
203
|
export type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>
|
|
@@ -229,21 +222,6 @@ export type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactor
|
|
|
229
222
|
* @example ('pet') => 'Pet'
|
|
230
223
|
*/
|
|
231
224
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
|
|
232
|
-
/**
|
|
233
|
-
* Makes it possible to run async logic to override the path defined previously by `resolvePath`.
|
|
234
|
-
* @type hookFirst
|
|
235
|
-
*/
|
|
236
|
-
load?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>
|
|
237
|
-
/**
|
|
238
|
-
* Transform the source-code.
|
|
239
|
-
* @type hookReduceArg0
|
|
240
|
-
*/
|
|
241
|
-
transform?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>
|
|
242
|
-
/**
|
|
243
|
-
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
|
244
|
-
* @type hookParallel
|
|
245
|
-
*/
|
|
246
|
-
writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path, source: string | undefined) => PossiblePromise<string | void>
|
|
247
225
|
/**
|
|
248
226
|
* End of the plugin lifecycle.
|
|
249
227
|
* @type hookParallel
|
|
@@ -296,6 +274,3 @@ export type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryO
|
|
|
296
274
|
*/
|
|
297
275
|
plugin: Plugin<TOptions>
|
|
298
276
|
}
|
|
299
|
-
|
|
300
|
-
// null will mean clear the watcher for this key
|
|
301
|
-
export type TransformResult = string | null
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/core/dist/chunk-LKXUCYWU.cjs","../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.5_@types+node@20.14.15__jiti@1.21.6_postcss@8.4.40_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"],"names":[],"mappings":"AAAA,6EAAI,SAAS,EAAE,MAAM,CAAC,MAAM;AAC5B,IAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,iBAAiB,EAAE,MAAM,CAAC,wBAAwB;AACtD,IAAI,kBAAkB,EAAE,MAAM,CAAC,mBAAmB;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,cAAc;AACxC,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG;AAC3B,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC;AACtB,CAAC;AACD,IAAI,gBAAgB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK;AAC/J,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,SAAS,MAAM,CAAC,EAAE;AAC3C,EAAE,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAA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AAC,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC;AAC3K,IAAI,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,uBAAuB,CAAC,EAAE,MAAM,CAAC;AAC5G,IAAI,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC;AACzD,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE;AACf,IAAI,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;AAC5C,EAAE,CAAC;AACH,EAAE,IAAI,CAAC,CAAC,EAAE;AACV,IAAI,OAAO,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC;AAC5C,EAAE;AACF,CAAC,CAAC;AACF;AACA;AC/CA,IAAA,eAAA,EAAA,KAAA,CAAA;AAAA,EAAA,wLAAA,CAAA,EAAA;AAAA,IAAA,YAAA;AAAA,EAAA;AAAA,CAAA,CAAA;ADqDA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,kVAAC","file":"/home/runner/work/kubb/kubb/packages/core/dist/chunk-LKXUCYWU.cjs","sourcesContent":[null,"// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"]}
|
package/globals.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `tsconfig.json`
|
|
3
|
-
* @example
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
___ "types": ["@kubb/core/globals"]
|
|
6
|
-
}
|
|
7
|
-
* @example implementation
|
|
8
|
-
type SwaggerPlugin = Kubb.Plugins["@kubb/plugin-oas"]
|
|
9
|
-
const swaggerPlugin: SwaggerPlugin={
|
|
10
|
-
___ validate: true
|
|
11
|
-
}
|
|
12
|
-
*/
|
|
13
|
-
declare namespace Kubb {
|
|
14
|
-
namespace Helpers {
|
|
15
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never
|
|
16
|
-
type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never
|
|
17
|
-
|
|
18
|
-
// TS4.0+
|
|
19
|
-
type Push<T extends any[], V> = [...T, V]
|
|
20
|
-
|
|
21
|
-
// TS4.1+
|
|
22
|
-
type TuplifyUnion<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>
|
|
23
|
-
|
|
24
|
-
type ObjValueTuple<T, KS extends any[] = TuplifyUnion<keyof T>, R extends any[] = []> = KS extends [infer K, ...infer KT]
|
|
25
|
-
? ObjValueTuple<T, KT, [...R, [name: K & keyof T, options: T[K & keyof T]]]>
|
|
26
|
-
: R
|
|
27
|
-
|
|
28
|
-
type TupleToUnion<T> = T extends Array<infer ITEMS> ? ITEMS : never
|
|
29
|
-
}
|
|
30
|
-
type Plugins = {
|
|
31
|
-
['@kubb/plugin-oas']: import('@kubb/plugin-Oas').PluginOas
|
|
32
|
-
['@kubb/plugin-redoc']: import('@kubb/plugin-redoc').PluginRedoc
|
|
33
|
-
['@kubb/plugin-client']: import('@kubb/plugin-client').PluginClient
|
|
34
|
-
['@kubb/plugin-faker']: import('@kubb/plugin-faker').PluginFaker
|
|
35
|
-
['@kubb/plugin-swr']: import('@kubb/plugin-swr').PluginSwr
|
|
36
|
-
['@kubb/plugin-tanstack-query']: import('@kubb/plugin-tanstack-query').PluginTanstackQuery
|
|
37
|
-
['@kubb/plugin-ts']: import('@kubb/plugin-ts').PluginTs
|
|
38
|
-
['@kubb/plugin-zod']: import('@kubb/plugin-zod').PluginZod
|
|
39
|
-
['@kubb/plugin-zodios']: import('@kubb/plugin-zodios').PluginZodios
|
|
40
|
-
['@kubb/plugin-msw']: import('@kubb/plugin-msw').PluginMsw
|
|
41
|
-
}
|
|
42
|
-
type OptionsPlugins = { [K in keyof Plugins]: Plugins[K]['options'] }
|
|
43
|
-
|
|
44
|
-
type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options']
|
|
45
|
-
|
|
46
|
-
type PluginUnion = Helpers.TupleToUnion<Helpers.ObjValueTuple<OptionsPlugins>>
|
|
47
|
-
|
|
48
|
-
type Plugin = keyof Plugins
|
|
49
|
-
}
|
package/src/kubb.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ObjValueTuple, TupleToUnion } from '@kubb/types'
|
|
2
|
-
import type { _Register } from './index.ts'
|
|
3
|
-
|
|
4
|
-
export type Plugins = _Register
|
|
5
|
-
export type OptionsPlugins = { [K in keyof Plugins]: Plugins[K]['options'] }
|
|
6
|
-
|
|
7
|
-
export type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options']
|
|
8
|
-
|
|
9
|
-
export type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>
|
|
10
|
-
|
|
11
|
-
export type Plugin = keyof Plugins
|