Type Reference
Complete TypeScript type definitions exported by @sonar/sdk.
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';Scope Types
AllowedScopesResponse
interface AllowedScopesResponse { keyPrefix: string; name: string; scopes: string[];}ScopeCategory
interface ScopeCategory { id: string; label: string; types: ScopeType[];}ScopeType
interface ScopeType { id: string; label: string; scopes: ScopeEntry[];}ScopeEntry
interface ScopeEntry { value: string; label: string;}ScopeValue
type ScopeValue = (typeof Scope)[keyof typeof Scope];Error Types
APIErrorResponse
interface APIErrorResponse { success: false; code: string; message: string; errors?: Array<{ field: string; code: string; message: string; }>;}ErrorCode
type ErrorCode = | 'MISSING_API_KEY' | 'INVALID_API_KEY' | 'EXPIRED_API_KEY' | 'REVOKED_API_KEY' | 'INSUFFICIENT_SCOPE' | 'IP_NOT_ALLOWED' | 'RATE_LIMIT_EXCEEDED' | 'DOCUMENT_NOT_FOUND' | 'RESOURCE_NOT_FOUND' | 'INVALID_REQUEST' | 'INVALID_PARAMETER' | 'EXPORT_LIMIT_EXCEEDED' | 'EXPORT_SIZE_EXCEEDED' | 'EXPORT_NO_FILES' | 'INTERNAL_ERROR';Complete Exports
Everything exported from @sonar/sdk:
// Main Clientexport { SonarSDK } from './client';
// Configurationexport type { SonarSDKConfig } from './types/config';
// Document Typesexport type { Document, DocumentSignature, DocumentClassification, SignatureType, ListDocumentsParams, ListDocumentsResponse, ExportDocumentsParams, UploadDocumentParams, DocumentUploadSource, DownloadResponse, DownloadUrlParams, DownloadUrlResponse, DeleteDocumentResponse, BatchDeleteParams, BatchDeleteResponse, ScopeAction, SignatureChainDocument, SignatureChain,} from './types/documents';
// Scope Types & Constantsexport { Scope } from './types/scopes';export type { AllowedScopesResponse, ScopeValue, ScopeCategory, ScopeType, ScopeEntry,} from './types/scopes';
// Error Typesexport type { APIErrorResponse, ErrorCode } from './types/errors';
// Error Classesexport { SonarSDKError, AuthenticationError, RateLimitError, DocumentNotFoundError, ValidationError,} from './utils/errors';