@fin.cx/einvoice
Version:
A TypeScript module for creating, manipulating, and embedding XML data within PDF files specifically tailored for electronic invoice (einvoice) packages.
122 lines (121 loc) • 3.37 kB
TypeScript
/**
* Base error class for all EInvoice-related errors
*/
export declare class EInvoiceError extends Error {
code: string;
details?: any;
cause?: Error;
constructor(message: string, code: string, details?: any, cause?: Error);
/**
* Returns a detailed error message including cause if available
*/
getDetailedMessage(): string;
}
/**
* Error thrown when XML parsing fails
*/
export declare class EInvoiceParsingError extends EInvoiceError {
line?: number;
column?: number;
xmlSnippet?: string;
constructor(message: string, details?: {
line?: number;
column?: number;
xmlSnippet?: string;
format?: string;
}, cause?: Error);
/**
* Returns a user-friendly error message with location information
*/
getLocationMessage(): string;
}
/**
* Error thrown when validation fails
*/
export declare class EInvoiceValidationError extends EInvoiceError {
validationErrors: Array<{
code: string;
message: string;
location?: string;
severity?: 'error' | 'warning';
}>;
constructor(message: string, validationErrors: Array<{
code: string;
message: string;
location?: string;
severity?: 'error' | 'warning';
}>, details?: any);
/**
* Returns a formatted validation report
*/
getValidationReport(): string;
/**
* Gets validation errors by severity
*/
getErrorsBySeverity(severity: 'error' | 'warning'): typeof this.validationErrors;
}
/**
* Error thrown during PDF operations
*/
export declare class EInvoicePDFError extends EInvoiceError {
operation: 'extract' | 'embed' | 'create' | 'validate';
pdfInfo?: {
filename?: string;
size?: number;
pageCount?: number;
};
constructor(message: string, operation: 'extract' | 'embed' | 'create' | 'validate', details?: any, cause?: Error);
/**
* Returns recovery suggestions based on the operation
*/
getRecoverySuggestions(): string[];
}
/**
* Error thrown for format-specific issues
*/
export declare class EInvoiceFormatError extends EInvoiceError {
sourceFormat?: string;
targetFormat?: string;
unsupportedFeatures?: string[];
constructor(message: string, details: {
sourceFormat?: string;
targetFormat?: string;
unsupportedFeatures?: string[];
conversionPath?: string;
}, cause?: Error);
/**
* Returns a compatibility report
*/
getCompatibilityReport(): string;
}
/**
* Error recovery helper class
*/
export declare class ErrorRecovery {
/**
* Attempts to recover from a parsing error by cleaning the XML
*/
static attemptXMLRecovery(xmlString: string, error: EInvoiceParsingError): Promise<{
success: boolean;
cleanedXml?: string;
message: string;
}>;
/**
* Provides partial data extraction on validation failure
*/
static extractPartialData(xmlString: string, format: string): {
success: boolean;
partialData?: any;
message: string;
};
}
/**
* Error context builder for detailed error information
*/
export declare class ErrorContext {
private context;
add(key: string, value: any): this;
addTimestamp(): this;
addEnvironment(): this;
build(): Record<string, any>;
}