(relPath: string)
| 298 | * Used to normalize a watcher event on any database file back to its identity. |
| 299 | */ |
| 300 | export function databaseCsvPathFor(relPath: string): string | null { |
| 301 | const p = toPosixPath(relPath) |
| 302 | if (p.toLowerCase().endsWith(`/${FORM_SCHEMA_FILE}`)) { |
| 303 | const dir = p.slice(0, p.lastIndexOf('/')) |
| 304 | if (isFormDirName(dir)) return `${dir}/${FORM_DATA_FILE}` |
| 305 | } |
| 306 | if (formDirFromCsvPath(p)) return p |
| 307 | // Legacy: a `<Name>.csv.base.json` sidecar maps to its `.csv`. |
| 308 | if (isDatabaseSidecarPath(p)) return p.slice(0, -DATABASE_SIDECAR_SUFFIX.length) |
| 309 | // Legacy loose `.csv` (not inside a `.base` folder). |
| 310 | if (!formDirContaining(p) && isDatabaseCsvPath(p)) return p |
| 311 | return null |
| 312 | } |
no test coverage detected