/** * Document Domain Types * Defines documents, versions, metadata, and permissions */ import type { Timestamp, UUID } from './common'; /** * Document type enum for type-specific handling */ export type DocumentType = 'document' | 'spreadsheet' | 'presentation' | 'whiteboard'; /** * Document core properties */ export interface Document { id: UUID; workspaceId: UUID; title: string; description?: string; type: DocumentType; content: DocumentContent; ownerId: UUID; createdAt: Timestamp; updatedAt: Timestamp; lastModifiedBy: UUID; archivedAt?: Timestamp; deletedAt?: Timestamp; status: 'active' | 'archived' | 'deleted' | 'draft'; visibility: 'private' | 'workspace' | 'public'; metadata: DocumentMetadata; version: number; lock?: DocumentLock; } /** * Document content - can be different types based on DocumentType */ export type DocumentContent = TextDocumentContent | SpreadsheetContent | PresentationContent | WhiteboardContent; /** * Text document content (rich text or markdown) */ export interface TextDocumentContent { type: 'document'; format: 'markdown' | 'rich-text' | 'html'; body: string; headings: DocumentHeading[]; wordCount: number; } /** * Heading for table of contents */ export interface DocumentHeading { id: string; level: 1 | 2 | 3 | 4 | 5 | 6; text: string; position: number; } /** * Spreadsheet content structure */ export interface SpreadsheetContent { type: 'spreadsheet'; sheets: Sheet[]; namedRanges?: NamedRange[]; } /** * Sheet within a spreadsheet */ export interface Sheet { id: UUID; name: string; rows: number; columns: number; cells: Record; freeze?: { rows: number; columns: number; }; filters?: SheetFilter[]; } /** * Cell in a spreadsheet */ export interface Cell { id: string; row: number; col: number; value: CellValue; formula?: string; format?: CellFormat; comment?: CellComment; locked: boolean; } /** * Cell value can be various types */ export type CellValue = string | number | boolean | Date | null; /** * Cell formatting options */ export interface CellFormat { bold: boolean; italic: boolean; underline: boolean; strikethrough: boolean; fontSize: number; fontFamily: string; backgroundColor: string; textColor: string; alignment: 'left' | 'center' | 'right'; numberFormat?: string; merged?: { rows: number; cols: number; }; } /** * Comment on a cell */ export interface CellComment { id: UUID; userId: UUID; text: string; createdAt: Timestamp; updatedAt: Timestamp; resolved: boolean; replies: CommentReply[]; } /** * Reply to a comment */ export interface CommentReply { id: UUID; userId: UUID; text: string; createdAt: Timestamp; updatedAt: Timestamp; } /** * Named range in spreadsheet */ export interface NamedRange { name: string; sheetId: UUID; startCell: { row: number; col: number; }; endCell: { row: number; col: number; }; } /** * Sheet filter definition */ export interface SheetFilter { id: UUID; name: string; criteria: FilterCriteria[]; } /** * Filter criteria for sheet */ export interface FilterCriteria { column: number; operator: 'equals' | 'contains' | 'gt' | 'lt' | 'gte' | 'lte' | 'between'; value: CellValue | [CellValue, CellValue]; } /** * Presentation content */ export interface PresentationContent { type: 'presentation'; slides: Slide[]; theme?: string; } /** * Slide in presentation */ export interface Slide { id: UUID; presentationId: UUID; order: number; layout: SlideLayout; elements: SlideElement[]; notes?: string; speaker?: string; duration?: number; } /** * Slide layout type */ export type SlideLayout = 'blank' | 'title' | 'title-and-content' | 'title-only' | 'two-column' | 'comparison' | 'custom'; /** * Slide element (shape, text, image, etc) */ export type SlideElement = TextElement | ImageElement | ShapeElement | VideoElement; /** * Text element on slide */ export interface TextElement { id: UUID; type: 'text'; text: string; position: { x: number; y: number; }; size: { width: number; height: number; }; format: TextFormat; zIndex: number; } /** * Image element on slide */ export interface ImageElement { id: UUID; type: 'image'; url: string; position: { x: number; y: number; }; size: { width: number; height: number; }; altText?: string; zIndex: number; } /** * Shape element on slide */ export interface ShapeElement { id: UUID; type: 'shape'; shape: 'rectangle' | 'circle' | 'triangle' | 'polygon' | 'line' | 'arrow'; position: { x: number; y: number; }; size: { width: number; height: number; }; fill: string; stroke: string; strokeWidth: number; zIndex: number; } /** * Video element on slide */ export interface VideoElement { id: UUID; type: 'video'; url: string; position: { x: number; y: number; }; size: { width: number; height: number; }; thumbnail?: string; zIndex: number; } /** * Text formatting on slide */ export interface TextFormat { fontSize: number; fontFamily: string; bold: boolean; italic: boolean; color: string; alignment: 'left' | 'center' | 'right'; } /** * Whiteboard content (canvas-based collaborative drawing) */ export interface WhiteboardContent { type: 'whiteboard'; elements: WhiteboardElement[]; backgroundColor: string; gridSize: number; } /** * Element on whiteboard */ export type WhiteboardElement = FreehandElement | ShapeElementWb | TextElementWb; /** * Freehand drawing on whiteboard */ export interface FreehandElement { id: UUID; type: 'freehand'; points: Array<{ x: number; y: number; }>; color: string; width: number; opacity: number; } /** * Shape on whiteboard */ export interface ShapeElementWb { id: UUID; type: 'shape'; shape: string; x: number; y: number; width: number; height: number; fill: string; stroke: string; } /** * Text on whiteboard */ export interface TextElementWb { id: UUID; type: 'text'; text: string; x: number; y: number; fontSize: number; color: string; } /** * Document metadata */ export interface DocumentMetadata { tags: string[]; labels: string[]; customFields: Record; starred: boolean; pinned: boolean; parentFolderId?: UUID; templateId?: UUID; } /** * Document version for history/undo */ export interface DocumentVersion { id: UUID; documentId: UUID; versionNumber: number; content: DocumentContent; createdBy: UUID; createdAt: Timestamp; summary?: string; changeLog?: Change[]; } /** * Change in document */ export interface Change { id: UUID; type: 'insert' | 'delete' | 'update' | 'format'; path: string; value?: unknown; oldValue?: unknown; timestamp: Timestamp; userId: UUID; } /** * Document permission */ export interface DocumentPermission { id: UUID; documentId: UUID; granteeId: UUID; granteeType: 'user' | 'team' | 'workspace'; role: DocumentRole; grantedAt: Timestamp; grantedBy: UUID; expiresAt?: Timestamp; } /** * Document-level role */ export type DocumentRole = 'owner' | 'editor' | 'commenter' | 'viewer'; /** * Document lock for preventing concurrent edits */ export interface DocumentLock { lockedBy: UUID; lockedAt: Timestamp; expiresAt: Timestamp; } /** * Sharing link for document */ export interface DocumentShareLink { id: UUID; documentId: UUID; token: string; role: 'viewer' | 'commenter' | 'editor'; expiresAt?: Timestamp; createdBy: UUID; createdAt: Timestamp; requirePassword?: boolean; passwordHash?: string; accessCount: number; lastAccessedAt?: Timestamp; } /** * Type guard to check if content is text document */ export declare function isTextDocument(content: DocumentContent): content is TextDocumentContent; /** * Type guard to check if content is spreadsheet */ export declare function isSpreadsheet(content: DocumentContent): content is SpreadsheetContent; /** * Type guard to check if content is presentation */ export declare function isPresentation(content: DocumentContent): content is PresentationContent; /** * Type guard to check if content is whiteboard */ export declare function isWhiteboard(content: DocumentContent): content is WhiteboardContent; /** * Can user edit document with given role */ export declare function canEditDocument(role: DocumentRole): boolean; //# sourceMappingURL=document.d.ts.map