- refactor(documents): implement stable SHA256-based document IDs - feat(library): add support for external document libraries - refactor(audiobook): consolidate server logic and migrate to V1 storage layout - feat(audiobook): add reset functionality and improve chapter management - fix(ui): enhance audiobook export modal with download/regenerate controls - test: add coverage for upload hashing and export reset flow
72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
export type DocumentType = 'pdf' | 'epub' | 'docx' | 'html';
|
|
|
|
export interface BaseDocument {
|
|
id: string;
|
|
name: string;
|
|
size: number;
|
|
lastModified: number;
|
|
type: DocumentType;
|
|
folderId?: string;
|
|
isConverting?: boolean;
|
|
}
|
|
|
|
export interface PDFDocument extends BaseDocument {
|
|
type: 'pdf';
|
|
data: ArrayBuffer;
|
|
}
|
|
|
|
export interface HTMLDocument extends BaseDocument {
|
|
type: 'html';
|
|
data: string; // Store as string since it's text content
|
|
}
|
|
|
|
export interface EPUBDocument extends BaseDocument {
|
|
type: 'epub';
|
|
data: ArrayBuffer;
|
|
}
|
|
|
|
export interface DOCXDocument extends BaseDocument {
|
|
type: 'docx';
|
|
data: ArrayBuffer;
|
|
}
|
|
|
|
export type AnyDocument =
|
|
| PDFDocument
|
|
| EPUBDocument
|
|
| HTMLDocument
|
|
| DOCXDocument;
|
|
|
|
export type BinaryDocument = PDFDocument | EPUBDocument | DOCXDocument;
|
|
|
|
// Representation used when syncing binary documents to/from the server.
|
|
// Data is converted from ArrayBuffer to a numeric array for JSON transport.
|
|
export interface SyncedDocument extends BaseDocument {
|
|
data: number[];
|
|
}
|
|
|
|
export interface DocumentListDocument extends BaseDocument {
|
|
type: DocumentType;
|
|
}
|
|
|
|
export interface Folder {
|
|
id: string;
|
|
name: string;
|
|
documents: DocumentListDocument[];
|
|
}
|
|
|
|
export type SortBy = 'name' | 'type' | 'date' | 'size';
|
|
export type SortDirection = 'asc' | 'desc';
|
|
|
|
export interface DocumentListState {
|
|
sortBy: SortBy;
|
|
sortDirection: SortDirection;
|
|
folders: Folder[];
|
|
collapsedFolders: string[];
|
|
showHint: boolean;
|
|
viewMode?: 'list' | 'grid';
|
|
}
|
|
|
|
export interface LibraryDocument extends BaseDocument {
|
|
// `id` is a stable server-provided reference, not necessarily the same as the local document id.
|
|
id: string;
|
|
}
|