credl-parser-evaluator
Version:
TypeScript-based CREDL Parser and Evaluator that processes CREDL files and outputs complete Intermediate Representations
183 lines • 7.28 kB
TypeScript
/**
* CREDL Parser and Evaluator - Main API Interface
*
* This module provides the main public API for parsing, validating, and generating
* Intermediate Representation (IR) from CREDL (Commercial Real Estate Domain Language) files.
*/
import { ValidationOptions } from '../parser/SchemaValidator';
import { IRBuilderOptions } from '../engine/IRBuilder';
import { Readable } from 'stream';
import { CREDLFile, IR, ValidationResult } from '../types/CREDLTypes';
/**
* Main API interface for CREDL parsing and evaluation
*/
export interface CREDLApi {
/**
* Parse a CREDL YAML string into typed objects
*/
parse(yamlContent: string): Promise<CREDLFile>;
/**
* Validate a parsed CREDL file structure
*/
validate(credlFile: CREDLFile, options?: ValidationOptions): Promise<ValidationResult>;
/**
* Generate complete IR from parsed and validated CREDL data
*/
generateIR(credlFile: CREDLFile, options?: IRBuilderOptions): Promise<IR>;
/**
* Parse, validate, and generate IR in one step
*/
processFile(yamlContent: string, validationOptions?: ValidationOptions, irOptions?: IRBuilderOptions): Promise<IR>;
}
/**
* Parse a CREDL YAML string into typed objects
*
* @param yamlContent - The YAML content as a string
* @returns Promise resolving to parsed CREDL file structure
* @throws Error if parsing fails
*/
export declare function parse(yamlContent: string): Promise<CREDLFile>;
/**
* Parse CREDL content from a readable stream
*
* @param stream - Readable stream containing CREDL YAML content
* @returns Promise resolving to parsed CREDL file structure
* @throws Error if parsing fails
*/
export declare function parseStream(stream: Readable): Promise<CREDLFile>;
/**
* Validate a parsed CREDL file structure
*
* @param credlFile - The parsed CREDL file to validate
* @param options - Optional validation options
* @returns Promise resolving to validation result
*/
export declare function validate(credlFile: CREDLFile, options?: ValidationOptions): Promise<ValidationResult>;
/**
* Generate complete IR from parsed and validated CREDL data
*
* @param credlFile - The parsed and validated CREDL file
* @param options - Optional IR builder options
* @returns Promise resolving to generated IR
*/
export declare function generateIR(credlFile: CREDLFile, options?: IRBuilderOptions): Promise<IR>;
/**
* Parse, validate, and generate IR from CREDL content in one step
*
* @param yamlContent - The YAML content as a string
* @param validationOptions - Optional validation options
* @param irOptions - Optional IR builder options
* @returns Promise resolving to generated IR
*/
export declare function processFile(yamlContent: string, validationOptions?: ValidationOptions, irOptions?: IRBuilderOptions): Promise<IR>;
/**
* Parse CREDL content from a file path using async file I/O (Node.js only)
*
* @param filePath - Path to the CREDL YAML file
* @param validationOptions - Optional validation options
* @param irOptions - Optional IR builder options
* @returns Promise resolving to generated IR
*/
export declare function processFileFromPath(filePath: string, validationOptions?: ValidationOptions, irOptions?: IRBuilderOptions): Promise<IR>;
/**
* Read and parse CREDL content from a file path without full IR generation
*
* @param filePath - Path to the CREDL YAML file
* @param options - Optional validation options
* @returns Promise resolving to parsed and validated CREDL file
*/
export declare function parseFileFromPath(filePath: string, options?: ValidationOptions): Promise<ValidationResult & {
credlFile?: CREDLFile;
}>;
/**
* Write IR results to a JSON file using async file I/O (Node.js only)
*
* @param ir - The IR to write
* @param outputPath - Path where to write the JSON file
* @param pretty - Whether to format JSON with indentation (default: true)
* @returns Promise resolving when file is written
*/
export declare function writeIRToFile(ir: IR, outputPath: string, pretty?: boolean): Promise<void>;
/**
* Process multiple CREDL files concurrently using async file I/O
*
* @param filePaths - Array of CREDL file paths to process
* @param validationOptions - Optional validation options
* @param irOptions - Optional IR builder options
* @param maxConcurrency - Maximum number of files to process concurrently (default: 5)
* @returns Promise resolving to array of IR results with file paths
*/
export declare function processMultipleFiles(filePaths: string[], validationOptions?: ValidationOptions, irOptions?: IRBuilderOptions, maxConcurrency?: number): Promise<Array<{
filePath: string;
ir?: IR;
error?: string;
}>>;
/**
* Check if a file exists and is readable using async file I/O
*
* @param filePath - Path to check
* @returns Promise resolving to true if file exists and is readable
*/
export declare function checkFileExists(filePath: string): Promise<boolean>;
/**
* Get file stats using async file I/O
*
* @param filePath - Path to get stats for
* @returns Promise resolving to file stats or null if file doesn't exist
*/
export declare function getFileStats(filePath: string): Promise<{
size: number;
modified: Date;
} | null>;
/**
* Process CREDL content from a readable stream to generate IR
*
* @param stream - Readable stream containing CREDL YAML content
* @param validationOptions - Optional validation options
* @param irOptions - Optional IR builder options
* @returns Promise resolving to generated IR
*/
export declare function processStream(stream: Readable, validationOptions?: ValidationOptions, irOptions?: IRBuilderOptions): Promise<IR>;
/**
* Validate CREDL content from a readable stream without full IR generation
*
* @param stream - Readable stream containing CREDL YAML content
* @param options - Optional validation options
* @returns Promise resolving to validation result with parsed file
*/
export declare function validateStream(stream: Readable, options?: ValidationOptions): Promise<ValidationResult & {
credlFile?: CREDLFile;
}>;
/**
* Create a readable stream from a string (utility function)
*
* @param content - String content to convert to stream
* @returns Readable stream containing the content
*/
export declare function createStreamFromString(content: string): Readable;
/**
* Utility function to check if a CREDL file is valid without generating full IR
*
* @param yamlContent - The YAML content as a string
* @param options - Optional validation options
* @returns Promise resolving to validation result with parsed file
*/
export declare function validateFile(yamlContent: string, options?: ValidationOptions): Promise<ValidationResult & {
credlFile?: CREDLFile;
}>;
/**
* Get library version and metadata
*/
export declare function getVersion(): {
version: string;
generator: string;
};
export * from '../types/CREDLTypes';
export { CREDLParser } from '../parser/CREDLParser';
export { SchemaValidator } from '../parser/SchemaValidator';
export { IRBuilder } from '../engine/IRBuilder';
export { PresetResolver } from '../engine/PresetResolver';
export { TemplateResolver } from '../engine/TemplateResolver';
declare const credlApi: CREDLApi;
export default credlApi;
//# sourceMappingURL=index.d.ts.map