@nooh-ts/compiler 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +76 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +980 -85
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/generate/utils.ts","../src/utils/path.ts","../src/generate/app.ts","../src/generate/group.ts","../src/generate/middleware.ts","../src/generate/router.ts","../src/generate/types.ts","../src/generate/index.ts","../src/pipeline/analyze.ts","../src/pipeline/config.ts","../src/pipeline/discover.ts","../src/types.ts","../src/pipeline/route-parser.ts","../src/pipeline/parse.ts","../src/pipeline/plan.ts","../src/compiler.ts","../src/compile.ts","../src/diff.ts","../src/recompile.ts"],"sourcesContent":["import type { CompilationPlan } from \"@/types\";\n\n/**\n * Returns the output file path for a route group module.\n * The root group uses the reserved name \"root\".\n */\nexport const groupModuleId = (\n plan: CompilationPlan,\n groupId: string\n): string => {\n if (groupId === \"root\") {\n return `${plan.outputRoot}/groups/root.ts`;\n }\n\n return `${plan.outputRoot}/groups/${groupId}.ts`;\n};\n","const WINDOWS_DRIVE_REGEX = /^[A-Za-z]:\\//;\nconst LEADING_SLASH_REGEX = /^\\/+/;\nconst DRIVE_REGEX = /^([A-Za-z]):\\//;\n\nexport const isAbsolutePath = (value: string): boolean => {\n const normalized = value.replaceAll(\"\\\\\", \"/\");\n\n return normalized.startsWith(\"/\") || WINDOWS_DRIVE_REGEX.test(normalized);\n};\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ...\nexport const normalizePath = (value: string): string => {\n const normalized = value.replaceAll(\"\\\\\", \"/\");\n\n const isPosixAbsolute = normalized.startsWith(\"/\");\n const driveMatch = normalized.match(DRIVE_REGEX);\n\n const body = driveMatch\n ? normalized.slice(3)\n : // biome-ignore lint/style/noNestedTernary: ...\n isPosixAbsolute\n ? normalized.slice(1)\n : normalized;\n\n const parts = body.split(\"/\");\n const result: string[] = [];\n\n for (const part of parts) {\n if (!part || part === \".\") {\n continue;\n }\n\n if (part === \"..\") {\n if (result.length > 0 && result.at(-1) !== \"..\") {\n result.pop();\n } else if (!(isPosixAbsolute || driveMatch)) {\n result.push(\"..\");\n }\n\n continue;\n }\n\n result.push(part);\n }\n\n const joined = result.join(\"/\");\n\n if (driveMatch) {\n return joined ? `${driveMatch[1]}:/${joined}` : `${driveMatch[1]}:/`;\n }\n\n if (isPosixAbsolute) {\n return joined ? `/${joined}` : \"/\";\n }\n\n return joined;\n};\n\nexport const stripLeadingSlash = (value: string): string =>\n value.replace(LEADING_SLASH_REGEX, \"\");\n\nexport const ensureLeadingSlash = (value: string): string => {\n if (!value) {\n return \"/\";\n }\n\n return value.startsWith(\"/\") ? value : `/${value}`;\n};\n\nexport const joinPath = (...parts: string[]): string =>\n normalizePath(parts.filter(Boolean).join(\"/\"));\n\nexport const dirname = (value: string): string => {\n const normalized = normalizePath(value);\n const index = normalized.lastIndexOf(\"/\");\n\n if (index === -1) {\n return \"\";\n }\n\n if (index === 0) {\n return \"/\";\n }\n\n return normalized.slice(0, index);\n};\n\nexport const basename = (value: string): string => {\n const normalized = normalizePath(value);\n const index = normalized.lastIndexOf(\"/\");\n\n if (index === -1) {\n return normalized;\n }\n\n return normalized.slice(index + 1);\n};\n\nexport const relativePath = (from: string, to: string): string => {\n const fromParts = normalizePath(from).split(\"/\").filter(Boolean);\n const toParts = normalizePath(to).split(\"/\").filter(Boolean);\n\n let common = 0;\n\n while (\n common < fromParts.length &&\n common < toParts.length &&\n fromParts[common] === toParts[common]\n ) {\n common += 1;\n }\n\n const result = [\n ...fromParts.slice(common).map(() => \"..\"),\n ...toParts.slice(common),\n ];\n\n return result.join(\"/\");\n};\n\nexport const toProjectPath = (value: string, root: string): string => {\n const normalizedValue = normalizePath(value);\n const normalizedRoot = normalizePath(root);\n\n if (!(normalizedRoot && isAbsolutePath(normalizedRoot))) {\n return normalizedValue;\n }\n\n if (!isAbsolutePath(normalizedValue)) {\n return normalizedValue;\n }\n\n if (!isPathInside(normalizedValue, normalizedRoot)) {\n return normalizedValue;\n }\n\n return relativePath(normalizedRoot, normalizedValue);\n};\n\nexport const relativeModuleSpecifier = (\n fromModule: string,\n toSource: string\n): string => {\n const fromDirectory = dirname(fromModule);\n\n let target = normalizePath(toSource);\n\n if (target.endsWith(\".ts\")) {\n target = `${target.slice(0, -3)}.js`;\n } else if (target.endsWith(\".tsx\")) {\n target = `${target.slice(0, -4)}.js`;\n }\n\n const relative = relativePath(fromDirectory, target);\n\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n};\n\nexport const isPathInside = (file: string, root: string): boolean => {\n const normalizedFile = normalizePath(file);\n const normalizedRoot = normalizePath(root);\n\n if (normalizedFile === normalizedRoot) {\n return true;\n }\n\n return normalizedFile.startsWith(`${normalizedRoot}/`);\n};\n\nconst EXTENSION_REGEX = /\\.[^.]+$/;\nexport const removeExtension = (value: string): string =>\n value.replace(EXTENSION_REGEX, \"\");\n","import { groupModuleId } from \"@/generate/utils\";\n\nimport type { CompilationPlan, GeneratedModule, ProjectModel } from \"@/types\";\nimport { relativeModuleSpecifier } from \"@/utils/path\";\n\nexport const generateAppModule = (\n plan: CompilationPlan,\n model: ProjectModel\n): GeneratedModule => {\n const moduleId = `${plan.outputRoot}/app.ts`;\n const typesModuleId = `${plan.outputRoot}/types.ts`;\n\n const root = model.groups.find((group) => group.id === \"root\");\n\n if (!root) {\n throw new Error(\"Nooh compilation requires a root route group.\");\n }\n\n const imports = [\n `import { Hono } from \"hono\";`,\n `import type { App } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, typesModuleId)\n )};`,\n `import root from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, groupModuleId(plan, root.id))\n )};`,\n ];\n\n const code = [\n ...imports,\n \"\",\n \"const app = new Hono<App>();\",\n \"\",\n 'app.route(\"/\", root);',\n \"\",\n \"export type AppType = typeof app;\",\n \"\",\n \"export default app;\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"app\",\n };\n};\n","import { groupModuleId } from \"@/generate/utils\";\n\nimport type {\n CompilationPlan,\n GeneratedModule,\n ProjectModel,\n RouteGroup,\n RouteModel,\n} from \"@/types\";\nimport { ensureLeadingSlash, relativeModuleSpecifier } from \"@/utils/path\";\n\nconst getGroupRoutes = (\n model: ProjectModel,\n group: RouteGroup\n): readonly RouteModel[] => {\n const ids = new Set(group.routes);\n\n return model.routes\n .filter((route) => ids.has(route.id))\n .sort((a, b) => {\n const pathDifference = a.localPath.localeCompare(b.localPath);\n\n if (pathDifference !== 0) {\n return pathDifference;\n }\n\n const methodDifference = a.method.localeCompare(b.method);\n\n if (methodDifference !== 0) {\n return methodDifference;\n }\n\n return a.source.localeCompare(b.source);\n });\n};\n\nconst capitalize = (value: string): string =>\n value.charAt(0).toUpperCase() + value.slice(1);\n\nconst getGroup = (model: ProjectModel, id: string): RouteGroup | undefined =>\n model.groups.find((group) => group.id === id);\n\nconst getChildPath = (parent: RouteGroup, child: RouteGroup): string => {\n if (parent.path === \"/\") {\n return child.path;\n }\n\n const prefix = `${parent.path}/`;\n\n if (!child.path.startsWith(prefix)) {\n throw new Error(\n `Invalid group tree: \"${child.path}\" is not a child of \"${parent.path}\".`\n );\n }\n\n return child.path.slice(prefix.length);\n};\n\nexport const generateGroupModule = (\n plan: CompilationPlan,\n model: ProjectModel,\n group: RouteGroup\n): GeneratedModule => {\n const moduleId = groupModuleId(plan, group.id);\n const typesModuleId = `${plan.outputRoot}/types.ts`;\n const routes = getGroupRoutes(model, group);\n\n const children = group.children\n .map((childId) => getGroup(model, childId))\n .filter((child): child is RouteGroup => child !== undefined)\n .sort((a, b) => a.path.localeCompare(b.path));\n\n const imports = [\n `import { Hono } from \"hono\";`,\n `import type { App } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, typesModuleId)\n )};`,\n ];\n\n if (group.configSource) {\n imports.push(\n `import groupConfig from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, group.configSource)\n )};`\n );\n }\n\n children.forEach((child, index) => {\n imports.push(\n `import child${index} from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, groupModuleId(plan, child.id))\n )};`\n );\n });\n\n routes.forEach((route, index) => {\n imports.push(\n `import endpoint${index} from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, route.source)\n )};`\n );\n });\n\n const methods = [...new Set(routes.map((route) => route.method))].sort();\n\n const registerTypes = [\n \"type RouteRegister = (\",\n \" path: string,\",\n \" ...handlers: any[]\",\n \") => typeof route;\",\n ];\n\n const registerDeclarations = methods.map((method) => {\n const name = `register${capitalize(method)}`;\n\n return `const ${name} = route.${method} as unknown as RouteRegister;`;\n });\n\n const useDeclaration = group.configSource\n ? [\n \"type RouteUse = (\",\n \" path: string,\",\n \" ...handlers: any[]\",\n \") => typeof route;\",\n \"\",\n \"const use = route.use as unknown as RouteUse;\",\n \"\",\n 'use(\"*\", ...(groupConfig.middleware ?? []));',\n ]\n : [];\n\n const registrations = routes.map((route, index) => {\n const register = `register${capitalize(route.method)}`;\n\n return ` ${register}(${JSON.stringify(\n ensureLeadingSlash(route.localPath)\n )}, ...endpoint${index});`;\n });\n\n const childRegistrations = children.map(\n (child, index) =>\n ` route.route(${JSON.stringify(\n getChildPath(group, child)\n )}, child${index});`\n );\n\n const code = [\n ...imports,\n \"\",\n \"const route = new Hono<App>();\",\n \"\",\n ...registerTypes,\n \"\",\n ...registerDeclarations,\n ...(useDeclaration.length > 0 ? [\"\", ...useDeclaration] : []),\n ...(registrations.length > 0 ? [\"\", ...registrations] : []),\n ...(childRegistrations.length > 0 ? [\"\", ...childRegistrations] : []),\n \"\",\n \"export default route;\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"group\",\n };\n};\n","import type { CompilationPlan, GeneratedModule } from \"@/types\";\n\nexport const generateMiddlewareModule = (\n plan: CompilationPlan\n): GeneratedModule => {\n const moduleId = `${plan.outputRoot}/router/middleware.ts`;\n\n return {\n code: [\n `import { createMiddleware } from \"hono/factory\";`,\n `import type { App } from \"../types.js\";`,\n \"\",\n \"export const middleware = createMiddleware<App>;\",\n \"\",\n ].join(\"\\n\"),\n id: moduleId,\n kind: \"middleware\",\n };\n};\n","import type {\n CompilationPlan,\n GeneratedModule,\n ProjectModel,\n RouteModel,\n} from \"@/types\";\nimport { ensureLeadingSlash, relativeModuleSpecifier } from \"@/utils/path\";\n\nconst VALIDATION_TARGETS = [\n \"json\",\n \"form\",\n \"query\",\n \"param\",\n \"header\",\n \"cookie\",\n] as const;\n\nconst METHOD_FUNCTION_NAMES: Record<RouteModel[\"method\"], string> = {\n all: \"all\",\n delete: \"del\",\n get: \"get\",\n head: \"head\",\n options: \"options\",\n patch: \"patch\",\n post: \"post\",\n put: \"put\",\n};\n\nconst getRoutesForRouter = (\n model: ProjectModel,\n routerPath: string\n): readonly RouteModel[] =>\n model.routes\n .filter((route) => route.routerPath === routerPath)\n .sort((a, b) => a.method.localeCompare(b.method));\n\nconst renderMethod = (route: RouteModel): string => {\n const { method } = route;\n const functionName = METHOD_FUNCTION_NAMES[method];\n\n const path = JSON.stringify(ensureLeadingSlash(route.localPath));\n\n return [\n `type Path = ${path};`,\n \"\",\n \"type RouteMiddleware = MiddlewareHandler<App, Path>;\",\n \"\",\n \"type ValidationTarget = Parameters<typeof sValidator>[0];\",\n \"type StandardSchema = Parameters<typeof sValidator>[1];\",\n \"\",\n \"type ValidationOptions = Partial<\",\n \" Record<ValidationTarget, StandardSchema>\",\n \">;\",\n \"\",\n \"type HandlerInput<T> = T extends Handler<\",\n \" any,\",\n \" any,\",\n \" infer I,\",\n \" any\",\n \"> ? I : never;\",\n \"\",\n \"type ValidationHandler<\",\n \" Target extends ValidationTarget,\",\n \" Schema extends StandardSchema,\",\n \"> = ReturnType<\",\n \" typeof sValidator<Schema, Target, App, Path>\",\n \">;\",\n \"\",\n \"type ValidationInput<V extends ValidationOptions> =\",\n ...VALIDATION_TARGETS.map(\n (target) =>\n ` & (${JSON.stringify(target)} extends keyof V ? HandlerInput<ValidationHandler<${JSON.stringify(target)}, NonNullable<V[${JSON.stringify(target)}]>>> : {})`\n ),\n \";\",\n \"\",\n \"type RouteHandler = Handler<App, Path, any, any>;\",\n \"\",\n \"type EndpointOptions<\",\n \" M extends readonly RouteMiddleware[],\",\n \" V extends ValidationOptions,\",\n \" H extends Handler<App, Path, ValidationInput<V>>,\",\n \"> = {\",\n \" readonly middleware?: M;\",\n \" readonly validation?: V;\",\n \" readonly handler: H;\",\n \"};\",\n \"\",\n `export function ${functionName}<H extends Handler<App, Path>>(`,\n \" handler: H,\",\n \"): readonly RouteHandler[];\",\n \"\",\n `export function ${functionName}<`,\n \" M extends readonly RouteMiddleware[],\",\n \" V extends ValidationOptions,\",\n \" H extends Handler<App, Path, ValidationInput<V>>,\",\n \">(\",\n \" options: EndpointOptions<M, V, H>,\",\n \"): readonly RouteHandler[];\",\n \"\",\n `export function ${functionName}<`,\n \" M extends readonly RouteMiddleware[],\",\n \" V extends ValidationOptions,\",\n \" H extends Handler<App, Path, ValidationInput<V>>,\",\n \">(\",\n \" input:\",\n \" | H\",\n \" | EndpointOptions<M, V, H>,\",\n \"): readonly RouteHandler[] {\",\n ' if (typeof input === \"function\") {',\n \" return [input as RouteHandler];\",\n \" }\",\n \"\",\n \" return [\",\n \" ...(input.middleware ?? []) as readonly RouteHandler[],\",\n ...VALIDATION_TARGETS.map(\n (target) =>\n ` ...(input.validation?.${target} !== undefined ? [sValidator(${JSON.stringify(target)}, input.validation.${target}) as RouteHandler] : []),`\n ),\n \" input.handler as RouteHandler,\",\n \" ];\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n};\n\nexport const generateRouterModule = (\n plan: CompilationPlan,\n model: ProjectModel,\n routerPath: string\n): GeneratedModule => {\n const routes = getRoutesForRouter(model, routerPath);\n\n const moduleId = `${plan.outputRoot}/${routerPath}.ts`;\n\n const typesModuleId = `${plan.outputRoot}/types.ts`;\n\n return {\n code: [\n `import { sValidator } from \"@hono/standard-validator\";`,\n `import type { Handler, MiddlewareHandler } from \"hono\";`,\n `import type { App } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, typesModuleId)\n )};`,\n \"\",\n ...routes.map(renderMethod),\n ].join(\"\\n\"),\n id: moduleId,\n kind: \"router\",\n };\n};\n","import type { CompilationPlan, GeneratedModule, LoadedConfig } from \"@/types\";\nimport { relativeModuleSpecifier } from \"@/utils/path\";\n\nexport const generateTypesModule = (\n plan: CompilationPlan,\n config: LoadedConfig\n): GeneratedModule => {\n const moduleId = `${plan.outputRoot}/types.ts`;\n\n const configImport = relativeModuleSpecifier(moduleId, config.source);\n\n const code = [\n `import type config from \"${configImport}\";`,\n \"\",\n \"type ExtractEnvironment<T> = T extends {\",\n \" readonly __nooh_env: infer Environment;\",\n \"}\",\n \" ? Environment\",\n \" : never;\",\n \"\",\n \"export type App = ExtractEnvironment<typeof config>;\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"types\",\n };\n};\n","import { generateAppModule } from \"@/generate/app\";\nimport { generateGroupModule } from \"@/generate/group\";\nimport { generateMiddlewareModule } from \"@/generate/middleware\";\nimport { generateRouterModule } from \"@/generate/router\";\nimport { generateTypesModule } from \"@/generate/types\";\n\nimport type {\n CompilationPlan,\n GeneratedModule,\n GeneratedOutput,\n ProjectModel,\n} from \"@/types\";\n\nexport const generate = (\n plan: CompilationPlan,\n model: ProjectModel\n): GeneratedOutput => {\n const modules: GeneratedModule[] = [];\n\n modules.push(generateTypesModule(plan, model.config));\n\n modules.push(generateMiddlewareModule(plan));\n\n const routerPaths = [\n ...new Set(model.routes.map((route) => route.routerPath)),\n ].sort();\n\n for (const routerPath of routerPaths) {\n modules.push(generateRouterModule(plan, model, routerPath));\n }\n\n for (const group of model.groups) {\n modules.push(generateGroupModule(plan, model, group));\n }\n\n modules.push(generateAppModule(plan, model));\n\n modules.sort((a, b) => a.id.localeCompare(b.id));\n\n return {\n modules,\n };\n};\n","import type {\n Diagnostic,\n LoadedConfig,\n ParsedProject,\n ParsedRoute,\n ProjectModel,\n RouteGroup,\n RouteModel,\n RouteSegment,\n} from \"@/types\";\nimport { ensureLeadingSlash, normalizePath } from \"@/utils/path\";\n\nconst segmentToHono = (segment: RouteSegment): string => {\n // biome-ignore lint/style/useDefaultSwitchClause: ...\n switch (segment.kind) {\n case \"static\":\n return segment.value;\n\n case \"param\":\n return `:${segment.name}`;\n\n case \"splat\":\n return \"*\";\n }\n};\n\nconst segmentsToPath = (segments: readonly RouteSegment[]): string => {\n if (segments.length === 0) {\n return \"\";\n }\n\n return segments.map(segmentToHono).join(\"/\");\n};\n\nconst combinePaths = (groupPath: string, localPath: string): string => {\n const group = normalizePath(groupPath).replace(/^\\/+|\\/+$/g, \"\");\n const local = normalizePath(localPath).replace(/^\\/+|\\/+$/g, \"\");\n\n if (!(group || local)) {\n return \"/\";\n }\n\n if (!group) {\n return `/${local}`;\n }\n\n if (!local) {\n return `/${group}`;\n }\n\n return `/${group}/${local}`;\n};\n\nconst routeSegmentsToRouterPath = (\n groupPath: string,\n rawSegments: readonly string[]\n): string => {\n const parts = [\n ...groupPath.split(\"/\").filter(Boolean),\n ...rawSegments.filter(Boolean),\n ];\n\n return parts.length === 0 ? \"router/index\" : `router/${parts.join(\"/\")}`;\n};\n\nconst routeId = (route: ParsedRoute): string =>\n `${route.method.toUpperCase()} ${combinePaths(\n route.groupPath,\n segmentsToPath(route.segments)\n )}`;\n\nconst sortRoutes = (a: RouteModel, b: RouteModel): number => {\n const pathDifference = a.fullPath.localeCompare(b.fullPath);\n\n if (pathDifference !== 0) {\n return pathDifference;\n }\n\n const methodDifference = a.method.localeCompare(b.method);\n\n if (methodDifference !== 0) {\n return methodDifference;\n }\n\n return a.source.localeCompare(b.source);\n};\n\nconst parentGroupPath = (groupPath: string): string | null => {\n const normalized = normalizePath(groupPath);\n\n if (!normalized) {\n return null;\n }\n\n const parts = normalized.split(\"/\").filter(Boolean);\n\n if (parts.length <= 1) {\n return \"\";\n }\n\n return parts.slice(0, -1).join(\"/\");\n};\n\nconst getAncestorGroupPaths = (groupPath: string): readonly string[] => {\n const parts = normalizePath(groupPath).split(\"/\").filter(Boolean);\n\n return Array.from({ length: parts.length + 1 }, (_, index) =>\n parts.slice(0, index).join(\"/\")\n );\n};\n\nconst groupId = (path: string): string => path || \"root\";\n\nconst buildGroups = (\n parsed: ParsedProject,\n routeModels: readonly RouteModel[],\n diagnostics: Diagnostic[]\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ...\n): readonly RouteGroup[] => {\n const configSources = new Map<string, string>();\n\n for (const group of parsed.groups) {\n const path = normalizePath(group.groupPath);\n const previous = configSources.get(path);\n\n if (previous) {\n diagnostics.push({\n code: \"NOOH006\",\n file: group.source,\n message: [\n `Duplicate group definition for \"${path || \"/\"}\".`,\n \"\",\n `First declaration: ${previous}`,\n `Second declaration: ${group.source}`,\n ].join(\"\\n\"),\n severity: \"error\",\n });\n\n continue;\n }\n\n configSources.set(path, group.source);\n }\n\n const groupPaths = new Set<string>([\"\"]);\n\n for (const group of parsed.groups) {\n for (const ancestor of getAncestorGroupPaths(group.groupPath)) {\n groupPaths.add(ancestor);\n }\n }\n\n for (const route of routeModels) {\n for (const ancestor of getAncestorGroupPaths(route.groupPath)) {\n groupPaths.add(ancestor);\n }\n }\n\n const routesByGroup = new Map<string, string[]>();\n\n for (const route of routeModels) {\n const routes = routesByGroup.get(route.groupPath);\n\n if (routes) {\n routes.push(route.id);\n } else {\n routesByGroup.set(route.groupPath, [route.id]);\n }\n }\n\n const childrenByGroup = new Map<string, string[]>();\n\n for (const path of groupPaths) {\n if (!path) {\n continue;\n }\n\n const parent = parentGroupPath(path) ?? \"\";\n\n const children = childrenByGroup.get(parent);\n\n if (children) {\n children.push(path);\n } else {\n childrenByGroup.set(parent, [path]);\n }\n }\n\n return [...groupPaths]\n .sort((a, b) => {\n if (!a && b) {\n return -1;\n }\n\n if (a && !b) {\n return 1;\n }\n\n return a.localeCompare(b);\n })\n .map((path) => {\n const children = [...(childrenByGroup.get(path) ?? [])].sort();\n const configSource = configSources.get(path);\n const parent = parentGroupPath(path);\n\n return {\n children: children.map(groupId),\n id: groupId(path),\n ...(parent !== null && {\n parentId: groupId(parent),\n }),\n path: path ? ensureLeadingSlash(path) : \"/\",\n routes: [...(routesByGroup.get(path) ?? [])].sort(),\n ...(configSource !== undefined && {\n configSource,\n }),\n };\n });\n};\n\nexport const analyze = (\n parsed: ParsedProject,\n config: LoadedConfig\n): {\n model: ProjectModel;\n diagnostics: readonly Diagnostic[];\n} => {\n const diagnostics: Diagnostic[] = [...parsed.diagnostics];\n\n const routeModels: RouteModel[] = [];\n const seen = new Map<string, string>();\n\n for (const route of parsed.routes) {\n const localPath = segmentsToPath(route.segments);\n const fullPath = combinePaths(route.groupPath, localPath);\n const id = routeId(route);\n\n const previousSource = seen.get(id);\n\n if (previousSource) {\n diagnostics.push({\n code: \"NOOH005\",\n file: route.source,\n message: [\n `Duplicate route \"${id}\".`,\n \"\",\n `First declaration: ${previousSource}`,\n `Second declaration: ${route.source}`,\n ].join(\"\\n\"),\n severity: \"error\",\n });\n\n continue;\n }\n\n seen.set(id, route.source);\n\n routeModels.push({\n fullPath,\n groupPath: normalizePath(route.groupPath),\n id,\n localPath,\n method: route.method,\n routerPath: routeSegmentsToRouterPath(route.groupPath, route.rawSegments),\n routeSegments: route.segments,\n source: route.source,\n });\n }\n\n routeModels.sort(sortRoutes);\n\n const groups = buildGroups(parsed, routeModels, diagnostics);\n\n return {\n diagnostics,\n model: {\n config,\n groups,\n routes: routeModels,\n },\n };\n};\n","import type { CompileInput, ConfigLoadResult, RuntimeConfig } from \"@/types\";\nimport { normalizePath, toProjectPath } from \"@/utils/path\";\n\nconst DEFAULT_ROUTES_ROOT = \"src/routes\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isString = (value: unknown): value is string => typeof value === \"string\";\n\nexport const loadConfig = async (\n input: CompileInput\n): Promise<ConfigLoadResult> => {\n let defaultExport: unknown;\n\n try {\n defaultExport = await input.loader.loadDefault(input.config);\n } catch (error) {\n return {\n diagnostics: [\n {\n code: \"NOOH010\",\n file: input.config,\n message:\n error instanceof Error\n ? `Failed to load config: ${error.message}`\n : \"Failed to load config.\",\n severity: \"error\",\n },\n ],\n };\n }\n\n if (!isRecord(defaultExport)) {\n return {\n diagnostics: [\n {\n code: \"NOOH011\",\n file: input.config,\n message: \"The Nooh config default export must be an object.\",\n severity: \"error\",\n },\n ],\n };\n }\n\n const routesValue = defaultExport.routes;\n\n if (routesValue !== undefined && !isString(routesValue)) {\n return {\n diagnostics: [\n {\n code: \"NOOH012\",\n file: input.config,\n message: 'The Nooh config \"routes\" option must be a string.',\n severity: \"error\",\n },\n ],\n };\n }\n\n const root = normalizePath(input.root ?? \"\");\n const source = toProjectPath(input.config, root);\n const routes = routesValue ?? DEFAULT_ROUTES_ROOT;\n const routesRoot = toProjectPath(routes, root);\n\n const value: RuntimeConfig = {\n routes: routesValue,\n };\n\n return {\n config: {\n root,\n routesRoot,\n source,\n value,\n },\n diagnostics: [],\n };\n};\n","import type {\n DiscoveredEndpoint,\n DiscoveredGroup,\n DiscoveredProject,\n LoadedConfig,\n SourceFile,\n SourceSnapshot,\n} from \"@/types\";\nimport {\n basename,\n dirname,\n isPathInside,\n normalizePath,\n relativePath,\n toProjectPath,\n} from \"@/utils/path\";\n\nconst ROUTE_FILE_PATTERN =\n /\\.(get|post|put|patch|delete|options|head|all)\\.(?:ts|tsx)$/;\n\nconst isTypeScriptFile = (file: SourceFile): boolean =>\n file.path.endsWith(\".ts\") || file.path.endsWith(\".tsx\");\n\nconst isRouteFile = (filePath: string): boolean =>\n ROUTE_FILE_PATTERN.test(filePath);\n\nconst isGroupFile = (filePath: string): boolean => {\n const filename = basename(filePath);\n\n return filename === \"$.ts\" || filename === \"$.tsx\";\n};\n\nconst discoverGroup = (\n config: LoadedConfig,\n file: SourceFile\n): DiscoveredGroup | null => {\n const source = toProjectPath(file.path, config.root);\n\n if (!isPathInside(source, config.routesRoot)) {\n return null;\n }\n\n if (!isGroupFile(source)) {\n return null;\n }\n\n const relative = relativePath(config.routesRoot, source);\n const directory = dirname(relative);\n\n return {\n groupPath: normalizePath(directory),\n source,\n };\n};\n\nconst discoverEndpoint = (\n config: LoadedConfig,\n file: SourceFile\n): DiscoveredEndpoint | null => {\n const source = toProjectPath(file.path, config.root);\n\n if (!isPathInside(source, config.routesRoot)) {\n return null;\n }\n\n if (!isRouteFile(source)) {\n return null;\n }\n\n const relative = relativePath(config.routesRoot, source);\n\n return {\n groupPath: normalizePath(dirname(relative)),\n localPath: normalizePath(basename(relative)),\n source,\n };\n};\n\nexport const discover = (\n snapshot: SourceSnapshot,\n config: LoadedConfig\n): DiscoveredProject => {\n const endpoints: DiscoveredEndpoint[] = [];\n const groups: DiscoveredGroup[] = [];\n\n for (const file of snapshot.files) {\n if (!isTypeScriptFile(file)) {\n continue;\n }\n\n const group = discoverGroup(config, file);\n\n if (group) {\n groups.push(group);\n continue;\n }\n\n const endpoint = discoverEndpoint(config, file);\n\n if (endpoint) {\n endpoints.push(endpoint);\n }\n }\n\n endpoints.sort((a, b) => a.source.localeCompare(b.source));\n groups.sort((a, b) => a.source.localeCompare(b.source));\n\n return {\n config,\n endpoints,\n groups,\n };\n};\n","export const ROUTE_METHODS = [\n \"get\",\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n \"options\",\n \"head\",\n \"all\",\n] as const;\n\nexport type RouteMethod = (typeof ROUTE_METHODS)[number];\n\nexport interface SourceFile {\n readonly content: string;\n readonly path: string;\n}\n\nexport interface SourceSnapshot {\n readonly files: readonly SourceFile[];\n}\n\nexport interface ModuleLoader {\n loadDefault: (modulePath: string) => Promise<unknown>;\n}\n\nexport interface CompileOptions {\n readonly outputRoot?: string;\n}\n\nexport interface CompileInput {\n readonly config: string;\n readonly loader: ModuleLoader;\n readonly options?: CompileOptions;\n readonly root?: string;\n readonly sources: SourceSnapshot;\n}\n\nexport interface RuntimeConfig {\n readonly routes?: string | undefined;\n}\n\nexport interface LoadedConfig {\n readonly root: string;\n readonly routesRoot: string;\n readonly source: string;\n readonly value: RuntimeConfig;\n}\n\nexport interface ConfigLoadResult {\n readonly config?: LoadedConfig;\n readonly diagnostics: readonly Diagnostic[];\n}\n\nexport interface DiscoveredEndpoint {\n readonly groupPath: string;\n readonly localPath: string;\n readonly source: string;\n}\n\nexport interface DiscoveredGroup {\n readonly groupPath: string;\n readonly source: string;\n}\n\nexport interface DiscoveredProject {\n readonly config: LoadedConfig;\n readonly endpoints: readonly DiscoveredEndpoint[];\n readonly groups: readonly DiscoveredGroup[];\n}\n\nexport type RouteSegment =\n | {\n readonly kind: \"static\";\n readonly value: string;\n }\n | {\n readonly kind: \"param\";\n readonly name: string;\n }\n | {\n readonly kind: \"splat\";\n readonly name?: string;\n };\n\nexport interface ParsedRoute {\n readonly groupPath: string;\n readonly method: RouteMethod;\n readonly rawSegments: readonly string[];\n readonly segments: readonly RouteSegment[];\n readonly source: string;\n}\n\nexport interface ParsedGroup {\n readonly groupPath: string;\n readonly source: string;\n}\n\nexport interface ParsedProject {\n readonly diagnostics: readonly Diagnostic[];\n readonly groups: readonly ParsedGroup[];\n readonly routes: readonly ParsedRoute[];\n}\n\nexport interface RouteModel {\n readonly fullPath: string;\n\n readonly groupPath: string;\n readonly id: string;\n\n readonly localPath: string;\n\n readonly method: RouteMethod;\n\n readonly routerPath: string;\n readonly routeSegments: readonly RouteSegment[];\n readonly source: string;\n}\n\nexport interface RouteGroup {\n readonly children: readonly string[];\n readonly configSource?: string;\n readonly id: string;\n readonly parentId?: string;\n readonly path: string;\n readonly routes: readonly string[];\n}\n\nexport interface ProjectModel {\n readonly config: LoadedConfig;\n readonly groups: readonly RouteGroup[];\n readonly routes: readonly RouteModel[];\n}\n\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"info\";\n\nexport interface Diagnostic {\n readonly code: string;\n readonly file?: string;\n readonly message: string;\n readonly severity: DiagnosticSeverity;\n}\n\nexport type ModuleKind = \"types\" | \"router\" | \"middleware\" | \"group\" | \"app\";\n\nexport interface ModulePlan {\n readonly groupId?: string;\n readonly id: string;\n readonly kind: ModuleKind;\n readonly routeId?: string;\n}\n\nexport interface CompilationPlan {\n readonly modules: readonly ModulePlan[];\n readonly outputRoot: string;\n}\n\nexport interface GeneratedModule {\n readonly code: string;\n readonly id: string;\n readonly kind: ModuleKind;\n}\n\nexport interface GeneratedOutput {\n readonly modules: readonly GeneratedModule[];\n}\n\nexport interface Compilation {\n readonly diagnostics: readonly Diagnostic[];\n readonly model: ProjectModel;\n readonly output: GeneratedOutput | null;\n readonly plan: CompilationPlan | null;\n}\n\nexport interface NoohCompiler {\n analyze: (\n parsed: ParsedProject,\n config: LoadedConfig\n ) => {\n model: ProjectModel;\n diagnostics: readonly Diagnostic[];\n };\n compile: (input: CompileInput) => Promise<Compilation>;\n discover: (\n sources: CompileInput[\"sources\"],\n config: LoadedConfig\n ) => DiscoveredProject;\n generate: (plan: CompilationPlan, model: ProjectModel) => GeneratedOutput;\n loadConfig: (input: CompileInput) => Promise<ConfigLoadResult>;\n parse: (project: DiscoveredProject) => ParsedProject;\n plan: (model: ProjectModel, outputRoot?: string) => CompilationPlan;\n}\n\nexport interface OutputDiff {\n readonly added: readonly GeneratedModule[];\n readonly changed: readonly GeneratedModule[];\n readonly removed: readonly string[];\n readonly unchanged: readonly GeneratedModule[];\n}\n\nexport interface RecompileInput {\n readonly config?: string;\n readonly loader: CompileInput[\"loader\"];\n readonly options?: CompileInput[\"options\"];\n readonly previous: Compilation;\n readonly snapshot: SourceSnapshot;\n}\n","import type {\n Diagnostic,\n DiscoveredEndpoint,\n ParsedRoute,\n RouteSegment,\n} from \"@/types\";\nimport { ROUTE_METHODS } from \"@/types\";\nimport { normalizePath } from \"@/utils/path\";\n\nconst METHOD_PATTERN =\n /^(.*)\\.(get|post|put|patch|delete|options|head|all)\\.(?:ts|tsx)$/;\n\nconst PARAM_PATTERN = /^\\[([A-Za-z0-9_]+)\\]$/;\nconst SPLAT_PATTERN = /^\\[\\.\\.\\.([A-Za-z0-9_]+)\\]$/;\n\nconst methodSet = new Set<string>(ROUTE_METHODS);\n\nconst parseSegment = (\n segment: string\n):\n | { segment: RouteSegment; error?: undefined }\n | {\n segment?: undefined;\n error: Diagnostic;\n } => {\n const parameter = segment.match(PARAM_PATTERN);\n\n if (parameter?.[1]) {\n return {\n segment: {\n kind: \"param\",\n name: parameter[1],\n },\n };\n }\n\n const splat = segment.match(SPLAT_PATTERN);\n\n if (splat?.[1]) {\n return {\n segment: {\n kind: \"splat\",\n name: splat[1],\n },\n };\n }\n\n if (segment.includes(\"[\") || segment.includes(\"]\")) {\n return {\n error: {\n code: \"NOOH003\",\n message: `Invalid route segment \"${segment}\".`,\n severity: \"error\",\n },\n };\n }\n\n if (!segment) {\n return {\n error: {\n code: \"NOOH004\",\n message: \"Route segments cannot be empty.\",\n severity: \"error\",\n },\n };\n }\n\n return {\n segment: {\n kind: \"static\",\n value: segment,\n },\n };\n};\n\nexport const parseEndpoint = (\n endpoint: DiscoveredEndpoint\n): {\n route?: ParsedRoute;\n diagnostics: readonly Diagnostic[];\n} => {\n const localParts = endpoint.localPath.split(\"/\").filter(Boolean);\n const filename = localParts.pop();\n\n if (!filename) {\n return {\n diagnostics: [\n {\n code: \"NOOH001\",\n file: endpoint.source,\n message: \"Invalid empty endpoint filename.\",\n severity: \"error\",\n },\n ],\n };\n }\n\n const match = filename.match(METHOD_PATTERN);\n\n if (!match) {\n return {\n diagnostics: [\n {\n code: \"NOOH001\",\n file: endpoint.source,\n message: 'Invalid endpoint filename. Expected \"<name>.<method>.ts\".',\n severity: \"error\",\n },\n ],\n };\n }\n\n const [_match, routeFile, method] = match;\n\n if (!(method && methodSet.has(method))) {\n return {\n diagnostics: [\n {\n code: \"NOOH002\",\n file: endpoint.source,\n message: `Unsupported HTTP method \"${method}\".`,\n severity: \"error\",\n },\n ],\n };\n }\n\n const validMethod = method as ParsedRoute[\"method\"];\n\n const routeFileSegments = routeFile?.split(\"/\").filter(Boolean) || [];\n const rawSegments = [...localParts, ...routeFileSegments];\n\n const last = rawSegments.at(-1);\n const effectiveSegments =\n last === \"index\" ? rawSegments.slice(0, -1) : rawSegments;\n\n const diagnostics: Diagnostic[] = [];\n const segments: RouteSegment[] = [];\n\n for (const rawSegment of effectiveSegments) {\n const result = parseSegment(rawSegment);\n\n if (result.error) {\n diagnostics.push({\n ...result.error,\n file: endpoint.source,\n });\n\n continue;\n }\n\n segments.push(result.segment);\n }\n\n if (diagnostics.length > 0) {\n return {\n diagnostics,\n };\n }\n\n return {\n diagnostics: [],\n route: {\n groupPath: normalizePath(endpoint.groupPath),\n method: validMethod,\n rawSegments: effectiveSegments,\n segments,\n source: endpoint.source,\n },\n };\n};\n","import { parseEndpoint } from \"@/pipeline/route-parser\";\nimport type {\n Diagnostic,\n DiscoveredProject,\n ParsedGroup,\n ParsedProject,\n ParsedRoute,\n} from \"@/types\";\n\nexport const parse = (project: DiscoveredProject): ParsedProject => {\n const routes: ParsedRoute[] = [];\n const diagnostics: Diagnostic[] = [];\n\n for (const endpoint of project.endpoints) {\n const result = parseEndpoint(endpoint);\n\n diagnostics.push(...result.diagnostics);\n\n if (result.route) {\n routes.push(result.route);\n }\n }\n\n const groups: ParsedGroup[] = project.groups.map((group) => ({\n groupPath: group.groupPath,\n source: group.source,\n }));\n\n routes.sort((a, b) => a.source.localeCompare(b.source));\n groups.sort((a, b) => a.source.localeCompare(b.source));\n\n return {\n diagnostics,\n groups,\n routes,\n };\n};\n","import type { CompilationPlan, ModulePlan, ProjectModel } from \"@/types\";\nimport { normalizePath } from \"@/utils/path\";\n\nconst DEFAULT_OUTPUT_ROOT = \".nooh\";\n\nconst modulePath = (outputRoot: string, value: string): string =>\n normalizePath(`${outputRoot}/${value}.ts`);\n\nexport const plan = (\n model: ProjectModel,\n outputRoot: string = DEFAULT_OUTPUT_ROOT\n): CompilationPlan => {\n const normalizedOutputRoot = normalizePath(outputRoot);\n\n const modules: ModulePlan[] = [\n {\n id: modulePath(normalizedOutputRoot, \"types\"),\n kind: \"types\",\n },\n {\n id: modulePath(normalizedOutputRoot, \"router/middleware\"),\n kind: \"middleware\",\n },\n ];\n\n const routerPaths = [\n ...new Set(model.routes.map((route) => route.routerPath)),\n ].sort();\n\n for (const routerPath of routerPaths) {\n const route = model.routes.find(\n (candidate) => candidate.routerPath === routerPath\n );\n\n if (!route) {\n continue;\n }\n\n modules.push({\n id: modulePath(normalizedOutputRoot, routerPath),\n kind: \"router\",\n routeId: route.routerPath,\n });\n }\n\n for (const group of model.groups) {\n const groupPath =\n group.id === \"root\" ? \"groups/root\" : `groups/${group.id}`;\n\n modules.push({\n groupId: group.id,\n id: modulePath(normalizedOutputRoot, groupPath),\n kind: \"group\",\n });\n }\n\n modules.push({\n id: modulePath(normalizedOutputRoot, \"app\"),\n kind: \"app\",\n });\n\n modules.sort((a, b) => a.id.localeCompare(b.id));\n\n return {\n modules,\n outputRoot: normalizedOutputRoot,\n };\n};\n","import { generate } from \"@/generate\";\n\nimport { analyze } from \"@/pipeline/analyze\";\nimport { loadConfig } from \"@/pipeline/config\";\nimport { discover } from \"@/pipeline/discover\";\nimport { parse } from \"@/pipeline/parse\";\nimport { plan } from \"@/pipeline/plan\";\n\nimport type { NoohCompiler } from \"@/types\";\n\nexport const createCompiler = (): NoohCompiler => ({\n analyze,\n\n compile: async (input) => {\n const configResult = await loadConfig(input);\n\n if (!configResult.config) {\n return {\n diagnostics: configResult.diagnostics,\n model: {\n config: {\n root: input.root ? input.root.replaceAll(\"\\\\\", \"/\") : \"\",\n routesRoot: \"\",\n source: input.config,\n value: {},\n },\n groups: [],\n routes: [],\n },\n output: null,\n plan: null,\n };\n }\n\n const discovered = discover(input.sources, configResult.config);\n const parsed = parse(discovered);\n const analyzed = analyze(parsed, configResult.config);\n const diagnostics = [...configResult.diagnostics, ...analyzed.diagnostics];\n\n const hasErrors = diagnostics.some(\n (diagnostic) => diagnostic.severity === \"error\"\n );\n\n if (hasErrors) {\n return {\n diagnostics,\n model: analyzed.model,\n output: null,\n plan: null,\n };\n }\n\n const compilationPlan = plan(analyzed.model, input.options?.outputRoot);\n\n const output = generate(compilationPlan, analyzed.model);\n\n return {\n diagnostics,\n model: analyzed.model,\n output,\n plan: compilationPlan,\n };\n },\n\n discover,\n generate,\n loadConfig,\n parse,\n plan,\n});\n","import { createCompiler } from \"@/compiler\";\nimport type { Compilation, CompileInput } from \"@/types\";\n\nexport const compile = (input: CompileInput): Promise<Compilation> =>\n createCompiler().compile(input);\n","import type { GeneratedModule, GeneratedOutput, OutputDiff } from \"@/types\";\n\nexport const diff = (\n previous: GeneratedOutput,\n next: GeneratedOutput\n): OutputDiff => {\n const previousMap = new Map(\n previous.modules.map((module) => [module.id, module])\n );\n\n const nextMap = new Map(next.modules.map((module) => [module.id, module]));\n\n const added: GeneratedModule[] = [];\n const changed: GeneratedModule[] = [];\n const unchanged: GeneratedModule[] = [];\n const removed: string[] = [];\n\n for (const module of next.modules) {\n const previousModule = previousMap.get(module.id);\n\n if (!previousModule) {\n added.push(module);\n continue;\n }\n\n if (previousModule.code !== module.code) {\n changed.push(module);\n continue;\n }\n\n unchanged.push(module);\n }\n\n for (const module of previous.modules) {\n if (!nextMap.has(module.id)) {\n removed.push(module.id);\n }\n }\n\n return {\n added,\n changed,\n removed,\n unchanged,\n };\n};\n","import { createCompiler } from \"@/compiler\";\nimport type { Compilation, RecompileInput } from \"@/types\";\n\nexport const recompile = (input: RecompileInput): Promise<Compilation> => {\n const compiler = createCompiler();\n\n const config = input.config ?? input.previous.model.config.source;\n\n return compiler.compile({\n config,\n loader: input.loader,\n root: input.previous.model.config.root,\n\n ...(input.options !== undefined && {\n options: input.options,\n }),\n\n sources: input.snapshot,\n });\n};\n"],"mappings":";;;;;AAMA,MAAa,iBACX,MACA,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QAAQ,KAAK,MAAM;GACnB;EACF;EAEA,UAAU,KAAK,MAAM;CACvB;CAEA,KAAK,MAAM,UAAU,SAAS,SAC5B,IAAI,CAAC,QAAQ,IAAI,OAAO,EAAE,GACxB,QAAQ,KAAK,OAAO,EAAE;CAI1B,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;;;AC1CA,MAAa,aAAa,UAAgD;CACxE,MAAM,WAAW,eAAe;CAEhC,MAAM,SAAS,MAAM,UAAU,MAAM,SAAS,MAAM,OAAO;CAE3D,OAAO,SAAS,QAAQ;EACtB;EACA,QAAQ,MAAM;EACd,MAAM,MAAM,SAAS,MAAM,OAAO;EAElC,GAAI,MAAM,YAAY,KAAA,KAAa,EACjC,SAAS,MAAM,QACjB;EAEA,SAAS,MAAM;CACjB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["isRecord","isRecord","emptyDependencyGraph"],"sources":["../src/generate/utils.ts","../src/utils/path.ts","../src/generate/app.ts","../src/generate/dependency.ts","../src/generate/error.ts","../src/generate/group.ts","../src/generate/middleware.ts","../src/generate/router.ts","../src/generate/types.ts","../src/generate/index.ts","../src/pipeline/dependencies.ts","../src/introspect.ts","../src/pipeline/analyze.ts","../src/pipeline/config.ts","../src/pipeline/discover.ts","../src/types.ts","../src/pipeline/route-parser.ts","../src/pipeline/parse.ts","../src/pipeline/plan.ts","../src/compiler.ts","../src/compile.ts","../src/diff.ts","../src/finalize.ts","../src/recompile.ts"],"sourcesContent":["import type { CompilationPlan } from \"@/types\";\n\n/**\n * Returns the output file path for a route group module.\n * The root group uses the reserved name \"root\".\n */\nexport const groupModuleId = (\n plan: CompilationPlan,\n groupId: string\n): string => {\n if (groupId === \"root\") {\n return `${plan.outputRoot}/groups/root.ts`;\n }\n\n return `${plan.outputRoot}/groups/${groupId}.ts`;\n};\n","const WINDOWS_DRIVE_REGEX = /^[A-Za-z]:\\//;\nconst LEADING_SLASH_REGEX = /^\\/+/;\nconst DRIVE_REGEX = /^([A-Za-z]):\\//;\n\nexport const isAbsolutePath = (value: string): boolean => {\n const normalized = value.replaceAll(\"\\\\\", \"/\");\n\n return normalized.startsWith(\"/\") || WINDOWS_DRIVE_REGEX.test(normalized);\n};\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ...\nexport const normalizePath = (value: string): string => {\n const normalized = value.replaceAll(\"\\\\\", \"/\");\n\n const isPosixAbsolute = normalized.startsWith(\"/\");\n const driveMatch = normalized.match(DRIVE_REGEX);\n\n const body = driveMatch\n ? normalized.slice(3)\n : // biome-ignore lint/style/noNestedTernary: ...\n isPosixAbsolute\n ? normalized.slice(1)\n : normalized;\n\n const parts = body.split(\"/\");\n const result: string[] = [];\n\n for (const part of parts) {\n if (!part || part === \".\") {\n continue;\n }\n\n if (part === \"..\") {\n if (result.length > 0 && result.at(-1) !== \"..\") {\n result.pop();\n } else if (!(isPosixAbsolute || driveMatch)) {\n result.push(\"..\");\n }\n\n continue;\n }\n\n result.push(part);\n }\n\n const joined = result.join(\"/\");\n\n if (driveMatch) {\n return joined ? `${driveMatch[1]}:/${joined}` : `${driveMatch[1]}:/`;\n }\n\n if (isPosixAbsolute) {\n return joined ? `/${joined}` : \"/\";\n }\n\n return joined;\n};\n\nexport const stripLeadingSlash = (value: string): string =>\n value.replace(LEADING_SLASH_REGEX, \"\");\n\nexport const ensureLeadingSlash = (value: string): string => {\n if (!value) {\n return \"/\";\n }\n\n return value.startsWith(\"/\") ? value : `/${value}`;\n};\n\nexport const joinPath = (...parts: string[]): string =>\n normalizePath(parts.filter(Boolean).join(\"/\"));\n\nexport const dirname = (value: string): string => {\n const normalized = normalizePath(value);\n const index = normalized.lastIndexOf(\"/\");\n\n if (index === -1) {\n return \"\";\n }\n\n if (index === 0) {\n return \"/\";\n }\n\n return normalized.slice(0, index);\n};\n\nexport const basename = (value: string): string => {\n const normalized = normalizePath(value);\n const index = normalized.lastIndexOf(\"/\");\n\n if (index === -1) {\n return normalized;\n }\n\n return normalized.slice(index + 1);\n};\n\nexport const relativePath = (from: string, to: string): string => {\n const fromParts = normalizePath(from).split(\"/\").filter(Boolean);\n const toParts = normalizePath(to).split(\"/\").filter(Boolean);\n\n let common = 0;\n\n while (\n common < fromParts.length &&\n common < toParts.length &&\n fromParts[common] === toParts[common]\n ) {\n common += 1;\n }\n\n const result = [\n ...fromParts.slice(common).map(() => \"..\"),\n ...toParts.slice(common),\n ];\n\n return result.join(\"/\");\n};\n\nexport const toProjectPath = (value: string, root: string): string => {\n const normalizedValue = normalizePath(value);\n const normalizedRoot = normalizePath(root);\n\n if (!(normalizedRoot && isAbsolutePath(normalizedRoot))) {\n return normalizedValue;\n }\n\n if (!isAbsolutePath(normalizedValue)) {\n return normalizedValue;\n }\n\n if (!isPathInside(normalizedValue, normalizedRoot)) {\n return normalizedValue;\n }\n\n return relativePath(normalizedRoot, normalizedValue);\n};\n\nexport const relativeModuleSpecifier = (\n fromModule: string,\n toSource: string\n): string => {\n const fromDirectory = dirname(fromModule);\n\n let target = normalizePath(toSource);\n\n if (target.endsWith(\".ts\")) {\n target = `${target.slice(0, -3)}.js`;\n } else if (target.endsWith(\".tsx\")) {\n target = `${target.slice(0, -4)}.js`;\n }\n\n const relative = relativePath(fromDirectory, target);\n\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n};\n\nexport const isPathInside = (file: string, root: string): boolean => {\n const normalizedFile = normalizePath(file);\n const normalizedRoot = normalizePath(root);\n\n if (normalizedFile === normalizedRoot) {\n return true;\n }\n\n return normalizedFile.startsWith(`${normalizedRoot}/`);\n};\n\nconst EXTENSION_REGEX = /\\.[^.]+$/;\nexport const removeExtension = (value: string): string =>\n value.replace(EXTENSION_REGEX, \"\");\n","import { groupModuleId } from \"@/generate/utils\";\n\nimport type { CompilationPlan, GeneratedModule, ProjectModel } from \"@/types\";\nimport { relativeModuleSpecifier } from \"@/utils/path\";\n\nexport const generateAppModule = (\n plan: CompilationPlan,\n model: ProjectModel\n): GeneratedModule => {\n const moduleId = `${plan.outputRoot}/app.ts`;\n const typesModuleId = `${plan.outputRoot}/types.ts`;\n const errorModuleId = `${plan.outputRoot}/error.ts`;\n\n const root = model.groups.find((group) => group.id === \"root\");\n\n if (!root) {\n throw new Error(\"Nooh compilation requires a root route group.\");\n }\n\n const imports = [\n `import { Hono } from \"hono\";`,\n `import config from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, model.config.source)\n )};`,\n `import type { App } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, typesModuleId)\n )};`,\n `import { defaultErrorHandler } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, errorModuleId)\n )};`,\n `import root from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, groupModuleId(plan, root.id))\n )};`,\n ];\n\n const code = [\n ...imports,\n \"\",\n \"const app = new Hono<App>();\",\n \"\",\n \"if (config.onError !== undefined) {\",\n \" app.onError(\",\n \" config.onError as Parameters<typeof app.onError>[0],\",\n \" );\",\n \"} else {\",\n \" app.onError(defaultErrorHandler);\",\n \"}\",\n \"\",\n 'app.route(\"/\", root);',\n \"\",\n \"export type AppType = typeof app;\",\n \"\",\n \"export default app;\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"app\",\n };\n};\n","import type { CompilationPlan, GeneratedModule } from \"@/types\";\n\nexport const generateDependencyModule = (\n plan: CompilationPlan\n): GeneratedModule => {\n const moduleId = `${plan.outputRoot}/router/di.ts`;\n\n const code = [\n \"import type {\",\n \" DependencyResolutionContext,\",\n '} from \"@nooh-ts/nooh\";',\n \"\",\n\n \"const requestContexts =\",\n \" new WeakMap<object, DependencyResolutionContext>();\",\n \"\",\n\n \"export const createDependencyResolutionContext = (): DependencyResolutionContext => ({\",\n \" cache: new Map<object, unknown>(),\",\n \" resolving: new Set<object>(),\",\n \" stack: [],\",\n \"});\",\n \"\",\n\n \"export const getDependencyResolutionContext = (\",\n \" request: object,\",\n \"): DependencyResolutionContext => {\",\n \" const existing = requestContexts.get(request);\",\n \"\",\n \" if (existing) {\",\n \" return existing;\",\n \" }\",\n \"\",\n \" const created = createDependencyResolutionContext();\",\n \"\",\n \" requestContexts.set(request, created);\",\n \"\",\n \" return created;\",\n \"};\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"di\",\n };\n};\n","/** biome-ignore-all lint/suspicious/noTemplateCurlyInString: ... */\nimport type { CompilationPlan, GeneratedModule } from \"@/types\";\nimport { relativeModuleSpecifier } from \"@/utils/path\";\n\nexport const generateErrorModule = (plan: CompilationPlan): GeneratedModule => {\n const moduleId = `${plan.outputRoot}/error.ts`;\n const typesModuleId = `${plan.outputRoot}/types.ts`;\n\n const code = [\n `import { HTTPException } from \"hono/http-exception\";`,\n `import type { ErrorHandler } from \"hono\";`,\n `import type { App } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, typesModuleId)\n )};`,\n `import type { NoohStandardSchema } from \"@nooh-ts/nooh\";`,\n \"\",\n \"const isRecord = (\",\n \" value: unknown,\",\n \"): value is Record<PropertyKey, unknown> =>\",\n ' typeof value === \"object\" && value !== null;',\n \"\",\n \"export class ResponseValidationError extends Error {\",\n \" readonly route: string;\",\n \" readonly issues: readonly unknown[];\",\n \"\",\n \" constructor(\",\n \" route: string,\",\n \" issues: readonly unknown[],\",\n \" ) {\",\n \" super(`Response validation failed for ${route}.`);\",\n ' this.name = \"ResponseValidationError\";',\n \" this.route = route;\",\n \" this.issues = issues;\",\n \" }\",\n \"}\",\n \"\",\n \"const extractResponseValue = async (\",\n \" response: Response,\",\n \" route: string,\",\n \"): Promise<unknown> => {\",\n \" if (\",\n \" response.status === 204 ||\",\n \" response.status === 205 ||\",\n \" response.status === 304 ||\",\n \" response.body === null\",\n \" ) {\",\n \" return undefined;\",\n \" }\",\n \"\",\n \" const contentType =\",\n ' response.headers.get(\"content-type\")?.split(\";\", 1)[0]?.trim().toLowerCase() ??',\n ' \"\";',\n \"\",\n \" let clone: Response;\",\n \"\",\n \" try {\",\n \" clone = response.clone();\",\n \" } catch {\",\n \" throw new ResponseValidationError(route, [\",\n \" {\",\n ' message: \"The response body could not be cloned for validation.\",',\n \" },\",\n \" ]);\",\n \" }\",\n \"\",\n \" if (\",\n ' contentType === \"application/json\" ||',\n ' contentType.endsWith(\"+json\")',\n \" ) {\",\n \" try {\",\n \" return await clone.json();\",\n \" } catch {\",\n \" throw new ResponseValidationError(route, [\",\n \" {\",\n ' message: \"The response body is not valid JSON.\",',\n \" },\",\n \" ]);\",\n \" }\",\n \" }\",\n \"\",\n ' if (contentType.startsWith(\"text/\")) {',\n \" return clone.text();\",\n \" }\",\n \"\",\n \" throw new ResponseValidationError(route, [\",\n \" {\",\n \" message:\",\n \" `Response validation only supports JSON and text responses. ` +\",\n ' `Received \"${contentType || \"unknown\"}\".`,',\n \" },\",\n \" ]);\",\n \"};\",\n \"\",\n \"export const validateResponse = async (\",\n \" response: Response,\",\n \" schema: NoohStandardSchema,\",\n \" route: string,\",\n \"): Promise<Response> => {\",\n \" const value = await extractResponseValue(response, route);\",\n \"\",\n ' const validate = schema[\"~standard\"]',\n \" .validate as (value: unknown) =>\",\n \" | unknown\",\n \" | Promise<unknown>;\",\n \"\",\n \" const result = await validate(value);\",\n \"\",\n \" if (\",\n \" isRecord(result) &&\",\n ' \"issues\" in result &&',\n \" Array.isArray(result.issues)\",\n \" ) {\",\n \" throw new ResponseValidationError(route, result.issues);\",\n \" }\",\n \"\",\n \" return response;\",\n \"};\",\n \"\",\n \"export const defaultErrorHandler: ErrorHandler<App> = (error, c) => {\",\n \" if (error instanceof HTTPException) {\",\n \" return error.getResponse();\",\n \" }\",\n \"\",\n \" console.error(error);\",\n \"\",\n ' return c.json({ error: \"Internal Server Error\" }, 500);',\n \"};\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"error\",\n };\n};\n","import { groupModuleId } from \"@/generate/utils\";\n\nimport type {\n CompilationPlan,\n GeneratedModule,\n ProjectModel,\n RouteGroup,\n RouteModel,\n} from \"@/types\";\nimport { ensureLeadingSlash, relativeModuleSpecifier } from \"@/utils/path\";\n\nconst getGroupRoutes = (\n model: ProjectModel,\n group: RouteGroup\n): readonly RouteModel[] => {\n const ids = new Set(group.routes);\n\n return model.routes\n .filter((route) => ids.has(route.id))\n .sort((a, b) => {\n const pathDifference = a.localPath.localeCompare(b.localPath);\n\n if (pathDifference !== 0) {\n return pathDifference;\n }\n\n const methodDifference = a.method.localeCompare(b.method);\n\n if (methodDifference !== 0) {\n return methodDifference;\n }\n\n return a.source.localeCompare(b.source);\n });\n};\n\nconst capitalize = (value: string): string =>\n value.charAt(0).toUpperCase() + value.slice(1);\n\nconst getGroup = (model: ProjectModel, id: string): RouteGroup | undefined =>\n model.groups.find((group) => group.id === id);\n\nconst getChildPath = (parent: RouteGroup, child: RouteGroup): string => {\n if (parent.path === \"/\") {\n return child.path;\n }\n\n const prefix = `${parent.path}/`;\n\n if (!child.path.startsWith(prefix)) {\n throw new Error(\n `Invalid group tree: \"${child.path}\" is not a child of \"${parent.path}\".`\n );\n }\n\n return child.path.slice(prefix.length);\n};\n\nexport const generateGroupModule = (\n plan: CompilationPlan,\n model: ProjectModel,\n group: RouteGroup\n): GeneratedModule => {\n const moduleId = groupModuleId(plan, group.id);\n const typesModuleId = `${plan.outputRoot}/types.ts`;\n const routes = getGroupRoutes(model, group);\n\n const children = group.children\n .map((childId) => getGroup(model, childId))\n .filter((child): child is RouteGroup => child !== undefined)\n .sort((a, b) => a.path.localeCompare(b.path));\n\n const imports = [\n `import { Hono } from \"hono\";`,\n `import type { App } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, typesModuleId)\n )};`,\n ];\n\n if (group.configSource) {\n imports.push(\n `import groupConfig from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, group.configSource)\n )};`\n );\n }\n\n children.forEach((child, index) => {\n imports.push(\n `import child${index} from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, groupModuleId(plan, child.id))\n )};`\n );\n });\n\n routes.forEach((route, index) => {\n imports.push(\n `import endpoint${index} from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, route.source)\n )};`\n );\n });\n\n const methods = [...new Set(routes.map((route) => route.method))].sort();\n\n const registerTypes = [\n \"type RouteRegister = (\",\n \" path: string,\",\n \" ...handlers: any[]\",\n \") => typeof route;\",\n ];\n\n const registerDeclarations = methods.map((method) => {\n const name = `register${capitalize(method)}`;\n\n return `const ${name} = route.${method} as unknown as RouteRegister;`;\n });\n\n const useDeclaration = group.configSource\n ? [\n \"type RouteUse = (\",\n \" path: string,\",\n \" ...handlers: any[]\",\n \") => typeof route;\",\n \"\",\n \"const use = route.use as unknown as RouteUse;\",\n \"\",\n 'use(\"*\", ...(groupConfig.middleware ?? []));',\n ]\n : [];\n\n const routeRegistrations = routes.map((route, index) => {\n const register = `register${capitalize(route.method)}`;\n const path = JSON.stringify(ensureLeadingSlash(route.localPath));\n const endpointApp = `endpointApp${index}`;\n const endpointRegister = `registerEndpoint${index}`;\n\n return [\n ` if (endpoint${index}.onError === undefined) {`,\n ` ${register}(${path}, ...endpoint${index});`,\n \" } else {\",\n ` const ${endpointApp} = new Hono<App>();`,\n ` ${endpointApp}.onError(`,\n ` endpoint${index}.onError as Parameters<typeof ${endpointApp}.onError>[0],`,\n \" );\",\n ` const ${endpointRegister} = ${endpointApp}.${route.method} as unknown as RouteRegister;`,\n ` ${endpointRegister}(${path}, ...endpoint${index});`,\n ` route.route(${path}, ${endpointApp});`,\n \" }\",\n ].join(\"\\n\");\n });\n\n const childRegistrations = children.map(\n (child, index) =>\n ` route.route(${JSON.stringify(\n getChildPath(group, child)\n )}, child${index});`\n );\n\n const groupErrorHandler = group.configSource\n ? [\n \"\",\n \"if (groupConfig.onError !== undefined) {\",\n \" route.onError(groupConfig.onError);\",\n \"}\",\n ]\n : [];\n\n const code = [\n ...imports,\n \"\",\n \"const route = new Hono<App>();\",\n \"\",\n ...registerTypes,\n \"\",\n ...registerDeclarations,\n ...(useDeclaration.length > 0 ? [\"\", ...useDeclaration] : []),\n ...groupErrorHandler,\n ...(routeRegistrations.length > 0 ? [\"\", ...routeRegistrations] : []),\n ...(childRegistrations.length > 0 ? [\"\", ...childRegistrations] : []),\n \"\",\n \"export default route;\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"group\",\n };\n};\n","import type { CompilationPlan, GeneratedModule } from \"@/types\";\n\nexport const generateMiddlewareModule = (\n plan: CompilationPlan\n): GeneratedModule => {\n const moduleId = `${plan.outputRoot}/router/middleware.ts`;\n\n return {\n code: [\n `import { createMiddleware } from \"hono/factory\";`,\n `import type { App } from \"../types.js\";`,\n \"\",\n \"export const middleware = createMiddleware<App>;\",\n \"\",\n ].join(\"\\n\"),\n id: moduleId,\n kind: \"middleware\",\n };\n};\n","import type {\n CompilationPlan,\n GeneratedModule,\n ProjectModel,\n RouteDependencyModel,\n RouteModel,\n} from \"@/types\";\nimport { ensureLeadingSlash, relativeModuleSpecifier } from \"@/utils/path\";\n\nconst METHOD_FUNCTION_NAMES: Record<RouteModel[\"method\"], string> = {\n all: \"all\",\n delete: \"del\",\n get: \"get\",\n head: \"head\",\n options: \"options\",\n patch: \"patch\",\n post: \"post\",\n put: \"put\",\n};\n\nexport type RouterGenerationMode = \"runtime\" | \"introspection\";\n\nconst getRoutesForRouter = (\n model: ProjectModel,\n routerPath: string\n): readonly RouteModel[] =>\n model.routes\n .filter((route) => route.routerPath === routerPath)\n .sort((a, b) => a.method.localeCompare(b.method));\n\nconst getRouteDependencyModel = (\n model: ProjectModel,\n routeId: string\n): RouteDependencyModel | undefined =>\n model.routeDependencies.find((route) => route.routeId === routeId);\n\nconst getDependencyNames = (\n model: ProjectModel,\n route: RouteModel\n): readonly string[] => {\n const dependencyModel = getRouteDependencyModel(model, route.id);\n\n if (!dependencyModel) {\n return [];\n }\n\n return dependencyModel.roots.map((dependencyId) => {\n const node = model.dependencies.nodes.get(dependencyId);\n\n if (!node) {\n throw new Error(\n [\n \"Nooh internal error:\",\n `dependency \"${dependencyId}\"`,\n `for route \"${route.id}\" is missing`,\n \"from the dependency graph.\",\n ].join(\" \")\n );\n }\n\n return node.declaration.name;\n });\n};\n\nconst renderMethod = (\n model: ProjectModel,\n route: RouteModel,\n mode: RouterGenerationMode\n): string => {\n const functionName = METHOD_FUNCTION_NAMES[route.method];\n\n const prefix = functionName.charAt(0).toUpperCase() + functionName.slice(1);\n\n const path = JSON.stringify(ensureLeadingSlash(route.localPath));\n const routeLabel = JSON.stringify(\n `${route.method.toUpperCase()} ${ensureLeadingSlash(route.localPath)}`\n );\n\n const dependencyNames = getDependencyNames(model, route);\n\n const common = [\n `type ${prefix}Path = ${path};`,\n \"\",\n `type ${prefix}RouteMiddleware = MiddlewareHandler<App, ${prefix}Path>;`,\n \"\",\n `type ${prefix}RouteHandler = Handler<App, ${prefix}Path, any, any>;`,\n \"\",\n\n `type ${prefix}ValidationSchemaMap = Record<`,\n \" NoohRequestValidationTarget,\",\n \" NoohStandardSchema\",\n \">;\",\n \"\",\n\n `type ${prefix}ValidationOptions = Partial<${prefix}ValidationSchemaMap> & {`,\n \" readonly response?: NoohStandardSchema;\",\n \"};\",\n \"\",\n\n `type ${prefix}ValidationEntry<`,\n \" Target extends NoohRequestValidationTarget,\",\n \" Schema extends NoohStandardSchema\",\n \"> = undefined extends NoohStandardSchemaInput<Schema>\",\n \" ? {\",\n \" readonly in: {\",\n \" readonly [Key in Target]?: NoohStandardSchemaInput<Schema>;\",\n \" };\",\n \" readonly out: {\",\n \" readonly [Key in Target]: NoohStandardSchemaOutput<Schema>;\",\n \" };\",\n \" }\",\n \" : {\",\n \" readonly in: {\",\n \" readonly [Key in Target]: NoohStandardSchemaInput<Schema>;\",\n \" };\",\n \" readonly out: {\",\n \" readonly [Key in Target]: NoohStandardSchemaOutput<Schema>;\",\n \" };\",\n \" };\",\n \"\",\n\n `type ${prefix}ValidationInput<V extends ${prefix}ValidationOptions> =`,\n \" keyof V extends never\",\n \" ? {}\",\n \" : UnionToIntersection<{\",\n \" [Target in keyof V & NoohRequestValidationTarget]:\",\n \" V[Target] extends NoohStandardSchema\",\n \" ? \",\n ` ${prefix}ValidationEntry<Target, V[Target]>`,\n \" : never\",\n \" }[keyof V &\",\n \" NoohRequestValidationTarget]>;\",\n \"\",\n `type ${prefix}ResponseSchema<V extends ${prefix}ValidationOptions> =`,\n \" V extends {\",\n \" readonly response: infer Schema extends NoohStandardSchema;\",\n \" }\",\n \" ? Schema\",\n \" : never;\",\n \"\",\n `type ${prefix}NoohHandlerReturn<V extends ${prefix}ValidationOptions> =`,\n \" V extends {\",\n \" readonly response: infer Schema extends NoohStandardSchema;\",\n \" }\",\n \" ? Response &\",\n \" TypedResponse<\",\n \" NoohStandardSchemaInput<Schema>,\",\n \" any,\",\n \" any\",\n \" >\",\n \" | Promise<\",\n \" Response &\",\n \" TypedResponse<\",\n \" NoohStandardSchemaInput<Schema>,\",\n \" any,\",\n \" any\",\n \" >\",\n \" >\",\n ` : ReturnType<${prefix}RouteHandler>;`,\n \"\",\n\n `type ${prefix}RouteContext<V extends ${prefix}ValidationOptions> =`,\n \" Context<\",\n \" App,\",\n ` ${prefix}Path,`,\n ` ${prefix}ValidationInput<V>`,\n \" >;\",\n \"\",\n\n `type ${prefix}RouteNext = Parameters<${prefix}RouteHandler>[1];`,\n \"\",\n\n `type ${prefix}RouteErrorHandler = NoohErrorHandler<App, ${prefix}Path>;`,\n \"\",\n\n `type ${prefix}HandlerInput<`,\n \" D extends readonly RouteDependency[],\",\n ` V extends ${prefix}ValidationOptions,`,\n \" E extends ErrorDefinitions\",\n \"> = {\",\n ` readonly c: ${prefix}RouteContext<V>;`,\n ` readonly next: ${prefix}RouteNext;`,\n \"} & DependencyContext<D> & (\",\n \" keyof E extends never\",\n \" ? {}\",\n \" : { readonly errors: ErrorContext<E> }\",\n \");\",\n \"\",\n `type ${prefix}NoohHandler<`,\n \" D extends readonly RouteDependency[],\",\n ` V extends ${prefix}ValidationOptions,`,\n \" E extends ErrorDefinitions\",\n \"> = (\",\n ` input: ${prefix}HandlerInput<D, V, E>`,\n `) => ${prefix}NoohHandlerReturn<V>;`,\n \"\",\n `type ${prefix}RouteHandlers = readonly ${prefix}RouteHandler[] & {`,\n ` readonly onError?: ${prefix}RouteErrorHandler;`,\n \"};\",\n \"\",\n\n `type ${prefix}EndpointOptions<`,\n \" D extends readonly RouteDependency[] = readonly RouteDependency[],\",\n ` V extends ${prefix}ValidationOptions = ${prefix}ValidationOptions,`,\n ` M extends readonly ${prefix}RouteMiddleware[] = readonly ${prefix}RouteMiddleware[],`,\n \" E extends ErrorDefinitions = {}\",\n \"> = {\",\n \" readonly middleware?: M;\",\n \" readonly validation?: V;\",\n \" readonly deps?: D & ValidateDependencies<D, ReservedDependencyName>;\",\n \" readonly errors?: E;\",\n ` readonly onError?: ${prefix}RouteErrorHandler;`,\n ` readonly handler: ${prefix}NoohHandler<D, V, E>;`,\n \"};\",\n \"\",\n\n `export function ${functionName}(`,\n ` handler: ${prefix}RouteHandler`,\n `): ${prefix}RouteHandlers;`,\n \"\",\n `export function ${functionName}<`,\n \" const D extends readonly RouteDependency[] = [],\",\n ` const V extends ${prefix}ValidationOptions = {},`,\n ` const M extends readonly ${prefix}RouteMiddleware[] = [],`,\n \" const E extends ErrorDefinitions = {}\",\n \">(\",\n ` options: ${prefix}EndpointOptions<D, V, M, E>`,\n `): ${prefix}RouteHandlers;`,\n \"\",\n `export function ${functionName}(`,\n \" input:\",\n ` | ${prefix}RouteHandler`,\n ` | ${prefix}EndpointOptions`,\n `): ${prefix}RouteHandlers {`,\n ];\n\n if (mode === \"introspection\") {\n return [\n ...common,\n \"\",\n ' if (typeof input === \"function\") {',\n \" return defineRouteMetadata(\",\n \" [input],\",\n \" [],\",\n ` ) as unknown as ${prefix}RouteHandlers;`,\n \" }\",\n \"\",\n \" return defineRouteMetadata(\",\n ` [input.handler as unknown as ${prefix}RouteHandler],`,\n \" input.deps ?? [],\",\n ` ) as unknown as ${prefix}RouteHandlers;`,\n \"}\",\n \"\",\n ].join(\"\\n\");\n }\n\n const dependencyResolution = dependencyNames.flatMap((_, index) => [\n ` const resolvedDependency${index} = dependencies[${index}]!.resolve(dependencyContext);`,\n ]);\n\n const dependencyProperties = dependencyNames.map(\n (name, index) =>\n ` ${JSON.stringify(name)}: resolvedDependency${index},`\n );\n\n return [\n ...common,\n \"\",\n ' if (typeof input === \"function\") {',\n ` return defineRouteHandlers<${prefix}Path>([input]);`,\n \" }\",\n \"\",\n \" const dependencies = input.deps ?? [];\",\n \"\",\n \" const errors =\",\n \" input.errors === undefined\",\n \" ? undefined\",\n \" : createErrorContext(input.errors);\",\n \"\",\n\n ` const handler: ${prefix}RouteHandler = async (c, next) => {`,\n ...(dependencyNames.length > 0\n ? [\n \" const dependencyContext =\",\n \" getDependencyResolutionContext(c);\",\n \"\",\n ...dependencyResolution,\n \"\",\n ]\n : []),\n\n \" const response = await input.handler({\",\n \" c: c as unknown as\",\n ` ${prefix}RouteContext<${prefix}ValidationOptions>,`,\n \" next,\",\n ...(dependencyNames.length > 0 ? dependencyProperties : []),\n \" ...(errors !== undefined ? { errors } : {})\",\n \" });\",\n \"\",\n\n \" if (input.validation?.response !== undefined) {\",\n \" return validateResponse(\",\n \" response as Response,\",\n \" input.validation.response,\",\n ` ${routeLabel}`,\n \" );\",\n \" }\",\n \"\",\n \" return response;\",\n \" };\",\n \"\",\n \" const handlers = [\",\n ` ...((input.middleware ?? []) as readonly ${prefix}RouteHandler[]),`,\n ...([\"json\", \"form\", \"query\", \"param\", \"header\", \"cookie\"] as const).map(\n (target) =>\n ` ...(input.validation?.${target} !== undefined ? [validatorEngine(${JSON.stringify(\n target\n )}, input.validation.${target}) as ${prefix}RouteHandler] : []),`\n ),\n \" handler,\",\n \" ] as const;\",\n \"\",\n ` return defineRouteHandlers<${prefix}Path>(handlers, input.onError);`,\n \"}\",\n \"\",\n ].join(\"\\n\");\n};\n\nconst COMMON_TYPES = [\n \"type RouteDependency = AnyDependencyReference;\",\n \"\",\n \"type ErrorDefinitions = Record<string, ErrorConstructor>;\",\n \"\",\n \"type UnionToIntersection<Union> =\",\n \" (Union extends unknown\",\n \" ? (value: Union) => void\",\n \" : never) extends\",\n \" (value: infer Intersection) => void\",\n \" ? Intersection\",\n \" : never;\",\n \"\",\n \"type ReservedDependencyName =\",\n ' | \"c\"',\n ' | \"next\"',\n ' | \"error\"',\n ' | \"errors\"',\n ' | \"onError\"',\n ' | \"response\"',\n \" | NoohValidationTarget;\",\n];\n\nexport const generateRouterModule = (\n plan: CompilationPlan,\n model: ProjectModel,\n routerPath: string,\n mode: RouterGenerationMode = \"runtime\"\n): GeneratedModule => {\n const routes = getRoutesForRouter(model, routerPath);\n\n const moduleId = `${plan.outputRoot}/${routerPath}.ts`;\n\n const typesModuleId = `${plan.outputRoot}/types.ts`;\n\n const dependencyModuleId = `${plan.outputRoot}/router/di.ts`;\n\n const errorModuleId = `${plan.outputRoot}/error.ts`;\n\n const configModuleId = model.config.source;\n\n const usesDependencies =\n mode === \"runtime\" &&\n routes.some((route) => {\n const dependencyModel = getRouteDependencyModel(model, route.id);\n\n return !!dependencyModel?.roots.length;\n });\n\n const imports: string[] = [\n \"import type {\",\n \" Context,\",\n \" Handler,\",\n \" MiddlewareHandler,\",\n \" TypedResponse\",\n '} from \"hono\";',\n \"import type {\",\n \" AnyDependencyReference,\",\n \" DependencyContext,\",\n \" ErrorContext,\",\n \" ErrorConstructor,\",\n \" NoohErrorHandler,\",\n \" NoohRequestValidationTarget,\",\n \" NoohStandardSchema,\",\n \" NoohStandardSchemaInput,\",\n \" NoohStandardSchemaOutput,\",\n \" NoohValidationTarget,\",\n \" ValidateDependencies\",\n '} from \"@nooh-ts/nooh\";',\n `import type { App } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, typesModuleId)\n )};`,\n ];\n\n if (mode === \"runtime\") {\n imports.unshift(\n `import { sValidator } from \"@hono/standard-validator\";`,\n `import config from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, configModuleId)\n )};`,\n `import { validateResponse } from ${JSON.stringify(\n relativeModuleSpecifier(moduleId, errorModuleId)\n )};`\n );\n }\n\n if (usesDependencies) {\n imports.push(\n \"import {\",\n \" getDependencyResolutionContext\",\n \"} from \" +\n JSON.stringify(relativeModuleSpecifier(moduleId, dependencyModuleId)) +\n \";\"\n );\n }\n\n const prelude: string[] = [\"\", ...COMMON_TYPES];\n\n if (mode === \"runtime\") {\n prelude.push(\n \"\",\n \"const validatorEngine = (\",\n \" config.validator?.engine ?? sValidator\",\n \") as unknown as (\",\n \" target: NoohRequestValidationTarget,\",\n \" schema: NoohStandardSchema\",\n \") => unknown;\"\n );\n }\n\n if (mode === \"runtime\") {\n prelude.push(\n \"\",\n \"const createErrorContext = <\",\n \" const E extends ErrorDefinitions\",\n \">(\",\n \" definitions: E | undefined\",\n \"): ErrorContext<E> => {\",\n \" const errors: Record<string, unknown> = {};\",\n \"\",\n \" if (definitions === undefined) {\",\n \" return errors as ErrorContext<E>;\",\n \" }\",\n \"\",\n \" for (const [name, Constructor] of Object.entries(definitions)) {\",\n \" errors[name] = (...args: unknown[]) =>\",\n \" Reflect.construct(Constructor, args);\",\n \" }\",\n \"\",\n \" return errors as ErrorContext<E>;\",\n \"};\",\n \"\",\n \"const defineRouteHandlers = <\",\n \" const P extends string,\",\n \" const T extends readonly Handler<App, P, any, any>[]\",\n \">(\",\n \" handlers: T,\",\n \" onError?: NoohErrorHandler<App, P>\",\n \"): T & { readonly onError?: NoohErrorHandler<App, P> } => {\",\n \" if (onError !== undefined) {\",\n ' Object.defineProperty(handlers, \"onError\", {',\n \" configurable: false,\",\n \" enumerable: false,\",\n \" value: onError,\",\n \" writable: false\",\n \" });\",\n \" }\",\n \"\",\n \" return handlers as T & {\",\n \" readonly onError?: NoohErrorHandler<App, P>\",\n \" };\",\n \"};\"\n );\n }\n\n if (mode === \"introspection\") {\n prelude.push(\n \"\",\n 'const NOOH_ROUTE_METADATA = Symbol.for(\"nooh.route\");',\n \"\",\n \"type NoohRouteMetadata = {\",\n ' readonly kind: \"route\";',\n \" readonly dependencies: readonly RouteDependency[]\",\n \"};\",\n \"\",\n \"const defineRouteMetadata = <\",\n \" T extends readonly unknown[]\",\n \">(\",\n \" handlers: T,\",\n \" dependencies: readonly RouteDependency[]\",\n \"): T => {\",\n \" const metadata: NoohRouteMetadata = {\",\n ' kind: \"route\",',\n \" dependencies\",\n \"};\",\n \"\",\n \" Object.defineProperty(\",\n \" handlers,\",\n \" NOOH_ROUTE_METADATA,\",\n \" {\",\n \" value: metadata,\",\n \" enumerable: false\",\n \" }\",\n \" );\",\n \"\",\n \" return handlers;\",\n \"};\"\n );\n }\n\n const code = [\n ...imports,\n ...prelude,\n \"\",\n ...routes.map((route) => renderMethod(model, route, mode)),\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"router\",\n };\n};\n","import type { CompilationPlan, GeneratedModule, LoadedConfig } from \"@/types\";\nimport { relativeModuleSpecifier } from \"@/utils/path\";\n\nexport const generateTypesModule = (\n plan: CompilationPlan,\n config: LoadedConfig\n): GeneratedModule => {\n const moduleId = `${plan.outputRoot}/types.ts`;\n\n const configImport = relativeModuleSpecifier(moduleId, config.source);\n\n const code = [\n `import type config from \"${configImport}\";`,\n \"\",\n \"type ExtractEnvironment<T> = T extends {\",\n \" readonly __nooh_env: infer Environment;\",\n \"}\",\n \" ? Environment\",\n \" : never;\",\n \"\",\n \"export type App = ExtractEnvironment<typeof config>;\",\n \"\",\n ].join(\"\\n\");\n\n return {\n code,\n id: moduleId,\n kind: \"types\",\n };\n};\n","import { generateAppModule } from \"@/generate/app\";\nimport { generateDependencyModule } from \"@/generate/dependency\";\nimport { generateErrorModule } from \"@/generate/error\";\nimport { generateGroupModule } from \"@/generate/group\";\nimport { generateMiddlewareModule } from \"@/generate/middleware\";\nimport { generateRouterModule } from \"@/generate/router\";\nimport { generateTypesModule } from \"@/generate/types\";\n\nimport type {\n CompilationPlan,\n GeneratedModule,\n GeneratedOutput,\n ProjectModel,\n} from \"@/types\";\n\nconst getRouterPaths = (model: ProjectModel): readonly string[] =>\n [...new Set(model.routes.map((route) => route.routerPath))].sort();\n\nexport const generate = (\n plan: CompilationPlan,\n model: ProjectModel\n): GeneratedOutput => {\n const modules: GeneratedModule[] = [];\n\n modules.push(generateTypesModule(plan, model.config));\n\n modules.push(generateDependencyModule(plan));\n\n modules.push(generateErrorModule(plan));\n\n modules.push(generateMiddlewareModule(plan));\n\n for (const routerPath of getRouterPaths(model)) {\n modules.push(generateRouterModule(plan, model, routerPath));\n }\n\n for (const group of model.groups) {\n modules.push(generateGroupModule(plan, model, group));\n }\n\n modules.push(generateAppModule(plan, model));\n\n modules.sort((a, b) => a.id.localeCompare(b.id));\n\n return {\n modules,\n };\n};\n\nexport const generateRouteIntrospection = (\n plan: CompilationPlan,\n model: ProjectModel\n): GeneratedOutput => {\n const modules: GeneratedModule[] = [];\n\n for (const routerPath of getRouterPaths(model)) {\n modules.push(\n generateRouterModule(plan, model, routerPath, \"introspection\")\n );\n }\n\n modules.sort((a, b) => a.id.localeCompare(b.id));\n\n return {\n modules,\n };\n};\n","import type {\n DependencyDeclaration,\n DependencyGraph,\n DependencyNode,\n DependencyScope,\n Diagnostic,\n ModuleLoader,\n SourceFile,\n} from \"@/types\";\n\ninterface DependencyReferenceLike {\n readonly __nooh_dependency: true;\n readonly dependencies: readonly unknown[];\n readonly name: string;\n readonly scope: DependencyScope;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isDependencyReference = (\n value: unknown\n): value is DependencyReferenceLike =>\n isRecord(value) &&\n value.__nooh_dependency === true &&\n typeof value.name === \"string\" &&\n Array.isArray(value.dependencies) &&\n (value.scope === \"value\" ||\n value.scope === \"singleton\" ||\n value.scope === \"request\" ||\n value.scope === \"transient\");\n\nconst isDependencyContainer = (\n value: unknown\n): value is Record<string, unknown> => {\n if (!isRecord(value) || Array.isArray(value)) {\n return false;\n }\n\n if (!Object.isFrozen(value)) {\n return false;\n }\n\n const entries = Object.entries(value);\n\n return (\n entries.length > 0 &&\n entries.every(([, entry]) => isDependencyReference(entry))\n );\n};\n\nconst emptyGraph = (): DependencyGraph => ({\n nodes: new Map(),\n order: [],\n references: new Map(),\n});\n\nconst canDependOn = (\n parent: DependencyScope,\n child: DependencyScope\n): boolean => {\n if (parent === \"singleton\") {\n return child === \"singleton\" || child === \"value\";\n }\n\n if (parent === \"request\") {\n return (\n child === \"singleton\" ||\n child === \"request\" ||\n child === \"transient\" ||\n child === \"value\"\n );\n }\n\n if (parent === \"transient\") {\n return true;\n }\n\n return child === \"value\";\n};\n\nconst createScopeDiagnostic = (\n declaration: DependencyDeclaration,\n dependency: DependencyDeclaration\n): Diagnostic | null => {\n if (canDependOn(declaration.scope, dependency.scope)) {\n return null;\n }\n\n return {\n code: \"NOOH020\",\n file: declaration.source,\n message: [\n `Dependency \"${declaration.name}\" with scope \"${declaration.scope}\"`,\n `cannot depend on \"${dependency.name}\" with scope \"${dependency.scope}\".`,\n ].join(\" \"),\n severity: \"error\",\n };\n};\n\nconst createMissingDependencyDiagnostic = (\n declaration: DependencyDeclaration,\n dependencyId: string\n): Diagnostic => ({\n code: \"NOOH021\",\n file: declaration.source,\n message: [\n `Dependency \"${declaration.name}\" references`,\n `unknown dependency \"${dependencyId}\".`,\n ].join(\" \"),\n severity: \"error\",\n});\n\nconst createDuplicateDependencyDiagnostic = (\n declaration: DependencyDeclaration\n): Diagnostic => ({\n code: \"NOOH022\",\n file: declaration.source,\n message: `Duplicate dependency provider \"${declaration.id}\".`,\n severity: \"error\",\n});\n\nconst createCycleDiagnostic = (\n cycle: readonly DependencyNode[]\n): Diagnostic => {\n const [first] = cycle;\n\n return {\n code: \"NOOH023\",\n ...(first?.declaration.source !== undefined && {\n file: first.declaration.source,\n }),\n message: `Circular dependency detected: ${cycle\n .map((node) => node.declaration.name)\n .join(\" -> \")}`,\n severity: \"error\",\n };\n};\n\nconst topologicalOrder = (\n nodes: ReadonlyMap<string, DependencyNode>,\n diagnostics: Diagnostic[]\n): readonly string[] => {\n const state = new Map<string, \"unvisited\" | \"visiting\" | \"visited\">();\n const stack: string[] = [];\n const order: string[] = [];\n\n const visit = (id: string): void => {\n const current = state.get(id);\n\n if (current === \"visited\") {\n return;\n }\n\n if (current === \"visiting\") {\n const cycleStart = stack.indexOf(id);\n\n const cycleIds =\n cycleStart === -1 ? [...stack, id] : [...stack.slice(cycleStart), id];\n\n const cycle = cycleIds\n .map((cycleId) => nodes.get(cycleId))\n .filter((n): n is DependencyNode => n !== undefined);\n\n diagnostics.push(createCycleDiagnostic(cycle));\n\n return;\n }\n\n const node = nodes.get(id);\n\n if (!node) {\n return;\n }\n\n state.set(id, \"visiting\");\n stack.push(id);\n\n for (const dependencyId of node.declaration.dependencies) {\n visit(dependencyId);\n }\n\n stack.pop();\n state.set(id, \"visited\");\n\n order.push(id);\n };\n\n const ids = [...nodes.keys()].sort();\n\n for (const id of ids) {\n visit(id);\n }\n\n return order;\n};\n\nexport const createDependencyGraph = (\n declarations: readonly DependencyDeclaration[],\n references: ReadonlyMap<object, string> = new Map()\n): {\n readonly diagnostics: readonly Diagnostic[];\n readonly graph: DependencyGraph;\n} => {\n if (declarations.length === 0) {\n return {\n diagnostics: [],\n graph: {\n ...emptyGraph(),\n references,\n },\n };\n }\n\n const diagnostics: Diagnostic[] = [];\n const nodes = new Map<string, DependencyNode>();\n\n for (const declaration of declarations) {\n if (nodes.has(declaration.id)) {\n diagnostics.push(createDuplicateDependencyDiagnostic(declaration));\n\n continue;\n }\n\n nodes.set(declaration.id, {\n declaration,\n });\n }\n\n for (const declaration of declarations) {\n const node = nodes.get(declaration.id);\n\n if (!node) {\n continue;\n }\n\n for (const dependencyId of declaration.dependencies) {\n const dependencyNode = nodes.get(dependencyId);\n\n if (!dependencyNode) {\n diagnostics.push(\n createMissingDependencyDiagnostic(declaration, dependencyId)\n );\n\n continue;\n }\n\n const scopeDiagnostic = createScopeDiagnostic(\n declaration,\n dependencyNode.declaration\n );\n\n if (scopeDiagnostic) {\n diagnostics.push(scopeDiagnostic);\n }\n }\n }\n\n const order = topologicalOrder(nodes, diagnostics);\n\n const unique = new Map<string, Diagnostic>();\n\n for (const diagnostic of diagnostics) {\n const key = [\n diagnostic.code,\n diagnostic.file ?? \"\",\n diagnostic.message,\n ].join(\"\\0\");\n\n unique.set(key, diagnostic);\n }\n\n return {\n diagnostics: [...unique.values()],\n graph: {\n nodes,\n order,\n references,\n },\n };\n};\n\nconst loadModule = async (\n loader: ModuleLoader,\n path: string\n): Promise<Record<string, unknown>> => {\n if (loader.loadModule) {\n return loader.loadModule(path);\n }\n\n const value = await loader.loadDefault(path);\n\n return {\n default: value,\n };\n};\n\ninterface LoadedReference {\n readonly id: string;\n readonly name: string;\n readonly reference: DependencyReferenceLike;\n readonly scope: DependencyScope;\n readonly source: string;\n}\n\nconst collectReferences = (\n source: string,\n module: Record<string, unknown>\n): {\n readonly diagnostics: readonly Diagnostic[];\n readonly references: readonly LoadedReference[];\n} => {\n const diagnostics: Diagnostic[] = [];\n const references: LoadedReference[] = [];\n\n const seenObjects = new Set<object>();\n\n const addReference = (id: string, value: DependencyReferenceLike): void => {\n if (seenObjects.has(value)) {\n diagnostics.push({\n code: \"NOOH027\",\n file: source,\n message: [\n `Dependency reference \"${value.name}\"`,\n \"is exported more than once.\",\n `Duplicate provider: \"${id}\".`,\n ].join(\" \"),\n severity: \"error\",\n });\n\n return;\n }\n\n seenObjects.add(value);\n\n references.push({\n id,\n name: value.name,\n reference: value,\n scope: value.scope,\n source,\n });\n };\n\n for (const [exportName, exported] of Object.entries(module)) {\n if (exportName === \"__esModule\") {\n continue;\n }\n\n if (isDependencyReference(exported)) {\n addReference(`${source}#${exportName}`, exported);\n\n continue;\n }\n\n if (isDependencyContainer(exported)) {\n for (const [name, reference] of Object.entries(exported)) {\n if (!isDependencyReference(reference)) {\n continue;\n }\n\n addReference(`${source}#${exportName}.${name}`, reference);\n }\n }\n }\n\n return {\n diagnostics,\n references,\n };\n};\n\nexport const loadDependencyGraph = async (\n sources: readonly SourceFile[],\n loader: ModuleLoader\n): Promise<{\n readonly diagnostics: readonly Diagnostic[];\n readonly graph: DependencyGraph;\n}> => {\n if (sources.length === 0) {\n return {\n diagnostics: [],\n graph: emptyGraph(),\n };\n }\n\n const diagnostics: Diagnostic[] = [];\n const loaded: LoadedReference[] = [];\n\n for (const source of sources) {\n let module: Record<string, unknown> | undefined;\n\n try {\n // biome-ignore lint/performance/noAwaitInLoops: ...\n module = await loadModule(loader, source.path);\n } catch (error) {\n diagnostics.push({\n code: \"NOOH024\",\n file: source.path,\n message:\n error instanceof Error\n ? [\"Failed to load dependency module:\", error.message].join(\" \")\n : \"Failed to load dependency module.\",\n severity: \"error\",\n });\n\n continue;\n }\n\n const result = collectReferences(source.path, module);\n\n diagnostics.push(...result.diagnostics);\n\n loaded.push(...result.references);\n }\n\n const references = new Map<object, string>();\n\n for (const entry of loaded) {\n references.set(entry.reference, entry.id);\n }\n\n const declarations: DependencyDeclaration[] = [];\n\n for (const entry of loaded) {\n const dependencies: string[] = [];\n\n for (const dependency of entry.reference.dependencies) {\n if (!isDependencyReference(dependency)) {\n diagnostics.push({\n code: \"NOOH026\",\n file: entry.source,\n message: [\n `Dependency \"${entry.name}\" contains`,\n \"an invalid dependency reference.\",\n ].join(\" \"),\n severity: \"error\",\n });\n\n continue;\n }\n\n const dependencyId = references.get(dependency);\n\n if (!dependencyId) {\n diagnostics.push({\n code: \"NOOH021\",\n file: entry.source,\n message: [\n `Dependency \"${entry.name}\" references`,\n `an unknown dependency \"${dependency.name}\".`,\n ].join(\" \"),\n severity: \"error\",\n });\n\n continue;\n }\n\n dependencies.push(dependencyId);\n }\n\n declarations.push({\n dependencies,\n id: entry.id,\n name: entry.name,\n scope: entry.scope,\n source: entry.source,\n });\n }\n\n const result = createDependencyGraph(declarations, references);\n\n return {\n diagnostics: [...diagnostics, ...result.diagnostics],\n graph: result.graph,\n };\n};\n\nexport const dependencyClosure = (\n graph: DependencyGraph,\n roots: readonly string[]\n): readonly string[] => {\n const visited = new Set<string>();\n const result: string[] = [];\n\n const visit = (id: string): void => {\n if (visited.has(id)) {\n return;\n }\n\n visited.add(id);\n\n const node = graph.nodes.get(id);\n\n if (!node) {\n return;\n }\n\n for (const dependencyId of node.declaration.dependencies) {\n visit(dependencyId);\n }\n\n result.push(id);\n };\n\n for (const root of roots) {\n visit(root);\n }\n\n return result;\n};\n","import { dependencyClosure } from \"@/pipeline/dependencies\";\n\nimport type {\n CompilationIntrospection,\n Diagnostic,\n IntrospectionInput,\n IntrospectionResult,\n RouteModel,\n} from \"@/types\";\n\nexport const NOOH_ROUTE_METADATA: unique symbol = Symbol.for(\"nooh.route\");\n\nexport interface RouteMetadata {\n readonly dependencies: readonly unknown[];\n readonly kind: \"route\";\n}\n\nconst isRecord = (value: unknown): value is Record<PropertyKey, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isRouteMetadata = (value: unknown): value is RouteMetadata => {\n if (!isRecord(value)) {\n return false;\n }\n\n return value.kind === \"route\" && Array.isArray(value.dependencies);\n};\n\nexport const readRouteMetadata = (value: unknown): RouteMetadata | null => {\n if (!isRecord(value)) {\n return null;\n }\n\n const metadata = value[NOOH_ROUTE_METADATA];\n\n return isRouteMetadata(metadata) ? metadata : null;\n};\n\nexport const introspectRoute = async (\n route: RouteModel,\n loader: IntrospectionInput[\"loader\"]\n): Promise<{\n readonly diagnostics: readonly Diagnostic[];\n readonly metadata?: RouteMetadata | undefined;\n}> => {\n let exported: unknown;\n\n try {\n exported = await loader.loadDefault(route.source);\n } catch (error) {\n return {\n diagnostics: [\n {\n code: \"NOOH031\",\n file: route.source,\n message:\n error instanceof Error\n ? `Failed to introspect route: ${error.message}`\n : \"Failed to introspect route.\",\n severity: \"error\",\n },\n ],\n };\n }\n\n const metadata = readRouteMetadata(exported);\n\n if (!metadata) {\n return {\n diagnostics: [\n {\n code: \"NOOH032\",\n file: route.source,\n message: [\n \"The route did not expose Nooh route metadata.\",\n \"\",\n \"Make sure the route is evaluated against\",\n \"the generated Nooh introspection router.\",\n ].join(\"\\n\"),\n severity: \"error\",\n },\n ],\n };\n }\n\n return {\n diagnostics: [],\n metadata,\n };\n};\n\nconst unknownDependencyDiagnostic = (\n route: RouteModel,\n dependency: unknown\n): Diagnostic => ({\n code: \"NOOH034\",\n file: route.source,\n message:\n isRecord(dependency) && typeof dependency.name === \"string\"\n ? [\n `Route \"${route.id}\" references unknown dependency`,\n `\"${dependency.name}\".`,\n ].join(\" \")\n : `Route \"${route.id}\" contains an invalid dependency reference.`,\n severity: \"error\",\n});\n\nconst duplicateRouteDependencyNameDiagnostic = (\n route: RouteModel,\n name: string\n): Diagnostic => ({\n code: \"NOOH035\",\n file: route.source,\n message: [\n `Route \"${route.id}\" injects multiple dependencies`,\n `with the same name \"${name}\".`,\n ].join(\" \"),\n severity: \"error\",\n});\n\nexport const introspectCompilation = async (\n input: IntrospectionInput\n): Promise<IntrospectionResult> => {\n if (!input.compilation.plan) {\n return {\n diagnostics: [\n {\n code: \"NOOH033\",\n message:\n \"Cannot introspect a compilation without a compilation plan.\",\n severity: \"error\",\n },\n ],\n introspection: null,\n };\n }\n\n const graph = input.compilation.model.dependencies;\n\n const diagnostics: Diagnostic[] = [];\n\n const routeDependencies = new Map<\n string,\n {\n readonly roots: readonly string[];\n readonly closure: readonly string[];\n }\n >();\n\n for (const route of input.compilation.model.routes) {\n // biome-ignore lint/performance/noAwaitInLoops: ...\n const result = await introspectRoute(route, input.loader);\n\n diagnostics.push(...result.diagnostics);\n\n if (!result.metadata) {\n continue;\n }\n\n const roots: string[] = [];\n const names = new Set<string>();\n\n for (const dependency of result.metadata.dependencies) {\n if (typeof dependency !== \"object\" || dependency === null) {\n diagnostics.push(unknownDependencyDiagnostic(route, dependency));\n\n continue;\n }\n\n const id = graph.references.get(dependency);\n\n if (!id) {\n diagnostics.push(unknownDependencyDiagnostic(route, dependency));\n\n continue;\n }\n\n const node = graph.nodes.get(id);\n\n if (!node) {\n diagnostics.push({\n code: \"NOOH034\",\n file: route.source,\n message: [\n `Route \"${route.id}\" references dependency`,\n `\"${id}\" that is missing from the dependency graph.`,\n ].join(\" \"),\n severity: \"error\",\n });\n\n continue;\n }\n\n const { name } = node.declaration;\n\n if (names.has(name)) {\n diagnostics.push(duplicateRouteDependencyNameDiagnostic(route, name));\n\n continue;\n }\n\n names.add(name);\n roots.push(id);\n }\n\n const closure = dependencyClosure(graph, roots);\n\n routeDependencies.set(route.id, {\n closure,\n roots,\n });\n }\n\n if (diagnostics.some((diagnostic) => diagnostic.severity === \"error\")) {\n return {\n diagnostics,\n introspection: null,\n };\n }\n\n const introspection: CompilationIntrospection = {\n dependencies: graph,\n\n routeDependencies: [...routeDependencies.entries()]\n .map(([routeId, value]) => ({\n closure: value.closure,\n roots: value.roots,\n routeId,\n }))\n .sort((a, b) => a.routeId.localeCompare(b.routeId)),\n };\n\n return {\n diagnostics,\n introspection,\n };\n};\n","import type {\n DependencyGraph,\n Diagnostic,\n LoadedConfig,\n ParsedProject,\n ParsedRoute,\n ProjectModel,\n RouteGroup,\n RouteModel,\n RouteSegment,\n} from \"@/types\";\nimport { ensureLeadingSlash, normalizePath } from \"@/utils/path\";\n\nconst emptyDependencyGraph = (): DependencyGraph => ({\n nodes: new Map(),\n order: [],\n references: new Map(),\n});\n\nconst segmentToHono = (segment: RouteSegment): string => {\n // biome-ignore lint/style/useDefaultSwitchClause: ...\n switch (segment.kind) {\n case \"static\":\n return segment.value;\n\n case \"param\":\n return `:${segment.name}`;\n\n case \"splat\":\n return \"*\";\n }\n};\n\nconst segmentsToPath = (segments: readonly RouteSegment[]): string => {\n if (segments.length === 0) {\n return \"\";\n }\n\n return segments.map(segmentToHono).join(\"/\");\n};\n\nconst combinePaths = (groupPath: string, localPath: string): string => {\n const group = normalizePath(groupPath).replace(/^\\/+|\\/+$/g, \"\");\n const local = normalizePath(localPath).replace(/^\\/+|\\/+$/g, \"\");\n\n if (!(group || local)) {\n return \"/\";\n }\n\n if (!group) {\n return `/${local}`;\n }\n\n if (!local) {\n return `/${group}`;\n }\n\n return `/${group}/${local}`;\n};\n\nconst routeSegmentsToRouterPath = (\n groupPath: string,\n rawSegments: readonly string[]\n): string => {\n const parts = [\n ...groupPath.split(\"/\").filter(Boolean),\n ...rawSegments.filter(Boolean),\n ];\n\n return parts.length === 0 ? \"router/index\" : `router/${parts.join(\"/\")}`;\n};\n\nconst routeId = (route: ParsedRoute): string =>\n `${route.method.toUpperCase()} ${combinePaths(\n route.groupPath,\n segmentsToPath(route.segments)\n )}`;\n\nconst sortRoutes = (a: RouteModel, b: RouteModel): number => {\n const pathDifference = a.fullPath.localeCompare(b.fullPath);\n\n if (pathDifference !== 0) {\n return pathDifference;\n }\n\n const methodDifference = a.method.localeCompare(b.method);\n\n if (methodDifference !== 0) {\n return methodDifference;\n }\n\n return a.source.localeCompare(b.source);\n};\n\nconst parentGroupPath = (groupPath: string): string | null => {\n const normalized = normalizePath(groupPath);\n\n if (!normalized) {\n return null;\n }\n\n const parts = normalized.split(\"/\").filter(Boolean);\n\n if (parts.length <= 1) {\n return \"\";\n }\n\n return parts.slice(0, -1).join(\"/\");\n};\n\nconst getAncestorGroupPaths = (groupPath: string): readonly string[] => {\n const parts = normalizePath(groupPath).split(\"/\").filter(Boolean);\n\n return Array.from(\n {\n length: parts.length + 1,\n },\n (_, index) => parts.slice(0, index).join(\"/\")\n );\n};\n\nconst groupId = (path: string): string => path || \"root\";\n\nconst buildGroups = (\n parsed: ParsedProject,\n routeModels: readonly RouteModel[],\n diagnostics: Diagnostic[]\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ...\n): readonly RouteGroup[] => {\n const configSources = new Map<string, string>();\n\n for (const group of parsed.groups) {\n const path = normalizePath(group.groupPath);\n const previous = configSources.get(path);\n\n if (previous) {\n diagnostics.push({\n code: \"NOOH006\",\n file: group.source,\n message: [\n `Duplicate group definition for \"${path || \"/\"}\".`,\n \"\",\n `First declaration: ${previous}`,\n `Second declaration: ${group.source}`,\n ].join(\"\\n\"),\n severity: \"error\",\n });\n\n continue;\n }\n\n configSources.set(path, group.source);\n }\n\n const groupPaths = new Set<string>([\"\"]);\n\n for (const group of parsed.groups) {\n for (const ancestor of getAncestorGroupPaths(group.groupPath)) {\n groupPaths.add(ancestor);\n }\n }\n\n for (const route of routeModels) {\n for (const ancestor of getAncestorGroupPaths(route.groupPath)) {\n groupPaths.add(ancestor);\n }\n }\n\n const routesByGroup = new Map<string, string[]>();\n\n for (const route of routeModels) {\n const routes = routesByGroup.get(route.groupPath);\n\n if (routes) {\n routes.push(route.id);\n } else {\n routesByGroup.set(route.groupPath, [route.id]);\n }\n }\n\n const childrenByGroup = new Map<string, string[]>();\n\n for (const path of groupPaths) {\n if (!path) {\n continue;\n }\n\n const parent = parentGroupPath(path) ?? \"\";\n\n const children = childrenByGroup.get(parent);\n\n if (children) {\n children.push(path);\n } else {\n childrenByGroup.set(parent, [path]);\n }\n }\n\n return [...groupPaths]\n .sort((a, b) => {\n if (!a && b) {\n return -1;\n }\n\n if (a && !b) {\n return 1;\n }\n\n return a.localeCompare(b);\n })\n .map((path) => {\n const children = [...(childrenByGroup.get(path) ?? [])].sort();\n const configSource = configSources.get(path);\n const parent = parentGroupPath(path);\n\n return {\n children: children.map(groupId),\n id: groupId(path),\n ...(parent !== null && {\n parentId: groupId(parent),\n }),\n path: path ? ensureLeadingSlash(path) : \"/\",\n routes: [...(routesByGroup.get(path) ?? [])].sort(),\n ...(configSource !== undefined && {\n configSource,\n }),\n };\n });\n};\n\nexport const analyze = (\n parsed: ParsedProject,\n config: LoadedConfig,\n dependencies: DependencyGraph = emptyDependencyGraph()\n): {\n model: ProjectModel;\n diagnostics: readonly Diagnostic[];\n} => {\n const diagnostics: Diagnostic[] = [...parsed.diagnostics];\n\n const routeModels: RouteModel[] = [];\n const seen = new Map<string, string>();\n\n for (const route of parsed.routes) {\n const localPath = segmentsToPath(route.segments);\n const fullPath = combinePaths(route.groupPath, localPath);\n const id = routeId(route);\n\n const previousSource = seen.get(id);\n\n if (previousSource) {\n diagnostics.push({\n code: \"NOOH005\",\n file: route.source,\n message: [\n `Duplicate route \"${id}\".`,\n \"\",\n `First declaration: ${previousSource}`,\n `Second declaration: ${route.source}`,\n ].join(\"\\n\"),\n severity: \"error\",\n });\n\n continue;\n }\n\n seen.set(id, route.source);\n\n routeModels.push({\n fullPath,\n groupPath: normalizePath(route.groupPath),\n id,\n localPath,\n method: route.method,\n routerPath: routeSegmentsToRouterPath(route.groupPath, route.rawSegments),\n routeSegments: route.segments,\n source: route.source,\n });\n }\n\n routeModels.sort(sortRoutes);\n\n const groups = buildGroups(parsed, routeModels, diagnostics);\n\n return {\n diagnostics,\n model: {\n config,\n dependencies,\n groups,\n routeDependencies: [],\n routes: routeModels,\n },\n };\n};\n","import type { CompileInput, ConfigLoadResult, RuntimeConfig } from \"@/types\";\nimport { normalizePath, toProjectPath } from \"@/utils/path\";\n\nconst DEFAULT_DEPENDENCIES_ROOT = \"src/deps\";\nconst DEFAULT_ROUTES_ROOT = \"src/routes\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isString = (value: unknown): value is string => typeof value === \"string\";\n\nconst isFunction = (value: unknown): value is (...args: never[]) => unknown =>\n typeof value === \"function\";\n\nexport const loadConfig = async (\n input: CompileInput\n): Promise<ConfigLoadResult> => {\n let defaultExport: unknown;\n\n try {\n defaultExport = await input.loader.loadDefault(input.config);\n } catch (error) {\n return {\n diagnostics: [\n {\n code: \"NOOH010\",\n file: input.config,\n message:\n error instanceof Error\n ? `Failed to load config: ${error.message}`\n : \"Failed to load config.\",\n severity: \"error\",\n },\n ],\n };\n }\n\n if (!isRecord(defaultExport)) {\n return {\n diagnostics: [\n {\n code: \"NOOH011\",\n file: input.config,\n message: \"The Nooh config default export must be an object.\",\n severity: \"error\",\n },\n ],\n };\n }\n\n const routesValue = defaultExport.routes;\n\n if (routesValue !== undefined && !isString(routesValue)) {\n return {\n diagnostics: [\n {\n code: \"NOOH012\",\n file: input.config,\n message: 'The Nooh config \"routes\" option must be a string.',\n severity: \"error\",\n },\n ],\n };\n }\n\n const dependenciesValue = defaultExport.dependencies;\n\n if (dependenciesValue !== undefined && !isString(dependenciesValue)) {\n return {\n diagnostics: [\n {\n code: \"NOOH013\",\n file: input.config,\n message: 'The Nooh config \"dependencies\" option must be a string.',\n severity: \"error\",\n },\n ],\n };\n }\n\n const validatorValue = defaultExport.validator;\n\n if (validatorValue !== undefined && !isRecord(validatorValue)) {\n return {\n diagnostics: [\n {\n code: \"NOOH014\",\n file: input.config,\n message: 'The Nooh config \"validator\" option must be an object.',\n severity: \"error\",\n },\n ],\n };\n }\n\n if (\n isRecord(validatorValue) &&\n validatorValue.engine !== undefined &&\n !isFunction(validatorValue.engine)\n ) {\n return {\n diagnostics: [\n {\n code: \"NOOH015\",\n file: input.config,\n message:\n 'The Nooh config \"validator.engine\" option must be a function.',\n severity: \"error\",\n },\n ],\n };\n }\n\n const root = normalizePath(input.root ?? \"\");\n const source = toProjectPath(input.config, root);\n const routes = routesValue ?? DEFAULT_ROUTES_ROOT;\n const dependencies = dependenciesValue ?? DEFAULT_DEPENDENCIES_ROOT;\n const routesRoot = toProjectPath(routes, root);\n const dependenciesRoot = toProjectPath(dependencies, root);\n\n const value: RuntimeConfig = {\n dependencies: dependenciesValue,\n routes: routesValue,\n };\n\n return {\n config: {\n dependenciesRoot,\n root,\n routesRoot,\n source,\n value,\n },\n diagnostics: [],\n };\n};\n","import type {\n DiscoveredEndpoint,\n DiscoveredGroup,\n DiscoveredProject,\n LoadedConfig,\n SourceFile,\n SourceSnapshot,\n} from \"@/types\";\nimport {\n basename,\n dirname,\n isPathInside,\n normalizePath,\n relativePath,\n toProjectPath,\n} from \"@/utils/path\";\n\nconst ROUTE_FILE_PATTERN =\n /\\.(get|post|put|patch|delete|options|head|all)\\.(?:ts|tsx)$/;\n\nconst isTypeScriptFile = (file: SourceFile): boolean =>\n file.path.endsWith(\".ts\") || file.path.endsWith(\".tsx\");\n\nconst isRouteFile = (filePath: string): boolean =>\n ROUTE_FILE_PATTERN.test(filePath);\n\nconst isGroupFile = (filePath: string): boolean => {\n const filename = basename(filePath);\n\n return filename === \"$.ts\" || filename === \"$.tsx\";\n};\n\nconst discoverDependency = (\n config: LoadedConfig,\n file: SourceFile\n): SourceFile | null => {\n const source = toProjectPath(file.path, config.root);\n\n if (!isPathInside(source, config.dependenciesRoot)) {\n return null;\n }\n\n return {\n content: file.content,\n path: source,\n };\n};\n\nconst discoverGroup = (\n config: LoadedConfig,\n file: SourceFile\n): DiscoveredGroup | null => {\n const source = toProjectPath(file.path, config.root);\n\n if (!isPathInside(source, config.routesRoot)) {\n return null;\n }\n\n if (!isGroupFile(source)) {\n return null;\n }\n\n const relative = relativePath(config.routesRoot, source);\n const directory = dirname(relative);\n\n return {\n groupPath: normalizePath(directory),\n source,\n };\n};\n\nconst discoverEndpoint = (\n config: LoadedConfig,\n file: SourceFile\n): DiscoveredEndpoint | null => {\n const source = toProjectPath(file.path, config.root);\n\n if (!isPathInside(source, config.routesRoot)) {\n return null;\n }\n\n if (!isRouteFile(source)) {\n return null;\n }\n\n const relative = relativePath(config.routesRoot, source);\n\n return {\n groupPath: normalizePath(dirname(relative)),\n localPath: normalizePath(basename(relative)),\n source,\n };\n};\n\nexport const discover = (\n snapshot: SourceSnapshot,\n config: LoadedConfig\n): DiscoveredProject => {\n const endpoints: DiscoveredEndpoint[] = [];\n const groups: DiscoveredGroup[] = [];\n const dependencies: SourceFile[] = [];\n\n for (const file of snapshot.files) {\n if (!isTypeScriptFile(file)) {\n continue;\n }\n\n const dependency = discoverDependency(config, file);\n\n if (dependency) {\n dependencies.push(dependency);\n continue;\n }\n\n const group = discoverGroup(config, file);\n\n if (group) {\n groups.push(group);\n continue;\n }\n\n const endpoint = discoverEndpoint(config, file);\n\n if (endpoint) {\n endpoints.push(endpoint);\n }\n }\n dependencies.sort((a, b) => a.path.localeCompare(b.path));\n\n endpoints.sort((a, b) => a.source.localeCompare(b.source));\n groups.sort((a, b) => a.source.localeCompare(b.source));\n\n return {\n config,\n dependencies,\n endpoints,\n groups,\n };\n};\n","export const ROUTE_METHODS = [\n \"get\",\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n \"options\",\n \"head\",\n \"all\",\n] as const;\n\nexport type RouteMethod = (typeof ROUTE_METHODS)[number];\n\nexport interface SourceFile {\n readonly content: string;\n readonly path: string;\n}\n\nexport interface SourceSnapshot {\n readonly files: readonly SourceFile[];\n}\n\nexport interface ModuleLoader {\n loadDefault: (modulePath: string) => Promise<unknown>;\n loadModule?: (modulePath: string) => Promise<Record<string, unknown>>;\n}\n\nexport interface CompileOptions {\n readonly outputRoot?: string;\n}\n\nexport interface CompileInput {\n readonly config: string;\n readonly loader: ModuleLoader;\n readonly options?: CompileOptions;\n readonly root?: string;\n readonly sources: SourceSnapshot;\n}\n\nexport interface RuntimeConfig {\n readonly dependencies?: string | undefined;\n readonly routes?: string | undefined;\n}\n\nexport interface LoadedConfig {\n readonly dependenciesRoot: string;\n readonly root: string;\n readonly routesRoot: string;\n readonly source: string;\n readonly value: RuntimeConfig;\n}\n\nexport interface ConfigLoadResult {\n readonly config?: LoadedConfig;\n readonly diagnostics: readonly Diagnostic[];\n}\n\nexport interface DiscoveredEndpoint {\n readonly groupPath: string;\n readonly localPath: string;\n readonly source: string;\n}\n\nexport interface DiscoveredGroup {\n readonly groupPath: string;\n readonly source: string;\n}\n\nexport interface DiscoveredProject {\n readonly config: LoadedConfig;\n readonly dependencies: readonly SourceFile[];\n readonly endpoints: readonly DiscoveredEndpoint[];\n readonly groups: readonly DiscoveredGroup[];\n}\n\nexport type RouteSegment =\n | {\n readonly kind: \"static\";\n readonly value: string;\n }\n | {\n readonly kind: \"param\";\n readonly name: string;\n }\n | {\n readonly kind: \"splat\";\n readonly name?: string;\n };\n\nexport interface ParsedRoute {\n readonly groupPath: string;\n readonly method: RouteMethod;\n readonly rawSegments: readonly string[];\n readonly segments: readonly RouteSegment[];\n readonly source: string;\n}\n\nexport interface ParsedGroup {\n readonly groupPath: string;\n readonly source: string;\n}\n\nexport interface ParsedProject {\n readonly diagnostics: readonly Diagnostic[];\n readonly groups: readonly ParsedGroup[];\n readonly routes: readonly ParsedRoute[];\n}\n\nexport interface RouteModel {\n readonly fullPath: string;\n\n readonly groupPath: string;\n readonly id: string;\n\n readonly localPath: string;\n\n readonly method: RouteMethod;\n\n readonly routerPath: string;\n readonly routeSegments: readonly RouteSegment[];\n readonly source: string;\n}\n\nexport type DependencyScope = \"value\" | \"singleton\" | \"request\" | \"transient\";\n\nexport interface DependencyDeclaration {\n readonly dependencies: readonly string[];\n readonly id: string;\n readonly name: string;\n readonly scope: DependencyScope;\n readonly source: string;\n}\n\nexport interface DependencyNode {\n readonly declaration: DependencyDeclaration;\n}\n\nexport interface DependencyGraph {\n readonly nodes: ReadonlyMap<string, DependencyNode>;\n readonly order: readonly string[];\n readonly references: ReadonlyMap<object, string>;\n}\n\nexport interface RouteDependencyModel {\n readonly closure: readonly string[];\n readonly roots: readonly string[];\n readonly routeId: string;\n}\n\nexport interface CompilationIntrospection {\n readonly dependencies: DependencyGraph;\n readonly routeDependencies: readonly RouteDependencyModel[];\n}\n\nexport interface IntrospectionInput {\n readonly compilation: Compilation;\n readonly dependencySources: readonly SourceFile[];\n readonly loader: ModuleLoader;\n}\n\nexport interface IntrospectionResult {\n readonly diagnostics: readonly Diagnostic[];\n readonly introspection: CompilationIntrospection | null;\n}\n\nexport interface RouteGroup {\n readonly children: readonly string[];\n readonly configSource?: string;\n readonly id: string;\n readonly parentId?: string;\n readonly path: string;\n readonly routes: readonly string[];\n}\n\nexport interface ProjectModel {\n readonly config: LoadedConfig;\n readonly dependencies: DependencyGraph;\n readonly groups: readonly RouteGroup[];\n readonly routeDependencies: readonly RouteDependencyModel[];\n readonly routes: readonly RouteModel[];\n}\n\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"info\";\n\nexport interface Diagnostic {\n readonly code: string;\n readonly file?: string;\n readonly message: string;\n readonly severity: DiagnosticSeverity;\n}\n\nexport type ModuleKind =\n | \"types\"\n | \"router\"\n | \"middleware\"\n | \"group\"\n | \"di\"\n | \"error\"\n | \"app\";\n\nexport interface ModulePlan {\n readonly groupId?: string;\n readonly id: string;\n readonly kind: ModuleKind;\n readonly routeId?: string;\n}\n\nexport interface CompilationPlan {\n readonly dependencies: DependencyGraph;\n readonly modules: readonly ModulePlan[];\n readonly outputRoot: string;\n readonly routeDependencies: readonly RouteDependencyModel[];\n}\n\nexport interface GeneratedModule {\n readonly code: string;\n readonly id: string;\n readonly kind: ModuleKind;\n}\n\nexport interface GeneratedOutput {\n readonly modules: readonly GeneratedModule[];\n}\n\nexport interface Compilation {\n readonly diagnostics: readonly Diagnostic[];\n readonly model: ProjectModel;\n readonly output: GeneratedOutput | null;\n readonly plan: CompilationPlan | null;\n}\n\nexport interface NoohCompiler {\n analyze: (\n parsed: ParsedProject,\n config: LoadedConfig,\n dependencies?: DependencyGraph\n ) => {\n model: ProjectModel;\n diagnostics: readonly Diagnostic[];\n };\n compile: (input: CompileInput) => Promise<Compilation>;\n discover: (\n sources: CompileInput[\"sources\"],\n config: LoadedConfig\n ) => DiscoveredProject;\n generate: (plan: CompilationPlan, model: ProjectModel) => GeneratedOutput;\n generateRouteIntrospection: (\n plan: CompilationPlan,\n model: ProjectModel\n ) => GeneratedOutput;\n loadConfig: (input: CompileInput) => Promise<ConfigLoadResult>;\n parse: (project: DiscoveredProject) => ParsedProject;\n plan: (model: ProjectModel, outputRoot?: string) => CompilationPlan;\n}\n\nexport interface OutputDiff {\n readonly added: readonly GeneratedModule[];\n readonly changed: readonly GeneratedModule[];\n readonly removed: readonly string[];\n readonly unchanged: readonly GeneratedModule[];\n}\n\nexport interface RecompileInput {\n readonly config?: string;\n readonly loader: CompileInput[\"loader\"];\n readonly options?: CompileInput[\"options\"];\n readonly previous: Compilation;\n readonly snapshot: SourceSnapshot;\n}\n","import type {\n Diagnostic,\n DiscoveredEndpoint,\n ParsedRoute,\n RouteSegment,\n} from \"@/types\";\nimport { ROUTE_METHODS } from \"@/types\";\nimport { normalizePath } from \"@/utils/path\";\n\nconst METHOD_PATTERN =\n /^(.*)\\.(get|post|put|patch|delete|options|head|all)\\.(?:ts|tsx)$/;\n\nconst PARAM_PATTERN = /^\\[([A-Za-z0-9_]+)\\]$/;\nconst SPLAT_PATTERN = /^\\[\\.\\.\\.([A-Za-z0-9_]+)\\]$/;\n\nconst methodSet = new Set<string>(ROUTE_METHODS);\n\nconst parseSegment = (\n segment: string\n):\n | { segment: RouteSegment; error?: undefined }\n | {\n segment?: undefined;\n error: Diagnostic;\n } => {\n const parameter = segment.match(PARAM_PATTERN);\n\n if (parameter?.[1]) {\n return {\n segment: {\n kind: \"param\",\n name: parameter[1],\n },\n };\n }\n\n const splat = segment.match(SPLAT_PATTERN);\n\n if (splat?.[1]) {\n return {\n segment: {\n kind: \"splat\",\n name: splat[1],\n },\n };\n }\n\n if (segment.includes(\"[\") || segment.includes(\"]\")) {\n return {\n error: {\n code: \"NOOH003\",\n message: `Invalid route segment \"${segment}\".`,\n severity: \"error\",\n },\n };\n }\n\n if (!segment) {\n return {\n error: {\n code: \"NOOH004\",\n message: \"Route segments cannot be empty.\",\n severity: \"error\",\n },\n };\n }\n\n return {\n segment: {\n kind: \"static\",\n value: segment,\n },\n };\n};\n\nexport const parseEndpoint = (\n endpoint: DiscoveredEndpoint\n): {\n route?: ParsedRoute;\n diagnostics: readonly Diagnostic[];\n} => {\n const localParts = endpoint.localPath.split(\"/\").filter(Boolean);\n const filename = localParts.pop();\n\n if (!filename) {\n return {\n diagnostics: [\n {\n code: \"NOOH001\",\n file: endpoint.source,\n message: \"Invalid empty endpoint filename.\",\n severity: \"error\",\n },\n ],\n };\n }\n\n const match = filename.match(METHOD_PATTERN);\n\n if (!match) {\n return {\n diagnostics: [\n {\n code: \"NOOH001\",\n file: endpoint.source,\n message: 'Invalid endpoint filename. Expected \"<name>.<method>.ts\".',\n severity: \"error\",\n },\n ],\n };\n }\n\n const [_match, routeFile, method] = match;\n\n if (!(method && methodSet.has(method))) {\n return {\n diagnostics: [\n {\n code: \"NOOH002\",\n file: endpoint.source,\n message: `Unsupported HTTP method \"${method}\".`,\n severity: \"error\",\n },\n ],\n };\n }\n\n const validMethod = method as ParsedRoute[\"method\"];\n\n const routeFileSegments = routeFile?.split(\"/\").filter(Boolean) || [];\n const rawSegments = [...localParts, ...routeFileSegments];\n\n const last = rawSegments.at(-1);\n const effectiveSegments =\n last === \"index\" ? rawSegments.slice(0, -1) : rawSegments;\n\n const diagnostics: Diagnostic[] = [];\n const segments: RouteSegment[] = [];\n\n for (const rawSegment of effectiveSegments) {\n const result = parseSegment(rawSegment);\n\n if (result.error) {\n diagnostics.push({\n ...result.error,\n file: endpoint.source,\n });\n\n continue;\n }\n\n segments.push(result.segment);\n }\n\n if (diagnostics.length > 0) {\n return {\n diagnostics,\n };\n }\n\n return {\n diagnostics: [],\n route: {\n groupPath: normalizePath(endpoint.groupPath),\n method: validMethod,\n rawSegments: effectiveSegments,\n segments,\n source: endpoint.source,\n },\n };\n};\n","import { parseEndpoint } from \"@/pipeline/route-parser\";\nimport type {\n Diagnostic,\n DiscoveredProject,\n ParsedGroup,\n ParsedProject,\n ParsedRoute,\n} from \"@/types\";\n\nexport const parse = (project: DiscoveredProject): ParsedProject => {\n const routes: ParsedRoute[] = [];\n const diagnostics: Diagnostic[] = [];\n\n for (const endpoint of project.endpoints) {\n const result = parseEndpoint(endpoint);\n\n diagnostics.push(...result.diagnostics);\n\n if (result.route) {\n routes.push(result.route);\n }\n }\n\n const groups: ParsedGroup[] = project.groups.map((group) => ({\n groupPath: group.groupPath,\n source: group.source,\n }));\n\n routes.sort((a, b) => a.source.localeCompare(b.source));\n groups.sort((a, b) => a.source.localeCompare(b.source));\n\n return {\n diagnostics,\n groups,\n routes,\n };\n};\n","import type { CompilationPlan, ModulePlan, ProjectModel } from \"@/types\";\nimport { normalizePath } from \"@/utils/path\";\n\nconst DEFAULT_OUTPUT_ROOT = \".nooh\";\n\nconst modulePath = (outputRoot: string, value: string): string =>\n normalizePath(`${outputRoot}/${value}.ts`);\n\nexport const plan = (\n model: ProjectModel,\n outputRoot: string = DEFAULT_OUTPUT_ROOT\n): CompilationPlan => {\n const normalizedOutputRoot = normalizePath(outputRoot);\n\n const modules: ModulePlan[] = [\n {\n id: modulePath(normalizedOutputRoot, \"types\"),\n kind: \"types\",\n },\n {\n id: modulePath(normalizedOutputRoot, \"router/di\"),\n kind: \"di\",\n },\n {\n id: modulePath(normalizedOutputRoot, \"router/middleware\"),\n kind: \"middleware\",\n },\n {\n id: modulePath(normalizedOutputRoot, \"error\"),\n kind: \"error\",\n },\n ];\n\n const routerPaths = [\n ...new Set(model.routes.map((route) => route.routerPath)),\n ].sort();\n\n for (const routerPath of routerPaths) {\n const route = model.routes.find(\n (candidate) => candidate.routerPath === routerPath\n );\n\n if (!route) {\n continue;\n }\n\n modules.push({\n id: modulePath(normalizedOutputRoot, routerPath),\n kind: \"router\",\n routeId: route.routerPath,\n });\n }\n\n for (const group of model.groups) {\n const groupPath =\n group.id === \"root\" ? \"groups/root\" : `groups/${group.id}`;\n\n modules.push({\n groupId: group.id,\n id: modulePath(normalizedOutputRoot, groupPath),\n kind: \"group\",\n });\n }\n\n modules.push({\n id: modulePath(normalizedOutputRoot, \"app\"),\n kind: \"app\",\n });\n\n modules.sort((a, b) => a.id.localeCompare(b.id));\n\n return {\n dependencies: model.dependencies,\n modules,\n outputRoot: normalizedOutputRoot,\n };\n};\n","import { generate, generateRouteIntrospection } from \"@/generate\";\nimport { introspectCompilation } from \"@/introspect\";\n\nimport { analyze } from \"@/pipeline/analyze\";\nimport { loadConfig } from \"@/pipeline/config\";\nimport { loadDependencyGraph } from \"@/pipeline/dependencies\";\nimport { discover } from \"@/pipeline/discover\";\nimport { parse } from \"@/pipeline/parse\";\nimport { plan } from \"@/pipeline/plan\";\n\nimport type {\n Compilation,\n CompileInput,\n IntrospectionInput,\n IntrospectionResult,\n NoohCompiler,\n} from \"@/types\";\n\nconst emptyDependencyGraph = {\n nodes: new Map(),\n order: [],\n references: new Map(),\n};\n\nexport const createCompiler = (): NoohCompiler => ({\n analyze,\n\n compile: async (input: CompileInput): Promise<Compilation> => {\n const configResult = await loadConfig(input);\n\n if (!configResult.config) {\n return {\n diagnostics: configResult.diagnostics,\n model: {\n config: {\n dependenciesRoot: \"\",\n root: input.root ? input.root.replaceAll(\"\\\\\", \"/\") : \"\",\n routesRoot: \"\",\n source: input.config,\n value: {},\n },\n dependencies: emptyDependencyGraph,\n groups: [],\n routeDependencies: [],\n routes: [],\n },\n output: null,\n plan: null,\n };\n }\n\n const discovered = discover(input.sources, configResult.config);\n const parsed = parse(discovered);\n\n const dependencyResult = await loadDependencyGraph(\n discovered.dependencies,\n input.loader\n );\n\n const analyzed = analyze(\n parsed,\n configResult.config,\n dependencyResult.graph\n );\n\n const diagnostics = [\n ...configResult.diagnostics,\n ...dependencyResult.diagnostics,\n ...analyzed.diagnostics,\n ];\n\n const hasErrors = diagnostics.some(\n (diagnostic) => diagnostic.severity === \"error\"\n );\n\n if (hasErrors) {\n return {\n diagnostics,\n model: analyzed.model,\n output: null,\n plan: null,\n };\n }\n\n const compilationPlan = plan(analyzed.model, input.options?.outputRoot);\n\n const output = generateRouteIntrospection(compilationPlan, analyzed.model);\n\n return {\n diagnostics,\n model: analyzed.model,\n output,\n plan: compilationPlan,\n };\n },\n\n discover,\n generate,\n generateRouteIntrospection,\n loadConfig,\n parse,\n plan,\n});\n\nexport const introspect = (\n input: IntrospectionInput\n): Promise<IntrospectionResult> => introspectCompilation(input);\n","import { createCompiler } from \"@/compiler\";\nimport type { Compilation, CompileInput } from \"@/types\";\n\nexport const compile = (input: CompileInput): Promise<Compilation> =>\n createCompiler().compile(input);\n","import type { GeneratedModule, GeneratedOutput, OutputDiff } from \"@/types\";\n\nexport const diff = (\n previous: GeneratedOutput,\n next: GeneratedOutput\n): OutputDiff => {\n const previousMap = new Map(\n previous.modules.map((module) => [module.id, module])\n );\n\n const nextMap = new Map(next.modules.map((module) => [module.id, module]));\n\n const added: GeneratedModule[] = [];\n const changed: GeneratedModule[] = [];\n const unchanged: GeneratedModule[] = [];\n const removed: string[] = [];\n\n for (const module of next.modules) {\n const previousModule = previousMap.get(module.id);\n\n if (!previousModule) {\n added.push(module);\n continue;\n }\n\n if (previousModule.code !== module.code) {\n changed.push(module);\n continue;\n }\n\n unchanged.push(module);\n }\n\n for (const module of previous.modules) {\n if (!nextMap.has(module.id)) {\n removed.push(module.id);\n }\n }\n\n return {\n added,\n changed,\n removed,\n unchanged,\n };\n};\n","import type { Compilation, CompilationIntrospection } from \"@/types\";\n\nexport const finalizeCompilation = (\n compilation: Compilation,\n introspection: CompilationIntrospection\n): Compilation => {\n if (!(compilation.plan && compilation.output)) {\n return compilation;\n }\n\n const model = {\n ...compilation.model,\n dependencies: introspection.dependencies,\n routeDependencies: introspection.routeDependencies,\n };\n\n const plan = {\n ...compilation.plan,\n dependencies: introspection.dependencies,\n routeDependencies: introspection.routeDependencies,\n };\n\n return {\n ...compilation,\n model,\n plan,\n };\n};\n","import { createCompiler } from \"@/compiler\";\nimport type { Compilation, RecompileInput } from \"@/types\";\n\nexport const recompile = (input: RecompileInput): Promise<Compilation> => {\n const compiler = createCompiler();\n\n const config = input.config ?? input.previous.model.config.source;\n\n return compiler.compile({\n config,\n loader: input.loader,\n root: input.previous.model.config.root,\n\n ...(input.options !== undefined && {\n options: input.options,\n }),\n\n sources: input.snapshot,\n });\n};\n"],"mappings":";;;;;AAMA,MAAa,iBACX,MACA,YACW;CACX,IAAI,YAAY,QACd,OAAO,GAAG,KAAK,WAAW;CAG5B,OAAO,GAAG,KAAK,WAAW,UAAU,QAAQ;AAC9C;;;ACfA,MAAM,sBAAsB;AAE5B,MAAM,cAAc;AAEpB,MAAa,kBAAkB,UAA2B;CACxD,MAAM,aAAa,MAAM,WAAW,MAAM,GAAG;CAE7C,OAAO,WAAW,WAAW,GAAG,KAAK,oBAA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GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,CAAC,KAAK,IAGF;EACH,IAAI;EACJ,MAAM;CACR;AACF;;;AC5HA,MAAM,kBACJ,OACA,UAC0B;CAC1B,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM;CAEhC,OAAO,MAAM,OACV,QAAQ,UAAU,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC,CACpC,MAAM,GAAG,MAAM;EACd,MAAM,iBAAiB,EAAE,UAAU,cAAc,EAAE,SAAS;EAE5D,IAAI,mBAAmB,GACrB,OAAO;EAGT,MAAM,mBAAmB,EAAE,OAAO,cAAc,EAAE,MAAM;EAExD,IAAI,qBAAqB,GACvB,OAAO;EAGT,OAAO,EAAE,OAAO,cAAc,EAAE,MAAM;CACxC,CAAC;AACL;AAEA,MAAM,cAAc,UAClB,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AAE/C,MAAM,YAAY,OAAqB,OACrC,MAAM,OAAO,MAAM,UAAU,MAAM,OAAO,EAAE;AAE9C,MAAM,gBAAgB,QAAoB,UAA8B;CACtE,IAAI,OAAO,SAAS,KAClB,OAAO,MAAM;CAGf,MAAM,SAAS,GAAG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