import { Buffer } from 'node:buffer'; import { XmlDocument } from 'libxml2-wasm'; import { CrossIndustryInvoiceType, AccountingAccountTypeCodeType, AdvancePaymentType, AllowanceChargeReasonCodeType, AmountType, BinaryObjectType, CodeType, ContactTypeCodeType, CountryIDType, CreditorFinancialAccountType, CreditorFinancialInstitutionType, CurrencyCodeType, DateTimeType, DateType, DebtorFinancialAccountType, DebtorFinancialInstitutionType, DeliveryTermsCodeType, DocumentCodeType, DocumentContextParameterType, DocumentLineDocumentType, ExchangedDocumentContextType, ExchangedDocumentType, FinancialAdjustmentType, FormattedDateTimeType, HeaderTradeAgreementType, HeaderTradeDeliveryType, HeaderTradeSettlementType, IDType, IndicatorType, LegalOrganizationType, LineStatusCodeType, LineTradeAgreementType, LineTradeDeliveryType, LineTradeSettlementType, LogisticsServiceChargeType, LogisticsTransportMovementType, MeasureType, NoteType, NumericType, PartyRoleCodeType, PaymentMeansCodeType, PercentType, ProcuringProjectType, ProductCharacteristicType, ProductClassificationType, QuantityType, RateType, ReferenceCodeType, ReferencedDocumentType, ReferencedProductType, SpecifiedPeriodType, SupplyChainConsignmentType, SupplyChainEventType, SupplyChainTradeLineItemType, SupplyChainTradeTransactionType, TaxCategoryCodeType, TaxRegistrationType, TaxTypeCodeType, TextType, TimeReferenceCodeType, TradeAccountingAccountType, TradeAddressType, TradeAllowanceChargeType, TradeContactType, TradeCountryType, TradeCurrencyExchangeType, TradeDeliveryTermsType, TradeLocationType, TradePartyType, TradePaymentDiscountTermsType, TradePaymentPenaltyTermsType, TradePaymentTermsType, TradePriceType, TradeProductInstanceType, TradeProductType, TradeSettlementFinancialCardType, TradeSettlementHeaderMonetarySummationType, TradeSettlementLineMonetarySummationType, TradeSettlementPaymentMeansType, TradeTaxType, TransportModeCodeType, UniversalCommunicationType } from './models.mjs'; import { PDFDocument } from 'pdf-lib'; /** * Schematron (business-rule) validation for Factur-X 1.09. * * The official spec ships ISO-Schematron compiled to XSLT 2.0 (one per profile) * that emits SVRL and validates code lists via `document(...codedb.xml)`. We * vendor those transforms precompiled to a relocatable Saxon SEF (gzipped) plus * the matching codedb, and run them with SaxonJS. XSD validation (see check.ts) * only checks structure; Schematron enforces EN16931 BR-* rules and code lists. */ interface SchematronError { /** Human readable assertion message, e.g. "[BR-16]-An Invoice shall have ...". */ message: string; /** Business rule id parsed from the message, e.g. "BR-16" (when present). */ id?: string; /** The failing XPath test expression. */ test?: string; /** Location of the offending node. */ location?: string; /** Severity flag from the rule (e.g. "fatal", "warning"). */ flag?: string; } /** * Run Schematron business-rule validation against a Factur-X XML document. * Only the `facturx` flavor is supported (the spec ships no Order-X Schematron here). */ declare function validateSchematron(options: { xml: string | Buffer; flavor?: string; level: string; }): Promise<{ valid: boolean; errors: SchematronError[]; }>; declare function check(options: { xml: string | Buffer | XmlDocument; flavor?: string; level?: string; /** * Also run Schematron (business-rule) validation in addition to the XSD check. * Only available for the `facturx` flavor. Defaults to `false`. */ schematron?: boolean; }): Promise<{ valid: boolean; errors: any[]; flavor: string; level: string; schematronValid?: boolean; schematronErrors?: SchematronError[]; }>; /** * Converter for FacturX CrossIndustryInvoice model to XML. * * Element emission follows the xs:sequence order of the Factur-X 1.09 (CII D22B) * EXTENDED schema, which is a superset of all lower profiles. Only fields that * are present on the model are emitted, so the same converter produces valid * output for MINIMUM through EXTENDED. */ declare function invoiceToXml(invoice: CrossIndustryInvoiceType): Promise; interface ExtractResult { filename: string; xml: string; flavor?: string; level?: string; } declare function extract(options: { pdf: string | Buffer | PDFDocument; check?: boolean; level?: string; flavor?: string; }): Promise; interface PdfMetadata { author: string; title: string; subject: string; keywords: string[]; date: Date; } declare function generate(options: { pdf: string | Buffer | PDFDocument; xml: string | Buffer | XmlDocument; check?: boolean; flavor?: string; level?: string; language?: string; meta?: PdfMetadata; }): Promise; /** * Factur-X model index file */ declare const index_AccountingAccountTypeCodeType: typeof AccountingAccountTypeCodeType; declare const index_AdvancePaymentType: typeof AdvancePaymentType; declare const index_AllowanceChargeReasonCodeType: typeof AllowanceChargeReasonCodeType; declare const index_AmountType: typeof AmountType; declare const index_BinaryObjectType: typeof BinaryObjectType; declare const index_CodeType: typeof CodeType; declare const index_ContactTypeCodeType: typeof ContactTypeCodeType; declare const index_CountryIDType: typeof CountryIDType; declare const index_CreditorFinancialAccountType: typeof CreditorFinancialAccountType; declare const index_CreditorFinancialInstitutionType: typeof CreditorFinancialInstitutionType; declare const index_CrossIndustryInvoiceType: typeof CrossIndustryInvoiceType; declare const index_CurrencyCodeType: typeof CurrencyCodeType; declare const index_DateTimeType: typeof DateTimeType; declare const index_DateType: typeof DateType; declare const index_DebtorFinancialAccountType: typeof DebtorFinancialAccountType; declare const index_DebtorFinancialInstitutionType: typeof DebtorFinancialInstitutionType; declare const index_DeliveryTermsCodeType: typeof DeliveryTermsCodeType; declare const index_DocumentCodeType: typeof DocumentCodeType; declare const index_DocumentContextParameterType: typeof DocumentContextParameterType; declare const index_DocumentLineDocumentType: typeof DocumentLineDocumentType; declare const index_ExchangedDocumentContextType: typeof ExchangedDocumentContextType; declare const index_ExchangedDocumentType: typeof ExchangedDocumentType; declare const index_FinancialAdjustmentType: typeof FinancialAdjustmentType; declare const index_FormattedDateTimeType: typeof FormattedDateTimeType; declare const index_HeaderTradeAgreementType: typeof HeaderTradeAgreementType; declare const index_HeaderTradeDeliveryType: typeof HeaderTradeDeliveryType; declare const index_HeaderTradeSettlementType: typeof HeaderTradeSettlementType; declare const index_IDType: typeof IDType; declare const index_IndicatorType: typeof IndicatorType; declare const index_LegalOrganizationType: typeof LegalOrganizationType; declare const index_LineStatusCodeType: typeof LineStatusCodeType; declare const index_LineTradeAgreementType: typeof LineTradeAgreementType; declare const index_LineTradeDeliveryType: typeof LineTradeDeliveryType; declare const index_LineTradeSettlementType: typeof LineTradeSettlementType; declare const index_LogisticsServiceChargeType: typeof LogisticsServiceChargeType; declare const index_LogisticsTransportMovementType: typeof LogisticsTransportMovementType; declare const index_MeasureType: typeof MeasureType; declare const index_NoteType: typeof NoteType; declare const index_NumericType: typeof NumericType; declare const index_PartyRoleCodeType: typeof PartyRoleCodeType; declare const index_PaymentMeansCodeType: typeof PaymentMeansCodeType; declare const index_PercentType: typeof PercentType; declare const index_ProcuringProjectType: typeof ProcuringProjectType; declare const index_ProductCharacteristicType: typeof ProductCharacteristicType; declare const index_ProductClassificationType: typeof ProductClassificationType; declare const index_QuantityType: typeof QuantityType; declare const index_RateType: typeof RateType; declare const index_ReferenceCodeType: typeof ReferenceCodeType; declare const index_ReferencedDocumentType: typeof ReferencedDocumentType; declare const index_ReferencedProductType: typeof ReferencedProductType; declare const index_SpecifiedPeriodType: typeof SpecifiedPeriodType; declare const index_SupplyChainConsignmentType: typeof SupplyChainConsignmentType; declare const index_SupplyChainEventType: typeof SupplyChainEventType; declare const index_SupplyChainTradeLineItemType: typeof SupplyChainTradeLineItemType; declare const index_SupplyChainTradeTransactionType: typeof SupplyChainTradeTransactionType; declare const index_TaxCategoryCodeType: typeof TaxCategoryCodeType; declare const index_TaxRegistrationType: typeof TaxRegistrationType; declare const index_TaxTypeCodeType: typeof TaxTypeCodeType; declare const index_TextType: typeof TextType; declare const index_TimeReferenceCodeType: typeof TimeReferenceCodeType; declare const index_TradeAccountingAccountType: typeof TradeAccountingAccountType; declare const index_TradeAddressType: typeof TradeAddressType; declare const index_TradeAllowanceChargeType: typeof TradeAllowanceChargeType; declare const index_TradeContactType: typeof TradeContactType; declare const index_TradeCountryType: typeof TradeCountryType; declare const index_TradeCurrencyExchangeType: typeof TradeCurrencyExchangeType; declare const index_TradeDeliveryTermsType: typeof TradeDeliveryTermsType; declare const index_TradeLocationType: typeof TradeLocationType; declare const index_TradePartyType: typeof TradePartyType; declare const index_TradePaymentDiscountTermsType: typeof TradePaymentDiscountTermsType; declare const index_TradePaymentPenaltyTermsType: typeof TradePaymentPenaltyTermsType; declare const index_TradePaymentTermsType: typeof TradePaymentTermsType; declare const index_TradePriceType: typeof TradePriceType; declare const index_TradeProductInstanceType: typeof TradeProductInstanceType; declare const index_TradeProductType: typeof TradeProductType; declare const index_TradeSettlementFinancialCardType: typeof TradeSettlementFinancialCardType; declare const index_TradeSettlementHeaderMonetarySummationType: typeof TradeSettlementHeaderMonetarySummationType; declare const index_TradeSettlementLineMonetarySummationType: typeof TradeSettlementLineMonetarySummationType; declare const index_TradeSettlementPaymentMeansType: typeof TradeSettlementPaymentMeansType; declare const index_TradeTaxType: typeof TradeTaxType; declare const index_TransportModeCodeType: typeof TransportModeCodeType; declare const index_UniversalCommunicationType: typeof UniversalCommunicationType; declare namespace index { export { index_AccountingAccountTypeCodeType as AccountingAccountTypeCodeType, index_AdvancePaymentType as AdvancePaymentType, index_AllowanceChargeReasonCodeType as AllowanceChargeReasonCodeType, index_AmountType as AmountType, index_BinaryObjectType as BinaryObjectType, index_CodeType as CodeType, index_ContactTypeCodeType as ContactTypeCodeType, index_CountryIDType as CountryIDType, index_CreditorFinancialAccountType as CreditorFinancialAccountType, index_CreditorFinancialInstitutionType as CreditorFinancialInstitutionType, index_CrossIndustryInvoiceType as CrossIndustryInvoiceType, index_CurrencyCodeType as CurrencyCodeType, index_DateTimeType as DateTimeType, index_DateType as DateType, index_DebtorFinancialAccountType as DebtorFinancialAccountType, index_DebtorFinancialInstitutionType as DebtorFinancialInstitutionType, index_DeliveryTermsCodeType as DeliveryTermsCodeType, index_DocumentCodeType as DocumentCodeType, index_DocumentContextParameterType as DocumentContextParameterType, index_DocumentLineDocumentType as DocumentLineDocumentType, index_ExchangedDocumentContextType as ExchangedDocumentContextType, index_ExchangedDocumentType as ExchangedDocumentType, index_FinancialAdjustmentType as FinancialAdjustmentType, index_FormattedDateTimeType as FormattedDateTimeType, index_HeaderTradeAgreementType as HeaderTradeAgreementType, index_HeaderTradeDeliveryType as HeaderTradeDeliveryType, index_HeaderTradeSettlementType as HeaderTradeSettlementType, index_IDType as IDType, index_IndicatorType as IndicatorType, index_LegalOrganizationType as LegalOrganizationType, index_LineStatusCodeType as LineStatusCodeType, index_LineTradeAgreementType as LineTradeAgreementType, index_LineTradeDeliveryType as LineTradeDeliveryType, index_LineTradeSettlementType as LineTradeSettlementType, index_LogisticsServiceChargeType as LogisticsServiceChargeType, index_LogisticsTransportMovementType as LogisticsTransportMovementType, index_MeasureType as MeasureType, index_NoteType as NoteType, index_NumericType as NumericType, index_PartyRoleCodeType as PartyRoleCodeType, index_PaymentMeansCodeType as PaymentMeansCodeType, index_PercentType as PercentType, index_ProcuringProjectType as ProcuringProjectType, index_ProductCharacteristicType as ProductCharacteristicType, index_ProductClassificationType as ProductClassificationType, index_QuantityType as QuantityType, index_RateType as RateType, index_ReferenceCodeType as ReferenceCodeType, index_ReferencedDocumentType as ReferencedDocumentType, index_ReferencedProductType as ReferencedProductType, index_SpecifiedPeriodType as SpecifiedPeriodType, index_SupplyChainConsignmentType as SupplyChainConsignmentType, index_SupplyChainEventType as SupplyChainEventType, index_SupplyChainTradeLineItemType as SupplyChainTradeLineItemType, index_SupplyChainTradeTransactionType as SupplyChainTradeTransactionType, index_TaxCategoryCodeType as TaxCategoryCodeType, index_TaxRegistrationType as TaxRegistrationType, index_TaxTypeCodeType as TaxTypeCodeType, index_TextType as TextType, index_TimeReferenceCodeType as TimeReferenceCodeType, index_TradeAccountingAccountType as TradeAccountingAccountType, index_TradeAddressType as TradeAddressType, index_TradeAllowanceChargeType as TradeAllowanceChargeType, index_TradeContactType as TradeContactType, index_TradeCountryType as TradeCountryType, index_TradeCurrencyExchangeType as TradeCurrencyExchangeType, index_TradeDeliveryTermsType as TradeDeliveryTermsType, index_TradeLocationType as TradeLocationType, index_TradePartyType as TradePartyType, index_TradePaymentDiscountTermsType as TradePaymentDiscountTermsType, index_TradePaymentPenaltyTermsType as TradePaymentPenaltyTermsType, index_TradePaymentTermsType as TradePaymentTermsType, index_TradePriceType as TradePriceType, index_TradeProductInstanceType as TradeProductInstanceType, index_TradeProductType as TradeProductType, index_TradeSettlementFinancialCardType as TradeSettlementFinancialCardType, index_TradeSettlementHeaderMonetarySummationType as TradeSettlementHeaderMonetarySummationType, index_TradeSettlementLineMonetarySummationType as TradeSettlementLineMonetarySummationType, index_TradeSettlementPaymentMeansType as TradeSettlementPaymentMeansType, index_TradeTaxType as TradeTaxType, index_TransportModeCodeType as TransportModeCodeType, index_UniversalCommunicationType as UniversalCommunicationType, }; } /** * Parse a Factur-X XML string into a CrossIndustryInvoiceType object. * Mirrors the converter: every aggregate emitted by invoiceToXml is read back here. */ declare function xmlToInvoice(xml: string | Buffer): Promise; export { index as Models, check, extract, generate, invoiceToXml, validateSchematron, xmlToInvoice };