UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

33 lines • 1.7 kB
import type { MongoDBAccessor } from '../../accessor/mongodb.ts'; import { type FileEvent, type JsonValue, type PathSpec } from '../../types.ts'; /** * Map one MongoDB change stream event onto mount paths. * * The consumer owns the stream (`watch()` on the client or one database, with * `showExpandedEvents` so collection and index changes come through) and its * resume token, and passes each event's `operationType` with the event. * Nothing here runs a loop. * * A collection is one `documents.jsonl` and one `schema.json`, so an event * says exactly which files moved: a document written or removed rewrites its * collection's documents.jsonl and the schema.json sampled from it, and both * files of every view in that database (a view reads other collections); an * index or validator change rewrites its schema.json, and a view's new * pipeline (its `modify` names `viewOn`) both of the view's files; a * collection created, dropped or renamed is its directory appearing or * leaving, and its database's database.json, which lists it. A dropped * database leaves, and an invalidated stream leaves the whole mount UNKNOWN. * The views of a database are listed once and listed again after any event * that changes what the database holds. * * Mirrors Python `MongoDBEventHook` (`core/mongodb/events.py`). */ export declare class MongoDBEventHook { private readonly accessor; private readonly views; constructor(accessor: MongoDBAccessor); /** The views `db` holds, listed once until it changes. */ private viewsOf; toEvents(root: PathSpec, operationType: string, payload: JsonValue): Promise<readonly FileEvent[]>; } //# sourceMappingURL=events.d.ts.map