@kubb/core 5.0.0-alpha.6 → 5.0.0-alpha.60
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 +3 -2
- package/dist/PluginDriver-Bc0HQM8V.js +948 -0
- package/dist/PluginDriver-Bc0HQM8V.js.map +1 -0
- package/dist/PluginDriver-Dyl2fwfQ.cjs +1039 -0
- package/dist/PluginDriver-Dyl2fwfQ.cjs.map +1 -0
- package/dist/index.cjs +691 -1798
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +279 -265
- package/dist/index.js +678 -1765
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +138 -0
- package/dist/mocks.cjs.map +1 -0
- package/dist/mocks.d.ts +74 -0
- package/dist/mocks.js +133 -0
- package/dist/mocks.js.map +1 -0
- package/dist/types-i0b4_23K.d.ts +1903 -0
- package/package.json +51 -57
- package/src/FileManager.ts +110 -0
- package/src/FileProcessor.ts +86 -0
- package/src/Kubb.ts +205 -130
- package/src/PluginDriver.ts +424 -0
- package/src/constants.ts +20 -47
- package/src/createAdapter.ts +25 -0
- package/src/createKubb.ts +527 -0
- package/src/createRenderer.ts +57 -0
- package/src/createStorage.ts +58 -0
- package/src/defineGenerator.ts +88 -100
- package/src/defineLogger.ts +13 -3
- package/src/defineMiddleware.ts +59 -0
- package/src/defineParser.ts +45 -0
- package/src/definePlugin.ts +78 -7
- package/src/defineResolver.ts +521 -0
- package/src/devtools.ts +14 -14
- package/src/index.ts +13 -17
- package/src/mocks.ts +171 -0
- package/src/renderNode.ts +35 -0
- package/src/storages/fsStorage.ts +40 -11
- package/src/storages/memoryStorage.ts +4 -3
- package/src/types.ts +738 -218
- package/src/utils/diagnostics.ts +4 -1
- package/src/utils/isInputPath.ts +10 -0
- package/src/utils/packageJSON.ts +99 -0
- package/dist/PluginManager-vZodFEMe.d.ts +0 -1056
- package/dist/chunk-ByKO4r7w.cjs +0 -38
- package/dist/hooks.cjs +0 -60
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.d.ts +0 -64
- package/dist/hooks.js +0 -56
- package/dist/hooks.js.map +0 -1
- package/src/BarrelManager.ts +0 -74
- package/src/PackageManager.ts +0 -180
- package/src/PluginManager.ts +0 -667
- package/src/PromiseManager.ts +0 -40
- package/src/build.ts +0 -419
- package/src/config.ts +0 -56
- package/src/defineAdapter.ts +0 -22
- package/src/defineStorage.ts +0 -56
- package/src/errors.ts +0 -1
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useKubb.ts +0 -55
- package/src/hooks/useMode.ts +0 -11
- package/src/hooks/usePlugin.ts +0 -11
- package/src/hooks/usePluginManager.ts +0 -11
- package/src/utils/FunctionParams.ts +0 -155
- package/src/utils/TreeNode.ts +0 -215
- package/src/utils/executeStrategies.ts +0 -81
- package/src/utils/formatters.ts +0 -56
- package/src/utils/getBarrelFiles.ts +0 -79
- package/src/utils/getConfigs.ts +0 -30
- package/src/utils/getPlugins.ts +0 -23
- package/src/utils/linters.ts +0 -25
- package/src/utils/resolveOptions.ts +0 -93
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { isOperationNode, isSchemaNode } from '@kubb/ast'
|
|
2
|
-
import type { Node, OperationNode, SchemaNode } from '@kubb/ast/types'
|
|
3
|
-
|
|
4
|
-
type FilterItem = {
|
|
5
|
-
type: string
|
|
6
|
-
pattern: string | RegExp
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type OverrideItem<TOptions> = FilterItem & {
|
|
10
|
-
options: Omit<Partial<TOptions>, 'override'>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type ResolveOptionsContext<TOptions> = {
|
|
14
|
-
options: TOptions
|
|
15
|
-
exclude?: Array<FilterItem>
|
|
16
|
-
include?: Array<FilterItem>
|
|
17
|
-
override?: Array<OverrideItem<TOptions>>
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function matchesOperationPattern(node: OperationNode, type: string, pattern: string | RegExp): boolean {
|
|
21
|
-
switch (type) {
|
|
22
|
-
case 'tag':
|
|
23
|
-
return node.tags.some((tag) => !!tag.match(pattern))
|
|
24
|
-
case 'operationId':
|
|
25
|
-
return !!node.operationId.match(pattern)
|
|
26
|
-
case 'path':
|
|
27
|
-
return !!node.path.match(pattern)
|
|
28
|
-
case 'method':
|
|
29
|
-
return !!(node.method.toLowerCase() as string).match(pattern)
|
|
30
|
-
default:
|
|
31
|
-
return false
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function matchesSchemaPattern(node: SchemaNode, type: string, pattern: string | RegExp): boolean | null {
|
|
36
|
-
switch (type) {
|
|
37
|
-
case 'schemaName':
|
|
38
|
-
return node.name ? !!node.name.match(pattern) : false
|
|
39
|
-
default:
|
|
40
|
-
return null
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Resolves the effective plugin options for a given AST node by applying
|
|
46
|
-
* `exclude`, `include`, and `override` rules from the plugin configuration.
|
|
47
|
-
*
|
|
48
|
-
* Returns `null` when the node is excluded or not matched by `include`.
|
|
49
|
-
* Returns the merged options (base options merged with any matching `override`) otherwise.
|
|
50
|
-
*
|
|
51
|
-
* Supported filter types for `OperationNode`: `tag`, `operationId`, `path`, `method`.
|
|
52
|
-
* Supported filter types for `SchemaNode`: `schemaName`.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* const resolved = resolveOptions(operationNode, { options, exclude, include, override })
|
|
56
|
-
* if (!resolved) return // excluded
|
|
57
|
-
*/
|
|
58
|
-
export function resolveOptions<TOptions>(node: Node, { options, exclude = [], include, override = [] }: ResolveOptionsContext<TOptions>): TOptions | null {
|
|
59
|
-
if (isOperationNode(node)) {
|
|
60
|
-
const isExcluded = exclude.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))
|
|
61
|
-
if (isExcluded) {
|
|
62
|
-
return null
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (include && !include.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) {
|
|
66
|
-
return null
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const overrideOptions = override.find(({ type, pattern }) => matchesOperationPattern(node, type, pattern))?.options
|
|
70
|
-
|
|
71
|
-
return { ...options, ...overrideOptions }
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (isSchemaNode(node)) {
|
|
75
|
-
if (exclude.some(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)) {
|
|
76
|
-
return null
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (include) {
|
|
80
|
-
const results = include.map(({ type, pattern }) => matchesSchemaPattern(node, type, pattern))
|
|
81
|
-
const applicable = results.filter((r) => r !== null)
|
|
82
|
-
if (applicable.length > 0 && !applicable.includes(true)) {
|
|
83
|
-
return null
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const overrideOptions = override.find(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)?.options
|
|
88
|
-
|
|
89
|
-
return { ...options, ...overrideOptions }
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return options
|
|
93
|
-
}
|