@trapi/metadata 2.0.0-beta.0 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +138 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +193 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["arrayLiteral","readDecoratorName","ValidatorError","ValidatorErrorCode","ValidatorError","ValidatorErrorCode","ResolverError","prettyLocationOfNode","prettyTroubleCause","isResolverError","ResolverError","ResolverError","ResolverError","ResolverError","ResolverError","ResolverError","ResolverError","modelTypeDeclaration","stringifyFlatted","parseFlatted","joinFilePath","GeneratorError","isGeneratorError","GeneratorErrorCode","ParameterError","ParameterError","GeneratorError","GeneratorErrorCode","GeneratorError","GeneratorErrorCode","isResolverError","isGeneratorError","GeneratorError","GeneratorErrorCode","hasOwnProperty"],"sources":["../src/core/resolver/constants.ts","../src/core/resolver/type-guards.ts","../src/core/error/base.ts","../src/core/resolver/error.ts","../src/core/method/constants.ts","../src/core/parameter/constants.ts","../src/core/parameter/error.ts","../src/core/generator/error.ts","../src/core/generator/constants.ts","../src/core/validator/error.ts","../src/core/validator/constants.ts","../src/core/error/config.ts","../src/core/error/config-codes.ts","../src/adapters/decorator/constants.ts","../src/adapters/decorator/utils.ts","../src/adapters/decorator/validation/module.ts","../src/adapters/decorator/module.ts","../src/adapters/typescript/js-doc/constants.ts","../src/core/utils/array.ts","../src/core/utils/object.ts","../src/core/utils/path-normalize.ts","../src/adapters/typescript/js-doc/utils.ts","../src/adapters/typescript/js-doc/module.ts","../src/adapters/typescript/initializer.ts","../src/adapters/decorator/typescript/utils.ts","../src/adapters/decorator/typescript/module.ts","../src/adapters/decorator/orchestrator/module.ts","../src/core/error/validator.ts","../src/core/error/validator-codes.ts","../src/adapters/typescript/validator/module.ts","../src/core/error/resolver.ts","../src/adapters/typescript/resolver/extension/module.ts","../src/adapters/typescript/resolver/sub/array.ts","../src/adapters/typescript/resolver/sub/base.ts","../src/adapters/typescript/resolver/utils.ts","../src/adapters/typescript/resolver/sub/indexed-access.ts","../src/adapters/typescript/resolver/sub/intersection.ts","../src/adapters/typescript/resolver/sub/literal.ts","../src/adapters/typescript/resolver/sub/mapped.ts","../src/adapters/typescript/resolver/sub/object-literal.ts","../src/adapters/typescript/resolver/sub/primitive.ts","../src/adapters/typescript/resolver/sub/reference.ts","../src/adapters/typescript/resolver/sub/tuple.ts","../src/adapters/typescript/resolver/sub/type-operator.ts","../src/adapters/typescript/resolver/sub/union.ts","../src/adapters/typescript/resolver/module.ts","../src/adapters/typescript/resolver/cache.ts","../src/adapters/typescript/node-utils/module.ts","../src/adapters/filesystem/source-files.ts","../src/adapters/filesystem/tsconfig/module.ts","../src/adapters/cache/constants.ts","../src/adapters/cache/utils.ts","../src/adapters/cache/client.ts","../src/core/error/generator.ts","../src/core/error/generator-codes.ts","../src/core/error/parameter.ts","../src/app/generator/parameter/module.ts","../src/app/generator/method/module.ts","../src/app/generator/controller/module.ts","../src/app/generator/metadata/module.ts","../src/app/generator/metadata/utils.ts","../src/app/generate.ts"],"sourcesContent":["/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum TypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n BIGINT = 'bigint',\n DOUBLE = 'double',\n FLOAT = 'float',\n FILE = 'file',\n INTEGER = 'integer',\n LONG = 'long',\n ENUM = 'enum',\n ARRAY = 'array',\n DATETIME = 'datetime',\n DATE = 'date',\n BINARY = 'binary',\n BUFFER = 'buffer',\n BYTE = 'byte',\n VOID = 'void',\n OBJECT = 'object',\n ANY = 'any',\n UNDEFINED = 'undefined',\n NEVER = 'never',\n REF_ENUM = 'refEnum',\n REF_OBJECT = 'refObject',\n REF_ALIAS = 'refAlias',\n NESTED_OBJECT_LITERAL = 'nestedObjectLiteral',\n UNION = 'union',\n INTERSECTION = 'intersection',\n TUPLE = 'tuple',\n}\n\nexport enum UtilityTypeName {\n NON_NULLABLE = 'NonNullable',\n OMIT = 'Omit',\n PARTIAL = 'Partial',\n READONLY = 'Readonly',\n RECORD = 'Record',\n REQUIRED = 'Required',\n PICK = 'Pick',\n // Checker-resolvable utility types — delegated to the TS type checker\n EXTRACT = 'Extract',\n EXCLUDE = 'Exclude',\n RETURN_TYPE = 'ReturnType',\n PARAMETERS = 'Parameters',\n AWAITED = 'Awaited',\n INSTANCE_TYPE = 'InstanceType',\n CONSTRUCTOR_PARAMETERS = 'ConstructorParameters',\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { TypeName } from './constants';\nimport type {\n AnyType,\n ArrayType,\n BaseType,\n BigintType,\n BinaryType,\n BooleanType,\n BufferType,\n ByteType,\n DateTimeType,\n DateType,\n DoubleType,\n EnumType,\n FileType,\n FloatType,\n IntegerType,\n IntersectionType,\n LongType,\n NestedObjectLiteralType,\n NeverType,\n ObjectType,\n PrimitiveType,\n RefAliasType,\n RefEnumType,\n RefObjectType,\n ReferenceType,\n StringType,\n TupleType,\n UndefinedType,\n UnionType,\n VoidType,\n} from './types';\n\n// -------------------------------------------\n// Primitive Type Guards\n// -------------------------------------------\n\nexport function isAnyType(param: BaseType): param is AnyType {\n return param.typeName === TypeName.ANY;\n}\n\nexport function isUndefinedType(param: BaseType): param is UndefinedType {\n return param.typeName === TypeName.UNDEFINED;\n}\n\nexport function isStringType(param: BaseType): param is StringType {\n return param.typeName === TypeName.STRING;\n}\n\nexport function isBooleanType(param: BaseType): param is BooleanType {\n return param.typeName === TypeName.BOOLEAN;\n}\n\nexport function isBigintType(param: BaseType): param is BigintType {\n return param.typeName === TypeName.BIGINT;\n}\n\nexport function isDoubleType(param: BaseType): param is DoubleType {\n return param.typeName === TypeName.DOUBLE;\n}\n\nexport function isFloatType(param: BaseType): param is FloatType {\n return param.typeName === TypeName.FLOAT;\n}\n\nexport function isIntegerType(param: BaseType): param is IntegerType {\n return param.typeName === TypeName.INTEGER;\n}\n\nexport function isLongType(param: BaseType): param is LongType {\n return param.typeName === TypeName.LONG;\n}\n\nexport function isVoidType(param: BaseType | undefined): param is VoidType {\n return typeof param === 'undefined' || param.typeName === TypeName.VOID;\n}\n\nexport function isNeverType(param: BaseType): param is NeverType {\n return param.typeName === TypeName.NEVER;\n}\n\n// -------------------------------------------\n// Simple Type Guards\n// -------------------------------------------\n\nexport function isDateType(param: BaseType): param is DateType {\n return param.typeName === TypeName.DATE;\n}\n\nexport function isFileType(param: BaseType): param is FileType {\n return param.typeName === TypeName.FILE;\n}\n\nexport function isDateTimeType(param: BaseType): param is DateTimeType {\n return param.typeName === TypeName.DATETIME;\n}\n\nexport function isBinaryType(param: BaseType): param is BinaryType {\n return param.typeName === TypeName.BINARY;\n}\n\nexport function isBufferType(param: BaseType): param is BufferType {\n return param.typeName === TypeName.BUFFER;\n}\n\nexport function isByteType(param: BaseType): param is ByteType {\n return param.typeName === TypeName.BYTE;\n}\n\nexport function isObjectType(param: BaseType): param is ObjectType {\n return param.typeName === TypeName.OBJECT;\n}\n\n// -------------------------------------------\n// Complex Type Guards\n// -------------------------------------------\n\nexport function isEnumType(param: BaseType): param is EnumType {\n return param.typeName === TypeName.ENUM;\n}\n\nexport function isArrayType(param: BaseType): param is ArrayType {\n return param.typeName === TypeName.ARRAY;\n}\n\nexport function isNestedObjectLiteralType(param: BaseType): param is NestedObjectLiteralType {\n return param.typeName === TypeName.NESTED_OBJECT_LITERAL;\n}\n\nexport function isIntersectionType(param: BaseType): param is IntersectionType {\n return param.typeName === TypeName.INTERSECTION;\n}\n\nexport function isUnionType(param: BaseType): param is UnionType {\n return param.typeName === TypeName.UNION;\n}\n\nexport function isTupleType(param: BaseType): param is TupleType {\n return param.typeName === TypeName.TUPLE;\n}\n\n// -------------------------------------------\n// Reference Type Guards\n// -------------------------------------------\n\nexport function isRefEnumType(param: BaseType): param is RefEnumType {\n return param.typeName === TypeName.REF_ENUM;\n}\n\nexport function isRefObjectType(param: BaseType): param is RefObjectType {\n return param.typeName === TypeName.REF_OBJECT;\n}\n\nexport function isRefAliasType(param: BaseType): param is RefAliasType {\n return param.typeName === TypeName.REF_ALIAS;\n}\n\nexport function isReferenceType(param: BaseType): param is ReferenceType {\n return param.typeName === TypeName.REF_ALIAS ||\n param.typeName === TypeName.REF_ENUM ||\n param.typeName === TypeName.REF_OBJECT;\n}\n\nexport function isPrimitiveType(type: BaseType): type is PrimitiveType {\n return isAnyType(type) ||\n isBinaryType(type) ||\n isBooleanType(type) ||\n isBufferType(type) ||\n isByteType(type) ||\n isDateType(type) ||\n isDateTimeType(type) ||\n isBigintType(type) ||\n isDoubleType(type) ||\n isFloatType(type) ||\n isFileType(type) ||\n isIntegerType(type) ||\n isLongType(type) ||\n isObjectType(type) ||\n isStringType(type) ||\n isUndefinedType(type);\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from '@ebec/core';\n\nexport class MetadataError extends BaseError {\n\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { normalize } from 'node:path';\nimport { isBaseError } from '@ebec/core';\nimport type { Node, TypeNode } from 'typescript';\nimport { MetadataError } from '../error/base';\n\nexport class ResolverError extends MetadataError {\n public readonly file?: string;\n\n public readonly line?: number;\n\n constructor(\n message: string,\n node?: Node | TypeNode,\n options?: boolean | { onlyCurrent?: boolean, cause?: unknown },\n ) {\n const opts = typeof options === 'boolean' ? { onlyCurrent: options } : options;\n const onlyCurrent = opts?.onlyCurrent ?? false;\n\n const parts: string[] = [message];\n let file: string | undefined;\n let line: number | undefined;\n\n if (node) {\n const location = prettyLocationOfNode(node);\n if (location) {\n parts.push(location.text);\n file = location.file;\n line = location.line;\n }\n\n parts.push(prettyTroubleCause(node, onlyCurrent));\n }\n\n super({\n message: parts.join('\\n'),\n cause: opts?.cause,\n });\n\n this.file = file;\n this.line = line;\n }\n}\n\nexport function isResolverError(input: unknown): input is ResolverError {\n if (!isBaseError(input)) {\n return false;\n }\n\n return 'file' in input && 'line' in input;\n}\n\nexport function prettyLocationOfNode(node: Node | TypeNode): {\n text: string,\n file: string,\n line?: number,\n} | undefined {\n try {\n const sourceFile = node.getSourceFile();\n if (!sourceFile) return undefined;\n\n const token = node.getFirstToken() || node.parent?.getFirstToken();\n const start = token ? sourceFile.getLineAndCharacterOfPosition(token.getStart()).line + 1 : undefined;\n const end = token ? sourceFile.getLineAndCharacterOfPosition(token.getEnd()).line + 1 : undefined;\n\n const normalizedFile = normalize(sourceFile.fileName);\n const startSuffix = start ? `:${start}` : '';\n const endSuffix = end ? `:${end}` : '';\n\n return {\n text: `At: ${normalizedFile}${startSuffix}${endSuffix}.`,\n file: sourceFile.fileName,\n line: start,\n };\n } catch {\n return undefined;\n }\n}\n\nexport function prettyTroubleCause(node: Node | TypeNode, onlyCurrent = false) {\n try {\n let name: string;\n if (onlyCurrent || !node.parent) {\n name = node.pos !== -1 ? node.getText() : (node as any).name.text;\n } else {\n name = node.parent.pos !== -1 ? node.parent.getText() : (node as any).parent.name.text;\n }\n\n return `This was caused by '${name}'`;\n } catch {\n return 'This was caused by an unknown node';\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const MethodName = {\n ALL: 'ALL',\n GET: 'GET',\n POST: 'POST',\n PUT: 'PUT',\n DELETE: 'DELETE',\n PATCH: 'PATCH',\n OPTIONS: 'OPTIONS',\n HEAD: 'HEAD',\n} as const;\nexport type MethodName = typeof MethodName[keyof typeof MethodName];\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const ParameterSource = {\n BODY: 'body',\n BODY_PROP: 'bodyProp',\n CONTEXT: 'context',\n COOKIE: 'cookie',\n HEADER: 'header',\n FORM_DATA: 'formData',\n QUERY: 'query',\n QUERY_PROP: 'queryProp',\n PATH: 'path',\n} as const;\nexport type ParameterSource = typeof ParameterSource[keyof typeof ParameterSource];\n\nexport const CollectionFormat = {\n CSV: 'csv',\n SSV: 'ssv',\n TSV: 'tsv',\n PIPES: 'pipes',\n MULTI: 'multi',\n} as const;\nexport type CollectionFormat = typeof CollectionFormat[keyof typeof CollectionFormat];\n\nexport const ParameterErrorCode = {\n TYPE_UNSUPPORTED: 'PARAMETER_TYPE_UNSUPPORTED',\n METHOD_UNSUPPORTED: 'PARAMETER_METHOD_UNSUPPORTED',\n PATH_MISMATCH: 'PARAMETER_PATH_MISMATCH',\n SCOPE_REQUIRED: 'PARAMETER_SCOPE_REQUIRED',\n INVALID_EXAMPLE: 'PARAMETER_INVALID_EXAMPLE',\n} as const;\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport { isClassDeclaration, isMethodDeclaration } from 'typescript';\nimport type { Node } from 'typescript';\nimport type { BaseType } from '../resolver/types';\nimport { ParameterErrorCode } from './constants';\nimport { MetadataError } from '../error/base';\n\ntype UnsupportedTypeContext = {\n decoratorName: string,\n propertyName: string,\n type: BaseType,\n node?: Node\n};\n\ntype UnsupportedMethodContext = {\n decoratorName: string,\n propertyName: string,\n method: string,\n node?: Node\n};\n\ntype PathMatchInvalidContext = {\n decoratorName: string,\n propertyName: string,\n path: string,\n node?: Node\n};\n\ntype ScopeRequiredContext = {\n decoratorName: string,\n node?: Node\n};\n\nexport class ParameterError extends MetadataError {\n static typeUnsupported(context: UnsupportedTypeContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not support '${context.type.typeName}' type${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.TYPE_UNSUPPORTED,\n });\n }\n\n static methodUnsupported(context: UnsupportedMethodContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not support method '${context.method}'${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.METHOD_UNSUPPORTED,\n });\n }\n\n static invalidPathMatch(context: PathMatchInvalidContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not exist in path '${context.path}'${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.PATH_MISMATCH,\n });\n }\n\n static scopeRequired(context: ScopeRequiredContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}() requires a scope argument${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.SCOPE_REQUIRED,\n });\n }\n\n static invalidExampleSchema() {\n return new ParameterError({\n message: 'The @example JSDoc tag contains invalid JSON.',\n code: ParameterErrorCode.INVALID_EXAMPLE,\n });\n }\n\n public static getCurrentLocation(node: Node) {\n const parts : string[] = [];\n\n if (isMethodDeclaration(node.parent)) {\n parts.push(node.parent.name.getText());\n\n if (isClassDeclaration(node.parent.parent)) {\n parts.unshift(node.parent.parent.name.text);\n }\n }\n\n return parts.join('.');\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isBaseError } from '@ebec/core';\nimport { MetadataError } from '../error/base';\n\nexport class GeneratorError extends MetadataError {\n\n}\n\nexport function isGeneratorError(input: unknown): input is GeneratorError & { code: string } {\n if (!isBaseError(input)) {\n return false;\n }\n\n return typeof input.code === 'string';\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const GeneratorErrorCode = {\n CONTROLLER_NO_SOURCE_FILE: 'GENERATOR_CONTROLLER_NO_SOURCE_FILE',\n CONTROLLER_NO_NAME: 'GENERATOR_CONTROLLER_NO_NAME',\n PARAMETER_GENERATION_FAILED: 'GENERATOR_PARAMETER_GENERATION_FAILED',\n BODY_PARAMETER_DUPLICATE: 'GENERATOR_BODY_PARAMETER_DUPLICATE',\n BODY_FORM_CONFLICT: 'GENERATOR_BODY_FORM_CONFLICT',\n} as const;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { MetadataError } from '../error/base';\n\nexport class ValidatorError extends MetadataError {\n\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum ValidatorName {\n UNIQUE_ITEMS = 'uniqueItems',\n\n MINIMUM = 'minimum',\n MAXIMUM = 'maximum',\n MIN_ITEMS = 'minItems',\n MAX_ITEMS = 'maxItems',\n MIN_LENGTH = 'minLength',\n MAX_LENGTH = 'maxLength',\n\n MIN_DATE = 'minDate',\n MAX_DATE = 'maxDate',\n\n PATTERN = 'pattern',\n}\n\nexport const ValidatorErrorCode = {\n EXPECTED_NUMBER: 'VALIDATOR_EXPECTED_NUMBER',\n EXPECTED_DATE: 'VALIDATOR_EXPECTED_DATE',\n EXPECTED_STRING: 'VALIDATOR_EXPECTED_STRING',\n} as const;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { MetadataError } from './base';\n\nexport class ConfigError extends MetadataError {\n\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const ConfigErrorCode = {\n TSCONFIG_MALFORMED: 'CONFIG_TSCONFIG_MALFORMED',\n PRESET_NOT_FOUND: 'CONFIG_PRESET_NOT_FOUND',\n PRESET_MISSING: 'CONFIG_PRESET_MISSING',\n} as const;\nexport type ConfigErrorCode = typeof ConfigErrorCode[keyof typeof ConfigErrorCode];\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const ParamKind = {\n Body: 'body',\n BodyProp: 'bodyProp',\n Context: 'context',\n Cookie: 'cookie',\n Header: 'header',\n FormData: 'formData',\n Query: 'query',\n QueryProp: 'queryProp',\n Path: 'path',\n} as const;\nexport type ParamKind = typeof ParamKind[keyof typeof ParamKind];\n\nexport const CollectionKind = {\n Csv: 'csv',\n Ssv: 'ssv',\n Tsv: 'tsv',\n Pipes: 'pipes',\n Multi: 'multi',\n} as const;\nexport type CollectionKind = typeof CollectionKind[keyof typeof CollectionKind];\n\nexport const DecoratorTargetKind = {\n Class: 'class',\n Method: 'method',\n Parameter: 'parameter',\n Property: 'property',\n} as const;\nexport type DecoratorTargetKind = typeof DecoratorTargetKind[keyof typeof DecoratorTargetKind];\n\nexport const DecoratorArgumentKindName = {\n Literal: 'literal',\n Object: 'object',\n Array: 'array',\n Identifier: 'identifier',\n Unresolvable: 'unresolvable',\n} as const;\nexport type DecoratorArgumentKindName = typeof DecoratorArgumentKindName[keyof typeof DecoratorArgumentKindName];\n\nexport const MarkerName = {\n Hidden: 'hidden',\n Deprecated: 'deprecated',\n Extension: 'extension',\n} as const;\nexport type MarkerName = typeof MarkerName[keyof typeof MarkerName];\n\nexport const NumericKind = {\n Int: 'int',\n Long: 'long',\n Float: 'float',\n Double: 'double',\n} as const;\nexport type NumericKind = typeof NumericKind[keyof typeof NumericKind];\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport type {\n ControllerDraft,\n ControllerHandler,\n ControllerJsDocHandler,\n DecoratorSource,\n HandlerContext,\n JsDocMatch,\n JsDocSource,\n Match,\n MethodDraft,\n MethodHandler,\n MethodJsDocHandler,\n ParameterDraft,\n ParameterHandler,\n ParameterJsDocHandler,\n Registry,\n ResolverMarker,\n} from './types';\n\n// -----------------------------------------------------------------------------\n// Match predicates\n// -----------------------------------------------------------------------------\n\nexport function matches(match: Match, source: Pick<DecoratorSource, 'name' | 'target'>): boolean {\n if (match.name !== source.name) {\n return false;\n }\n if (match.on && match.on !== source.target) {\n return false;\n }\n return true;\n}\n\nexport function matchesJsDoc(match: JsDocMatch, source: Pick<JsDocSource, 'tag' | 'target'>): boolean {\n if (match.tag !== source.tag) {\n return false;\n }\n if (match.on && match.on !== source.target) {\n return false;\n }\n return true;\n}\n\n// -----------------------------------------------------------------------------\n// Draft factories\n// -----------------------------------------------------------------------------\n\nexport function newControllerDraft(input: Pick<ControllerDraft, 'name' | 'location'>): ControllerDraft {\n return {\n name: input.name,\n location: input.location,\n hidden: false,\n consumes: [],\n produces: [],\n tags: [],\n responses: [],\n security: [],\n extensions: [],\n };\n}\n\nexport function newMethodDraft(input: Pick<MethodDraft, 'name'>): MethodDraft {\n return {\n name: input.name,\n path: '',\n description: '',\n hidden: false,\n consumes: [],\n produces: [],\n tags: [],\n responses: [],\n security: [],\n extensions: [],\n parameters: [],\n defaultResponseExamples: [],\n };\n}\n\nexport function newParameterDraft(input: Pick<ParameterDraft, 'parameterName'>): ParameterDraft {\n return {\n parameterName: input.parameterName,\n name: input.parameterName,\n description: '',\n required: true,\n examples: [],\n exampleLabels: [],\n extensions: [],\n validators: {},\n };\n}\n\n// -----------------------------------------------------------------------------\n// Registry factory\n// -----------------------------------------------------------------------------\n\nexport function createRegistry(): Registry {\n return {\n controllers: [],\n methods: [],\n parameters: [],\n controllerJsDoc: [],\n methodJsDoc: [],\n parameterJsDoc: [],\n };\n}\n\n// -----------------------------------------------------------------------------\n// Preset name resolution (used by loadRegistryByName)\n// -----------------------------------------------------------------------------\n\nexport function generatePresetLookupPaths(input: string) : string[] {\n if (path.isAbsolute(input) || input.startsWith('./') || input.startsWith('../')) {\n return [input];\n }\n\n if (input.startsWith('module:')) {\n return [input.substring('module:'.length)];\n }\n\n if (!input.startsWith('@')) {\n return [input, `@trapi/${input}`];\n }\n\n return [input];\n}\n\n// -----------------------------------------------------------------------------\n// Resolver marker lookups\n// -----------------------------------------------------------------------------\n\n/**\n * Collect the unique decorator names of every handler whose `marker` matches\n * the given predicate. Lets the type resolver discover preset-renamed\n * decorators without hard-coding canonical names.\n */\nexport function namesForMarker(\n registry: Registry,\n predicate: (marker: ResolverMarker) => boolean,\n): Set<string> {\n const names = new Set<string>();\n const all = [\n ...registry.controllers,\n ...registry.methods,\n ...registry.parameters,\n ];\n for (const handler of all) {\n if (handler.marker !== undefined && predicate(handler.marker)) {\n names.add(handler.match.name);\n }\n }\n return names;\n}\n\n/**\n * Collect the unique JSDoc tag names of every JSDoc handler whose `marker`\n * matches the given predicate. JSDoc analogue of `namesForMarker`.\n */\nexport function tagsForMarker(\n registry: Registry,\n predicate: (marker: ResolverMarker) => boolean,\n): Set<string> {\n const tags = new Set<string>();\n const all = [\n ...registry.controllerJsDoc,\n ...registry.methodJsDoc,\n ...registry.parameterJsDoc,\n ];\n for (const handler of all) {\n if (handler.marker !== undefined && predicate(handler.marker)) {\n tags.add(handler.match.tag);\n }\n }\n return tags;\n}\n\nexport function isHiddenMarker(marker: ResolverMarker): boolean {\n return marker === 'hidden';\n}\n\nexport function isDeprecatedMarker(marker: ResolverMarker): boolean {\n return marker === 'deprecated';\n}\n\nexport function isExtensionMarker(marker: ResolverMarker): boolean {\n return marker === 'extension';\n}\n\nexport function numericMarkerKind(\n marker: ResolverMarker,\n): 'int' | 'long' | 'float' | 'double' | undefined {\n if (typeof marker === 'object' && marker !== null && 'numeric' in marker) {\n return marker.numeric;\n }\n return undefined;\n}\n\n// -----------------------------------------------------------------------------\n// Handler builder identity functions (preserve narrow types at declaration site)\n// -----------------------------------------------------------------------------\n\nexport const controller = (handler: ControllerHandler): ControllerHandler => handler;\nexport const method = (handler: MethodHandler): MethodHandler => handler;\nexport const parameter = (handler: ParameterHandler): ParameterHandler => handler;\nexport const controllerJsDoc = (handler: ControllerJsDocHandler): ControllerJsDocHandler => handler;\nexport const methodJsDoc = (handler: MethodJsDocHandler): MethodJsDocHandler => handler;\nexport const parameterJsDoc = (handler: ParameterJsDocHandler): ParameterJsDocHandler => handler;\n\n// -----------------------------------------------------------------------------\n// Apply helpers (Layer 4)\n// -----------------------------------------------------------------------------\n\ntype AnyDraft = ControllerDraft | MethodDraft | ParameterDraft;\ntype DraftApply = (ctx: HandlerContext, draft: AnyDraft) => void;\n\nfunction isLiteralLike(kind: string): boolean {\n return kind === 'literal' || kind === 'identifier';\n}\n\nfunction readArray(draft: AnyDraft, key: string): unknown[] {\n const record = draft as Record<string, unknown>;\n const existing = record[key];\n if (Array.isArray(existing)) {\n return existing;\n }\n if (typeof existing !== 'undefined') {\n throw new TypeError(\n `append(): cannot append to draft key \"${key}\": existing value is not an array (got ${typeof existing}).`,\n );\n }\n const created: unknown[] = [];\n record[key] = created;\n return created;\n}\n\n// Scalar-only writer. Use for fields that hold a single value (path, name, description, ...).\n// Object/array/unresolvable arguments are intentionally ignored — use `append()` for arrays.\nexport function into(key: string) {\n return {\n positional(index: number): DraftApply {\n return (ctx, draft) => {\n const arg = ctx.argument(index);\n if (arg && isLiteralLike(arg.kind)) {\n (draft as Record<string, unknown>)[key] = arg.raw;\n }\n };\n },\n typeArgument(index = 0): DraftApply {\n return (ctx, draft) => {\n const ta = ctx.typeArgument(index);\n if (ta) {\n (draft as Record<string, unknown>)[key] = ta.resolve();\n }\n };\n },\n };\n}\n\n// Array writer. Use for fields that hold lists (tags, produces, security, ...).\n// Array arguments are flattened; scalar arguments are pushed as-is.\nexport function append(key: string) {\n return {\n positional(index: number): DraftApply {\n return (ctx, draft) => {\n const arg = ctx.argument(index);\n if (!arg) {\n return;\n }\n const target = readArray(draft, key);\n if (arg.kind === 'array' && Array.isArray(arg.raw)) {\n target.push(...arg.raw);\n } else if (isLiteralLike(arg.kind)) {\n target.push(arg.raw);\n }\n };\n },\n positionalAll(): DraftApply {\n return (ctx, draft) => {\n const target = readArray(draft, key);\n for (const arg of ctx.arguments()) {\n if (arg.kind === 'array' && Array.isArray(arg.raw)) {\n target.push(...arg.raw);\n } else if (isLiteralLike(arg.kind)) {\n target.push(arg.raw);\n }\n }\n };\n },\n };\n}\n\nexport function flag(key: string, value: unknown = true): DraftApply {\n return (_ctx, draft) => {\n (draft as Record<string, unknown>)[key] = value;\n };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Container } from 'validup';\nimport { createValidator } from '@validup/adapter-zod';\nimport { z } from 'zod';\nimport type { Preset } from '../types';\n\nconst decoratorTargetSchema = z.enum([\n 'class',\n 'method',\n 'parameter',\n 'property',\n]);\n\nconst replacesPolicySchema = z.union([z.literal(true), z.string().min(1)]);\n\nfunction matchSchemaForKind(allowedOn: 'class' | 'method' | 'parameter') {\n return z.object({\n name: z.string().min(1),\n on: decoratorTargetSchema.optional(),\n }).refine(\n (m) => m.on === undefined || m.on === allowedOn,\n {\n message: `match.on is incompatible with the handler array it lives in — expected '${allowedOn}' or omit 'on' entirely.`,\n path: ['on'],\n },\n );\n}\n\nfunction jsDocMatchSchemaForKind(allowedOn: 'class' | 'method' | 'parameter') {\n return z.object({\n tag: z.string().min(1),\n on: decoratorTargetSchema.optional(),\n }).refine(\n (m) => m.on === undefined || m.on === allowedOn,\n {\n message: `match.on is incompatible with the JSDoc handler array it lives in — expected '${allowedOn}' or omit 'on' entirely.`,\n path: ['on'],\n },\n );\n}\n\n// Public re-exports for callers that previously imported the legacy un-kinded schemas.\nexport const matchSchema = z.object({\n name: z.string().min(1),\n on: decoratorTargetSchema.optional(),\n});\n\nexport const jsDocMatchSchema = z.object({\n tag: z.string().min(1),\n on: decoratorTargetSchema.optional(),\n});\n\nconst numericMarkerSchema = z.object({ numeric: z.enum(['int', 'long', 'float', 'double']) });\n\nconst resolverMarkerSchema = z.union([\n z.literal('hidden'),\n z.literal('deprecated'),\n z.literal('extension'),\n numericMarkerSchema,\n]);\n\nconst handlerBaseShape = {\n replaces: replacesPolicySchema.optional(),\n marker: resolverMarkerSchema.optional(),\n apply: z.custom<(...args: unknown[]) => unknown>(\n (value) => typeof value === 'function',\n { message: 'apply must be a function' },\n ),\n};\n\nexport const controllerHandlerSchema = z.object({\n match: matchSchemaForKind('class'),\n ...handlerBaseShape,\n});\n\nexport const methodHandlerSchema = z.object({\n match: matchSchemaForKind('method'),\n ...handlerBaseShape,\n});\n\nexport const parameterHandlerSchema = z.object({\n match: matchSchemaForKind('parameter'),\n ...handlerBaseShape,\n});\n\nexport const controllerJsDocHandlerSchema = z.object({\n match: jsDocMatchSchemaForKind('class'),\n ...handlerBaseShape,\n});\n\nexport const methodJsDocHandlerSchema = z.object({\n match: jsDocMatchSchemaForKind('method'),\n ...handlerBaseShape,\n});\n\nexport const parameterJsDocHandlerSchema = z.object({\n match: jsDocMatchSchemaForKind('parameter'),\n ...handlerBaseShape,\n});\n\nexport const presetSchema = z.object({\n name: z.string().min(1),\n extends: z.array(z.string().min(1)).optional(),\n controllers: z.array(controllerHandlerSchema).optional(),\n methods: z.array(methodHandlerSchema).optional(),\n parameters: z.array(parameterHandlerSchema).optional(),\n controllerJsDoc: z.array(controllerJsDocHandlerSchema).optional(),\n methodJsDoc: z.array(methodJsDocHandlerSchema).optional(),\n parameterJsDoc: z.array(parameterJsDocHandlerSchema).optional(),\n});\n\nexport function createPresetContainer(): Container<Preset> {\n const container = new Container<Preset>();\n container.mount('name', createValidator(presetSchema.shape.name));\n container.mount('extends', { optional: true }, createValidator(presetSchema.shape.extends));\n container.mount('controllers', { optional: true }, createValidator(presetSchema.shape.controllers));\n container.mount('methods', { optional: true }, createValidator(presetSchema.shape.methods));\n container.mount('parameters', { optional: true }, createValidator(presetSchema.shape.parameters));\n container.mount('controllerJsDoc', { optional: true }, createValidator(presetSchema.shape.controllerJsDoc));\n container.mount('methodJsDoc', { optional: true }, createValidator(presetSchema.shape.methodJsDoc));\n container.mount('parameterJsDoc', { optional: true }, createValidator(presetSchema.shape.parameterJsDoc));\n return container;\n}\n\nconst sharedContainer = createPresetContainer();\n\nexport async function validatePreset(input: unknown): Promise<Preset> {\n if (input === null || typeof input !== 'object' || Array.isArray(input)) {\n throw new TypeError('preset input must be an object');\n }\n return sharedContainer.run(input as Record<string, unknown>) as Promise<Preset>;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { load } from 'locter';\nimport type {\n AnyDecoratorHandler,\n AnyJsDocHandler,\n ControllerHandler,\n ControllerJsDocHandler,\n LoadRegistryOptions,\n MethodHandler,\n MethodJsDocHandler,\n ParameterHandler,\n ParameterJsDocHandler,\n Preset,\n Registry,\n ReplacesPolicy,\n} from './types';\nimport { createRegistry, generatePresetLookupPaths } from './utils';\nimport { validatePreset } from './validation';\nimport { ConfigError } from '../../core/error/config';\nimport { ConfigErrorCode } from '../../core/error/config-codes';\nimport { MetadataError } from '../../core/error/base';\n\nconst decoratorKinds = ['controllers', 'methods', 'parameters'] as const;\nconst jsDocKinds = ['controllerJsDoc', 'methodJsDoc', 'parameterJsDoc'] as const;\n\ntype TaggedDecoratorHandler = { origin: string; handler: AnyDecoratorHandler };\ntype TaggedJsDocHandler = { origin: string; handler: AnyJsDocHandler };\n\ntype TaggedRegistry = {\n controllers: { origin: string; handler: ControllerHandler }[];\n methods: { origin: string; handler: MethodHandler }[];\n parameters: { origin: string; handler: ParameterHandler }[];\n controllerJsDoc: { origin: string; handler: ControllerJsDocHandler }[];\n methodJsDoc: { origin: string; handler: MethodJsDocHandler }[];\n parameterJsDoc: { origin: string; handler: ParameterJsDocHandler }[];\n};\n\nfunction emptyTaggedRegistry(): TaggedRegistry {\n return {\n controllers: [],\n methods: [],\n parameters: [],\n controllerJsDoc: [],\n methodJsDoc: [],\n parameterJsDoc: [],\n };\n}\n\nexport async function loadRegistry(\n preset: Preset,\n options: LoadRegistryOptions,\n): Promise<Registry> {\n const tagged = await loadTaggedRegistry(preset, options, new Set());\n return stripOrigins(tagged);\n}\n\nasync function loadTaggedRegistry(\n preset: Preset,\n options: LoadRegistryOptions,\n visited: ReadonlySet<string>,\n): Promise<TaggedRegistry> {\n const validated = await validatePreset(preset);\n\n if (visited.has(validated.name)) {\n throw new MetadataError({ message: `Preset cycle detected: ${[...visited, validated.name].join(' -> ')}` });\n }\n const nextVisited = new Set(visited);\n nextVisited.add(validated.name);\n\n const merged = emptyTaggedRegistry();\n\n for (const extendsName of validated.extends ?? []) {\n const parentPreset = await options.resolver(extendsName);\n const parentRegistry = await loadTaggedRegistry(parentPreset, options, nextVisited);\n appendTagged(merged, parentRegistry);\n }\n\n applyOwnHandlers(merged, validated, !!options.strict);\n\n return merged;\n}\n\nfunction applyOwnHandlers(\n merged: TaggedRegistry,\n preset: Preset,\n strict: boolean,\n): void {\n for (const kind of decoratorKinds) {\n const handlers = (preset[kind] ?? []) as AnyDecoratorHandler[];\n for (const handler of handlers) {\n if (handler.replaces) {\n applyReplacesDecorator(merged, kind, handler, preset.name, strict);\n }\n (merged[kind] as TaggedDecoratorHandler[]).push({ origin: preset.name, handler });\n }\n }\n\n for (const kind of jsDocKinds) {\n const handlers = (preset[kind] ?? []) as AnyJsDocHandler[];\n for (const handler of handlers) {\n if (handler.replaces) {\n applyReplacesJsDoc(merged, kind, handler, preset.name, strict);\n }\n (merged[kind] as TaggedJsDocHandler[]).push({ origin: preset.name, handler });\n }\n }\n}\n\nfunction applyReplacesDecorator(\n merged: TaggedRegistry,\n kind: typeof decoratorKinds[number],\n handler: AnyDecoratorHandler,\n presetName: string,\n strict: boolean,\n): void {\n const list = merged[kind] as TaggedDecoratorHandler[];\n const remaining: TaggedDecoratorHandler[] = [];\n let removed = 0;\n for (const entry of list) {\n if (entry.origin !== presetName &&\n handlerMatches(handler, entry.handler.match.name, entry.handler.match.on) &&\n originMatches(handler.replaces!, entry.origin)) {\n removed += 1;\n continue;\n }\n remaining.push(entry);\n }\n if (removed === 0 && strict) {\n throw new MetadataError({ message: `Preset '${presetName}': handler with replaces=${describeReplaces(handler.replaces!)} on '${handler.match.name}' did not match any parent handler` });\n }\n (merged as Record<string, unknown>)[kind] = remaining;\n}\n\nfunction applyReplacesJsDoc(\n merged: TaggedRegistry,\n kind: typeof jsDocKinds[number],\n handler: AnyJsDocHandler,\n presetName: string,\n strict: boolean,\n): void {\n const list = merged[kind] as TaggedJsDocHandler[];\n const remaining: TaggedJsDocHandler[] = [];\n let removed = 0;\n for (const entry of list) {\n if (entry.origin !== presetName &&\n handlerMatches(handler, entry.handler.match.tag, entry.handler.match.on) &&\n originMatches(handler.replaces!, entry.origin)) {\n removed += 1;\n continue;\n }\n remaining.push(entry);\n }\n if (removed === 0 && strict) {\n throw new MetadataError({ message: `Preset '${presetName}': JSDoc handler with replaces=${describeReplaces(handler.replaces!)} on '@${handler.match.tag}' did not match any parent handler` });\n }\n (merged as Record<string, unknown>)[kind] = remaining;\n}\n\nfunction handlerMatches(\n handler: AnyDecoratorHandler | AnyJsDocHandler,\n targetName: string,\n targetOn: string | undefined,\n): boolean {\n const matchName = 'name' in handler.match ? handler.match.name : handler.match.tag;\n if (matchName !== targetName) {\n return false;\n }\n if (handler.match.on && handler.match.on !== targetOn) {\n return false;\n }\n return true;\n}\n\nfunction originMatches(replaces: ReplacesPolicy, origin: string): boolean {\n if (replaces === true) {\n return true;\n }\n return replaces === origin;\n}\n\nfunction describeReplaces(replaces: ReplacesPolicy): string {\n return replaces === true ? 'true' : `'${replaces}'`;\n}\n\nfunction appendTagged(target: TaggedRegistry, source: TaggedRegistry): void {\n for (const kind of decoratorKinds) {\n (target[kind] as TaggedDecoratorHandler[]).push(...(source[kind] as TaggedDecoratorHandler[]));\n }\n for (const kind of jsDocKinds) {\n (target[kind] as TaggedJsDocHandler[]).push(...(source[kind] as TaggedJsDocHandler[]));\n }\n}\n\nfunction stripOrigins(tagged: TaggedRegistry): Registry {\n const registry = createRegistry();\n registry.controllers = tagged.controllers.map((e) => e.handler);\n registry.methods = tagged.methods.map((e) => e.handler);\n registry.parameters = tagged.parameters.map((e) => e.handler);\n registry.controllerJsDoc = tagged.controllerJsDoc.map((e) => e.handler);\n registry.methodJsDoc = tagged.methodJsDoc.map((e) => e.handler);\n registry.parameterJsDoc = tagged.parameterJsDoc.map((e) => e.handler);\n return registry;\n}\n\n/**\n * Resolve a preset by string identifier (npm package, relative path, etc.) and\n * return the v2 Preset object. Looks for a `preset` named export, then the\n * default export, then the module itself.\n */\nexport async function resolvePresetByName(input: string): Promise<Preset> {\n const lookupPaths = generatePresetLookupPaths(input);\n let lastError: unknown;\n\n for (const lookupPath of lookupPaths) {\n try {\n const moduleExport = await load(lookupPath) as Record<string, unknown>;\n\n const candidates: unknown[] = [\n (moduleExport as { preset?: unknown }).preset,\n (moduleExport as { default?: unknown }).default,\n moduleExport,\n ];\n\n for (const candidate of candidates) {\n if (isV2Preset(candidate)) {\n return candidate;\n }\n }\n } catch (e) {\n // Module-not-found errors are expected when iterating lookup paths;\n // capture the last error so we can surface it if every path fails.\n lastError = e;\n }\n }\n\n throw new ConfigError({\n message: `Preset '${input}' could not be resolved.`,\n code: ConfigErrorCode.PRESET_NOT_FOUND,\n cause: lastError,\n });\n}\n\n/**\n * Resolve a preset by name and immediately materialize its registry, recursively\n * loading `extends` parents through the same resolver.\n */\nexport async function loadRegistryByName(input: string): Promise<Registry> {\n const preset = await resolvePresetByName(input);\n return loadRegistry(preset, { resolver: resolvePresetByName });\n}\n\nfunction isV2Preset(input: unknown): input is Preset {\n return (\n typeof input === 'object' &&\n input !== null &&\n typeof (input as { name?: unknown }).name === 'string' &&\n !('items' in input)\n );\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum JSDocTagName {\n ABSTRACT = 'abstract',\n ACCESS = 'access',\n ALIAS = 'alias',\n ASYNC = 'async',\n /**\n * Alias for @extends\n */\n AUGMENTS = 'augments',\n AUTHOR = 'author',\n\n // todo: ... add missing\n\n DEFAULT = 'default',\n DEPRECATED = 'deprecated',\n DESCRIPTION = 'description',\n EXAMPLE = 'example',\n\n FORMAT = 'format',\n\n IGNORE = 'ignore',\n\n SUMMARY = 'summary',\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isStringArray(input: unknown) : input is string[] {\n if (!Array.isArray(input)) {\n return false;\n }\n\n for (const element of input) {\n if (typeof element !== 'string') {\n return false;\n }\n }\n\n return true;\n}\n","/*\n * Copyright (c) 2021-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function hasOwnProperty<Y extends PropertyKey>(obj: unknown, prop: Y): obj is Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function normalizePath(str: string) : string {\n // remove slashes\n str = str.replace(/^[/\\\\\\s]+|[/\\\\\\s]+$/g, '');\n\n str = str.replace(/([^:]\\/)\\/+/g, '$1');\n\n return str;\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from 'locter';\nimport type { JSDocComment, NodeArray } from 'typescript';\n\nexport function transformJSDocComment(\n input?: string | NodeArray<JSDocComment>,\n) : string | undefined {\n if (typeof input === 'string') {\n return input;\n }\n\n if (!input || input.length === 0) {\n return undefined;\n }\n\n const comment = input[0];\n if (typeof comment === 'string') {\n return comment;\n }\n\n if (\n isObject(comment) &&\n typeof comment.text === 'string'\n ) {\n return comment.text;\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2021-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n Identifier, \n JSDoc, \n JSDocTag, \n Node,\n} from 'typescript';\nimport { SyntaxKind, isJSDocParameterTag } from 'typescript';\nimport { MetadataError } from '../../../core/error';\nimport { hasOwnProperty } from '../../../core/utils';\nimport type { JSDocTagName } from './constants';\nimport { transformJSDocComment } from './utils';\n\n// -----------------------------------------\n// Description\n// -----------------------------------------\nexport function getJSDocDescription(node: Node, index?: number) : string | undefined {\n const jsDoc = getJSDoc(node, index);\n if (!jsDoc) {\n return undefined;\n }\n\n return transformJSDocComment(jsDoc.comment);\n}\n\n// -----------------------------------------\n// Tag\n// -----------------------------------------\n\nexport function getJSDoc(node: Node, index?: number) : undefined | JSDoc {\n if (!hasOwnProperty(node, 'jsDoc')) {\n return undefined;\n }\n\n const jsDoc : JSDoc[] | undefined = (node as any).jsDoc as JSDoc[];\n\n if (!jsDoc || !Array.isArray(jsDoc) || !jsDoc.length) {\n return undefined;\n }\n\n index = index ?? 0;\n return jsDoc.length > index && index >= 0 ? jsDoc[index] : undefined; // jsDoc[0] else case\n}\n\nexport function getJSDocTags(\n node: Node,\n isMatching?:\n | `${JSDocTagName}` |\n `${JSDocTagName}`[] |\n (string & {}) |\n (string & {})[] |\n ((tag: JSDocTag) => boolean),\n) : JSDocTag[] {\n const jsDoc : JSDoc = getJSDoc(node);\n if (typeof jsDoc === 'undefined') {\n return [];\n }\n\n const jsDocTags : JSDocTag[] = jsDoc.tags as unknown as JSDocTag[];\n\n if (typeof jsDocTags === 'undefined') {\n return [];\n }\n\n if (typeof isMatching === 'undefined') {\n return jsDocTags;\n }\n\n if (typeof isMatching === 'function') {\n return jsDocTags.filter(isMatching);\n }\n\n const tagNames : string[] = Array.isArray(isMatching) ? isMatching : [isMatching];\n\n return jsDocTags.filter((tag) => tagNames.includes(tag.tagName.text));\n}\n\nexport function hasJSDocTag(node: Node, tagName: ((tag: JSDocTag) => boolean) | `${JSDocTagName}` | (string & {})) : boolean {\n const tags : JSDocTag[] = getJSDocTags(node, tagName);\n\n return !(!tags || !tags.length);\n}\n\n// -----------------------------------------\n// Tag Comment(s)\n// -----------------------------------------\n\nexport function getJSDocTagComment(node: Node, tagName: ((tag: JSDocTag) => boolean) | `${JSDocTagName}`) : undefined | string {\n const tags : JSDocTag[] = getJSDocTags(node, tagName);\n\n if (!tags || !tags.length || typeof tags[0].comment !== 'string') {\n return undefined;\n }\n return tags[0].comment;\n}\n\n// -----------------------------------------\n// Tag Names\n// -----------------------------------------\n\nexport function getJSDocTagNames(node: Node, requireTagName = false) : string[] {\n let tags: JSDocTag[];\n\n /* istanbul ignore next */\n if (node.kind === SyntaxKind.Parameter) {\n const parameterName = ((node as any).name as Identifier).text;\n tags = getJSDocTags(node.parent as any, (tag) => {\n if (isJSDocParameterTag(tag)) {\n return false;\n } if (tag.comment === undefined) {\n throw new MetadataError(`Orphan tag: @${String(tag.tagName.text || tag.tagName.escapedText)} must be followed by a parameter name.`);\n }\n return typeof tag.comment === 'string' ? tag.comment.startsWith(parameterName) : false;\n });\n } else {\n tags = getJSDocTags(node as any, (tag) => (requireTagName ? tag.comment !== undefined : true));\n }\n\n return tags.map((tag) => tag.tagName.text);\n}\n","/*\n * Copyright (c) 2021-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { MetadataError } from '../../core/error';\nimport type { Type } from '../../core/types/resolver';\nimport { hasOwnProperty } from '../../core/utils/object';\n\nexport function getInitializerValue(\n initializer?: ts.Expression,\n typeChecker?: ts.TypeChecker,\n type?: Type,\n) : unknown {\n if (!initializer) {\n return undefined;\n }\n\n switch (initializer.kind) {\n case ts.SyntaxKind.ArrayLiteralExpression: {\n const arrayLiteral = initializer as ts.ArrayLiteralExpression;\n return arrayLiteral.elements.map((element) => getInitializerValue(element, typeChecker));\n }\n case ts.SyntaxKind.StringLiteral:\n case ts.SyntaxKind.NoSubstitutionTemplateLiteral:\n return (initializer as ts.StringLiteral).text;\n case ts.SyntaxKind.TrueKeyword:\n return true;\n case ts.SyntaxKind.FalseKeyword:\n return false;\n case ts.SyntaxKind.PrefixUnaryExpression: {\n const prefixUnary = initializer as ts.PrefixUnaryExpression;\n switch (prefixUnary.operator) {\n case ts.SyntaxKind.PlusToken:\n return Number((prefixUnary.operand as ts.NumericLiteral).text);\n case ts.SyntaxKind.MinusToken:\n return Number(`-${(prefixUnary.operand as ts.NumericLiteral).text}`);\n default:\n throw new MetadataError(`Unsupported prefix operator token: ${prefixUnary.operator}`);\n }\n }\n case ts.SyntaxKind.NumberKeyword:\n case ts.SyntaxKind.FirstLiteralToken:\n return Number((initializer as ts.NumericLiteral).text);\n case ts.SyntaxKind.NewExpression: {\n const newExpression = initializer as ts.NewExpression;\n const ident = newExpression.expression as ts.Identifier;\n\n if (ident.text === 'Date') {\n let date = new Date();\n if (newExpression.arguments) {\n const newArguments = newExpression.arguments.filter((args) => args.kind !== undefined);\n const argsValue = newArguments.map((args) => getInitializerValue(args, typeChecker));\n if (argsValue.length > 0) {\n date = new Date(argsValue as any);\n }\n }\n const dateString = date.toISOString();\n if (type && type.typeName === 'date') {\n return dateString.split('T')[0];\n }\n\n return dateString;\n }\n\n return undefined;\n }\n case ts.SyntaxKind.NullKeyword: {\n return null;\n }\n case ts.SyntaxKind.ObjectLiteralExpression: {\n const objectLiteral = initializer as ts.ObjectLiteralExpression;\n const nestedObject: any = {};\n objectLiteral.properties.forEach((p: any) => {\n nestedObject[p.name.text] = getInitializerValue(p.initializer, typeChecker);\n });\n return nestedObject;\n }\n case ts.SyntaxKind.ImportSpecifier: {\n if (typeof typeChecker === 'undefined') {\n return undefined;\n }\n\n const importSpecifier = (initializer as any) as ts.ImportSpecifier;\n const importSymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);\n if (!importSymbol) {\n return undefined;\n }\n\n const aliasedSymbol = typeChecker.getAliasedSymbol(importSymbol);\n const declarations = aliasedSymbol.getDeclarations();\n const declaration = declarations && declarations.length > 0 ? declarations[0] : undefined;\n return getInitializerValue(extractInitializer(declaration), typeChecker);\n }\n default: {\n if (typeof initializer === 'undefined') {\n return undefined;\n }\n if (\n typeof initializer.parent === 'undefined' ||\n typeof typeChecker === 'undefined'\n ) {\n if (hasOwnProperty(initializer, 'text')) {\n return initializer.text;\n }\n\n return undefined;\n }\n\n const symbol = typeChecker.getSymbolAtLocation(initializer);\n return getInitializerValue(\n extractInitializer(symbol.valueDeclaration) || extractInitializer(extractImportSpecifier(symbol)),\n typeChecker,\n );\n }\n }\n}\n\nexport const hasInitializer = (\n node: ts.Node,\n): node is ts.HasInitializer => Object.prototype.hasOwnProperty.call(node, 'initializer');\nconst extractInitializer = (\n valueDeclaration?: ts.Declaration,\n) => (valueDeclaration && hasInitializer(valueDeclaration) && (valueDeclaration.initializer as ts.Expression)) || undefined;\nconst extractImportSpecifier = (\n symbol?: ts.Symbol,\n) => (symbol?.declarations && symbol.declarations.length > 0 && ts.isImportSpecifier(symbol.declarations[0]) && symbol.declarations[0]) || undefined;\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n Expression, \n Node, \n TypeChecker,\n} from 'typescript';\nimport * as ts from 'typescript';\nimport { getInitializerValue } from '../../typescript/initializer';\nimport type { DecoratorArgument } from '../types';\n\nexport type RawDecorator = {\n name: string;\n arguments: DecoratorArgument[];\n};\n\n/**\n * Enumerate decorators on a TS node and classify their argument values without\n * going through the registry. Used by read-side consumers (type resolver,\n * extension extraction) that only need decorator names + argument values.\n */\nexport function readNodeDecorators(node: Node, typeChecker?: TypeChecker): RawDecorator[] {\n if (!ts.canHaveDecorators(node)) {\n return [];\n }\n const decorators = ts.getDecorators(node);\n if (!decorators || decorators.length === 0) {\n return [];\n }\n\n const output: RawDecorator[] = [];\n for (const decorator of decorators) {\n const { expression } = decorator;\n let name: string | undefined;\n let argumentExpressions: readonly ts.Expression[] = [];\n\n if (ts.isCallExpression(expression)) {\n argumentExpressions = expression.arguments;\n name = readDecoratorName(expression.expression);\n } else {\n name = readDecoratorName(expression);\n }\n\n if (!name) {\n continue;\n }\n\n output.push({\n name,\n arguments: argumentExpressions.map((a) => buildDecoratorArgument(a, typeChecker)),\n });\n }\n return output;\n}\n\nexport function findDecoratorByName(\n node: Node,\n name: string,\n typeChecker?: TypeChecker,\n): RawDecorator | undefined {\n return readNodeDecorators(node, typeChecker).find((d) => d.name === name);\n}\n\nexport function findDecoratorsByName(\n node: Node,\n name: string,\n typeChecker?: TypeChecker,\n): RawDecorator[] {\n return readNodeDecorators(node, typeChecker).filter((d) => d.name === name);\n}\n\nexport function hasDecoratorNamed(node: Node, name: string, typeChecker?: TypeChecker): boolean {\n return readNodeDecorators(node, typeChecker).some((d) => d.name === name);\n}\n\nfunction readDecoratorName(expression: ts.Node): string | undefined {\n if (ts.isIdentifier(expression)) {\n return expression.text;\n }\n if (ts.isPropertyAccessExpression(expression)) {\n return expression.name.text;\n }\n return undefined;\n}\n\nexport function buildDecoratorArgument(\n expr: Expression,\n typeChecker?: TypeChecker,\n): DecoratorArgument {\n if (\n ts.isStringLiteral(expr) ||\n ts.isNumericLiteral(expr) ||\n ts.isNoSubstitutionTemplateLiteral(expr)\n ) {\n return { raw: getInitializerValue(expr, typeChecker), kind: 'literal' };\n }\n\n if (expr.kind === ts.SyntaxKind.TrueKeyword) {\n return { raw: true, kind: 'literal' };\n }\n\n if (expr.kind === ts.SyntaxKind.FalseKeyword) {\n return { raw: false, kind: 'literal' };\n }\n\n if (expr.kind === ts.SyntaxKind.NullKeyword) {\n return { raw: null, kind: 'literal' };\n }\n\n if (\n ts.isPrefixUnaryExpression(expr) &&\n (expr.operator === ts.SyntaxKind.PlusToken || expr.operator === ts.SyntaxKind.MinusToken) &&\n ts.isNumericLiteral(expr.operand)\n ) {\n return { raw: getInitializerValue(expr, typeChecker), kind: 'literal' };\n }\n\n if (ts.isObjectLiteralExpression(expr)) {\n return { raw: getInitializerValue(expr, typeChecker), kind: 'object' };\n }\n\n if (ts.isArrayLiteralExpression(expr)) {\n return { raw: getInitializerValue(expr, typeChecker), kind: 'array' };\n }\n\n if (ts.isIdentifier(expr) || ts.isPropertyAccessExpression(expr)) {\n const value = getInitializerValue(expr, typeChecker);\n if (typeof value !== 'undefined') {\n return { raw: value, kind: 'identifier' };\n }\n return { raw: undefined, kind: 'unresolvable' };\n }\n\n return { raw: undefined, kind: 'unresolvable' };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { JSDocTag, Node, TypeNode } from 'typescript';\nimport * as ts from 'typescript';\nimport { getJSDocTags } from '../../typescript/js-doc';\nimport { transformJSDocComment } from '../../typescript/js-doc/utils';\nimport type {\n DecoratorArgument,\n DecoratorSource,\n DecoratorTypeArgument,\n JsDocSource,\n} from '../types';\nimport type { DecoratorSourceBuilderOptions, JsDocSourceBuilderOptions } from './types';\nimport { buildDecoratorArgument } from './utils';\n\n// -----------------------------------------------------------------------------\n// Decorator sources\n// -----------------------------------------------------------------------------\n\nexport function buildDecoratorSources(\n node: Node,\n options: DecoratorSourceBuilderOptions,\n): DecoratorSource[] {\n if (!ts.canHaveDecorators(node)) {\n return [];\n }\n\n const decorators = ts.getDecorators(node);\n if (!decorators || decorators.length === 0) {\n return [];\n }\n\n const output: DecoratorSource[] = [];\n for (const decorator of decorators) {\n const source = buildDecoratorSource(decorator, options);\n if (source) {\n output.push(source);\n }\n }\n return output;\n}\n\nfunction buildDecoratorSource(\n decorator: ts.Decorator,\n options: DecoratorSourceBuilderOptions,\n): DecoratorSource | undefined {\n const { expression } = decorator;\n\n let name: string | undefined;\n let argumentExpressions: readonly ts.Expression[] = [];\n let typeArgumentNodes: readonly ts.TypeNode[] = [];\n\n if (ts.isCallExpression(expression)) {\n argumentExpressions = expression.arguments;\n typeArgumentNodes = expression.typeArguments ?? [];\n name = readDecoratorName(expression.expression);\n } else {\n name = readDecoratorName(expression);\n }\n\n if (!name) {\n return undefined;\n }\n\n const decoratorArguments: DecoratorArgument[] = argumentExpressions.map(\n (arg) => buildDecoratorArgument(arg, options.typeChecker),\n );\n\n const decoratorTypeArguments: DecoratorTypeArgument[] = typeArgumentNodes.map(\n (typeNode) => ({ resolve: () => options.resolveTypeNode(typeNode) }),\n );\n\n const sourceFile = decorator.getSourceFile();\n const location = sourceFile ? {\n file: sourceFile.fileName,\n line: sourceFile.getLineAndCharacterOfPosition(decorator.getStart()).line + 1,\n } : undefined;\n\n return {\n name,\n arguments: decoratorArguments,\n typeArguments: decoratorTypeArguments,\n target: options.target,\n host: options.host,\n location,\n };\n}\n\nfunction readDecoratorName(expression: ts.Node): string | undefined {\n if (ts.isIdentifier(expression)) {\n return expression.text;\n }\n if (ts.isPropertyAccessExpression(expression)) {\n return expression.name.text;\n }\n return undefined;\n}\n\n// -----------------------------------------------------------------------------\n// JSDoc sources\n// -----------------------------------------------------------------------------\n\nexport function buildJsDocSources(\n node: Node,\n options: JsDocSourceBuilderOptions,\n): JsDocSource[] {\n const tags = getJSDocTags(node);\n if (tags.length === 0) {\n return [];\n }\n\n const output: JsDocSource[] = [];\n for (const tag of tags) {\n output.push(buildJsDocSource(tag, options));\n }\n return output;\n}\n\nfunction buildJsDocSource(\n tag: JSDocTag,\n options: JsDocSourceBuilderOptions,\n): JsDocSource {\n const tagName = tag.tagName.text;\n const text = transformJSDocComment(tag.comment);\n\n let parameterName: string | undefined;\n let typeNode: TypeNode | undefined;\n\n if (ts.isJSDocParameterTag(tag) || ts.isJSDocPropertyTag(tag)) {\n if (tag.name) {\n parameterName = readEntityName(tag.name);\n }\n typeNode = tag.typeExpression?.type;\n } else if (\n ts.isJSDocReturnTag(tag) ||\n ts.isJSDocTypeTag(tag) ||\n ts.isJSDocThisTag(tag)\n ) {\n typeNode = tag.typeExpression?.type;\n }\n\n const source: JsDocSource = {\n tag: tagName,\n target: options.target,\n host: options.host,\n };\n\n if (typeof text !== 'undefined') {\n source.text = text;\n }\n\n if (typeof parameterName !== 'undefined') {\n source.parameterName = parameterName;\n }\n\n if (typeNode) {\n const capturedTypeNode = typeNode;\n source.typeExpression = { resolve: () => options.resolveTypeNode(capturedTypeNode) };\n }\n\n return source;\n}\n\nfunction readEntityName(name: ts.EntityName): string | undefined {\n if (ts.isIdentifier(name)) {\n return name.text;\n }\n if (ts.isQualifiedName(name)) {\n const left = readEntityName(name.left);\n return left ? `${left}.${name.right.text}` : name.right.text;\n }\n return undefined;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node } from 'typescript';\nimport { matches, matchesJsDoc } from '../utils';\nimport type {\n DecoratorSource,\n HandlerContext,\n JsDocHandlerContext,\n JsDocMatch,\n JsDocSource,\n Match,\n} from '../types';\nimport { buildDecoratorSources, buildJsDocSources } from '../typescript';\nimport type { ApplyHandlersOptions } from './types';\n\ntype DecoratorHandlerLike<D> = {\n match: Match;\n apply: (ctx: HandlerContext, draft: D) => void;\n};\n\ntype JsDocHandlerLike<D> = {\n match: JsDocMatch;\n apply: (ctx: JsDocHandlerContext, draft: D) => void;\n};\n\nexport function buildHandlerContext(\n source: DecoratorSource,\n options: ApplyHandlersOptions,\n): HandlerContext {\n return {\n host: source.host,\n argument: (i) => source.arguments[i],\n arguments: () => source.arguments,\n typeArgument: (i) => source.typeArguments[i],\n typeArguments: () => source.typeArguments,\n parameterType: options.parameterType ?? (() => undefined),\n };\n}\n\nexport function buildJsDocHandlerContext(\n source: JsDocSource,\n options: ApplyHandlersOptions,\n): JsDocHandlerContext {\n return {\n host: source.host,\n source,\n parameterType: options.parameterType ?? (() => undefined),\n };\n}\n\nexport function applyDecoratorHandlers<D>(\n node: Node,\n handlers: DecoratorHandlerLike<D>[],\n draft: D,\n options: ApplyHandlersOptions,\n): void {\n if (handlers.length === 0 && !options.onUnmatchedDecorator) {\n return;\n }\n const sources = buildDecoratorSources(node, options);\n if (sources.length === 0) {\n return;\n }\n for (const source of sources) {\n let matched = 0;\n for (const handler of handlers) {\n if (matches(handler.match, source)) {\n handler.apply(buildHandlerContext(source, options), draft);\n matched += 1;\n }\n }\n if (matched === 0 && options.onUnmatchedDecorator) {\n // Prefer the decorator's own AST line if `buildDecoratorSources`\n // populated it; fall back to the host node's line otherwise.\n let file: string;\n let line: number;\n if (source.location) {\n file = source.location.file;\n line = source.location.line;\n } else {\n const sourceFile = node.getSourceFile();\n file = sourceFile.fileName;\n line = sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1;\n }\n options.onUnmatchedDecorator(\n {\n name: source.name,\n target: source.target,\n host: source.host,\n file,\n line,\n },\n source,\n );\n }\n }\n}\n\nexport function applyJsDocHandlers<D>(\n node: Node,\n handlers: JsDocHandlerLike<D>[],\n draft: D,\n options: ApplyHandlersOptions,\n): void {\n if (handlers.length === 0) {\n return;\n }\n const sources = buildJsDocSources(node, options);\n if (sources.length === 0) {\n return;\n }\n for (const source of sources) {\n for (const handler of handlers) {\n if (matchesJsDoc(handler.match, source)) {\n handler.apply(buildJsDocHandlerContext(source, options), draft);\n }\n }\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { MetadataError } from './base';\n\nexport class ValidatorError extends MetadataError {\n\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum ValidatorName {\n UNIQUE_ITEMS = 'uniqueItems',\n\n MINIMUM = 'minimum',\n MAXIMUM = 'maximum',\n MIN_ITEMS = 'minItems',\n MAX_ITEMS = 'maxItems',\n MIN_LENGTH = 'minLength',\n MAX_LENGTH = 'maxLength',\n\n MIN_DATE = 'minDate',\n MAX_DATE = 'maxDate',\n\n PATTERN = 'pattern',\n}\n\nexport const ValidatorErrorCode = {\n EXPECTED_NUMBER: 'VALIDATOR_EXPECTED_NUMBER',\n EXPECTED_DATE: 'VALIDATOR_EXPECTED_DATE',\n EXPECTED_STRING: 'VALIDATOR_EXPECTED_STRING',\n} as const;\n","/*\n * Copyright (c) 2021-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n ParameterDeclaration, \n PropertyDeclaration, \n PropertySignature, \n TypeAliasDeclaration,\n} from 'typescript';\nimport type { Validator } from '../../../core/types/validator';\nimport { ValidatorError } from '../../../core/error/validator';\nimport { getJSDocTags, transformJSDocComment } from '../js-doc';\nimport { ValidatorErrorCode, ValidatorName } from '../../../core/error/validator-codes';\n\nexport function getDeclarationValidators(\n declaration: PropertyDeclaration | TypeAliasDeclaration | PropertySignature | ParameterDeclaration,\n name?: string,\n): Record<string, Validator> {\n if (!declaration.parent) {\n return {};\n }\n\n const getCommentValue = (comment?: string) => comment && comment.split(' ')[0];\n\n const parameterTags = getSupportedParameterTags();\n const tags = getJSDocTags(declaration.parent, (tag) => {\n const { comment } = tag;\n const text : string = transformJSDocComment(comment);\n if (!comment) {\n return false;\n }\n\n const commentValue = getCommentValue(text);\n\n return parameterTags.some((value) => {\n if (value !== tag.tagName.text) {\n return false;\n }\n\n return !(name && name !== commentValue);\n });\n });\n\n function getErrorMsg(comment?: string, isValue = true) : string {\n if (!comment) {\n return undefined;\n }\n if (isValue) {\n const indexOf = comment.indexOf(' ');\n if (indexOf > 0) {\n return comment.substring(indexOf + 1);\n }\n return undefined;\n }\n\n return comment;\n }\n\n const validators : Record<string, Validator> = {};\n\n for (const tag of tags) {\n if (!tag.comment) {\n continue;\n }\n\n const name = tag.tagName.text;\n\n let comment = transformJSDocComment(tag.comment);\n comment = comment.substring(comment.indexOf(' ') + 1).trim();\n\n const value = getCommentValue(comment);\n\n switch (name) {\n case ValidatorName.UNIQUE_ITEMS:\n validators[name] = {\n message: getErrorMsg(comment, false),\n value: undefined,\n };\n break;\n case ValidatorName.MINIMUM:\n case ValidatorName.MAXIMUM:\n case ValidatorName.MIN_ITEMS:\n case ValidatorName.MAX_ITEMS:\n case ValidatorName.MIN_LENGTH:\n case ValidatorName.MAX_LENGTH:\n {\n const parsed = Number(value);\n if (!Number.isFinite(parsed)) {\n throw new ValidatorError({\n message: `@${name} validator expects a numeric value, got '${value}'.`,\n code: ValidatorErrorCode.EXPECTED_NUMBER,\n });\n }\n validators[name] = {\n message: getErrorMsg(comment),\n value: parsed,\n };\n }\n break;\n case ValidatorName.MIN_DATE:\n case ValidatorName.MAX_DATE:\n if (typeof value !== 'string') {\n throw new ValidatorError({\n message: `@${name} validator expects a date string, got '${typeof value}'.`,\n code: ValidatorErrorCode.EXPECTED_DATE,\n });\n }\n\n validators[name] = {\n message: getErrorMsg(comment),\n value,\n };\n break;\n case ValidatorName.PATTERN:\n if (typeof value !== 'string') {\n throw new ValidatorError({\n message: `@${name} validator expects a string pattern, got '${value}'.`,\n code: ValidatorErrorCode.EXPECTED_STRING,\n });\n }\n\n validators[name] = {\n message: getErrorMsg(comment),\n value: removeSurroundingQuotes(value),\n };\n break;\n default:\n if (name.toLowerCase().startsWith('is')) {\n const errorMsg = getErrorMsg(comment, false);\n if (errorMsg) {\n validators[name] = {\n message: errorMsg,\n value: undefined,\n };\n }\n }\n break;\n }\n }\n\n return validators;\n}\n\nfunction getSupportedParameterTags() {\n return [\n 'isString',\n 'isBoolean',\n 'isInt',\n 'isLong',\n 'isFloat',\n 'isDouble',\n 'isDate',\n 'isDateTime',\n\n 'minItems',\n 'maxItems',\n 'uniqueItems',\n 'minLength',\n 'maxLength',\n 'pattern',\n 'minimum',\n 'maximum',\n 'minDate',\n 'maxDate',\n ];\n}\n\nfunction removeSurroundingQuotes(str: string) {\n if (str.startsWith('`') && str.endsWith('`')) {\n return str.substring(1, str.length - 1);\n }\n if (str.startsWith('```') && str.endsWith('```')) {\n return str.substring(3, str.length - 3);\n }\n return str;\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { normalize } from 'node:path';\nimport { isBaseError } from '@ebec/core';\nimport type { Node, TypeNode } from 'typescript';\nimport { MetadataError } from './base';\n\nexport class ResolverError extends MetadataError {\n public readonly file?: string;\n\n public readonly line?: number;\n\n constructor(\n message: string,\n node?: Node | TypeNode,\n options?: boolean | { onlyCurrent?: boolean, cause?: unknown },\n ) {\n const opts = typeof options === 'boolean' ? { onlyCurrent: options } : options;\n const onlyCurrent = opts?.onlyCurrent ?? false;\n\n const parts: string[] = [message];\n let file: string | undefined;\n let line: number | undefined;\n\n if (node) {\n const location = prettyLocationOfNode(node);\n if (location) {\n parts.push(location.text);\n file = location.file;\n line = location.line;\n }\n\n parts.push(prettyTroubleCause(node, onlyCurrent));\n }\n\n super({\n message: parts.join('\\n'),\n cause: opts?.cause,\n });\n\n this.file = file;\n this.line = line;\n }\n}\n\nexport function isResolverError(input: unknown): input is ResolverError {\n if (!isBaseError(input)) {\n return false;\n }\n\n return 'file' in input && 'line' in input;\n}\n\nexport function prettyLocationOfNode(node: Node | TypeNode): {\n text: string,\n file: string,\n line?: number,\n} | undefined {\n try {\n const sourceFile = node.getSourceFile();\n if (!sourceFile) return undefined;\n\n const token = node.getFirstToken() || node.parent?.getFirstToken();\n const start = token ? sourceFile.getLineAndCharacterOfPosition(token.getStart()).line + 1 : undefined;\n const end = token ? sourceFile.getLineAndCharacterOfPosition(token.getEnd()).line + 1 : undefined;\n\n const normalizedFile = normalize(sourceFile.fileName);\n const startSuffix = start ? `:${start}` : '';\n const endSuffix = end ? `:${end}` : '';\n\n return {\n text: `At: ${normalizedFile}${startSuffix}${endSuffix}.`,\n file: sourceFile.fileName,\n line: start,\n };\n } catch {\n return undefined;\n }\n}\n\nexport function prettyTroubleCause(node: Node | TypeNode, onlyCurrent = false) {\n try {\n let name: string;\n if (onlyCurrent || !node.parent) {\n name = node.pos !== -1 ? node.getText() : (node as any).name.text;\n } else {\n name = node.parent.pos !== -1 ? node.parent.getText() : (node as any).parent.name.text;\n }\n\n return `This was caused by '${name}'`;\n } catch {\n return 'This was caused by an unknown node';\n }\n}\n","/*\n * Copyright (c) 2023-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node } from 'typescript';\nimport {\n type Registry,\n findDecoratorsByName,\n isExtensionMarker,\n namesForMarker,\n} from '../../../decorator';\nimport type { Extension } from '../../../../core/types/extension';\n\nexport function getNodeExtensions(node: Node, registry: Registry) : Extension[] {\n const names = namesForMarker(registry, isExtensionMarker);\n if (names.size === 0) {\n return [];\n }\n\n const output : Extension[] = [];\n for (const name of names) {\n const decorators = findDecoratorsByName(node, name);\n for (const decorator of decorators) {\n const keyArg = decorator.arguments[0];\n const valueArg = decorator.arguments[1];\n if (!keyArg || keyArg.kind !== 'literal' || typeof keyArg.raw !== 'string') {\n continue;\n }\n if (!valueArg || valueArg.kind === 'unresolvable' || typeof valueArg.raw === 'undefined') {\n continue;\n }\n output.push({ key: keyArg.raw, value: valueArg.raw as never });\n }\n }\n return output;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { ArrayType, SubResolverContext, Type } from '../types';\n\nexport function resolveArrayType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isArrayTypeNode(typeNode)) {\n return undefined;\n }\n\n return {\n typeName: TypeName.ARRAY,\n elementType: ctx.resolveType(\n typeNode.elementType,\n ctx.parentNode,\n ctx.context,\n ),\n } as ArrayType;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node } from 'typescript';\nimport {\n SyntaxKind,\n canHaveModifiers,\n getModifiers,\n} from 'typescript';\n\n\nexport class ResolverBase {\n protected hasPublicModifier(node: Node) {\n if (!canHaveModifiers(node)) {\n return true;\n }\n\n const modifiers = getModifiers(node);\n if (!modifiers) {\n return true;\n }\n\n return modifiers.every(\n (modifier) => modifier.kind !== SyntaxKind.ProtectedKeyword && modifier.kind !== SyntaxKind.PrivateKeyword,\n );\n }\n\n protected hasStaticModifier(node: Node) {\n if (!canHaveModifiers(node)) {\n return false;\n }\n\n const modifiers = getModifiers(node);\n\n return modifiers && modifiers.some((modifier) => modifier.kind === SyntaxKind.StaticKeyword);\n }\n\n protected isAccessibleParameter(node: Node) {\n // No modifiers\n if (!canHaveModifiers(node)) {\n return false;\n }\n\n const modifiers = getModifiers(node);\n if (!modifiers) {\n return false;\n }\n\n // public || public readonly\n if (modifiers.some((modifier) => modifier.kind === SyntaxKind.PublicKeyword)) {\n return true;\n }\n\n // readonly, not private readonly, not public readonly\n const isReadonly = modifiers.some((modifier) => modifier.kind === SyntaxKind.ReadonlyKeyword);\n const isProtectedOrPrivate = modifiers.some(\n (modifier) => modifier.kind === SyntaxKind.ProtectedKeyword ||\n modifier.kind === SyntaxKind.PrivateKeyword,\n );\n\n return isReadonly && !isProtectedOrPrivate;\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport type {\n Node,\n TypeChecker,\n TypeNode,\n} from 'typescript';\nimport { SyntaxKind, displayPartsToString } from 'typescript';\nimport { hasOwnProperty } from '../../../core/utils';\nimport { ResolverError } from '../../../core/error/resolver';\n\nexport function getNodeDescription(\n node: Node,\n typeChecker: TypeChecker,\n) {\n if (!hasOwnProperty(node, 'name')) {\n return undefined;\n }\n\n const symbol = typeChecker.getSymbolAtLocation(node.name as Node);\n if (!symbol) {\n return undefined;\n }\n\n /**\n * TODO: Workaround for what seems like a bug in the compiler\n * Warrants more investigation and possibly a PR against typescript\n */\n if (node.kind === SyntaxKind.Parameter) {\n // TypeScript won't parse jsdoc if the flag is 4, i.e. 'Property'\n symbol.flags = 0;\n }\n\n const comments = symbol.getDocumentationComment(typeChecker);\n if (comments.length) {\n return displayPartsToString(comments);\n }\n\n return undefined;\n}\n\nexport function toTypeNodeOrFail(\n typeChecker: TypeChecker,\n ...args: Parameters<TypeChecker['typeToTypeNode']>\n) : TypeNode {\n const output = typeChecker.typeToTypeNode(...args);\n if (typeof output === 'undefined') {\n throw new ResolverError('Type could not be transformed to TypeNode.');\n }\n\n return output;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport type { SubResolverContext, Type } from '../types';\nimport { toTypeNodeOrFail } from '../utils';\n\nexport function resolveIndexedAccessType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isIndexedAccessTypeNode(typeNode)) {\n return undefined;\n }\n\n // Variant 1: T[number] or T[string]\n if (\n typeNode.indexType.kind === ts.SyntaxKind.NumberKeyword ||\n typeNode.indexType.kind === ts.SyntaxKind.StringKeyword\n ) {\n const numberIndexType = typeNode.indexType.kind === ts.SyntaxKind.NumberKeyword;\n const objectType = ctx.typeChecker.getTypeFromTypeNode(typeNode.objectType);\n const type = numberIndexType ? objectType.getNumberIndexType() : objectType.getStringIndexType();\n if (type === undefined) {\n throw new ResolverError(\n `Could not determine ${numberIndexType ? 'number' : 'string'} index on ${ctx.typeChecker.typeToString(objectType)}`,\n typeNode,\n );\n }\n return ctx.resolveType(\n toTypeNodeOrFail(ctx.typeChecker, type, undefined, undefined),\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n }\n\n // Variant 2: T['key'] or T[0]\n if (\n ts.isLiteralTypeNode(typeNode.indexType) &&\n (\n ts.isStringLiteral(typeNode.indexType.literal) ||\n ts.isNumericLiteral(typeNode.indexType.literal)\n )\n ) {\n const hasType = (node: ts.Node | undefined): node is ts.HasType => node !== undefined &&\n Object.prototype.hasOwnProperty.call(node, 'type');\n\n const symbol = ctx.typeChecker.getPropertyOfType(\n ctx.typeChecker.getTypeFromTypeNode(typeNode.objectType),\n typeNode.indexType.literal.text,\n );\n\n if (symbol === undefined) {\n throw new ResolverError(\n `Could not determine the keys on ${ctx.typeChecker.typeToString(ctx.typeChecker.getTypeFromTypeNode(typeNode.objectType))}`,\n typeNode,\n );\n }\n\n if (hasType(symbol.valueDeclaration) && symbol.valueDeclaration.type) {\n return ctx.resolveType(\n symbol.valueDeclaration.type,\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n }\n\n const declaration = ctx.typeChecker.getTypeOfSymbolAtLocation(symbol, typeNode.objectType);\n try {\n return ctx.resolveType(\n toTypeNodeOrFail(ctx.typeChecker, declaration, undefined, undefined),\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n } catch (err) {\n throw new ResolverError(\n `Could not determine the keys on ${ctx.typeChecker.typeToString(declaration)}`,\n typeNode,\n { cause: err },\n );\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { IntersectionType, SubResolverContext, Type } from '../types';\n\nexport function resolveIntersectionType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isIntersectionTypeNode(typeNode)) {\n return undefined;\n }\n\n const members = typeNode.types.map(\n (type) => ctx.resolveType(type, ctx.parentNode, ctx.context),\n );\n\n return {\n typeName: TypeName.INTERSECTION,\n members,\n } as IntersectionType;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport type { \n AnyType, \n EnumType, \n SubResolverContext, \n Type, \n} from '../types';\n\nexport function resolveLiteralType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (typeNode.kind === ts.SyntaxKind.NullKeyword) {\n return {\n typeName: TypeName.ENUM,\n members: [null],\n } as EnumType;\n }\n\n if (\n typeNode.kind === ts.SyntaxKind.AnyKeyword ||\n typeNode.kind === ts.SyntaxKind.UnknownKeyword\n ) {\n return { typeName: TypeName.ANY } as AnyType;\n }\n\n if (ts.isLiteralTypeNode(typeNode)) {\n return {\n typeName: TypeName.ENUM,\n members: [getLiteralValue(typeNode)],\n } as EnumType;\n }\n\n if (typeNode.kind === ts.SyntaxKind.TemplateLiteralType) {\n const type = ctx.typeChecker.getTypeFromTypeNode(ctx.referencer || typeNode);\n if (type.isUnion() && type.types.every((t) => t.isStringLiteral())) {\n return {\n typeName: TypeName.ENUM,\n members: type.types.map(\n (t: ts.StringLiteralType) => t.value,\n ),\n } as EnumType;\n }\n\n throw new ResolverError(\n `Could not resolve type: ${ctx.typeChecker.typeToString(ctx.typeChecker.getTypeFromTypeNode(typeNode), typeNode)}`,\n typeNode,\n );\n }\n\n if (ts.isParenthesizedTypeNode(typeNode)) {\n return ctx.resolveType(\n typeNode.type,\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n }\n\n if (\n typeNode.kind === ts.SyntaxKind.ObjectKeyword ||\n ts.isFunctionTypeNode(typeNode)\n ) {\n return { typeName: TypeName.OBJECT };\n }\n\n return undefined;\n}\n\nexport function getLiteralValue(typeNode: ts.LiteralTypeNode): string | number | boolean | null {\n let value: boolean | number | string | null;\n switch (typeNode.literal.kind) {\n case ts.SyntaxKind.TrueKeyword:\n value = true;\n break;\n case ts.SyntaxKind.FalseKeyword:\n value = false;\n break;\n case ts.SyntaxKind.StringLiteral:\n value = typeNode.literal.text;\n break;\n case ts.SyntaxKind.NumericLiteral:\n value = Number.parseFloat(typeNode.literal.text);\n break;\n case ts.SyntaxKind.NullKeyword:\n value = null;\n break;\n default:\n if (Object.prototype.hasOwnProperty.call(typeNode.literal, 'text')) {\n value = (typeNode.literal as ts.LiteralExpression).text;\n } else {\n throw new ResolverError(\n `Couldn't resolve literal node: ${typeNode.literal.getText()}`,\n typeNode.literal,\n );\n }\n }\n return value;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { JSDocTagName } from '../../js-doc';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { ResolverProperty, SubResolverContext, Type } from '../types';\nimport { toTypeNodeOrFail } from '../utils';\n\nexport function resolveMappedType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isMappedTypeNode(typeNode) || !ctx.referencer) {\n return undefined;\n }\n\n const type = ctx.typeChecker.getTypeFromTypeNode(ctx.referencer);\n const mappedTypeNode = typeNode;\n const { typeChecker } = ctx;\n\n const getDeclaration = (prop: ts.Symbol) => prop.declarations && (prop.declarations[0] as ts.Declaration | undefined);\n\n const isIgnored = (prop: ts.Symbol) => {\n const declaration = getDeclaration(prop);\n const tagNames = prop.getJsDocTags();\n const tagNameIndex = tagNames.findIndex((tag) => tag.name === JSDocTagName.IGNORE);\n if (tagNameIndex >= 0) {\n return true;\n }\n return (\n !!declaration &&\n !ts.isPropertyDeclaration(declaration) &&\n !ts.isPropertySignature(declaration) &&\n !ts.isParameter(declaration)\n );\n };\n\n const properties: ResolverProperty[] = type\n .getProperties()\n .filter((property) => !isIgnored(property))\n .map((property) => {\n const declaration = getDeclaration(property) as\n ts.PropertySignature |\n ts.PropertyDeclaration |\n ts.ParameterDeclaration |\n undefined;\n\n // Normalize +? (PlusToken) to ? (QuestionToken) so property helpers treat it as optional\n const overrideToken = mappedTypeNode.questionToken?.kind === ts.SyntaxKind.PlusToken ?\n ts.factory.createToken(ts.SyntaxKind.QuestionToken) :\n mappedTypeNode.questionToken;\n\n if (declaration && ts.isPropertySignature(declaration)) {\n return { ...ctx.propertyFromSignature(declaration, overrideToken), name: property.getName() };\n }\n if (declaration && (ts.isPropertyDeclaration(declaration) || ts.isParameter(declaration))) {\n return { ...ctx.propertyFromDeclaration(declaration, overrideToken), name: property.getName() };\n }\n\n let required = (property.flags & ts.SymbolFlags.Optional) === 0;\n\n const typeNode2 = toTypeNodeOrFail(\n typeChecker,\n typeChecker.getTypeOfSymbolAtLocation(property, typeNode),\n undefined,\n ts.NodeBuilderFlags.NoTruncation,\n );\n if (mappedTypeNode.questionToken && mappedTypeNode.questionToken.kind === ts.SyntaxKind.MinusToken) {\n required = true;\n } else if (\n mappedTypeNode.questionToken &&\n (\n mappedTypeNode.questionToken.kind === ts.SyntaxKind.QuestionToken ||\n mappedTypeNode.questionToken.kind === ts.SyntaxKind.PlusToken\n )\n ) {\n required = false;\n }\n\n return {\n name: property.getName(),\n required,\n deprecated: false,\n type: ctx.resolveType(typeNode2, typeNode, ctx.context, ctx.referencer),\n validators: {},\n };\n });\n\n return {\n typeName: TypeName.NESTED_OBJECT_LITERAL,\n properties,\n };\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport {\n JSDocTagName,\n getJSDocTagComment,\n hasJSDocTag,\n} from '../../js-doc';\nimport { getDeclarationValidators } from '../../validator';\nimport { TypeName } from '../../../../core/types/type-name';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport { isStringType } from '../../../../core/types/type-guards';\nimport type { \n NestedObjectLiteralType, \n ResolverProperty, \n SubResolverContext, \n Type, \n} from '../types';\n\nexport function resolveObjectLiteralType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isTypeLiteralNode(typeNode)) {\n return undefined;\n }\n\n const properties: ResolverProperty[] = typeNode.members\n .filter((member) => ts.isPropertySignature(member))\n .reduce((res, propertySignature: ts.PropertySignature) => {\n if (!propertySignature.type) {\n throw new ResolverError('No valid type found for property declaration.', propertySignature);\n }\n\n const type = ctx.resolveType(\n propertySignature.type,\n propertySignature,\n ctx.context,\n );\n\n const property: ResolverProperty = {\n deprecated: hasJSDocTag(propertySignature, JSDocTagName.DEPRECATED),\n example: ctx.getNodeExample(propertySignature),\n extensions: ctx.getNodeExtensions(propertySignature),\n default: getJSDocTagComment(propertySignature, JSDocTagName.DEFAULT),\n description: ctx.getNodeDescription(propertySignature),\n format: getNodeFormat(propertySignature),\n name: getPropertyName(propertySignature),\n required: !propertySignature.questionToken,\n type,\n validators: getDeclarationValidators(propertySignature) || {},\n };\n\n return [property, ...res];\n }, [] as ResolverProperty[]);\n\n const indexMember = typeNode.members.find(\n (member) => ts.isIndexSignatureDeclaration(member),\n );\n let additionalType: Type | undefined;\n\n if (indexMember) {\n const indexSignatureDeclaration = indexMember as ts.IndexSignatureDeclaration;\n const indexType = ctx.resolveType(\n indexSignatureDeclaration.parameters[0].type as ts.TypeNode,\n ctx.parentNode,\n ctx.context,\n );\n\n if (!isStringType(indexType)) {\n throw new ResolverError('Only string indexes are supported.', typeNode);\n }\n\n additionalType = ctx.resolveType(\n indexSignatureDeclaration.type,\n ctx.parentNode,\n ctx.context,\n );\n }\n\n return {\n additionalProperties: indexMember && additionalType,\n typeName: TypeName.NESTED_OBJECT_LITERAL,\n properties,\n } as NestedObjectLiteralType;\n}\n\nfunction getNodeFormat(\n node: ts.PropertySignature | ts.PropertyDeclaration | ts.ParameterDeclaration,\n) {\n return getJSDocTagComment(node, JSDocTagName.FORMAT);\n}\n\nfunction getPropertyName(node: ts.PropertySignature): string {\n if (ts.isIdentifier(node.name)) {\n return node.name.text;\n }\n\n if (ts.isStringLiteral(node.name) || ts.isNumericLiteral(node.name)) {\n return node.name.text;\n }\n\n return node.name.getText();\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node, TypeNode } from 'typescript';\nimport { SyntaxKind } from 'typescript';\nimport {\n NumericKind,\n type Registry,\n type ResolverMarker,\n hasDecoratorNamed,\n namesForMarker,\n numericMarkerKind,\n tagsForMarker,\n} from '../../../decorator';\nimport { getJSDocTagNames } from '../../js-doc';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { NeverType, PrimitiveType, VoidType } from '../types';\n\nconst NUMERIC_KIND_TO_TYPE_NAME: Record<string, string> = {\n [NumericKind.Int]: TypeName.INTEGER,\n [NumericKind.Long]: TypeName.LONG,\n [NumericKind.Float]: TypeName.FLOAT,\n [NumericKind.Double]: TypeName.DOUBLE,\n};\n\nexport class PrimitiveResolver {\n protected registry: Registry;\n\n constructor(registry: Registry) {\n this.registry = registry;\n }\n\n resolve(node: TypeNode, parentNode?: Node) : PrimitiveType | NeverType | VoidType | undefined {\n const resolved = this.resolveSyntaxKind(node.kind);\n if (resolved) {\n if (resolved === 'string') {\n return { typeName: TypeName.STRING };\n }\n\n if (resolved === 'void') {\n return { typeName: TypeName.VOID };\n }\n\n if (resolved === 'boolean') {\n return { typeName: TypeName.BOOLEAN };\n }\n\n if (resolved === 'undefined') {\n return { typeName: TypeName.UNDEFINED };\n }\n\n if (resolved === 'null') {\n // todo: check\n return undefined;\n }\n\n if (resolved === 'never') {\n return { typeName: TypeName.NEVER };\n }\n\n if (resolved === 'bigint') {\n return { typeName: TypeName.BIGINT };\n }\n\n if (resolved === 'number') {\n if (!parentNode) {\n return { typeName: TypeName.DOUBLE };\n }\n\n // For each numeric kind: check decorator handlers first (preset\n // may rename `@IsInt`), then JSDoc handlers (preset may rename\n // `@isInt`). Both lookups use the registry markers.\n const presentJsDocTags = new Set(\n getJSDocTagNames(parentNode).map((tag) => tag.toLowerCase()),\n );\n for (const kind of [NumericKind.Int, NumericKind.Long, NumericKind.Float, NumericKind.Double] as const) {\n const matchKind = (m: ResolverMarker) => numericMarkerKind(m) === kind;\n\n const decoratorNames = namesForMarker(this.registry, matchKind);\n for (const name of decoratorNames) {\n if (hasDecoratorNamed(parentNode, name)) {\n return { typeName: NUMERIC_KIND_TO_TYPE_NAME[kind] } as PrimitiveType;\n }\n }\n\n const jsDocTags = tagsForMarker(this.registry, matchKind);\n for (const tag of jsDocTags) {\n if (presentJsDocTags.has(tag.toLowerCase())) {\n return { typeName: NUMERIC_KIND_TO_TYPE_NAME[kind] } as PrimitiveType;\n }\n }\n }\n\n return { typeName: TypeName.DOUBLE };\n }\n }\n\n return undefined;\n }\n\n resolveSyntaxKind(syntaxKind: SyntaxKind) {\n switch (syntaxKind) {\n case SyntaxKind.StringKeyword:\n return 'string';\n case SyntaxKind.BooleanKeyword:\n return 'boolean';\n case SyntaxKind.VoidKeyword:\n return 'void';\n case SyntaxKind.UndefinedKeyword:\n return 'undefined';\n case SyntaxKind.NullKeyword:\n return 'null';\n case SyntaxKind.NumberKeyword:\n return 'number';\n case SyntaxKind.BigIntKeyword:\n return 'bigint';\n case SyntaxKind.NeverKeyword:\n return 'never';\n default:\n return undefined;\n }\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { EnumDeclaration, EnumMember, TypeChecker } from 'typescript';\nimport { JSDocTagName, hasJSDocTag } from '../../js-doc';\nimport { TypeName } from '../../../../core/types/type-name';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport type {\n RefEnumType, \n RefObjectType, \n ReferenceType, \n Type,\n} from '../types';\nimport { getNodeDescription } from '../utils';\nimport { ResolverBase } from './base';\n\nexport class ReferenceResolver extends ResolverBase {\n protected typeChecker : TypeChecker;\n\n constructor(typeChecker: TypeChecker) {\n super();\n\n this.typeChecker = typeChecker;\n }\n\n public merge(referenceTypes: ReferenceType[]): ReferenceType {\n if (referenceTypes.length === 1) {\n return referenceTypes[0];\n }\n\n if (referenceTypes.every((refType) => refType.refName === TypeName.REF_ENUM)) {\n return this.mergeManyRefEnums(referenceTypes as RefEnumType[]);\n }\n\n if (referenceTypes.every((refType) => refType.refName === TypeName.REF_OBJECT)) {\n return this.mergeManyRefObjects(referenceTypes as RefObjectType[]);\n }\n\n throw new ResolverError(\n `These resolved type merge rules are not defined: ${JSON.stringify(referenceTypes)}`,\n );\n }\n\n public mergeManyRefEnums(many: RefEnumType[]): RefEnumType {\n let merged = this.mergeRefEnums(many[0], many[1]);\n for (let i = 2; i < many.length; ++i) {\n merged = this.mergeRefEnums(merged, many[i]);\n }\n\n return merged;\n }\n\n public mergeRefEnums(first: RefEnumType, second: RefEnumType): RefEnumType {\n let description : string | undefined;\n if (first.description || second.description) {\n if (!first.description) {\n description = second.description;\n } else if (!second.description) {\n description = first.description;\n } else {\n description = `${first.description}\\n${second.description}`;\n }\n }\n\n return {\n typeName: TypeName.REF_ENUM,\n example: first.example || second.example,\n description,\n members: [\n ...(first.members || []),\n ...(second.members || []),\n ],\n memberNames: [\n ...(first.memberNames || []),\n ...(second.memberNames || []),\n ],\n refName: first.refName,\n deprecated: first.deprecated || second.deprecated,\n };\n }\n\n public mergeManyRefObjects(many: RefObjectType[]) {\n let merged = this.mergeRefObject(many[0], many[1]);\n for (let i = 2; i < many.length; ++i) {\n merged = this.mergeRefObject(merged, many[i]);\n }\n return merged;\n }\n\n public mergeRefObject(first: RefObjectType, second: RefObjectType) : RefObjectType {\n let description : string | undefined;\n if (first.description || second.description) {\n if (!first.description) {\n description = second.description;\n } else if (!second.description) {\n description = first.description;\n } else {\n description = `${first.description}\\n${second.description}`;\n }\n }\n\n const properties = [\n ...first.properties,\n ...second.properties.filter((prop) => first.properties.every((firstProp) => firstProp.name !== prop.name)),\n ];\n\n let additionalProperties : Type | undefined;\n if (first.additionalProperties || second.additionalProperties) {\n if (!first.additionalProperties) {\n additionalProperties = second.additionalProperties;\n } else if (!second.additionalProperties) {\n additionalProperties = first.additionalProperties;\n } else {\n additionalProperties = {\n typeName: TypeName.UNION,\n members: [first.additionalProperties, second.additionalProperties],\n };\n }\n }\n\n return {\n typeName: TypeName.REF_OBJECT,\n description,\n properties,\n additionalProperties,\n refName: first.refName,\n deprecated: first.deprecated || second.deprecated,\n example: first.example || second.example,\n };\n }\n\n transformEnum(declaration: EnumDeclaration, enumName: string) : RefEnumType {\n const isNotUndefined = <T>(item: T): item is Exclude<T, undefined> => item !== undefined;\n\n const enums = declaration.members.map(this.typeChecker.getConstantValue.bind(this.typeChecker)).filter(isNotUndefined);\n const enumNames = declaration.members.map((e) => e.name.getText()).filter(isNotUndefined);\n\n return {\n typeName: TypeName.REF_ENUM,\n description: getNodeDescription(declaration, this.typeChecker),\n members: enums as string[],\n memberNames: enumNames,\n refName: enumName,\n deprecated: hasJSDocTag(declaration, JSDocTagName.DEPRECATED),\n };\n }\n\n transformEnumMember(declaration: EnumMember, enumName: string) : RefEnumType {\n return {\n typeName: TypeName.REF_ENUM,\n refName: enumName,\n members: [this.typeChecker.getConstantValue(declaration)!],\n memberNames: [declaration.name.getText()],\n deprecated: hasJSDocTag(declaration, JSDocTagName.DEPRECATED),\n };\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type {\n SubResolverContext,\n TupleType,\n Type,\n} from '../types';\n\nexport function resolveTupleType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isTupleTypeNode(typeNode)) {\n return undefined;\n }\n\n const elements = typeNode.elements.map((element) => {\n const isNamed = ts.isNamedTupleMember(element);\n const actualType = isNamed ? element.type : element;\n return {\n type: ctx.resolveType(actualType, ctx.parentNode, ctx.context),\n ...(isNamed && { name: element.name.text }),\n };\n });\n\n return {\n typeName: TypeName.TUPLE,\n elements,\n } as TupleType;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport type { SubResolverContext, Type } from '../types';\nimport { toTypeNodeOrFail } from '../utils';\n\nexport function resolveTypeOperatorType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isTypeOperatorNode(typeNode)) {\n return undefined;\n }\n\n if (typeNode.operator === ts.SyntaxKind.KeyOfKeyword) {\n const type = ctx.typeChecker.getTypeFromTypeNode(typeNode);\n try {\n return ctx.resolveType(\n toTypeNodeOrFail(ctx.typeChecker, type, undefined, ts.NodeBuilderFlags.NoTruncation),\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n } catch (err) {\n const indexedTypeName = ctx.typeChecker.typeToString(\n ctx.typeChecker.getTypeFromTypeNode(typeNode.type),\n );\n throw new ResolverError(\n `Could not determine the keys on ${indexedTypeName}`,\n typeNode,\n { cause: err },\n );\n }\n }\n\n if (typeNode.operator === ts.SyntaxKind.ReadonlyKeyword) {\n return ctx.resolveType(typeNode.type, typeNode, ctx.context, ctx.referencer);\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { SubResolverContext, Type, UnionType } from '../types';\n\nexport function resolveUnionType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isUnionTypeNode(typeNode)) {\n return undefined;\n }\n\n const members = typeNode.types.map(\n (type) => ctx.resolveType(type, ctx.parentNode, ctx.context),\n );\n\n return {\n typeName: TypeName.UNION,\n members,\n } as UnionType;\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isEnumDeclaration, isEnumMember } from 'typescript';\nimport * as ts from 'typescript';\nimport {\n hasDecoratorNamed,\n isDeprecatedMarker,\n namesForMarker,\n tagsForMarker,\n} from '../../decorator';\nimport type { IReferenceTypeRegistry, IResolverContext } from '../../../core/types/metadata';\nimport { TypeName, UtilityTypeName } from '../../../core/types/type-name';\n\nimport type { Extension } from '../../../core/types/extension';\nimport {\n JSDocTagName,\n getJSDocTagComment,\n getJSDocTagNames,\n hasJSDocTag,\n} from '../js-doc';\nimport { getDeclarationValidators } from '../validator';\nimport { getInitializerValue } from '../initializer';\nimport { ResolverError } from '../../../core/error/resolver';\nimport { getNodeExtensions } from './extension';\nimport {\n PrimitiveResolver,\n ReferenceResolver,\n ResolverBase,\n resolveArrayType,\n resolveIndexedAccessType,\n resolveIntersectionType,\n resolveLiteralType,\n resolveMappedType,\n resolveObjectLiteralType,\n resolveTupleType,\n resolveTypeOperatorType,\n resolveUnionType,\n} from './sub';\nimport { getLiteralValue } from './sub/literal';\nimport {\n isRefAliasType,\n isRefObjectType,\n} from '../../../core/types/type-guards';\nimport type {\n BufferType,\n DateTimeType,\n DateType,\n NestedObjectLiteralType,\n OverrideToken,\n RefEnumType,\n ReferenceType,\n ResolverProperty,\n SubResolverContext,\n Type,\n TypeNodeResolverContext,\n UsableDeclaration,\n} from './types';\nimport { getNodeDescription } from './utils';\n\nexport class TypeNodeResolver extends ResolverBase {\n private static readonly MAX_DEPTH = 50;\n\n private readonly typeNode : ts.TypeNode;\n\n private readonly current: IResolverContext & IReferenceTypeRegistry;\n\n private readonly parentNode?: ts.Node;\n\n private context: TypeNodeResolverContext;\n\n private readonly referencer : ts.TypeNode | undefined;\n\n private readonly depth: number;\n\n private readonly primitiveResolver : PrimitiveResolver;\n\n private readonly referenceResolver : ReferenceResolver;\n\n constructor(\n typeNode: ts.TypeNode,\n current: IResolverContext & IReferenceTypeRegistry,\n parentNode?: ts.Node,\n context?: TypeNodeResolverContext,\n referencer?: ts.TypeNode,\n depth?: number,\n ) {\n super();\n\n this.typeNode = typeNode;\n this.current = current;\n this.parentNode = parentNode;\n this.context = context || {};\n this.referencer = referencer;\n this.depth = depth ?? 0;\n\n this.primitiveResolver = new PrimitiveResolver(current.registry);\n this.referenceResolver = new ReferenceResolver(current.typeChecker);\n }\n\n /**\n * @deprecated Use resolverCache.clear() on the context instead.\n * Kept for backward compatibility — no-ops since cache is now instance-scoped.\n */\n public static clearCache() {\n // Cache is now instance-scoped via IResolverContext.resolverCache.\n // This method is a no-op for backward compatibility.\n }\n\n public resolve(): Type {\n if (this.depth > TypeNodeResolver.MAX_DEPTH) {\n throw new ResolverError(\n `Type resolution exceeded maximum depth of ${TypeNodeResolver.MAX_DEPTH}. This usually indicates deeply nested or circular generics.`,\n this.typeNode,\n );\n }\n\n const ctx = this.createSubResolverContext();\n\n const result = this.primitiveResolver.resolve(this.typeNode, this.parentNode) ??\n resolveLiteralType(this.typeNode, ctx) ??\n resolveArrayType(this.typeNode, ctx) ??\n resolveUnionType(this.typeNode, ctx) ??\n resolveIntersectionType(this.typeNode, ctx) ??\n resolveObjectLiteralType(this.typeNode, ctx) ??\n resolveTupleType(this.typeNode, ctx) ??\n resolveMappedType(this.typeNode, ctx) ??\n this.resolveConditionalType() ??\n resolveTypeOperatorType(this.typeNode, ctx) ??\n resolveIndexedAccessType(this.typeNode, ctx) ??\n this.resolveTypeReference();\n\n if (!result) {\n this.throwUnknownType();\n }\n\n return result;\n }\n\n private createSubResolverContext(): SubResolverContext {\n return {\n typeChecker: this.current.typeChecker,\n current: this.current,\n parentNode: this.parentNode,\n context: this.context,\n referencer: this.referencer,\n resolveType: (typeNode, parentNode, context, referencer) => (\n this.resolveNestedType(typeNode, parentNode, context, referencer)\n ),\n propertyFromSignature: (sig, overrideToken) => this.propertyFromSignature(sig, overrideToken),\n propertyFromDeclaration: (decl, overrideToken) => (\n this.propertyFromDeclaration(decl, overrideToken)\n ),\n getNodeDescription: (node) => this.getNodeDescription(node),\n getNodeExample: (node) => this.getNodeExample(node),\n getNodeExtensions: (node) => this.getNodeExtensions(node),\n };\n }\n\n private resolveNestedType(\n typeNode: ts.TypeNode,\n parentNode?: ts.Node,\n context?: TypeNodeResolverContext,\n referencer?: ts.TypeNode,\n ): Type {\n return new TypeNodeResolver(\n typeNode,\n this.current,\n parentNode,\n context,\n referencer,\n this.depth + 1,\n ).resolve();\n }\n\n private throwUnknownType(): never {\n throw new ResolverError(`Unknown type: ${ts.SyntaxKind[this.typeNode.kind]}`, this.typeNode);\n }\n\n // ------------------------------------------------------------------\n // Conditional type resolution (kept inline — deeply coupled to reference handling)\n // ------------------------------------------------------------------\n\n private resolveConditionalType(): Type | undefined {\n if (!ts.isConditionalTypeNode(this.typeNode)) {\n return undefined;\n }\n\n // When inside a generic type alias (context has entries) and we\n // have a usage-site node (referencer), resolve via the referencer\n // so the checker evaluates with concrete type arguments (#782).\n if (Object.keys(this.context).length > 0 && this.referencer) {\n return this.resolveTypeViaChecker(this.referencer);\n }\n\n // Delegate conditional type evaluation to the TypeScript type\n // checker. The checker can evaluate any conditional directly,\n // including complex patterns like `typeof globalThis extends\n // { onmessage: any } ? {} : X` from @types/node (#753).\n return this.resolveTypeViaChecker(this.typeNode);\n }\n\n // ------------------------------------------------------------------\n // Type reference resolution (kept inline — deeply coupled to caching/utility types)\n // ------------------------------------------------------------------\n\n private resolveTypeReference(): Type | undefined {\n if (this.typeNode.kind !== ts.SyntaxKind.TypeReference) {\n return undefined;\n }\n\n const typeReference = this.typeNode as ts.TypeReferenceNode;\n\n if (typeReference.typeName.kind === ts.SyntaxKind.Identifier) {\n if (\n typeReference.typeName.text === 'Record' &&\n typeReference.typeArguments\n ) {\n return {\n additionalProperties: this.resolveNestedType(\n typeReference.typeArguments[1],\n this.parentNode,\n this.context,\n ),\n typeName: TypeName.NESTED_OBJECT_LITERAL,\n properties: [],\n } as NestedObjectLiteralType;\n }\n\n const specialReference = TypeNodeResolver.resolveSpecialReference(typeReference.typeName);\n if (typeof specialReference !== 'undefined') {\n return specialReference;\n }\n\n if (typeReference.typeName.text === 'Date') {\n return this.getDateType(this.parentNode);\n }\n\n if (\n typeReference.typeName.text === 'Buffer' ||\n typeReference.typeName.text === 'Readable'\n ) {\n return { typeName: TypeName.BUFFER };\n }\n\n if (\n typeReference.typeName.text === 'Array' &&\n typeReference.typeArguments &&\n typeReference.typeArguments.length >= 1\n ) {\n return {\n typeName: TypeName.ARRAY,\n elementType: this.resolveNestedType(\n typeReference.typeArguments[0],\n this.parentNode,\n this.context,\n ),\n };\n }\n\n if (\n typeReference.typeName.text === 'Promise' &&\n typeReference.typeArguments &&\n typeReference.typeArguments.length === 1\n ) {\n return this.resolveNestedType(\n typeReference.typeArguments[0],\n this.parentNode,\n this.context,\n );\n }\n\n if (typeReference.typeName.text === 'String') {\n return { typeName: TypeName.STRING };\n }\n\n if (this.context[typeReference.typeName.text]) {\n return this.resolveNestedType(\n this.context[typeReference.typeName.text],\n this.parentNode,\n this.context,\n );\n }\n\n if (TypeNodeResolver.isCheckerResolvableUtilityType(typeReference.typeName.text)) {\n return this.resolveUtilityTypeViaChecker(typeReference);\n }\n }\n\n try {\n const referenceType = this.getReferenceType(typeReference);\n\n this.current.addReferenceType(referenceType);\n return referenceType;\n } catch (err) {\n // When the model declaration walker fails (e.g. for global types\n // like Headers, Request, Response from @types/node that use\n // complex declaration patterns — #753), fall back to the checker.\n // If the checker also fails, re-throw the original error.\n try {\n return this.resolveTypeViaChecker(typeReference);\n } catch {\n throw err;\n }\n }\n }\n\n // ------------------------------------------------------------------------\n // Utility Type(s)\n // ------------------------------------------------------------------------\n\n private static readonly CHECKER_RESOLVABLE_UTILITY_TYPES: ReadonlySet<string> = new Set([\n UtilityTypeName.NON_NULLABLE,\n UtilityTypeName.OMIT,\n UtilityTypeName.PARTIAL,\n UtilityTypeName.READONLY,\n UtilityTypeName.REQUIRED,\n UtilityTypeName.PICK,\n UtilityTypeName.EXTRACT,\n UtilityTypeName.EXCLUDE,\n UtilityTypeName.RETURN_TYPE,\n UtilityTypeName.PARAMETERS,\n UtilityTypeName.AWAITED,\n UtilityTypeName.INSTANCE_TYPE,\n UtilityTypeName.CONSTRUCTOR_PARAMETERS,\n ]);\n\n private static isCheckerResolvableUtilityType(name: string): boolean {\n return TypeNodeResolver.CHECKER_RESOLVABLE_UTILITY_TYPES.has(name);\n }\n\n private resolveUtilityTypeViaChecker(typeReference: ts.TypeReferenceNode): Type {\n // When type arguments reference unbound type parameters from our\n // context (e.g. `Awaited<T>` inside `type Box<T> = Awaited<T>`),\n // the checker can't resolve them from the declaration-site node.\n // Use the referencer (usage-site node like `Box<Promise<Foo>>`)\n // which the checker CAN resolve with concrete type arguments.\n if (this.hasUnboundContextArgs(typeReference) && this.referencer) {\n return this.resolveTypeViaChecker(this.referencer);\n }\n\n return this.resolveTypeViaChecker(typeReference);\n }\n\n /**\n * Shared checker delegation: resolves a type node by letting the TS\n * type checker evaluate it, converting back to a TypeNode, and\n * recursively resolving the result.\n */\n private resolveTypeViaChecker(typeNode: ts.TypeNode): Type {\n const type = this.current.typeChecker.getTypeFromTypeNode(typeNode);\n // InTypeAlias prevents the node builder from emitting type alias\n // references (which could cause circular resolution when the utility\n // type is used inside a type alias declaration).\n const resolvedTypeNode = this.current.typeChecker.typeToTypeNode(\n type,\n undefined,\n ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.InTypeAlias,\n );\n\n // typeToTypeNode returns undefined for some edge cases (e.g. empty\n // tuples from Parameters<> of a no-arg function). Fall back to an\n // empty tuple type.\n if (!resolvedTypeNode) {\n return { typeName: TypeName.TUPLE, elements: [] };\n }\n\n return this.resolveNestedType(\n resolvedTypeNode,\n this.parentNode,\n this.context,\n );\n }\n\n /**\n * Check if a type reference has type arguments that reference unbound\n * type parameters from this.context (e.g. `Awaited<T>` where T is a\n * generic parameter mapped in context).\n */\n private hasUnboundContextArgs(typeReference: ts.TypeReferenceNode): boolean {\n if (!typeReference.typeArguments || Object.keys(this.context).length === 0) {\n return false;\n }\n\n return typeReference.typeArguments.some((arg) =>\n ts.isTypeReferenceNode(arg) &&\n ts.isIdentifier(arg.typeName) &&\n arg.typeName.text in this.context);\n }\n\n private static resolveSpecialReference(node: ts.Identifier) : Type | undefined {\n switch (node.text) {\n case 'Buffer':\n case 'DownloadBinaryData':\n case 'DownloadResource':\n return { typeName: TypeName.BUFFER } as BufferType;\n default:\n return undefined;\n }\n }\n\n private getDateType(parentNode?: ts.Node): DateType | DateTimeType {\n if (!parentNode) {\n return { typeName: TypeName.DATETIME };\n }\n const tags = getJSDocTagNames(parentNode).filter((name) => ['isDate', 'isDateTime'].includes(name));\n\n if (tags.length === 0) {\n return { typeName: TypeName.DATETIME };\n }\n\n switch (tags[0]) {\n case 'isDate':\n return { typeName: TypeName.DATE };\n default:\n return { typeName: TypeName.DATETIME };\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private static getDesignatedModels<T extends ts.Node>(nodes: T[], _typeName: string): T[] {\n return nodes;\n }\n\n private getEnumerateType(typeName: ts.EntityName): RefEnumType | undefined {\n const enumName = (typeName as ts.Identifier).text;\n let enumNodes = this.current.nodes.filter(\n (node) => node.kind === ts.SyntaxKind.EnumDeclaration && (node as any).name.text === enumName,\n );\n\n if (!enumNodes.length) {\n return undefined;\n }\n\n enumNodes = TypeNodeResolver.getDesignatedModels(enumNodes, enumName);\n\n if (enumNodes.length > 1) {\n throw new ResolverError(`Multiple matching enum found for enum ${enumName}; please make enum names unique.`);\n }\n\n const enumDeclaration = enumNodes[0] as ts.EnumDeclaration;\n\n const isNotUndefined = <T>(item: T): item is Exclude<T, undefined> => item !== undefined;\n\n const enums = enumDeclaration.members.map(this.current.typeChecker.getConstantValue.bind(this.current.typeChecker)).filter(isNotUndefined);\n const enumNames = enumDeclaration.members.map((e) => e.name.getText()).filter(isNotUndefined);\n\n return {\n typeName: TypeName.REF_ENUM,\n description: this.getNodeDescription(enumDeclaration),\n members: enums as string[],\n memberNames: enumNames,\n refName: enumName,\n deprecated: hasJSDocTag(enumDeclaration, JSDocTagName.DEPRECATED),\n };\n }\n\n private getReferenceType(node: ts.TypeReferenceType): ReferenceType {\n let type: ts.EntityName;\n if (ts.isTypeReferenceNode(node)) {\n type = node.typeName;\n } else if (ts.isExpressionWithTypeArguments(node)) {\n type = node.expression as ts.EntityName;\n } else {\n throw new ResolverError('Can\\'t resolve reference type.');\n }\n\n // Can't invoke getText on Synthetic Nodes\n let resolvableName = node.pos !== -1 ? node.getText() : (type as ts.Identifier).text;\n if (node.pos === -1 && 'typeArguments' in node && Array.isArray(node.typeArguments)) {\n // Add typeArguments for Synthetic nodes (e.g. Record<> in TestClassModel.indexedResponse)\n const argumentsString = node.typeArguments\n .map((arg) => {\n if (ts.isLiteralTypeNode(arg)) {\n return `'${String(getLiteralValue(arg))}'`;\n }\n const resolvedType = this.primitiveResolver.resolveSyntaxKind(arg.kind);\n if (\n typeof resolvedType === 'undefined'\n ) { return 'any'; }\n return resolvedType;\n });\n\n resolvableName += `<${argumentsString.join(', ')}>`;\n }\n\n const name = this.contextualizedName(resolvableName);\n\n this.typeArgumentsToContext(node, type, this.context);\n\n try {\n const existingType = this.current.resolverCache.getCachedType(name);\n if (existingType) {\n return existingType;\n }\n\n if (this.current.resolverCache.isInProgress(name)) {\n return this.createCircularDependencyResolver(name);\n }\n\n this.current.resolverCache.markInProgress(name);\n\n try {\n const refName = TypeNodeResolver.getRefTypeName(name);\n const declarations = this.getModelTypeDeclarations(type);\n const referenceTypes: ReferenceType[] = [];\n for (const declaration of declarations) {\n if (ts.isTypeAliasDeclaration(declaration)) {\n referenceTypes.push(\n this.getTypeAliasReference(\n declaration,\n name,\n node,\n ),\n );\n } else if (isEnumDeclaration(declaration)) {\n referenceTypes.push(this.referenceResolver.transformEnum(declaration, refName));\n } else if (isEnumMember(declaration)) {\n referenceTypes.push(this.referenceResolver.transformEnumMember(declaration, refName));\n } else {\n // todo: dont cast handle property-signature\n referenceTypes.push(\n this.getModelReference(\n declaration as ts.InterfaceDeclaration,\n name,\n ),\n );\n }\n }\n\n const referenceType = this.referenceResolver.merge(referenceTypes);\n\n this.current.resolverCache.setCachedType(name, referenceType);\n return referenceType;\n } finally {\n this.current.resolverCache.clearInProgress(name);\n }\n } catch (err) {\n throw new ResolverError(\n `There was a problem resolving type of '${name}'.`,\n node,\n { cause: err },\n );\n }\n }\n\n private getTypeAliasReference(\n declaration: ts.TypeAliasDeclaration,\n name: string,\n referencer: ts.TypeReferenceType,\n ): ReferenceType {\n const refName = TypeNodeResolver.getRefTypeName(name);\n\n if (declaration.type.kind === ts.SyntaxKind.TypeReference) {\n const innerRef = declaration.type as ts.TypeReferenceNode;\n // Record<K,V> and checker-resolvable utility types (Pick, Omit, etc.)\n // should not go through getReferenceType — resolveNestedType handles\n // them correctly via resolveTypeReference.\n const innerName = ts.isIdentifier(innerRef.typeName) ? innerRef.typeName.text : undefined;\n const skipReferenceType = innerName === UtilityTypeName.RECORD ||\n (innerName !== undefined && TypeNodeResolver.isCheckerResolvableUtilityType(innerName));\n\n if (!skipReferenceType) {\n const referenceType = this.getReferenceType(innerRef);\n if (referenceType.refName === refName) {\n return referenceType;\n }\n }\n }\n\n const type = this.resolveNestedType(\n declaration.type,\n declaration,\n this.context,\n this.referencer || referencer,\n );\n\n const example = this.getNodeExample(declaration);\n\n return {\n typeName: TypeName.REF_ALIAS,\n default: getJSDocTagComment(declaration, JSDocTagName.DEFAULT),\n description: this.getNodeDescription(declaration),\n refName,\n format: TypeNodeResolver.getNodeFormat(declaration),\n type,\n validators: getDeclarationValidators(declaration) || {},\n deprecated: hasJSDocTag(declaration, JSDocTagName.DEPRECATED),\n ...(example && { example }),\n };\n }\n\n private getModelReference(\n modelType: ts.InterfaceDeclaration | ts.ClassDeclaration,\n name: string,\n ) : ReferenceType {\n const example = this.getNodeExample(modelType);\n const description = this.getNodeDescription(modelType);\n const deprecatedDecoratorNames = namesForMarker(this.current.registry, isDeprecatedMarker);\n const deprecatedJsDocTags = tagsForMarker(this.current.registry, isDeprecatedMarker);\n const deprecated : boolean = [...deprecatedJsDocTags].some((tag) => hasJSDocTag(modelType, tag)) ||\n [...deprecatedDecoratorNames].some((name) => hasDecoratorNamed(modelType, name));\n\n // Handle toJSON methods\n if (!modelType.name) {\n throw new ResolverError('Can\\'t get Symbol from anonymous class', modelType);\n }\n const type = this.current.typeChecker.getTypeAtLocation(modelType.name);\n const toJSON = this.current.typeChecker.getPropertyOfType(type, 'toJSON');\n if (\n toJSON &&\n toJSON.valueDeclaration &&\n (\n ts.isMethodDeclaration(toJSON.valueDeclaration) ||\n ts.isMethodSignature(toJSON.valueDeclaration)\n )\n ) {\n let nodeType = toJSON.valueDeclaration.type;\n if (!nodeType) {\n const signature = this.current.typeChecker.getSignatureFromDeclaration(toJSON.valueDeclaration);\n if (signature) {\n const implicitType = this.current.typeChecker.getReturnTypeOfSignature(signature);\n nodeType = this.current.typeChecker.typeToTypeNode(implicitType, undefined, ts.NodeBuilderFlags.NoTruncation) as ts.TypeNode;\n } else {\n throw new ResolverError('Can\\'t get signature from toJson value declaration', modelType);\n }\n }\n\n return {\n refName: `${TypeNodeResolver.getRefTypeName(name)}Alias`,\n typeName: TypeName.REF_ALIAS,\n description,\n type: this.resolveNestedType(nodeType),\n deprecated,\n validators: {},\n ...(example && { example }),\n };\n }\n\n const properties = this.getModelProperties(modelType);\n const additionalProperties = this.getModelAdditionalProperties(modelType);\n const inheritedProperties = this.getModelInheritedProperties(modelType) || [];\n\n const referenceType: ReferenceType & { properties: ResolverProperty[] } = {\n additionalProperties,\n typeName: TypeName.REF_OBJECT,\n description,\n properties: inheritedProperties,\n refName: TypeNodeResolver.getRefTypeName(name),\n deprecated,\n ...(example && { example }),\n };\n\n referenceType.properties = referenceType.properties.concat(properties);\n\n return referenceType;\n }\n\n private static getRefTypeName(name: string): string {\n const sanitized = name\n // Structural characters → temporary placeholders\n .replace(/[<>]/g, '_')\n .replace(/[{}]/g, '_')\n .replace(/\\s+/g, '')\n // Delimiter characters → semantic names\n .replace(/,/g, '.')\n .replace(/'([^']*)'/g, '$1')\n .replace(/\"([^\"]*)\"/g, '$1')\n .replace(/&/g, '-and-')\n .replace(/\\|/g, '-or-')\n .replace(/\\[\\]/g, '-array')\n .replace(/([a-z]+):([a-z]+)/gi, '$1-$2')\n .replace(/;/g, '--')\n .replace(/([a-z]+)\\[([a-z]+)]/gi, '$1-at-$2')\n // Strip temporary placeholders (keep hyphens for semantic separators)\n .replace(/_/g, '');\n\n return encodeURIComponent(sanitized);\n }\n\n private contextualizedName(name: string): string {\n return Object.entries(\n this.context,\n ).reduce((acc, [key, entry]) => acc\n .replace(new RegExp(`<\\\\s*([^>]*\\\\s)*\\\\s*(${key})(\\\\s[^>]*)*\\\\s*>`, 'g'), `<$1${entry.getText()}$3>`)\n .replace(new RegExp(`<\\\\s*([^,]*\\\\s)*\\\\s*(${key})(\\\\s[^,]*)*\\\\s*,`, 'g'), `<$1${entry.getText()}$3,`)\n .replace(new RegExp(`,\\\\s*([^>]*\\\\s)*\\\\s*(${key})(\\\\s[^>]*)*\\\\s*>`, 'g'), `,$1${entry.getText()}$3>`)\n .replace(new RegExp(`<\\\\s*([^<]*\\\\s)*\\\\s*(${key})(\\\\s[^<]*)*\\\\s*<`, 'g'), `<$1${entry.getText()}$3<`), name);\n }\n\n private handleCachingAndCircularReferences(name: string, declarationResolver: () => ReferenceType): ReferenceType {\n try {\n const existingType = this.current.resolverCache.getCachedType(name);\n if (existingType) {\n return existingType;\n }\n\n if (this.current.resolverCache.isInProgress(name)) {\n return this.createCircularDependencyResolver(name);\n }\n\n this.current.resolverCache.markInProgress(name);\n\n try {\n const reference = declarationResolver();\n\n this.current.resolverCache.setCachedType(name, reference);\n\n this.current.addReferenceType(reference);\n\n return reference;\n } finally {\n this.current.resolverCache.clearInProgress(name);\n }\n } catch (err) {\n throw new ResolverError(\n `There was a problem resolving type of '${name}'.`,\n this.typeNode,\n { cause: err },\n );\n }\n }\n\n private createCircularDependencyResolver(refName: string) {\n const referenceType : ReferenceType = {\n deprecated: false,\n properties: [],\n typeName: TypeName.REF_OBJECT,\n refName,\n };\n\n this.current.registerDependencyResolver((referenceTypes) => {\n const realReferenceType : ReferenceType | undefined = referenceTypes[refName];\n if (!realReferenceType) {\n return;\n }\n\n referenceType.description = realReferenceType.description;\n if (realReferenceType.typeName === 'refObject' && referenceType.typeName === 'refObject') {\n referenceType.properties = realReferenceType.properties;\n }\n referenceType.typeName = realReferenceType.typeName as `${TypeName.REF_OBJECT}`;\n referenceType.refName = realReferenceType.refName;\n });\n\n return referenceType;\n }\n\n private static nodeIsUsable(node: ts.Node) : node is UsableDeclaration {\n switch (node.kind) {\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.TypeAliasDeclaration:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.EnumMember:\n return true;\n default:\n return false;\n }\n }\n\n private getModelTypeDeclarations(type: ts.EntityName) {\n let typeName = type.kind === ts.SyntaxKind.Identifier ? type.text : type.right.text;\n\n let symbol : ts.Symbol | undefined = this.getSymbolAtLocation(type);\n if (!symbol && type.kind === ts.SyntaxKind.QualifiedName) {\n const fullEnumSymbol = this.getSymbolAtLocation(type.left);\n symbol = fullEnumSymbol.exports?.get(typeName as any);\n }\n\n if (!symbol) {\n throw new ResolverError(\n `No symbol found for referenced type ${typeName}.`,\n );\n }\n\n const declarations = symbol.getDeclarations();\n if (!declarations || declarations.length === 0) {\n throw new ResolverError(\n `No declarations found for referenced type ${typeName}.`,\n );\n }\n\n if (symbol.escapedName !== typeName && symbol.escapedName !== 'default') {\n typeName = symbol.escapedName as string;\n }\n\n let modelTypes = declarations.filter((node) => {\n if (!TypeNodeResolver.nodeIsUsable(node) || !this.current.isExportedNode(node)) {\n return false;\n }\n\n const modelTypeDeclaration = node as UsableDeclaration;\n return (modelTypeDeclaration.name as ts.Identifier)?.text === typeName;\n });\n\n if (!modelTypes.length) {\n throw new ResolverError(\n `No matching model found for referenced type ${typeName}. If ${typeName} comes from a dependency, please create an interface in your own code that has the same structure. The compiler can not utilize interfaces from external dependencies.`,\n );\n }\n\n if (modelTypes.length > 1) {\n // remove types that are from typescript e.g. 'Account'\n modelTypes = modelTypes.filter((modelType) => modelType.getSourceFile()\n .fileName.replace(/\\\\/g, '/').toLowerCase().indexOf('node_modules/typescript') <= -1);\n\n modelTypes = TypeNodeResolver.getDesignatedModels(modelTypes, typeName);\n }\n\n return modelTypes;\n }\n\n private getModelTypeDeclaration(type: ts.EntityName) : UsableDeclaration {\n let typeName = type.kind === ts.SyntaxKind.Identifier ? type.text : type.right.text;\n\n const symbol = this.getSymbolAtLocation(type);\n const declarations = symbol.getDeclarations();\n if (!declarations || declarations.length === 0) {\n throw new ResolverError(\n `No models found for referenced type ${typeName}.`,\n );\n }\n\n if (symbol.escapedName !== typeName && symbol.escapedName !== 'default') {\n typeName = symbol.escapedName as string;\n }\n\n let modelTypes = declarations.filter((node) => {\n if (!TypeNodeResolver.nodeIsUsable(node) || !this.current.isExportedNode(node)) {\n return false;\n }\n\n const modelTypeDeclaration = node as UsableDeclaration;\n return (modelTypeDeclaration.name as ts.Identifier)?.text === typeName;\n });\n\n if (!modelTypes.length) {\n throw new ResolverError(\n `No matching model found for referenced type ${typeName}. If ${typeName} comes from a dependency, please create an interface in your own code that has the same structure. The compiler can not utilize interfaces from external dependencies.`,\n );\n }\n\n if (modelTypes.length > 1) {\n // remove types that are from typescript e.g. 'Account'\n modelTypes = modelTypes.filter((modelType) => modelType.getSourceFile()\n .fileName.replace(/\\\\/g, '/').toLowerCase().indexOf('node_modules/typescript') <= -1);\n\n modelTypes = TypeNodeResolver.getDesignatedModels(modelTypes, typeName);\n }\n if (modelTypes.length > 1) {\n const conflicts = modelTypes.map((modelType) => modelType.getSourceFile().fileName).join('\"; \"');\n throw new ResolverError(\n `Multiple matching models found for referenced type ${typeName}; please make model names unique. Conflicts found: \"${conflicts}\".`,\n );\n }\n\n return modelTypes[0] as UsableDeclaration;\n }\n\n private hasFlag(type: ts.Symbol | ts.Declaration, flag: number) {\n return (type.flags & flag) === flag;\n }\n\n private getSymbolAtLocation(type: ts.Node) : ts.Symbol {\n const symbol = this.current.typeChecker.getSymbolAtLocation(type) || ((type as any).symbol as ts.Symbol);\n // resolve alias if it is an alias, otherwise take symbol directly\n return (\n symbol &&\n this.hasFlag(symbol, ts.SymbolFlags.Alias) &&\n this.current.typeChecker.getAliasedSymbol(symbol)\n ) || symbol;\n }\n\n private getModelProperties(\n node: ts.InterfaceDeclaration | ts.ClassDeclaration,\n overrideToken?: OverrideToken,\n ) : ResolverProperty[] {\n const isIgnored = (e: ts.TypeElement | ts.ClassElement) => hasJSDocTag(e, JSDocTagName.IGNORE);\n\n // Interface model\n if (ts.isInterfaceDeclaration(node)) {\n return node.members\n .filter(\n (member) => !isIgnored(member) &&\n ts.isPropertySignature(member),\n ).map(\n (member) => this.propertyFromSignature(member as ts.PropertySignature, overrideToken),\n );\n }\n\n // Class model\n const properties = node.members\n .filter((member) => !isIgnored(member) &&\n member.kind === ts.SyntaxKind.PropertyDeclaration &&\n !this.hasStaticModifier(member) &&\n this.hasPublicModifier(member)) as Array<ts.PropertyDeclaration | ts.ParameterDeclaration>;\n\n const classConstructor = node.members.find(\n (member) => ts.isConstructorDeclaration(member),\n ) as ts.ConstructorDeclaration;\n\n if (classConstructor && classConstructor.parameters) {\n const constructorProperties = classConstructor.parameters.filter((parameter) => this.isAccessibleParameter(parameter));\n\n properties.push(...constructorProperties);\n }\n\n return properties.map((property) => this.propertyFromDeclaration(property, overrideToken));\n }\n\n private propertyFromSignature(propertySignature: ts.PropertySignature, overrideToken?: OverrideToken) {\n const identifier = propertySignature.name as ts.Identifier;\n\n if (!propertySignature.type) {\n throw new ResolverError('No valid type found for property declaration.');\n }\n\n let required = !propertySignature.questionToken;\n if (overrideToken && overrideToken.kind === ts.SyntaxKind.MinusToken) {\n required = true;\n } else if (overrideToken && overrideToken.kind === ts.SyntaxKind.QuestionToken) {\n required = false;\n }\n\n const property: ResolverProperty = {\n deprecated: hasJSDocTag(propertySignature, JSDocTagName.DEPRECATED),\n default: getJSDocTagComment(propertySignature, JSDocTagName.DEFAULT),\n description: this.getNodeDescription(propertySignature),\n example: this.getNodeExample(propertySignature),\n extensions: this.getNodeExtensions(propertySignature),\n format: TypeNodeResolver.getNodeFormat(propertySignature),\n name: identifier.text,\n required,\n type: this.resolveNestedType(\n propertySignature.type,\n propertySignature.type.parent,\n this.context,\n propertySignature.type,\n ),\n validators: getDeclarationValidators(propertySignature) || {},\n };\n return property;\n }\n\n private propertyFromDeclaration(\n propertyDeclaration: ts.PropertyDeclaration | ts.ParameterDeclaration,\n overrideToken?: OverrideToken,\n ) {\n const identifier = propertyDeclaration.name as ts.Identifier;\n let typeNode = propertyDeclaration.type;\n\n if (!typeNode) {\n const tsType = this.current.typeChecker.getTypeAtLocation(propertyDeclaration);\n typeNode = this.current.typeChecker.typeToTypeNode(tsType, undefined, ts.NodeBuilderFlags.NoTruncation);\n }\n\n if (!typeNode) {\n throw new ResolverError('No valid type found for property declaration.');\n }\n\n const type = this.resolveNestedType(typeNode, propertyDeclaration, this.context, typeNode);\n\n let required = !propertyDeclaration.questionToken && !propertyDeclaration.initializer;\n if (overrideToken && overrideToken.kind === ts.SyntaxKind.MinusToken) {\n required = true;\n } else if (overrideToken && overrideToken.kind === ts.SyntaxKind.QuestionToken) {\n required = false;\n }\n\n const property: ResolverProperty = {\n deprecated: hasJSDocTag(propertyDeclaration, JSDocTagName.DEPRECATED),\n default: getInitializerValue(propertyDeclaration.initializer, this.current.typeChecker),\n description: this.getNodeDescription(propertyDeclaration),\n example: this.getNodeExample(propertyDeclaration),\n extensions: this.getNodeExtensions(propertyDeclaration),\n format: TypeNodeResolver.getNodeFormat(propertyDeclaration),\n name: identifier.text,\n required,\n type,\n validators: getDeclarationValidators(propertyDeclaration) || {},\n };\n return property;\n }\n\n private getModelAdditionalProperties(node: UsableDeclaration) {\n if (node.kind === ts.SyntaxKind.InterfaceDeclaration) {\n const indexMember = node.members.find((member) => member.kind === ts.SyntaxKind.IndexSignature);\n if (!indexMember) {\n return undefined;\n }\n\n const indexSignatureDeclaration = indexMember as ts.IndexSignatureDeclaration;\n const indexType = this.resolveNestedType(\n indexSignatureDeclaration.parameters[0].type as ts.TypeNode,\n this.parentNode,\n this.context,\n );\n\n if (indexType.typeName !== 'string') {\n throw new ResolverError('Only string indexers are supported.', this.typeNode);\n }\n\n return this.resolveNestedType(indexSignatureDeclaration.type, this.parentNode, this.context);\n }\n\n return undefined;\n }\n\n private typeArgumentsToContext(\n type: ts.TypeReferenceNode | ts.ExpressionWithTypeArguments,\n targetEntity: ts.EntityName,\n context: TypeNodeResolverContext,\n ): TypeNodeResolverContext {\n // this.context = {};\n\n const declaration = this.getModelTypeDeclaration(targetEntity);\n if (typeof declaration === 'undefined' || !('typeParameters' in declaration)) {\n return context;\n }\n\n const { typeParameters } = declaration;\n\n if (typeParameters) {\n for (const [index, typeParameter] of typeParameters.entries()) {\n const typeArg = type.typeArguments && type.typeArguments[index];\n let resolvedType: ts.TypeNode;\n\n // Argument may be a forward reference from context\n if (typeArg && ts.isTypeReferenceNode(typeArg) && ts.isIdentifier(typeArg.typeName) && context[typeArg.typeName.text]) {\n resolvedType = context[typeArg.typeName.text];\n } else if (typeArg) {\n resolvedType = typeArg;\n } else if (typeParameter.default) {\n resolvedType = typeParameter.default;\n } else {\n throw new ResolverError(`Could not find a value for type parameter ${typeParameter.name.text}`, type);\n }\n\n this.context = {\n ...this.context,\n [typeParameter.name.text]: resolvedType,\n };\n }\n }\n return context;\n }\n\n private getModelInheritedProperties(\n modelTypeDeclaration: Exclude<UsableDeclaration, ts.PropertySignature | ts.TypeAliasDeclaration | ts.EnumMember>,\n ): ResolverProperty[] {\n let properties: ResolverProperty[] = [];\n\n const { heritageClauses } = modelTypeDeclaration;\n if (!heritageClauses) {\n return properties;\n }\n\n heritageClauses.forEach((clause) => {\n if (!clause.types) {\n return;\n }\n\n clause.types.forEach((t) => {\n const baseEntityName = t.expression as ts.EntityName;\n\n // create subContext\n const resetCtx = this.typeArgumentsToContext(t, baseEntityName, this.context);\n\n const referenceType = this.getReferenceType(t);\n if (referenceType) {\n if (isRefAliasType(referenceType)) {\n let type: Type = referenceType;\n while (isRefAliasType(type)) {\n type = type.type;\n }\n\n if (type.typeName === TypeName.REF_OBJECT) {\n properties = [...properties, ...type.properties];\n } else if (type.typeName === TypeName.NESTED_OBJECT_LITERAL) {\n properties = [...properties, ...type.properties];\n }\n }\n\n if (isRefObjectType(referenceType)) {\n referenceType.properties.forEach((property) => properties.push(property));\n }\n }\n\n // reset subContext\n this.context = resetCtx;\n });\n });\n\n return properties;\n }\n\n private getNodeDescription(node: UsableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.EnumDeclaration) {\n return getNodeDescription(node, this.current.typeChecker);\n }\n\n private static getNodeFormat(\n node: UsableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.EnumDeclaration,\n ) {\n return getJSDocTagComment(node, JSDocTagName.FORMAT);\n }\n\n private getNodeExample(node: UsableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.EnumDeclaration) {\n const example = getJSDocTagComment(node, JSDocTagName.EXAMPLE);\n\n if (example) {\n try {\n return JSON.parse(example);\n } catch {\n return example;\n }\n }\n\n return undefined;\n }\n\n protected getNodeExtensions(node: UsableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.EnumDeclaration) : Extension[] {\n return getNodeExtensions(node, this.current.registry);\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IResolverCache, ReferenceType } from './types';\n\nexport class ResolverCache implements IResolverCache {\n private referenceTypes = new Map<string, ReferenceType>();\n\n private inProgressTypes = new Set<string>();\n\n getCachedType(name: string): ReferenceType | undefined {\n return this.referenceTypes.get(name);\n }\n\n setCachedType(name: string, type: ReferenceType): void {\n this.referenceTypes.set(name, type);\n }\n\n isInProgress(name: string): boolean {\n return this.inProgressTypes.has(name);\n }\n\n markInProgress(name: string): void {\n this.inProgressTypes.add(name);\n }\n\n clearInProgress(name: string): void {\n this.inProgressTypes.delete(name);\n }\n\n clear(): void {\n this.referenceTypes.clear();\n this.inProgressTypes.clear();\n }\n}\n","/*\n * Copyright (c) 2021-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node } from 'typescript';\nimport {\n canHaveDecorators,\n getDecorators,\n isCallExpression,\n isNumericLiteral,\n isStringLiteral,\n} from 'typescript';\nimport type { NodeDecorator } from './types';\n\n/**\n * Get Decorators for a specific node.\n *\n * @param node\n * @param isMatching\n */\nexport function getNodeDecorators(\n node: Node,\n isMatching?: (data: NodeDecorator) => boolean,\n): NodeDecorator[] {\n if (!canHaveDecorators(node)) {\n return [];\n }\n\n const decorators = getDecorators(node);\n\n if (typeof decorators === 'undefined') {\n return [];\n }\n\n const items = decorators\n .map((d) => {\n const result: any = {\n arguments: [],\n typeArguments: [],\n };\n\n let x: any = d.expression;\n\n if (isCallExpression(x)) {\n if (x.arguments) {\n result.arguments = x.arguments.map((argument: any) => {\n if (isStringLiteral(argument) || isNumericLiteral(argument)) {\n return argument.text;\n }\n return argument;\n });\n }\n\n if (x.typeArguments) {\n result.typeArguments = x.typeArguments;\n }\n\n x = x.expression;\n }\n\n result.text = x.text || x.name.text;\n\n return result as NodeDecorator;\n });\n\n return typeof isMatching === 'undefined' ? items : items.filter(isMatching);\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { LocatorInfo } from 'locter';\nimport { buildFilePath, locateMany } from 'locter';\nimport type { EntryPoint } from '../../core/config';\n\nexport async function scanSourceFiles(input: EntryPoint) : Promise<string[]> {\n const sources = Array.isArray(input) ? input : [input];\n const result: Set<string> = new Set<string>();\n\n const promises : Promise<LocatorInfo[]>[] = [];\n\n for (const source of sources) {\n if (typeof source === 'string') {\n promises.push(locateMany(source));\n } else {\n promises.push(locateMany(source.pattern, { path: source.cwd }));\n }\n }\n\n const groupMatches = await Promise.all(promises);\n const matches = groupMatches.flat();\n\n for (const match of matches) {\n result.add(buildFilePath(match));\n }\n\n return Array.from(result);\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject, load } from 'locter';\nimport { ConfigErrorCode } from '../../../core/error/config-codes';\nimport { ConfigError } from '../../../core/error/config';\nimport process from 'node:process';\nimport path from 'node:path';\nimport { convertCompilerOptionsFromJson } from 'typescript';\nimport type { TsConfig, TsconfigLoadContext } from './types';\n\nexport async function loadTSConfig(\n context: TsconfigLoadContext = {},\n) : Promise<TsConfig> {\n let fileName : string;\n let filePath : string;\n const cwd = context.cwd || process.cwd();\n\n if (typeof context.name === 'string') {\n if (path.isAbsolute(context.name)) {\n filePath = context.name;\n } else {\n filePath = path.resolve(cwd, context.name);\n }\n\n fileName = path.basename(filePath);\n } else {\n fileName = 'tsconfig.json';\n filePath = path.join(cwd, fileName);\n }\n\n const content = await load(filePath);\n if (!isObject(content)) {\n throw new ConfigError({\n message: `The tsconfig file '${filePath}' is malformed.`,\n code: ConfigErrorCode.TSCONFIG_MALFORMED,\n });\n }\n\n if (typeof content.compilerOptions !== 'undefined') {\n const { options: compilerOptions } = convertCompilerOptionsFromJson(\n content.compilerOptions,\n cwd,\n fileName,\n );\n\n content.compilerOptions = compilerOptions;\n }\n\n return content;\n}\n\nexport async function softLoadTsconfig(\n context: TsconfigLoadContext = {},\n) : Promise<TsConfig> {\n try {\n return await loadTSConfig(context);\n } catch {\n return {};\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Bump whenever the on-disk cache shape changes incompatibly\n * (Metadata, Controller, Method, Parameter, resolver type nodes,\n * or the cache wrapper itself). Old cache files with a different\n * version are rejected on read.\n */\nexport const CACHE_SCHEMA_VERSION = '3';\n\nexport const CACHE_FILE_PREFIX = '.trapi-metadata-';\nexport const CACHE_FILE_SUFFIX = '.json';\n\n/** 7 days. */\nexport const CACHE_DEFAULT_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { tmpdir } from 'node:os';\nimport path from 'node:path';\nimport crypto from 'node:crypto';\nimport process from 'node:process';\nimport type { CompilerOptions } from 'typescript';\nimport type { Registry } from '../decorator/types';\nimport { CACHE_DEFAULT_MAX_AGE_MS } from './constants';\nimport type { CacheOptions, CacheOptionsInput } from './types';\n\nexport function buildCacheOptions(input?: string | boolean | CacheOptionsInput) : CacheOptions {\n if (typeof input === 'string') {\n input = {\n enabled: true,\n directoryPath: input,\n };\n }\n\n if (typeof input === 'boolean') {\n input = { enabled: input };\n }\n\n input = input || {};\n\n let directoryPath = tmpdir();\n if (typeof input.directoryPath === 'string') {\n directoryPath = path.isAbsolute(input.directoryPath) ?\n input.directoryPath :\n path.join(process.cwd(), input.directoryPath);\n }\n\n return {\n fileName: input.fileName,\n directoryPath,\n enabled: input.enabled ?? true,\n maxAgeMs: normalizeMaxAgeMs(input.maxAgeMs),\n };\n}\n\nfunction normalizeMaxAgeMs(input: number | undefined): number {\n if (typeof input !== 'number' || !Number.isFinite(input) || input < 0) {\n // NaN, Infinity, negative, or absent → fall back to the default.\n // Only `0` (explicit disable) and positive finite values are honored.\n return CACHE_DEFAULT_MAX_AGE_MS;\n }\n return input;\n}\n\n// -----------------------------------------------------------------------------\n// Cache key composition\n// -----------------------------------------------------------------------------\n\nexport type CacheKeyParts = {\n schemaVersion: string;\n sourceFilesHash: string;\n compilerOptionsHash: string;\n registryHash: string;\n presetName?: string;\n};\n\n/**\n * Combines all key contributors into a single sha256 hex string. The order is\n * stable; each part is null-separated to avoid concatenation ambiguity.\n */\nexport function composeCacheKey(parts: CacheKeyParts): string {\n const hash = crypto.createHash('sha256');\n hash.update(parts.schemaVersion);\n hash.update('\\0');\n hash.update(parts.sourceFilesHash);\n hash.update('\\0');\n hash.update(parts.compilerOptionsHash);\n hash.update('\\0');\n hash.update(parts.registryHash);\n hash.update('\\0');\n hash.update(parts.presetName ?? '');\n return hash.digest('hex');\n}\n\n/**\n * Hash a stable JSON projection of `compilerOptions`. Sorting keys keeps the\n * output deterministic regardless of declaration order in tsconfig.json.\n */\nexport function hashCompilerOptions(options?: CompilerOptions): string {\n const hash = crypto.createHash('sha256');\n hash.update(stableStringify(options ?? {}));\n return hash.digest('hex');\n}\n\n/**\n * Hash the resolved registry's structural shape. Catches structural changes\n * (handler added/removed/renamed, marker changed, replaces policy changed)\n * AND most logic changes via `apply.toString()`. Misses changes that are\n * purely captured-variable shifts in factory-built handlers — acceptable\n * trade-off for catching local preset edits.\n */\nexport function hashRegistry(registry: Registry): string {\n const hash = crypto.createHash('sha256');\n const kinds = [\n 'controllers',\n 'methods',\n 'parameters',\n 'controllerJsDoc',\n 'methodJsDoc',\n 'parameterJsDoc',\n ] as const;\n for (const kind of kinds) {\n hash.update(kind);\n hash.update('\\0');\n const handlers = registry[kind] ?? [];\n for (const handler of handlers) {\n hash.update(stableStringify(handler.match));\n hash.update('\\0');\n hash.update(stableStringify(handler.marker ?? null));\n hash.update('\\0');\n hash.update(String(handler.replaces ?? ''));\n hash.update('\\0');\n hash.update(handler.apply.toString());\n hash.update('\\0');\n }\n hash.update('\\x01');\n }\n return hash.digest('hex');\n}\n\n/**\n * JSON.stringify with sorted object keys at every level. Functions and\n * undefined are omitted as usual; that's fine for the inputs we hash here.\n */\nfunction stableStringify(value: unknown): string {\n return JSON.stringify(value, (_key, val) => {\n if (val && typeof val === 'object' && !Array.isArray(val)) {\n const sorted: Record<string, unknown> = {};\n for (const k of Object.keys(val as Record<string, unknown>).sort()) {\n sorted[k] = (val as Record<string, unknown>)[k];\n }\n return sorted;\n }\n return val;\n });\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { parse as parseFlatted, stringify as stringifyFlatted } from 'flatted';\nimport { buildFilePath as joinFilePath, locateMany } from 'locter';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport {\n CACHE_FILE_PREFIX,\n CACHE_FILE_SUFFIX,\n CACHE_SCHEMA_VERSION,\n} from './constants';\nimport { buildCacheOptions } from './utils';\nimport type {\n CacheData,\n CacheOptions,\n CacheOptionsInput,\n ICacheClient,\n} from './types';\n\nexport class CacheClient implements ICacheClient {\n private readonly options: CacheOptions;\n\n constructor(input?: string | boolean | CacheOptionsInput) {\n this.options = buildCacheOptions(input);\n }\n\n // -------------------------------------------------------------------------\n\n async save(data: CacheData): Promise<string | undefined> {\n if (!this.options.enabled) {\n return undefined;\n }\n\n await this.ensureDirectory();\n\n const filePath = this.resolveFilePath(data.cacheKey);\n // `flatted` is cycle-safe — it encodes self-references and back-edges\n // as integer indices into a flat array. Well-formed metadata uses\n // `refName` strings for cross-references and contains no cycles, but\n // we use `flatted` defensively so a future regression cannot crash\n // serialization or silently corrupt the cached graph.\n const payload = stringifyFlatted(data);\n\n // Atomic write: rename is atomic on POSIX, so concurrent generators\n // either see the previous file or the new one — never a half-written\n // truncation.\n const tmpPath = `${filePath}.${process.pid}.${crypto.randomBytes(6).toString('hex')}.tmp`;\n\n try {\n await fs.promises.writeFile(tmpPath, payload);\n await fs.promises.rename(tmpPath, filePath);\n } catch (err) {\n // Best-effort cleanup of the temp file if rename failed.\n try {\n await fs.promises.unlink(tmpPath);\n } catch {\n // ignore\n }\n throw err;\n }\n\n // Opportunistic eviction. Errors are ignored — eviction is a\n // housekeeping concern, not a correctness one.\n this.evict().catch(() => undefined);\n\n return filePath;\n }\n\n async get(cacheKey: string): Promise<CacheData | undefined> {\n if (!this.options.enabled) {\n return undefined;\n }\n\n const filePath = this.resolveFilePath(cacheKey);\n\n let content: string;\n try {\n content = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n } catch {\n return undefined;\n }\n\n let cache: CacheData;\n try {\n cache = parseFlatted(content) as CacheData;\n } catch {\n // Corrupt file — drop it so the next save can replace cleanly.\n await fs.promises.unlink(filePath).catch(() => undefined);\n return undefined;\n }\n\n if (\n !cache ||\n cache.cacheKey !== cacheKey ||\n cache.schemaVersion !== CACHE_SCHEMA_VERSION\n ) {\n return undefined;\n }\n\n return cache;\n }\n\n // -------------------------------------------------------------------------\n\n /**\n * Prune cache files older than `maxAgeMs`. No-op when disabled or when\n * `maxAgeMs <= 0`. Each unlink is best-effort — a concurrent generator\n * may have already removed the file.\n */\n async evict(): Promise<void> {\n if (!this.options.enabled || this.options.maxAgeMs <= 0) {\n return;\n }\n\n const pattern = this.options.fileName ?? `${CACHE_FILE_PREFIX}*${CACHE_FILE_SUFFIX}`;\n\n let entries: Awaited<ReturnType<typeof locateMany>>;\n try {\n entries = await locateMany(pattern, { path: this.options.directoryPath });\n } catch {\n return;\n }\n\n const cutoff = Date.now() - this.options.maxAgeMs;\n\n await Promise.all(entries.map(async (entry) => {\n const filePath = joinFilePath(entry);\n try {\n const stat = await fs.promises.stat(filePath);\n if (stat.mtimeMs < cutoff) {\n await fs.promises.unlink(filePath);\n }\n } catch {\n // ignore — file may have been removed by another process\n }\n }));\n }\n\n // -------------------------------------------------------------------------\n\n private resolveFilePath(cacheKey: string): string {\n // The internal pipeline always passes a sha256 hex digest, but the\n // public `ICacheClient` accepts any string. Reject anything that\n // could break out of `directoryPath` via `path.join`'s normalization\n // (`../`, absolute paths, embedded separators, NUL bytes).\n if (!CACHE_KEY_PATTERN.test(cacheKey)) {\n throw new Error(`Invalid cacheKey: must match ${CACHE_KEY_PATTERN}`);\n }\n const fileName = this.options.fileName ??\n `${CACHE_FILE_PREFIX}${cacheKey}${CACHE_FILE_SUFFIX}`;\n return path.join(this.options.directoryPath, fileName);\n }\n\n private async ensureDirectory(): Promise<void> {\n // Don't memoize — the directory may be removed externally (temp\n // cleanup, another process) at any time. `mkdir(recursive: true)`\n // is a no-op when the directory already exists, so re-running it\n // on every save is cheap and self-healing.\n await fs.promises.mkdir(this.options.directoryPath, { recursive: true });\n }\n}\n\n// Hex digest from sha256 (64 chars) is the canonical caller, but allow\n// any printable ASCII without separators / dots up to a sane length so\n// custom callers (and the suffix-bearing tmp path) keep working.\nconst CACHE_KEY_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isBaseError } from '@ebec/core';\nimport { MetadataError } from './base';\n\nexport class GeneratorError extends MetadataError {\n\n}\n\nexport function isGeneratorError(input: unknown): input is GeneratorError & { code: string } {\n if (!isBaseError(input)) {\n return false;\n }\n\n return typeof input.code === 'string';\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const GeneratorErrorCode = {\n CONTROLLER_NO_SOURCE_FILE: 'GENERATOR_CONTROLLER_NO_SOURCE_FILE',\n CONTROLLER_NO_NAME: 'GENERATOR_CONTROLLER_NO_NAME',\n PARAMETER_GENERATION_FAILED: 'GENERATOR_PARAMETER_GENERATION_FAILED',\n BODY_PARAMETER_DUPLICATE: 'GENERATOR_BODY_PARAMETER_DUPLICATE',\n BODY_FORM_CONFLICT: 'GENERATOR_BODY_FORM_CONFLICT',\n STRICT_UNMATCHED_DECORATORS: 'GENERATOR_STRICT_UNMATCHED_DECORATORS',\n} as const;\nexport type GeneratorErrorCode = typeof GeneratorErrorCode[keyof typeof GeneratorErrorCode];\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport { isClassDeclaration, isMethodDeclaration } from 'typescript';\nimport type { Node } from 'typescript';\nimport type { BaseType } from '../types/resolver';\nimport { ParameterErrorCode } from '../types/index.ts';\nimport { MetadataError } from './base';\n\ntype UnsupportedTypeContext = {\n decoratorName: string,\n propertyName: string,\n type: BaseType,\n node?: Node\n};\n\ntype UnsupportedMethodContext = {\n decoratorName: string,\n propertyName: string,\n method: string,\n node?: Node\n};\n\ntype PathMatchInvalidContext = {\n decoratorName: string,\n propertyName: string,\n path: string,\n node?: Node\n};\n\ntype ScopeRequiredContext = {\n decoratorName: string,\n node?: Node\n};\n\nexport class ParameterError extends MetadataError {\n static typeUnsupported(context: UnsupportedTypeContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not support '${context.type.typeName}' type${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.TYPE_UNSUPPORTED,\n });\n }\n\n static methodUnsupported(context: UnsupportedMethodContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not support method '${context.method}'${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.METHOD_UNSUPPORTED,\n });\n }\n\n static invalidPathMatch(context: PathMatchInvalidContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not exist in path '${context.path}'${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.PATH_MISMATCH,\n });\n }\n\n static scopeRequired(context: ScopeRequiredContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}() requires a scope argument${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.SCOPE_REQUIRED,\n });\n }\n\n static invalidExampleSchema() {\n return new ParameterError({\n message: 'The @example JSDoc tag contains invalid JSON.',\n code: ParameterErrorCode.INVALID_EXAMPLE,\n });\n }\n\n public static getCurrentLocation(node: Node) {\n const parts : string[] = [];\n\n if (isMethodDeclaration(node.parent)) {\n parts.push(node.parent.name.getText());\n\n if (isClassDeclaration(node.parent.parent)) {\n parts.unshift(node.parent.parent.name.text);\n }\n }\n\n return parts.join('.');\n }\n}\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from 'locter';\nimport * as ts from 'typescript';\nimport {\n type ApplyHandlersOptions,\n ParamKind,\n type ParameterDraft,\n applyDecoratorHandlers,\n applyJsDocHandlers,\n newParameterDraft,\n} from '../../../adapters/decorator';\nimport { getInitializerValue } from '../../../adapters/typescript/initializer';\nimport { getDeclarationValidators } from '../../../adapters/typescript/validator';\nimport {\n JSDocTagName,\n getJSDocTags,\n hasJSDocTag,\n transformJSDocComment,\n} from '../../../adapters/typescript/js-doc';\nimport { TypeNodeResolver } from '../../../adapters/typescript/resolver';\nimport {\n isArrayType,\n isNestedObjectLiteralType,\n isRefEnumType,\n isRefObjectType,\n isUnionType,\n} from '../../../core/types/type-guards';\nimport { TypeName } from '../../../core/types/type-name';\nimport {\n CollectionFormat,\n ParameterSource,\n} from '../../../core/types/parameter-source';\nimport { ParameterError } from '../../../core/error/parameter';\nimport type { IGeneratorContext } from '../../../core/types/metadata';\nimport type {\n BaseType,\n NestedObjectLiteralType,\n RefObjectType,\n Type,\n} from '../../../core/types/resolver';\nimport type { Extension } from '../../../core/types/extension';\nimport type { ArrayParameter, IParameterGenerator, Parameter } from '../../../core/types/parameter';\n\nconst BODY_SUPPORTED_METHODS = new Set(['delete', 'post', 'put', 'patch', 'get']);\n\nconst SUPPORTED_LEAF_TYPES = new Set<string>([\n TypeName.STRING,\n TypeName.INTEGER,\n TypeName.LONG,\n TypeName.FLOAT,\n TypeName.DOUBLE,\n TypeName.DATE,\n TypeName.DATETIME,\n TypeName.BUFFER,\n TypeName.BOOLEAN,\n TypeName.ENUM,\n]);\n\nexport class ParameterGenerator implements IParameterGenerator {\n private readonly parameter: ts.ParameterDeclaration;\n\n private readonly method: string;\n\n private readonly paths: string[];\n\n private readonly current: IGeneratorContext;\n\n constructor(\n parameter: ts.ParameterDeclaration,\n method: string,\n paths: string[],\n current: IGeneratorContext,\n ) {\n this.parameter = parameter;\n this.method = method;\n this.paths = paths.length === 0 ? [''] : paths;\n this.current = current;\n }\n\n public generate(): Parameter[] {\n const parameterName = this.getParameterName();\n const draft = newParameterDraft({ parameterName });\n\n const options = this.applyOptions(parameterName);\n applyDecoratorHandlers(this.parameter, this.current.registry.parameters, draft, options);\n applyJsDocHandlers(this.parameter, this.current.registry.parameterJsDoc, draft, options);\n\n // TS-resolved type\n const type = this.resolveType();\n draft.type = type;\n\n // Description from TS symbol's documentation comment.\n const description = this.getDescription();\n if (description) {\n draft.description = description;\n }\n\n // Deprecation: handler may have set it; otherwise check JSDoc on parameter.\n if (draft.deprecated === undefined && hasJSDocTag(this.parameter, JSDocTagName.DEPRECATED)) {\n draft.deprecated = true;\n }\n\n // Default value from TS initializer.\n const defaultValue = getInitializerValue(this.parameter.initializer, this.current.typeChecker, type);\n if (defaultValue !== undefined) {\n draft.default = defaultValue;\n }\n\n // Required: TS optionality and presence of initializer.\n draft.required = !this.parameter.questionToken && !this.parameter.initializer;\n\n // Examples from method-level JSDoc @example tags scoped to this parameter.\n const { examples, exampleLabels } = this.getJsDocExamples(parameterName);\n if (examples) {\n draft.examples = examples.map((value) => ({ value }));\n draft.exampleLabels = (exampleLabels ?? []).filter((l): l is string => l !== undefined);\n }\n\n // Declaration-level validators (e.g., @MaxLength annotations on the parameter).\n Object.assign(draft.validators, getDeclarationValidators(this.parameter, parameterName));\n\n // Apply default `in` if no handler claimed.\n if (!draft.in) {\n if (!BODY_SUPPORTED_METHODS.has(this.method)) {\n throw ParameterError.methodUnsupported({\n decoratorName: 'Body',\n propertyName: parameterName,\n method: this.method,\n node: this.parameter,\n });\n }\n draft.in = ParamKind.Body;\n }\n\n // Body validation requires the method to support a body.\n if ((draft.in === ParamKind.Body || draft.in === ParamKind.BodyProp) &&\n !BODY_SUPPORTED_METHODS.has(this.method)) {\n throw ParameterError.methodUnsupported({\n decoratorName: 'Body',\n propertyName: draft.name,\n method: this.method,\n node: this.parameter,\n });\n }\n\n return this.finalize(draft, type, parameterName, examples, exampleLabels);\n }\n\n private finalize(\n draft: ParameterDraft,\n type: Type,\n parameterName: string,\n examples: unknown[] | undefined,\n exampleLabels: Array<string | undefined> | undefined,\n ): Parameter[] {\n const kind = draft.in!;\n const wrappedExamples = examples ? examples.map((value) => ({ value })) : undefined;\n const filteredLabels = exampleLabels?.filter((l): l is string => l !== undefined);\n\n // Object decomposition for kinds that can carry an object payload.\n if ((kind === ParameterSource.QUERY || kind === ParameterSource.PATH) &&\n (isNestedObjectLiteralType(type) || isRefObjectType(type))) {\n const decomposed = this.decomposeObject(type, {\n in: kind === ParameterSource.QUERY ? ParameterSource.QUERY_PROP : ParameterSource.PATH,\n examples: wrappedExamples,\n exampleLabels: filteredLabels,\n extensions: draft.extensions,\n });\n if (kind === ParameterSource.PATH) {\n this.validatePathDecomposition(decomposed);\n }\n return decomposed;\n }\n\n if ((kind === ParameterSource.QUERY || kind === ParameterSource.QUERY_PROP) &&\n isArrayType(type)) {\n if (!this.isLeafTypeSupported(type.elementType)) {\n throw ParameterError.typeUnsupported({\n decoratorName: kind === ParameterSource.QUERY ? 'Query' : 'QueryProp',\n propertyName: draft.name,\n type: type.elementType,\n node: this.parameter,\n });\n }\n const arrayParameter: ArrayParameter = {\n ...this.draftToParameter(draft),\n collectionFormat: draft.collectionFormat ?? CollectionFormat.MULTI,\n type,\n };\n return [arrayParameter];\n }\n\n if ((kind === ParameterSource.QUERY || kind === ParameterSource.QUERY_PROP) &&\n !this.isLeafOrEnumOrUnion(type)) {\n throw ParameterError.typeUnsupported({\n decoratorName: kind === ParameterSource.QUERY ? 'Query' : 'QueryProp',\n propertyName: draft.name,\n type,\n node: this.parameter,\n });\n }\n\n if (kind === ParameterSource.PATH) {\n this.validatePathName(draft.name, parameterName);\n }\n\n return [this.draftToParameter(draft)];\n }\n\n private draftToParameter(draft: ParameterDraft): Parameter {\n return {\n allowEmptyValue: draft.allowEmptyValue,\n collectionFormat: draft.collectionFormat,\n default: draft.default,\n description: draft.description,\n examples: draft.examples.length > 0 ? draft.examples : undefined,\n exampleLabels: draft.exampleLabels.length > 0 ? draft.exampleLabels : undefined,\n extensions: draft.extensions,\n in: draft.in!,\n maxItems: draft.maxItems,\n minItems: draft.minItems,\n name: draft.name,\n parameterName: draft.parameterName,\n required: draft.required,\n type: draft.type!,\n deprecated: draft.deprecated,\n validators: draft.validators,\n };\n }\n\n private decomposeObject(\n type: NestedObjectLiteralType | RefObjectType,\n details: {\n in: `${ParameterSource}`;\n examples: { value: unknown }[] | undefined;\n exampleLabels: string[] | undefined;\n extensions: Extension[];\n },\n ): Parameter[] {\n if (type.properties.length === 0) {\n return [];\n }\n\n const parameterName = this.getParameterName();\n const initializerValue = getInitializerValue(this.parameter.initializer, this.current.typeChecker, type);\n const description = this.getDescription();\n const isParamOptional = !!this.parameter.questionToken;\n const isParamDeprecated = hasJSDocTag(this.parameter, JSDocTagName.DEPRECATED);\n\n const output: Parameter[] = [];\n for (const property of type.properties) {\n let propertyDefaultValue = property.default;\n if (typeof propertyDefaultValue === 'undefined' && isObject(initializerValue)) {\n propertyDefaultValue = (initializerValue as Record<string, unknown>)[property.name];\n }\n\n const required = isParamOptional ? false : property.required;\n\n output.push({\n extensions: [...details.extensions],\n in: details.in,\n examples: details.examples,\n exampleLabels: details.exampleLabels,\n default: propertyDefaultValue,\n description: property.description || description,\n name: property.name,\n parameterName,\n required,\n type: property.type,\n deprecated: property.deprecated || isParamDeprecated,\n validators: {},\n });\n }\n return output;\n }\n\n private pathContainsParam(name: string): boolean {\n // Match `{name}` literally — curly braces are their own boundaries.\n // For `:name`, require a word boundary after the name so `:id` doesn't\n // match `:id2` (substring), but it still matches when path-to-regexp\n // modifiers/constraints follow the name (`:id?`, `:id*`, `:id(\\\\d+)`).\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const colonPattern = new RegExp(`:${escaped}\\\\b`);\n const bracePattern = `{${name}}`;\n for (const p of this.paths) {\n if (p.includes(bracePattern) || colonPattern.test(p)) {\n return true;\n }\n }\n return false;\n }\n\n private validatePathDecomposition(decomposed: Parameter[]): void {\n for (const element of decomposed) {\n if (!this.pathContainsParam(element.name)) {\n throw ParameterError.invalidPathMatch({\n decoratorName: 'Path',\n propertyName: element.name,\n path: this.paths.join(' | '),\n node: this.parameter,\n });\n }\n }\n }\n\n private validatePathName(name: string, parameterName: string): void {\n const candidate = name || parameterName;\n if (!this.pathContainsParam(candidate)) {\n throw ParameterError.invalidPathMatch({\n decoratorName: 'Path',\n propertyName: candidate,\n path: this.paths.join(' | '),\n node: this.parameter,\n });\n }\n }\n\n private isLeafTypeSupported(type: BaseType): boolean {\n return SUPPORTED_LEAF_TYPES.has(type.typeName);\n }\n\n private isLeafOrEnumOrUnion(type: Type): boolean {\n return SUPPORTED_LEAF_TYPES.has(type.typeName) ||\n isRefEnumType(type) ||\n isUnionType(type);\n }\n\n private resolveType(): Type {\n let typeNode = this.parameter.type;\n if (!typeNode) {\n const t = this.current.typeChecker.getTypeAtLocation(this.parameter);\n typeNode = this.current.typeChecker.typeToTypeNode(\n t,\n undefined,\n ts.NodeBuilderFlags.NoTruncation,\n );\n }\n if (!typeNode) {\n throw new ParameterError({ message: `Could not resolve type for parameter '${this.getParameterName()}'.` });\n }\n return new TypeNodeResolver(typeNode, this.current, this.parameter).resolve();\n }\n\n private getParameterName(): string {\n if (!ts.isIdentifier(this.parameter.name)) {\n throw new ParameterError({ message: 'Destructured parameters are not supported. Use a simple identifier name.' });\n }\n return this.parameter.name.text;\n }\n\n private getDescription(): string {\n const symbol = this.current.typeChecker.getSymbolAtLocation(this.parameter.name);\n if (symbol) {\n const comments = symbol.getDocumentationComment(this.current.typeChecker);\n if (comments.length > 0) {\n return ts.displayPartsToString(comments);\n }\n }\n return '';\n }\n\n private getJsDocExamples(parameterName: string): {\n examples: unknown[] | undefined;\n exampleLabels: Array<string | undefined> | undefined;\n } {\n const exampleLabels: Array<string | undefined> = [];\n const tags = getJSDocTags(this.parameter.parent, (tag) => {\n const comment = transformJSDocComment(tag.comment);\n const isExample = (tag.tagName.text === JSDocTagName.EXAMPLE ||\n tag.tagName.escapedText === JSDocTagName.EXAMPLE) &&\n !!comment && comment.startsWith(parameterName);\n\n if (isExample && comment) {\n const hasExampleLabel = (comment.split(' ')[0].indexOf('.') || -1) > 0;\n exampleLabels.push(hasExampleLabel ?\n comment.split(' ')[0].split('.').slice(1).join('.') :\n undefined);\n }\n return isExample ?? false;\n });\n\n const examples = tags.map((tag) => (\n transformJSDocComment(tag.comment) || '')\n .replace(`${transformJSDocComment(tag.comment)?.split(' ')[0] || ''}`, '')\n .replace(/\\r/g, ''));\n\n if (examples.length === 0) {\n return { examples: undefined, exampleLabels: undefined };\n }\n\n try {\n return {\n examples: examples.map((example) => JSON.parse(example)),\n exampleLabels,\n };\n } catch {\n throw ParameterError.invalidExampleSchema();\n }\n }\n\n private applyOptions(parameterName: string): ApplyHandlersOptions {\n return {\n target: 'parameter',\n host: { name: parameterName, parentName: this.method },\n resolveTypeNode: (n) => new TypeNodeResolver(n, this.current).resolve(),\n typeChecker: this.current.typeChecker,\n parameterType: () => this.parameter.type ?\n new TypeNodeResolver(this.parameter.type, this.current).resolve() :\n undefined,\n onUnmatchedDecorator: (this.current.config.strict || this.current.config.onUnmatchedDecorator) ?\n (report) => this.current.reportUnmatchedDecorator?.(report) :\n undefined,\n };\n }\n}\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport { NodeBuilderFlags } from 'typescript';\nimport type {\n ClassDeclaration,\n Identifier,\n MethodDeclaration,\n TypeNode,\n} from 'typescript';\nimport {\n type ApplyHandlersOptions,\n applyDecoratorHandlers,\n applyJsDocHandlers,\n newMethodDraft,\n} from '../../../adapters/decorator';\nimport { GeneratorErrorCode } from '../../../core/error/generator-codes';\nimport { GeneratorError } from '../../../core/error/generator';\nimport type { BaseType } from '../../../core/types/resolver';\nimport { TypeNodeResolver } from '../../../adapters/typescript/resolver';\nimport { isVoidType } from '../../../core/types/type-guards';\nimport {\n JSDocTagName,\n getJSDocDescription,\n getJSDocTagComment,\n} from '../../../adapters/typescript/js-doc';\nimport { normalizePath } from '../../../core/utils';\nimport type { IGeneratorContext } from '../../../core/types/metadata';\nimport type { Parameter } from '../../../core/types/parameter';\nimport { ParameterGenerator } from '../parameter';\nimport { ParameterSource } from '../../../core/types/parameter-source';\nimport type { Example, Response } from '../../../core/types/generator';\nimport type { Method } from '../../../core/types/method';\n\nexport class MethodGenerator {\n protected readonly node: MethodDeclaration;\n\n protected readonly current: IGeneratorContext;\n\n constructor(node: MethodDeclaration, current: IGeneratorContext) {\n this.node = node;\n this.current = current;\n }\n\n public getMethodName(): string {\n const identifier = this.node.name as Identifier;\n return identifier.text;\n }\n\n public generate(controllerPaths: string[]): Method | null {\n const name = this.getMethodName();\n const draft = newMethodDraft({ name });\n\n const options = this.applyOptions();\n applyDecoratorHandlers(this.node, this.current.registry.methods, draft, options);\n applyJsDocHandlers(this.node, this.current.registry.methodJsDoc, draft, options);\n\n // Not a route method (no HTTP verb decorator matched).\n if (!draft.verb) {\n return null;\n }\n\n // Skip hidden methods entirely (matches v1 behaviour for class member iteration).\n if (draft.hidden) {\n return null;\n }\n\n // Resolve return type.\n const returnType = this.resolveReturnType();\n\n // Build responses: handler-supplied first, then a derived default that\n // carries any handler-contributed default-response examples.\n const defaultResponse = buildDefaultResponse(returnType, draft.defaultResponseExamples);\n const responses = mergeDefaultResponse(draft.responses, defaultResponse);\n\n // Walk parameters.\n const parameters = this.buildParameters(controllerPaths, draft.path, draft.verb);\n\n // Description from leading JSDoc comment (no v2 handler covers this since it\n // isn't a tagged value).\n const description = getJSDocDescription(this.node) ?? draft.description;\n const summary = draft.summary ?? getJSDocTagComment(this.node, JSDocTagName.SUMMARY);\n\n return {\n consumes: draft.consumes,\n deprecated: draft.deprecated ?? false,\n description: description ?? '',\n extensions: draft.extensions,\n hidden: draft.hidden,\n method: draft.verb,\n name,\n path: normalizePath(draft.path),\n produces: draft.produces,\n responses,\n security: draft.security,\n summary,\n tags: draft.tags,\n type: returnType,\n parameters,\n };\n }\n\n private applyOptions(): ApplyHandlersOptions {\n const parentName = (this.node.parent as ClassDeclaration).name?.text;\n return {\n target: 'method',\n host: { name: this.getMethodName(), parentName },\n resolveTypeNode: (n: TypeNode) => new TypeNodeResolver(n, this.current).resolve(),\n typeChecker: this.current.typeChecker,\n onUnmatchedDecorator: (this.current.config.strict || this.current.config.onUnmatchedDecorator) ?\n (report) => this.current.reportUnmatchedDecorator?.(report) :\n undefined,\n };\n }\n\n private resolveReturnType(): BaseType {\n let nodeType = this.node.type;\n if (!nodeType) {\n const { typeChecker } = this.current;\n const signature = typeChecker.getSignatureFromDeclaration(this.node);\n const implicitType = typeChecker.getReturnTypeOfSignature(signature);\n nodeType = typeChecker.typeToTypeNode(implicitType, undefined, NodeBuilderFlags.NoTruncation) as TypeNode;\n }\n return new TypeNodeResolver(nodeType, this.current).resolve();\n }\n\n private buildParameters(\n controllerPaths: string[],\n methodPath: string,\n verb: string,\n ): Parameter[] {\n const controllerId = (this.node.parent as ClassDeclaration).name as Identifier;\n const methodId = this.node.name as Identifier;\n // Build the union of every (controllerPath × methodPath) combination so\n // path-parameter validation accepts a parameter that's present in any\n // mount (a controller can mount at /roles AND /realms/:id/roles).\n const fullPaths = (controllerPaths.length === 0 ? [''] : controllerPaths)\n .map((cp) => path.posix.join('/', cp, methodPath));\n\n const output: Parameter[] = [];\n let bodyParameterCount = 0;\n let formParameterCount = 0;\n\n for (let i = 0; i < this.node.parameters.length; i++) {\n try {\n const generator = new ParameterGenerator(\n this.node.parameters[i],\n verb,\n fullPaths,\n this.current,\n );\n\n const parameters = generator.generate();\n\n for (const parameter of parameters) {\n if (parameter.in === ParameterSource.BODY) {\n bodyParameterCount += 1;\n }\n if (parameter.in === ParameterSource.FORM_DATA) {\n formParameterCount += 1;\n }\n if (parameter.in !== ParameterSource.CONTEXT) {\n output.push(parameter);\n }\n }\n } catch (e) {\n const causeMsg = e instanceof Error ? `: ${e.message}` : '';\n throw new GeneratorError({\n message: `Parameter generation failed for '${controllerId.text}.${methodId.text}' argument index ${i}${causeMsg}`,\n code: GeneratorErrorCode.PARAMETER_GENERATION_FAILED,\n cause: e,\n });\n }\n }\n\n if (bodyParameterCount > 1) {\n throw new GeneratorError({\n message: `Only one body parameter allowed in '${controllerId.text}.${methodId.text}' method.`,\n code: GeneratorErrorCode.BODY_PARAMETER_DUPLICATE,\n });\n }\n\n if (bodyParameterCount > 0 && formParameterCount > 0) {\n throw new GeneratorError({\n message: `Cannot mix body and form parameters in '${controllerId.text}.${methodId.text}' method.`,\n code: GeneratorErrorCode.BODY_FORM_CONFLICT,\n });\n }\n\n return output;\n }\n}\n\nfunction buildDefaultResponse(returnType: BaseType, examples: Example[]): Response {\n const isVoid = isVoidType(returnType);\n return {\n description: isVoid ? 'No content' : 'Ok',\n examples,\n schema: returnType,\n status: isVoid ? '204' : '200',\n name: isVoid ? '204' : '200',\n };\n}\n\nfunction mergeDefaultResponse(handlerResponses: Response[], defaultResponse: Response): Response[] {\n if (handlerResponses.length === 0) {\n return [defaultResponse];\n }\n const existing = handlerResponses.findIndex((r) => r.status === defaultResponse.status);\n if (existing >= 0) {\n const target = handlerResponses[existing];\n if (defaultResponse.examples && defaultResponse.examples.length > 0 &&\n (!target.examples || target.examples.length === 0)) {\n target.examples = defaultResponse.examples;\n }\n return handlerResponses;\n }\n return [...handlerResponses, defaultResponse];\n}\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n ClassDeclaration, \n Expression, \n MethodDeclaration, \n TypeNode,\n} from 'typescript';\nimport {\n SymbolFlags,\n SyntaxKind,\n isClassDeclaration,\n isMethodDeclaration,\n} from 'typescript';\nimport {\n type ApplyHandlersOptions,\n applyDecoratorHandlers,\n applyJsDocHandlers,\n newControllerDraft,\n} from '../../../adapters/decorator';\nimport { TypeNodeResolver } from '../../../adapters/typescript/resolver';\nimport { isResolverError } from '../../../core/error/resolver';\nimport { GeneratorErrorCode } from '../../../core/error/generator-codes';\nimport { GeneratorError, isGeneratorError } from '../../../core/error/generator';\nimport { normalizePath } from '../../../core/utils';\nimport type { Method } from '../../../core/types/method';\nimport { MethodGenerator } from '../method';\nimport type { IGeneratorContext } from '../../../core/types/metadata';\nimport type { Controller, IControllerGenerator } from '../../../core/types/controller';\n\nexport class ControllerGenerator implements IControllerGenerator {\n protected readonly node: ClassDeclaration;\n\n protected readonly current: IGeneratorContext;\n\n constructor(node: ClassDeclaration, current: IGeneratorContext) {\n this.node = node;\n this.current = current;\n }\n\n public isValid(): boolean {\n // Whether a class is a controller depends on whether any registry handler\n // matches one of its decorators (e.g. `@Controller`). Resolving that\n // requires running handler dispatch — which `generate()` does — so\n // `isValid()` only screens out unnamed classes here. `generate()` returns\n // `null` when no controller handler claimed the node.\n return !!this.node.name;\n }\n\n public generate(): Controller | null {\n if (!this.node.parent) {\n throw new GeneratorError({\n message: 'Controller node doesn\\'t have a valid parent source file.',\n code: GeneratorErrorCode.CONTROLLER_NO_SOURCE_FILE,\n });\n }\n if (!this.node.name) {\n throw new GeneratorError({\n message: 'Controller node doesn\\'t have a valid name.',\n code: GeneratorErrorCode.CONTROLLER_NO_NAME,\n });\n }\n\n const sourceFile = this.node.parent.getSourceFile();\n const draft = newControllerDraft({\n name: this.node.name.text,\n location: sourceFile.fileName,\n });\n\n const options = this.applyOptions();\n applyDecoratorHandlers(this.node, this.current.registry.controllers, draft, options);\n applyJsDocHandlers(this.node, this.current.registry.controllerJsDoc, draft, options);\n\n // A class is a controller iff a controller-target handler claimed it\n // (convention: the Controller handler sets `draft.paths` to a non-undefined value).\n if (draft.paths === undefined) {\n return null;\n }\n\n // Normalize and dedupe — a user passing `@Controller(['/roles', '/roles'])`\n // (or paths that collide after normalization) shouldn't produce duplicate\n // OpenAPI path keys downstream.\n const normalized = (draft.paths.length === 0 ? [''] : draft.paths).map(normalizePath);\n const paths = [...new Set(normalized)];\n const methods = this.buildMethods(paths);\n\n return {\n consumes: draft.consumes,\n extensions: draft.extensions,\n hidden: draft.hidden,\n location: draft.location,\n name: draft.name,\n paths,\n produces: draft.produces,\n responses: draft.responses,\n security: draft.security,\n tags: draft.tags,\n methods,\n };\n }\n\n private applyOptions(): ApplyHandlersOptions {\n return {\n target: 'class',\n host: { name: this.node.name!.text },\n resolveTypeNode: (n: TypeNode) => new TypeNodeResolver(n, this.current).resolve(),\n typeChecker: this.current.typeChecker,\n onUnmatchedDecorator: (this.current.config.strict || this.current.config.onUnmatchedDecorator) ?\n (report) => this.current.reportUnmatchedDecorator?.(report) :\n undefined,\n };\n }\n\n protected buildMethods(controllerPaths: string[]): Method[] {\n const set = new Set<string>();\n const output: Method[] = [];\n\n // Process own methods first\n for (const member of this.node.members) {\n if (!isMethodDeclaration(member)) {\n continue;\n }\n\n const generator = new MethodGenerator(member, this.current);\n const methodName = generator.getMethodName();\n if (set.has(methodName)) {\n continue;\n }\n\n const method = generator.generate(controllerPaths);\n if (!method) {\n continue;\n }\n set.add(methodName);\n output.push(method);\n }\n\n // Then process inherited methods from base classes\n const inheritedMethods = this.collectInheritedMethodDeclarations(this.node);\n for (const node of inheritedMethods) {\n const generator = new MethodGenerator(node, this.current);\n const methodName = generator.getMethodName();\n if (set.has(methodName)) {\n continue;\n }\n\n try {\n const method = generator.generate(controllerPaths);\n if (!method) {\n continue;\n }\n set.add(methodName);\n output.push(method);\n } catch (error: unknown) {\n // Skip inherited methods that fail due to unresolvable generic\n // type parameters (e.g., return type T or parameter type T from\n // generic base classes). Rethrow everything else.\n if (\n isResolverError(error) ||\n (isGeneratorError(error) &&\n error.code === GeneratorErrorCode.PARAMETER_GENERATION_FAILED)\n ) {\n continue;\n }\n\n throw error;\n }\n }\n\n return output;\n }\n\n private collectInheritedMethodDeclarations(node: ClassDeclaration): MethodDeclaration[] {\n const methods: MethodDeclaration[] = [];\n\n if (!node.heritageClauses) {\n return methods;\n }\n\n for (const clause of node.heritageClauses) {\n if (clause.token !== SyntaxKind.ExtendsKeyword) {\n continue;\n }\n\n for (const type of clause.types) {\n const baseDeclaration = this.resolveBaseClassDeclaration(type.expression);\n if (!baseDeclaration) {\n continue;\n }\n\n // Collect direct methods from the base class\n for (const member of baseDeclaration.members) {\n if (isMethodDeclaration(member)) {\n methods.push(member);\n }\n }\n\n // Recurse to pick up the full inheritance chain\n methods.push(...this.collectInheritedMethodDeclarations(baseDeclaration));\n }\n }\n\n return methods;\n }\n\n private resolveBaseClassDeclaration(expression: Expression): ClassDeclaration | undefined {\n let symbol = this.current.typeChecker.getSymbolAtLocation(expression);\n if (!symbol) {\n return undefined;\n }\n\n // Follow import aliases to the original declaration\n if (symbol.flags & SymbolFlags.Alias) {\n symbol = this.current.typeChecker.getAliasedSymbol(symbol);\n }\n\n const declarations = symbol.getDeclarations();\n if (!declarations || declarations.length === 0) {\n return undefined;\n }\n\n const declaration = declarations[0];\n if (isClassDeclaration(declaration)) {\n return declaration;\n }\n\n return undefined;\n }\n}\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport crypto from 'node:crypto';\nimport { minimatch } from 'minimatch';\nimport type {\n Node,\n Program,\n SourceFile,\n TypeChecker,\n} from 'typescript';\nimport {\n NodeFlags,\n createProgram,\n forEachChild,\n isClassDeclaration,\n isModuleBlock,\n isModuleDeclaration,\n} from 'typescript';\nimport {\n CACHE_SCHEMA_VERSION,\n CacheClient,\n composeCacheKey,\n hashCompilerOptions,\n hashRegistry,\n} from '../../../adapters/cache';\nimport type { MetadataGeneratorOptions } from '../../../core/config';\nimport type { Registry, UnmatchedDecoratorReport } from '../../../adapters/decorator';\nimport { createRegistry, loadRegistryByName } from '../../../adapters/decorator';\nimport { ConfigError } from '../../../core/error/config';\nimport { ConfigErrorCode } from '../../../core/error/config-codes';\nimport { GeneratorError } from '../../../core/error/generator';\nimport { GeneratorErrorCode } from '../../../core/error/generator-codes';\nimport type { DependencyResolver, ReferenceType, ReferenceTypes } from '../../../core/types/resolver';\nimport { ResolverCache } from '../../../adapters/typescript/resolver/cache';\nimport type { Controller } from '../../../core/types/controller';\nimport { ControllerGenerator } from '../controller';\nimport type {\n IGeneratorContext,\n IMetadataGenerator,\n Metadata,\n MetadataGeneratorContext,\n} from '../../../core/types/metadata';\n\nexport class MetadataGenerator implements IGeneratorContext, IMetadataGenerator {\n public readonly nodes : Node[];\n\n public readonly typeChecker: TypeChecker;\n\n public registry: Registry;\n\n public readonly resolverCache: ResolverCache;\n\n public readonly config: MetadataGeneratorOptions;\n\n private readonly program: Program;\n\n private cache : CacheClient;\n\n private controllers: Controller[];\n\n private referenceTypes: ReferenceTypes = {};\n\n private circularDependencyResolvers = new Array<DependencyResolver>();\n\n private unmatchedDecorators: Map<string, UnmatchedDecoratorReport[]> = new Map();\n\n // -------------------------------------------------------------------------\n\n constructor(context: MetadataGeneratorContext) {\n this.nodes = [];\n this.config = context.options;\n\n this.cache = new CacheClient(context.options.cache);\n this.registry = createRegistry();\n this.resolverCache = new ResolverCache();\n\n this.program = createProgram(\n context.sourceFiles,\n context.compilerOptions || {},\n );\n this.typeChecker = this.program.getTypeChecker();\n }\n\n // -------------------------------------------------------------------------\n\n async generate(): Promise<Metadata> {\n const sourceFilesHash : string = this.buildNodesFromSourceFiles();\n\n // Load the preset upfront so its resolved registry can contribute to\n // the cache key. Otherwise edits to a local preset (or upgrades that\n // share a name) would silently serve stale metadata.\n if (this.config.preset) {\n this.registry = await loadRegistryByName(this.config.preset);\n }\n\n const cacheKey = composeCacheKey({\n schemaVersion: CACHE_SCHEMA_VERSION,\n sourceFilesHash,\n compilerOptionsHash: hashCompilerOptions(this.program.getCompilerOptions()),\n registryHash: hashRegistry(this.registry),\n presetName: this.config.preset,\n });\n\n // Strict reporting requires handler dispatch to actually run. A cache hit\n // would skip it and silently swallow unmatched-decorator reports.\n const bypassCache = !!(this.config.strict || this.config.onUnmatchedDecorator);\n\n let cache = bypassCache ?\n undefined :\n await this.cache.get(cacheKey);\n\n if (!cache) {\n this.buildControllers();\n\n this.assertPresetProducedControllers();\n\n this.circularDependencyResolvers.forEach((resolve) => resolve(this.referenceTypes));\n\n cache = {\n controllers: this.controllers,\n referenceTypes: this.referenceTypes,\n cacheKey,\n schemaVersion: CACHE_SCHEMA_VERSION,\n };\n\n if (!bypassCache) {\n await this.cache.save(cache);\n }\n }\n\n if (this.config.strict || this.config.onUnmatchedDecorator) {\n this.dispatchUnmatchedDecoratorReports();\n }\n\n return {\n controllers: cache.controllers,\n referenceTypes: cache.referenceTypes,\n };\n }\n\n private assertPresetProducedControllers(): void {\n if (this.config.preset || this.controllers.length > 0) {\n return;\n }\n // Only fault a missing preset when we actually scanned source files —\n // an empty entry point is a different misconfiguration that shouldn't\n // surface as a preset error.\n if (this.nodes.length === 0) {\n return;\n }\n throw new ConfigError({\n message: 'No preset configured and no controllers detected. Provide `preset: \\'@trapi/preset-decorators-express\\'` (or another preset) so handlers can match your decorators.',\n code: ConfigErrorCode.PRESET_MISSING,\n });\n }\n\n public reportUnmatchedDecorator(report: UnmatchedDecoratorReport): void {\n const key = `${report.target}:${report.name}`;\n const existing = this.unmatchedDecorators.get(key);\n if (existing) {\n existing.push(report);\n return;\n }\n this.unmatchedDecorators.set(key, [report]);\n }\n\n private dispatchUnmatchedDecoratorReports(): void {\n if (this.unmatchedDecorators.size === 0) {\n return;\n }\n\n const flat: UnmatchedDecoratorReport[] = [];\n for (const reports of this.unmatchedDecorators.values()) {\n flat.push(...reports);\n }\n\n // User-supplied callback short-circuits the default warn/throw path.\n if (this.config.onUnmatchedDecorator) {\n this.config.onUnmatchedDecorator(flat);\n return;\n }\n\n const summary = this.formatUnmatchedSummary();\n\n if (this.config.strict === 'throw') {\n throw new GeneratorError({\n message: summary,\n code: GeneratorErrorCode.STRICT_UNMATCHED_DECORATORS,\n });\n }\n\n // eslint-disable-next-line no-console\n console.warn(summary);\n }\n\n private formatUnmatchedSummary(): string {\n const lines: string[] = ['[trapi] strict mode: decorators with no matching handler:'];\n for (const reports of this.unmatchedDecorators.values()) {\n const first = reports[0];\n const occurrences = reports.length;\n const location = `${first.file}:${first.line}`;\n const suffix = occurrences > 1 ?\n ` (${occurrences} occurrences; first at ${location})` :\n ` (${location})`;\n lines.push(` - @${first.name} on ${first.target} '${first.host.name}'${suffix}`);\n }\n return lines.join('\\n');\n }\n\n protected buildNodesFromSourceFiles() : string {\n const hash = crypto.createHash('sha256');\n\n this.program.getSourceFiles().forEach((sf: SourceFile) => {\n if (\n this.isIgnoredPath(sf.fileName) &&\n !this.isAllowedPath(sf.fileName)\n ) {\n return;\n }\n\n // Hash the file path alongside its contents so that renames or\n // reordered identical files invalidate the cache. The null byte is\n // a safe separator since it cannot appear in a path or source.\n hash.update(sf.fileName);\n hash.update('\\0');\n hash.update(sf.text);\n hash.update('\\0');\n\n forEachChild(sf, (node: any) => {\n if (isModuleDeclaration(node)) {\n /**\n * For some reason unknown to me, TS resolves both `declare module` and `namespace` to\n * the same kind (`ModuleDeclaration`). In order to figure out whether it's one or the other,\n * we check the node flags. They tell us whether it is a namespace or not.\n */\n\n // tslint:disable-next-line:no-bitwise\n if ((node.flags & NodeFlags.Namespace) === 0 && node.body && isModuleBlock(node.body)) {\n node.body.statements.forEach((statement) => {\n this.nodes.push(statement);\n });\n return;\n }\n }\n\n this.nodes.push(node);\n });\n });\n\n return hash.digest('hex');\n }\n\n // -------------------------------------------------------------------------\n\n /**\n * Check if the source file path is in the ignored path list.\n *\n * @param filePath\n * @protected\n */\n protected isIgnoredPath(filePath: string) : boolean {\n if (typeof this.config.ignore === 'undefined') {\n return false;\n }\n\n return this.config.ignore.some((item) => minimatch(filePath, item));\n }\n\n /**\n * Check if the source file path is in the ignored path list.\n *\n * @param filePath\n * @protected\n */\n protected isAllowedPath(filePath: string) {\n if (typeof this.config.allow === 'undefined') {\n return false;\n }\n\n return this.config.allow.some((item) => minimatch(filePath, item));\n }\n\n // -------------------------------------------------------------------------\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public isExportedNode(_node: Node) {\n return true;\n }\n\n // -------------------------------------------------------------------------\n\n public addReferenceType(referenceType: ReferenceType) {\n if (!referenceType.refName) {\n return;\n }\n\n this.referenceTypes[referenceType.refName] = referenceType;\n }\n\n public getReferenceType(refName: string) {\n return this.referenceTypes[refName];\n }\n\n public registerDependencyResolver(callback: DependencyResolver) {\n this.circularDependencyResolvers.push(callback);\n }\n\n private buildControllers() : void {\n this.controllers = [];\n\n for (let i = 0; i < this.nodes.length; i++) {\n const node = this.nodes[i];\n if (!isClassDeclaration(node)) {\n continue;\n }\n\n const generator = new ControllerGenerator(node, this);\n if (!generator.isValid()) {\n continue;\n }\n\n const controller = generator.generate();\n if (controller) {\n this.controllers.push(controller);\n }\n }\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty, isObject } from 'locter';\nimport type { Metadata } from '../../../core/index.ts';\n\nexport function isMetadata(input: unknown) : input is Metadata {\n return isObject(input) &&\n hasOwnProperty(input, 'controllers') &&\n Array.isArray(input.controllers) &&\n hasOwnProperty(input, 'referenceTypes') &&\n isObject(input.referenceTypes);\n}\n","/*\n * Copyright (c) 2021-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { CompilerOptions } from 'typescript';\nimport type { MetadataGenerateOptions } from '../core/config';\nimport type { Metadata } from '../core/types/metadata';\nimport { MetadataGenerator } from './generator/metadata';\nimport { scanSourceFiles } from '../adapters/filesystem';\nimport { softLoadTsconfig } from '../adapters/filesystem/tsconfig';\n\nexport async function generateMetadata(\n options: MetadataGenerateOptions,\n) : Promise<Metadata> {\n let compilerOptions : CompilerOptions | undefined;\n\n if (options.tsconfig) {\n let { tsconfig } = options;\n if (typeof tsconfig === 'string') {\n tsconfig = await softLoadTsconfig({ name: tsconfig });\n compilerOptions = tsconfig.compilerOptions;\n } else {\n compilerOptions = tsconfig.compilerOptions || {};\n }\n }\n\n const sourceFiles = await scanSourceFiles(options.entryPoint);\n\n const generator = new MetadataGenerator({\n sourceFiles,\n compilerOptions,\n options,\n });\n\n return generator.generate();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,IAAY,WAAL,yBAAA,UAAA;AACH,UAAA,YAAA;AACA,UAAA,aAAA;AACA,UAAA,YAAA;AACA,UAAA,YAAA;AACA,UAAA,WAAA;AACA,UAAA,UAAA;AACA,UAAA,aAAA;AACA,UAAA,UAAA;AACA,UAAA,UAAA;AACA,UAAA,WAAA;AACA,UAAA,cAAA;AACA,UAAA,UAAA;AACA,UAAA,YAAA;AACA,UAAA,YAAA;AACA,UAAA,UAAA;AACA,UAAA,UAAA;AACA,UAAA,YAAA;AACA,UAAA,SAAA;AACA,UAAA,eAAA;AACA,UAAA,WAAA;AACA,UAAA,cAAA;AACA,UAAA,gBAAA;AACA,UAAA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W;;;;;;AC9TjD,SAAgB,WAAW,OAAoC;AAC3D,QAAO,SAAS,MAAM,IAClBC,iBAAe,OAAO,cAAc,IACpC,MAAM,QAAQ,MAAM,YAAY,IAChCA,iBAAe,OAAO,iBAAiB,IACvC,SAAS,MAAM,eAAe;;;;ACDtC,eAAsB,iBAClB,SACkB;CAClB,IAAI;AAEJ,KAAI,QAAQ,UAAU;EAClB,IAAI,EAAE,aAAa;AACnB,MAAI,OAAO,aAAa,UAAU;AAC9B,cAAW,MAAM,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACrD,qBAAkB,SAAS;QAE3B,mBAAkB,SAAS,mBAAmB,EAAE;;AAYxD,QAAO,IANe,kBAAkB;EACpC,aAAA,MAHsB,gBAAgB,QAAQ,WAAW;EAIzD;EACA;EACH,CAEe,CAAC,UAAU"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["arrayLiteral","readDecoratorName","ValidatorError","ValidatorErrorCode","ValidatorError","ValidatorErrorCode","ResolverError","prettyLocationOfNode","prettyTroubleCause","isResolverError","ResolverError","ResolverError","ResolverError","ResolverError","ResolverError","ResolverError","ResolverError","modelTypeDeclaration","stringifyFlatted","parseFlatted","joinFilePath","GeneratorError","isGeneratorError","GeneratorErrorCode","ParameterError","ParameterError","GeneratorError","GeneratorErrorCode","GeneratorError","GeneratorErrorCode","isResolverError","isGeneratorError","GeneratorError","GeneratorErrorCode","hasOwnProperty"],"sources":["../src/core/resolver/constants.ts","../src/core/resolver/type-guards.ts","../src/core/error/base.ts","../src/core/resolver/error.ts","../src/core/method/constants.ts","../src/core/parameter/constants.ts","../src/core/parameter/error.ts","../src/core/generator/error.ts","../src/core/generator/constants.ts","../src/core/validator/error.ts","../src/core/validator/constants.ts","../src/core/error/config.ts","../src/core/error/config-codes.ts","../src/adapters/decorator/constants.ts","../src/adapters/decorator/helpers.ts","../src/adapters/decorator/utils.ts","../src/adapters/decorator/validation/module.ts","../src/adapters/decorator/module.ts","../src/adapters/decorator/test-helpers.ts","../src/adapters/typescript/js-doc/constants.ts","../src/core/utils/array.ts","../src/core/utils/object.ts","../src/core/utils/path-normalize.ts","../src/adapters/typescript/js-doc/utils.ts","../src/adapters/typescript/js-doc/module.ts","../src/adapters/typescript/initializer.ts","../src/adapters/decorator/typescript/utils.ts","../src/adapters/decorator/typescript/module.ts","../src/adapters/decorator/orchestrator/module.ts","../src/core/error/validator.ts","../src/core/error/validator-codes.ts","../src/adapters/typescript/validator/module.ts","../src/core/error/resolver.ts","../src/adapters/typescript/resolver/extension/module.ts","../src/adapters/typescript/resolver/sub/array.ts","../src/adapters/typescript/resolver/sub/base.ts","../src/adapters/typescript/resolver/utils.ts","../src/adapters/typescript/resolver/sub/indexed-access.ts","../src/adapters/typescript/resolver/sub/intersection.ts","../src/adapters/typescript/resolver/sub/literal.ts","../src/adapters/typescript/resolver/sub/mapped.ts","../src/adapters/typescript/resolver/sub/object-literal.ts","../src/adapters/typescript/resolver/sub/primitive.ts","../src/adapters/typescript/resolver/sub/reference.ts","../src/adapters/typescript/resolver/sub/tuple.ts","../src/adapters/typescript/resolver/sub/type-operator.ts","../src/adapters/typescript/resolver/sub/union.ts","../src/adapters/typescript/resolver/module.ts","../src/adapters/typescript/resolver/cache.ts","../src/adapters/typescript/node-utils/module.ts","../src/adapters/filesystem/source-files.ts","../src/adapters/filesystem/tsconfig/module.ts","../src/adapters/cache/constants.ts","../src/adapters/cache/utils.ts","../src/adapters/cache/client.ts","../src/core/error/generator.ts","../src/core/error/generator-codes.ts","../src/core/error/parameter.ts","../src/app/generator/parameter/module.ts","../src/app/generator/method/module.ts","../src/app/generator/controller/module.ts","../src/app/generator/metadata/module.ts","../src/app/generator/metadata/utils.ts","../src/app/generate.ts"],"sourcesContent":["/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum TypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n BIGINT = 'bigint',\n DOUBLE = 'double',\n FLOAT = 'float',\n FILE = 'file',\n INTEGER = 'integer',\n LONG = 'long',\n ENUM = 'enum',\n ARRAY = 'array',\n DATETIME = 'datetime',\n DATE = 'date',\n BINARY = 'binary',\n BUFFER = 'buffer',\n BYTE = 'byte',\n VOID = 'void',\n OBJECT = 'object',\n ANY = 'any',\n UNDEFINED = 'undefined',\n NEVER = 'never',\n REF_ENUM = 'refEnum',\n REF_OBJECT = 'refObject',\n REF_ALIAS = 'refAlias',\n NESTED_OBJECT_LITERAL = 'nestedObjectLiteral',\n UNION = 'union',\n INTERSECTION = 'intersection',\n TUPLE = 'tuple',\n}\n\nexport enum UtilityTypeName {\n NON_NULLABLE = 'NonNullable',\n OMIT = 'Omit',\n PARTIAL = 'Partial',\n READONLY = 'Readonly',\n RECORD = 'Record',\n REQUIRED = 'Required',\n PICK = 'Pick',\n // Checker-resolvable utility types — delegated to the TS type checker\n EXTRACT = 'Extract',\n EXCLUDE = 'Exclude',\n RETURN_TYPE = 'ReturnType',\n PARAMETERS = 'Parameters',\n AWAITED = 'Awaited',\n INSTANCE_TYPE = 'InstanceType',\n CONSTRUCTOR_PARAMETERS = 'ConstructorParameters',\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { TypeName } from './constants';\nimport type {\n AnyType,\n ArrayType,\n BaseType,\n BigintType,\n BinaryType,\n BooleanType,\n BufferType,\n ByteType,\n DateTimeType,\n DateType,\n DoubleType,\n EnumType,\n FileType,\n FloatType,\n IntegerType,\n IntersectionType,\n LongType,\n NestedObjectLiteralType,\n NeverType,\n ObjectType,\n PrimitiveType,\n RefAliasType,\n RefEnumType,\n RefObjectType,\n ReferenceType,\n StringType,\n TupleType,\n UndefinedType,\n UnionType,\n VoidType,\n} from './types';\n\n// -------------------------------------------\n// Primitive Type Guards\n// -------------------------------------------\n\nexport function isAnyType(param: BaseType): param is AnyType {\n return param.typeName === TypeName.ANY;\n}\n\nexport function isUndefinedType(param: BaseType): param is UndefinedType {\n return param.typeName === TypeName.UNDEFINED;\n}\n\nexport function isStringType(param: BaseType): param is StringType {\n return param.typeName === TypeName.STRING;\n}\n\nexport function isBooleanType(param: BaseType): param is BooleanType {\n return param.typeName === TypeName.BOOLEAN;\n}\n\nexport function isBigintType(param: BaseType): param is BigintType {\n return param.typeName === TypeName.BIGINT;\n}\n\nexport function isDoubleType(param: BaseType): param is DoubleType {\n return param.typeName === TypeName.DOUBLE;\n}\n\nexport function isFloatType(param: BaseType): param is FloatType {\n return param.typeName === TypeName.FLOAT;\n}\n\nexport function isIntegerType(param: BaseType): param is IntegerType {\n return param.typeName === TypeName.INTEGER;\n}\n\nexport function isLongType(param: BaseType): param is LongType {\n return param.typeName === TypeName.LONG;\n}\n\nexport function isVoidType(param: BaseType | undefined): param is VoidType {\n return typeof param === 'undefined' || param.typeName === TypeName.VOID;\n}\n\nexport function isNeverType(param: BaseType): param is NeverType {\n return param.typeName === TypeName.NEVER;\n}\n\n// -------------------------------------------\n// Simple Type Guards\n// -------------------------------------------\n\nexport function isDateType(param: BaseType): param is DateType {\n return param.typeName === TypeName.DATE;\n}\n\nexport function isFileType(param: BaseType): param is FileType {\n return param.typeName === TypeName.FILE;\n}\n\nexport function isDateTimeType(param: BaseType): param is DateTimeType {\n return param.typeName === TypeName.DATETIME;\n}\n\nexport function isBinaryType(param: BaseType): param is BinaryType {\n return param.typeName === TypeName.BINARY;\n}\n\nexport function isBufferType(param: BaseType): param is BufferType {\n return param.typeName === TypeName.BUFFER;\n}\n\nexport function isByteType(param: BaseType): param is ByteType {\n return param.typeName === TypeName.BYTE;\n}\n\nexport function isObjectType(param: BaseType): param is ObjectType {\n return param.typeName === TypeName.OBJECT;\n}\n\n// -------------------------------------------\n// Complex Type Guards\n// -------------------------------------------\n\nexport function isEnumType(param: BaseType): param is EnumType {\n return param.typeName === TypeName.ENUM;\n}\n\nexport function isArrayType(param: BaseType): param is ArrayType {\n return param.typeName === TypeName.ARRAY;\n}\n\nexport function isNestedObjectLiteralType(param: BaseType): param is NestedObjectLiteralType {\n return param.typeName === TypeName.NESTED_OBJECT_LITERAL;\n}\n\nexport function isIntersectionType(param: BaseType): param is IntersectionType {\n return param.typeName === TypeName.INTERSECTION;\n}\n\nexport function isUnionType(param: BaseType): param is UnionType {\n return param.typeName === TypeName.UNION;\n}\n\nexport function isTupleType(param: BaseType): param is TupleType {\n return param.typeName === TypeName.TUPLE;\n}\n\n// -------------------------------------------\n// Reference Type Guards\n// -------------------------------------------\n\nexport function isRefEnumType(param: BaseType): param is RefEnumType {\n return param.typeName === TypeName.REF_ENUM;\n}\n\nexport function isRefObjectType(param: BaseType): param is RefObjectType {\n return param.typeName === TypeName.REF_OBJECT;\n}\n\nexport function isRefAliasType(param: BaseType): param is RefAliasType {\n return param.typeName === TypeName.REF_ALIAS;\n}\n\nexport function isReferenceType(param: BaseType): param is ReferenceType {\n return param.typeName === TypeName.REF_ALIAS ||\n param.typeName === TypeName.REF_ENUM ||\n param.typeName === TypeName.REF_OBJECT;\n}\n\nexport function isPrimitiveType(type: BaseType): type is PrimitiveType {\n return isAnyType(type) ||\n isBinaryType(type) ||\n isBooleanType(type) ||\n isBufferType(type) ||\n isByteType(type) ||\n isDateType(type) ||\n isDateTimeType(type) ||\n isBigintType(type) ||\n isDoubleType(type) ||\n isFloatType(type) ||\n isFileType(type) ||\n isIntegerType(type) ||\n isLongType(type) ||\n isObjectType(type) ||\n isStringType(type) ||\n isUndefinedType(type);\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from '@ebec/core';\n\nexport class MetadataError extends BaseError {\n\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { normalize } from 'node:path';\nimport { isBaseError } from '@ebec/core';\nimport type { Node, TypeNode } from 'typescript';\nimport { MetadataError } from '../error/base';\n\nexport class ResolverError extends MetadataError {\n public readonly file?: string;\n\n public readonly line?: number;\n\n constructor(\n message: string,\n node?: Node | TypeNode,\n options?: boolean | { onlyCurrent?: boolean, cause?: unknown },\n ) {\n const opts = typeof options === 'boolean' ? { onlyCurrent: options } : options;\n const onlyCurrent = opts?.onlyCurrent ?? false;\n\n const parts: string[] = [message];\n let file: string | undefined;\n let line: number | undefined;\n\n if (node) {\n const location = prettyLocationOfNode(node);\n if (location) {\n parts.push(location.text);\n file = location.file;\n line = location.line;\n }\n\n parts.push(prettyTroubleCause(node, onlyCurrent));\n }\n\n super({\n message: parts.join('\\n'),\n cause: opts?.cause,\n });\n\n this.file = file;\n this.line = line;\n }\n}\n\nexport function isResolverError(input: unknown): input is ResolverError {\n if (!isBaseError(input)) {\n return false;\n }\n\n return 'file' in input && 'line' in input;\n}\n\nexport function prettyLocationOfNode(node: Node | TypeNode): {\n text: string,\n file: string,\n line?: number,\n} | undefined {\n try {\n const sourceFile = node.getSourceFile();\n if (!sourceFile) return undefined;\n\n const token = node.getFirstToken() || node.parent?.getFirstToken();\n const start = token ? sourceFile.getLineAndCharacterOfPosition(token.getStart()).line + 1 : undefined;\n const end = token ? sourceFile.getLineAndCharacterOfPosition(token.getEnd()).line + 1 : undefined;\n\n const normalizedFile = normalize(sourceFile.fileName);\n const startSuffix = start ? `:${start}` : '';\n const endSuffix = end ? `:${end}` : '';\n\n return {\n text: `At: ${normalizedFile}${startSuffix}${endSuffix}.`,\n file: sourceFile.fileName,\n line: start,\n };\n } catch {\n return undefined;\n }\n}\n\nexport function prettyTroubleCause(node: Node | TypeNode, onlyCurrent = false) {\n try {\n let name: string;\n if (onlyCurrent || !node.parent) {\n name = node.pos !== -1 ? node.getText() : (node as any).name.text;\n } else {\n name = node.parent.pos !== -1 ? node.parent.getText() : (node as any).parent.name.text;\n }\n\n return `This was caused by '${name}'`;\n } catch {\n return 'This was caused by an unknown node';\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const MethodName = {\n ALL: 'ALL',\n GET: 'GET',\n POST: 'POST',\n PUT: 'PUT',\n DELETE: 'DELETE',\n PATCH: 'PATCH',\n OPTIONS: 'OPTIONS',\n HEAD: 'HEAD',\n} as const;\nexport type MethodName = typeof MethodName[keyof typeof MethodName];\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const ParameterSource = {\n BODY: 'body',\n BODY_PROP: 'bodyProp',\n CONTEXT: 'context',\n COOKIE: 'cookie',\n HEADER: 'header',\n FORM_DATA: 'formData',\n QUERY: 'query',\n QUERY_PROP: 'queryProp',\n PATH: 'path',\n} as const;\nexport type ParameterSource = typeof ParameterSource[keyof typeof ParameterSource];\n\nexport const CollectionFormat = {\n CSV: 'csv',\n SSV: 'ssv',\n TSV: 'tsv',\n PIPES: 'pipes',\n MULTI: 'multi',\n} as const;\nexport type CollectionFormat = typeof CollectionFormat[keyof typeof CollectionFormat];\n\nexport const ParameterErrorCode = {\n TYPE_UNSUPPORTED: 'PARAMETER_TYPE_UNSUPPORTED',\n METHOD_UNSUPPORTED: 'PARAMETER_METHOD_UNSUPPORTED',\n PATH_MISMATCH: 'PARAMETER_PATH_MISMATCH',\n SCOPE_REQUIRED: 'PARAMETER_SCOPE_REQUIRED',\n INVALID_EXAMPLE: 'PARAMETER_INVALID_EXAMPLE',\n} as const;\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport { isClassDeclaration, isMethodDeclaration } from 'typescript';\nimport type { Node } from 'typescript';\nimport type { BaseType } from '../resolver/types';\nimport { ParameterErrorCode } from './constants';\nimport { MetadataError } from '../error/base';\n\ntype UnsupportedTypeContext = {\n decoratorName: string,\n propertyName: string,\n type: BaseType,\n node?: Node\n};\n\ntype UnsupportedMethodContext = {\n decoratorName: string,\n propertyName: string,\n method: string,\n node?: Node\n};\n\ntype PathMatchInvalidContext = {\n decoratorName: string,\n propertyName: string,\n path: string,\n node?: Node\n};\n\ntype ScopeRequiredContext = {\n decoratorName: string,\n node?: Node\n};\n\nexport class ParameterError extends MetadataError {\n static typeUnsupported(context: UnsupportedTypeContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not support '${context.type.typeName}' type${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.TYPE_UNSUPPORTED,\n });\n }\n\n static methodUnsupported(context: UnsupportedMethodContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not support method '${context.method}'${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.METHOD_UNSUPPORTED,\n });\n }\n\n static invalidPathMatch(context: PathMatchInvalidContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not exist in path '${context.path}'${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.PATH_MISMATCH,\n });\n }\n\n static scopeRequired(context: ScopeRequiredContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}() requires a scope argument${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.SCOPE_REQUIRED,\n });\n }\n\n static invalidExampleSchema() {\n return new ParameterError({\n message: 'The @example JSDoc tag contains invalid JSON.',\n code: ParameterErrorCode.INVALID_EXAMPLE,\n });\n }\n\n public static getCurrentLocation(node: Node) {\n const parts : string[] = [];\n\n if (isMethodDeclaration(node.parent)) {\n parts.push(node.parent.name.getText());\n\n if (isClassDeclaration(node.parent.parent)) {\n parts.unshift(node.parent.parent.name.text);\n }\n }\n\n return parts.join('.');\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isBaseError } from '@ebec/core';\nimport { MetadataError } from '../error/base';\n\nexport class GeneratorError extends MetadataError {\n\n}\n\nexport function isGeneratorError(input: unknown): input is GeneratorError & { code: string } {\n if (!isBaseError(input)) {\n return false;\n }\n\n return typeof input.code === 'string';\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const GeneratorErrorCode = {\n CONTROLLER_NO_SOURCE_FILE: 'GENERATOR_CONTROLLER_NO_SOURCE_FILE',\n CONTROLLER_NO_NAME: 'GENERATOR_CONTROLLER_NO_NAME',\n PARAMETER_GENERATION_FAILED: 'GENERATOR_PARAMETER_GENERATION_FAILED',\n BODY_PARAMETER_DUPLICATE: 'GENERATOR_BODY_PARAMETER_DUPLICATE',\n BODY_FORM_CONFLICT: 'GENERATOR_BODY_FORM_CONFLICT',\n} as const;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { MetadataError } from '../error/base';\n\nexport class ValidatorError extends MetadataError {\n\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum ValidatorName {\n UNIQUE_ITEMS = 'uniqueItems',\n\n MINIMUM = 'minimum',\n MAXIMUM = 'maximum',\n MIN_ITEMS = 'minItems',\n MAX_ITEMS = 'maxItems',\n MIN_LENGTH = 'minLength',\n MAX_LENGTH = 'maxLength',\n\n MIN_DATE = 'minDate',\n MAX_DATE = 'maxDate',\n\n PATTERN = 'pattern',\n}\n\nexport const ValidatorErrorCode = {\n EXPECTED_NUMBER: 'VALIDATOR_EXPECTED_NUMBER',\n EXPECTED_DATE: 'VALIDATOR_EXPECTED_DATE',\n EXPECTED_STRING: 'VALIDATOR_EXPECTED_STRING',\n} as const;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { MetadataError } from './base';\n\nexport class ConfigError extends MetadataError {\n\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const ConfigErrorCode = {\n TSCONFIG_MALFORMED: 'CONFIG_TSCONFIG_MALFORMED',\n PRESET_NOT_FOUND: 'CONFIG_PRESET_NOT_FOUND',\n PRESET_MISSING: 'CONFIG_PRESET_MISSING',\n} as const;\nexport type ConfigErrorCode = typeof ConfigErrorCode[keyof typeof ConfigErrorCode];\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const ParamKind = {\n Body: 'body',\n BodyProp: 'bodyProp',\n Context: 'context',\n Cookie: 'cookie',\n Header: 'header',\n FormData: 'formData',\n Query: 'query',\n QueryProp: 'queryProp',\n Path: 'path',\n} as const;\nexport type ParamKind = typeof ParamKind[keyof typeof ParamKind];\n\nexport const CollectionKind = {\n Csv: 'csv',\n Ssv: 'ssv',\n Tsv: 'tsv',\n Pipes: 'pipes',\n Multi: 'multi',\n} as const;\nexport type CollectionKind = typeof CollectionKind[keyof typeof CollectionKind];\n\nexport const DecoratorTargetKind = {\n Class: 'class',\n Method: 'method',\n Parameter: 'parameter',\n Property: 'property',\n} as const;\nexport type DecoratorTargetKind = typeof DecoratorTargetKind[keyof typeof DecoratorTargetKind];\n\nexport const DecoratorArgumentKindName = {\n Literal: 'literal',\n Object: 'object',\n Array: 'array',\n Identifier: 'identifier',\n Unresolvable: 'unresolvable',\n} as const;\nexport type DecoratorArgumentKindName = typeof DecoratorArgumentKindName[keyof typeof DecoratorArgumentKindName];\n\nexport const MarkerName = {\n Hidden: 'hidden',\n Deprecated: 'deprecated',\n Extension: 'extension',\n} as const;\nexport type MarkerName = typeof MarkerName[keyof typeof MarkerName];\n\nexport const NumericKind = {\n Int: 'int',\n Long: 'long',\n Float: 'float',\n Double: 'double',\n} as const;\nexport type NumericKind = typeof NumericKind[keyof typeof NumericKind];\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n ControllerDraft,\n DecoratorArgument,\n MethodDraft,\n} from './types';\n\n/**\n * Read a positional argument as a string. Accepts both literal string args\n * (`@Foo('value')`) and identifier references that resolve to a string\n * (`@Foo(SOME_CONSTANT)`). Returns `undefined` for any other argument shape.\n */\nexport function readString(arg: DecoratorArgument | undefined): string | undefined {\n if (!arg) return undefined;\n if (arg.kind === 'literal' && typeof arg.raw === 'string') return arg.raw;\n if (arg.kind === 'identifier' && typeof arg.raw === 'string') return arg.raw;\n return undefined;\n}\n\n/**\n * Read a positional argument as a number. Only matches numeric literals.\n */\nexport function readNumber(arg: DecoratorArgument | undefined): number | undefined {\n if (!arg) return undefined;\n if (arg.kind === 'literal' && typeof arg.raw === 'number') return arg.raw;\n return undefined;\n}\n\n/**\n * Read a positional argument as a boolean. Only matches boolean literals.\n */\nexport function readBoolean(arg: DecoratorArgument | undefined): boolean | undefined {\n if (!arg) return undefined;\n if (arg.kind === 'literal' && typeof arg.raw === 'boolean') return arg.raw;\n return undefined;\n}\n\n/**\n * Read a positional argument that may be either a single string or an array\n * of strings. Returns `undefined` when the argument is missing, when any\n * array element is non-string, or otherwise unresolvable. All-or-nothing:\n * never returns a partial array with non-string items silently dropped.\n */\nexport function readStringOrStringArray(\n arg: DecoratorArgument | undefined,\n): string[] | undefined {\n const single = readString(arg);\n if (single !== undefined) {\n return [single];\n }\n if (arg?.kind === 'array' && Array.isArray(arg.raw)) {\n if (arg.raw.every((item) => typeof item === 'string')) {\n return arg.raw;\n }\n return undefined;\n }\n return undefined;\n}\n\n/**\n * Convenience for the common controller path assignment. Reads the first\n * argument as a string-or-string-array and writes it to `draft.paths`,\n * defaulting to `['']` when the argument is missing or unresolvable. Use this\n * inside a `controller({ match, apply })` handler to declare a class as a\n * controller.\n */\nexport function setControllerPaths(\n draft: ControllerDraft,\n arg: DecoratorArgument | undefined,\n): void {\n draft.paths = readStringOrStringArray(arg) ?? [''];\n}\n\n/**\n * Convenience for the common method path assignment. Reads the first argument\n * as a string and writes it to `draft.path` if present; leaves the field\n * untouched otherwise (the orchestrator initialises it to `''`).\n */\nexport function setMethodPath(\n draft: MethodDraft,\n arg: DecoratorArgument | undefined,\n): void {\n const path = readString(arg);\n if (path !== undefined) {\n draft.path = path;\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport type {\n ControllerDraft,\n ControllerHandler,\n ControllerJsDocHandler,\n DecoratorSource,\n HandlerContext,\n JsDocMatch,\n JsDocSource,\n Match,\n MethodDraft,\n MethodHandler,\n MethodJsDocHandler,\n ParameterDraft,\n ParameterHandler,\n ParameterJsDocHandler,\n Registry,\n ResolverMarker,\n} from './types';\n\n// -----------------------------------------------------------------------------\n// Match predicates\n// -----------------------------------------------------------------------------\n\nexport function matches(match: Match, source: Pick<DecoratorSource, 'name' | 'target'>): boolean {\n if (match.name !== source.name) {\n return false;\n }\n if (match.on && match.on !== source.target) {\n return false;\n }\n return true;\n}\n\nexport function matchesJsDoc(match: JsDocMatch, source: Pick<JsDocSource, 'tag' | 'target'>): boolean {\n if (match.tag !== source.tag) {\n return false;\n }\n if (match.on && match.on !== source.target) {\n return false;\n }\n return true;\n}\n\n// -----------------------------------------------------------------------------\n// Draft factories\n// -----------------------------------------------------------------------------\n\nexport function newControllerDraft(input: Pick<ControllerDraft, 'name' | 'location'>): ControllerDraft {\n return {\n name: input.name,\n location: input.location,\n hidden: false,\n consumes: [],\n produces: [],\n tags: [],\n responses: [],\n security: [],\n extensions: [],\n };\n}\n\nexport function newMethodDraft(input: Pick<MethodDraft, 'name'>): MethodDraft {\n return {\n name: input.name,\n path: '',\n description: '',\n hidden: false,\n consumes: [],\n produces: [],\n tags: [],\n responses: [],\n security: [],\n extensions: [],\n parameters: [],\n defaultResponseExamples: [],\n };\n}\n\nexport function newParameterDraft(input: Pick<ParameterDraft, 'parameterName'>): ParameterDraft {\n return {\n parameterName: input.parameterName,\n name: input.parameterName,\n description: '',\n required: true,\n examples: [],\n exampleLabels: [],\n extensions: [],\n validators: {},\n };\n}\n\n// -----------------------------------------------------------------------------\n// Registry factory\n// -----------------------------------------------------------------------------\n\n/**\n * Build a {@link Registry}, optionally seeded with handler arrays from `input`.\n * Any kind omitted from `input` falls back to an empty array, so callers can\n * pass just the kinds they care about (e.g. `createRegistry({ methods: [...] })`).\n *\n * The provided arrays are copied — mutating the result does not affect `input`.\n */\nexport function createRegistry(input: Partial<Registry> = {}): Registry {\n return {\n controllers: input.controllers ? [...input.controllers] : [],\n methods: input.methods ? [...input.methods] : [],\n parameters: input.parameters ? [...input.parameters] : [],\n controllerJsDoc: input.controllerJsDoc ? [...input.controllerJsDoc] : [],\n methodJsDoc: input.methodJsDoc ? [...input.methodJsDoc] : [],\n parameterJsDoc: input.parameterJsDoc ? [...input.parameterJsDoc] : [],\n };\n}\n\n/**\n * Concatenate two registries kind-by-kind. Earlier handlers run first inside\n * the orchestrator, so callers who want override-by-running-later semantics\n * should pass the dominant registry as `b`.\n */\nexport function mergeRegistries(a: Registry, b: Registry): Registry {\n return {\n controllers: [...a.controllers, ...b.controllers],\n methods: [...a.methods, ...b.methods],\n parameters: [...a.parameters, ...b.parameters],\n controllerJsDoc: [...a.controllerJsDoc, ...b.controllerJsDoc],\n methodJsDoc: [...a.methodJsDoc, ...b.methodJsDoc],\n parameterJsDoc: [...a.parameterJsDoc, ...b.parameterJsDoc],\n };\n}\n\n// -----------------------------------------------------------------------------\n// Preset name resolution (used by loadRegistryByName)\n// -----------------------------------------------------------------------------\n\nexport function generatePresetLookupPaths(input: string) : string[] {\n if (path.isAbsolute(input) || input.startsWith('./') || input.startsWith('../')) {\n return [input];\n }\n\n if (input.startsWith('module:')) {\n return [input.substring('module:'.length)];\n }\n\n if (!input.startsWith('@')) {\n return [input, `@trapi/${input}`];\n }\n\n return [input];\n}\n\n// -----------------------------------------------------------------------------\n// Resolver marker lookups\n// -----------------------------------------------------------------------------\n\n/**\n * Collect the unique decorator names of every handler whose `marker` matches\n * the given predicate. Lets the type resolver discover preset-renamed\n * decorators without hard-coding canonical names.\n */\nexport function namesForMarker(\n registry: Registry,\n predicate: (marker: ResolverMarker) => boolean,\n): Set<string> {\n const names = new Set<string>();\n const all = [\n ...registry.controllers,\n ...registry.methods,\n ...registry.parameters,\n ];\n for (const handler of all) {\n if (handler.marker !== undefined && predicate(handler.marker)) {\n names.add(handler.match.name);\n }\n }\n return names;\n}\n\n/**\n * Collect the unique JSDoc tag names of every JSDoc handler whose `marker`\n * matches the given predicate. JSDoc analogue of `namesForMarker`.\n */\nexport function tagsForMarker(\n registry: Registry,\n predicate: (marker: ResolverMarker) => boolean,\n): Set<string> {\n const tags = new Set<string>();\n const all = [\n ...registry.controllerJsDoc,\n ...registry.methodJsDoc,\n ...registry.parameterJsDoc,\n ];\n for (const handler of all) {\n if (handler.marker !== undefined && predicate(handler.marker)) {\n tags.add(handler.match.tag);\n }\n }\n return tags;\n}\n\nexport function isHiddenMarker(marker: ResolverMarker): boolean {\n return marker === 'hidden';\n}\n\nexport function isDeprecatedMarker(marker: ResolverMarker): boolean {\n return marker === 'deprecated';\n}\n\nexport function isExtensionMarker(marker: ResolverMarker): boolean {\n return marker === 'extension';\n}\n\nexport function numericMarkerKind(\n marker: ResolverMarker,\n): 'int' | 'long' | 'float' | 'double' | undefined {\n if (typeof marker === 'object' && marker !== null && 'numeric' in marker) {\n return marker.numeric;\n }\n return undefined;\n}\n\n// -----------------------------------------------------------------------------\n// Handler builder identity functions (preserve narrow types at declaration site)\n// -----------------------------------------------------------------------------\n\nexport const controller = (handler: ControllerHandler): ControllerHandler => handler;\nexport const method = (handler: MethodHandler): MethodHandler => handler;\nexport const parameter = (handler: ParameterHandler): ParameterHandler => handler;\nexport const controllerJsDoc = (handler: ControllerJsDocHandler): ControllerJsDocHandler => handler;\nexport const methodJsDoc = (handler: MethodJsDocHandler): MethodJsDocHandler => handler;\nexport const parameterJsDoc = (handler: ParameterJsDocHandler): ParameterJsDocHandler => handler;\n\n// -----------------------------------------------------------------------------\n// Apply helpers (Layer 4)\n// -----------------------------------------------------------------------------\n\ntype AnyDraft = ControllerDraft | MethodDraft | ParameterDraft;\ntype DraftApply = (ctx: HandlerContext, draft: AnyDraft) => void;\n\nfunction isLiteralLike(kind: string): boolean {\n return kind === 'literal' || kind === 'identifier';\n}\n\nfunction readArray(draft: AnyDraft, key: string): unknown[] {\n const record = draft as Record<string, unknown>;\n const existing = record[key];\n if (Array.isArray(existing)) {\n return existing;\n }\n if (typeof existing !== 'undefined') {\n throw new TypeError(\n `append(): cannot append to draft key \"${key}\": existing value is not an array (got ${typeof existing}).`,\n );\n }\n const created: unknown[] = [];\n record[key] = created;\n return created;\n}\n\n// Scalar-only writer. Use for fields that hold a single value (path, name, description, ...).\n// Object/array/unresolvable arguments are intentionally ignored — use `append()` for arrays.\nexport function into(key: string) {\n return {\n positional(index: number): DraftApply {\n return (ctx, draft) => {\n const arg = ctx.argument(index);\n if (arg && isLiteralLike(arg.kind)) {\n (draft as Record<string, unknown>)[key] = arg.raw;\n }\n };\n },\n typeArgument(index = 0): DraftApply {\n return (ctx, draft) => {\n const ta = ctx.typeArgument(index);\n if (ta) {\n (draft as Record<string, unknown>)[key] = ta.resolve();\n }\n };\n },\n };\n}\n\n// Array writer. Use for fields that hold lists (tags, produces, security, ...).\n// Array arguments are flattened; scalar arguments are pushed as-is.\nexport function append(key: string) {\n return {\n positional(index: number): DraftApply {\n return (ctx, draft) => {\n const arg = ctx.argument(index);\n if (!arg) {\n return;\n }\n const target = readArray(draft, key);\n if (arg.kind === 'array' && Array.isArray(arg.raw)) {\n target.push(...arg.raw);\n } else if (isLiteralLike(arg.kind)) {\n target.push(arg.raw);\n }\n };\n },\n positionalAll(): DraftApply {\n return (ctx, draft) => {\n const target = readArray(draft, key);\n for (const arg of ctx.arguments()) {\n if (arg.kind === 'array' && Array.isArray(arg.raw)) {\n target.push(...arg.raw);\n } else if (isLiteralLike(arg.kind)) {\n target.push(arg.raw);\n }\n }\n };\n },\n };\n}\n\nexport function flag(key: string, value: unknown = true): DraftApply {\n return (_ctx, draft) => {\n (draft as Record<string, unknown>)[key] = value;\n };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Container } from 'validup';\nimport { createValidator } from '@validup/adapter-zod';\nimport { z } from 'zod';\nimport type { Preset } from '../types';\n\nconst decoratorTargetSchema = z.enum([\n 'class',\n 'method',\n 'parameter',\n 'property',\n]);\n\nconst replacesPolicySchema = z.union([z.literal(true), z.string().min(1)]);\n\nfunction matchSchemaForKind(allowedOn: 'class' | 'method' | 'parameter') {\n return z.object({\n name: z.string().min(1),\n on: decoratorTargetSchema.optional(),\n }).refine(\n (m) => m.on === undefined || m.on === allowedOn,\n {\n message: `match.on is incompatible with the handler array it lives in — expected '${allowedOn}' or omit 'on' entirely.`,\n path: ['on'],\n },\n );\n}\n\nfunction jsDocMatchSchemaForKind(allowedOn: 'class' | 'method' | 'parameter') {\n return z.object({\n tag: z.string().min(1),\n on: decoratorTargetSchema.optional(),\n }).refine(\n (m) => m.on === undefined || m.on === allowedOn,\n {\n message: `match.on is incompatible with the JSDoc handler array it lives in — expected '${allowedOn}' or omit 'on' entirely.`,\n path: ['on'],\n },\n );\n}\n\n// Public re-exports for callers that previously imported the legacy un-kinded schemas.\nexport const matchSchema = z.object({\n name: z.string().min(1),\n on: decoratorTargetSchema.optional(),\n});\n\nexport const jsDocMatchSchema = z.object({\n tag: z.string().min(1),\n on: decoratorTargetSchema.optional(),\n});\n\nconst numericMarkerSchema = z.object({ numeric: z.enum(['int', 'long', 'float', 'double']) });\n\nconst resolverMarkerSchema = z.union([\n z.literal('hidden'),\n z.literal('deprecated'),\n z.literal('extension'),\n numericMarkerSchema,\n]);\n\nconst handlerBaseShape = {\n replaces: replacesPolicySchema.optional(),\n marker: resolverMarkerSchema.optional(),\n apply: z.custom<(...args: unknown[]) => unknown>(\n (value) => typeof value === 'function',\n { message: 'apply must be a function' },\n ),\n};\n\nexport const controllerHandlerSchema = z.object({\n match: matchSchemaForKind('class'),\n ...handlerBaseShape,\n});\n\nexport const methodHandlerSchema = z.object({\n match: matchSchemaForKind('method'),\n ...handlerBaseShape,\n});\n\nexport const parameterHandlerSchema = z.object({\n match: matchSchemaForKind('parameter'),\n ...handlerBaseShape,\n});\n\nexport const controllerJsDocHandlerSchema = z.object({\n match: jsDocMatchSchemaForKind('class'),\n ...handlerBaseShape,\n});\n\nexport const methodJsDocHandlerSchema = z.object({\n match: jsDocMatchSchemaForKind('method'),\n ...handlerBaseShape,\n});\n\nexport const parameterJsDocHandlerSchema = z.object({\n match: jsDocMatchSchemaForKind('parameter'),\n ...handlerBaseShape,\n});\n\nexport const presetSchema = z.object({\n name: z.string().min(1),\n extends: z.array(z.string().min(1)).optional(),\n controllers: z.array(controllerHandlerSchema).optional(),\n methods: z.array(methodHandlerSchema).optional(),\n parameters: z.array(parameterHandlerSchema).optional(),\n controllerJsDoc: z.array(controllerJsDocHandlerSchema).optional(),\n methodJsDoc: z.array(methodJsDocHandlerSchema).optional(),\n parameterJsDoc: z.array(parameterJsDocHandlerSchema).optional(),\n});\n\nexport function createPresetContainer(): Container<Preset> {\n const container = new Container<Preset>();\n container.mount('name', createValidator(presetSchema.shape.name));\n container.mount('extends', { optional: true }, createValidator(presetSchema.shape.extends));\n container.mount('controllers', { optional: true }, createValidator(presetSchema.shape.controllers));\n container.mount('methods', { optional: true }, createValidator(presetSchema.shape.methods));\n container.mount('parameters', { optional: true }, createValidator(presetSchema.shape.parameters));\n container.mount('controllerJsDoc', { optional: true }, createValidator(presetSchema.shape.controllerJsDoc));\n container.mount('methodJsDoc', { optional: true }, createValidator(presetSchema.shape.methodJsDoc));\n container.mount('parameterJsDoc', { optional: true }, createValidator(presetSchema.shape.parameterJsDoc));\n return container;\n}\n\nconst sharedContainer = createPresetContainer();\n\nexport async function validatePreset(input: unknown): Promise<Preset> {\n if (input === null || typeof input !== 'object' || Array.isArray(input)) {\n throw new TypeError('preset input must be an object');\n }\n return sharedContainer.run(input as Record<string, unknown>) as Promise<Preset>;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { load } from 'locter';\nimport type {\n AnyDecoratorHandler,\n AnyJsDocHandler,\n ControllerHandler,\n ControllerJsDocHandler,\n LoadRegistryOptions,\n MethodHandler,\n MethodJsDocHandler,\n ParameterHandler,\n ParameterJsDocHandler,\n Preset,\n Registry,\n ReplacesPolicy,\n} from './types';\nimport { createRegistry, generatePresetLookupPaths } from './utils';\nimport { validatePreset } from './validation';\nimport { ConfigError } from '../../core/error/config';\nimport { ConfigErrorCode } from '../../core/error/config-codes';\nimport { MetadataError } from '../../core/error/base';\n\nconst decoratorKinds = ['controllers', 'methods', 'parameters'] as const;\nconst jsDocKinds = ['controllerJsDoc', 'methodJsDoc', 'parameterJsDoc'] as const;\n\ntype TaggedDecoratorHandler = { origin: string; handler: AnyDecoratorHandler };\ntype TaggedJsDocHandler = { origin: string; handler: AnyJsDocHandler };\n\ntype TaggedRegistry = {\n controllers: { origin: string; handler: ControllerHandler }[];\n methods: { origin: string; handler: MethodHandler }[];\n parameters: { origin: string; handler: ParameterHandler }[];\n controllerJsDoc: { origin: string; handler: ControllerJsDocHandler }[];\n methodJsDoc: { origin: string; handler: MethodJsDocHandler }[];\n parameterJsDoc: { origin: string; handler: ParameterJsDocHandler }[];\n};\n\nfunction emptyTaggedRegistry(): TaggedRegistry {\n return {\n controllers: [],\n methods: [],\n parameters: [],\n controllerJsDoc: [],\n methodJsDoc: [],\n parameterJsDoc: [],\n };\n}\n\nexport async function loadRegistry(\n preset: Preset,\n options: LoadRegistryOptions,\n): Promise<Registry> {\n const tagged = await loadTaggedRegistry(preset, options, new Set());\n return stripOrigins(tagged);\n}\n\nasync function loadTaggedRegistry(\n preset: Preset,\n options: LoadRegistryOptions,\n visited: ReadonlySet<string>,\n): Promise<TaggedRegistry> {\n const validated = await validatePreset(preset);\n\n if (visited.has(validated.name)) {\n throw new MetadataError({ message: `Preset cycle detected: ${[...visited, validated.name].join(' -> ')}` });\n }\n const nextVisited = new Set(visited);\n nextVisited.add(validated.name);\n\n const merged = emptyTaggedRegistry();\n\n for (const extendsName of validated.extends ?? []) {\n const parentPreset = await options.resolver(extendsName);\n const parentRegistry = await loadTaggedRegistry(parentPreset, options, nextVisited);\n appendTagged(merged, parentRegistry);\n }\n\n applyOwnHandlers(merged, validated, !!options.strict);\n\n return merged;\n}\n\nfunction applyOwnHandlers(\n merged: TaggedRegistry,\n preset: Preset,\n strict: boolean,\n): void {\n for (const kind of decoratorKinds) {\n const handlers = (preset[kind] ?? []) as AnyDecoratorHandler[];\n for (const handler of handlers) {\n if (handler.replaces) {\n applyReplacesDecorator(merged, kind, handler, preset.name, strict);\n }\n (merged[kind] as TaggedDecoratorHandler[]).push({ origin: preset.name, handler });\n }\n }\n\n for (const kind of jsDocKinds) {\n const handlers = (preset[kind] ?? []) as AnyJsDocHandler[];\n for (const handler of handlers) {\n if (handler.replaces) {\n applyReplacesJsDoc(merged, kind, handler, preset.name, strict);\n }\n (merged[kind] as TaggedJsDocHandler[]).push({ origin: preset.name, handler });\n }\n }\n}\n\nfunction applyReplacesDecorator(\n merged: TaggedRegistry,\n kind: typeof decoratorKinds[number],\n handler: AnyDecoratorHandler,\n presetName: string,\n strict: boolean,\n): void {\n const list = merged[kind] as TaggedDecoratorHandler[];\n const remaining: TaggedDecoratorHandler[] = [];\n let removed = 0;\n for (const entry of list) {\n if (entry.origin !== presetName &&\n handlerMatches(handler, entry.handler.match.name, entry.handler.match.on) &&\n originMatches(handler.replaces!, entry.origin)) {\n removed += 1;\n continue;\n }\n remaining.push(entry);\n }\n if (removed === 0 && strict) {\n throw new MetadataError({ message: `Preset '${presetName}': handler with replaces=${describeReplaces(handler.replaces!)} on '${handler.match.name}' did not match any parent handler` });\n }\n (merged as Record<string, unknown>)[kind] = remaining;\n}\n\nfunction applyReplacesJsDoc(\n merged: TaggedRegistry,\n kind: typeof jsDocKinds[number],\n handler: AnyJsDocHandler,\n presetName: string,\n strict: boolean,\n): void {\n const list = merged[kind] as TaggedJsDocHandler[];\n const remaining: TaggedJsDocHandler[] = [];\n let removed = 0;\n for (const entry of list) {\n if (entry.origin !== presetName &&\n handlerMatches(handler, entry.handler.match.tag, entry.handler.match.on) &&\n originMatches(handler.replaces!, entry.origin)) {\n removed += 1;\n continue;\n }\n remaining.push(entry);\n }\n if (removed === 0 && strict) {\n throw new MetadataError({ message: `Preset '${presetName}': JSDoc handler with replaces=${describeReplaces(handler.replaces!)} on '@${handler.match.tag}' did not match any parent handler` });\n }\n (merged as Record<string, unknown>)[kind] = remaining;\n}\n\nfunction handlerMatches(\n handler: AnyDecoratorHandler | AnyJsDocHandler,\n targetName: string,\n targetOn: string | undefined,\n): boolean {\n const matchName = 'name' in handler.match ? handler.match.name : handler.match.tag;\n if (matchName !== targetName) {\n return false;\n }\n if (handler.match.on && handler.match.on !== targetOn) {\n return false;\n }\n return true;\n}\n\nfunction originMatches(replaces: ReplacesPolicy, origin: string): boolean {\n if (replaces === true) {\n return true;\n }\n return replaces === origin;\n}\n\nfunction describeReplaces(replaces: ReplacesPolicy): string {\n return replaces === true ? 'true' : `'${replaces}'`;\n}\n\nfunction appendTagged(target: TaggedRegistry, source: TaggedRegistry): void {\n for (const kind of decoratorKinds) {\n (target[kind] as TaggedDecoratorHandler[]).push(...(source[kind] as TaggedDecoratorHandler[]));\n }\n for (const kind of jsDocKinds) {\n (target[kind] as TaggedJsDocHandler[]).push(...(source[kind] as TaggedJsDocHandler[]));\n }\n}\n\nfunction stripOrigins(tagged: TaggedRegistry): Registry {\n const registry = createRegistry();\n registry.controllers = tagged.controllers.map((e) => e.handler);\n registry.methods = tagged.methods.map((e) => e.handler);\n registry.parameters = tagged.parameters.map((e) => e.handler);\n registry.controllerJsDoc = tagged.controllerJsDoc.map((e) => e.handler);\n registry.methodJsDoc = tagged.methodJsDoc.map((e) => e.handler);\n registry.parameterJsDoc = tagged.parameterJsDoc.map((e) => e.handler);\n return registry;\n}\n\n/**\n * Resolve a preset by string identifier (npm package, relative path, etc.) and\n * return the v2 Preset object. Looks for a `preset` named export, then the\n * default export, then the module itself.\n */\nexport async function resolvePresetByName(input: string): Promise<Preset> {\n const lookupPaths = generatePresetLookupPaths(input);\n let lastError: unknown;\n\n for (const lookupPath of lookupPaths) {\n try {\n const moduleExport = await load(lookupPath) as Record<string, unknown>;\n\n const candidates: unknown[] = [\n (moduleExport as { preset?: unknown }).preset,\n (moduleExport as { default?: unknown }).default,\n moduleExport,\n ];\n\n for (const candidate of candidates) {\n if (isV2Preset(candidate)) {\n return candidate;\n }\n }\n } catch (e) {\n // Module-not-found errors are expected when iterating lookup paths;\n // capture the last error so we can surface it if every path fails.\n lastError = e;\n }\n }\n\n throw new ConfigError({\n message: `Preset '${input}' could not be resolved.`,\n code: ConfigErrorCode.PRESET_NOT_FOUND,\n cause: lastError,\n });\n}\n\n/**\n * Resolve a preset by name and immediately materialize its registry, recursively\n * loading `extends` parents through the same resolver.\n */\nexport async function loadRegistryByName(input: string): Promise<Registry> {\n const preset = await resolvePresetByName(input);\n return loadRegistry(preset, { resolver: resolvePresetByName });\n}\n\nfunction isV2Preset(input: unknown): input is Preset {\n return (\n typeof input === 'object' &&\n input !== null &&\n typeof (input as { name?: unknown }).name === 'string' &&\n !('items' in input)\n );\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Type } from '../../core/resolver/types';\nimport type {\n DecoratorArgument,\n DecoratorHost,\n DecoratorTypeArgument,\n HandlerContext,\n} from './types';\n\n/**\n * Build a literal-kind {@link DecoratorArgument} from a primitive value.\n * Use this in unit tests to feed handlers a mock argument:\n *\n * ```ts\n * const ctx = createHandlerContext({ args: [literalArg('users')] });\n * controllerHandler.apply(ctx, draft);\n * ```\n */\nexport function literalArg(raw: string | number | boolean | null): DecoratorArgument {\n return { kind: 'literal', raw };\n}\n\n/**\n * Build an identifier-kind {@link DecoratorArgument} (e.g. `@Foo(SOME_CONSTANT)`).\n * `raw` is the resolved value the identifier points to — typically a string.\n */\nexport function identifierArg(raw: unknown): DecoratorArgument {\n return { kind: 'identifier', raw };\n}\n\n/**\n * Build an array-kind {@link DecoratorArgument} (e.g. `@Foo(['a', 'b'])`).\n */\nexport function arrayArg(raw: unknown[]): DecoratorArgument {\n return { kind: 'array', raw };\n}\n\n/**\n * Build an object-kind {@link DecoratorArgument} (e.g. `@Foo({ key: 'value' })`).\n */\nexport function objectArg(raw: Record<string, unknown>): DecoratorArgument {\n return { kind: 'object', raw };\n}\n\n/**\n * Build an unresolvable-kind {@link DecoratorArgument} — represents arguments\n * the source extractor couldn't statically evaluate (e.g. function calls,\n * unknown identifiers).\n */\nexport function unresolvableArg(): DecoratorArgument {\n return { kind: 'unresolvable', raw: undefined };\n}\n\n/**\n * Build a {@link DecoratorTypeArgument} stub that returns the supplied type\n * when `resolve()` is called.\n */\nexport function typeArg(type: Type): DecoratorTypeArgument {\n return { resolve: () => type };\n}\n\nexport type CreateHandlerContextInput = {\n args?: DecoratorArgument[];\n typeArgs?: DecoratorTypeArgument[];\n host?: DecoratorHost;\n parameterType?: Type;\n};\n\n/**\n * Construct a {@link HandlerContext} for unit-testing handlers in isolation\n * without spinning up the full TypeScript compiler / `generateMetadata`\n * pipeline. Combine with the `*Arg(...)` builders to feed a handler a\n * controlled mock decorator source.\n *\n * ```ts\n * const ctx = createHandlerContext({ args: [literalArg('users')] });\n * const draft = newControllerDraft({ name: 'UserController', location: '/x.ts' });\n * myHandler.apply(ctx, draft);\n * expect(draft.paths).toEqual(['users']);\n * ```\n */\nexport function createHandlerContext(input: CreateHandlerContextInput = {}): HandlerContext {\n const args = input.args ?? [];\n const typeArgs = input.typeArgs ?? [];\n return {\n host: input.host ?? { name: 'TestHost' },\n argument: (index) => args[index],\n arguments: () => [...args],\n typeArgument: (index) => typeArgs[index],\n typeArguments: () => [...typeArgs],\n parameterType: () => input.parameterType,\n };\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum JSDocTagName {\n ABSTRACT = 'abstract',\n ACCESS = 'access',\n ALIAS = 'alias',\n ASYNC = 'async',\n /**\n * Alias for @extends\n */\n AUGMENTS = 'augments',\n AUTHOR = 'author',\n\n // todo: ... add missing\n\n DEFAULT = 'default',\n DEPRECATED = 'deprecated',\n DESCRIPTION = 'description',\n EXAMPLE = 'example',\n\n FORMAT = 'format',\n\n IGNORE = 'ignore',\n\n SUMMARY = 'summary',\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isStringArray(input: unknown) : input is string[] {\n if (!Array.isArray(input)) {\n return false;\n }\n\n for (const element of input) {\n if (typeof element !== 'string') {\n return false;\n }\n }\n\n return true;\n}\n","/*\n * Copyright (c) 2021-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function hasOwnProperty<Y extends PropertyKey>(obj: unknown, prop: Y): obj is Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function normalizePath(str: string) : string {\n // remove slashes\n str = str.replace(/^[/\\\\\\s]+|[/\\\\\\s]+$/g, '');\n\n str = str.replace(/([^:]\\/)\\/+/g, '$1');\n\n return str;\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from 'locter';\nimport type { JSDocComment, NodeArray } from 'typescript';\n\nexport function transformJSDocComment(\n input?: string | NodeArray<JSDocComment>,\n) : string | undefined {\n if (typeof input === 'string') {\n return input;\n }\n\n if (!input || input.length === 0) {\n return undefined;\n }\n\n const comment = input[0];\n if (typeof comment === 'string') {\n return comment;\n }\n\n if (\n isObject(comment) &&\n typeof comment.text === 'string'\n ) {\n return comment.text;\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2021-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n Identifier, \n JSDoc, \n JSDocTag, \n Node,\n} from 'typescript';\nimport { SyntaxKind, isJSDocParameterTag } from 'typescript';\nimport { MetadataError } from '../../../core/error';\nimport { hasOwnProperty } from '../../../core/utils';\nimport type { JSDocTagName } from './constants';\nimport { transformJSDocComment } from './utils';\n\n// -----------------------------------------\n// Description\n// -----------------------------------------\nexport function getJSDocDescription(node: Node, index?: number) : string | undefined {\n const jsDoc = getJSDoc(node, index);\n if (!jsDoc) {\n return undefined;\n }\n\n return transformJSDocComment(jsDoc.comment);\n}\n\n// -----------------------------------------\n// Tag\n// -----------------------------------------\n\nexport function getJSDoc(node: Node, index?: number) : undefined | JSDoc {\n if (!hasOwnProperty(node, 'jsDoc')) {\n return undefined;\n }\n\n const jsDoc : JSDoc[] | undefined = (node as any).jsDoc as JSDoc[];\n\n if (!jsDoc || !Array.isArray(jsDoc) || !jsDoc.length) {\n return undefined;\n }\n\n index = index ?? 0;\n return jsDoc.length > index && index >= 0 ? jsDoc[index] : undefined; // jsDoc[0] else case\n}\n\nexport function getJSDocTags(\n node: Node,\n isMatching?:\n | `${JSDocTagName}` |\n `${JSDocTagName}`[] |\n (string & {}) |\n (string & {})[] |\n ((tag: JSDocTag) => boolean),\n) : JSDocTag[] {\n const jsDoc : JSDoc = getJSDoc(node);\n if (typeof jsDoc === 'undefined') {\n return [];\n }\n\n const jsDocTags : JSDocTag[] = jsDoc.tags as unknown as JSDocTag[];\n\n if (typeof jsDocTags === 'undefined') {\n return [];\n }\n\n if (typeof isMatching === 'undefined') {\n return jsDocTags;\n }\n\n if (typeof isMatching === 'function') {\n return jsDocTags.filter(isMatching);\n }\n\n const tagNames : string[] = Array.isArray(isMatching) ? isMatching : [isMatching];\n\n return jsDocTags.filter((tag) => tagNames.includes(tag.tagName.text));\n}\n\nexport function hasJSDocTag(node: Node, tagName: ((tag: JSDocTag) => boolean) | `${JSDocTagName}` | (string & {})) : boolean {\n const tags : JSDocTag[] = getJSDocTags(node, tagName);\n\n return !(!tags || !tags.length);\n}\n\n// -----------------------------------------\n// Tag Comment(s)\n// -----------------------------------------\n\nexport function getJSDocTagComment(node: Node, tagName: ((tag: JSDocTag) => boolean) | `${JSDocTagName}`) : undefined | string {\n const tags : JSDocTag[] = getJSDocTags(node, tagName);\n\n if (!tags || !tags.length || typeof tags[0].comment !== 'string') {\n return undefined;\n }\n return tags[0].comment;\n}\n\n// -----------------------------------------\n// Tag Names\n// -----------------------------------------\n\nexport function getJSDocTagNames(node: Node, requireTagName = false) : string[] {\n let tags: JSDocTag[];\n\n /* istanbul ignore next */\n if (node.kind === SyntaxKind.Parameter) {\n const parameterName = ((node as any).name as Identifier).text;\n tags = getJSDocTags(node.parent as any, (tag) => {\n if (isJSDocParameterTag(tag)) {\n return false;\n } if (tag.comment === undefined) {\n throw new MetadataError(`Orphan tag: @${String(tag.tagName.text || tag.tagName.escapedText)} must be followed by a parameter name.`);\n }\n return typeof tag.comment === 'string' ? tag.comment.startsWith(parameterName) : false;\n });\n } else {\n tags = getJSDocTags(node as any, (tag) => (requireTagName ? tag.comment !== undefined : true));\n }\n\n return tags.map((tag) => tag.tagName.text);\n}\n","/*\n * Copyright (c) 2021-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { MetadataError } from '../../core/error';\nimport type { Type } from '../../core/types/resolver';\nimport { hasOwnProperty } from '../../core/utils/object';\n\nexport function getInitializerValue(\n initializer?: ts.Expression,\n typeChecker?: ts.TypeChecker,\n type?: Type,\n) : unknown {\n if (!initializer) {\n return undefined;\n }\n\n switch (initializer.kind) {\n case ts.SyntaxKind.ArrayLiteralExpression: {\n const arrayLiteral = initializer as ts.ArrayLiteralExpression;\n return arrayLiteral.elements.map((element) => getInitializerValue(element, typeChecker));\n }\n case ts.SyntaxKind.StringLiteral:\n case ts.SyntaxKind.NoSubstitutionTemplateLiteral:\n return (initializer as ts.StringLiteral).text;\n case ts.SyntaxKind.TrueKeyword:\n return true;\n case ts.SyntaxKind.FalseKeyword:\n return false;\n case ts.SyntaxKind.PrefixUnaryExpression: {\n const prefixUnary = initializer as ts.PrefixUnaryExpression;\n switch (prefixUnary.operator) {\n case ts.SyntaxKind.PlusToken:\n return Number((prefixUnary.operand as ts.NumericLiteral).text);\n case ts.SyntaxKind.MinusToken:\n return Number(`-${(prefixUnary.operand as ts.NumericLiteral).text}`);\n default:\n throw new MetadataError(`Unsupported prefix operator token: ${prefixUnary.operator}`);\n }\n }\n case ts.SyntaxKind.NumberKeyword:\n case ts.SyntaxKind.FirstLiteralToken:\n return Number((initializer as ts.NumericLiteral).text);\n case ts.SyntaxKind.NewExpression: {\n const newExpression = initializer as ts.NewExpression;\n const ident = newExpression.expression as ts.Identifier;\n\n if (ident.text === 'Date') {\n let date = new Date();\n if (newExpression.arguments) {\n const newArguments = newExpression.arguments.filter((args) => args.kind !== undefined);\n const argsValue = newArguments.map((args) => getInitializerValue(args, typeChecker));\n if (argsValue.length > 0) {\n date = new Date(argsValue as any);\n }\n }\n const dateString = date.toISOString();\n if (type && type.typeName === 'date') {\n return dateString.split('T')[0];\n }\n\n return dateString;\n }\n\n return undefined;\n }\n case ts.SyntaxKind.NullKeyword: {\n return null;\n }\n case ts.SyntaxKind.ObjectLiteralExpression: {\n const objectLiteral = initializer as ts.ObjectLiteralExpression;\n const nestedObject: any = {};\n objectLiteral.properties.forEach((p: any) => {\n nestedObject[p.name.text] = getInitializerValue(p.initializer, typeChecker);\n });\n return nestedObject;\n }\n case ts.SyntaxKind.ImportSpecifier: {\n if (typeof typeChecker === 'undefined') {\n return undefined;\n }\n\n const importSpecifier = (initializer as any) as ts.ImportSpecifier;\n const importSymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);\n if (!importSymbol) {\n return undefined;\n }\n\n const aliasedSymbol = typeChecker.getAliasedSymbol(importSymbol);\n const declarations = aliasedSymbol.getDeclarations();\n const declaration = declarations && declarations.length > 0 ? declarations[0] : undefined;\n return getInitializerValue(extractInitializer(declaration), typeChecker);\n }\n default: {\n if (typeof initializer === 'undefined') {\n return undefined;\n }\n if (\n typeof initializer.parent === 'undefined' ||\n typeof typeChecker === 'undefined'\n ) {\n if (hasOwnProperty(initializer, 'text')) {\n return initializer.text;\n }\n\n return undefined;\n }\n\n const symbol = typeChecker.getSymbolAtLocation(initializer);\n return getInitializerValue(\n extractInitializer(symbol.valueDeclaration) || extractInitializer(extractImportSpecifier(symbol)),\n typeChecker,\n );\n }\n }\n}\n\nexport const hasInitializer = (\n node: ts.Node,\n): node is ts.HasInitializer => Object.prototype.hasOwnProperty.call(node, 'initializer');\nconst extractInitializer = (\n valueDeclaration?: ts.Declaration,\n) => (valueDeclaration && hasInitializer(valueDeclaration) && (valueDeclaration.initializer as ts.Expression)) || undefined;\nconst extractImportSpecifier = (\n symbol?: ts.Symbol,\n) => (symbol?.declarations && symbol.declarations.length > 0 && ts.isImportSpecifier(symbol.declarations[0]) && symbol.declarations[0]) || undefined;\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n Expression, \n Node, \n TypeChecker,\n} from 'typescript';\nimport * as ts from 'typescript';\nimport { getInitializerValue } from '../../typescript/initializer';\nimport type { DecoratorArgument } from '../types';\n\nexport type RawDecorator = {\n name: string;\n arguments: DecoratorArgument[];\n};\n\n/**\n * Enumerate decorators on a TS node and classify their argument values without\n * going through the registry. Used by read-side consumers (type resolver,\n * extension extraction) that only need decorator names + argument values.\n */\nexport function readNodeDecorators(node: Node, typeChecker?: TypeChecker): RawDecorator[] {\n if (!ts.canHaveDecorators(node)) {\n return [];\n }\n const decorators = ts.getDecorators(node);\n if (!decorators || decorators.length === 0) {\n return [];\n }\n\n const output: RawDecorator[] = [];\n for (const decorator of decorators) {\n const { expression } = decorator;\n let name: string | undefined;\n let argumentExpressions: readonly ts.Expression[] = [];\n\n if (ts.isCallExpression(expression)) {\n argumentExpressions = expression.arguments;\n name = readDecoratorName(expression.expression);\n } else {\n name = readDecoratorName(expression);\n }\n\n if (!name) {\n continue;\n }\n\n output.push({\n name,\n arguments: argumentExpressions.map((a) => buildDecoratorArgument(a, typeChecker)),\n });\n }\n return output;\n}\n\nexport function findDecoratorByName(\n node: Node,\n name: string,\n typeChecker?: TypeChecker,\n): RawDecorator | undefined {\n return readNodeDecorators(node, typeChecker).find((d) => d.name === name);\n}\n\nexport function findDecoratorsByName(\n node: Node,\n name: string,\n typeChecker?: TypeChecker,\n): RawDecorator[] {\n return readNodeDecorators(node, typeChecker).filter((d) => d.name === name);\n}\n\nexport function hasDecoratorNamed(node: Node, name: string, typeChecker?: TypeChecker): boolean {\n return readNodeDecorators(node, typeChecker).some((d) => d.name === name);\n}\n\nfunction readDecoratorName(expression: ts.Node): string | undefined {\n if (ts.isIdentifier(expression)) {\n return expression.text;\n }\n if (ts.isPropertyAccessExpression(expression)) {\n return expression.name.text;\n }\n return undefined;\n}\n\nexport function buildDecoratorArgument(\n expr: Expression,\n typeChecker?: TypeChecker,\n): DecoratorArgument {\n if (\n ts.isStringLiteral(expr) ||\n ts.isNumericLiteral(expr) ||\n ts.isNoSubstitutionTemplateLiteral(expr)\n ) {\n return { raw: getInitializerValue(expr, typeChecker), kind: 'literal' };\n }\n\n if (expr.kind === ts.SyntaxKind.TrueKeyword) {\n return { raw: true, kind: 'literal' };\n }\n\n if (expr.kind === ts.SyntaxKind.FalseKeyword) {\n return { raw: false, kind: 'literal' };\n }\n\n if (expr.kind === ts.SyntaxKind.NullKeyword) {\n return { raw: null, kind: 'literal' };\n }\n\n if (\n ts.isPrefixUnaryExpression(expr) &&\n (expr.operator === ts.SyntaxKind.PlusToken || expr.operator === ts.SyntaxKind.MinusToken) &&\n ts.isNumericLiteral(expr.operand)\n ) {\n return { raw: getInitializerValue(expr, typeChecker), kind: 'literal' };\n }\n\n if (ts.isObjectLiteralExpression(expr)) {\n return { raw: getInitializerValue(expr, typeChecker), kind: 'object' };\n }\n\n if (ts.isArrayLiteralExpression(expr)) {\n return { raw: getInitializerValue(expr, typeChecker), kind: 'array' };\n }\n\n if (ts.isIdentifier(expr) || ts.isPropertyAccessExpression(expr)) {\n const value = getInitializerValue(expr, typeChecker);\n if (typeof value !== 'undefined') {\n return { raw: value, kind: 'identifier' };\n }\n return { raw: undefined, kind: 'unresolvable' };\n }\n\n return { raw: undefined, kind: 'unresolvable' };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { JSDocTag, Node, TypeNode } from 'typescript';\nimport * as ts from 'typescript';\nimport { getJSDocTags } from '../../typescript/js-doc';\nimport { transformJSDocComment } from '../../typescript/js-doc/utils';\nimport type {\n DecoratorArgument,\n DecoratorSource,\n DecoratorTypeArgument,\n JsDocSource,\n} from '../types';\nimport type { DecoratorSourceBuilderOptions, JsDocSourceBuilderOptions } from './types';\nimport { buildDecoratorArgument } from './utils';\n\n// -----------------------------------------------------------------------------\n// Decorator sources\n// -----------------------------------------------------------------------------\n\nexport function buildDecoratorSources(\n node: Node,\n options: DecoratorSourceBuilderOptions,\n): DecoratorSource[] {\n if (!ts.canHaveDecorators(node)) {\n return [];\n }\n\n const decorators = ts.getDecorators(node);\n if (!decorators || decorators.length === 0) {\n return [];\n }\n\n const output: DecoratorSource[] = [];\n for (const decorator of decorators) {\n const source = buildDecoratorSource(decorator, options);\n if (source) {\n output.push(source);\n }\n }\n return output;\n}\n\nfunction buildDecoratorSource(\n decorator: ts.Decorator,\n options: DecoratorSourceBuilderOptions,\n): DecoratorSource | undefined {\n const { expression } = decorator;\n\n let name: string | undefined;\n let argumentExpressions: readonly ts.Expression[] = [];\n let typeArgumentNodes: readonly ts.TypeNode[] = [];\n\n if (ts.isCallExpression(expression)) {\n argumentExpressions = expression.arguments;\n typeArgumentNodes = expression.typeArguments ?? [];\n name = readDecoratorName(expression.expression);\n } else {\n name = readDecoratorName(expression);\n }\n\n if (!name) {\n return undefined;\n }\n\n const decoratorArguments: DecoratorArgument[] = argumentExpressions.map(\n (arg) => buildDecoratorArgument(arg, options.typeChecker),\n );\n\n const decoratorTypeArguments: DecoratorTypeArgument[] = typeArgumentNodes.map(\n (typeNode) => ({ resolve: () => options.resolveTypeNode(typeNode) }),\n );\n\n const sourceFile = decorator.getSourceFile();\n const location = sourceFile ? {\n file: sourceFile.fileName,\n line: sourceFile.getLineAndCharacterOfPosition(decorator.getStart()).line + 1,\n } : undefined;\n\n return {\n name,\n arguments: decoratorArguments,\n typeArguments: decoratorTypeArguments,\n target: options.target,\n host: options.host,\n location,\n };\n}\n\nfunction readDecoratorName(expression: ts.Node): string | undefined {\n if (ts.isIdentifier(expression)) {\n return expression.text;\n }\n if (ts.isPropertyAccessExpression(expression)) {\n return expression.name.text;\n }\n return undefined;\n}\n\n// -----------------------------------------------------------------------------\n// JSDoc sources\n// -----------------------------------------------------------------------------\n\nexport function buildJsDocSources(\n node: Node,\n options: JsDocSourceBuilderOptions,\n): JsDocSource[] {\n const tags = getJSDocTags(node);\n if (tags.length === 0) {\n return [];\n }\n\n const output: JsDocSource[] = [];\n for (const tag of tags) {\n output.push(buildJsDocSource(tag, options));\n }\n return output;\n}\n\nfunction buildJsDocSource(\n tag: JSDocTag,\n options: JsDocSourceBuilderOptions,\n): JsDocSource {\n const tagName = tag.tagName.text;\n const text = transformJSDocComment(tag.comment);\n\n let parameterName: string | undefined;\n let typeNode: TypeNode | undefined;\n\n if (ts.isJSDocParameterTag(tag) || ts.isJSDocPropertyTag(tag)) {\n if (tag.name) {\n parameterName = readEntityName(tag.name);\n }\n typeNode = tag.typeExpression?.type;\n } else if (\n ts.isJSDocReturnTag(tag) ||\n ts.isJSDocTypeTag(tag) ||\n ts.isJSDocThisTag(tag)\n ) {\n typeNode = tag.typeExpression?.type;\n }\n\n const source: JsDocSource = {\n tag: tagName,\n target: options.target,\n host: options.host,\n };\n\n if (typeof text !== 'undefined') {\n source.text = text;\n }\n\n if (typeof parameterName !== 'undefined') {\n source.parameterName = parameterName;\n }\n\n if (typeNode) {\n const capturedTypeNode = typeNode;\n source.typeExpression = { resolve: () => options.resolveTypeNode(capturedTypeNode) };\n }\n\n return source;\n}\n\nfunction readEntityName(name: ts.EntityName): string | undefined {\n if (ts.isIdentifier(name)) {\n return name.text;\n }\n if (ts.isQualifiedName(name)) {\n const left = readEntityName(name.left);\n return left ? `${left}.${name.right.text}` : name.right.text;\n }\n return undefined;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node } from 'typescript';\nimport { matches, matchesJsDoc } from '../utils';\nimport type {\n DecoratorSource,\n HandlerContext,\n JsDocHandlerContext,\n JsDocMatch,\n JsDocSource,\n Match,\n} from '../types';\nimport { buildDecoratorSources, buildJsDocSources } from '../typescript';\nimport type { ApplyHandlersOptions } from './types';\n\ntype DecoratorHandlerLike<D> = {\n match: Match;\n apply: (ctx: HandlerContext, draft: D) => void;\n};\n\ntype JsDocHandlerLike<D> = {\n match: JsDocMatch;\n apply: (ctx: JsDocHandlerContext, draft: D) => void;\n};\n\nexport function buildHandlerContext(\n source: DecoratorSource,\n options: ApplyHandlersOptions,\n): HandlerContext {\n return {\n host: source.host,\n argument: (i) => source.arguments[i],\n arguments: () => source.arguments,\n typeArgument: (i) => source.typeArguments[i],\n typeArguments: () => source.typeArguments,\n parameterType: options.parameterType ?? (() => undefined),\n };\n}\n\nexport function buildJsDocHandlerContext(\n source: JsDocSource,\n options: ApplyHandlersOptions,\n): JsDocHandlerContext {\n return {\n host: source.host,\n source,\n parameterType: options.parameterType ?? (() => undefined),\n };\n}\n\nexport function applyDecoratorHandlers<D>(\n node: Node,\n handlers: DecoratorHandlerLike<D>[],\n draft: D,\n options: ApplyHandlersOptions,\n): void {\n if (handlers.length === 0 && !options.onUnmatchedDecorator) {\n return;\n }\n const sources = buildDecoratorSources(node, options);\n if (sources.length === 0) {\n return;\n }\n for (const source of sources) {\n let matched = 0;\n for (const handler of handlers) {\n if (matches(handler.match, source)) {\n handler.apply(buildHandlerContext(source, options), draft);\n matched += 1;\n }\n }\n if (matched === 0 && options.onUnmatchedDecorator) {\n // Prefer the decorator's own AST line if `buildDecoratorSources`\n // populated it; fall back to the host node's line otherwise.\n let file: string;\n let line: number;\n if (source.location) {\n file = source.location.file;\n line = source.location.line;\n } else {\n const sourceFile = node.getSourceFile();\n file = sourceFile.fileName;\n line = sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1;\n }\n options.onUnmatchedDecorator(\n {\n name: source.name,\n target: source.target,\n host: source.host,\n file,\n line,\n },\n source,\n );\n }\n }\n}\n\nexport function applyJsDocHandlers<D>(\n node: Node,\n handlers: JsDocHandlerLike<D>[],\n draft: D,\n options: ApplyHandlersOptions,\n): void {\n if (handlers.length === 0) {\n return;\n }\n const sources = buildJsDocSources(node, options);\n if (sources.length === 0) {\n return;\n }\n for (const source of sources) {\n for (const handler of handlers) {\n if (matchesJsDoc(handler.match, source)) {\n handler.apply(buildJsDocHandlerContext(source, options), draft);\n }\n }\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { MetadataError } from './base';\n\nexport class ValidatorError extends MetadataError {\n\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum ValidatorName {\n UNIQUE_ITEMS = 'uniqueItems',\n\n MINIMUM = 'minimum',\n MAXIMUM = 'maximum',\n MIN_ITEMS = 'minItems',\n MAX_ITEMS = 'maxItems',\n MIN_LENGTH = 'minLength',\n MAX_LENGTH = 'maxLength',\n\n MIN_DATE = 'minDate',\n MAX_DATE = 'maxDate',\n\n PATTERN = 'pattern',\n}\n\nexport const ValidatorErrorCode = {\n EXPECTED_NUMBER: 'VALIDATOR_EXPECTED_NUMBER',\n EXPECTED_DATE: 'VALIDATOR_EXPECTED_DATE',\n EXPECTED_STRING: 'VALIDATOR_EXPECTED_STRING',\n} as const;\n","/*\n * Copyright (c) 2021-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n ParameterDeclaration, \n PropertyDeclaration, \n PropertySignature, \n TypeAliasDeclaration,\n} from 'typescript';\nimport type { Validator } from '../../../core/types/validator';\nimport { ValidatorError } from '../../../core/error/validator';\nimport { getJSDocTags, transformJSDocComment } from '../js-doc';\nimport { ValidatorErrorCode, ValidatorName } from '../../../core/error/validator-codes';\n\nexport function getDeclarationValidators(\n declaration: PropertyDeclaration | TypeAliasDeclaration | PropertySignature | ParameterDeclaration,\n name?: string,\n): Record<string, Validator> {\n if (!declaration.parent) {\n return {};\n }\n\n const getCommentValue = (comment?: string) => comment && comment.split(' ')[0];\n\n const parameterTags = getSupportedParameterTags();\n const tags = getJSDocTags(declaration.parent, (tag) => {\n const { comment } = tag;\n const text : string = transformJSDocComment(comment);\n if (!comment) {\n return false;\n }\n\n const commentValue = getCommentValue(text);\n\n return parameterTags.some((value) => {\n if (value !== tag.tagName.text) {\n return false;\n }\n\n return !(name && name !== commentValue);\n });\n });\n\n function getErrorMsg(comment?: string, isValue = true) : string {\n if (!comment) {\n return undefined;\n }\n if (isValue) {\n const indexOf = comment.indexOf(' ');\n if (indexOf > 0) {\n return comment.substring(indexOf + 1);\n }\n return undefined;\n }\n\n return comment;\n }\n\n const validators : Record<string, Validator> = {};\n\n for (const tag of tags) {\n if (!tag.comment) {\n continue;\n }\n\n const name = tag.tagName.text;\n\n let comment = transformJSDocComment(tag.comment);\n comment = comment.substring(comment.indexOf(' ') + 1).trim();\n\n const value = getCommentValue(comment);\n\n switch (name) {\n case ValidatorName.UNIQUE_ITEMS:\n validators[name] = {\n message: getErrorMsg(comment, false),\n value: undefined,\n };\n break;\n case ValidatorName.MINIMUM:\n case ValidatorName.MAXIMUM:\n case ValidatorName.MIN_ITEMS:\n case ValidatorName.MAX_ITEMS:\n case ValidatorName.MIN_LENGTH:\n case ValidatorName.MAX_LENGTH:\n {\n const parsed = Number(value);\n if (!Number.isFinite(parsed)) {\n throw new ValidatorError({\n message: `@${name} validator expects a numeric value, got '${value}'.`,\n code: ValidatorErrorCode.EXPECTED_NUMBER,\n });\n }\n validators[name] = {\n message: getErrorMsg(comment),\n value: parsed,\n };\n }\n break;\n case ValidatorName.MIN_DATE:\n case ValidatorName.MAX_DATE:\n if (typeof value !== 'string') {\n throw new ValidatorError({\n message: `@${name} validator expects a date string, got '${typeof value}'.`,\n code: ValidatorErrorCode.EXPECTED_DATE,\n });\n }\n\n validators[name] = {\n message: getErrorMsg(comment),\n value,\n };\n break;\n case ValidatorName.PATTERN:\n if (typeof value !== 'string') {\n throw new ValidatorError({\n message: `@${name} validator expects a string pattern, got '${value}'.`,\n code: ValidatorErrorCode.EXPECTED_STRING,\n });\n }\n\n validators[name] = {\n message: getErrorMsg(comment),\n value: removeSurroundingQuotes(value),\n };\n break;\n default:\n if (name.toLowerCase().startsWith('is')) {\n const errorMsg = getErrorMsg(comment, false);\n if (errorMsg) {\n validators[name] = {\n message: errorMsg,\n value: undefined,\n };\n }\n }\n break;\n }\n }\n\n return validators;\n}\n\nfunction getSupportedParameterTags() {\n return [\n 'isString',\n 'isBoolean',\n 'isInt',\n 'isLong',\n 'isFloat',\n 'isDouble',\n 'isDate',\n 'isDateTime',\n\n 'minItems',\n 'maxItems',\n 'uniqueItems',\n 'minLength',\n 'maxLength',\n 'pattern',\n 'minimum',\n 'maximum',\n 'minDate',\n 'maxDate',\n ];\n}\n\nfunction removeSurroundingQuotes(str: string) {\n if (str.startsWith('`') && str.endsWith('`')) {\n return str.substring(1, str.length - 1);\n }\n if (str.startsWith('```') && str.endsWith('```')) {\n return str.substring(3, str.length - 3);\n }\n return str;\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { normalize } from 'node:path';\nimport { isBaseError } from '@ebec/core';\nimport type { Node, TypeNode } from 'typescript';\nimport { MetadataError } from './base';\n\nexport class ResolverError extends MetadataError {\n public readonly file?: string;\n\n public readonly line?: number;\n\n constructor(\n message: string,\n node?: Node | TypeNode,\n options?: boolean | { onlyCurrent?: boolean, cause?: unknown },\n ) {\n const opts = typeof options === 'boolean' ? { onlyCurrent: options } : options;\n const onlyCurrent = opts?.onlyCurrent ?? false;\n\n const parts: string[] = [message];\n let file: string | undefined;\n let line: number | undefined;\n\n if (node) {\n const location = prettyLocationOfNode(node);\n if (location) {\n parts.push(location.text);\n file = location.file;\n line = location.line;\n }\n\n parts.push(prettyTroubleCause(node, onlyCurrent));\n }\n\n super({\n message: parts.join('\\n'),\n cause: opts?.cause,\n });\n\n this.file = file;\n this.line = line;\n }\n}\n\nexport function isResolverError(input: unknown): input is ResolverError {\n if (!isBaseError(input)) {\n return false;\n }\n\n return 'file' in input && 'line' in input;\n}\n\nexport function prettyLocationOfNode(node: Node | TypeNode): {\n text: string,\n file: string,\n line?: number,\n} | undefined {\n try {\n const sourceFile = node.getSourceFile();\n if (!sourceFile) return undefined;\n\n const token = node.getFirstToken() || node.parent?.getFirstToken();\n const start = token ? sourceFile.getLineAndCharacterOfPosition(token.getStart()).line + 1 : undefined;\n const end = token ? sourceFile.getLineAndCharacterOfPosition(token.getEnd()).line + 1 : undefined;\n\n const normalizedFile = normalize(sourceFile.fileName);\n const startSuffix = start ? `:${start}` : '';\n const endSuffix = end ? `:${end}` : '';\n\n return {\n text: `At: ${normalizedFile}${startSuffix}${endSuffix}.`,\n file: sourceFile.fileName,\n line: start,\n };\n } catch {\n return undefined;\n }\n}\n\nexport function prettyTroubleCause(node: Node | TypeNode, onlyCurrent = false) {\n try {\n let name: string;\n if (onlyCurrent || !node.parent) {\n name = node.pos !== -1 ? node.getText() : (node as any).name.text;\n } else {\n name = node.parent.pos !== -1 ? node.parent.getText() : (node as any).parent.name.text;\n }\n\n return `This was caused by '${name}'`;\n } catch {\n return 'This was caused by an unknown node';\n }\n}\n","/*\n * Copyright (c) 2023-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node } from 'typescript';\nimport {\n type Registry,\n findDecoratorsByName,\n isExtensionMarker,\n namesForMarker,\n} from '../../../decorator';\nimport type { Extension } from '../../../../core/types/extension';\n\nexport function getNodeExtensions(node: Node, registry: Registry) : Extension[] {\n const names = namesForMarker(registry, isExtensionMarker);\n if (names.size === 0) {\n return [];\n }\n\n const output : Extension[] = [];\n for (const name of names) {\n const decorators = findDecoratorsByName(node, name);\n for (const decorator of decorators) {\n const keyArg = decorator.arguments[0];\n const valueArg = decorator.arguments[1];\n if (!keyArg || keyArg.kind !== 'literal' || typeof keyArg.raw !== 'string') {\n continue;\n }\n if (!valueArg || valueArg.kind === 'unresolvable' || typeof valueArg.raw === 'undefined') {\n continue;\n }\n output.push({ key: keyArg.raw, value: valueArg.raw as never });\n }\n }\n return output;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { ArrayType, SubResolverContext, Type } from '../types';\n\nexport function resolveArrayType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isArrayTypeNode(typeNode)) {\n return undefined;\n }\n\n return {\n typeName: TypeName.ARRAY,\n elementType: ctx.resolveType(\n typeNode.elementType,\n ctx.parentNode,\n ctx.context,\n ),\n } as ArrayType;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node } from 'typescript';\nimport {\n SyntaxKind,\n canHaveModifiers,\n getModifiers,\n} from 'typescript';\n\n\nexport class ResolverBase {\n protected hasPublicModifier(node: Node) {\n if (!canHaveModifiers(node)) {\n return true;\n }\n\n const modifiers = getModifiers(node);\n if (!modifiers) {\n return true;\n }\n\n return modifiers.every(\n (modifier) => modifier.kind !== SyntaxKind.ProtectedKeyword && modifier.kind !== SyntaxKind.PrivateKeyword,\n );\n }\n\n protected hasStaticModifier(node: Node) {\n if (!canHaveModifiers(node)) {\n return false;\n }\n\n const modifiers = getModifiers(node);\n\n return modifiers && modifiers.some((modifier) => modifier.kind === SyntaxKind.StaticKeyword);\n }\n\n protected isAccessibleParameter(node: Node) {\n // No modifiers\n if (!canHaveModifiers(node)) {\n return false;\n }\n\n const modifiers = getModifiers(node);\n if (!modifiers) {\n return false;\n }\n\n // public || public readonly\n if (modifiers.some((modifier) => modifier.kind === SyntaxKind.PublicKeyword)) {\n return true;\n }\n\n // readonly, not private readonly, not public readonly\n const isReadonly = modifiers.some((modifier) => modifier.kind === SyntaxKind.ReadonlyKeyword);\n const isProtectedOrPrivate = modifiers.some(\n (modifier) => modifier.kind === SyntaxKind.ProtectedKeyword ||\n modifier.kind === SyntaxKind.PrivateKeyword,\n );\n\n return isReadonly && !isProtectedOrPrivate;\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport type {\n Node,\n TypeChecker,\n TypeNode,\n} from 'typescript';\nimport { SyntaxKind, displayPartsToString } from 'typescript';\nimport { hasOwnProperty } from '../../../core/utils';\nimport { ResolverError } from '../../../core/error/resolver';\n\nexport function getNodeDescription(\n node: Node,\n typeChecker: TypeChecker,\n) {\n if (!hasOwnProperty(node, 'name')) {\n return undefined;\n }\n\n const symbol = typeChecker.getSymbolAtLocation(node.name as Node);\n if (!symbol) {\n return undefined;\n }\n\n /**\n * TODO: Workaround for what seems like a bug in the compiler\n * Warrants more investigation and possibly a PR against typescript\n */\n if (node.kind === SyntaxKind.Parameter) {\n // TypeScript won't parse jsdoc if the flag is 4, i.e. 'Property'\n symbol.flags = 0;\n }\n\n const comments = symbol.getDocumentationComment(typeChecker);\n if (comments.length) {\n return displayPartsToString(comments);\n }\n\n return undefined;\n}\n\nexport function toTypeNodeOrFail(\n typeChecker: TypeChecker,\n ...args: Parameters<TypeChecker['typeToTypeNode']>\n) : TypeNode {\n const output = typeChecker.typeToTypeNode(...args);\n if (typeof output === 'undefined') {\n throw new ResolverError('Type could not be transformed to TypeNode.');\n }\n\n return output;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport type { SubResolverContext, Type } from '../types';\nimport { toTypeNodeOrFail } from '../utils';\n\nexport function resolveIndexedAccessType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isIndexedAccessTypeNode(typeNode)) {\n return undefined;\n }\n\n // Variant 1: T[number] or T[string]\n if (\n typeNode.indexType.kind === ts.SyntaxKind.NumberKeyword ||\n typeNode.indexType.kind === ts.SyntaxKind.StringKeyword\n ) {\n const numberIndexType = typeNode.indexType.kind === ts.SyntaxKind.NumberKeyword;\n const objectType = ctx.typeChecker.getTypeFromTypeNode(typeNode.objectType);\n const type = numberIndexType ? objectType.getNumberIndexType() : objectType.getStringIndexType();\n if (type === undefined) {\n throw new ResolverError(\n `Could not determine ${numberIndexType ? 'number' : 'string'} index on ${ctx.typeChecker.typeToString(objectType)}`,\n typeNode,\n );\n }\n return ctx.resolveType(\n toTypeNodeOrFail(ctx.typeChecker, type, undefined, undefined),\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n }\n\n // Variant 2: T['key'] or T[0]\n if (\n ts.isLiteralTypeNode(typeNode.indexType) &&\n (\n ts.isStringLiteral(typeNode.indexType.literal) ||\n ts.isNumericLiteral(typeNode.indexType.literal)\n )\n ) {\n const hasType = (node: ts.Node | undefined): node is ts.HasType => node !== undefined &&\n Object.prototype.hasOwnProperty.call(node, 'type');\n\n const symbol = ctx.typeChecker.getPropertyOfType(\n ctx.typeChecker.getTypeFromTypeNode(typeNode.objectType),\n typeNode.indexType.literal.text,\n );\n\n if (symbol === undefined) {\n throw new ResolverError(\n `Could not determine the keys on ${ctx.typeChecker.typeToString(ctx.typeChecker.getTypeFromTypeNode(typeNode.objectType))}`,\n typeNode,\n );\n }\n\n if (hasType(symbol.valueDeclaration) && symbol.valueDeclaration.type) {\n return ctx.resolveType(\n symbol.valueDeclaration.type,\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n }\n\n const declaration = ctx.typeChecker.getTypeOfSymbolAtLocation(symbol, typeNode.objectType);\n try {\n return ctx.resolveType(\n toTypeNodeOrFail(ctx.typeChecker, declaration, undefined, undefined),\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n } catch (err) {\n throw new ResolverError(\n `Could not determine the keys on ${ctx.typeChecker.typeToString(declaration)}`,\n typeNode,\n { cause: err },\n );\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { IntersectionType, SubResolverContext, Type } from '../types';\n\nexport function resolveIntersectionType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isIntersectionTypeNode(typeNode)) {\n return undefined;\n }\n\n const members = typeNode.types.map(\n (type) => ctx.resolveType(type, ctx.parentNode, ctx.context),\n );\n\n return {\n typeName: TypeName.INTERSECTION,\n members,\n } as IntersectionType;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport type { \n AnyType, \n EnumType, \n SubResolverContext, \n Type, \n} from '../types';\n\nexport function resolveLiteralType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (typeNode.kind === ts.SyntaxKind.NullKeyword) {\n return {\n typeName: TypeName.ENUM,\n members: [null],\n } as EnumType;\n }\n\n if (\n typeNode.kind === ts.SyntaxKind.AnyKeyword ||\n typeNode.kind === ts.SyntaxKind.UnknownKeyword\n ) {\n return { typeName: TypeName.ANY } as AnyType;\n }\n\n if (ts.isLiteralTypeNode(typeNode)) {\n return {\n typeName: TypeName.ENUM,\n members: [getLiteralValue(typeNode)],\n } as EnumType;\n }\n\n if (typeNode.kind === ts.SyntaxKind.TemplateLiteralType) {\n const type = ctx.typeChecker.getTypeFromTypeNode(ctx.referencer || typeNode);\n if (type.isUnion() && type.types.every((t) => t.isStringLiteral())) {\n return {\n typeName: TypeName.ENUM,\n members: type.types.map(\n (t: ts.StringLiteralType) => t.value,\n ),\n } as EnumType;\n }\n\n throw new ResolverError(\n `Could not resolve type: ${ctx.typeChecker.typeToString(ctx.typeChecker.getTypeFromTypeNode(typeNode), typeNode)}`,\n typeNode,\n );\n }\n\n if (ts.isParenthesizedTypeNode(typeNode)) {\n return ctx.resolveType(\n typeNode.type,\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n }\n\n if (\n typeNode.kind === ts.SyntaxKind.ObjectKeyword ||\n ts.isFunctionTypeNode(typeNode)\n ) {\n return { typeName: TypeName.OBJECT };\n }\n\n return undefined;\n}\n\nexport function getLiteralValue(typeNode: ts.LiteralTypeNode): string | number | boolean | null {\n let value: boolean | number | string | null;\n switch (typeNode.literal.kind) {\n case ts.SyntaxKind.TrueKeyword:\n value = true;\n break;\n case ts.SyntaxKind.FalseKeyword:\n value = false;\n break;\n case ts.SyntaxKind.StringLiteral:\n value = typeNode.literal.text;\n break;\n case ts.SyntaxKind.NumericLiteral:\n value = Number.parseFloat(typeNode.literal.text);\n break;\n case ts.SyntaxKind.NullKeyword:\n value = null;\n break;\n default:\n if (Object.prototype.hasOwnProperty.call(typeNode.literal, 'text')) {\n value = (typeNode.literal as ts.LiteralExpression).text;\n } else {\n throw new ResolverError(\n `Couldn't resolve literal node: ${typeNode.literal.getText()}`,\n typeNode.literal,\n );\n }\n }\n return value;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { JSDocTagName } from '../../js-doc';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { ResolverProperty, SubResolverContext, Type } from '../types';\nimport { toTypeNodeOrFail } from '../utils';\n\nexport function resolveMappedType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isMappedTypeNode(typeNode) || !ctx.referencer) {\n return undefined;\n }\n\n const type = ctx.typeChecker.getTypeFromTypeNode(ctx.referencer);\n const mappedTypeNode = typeNode;\n const { typeChecker } = ctx;\n\n const getDeclaration = (prop: ts.Symbol) => prop.declarations && (prop.declarations[0] as ts.Declaration | undefined);\n\n const isIgnored = (prop: ts.Symbol) => {\n const declaration = getDeclaration(prop);\n const tagNames = prop.getJsDocTags();\n const tagNameIndex = tagNames.findIndex((tag) => tag.name === JSDocTagName.IGNORE);\n if (tagNameIndex >= 0) {\n return true;\n }\n return (\n !!declaration &&\n !ts.isPropertyDeclaration(declaration) &&\n !ts.isPropertySignature(declaration) &&\n !ts.isParameter(declaration)\n );\n };\n\n const properties: ResolverProperty[] = type\n .getProperties()\n .filter((property) => !isIgnored(property))\n .map((property) => {\n const declaration = getDeclaration(property) as\n ts.PropertySignature |\n ts.PropertyDeclaration |\n ts.ParameterDeclaration |\n undefined;\n\n // Normalize +? (PlusToken) to ? (QuestionToken) so property helpers treat it as optional\n const overrideToken = mappedTypeNode.questionToken?.kind === ts.SyntaxKind.PlusToken ?\n ts.factory.createToken(ts.SyntaxKind.QuestionToken) :\n mappedTypeNode.questionToken;\n\n if (declaration && ts.isPropertySignature(declaration)) {\n return { ...ctx.propertyFromSignature(declaration, overrideToken), name: property.getName() };\n }\n if (declaration && (ts.isPropertyDeclaration(declaration) || ts.isParameter(declaration))) {\n return { ...ctx.propertyFromDeclaration(declaration, overrideToken), name: property.getName() };\n }\n\n let required = (property.flags & ts.SymbolFlags.Optional) === 0;\n\n const typeNode2 = toTypeNodeOrFail(\n typeChecker,\n typeChecker.getTypeOfSymbolAtLocation(property, typeNode),\n undefined,\n ts.NodeBuilderFlags.NoTruncation,\n );\n if (mappedTypeNode.questionToken && mappedTypeNode.questionToken.kind === ts.SyntaxKind.MinusToken) {\n required = true;\n } else if (\n mappedTypeNode.questionToken &&\n (\n mappedTypeNode.questionToken.kind === ts.SyntaxKind.QuestionToken ||\n mappedTypeNode.questionToken.kind === ts.SyntaxKind.PlusToken\n )\n ) {\n required = false;\n }\n\n return {\n name: property.getName(),\n required,\n deprecated: false,\n type: ctx.resolveType(typeNode2, typeNode, ctx.context, ctx.referencer),\n validators: {},\n };\n });\n\n return {\n typeName: TypeName.NESTED_OBJECT_LITERAL,\n properties,\n };\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport {\n JSDocTagName,\n getJSDocTagComment,\n hasJSDocTag,\n} from '../../js-doc';\nimport { getDeclarationValidators } from '../../validator';\nimport { TypeName } from '../../../../core/types/type-name';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport { isStringType } from '../../../../core/types/type-guards';\nimport type { \n NestedObjectLiteralType, \n ResolverProperty, \n SubResolverContext, \n Type, \n} from '../types';\n\nexport function resolveObjectLiteralType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isTypeLiteralNode(typeNode)) {\n return undefined;\n }\n\n const properties: ResolverProperty[] = typeNode.members\n .filter((member) => ts.isPropertySignature(member))\n .reduce((res, propertySignature: ts.PropertySignature) => {\n if (!propertySignature.type) {\n throw new ResolverError('No valid type found for property declaration.', propertySignature);\n }\n\n const type = ctx.resolveType(\n propertySignature.type,\n propertySignature,\n ctx.context,\n );\n\n const property: ResolverProperty = {\n deprecated: hasJSDocTag(propertySignature, JSDocTagName.DEPRECATED),\n example: ctx.getNodeExample(propertySignature),\n extensions: ctx.getNodeExtensions(propertySignature),\n default: getJSDocTagComment(propertySignature, JSDocTagName.DEFAULT),\n description: ctx.getNodeDescription(propertySignature),\n format: getNodeFormat(propertySignature),\n name: getPropertyName(propertySignature),\n required: !propertySignature.questionToken,\n type,\n validators: getDeclarationValidators(propertySignature) || {},\n };\n\n return [property, ...res];\n }, [] as ResolverProperty[]);\n\n const indexMember = typeNode.members.find(\n (member) => ts.isIndexSignatureDeclaration(member),\n );\n let additionalType: Type | undefined;\n\n if (indexMember) {\n const indexSignatureDeclaration = indexMember as ts.IndexSignatureDeclaration;\n const indexType = ctx.resolveType(\n indexSignatureDeclaration.parameters[0].type as ts.TypeNode,\n ctx.parentNode,\n ctx.context,\n );\n\n if (!isStringType(indexType)) {\n throw new ResolverError('Only string indexes are supported.', typeNode);\n }\n\n additionalType = ctx.resolveType(\n indexSignatureDeclaration.type,\n ctx.parentNode,\n ctx.context,\n );\n }\n\n return {\n additionalProperties: indexMember && additionalType,\n typeName: TypeName.NESTED_OBJECT_LITERAL,\n properties,\n } as NestedObjectLiteralType;\n}\n\nfunction getNodeFormat(\n node: ts.PropertySignature | ts.PropertyDeclaration | ts.ParameterDeclaration,\n) {\n return getJSDocTagComment(node, JSDocTagName.FORMAT);\n}\n\nfunction getPropertyName(node: ts.PropertySignature): string {\n if (ts.isIdentifier(node.name)) {\n return node.name.text;\n }\n\n if (ts.isStringLiteral(node.name) || ts.isNumericLiteral(node.name)) {\n return node.name.text;\n }\n\n return node.name.getText();\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node, TypeNode } from 'typescript';\nimport { SyntaxKind } from 'typescript';\nimport {\n NumericKind,\n type Registry,\n type ResolverMarker,\n hasDecoratorNamed,\n namesForMarker,\n numericMarkerKind,\n tagsForMarker,\n} from '../../../decorator';\nimport { getJSDocTagNames } from '../../js-doc';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { NeverType, PrimitiveType, VoidType } from '../types';\n\nconst NUMERIC_KIND_TO_TYPE_NAME: Record<string, string> = {\n [NumericKind.Int]: TypeName.INTEGER,\n [NumericKind.Long]: TypeName.LONG,\n [NumericKind.Float]: TypeName.FLOAT,\n [NumericKind.Double]: TypeName.DOUBLE,\n};\n\nexport class PrimitiveResolver {\n protected registry: Registry;\n\n constructor(registry: Registry) {\n this.registry = registry;\n }\n\n resolve(node: TypeNode, parentNode?: Node) : PrimitiveType | NeverType | VoidType | undefined {\n const resolved = this.resolveSyntaxKind(node.kind);\n if (resolved) {\n if (resolved === 'string') {\n return { typeName: TypeName.STRING };\n }\n\n if (resolved === 'void') {\n return { typeName: TypeName.VOID };\n }\n\n if (resolved === 'boolean') {\n return { typeName: TypeName.BOOLEAN };\n }\n\n if (resolved === 'undefined') {\n return { typeName: TypeName.UNDEFINED };\n }\n\n if (resolved === 'null') {\n // todo: check\n return undefined;\n }\n\n if (resolved === 'never') {\n return { typeName: TypeName.NEVER };\n }\n\n if (resolved === 'bigint') {\n return { typeName: TypeName.BIGINT };\n }\n\n if (resolved === 'number') {\n if (!parentNode) {\n return { typeName: TypeName.DOUBLE };\n }\n\n // For each numeric kind: check decorator handlers first (preset\n // may rename `@IsInt`), then JSDoc handlers (preset may rename\n // `@isInt`). Both lookups use the registry markers.\n const presentJsDocTags = new Set(\n getJSDocTagNames(parentNode).map((tag) => tag.toLowerCase()),\n );\n for (const kind of [NumericKind.Int, NumericKind.Long, NumericKind.Float, NumericKind.Double] as const) {\n const matchKind = (m: ResolverMarker) => numericMarkerKind(m) === kind;\n\n const decoratorNames = namesForMarker(this.registry, matchKind);\n for (const name of decoratorNames) {\n if (hasDecoratorNamed(parentNode, name)) {\n return { typeName: NUMERIC_KIND_TO_TYPE_NAME[kind] } as PrimitiveType;\n }\n }\n\n const jsDocTags = tagsForMarker(this.registry, matchKind);\n for (const tag of jsDocTags) {\n if (presentJsDocTags.has(tag.toLowerCase())) {\n return { typeName: NUMERIC_KIND_TO_TYPE_NAME[kind] } as PrimitiveType;\n }\n }\n }\n\n return { typeName: TypeName.DOUBLE };\n }\n }\n\n return undefined;\n }\n\n resolveSyntaxKind(syntaxKind: SyntaxKind) {\n switch (syntaxKind) {\n case SyntaxKind.StringKeyword:\n return 'string';\n case SyntaxKind.BooleanKeyword:\n return 'boolean';\n case SyntaxKind.VoidKeyword:\n return 'void';\n case SyntaxKind.UndefinedKeyword:\n return 'undefined';\n case SyntaxKind.NullKeyword:\n return 'null';\n case SyntaxKind.NumberKeyword:\n return 'number';\n case SyntaxKind.BigIntKeyword:\n return 'bigint';\n case SyntaxKind.NeverKeyword:\n return 'never';\n default:\n return undefined;\n }\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { EnumDeclaration, EnumMember, TypeChecker } from 'typescript';\nimport { JSDocTagName, hasJSDocTag } from '../../js-doc';\nimport { TypeName } from '../../../../core/types/type-name';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport type {\n RefEnumType, \n RefObjectType, \n ReferenceType, \n Type,\n} from '../types';\nimport { getNodeDescription } from '../utils';\nimport { ResolverBase } from './base';\n\nexport class ReferenceResolver extends ResolverBase {\n protected typeChecker : TypeChecker;\n\n constructor(typeChecker: TypeChecker) {\n super();\n\n this.typeChecker = typeChecker;\n }\n\n public merge(referenceTypes: ReferenceType[]): ReferenceType {\n if (referenceTypes.length === 1) {\n return referenceTypes[0];\n }\n\n if (referenceTypes.every((refType) => refType.refName === TypeName.REF_ENUM)) {\n return this.mergeManyRefEnums(referenceTypes as RefEnumType[]);\n }\n\n if (referenceTypes.every((refType) => refType.refName === TypeName.REF_OBJECT)) {\n return this.mergeManyRefObjects(referenceTypes as RefObjectType[]);\n }\n\n throw new ResolverError(\n `These resolved type merge rules are not defined: ${JSON.stringify(referenceTypes)}`,\n );\n }\n\n public mergeManyRefEnums(many: RefEnumType[]): RefEnumType {\n let merged = this.mergeRefEnums(many[0], many[1]);\n for (let i = 2; i < many.length; ++i) {\n merged = this.mergeRefEnums(merged, many[i]);\n }\n\n return merged;\n }\n\n public mergeRefEnums(first: RefEnumType, second: RefEnumType): RefEnumType {\n let description : string | undefined;\n if (first.description || second.description) {\n if (!first.description) {\n description = second.description;\n } else if (!second.description) {\n description = first.description;\n } else {\n description = `${first.description}\\n${second.description}`;\n }\n }\n\n return {\n typeName: TypeName.REF_ENUM,\n example: first.example || second.example,\n description,\n members: [\n ...(first.members || []),\n ...(second.members || []),\n ],\n memberNames: [\n ...(first.memberNames || []),\n ...(second.memberNames || []),\n ],\n refName: first.refName,\n deprecated: first.deprecated || second.deprecated,\n };\n }\n\n public mergeManyRefObjects(many: RefObjectType[]) {\n let merged = this.mergeRefObject(many[0], many[1]);\n for (let i = 2; i < many.length; ++i) {\n merged = this.mergeRefObject(merged, many[i]);\n }\n return merged;\n }\n\n public mergeRefObject(first: RefObjectType, second: RefObjectType) : RefObjectType {\n let description : string | undefined;\n if (first.description || second.description) {\n if (!first.description) {\n description = second.description;\n } else if (!second.description) {\n description = first.description;\n } else {\n description = `${first.description}\\n${second.description}`;\n }\n }\n\n const properties = [\n ...first.properties,\n ...second.properties.filter((prop) => first.properties.every((firstProp) => firstProp.name !== prop.name)),\n ];\n\n let additionalProperties : Type | undefined;\n if (first.additionalProperties || second.additionalProperties) {\n if (!first.additionalProperties) {\n additionalProperties = second.additionalProperties;\n } else if (!second.additionalProperties) {\n additionalProperties = first.additionalProperties;\n } else {\n additionalProperties = {\n typeName: TypeName.UNION,\n members: [first.additionalProperties, second.additionalProperties],\n };\n }\n }\n\n return {\n typeName: TypeName.REF_OBJECT,\n description,\n properties,\n additionalProperties,\n refName: first.refName,\n deprecated: first.deprecated || second.deprecated,\n example: first.example || second.example,\n };\n }\n\n transformEnum(declaration: EnumDeclaration, enumName: string) : RefEnumType {\n const isNotUndefined = <T>(item: T): item is Exclude<T, undefined> => item !== undefined;\n\n const enums = declaration.members.map(this.typeChecker.getConstantValue.bind(this.typeChecker)).filter(isNotUndefined);\n const enumNames = declaration.members.map((e) => e.name.getText()).filter(isNotUndefined);\n\n return {\n typeName: TypeName.REF_ENUM,\n description: getNodeDescription(declaration, this.typeChecker),\n members: enums as string[],\n memberNames: enumNames,\n refName: enumName,\n deprecated: hasJSDocTag(declaration, JSDocTagName.DEPRECATED),\n };\n }\n\n transformEnumMember(declaration: EnumMember, enumName: string) : RefEnumType {\n return {\n typeName: TypeName.REF_ENUM,\n refName: enumName,\n members: [this.typeChecker.getConstantValue(declaration)!],\n memberNames: [declaration.name.getText()],\n deprecated: hasJSDocTag(declaration, JSDocTagName.DEPRECATED),\n };\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type {\n SubResolverContext,\n TupleType,\n Type,\n} from '../types';\n\nexport function resolveTupleType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isTupleTypeNode(typeNode)) {\n return undefined;\n }\n\n const elements = typeNode.elements.map((element) => {\n const isNamed = ts.isNamedTupleMember(element);\n const actualType = isNamed ? element.type : element;\n return {\n type: ctx.resolveType(actualType, ctx.parentNode, ctx.context),\n ...(isNamed && { name: element.name.text }),\n };\n });\n\n return {\n typeName: TypeName.TUPLE,\n elements,\n } as TupleType;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { ResolverError } from '../../../../core/error/resolver';\nimport type { SubResolverContext, Type } from '../types';\nimport { toTypeNodeOrFail } from '../utils';\n\nexport function resolveTypeOperatorType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isTypeOperatorNode(typeNode)) {\n return undefined;\n }\n\n if (typeNode.operator === ts.SyntaxKind.KeyOfKeyword) {\n const type = ctx.typeChecker.getTypeFromTypeNode(typeNode);\n try {\n return ctx.resolveType(\n toTypeNodeOrFail(ctx.typeChecker, type, undefined, ts.NodeBuilderFlags.NoTruncation),\n typeNode,\n ctx.context,\n ctx.referencer,\n );\n } catch (err) {\n const indexedTypeName = ctx.typeChecker.typeToString(\n ctx.typeChecker.getTypeFromTypeNode(typeNode.type),\n );\n throw new ResolverError(\n `Could not determine the keys on ${indexedTypeName}`,\n typeNode,\n { cause: err },\n );\n }\n }\n\n if (typeNode.operator === ts.SyntaxKind.ReadonlyKeyword) {\n return ctx.resolveType(typeNode.type, typeNode, ctx.context, ctx.referencer);\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport * as ts from 'typescript';\nimport { TypeName } from '../../../../core/types/type-name';\nimport type { SubResolverContext, Type, UnionType } from '../types';\n\nexport function resolveUnionType(\n typeNode: ts.TypeNode,\n ctx: SubResolverContext,\n): Type | undefined {\n if (!ts.isUnionTypeNode(typeNode)) {\n return undefined;\n }\n\n const members = typeNode.types.map(\n (type) => ctx.resolveType(type, ctx.parentNode, ctx.context),\n );\n\n return {\n typeName: TypeName.UNION,\n members,\n } as UnionType;\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isEnumDeclaration, isEnumMember } from 'typescript';\nimport * as ts from 'typescript';\nimport {\n hasDecoratorNamed,\n isDeprecatedMarker,\n namesForMarker,\n tagsForMarker,\n} from '../../decorator';\nimport type { IReferenceTypeRegistry, IResolverContext } from '../../../core/types/metadata';\nimport { TypeName, UtilityTypeName } from '../../../core/types/type-name';\n\nimport type { Extension } from '../../../core/types/extension';\nimport {\n JSDocTagName,\n getJSDocTagComment,\n getJSDocTagNames,\n hasJSDocTag,\n} from '../js-doc';\nimport { getDeclarationValidators } from '../validator';\nimport { getInitializerValue } from '../initializer';\nimport { ResolverError } from '../../../core/error/resolver';\nimport { getNodeExtensions } from './extension';\nimport {\n PrimitiveResolver,\n ReferenceResolver,\n ResolverBase,\n resolveArrayType,\n resolveIndexedAccessType,\n resolveIntersectionType,\n resolveLiteralType,\n resolveMappedType,\n resolveObjectLiteralType,\n resolveTupleType,\n resolveTypeOperatorType,\n resolveUnionType,\n} from './sub';\nimport { getLiteralValue } from './sub/literal';\nimport {\n isRefAliasType,\n isRefObjectType,\n} from '../../../core/types/type-guards';\nimport type {\n BufferType,\n DateTimeType,\n DateType,\n NestedObjectLiteralType,\n OverrideToken,\n RefEnumType,\n ReferenceType,\n ResolverProperty,\n SubResolverContext,\n Type,\n TypeNodeResolverContext,\n UsableDeclaration,\n} from './types';\nimport { getNodeDescription } from './utils';\n\nexport class TypeNodeResolver extends ResolverBase {\n private static readonly MAX_DEPTH = 50;\n\n private readonly typeNode : ts.TypeNode;\n\n private readonly current: IResolverContext & IReferenceTypeRegistry;\n\n private readonly parentNode?: ts.Node;\n\n private context: TypeNodeResolverContext;\n\n private readonly referencer : ts.TypeNode | undefined;\n\n private readonly depth: number;\n\n private readonly primitiveResolver : PrimitiveResolver;\n\n private readonly referenceResolver : ReferenceResolver;\n\n constructor(\n typeNode: ts.TypeNode,\n current: IResolverContext & IReferenceTypeRegistry,\n parentNode?: ts.Node,\n context?: TypeNodeResolverContext,\n referencer?: ts.TypeNode,\n depth?: number,\n ) {\n super();\n\n this.typeNode = typeNode;\n this.current = current;\n this.parentNode = parentNode;\n this.context = context || {};\n this.referencer = referencer;\n this.depth = depth ?? 0;\n\n this.primitiveResolver = new PrimitiveResolver(current.registry);\n this.referenceResolver = new ReferenceResolver(current.typeChecker);\n }\n\n /**\n * @deprecated Use resolverCache.clear() on the context instead.\n * Kept for backward compatibility — no-ops since cache is now instance-scoped.\n */\n public static clearCache() {\n // Cache is now instance-scoped via IResolverContext.resolverCache.\n // This method is a no-op for backward compatibility.\n }\n\n public resolve(): Type {\n if (this.depth > TypeNodeResolver.MAX_DEPTH) {\n throw new ResolverError(\n `Type resolution exceeded maximum depth of ${TypeNodeResolver.MAX_DEPTH}. This usually indicates deeply nested or circular generics.`,\n this.typeNode,\n );\n }\n\n const ctx = this.createSubResolverContext();\n\n const result = this.primitiveResolver.resolve(this.typeNode, this.parentNode) ??\n resolveLiteralType(this.typeNode, ctx) ??\n resolveArrayType(this.typeNode, ctx) ??\n resolveUnionType(this.typeNode, ctx) ??\n resolveIntersectionType(this.typeNode, ctx) ??\n resolveObjectLiteralType(this.typeNode, ctx) ??\n resolveTupleType(this.typeNode, ctx) ??\n resolveMappedType(this.typeNode, ctx) ??\n this.resolveConditionalType() ??\n resolveTypeOperatorType(this.typeNode, ctx) ??\n resolveIndexedAccessType(this.typeNode, ctx) ??\n this.resolveTypeReference();\n\n if (!result) {\n this.throwUnknownType();\n }\n\n return result;\n }\n\n private createSubResolverContext(): SubResolverContext {\n return {\n typeChecker: this.current.typeChecker,\n current: this.current,\n parentNode: this.parentNode,\n context: this.context,\n referencer: this.referencer,\n resolveType: (typeNode, parentNode, context, referencer) => (\n this.resolveNestedType(typeNode, parentNode, context, referencer)\n ),\n propertyFromSignature: (sig, overrideToken) => this.propertyFromSignature(sig, overrideToken),\n propertyFromDeclaration: (decl, overrideToken) => (\n this.propertyFromDeclaration(decl, overrideToken)\n ),\n getNodeDescription: (node) => this.getNodeDescription(node),\n getNodeExample: (node) => this.getNodeExample(node),\n getNodeExtensions: (node) => this.getNodeExtensions(node),\n };\n }\n\n private resolveNestedType(\n typeNode: ts.TypeNode,\n parentNode?: ts.Node,\n context?: TypeNodeResolverContext,\n referencer?: ts.TypeNode,\n ): Type {\n return new TypeNodeResolver(\n typeNode,\n this.current,\n parentNode,\n context,\n referencer,\n this.depth + 1,\n ).resolve();\n }\n\n private throwUnknownType(): never {\n throw new ResolverError(`Unknown type: ${ts.SyntaxKind[this.typeNode.kind]}`, this.typeNode);\n }\n\n // ------------------------------------------------------------------\n // Conditional type resolution (kept inline — deeply coupled to reference handling)\n // ------------------------------------------------------------------\n\n private resolveConditionalType(): Type | undefined {\n if (!ts.isConditionalTypeNode(this.typeNode)) {\n return undefined;\n }\n\n // When inside a generic type alias (context has entries) and we\n // have a usage-site node (referencer), resolve via the referencer\n // so the checker evaluates with concrete type arguments (#782).\n if (Object.keys(this.context).length > 0 && this.referencer) {\n return this.resolveTypeViaChecker(this.referencer);\n }\n\n // Delegate conditional type evaluation to the TypeScript type\n // checker. The checker can evaluate any conditional directly,\n // including complex patterns like `typeof globalThis extends\n // { onmessage: any } ? {} : X` from @types/node (#753).\n return this.resolveTypeViaChecker(this.typeNode);\n }\n\n // ------------------------------------------------------------------\n // Type reference resolution (kept inline — deeply coupled to caching/utility types)\n // ------------------------------------------------------------------\n\n private resolveTypeReference(): Type | undefined {\n if (this.typeNode.kind !== ts.SyntaxKind.TypeReference) {\n return undefined;\n }\n\n const typeReference = this.typeNode as ts.TypeReferenceNode;\n\n if (typeReference.typeName.kind === ts.SyntaxKind.Identifier) {\n if (\n typeReference.typeName.text === 'Record' &&\n typeReference.typeArguments\n ) {\n return {\n additionalProperties: this.resolveNestedType(\n typeReference.typeArguments[1],\n this.parentNode,\n this.context,\n ),\n typeName: TypeName.NESTED_OBJECT_LITERAL,\n properties: [],\n } as NestedObjectLiteralType;\n }\n\n const specialReference = TypeNodeResolver.resolveSpecialReference(typeReference.typeName);\n if (typeof specialReference !== 'undefined') {\n return specialReference;\n }\n\n if (typeReference.typeName.text === 'Date') {\n return this.getDateType(this.parentNode);\n }\n\n if (\n typeReference.typeName.text === 'Buffer' ||\n typeReference.typeName.text === 'Readable'\n ) {\n return { typeName: TypeName.BUFFER };\n }\n\n if (\n typeReference.typeName.text === 'Array' &&\n typeReference.typeArguments &&\n typeReference.typeArguments.length >= 1\n ) {\n return {\n typeName: TypeName.ARRAY,\n elementType: this.resolveNestedType(\n typeReference.typeArguments[0],\n this.parentNode,\n this.context,\n ),\n };\n }\n\n if (\n typeReference.typeName.text === 'Promise' &&\n typeReference.typeArguments &&\n typeReference.typeArguments.length === 1\n ) {\n return this.resolveNestedType(\n typeReference.typeArguments[0],\n this.parentNode,\n this.context,\n );\n }\n\n if (typeReference.typeName.text === 'String') {\n return { typeName: TypeName.STRING };\n }\n\n if (this.context[typeReference.typeName.text]) {\n return this.resolveNestedType(\n this.context[typeReference.typeName.text],\n this.parentNode,\n this.context,\n );\n }\n\n if (TypeNodeResolver.isCheckerResolvableUtilityType(typeReference.typeName.text)) {\n return this.resolveUtilityTypeViaChecker(typeReference);\n }\n }\n\n try {\n const referenceType = this.getReferenceType(typeReference);\n\n this.current.addReferenceType(referenceType);\n return referenceType;\n } catch (err) {\n // When the model declaration walker fails (e.g. for global types\n // like Headers, Request, Response from @types/node that use\n // complex declaration patterns — #753), fall back to the checker.\n // If the checker also fails, re-throw the original error.\n try {\n return this.resolveTypeViaChecker(typeReference);\n } catch {\n throw err;\n }\n }\n }\n\n // ------------------------------------------------------------------------\n // Utility Type(s)\n // ------------------------------------------------------------------------\n\n private static readonly CHECKER_RESOLVABLE_UTILITY_TYPES: ReadonlySet<string> = new Set([\n UtilityTypeName.NON_NULLABLE,\n UtilityTypeName.OMIT,\n UtilityTypeName.PARTIAL,\n UtilityTypeName.READONLY,\n UtilityTypeName.REQUIRED,\n UtilityTypeName.PICK,\n UtilityTypeName.EXTRACT,\n UtilityTypeName.EXCLUDE,\n UtilityTypeName.RETURN_TYPE,\n UtilityTypeName.PARAMETERS,\n UtilityTypeName.AWAITED,\n UtilityTypeName.INSTANCE_TYPE,\n UtilityTypeName.CONSTRUCTOR_PARAMETERS,\n ]);\n\n private static isCheckerResolvableUtilityType(name: string): boolean {\n return TypeNodeResolver.CHECKER_RESOLVABLE_UTILITY_TYPES.has(name);\n }\n\n private resolveUtilityTypeViaChecker(typeReference: ts.TypeReferenceNode): Type {\n // When type arguments reference unbound type parameters from our\n // context (e.g. `Awaited<T>` inside `type Box<T> = Awaited<T>`),\n // the checker can't resolve them from the declaration-site node.\n // Use the referencer (usage-site node like `Box<Promise<Foo>>`)\n // which the checker CAN resolve with concrete type arguments.\n if (this.hasUnboundContextArgs(typeReference) && this.referencer) {\n return this.resolveTypeViaChecker(this.referencer);\n }\n\n return this.resolveTypeViaChecker(typeReference);\n }\n\n /**\n * Shared checker delegation: resolves a type node by letting the TS\n * type checker evaluate it, converting back to a TypeNode, and\n * recursively resolving the result.\n */\n private resolveTypeViaChecker(typeNode: ts.TypeNode): Type {\n const type = this.current.typeChecker.getTypeFromTypeNode(typeNode);\n // InTypeAlias prevents the node builder from emitting type alias\n // references (which could cause circular resolution when the utility\n // type is used inside a type alias declaration).\n const resolvedTypeNode = this.current.typeChecker.typeToTypeNode(\n type,\n undefined,\n ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.InTypeAlias,\n );\n\n // typeToTypeNode returns undefined for some edge cases (e.g. empty\n // tuples from Parameters<> of a no-arg function). Fall back to an\n // empty tuple type.\n if (!resolvedTypeNode) {\n return { typeName: TypeName.TUPLE, elements: [] };\n }\n\n return this.resolveNestedType(\n resolvedTypeNode,\n this.parentNode,\n this.context,\n );\n }\n\n /**\n * Check if a type reference has type arguments that reference unbound\n * type parameters from this.context (e.g. `Awaited<T>` where T is a\n * generic parameter mapped in context).\n */\n private hasUnboundContextArgs(typeReference: ts.TypeReferenceNode): boolean {\n if (!typeReference.typeArguments || Object.keys(this.context).length === 0) {\n return false;\n }\n\n return typeReference.typeArguments.some((arg) =>\n ts.isTypeReferenceNode(arg) &&\n ts.isIdentifier(arg.typeName) &&\n arg.typeName.text in this.context);\n }\n\n private static resolveSpecialReference(node: ts.Identifier) : Type | undefined {\n switch (node.text) {\n case 'Buffer':\n case 'DownloadBinaryData':\n case 'DownloadResource':\n return { typeName: TypeName.BUFFER } as BufferType;\n default:\n return undefined;\n }\n }\n\n private getDateType(parentNode?: ts.Node): DateType | DateTimeType {\n if (!parentNode) {\n return { typeName: TypeName.DATETIME };\n }\n const tags = getJSDocTagNames(parentNode).filter((name) => ['isDate', 'isDateTime'].includes(name));\n\n if (tags.length === 0) {\n return { typeName: TypeName.DATETIME };\n }\n\n switch (tags[0]) {\n case 'isDate':\n return { typeName: TypeName.DATE };\n default:\n return { typeName: TypeName.DATETIME };\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private static getDesignatedModels<T extends ts.Node>(nodes: T[], _typeName: string): T[] {\n return nodes;\n }\n\n private getEnumerateType(typeName: ts.EntityName): RefEnumType | undefined {\n const enumName = (typeName as ts.Identifier).text;\n let enumNodes = this.current.nodes.filter(\n (node) => node.kind === ts.SyntaxKind.EnumDeclaration && (node as any).name.text === enumName,\n );\n\n if (!enumNodes.length) {\n return undefined;\n }\n\n enumNodes = TypeNodeResolver.getDesignatedModels(enumNodes, enumName);\n\n if (enumNodes.length > 1) {\n throw new ResolverError(`Multiple matching enum found for enum ${enumName}; please make enum names unique.`);\n }\n\n const enumDeclaration = enumNodes[0] as ts.EnumDeclaration;\n\n const isNotUndefined = <T>(item: T): item is Exclude<T, undefined> => item !== undefined;\n\n const enums = enumDeclaration.members.map(this.current.typeChecker.getConstantValue.bind(this.current.typeChecker)).filter(isNotUndefined);\n const enumNames = enumDeclaration.members.map((e) => e.name.getText()).filter(isNotUndefined);\n\n return {\n typeName: TypeName.REF_ENUM,\n description: this.getNodeDescription(enumDeclaration),\n members: enums as string[],\n memberNames: enumNames,\n refName: enumName,\n deprecated: hasJSDocTag(enumDeclaration, JSDocTagName.DEPRECATED),\n };\n }\n\n private getReferenceType(node: ts.TypeReferenceType): ReferenceType {\n let type: ts.EntityName;\n if (ts.isTypeReferenceNode(node)) {\n type = node.typeName;\n } else if (ts.isExpressionWithTypeArguments(node)) {\n type = node.expression as ts.EntityName;\n } else {\n throw new ResolverError('Can\\'t resolve reference type.');\n }\n\n // Can't invoke getText on Synthetic Nodes\n let resolvableName = node.pos !== -1 ? node.getText() : (type as ts.Identifier).text;\n if (node.pos === -1 && 'typeArguments' in node && Array.isArray(node.typeArguments)) {\n // Add typeArguments for Synthetic nodes (e.g. Record<> in TestClassModel.indexedResponse)\n const argumentsString = node.typeArguments\n .map((arg) => {\n if (ts.isLiteralTypeNode(arg)) {\n return `'${String(getLiteralValue(arg))}'`;\n }\n const resolvedType = this.primitiveResolver.resolveSyntaxKind(arg.kind);\n if (\n typeof resolvedType === 'undefined'\n ) { return 'any'; }\n return resolvedType;\n });\n\n resolvableName += `<${argumentsString.join(', ')}>`;\n }\n\n const name = this.contextualizedName(resolvableName);\n\n this.typeArgumentsToContext(node, type, this.context);\n\n try {\n const existingType = this.current.resolverCache.getCachedType(name);\n if (existingType) {\n return existingType;\n }\n\n if (this.current.resolverCache.isInProgress(name)) {\n return this.createCircularDependencyResolver(name);\n }\n\n this.current.resolverCache.markInProgress(name);\n\n try {\n const refName = TypeNodeResolver.getRefTypeName(name);\n const declarations = this.getModelTypeDeclarations(type);\n const referenceTypes: ReferenceType[] = [];\n for (const declaration of declarations) {\n if (ts.isTypeAliasDeclaration(declaration)) {\n referenceTypes.push(\n this.getTypeAliasReference(\n declaration,\n name,\n node,\n ),\n );\n } else if (isEnumDeclaration(declaration)) {\n referenceTypes.push(this.referenceResolver.transformEnum(declaration, refName));\n } else if (isEnumMember(declaration)) {\n referenceTypes.push(this.referenceResolver.transformEnumMember(declaration, refName));\n } else {\n // todo: dont cast handle property-signature\n referenceTypes.push(\n this.getModelReference(\n declaration as ts.InterfaceDeclaration,\n name,\n ),\n );\n }\n }\n\n const referenceType = this.referenceResolver.merge(referenceTypes);\n\n this.current.resolverCache.setCachedType(name, referenceType);\n return referenceType;\n } finally {\n this.current.resolverCache.clearInProgress(name);\n }\n } catch (err) {\n throw new ResolverError(\n `There was a problem resolving type of '${name}'.`,\n node,\n { cause: err },\n );\n }\n }\n\n private getTypeAliasReference(\n declaration: ts.TypeAliasDeclaration,\n name: string,\n referencer: ts.TypeReferenceType,\n ): ReferenceType {\n const refName = TypeNodeResolver.getRefTypeName(name);\n\n if (declaration.type.kind === ts.SyntaxKind.TypeReference) {\n const innerRef = declaration.type as ts.TypeReferenceNode;\n // Record<K,V> and checker-resolvable utility types (Pick, Omit, etc.)\n // should not go through getReferenceType — resolveNestedType handles\n // them correctly via resolveTypeReference.\n const innerName = ts.isIdentifier(innerRef.typeName) ? innerRef.typeName.text : undefined;\n const skipReferenceType = innerName === UtilityTypeName.RECORD ||\n (innerName !== undefined && TypeNodeResolver.isCheckerResolvableUtilityType(innerName));\n\n if (!skipReferenceType) {\n const referenceType = this.getReferenceType(innerRef);\n if (referenceType.refName === refName) {\n return referenceType;\n }\n }\n }\n\n const type = this.resolveNestedType(\n declaration.type,\n declaration,\n this.context,\n this.referencer || referencer,\n );\n\n const example = this.getNodeExample(declaration);\n\n return {\n typeName: TypeName.REF_ALIAS,\n default: getJSDocTagComment(declaration, JSDocTagName.DEFAULT),\n description: this.getNodeDescription(declaration),\n refName,\n format: TypeNodeResolver.getNodeFormat(declaration),\n type,\n validators: getDeclarationValidators(declaration) || {},\n deprecated: hasJSDocTag(declaration, JSDocTagName.DEPRECATED),\n ...(example && { example }),\n };\n }\n\n private getModelReference(\n modelType: ts.InterfaceDeclaration | ts.ClassDeclaration,\n name: string,\n ) : ReferenceType {\n const example = this.getNodeExample(modelType);\n const description = this.getNodeDescription(modelType);\n const deprecatedDecoratorNames = namesForMarker(this.current.registry, isDeprecatedMarker);\n const deprecatedJsDocTags = tagsForMarker(this.current.registry, isDeprecatedMarker);\n const deprecated : boolean = [...deprecatedJsDocTags].some((tag) => hasJSDocTag(modelType, tag)) ||\n [...deprecatedDecoratorNames].some((name) => hasDecoratorNamed(modelType, name));\n\n // Handle toJSON methods\n if (!modelType.name) {\n throw new ResolverError('Can\\'t get Symbol from anonymous class', modelType);\n }\n const type = this.current.typeChecker.getTypeAtLocation(modelType.name);\n const toJSON = this.current.typeChecker.getPropertyOfType(type, 'toJSON');\n if (\n toJSON &&\n toJSON.valueDeclaration &&\n (\n ts.isMethodDeclaration(toJSON.valueDeclaration) ||\n ts.isMethodSignature(toJSON.valueDeclaration)\n )\n ) {\n let nodeType = toJSON.valueDeclaration.type;\n if (!nodeType) {\n const signature = this.current.typeChecker.getSignatureFromDeclaration(toJSON.valueDeclaration);\n if (signature) {\n const implicitType = this.current.typeChecker.getReturnTypeOfSignature(signature);\n nodeType = this.current.typeChecker.typeToTypeNode(implicitType, undefined, ts.NodeBuilderFlags.NoTruncation) as ts.TypeNode;\n } else {\n throw new ResolverError('Can\\'t get signature from toJson value declaration', modelType);\n }\n }\n\n return {\n refName: `${TypeNodeResolver.getRefTypeName(name)}Alias`,\n typeName: TypeName.REF_ALIAS,\n description,\n type: this.resolveNestedType(nodeType),\n deprecated,\n validators: {},\n ...(example && { example }),\n };\n }\n\n const properties = this.getModelProperties(modelType);\n const additionalProperties = this.getModelAdditionalProperties(modelType);\n const inheritedProperties = this.getModelInheritedProperties(modelType) || [];\n\n const referenceType: ReferenceType & { properties: ResolverProperty[] } = {\n additionalProperties,\n typeName: TypeName.REF_OBJECT,\n description,\n properties: inheritedProperties,\n refName: TypeNodeResolver.getRefTypeName(name),\n deprecated,\n ...(example && { example }),\n };\n\n referenceType.properties = referenceType.properties.concat(properties);\n\n return referenceType;\n }\n\n private static getRefTypeName(name: string): string {\n const sanitized = name\n // Structural characters → temporary placeholders\n .replace(/[<>]/g, '_')\n .replace(/[{}]/g, '_')\n .replace(/\\s+/g, '')\n // Delimiter characters → semantic names\n .replace(/,/g, '.')\n .replace(/'([^']*)'/g, '$1')\n .replace(/\"([^\"]*)\"/g, '$1')\n .replace(/&/g, '-and-')\n .replace(/\\|/g, '-or-')\n .replace(/\\[\\]/g, '-array')\n .replace(/([a-z]+):([a-z]+)/gi, '$1-$2')\n .replace(/;/g, '--')\n .replace(/([a-z]+)\\[([a-z]+)]/gi, '$1-at-$2')\n // Strip temporary placeholders (keep hyphens for semantic separators)\n .replace(/_/g, '');\n\n return encodeURIComponent(sanitized);\n }\n\n private contextualizedName(name: string): string {\n return Object.entries(\n this.context,\n ).reduce((acc, [key, entry]) => acc\n .replace(new RegExp(`<\\\\s*([^>]*\\\\s)*\\\\s*(${key})(\\\\s[^>]*)*\\\\s*>`, 'g'), `<$1${entry.getText()}$3>`)\n .replace(new RegExp(`<\\\\s*([^,]*\\\\s)*\\\\s*(${key})(\\\\s[^,]*)*\\\\s*,`, 'g'), `<$1${entry.getText()}$3,`)\n .replace(new RegExp(`,\\\\s*([^>]*\\\\s)*\\\\s*(${key})(\\\\s[^>]*)*\\\\s*>`, 'g'), `,$1${entry.getText()}$3>`)\n .replace(new RegExp(`<\\\\s*([^<]*\\\\s)*\\\\s*(${key})(\\\\s[^<]*)*\\\\s*<`, 'g'), `<$1${entry.getText()}$3<`), name);\n }\n\n private handleCachingAndCircularReferences(name: string, declarationResolver: () => ReferenceType): ReferenceType {\n try {\n const existingType = this.current.resolverCache.getCachedType(name);\n if (existingType) {\n return existingType;\n }\n\n if (this.current.resolverCache.isInProgress(name)) {\n return this.createCircularDependencyResolver(name);\n }\n\n this.current.resolverCache.markInProgress(name);\n\n try {\n const reference = declarationResolver();\n\n this.current.resolverCache.setCachedType(name, reference);\n\n this.current.addReferenceType(reference);\n\n return reference;\n } finally {\n this.current.resolverCache.clearInProgress(name);\n }\n } catch (err) {\n throw new ResolverError(\n `There was a problem resolving type of '${name}'.`,\n this.typeNode,\n { cause: err },\n );\n }\n }\n\n private createCircularDependencyResolver(refName: string) {\n const referenceType : ReferenceType = {\n deprecated: false,\n properties: [],\n typeName: TypeName.REF_OBJECT,\n refName,\n };\n\n this.current.registerDependencyResolver((referenceTypes) => {\n const realReferenceType : ReferenceType | undefined = referenceTypes[refName];\n if (!realReferenceType) {\n return;\n }\n\n referenceType.description = realReferenceType.description;\n if (realReferenceType.typeName === 'refObject' && referenceType.typeName === 'refObject') {\n referenceType.properties = realReferenceType.properties;\n }\n referenceType.typeName = realReferenceType.typeName as `${TypeName.REF_OBJECT}`;\n referenceType.refName = realReferenceType.refName;\n });\n\n return referenceType;\n }\n\n private static nodeIsUsable(node: ts.Node) : node is UsableDeclaration {\n switch (node.kind) {\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.TypeAliasDeclaration:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.EnumMember:\n return true;\n default:\n return false;\n }\n }\n\n private getModelTypeDeclarations(type: ts.EntityName) {\n let typeName = type.kind === ts.SyntaxKind.Identifier ? type.text : type.right.text;\n\n let symbol : ts.Symbol | undefined = this.getSymbolAtLocation(type);\n if (!symbol && type.kind === ts.SyntaxKind.QualifiedName) {\n const fullEnumSymbol = this.getSymbolAtLocation(type.left);\n symbol = fullEnumSymbol.exports?.get(typeName as any);\n }\n\n if (!symbol) {\n throw new ResolverError(\n `No symbol found for referenced type ${typeName}.`,\n );\n }\n\n const declarations = symbol.getDeclarations();\n if (!declarations || declarations.length === 0) {\n throw new ResolverError(\n `No declarations found for referenced type ${typeName}.`,\n );\n }\n\n if (symbol.escapedName !== typeName && symbol.escapedName !== 'default') {\n typeName = symbol.escapedName as string;\n }\n\n let modelTypes = declarations.filter((node) => {\n if (!TypeNodeResolver.nodeIsUsable(node) || !this.current.isExportedNode(node)) {\n return false;\n }\n\n const modelTypeDeclaration = node as UsableDeclaration;\n return (modelTypeDeclaration.name as ts.Identifier)?.text === typeName;\n });\n\n if (!modelTypes.length) {\n throw new ResolverError(\n `No matching model found for referenced type ${typeName}. If ${typeName} comes from a dependency, please create an interface in your own code that has the same structure. The compiler can not utilize interfaces from external dependencies.`,\n );\n }\n\n if (modelTypes.length > 1) {\n // remove types that are from typescript e.g. 'Account'\n modelTypes = modelTypes.filter((modelType) => modelType.getSourceFile()\n .fileName.replace(/\\\\/g, '/').toLowerCase().indexOf('node_modules/typescript') <= -1);\n\n modelTypes = TypeNodeResolver.getDesignatedModels(modelTypes, typeName);\n }\n\n return modelTypes;\n }\n\n private getModelTypeDeclaration(type: ts.EntityName) : UsableDeclaration {\n let typeName = type.kind === ts.SyntaxKind.Identifier ? type.text : type.right.text;\n\n const symbol = this.getSymbolAtLocation(type);\n const declarations = symbol.getDeclarations();\n if (!declarations || declarations.length === 0) {\n throw new ResolverError(\n `No models found for referenced type ${typeName}.`,\n );\n }\n\n if (symbol.escapedName !== typeName && symbol.escapedName !== 'default') {\n typeName = symbol.escapedName as string;\n }\n\n let modelTypes = declarations.filter((node) => {\n if (!TypeNodeResolver.nodeIsUsable(node) || !this.current.isExportedNode(node)) {\n return false;\n }\n\n const modelTypeDeclaration = node as UsableDeclaration;\n return (modelTypeDeclaration.name as ts.Identifier)?.text === typeName;\n });\n\n if (!modelTypes.length) {\n throw new ResolverError(\n `No matching model found for referenced type ${typeName}. If ${typeName} comes from a dependency, please create an interface in your own code that has the same structure. The compiler can not utilize interfaces from external dependencies.`,\n );\n }\n\n if (modelTypes.length > 1) {\n // remove types that are from typescript e.g. 'Account'\n modelTypes = modelTypes.filter((modelType) => modelType.getSourceFile()\n .fileName.replace(/\\\\/g, '/').toLowerCase().indexOf('node_modules/typescript') <= -1);\n\n modelTypes = TypeNodeResolver.getDesignatedModels(modelTypes, typeName);\n }\n if (modelTypes.length > 1) {\n const conflicts = modelTypes.map((modelType) => modelType.getSourceFile().fileName).join('\"; \"');\n throw new ResolverError(\n `Multiple matching models found for referenced type ${typeName}; please make model names unique. Conflicts found: \"${conflicts}\".`,\n );\n }\n\n return modelTypes[0] as UsableDeclaration;\n }\n\n private hasFlag(type: ts.Symbol | ts.Declaration, flag: number) {\n return (type.flags & flag) === flag;\n }\n\n private getSymbolAtLocation(type: ts.Node) : ts.Symbol {\n const symbol = this.current.typeChecker.getSymbolAtLocation(type) || ((type as any).symbol as ts.Symbol);\n // resolve alias if it is an alias, otherwise take symbol directly\n return (\n symbol &&\n this.hasFlag(symbol, ts.SymbolFlags.Alias) &&\n this.current.typeChecker.getAliasedSymbol(symbol)\n ) || symbol;\n }\n\n private getModelProperties(\n node: ts.InterfaceDeclaration | ts.ClassDeclaration,\n overrideToken?: OverrideToken,\n ) : ResolverProperty[] {\n const isIgnored = (e: ts.TypeElement | ts.ClassElement) => hasJSDocTag(e, JSDocTagName.IGNORE);\n\n // Interface model\n if (ts.isInterfaceDeclaration(node)) {\n return node.members\n .filter(\n (member) => !isIgnored(member) &&\n ts.isPropertySignature(member),\n ).map(\n (member) => this.propertyFromSignature(member as ts.PropertySignature, overrideToken),\n );\n }\n\n // Class model\n const properties = node.members\n .filter((member) => !isIgnored(member) &&\n member.kind === ts.SyntaxKind.PropertyDeclaration &&\n !this.hasStaticModifier(member) &&\n this.hasPublicModifier(member)) as Array<ts.PropertyDeclaration | ts.ParameterDeclaration>;\n\n const classConstructor = node.members.find(\n (member) => ts.isConstructorDeclaration(member),\n ) as ts.ConstructorDeclaration;\n\n if (classConstructor && classConstructor.parameters) {\n const constructorProperties = classConstructor.parameters.filter((parameter) => this.isAccessibleParameter(parameter));\n\n properties.push(...constructorProperties);\n }\n\n return properties.map((property) => this.propertyFromDeclaration(property, overrideToken));\n }\n\n private propertyFromSignature(propertySignature: ts.PropertySignature, overrideToken?: OverrideToken) {\n const identifier = propertySignature.name as ts.Identifier;\n\n if (!propertySignature.type) {\n throw new ResolverError('No valid type found for property declaration.');\n }\n\n let required = !propertySignature.questionToken;\n if (overrideToken && overrideToken.kind === ts.SyntaxKind.MinusToken) {\n required = true;\n } else if (overrideToken && overrideToken.kind === ts.SyntaxKind.QuestionToken) {\n required = false;\n }\n\n const property: ResolverProperty = {\n deprecated: hasJSDocTag(propertySignature, JSDocTagName.DEPRECATED),\n default: getJSDocTagComment(propertySignature, JSDocTagName.DEFAULT),\n description: this.getNodeDescription(propertySignature),\n example: this.getNodeExample(propertySignature),\n extensions: this.getNodeExtensions(propertySignature),\n format: TypeNodeResolver.getNodeFormat(propertySignature),\n name: identifier.text,\n required,\n type: this.resolveNestedType(\n propertySignature.type,\n propertySignature.type.parent,\n this.context,\n propertySignature.type,\n ),\n validators: getDeclarationValidators(propertySignature) || {},\n };\n return property;\n }\n\n private propertyFromDeclaration(\n propertyDeclaration: ts.PropertyDeclaration | ts.ParameterDeclaration,\n overrideToken?: OverrideToken,\n ) {\n const identifier = propertyDeclaration.name as ts.Identifier;\n let typeNode = propertyDeclaration.type;\n\n if (!typeNode) {\n const tsType = this.current.typeChecker.getTypeAtLocation(propertyDeclaration);\n typeNode = this.current.typeChecker.typeToTypeNode(tsType, undefined, ts.NodeBuilderFlags.NoTruncation);\n }\n\n if (!typeNode) {\n throw new ResolverError('No valid type found for property declaration.');\n }\n\n const type = this.resolveNestedType(typeNode, propertyDeclaration, this.context, typeNode);\n\n let required = !propertyDeclaration.questionToken && !propertyDeclaration.initializer;\n if (overrideToken && overrideToken.kind === ts.SyntaxKind.MinusToken) {\n required = true;\n } else if (overrideToken && overrideToken.kind === ts.SyntaxKind.QuestionToken) {\n required = false;\n }\n\n const property: ResolverProperty = {\n deprecated: hasJSDocTag(propertyDeclaration, JSDocTagName.DEPRECATED),\n default: getInitializerValue(propertyDeclaration.initializer, this.current.typeChecker),\n description: this.getNodeDescription(propertyDeclaration),\n example: this.getNodeExample(propertyDeclaration),\n extensions: this.getNodeExtensions(propertyDeclaration),\n format: TypeNodeResolver.getNodeFormat(propertyDeclaration),\n name: identifier.text,\n required,\n type,\n validators: getDeclarationValidators(propertyDeclaration) || {},\n };\n return property;\n }\n\n private getModelAdditionalProperties(node: UsableDeclaration) {\n if (node.kind === ts.SyntaxKind.InterfaceDeclaration) {\n const indexMember = node.members.find((member) => member.kind === ts.SyntaxKind.IndexSignature);\n if (!indexMember) {\n return undefined;\n }\n\n const indexSignatureDeclaration = indexMember as ts.IndexSignatureDeclaration;\n const indexType = this.resolveNestedType(\n indexSignatureDeclaration.parameters[0].type as ts.TypeNode,\n this.parentNode,\n this.context,\n );\n\n if (indexType.typeName !== 'string') {\n throw new ResolverError('Only string indexers are supported.', this.typeNode);\n }\n\n return this.resolveNestedType(indexSignatureDeclaration.type, this.parentNode, this.context);\n }\n\n return undefined;\n }\n\n private typeArgumentsToContext(\n type: ts.TypeReferenceNode | ts.ExpressionWithTypeArguments,\n targetEntity: ts.EntityName,\n context: TypeNodeResolverContext,\n ): TypeNodeResolverContext {\n // this.context = {};\n\n const declaration = this.getModelTypeDeclaration(targetEntity);\n if (typeof declaration === 'undefined' || !('typeParameters' in declaration)) {\n return context;\n }\n\n const { typeParameters } = declaration;\n\n if (typeParameters) {\n for (const [index, typeParameter] of typeParameters.entries()) {\n const typeArg = type.typeArguments && type.typeArguments[index];\n let resolvedType: ts.TypeNode;\n\n // Argument may be a forward reference from context\n if (typeArg && ts.isTypeReferenceNode(typeArg) && ts.isIdentifier(typeArg.typeName) && context[typeArg.typeName.text]) {\n resolvedType = context[typeArg.typeName.text];\n } else if (typeArg) {\n resolvedType = typeArg;\n } else if (typeParameter.default) {\n resolvedType = typeParameter.default;\n } else {\n throw new ResolverError(`Could not find a value for type parameter ${typeParameter.name.text}`, type);\n }\n\n this.context = {\n ...this.context,\n [typeParameter.name.text]: resolvedType,\n };\n }\n }\n return context;\n }\n\n private getModelInheritedProperties(\n modelTypeDeclaration: Exclude<UsableDeclaration, ts.PropertySignature | ts.TypeAliasDeclaration | ts.EnumMember>,\n ): ResolverProperty[] {\n let properties: ResolverProperty[] = [];\n\n const { heritageClauses } = modelTypeDeclaration;\n if (!heritageClauses) {\n return properties;\n }\n\n heritageClauses.forEach((clause) => {\n if (!clause.types) {\n return;\n }\n\n clause.types.forEach((t) => {\n const baseEntityName = t.expression as ts.EntityName;\n\n // create subContext\n const resetCtx = this.typeArgumentsToContext(t, baseEntityName, this.context);\n\n const referenceType = this.getReferenceType(t);\n if (referenceType) {\n if (isRefAliasType(referenceType)) {\n let type: Type = referenceType;\n while (isRefAliasType(type)) {\n type = type.type;\n }\n\n if (type.typeName === TypeName.REF_OBJECT) {\n properties = [...properties, ...type.properties];\n } else if (type.typeName === TypeName.NESTED_OBJECT_LITERAL) {\n properties = [...properties, ...type.properties];\n }\n }\n\n if (isRefObjectType(referenceType)) {\n referenceType.properties.forEach((property) => properties.push(property));\n }\n }\n\n // reset subContext\n this.context = resetCtx;\n });\n });\n\n return properties;\n }\n\n private getNodeDescription(node: UsableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.EnumDeclaration) {\n return getNodeDescription(node, this.current.typeChecker);\n }\n\n private static getNodeFormat(\n node: UsableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.EnumDeclaration,\n ) {\n return getJSDocTagComment(node, JSDocTagName.FORMAT);\n }\n\n private getNodeExample(node: UsableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.EnumDeclaration) {\n const example = getJSDocTagComment(node, JSDocTagName.EXAMPLE);\n\n if (example) {\n try {\n return JSON.parse(example);\n } catch {\n return example;\n }\n }\n\n return undefined;\n }\n\n protected getNodeExtensions(node: UsableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.EnumDeclaration) : Extension[] {\n return getNodeExtensions(node, this.current.registry);\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { IResolverCache, ReferenceType } from './types';\n\nexport class ResolverCache implements IResolverCache {\n private referenceTypes = new Map<string, ReferenceType>();\n\n private inProgressTypes = new Set<string>();\n\n getCachedType(name: string): ReferenceType | undefined {\n return this.referenceTypes.get(name);\n }\n\n setCachedType(name: string, type: ReferenceType): void {\n this.referenceTypes.set(name, type);\n }\n\n isInProgress(name: string): boolean {\n return this.inProgressTypes.has(name);\n }\n\n markInProgress(name: string): void {\n this.inProgressTypes.add(name);\n }\n\n clearInProgress(name: string): void {\n this.inProgressTypes.delete(name);\n }\n\n clear(): void {\n this.referenceTypes.clear();\n this.inProgressTypes.clear();\n }\n}\n","/*\n * Copyright (c) 2021-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Node } from 'typescript';\nimport {\n canHaveDecorators,\n getDecorators,\n isCallExpression,\n isNumericLiteral,\n isStringLiteral,\n} from 'typescript';\nimport type { NodeDecorator } from './types';\n\n/**\n * Get Decorators for a specific node.\n *\n * @param node\n * @param isMatching\n */\nexport function getNodeDecorators(\n node: Node,\n isMatching?: (data: NodeDecorator) => boolean,\n): NodeDecorator[] {\n if (!canHaveDecorators(node)) {\n return [];\n }\n\n const decorators = getDecorators(node);\n\n if (typeof decorators === 'undefined') {\n return [];\n }\n\n const items = decorators\n .map((d) => {\n const result: any = {\n arguments: [],\n typeArguments: [],\n };\n\n let x: any = d.expression;\n\n if (isCallExpression(x)) {\n if (x.arguments) {\n result.arguments = x.arguments.map((argument: any) => {\n if (isStringLiteral(argument) || isNumericLiteral(argument)) {\n return argument.text;\n }\n return argument;\n });\n }\n\n if (x.typeArguments) {\n result.typeArguments = x.typeArguments;\n }\n\n x = x.expression;\n }\n\n result.text = x.text || x.name.text;\n\n return result as NodeDecorator;\n });\n\n return typeof isMatching === 'undefined' ? items : items.filter(isMatching);\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { LocatorInfo } from 'locter';\nimport { buildFilePath, locateMany } from 'locter';\nimport type { EntryPoint } from '../../core/config';\n\nexport async function scanSourceFiles(input: EntryPoint) : Promise<string[]> {\n const sources = Array.isArray(input) ? input : [input];\n const result: Set<string> = new Set<string>();\n\n const promises : Promise<LocatorInfo[]>[] = [];\n\n for (const source of sources) {\n if (typeof source === 'string') {\n promises.push(locateMany(source));\n } else {\n promises.push(locateMany(source.pattern, { path: source.cwd }));\n }\n }\n\n const groupMatches = await Promise.all(promises);\n const matches = groupMatches.flat();\n\n for (const match of matches) {\n result.add(buildFilePath(match));\n }\n\n return Array.from(result);\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject, load } from 'locter';\nimport { ConfigErrorCode } from '../../../core/error/config-codes';\nimport { ConfigError } from '../../../core/error/config';\nimport process from 'node:process';\nimport path from 'node:path';\nimport { convertCompilerOptionsFromJson } from 'typescript';\nimport type { TsConfig, TsconfigLoadContext } from './types';\n\nexport async function loadTSConfig(\n context: TsconfigLoadContext = {},\n) : Promise<TsConfig> {\n let fileName : string;\n let filePath : string;\n const cwd = context.cwd || process.cwd();\n\n if (typeof context.name === 'string') {\n if (path.isAbsolute(context.name)) {\n filePath = context.name;\n } else {\n filePath = path.resolve(cwd, context.name);\n }\n\n fileName = path.basename(filePath);\n } else {\n fileName = 'tsconfig.json';\n filePath = path.join(cwd, fileName);\n }\n\n const content = await load(filePath);\n if (!isObject(content)) {\n throw new ConfigError({\n message: `The tsconfig file '${filePath}' is malformed.`,\n code: ConfigErrorCode.TSCONFIG_MALFORMED,\n });\n }\n\n if (typeof content.compilerOptions !== 'undefined') {\n const { options: compilerOptions } = convertCompilerOptionsFromJson(\n content.compilerOptions,\n cwd,\n fileName,\n );\n\n content.compilerOptions = compilerOptions;\n }\n\n return content;\n}\n\nexport async function softLoadTsconfig(\n context: TsconfigLoadContext = {},\n) : Promise<TsConfig> {\n try {\n return await loadTSConfig(context);\n } catch {\n return {};\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Bump whenever the on-disk cache shape changes incompatibly\n * (Metadata, Controller, Method, Parameter, resolver type nodes,\n * or the cache wrapper itself). Old cache files with a different\n * version are rejected on read.\n */\nexport const CACHE_SCHEMA_VERSION = '3';\n\nexport const CACHE_FILE_PREFIX = '.trapi-metadata-';\nexport const CACHE_FILE_SUFFIX = '.json';\n\n/** 7 days. */\nexport const CACHE_DEFAULT_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { tmpdir } from 'node:os';\nimport path from 'node:path';\nimport crypto from 'node:crypto';\nimport process from 'node:process';\nimport type { CompilerOptions } from 'typescript';\nimport type { Registry } from '../decorator/types';\nimport { CACHE_DEFAULT_MAX_AGE_MS } from './constants';\nimport type { CacheOptions, CacheOptionsInput } from './types';\n\nexport function buildCacheOptions(input?: string | boolean | CacheOptionsInput) : CacheOptions {\n if (typeof input === 'string') {\n input = {\n enabled: true,\n directoryPath: input,\n };\n }\n\n if (typeof input === 'boolean') {\n input = { enabled: input };\n }\n\n input = input || {};\n\n let directoryPath = tmpdir();\n if (typeof input.directoryPath === 'string') {\n directoryPath = path.isAbsolute(input.directoryPath) ?\n input.directoryPath :\n path.join(process.cwd(), input.directoryPath);\n }\n\n return {\n fileName: input.fileName,\n directoryPath,\n enabled: input.enabled ?? true,\n maxAgeMs: normalizeMaxAgeMs(input.maxAgeMs),\n };\n}\n\nfunction normalizeMaxAgeMs(input: number | undefined): number {\n if (typeof input !== 'number' || !Number.isFinite(input) || input < 0) {\n // NaN, Infinity, negative, or absent → fall back to the default.\n // Only `0` (explicit disable) and positive finite values are honored.\n return CACHE_DEFAULT_MAX_AGE_MS;\n }\n return input;\n}\n\n// -----------------------------------------------------------------------------\n// Cache key composition\n// -----------------------------------------------------------------------------\n\nexport type CacheKeyParts = {\n schemaVersion: string;\n sourceFilesHash: string;\n compilerOptionsHash: string;\n registryHash: string;\n presetName?: string;\n};\n\n/**\n * Combines all key contributors into a single sha256 hex string. The order is\n * stable; each part is null-separated to avoid concatenation ambiguity.\n */\nexport function composeCacheKey(parts: CacheKeyParts): string {\n const hash = crypto.createHash('sha256');\n hash.update(parts.schemaVersion);\n hash.update('\\0');\n hash.update(parts.sourceFilesHash);\n hash.update('\\0');\n hash.update(parts.compilerOptionsHash);\n hash.update('\\0');\n hash.update(parts.registryHash);\n hash.update('\\0');\n hash.update(parts.presetName ?? '');\n return hash.digest('hex');\n}\n\n/**\n * Hash a stable JSON projection of `compilerOptions`. Sorting keys keeps the\n * output deterministic regardless of declaration order in tsconfig.json.\n */\nexport function hashCompilerOptions(options?: CompilerOptions): string {\n const hash = crypto.createHash('sha256');\n hash.update(stableStringify(options ?? {}));\n return hash.digest('hex');\n}\n\n/**\n * Hash the resolved registry's structural shape. Catches structural changes\n * (handler added/removed/renamed, marker changed, replaces policy changed)\n * AND most logic changes via `apply.toString()`. Misses changes that are\n * purely captured-variable shifts in factory-built handlers — acceptable\n * trade-off for catching local preset edits.\n */\nexport function hashRegistry(registry: Registry): string {\n const hash = crypto.createHash('sha256');\n const kinds = [\n 'controllers',\n 'methods',\n 'parameters',\n 'controllerJsDoc',\n 'methodJsDoc',\n 'parameterJsDoc',\n ] as const;\n for (const kind of kinds) {\n hash.update(kind);\n hash.update('\\0');\n const handlers = registry[kind] ?? [];\n for (const handler of handlers) {\n hash.update(stableStringify(handler.match));\n hash.update('\\0');\n hash.update(stableStringify(handler.marker ?? null));\n hash.update('\\0');\n hash.update(String(handler.replaces ?? ''));\n hash.update('\\0');\n hash.update(handler.apply.toString());\n hash.update('\\0');\n }\n hash.update('\\x01');\n }\n return hash.digest('hex');\n}\n\n/**\n * JSON.stringify with sorted object keys at every level. Functions and\n * undefined are omitted as usual; that's fine for the inputs we hash here.\n */\nfunction stableStringify(value: unknown): string {\n return JSON.stringify(value, (_key, val) => {\n if (val && typeof val === 'object' && !Array.isArray(val)) {\n const sorted: Record<string, unknown> = {};\n for (const k of Object.keys(val as Record<string, unknown>).sort()) {\n sorted[k] = (val as Record<string, unknown>)[k];\n }\n return sorted;\n }\n return val;\n });\n}\n","/*\n * Copyright (c) 2021.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { parse as parseFlatted, stringify as stringifyFlatted } from 'flatted';\nimport { buildFilePath as joinFilePath, locateMany } from 'locter';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport {\n CACHE_FILE_PREFIX,\n CACHE_FILE_SUFFIX,\n CACHE_SCHEMA_VERSION,\n} from './constants';\nimport { buildCacheOptions } from './utils';\nimport type {\n CacheData,\n CacheOptions,\n CacheOptionsInput,\n ICacheClient,\n} from './types';\n\nexport class CacheClient implements ICacheClient {\n private readonly options: CacheOptions;\n\n constructor(input?: string | boolean | CacheOptionsInput) {\n this.options = buildCacheOptions(input);\n }\n\n // -------------------------------------------------------------------------\n\n async save(data: CacheData): Promise<string | undefined> {\n if (!this.options.enabled) {\n return undefined;\n }\n\n await this.ensureDirectory();\n\n const filePath = this.resolveFilePath(data.cacheKey);\n // `flatted` is cycle-safe — it encodes self-references and back-edges\n // as integer indices into a flat array. Well-formed metadata uses\n // `refName` strings for cross-references and contains no cycles, but\n // we use `flatted` defensively so a future regression cannot crash\n // serialization or silently corrupt the cached graph.\n const payload = stringifyFlatted(data);\n\n // Atomic write: rename is atomic on POSIX, so concurrent generators\n // either see the previous file or the new one — never a half-written\n // truncation.\n const tmpPath = `${filePath}.${process.pid}.${crypto.randomBytes(6).toString('hex')}.tmp`;\n\n try {\n await fs.promises.writeFile(tmpPath, payload);\n await fs.promises.rename(tmpPath, filePath);\n } catch (err) {\n // Best-effort cleanup of the temp file if rename failed.\n try {\n await fs.promises.unlink(tmpPath);\n } catch {\n // ignore\n }\n throw err;\n }\n\n // Opportunistic eviction. Errors are ignored — eviction is a\n // housekeeping concern, not a correctness one.\n this.evict().catch(() => undefined);\n\n return filePath;\n }\n\n async get(cacheKey: string): Promise<CacheData | undefined> {\n if (!this.options.enabled) {\n return undefined;\n }\n\n const filePath = this.resolveFilePath(cacheKey);\n\n let content: string;\n try {\n content = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n } catch {\n return undefined;\n }\n\n let cache: CacheData;\n try {\n cache = parseFlatted(content) as CacheData;\n } catch {\n // Corrupt file — drop it so the next save can replace cleanly.\n await fs.promises.unlink(filePath).catch(() => undefined);\n return undefined;\n }\n\n if (\n !cache ||\n cache.cacheKey !== cacheKey ||\n cache.schemaVersion !== CACHE_SCHEMA_VERSION\n ) {\n return undefined;\n }\n\n return cache;\n }\n\n // -------------------------------------------------------------------------\n\n /**\n * Prune cache files older than `maxAgeMs`. No-op when disabled or when\n * `maxAgeMs <= 0`. Each unlink is best-effort — a concurrent generator\n * may have already removed the file.\n */\n async evict(): Promise<void> {\n if (!this.options.enabled || this.options.maxAgeMs <= 0) {\n return;\n }\n\n const pattern = this.options.fileName ?? `${CACHE_FILE_PREFIX}*${CACHE_FILE_SUFFIX}`;\n\n let entries: Awaited<ReturnType<typeof locateMany>>;\n try {\n entries = await locateMany(pattern, { path: this.options.directoryPath });\n } catch {\n return;\n }\n\n const cutoff = Date.now() - this.options.maxAgeMs;\n\n await Promise.all(entries.map(async (entry) => {\n const filePath = joinFilePath(entry);\n try {\n const stat = await fs.promises.stat(filePath);\n if (stat.mtimeMs < cutoff) {\n await fs.promises.unlink(filePath);\n }\n } catch {\n // ignore — file may have been removed by another process\n }\n }));\n }\n\n // -------------------------------------------------------------------------\n\n private resolveFilePath(cacheKey: string): string {\n // The internal pipeline always passes a sha256 hex digest, but the\n // public `ICacheClient` accepts any string. Reject anything that\n // could break out of `directoryPath` via `path.join`'s normalization\n // (`../`, absolute paths, embedded separators, NUL bytes).\n if (!CACHE_KEY_PATTERN.test(cacheKey)) {\n throw new Error(`Invalid cacheKey: must match ${CACHE_KEY_PATTERN}`);\n }\n const fileName = this.options.fileName ??\n `${CACHE_FILE_PREFIX}${cacheKey}${CACHE_FILE_SUFFIX}`;\n return path.join(this.options.directoryPath, fileName);\n }\n\n private async ensureDirectory(): Promise<void> {\n // Don't memoize — the directory may be removed externally (temp\n // cleanup, another process) at any time. `mkdir(recursive: true)`\n // is a no-op when the directory already exists, so re-running it\n // on every save is cheap and self-healing.\n await fs.promises.mkdir(this.options.directoryPath, { recursive: true });\n }\n}\n\n// Hex digest from sha256 (64 chars) is the canonical caller, but allow\n// any printable ASCII without separators / dots up to a sane length so\n// custom callers (and the suffix-bearing tmp path) keep working.\nconst CACHE_KEY_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isBaseError } from '@ebec/core';\nimport { MetadataError } from './base';\n\nexport class GeneratorError extends MetadataError {\n\n}\n\nexport function isGeneratorError(input: unknown): input is GeneratorError & { code: string } {\n if (!isBaseError(input)) {\n return false;\n }\n\n return typeof input.code === 'string';\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const GeneratorErrorCode = {\n CONTROLLER_NO_SOURCE_FILE: 'GENERATOR_CONTROLLER_NO_SOURCE_FILE',\n CONTROLLER_NO_NAME: 'GENERATOR_CONTROLLER_NO_NAME',\n PARAMETER_GENERATION_FAILED: 'GENERATOR_PARAMETER_GENERATION_FAILED',\n BODY_PARAMETER_DUPLICATE: 'GENERATOR_BODY_PARAMETER_DUPLICATE',\n BODY_FORM_CONFLICT: 'GENERATOR_BODY_FORM_CONFLICT',\n STRICT_UNMATCHED_DECORATORS: 'GENERATOR_STRICT_UNMATCHED_DECORATORS',\n} as const;\nexport type GeneratorErrorCode = typeof GeneratorErrorCode[keyof typeof GeneratorErrorCode];\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport { isClassDeclaration, isMethodDeclaration } from 'typescript';\nimport type { Node } from 'typescript';\nimport type { BaseType } from '../types/resolver';\nimport { ParameterErrorCode } from '../types/index.ts';\nimport { MetadataError } from './base';\n\ntype UnsupportedTypeContext = {\n decoratorName: string,\n propertyName: string,\n type: BaseType,\n node?: Node\n};\n\ntype UnsupportedMethodContext = {\n decoratorName: string,\n propertyName: string,\n method: string,\n node?: Node\n};\n\ntype PathMatchInvalidContext = {\n decoratorName: string,\n propertyName: string,\n path: string,\n node?: Node\n};\n\ntype ScopeRequiredContext = {\n decoratorName: string,\n node?: Node\n};\n\nexport class ParameterError extends MetadataError {\n static typeUnsupported(context: UnsupportedTypeContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not support '${context.type.typeName}' type${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.TYPE_UNSUPPORTED,\n });\n }\n\n static methodUnsupported(context: UnsupportedMethodContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not support method '${context.method}'${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.METHOD_UNSUPPORTED,\n });\n }\n\n static invalidPathMatch(context: PathMatchInvalidContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}('${context.propertyName}') does not exist in path '${context.path}'${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.PATH_MISMATCH,\n });\n }\n\n static scopeRequired(context: ScopeRequiredContext) {\n const location = context.node ? ParameterError.getCurrentLocation(context.node) : undefined;\n return new ParameterError({\n message: `@${context.decoratorName}() requires a scope argument${location ? ` at ${location}` : ''}.`,\n code: ParameterErrorCode.SCOPE_REQUIRED,\n });\n }\n\n static invalidExampleSchema() {\n return new ParameterError({\n message: 'The @example JSDoc tag contains invalid JSON.',\n code: ParameterErrorCode.INVALID_EXAMPLE,\n });\n }\n\n public static getCurrentLocation(node: Node) {\n const parts : string[] = [];\n\n if (isMethodDeclaration(node.parent)) {\n parts.push(node.parent.name.getText());\n\n if (isClassDeclaration(node.parent.parent)) {\n parts.unshift(node.parent.parent.name.text);\n }\n }\n\n return parts.join('.');\n }\n}\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from 'locter';\nimport * as ts from 'typescript';\nimport {\n type ApplyHandlersOptions,\n ParamKind,\n type ParameterDraft,\n applyDecoratorHandlers,\n applyJsDocHandlers,\n newParameterDraft,\n} from '../../../adapters/decorator';\nimport { getInitializerValue } from '../../../adapters/typescript/initializer';\nimport { getDeclarationValidators } from '../../../adapters/typescript/validator';\nimport {\n JSDocTagName,\n getJSDocTags,\n hasJSDocTag,\n transformJSDocComment,\n} from '../../../adapters/typescript/js-doc';\nimport { TypeNodeResolver } from '../../../adapters/typescript/resolver';\nimport {\n isArrayType,\n isNestedObjectLiteralType,\n isRefEnumType,\n isRefObjectType,\n isUnionType,\n} from '../../../core/types/type-guards';\nimport { TypeName } from '../../../core/types/type-name';\nimport {\n CollectionFormat,\n ParameterSource,\n} from '../../../core/types/parameter-source';\nimport { ParameterError } from '../../../core/error/parameter';\nimport type { IGeneratorContext } from '../../../core/types/metadata';\nimport type {\n BaseType,\n NestedObjectLiteralType,\n RefObjectType,\n Type,\n} from '../../../core/types/resolver';\nimport type { Extension } from '../../../core/types/extension';\nimport type { ArrayParameter, IParameterGenerator, Parameter } from '../../../core/types/parameter';\n\nconst BODY_SUPPORTED_METHODS = new Set(['delete', 'post', 'put', 'patch', 'get']);\n\nconst SUPPORTED_LEAF_TYPES = new Set<string>([\n TypeName.STRING,\n TypeName.INTEGER,\n TypeName.LONG,\n TypeName.FLOAT,\n TypeName.DOUBLE,\n TypeName.DATE,\n TypeName.DATETIME,\n TypeName.BUFFER,\n TypeName.BOOLEAN,\n TypeName.ENUM,\n]);\n\nexport class ParameterGenerator implements IParameterGenerator {\n private readonly parameter: ts.ParameterDeclaration;\n\n private readonly method: string;\n\n private readonly paths: string[];\n\n private readonly current: IGeneratorContext;\n\n constructor(\n parameter: ts.ParameterDeclaration,\n method: string,\n paths: string[],\n current: IGeneratorContext,\n ) {\n this.parameter = parameter;\n this.method = method;\n this.paths = paths.length === 0 ? [''] : paths;\n this.current = current;\n }\n\n public generate(): Parameter[] {\n const parameterName = this.getParameterName();\n const draft = newParameterDraft({ parameterName });\n\n const options = this.applyOptions(parameterName);\n applyDecoratorHandlers(this.parameter, this.current.registry.parameters, draft, options);\n applyJsDocHandlers(this.parameter, this.current.registry.parameterJsDoc, draft, options);\n\n // TS-resolved type\n const type = this.resolveType();\n draft.type = type;\n\n // Description from TS symbol's documentation comment.\n const description = this.getDescription();\n if (description) {\n draft.description = description;\n }\n\n // Deprecation: handler may have set it; otherwise check JSDoc on parameter.\n if (draft.deprecated === undefined && hasJSDocTag(this.parameter, JSDocTagName.DEPRECATED)) {\n draft.deprecated = true;\n }\n\n // Default value from TS initializer.\n const defaultValue = getInitializerValue(this.parameter.initializer, this.current.typeChecker, type);\n if (defaultValue !== undefined) {\n draft.default = defaultValue;\n }\n\n // Required: TS optionality and presence of initializer.\n draft.required = !this.parameter.questionToken && !this.parameter.initializer;\n\n // Examples from method-level JSDoc @example tags scoped to this parameter.\n const { examples, exampleLabels } = this.getJsDocExamples(parameterName);\n if (examples) {\n draft.examples = examples.map((value) => ({ value }));\n draft.exampleLabels = (exampleLabels ?? []).filter((l): l is string => l !== undefined);\n }\n\n // Declaration-level validators (e.g., @MaxLength annotations on the parameter).\n Object.assign(draft.validators, getDeclarationValidators(this.parameter, parameterName));\n\n // Apply default `in` if no handler claimed.\n if (!draft.in) {\n if (!BODY_SUPPORTED_METHODS.has(this.method)) {\n throw ParameterError.methodUnsupported({\n decoratorName: 'Body',\n propertyName: parameterName,\n method: this.method,\n node: this.parameter,\n });\n }\n draft.in = ParamKind.Body;\n }\n\n // Body validation requires the method to support a body.\n if ((draft.in === ParamKind.Body || draft.in === ParamKind.BodyProp) &&\n !BODY_SUPPORTED_METHODS.has(this.method)) {\n throw ParameterError.methodUnsupported({\n decoratorName: 'Body',\n propertyName: draft.name,\n method: this.method,\n node: this.parameter,\n });\n }\n\n return this.finalize(draft, type, parameterName, examples, exampleLabels);\n }\n\n private finalize(\n draft: ParameterDraft,\n type: Type,\n parameterName: string,\n examples: unknown[] | undefined,\n exampleLabels: Array<string | undefined> | undefined,\n ): Parameter[] {\n const kind = draft.in!;\n const wrappedExamples = examples ? examples.map((value) => ({ value })) : undefined;\n const filteredLabels = exampleLabels?.filter((l): l is string => l !== undefined);\n\n // Object decomposition for kinds that can carry an object payload.\n if ((kind === ParameterSource.QUERY || kind === ParameterSource.PATH) &&\n (isNestedObjectLiteralType(type) || isRefObjectType(type))) {\n const decomposed = this.decomposeObject(type, {\n in: kind === ParameterSource.QUERY ? ParameterSource.QUERY_PROP : ParameterSource.PATH,\n examples: wrappedExamples,\n exampleLabels: filteredLabels,\n extensions: draft.extensions,\n });\n if (kind === ParameterSource.PATH) {\n this.validatePathDecomposition(decomposed);\n }\n return decomposed;\n }\n\n if ((kind === ParameterSource.QUERY || kind === ParameterSource.QUERY_PROP) &&\n isArrayType(type)) {\n if (!this.isLeafTypeSupported(type.elementType)) {\n throw ParameterError.typeUnsupported({\n decoratorName: kind === ParameterSource.QUERY ? 'Query' : 'QueryProp',\n propertyName: draft.name,\n type: type.elementType,\n node: this.parameter,\n });\n }\n const arrayParameter: ArrayParameter = {\n ...this.draftToParameter(draft),\n collectionFormat: draft.collectionFormat ?? CollectionFormat.MULTI,\n type,\n };\n return [arrayParameter];\n }\n\n if ((kind === ParameterSource.QUERY || kind === ParameterSource.QUERY_PROP) &&\n !this.isLeafOrEnumOrUnion(type)) {\n throw ParameterError.typeUnsupported({\n decoratorName: kind === ParameterSource.QUERY ? 'Query' : 'QueryProp',\n propertyName: draft.name,\n type,\n node: this.parameter,\n });\n }\n\n if (kind === ParameterSource.PATH) {\n this.validatePathName(draft.name, parameterName);\n }\n\n return [this.draftToParameter(draft)];\n }\n\n private draftToParameter(draft: ParameterDraft): Parameter {\n return {\n allowEmptyValue: draft.allowEmptyValue,\n collectionFormat: draft.collectionFormat,\n default: draft.default,\n description: draft.description,\n examples: draft.examples.length > 0 ? draft.examples : undefined,\n exampleLabels: draft.exampleLabels.length > 0 ? draft.exampleLabels : undefined,\n extensions: draft.extensions,\n in: draft.in!,\n maxItems: draft.maxItems,\n minItems: draft.minItems,\n name: draft.name,\n parameterName: draft.parameterName,\n required: draft.required,\n type: draft.type!,\n deprecated: draft.deprecated,\n validators: draft.validators,\n };\n }\n\n private decomposeObject(\n type: NestedObjectLiteralType | RefObjectType,\n details: {\n in: `${ParameterSource}`;\n examples: { value: unknown }[] | undefined;\n exampleLabels: string[] | undefined;\n extensions: Extension[];\n },\n ): Parameter[] {\n if (type.properties.length === 0) {\n return [];\n }\n\n const parameterName = this.getParameterName();\n const initializerValue = getInitializerValue(this.parameter.initializer, this.current.typeChecker, type);\n const description = this.getDescription();\n const isParamOptional = !!this.parameter.questionToken;\n const isParamDeprecated = hasJSDocTag(this.parameter, JSDocTagName.DEPRECATED);\n\n const output: Parameter[] = [];\n for (const property of type.properties) {\n let propertyDefaultValue = property.default;\n if (typeof propertyDefaultValue === 'undefined' && isObject(initializerValue)) {\n propertyDefaultValue = (initializerValue as Record<string, unknown>)[property.name];\n }\n\n const required = isParamOptional ? false : property.required;\n\n output.push({\n extensions: [...details.extensions],\n in: details.in,\n examples: details.examples,\n exampleLabels: details.exampleLabels,\n default: propertyDefaultValue,\n description: property.description || description,\n name: property.name,\n parameterName,\n required,\n type: property.type,\n deprecated: property.deprecated || isParamDeprecated,\n validators: {},\n });\n }\n return output;\n }\n\n private pathContainsParam(name: string): boolean {\n // Match `{name}` literally — curly braces are their own boundaries.\n // For `:name`, require a word boundary after the name so `:id` doesn't\n // match `:id2` (substring), but it still matches when path-to-regexp\n // modifiers/constraints follow the name (`:id?`, `:id*`, `:id(\\\\d+)`).\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const colonPattern = new RegExp(`:${escaped}\\\\b`);\n const bracePattern = `{${name}}`;\n for (const p of this.paths) {\n if (p.includes(bracePattern) || colonPattern.test(p)) {\n return true;\n }\n }\n return false;\n }\n\n private validatePathDecomposition(decomposed: Parameter[]): void {\n for (const element of decomposed) {\n if (!this.pathContainsParam(element.name)) {\n throw ParameterError.invalidPathMatch({\n decoratorName: 'Path',\n propertyName: element.name,\n path: this.paths.join(' | '),\n node: this.parameter,\n });\n }\n }\n }\n\n private validatePathName(name: string, parameterName: string): void {\n const candidate = name || parameterName;\n if (!this.pathContainsParam(candidate)) {\n throw ParameterError.invalidPathMatch({\n decoratorName: 'Path',\n propertyName: candidate,\n path: this.paths.join(' | '),\n node: this.parameter,\n });\n }\n }\n\n private isLeafTypeSupported(type: BaseType): boolean {\n return SUPPORTED_LEAF_TYPES.has(type.typeName);\n }\n\n private isLeafOrEnumOrUnion(type: Type): boolean {\n return SUPPORTED_LEAF_TYPES.has(type.typeName) ||\n isRefEnumType(type) ||\n isUnionType(type);\n }\n\n private resolveType(): Type {\n let typeNode = this.parameter.type;\n if (!typeNode) {\n const t = this.current.typeChecker.getTypeAtLocation(this.parameter);\n typeNode = this.current.typeChecker.typeToTypeNode(\n t,\n undefined,\n ts.NodeBuilderFlags.NoTruncation,\n );\n }\n if (!typeNode) {\n throw new ParameterError({ message: `Could not resolve type for parameter '${this.getParameterName()}'.` });\n }\n return new TypeNodeResolver(typeNode, this.current, this.parameter).resolve();\n }\n\n private getParameterName(): string {\n if (!ts.isIdentifier(this.parameter.name)) {\n throw new ParameterError({ message: 'Destructured parameters are not supported. Use a simple identifier name.' });\n }\n return this.parameter.name.text;\n }\n\n private getDescription(): string {\n const symbol = this.current.typeChecker.getSymbolAtLocation(this.parameter.name);\n if (symbol) {\n const comments = symbol.getDocumentationComment(this.current.typeChecker);\n if (comments.length > 0) {\n return ts.displayPartsToString(comments);\n }\n }\n return '';\n }\n\n private getJsDocExamples(parameterName: string): {\n examples: unknown[] | undefined;\n exampleLabels: Array<string | undefined> | undefined;\n } {\n const exampleLabels: Array<string | undefined> = [];\n const tags = getJSDocTags(this.parameter.parent, (tag) => {\n const comment = transformJSDocComment(tag.comment);\n const isExample = (tag.tagName.text === JSDocTagName.EXAMPLE ||\n tag.tagName.escapedText === JSDocTagName.EXAMPLE) &&\n !!comment && comment.startsWith(parameterName);\n\n if (isExample && comment) {\n const hasExampleLabel = (comment.split(' ')[0].indexOf('.') || -1) > 0;\n exampleLabels.push(hasExampleLabel ?\n comment.split(' ')[0].split('.').slice(1).join('.') :\n undefined);\n }\n return isExample ?? false;\n });\n\n const examples = tags.map((tag) => (\n transformJSDocComment(tag.comment) || '')\n .replace(`${transformJSDocComment(tag.comment)?.split(' ')[0] || ''}`, '')\n .replace(/\\r/g, ''));\n\n if (examples.length === 0) {\n return { examples: undefined, exampleLabels: undefined };\n }\n\n try {\n return {\n examples: examples.map((example) => JSON.parse(example)),\n exampleLabels,\n };\n } catch {\n throw ParameterError.invalidExampleSchema();\n }\n }\n\n private applyOptions(parameterName: string): ApplyHandlersOptions {\n return {\n target: 'parameter',\n host: { name: parameterName, parentName: this.method },\n resolveTypeNode: (n) => new TypeNodeResolver(n, this.current).resolve(),\n typeChecker: this.current.typeChecker,\n parameterType: () => this.parameter.type ?\n new TypeNodeResolver(this.parameter.type, this.current).resolve() :\n undefined,\n onUnmatchedDecorator: (this.current.config.strict || this.current.config.onUnmatchedDecorator) ?\n (report) => this.current.reportUnmatchedDecorator?.(report) :\n undefined,\n };\n }\n}\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport { NodeBuilderFlags } from 'typescript';\nimport type {\n ClassDeclaration,\n Identifier,\n MethodDeclaration,\n TypeNode,\n} from 'typescript';\nimport {\n type ApplyHandlersOptions,\n applyDecoratorHandlers,\n applyJsDocHandlers,\n newMethodDraft,\n} from '../../../adapters/decorator';\nimport { GeneratorErrorCode } from '../../../core/error/generator-codes';\nimport { GeneratorError } from '../../../core/error/generator';\nimport type { BaseType } from '../../../core/types/resolver';\nimport { TypeNodeResolver } from '../../../adapters/typescript/resolver';\nimport { isVoidType } from '../../../core/types/type-guards';\nimport {\n JSDocTagName,\n getJSDocDescription,\n getJSDocTagComment,\n} from '../../../adapters/typescript/js-doc';\nimport { normalizePath } from '../../../core/utils';\nimport type { IGeneratorContext } from '../../../core/types/metadata';\nimport type { Parameter } from '../../../core/types/parameter';\nimport { ParameterGenerator } from '../parameter';\nimport { ParameterSource } from '../../../core/types/parameter-source';\nimport type { Example, Response } from '../../../core/types/generator';\nimport type { Method } from '../../../core/types/method';\n\nexport class MethodGenerator {\n protected readonly node: MethodDeclaration;\n\n protected readonly current: IGeneratorContext;\n\n constructor(node: MethodDeclaration, current: IGeneratorContext) {\n this.node = node;\n this.current = current;\n }\n\n public getMethodName(): string {\n const identifier = this.node.name as Identifier;\n return identifier.text;\n }\n\n public generate(controllerPaths: string[]): Method | null {\n const name = this.getMethodName();\n const draft = newMethodDraft({ name });\n\n const options = this.applyOptions();\n applyDecoratorHandlers(this.node, this.current.registry.methods, draft, options);\n applyJsDocHandlers(this.node, this.current.registry.methodJsDoc, draft, options);\n\n // Not a route method (no HTTP verb decorator matched).\n if (!draft.verb) {\n return null;\n }\n\n // Skip hidden methods entirely (matches v1 behaviour for class member iteration).\n if (draft.hidden) {\n return null;\n }\n\n // Resolve return type.\n const returnType = this.resolveReturnType();\n\n // Build responses: handler-supplied first, then a derived default that\n // carries any handler-contributed default-response examples.\n const defaultResponse = buildDefaultResponse(returnType, draft.defaultResponseExamples);\n const responses = mergeDefaultResponse(draft.responses, defaultResponse);\n\n // Walk parameters.\n const parameters = this.buildParameters(controllerPaths, draft.path, draft.verb);\n\n // Description from leading JSDoc comment (no v2 handler covers this since it\n // isn't a tagged value).\n const description = getJSDocDescription(this.node) ?? draft.description;\n const summary = draft.summary ?? getJSDocTagComment(this.node, JSDocTagName.SUMMARY);\n\n return {\n consumes: draft.consumes,\n deprecated: draft.deprecated ?? false,\n description: description ?? '',\n extensions: draft.extensions,\n hidden: draft.hidden,\n method: draft.verb,\n name,\n path: normalizePath(draft.path),\n produces: draft.produces,\n responses,\n security: draft.security,\n summary,\n tags: draft.tags,\n type: returnType,\n parameters,\n };\n }\n\n private applyOptions(): ApplyHandlersOptions {\n const parentName = (this.node.parent as ClassDeclaration).name?.text;\n return {\n target: 'method',\n host: { name: this.getMethodName(), parentName },\n resolveTypeNode: (n: TypeNode) => new TypeNodeResolver(n, this.current).resolve(),\n typeChecker: this.current.typeChecker,\n onUnmatchedDecorator: (this.current.config.strict || this.current.config.onUnmatchedDecorator) ?\n (report) => this.current.reportUnmatchedDecorator?.(report) :\n undefined,\n };\n }\n\n private resolveReturnType(): BaseType {\n let nodeType = this.node.type;\n if (!nodeType) {\n const { typeChecker } = this.current;\n const signature = typeChecker.getSignatureFromDeclaration(this.node);\n const implicitType = typeChecker.getReturnTypeOfSignature(signature);\n nodeType = typeChecker.typeToTypeNode(implicitType, undefined, NodeBuilderFlags.NoTruncation) as TypeNode;\n }\n return new TypeNodeResolver(nodeType, this.current).resolve();\n }\n\n private buildParameters(\n controllerPaths: string[],\n methodPath: string,\n verb: string,\n ): Parameter[] {\n const controllerId = (this.node.parent as ClassDeclaration).name as Identifier;\n const methodId = this.node.name as Identifier;\n // Build the union of every (controllerPath × methodPath) combination so\n // path-parameter validation accepts a parameter that's present in any\n // mount (a controller can mount at /roles AND /realms/:id/roles).\n const fullPaths = (controllerPaths.length === 0 ? [''] : controllerPaths)\n .map((cp) => path.posix.join('/', cp, methodPath));\n\n const output: Parameter[] = [];\n let bodyParameterCount = 0;\n let formParameterCount = 0;\n\n for (let i = 0; i < this.node.parameters.length; i++) {\n try {\n const generator = new ParameterGenerator(\n this.node.parameters[i],\n verb,\n fullPaths,\n this.current,\n );\n\n const parameters = generator.generate();\n\n for (const parameter of parameters) {\n if (parameter.in === ParameterSource.BODY) {\n bodyParameterCount += 1;\n }\n if (parameter.in === ParameterSource.FORM_DATA) {\n formParameterCount += 1;\n }\n if (parameter.in !== ParameterSource.CONTEXT) {\n output.push(parameter);\n }\n }\n } catch (e) {\n const causeMsg = e instanceof Error ? `: ${e.message}` : '';\n throw new GeneratorError({\n message: `Parameter generation failed for '${controllerId.text}.${methodId.text}' argument index ${i}${causeMsg}`,\n code: GeneratorErrorCode.PARAMETER_GENERATION_FAILED,\n cause: e,\n });\n }\n }\n\n if (bodyParameterCount > 1) {\n throw new GeneratorError({\n message: `Only one body parameter allowed in '${controllerId.text}.${methodId.text}' method.`,\n code: GeneratorErrorCode.BODY_PARAMETER_DUPLICATE,\n });\n }\n\n if (bodyParameterCount > 0 && formParameterCount > 0) {\n throw new GeneratorError({\n message: `Cannot mix body and form parameters in '${controllerId.text}.${methodId.text}' method.`,\n code: GeneratorErrorCode.BODY_FORM_CONFLICT,\n });\n }\n\n return output;\n }\n}\n\nfunction buildDefaultResponse(returnType: BaseType, examples: Example[]): Response {\n const isVoid = isVoidType(returnType);\n return {\n description: isVoid ? 'No content' : 'Ok',\n examples,\n schema: returnType,\n status: isVoid ? '204' : '200',\n name: isVoid ? '204' : '200',\n };\n}\n\nfunction mergeDefaultResponse(handlerResponses: Response[], defaultResponse: Response): Response[] {\n if (handlerResponses.length === 0) {\n return [defaultResponse];\n }\n const existing = handlerResponses.findIndex((r) => r.status === defaultResponse.status);\n if (existing >= 0) {\n const target = handlerResponses[existing];\n if (defaultResponse.examples && defaultResponse.examples.length > 0 &&\n (!target.examples || target.examples.length === 0)) {\n target.examples = defaultResponse.examples;\n }\n return handlerResponses;\n }\n return [...handlerResponses, defaultResponse];\n}\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type {\n ClassDeclaration, \n Expression, \n MethodDeclaration, \n TypeNode,\n} from 'typescript';\nimport {\n SymbolFlags,\n SyntaxKind,\n isClassDeclaration,\n isMethodDeclaration,\n} from 'typescript';\nimport {\n type ApplyHandlersOptions,\n applyDecoratorHandlers,\n applyJsDocHandlers,\n newControllerDraft,\n} from '../../../adapters/decorator';\nimport { TypeNodeResolver } from '../../../adapters/typescript/resolver';\nimport { isResolverError } from '../../../core/error/resolver';\nimport { GeneratorErrorCode } from '../../../core/error/generator-codes';\nimport { GeneratorError, isGeneratorError } from '../../../core/error/generator';\nimport { normalizePath } from '../../../core/utils';\nimport type { Method } from '../../../core/types/method';\nimport { MethodGenerator } from '../method';\nimport type { IGeneratorContext } from '../../../core/types/metadata';\nimport type { Controller, IControllerGenerator } from '../../../core/types/controller';\n\nexport class ControllerGenerator implements IControllerGenerator {\n protected readonly node: ClassDeclaration;\n\n protected readonly current: IGeneratorContext;\n\n constructor(node: ClassDeclaration, current: IGeneratorContext) {\n this.node = node;\n this.current = current;\n }\n\n public isValid(): boolean {\n // Whether a class is a controller depends on whether any registry handler\n // matches one of its decorators (e.g. `@Controller`). Resolving that\n // requires running handler dispatch — which `generate()` does — so\n // `isValid()` only screens out unnamed classes here. `generate()` returns\n // `null` when no controller handler claimed the node.\n return !!this.node.name;\n }\n\n public generate(): Controller | null {\n if (!this.node.parent) {\n throw new GeneratorError({\n message: 'Controller node doesn\\'t have a valid parent source file.',\n code: GeneratorErrorCode.CONTROLLER_NO_SOURCE_FILE,\n });\n }\n if (!this.node.name) {\n throw new GeneratorError({\n message: 'Controller node doesn\\'t have a valid name.',\n code: GeneratorErrorCode.CONTROLLER_NO_NAME,\n });\n }\n\n const sourceFile = this.node.parent.getSourceFile();\n const draft = newControllerDraft({\n name: this.node.name.text,\n location: sourceFile.fileName,\n });\n\n const options = this.applyOptions();\n applyDecoratorHandlers(this.node, this.current.registry.controllers, draft, options);\n applyJsDocHandlers(this.node, this.current.registry.controllerJsDoc, draft, options);\n\n // A class is a controller iff a controller-target handler claimed it\n // (convention: the Controller handler sets `draft.paths` to a non-undefined value).\n if (draft.paths === undefined) {\n return null;\n }\n\n // Normalize and dedupe — a user passing `@Controller(['/roles', '/roles'])`\n // (or paths that collide after normalization) shouldn't produce duplicate\n // OpenAPI path keys downstream.\n const normalized = (draft.paths.length === 0 ? [''] : draft.paths).map(normalizePath);\n const paths = [...new Set(normalized)];\n const methods = this.buildMethods(paths);\n\n return {\n consumes: draft.consumes,\n deprecated: draft.deprecated,\n extensions: draft.extensions,\n hidden: draft.hidden,\n location: draft.location,\n name: draft.name,\n paths,\n produces: draft.produces,\n responses: draft.responses,\n security: draft.security,\n tags: draft.tags,\n methods,\n };\n }\n\n private applyOptions(): ApplyHandlersOptions {\n return {\n target: 'class',\n host: { name: this.node.name!.text },\n resolveTypeNode: (n: TypeNode) => new TypeNodeResolver(n, this.current).resolve(),\n typeChecker: this.current.typeChecker,\n onUnmatchedDecorator: (this.current.config.strict || this.current.config.onUnmatchedDecorator) ?\n (report) => this.current.reportUnmatchedDecorator?.(report) :\n undefined,\n };\n }\n\n protected buildMethods(controllerPaths: string[]): Method[] {\n const set = new Set<string>();\n const output: Method[] = [];\n\n // Process own methods first\n for (const member of this.node.members) {\n if (!isMethodDeclaration(member)) {\n continue;\n }\n\n const generator = new MethodGenerator(member, this.current);\n const methodName = generator.getMethodName();\n if (set.has(methodName)) {\n continue;\n }\n\n const method = generator.generate(controllerPaths);\n if (!method) {\n continue;\n }\n set.add(methodName);\n output.push(method);\n }\n\n // Then process inherited methods from base classes\n const inheritedMethods = this.collectInheritedMethodDeclarations(this.node);\n for (const node of inheritedMethods) {\n const generator = new MethodGenerator(node, this.current);\n const methodName = generator.getMethodName();\n if (set.has(methodName)) {\n continue;\n }\n\n try {\n const method = generator.generate(controllerPaths);\n if (!method) {\n continue;\n }\n set.add(methodName);\n output.push(method);\n } catch (error: unknown) {\n // Skip inherited methods that fail due to unresolvable generic\n // type parameters (e.g., return type T or parameter type T from\n // generic base classes). Rethrow everything else.\n if (\n isResolverError(error) ||\n (isGeneratorError(error) &&\n error.code === GeneratorErrorCode.PARAMETER_GENERATION_FAILED)\n ) {\n continue;\n }\n\n throw error;\n }\n }\n\n return output;\n }\n\n private collectInheritedMethodDeclarations(node: ClassDeclaration): MethodDeclaration[] {\n const methods: MethodDeclaration[] = [];\n\n if (!node.heritageClauses) {\n return methods;\n }\n\n for (const clause of node.heritageClauses) {\n if (clause.token !== SyntaxKind.ExtendsKeyword) {\n continue;\n }\n\n for (const type of clause.types) {\n const baseDeclaration = this.resolveBaseClassDeclaration(type.expression);\n if (!baseDeclaration) {\n continue;\n }\n\n // Collect direct methods from the base class\n for (const member of baseDeclaration.members) {\n if (isMethodDeclaration(member)) {\n methods.push(member);\n }\n }\n\n // Recurse to pick up the full inheritance chain\n methods.push(...this.collectInheritedMethodDeclarations(baseDeclaration));\n }\n }\n\n return methods;\n }\n\n private resolveBaseClassDeclaration(expression: Expression): ClassDeclaration | undefined {\n let symbol = this.current.typeChecker.getSymbolAtLocation(expression);\n if (!symbol) {\n return undefined;\n }\n\n // Follow import aliases to the original declaration\n if (symbol.flags & SymbolFlags.Alias) {\n symbol = this.current.typeChecker.getAliasedSymbol(symbol);\n }\n\n const declarations = symbol.getDeclarations();\n if (!declarations || declarations.length === 0) {\n return undefined;\n }\n\n const declaration = declarations[0];\n if (isClassDeclaration(declaration)) {\n return declaration;\n }\n\n return undefined;\n }\n}\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport crypto from 'node:crypto';\nimport { minimatch } from 'minimatch';\nimport type {\n Node,\n Program,\n SourceFile,\n TypeChecker,\n} from 'typescript';\nimport {\n NodeFlags,\n createProgram,\n forEachChild,\n isClassDeclaration,\n isModuleBlock,\n isModuleDeclaration,\n} from 'typescript';\nimport {\n CACHE_SCHEMA_VERSION,\n CacheClient,\n composeCacheKey,\n hashCompilerOptions,\n hashRegistry,\n} from '../../../adapters/cache';\nimport type { MetadataGeneratorOptions } from '../../../core/config';\nimport type { Registry, UnmatchedDecoratorReport } from '../../../adapters/decorator';\nimport {\n createRegistry,\n loadRegistry,\n loadRegistryByName,\n mergeRegistries,\n resolvePresetByName,\n} from '../../../adapters/decorator';\nimport { ConfigError } from '../../../core/error/config';\nimport { ConfigErrorCode } from '../../../core/error/config-codes';\nimport { GeneratorError } from '../../../core/error/generator';\nimport { GeneratorErrorCode } from '../../../core/error/generator-codes';\nimport type { DependencyResolver, ReferenceType, ReferenceTypes } from '../../../core/types/resolver';\nimport { ResolverCache } from '../../../adapters/typescript/resolver/cache';\nimport type { Controller } from '../../../core/types/controller';\nimport { ControllerGenerator } from '../controller';\nimport type {\n IGeneratorContext,\n IMetadataGenerator,\n Metadata,\n MetadataGeneratorContext,\n} from '../../../core/types/metadata';\n\nexport class MetadataGenerator implements IGeneratorContext, IMetadataGenerator {\n public readonly nodes : Node[];\n\n public readonly typeChecker: TypeChecker;\n\n public registry: Registry;\n\n public readonly resolverCache: ResolverCache;\n\n public readonly config: MetadataGeneratorOptions;\n\n private readonly program: Program;\n\n private cache : CacheClient;\n\n private controllers: Controller[];\n\n private referenceTypes: ReferenceTypes = {};\n\n private circularDependencyResolvers = new Array<DependencyResolver>();\n\n private unmatchedDecorators: Map<string, UnmatchedDecoratorReport[]> = new Map();\n\n // -------------------------------------------------------------------------\n\n constructor(context: MetadataGeneratorContext) {\n this.nodes = [];\n this.config = context.options;\n\n this.cache = new CacheClient(context.options.cache);\n this.registry = createRegistry();\n this.resolverCache = new ResolverCache();\n\n this.program = createProgram(\n context.sourceFiles,\n context.compilerOptions || {},\n );\n this.typeChecker = this.program.getTypeChecker();\n }\n\n // -------------------------------------------------------------------------\n\n async generate(): Promise<Metadata> {\n const sourceFilesHash : string = this.buildNodesFromSourceFiles();\n\n // Load the preset upfront so its resolved registry can contribute to\n // the cache key. Otherwise edits to a local preset (or upgrades that\n // share a name) would silently serve stale metadata.\n let presetRegistry: Registry | undefined;\n let presetName: string | undefined;\n if (typeof this.config.preset === 'string') {\n presetName = this.config.preset;\n presetRegistry = await loadRegistryByName(this.config.preset);\n } else if (this.config.preset) {\n presetName = this.config.preset.name;\n presetRegistry = await loadRegistry(this.config.preset, { resolver: resolvePresetByName });\n }\n\n if (presetRegistry && this.config.registry) {\n this.registry = mergeRegistries(presetRegistry, this.config.registry);\n } else if (presetRegistry) {\n this.registry = presetRegistry;\n } else if (this.config.registry) {\n this.registry = this.config.registry;\n }\n\n const cacheKey = composeCacheKey({\n schemaVersion: CACHE_SCHEMA_VERSION,\n sourceFilesHash,\n compilerOptionsHash: hashCompilerOptions(this.program.getCompilerOptions()),\n registryHash: hashRegistry(this.registry),\n presetName,\n });\n\n // Strict reporting requires handler dispatch to actually run. A cache hit\n // would skip it and silently swallow unmatched-decorator reports.\n const bypassCache = !!(this.config.strict || this.config.onUnmatchedDecorator);\n\n let cache = bypassCache ?\n undefined :\n await this.cache.get(cacheKey);\n\n if (!cache) {\n this.buildControllers();\n\n this.assertPresetProducedControllers();\n\n this.circularDependencyResolvers.forEach((resolve) => resolve(this.referenceTypes));\n\n cache = {\n controllers: this.controllers,\n referenceTypes: this.referenceTypes,\n cacheKey,\n schemaVersion: CACHE_SCHEMA_VERSION,\n };\n\n if (!bypassCache) {\n await this.cache.save(cache);\n }\n }\n\n if (this.config.strict || this.config.onUnmatchedDecorator) {\n this.dispatchUnmatchedDecoratorReports();\n }\n\n return {\n controllers: cache.controllers,\n referenceTypes: cache.referenceTypes,\n };\n }\n\n private assertPresetProducedControllers(): void {\n if (this.config.preset || this.config.registry || this.controllers.length > 0) {\n return;\n }\n // Only fault a missing preset when we actually scanned source files —\n // an empty entry point is a different misconfiguration that shouldn't\n // surface as a preset error.\n if (this.nodes.length === 0) {\n return;\n }\n throw new ConfigError({\n message: 'No preset or registry configured and no controllers detected. Provide `preset: \\'@trapi/preset-decorators-express\\'` (or another preset), or pass an inline `registry`, so handlers can match your decorators.',\n code: ConfigErrorCode.PRESET_MISSING,\n });\n }\n\n public reportUnmatchedDecorator(report: UnmatchedDecoratorReport): void {\n const key = `${report.target}:${report.name}`;\n const existing = this.unmatchedDecorators.get(key);\n if (existing) {\n existing.push(report);\n return;\n }\n this.unmatchedDecorators.set(key, [report]);\n }\n\n private dispatchUnmatchedDecoratorReports(): void {\n if (this.unmatchedDecorators.size === 0) {\n return;\n }\n\n const flat: UnmatchedDecoratorReport[] = [];\n for (const reports of this.unmatchedDecorators.values()) {\n flat.push(...reports);\n }\n\n // User-supplied callback short-circuits the default warn/throw path.\n if (this.config.onUnmatchedDecorator) {\n this.config.onUnmatchedDecorator(flat);\n return;\n }\n\n const summary = this.formatUnmatchedSummary();\n\n if (this.config.strict === 'throw') {\n throw new GeneratorError({\n message: summary,\n code: GeneratorErrorCode.STRICT_UNMATCHED_DECORATORS,\n });\n }\n\n // eslint-disable-next-line no-console\n console.warn(summary);\n }\n\n private formatUnmatchedSummary(): string {\n const lines: string[] = ['[trapi] strict mode: decorators with no matching handler:'];\n for (const reports of this.unmatchedDecorators.values()) {\n const first = reports[0];\n const occurrences = reports.length;\n const location = `${first.file}:${first.line}`;\n const suffix = occurrences > 1 ?\n ` (${occurrences} occurrences; first at ${location})` :\n ` (${location})`;\n lines.push(` - @${first.name} on ${first.target} '${first.host.name}'${suffix}`);\n }\n return lines.join('\\n');\n }\n\n protected buildNodesFromSourceFiles() : string {\n const hash = crypto.createHash('sha256');\n\n this.program.getSourceFiles().forEach((sf: SourceFile) => {\n if (\n this.isIgnoredPath(sf.fileName) &&\n !this.isAllowedPath(sf.fileName)\n ) {\n return;\n }\n\n // Hash the file path alongside its contents so that renames or\n // reordered identical files invalidate the cache. The null byte is\n // a safe separator since it cannot appear in a path or source.\n hash.update(sf.fileName);\n hash.update('\\0');\n hash.update(sf.text);\n hash.update('\\0');\n\n forEachChild(sf, (node: any) => {\n if (isModuleDeclaration(node)) {\n /**\n * For some reason unknown to me, TS resolves both `declare module` and `namespace` to\n * the same kind (`ModuleDeclaration`). In order to figure out whether it's one or the other,\n * we check the node flags. They tell us whether it is a namespace or not.\n */\n\n // tslint:disable-next-line:no-bitwise\n if ((node.flags & NodeFlags.Namespace) === 0 && node.body && isModuleBlock(node.body)) {\n node.body.statements.forEach((statement) => {\n this.nodes.push(statement);\n });\n return;\n }\n }\n\n this.nodes.push(node);\n });\n });\n\n return hash.digest('hex');\n }\n\n // -------------------------------------------------------------------------\n\n /**\n * Check if the source file path is in the ignored path list.\n *\n * @param filePath\n * @protected\n */\n protected isIgnoredPath(filePath: string) : boolean {\n if (typeof this.config.ignore === 'undefined') {\n return false;\n }\n\n return this.config.ignore.some((item) => minimatch(filePath, item));\n }\n\n /**\n * Check if the source file path is in the ignored path list.\n *\n * @param filePath\n * @protected\n */\n protected isAllowedPath(filePath: string) {\n if (typeof this.config.allow === 'undefined') {\n return false;\n }\n\n return this.config.allow.some((item) => minimatch(filePath, item));\n }\n\n // -------------------------------------------------------------------------\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public isExportedNode(_node: Node) {\n return true;\n }\n\n // -------------------------------------------------------------------------\n\n public addReferenceType(referenceType: ReferenceType) {\n if (!referenceType.refName) {\n return;\n }\n\n this.referenceTypes[referenceType.refName] = referenceType;\n }\n\n public getReferenceType(refName: string) {\n return this.referenceTypes[refName];\n }\n\n public registerDependencyResolver(callback: DependencyResolver) {\n this.circularDependencyResolvers.push(callback);\n }\n\n private buildControllers() : void {\n this.controllers = [];\n\n for (let i = 0; i < this.nodes.length; i++) {\n const node = this.nodes[i];\n if (!isClassDeclaration(node)) {\n continue;\n }\n\n const generator = new ControllerGenerator(node, this);\n if (!generator.isValid()) {\n continue;\n }\n\n const controller = generator.generate();\n if (controller) {\n this.controllers.push(controller);\n }\n }\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty, isObject } from 'locter';\nimport type { Metadata } from '../../../core/index.ts';\n\nexport function isMetadata(input: unknown) : input is Metadata {\n return isObject(input) &&\n hasOwnProperty(input, 'controllers') &&\n Array.isArray(input.controllers) &&\n hasOwnProperty(input, 'referenceTypes') &&\n isObject(input.referenceTypes);\n}\n","/*\n * Copyright (c) 2021-2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { CompilerOptions } from 'typescript';\nimport type { MetadataGenerateOptions } from '../core/config';\nimport type { Metadata } from '../core/types/metadata';\nimport { MetadataGenerator } from './generator/metadata';\nimport { scanSourceFiles } from '../adapters/filesystem';\nimport { softLoadTsconfig } from '../adapters/filesystem/tsconfig';\n\nexport async function generateMetadata(\n options: MetadataGenerateOptions,\n) : Promise<Metadata> {\n let compilerOptions : CompilerOptions | undefined;\n\n if (options.tsconfig) {\n let { tsconfig } = options;\n if (typeof tsconfig === 'string') {\n tsconfig = await softLoadTsconfig({ name: tsconfig });\n compilerOptions = tsconfig.compilerOptions;\n } else {\n compilerOptions = tsconfig.compilerOptions || {};\n }\n }\n\n const sourceFiles = await scanSourceFiles(options.entryPoint);\n\n const generator = new MetadataGenerator({\n sourceFiles,\n compilerOptions,\n options,\n });\n\n return generator.generate();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,IAAY,WAAL,yBAAA,UAAA;AACH,UAAA,YAAA;AACA,UAAA,aAAA;AACA,UAAA,YAAA;AACA,UAAA,YAAA;AACA,UAAA,WAAA;AACA,UAAA,UAAA;AACA,UAAA,aAAA;AACA,UAAA,UAAA;AACA,UAAA,UAAA;AACA,UAAA,WAAA;AACA,UAAA,cAAA;AACA,UAAA,UAAA;AACA,UAAA,YAAA;AACA,UAAA,YAAA;AACA,UAAA,UAAA;AACA,UAAA,UAAA;AACA,UAAA,YAAA;AACA,UAAA,SAAA;AACA,UAAA,eAAA;AACA,UAAA,WAAA;AACA,UAAA,cAAA;AACA,UAAA,gBAAA;AACA,UAAA,eAAA;AACA,UAAA,2BAAA;AACA,UAAA,WAAA;AACA,UAAA,kBAAA;AACA,UAAA,WAAA;;KACH;AAED,IAAY,kBAAL,yBAAA,iBAAA;AACH,iBAAA,kBAAA;AACA,iBAAA,UAAA;AACA,iBAAA,aAAA;AACA,iBAAA,cAAA;AACA,iBAAA,YAAA;AACA,iBAAA,cAAA;AACA,iBAAA,UAAA;AAEA,iBAAA,aAAA;AACA,iBAAA,aAAA;AACA,iBAAA,iBAAA;AACA,iBAAA,gBAAA;AACA,iBAAA,aAAA;AACA,iBAAA,mBAAA;AACA,iBAAA,4BAAA;;KACH;;;ACRD,SAAgB,UAAU,OAAmC;AACzD,QAAO,MAAM,aAAA;;AAGjB,SAAgB,gBAAgB,OAAyC;AACrE,QAAO,MAAM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