{"version":3,"file":"generators-CyWd3UXA.cjs","names":["camelCase","getBanner","getFooter"],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n  name: string\n  version?: TVersion\n  operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n  operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n  schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n  name: string\n  type: 'core'\n  version: TVersion\n  operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n  operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n  schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n  generator: UserGenerator<TOptions, TVersion>,\n): CoreGenerator<TOptions, TVersion> {\n  return {\n    type: 'core',\n    version: (generator.version ?? '1') as TVersion,\n    async operations() {\n      return []\n    },\n    async operation() {\n      return []\n    },\n    async schema() {\n      return []\n    },\n    ...generator,\n  }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n  name: string\n  version?: TVersion\n  Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n  Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n  Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n  name: string\n  type: 'react'\n  version: TVersion\n  Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n  Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n  Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * 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.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n  generator: UserGenerator<TOptions, TVersion>,\n): ReactGenerator<TOptions, TVersion> {\n  return {\n    type: 'react',\n    version: (generator.version ?? '1') as TVersion,\n    Operations() {\n      return null\n    },\n    Operation() {\n      return null\n    },\n    Schema() {\n      return null\n    },\n    ...generator,\n  }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n  name: 'plugin-oas',\n  async schema({ schema, generator }) {\n    const { pluginManager, plugin } = generator.context\n    const file = pluginManager.getFile({\n      name: camelCase(schema.name),\n      extname: '.json',\n      mode: 'split',\n      pluginKey: plugin.key,\n    })\n\n    return [\n      {\n        ...file,\n        sources: [\n          {\n            name: camelCase(schema.name),\n            isExportable: false,\n            isIndexable: false,\n            value: JSON.stringify(schema.value),\n          },\n        ],\n        banner: getBanner({\n          oas: generator.context.oas,\n          output: plugin.options.output,\n          config: pluginManager.config,\n        }),\n        format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n      },\n    ]\n  },\n})\n"],"mappings":";;;AAqBA,SAAgB,gBACd,WACmC;AACnC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACTH,SAAgB,qBACd,WACoC;AACpC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACtCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQC,kBAAAA,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,kBAAAA,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}