import { Static } from '@sinclair/typebox'; import { ComponentDefinitionSchema } from './schemas/components.js'; import { ValueError } from '@sinclair/typebox/value'; import { ValidationResult as ValidationResult$1, ValidationError as ValidationError$1 } from '@json-to-office/shared'; /** * Unified validation types - extends @json-to-office/shared types */ /** * Re-export the shared ValidationError type. * Docx validation code uses this everywhere. */ type ValidationError = ValidationError$1; /** * Generic validation result that can be used for any validation scenario */ interface ValidationResult extends ValidationResult$1 { success?: boolean; data?: T; errors?: ValidationError[]; } /** * Options for validation behavior */ interface ValidationOptions { /** Apply Value.Clean to remove unknown properties */ clean?: boolean; /** Apply Value.Default to add default values */ applyDefaults?: boolean; /** Include detailed error reports */ includeReport?: boolean; /** Calculate line/column for JSON errors */ calculatePosition?: boolean; /** Original JSON string for position calculation */ jsonString?: string; /** Maximum number of errors to collect */ maxErrors?: number; /** * When true, unknown/extra properties are stripped before validation instead * of being rejected by additionalProperties:false. Escape hatch for callers * migrating onto strict schemas. */ allowUnknownFields?: boolean; /** * Names of registered plugin components. They are not flagged as unknown and * their props are not checked against a standard schema here — the plugin * layer validates custom props version-aware separately. */ knownCustomNames?: Set; } /** * Result specifically for JSON parsing with validation */ interface JsonValidationResult extends ValidationResult { parsed?: unknown; isJsonError?: boolean; } /** * Theme-specific validation result */ interface ThemeValidationResult extends ValidationResult { themeName?: string; } /** * Document-specific validation result */ interface DocumentValidationResult extends ValidationResult { documentType?: string; hasCustomComponents?: boolean; errors: ValidationError[]; warnings?: ValidationError[]; } /** * Component-specific validation result */ interface ComponentValidationResult extends ValidationResult { componentName?: string; isCustomComponent?: boolean; success?: boolean; } /** * TypeBox error with additional context */ interface EnhancedValueError extends ValueError { suggestion?: string; severity?: 'error' | 'warning' | 'info'; } /** * Document validation implementation * Single source of truth for all document validation */ /** * Validate a document/report component definition */ declare function validateDocument(data: unknown, options?: ValidationOptions): DocumentValidationResult; /** * Validate a JSON document (string or object) */ declare function validateJsonDocument(jsonInput: string | object, options?: ValidationOptions): DocumentValidationResult; /** * Type guard for document validation result */ declare function isValidDocument(result: DocumentValidationResult): result is DocumentValidationResult & { valid: true; data: Static; }; /** * Create a document validator with default options */ declare function createDocumentValidator(defaultOptions?: ValidationOptions): { validate: (data: unknown, options?: ValidationOptions) => DocumentValidationResult; validateJson: (jsonInput: string | object, options?: ValidationOptions) => DocumentValidationResult; }; declare const documentValidator: { validate: (data: unknown, options?: ValidationOptions) => DocumentValidationResult; validateJson: (jsonInput: string | object, options?: ValidationOptions) => DocumentValidationResult; }; declare const strictDocumentValidator: { validate: (data: unknown, options?: ValidationOptions) => DocumentValidationResult; validateJson: (jsonInput: string | object, options?: ValidationOptions) => DocumentValidationResult; }; /** * Legacy compatibility exports */ declare const validateJsonComponent: typeof validateJsonDocument; declare const validateDocumentWithSchema: typeof validateDocument; export { type ComponentValidationResult as C, type DocumentValidationResult as D, type EnhancedValueError as E, type JsonValidationResult as J, type ThemeValidationResult as T, type ValidationOptions as V, validateDocumentWithSchema as a, validateJsonDocument as b, createDocumentValidator as c, documentValidator as d, validateJsonComponent as e, type ValidationResult as f, isValidDocument as i, strictDocumentValidator as s, validateDocument as v };