@kubb/core 5.0.0-beta.8 → 5.0.0-beta.80
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/LICENSE +17 -10
- package/README.md +20 -123
- package/dist/diagnostics-CQYd4UQZ.d.ts +2888 -0
- package/dist/index.cjs +2350 -1102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +80 -138
- package/dist/index.js +2344 -1101
- package/dist/index.js.map +1 -1
- package/dist/memoryStorage-9cOBg7bL.cjs +1022 -0
- package/dist/memoryStorage-9cOBg7bL.cjs.map +1 -0
- package/dist/memoryStorage-C-3NpTDQ.js +884 -0
- package/dist/memoryStorage-C-3NpTDQ.js.map +1 -0
- package/dist/mocks.cjs +84 -24
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +37 -11
- package/dist/mocks.js +86 -28
- package/dist/mocks.js.map +1 -1
- package/package.json +9 -23
- package/dist/PluginDriver-Cu1Kj9S-.cjs +0 -1075
- package/dist/PluginDriver-Cu1Kj9S-.cjs.map +0 -1
- package/dist/PluginDriver-D8Z0Htid.js +0 -978
- package/dist/PluginDriver-D8Z0Htid.js.map +0 -1
- package/dist/createKubb-Cagd4PIe.d.ts +0 -2082
- package/src/FileManager.ts +0 -115
- package/src/FileProcessor.ts +0 -86
- package/src/PluginDriver.ts +0 -457
- package/src/constants.ts +0 -35
- package/src/createAdapter.ts +0 -108
- package/src/createKubb.ts +0 -1268
- package/src/createRenderer.ts +0 -57
- package/src/createStorage.ts +0 -70
- package/src/defineGenerator.ts +0 -175
- package/src/defineLogger.ts +0 -58
- package/src/defineMiddleware.ts +0 -62
- package/src/defineParser.ts +0 -44
- package/src/definePlugin.ts +0 -379
- package/src/defineResolver.ts +0 -654
- package/src/devtools.ts +0 -66
- package/src/index.ts +0 -20
- package/src/mocks.ts +0 -177
- package/src/storages/fsStorage.ts +0 -90
- package/src/storages/memoryStorage.ts +0 -55
- package/src/types.ts +0 -41
- /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/src/createAdapter.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type { PossiblePromise } from '@internals/utils'
|
|
2
|
-
import type { ImportNode, InputNode, 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
|
-
inputNode: InputNode | null
|
|
61
|
-
/**
|
|
62
|
-
* Parse the source into a universal `InputNode`.
|
|
63
|
-
*/
|
|
64
|
-
parse: (source: AdapterSource) => PossiblePromise<InputNode>
|
|
65
|
-
/**
|
|
66
|
-
* Extract `ImportNode` entries for a schema tree.
|
|
67
|
-
* Returns an empty array before the first `parse()` call.
|
|
68
|
-
*
|
|
69
|
-
* The `resolve` callback receives the collision-corrected schema name and must
|
|
70
|
-
* return `{ name, path }` for the import, or `undefined` to skip it.
|
|
71
|
-
*/
|
|
72
|
-
getImports: (node: SchemaNode, resolve: (schemaName: string) => { name: string; path: string }) => Array<ImportNode>
|
|
73
|
-
/**
|
|
74
|
-
* Validate the document at the given path or URL.
|
|
75
|
-
*/
|
|
76
|
-
validate: (input: string, options?: { throwOnError?: boolean }) => Promise<void>
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Factory for implementing custom adapters that translate non-OpenAPI specs into Kubb's AST.
|
|
83
|
-
*
|
|
84
|
-
* Use this to support GraphQL schemas, gRPC definitions, AsyncAPI, or custom domain-specific languages.
|
|
85
|
-
* Built-in adapters include `@kubb/adapter-oas` for OpenAPI and Swagger documents.
|
|
86
|
-
*
|
|
87
|
-
* @note Adapters must parse their input format to Kubb's `InputNode` structure.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```ts
|
|
91
|
-
* export const myAdapter = createAdapter<MyAdapter>((options) => {
|
|
92
|
-
* return {
|
|
93
|
-
* name: 'my-adapter',
|
|
94
|
-
* options,
|
|
95
|
-
* async parse(source) {
|
|
96
|
-
* // Transform source format to InputNode
|
|
97
|
-
* return { ... }
|
|
98
|
-
* },
|
|
99
|
-
* }
|
|
100
|
-
* })
|
|
101
|
-
*
|
|
102
|
-
* // Instantiate:
|
|
103
|
-
* const adapter = myAdapter({ validate: true })
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
export function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T> {
|
|
107
|
-
return (options) => build(options ?? ({} as T['options']))
|
|
108
|
-
}
|