dnsz
Version:
Generic DNS zone file parser and stringifier
44 lines • 2.14 kB
TypeScript
//#region index.d.ts
type DnszDnsRecord = {
/**The lowercase DNS name without a trailing dot, e.g. `"example.com"`. */name: string; /** The TTL in seconds, e.g. `60`. */
ttl: number; /** The DNS class, e.g. `"IN"`. */
class: string; /** The record type, e.g. `"A"`. */
type: string; /** The record content, e.g. `"2001:db8::1"` or `"example.com."`. */
content: string; /** A comment, e.g. `"a comment"`, `null` if absent. */
comment: string | null;
};
type DnszDnsData = {
/** Array of `record` */records: Array<DnszDnsRecord>; /** The value of `$ORIGIN` in the zone file. */
origin?: string; /** The value of `$TTL` in the zone file. */
ttl?: number; /** An optional header at the start of the file. Can be multiline. Does not include comment markers. */
header?: string;
};
type DnszParseOptions = {
/** When specified, replaces any `@` in `name` or `content` with it. */replaceOrigin?: string | null; /** When true, emit `\r\n` instead of `\n` in `header`. */
crlf?: boolean; /** Default class when absent. */
defaultClass?: string; /** Default TTL when absent and `$TTL` is not present. */
defaultTTL?: number; /** Ensure trailing dots on FQDNs in content. Supports a limited amount of record types. */
dots?: boolean;
};
type DnszStringifyOptions = {
/** Whether to group records into sections. */sections?: boolean; /** When `true`, emit `\r\n` instead of `\n` for the resulting zone file. */
crlf?: boolean; /** Ensure trailing dots on FQDNs in content. Supports a limited amount of record types. Default: `false`. */
dots?: boolean;
};
/** Parse a string of a DNS zone file and returns a `data` object. */
declare function parseZone(str: string, {
replaceOrigin,
crlf,
defaultTTL,
defaultClass,
dots
}?: DnszParseOptions): DnszDnsData;
/** Parse a `data` object and return a string with the zone file contents. */
declare function stringifyZone(data: DnszDnsData, {
crlf,
sections,
dots
}?: DnszStringifyOptions): string;
//#endregion
export { DnszDnsData, DnszDnsRecord, DnszParseOptions, DnszStringifyOptions, parseZone, stringifyZone };
//# sourceMappingURL=index.d.ts.map