weavebot-core
Version:
Generic content processing framework for web scraping and AI extraction
46 lines (43 loc) • 1.33 kB
TypeScript
import { z } from 'zod';
/**
* Generic Schema Registry for dynamic schema management
* This registry allows applications to register their own schemas
*/
declare class SchemaRegistry {
private schemas;
private fieldMappings;
/**
* Register a schema with optional field mapping
*/
register<T>(name: string, schema: z.ZodType<T>, fieldMapping?: Record<string, string>): void;
/**
* Validate data against a registered schema
*/
validate<T>(schemaName: string, data: unknown): T;
/**
* Get a registered schema
*/
getSchema(name: string): z.ZodType | undefined;
/**
* Get field mapping for a schema
*/
getFieldMapping(name: string): Record<string, string> | undefined;
/**
* List all registered schema names
*/
listSchemas(): string[];
/**
* Check if a schema is registered
*/
hasSchema(name: string): boolean;
/**
* Clear all registered schemas
*/
clear(): void;
}
declare const defaultSchemaRegistry: SchemaRegistry;
/**
* Helper to create a schema registry with initial schemas
*/
declare function createSchemaRegistry(schemas?: Record<string, z.ZodType>, mappings?: Record<string, Record<string, string>>): SchemaRegistry;
export { SchemaRegistry, createSchemaRegistry, defaultSchemaRegistry };