docs + fix: eTerra health check keywords from real maintenance page

- Added real eTerra maintenance keywords observed 2026-03-08:
  'serviciu indisponibil', 'activități de mentenanță sunt în desfășurare'
- Extract actual maintenance message from HTML response for UI display
- Updated CLAUDE.md: ParcelSync module #15, Visual Copilot #16,
  eTerra/PostGIS integrations, TS strict gotchas, eTerra API rules
- Updated ROADMAP.md: Phase 7B (ParcelSync) with 5 completed tasks
- Updated SESSION-LOG.md: full session entry with bugs/learnings
This commit is contained in:
AI Assistant
2026-03-08 13:04:11 +02:00
parent b7a236c45a
commit a6fa94deec
4 changed files with 219 additions and 8 deletions
@@ -46,13 +46,22 @@ const MAINTENANCE_THRESHOLD = 2;
/**
* Keywords in eTerra HTML responses that indicate maintenance.
* Romanian maintenance pages often contain these.
* These are actual strings observed on the eTerra login page during downtime.
* Matched case-insensitively against the response body.
*/
const MAINTENANCE_KEYWORDS = [
"mentenan",
// Observed on eterra.ancpi.ro/#/login during real maintenance (2026-03-08)
"serviciu indisponibil",
"activități de mentenanță",
"activitati de mentenanta",
"mentenanță",
"mentenanta",
// Generic maintenance patterns
"maintenance",
"indisponibil",
"temporar",
"în desfășurare",
"in desfasurare",
"temporar indisponibil",
"lucrări",
"lucrari",
"întrerupere",
@@ -90,6 +99,37 @@ function getState(): HealthState {
return g.__eterraHealthState;
}
/* ------------------------------------------------------------------ */
/* Helpers */
/* ------------------------------------------------------------------ */
/**
* Try to extract a human-readable maintenance message from the HTML body.
* eTerra's login page shows messages like:
* "Serviciu indisponibil"
* "activități de mentenanță sunt în desfășurare"
*/
function extractMaintenanceMessage(body: string): string | null {
// Try common patterns in the eTerra maintenance page
// Pattern: text between tags that contains maintenance keywords
const patterns = [
/serviciu\s+indisponibil[^<]*/i,
/activit[aă][tț]i\s+de\s+mentenan[tț][aă]\s+[^<]*/i,
/mentenan[tț][aă]\s+[^<]{0,100}/i,
];
for (const pattern of patterns) {
const match = body.match(pattern);
if (match) {
// Capitalize first letter, trim, remove trailing HTML artifacts
const raw = match[0].replace(/<[^>]*>/g, "").trim();
if (raw.length > 5 && raw.length < 200) {
return raw.charAt(0).toUpperCase() + raw.slice(1);
}
}
}
return null;
}
/* ------------------------------------------------------------------ */
/* Core check */
/* ------------------------------------------------------------------ */
@@ -117,13 +157,15 @@ async function performHealthCheck(): Promise<EterraHealthStatus> {
typeof response.data === "string" ? response.data.toLowerCase() : "";
// Check if the page content indicates maintenance
const isMaintenance =
status === 503 || MAINTENANCE_KEYWORDS.some((kw) => body.includes(kw));
const matchedKeyword = MAINTENANCE_KEYWORDS.find((kw) => body.includes(kw));
const isMaintenance = status === 503 || !!matchedKeyword;
if (isMaintenance) {
// Try to extract the actual maintenance message from the page
const extractedMsg = extractMaintenanceMessage(body);
state.status = {
available: false,
message: "eTerra este în mentenanță programată",
message: extractedMsg || "eTerra este în mentenanță programată",
lastCheckedAt: new Date().toISOString(),
lastAvailableAt: state.status.lastAvailableAt,
consecutiveFailures: state.status.consecutiveFailures + 1,