swagger-typescript-api 13.2.8 → 13.2.9

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-B-cU8h_Y.cjs","names":["content","Biome","Distribution","path","name","usageName: string | null","packageJson","CONSTANTS.HTTP_CLIENT.FETCH","description","CONSTANTS","componentSchema: SchemaComponent","description","type","description","content","enumNames","formatted: string | undefined","name","interfaceKeysContent: any","type","recordKeysContent: any","recordValuesContent: any","description","type","type","type","SchemaParser","name","type","resultType: string","pathParams","fixedRoute","schema","name","name","path","requestOptions: Partial<RequestInit>","url","url","yaml","require","module","__dirname","path","url","name","Eta","configuration","options","name","fs","path","__dirname","url","componentsToParse: SchemaComponent[]","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","../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.9\",\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\": {\n \"types\": \"./dist/lib.d.ts\",\n \"default\": \"./dist/lib.js\"\n },\n \"require\": {\n \"types\": \"./dist/lib.d.cts\",\n \"default\": \"./dist/lib.cjs\"\n }\n }\n },\n \"main\": \"./dist/lib.cjs\",\n \"module\": \"./dist/lib.js\",\n \"types\": \"./dist/lib.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.2\",\n \"@types/swagger-schema-official\": \"^2.0.25\",\n \"c12\": \"^3.2.0\",\n \"citty\": \"^0.1.6\",\n \"consola\": \"^3.4.2\",\n \"eta\": \"^2.2.0\",\n \"js-yaml\": \"^4.1.0\",\n \"lodash\": \"^4.17.21\",\n \"nanoid\": \"^5.1.5\",\n \"swagger-schema-official\": \"2.0.0-bab6bed\",\n \"swagger2openapi\": \"^7.0.8\",\n \"typescript\": \"~5.9.2\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"2.2.2\",\n \"@changesets/changelog-github\": \"0.5.1\",\n \"@changesets/cli\": \"2.29.6\",\n \"@tsconfig/node18\": \"18.2.4\",\n \"@tsconfig/strictest\": \"2.0.5\",\n \"@types/js-yaml\": \"4.0.9\",\n \"@types/lodash\": \"4.17.20\",\n \"@types/node\": \"24.3.0\",\n \"@types/swagger2openapi\": \"7.0.4\",\n \"axios\": \"1.11.0\",\n \"openapi-types\": \"12.1.3\",\n \"tsdown\": \"0.14.2\",\n \"typedoc\": \"0.28.11\",\n \"vitest\": \"3.2.4\"\n },\n \"packageManager\": \"yarn@4.9.4\",\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","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 if (\n mappingPropertySchema?.rawTypeData?.$parsed?.type === SCHEMA_TYPES.ENUM\n ) {\n mappingPropertySchemaEnumKeysMap = lodash.reduce(\n mappingPropertySchema.rawTypeData.$parsed.enum,\n (acc, key, index) => {\n const enumKey =\n mappingPropertySchema.rawTypeData.$parsed.content[index].key;\n acc[key] = ts.EnumUsageKey(\n mappingPropertySchema.rawTypeData.$parsed.typeName,\n enumKey,\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 * as yaml from \"js-yaml\";\nimport lodash from \"lodash\";\nimport type { OpenAPI, OpenAPIV2 } from \"openapi-types\";\nimport * as swagger2openapi from \"swagger2openapi\";\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 (e) {\n return yaml.load(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 * as 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\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: object,\n options: object = {},\n ) => {\n if (!template) return \"\";\n\n return Eta.render(\n template,\n {\n ...this.getRenderTemplateData(),\n ...configuration,\n },\n {\n async: false,\n ...options,\n includeFile: (\n path: string,\n configuration: object,\n options: object = {},\n ) => {\n return this.renderTemplate(\n this.getTemplateContent(path),\n configuration,\n options,\n );\n },\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 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 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 {\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 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;EACrD,MAAM,kBAAkB,WAAW,sBAAsB;EAEzD,MAAM,kBAAkB,gBAAgB,gBACtC;GAAE,MAAM;GAAQ,UAAU;KAC1B,EA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