adorn-api 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -2
- package/dist/adapter/express/bootstrap.d.ts +1 -0
- package/dist/adapter/express/bootstrap.d.ts.map +1 -1
- package/dist/adapter/express/index.d.ts +11 -0
- package/dist/adapter/express/index.d.ts.map +1 -1
- package/dist/cli.cjs +141 -34
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +140 -33
- package/dist/cli.js.map +1 -1
- package/dist/compiler/analyze/extractQueryStyle.d.ts +8 -0
- package/dist/compiler/analyze/extractQueryStyle.d.ts.map +1 -0
- package/dist/compiler/manifest/emit.d.ts.map +1 -1
- package/dist/compiler/schema/openapi.d.ts.map +1 -1
- package/dist/compiler/schema/typeToJsonSchema.d.ts.map +1 -1
- package/dist/express.cjs +327 -60
- package/dist/express.cjs.map +1 -1
- package/dist/express.js +327 -60
- package/dist/express.js.map +1 -1
- package/dist/http.d.ts +4 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/index.cjs +7 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/metal/index.d.ts +1 -0
- package/dist/metal/index.d.ts.map +1 -1
- package/dist/metal/searchWhere.d.ts +42 -0
- package/dist/metal/searchWhere.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/compiler/runner/createProgram.ts","../src/compiler/analyze/scanControllers.ts","../src/utils/operationId.ts","../src/compiler/schema/openapi.ts","../src/compiler/schema/typeToJsonSchema.ts","../src/compiler/schema/extractAnnotations.ts","../src/compiler/manifest/emit.ts","../src/compiler/validation/emitPrecompiledValidators.ts","../src/compiler/cache/isStale.ts","../src/compiler/cache/writeCache.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { writeFileSync, mkdirSync, rmSync, existsSync, readFileSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\nimport { createProgramFromConfig } from \"./compiler/runner/createProgram.js\";\nimport { scanControllers } from \"./compiler/analyze/scanControllers.js\";\nimport { generateOpenAPI } from \"./compiler/schema/openapi.js\";\nimport { generateManifest } from \"./compiler/manifest/emit.js\";\nimport { emitPrecompiledValidators } from \"./compiler/validation/emitPrecompiledValidators.js\";\nimport { isStale } from \"./compiler/cache/isStale.js\";\nimport { writeCache } from \"./compiler/cache/writeCache.js\";\nimport ts from \"typescript\";\nimport process from \"node:process\";\n\nconst ADORN_VERSION = \"0.1.0\";\n\ntype ValidationMode = \"none\" | \"ajv-runtime\" | \"precompiled\";\n\nfunction log(msg: string) {\n process.stdout.write(msg + \"\\n\");\n}\n\nfunction debug(...args: unknown[]) {\n if (process.env.ADORN_DEBUG) {\n console.error(\"[adorn-api]\", ...args);\n }\n}\n\nasync function buildCommand(args: string[]) {\n const projectIndex = args.indexOf(\"-p\");\n const projectPath = projectIndex !== -1 ? args[projectIndex + 1] : \"./tsconfig.json\";\n const outputDir = args.includes(\"--output\")\n ? args[args.indexOf(\"--output\") + 1]\n : \".adorn\";\n const ifStale = args.includes(\"--if-stale\");\n \n const validationModeIndex = args.indexOf(\"--validation-mode\");\n const validationMode: ValidationMode = validationModeIndex !== -1 \n ? (args[validationModeIndex + 1] as ValidationMode) \n : \"ajv-runtime\";\n\n if (validationMode !== \"none\" && validationMode !== \"ajv-runtime\" && validationMode !== \"precompiled\") {\n console.error(`Invalid validation mode: ${validationMode}. Valid values: none, ajv-runtime, precompiled`);\n process.exit(1);\n }\n\n const outputPath = resolve(outputDir);\n\n if (ifStale) {\n const stale = await isStale({\n outDir: outputDir,\n project: projectPath,\n adornVersion: ADORN_VERSION,\n typescriptVersion: ts.version\n });\n\n if (!stale.stale) {\n log(\"adorn-api: artifacts up-to-date\");\n return;\n }\n\n log(`adorn-api: building artifacts (reason: ${stale.reason}${stale.detail ? `: ${stale.detail}` : \"\"})`);\n debug(\"Stale detail:\", stale.detail);\n } else {\n log(\"adorn-api: building artifacts (reason: forced-build)\");\n }\n\n const { program, checker, sourceFiles } = createProgramFromConfig(projectPath);\n const controllers = scanControllers(sourceFiles, checker);\n\n if (controllers.length === 0) {\n console.warn(\"No controllers found!\");\n process.exit(1);\n }\n\n log(`Found ${controllers.length} controller(s)`);\n\n const openapi = generateOpenAPI(controllers, checker, { title: \"API\", version: \"1.0.0\" });\n const manifest = generateManifest(controllers, checker, ADORN_VERSION, validationMode);\n\n mkdirSync(outputPath, { recursive: true });\n\n writeFileSync(resolve(outputPath, \"openapi.json\"), JSON.stringify(openapi, null, 2));\n writeFileSync(resolve(outputPath, \"manifest.json\"), JSON.stringify(manifest, null, 2));\n\n if (validationMode === \"precompiled\") {\n log(\"Generating precompiled validators...\");\n \n const manifestObj = JSON.parse(readFileSync(resolve(outputPath, \"manifest.json\"), \"utf-8\"));\n \n await emitPrecompiledValidators({\n outDir: outputPath,\n openapi,\n manifest: manifestObj,\n strict: \"off\",\n formatsMode: \"full\"\n });\n\n manifestObj.validation = {\n mode: \"precompiled\",\n precompiledModule: \"./validators.mjs\"\n };\n \n writeFileSync(resolve(outputPath, \"manifest.json\"), JSON.stringify(manifestObj, null, 2));\n \n log(\" - validators.cjs\");\n log(\" - validators.mjs\");\n log(\" - validators.meta.json\");\n }\n\n writeCache({\n outDir: outputDir,\n tsconfigAbs: resolve(projectPath),\n program,\n adornVersion: ADORN_VERSION\n });\n\n log(`Written to ${outputPath}/`);\n log(\" - openapi.json\");\n log(\" - manifest.json\");\n log(\" - cache.json\");\n}\n\nfunction cleanCommand(args: string[]) {\n const outputDir = args.includes(\"--output\")\n ? args[args.indexOf(\"--output\") + 1]\n : \".adorn\";\n\n const outputPath = resolve(outputDir);\n\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true });\n }\n\n log(`adorn-api: cleaned ${outputDir}`);\n}\n\nconst command = process.argv[2];\n\nif (command === \"build\") {\n buildCommand(process.argv.slice(3)).catch((err) => {\n console.error(err);\n process.exit(1);\n });\n} else if (command === \"clean\") {\n cleanCommand(process.argv.slice(3));\n} else {\n console.log(`\nadorn-api CLI\n\nCommands:\n build Generate OpenAPI and manifest from TypeScript source\n clean Remove generated artifacts\n\nOptions:\n -p <path> Path to tsconfig.json (default: ./tsconfig.json)\n --output <dir> Output directory (default: .adorn)\n --if-stale Only rebuild if artifacts are stale\n --validation-mode <mode> Validation mode: none, ajv-runtime, precompiled (default: ajv-runtime)\n\nExamples:\n adorn-api build -p ./tsconfig.json --output .adorn\n adorn-api build --if-stale\n adorn-api build --validation-mode precompiled\n adorn-api clean\n `);\n}\n","import ts from \"typescript\";\nimport { readFileSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\n\nexport interface ProgramContext {\n program: ts.Program;\n checker: ts.TypeChecker;\n sourceFiles: ts.SourceFile[];\n}\n\nexport function createProgramFromConfig(tsconfigPath: string): ProgramContext {\n const absolutePath = resolve(tsconfigPath);\n const configDir = dirname(absolutePath);\n\n const configFile = ts.readConfigFile(absolutePath, (path) => readFileSync(path, \"utf-8\"));\n if (configFile.error) {\n throw new Error(`Failed to read tsconfig: ${ts.flattenDiagnosticMessageText(configFile.error.messageText, \"\\n\")}`);\n }\n\n const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, configDir);\n if (parsed.errors.length > 0) {\n const messages = parsed.errors.map(e => ts.flattenDiagnosticMessageText(e.messageText, \"\\n\"));\n throw new Error(`Failed to parse tsconfig:\\n${messages.join(\"\\n\")}`);\n }\n\n const program = ts.createProgram(parsed.fileNames, parsed.options);\n const checker = program.getTypeChecker();\n\n const sourceFiles = program.getSourceFiles().filter(sf =>\n !sf.isDeclarationFile &&\n !sf.fileName.includes(\"node_modules\")\n );\n\n return { program, checker, sourceFiles };\n}\n","import ts from \"typescript\";\nimport { defaultOperationId } from \"../../utils/operationId.js\";\n\nexport interface ScannedController {\n className: string;\n basePath: string;\n sourceFile: ts.SourceFile;\n classDeclaration: ts.ClassDeclaration;\n operations: ScannedOperation[];\n consumes?: string[];\n produces?: string[];\n}\n\nexport interface ScannedOperation {\n methodName: string;\n httpMethod: string;\n path: string;\n operationId: string;\n methodDeclaration: ts.MethodDeclaration;\n returnType: ts.Type;\n parameters: ScannedParameter[];\n pathParamIndices: number[];\n bodyParamIndex: number | null;\n queryParamIndices: number[];\n queryObjectParamIndex: number | null;\n headerObjectParamIndex: number | null;\n cookieObjectParamIndex: number | null;\n bodyContentType?: string;\n}\n\nexport interface ScannedParameter {\n name: string;\n index: number;\n type: ts.Type;\n isOptional: boolean;\n paramNode?: ts.ParameterDeclaration;\n}\n\nexport function scanControllers(\n sourceFiles: ts.SourceFile[],\n checker: ts.TypeChecker\n): ScannedController[] {\n const controllers: ScannedController[] = [];\n\n for (const sourceFile of sourceFiles) {\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isClassDeclaration(node) && node.name) {\n const controller = analyzeClass(node, sourceFile, checker);\n if (controller) {\n controllers.push(controller);\n }\n }\n });\n }\n\n return controllers;\n}\n\nfunction analyzeClass(\n node: ts.ClassDeclaration,\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker\n): ScannedController | null {\n if (!node.name) return null;\n\n const controllerDecorator = findDecorator(node, \"Controller\");\n if (!controllerDecorator) return null;\n\n const basePath = extractDecoratorStringArg(controllerDecorator) ?? \"/\";\n const className = node.name.text;\n\n const consumes = extractClassConsumes(node, checker);\n const produces = extractClassProduces(node, checker);\n\n const operations: ScannedOperation[] = [];\n\n for (const member of node.members) {\n if (ts.isMethodDeclaration(member) && member.name) {\n const operation = analyzeMethod(member, className, checker);\n if (operation) {\n operations.push(operation);\n }\n }\n }\n\n if (operations.length === 0) return null;\n\n return {\n className,\n basePath,\n sourceFile,\n classDeclaration: node,\n operations,\n consumes,\n produces,\n };\n}\n\nfunction extractClassConsumes(node: ts.ClassDeclaration, checker: ts.TypeChecker): string[] | undefined {\n const decorator = findDecorator(node, \"Consumes\");\n if (!decorator) return undefined;\n\n const callExpr = decorator.expression;\n if (!ts.isCallExpression(callExpr)) return undefined;\n const args = callExpr.arguments;\n if (args.length === 0) return undefined;\n\n const firstArg = args[0];\n if (ts.isStringLiteral(firstArg)) {\n return [firstArg.text];\n }\n if (ts.isArrayLiteralExpression(firstArg)) {\n return firstArg.elements\n .filter(ts.isStringLiteral)\n .map(e => e.text);\n }\n return undefined;\n}\n\nfunction extractClassProduces(node: ts.ClassDeclaration, checker: ts.TypeChecker): string[] | undefined {\n const decorator = findDecorator(node, \"Produces\");\n if (!decorator) return undefined;\n\n const callExpr = decorator.expression;\n if (!ts.isCallExpression(callExpr)) return undefined;\n const args = callExpr.arguments;\n if (args.length === 0) return undefined;\n\n const firstArg = args[0];\n if (ts.isStringLiteral(firstArg)) {\n return [firstArg.text];\n }\n if (ts.isArrayLiteralExpression(firstArg)) {\n return firstArg.elements\n .filter(ts.isStringLiteral)\n .map(e => e.text);\n }\n return undefined;\n}\n\nfunction analyzeMethod(\n node: ts.MethodDeclaration,\n className: string,\n checker: ts.TypeChecker\n): ScannedOperation | null {\n const methodName = ts.isIdentifier(node.name) ? node.name.text : null;\n if (!methodName) return null;\n\n const httpMethods = [\"Get\", \"Post\", \"Put\", \"Patch\", \"Delete\"];\n let httpMethod: string | null = null;\n let path = \"/\";\n\n for (const method of httpMethods) {\n const decorator = findDecorator(node, method);\n if (decorator) {\n httpMethod = method.toUpperCase();\n path = extractDecoratorStringArg(decorator) ?? \"/\";\n break;\n }\n }\n\n if (!httpMethod) return null;\n\n const signature = checker.getSignatureFromDeclaration(node);\n if (!signature) return null;\n\n let returnType = checker.getReturnTypeOfSignature(signature);\n returnType = unwrapPromise(returnType, checker);\n\n const parameters: ScannedParameter[] = [];\n for (let i = 0; i < node.parameters.length; i++) {\n const param = node.parameters[i];\n const paramName = ts.isIdentifier(param.name) ? param.name.text : `arg${i}`;\n const paramType = checker.getTypeAtLocation(param);\n const isOptional = !!param.questionToken || !!param.initializer;\n\n parameters.push({\n name: paramName,\n index: i,\n type: paramType,\n isOptional,\n paramNode: param,\n });\n }\n\n const pathParamNames = extractPathParams(path);\n const pathParamIndices = matchPathParamsToIndices(pathParamNames, parameters);\n \n const { bodyParamIndex, queryParamIndices, queryObjectParamIndex, headerObjectParamIndex, cookieObjectParamIndex, bodyContentType } = \n classifyParameters(parameters, httpMethod, pathParamIndices, checker);\n\n return {\n methodName,\n httpMethod,\n path,\n operationId: defaultOperationId(className, methodName),\n methodDeclaration: node,\n returnType,\n parameters,\n pathParamIndices,\n bodyParamIndex,\n queryParamIndices,\n queryObjectParamIndex,\n headerObjectParamIndex,\n cookieObjectParamIndex,\n bodyContentType,\n };\n}\n\nfunction extractPathParams(path: string): string[] {\n const matches = path.match(/:([^/]+)/g);\n if (!matches) return [];\n return matches.map(m => m.slice(1));\n}\n\nfunction matchPathParamsToIndices(pathParamNames: string[], parameters: ScannedParameter[]): number[] {\n const indices: number[] = [];\n for (const name of pathParamNames) {\n const param = parameters.find(p => p.name === name);\n if (param) {\n indices.push(param.index);\n }\n }\n return indices;\n}\n\nfunction classifyParameters(\n parameters: ScannedParameter[],\n httpMethod: string,\n pathParamIndices: number[],\n checker: ts.TypeChecker\n): {\n bodyParamIndex: number | null;\n queryParamIndices: number[];\n queryObjectParamIndex: number | null;\n headerObjectParamIndex: number | null;\n cookieObjectParamIndex: number | null;\n bodyContentType: string | undefined;\n} {\n const usedIndices = new Set(pathParamIndices);\n const queryParamIndices: number[] = [];\n let bodyParamIndex: number | null = null;\n let queryObjectParamIndex: number | null = null;\n let headerObjectParamIndex: number | null = null;\n let cookieObjectParamIndex: number | null = null;\n\n const isBodyMethod = [\"POST\", \"PUT\", \"PATCH\"].includes(httpMethod);\n\n for (let i = 0; i < parameters.length; i++) {\n const param = parameters[i];\n if (usedIndices.has(i)) continue;\n\n const typeStr = param.type.getSymbol()?.getName() ?? \"\";\n\n if (typeStr === \"Body\") {\n bodyParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n if (typeStr === \"Query\") {\n queryObjectParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n if (typeStr === \"Headers\") {\n headerObjectParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n if (typeStr === \"Cookies\") {\n cookieObjectParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n if (isBodyMethod && bodyParamIndex === null) {\n bodyParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n const isObj = isObjectType(param.type, checker);\n if (isObj && queryObjectParamIndex === null && !isBodyMethod) {\n queryObjectParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n queryParamIndices.push(i);\n usedIndices.add(i);\n }\n\n return {\n bodyParamIndex,\n queryParamIndices,\n queryObjectParamIndex,\n headerObjectParamIndex,\n cookieObjectParamIndex,\n bodyContentType: undefined,\n };\n}\n\nfunction isObjectType(type: ts.Type, checker: ts.TypeChecker): boolean {\n const objectFlags = (type.flags & ts.TypeFlags.Object) !== 0;\n if (!objectFlags) return false;\n\n const symbol = type.getSymbol();\n if (symbol?.getName() === \"__object\") return true;\n\n const properties = checker.getPropertiesOfType(type);\n if (properties.length > 0) return true;\n\n const callSignatures = type.getCallSignatures();\n if (callSignatures && callSignatures.length > 0) return false;\n\n return true;\n}\n\nfunction findDecorator(node: ts.HasDecorators, name: string): ts.Decorator | null {\n const decorators = ts.getDecorators(node);\n if (!decorators) return null;\n\n for (const decorator of decorators) {\n if (ts.isCallExpression(decorator.expression)) {\n const expr = decorator.expression.expression;\n if (ts.isIdentifier(expr) && expr.text === name) {\n return decorator;\n }\n }\n }\n return null;\n}\n\nfunction extractDecoratorStringArg(decorator: ts.Decorator): string | null {\n if (ts.isCallExpression(decorator.expression)) {\n const arg = decorator.expression.arguments[0];\n if (arg && ts.isStringLiteral(arg)) {\n return arg.text;\n }\n }\n return null;\n}\n\nfunction unwrapPromise(type: ts.Type, checker: ts.TypeChecker): ts.Type {\n const symbol = type.getSymbol();\n if (symbol?.getName() === \"Promise\") {\n const typeArgs = (type as ts.TypeReference).typeArguments;\n if (typeArgs && typeArgs.length > 0) {\n return typeArgs[0];\n }\n }\n return type;\n}\n","export function defaultOperationId(controllerName: string, methodName: string): string {\n return `${controllerName}_${methodName}`;\n}\n","import ts from \"typescript\";\nimport type { ScannedController, ScannedOperation, ScannedParameter } from \"../analyze/scanControllers.js\";\nimport { typeToJsonSchema, createSchemaContext } from \"./typeToJsonSchema.js\";\nimport { extractPropertySchemaFragments, mergeFragments } from \"./extractAnnotations.js\";\nimport type { SchemaContext, JsonSchema } from \"./typeToJsonSchema.js\";\n\nexport interface OpenAPI31 {\n openapi: \"3.1.0\";\n info: {\n title: string;\n version: string;\n };\n components: {\n schemas: Record<string, JsonSchema>;\n };\n paths: Record<string, Record<string, any>>;\n}\n\nexport function generateOpenAPI(\n controllers: ScannedController[],\n checker: ts.TypeChecker,\n options: { title?: string; version?: string } = {}\n): OpenAPI31 {\n const components = new Map<string, JsonSchema>();\n const ctx: SchemaContext = {\n checker,\n components,\n typeStack: new Set(),\n typeNameStack: [],\n };\n\n const paths: Record<string, Record<string, any>> = {};\n\n for (const controller of controllers) {\n for (const operation of controller.operations) {\n const fullPath = convertToOpenApiPath(controller.basePath, operation.path);\n\n if (!paths[fullPath]) {\n paths[fullPath] = {};\n }\n\n const method = operation.httpMethod.toLowerCase();\n paths[fullPath][method] = buildOperation(operation, ctx, controller.consumes);\n }\n }\n\n return {\n openapi: \"3.1.0\",\n info: {\n title: options.title ?? \"API\",\n version: options.version ?? \"1.0.0\",\n },\n components: {\n schemas: Object.fromEntries(components),\n },\n paths,\n };\n}\n\nfunction convertToOpenApiPath(basePath: string, path: string): string {\n const base = basePath.endsWith(\"/\") ? basePath.slice(0, -1) : basePath;\n const converted = path.replace(/:([^/]+)/g, \"{$1}\");\n return base + converted || \"/\";\n}\n\nfunction buildOperation(operation: ScannedOperation, ctx: SchemaContext, controllerConsumes?: string[]): any {\n const op: any = {\n operationId: operation.operationId,\n responses: {},\n };\n\n const parameters: any[] = [];\n\n buildPathParameters(operation, ctx, parameters);\n buildQueryParameters(operation, ctx, parameters);\n buildHeaderParameters(operation, ctx, parameters);\n buildCookieParameters(operation, ctx, parameters);\n\n if (parameters.length > 0) {\n op.parameters = parameters;\n }\n\n const responseSchema = typeToJsonSchema(operation.returnType, ctx);\n\n const status = operation.httpMethod === \"POST\" ? 201 : 200;\n op.responses[status] = {\n description: status === 201 ? \"Created\" : \"OK\",\n content: {\n \"application/json\": {\n schema: responseSchema,\n },\n },\n };\n\n if ([\"POST\", \"PUT\", \"PATCH\"].includes(operation.httpMethod) && operation.bodyParamIndex !== null) {\n const bodyParam = operation.parameters[operation.bodyParamIndex];\n if (bodyParam) {\n let bodySchema = typeToJsonSchema(bodyParam.type, ctx);\n bodySchema = mergeBodySchemaAnnotations(bodyParam, ctx, bodySchema);\n \n const contentType = operation.bodyContentType ?? controllerConsumes?.[0] ?? \"application/json\";\n \n const requestBody: any = {\n required: !bodyParam.isOptional,\n content: {},\n };\n\n if (contentType === \"multipart/form-data\") {\n requestBody.content[\"multipart/form-data\"] = {\n schema: bodySchema,\n };\n } else {\n requestBody.content[contentType] = {\n schema: bodySchema,\n };\n }\n\n op.requestBody = requestBody;\n }\n }\n\n return op;\n}\n\nfunction mergeBodySchemaAnnotations(\n bodyParam: ScannedParameter,\n ctx: SchemaContext,\n schema: JsonSchema\n): JsonSchema {\n if (!schema.properties) return schema;\n\n const typeSymbol = bodyParam.type.getSymbol();\n if (!typeSymbol) return schema;\n\n const declarations = typeSymbol.getDeclarations();\n if (!declarations || declarations.length === 0) return schema;\n\n const classDecl = declarations[0];\n if (!ts.isClassDeclaration(classDecl)) return schema;\n\n const result = { ...schema };\n const props = { ...result.properties as Record<string, JsonSchema> };\n\n for (const member of classDecl.members) {\n if (!ts.isPropertyDeclaration(member) || !member.name) continue;\n\n const propName = ts.isIdentifier(member.name) ? member.name.text : null;\n if (!propName) continue;\n if (!props[propName]) continue;\n\n const frags = extractPropertySchemaFragments(ctx.checker, member);\n if (frags.length > 0) {\n props[propName] = mergeFragments(props[propName] as Record<string, unknown>, ...frags) as JsonSchema;\n }\n }\n\n result.properties = props;\n return result;\n}\n\nfunction buildPathParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void {\n for (const paramIndex of operation.pathParamIndices) {\n const param = operation.parameters[paramIndex];\n if (param) {\n let paramSchema = typeToJsonSchema(param.type, ctx);\n if (param.paramNode) {\n const frags = extractPropertySchemaFragments(ctx.checker, param.paramNode);\n if (frags.length > 0) {\n paramSchema = mergeFragments(paramSchema as Record<string, unknown>, ...frags) as JsonSchema;\n }\n }\n parameters.push({\n name: param.name,\n in: \"path\",\n required: !param.isOptional,\n schema: paramSchema.$ref\n ? { type: \"string\", $ref: paramSchema.$ref }\n : paramSchema,\n });\n }\n }\n}\n\nfunction buildQueryParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void {\n if (operation.queryObjectParamIndex !== null) {\n const queryParam = operation.parameters[operation.queryObjectParamIndex];\n if (!queryParam) return;\n\n const querySchema = typeToJsonSchema(queryParam.type, ctx);\n if (!querySchema.properties) return;\n\n const queryObjProps = querySchema.properties;\n for (const [propName, propSchema] of Object.entries(queryObjProps as Record<string, any>)) {\n const isRequired = querySchema.required?.includes(propName) ?? false;\n const serialization = determineQuerySerialization(propSchema.type);\n parameters.push({\n name: propName,\n in: \"query\",\n required: isRequired,\n schema: propSchema,\n ...(Object.keys(serialization).length > 0 ? serialization : {}),\n });\n }\n }\n\n for (const paramIndex of operation.queryParamIndices) {\n const param = operation.parameters[paramIndex];\n if (param) {\n let paramSchema = typeToJsonSchema(param.type, ctx);\n if (param.paramNode) {\n const frags = extractPropertySchemaFragments(ctx.checker, param.paramNode);\n if (frags.length > 0) {\n paramSchema = mergeFragments(paramSchema as Record<string, unknown>, ...frags) as JsonSchema;\n }\n }\n const serialization = determineQuerySerialization(paramSchema.type);\n parameters.push({\n name: param.name,\n in: \"query\",\n required: !param.isOptional,\n schema: paramSchema.$ref\n ? { type: \"string\", $ref: paramSchema.$ref }\n : paramSchema,\n ...(Object.keys(serialization).length > 0 ? serialization : {}),\n });\n }\n }\n}\n\nfunction determineQuerySerialization(schemaType: string | string[] | undefined): { style?: string; explode?: boolean } {\n const typeArray = Array.isArray(schemaType) ? schemaType : schemaType ? [schemaType] : [];\n const isArray = typeArray.includes(\"array\");\n \n if (isArray) {\n return { style: \"form\", explode: true };\n }\n \n return {};\n}\n\nfunction buildHeaderParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void {\n if (operation.headerObjectParamIndex === null) return;\n\n const headerParam = operation.parameters[operation.headerObjectParamIndex];\n if (!headerParam) return;\n\n const headerSchema = typeToJsonSchema(headerParam.type, ctx);\n if (!headerSchema.properties) return;\n\n const headerObjProps = headerSchema.properties;\n for (const [propName, propSchema] of Object.entries(headerObjProps as Record<string, any>)) {\n const isRequired = headerSchema.required?.includes(propName) ?? false;\n parameters.push({\n name: propName,\n in: \"header\",\n required: isRequired,\n schema: propSchema,\n });\n }\n}\n\nfunction buildCookieParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void {\n if (operation.cookieObjectParamIndex === null) return;\n\n const cookieParam = operation.parameters[operation.cookieObjectParamIndex];\n if (!cookieParam) return;\n\n const cookieSchema = typeToJsonSchema(cookieParam.type, ctx);\n if (!cookieSchema.properties) return;\n\n const cookieObjProps = cookieSchema.properties;\n for (const [propName, propSchema] of Object.entries(cookieObjProps as Record<string, any>)) {\n const isRequired = cookieSchema.required?.includes(propName) ?? false;\n parameters.push({\n name: propName,\n in: \"cookie\",\n required: isRequired,\n schema: propSchema,\n style: \"form\",\n explode: true,\n });\n }\n}\n","import ts from \"typescript\";\n\nexport interface JsonSchema {\n type?: string | string[];\n properties?: Record<string, JsonSchema>;\n required?: string[];\n items?: JsonSchema;\n enum?: (string | number | boolean)[];\n $ref?: string;\n nullable?: boolean;\n description?: string;\n default?: unknown;\n examples?: unknown[];\n example?: unknown;\n anyOf?: JsonSchema[];\n oneOf?: JsonSchema[];\n allOf?: JsonSchema[];\n discriminator?: DiscriminatorObject;\n additionalProperties?: boolean | JsonSchema;\n unevaluatedProperties?: boolean | JsonSchema;\n format?: string;\n pattern?: string;\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n minLength?: number;\n maxLength?: number;\n minItems?: number;\n maxItems?: number;\n minProperties?: number;\n maxProperties?: number;\n multipleOf?: number;\n const?: unknown;\n uniqueItems?: boolean;\n title?: string;\n}\n\nexport interface DiscriminatorObject {\n propertyName: string;\n mapping?: Record<string, string>;\n}\n\nexport interface SchemaContext {\n checker: ts.TypeChecker;\n components: Map<string, JsonSchema>;\n typeStack: Set<ts.Type>;\n typeNameStack: string[];\n}\n\nexport function typeToJsonSchema(\n type: ts.Type,\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const { checker } = ctx;\n\n if (type.flags & ts.TypeFlags.Undefined) {\n return {};\n }\n if (type.flags & ts.TypeFlags.Null) {\n return { type: \"null\" };\n }\n\n if (type.flags & ts.TypeFlags.String) {\n return { type: \"string\" };\n }\n if (type.flags & ts.TypeFlags.Number) {\n return { type: \"number\" };\n }\n if (type.flags & ts.TypeFlags.Boolean) {\n return { type: \"boolean\" };\n }\n if (type.flags & ts.TypeFlags.BigInt) {\n return {\n type: \"string\",\n format: \"int64\",\n pattern: \"^-?\\\\d+$\"\n };\n }\n\n if (type.flags & ts.TypeFlags.StringLiteral) {\n const value = (type as ts.StringLiteralType).value;\n return { type: \"string\", enum: [value] };\n }\n if (type.flags & ts.TypeFlags.NumberLiteral) {\n const value = (type as ts.NumberLiteralType).value;\n return { type: \"number\", enum: [value] };\n }\n if (type.flags & ts.TypeFlags.BooleanLiteral) {\n const intrinsic = (type as any).intrinsicName;\n return { type: \"boolean\", enum: [intrinsic === \"true\"] };\n }\n\n if (type.isUnion()) {\n return handleUnion(type.types, ctx, typeNode);\n }\n\n if (type.isIntersection()) {\n return handleIntersection(type.types, ctx, typeNode);\n }\n\n if (checker.isArrayType(type)) {\n const typeArgs = (type as ts.TypeReference).typeArguments;\n const itemType = typeArgs?.[0];\n const items = itemType ? typeToJsonSchema(itemType, ctx) : {};\n return {\n type: \"array\",\n items,\n uniqueItems: isSetType(type, checker) ? true : undefined,\n };\n }\n\n if (type.flags & ts.TypeFlags.Object) {\n return handleObjectType(type as ts.ObjectType, ctx, typeNode);\n }\n\n return {};\n}\n\nfunction isSetType(type: ts.Type, checker: ts.TypeChecker): boolean {\n const symbol = type.getSymbol();\n if (!symbol) return false;\n const name = symbol.getName();\n if (name === \"Set\") return true;\n return false;\n}\n\nfunction handleUnion(\n types: readonly ts.Type[],\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const nullType = types.find(t => t.flags & ts.TypeFlags.Null);\n const otherTypes = types.filter(t => !(t.flags & ts.TypeFlags.Null) && !(t.flags & ts.TypeFlags.Undefined));\n\n const allStringLiterals = otherTypes.every(t => t.flags & ts.TypeFlags.StringLiteral);\n if (allStringLiterals && otherTypes.length > 0) {\n const enumValues = otherTypes.map(t => (t as ts.StringLiteralType).value);\n const schema: JsonSchema = { type: \"string\", enum: enumValues };\n if (nullType) {\n schema.type = [\"string\", \"null\"];\n }\n return schema;\n }\n\n if (otherTypes.length === 1 && nullType) {\n const innerSchema = typeToJsonSchema(otherTypes[0], ctx);\n if (typeof innerSchema.type === \"string\") {\n innerSchema.type = [innerSchema.type, \"null\"];\n }\n return innerSchema;\n }\n\n if (otherTypes.length > 1) {\n const branches = otherTypes.map(t => typeToJsonSchema(t, ctx));\n const hasNull = !!nullType;\n\n const result: JsonSchema = {};\n\n if (hasNull) {\n result.anyOf = [...branches, { type: \"null\" }];\n } else {\n result.anyOf = branches;\n }\n\n const discriminatorResult = detectDiscriminatedUnion(otherTypes, ctx, branches);\n if (discriminatorResult) {\n result.oneOf = branches;\n result.discriminator = discriminatorResult;\n }\n\n return result;\n }\n\n if (otherTypes.length === 1) {\n return typeToJsonSchema(otherTypes[0], ctx);\n }\n\n return {};\n}\n\nfunction handleIntersection(\n types: readonly ts.Type[],\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const brandCollapsed = tryCollapseBrandedIntersection(types, ctx, typeNode);\n if (brandCollapsed) {\n return brandCollapsed;\n }\n\n const allOf: JsonSchema[] = [];\n for (const t of types) {\n allOf.push(typeToJsonSchema(t, ctx));\n }\n\n return { allOf };\n}\n\nfunction tryCollapseBrandedIntersection(\n types: readonly ts.Type[],\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema | null {\n const { checker } = ctx;\n const parts = [...types];\n\n const prim = parts.find(isPrimitiveLike);\n if (!prim) return null;\n\n const rest = parts.filter(p => p !== prim);\n if (rest.every(r => isBrandObject(checker, r, ctx))) {\n return typeToJsonSchema(prim, ctx);\n }\n\n return null;\n}\n\nfunction isPrimitiveLike(t: ts.Type): boolean {\n return (t.flags & (ts.TypeFlags.String | ts.TypeFlags.Number | ts.TypeFlags.Boolean | ts.TypeFlags.BigInt)) !== 0\n || (t.flags & ts.TypeFlags.StringLiteral) !== 0\n || (t.flags & ts.TypeFlags.NumberLiteral) !== 0;\n}\n\nfunction isBrandObject(checker: ts.TypeChecker, t: ts.Type, ctx: SchemaContext): boolean {\n if (!(t.flags & ts.TypeFlags.Object)) return false;\n\n const props = t.getProperties();\n if (props.length === 0) return false;\n\n const allowed = new Set([\"__brand\", \"__type\", \"__tag\", \"brand\"]);\n for (const p of props) {\n if (!allowed.has(p.getName())) return false;\n }\n\n const callSigs = (t as ts.ObjectType).getCallSignatures?.();\n if (callSigs && callSigs.length > 0) return false;\n\n const constructSigs = (t as ts.ObjectType).getConstructSignatures?.();\n if (constructSigs && constructSigs.length > 0) return false;\n\n return true;\n}\n\nfunction detectDiscriminatedUnion(\n types: readonly ts.Type[],\n ctx: SchemaContext,\n branches: JsonSchema[]\n): DiscriminatorObject | null {\n if (types.length < 2) return null;\n\n const candidates = findCommonPropertyNames(ctx.checker, types);\n for (const propName of candidates) {\n const requiredInAll = types.every(t => isRequiredProperty(ctx.checker, t, propName));\n if (!requiredInAll) continue;\n\n const literalSets = types.map(t => getPropertyLiteralValues(ctx.checker, t, propName));\n if (literalSets.some(s => s === null)) continue;\n\n const allSets = literalSets as Array<Set<string>>;\n if (!areSetsDisjoint(allSets)) continue;\n\n const mapping: Record<string, string> = {};\n for (let i = 0; i < types.length; i++) {\n const branchName = getBranchSchemaName(types[i], ctx);\n for (const val of allSets[i]) {\n mapping[val] = `#/components/schemas/${branchName}`;\n }\n }\n\n return { propertyName: propName, mapping };\n }\n\n return null;\n}\n\nfunction findCommonPropertyNames(checker: ts.TypeChecker, types: readonly ts.Type[]): string[] {\n if (types.length === 0) return [];\n\n const firstProps = types[0].getProperties().map(s => s.getName());\n return firstProps.filter(name =>\n types.every(m => !!checker.getPropertyOfType(m, name))\n );\n}\n\nfunction isRequiredProperty(checker: ts.TypeChecker, type: ts.Type, propName: string): boolean {\n const sym = checker.getPropertyOfType(type, propName);\n if (!sym) return false;\n\n if (sym.flags & ts.SymbolFlags.Optional) return false;\n\n const propType = checker.getTypeOfSymbol(sym);\n if (propType.isUnion?.()) {\n const hasUndefined = propType.types.some(t => (t.flags & ts.TypeFlags.Undefined) !== 0);\n if (hasUndefined) return false;\n }\n\n return true;\n}\n\nfunction getPropertyLiteralValues(checker: ts.TypeChecker, type: ts.Type, propName: string): Set<string> | null {\n const sym = checker.getPropertyOfType(type, propName);\n if (!sym) return null;\n\n const propType = checker.getTypeOfSymbol(sym);\n\n if (propType.isStringLiteral?.()) {\n return new Set([(propType as ts.StringLiteralType).value]);\n }\n\n if (propType.isUnion?.()) {\n const values = new Set<string>();\n for (const m of propType.types) {\n if (!m.isStringLiteral?.()) return null;\n values.add((m as ts.StringLiteralType).value);\n }\n return values;\n }\n\n return null;\n}\n\nfunction areSetsDisjoint(sets: Array<Set<string>>): boolean {\n const seen = new Set<string>();\n for (const s of sets) {\n for (const v of s) {\n if (seen.has(v)) return false;\n seen.add(v);\n }\n }\n return true;\n}\n\nfunction getBranchSchemaName(type: ts.Type, ctx: SchemaContext): string {\n const symbol = type.getSymbol();\n if (symbol) {\n return symbol.getName();\n }\n\n const aliasSymbol = (type as any).aliasSymbol;\n if (aliasSymbol) {\n return aliasSymbol.getName();\n }\n\n return `Anonymous_${ctx.typeNameStack.length}`;\n}\n\nfunction handleObjectType(\n type: ts.ObjectType,\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const { checker, components, typeStack } = ctx;\n const symbol = type.getSymbol();\n const typeName = symbol?.getName?.() ?? getTypeNameFromNode(typeNode, ctx);\n\n if (typeName && typeName !== \"__type\") {\n if (components.has(typeName)) {\n return { $ref: `#/components/schemas/${typeName}` };\n }\n\n if (typeStack.has(type)) {\n return { $ref: `#/components/schemas/${typeName}` };\n }\n\n typeStack.add(type);\n }\n\n const schema = buildObjectSchema(type, ctx, typeNode);\n\n if (typeName && typeName !== \"__type\") {\n typeStack.delete(type);\n if (!components.has(typeName)) {\n components.set(typeName, schema);\n }\n return { $ref: `#/components/schemas/${typeName}` };\n }\n\n typeStack.delete(type);\n return schema;\n}\n\nfunction getTypeId(type: ts.Type, typeName: string): string {\n const typeFlags = type.flags.toString();\n return `${typeName}_${typeFlags}`;\n}\n\nfunction getTypeNameFromNode(typeNode: ts.TypeNode | undefined, ctx: SchemaContext): string {\n if (!typeNode) return `Anonymous_${ctx.typeNameStack.length}`;\n\n if (ts.isTypeReferenceNode(typeNode)) {\n if (ts.isIdentifier(typeNode.typeName)) {\n return typeNode.typeName.text;\n }\n }\n\n if (ts.isTypeAliasDeclaration(typeNode.parent)) {\n if (ts.isIdentifier(typeNode.parent.name)) {\n return typeNode.parent.name.text;\n }\n }\n\n return `Anonymous_${ctx.typeNameStack.length}`;\n}\n\nfunction buildObjectSchema(\n type: ts.ObjectType,\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const { checker } = ctx;\n\n const properties: Record<string, JsonSchema> = {};\n const required: string[] = [];\n\n const props = checker.getPropertiesOfType(type);\n for (const prop of props) {\n const propName = prop.getName();\n const propType = checker.getTypeOfSymbol(prop);\n const isOptional = !!(prop.flags & ts.SymbolFlags.Optional);\n\n properties[propName] = typeToJsonSchema(propType, ctx);\n\n if (!isOptional) {\n required.push(propName);\n }\n }\n\n const schema: JsonSchema = {\n type: \"object\",\n properties,\n };\n\n if (required.length > 0) {\n schema.required = required;\n }\n\n if (isRecordType(type, checker)) {\n const valueType = getRecordValueType(type, checker);\n if (valueType) {\n schema.additionalProperties = typeToJsonSchema(valueType, ctx);\n }\n }\n\n return schema;\n}\n\nfunction isRecordType(type: ts.ObjectType, checker: ts.TypeChecker): boolean {\n const symbol = type.getSymbol();\n if (!symbol) return false;\n\n const name = symbol.getName();\n if (name === \"Record\") return true;\n\n return false;\n}\n\nfunction getRecordValueType(type: ts.ObjectType, checker: ts.TypeChecker): ts.Type | null {\n const symbol = type.getSymbol();\n if (!symbol) return null;\n\n const name = symbol.getName();\n if (name === \"Record\") {\n const typeRef = type as ts.TypeReference;\n const typeArgs = typeRef.typeArguments;\n if (typeArgs && typeArgs.length >= 2) {\n return typeArgs[1];\n }\n }\n\n return null;\n}\n\nexport function createSchemaContext(checker: ts.TypeChecker): SchemaContext {\n return {\n checker,\n components: new Map(),\n typeStack: new Set(),\n typeNameStack: [],\n };\n}\n","import ts from \"typescript\";\n\nexport interface SchemaFragment {\n [key: string]: unknown;\n}\n\nexport function extractPropertySchemaFragments(\n checker: ts.TypeChecker,\n prop: ts.PropertyDeclaration | ts.ParameterDeclaration\n): SchemaFragment[] {\n if (!ts.canHaveDecorators(prop)) return [];\n\n const decs = ts.getDecorators(prop);\n if (!decs || decs.length === 0) return [];\n\n const frags: SchemaFragment[] = [];\n\n for (const d of decs) {\n const expr = d.expression;\n\n let callee: ts.Expression;\n let args: ts.NodeArray<ts.Expression>;\n\n if (ts.isCallExpression(expr)) {\n callee = expr.expression;\n args = expr.arguments;\n } else {\n callee = expr;\n args = ts.factory.createNodeArray([]);\n }\n\n const sym = checker.getSymbolAtLocation(callee);\n if (!sym) continue;\n\n const resolved = resolveImportedDecorator(checker, sym);\n if (!resolved || resolved.module !== \"adorn-api/schema\") continue;\n\n const name = resolved.name;\n\n if (name === \"Schema\") {\n const obj = args[0];\n if (obj && ts.isObjectLiteralExpression(obj)) {\n const frag = objectLiteralToJson(obj);\n if (frag) frags.push(frag);\n }\n continue;\n }\n\n if (name === \"Min\" && isNumberLiteral(args[0])) {\n frags.push({ minimum: Number(args[0].text) });\n } else if (name === \"Max\" && isNumberLiteral(args[0])) {\n frags.push({ maximum: Number(args[0].text) });\n } else if (name === \"ExclusiveMin\" && isNumberLiteral(args[0])) {\n frags.push({ exclusiveMinimum: Number(args[0].text) });\n } else if (name === \"ExclusiveMax\" && isNumberLiteral(args[0])) {\n frags.push({ exclusiveMaximum: Number(args[0].text) });\n } else if (name === \"MinLength\" && isNumberLiteral(args[0])) {\n frags.push({ minLength: Number(args[0].text) });\n } else if (name === \"MaxLength\" && isNumberLiteral(args[0])) {\n frags.push({ maxLength: Number(args[0].text) });\n } else if (name === \"Format\" && isStringLiteral(args[0])) {\n frags.push({ format: args[0].text });\n } else if (name === \"Pattern\") {\n const arg = args[0];\n if (arg && ts.isRegularExpressionLiteral(arg)) {\n frags.push({ pattern: extractRegexPattern(arg.text) });\n } else if (isStringLiteral(arg)) {\n frags.push({ pattern: arg.text });\n }\n } else if (name === \"MinItems\" && isNumberLiteral(args[0])) {\n frags.push({ minItems: Number(args[0].text) });\n } else if (name === \"MaxItems\" && isNumberLiteral(args[0])) {\n frags.push({ maxItems: Number(args[0].text) });\n } else if (name === \"MinProperties\" && isNumberLiteral(args[0])) {\n frags.push({ minProperties: Number(args[0].text) });\n } else if (name === \"MaxProperties\" && isNumberLiteral(args[0])) {\n frags.push({ maxProperties: Number(args[0].text) });\n } else if (name === \"MultipleOf\" && isNumberLiteral(args[0])) {\n frags.push({ multipleOf: Number(args[0].text) });\n } else if (name === \"Example\") {\n frags.push({ example: literalToJson(args[0]) });\n } else if (name === \"Examples\" && ts.isArrayLiteralExpression(args[0])) {\n frags.push({ examples: args[0].elements.map(e => literalToJson(e)) });\n } else if (name === \"Description\" && isStringLiteral(args[0])) {\n frags.push({ description: args[0].text });\n } else if (name === \"Enum\" && ts.isArrayLiteralExpression(args[0])) {\n frags.push({ enum: args[0].elements.map(e => literalToJson(e)) });\n } else if (name === \"Const\") {\n frags.push({ const: literalToJson(args[0]) });\n } else if (name === \"Default\") {\n frags.push({ default: literalToJson(args[0]) });\n } else if (name === \"AdditionalProperties\") {\n const arg = args[0];\n if (arg && (arg.kind === ts.SyntaxKind.FalseKeyword || arg.kind === ts.SyntaxKind.TrueKeyword)) {\n frags.push({ additionalProperties: arg.kind === ts.SyntaxKind.TrueKeyword });\n } else if (arg && ts.isObjectLiteralExpression(arg)) {\n const obj = objectLiteralToJson(arg);\n if (obj) frags.push({ additionalProperties: obj });\n }\n } else if (name === \"Closed\") {\n frags.push({ additionalProperties: false });\n } else if (name === \"ClosedUnevaluated\") {\n frags.push({ unevaluatedProperties: false });\n }\n }\n\n return frags;\n}\n\nfunction resolveImportedDecorator(\n checker: ts.TypeChecker,\n sym: ts.Symbol\n): { module: string; name: string } | null {\n const target = (sym.flags & ts.SymbolFlags.Alias) ? checker.getAliasedSymbol(sym) : sym;\n const name = target.getName();\n\n const decl = target.declarations?.[0];\n if (!decl) return null;\n\n const fileName = decl.getSourceFile().fileName.replace(/\\\\/g, \"/\");\n\n if (fileName.includes(\"/node_modules/adorn-api/\") || fileName.includes(\"/src/schema/\")) {\n return { module: \"adorn-api/schema\", name };\n }\n\n return null;\n}\n\nfunction isNumberLiteral(node: ts.Node | undefined): node is ts.NumericLiteral {\n return !!node && ts.isNumericLiteral(node);\n}\n\nfunction isStringLiteral(node: ts.Node | undefined): node is ts.StringLiteral {\n return !!node && ts.isStringLiteral(node);\n}\n\nfunction extractRegexPattern(text: string): string {\n const match = text.match(/^\\/(.+)\\/[gimsuy]*$/);\n return match ? match[1] : text;\n}\n\nfunction objectLiteralToJson(obj: ts.ObjectLiteralExpression): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const prop of obj.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const name = prop.name;\n let key: string;\n if (ts.isIdentifier(name)) {\n key = name.text;\n } else if (ts.isStringLiteral(name)) {\n key = name.text;\n } else {\n continue;\n }\n out[key] = literalToJson(prop.initializer);\n }\n return out;\n}\n\nfunction literalToJson(node: ts.Expression): unknown {\n if (ts.isStringLiteral(node)) return node.text;\n if (ts.isNumericLiteral(node)) return Number(node.text);\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (node.kind === ts.SyntaxKind.NullKeyword) return null;\n if (ts.isObjectLiteralExpression(node)) return objectLiteralToJson(node);\n if (ts.isArrayLiteralExpression(node)) return node.elements.map(e => literalToJson(e));\n return undefined;\n}\n\nexport function mergeFragments(base: Record<string, unknown>, ...frags: SchemaFragment[]): Record<string, unknown> {\n const result = { ...base };\n for (const frag of frags) {\n Object.assign(result, frag);\n }\n return result;\n}\n\nexport function extractJSDocDescription(checker: ts.TypeChecker, node: ts.Node): string | undefined {\n const sourceFile = node.getSourceFile();\n const docComments = ts.getLeadingCommentRanges(sourceFile.fileName, node.pos);\n if (!docComments || docComments.length === 0) return undefined;\n\n const sourceText = sourceFile.getText();\n let fullComment = \"\";\n\n for (const commentRange of docComments) {\n const comment = sourceText.substring(commentRange.pos, commentRange.end);\n const cleanComment = comment\n .replace(/^\\/\\*\\*/, \"\")\n .replace(/\\*\\/$/, \"\")\n .replace(/^\\s*\\*\\s?/gm, \"\")\n .trim();\n fullComment += cleanComment + \"\\n\";\n }\n\n return fullComment.trim() || undefined;\n}\n\nexport function extractJSDocTags(checker: ts.TypeChecker, node: ts.Node): Record<string, unknown> {\n const tags: Record<string, unknown> = {};\n\n const jsDocTags = ts.getJSDocTags(node);\n if (!jsDocTags) return tags;\n\n for (const tag of jsDocTags) {\n const tagName = tag.tagName.text;\n\n if (tagName === \"example\") {\n const exampleComment = getTagComment(tag);\n if (exampleComment) {\n const existing = (tags.examples as string[]) ?? [];\n tags.examples = [...existing, exampleComment];\n }\n } else if (tagName === \"default\") {\n const defaultComment = getTagComment(tag);\n if (defaultComment) {\n tags.default = parseDefaultValue(defaultComment);\n }\n } else if (tagName === \"description\") {\n const desc = getTagComment(tag);\n if (desc) {\n tags.description = desc;\n }\n } else if (tagName === \"deprecated\") {\n tags.deprecated = true;\n }\n }\n\n return tags;\n}\n\nfunction getTagComment(tag: ts.JSDocTag): string | undefined {\n const comment = tag.comment;\n if (typeof comment === \"string\") {\n return comment.trim();\n }\n if (comment && Array.isArray(comment) && comment.length > 0) {\n return comment.map(c => typeof c === \"string\" ? c : c.text).join(\" \").trim();\n }\n return undefined;\n}\n\nfunction parseDefaultValue(comment: string): unknown {\n const trimmed = comment.trim();\n\n if (trimmed === \"true\") return true;\n if (trimmed === \"false\") return false;\n if (trimmed === \"null\") return null;\n\n const num = Number(trimmed);\n if (!isNaN(num) && trimmed === num.toString()) return num;\n\n if ((trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))) {\n return trimmed.slice(1, -1);\n }\n\n return trimmed;\n}\n\nexport function extractClassSchemaFragments(\n checker: ts.TypeChecker,\n classDecl: ts.ClassDeclaration\n): SchemaFragment[] {\n const frags: SchemaFragment[] = [];\n\n if (!ts.canHaveDecorators(classDecl)) return [];\n\n const decs = ts.getDecorators(classDecl);\n if (!decs || decs.length === 0) return frags;\n\n for (const d of decs) {\n const expr = d.expression;\n\n let callee: ts.Expression;\n let args: ts.NodeArray<ts.Expression>;\n\n if (ts.isCallExpression(expr)) {\n callee = expr.expression;\n args = expr.arguments;\n } else {\n callee = expr;\n args = ts.factory.createNodeArray([]);\n }\n\n const sym = checker.getSymbolAtLocation(callee);\n if (!sym) continue;\n\n const resolved = resolveImportedDecorator(checker, sym);\n if (!resolved || resolved.module !== \"adorn-api/schema\") continue;\n\n const name = resolved.name;\n\n if (name === \"Schema\") {\n const obj = args[0];\n if (obj && ts.isObjectLiteralExpression(obj)) {\n const frag = objectLiteralToJson(obj);\n if (frag) frags.push(frag);\n }\n } else if (name === \"Description\" && isStringLiteral(args[0])) {\n frags.push({ description: args[0].text });\n } else if (name === \"Example\") {\n frags.push({ example: literalToJson(args[0]) });\n } else if (name === \"Examples\" && ts.isArrayLiteralExpression(args[0])) {\n frags.push({ examples: args[0].elements.map(e => literalToJson(e)) });\n } else if (name === \"Closed\") {\n frags.push({ additionalProperties: false });\n } else if (name === \"ClosedUnevaluated\") {\n frags.push({ unevaluatedProperties: false });\n }\n }\n\n const jsDocDesc = extractJSDocDescription(checker, classDecl);\n if (jsDocDesc) {\n frags.push({ description: jsDocDesc });\n }\n\n const jsDocTags = extractJSDocTags(checker, classDecl);\n if (Object.keys(jsDocTags).length > 0) {\n frags.push(jsDocTags);\n }\n\n return frags;\n}\n","import type { ScannedController, ScannedOperation } from \"../analyze/scanControllers.js\";\nimport type { ManifestV1, ControllerEntry, OperationEntry, ArgsSpec, HttpMethod } from \"./format.js\";\nimport { typeToJsonSchema } from \"../schema/typeToJsonSchema.js\";\nimport type { SchemaContext } from \"../schema/typeToJsonSchema.js\";\nimport ts from \"typescript\";\n\ntype ValidationMode = \"none\" | \"ajv-runtime\" | \"precompiled\";\n\nexport function generateManifest(\n controllers: ScannedController[],\n checker: ts.TypeChecker,\n version: string,\n validationMode: ValidationMode = \"ajv-runtime\"\n): ManifestV1 {\n const components = new Map<string, any>();\n const ctx: SchemaContext = {\n checker,\n components,\n typeStack: new Set(),\n typeNameStack: [],\n };\n\n const controllerEntries: ControllerEntry[] = controllers.map(ctrl => ({\n controllerId: ctrl.className,\n basePath: ctrl.basePath,\n operations: ctrl.operations.map(op => buildOperationEntry(op, ctx)),\n }));\n\n const validationConfig: { mode: \"none\" | \"ajv-runtime\" | \"precompiled\"; precompiledModule: string | null } = \n validationMode === \"precompiled\"\n ? { mode: \"precompiled\", precompiledModule: null }\n : validationMode === \"none\"\n ? { mode: \"none\", precompiledModule: null }\n : { mode: \"ajv-runtime\", precompiledModule: null };\n\n return {\n manifestVersion: 1,\n generatedAt: new Date().toISOString(),\n generator: {\n name: \"adorn-api\",\n version,\n typescript: ts.version,\n },\n schemas: {\n kind: \"openapi-3.1\",\n file: \"./openapi.json\",\n componentsSchemasPointer: \"/components/schemas\",\n },\n validation: validationConfig,\n controllers: controllerEntries,\n };\n}\n\nfunction buildOperationEntry(op: ScannedOperation, ctx: SchemaContext): OperationEntry {\n const args: ArgsSpec = {\n body: null,\n path: [],\n query: [],\n headers: [],\n cookies: [],\n };\n\n buildPathArgs(op, ctx, args);\n buildQueryArgs(op, ctx, args);\n buildHeaderArgs(op, ctx, args);\n buildCookieArgs(op, ctx, args);\n\n if (op.bodyParamIndex !== null) {\n const bodyParam = op.parameters[op.bodyParamIndex];\n if (bodyParam) {\n const bodySchema = typeToJsonSchema(bodyParam.type, ctx);\n const schemaRef = bodySchema.$ref ?? \"#/components/schemas/InlineBody\";\n\n args.body = {\n index: bodyParam.index,\n required: !bodyParam.isOptional,\n contentType: op.bodyContentType ?? \"application/json\",\n schemaRef,\n };\n }\n }\n\n const responseSchema = typeToJsonSchema(op.returnType, ctx);\n const status = op.httpMethod === \"POST\" ? 201 : 200;\n\n let schemaRef = responseSchema.$ref;\n let isArray = false;\n\n if (!schemaRef && responseSchema.type === \"array\" && responseSchema.items?.$ref) {\n schemaRef = responseSchema.items.$ref;\n isArray = true;\n } else if (!schemaRef) {\n schemaRef = \"#/components/schemas/InlineResponse\";\n }\n\n return {\n operationId: op.operationId,\n http: {\n method: op.httpMethod as HttpMethod,\n path: op.path,\n },\n handler: {\n methodName: op.methodName,\n },\n args,\n responses: [\n {\n status,\n contentType: \"application/json\",\n schemaRef,\n isArray,\n },\n ],\n };\n}\n\nfunction buildPathArgs(op: ScannedOperation, ctx: SchemaContext, args: ArgsSpec): void {\n for (const paramIndex of op.pathParamIndices) {\n const param = op.parameters[paramIndex];\n if (param) {\n const paramSchema = typeToJsonSchema(param.type, ctx);\n\n args.path.push({\n name: param.name,\n index: param.index,\n required: !param.isOptional,\n schemaRef: paramSchema.$ref ?? \"#/components/schemas/InlinePathParam\",\n schemaType: paramSchema.type,\n });\n }\n }\n}\n\nfunction buildQueryArgs(op: ScannedOperation, ctx: SchemaContext, args: ArgsSpec): void {\n if (op.queryObjectParamIndex !== null) {\n const queryParam = op.parameters[op.queryObjectParamIndex];\n if (queryParam) {\n const querySchema = typeToJsonSchema(queryParam.type, ctx);\n if (!querySchema.properties) return;\n\n for (const [propName, propSchema] of Object.entries(querySchema.properties as Record<string, any>)) {\n const isRequired = querySchema.required?.includes(propName) ?? false;\n let schemaRef = propSchema.$ref;\n if (!schemaRef) {\n schemaRef = \"#/components/schemas/InlineQueryParam\";\n }\n\n args.query.push({\n name: propName,\n index: queryParam.index,\n required: !isRequired,\n schemaRef,\n schemaType: propSchema.type,\n });\n }\n }\n }\n\n for (const paramIndex of op.queryParamIndices) {\n const param = op.parameters[paramIndex];\n if (param) {\n const paramSchema = typeToJsonSchema(param.type, ctx);\n const schemaRef = paramSchema.$ref ?? \"#/components/schemas/InlineQueryParam\";\n\n args.query.push({\n name: param.name,\n index: param.index,\n required: !param.isOptional,\n schemaRef,\n schemaType: paramSchema.type,\n });\n }\n }\n}\n\nfunction buildHeaderArgs(op: ScannedOperation, ctx: SchemaContext, args: ArgsSpec): void {\n if (op.headerObjectParamIndex === null) return;\n\n const headerParam = op.parameters[op.headerObjectParamIndex];\n if (!headerParam) return;\n\n const headerSchema = typeToJsonSchema(headerParam.type, ctx);\n if (!headerSchema.properties) return;\n\n for (const [propName, propSchema] of Object.entries(headerSchema.properties as Record<string, any>)) {\n const isRequired = headerSchema.required?.includes(propName) ?? false;\n let schemaRef = propSchema.$ref;\n if (!schemaRef) {\n schemaRef = \"#/components/schemas/InlineHeaderParam\";\n }\n\n args.headers.push({\n name: propName,\n index: headerParam.index,\n required: !isRequired,\n schemaRef,\n schemaType: propSchema.type,\n });\n }\n}\n\nfunction buildCookieArgs(op: ScannedOperation, ctx: SchemaContext, args: ArgsSpec): void {\n if (op.cookieObjectParamIndex === null) return;\n\n const cookieParam = op.parameters[op.cookieObjectParamIndex];\n if (!cookieParam) return;\n\n const cookieSchema = typeToJsonSchema(cookieParam.type, ctx);\n if (!cookieSchema.properties) return;\n\n for (const [propName, propSchema] of Object.entries(cookieSchema.properties as Record<string, any>)) {\n const isRequired = cookieSchema.required?.includes(propName) ?? false;\n let schemaRef = propSchema.$ref;\n if (!schemaRef) {\n schemaRef = \"#/components/schemas/InlineCookieParam\";\n }\n\n args.cookies.push({\n name: propName,\n index: cookieParam.index,\n required: !isRequired,\n schemaRef,\n schemaType: propSchema.type,\n serialization: { style: \"form\", explode: true },\n });\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\n\nimport Ajv from \"ajv\";\nimport addFormats from \"ajv-formats\";\nimport type { AnySchema } from \"ajv\";\n\ninterface OpenApi {\n openapi: string;\n components?: {\n schemas?: Record<string, unknown>;\n };\n}\n\ninterface Manifest {\n manifestVersion: number;\n controllers: Array<{\n controllerId: string;\n basePath: string;\n operations: Array<{\n operationId: string;\n args: {\n body?: {\n schemaRef: string;\n contentType: string;\n } | null;\n response?: Array<{\n status: number;\n contentType: string;\n schemaRef?: string;\n }>;\n };\n responses: Array<{\n status: number;\n contentType: string;\n schemaRef: string;\n }>;\n }>;\n }>;\n}\n\nconst OAS_SCHEMA_ONLY = new Set([\"discriminator\", \"xml\", \"externalDocs\", \"example\"]);\n\nfunction sanitizeSchemaForAjv(schema: unknown): unknown {\n if (schema == null || typeof schema !== \"object\") return schema;\n if (Array.isArray(schema)) return schema.map(sanitizeSchemaForAjv);\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(schema as Record<string, unknown>)) {\n if (OAS_SCHEMA_ONLY.has(k)) continue;\n if (k.startsWith(\"x-\")) continue;\n out[k] = sanitizeSchemaForAjv(v);\n }\n return out;\n}\n\nfunction rewriteComponentRefs(schema: unknown): unknown {\n if (schema == null || typeof schema !== \"object\") return schema;\n if (Array.isArray(schema)) return schema.map(rewriteComponentRefs);\n\n if (typeof (schema as Record<string, unknown>).$ref === \"string\") {\n const ref = (schema as Record<string, unknown>).$ref as string;\n const m = ref.match(/^#\\/components\\/schemas\\/(.+)$/);\n if (m) {\n return { ...schema, $ref: m[1] };\n }\n }\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(schema as Record<string, unknown>)) {\n out[k] = rewriteComponentRefs(v);\n }\n return out;\n}\n\nfunction safeId(s: string): string {\n return s.replace(/[^A-Za-z0-9_]/g, \"_\").replace(/^[^A-Za-z_]/, \"_$&\");\n}\n\nfunction schemaNameFromRef(schemaRef: string): string {\n return schemaRef.replace(/^#\\/components\\/schemas\\//, \"\");\n}\n\nexport interface EmitPrecompiledValidatorsOptions {\n outDir: string;\n openapi: OpenApi;\n manifest: Manifest;\n strict?: \"off\" | \"log\" | \"error\";\n formatsMode?: \"fast\" | \"full\";\n}\n\nexport async function emitPrecompiledValidators(opts: EmitPrecompiledValidatorsOptions): Promise<{\n validatorsCjsPath: string;\n validatorsEsmPath: string;\n hash: string;\n}> {\n const outDir = opts.outDir;\n const cjsPath = path.join(outDir, \"validators.cjs\");\n const esmPath = path.join(outDir, \"validators.mjs\");\n const metaPath = path.join(outDir, \"validators.meta.json\");\n\n fs.mkdirSync(outDir, { recursive: true });\n\n const schemas: AnySchema[] = [];\n\n for (const [name, sch] of Object.entries(opts.openapi.components?.schemas ?? {})) {\n const clean = rewriteComponentRefs(sanitizeSchemaForAjv(sch));\n schemas.push({ ...(clean as object), $id: name } as AnySchema);\n }\n\n const opIndex: Record<string, { body?: string; response: Record<string, string> }> = {};\n\n for (const ctrl of opts.manifest.controllers ?? []) {\n for (const op of ctrl.operations ?? []) {\n const entry: { body?: string; response: Record<string, string> } = { response: {} };\n opIndex[op.operationId] = entry;\n\n if (op.args.body?.schemaRef) {\n const typeName = schemaNameFromRef(op.args.body.schemaRef);\n const id = safeId(`op_${op.operationId}_body`);\n schemas.push({ $id: id, $ref: typeName } as AnySchema);\n entry.body = id;\n }\n\n for (const r of op.responses ?? []) {\n if (!r.schemaRef) continue;\n const typeName = schemaNameFromRef(r.schemaRef);\n const key = `${r.status}|${r.contentType}`;\n const id = safeId(`op_${op.operationId}_res_${r.status}_${r.contentType}`);\n schemas.push({ $id: id, $ref: typeName } as AnySchema);\n entry.response[key] = id;\n }\n }\n }\n\n const strictOpt = opts.strict === \"off\" ? false : opts.strict === \"log\" ? \"log\" : true;\n\n const ajv = new Ajv.default({\n schemas,\n allErrors: true,\n strict: strictOpt,\n code: { source: true },\n });\n\n addFormats.default(ajv, { mode: opts.formatsMode ?? \"full\" });\n\n let cjs: string;\n const standaloneModule = require(\"ajv/dist/standalone\");\n if (typeof standaloneModule === \"function\") {\n cjs = standaloneModule(ajv);\n } else if (standaloneModule && typeof standaloneModule.default === \"function\") {\n cjs = standaloneModule.default(ajv);\n } else {\n throw new Error(\"Unable to find standalone code generator in ajv/dist/standalone\");\n }\n\n cjs += \"\\n\\n// --- adorn-api operation lookup (generated) ---\\n\";\n cjs += \"exports.validators = {\\n\";\n for (const [operationId, v] of Object.entries(opIndex)) {\n cjs += ` ${JSON.stringify(operationId)}: {\\n`;\n cjs += ` body: ${v.body ? `exports[${JSON.stringify(v.body)}]` : \"undefined\"},\\n`;\n cjs += ` response: {\\n`;\n for (const [key, id] of Object.entries(v.response)) {\n cjs += ` ${JSON.stringify(key)}: exports[${JSON.stringify(id)}],\\n`;\n }\n cjs += ` }\\n`;\n cjs += ` },\\n`;\n }\n cjs += \"};\\n\";\n\n fs.writeFileSync(cjsPath, cjs, \"utf8\");\n\n const esm = `// .adorn/validators.mjs (generated)\nimport { createRequire } from \"node:module\";\nconst require = createRequire(import.meta.url);\nconst cjs = require(\"./validators.cjs\");\n\nexport const validators = cjs.validators;\n\nexport function validateBody(operationId, data) {\n const v = validators?.[operationId]?.body;\n if (!v) return { ok: true, errors: null };\n const ok = v(data);\n return { ok, errors: ok ? null : v.errors };\n}\n\nexport function validateResponse(operationId, status, contentType, data) {\n const key = String(status) + \"|\" + String(contentType);\n const v = validators?.[operationId]?.response?.[key];\n if (!v) return { ok: true, errors: null };\n const ok = v(data);\n return { ok, errors: ok ? null : v.errors };\n}\n`;\n fs.writeFileSync(esmPath, esm, \"utf8\");\n\n const hash = crypto.createHash(\"sha256\").update(cjs).digest(\"hex\");\n fs.writeFileSync(metaPath, JSON.stringify({ hash }, null, 2), \"utf8\");\n\n return { validatorsCjsPath: cjsPath, validatorsEsmPath: esmPath, hash };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport ts from \"typescript\";\nimport type { AdornCacheV1 } from \"./schema.js\";\n\nexport type StaleResult =\n | { stale: false; reason: \"up-to-date\" }\n | { stale: true; reason: string; detail?: string };\n\nfunction readJson<T>(p: string): T | null {\n try {\n return JSON.parse(fs.readFileSync(p, \"utf8\")) as T;\n } catch {\n return null;\n }\n}\n\nfunction statMtimeMs(p: string): number | null {\n try {\n return fs.statSync(p).mtimeMs;\n } catch {\n return null;\n }\n}\n\nfunction ensureAbs(p: string): string {\n return path.isAbsolute(p) ? p : path.resolve(p);\n}\n\nexport function collectTsconfigChain(tsconfigPathAbs: string): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n\n function visit(pAbs: string) {\n if (seen.has(pAbs)) return;\n seen.add(pAbs);\n out.push(pAbs);\n\n const raw = readJson<any>(pAbs);\n const ext = raw?.extends;\n if (!ext) return;\n\n let resolved: string | null = null;\n\n if (ext.startsWith(\".\") || ext.startsWith(\"/\") || /^[A-Za-z]:\\\\/.test(ext)) {\n resolved = ensureAbs(path.resolve(path.dirname(pAbs), ext));\n if (!resolved.endsWith(\".json\")) resolved += \".json\";\n } else {\n try {\n const req = (module as any).createRequire?.(import.meta.url) ?? require;\n resolved = req.resolve(ext);\n } catch {\n try {\n const req = (module as any).createRequire?.(import.meta.url) ?? require;\n resolved = req.resolve(ext.endsWith(\".json\") ? ext : `${ext}.json`);\n } catch {\n resolved = null;\n }\n }\n }\n\n if (resolved) visit(resolved);\n }\n\n visit(tsconfigPathAbs);\n return out;\n}\n\nexport function findLockfile(startDir: string): { path: string; mtimeMs: number } | null {\n const names = [\"pnpm-lock.yaml\", \"package-lock.json\", \"yarn.lock\"];\n let dir = startDir;\n\n for (let i = 0; i < 20; i++) {\n for (const n of names) {\n const p = path.join(dir, n);\n const mt = statMtimeMs(p);\n if (mt != null) return { path: p, mtimeMs: mt };\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\nexport async function isStale(params: {\n outDir: string;\n project: string;\n adornVersion: string;\n typescriptVersion: string;\n}): Promise<StaleResult> {\n const outDirAbs = ensureAbs(params.outDir);\n const tsconfigAbs = ensureAbs(params.project);\n\n const manifestPath = path.join(outDirAbs, \"manifest.json\");\n const cachePath = path.join(outDirAbs, \"cache.json\");\n\n if (!fs.existsSync(manifestPath)) return { stale: true, reason: \"missing-manifest\" };\n\n const cache = readJson<AdornCacheV1>(cachePath);\n if (!cache) return { stale: true, reason: \"missing-cache\" };\n\n if (cache.generator.version !== params.adornVersion) {\n return { stale: true, reason: \"generator-version-changed\", detail: `${cache.generator.version} -> ${params.adornVersion}` };\n }\n\n if (ensureAbs(cache.project.tsconfigPath) !== tsconfigAbs) {\n return { stale: true, reason: \"tsconfig-changed\", detail: \"different project path\" };\n }\n\n const chain = collectTsconfigChain(tsconfigAbs);\n for (const cfg of chain) {\n const mt = statMtimeMs(cfg);\n if (mt == null) return { stale: true, reason: \"config-missing\", detail: cfg };\n\n const cachedMt = cache.project.configFiles[cfg];\n if (cachedMt == null || Math.abs(cachedMt - mt) > 0.0001) {\n return { stale: true, reason: \"config-updated\", detail: cfg };\n }\n }\n\n if (cache.project.lockfile?.path) {\n const mt = statMtimeMs(cache.project.lockfile.path);\n if (mt == null) return { stale: true, reason: \"lockfile-missing\", detail: cache.project.lockfile.path };\n\n if (Math.abs(cache.project.lockfile.mtimeMs - mt) > 0.0001) {\n return { stale: true, reason: \"lockfile-updated\", detail: cache.project.lockfile.path };\n }\n }\n\n for (const [file, cachedMt] of Object.entries(cache.inputs)) {\n const mt = statMtimeMs(file);\n if (mt == null) return { stale: true, reason: \"input-missing\", detail: file };\n if (Math.abs(cachedMt - mt) > 0.0001) return { stale: true, reason: \"input-updated\", detail: file };\n }\n\n return { stale: false, reason: \"up-to-date\" };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport ts from \"typescript\";\nimport { collectTsconfigChain, findLockfile } from \"./isStale.js\";\nimport type { AdornCacheV1 } from \"./schema.js\";\n\nfunction statMtimeMs(p: string): number {\n return fs.statSync(p).mtimeMs;\n}\n\nfunction ensureDir(p: string) {\n fs.mkdirSync(p, { recursive: true });\n}\n\nfunction isProjectSourceFile(f: string): boolean {\n if (f.includes(`${path.sep}node_modules${path.sep}`)) return false;\n if (f.includes(`${path.sep}typescript${path.sep}lib${path.sep}`)) return false;\n return /\\.(ts|tsx|mts|cts)$/.test(f);\n}\n\nexport function writeCache(params: {\n outDir: string;\n tsconfigAbs: string;\n program: ts.Program;\n adornVersion: string;\n}): void {\n const outDirAbs = path.isAbsolute(params.outDir) ? params.outDir : path.resolve(params.outDir);\n ensureDir(outDirAbs);\n\n const configFiles = collectTsconfigChain(params.tsconfigAbs);\n const configMtimes: Record<string, number> = {};\n for (const cfg of configFiles) configMtimes[cfg] = statMtimeMs(cfg);\n\n const lock = findLockfile(path.dirname(params.tsconfigAbs));\n\n const inputs: Record<string, number> = {};\n for (const sf of params.program.getSourceFiles()) {\n const f = sf.fileName;\n if (!isProjectSourceFile(f)) continue;\n try {\n inputs[f] = statMtimeMs(f);\n } catch {\n }\n }\n\n const cache: AdornCacheV1 = {\n cacheVersion: 1,\n generator: {\n name: \"adorn-api\",\n version: params.adornVersion,\n typescript: ts.version\n },\n project: {\n tsconfigPath: params.tsconfigAbs,\n configFiles: configMtimes,\n lockfile: lock ?? null\n },\n inputs\n };\n\n fs.writeFileSync(path.join(outDirAbs, \"cache.json\"), JSON.stringify(cache, null, 2), \"utf8\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,kBAA2E;AAC3E,IAAAC,oBAAiC;;;ACFjC,wBAAe;AACf,qBAA6B;AAC7B,uBAAiC;AAQ1B,SAAS,wBAAwB,cAAsC;AAC5E,QAAM,mBAAe,0BAAQ,YAAY;AACzC,QAAM,gBAAY,0BAAQ,YAAY;AAEtC,QAAM,aAAa,kBAAAC,QAAG,eAAe,cAAc,CAACC,cAAS,6BAAaA,OAAM,OAAO,CAAC;AACxF,MAAI,WAAW,OAAO;AACpB,UAAM,IAAI,MAAM,4BAA4B,kBAAAD,QAAG,6BAA6B,WAAW,MAAM,aAAa,IAAI,CAAC,EAAE;AAAA,EACnH;AAEA,QAAM,SAAS,kBAAAA,QAAG,2BAA2B,WAAW,QAAQ,kBAAAA,QAAG,KAAK,SAAS;AACjF,MAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,WAAW,OAAO,OAAO,IAAI,OAAK,kBAAAA,QAAG,6BAA6B,EAAE,aAAa,IAAI,CAAC;AAC5F,UAAM,IAAI,MAAM;AAAA,EAA8B,SAAS,KAAK,IAAI,CAAC,EAAE;AAAA,EACrE;AAEA,QAAM,UAAU,kBAAAA,QAAG,cAAc,OAAO,WAAW,OAAO,OAAO;AACjE,QAAM,UAAU,QAAQ,eAAe;AAEvC,QAAM,cAAc,QAAQ,eAAe,EAAE;AAAA,IAAO,QAClD,CAAC,GAAG,qBACJ,CAAC,GAAG,SAAS,SAAS,cAAc;AAAA,EACtC;AAEA,SAAO,EAAE,SAAS,SAAS,YAAY;AACzC;;;AClCA,IAAAE,qBAAe;;;ACAR,SAAS,mBAAmB,gBAAwB,YAA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R,iBAAa,2BAAQ,WAAW;AAAA,IAChC;AAAA,IACA,cAAc;AAAA,EAChB,CAAC;AAED,MAAI,cAAc,UAAU,GAAG;AAC/B,MAAI,kBAAkB;AACtB,MAAI,mBAAmB;AACvB,MAAI,gBAAgB;AACtB;AAEA,SAAS,aAAa,MAAgB;AACpC,QAAM,YAAY,KAAK,SAAS,UAAU,IACtC,KAAK,KAAK,QAAQ,UAAU,IAAI,CAAC,IACjC;AAEJ,QAAM,iBAAa,2BAAQ,SAAS;AAEpC,UAAI,4BAAW,UAAU,GAAG;AAC1B,gCAAO,YAAY,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,EACrD;AAEA,MAAI,sBAAsB,SAAS,EAAE;AACvC;AAEA,IAAM,UAAU,oBAAAA,QAAQ,KAAK,CAAC;AAE9B,IAAI,YAAY,SAAS;AACvB,eAAa,oBAAAA,QAAQ,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ;AACjD,YAAQ,MAAM,GAAG;AACjB,wBAAAA,QAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH,WAAW,YAAY,SAAS;AAC9B,eAAa,oBAAAA,QAAQ,KAAK,MAAM,CAAC,CAAC;AACpC,OAAO;AACL,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAkBX;AACH;","names":["import_node_fs","import_node_path","ts","path","import_typescript","ts","path","import_typescript","import_typescript","ts","ts","import_typescript","ts","path","ts","import_typescript","ts","schemaRef","import_node_fs","import_node_path","path","fs","Ajv","addFormats","crypto","import_node_fs","import_node_path","import_typescript","fs","path","import_node_fs","import_node_path","import_typescript","statMtimeMs","fs","path","ts","import_typescript","process","ts"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/compiler/runner/createProgram.ts","../src/compiler/analyze/scanControllers.ts","../src/utils/operationId.ts","../src/compiler/schema/openapi.ts","../src/compiler/schema/typeToJsonSchema.ts","../src/compiler/schema/extractAnnotations.ts","../src/compiler/analyze/extractQueryStyle.ts","../src/compiler/manifest/emit.ts","../src/compiler/validation/emitPrecompiledValidators.ts","../src/compiler/cache/isStale.ts","../src/compiler/cache/writeCache.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { writeFileSync, mkdirSync, rmSync, existsSync, readFileSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\nimport { createProgramFromConfig } from \"./compiler/runner/createProgram.js\";\nimport { scanControllers } from \"./compiler/analyze/scanControllers.js\";\nimport { generateOpenAPI } from \"./compiler/schema/openapi.js\";\nimport { generateManifest } from \"./compiler/manifest/emit.js\";\nimport { emitPrecompiledValidators } from \"./compiler/validation/emitPrecompiledValidators.js\";\nimport { isStale } from \"./compiler/cache/isStale.js\";\nimport { writeCache } from \"./compiler/cache/writeCache.js\";\nimport ts from \"typescript\";\nimport process from \"node:process\";\n\nconst ADORN_VERSION = \"0.1.0\";\n\ntype ValidationMode = \"none\" | \"ajv-runtime\" | \"precompiled\";\n\nfunction log(msg: string) {\n process.stdout.write(msg + \"\\n\");\n}\n\nfunction debug(...args: unknown[]) {\n if (process.env.ADORN_DEBUG) {\n console.error(\"[adorn-api]\", ...args);\n }\n}\n\nasync function buildCommand(args: string[]) {\n const projectIndex = args.indexOf(\"-p\");\n const projectPath = projectIndex !== -1 ? args[projectIndex + 1] : \"./tsconfig.json\";\n const outputDir = args.includes(\"--output\")\n ? args[args.indexOf(\"--output\") + 1]\n : \".adorn\";\n const ifStale = args.includes(\"--if-stale\");\n \n const validationModeIndex = args.indexOf(\"--validation-mode\");\n const validationMode: ValidationMode = validationModeIndex !== -1 \n ? (args[validationModeIndex + 1] as ValidationMode) \n : \"ajv-runtime\";\n\n if (validationMode !== \"none\" && validationMode !== \"ajv-runtime\" && validationMode !== \"precompiled\") {\n console.error(`Invalid validation mode: ${validationMode}. Valid values: none, ajv-runtime, precompiled`);\n process.exit(1);\n }\n\n const outputPath = resolve(outputDir);\n\n if (ifStale) {\n const stale = await isStale({\n outDir: outputDir,\n project: projectPath,\n adornVersion: ADORN_VERSION,\n typescriptVersion: ts.version\n });\n\n if (!stale.stale) {\n log(\"adorn-api: artifacts up-to-date\");\n return;\n }\n\n log(`adorn-api: building artifacts (reason: ${stale.reason}${stale.detail ? `: ${stale.detail}` : \"\"})`);\n debug(\"Stale detail:\", stale.detail);\n } else {\n log(\"adorn-api: building artifacts (reason: forced-build)\");\n }\n\n const { program, checker, sourceFiles } = createProgramFromConfig(projectPath);\n const controllers = scanControllers(sourceFiles, checker);\n\n if (controllers.length === 0) {\n console.warn(\"No controllers found!\");\n process.exit(1);\n }\n\n log(`Found ${controllers.length} controller(s)`);\n\n const openapi = generateOpenAPI(controllers, checker, { title: \"API\", version: \"1.0.0\" });\n const manifest = generateManifest(controllers, checker, ADORN_VERSION, validationMode);\n\n mkdirSync(outputPath, { recursive: true });\n\n writeFileSync(resolve(outputPath, \"openapi.json\"), JSON.stringify(openapi, null, 2));\n writeFileSync(resolve(outputPath, \"manifest.json\"), JSON.stringify(manifest, null, 2));\n\n if (validationMode === \"precompiled\") {\n log(\"Generating precompiled validators...\");\n \n const manifestObj = JSON.parse(readFileSync(resolve(outputPath, \"manifest.json\"), \"utf-8\"));\n \n await emitPrecompiledValidators({\n outDir: outputPath,\n openapi,\n manifest: manifestObj,\n strict: \"off\",\n formatsMode: \"full\"\n });\n\n manifestObj.validation = {\n mode: \"precompiled\",\n precompiledModule: \"./validators.mjs\"\n };\n \n writeFileSync(resolve(outputPath, \"manifest.json\"), JSON.stringify(manifestObj, null, 2));\n \n log(\" - validators.cjs\");\n log(\" - validators.mjs\");\n log(\" - validators.meta.json\");\n }\n\n writeCache({\n outDir: outputDir,\n tsconfigAbs: resolve(projectPath),\n program,\n adornVersion: ADORN_VERSION\n });\n\n log(`Written to ${outputPath}/`);\n log(\" - openapi.json\");\n log(\" - manifest.json\");\n log(\" - cache.json\");\n}\n\nfunction cleanCommand(args: string[]) {\n const outputDir = args.includes(\"--output\")\n ? args[args.indexOf(\"--output\") + 1]\n : \".adorn\";\n\n const outputPath = resolve(outputDir);\n\n if (existsSync(outputPath)) {\n rmSync(outputPath, { recursive: true, force: true });\n }\n\n log(`adorn-api: cleaned ${outputDir}`);\n}\n\nconst command = process.argv[2];\n\nif (command === \"build\") {\n buildCommand(process.argv.slice(3)).catch((err) => {\n console.error(err);\n process.exit(1);\n });\n} else if (command === \"clean\") {\n cleanCommand(process.argv.slice(3));\n} else {\n console.log(`\nadorn-api CLI\n\nCommands:\n build Generate OpenAPI and manifest from TypeScript source\n clean Remove generated artifacts\n\nOptions:\n -p <path> Path to tsconfig.json (default: ./tsconfig.json)\n --output <dir> Output directory (default: .adorn)\n --if-stale Only rebuild if artifacts are stale\n --validation-mode <mode> Validation mode: none, ajv-runtime, precompiled (default: ajv-runtime)\n\nExamples:\n adorn-api build -p ./tsconfig.json --output .adorn\n adorn-api build --if-stale\n adorn-api build --validation-mode precompiled\n adorn-api clean\n `);\n}\n","import ts from \"typescript\";\nimport { readFileSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\n\nexport interface ProgramContext {\n program: ts.Program;\n checker: ts.TypeChecker;\n sourceFiles: ts.SourceFile[];\n}\n\nexport function createProgramFromConfig(tsconfigPath: string): ProgramContext {\n const absolutePath = resolve(tsconfigPath);\n const configDir = dirname(absolutePath);\n\n const configFile = ts.readConfigFile(absolutePath, (path) => readFileSync(path, \"utf-8\"));\n if (configFile.error) {\n throw new Error(`Failed to read tsconfig: ${ts.flattenDiagnosticMessageText(configFile.error.messageText, \"\\n\")}`);\n }\n\n const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, configDir);\n if (parsed.errors.length > 0) {\n const messages = parsed.errors.map(e => ts.flattenDiagnosticMessageText(e.messageText, \"\\n\"));\n throw new Error(`Failed to parse tsconfig:\\n${messages.join(\"\\n\")}`);\n }\n\n const program = ts.createProgram(parsed.fileNames, parsed.options);\n const checker = program.getTypeChecker();\n\n const sourceFiles = program.getSourceFiles().filter(sf =>\n !sf.isDeclarationFile &&\n !sf.fileName.includes(\"node_modules\")\n );\n\n return { program, checker, sourceFiles };\n}\n","import ts from \"typescript\";\nimport { defaultOperationId } from \"../../utils/operationId.js\";\n\nexport interface ScannedController {\n className: string;\n basePath: string;\n sourceFile: ts.SourceFile;\n classDeclaration: ts.ClassDeclaration;\n operations: ScannedOperation[];\n consumes?: string[];\n produces?: string[];\n}\n\nexport interface ScannedOperation {\n methodName: string;\n httpMethod: string;\n path: string;\n operationId: string;\n methodDeclaration: ts.MethodDeclaration;\n returnType: ts.Type;\n parameters: ScannedParameter[];\n pathParamIndices: number[];\n bodyParamIndex: number | null;\n queryParamIndices: number[];\n queryObjectParamIndex: number | null;\n headerObjectParamIndex: number | null;\n cookieObjectParamIndex: number | null;\n bodyContentType?: string;\n}\n\nexport interface ScannedParameter {\n name: string;\n index: number;\n type: ts.Type;\n isOptional: boolean;\n paramNode?: ts.ParameterDeclaration;\n}\n\nexport function scanControllers(\n sourceFiles: ts.SourceFile[],\n checker: ts.TypeChecker\n): ScannedController[] {\n const controllers: ScannedController[] = [];\n\n for (const sourceFile of sourceFiles) {\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isClassDeclaration(node) && node.name) {\n const controller = analyzeClass(node, sourceFile, checker);\n if (controller) {\n controllers.push(controller);\n }\n }\n });\n }\n\n return controllers;\n}\n\nfunction analyzeClass(\n node: ts.ClassDeclaration,\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker\n): ScannedController | null {\n if (!node.name) return null;\n\n const controllerDecorator = findDecorator(node, \"Controller\");\n if (!controllerDecorator) return null;\n\n const basePath = extractDecoratorStringArg(controllerDecorator) ?? \"/\";\n const className = node.name.text;\n\n const consumes = extractClassConsumes(node, checker);\n const produces = extractClassProduces(node, checker);\n\n const operations: ScannedOperation[] = [];\n\n for (const member of node.members) {\n if (ts.isMethodDeclaration(member) && member.name) {\n const operation = analyzeMethod(member, className, checker);\n if (operation) {\n operations.push(operation);\n }\n }\n }\n\n if (operations.length === 0) return null;\n\n return {\n className,\n basePath,\n sourceFile,\n classDeclaration: node,\n operations,\n consumes,\n produces,\n };\n}\n\nfunction extractClassConsumes(node: ts.ClassDeclaration, checker: ts.TypeChecker): string[] | undefined {\n const decorator = findDecorator(node, \"Consumes\");\n if (!decorator) return undefined;\n\n const callExpr = decorator.expression;\n if (!ts.isCallExpression(callExpr)) return undefined;\n const args = callExpr.arguments;\n if (args.length === 0) return undefined;\n\n const firstArg = args[0];\n if (ts.isStringLiteral(firstArg)) {\n return [firstArg.text];\n }\n if (ts.isArrayLiteralExpression(firstArg)) {\n return firstArg.elements\n .filter(ts.isStringLiteral)\n .map(e => e.text);\n }\n return undefined;\n}\n\nfunction extractClassProduces(node: ts.ClassDeclaration, checker: ts.TypeChecker): string[] | undefined {\n const decorator = findDecorator(node, \"Produces\");\n if (!decorator) return undefined;\n\n const callExpr = decorator.expression;\n if (!ts.isCallExpression(callExpr)) return undefined;\n const args = callExpr.arguments;\n if (args.length === 0) return undefined;\n\n const firstArg = args[0];\n if (ts.isStringLiteral(firstArg)) {\n return [firstArg.text];\n }\n if (ts.isArrayLiteralExpression(firstArg)) {\n return firstArg.elements\n .filter(ts.isStringLiteral)\n .map(e => e.text);\n }\n return undefined;\n}\n\nfunction analyzeMethod(\n node: ts.MethodDeclaration,\n className: string,\n checker: ts.TypeChecker\n): ScannedOperation | null {\n const methodName = ts.isIdentifier(node.name) ? node.name.text : null;\n if (!methodName) return null;\n\n const httpMethods = [\"Get\", \"Post\", \"Put\", \"Patch\", \"Delete\"];\n let httpMethod: string | null = null;\n let path = \"/\";\n\n for (const method of httpMethods) {\n const decorator = findDecorator(node, method);\n if (decorator) {\n httpMethod = method.toUpperCase();\n path = extractDecoratorStringArg(decorator) ?? \"/\";\n break;\n }\n }\n\n if (!httpMethod) return null;\n\n const signature = checker.getSignatureFromDeclaration(node);\n if (!signature) return null;\n\n let returnType = checker.getReturnTypeOfSignature(signature);\n returnType = unwrapPromise(returnType, checker);\n\n const parameters: ScannedParameter[] = [];\n for (let i = 0; i < node.parameters.length; i++) {\n const param = node.parameters[i];\n const paramName = ts.isIdentifier(param.name) ? param.name.text : `arg${i}`;\n const paramType = checker.getTypeAtLocation(param);\n const isOptional = !!param.questionToken || !!param.initializer;\n\n parameters.push({\n name: paramName,\n index: i,\n type: paramType,\n isOptional,\n paramNode: param,\n });\n }\n\n const pathParamNames = extractPathParams(path);\n const pathParamIndices = matchPathParamsToIndices(pathParamNames, parameters);\n \n const { bodyParamIndex, queryParamIndices, queryObjectParamIndex, headerObjectParamIndex, cookieObjectParamIndex, bodyContentType } = \n classifyParameters(parameters, httpMethod, pathParamIndices, checker);\n\n return {\n methodName,\n httpMethod,\n path,\n operationId: defaultOperationId(className, methodName),\n methodDeclaration: node,\n returnType,\n parameters,\n pathParamIndices,\n bodyParamIndex,\n queryParamIndices,\n queryObjectParamIndex,\n headerObjectParamIndex,\n cookieObjectParamIndex,\n bodyContentType,\n };\n}\n\nfunction extractPathParams(path: string): string[] {\n const matches = path.match(/:([^/]+)/g);\n if (!matches) return [];\n return matches.map(m => m.slice(1));\n}\n\nfunction matchPathParamsToIndices(pathParamNames: string[], parameters: ScannedParameter[]): number[] {\n const indices: number[] = [];\n for (const name of pathParamNames) {\n const param = parameters.find(p => p.name === name);\n if (param) {\n indices.push(param.index);\n }\n }\n return indices;\n}\n\nfunction classifyParameters(\n parameters: ScannedParameter[],\n httpMethod: string,\n pathParamIndices: number[],\n checker: ts.TypeChecker\n): {\n bodyParamIndex: number | null;\n queryParamIndices: number[];\n queryObjectParamIndex: number | null;\n headerObjectParamIndex: number | null;\n cookieObjectParamIndex: number | null;\n bodyContentType: string | undefined;\n} {\n const usedIndices = new Set(pathParamIndices);\n const queryParamIndices: number[] = [];\n let bodyParamIndex: number | null = null;\n let queryObjectParamIndex: number | null = null;\n let headerObjectParamIndex: number | null = null;\n let cookieObjectParamIndex: number | null = null;\n\n const isBodyMethod = [\"POST\", \"PUT\", \"PATCH\"].includes(httpMethod);\n\n for (let i = 0; i < parameters.length; i++) {\n const param = parameters[i];\n if (usedIndices.has(i)) continue;\n\n const nonNullableType = checker.getNonNullableType(param.type);\n const typeStr = getTypeName(param.type) || getTypeName(nonNullableType);\n\n if (typeStr === \"Body\") {\n bodyParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n if (typeStr === \"Query\") {\n queryObjectParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n if (typeStr === \"Headers\") {\n headerObjectParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n if (typeStr === \"Cookies\") {\n cookieObjectParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n if (isBodyMethod && bodyParamIndex === null) {\n bodyParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n const isObj = isObjectType(nonNullableType, checker);\n if (isObj && queryObjectParamIndex === null && !isBodyMethod) {\n queryObjectParamIndex = i;\n usedIndices.add(i);\n continue;\n }\n\n queryParamIndices.push(i);\n usedIndices.add(i);\n }\n\n return {\n bodyParamIndex,\n queryParamIndices,\n queryObjectParamIndex,\n headerObjectParamIndex,\n cookieObjectParamIndex,\n bodyContentType: undefined,\n };\n}\n\nfunction isObjectType(type: ts.Type, checker: ts.TypeChecker): boolean {\n const objectFlags = (type.flags & ts.TypeFlags.Object) !== 0;\n if (!objectFlags) return false;\n\n const symbol = type.getSymbol();\n if (symbol?.getName() === \"__object\") return true;\n\n const properties = checker.getPropertiesOfType(type);\n if (properties.length > 0) return true;\n\n const callSignatures = type.getCallSignatures();\n if (callSignatures && callSignatures.length > 0) return false;\n\n return true;\n}\n\nfunction getTypeName(type: ts.Type): string {\n const aliasSymbol = (type as ts.TypeReference).aliasSymbol ?? (type as any).aliasSymbol;\n if (aliasSymbol) return aliasSymbol.getName();\n const symbol = type.getSymbol();\n return symbol?.getName() ?? \"\";\n}\n\nfunction findDecorator(node: ts.HasDecorators, name: string): ts.Decorator | null {\n const decorators = ts.getDecorators(node);\n if (!decorators) return null;\n\n for (const decorator of decorators) {\n if (ts.isCallExpression(decorator.expression)) {\n const expr = decorator.expression.expression;\n if (ts.isIdentifier(expr) && expr.text === name) {\n return decorator;\n }\n }\n }\n return null;\n}\n\nfunction extractDecoratorStringArg(decorator: ts.Decorator): string | null {\n if (ts.isCallExpression(decorator.expression)) {\n const arg = decorator.expression.arguments[0];\n if (arg && ts.isStringLiteral(arg)) {\n return arg.text;\n }\n }\n return null;\n}\n\nfunction unwrapPromise(type: ts.Type, checker: ts.TypeChecker): ts.Type {\n const symbol = type.getSymbol();\n if (symbol?.getName() === \"Promise\") {\n const typeArgs = (type as ts.TypeReference).typeArguments;\n if (typeArgs && typeArgs.length > 0) {\n return typeArgs[0];\n }\n }\n return type;\n}\n","export function defaultOperationId(controllerName: string, methodName: string): string {\n return `${controllerName}_${methodName}`;\n}\n","import ts from \"typescript\";\nimport type { ScannedController, ScannedOperation, ScannedParameter } from \"../analyze/scanControllers.js\";\nimport { typeToJsonSchema, createSchemaContext } from \"./typeToJsonSchema.js\";\nimport { extractPropertySchemaFragments, mergeFragments } from \"./extractAnnotations.js\";\nimport type { SchemaContext, JsonSchema } from \"./typeToJsonSchema.js\";\nimport { extractQueryStyleOptions } from \"../analyze/extractQueryStyle.js\";\n\nexport interface OpenAPI31 {\n openapi: \"3.1.0\";\n info: {\n title: string;\n version: string;\n };\n components: {\n schemas: Record<string, JsonSchema>;\n };\n paths: Record<string, Record<string, any>>;\n}\n\nexport function generateOpenAPI(\n controllers: ScannedController[],\n checker: ts.TypeChecker,\n options: { title?: string; version?: string } = {}\n): OpenAPI31 {\n const components = new Map<string, JsonSchema>();\n const ctx: SchemaContext = {\n checker,\n components,\n typeStack: new Set(),\n typeNameStack: [],\n };\n\n const paths: Record<string, Record<string, any>> = {};\n\n for (const controller of controllers) {\n for (const operation of controller.operations) {\n const fullPath = convertToOpenApiPath(controller.basePath, operation.path);\n\n if (!paths[fullPath]) {\n paths[fullPath] = {};\n }\n\n const method = operation.httpMethod.toLowerCase();\n paths[fullPath][method] = buildOperation(operation, ctx, controller.consumes);\n }\n }\n\n return {\n openapi: \"3.1.0\",\n info: {\n title: options.title ?? \"API\",\n version: options.version ?? \"1.0.0\",\n },\n components: {\n schemas: Object.fromEntries(components),\n },\n paths,\n };\n}\n\nfunction convertToOpenApiPath(basePath: string, path: string): string {\n const base = basePath.endsWith(\"/\") ? basePath.slice(0, -1) : basePath;\n const converted = path.replace(/:([^/]+)/g, \"{$1}\");\n return base + converted || \"/\";\n}\n\nfunction buildOperation(operation: ScannedOperation, ctx: SchemaContext, controllerConsumes?: string[]): any {\n const op: any = {\n operationId: operation.operationId,\n responses: {},\n };\n\n const parameters: any[] = [];\n\n buildPathParameters(operation, ctx, parameters);\n buildQueryParameters(operation, ctx, parameters);\n buildHeaderParameters(operation, ctx, parameters);\n buildCookieParameters(operation, ctx, parameters);\n\n if (parameters.length > 0) {\n op.parameters = parameters;\n }\n\n const responseSchema = typeToJsonSchema(operation.returnType, ctx);\n\n const status = operation.httpMethod === \"POST\" ? 201 : 200;\n op.responses[status] = {\n description: status === 201 ? \"Created\" : \"OK\",\n content: {\n \"application/json\": {\n schema: responseSchema,\n },\n },\n };\n\n if ([\"POST\", \"PUT\", \"PATCH\"].includes(operation.httpMethod) && operation.bodyParamIndex !== null) {\n const bodyParam = operation.parameters[operation.bodyParamIndex];\n if (bodyParam) {\n let bodySchema = typeToJsonSchema(bodyParam.type, ctx);\n bodySchema = mergeBodySchemaAnnotations(bodyParam, ctx, bodySchema);\n \n const contentType = operation.bodyContentType ?? controllerConsumes?.[0] ?? \"application/json\";\n \n const requestBody: any = {\n required: !bodyParam.isOptional,\n content: {},\n };\n\n if (contentType === \"multipart/form-data\") {\n requestBody.content[\"multipart/form-data\"] = {\n schema: bodySchema,\n };\n } else {\n requestBody.content[contentType] = {\n schema: bodySchema,\n };\n }\n\n op.requestBody = requestBody;\n }\n }\n\n return op;\n}\n\nfunction mergeBodySchemaAnnotations(\n bodyParam: ScannedParameter,\n ctx: SchemaContext,\n schema: JsonSchema\n): JsonSchema {\n if (!schema.properties) return schema;\n\n const typeSymbol = bodyParam.type.getSymbol();\n if (!typeSymbol) return schema;\n\n const declarations = typeSymbol.getDeclarations();\n if (!declarations || declarations.length === 0) return schema;\n\n const classDecl = declarations[0];\n if (!ts.isClassDeclaration(classDecl)) return schema;\n\n const result = { ...schema };\n const props = { ...result.properties as Record<string, JsonSchema> };\n\n for (const member of classDecl.members) {\n if (!ts.isPropertyDeclaration(member) || !member.name) continue;\n\n const propName = ts.isIdentifier(member.name) ? member.name.text : null;\n if (!propName) continue;\n if (!props[propName]) continue;\n\n const frags = extractPropertySchemaFragments(ctx.checker, member);\n if (frags.length > 0) {\n props[propName] = mergeFragments(props[propName] as Record<string, unknown>, ...frags) as JsonSchema;\n }\n }\n\n result.properties = props;\n return result;\n}\n\nfunction buildPathParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void {\n for (const paramIndex of operation.pathParamIndices) {\n const param = operation.parameters[paramIndex];\n if (param) {\n let paramSchema = typeToJsonSchema(param.type, ctx);\n if (param.paramNode) {\n const frags = extractPropertySchemaFragments(ctx.checker, param.paramNode);\n if (frags.length > 0) {\n paramSchema = mergeFragments(paramSchema as Record<string, unknown>, ...frags) as JsonSchema;\n }\n }\n parameters.push({\n name: param.name,\n in: \"path\",\n required: !param.isOptional,\n schema: paramSchema.$ref\n ? { type: \"string\", $ref: paramSchema.$ref }\n : paramSchema,\n });\n }\n }\n}\n\nfunction buildQueryParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void {\n if (operation.queryObjectParamIndex !== null) {\n const queryParam = operation.parameters[operation.queryObjectParamIndex];\n if (!queryParam) return;\n\n const queryStyle = extractQueryStyleOptions(ctx.checker, operation.methodDeclaration);\n const querySchema = typeToJsonSchema(queryParam.type, ctx);\n if (queryStyle?.style === \"deepObject\") {\n const explode = queryStyle.explode ?? true;\n const deepParam: Record<string, unknown> = {\n name: queryParam.name,\n in: \"query\",\n required: !queryParam.isOptional,\n schema: querySchema.$ref ? { $ref: querySchema.$ref } : querySchema,\n style: \"deepObject\",\n explode,\n };\n if (queryStyle.allowReserved !== undefined) {\n deepParam.allowReserved = queryStyle.allowReserved;\n }\n parameters.push(deepParam);\n } else {\n if (!querySchema.properties) return;\n\n const queryObjProps = querySchema.properties;\n for (const [propName, propSchema] of Object.entries(queryObjProps as Record<string, any>)) {\n const isRequired = querySchema.required?.includes(propName) ?? false;\n const serialization = determineQuerySerialization(propSchema.type);\n parameters.push({\n name: propName,\n in: \"query\",\n required: isRequired,\n schema: propSchema,\n ...(Object.keys(serialization).length > 0 ? serialization : {}),\n });\n }\n }\n }\n\n for (const paramIndex of operation.queryParamIndices) {\n const param = operation.parameters[paramIndex];\n if (param) {\n let paramSchema = typeToJsonSchema(param.type, ctx);\n if (param.paramNode) {\n const frags = extractPropertySchemaFragments(ctx.checker, param.paramNode);\n if (frags.length > 0) {\n paramSchema = mergeFragments(paramSchema as Record<string, unknown>, ...frags) as JsonSchema;\n }\n }\n const serialization = determineQuerySerialization(paramSchema.type);\n parameters.push({\n name: param.name,\n in: \"query\",\n required: !param.isOptional,\n schema: paramSchema.$ref\n ? { type: \"string\", $ref: paramSchema.$ref }\n : paramSchema,\n ...(Object.keys(serialization).length > 0 ? serialization : {}),\n });\n }\n }\n}\n\nfunction determineQuerySerialization(schemaType: string | string[] | undefined): { style?: string; explode?: boolean } {\n const typeArray = Array.isArray(schemaType) ? schemaType : schemaType ? [schemaType] : [];\n const isArray = typeArray.includes(\"array\");\n \n if (isArray) {\n return { style: \"form\", explode: true };\n }\n \n return {};\n}\n\nfunction buildHeaderParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void {\n if (operation.headerObjectParamIndex === null) return;\n\n const headerParam = operation.parameters[operation.headerObjectParamIndex];\n if (!headerParam) return;\n\n const headerSchema = typeToJsonSchema(headerParam.type, ctx);\n if (!headerSchema.properties) return;\n\n const headerObjProps = headerSchema.properties;\n for (const [propName, propSchema] of Object.entries(headerObjProps as Record<string, any>)) {\n const isRequired = headerSchema.required?.includes(propName) ?? false;\n parameters.push({\n name: propName,\n in: \"header\",\n required: isRequired,\n schema: propSchema,\n });\n }\n}\n\nfunction buildCookieParameters(operation: ScannedOperation, ctx: SchemaContext, parameters: any[]): void {\n if (operation.cookieObjectParamIndex === null) return;\n\n const cookieParam = operation.parameters[operation.cookieObjectParamIndex];\n if (!cookieParam) return;\n\n const cookieSchema = typeToJsonSchema(cookieParam.type, ctx);\n if (!cookieSchema.properties) return;\n\n const cookieObjProps = cookieSchema.properties;\n for (const [propName, propSchema] of Object.entries(cookieObjProps as Record<string, any>)) {\n const isRequired = cookieSchema.required?.includes(propName) ?? false;\n parameters.push({\n name: propName,\n in: \"cookie\",\n required: isRequired,\n schema: propSchema,\n style: \"form\",\n explode: true,\n });\n }\n}\n","import ts from \"typescript\";\n\nexport interface JsonSchema {\n type?: string | string[];\n properties?: Record<string, JsonSchema>;\n required?: string[];\n items?: JsonSchema;\n enum?: (string | number | boolean)[];\n $ref?: string;\n nullable?: boolean;\n description?: string;\n default?: unknown;\n examples?: unknown[];\n example?: unknown;\n anyOf?: JsonSchema[];\n oneOf?: JsonSchema[];\n allOf?: JsonSchema[];\n discriminator?: DiscriminatorObject;\n additionalProperties?: boolean | JsonSchema;\n unevaluatedProperties?: boolean | JsonSchema;\n format?: string;\n pattern?: string;\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n minLength?: number;\n maxLength?: number;\n minItems?: number;\n maxItems?: number;\n minProperties?: number;\n maxProperties?: number;\n multipleOf?: number;\n const?: unknown;\n uniqueItems?: boolean;\n title?: string;\n}\n\nexport interface DiscriminatorObject {\n propertyName: string;\n mapping?: Record<string, string>;\n}\n\nexport interface SchemaContext {\n checker: ts.TypeChecker;\n components: Map<string, JsonSchema>;\n typeStack: Set<ts.Type>;\n typeNameStack: string[];\n}\n\nexport function typeToJsonSchema(\n type: ts.Type,\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const { checker } = ctx;\n\n if (type.flags & ts.TypeFlags.Undefined) {\n return {};\n }\n if (type.flags & ts.TypeFlags.Null) {\n return { type: \"null\" };\n }\n if (isDateType(type, checker)) {\n return { type: \"string\", format: \"date-time\" };\n }\n\n if (type.flags & ts.TypeFlags.String) {\n return { type: \"string\" };\n }\n if (type.flags & ts.TypeFlags.Number) {\n return { type: \"number\" };\n }\n if (type.flags & ts.TypeFlags.Boolean) {\n return { type: \"boolean\" };\n }\n if (type.flags & ts.TypeFlags.BigInt) {\n return {\n type: \"string\",\n format: \"int64\",\n pattern: \"^-?\\\\d+$\"\n };\n }\n\n if (type.flags & ts.TypeFlags.StringLiteral) {\n const value = (type as ts.StringLiteralType).value;\n return { type: \"string\", enum: [value] };\n }\n if (type.flags & ts.TypeFlags.NumberLiteral) {\n const value = (type as ts.NumberLiteralType).value;\n return { type: \"number\", enum: [value] };\n }\n if (type.flags & ts.TypeFlags.BooleanLiteral) {\n const intrinsic = (type as any).intrinsicName;\n return { type: \"boolean\", enum: [intrinsic === \"true\"] };\n }\n\n if (type.isUnion()) {\n return handleUnion(type.types, ctx, typeNode);\n }\n\n if (type.isIntersection()) {\n return handleIntersection(type.types, ctx, typeNode);\n }\n\n if (checker.isArrayType(type)) {\n const typeArgs = (type as ts.TypeReference).typeArguments;\n const itemType = typeArgs?.[0];\n const items = itemType ? typeToJsonSchema(itemType, ctx) : {};\n return {\n type: \"array\",\n items,\n uniqueItems: isSetType(type, checker) ? true : undefined,\n };\n }\n\n if (type.flags & ts.TypeFlags.Object) {\n return handleObjectType(type as ts.ObjectType, ctx, typeNode);\n }\n\n return {};\n}\n\nfunction isDateType(type: ts.Type, checker: ts.TypeChecker): boolean {\n const symbol = type.getSymbol();\n const aliasSymbol = (type as any).aliasSymbol as ts.Symbol | undefined;\n if (aliasSymbol && (aliasSymbol.flags & ts.SymbolFlags.Alias)) {\n const aliased = checker.getAliasedSymbol(aliasSymbol);\n return aliased?.getName() === \"Date\";\n }\n\n if (symbol && (symbol.flags & ts.SymbolFlags.Alias)) {\n const aliased = checker.getAliasedSymbol(symbol);\n return aliased?.getName() === \"Date\";\n }\n\n return symbol?.getName() === \"Date\";\n}\n\nfunction isSetType(type: ts.Type, checker: ts.TypeChecker): boolean {\n const symbol = type.getSymbol();\n if (!symbol) return false;\n const name = symbol.getName();\n if (name === \"Set\") return true;\n return false;\n}\n\nfunction handleUnion(\n types: readonly ts.Type[],\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const nullType = types.find(t => t.flags & ts.TypeFlags.Null);\n const otherTypes = types.filter(t => !(t.flags & ts.TypeFlags.Null) && !(t.flags & ts.TypeFlags.Undefined));\n\n const allStringLiterals = otherTypes.every(t => t.flags & ts.TypeFlags.StringLiteral);\n if (allStringLiterals && otherTypes.length > 0) {\n const enumValues = otherTypes.map(t => (t as ts.StringLiteralType).value);\n const schema: JsonSchema = { type: \"string\", enum: enumValues };\n if (nullType) {\n schema.type = [\"string\", \"null\"];\n }\n return schema;\n }\n\n if (otherTypes.length === 1 && nullType) {\n const innerSchema = typeToJsonSchema(otherTypes[0], ctx);\n if (typeof innerSchema.type === \"string\") {\n innerSchema.type = [innerSchema.type, \"null\"];\n }\n return innerSchema;\n }\n\n if (otherTypes.length > 1) {\n const branches = otherTypes.map(t => typeToJsonSchema(t, ctx));\n const hasNull = !!nullType;\n\n const result: JsonSchema = {};\n\n if (hasNull) {\n result.anyOf = [...branches, { type: \"null\" }];\n } else {\n result.anyOf = branches;\n }\n\n const discriminatorResult = detectDiscriminatedUnion(otherTypes, ctx, branches);\n if (discriminatorResult) {\n result.oneOf = branches;\n result.discriminator = discriminatorResult;\n }\n\n return result;\n }\n\n if (otherTypes.length === 1) {\n return typeToJsonSchema(otherTypes[0], ctx);\n }\n\n return {};\n}\n\nfunction handleIntersection(\n types: readonly ts.Type[],\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const brandCollapsed = tryCollapseBrandedIntersection(types, ctx, typeNode);\n if (brandCollapsed) {\n return brandCollapsed;\n }\n\n const allOf: JsonSchema[] = [];\n for (const t of types) {\n allOf.push(typeToJsonSchema(t, ctx));\n }\n\n return { allOf };\n}\n\nfunction tryCollapseBrandedIntersection(\n types: readonly ts.Type[],\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema | null {\n const { checker } = ctx;\n const parts = [...types];\n\n const prim = parts.find(isPrimitiveLike);\n if (!prim) return null;\n\n const rest = parts.filter(p => p !== prim);\n if (rest.every(r => isBrandObject(checker, r, ctx))) {\n return typeToJsonSchema(prim, ctx);\n }\n\n return null;\n}\n\nfunction isPrimitiveLike(t: ts.Type): boolean {\n return (t.flags & (ts.TypeFlags.String | ts.TypeFlags.Number | ts.TypeFlags.Boolean | ts.TypeFlags.BigInt)) !== 0\n || (t.flags & ts.TypeFlags.StringLiteral) !== 0\n || (t.flags & ts.TypeFlags.NumberLiteral) !== 0;\n}\n\nfunction isBrandObject(checker: ts.TypeChecker, t: ts.Type, ctx: SchemaContext): boolean {\n if (!(t.flags & ts.TypeFlags.Object)) return false;\n\n const props = t.getProperties();\n if (props.length === 0) return false;\n\n const allowed = new Set([\"__brand\", \"__type\", \"__tag\", \"brand\"]);\n for (const p of props) {\n if (!allowed.has(p.getName())) return false;\n }\n\n const callSigs = (t as ts.ObjectType).getCallSignatures?.();\n if (callSigs && callSigs.length > 0) return false;\n\n const constructSigs = (t as ts.ObjectType).getConstructSignatures?.();\n if (constructSigs && constructSigs.length > 0) return false;\n\n return true;\n}\n\nfunction detectDiscriminatedUnion(\n types: readonly ts.Type[],\n ctx: SchemaContext,\n branches: JsonSchema[]\n): DiscriminatorObject | null {\n if (types.length < 2) return null;\n\n const candidates = findCommonPropertyNames(ctx.checker, types);\n for (const propName of candidates) {\n const requiredInAll = types.every(t => isRequiredProperty(ctx.checker, t, propName));\n if (!requiredInAll) continue;\n\n const literalSets = types.map(t => getPropertyLiteralValues(ctx.checker, t, propName));\n if (literalSets.some(s => s === null)) continue;\n\n const allSets = literalSets as Array<Set<string>>;\n if (!areSetsDisjoint(allSets)) continue;\n\n const mapping: Record<string, string> = {};\n for (let i = 0; i < types.length; i++) {\n const branchName = getBranchSchemaName(types[i], ctx);\n for (const val of allSets[i]) {\n mapping[val] = `#/components/schemas/${branchName}`;\n }\n }\n\n return { propertyName: propName, mapping };\n }\n\n return null;\n}\n\nfunction findCommonPropertyNames(checker: ts.TypeChecker, types: readonly ts.Type[]): string[] {\n if (types.length === 0) return [];\n\n const firstProps = types[0].getProperties().map(s => s.getName());\n return firstProps.filter(name =>\n types.every(m => !!checker.getPropertyOfType(m, name))\n );\n}\n\nfunction isRequiredProperty(checker: ts.TypeChecker, type: ts.Type, propName: string): boolean {\n const sym = checker.getPropertyOfType(type, propName);\n if (!sym) return false;\n\n if (sym.flags & ts.SymbolFlags.Optional) return false;\n\n const propType = checker.getTypeOfSymbol(sym);\n if (propType.isUnion?.()) {\n const hasUndefined = propType.types.some(t => (t.flags & ts.TypeFlags.Undefined) !== 0);\n if (hasUndefined) return false;\n }\n\n return true;\n}\n\nfunction getPropertyLiteralValues(checker: ts.TypeChecker, type: ts.Type, propName: string): Set<string> | null {\n const sym = checker.getPropertyOfType(type, propName);\n if (!sym) return null;\n\n const propType = checker.getTypeOfSymbol(sym);\n\n if (propType.isStringLiteral?.()) {\n return new Set([(propType as ts.StringLiteralType).value]);\n }\n\n if (propType.isUnion?.()) {\n const values = new Set<string>();\n for (const m of propType.types) {\n if (!m.isStringLiteral?.()) return null;\n values.add((m as ts.StringLiteralType).value);\n }\n return values;\n }\n\n return null;\n}\n\nfunction areSetsDisjoint(sets: Array<Set<string>>): boolean {\n const seen = new Set<string>();\n for (const s of sets) {\n for (const v of s) {\n if (seen.has(v)) return false;\n seen.add(v);\n }\n }\n return true;\n}\n\nfunction getBranchSchemaName(type: ts.Type, ctx: SchemaContext): string {\n const symbol = type.getSymbol();\n if (symbol) {\n return symbol.getName();\n }\n\n const aliasSymbol = (type as any).aliasSymbol;\n if (aliasSymbol) {\n return aliasSymbol.getName();\n }\n\n return `Anonymous_${ctx.typeNameStack.length}`;\n}\n\nfunction handleObjectType(\n type: ts.ObjectType,\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const { checker, components, typeStack } = ctx;\n const symbol = type.getSymbol();\n const typeName = symbol?.getName?.() ?? getTypeNameFromNode(typeNode, ctx);\n\n if (typeName && typeName !== \"__type\") {\n if (components.has(typeName)) {\n return { $ref: `#/components/schemas/${typeName}` };\n }\n\n if (typeStack.has(type)) {\n return { $ref: `#/components/schemas/${typeName}` };\n }\n\n typeStack.add(type);\n }\n\n const schema = buildObjectSchema(type, ctx, typeNode);\n\n if (typeName && typeName !== \"__type\") {\n typeStack.delete(type);\n if (!components.has(typeName)) {\n components.set(typeName, schema);\n }\n return { $ref: `#/components/schemas/${typeName}` };\n }\n\n typeStack.delete(type);\n return schema;\n}\n\nfunction getTypeId(type: ts.Type, typeName: string): string {\n const typeFlags = type.flags.toString();\n return `${typeName}_${typeFlags}`;\n}\n\nfunction getTypeNameFromNode(typeNode: ts.TypeNode | undefined, ctx: SchemaContext): string {\n if (!typeNode) return `Anonymous_${ctx.typeNameStack.length}`;\n\n if (ts.isTypeReferenceNode(typeNode)) {\n if (ts.isIdentifier(typeNode.typeName)) {\n return typeNode.typeName.text;\n }\n }\n\n if (ts.isTypeAliasDeclaration(typeNode.parent)) {\n if (ts.isIdentifier(typeNode.parent.name)) {\n return typeNode.parent.name.text;\n }\n }\n\n return `Anonymous_${ctx.typeNameStack.length}`;\n}\n\nfunction buildObjectSchema(\n type: ts.ObjectType,\n ctx: SchemaContext,\n typeNode?: ts.TypeNode\n): JsonSchema {\n const { checker } = ctx;\n\n const properties: Record<string, JsonSchema> = {};\n const required: string[] = [];\n\n const props = checker.getPropertiesOfType(type);\n for (const prop of props) {\n const propName = prop.getName();\n const propType = checker.getTypeOfSymbol(prop);\n const isOptional = !!(prop.flags & ts.SymbolFlags.Optional);\n\n properties[propName] = typeToJsonSchema(propType, ctx);\n\n if (!isOptional) {\n required.push(propName);\n }\n }\n\n const schema: JsonSchema = {\n type: \"object\",\n properties,\n };\n\n if (required.length > 0) {\n schema.required = required;\n }\n\n if (isRecordType(type, checker)) {\n const valueType = getRecordValueType(type, checker);\n if (valueType) {\n schema.additionalProperties = typeToJsonSchema(valueType, ctx);\n }\n }\n\n return schema;\n}\n\nfunction isRecordType(type: ts.ObjectType, checker: ts.TypeChecker): boolean {\n const symbol = type.getSymbol();\n if (!symbol) return false;\n\n const name = symbol.getName();\n if (name === \"Record\") return true;\n\n return false;\n}\n\nfunction getRecordValueType(type: ts.ObjectType, checker: ts.TypeChecker): ts.Type | null {\n const symbol = type.getSymbol();\n if (!symbol) return null;\n\n const name = symbol.getName();\n if (name === \"Record\") {\n const typeRef = type as ts.TypeReference;\n const typeArgs = typeRef.typeArguments;\n if (typeArgs && typeArgs.length >= 2) {\n return typeArgs[1];\n }\n }\n\n return null;\n}\n\nexport function createSchemaContext(checker: ts.TypeChecker): SchemaContext {\n return {\n checker,\n components: new Map(),\n typeStack: new Set(),\n typeNameStack: [],\n };\n}\n","import ts from \"typescript\";\n\nexport interface SchemaFragment {\n [key: string]: unknown;\n}\n\nexport function extractPropertySchemaFragments(\n checker: ts.TypeChecker,\n prop: ts.PropertyDeclaration | ts.ParameterDeclaration\n): SchemaFragment[] {\n if (!ts.canHaveDecorators(prop)) return [];\n\n const decs = ts.getDecorators(prop);\n if (!decs || decs.length === 0) return [];\n\n const frags: SchemaFragment[] = [];\n\n for (const d of decs) {\n const expr = d.expression;\n\n let callee: ts.Expression;\n let args: ts.NodeArray<ts.Expression>;\n\n if (ts.isCallExpression(expr)) {\n callee = expr.expression;\n args = expr.arguments;\n } else {\n callee = expr;\n args = ts.factory.createNodeArray([]);\n }\n\n const sym = checker.getSymbolAtLocation(callee);\n if (!sym) continue;\n\n const resolved = resolveImportedDecorator(checker, sym);\n if (!resolved || resolved.module !== \"adorn-api/schema\") continue;\n\n const name = resolved.name;\n\n if (name === \"Schema\") {\n const obj = args[0];\n if (obj && ts.isObjectLiteralExpression(obj)) {\n const frag = objectLiteralToJson(obj);\n if (frag) frags.push(frag);\n }\n continue;\n }\n\n if (name === \"Min\" && isNumberLiteral(args[0])) {\n frags.push({ minimum: Number(args[0].text) });\n } else if (name === \"Max\" && isNumberLiteral(args[0])) {\n frags.push({ maximum: Number(args[0].text) });\n } else if (name === \"ExclusiveMin\" && isNumberLiteral(args[0])) {\n frags.push({ exclusiveMinimum: Number(args[0].text) });\n } else if (name === \"ExclusiveMax\" && isNumberLiteral(args[0])) {\n frags.push({ exclusiveMaximum: Number(args[0].text) });\n } else if (name === \"MinLength\" && isNumberLiteral(args[0])) {\n frags.push({ minLength: Number(args[0].text) });\n } else if (name === \"MaxLength\" && isNumberLiteral(args[0])) {\n frags.push({ maxLength: Number(args[0].text) });\n } else if (name === \"Format\" && isStringLiteral(args[0])) {\n frags.push({ format: args[0].text });\n } else if (name === \"Pattern\") {\n const arg = args[0];\n if (arg && ts.isRegularExpressionLiteral(arg)) {\n frags.push({ pattern: extractRegexPattern(arg.text) });\n } else if (isStringLiteral(arg)) {\n frags.push({ pattern: arg.text });\n }\n } else if (name === \"MinItems\" && isNumberLiteral(args[0])) {\n frags.push({ minItems: Number(args[0].text) });\n } else if (name === \"MaxItems\" && isNumberLiteral(args[0])) {\n frags.push({ maxItems: Number(args[0].text) });\n } else if (name === \"MinProperties\" && isNumberLiteral(args[0])) {\n frags.push({ minProperties: Number(args[0].text) });\n } else if (name === \"MaxProperties\" && isNumberLiteral(args[0])) {\n frags.push({ maxProperties: Number(args[0].text) });\n } else if (name === \"MultipleOf\" && isNumberLiteral(args[0])) {\n frags.push({ multipleOf: Number(args[0].text) });\n } else if (name === \"Example\") {\n frags.push({ example: literalToJson(args[0]) });\n } else if (name === \"Examples\" && ts.isArrayLiteralExpression(args[0])) {\n frags.push({ examples: args[0].elements.map(e => literalToJson(e)) });\n } else if (name === \"Description\" && isStringLiteral(args[0])) {\n frags.push({ description: args[0].text });\n } else if (name === \"Enum\" && ts.isArrayLiteralExpression(args[0])) {\n frags.push({ enum: args[0].elements.map(e => literalToJson(e)) });\n } else if (name === \"Const\") {\n frags.push({ const: literalToJson(args[0]) });\n } else if (name === \"Default\") {\n frags.push({ default: literalToJson(args[0]) });\n } else if (name === \"AdditionalProperties\") {\n const arg = args[0];\n if (arg && (arg.kind === ts.SyntaxKind.FalseKeyword || arg.kind === ts.SyntaxKind.TrueKeyword)) {\n frags.push({ additionalProperties: arg.kind === ts.SyntaxKind.TrueKeyword });\n } else if (arg && ts.isObjectLiteralExpression(arg)) {\n const obj = objectLiteralToJson(arg);\n if (obj) frags.push({ additionalProperties: obj });\n }\n } else if (name === \"Closed\") {\n frags.push({ additionalProperties: false });\n } else if (name === \"ClosedUnevaluated\") {\n frags.push({ unevaluatedProperties: false });\n }\n }\n\n return frags;\n}\n\nfunction resolveImportedDecorator(\n checker: ts.TypeChecker,\n sym: ts.Symbol\n): { module: string; name: string } | null {\n const target = (sym.flags & ts.SymbolFlags.Alias) ? checker.getAliasedSymbol(sym) : sym;\n const name = target.getName();\n\n const decl = target.declarations?.[0];\n if (!decl) return null;\n\n const fileName = decl.getSourceFile().fileName.replace(/\\\\/g, \"/\");\n\n if (fileName.includes(\"/node_modules/adorn-api/\") || fileName.includes(\"/src/schema/\")) {\n return { module: \"adorn-api/schema\", name };\n }\n\n return null;\n}\n\nfunction isNumberLiteral(node: ts.Node | undefined): node is ts.NumericLiteral {\n return !!node && ts.isNumericLiteral(node);\n}\n\nfunction isStringLiteral(node: ts.Node | undefined): node is ts.StringLiteral {\n return !!node && ts.isStringLiteral(node);\n}\n\nfunction extractRegexPattern(text: string): string {\n const match = text.match(/^\\/(.+)\\/[gimsuy]*$/);\n return match ? match[1] : text;\n}\n\nfunction objectLiteralToJson(obj: ts.ObjectLiteralExpression): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const prop of obj.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const name = prop.name;\n let key: string;\n if (ts.isIdentifier(name)) {\n key = name.text;\n } else if (ts.isStringLiteral(name)) {\n key = name.text;\n } else {\n continue;\n }\n out[key] = literalToJson(prop.initializer);\n }\n return out;\n}\n\nfunction literalToJson(node: ts.Expression): unknown {\n if (ts.isStringLiteral(node)) return node.text;\n if (ts.isNumericLiteral(node)) return Number(node.text);\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (node.kind === ts.SyntaxKind.NullKeyword) return null;\n if (ts.isObjectLiteralExpression(node)) return objectLiteralToJson(node);\n if (ts.isArrayLiteralExpression(node)) return node.elements.map(e => literalToJson(e));\n return undefined;\n}\n\nexport function mergeFragments(base: Record<string, unknown>, ...frags: SchemaFragment[]): Record<string, unknown> {\n const result = { ...base };\n for (const frag of frags) {\n Object.assign(result, frag);\n }\n return result;\n}\n\nexport function extractJSDocDescription(checker: ts.TypeChecker, node: ts.Node): string | undefined {\n const sourceFile = node.getSourceFile();\n const docComments = ts.getLeadingCommentRanges(sourceFile.fileName, node.pos);\n if (!docComments || docComments.length === 0) return undefined;\n\n const sourceText = sourceFile.getText();\n let fullComment = \"\";\n\n for (const commentRange of docComments) {\n const comment = sourceText.substring(commentRange.pos, commentRange.end);\n const cleanComment = comment\n .replace(/^\\/\\*\\*/, \"\")\n .replace(/\\*\\/$/, \"\")\n .replace(/^\\s*\\*\\s?/gm, \"\")\n .trim();\n fullComment += cleanComment + \"\\n\";\n }\n\n return fullComment.trim() || undefined;\n}\n\nexport function extractJSDocTags(checker: ts.TypeChecker, node: ts.Node): Record<string, unknown> {\n const tags: Record<string, unknown> = {};\n\n const jsDocTags = ts.getJSDocTags(node);\n if (!jsDocTags) return tags;\n\n for (const tag of jsDocTags) {\n const tagName = tag.tagName.text;\n\n if (tagName === \"example\") {\n const exampleComment = getTagComment(tag);\n if (exampleComment) {\n const existing = (tags.examples as string[]) ?? [];\n tags.examples = [...existing, exampleComment];\n }\n } else if (tagName === \"default\") {\n const defaultComment = getTagComment(tag);\n if (defaultComment) {\n tags.default = parseDefaultValue(defaultComment);\n }\n } else if (tagName === \"description\") {\n const desc = getTagComment(tag);\n if (desc) {\n tags.description = desc;\n }\n } else if (tagName === \"deprecated\") {\n tags.deprecated = true;\n }\n }\n\n return tags;\n}\n\nfunction getTagComment(tag: ts.JSDocTag): string | undefined {\n const comment = tag.comment;\n if (typeof comment === \"string\") {\n return comment.trim();\n }\n if (comment && Array.isArray(comment) && comment.length > 0) {\n return comment.map(c => typeof c === \"string\" ? c : c.text).join(\" \").trim();\n }\n return undefined;\n}\n\nfunction parseDefaultValue(comment: string): unknown {\n const trimmed = comment.trim();\n\n if (trimmed === \"true\") return true;\n if (trimmed === \"false\") return false;\n if (trimmed === \"null\") return null;\n\n const num = Number(trimmed);\n if (!isNaN(num) && trimmed === num.toString()) return num;\n\n if ((trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))) {\n return trimmed.slice(1, -1);\n }\n\n return trimmed;\n}\n\nexport function extractClassSchemaFragments(\n checker: ts.TypeChecker,\n classDecl: ts.ClassDeclaration\n): SchemaFragment[] {\n const frags: SchemaFragment[] = [];\n\n if (!ts.canHaveDecorators(classDecl)) return [];\n\n const decs = ts.getDecorators(classDecl);\n if (!decs || decs.length === 0) return frags;\n\n for (const d of decs) {\n const expr = d.expression;\n\n let callee: ts.Expression;\n let args: ts.NodeArray<ts.Expression>;\n\n if (ts.isCallExpression(expr)) {\n callee = expr.expression;\n args = expr.arguments;\n } else {\n callee = expr;\n args = ts.factory.createNodeArray([]);\n }\n\n const sym = checker.getSymbolAtLocation(callee);\n if (!sym) continue;\n\n const resolved = resolveImportedDecorator(checker, sym);\n if (!resolved || resolved.module !== \"adorn-api/schema\") continue;\n\n const name = resolved.name;\n\n if (name === \"Schema\") {\n const obj = args[0];\n if (obj && ts.isObjectLiteralExpression(obj)) {\n const frag = objectLiteralToJson(obj);\n if (frag) frags.push(frag);\n }\n } else if (name === \"Description\" && isStringLiteral(args[0])) {\n frags.push({ description: args[0].text });\n } else if (name === \"Example\") {\n frags.push({ example: literalToJson(args[0]) });\n } else if (name === \"Examples\" && ts.isArrayLiteralExpression(args[0])) {\n frags.push({ examples: args[0].elements.map(e => literalToJson(e)) });\n } else if (name === \"Closed\") {\n frags.push({ additionalProperties: false });\n } else if (name === \"ClosedUnevaluated\") {\n frags.push({ unevaluatedProperties: false });\n }\n }\n\n const jsDocDesc = extractJSDocDescription(checker, classDecl);\n if (jsDocDesc) {\n frags.push({ description: jsDocDesc });\n }\n\n const jsDocTags = extractJSDocTags(checker, classDecl);\n if (Object.keys(jsDocTags).length > 0) {\n frags.push(jsDocTags);\n }\n\n return frags;\n}\n","import ts from \"typescript\";\n\nexport interface QueryStyleOptions {\n style?: \"form\" | \"spaceDelimited\" | \"pipeDelimited\" | \"deepObject\";\n explode?: boolean;\n allowReserved?: boolean;\n}\n\nexport function extractQueryStyleOptions(\n checker: ts.TypeChecker,\n method: ts.MethodDeclaration\n): QueryStyleOptions | null {\n if (!ts.canHaveDecorators(method)) return null;\n const decorators = ts.getDecorators(method);\n if (!decorators || decorators.length === 0) return null;\n\n for (const decorator of decorators) {\n const expr = decorator.expression;\n const isCall = ts.isCallExpression(expr);\n const callee = isCall ? expr.expression : expr;\n const args = isCall ? expr.arguments : ts.factory.createNodeArray([]);\n\n const sym = checker.getSymbolAtLocation(callee);\n if (!sym) continue;\n\n const resolved = (sym.flags & ts.SymbolFlags.Alias) ? checker.getAliasedSymbol(sym) : sym;\n const name = resolved.getName();\n if (name !== \"QueryStyle\") continue;\n\n const optsNode = args[0];\n if (!optsNode || !ts.isObjectLiteralExpression(optsNode)) {\n return {};\n }\n\n return parseQueryStyleOptions(optsNode);\n }\n\n return null;\n}\n\nfunction parseQueryStyleOptions(node: ts.ObjectLiteralExpression): QueryStyleOptions {\n const opts: QueryStyleOptions = {};\n\n for (const prop of node.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const name = getPropName(prop.name);\n if (!name) continue;\n\n if (name === \"style\" && ts.isStringLiteral(prop.initializer)) {\n const style = prop.initializer.text as QueryStyleOptions[\"style\"];\n opts.style = style;\n } else if (name === \"explode\" && isBooleanLiteral(prop.initializer)) {\n opts.explode = prop.initializer.kind === ts.SyntaxKind.TrueKeyword;\n } else if (name === \"allowReserved\" && isBooleanLiteral(prop.initializer)) {\n opts.allowReserved = prop.initializer.kind === ts.SyntaxKind.TrueKeyword;\n }\n }\n\n return opts;\n}\n\nfunction getPropName(name: ts.PropertyName): string | null {\n if (ts.isIdentifier(name)) return name.text;\n if (ts.isStringLiteral(name)) return name.text;\n return null;\n}\n\nfunction isBooleanLiteral(node: ts.Expression): node is ts.BooleanLiteral {\n return node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword;\n}\n","import type { ScannedController, ScannedOperation } from \"../analyze/scanControllers.js\";\nimport type { ManifestV1, ControllerEntry, OperationEntry, ArgsSpec, HttpMethod } from \"./format.js\";\nimport { typeToJsonSchema } from \"../schema/typeToJsonSchema.js\";\nimport type { SchemaContext } from \"../schema/typeToJsonSchema.js\";\nimport { extractQueryStyleOptions } from \"../analyze/extractQueryStyle.js\";\nimport ts from \"typescript\";\n\ntype ValidationMode = \"none\" | \"ajv-runtime\" | \"precompiled\";\n\nexport function generateManifest(\n controllers: ScannedController[],\n checker: ts.TypeChecker,\n version: string,\n validationMode: ValidationMode = \"ajv-runtime\"\n): ManifestV1 {\n const components = new Map<string, any>();\n const ctx: SchemaContext = {\n checker,\n components,\n typeStack: new Set(),\n typeNameStack: [],\n };\n\n const controllerEntries: ControllerEntry[] = controllers.map(ctrl => ({\n controllerId: ctrl.className,\n basePath: ctrl.basePath,\n operations: ctrl.operations.map(op => buildOperationEntry(op, ctx)),\n }));\n\n const validationConfig: { mode: \"none\" | \"ajv-runtime\" | \"precompiled\"; precompiledModule: string | null } = \n validationMode === \"precompiled\"\n ? { mode: \"precompiled\", precompiledModule: null }\n : validationMode === \"none\"\n ? { mode: \"none\", precompiledModule: null }\n : { mode: \"ajv-runtime\", precompiledModule: null };\n\n return {\n manifestVersion: 1,\n generatedAt: new Date().toISOString(),\n generator: {\n name: \"adorn-api\",\n version,\n typescript: ts.version,\n },\n schemas: {\n kind: \"openapi-3.1\",\n file: \"./openapi.json\",\n componentsSchemasPointer: \"/components/schemas\",\n },\n validation: validationConfig,\n controllers: controllerEntries,\n };\n}\n\nfunction buildOperationEntry(op: ScannedOperation, ctx: SchemaContext): OperationEntry {\n const args: ArgsSpec = {\n body: null,\n path: [],\n query: [],\n headers: [],\n cookies: [],\n };\n\n buildPathArgs(op, ctx, args);\n buildQueryArgs(op, ctx, args);\n buildHeaderArgs(op, ctx, args);\n buildCookieArgs(op, ctx, args);\n\n if (op.bodyParamIndex !== null) {\n const bodyParam = op.parameters[op.bodyParamIndex];\n if (bodyParam) {\n const bodySchema = typeToJsonSchema(bodyParam.type, ctx);\n const schemaRef = bodySchema.$ref ?? \"#/components/schemas/InlineBody\";\n\n args.body = {\n index: bodyParam.index,\n required: !bodyParam.isOptional,\n contentType: op.bodyContentType ?? \"application/json\",\n schemaRef,\n };\n }\n }\n\n const responseSchema = typeToJsonSchema(op.returnType, ctx);\n const status = op.httpMethod === \"POST\" ? 201 : 200;\n\n let schemaRef = responseSchema.$ref;\n let isArray = false;\n\n if (!schemaRef && responseSchema.type === \"array\" && responseSchema.items?.$ref) {\n schemaRef = responseSchema.items.$ref;\n isArray = true;\n } else if (!schemaRef) {\n schemaRef = \"#/components/schemas/InlineResponse\";\n }\n\n return {\n operationId: op.operationId,\n http: {\n method: op.httpMethod as HttpMethod,\n path: op.path,\n },\n handler: {\n methodName: op.methodName,\n },\n args,\n responses: [\n {\n status,\n contentType: \"application/json\",\n schemaRef,\n isArray,\n },\n ],\n };\n}\n\nfunction buildPathArgs(op: ScannedOperation, ctx: SchemaContext, args: ArgsSpec): void {\n for (const paramIndex of op.pathParamIndices) {\n const param = op.parameters[paramIndex];\n if (param) {\n const paramSchema = typeToJsonSchema(param.type, ctx);\n\n args.path.push({\n name: param.name,\n index: param.index,\n required: !param.isOptional,\n schemaRef: paramSchema.$ref ?? \"#/components/schemas/InlinePathParam\",\n schemaType: paramSchema.type,\n });\n }\n }\n}\n\nfunction buildQueryArgs(op: ScannedOperation, ctx: SchemaContext, args: ArgsSpec): void {\n if (op.queryObjectParamIndex !== null) {\n const queryParam = op.parameters[op.queryObjectParamIndex];\n if (queryParam) {\n const queryStyle = extractQueryStyleOptions(ctx.checker, op.methodDeclaration);\n const querySchema = typeToJsonSchema(queryParam.type, ctx);\n if (queryStyle?.style === \"deepObject\") {\n const schemaRef = querySchema.$ref ?? \"#/components/schemas/InlineQueryParam\";\n args.query.push({\n name: queryParam.name,\n index: queryParam.index,\n required: !queryParam.isOptional,\n schemaRef,\n schemaType: querySchema.type,\n serialization: {\n style: \"deepObject\",\n explode: queryStyle.explode ?? true,\n allowReserved: queryStyle.allowReserved,\n },\n });\n } else {\n if (!querySchema.properties) return;\n\n for (const [propName, propSchema] of Object.entries(querySchema.properties as Record<string, any>)) {\n const isRequired = querySchema.required?.includes(propName) ?? false;\n let schemaRef = propSchema.$ref;\n if (!schemaRef) {\n schemaRef = \"#/components/schemas/InlineQueryParam\";\n }\n\n args.query.push({\n name: propName,\n index: queryParam.index,\n required: !isRequired,\n schemaRef,\n schemaType: propSchema.type,\n });\n }\n }\n }\n }\n\n for (const paramIndex of op.queryParamIndices) {\n const param = op.parameters[paramIndex];\n if (param) {\n const paramSchema = typeToJsonSchema(param.type, ctx);\n const schemaRef = paramSchema.$ref ?? \"#/components/schemas/InlineQueryParam\";\n\n args.query.push({\n name: param.name,\n index: param.index,\n required: !param.isOptional,\n schemaRef,\n schemaType: paramSchema.type,\n });\n }\n }\n}\n\nfunction buildHeaderArgs(op: ScannedOperation, ctx: SchemaContext, args: ArgsSpec): void {\n if (op.headerObjectParamIndex === null) return;\n\n const headerParam = op.parameters[op.headerObjectParamIndex];\n if (!headerParam) return;\n\n const headerSchema = typeToJsonSchema(headerParam.type, ctx);\n if (!headerSchema.properties) return;\n\n for (const [propName, propSchema] of Object.entries(headerSchema.properties as Record<string, any>)) {\n const isRequired = headerSchema.required?.includes(propName) ?? false;\n let schemaRef = propSchema.$ref;\n if (!schemaRef) {\n schemaRef = \"#/components/schemas/InlineHeaderParam\";\n }\n\n args.headers.push({\n name: propName,\n index: headerParam.index,\n required: !isRequired,\n schemaRef,\n schemaType: propSchema.type,\n });\n }\n}\n\nfunction buildCookieArgs(op: ScannedOperation, ctx: SchemaContext, args: ArgsSpec): void {\n if (op.cookieObjectParamIndex === null) return;\n\n const cookieParam = op.parameters[op.cookieObjectParamIndex];\n if (!cookieParam) return;\n\n const cookieSchema = typeToJsonSchema(cookieParam.type, ctx);\n if (!cookieSchema.properties) return;\n\n for (const [propName, propSchema] of Object.entries(cookieSchema.properties as Record<string, any>)) {\n const isRequired = cookieSchema.required?.includes(propName) ?? false;\n let schemaRef = propSchema.$ref;\n if (!schemaRef) {\n schemaRef = \"#/components/schemas/InlineCookieParam\";\n }\n\n args.cookies.push({\n name: propName,\n index: cookieParam.index,\n required: !isRequired,\n schemaRef,\n schemaType: propSchema.type,\n serialization: { style: \"form\", explode: true },\n });\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\n\nimport Ajv from \"ajv\";\nimport addFormats from \"ajv-formats\";\nimport type { AnySchema } from \"ajv\";\n\ninterface OpenApi {\n openapi: string;\n components?: {\n schemas?: Record<string, unknown>;\n };\n}\n\ninterface Manifest {\n manifestVersion: number;\n controllers: Array<{\n controllerId: string;\n basePath: string;\n operations: Array<{\n operationId: string;\n args: {\n body?: {\n schemaRef: string;\n contentType: string;\n } | null;\n response?: Array<{\n status: number;\n contentType: string;\n schemaRef?: string;\n }>;\n };\n responses: Array<{\n status: number;\n contentType: string;\n schemaRef: string;\n }>;\n }>;\n }>;\n}\n\nconst OAS_SCHEMA_ONLY = new Set([\"discriminator\", \"xml\", \"externalDocs\", \"example\"]);\n\nfunction sanitizeSchemaForAjv(schema: unknown): unknown {\n if (schema == null || typeof schema !== \"object\") return schema;\n if (Array.isArray(schema)) return schema.map(sanitizeSchemaForAjv);\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(schema as Record<string, unknown>)) {\n if (OAS_SCHEMA_ONLY.has(k)) continue;\n if (k.startsWith(\"x-\")) continue;\n out[k] = sanitizeSchemaForAjv(v);\n }\n return out;\n}\n\nfunction rewriteComponentRefs(schema: unknown): unknown {\n if (schema == null || typeof schema !== \"object\") return schema;\n if (Array.isArray(schema)) return schema.map(rewriteComponentRefs);\n\n if (typeof (schema as Record<string, unknown>).$ref === \"string\") {\n const ref = (schema as Record<string, unknown>).$ref as string;\n const m = ref.match(/^#\\/components\\/schemas\\/(.+)$/);\n if (m) {\n return { ...schema, $ref: m[1] };\n }\n }\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(schema as Record<string, unknown>)) {\n out[k] = rewriteComponentRefs(v);\n }\n return out;\n}\n\nfunction safeId(s: string): string {\n return s.replace(/[^A-Za-z0-9_]/g, \"_\").replace(/^[^A-Za-z_]/, \"_$&\");\n}\n\nfunction schemaNameFromRef(schemaRef: string): string {\n return schemaRef.replace(/^#\\/components\\/schemas\\//, \"\");\n}\n\nexport interface EmitPrecompiledValidatorsOptions {\n outDir: string;\n openapi: OpenApi;\n manifest: Manifest;\n strict?: \"off\" | \"log\" | \"error\";\n formatsMode?: \"fast\" | \"full\";\n}\n\nexport async function emitPrecompiledValidators(opts: EmitPrecompiledValidatorsOptions): Promise<{\n validatorsCjsPath: string;\n validatorsEsmPath: string;\n hash: string;\n}> {\n const outDir = opts.outDir;\n const cjsPath = path.join(outDir, \"validators.cjs\");\n const esmPath = path.join(outDir, \"validators.mjs\");\n const metaPath = path.join(outDir, \"validators.meta.json\");\n\n fs.mkdirSync(outDir, { recursive: true });\n\n const schemas: AnySchema[] = [];\n\n for (const [name, sch] of Object.entries(opts.openapi.components?.schemas ?? {})) {\n const clean = rewriteComponentRefs(sanitizeSchemaForAjv(sch));\n schemas.push({ ...(clean as object), $id: name } as AnySchema);\n }\n\n const opIndex: Record<string, { body?: string; response: Record<string, string> }> = {};\n\n for (const ctrl of opts.manifest.controllers ?? []) {\n for (const op of ctrl.operations ?? []) {\n const entry: { body?: string; response: Record<string, string> } = { response: {} };\n opIndex[op.operationId] = entry;\n\n if (op.args.body?.schemaRef) {\n const typeName = schemaNameFromRef(op.args.body.schemaRef);\n const id = safeId(`op_${op.operationId}_body`);\n schemas.push({ $id: id, $ref: typeName } as AnySchema);\n entry.body = id;\n }\n\n for (const r of op.responses ?? []) {\n if (!r.schemaRef) continue;\n const typeName = schemaNameFromRef(r.schemaRef);\n const key = `${r.status}|${r.contentType}`;\n const id = safeId(`op_${op.operationId}_res_${r.status}_${r.contentType}`);\n schemas.push({ $id: id, $ref: typeName } as AnySchema);\n entry.response[key] = id;\n }\n }\n }\n\n const strictOpt = opts.strict === \"off\" ? false : opts.strict === \"log\" ? \"log\" : true;\n\n const ajv = new Ajv.default({\n schemas,\n allErrors: true,\n strict: strictOpt,\n code: { source: true },\n });\n\n addFormats.default(ajv, { mode: opts.formatsMode ?? \"full\" });\n\n let cjs: string;\n const standaloneModule = require(\"ajv/dist/standalone\");\n if (typeof standaloneModule === \"function\") {\n cjs = standaloneModule(ajv);\n } else if (standaloneModule && typeof standaloneModule.default === \"function\") {\n cjs = standaloneModule.default(ajv);\n } else {\n throw new Error(\"Unable to find standalone code generator in ajv/dist/standalone\");\n }\n\n cjs += \"\\n\\n// --- adorn-api operation lookup (generated) ---\\n\";\n cjs += \"exports.validators = {\\n\";\n for (const [operationId, v] of Object.entries(opIndex)) {\n cjs += ` ${JSON.stringify(operationId)}: {\\n`;\n cjs += ` body: ${v.body ? `exports[${JSON.stringify(v.body)}]` : \"undefined\"},\\n`;\n cjs += ` response: {\\n`;\n for (const [key, id] of Object.entries(v.response)) {\n cjs += ` ${JSON.stringify(key)}: exports[${JSON.stringify(id)}],\\n`;\n }\n cjs += ` }\\n`;\n cjs += ` },\\n`;\n }\n cjs += \"};\\n\";\n\n fs.writeFileSync(cjsPath, cjs, \"utf8\");\n\n const esm = `// .adorn/validators.mjs (generated)\nimport { createRequire } from \"node:module\";\nconst require = createRequire(import.meta.url);\nconst cjs = require(\"./validators.cjs\");\n\nexport const validators = cjs.validators;\n\nexport function validateBody(operationId, data) {\n const v = validators?.[operationId]?.body;\n if (!v) return { ok: true, errors: null };\n const ok = v(data);\n return { ok, errors: ok ? null : v.errors };\n}\n\nexport function validateResponse(operationId, status, contentType, data) {\n const key = String(status) + \"|\" + String(contentType);\n const v = validators?.[operationId]?.response?.[key];\n if (!v) return { ok: true, errors: null };\n const ok = v(data);\n return { ok, errors: ok ? null : v.errors };\n}\n`;\n fs.writeFileSync(esmPath, esm, \"utf8\");\n\n const hash = crypto.createHash(\"sha256\").update(cjs).digest(\"hex\");\n fs.writeFileSync(metaPath, JSON.stringify({ hash }, null, 2), \"utf8\");\n\n return { validatorsCjsPath: cjsPath, validatorsEsmPath: esmPath, hash };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport ts from \"typescript\";\nimport type { AdornCacheV1 } from \"./schema.js\";\n\nexport type StaleResult =\n | { stale: false; reason: \"up-to-date\" }\n | { stale: true; reason: string; detail?: string };\n\nfunction readJson<T>(p: string): T | null {\n try {\n return JSON.parse(fs.readFileSync(p, \"utf8\")) as T;\n } catch {\n return null;\n }\n}\n\nfunction statMtimeMs(p: string): number | null {\n try {\n return fs.statSync(p).mtimeMs;\n } catch {\n return null;\n }\n}\n\nfunction ensureAbs(p: string): string {\n return path.isAbsolute(p) ? p : path.resolve(p);\n}\n\nexport function collectTsconfigChain(tsconfigPathAbs: string): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n\n function visit(pAbs: string) {\n if (seen.has(pAbs)) return;\n seen.add(pAbs);\n out.push(pAbs);\n\n const raw = readJson<any>(pAbs);\n const ext = raw?.extends;\n if (!ext) return;\n\n let resolved: string | null = null;\n\n if (ext.startsWith(\".\") || ext.startsWith(\"/\") || /^[A-Za-z]:\\\\/.test(ext)) {\n resolved = ensureAbs(path.resolve(path.dirname(pAbs), ext));\n if (!resolved.endsWith(\".json\")) resolved += \".json\";\n } else {\n try {\n const req = (module as any).createRequire?.(import.meta.url) ?? require;\n resolved = req.resolve(ext);\n } catch {\n try {\n const req = (module as any).createRequire?.(import.meta.url) ?? require;\n resolved = req.resolve(ext.endsWith(\".json\") ? ext : `${ext}.json`);\n } catch {\n resolved = null;\n }\n }\n }\n\n if (resolved) visit(resolved);\n }\n\n visit(tsconfigPathAbs);\n return out;\n}\n\nexport function findLockfile(startDir: string): { path: string; mtimeMs: number } | null {\n const names = [\"pnpm-lock.yaml\", \"package-lock.json\", \"yarn.lock\"];\n let dir = startDir;\n\n for (let i = 0; i < 20; i++) {\n for (const n of names) {\n const p = path.join(dir, n);\n const mt = statMtimeMs(p);\n if (mt != null) return { path: p, mtimeMs: mt };\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\nexport async function isStale(params: {\n outDir: string;\n project: string;\n adornVersion: string;\n typescriptVersion: string;\n}): Promise<StaleResult> {\n const outDirAbs = ensureAbs(params.outDir);\n const tsconfigAbs = ensureAbs(params.project);\n\n const manifestPath = path.join(outDirAbs, \"manifest.json\");\n const cachePath = path.join(outDirAbs, \"cache.json\");\n\n if (!fs.existsSync(manifestPath)) return { stale: true, reason: \"missing-manifest\" };\n\n const cache = readJson<AdornCacheV1>(cachePath);\n if (!cache) return { stale: true, reason: \"missing-cache\" };\n\n if (cache.generator.version !== params.adornVersion) {\n return { stale: true, reason: \"generator-version-changed\", detail: `${cache.generator.version} -> ${params.adornVersion}` };\n }\n\n if (ensureAbs(cache.project.tsconfigPath) !== tsconfigAbs) {\n return { stale: true, reason: \"tsconfig-changed\", detail: \"different project path\" };\n }\n\n const chain = collectTsconfigChain(tsconfigAbs);\n for (const cfg of chain) {\n const mt = statMtimeMs(cfg);\n if (mt == null) return { stale: true, reason: \"config-missing\", detail: cfg };\n\n const cachedMt = cache.project.configFiles[cfg];\n if (cachedMt == null || Math.abs(cachedMt - mt) > 0.0001) {\n return { stale: true, reason: \"config-updated\", detail: cfg };\n }\n }\n\n if (cache.project.lockfile?.path) {\n const mt = statMtimeMs(cache.project.lockfile.path);\n if (mt == null) return { stale: true, reason: \"lockfile-missing\", detail: cache.project.lockfile.path };\n\n if (Math.abs(cache.project.lockfile.mtimeMs - mt) > 0.0001) {\n return { stale: true, reason: \"lockfile-updated\", detail: cache.project.lockfile.path };\n }\n }\n\n for (const [file, cachedMt] of Object.entries(cache.inputs)) {\n const mt = statMtimeMs(file);\n if (mt == null) return { stale: true, reason: \"input-missing\", detail: file };\n if (Math.abs(cachedMt - mt) > 0.0001) return { stale: true, reason: \"input-updated\", detail: file };\n }\n\n return { stale: false, reason: \"up-to-date\" };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport ts from \"typescript\";\nimport { collectTsconfigChain, findLockfile } from \"./isStale.js\";\nimport type { AdornCacheV1 } from \"./schema.js\";\n\nfunction statMtimeMs(p: string): number {\n return fs.statSync(p).mtimeMs;\n}\n\nfunction ensureDir(p: string) {\n fs.mkdirSync(p, { recursive: true });\n}\n\nfunction isProjectSourceFile(f: string): boolean {\n if (f.includes(`${path.sep}node_modules${path.sep}`)) return false;\n if (f.includes(`${path.sep}typescript${path.sep}lib${path.sep}`)) return false;\n return /\\.(ts|tsx|mts|cts)$/.test(f);\n}\n\nexport function writeCache(params: {\n outDir: string;\n tsconfigAbs: string;\n program: ts.Program;\n adornVersion: string;\n}): void {\n const outDirAbs = path.isAbsolute(params.outDir) ? params.outDir : path.resolve(params.outDir);\n ensureDir(outDirAbs);\n\n const configFiles = collectTsconfigChain(params.tsconfigAbs);\n const configMtimes: Record<string, number> = {};\n for (const cfg of configFiles) configMtimes[cfg] = statMtimeMs(cfg);\n\n const lock = findLockfile(path.dirname(params.tsconfigAbs));\n\n const inputs: Record<string, number> = {};\n for (const sf of params.program.getSourceFiles()) {\n const f = sf.fileName;\n if (!isProjectSourceFile(f)) continue;\n try {\n inputs[f] = statMtimeMs(f);\n } catch {\n }\n }\n\n const cache: AdornCacheV1 = {\n cacheVersion: 1,\n generator: {\n name: \"adorn-api\",\n version: params.adornVersion,\n typescript: ts.version\n },\n project: {\n tsconfigPath: params.tsconfigAbs,\n configFiles: configMtimes,\n lockfile: lock ?? null\n },\n inputs\n };\n\n fs.writeFileSync(path.join(outDirAbs, \"cache.json\"), JSON.stringify(cache, null, 2), \"utf8\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,kBAA2E;AAC3E,IAAAC,oBAAiC;;;ACFjC,wBAAe;AACf,qBAA6B;AAC7B,uBAAiC;AAQ1B,SAAS,wBAAwB,cAAsC;AAC5E,QAAM,mBAAe,0BAAQ,YAAY;AACzC,QAAM,gBAAY,0BAAQ,YAAY;AAEtC,QAAM,aAAa,kBAAAC,QAAG,eAAe,cAAc,CAACC,cAAS,6BAAaA,OAAM,OAAO,CAAC;AACxF,MAAI,WAAW,OAAO;AACpB,UAAM,IAAI,MAAM,4BAA4B,kBAAAD,QAAG,6BAA6B,WAAW,MAAM,aAAa,IAAI,CAAC,EAAE;AAAA,EACnH;AAEA,QAAM,SAAS,kBAAAA,QAAG,2BAA2B,WAAW,QAAQ,kBAAAA,QAAG,KAAK,SAAS;AACjF,MAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,WAAW,OAAO,OAAO,IAAI,OAAK,kBAAAA,QAAG,6BAA6B,EAAE,aAAa,IAAI,CAAC;AAC5F,UAAM,IAAI,MAAM;AAAA,EAA8B,SAAS,KAAK,IAAI,CAAC,EAAE;AAAA,EACrE;AAEA,QAAM,UA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;AAEA,SAAS,aAAa,MAAgB;AACpC,QAAM,YAAY,KAAK,SAAS,UAAU,IACtC,KAAK,KAAK,QAAQ,UAAU,IAAI,CAAC,IACjC;AAEJ,QAAM,iBAAa,2BAAQ,SAAS;AAEpC,UAAI,4BAAW,UAAU,GAAG;AAC1B,gCAAO,YAAY,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,EACrD;AAEA,MAAI,sBAAsB,SAAS,EAAE;AACvC;AAEA,IAAM,UAAU,oBAAAA,QAAQ,KAAK,CAAC;AAE9B,IAAI,YAAY,SAAS;AACvB,eAAa,oBAAAA,QAAQ,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ;AACjD,YAAQ,MAAM,GAAG;AACjB,wBAAAA,QAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH,WAAW,YAAY,SAAS;AAC9B,eAAa,oBAAAA,QAAQ,KAAK,MAAM,CAAC,CAAC;AACpC,OAAO;AACL,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAkBX;AACH;","names":["import_node_fs","import_node_path","ts","path","import_typescript","ts","path","import_typescript","import_typescript","ts","ts","import_typescript","ts","import_typescript","ts","path","ts","import_typescript","ts","schemaRef","import_node_fs","import_node_path","path","fs","Ajv","addFormats","crypto","import_node_fs","import_node_path","import_typescript","fs","path","import_node_fs","import_node_path","import_typescript","statMtimeMs","fs","path","ts","import_typescript","process","ts"]}
|