{"version":3,"file":"ui-seam.mjs","names":[],"sources":["../../../../../src/services/scaffold/upgrade-audit/checks/ui-seam.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { Finding, type RouterSeam } from \"../domain\";\nimport { fileExists, readText } from \"../fs\";\n\nconst ROUTER_PATH = \"ui/src/router.tsx\";\nconst APP_PATH = \"ui/src/app.ts\";\n\nconst AUTHORED_SEAM_RE = /everything-dev\\/ui\\/router-client/;\nconst MONOLITHIC_RE = /createTanStackRouter\\s*\\(/;\n\nexport const detectRouterSeam = (source: string): RouterSeam => {\n  if (AUTHORED_SEAM_RE.test(source)) return \"authored-seam\";\n  if (MONOLITHIC_RE.test(source)) return \"monolithic\";\n  return \"unknown\";\n};\n\nexport const readRouterSeam = (projectDir: string): Effect.Effect<RouterSeam, Error> =>\n  Effect.gen(function* () {\n    const exists = yield* fileExists(projectDir, ROUTER_PATH);\n    if (!exists) return \"absent\";\n    return detectRouterSeam(yield* readText(projectDir, ROUTER_PATH));\n  });\n\nconst hasExport = (source: string, name: string): boolean =>\n  new RegExp(`export\\\\s+(?:const|function)\\\\s+${name}\\\\b`).test(source);\n\nexport const checkUiSeam = (projectDir: string): Effect.Effect<Finding[], Error> =>\n  Effect.gen(function* () {\n    const findings: Finding[] = [];\n\n    const routerSeam = yield* readRouterSeam(projectDir);\n    if (routerSeam === \"absent\") {\n      findings.push(\n        new Finding({\n          check: \"ui-seam\",\n          path: ROUTER_PATH,\n          severity: \"warn\",\n          message:\n            \"ui/src/router.tsx not found — the authored router seam (ADR 0023) is required by the generated hydrate/SSR stubs\",\n        }),\n      );\n    }\n    if (routerSeam === \"monolithic\") {\n      findings.push(\n        new Finding({\n          check: \"ui-seam\",\n          path: ROUTER_PATH,\n          severity: \"warn\",\n          message:\n            \"pre-ADR-0023 monolithic router factory — drops the composed manifest tree (opts.routeTree); apply migrates it to the createCoreRouter authored seam\",\n        }),\n      );\n    }\n    if (routerSeam === \"unknown\") {\n      findings.push(\n        new Finding({\n          check: \"ui-seam\",\n          path: ROUTER_PATH,\n          severity: \"warn\",\n          message:\n            \"ui/src/router.tsx is neither the authored seam nor the known monolithic factory — inspect manually; apply will not touch it\",\n        }),\n      );\n    }\n\n    const appExists = yield* fileExists(projectDir, APP_PATH);\n    if (!appExists) {\n      findings.push(\n        new Finding({\n          check: \"ui-seam\",\n          path: APP_PATH,\n          severity: \"warn\",\n          message:\n            \"ui/src/app.ts not found — the @/app public surface is required by the generated stubs\",\n        }),\n      );\n      return findings;\n    }\n\n    const appSource = yield* readText(projectDir, APP_PATH);\n    const missing = [\"appLocale\", \"apiConnectionError\"].filter(\n      (name) => !hasExport(appSource, name),\n    );\n    if (missing.length > 0) {\n      findings.push(\n        new Finding({\n          check: \"ui-seam\",\n          path: APP_PATH,\n          severity: \"warn\",\n          message: `app surface is missing bootstrap overrides the generated stubs read: ${missing.join(\", \")}`,\n        }),\n      );\n    }\n\n    return findings;\n  });\n"],"mappings":";;;;;AAIA,MAAM,cAAc;AACpB,MAAM,WAAW;AAEjB,MAAM,mBAAmB;AACzB,MAAM,gBAAgB;AAEtB,MAAa,oBAAoB,WAA+B;CAC9D,IAAI,iBAAiB,KAAK,MAAM,GAAG,OAAO;CAC1C,IAAI,cAAc,KAAK,MAAM,GAAG,OAAO;CACvC,OAAO;AACT;AAEA,MAAa,kBAAkB,eAC7B,OAAO,IAAI,aAAa;CAEtB,IAAI,EAAC,OADiB,WAAW,YAAY,WAAW,IAC3C,OAAO;CACpB,OAAO,iBAAiB,OAAO,SAAS,YAAY,WAAW,CAAC;AAClE,CAAC;AAEH,MAAM,aAAa,QAAgB,SACjC,IAAI,OAAO,mCAAmC,KAAK,IAAI,CAAC,CAAC,KAAK,MAAM;AAEtE,MAAa,eAAe,eAC1B,OAAO,IAAI,aAAa;CACtB,MAAM,WAAsB,CAAC;CAE7B,MAAM,aAAa,OAAO,eAAe,UAAU;CACnD,IAAI,eAAe,UACjB,SAAS,KACP,IAAI,QAAQ;EACV,OAAO;EACP,MAAM;EACN,U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