rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
54 lines (53 loc) • 1.63 kB
TypeScript
/**
* Enhanced JSON mapping structure that integrates column mapping and type protection configuration.
* This unified approach eliminates the need for separate .types.json files.
*/
import { JsonMapping } from './PostgresJsonQueryBuilder';
/**
* Supported column type enforcement options.
*/
export type ColumnType = 'string' | 'auto';
/**
* Column configuration that can either be a simple string mapping or an enhanced mapping with type control.
*/
export type ColumnMappingConfig = string | {
column: string;
type?: ColumnType;
};
/**
* Enhanced JSON mapping configuration with integrated type protection.
*/
export interface UnifiedJsonMapping {
rootName: string;
typeInfo?: {
interface: string;
importPath: string;
};
rootEntity: {
id: string;
name: string;
columns: Record<string, ColumnMappingConfig>;
};
nestedEntities?: Array<{
id: string;
name: string;
parentId: string;
propertyName: string;
relationshipType: 'object' | 'array';
columns: Record<string, ColumnMappingConfig>;
}>;
}
/**
* Type protection configuration extracted from the unified mapping.
*/
export interface TypeProtectionConfig {
protectedStringFields: string[];
}
/**
* Convert a unified JSON mapping to separate JsonMapping and TypeProtectionConfig.
* This enables backward compatibility with existing code while supporting the new unified structure.
*/
export declare function convertUnifiedMapping(unified: UnifiedJsonMapping): {
jsonMapping: JsonMapping;
typeProtection: TypeProtectionConfig;
};