import Document from './Document' import Template from './Template' export type RootAttributes = { seed?: string locale?: string debug?: string refDate?: string } export interface RootConstructor { $: RootAttributes Document: Document Template?: Template | Template[] } export default class Root { public $: RootAttributes public seed?: number public locale?: string public debug?: boolean public refDate?: string public Document: Document public Template?: Template | Template[] constructor(opts: RootConstructor) { this.$ = opts.$ this.seed = opts?.$?.seed !== undefined ? +(opts.$.seed) : undefined this.locale = opts?.$?.locale ?? undefined this.debug = opts?.$?.debug === 'true' this.refDate = opts?.$?.refDate ?? undefined // eslint-disable-next-line @typescript-eslint/no-explicit-any this.Document = new Document(opts.Document as any) this.Template = Array.isArray(opts.Template) ? opts.Template.map(tmpl => new Template(tmpl)) : opts.Template && new Template(opts.Template) } public toString(): string { return this.Document.toString() } }