swagger-typescript-api 13.2.15 → 13.2.16

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"src-CgtuxwSo.cjs","names":["content","Biome","Distribution","path","name","usageName: string | null","packageJson","SCHEMA_TYPES","CONSTANTS.PROJECT_VERSION","description","CONSTANTS","componentSchema: SchemaComponent","SCHEMA_TYPES","description","type","SCHEMA_TYPES","description","SCHEMA_TYPES","SCHEMA_TYPES","enumNames","SCHEMA_TYPES","formatted: string | undefined","SCHEMA_TYPES","name","interfaceKeysContent: any","type","recordKeysContent: any","recordValuesContent: any","SCHEMA_TYPES","description","type","type","type","SCHEMA_TYPES","name","type","SCHEMA_TYPES","resultType: string","pathParams","fixedRoute","schema","name","name","path","requestOptions: Partial<RequestInit>","url","url","YAML","require","module","eta","Eta","__dirname","path","url","name","configuration","name","fs","path","__dirname","url","files","name","modularApiFileInfos: TranslatorIO[]","__dirname","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/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/util/internal-case.ts","../src/util/pascal-case.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/schema-walker.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/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 lodash from \"lodash\";\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 = lodash.uniq(lodash.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 = lodash.uniq(lodash.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 getRandomFloat = (min = 0, max = 1) => {\n return Math.random() * (max - min) + min;\n};\n\nexport const getRandomInt = (min = 0, max = 1) => {\n if (min === max) return min;\n\n return Math.round(getRandomFloat(min, max));\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","{\n \"name\": \"swagger-typescript-api\",\n \"version\": \"13.2.15\",\n \"description\": \"Generate the API client for Fetch or Axios from an OpenAPI Specification\",\n \"homepage\": \"https://github.com/acacode/swagger-typescript-api\",\n \"bugs\": \"https://github.com/acacode/swagger-typescript-api/issues\",\n \"repository\": \"github:acacode/swagger-typescript-api\",\n \"license\": \"MIT\",\n \"author\": \"Sergey Volkov <js2me@outlook.com>\",\n \"maintainers\": [\n \"Sora Morimoto <sora@morimoto.io>\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./cli\": {\n \"import\": \"./dist/cli.js\",\n \"require\": \"./dist/cli.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\n \"bin\": {\n \"sta\": \"./dist/cli.js\",\n \"swagger-typescript-api\": \"./dist/cli.js\"\n },\n \"files\": [\n \"dist\",\n \"templates\"\n ],\n \"scripts\": {\n \"build\": \"tsdown\",\n \"cli:help\": \"node index.js -h\",\n \"cli:json\": \"node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts\",\n \"cli:yaml\": \"node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts\",\n \"format\": \"biome format --write .\",\n \"format:check\": \"biome format .\",\n \"lint\": \"biome check\",\n \"prepack\": \"tsdown\",\n \"test\": \"vitest run\",\n \"typedoc\": \"typedoc\"\n },\n \"dependencies\": {\n \"@biomejs/js-api\": \"3.0.0\",\n \"@biomejs/wasm-nodejs\": \"2.2.5\",\n \"@types/lodash\": \"^4.17.20\",\n \"@types/swagger-schema-official\": \"^2.0.25\",\n \"c12\": \"^3.3.0\",\n \"citty\": \"^0.1.6\",\n \"consola\": \"^3.4.2\",\n \"eta\": \"^4.0.1\",\n \"lodash\": \"^4.17.21\",\n \"nanoid\": \"^5.1.6\",\n \"openapi-types\": \"^12.1.3\",\n \"swagger-schema-official\": \"2.0.0-bab6bed\",\n \"swagger2openapi\": \"^7.0.8\",\n \"typescript\": \"~5.9.3\",\n \"yaml\": \"^2.8.1\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"2.2.5\",\n \"@changesets/changelog-github\": \"0.5.1\",\n \"@changesets/cli\": \"2.29.7\",\n \"@tsconfig/node20\": \"20.1.6\",\n \"@tsconfig/strictest\": \"2.0.6\",\n \"@types/node\": \"24.7.0\",\n \"@types/swagger2openapi\": \"7.0.4\",\n \"axios\": \"1.12.2\",\n \"tsdown\": \"0.15.6\",\n \"typedoc\": \"0.28.13\",\n \"vitest\": \"3.2.4\"\n },\n \"packageManager\": \"yarn@4.10.3\",\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true,\n \"registry\": \"https://registry.npmjs.org\"\n },\n \"typedocOptions\": {\n \"entryPoints\": [\n \"src/index.ts\"\n ],\n \"skipErrorChecking\": true\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 lodash from \"lodash\";\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;\n const undefinedKeys = lodash\n .map(update, (value, key) => value === undefined && key)\n .filter((key) => typeof key === \"string\");\n Object.assign(target, lodash.merge(target, update));\n for (const key of undefinedKeys) {\n target[key] = undefined;\n }\n};\n","import lodash from \"lodash\";\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 { 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 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 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 = 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 lodash.join(lodash.uniq(contents), ` ${this.Ts.Keyword.Union} `),\n /**\n * ($A1)\n */\n ExpressionGroup: (content: unknown) => (content ? `(${content})` : \"\"),\n /**\n * $A1 & $A2\n */\n IntersectionType: (contents: unknown[]) =>\n lodash.join(lodash.uniq(contents), ` ${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 lodash\n .compact([readonly && \"readonly \", key, optional && \"?\", \": \", 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 lodash\n .map(contents, ({ key, value, description }) => {\n return [\n this.Ts.EnumFieldDescription(description),\n ` ${this.Ts.EnumField(key, value)}`,\n ]\n .filter(Boolean)\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 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: lodash.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 = (update: Partial<GenerateApiConfiguration[\"config\"]>) => {\n objectAssign(this, update);\n if (this.enumNamesAsValues) {\n this.extractEnums = true;\n }\n };\n}\n","import type { SchemaComponent } from \"../types/index.js\";\nimport type { CodeGenConfig } from \"./configuration.js\";\n\nexport class SchemaComponentsMap {\n _data: SchemaComponent[] = [];\n config: CodeGenConfig;\n\n constructor(config: CodeGenConfig) {\n this.config = config;\n }\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 createComponent(\n $ref: string,\n rawTypeData: SchemaComponent[\"rawTypeData\"],\n ): SchemaComponent {\n const parsed = this.parseRef($ref);\n const typeName = parsed[parsed.length - 1]!;\n const componentName = parsed[\n parsed.length - 2\n ] as SchemaComponent[\"componentName\"];\n const componentSchema: SchemaComponent = {\n $ref,\n typeName,\n rawTypeData,\n componentName,\n /** result from schema parser */\n typeData: null,\n };\n\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 this._data.push(usageComponent);\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 return this._data.find((c) => c.$ref === $ref) || 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 lodash from \"lodash\";\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 return {\n ...parsedSchema,\n $content: parsedSchema.content,\n content: this.config.Ts.EnumFieldsWrapper(parsedSchema.content),\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 lodash.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 lodash.get(parsedSchema, [\"schemaType\"]) ||\n lodash.get(parsedSchema, [\"$parsed\", \"schemaType\"]);\n const formatterFn = lodash.get(this, [formatType, schemaType]);\n return formatterFn?.(parsedSchema) || parsedSchema;\n };\n\n formatDescription = (description, inline) => {\n if (!description) return \"\";\n\n const hasMultipleLines = description.includes(\"\\n\");\n\n if (!hasMultipleLines) return description;\n\n if (inline) {\n return (\n lodash\n // @ts-expect-error TS(2339) FIXME: Property '_' does not exist on type 'LoDashStatic'... Remove this comment to see the full error message\n ._(description)\n .split(/\\n/g)\n .map((part) => part.trim())\n .compact()\n .join(\" \")\n .valueOf()\n );\n }\n\n return description.replace(/\\n$/g, \"\");\n };\n\n formatObjectContent = (content) => {\n const fields = [];\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 class MonoSchemaParser {\n schema;\n typeName;\n schemaPath;\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,\n typeName = null,\n schemaPath = [],\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 lodash from \"lodash\";\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 = lodash.omit(\n lodash.clone(this.schema),\n lodash.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 lodash.compact(\n lodash.map(this.schema[complexType], \"description\"),\n )[0] ||\n \"\",\n ),\n content:\n this.config.Ts.IntersectionType(\n lodash.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 lodash from \"lodash\";\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 [\n abstractSchemaStruct?.content,\n discriminatorSchemaStruct?.content,\n ].filter(Boolean),\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 = lodash.entries(discriminator.mapping);\n const ableToCreateMappingType =\n !skipMappingType &&\n !!(abstractSchemaStruct?.typeName && mappingEntries.length);\n const mappingContents = [];\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: 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 let mappingPropertySchemaEnumKeysMap = {};\n let mappingPropertySchema = lodash.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 mappingPropertySchemaEnumKeysMap = lodash.reduce(\n parsedEnum.enum,\n (acc, key, index) => {\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 acc[key] = literalValue;\n }\n } else if (parsedEnum.typeName && enumContent?.key) {\n acc[key] = ts.EnumUsageKey(parsedEnum.typeName, enumContent.key);\n }\n return acc;\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 = lodash.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 = lodash.keys(\n this.schemaParser._complexSchemaParsers,\n );\n const schema = lodash.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 = !lodash.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 lodash from \"lodash\";\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) {\n // @ts-expect-error TS(2556) FIXME: A spread argument must either have a tuple type or... Remove this comment to see the full error message\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) && lodash.size(enumNames)) {\n content = enumNames.map((enumName, index) => {\n const enumValue = lodash.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 // @ts-expect-error TS(2345) FIXME: Argument of type '{ value: any; }' is not assignab... Remove this comment to see the full error message\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 }) => {\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 lodash from \"lodash\";\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 = lodash.map(properties, (property, name) => {\n const required = this.schemaUtils.isPropertyRequired(\n name,\n property,\n schema,\n );\n const rawTypeData = lodash.get(\n this.schemaUtils.getSchemaRefType(property),\n \"rawTypeData\",\n {},\n );\n const nullable = !!(rawTypeData.nullable || property.nullable);\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.readOnly;\n\n return {\n ...property,\n $$raw: property,\n title: property.title,\n description:\n property.description ||\n lodash.compact(\n lodash.map(\n property[this.schemaUtils.getComplexType(property)],\n \"description\",\n ),\n )[0] ||\n rawTypeData.description ||\n lodash.compact(\n lodash.map(\n rawTypeData[this.schemaUtils.getComplexType(rawTypeData)],\n \"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: any;\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: any;\n let recordValuesContent: any;\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 contentType = this.config.Ts.RecordType(\n recordKeysContent,\n recordValuesContent,\n );\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((type) => ({ type })),\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 lodash from \"lodash\";\nimport type { CodeGenConfig } from \"../configuration.js\";\nimport { SCHEMA_TYPES } from \"../constants.js\";\nimport type { SchemaComponentsMap } from \"../schema-components-map.js\";\nimport type { SchemaWalker } from \"../schema-walker.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 schemaWalker: SchemaWalker;\n\n typeName;\n schema;\n schemaPath = [];\n\n // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message\n constructor(schemaParserFabric, { typeName, schema, schemaPath } = {}) {\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.schemaWalker = schemaParserFabric.schemaWalker;\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 lodash.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 firstResponse = lodash.first(lodash.values(content));\n const firstSchema = lodash.get(firstResponse, \"schema\");\n\n if (!firstSchema) return;\n\n return {\n ...extras,\n ...lodash.omit(firstResponse, \"schema\"),\n ...firstSchema,\n };\n };\n}\n","import lodash from \"lodash\";\n\nexport function internalCase(value: string) {\n return lodash.camelCase(lodash.lowerCase(value));\n}\n","import lodash from \"lodash\";\n\nexport function pascalCase(value: string) {\n return lodash.upperFirst(lodash.camelCase(value));\n}\n","import lodash from \"lodash\";\nimport type { CodeGenConfig } from \"../configuration.js\";\nimport { SCHEMA_TYPES } from \"../constants.js\";\nimport type { SchemaComponentsMap } from \"../schema-components-map.js\";\nimport type { SchemaWalker } from \"../schema-walker.js\";\nimport type { TypeNameFormatter } from \"../type-name-formatter.js\";\nimport { internalCase } from \"../util/internal-case.js\";\nimport { pascalCase } from \"../util/pascal-case.js\";\n\nexport class SchemaUtils {\n config: CodeGenConfig;\n schemaComponentsMap: SchemaComponentsMap;\n typeNameFormatter: TypeNameFormatter;\n schemaWalker: SchemaWalker;\n\n constructor({\n config,\n schemaComponentsMap,\n typeNameFormatter,\n schemaWalker,\n }) {\n this.config = config;\n this.schemaComponentsMap = schemaComponentsMap;\n this.typeNameFormatter = typeNameFormatter;\n this.schemaWalker = schemaWalker;\n }\n\n getRequiredProperties = (schema) => {\n return lodash.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 !!lodash.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 internalCase(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 internalCase(enumFieldType);\n }\n if (lodash.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 = lodash.uniq([\n ...this.getRequiredProperties(parentSchema),\n ...this.getRequiredProperties(childSchema),\n ]);\n\n const refData = this.getSchemaRefType(childSchema);\n\n if (refData) {\n const refObjectProperties = lodash.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 = lodash.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: lodash.uniq([\n ...this.getRequiredProperties(childSchema),\n ...existedRequiredKeys,\n ]),\n ...childSchema,\n };\n }\n\n return childSchema;\n };\n\n filterSchemaContents = (contents, filterFn) => {\n return lodash.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 !lodash.isEmpty(schema.enum) ||\n !lodash.isEmpty(this.getEnumNames(schema))\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 (!lodash.isEmpty(schema.properties)) {\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 const typeAlias =\n lodash.get(this.config.primitiveTypes, [\n primitiveType,\n schema.format,\n ]) ||\n lodash.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 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 = lodash.uniq(lodash.compact(schemaPath));\n\n if (!schemaPath || !schemaPath[0]) return null;\n\n return pascalCase(\n lodash.camelCase(\n lodash\n .uniq([schemaPath[0], schemaPath[schemaPath.length - 1]])\n .join(\"_\"),\n ),\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 { SchemaWalker } from \"../schema-walker.js\";\nimport type { TemplatesWorker } from \"../templates-worker.js\";\nimport type { TypeNameFormatter } from \"../type-name-formatter.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 schemaWalker: SchemaWalker;\n\n constructor(\n config: CodeGenConfig,\n templatesWorker: TemplatesWorker,\n schemaComponentsMap: SchemaComponentsMap,\n typeNameFormatter: TypeNameFormatter,\n schemaWalker: SchemaWalker,\n ) {\n this.config = config;\n this.schemaComponentsMap = schemaComponentsMap;\n this.typeNameFormatter = typeNameFormatter;\n this.templatesWorker = templatesWorker;\n this.schemaWalker = schemaWalker;\n this.schemaUtils = new SchemaUtils(this);\n this.schemaFormatters = new SchemaFormatters(this);\n }\n\n createSchemaParser = ({ schema, typeName, schemaPath }) => {\n return new SchemaParser(this, { schema, typeName, schemaPath });\n };\n\n createSchema = ({\n content,\n linkedSchema = {},\n linkedComponent,\n schemaPath,\n ...otherSchemaProps\n }) => {\n // @ts-expect-error TS(2345) FIXME: Argument of type '{ schema: any; schemaPath: any; ... Remove this comment to see the full error message\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 }): 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: string,\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: string,\n typeName: string | null,\n schemaPath: string[],\n ): Record<string, any> => {\n const parser = this.createSchemaParser({ schema, typeName, schemaPath });\n return parser.getInlineParseContent();\n };\n\n getParseContent = (\n schema: string,\n typeName: string | null,\n schemaPath: string[],\n ): Record<string, any> => {\n const parser = this.createSchemaParser({ schema, typeName, schemaPath });\n return parser.getParseContent();\n };\n}\n","import * as nanoid from \"nanoid\";\n\nconst ALPHABET = \"abcdefghijklmnopqrstuvwxyz0123456789\";\n\nexport const generateId = nanoid.customAlphabet(ALPHABET, 12);\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 lodash from \"lodash\";\nimport type {\n GenerateApiConfiguration,\n ParsedRoute,\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 { 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 config: CodeGenConfig;\n schemaParserFabric: SchemaParserFabric;\n schemaUtils: SchemaUtils;\n typeNameFormatter: TypeNameFormatter;\n schemaComponentsMap: SchemaComponentsMap;\n templatesWorker: TemplatesWorker;\n\n FORM_DATA_TYPES: string[] = [];\n\n routes: ParsedRoute[] = [];\n hasSecurityRoutes = false;\n hasQueryRoutes = false;\n hasFormDataRoutes = false;\n\n constructor(\n config: CodeGenConfig,\n schemaParserFabric: SchemaParserFabric,\n schemaComponentsMap: SchemaComponentsMap,\n templatesWorker: TemplatesWorker,\n typeNameFormatter: TypeNameFormatter,\n ) {\n this.config = config;\n this.schemaParserFabric = schemaParserFabric;\n this.schemaUtils = this.schemaParserFabric.schemaUtils;\n this.typeNameFormatter = typeNameFormatter;\n this.schemaComponentsMap = schemaComponentsMap;\n this.templatesWorker = templatesWorker;\n\n this.FORM_DATA_TYPES = lodash.uniq([\n this.schemaUtils.getSchemaType({ type: \"string\", format: \"file\" }),\n this.schemaUtils.getSchemaType({ type: \"string\", format: \"binary\" }),\n ]);\n }\n\n createRequestsMap = (routeInfoByMethodsMap) => {\n const parameters = lodash.get(routeInfoByMethodsMap, \"parameters\");\n\n return lodash.reduce(\n routeInfoByMethodsMap,\n (acc, requestInfo, method) => {\n if (\n method.startsWith(\"x-\") ||\n [\"parameters\", \"$ref\"].includes(method)\n ) {\n return acc;\n }\n\n acc[method] = {\n ...requestInfo,\n parameters: lodash.compact(\n lodash.concat(parameters, requestInfo.parameters),\n ),\n };\n\n return acc;\n },\n {},\n );\n };\n\n parseRouteName = (originalRouteName) => {\n const routeName =\n this.config.hooks.onPreBuildRoutePath(originalRouteName) ||\n originalRouteName;\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 = lodash.reduce(\n pathParamMatches,\n (pathParams, match) => {\n const paramName = match.replace(/\\{|\\}|:/g, \"\");\n\n if (!paramName) return pathParams;\n\n if (paramName.includes(\"-\")) {\n consola.warn(\"wrong path param name\", paramName);\n }\n\n pathParams.push({\n $match: match,\n name: lodash.camelCase(paramName),\n required: true,\n type: \"string\",\n description: \"\",\n schema: {\n type: \"string\",\n },\n in: \"path\",\n });\n\n return pathParams;\n },\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 = [];\n\n if (queryParamMatches?.length) {\n for (const match of queryParamMatches) {\n fixedRoute = fixedRoute.replace(match, \"\");\n }\n\n const paramNames = lodash.uniq(\n queryParamMatches\n .join(\",\")\n .replace(/(\\{\\?)|(\\})|\\s/g, \"\")\n .split(\",\"),\n );\n\n for (const paramName of paramNames) {\n // @ts-expect-error TS(2339) FIXME: Property 'includes' does not exist on type 'unknow... Remove this comment to see the full error message\n if (paramName.includes(\"-\")) {\n consola.warn(\"wrong query param name\", paramName);\n }\n\n queryParams.push({\n $match: paramName,\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 name: lodash.camelCase(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: originalRouteName || \"\",\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 lodash.each(parameters, (parameter) => {\n const refTypeInfo =\n this.schemaParserFabric.schemaUtils.getSchemaRefType(parameter);\n\n let routeParam = null;\n\n if (refTypeInfo?.rawTypeData.in && refTypeInfo.rawTypeData) {\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) return;\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) return;\n\n routeParam.name = lodash.camelCase(routeParam.name);\n }\n\n if (routeParam) {\n routeParams[routeParam.in].push(routeParam);\n }\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 lodash.uniq(\n lodash.compact([\n ...(extraContentTypes || []),\n ...lodash.flatten(\n lodash.map(\n requestInfo,\n (requestInfoData) =>\n requestInfoData && lodash.keys(requestInfoData.content),\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 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 = lodash.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 lodash.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 }) =>\n lodash.reduce(\n requestInfos,\n (acc, requestInfo, status) => {\n // @ts-expect-error TS(2554) FIXME: Expected 2 arguments, but got 1.\n const contentTypes = this.getContentTypes([requestInfo]);\n\n return [\n ...acc,\n {\n ...(requestInfo || {}),\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:\n this.schemaParserFabric.schemaFormatters.formatDescription(\n requestInfo.description || \"\",\n true,\n ),\n status: Number.isNaN(+status) ? status : +status,\n isSuccess: this.isSuccessStatus(status),\n },\n ];\n },\n [],\n );\n\n getResponseBodyInfo = (routeInfo, parsedSchemas) => {\n const { produces, operationId, responses } = routeInfo;\n\n const contentTypes = this.getContentTypes(responses, [\n ...(produces || []),\n routeInfo[\"x-accepts\"],\n ]);\n\n const responseInfos = this.getRequestInfoTypes({\n requestInfos: responses,\n parsedSchemas,\n operationId,\n defaultType: this.config.defaultResponseType,\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 return {\n contentTypes,\n responses: responseInfos,\n success: {\n schema: successResponse,\n type: successResponse?.type || this.config.Ts.Keyword.Any,\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 = lodash.reduce(\n lodash.get(queryObjectSchema, \"properties\", {}),\n (acc, property, name) => {\n if (name && typeof property === \"object\") {\n acc[name] = {\n ...property,\n in: \"query\",\n };\n }\n\n return acc;\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\n if (successResponse.schema && !successResponse.schema.$ref) {\n const contentKind = successResponse.schema.contentKind;\n const schema = this.getSchemaFromRequestType(successResponse.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 lodash.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 = responseBodyInfo.error.schemas\n .map(this.getSchemaFromRequestType)\n .filter(Boolean);\n\n if (!errorSchemas.length) return;\n\n const schema = this.schemaParserFabric.parseSchema(\n {\n oneOf: errorSchemas,\n title: errorSchemas\n .map((schema) => schema.title)\n .filter(Boolean)\n .join(\" \"),\n description: errorSchemas\n .map((schema) => schema.description)\n .filter(Boolean)\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 usageSchema,\n parsedSchemas,\n ): ParsedRoute => {\n const { security: globalSecurity } = 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 ? lodash.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 lodash.camelCase(lodash.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(routeInfo, parsedSchemas);\n\n const rawRouteInfo = {\n ...otherInfo,\n pathArgs,\n operationId,\n method,\n route: rawRouteName,\n moduleName,\n responsesTypes: responseBodyInfo.responses,\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 = ({ usageSchema, parsedSchemas }) => {\n this.config.routeNameDuplicatesMap.clear();\n\n const pathsEntries = lodash.entries(usageSchema.paths);\n\n for (const [rawRouteName, routeInfoByMethodsMap] of pathsEntries) {\n const routeInfosMap = this.createRequestsMap(routeInfoByMethodsMap);\n\n for (const [method, routeInfo] of Object.entries(routeInfosMap)) {\n const parsedRouteInfo = this.parseRouteInfo(\n rawRouteName,\n routeInfo,\n method,\n usageSchema,\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 = lodash.reduce(\n groupedRoutes,\n (acc, routesGroup, moduleName) => {\n if (moduleName === \"$outOfModule\") {\n acc.outOfModule = routesGroup;\n } else {\n if (!acc.combined) {\n acc.combined = [];\n }\n acc.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 return acc;\n },\n {} as GenerateApiConfiguration[\"routes\"],\n );\n\n if (this.config.sortRoutes) {\n if (routeGroups.outOfModule) {\n routeGroups.outOfModule = this.sortRoutes(routeGroups.outOfModule);\n }\n if (routeGroups.combined) {\n lodash.each(routeGroups.combined, (routeGroup) => {\n routeGroup.routes = this.sortRoutes(routeGroup.routes);\n });\n }\n }\n\n return routeGroups;\n };\n\n sortRoutes = (routes: ParsedRoute[]) => {\n return lodash\n .slice(routes)\n .sort((routeA, routeB) =>\n routeA.routeName.usage.localeCompare(routeB.routeName.usage),\n );\n };\n}\n","import lodash from \"lodash\";\nimport type { OpenAPI } from \"openapi-types\";\nimport type { CodeGenConfig } from \"./configuration.js\";\nimport type { SwaggerSchemaResolver } from \"./swagger-schema-resolver.js\";\n\n// TODO: WIP\n// this class will be needed to walk by schema everywhere\nexport class SchemaWalker {\n config: CodeGenConfig;\n swaggerSchemaResolver: SwaggerSchemaResolver;\n schemas = new Map<string, OpenAPI.Document>();\n caches = new Map<string, OpenAPI.Document>();\n\n constructor(\n config: CodeGenConfig,\n swaggerSchemaResolver: SwaggerSchemaResolver,\n ) {\n this.config = config;\n this.swaggerSchemaResolver = swaggerSchemaResolver;\n }\n\n addSchema = (name: string, schema: OpenAPI.Document) => {\n this.schemas.set(name, structuredClone(schema));\n };\n\n _isLocalRef = (ref: string) => {\n return ref.startsWith(\"#\");\n };\n\n _isRemoteRef = (ref: string) => {\n return ref.startsWith(\"http://\") || ref.startsWith(\"https://\");\n };\n\n _getRefDataFromSchema = (schema: Record<string, unknown>, ref: string) => {\n const path = ref.replace(\"#\", \"\").split(\"/\");\n const refData = lodash.get(schema, path);\n if (refData) {\n this.caches.set(ref, refData);\n }\n return refData;\n };\n}\n","import { consola } from \"consola\";\nimport lodash from \"lodash\";\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 lodash.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 lodash from \"lodash\";\nimport type { OpenAPI, OpenAPIV2 } from \"openapi-types\";\nimport * as swagger2openapi from \"swagger2openapi\";\nimport * as YAML from \"yaml\";\nimport type { CodeGenConfig } from \"./configuration.js\";\nimport type { FileSystem } from \"./util/file-system.js\";\nimport { Request } from \"./util/request.js\";\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() {\n const { spec, patch, input, url, authorizationToken } = this.config;\n\n if (spec) {\n return await this.convertSwaggerObject(spec, { patch });\n }\n\n const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(\n input,\n url,\n authorizationToken,\n );\n const swaggerSchemaObject =\n this.processSwaggerSchemaFile(swaggerSchemaFile);\n return await this.convertSwaggerObject(swaggerSchemaObject, { patch });\n }\n\n convertSwaggerObject(\n swaggerSchema: OpenAPI.Document,\n converterOptions: { patch?: boolean },\n ): Promise<{\n usageSchema: OpenAPI.Document;\n originalSchema: OpenAPI.Document;\n }> {\n return new Promise((resolve) => {\n const result = structuredClone(swaggerSchema);\n result.info = lodash.merge(\n {\n title: \"No title\",\n version: \"\",\n },\n result.info,\n );\n\n if (!Object.hasOwn(result, \"openapi\")) {\n result.paths = lodash.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 = lodash.get(\n err,\n \"options.openapi\",\n lodash.get(options, \"openapi\"),\n );\n if (!parsedSwaggerSchema && err) {\n throw err;\n }\n this.config.update({ convertedFromSwagger2: true });\n resolve({\n usageSchema: parsedSwaggerSchema,\n originalSchema: result,\n });\n },\n );\n } else {\n resolve({\n usageSchema: result,\n originalSchema: structuredClone(result),\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 fixSwaggerSchema({ usageSchema, originalSchema }) {\n const usagePaths = lodash.get(usageSchema, \"paths\");\n const originalPaths = lodash.get(originalSchema, \"paths\");\n\n // walk by routes\n lodash.each(usagePaths, (usagePathObject, route) => {\n const originalPathObject = lodash.get(originalPaths, route);\n\n // walk by methods\n lodash.each(usagePathObject, (usageRouteInfo, methodName) => {\n const originalRouteInfo = lodash.get(originalPathObject, methodName);\n const usageRouteParams = lodash.get(usageRouteInfo, \"parameters\", []);\n const originalRouteParams = lodash.get(\n originalRouteInfo,\n \"parameters\",\n [],\n );\n\n if (typeof usageRouteInfo === \"object\") {\n usageRouteInfo.consumes = lodash.uniq(\n lodash.compact([\n ...(usageRouteInfo.consumes || []),\n ...(originalRouteInfo.consumes || []),\n ]),\n );\n usageRouteInfo.produces = lodash.uniq(\n lodash.compact([\n ...(usageRouteInfo.produces || []),\n ...(originalRouteInfo.produces || []),\n ]),\n );\n }\n\n lodash.each(originalRouteParams, (originalRouteParam) => {\n const existUsageParam = usageRouteParams.find(\n (param) =>\n originalRouteParam.in === param.in &&\n originalRouteParam.name === param.name,\n );\n if (!existUsageParam) {\n usageRouteParams.push(originalRouteParam);\n }\n });\n });\n });\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 { Eta } from \"eta\";\nimport lodash from \"lodash\";\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 lodash.reduce(\n this.config.templateInfos,\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 = lodash\n .keys(this.config.templatePaths)\n .find((key) => path_.startsWith(`@${key}`));\n\n if (foundTemplatePathKey) {\n const rawPath = path.resolve(\n path_.replace(\n `@${foundTemplatePathKey}`,\n lodash.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 lodash from \"lodash\";\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 lodash.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 = lodash\n .startCase(`${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 lodash.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 { consola } from \"consola\";\nimport lodash from \"lodash\";\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 { SchemaWalker } from \"./schema-walker.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 { internalCase } from \"./util/internal-case.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 schemaWalker: SchemaWalker;\n javascriptTranslator: JavascriptTranslator;\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.schemaWalker = new SchemaWalker(\n this.config,\n this.swaggerSchemaResolver,\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 this.schemaWalker,\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 swagger = await this.swaggerSchemaResolver.create();\n\n this.swaggerSchemaResolver.fixSwaggerSchema(swagger);\n\n this.config.update({\n swaggerSchema: swagger.usageSchema,\n originalSchema: swagger.originalSchema,\n });\n\n this.schemaWalker.addSchema(\"$usage\", swagger.usageSchema);\n this.schemaWalker.addSchema(\"$original\", swagger.originalSchema);\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 swagger.usageSchema = this.config.swaggerSchema;\n }\n if (this.config.originalSchema) {\n swagger.originalSchema = this.config.originalSchema;\n }\n\n this.schemaComponentsMap.clear();\n\n lodash.each(swagger.usageSchema.components, (component, componentName) =>\n lodash.each(component, (rawTypeData, typeName) => {\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 lodash.compact([\n \"schemas\",\n this.config.extractResponses && \"responses\",\n ]),\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({\n usageSchema: swagger.usageSchema,\n parsedSchemas,\n });\n\n const rawConfiguration = {\n apiConfig: this.createApiConfig(swagger.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 internalCase: internalCase,\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 _: lodash,\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 = lodash.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 (!lodash.isEmpty(configuration.extraTemplates)) {\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 lodash\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 ])\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: lodash.merge(\n {\n url: \"\",\n description: \"\",\n },\n externalDocs,\n ),\n tags: lodash.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 { ComponentTypeNameResolver } from \"../src/component-type-name-resolver.js\";\nimport type * as CONSTANTS from \"../src/constants.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}\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}\n\nexport type RawRouteInfo = {\n operationId: string;\n method: string;\n route: string;\n moduleName: string;\n responsesTypes: RequestResponseInfo[];\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 // 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,\n ) => Partial<PrimitiveTypeStruct>;\n /** customise code generation constructs */\n codeGenConstructs?: (struct: CodeGenConstruct) => Partial<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 _: import(\"lodash\").LoDashStatic;\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,kBA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