Document Types
Document
Represents a single document in the Sonar system.
interface Document { id: string; // Unique document identifier name: string; // Document display name extension: string; // File extension (e.g., "pdf") size: string; // File size in bytes (as string) type: string; // MIME type (e.g., "application/pdf") status: boolean; // Active status uploadFrom: string; // Upload source identifier uploadDate: string; // ISO 8601 upload timestamp isSigned: boolean; // Whether the document has been signed isUsed: boolean; // Whether the document is in use fileHash?: string; // SHA hash of the file content signatureType?: SignatureType; // Type of signature applied lastSignedAt?: string; // ISO 8601 timestamp of last signature signature?: DocumentSignature; // Signature details parentDocumentId?: string | null; // Parent in signature chain originalDocumentId?: string | null; // Original document in chain signatureChainOrder?: number; // Position in signature chain isLatestVersion?: boolean; // Whether this is the latest version createdAt: string; // ISO 8601 creation timestamp updatedAt: string; // ISO 8601 last update timestamp}DocumentSignature
interface DocumentSignature { signedAt: string; // ISO 8601 timestamp when signed certificateId: string; // ID of the signing certificate signatureHash?: string; // Hash of the signature pageNumber?: number; // Page where signature appears isPadesCompliant?: boolean; // Whether signature is PAdES compliant}DocumentClassification
type DocumentClassification = 'generated' | 'uploaded' | 'signed';SignatureType
type SignatureType = 'SIMPLE' | 'ADVANCE' | 'AES';DocumentUploadSource
type DocumentUploadSource = | 'session-chat' | 'session-call' | 'user-documents' | 'session-recording' | 'queue-documents' | 'application-settings-appearance';ListDocumentsParams
interface ListDocumentsParams { page?: number; // min: 1, default: 1 limit?: number; // min: 1, max: 100, default: 20 classification?: DocumentClassification; isSigned?: boolean; type?: string; // MIME type filter uploadFrom?: DocumentUploadSource; sessionId?: string; // MongoDB ObjectId fromDate?: string | Date; // ISO 8601 toDate?: string | Date; // ISO 8601}ListDocumentsResponse
interface ListDocumentsResponse { docs: Document[]; totalDocs: number; limit: number; totalPages: number; page: number; pagingCounter: number; hasPrevPage: boolean; hasNextPage: boolean; prevPage: number | null; nextPage: number | null;}UploadDocumentParams
interface UploadDocumentParams { file: Buffer | Blob | NodeJS.ReadableStream; filename?: string; contentType?: string; name?: string; uploadFrom?: DocumentUploadSource; identity?: string; classification?: DocumentClassification;}DownloadResponse
interface DownloadResponse { data: ArrayBuffer; contentType: string; filename: string; size: number;}DownloadUrlParams
interface DownloadUrlParams { expiresIn?: number; // URL expiry in seconds (min: 60, max: 3600, default: 300)}DownloadUrlResponse
interface DownloadUrlResponse { documentId: string; name: string; url: string; expiresIn: number;}DeleteDocumentResponse
interface DeleteDocumentResponse { documentId: string;}BatchDeleteParams
interface BatchDeleteParams { documentIds: string[]; // max: 500}BatchDeleteResponse
interface BatchDeleteResponse { deleted: number; failed: number; total: number;}ExportDocumentsParams
interface ExportDocumentsParams { documentIds: string[]; // min: 1, max: 500}SignatureChain
interface SignatureChain { originalDocumentId: string; chainLength: number; documents: SignatureChainDocument[];}SignatureChainDocument
interface SignatureChainDocument { id: string; name: string; isSigned: boolean; signatureType?: SignatureType; signature?: { signedAt: string; certificateId: string; isPadesCompliant?: boolean; }; signatureChainOrder: number; isLatestVersion: boolean; parentDocumentId?: string | null; originalDocumentId?: string | null; createdAt: string;}ScopeAction
type ScopeAction = 'read' | 'upload' | 'update' | 'export' | 'delete';