@kubb/core 5.0.0-beta.8 → 5.0.0-beta.81

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.
Files changed (44) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +20 -123
  3. package/dist/diagnostics-DcFh-77r.d.ts +2889 -0
  4. package/dist/index.cjs +2349 -1107
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +79 -138
  7. package/dist/index.js +2344 -1101
  8. package/dist/index.js.map +1 -1
  9. package/dist/memoryStorage-BjUIqpYE.js +883 -0
  10. package/dist/memoryStorage-BjUIqpYE.js.map +1 -0
  11. package/dist/memoryStorage-DQ6qXJ8o.cjs +1021 -0
  12. package/dist/memoryStorage-DQ6qXJ8o.cjs.map +1 -0
  13. package/dist/mocks.cjs +84 -24
  14. package/dist/mocks.cjs.map +1 -1
  15. package/dist/mocks.d.ts +37 -11
  16. package/dist/mocks.js +86 -28
  17. package/dist/mocks.js.map +1 -1
  18. package/package.json +8 -26
  19. package/dist/PluginDriver-Cu1Kj9S-.cjs +0 -1075
  20. package/dist/PluginDriver-Cu1Kj9S-.cjs.map +0 -1
  21. package/dist/PluginDriver-D8Z0Htid.js +0 -978
  22. package/dist/PluginDriver-D8Z0Htid.js.map +0 -1
  23. package/dist/createKubb-Cagd4PIe.d.ts +0 -2082
  24. package/src/FileManager.ts +0 -115
  25. package/src/FileProcessor.ts +0 -86
  26. package/src/PluginDriver.ts +0 -457
  27. package/src/constants.ts +0 -35
  28. package/src/createAdapter.ts +0 -108
  29. package/src/createKubb.ts +0 -1268
  30. package/src/createRenderer.ts +0 -57
  31. package/src/createStorage.ts +0 -70
  32. package/src/defineGenerator.ts +0 -175
  33. package/src/defineLogger.ts +0 -58
  34. package/src/defineMiddleware.ts +0 -62
  35. package/src/defineParser.ts +0 -44
  36. package/src/definePlugin.ts +0 -379
  37. package/src/defineResolver.ts +0 -654
  38. package/src/devtools.ts +0 -66
  39. package/src/index.ts +0 -20
  40. package/src/mocks.ts +0 -177
  41. package/src/storages/fsStorage.ts +0 -90
  42. package/src/storages/memoryStorage.ts +0 -55
  43. package/src/types.ts +0 -41
  44. /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
@@ -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
- }