/** * Shared types for the worker. */ export interface Env { /** KV: key = Figma file_key, value = Discord channel webhook URL. */ FIGMA_DISCORD_WEBHOOK: KVNamespace; /** Durable Object namespace for the Batcher class. */ BATCHER: DurableObjectNamespace; /** Shared secret that Figma echoes back in every webhook payload. */ FIGMA_PASSCODE: string; } /** A single published item from a Figma library (component, style, or variable). */ export interface LibraryItem { key: string; name: string; } /** Buckets of items pending flush for one file. */ export interface BatchItems { components: Record; styles: Record; variables: Record; } /** Persistent state held by a Batcher Durable Object for a single file. */ export interface BatchState { fileKey: string; fileName: string; /** Optional publish description from the designer. */ fileDescription: string; /** Timestamp of the first event in the current batch (ms since epoch). */ firstSeenAt: number; items: BatchItems; /** The Discord webhook URL to flush to, captured from KV on first ingest. */ discordWebhookUrl: string; /** Number of flush attempts made so far (bounded to prevent loops). */ flushAttempts: number; }