@nodecfdi/cfdi-core
Version:
Librería que contiene las herramientas base para trabajar con CFDI's
102 lines (92 loc) • 4.68 kB
TypeScript
import { DOMParser, XMLSerializer, DOMImplementation, Node, Element, Attr, Text, Document, CDATASection } from '@xmldom/xmldom';
export { Attr, CDATASection, DOMImplementation, DOMParser, Document, Element, MIME_TYPE, NAMESPACE, Node, Text, XMLSerializer, onErrorStopParsing } from '@xmldom/xmldom';
import { X as XmlNodeInterface, a as XmlNodes, b as XmlAttributes } from './types-Cc7ykLcP.js';
declare const getParser: () => DOMParser;
declare const getSerializer: () => XMLSerializer;
declare const getDomImplementation: () => DOMImplementation;
declare const isNode: (nodo: unknown) => nodo is Node & {
nodeType: number;
};
declare const isElement: (nodo: unknown) => nodo is Element;
declare const isAttribute: (nodo: unknown) => nodo is Attr;
declare const isText: (nodo: unknown) => nodo is Text;
declare const isDocument: (nodo: unknown) => nodo is Document;
declare const isCDataSection: (nodo: unknown) => nodo is CDATASection;
declare const toFloat: (value: string) => number;
declare const roundNumber: (num: number, precision: number) => number;
declare const formatNumber: (num: number, precision: number) => string;
declare const documentElement: (document: Document) => Element;
declare const ownerDocument: (node: Node) => Document;
declare const newDocument: (document?: Document) => Document;
declare const newDocumentContent: (content: string) => Document;
declare const isValidXmlName: (name: string) => boolean;
declare const createDomElement: (makeElement: () => Element, errorMessage: string, content: string) => Element;
declare const createElement: (document: Document, name: string, content?: string) => Element;
declare class XmlNode implements XmlNodeInterface {
private readonly _name;
private readonly _attributes;
private readonly _children;
private _value;
private _cdata;
constructor(name: string, attributes?: Record<string, unknown>, children?: XmlNodeInterface[], value?: string, cdata?: string);
get length(): number;
name(): string;
children(): XmlNodes;
addChild(node: XmlNodeInterface): XmlNodeInterface;
attributes(): XmlAttributes;
hasAttribute(name: string): boolean;
setAttribute(name: string, value?: string | null): void;
getAttribute(name: string): string;
addAttributes(attributes: Record<string, unknown>): void;
clear(): void;
searchAttribute(...searchPath: string[]): string;
searchNodes(...searchPath: string[]): XmlNodes;
searchNode(...searchPath: string[]): XmlNodeInterface | undefined;
value(): string;
setValue(value: string): void;
cdata(): string;
setCData(cdata: string): void;
[Symbol.iterator](): IterableIterator<XmlNodeInterface>;
}
declare class XmlNodeExporter {
private readonly node;
constructor(node: XmlNodeInterface);
export(): Element;
private exportRecursive;
}
declare class XmlNodeImporter {
private readonly element;
/**
* Local record for registered namespaces to avoid set the namespace declaration in every child
*/
private registeredNamespaces;
constructor(element: Element);
import(): XmlNodeInterface;
private importRecursive;
private registerNamespace;
private extractValue;
private extractCData;
}
declare const nodeToXmlElement: (node: XmlNodeInterface) => Element;
declare const nodeToXmlString: (node: XmlNodeInterface, withXmlHeader?: boolean) => string;
declare const nodeFromXmlElement: (element: Element) => XmlNodeInterface;
declare const nodeFromXmlString: (content: string) => XmlNodeInterface;
declare class XmlNodesSorter {
/** Record of key (string) value (number|int) representing the naming order. */
private _order;
private _length;
constructor(order?: string[]);
setOrder(names: string[]): boolean;
parseNames(names: unknown[]): string[];
getOrder(): string[];
sort(nodes: XmlNodeInterface[]): XmlNodeInterface[];
compareNodesByName(a: XmlNodeInterface, b: XmlNodeInterface): number;
valueByName(name: string): number;
private isValidName;
/**
* This function is a replacement for sort that try to sort
* but if items are equal then uses the relative position as second argument.
*/
private stableArraySort;
}
export { XmlAttributes, XmlNode, XmlNodeExporter, XmlNodeImporter, XmlNodes, XmlNodesSorter, createDomElement, createElement, documentElement, formatNumber, getDomImplementation, getParser, getSerializer, isAttribute, isCDataSection, isDocument, isElement, isNode, isText, isValidXmlName, newDocument, newDocumentContent, nodeFromXmlElement, nodeFromXmlString, nodeToXmlElement, nodeToXmlString, ownerDocument, roundNumber, toFloat };