/** * Nitro plugin that mounts collaborative editing routes. * * Templates opt in with one line: * ```ts * // server/plugins/collab.ts * import { createCollabPlugin } from "@agent-native/core/server"; * export default createCollabPlugin({ * table: "documents", * contentColumn: "content", * access: { mode: "resource", resourceType: "document" }, * }); * ``` */ type NitroPluginDef = (nitroApp: any) => void | Promise; export type CollabResourceIdResolver = (docId: string) => string | null | Promise; export type CollabAccess = { mode: "resource"; /** The shareable resource type registered via `registerShareableResource`. */ resourceType: string; /** Map a collab document id to its parent shareable resource id. */ resolveResourceId?: CollabResourceIdResolver; } | { /** Deliver collaboration events to every authenticated user. */ mode: "all-authenticated"; }; type NormalizedCollabAccess = { mode: "resource"; resourceType: string; resolveResourceId?: CollabResourceIdResolver; } | { mode: "all-authenticated"; explicit: boolean; }; export interface CollabPluginOptions { /** Table name containing document content. Default: "documents" */ table?: string; /** Column name for text content. Default: "content" */ contentColumn?: string; /** Column name for the document ID. Default: "id" */ idColumn?: string; /** Whether to auto-seed existing documents on startup. Default: true */ autoSeed?: boolean; /** * Callback invoked after a collab update to sync the content column. * If not provided, the plugin auto-syncs using table/contentColumn/idColumn. */ onContentSync?: (docId: string, text: string) => Promise; /** Content type: "text" for Y.Text (default) or "json" for Y.Map/Y.Array. */ contentType?: "text" | "json"; /** Column name for JSON content (used when contentType is "json"). */ jsonColumn?: string; /** * Access policy for collaboration routes and event delivery. * Use `resource` for registered shareable resources, or explicitly choose * `all-authenticated` for deployment-wide collaboration. */ access?: CollabAccess; /** * The shareable resource type registered via `registerShareableResource`. * Used to enforce access checks on collab routes. * @deprecated Use `access: { mode: "resource", resourceType }`. */ resourceType?: string; /** * Map the collab document id to the shareable resource id. Many templates * use route-specific collab ids (for example, one doc per slide inside a * deck) while sharing is enforced at the parent resource level. * @deprecated Use `access: { mode: "resource", resourceType, resolveResourceId }`. */ resolveResourceId?: CollabResourceIdResolver; /** * Maximum allowed body size in bytes for write operations * (update/text/json/patch). Requests exceeding this are rejected with 413. * Default: 2097152 (2 MB). */ maxPayloadBytes?: number; } export declare function normalizeCollabAccess(options: Pick): NormalizedCollabAccess; export declare function createCollabPlugin(options?: CollabPluginOptions): NitroPluginDef; export {}; //# sourceMappingURL=collab-plugin.d.ts.map