UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

31 lines • 1.19 kB
import { enoent } from "../../errors/fs.js"; import { NotionAPIError } from "./client.js"; import { pageSegmentName } from "./normalize.js"; import { getPage } from "./pages.js"; /** Fetch and validate the row named by a path, including descendants. */ export async function resolveRow(accessor, match, virtual) { let page; try { page = await getPage(accessor.transport, match.slots.row_id ?? ''); } catch (err) { if (err instanceof NotionAPIError && (err.status === 404 || err.code === 'validation_error')) { throw enoent(virtual); } throw err; } const parent = page.parent; const name = `${match.slots.row ?? ''}__${match.slots.row_id ?? ''}`; if (parent?.data_source_id !== match.slots.data_source_id || page.in_trash === true || page.archived === true || pageSegmentName(page) !== name) throw enoent(virtual); return page; } /** Validate a containing row when this path has one. */ export async function guardRow(accessor, match, virtual) { if (match.slots.row_id !== undefined) await resolveRow(accessor, match, virtual); } //# sourceMappingURL=resolve.js.map