@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
45 lines • 2.36 kB
TypeScript
import type { NotionAccessor } from '../../accessor/notion.ts';
import { type FileEvent, type JsonValue, type PathSpec } from '../../types.ts';
/**
* Map one Notion webhook event onto mount paths.
*
* The consumer owns the subscription's endpoint and passes the event's `type`
* with its body. Nothing here runs a loop. An event names its entity by id
* only, so each place is read from Notion: a page by its parent chain up to
* the workspace or a data source, a data source through its database. Each
* place is remembered, so a later event on the same page or one below it costs
* nothing, and a move, rename or delete forgets what was below the old place.
*
* A page is a directory holding `page.json`, below `pages` when it is a
* workspace page, below another page, or below a data source as a row. A page
* inside some other block is not listed, so it maps to nothing, as does one
* the integration cannot read up to the top. `page.json` renders the page's
* properties and blocks, so a content or property change updates it, and a
* row's line in its data source's `rows.jsonl` carries the same properties
* and edit time.
*
* A page made or restored creates its `page.json`, and one deleted deletes its
* directory. A page's directory carries its title, so a move or a retitle
* moves everything below it, which the event does not list: the old place,
* when the hook saw it, and the new one are UNKNOWN. A move of one it never
* saw has an old place nothing names, so the whole mount is UNKNOWN, and a
* retitle of a page it never saw is UNKNOWN on the page's parent. Databases and data sources
* follow the same rules with `database.json` and `data_source.json`; a data
* source's rows changing updates `rows.jsonl`, and a database lists its data
* sources, so a data source made, moved, retitled or deleted also updates
* `database.json`. Comments are rendered nowhere.
*
* Mirrors Python `NotionEventHook` (`core/notion/events.py`).
*/
export declare class NotionEventHook {
private readonly accessor;
private readonly places;
constructor(accessor: NotionAccessor);
private read;
private place;
private pageParent;
private forget;
private companions;
toEvents(root: PathSpec, eventType: string, payload: JsonValue): Promise<readonly FileEvent[]>;
}
//# sourceMappingURL=events.d.ts.map