import { configProblem, INVALID_CONFIG_HELP } from '@internals/utils' import { type Config, Diagnostics, assertPluginOption as coreAssertPluginOption } from '@kubb/core' /** * Throws `KUBB_INVALID_CONFIG` for a config without `output.path`, or with an unknown `output.format` or `output.lint` tool. * * @example * ```ts * assertValidConfig({ output: { path: './src/gen', format: 'auto' } }) * ``` */ export function assertValidConfig(config: Pick): void { const problem = configProblem(config.output) if (!problem) return throw new Diagnostics.Error({ code: Diagnostics.code.invalidConfig, severity: 'error', message: problem, help: INVALID_CONFIG_HELP, location: { kind: 'config' }, }) } /** * Throws `KUBB_INVALID_PLUGIN_OPTIONS`, listing the allowed values, when `value` is not one of `allowed`. * * @example * ```ts * assertPluginOption({ plugin: 'plugin-ts', option: 'syntaxType', value: options.syntaxType, allowed: ['type', 'interface'] }) * ``` */ export function assertPluginOption(options: Parameters[0]): void { coreAssertPluginOption(options) }