import { ZodSchema } from 'zod'; import { HybridDocumentCode } from './codelist/hybrid-document.cjs'; import { FilenameCode } from './codelist/filename.cjs'; import { HybridVersionCode } from './codelist/hybrid-version.cjs'; import { HybridConformanceCode } from './codelist/hybrid-conformance.cjs'; import * as pdf_lib from 'pdf-lib'; import { PDFDocument, AFRelationship, AttachmentOptions } from 'pdf-lib'; import * as fast_xml_parser from 'fast-xml-parser'; type LiteralString = "" | (string & Record); type PickRequired = Omit & Required>; type UnionToIntersection$1 = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; type PDFAMetadata = { author?: string; creator?: string; producer?: string; createDate?: Date; modifyDate?: Date; language?: string; subject?: string; title?: string; keywords?: string[]; facturX: { documentType: HybridDocumentCode; documentFileName: FilenameCode; version: HybridVersionCode; conformanceLevel: HybridConformanceCode; }; }; type ParseSchemaOptions = { groupIndices?: GroupIndices; }; type GroupIndices = Record; declare const levels: readonly ["info", "success", "warn", "error", "debug"]; type LogLevel = (typeof levels)[number]; type Logger = { disabled?: boolean; level?: Exclude; log?: (level: Exclude, message: string, ...args: any[]) => void; }; type LogHandlerParams = Parameters> extends [ LogLevel, ...infer Rest ] ? Rest : never; declare const createLogger: (options?: Logger) => Record void>; type ZugferdPlugin = (ctx: ZugferdContext) => { [key: string]: unknown; }; type ZugferdOptions = { profile: ProfileContext; strict?: boolean; plugins?: ZugferdPlugin[]; logger?: Logger; }; declare const createDocumentFactory: (ctx: BaseZugferdContext, options: O) => (data: InferSchema) => { toObj: () => any; toXML: () => Promise; embedInPdf: (pdf: PDFDocument | string | Uint8Array | ArrayBuffer, opts?: { metadata?: Omit; additionalFiles?: Array<{ content: string | ArrayBuffer | Uint8Array; filename: string; relationship?: keyof typeof AFRelationship; } & Omit>; }) => Promise>; }; declare const validateDocumentFactory: (ctx: BaseZugferdContext) => ProfileValidateHandler; type BaseZugferdContext = { options: ZugferdOptions; logger: ReturnType; } & InternalTools; type ZugferdContext = BaseZugferdContext & { document: { create: ReturnType>; validate: ReturnType; }; }; type InternalTools = ReturnType; type InternalContext = { options: ZugferdOptions; logger: ReturnType; }; declare const getInternalTools: (ctx: InternalContext) => { parseSchema: (data: InferRawSchema, def: Schema, options: ParseSchemaOptions, parentGroupIndices?: { [x: string]: number; } | undefined, fullData?: any) => any; mergeSchemas: (profile: Profile) => Schema; xml: { format: (doc: any, options?: Omit | undefined) => string; }; pdf: { addMetadata: (pdfDoc: pdf_lib.PDFDocument, metadata: Omit & Required> & { now: Date; }) => pdf_lib.PDFDocument; addTrailerInfoId: (pdfDoc: pdf_lib.PDFDocument, trailerInfoId: string) => pdf_lib.PDFDocument; fixLinkAnnotations: (pdfDoc: pdf_lib.PDFDocument) => pdf_lib.PDFDocument; addStructTreeRoot: (pdfDoc: pdf_lib.PDFDocument) => pdf_lib.PDFDocument; addMarkInfo: (pdfDoc: pdf_lib.PDFDocument) => pdf_lib.PDFDocument; addICC: (pdfDoc: pdf_lib.PDFDocument) => pdf_lib.PDFDocument; getAttachments: (pdfDoc: pdf_lib.PDFDocument) => { name: string; data: Uint8Array; }[]; }; }; type Profile = { id: LiteralString; extends?: Profile[]; schema: Schema; xsdPath?: string | (() => Promise | string); conformanceLevel: HybridConformanceCode; documentFileName: FilenameCode; mask?: Record; /** * @default "INVOICE" */ documentType?: HybridDocumentCode; version: HybridVersionCode; }; type ProfileParseHandlerContext

= { context: BaseZugferdContext; data: InferSchema

; }; type ProfileParseHandler

= (ctx: { context: BaseZugferdContext; data: InferSchema

; }) => any; type ProfileValidateHandler = (data: string | Buffer | { file: string; }) => Promise; type ProfileContext

= P & { parse: ProfileParseHandler

; validate: ProfileValidateHandler; }; type FieldType = "string" | "string[]" | "number" | "number[]" | "date" | "boolean" | "object" | "object[]" | "string | number" | "(string | number)[]" | Array; type Primitive = string | boolean | number | Date | null | undefined | object; type SchemaFieldConfig = { key?: string; defaultValue?: Primitive | (() => Primitive); validator?: ZodSchema; xpath?: string; group?: LiteralString; description?: string; required?: boolean; sibling?: T extends "object[]" ? (data: any, groupIndicies: { [key: string]: number; }) => any : never; shape?: T extends "object" | "object[]" ? Schema : never; additionalXml?: { [key: string]: { type: FieldType; key?: string; xpath?: string; defaultValue?: Primitive | (() => Primitive); }; }; transform?: { input?: (val: any) => any; output?: (val: any) => any; }; }; type SchemaField = { type: T; } & SchemaFieldConfig; type Schema = { [key: string]: SchemaField; }; type InferValueType = T extends "string" ? string : T extends "number" ? number : T extends "string | number" ? string | number : T extends "boolean" ? boolean : T extends "date" ? Date | string : T extends "string[]" ? string[] : T extends "number[]" ? number[] : T extends "(string | number)[]" ? (string | number)[] : T extends Array ? T[number] : never; type UnionToIntersection = (U extends U ? (x: U) => void : never) extends (x: infer I) => void ? I : never; type InferSchema

= InferRawSchema & (P["extends"] extends Profile[] ? UnionToIntersection> : {}); type InferSchemaHelper = E extends Profile ? InferRawSchema & (E["extends"] extends Profile[] ? InferSchemaHelper : {}) : {}; type InferRawSchema = { [K in keyof S as S[K]["required"] extends false ? K : never]?: S[K]["type"] extends "object" ? S[K]["shape"] extends Schema ? InferRawSchema : {} : S[K]["type"] extends "object[]" ? S[K]["shape"] extends Schema ? Array> : [] : InferValueType; } & { [K in keyof S as S[K]["required"] extends false ? never : K]: S[K]["type"] extends "object" ? S[K]["shape"] extends Schema ? InferRawSchema : {} : S[K]["type"] extends "object[]" ? S[K]["shape"] extends Schema ? Array> : [] : InferValueType; }; export { type BaseZugferdContext as B, type FieldType as F, type InferSchema as I, type LiteralString as L, type Profile as P, type SchemaFieldConfig as S, type UnionToIntersection$1 as U, type ZugferdOptions as Z, type ZugferdContext as a, type ProfileValidateHandler as b, createDocumentFactory as c, type ZugferdPlugin as d, type SchemaField as e, type Schema as f, type InferValueType as g, type InferRawSchema as h, type ProfileParseHandlerContext as i, type ProfileParseHandler as j, type ProfileContext as k, type PickRequired as l };