@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/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, Visitor } from '@kubb/ast'
4
- import { transform } from '@kubb/ast'
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
- transformer?: Visitor
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
- transformer: params.transformer,
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.transformer ? transform(node, opts.plugin.transformer) : node
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.transformer ? transform(node, opts.plugin.transformer) : node
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.transformer ? nodes.map((n) => transform(n, opts.plugin.transformer!)) : nodes
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,