@kubb/core 5.0.0-beta.2 → 5.0.0-beta.21
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 +8 -38
- package/dist/KubbDriver-BBRa5CH2.cjs +2231 -0
- package/dist/KubbDriver-BBRa5CH2.cjs.map +1 -0
- package/dist/KubbDriver-Cq1isv2P.js +2110 -0
- package/dist/KubbDriver-Cq1isv2P.js.map +1 -0
- package/dist/{types-CC09VtBt.d.ts → createKubb-CYrw_xaR.d.ts} +1414 -1255
- package/dist/index.cjs +221 -1074
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -185
- package/dist/index.js +211 -1068
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +30 -21
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +5 -5
- package/dist/mocks.js +29 -20
- package/dist/mocks.js.map +1 -1
- package/package.json +6 -18
- package/src/FileManager.ts +75 -58
- package/src/FileProcessor.ts +48 -38
- package/src/KubbDriver.ts +915 -0
- package/src/constants.ts +11 -6
- package/src/createAdapter.ts +84 -1
- package/src/createKubb.ts +1022 -485
- package/src/createRenderer.ts +33 -22
- package/src/defineGenerator.ts +96 -7
- package/src/defineLogger.ts +42 -3
- package/src/defineMiddleware.ts +1 -1
- package/src/defineParser.ts +1 -1
- package/src/definePlugin.ts +304 -8
- package/src/defineResolver.ts +271 -150
- package/src/devtools.ts +8 -1
- package/src/index.ts +2 -2
- package/src/mocks.ts +11 -14
- package/src/storages/fsStorage.ts +13 -37
- package/src/types.ts +39 -1292
- package/dist/PluginDriver-BXibeQk-.cjs +0 -1036
- package/dist/PluginDriver-BXibeQk-.cjs.map +0 -1
- package/dist/PluginDriver-DV3p2Hky.js +0 -945
- package/dist/PluginDriver-DV3p2Hky.js.map +0 -1
- package/src/Kubb.ts +0 -300
- package/src/PluginDriver.ts +0 -424
- package/src/renderNode.ts +0 -35
- package/src/utils/diagnostics.ts +0 -18
- package/src/utils/isInputPath.ts +0 -10
- package/src/utils/packageJSON.ts +0 -99
package/src/constants.ts
CHANGED
|
@@ -3,12 +3,7 @@ import type { FileNode } from '@kubb/ast'
|
|
|
3
3
|
/**
|
|
4
4
|
* Base URL for the Kubb Studio web app.
|
|
5
5
|
*/
|
|
6
|
-
export const DEFAULT_STUDIO_URL = 'https://
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Maximum number of files processed in parallel by FileProcessor.
|
|
10
|
-
*/
|
|
11
|
-
export const PARALLEL_CONCURRENCY_LIMIT = 100
|
|
6
|
+
export const DEFAULT_STUDIO_URL = 'https://kubb.studio' as const
|
|
12
7
|
|
|
13
8
|
/**
|
|
14
9
|
* Default banner style written at the top of every generated file.
|
|
@@ -20,6 +15,16 @@ export const DEFAULT_BANNER = 'simple' as const
|
|
|
20
15
|
*/
|
|
21
16
|
export const DEFAULT_EXTENSION: Record<FileNode['extname'], FileNode['extname'] | ''> = { '.ts': '.ts' }
|
|
22
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Number of file writes to batch in parallel during `flushPendingFiles`.
|
|
20
|
+
*/
|
|
21
|
+
export const STREAM_FLUSH_EVERY = 50
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Number of schema/operation nodes to dispatch concurrently during generation.
|
|
25
|
+
*/
|
|
26
|
+
export const SCHEMA_PARALLEL = 8
|
|
27
|
+
|
|
23
28
|
/**
|
|
24
29
|
* Numeric log-level thresholds used internally to compare verbosity.
|
|
25
30
|
*
|
package/src/createAdapter.ts
CHANGED
|
@@ -1,4 +1,87 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PossiblePromise } from '@internals/utils'
|
|
2
|
+
import type { ImportNode, InputNode, InputStreamNode, SchemaNode } from '@kubb/ast'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Source data passed to an adapter's `parse` function.
|
|
6
|
+
* Mirrors the config input shape with paths resolved to absolute.
|
|
7
|
+
*/
|
|
8
|
+
export type AdapterSource = { type: 'path'; path: string } | { type: 'data'; data: string | unknown } | { type: 'paths'; paths: Array<string> }
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generic type parameters for an adapter definition.
|
|
12
|
+
*
|
|
13
|
+
* - `TName` — unique identifier (e.g. `'oas'`, `'asyncapi'`)
|
|
14
|
+
* - `TOptions` — user-facing options passed to the adapter factory
|
|
15
|
+
* - `TResolvedOptions` — options after defaults applied
|
|
16
|
+
* - `TDocument` — type of the parsed source document
|
|
17
|
+
*/
|
|
18
|
+
export type AdapterFactoryOptions<
|
|
19
|
+
TName extends string = string,
|
|
20
|
+
TOptions extends object = object,
|
|
21
|
+
TResolvedOptions extends object = TOptions,
|
|
22
|
+
TDocument = unknown,
|
|
23
|
+
> = {
|
|
24
|
+
name: TName
|
|
25
|
+
options: TOptions
|
|
26
|
+
resolvedOptions: TResolvedOptions
|
|
27
|
+
document: TDocument
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Adapter that converts input files or data into an `InputNode`.
|
|
32
|
+
*
|
|
33
|
+
* Adapters parse different schema formats (OpenAPI, AsyncAPI, Drizzle, etc.) into Kubb's
|
|
34
|
+
* universal intermediate representation that all plugins consume.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { adapterOas } from '@kubb/adapter-oas'
|
|
39
|
+
*
|
|
40
|
+
* export default defineConfig({
|
|
41
|
+
* adapter: adapterOas(),
|
|
42
|
+
* input: { path: './openapi.yaml' },
|
|
43
|
+
* plugins: [pluginTs(), pluginZod()],
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
48
|
+
/**
|
|
49
|
+
* Human-readable adapter identifier (e.g. `'oas'`, `'asyncapi'`).
|
|
50
|
+
*/
|
|
51
|
+
name: TOptions['name']
|
|
52
|
+
/**
|
|
53
|
+
* Resolved adapter options after defaults have been applied.
|
|
54
|
+
*/
|
|
55
|
+
options: TOptions['resolvedOptions']
|
|
56
|
+
/**
|
|
57
|
+
* Parsed source document after the first `parse()` call. `null` before parsing.
|
|
58
|
+
*/
|
|
59
|
+
document: TOptions['document'] | null
|
|
60
|
+
/**
|
|
61
|
+
* Parse the source into a universal `InputNode`.
|
|
62
|
+
*/
|
|
63
|
+
parse: (source: AdapterSource) => PossiblePromise<InputNode>
|
|
64
|
+
/**
|
|
65
|
+
* Extract `ImportNode` entries for a schema tree.
|
|
66
|
+
* Returns an empty array before the first `parse()` call.
|
|
67
|
+
*
|
|
68
|
+
* The `resolve` callback receives the collision-corrected schema name and must
|
|
69
|
+
* return `{ name, path }` for the import, or `undefined` to skip it.
|
|
70
|
+
*/
|
|
71
|
+
getImports: (node: SchemaNode, resolve: (schemaName: string) => { name: string; path: string }) => Array<ImportNode>
|
|
72
|
+
/**
|
|
73
|
+
* Validate the document at the given path or URL.
|
|
74
|
+
*/
|
|
75
|
+
validate: (input: string, options?: { throwOnError?: boolean }) => Promise<void>
|
|
76
|
+
/**
|
|
77
|
+
* Memory-efficient streaming variant of `parse()`.
|
|
78
|
+
*
|
|
79
|
+
* Returns an `InputStreamNode` whose `schemas` and `operations` are `AsyncIterable`.
|
|
80
|
+
* Each `for await` loop creates a fresh parse pass over the cached in-memory document —
|
|
81
|
+
* no pre-built arrays are held in memory.
|
|
82
|
+
*/
|
|
83
|
+
stream?: (source: AdapterSource) => Promise<InputStreamNode>
|
|
84
|
+
}
|
|
2
85
|
|
|
3
86
|
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>
|
|
4
87
|
|