fix(parcel-sync): robust workspace resolution with direct nomen lookup

- Add fetchNomenByPk() to EterraClient  single nomen entry lookup
- resolveWorkspace() now tries fast path first: direct nomen lookup for
  SIRUTA  walk parentNomenPk chain to find COUNTY (1-3 calls vs 42+)
- Falls back to full county scan only if direct lookup fails
- Search route: DB lookup as middle fallback between workspacePk and resolve
- Debug logging to trace workspace resolution on production
- Fix: try all possible UAT identifier fields (nomenPk, siruta, code, pk)
This commit is contained in:
AI Assistant
2026-03-06 21:09:22 +02:00
parent ec5a866673
commit 1b72d641cd
3 changed files with 118 additions and 38 deletions
@@ -560,6 +560,20 @@ export class EterraClient {
return this.getRawJson(url);
}
/**
* Fetch a single nomenclature entry by nomenPk.
* Returns { nomenPk, name, parentNomenPk, nomenType, ... } or null
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async fetchNomenByPk(nomenPk: string | number): Promise<any> {
const url = `${BASE_URL}/api/adm/nomen/${nomenPk}`;
try {
return await this.getRawJson(url);
} catch {
return null;
}
}
/**
* Fetch administrative units (UATs) under a county workspace.
* Returns array of { nomenPk, name, parentNomenPk, ... }