import { z } from "zod" import { HorizontalAlignment, VerticalAlignment, CssMediaType, FitToPaperModes, MeasurementUnit, UseMargins, ChromeGpuModes, ChangeTrackingModes, HtmlString, HtmlFilePath, ZipFilePath, PdfFilePath, UrlString, BarcodeType, PdfPageSelection, SaveOptions, Length, CropRectangle, MarginConfig, ImageFilePath, ImageBuffer, PdfPassword, PdfInput, TableOfContentsTypes } from "../../public/types" import {pdfDocumentSchema} from "./pdfDocumentSchema"; import {Buffer} from "buffer"; export const horizontalAlignmentSchema: z.ZodType = z.nativeEnum(HorizontalAlignment) export const verticalAlignmentSchema: z.ZodType = z.nativeEnum(VerticalAlignment) export const cssMediaTypeSchema: z.ZodType = z.nativeEnum(CssMediaType) export const fitToPaperModesSchema: z.ZodType = z.nativeEnum(FitToPaperModes) export const pdfPageSelectionSchema: z.ZodType = z.union([ z.number(), z.array(z.number()), z.literal("all"), z.undefined() ]) export const measurementUnitSchema: z.ZodType = z.nativeEnum(MeasurementUnit) export const saveOptionsSchema: z.ZodType = z.object({ userPassword: z.string().optional(), ownerPassword: z .string() .optional(), saveAsPdfA: z .boolean() .optional(), incremental: z .boolean() .optional() }) export const lengthSchema: z.ZodType = z.object({ value: z.number(), unit: measurementUnitSchema }) export const cropRectangleSchema: z.ZodType = z.object({ x: z.number().optional(), y: z.number().optional(), width: z.number().optional(), height: z.number().optional() }) export const marginConfigSchema: z.ZodType = z.object({ default: z.number().optional(), top: z.number().optional(), right: z.number().optional(), bottom: z.number().optional(), left: z.number().optional() }) export const filePathSchema: z.ZodType = z.string() export const pdfFilePathSchema: z.ZodType = z.string() export const zipFilePathSchema: z.ZodType = z.string() export const htmlStringSchema: z.ZodType = z.string() export const htmlFilePathSchema: z.ZodType = z.string() export const urlStringSchema: z.ZodType = z.string() export const stringSchema: z.ZodType = z.string() export const urlSchema: z.ZodType = z.instanceof(URL) export const imageFilePathSchema: z.ZodType = z.string() export const bufferSchema: z.ZodType = z.instanceof(Buffer) export const imageBufferSchema: z.ZodType = bufferSchema export const useMarginsSchema: z.ZodType = z.nativeEnum(UseMargins) export const pdfPasswordSchema: z.ZodType = z.object({ userPassword: z.string().optional(), ownerPassword: z.string().optional() }) export const chromeGpuModesSchema: z.ZodType = z.nativeEnum(ChromeGpuModes) export const changeTrackingModesSchema: z.ZodType = z.nativeEnum(ChangeTrackingModes) export const pdfInputSchema: z.ZodType = z.union([pdfDocumentSchema,bufferSchema,htmlStringSchema,htmlFilePathSchema,zipFilePathSchema,pdfFilePathSchema,urlSchema,urlStringSchema]) export const dateSchema: z.ZodType = z.instanceof(Date) export const barcodeTypeSchema: z.ZodType = z.nativeEnum(BarcodeType) export const tableOfContentsTypesSchema: z.ZodType = z.nativeEnum(TableOfContentsTypes) export const stringArraySchema: z.ZodType = z.array(z.string()) export const bufferArraySchema: z.ZodType = z.array(bufferSchema) export const numberSchema: z.ZodType = z.number() export const booleanSchema: z.ZodType = z.boolean() export const mapStringSchema: z.ZodType> = z.map(z.string(),z.string())