@kubb/core 5.0.0-beta.11 → 5.0.0-beta.110

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/index.cjs +2430 -1184
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +136 -140
  6. package/dist/index.js +2419 -1173
  7. package/dist/index.js.map +1 -1
  8. package/dist/mocks.cjs +86 -32
  9. package/dist/mocks.cjs.map +1 -1
  10. package/dist/mocks.d.ts +37 -14
  11. package/dist/mocks.js +88 -36
  12. package/dist/mocks.js.map +1 -1
  13. package/dist/types-Ba5Mo-G8.d.ts +3016 -0
  14. package/dist/usingCtx-BdYw7ICK.cjs +954 -0
  15. package/dist/usingCtx-BdYw7ICK.cjs.map +1 -0
  16. package/dist/usingCtx-njZUKKsY.js +822 -0
  17. package/dist/usingCtx-njZUKKsY.js.map +1 -0
  18. package/package.json +7 -28
  19. package/dist/PluginDriver-C1OsqGBJ.cjs +0 -1086
  20. package/dist/PluginDriver-C1OsqGBJ.cjs.map +0 -1
  21. package/dist/PluginDriver-CGypdXHg.js +0 -989
  22. package/dist/PluginDriver-CGypdXHg.js.map +0 -1
  23. package/dist/createKubb-BSfMDBwR.d.ts +0 -2176
  24. package/src/FileManager.ts +0 -123
  25. package/src/FileProcessor.ts +0 -91
  26. package/src/PluginDriver.ts +0 -466
  27. package/src/constants.ts +0 -39
  28. package/src/createAdapter.ts +0 -108
  29. package/src/createKubb.ts +0 -1380
  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 -89
  42. package/src/storages/memoryStorage.ts +0 -55
  43. package/src/types.ts +0 -42
  44. /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/src/constants.ts DELETED
@@ -1,39 +0,0 @@
1
- import type { FileNode } from '@kubb/ast'
2
-
3
- /**
4
- * Base URL for the Kubb Studio web app.
5
- */
6
- export const DEFAULT_STUDIO_URL = 'https://kubb.studio' as const
7
-
8
- /**
9
- * Maximum number of files processed in parallel by FileProcessor.
10
- *
11
- * Capped at 16 to bound the number of CodeNode trees that are alive simultaneously
12
- * during rendering; I/O latency is the real bottleneck so higher values offer no
13
- * meaningful throughput improvement.
14
- */
15
- export const PARALLEL_CONCURRENCY_LIMIT = 16
16
-
17
- /**
18
- * Default banner style written at the top of every generated file.
19
- */
20
- export const DEFAULT_BANNER = 'simple' as const
21
-
22
- /**
23
- * Default file-extension mapping used when no explicit mapping is configured.
24
- */
25
- export const DEFAULT_EXTENSION: Record<FileNode['extname'], FileNode['extname'] | ''> = { '.ts': '.ts' }
26
-
27
- /**
28
- * Numeric log-level thresholds used internally to compare verbosity.
29
- *
30
- * Higher numbers are more verbose.
31
- */
32
- export const logLevel = {
33
- silent: Number.NEGATIVE_INFINITY,
34
- error: 0,
35
- warn: 1,
36
- info: 3,
37
- verbose: 4,
38
- debug: 5,
39
- } as const
@@ -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
- }