UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

39 lines • 2.32 kB
import type { GmailAccessor } from '../../accessor/gmail.ts'; import { Delta, type PathSpec } from '../../types.ts'; import type { DeltaHook } from '../../events/base.ts'; import type { GmailLabel } from './labels.ts'; import { type GmailMessageRaw } from './messages.ts'; /** * The paths a message is under `labelIds`: its file in each label's day * directory, and its attachment directory beside it when it has attachments, * named as the listings name them. Mirrors Python's `message_paths`. */ export declare function messagePaths(prefix: string, raw: GmailMessageRaw, labels: ReadonlyMap<string, GmailLabel>, labelIds: readonly string[]): string[]; /** * Each label's folder name, by label id, as the root listing names it: a * system label by its id, any other by its name. Mirrors Python's * `label_folders`. */ export declare function labelFolders(labels: readonly GmailLabel[]): Map<string, string>; /** * Checkpointed delta over Gmail's history. The checkpoint holds the history id * the next pull starts after, each label's folder name and, by message id, the * paths of each message a pull has seen. History records no label created, * renamed or deleted, so each pull lists the labels and compares the folders: * one that appeared, left or moved is reported whatever its messages did. A record names a message by id only, so each one added or * relabeled is read to name its paths: one under each label it holds, in the * day it arrived. Its labels before the record follow from the label changes * the records carry, so a relabel moves exactly the paths it should, and a file * it keeps is updated, since its labels are part of its content. A message * deleted for good cannot be read any more: one a pull has seen leaves the * paths it was, and one it has not reports the event root as unknown, as a * history id Gmail no longer keeps does. Mirrors Python's GmailDeltaHook. */ export declare class GmailDeltaHook implements DeltaHook { private readonly accessor; constructor(accessor: GmailAccessor); pull(root: PathSpec, checkpoint: string | null): Promise<Delta>; } /** Build the Gmail delta hook (`GmailDeltaHook`). Mirrors Python's `build_delta_hook`. */ export declare function buildDeltaHook(accessor: GmailAccessor): DeltaHook; //# sourceMappingURL=events.d.ts.map