@aidalinfo/pdf-processor
Version:
Powerful PDF data extraction library powered by AI vision models. Transform PDFs into structured, validated data using TypeScript, Zod, and AI providers like Scaleway and Ollama.
1,228 lines (1,227 loc) • 119 kB
TypeScript
/**
* PDF Vision Library - Interface publique pour utilisation directe
*/
import { z } from 'zod';
import { type ComprehensiveInvoice, type TablesOnly, type BasicReceipt } from "../core/schemas";
import type { VisionExtractionOptions, PdfProcessorConfig, ProviderConfig } from "../core/types";
/**
* Options d'extraction pour l'API publique
*/
export interface ExtractOptions extends Omit<VisionExtractionOptions, 'provider'> {
/** Provider d'IA à utiliser */
provider?: 'scaleway' | 'ollama' | 'mistral';
/** Modèle spécifique (optionnel) */
model?: string;
/** Schema JSON personnalisé ou type de document */
query?: string;
/** Taille de recadrage en pourcentage (10-90) */
cropSize?: number;
/** Extraction focalisée sur les tableaux uniquement */
tablesOnly?: boolean;
/** Type de document pour utiliser un schéma prédéfini */
documentType?: 'invoice' | 'receipt' | 'basic' | 'custom';
/** Amélioration du contraste (défaut: true) */
enhanceContrast?: boolean;
/** Qualité de compression JPEG (70-100, défaut: 95) */
targetQuality?: number;
/** DPI pour la conversion PDF vers images (défaut: 300) */
dpi?: number;
/** Nombre de tentatives en cas d'échec (défaut: 2) */
maxRetries?: number;
/** Schéma Zod personnalisé pour validation stricte */
customSchema?: z.ZodSchema;
/** Configuration personnalisée des providers */
pdfProcessor?: PdfProcessorConfig;
}
/**
* Résultat d'extraction avec métadonnées
*/
export interface ExtractResult<T = any> {
/** Données extraites et validées */
data: T;
/** Métadonnées du traitement */
metadata: {
/** Nombre de pages traitées */
pageCount: number;
/** Temps de traitement total en ms */
processingTime: number;
/** Provider utilisé */
provider: string;
/** Modèle utilisé */
model: string;
/** Nom du schéma utilisé */
schemaUsed: string;
/** Métriques d'optimisation des images */
optimizationMetrics: {
originalSizeMB: number;
optimizedSizeMB: number;
compressionRatio: number;
};
};
/** Résultat de la validation */
validation: {
success: boolean;
errors?: z.ZodError;
};
}
/**
* Extrait des données d'un PDF avec schéma personnalisé
*/
export declare function extractPdf<T extends z.ZodSchema>(filePath: string, schema: T, options?: ExtractOptions): Promise<z.infer<T>>;
/**
* Extrait des données d'un PDF avec résultat détaillé
*/
export declare function extractPdfWithMetadata<T extends z.ZodSchema>(filePath: string, schema: T, options?: ExtractOptions): Promise<ExtractResult<z.infer<T>>>;
/**
* Extrait une facture avec le schéma complet
*/
export declare function extractInvoicePdf(filePath: string, options?: ExtractOptions): Promise<ComprehensiveInvoice>;
/**
* Extrait les tableaux d'un PDF
*/
export declare function extractTablesPdf(filePath: string, options?: ExtractOptions): Promise<TablesOnly>;
/**
* Extrait un reçu avec le schéma simplifié
*/
export declare function extractReceiptPdf(filePath: string, options?: ExtractOptions): Promise<BasicReceipt>;
/**
* Schémas Zod prédéfinis pour validation
*/
export declare const schemas: {
invoice: z.ZodObject<{
document_info: z.ZodOptional<z.ZodObject<{
document_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
total_pages: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
document_type?: string;
language?: string;
currency?: string;
total_pages?: number;
}, {
document_type?: string;
language?: string;
currency?: string;
total_pages?: number;
}>>;
invoice_details: z.ZodOptional<z.ZodObject<{
invoice_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
invoice_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
due_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
purchase_order: z.ZodOptional<z.ZodNullable<z.ZodString>>;
reference_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
invoice_number?: string;
invoice_date?: string;
due_date?: string;
purchase_order?: string;
reference_number?: string;
}, {
invoice_number?: string;
invoice_date?: string;
due_date?: string;
purchase_order?: string;
reference_number?: string;
}>>;
seller_info: z.ZodOptional<z.ZodObject<{
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
company_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
address: z.ZodOptional<z.ZodNullable<z.ZodObject<{
street: z.ZodOptional<z.ZodNullable<z.ZodString>>;
city: z.ZodOptional<z.ZodNullable<z.ZodString>>;
postal_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
country: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
street?: string;
city?: string;
postal_code?: string;
country?: string;
}, {
street?: string;
city?: string;
postal_code?: string;
country?: string;
}>>>;
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
email: z.ZodOptional<z.ZodUnion<[z.ZodNullable<z.ZodString>, z.ZodLiteral<any>]>>;
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
vat_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
tax_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
name?: string;
company_name?: string;
address?: {
street?: string;
city?: string;
postal_code?: string;
country?: string;
};
phone?: string;
email?: any;
website?: string;
vat_number?: string;
tax_id?: string;
}, {
name?: string;
company_name?: string;
address?: {
street?: string;
city?: string;
postal_code?: string;
country?: string;
};
phone?: string;
email?: any;
website?: string;
vat_number?: string;
tax_id?: string;
}>>;
buyer_info: z.ZodOptional<z.ZodObject<{
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
company_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
address: z.ZodOptional<z.ZodNullable<z.ZodObject<{
street: z.ZodOptional<z.ZodNullable<z.ZodString>>;
city: z.ZodOptional<z.ZodNullable<z.ZodString>>;
postal_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
country: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
street?: string;
city?: string;
postal_code?: string;
country?: string;
}, {
street?: string;
city?: string;
postal_code?: string;
country?: string;
}>>>;
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
email: z.ZodOptional<z.ZodUnion<[z.ZodNullable<z.ZodString>, z.ZodLiteral<any>]>>;
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
vat_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
tax_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
name?: string;
company_name?: string;
address?: {
street?: string;
city?: string;
postal_code?: string;
country?: string;
};
phone?: string;
email?: any;
website?: string;
vat_number?: string;
tax_id?: string;
}, {
name?: string;
company_name?: string;
address?: {
street?: string;
city?: string;
postal_code?: string;
country?: string;
};
phone?: string;
email?: any;
website?: string;
vat_number?: string;
tax_id?: string;
}>>;
line_items: z.ZodOptional<z.ZodArray<z.ZodObject<{
item_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
quantity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
unit: z.ZodOptional<z.ZodNullable<z.ZodString>>;
unit_price: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
discount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
tax_rate: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
tax_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
line_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
quantite: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
prix_unitaire: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
taux_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}, {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>, "many">>;
financial_totals: z.ZodOptional<z.ZodObject<{
subtotal: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
discount_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
tax_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
shipping_cost: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
amount_paid: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
balance_due: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
}, {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
}>>;
payment_info: z.ZodOptional<z.ZodObject<{
payment_terms: z.ZodOptional<z.ZodNullable<z.ZodString>>;
payment_method: z.ZodOptional<z.ZodNullable<z.ZodString>>;
payment_due_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
bank_details: z.ZodOptional<z.ZodNullable<z.ZodString>>;
iban: z.ZodOptional<z.ZodNullable<z.ZodString>>;
swift_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
payment_terms?: string;
payment_method?: string;
payment_due_date?: string;
bank_details?: string;
iban?: string;
swift_code?: string;
}, {
payment_terms?: string;
payment_method?: string;
payment_due_date?: string;
bank_details?: string;
iban?: string;
swift_code?: string;
}>>;
pages: z.ZodOptional<z.ZodArray<z.ZodObject<{
page: z.ZodNumber;
page_tables: z.ZodArray<z.ZodObject<{
billed_services: z.ZodOptional<z.ZodArray<z.ZodObject<{
item_number: z.ZodOptional<z.ZodNullable<z.ZodString>>;
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
quantity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
unit: z.ZodOptional<z.ZodNullable<z.ZodString>>;
unit_price: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
discount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
tax_rate: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
tax_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
line_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
quantite: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
prix_unitaire: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
taux_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}, {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>, "many">>;
totals: z.ZodOptional<z.ZodObject<{
subtotal: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
discount_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
tax_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
shipping_cost: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
amount_paid: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
balance_due: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
}, {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
}>>;
sections_detaillees: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
items: z.ZodRecord<z.ZodString, z.ZodObject<{
quantite: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
prix_unitaire: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
taux_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>>;
sous_total: z.ZodOptional<z.ZodObject<{
subtotal: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
discount_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
tax_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
shipping_cost: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
amount_paid: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
balance_due: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
}, {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
}>>;
}, "strip", z.ZodTypeAny, {
items?: Record<string, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>;
sous_total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
}, {
items?: Record<string, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>;
sous_total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
}>>>;
total: z.ZodOptional<z.ZodObject<{
subtotal: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
discount_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
tax_total: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
shipping_cost: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_amount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
amount_paid: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
balance_due: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
total_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ht: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_tva: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
montant_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
}, {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
}>>;
reference: z.ZodOptional<z.ZodString>;
exercice: z.ZodOptional<z.ZodNullable<z.ZodString>>;
montant_ttc: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
raw_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
}, "strip", z.ZodTypeAny, {
currency?: string;
montant_ttc?: number;
billed_services?: {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}[];
totals?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
sections_detaillees?: Record<string, {
items?: Record<string, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>;
sous_total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
}>;
total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
reference?: string;
exercice?: string;
raw_data?: Record<string, any>;
}, {
currency?: string;
montant_ttc?: number;
billed_services?: {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}[];
totals?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
sections_detaillees?: Record<string, {
items?: Record<string, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>;
sous_total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
}>;
total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
reference?: string;
exercice?: string;
raw_data?: Record<string, any>;
}>, "many">;
}, "strip", z.ZodTypeAny, {
page?: number;
page_tables?: {
currency?: string;
montant_ttc?: number;
billed_services?: {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}[];
totals?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
sections_detaillees?: Record<string, {
items?: Record<string, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>;
sous_total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
}>;
total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
reference?: string;
exercice?: string;
raw_data?: Record<string, any>;
}[];
}, {
page?: number;
page_tables?: {
currency?: string;
montant_ttc?: number;
billed_services?: {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}[];
totals?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
sections_detaillees?: Record<string, {
items?: Record<string, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>;
sous_total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
}>;
total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
reference?: string;
exercice?: string;
raw_data?: Record<string, any>;
}[];
}>, "many">>;
extraction_metadata: z.ZodOptional<z.ZodObject<{
confidence_score: z.ZodNullable<z.ZodNumber>;
fields_found: z.ZodNullable<z.ZodNumber>;
fields_empty: z.ZodNullable<z.ZodNumber>;
processing_notes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
confidence_score?: number;
fields_found?: number;
fields_empty?: number;
processing_notes?: string[];
}, {
confidence_score?: number;
fields_found?: number;
fields_empty?: number;
processing_notes?: string[];
}>>;
}, "strip", z.ZodTypeAny, {
document_info?: {
document_type?: string;
language?: string;
currency?: string;
total_pages?: number;
};
invoice_details?: {
invoice_number?: string;
invoice_date?: string;
due_date?: string;
purchase_order?: string;
reference_number?: string;
};
seller_info?: {
name?: string;
company_name?: string;
address?: {
street?: string;
city?: string;
postal_code?: string;
country?: string;
};
phone?: string;
email?: any;
website?: string;
vat_number?: string;
tax_id?: string;
};
buyer_info?: {
name?: string;
company_name?: string;
address?: {
street?: string;
city?: string;
postal_code?: string;
country?: string;
};
phone?: string;
email?: any;
website?: string;
vat_number?: string;
tax_id?: string;
};
line_items?: {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}[];
financial_totals?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
payment_info?: {
payment_terms?: string;
payment_method?: string;
payment_due_date?: string;
bank_details?: string;
iban?: string;
swift_code?: string;
};
pages?: {
page?: number;
page_tables?: {
currency?: string;
montant_ttc?: number;
billed_services?: {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}[];
totals?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
sections_detaillees?: Record<string, {
items?: Record<string, {
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}>;
sous_total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
}>;
total?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;
balance_due?: number;
total_ht?: number;
total_tva?: number;
total_ttc?: number;
};
reference?: string;
exercice?: string;
raw_data?: Record<string, any>;
}[];
}[];
extraction_metadata?: {
confidence_score?: number;
fields_found?: number;
fields_empty?: number;
processing_notes?: string[];
};
}, {
document_info?: {
document_type?: string;
language?: string;
currency?: string;
total_pages?: number;
};
invoice_details?: {
invoice_number?: string;
invoice_date?: string;
due_date?: string;
purchase_order?: string;
reference_number?: string;
};
seller_info?: {
name?: string;
company_name?: string;
address?: {
street?: string;
city?: string;
postal_code?: string;
country?: string;
};
phone?: string;
email?: any;
website?: string;
vat_number?: string;
tax_id?: string;
};
buyer_info?: {
name?: string;
company_name?: string;
address?: {
street?: string;
city?: string;
postal_code?: string;
country?: string;
};
phone?: string;
email?: any;
website?: string;
vat_number?: string;
tax_id?: string;
};
line_items?: {
currency?: string;
item_number?: string;
description?: string;
quantity?: number;
unit?: string;
unit_price?: number;
discount?: number;
tax_rate?: number;
tax_amount?: number;
line_total?: number;
quantite?: number;
prix_unitaire?: number;
montant_ht?: number;
montant_ttc?: number;
taux_tva?: number;
montant_tva?: number;
}[];
financial_totals?: {
currency?: string;
montant_ht?: number;
montant_ttc?: number;
montant_tva?: number;
subtotal?: number;
discount_total?: number;
tax_total?: number;
shipping_cost?: number;
total_amount?: number;
amount_paid?: number;