@kubb/core 5.0.0-beta.60 → 5.0.0-beta.62
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/dist/{diagnostics-B-UZnFqP.d.ts → diagnostics-D0G07LHG.d.ts} +12 -14
- package/dist/index.cjs +71 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +72 -64
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +4 -4
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +3 -3
- package/dist/mocks.js +5 -5
- package/dist/mocks.js.map +1 -1
- package/package.json +4 -4
- package/src/KubbDriver.ts +23 -38
- package/src/Transform.ts +57 -27
- package/src/defineGenerator.ts +1 -8
- package/src/definePlugin.ts +10 -5
- package/src/mocks.ts +7 -7
package/src/mocks.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path, { resolve } from 'node:path'
|
|
2
2
|
import { camelCase } from '@internals/utils'
|
|
3
|
-
import type { FileNode, InputMeta, OperationNode, SchemaNode
|
|
4
|
-
import {
|
|
3
|
+
import type { FileNode, InputMeta, Macro, OperationNode, SchemaNode } from '@kubb/ast'
|
|
4
|
+
import { applyMacros } from '@kubb/ast'
|
|
5
5
|
import { expect } from 'vitest'
|
|
6
6
|
import type { Parser } from './defineParser.ts'
|
|
7
7
|
import { FileManager } from './FileManager.ts'
|
|
@@ -81,14 +81,14 @@ export function createMockedPlugin<TOptions extends PluginFactoryOptions = Plugi
|
|
|
81
81
|
name: TOptions['name']
|
|
82
82
|
options: TOptions['resolvedOptions']
|
|
83
83
|
resolver?: TOptions['resolver']
|
|
84
|
-
|
|
84
|
+
macros?: Array<Macro>
|
|
85
85
|
dependencies?: Array<string>
|
|
86
86
|
}): NormalizedPlugin<TOptions> {
|
|
87
87
|
return {
|
|
88
88
|
name: params.name,
|
|
89
89
|
options: params.options,
|
|
90
90
|
resolver: params.resolver,
|
|
91
|
-
|
|
91
|
+
macros: params.macros,
|
|
92
92
|
dependencies: params.dependencies,
|
|
93
93
|
hooks: {},
|
|
94
94
|
} as unknown as NormalizedPlugin<TOptions>
|
|
@@ -141,7 +141,7 @@ export async function renderGeneratorSchema<TOptions extends PluginFactoryOption
|
|
|
141
141
|
): Promise<void> {
|
|
142
142
|
if (!generator.schema) return
|
|
143
143
|
const context = createMockedPluginContext(opts)
|
|
144
|
-
const transformedNode = opts.plugin.
|
|
144
|
+
const transformedNode = opts.plugin.macros?.length ? applyMacros(node, opts.plugin.macros) : node
|
|
145
145
|
const result = await generator.schema(transformedNode, {
|
|
146
146
|
...context,
|
|
147
147
|
options: opts.options,
|
|
@@ -165,7 +165,7 @@ export async function renderGeneratorOperation<TOptions extends PluginFactoryOpt
|
|
|
165
165
|
): Promise<void> {
|
|
166
166
|
if (!generator.operation) return
|
|
167
167
|
const context = createMockedPluginContext(opts)
|
|
168
|
-
const transformedNode = opts.plugin.
|
|
168
|
+
const transformedNode = opts.plugin.macros?.length ? applyMacros(node, opts.plugin.macros) : node
|
|
169
169
|
const result = await generator.operation(transformedNode, {
|
|
170
170
|
...context,
|
|
171
171
|
options: opts.options,
|
|
@@ -189,7 +189,7 @@ export async function renderGeneratorOperations<TOptions extends PluginFactoryOp
|
|
|
189
189
|
): Promise<void> {
|
|
190
190
|
if (!generator.operations) return
|
|
191
191
|
const context = createMockedPluginContext(opts)
|
|
192
|
-
const transformedNodes = opts.plugin.
|
|
192
|
+
const transformedNodes = opts.plugin.macros?.length ? nodes.map((n) => applyMacros(n, opts.plugin.macros!)) : nodes
|
|
193
193
|
const result = await generator.operations(transformedNodes, {
|
|
194
194
|
...context,
|
|
195
195
|
options: opts.options,
|