UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

47 lines • 2.47 kB
import type { AirtableAccessor } from '../../accessor/airtable.ts'; import { Delta, type PathSpec } from '../../types.ts'; import type { DeltaHook } from '../../events/base.ts'; /** * What changed in the Airtable bases under an event root since the last * cursors, for the consumer to call when Airtable pings. * * An Airtable webhook's notification names the base, the webhook and a time, * never the change, so each ping is answered by reading, for every webhook on * each base the root covers, its `payloads` from the cursor the last pull * kept. The bases are those the root names, or the account's (`listBases`) * when the root is above them, as `readdir` lists them. A baseline takes each * webhook's `cursorForNextPayload` and each base's table names and reports * nothing. A webhook made after the last pull is read from its first payload, * and a base the last pull did not cover is UNKNOWN. * * A payload names tables by id, so the checkpoint keeps each table's * directory, named from the base schema the first time and kept current by * the renames the payloads carry. A record or field change updates the * table's `records.jsonl`, and a field or description change its * `table.json`; which saved views show a record is the view's own filter, so * a table's `views` is UNKNOWN when its records change. A table made, renamed * or destroyed also updates `base.json`, which lists the tables; a renamed * table moves everything below it, so its old and new directory are UNKNOWN. * * Airtable keeps payloads for seven days, and a cursor older than that reads * from the oldest left, which shows as a later cursor than the payloads read * account for. That, a webhook the last pull read that is gone, and a payload * marked `error` all mean changes were lost, so the event root is UNKNOWN and * the base's table names are read from its schema again. * * Mirrors Python `AirtableDeltaHook` (`core/airtable/events.py`). */ export declare class AirtableDeltaHook implements DeltaHook { private readonly accessor; constructor(accessor: AirtableAccessor); private bases; private tables; private present; private payloads; private map; private read; pull(root: PathSpec, checkpoint: string | null): Promise<Delta>; } /** Build the Airtable delta hook. Mirrors Python `build_delta_hook`. */ export declare function buildDeltaHook(accessor: AirtableAccessor): DeltaHook; //# sourceMappingURL=events.d.ts.map