UNPKG

rawsql-ts

Version:

[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

101 lines (100 loc) 3.48 kB
/** * Unified JSON Mapping processor that supports both legacy and model-driven formats. * * @deprecated Use JsonMappingConverter instead. This module is kept for backward compatibility. * This module provides backward compatibility while encouraging migration to the model-driven format. * It automatically detects the input format and normalizes to a consistent internal representation. */ import { JsonMapping } from './PostgresJsonQueryBuilder'; import { ModelDrivenJsonMapping } from './ModelDrivenJsonMapping'; /** * Unified mapping format that can handle both legacy and model-driven inputs. */ export interface UnifiedMappingInput { typeInfo?: { interface: string; importPath: string; }; structure?: any; protectedStringFields?: string[]; rootName?: string; rootEntity?: any; nestedEntities?: any[]; columns?: any; relationships?: any; } /** * Result of mapping format detection and conversion. */ export interface MappingProcessResult { format: 'model-driven' | 'unified' | 'legacy'; jsonMapping: JsonMapping; originalInput: UnifiedMappingInput; metadata?: { typeInfo?: { interface: string; importPath: string; }; protectedStringFields?: string[]; typeProtection?: any; }; } /** * Detects the format of a JSON mapping configuration. * * @param input - The mapping configuration to analyze * @returns The detected format type */ export declare function detectMappingFormat(input: UnifiedMappingInput): 'model-driven' | 'unified' | 'legacy'; /** * Main processor that unifies all JSON mapping formats into a consistent JsonMapping. * * @deprecated Use JsonMappingConverter.convert() instead. * * Features: * - Automatic format detection * - Backward compatibility with all existing formats * - Metadata preservation for advanced features * - Zero external dependencies * * @param input - Any supported JSON mapping format * @returns Unified processing result with JsonMapping and metadata */ export declare function processJsonMapping(input: UnifiedMappingInput): MappingProcessResult; /** * Convenience function for direct JsonMapping extraction. * * @deprecated Use JsonMappingConverter.toLegacyMapping() instead. * * @param input - Any supported JSON mapping format * @returns JsonMapping ready for use with PostgresJsonQueryBuilder */ export declare function unifyJsonMapping(input: UnifiedMappingInput): JsonMapping; /** * Type guard to check if input uses model-driven format. * * @param input - Mapping input to check * @returns True if input is model-driven format */ export declare function isModelDrivenFormat(input: UnifiedMappingInput): input is ModelDrivenJsonMapping; /** * Type guard to check if input uses unified format. * * @param input - Mapping input to check * @returns True if input is unified format */ export declare function isUnifiedFormat(input: UnifiedMappingInput): boolean; /** * Type guard to check if input uses legacy format. * * @param input - Mapping input to check * @returns True if input is legacy format */ export declare function isLegacyFormat(input: UnifiedMappingInput): boolean; /** * Migration helper that suggests upgrading to model-driven format. * * @param input - Current mapping configuration * @returns Suggestions for migration (if applicable) */ export declare function suggestModelDrivenMigration(input: UnifiedMappingInput): string[];