import type { PluginFactoryOptions } from '@kubb/core' import type { FabricReactNode } from '@kubb/react-fabric/types' import type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts' type UserGenerator = { name: string version?: TVersion Operations?: (props: OperationsProps) => FabricReactNode Operation?: (props: OperationProps) => FabricReactNode Schema?: (props: SchemaProps) => FabricReactNode } export type ReactGenerator = { name: string type: 'react' version: TVersion Operations: (props: OperationsProps) => FabricReactNode Operation: (props: OperationProps) => FabricReactNode Schema: (props: SchemaProps) => FabricReactNode } /**** * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas. * * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array. * * @returns A generator object with async methods for operations, operation, and schema file generation. */ export function createReactGenerator( generator: UserGenerator, ): ReactGenerator { return { type: 'react', version: (generator.version ?? '1') as TVersion, Operations() { return null }, Operation() { return null }, Schema() { return null }, ...generator, } }