swagger-typescript-api 13.6.2 → 13.6.3
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/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-BQOg3KNL.mjs → src-Cs2Ms4ew.mjs} +49 -7
- package/dist/src-Cs2Ms4ew.mjs.map +1 -0
- package/dist/{src-CxPRLeDh.cjs → src-DqcUpLvd.cjs} +49 -7
- package/dist/src-DqcUpLvd.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/src-BQOg3KNL.mjs.map +0 -1
- package/dist/src-CxPRLeDh.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-Cs2Ms4ew.mjs","names":["path","packageJson.version","SCHEMA_TYPES","CONSTANTS.PROJECT_VERSION","CONSTANTS","SCHEMA_TYPES","SCHEMA_TYPES","SCHEMA_TYPES","SCHEMA_TYPES","SCHEMA_TYPES","SCHEMA_TYPES","SCHEMA_TYPES","SCHEMA_TYPES","SCHEMA_TYPES","path","url","path","url"],"sources":["../src/code-formatter.ts","../src/util/name-resolver.ts","../src/util/random.ts","../src/component-type-name-resolver.ts","../package.json","../src/constants.ts","../src/util/object-assign.ts","../src/configuration.ts","../src/util/pascal-case.ts","../src/schema-components-map.ts","../src/schema-parser/schema-formatters.ts","../src/util/sort-by-property.ts","../src/schema-parser/mono-schema-parser.ts","../src/schema-parser/base-schema-parsers/array.ts","../src/schema-parser/base-schema-parsers/complex.ts","../src/schema-parser/base-schema-parsers/discriminator.ts","../src/schema-parser/util/enum-key-resolver.ts","../src/schema-parser/base-schema-parsers/enum.ts","../src/schema-parser/base-schema-parsers/object.ts","../src/schema-parser/base-schema-parsers/primitive.ts","../src/schema-parser/complex-schema-parsers/all-of.ts","../src/schema-parser/complex-schema-parsers/any-of.ts","../src/schema-parser/complex-schema-parsers/not.ts","../src/schema-parser/complex-schema-parsers/one-of.ts","../src/schema-parser/schema-parser.ts","../src/schema-parser/schema-utils.ts","../src/schema-parser/schema-parser-fabric.ts","../src/util/id.ts","../src/schema-routes/util/specific-arg-name-resolver.ts","../src/schema-routes/schema-routes.ts","../src/resolved-swagger-schema.ts","../src/util/request.ts","../src/swagger-schema-resolver.ts","../src/templates-worker.ts","../src/translators/translator.ts","../src/translators/javascript.ts","../src/type-name-formatter.ts","../src/util/file-system.ts","../src/util/lodash-compat.ts","../src/code-gen-process.ts","../types/index.ts","../src/commands/generate-templates/configuration.ts","../src/commands/generate-templates/templates-gen-process.ts","../src/commands/generate-templates/index.ts","../src/index.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { Biome, Distribution } from \"@biomejs/js-api\";\nimport * as nanoid from \"nanoid\";\nimport * as typescript from \"typescript\";\nimport type { CodeGenConfig } from \"./configuration.js\";\n\nexport class CodeFormatter {\n config: CodeGenConfig;\n\n constructor(config: CodeGenConfig) {\n this.config = config;\n }\n\n removeUnusedImports = (content: string) => {\n const tempFileName = \"file.ts\";\n\n const host = new TsLanguageServiceHost(tempFileName, content);\n const languageService = typescript.createLanguageService(host);\n\n const fileTextChanges = languageService.organizeImports(\n { type: \"file\", fileName: tempFileName },\n { newLineCharacter: typescript.sys.newLine },\n undefined,\n )[0];\n\n if (fileTextChanges?.textChanges.length) {\n return fileTextChanges.textChanges.reduceRight(\n (content, { span, newText }) =>\n `${content.slice(0, span.start)}${newText}${content.slice(\n span.start + span.length,\n )}`,\n content,\n );\n }\n\n return content;\n };\n\n format = async (content: string) => {\n const biome = await Biome.create({ distribution: Distribution.NODE });\n const biomeProject = biome.openProject();\n biome.applyConfiguration(biomeProject.projectKey, {\n files: { maxSize: Number.MAX_SAFE_INTEGER },\n formatter: { indentStyle: \"space\" },\n });\n const formatted = biome.formatContent(biomeProject.projectKey, content, {\n filePath: path.format({ name: nanoid.nanoid(), ext: \"ts\" }),\n });\n return formatted.content;\n };\n\n formatCode = async (\n code: string,\n { removeUnusedImports = true, format = true } = {},\n ) => {\n if (removeUnusedImports) {\n code = this.removeUnusedImports(code);\n }\n if (format) {\n code = await this.format(code);\n }\n return code;\n };\n}\n\nclass TsLanguageServiceHost {\n fileName: string;\n content: string;\n compilerOptions: typescript.CompilerOptions;\n\n constructor(fileName: string, content: string) {\n this.fileName = fileName;\n this.content = content;\n const tsconfig = typescript.findConfigFile(\n fileName,\n typescript.sys.fileExists,\n );\n this.compilerOptions = tsconfig\n ? typescript.convertCompilerOptionsFromJson(\n typescript.readConfigFile(tsconfig, typescript.sys.readFile).config\n .compilerOptions,\n \"\",\n ).options\n : typescript.getDefaultCompilerOptions();\n }\n\n getNewLine() {\n return \"newLine\" in typescript.sys ? typescript.sys.newLine : \"\\n\";\n }\n getScriptFileNames() {\n return [this.fileName];\n }\n getCompilationSettings() {\n return this.compilerOptions;\n }\n getDefaultLibFileName() {\n return typescript.getDefaultLibFileName(this.getCompilationSettings());\n }\n getCurrentDirectory() {\n return process.cwd();\n }\n getScriptVersion() {\n return typescript.version;\n }\n getScriptSnapshot() {\n return typescript.ScriptSnapshot.fromString(this.content);\n }\n readFile(fileName: string, encoding: string) {\n if (fileName === this.fileName) {\n return this.content;\n }\n\n return typescript.sys.readFile(fileName, encoding);\n }\n fileExists(path: string) {\n return typescript.sys.fileExists(path);\n }\n}\n","import { consola } from \"consola\";\nimport { compact, uniq } from \"es-toolkit\";\nimport type { CodeGenConfig } from \"../configuration.js\";\n\ntype Resolver = (reserved: string[], extras?: string[]) => string;\n\nexport class NameResolver {\n reservedNames: string[] = [];\n getFallbackName: Resolver;\n\n config: CodeGenConfig;\n\n constructor(\n config: CodeGenConfig,\n reservedNames: string[],\n getFallbackName: Resolver,\n ) {\n this.config = config;\n this.getFallbackName = getFallbackName;\n this.reserve(reservedNames);\n }\n\n reserve(names: string[]) {\n const fixedNames = uniq(compact(names));\n for (const name of fixedNames) {\n if (this.reservedNames.indexOf(name) === -1) {\n this.reservedNames.push(name);\n }\n }\n }\n\n unreserve(names: string[]) {\n this.reservedNames = this.reservedNames.filter(\n (reservedName) => !names.some((name) => name === reservedName),\n );\n }\n\n isReserved(name: string) {\n return this.reservedNames.some((reservedName) => reservedName === name);\n }\n\n resolve(\n variants: string[],\n resolver?: Resolver,\n extras?: string[],\n shouldReserve = true,\n ): string | null {\n if (typeof resolver === \"function\") {\n let usageName: string | null = null;\n while (usageName === null) {\n const variant = resolver(variants, extras);\n\n if (variant === undefined) {\n consola.warn(\n \"unable to resolve name. current reserved names: \",\n ...this.reservedNames,\n );\n return null;\n }\n if (!shouldReserve || !this.isReserved(variant)) {\n usageName = variant;\n }\n }\n\n shouldReserve && this.reserve([usageName]);\n return usageName;\n }\n\n if (Array.isArray(variants)) {\n let usageName: string | null = null;\n const uniqVariants = uniq(compact(variants));\n\n for (const variant of uniqVariants) {\n if (!usageName && (!shouldReserve || !this.isReserved(variant))) {\n usageName = variant;\n }\n }\n\n if (usageName) {\n shouldReserve && this.reserve([usageName]);\n return usageName;\n }\n\n consola.debug(\n \"trying to resolve name with using fallback name generator using variants\",\n ...variants,\n );\n return this.resolve(variants, this.getFallbackName, extras);\n }\n\n consola.debug(\n \"problem with reserving names. current reserved names: \",\n ...this.reservedNames,\n );\n return null;\n }\n}\n","export const getRandomInt = (min = 0, max = 1) => {\n if (min === max) return min;\n\n return Math.round(Math.random() * (max - min) + min);\n};\n","import { consola } from \"consola\";\nimport type { CodeGenConfig } from \"./configuration.js\";\nimport { NameResolver } from \"./util/name-resolver.js\";\nimport { getRandomInt } from \"./util/random.js\";\n\nexport class ComponentTypeNameResolver extends NameResolver {\n counter = 1;\n fallbackNameCounter = 1;\n countersByVariant = new Map<string, number>();\n\n constructor(config: CodeGenConfig, reservedNames: string[]) {\n super(config, reservedNames, (variants) => {\n const randomVariant = variants[getRandomInt(0, variants.length - 1)];\n if (randomVariant) {\n if (!this.countersByVariant.has(randomVariant)) {\n this.countersByVariant.set(randomVariant, 0);\n }\n const variantCounter =\n (this.countersByVariant.get(randomVariant) as number) + 1;\n this.countersByVariant.set(randomVariant, variantCounter);\n const dirtyResolvedName = `${randomVariant}${variantCounter}`;\n consola.debug(\n \"generated dirty resolved type name for component - \",\n dirtyResolvedName,\n );\n return dirtyResolvedName;\n }\n\n const fallbackName = `${this.config.componentTypeNameResolver}${this\n .fallbackNameCounter++}`;\n consola.debug(\n \"generated fallback type name for component - \",\n fallbackName,\n );\n return fallbackName;\n });\n }\n}\n","","import packageJson from \"../package.json\" with { type: \"json\" };\n\nexport const DEFAULT_BODY_ARG_NAME = \"data\";\n\nexport const FILE_PREFIX = `/* eslint-disable */\n/* tslint:disable */\n// @ts-nocheck\n/*\n * ---------------------------------------------------------------\n * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##\n * ## ##\n * ## AUTHOR: acacode ##\n * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##\n * ---------------------------------------------------------------\n */\n\n`;\n\nexport const HTTP_CLIENT = {\n FETCH: \"fetch\",\n AXIOS: \"axios\",\n} as const;\n\nexport const PROJECT_VERSION = packageJson.version;\n\nexport const RESERVED_BODY_ARG_NAMES = [\"data\", \"body\", \"reqBody\"];\n\nexport const RESERVED_HEADER_ARG_NAMES = [\"headers\", \"headersParams\"];\n\nexport const RESERVED_PATH_ARG_NAMES = [\"path\", \"pathParams\"];\n\nexport const RESERVED_QUERY_ARG_NAMES = [\"query\", \"queryParams\", \"queryArg\"];\n\nexport const RESERVED_REQ_PARAMS_ARG_NAMES = [\n \"params\",\n \"requestParams\",\n \"reqParams\",\n \"httpParams\",\n];\n\nexport const SCHEMA_TYPES = {\n ARRAY: \"array\",\n OBJECT: \"object\",\n ENUM: \"enum\",\n REF: \"$ref\",\n PRIMITIVE: \"primitive\",\n COMPLEX: \"complex\",\n DISCRIMINATOR: \"discriminator\",\n COMPLEX_ONE_OF: \"oneOf\",\n COMPLEX_ANY_OF: \"anyOf\",\n COMPLEX_ALL_OF: \"allOf\",\n COMPLEX_NOT: \"not\",\n COMPLEX_UNKNOWN: \"__unknown\",\n} as const;\n","import { merge } from \"es-toolkit\";\n\ntype Updater = (target: unknown) => unknown;\n\nexport const objectAssign = (target: object, updater: Updater | unknown) => {\n if (!updater) return;\n const update = (typeof updater === \"function\" ? updater(target) : updater) as\n | Record<string, unknown>\n | null\n | undefined;\n if (!update) return;\n const undefinedKeys = Object.entries(update)\n .filter(([, value]) => value === undefined)\n .map(([key]) => key);\n merge(target, update);\n for (const key of undefinedKeys) {\n (target as Record<string, unknown>)[key] = undefined;\n }\n};\n","import { compact, merge, uniq } from \"es-toolkit\";\nimport type { OpenAPI } from \"openapi-types\";\nimport * as typescript from \"typescript\";\nimport type {\n ExtractingOptions,\n GenerateApiConfiguration,\n Hooks,\n SchemaComponent,\n} from \"../types/index.js\";\nimport { ComponentTypeNameResolver } from \"./component-type-name-resolver.js\";\nimport * as CONSTANTS from \"./constants.js\";\nimport type { ResolvedSwaggerSchema } from \"./resolved-swagger-schema.js\";\nimport type { MonoSchemaParser } from \"./schema-parser/mono-schema-parser.js\";\nimport type { SchemaParser } from \"./schema-parser/schema-parser.js\";\nimport type { Translator } from \"./translators/translator.js\";\nimport { objectAssign } from \"./util/object-assign.js\";\n\nconst TsKeyword = {\n Number: \"number\",\n String: \"string\",\n Boolean: \"boolean\",\n Any: \"any\",\n Void: \"void\",\n Unknown: \"unknown\",\n Null: \"null\",\n Undefined: \"undefined\",\n Object: \"object\",\n File: \"File\",\n Blob: \"Blob\",\n Date: \"Date\",\n Type: \"type\",\n Enum: \"enum\",\n Interface: \"interface\",\n Array: \"Array\",\n Record: \"Record\",\n Intersection: \"&\",\n Union: \"|\",\n};\n\nconst TsCodeGenKeyword = {\n UtilRequiredKeys: \"UtilRequiredKeys\",\n};\n\nexport class CodeGenConfig {\n version = CONSTANTS.PROJECT_VERSION;\n /** CLI flag */\n templates = \"\";\n /** CLI flag */\n generateResponses = false;\n /** CLI flag */\n defaultResponseAsSuccess = false;\n /** CLI flag */\n generateRouteTypes = false;\n /** CLI flag */\n generateClient = true;\n /** CLI flag */\n generateUnionEnums = false;\n /** CLI flag */\n addReadonly = false;\n enumNamesAsValues = false;\n /** parsed swagger schema from getSwaggerObject() */\n\n /** parsed swagger schema ref */\n swaggerSchema = null;\n /** original (converted to json) swagger schema ref */\n originalSchema = null;\n\n /** { \"#/components/schemas/Foo\": @TypeInfo, ... } */\n componentsMap = {};\n /** flag for catching conversion from swagger 2.0 */\n convertedFromSwagger2 = false;\n\n /** url index from paths used for merging into modules */\n moduleNameIndex = 0;\n\n /** use the first tag for the module name */\n moduleNameFirstTag = false;\n extractRequestParams = false;\n extractRequestBody = false;\n extractResponseBody = false;\n extractResponseError = false;\n extractResponses = false;\n extractEnums = false;\n fileNames = {\n dataContracts: \"data-contracts\",\n routeTypes: \"route-types\",\n httpClient: \"http-client\",\n outOfModuleApi: \"Common\",\n };\n routeNameDuplicatesMap = new Map();\n hooks: Hooks = {\n onPreBuildRoutePath: (_routePath: unknown) => void 0,\n onBuildRoutePath: (_routeData: unknown) => void 0,\n onInsertPathParam: (_pathParam: unknown) => void 0,\n onCreateComponent: (schema: SchemaComponent) => schema,\n onPreParseSchema: (\n _originalSchema: unknown,\n _typeName: unknown,\n _schemaType: unknown,\n ) => void 0,\n onParseSchema: (_originalSchema: unknown, parsedSchema: unknown) =>\n parsedSchema,\n onCreateRoute: (routeData: unknown) => routeData,\n onInit: (config: unknown, _codeGenProcess: unknown) => config,\n onPrepareConfig: (apiConfig: unknown) => apiConfig,\n onCreateRequestParams: (_rawType: unknown) => {},\n onCreateRouteName: () => {},\n onFormatTypeName: (\n _typeName: unknown,\n _rawTypeName: unknown,\n _schemaType: unknown,\n ) => {},\n onFormatRouteName: (_routeInfo: unknown, _templateRouteName: unknown) => {},\n };\n resolvedSwaggerSchema!: ResolvedSwaggerSchema;\n defaultResponseType;\n singleHttpClient = false;\n httpClientType = CONSTANTS.HTTP_CLIENT.FETCH;\n unwrapResponseData = false;\n disableThrowOnError = false;\n sortTypes = false;\n sortRoutes = false;\n templatePaths = {\n /** `templates/base` */\n base: \"\",\n /** `templates/default` */\n default: \"\",\n /** `templates/modular` */\n modular: \"\",\n /** usage path if `--templates` option is not set */\n original: \"\",\n /** custom path to templates (`--templates`) */\n custom: \"\",\n };\n /** Record<templateName, templateContent> */\n templatesToRender = {\n api: \"\",\n dataContracts: \"\",\n dataContractJsDoc: \"\",\n interfaceDataContract: \"\",\n typeDataContract: \"\",\n enumDataContract: \"\",\n objectFieldJsDoc: \"\",\n httpClient: \"\",\n routeTypes: \"\",\n routeName: \"\",\n };\n schemaParsers: Record<string, (...args: unknown[]) => MonoSchemaParser> = {};\n toJS = false;\n silent = false;\n typePrefix = \"\";\n typeSuffix = \"\";\n enumKeyPrefix = \"\";\n enumKeySuffix = \"\";\n patch = false;\n componentTypeNameResolver: ComponentTypeNameResolver;\n /** name of the main exported class */\n apiClassName = \"Api\";\n debug = false;\n anotherArrayType = false;\n internalTemplateOptions = {\n addUtilRequiredKeysType: false,\n };\n extraTemplates = [];\n input = \"\";\n modular = false;\n output = \"\";\n url = \"\";\n cleanOutput = false;\n spec: OpenAPI.Document | null = null;\n fileName = \"Api.ts\";\n authorizationToken: string | undefined;\n requestOptions: Record<string, any> | null = null;\n\n jsPrimitiveTypes: string[] = [];\n jsEmptyTypes: string[] = [];\n fixInvalidTypeNamePrefix = \"Type\";\n fixInvalidEnumKeyPrefix = \"Value\";\n\n enumKeyResolverName = \"Value\";\n typeNameResolverName = \"ComponentType\";\n specificArgNameResolverName = \"arg\";\n\n successResponseStatusRange = [200, 299];\n\n extractingOptions: Partial<ExtractingOptions> = {\n requestBodySuffix: [\"Payload\", \"Body\", \"Input\"],\n requestParamsSuffix: [\"Params\"],\n responseBodySuffix: [\"Data\", \"Result\", \"Output\"],\n responseErrorSuffix: [\n \"Error\",\n \"Fail\",\n \"Fails\",\n \"ErrorData\",\n \"HttpError\",\n \"BadResponse\",\n ],\n enumSuffix: [\"Enum\"],\n discriminatorMappingSuffix: [\"Mapping\", \"Mapper\", \"MapType\"],\n discriminatorAbstractPrefix: [\n \"Base\",\n \"Abstract\",\n \"Discriminator\",\n \"Internal\",\n \"Polymorph\",\n ],\n };\n\n compilerTsConfig = {\n module: typescript.ModuleKind.ESNext,\n noImplicitReturns: true,\n alwaysStrict: true,\n target: typescript.ScriptTarget.ESNext,\n declaration: true,\n noImplicitAny: false,\n sourceMap: false,\n removeComments: false,\n disableSizeLimit: true,\n esModuleInterop: true,\n emitDecoratorMetadata: true,\n skipLibCheck: true,\n };\n customTranslator?: new () => Translator;\n\n Ts = {\n Keyword: structuredClone(TsKeyword),\n CodeGenKeyword: structuredClone(TsCodeGenKeyword),\n /**\n * $A[] or Array<$A>\n */\n ArrayType: (content: unknown) => {\n if (this.anotherArrayType) {\n return this.Ts.TypeWithGeneric(this.Ts.Keyword.Array, [content]);\n }\n\n return `${this.Ts.ExpressionGroup(content)}[]`;\n },\n /**\n * \"$A\"\n */\n StringValue: (content: unknown) => `\"${content}\"`,\n /**\n * $A\n */\n BooleanValue: (content: unknown) => `${content}`,\n /**\n * $A\n */\n NumberValue: (content: unknown) => `${content}`,\n /**\n * $A\n */\n NullValue: () => \"null\",\n /**\n * $A1 | $A2\n */\n UnionType: (contents: unknown[]) =>\n uniq(contents).join(` ${this.Ts.Keyword.Union} `),\n /**\n * ($A1)\n */\n ExpressionGroup: (content: unknown) => (content ? `(${content})` : \"\"),\n /**\n * $A1 & $A2\n */\n IntersectionType: (contents: unknown[]) =>\n uniq(contents).join(` ${this.Ts.Keyword.Intersection} `),\n /**\n * Record<$A1, $A2>\n */\n RecordType: (key: unknown, value: unknown) =>\n this.Ts.TypeWithGeneric(this.Ts.Keyword.Record, [key, value]),\n /**\n * readonly $key?:$value\n */\n TypeField: ({ readonly, key, optional, value }: Record<string, unknown>) =>\n compact([\n readonly && \"readonly \",\n key,\n optional && \"?\",\n \": \",\n value,\n ]).join(\"\"),\n /**\n * [key: $A1]: $A2\n */\n InterfaceDynamicField: (key: unknown, value: unknown) =>\n `[key: ${key}]: ${value}`,\n\n /**\n * EnumName.EnumKey\n */\n EnumUsageKey: (enumStruct: unknown, key: unknown) => `${enumStruct}.${key}`,\n /**\n * $A1 = $A2\n */\n EnumField: (key: unknown, value: unknown) => `${key} = ${value}`,\n /**\n * /\\** description \\*\\/\n */\n EnumFieldDescription: (description: any) => {\n if (description) {\n return ` /** ${description} */`;\n } else {\n return \"\";\n }\n },\n /**\n * /\\** $A0.description \\*\\/\n * $A0.key = $A0.value,\n * /\\** $A1.description \\*\\/\n * $A1.key = $A1.value,\n * /\\** $AN.description \\*\\/\n * $AN.key = $AN.value,\n */\n EnumFieldsWrapper: (contents: Record<string, unknown>[]) =>\n contents\n .map(({ key, value, description }) => {\n return compact([\n this.Ts.EnumFieldDescription(description),\n ` ${this.Ts.EnumField(key, value)}`,\n ]).join(\"\\n\");\n })\n .join(\",\\n\"),\n /**\n * {\\n $A \\n}\n */\n ObjectWrapper: (content: unknown) => `{\\n${content}\\n}`,\n /**\n * /** $A *\\/\n */\n MultilineComment: (\n contents: unknown[],\n formatFn: (arg: unknown) => unknown,\n ) =>\n [\n ...(contents.length === 1\n ? [`/** ${contents[0]} */`]\n : [\"/**\", ...contents.map((content) => ` * ${content}`), \" */\"]),\n ].map((part) => `${formatFn ? formatFn(part) : part}\\n`),\n /**\n * $A1<...$A2.join(,)>\n */\n TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => {\n return `${typeName}${\n genericArgs.length ? `<${genericArgs.join(\",\")}>` : \"\"\n }`;\n },\n /**\n * [$A1, $A2, ...$AN]\n */\n Tuple: (values: unknown[]) => {\n return `[${values.join(\", \")}]`;\n },\n };\n\n /**\n * swagger schema type -> typescript type\n * https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times\n */\n primitiveTypes: Record<\n string,\n | string\n | ((schema: OpenAPI.Document, parser: SchemaParser) => string)\n | ({ $default: string } & Record<\n string,\n string | ((schema: OpenAPI.Document, parser: SchemaParser) => string)\n >)\n > = {\n integer: () => this.Ts.Keyword.Number,\n number: () => this.Ts.Keyword.Number,\n boolean: () => this.Ts.Keyword.Boolean,\n object: () => this.Ts.Keyword.Object,\n file: () => this.Ts.Keyword.File,\n string: {\n $default: this.Ts.Keyword.String,\n\n /** formats */\n binary: () => this.Ts.Keyword.File,\n byte: () => this.Ts.Keyword.Blob,\n file: () => this.Ts.Keyword.File,\n \"date-time\": () => this.Ts.Keyword.String,\n time: () => this.Ts.Keyword.String,\n date: () => this.Ts.Keyword.String,\n duration: () => this.Ts.Keyword.String,\n email: () => this.Ts.Keyword.String,\n \"idn-email\": () => this.Ts.Keyword.String,\n \"idn-hostname\": () => this.Ts.Keyword.String,\n ipv4: () => this.Ts.Keyword.String,\n ipv6: () => this.Ts.Keyword.String,\n uuid: () => this.Ts.Keyword.String,\n uri: () => this.Ts.Keyword.String,\n \"uri-reference\": () => this.Ts.Keyword.String,\n \"uri-template\": () => this.Ts.Keyword.String,\n \"json-pointer\": () => this.Ts.Keyword.String,\n \"relative-json-pointer\": () => this.Ts.Keyword.String,\n regex: () => this.Ts.Keyword.String,\n },\n };\n\n templateInfos = [\n { name: \"api\", fileName: \"api\" },\n { name: \"dataContracts\", fileName: \"data-contracts\" },\n { name: \"dataContractJsDoc\", fileName: \"data-contract-jsdoc\" },\n { name: \"interfaceDataContract\", fileName: \"interface-data-contract\" },\n { name: \"typeDataContract\", fileName: \"type-data-contract\" },\n { name: \"enumDataContract\", fileName: \"enum-data-contract\" },\n { name: \"objectFieldJsDoc\", fileName: \"object-field-jsdoc\" },\n { name: \"httpClient\", fileName: \"http-client\" },\n { name: \"routeTypes\", fileName: \"route-types\" },\n { name: \"routeName\", fileName: \"route-name\" },\n ];\n\n templateExtensions = [\".eta\", \".ejs\"];\n\n constructor({\n codeGenConstructs,\n primitiveTypeConstructs,\n constants,\n templateInfos,\n hooks,\n ...otherConfig\n }: Partial<GenerateApiConfiguration[\"config\"]>) {\n objectAssign(this.Ts, codeGenConstructs);\n objectAssign(this.primitiveTypes, primitiveTypeConstructs);\n\n this.defaultResponseType = this.Ts.Keyword.Void;\n\n this.update({\n ...otherConfig,\n hooks: merge(this.hooks, hooks || {}),\n constants: {\n ...CONSTANTS,\n ...constants,\n },\n templateInfos: templateInfos || this.templateInfos,\n });\n\n this.jsPrimitiveTypes = [\n this.Ts.Keyword.Number,\n this.Ts.Keyword.String,\n this.Ts.Keyword.Boolean,\n ];\n this.jsEmptyTypes = [this.Ts.Keyword.Null, this.Ts.Keyword.Undefined];\n this.componentTypeNameResolver = new ComponentTypeNameResolver(this, []);\n }\n\n update = (\n update: Partial<\n GenerateApiConfiguration[\"config\"] & {\n resolvedSwaggerSchema: ResolvedSwaggerSchema;\n }\n >,\n ) => {\n objectAssign(this, update);\n if (this.enumNamesAsValues) {\n this.extractEnums = true;\n }\n };\n}\n","import { camelCase, upperFirst } from \"es-toolkit/compat\";\n\nexport function pascalCase(value: string) {\n return upperFirst(camelCase(value));\n}\n","import { typeGuard } from \"yummies/type-guard\";\nimport type { AnyObject, Maybe } from \"yummies/types\";\nimport type { SchemaComponent } from \"../types/index.js\";\nimport type { CodeGenConfig } from \"./configuration.js\";\nimport { pascalCase } from \"./util/pascal-case.js\";\n\nexport class SchemaComponentsMap {\n _data: SchemaComponent[] = [];\n\n constructor(public config: CodeGenConfig) {}\n\n clear() {\n this._data = [];\n }\n\n createRef = (paths: string[]) => {\n return [\"#\", ...paths].join(\"/\");\n };\n\n parseRef = (ref: string) => {\n return ref.split(\"/\");\n };\n\n private createComponentDraft(\n $ref: string,\n rawTypeData: Maybe<AnyObject> | SchemaComponent,\n ): SchemaComponent {\n if (\n typeGuard.isObject(rawTypeData) &&\n rawTypeData.typeName &&\n rawTypeData.rawTypeData &&\n rawTypeData.$ref\n ) {\n return rawTypeData as SchemaComponent;\n }\n\n const parsed = this.parseRef($ref);\n const [, rawPointer = \"\"] = $ref.split(\"#\");\n const pointer = rawPointer.startsWith(\"/\") ? rawPointer : `/${rawPointer}`;\n const pointerParts = pointer.split(\"/\").filter(Boolean);\n\n const typeName = pointerParts.at(-1) || parsed.at(-1) || \"Unknown\";\n const rawComponentName =\n pointerParts.at(-2) || parsed[parsed.length - 2] || \"schemas\";\n const componentName =\n rawComponentName === \"definitions\"\n ? \"schemas\"\n : (rawComponentName as SchemaComponent[\"componentName\"]);\n\n return {\n $ref,\n typeName,\n rawTypeData: rawTypeData as SchemaComponent[\"rawTypeData\"],\n componentName,\n /** result from schema parser */\n typeData: null,\n };\n }\n\n createComponent(\n $ref: string,\n rawTypeData: SchemaComponent[\"rawTypeData\"] | SchemaComponent,\n addAtStart?: boolean,\n ): SchemaComponent {\n const componentSchema = this.createComponentDraft($ref, rawTypeData);\n const usageComponent =\n this.config.hooks.onCreateComponent(componentSchema) || componentSchema;\n\n const refIndex = this._data.findIndex((c) => c.$ref === $ref);\n\n if (refIndex === -1) {\n if (addAtStart) {\n this._data.unshift(usageComponent);\n } else {\n this._data.push(usageComponent);\n }\n } else {\n this._data[refIndex] = usageComponent;\n }\n\n return usageComponent;\n }\n\n getComponents() {\n return this._data;\n }\n\n filter(...componentNames: (string[] | string)[]) {\n return this._data.filter((it) =>\n componentNames.some((componentName) =>\n it.$ref.startsWith(`#/components/${componentName}`),\n ),\n );\n }\n\n get = ($ref: string) => {\n const localFound = this._data.find((c) => c.$ref === $ref) || null;\n\n if (localFound != null) {\n return localFound;\n }\n\n const { resolvedSwaggerSchema } = this.config;\n\n if (resolvedSwaggerSchema.isLocalRef($ref)) {\n return null;\n }\n\n const foundByRef = resolvedSwaggerSchema.getRef($ref);\n const refDetails = resolvedSwaggerSchema.getRefDetails($ref);\n\n if (foundByRef != null) {\n const componentDraft = this.createComponentDraft(\n $ref,\n foundByRef as AnyObject,\n );\n\n componentDraft.typeName =\n this.config.hooks.onFormatExternalTypeName?.(\n componentDraft.typeName,\n refDetails,\n ) || componentDraft.typeName;\n\n if (\n // duplicate name\n this._data.some(\n (component) => component.typeName === componentDraft.typeName,\n )\n ) {\n componentDraft.typeName =\n this.config.hooks.onFixDuplicateExternalTypeName?.(\n componentDraft.typeName,\n refDetails,\n this._data.map((it) => it.typeName),\n ) ??\n `${pascalCase(refDetails.externalOpenapiFileName || \"External\")}${componentDraft.typeName}`;\n }\n\n return this.createComponent($ref, componentDraft);\n }\n\n return null;\n };\n\n // Ensure enums are at the top of components list\n enumsFirst() {\n this._data.sort((a, b) => {\n if (Object.keys(a.rawTypeData || {}).includes(\"enum\")) return -1;\n if (Object.keys(b.rawTypeData || {}).includes(\"enum\")) return 1;\n return 0;\n });\n }\n\n // Ensure discriminators are at the top of components list\n discriminatorsFirst() {\n this._data.sort((a, b) => {\n if (Object.keys(a.rawTypeData || {}).includes(\"discriminator\")) return -1;\n if (Object.keys(b.rawTypeData || {}).includes(\"discriminator\")) return 1;\n return 0;\n });\n }\n}\n","import { compact } from \"es-toolkit\";\nimport { get } from \"es-toolkit/compat\";\nimport type { CodeGenConfig } from \"../configuration.js\";\nimport { SCHEMA_TYPES } from \"../constants.js\";\nimport type { TemplatesWorker } from \"../templates-worker.js\";\nimport type { SchemaParser } from \"./schema-parser.js\";\nimport type { SchemaParserFabric } from \"./schema-parser-fabric.js\";\nimport type { SchemaUtils } from \"./schema-utils.js\";\n\nexport class SchemaFormatters {\n config: CodeGenConfig;\n templatesWorker: TemplatesWorker;\n schemaUtils: SchemaUtils;\n\n constructor(schemaParser: SchemaParser | SchemaParserFabric) {\n this.config = schemaParser.config;\n this.schemaUtils = schemaParser.schemaUtils;\n this.templatesWorker = schemaParser.templatesWorker;\n }\n\n base = {\n [SCHEMA_TYPES.ENUM]: (parsedSchema) => {\n if (this.config.generateUnionEnums) {\n return {\n ...parsedSchema,\n $content: parsedSchema.content,\n content: this.config.Ts.UnionType(\n parsedSchema.content.map(({ value }) => value),\n ),\n };\n }\n\n const escapedContent = parsedSchema.content.map((item) => ({\n ...item,\n description: item.description\n ? this.escapeJSDocContent(item.description)\n : \"\",\n }));\n\n return {\n ...parsedSchema,\n $content: parsedSchema.content,\n content: this.config.Ts.EnumFieldsWrapper(escapedContent),\n };\n },\n [SCHEMA_TYPES.OBJECT]: (parsedSchema) => {\n if (parsedSchema.nullable)\n return this.inline[SCHEMA_TYPES.OBJECT](parsedSchema);\n return {\n ...parsedSchema,\n $content: parsedSchema.content,\n content: this.formatObjectContent(parsedSchema.content),\n };\n },\n [SCHEMA_TYPES.PRIMITIVE]: (parsedSchema) => {\n return {\n ...parsedSchema,\n $content: parsedSchema.content,\n };\n },\n };\n inline = {\n [SCHEMA_TYPES.ENUM]: (parsedSchema) => {\n return {\n ...parsedSchema,\n content: parsedSchema.$ref\n ? parsedSchema.typeName\n : this.config.Ts.UnionType(\n compact([\n ...parsedSchema.content.map(({ value }) => `${value}`),\n parsedSchema.nullable && this.config.Ts.Keyword.Null,\n ]),\n ) || this.config.Ts.Keyword.Any,\n };\n },\n [SCHEMA_TYPES.OBJECT]: (parsedSchema) => {\n if (typeof parsedSchema.content === \"string\")\n return {\n ...parsedSchema,\n typeIdentifier: this.config.Ts.Keyword.Type,\n content: this.schemaUtils.safeAddNullToType(parsedSchema.content),\n };\n\n return {\n ...parsedSchema,\n typeIdentifier: this.config.Ts.Keyword.Type,\n content: this.schemaUtils.safeAddNullToType(\n parsedSchema,\n parsedSchema.content.length\n ? this.config.Ts.ObjectWrapper(\n this.formatObjectContent(parsedSchema.content),\n )\n : this.config.Ts.RecordType(\n this.config.Ts.Keyword.String,\n this.config.Ts.Keyword.Any,\n ),\n ),\n };\n },\n };\n\n formatSchema = (\n parsedSchema: Record<string, any>,\n formatType: \"base\" | \"inline\" = \"base\",\n ) => {\n const schemaType =\n get(parsedSchema, [\"schemaType\"]) ||\n get(parsedSchema, [\"$parsed\", \"schemaType\"]);\n const formatterFn = get(this, [formatType, schemaType]);\n return formatterFn?.(parsedSchema) || parsedSchema;\n };\n\n // OpenAPI fields are untrusted input that may contain `*/` which would\n // prematurely close JSDoc block comments in generated TypeScript output.\n // Note: only `undefined` maps to empty string; `null` is preserved as \"null\"\n // because `@default null` is a valid JSDoc annotation for nullable fields.\n escapeJSDocContent = (content: unknown): string => {\n if (content === undefined) return \"\";\n const str = typeof content === \"string\" ? content : String(content);\n return str.replace(/\\*\\//g, \"*\\\\/\");\n };\n\n formatDescription = (\n description: string | undefined,\n inline?: boolean,\n ): string => {\n if (!description) return \"\";\n\n const escapedDescription = this.escapeJSDocContent(description);\n const hasMultipleLines = escapedDescription.includes(\"\\n\");\n\n if (!hasMultipleLines) return escapedDescription;\n\n if (inline) {\n return compact(\n escapedDescription.split(/\\n/g).map((part) => part.trim()),\n ).join(\" \");\n }\n\n return escapedDescription.replace(/\\n$/g, \"\");\n };\n\n formatObjectContent = (content) => {\n const fields: string[] = [];\n\n for (const part of content) {\n const extraSpace = \" \";\n const result = `${extraSpace}${part.field},\\n`;\n\n const renderedJsDoc = this.templatesWorker.renderTemplate(\n this.config.templatesToRender.dataContractJsDoc,\n {\n data: part,\n },\n );\n\n const routeNameFromTemplate = renderedJsDoc\n .split(\"\\n\")\n .map((c) => `${extraSpace}${c}`)\n .join(\"\\n\");\n\n if (routeNameFromTemplate) {\n fields.push(`${routeNameFromTemplate}${result}`);\n } else {\n fields.push(`${result}`);\n }\n }\n\n return fields.join(\"\");\n };\n}\n","export const sortByProperty =\n (propertyName: string) =>\n (o1: Record<string, any>, o2: Record<string, any>): 1 | -1 | 0 => {\n if (o1[propertyName] > o2[propertyName]) {\n return 1;\n }\n if (o1[propertyName] < o2[propertyName]) {\n return -1;\n }\n return 0;\n };\n","import type { CodeGenConfig } from \"../configuration.js\";\nimport type { SchemaComponentsMap } from \"../schema-components-map.js\";\nimport type { TypeNameFormatter } from \"../type-name-formatter.js\";\nimport type { SchemaFormatters } from \"./schema-formatters.js\";\nimport type { SchemaParser } from \"./schema-parser.js\";\nimport type { SchemaParserFabric } from \"./schema-parser-fabric.js\";\nimport type { SchemaUtils } from \"./schema-utils.js\";\n\nexport interface SchemaParserConfig {\n typeName?: string | null;\n // biome-ignore lint/suspicious/noExplicitAny: TODO: narrow to OpenAPI schema type\n schema?: any;\n schemaPath?: string[];\n}\n\nexport class MonoSchemaParser {\n // biome-ignore lint/suspicious/noExplicitAny: TODO: narrow to OpenAPI schema type\n schema: any;\n typeName: string | null;\n schemaPath: string[];\n\n schemaParser: SchemaParser;\n schemaParserFabric: SchemaParserFabric;\n typeNameFormatter: TypeNameFormatter;\n schemaComponentsMap: SchemaComponentsMap;\n schemaUtils: SchemaUtils;\n config: CodeGenConfig;\n schemaFormatters: SchemaFormatters;\n\n constructor(\n schemaParser: SchemaParser,\n schema: unknown,\n typeName: string | null = null,\n schemaPath: string[] = [],\n ) {\n this.schemaParser = schemaParser;\n this.schemaParserFabric = schemaParser.schemaParserFabric;\n this.schema = schema;\n this.typeName = typeName;\n this.typeNameFormatter = schemaParser.typeNameFormatter;\n this.schemaPath = schemaPath;\n this.schemaComponentsMap = this.schemaParser.schemaComponentsMap;\n this.schemaUtils = this.schemaParser.schemaUtils;\n this.config = this.schemaParser.config;\n this.schemaFormatters = this.schemaParser.schemaFormatters;\n }\n\n parse() {\n throw new Error(\"not implemented\");\n }\n\n buildTypeNameFromPath = () => {\n return this.schemaUtils.buildTypeNameFromPath(this.schemaPath);\n };\n}\n","import { SCHEMA_TYPES } from \"../../constants.js\";\nimport { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\nexport class ArraySchemaParser extends MonoSchemaParser {\n override parse() {\n let contentType;\n const { type, description, items } = this.schema || {};\n\n if (Array.isArray(items) && type === SCHEMA_TYPES.ARRAY) {\n const tupleContent = [];\n for (const item of items) {\n tupleContent.push(\n this.schemaParserFabric\n .createSchemaParser({ schema: item, schemaPath: this.schemaPath })\n .getInlineParseContent(),\n );\n }\n contentType = this.config.Ts.Tuple(tupleContent);\n } else {\n const content = this.schemaParserFabric\n .createSchemaParser({ schema: items, schemaPath: this.schemaPath })\n .getInlineParseContent();\n contentType = this.config.Ts.ArrayType(content);\n }\n\n return {\n ...(typeof this.schema === \"object\" ? this.schema : {}),\n $schemaPath: this.schemaPath.slice(),\n $parsedSchema: true,\n schemaType: SCHEMA_TYPES.PRIMITIVE,\n type: SCHEMA_TYPES.PRIMITIVE,\n typeIdentifier: this.config.Ts.Keyword.Type,\n name: this.typeName,\n description: this.schemaFormatters.formatDescription(description),\n content: this.schemaUtils.safeAddNullToType(this.schema, contentType),\n };\n }\n}\n","import { compact, omit } from \"es-toolkit\";\nimport { SCHEMA_TYPES } from \"../../constants.js\";\nimport { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\nexport class ComplexSchemaParser extends MonoSchemaParser {\n override parse() {\n const complexType = this.schemaUtils.getComplexType(this.schema);\n const simpleSchema = omit(\n this.schema,\n Object.keys(this.schemaParser._complexSchemaParsers),\n );\n const complexSchemaContent = this.schemaParser._complexSchemaParsers[\n complexType\n ](this.schema);\n\n return {\n ...(typeof this.schema === \"object\" ? this.schema : {}),\n $schemaPath: this.schemaPath.slice(),\n $parsedSchema: true,\n schemaType: SCHEMA_TYPES.COMPLEX,\n type: SCHEMA_TYPES.PRIMITIVE,\n typeIdentifier: this.config.Ts.Keyword.Type,\n name: this.typeName,\n description: this.schemaFormatters.formatDescription(\n this.schema.description ||\n compact(\n (this.schema[complexType] || []).map(\n (item: any) => item?.description,\n ),\n )[0] ||\n \"\",\n ),\n content:\n this.config.Ts.IntersectionType(\n compact([\n this.config.Ts.ExpressionGroup(complexSchemaContent),\n this.schemaUtils.getInternalSchemaType(simpleSchema) ===\n SCHEMA_TYPES.OBJECT &&\n this.config.Ts.ExpressionGroup(\n this.schemaParserFabric\n .createSchemaParser({\n schema: simpleSchema,\n schemaPath: this.schemaPath,\n })\n .getInlineParseContent(),\n ),\n ]),\n ) || this.config.Ts.Keyword.Any,\n };\n }\n}\n","import { compact, omit } from \"es-toolkit\";\nimport { get } from \"es-toolkit/compat\";\nimport { SCHEMA_TYPES } from \"../../constants.js\";\nimport { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\nexport class DiscriminatorSchemaParser extends MonoSchemaParser {\n override parse() {\n const ts = this.config.Ts;\n const { discriminator, ...noDiscriminatorSchema } = this.schema;\n\n if (!discriminator.mapping) {\n return this.schemaParserFabric\n .createSchemaParser({\n schema: noDiscriminatorSchema,\n typeName: this.typeName,\n schemaPath: this.schemaPath,\n })\n .parseSchema();\n }\n\n // https://github.com/acacode/swagger-typescript-api/issues/456\n // const skipMappingType = !!noDiscriminatorSchema.oneOf;\n const skipMappingType = false;\n\n const abstractSchemaStruct = this.createAbstractSchemaStruct();\n // const complexSchemaStruct = this.createComplexSchemaStruct();\n const discriminatorSchemaStruct = this.createDiscriminatorSchema({\n skipMappingType,\n abstractSchemaStruct,\n });\n\n const schemaContent = ts.IntersectionType(\n compact([\n abstractSchemaStruct?.content,\n discriminatorSchemaStruct?.content,\n ]),\n );\n\n return {\n ...(typeof this.schema === \"object\" ? this.schema : {}),\n $schemaPath: this.schemaPath.slice(),\n $parsedSchema: true,\n schemaType: SCHEMA_TYPES.COMPLEX,\n type: SCHEMA_TYPES.PRIMITIVE,\n typeIdentifier: ts.Keyword.Type,\n name: this.typeName,\n description: this.schemaFormatters.formatDescription(\n this.schema.description,\n ),\n content: schemaContent,\n };\n }\n\n createDiscriminatorSchema = ({ skipMappingType, abstractSchemaStruct }) => {\n const ts = this.config.Ts;\n\n const refPath = this.schemaComponentsMap.createRef([\n \"components\",\n \"schemas\",\n this.typeName,\n ]);\n const { discriminator } = this.schema;\n const mappingEntries = Object.entries(discriminator.mapping || {});\n const ableToCreateMappingType =\n !skipMappingType &&\n !!(abstractSchemaStruct?.typeName && mappingEntries.length);\n const mappingContents: string[] = [];\n let mappingTypeName;\n\n /** { mapping_key: SchemaEnum.MappingKey, ... } */\n const mappingPropertySchemaEnumKeysMap =\n this.createMappingPropertySchemaEnumKeys({\n abstractSchemaStruct,\n discPropertyName: discriminator.propertyName,\n });\n\n if (ableToCreateMappingType) {\n const rawTypeName = `${abstractSchemaStruct.typeName}_${discriminator.propertyName}`;\n const generatedTypeName = this.schemaUtils.resolveTypeName(rawTypeName, {\n suffixes: this.config.extractingOptions.discriminatorMappingSuffix,\n resolver:\n this.config.extractingOptions.discriminatorMappingNameResolver,\n });\n\n const content = ts.IntersectionType([\n ts.ObjectWrapper(\n ts.TypeField({\n key: ts.StringValue(discriminator.propertyName),\n value: \"Key\",\n }),\n ),\n \"Type\",\n ]);\n\n const component = this.schemaParserFabric.createParsedComponent({\n typeName: generatedTypeName,\n schema: {\n type: \"object\",\n properties: {},\n genericArgs: [{ name: \"Key\" }, { name: \"Type\" }],\n internal: true,\n },\n });\n\n component.typeData.content = content;\n\n mappingTypeName = this.typeNameFormatter.format(component.typeName);\n }\n\n /** returns (GenericType<\"mapping_key\", MappingType>) or ({ discriminatorProperty: \"mapping_key\" } & MappingType) */\n const createMappingContent = (mappingSchema, mappingKey) => {\n const content = this.schemaParserFabric\n .createSchemaParser({\n schema: mappingSchema,\n schemaPath: this.schemaPath,\n })\n .getInlineParseContent();\n\n const mappingUsageKey =\n mappingPropertySchemaEnumKeysMap[mappingKey] ||\n ts.StringValue(mappingKey);\n\n if (ableToCreateMappingType) {\n return ts.TypeWithGeneric(mappingTypeName, [mappingUsageKey, content]);\n }\n\n return ts.ExpressionGroup(\n ts.IntersectionType([\n ts.ObjectWrapper(\n ts.TypeField({\n key: ts.StringValue(discriminator.propertyName),\n value: mappingUsageKey,\n }),\n ),\n content,\n ]),\n );\n };\n\n for (const [mappingKey, schema] of mappingEntries) {\n const mappingSchema =\n typeof schema === \"string\" ? { $ref: schema } : schema;\n\n this.mutateMappingDependentSchema({\n discPropertyName: discriminator.propertyName,\n abstractSchemaStruct,\n mappingSchema,\n refPath,\n mappingPropertySchemaEnumKeysMap,\n });\n\n mappingContents.push(createMappingContent(mappingSchema, mappingKey));\n }\n\n if (skipMappingType) return null;\n\n const content = ts.ExpressionGroup(ts.UnionType(mappingContents));\n\n return {\n content,\n };\n };\n\n createMappingPropertySchemaEnumKeys = ({\n abstractSchemaStruct,\n discPropertyName,\n }) => {\n const ts = this.config.Ts;\n\n const mappingPropertySchemaEnumKeysMap = {};\n let mappingPropertySchema = get(\n abstractSchemaStruct?.component?.rawTypeData,\n [\"properties\", discPropertyName],\n );\n if (this.schemaUtils.isRefSchema(mappingPropertySchema)) {\n mappingPropertySchema = this.schemaUtils.getSchemaRefType(\n mappingPropertySchema,\n );\n }\n\n const parsedEnum = mappingPropertySchema?.rawTypeData?.$parsed;\n if (parsedEnum?.type === SCHEMA_TYPES.ENUM) {\n const enumEntries = (parsedEnum.enum || []).map((key, index) => [\n key,\n index,\n ]);\n for (const [key, index] of enumEntries) {\n const enumContent = parsedEnum.content?.[index];\n if (this.config.generateUnionEnums) {\n const literalValue =\n enumContent?.value ??\n (key !== undefined ? ts.StringValue(key) : undefined);\n if (literalValue !== undefined) {\n mappingPropertySchemaEnumKeysMap[key] = literalValue;\n }\n } else if (parsedEnum.typeName && enumContent?.key) {\n mappingPropertySchemaEnumKeysMap[key] = ts.EnumUsageKey(\n parsedEnum.typeName,\n enumContent.key,\n );\n }\n }\n }\n\n return mappingPropertySchemaEnumKeysMap;\n };\n\n mutateMappingDependentSchema = ({\n discPropertyName,\n abstractSchemaStruct,\n mappingSchema,\n refPath,\n mappingPropertySchemaEnumKeysMap,\n }) => {\n const complexSchemaKeys = Object.keys(\n this.schemaParser._complexSchemaParsers,\n );\n // override parent dependencies\n if (mappingSchema.$ref && abstractSchemaStruct?.component?.$ref) {\n const mappingRefSchema =\n this.schemaUtils.getSchemaRefType(mappingSchema)?.rawTypeData;\n if (mappingRefSchema) {\n for (const schemaKey of complexSchemaKeys) {\n if (Array.isArray(mappingRefSchema[schemaKey])) {\n mappingRefSchema[schemaKey] = mappingRefSchema[schemaKey].map(\n (schema) => {\n if (schema.$ref === refPath) {\n return {\n ...schema,\n $ref: abstractSchemaStruct.component.$ref,\n };\n }\n if (\n this.schemaUtils.getInternalSchemaType(schema) ===\n SCHEMA_TYPES.OBJECT\n ) {\n for (const schemaPropertyName in schema.properties) {\n const schemaProperty =\n schema.properties[schemaPropertyName];\n if (\n schemaPropertyName === discPropertyName &&\n this.schemaUtils.getInternalSchemaType(schemaProperty) ===\n SCHEMA_TYPES.ENUM &&\n schemaProperty.enum.length === 1 &&\n mappingPropertySchemaEnumKeysMap[schemaProperty.enum[0]]\n ) {\n schema.properties[schemaPropertyName] =\n this.schemaParserFabric.createSchema({\n content:\n mappingPropertySchemaEnumKeysMap[\n schemaProperty.enum[0]\n ],\n });\n }\n }\n }\n return schema;\n },\n );\n }\n }\n }\n }\n };\n\n createAbstractSchemaStruct = () => {\n const { discriminator, ...noDiscriminatorSchema } = this.schema;\n const complexSchemaKeys = Object.keys(\n this.schemaParser._complexSchemaParsers,\n );\n const schema = omit(\n structuredClone(noDiscriminatorSchema),\n complexSchemaKeys,\n );\n const schemaIsAny =\n this.schemaParserFabric.getInlineParseContent(structuredClone(schema)) ===\n this.config.Ts.Keyword.Any;\n const schemaIsEmpty = !Object.keys(schema).length;\n\n if (schemaIsEmpty || schemaIsAny) return null;\n\n const typeName = this.schemaUtils.resolveTypeName(this.typeName, {\n prefixes: this.config.extractingOptions.discriminatorAbstractPrefix,\n resolver: this.config.extractingOptions.discriminatorAbstractResolver,\n });\n const component = this.schemaComponentsMap.createComponent(\n this.schemaComponentsMap.createRef([\"components\", \"schemas\", typeName]),\n {\n ...schema,\n internal: true,\n },\n );\n const content = this.schemaParserFabric\n .createSchemaParser({ schema: component, schemaPath: this.schemaPath })\n .getInlineParseContent();\n\n return {\n typeName,\n component,\n content,\n };\n };\n\n createComplexSchemaStruct = () => {\n const ts = this.config.Ts;\n const complexType = this.schemaUtils.getComplexType(this.schema);\n\n if (complexType === SCHEMA_TYPES.COMPLEX_UNKNOWN) return null;\n\n return {\n content: ts.ExpressionGroup(\n this.schemaParser._complexSchemaParsers[complexType](this.schema),\n ),\n };\n };\n}\n","import { consola } from \"consola\";\nimport type { CodeGenConfig } from \"../../configuration.js\";\nimport { NameResolver } from \"../../util/name-resolver.js\";\n\nexport class EnumKeyResolver extends NameResolver {\n counter = 1;\n constructor(config: CodeGenConfig, reservedNames: string[]) {\n super(config, reservedNames, (variants) => {\n const generatedVariant =\n (variants[0] && `${variants[0]}${this.counter++}`) ||\n `${this.config.enumKeyResolverName}${this.counter++}`;\n consola.debug(\n \"generated fallback type name for enum key - \",\n generatedVariant,\n );\n return generatedVariant;\n });\n }\n}\n","import { get } from \"es-toolkit/compat\";\nimport { SCHEMA_TYPES } from \"../../constants.js\";\nimport { MonoSchemaParser } from \"../mono-schema-parser.js\";\nimport { EnumKeyResolver } from \"../util/enum-key-resolver.js\";\n\nexport class EnumSchemaParser extends MonoSchemaParser {\n enumKeyResolver: EnumKeyResolver;\n\n constructor(...args: ConstructorParameters<typeof MonoSchemaParser>) {\n super(...args);\n this.enumKeyResolver = new EnumKeyResolver(this.config, []);\n }\n\n extractEnum = (pathTypeName) => {\n const generatedTypeName = this.schemaUtils.resolveTypeName(pathTypeName, {\n suffixes: this.config.extractingOptions.enumSuffix,\n resolver: this.config.extractingOptions.enumNameResolver,\n });\n const customComponent = this.schemaComponentsMap.createComponent(\n this.schemaComponentsMap.createRef([\n \"components\",\n \"schemas\",\n generatedTypeName,\n ]),\n {\n ...this.schema,\n },\n );\n return this.schemaParserFabric.parseSchema(customComponent);\n };\n\n override parse() {\n const pathTypeName = this.buildTypeNameFromPath();\n\n if (this.config.extractEnums && !this.typeName && pathTypeName != null) {\n return this.extractEnum(pathTypeName);\n }\n\n const refType = this.schemaUtils.getSchemaRefType(this.schema);\n const $ref = refType?.$ref || null;\n\n // fix schema when enum has length 1+ but value is []\n if (Array.isArray(this.schema.enum)) {\n this.schema.enum = this.schema.enum.filter((key) => key != null);\n }\n\n if (Array.isArray(this.schema.enum) && Array.isArray(this.schema.enum[0])) {\n return this.schemaParserFabric.parseSchema(\n {\n oneOf: this.schema.enum.map((enumNames) => ({\n type: \"array\",\n items: enumNames.map((enumName) => ({\n type: \"string\",\n enum: [enumName],\n })),\n })),\n },\n this.typeName,\n this.schemaPath,\n );\n }\n\n const keyType = this.schemaUtils.getSchemaType(this.schema);\n const enumNames = this.schemaUtils.getEnumNames(this.schema);\n const enumDescriptions = this.schemaUtils.getEnumDescriptions(this.schema);\n\n let content = null;\n\n const formatValue = (value) => {\n if (value === null) {\n return this.config.Ts.NullValue(value);\n }\n\n if (\n keyType.includes(this.schemaUtils.getSchemaType({ type: \"number\" }))\n ) {\n const maybeNumber = typeof value === \"number\" ? value : Number(value);\n if (!Number.isNaN(maybeNumber)) {\n return this.config.Ts.NumberValue(maybeNumber);\n }\n }\n\n if (\n keyType.includes(this.schemaUtils.getSchemaType({ type: \"boolean\" }))\n ) {\n if (typeof value === \"boolean\") {\n return this.config.Ts.BooleanValue(value);\n }\n if (value === \"true\" || value === \"false\") {\n return this.config.Ts.BooleanValue(value === \"true\");\n }\n }\n\n switch (typeof value) {\n case \"number\":\n return this.config.Ts.NumberValue(value);\n case \"boolean\":\n return this.config.Ts.BooleanValue(value);\n default:\n return this.config.Ts.StringValue(value);\n }\n };\n\n if (Array.isArray(enumNames) && enumNames.length > 0) {\n content = enumNames.map((enumName, index) => {\n const enumValue = get(this.schema.enum, index);\n const formattedKey = this.formatEnumKey({\n key: enumName,\n value: enumValue,\n });\n\n if (this.config.enumNamesAsValues || enumValue === undefined) {\n return {\n key: formattedKey,\n type: this.config.Ts.Keyword.String,\n value: this.config.Ts.StringValue(enumName),\n description: enumDescriptions?.[index],\n };\n }\n\n return {\n key: formattedKey,\n type: keyType,\n value: formatValue(enumValue),\n description: enumDescriptions?.[index],\n };\n });\n } else {\n content = this.schema.enum.map((value, index) => {\n return {\n key: this.formatEnumKey({ value }),\n type: keyType,\n value: formatValue(value),\n description: enumDescriptions?.[index],\n };\n });\n }\n\n return {\n ...(typeof this.schema === \"object\" ? this.schema : {}),\n $ref: $ref,\n typeName: this.typeName || ($ref && refType.typeName) || null,\n $parsedSchema: true,\n schemaType: SCHEMA_TYPES.ENUM,\n type: SCHEMA_TYPES.ENUM,\n keyType: keyType,\n typeIdentifier: this.config.generateUnionEnums\n ? this.config.Ts.Keyword.Type\n : this.config.Ts.Keyword.Enum,\n name: this.typeName,\n description: this.schemaFormatters.formatDescription(\n this.schema.description,\n ),\n content,\n };\n }\n\n formatEnumKey = ({ key, value }: { key?: string; value: unknown }) => {\n let formatted: string | undefined;\n\n if (key) {\n formatted = this.typeNameFormatter.format(key, {\n type: \"enum-key\",\n });\n }\n\n if (!formatted) {\n formatted = this.typeNameFormatter.format(`${value}`, {\n type: \"enum-key\",\n });\n }\n\n return this.enumKeyResolver.resolve([formatted]);\n };\n}\n","import { compact } from \"es-toolkit\";\nimport { get } from \"es-toolkit/compat\";\nimport { SCHEMA_TYPES } from \"../../constants.js\";\nimport { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\nexport class ObjectSchemaParser extends MonoSchemaParser {\n override parse() {\n const contentProperties = this.getObjectSchemaContent(this.schema);\n\n return {\n ...(typeof this.schema === \"object\" ? this.schema : {}),\n $schemaPath: this.schemaPath.slice(),\n $parsedSchema: true,\n schemaType: SCHEMA_TYPES.OBJECT,\n type: SCHEMA_TYPES.OBJECT,\n typeIdentifier: this.config.Ts.Keyword.Interface,\n name: this.typeName,\n description: this.schemaFormatters.formatDescription(\n this.schema.description,\n ),\n allFieldsAreOptional: !contentProperties.some((part) => part.isRequired),\n content: contentProperties,\n };\n }\n\n getObjectSchemaContent = (schema) => {\n const { properties, additionalProperties } = schema || {};\n\n const propertiesContent: any[] = [];\n\n for (const [name, property] of Object.entries(properties || {})) {\n const required = this.schemaUtils.isPropertyRequired(\n name,\n property as Record<string, unknown>,\n schema,\n );\n const rawTypeData = get(\n this.schemaUtils.getSchemaRefType(property),\n \"rawTypeData\",\n {},\n );\n const nullable = !!(\n rawTypeData.nullable || (property as Record<string, unknown>).nullable\n );\n const fieldName = this.typeNameFormatter.isValidName(name)\n ? name\n : this.config.Ts.StringValue(name);\n const fieldValue = this.schemaParserFabric\n .createSchemaParser({\n schema: property,\n schemaPath: [...this.schemaPath, name],\n })\n .getInlineParseContent();\n const readOnly = (property as Record<string, unknown>).readOnly;\n\n const complexType = this.schemaUtils.getComplexType(property);\n const rawDataComplexType = this.schemaUtils.getComplexType(rawTypeData);\n\n propertiesContent.push({\n ...(property as object),\n $$raw: property,\n title: (property as Record<string, unknown>).title,\n description:\n (property as Record<string, unknown>).description ||\n compact(\n (\n ((property as Record<string, unknown>)[complexType] as any[]) ||\n []\n ).map((item: any) => item?.description),\n )[0] ||\n rawTypeData.description ||\n compact(\n ((rawTypeData[rawDataComplexType] as any[]) || []).map(\n (item: any) => item?.description,\n ),\n )[0] ||\n \"\",\n isRequired: required,\n isNullable: nullable,\n name: fieldName,\n value: fieldValue,\n field: this.config.Ts.TypeField({\n readonly: readOnly && this.config.addReadonly,\n optional: !required,\n key: fieldName,\n value: fieldValue,\n }),\n });\n }\n\n if (additionalProperties) {\n const propertyNamesSchema =\n this.schemaUtils.getSchemaPropertyNamesSchema(schema);\n let interfaceKeysContent: string;\n\n if (propertyNamesSchema) {\n interfaceKeysContent = this.schemaParserFabric\n .createSchemaParser({\n schema: propertyNamesSchema,\n schemaPath: this.schemaPath,\n })\n .getInlineParseContent();\n } else {\n interfaceKeysContent = this.config.Ts.Keyword.String;\n }\n\n propertiesContent.push({\n $$raw: { additionalProperties },\n description: \"\",\n isRequired: false,\n field: this.config.Ts.InterfaceDynamicField(\n interfaceKeysContent,\n this.config.Ts.Keyword.Any,\n ),\n });\n }\n\n return propertiesContent;\n };\n}\n","import { SCHEMA_TYPES } from \"../../constants.js\";\nimport { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\nexport class PrimitiveSchemaParser extends MonoSchemaParser {\n override parse() {\n let contentType = null;\n const { additionalProperties, type, description, items } =\n this.schema || {};\n\n if (type === this.config.Ts.Keyword.Object && additionalProperties) {\n const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(\n this.schema,\n );\n\n let recordKeysContent: string;\n let recordValuesContent: string;\n\n if (propertyNamesSchema) {\n recordKeysContent = this.schemaParserFabric\n .createSchemaParser({\n schema: propertyNamesSchema,\n schemaPath: this.schemaPath,\n })\n .getInlineParseContent();\n } else {\n recordKeysContent = this.config.Ts.Keyword.String;\n }\n\n if (typeof additionalProperties === \"object\") {\n recordValuesContent = this.schemaParserFabric\n .createSchemaParser({\n schema: additionalProperties,\n schemaPath: this.schemaPath,\n })\n .getInlineParseContent();\n } else {\n recordValuesContent = this.config.Ts.Keyword.Any;\n }\n\n const recordType = this.config.Ts.RecordType(\n recordKeysContent,\n recordValuesContent,\n );\n\n contentType = propertyNamesSchema\n ? this.config.Ts.TypeWithGeneric(\"Partial\", [recordType])\n : recordType;\n }\n\n if (Array.isArray(type) && type.length) {\n contentType = this.schemaParser._complexSchemaParsers.oneOf({\n ...(typeof this.schema === \"object\" ? this.schema : {}),\n oneOf: type.map((t) => {\n const branch: Record<string, unknown> = { type: t };\n Object.assign(branch, this.schema);\n branch.type = t;\n return branch;\n }),\n });\n }\n\n if (Array.isArray(items) && type === SCHEMA_TYPES.ARRAY) {\n contentType = this.config.Ts.Tuple(\n items.map((item) =>\n this.schemaParserFabric\n .createSchemaParser({ schema: item, schemaPath: this.schemaPath })\n .getInlineParseContent(),\n ),\n );\n }\n\n return {\n ...(typeof this.schema === \"object\" ? this.schema : {}),\n $schemaPath: this.schemaPath.slice(),\n $parsedSchema: true,\n schemaType: SCHEMA_TYPES.PRIMITIVE,\n type: SCHEMA_TYPES.PRIMITIVE,\n typeIdentifier: this.config.Ts.Keyword.Type,\n name: this.typeName,\n description: this.schemaFormatters.formatDescription(description),\n // TODO: probably it should be refactored. `type === 'null'` is not flexible\n content:\n type === this.config.Ts.Keyword.Null\n ? type\n : contentType || this.schemaUtils.getSchemaType(this.schema),\n };\n }\n}\n","import { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\n// T1 & T2\nexport class AllOfSchemaParser extends MonoSchemaParser {\n override parse() {\n const ignoreTypes = [this.config.Ts.Keyword.Any];\n const combined = this.schema.allOf.map((childSchema) =>\n this.schemaParserFabric.getInlineParseContent(\n this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema),\n null,\n this.schemaPath,\n ),\n );\n const filtered = this.schemaUtils.filterSchemaContents(\n combined,\n (content) => !ignoreTypes.includes(content),\n );\n\n const type = this.config.Ts.IntersectionType(filtered);\n\n return this.schemaUtils.safeAddNullToType(this.schema, type);\n }\n}\n","import { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\n// T1 | T2\nexport class AnyOfSchemaParser extends MonoSchemaParser {\n override parse() {\n const ignoreTypes = [this.config.Ts.Keyword.Any];\n const combined = this.schema.anyOf.map((childSchema) =>\n this.schemaParserFabric.getInlineParseContent(\n this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema),\n null,\n this.schemaPath,\n ),\n );\n\n const filtered = this.schemaUtils.filterSchemaContents(\n combined,\n (content) => !ignoreTypes.includes(content),\n );\n\n const type = this.config.Ts.UnionType(filtered);\n\n return this.schemaUtils.safeAddNullToType(this.schema, type);\n }\n}\n","import { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\nexport class NotSchemaParser extends MonoSchemaParser {\n override parse() {\n return this.config.Ts.Keyword.Any;\n }\n}\n","import { MonoSchemaParser } from \"../mono-schema-parser.js\";\n\n// T1 | T2\nexport class OneOfSchemaParser extends MonoSchemaParser {\n override parse() {\n const ignoreTypes = [this.config.Ts.Keyword.Any];\n const combined = this.schema.oneOf.map((childSchema) =>\n this.schemaParserFabric.getInlineParseContent(\n this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema),\n null,\n this.schemaPath,\n ),\n );\n\n const filtered = this.schemaUtils.filterSchemaContents(\n combined,\n (content) => !ignoreTypes.includes(content),\n );\n\n const type = this.config.Ts.UnionType(filtered);\n\n return this.schemaUtils.safeAddNullToType(this.schema, type);\n }\n}\n","import { consola } from \"consola\";\nimport { merge } from \"es-toolkit\";\nimport { get } from \"es-toolkit/compat\";\nimport type { CodeGenConfig } from \"../configuration.js\";\nimport { SCHEMA_TYPES } from \"../constants.js\";\nimport type { SchemaComponentsMap } from \"../schema-components-map.js\";\nimport type { TemplatesWorker } from \"../templates-worker.js\";\nimport type { TypeNameFormatter } from \"../type-name-formatter.js\";\nimport { sortByProperty } from \"../util/sort-by-property.js\";\nimport { ArraySchemaParser } from \"./base-schema-parsers/array.js\";\nimport { ComplexSchemaParser } from \"./base-schema-parsers/complex.js\";\nimport { DiscriminatorSchemaParser } from \"./base-schema-parsers/discriminator.js\";\nimport { EnumSchemaParser } from \"./base-schema-parsers/enum.js\";\nimport { ObjectSchemaParser } from \"./base-schema-parsers/object.js\";\nimport { PrimitiveSchemaParser } from \"./base-schema-parsers/primitive.js\";\nimport { AllOfSchemaParser } from \"./complex-schema-parsers/all-of.js\";\nimport { AnyOfSchemaParser } from \"./complex-schema-parsers/any-of.js\";\nimport { NotSchemaParser } from \"./complex-schema-parsers/not.js\";\nimport { OneOfSchemaParser } from \"./complex-schema-parsers/one-of.js\";\nimport type { SchemaFormatters } from \"./schema-formatters.js\";\nimport type { SchemaParserFabric } from \"./schema-parser-fabric.js\";\nimport type { SchemaUtils } from \"./schema-utils.js\";\n\nexport class SchemaParser {\n schemaParserFabric: SchemaParserFabric;\n config: CodeGenConfig;\n schemaComponentsMap: SchemaComponentsMap;\n typeNameFormatter: TypeNameFormatter;\n schemaFormatters: SchemaFormatters;\n schemaUtils: SchemaUtils;\n templatesWorker: TemplatesWorker;\n\n typeName: string | null;\n // biome-ignore lint/suspicious/noExplicitAny: TODO: narrow to OpenAPI schema type\n schema: any;\n schemaPath: string[];\n\n constructor(\n schemaParserFabric: SchemaParserFabric,\n {\n typeName,\n schema,\n schemaPath,\n }: {\n typeName?: string | null;\n // biome-ignore lint/suspicious/noExplicitAny: TODO: narrow to OpenAPI schema type\n schema?: any;\n schemaPath?: string[];\n } = {},\n ) {\n this.schemaParserFabric = schemaParserFabric;\n this.config = schemaParserFabric.config;\n this.templatesWorker = schemaParserFabric.templatesWorker;\n this.schemaComponentsMap = schemaParserFabric.schemaComponentsMap;\n this.typeNameFormatter = schemaParserFabric.typeNameFormatter;\n this.schemaFormatters = schemaParserFabric.schemaFormatters;\n this.schemaUtils = schemaParserFabric.schemaUtils;\n\n this.typeName = typeName || null;\n this.schema = schema;\n this.schemaPath = [...(schemaPath || [])];\n }\n\n _complexSchemaParsers = {\n [SCHEMA_TYPES.COMPLEX_ONE_OF]: (schema) => {\n const SchemaParser =\n this.config.schemaParsers.complexOneOf || OneOfSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n null,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n [SCHEMA_TYPES.COMPLEX_ALL_OF]: (schema) => {\n const SchemaParser =\n this.config.schemaParsers.complexAllOf || AllOfSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n null,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n [SCHEMA_TYPES.COMPLEX_ANY_OF]: (schema) => {\n const SchemaParser =\n this.config.schemaParsers.complexAnyOf || AnyOfSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n null,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n [SCHEMA_TYPES.COMPLEX_NOT]: (schema) => {\n const SchemaParser =\n this.config.schemaParsers.complexNot || NotSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n null,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n };\n\n _baseSchemaParsers = {\n [SCHEMA_TYPES.ENUM]: (schema, typeName) => {\n const SchemaParser = this.config.schemaParsers.enum || EnumSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n typeName,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n [SCHEMA_TYPES.OBJECT]: (schema, typeName) => {\n const SchemaParser =\n this.config.schemaParsers.object || ObjectSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n typeName,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n [SCHEMA_TYPES.COMPLEX]: (schema, typeName) => {\n const SchemaParser =\n this.config.schemaParsers.complex || ComplexSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n typeName,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n [SCHEMA_TYPES.PRIMITIVE]: (schema, typeName) => {\n const SchemaParser =\n this.config.schemaParsers.primitive || PrimitiveSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n typeName,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n [SCHEMA_TYPES.DISCRIMINATOR]: (schema, typeName) => {\n const SchemaParser =\n this.config.schemaParsers.discriminator || DiscriminatorSchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n typeName,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n [SCHEMA_TYPES.ARRAY]: (schema, typeName) => {\n const SchemaParser = this.config.schemaParsers.array || ArraySchemaParser;\n const schemaParser = new SchemaParser(\n this,\n schema,\n typeName,\n this.schemaPath,\n );\n return schemaParser.parse();\n },\n };\n\n parseSchema = () => {\n if (!this.schema)\n return this._baseSchemaParsers[SCHEMA_TYPES.PRIMITIVE](\n null,\n this.typeName,\n );\n\n let schemaType = null;\n let parsedSchema = null;\n\n if (typeof this.schema === \"string\") {\n return this.schema;\n }\n\n if (!this.schema.$parsed) {\n if (!this.typeName && this.schemaUtils.isRefSchema(this.schema)) {\n this.typeName = this.schemaUtils.getSchemaType(this.schema);\n }\n\n //#region swagger schemas fixes\n\n // schema has items but don't have array type\n if (\n this.schema.items &&\n !Array.isArray(this.schema.items) &&\n !this.schema.type\n ) {\n this.schema.type = SCHEMA_TYPES.ARRAY;\n }\n // schema is enum with one null value\n if (\n Array.isArray(this.schema.enum) &&\n this.schema.enum.length === 1 &&\n this.schema.enum[0] == null\n ) {\n consola.debug(\"invalid enum schema\", this.schema);\n this.schema = { type: this.config.Ts.Keyword.Null };\n }\n // schema is response schema\n if (\"content\" in this.schema && typeof this.schema.content === \"object\") {\n const schema = this.extractSchemaFromResponseStruct(this.schema);\n const schemaParser = this.schemaParserFabric.createSchemaParser({\n schema,\n typeName: this.typeName,\n schemaPath: this.schemaPath,\n });\n this.schema.$parsed = schemaParser.parseSchema();\n return this.schema.$parsed;\n }\n\n //#endregion\n\n schemaType = this.schemaUtils.getInternalSchemaType(this.schema);\n\n this.schemaPath.push(this.typeName);\n\n merge(\n this.schema,\n this.config.hooks.onPreParseSchema(\n this.schema,\n this.typeName,\n schemaType,\n ) || {},\n );\n parsedSchema = this._baseSchemaParsers[schemaType](\n this.schema,\n this.typeName,\n );\n this.schema.$parsed =\n this.config.hooks.onParseSchema(this.schema, parsedSchema) ||\n parsedSchema;\n\n if (\n this.config.sortTypes &&\n Array.isArray(this.schema.$parsed?.content)\n ) {\n this.schema.$parsed.content = this.schema.$parsed.content.sort(\n sortByProperty(\"name\"),\n );\n }\n }\n\n this.schemaPath.pop();\n\n return this.schema.$parsed;\n };\n\n getInlineParseContent = () => {\n const parsedSchema = this.parseSchema();\n const formattedSchema = this.schemaFormatters.formatSchema(\n parsedSchema,\n \"inline\",\n );\n return formattedSchema.content;\n };\n\n getParseContent = () => {\n const parsedSchema = this.parseSchema();\n const formattedSchema = this.schemaFormatters.formatSchema(\n parsedSchema,\n \"base\",\n );\n return formattedSchema.content;\n };\n\n extractSchemaFromResponseStruct = (responseStruct) => {\n const { content, ...extras } = responseStruct;\n\n const contentValues = Object.values(content || {});\n const firstResponse = contentValues[0] as\n | Record<string, unknown>\n | undefined;\n const firstSchema = get(firstResponse, \"schema\");\n\n if (!firstSchema) return;\n\n const { schema: _, ...restResponse } = firstResponse || {};\n\n return {\n ...extras,\n ...restResponse,\n ...firstSchema,\n };\n };\n}\n","import { compact, uniq } from \"es-toolkit\";\nimport { camelCase, get } from \"es-toolkit/compat\";\nimport type { CodeGenConfig } from \"../configuration.js\";\nimport { SCHEMA_TYPES } from \"../constants.js\";\nimport type { SchemaComponentsMap } from \"../schema-components-map.js\";\nimport type { TypeNameFormatter } from \"../type-name-formatter.js\";\nimport { pascalCase } from \"../util/pascal-case.js\";\n\nexport class SchemaUtils {\n constructor(\n public config: CodeGenConfig,\n public schemaComponentsMap: SchemaComponentsMap,\n public typeNameFormatter: TypeNameFormatter,\n ) {}\n\n isBinaryLikeMimeType = (contentMediaType: unknown) => {\n if (typeof contentMediaType !== \"string\" || !contentMediaType) return false;\n\n const mediaType = contentMediaType.split(\";\")[0]?.trim().toLowerCase();\n\n if (!mediaType) return false;\n\n /**\n * `contentMediaType` comes from JSON Schema. In practice it is often used to\n * signal \"this string is a file/blob\", but it may also be used for textual\n * payloads (json/xml/etc). We treat only binary-ish media types as `File`.\n */\n if (mediaType.startsWith(\"text/\")) return false;\n if (mediaType.includes(\"json\") || mediaType.includes(\"+json\")) return false;\n\n /** application/vnd.* binary types first: names like \"openxmlformats\" / \"spreadsheetml\" contain \"xml\" but are binary. */\n if (mediaType.startsWith(\"application/vnd.\")) {\n return (\n mediaType.endsWith(\".blob\") ||\n mediaType.includes(\"spreadsheetml.sheet\") ||\n mediaType.startsWith(\"application/vnd.ms-excel\") ||\n mediaType.startsWith(\n \"application/vnd.openxmlformats-officedocument.\",\n ) ||\n mediaType === \"application/vnd.rar\" ||\n mediaType.startsWith(\"application/vnd.oasis.opendocument.\") ||\n mediaType.startsWith(\"application/vnd.ms-powerpoint\") ||\n mediaType.startsWith(\"application/vnd.ms-fontobject\") ||\n mediaType === \"application/vnd.visio\" ||\n mediaType === \"application/vnd.amazon.ebook\"\n );\n }\n\n if (mediaType.includes(\"xml\") || mediaType.includes(\"+xml\")) return false;\n if (mediaType === \"application/x-www-form-urlencoded\") return false;\n if (\n mediaType === \"application/javascript\" ||\n mediaType === \"application/ecmascript\" ||\n mediaType === \"application/graphql\" ||\n mediaType === \"application/yaml\" ||\n mediaType === \"application/x-yaml\" ||\n mediaType === \"application/jwt\"\n ) {\n return false;\n }\n\n if (mediaType.startsWith(\"application/\")) {\n return (\n mediaType === \"application/octet-stream\" ||\n mediaType.startsWith(\"application/pdf\") ||\n mediaType === \"application/zip\" ||\n mediaType.startsWith(\"application/x-zip\") ||\n mediaType === \"application/gzip\" ||\n mediaType.startsWith(\"application/x-gzip\") ||\n mediaType.startsWith(\"application/x-bzip\") ||\n mediaType === \"application/x-bzip2\" ||\n mediaType.startsWith(\"application/x-tar\") ||\n mediaType.startsWith(\"application/x-rar\") ||\n mediaType.startsWith(\"application/x-7z\") ||\n mediaType === \"application/x-binary\" ||\n mediaType === \"application/java-archive\" ||\n mediaType === \"application/epub+zip\" ||\n mediaType === \"application/msword\" ||\n mediaType === \"application/rtf\" ||\n mediaType === \"application/x-abiword\" ||\n mediaType === \"application/x-freearc\"\n );\n }\n\n return (\n mediaType.startsWith(\"image/\") ||\n mediaType.startsWith(\"audio/\") ||\n mediaType.startsWith(\"video/\") ||\n mediaType.startsWith(\"font/\") ||\n mediaType.startsWith(\"model/\")\n );\n };\n\n getRequiredProperties = (schema) => {\n return uniq(\n (schema && Array.isArray(schema.required) && schema.required) || [],\n );\n };\n\n isRefSchema = (schema) => {\n return !!schema?.$ref;\n };\n\n getEnumNames = (schema) => {\n return (\n schema[\"x-enumNames\"] ||\n schema.xEnumNames ||\n schema[\"x-enumnames\"] ||\n schema[\"x-enum-varnames\"]\n );\n };\n\n getEnumDescriptions = (schema) => {\n return (\n schema[\"x-enumDescriptions\"] ||\n schema.xEnumDescriptions ||\n schema[\"x-enumdescriptions\"] ||\n schema[\"x-enum-descriptions\"]\n );\n };\n\n getSchemaPropertyNamesSchema = (schema) => {\n if (!schema) return null;\n return schema.propertyNames || schema[\"x-propertyNames\"] || null;\n };\n\n getSchemaRefType = (schema) => {\n if (!this.isRefSchema(schema)) return null;\n return this.schemaComponentsMap.get(schema.$ref);\n };\n\n isPropertyRequired = (name, propertySchema, rootSchema) => {\n if (propertySchema[\"x-omitempty\"] === false) {\n return true;\n }\n\n const isRequired =\n typeof propertySchema.required === \"boolean\"\n ? !!propertySchema.required\n : Array.isArray(rootSchema.required)\n ? rootSchema.required.includes(name)\n : !!rootSchema.required;\n\n if (this.config.convertedFromSwagger2) {\n return typeof propertySchema.nullable === this.config.Ts.Keyword.Undefined\n ? isRequired\n : !propertySchema.nullable;\n }\n return isRequired;\n };\n\n isNullMissingInType = (schema, type) => {\n const { nullable, type: schemaType } = schema || {};\n return (\n (nullable ||\n !!get(schema, \"x-nullable\") ||\n schemaType === this.config.Ts.Keyword.Null) &&\n typeof type === \"string\" &&\n !type.includes(` ${this.config.Ts.Keyword.Null}`) &&\n !type.includes(`${this.config.Ts.Keyword.Null} `)\n );\n };\n\n safeAddNullToType = (schema, type) => {\n if (this.isNullMissingInType(schema, type)) {\n return this.config.Ts.UnionType([type, this.config.Ts.Keyword.Null]);\n }\n return type;\n };\n\n getSchemaPrimitiveType = (rawSchema) => {\n const schema = rawSchema || {};\n\n if (schema.type) {\n return camelCase(schema.type);\n }\n if (schema.enum) {\n const enumFieldType = typeof schema.enum[0];\n if (enumFieldType === this.config.Ts.Keyword.Undefined) return;\n\n return camelCase(enumFieldType);\n }\n if (Object.keys(schema.properties || {}).length) {\n return SCHEMA_TYPES.OBJECT;\n }\n if (schema.items) {\n return SCHEMA_TYPES.ARRAY;\n }\n\n return null;\n };\n\n checkAndAddRequiredKeys = (schema, resultType) => {\n if (\"$$requiredKeys\" in schema && schema.$$requiredKeys.length) {\n this.config.update({\n internalTemplateOptions: {\n addUtilRequiredKeysType: true,\n },\n });\n return this.config.Ts.TypeWithGeneric(\n this.config.Ts.CodeGenKeyword.UtilRequiredKeys,\n [\n resultType,\n this.config.Ts.UnionType(\n schema.$$requiredKeys.map(this.config.Ts.StringValue),\n ),\n ],\n );\n }\n\n return resultType;\n };\n\n makeAddRequiredToChildSchema = (parentSchema, childSchema) => {\n if (!childSchema) return childSchema;\n\n const required = uniq([\n ...this.getRequiredProperties(parentSchema),\n ...this.getRequiredProperties(childSchema),\n ]);\n\n const refData = this.getSchemaRefType(childSchema);\n\n if (refData) {\n const refObjectProperties = Object.keys(\n refData.rawTypeData?.properties || {},\n );\n const existedRequiredKeys = refObjectProperties.filter((key) =>\n required.includes(key),\n );\n\n if (!existedRequiredKeys.length) return childSchema;\n\n return {\n ...childSchema,\n $$requiredKeys: existedRequiredKeys,\n };\n }\n\n if (childSchema.properties) {\n const childSchemaProperties = Object.keys(childSchema.properties);\n const existedRequiredKeys = childSchemaProperties.filter((key) =>\n required.includes(key),\n );\n\n if (!existedRequiredKeys.length) return childSchema;\n\n return {\n required: uniq([\n ...this.getRequiredProperties(childSchema),\n ...existedRequiredKeys,\n ]),\n ...childSchema,\n };\n }\n\n return childSchema;\n };\n\n filterSchemaContents = (contents, filterFn) => {\n return uniq(contents.filter((type) => filterFn(type)));\n };\n\n resolveTypeName = (\n typeName,\n { suffixes, resolver, prefixes, shouldReserve = true },\n ) => {\n if (resolver) {\n return this.config.componentTypeNameResolver.resolve([], (reserved) => {\n return resolver(pascalCase(typeName), reserved);\n });\n }\n\n return this.config.componentTypeNameResolver.resolve(\n [\n ...(prefixes || []).map((prefix) =>\n pascalCase(`${prefix} ${typeName}`),\n ),\n ...(suffixes || []).map((suffix) =>\n pascalCase(`${typeName} ${suffix}`),\n ),\n ],\n shouldReserve,\n );\n };\n\n getComplexType = (schema) => {\n if (schema.oneOf) return SCHEMA_TYPES.COMPLEX_ONE_OF;\n if (schema.allOf) return SCHEMA_TYPES.COMPLEX_ALL_OF;\n if (schema.anyOf) return SCHEMA_TYPES.COMPLEX_ANY_OF;\n // TODO :(\n if (schema.not) return SCHEMA_TYPES.COMPLEX_NOT;\n\n return SCHEMA_TYPES.COMPLEX_UNKNOWN;\n };\n\n getInternalSchemaType = (schema) => {\n if (\n (schema.enum && schema.enum.length > 0) ||\n (this.getEnumNames(schema) && this.getEnumNames(schema).length > 0)\n ) {\n return SCHEMA_TYPES.ENUM;\n }\n if (schema.discriminator) {\n return SCHEMA_TYPES.DISCRIMINATOR;\n }\n if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) {\n return SCHEMA_TYPES.COMPLEX;\n }\n if (schema.properties && Object.keys(schema.properties).length > 0) {\n return SCHEMA_TYPES.OBJECT;\n }\n if (schema.type === SCHEMA_TYPES.ARRAY) {\n return SCHEMA_TYPES.ARRAY;\n }\n\n return SCHEMA_TYPES.PRIMITIVE;\n };\n\n getSchemaType = (schema) => {\n if (!schema) return this.config.Ts.Keyword.Any;\n\n const refTypeInfo = this.getSchemaRefType(schema);\n\n if (refTypeInfo) {\n return this.checkAndAddRequiredKeys(\n schema,\n this.safeAddNullToType(\n schema,\n this.typeNameFormatter.format(refTypeInfo.typeName),\n ),\n );\n }\n\n let resultType: string;\n\n if (this.isConstantSchema(schema) && !schema.enum) {\n resultType = this.formatJsValue(schema.const);\n } else {\n const primitiveType = this.getSchemaPrimitiveType(schema);\n\n if (primitiveType == null) {\n return this.config.Ts.Keyword.Any;\n }\n\n if (\n primitiveType === this.config.Ts.Keyword.String &&\n !schema.format &&\n this.isBinaryLikeMimeType(schema.contentMediaType)\n ) {\n resultType = this.config.Ts.UnionType([\n this.config.Ts.Keyword.File,\n this.config.Ts.Keyword.Blob,\n ]);\n } else {\n const typeAlias =\n get(this.config.primitiveTypes, [primitiveType, schema.format]) ||\n get(this.config.primitiveTypes, [primitiveType, \"$default\"]) ||\n this.config.primitiveTypes[primitiveType];\n\n if (typeof typeAlias === \"function\") {\n resultType = typeAlias(schema, this);\n } else {\n resultType = typeAlias || primitiveType;\n }\n }\n }\n\n if (!resultType) {\n return this.config.Ts.Keyword.Any;\n }\n\n return this.checkAndAddRequiredKeys(\n schema,\n this.safeAddNullToType(schema, resultType),\n );\n };\n\n buildTypeNameFromPath = (schemaPath) => {\n schemaPath = uniq(compact(schemaPath || []));\n\n if (!schemaPath || !schemaPath[0]) return null;\n\n return pascalCase(\n uniq([schemaPath[0], schemaPath[schemaPath.length - 1]]).join(\"_\"),\n );\n };\n\n isConstantSchema(schema) {\n return \"const\" in schema;\n }\n\n formatJsValue = (value) => {\n switch (typeof value) {\n case \"string\": {\n return this.config.Ts.StringValue(value);\n }\n case \"boolean\": {\n return this.config.Ts.BooleanValue(value);\n }\n case \"number\": {\n return this.config.Ts.NumberValue(value);\n }\n default: {\n if (value === null) {\n return this.config.Ts.NullValue(value);\n }\n\n return this.config.Ts.Keyword.Any;\n }\n }\n };\n}\n","import type {\n ParsedSchema,\n SchemaComponent,\n SchemaTypeEnumContent,\n SchemaTypeObjectContent,\n SchemaTypePrimitiveContent,\n} from \"../../types/index.js\";\nimport type { CodeGenConfig } from \"../configuration.js\";\nimport type { SchemaComponentsMap } from \"../schema-components-map.js\";\nimport type { TemplatesWorker } from \"../templates-worker.js\";\nimport type { TypeNameFormatter } from \"../type-name-formatter.js\";\nimport type { SchemaParserConfig } from \"./mono-schema-parser.js\";\nimport { SchemaFormatters } from \"./schema-formatters.js\";\nimport { SchemaParser } from \"./schema-parser.js\";\nimport { SchemaUtils } from \"./schema-utils.js\";\n\nexport class SchemaParserFabric {\n config: CodeGenConfig;\n schemaComponentsMap: SchemaComponentsMap;\n typeNameFormatter: TypeNameFormatter;\n schemaFormatters: SchemaFormatters;\n templatesWorker: TemplatesWorker;\n schemaUtils: SchemaUtils;\n\n constructor(\n config: CodeGenConfig,\n templatesWorker: TemplatesWorker,\n schemaComponentsMap: SchemaComponentsMap,\n typeNameFormatter: TypeNameFormatter,\n ) {\n this.config = config;\n this.schemaComponentsMap = schemaComponentsMap;\n this.typeNameFormatter = typeNameFormatter;\n this.templatesWorker = templatesWorker;\n this.schemaUtils = new SchemaUtils(\n this.config,\n this.schemaComponentsMap,\n this.typeNameFormatter,\n );\n this.schemaFormatters = new SchemaFormatters(this);\n }\n\n createSchemaParser = ({\n schema,\n typeName,\n schemaPath,\n }: SchemaParserConfig) => {\n return new SchemaParser(this, { schema, typeName, schemaPath });\n };\n\n createSchema = ({\n content,\n linkedSchema = {},\n linkedComponent,\n schemaPath,\n ...otherSchemaProps\n }: {\n content: unknown;\n linkedSchema?: Record<string, unknown>;\n linkedComponent?: SchemaComponent;\n schemaPath?: string[];\n [key: string]: unknown;\n }) => {\n const parser = this.createSchemaParser({\n schema: linkedComponent || linkedSchema,\n schemaPath,\n });\n const parsed = parser.parseSchema();\n parsed.content = content;\n Object.assign(parsed, otherSchemaProps);\n if (linkedComponent) {\n linkedComponent.typeData = parsed;\n }\n return parser.schema;\n };\n\n createParsedComponent = ({\n typeName,\n schema,\n schemaPath,\n }: Required<SchemaParserConfig> & { typeName: string }): SchemaComponent => {\n const schemaCopy = structuredClone(schema);\n const customComponent = this.schemaComponentsMap.createComponent(\n this.schemaComponentsMap.createRef([\"components\", \"schemas\", typeName]),\n schemaCopy,\n );\n const parsed = this.parseSchema(schemaCopy, null, schemaPath);\n\n parsed.name = typeName;\n customComponent.typeData = parsed;\n\n return customComponent;\n };\n\n parseSchema = (\n schema: SchemaParserConfig[\"schema\"],\n typeName: string | null = null,\n schemaPath: string[] = [],\n ): ParsedSchema<\n SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent\n > => {\n const schemaParser = this.createSchemaParser({\n schema,\n typeName,\n schemaPath,\n });\n return schemaParser.parseSchema();\n };\n\n getInlineParseContent = (\n schema: SchemaParserConfig[\"schema\"],\n typeName: string | null,\n schemaPath: string[],\n ): // biome-ignore lint/suspicious/noExplicitAny: TODO: narrow return type\n Record<string, any> => {\n const parser = this.createSchemaParser({ schema, typeName, schemaPath });\n return parser.getInlineParseContent();\n };\n\n getParseContent = (\n schema: SchemaParserConfig[\"schema\"],\n typeName: string | null,\n schemaPath: string[],\n ): // biome-ignore lint/suspicious/noExplicitAny: TODO: narrow return type\n Record<string, any> => {\n const parser = this.createSchemaParser({ schema, typeName, schemaPath });\n return parser.getParseContent();\n };\n}\n","import * as crypto from \"node:crypto\";\n\nexport const generateId = () => crypto.randomUUID();\n","import { consola } from \"consola\";\nimport type { CodeGenConfig } from \"../../configuration.js\";\nimport { NameResolver } from \"../../util/name-resolver.js\";\n\nexport class SpecificArgNameResolver extends NameResolver {\n counter = 1;\n constructor(config: CodeGenConfig, reservedNames: string[]) {\n super(config, reservedNames, (variants) => {\n const generatedVariant =\n (variants[0] && `${variants[0]}${this.counter++}`) ||\n `${this.config.specificArgNameResolverName}${this.counter++}`;\n consola.debug(\n \"generated fallback type name for specific arg - \",\n generatedVariant,\n );\n return generatedVariant;\n });\n }\n}\n","import { consola } from \"consola\";\nimport { compact, flattenDeep, isEqual, mapValues, uniq } from \"es-toolkit\";\nimport { camelCase, get, reduce } from \"es-toolkit/compat\";\nimport { typeGuard } from \"yummies/type-guard\";\nimport type { AnyObject } from \"yummies/types\";\nimport type {\n GenerateApiConfiguration,\n ParsedRoute,\n ParsedSchema,\n RouteLinkInfo,\n SchemaTypeEnumContent,\n SchemaTypeObjectContent,\n SchemaTypePrimitiveContent,\n} from \"../../types/index.js\";\nimport type { CodeGenConfig } from \"../configuration.js\";\nimport {\n DEFAULT_BODY_ARG_NAME,\n RESERVED_BODY_ARG_NAMES,\n RESERVED_HEADER_ARG_NAMES,\n RESERVED_PATH_ARG_NAMES,\n RESERVED_QUERY_ARG_NAMES,\n} from \"../constants.js\";\nimport type { ResolvedSwaggerSchema } from \"../resolved-swagger-schema.js\";\nimport type { SchemaComponentsMap } from \"../schema-components-map.js\";\nimport type { SchemaParserFabric } from \"../schema-parser/schema-parser-fabric.js\";\nimport type { SchemaUtils } from \"../schema-parser/schema-utils.js\";\nimport type { TemplatesWorker } from \"../templates-worker.js\";\nimport type { TypeNameFormatter } from \"../type-name-formatter.js\";\nimport { generateId } from \"../util/id.js\";\nimport { SpecificArgNameResolver } from \"./util/specific-arg-name-resolver.js\";\n\nconst CONTENT_KIND = {\n JSON: \"JSON\",\n JSON_API: \"JSON_API\",\n URL_ENCODED: \"URL_ENCODED\",\n FORM_DATA: \"FORM_DATA\",\n IMAGE: \"IMAGE\",\n OTHER: \"OTHER\",\n TEXT: \"TEXT\",\n};\n\nexport class SchemaRoutes {\n schemaUtils: SchemaUtils;\n FORM_DATA_TYPES: string[] = [];\n\n routes: ParsedRoute[] = [];\n hasSecurityRoutes = false;\n hasQueryRoutes = false;\n hasFormDataRoutes = false;\n\n constructor(\n public config: CodeGenConfig,\n public schemaParserFabric: SchemaParserFabric,\n public schemaComponentsMap: SchemaComponentsMap,\n public templatesWorker: TemplatesWorker,\n public typeNameFormatter: TypeNameFormatter,\n ) {\n this.schemaUtils = this.schemaParserFabric.schemaUtils;\n\n this.FORM_DATA_TYPES = uniq([\n this.schemaUtils.getSchemaType({ type: \"string\", format: \"file\" }),\n this.schemaUtils.getSchemaType({ type: \"string\", format: \"binary\" }),\n ]);\n }\n\n createRequestsMap = (\n resolvedSwaggerSchema: ResolvedSwaggerSchema,\n routesByMethod,\n ) => {\n const parameters = get(routesByMethod, \"parameters\");\n\n const result = {};\n for (const [method, requestInfo] of Object.entries(routesByMethod)) {\n if (method.startsWith(\"x-\") || [\"parameters\"].includes(method)) {\n continue;\n }\n\n if (method === \"$ref\") {\n const refData = resolvedSwaggerSchema.getRef(requestInfo);\n if (typeGuard.isObject(refData)) {\n Object.assign(\n result,\n this.createRequestsMap(resolvedSwaggerSchema, refData),\n );\n }\n continue;\n }\n\n result[method] = {\n ...(requestInfo as object),\n parameters: compact([\n ...(parameters || []),\n ...((requestInfo as any).parameters || []),\n ]),\n };\n }\n\n return result;\n };\n\n parseRouteName = (rawRoute) => {\n const routeName =\n this.config.hooks.onPreBuildRoutePath(rawRoute) || rawRoute;\n\n // TODO forbid leading symbols [\\]^` in a major release (allowed yet for backwards compatibility)\n const pathParamMatches = (routeName || \"\").match(\n /({[\\w[\\\\\\]^`][-_.\\w]*})|(:[\\w[\\\\\\]^`][-_.\\w]*:?)/g,\n );\n\n // used in case when path parameters is not declared in requestInfo.parameters (\"in\": \"path\")\n const pathParams: any[] = [];\n for (const match of pathParamMatches || []) {\n const paramName = match.replace(/\\{|\\}|:/g, \"\");\n\n if (!paramName) continue;\n\n if (paramName.includes(\"-\")) {\n consola.warn(\"wrong path param name\", paramName);\n }\n\n pathParams.push({\n $match: match,\n name: camelCase(paramName),\n required: true,\n type: \"string\",\n description: \"\",\n schema: {\n type: \"string\",\n },\n in: \"path\",\n });\n }\n\n let fixedRoute = pathParams.reduce((fixedRoute, pathParam, i, arr) => {\n const insertion =\n this.config.hooks.onInsertPathParam(\n pathParam.name,\n i,\n arr,\n fixedRoute,\n ) || pathParam.name;\n return fixedRoute.replace(pathParam.$match, `\\${${insertion}}`);\n }, routeName || \"\");\n\n const queryParamMatches = fixedRoute.match(/(\\{\\?.*\\})/g);\n const queryParams: any[] = [];\n\n if (queryParamMatches?.length) {\n for (const match of queryParamMatches) {\n fixedRoute = fixedRoute.replace(match, \"\");\n }\n\n const paramNames = uniq(\n queryParamMatches\n .join(\",\")\n .replace(/(\\{\\?)|(\\})|\\s/g, \"\")\n .split(\",\"),\n );\n\n for (const paramName of paramNames) {\n if (typeof paramName === \"string\" && paramName.includes(\"-\")) {\n consola.warn(\"wrong query param name\", paramName);\n }\n\n queryParams.push({\n $match: paramName,\n name:\n typeof paramName === \"string\"\n ? camelCase(paramName)\n : camelCase(String(paramName)),\n required: true,\n type: \"string\",\n description: \"\",\n schema: {\n type: \"string\",\n },\n in: \"query\",\n });\n }\n }\n\n const result = {\n originalRoute: rawRoute || \"\",\n route: fixedRoute,\n pathParams,\n queryParams,\n };\n\n return this.config.hooks.onBuildRoutePath(result) || result;\n };\n\n getRouteParams = (\n routeInfo,\n pathParamsFromRouteName,\n queryParamsFromRouteName,\n ) => {\n const { parameters } = routeInfo;\n\n const routeParams = {\n path: [],\n header: [],\n body: [],\n query: [],\n formData: [],\n cookie: [],\n };\n\n for (const parameter of parameters || []) {\n const refTypeInfo =\n this.schemaParserFabric.schemaUtils.getSchemaRefType(parameter);\n\n let routeParam = null;\n\n if (\n !!refTypeInfo?.rawTypeData &&\n typeof refTypeInfo === \"object\" &&\n refTypeInfo?.rawTypeData.in\n ) {\n if (!routeParams[refTypeInfo.rawTypeData.in]) {\n routeParams[refTypeInfo.rawTypeData.in] = [];\n }\n\n routeParam = {\n ...refTypeInfo.rawTypeData,\n ...(refTypeInfo.rawTypeData.schema || {}),\n };\n\n if (parameter?.required && !routeParam.required) {\n routeParam.required = parameter.required;\n }\n } else {\n if (!parameter.in) continue;\n\n if (!routeParams[parameter.in]) {\n routeParams[parameter.in] = [];\n }\n\n routeParam = {\n ...parameter,\n ...(parameter.schema || {}),\n };\n }\n\n if (routeParam.in === \"path\") {\n if (!routeParam.name) continue;\n\n routeParam.name = camelCase(routeParam.name);\n }\n\n routeParams[routeParam.in].push(routeParam);\n }\n\n // used in case when path parameters is not declared in requestInfo.parameters (\"in\": \"path\")\n for (const pathParam of pathParamsFromRouteName) {\n const alreadyExist = routeParams.path.some(\n (parameter) => parameter.name === pathParam.name,\n );\n\n if (!alreadyExist) {\n routeParams.path.push(pathParam);\n }\n }\n\n // used in case when path parameters is not declared in requestInfo.parameters (\"in\": \"path\")\n for (const queryParam of queryParamsFromRouteName) {\n const alreadyExist = routeParams.query.some(\n (parameter) => parameter.name === queryParam.name,\n );\n\n if (!alreadyExist) {\n routeParams.query.push(queryParam);\n }\n }\n\n return routeParams;\n };\n\n getContentTypes = (requestInfo, extraContentTypes) => {\n const requestInfoArray = Array.isArray(requestInfo)\n ? requestInfo\n : Object.values(requestInfo || {});\n return uniq(\n compact([\n ...(extraContentTypes || []),\n ...flattenDeep(\n requestInfoArray.map(\n (requestInfoData) =>\n requestInfoData && Object.keys(requestInfoData?.content || {}),\n ),\n ),\n ]),\n );\n };\n\n getContentKind = (contentTypes) => {\n if (contentTypes.includes(\"application/vnd.api+json\")) {\n return CONTENT_KIND.JSON_API;\n }\n\n if (\n contentTypes.some((contentType) =>\n contentType.startsWith(\"application/json\"),\n ) ||\n contentTypes.some((contentType) => contentType.endsWith(\"+json\"))\n ) {\n return CONTENT_KIND.JSON;\n }\n\n if (contentTypes.includes(\"application/x-www-form-urlencoded\")) {\n return CONTENT_KIND.URL_ENCODED;\n }\n\n if (contentTypes.includes(\"multipart/form-data\")) {\n return CONTENT_KIND.FORM_DATA;\n }\n\n if (contentTypes.some((contentType) => contentType.includes(\"image/\"))) {\n return CONTENT_KIND.IMAGE;\n }\n\n if (contentTypes.some((contentType) => contentType.startsWith(\"text/\"))) {\n return CONTENT_KIND.TEXT;\n }\n\n return CONTENT_KIND.OTHER;\n };\n\n /** True when response produces only binary media types (e.g. file download). */\n isBinaryOnlyContentTypes = (contentTypes: string[]) =>\n !!contentTypes?.length &&\n contentTypes.every((ct) => this.schemaUtils.isBinaryLikeMimeType(ct));\n\n isSuccessStatus = (status) =>\n (this.config.defaultResponseAsSuccess && status === \"default\") ||\n (+status >= this.config.successResponseStatusRange[0] &&\n +status <= this.config.successResponseStatusRange[1]) ||\n status === \"2xx\";\n\n getSchemaFromRequestType = (requestInfo) => {\n const content = get(requestInfo, \"content\");\n\n if (!content) return null;\n\n /* content: { \"multipart/form-data\": { schema: {...} }, \"application/json\": { schema: {...} } } */\n\n /* for example: dataType = \"multipart/form-data\" */\n for (const dataType in content) {\n if (content[dataType]?.schema) {\n return {\n ...content[dataType].schema,\n dataType,\n };\n }\n }\n\n return null;\n };\n\n getTypeFromRequestInfo = ({\n requestInfo,\n parsedSchemas,\n operationId,\n defaultType,\n typeName,\n }) => {\n // TODO: make more flexible pick schema without content type\n const schema = this.getSchemaFromRequestType(requestInfo);\n const refTypeInfo =\n this.schemaParserFabric.schemaUtils.getSchemaRefType(requestInfo);\n\n if (schema) {\n const content = this.schemaParserFabric.getInlineParseContent(\n schema,\n typeName,\n [operationId],\n );\n const foundedSchemaByName = parsedSchemas.find(\n (parsedSchema) =>\n this.typeNameFormatter.format(parsedSchema.name) === content,\n );\n const foundSchemaByContent = parsedSchemas.find((parsedSchema) =>\n isEqual(parsedSchema.content, content),\n );\n\n const foundSchema = foundedSchemaByName || foundSchemaByContent;\n\n return foundSchema\n ? this.typeNameFormatter.format(foundSchema.name)\n : content;\n }\n\n if (refTypeInfo) {\n // const refTypeWithoutOpId = refType.replace(operationId, '');\n // const foundedSchemaByName = _.find(parsedSchemas, ({ name }) => name === refType || name === refTypeWithoutOpId)\n\n // TODO:HACK fix problem of swagger2openapi\n const typeNameWithoutOpId = refTypeInfo.typeName.replace(operationId, \"\");\n if (parsedSchemas.find((schema) => schema.name === typeNameWithoutOpId)) {\n return this.typeNameFormatter.format(typeNameWithoutOpId);\n }\n\n switch (refTypeInfo.componentName) {\n case \"schemas\":\n return this.typeNameFormatter.format(refTypeInfo.typeName);\n case \"responses\":\n case \"requestBodies\":\n return this.schemaParserFabric.getInlineParseContent(\n this.getSchemaFromRequestType(refTypeInfo.rawTypeData),\n refTypeInfo.typeName || null,\n [operationId],\n );\n default:\n return this.schemaParserFabric.getInlineParseContent(\n refTypeInfo.rawTypeData,\n refTypeInfo.typeName || null,\n [operationId],\n );\n }\n }\n\n return defaultType || this.config.Ts.Keyword.Any;\n };\n\n getRequestInfoTypes = ({\n requestInfos,\n parsedSchemas,\n operationId,\n defaultType,\n resolvedSwaggerSchema,\n }) => {\n const result: any[] = [];\n\n for (const [status, requestInfo] of Object.entries(requestInfos || {})) {\n // content types are derived from response `content` keys; never mix in operationId\n const contentTypes = this.getContentTypes([requestInfo]);\n const links = this.getRouteLinksFromResponse(\n resolvedSwaggerSchema,\n requestInfo,\n status,\n );\n\n result.push({\n ...((requestInfo as object) || {}),\n contentTypes: contentTypes,\n contentKind: this.getContentKind(contentTypes),\n type: this.schemaParserFabric.schemaUtils.safeAddNullToType(\n requestInfo,\n // @ts-expect-error TS(2345) FIXME: Argument of type '{ requestInfo: any; parsedSchema... Remove this comment to see the full error message\n this.getTypeFromRequestInfo({\n requestInfo,\n parsedSchemas,\n operationId,\n defaultType,\n }),\n ),\n description: this.schemaParserFabric.schemaFormatters.formatDescription(\n (requestInfo as any).description || \"\",\n true,\n ),\n links,\n status: Number.isNaN(+status) ? status : +status,\n isSuccess: this.isSuccessStatus(status),\n });\n }\n\n return result;\n };\n\n getRouteLinksFromResponse = (\n resolvedSwaggerSchema: ResolvedSwaggerSchema,\n responseInfo: AnyObject,\n status: string,\n ): RouteLinkInfo[] => {\n const links = get(responseInfo, \"links\");\n if (!typeGuard.isObject(links)) {\n return [];\n }\n\n return reduce(\n links,\n (acc, linkInfo, linkName) => {\n if (!typeGuard.isObject(linkInfo)) {\n return acc;\n }\n\n let normalizedLinkInfo = linkInfo;\n\n if (typeof linkInfo.$ref === \"string\") {\n const refData = resolvedSwaggerSchema.getRef(linkInfo.$ref);\n if (typeGuard.isObject(refData)) {\n normalizedLinkInfo = refData;\n }\n }\n\n const operationId =\n typeof normalizedLinkInfo.operationId === \"string\"\n ? normalizedLinkInfo.operationId\n : undefined;\n const operationRef =\n typeof normalizedLinkInfo.operationRef === \"string\"\n ? normalizedLinkInfo.operationRef\n : typeof linkInfo.$ref === \"string\"\n ? linkInfo.$ref\n : undefined;\n\n if (!operationId && !operationRef) {\n return acc;\n }\n\n const parameters = typeGuard.isObject(normalizedLinkInfo.parameters)\n ? mapValues(normalizedLinkInfo.parameters, (value) => String(value))\n : undefined;\n\n acc.push({\n status: Number.isNaN(+status) ? status : +status,\n name: String(linkName),\n operationId,\n operationRef,\n parameters,\n });\n\n return acc;\n },\n [] as RouteLinkInfo[],\n );\n };\n\n getResponseBodyInfo = (\n routeInfo,\n parsedSchemas,\n resolvedSwaggerSchema,\n pathName?: string,\n method?: string,\n ) => {\n const { produces, operationId, responses } = routeInfo;\n\n const contentTypes = this.getContentTypes(responses, [\n ...(produces || []),\n routeInfo[\"x-accepts\"],\n ]);\n\n const successStatus = Object.keys(responses || {}).find((s) =>\n this.isSuccessStatus(s),\n );\n const successResponseContent =\n successStatus && (responses as AnyObject)?.[successStatus];\n const successContentTypes =\n successResponseContent?.content &&\n typeof successResponseContent.content === \"object\"\n ? Object.keys(successResponseContent.content)\n : null;\n\n const originalProduces =\n pathName && method\n ? (resolvedSwaggerSchema.getOriginalProduces(pathName, method) ??\n get(resolvedSwaggerSchema.originalSchema, [\n \"paths\",\n pathName,\n method,\n \"produces\",\n ]))\n : undefined;\n\n const responseInfos = this.getRequestInfoTypes({\n requestInfos: responses,\n parsedSchemas,\n operationId,\n defaultType: this.config.defaultResponseType,\n resolvedSwaggerSchema,\n });\n const links = responseInfos.flatMap(\n (responseInfo) => responseInfo.links || [],\n );\n\n const successResponse = responseInfos.find(\n (response) => response.isSuccess,\n );\n const errorResponses = responseInfos.filter(\n (response) =>\n !response.isSuccess && response.type !== this.config.Ts.Keyword.Any,\n );\n\n const handleResponseHeaders = (src) => {\n if (!src) {\n return \"headers: {},\";\n }\n const headerTypes = Object.fromEntries(\n Object.entries(src).map(([k, v]) => {\n return [k, this.schemaUtils.getSchemaType(v)];\n }),\n );\n const r = `headers: { ${Object.entries(headerTypes)\n .map(([k, v]) => `\"${k}\": ${v}`)\n .join(\",\")} },`;\n return r;\n };\n\n /* Prefer operation-level produces for binary check. After Swagger 2→OAS3 conversion, response content is often filled from global produces (e.g. application/json), so use original schema's produces when available. */\n const typesToCheck =\n (Array.isArray(originalProduces) && originalProduces.length > 0\n ? originalProduces\n : null) ??\n (produces?.length ? produces : null) ??\n (successContentTypes?.length ? successContentTypes : null) ??\n contentTypes;\n const isBinarySuccessType = this.isBinaryOnlyContentTypes(typesToCheck);\n\n const successType = isBinarySuccessType\n ? this.config.Ts.Keyword.Blob\n : successResponse?.type || this.config.Ts.Keyword.Any;\n\n return {\n contentTypes,\n responses: responseInfos,\n links,\n typesToCheck,\n success: {\n isBinary: isBinarySuccessType,\n schema: successResponse,\n type: successType,\n },\n error: {\n schemas: errorResponses,\n type:\n this.config.Ts.UnionType(\n errorResponses.map((response) => response.type),\n ) || this.config.Ts.Keyword.Any,\n },\n full: {\n types:\n this.config.Ts.UnionType(\n responseInfos.map(\n (response) => `{\n data: ${response.type}, status: ${response.status}, statusCode: ${\n response.status\n }, statusText: \"${response.description}\", ${handleResponseHeaders(\n response.headers,\n )} config: {} }`,\n ),\n ) || this.config.Ts.Keyword.Any,\n },\n };\n };\n\n convertRouteParamsIntoObject = (params) => {\n return params.reduce(\n (objectSchema, schemaPart) => {\n if (!schemaPart || !schemaPart.name) return objectSchema;\n\n return {\n ...objectSchema,\n properties: {\n ...objectSchema.properties,\n [schemaPart.name]: {\n ...schemaPart,\n ...(schemaPart.schema || {}),\n },\n },\n };\n },\n {\n properties: {},\n type: \"object\",\n },\n );\n };\n\n getRequestBodyInfo = (routeInfo, routeParams, parsedSchemas, routeName) => {\n const { requestBody, consumes, requestBodyName, operationId } = routeInfo;\n let schema = null;\n let content = null;\n\n const contentTypes = this.getContentTypes(\n [requestBody],\n [...(consumes || []), routeInfo[\"x-contentType\"]],\n );\n let contentKind = this.getContentKind(contentTypes);\n\n let typeName = null;\n\n if (this.config.extractRequestBody) {\n typeName = this.schemaUtils.resolveTypeName(routeName.usage, {\n suffixes: this.config.extractingOptions.requestBodySuffix,\n resolver: this.config.extractingOptions.requestBodyNameResolver,\n });\n }\n\n if (routeParams.formData.length) {\n contentKind = CONTENT_KIND.FORM_DATA;\n schema = this.convertRouteParamsIntoObject(routeParams.formData);\n content = this.schemaParserFabric.getInlineParseContent(\n schema,\n typeName,\n [operationId],\n );\n } else if (contentKind === CONTENT_KIND.FORM_DATA) {\n schema = this.getSchemaFromRequestType(requestBody);\n content = this.schemaParserFabric.getInlineParseContent(\n schema,\n typeName,\n [operationId],\n );\n } else if (requestBody) {\n schema = this.getSchemaFromRequestType(requestBody);\n content = this.schemaParserFabric.schemaUtils.safeAddNullToType(\n requestBody,\n // @ts-expect-error TS(2345) FIXME: Argument of type '{ requestInfo: any; parsedSchema... Remove this comment to see the full error message\n this.getTypeFromRequestInfo({\n requestInfo: requestBody,\n parsedSchemas,\n operationId,\n typeName,\n }),\n );\n\n // TODO: Refactor that.\n // It needed for cases when swagger schema is not declared request body type as form data\n // but request body data type contains form data types like File\n if (\n this.FORM_DATA_TYPES.some((dataType) =>\n content.includes(`: ${dataType}`),\n )\n ) {\n contentKind = CONTENT_KIND.FORM_DATA;\n }\n }\n\n if (schema && !schema.$ref && this.config.extractRequestBody) {\n schema = this.schemaParserFabric.createParsedComponent({\n schema,\n typeName,\n schemaPath: [operationId],\n });\n\n if (schema?.typeData) {\n schema.typeData.isExtractedRequestBody = true;\n }\n content = this.schemaParserFabric.getInlineParseContent({\n $ref: schema.$ref,\n });\n }\n\n if (\n schema &&\n schema.typeData &&\n !schema.typeData.description &&\n requestBody?.description\n ) {\n schema.typeData.description = requestBody.description;\n }\n\n return {\n ...(requestBody || {}),\n paramName: requestBodyName || requestBody?.name || DEFAULT_BODY_ARG_NAME,\n contentTypes,\n contentKind,\n schema,\n type: content,\n required:\n requestBody &&\n (typeof requestBody.required === \"undefined\" || !!requestBody.required),\n };\n };\n\n createRequestParamsSchema = ({\n queryParams,\n queryObjectSchema,\n pathArgsSchemas,\n extractRequestParams,\n routeName,\n }) => {\n if (\n (!queryParams || !queryParams.length) &&\n (!pathArgsSchemas || !pathArgsSchemas.length)\n )\n return null;\n\n const pathParams = pathArgsSchemas.reduce((acc, pathArgSchema) => {\n if (pathArgSchema.name) {\n acc[pathArgSchema.name] = {\n ...pathArgSchema,\n in: \"path\",\n };\n }\n\n return acc;\n }, {});\n\n const fixedQueryParams = {};\n const queryObjectProperties = get(queryObjectSchema, \"properties\") || {};\n for (const [name, property] of Object.entries(queryObjectProperties)) {\n if (name && typeof property === \"object\") {\n fixedQueryParams[name] = {\n ...property,\n in: \"query\",\n };\n }\n }\n\n const schema = {\n ...queryObjectSchema,\n properties: {\n ...fixedQueryParams,\n ...pathParams,\n },\n };\n\n const fixedSchema = this.config.hooks.onCreateRequestParams(schema);\n\n if (fixedSchema) return fixedSchema;\n\n if (extractRequestParams) {\n const generatedTypeName = this.schemaUtils.resolveTypeName(\n routeName.usage,\n {\n suffixes: this.config.extractingOptions.requestParamsSuffix,\n resolver: this.config.extractingOptions.requestParamsNameResolver,\n },\n );\n\n const component = this.schemaParserFabric.createParsedComponent({\n typeName: generatedTypeName,\n schema: schema,\n });\n\n if (component.typeData) {\n component.typeData.isExtractedRequestParams = true;\n }\n\n return component;\n }\n\n return schema;\n };\n\n extractResponseBodyIfItNeeded = (routeInfo, responseBodyInfo, routeName) => {\n if (\n responseBodyInfo.responses.length &&\n responseBodyInfo.success &&\n responseBodyInfo.success.schema\n ) {\n const typeName = this.schemaUtils.resolveTypeName(routeName.usage, {\n suffixes: this.config.extractingOptions.responseBodySuffix,\n resolver: this.config.extractingOptions.responseBodyNameResolver,\n });\n\n const idx = responseBodyInfo.responses.indexOf(\n responseBodyInfo.success.schema,\n );\n\n const successResponse = responseBodyInfo.success;\n const contentKind = successResponse.schema?.contentKind;\n const actualSchema = this.getSchemaFromRequestType(\n successResponse.schema,\n );\n\n if (actualSchema && !actualSchema.$ref) {\n successResponse.schema = this.schemaParserFabric.createParsedComponent({\n schema: actualSchema,\n typeName,\n schemaPath: [routeInfo.operationId],\n });\n successResponse.schema.contentKind = contentKind;\n if (successResponse.schema.typeData) {\n successResponse.schema.typeData.isExtractedResponseBody = true;\n }\n successResponse.type = this.schemaParserFabric.getInlineParseContent({\n $ref: successResponse.schema.$ref,\n });\n\n if (idx > -1) {\n Object.assign(responseBodyInfo.responses[idx], {\n ...successResponse.schema,\n type: successResponse.type,\n });\n }\n } else if (responseBodyInfo.success.isBinary) {\n /* Binary response with $ref or OAS3 content: emit type alias GetXxxData = Blob and use Blob in route (same as isBinarySuccessType in getResponseBodyInfo). */\n const blobSchema = { type: \"string\", format: \"byte\" };\n successResponse.schema = this.schemaParserFabric.createParsedComponent({\n schema: blobSchema,\n typeName,\n schemaPath: [routeInfo.operationId],\n });\n successResponse.schema.contentKind = contentKind;\n if (successResponse.schema.typeData) {\n successResponse.schema.typeData.isExtractedResponseBody = true;\n }\n successResponse.type = this.config.Ts.Keyword.Blob;\n\n if (idx > -1) {\n Object.assign(responseBodyInfo.responses[idx], {\n ...successResponse.schema,\n type: successResponse.type,\n });\n }\n } else if (actualSchema?.$ref) {\n /* Non-binary response with $ref: emit type alias GetXxxData = RefType (e.g. GetPetByIdData = Pet). */\n successResponse.schema = this.schemaParserFabric.createParsedComponent({\n schema: actualSchema,\n typeName,\n schemaPath: [routeInfo.operationId],\n });\n successResponse.schema.contentKind = contentKind;\n if (successResponse.schema.typeData) {\n successResponse.schema.typeData.isExtractedResponseBody = true;\n }\n successResponse.type = this.schemaParserFabric.getInlineParseContent({\n $ref: successResponse.schema.$ref,\n });\n\n if (idx > -1) {\n Object.assign(responseBodyInfo.responses[idx], {\n ...successResponse.schema,\n type: successResponse.type,\n });\n }\n } else if (\n successResponse.schema &&\n actualSchema === null &&\n (responseBodyInfo.success.type === this.config.Ts.Keyword.Any ||\n responseBodyInfo.success.type === this.config.defaultResponseType)\n ) {\n /* Response with no content schema and type Any/void (e.g. form-url-encoded): preserve legacy extracted type alias (= any). When actualSchema is null but type is a real type (e.g. $ref to components/responses), skip so route keeps the correct type from getResponseBodyInfo. */\n const schema = {};\n successResponse.schema = this.schemaParserFabric.createParsedComponent({\n schema,\n typeName,\n schemaPath: [routeInfo.operationId],\n });\n successResponse.schema.contentKind = contentKind;\n if (successResponse.schema.typeData) {\n successResponse.schema.typeData.isExtractedResponseBody = true;\n }\n successResponse.type = this.schemaParserFabric.getInlineParseContent({\n $ref: successResponse.schema.$ref,\n });\n\n if (idx > -1) {\n Object.assign(responseBodyInfo.responses[idx], {\n ...successResponse.schema,\n type: successResponse.type,\n });\n }\n }\n }\n };\n\n extractResponseErrorIfItNeeded = (routeInfo, responseBodyInfo, routeName) => {\n if (\n responseBodyInfo.responses.length &&\n responseBodyInfo.error.schemas &&\n responseBodyInfo.error.schemas.length\n ) {\n const typeName = this.schemaUtils.resolveTypeName(routeName.usage, {\n suffixes: this.config.extractingOptions.responseErrorSuffix,\n resolver: this.config.extractingOptions.responseErrorNameResolver,\n });\n\n const errorSchemas = compact(\n responseBodyInfo.error.schemas.map(this.getSchemaFromRequestType),\n );\n\n if (!errorSchemas.length) return;\n\n const schema = this.schemaParserFabric.parseSchema(\n {\n oneOf: errorSchemas,\n title: compact(errorSchemas.map((schema) => schema.title)).join(\" \"),\n description: compact(\n errorSchemas.map((schema) => schema.description),\n ).join(\"\\n\"),\n },\n null,\n [routeInfo.operationId],\n );\n const component = this.schemaComponentsMap.createComponent(\n this.schemaComponentsMap.createRef([\"components\", \"schemas\", typeName]),\n schema,\n );\n responseBodyInfo.error.schemas = [component];\n if (component.typeData) {\n component.typeData.isExtractedResponseError = true;\n }\n responseBodyInfo.error.type = this.typeNameFormatter.format(\n component.typeName,\n );\n }\n };\n\n getRouteName = (rawRouteInfo) => {\n const { moduleName } = rawRouteInfo;\n const { routeNameDuplicatesMap, templatesToRender } = this.config;\n const routeNameTemplate = templatesToRender.routeName;\n\n const routeNameFromTemplate = this.templatesWorker.renderTemplate(\n routeNameTemplate,\n {\n routeInfo: rawRouteInfo,\n },\n );\n\n const routeName =\n this.config.hooks.onFormatRouteName?.(\n rawRouteInfo,\n routeNameFromTemplate,\n ) || routeNameFromTemplate;\n\n const duplicateIdentifier = `${moduleName}|${routeName}`;\n\n if (routeNameDuplicatesMap.has(duplicateIdentifier)) {\n routeNameDuplicatesMap.set(\n duplicateIdentifier,\n routeNameDuplicatesMap.get(duplicateIdentifier) + 1,\n );\n\n consola.warn(\n `Module \"${moduleName}\" already has method \"${routeName}()\".`,\n `This method has been renamed to \"${\n routeName + routeNameDuplicatesMap.get(duplicateIdentifier)\n }()\" to solve conflict names.`,\n );\n } else {\n routeNameDuplicatesMap.set(duplicateIdentifier, 1);\n }\n\n const duplicates = routeNameDuplicatesMap.get(duplicateIdentifier);\n\n const routeNameInfo = {\n usage: routeName + (duplicates > 1 ? duplicates : \"\"),\n original: routeName,\n duplicate: duplicates > 1,\n };\n\n return (\n this.config.hooks.onCreateRouteName?.(routeNameInfo, rawRouteInfo) ||\n routeNameInfo\n );\n };\n\n parseRouteInfo = (\n rawRouteName,\n routeInfo,\n method,\n resolvedSwaggerSchema: ResolvedSwaggerSchema,\n parsedSchemas,\n ): ParsedRoute => {\n const { security: globalSecurity } = resolvedSwaggerSchema.usageSchema;\n const { moduleNameIndex, moduleNameFirstTag, extractRequestParams } =\n this.config;\n const {\n operationId,\n requestBody,\n security,\n parameters,\n summary,\n description,\n tags,\n responses,\n requestBodyName,\n produces,\n consumes,\n ...otherInfo\n } = routeInfo;\n const {\n route,\n pathParams: pathParamsFromRouteName,\n queryParams: queryParamsFromRouteName,\n } = this.parseRouteName(rawRouteName);\n\n const routeId = generateId();\n const firstTag = tags && tags.length > 0 ? tags[0] : null;\n const moduleName =\n moduleNameFirstTag && firstTag\n ? camelCase(firstTag)\n : // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message\n camelCase(compact(route.split(\"/\"))[moduleNameIndex] || \"\");\n let hasSecurity = !!globalSecurity?.length;\n if (security) {\n hasSecurity = security.length > 0;\n }\n\n const routeParams = this.getRouteParams(\n routeInfo,\n pathParamsFromRouteName,\n queryParamsFromRouteName,\n );\n\n const pathArgs = routeParams.path.map((pathArgSchema) => ({\n name: pathArgSchema.name,\n optional: !pathArgSchema.required,\n // mark it as any for now, because \"getInlineParseContent\" breaks type names of extracted enums\n type: this.config.Ts.Keyword.Any,\n description: pathArgSchema.description,\n }));\n const pathArgsNames = pathArgs.map((arg) => arg.name);\n\n const responseBodyInfo = this.getResponseBodyInfo(\n routeInfo,\n parsedSchemas,\n resolvedSwaggerSchema,\n rawRouteName,\n method,\n );\n\n const rawRouteInfo = {\n ...otherInfo,\n pathArgs,\n operationId,\n method,\n route: rawRouteName,\n moduleName,\n responsesTypes: responseBodyInfo.responses,\n links: responseBodyInfo.links,\n description,\n tags,\n summary,\n responses,\n produces,\n requestBody,\n consumes,\n security,\n };\n\n const queryObjectSchema = this.convertRouteParamsIntoObject(\n routeParams.query,\n );\n const pathObjectSchema = this.convertRouteParamsIntoObject(\n routeParams.path,\n );\n const headersObjectSchema = this.convertRouteParamsIntoObject(\n routeParams.header,\n );\n\n const routeName = this.getRouteName(rawRouteInfo);\n\n const requestBodyInfo = this.getRequestBodyInfo(\n routeInfo,\n routeParams,\n parsedSchemas,\n routeName,\n );\n\n const requestParamsSchema = this.createRequestParamsSchema({\n queryParams: routeParams.query,\n pathArgsSchemas: routeParams.path,\n queryObjectSchema,\n extractRequestParams,\n routeName,\n });\n\n if (this.config.extractResponseBody) {\n this.extractResponseBodyIfItNeeded(\n routeInfo,\n responseBodyInfo,\n routeName,\n );\n }\n if (this.config.extractResponseError) {\n this.extractResponseErrorIfItNeeded(\n routeInfo,\n responseBodyInfo,\n routeName,\n );\n }\n\n const typeName = this.schemaUtils.resolveTypeName(routeName.usage, {\n suffixes: this.config.extractingOptions.requestParamsSuffix,\n resolver: this.config.extractingOptions.requestParamsNameResolver,\n shouldReserve: false,\n });\n\n const queryType = routeParams.query.length\n ? this.schemaParserFabric.getInlineParseContent(queryObjectSchema, null, [\n typeName,\n ])\n : null;\n const pathType = routeParams.path.length\n ? this.schemaParserFabric.getInlineParseContent(pathObjectSchema, null, [\n typeName,\n ])\n : null;\n const headersType = routeParams.header.length\n ? this.schemaParserFabric.getInlineParseContent(\n headersObjectSchema,\n null,\n [typeName],\n )\n : null;\n\n const nameResolver = new SpecificArgNameResolver(\n this.config,\n pathArgsNames,\n );\n\n const specificArgs = {\n query: queryType\n ? {\n name: nameResolver.resolve(RESERVED_QUERY_ARG_NAMES),\n optional: this.schemaParserFabric.parseSchema(\n queryObjectSchema,\n null,\n [routeName.usage],\n ).allFieldsAreOptional,\n type: queryType,\n }\n : void 0,\n body: requestBodyInfo.type\n ? {\n ...requestBodyInfo,\n name: nameResolver.resolve([\n requestBodyInfo.paramName,\n ...RESERVED_BODY_ARG_NAMES,\n ]),\n optional: !requestBodyInfo.required,\n type: requestBodyInfo.type,\n }\n : void 0,\n pathParams: pathType\n ? {\n name: nameResolver.resolve(RESERVED_PATH_ARG_NAMES),\n optional: this.schemaParserFabric.parseSchema(\n pathObjectSchema,\n null,\n [routeName.usage],\n ).allFieldsAreOptional,\n type: pathType,\n }\n : void 0,\n headers: headersType\n ? {\n name: nameResolver.resolve(RESERVED_HEADER_ARG_NAMES),\n optional: this.schemaParserFabric.parseSchema(\n headersObjectSchema,\n null,\n [routeName.usage],\n ).allFieldsAreOptional,\n type: headersType,\n }\n : void 0,\n };\n\n pathArgs.forEach((pathArg, i) => {\n pathArg.type = this.schemaParserFabric.getInlineParseContent(\n routeParams.path[i].schema,\n null,\n [typeName],\n );\n });\n\n return {\n id: routeId,\n namespace: moduleName.replace(/^(\\d)/, \"v$1\"),\n routeName,\n routeParams,\n requestBodyInfo,\n responseBodyInfo,\n specificArgs,\n queryObjectSchema,\n pathObjectSchema,\n headersObjectSchema,\n responseBodySchema: responseBodyInfo.success.schema,\n requestBodySchema: requestBodyInfo.schema,\n specificArgNameResolver: nameResolver,\n request: {\n contentTypes: requestBodyInfo.contentTypes,\n parameters: pathArgs,\n path: route,\n formData: requestBodyInfo.contentKind === CONTENT_KIND.FORM_DATA,\n isQueryBody: requestBodyInfo.contentKind === CONTENT_KIND.URL_ENCODED,\n security: hasSecurity,\n method: method,\n requestParams: requestParamsSchema,\n\n payload: specificArgs.body,\n query: specificArgs.query,\n pathParams: specificArgs.pathParams,\n headers: specificArgs.headers,\n },\n response: {\n contentTypes: responseBodyInfo.contentTypes,\n type: responseBodyInfo.success.type,\n errorType: responseBodyInfo.error.type,\n fullTypes: responseBodyInfo.full.types,\n },\n raw: rawRouteInfo,\n };\n };\n\n attachSchema = (\n resolvedSwaggerSchema: ResolvedSwaggerSchema,\n parsedSchemas: ParsedSchema<\n | SchemaTypeObjectContent\n | SchemaTypeEnumContent\n | SchemaTypePrimitiveContent\n >[],\n ) => {\n this.config.routeNameDuplicatesMap.clear();\n\n const pathsEntries = Object.entries(\n resolvedSwaggerSchema.usageSchema.paths || {},\n );\n\n for (const [rawRouteName, routeInfoByMethodsMap] of pathsEntries) {\n const routeInfosMap = this.createRequestsMap(\n resolvedSwaggerSchema,\n routeInfoByMethodsMap,\n );\n\n for (const [method, routeInfo] of Object.entries(routeInfosMap)) {\n const parsedRouteInfo = this.parseRouteInfo(\n rawRouteName,\n routeInfo,\n method,\n resolvedSwaggerSchema,\n parsedSchemas,\n );\n const processedRouteInfo =\n this.config.hooks.onCreateRoute(parsedRouteInfo);\n if (processedRouteInfo !== false) {\n const route = processedRouteInfo || parsedRouteInfo;\n\n if (!this.hasSecurityRoutes && route.security) {\n this.hasSecurityRoutes = route.security;\n }\n if (!this.hasQueryRoutes && route.hasQuery) {\n this.hasQueryRoutes = route.hasQuery;\n }\n if (!this.hasFormDataRoutes && route.hasFormDataParams) {\n this.hasFormDataRoutes = route.hasFormDataParams;\n }\n\n this.routes.push(route);\n }\n }\n }\n };\n\n getGroupedRoutes = () => {\n const groupedRoutes = this.routes.reduce(\n (modules, route) => {\n if (route.namespace) {\n if (!modules[route.namespace]) {\n modules[route.namespace] = [];\n }\n\n modules[route.namespace].push(route);\n } else {\n modules.$outOfModule.push(route);\n }\n\n return modules;\n },\n { $outOfModule: [] as ParsedRoute[] },\n );\n\n const routeGroups: GenerateApiConfiguration[\"routes\"] = {\n outOfModule: undefined,\n combined: undefined,\n };\n\n for (const [moduleName, routesGroup] of Object.entries(groupedRoutes)) {\n if (moduleName === \"$outOfModule\") {\n routeGroups.outOfModule = routesGroup;\n } else {\n if (!routeGroups.combined) {\n routeGroups.combined = [];\n }\n routeGroups.combined.push({\n moduleName,\n routes: routesGroup.map((route) => {\n const { original: originalName, usage: usageName } =\n route.routeName;\n\n // TODO: https://github.com/acacode/swagger-typescript-api/issues/152\n // TODO: refactor\n if (\n routesGroup.length > 1 &&\n usageName !== originalName &&\n !routesGroup.some(\n ({ routeName, id }) =>\n id !== route.id && originalName === routeName.original,\n )\n ) {\n return {\n ...route,\n routeName: {\n ...route.routeName,\n usage: originalName,\n },\n };\n }\n\n return route;\n }),\n });\n }\n }\n\n if (this.config.sortRoutes) {\n if (routeGroups.outOfModule) {\n routeGroups.outOfModule = this.sortRoutes(routeGroups.outOfModule);\n }\n if (routeGroups.combined) {\n for (const routeGroup of routeGroups.combined) {\n routeGroup.routes = this.sortRoutes(routeGroup.routes);\n }\n }\n }\n\n return routeGroups;\n };\n\n sortRoutes = (routes: ParsedRoute[]) => {\n return routes\n .slice()\n .sort((routeA, routeB) =>\n routeA.routeName.usage.localeCompare(routeB.routeName.usage),\n );\n };\n}\n","import * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { resolve } from \"@apidevtools/swagger-parser\";\nimport SwaggerParser from \"@apidevtools/swagger-parser\";\nimport consola from \"consola\";\nimport type { OpenAPI } from \"openapi-types\";\nimport * as YAML from \"yaml\";\nimport type { AnyObject, Maybe, Primitive } from \"yummies/types\";\nimport type { CodeGenConfig } from \"./configuration.js\";\n\nexport interface RefDetails {\n ref: string;\n isLocal: boolean;\n externalUrlOrPath: Maybe<string>;\n externalOpenapiFileName?: string;\n}\n\nexport class ResolvedSwaggerSchema {\n private parsedRefsCache = new Map<string, RefDetails>();\n private externalSchemaCache = new Map<string, AnyObject>();\n private httpMethodSegments = new Set([\n \"get\",\n \"put\",\n \"post\",\n \"delete\",\n \"patch\",\n \"options\",\n \"head\",\n \"trace\",\n \"parameters\",\n ]);\n\n private normalizeRef(ref: string): string {\n let normalizedRef = ref;\n\n // Some specs contain refs like \"./file.yaml/#/components/...\"\n // while resolvers usually expect \"./file.yaml#/components/...\".\n normalizedRef = normalizedRef.replace(/\\/#(?=\\/)/, \"#\");\n\n // Keep backward compatibility with refs like \"#components/...\"\n normalizedRef = normalizedRef.replace(/#(?!\\/)/, \"#/\");\n\n return normalizedRef;\n }\n\n private createEscapedPathsRefVariant(ref: string): string | null {\n const normalizedRef = this.normalizeRef(ref);\n const [prefix = \"\", rawPointer = \"\"] = normalizedRef.split(\"#\");\n const pointer = rawPointer.startsWith(\"/\") ? rawPointer : `/${rawPointer}`;\n\n if (!pointer.startsWith(\"/paths/\") || pointer.startsWith(\"/paths/~1\")) {\n return null;\n }\n\n const rest = pointer.slice(\"/paths/\".length);\n if (!rest) {\n return null;\n }\n\n const parts = rest.split(\"/\");\n const last = parts.at(-1)?.toLowerCase() || \"\";\n\n const hasTailSegment = this.httpMethodSegments.has(last);\n const pathParts = hasTailSegment ? parts.slice(0, -1) : parts;\n const tail = hasTailSegment ? `/${parts.at(-1)}` : \"\";\n\n if (!pathParts.length) {\n return null;\n }\n\n const rawPathKey = pathParts.join(\"/\");\n const escapedPathKey = `~1${rawPathKey.replace(/\\//g, \"~1\")}`;\n\n return `${prefix}#/paths/${escapedPathKey}${tail}`;\n }\n\n private isHttpUrl(value: string): boolean {\n return /^https?:\\/\\//i.test(value);\n }\n\n private getRemoteRequestHeaders(): Record<string, string> {\n return Object.assign(\n {},\n this.config.authorizationToken\n ? {\n Authorization: this.config.authorizationToken,\n }\n : {},\n (this.config.requestOptions?.headers as\n | Record<string, string>\n | undefined) || {},\n );\n }\n\n private stripHash(urlOrPath: string): string {\n return urlOrPath.split(\"#\")[0] || urlOrPath;\n }\n\n private extractRefsFromSchema(schema: unknown): string[] {\n const refs = new Set<string>();\n\n const walk = (node: unknown) => {\n if (!node || typeof node !== \"object\") {\n return;\n }\n\n if (Array.isArray(node)) {\n for (const item of node) {\n walk(item);\n }\n return;\n }\n\n const recordNode = node as Record<string, unknown>;\n if (typeof recordNode.$ref === \"string\") {\n refs.add(recordNode.$ref);\n }\n\n for (const value of Object.values(recordNode)) {\n walk(value);\n }\n };\n\n walk(schema);\n return [...refs];\n }\n\n private async fetchRemoteSchemaDocument(\n url: string,\n ): Promise<Maybe<AnyObject>> {\n try {\n const response = await fetch(url, {\n headers: this.getRemoteRequestHeaders(),\n });\n\n if (!response.ok) {\n return null;\n }\n\n const content = await response.text();\n\n try {\n const parsed = JSON.parse(content);\n if (parsed && typeof parsed === \"object\") {\n return parsed as AnyObject;\n }\n } catch {\n const parsed = YAML.parse(content);\n if (parsed && typeof parsed === \"object\") {\n return parsed as AnyObject;\n }\n }\n } catch (e) {\n consola.debug(e);\n }\n\n return null;\n }\n\n private async warmUpRemoteSchemasCache() {\n if (\n typeof this.config.url !== \"string\" ||\n !this.isHttpUrl(this.config.url)\n ) {\n return;\n }\n\n const visited = new Set<string>();\n const queue = [this.stripHash(this.config.url)];\n\n while (queue.length > 0) {\n const currentUrl = queue.shift();\n if (!currentUrl || visited.has(currentUrl)) {\n continue;\n }\n visited.add(currentUrl);\n\n if (this.externalSchemaCache.has(currentUrl)) {\n continue;\n }\n\n const schema = await this.fetchRemoteSchemaDocument(currentUrl);\n if (!schema) {\n continue;\n }\n\n this.externalSchemaCache.set(currentUrl, schema);\n\n for (const ref of this.extractRefsFromSchema(schema)) {\n const normalizedRef = this.normalizeRef(ref);\n if (normalizedRef.startsWith(\"#\")) {\n continue;\n }\n\n const [externalPath = \"\"] = normalizedRef.split(\"#\");\n if (!externalPath) {\n continue;\n }\n\n let absoluteUrl = \"\";\n try {\n absoluteUrl = this.isHttpUrl(externalPath)\n ? this.stripHash(externalPath)\n : this.stripHash(new URL(externalPath, currentUrl).toString());\n } catch (e) {\n consola.debug(e);\n }\n\n if (absoluteUrl && !visited.has(absoluteUrl)) {\n queue.push(absoluteUrl);\n }\n }\n }\n }\n\n private collectRemoteAbsoluteRefCandidates(ref: string): string[] {\n if (!ref || this.isHttpUrl(ref) || ref.startsWith(\"#\")) {\n return [];\n }\n\n const [relativePath = \"\", rawPointer = \"\"] =\n this.normalizeRef(ref).split(\"#\");\n if (!relativePath) {\n return [];\n }\n\n const pointer = rawPointer\n ? rawPointer.startsWith(\"/\")\n ? rawPointer\n : `/${rawPointer}`\n : \"\";\n\n const bases = new Set<string>();\n\n if (\n typeof this.config.url === \"string\" &&\n this.isHttpUrl(this.config.url)\n ) {\n bases.add(this.config.url);\n }\n\n for (const cachedUrl of this.externalSchemaCache.keys()) {\n if (this.isHttpUrl(cachedUrl)) {\n bases.add(cachedUrl);\n }\n }\n\n for (const resolver of this.resolvers) {\n try {\n const resolverPaths =\n typeof resolver.paths === \"function\" ? resolver.paths() : [];\n for (const resolverPath of resolverPaths) {\n if (\n typeof resolverPath === \"string\" &&\n this.isHttpUrl(resolverPath)\n ) {\n bases.add(resolverPath);\n }\n }\n } catch (e) {\n consola.debug(e);\n }\n }\n\n const results = new Set<string>();\n\n for (const base of bases) {\n try {\n const absolutePath = new URL(relativePath, base).toString();\n results.add(pointer ? `${absolutePath}#${pointer}` : absolutePath);\n } catch (e) {\n consola.debug(e);\n }\n }\n\n return [...results];\n }\n\n private resolveFromRemoteSchemaCache(\n absoluteRef: string,\n ): Maybe<AnyObject | Primitive> {\n const normalizedRef = this.normalizeRef(absoluteRef);\n const [externalPath = \"\", rawPointer = \"\"] = normalizedRef.split(\"#\");\n\n if (!externalPath || !this.isHttpUrl(externalPath)) {\n return null;\n }\n\n const schema = this.externalSchemaCache.get(this.stripHash(externalPath));\n if (!schema) {\n return null;\n }\n\n const pointer = rawPointer\n ? rawPointer.startsWith(\"/\")\n ? rawPointer\n : `/${rawPointer}`\n : \"/\";\n\n const resolved = this.resolveJsonPointer(schema, pointer);\n if (resolved == null) {\n return null;\n }\n\n return this.absolutizeLocalRefs(resolved, this.stripHash(externalPath));\n }\n\n private originalProducesByRoute: Record<string, Record<string, string[]>> =\n Object.create(null);\n\n private constructor(\n private config: CodeGenConfig,\n public usageSchema: OpenAPI.Document,\n public originalSchema: OpenAPI.Document,\n private resolvers: Awaited<ReturnType<typeof resolve>>[],\n originalProducesByRoute?: Record<string, Record<string, string[]>>,\n ) {\n this.usageSchema = usageSchema;\n this.originalSchema = originalSchema;\n if (originalProducesByRoute) {\n this.originalProducesByRoute = originalProducesByRoute;\n }\n }\n\n getOriginalProduces(pathName: string, method: string): string[] | undefined {\n return this.originalProducesByRoute[pathName]?.[method];\n }\n\n getRefDetails(ref: string): RefDetails {\n const normalizedRef = this.normalizeRef(ref);\n\n if (!this.parsedRefsCache.has(ref)) {\n const isLocal = normalizedRef.startsWith(\"#\");\n\n if (isLocal) {\n this.parsedRefsCache.set(ref, {\n ref: normalizedRef,\n isLocal,\n externalUrlOrPath: null,\n });\n } else {\n const externalUrlOrPath = normalizedRef.split(\"#\")[0] || \"\";\n const externalPathWithoutTrailingSlash = externalUrlOrPath.replace(\n /\\/$/,\n \"\",\n );\n let externalOpenapiFileName =\n externalPathWithoutTrailingSlash.split(\"/\").at(-1) || \"\";\n\n if (\n externalOpenapiFileName.endsWith(\".json\") ||\n externalOpenapiFileName.endsWith(\".yaml\")\n ) {\n externalOpenapiFileName = externalOpenapiFileName.slice(0, -5);\n } else if (externalOpenapiFileName.endsWith(\".yml\")) {\n externalOpenapiFileName = externalOpenapiFileName.slice(0, -4);\n }\n\n this.parsedRefsCache.set(ref, {\n ref: normalizedRef,\n isLocal,\n externalUrlOrPath,\n externalOpenapiFileName,\n });\n }\n }\n\n const cachedRef = this.parsedRefsCache.get(ref);\n if (cachedRef) {\n return cachedRef;\n }\n\n if (normalizedRef.startsWith(\"#\")) {\n return {\n ref: normalizedRef,\n isLocal: true,\n externalUrlOrPath: null,\n };\n }\n\n return {\n ref: normalizedRef,\n isLocal: false,\n externalUrlOrPath: normalizedRef.split(\"#\")[0] || null,\n externalOpenapiFileName: \"\",\n };\n }\n\n isLocalRef(ref: string): boolean {\n return this.getRefDetails(ref).isLocal;\n }\n\n getRef(ref: Maybe<string>): Maybe<AnyObject | Primitive> {\n if (!ref) {\n return null;\n }\n\n const normalizedRef = this.normalizeRef(ref);\n const escapedPathsRefVariant = this.createEscapedPathsRefVariant(ref);\n\n if (normalizedRef !== ref) {\n const resolvedByNormalizedRef = this.tryToResolveRef(normalizedRef);\n\n if (resolvedByNormalizedRef) {\n return this.normalizeResolvedExternalSchemaRef(\n normalizedRef,\n resolvedByNormalizedRef,\n );\n }\n }\n\n if (escapedPathsRefVariant) {\n const resolvedByEscapedPathsRef = this.tryToResolveRef(\n escapedPathsRefVariant,\n );\n\n if (resolvedByEscapedPathsRef) {\n return this.normalizeResolvedExternalSchemaRef(\n escapedPathsRefVariant,\n resolvedByEscapedPathsRef,\n );\n }\n }\n\n const remoteAbsoluteCandidates =\n this.collectRemoteAbsoluteRefCandidates(ref);\n for (const remoteAbsoluteRef of remoteAbsoluteCandidates) {\n const resolvedFromRemoteCache =\n this.resolveFromRemoteSchemaCache(remoteAbsoluteRef);\n if (resolvedFromRemoteCache) {\n return resolvedFromRemoteCache;\n }\n\n const resolvedByRemoteAbsoluteRef =\n this.tryToResolveRef(remoteAbsoluteRef);\n if (resolvedByRemoteAbsoluteRef) {\n return this.normalizeResolvedExternalSchemaRef(\n remoteAbsoluteRef,\n resolvedByRemoteAbsoluteRef,\n );\n }\n }\n\n const resolvedByOrigRef = this.tryToResolveRef(ref);\n\n if (resolvedByOrigRef) {\n return this.normalizeResolvedExternalSchemaRef(ref, resolvedByOrigRef);\n }\n\n // const ref.match(/\\#[a-z]/)\n if (/#[a-z]/.test(ref)) {\n const fixedRef = ref.replace(/#[a-z]/, (match) => {\n const [hashtag, char] = match.split(\"\");\n return `${hashtag}/${char}`;\n });\n\n const resolvedByFixedRef = this.tryToResolveRef(fixedRef);\n\n if (resolvedByFixedRef) {\n return this.normalizeResolvedExternalSchemaRef(\n fixedRef,\n resolvedByFixedRef,\n );\n }\n }\n\n return this.tryToResolveRefFromFile(normalizedRef);\n\n // this.tryToResolveRef(`@usage${ref}`) ??\n // this.tryToResolveRef(`@original${ref}`)\n }\n\n private tryToResolveRef(ref: Maybe<string>) {\n if (!this.resolvers || !ref) {\n return null;\n }\n\n for (const resolver of this.resolvers) {\n try {\n const resolvedAsIs = resolver.get(ref);\n return resolvedAsIs;\n } catch (e) {\n consola.debug(e);\n }\n }\n\n return null;\n }\n\n private readExternalSchema(filePath: string): Maybe<AnyObject> {\n if (this.externalSchemaCache.has(filePath)) {\n return this.externalSchemaCache.get(filePath) || null;\n }\n\n if (!fs.existsSync(filePath)) {\n return null;\n }\n\n try {\n const content = fs.readFileSync(filePath, \"utf8\");\n const parsed = JSON.parse(content);\n this.externalSchemaCache.set(filePath, parsed);\n return parsed;\n } catch {\n try {\n const content = fs.readFileSync(filePath, \"utf8\");\n const parsed = YAML.parse(content);\n if (parsed && typeof parsed === \"object\") {\n this.externalSchemaCache.set(filePath, parsed as AnyObject);\n return parsed as AnyObject;\n }\n } catch (e) {\n consola.debug(e);\n }\n }\n\n return null;\n }\n\n private resolveJsonPointer(\n source: Maybe<AnyObject>,\n pointer: string,\n ): Maybe<AnyObject | Primitive> {\n if (!source || typeof source !== \"object\") {\n return null;\n }\n\n if (!pointer || pointer === \"/\") {\n return source;\n }\n\n const tokens = pointer\n .replace(/^\\/+/, \"\")\n .split(\"/\")\n .filter(Boolean)\n .map((part) =>\n decodeURIComponent(part.replace(/~1/g, \"/\").replace(/~0/g, \"~\")),\n );\n\n let current: unknown = source;\n\n for (const token of tokens) {\n if (!current || typeof current !== \"object\") {\n return null;\n }\n current = (current as Record<string, unknown>)[token];\n }\n\n return (current as Maybe<AnyObject | Primitive>) ?? null;\n }\n\n private absolutizeLocalRefs(\n value: Maybe<AnyObject | Primitive>,\n externalPath: string,\n ): Maybe<AnyObject | Primitive> {\n if (value == null || typeof value !== \"object\") {\n return value;\n }\n\n const cloneValue = structuredClone(value) as Maybe<AnyObject | Primitive>;\n const walk = (node: unknown) => {\n if (!node || typeof node !== \"object\") {\n return;\n }\n\n if (Array.isArray(node)) {\n for (const item of node) {\n walk(item);\n }\n return;\n }\n\n const recordNode = node as Record<string, unknown>;\n\n if (\n typeof recordNode.$ref === \"string\" &&\n recordNode.$ref.startsWith(\"#\")\n ) {\n recordNode.$ref = `${externalPath}${this.normalizeRef(recordNode.$ref)}`;\n }\n\n for (const nested of Object.values(recordNode)) {\n walk(nested);\n }\n };\n\n walk(cloneValue);\n\n return cloneValue;\n }\n\n private normalizeResolvedExternalSchemaRef(\n ref: string,\n resolved: Maybe<AnyObject | Primitive>,\n ): Maybe<AnyObject | Primitive> {\n const normalizedRef = this.normalizeRef(ref);\n if (normalizedRef.startsWith(\"#\")) {\n return resolved;\n }\n\n const externalPath = normalizedRef.split(\"#\")[0] || \"\";\n if (!externalPath) {\n return resolved;\n }\n\n return this.absolutizeLocalRefs(resolved, externalPath);\n }\n\n private collectExternalRefCandidates(externalPath: string): string[] {\n const candidates = new Set<string>();\n const isRemote = /^https?:\\/\\//i.test(externalPath);\n\n if (isRemote) {\n return [];\n }\n\n if (path.isAbsolute(externalPath)) {\n candidates.add(externalPath);\n }\n\n const inputPath = this.config.input;\n if (typeof inputPath === \"string\" && inputPath) {\n candidates.add(path.resolve(path.dirname(inputPath), externalPath));\n }\n\n for (const resolver of this.resolvers) {\n try {\n const resolverPaths =\n typeof resolver.paths === \"function\" ? resolver.paths() : [];\n for (const resolverPath of resolverPaths) {\n if (typeof resolverPath !== \"string\") {\n continue;\n }\n if (/^https?:\\/\\//i.test(resolverPath)) {\n continue;\n }\n candidates.add(\n path.resolve(path.dirname(resolverPath), externalPath),\n );\n }\n } catch (e) {\n consola.debug(e);\n }\n }\n\n return [...candidates];\n }\n\n private tryToResolveRefFromFile(ref: string): Maybe<AnyObject | Primitive> {\n if (!ref || ref.startsWith(\"#\")) {\n return null;\n }\n\n const [externalPath = \"\", rawPointer = \"\"] = ref.split(\"#\");\n if (!externalPath) {\n return null;\n }\n\n const pointer = rawPointer\n ? rawPointer.startsWith(\"/\")\n ? rawPointer\n : `/${rawPointer}`\n : \"/\";\n\n const candidates = this.collectExternalRefCandidates(externalPath);\n\n for (const candidate of candidates) {\n const schema = this.readExternalSchema(candidate);\n const resolved = this.resolveJsonPointer(schema, pointer);\n if (resolved != null) {\n return this.absolutizeLocalRefs(resolved, externalPath);\n }\n }\n\n return null;\n }\n\n static async create(\n config: CodeGenConfig,\n usageSchema: OpenAPI.Document,\n originalSchema: OpenAPI.Document,\n originalProducesByRoute?: Record<string, Record<string, string[]>>,\n ) {\n const resolvers: Awaited<ReturnType<typeof resolve>>[] = [];\n\n const options: SwaggerParser.Options = {\n continueOnError: true,\n mutateInputSchema: true,\n dereference: {},\n validate: {\n schema: false,\n spec: false,\n },\n resolve: {\n external: true,\n http: {\n ...config.requestOptions,\n headers: Object.assign(\n {},\n config.authorizationToken\n ? {\n Authorization: config.authorizationToken,\n }\n : {},\n config.requestOptions?.headers ?? {},\n ),\n },\n },\n };\n\n try {\n resolvers.push(\n await SwaggerParser.resolve(\n originalSchema,\n // this.config.url || this.config.input || (this.config.spec as any),\n options,\n ),\n );\n } catch (e) {\n consola.debug(e);\n }\n try {\n resolvers.push(await SwaggerParser.resolve(usageSchema, options));\n } catch (e) {\n consola.debug(e);\n }\n try {\n resolvers.push(\n await SwaggerParser.resolve(\n config.url || config.input || (config.spec as OpenAPI.Document),\n options,\n ),\n );\n } catch (e) {\n consola.debug(e);\n }\n\n const resolvedSwaggerSchema = new ResolvedSwaggerSchema(\n config,\n usageSchema,\n originalSchema,\n resolvers,\n originalProducesByRoute,\n );\n\n await resolvedSwaggerSchema.warmUpRemoteSchemasCache();\n\n return resolvedSwaggerSchema;\n }\n}\n","import { consola } from \"consola\";\nimport { merge } from \"es-toolkit\";\nimport type { CodeGenConfig } from \"../configuration.js\";\n\nexport class Request {\n config: CodeGenConfig;\n\n constructor(config: CodeGenConfig) {\n this.config = config;\n }\n\n async download({\n url,\n authToken,\n ...options\n }: {\n url: string;\n authToken?: string;\n options?: Partial<RequestInit>;\n }) {\n const requestOptions: Partial<RequestInit> = {};\n\n if (authToken) {\n requestOptions.headers = {\n Authorization: authToken,\n };\n }\n\n merge(merge(requestOptions, options), this.config.requestOptions || {});\n\n try {\n const response = await fetch(url, requestOptions);\n return await response.text();\n } catch (error) {\n const message = `error while fetching data from URL \"${url}\"`;\n consola.error(message, error);\n return message;\n }\n }\n}\n","import { consola } from \"consola\";\nimport { compact, merge, uniq } from \"es-toolkit\";\nimport { get } from \"es-toolkit/compat\";\nimport type { OpenAPI, OpenAPIV2, OpenAPIV3 } from \"openapi-types\";\nimport type { AnyObject } from \"yummies/types\";\nimport * as swagger2openapi from \"swagger2openapi\";\nimport * as YAML from \"yaml\";\nimport type { CodeGenConfig } from \"./configuration.js\";\nimport { ResolvedSwaggerSchema } from \"./resolved-swagger-schema.js\";\nimport type { FileSystem } from \"./util/file-system.js\";\nimport { Request } from \"./util/request.js\";\n\ninterface SwaggerSchemas {\n usageSchema: OpenAPI.Document;\n originalSchema: OpenAPI.Document;\n /** Unmutated copy of the schema before Swagger 2→3 conversion; used to read operation-level produces. */\n originalSchemaForProduces?: OpenAPI.Document;\n}\n\nexport class SwaggerSchemaResolver {\n config: CodeGenConfig;\n fileSystem: FileSystem;\n request: Request;\n\n constructor(config: CodeGenConfig, fileSystem: FileSystem) {\n this.config = config;\n this.fileSystem = fileSystem;\n this.request = new Request(config);\n }\n\n async create(): Promise<ResolvedSwaggerSchema> {\n const { spec, patch, input, url, authorizationToken } = this.config;\n let swaggerSchemas: SwaggerSchemas;\n\n if (spec) {\n swaggerSchemas = await this.convertSwaggerObject(spec, { patch });\n } else {\n const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(\n input,\n url,\n authorizationToken,\n );\n const swaggerSchemaObject =\n this.processSwaggerSchemaFile(swaggerSchemaFile);\n\n swaggerSchemas = await this.convertSwaggerObject(swaggerSchemaObject, {\n patch,\n });\n }\n\n const originalProducesByRoute = this.fixSwaggerSchemas(swaggerSchemas);\n\n const resolvedSwaggerSchema = await ResolvedSwaggerSchema.create(\n this.config,\n swaggerSchemas.usageSchema,\n swaggerSchemas.originalSchema,\n originalProducesByRoute,\n );\n\n return resolvedSwaggerSchema;\n }\n\n convertSwaggerObject(\n swaggerSchema: OpenAPI.Document,\n converterOptions: { patch?: boolean },\n ): Promise<SwaggerSchemas> {\n return new Promise((resolve) => {\n const result = structuredClone(swaggerSchema);\n const originalSchemaForProduces = structuredClone(swaggerSchema);\n result.info = merge(\n {\n title: \"No title\",\n version: \"\",\n },\n result.info || {},\n );\n\n if (!Object.hasOwn(result, \"openapi\")) {\n result.paths = merge({}, result.paths || {});\n\n swagger2openapi.convertObj(\n result as OpenAPIV2.Document,\n {\n ...converterOptions,\n resolveInternal: true,\n warnOnly: true,\n refSiblings: \"preserve\",\n rbname: \"requestBodyName\",\n },\n (err, options) => {\n const parsedSwaggerSchema =\n get(err, \"options.openapi\") ?? get(options, \"openapi\");\n if (!parsedSwaggerSchema && err) {\n throw err;\n }\n this.config.update({ convertedFromSwagger2: true });\n resolve({\n usageSchema: parsedSwaggerSchema,\n originalSchema: result,\n originalSchemaForProduces,\n });\n },\n );\n } else {\n resolve({\n usageSchema: result,\n originalSchema: structuredClone(result),\n originalSchemaForProduces,\n });\n }\n });\n }\n\n getSwaggerSchemaByPath = (pathToSwagger: string) => {\n consola.info(`try to get swagger by path \"${pathToSwagger}\"`);\n return this.fileSystem.getFileContent(pathToSwagger);\n };\n\n async fetchSwaggerSchemaFile(\n pathToSwagger: string,\n urlToSwagger: string,\n authToken?: string,\n ) {\n if (this.fileSystem.pathIsExist(pathToSwagger)) {\n return this.getSwaggerSchemaByPath(pathToSwagger);\n }\n consola.info(`try to get swagger by URL \"${urlToSwagger}\"`);\n return await this.request.download({\n url: urlToSwagger,\n authToken: authToken,\n });\n }\n\n processSwaggerSchemaFile(file: string) {\n if (typeof file !== \"string\") return file;\n\n try {\n return JSON.parse(file);\n } catch {\n return YAML.parse(file);\n }\n }\n\n private normalizeRefValue(ref: string): string {\n const refWithoutSlashBeforeHash = ref.split(\"/#/\").join(\"#/\");\n const hashIndex = refWithoutSlashBeforeHash.indexOf(\"#\");\n\n if (hashIndex === -1) {\n return refWithoutSlashBeforeHash;\n }\n\n if (refWithoutSlashBeforeHash[hashIndex + 1] === \"/\") {\n return refWithoutSlashBeforeHash;\n }\n\n return `${refWithoutSlashBeforeHash.slice(0, hashIndex + 1)}/${refWithoutSlashBeforeHash.slice(hashIndex + 1)}`;\n }\n\n private normalizeRefsInSchema(schema: unknown): void {\n if (!schema || typeof schema !== \"object\") {\n return;\n }\n\n if (Array.isArray(schema)) {\n for (const value of schema) {\n this.normalizeRefsInSchema(value);\n }\n return;\n }\n\n const objectSchema = schema as Record<string, unknown>;\n\n if (typeof objectSchema.$ref === \"string\") {\n objectSchema.$ref = this.normalizeRefValue(objectSchema.$ref);\n }\n\n for (const value of Object.values(objectSchema)) {\n this.normalizeRefsInSchema(value);\n }\n }\n\n private fixSwaggerSchemas({\n usageSchema,\n originalSchema,\n originalSchemaForProduces,\n }: SwaggerSchemas): Record<string, Record<string, string[]>> {\n this.normalizeRefsInSchema(usageSchema);\n this.normalizeRefsInSchema(originalSchema);\n\n const usagePaths = get(usageSchema, \"paths\") || {};\n const schemaForProduces = originalSchemaForProduces ?? originalSchema;\n const originalPaths = get(schemaForProduces, \"paths\") || {};\n const basePath =\n (schemaForProduces as OpenAPIV2.Document).basePath?.replace(/\\/$/, \"\") ||\n \"\";\n\n const originalProducesByRoute: Record<\n string,\n Record<string, string[]>\n > = Object.create(null);\n\n // walk by routes\n for (const [route, usagePathObject] of Object.entries(usagePaths)) {\n const routeWithoutBase =\n basePath && route.startsWith(basePath)\n ? route.slice(basePath.length) || \"/\"\n : route;\n const routeWithBase =\n basePath && !route.startsWith(basePath)\n ? `${basePath}${route.startsWith(\"/\") ? route : `/${route}`}`\n : route;\n const originalPathObject =\n get(originalPaths, route) ||\n get(\n originalPaths,\n routeWithoutBase.startsWith(\"/\")\n ? routeWithoutBase\n : `/${routeWithoutBase}`,\n ) ||\n get(originalPaths, routeWithBase) ||\n {};\n\n // walk by methods\n for (const [methodName, usageRouteInfo] of Object.entries(\n usagePathObject as Record<string, any>,\n )) {\n const originalRouteInfo = get(originalPathObject, methodName) || {};\n const usageRouteParams = get(usageRouteInfo, \"parameters\") || [];\n const originalRouteParams = get(originalRouteInfo, \"parameters\") || [];\n\n const usageAsOpenapiv2 =\n usageRouteInfo as unknown as OpenAPIV2.Document;\n\n if (typeof usageRouteInfo === \"object\") {\n usageAsOpenapiv2.consumes = uniq(\n compact([\n ...(usageAsOpenapiv2.consumes || []),\n ...(originalRouteInfo.consumes || []),\n ]),\n );\n let mergedProduces = uniq(\n compact([\n ...(usageAsOpenapiv2.produces || []),\n ...(originalRouteInfo.produces || []),\n ]),\n );\n if (mergedProduces.length === 0) {\n mergedProduces = uniq(\n compact(get(schemaForProduces, \"produces\") || []),\n );\n }\n usageAsOpenapiv2.produces = mergedProduces;\n if (mergedProduces.length > 0) {\n if (!originalProducesByRoute[route]) {\n originalProducesByRoute[route] = Object.create(null);\n }\n originalProducesByRoute[route][methodName] = mergedProduces;\n }\n }\n\n for (const originalRouteParam of originalRouteParams) {\n const existUsageParam = usageRouteParams.find(\n (param: OpenAPIV3.ParameterObject) =>\n originalRouteParam.in === param.in &&\n originalRouteParam.name === param.name,\n );\n if (!existUsageParam) {\n usageRouteParams.push(originalRouteParam);\n }\n }\n }\n }\n return originalProducesByRoute;\n }\n}\n","import * as module from \"node:module\";\nimport * as path from \"node:path\";\nimport * as url from \"node:url\";\nimport { consola } from \"consola\";\nimport { get } from \"es-toolkit/compat\";\nimport { Eta } from \"eta\";\nimport type { CodeGenProcess } from \"./code-gen-process.js\";\nimport type { CodeGenConfig } from \"./configuration.js\";\nimport type { FileSystem } from \"./util/file-system.js\";\n\nconst require = module.createRequire(import.meta.url);\n\nconst eta = new Eta({\n functionHeader: \"const includeFile = options.includeFile;\",\n});\n\nexport class TemplatesWorker {\n config: CodeGenConfig;\n fileSystem: FileSystem;\n getRenderTemplateData: CodeGenProcess[\"getRenderTemplateData\"];\n\n constructor(\n config: CodeGenConfig,\n fileSystem: FileSystem,\n getRenderTemplateData: CodeGenProcess[\"getRenderTemplateData\"],\n ) {\n this.config = config;\n this.fileSystem = fileSystem;\n this.getRenderTemplateData = getRenderTemplateData;\n if (this.config.debug) consola.level = Number.MAX_SAFE_INTEGER;\n if (this.config.silent) consola.level = 0;\n }\n\n getTemplatePaths = (\n config: CodeGenConfig,\n ): CodeGenConfig[\"templatePaths\"] => {\n const __dirname = path.dirname(url.fileURLToPath(import.meta.url));\n const baseTemplatesPath = path.resolve(__dirname, \"../templates/base\");\n const defaultTemplatesPath = path.resolve(\n __dirname,\n \"../templates/default\",\n );\n const modularTemplatesPath = path.resolve(\n __dirname,\n \"../templates/modular\",\n );\n const originalTemplatesPath = config.modular\n ? modularTemplatesPath\n : defaultTemplatesPath;\n const customTemplatesPath =\n config.templates && path.resolve(process.cwd(), config.templates);\n\n return {\n /** `templates/base` */\n base: baseTemplatesPath,\n /** `templates/default` */\n default: defaultTemplatesPath,\n /** `templates/modular` */\n modular: modularTemplatesPath,\n /** usage path if `--templates` option is not set */\n original: originalTemplatesPath,\n /** custom path to templates (`--templates`) */\n custom: customTemplatesPath,\n };\n };\n\n cropExtension = (path: string) =>\n this.config.templateExtensions.reduce(\n (path, ext) => (path.endsWith(ext) ? path.replace(ext, \"\") : path),\n path,\n );\n\n getTemplateFullPath = (path_: string, fileName: string) => {\n const raw = path.resolve(path_, \"./\", this.cropExtension(fileName));\n const pathVariants = this.config.templateExtensions.map(\n (extension) => `${raw}${extension}`,\n );\n\n return pathVariants.find(\n (variant) => !!this.fileSystem.pathIsExist(variant),\n );\n };\n\n requireFnFromTemplate = (packageOrPath: string) => {\n const isPath =\n packageOrPath.startsWith(\"./\") || packageOrPath.startsWith(\"../\");\n\n if (isPath) {\n return require(\n path.resolve(\n this.config.templatePaths.custom ||\n this.config.templatePaths.original,\n packageOrPath,\n ),\n );\n }\n\n return require(packageOrPath);\n };\n\n getTemplate = (name: string, fileName: string, path?: string) => {\n const { templatePaths } = this.config;\n\n if (path) {\n return this.fileSystem.getFileContent(path);\n }\n\n if (!fileName) return \"\";\n\n const customFullPath =\n templatePaths.custom &&\n this.getTemplateFullPath(templatePaths.custom, fileName);\n let fileContent =\n customFullPath && this.fileSystem.getFileContent(customFullPath);\n\n if (fileContent) {\n consola.info(\n `\"${name.toLowerCase()}\" template found in \"${templatePaths.custom}\"`,\n );\n return fileContent;\n }\n\n const baseFullPath = this.getTemplateFullPath(templatePaths.base, fileName);\n\n if (baseFullPath) {\n fileContent = this.fileSystem.getFileContent(baseFullPath);\n } else {\n if (templatePaths.custom) {\n consola.warn(\n \"Code generator will use the default template:\",\n `\"${name.toLowerCase()}\"`,\n \"template not found in\",\n `\"${templatePaths.custom}\"`,\n );\n } else {\n consola.info(\n `Code generator will use the default template for \"${name.toLowerCase()}\"`,\n );\n }\n }\n\n const originalFullPath = this.getTemplateFullPath(\n templatePaths.original,\n fileName,\n );\n\n if (originalFullPath) {\n fileContent = this.fileSystem.getFileContent(originalFullPath);\n }\n\n return fileContent;\n };\n\n getTemplates = ({ templatePaths }: CodeGenConfig) => {\n if (templatePaths.custom) {\n consola.info(\n `try to read templates from directory \"${templatePaths.custom}\"`,\n );\n }\n\n return this.config.templateInfos.reduce(\n (acc, { name, fileName }) => ({\n ...acc,\n [name]: this.getTemplate(name, fileName),\n }),\n {},\n );\n };\n\n findTemplateWithExt = (path: string) => {\n const raw = this.cropExtension(path);\n const pathVariants = this.config.templateExtensions.map(\n (extension) => `${raw}${extension}`,\n );\n return pathVariants.find((variant) => this.fileSystem.pathIsExist(variant));\n };\n\n getTemplateContent = (path_: string) => {\n const foundTemplatePathKey = Object.keys(this.config.templatePaths).find(\n (key) => path_.startsWith(`@${key}`),\n );\n\n if (foundTemplatePathKey) {\n const rawPath = path.resolve(\n path_.replace(\n `@${foundTemplatePathKey}`,\n get(this.config.templatePaths, foundTemplatePathKey),\n ),\n );\n const fixedPath = this.findTemplateWithExt(rawPath);\n\n if (fixedPath) {\n return this.fileSystem.getFileContent(fixedPath);\n }\n }\n\n const customPath =\n this.config.templatePaths.custom &&\n this.findTemplateWithExt(\n path.resolve(this.config.templatePaths.custom, path_),\n );\n\n if (customPath) {\n return this.fileSystem.getFileContent(customPath);\n }\n\n const originalPath = this.findTemplateWithExt(\n path.resolve(this.config.templatePaths.original, path_),\n );\n\n if (originalPath) {\n return this.fileSystem.getFileContent(originalPath);\n }\n\n return \"\";\n };\n\n renderTemplate = (\n template: string,\n configuration: Record<string, unknown>,\n ) => {\n if (!template) return \"\";\n\n return eta.render(\n eta.compile(template, { async: false }),\n {\n ...this.getRenderTemplateData(),\n ...configuration,\n },\n {\n // @ts-expect-error eta's meta options lack includeFile despite runtime support\n includeFile: (path: string, configuration: Record<string, string>) =>\n this.renderTemplate(this.getTemplateContent(path), configuration),\n },\n );\n };\n}\n","import type { CodeFormatter } from \"../code-formatter.js\";\nimport type { CodeGenConfig } from \"../configuration.js\";\n\nexport interface TranslatorIO {\n fileName: string;\n fileExtension: string;\n fileContent: string;\n}\n\nexport class Translator {\n config: CodeGenConfig;\n codeFormatter: CodeFormatter;\n\n constructor(config: CodeGenConfig, codeFormatter: CodeFormatter) {\n this.config = config;\n this.codeFormatter = codeFormatter;\n }\n\n translate(_input: TranslatorIO): Promise<TranslatorIO[]> {\n throw new Error(\"not implemented\");\n }\n}\n","import * as typescript from \"typescript\";\nimport { Translator, type TranslatorIO } from \"./translator.js\";\n\nexport class JavascriptTranslator extends Translator {\n compileTSCode = (input: TranslatorIO): Record<string, string> => {\n const fileNameFull = `${input.fileName}${input.fileExtension}`;\n const output = {};\n const host = typescript.createCompilerHost(\n this.config.compilerTsConfig,\n true,\n );\n const fileNames = [fileNameFull];\n const originalSourceFileGet = host.getSourceFile.bind(host);\n host.getSourceFile = (\n sourceFileName,\n languageVersion,\n onError,\n shouldCreateNewSourceFile,\n ) => {\n if (sourceFileName !== fileNameFull)\n return originalSourceFileGet(\n sourceFileName,\n languageVersion,\n onError,\n shouldCreateNewSourceFile,\n );\n\n return typescript.createSourceFile(\n sourceFileName,\n input.fileContent,\n languageVersion,\n true,\n typescript.ScriptKind.TS,\n );\n };\n\n host.writeFile = (fileName, contents) => {\n output[fileName] = contents;\n };\n\n typescript\n .createProgram(fileNames, this.config.compilerTsConfig, host)\n .emit();\n\n return output;\n };\n\n translate = async (input) => {\n const compiled = this.compileTSCode(input);\n\n const jsFileName = `${input.fileName}${typescript.Extension.Js}`;\n const dtsFileName = `${input.fileName}${typescript.Extension.Dts}`;\n const sourceContent = compiled[jsFileName];\n const tsImportRows = input.fileContent\n .split(\"\\n\")\n .filter((line) => line.startsWith(\"import \"));\n const declarationContent = compiled[dtsFileName]\n .split(\"\\n\")\n .map((line) => {\n if (line.startsWith(\"import \")) {\n return tsImportRows.shift();\n }\n return line;\n })\n .join(\"\\n\");\n\n return [\n {\n fileName: input.fileName,\n fileExtension: typescript.Extension.Js,\n fileContent: await this.codeFormatter.formatCode(sourceContent),\n },\n {\n fileName: input.fileName,\n fileExtension: typescript.Extension.Dts,\n fileContent: await this.codeFormatter.formatCode(declarationContent),\n },\n ];\n };\n}\n","import { consola } from \"consola\";\nimport { compact } from \"es-toolkit\";\nimport { startCase } from \"es-toolkit/compat\";\nimport type { CodeGenConfig } from \"./configuration.js\";\n\ntype FormattingSchemaType = \"enum-key\" | \"type-name\";\n\nexport class TypeNameFormatter {\n formattedModelNamesMap = new Map<string, string>();\n config: CodeGenConfig;\n\n constructor(config: CodeGenConfig) {\n this.config = config;\n }\n\n format = (name: string, options: { type?: FormattingSchemaType } = {}) => {\n const schemaType = options.type ?? \"type-name\";\n\n const typePrefix =\n schemaType === \"enum-key\"\n ? this.config.enumKeyPrefix\n : this.config.typePrefix;\n const typeSuffix =\n schemaType === \"enum-key\"\n ? this.config.enumKeySuffix\n : this.config.typeSuffix;\n\n const hashKey = `${typePrefix}_${name}_${typeSuffix}`;\n\n if (typeof name !== \"string\") {\n consola.warn(\"wrong model name\", name);\n return name;\n }\n\n // constant names like LEFT_ARROW, RIGHT_FORWARD, ETC_KEY, _KEY_NUM_\n if (/^(?!\\d)([A-Z0-9_]{1,})$/g.test(name)) {\n return compact([typePrefix, name, typeSuffix]).join(\"_\");\n }\n\n if (this.formattedModelNamesMap.has(hashKey)) {\n return this.formattedModelNamesMap.get(hashKey);\n }\n\n const fixedModelName = this.fixModelName(name, { type: schemaType });\n\n const formattedName = startCase(\n `${typePrefix}_${fixedModelName}_${typeSuffix}`,\n ).replace(/\\s/g, \"\");\n const formattedResultName =\n this.config.hooks.onFormatTypeName?.(formattedName, name, schemaType) ||\n formattedName;\n\n this.formattedModelNamesMap.set(hashKey, formattedResultName);\n\n return formattedResultName;\n };\n\n isValidName = (name: string) => /^([A-Za-z$_]{1,})$/g.test(name);\n\n fixModelName = (\n name: string,\n options: { type?: FormattingSchemaType },\n ): string => {\n if (!this.isValidName(name)) {\n if (!/^[a-zA-Z_$]/g.test(name)) {\n const fixPrefix =\n options.type === \"enum-key\"\n ? this.config.fixInvalidEnumKeyPrefix\n : this.config.fixInvalidTypeNamePrefix;\n return `${fixPrefix} ${name}`;\n }\n\n // specific replaces for TSOA 3.x\n if (name.includes(\".\")) {\n return name\n .replace(/Exclude_keyof[A-Za-z]+/g, () => \"ExcludeKeys\")\n .replace(/%22~AND~%22/g, \"And\")\n .replace(/%22~OR~%22/g, \"Or\")\n .replace(/(\\.?%22)|\\./g, \"_\")\n .replace(/__+$/, \"\");\n }\n\n if (name.includes(\"-\")) {\n return startCase(name).replace(/ /g, \"\");\n }\n }\n\n return name;\n };\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as url from \"node:url\";\nimport { consola } from \"consola\";\nimport { FILE_PREFIX } from \"../constants.js\";\n\nexport class FileSystem {\n getFileContent = (path: string) => {\n return fs.readFileSync(path, { encoding: \"utf8\" });\n };\n\n readDir = (path: string) => {\n return fs.readdirSync(path);\n };\n\n pathIsDir = (path: string) => {\n if (!path) return false;\n\n try {\n const stat = fs.statSync(path);\n return stat.isDirectory();\n } catch (e) {\n return false;\n }\n };\n\n cropExtension = (fileName: string) => {\n const fileNameParts = fileName.split(\".\");\n\n if (fileNameParts.length > 1) {\n fileNameParts.pop();\n }\n\n return fileNameParts.join(\".\");\n };\n\n removeDir = (path: string) => {\n try {\n if (typeof fs.rmSync === \"function\") {\n fs.rmSync(path, { recursive: true });\n } else {\n fs.rmdirSync(path, { recursive: true });\n }\n } catch (e) {\n consola.debug(\"failed to remove dir\", e);\n }\n };\n\n createDir = (path: string) => {\n try {\n fs.mkdirSync(path, { recursive: true });\n } catch (e) {\n consola.debug(\"failed to create dir\", e);\n }\n };\n\n cleanDir = (path: string) => {\n this.removeDir(path);\n this.createDir(path);\n };\n\n pathIsExist = (path: string) => {\n return !!path && fs.existsSync(path);\n };\n\n createFile = ({ path: path_, fileName, content, withPrefix }) => {\n const __dirname = path.dirname(url.fileURLToPath(import.meta.url));\n const absolutePath = path.resolve(__dirname, path_, `./${fileName}`);\n const fileContent = `${withPrefix ? FILE_PREFIX : \"\"}${content}`;\n\n return fs.writeFileSync(absolutePath, fileContent);\n };\n}\n","import * as esToolkit from \"es-toolkit\";\nimport * as esToolkitCompat from \"es-toolkit/compat\";\n\n// Create a lodash-compatible object for templates\n// This is exported as `_` to templates for backwards compatibility\nexport function createLodashCompat(): Record<string, unknown> {\n return {\n ...esToolkit,\n ...esToolkitCompat,\n };\n}\n","import type { resolve } from \"@apidevtools/swagger-parser\";\nimport { consola } from \"consola\";\nimport { compact, merge } from \"es-toolkit\";\nimport { camelCase } from \"es-toolkit/compat\";\nimport * as typescript from \"typescript\";\nimport type {\n GenerateApiConfiguration,\n SchemaComponent,\n} from \"../types/index.js\";\nimport { CodeFormatter } from \"./code-formatter.js\";\nimport { CodeGenConfig } from \"./configuration.js\";\nimport { SchemaComponentsMap } from \"./schema-components-map.js\";\nimport { SchemaParserFabric } from \"./schema-parser/schema-parser-fabric.js\";\nimport { SchemaRoutes } from \"./schema-routes/schema-routes.js\";\nimport { SwaggerSchemaResolver } from \"./swagger-schema-resolver.js\";\nimport { TemplatesWorker } from \"./templates-worker.js\";\nimport { JavascriptTranslator } from \"./translators/javascript.js\";\nimport type { TranslatorIO } from \"./translators/translator.js\";\nimport { TypeNameFormatter } from \"./type-name-formatter.js\";\nimport { FileSystem } from \"./util/file-system.js\";\nimport { createLodashCompat } from \"./util/lodash-compat.js\";\nimport { NameResolver } from \"./util/name-resolver.js\";\nimport { pascalCase } from \"./util/pascal-case.js\";\nimport { sortByProperty } from \"./util/sort-by-property.js\";\n\nconst PATCHABLE_INSTANCES = [\n \"schemaWalker\",\n \"swaggerSchemaResolver\",\n \"schemaComponentsMap\",\n \"typeNameFormatter\",\n \"templatesWorker\",\n \"codeFormatter\",\n \"schemaParserFabric\",\n \"schemaRoutes\",\n \"javascriptTranslator\",\n];\n\nexport class CodeGenProcess {\n config: CodeGenConfig;\n swaggerSchemaResolver: SwaggerSchemaResolver;\n schemaComponentsMap: SchemaComponentsMap;\n typeNameFormatter: TypeNameFormatter;\n schemaParserFabric: SchemaParserFabric;\n schemaRoutes: SchemaRoutes;\n fileSystem: FileSystem;\n codeFormatter: CodeFormatter;\n templatesWorker: TemplatesWorker;\n javascriptTranslator: JavascriptTranslator;\n swaggerRefs: Awaited<ReturnType<typeof resolve>> | undefined | null;\n\n constructor(config: Partial<GenerateApiConfiguration[\"config\"]>) {\n this.config = new CodeGenConfig(config);\n this.fileSystem = new FileSystem();\n this.swaggerSchemaResolver = new SwaggerSchemaResolver(\n this.config,\n this.fileSystem,\n );\n this.schemaComponentsMap = new SchemaComponentsMap(this.config);\n this.typeNameFormatter = new TypeNameFormatter(this.config);\n this.templatesWorker = new TemplatesWorker(\n this.config,\n this.fileSystem,\n this.getRenderTemplateData,\n );\n this.codeFormatter = new CodeFormatter(this.config);\n this.schemaParserFabric = new SchemaParserFabric(\n this.config,\n this.templatesWorker,\n this.schemaComponentsMap,\n this.typeNameFormatter,\n );\n this.schemaRoutes = new SchemaRoutes(\n this.config,\n this.schemaParserFabric,\n this.schemaComponentsMap,\n this.templatesWorker,\n this.typeNameFormatter,\n );\n this.javascriptTranslator = new JavascriptTranslator(\n this.config,\n this.codeFormatter,\n );\n }\n\n async start() {\n this.config.update({\n templatePaths: this.templatesWorker.getTemplatePaths(this.config),\n });\n this.config.update({\n templatesToRender: this.templatesWorker.getTemplates(this.config),\n });\n\n const resolvedSwaggerSchema = await this.swaggerSchemaResolver.create();\n\n this.config.update({\n resolvedSwaggerSchema: resolvedSwaggerSchema,\n swaggerSchema: resolvedSwaggerSchema.usageSchema,\n originalSchema: resolvedSwaggerSchema.originalSchema,\n });\n\n consola.info(\"start generating your typescript api\");\n\n this.config.update(\n this.config.hooks.onInit?.(this.config, this) || this.config,\n );\n\n if (this.config.swaggerSchema) {\n resolvedSwaggerSchema.usageSchema = this.config.swaggerSchema;\n }\n if (this.config.originalSchema) {\n resolvedSwaggerSchema.originalSchema = this.config.originalSchema;\n }\n\n this.schemaComponentsMap.clear();\n\n for (const [componentName, component] of Object.entries(\n resolvedSwaggerSchema.usageSchema.components || {},\n )) {\n for (const [typeName, rawTypeData] of Object.entries(\n component as Record<string, unknown>,\n )) {\n this.schemaComponentsMap.createComponent(\n this.schemaComponentsMap.createRef([\n \"components\",\n componentName,\n typeName,\n ]),\n rawTypeData,\n );\n }\n }\n\n // Set all discriminators at the top\n this.schemaComponentsMap.discriminatorsFirst();\n // Put all enums at the top (before discriminators)\n this.schemaComponentsMap.enumsFirst();\n\n const componentsToParse: SchemaComponent[] =\n this.schemaComponentsMap.filter(\n compact([\"schemas\", this.config.extractResponses && \"responses\"]),\n );\n\n const parsedSchemas = componentsToParse.map((schemaComponent) => {\n const parsed = this.schemaParserFabric.parseSchema(\n schemaComponent.rawTypeData,\n schemaComponent.typeName,\n );\n schemaComponent.typeData = parsed;\n return parsed;\n });\n\n this.schemaRoutes.attachSchema(resolvedSwaggerSchema, parsedSchemas);\n\n const rawConfiguration = {\n apiConfig: this.createApiConfig(resolvedSwaggerSchema.usageSchema),\n config: this.config,\n modelTypes: this.collectModelTypes(),\n hasSecurityRoutes: this.schemaRoutes.hasSecurityRoutes,\n hasQueryRoutes: this.schemaRoutes.hasQueryRoutes,\n hasFormDataRoutes: this.schemaRoutes.hasFormDataRoutes,\n generateResponses: this.config.generateResponses,\n routes: this.schemaRoutes.getGroupedRoutes(),\n extraTemplates: this.config.extraTemplates,\n fileName: this.config.fileName,\n translateToJavaScript: this.config.toJS,\n customTranslator: this.config.customTranslator\n ? new this.config.customTranslator()\n : null,\n utils: this.getRenderTemplateData().utils,\n };\n\n const configuration =\n this.config.hooks.onPrepareConfig?.(rawConfiguration) || rawConfiguration;\n\n if (this.fileSystem.pathIsExist(this.config.output)) {\n if (this.config.cleanOutput) {\n consola.debug(\"cleaning dir\", this.config.output);\n this.fileSystem.cleanDir(this.config.output);\n }\n } else {\n consola.debug(\n `path ${this.config.output} is not exist. creating dir by this path`,\n );\n this.fileSystem.createDir(this.config.output);\n }\n\n const files = await this.generateOutputFiles({\n configuration: configuration,\n });\n\n const isDirPath = this.fileSystem.pathIsDir(this.config.output);\n\n if (isDirPath) {\n for (const file of files) {\n this.fileSystem.createFile({\n path: this.config.output,\n fileName: `${file.fileName}${file.fileExtension}`,\n content: file.fileContent,\n withPrefix: true,\n });\n\n consola.success(\n \"api file\",\n `\"${file.fileName}${file.fileExtension}\"`,\n `created in ${this.config.output}`,\n );\n }\n }\n\n return {\n files,\n configuration,\n getTemplate: this.templatesWorker.getTemplate,\n renderTemplate: this.templatesWorker.renderTemplate,\n createFile: this.fileSystem.createFile,\n formatTSContent: this.codeFormatter.formatCode,\n };\n }\n\n getRenderTemplateData = () => {\n return {\n utils: {\n Ts: this.config.Ts,\n formatDescription:\n this.schemaParserFabric.schemaFormatters.formatDescription,\n escapeJSDocContent:\n this.schemaParserFabric.schemaFormatters.escapeJSDocContent,\n internalCase: camelCase,\n classNameCase: pascalCase,\n pascalCase: pascalCase,\n getInlineParseContent: this.schemaParserFabric.getInlineParseContent,\n getParseContent: this.schemaParserFabric.getParseContent,\n getComponentByRef: this.schemaComponentsMap.get,\n parseSchema: this.schemaParserFabric.parseSchema,\n checkAndAddNull: this.schemaParserFabric.schemaUtils.safeAddNullToType,\n safeAddNullToType:\n this.schemaParserFabric.schemaUtils.safeAddNullToType,\n isNeedToAddNull:\n this.schemaParserFabric.schemaUtils.isNullMissingInType,\n inlineExtraFormatters: this.schemaParserFabric.schemaFormatters.inline,\n formatters: this.schemaParserFabric.schemaFormatters.base,\n formatModelName: this.typeNameFormatter.format,\n fmtToJSDocLine: (line: string, { eol = true }) => {\n return ` * ${line}${eol ? \"\\n\" : \"\"}`;\n },\n NameResolver: NameResolver,\n _: createLodashCompat(),\n require: this.templatesWorker.requireFnFromTemplate,\n },\n config: this.config,\n };\n };\n\n collectModelTypes = () => {\n const components = this.schemaComponentsMap.getComponents();\n let modelTypes = [];\n\n const modelTypeComponents = compact([\n \"schemas\",\n this.config.extractResponses && \"responses\",\n ]);\n\n const getSchemaComponentsCount = () =>\n this.schemaComponentsMap.filter(...modelTypeComponents).length;\n\n let schemaComponentsCount = getSchemaComponentsCount();\n let processedCount = 0;\n\n while (processedCount < schemaComponentsCount) {\n modelTypes = [];\n processedCount = 0;\n for (const component of components) {\n if (modelTypeComponents.includes(component.componentName)) {\n const modelType = this.prepareModelType(component);\n if (modelType) {\n modelTypes.push(modelType);\n }\n processedCount++;\n }\n }\n schemaComponentsCount = getSchemaComponentsCount();\n }\n\n if (this.config.sortTypes) {\n return modelTypes.sort(sortByProperty(\"name\"));\n }\n\n return modelTypes;\n };\n\n prepareModelType = (typeInfo) => {\n if (typeInfo.$prepared) return typeInfo.$prepared;\n\n if (!typeInfo.typeData) {\n typeInfo.typeData = this.schemaParserFabric.parseSchema(\n typeInfo.rawTypeData,\n typeInfo.typeName,\n );\n }\n const rawTypeData = typeInfo.typeData;\n const typeData = this.schemaParserFabric.schemaFormatters.base[\n rawTypeData.type\n ]\n ? this.schemaParserFabric.schemaFormatters.base[rawTypeData.type](\n rawTypeData,\n )\n : rawTypeData;\n const {\n typeIdentifier,\n name: originalName,\n content,\n description,\n } = typeData;\n const name = this.typeNameFormatter.format(originalName);\n\n if (name === null) return null;\n\n const preparedModelType = {\n ...typeData,\n typeIdentifier,\n name,\n description,\n $content: rawTypeData.content,\n rawContent: rawTypeData.content,\n content: content,\n typeData,\n };\n\n typeInfo.$prepared = preparedModelType;\n\n return preparedModelType;\n };\n\n generateOutputFiles = async ({ configuration }): Promise<TranslatorIO[]> => {\n const { modular, templatesToRender } = this.config;\n\n const output = modular\n ? await this.createMultipleFileInfos(templatesToRender, configuration)\n : await this.createSingleFileInfo(templatesToRender, configuration);\n\n if (configuration.extraTemplates?.length) {\n for (const extraTemplate of configuration.extraTemplates) {\n const content = this.templatesWorker.renderTemplate(\n this.fileSystem.getFileContent(extraTemplate.path),\n configuration,\n );\n output.push(\n ...(await this.createOutputFileInfo(\n configuration,\n extraTemplate.name,\n content,\n )),\n );\n }\n }\n\n return output.filter((fileInfo) => !!fileInfo && !!fileInfo.fileContent);\n };\n\n createMultipleFileInfos = async (\n templatesToRender,\n configuration,\n ): Promise<TranslatorIO[]> => {\n const { routes } = configuration;\n const { fileNames, generateRouteTypes, generateClient } =\n configuration.config;\n const modularApiFileInfos: TranslatorIO[] = [];\n\n if (routes.$outOfModule) {\n if (generateRouteTypes) {\n const outOfModuleRouteContent = this.templatesWorker.renderTemplate(\n templatesToRender.routeTypes,\n {\n ...configuration,\n route: configuration.routes.$outOfModule,\n },\n );\n\n modularApiFileInfos.push(\n ...(await this.createOutputFileInfo(\n configuration,\n fileNames.outOfModuleApi,\n outOfModuleRouteContent,\n )),\n );\n }\n if (generateClient) {\n const outOfModuleApiContent = this.templatesWorker.renderTemplate(\n templatesToRender.api,\n {\n ...configuration,\n route: configuration.routes.$outOfModule,\n },\n );\n\n modularApiFileInfos.push(\n ...(await this.createOutputFileInfo(\n configuration,\n fileNames.outOfModuleApi,\n outOfModuleApiContent,\n )),\n );\n }\n }\n\n if (routes.combined) {\n for (const route of routes.combined) {\n if (generateRouteTypes) {\n const routeModuleContent = this.templatesWorker.renderTemplate(\n templatesToRender.routeTypes,\n {\n ...configuration,\n route,\n },\n );\n\n modularApiFileInfos.push(\n ...(await this.createOutputFileInfo(\n configuration,\n pascalCase(`${route.moduleName}_Route`),\n routeModuleContent,\n )),\n );\n }\n\n if (generateClient) {\n const apiModuleContent = this.templatesWorker.renderTemplate(\n templatesToRender.api,\n {\n ...configuration,\n route,\n },\n );\n\n modularApiFileInfos.push(\n ...(await this.createOutputFileInfo(\n configuration,\n pascalCase(route.moduleName),\n apiModuleContent,\n )),\n );\n }\n }\n }\n\n return [\n ...(await this.createOutputFileInfo(\n configuration,\n fileNames.dataContracts,\n this.templatesWorker.renderTemplate(\n templatesToRender.dataContracts,\n configuration,\n ),\n )),\n ...(generateClient\n ? await this.createOutputFileInfo(\n configuration,\n fileNames.httpClient,\n this.templatesWorker.renderTemplate(\n templatesToRender.httpClient,\n configuration,\n ),\n )\n : []),\n ...modularApiFileInfos,\n ];\n };\n\n createSingleFileInfo = async (\n templatesToRender,\n configuration,\n ): Promise<TranslatorIO[]> => {\n const { generateRouteTypes, generateClient } = configuration.config;\n\n return await this.createOutputFileInfo(\n configuration,\n configuration.fileName,\n compact([\n this.templatesWorker.renderTemplate(\n templatesToRender.dataContracts,\n configuration,\n ),\n generateRouteTypes &&\n this.templatesWorker.renderTemplate(\n templatesToRender.routeTypes,\n configuration,\n ),\n generateClient &&\n this.templatesWorker.renderTemplate(\n templatesToRender.httpClient,\n configuration,\n ),\n generateClient &&\n this.templatesWorker.renderTemplate(\n templatesToRender.api,\n configuration,\n ),\n ]).join(\"\\n\"),\n );\n };\n\n createOutputFileInfo = async (\n configuration,\n fileNameFull,\n content,\n ): Promise<TranslatorIO[]> => {\n const fileName = this.fileSystem.cropExtension(fileNameFull);\n const fileExtension = typescript.Extension.Ts;\n\n if (configuration.translateToJavaScript) {\n consola.debug(\"using js translator for\", fileName);\n return await this.javascriptTranslator.translate({\n fileName: fileName,\n fileExtension: fileExtension,\n fileContent: content,\n });\n }\n\n if (configuration.customTranslator) {\n consola.debug(\"using custom translator for\", fileName);\n return await configuration.customTranslator.translate({\n fileName: fileName,\n fileExtension: fileExtension,\n fileContent: content,\n });\n }\n\n consola.debug(\"generating output for\", `${fileName}${fileExtension}`);\n\n return [\n {\n fileName,\n fileExtension: fileExtension,\n fileContent: await this.codeFormatter.formatCode(content),\n },\n ];\n };\n\n createApiConfig = (swaggerSchema) => {\n const { info, servers, host, basePath, externalDocs, tags } = swaggerSchema;\n const server = servers?.[0] || { url: \"\" };\n const { title = \"No title\", version } = info || {};\n const { url: serverUrl } = server;\n\n return {\n info: info || {},\n servers: servers || [],\n basePath,\n host,\n externalDocs: merge(\n {\n url: \"\",\n description: \"\",\n },\n externalDocs || {},\n ),\n tags: compact(tags || []),\n baseUrl: serverUrl,\n title,\n version,\n };\n };\n\n injectClassInstance = (key, value) => {\n this[key] = value;\n for (const instanceKey of PATCHABLE_INSTANCES) {\n if (instanceKey !== key && key in this[instanceKey]) {\n this[instanceKey][key] = value;\n }\n }\n };\n}\n","import type { PartialDeep } from \"type-fest\";\nimport type { ComponentTypeNameResolver } from \"../src/component-type-name-resolver.js\";\nimport type * as CONSTANTS from \"../src/constants.js\";\nimport type { RefDetails } from \"../src/resolved-swagger-schema.js\";\nimport type { MonoSchemaParser } from \"../src/schema-parser/mono-schema-parser.js\";\nimport type { Translator } from \"../src/translators/translator.js\";\n\nexport type HttpClientType =\n (typeof CONSTANTS.HTTP_CLIENT)[keyof typeof CONSTANTS.HTTP_CLIENT];\n\ntype CodeGenConstruct = {\n Keyword: {\n Number: string;\n String: string;\n Boolean: string;\n Any: string;\n Void: string;\n Unknown: string;\n Null: string;\n Undefined: string;\n Object: string;\n File: string;\n Date: string;\n Type: string;\n Enum: string;\n Interface: string;\n Array: string;\n Record: string;\n Intersection: string;\n Union: string;\n };\n CodeGenKeyword: {\n UtilRequiredKeys: string;\n };\n ArrayType: (content: unknown) => string;\n StringValue: (content: unknown) => string;\n BooleanValue: (content: unknown) => string;\n NumberValue: (content: unknown) => string;\n NullValue: (content: unknown) => string;\n UnionType: (content: unknown) => string;\n ExpressionGroup: (content: unknown) => string;\n IntersectionType: (content: unknown) => string;\n RecordType: (content: unknown) => string;\n TypeField: (content: unknown) => string;\n InterfaceDynamicField: (content: unknown) => string;\n EnumUsageKey: (enumStruct: unknown, key: unknown) => string;\n EnumField: (content: unknown) => string;\n EnumFieldDescription: (content: unknown) => string;\n EnumFieldsWrapper: (content: unknown) => string;\n ObjectWrapper: (content: unknown) => string;\n MultilineComment: (content: unknown) => string;\n TypeWithGeneric: (content: unknown) => string;\n Tuple: (content: unknown) => string;\n};\n\ntype PrimitiveTypeStructValue =\n | string\n | ((\n schema: Record<string, unknown>,\n parser: import(\"../src/schema-parser/schema-parser.js\").SchemaParser,\n ) => string);\n\ntype PrimitiveTypeStruct = Record<\n \"integer\" | \"number\" | \"boolean\" | \"object\" | \"file\" | \"string\" | \"array\",\n | string\n | ({ $default: PrimitiveTypeStructValue } & Record<\n string,\n PrimitiveTypeStructValue\n >)\n>;\n\ninterface GenerateApiParamsFromPath\n extends Partial<GenerateApiConfiguration[\"config\"]> {\n /**\n * path to swagger schema\n */\n input: string;\n}\n\ninterface GenerateApiParamsFromUrl\n extends Partial<GenerateApiConfiguration[\"config\"]> {\n /**\n * url to swagger schema\n */\n url: string;\n}\n\ninterface GenerateApiParamsFromSpecLiteral\n extends Partial<GenerateApiConfiguration[\"config\"]> {\n /**\n * swagger schema JSON\n */\n spec: import(\"swagger-schema-official\").Spec;\n}\n\nexport type GenerateApiParams =\n | GenerateApiParamsFromPath\n | GenerateApiParamsFromUrl\n | GenerateApiParamsFromSpecLiteral;\n\ntype BuildRouteParam = {\n /** {bar} */\n $match: string;\n name: string;\n required: boolean;\n type: \"string\";\n description: string;\n schema: {\n type: string;\n };\n in: \"path\" | \"query\";\n};\n\ntype BuildRoutePath = {\n /** /foo/{bar}/baz */\n originalRoute: string;\n /** /foo/${bar}/baz */\n route: string;\n pathParams: BuildRouteParam[];\n queryParams: BuildRouteParam[];\n};\n\nexport interface Hooks {\n /** calls before parse\\process route path */\n onPreBuildRoutePath: (routePath: string) => string | undefined;\n /** calls after parse\\process route path */\n onBuildRoutePath: (data: BuildRoutePath) => BuildRoutePath | undefined;\n /** calls before insert path param name into string path interpolation */\n onInsertPathParam: (\n paramName: string,\n index: number,\n arr: BuildRouteParam[],\n resultRoute: string,\n ) => string | undefined;\n /** calls after parse schema component */\n onCreateComponent: (\n component: SchemaComponent,\n ) => SchemaComponent | undefined;\n /** calls before parse any kind of schema */\n onPreParseSchema: (\n originalSchema: unknown,\n typeName: string,\n schemaType: string,\n ) => undefined;\n /** calls after parse any kind of schema */\n onParseSchema: (\n originalSchema: unknown,\n parsedSchema: unknown,\n ) => unknown | undefined;\n /** calls after parse route (return type: customized route (ParsedRoute), nothing change (void), false (ignore this route)) */\n onCreateRoute: (routeData: ParsedRoute) => ParsedRoute | false | undefined;\n /** Start point of work this tool (after fetching schema) */\n onInit?: <C extends GenerateApiConfiguration[\"config\"]>(\n configuration: C,\n codeGenProcess: import(\"../src/code-gen-process.js\").CodeGenProcess,\n ) => C | undefined;\n /** customize configuration object before sending it to ETA templates */\n onPrepareConfig?: <C extends GenerateApiConfiguration>(\n currentConfiguration: C,\n ) => C | undefined;\n /** customize route name as you need */\n onCreateRouteName?: (\n routeNameInfo: RouteNameInfo,\n rawRouteInfo: RawRouteInfo,\n ) => RouteNameInfo | undefined;\n /** customize request params (path params, query params) */\n onCreateRequestParams?: (\n rawType: SchemaComponent[\"rawTypeData\"],\n ) => SchemaComponent[\"rawTypeData\"] | undefined;\n /** customize name of model type */\n onFormatTypeName?: (\n typeName: string,\n rawTypeName?: string,\n schemaType?: \"type-name\" | \"enum-key\",\n ) => string | undefined;\n /** customize name of route (operationId), you can do it with using onCreateRouteName too */\n onFormatRouteName?: (\n routeInfo: RawRouteInfo,\n templateRouteName: string,\n ) => string | undefined;\n onFormatExternalTypeName?: (\n typeName: string,\n refInfo: RefDetails,\n ) => string | undefined;\n onFixDuplicateExternalTypeName?: (\n typeName: string,\n refInfo: RefDetails,\n existedTypeNames: string[],\n ) => string | undefined;\n}\n\nexport type RouteNameRouteInfo = Record<string, unknown>;\n\nexport type RouteNameInfo = {\n usage: string;\n original: string;\n duplicate: boolean;\n};\n\nexport type SchemaTypePrimitiveContent = {\n $parsedSchema: boolean;\n schemaType: string;\n type: string;\n typeIdentifier: string;\n name?: unknown;\n description: string;\n content: string;\n};\n\nexport type SchemaTypeObjectContent = {\n $$raw: {\n type: string;\n required: boolean;\n $parsed: SchemaTypePrimitiveContent;\n };\n isRequired: boolean;\n field: string;\n}[];\n\nexport type SchemaTypeEnumContent = {\n key: string;\n type: string;\n value: string;\n};\n\nexport interface ParsedSchema<C> {\n $parsedSchema: boolean;\n schemaType: string;\n type: string;\n typeIdentifier: string;\n name: string;\n description?: string;\n allFieldsAreOptional?: boolean;\n content: C;\n isExtractedRequestParams?: boolean;\n isExtractedRequestBody?: boolean;\n isExtractedResponseBody?: boolean;\n isExtractedResponseError?: boolean;\n}\n\nexport interface PathArgInfo {\n name: string;\n optional: boolean;\n type: string;\n description?: string;\n}\n\nexport interface SchemaComponent {\n $ref: string;\n typeName: string;\n rawTypeData?: {\n type: string;\n required?: string[];\n properties?: Record<\n string,\n {\n name?: string;\n type: string;\n required: boolean;\n $parsed?: SchemaTypePrimitiveContent;\n }\n >;\n discriminator?: {\n propertyName?: string;\n };\n $parsed: ParsedSchema<\n | SchemaTypeObjectContent\n | SchemaTypeEnumContent\n | SchemaTypePrimitiveContent\n >;\n };\n componentName: \"schemas\" | \"paths\";\n typeData: ParsedSchema<\n SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent\n > | null;\n}\n\nexport enum RequestContentKind {\n JSON = \"JSON\",\n URL_ENCODED = \"URL_ENCODED\",\n FORM_DATA = \"FORM_DATA\",\n IMAGE = \"IMAGE\",\n OTHER = \"OTHER\",\n TEXT = \"TEXT\",\n}\n\nexport interface RequestResponseInfo {\n contentTypes: string[];\n contentKind: RequestContentKind;\n type: string;\n description: string;\n status: string | number;\n isSuccess: boolean;\n links?: RouteLinkInfo[];\n}\n\nexport interface RouteLinkInfo {\n status: string | number;\n name: string;\n operationId?: string;\n operationRef?: string;\n parameters?: Record<string, string>;\n}\n\nexport type RawRouteInfo = {\n operationId: string;\n method: string;\n route: string;\n moduleName: string;\n responsesTypes: RequestResponseInfo[];\n links?: RouteLinkInfo[];\n description?: string;\n tags?: string[];\n summary?: string;\n responses?: import(\"swagger-schema-official\").Spec[\"responses\"];\n produces?: string[];\n requestBody?: object;\n consumes?: string[];\n};\n\nexport interface ParsedRouteRequest {\n contentTypes?: string[];\n formData?: boolean;\n headers?: {\n name: string | null;\n optional: boolean | undefined;\n type: Record<string, any>;\n };\n isQueryBody?: boolean;\n method?: string;\n parameters?: Record<string, unknown>[];\n path?: string;\n pathParams?: Record<string, unknown>;\n payload?: { name: string | null; optional?: boolean; type: string };\n query?: Record<string, unknown>;\n requestParams?: Record<string, unknown> | null;\n security?: boolean;\n}\n\nexport interface ParsedRouteResponse {\n contentTypes?: string[];\n errorType?: string;\n fullTypes?: string;\n type?: string;\n}\n\nexport interface ParsedRoute {\n id: string;\n namespace: string;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n routeParams?: Record<string, any>;\n requestBodyInfo?: {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n paramName: any;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n contentTypes: any[];\n contentKind: string;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n schema: any;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n type: any;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n required: any;\n };\n responseBodyInfo?: {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n contentTypes: any[];\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n responses: any[];\n links?: RouteLinkInfo[];\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n success?: Record<string, any>;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n error?: Record<string, any>;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n full?: Record<string, any>;\n };\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n specificArgs?: Record<string, any>;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n queryObjectSchema?: Record<string, any>;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n pathObjectSchema?: Record<string, any>;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n headersObjectSchema?: Record<string, any>;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n responseBodySchema?: Record<string, any>;\n requestBodySchema?: Record<string, any>;\n specificArgNameResolver?: Record<string, any>;\n request: ParsedRouteRequest;\n response: ParsedRouteResponse;\n routeName: RouteNameInfo;\n raw: RawRouteInfo;\n}\n\nexport type ModelType = {\n typeIdentifier: string;\n name: string;\n rawContent: string;\n description: string;\n content: string;\n};\n\nexport enum SCHEMA_TYPES {\n ARRAY = \"array\",\n OBJECT = \"object\",\n ENUM = \"enum\",\n REF = \"$ref\",\n PRIMITIVE = \"primitive\",\n COMPLEX = \"complex\",\n COMPLEX_ONE_OF = \"oneOf\",\n COMPLEX_ANY_OF = \"anyOf\",\n COMPLEX_ALL_OF = \"allOf\",\n COMPLEX_NOT = \"not\",\n COMPLEX_UNKNOWN = \"__unknown\",\n}\n\ntype MAIN_SCHEMA_TYPES =\n | SCHEMA_TYPES.PRIMITIVE\n | SCHEMA_TYPES.OBJECT\n | SCHEMA_TYPES.ENUM;\n\nexport type ExtractingOptions = {\n requestBodySuffix: string[];\n responseBodySuffix: string[];\n responseErrorSuffix: string[];\n requestParamsSuffix: string[];\n enumSuffix: string[];\n discriminatorMappingSuffix: string[];\n discriminatorAbstractPrefix: string[];\n requestBodyNameResolver: (\n name: string,\n reservedNames: string,\n ) => string | undefined;\n responseBodyNameResolver: (\n name: string,\n reservedNames: string,\n ) => string | undefined;\n responseErrorNameResolver: (\n name: string,\n reservedNames: string,\n ) => string | undefined;\n requestParamsNameResolver: (\n name: string,\n reservedNames: string,\n ) => string | undefined;\n enumNameResolver: (name: string, reservedNames: string) => string | undefined;\n discriminatorMappingNameResolver: (\n name: string,\n reservedNames: string,\n ) => string | undefined;\n discriminatorAbstractResolver: (\n name: string,\n reservedNames: string,\n ) => string | undefined;\n};\n\nexport interface GenerateApiConfiguration {\n apiConfig: {\n /** base url from schema */\n baseUrl: string;\n /** document title */\n title: string;\n /** document version */\n version: string;\n /** description split into lines */\n description: string[];\n /** flag that description is present */\n hasDescription: boolean;\n };\n config: {\n /** path to swagger schema */\n input: string;\n /**\n * generate separated files for http client, data contracts, and routes\n * @default false\n */\n modular: boolean;\n /**\n * path to folder where the created api module will be placed.\n * may be set to `false` to skip writing content to disk; in this case\n * the `files` array on the return value will contain the generated contents.\n */\n output: string | false;\n /** url to swagger schema */\n url: string;\n /** swagger schema JSON */\n spec: unknown;\n /**\n * file name for the generated API module\n * @default 'Api.ts'\n */\n fileName: string;\n /**\n * path to folder containing custom templates\n * @default \"\"\n */\n templates: string;\n templatePaths: {\n /** `templates/base` */\n base: string;\n /** `templates/default` */\n default: string;\n /** `templates/modular` */\n modular: string;\n /** usage path if `--templates` option is not set */\n original: string;\n /** custom path to templates (`--templates`) */\n custom: string | null;\n };\n /** authorisation token for private swagger schema access */\n authorizationToken?: string;\n /** generate additional information about request responses and error typings */\n generateResponses: boolean;\n /**\n * use \"default\" response status code as success response.\n * some swagger schemas treat \"default\" as a successful response.\n */\n defaultResponseAsSuccess: boolean;\n /** generate type definitions for API routes */\n generateRouteTypes: boolean;\n /** generate an API client */\n generateClient: boolean;\n /** generate all \"enum\" types as union types (T1 | T2 | TN) */\n generateUnionEnums: boolean;\n /** parsed swagger schema */\n swaggerSchema: object;\n /** original swagger schema */\n originalSchema: object;\n /** map of schema component references */\n componentsMap: Record<string, SchemaComponent>;\n /** flag indicating the schema was converted from Swagger 2.0 */\n convertedFromSwagger2: boolean;\n /** determines which path index should be used for routes separation */\n moduleNameIndex: number;\n /** use the first tag for the module name */\n moduleNameFirstTag: boolean;\n /** extra templates */\n extraTemplates: { name: string; path: string }[];\n /** extract request params to data contract */\n extractRequestParams: boolean;\n /** unwrap the data item from the response */\n unwrapResponseData: boolean;\n /** sort data contracts in alphabetical order */\n sortTypes: boolean;\n /** sort routes in alphabetical order */\n sortRoutes: boolean;\n /** ability to send HttpClient instance to Api constructor */\n singleHttpClient: boolean;\n /** prefix string value for type names */\n typePrefix: string;\n /** suffix string value for type names */\n typeSuffix: string;\n /** prefix string value for enum keys */\n enumKeyPrefix: string;\n /** suffix string value for enum keys */\n enumKeySuffix: string;\n /** fix up small errors in the swagger source definition */\n patch: boolean;\n /** remove output directory before generating */\n cleanOutput: boolean;\n /** output debug messages */\n debug: boolean;\n /**\n * generate array types as Array<Type>\n * @default false\n */\n anotherArrayType: boolean;\n /** extract request body type to data contract */\n extractRequestBody: boolean;\n /** generated http client type */\n httpClientType: \"axios\" | \"fetch\";\n /** generate readonly properties */\n addReadonly: boolean;\n /** customise primitive type mappings */\n primitiveTypeConstructs?:\n | ((struct: PrimitiveTypeStruct) => PartialDeep<PrimitiveTypeStruct>)\n | PartialDeep<PrimitiveTypeStruct>;\n /** customise code generation constructs */\n codeGenConstructs?:\n | ((struct: CodeGenConstruct) => PartialDeep<CodeGenConstruct>)\n | PartialDeep<CodeGenConstruct>;\n /** extract response body type to data contract */\n extractResponseBody: boolean;\n /** extract response error type to data contract */\n extractResponseError: boolean;\n /** extract all enums from nested types/interfaces to `enum` construction */\n extractEnums: boolean;\n /** extract all enums from inline interface/type content to typescript enum construction */\n extractResponses: boolean;\n /**\n * prefix string value needed to fix invalid type names\n * @default \"Type\"\n */\n fixInvalidTypeNamePrefix: string;\n /**\n * prefix string value needed to fix invalid enum keys\n * @default \"Value\"\n */\n fixInvalidEnumKeyPrefix: string;\n /**\n * default type for empty response schema\n * @default \"void\"\n */\n defaultResponseType: string;\n /**\n * generate js api module with declaration file\n * @default false\n */\n toJS: boolean;\n /** disable throwing on a non-successful response */\n disableThrowOnError: boolean;\n /**\n * output only errors to console\n * @default false\n */\n silent: boolean;\n /** hooks for customising the generation process */\n hooks: Partial<Hooks>;\n /** use enum names as values */\n enumNamesAsValues: boolean;\n /** package version */\n version: string;\n /** ts compiler configuration object (for --to-js option) */\n compilerTsConfig: Record<string, unknown>;\n /** enum key resolver name */\n enumKeyResolverName: string;\n /** type name resolver name */\n typeNameResolverName: string;\n /** specific argument name resolver name */\n specificArgNameResolverName: string;\n /**\n * custom ts->* translator\n * do not use constructor args, just send class reference\n */\n customTranslator?: new () => Translator;\n /** internal constants */\n constants: typeof CONSTANTS;\n /** code generation constructs for TypeScript */\n Ts: CodeGenConstruct;\n /**\n * swagger schema type -> typescript type\n * https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times\n */\n primitiveTypes: PrimitiveTypeStruct;\n /** built-in template info */\n templateInfos: { name: string; fileName: string }[];\n /** supported template file extensions */\n templateExtensions: string[];\n /** range of HTTP status codes treated as success */\n successResponseStatusRange: [number, number];\n /** custom schema parsers */\n schemaParsers?: {\n complexOneOf?: MonoSchemaParser;\n complexAllOf?: MonoSchemaParser;\n complexAnyOf?: MonoSchemaParser;\n complexNot?: MonoSchemaParser;\n enum?: MonoSchemaParser;\n object?: MonoSchemaParser;\n complex?: MonoSchemaParser;\n primitive?: MonoSchemaParser;\n discriminator?: MonoSchemaParser;\n array?: MonoSchemaParser;\n };\n /** internal options for templates */\n internalTemplateOptions: {\n addUtilRequiredKeysType: boolean;\n };\n /** resolver for component type names */\n componentTypeNameResolver: ComponentTypeNameResolver;\n /** generated file names */\n fileNames: {\n dataContracts: string;\n routeTypes: string;\n httpClient: string;\n outOfModuleApi: string;\n };\n /** Record<templateName, templateContent> */\n templatesToRender: {\n api: string;\n dataContracts: string;\n httpClient: string;\n routeTypes: string;\n routeName: string;\n dataContractJsDoc: string;\n interfaceDataContract: string;\n typeDataContract: string;\n enumDataContract: string;\n objectFieldJsDoc: string;\n };\n /** map of duplicate route names */\n routeNameDuplicatesMap: Map<string, string>;\n /** name of the main exported class */\n apiClassName: string;\n /** configuration for fetching swagger schema requests */\n requestOptions?: Partial<RequestInit>;\n /** extra configuration for extracting type names operations */\n extractingOptions: Partial<ExtractingOptions>;\n /** update configuration object during generation */\n update: (update: Partial<GenerateApiConfiguration[\"config\"]>) => void;\n };\n modelTypes: ModelType[];\n hasFormDataRoutes: boolean;\n hasSecurityRoutes: boolean;\n hasQueryRoutes: boolean;\n generateResponses: boolean;\n routes: {\n outOfModule: ParsedRoute[];\n combined?: {\n moduleName: string;\n routes: ParsedRoute[];\n }[];\n };\n requestOptions?: Partial<RequestInit>;\n utils: {\n formatDescription: (description: string, inline?: boolean) => string;\n internalCase: (value: string) => string;\n /** @deprecated */\n classNameCase: (value: string) => string;\n pascalCase: (value: string) => string;\n getInlineParseContent: (\n rawTypeData: SchemaComponent[\"rawTypeData\"],\n typeName?: string,\n ) => string;\n getParseContent: (\n rawTypeData: SchemaComponent[\"rawTypeData\"],\n typeName?: string,\n ) => ModelType;\n getComponentByRef: (ref: string) => SchemaComponent;\n parseSchema: (\n rawSchema: string | SchemaComponent[\"rawTypeData\"],\n typeName?: string,\n formattersMap?: Record<MAIN_SCHEMA_TYPES, (content: ModelType) => string>,\n ) => ModelType;\n formatters: Record<\n MAIN_SCHEMA_TYPES,\n (content: string | object | string[] | object[]) => string\n >;\n inlineExtraFormatters: Record<\n Exclude<MAIN_SCHEMA_TYPES, SCHEMA_TYPES.PRIMITIVE>,\n (schema: ModelType) => string\n >;\n formatModelName: (name: string) => string;\n fmtToJSDocLine: (line: string, params?: { eol?: boolean }) => string;\n _: typeof import(\"es-toolkit\") & typeof import(\"es-toolkit/compat\");\n require: (path: string) => unknown;\n };\n}\n\ntype FileInfo = {\n /** @example myFilename */\n fileName: string;\n /** @example .d.ts */\n fileExtension: string;\n /** content of the file */\n fileContent: string;\n};\n\nexport interface GenerateApiOutput {\n configuration: GenerateApiConfiguration;\n files: FileInfo[];\n createFile: (params: {\n path: string;\n fileName: string;\n content: string;\n withPrefix: boolean;\n }) => void;\n renderTemplate: (\n templateContent: string,\n data: Record<string, unknown>,\n etaOptions?: Partial<import(\"eta\").EtaConfig>,\n ) => Promise<string> | string;\n getTemplate: (params: {\n fileName?: string;\n name?: string;\n path?: string;\n }) => string;\n formatTSContent: (content: string) => Promise<string>;\n}\n\nexport declare function generateApi(\n params: GenerateApiParams,\n): Promise<GenerateApiOutput>;\n\nexport interface GenerateTemplatesParams {\n cleanOutput?: boolean;\n output?: string;\n httpClientType?: HttpClientType;\n modular?: boolean;\n rewrite?: boolean;\n silent?: boolean;\n debug?: boolean;\n}\n\nexport interface GenerateTemplatesOutput\n extends Pick<GenerateApiOutput, \"files\" | \"createFile\"> {}\n\nexport declare function generateTemplates(\n params: GenerateTemplatesParams,\n): Promise<GenerateTemplatesOutput>;\n","import type {\n GenerateTemplatesParams,\n HttpClientType,\n} from \"../../../types/index.js\";\nimport { HTTP_CLIENT, PROJECT_VERSION } from \"../../constants.js\";\nimport { objectAssign } from \"../../util/object-assign.js\";\n\nexport class TemplatesGenConfig {\n cleanOutput = false;\n debug = false;\n httpClientType: HttpClientType = HTTP_CLIENT.FETCH;\n modular = false;\n output = undefined;\n rewrite = false;\n silent = false;\n version = PROJECT_VERSION;\n\n constructor(config: GenerateTemplatesParams) {\n this.update(config);\n }\n\n update = (update: Partial<GenerateTemplatesParams>) => {\n objectAssign(this, update);\n };\n}\n","import path from \"node:path\";\nimport url from \"node:url\";\nimport { consola } from \"consola\";\nimport type {\n GenerateTemplatesOutput,\n GenerateTemplatesParams,\n} from \"../../../types/index.js\";\nimport { FileSystem } from \"../../util/file-system.js\";\nimport { TemplatesGenConfig } from \"./configuration.js\";\n\nconst __dirname = path.dirname(url.fileURLToPath(import.meta.url));\n\nexport class TemplatesGenProcess {\n config: TemplatesGenConfig;\n fileSystem: FileSystem;\n\n rootDir = path.resolve(__dirname, \"..\");\n\n paths = {\n baseTemplates: \"templates/base\",\n httpClientTemplates: \"templates/base/http-clients\",\n moduleApiTemplates: \"templates/modular\",\n defaultApiTemplates: \"templates/default\",\n };\n\n importTemplatePrefixes = [\"@base\", \"@modular\", \"@default\"];\n\n constructor(config: GenerateTemplatesParams) {\n this.config = new TemplatesGenConfig(config);\n this.fileSystem = new FileSystem();\n }\n\n async start(): Promise<GenerateTemplatesOutput> {\n consola.info('start generating source templates \".ejs\" for code generator');\n\n const templates = this.getTemplates();\n\n if (this.config.output) {\n consola.info(\"preparing output directory for source templates\");\n const outputPath = path.resolve(process.cwd(), this.config.output);\n\n if (this.fileSystem.pathIsExist(outputPath)) {\n if (this.config.cleanOutput) {\n this.fileSystem.cleanDir(outputPath);\n }\n } else {\n this.fileSystem.createDir(outputPath);\n }\n\n for (const template of templates) {\n const templateName = this.fileSystem.cropExtension(template.name);\n const templateEjsPath = path.resolve(outputPath, `${templateName}.ejs`);\n const templateEtaPath = path.resolve(outputPath, `${templateName}.eta`);\n const templateEjsPathExist =\n this.fileSystem.pathIsExist(templateEjsPath);\n const templateEtaPathExist =\n this.fileSystem.pathIsExist(templateEtaPath);\n\n const templateNotExist = !templateEjsPathExist && !templateEtaPathExist;\n\n if (templateNotExist) {\n this.fileSystem.createFile({\n path: outputPath,\n fileName: template.name,\n content: template.content,\n withPrefix: false,\n });\n } else if (this.config.rewrite) {\n if (templateEjsPathExist) {\n this.fileSystem.createFile({\n path: outputPath,\n fileName: `${templateName}.ejs`,\n content: template.content,\n withPrefix: false,\n });\n } else if (templateEtaPathExist) {\n this.fileSystem.createFile({\n path: outputPath,\n fileName: `${templateName}.eta`,\n content: template.content,\n withPrefix: false,\n });\n }\n }\n }\n\n consola.success(\n `source templates has been successfully created in \"${outputPath}\"`,\n );\n }\n\n return {\n files: templates,\n configuration: this.config,\n createFile: this.fileSystem.createFile,\n };\n }\n\n getTemplates = () => {\n const outputFiles = [];\n const baseTemplates = this.getTemplateNamesFromDir(\n this.paths.baseTemplates,\n );\n const httpClientTemplates = this.getTemplateNamesFromDir(\n this.paths.httpClientTemplates,\n );\n const apiTemplatesPath = this.config.modular\n ? this.paths.moduleApiTemplates\n : this.paths.defaultApiTemplates;\n const apiTemplates = this.getTemplateNamesFromDir(apiTemplatesPath);\n\n const usingHttpClientTemplate = httpClientTemplates.find((template) =>\n template.startsWith(`${this.config.httpClientType}-`),\n );\n\n let httpClientTemplateContent = \"\";\n\n if (usingHttpClientTemplate) {\n httpClientTemplateContent = this.fixTemplateContent(\n this.getTemplateContent(\n `${this.paths.httpClientTemplates}/${usingHttpClientTemplate}`,\n ),\n );\n }\n\n for (const fileName of baseTemplates) {\n const templateContent =\n (fileName === \"http-client.ejs\" && httpClientTemplateContent) ||\n this.fixTemplateContent(\n this.getTemplateContent(`${this.paths.baseTemplates}/${fileName}`),\n );\n\n outputFiles.push({\n name: fileName,\n content: templateContent,\n });\n }\n\n for (const fileName of apiTemplates) {\n outputFiles.push({\n name: fileName,\n content: this.fixTemplateContent(\n this.getTemplateContent(`${apiTemplatesPath}/${fileName}`),\n ),\n });\n }\n\n return outputFiles;\n };\n\n fixTemplateContent = (content) => {\n // includeFile(\"@base/\n const importsRegExp1 = new RegExp(\n `includeFile\\\\(\"(${this.importTemplatePrefixes\n .map((v) => `(${v})`)\n .join(\"|\")})/`,\n \"g\",\n );\n // includeFile(`@base/\n const importsRegExp2 = new RegExp(\n `includeFile\\\\(\\`(${this.importTemplatePrefixes\n .map((v) => `(${v})`)\n .join(\"|\")})/`,\n \"g\",\n );\n // includeFile('@base/\n const importsRegExp3 = new RegExp(\n `includeFile\\\\('(${this.importTemplatePrefixes\n .map((v) => `(${v})`)\n .join(\"|\")})/`,\n \"g\",\n );\n\n return content\n .replace(importsRegExp1, 'includeFile(\"./')\n .replace(importsRegExp2, \"includeFile(`./\")\n .replace(importsRegExp3, \"includeFile('./\");\n };\n\n getTemplateNamesFromDir = (dir) => {\n return this.fileSystem\n .readDir(path.resolve(this.rootDir, dir))\n .filter((file) => file.endsWith(\".ejs\"));\n };\n\n getTemplateContent = (pathToFile) => {\n return this.fileSystem.getFileContent(\n path.resolve(this.rootDir, pathToFile),\n );\n };\n}\n","import { consola } from \"consola\";\nimport type { GenerateTemplatesParams } from \"../../../types/index.js\";\nimport { TemplatesGenProcess } from \"./templates-gen-process.js\";\n\nexport async function generateTemplates(config: GenerateTemplatesParams) {\n if (config.debug) consola.level = Number.MAX_SAFE_INTEGER;\n if (config.silent) consola.level = 0;\n const codeGenProcess = new TemplatesGenProcess(config);\n return await codeGenProcess.start();\n}\n","import { consola } from \"consola\";\nimport type { GenerateApiConfiguration } from \"../types/index.js\";\nimport { CodeGenProcess } from \"./code-gen-process.js\";\n\nexport * from \"../types/index.js\";\n\nexport async function generateApi(\n config: Partial<GenerateApiConfiguration[\"config\"]>,\n) {\n if (config.debug) consola.level = Number.MAX_SAFE_INTEGER;\n if (config.silent) consola.level = 0;\n const codeGenProcess = new CodeGenProcess(config);\n return await codeGenProcess.start();\n}\n\nexport { generateTemplates } from \"./commands/generate-templates/index.js\";\nexport * as constants from \"./constants.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMA,IAAa,gBAAb,MAA2B;CACzB;CAEA,YAAY,QAAuB;AACjC,OAAK,SAAS;;CAGhB,uBAAuB,YAAoB;EACzC,MAAM,eAAe;EAErB,MAAM,OAAO,IAAI,sBAAsB,cAAc,QAAQ;EAG7D,MAAM,kBAFkB,WAAW,sBAAsB,KAAK,CAEtB,gBACtC;GAAE,MAAM;GAAQ,UAAU;GAAc,EACxC,EAAE,kBAAkB,WAAW,IAAI,SAAS,EAC5C,KAAA,EACD,CAAC;AAEF,MAAI,iBAAiB,YAAY,OAC/B,QAAO,gBAAgB,YAAY,aAChC,SAAS,EAAE,MAAM,cAChB,GAAG,QAAQ,MAAM,GAAG,KAAK,MAAM,GAAG,UAAU,QAAQ,MAClD,KAAK,QAAQ,KAAK,OACnB,IACH,QACD;AAGH,SAAO;;CAGT,SAAS,OAAO,YAAoB;EAClC,MAAM,QAAQ,MAAM,MAAM,OAAO,EAAE,cAAc,aAAa,MAAM,CAAC;EACrE,MAAM,eAAe,MAAM,aAAa;AACxC,QAAM,mBAAmB,aAAa,YAAY;GAChD,OAAO,EAAE,SAAS,OAAO,kBAAkB;GAC3C,WAAW,EAAE,aAAa,SAAS;GACpC,CAAC;AAIF,SAHkB,MAAM,cAAc,aAAa,YAAY,SAAS,EACtE,UAAUA,OAAK,OAAO;GAAE,MAAM,OAAO,QAAQ;GAAE,KAAK;GAAM,CAAC,EAC5D,CAAC,CACe;;CAGnB,aAAa,OACX,MACA,EAAE,sBAAsB,MAAM,SAAS,SAAS,EAAE,KAC/C;AACH,MAAI,oBACF,QAAO,KAAK,oBA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