@moccona/apicodegen 0.1.1 → 0.1.2
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/README.md +230 -117
- package/bin/cli.cjs +12 -12
- package/npm/index.cjs +1256 -729
- package/npm/index.cjs.map +1 -1
- package/npm/index.d.cts +124 -50
- package/npm/index.d.cts.map +1 -1
- package/npm/index.d.mts +124 -50
- package/npm/index.d.mts.map +1 -1
- package/npm/index.mjs +1254 -729
- package/npm/index.mjs.map +1 -1
- package/npm/vite/index.d.mts +11 -0
- package/npm/vite/index.d.mts.map +1 -1
- package/npm/vite/index.mjs +1074 -535
- package/npm/vite/index.mjs.map +1 -1
- package/package.json +6 -3
package/npm/vite/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["logger","t","t","t"],"sources":["../../src/core/config.ts","../../src/core/errors.ts","../../src/core/logger.ts","../../src/core/base/Adaptor.ts","../../src/core/constants/keywords.ts","../../src/core/interface.ts","../../src/core/base/Base.ts","../../src/core/base/Provider.ts","../../src/core/generator/index.ts","../../src/core/client/axios.ts","../../src/core/client/fetch.ts","../../src/openapi/VersionedProvider.ts","../../src/openapi/V2.ts","../../src/openapi/V3.ts","../../src/openapi/V3_1.ts","../../src/openapi/index.ts","../../src/vite-plugin/index.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'fs-extra';\n\nimport type { Adaptors, FetchDocRequestInit } from './interface.js';\n\n/**\n * Adaptor type for HTTP client\n */\nexport type ConfigAdaptor = keyof typeof Adaptors;\n\n/**\n * Shared config interface for CLI and Vite plugin\n */\nexport interface ApicodegenConfig {\n\t/** OpenAPI spec file path or URL (required) */\n\tspec: string;\n\t/** Output file path */\n\toutput: string;\n\t/** HTTP client adaptor (fetch|axios) */\n\tadaptor?: ConfigAdaptor;\n\t/** Base URL for API endpoints */\n\tbaseURL?: string;\n\t/** Custom client import source path */\n\timportClientSource?: string;\n\t/** Enable verbose logging */\n\tverbose?: boolean;\n\t/** Run type check after generation (default: true) */\n\ttypeCheck?: boolean;\n\t/** Watch for file changes */\n\twatch?: boolean;\n\t/** Request options for fetching spec */\n\trequestOptions?: FetchDocRequestInit;\n}\n\n/**\n * Options for loading config\n */\nexport interface LoadConfigOptions {\n\t/** Explicit config file path */\n\tconfigFile?: string;\n\t/** Config file directory (defaults to cwd) */\n\tcwd?: string;\n\t/** CLI overrides */\n\tcliOptions?: Partial<ApicodegenConfig>;\n\t/** Vite plugin options (for name metadata) */\n\tname?: string;\n}\n\n/**\n * Result of config loading\n */\nexport interface ResolvedConfig extends ApicodegenConfig {\n\t/** Config file path if loaded from file */\n\tconfigFilePath?: string;\n\t/** Config name for logging */\n\tname: string;\n}\n\n/**\n * Environment variable mappings\n */\nconst ENV_MAPPINGS: Record<string, keyof ApicodegenConfig> = {\n\tAPICODEGEN_SPEC: 'spec',\n\tAPICODEGEN_OUTPUT: 'output',\n\tAPICODEGEN_BASE_URL: 'baseURL',\n\tAPICODEGEN_ADAPTOR: 'adaptor',\n\tAPICODEGEN_VERBOSE: 'verbose',\n\tAPICODEGEN_WATCH: 'watch',\n\tAPICODEGEN_TYPE_CHECK: 'typeCheck',\n};\n\n/**\n * Load config from environment variables\n */\nfunction loadFromEnv(): Partial<ApicodegenConfig> {\n\tconst config: Partial<ApicodegenConfig> = {};\n\n\tfor (const [envKey, configKey] of Object.entries(ENV_MAPPINGS)) {\n\t\tconst value = process.env[envKey];\n\t\tif (value !== undefined) {\n\t\t\t// Convert string to appropriate type\n\t\t\tswitch (configKey) {\n\t\t\t\tcase 'verbose':\n\t\t\t\tcase 'watch':\n\t\t\t\tcase 'typeCheck':\n\t\t\t\t\tconfig[configKey] = value === 'true' || value === '1';\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'adaptor':\n\t\t\t\t\tconfig[configKey] = value as ConfigAdaptor;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tconfig[configKey] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn config;\n}\n\n/**\n * Load config from a file\n */\nasync function loadFromFile(\n\tfilePath: string\n): Promise<Partial<ApicodegenConfig>> {\n\tconst ext = path.extname(filePath).toLowerCase();\n\n\ttry {\n\t\tif (ext === '.json' || ext === '.jsonc') {\n\t\t\tconst content = await fs.readFile(filePath, 'utf-8');\n\t\t\treturn JSON.parse(content);\n\t\t}\n\n\t\tif (ext === '.js' || ext === '.cjs' || ext === '.mjs') {\n\t\t\tconst mod = await import(filePath);\n\t\t\treturn mod.default || mod;\n\t\t}\n\n\t\tif (ext === '.ts') {\n\t\t\t// For .ts files, try to load as JSON first\n\t\t\tconst content = await fs.readFile(filePath, 'utf-8');\n\t\t\t// Try parsing as JSON (may work for JSON-like TS files)\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(content);\n\t\t\t} catch {\n\t\t\t\t// For actual TS config, we'd need ts-node or similar\n\t\t\t\t// For now, fall back to looking for JSON export pattern\n\t\t\t\tconst jsonMatch = content.match(/export\\s+default\\s+(\\{.+\\})/s);\n\t\t\t\tif (jsonMatch) {\n\t\t\t\t\treturn JSON.parse(jsonMatch[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Try parsing as JSON for unknown extensions\n\t\tconst content = await fs.readFile(filePath, 'utf-8');\n\t\treturn JSON.parse(content);\n\t} catch (error) {\n\t\tthrow new Error(`Failed to load config from ${filePath}: ${error}`);\n\t}\n}\n\n/**\n * Find config file in project root\n */\nasync function findConfigFile(cwd: string): Promise<string | null> {\n\tconst configFiles = [\n\t\t'apicodegen.config.json',\n\t\t'apicodegen.config.js',\n\t\t'apicodegen.config.mjs',\n\t\t'.apicodegenrc',\n\t\t'.apicodegenrc.json',\n\t\t'.apicodegenrc.js',\n\t\t'.apicodegenrc.mjs',\n\t];\n\n\tfor (const fileName of configFiles) {\n\t\tconst filePath = path.join(cwd, fileName);\n\t\tif (await fs.pathExists(filePath)) {\n\t\t\treturn filePath;\n\t\t}\n\t}\n\n\t// Also check package.json for apicodegen field\n\tconst packageJsonPath = path.join(cwd, 'package.json');\n\tif (await fs.pathExists(packageJsonPath)) {\n\t\ttry {\n\t\t\tconst pkg = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));\n\t\t\tif (pkg.apicodegen && typeof pkg.apicodegen === 'string') {\n\t\t\t\treturn path.resolve(cwd, pkg.apicodegen);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore package.json parse errors\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Merge multiple config sources with priority\n * Priority: defaults < env vars < config file < CLI args\n */\nfunction mergeConfigs(\n\tbase: ApicodegenConfig,\n\t...sources: (Partial<ApicodegenConfig> | undefined)[]\n): ApicodegenConfig {\n\tconst result = { ...base };\n\n\tfor (const source of sources) {\n\t\tif (!source) continue;\n\n\t\tfor (const [key, value] of Object.entries(source)) {\n\t\t\t// Only override if value is defined (not undefined)\n\t\t\tif (value !== undefined) {\n\t\t\t\t(result as Record<string, unknown>)[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Validate config has required fields\n */\nfunction validateConfig(\n\tconfig: Partial<ApicodegenConfig>\n): config is ApicodegenConfig {\n\tif (!config.spec) {\n\t\tthrow new Error(\n\t\t\t'Missing required field: spec (OpenAPI spec file path or URL)'\n\t\t);\n\t}\n\treturn true;\n}\n\n/**\n * Load and resolve config from multiple sources\n */\nexport async function loadConfig(\n\toptions: LoadConfigOptions = {}\n): Promise<ResolvedConfig> {\n\tconst cwd = options.cwd || process.cwd();\n\tconst cliOptions = options.cliOptions || {};\n\n\t// 1. Load from environment variables\n\tconst envConfig = loadFromEnv();\n\n\t// 2. Load from config file (if specified or found)\n\tlet fileConfig: Partial<ApicodegenConfig> = {};\n\tlet configFilePath: string | undefined;\n\n\tif (options.configFile) {\n\t\tconfigFilePath = path.resolve(cwd, options.configFile);\n\t\tfileConfig = await loadFromFile(configFilePath);\n\t} else {\n\t\tconst foundPath = await findConfigFile(cwd);\n\t\tif (foundPath) {\n\t\t\tconfigFilePath = foundPath;\n\t\t\tfileConfig = await loadFromFile(foundPath);\n\t\t}\n\t}\n\n\t// 3. Check package.json inline config\n\tconst packageJsonPath = path.join(cwd, 'package.json');\n\tlet inlineConfig: Partial<ApicodegenConfig> = {};\n\tif (await fs.pathExists(packageJsonPath)) {\n\t\ttry {\n\t\t\tconst pkg = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));\n\t\t\tif (pkg.apicodegen && typeof pkg.apicodegen === 'object') {\n\t\t\t\tinlineConfig = pkg.apicodegen as Partial<ApicodegenConfig>;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore\n\t\t}\n\t}\n\n\t// 4. Merge configs with priority\n\tconst merged = mergeConfigs(\n\t\t{ spec: '', output: './output.ts' }, // defaults\n\t\tenvConfig,\n\t\tinlineConfig,\n\t\tfileConfig,\n\t\tcliOptions\n\t);\n\n\t// 5. Validate\n\tvalidateConfig(merged);\n\n\t// 6. Add metadata\n\tconst name = options.name || merged.baseURL || merged.spec;\n\n\treturn {\n\t\t...merged,\n\t\tconfigFilePath,\n\t\tname,\n\t};\n}\n\n/**\n * Convert resolved config to provider options format\n */\nexport function toProviderOptions(config: ResolvedConfig) {\n\treturn {\n\t\tdocURL: config.spec,\n\t\toutput: config.output,\n\t\tadaptor: config.adaptor,\n\t\tbaseURL: config.baseURL,\n\t\timportClientSource: config.importClientSource,\n\t\tverbose: config.verbose,\n\t\trequestOptions: config.requestOptions,\n\t};\n}\n","/**\n * Error handling utilities for api-codegen\n */\n\n// Error codes\nexport const ErrorCodes = {\n\tSPEC_NOT_FOUND: 'E_SPEC_NOT_FOUND',\n\tSPEC_FETCH_FAILED: 'E_SPEC_FETCH_FAILED',\n\tSPEC_PARSE_FAILED: 'E_SPEC_PARSE_FAILED',\n\tOUTPUT_DIR_MISSING: 'E_OUTPUT_DIR_MISSING',\n\tCONFIG_INVALID: 'E_CONFIG_INVALID',\n\tVALIDATION_FAILED: 'E_VALIDATION_FAILED',\n\tGENERATION_FAILED: 'E_GENERATION_FAILED',\n\tTYPE_CHECK_FAILED: 'E_TYPE_CHECK_FAILED',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n\n/**\n * Error context for ApicodegenError\n */\nexport interface ApicodegenErrorContext {\n\t/** Error code */\n\tcode: ErrorCode;\n\t/** Human readable message */\n\tmessage: string;\n\t/** File/URL related to error */\n\tlocation?: string;\n\t/** Line number if applicable */\n\tline?: number;\n\t/** Column number if applicable */\n\tcolumn?: number;\n\t/** Related schema/path if applicable */\n\tpath?: string;\n\t/** Suggested fixes */\n\tsuggestions?: string[];\n\t/** Original error */\n\tcause?: Error;\n}\n\n/**\n * Custom error class for api-codegen with rich context\n */\nexport class ApicodegenError extends Error {\n\treadonly code: ErrorCode;\n\treadonly location?: string;\n\treadonly line?: number;\n\treadonly column?: number;\n\treadonly path?: string;\n\treadonly suggestions: string[];\n\treadonly cause?: Error;\n\n\tconstructor(context: ApicodegenErrorContext) {\n\t\tsuper(context.message);\n\t\tthis.name = 'ApicodegenError';\n\t\tthis.code = context.code;\n\t\tthis.location = context.location;\n\t\tthis.line = context.line;\n\t\tthis.column = context.column;\n\t\tthis.path = context.path;\n\t\tthis.suggestions = context.suggestions || [];\n\t\tthis.cause = context.cause;\n\n\t\t// Maintains proper stack trace in V8 environments\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, ApicodegenError);\n\t\t}\n\t}\n\n\t/**\n\t * Convert error to formatted string for CLI output\n\t */\n\ttoString(verbose = false): string {\n\t\tconst lines: string[] = [];\n\n\t\t// Error header with code\n\t\tlines.push(`\\x1b[1;31mError [${this.code}]\\x1b[0m ${this.message}`);\n\n\t\t// Location\n\t\tif (this.location) {\n\t\t\tlines.push(` \\x1b[36m→ Location:\\x1b[0m ${this.location}`);\n\t\t}\n\n\t\t// Path\n\t\tif (this.path) {\n\t\t\tlines.push(` \\x1b[36m→ Path:\\x1b[0m ${this.path}`);\n\t\t}\n\n\t\t// Line/column\n\t\tif (this.line !== undefined) {\n\t\t\tlet lineInfo = ` \\x1b[36m→ Line:\\x1b[0m ${this.line}`;\n\t\t\tif (this.column !== undefined) {\n\t\t\t\tlineInfo += `, Column: ${this.column}`;\n\t\t\t}\n\t\t\tlines.push(lineInfo);\n\t\t}\n\n\t\t// Suggestions\n\t\tif (this.suggestions.length > 0) {\n\t\t\tfor (const suggestion of this.suggestions) {\n\t\t\t\tlines.push(` \\x1b[32m→ Suggestion:\\x1b[0m ${suggestion}`);\n\t\t\t}\n\t\t}\n\n\t\t// Stack trace in verbose mode\n\t\tif (verbose && this.cause) {\n\t\t\tlines.push(`\\n \\x1b[90mOriginal Error:\\x1b[0m ${this.cause.message}`);\n\t\t\tif (this.stack) {\n\t\t\t\t// Skip first few lines of stack (our error header)\n\t\t\t\tconst stackLines = this.stack.split('\\n').slice(1).join('\\n');\n\t\t\t\tlines.push(`\\x1b[90m${stackLines}\\x1b[0m`);\n\t\t\t}\n\t\t}\n\n\t\treturn lines.join('\\n');\n\t}\n\n\t/**\n\t * Convert to JSON-serializable object\n\t */\n\ttoJSON(): object {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tlocation: this.location,\n\t\t\tline: this.line,\n\t\t\tcolumn: this.column,\n\t\t\tpath: this.path,\n\t\t\tsuggestions: this.suggestions,\n\t\t\tcause: this.cause?.message,\n\t\t};\n\t}\n}\n\n/**\n * ANSI color codes for terminal output\n */\nexport const Colors = {\n\treset: '\\x1b[0m',\n\tbold: '\\x1b[1m',\n\tred: '\\x1b[31m',\n\tgreen: '\\x1b[32m',\n\tyellow: '\\x1b[33m',\n\tblue: '\\x1b[34m',\n\tcyan: '\\x1b[36m',\n\tgray: '\\x1b[90m',\n\tbrightRed: '\\x1b[91m',\n\tbrightGreen: '\\x1b[92m',\n} as const;\n\n/**\n * Format error for CLI output\n */\nexport function formatError(error: unknown, verbose = false): string {\n\tif (error instanceof ApicodegenError) {\n\t\treturn error.toString(verbose);\n\t}\n\n\tif (error instanceof Error) {\n\t\treturn `${Colors.red}${Colors.bold}Error${Colors.reset}: ${error.message}${verbose && error.stack ? `\\n\\n${Colors.gray}${error.stack}${Colors.reset}` : ''}`;\n\t}\n\n\treturn `${Colors.red}${Colors.bold}Error${Colors.reset}: ${String(error)}`;\n}\n\n/**\n * Print error to console with formatting\n */\nexport function printError(\n\terror: unknown,\n\tverbose = false,\n\tstream: NodeJS.WriteStream = process.stderr\n): void {\n\tstream.write(formatError(error, verbose));\n\tstream.write('\\n');\n}\n\n/**\n * Create error with common patterns\n */\nexport const createErrors = {\n\tspecNotFound(path: string, cause?: Error): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.SPEC_NOT_FOUND,\n\t\t\tmessage: 'OpenAPI spec file not found',\n\t\t\tlocation: path,\n\t\t\tsuggestions: [\n\t\t\t\t\"Check if the file exists using 'ls -la'\",\n\t\t\t\t'Use --spec to provide the correct path',\n\t\t\t\t'For remote specs, ensure the URL is accessible',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tspecFetchFailed(\n\t\turl: string,\n\t\tstatusCode?: number,\n\t\tcause?: Error\n\t): ApicodegenError {\n\t\tconst message = statusCode\n\t\t\t? `Failed to fetch OpenAPI spec (HTTP ${statusCode})`\n\t\t\t: 'Failed to fetch OpenAPI spec from URL';\n\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.SPEC_FETCH_FAILED,\n\t\t\tmessage,\n\t\t\tlocation: url,\n\t\t\tsuggestions: [\n\t\t\t\t'Check if the URL is accessible in a browser',\n\t\t\t\t'Download the spec file locally and use the local path',\n\t\t\t\t'Verify CORS settings if fetching from a different origin',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tspecParseFailed(\n\t\tpath: string,\n\t\tline?: number,\n\t\tcolumn?: number,\n\t\tcause?: Error\n\t): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.SPEC_PARSE_FAILED,\n\t\t\tmessage: 'Failed to parse OpenAPI spec (invalid JSON or YAML)',\n\t\t\tlocation: path,\n\t\t\tline,\n\t\t\tcolumn,\n\t\t\tsuggestions: [\n\t\t\t\t'Validate JSON syntax using jsonlint.com',\n\t\t\t\t'For YAML specs, ensure proper indentation',\n\t\t\t\t'Check for trailing commas or unquoted special characters',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\toutputDirMissing(path: string, cause?: Error): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.OUTPUT_DIR_MISSING,\n\t\t\tmessage: 'Output directory does not exist',\n\t\t\tlocation: path,\n\t\t\tsuggestions: [\n\t\t\t\t'Create the directory: mkdir -p $(dirname <output>)',\n\t\t\t\t'Check if the path is correct',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tconfigInvalid(path: string, cause?: Error): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.CONFIG_INVALID,\n\t\t\tmessage: 'Invalid configuration file',\n\t\t\tlocation: path,\n\t\t\tsuggestions: [\n\t\t\t\t'Validate JSON syntax in the config file',\n\t\t\t\t'Check for required fields (spec, output)',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tvalidationFailed(\n\t\tpath: string,\n\t\tdetails: string,\n\t\tcause?: Error\n\t): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.VALIDATION_FAILED,\n\t\t\tmessage: 'OpenAPI spec validation failed',\n\t\t\tlocation: path,\n\t\t\tpath: details,\n\t\t\tsuggestions: [\n\t\t\t\t'Check OpenAPI spec structure at the specified path',\n\t\t\t\t'Ensure all required fields are present',\n\t\t\t\t'Validate using swagger.io editor',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tgenerationFailed(cause?: Error): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.GENERATION_FAILED,\n\t\t\tmessage: 'Code generation failed',\n\t\t\tsuggestions: [\n\t\t\t\t'Check for unsupported OpenAPI features',\n\t\t\t\t'Ensure spec follows OpenAPI 2.0, 3.0, or 3.1 specification',\n\t\t\t\t'Use --verbose for more details',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\ttypeCheckFailed(\n\t\tpath: string,\n\t\t_errors: string[],\n\t\tcause?: Error\n\t): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.TYPE_CHECK_FAILED,\n\t\t\tmessage: 'TypeScript type check failed',\n\t\t\tlocation: path,\n\t\t\tsuggestions: [\n\t\t\t\t'Review type errors above',\n\t\t\t\t'Check for schema inconsistencies',\n\t\t\t\t'Update generated types or fix source schema',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tmissingRequiredField(field: string, context?: string): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.VALIDATION_FAILED,\n\t\t\tmessage: `Missing required field: ${field}`,\n\t\t\tpath: context,\n\t\t\tsuggestions: [`Add the '${field}' field to your configuration`],\n\t\t});\n\t},\n};\n\n/**\n * Wrap unknown error in ApicodegenError if needed\n */\nexport function wrapError(\n\terror: unknown,\n\tcontext?: Partial<ApicodegenErrorContext>\n): ApicodegenError {\n\tif (error instanceof ApicodegenError) {\n\t\treturn error;\n\t}\n\n\tif (error instanceof Error) {\n\t\treturn new ApicodegenError({\n\t\t\tcode: context?.code || ErrorCodes.GENERATION_FAILED,\n\t\t\tmessage: context?.message || error.message,\n\t\t\tlocation: context?.location,\n\t\t\tsuggestions: context?.suggestions,\n\t\t\tcause: error,\n\t\t});\n\t}\n\n\treturn new ApicodegenError({\n\t\tcode: context?.code || ErrorCodes.GENERATION_FAILED,\n\t\tmessage: String(error),\n\t\tsuggestions: context?.suggestions,\n\t});\n}\n\n/**\n * Check if error is an ApicodegenError\n */\nexport function isApicodegenError(error: unknown): error is ApicodegenError {\n\treturn error instanceof ApicodegenError;\n}\n","const cyan = (s: string) => `\\x1b[36m${s}\\x1b[0m`;\nconst green = (s: string) => `\\x1b[32m${s}\\x1b[0m`;\nconst red = (s: string) => `\\x1b[31m${s}\\x1b[0m`;\nconst blue = (s: string) => `\\x1b[34m${s}\\x1b[0m`;\nconst yellow = (s: string) => `\\x1b[33m${s}\\x1b[0m`;\nconst magenta = (s: string) => `\\x1b[35m${s}\\x1b[0m`;\nconst gray = (s: string) => `\\x1b[90m${s}\\x1b[0m`;\nconst bold = (s: string) => `\\x1b[1m${s}\\x1b[0m`;\n\nexport const logger = {\n\tsuccess(msg: string): void {\n\t\tconsole.log(`${green('✓')} ${msg}`);\n\t},\n\n\terror(err: unknown, verbose = false): void {\n\t\tif (isApicodegenError(err)) {\n\t\t\tconsole.error(`${red('✗')} ${err.toString(verbose)}`);\n\t\t} else if (err instanceof Error) {\n\t\t\tconst msg = `Error: ${err.message}`;\n\t\t\tconsole.error(\n\t\t\t\t`${red('✗')} ${msg}${verbose && err.stack ? `\\n${gray(err.stack)}` : ''}`\n\t\t\t);\n\t\t} else {\n\t\t\tconsole.error(`${red('✗')} ${String(err)}`);\n\t\t}\n\t},\n\n\tinfo(msg: string): void {\n\t\tconsole.log(`${blue('ℹ')} ${msg}`);\n\t},\n\n\twarn(msg: string): void {\n\t\tconsole.log(`${yellow('⚠')} ${msg}`);\n\t},\n\n\tloading(msg: string): void {\n\t\tconsole.log(`${yellow('🔄')} ${msg}`);\n\t},\n\n\twatching(msg: string): void {\n\t\tconsole.log(`${magenta('⟳')} ${msg}`);\n\t},\n\n\tfileChange(filePath: string): void {\n\t\tconsole.log(`${yellow('↓')} ${filePath}`);\n\t},\n\n\tfileAdd(filePath: string): void {\n\t\tconsole.log(`${green('+')} ${filePath}`);\n\t},\n\n\tshutdown(): void {\n\t\tconsole.log(`\\n${gray('👋 Shutting down...')}`);\n\t},\n\n\tdivider(width = 50): void {\n\t\tconsole.log(`${bold(cyan('─'.repeat(width)))}`);\n\t},\n\n\theading(text: string, mode: string, width = 50): void {\n\t\tconsole.log(`${bold(cyan('─'.repeat(width)))}`);\n\t\tconsole.log(`${bold(cyan(text))}`);\n\t\tconsole.log(`${gray('Mode:')} ${mode || 'unknown'}`);\n\t\tconsole.log(`${bold(cyan('─'.repeat(width)))}`);\n\t},\n\n\titem(label: string, color: 'green' | 'red' | 'yellow' = 'green'): void {\n\t\tconst icon = color === 'green' ? '✓' : color === 'red' ? '✗' : '⚠';\n\t\tconsole.log(\n\t\t\t`${color === 'green' ? green(icon) : color === 'red' ? red(icon) : yellow(icon)} ${label}`\n\t\t);\n\t},\n\n\tsummary(stats: {\n\t\tsucceeded: number;\n\t\tfailed: number;\n\t\tendpoints: number;\n\t\tschemas: number;\n\t\tduration: number;\n\t}): void {\n\t\tconst { succeeded, failed, endpoints, schemas, duration } = stats;\n\t\tconst label = `API Code Gen - Complete (${succeeded} succeeded${\n\t\t\tfailed > 0 ? `, ${failed} failed` : ''\n\t\t}, ${endpoints} endpoints, ${schemas} schemas, ${duration}ms)`;\n\t\tif (failed === 0) {\n\t\t\tconsole.log(`${green('✓')} ${label}`);\n\t\t} else {\n\t\t\tconsole.log(`${yellow('⚠')} ${label}`);\n\t\t}\n\t},\n};\n\nimport { isApicodegenError } from './errors.js';\n","/**\n * @file Adapter abstract class definition\n * @author wp.l\n * @description Base adapter implementation for various code generation tools\n */\n\nimport type { Statement } from 'typescript';\nimport type { MediaTypeObject, ParameterObject } from '../interface.js';\n\n/**\n * Base adapter for tool\n * This abstract class serves as the foundation for implementing adapters for different code generation tools\n */\nexport abstract class Adapter {\n\t/**\n\t * @abstract The unique name/identifier for this adapter implementation\n\t */\n\tabstract readonly name: string;\n\n\t/**\n\t * @abstract The name of the field used to specify the HTTP method in API calls\n\t */\n\tabstract readonly methodFieldName: string;\n\n\t/**\n\t * @abstract The name of the field used to specify the request body in API calls\n\t */\n\tabstract readonly bodyFieldName: string;\n\n\t/**\n\t * @abstract The name of the field used to specify request headers in API calls\n\t */\n\tabstract readonly headersFieldName: string;\n\n\t/**\n\t * @abstract The name of the field used to specify query parameters in API calls\n\t */\n\tabstract readonly queryFieldName: string;\n\n\t/**\n\t * @abstract\n\t * @param {string} uri - The API endpoint URI\n\t * @param {string} method - The HTTP method (e.g., GET, POST, etc.)\n\t * @param {ParameterObject[]} parameters - An array of parameters for the API call\n\t * @param {MediaTypeObject | undefined} requestBody - The request body payload (if applicable)\n\t * @param {MediaTypeObject | undefined} response - The expected response format (if applicable)\n\t * @param {Adapter} adapter - An instance of the adapter being used\n\t * @param {boolean} useFormData - Flag indicating whether to use FormData for the request body\n\t * @param {boolean} useJSONResponse - Flag indicating whether the response should be parsed as JSON\n\t * @param {boolean} isEventStream - Flag indicating whether the response is a text/event-stream (SSE) stream; when true, the adapter must return the raw response without parsing\n\t * @returns {Statement[]} An array of TypeScript AST statements representing the generated code\n\t */\n\tabstract client(\n\t\turi: string,\n\t\tmethod: string,\n\t\tparameters: ParameterObject[],\n\t\trequestBody: MediaTypeObject | undefined,\n\t\tresponse: MediaTypeObject | undefined,\n\t\tadapter: Adapter,\n\t\tuseFormData: boolean,\n\t\tuseJSONResponse: boolean,\n\t\tisEventStream: boolean\n\t): Statement[];\n}\n","export const typescriptKeywords = new Set([\n\t'break',\n\t'case',\n\t'catch',\n\t'class',\n\t'const',\n\t'continue',\n\t'debugger',\n\t'default',\n\t'delete',\n\t'do',\n\t'else',\n\t'enum',\n\t'export',\n\t'extends',\n\t'false',\n\t'finally',\n\t'for',\n\t'function',\n\t'if',\n\t'import',\n\t'in',\n\t'instanceof',\n\t'new',\n\t'null',\n\t'return',\n\t'super',\n\t'switch',\n\t'this',\n\t'throw',\n\t'true',\n\t'try',\n\t'typeof',\n\t'var',\n\t'void',\n\t'while',\n\t'with',\n\t'as',\n\t'implements',\n\t'interface',\n\t'let',\n\t'package',\n\t'private',\n\t'protected',\n\t'public',\n\t'static',\n\t'yield',\n\t'abstract',\n\t'any',\n\t'async',\n\t'await',\n\t'constructor',\n\t'declare',\n\t'from',\n\t'get',\n\t'is',\n\t'module',\n\t'namespace',\n\t'never',\n\t'require',\n\t'set',\n\t'type',\n\t'unknown',\n\t'readonly',\n\t'of',\n\t'asserts',\n\t'infer',\n\t'keyof',\n\t'boolean',\n\t'number',\n\t'string',\n\t'symbol',\n\t'object',\n\t'undefined',\n\t'bigint',\n]);\n","/**\n * Simple represenration for JSON object\n */\nexport type JSONValue = {\n\t[K: string]:\n\t\t| string\n\t\t| number\n\t\t| boolean\n\t\t| JSONValue\n\t\t| (string | number | boolean | JSONValue)[];\n};\n\nexport enum SchemaType {\n\tschemas = 'schemas',\n\tparameters = 'parameters',\n\tresponses = 'responses',\n\trequestBodies = 'requestBodies',\n}\n\nexport enum NonArraySchemaType {\n\tobject = 'object',\n\tstring = 'string',\n\tnumber = 'number',\n\tboolean = 'boolean',\n\tinteger = 'integer',\n\tenum = 'enum',\n\tfile = 'file',\n}\n\nexport enum ArraySchemaType {\n\tarray = 'array',\n}\n\nexport enum SchemaFormatType {\n\tstring = 'string',\n\tnumber = 'number',\n\tboolean = 'boolean',\n\tfile = 'file',\n\tbinary = 'binary',\n\tblob = 'blob',\n}\n\nexport enum ParameterIn {\n\theader = 'header',\n\tbody = 'body',\n\tquery = 'query',\n\tcookie = 'cookie',\n\tpath = 'path',\n\tformData = 'formData',\n}\n\nexport interface ReferenceObject {\n\t$ref: string;\n}\n\nexport interface EnumSchemaObject {\n\tname: string;\n\tenum: (string | number)[];\n}\n\nexport interface SingleTypeSchemaObject {\n\t// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n\ttype: keyof typeof NonArraySchemaType | string;\n\tdescription?: string;\n\tallOf?: SchemaObject[];\n\tanyOf?: SchemaObject[];\n\tdeprecated?: boolean;\n\tenum?: (string | number)[];\n\tformat?: keyof typeof SchemaFormatType;\n\toneOf?: SchemaObject[];\n\tproperties?: Record<string, SchemaObject>;\n\treadonly?: boolean;\n\trequired?: string[] | boolean;\n\tref?: string;\n\tisRef?: boolean;\n}\n\nexport interface ArrayTypeSchemaObject {\n\ttype: keyof typeof ArraySchemaType;\n\titems?: SchemaObject;\n\trequired?: boolean;\n\tdescription?: string;\n\tref?: string;\n}\n\nexport type SchemaObject = SingleTypeSchemaObject | ArrayTypeSchemaObject;\n\nexport type ParameterObject = {\n\tname: string;\n\tin: keyof typeof ParameterIn;\n\tschema?: SchemaObject;\n\trequired?: boolean;\n\tdescription?: string;\n\tdeprecated?: boolean;\n\tref?: string;\n};\n\nexport enum MediaTypes {\n\tJSON = 'application/json',\n\tEVENT_STREAM = 'text/event-stream',\n\tTEXT = 'text',\n\tIMAGE = 'image',\n\tAUDIO = 'audio',\n\tVIDEO = 'video',\n}\n\nexport type MediaTypeObject = {\n\ttype: MediaTypes | keyof typeof MediaTypes;\n\tschema?: SchemaObject;\n};\n\nexport type ResponsesObject = Record<string, MediaTypeObject[]>;\n\nexport type RequestBodyObject = ResponsesObject;\n\nexport enum HttpMethods {\n\tGET = 'get',\n\tPUT = 'put',\n\tPOST = 'post',\n\tDELETE = 'delete',\n\tOPTIONS = 'options',\n\tHEAD = 'head',\n\tPATCH = 'patch',\n\tTRACE = 'trace',\n}\n\nexport type OperationObject = {\n\tmethod: string;\n\tsummary?: string;\n\tdescription?: string;\n\toperationId?: string;\n\texternalDocs?: { url: string; description?: string }[];\n\tparameters?: ParameterObject[];\n\trequestBody?: MediaTypeObject[];\n\tresponses: MediaTypeObject[];\n\tdeprecated?: boolean;\n};\n\nexport type PathObject = {\n\tref?: string;\n\tsummary?: string;\n\tdescription?: string;\n\tparameters?: ParameterObject[];\n} & Partial<Record<HttpMethods, OperationObject>>;\n\nexport type PathsObject = Record<string, OperationObject[]>;\n\nexport type FetchDocRequestInit = {\n\tmethod?: string;\n\tbody?: string | FormData;\n\theaders?: Record<string, string>;\n};\n\nexport enum Adaptors {\n\tfetch = 'fetch',\n\taxios = 'axios',\n}\n\nexport type ProviderInitOptions = {\n\tdocURL: string;\n\toutput: string;\n\tbaseURL?: string;\n\timportClientSource?: string;\n\trequestOptions?: FetchDocRequestInit;\n\tverbose?: boolean;\n\tadaptor?: keyof typeof Adaptors;\n};\n\nexport interface ProviderInitResult {\n\treadonly enums: EnumSchemaObject[];\n\treadonly schemas: Record<string, SchemaObject>;\n\treadonly parameters: Record<string, ParameterObject>;\n\treadonly responses: Record<string, ResponsesObject>;\n\treadonly requestBodies: Record<string, RequestBodyObject>;\n\treadonly apis: PathsObject;\n}\n","/**\n * @file Base class implementation\n * @author wp.l\n * @description Base utility class providing common methods for code generation and API handling\n */\n\nimport { Agent, request } from 'undici';\nimport { typescriptKeywords } from '../constants/keywords.js';\nimport type {\n\tEnumSchemaObject,\n\tFetchDocRequestInit,\n\tReferenceObject,\n\tSchemaObject,\n\tSingleTypeSchemaObject,\n} from '../interface.js';\nimport { MediaTypes } from '../interface.js';\n\n/**\n * Represents success HTTP status codes.\n * Each key is a string representation of a success HTTP status code.\n */\nexport const SuccessHttpStatusCode = {\n\t'200': '200', // OK\n\t'201': '201', // Created\n\t'202': '202', // Accepted\n\t'203': '203', // Non-Authoritative Information\n\t'204': '204', // No Content\n\t'205': '205', // Reset Content\n\t'206': '206', // Partial Content\n\t'207': '207', // Multi_Status\n\t'208': '208', // Already_Reported\n\t'226': '226', // IM Used\n};\n\n/**\n * Base abstract class providing common utility methods.\n */\nexport abstract class Base {\n\tprotected constructor() {\n\t\tif (new.target === Base) {\n\t\t\tthrow new Error('Cannot instantiate abstract class');\n\t\t}\n\t}\n\n\t/**\n\t * Converts a reference string to a meaningful name.\n\t * @param ref - The reference string to process.\n\t * @param [doc] - Optional document reference for context.\n\t * @returns - The processed name.\n\t */\n\tstatic ref2name(ref: string, doc?: any): string {\n\t\tconst paths = ref.replace(/^#/, '').split('/').filter(Boolean);\n\n\t\tif (!doc) {\n\t\t\treturn paths.slice(-1)[0];\n\t\t}\n\n\t\tlet temporary = doc as unknown;\n\t\tlet lastPath = '';\n\t\tfor (const path of paths) {\n\t\t\t// For handling path prefix with ~1\n\t\t\tconst adjustedPath = path.replaceAll('~1', '/');\n\t\t\ttemporary = (temporary as Record<string, any>)[adjustedPath];\n\t\t\tlastPath = adjustedPath;\n\t\t}\n\n\t\tif (!temporary) {\n\t\t\treturn 'unknown';\n\t\t}\n\n\t\treturn (temporary as unknown as { $ref: string }).$ref\n\t\t\t? Base.ref2name((temporary as unknown as { $ref: string }).$ref, doc)\n\t\t\t: lastPath;\n\t}\n\n\t/**\n\t * Converts an API path to a function name.\n\t * @param path - The API endpoint path.\n\t * @param [method] - The HTTP method (e.g., GET, POST).\n\t * @param [operationId] - Unique identifier for the operation.\n\t * @returns - The generated function name.\n\t */\n\tstatic pathToFnName(\n\t\tpath: string,\n\t\tmethod?: string,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_operationId: string = ''\n\t) {\n\t\tconst name = Base.normalize(Base.camelCase(Base.normalize(path)));\n\t\tconst suffix = method\n\t\t\t? Base.capitalize(Base.upperCamelCase(`using_${method}`))\n\t\t\t: '';\n\n\t\treturn name + suffix;\n\t}\n\n\t/**\n\t * Normalizes a string by replacing special characters and avoiding TypeScript keywords.\n\t * @param text - Input text to normalize.\n\t * @returns - The normalized string.\n\t */\n\tstatic normalize(text: string) {\n\t\tif (typescriptKeywords.has(text)) {\n\t\t\ttext += '_';\n\t\t}\n\t\treturn text\n\t\t\t.replace(/[/\\-_{}():\\s`,*<>$#.]/gm, '_')\n\t\t\t.replace(/^\\d./gm, '')\n\t\t\t.replaceAll('...', '');\n\t}\n\n\t/**\n\t * Capitalizes the first character of a string.\n\t * @param text - Input string.\n\t * @returns - Capitalized string.\n\t */\n\tstatic capitalize(text: string) {\n\t\ttext = text.trim();\n\t\treturn `${text.charAt(0).toUpperCase()}${text.slice(1)}`;\n\t}\n\n\t/**\n\t * Converts a string to camelCase.\n\t * @param text - Input string.\n\t * @returns - CamelCase string.\n\t */\n\tstatic camelCase(text: string) {\n\t\ttext = text.trim();\n\t\tconst parts = text.split('_').filter(Boolean);\n\t\twhile (parts[0]?.match(/^\\d/)) {\n\t\t\tparts.shift();\n\t\t}\n\t\treturn parts\n\t\t\t.map((t, index) => (index === 0 ? t : Base.capitalize(t)))\n\t\t\t.join('');\n\t}\n\n\t/**\n\t * Converts a string to UpperCamelCase.\n\t * @param text - Input string.\n\t * @returns - UpperCamelCase string.\n\t */\n\tstatic upperCamelCase(text: string) {\n\t\treturn Base.normalize(text)\n\t\t\t.replaceAll('...', '')\n\t\t\t.split('_')\n\t\t\t.filter(Boolean)\n\t\t\t.map(Base.capitalize)\n\t\t\t.join('');\n\t}\n\n\t/**\n\t * Fetches documentation from a given URL.\n\t * @param url - The URL to fetch the documentation from.\n\t * @param requestInit - Additional request parameters.\n\t * @returns - A promise resolving to the fetched documentation data.\n\t */\n\tstatic async fetchDoc<T = unknown>(\n\t\turl: string,\n\t\trequestInit: FetchDocRequestInit = {}\n\t): Promise<T> {\n\t\tconst agent = new Agent({\n\t\t\tconnect: { rejectUnauthorized: false },\n\t\t});\n\n\t\tconst { body, statusCode } = await request(url, {\n\t\t\tmethod: 'GET',\n\t\t\tdispatcher: agent,\n\t\t\t...requestInit,\n\t\t});\n\n\t\tif (statusCode >= 400) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch OpenAPI documentation from ${url}: HTTP ${statusCode}`\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\treturn body.json() as T;\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to parse JSON response from ${url}: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Determines the media type from a given media type string.\n\t * @param mediaType - The media type string to evaluate.\n\t * @returns - The matched MediaTypes or null.\n\t */\n\tstatic getMediaType(mediaType: string): MediaTypes | undefined {\n\t\tconst mediaTypeValues = Object.values(MediaTypes) as string[];\n\t\tconst found = mediaTypeValues.find((type) => mediaType.includes(type));\n\t\treturn found as MediaTypes | undefined;\n\t}\n\n\t/**\n\t * Checks if a schema is a valid enum type that isn't boolean.\n\t * @param a - The schema object to evaluate.\n\t * @returns - True if the schema is a valid non-boolean enum.\n\t */\n\tstatic isValidEnumType(a: SchemaObject) {\n\t\treturn a.type !== 'boolean' && !Base.isBooleanEnum(a);\n\t}\n\n\t/**\n\t * Checks if a schema represents a boolean enum.\n\t * @param a - The schema object to evaluate.\n\t * @returns - True if the schema is a boolean enum.\n\t */\n\tstatic isBooleanEnum(a: SchemaObject) {\n\t\treturn (\n\t\t\ta.type === 'boolean' ||\n\t\t\t!!(a as SingleTypeSchemaObject).enum?.some(\n\t\t\t\t(member) => typeof member === 'boolean'\n\t\t\t)\n\t\t);\n\t}\n\n\t/**\n\t * Checks if two enum schemas are identical.\n\t * @param a - First enum schema to compare.\n\t * @param b - Second enum schema to compare.\n\t * @returns - True if the enums are identical.\n\t */\n\tprivate static isSameEnum(a: EnumSchemaObject, b: EnumSchemaObject) {\n\t\treturn (\n\t\t\ta.enum.length === b.enum.length &&\n\t\t\ta.enum.sort().every((v, index) => v === b.enum.sort()[index])\n\t\t);\n\t}\n\n\t/**\n\t * Filters out duplicate enum schemas from an array.\n\t * @param enums - Array of enum schemas to process.\n\t * @returns - Array of unique enum schemas.\n\t */\n\tstatic uniqueEnums(enums: EnumSchemaObject[]): EnumSchemaObject[] {\n\t\tconst enumMap = new Map<string, Set<string | number>>();\n\n\t\tfor (const e of enums) {\n\t\t\tconst existing = enumMap.get(e.name);\n\t\t\tif (existing) {\n\t\t\t\t// Merge enum values with the same name\n\t\t\t\tfor (const value of e.enum) {\n\t\t\t\t\texisting.add(value);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tenumMap.set(e.name, new Set(e.enum));\n\t\t\t}\n\t\t}\n\n\t\t// Convert back to array\n\t\treturn Array.from(enumMap.entries()).map(([name, values]) => ({\n\t\t\tname,\n\t\t\tenum: Array.from(values),\n\t\t}));\n\t}\n\n\t/**\n\t * Finds the first occurrence of a matching enum schema in an array.\n\t * @param a - The enum schema to find.\n\t * @param enums - Array of enum schemas to search.\n\t * @returns - The found schema or undefined.\n\t */\n\tstatic findSameSchema(a: EnumSchemaObject, enums: EnumSchemaObject[]) {\n\t\treturn enums.find((b) => Base.isSameEnum(b, a));\n\t}\n\n\t/**\n\t * Checks if an object is a reference object.\n\t * @param schema - The object to check.\n\t * @returns - True if the object is a reference.\n\t */\n\n\tstatic isRef(schema: unknown): schema is ReferenceObject {\n\t\treturn (\n\t\t\ttypeof schema === 'object' &&\n\t\t\tschema !== null &&\n\t\t\t'$ref' in schema &&\n\t\t\ttypeof (schema as Record<string, unknown>).$ref === 'string'\n\t\t);\n\t}\n}\n","/**\n * @file Base class implementation\n * @author wp.l\n * @description This file defines the `Provider` abstract class, which serves as a base for providers responsible for parsing and processing API documentation.\n */\n\nimport type {\n\tEnumSchemaObject,\n\tFetchDocRequestInit,\n\tOperationObject,\n\tParameterObject,\n\tProviderInitOptions,\n\tProviderInitResult,\n\tRequestBodyObject,\n\tResponsesObject,\n\tSchemaObject,\n} from '../interface.js';\n\n/**\n * Abstract Provider Class.\n *\n * The Provider class is designed to be extended by specific implementations (e.g., OpenAPI 2 provider, OpenAPI 3 provider).\n * It handles the initialization of the provider and the parsing of documentation into structured data.\n *\n * @example\n *\n * ```ts\n * /// Example of how this class might be used by a subclass:\n * class OpenAPIProvider extends Provider {\n * /// Implement the parse method to handle OpenAPI-specific documentation parsing.\n * parse(doc: unknown): ProviderInitResult {\n * /// Implementation details...\n * }\n * }\n *\n * /// Initializing a provider with configuration and documentation data:\n * const initOptions: ProviderInitOptions = {\n * docURL: \"https://example.com/api/swagger.json\",\n * baseURL: \"https://api.example.com\",\n * output: \"./generated\",\n * requestOptions: {\n * headers: { \"Content-Type\": \"application/json\" },\n * },\n * importClientSource: \"generated/client\",\n * };\n *\n * const docData = fetchSwaggerDoc();\n * const provider = new OpenAPIProvider(initOptions, docData);\n * ```\n */\nexport abstract class Provider\n\timplements ProviderInitResult, ProviderInitOptions\n{\n\t/** collection of enum schemas */\n\treadonly enums: EnumSchemaObject[] = [];\n\t/** collection of schemas indexed by name */\n\treadonly schemas: Record<string, SchemaObject> = {};\n\t/** collection of parameters indexed by name */\n\treadonly parameters: Record<string, ParameterObject> = {};\n\t/** collection of API responses indexed by name */\n\treadonly responses: Record<string, ResponsesObject> = {};\n\t/** collection of request bodies indexed by name */\n\treadonly requestBodies: Record<string, RequestBodyObject> = {};\n\t/** collection of API endpoints (operations) indexed by path */\n\treadonly apis: Record<string, OperationObject[]> = {};\n\n\t/** URL for fetching API documentation */\n\treadonly docURL: string;\n\t/** base URL for API endpoints */\n\treadonly baseURL: string;\n\t/** output directory for generated code */\n\treadonly output: string;\n\t/** request options for API documentation fetch */\n\treadonly requestOptions: FetchDocRequestInit;\n\t/** source path for imported client */\n\treadonly importClientSource: string;\n\n\t/**\n\t * Provider Constructor.\n\t * @param {ProviderInitOptions} initOptions - Initial configuration for the provider.\n\t * @param {unknown} doc - Raw API documentation data to be parsed.\n\t */\n\tconstructor(initOptions: ProviderInitOptions, doc: unknown) {\n\t\tthis.docURL = initOptions.docURL;\n\t\tthis.baseURL = initOptions.baseURL ?? '';\n\t\tthis.output = initOptions.output ?? '.';\n\t\tthis.requestOptions = initOptions.requestOptions ?? {};\n\t\tthis.importClientSource = initOptions.importClientSource ?? '';\n\n\t\tconst { enums, schemas, requestBodies, responses, parameters, apis } =\n\t\t\tthis.parse(doc);\n\n\t\tthis.enums = enums;\n\t\tthis.schemas = schemas;\n\t\tthis.responses = responses;\n\t\tthis.parameters = parameters;\n\t\tthis.requestBodies = requestBodies;\n\t\tthis.apis = apis;\n\t}\n\n\t/**\n\t * Abstract Parse Method.\n\t * @abstract\n\t * @param {unknown} doc - Raw API documentation data.\n\t * @returns {ProviderInitResult} - Parsed documentation data.\n\t *\n\t * This method must be implemented by subclasses to parse the raw documentation into structured data.\n\t */\n\tabstract parse(doc: unknown): ProviderInitResult;\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */\n/* eslint-disable no-case-declarations */\n\nimport { writeFile } from 'node:fs/promises';\nimport { format } from 'prettier';\nimport type {\n\tBindingElement,\n\tBlock,\n\tNode,\n\tParameterDeclaration,\n\tPropertySignature,\n\tStatement,\n\tTypeNode,\n} from 'typescript';\nimport {\n\taddSyntheticLeadingComment,\n\tcreatePrinter,\n\tNodeFlags,\n\tSyntaxKind,\n\tfactory as t,\n} from 'typescript';\nimport type { Adapter } from '../base/Adaptor.js';\nimport { Base } from '../base/Base.js';\nimport { ApicodegenError, ErrorCodes } from '../errors.js';\nimport type {\n\tArrayTypeSchemaObject,\n\tMediaTypeObject,\n\tParameterObject,\n\tProviderInitOptions,\n\tProviderInitResult,\n\tSchemaObject,\n\tSingleTypeSchemaObject,\n} from '../interface.js';\nimport {\n\tArraySchemaType,\n\tMediaTypes,\n\tNonArraySchemaType,\n\tParameterIn,\n\tSchemaFormatType,\n} from '../interface.js';\n\n/**\n * Represents a comment object with optional tag and message.\n */\nexport type CommentObject = {\n\ttag?: 'deprecated' | 'param' | 'returns';\n\tcomment: string;\n\tparamName?: string;\n\ttype?: string;\n};\n\n/**\n * Array of comment objects to be added to the code.\n */\nexport type Comments = CommentObject[];\n\nexport class Generator {\n\t/**\n\t * Converts an array of TypeScript statements into a formatted string of code.\n\t *\n\t * @param statements - The array of TypeScript statement nodes.\n\t * @returns Formatted code as a string.\n\t * @throws {Error} If no valid statements are provided.\n\t */\n\tstatic toCode(statements: Statement[]): string {\n\t\tif (statements.length === 0) {\n\t\t\treturn '// No api declaration found.';\n\t\t}\n\n\t\tconst sourceFile = t.createSourceFile(\n\t\t\tstatements,\n\t\t\tt.createToken(SyntaxKind.EndOfFileToken),\n\t\t\tNodeFlags.None\n\t\t);\n\n\t\treturn createPrinter().printFile(sourceFile);\n\t}\n\n\tstatic async write(code: string, filepath: string) {\n\t\tconst { mkdir } = await import('node:fs/promises');\n\t\tconst { dirname } = await import('node:path');\n\t\ttry {\n\t\t\tawait mkdir(dirname(filepath), { recursive: true });\n\t\t\tawait writeFile(filepath, code);\n\t\t} catch (error) {\n\t\t\tthrow new ApicodegenError({\n\t\t\t\tcode: ErrorCodes.OUTPUT_DIR_MISSING,\n\t\t\t\tmessage: 'Failed to write generated code to output file',\n\t\t\t\tlocation: filepath,\n\t\t\t\tcause: error instanceof Error ? error : new Error(String(error)),\n\t\t\t\tsuggestions: [\n\t\t\t\t\t'Verify the output directory path is writable',\n\t\t\t\t\t'Check that the parent directory exists or can be created',\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Converts a path string with parameters into a TypeScript template expression.\n\t * Handles query parameters and path placeholders.\n\t *\n\t * @param path - The base path string containing placeholders.\n\t * @param parameters - Array of parameter objects defining the parameters.\n\t * @param basePath - Optional base path to prepend (default: \"\").\n\t * @returns A TypeScript template expressi\n\t */\n\tstatic toUrlTemplate(\n\t\tpath: string,\n\t\tparameters: ParameterObject[],\n\t\tbasePath = ''\n\t) {\n\t\t// Extract query parameters\n\t\tconst queryParameters = parameters.filter(\n\t\t\t(p) => p.in === ParameterIn.query\n\t\t);\n\n\t\tif (queryParameters.length > 0) {\n\t\t\tconst queryString = queryParameters\n\t\t\t\t.map(\n\t\t\t\t\t(qp, index) =>\n\t\t\t\t\t\t`${index === 0 ? '?' : '&'}${encodeURIComponent(qp.name)}={${Base.normalize(qp.name)}}`\n\t\t\t\t)\n\t\t\t\t.join('');\n\t\t\tpath += queryString;\n\t\t}\n\n\t\t// Split the path into segments\n\t\tconst pathSegments = path.replaceAll('{', '${').split('$').filter(Boolean);\n\n\t\t// If path segments only got one item, it means there are no parameters in path. So just return the path literal.\n\t\tif (pathSegments.length === 1) {\n\t\t\treturn t.createNoSubstitutionTemplateLiteral(basePath + path);\n\t\t}\n\n\t\treturn t.createTemplateExpression(\n\t\t\tt.createTemplateHead(basePath + pathSegments[0]),\n\t\t\tpathSegments.slice(1).map((segment, index) => {\n\t\t\t\tconst match = /^{(.+)}(.+)?/gm.exec(segment);\n\t\t\t\tconst isLastSegment = index === pathSegments.length - 2;\n\n\t\t\t\tif (!match) {\n\t\t\t\t\tthrow new Error(`Invalid path segment: ${segment}`);\n\t\t\t\t}\n\n\t\t\t\treturn t.createTemplateSpan(\n\t\t\t\t\tt.createIdentifier(Base.normalize(match[1])),\n\t\t\t\t\t!isLastSegment\n\t\t\t\t\t\t? t.createTemplateMiddle(match[2])\n\t\t\t\t\t\t: t.createTemplateTail(match[2] || '')\n\t\t\t\t);\n\t\t\t})\n\t\t);\n\t}\n\n\t/**\n\t * Adds synthetic comments to a TypeScript AST node.\n\t *\n\t * @param node - The target AST node.\n\t * @param comments - Array of comment objects to add.\n\t */\n\tstatic addComments(node: Node, comments: Comments) {\n\t\tif (!Array.isArray(comments) || comments.filter(Boolean).length === 0)\n\t\t\treturn;\n\n\t\tconst formatComment = (comment: CommentObject): string => {\n\t\t\tif (comment.tag === 'returns') {\n\t\t\t\treturn `* @returns {${comment.type}} ${comment.comment ?? ''}`;\n\t\t\t}\n\t\t\tif (comment.tag === 'param') {\n\t\t\t\treturn comment.comment\n\t\t\t\t\t? `* @param ${comment.paramName} - ${comment.comment}`\n\t\t\t\t\t: `* @param ${comment.paramName}`;\n\t\t\t}\n\t\t\tif (comment.tag) {\n\t\t\t\treturn `* @${comment.tag} ${comment.comment ?? ''}`;\n\t\t\t}\n\t\t\treturn `* ${comment.comment}`;\n\t\t};\n\n\t\tconst formattedComments =\n\t\t\tcomments.map(formatComment).join('\\n').trim() + '\\n';\n\n\t\taddSyntheticLeadingComment(\n\t\t\tnode,\n\t\t\tSyntaxKind.MultiLineCommentTrivia,\n\t\t\tformattedComments,\n\t\t\ttrue\n\t\t);\n\t}\n\n\t/**\n\t * Checks if a schema represents a binary type.\n\t *\n\t * @param schema - The schema object to check.\n\t * @returns true if the schema is a binary type, false otherwise.\n\t */\n\tstatic isBinarySchema(schema: SchemaObject): boolean {\n\t\tif (schema.type === 'array') {\n\t\t\tconst arraySchema = schema as ArrayTypeSchemaObject;\n\t\t\treturn Generator.isBinarySchema(arraySchema.items!);\n\t\t}\n\n\t\tconst nonArraySchema = schema as SingleTypeSchemaObject;\n\t\treturn (\n\t\t\tnonArraySchema.format === SchemaFormatType.blob ||\n\t\t\tnonArraySchema.format === SchemaFormatType.binary ||\n\t\t\tnonArraySchema.type === SchemaFormatType.file\n\t\t);\n\t}\n\n\tstatic schemaToTypeString(schema: SchemaObject): string {\n\t\tif (schema.type === 'array') {\n\t\t\tconst arraySchema = schema as ArrayTypeSchemaObject;\n\t\t\treturn arraySchema.items\n\t\t\t\t? `${Generator.schemaToTypeString(arraySchema.items)}[]`\n\t\t\t\t: 'unknown';\n\t\t}\n\t\tconst singleSchema = schema as SingleTypeSchemaObject;\n\t\tif (schema.type === 'string') return 'string';\n\t\tif (schema.type === 'number' || schema.type === 'integer') return 'number';\n\t\tif (schema.type === 'boolean') return 'boolean';\n\t\tif (\n\t\t\tschema.type === 'object' ||\n\t\t\t(schema as SingleTypeSchemaObject).properties\n\t\t)\n\t\t\treturn 'object';\n\t\tif (singleSchema.format === 'binary' || singleSchema.type === 'file')\n\t\t\treturn 'Blob';\n\t\tif (singleSchema.format === 'blob') return 'Blob';\n\t\tif (singleSchema.ref) return singleSchema.ref;\n\t\treturn 'unknown';\n\t}\n\n\tstatic generateParamTags(\n\t\tparameters: ParameterObject[],\n\t\trequestBody?: MediaTypeObject\n\t): CommentObject[] {\n\t\tconst tags: CommentObject[] = [];\n\n\t\tfor (const p of parameters) {\n\t\t\tconst paramName = Base.normalize(p.name);\n\t\t\tlet paramType = 'unknown';\n\n\t\t\tif (p.schema) {\n\t\t\t\tparamType = Generator.schemaToTypeString(p.schema);\n\t\t\t}\n\n\t\t\tconst isOptional = p.required === false;\n\t\t\ttags.push({\n\t\t\t\ttag: 'param',\n\t\t\t\tparamName: paramName,\n\t\t\t\ttype: `${paramType}${isOptional ? ' | undefined' : ''}`,\n\t\t\t\tcomment: p.description ?? '',\n\t\t\t});\n\t\t}\n\n\t\tif (requestBody?.schema && 'properties' in requestBody.schema) {\n\t\t\tconst properties = requestBody.schema.properties as Record<\n\t\t\t\tstring,\n\t\t\t\tSchemaObject\n\t\t\t>;\n\t\t\tconst required = requestBody.schema.required;\n\t\t\tconst requiredArray = Array.isArray(required) ? required : [];\n\t\t\tfor (const [key, schema] of Object.entries(properties ?? {})) {\n\t\t\t\tconst paramName = `req.${key}`;\n\t\t\t\tconst paramType = Generator.schemaToTypeString(schema);\n\t\t\t\tconst isOptional = !requiredArray.includes(key);\n\t\t\t\ttags.push({\n\t\t\t\t\ttag: 'param',\n\t\t\t\t\tparamName: paramName,\n\t\t\t\t\ttype: `${paramType}${isOptional ? ' | undefined' : ''}`,\n\t\t\t\t\tcomment: schema.description ?? '',\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn tags;\n\t}\n\n\tstatic toRequestBodyTypeNode(schema: SchemaObject) {\n\t\treturn t.createParameterDeclaration(\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tt.createIdentifier('req'),\n\t\t\tundefined,\n\t\t\tGenerator.toTypeNode(schema)\n\t\t);\n\t}\n\n\tstatic toTypeNode(schema: SchemaObject): TypeNode {\n\t\tconst { type, ref } = schema;\n\n\t\tif (ref) {\n\t\t\tconst identify = Base.ref2name(ref);\n\t\t\treturn t.createTypeReferenceNode(\n\t\t\t\tt.createIdentifier(\n\t\t\t\t\tidentify === 'unknown' ? identify : Base.upperCamelCase(identify)\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tswitch (type) {\n\t\t\tcase ArraySchemaType.array: {\n\t\t\t\tconst { items } = schema as ArrayTypeSchemaObject;\n\t\t\t\treturn t.createArrayTypeNode(Generator.toTypeNode(items!));\n\t\t\t}\n\t\t\tcase NonArraySchemaType.object: {\n\t\t\t\tconst propsCount = Object.keys(schema.properties ?? {}).length;\n\t\t\t\tif (!schema.properties || propsCount === 0) {\n\t\t\t\t\t// Record<string, unknown>\n\t\t\t\t\treturn t.createTypeReferenceNode(t.createIdentifier('Record'), [\n\t\t\t\t\t\tt.createToken(SyntaxKind.StringKeyword),\n\t\t\t\t\t\tt.createToken(SyntaxKind.UnknownKeyword),\n\t\t\t\t\t]);\n\t\t\t\t}\n\n\t\t\t\tconst props = Object.keys(schema.properties);\n\n\t\t\t\treturn t.createTypeLiteralNode(\n\t\t\t\t\tprops.map((propKey) => {\n\t\t\t\t\t\tconst propSchema = schema.properties![propKey];\n\t\t\t\t\t\treturn t.createPropertySignature(\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tt.createStringLiteral(propKey),\n\t\t\t\t\t\t\t// When field is required, a refrence or binary value, don't add question mark.\n\t\t\t\t\t\t\tschema.required || schema.ref || Generator.isBinarySchema(schema)\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: t.createToken(SyntaxKind.QuestionToken),\n\t\t\t\t\t\t\tGenerator.toTypeNode(propSchema)\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase NonArraySchemaType.integer:\n\t\t\tcase NonArraySchemaType.number:\n\t\t\t\tif (schema.enum) {\n\t\t\t\t\treturn t.createUnionTypeNode(\n\t\t\t\t\t\tschema.enum.map((e) =>\n\t\t\t\t\t\t\tt.createLiteralTypeNode(t.createNumericLiteral(e))\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn t.createToken(SyntaxKind.NumberKeyword);\n\t\t\t// case NonArraySchemaType.string:\n\t\t\tcase NonArraySchemaType.boolean:\n\t\t\t\treturn t.createToken(SyntaxKind.BooleanKeyword);\n\t\t\tcase NonArraySchemaType.file:\n\t\t\t\treturn t.createTypeReferenceNode(t.createIdentifier('Blob'));\n\t\t\tdefault: {\n\t\t\t\tconst {\n\t\t\t\t\tformat,\n\t\t\t\t\toneOf,\n\t\t\t\t\tallOf,\n\t\t\t\t\tanyOf,\n\t\t\t\t\ttype,\n\t\t\t\t\tenum: enum_,\n\t\t\t\t} = schema as SingleTypeSchemaObject;\n\n\t\t\t\tswitch (format) {\n\t\t\t\t\tcase SchemaFormatType.number:\n\t\t\t\t\t\treturn t.createToken(SyntaxKind.NumberKeyword);\n\t\t\t\t\tcase SchemaFormatType.string:\n\t\t\t\t\t\treturn t.createToken(SyntaxKind.StringKeyword);\n\t\t\t\t\tcase SchemaFormatType.boolean:\n\t\t\t\t\t\treturn t.createToken(SyntaxKind.BooleanKeyword);\n\t\t\t\t\tcase SchemaFormatType.blob:\n\t\t\t\t\tcase SchemaFormatType.binary:\n\t\t\t\t\t\treturn t.createTypeReferenceNode(t.createIdentifier('Blob'));\n\t\t\t\t\tdefault:\n\t\t\t\t}\n\n\t\t\t\tif (enum_) {\n\t\t\t\t\treturn t.createUnionTypeNode(\n\t\t\t\t\t\tenum_.map((e) =>\n\t\t\t\t\t\t\tt.createLiteralTypeNode(t.createStringLiteral(e as string))\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (type === NonArraySchemaType.string) {\n\t\t\t\t\treturn t.createToken(SyntaxKind.StringKeyword);\n\t\t\t\t}\n\n\t\t\t\tif (oneOf) {\n\t\t\t\t\treturn t.createUnionTypeNode(\n\t\t\t\t\t\toneOf.map((schema) => Generator.toTypeNode(schema))\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (anyOf) {\n\t\t\t\t\treturn t.createUnionTypeNode(\n\t\t\t\t\t\tanyOf.map((schema) => Generator.toTypeNode(schema))\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (allOf) {\n\t\t\t\t\treturn t.createIntersectionTypeNode(\n\t\t\t\t\t\tallOf.map((schema) => Generator.toTypeNode(schema))\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (type && typeof type === 'string') {\n\t\t\t\t\treturn t.createTypeReferenceNode(\n\t\t\t\t\t\ttype !== 'unknown' && type !== 'null'\n\t\t\t\t\t\t\t? t.createIdentifier(Base.upperCamelCase(type))\n\t\t\t\t\t\t\t: type\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn t.createToken(SyntaxKind.UnknownKeyword);\n\t}\n\n\tstatic toDeclarationNodes(\n\t\tparameters: ParameterObject[]\n\t): ParameterDeclaration[] {\n\t\tconst objectElements: BindingElement[] = [];\n\t\tconst typeObjectElements: PropertySignature[] = [];\n\t\tconst refParameters: ParameterDeclaration[] = [];\n\n\t\tfor (const parameter of parameters) {\n\t\t\tif (parameter.ref) {\n\t\t\t\t// Handle reference parameters as standalone parameters\n\t\t\t\tconst refName = Base.ref2name(parameter.ref);\n\t\t\t\trefParameters.push(\n\t\t\t\t\tt.createParameterDeclaration(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createIdentifier(Base.normalize(refName)),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createTypeReferenceNode(\n\t\t\t\t\t\t\tt.createIdentifier(Base.upperCamelCase(Base.normalize(refName)))\n\t\t\t\t\t\t),\n\t\t\t\t\t\tundefined\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst { name, schema, required } = parameter;\n\t\t\t\tobjectElements.push(\n\t\t\t\t\tt.createBindingElement(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createIdentifier(Base.normalize(name))\n\t\t\t\t\t)\n\t\t\t\t);\n\n\t\t\t\ttypeObjectElements.push(\n\t\t\t\t\tt.createPropertySignature(\n\t\t\t\t\t\t[],\n\t\t\t\t\t\tt.createIdentifier(Base.normalize(name)),\n\t\t\t\t\t\trequired ? undefined : t.createToken(SyntaxKind.QuestionToken),\n\t\t\t\t\t\t!schema\n\t\t\t\t\t\t\t? t.createToken(SyntaxKind.UnknownKeyword)\n\t\t\t\t\t\t\t: Generator.toTypeNode(schema)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Build object destructuring parameter for non-ref parameters\n\t\tif (objectElements.length > 0) {\n\t\t\tconst objectParam = t.createParameterDeclaration(\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tt.createObjectBindingPattern(objectElements),\n\t\t\t\tundefined,\n\t\t\t\tt.createTypeLiteralNode(typeObjectElements),\n\t\t\t\tundefined\n\t\t\t);\n\t\t\treturn [objectParam, ...refParameters];\n\t\t}\n\n\t\treturn refParameters;\n\t}\n\n\tstatic toFormDataStatement(\n\t\tparameters: ParameterObject[],\n\t\trequestBody?: SchemaObject\n\t): Statement[] {\n\t\tconst statements: Statement[] = [];\n\t\tconst fdDeclaration = t.createVariableStatement(\n\t\t\tundefined,\n\t\t\tt.createVariableDeclarationList(\n\t\t\t\t[\n\t\t\t\t\tt.createVariableDeclaration(\n\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createNewExpression(t.createIdentifier('FormData'), undefined, [])\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tNodeFlags.Const\n\t\t\t)\n\t\t);\n\n\t\tstatements.push(fdDeclaration);\n\n\t\tparameters.forEach((parameter) => {\n\t\t\tstatements.push(\n\t\t\t\tt.createExpressionStatement(\n\t\t\t\t\tt.createBinaryExpression(\n\t\t\t\t\t\tt.createIdentifier(parameter.name),\n\t\t\t\t\t\tt.createToken(SyntaxKind.AmpersandAmpersandToken),\n\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tt.createStringLiteral(parameter.name),\n\t\t\t\t\t\t\t\tt.createIdentifier(parameter.name),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t});\n\n\t\tif (\n\t\t\trequestBody &&\n\t\t\trequestBody.type === 'object' &&\n\t\t\trequestBody.properties &&\n\t\t\tObject.keys(requestBody.properties).length !== 0\n\t\t) {\n\t\t\tObject.keys(requestBody.properties).forEach((key) => {\n\t\t\t\tconst schemaByKey = requestBody.properties![key];\n\t\t\t\tif (\n\t\t\t\t\tschemaByKey.type === ArraySchemaType.array &&\n\t\t\t\t\tGenerator.isBinarySchema(schemaByKey)\n\t\t\t\t) {\n\t\t\t\t\tstatements.push(\n\t\t\t\t\t\tt.createForOfStatement(\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tt.createVariableDeclarationList(\n\t\t\t\t\t\t\t\t[t.createVariableDeclaration('file')],\n\t\t\t\t\t\t\t\tNodeFlags.Const\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tt.createBlock([\n\t\t\t\t\t\t\t\tt.createExpressionStatement(\n\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key),\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('file'),\n\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\tt.createAsExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('file'),\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createTypeReferenceNode(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('File'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('name')\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tif (schemaByKey.required) {\n\t\t\t\t\t\tstatements.push(\n\t\t\t\t\t\t\tt.createExpressionStatement(\n\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key),\n\t\t\t\t\t\t\t\t\t\tschemaByKey.type === 'string' ||\n\t\t\t\t\t\t\t\t\t\tGenerator.isBinarySchema(schemaByKey as SchemaObject) ||\n\t\t\t\t\t\t\t\t\t\t(schemaByKey as SingleTypeSchemaObject).isRef\n\t\t\t\t\t\t\t\t\t\t\t? t.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t: schemaByKey.type === 'array' ||\n\t\t\t\t\t\t\t\t\t\t\t\t\tschemaByKey.type === 'object'\n\t\t\t\t\t\t\t\t\t\t\t\t? t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('JSON'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('stringify')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t: t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('String'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstatements.push(\n\t\t\t\t\t\t\tt.createExpressionStatement(\n\t\t\t\t\t\t\t\tt.createBinaryExpression(\n\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tt.createToken(SyntaxKind.AmpersandAmpersandToken),\n\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key),\n\t\t\t\t\t\t\t\t\t\t\tschemaByKey.type === 'string' ||\n\t\t\t\t\t\t\t\t\t\t\tGenerator.isBinarySchema(schemaByKey as SchemaObject) ||\n\t\t\t\t\t\t\t\t\t\t\t(schemaByKey as SingleTypeSchemaObject).isRef\n\t\t\t\t\t\t\t\t\t\t\t\t? t.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t: schemaByKey.type === 'array' ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tschemaByKey.type === 'object'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('JSON'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('stringify')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t: t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('String'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn statements;\n\t}\n\n\tstatic bodyBlock(\n\t\turi: string,\n\t\tmethod: string,\n\t\tparameters: ParameterObject[],\n\t\trequestBody: MediaTypeObject | undefined,\n\t\tresponse: MediaTypeObject | undefined,\n\t\tadapter: Adapter\n\t): Block {\n\t\tconst isFormDataRequest =\n\t\t\trequestBody &&\n\t\t\t['multipart/form-data', 'application/x-www-form-urlencoded'].includes(\n\t\t\t\trequestBody.type\n\t\t\t);\n\n\t\tconst shouldParseResponseToJSON = 'application/json' === response?.type;\n\t\tconst isEventStream = response?.type === 'text/event-stream';\n\n\t\t// Ignore one and only blob parameter.\n\t\tconst isRequestBodyBinary =\n\t\t\trequestBody?.schema &&\n\t\t\trequestBody.schema.type === ArraySchemaType.array &&\n\t\t\tGenerator.isBinarySchema(requestBody.schema);\n\n\t\tconst parametersShouldPutInFormData = parameters.filter(\n\t\t\t(p) =>\n\t\t\t\tp.in === ParameterIn.formData ||\n\t\t\t\t(p.schema && Generator.isBinarySchema(p.schema))\n\t\t);\n\n\t\tconst parametersShouldNotPutInFormData = parameters.filter(\n\t\t\t(p) => !parametersShouldPutInFormData.includes(p)\n\t\t);\n\n\t\tconst isRequestBodyContainsBinary =\n\t\t\trequestBody?.schema &&\n\t\t\t'properties' in requestBody.schema &&\n\t\t\tObject.values(requestBody.schema?.properties ?? {}).some((p) =>\n\t\t\t\tGenerator.isBinarySchema(p)\n\t\t\t);\n\n\t\tconst hasBinaryInParameters = parameters.some(\n\t\t\t(p) => p?.schema && Generator.isBinarySchema(p.schema)\n\t\t);\n\n\t\tconst shouldPutParametersOrBodyInFormData =\n\t\t\t!!isFormDataRequest &&\n\t\t\t(isRequestBodyBinary ||\n\t\t\t\thasBinaryInParameters ||\n\t\t\t\tisRequestBodyContainsBinary ||\n\t\t\t\tparametersShouldPutInFormData.length > 0);\n\n\t\treturn t.createBlock([\n\t\t\t...(shouldPutParametersOrBodyInFormData\n\t\t\t\t? Generator.toFormDataStatement(\n\t\t\t\t\t\tparametersShouldPutInFormData,\n\t\t\t\t\t\trequestBody?.schema\n\t\t\t\t\t)\n\t\t\t\t: []),\n\t\t\t...adapter.client(\n\t\t\t\turi,\n\t\t\t\tmethod,\n\t\t\t\tparametersShouldNotPutInFormData,\n\t\t\t\trequestBody,\n\t\t\t\tresponse,\n\t\t\t\tadapter,\n\t\t\t\tshouldPutParametersOrBodyInFormData,\n\t\t\t\tshouldParseResponseToJSON,\n\t\t\t\tisEventStream\n\t\t\t),\n\t\t]);\n\t}\n\n\tstatic schemaToStatemets(\n\t\tparsedDoc: ProviderInitResult,\n\t\tadaptor: Adapter,\n\t\toptions: Omit<ProviderInitOptions, 'docURL' | 'output' | 'requestOptions'>\n\t): Statement[] {\n\t\tconst statements = [] as Statement[];\n\t\tconst { apis, schemas = {}, enums } = parsedDoc;\n\n\t\tconst enumNames: string[] = [];\n\n\t\tfor (const enumObject of enums) {\n\t\t\tenumNames.push(Base.upperCamelCase(enumObject.name));\n\t\t\tstatements.push(\n\t\t\t\tt.createEnumDeclaration(\n\t\t\t\t\t[t.createToken(SyntaxKind.ExportKeyword)],\n\t\t\t\t\tt.createIdentifier(Base.upperCamelCase(enumObject.name)),\n\t\t\t\t\tenumObject.enum.map((member) => {\n\t\t\t\t\t\treturn t.createEnumMember(\n\t\t\t\t\t\t\tt.createStringLiteral(\n\t\t\t\t\t\t\t\ttypeof member === 'string' ? member : `${member}_`\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttypeof member === 'string'\n\t\t\t\t\t\t\t\t? t.createStringLiteral(member)\n\t\t\t\t\t\t\t\t: t.createNumericLiteral(member)\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tfor (const schemaKey in schemas) {\n\t\t\tif (\n\t\t\t\tObject.hasOwn(schemas, schemaKey) &&\n\t\t\t\t!enumNames.includes(Base.upperCamelCase(schemaKey))\n\t\t\t) {\n\t\t\t\tconst schema = schemas[schemaKey];\n\t\t\t\tstatements.push(\n\t\t\t\t\tt.createTypeAliasDeclaration(\n\t\t\t\t\t\t[t.createModifier(SyntaxKind.ExportKeyword)],\n\t\t\t\t\t\tt.createIdentifier(Base.upperCamelCase(schemaKey)),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tGenerator.toTypeNode(schema)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tfor (const uri in apis) {\n\t\t\tconst operations = apis[uri];\n\t\t\tfor (const operation of operations) {\n\t\t\t\tconst {\n\t\t\t\t\tmethod,\n\t\t\t\t\toperationId,\n\t\t\t\t\trequestBody = [],\n\t\t\t\t\tresponses = [],\n\t\t\t\t\tsummary,\n\t\t\t\t\tdeprecated,\n\t\t\t\t\tdescription,\n\t\t\t\t} = operation;\n\n\t\t\t\tlet { parameters = [] } = operation;\n\n\t\t\t\tparameters = parameters.filter((p) => p.in !== 'cookie');\n\n\t\t\t\t// Add a default request, with no schema.\n\t\t\t\tif (requestBody.length === 0) {\n\t\t\t\t\trequestBody.push({ type: MediaTypes.JSON });\n\t\t\t\t}\n\n\t\t\t\tconst shouldAddExtraMethodNameSuffix = requestBody.length > 1;\n\n\t\t\t\tfor (const req of requestBody) {\n\t\t\t\t\tconst statement = t.createFunctionDeclaration(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tt.createModifier(SyntaxKind.ExportKeyword),\n\t\t\t\t\t\t\tt.createModifier(SyntaxKind.AsyncKeyword),\n\t\t\t\t\t\t],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tBase.pathToFnName(uri, method, operationId) +\n\t\t\t\t\t\t\t(shouldAddExtraMethodNameSuffix\n\t\t\t\t\t\t\t\t? Base.capitalize(req.type.split('/')[1])\n\t\t\t\t\t\t\t\t: ''),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t...(parameters.length > 0\n\t\t\t\t\t\t\t\t? Generator.toDeclarationNodes(parameters)\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t...(req?.schema\n\t\t\t\t\t\t\t\t? [Generator.toRequestBodyTypeNode(req.schema)]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t].filter(Boolean) as ParameterDeclaration[],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tGenerator.bodyBlock(\n\t\t\t\t\t\t\toptions.baseURL + uri,\n\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\tparameters,\n\t\t\t\t\t\t\treq,\n\t\t\t\t\t\t\tresponses[0],\n\t\t\t\t\t\t\tadaptor\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\tconst mergedDescription = [description, summary]\n\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t.join('. ');\n\t\t\t\t\tGenerator.addComments(\n\t\t\t\t\t\tstatement,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tmergedDescription && {\n\t\t\t\t\t\t\t\tcomment: mergedDescription,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdeprecated && {\n\t\t\t\t\t\t\t\ttag: 'deprecated',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...Generator.generateParamTags(parameters, req),\n\t\t\t\t\t\t].filter(Boolean) as CommentObject[]\n\t\t\t\t\t);\n\t\t\t\t\tstatements.push(statement);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn statements;\n\t}\n\n\tstatic async prettier(code: string) {\n\t\treturn await format(code, {\n\t\t\tparser: 'typescript',\n\t\t});\n\t}\n\n\tstatic async genCode(\n\t\tschema: ProviderInitResult,\n\t\tinitOptions: ProviderInitOptions,\n\t\tadaptor: Adapter\n\t) {\n\t\tconst { importClientSource } = initOptions;\n\t\tconst statements = Generator.schemaToStatemets(schema, adaptor, {\n\t\t\tbaseURL: initOptions.baseURL ?? '',\n\t\t});\n\t\tlet code = Generator.toCode(statements);\n\n\t\tif (importClientSource) {\n\t\t\tcode = importClientSource + '\\n\\n' + code;\n\t\t}\n\n\t\treturn await Generator.prettier(code);\n\t}\n}\n","/* eslint-disable unicorn/prefer-spread */\n/**\n * File containing the implementation of the AxiosAdapter class.\n * This adapter is responsible for generating code that uses the Axios HTTP client library.\n */\n\nimport type {\n\tPropertyAssignment,\n\tStatement,\n\tTypeReferenceNode,\n} from 'typescript';\nimport { factory as t } from 'typescript';\nimport { Adapter } from '../base/Adaptor.js';\nimport { Base } from '../base/Base.js';\nimport { Generator } from '../generator/index.js';\nimport type { MediaTypeObject, ParameterObject } from '../interface.js';\n\n/**\n * Adapter class implementing support for generating code that makes use of the Axios HTTP client library.\n * This class defines custom behavior and field mappings specific to the Axios client.\n */\nexport class AxiosAdapter extends Adapter {\n\t/**\n\t * Name of the field used to specify the HTTP method in the request configuration.\n\t */\n\treadonly methodFieldName = 'method';\n\n\t/**\n\t * Name of the field used to specify the request body (data) in the request configuration.\n\t */\n\treadonly bodyFieldName = 'data';\n\n\t/**\n\t * Name of the field used to specify the request headers in the request configuration.\n\t */\n\treadonly headersFieldName = 'headers';\n\n\t/**\n\t * Name of the field used to specify the query parameters in the request configuration.\n\t */\n\treadonly queryFieldName = 'params';\n\n\t/**\n\t * The name of the client this adapter is configured for, which is 'axios' in this case.\n\t */\n\treadonly name = 'axios';\n\n\t/**\n\t * Generates client code for making API requests using Axios.\n\t * @param uri - The API endpoint URI\n\t * @param method - The HTTP method (GET, POST, etc.)\n\t * @param parameters - Array of parameters to include in the request\n\t * @param requestBody - The request body media type definition\n\t * @param response - The response media type definition\n\t * @param adapter - The adapter instance\n\t * @param shouldUseFormData - Flag to use FormData for the request body\n\t * @param shouldUseJSONResponse - Unused by AxiosAdapter; present to align with the abstract signature so positional args bind correctly\n\t * @param isEventStream - Flag indicating a text/event-stream response; when true the raw AxiosResponse is returned without JSON parsing\n\t * @return - An array of generated TypeScript statements\n\t */\n\tpublic client(\n\t\turi: string,\n\t\tmethod: string,\n\t\tparameters: ParameterObject[],\n\t\trequestBody: MediaTypeObject | undefined,\n\t\tresponse: MediaTypeObject | undefined,\n\t\tadapter: Adapter,\n\t\tshouldUseFormData: boolean,\n\t\t_shouldUseJSONResponse: boolean,\n\t\tisEventStream: boolean\n\t): Statement[] {\n\t\tconst statements: Statement[] = [];\n\n\t\t// Split parameters into header and body parameters\n\t\tconst inBody = parameters.filter((p) => !p.in || p.in === 'body');\n\t\tconst inHeader = parameters.filter((p) => p.in === 'header');\n\n\t\t/**\n\t\t * Creates the literal object expression for fetch options\n\t\t * including method, headers, and body.\n\t\t * @returns - The constructed fetch options object\n\t\t */\n\t\tconst toLiterlExpression = (extraProperties: PropertyAssignment[] = []) => {\n\t\t\treturn t.createObjectLiteralExpression(\n\t\t\t\t[\n\t\t\t\t\t// Set the HTTP method\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createIdentifier(adapter.methodFieldName),\n\t\t\t\t\t\tt.createStringLiteral(method.toUpperCase())\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t\t\t.concat(\n\t\t\t\t\t\t// Add headers if there are any\n\t\t\t\t\t\tinHeader.length > 0\n\t\t\t\t\t\t\t? t.createPropertyAssignment(\n\t\t\t\t\t\t\t\t\tt.createIdentifier(adapter.headersFieldName),\n\t\t\t\t\t\t\t\t\tt.createObjectLiteralExpression(\n\t\t\t\t\t\t\t\t\t\tinHeader.map((p) =>\n\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(p.name),\n\t\t\t\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('encodeURIComponent'),\n\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('String'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[t.createIdentifier(Base.normalize(p.name))]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: []\n\t\t\t\t\t)\n\t\t\t\t\t.concat(\n\t\t\t\t\t\tshouldUseFormData || inBody.length > 0 || requestBody?.schema\n\t\t\t\t\t\t\t? t.createPropertyAssignment(\n\t\t\t\t\t\t\t\t\tt.createIdentifier(adapter.bodyFieldName),\n\t\t\t\t\t\t\t\t\tshouldUseFormData\n\t\t\t\t\t\t\t\t\t\t? t.createIdentifier('fd')\n\t\t\t\t\t\t\t\t\t\t: inBody.length > 0 ||\n\t\t\t\t\t\t\t\t\t\t\t\t(requestBody?.schema &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t!Generator.isBinarySchema(requestBody.schema))\n\t\t\t\t\t\t\t\t\t\t\t? t.createIdentifier('req')\n\t\t\t\t\t\t\t\t\t\t\t: t.createIdentifier('req')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: []\n\t\t\t\t\t)\n\t\t\t\t\t.concat(extraProperties),\n\t\t\t\ttrue\n\t\t\t);\n\t\t};\n\n\t\t// SSE responses need axios to use the fetch adapter and stream the\n\t\t// response body so callers can iterate over the event stream.\n\t\tif (isEventStream) {\n\t\t\tstatements.push(\n\t\t\t\tt.createReturnStatement(\n\t\t\t\t\tt.createCallExpression(t.createIdentifier(adapter.name), undefined, [\n\t\t\t\t\t\tGenerator.toUrlTemplate(uri, parameters),\n\t\t\t\t\t\ttoLiterlExpression([\n\t\t\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\t\t\tt.createIdentifier('adapter'),\n\t\t\t\t\t\t\t\tt.createStringLiteral('fetch')\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\t\t\tt.createIdentifier('responseType'),\n\t\t\t\t\t\t\t\tt.createStringLiteral('stream')\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t]),\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn statements;\n\t\t}\n\n\t\t// Construct the fetch call and return statement\n\t\tstatements.push(\n\t\t\tt.createReturnStatement(\n\t\t\t\tt.createCallExpression(\n\t\t\t\t\tt.createIdentifier(adapter.name),\n\t\t\t\t\tresponse?.schema\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tGenerator.toTypeNode(\n\t\t\t\t\t\t\t\t\tresponse.schema\n\t\t\t\t\t\t\t\t) as unknown as TypeReferenceNode,\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\t[Generator.toUrlTemplate(uri, parameters), toLiterlExpression()]\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\n\t\treturn statements;\n\t}\n}\n","/* eslint-disable unicorn/prefer-spread */\n\nimport type { Statement } from 'typescript';\nimport { SyntaxKind, factory as t } from 'typescript';\nimport { Adapter } from '../base/Adaptor.js';\nimport { Base } from '../base/Base.js';\nimport { Generator } from '../generator/index.js';\nimport type { MediaTypeObject, ParameterObject } from '../interface.js';\n\n/**\n * FetchAdapter is an adapter class that generates client-side fetch requests.\n * It handles parameters, headers, and request bodies to construct proper fetch calls.\n */\nexport class FetchAdapter extends Adapter {\n\treadonly methodFieldName = 'method';\n\treadonly bodyFieldName = 'body';\n\treadonly headersFieldName = 'headers';\n\treadonly queryFieldName = '';\n\treadonly name = 'fetch';\n\n\t/**\n\t * Generates client code for making API requests using the Fetch API.\n\t * @param uri - The API endpoint URI\n\t * @param method - The HTTP method (GET, POST, etc.)\n\t * @param parameters - Array of parameters to include in the request\n\t * @param requestBody - The request body media type definition\n\t * @param response - The response media type definition\n\t * @param adapter - The adapter instance\n\t * @param shouldUseFormData - Flag to use FormData for the request body\n\t * @param shouldUseJSONResponse - Flag to use JSON parsing for the response\n\t * @param isEventStream - Flag indicating a text/event-stream response; when true the raw Response is returned unparsed\n\t * @return - An array of generated TypeScript statements\n\t */\n\tpublic client(\n\t\turi: string,\n\t\tmethod: string,\n\t\tparameters: ParameterObject[],\n\t\trequestBody: MediaTypeObject | undefined,\n\t\tresponse: MediaTypeObject | undefined,\n\t\tadapter: Adapter,\n\t\tshouldUseFormData: boolean,\n\t\tshouldUseJSONResponse: boolean,\n\t\tisEventStream: boolean\n\t): Statement[] {\n\t\tconst statements: Statement[] = [];\n\n\t\t// Split parameters into header and body parameters\n\t\tconst inBody = parameters.filter((p) => !p.in || p.in === 'body');\n\t\tconst inHeader = parameters.filter((p) => p.in === 'header');\n\n\t\t/**\n\t\t * Creates the literal object expression for fetch options\n\t\t * including method, headers, and body.\n\t\t * @returns - The constructed fetch options object\n\t\t */\n\t\tconst toLiterlExpression = () => {\n\t\t\treturn t.createObjectLiteralExpression(\n\t\t\t\t[\n\t\t\t\t\t// Set the HTTP method\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createIdentifier(adapter.methodFieldName),\n\t\t\t\t\t\tt.createStringLiteral(method.toUpperCase())\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t\t\t.concat(\n\t\t\t\t\t\t// Add headers if there are any\n\t\t\t\t\t\tinHeader.length > 0\n\t\t\t\t\t\t\t? t.createPropertyAssignment(\n\t\t\t\t\t\t\t\t\tt.createIdentifier(adapter.headersFieldName),\n\t\t\t\t\t\t\t\t\tt.createObjectLiteralExpression(\n\t\t\t\t\t\t\t\t\t\tinHeader.map((p) =>\n\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(p.name),\n\t\t\t\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('encodeURIComponent'),\n\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('String'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[t.createIdentifier(Base.normalize(p.name))]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: []\n\t\t\t\t\t)\n\t\t\t\t\t.concat(\n\t\t\t\t\t\tshouldUseFormData || inBody.length > 0 || requestBody?.schema\n\t\t\t\t\t\t\t? t.createPropertyAssignment(\n\t\t\t\t\t\t\t\t\tt.createIdentifier(adapter.bodyFieldName),\n\t\t\t\t\t\t\t\t\tshouldUseFormData\n\t\t\t\t\t\t\t\t\t\t? t.createIdentifier('fd')\n\t\t\t\t\t\t\t\t\t\t: inBody.length > 0 ||\n\t\t\t\t\t\t\t\t\t\t\t\t(requestBody?.schema &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t!Generator.isBinarySchema(requestBody.schema))\n\t\t\t\t\t\t\t\t\t\t\t? t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('JSON'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('stringify')\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\trequestBody\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? t.createIdentifier('req')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: t.createObjectLiteralExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tinBody.map((b) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createShorthandPropertyAssignment(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier(b.name)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t: // One File parameter\n\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: []\n\t\t\t\t\t),\n\t\t\t\ttrue\n\t\t\t);\n\t\t};\n\n\t\t// SSE responses are returned unparsed so the caller can read the stream\n\t\tif (isEventStream) {\n\t\t\tstatements.push(\n\t\t\t\tt.createReturnStatement(\n\t\t\t\t\tt.createCallExpression(t.createIdentifier(adapter.name), undefined, [\n\t\t\t\t\t\tGenerator.toUrlTemplate(uri, parameters),\n\t\t\t\t\t\ttoLiterlExpression(),\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn statements;\n\t\t}\n\n\t\t// Construct the fetch call and return statement\n\t\tstatements.push(\n\t\t\tt.createReturnStatement(\n\t\t\t\tshouldUseJSONResponse\n\t\t\t\t\t? // Handle JSON response with proper type checking\n\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\tt.createIdentifier(adapter.name),\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tGenerator.toUrlTemplate(uri, parameters),\n\t\t\t\t\t\t\t\t\t\ttoLiterlExpression(),\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tt.createIdentifier('then')\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tt.createArrowFunction(\n\t\t\t\t\t\t\t\t\t[t.createModifier(SyntaxKind.AsyncKeyword)],\n\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tt.createParameterDeclaration(\n\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('response')\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\tt.createToken(SyntaxKind.EqualsGreaterThanToken),\n\t\t\t\t\t\t\t\t\tresponse?.schema\n\t\t\t\t\t\t\t\t\t\t? t.createAsExpression(\n\t\t\t\t\t\t\t\t\t\t\t\tt.createParenthesizedExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createAwaitExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('response'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('json')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tresponse?.schema\n\t\t\t\t\t\t\t\t\t\t\t\t\t? Generator.toTypeNode(response.schema)\n\t\t\t\t\t\t\t\t\t\t\t\t\t: t.createToken(SyntaxKind.UnknownKeyword)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t: t.createParenthesizedExpression(\n\t\t\t\t\t\t\t\t\t\t\t\tt.createAwaitExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('response'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('json')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[]\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t: // Simple fetch call without JSON parsing\n\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\tt.createIdentifier(adapter.name),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[Generator.toUrlTemplate(uri, parameters), toLiterlExpression()]\n\t\t\t\t\t\t)\n\t\t\t)\n\t\t);\n\n\t\treturn statements;\n\t}\n}\n","/**\n * @file VersionedProvider abstract base class\n * @description Shared OpenAPI doc parsing logic used by V2 / V3 / V3_1 providers.\n * Subclasses supply version-specific container accessors; the base class\n * owns the conversion methods (getSchemaByRef, toBaseSchema, etc.).\n */\n\nimport type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\nimport {\n\tBase,\n\ttype EnumSchemaObject,\n\tHttpMethods,\n\ttype MediaTypeObject,\n\ttype MediaTypes,\n\tNonArraySchemaType,\n\ttype OperationObject,\n\ttype ParameterIn,\n\ttype ParameterObject,\n\ttype ProviderInitResult,\n\ttype SchemaFormatType,\n\ttype SchemaObject,\n} from '../core/index.js';\n\n/**\n * Any of the three supported OpenAPI document shapes.\n * Subclasses narrow this to a specific version in their constructor.\n */\nexport type VersionedDoc =\n\t| OpenAPIV2.Document\n\t| OpenAPIV3.Document\n\t| OpenAPIV3_1.Document;\n\n/**\n * Minimal interfaces for the three version-specific container shapes we read.\n * Kept loose on purpose so v2/v3/v3.1 can be plugged in interchangeably.\n */\ntype SchemaMap = Record<string, unknown>;\ntype ParameterMap = Record<string, unknown>;\ntype ResponseMap = Record<string, unknown>;\ntype RequestBodyMap = Record<string, unknown>;\n\n/**\n * Returns the operations container for a path item regardless of version.\n */\ntype PathItemObject = Record<string, unknown>;\n\n/**\n * OpenAPI version tag for subclasses.\n */\nexport enum OpenAPIVersion {\n\tv2 = 'v2',\n\tv3 = 'v3',\n\tv3_1 = 'v3_1',\n}\n\n/**\n * Abstract base class. Subclasses implement the four container accessors\n * and a version tag. The shared logic lives here.\n */\nexport abstract class VersionedProvider {\n\tprotected abstract readonly doc: VersionedDoc;\n\n\t/**\n\t * The OpenAPI version this provider handles.\n\t */\n\tabstract readonly version: OpenAPIVersion;\n\n\t/**\n\t * Returns the version-specific schema container (`definitions` for v2,\n\t * `components.schemas` for v3 / v3.1).\n\t */\n\tprotected abstract getSchemaContainer(): SchemaMap | undefined;\n\n\t/**\n\t * Returns the version-specific parameter container (root-level `parameters`\n\t * for v2; `components.parameters` for v3 / v3.1).\n\t */\n\tprotected abstract getParameterContainer(): ParameterMap | undefined;\n\n\t/**\n\t * Returns the version-specific response container (root-level `responses`\n\t * for v2; `components.responses` for v3 / v3.1).\n\t */\n\tprotected abstract getResponseContainer(): ResponseMap | undefined;\n\n\t/**\n\t * Returns the version-specific requestBody container\n\t * (`components.requestBodies` for v3 / v3.1; undefined for v2).\n\t */\n\tprotected abstract getRequestBodyContainer(): RequestBodyMap | undefined;\n\n\t/**\n\t * Resolves a path $ref to the actual path object.\n\t */\n\tprotected resolvePathRef($ref: string): PathItemObject | undefined {\n\t\tconst refName = Base.ref2name(\n\t\t\t$ref,\n\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t);\n\t\tconst paths = (this.doc as { paths?: Record<string, PathItemObject> })\n\t\t\t.paths;\n\t\treturn paths?.[refName];\n\t}\n\n\t/**\n\t * Is array schema.\n\t */\n\tprivate isOpenAPIArraySchema(schema: unknown): boolean {\n\t\treturn (\n\t\t\ttypeof schema === 'object' &&\n\t\t\tschema !== null &&\n\t\t\t(schema as { type?: unknown }).type === 'array'\n\t\t);\n\t}\n\n\t/**\n\t * OpenAPI schema to base schema. Override for version-specific quirks\n\t * (V3_1 throws on missing ref; V3 returns `{ type: 'unknown' }`).\n\t */\n\tprotected getSchemaByRef(\n\t\tschema: unknown,\n\t\treserveRef = false,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): SchemaObject {\n\t\tlet refName = '';\n\t\tif (Base.isRef(schema)) {\n\t\t\trefName = this.formatRefName(Base.ref2name(schema.$ref));\n\t\t\tif (reserveRef) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: upLevelSchemaKey + refName,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.getSchemaContainer()?.[\n\t\t\t\t\tBase.ref2name(\n\t\t\t\t\t\tschema.$ref,\n\t\t\t\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t\t\t\t)\n\t\t\t\t];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\treturn { type: 'unknown' };\n\t\t\t}\n\t\t\tschema = resolvedSchema;\n\t\t}\n\n\t\treturn this.toBaseSchema(\n\t\t\tschema as Record<string, unknown>,\n\t\t\tenums,\n\t\t\t'',\n\t\t\tupLevelSchemaKey + refName\n\t\t);\n\t}\n\n\t/**\n\t * Format a ref name for the schema's `type` field.\n\t * V3 uses `capitalize`; V3_1 uses `upperCamelCase` (preserved for compat).\n\t */\n\tprotected formatRefName(name: string): string {\n\t\treturn Base.capitalize(name);\n\t}\n\n\t/**\n\t * OpenAPI parameter to base parameter. Override in V2 — its parameter\n\t * shape is structurally different (top-level `items`/`properties`/`enum`).\n\t */\n\tprotected getParameterByRef(\n\t\tschema: unknown,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): ParameterObject {\n\t\tif (Base.isRef(schema)) {\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.getParameterContainer()?.[\n\t\t\t\t\tBase.ref2name(\n\t\t\t\t\t\tschema.$ref,\n\t\t\t\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t\t\t\t)\n\t\t\t\t];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\treturn {\n\t\t\t\t\tname: 'unknown',\n\t\t\t\t\tin: 'query' as ParameterIn,\n\t\t\t\t};\n\t\t\t}\n\t\t\tschema = resolvedSchema;\n\t\t}\n\n\t\tconst {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdeprecated,\n\t\t\tdescription,\n\t\t\tschema: parameterSchema,\n\t\t} = schema as {\n\t\t\tname: string;\n\t\t\trequired?: boolean;\n\t\t\tdeprecated?: boolean;\n\t\t\tdescription?: string;\n\t\t\tschema?: unknown;\n\t\t\tin: string;\n\t\t};\n\n\t\tif (\n\t\t\tparameterSchema &&\n\t\t\t!Base.isRef(parameterSchema) &&\n\t\t\t(parameterSchema as { enum?: unknown }).enum\n\t\t) {\n\t\t\tconst type =\n\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\tBase.upperCamelCase(Base.normalize(name));\n\n\t\t\tconst enumSchema = {\n\t\t\t\tname: type,\n\t\t\t\tenum: [\n\t\t\t\t\t...new Set((parameterSchema as { enum: (string | number)[] }).enum),\n\t\t\t\t],\n\t\t\t};\n\n\t\t\tconst sameEnum = Base.findSameSchema(enumSchema, enums);\n\n\t\t\tif (\n\t\t\t\t!sameEnum &&\n\t\t\t\tBase.isValidEnumType(parameterSchema as unknown as SchemaObject)\n\t\t\t) {\n\t\t\t\tenums.push(enumSchema);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tdeprecated,\n\t\t\t\tin: (schema as { in: ParameterIn }).in,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: sameEnum?.name ?? type,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdescription,\n\t\t\tdeprecated,\n\t\t\tin: (schema as { in: ParameterIn }).in,\n\t\t\tschema: (schema as { schema?: unknown }).schema\n\t\t\t\t? this.getSchemaByRef(\n\t\t\t\t\t\t(schema as { schema?: unknown }).schema,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\tenums,\n\t\t\t\t\t\tupLevelSchemaKey + Base.capitalize(name)\n\t\t\t\t\t)\n\t\t\t\t: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * OpenAPI schema to base response. Override in V2 (its response shape\n\t * lacks the `content` wrapper).\n\t */\n\tprotected getResponseByRef(schema: unknown): MediaTypeObject[] {\n\t\tif (Base.isRef(schema)) {\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.getResponseContainer()?.[\n\t\t\t\t\tBase.ref2name(\n\t\t\t\t\t\tschema.$ref,\n\t\t\t\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t\t\t\t)\n\t\t\t\t];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tschema = resolvedSchema;\n\t\t}\n\n\t\tconst { content = {} } = schema as {\n\t\t\tcontent?: Record<string, { schema?: unknown }>;\n\t\t};\n\n\t\treturn Object.keys(content).map((c) => ({\n\t\t\ttype: c as MediaTypes,\n\t\t\tschema: content[c].schema\n\t\t\t\t? this.getSchemaByRef(content[c].schema, true)\n\t\t\t\t: undefined,\n\t\t}));\n\t}\n\n\t/**\n\t * OpenAPI schema to requestBody. V2 has no requestBody concept.\n\t */\n\tprotected getRequestBodyByRef(\n\t\tschema: unknown,\n\t\tenums: EnumSchemaObject[] = []\n\t): MediaTypeObject[] {\n\t\tif (Base.isRef(schema)) {\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.getRequestBodyContainer()?.[\n\t\t\t\t\tBase.ref2name(\n\t\t\t\t\t\tschema.$ref,\n\t\t\t\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t\t\t\t)\n\t\t\t\t];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tschema = resolvedSchema;\n\t\t}\n\n\t\tconst { content = {} } = schema as {\n\t\t\tcontent?: Record<string, { schema?: unknown }>;\n\t\t};\n\n\t\treturn Object.keys(content).map((c) => ({\n\t\t\ttype: c as MediaTypes,\n\t\t\tschema: content[c].schema\n\t\t\t\t? this.getSchemaByRef(content[c].schema, false, enums)\n\t\t\t\t: undefined,\n\t\t}));\n\t}\n\n\t/**\n\t * Transform all OpenAPI schema to Base Schema\n\t */\n\tprivate toBaseSchema(\n\t\tschema: unknown,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tschemaKey = '',\n\t\tupLevelSchemaKey = ''\n\t): SchemaObject {\n\t\tif (!schema) {\n\t\t\treturn {\n\t\t\t\ttype: 'unknown',\n\t\t\t};\n\t\t}\n\n\t\tif (Base.isRef(schema)) {\n\t\t\treturn this.getSchemaByRef(schema, true);\n\t\t}\n\n\t\tif (this.isOpenAPIArraySchema(schema)) {\n\t\t\tconst { type, description, items, required } = schema as {\n\t\t\t\ttype: string;\n\t\t\t\tdescription?: string;\n\t\t\t\titems?: unknown;\n\t\t\t\trequired?: unknown;\n\t\t\t};\n\n\t\t\tconst itemsSchema = items\n\t\t\t\t? this.toBaseSchema(items, enums, schemaKey, upLevelSchemaKey)\n\t\t\t\t: ({ type: 'unknown' } as SchemaObject);\n\n\t\t\treturn {\n\t\t\t\ttype: type as 'array',\n\t\t\t\trequired: !!required,\n\t\t\t\tdescription,\n\t\t\t\titems: itemsSchema,\n\t\t\t};\n\t\t}\n\t\tconst {\n\t\t\trequired = [],\n\t\t\tallOf,\n\t\t\tanyOf,\n\t\t\tdescription,\n\t\t\tdeprecated,\n\t\t\tenum: enum_,\n\t\t\tformat,\n\t\t\toneOf,\n\t\t\tproperties = {},\n\t\t} = schema as {\n\t\t\trequired?: string[];\n\t\t\tallOf?: unknown[];\n\t\t\tanyOf?: unknown[];\n\t\t\tdescription?: string;\n\t\t\tdeprecated?: boolean;\n\t\t\tenum?: (string | number)[];\n\t\t\tformat?: string;\n\t\t\toneOf?: unknown[];\n\t\t\tproperties?: Record<string, unknown>;\n\t\t\ttype?: string;\n\t\t};\n\t\tlet { type } = schema as { type?: string };\n\n\t\tif (enum_ && type !== 'boolean') {\n\t\t\tconst name =\n\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\tBase.upperCamelCase(Base.normalize(schemaKey));\n\n\t\t\tconst enumObject = {\n\t\t\t\tname,\n\t\t\t\tenum: [...new Set(enum_)],\n\t\t\t};\n\n\t\t\tconst sameObject = Base.findSameSchema(enumObject, enums);\n\n\t\t\tif (\n\t\t\t\t!sameObject &&\n\t\t\t\tBase.isValidEnumType(schema as unknown as SchemaObject)\n\t\t\t) {\n\t\t\t\tenums.push(enumObject);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: sameObject\n\t\t\t\t\t? sameObject.name\n\t\t\t\t\t: Base.isBooleanEnum(schema as unknown as SchemaObject)\n\t\t\t\t\t\t? 'boolean'\n\t\t\t\t\t\t: enumObject.name,\n\t\t\t\trequired: required as string[] | undefined,\n\t\t\t\tdescription,\n\t\t\t\tdeprecated,\n\t\t\t};\n\t\t}\n\n\t\tif (type === undefined && Object.keys(properties).length > 0) {\n\t\t\ttype = NonArraySchemaType.object;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: type as unknown as NonArraySchemaType,\n\t\t\trequired: required as string[] | undefined,\n\t\t\tdescription,\n\t\t\tdeprecated,\n\t\t\tenum: enum_,\n\t\t\tformat: format as unknown as SchemaFormatType,\n\t\t\tallOf: allOf?.map((s) =>\n\t\t\t\tBase.isRef(s)\n\t\t\t\t\t? ({\n\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\tref: (s as { $ref: string }).$ref,\n\t\t\t\t\t\t\ttype: Base.capitalize(\n\t\t\t\t\t\t\t\tBase.ref2name(\n\t\t\t\t\t\t\t\t\t(s as { $ref: string }).$ref,\n\t\t\t\t\t\t\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} as unknown as SchemaObject)\n\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t),\n\t\t\tanyOf: anyOf?.map((s) =>\n\t\t\t\tBase.isRef(s)\n\t\t\t\t\t? ({\n\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\tref: (s as { $ref: string }).$ref,\n\t\t\t\t\t\t\ttype: Base.capitalize(\n\t\t\t\t\t\t\t\tBase.ref2name(\n\t\t\t\t\t\t\t\t\t(s as { $ref: string }).$ref,\n\t\t\t\t\t\t\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} as unknown as SchemaObject)\n\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t),\n\t\t\toneOf: oneOf?.map((s) =>\n\t\t\t\tBase.isRef(s)\n\t\t\t\t\t? ({\n\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\tref: (s as { $ref: string }).$ref,\n\t\t\t\t\t\t\ttype: Base.capitalize(\n\t\t\t\t\t\t\t\tBase.ref2name(\n\t\t\t\t\t\t\t\t\t(s as { $ref: string }).$ref,\n\t\t\t\t\t\t\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} as unknown as SchemaObject)\n\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t),\n\t\t\tproperties: Object.keys(properties).reduce(\n\t\t\t\t(acc, p) => {\n\t\t\t\t\tconst propSchema = properties[p];\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[p]: Base.isRef(propSchema)\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\ttype: Base.capitalize(\n\t\t\t\t\t\t\t\t\t\tBase.ref2name(\n\t\t\t\t\t\t\t\t\t\t\t(propSchema as { $ref: string }).$ref,\n\t\t\t\t\t\t\t\t\t\t\tthis.doc as unknown as Record<string, unknown>\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tisRef: true,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: this.toBaseSchema(propSchema, enums, p, upLevelSchemaKey),\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{} as Record<string, SchemaObject>\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * Run the parsing pipeline and return a ProviderInitResult.\n\t */\n\tpublic init(): ProviderInitResult {\n\t\tconst { paths = {} } = this.doc as {\n\t\t\tpaths?: Record<string, PathItemObject>;\n\t\t};\n\t\tconst enums: EnumSchemaObject[] = [];\n\t\tconst schemaContainer = this.getSchemaContainer() ?? {};\n\t\tconst parameterContainer = this.getParameterContainer() ?? {};\n\t\tconst responseContainer = this.getResponseContainer() ?? {};\n\t\tconst requestBodyContainer = this.getRequestBodyContainer() ?? {};\n\n\t\tconst schemas_ = Object.keys(schemaContainer).reduce((acc, key) => {\n\t\t\tconst schema = schemaContainer[key];\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getSchemaByRef(schema, false, enums, key),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst parameters_ = Object.keys(parameterContainer).reduce((acc, key) => {\n\t\t\tconst parameter = parameterContainer[key];\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getParameterByRef(parameter, enums, key),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst responses_ = Object.keys(responseContainer).reduce((acc, key) => {\n\t\t\tconst response = responseContainer[key];\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getResponseByRef(response),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst requestBodies_ = Object.keys(requestBodyContainer).reduce(\n\t\t\t(acc, key) => {\n\t\t\t\tconst requestBody = requestBodyContainer[key];\n\t\t\t\treturn {\n\t\t\t\t\t...acc,\n\t\t\t\t\t[key]: this.getRequestBodyByRef(requestBody, enums),\n\t\t\t\t};\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tconst apis = Object.keys(paths).reduce((acc, path) => {\n\t\t\tlet pathObject: PathItemObject = paths[path] ?? {};\n\n\t\t\tif ((pathObject as { $ref?: string }).$ref) {\n\t\t\t\tconst resolved = this.resolvePathRef(\n\t\t\t\t\t(pathObject as { $ref: string }).$ref\n\t\t\t\t);\n\t\t\t\tif (resolved) {\n\t\t\t\t\tpathObject = resolved;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tparameters = [],\n\t\t\t\tdescription,\n\t\t\t\tsummary,\n\t\t\t} = pathObject as {\n\t\t\t\tparameters?: unknown[];\n\t\t\t\tdescription?: string;\n\t\t\t\tsummary?: string;\n\t\t\t};\n\t\t\tconst methodApis: OperationObject[] = [];\n\n\t\t\tObject.values(HttpMethods).forEach((method) => {\n\t\t\t\tconst methodObject = (pathObject as Record<string, unknown>)[method];\n\n\t\t\t\tif (methodObject) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tdeprecated,\n\t\t\t\t\t\toperationId,\n\t\t\t\t\t\tresponses,\n\t\t\t\t\t\tsummary: summary_,\n\t\t\t\t\t\tdescription: description_,\n\t\t\t\t\t\trequestBody = { content: {} },\n\t\t\t\t\t} = methodObject as {\n\t\t\t\t\t\tdeprecated?: boolean;\n\t\t\t\t\t\toperationId?: string;\n\t\t\t\t\t\tresponses?: Record<string, unknown>;\n\t\t\t\t\t\tsummary?: string;\n\t\t\t\t\t\tdescription?: string;\n\t\t\t\t\t\trequestBody?: { content?: Record<string, unknown> };\n\t\t\t\t\t};\n\t\t\t\t\t// Clone to avoid mutating the input spec when we inject a\n\t\t\t\t\t// default 200 response below.\n\t\t\t\t\tconst responsesClone: Record<string, unknown> = responses\n\t\t\t\t\t\t? { ...responses }\n\t\t\t\t\t\t: {};\n\t\t\t\t\tconst { parameters: parameters_ = [] } = methodObject as {\n\t\t\t\t\t\tparameters?: unknown[];\n\t\t\t\t\t};\n\t\t\t\t\tconst baseParameters = [...parameters, ...parameters_].map(\n\t\t\t\t\t\t(parameter) => this.getParameterByRef(parameter, enums)\n\t\t\t\t\t);\n\t\t\t\t\tconst baseRequestBody = this.getRequestBodyByRef(requestBody, enums);\n\t\t\t\t\tconst uniqueParameterName = [\n\t\t\t\t\t\t...new Set(baseParameters.map((p) => p.name)),\n\t\t\t\t\t];\n\n\t\t\t\t\tif (Object.keys(responsesClone).length === 0) {\n\t\t\t\t\t\tresponsesClone[200] = {\n\t\t\t\t\t\t\tdescription: 'Successful response',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst httpCodes = Object.keys(responsesClone);\n\t\t\t\t\tfor (const code of httpCodes) {\n\t\t\t\t\t\tif (code in responsesClone) {\n\t\t\t\t\t\t\tconst response = responsesClone[code];\n\t\t\t\t\t\t\tconst responseSchema = this.getResponseByRef(response);\n\t\t\t\t\t\t\tmethodApis.push({\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\toperationId,\n\t\t\t\t\t\t\t\tsummary: summary_ ?? summary,\n\t\t\t\t\t\t\t\tdescription: description_ ?? description,\n\t\t\t\t\t\t\t\tdeprecated: deprecated,\n\t\t\t\t\t\t\t\tparameters: uniqueParameterName\n\t\t\t\t\t\t\t\t\t.map((name) => baseParameters.find((p) => p.name === name))\n\t\t\t\t\t\t\t\t\t.filter((p): p is ParameterObject => p !== undefined),\n\t\t\t\t\t\t\t\tresponses: responseSchema,\n\t\t\t\t\t\t\t\trequestBody: baseRequestBody,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[path]: methodApis,\n\t\t\t};\n\t\t}, {});\n\n\t\treturn {\n\t\t\tenums: Base.uniqueEnums(enums),\n\t\t\tschemas: schemas_ as Record<string, SchemaObject>,\n\t\t\tresponses: responses_ as Record<\n\t\t\t\tstring,\n\t\t\t\timport('../core/index.js').ResponsesObject\n\t\t\t>,\n\t\t\tparameters: parameters_ as Record<string, ParameterObject>,\n\t\t\trequestBodies: requestBodies_ as Record<\n\t\t\t\tstring,\n\t\t\t\timport('../core/index.js').RequestBodyObject\n\t\t\t>,\n\t\t\tapis: apis as Record<string, OperationObject[]>,\n\t\t};\n\t}\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { OpenAPIV2 } from 'openapi-types';\nimport {\n\tBase,\n\ttype EnumSchemaObject,\n\tHttpMethods,\n\ttype MediaTypeObject,\n\tMediaTypes,\n\ttype OperationObject,\n\ttype ParameterIn,\n\ttype ParameterObject,\n\ttype SchemaObject,\n} from '../core/index.js';\nimport { OpenAPIVersion, VersionedProvider } from './VersionedProvider.js';\n\nexport class V2 extends VersionedProvider {\n\tprotected readonly doc: OpenAPIV2.Document;\n\treadonly version = OpenAPIVersion.v2;\n\n\tconstructor(doc: OpenAPIV2.Document) {\n\t\tsuper();\n\t\tthis.doc = doc;\n\t}\n\n\tprotected override getSchemaContainer():\n\t\t| Record<string, OpenAPIV2.SchemaObject>\n\t\t| undefined {\n\t\treturn this.doc.definitions as any;\n\t}\n\n\tprotected override getParameterContainer():\n\t\t| Record<string, OpenAPIV2.ParameterObject>\n\t\t| undefined {\n\t\treturn this.doc.parameters as any;\n\t}\n\n\tprotected override getResponseContainer():\n\t\t| Record<string, OpenAPIV2.ResponseObject>\n\t\t| undefined {\n\t\treturn this.doc.responses as any;\n\t}\n\n\tprotected override getRequestBodyContainer(): undefined {\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * V2 parameter shape differs from V3: top-level `items`/`properties`/`enum`\n\t * rather than nested under `schema`. Override accordingly.\n\t */\n\tprotected override getParameterByRef(\n\t\tparameter: unknown,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): ParameterObject {\n\t\tif (Base.isRef(parameter)) {\n\t\t\tconst refName = Base.ref2name(\n\t\t\t\t(parameter as { $ref: string }).$ref,\n\t\t\t\tthis.doc\n\t\t\t);\n\t\t\tconst resolved = (\n\t\t\t\tthis.doc as { parameters?: Record<string, OpenAPIV2.ParameterObject> }\n\t\t\t).parameters?.[refName];\n\t\t\tif (!resolved) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Parameter reference not found: ${(parameter as { $ref: string }).$ref}`\n\t\t\t\t);\n\t\t\t}\n\t\t\tparameter = resolved;\n\t\t}\n\n\t\tconst p = parameter as OpenAPIV2.ParameterObject;\n\t\tconst {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdescription,\n\t\t\ttype,\n\t\t\titems,\n\t\t\tenum: enum_,\n\t\t\tproperties,\n\t\t\tschema,\n\t\t} = p;\n\n\t\tif (enum_) {\n\t\t\tconst enumType =\n\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\tBase.upperCamelCase(Base.normalize(name));\n\n\t\t\tconst enumSchema = {\n\t\t\t\tname: enumType,\n\t\t\t\tenum: [...new Set(enum_ as (string | number)[])],\n\t\t\t};\n\n\t\t\tconst sameEnum = Base.findSameSchema(enumSchema, enums);\n\n\t\t\tif (\n\t\t\t\t!sameEnum &&\n\t\t\t\tBase.isValidEnumType({ type: enumType, enum: enum_ } as SchemaObject)\n\t\t\t) {\n\t\t\t\tenums.push(enumSchema);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tin: p.in as ParameterIn,\n\t\t\t\tschema: { type: sameEnum?.name ?? enumType },\n\t\t\t};\n\t\t}\n\n\t\tif (items) {\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tin: p.in as ParameterIn,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: type as string,\n\t\t\t\t\titems: items as unknown as SchemaObject,\n\t\t\t\t} as unknown as SchemaObject,\n\t\t\t};\n\t\t}\n\n\t\tif (schema && Base.isRef(schema)) {\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tin: p.in as ParameterIn,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: Base.capitalize(\n\t\t\t\t\t\tBase.ref2name((schema as { $ref: string }).$ref)\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdescription,\n\t\t\tin: p.in as ParameterIn,\n\t\t\tschema: { type: type as string, properties } as SchemaObject,\n\t\t};\n\t}\n\n\t/**\n\t * V2 response shape: a `schema` field directly, not `content`. V2 always\n\t * emits JSON.\n\t */\n\tprotected override getResponseByRef(schema: unknown): MediaTypeObject[] {\n\t\tif (Base.isRef(schema)) {\n\t\t\tschema = (\n\t\t\t\tthis.doc as { responses: Record<string, OpenAPIV2.ResponseObject> }\n\t\t\t).responses[Base.ref2name((schema as { $ref: string }).$ref, this.doc)];\n\t\t}\n\n\t\tconst { schema: responseSchema } = schema as { schema?: unknown };\n\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: MediaTypes.JSON,\n\t\t\t\tschema: responseSchema\n\t\t\t\t\t? this.getSchemaByRef(responseSchema, true)\n\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * V2 has no `requestBody` concept; parameters with `in: body` or\n\t * `in: formData` are split out and turned into a synthetic requestBody\n\t * here. A single body param named `body` is used directly; otherwise\n\t * the body / formData params are wrapped in a synthetic object.\n\t */\n\tpublic override init() {\n\t\tconst { paths = {} } = this.doc as {\n\t\t\tpaths?: Record<string, Record<string, unknown>>;\n\t\t};\n\t\tconst enums: EnumSchemaObject[] = [];\n\n\t\tconst schemaContainer = this.getSchemaContainer() ?? {};\n\t\tconst parameterContainer = this.getParameterContainer() ?? {};\n\t\tconst responseContainer = this.getResponseContainer() ?? {};\n\n\t\tconst schemas_ = Object.keys(schemaContainer).reduce((acc, key) => {\n\t\t\tconst schema = schemaContainer[key];\n\t\t\treturn { ...acc, [key]: this.getSchemaByRef(schema, false, enums, key) };\n\t\t}, {});\n\n\t\tconst parameters_ = Object.keys(parameterContainer).reduce((acc, key) => {\n\t\t\tconst parameter = parameterContainer[key];\n\t\t\treturn { ...acc, [key]: this.getParameterByRef(parameter, enums, key) };\n\t\t}, {});\n\n\t\tconst responses_ = Object.keys(responseContainer).reduce((acc, key) => {\n\t\t\tconst response = responseContainer[key];\n\t\t\treturn { ...acc, [key]: this.getResponseByRef(response) };\n\t\t}, {});\n\n\t\tconst apis: Record<string, OperationObject[]> = {};\n\t\tfor (const path of Object.keys(paths)) {\n\t\t\tlet pathObject = paths[path] ?? {};\n\n\t\t\tif ((pathObject as { $ref?: string }).$ref) {\n\t\t\t\tconst resolved = this.resolvePathRef(\n\t\t\t\t\t(pathObject as { $ref: string }).$ref\n\t\t\t\t);\n\t\t\t\tif (resolved) pathObject = resolved;\n\t\t\t}\n\n\t\t\tconst { parameters = [] } = pathObject as { parameters?: unknown[] };\n\t\t\tconst methodApis: OperationObject[] = [];\n\n\t\t\tObject.values(HttpMethods).forEach((method) => {\n\t\t\t\tconst methodObject = (pathObject as Record<string, unknown>)[method];\n\t\t\t\tif (!methodObject) return;\n\n\t\t\t\tconst {\n\t\t\t\t\tdeprecated,\n\t\t\t\t\toperationId,\n\t\t\t\t\tsummary: summary_,\n\t\t\t\t\tdescription: description_,\n\t\t\t\t\tresponses,\n\t\t\t\t} = methodObject as {\n\t\t\t\t\tdeprecated?: boolean;\n\t\t\t\t\toperationId?: string;\n\t\t\t\t\tsummary?: string;\n\t\t\t\t\tdescription?: string;\n\t\t\t\t\tresponses?: Record<string, unknown>;\n\t\t\t\t};\n\t\t\t\tconst { parameters: parameters_ = [] } = methodObject as {\n\t\t\t\t\tparameters?: unknown[];\n\t\t\t\t};\n\n\t\t\t\tconst baseParameters = [...parameters, ...parameters_].map((p) =>\n\t\t\t\t\tthis.getParameterByRef(p, enums)\n\t\t\t\t);\n\t\t\t\tconst uniqueParameterName = [\n\t\t\t\t\t...new Set(baseParameters.map((p) => p.name)),\n\t\t\t\t];\n\n\t\t\t\t// Clone to avoid mutating the input spec.\n\t\t\t\tconst responsesClone: Record<string, unknown> = responses\n\t\t\t\t\t? { ...responses }\n\t\t\t\t\t: {};\n\n\t\t\t\tif (Object.keys(responsesClone).length === 0) {\n\t\t\t\t\tresponsesClone[200] = { description: 'Successful response' };\n\t\t\t\t}\n\n\t\t\t\tconst inBody = baseParameters.filter(\n\t\t\t\t\t(p) => p.in === 'body' || p.in === 'formData'\n\t\t\t\t);\n\t\t\t\tconst notInBody = baseParameters.filter(\n\t\t\t\t\t(p) => p.in !== 'body' && p.in !== 'formData'\n\t\t\t\t);\n\n\t\t\t\tconst httpCodes = Object.keys(responsesClone);\n\t\t\t\tfor (const code of httpCodes) {\n\t\t\t\t\tif (code in responsesClone) {\n\t\t\t\t\t\tconst response = responsesClone[code];\n\t\t\t\t\t\tconst responseSchema = this.getResponseByRef(response);\n\n\t\t\t\t\t\tconst inBodyOnlyHasBody =\n\t\t\t\t\t\t\tinBody.length === 1 &&\n\t\t\t\t\t\t\tinBody[0].in === 'body' &&\n\t\t\t\t\t\t\tinBody[0].name === 'body';\n\n\t\t\t\t\t\tmethodApis.push({\n\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\toperationId,\n\t\t\t\t\t\t\tsummary: summary_,\n\t\t\t\t\t\t\tdeprecated: deprecated,\n\t\t\t\t\t\t\tdescription: description_,\n\t\t\t\t\t\t\tparameters: uniqueParameterName\n\t\t\t\t\t\t\t\t.map((name) => notInBody.find((p) => p.name === name))\n\t\t\t\t\t\t\t\t.filter((p): p is ParameterObject => p !== undefined),\n\t\t\t\t\t\t\tresponses: responseSchema,\n\t\t\t\t\t\t\trequestBody:\n\t\t\t\t\t\t\t\tinBody.length > 0\n\t\t\t\t\t\t\t\t\t? inBodyOnlyHasBody\n\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype: MediaTypes.JSON,\n\t\t\t\t\t\t\t\t\t\t\t\t\tschema: inBody[0].schema,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype: MediaTypes.JSON,\n\t\t\t\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: 'object' as const,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tproperties: inBody.reduce<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tRecord<string, SchemaObject>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>((a, p) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[p.name]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: (p.schema?.type ??\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'unknown') as 'object',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trequired: p.schema?.required,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titems: (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.schema as unknown as {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titems?: SchemaObject;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)?.items,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdescription: p.schema?.description,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} as SchemaObject,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tapis[path] = methodApis;\n\t\t}\n\n\t\treturn {\n\t\t\tenums: Base.uniqueEnums(enums),\n\t\t\tschemas: schemas_ as Record<string, SchemaObject>,\n\t\t\tresponses: responses_ as unknown as Record<\n\t\t\t\tstring,\n\t\t\t\timport('../core/index.js').ResponsesObject\n\t\t\t>,\n\t\t\tparameters: parameters_ as Record<string, ParameterObject>,\n\t\t\trequestBodies: {} as unknown as Record<\n\t\t\t\tstring,\n\t\t\t\timport('../core/index.js').RequestBodyObject\n\t\t\t>,\n\t\t\tapis: apis as Record<string, OperationObject[]>,\n\t\t};\n\t}\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { OpenAPIV3 } from 'openapi-types';\nimport { OpenAPIVersion, VersionedProvider } from './VersionedProvider.js';\n\nexport class V3 extends VersionedProvider {\n\tprotected readonly doc: OpenAPIV3.Document;\n\treadonly version = OpenAPIVersion.v3;\n\n\tconstructor(doc: OpenAPIV3.Document) {\n\t\tsuper();\n\t\tthis.doc = doc;\n\t}\n\n\tprotected override getSchemaContainer():\n\t\t| Record<string, OpenAPIV3.SchemaObject>\n\t\t| undefined {\n\t\treturn this.doc.components?.schemas as any;\n\t}\n\n\tprotected override getParameterContainer():\n\t\t| Record<string, OpenAPIV3.ParameterObject>\n\t\t| undefined {\n\t\treturn this.doc.components?.parameters as any;\n\t}\n\n\tprotected override getResponseContainer():\n\t\t| Record<string, OpenAPIV3.ResponseObject>\n\t\t| undefined {\n\t\treturn this.doc.components?.responses as any;\n\t}\n\n\tprotected override getRequestBodyContainer():\n\t\t| Record<string, OpenAPIV3.RequestBodyObject>\n\t\t| undefined {\n\t\treturn this.doc.components?.requestBodies as any;\n\t}\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable unicorn/filename-case */\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport { Base } from '../core/index.js';\nimport { OpenAPIVersion, VersionedProvider } from './VersionedProvider.js';\n\nexport class V3_1 extends VersionedProvider {\n\tprotected readonly doc: OpenAPIV3_1.Document;\n\treadonly version = OpenAPIVersion.v3_1;\n\n\tconstructor(doc: OpenAPIV3_1.Document) {\n\t\tsuper();\n\t\tthis.doc = doc;\n\t}\n\n\tprotected override formatRefName(name: string): string {\n\t\t// V3_1 normalizes ref names to UpperCamelCase (V3 only capitalizes\n\t\t// the first character). Preserved for backward compatibility.\n\t\treturn Base.upperCamelCase(name);\n\t}\n\n\tprotected override getSchemaContainer():\n\t\t| Record<string, OpenAPIV3_1.SchemaObject>\n\t\t| undefined {\n\t\treturn this.doc.components?.schemas as any;\n\t}\n\n\tprotected override getParameterContainer():\n\t\t| Record<string, OpenAPIV3_1.ParameterObject>\n\t\t| undefined {\n\t\treturn this.doc.components?.parameters as any;\n\t}\n\n\tprotected override getResponseContainer():\n\t\t| Record<string, OpenAPIV3_1.ResponseObject>\n\t\t| undefined {\n\t\treturn this.doc.components?.responses as any;\n\t}\n\n\tprotected override getRequestBodyContainer():\n\t\t| Record<string, OpenAPIV3_1.RequestBodyObject>\n\t\t| undefined {\n\t\treturn this.doc.components?.requestBodies as any;\n\t}\n}\n","import { createScopedLogger } from '@moccona/logger';\nimport type { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\nimport type {\n\tAdaptors,\n\tProviderInitOptions,\n\tProviderInitResult,\n} from '../core/index.js';\nimport {\n\ttype Adapter,\n\tAxiosAdapter,\n\tAdaptors as ads,\n\tBase,\n\tFetchAdapter,\n\tGenerator,\n\tProvider,\n} from '../core/index.js';\n\nimport { V2 } from './V2.js';\nimport { V3 } from './V3.js';\nimport { V3_1 } from './V3_1.js';\n\nconst logger = createScopedLogger('OpenAPI');\n\nexport enum OpenAPIVersion {\n\tv2 = 'v2',\n\tv3 = 'v3',\n\tv3_1 = 'v3_1',\n\tunknown = 'unknown',\n}\n\nfunction getDocVersion(doc: OpenAPI.Document) {\n\tconst version = (\n\t\t(doc as OpenAPIV3.Document).openapi || (doc as OpenAPIV2.Document).swagger\n\t).slice(0, 3);\n\n\tswitch (version) {\n\t\tcase '3.1':\n\t\t\treturn OpenAPIVersion.v3_1;\n\t\tcase '3.0':\n\t\t\treturn OpenAPIVersion.v3;\n\t\tcase '2.0':\n\t\t\treturn OpenAPIVersion.v2;\n\t\tdefault:\n\t\t\treturn OpenAPIVersion.unknown;\n\t}\n}\n\nexport class OpenAPIProvider extends Provider {\n\tpublic parse(doc: OpenAPIV3.Document): ProviderInitResult {\n\t\tconst version = getDocVersion(doc);\n\n\t\tlogger.debug(`openapi version ${version}`);\n\n\t\tswitch (version) {\n\t\t\tcase OpenAPIVersion.v2:\n\t\t\t\treturn new V2(doc as unknown as OpenAPIV2.Document).init();\n\t\t\tcase OpenAPIVersion.v3:\n\t\t\t\treturn new V3(doc as unknown as OpenAPIV3.Document).init();\n\t\t\tcase OpenAPIVersion.v3_1:\n\t\t\t\treturn new V3_1(doc as unknown as OpenAPIV3_1.Document).init();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Not a valid OpenAPI version: ${version}`);\n\t\t}\n\t}\n}\n\nfunction getAdaptor(type: keyof typeof Adaptors): Adapter {\n\tswitch (type) {\n\t\tcase ads.axios:\n\t\t\treturn new AxiosAdapter();\n\t\tdefault:\n\t\t\treturn new FetchAdapter();\n\t}\n}\n\nexport interface CodeGenResult {\n\tcode: string;\n\tstats: {\n\t\tendpoints: number;\n\t\tschemas: number;\n\t\tduration: number;\n\t};\n}\n\nexport async function codeGen(\n\tinitOptions: ProviderInitOptions\n): Promise<CodeGenResult> {\n\tconst startTime = Date.now();\n\tconst { verbose } = initOptions;\n\n\tif (verbose) {\n\t\tlogger.setLevel('debug');\n\t} else {\n\t\tlogger.setLevel('info');\n\t}\n\n\tlogger.info(`Fetch document from ${initOptions.docURL}`);\n\n\tconst doc = await Base.fetchDoc(\n\t\tinitOptions.docURL,\n\t\tinitOptions.requestOptions\n\t);\n\n\tconst provider = new OpenAPIProvider(initOptions, doc);\n\tconst { enums, schemas, parameters, responses, requestBodies, apis } =\n\t\tprovider;\n\n\tconst adaptor = getAdaptor(initOptions.adaptor ?? ads.fetch);\n\tconst code = await Generator.genCode(\n\t\t{\n\t\t\tenums,\n\t\t\tschemas,\n\t\t\tparameters,\n\t\t\tresponses,\n\t\t\trequestBodies,\n\t\t\tapis,\n\t\t},\n\t\tinitOptions,\n\t\tadaptor\n\t);\n\n\tif (initOptions.output) {\n\t\tawait Generator.write(code, initOptions.output);\n\t}\n\n\tconst duration = Date.now() - startTime;\n\tconst endpoints = Object.keys(apis).length;\n\tconst schemasCount = Object.keys(schemas).length;\n\n\treturn {\n\t\tcode,\n\t\tstats: {\n\t\t\tendpoints,\n\t\t\tschemas: schemasCount,\n\t\t\tduration,\n\t\t},\n\t};\n}\n\nexport type { ProviderInitOptions } from '../core/index.js';\n","import path from 'node:path';\nimport { createScopedLogger } from '@moccona/logger';\nimport fs from 'fs-extra';\nimport type { PluginOption } from 'vite';\nimport { loadConfig, toProviderOptions } from '../core/config.js';\nimport {\n\tcreateErrors,\n\tErrorCodes,\n\tisApicodegenError,\n\twrapError,\n} from '../core/errors.js';\nimport { logger } from '../core/logger.js';\nimport { codeGen } from '../openapi/index.js';\n\nconst PLUGIN_NAME = 'api-code-gen';\nconst pluginLogger = createScopedLogger('api-code-gen');\n\nexport type ApiCodeGenPluginOptions = {\n\t/** Human-readable name for this API config (required) */\n\tname: string;\n\t/** OpenAPI spec file path or URL */\n\tspec?: string;\n\t/** Output file path */\n\toutput?: string;\n\t/** HTTP client adaptor */\n\tadaptor?: 'fetch' | 'axios';\n\t/** Base URL for API endpoints */\n\tbaseURL?: string;\n\t/** Custom client import source path */\n\timportClientSource?: string;\n\t/** Enable verbose logging */\n\tverbose?: boolean;\n\t/** Run type check after generation (default: true) */\n\ttypeCheck?: boolean;\n};\n\n/**\n * Find the nearest tsconfig.json or jsconfig.json by searching upward.\n * Bounded by process.cwd() — the Vite project root — to avoid picking up\n * unrelated configs outside the project.\n */\nasync function findNearestTsConfig(filePath: string): Promise<string | null> {\n\tlet dir = path.dirname(path.resolve(filePath));\n\tconst rootDir = process.cwd();\n\tconst fsRoot = path.parse(dir).root;\n\n\twhile (true) {\n\t\tfor (const name of ['tsconfig.json', 'jsconfig.json']) {\n\t\t\tconst configPath = path.join(dir, name);\n\t\t\tif (await fs.pathExists(configPath)) {\n\t\t\t\treturn configPath;\n\t\t\t}\n\t\t}\n\n\t\tif (dir === rootDir || dir === fsRoot) break;\n\n\t\tdir = path.dirname(dir);\n\t}\n\n\treturn null;\n}\n\n/**\n * Run TypeScript type checking on generated file\n */\nasync function runTypeCheck(filePath: string): Promise<string[]> {\n\tconst { execaCommand } = await import('execa');\n\tconst errors: string[] = [];\n\n\tconst resolvedPath = path.resolve(filePath);\n\tconst tsconfigPath = await findNearestTsConfig(resolvedPath);\n\n\tif (!tsconfigPath) {\n\t\ttry {\n\t\t\tawait execaCommand(`npx tsc ${resolvedPath} --noEmit`, {\n\t\t\t\tshell: true,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\terrors.push(error.message);\n\t\t\t}\n\t\t}\n\t\treturn errors;\n\t}\n\n\tconst outputDir = path.dirname(resolvedPath);\n\tconst tempConfigName = `.${path.basename(resolvedPath).replace(/\\.ts$/i, '')}.${Date.now()}.apicodegen.json`;\n\tconst tempConfigPath = path.join(outputDir, tempConfigName);\n\tconst extendsPath = path.relative(outputDir, tsconfigPath);\n\n\tconst tempConfig = {\n\t\textends: extendsPath,\n\t\tcompilerOptions: {\n\t\t\tnoEmit: true,\n\t\t},\n\t\tinclude: [path.basename(resolvedPath)],\n\t};\n\n\ttry {\n\t\tawait fs.writeJson(tempConfigPath, tempConfig);\n\t\tawait execaCommand(`npx tsc --project \"${tempConfigPath}\" --noEmit`, {\n\t\t\tshell: true,\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\terrors.push(error.message);\n\t\t}\n\t} finally {\n\t\ttry {\n\t\t\tawait fs.remove(tempConfigPath);\n\t\t} catch {\n\t\t\t// ignore cleanup errors\n\t\t}\n\t}\n\n\treturn errors;\n}\n\n/**\n * Validate spec path exists\n */\nasync function validateSpecPath(specPath: string): Promise<void> {\n\t// For URLs, skip file existence check\n\tif (specPath.startsWith('http://') || specPath.startsWith('https://')) {\n\t\treturn;\n\t}\n\n\tconst filePath = specPath.replace(/^file:\\/\\//, '');\n\tconst absolutePath = path.isAbsolute(filePath)\n\t\t? filePath\n\t\t: path.resolve(process.cwd(), filePath);\n\n\tconst exists = await fs.pathExists(absolutePath);\n\tif (!exists) {\n\t\tthrow createErrors.specNotFound(absolutePath);\n\t}\n}\n\n/**\n * Generate code for a single API configuration\n */\nasync function generateForOption(option: ApiCodeGenPluginOptions): Promise<{\n\tsuccess: boolean;\n\tname: string;\n\toutput?: string;\n\tstats?: { endpoints: number; schemas: number; duration: number };\n\terror?: unknown;\n}> {\n\tconst { name, typeCheck = true, verbose, ...restOptions } = option;\n\n\ttry {\n\t\tlogger.info(`Generating ${name}...`);\n\n\t\t// Use config loader to handle env vars and config files\n\t\tconst config = await loadConfig({\n\t\t\tname,\n\t\t\tcliOptions: { ...restOptions, verbose },\n\t\t});\n\n\t\t// Validate spec exists\n\t\tawait validateSpecPath(config.spec);\n\n\t\t// Ensure output directory exists\n\t\tif (config.output) {\n\t\t\tconst outputDir = path.dirname(config.output);\n\t\t\tawait fs.ensureDir(outputDir);\n\t\t}\n\n\t\t// Convert to provider options and resolve docURL\n\t\tlet docURL = config.spec;\n\t\tif (!docURL.startsWith('http://') && !docURL.startsWith('https://')) {\n\t\t\tif (docURL.startsWith('/') || docURL.match(/^[A-Za-z]:/)) {\n\t\t\t\tdocURL = `file://${docURL}`;\n\t\t\t} else {\n\t\t\t\tdocURL = path.resolve(process.cwd(), docURL);\n\t\t\t}\n\t\t}\n\n\t\tconst result = await codeGen({\n\t\t\t...toProviderOptions(config),\n\t\t\tdocURL,\n\t\t});\n\n\t\tif (config.output) {\n\t\t\tawait fs.writeFile(config.output, result.code);\n\t\t}\n\n\t\t// Run type check if enabled\n\t\tif (typeCheck && config.output) {\n\t\t\tconst typeErrors = await runTypeCheck(config.output);\n\t\t\tif (typeErrors.length > 0) {\n\t\t\t\tpluginLogger.warn(`Type check failed for ${config.output}`);\n\t\t\t\tif (verbose) {\n\t\t\t\t\tfor (const error of typeErrors) {\n\t\t\t\t\t\tpluginLogger.warn(` ${error}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tname,\n\t\t\toutput: config.output,\n\t\t\tstats: result.stats,\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tname,\n\t\t\terror,\n\t\t};\n\t}\n}\n\n/**\n * Main Vite plugin function\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { apiCodeGenPlugin } from '@moccona/apicodegen/vite';\n *\n * export default defineConfig({\n * plugins: [\n * apiCodeGenPlugin([\n * {\n * name: 'my-api',\n * spec: './openapi.json',\n * output: './src/api/generated.ts',\n * baseURL: 'https://api.example.com',\n * },\n * ]),\n * ],\n * });\n * ```\n */\nexport function apiCodeGenPlugin(\n\toptions: ApiCodeGenPluginOptions[]\n): PluginOption {\n\tif (!Array.isArray(options) || options.length === 0) {\n\t\tpluginLogger.warn('No API configurations provided to apiCodeGenPlugin');\n\t\treturn { name: PLUGIN_NAME };\n\t}\n\n\treturn {\n\t\tname: PLUGIN_NAME,\n\n\t\tasync config(_config, env) {\n\t\t\tlogger.heading('API Code Gen', env?.command);\n\n\t\t\tconst results = await Promise.all(options.map(generateForOption));\n\t\t\tconst successCount = results.filter((r) => r.success).length;\n\t\t\tconst failCount = options.length - successCount;\n\n\t\t\tlogger.divider();\n\n\t\t\tfor (const result of results) {\n\t\t\t\tif (result.success) {\n\t\t\t\t\tconst { name, output, stats } = result;\n\t\t\t\t\tif (stats) {\n\t\t\t\t\t\tlogger.item(\n\t\t\t\t\t\t\t`${name} → ${output} (${stats.endpoints} endpoints, ${stats.schemas} schemas) ${stats.duration}ms`,\n\t\t\t\t\t\t\t'green'\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.item(`${name} → ${output || 'N/A'}`, 'green');\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst { name, error } = result;\n\t\t\t\t\tif (isApicodegenError(error)) {\n\t\t\t\t\t\tlogger.item(name, 'red');\n\t\t\t\t\t\tlogger.error(error, true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst wrapped = wrapError(error!, {\n\t\t\t\t\t\t\tcode: ErrorCodes.GENERATION_FAILED,\n\t\t\t\t\t\t\tmessage: `Failed to generate API \"${name}\"`,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tlogger.item(name, 'red');\n\t\t\t\t\t\tlogger.error(wrapped, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.divider();\n\n\t\t\tconst totalDuration = results.reduce(\n\t\t\t\t(sum, r) => sum + (r.stats?.duration || 0),\n\t\t\t\t0\n\t\t\t);\n\t\t\tconst totalEndpoints = results.reduce(\n\t\t\t\t(sum, r) => sum + (r.stats?.endpoints || 0),\n\t\t\t\t0\n\t\t\t);\n\t\t\tconst totalSchemas = results.reduce(\n\t\t\t\t(sum, r) => sum + (r.stats?.schemas || 0),\n\t\t\t\t0\n\t\t\t);\n\n\t\t\tlogger.summary({\n\t\t\t\tsucceeded: successCount,\n\t\t\t\tfailed: failCount,\n\t\t\t\tendpoints: totalEndpoints,\n\t\t\t\tschemas: totalSchemas,\n\t\t\t\tduration: totalDuration,\n\t\t\t});\n\t\t\tlogger.divider();\n\n\t\t\treturn {};\n\t\t},\n\t};\n}\n\nexport default apiCodeGenPlugin;\n"],"mappings":";;;;;;;;;;;AA6DA,MAAM,eAAuD;CAC5D,iBAAiB;CACjB,mBAAmB;CACnB,qBAAqB;CACrB,oBAAoB;CACpB,oBAAoB;CACpB,kBAAkB;CAClB,uBAAuB;AACxB;;;;AAKA,SAAS,cAAyC;CACjD,MAAM,SAAoC,CAAC;CAE3C,KAAK,MAAM,CAAC,QAAQ,cAAc,OAAO,QAAQ,YAAY,GAAG;EAC/D,MAAM,QAAQ,QAAQ,IAAI;EAC1B,IAAI,UAAU,KAAA,GAEb,QAAQ,WAAR;GACC,KAAK;GACL,KAAK;GACL,KAAK;IACJ,OAAO,aAAa,UAAU,UAAU,UAAU;IAClD;GACD,KAAK;IACJ,OAAO,aAAa;IACpB;GACD,SACC,OAAO,aAAa;EACtB;CAEF;CAEA,OAAO;AACR;;;;AAKA,eAAe,aACd,UACqC;CACrC,MAAM,MAAM,KAAK,QAAQ,QAAQ,EAAE,YAAY;CAE/C,IAAI;EACH,IAAI,QAAQ,WAAW,QAAQ,UAAU;GACxC,MAAM,UAAU,MAAM,GAAG,SAAS,UAAU,OAAO;GACnD,OAAO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ACD;GACA,MAAM,iBAAiB,QAAQ,QAC7B,KAAK,MAAM,OAAO,EAAE,OAAO,aAAa,IACzC,CACD;GACA,MAAM,eAAe,QAAQ,QAC3B,KAAK,MAAM,OAAO,EAAE,OAAO,WAAW,IACvC,CACD;GAEA,SAAO,QAAQ;IACd,WAAW;IACX,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;GACX,CAAC;GACD,SAAO,QAAQ;GAEf,OAAO,CAAC;EACT;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["t","t","t","logger"],"sources":["../../src/core/interface.ts","../../src/core/config.ts","../../src/core/errors.ts","../../src/core/base/Adaptor.ts","../../src/core/constants/keywords.ts","../../src/core/base/Base.ts","../../src/core/base/Provider.ts","../../src/core/generator/naming.ts","../../src/core/generator/index.ts","../../src/core/client/axios.ts","../../src/core/client/fetch.ts","../../src/openapi/V2.ts","../../src/openapi/V3.ts","../../src/openapi/V3_1.ts","../../src/openapi/index.ts","../../src/vite-plugin/cache.ts","../../src/vite-plugin/index.ts"],"sourcesContent":["/**\n * Simple represenration for JSON object\n */\nexport type JSONValue = {\n\t[K: string]:\n\t\t| string\n\t\t| number\n\t\t| boolean\n\t\t| JSONValue\n\t\t| (string | number | boolean | JSONValue)[];\n};\n\nexport enum SchemaType {\n\tschemas = 'schemas',\n\tparameters = 'parameters',\n\tresponses = 'responses',\n\trequestBodies = 'requestBodies',\n}\n\nexport enum NonArraySchemaType {\n\tobject = 'object',\n\tstring = 'string',\n\tnumber = 'number',\n\tboolean = 'boolean',\n\tinteger = 'integer',\n\tenum = 'enum',\n\tfile = 'file',\n}\n\nexport enum ArraySchemaType {\n\tarray = 'array',\n}\n\nexport enum SchemaFormatType {\n\tstring = 'string',\n\tnumber = 'number',\n\tboolean = 'boolean',\n\tfile = 'file',\n\tbinary = 'binary',\n\tblob = 'blob',\n}\n\nexport enum ParameterIn {\n\theader = 'header',\n\tbody = 'body',\n\tquery = 'query',\n\tcookie = 'cookie',\n\tpath = 'path',\n\tformData = 'formData',\n}\n\nexport interface ReferenceObject {\n\t$ref: string;\n}\n\nexport interface EnumSchemaObject {\n\tname: string;\n\tenum: (string | number)[];\n}\n\nexport interface SingleTypeSchemaObject {\n\t// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n\ttype: keyof typeof NonArraySchemaType | string;\n\tdescription?: string;\n\tallOf?: SchemaObject[];\n\tanyOf?: SchemaObject[];\n\tdeprecated?: boolean;\n\tenum?: (string | number)[];\n\tformat?: keyof typeof SchemaFormatType;\n\toneOf?: SchemaObject[];\n\tproperties?: Record<string, SchemaObject>;\n\treadonly?: boolean;\n\trequired?: string[] | boolean;\n\tref?: string;\n\tisRef?: boolean;\n}\n\nexport interface ArrayTypeSchemaObject {\n\ttype: keyof typeof ArraySchemaType;\n\titems?: SchemaObject;\n\trequired?: boolean;\n\tdescription?: string;\n\tref?: string;\n}\n\nexport type SchemaObject = SingleTypeSchemaObject | ArrayTypeSchemaObject;\n\nexport type ParameterObject = {\n\tname: string;\n\t/** Where the parameter is sent. A missing `in` is treated as a body parameter. */\n\tin?: keyof typeof ParameterIn;\n\tschema?: SchemaObject;\n\trequired?: boolean;\n\tdescription?: string;\n\tdeprecated?: boolean;\n\tref?: string;\n};\n\nexport enum MediaTypes {\n\tJSON = 'application/json',\n\tTEXT = 'text',\n\tIMAGE = 'image',\n\tAUDIO = 'audio',\n\tVIDEO = 'video',\n}\n\nexport type MediaTypeObject = {\n\t/**\n\t * Media type of the payload, e.g. `application/json`,\n\t * `multipart/form-data`. Known types keep autocomplete, any other media\n\t * type is accepted.\n\t */\n\ttype: MediaTypes | `${MediaTypes}` | (string & {});\n\tschema?: SchemaObject;\n};\n\nexport type ResponsesObject = Record<string, MediaTypeObject[]>;\n\nexport type RequestBodyObject = ResponsesObject;\n\nexport enum HttpMethods {\n\tGET = 'get',\n\tPUT = 'put',\n\tPOST = 'post',\n\tDELETE = 'delete',\n\tOPTIONS = 'options',\n\tHEAD = 'head',\n\tPATCH = 'patch',\n\tTRACE = 'trace',\n}\n\nexport type OperationObject = {\n\tmethod: string;\n\tsummary?: string;\n\tdescription?: string;\n\toperationId?: string;\n\texternalDocs?: { url: string; description?: string }[];\n\tparameters?: ParameterObject[];\n\trequestBody?: MediaTypeObject[];\n\tresponses: MediaTypeObject[];\n\tdeprecated?: boolean;\n};\n\nexport type PathObject = {\n\tref?: string;\n\tsummary?: string;\n\tdescription?: string;\n\tparameters?: ParameterObject[];\n} & Partial<Record<HttpMethods, OperationObject>>;\n\nexport type PathsObject = Record<string, OperationObject[]>;\n\nexport type FetchDocRequestInit = {\n\tmethod?: string;\n\tbody?: string | FormData;\n\theaders?: Record<string, string>;\n};\n\nexport enum Adaptors {\n\tfetch = 'fetch',\n\taxios = 'axios',\n}\n\nexport type ProviderInitOptions = {\n\tdocURL: string;\n\toutput: string;\n\tbaseURL?: string;\n\timportClientSource?: string;\n\trequestOptions?: FetchDocRequestInit;\n\tverbose?: boolean;\n\tadaptor?: keyof typeof Adaptors;\n};\n\nexport interface ProviderInitResult {\n\treadonly enums: EnumSchemaObject[];\n\treadonly schemas: Record<string, SchemaObject>;\n\treadonly parameters: Record<string, ParameterObject>;\n\treadonly responses: Record<string, ResponsesObject>;\n\treadonly requestBodies: Record<string, RequestBodyObject>;\n\treadonly apis: PathsObject;\n}\n","import path from 'node:path';\nimport fs from 'fs-extra';\n\nimport type { FetchDocRequestInit } from './interface.js';\nimport { Adaptors } from './interface.js';\n\n/**\n * Adaptor type for HTTP client\n */\nexport type ConfigAdaptor = keyof typeof Adaptors;\n\n/**\n * Shared config interface for CLI and Vite plugin\n */\nexport interface ApicodegenConfig {\n\t/** OpenAPI spec file path or URL (required) */\n\tspec: string;\n\t/** Output file path */\n\toutput: string;\n\t/** HTTP client adaptor (fetch|axios) */\n\tadaptor?: ConfigAdaptor;\n\t/** Base URL for API endpoints */\n\tbaseURL?: string;\n\t/** Custom client import source path */\n\timportClientSource?: string;\n\t/** Enable verbose logging */\n\tverbose?: boolean;\n\t/** Run type check after generation (default: true) */\n\ttypeCheck?: boolean;\n\t/** Watch for file changes */\n\twatch?: boolean;\n\t/** Request options for fetching spec */\n\trequestOptions?: FetchDocRequestInit;\n}\n\n/**\n * Options for loading config\n */\nexport interface LoadConfigOptions {\n\t/** Explicit config file path */\n\tconfigFile?: string;\n\t/** Config file directory (defaults to cwd) */\n\tcwd?: string;\n\t/** CLI overrides */\n\tcliOptions?: Partial<ApicodegenConfig>;\n\t/** Vite plugin options (for name metadata) */\n\tname?: string;\n}\n\n/**\n * Result of config loading\n */\nexport interface ResolvedConfig extends ApicodegenConfig {\n\t/** Config file path if loaded from file */\n\tconfigFilePath?: string;\n\t/** Config name for logging */\n\tname: string;\n}\n\n/**\n * Strings considered truthy for boolean env vars (verbose/watch/typeCheck).\n */\nconst TRUTHY_STRINGS = new Set(['true', '1', 'yes', 'on', 'enable']);\n\n/**\n * Environment variable mappings\n */\nconst ENV_MAPPINGS: Record<string, keyof ApicodegenConfig> = {\n\tAPICODEGEN_SPEC: 'spec',\n\tAPICODEGEN_OUTPUT: 'output',\n\tAPICODEGEN_BASE_URL: 'baseURL',\n\tAPICODEGEN_ADAPTOR: 'adaptor',\n\tAPICODEGEN_VERBOSE: 'verbose',\n\tAPICODEGEN_WATCH: 'watch',\n\tAPICODEGEN_TYPE_CHECK: 'typeCheck',\n};\n\n/**\n * Load config from environment variables\n */\nfunction loadFromEnv(): Partial<ApicodegenConfig> {\n\tconst config: Partial<ApicodegenConfig> = {};\n\n\tfor (const [envKey, configKey] of Object.entries(ENV_MAPPINGS)) {\n\t\tconst value = process.env[envKey];\n\t\tif (value !== undefined) {\n\t\t\t// Convert string to appropriate type\n\t\t\tswitch (configKey) {\n\t\t\t\tcase 'verbose':\n\t\t\t\tcase 'watch':\n\t\t\t\tcase 'typeCheck':\n\t\t\t\t\tconfig[configKey] = TRUTHY_STRINGS.has(value.toLowerCase());\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'adaptor':\n\t\t\t\t\tif (Object.values(Adaptors).includes(value as never)) {\n\t\t\t\t\t\tconfig[configKey] = value as ConfigAdaptor;\n\t\t\t\t\t}\n\t\t\t\t\t// else: silently ignore invalid adaptor value.\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tconfig[configKey] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn config;\n}\n\n/**\n * Load config from a file\n */\nasync function loadFromFile(\n\tfilePath: string\n): Promise<Partial<ApicodegenConfig>> {\n\tconst ext = path.extname(filePath).toLowerCase();\n\n\ttry {\n\t\tif (ext === '.json' || ext === '.jsonc') {\n\t\t\tconst content = await fs.readFile(filePath, 'utf-8');\n\t\t\treturn JSON.parse(content);\n\t\t}\n\n\t\tif (ext === '.js' || ext === '.cjs' || ext === '.mjs') {\n\t\t\tconst mod = await import(filePath);\n\t\t\treturn mod.default || mod;\n\t\t}\n\n\t\tif (ext === '.ts') {\n\t\t\t// For .ts files, try to load as JSON first\n\t\t\tconst content = await fs.readFile(filePath, 'utf-8');\n\t\t\t// Try parsing as JSON (may work for JSON-like TS files)\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(content);\n\t\t\t} catch {\n\t\t\t\t// For actual TS config, we'd need ts-node or similar\n\t\t\t\t// For now, fall back to looking for JSON export pattern\n\t\t\t\tconst jsonMatch = content.match(/export\\s+default\\s+(\\{.+\\})/s);\n\t\t\t\tif (jsonMatch) {\n\t\t\t\t\treturn JSON.parse(jsonMatch[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Try parsing as JSON for unknown extensions\n\t\tconst content = await fs.readFile(filePath, 'utf-8');\n\t\treturn JSON.parse(content);\n\t} catch (error) {\n\t\tthrow new Error(`Failed to load config from ${filePath}: ${error}`);\n\t}\n}\n\n/**\n * Find config file in project root\n */\nasync function findConfigFile(cwd: string): Promise<string | null> {\n\tconst configFiles = [\n\t\t'apicodegen.config.json',\n\t\t'apicodegen.config.js',\n\t\t'apicodegen.config.mjs',\n\t\t'.apicodegenrc',\n\t\t'.apicodegenrc.json',\n\t\t'.apicodegenrc.js',\n\t\t'.apicodegenrc.mjs',\n\t];\n\n\tfor (const fileName of configFiles) {\n\t\tconst filePath = path.join(cwd, fileName);\n\t\tif (await fs.pathExists(filePath)) {\n\t\t\treturn filePath;\n\t\t}\n\t}\n\n\t// Also check package.json for apicodegen field\n\tconst packageJsonPath = path.join(cwd, 'package.json');\n\tif (await fs.pathExists(packageJsonPath)) {\n\t\ttry {\n\t\t\tconst pkg = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));\n\t\t\tif (pkg.apicodegen && typeof pkg.apicodegen === 'string') {\n\t\t\t\treturn path.resolve(cwd, pkg.apicodegen);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore package.json parse errors\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Merge multiple config sources with priority\n * Priority: defaults < env vars < config file < CLI args\n */\nexport function mergeConfigs(\n\tbase: ApicodegenConfig,\n\t...sources: (Partial<ApicodegenConfig> | undefined)[]\n): ApicodegenConfig {\n\tconst result = { ...base };\n\n\tfor (const source of sources) {\n\t\tif (!source) continue;\n\n\t\tfor (const [key, value] of Object.entries(source)) {\n\t\t\t// Only override if value is defined and not null.\n\t\t\t// Explicit null is treated like undefined — callers usually want\n\t\t\t// \"unset\" semantics, not \"set to null\".\n\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t(result as Record<string, unknown>)[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Validate config has required fields\n */\nexport function validateConfig(\n\tconfig: Partial<ApicodegenConfig>\n): config is ApicodegenConfig {\n\tif (!config.spec) {\n\t\tthrow new Error(\n\t\t\t'Missing required field: spec (OpenAPI spec file path or URL)'\n\t\t);\n\t}\n\treturn true;\n}\n\n/**\n * Load and resolve config from multiple sources\n */\nexport async function loadConfig(\n\toptions: LoadConfigOptions = {}\n): Promise<ResolvedConfig> {\n\tconst cwd = options.cwd || process.cwd();\n\tconst cliOptions = options.cliOptions || {};\n\n\t// 1. Load from environment variables\n\tconst envConfig = loadFromEnv();\n\n\t// 2. Load from config file (if specified or found)\n\tlet fileConfig: Partial<ApicodegenConfig> = {};\n\tlet configFilePath: string | undefined;\n\n\tif (options.configFile) {\n\t\tconfigFilePath = path.resolve(cwd, options.configFile);\n\t\tfileConfig = await loadFromFile(configFilePath);\n\t} else {\n\t\tconst foundPath = await findConfigFile(cwd);\n\t\tif (foundPath) {\n\t\t\tconfigFilePath = foundPath;\n\t\t\tfileConfig = await loadFromFile(foundPath);\n\t\t}\n\t}\n\n\t// 3. Check package.json inline config\n\tconst packageJsonPath = path.join(cwd, 'package.json');\n\tlet inlineConfig: Partial<ApicodegenConfig> = {};\n\tif (await fs.pathExists(packageJsonPath)) {\n\t\ttry {\n\t\t\tconst pkg = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));\n\t\t\tif (pkg.apicodegen && typeof pkg.apicodegen === 'object') {\n\t\t\t\tinlineConfig = pkg.apicodegen as Partial<ApicodegenConfig>;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore\n\t\t}\n\t}\n\n\t// 4. Merge configs with priority\n\tconst merged = mergeConfigs(\n\t\t{ spec: '', output: './output.ts' }, // defaults\n\t\tenvConfig,\n\t\tinlineConfig,\n\t\tfileConfig,\n\t\tcliOptions\n\t);\n\n\t// 5. Validate\n\tvalidateConfig(merged);\n\n\t// 6. Add metadata\n\tconst name = options.name || merged.baseURL || merged.spec;\n\n\treturn {\n\t\t...merged,\n\t\tconfigFilePath,\n\t\tname,\n\t};\n}\n\n/**\n * Create CLI options from config for commander\n */\nexport function configToCLIOptions(\n\tconfig: ApicodegenConfig\n): Record<string, unknown> {\n\tconst options: Record<string, unknown> = {};\n\n\tif (config.spec) options.spec = config.spec;\n\tif (config.output) options.output = config.output;\n\tif (config.adaptor) options.adaptor = config.adaptor;\n\tif (config.baseURL) options.baseURL = config.baseURL;\n\tif (config.verbose) options.verbose = config.verbose;\n\tif (config.watch) options.watch = config.watch;\n\tif (config.importClientSource)\n\t\toptions.importClientSource = config.importClientSource;\n\n\treturn options;\n}\n\n/**\n * Convert resolved config to provider options format\n */\nexport function toProviderOptions(config: ResolvedConfig) {\n\treturn {\n\t\tdocURL: config.spec,\n\t\toutput: config.output,\n\t\tadaptor: config.adaptor,\n\t\tbaseURL: config.baseURL,\n\t\timportClientSource: config.importClientSource,\n\t\tverbose: config.verbose,\n\t\trequestOptions: config.requestOptions,\n\t};\n}\n","/**\n * Error handling utilities for api-codegen\n */\n\n// Error codes\nexport const ErrorCodes = {\n\tSPEC_NOT_FOUND: 'E_SPEC_NOT_FOUND',\n\tSPEC_FETCH_FAILED: 'E_SPEC_FETCH_FAILED',\n\tSPEC_PARSE_FAILED: 'E_SPEC_PARSE_FAILED',\n\tOUTPUT_DIR_MISSING: 'E_OUTPUT_DIR_MISSING',\n\tCONFIG_INVALID: 'E_CONFIG_INVALID',\n\tVALIDATION_FAILED: 'E_VALIDATION_FAILED',\n\tGENERATION_FAILED: 'E_GENERATION_FAILED',\n\tTYPE_CHECK_FAILED: 'E_TYPE_CHECK_FAILED',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n\n/**\n * Error context for ApicodegenError\n */\nexport interface ApicodegenErrorContext {\n\t/** Error code */\n\tcode: ErrorCode;\n\t/** Human readable message */\n\tmessage: string;\n\t/** File/URL related to error */\n\tlocation?: string;\n\t/** Line number if applicable */\n\tline?: number;\n\t/** Column number if applicable */\n\tcolumn?: number;\n\t/** Related schema/path if applicable */\n\tpath?: string;\n\t/** Suggested fixes */\n\tsuggestions?: string[];\n\t/** Original error */\n\tcause?: Error;\n}\n\n/**\n * Custom error class for api-codegen with rich context\n */\nexport class ApicodegenError extends Error {\n\treadonly code: ErrorCode;\n\treadonly location?: string;\n\treadonly line?: number;\n\treadonly column?: number;\n\treadonly path?: string;\n\treadonly suggestions: string[];\n\treadonly cause?: Error;\n\n\tconstructor(context: ApicodegenErrorContext) {\n\t\tsuper(context.message);\n\t\tthis.name = 'ApicodegenError';\n\t\tthis.code = context.code;\n\t\tthis.location = context.location;\n\t\tthis.line = context.line;\n\t\tthis.column = context.column;\n\t\tthis.path = context.path;\n\t\tthis.suggestions = context.suggestions || [];\n\t\tthis.cause = context.cause;\n\n\t\t// Maintains proper stack trace in V8 environments\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, ApicodegenError);\n\t\t}\n\t}\n\n\t/**\n\t * Convert error to formatted string for CLI output\n\t */\n\ttoString(verbose = false): string {\n\t\tconst lines: string[] = [];\n\n\t\t// Error header with code\n\t\tlines.push(`\\x1b[1;31mError [${this.code}]\\x1b[0m ${this.message}`);\n\n\t\t// Location\n\t\tif (this.location) {\n\t\t\tlines.push(` \\x1b[36m→ Location:\\x1b[0m ${this.location}`);\n\t\t}\n\n\t\t// Path\n\t\tif (this.path) {\n\t\t\tlines.push(` \\x1b[36m→ Path:\\x1b[0m ${this.path}`);\n\t\t}\n\n\t\t// Line/column\n\t\tif (this.line !== undefined) {\n\t\t\tlet lineInfo = ` \\x1b[36m→ Line:\\x1b[0m ${this.line}`;\n\t\t\tif (this.column !== undefined) {\n\t\t\t\tlineInfo += `, Column: ${this.column}`;\n\t\t\t}\n\t\t\tlines.push(lineInfo);\n\t\t}\n\n\t\t// Suggestions\n\t\tif (this.suggestions.length > 0) {\n\t\t\tfor (const suggestion of this.suggestions) {\n\t\t\t\tlines.push(` \\x1b[32m→ Suggestion:\\x1b[0m ${suggestion}`);\n\t\t\t}\n\t\t}\n\n\t\t// Stack trace in verbose mode\n\t\tif (verbose && this.cause) {\n\t\t\tlines.push(`\\n \\x1b[90mOriginal Error:\\x1b[0m ${this.cause.message}`);\n\t\t\tif (this.stack) {\n\t\t\t\t// Skip first few lines of stack (our error header)\n\t\t\t\tconst stackLines = this.stack.split('\\n').slice(1).join('\\n');\n\t\t\t\tlines.push(`\\x1b[90m${stackLines}\\x1b[0m`);\n\t\t\t}\n\t\t}\n\n\t\treturn lines.join('\\n');\n\t}\n\n\t/**\n\t * Convert to JSON-serializable object\n\t */\n\ttoJSON(): object {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tlocation: this.location,\n\t\t\tline: this.line,\n\t\t\tcolumn: this.column,\n\t\t\tpath: this.path,\n\t\t\tsuggestions: this.suggestions,\n\t\t\tcause: this.cause?.message,\n\t\t};\n\t}\n}\n\n/**\n * ANSI color codes for terminal output\n */\nexport const Colors = {\n\treset: '\\x1b[0m',\n\tbold: '\\x1b[1m',\n\tred: '\\x1b[31m',\n\tgreen: '\\x1b[32m',\n\tyellow: '\\x1b[33m',\n\tblue: '\\x1b[34m',\n\tcyan: '\\x1b[36m',\n\tgray: '\\x1b[90m',\n\tbrightRed: '\\x1b[91m',\n\tbrightGreen: '\\x1b[92m',\n} as const;\n\n/**\n * Format error for CLI output\n */\nexport function formatError(error: unknown, verbose = false): string {\n\tif (error instanceof ApicodegenError) {\n\t\treturn error.toString(verbose);\n\t}\n\n\tif (error instanceof Error) {\n\t\treturn `${Colors.red}${Colors.bold}Error${Colors.reset}: ${error.message}${verbose && error.stack ? `\\n\\n${Colors.gray}${error.stack}${Colors.reset}` : ''}`;\n\t}\n\n\treturn `${Colors.red}${Colors.bold}Error${Colors.reset}: ${String(error)}`;\n}\n\n/**\n * Print error to console with formatting\n */\nexport function printError(\n\terror: unknown,\n\tverbose = false,\n\tstream: NodeJS.WriteStream = process.stderr\n): void {\n\tstream.write(formatError(error, verbose));\n\tstream.write('\\n');\n}\n\n/**\n * Create error with common patterns\n */\nexport const createErrors = {\n\tspecNotFound(path: string, cause?: Error): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.SPEC_NOT_FOUND,\n\t\t\tmessage: 'OpenAPI spec file not found',\n\t\t\tlocation: path,\n\t\t\tsuggestions: [\n\t\t\t\t\"Check if the file exists using 'ls -la'\",\n\t\t\t\t'Use --spec to provide the correct path',\n\t\t\t\t'For remote specs, ensure the URL is accessible',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tspecFetchFailed(\n\t\turl: string,\n\t\tstatusCode?: number,\n\t\tcause?: Error\n\t): ApicodegenError {\n\t\tconst message = statusCode\n\t\t\t? `Failed to fetch OpenAPI spec (HTTP ${statusCode})`\n\t\t\t: 'Failed to fetch OpenAPI spec from URL';\n\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.SPEC_FETCH_FAILED,\n\t\t\tmessage,\n\t\t\tlocation: url,\n\t\t\tsuggestions: [\n\t\t\t\t'Check if the URL is accessible in a browser',\n\t\t\t\t'Download the spec file locally and use the local path',\n\t\t\t\t'Verify CORS settings if fetching from a different origin',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tspecParseFailed(\n\t\tpath: string,\n\t\tline?: number,\n\t\tcolumn?: number,\n\t\tcause?: Error\n\t): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.SPEC_PARSE_FAILED,\n\t\t\tmessage: 'Failed to parse OpenAPI spec (invalid JSON or YAML)',\n\t\t\tlocation: path,\n\t\t\tline,\n\t\t\tcolumn,\n\t\t\tsuggestions: [\n\t\t\t\t'Validate JSON syntax using jsonlint.com',\n\t\t\t\t'For YAML specs, ensure proper indentation',\n\t\t\t\t'Check for trailing commas or unquoted special characters',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\toutputDirMissing(path: string, cause?: Error): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.OUTPUT_DIR_MISSING,\n\t\t\tmessage: 'Output directory does not exist',\n\t\t\tlocation: path,\n\t\t\tsuggestions: [\n\t\t\t\t'Create the directory: mkdir -p $(dirname <output>)',\n\t\t\t\t'Check if the path is correct',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tconfigInvalid(path: string, cause?: Error): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.CONFIG_INVALID,\n\t\t\tmessage: 'Invalid configuration file',\n\t\t\tlocation: path,\n\t\t\tsuggestions: [\n\t\t\t\t'Validate JSON syntax in the config file',\n\t\t\t\t'Check for required fields (spec, output)',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tvalidationFailed(\n\t\tpath: string,\n\t\tdetails: string,\n\t\tcause?: Error\n\t): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.VALIDATION_FAILED,\n\t\t\tmessage: 'OpenAPI spec validation failed',\n\t\t\tlocation: path,\n\t\t\tpath: details,\n\t\t\tsuggestions: [\n\t\t\t\t'Check OpenAPI spec structure at the specified path',\n\t\t\t\t'Ensure all required fields are present',\n\t\t\t\t'Validate using swagger.io editor',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tgenerationFailed(cause?: Error): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.GENERATION_FAILED,\n\t\t\tmessage: 'Code generation failed',\n\t\t\tsuggestions: [\n\t\t\t\t'Check for unsupported OpenAPI features',\n\t\t\t\t'Ensure spec follows OpenAPI 2.0, 3.0, or 3.1 specification',\n\t\t\t\t'Use --verbose for more details',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\ttypeCheckFailed(\n\t\tpath: string,\n\t\t_errors: string[],\n\t\tcause?: Error\n\t): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.TYPE_CHECK_FAILED,\n\t\t\tmessage: 'TypeScript type check failed',\n\t\t\tlocation: path,\n\t\t\tsuggestions: [\n\t\t\t\t...(_errors.length > 0 ? _errors : []),\n\t\t\t\t'Review type errors above',\n\t\t\t\t'Check for schema inconsistencies',\n\t\t\t\t'Update generated types or fix source schema',\n\t\t\t],\n\t\t\tcause,\n\t\t});\n\t},\n\n\tmissingRequiredField(field: string, context?: string): ApicodegenError {\n\t\treturn new ApicodegenError({\n\t\t\tcode: ErrorCodes.VALIDATION_FAILED,\n\t\t\tmessage: `Missing required field: ${field}`,\n\t\t\tpath: context,\n\t\t\tsuggestions: [`Add the '${field}' field to your configuration`],\n\t\t});\n\t},\n};\n\n/**\n * Wrap unknown error in ApicodegenError if needed\n */\nexport function wrapError(\n\terror: unknown,\n\tcontext?: Partial<ApicodegenErrorContext>\n): ApicodegenError {\n\tif (error instanceof ApicodegenError) {\n\t\treturn error;\n\t}\n\n\tif (error instanceof Error) {\n\t\treturn new ApicodegenError({\n\t\t\tcode: context?.code || ErrorCodes.GENERATION_FAILED,\n\t\t\tmessage: context?.message || error.message,\n\t\t\tlocation: context?.location,\n\t\t\tsuggestions: context?.suggestions,\n\t\t\tcause: error,\n\t\t});\n\t}\n\n\treturn new ApicodegenError({\n\t\tcode: context?.code || ErrorCodes.GENERATION_FAILED,\n\t\tmessage: String(error),\n\t\tsuggestions: context?.suggestions,\n\t});\n}\n\n/**\n * Check if error is an ApicodegenError\n */\nexport function isApicodegenError(error: unknown): error is ApicodegenError {\n\treturn error instanceof ApicodegenError;\n}\n","/**\n * @file Adapter abstract class definition\n * @author wp.l\n * @description Base adapter implementation for various code generation tools\n */\n\nimport type { Statement } from 'typescript';\nimport type { MediaTypeObject, ParameterObject } from '../interface.js';\n\n/**\n * Body shape used to encode the request payload.\n *\n * - `json` — `application/json` (or unknown textual type): serialise via `JSON.stringify`.\n * - `form-data` — `multipart/form-data` (or any request containing files): build `FormData`.\n * - `urlencoded` — `application/x-www-form-urlencoded`: build `URLSearchParams`.\n * - `binary` — single binary/blob parameter: pass the value directly.\n * - `none` — no body.\n */\nexport type BodyKind = 'json' | 'form-data' | 'urlencoded' | 'binary' | 'none';\n\n/**\n * Base adapter for tool\n * This abstract class serves as the foundation for implementing adapters for different code generation tools\n */\nexport abstract class Adapter {\n\t/**\n\t * @abstract The unique name/identifier for this adapter implementation\n\t */\n\tabstract readonly name: string;\n\n\t/**\n\t * @abstract The name of the field used to specify the HTTP method in API calls\n\t */\n\tabstract readonly methodFieldName: string;\n\n\t/**\n\t * @abstract The name of the field used to specify the request body in API calls\n\t */\n\tabstract readonly bodyFieldName: string;\n\n\t/**\n\t * @abstract The name of the field used to specify request headers in API calls\n\t */\n\tabstract readonly headersFieldName: string;\n\n\t/**\n\t * @abstract The name of the field used to specify query parameters in API calls\n\t */\n\tabstract readonly queryFieldName: string;\n\n\t/**\n\t * @abstract\n\t * @param {string} uri - The API endpoint URI\n\t * @param {string} method - The HTTP method (e.g., GET, POST, etc.)\n\t * @param {ParameterObject[]} parameters - An array of parameters for the API call\n\t * @param {MediaTypeObject | undefined} requestBody - The request body payload (if applicable)\n\t * @param {MediaTypeObject | undefined} response - The expected response format (if applicable)\n\t * @param {Adapter} adapter - An instance of the adapter being used\n\t * @param {BodyKind} bodyKind - How the request body should be encoded\n\t * @param {string | undefined} bodyContentType - The Content-Type header to set (undefined means \"let the runtime decide\", e.g. for multipart with boundary)\n\t * @param {boolean} useJSONResponse - Flag indicating whether the response should be parsed as JSON\n\t * @returns {Statement[]} An array of TypeScript AST statements representing the generated code\n\t */\n\tabstract client(\n\t\turi: string,\n\t\tmethod: string,\n\t\tparameters: ParameterObject[],\n\t\trequestBody: MediaTypeObject | undefined,\n\t\tresponse: MediaTypeObject | undefined,\n\t\tadapter: Adapter,\n\t\tbodyKind: BodyKind,\n\t\tbodyContentType: string | undefined,\n\t\tuseJSONResponse: boolean\n\t): Statement[];\n}\n","export const typescriptKeywords = new Set([\n\t'break',\n\t'case',\n\t'catch',\n\t'class',\n\t'const',\n\t'continue',\n\t'debugger',\n\t'default',\n\t'delete',\n\t'do',\n\t'else',\n\t'enum',\n\t'export',\n\t'extends',\n\t'false',\n\t'finally',\n\t'for',\n\t'function',\n\t'if',\n\t'import',\n\t'in',\n\t'instanceof',\n\t'new',\n\t'null',\n\t'return',\n\t'super',\n\t'switch',\n\t'this',\n\t'throw',\n\t'true',\n\t'try',\n\t'typeof',\n\t'var',\n\t'void',\n\t'while',\n\t'with',\n\t'as',\n\t'implements',\n\t'interface',\n\t'let',\n\t'package',\n\t'private',\n\t'protected',\n\t'public',\n\t'static',\n\t'yield',\n\t'abstract',\n\t'any',\n\t'async',\n\t'await',\n\t'constructor',\n\t'declare',\n\t'from',\n\t'get',\n\t'is',\n\t'module',\n\t'namespace',\n\t'never',\n\t'require',\n\t'set',\n\t'type',\n\t'unknown',\n\t'readonly',\n\t'of',\n\t'asserts',\n\t'infer',\n\t'keyof',\n\t'boolean',\n\t'number',\n\t'string',\n\t'symbol',\n\t'object',\n\t'undefined',\n\t'bigint',\n]);\n","/**\n * @file Base class implementation\n * @author wp.l\n * @description Base utility class providing common methods for code generation and API handling\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { Agent, request } from 'undici';\nimport { typescriptKeywords } from '../constants/keywords.js';\nimport { createErrors } from '../errors.js';\nimport type {\n\tEnumSchemaObject,\n\tFetchDocRequestInit,\n\tReferenceObject,\n\tSchemaObject,\n\tSingleTypeSchemaObject,\n} from '../interface.js';\nimport { MediaTypes } from '../interface.js';\n\n/**\n * Represents success HTTP status codes.\n * Each key is a string representation of a success HTTP status code.\n */\nexport const SuccessHttpStatusCode = {\n\t'200': '200', // OK\n\t'201': '201', // Created\n\t'202': '202', // Accepted\n\t'203': '203', // Non-Authoritative Information\n\t'204': '204', // No Content\n\t'205': '205', // Reset Content\n\t'206': '206', // Partial Content\n\t'207': '207', // Multi_Status\n\t'208': '208', // Already_Reported\n\t'226': '226', // IM Used\n};\n\n/**\n * Base abstract class providing common utility methods.\n */\nexport abstract class Base {\n\tprotected constructor() {\n\t\tif (new.target === Base) {\n\t\t\tthrow new Error('Cannot instantiate abstract class');\n\t\t}\n\t}\n\n\t/**\n\t * Converts a reference string to a meaningful name.\n\t * @param ref - The reference string to process.\n\t * @param [doc] - Optional document reference for context.\n\t * @returns - The processed name.\n\t */\n\tstatic ref2name(ref: string, doc?: any): string {\n\t\tconst paths = ref.replace(/^#/, '').split('/').filter(Boolean);\n\n\t\tif (!doc) {\n\t\t\treturn paths.slice(-1)[0];\n\t\t}\n\n\t\tlet temporary = doc as unknown;\n\t\tlet lastPath = '';\n\t\tfor (const path of paths) {\n\t\t\t// For handling path prefix with ~1\n\t\t\tconst adjustedPath = path.replaceAll('~1', '/');\n\t\t\ttemporary = (temporary as Record<string, any>)[adjustedPath];\n\t\t\tlastPath = adjustedPath;\n\t\t}\n\n\t\tif (!temporary) {\n\t\t\treturn 'unknown';\n\t\t}\n\n\t\treturn (temporary as unknown as { $ref: string }).$ref\n\t\t\t? Base.ref2name((temporary as unknown as { $ref: string }).$ref, doc)\n\t\t\t: lastPath;\n\t}\n\n\t/**\n\t * Converts an API path to a function name.\n\t * @param path - The API endpoint path.\n\t * @param [method] - The HTTP method (e.g., GET, POST).\n\t * @param [operationId] - Unique identifier for the operation.\n\t * @returns - The generated function name.\n\t */\n\tstatic pathToFnName(path: string, method?: string, operationId?: string) {\n\t\tlet name = '';\n\t\tlet keywordProtected = false;\n\t\tif (operationId) {\n\t\t\t// Detect TS-keyword protection: if the raw input (before normalize)\n\t\t\t// was a TS keyword, normalize appends '_' (e.g. 'delete' → 'delete_').\n\t\t\tkeywordProtected = typescriptKeywords.has(operationId);\n\t\t\tname = Base.camelCase(Base.normalize(operationId));\n\t\t}\n\t\tif (!name) {\n\t\t\tkeywordProtected = typescriptKeywords.has(path);\n\t\t\tname = Base.camelCase(Base.normalize(path));\n\t\t}\n\t\t// camelCase drops the trailing '_' that normalize added for keyword\n\t\t// protection. Re-append it so the generated identifier stays legal.\n\t\tif (keywordProtected && !name.endsWith('_')) {\n\t\t\tname = `${name}_`;\n\t\t}\n\n\t\tconst suffix = method\n\t\t\t? Base.capitalize(Base.upperCamelCase(`using_${method}`))\n\t\t\t: '';\n\n\t\treturn name + suffix;\n\t}\n\n\t/**\n\t * Normalizes a string by replacing special characters and avoiding TypeScript keywords.\n\t * @param text - Input text to normalize.\n\t * @returns - The normalized string.\n\t */\n\tstatic normalize(text: string) {\n\t\tif (typescriptKeywords.has(text)) {\n\t\t\ttext += '_';\n\t\t}\n\t\treturn (\n\t\t\ttext\n\t\t\t\t// Collapse `...` FIRST so the per-char replacement below doesn't\n\t\t\t\t// turn each '.' into '_' and miss the `...` pattern.\n\t\t\t\t.replaceAll('...', '')\n\t\t\t\t.replace(/[/\\-_{}():\\s`,*<>$#.]/gm, '_')\n\t\t\t\t.replace(/^\\d/gm, '')\n\t\t);\n\t}\n\n\t/**\n\t * Map a request body media type to a stable function-name suffix.\n\t *\n\t * Used to disambiguate sibling operations sharing the same path+method\n\t * but different request body media types. The result is appended (in\n\t * upperCamelCase) to the operation's base function name.\n\t *\n\t * Known types are mapped to short, human-readable names. Unknown types\n\t * fall back to `camelCase(normalize(<sub-type>))`.\n\t *\n\t * @param mediaType - The OpenAPI media type (e.g. `application/json`).\n\t * @returns - The suffix without leading underscore, or empty string.\n\t */\n\tstatic mediaTypeToSuffix(mediaType: string): string {\n\t\tconst known: Record<string, string> = {\n\t\t\t'application/json': 'Json',\n\t\t\t'multipart/form-data': 'FormData',\n\t\t\t'application/x-www-form-urlencoded': 'FormUrlencoded',\n\t\t\t'application/octet-stream': 'OctetStream',\n\t\t\t'text/plain': 'Text',\n\t\t\t'text/html': 'Html',\n\t\t\t'application/xml': 'Xml',\n\t\t\t'text/xml': 'Xml',\n\t\t};\n\t\tconst normalized = mediaType.toLowerCase().split(';')[0]?.trim() ?? '';\n\t\tif (known[normalized]) return known[normalized];\n\t\tconst sub = normalized.split('/')[1];\n\t\tif (!sub || sub === '*' || normalized === '*/*' || normalized === '') {\n\t\t\treturn '';\n\t\t}\n\t\treturn Base.upperCamelCase(Base.normalize(sub));\n\t}\n\n\t/**\n\t * Capitalizes the first character of a string.\n\t * @param text - Input string.\n\t * @returns - Capitalized string.\n\t */\n\tstatic capitalize(text: string) {\n\t\ttext = text.trim();\n\t\treturn `${text.charAt(0).toUpperCase()}${text.slice(1)}`;\n\t}\n\n\t/**\n\t * Converts a string to camelCase.\n\t * @param text - Input string.\n\t * @returns - CamelCase string.\n\t */\n\tstatic camelCase(text: string) {\n\t\ttext = text.trim();\n\t\tconst parts = text.split('_').filter(Boolean);\n\t\twhile (parts[0]?.match(/^\\d/)) {\n\t\t\tparts.shift();\n\t\t}\n\t\treturn parts\n\t\t\t.map((t, index) => (index === 0 ? t : Base.capitalize(t)))\n\t\t\t.join('');\n\t}\n\n\t/**\n\t * Converts a string to UpperCamelCase.\n\t * @param text - Input string.\n\t * @returns - UpperCamelCase string.\n\t */\n\tstatic upperCamelCase(text: string) {\n\t\treturn Base.normalize(text)\n\t\t\t.replaceAll('...', '')\n\t\t\t.split('_')\n\t\t\t.filter(Boolean)\n\t\t\t.map((part) => (part.match(/^\\d/) ? `N${part}` : Base.capitalize(part)))\n\t\t\t.join('');\n\t}\n\n\t/**\n\t * Classify a spec location string into a transport + source pair.\n\t *\n\t * Returns:\n\t * - `{ transport: 'file', source }` when `input` looks like a local\n\t * filesystem path (`file://...`, POSIX absolute, Windows absolute).\n\t * - `{ transport: 'http', source }` for `http(s)://...` URLs.\n\t *\n\t * Relative paths are treated as `http` so that callers (CLI / Vite\n\t * plugin) must resolve them against cwd first. This makes intent\n\t * explicit and avoids accidentally reading from process.cwd().\n\t */\n\tstatic resolveSpecURL(input: string): {\n\t\ttransport: 'file' | 'http';\n\t\tsource: string;\n\t} {\n\t\tif (input.startsWith('file://')) {\n\t\t\t// Strip the `file://` scheme. For a POSIX absolute path the URL\n\t\t\t// is `file:///abs/path` — after stripping `file://` we are left\n\t\t\t// with the correct absolute path `/abs/path`. For Windows the\n\t\t\t// URL is `file:///C:/spec.json`, which after stripping is\n\t\t\t// `/C:/spec.json`; drop the leading slash so the drive-letter\n\t\t\t// path is the canonical form.\n\t\t\tconst stripped = input.replace(/^file:\\/\\//, '');\n\t\t\treturn {\n\t\t\t\ttransport: 'file',\n\t\t\t\tsource: /^\\/[A-Za-z]:/.test(stripped) ? stripped.slice(1) : stripped,\n\t\t\t};\n\t\t}\n\n\t\t// POSIX absolute path\n\t\tif (input.startsWith('/')) return { transport: 'file', source: input };\n\t\t// Windows absolute path (e.g. `C:\\spec.json` or `C:/spec.json`)\n\t\tif (/^[A-Za-z]:[\\\\/]/.test(input))\n\t\t\treturn { transport: 'file', source: input };\n\n\t\treturn { transport: 'http', source: input };\n\t}\n\n\t/**\n\t * Read and parse a local OpenAPI document from the filesystem.\n\t *\n\t * @param filePath - Absolute filesystem path to the spec.\n\t * @returns - A promise resolving to the parsed document.\n\t */\n\tprivate static async readLocalDoc<T = unknown>(filePath: string): Promise<T> {\n\t\tlet raw: string;\n\t\ttry {\n\t\t\traw = await readFile(filePath, 'utf8');\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException)?.code === 'ENOENT') {\n\t\t\t\tthrow createErrors.specNotFound(filePath, error as Error);\n\t\t\t}\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to read OpenAPI spec from ${filePath}: ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\treturn JSON.parse(raw) as T;\n\t\t} catch (error) {\n\t\t\tthrow createErrors.specParseFailed(\n\t\t\t\tfilePath,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\terror as Error\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetches documentation from a given URL.\n\t *\n\t * Supports three transport modes:\n\t * - `file://...` URLs → read from filesystem (parsed as JSON)\n\t * - absolute filesystem paths → read from filesystem (parsed as JSON)\n\t * - `http(s)://...` URLs (and unrecognised inputs like relative paths)\n\t * → fetched via undici (existing behavior)\n\t *\n\t * Callers should pass an already-resolved absolute path or URL. Relative\n\t * paths fall through to undici by design — CLI / Vite plugin should\n\t * resolve them against cwd first.\n\t *\n\t * @param url - The URL or filesystem path to fetch the documentation from.\n\t * @param requestInit - Additional request parameters (only used for http(s)).\n\t * @returns - A promise resolving to the fetched documentation data.\n\t */\n\tstatic async fetchDoc<T = unknown>(\n\t\turl: string,\n\t\trequestInit: FetchDocRequestInit = {}\n\t): Promise<T> {\n\t\tconst { transport, source } = Base.resolveSpecURL(url);\n\t\tif (transport === 'file') {\n\t\t\treturn Base.readLocalDoc<T>(source);\n\t\t}\n\n\t\tconst agent = new Agent({\n\t\t\tconnect: { rejectUnauthorized: false },\n\t\t});\n\n\t\tconst { body, statusCode } = await request(source, {\n\t\t\tmethod: 'GET',\n\t\t\tdispatcher: agent,\n\t\t\t...requestInit,\n\t\t});\n\n\t\tif (statusCode >= 400) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch OpenAPI documentation from ${source}: HTTP ${statusCode}`\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\treturn body.json() as T;\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to parse JSON response from ${source}: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Determines the media type from a given media type string.\n\t * @param mediaType - The media type string to evaluate.\n\t * @returns - The matched MediaTypes or null.\n\t */\n\tstatic getMediaType(mediaType: string): MediaTypes | undefined {\n\t\tconst mediaTypeValues = Object.values(MediaTypes) as string[];\n\t\tconst found = mediaTypeValues.find((type) => mediaType.includes(type));\n\t\treturn found as MediaTypes | undefined;\n\t}\n\n\t/**\n\t * Checks if a schema is a valid enum type that isn't boolean.\n\t * @param a - The schema object to evaluate.\n\t * @returns - True if the schema is a valid non-boolean enum.\n\t */\n\tstatic isValidEnumType(a: SchemaObject) {\n\t\treturn a.type !== 'boolean' && !Base.isBooleanEnum(a);\n\t}\n\n\t/**\n\t * Checks if a schema represents a boolean enum.\n\t * @param a - The schema object to evaluate.\n\t * @returns - True if the schema is a boolean enum.\n\t */\n\tstatic isBooleanEnum(a: SchemaObject) {\n\t\treturn (\n\t\t\ta.type === 'boolean' ||\n\t\t\t!!(a as SingleTypeSchemaObject).enum?.some(\n\t\t\t\t(member) => typeof member === 'boolean'\n\t\t\t)\n\t\t);\n\t}\n\n\t/**\n\t * Checks if two enum schemas are identical.\n\t * @param a - First enum schema to compare.\n\t * @param b - Second enum schema to compare.\n\t * @returns - True if the enums are identical.\n\t */\n\tprivate static isSameEnum(a: EnumSchemaObject, b: EnumSchemaObject) {\n\t\treturn (\n\t\t\ta.enum.length === b.enum.length &&\n\t\t\ta.enum.sort().every((v, index) => v === b.enum.sort()[index])\n\t\t);\n\t}\n\n\t/**\n\t * Filters out duplicate enum schemas from an array.\n\t * @param enums - Array of enum schemas to process.\n\t * @returns - Array of unique enum schemas.\n\t */\n\tstatic uniqueEnums(enums: EnumSchemaObject[]): EnumSchemaObject[] {\n\t\tconst enumMap = new Map<string, Set<string | number>>();\n\n\t\tfor (const e of enums) {\n\t\t\tconst existing = enumMap.get(e.name);\n\t\t\tif (existing) {\n\t\t\t\t// Merge enum values with the same name\n\t\t\t\tfor (const value of e.enum) {\n\t\t\t\t\texisting.add(value);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tenumMap.set(e.name, new Set(e.enum));\n\t\t\t}\n\t\t}\n\n\t\t// Convert back to array\n\t\treturn Array.from(enumMap.entries()).map(([name, values]) => ({\n\t\t\tname,\n\t\t\tenum: Array.from(values),\n\t\t}));\n\t}\n\n\t/**\n\t * Finds the first occurrence of a matching enum schema in an array.\n\t * @param a - The enum schema to find.\n\t * @param enums - Array of enum schemas to search.\n\t * @returns - The found schema or undefined.\n\t */\n\tstatic findSameSchema(a: EnumSchemaObject, enums: EnumSchemaObject[]) {\n\t\treturn enums.find((b) => Base.isSameEnum(b, a));\n\t}\n\n\t/**\n\t * Checks if an object is a reference object.\n\t * @param schema - The object to check.\n\t * @returns - True if the object is a reference.\n\t */\n\n\tstatic isRef(schema: unknown): schema is ReferenceObject {\n\t\treturn (\n\t\t\ttypeof schema === 'object' &&\n\t\t\tschema !== null &&\n\t\t\t'$ref' in schema &&\n\t\t\ttypeof (schema as Record<string, unknown>).$ref === 'string'\n\t\t);\n\t}\n}\n","/**\n * @file Base class implementation\n * @author wp.l\n * @description This file defines the `Provider` abstract class, which serves as a base for providers responsible for parsing and processing API documentation.\n */\n\nimport type {\n\tEnumSchemaObject,\n\tFetchDocRequestInit,\n\tOperationObject,\n\tParameterObject,\n\tProviderInitOptions,\n\tProviderInitResult,\n\tRequestBodyObject,\n\tResponsesObject,\n\tSchemaObject,\n} from '../interface.js';\n\n/**\n * Abstract Provider Class.\n *\n * The Provider class is designed to be extended by specific implementations (e.g., OpenAPI 2 provider, OpenAPI 3 provider).\n * It handles the initialization of the provider and the parsing of documentation into structured data.\n *\n * @example\n *\n * ```ts\n * /// Example of how this class might be used by a subclass:\n * class OpenAPIProvider extends Provider {\n * /// Implement the parse method to handle OpenAPI-specific documentation parsing.\n * parse(doc: unknown): ProviderInitResult {\n * /// Implementation details...\n * }\n * }\n *\n * /// Initializing a provider with configuration and documentation data:\n * const initOptions: ProviderInitOptions = {\n * docURL: \"https://example.com/api/swagger.json\",\n * baseURL: \"https://api.example.com\",\n * output: \"./generated\",\n * requestOptions: {\n * headers: { \"Content-Type\": \"application/json\" },\n * },\n * importClientSource: \"generated/client\",\n * };\n *\n * const docData = fetchSwaggerDoc();\n * const provider = new OpenAPIProvider(initOptions, docData);\n * ```\n */\nexport abstract class Provider\n\timplements ProviderInitResult, ProviderInitOptions\n{\n\t/** collection of enum schemas */\n\treadonly enums: EnumSchemaObject[] = [];\n\t/** collection of schemas indexed by name */\n\treadonly schemas: Record<string, SchemaObject> = {};\n\t/** collection of parameters indexed by name */\n\treadonly parameters: Record<string, ParameterObject> = {};\n\t/** collection of API responses indexed by name */\n\treadonly responses: Record<string, ResponsesObject> = {};\n\t/** collection of request bodies indexed by name */\n\treadonly requestBodies: Record<string, RequestBodyObject> = {};\n\t/** collection of API endpoints (operations) indexed by path */\n\treadonly apis: Record<string, OperationObject[]> = {};\n\n\t/** URL for fetching API documentation */\n\treadonly docURL: string;\n\t/** base URL for API endpoints */\n\treadonly baseURL: string;\n\t/** output directory for generated code */\n\treadonly output: string;\n\t/** request options for API documentation fetch */\n\treadonly requestOptions: FetchDocRequestInit;\n\t/** source path for imported client */\n\treadonly importClientSource: string;\n\n\t/**\n\t * Provider Constructor.\n\t * @param {ProviderInitOptions} initOptions - Initial configuration for the provider.\n\t * @param {unknown} doc - Raw API documentation data to be parsed.\n\t */\n\tconstructor(initOptions: ProviderInitOptions, doc: unknown) {\n\t\tthis.docURL = initOptions.docURL;\n\t\tthis.baseURL = initOptions.baseURL ?? '';\n\t\tthis.output = initOptions.output ?? '.';\n\t\tthis.requestOptions = initOptions.requestOptions ?? {};\n\t\tthis.importClientSource = initOptions.importClientSource ?? '';\n\n\t\tconst { enums, schemas, requestBodies, responses, parameters, apis } =\n\t\t\tthis.parse(doc);\n\n\t\tthis.enums = enums;\n\t\tthis.schemas = schemas;\n\t\tthis.responses = responses;\n\t\tthis.parameters = parameters;\n\t\tthis.requestBodies = requestBodies;\n\t\tthis.apis = apis;\n\t}\n\n\t/**\n\t * Abstract Parse Method.\n\t * @abstract\n\t * @param {unknown} doc - Raw API documentation data.\n\t * @returns {ProviderInitResult} - Parsed documentation data.\n\t *\n\t * This method must be implemented by subclasses to parse the raw documentation into structured data.\n\t */\n\tabstract parse(doc: unknown): ProviderInitResult;\n}\n","/**\n * Create a per-generation unique-name resolver.\n *\n * Tracks how many times each base name has been seen during a single\n * code generation pass and returns a unique variant on every call:\n *\n * reserve('foo') // 'foo'\n * reserve('foo') // 'foo2'\n * reserve('foo') // 'foo3'\n * reserve('bar') // 'bar' (independent counter)\n *\n * The resolver holds no module-level state — create one per generation pass\n * and let it go out of scope when the pass completes.\n */\nexport const createUniqueNameResolver = (): ((name: string) => string) => {\n\tconst seen = new Map<string, number>();\n\n\treturn (name: string): string => {\n\t\tconst next = (seen.get(name) ?? 0) + 1;\n\t\tseen.set(name, next);\n\t\treturn next === 1 ? name : `${name}${next}`;\n\t};\n};\n","/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */\n/* eslint-disable no-case-declarations */\n\nimport { writeFile } from 'node:fs/promises';\nimport { format } from 'prettier';\nimport type {\n\tBindingElement,\n\tBlock,\n\tNode,\n\tParameterDeclaration,\n\tPropertySignature,\n\tStatement,\n\tTypeNode,\n} from 'typescript';\nimport {\n\taddSyntheticLeadingComment,\n\tcreatePrinter,\n\tEmitHint,\n\tNodeFlags,\n\tScriptTarget,\n\tSyntaxKind,\n\tfactory as t,\n} from 'typescript';\nimport type { Adapter, BodyKind } from '../base/Adaptor.js';\nimport { Base } from '../base/Base.js';\nimport type {\n\tArrayTypeSchemaObject,\n\tMediaTypeObject,\n\tParameterObject,\n\tProviderInitOptions,\n\tProviderInitResult,\n\tSchemaObject,\n\tSingleTypeSchemaObject,\n} from '../interface.js';\nimport {\n\tArraySchemaType,\n\tMediaTypes,\n\tNonArraySchemaType,\n\tParameterIn,\n\tSchemaFormatType,\n} from '../interface.js';\nimport { createUniqueNameResolver } from './naming.js';\n\n/**\n * Represents a comment object with optional tag and message.\n */\nexport type CommentObject = {\n\ttag?: 'deprecated' | 'param' | 'returns';\n\tcomment: string;\n\tparamName?: string;\n\ttype?: string;\n};\n\n/**\n * Array of comment objects to be added to the code.\n */\nexport type Comments = CommentObject[];\n\nexport class Generator {\n\t/**\n\t * Converts an array of TypeScript statements into a formatted string of code.\n\t *\n\t * @param statements - The array of TypeScript statement nodes.\n\t * @returns Formatted code as a string.\n\t * @throws {Error} If no valid statements are provided.\n\t */\n\tstatic toCode(statements: Statement[]): string {\n\t\tif (statements.length === 0) {\n\t\t\treturn '// No api declaration found.';\n\t\t}\n\n\t\tconst sourceFile = t.createSourceFile(\n\t\t\tstatements,\n\t\t\tt.createToken(SyntaxKind.EndOfFileToken),\n\t\t\tNodeFlags.None\n\t\t);\n\n\t\treturn createPrinter().printFile(sourceFile);\n\t}\n\n\tstatic async write(code: string, filepath: string) {\n\t\ttry {\n\t\t\tawait writeFile(filepath, code);\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t}\n\n\t/**\n\t * Converts a path string with parameters into a TypeScript template expression.\n\t * Handles query parameters and path placeholders.\n\t *\n\t * @param path - The base path string containing placeholders.\n\t * @param parameters - Array of parameter objects defining the parameters.\n\t * @param basePath - Optional base path to prepend (default: \"\").\n\t * @returns A TypeScript template expressi\n\t */\n\tstatic toUrlTemplate(\n\t\tpath: string,\n\t\tparameters: ParameterObject[],\n\t\tbasePath = ''\n\t) {\n\t\t// Extract query parameters\n\t\tconst queryParameters = parameters.filter(\n\t\t\t(p) => p.in === ParameterIn.query\n\t\t);\n\n\t\tif (queryParameters.length > 0) {\n\t\t\tconst queryString = queryParameters\n\t\t\t\t.map(\n\t\t\t\t\t(qp, index) =>\n\t\t\t\t\t\t`${index === 0 ? '?' : '&'}${encodeURIComponent(qp.name)}={${Base.camelCase(Base.normalize(qp.name))}}`\n\t\t\t\t)\n\t\t\t\t.join('');\n\t\t\tpath += queryString;\n\t\t}\n\n\t\t// Split the path into segments\n\t\tconst pathSegments = path.replaceAll('{', '${').split('$').filter(Boolean);\n\n\t\t// If path segments only got one item, it means there are no parameters in path. So just return the path literal.\n\t\tif (pathSegments.length === 1) {\n\t\t\treturn t.createNoSubstitutionTemplateLiteral(basePath + path);\n\t\t}\n\n\t\treturn t.createTemplateExpression(\n\t\t\tt.createTemplateHead(basePath + pathSegments[0]),\n\t\t\tpathSegments.slice(1).map((segment, index) => {\n\t\t\t\tconst match = /^{(.+)}(.+)?/gm.exec(segment);\n\t\t\t\tconst isLastSegment = index === pathSegments.length - 2;\n\n\t\t\t\tif (!match) {\n\t\t\t\t\tthrow new Error(`Invalid path segment: ${segment}`);\n\t\t\t\t}\n\n\t\t\t\treturn t.createTemplateSpan(\n\t\t\t\t\tt.createIdentifier(match[1]),\n\t\t\t\t\t!isLastSegment\n\t\t\t\t\t\t? t.createTemplateMiddle(match[2])\n\t\t\t\t\t\t: t.createTemplateTail(match[2] || '')\n\t\t\t\t);\n\t\t\t})\n\t\t);\n\t}\n\n\t/**\n\t * Adds synthetic comments to a TypeScript AST node.\n\t *\n\t * @param node - The target AST node.\n\t * @param comments - Array of comment objects to add.\n\t */\n\tstatic addComments(node: Node, comments: Comments) {\n\t\tif (!Array.isArray(comments) || comments.filter(Boolean).length === 0)\n\t\t\treturn;\n\n\t\tconst formatComment = (comment: CommentObject): string => {\n\t\t\tif (comment.tag === 'returns') {\n\t\t\t\treturn `* @returns {${comment.type}} ${comment.comment ?? ''}`;\n\t\t\t}\n\t\t\tif (comment.tag === 'param') {\n\t\t\t\tconst typePart = comment.type ? `{${comment.type}} ` : '';\n\t\t\t\treturn comment.comment\n\t\t\t\t\t? `* @param ${typePart}${comment.paramName} - ${comment.comment}`\n\t\t\t\t\t: `* @param ${typePart}${comment.paramName}`;\n\t\t\t}\n\t\t\tif (comment.tag) {\n\t\t\t\treturn `* @${comment.tag} ${comment.comment ?? ''}`;\n\t\t\t}\n\t\t\treturn `* ${comment.comment}`;\n\t\t};\n\n\t\tconst formattedComments =\n\t\t\tcomments.map(formatComment).join('\\n').trim() + '\\n';\n\n\t\taddSyntheticLeadingComment(\n\t\t\tnode,\n\t\t\tSyntaxKind.MultiLineCommentTrivia,\n\t\t\tformattedComments,\n\t\t\ttrue\n\t\t);\n\t}\n\n\t/**\n\t * Checks if a schema represents a binary type.\n\t *\n\t * @param schema - The schema object to check.\n\t * @returns true if the schema is a binary type, false otherwise.\n\t */\n\tstatic isBinarySchema(schema: SchemaObject): boolean {\n\t\tif (schema.type === 'array') {\n\t\t\tconst arraySchema = schema as ArrayTypeSchemaObject;\n\t\t\treturn Generator.isBinarySchema(arraySchema.items!);\n\t\t}\n\n\t\tconst nonArraySchema = schema as SingleTypeSchemaObject;\n\t\treturn (\n\t\t\tnonArraySchema.format === SchemaFormatType.blob ||\n\t\t\tnonArraySchema.format === SchemaFormatType.binary ||\n\t\t\tnonArraySchema.type === SchemaFormatType.file\n\t\t);\n\t}\n\n\tstatic schemaToTypeString(schema: SchemaObject): string {\n\t\tif (schema.type === 'array') {\n\t\t\tconst arraySchema = schema as ArrayTypeSchemaObject;\n\t\t\treturn arraySchema.items\n\t\t\t\t? `${Generator.schemaToTypeString(arraySchema.items)}[]`\n\t\t\t\t: 'unknown';\n\t\t}\n\t\tconst singleSchema = schema as SingleTypeSchemaObject;\n\t\tif (schema.type === 'string') return 'string';\n\t\tif (schema.type === 'number' || schema.type === 'integer') return 'number';\n\t\tif (schema.type === 'boolean') return 'boolean';\n\t\tif (\n\t\t\tschema.type === 'object' ||\n\t\t\t(schema as SingleTypeSchemaObject).properties\n\t\t)\n\t\t\treturn 'object';\n\t\tif (singleSchema.format === 'binary' || singleSchema.type === 'file')\n\t\t\treturn 'Blob';\n\t\tif (singleSchema.format === 'blob') return 'Blob';\n\t\tif (singleSchema.ref) return singleSchema.ref;\n\t\treturn 'unknown';\n\t}\n\n\tstatic generateParamTags(\n\t\tparameters: ParameterObject[],\n\t\trequestBody?: MediaTypeObject\n\t): CommentObject[] {\n\t\tconst tags: CommentObject[] = [];\n\n\t\tfor (const p of parameters) {\n\t\t\tconst paramName = Base.camelCase(Base.normalize(p.name));\n\t\t\tlet paramType = 'unknown';\n\n\t\t\tif (p.schema) {\n\t\t\t\tparamType = Generator.schemaToTypeString(p.schema);\n\t\t\t}\n\n\t\t\tconst isOptional = p.required === false;\n\t\t\tconst inPrefix = p.in ? `[${p.in}] ` : '';\n\t\t\ttags.push({\n\t\t\t\ttag: 'param',\n\t\t\t\tparamName: paramName,\n\t\t\t\ttype: `${paramType}${isOptional ? ' | undefined' : ''}`,\n\t\t\t\tcomment: `${inPrefix}${p.description ?? ''}`,\n\t\t\t});\n\t\t}\n\n\t\tif (requestBody?.schema && 'properties' in requestBody.schema) {\n\t\t\tconst properties = requestBody.schema.properties as Record<\n\t\t\t\tstring,\n\t\t\t\tSchemaObject\n\t\t\t>;\n\t\t\tconst required = requestBody.schema.required;\n\t\t\tconst requiredArray = Array.isArray(required) ? required : [];\n\t\t\tfor (const [key, schema] of Object.entries(properties ?? {})) {\n\t\t\t\tconst paramName = `req.${key}`;\n\t\t\t\tconst paramType = Generator.schemaToTypeString(schema);\n\t\t\t\tconst isOptional = !requiredArray.includes(key);\n\t\t\t\ttags.push({\n\t\t\t\t\ttag: 'param',\n\t\t\t\t\tparamName: paramName,\n\t\t\t\t\ttype: `${paramType}${isOptional ? ' | undefined' : ''}`,\n\t\t\t\t\tcomment: schema.description ?? '',\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn tags;\n\t}\n\n\tstatic toRequestBodyTypeNode(schema: SchemaObject) {\n\t\treturn t.createParameterDeclaration(\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tt.createIdentifier('req'),\n\t\t\tundefined,\n\t\t\tGenerator.toTypeNode(schema)\n\t\t);\n\t}\n\n\tstatic toTypeNode(schema: SchemaObject): TypeNode {\n\t\tconst { type, ref } = schema;\n\n\t\tif (ref) {\n\t\t\tconst identify = Base.ref2name(ref);\n\t\t\treturn t.createTypeReferenceNode(\n\t\t\t\tt.createIdentifier(\n\t\t\t\t\tidentify === 'unknown' ? identify : Base.upperCamelCase(identify)\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tswitch (type) {\n\t\t\tcase ArraySchemaType.array: {\n\t\t\t\tconst { items } = schema as ArrayTypeSchemaObject;\n\t\t\t\treturn t.createArrayTypeNode(Generator.toTypeNode(items!));\n\t\t\t}\n\t\t\tcase NonArraySchemaType.object: {\n\t\t\t\tconst propsCount = Object.keys(schema.properties ?? {}).length;\n\t\t\t\tif (!schema.properties || propsCount === 0) {\n\t\t\t\t\treturn t.createTypeReferenceNode(t.createIdentifier('Record'), [\n\t\t\t\t\t\tt.createToken(SyntaxKind.StringKeyword),\n\t\t\t\t\t\tt.createToken(SyntaxKind.UnknownKeyword),\n\t\t\t\t\t]);\n\t\t\t\t}\n\n\t\t\t\tconst props = Object.keys(schema.properties);\n\t\t\t\t// A property is required only when listed in the parent\n\t\t\t\t// schema's `required` array (#44).\n\t\t\t\tconst required = Array.isArray(schema.required) ? schema.required : [];\n\n\t\t\t\treturn t.createTypeLiteralNode(\n\t\t\t\t\tprops.map((propKey) => {\n\t\t\t\t\t\tconst propSchema = schema.properties![propKey];\n\t\t\t\t\t\treturn t.createPropertySignature(\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tt.createStringLiteral(propKey),\n\t\t\t\t\t\t\trequired.includes(propKey)\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: t.createToken(SyntaxKind.QuestionToken),\n\t\t\t\t\t\t\tGenerator.toTypeNode(propSchema)\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase NonArraySchemaType.integer:\n\t\t\tcase NonArraySchemaType.number:\n\t\t\t\tif (schema.enum) {\n\t\t\t\t\treturn t.createUnionTypeNode(\n\t\t\t\t\t\tschema.enum.map((e) =>\n\t\t\t\t\t\t\tt.createLiteralTypeNode(t.createNumericLiteral(e))\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn t.createToken(SyntaxKind.NumberKeyword);\n\t\t\tcase NonArraySchemaType.boolean:\n\t\t\t\treturn t.createToken(SyntaxKind.BooleanKeyword);\n\t\t\tcase NonArraySchemaType.file:\n\t\t\t\treturn t.createTypeReferenceNode(t.createIdentifier('Blob'));\n\t\t\tdefault: {\n\t\t\t\tconst {\n\t\t\t\t\tformat,\n\t\t\t\t\toneOf,\n\t\t\t\t\tallOf,\n\t\t\t\t\tanyOf,\n\t\t\t\t\ttype,\n\t\t\t\t\tenum: enum_,\n\t\t\t\t} = schema as SingleTypeSchemaObject;\n\n\t\t\t\tswitch (format) {\n\t\t\t\t\tcase SchemaFormatType.number:\n\t\t\t\t\t\treturn t.createToken(SyntaxKind.NumberKeyword);\n\t\t\t\t\tcase SchemaFormatType.string:\n\t\t\t\t\t\treturn t.createToken(SyntaxKind.StringKeyword);\n\t\t\t\t\tcase SchemaFormatType.boolean:\n\t\t\t\t\t\treturn t.createToken(SyntaxKind.BooleanKeyword);\n\t\t\t\t\tcase SchemaFormatType.blob:\n\t\t\t\t\tcase SchemaFormatType.binary:\n\t\t\t\t\t\treturn t.createTypeReferenceNode(t.createIdentifier('Blob'));\n\t\t\t\t\tdefault:\n\t\t\t\t}\n\n\t\t\t\tif (enum_) {\n\t\t\t\t\treturn t.createUnionTypeNode(\n\t\t\t\t\t\tenum_.map((e) =>\n\t\t\t\t\t\t\tt.createLiteralTypeNode(t.createStringLiteral(e as string))\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (type === NonArraySchemaType.string) {\n\t\t\t\t\treturn t.createToken(SyntaxKind.StringKeyword);\n\t\t\t\t}\n\n\t\t\t\tif (oneOf) {\n\t\t\t\t\tconst uniqueTypes = Generator.deduplicateTypes(\n\t\t\t\t\t\toneOf.map((s) => Generator.toTypeNode(s))\n\t\t\t\t\t);\n\t\t\t\t\treturn t.createUnionTypeNode(uniqueTypes);\n\t\t\t\t}\n\n\t\t\t\tif (anyOf) {\n\t\t\t\t\tconst uniqueTypes = Generator.deduplicateTypes(\n\t\t\t\t\t\tanyOf.map((s) => Generator.toTypeNode(s))\n\t\t\t\t\t);\n\t\t\t\t\treturn t.createUnionTypeNode(uniqueTypes);\n\t\t\t\t}\n\n\t\t\t\tif (allOf) {\n\t\t\t\t\treturn t.createIntersectionTypeNode(\n\t\t\t\t\t\tallOf.map((schema) => Generator.toTypeNode(schema))\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (type && typeof type === 'string') {\n\t\t\t\t\treturn t.createTypeReferenceNode(\n\t\t\t\t\t\ttype !== 'unknown' && type !== 'null'\n\t\t\t\t\t\t\t? t.createIdentifier(Base.upperCamelCase(type))\n\t\t\t\t\t\t\t: type\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn t.createToken(SyntaxKind.UnknownKeyword);\n\t}\n\n\tstatic deduplicateTypes(types: TypeNode[]): TypeNode[] {\n\t\tconst seen = new Set<string>();\n\t\tconst unique: TypeNode[] = [];\n\t\tfor (const type of types) {\n\t\t\tconst key = Generator.getTypeNodeKey(type);\n\t\t\tif (!seen.has(key)) {\n\t\t\t\tseen.add(key);\n\t\t\t\tunique.push(type);\n\t\t\t}\n\t\t}\n\t\treturn unique;\n\t}\n\n\tstatic getTypeNodeKey(type: TypeNode): string {\n\t\treturn JSON.stringify(type);\n\t}\n\n\tstatic toDeclarationNodes(\n\t\tparameters: ParameterObject[]\n\t): ParameterDeclaration[] {\n\t\tconst objectElements: BindingElement[] = [];\n\t\tconst typeObjectElements: PropertySignature[] = [];\n\t\tconst refParameters: ParameterDeclaration[] = [];\n\n\t\tfor (const parameter of parameters) {\n\t\t\tif (parameter.ref) {\n\t\t\t\t// Handle reference parameters as standalone parameters\n\t\t\t\tconst refName = Base.ref2name(parameter.ref);\n\t\t\t\trefParameters.push(\n\t\t\t\t\tt.createParameterDeclaration(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createIdentifier(Base.camelCase(Base.normalize(refName))),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createTypeReferenceNode(\n\t\t\t\t\t\t\tt.createIdentifier(Base.upperCamelCase(Base.normalize(refName)))\n\t\t\t\t\t\t),\n\t\t\t\t\t\tundefined\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst { name, schema, required } = parameter;\n\t\t\t\tobjectElements.push(\n\t\t\t\t\tt.createBindingElement(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createIdentifier(Base.camelCase(Base.normalize(name)))\n\t\t\t\t\t)\n\t\t\t\t);\n\n\t\t\t\ttypeObjectElements.push(\n\t\t\t\t\tt.createPropertySignature(\n\t\t\t\t\t\t[],\n\t\t\t\t\t\tt.createIdentifier(Base.camelCase(Base.normalize(name))),\n\t\t\t\t\t\trequired ? undefined : t.createToken(SyntaxKind.QuestionToken),\n\t\t\t\t\t\t!schema\n\t\t\t\t\t\t\t? t.createToken(SyntaxKind.UnknownKeyword)\n\t\t\t\t\t\t\t: Generator.toTypeNode(schema)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Build object destructuring parameter for non-ref parameters\n\t\tif (objectElements.length > 0) {\n\t\t\tconst objectParam = t.createParameterDeclaration(\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tt.createObjectBindingPattern(objectElements),\n\t\t\t\tundefined,\n\t\t\t\tt.createTypeLiteralNode(typeObjectElements),\n\t\t\t\tundefined\n\t\t\t);\n\t\t\treturn [objectParam, ...refParameters];\n\t\t}\n\n\t\treturn refParameters;\n\t}\n\n\tstatic toFormDataStatement(\n\t\tparameters: ParameterObject[],\n\t\trequestBody?: SchemaObject\n\t): Statement[] {\n\t\tconst statements: Statement[] = [];\n\t\tconst fdDeclaration = t.createVariableStatement(\n\t\t\tundefined,\n\t\t\tt.createVariableDeclarationList(\n\t\t\t\t[\n\t\t\t\t\tt.createVariableDeclaration(\n\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createNewExpression(t.createIdentifier('FormData'), undefined, [])\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tNodeFlags.Const\n\t\t\t)\n\t\t);\n\n\t\tstatements.push(fdDeclaration);\n\n\t\tparameters.forEach((parameter) => {\n\t\t\tstatements.push(\n\t\t\t\tt.createExpressionStatement(\n\t\t\t\t\tt.createBinaryExpression(\n\t\t\t\t\t\tt.createIdentifier(parameter.name),\n\t\t\t\t\t\tt.createToken(SyntaxKind.AmpersandAmpersandToken),\n\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tt.createStringLiteral(parameter.name),\n\t\t\t\t\t\t\t\tt.createIdentifier(parameter.name),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t});\n\n\t\tif (\n\t\t\trequestBody &&\n\t\t\trequestBody.type === 'object' &&\n\t\t\trequestBody.properties &&\n\t\t\tObject.keys(requestBody.properties).length !== 0\n\t\t) {\n\t\t\tObject.keys(requestBody.properties).forEach((key) => {\n\t\t\t\tconst schemaByKey = requestBody.properties![key];\n\t\t\t\tif (\n\t\t\t\t\tschemaByKey.type === ArraySchemaType.array &&\n\t\t\t\t\tGenerator.isBinarySchema(schemaByKey)\n\t\t\t\t) {\n\t\t\t\t\tstatements.push(\n\t\t\t\t\t\tt.createForOfStatement(\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tt.createVariableDeclarationList(\n\t\t\t\t\t\t\t\t[t.createVariableDeclaration('file')],\n\t\t\t\t\t\t\t\tNodeFlags.Const\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tt.createBlock([\n\t\t\t\t\t\t\t\tt.createExpressionStatement(\n\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key),\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('file'),\n\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\tt.createAsExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('file'),\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createTypeReferenceNode(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('File'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('name')\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tif (schemaByKey.required) {\n\t\t\t\t\t\tstatements.push(\n\t\t\t\t\t\t\tt.createExpressionStatement(\n\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key),\n\t\t\t\t\t\t\t\t\t\tschemaByKey.type === 'string' ||\n\t\t\t\t\t\t\t\t\t\tGenerator.isBinarySchema(schemaByKey as SchemaObject) ||\n\t\t\t\t\t\t\t\t\t\t(schemaByKey as SingleTypeSchemaObject).isRef\n\t\t\t\t\t\t\t\t\t\t\t? t.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t: schemaByKey.type === 'array' ||\n\t\t\t\t\t\t\t\t\t\t\t\t\tschemaByKey.type === 'object'\n\t\t\t\t\t\t\t\t\t\t\t\t? t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('JSON'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('stringify')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t: t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('String'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstatements.push(\n\t\t\t\t\t\t\tt.createExpressionStatement(\n\t\t\t\t\t\t\t\tt.createBinaryExpression(\n\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tt.createToken(SyntaxKind.AmpersandAmpersandToken),\n\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('fd'),\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key),\n\t\t\t\t\t\t\t\t\t\t\tschemaByKey.type === 'string' ||\n\t\t\t\t\t\t\t\t\t\t\tGenerator.isBinarySchema(schemaByKey as SchemaObject) ||\n\t\t\t\t\t\t\t\t\t\t\t(schemaByKey as SingleTypeSchemaObject).isRef\n\t\t\t\t\t\t\t\t\t\t\t\t? t.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t: schemaByKey.type === 'array' ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tschemaByKey.type === 'object'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('JSON'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('stringify')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t: t.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('String'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createElementAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn statements;\n\t}\n\n\t/**\n\t * Build statements that construct a `URLSearchParams` from request body\n\t * fields for an `application/x-www-form-urlencoded` request.\n\t *\n\t * Skips `undefined` / `null` values so optional fields don't end up as\n\t * the literal string `\"undefined\"` in the URL (fixes #8).\n\t *\n\t * The resulting `sp` variable is referenced by the adapter as the\n\t * `body` payload.\n\t */\n\tstatic toURLSearchParamsStatement(\n\t\tparameters: ParameterObject[],\n\t\trequestBody?: SchemaObject\n\t): Statement[] {\n\t\tconst statements: Statement[] = [];\n\t\tconst spDeclaration = t.createVariableStatement(\n\t\t\tundefined,\n\t\t\tt.createVariableDeclarationList(\n\t\t\t\t[\n\t\t\t\t\tt.createVariableDeclaration(\n\t\t\t\t\t\tt.createIdentifier('sp'),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tt.createNewExpression(\n\t\t\t\t\t\t\tt.createIdentifier('URLSearchParams'),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[]\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tNodeFlags.Const\n\t\t\t)\n\t\t);\n\t\tstatements.push(spDeclaration);\n\n\t\tconst appendValue = (\n\t\t\tkey: string,\n\t\t\tvalueExpr: import('typescript').Expression\n\t\t): Statement =>\n\t\t\tt.createExpressionStatement(\n\t\t\t\tt.createCallExpression(\n\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\tt.createIdentifier('sp'),\n\t\t\t\t\t\tt.createIdentifier('append')\n\t\t\t\t\t),\n\t\t\t\t\tundefined,\n\t\t\t\t\t[t.createStringLiteral(key), valueExpr]\n\t\t\t\t)\n\t\t\t);\n\n\t\t// Body-level fields.\n\t\tif (\n\t\t\trequestBody &&\n\t\t\trequestBody.type === 'object' &&\n\t\t\trequestBody.properties &&\n\t\t\tObject.keys(requestBody.properties).length !== 0\n\t\t) {\n\t\t\tfor (const key of Object.keys(requestBody.properties)) {\n\t\t\t\tconst fieldSchema = requestBody.properties[key];\n\t\t\t\tconst required = !!fieldSchema.required;\n\t\t\t\tconst accessor = t.createElementAccessExpression(\n\t\t\t\t\tt.createIdentifier('req'),\n\t\t\t\t\tt.createStringLiteral(key)\n\t\t\t\t);\n\t\t\t\tconst stringValue = Generator.toFormDataCompatibleString(\n\t\t\t\t\taccessor,\n\t\t\t\t\tfieldSchema\n\t\t\t\t);\n\t\t\t\tconst append = appendValue(key, stringValue);\n\t\t\t\tif (required) {\n\t\t\t\t\tstatements.push(append);\n\t\t\t\t} else {\n\t\t\t\t\t// Skip nullish values.\n\t\t\t\t\tstatements.push(\n\t\t\t\t\t\tt.createIfStatement(\n\t\t\t\t\t\t\tt.createBinaryExpression(\n\t\t\t\t\t\t\t\taccessor,\n\t\t\t\t\t\t\t\tt.createToken(SyntaxKind.ExclamationEqualsToken),\n\t\t\t\t\t\t\t\tt.createToken(SyntaxKind.NullKeyword)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tt.createBlock([append], true)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Standalone query-style parameters (rare for form bodies, but kept\n\t\t// for symmetry with `toFormDataStatement`).\n\t\tfor (const parameter of parameters) {\n\t\t\tif (\n\t\t\t\tparameter.in === ParameterIn.header ||\n\t\t\t\tparameter.in === ParameterIn.cookie ||\n\t\t\t\tparameter.in === ParameterIn.path\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst accessor = t.createIdentifier(\n\t\t\t\tBase.camelCase(Base.normalize(parameter.name))\n\t\t\t);\n\t\t\tstatements.push(\n\t\t\t\tt.createIfStatement(\n\t\t\t\t\tt.createBinaryExpression(\n\t\t\t\t\t\taccessor,\n\t\t\t\t\t\tt.createToken(SyntaxKind.ExclamationEqualsToken),\n\t\t\t\t\t\tt.createToken(SyntaxKind.NullKeyword)\n\t\t\t\t\t),\n\t\t\t\t\tt.createBlock(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tappendValue(\n\t\t\t\t\t\t\t\tparameter.name,\n\t\t\t\t\t\t\t\tGenerator.toFormDataCompatibleString(accessor)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttrue\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn statements;\n\t}\n\n\t/**\n\t * Render `expr` as a string suitable for `FormData.append` /\n\t * `URLSearchParams.append`. Object/array schemas are JSON-stringified,\n\t * everything else is coerced via `String(...)`.\n\t */\n\tprivate static toFormDataCompatibleString(\n\t\texpr: import('typescript').Expression,\n\t\tschema?: SchemaObject\n\t): import('typescript').Expression {\n\t\tif (schema && (schema.type === 'object' || schema.type === 'array')) {\n\t\t\treturn t.createCallExpression(\n\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\tt.createIdentifier('JSON'),\n\t\t\t\t\tt.createIdentifier('stringify')\n\t\t\t\t),\n\t\t\t\tundefined,\n\t\t\t\t[expr]\n\t\t\t);\n\t\t}\n\t\treturn t.createCallExpression(t.createIdentifier('String'), undefined, [\n\t\t\texpr,\n\t\t]);\n\t}\n\n\tstatic bodyBlock(\n\t\turi: string,\n\t\tmethod: string,\n\t\tparameters: ParameterObject[],\n\t\trequestBody: MediaTypeObject | undefined,\n\t\tresponse: MediaTypeObject | undefined,\n\t\tadapter: Adapter\n\t): Block {\n\t\tconst shouldParseResponseToJSON = 'application/json' === response?.type;\n\n\t\t// Parameters that look like form fields (Swagger 2.0 style) or are\n\t\t// binary (3.x style, often co-located with multipart/form-data).\n\t\tconst parametersShouldPutInFormData = parameters.filter(\n\t\t\t(p) =>\n\t\t\t\tp.in === ParameterIn.formData ||\n\t\t\t\t(p.schema && Generator.isBinarySchema(p.schema))\n\t\t);\n\n\t\tconst parametersShouldNotPutInFormData = parameters.filter(\n\t\t\t(p) => !parametersShouldPutInFormData.includes(p)\n\t\t);\n\n\t\t// Parameters that look like Swagger 2.0 body params (rare in 3.x, but\n\t\t// kept for backwards compatibility with V2 specs).\n\t\tconst inBody = parametersShouldNotPutInFormData.filter(\n\t\t\t(p) => !p.in || p.in === 'body'\n\t\t);\n\n\t\tconst isRequestBodyContainsBinary =\n\t\t\trequestBody?.schema &&\n\t\t\t'properties' in requestBody.schema &&\n\t\t\tObject.values(requestBody.schema?.properties ?? {}).some((p) =>\n\t\t\t\tGenerator.isBinarySchema(p)\n\t\t\t);\n\n\t\tconst hasBinaryInParameters = parameters.some(\n\t\t\t(p) => p?.schema && Generator.isBinarySchema(p.schema)\n\t\t);\n\n\t\t// --- Decide body kind -------------------------------------------------\n\t\tconst mediaType = (requestBody?.type ?? '')\n\t\t\t.toLowerCase()\n\t\t\t.split(';')[0]\n\t\t\t?.trim();\n\n\t\tconst requestSchemaIsBinary =\n\t\t\trequestBody?.schema && Generator.isBinarySchema(requestBody.schema);\n\n\t\tlet bodyKind: BodyKind = 'none';\n\t\tlet bodyContentType: string | undefined;\n\n\t\tif (mediaType === 'multipart/form-data') {\n\t\t\t// Multipart: any binary/file content in either parameters or\n\t\t\t// requestBody.schema (3.x style) triggers FormData construction.\n\t\t\tif (\n\t\t\t\thasBinaryInParameters ||\n\t\t\t\tisRequestBodyContainsBinary ||\n\t\t\t\tparametersShouldPutInFormData.length > 0\n\t\t\t) {\n\t\t\t\tbodyKind = 'form-data';\n\t\t\t\t// Don't set Content-Type — runtime needs to add the boundary.\n\t\t\t}\n\t\t} else if (mediaType === 'application/x-www-form-urlencoded') {\n\t\t\t// URLSearchParams for any form-urlencoded request.\n\t\t\tbodyKind = 'urlencoded';\n\t\t\tbodyContentType = 'application/x-www-form-urlencoded';\n\t\t} else if (mediaType === 'application/json') {\n\t\t\t// Only emit a JSON body if the spec actually describes one\n\t\t\t// (schema or inBody parameters). The default `application/json`\n\t\t\t// placeholder injected by `schemaToStatemets` for body-less\n\t\t\t// operations has no schema and no params — leave those alone.\n\t\t\tif (requestBody?.schema || inBody.length > 0) {\n\t\t\t\tbodyKind = 'json';\n\t\t\t\tbodyContentType = 'application/json';\n\t\t\t}\n\t\t} else if (requestSchemaIsBinary) {\n\t\t\t// Single binary request body (Blob/File) — pass it through directly.\n\t\t\tbodyKind = 'binary';\n\t\t\tbodyContentType = requestBody?.type;\n\t\t} else if (requestBody?.schema) {\n\t\t\t// Unknown textual type with a schema (e.g. application/xml,\n\t\t\t// text/plain). We don't have a built-in serializer for these —\n\t\t\t// fall back to JSON.stringify. The Content-Type header is set\n\t\t\t// from the spec so the server still routes the request correctly.\n\t\t\tbodyKind = 'json';\n\t\t\tbodyContentType = requestBody?.type;\n\t\t}\n\t\t// No schema and unknown type → fall through to `none`.\n\n\t\t// Pre-statements: FormData / URLSearchParams construction.\n\t\tconst preStatements: Statement[] = [];\n\t\tif (bodyKind === 'form-data') {\n\t\t\tpreStatements.push(\n\t\t\t\t...Generator.toFormDataStatement(\n\t\t\t\t\tparametersShouldPutInFormData,\n\t\t\t\t\trequestBody?.schema\n\t\t\t\t)\n\t\t\t);\n\t\t} else if (bodyKind === 'urlencoded') {\n\t\t\tpreStatements.push(\n\t\t\t\t...Generator.toURLSearchParamsStatement(\n\t\t\t\t\tparametersShouldNotPutInFormData,\n\t\t\t\t\trequestBody?.schema\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn t.createBlock([\n\t\t\t...preStatements,\n\t\t\t...adapter.client(\n\t\t\t\turi,\n\t\t\t\tmethod,\n\t\t\t\tparametersShouldNotPutInFormData,\n\t\t\t\trequestBody,\n\t\t\t\tresponse,\n\t\t\t\tadapter,\n\t\t\t\tbodyKind,\n\t\t\t\tbodyContentType,\n\t\t\t\tshouldParseResponseToJSON\n\t\t\t),\n\t\t]);\n\t}\n\n\tstatic schemaToStatemets(\n\t\tparsedDoc: ProviderInitResult,\n\t\tadaptor: Adapter,\n\t\toptions: Omit<ProviderInitOptions, 'docURL' | 'output' | 'requestOptions'>\n\t): Statement[] {\n\t\tconst statements = [] as Statement[];\n\t\tconst { apis, schemas = {}, enums } = parsedDoc;\n\n\t\tconst enumNames: string[] = [];\n\n\t\tfor (const enumObject of enums) {\n\t\t\tenumNames.push(Base.upperCamelCase(enumObject.name));\n\t\t\tstatements.push(\n\t\t\t\tt.createEnumDeclaration(\n\t\t\t\t\t[t.createToken(SyntaxKind.ExportKeyword)],\n\t\t\t\t\tt.createIdentifier(Base.upperCamelCase(enumObject.name)),\n\t\t\t\t\tenumObject.enum.map((member, index) => {\n\t\t\t\t\t\tconst key = typeof member === 'string' ? member : `Value${member}`;\n\t\t\t\t\t\treturn t.createEnumMember(\n\t\t\t\t\t\t\tt.createStringLiteral(key),\n\t\t\t\t\t\t\ttypeof member === 'string'\n\t\t\t\t\t\t\t\t? t.createStringLiteral(member)\n\t\t\t\t\t\t\t\t: t.createNumericLiteral(member)\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tfor (const schemaKey in schemas) {\n\t\t\tif (\n\t\t\t\tObject.hasOwn(schemas, schemaKey) &&\n\t\t\t\t!enumNames.includes(Base.upperCamelCase(schemaKey))\n\t\t\t) {\n\t\t\t\tconst schema = schemas[schemaKey];\n\t\t\t\tstatements.push(\n\t\t\t\t\tt.createTypeAliasDeclaration(\n\t\t\t\t\t\t[t.createModifier(SyntaxKind.ExportKeyword)],\n\t\t\t\t\t\tt.createIdentifier(Base.upperCamelCase(schemaKey)),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tGenerator.toTypeNode(schema)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Per-generation unique-name resolver. Lives only for this pass so\n\t\t// repeated runs / dry-runs don't leak state across generations.\n\t\tconst reserveUnique = createUniqueNameResolver();\n\n\t\tfor (const uri in apis) {\n\t\t\tconst operations = apis[uri];\n\t\t\tfor (const operation of operations) {\n\t\t\t\tconst {\n\t\t\t\t\tmethod,\n\t\t\t\t\toperationId,\n\t\t\t\t\trequestBody = [],\n\t\t\t\t\tresponses = [],\n\t\t\t\t\tsummary,\n\t\t\t\t\tdeprecated,\n\t\t\t\t\tdescription,\n\t\t\t\t} = operation;\n\n\t\t\t\tlet { parameters = [] } = operation;\n\n\t\t\t\tparameters = parameters.filter((p) => p.in !== 'cookie');\n\n\t\t\t\t// Add a default request, with no schema.\n\t\t\t\tif (requestBody.length === 0) {\n\t\t\t\t\trequestBody.push({ type: MediaTypes.JSON });\n\t\t\t\t}\n\n\t\t\t\tconst shouldAddExtraMethodNameSuffix = requestBody.length > 1;\n\n\t\t\t\tfor (const req of requestBody) {\n\t\t\t\t\tconst statement = t.createFunctionDeclaration(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tt.createModifier(SyntaxKind.ExportKeyword),\n\t\t\t\t\t\t\tt.createModifier(SyntaxKind.AsyncKeyword),\n\t\t\t\t\t\t],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\treserveUnique(\n\t\t\t\t\t\t\tBase.pathToFnName(uri, method, operationId) +\n\t\t\t\t\t\t\t\t(shouldAddExtraMethodNameSuffix\n\t\t\t\t\t\t\t\t\t? Base.mediaTypeToSuffix(req.type)\n\t\t\t\t\t\t\t\t\t: '')\n\t\t\t\t\t\t),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t...(parameters.length > 0\n\t\t\t\t\t\t\t\t? Generator.toDeclarationNodes(parameters)\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t\t...(req?.schema\n\t\t\t\t\t\t\t\t? [Generator.toRequestBodyTypeNode(req.schema)]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t].filter(Boolean) as ParameterDeclaration[],\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tGenerator.bodyBlock(\n\t\t\t\t\t\t\toptions.baseURL + uri,\n\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\tparameters,\n\t\t\t\t\t\t\treq,\n\t\t\t\t\t\t\tresponses[0],\n\t\t\t\t\t\t\tadaptor\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\tconst mergedDescription = [description, summary]\n\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t.join('. ');\n\t\t\t\t\tGenerator.addComments(\n\t\t\t\t\t\tstatement,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tmergedDescription && {\n\t\t\t\t\t\t\t\tcomment: mergedDescription,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdeprecated && {\n\t\t\t\t\t\t\t\ttag: 'deprecated',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...Generator.generateParamTags(parameters, req),\n\t\t\t\t\t\t].filter(Boolean) as CommentObject[]\n\t\t\t\t\t);\n\t\t\t\t\tstatements.push(statement);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn statements;\n\t}\n\n\tstatic async prettier(code: string) {\n\t\treturn await format(code, {\n\t\t\tparser: 'typescript',\n\t\t});\n\t}\n\n\tstatic async genCode(\n\t\tschema: ProviderInitResult,\n\t\tinitOptions: ProviderInitOptions,\n\t\tadaptor: Adapter\n\t) {\n\t\tconst { importClientSource } = initOptions;\n\t\tconst statements = Generator.schemaToStatemets(schema, adaptor, {\n\t\t\tbaseURL: initOptions.baseURL ?? '',\n\t\t});\n\t\tlet code = Generator.toCode(statements);\n\n\t\tif (importClientSource) {\n\t\t\tcode = importClientSource + '\\n\\n' + code;\n\t\t}\n\n\t\treturn await Generator.prettier(code);\n\t}\n}\n","/* eslint-disable unicorn/prefer-spread */\n/**\n * File containing the implementation of the AxiosAdapter class.\n * This adapter is responsible for generating code that uses the Axios HTTP client library.\n */\n\nimport type {\n\tPropertyAssignment,\n\tStatement,\n\tTypeReferenceNode,\n} from 'typescript';\nimport { factory as t } from 'typescript';\nimport { Adapter, type BodyKind } from '../base/Adaptor.js';\nimport { Base } from '../base/Base.js';\nimport { Generator } from '../generator/index.js';\nimport type { MediaTypeObject, ParameterObject } from '../interface.js';\n\n/**\n * Adapter class implementing support for generating code that makes use of the Axios HTTP client library.\n * This adapter defines custom behavior and field mappings specific to the Axios client.\n */\nexport class AxiosAdapter extends Adapter {\n\t/**\n\t * Name of the field used to specify the HTTP method in the request configuration.\n\t */\n\treadonly methodFieldName = 'method';\n\n\t/**\n\t * Name of the field used to specify the request body (data) in the request configuration.\n\t */\n\treadonly bodyFieldName = 'data';\n\n\t/**\n\t * Name of the field used to specify the request headers in the request configuration.\n\t */\n\treadonly headersFieldName = 'headers';\n\n\t/**\n\t * Name of the field used to specify the query parameters in the request configuration.\n\t */\n\treadonly queryFieldName = 'params';\n\n\t/**\n\t * The name of the client this adapter is configured for, which is 'axios' in this case.\n\t */\n\treadonly name = 'axios';\n\n\t/**\n\t * Method that should generate and return the client-specific configuration statements.\n\t *\n\t * @returns {Statement[]} An array of TypeScript statements that define the client configuration.\n\t */\n\tpublic client(\n\t\turi: string,\n\t\tmethod: string,\n\t\tparameters: ParameterObject[],\n\t\trequestBody: MediaTypeObject | undefined,\n\t\tresponse: MediaTypeObject | undefined,\n\t\tadapter: Adapter,\n\t\tbodyKind: BodyKind,\n\t\tbodyContentType: string | undefined,\n\t\t_shouldUseJSONResponse: boolean\n\t): Statement[] {\n\t\tconst statements: Statement[] = [];\n\n\t\t// Split parameters into header and body parameters\n\t\tconst inBody = parameters.filter((p) => !p.in || p.in === 'body');\n\t\tconst inHeader = parameters.filter((p) => p.in === 'header');\n\n\t\tconst toLiterlExpression = () => {\n\t\t\tconst headerEntries: PropertyAssignment[] = [];\n\t\t\tfor (const p of inHeader) {\n\t\t\t\theaderEntries.push(\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createStringLiteral(p.name),\n\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\tt.createIdentifier('encodeURIComponent'),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\tt.createIdentifier('String'),\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t[t.createIdentifier(Base.camelCase(Base.normalize(p.name)))]\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (bodyContentType !== undefined) {\n\t\t\t\theaderEntries.push(\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createStringLiteral('Content-Type'),\n\t\t\t\t\t\tt.createStringLiteral(bodyContentType)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst properties: PropertyAssignment[] = [\n\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\tt.createIdentifier(adapter.methodFieldName),\n\t\t\t\t\tt.createStringLiteral(method.toUpperCase())\n\t\t\t\t),\n\t\t\t];\n\n\t\t\tif (headerEntries.length > 0) {\n\t\t\t\tproperties.push(\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createIdentifier(adapter.headersFieldName),\n\t\t\t\t\t\tt.createObjectLiteralExpression(headerEntries)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet bodyExpr: import('typescript').Expression | undefined;\n\t\t\tswitch (bodyKind) {\n\t\t\t\tcase 'form-data':\n\t\t\t\t\tbodyExpr = t.createIdentifier('fd');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'urlencoded':\n\t\t\t\t\tbodyExpr = t.createIdentifier('sp');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'json':\n\t\t\t\tcase 'binary':\n\t\t\t\t\tbodyExpr = t.createIdentifier('req');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'none':\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (bodyExpr) {\n\t\t\t\tproperties.push(\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createIdentifier(adapter.bodyFieldName),\n\t\t\t\t\t\tbodyExpr\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn t.createObjectLiteralExpression(properties, true);\n\t\t};\n\n\t\t// Construct the fetch call and return statement\n\t\tstatements.push(\n\t\t\tt.createReturnStatement(\n\t\t\t\tt.createCallExpression(\n\t\t\t\t\tt.createIdentifier(adapter.name),\n\t\t\t\t\tresponse?.schema\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\tGenerator.toTypeNode(\n\t\t\t\t\t\t\t\t\tresponse.schema\n\t\t\t\t\t\t\t\t) as unknown as TypeReferenceNode,\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: // No schema declared — type the response as `unknown`\n\t\t\t\t\t\t\t// so the function signature stays explicit.\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tt.createTypeReferenceNode(\n\t\t\t\t\t\t\t\t\tt.createIdentifier('unknown')\n\t\t\t\t\t\t\t\t) as unknown as TypeReferenceNode,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t[Generator.toUrlTemplate(uri, parameters), toLiterlExpression()]\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\n\t\treturn statements;\n\t}\n}\n","/* eslint-disable unicorn/prefer-spread */\n\nimport type { PropertyAssignment, Statement } from 'typescript';\nimport { SyntaxKind, factory as t } from 'typescript';\nimport { Adapter, type BodyKind } from '../base/Adaptor.js';\nimport { Base } from '../base/Base.js';\nimport { Generator } from '../generator/index.js';\nimport type { MediaTypeObject, ParameterObject } from '../interface.js';\n\n/**\n * FetchAdapter is an adapter class that generates client-side fetch requests.\n * It handles parameters, headers, and request bodies to construct proper fetch calls.\n */\nexport class FetchAdapter extends Adapter {\n\treadonly methodFieldName = 'method';\n\treadonly bodyFieldName = 'body';\n\treadonly headersFieldName = 'headers';\n\treadonly queryFieldName = '';\n\treadonly name = 'fetch';\n\n\t/**\n\t * Generates client code for making API requests using the Fetch API.\n\t * @param uri - The API endpoint URI\n\t * @param method - The HTTP method (GET, POST, etc.)\n\t * @param parameters - Array of parameters to include in the request\n\t * @param requestBody - The request body media type definition\n\t * @param response - The response media type definition\n\t * @param adapter - The adapter instance\n\t * @param bodyKind - How the body should be encoded (json / form-data / urlencoded / binary / none)\n\t * @param bodyContentType - Content-Type header to inject (undefined means \"let runtime decide\", e.g. multipart boundary)\n\t * @param shouldUseJSONResponse - Flag to use JSON parsing for the response\n\t * @return - An array of generated TypeScript statements\n\t */\n\tpublic client(\n\t\turi: string,\n\t\tmethod: string,\n\t\tparameters: ParameterObject[],\n\t\trequestBody: MediaTypeObject | undefined,\n\t\tresponse: MediaTypeObject | undefined,\n\t\tadapter: Adapter,\n\t\tbodyKind: BodyKind,\n\t\tbodyContentType: string | undefined,\n\t\tshouldUseJSONResponse: boolean\n\t): Statement[] {\n\t\tconst statements: Statement[] = [];\n\n\t\t// Split parameters into header and body parameters\n\t\tconst inBody = parameters.filter((p) => !p.in || p.in === 'body');\n\t\tconst inHeader = parameters.filter((p) => p.in === 'header');\n\n\t\t/**\n\t\t * Creates the literal object expression for fetch options\n\t\t * including method, headers, and body.\n\t\t * @returns - The constructed fetch options object\n\t\t */\n\t\tconst toLiterlExpression = () => {\n\t\t\tconst headerEntries: PropertyAssignment[] = [];\n\t\t\tfor (const p of inHeader) {\n\t\t\t\theaderEntries.push(\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createStringLiteral(p.name),\n\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\tt.createIdentifier('encodeURIComponent'),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\tt.createIdentifier('String'),\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t[t.createIdentifier(Base.camelCase(Base.normalize(p.name)))]\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (bodyContentType !== undefined) {\n\t\t\t\theaderEntries.push(\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createStringLiteral('Content-Type'),\n\t\t\t\t\t\tt.createStringLiteral(bodyContentType)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst properties: PropertyAssignment[] = [\n\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\tt.createIdentifier(adapter.methodFieldName),\n\t\t\t\t\tt.createStringLiteral(method.toUpperCase())\n\t\t\t\t),\n\t\t\t];\n\n\t\t\tif (headerEntries.length > 0) {\n\t\t\t\tproperties.push(\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createIdentifier(adapter.headersFieldName),\n\t\t\t\t\t\tt.createObjectLiteralExpression(headerEntries)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet bodyExpr: import('typescript').Expression | undefined;\n\t\t\tswitch (bodyKind) {\n\t\t\t\tcase 'form-data':\n\t\t\t\t\tbodyExpr = t.createIdentifier('fd');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'urlencoded':\n\t\t\t\t\tbodyExpr = t.createIdentifier('sp');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'json': {\n\t\t\t\t\tconst arg = requestBody\n\t\t\t\t\t\t? t.createIdentifier('req')\n\t\t\t\t\t\t: t.createObjectLiteralExpression(\n\t\t\t\t\t\t\t\tinBody.map((b) =>\n\t\t\t\t\t\t\t\t\tt.createShorthandPropertyAssignment(\n\t\t\t\t\t\t\t\t\t\tt.createIdentifier(b.name)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t);\n\t\t\t\t\tbodyExpr = t.createCallExpression(\n\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\tt.createIdentifier('JSON'),\n\t\t\t\t\t\t\tt.createIdentifier('stringify')\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[],\n\t\t\t\t\t\t[arg]\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'binary':\n\t\t\t\t\tbodyExpr = t.createIdentifier('req');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'none':\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (bodyExpr) {\n\t\t\t\tproperties.push(\n\t\t\t\t\tt.createPropertyAssignment(\n\t\t\t\t\t\tt.createIdentifier(adapter.bodyFieldName),\n\t\t\t\t\t\tbodyExpr\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn t.createObjectLiteralExpression(properties, true);\n\t\t};\n\n\t\t// Construct the fetch call and return statement\n\t\tstatements.push(\n\t\t\tt.createReturnStatement(\n\t\t\t\tshouldUseJSONResponse\n\t\t\t\t\t? // Handle JSON response with proper type checking\n\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\tt.createIdentifier(adapter.name),\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tGenerator.toUrlTemplate(uri, parameters),\n\t\t\t\t\t\t\t\t\t\ttoLiterlExpression(),\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tt.createIdentifier('then')\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tt.createArrowFunction(\n\t\t\t\t\t\t\t\t\t[t.createModifier(SyntaxKind.AsyncKeyword)],\n\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tt.createParameterDeclaration(\n\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('response')\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\tt.createToken(SyntaxKind.EqualsGreaterThanToken),\n\t\t\t\t\t\t\t\t\tresponse?.schema\n\t\t\t\t\t\t\t\t\t\t? t.createAsExpression(\n\t\t\t\t\t\t\t\t\t\t\t\tt.createParenthesizedExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createAwaitExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('response'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('json')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tGenerator.toTypeNode(response.schema)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t: // No declared response schema — cast to `unknown`\n\t\t\t\t\t\t\t\t\t\t\t// so callers still get a typed value (avoids\n\t\t\t\t\t\t\t\t\t\t\t// implicit any on `response.json()`) and the\n\t\t\t\t\t\t\t\t\t\t\t// function's return type stays explicit.\n\t\t\t\t\t\t\t\t\t\t\tt.createAsExpression(\n\t\t\t\t\t\t\t\t\t\t\t\tt.createParenthesizedExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tt.createAwaitExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createPropertyAccessExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('response'),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tt.createIdentifier('json')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tt.createToken(SyntaxKind.UnknownKeyword)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t: // Simple fetch call without JSON parsing\n\t\t\t\t\t\tt.createCallExpression(\n\t\t\t\t\t\t\tt.createIdentifier(adapter.name),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t[Generator.toUrlTemplate(uri, parameters), toLiterlExpression()]\n\t\t\t\t\t\t)\n\t\t\t)\n\t\t);\n\n\t\treturn statements;\n\t}\n}\n","import type { OpenAPIV2 } from 'openapi-types';\nimport {\n\ttype ArrayTypeSchemaObject,\n\tBase,\n\ttype EnumSchemaObject,\n\tHttpMethods,\n\ttype MediaTypeObject,\n\tMediaTypes,\n\tNonArraySchemaType,\n\ttype OperationObject,\n\ttype ParameterIn,\n\ttype ParameterObject,\n\ttype SchemaFormatType,\n\ttype SchemaObject,\n} from '../core/index.js';\n\nexport class V2 {\n\tdoc!: OpenAPIV2.Document;\n\n\tconstructor(doc: OpenAPIV2.Document) {\n\t\tthis.doc = doc;\n\t}\n\n\t/**\n\t * Resolves a path $ref to the actual path object.\n\t */\n\tprivate resolvePathRef($ref: string): OpenAPIV2.PathItemObject | undefined {\n\t\tconst refName = Base.ref2name($ref, this.doc);\n\t\treturn this.doc.paths?.[refName];\n\t}\n\n\t/**\n\t * Is array schema.\n\t */\n\tprivate isOpenAPIArraySchema(schema: OpenAPIV2.SchemaObject): boolean {\n\t\treturn typeof schema === 'object' && schema.type === 'array';\n\t}\n\n\t/**\n\t * OpenAPI schema to base schema.\n\t */\n\tprivate getSchemaByRef(\n\t\tschema: OpenAPIV2.SchemaObject | OpenAPIV2.ReferenceObject,\n\t\treserveRef = false,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): SchemaObject {\n\t\tlet refName = '';\n\t\tif (Base.isRef(schema)) {\n\t\t\trefName = Base.upperCamelCase(Base.ref2name(schema.$ref));\n\t\t\tif (reserveRef) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: upLevelSchemaKey + refName,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (!this.doc.definitions) {\n\t\t\t\tthis.doc.definitions = {};\n\t\t\t}\n\n\t\t\tschema = this.doc.definitions[Base.ref2name(schema.$ref, this.doc)];\n\t\t}\n\n\t\treturn this.toBaseSchema(schema, enums, '', upLevelSchemaKey + refName);\n\t}\n\n\t/**\n\t * Transform all OpenAPI schema to Base Schema\n\t */\n\tprivate toBaseSchema(\n\t\tschema: OpenAPIV2.SchemaObject | OpenAPIV2.ReferenceObject | undefined,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tschemaKey = '',\n\t\tupLevelSchemaKey = ''\n\t): SchemaObject {\n\t\tif (!schema) {\n\t\t\treturn {\n\t\t\t\ttype: 'unknown',\n\t\t\t};\n\t\t}\n\n\t\tif (Base.isRef(schema)) {\n\t\t\treturn this.getSchemaByRef(schema, true);\n\t\t}\n\n\t\tif (this.isOpenAPIArraySchema(schema)) {\n\t\t\tconst { type, description, items, required } = schema;\n\n\t\t\treturn {\n\t\t\t\ttype: type as string,\n\t\t\t\trequired: !!required,\n\t\t\t\tdescription,\n\t\t\t\titems: this.toBaseSchema(items, enums, schemaKey, upLevelSchemaKey),\n\t\t\t} as ArrayTypeSchemaObject;\n\t\t} else {\n\t\t\tconst {\n\t\t\t\trequired = [],\n\t\t\t\tallOf,\n\t\t\t\tanyOf,\n\t\t\t\tdescription,\n\t\t\t\tenum: enum_,\n\t\t\t\tformat,\n\t\t\t\toneOf,\n\t\t\t\tproperties = {},\n\t\t\t} = schema;\n\t\t\tlet { type } = schema;\n\n\t\t\tif (enum_ && type !== 'boolean') {\n\t\t\t\tconst name =\n\t\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\t\tBase.upperCamelCase(Base.normalize(schemaKey));\n\n\t\t\t\tconst enumObject = {\n\t\t\t\t\tname,\n\t\t\t\t\tenum: [...new Set(enum_ as (string | number)[])],\n\t\t\t\t};\n\n\t\t\t\tconst sameObject = Base.findSameSchema(enumObject, enums);\n\n\t\t\t\tif (\n\t\t\t\t\t!sameObject &&\n\t\t\t\t\tBase.isValidEnumType(schema as unknown as SchemaObject)\n\t\t\t\t) {\n\t\t\t\t\tenums.push(enumObject);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\ttype: sameObject\n\t\t\t\t\t\t? sameObject.name\n\t\t\t\t\t\t: Base.isBooleanEnum(schema as unknown as SchemaObject)\n\t\t\t\t\t\t\t? 'boolean'\n\t\t\t\t\t\t\t: enumObject.name,\n\t\t\t\t\trequired,\n\t\t\t\t\tdescription,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (type === undefined && Object.keys(properties).length > 0) {\n\t\t\t\ttype = NonArraySchemaType.object;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: type as unknown as NonArraySchemaType,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tenum: enum_,\n\t\t\t\tformat: format as unknown as SchemaFormatType,\n\t\t\t\tallOf: allOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s as OpenAPIV2.SchemaObject, enums)\n\t\t\t\t),\n\t\t\t\tanyOf: anyOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s as OpenAPIV2.SchemaObject, enums)\n\t\t\t\t),\n\t\t\t\toneOf: oneOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s as OpenAPIV2.SchemaObject, enums)\n\t\t\t\t),\n\t\t\t\tproperties: Object.keys(properties).reduce((acc, p) => {\n\t\t\t\t\tconst propSchema = properties[p];\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[p]: Base.isRef(propSchema)\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\ttype: Base.capitalize(\n\t\t\t\t\t\t\t\t\t\tBase.ref2name(propSchema.$ref, this.doc)\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: this.toBaseSchema(propSchema, enums, p, upLevelSchemaKey),\n\t\t\t\t\t};\n\t\t\t\t}, {}),\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * OpenAPI parameter to base parameter.\n\t */\n\tprivate getParameterByRef(\n\t\tparameter: OpenAPIV2.ParameterObject | OpenAPIV2.ReferenceObject,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): ParameterObject {\n\t\tif (Base.isRef(parameter)) {\n\t\t\tconst refName = Base.ref2name(parameter.$ref, this.doc);\n\t\t\tconst resolved = this.doc.parameters?.[refName];\n\t\t\tif (!resolved) {\n\t\t\t\tthrow new Error(`Parameter reference not found: ${parameter.$ref}`);\n\t\t\t}\n\t\t\tparameter = resolved;\n\t\t}\n\n\t\tconst p = parameter as OpenAPIV2.ParameterObject;\n\t\tconst {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdescription,\n\t\t\ttype,\n\t\t\titems,\n\t\t\tenum: enum_,\n\t\t\tproperties,\n\t\t\tschema,\n\t\t} = p;\n\n\t\tif (enum_) {\n\t\t\tconst type =\n\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\tBase.upperCamelCase(Base.normalize(name));\n\n\t\t\tconst enumSchema = {\n\t\t\t\tname: type,\n\t\t\t\tenum: [...new Set(enum_ as (string | number)[])],\n\t\t\t};\n\n\t\t\tconst sameEnum = Base.findSameSchema(enumSchema, enums);\n\n\t\t\tif (\n\t\t\t\t!sameEnum &&\n\t\t\t\tBase.isValidEnumType({ type, enum: enum_ } as SchemaObject)\n\t\t\t) {\n\t\t\t\tenums.push(enumSchema);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tin: p.in as ParameterIn,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: sameEnum?.name ?? type,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (items) {\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tin: p.in as ParameterIn,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: type as string,\n\t\t\t\t\titems: items as OpenAPIV2.SchemaObject | undefined,\n\t\t\t\t} as ArrayTypeSchemaObject,\n\t\t\t};\n\t\t}\n\n\t\tif (schema && Base.isRef(schema)) {\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tin: p.in as ParameterIn,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: Base.capitalize(Base.ref2name(schema.$ref)),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdescription,\n\t\t\tin: p.in as ParameterIn,\n\t\t\tschema: {\n\t\t\t\ttype: type as string,\n\t\t\t\tproperties,\n\t\t\t} as SchemaObject,\n\t\t};\n\t}\n\n\t/**\n\t * OpenAPI schema to base response\n\t */\n\tprivate getResponseByRef(\n\t\tschema: OpenAPIV2.ResponseObject | OpenAPIV2.ReferenceObject\n\t): MediaTypeObject[] {\n\t\tif (Base.isRef(schema)) {\n\t\t\tschema = this.doc.responses![Base.ref2name(schema.$ref, this.doc)]!;\n\t\t}\n\n\t\tconst { schema: responseSchema } = schema;\n\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: MediaTypes.JSON,\n\t\t\t\tschema: responseSchema && this.getSchemaByRef(responseSchema, true),\n\t\t\t},\n\t\t];\n\t}\n\n\tpublic init() {\n\t\tconst { definitions = {}, responses = {}, paths = {} } = this.doc;\n\t\tconst enums: EnumSchemaObject[] = [];\n\n\t\tconst definitions_ = Object.keys(definitions).reduce((acc, key) => {\n\t\t\tconst schema = definitions[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getSchemaByRef(schema, false, enums, key),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst responses_ = Object.keys(responses).reduce((acc, key) => {\n\t\t\tconst response = responses[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getResponseByRef(response),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst apis = Object.keys(paths).reduce((acc, path) => {\n\t\t\tlet pathObject = paths[path] ?? {};\n\n\t\t\t// Handle path-level $ref\n\t\t\tif (pathObject.$ref) {\n\t\t\t\tconst resolved = this.resolvePathRef(pathObject.$ref);\n\t\t\t\tif (resolved) {\n\t\t\t\t\tpathObject = resolved;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { parameters = [] } = pathObject;\n\t\t\tconst methodApis: OperationObject[] = [];\n\n\t\t\tObject.values(HttpMethods).forEach((method) => {\n\t\t\t\tconst methodObject = pathObject[method as OpenAPIV2.HttpMethods];\n\n\t\t\t\tif (methodObject) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tdeprecated,\n\t\t\t\t\t\toperationId,\n\t\t\t\t\t\tsummary: summary_,\n\t\t\t\t\t\tdescription: description_,\n\t\t\t\t\t\tresponses = {},\n\t\t\t\t\t} = methodObject;\n\t\t\t\t\tconst { parameters: parameters_ = [] } = methodObject;\n\t\t\t\t\tconst baseParameters = [...parameters, ...parameters_].map(\n\t\t\t\t\t\t(parameter) => this.getParameterByRef(parameter, enums)\n\t\t\t\t\t);\n\t\t\t\t\tconst uniqueParameterName = [\n\t\t\t\t\t\t...new Set(baseParameters.map((p) => p.name)),\n\t\t\t\t\t];\n\n\t\t\t\t\tif (Object.keys(responses).length === 0) {\n\t\t\t\t\t\tObject.assign(responses, {\n\t\t\t\t\t\t\t200: {\n\t\t\t\t\t\t\t\tdescription: 'Successful response',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tconst inBody = baseParameters.filter(\n\t\t\t\t\t\t(p) => p.in === 'body' || p.in === 'formData'\n\t\t\t\t\t);\n\n\t\t\t\t\tconst notInBody = baseParameters.filter(\n\t\t\t\t\t\t(p) => p.in !== 'body' && p.in !== 'formData'\n\t\t\t\t\t);\n\n\t\t\t\t\tconst httpCodes = Object.keys(responses);\n\t\t\t\t\tfor (const code of httpCodes) {\n\t\t\t\t\t\tif (code in responses) {\n\t\t\t\t\t\t\tconst response = responses[code]!;\n\t\t\t\t\t\t\tconst responseSchema = this.getResponseByRef(response);\n\n\t\t\t\t\t\t\tconst inBodyOnlyHasBody =\n\t\t\t\t\t\t\t\tinBody &&\n\t\t\t\t\t\t\t\tinBody.length === 1 &&\n\t\t\t\t\t\t\t\tinBody[0].in === 'body' &&\n\t\t\t\t\t\t\t\tinBody[0].name === 'body';\n\n\t\t\t\t\t\t\tmethodApis.push({\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\toperationId,\n\t\t\t\t\t\t\t\tsummary: summary_,\n\t\t\t\t\t\t\t\tdeprecated: deprecated,\n\t\t\t\t\t\t\t\tdescription: description_,\n\t\t\t\t\t\t\t\tparameters: uniqueParameterName\n\t\t\t\t\t\t\t\t\t.map((name) => notInBody.find((p) => p.name === name)!)\n\t\t\t\t\t\t\t\t\t.filter(Boolean),\n\t\t\t\t\t\t\t\tresponses: responseSchema,\n\t\t\t\t\t\t\t\trequestBody:\n\t\t\t\t\t\t\t\t\tinBody.length > 0\n\t\t\t\t\t\t\t\t\t\t? inBodyOnlyHasBody\n\t\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: MediaTypes.JSON,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tschema: inBody[0].schema,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: MediaTypes.JSON,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: NonArraySchemaType.object,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tproperties: inBody.reduce<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tRecord<string, SchemaObject>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>((a, p) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[p.name]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: p.schema?.type ?? 'unknown',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\trequired: p.schema?.required,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// @ts-expect-error items can be undefined\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titems: p.schema?.items,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdescription: p.schema?.description,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} as SchemaObject,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[path]: methodApis,\n\t\t\t};\n\t\t}, {});\n\n\t\treturn {\n\t\t\tenums: Base.uniqueEnums(enums),\n\t\t\tschemas: definitions_,\n\t\t\tresponses: responses_,\n\t\t\tparameters: {},\n\t\t\trequestBodies: {},\n\t\t\tapis,\n\t\t};\n\t}\n}\n","import type { OpenAPIV3 } from 'openapi-types';\nimport type {\n\tEnumSchemaObject,\n\tMediaTypeObject,\n\tMediaTypes,\n\tOperationObject,\n\tParameterIn,\n\tParameterObject,\n\tSchemaFormatType,\n\tSchemaObject,\n} from '../core/index.js';\nimport { Base, HttpMethods, NonArraySchemaType } from '../core/index.js';\n\nexport class V3 {\n\tdoc!: OpenAPIV3.Document;\n\n\tconstructor(doc: OpenAPIV3.Document) {\n\t\tthis.doc = doc;\n\t}\n\n\t/**\n\t * Resolves a path $ref to the actual path object.\n\t */\n\tprivate resolvePathRef($ref: string): OpenAPIV3.PathItemObject | undefined {\n\t\tconst refName = Base.ref2name($ref, this.doc);\n\t\treturn this.doc.paths?.[refName];\n\t}\n\n\t/**\n\t * Is array schema.\n\t */\n\tprivate isOpenAPIArraySchema(\n\t\tschema: OpenAPIV3.SchemaObject\n\t): schema is OpenAPIV3.ArraySchemaObject {\n\t\treturn typeof schema === 'object' && schema.type === 'array';\n\t}\n\n\t/**\n\t * OpenAPI schema to base schema.\n\t */\n\tprivate getSchemaByRef(\n\t\tschema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject,\n\t\treserveRef = false,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): SchemaObject {\n\t\tlet refName = '';\n\t\tif (Base.isRef(schema)) {\n\t\t\trefName = Base.capitalize(Base.ref2name(schema.$ref));\n\t\t\tif (reserveRef) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: upLevelSchemaKey + refName,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.doc.components?.schemas?.[Base.ref2name(schema.$ref, this.doc)];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\treturn { type: 'unknown' };\n\t\t\t}\n\t\t\tschema = resolvedSchema as OpenAPIV3.SchemaObject;\n\t\t}\n\n\t\treturn this.toBaseSchema(schema, enums, '', upLevelSchemaKey + refName);\n\t}\n\n\t/**\n\t * OpenAPI parameter to base parameter.\n\t */\n\tprivate getParameterByRef(\n\t\tschema: OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): ParameterObject {\n\t\tif (Base.isRef(schema)) {\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.doc.components?.parameters?.[Base.ref2name(schema.$ref, this.doc)];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\treturn {\n\t\t\t\t\tname: 'unknown',\n\t\t\t\t\tin: 'query' as ParameterIn,\n\t\t\t\t};\n\t\t\t}\n\t\t\tschema = resolvedSchema as OpenAPIV3.ParameterObject;\n\t\t}\n\n\t\tconst {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdeprecated,\n\t\t\tdescription,\n\t\t\tschema: parameterSchema,\n\t\t} = schema;\n\n\t\tif (\n\t\t\tparameterSchema &&\n\t\t\t!Base.isRef(parameterSchema) &&\n\t\t\tparameterSchema.enum\n\t\t) {\n\t\t\tconst type =\n\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\tBase.upperCamelCase(Base.normalize(name));\n\n\t\t\tconst enumSchema = {\n\t\t\t\tname: type,\n\t\t\t\tenum: [...new Set(parameterSchema.enum as (string | number)[])],\n\t\t\t};\n\n\t\t\tconst sameEnum = Base.findSameSchema(enumSchema, enums);\n\n\t\t\tif (\n\t\t\t\t!sameEnum &&\n\t\t\t\tBase.isValidEnumType(parameterSchema as unknown as SchemaObject)\n\t\t\t) {\n\t\t\t\tenums.push(enumSchema);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tdeprecated,\n\t\t\t\tin: schema.in as ParameterIn,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: sameEnum?.name ?? type,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdescription,\n\t\t\tdeprecated,\n\t\t\tin: schema.in as ParameterIn,\n\t\t\tschema:\n\t\t\t\tschema.schema &&\n\t\t\t\tthis.getSchemaByRef(\n\t\t\t\t\tschema.schema,\n\t\t\t\t\tfalse,\n\t\t\t\t\tenums,\n\t\t\t\t\tupLevelSchemaKey + Base.capitalize(name)\n\t\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * OpenAPI schema to base response\n\t */\n\tprivate getResponseByRef(\n\t\tschema: OpenAPIV3.ResponseObject | OpenAPIV3.ReferenceObject\n\t): MediaTypeObject[] {\n\t\tif (Base.isRef(schema)) {\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.doc.components?.responses?.[Base.ref2name(schema.$ref, this.doc)];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tschema = resolvedSchema as OpenAPIV3.ResponseObject;\n\t\t}\n\n\t\tconst { content = {} } = schema;\n\n\t\treturn Object.keys(content).map((c) => ({\n\t\t\ttype: c as MediaTypes,\n\t\t\tschema: content[c].schema && this.getSchemaByRef(content[c].schema, true),\n\t\t}));\n\t}\n\n\t/**\n\t * OpenAPI schema to requestBody.\n\t */\n\tprivate getRequestBodyByRef(\n\t\tschema: OpenAPIV3.RequestBodyObject | OpenAPIV3.ReferenceObject,\n\t\tenums: EnumSchemaObject[] = []\n\t): MediaTypeObject[] {\n\t\tif (Base.isRef(schema)) {\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.doc.components?.requestBodies?.[\n\t\t\t\t\tBase.ref2name(schema.$ref, this.doc)\n\t\t\t\t];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tschema = resolvedSchema as OpenAPIV3.RequestBodyObject;\n\t\t}\n\n\t\tconst { content = {} } = schema;\n\n\t\treturn Object.keys(content).map((c) => ({\n\t\t\ttype: c as MediaTypes,\n\t\t\tschema:\n\t\t\t\tcontent[c].schema &&\n\t\t\t\tthis.getSchemaByRef(content[c].schema, false, enums),\n\t\t}));\n\t}\n\n\t/**\n\t * Transform all OpenAPI schema to Base Schema\n\t */\n\tprivate toBaseSchema(\n\t\tschema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tschemaKey = '',\n\t\tupLevelSchemaKey = ''\n\t): SchemaObject {\n\t\tif (!schema) {\n\t\t\treturn {\n\t\t\t\ttype: 'unknown',\n\t\t\t};\n\t\t}\n\n\t\tif (Base.isRef(schema)) {\n\t\t\treturn this.getSchemaByRef(schema, true);\n\t\t}\n\n\t\tif (this.isOpenAPIArraySchema(schema)) {\n\t\t\tconst { type, description, items, required } = schema;\n\n\t\t\treturn {\n\t\t\t\ttype,\n\t\t\t\trequired: !!required,\n\t\t\t\tdescription,\n\t\t\t\titems: this.toBaseSchema(items, enums, schemaKey, upLevelSchemaKey),\n\t\t\t};\n\t\t} else {\n\t\t\tconst {\n\t\t\t\trequired = [],\n\t\t\t\tallOf,\n\t\t\t\tanyOf,\n\t\t\t\tdescription,\n\t\t\t\tdeprecated,\n\t\t\t\tenum: enum_,\n\t\t\t\tformat,\n\t\t\t\toneOf,\n\t\t\t\tproperties = {},\n\t\t\t} = schema;\n\t\t\tlet { type } = schema;\n\n\t\t\tif (enum_ && type !== 'boolean') {\n\t\t\t\tconst name =\n\t\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\t\tBase.upperCamelCase(Base.normalize(schemaKey));\n\n\t\t\t\tconst enumObject = {\n\t\t\t\t\tname,\n\t\t\t\t\tenum: [...new Set(enum_ as (string | number)[])],\n\t\t\t\t};\n\n\t\t\t\tconst sameObject = Base.findSameSchema(enumObject, enums);\n\n\t\t\t\tif (\n\t\t\t\t\t!sameObject &&\n\t\t\t\t\tBase.isValidEnumType(schema as unknown as SchemaObject)\n\t\t\t\t) {\n\t\t\t\t\tenums.push(enumObject);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\ttype: sameObject\n\t\t\t\t\t\t? sameObject.name\n\t\t\t\t\t\t: Base.isBooleanEnum(schema as unknown as SchemaObject)\n\t\t\t\t\t\t\t? 'boolean'\n\t\t\t\t\t\t\t: enumObject.name,\n\t\t\t\t\trequired,\n\t\t\t\t\tdescription,\n\t\t\t\t\tdeprecated,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (type === undefined && Object.keys(properties).length > 0) {\n\t\t\t\ttype = NonArraySchemaType.object;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: type as unknown as NonArraySchemaType,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tdeprecated,\n\t\t\t\tenum: enum_,\n\t\t\t\tformat: format as unknown as SchemaFormatType,\n\t\t\t\tallOf: allOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t\t),\n\t\t\t\tanyOf: anyOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t\t),\n\t\t\t\toneOf: oneOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t\t),\n\t\t\t\tproperties: Object.keys(properties).reduce((acc, p) => {\n\t\t\t\t\tconst propSchema = properties[p];\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[p]: Base.isRef(propSchema)\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\ttype: Base.capitalize(\n\t\t\t\t\t\t\t\t\t\tBase.ref2name(propSchema.$ref, this.doc)\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tisRef: true,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: this.toBaseSchema(propSchema, enums, p, upLevelSchemaKey),\n\t\t\t\t\t};\n\t\t\t\t}, {}),\n\t\t\t};\n\t\t}\n\t}\n\n\tpublic init() {\n\t\tconst { components = {}, paths = {} } = this.doc;\n\t\tconst enums: EnumSchemaObject[] = [];\n\t\tconst {\n\t\t\trequestBodies = {},\n\t\t\tresponses = {},\n\t\t\tparameters = {},\n\t\t\tschemas = {},\n\t\t} = components;\n\n\t\tconst schemas_ = Object.keys(schemas).reduce((acc, key) => {\n\t\t\tconst schema = schemas[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getSchemaByRef(schema, false, enums, key),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst parameters_ = Object.keys(parameters).reduce((acc, key) => {\n\t\t\tconst parameter = parameters[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getParameterByRef(parameter, enums, key),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst responses_ = Object.keys(responses).reduce((acc, key) => {\n\t\t\tconst response = responses[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getResponseByRef(response),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst requestBodies_ = Object.keys(requestBodies).reduce((acc, key) => {\n\t\t\tconst requestBody = requestBodies[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getRequestBodyByRef(requestBody, enums),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst apis = Object.keys(paths).reduce((acc, path) => {\n\t\t\tlet pathObject = paths[path] ?? {};\n\n\t\t\t// Handle path-level $ref\n\t\t\tif (pathObject.$ref) {\n\t\t\t\tconst resolved = this.resolvePathRef(pathObject.$ref);\n\t\t\t\tif (resolved) {\n\t\t\t\t\tpathObject = resolved;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { parameters = [], description, summary } = pathObject;\n\t\t\tconst methodApis: OperationObject[] = [];\n\n\t\t\tObject.values(HttpMethods).forEach((method) => {\n\t\t\t\tconst methodObject = pathObject[method as OpenAPIV3.HttpMethods];\n\n\t\t\t\tif (methodObject) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tdeprecated,\n\t\t\t\t\t\toperationId,\n\t\t\t\t\t\tresponses = {},\n\t\t\t\t\t\tsummary: summary_,\n\t\t\t\t\t\tdescription: description_,\n\t\t\t\t\t\trequestBody = { content: {} },\n\t\t\t\t\t} = methodObject;\n\t\t\t\t\tconst { parameters: parameters_ = [] } = methodObject;\n\t\t\t\t\tconst baseParameters = [...parameters, ...parameters_].map(\n\t\t\t\t\t\t(parameter) => this.getParameterByRef(parameter, enums)\n\t\t\t\t\t);\n\t\t\t\t\tconst baseRequestBody = this.getRequestBodyByRef(requestBody, enums);\n\t\t\t\t\tconst uniqueParameterName = [\n\t\t\t\t\t\t...new Set(baseParameters.map((p) => p.name)),\n\t\t\t\t\t];\n\n\t\t\t\t\tif (Object.keys(responses).length === 0) {\n\t\t\t\t\t\tObject.assign(responses, {\n\t\t\t\t\t\t\t200: {\n\t\t\t\t\t\t\t\tdescription: 'Successful response',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst httpCodes = Object.keys(responses);\n\t\t\t\t\tfor (const code of httpCodes) {\n\t\t\t\t\t\tif (code in responses) {\n\t\t\t\t\t\t\tconst response = responses[code];\n\t\t\t\t\t\t\tconst responseSchema = this.getResponseByRef(response);\n\t\t\t\t\t\t\tmethodApis.push({\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\toperationId,\n\t\t\t\t\t\t\t\tsummary: summary_ ?? summary,\n\t\t\t\t\t\t\t\tdescription: description_ ?? description,\n\t\t\t\t\t\t\t\tdeprecated: deprecated,\n\t\t\t\t\t\t\t\tparameters: uniqueParameterName\n\t\t\t\t\t\t\t\t\t.map((name) => baseParameters.find((p) => p.name === name))\n\t\t\t\t\t\t\t\t\t.filter((p): p is ParameterObject => p !== undefined),\n\t\t\t\t\t\t\t\tresponses: responseSchema,\n\t\t\t\t\t\t\t\trequestBody: baseRequestBody,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[path]: methodApis,\n\t\t\t};\n\t\t}, {});\n\n\t\treturn {\n\t\t\tenums: Base.uniqueEnums(enums),\n\t\t\tschemas: schemas_,\n\t\t\tresponses: responses_,\n\t\t\tparameters: parameters_,\n\t\t\trequestBodies: requestBodies_,\n\t\t\tapis,\n\t\t};\n\t}\n}\n","/* eslint-disable unicorn/filename-case */\n\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type {\n\tEnumSchemaObject,\n\tMediaTypeObject,\n\tMediaTypes,\n\tOperationObject,\n\tParameterIn,\n\tParameterObject,\n\tSchemaFormatType,\n\tSchemaObject,\n} from '../core/index.js';\nimport { Base, HttpMethods, NonArraySchemaType } from '../core/index.js';\n\nexport class V3_1 {\n\tdoc!: OpenAPIV3_1.Document;\n\n\tconstructor(doc: OpenAPIV3_1.Document) {\n\t\tthis.doc = doc;\n\t}\n\n\t/**\n\t * Resolves a path $ref to the actual path object.\n\t */\n\tprivate resolvePathRef($ref: string): OpenAPIV3_1.PathItemObject | undefined {\n\t\tconst refName = Base.ref2name($ref, this.doc);\n\t\treturn this.doc.paths?.[refName];\n\t}\n\n\t/**\n\t * Is array schema.\n\t */\n\tprivate isOpenAPIArraySchema(\n\t\tschema: OpenAPIV3_1.SchemaObject\n\t): schema is OpenAPIV3_1.ArraySchemaObject {\n\t\treturn typeof schema === 'object' && schema.type === 'array';\n\t}\n\n\t/**\n\t * OpenAPI schema to base schema.\n\t */\n\tprivate getSchemaByRef(\n\t\tschema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject,\n\t\treserveRef = false,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): SchemaObject {\n\t\tlet refName = '';\n\t\tif (Base.isRef(schema)) {\n\t\t\tconst upperRefName = Base.upperCamelCase(Base.ref2name(schema.$ref));\n\t\t\trefName = upperRefName;\n\t\t\tif (reserveRef) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: upLevelSchemaKey + refName,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (!this.doc.components) {\n\t\t\t\tthis.doc.components = {\n\t\t\t\t\tschemas: {},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst resolvedSchema =\n\t\t\t\tthis.doc.components.schemas?.[Base.ref2name(schema.$ref, this.doc)];\n\t\t\tif (!resolvedSchema) {\n\t\t\t\tthrow new Error(`Schema reference not found: ${refName}`);\n\t\t\t}\n\t\t\tschema = resolvedSchema;\n\t\t}\n\n\t\treturn this.toBaseSchema(schema, enums, '', upLevelSchemaKey + refName);\n\t}\n\n\t/**\n\t * OpenAPI parameter to base parameter.\n\t */\n\tprivate getParameterByRef(\n\t\tschema: OpenAPIV3_1.ParameterObject | OpenAPIV3_1.ReferenceObject,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tupLevelSchemaKey = ''\n\t): ParameterObject {\n\t\tif (Base.isRef(schema)) {\n\t\t\tschema = this.doc.components?.parameters?.[\n\t\t\t\tBase.ref2name(schema.$ref, this.doc)\n\t\t\t] as OpenAPIV3_1.ParameterObject;\n\t\t}\n\n\t\tconst {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdeprecated,\n\t\t\tdescription,\n\t\t\tschema: parameterSchema,\n\t\t} = schema;\n\n\t\tif (\n\t\t\tparameterSchema &&\n\t\t\t!Base.isRef(parameterSchema) &&\n\t\t\tparameterSchema.enum\n\t\t) {\n\t\t\tconst type =\n\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\tBase.upperCamelCase(Base.normalize(name));\n\n\t\t\tconst enumSchema = {\n\t\t\t\tname: type,\n\t\t\t\tenum: [...new Set(parameterSchema.enum as (string | number)[])],\n\t\t\t};\n\n\t\t\tconst sameEnum = Base.findSameSchema(enumSchema, enums);\n\n\t\t\tif (\n\t\t\t\t!sameEnum &&\n\t\t\t\tBase.isValidEnumType(parameterSchema as unknown as SchemaObject)\n\t\t\t) {\n\t\t\t\tenums.push(enumSchema);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tdeprecated,\n\t\t\t\tin: schema.in as ParameterIn,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: sameEnum?.name ?? type,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tname,\n\t\t\trequired,\n\t\t\tdescription,\n\t\t\tdeprecated,\n\t\t\tin: schema.in as ParameterIn,\n\t\t\tschema:\n\t\t\t\tschema.schema &&\n\t\t\t\tthis.getSchemaByRef(\n\t\t\t\t\tschema.schema,\n\t\t\t\t\tfalse,\n\t\t\t\t\tenums,\n\t\t\t\t\tupLevelSchemaKey + Base.capitalize(name)\n\t\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * OpenAPI schema to base response\n\t */\n\tprivate getResponseByRef(\n\t\tschema: OpenAPIV3_1.ResponseObject | OpenAPIV3_1.ReferenceObject\n\t): MediaTypeObject[] {\n\t\tif (Base.isRef(schema)) {\n\t\t\tschema = this.doc.components?.responses?.[\n\t\t\t\tBase.ref2name(schema.$ref, this.doc)\n\t\t\t] as OpenAPIV3_1.ResponseObject;\n\t\t}\n\n\t\tconst { content = {} } = schema;\n\n\t\treturn Object.keys(content).map((c) => ({\n\t\t\ttype: c as MediaTypes,\n\t\t\tschema: content[c].schema && this.getSchemaByRef(content[c].schema, true),\n\t\t}));\n\t}\n\n\t/**\n\t * OpenAPI schema to requestBody.\n\t */\n\tprivate getRequestBodyByRef(\n\t\tschema: OpenAPIV3_1.RequestBodyObject | OpenAPIV3_1.ReferenceObject,\n\t\tenums: EnumSchemaObject[] = []\n\t): MediaTypeObject[] {\n\t\tif (Base.isRef(schema)) {\n\t\t\tschema = this.doc.components?.requestBodies?.[\n\t\t\t\tBase.ref2name(schema.$ref, this.doc)\n\t\t\t] as OpenAPIV3_1.RequestBodyObject;\n\t\t}\n\n\t\tconst { content = {} } = schema;\n\n\t\treturn Object.keys(content).map((c) => ({\n\t\t\ttype: c as MediaTypes,\n\t\t\tschema:\n\t\t\t\tcontent[c].schema &&\n\t\t\t\tthis.getSchemaByRef(content[c].schema, true, enums),\n\t\t}));\n\t}\n\n\t/**\n\t * Transform all OpenAPI schema to Base Schema\n\t */\n\tprivate toBaseSchema(\n\t\tschema: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject | undefined,\n\t\tenums: EnumSchemaObject[] = [],\n\t\tschemaKey = '',\n\t\tupLevelSchemaKey = ''\n\t): SchemaObject {\n\t\tif (!schema) {\n\t\t\treturn {\n\t\t\t\ttype: 'unknown',\n\t\t\t};\n\t\t}\n\n\t\tif (Base.isRef(schema)) {\n\t\t\treturn this.getSchemaByRef(schema, true);\n\t\t}\n\n\t\tif (this.isOpenAPIArraySchema(schema)) {\n\t\t\tconst { type, description, items, required } = schema;\n\n\t\t\treturn {\n\t\t\t\ttype,\n\t\t\t\trequired: !!required,\n\t\t\t\tdescription,\n\t\t\t\titems: this.toBaseSchema(items, enums, schemaKey, upLevelSchemaKey),\n\t\t\t};\n\t\t} else {\n\t\t\tconst {\n\t\t\t\trequired = [],\n\t\t\t\tallOf,\n\t\t\t\tanyOf,\n\t\t\t\tdescription,\n\t\t\t\tdeprecated,\n\t\t\t\tenum: enum_,\n\t\t\t\tformat,\n\t\t\t\toneOf,\n\t\t\t\tproperties = {},\n\t\t\t} = schema;\n\t\t\tlet { type } = schema;\n\n\t\t\tif (enum_ && type !== 'boolean') {\n\t\t\t\tconst name =\n\t\t\t\t\tBase.upperCamelCase(Base.normalize(upLevelSchemaKey)) +\n\t\t\t\t\tBase.upperCamelCase(Base.normalize(schemaKey));\n\n\t\t\t\tconst enumObject = {\n\t\t\t\t\tname,\n\t\t\t\t\tenum: [...new Set(enum_ as (string | number)[])],\n\t\t\t\t};\n\n\t\t\t\tconst sameObject = Base.findSameSchema(enumObject, enums);\n\n\t\t\t\tif (\n\t\t\t\t\t!sameObject &&\n\t\t\t\t\tBase.isValidEnumType(schema as unknown as SchemaObject)\n\t\t\t\t) {\n\t\t\t\t\tenums.push(enumObject);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\ttype: sameObject\n\t\t\t\t\t\t? sameObject.name\n\t\t\t\t\t\t: Base.isBooleanEnum(schema as unknown as SchemaObject)\n\t\t\t\t\t\t\t? 'boolean'\n\t\t\t\t\t\t\t: enumObject.name,\n\t\t\t\t\trequired,\n\t\t\t\t\tdescription,\n\t\t\t\t\tdeprecated,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (type === undefined && Object.keys(properties).length > 0) {\n\t\t\t\ttype = NonArraySchemaType.object;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: type as unknown as NonArraySchemaType,\n\t\t\t\trequired,\n\t\t\t\tdescription,\n\t\t\t\tdeprecated,\n\t\t\t\tenum: enum_,\n\t\t\t\tformat: format as unknown as SchemaFormatType,\n\t\t\t\tallOf: allOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t\t),\n\t\t\t\tanyOf: anyOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t\t),\n\t\t\t\toneOf: oneOf?.map((s) =>\n\t\t\t\t\tBase.isRef(s)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\t\tref: s.$ref,\n\t\t\t\t\t\t\t\ttype: Base.capitalize(Base.ref2name(s.$ref, this.doc)),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: this.toBaseSchema(s, enums)\n\t\t\t\t),\n\t\t\t\tproperties: Object.keys(properties).reduce((acc, p) => {\n\t\t\t\t\tconst propSchema = properties[p];\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t[p]: Base.isRef(propSchema)\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\ttype: Base.capitalize(\n\t\t\t\t\t\t\t\t\t\tBase.ref2name(propSchema.$ref, this.doc)\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tisRef: true,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: this.toBaseSchema(propSchema, enums, p, upLevelSchemaKey),\n\t\t\t\t\t};\n\t\t\t\t}, {}),\n\t\t\t};\n\t\t}\n\t}\n\n\tpublic init() {\n\t\tconst { components = {}, paths = {} } = this.doc;\n\t\tconst enums: EnumSchemaObject[] = [];\n\t\tconst {\n\t\t\trequestBodies = {},\n\t\t\tresponses = {},\n\t\t\tparameters = {},\n\t\t\tschemas = {},\n\t\t} = components;\n\n\t\tconst schemas_ = Object.keys(schemas).reduce((acc, key) => {\n\t\t\tconst schema = schemas[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getSchemaByRef(schema, false, enums, key),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst parameters_ = Object.keys(parameters).reduce((acc, key) => {\n\t\t\tconst parameter = parameters[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getParameterByRef(parameter, enums, key),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst responses_ = Object.keys(responses).reduce((acc, key) => {\n\t\t\tconst response = responses[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getResponseByRef(response),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst requestBodies_ = Object.keys(requestBodies).reduce((acc, key) => {\n\t\t\tconst requestBody = requestBodies[key];\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: this.getRequestBodyByRef(requestBody, enums),\n\t\t\t};\n\t\t}, {});\n\n\t\tconst apis = Object.keys(paths).reduce((acc, path) => {\n\t\t\tlet pathObject = paths[path] ?? {};\n\n\t\t\t// Handle path-level $ref\n\t\t\tif (pathObject.$ref) {\n\t\t\t\tconst resolved = this.resolvePathRef(pathObject.$ref);\n\t\t\t\tif (resolved) {\n\t\t\t\t\tpathObject = resolved;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { parameters = [], description, summary } = pathObject;\n\t\t\tconst methodApis: OperationObject[] = [];\n\n\t\t\tObject.values(HttpMethods).forEach((method) => {\n\t\t\t\tconst methodObject = pathObject[method as OpenAPIV3_1.HttpMethods];\n\n\t\t\t\tif (methodObject) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tdeprecated,\n\t\t\t\t\t\toperationId,\n\t\t\t\t\t\tsummary: summary_,\n\t\t\t\t\t\tdescription: description_,\n\t\t\t\t\t\tresponses = {},\n\t\t\t\t\t\trequestBody = { content: {} },\n\t\t\t\t\t} = methodObject;\n\t\t\t\t\tconst { parameters: parameters_ = [] } = methodObject;\n\t\t\t\t\tconst baseParameters = [...parameters, ...parameters_].map(\n\t\t\t\t\t\t(parameter) => this.getParameterByRef(parameter, enums)\n\t\t\t\t\t);\n\t\t\t\t\tconst baseRequestBody = this.getRequestBodyByRef(requestBody, enums);\n\t\t\t\t\tconst uniqueParameterName = [\n\t\t\t\t\t\t...new Set(baseParameters.map((p) => p.name)),\n\t\t\t\t\t];\n\n\t\t\t\t\tif (Object.keys(responses).length === 0) {\n\t\t\t\t\t\tObject.assign(responses, {\n\t\t\t\t\t\t\t200: {\n\t\t\t\t\t\t\t\tdescription: 'Successful response',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst httpCodes = Object.keys(responses);\n\t\t\t\t\tfor (const code of httpCodes) {\n\t\t\t\t\t\tif (code in responses) {\n\t\t\t\t\t\t\tconst response = responses[code];\n\t\t\t\t\t\t\tconst responseSchema = this.getResponseByRef(response);\n\t\t\t\t\t\t\tmethodApis.push({\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\toperationId,\n\t\t\t\t\t\t\t\tsummary: summary_ ?? summary,\n\t\t\t\t\t\t\t\tdescription: description_ ?? description,\n\t\t\t\t\t\t\t\tdeprecated: deprecated,\n\t\t\t\t\t\t\t\tparameters: uniqueParameterName\n\t\t\t\t\t\t\t\t\t.map((name) => baseParameters.find((p) => p.name === name))\n\t\t\t\t\t\t\t\t\t.filter((p): p is ParameterObject => p !== undefined),\n\t\t\t\t\t\t\t\tresponses: responseSchema,\n\t\t\t\t\t\t\t\trequestBody: baseRequestBody,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[path]: methodApis,\n\t\t\t};\n\t\t}, {});\n\n\t\treturn {\n\t\t\tenums: Base.uniqueEnums(enums),\n\t\t\tschemas: schemas_,\n\t\t\tresponses: responses_,\n\t\t\tparameters: parameters_,\n\t\t\trequestBodies: requestBodies_,\n\t\t\tapis,\n\t\t};\n\t}\n}\n","import { readFile } from 'node:fs/promises';\nimport { createScopedLogger } from '@moccona/logger';\nimport type { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\nimport type {\n\tAdaptors,\n\tProviderInitOptions,\n\tProviderInitResult,\n} from '../core/index.js';\nimport {\n\ttype Adapter,\n\tAxiosAdapter,\n\tAdaptors as ads,\n\tBase,\n\tcreateErrors,\n\tFetchAdapter,\n\tGenerator,\n\tProvider,\n} from '../core/index.js';\n\nimport { V2 } from './V2.js';\nimport { V3 } from './V3.js';\nimport { V3_1 } from './V3_1.js';\n\nconst logger = createScopedLogger('OpenAPI');\n\nexport enum OpenAPIVersion {\n\tv2 = 'v2',\n\tv3 = 'v3',\n\tv3_1 = 'v3_1',\n\tunknown = 'unknown',\n}\n\nfunction getDocVersion(doc: OpenAPI.Document) {\n\tconst raw =\n\t\t(doc as OpenAPIV3.Document).openapi || (doc as OpenAPIV2.Document).swagger;\n\n\tif (typeof raw !== 'string' || raw.length === 0) {\n\t\treturn OpenAPIVersion.unknown;\n\t}\n\n\tconst version = raw.slice(0, 3);\n\n\tswitch (version) {\n\t\tcase '3.1':\n\t\t\treturn OpenAPIVersion.v3_1;\n\t\tcase '3.0':\n\t\t\treturn OpenAPIVersion.v3;\n\t\tcase '2.0':\n\t\t\treturn OpenAPIVersion.v2;\n\t\tdefault:\n\t\t\treturn OpenAPIVersion.unknown;\n\t}\n}\n\nexport class OpenAPIProvider extends Provider {\n\tpublic parse(doc: OpenAPIV3.Document): ProviderInitResult {\n\t\tconst version = getDocVersion(doc);\n\n\t\tlogger.debug(`openapi version ${version}`);\n\n\t\tswitch (version) {\n\t\t\tcase OpenAPIVersion.v2:\n\t\t\t\treturn new V2(doc as unknown as OpenAPIV2.Document).init();\n\t\t\tcase OpenAPIVersion.v3:\n\t\t\t\treturn new V3(doc as unknown as OpenAPIV3.Document).init();\n\t\t\tcase OpenAPIVersion.v3_1:\n\t\t\t\treturn new V3_1(doc as unknown as OpenAPIV3_1.Document).init();\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Not a valid OpenAPI version: ${version}`);\n\t\t}\n\t}\n}\n\nfunction getAdaptor(type: keyof typeof Adaptors): Adapter {\n\tswitch (type) {\n\t\tcase ads.axios:\n\t\t\treturn new AxiosAdapter();\n\t\tdefault:\n\t\t\treturn new FetchAdapter();\n\t}\n}\n\nexport interface CodeGenResult {\n\tcode: string;\n\tstats: {\n\t\tendpoints: number;\n\t\tschemas: number;\n\t\tduration: number;\n\t};\n}\n\nexport async function codeGen(\n\tinitOptions: ProviderInitOptions\n): Promise<CodeGenResult> {\n\tconst startTime = Date.now();\n\tconst { verbose } = initOptions;\n\n\tif (verbose) {\n\t\tlogger.setLevel('debug');\n\t} else {\n\t\tlogger.setLevel('info');\n\t}\n\n\tlogger.info(`Fetch document from ${initOptions.docURL}`);\n\n\tconst { transport, source } = Base.resolveSpecURL(initOptions.docURL);\n\tconst doc =\n\t\ttransport === 'file'\n\t\t\t? await (async () => {\n\t\t\t\t\tlet raw: string;\n\t\t\t\t\ttry {\n\t\t\t\t\t\traw = await readFile(source, 'utf8');\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif ((error as NodeJS.ErrnoException)?.code === 'ENOENT') {\n\t\t\t\t\t\t\tthrow createErrors.specNotFound(source, error as Error);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Failed to read OpenAPI spec from ${source}: ${\n\t\t\t\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn JSON.parse(raw) as unknown;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow createErrors.specParseFailed(\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\terror as Error\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t})()\n\t\t\t: await Base.fetchDoc(source, initOptions.requestOptions);\n\n\tconst provider = new OpenAPIProvider(initOptions, doc);\n\tconst { enums, schemas, parameters, responses, requestBodies, apis } =\n\t\tprovider;\n\n\tconst adaptor = getAdaptor(initOptions.adaptor ?? ads.fetch);\n\tconst code = await Generator.genCode(\n\t\t{\n\t\t\tenums,\n\t\t\tschemas,\n\t\t\tparameters,\n\t\t\tresponses,\n\t\t\trequestBodies,\n\t\t\tapis,\n\t\t},\n\t\tinitOptions,\n\t\tadaptor\n\t);\n\n\tif (initOptions.output) {\n\t\tawait Generator.write(code, initOptions.output);\n\t}\n\n\tconst duration = Date.now() - startTime;\n\tconst endpoints = Object.keys(apis).length;\n\tconst schemasCount = Object.keys(schemas).length;\n\n\treturn {\n\t\tcode,\n\t\tstats: {\n\t\t\tendpoints,\n\t\t\tschemas: schemasCount,\n\t\t\tduration,\n\t\t},\n\t};\n}\n\nexport type { ProviderInitOptions } from '../core/index.js';\n","import { createHash } from 'node:crypto';\nimport { readFile, stat, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport type { CodeGenResult } from '../openapi/index.js';\n\n/**\n * Serialized form of a generated artifact, persisted to disk so we can\n * skip the OpenAPI parse + codegen pass on subsequent vite restarts when\n * nothing has changed.\n */\nexport interface CacheEntry {\n\t/** SHA-256 of the resolved options (everything except the spec content) */\n\toptionsHash: string;\n\t/** mtime of the spec file in milliseconds (or undefined for remote specs) */\n\tspecMtimeMs: number | undefined;\n\t/** SHA-256 of the spec file content (or undefined for remote specs) */\n\tspecContentHash: string | undefined;\n\t/** The generated code */\n\tcode: string;\n\t/** Generation stats */\n\tstats: CodeGenResult['stats'];\n}\n\n/**\n * Cache for a single vite-plugin codegen run. Lives only for the duration\n * of one plugin invocation — there is no module-level state.\n *\n * Cache files are stored at:\n *\n * <cacheDir>/<optionsHash>.json\n *\n * where `<cacheDir>` defaults to `node_modules/.cache/apicodegen` but can\n * be overridden via `cacheDir`.\n */\nexport class CodegenCache {\n\tprivate readonly cacheDir: string;\n\n\tconstructor(cacheDir: string) {\n\t\tthis.cacheDir = cacheDir;\n\t}\n\n\t/** Hash the options that affect generated output (excluding the spec). */\n\tstatic hashOptions(options: Record<string, unknown>): string {\n\t\t// Sort keys for stability.\n\t\tconst keys = Object.keys(options).sort();\n\t\tconst payload = keys\n\t\t\t.filter((k) => k !== 'verbose' && k !== 'typeCheck' && k !== 'cache')\n\t\t\t.map((k) => `${k}=${JSON.stringify(options[k])}`)\n\t\t\t.join('|');\n\t\treturn createHash('sha256').update(payload).digest('hex').slice(0, 16);\n\t}\n\n\t/** Hash the raw spec content so unrelated edits are detected. */\n\tstatic hashContent(content: string): string {\n\t\treturn createHash('sha256').update(content).digest('hex').slice(0, 16);\n\t}\n\n\t/**\n\t * Look up a cached entry. Returns `null` on miss / corruption / disabled.\n\t *\n\t * @param optionsHash Options hash from `hashOptions`.\n\t * @param specSource Resolved spec path or URL. Local paths use mtime +\n\t * content hash; URLs always miss (no cache).\n\t */\n\tasync lookup(\n\t\toptionsHash: string,\n\t\tspecSource: string\n\t): Promise<CacheEntry | null> {\n\t\tconst cachePath = path.join(this.cacheDir, `${optionsHash}.json`);\n\t\tlet raw: string;\n\t\ttry {\n\t\t\traw = await readFile(cachePath, 'utf8');\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet entry: CacheEntry;\n\t\ttry {\n\t\t\tentry = JSON.parse(raw) as CacheEntry;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (entry.optionsHash !== optionsHash) return null;\n\n\t\t// Remote specs are not cached — too risky to assume the upstream\n\t\t// didn't change.\n\t\tconst isRemote =\n\t\t\tspecSource.startsWith('http://') || specSource.startsWith('https://');\n\t\tif (isRemote) return null;\n\n\t\t// Local spec: verify mtime + content hash.\n\t\tlet currentMtimeMs: number | undefined;\n\t\ttry {\n\t\t\tconst st = await stat(specSource);\n\t\t\tcurrentMtimeMs = st.mtimeMs;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t\tif (currentMtimeMs !== entry.specMtimeMs) return null;\n\n\t\tif (entry.specContentHash) {\n\t\t\tlet content: string;\n\t\t\ttry {\n\t\t\t\tcontent = await readFile(specSource, 'utf8');\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (CodegenCache.hashContent(content) !== entry.specContentHash) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\treturn entry;\n\t}\n\n\t/** Persist a successful codegen result. */\n\tasync store(entry: CacheEntry): Promise<void> {\n\t\tconst cachePath = path.join(this.cacheDir, `${entry.optionsHash}.json`);\n\t\tconst dir = path.dirname(cachePath);\n\t\tawait import('fs-extra').then((fs) => fs.ensureDir(dir));\n\t\tawait writeFile(cachePath, JSON.stringify(entry));\n\t}\n}\n","import path from 'node:path';\nimport { createScopedLogger } from '@moccona/logger';\nimport fs from 'fs-extra';\nimport type { PluginOption } from 'vite';\nimport { loadConfig, toProviderOptions } from '../core/config.js';\nimport {\n\tcreateErrors,\n\tformatError,\n\tisApicodegenError,\n\twrapError,\n} from '../core/errors.js';\nimport { type CodeGenResult, codeGen } from '../openapi/index.js';\nimport { CodegenCache } from './cache.js';\n\nconst PLUGIN_NAME = 'api-code-gen';\nconst logger = createScopedLogger('api-code-gen');\n\nexport type ApiCodeGenPluginOptions = {\n\t/** Human-readable name for this API config (required) */\n\tname: string;\n\t/** OpenAPI spec file path or URL */\n\tspec?: string;\n\t/** Output file path */\n\toutput?: string;\n\t/** HTTP client adaptor */\n\tadaptor?: 'fetch' | 'axios';\n\t/** Base URL for API endpoints */\n\tbaseURL?: string;\n\t/** Custom client import source path */\n\timportClientSource?: string;\n\t/** Enable verbose logging */\n\tverbose?: boolean;\n\t/** Run type check after generation (default: true) */\n\ttypeCheck?: boolean;\n\t/**\n\t * Enable on-disk caching of generated code (default: true).\n\t * Subsequent vite invocations skip codegen when neither the spec file\n\t * nor the options have changed. Disable to force a fresh generation.\n\t */\n\tcache?: boolean;\n\t/**\n\t * Directory to store cache entries (default: `node_modules/.cache/apicodegen`).\n\t * Ignored when `cache === false`.\n\t */\n\tcacheDir?: string;\n};\n\n/**\n * Run TypeScript type checking on generated file\n */\nasync function runTypeCheck(filePath: string): Promise<string[]> {\n\tconst { execaCommand } = await import('execa');\n\tconst errors: string[] = [];\n\n\ttry {\n\t\tawait execaCommand(`npx tsc ${filePath} --noEmit`, {\n\t\t\tshell: true,\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\terrors.push(error.message);\n\t\t}\n\t}\n\n\treturn errors;\n}\n\n/**\n * Validate spec path exists\n */\nasync function validateSpecPath(specPath: string): Promise<void> {\n\t// For URLs, skip file existence check\n\tif (specPath.startsWith('http://') || specPath.startsWith('https://')) {\n\t\treturn;\n\t}\n\n\tconst filePath = specPath.replace(/^file:\\/\\//, '');\n\tconst absolutePath = path.isAbsolute(filePath)\n\t\t? filePath\n\t\t: path.resolve(process.cwd(), filePath);\n\n\tconst exists = await fs.pathExists(absolutePath);\n\tif (!exists) {\n\t\tthrow createErrors.specNotFound(absolutePath);\n\t}\n}\n\n/**\n * Generate code for a single API configuration\n */\nasync function generateForOption(option: ApiCodeGenPluginOptions): Promise<{\n\tsuccess: boolean;\n\tname: string;\n\toutput?: string;\n\tstats?: { endpoints: number; schemas: number; duration: number };\n\terror?: unknown;\n\tcached?: boolean;\n}> {\n\tconst {\n\t\tname,\n\t\ttypeCheck = true,\n\t\tverbose,\n\t\tcache = true,\n\t\tcacheDir,\n\t\t...restOptions\n\t} = option;\n\n\ttry {\n\t\tconsole.log(`\\x1b[36m├─\\x1b[0m ${name}`);\n\n\t\t// Use config loader to handle env vars and config files\n\t\tconst config = await loadConfig({\n\t\t\tname,\n\t\t\tcliOptions: { ...restOptions, verbose },\n\t\t});\n\n\t\t// Validate spec exists\n\t\tawait validateSpecPath(config.spec);\n\n\t\t// Ensure output directory exists\n\t\tif (config.output) {\n\t\t\tconst outputDir = path.dirname(config.output);\n\t\t\tawait fs.ensureDir(outputDir);\n\t\t}\n\n\t\t// Convert to provider options and resolve docURL.\n\t\t// Pass absolute paths / file:// URLs through unchanged so the\n\t\t// generator's `Base.resolveSpecURL` can pick the file transport.\n\t\t// Only relative paths need to be anchored to cwd.\n\t\tlet docURL = config.spec;\n\t\tif (\n\t\t\t!docURL.startsWith('http://') &&\n\t\t\t!docURL.startsWith('https://') &&\n\t\t\t!docURL.startsWith('file://') &&\n\t\t\t!docURL.startsWith('/') &&\n\t\t\t!/^[A-Za-z]:[\\\\/]/.test(docURL)\n\t\t) {\n\t\t\tdocURL = path.resolve(process.cwd(), docURL);\n\t\t}\n\n\t\t// Resolve cache directory (default node_modules/.cache/apicodegen).\n\t\tconst resolvedCacheDir =\n\t\t\tcacheDir ??\n\t\t\tpath.join(process.cwd(), 'node_modules', '.cache', 'apicodegen');\n\t\tconst codegenCache = cache ? new CodegenCache(resolvedCacheDir) : null;\n\n\t\tconst optionsHash = CodegenCache.hashOptions({\n\t\t\tname,\n\t\t\tspec: docURL,\n\t\t\toutput: config.output,\n\t\t\tadaptor: config.adaptor,\n\t\t\tbaseURL: config.baseURL,\n\t\t\timportClientSource: config.importClientSource,\n\t\t});\n\n\t\tlet result: CodeGenResult | null = null;\n\t\tlet cached = false;\n\n\t\tif (codegenCache) {\n\t\t\tconst cachedEntry = await codegenCache.lookup(optionsHash, docURL);\n\t\t\tif (cachedEntry) {\n\t\t\t\tresult = {\n\t\t\t\t\tcode: cachedEntry.code,\n\t\t\t\t\tstats: cachedEntry.stats,\n\t\t\t\t};\n\t\t\t\tcached = true;\n\t\t\t\tif (verbose) {\n\t\t\t\t\tlogger.debug(`Cache hit for ${name} (${optionsHash})`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!result) {\n\t\t\tresult = await codeGen({\n\t\t\t\t...toProviderOptions(config),\n\t\t\t\tdocURL,\n\t\t\t});\n\n\t\t\t// Persist to cache for subsequent runs.\n\t\t\tif (codegenCache) {\n\t\t\t\ttry {\n\t\t\t\t\tconst fsPromises = await import('node:fs/promises');\n\t\t\t\t\tlet specMtimeMs: number | undefined;\n\t\t\t\t\tlet specContentHash: string | undefined;\n\t\t\t\t\tconst isRemote =\n\t\t\t\t\t\tdocURL.startsWith('http://') || docURL.startsWith('https://');\n\t\t\t\t\tif (!isRemote) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst st = await fsPromises.stat(docURL);\n\t\t\t\t\t\t\tspecMtimeMs = st.mtimeMs;\n\t\t\t\t\t\t\tconst content = await fsPromises.readFile(docURL, 'utf8');\n\t\t\t\t\t\t\tspecContentHash = CodegenCache.hashContent(content);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// Spec unreadable; skip caching.\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tawait codegenCache.store({\n\t\t\t\t\t\toptionsHash,\n\t\t\t\t\t\tspecMtimeMs,\n\t\t\t\t\t\tspecContentHash,\n\t\t\t\t\t\tcode: result.code,\n\t\t\t\t\t\tstats: result.stats,\n\t\t\t\t\t});\n\t\t\t\t} catch (cacheError) {\n\t\t\t\t\t// Cache write failures must not break generation.\n\t\t\t\t\tif (verbose) {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t`Cache write failed for ${name}: ${(cacheError as Error).message}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (config.output) {\n\t\t\tawait fs.writeFile(config.output, result.code);\n\t\t}\n\n\t\t// Run type check if enabled\n\t\tif (typeCheck && config.output) {\n\t\t\tconst typeErrors = await runTypeCheck(config.output);\n\t\t\tif (typeErrors.length > 0) {\n\t\t\t\tlogger.warn(`Type check failed for ${config.output}`);\n\t\t\t\tif (verbose) {\n\t\t\t\t\tfor (const error of typeErrors) {\n\t\t\t\t\t\tlogger.warn(` ${error}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tname,\n\t\t\toutput: config.output,\n\t\t\tstats: result.stats,\n\t\t\tcached,\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tname,\n\t\t\terror,\n\t\t};\n\t}\n}\n\n/**\n * Main Vite plugin function\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { apiCodeGenPlugin } from '@moccona/apicodegen/vite';\n *\n * export default defineConfig({\n * plugins: [\n * apiCodeGenPlugin([\n * {\n * name: 'my-api',\n * spec: './openapi.json',\n * output: './src/api/generated.ts',\n * baseURL: 'https://api.example.com',\n * },\n * ]),\n * ],\n * });\n * ```\n */\nexport function apiCodeGenPlugin(\n\toptions: ApiCodeGenPluginOptions[]\n): PluginOption {\n\tif (!Array.isArray(options) || options.length === 0) {\n\t\tlogger.warn('No API configurations provided to apiCodeGenPlugin');\n\t\treturn { name: PLUGIN_NAME };\n\t}\n\n\treturn {\n\t\tname: PLUGIN_NAME,\n\n\t\tasync config(_config, env) {\n\t\t\tconsole.log(`\\x1b[1m\\x1b[36m${'─'.repeat(50)}\\x1b[0m`);\n\t\t\tconsole.log(`\\x1b[1m\\x1b[36mAPI Code Gen\\x1b[0m`);\n\t\t\tconsole.log(`\\x1b[90mMode:\\x1b[0m ${env?.command || 'unknown'}`);\n\t\t\tconsole.log(`\\x1b[1m\\x1b[36m${'─'.repeat(50)}\\x1b[0m`);\n\n\t\t\tconst results = await Promise.all(options.map(generateForOption));\n\t\t\tconst successCount = results.filter((r) => r.success).length;\n\t\t\tconst failCount = options.length - successCount;\n\n\t\t\tconsole.log(`\\x1b[1m\\x1b[36m${'─'.repeat(50)}\\x1b[0m`);\n\n\t\t\tfor (const result of results) {\n\t\t\t\tif (result.success) {\n\t\t\t\t\tconst { name, output, stats, cached } = result;\n\t\t\t\t\tif (stats) {\n\t\t\t\t\t\tconst cachedTag = cached ? ' \\x1b[90m[cached]\\x1b[0m' : '';\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`\\x1b[32m✓\\x1b[0m ${name} → ${output} (${stats.endpoints} endpoints, ${stats.schemas} schemas) ${stats.duration}ms${cachedTag}`\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(`\\x1b[32m✓\\x1b[0m ${name} → ${output || 'N/A'}`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst { name, error } = result;\n\t\t\t\t\tif (isApicodegenError(error)) {\n\t\t\t\t\t\tconsole.log(`\\x1b[31m✗\\x1b[0m ${name}`);\n\t\t\t\t\t\tconsole.log(`\\x1b[90m${formatError(error, true)}\\x1b[0m`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst wrapped = wrapError(error!, {\n\t\t\t\t\t\t\tcode: 'E_GENERATION_FAILED',\n\t\t\t\t\t\t\tmessage: `Failed to generate API \"${name}\"`,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconsole.log(`\\x1b[31m✗\\x1b[0m ${name}`);\n\t\t\t\t\t\tconsole.log(`\\x1b[90m${formatError(wrapped, true)}\\x1b[0m`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconsole.log(`\\x1b[1m\\x1b[36m${'─'.repeat(50)}\\x1b[0m`);\n\n\t\t\tconst totalDuration = results.reduce(\n\t\t\t\t(sum, r) => sum + (r.stats?.duration || 0),\n\t\t\t\t0\n\t\t\t);\n\t\t\tconst totalEndpoints = results.reduce(\n\t\t\t\t(sum, r) => sum + (r.stats?.endpoints || 0),\n\t\t\t\t0\n\t\t\t);\n\t\t\tconst totalSchemas = results.reduce(\n\t\t\t\t(sum, r) => sum + (r.stats?.schemas || 0),\n\t\t\t\t0\n\t\t\t);\n\n\t\t\tif (failCount === 0) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`\\x1b[32m✓\\x1b[0m API Code Gen - Complete (\\x1b[90m${successCount}/${options.length} succeeded\\x1b[0m, ${totalEndpoints} endpoints, ${totalSchemas} schemas, ${totalDuration}ms\\x1b[0m)`\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`\\x1b[33m⚠\\x1b[0m API Code Gen - Complete (\\x1b[90m${successCount} succeeded, ${failCount} failed\\x1b[0m, ${totalEndpoints} endpoints, ${totalSchemas} schemas, ${totalDuration}ms\\x1b[0m)`\n\t\t\t\t);\n\t\t\t}\n\t\t\tconsole.log(`\\x1b[1m\\x1b[36m${'─'.repeat(50)}\\x1b[0m`);\n\n\t\t\treturn {};\n\t\t},\n\t};\n}\n\nexport default apiCodeGenPlugin;\n"],"mappings":";;;;;;;;;AAkGA,IAAY,aAAL,yBAAA,YAAA;CACN,WAAA,UAAA;CACA,WAAA,UAAA;CACA,WAAA,WAAA;CACA,WAAA,WAAA;CACA,WAAA,WAAA;;AACD,EAAA,CAAA,CAAA;AAgBA,IAAY,cAAL,yBAAA,aAAA;CACN,YAAA,SAAA;CACA,YAAA,SAAA;CACA,YAAA,UAAA;CACA,YAAA,YAAA;CACA,YAAA,aAAA;CACA,YAAA,UAAA;CACA,YAAA,WAAA;CACA,YAAA,WAAA;;AACD,EAAA,CAAA,CAAA;AA6BA,IAAY,WAAL,yBAAA,UAAA;CACN,SAAA,WAAA;CACA,SAAA,WAAA;;AACD,EAAA,CAAA,CAAA;;;;;;ACnGA,MAAM,iBAAiB,IAAI,IAAI;CAAC;CAAQ;CAAK;CAAO;CAAM;AAAQ,CAAC;;;;AAKnE,MAAM,eAAuD;CAC5D,iBAAiB;CACjB,mBAAmB;CACnB,qBAAqB;CACrB,oBAAoB;CACpB,oBAAoB;CACpB,kBAAkB;CAClB,uBAAuB;AACxB;;;;AAKA,SAAS,cAAyC;CACjD,MAAM,SAAoC,CAAC;CAE3C,KAAK,MAAM,CAAC,QA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S,IAAI,UAAU,CAAC;IACpC;IACA;IACA;GACD;GACA;EACD,CAAC;CACF;CAEA,qBAAqB,OAAe,SAAmC;EACtE,OAAO,IAAI,gBAAgB;GAC1B,MAAM,WAAW;GACjB,SAAS,2BAA2B;GACpC,MAAM;GACN,aAAa,CAAC,YAAY,MAAM,8BAA8B;EAC/D,CAAC;CACF;AACD;;;;AAKA,SAAgB,UACf,OACA,SACkB;CAClB,IAAI,iBAAiB,iBACpB,OAAO;CAGR,IAAI,iBAAiB,OACpB,OAAO,IAAI,gBAAgB;EAC1B,MAAM,SAAS,QAAQ,WAAW;EAClC,SAAS,SAAS,WAAW,MAAM;EACnC,UAAU,SAAS;EACnB,aAAa,SAAS;EACtB,OAAO;CACR,CAAC;CAGF,OAAO,IAAI,gBAAgB;EAC1B,MAAM,SAAS,QAAQ,WAAW;EAClC,SAAS,OAAO,KAAK;EACrB,aAAa,SAAS;CACvB,CAAC;AACF;;;;AAKA,SAAgB,kBAAkB,OAA0C;CAC3E,OAAO,iBAAiB;AACzB;;;;;;;AC/UA,IAAsB,UAAtB,MAA8B,CAkD9B;;;AC1EA,MAAa,qBAAqB,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;;;;;ACpCD,IAAsB,OAAtB,MAAsB,KAAK;CAC1B,cAAwB;EACvB,IAAI,IAAI,WAAW,MAClB,MAAM,IAAI,MAAM,mCAAmC;CAErD;;;;;;;CAQA,OAAO,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