MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / databaseCsvPathFor

Function databaseCsvPathFor

packages/shared-domain/src/databases.ts:300–312  ·  view source on GitHub ↗
(relPath: string)

Source from the content-addressed store, hash-verified

298 * Used to normalize a watcher event on any database file back to its identity.
299 */
300export 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}

Callers 3

databases.test.tsFile · 0.90
handlerMethod · 0.90
migrateLooseAssetsFunction · 0.90

Calls 6

toPosixPathFunction · 0.85
formDirFromCsvPathFunction · 0.85
isDatabaseSidecarPathFunction · 0.85
formDirContainingFunction · 0.85
isDatabaseCsvPathFunction · 0.85
isFormDirNameFunction · 0.70

Tested by

no test coverage detected