/** * Maximum length of the descriptive free-text fields of an e-CF, taken from * the DGII XSD (e-CF 31 v1.0 `AlfNumType`; `RazonModificacion` from the * e-CF 33/34 XSD). * * The DGII rejects the whole document when one of these is too long * ("The actual length is greater than the MaxLength value") and still marks * its e-NCF as used, so the number is lost. Cutting the text is always better * than that: the full text of an item can travel in `DescripcionItem` (1000). * * Only names, addresses, contacts and descriptions are listed. Identifiers * (`CodigoItem`, `TipoCodigo`, `CodigoVendedor`, `CodigoInternoComprador`, * `NumeroFacturaInterna`, `NumeroOrdenCompra`, `Sucursal`, `Placa`, …) and * formatted fields (emails, URLs, dates, RNC, amounts) are deliberately NOT * listed: two codes that share a prefix would collide once cut, and a cut * formatted value is just a different invalid value. An over-long identifier * must be fixed at its source. */ export declare const ECF_FIELD_MAX_LENGTHS: Readonly>; /** A field that was cut to fit the DGII limit. */ export interface TruncatedEcfField { field: string; maxLength: number; original: string; truncated: string; } export interface LimitEcfFieldLengthsOptions { /** Called once per field that had to be cut, e.g. to log it. */ onFieldTruncated?: (info: TruncatedEcfField) => void; } /** * Trims `value` and cuts it to `maxLength` characters. Counts Unicode code * points, not UTF-16 units, so an emoji or other astral character is never * split in half. A cut never leaves a trailing space. */ export declare const truncateEcfText: (value: string, maxLength: number) => string; /** * Cuts, in place, every free-text field of a parsed e-CF that exceeds its DGII * limit (see {@link ECF_FIELD_MAX_LENGTHS}). Returns the fields it cut. */ export declare const limitEcfFieldLengthsInDocument: (doc: Document, options?: LimitEcfFieldLengthsOptions) => TruncatedEcfField[]; /** * Same as {@link limitEcfFieldLengthsInDocument} for the JSON payload given to * `Transformer.json2xml()` (compact xml-js form: a field is a string, a number, * or `{ _text: string }`). A number longer than its field's limit becomes the * cut string. Returns a new object; the input is not modified. */ export declare const limitEcfFieldLengths: (payload: T, options?: LimitEcfFieldLengthsOptions) => T;