credl-parser-evaluator
Version:
TypeScript-based CREDL Parser and Evaluator that processes CREDL files and outputs complete Intermediate Representations
1,110 lines (847 loc) • 32.2 kB
Markdown
# CREDL Parser and Evaluator
A comprehensive TypeScript library for parsing, validating, and generating Intermediate Representation (IR) from CREDL (Commercial Real Estate Domain Language) files.
[](https://www.typescriptlang.org/)
[](https://nodejs.org/)
[](https://jestjs.io/)
[](#testing)
## Table of Contents
- [Overview](#overview)
- [Features](#features)
- [Installation](#installation)
- [Library Installation](#library-installation)
- [CLI Installation](#cli-installation)
- [Quick Start](#quick-start)
- [CLI Quick Start](#cli-quick-start)
- [Library Quick Start](#library-quick-start)
- [CLI Usage](#cli-usage)
- [CLI Commands](#cli-commands)
- [CLI Examples](#cli-examples)
- [CLI Workflows](#cli-workflows)
- [API Reference](#api-reference)
- [CREDL Language Guide](#credl-language-guide)
- [Documentation](#documentation)
- [Examples](#examples)
- [Performance](#performance)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)
## Overview
CREDL (Commercial Real Estate Domain Language) is a domain-specific language for modeling, simulating, and analyzing commercial real estate cash flows. This library provides both a **TypeScript/JavaScript API** and a **powerful CLI tool**:
### Library Features
- **Complete CREDL parsing** from YAML files into typed TypeScript objects
- **Comprehensive validation** with detailed error reporting and warnings
- **IR (Intermediate Representation) generation** for further processing and analysis
- **Advanced features** including presets, templates, scenarios, and waterfall structures
- **High performance** processing (typical files with <100 spaces in <100ms)
- **Stream support** for processing large files efficiently
### CLI Features
- **6 comprehensive commands** for complete CREDL development workflow
- **Interactive project initialization** with property type templates
- **Batch file validation** with multiple output formats
- **Performance benchmarking** with statistical analysis
- **Developer testing tools** with Jest integration
- **Professional output formatting** (tables, JSON, CSV)
## Features
### Library Core Functionality
- ✅ **YAML Parsing**: Convert CREDL YAML files to strongly-typed TypeScript objects
- ✅ **Schema Validation**: Comprehensive validation with detailed error messages
- ✅ **Cross-Reference Resolution**: Automatic resolution of relationships between elements
- ✅ **IR Generation**: Generate complete intermediate representation for analysis
### Library Advanced Features
- ✅ **Presets**: Reusable parameter sets with `preset_*` field references
- ✅ **Templates**: Automated space generation with `use_templates` blocks
- ✅ **Scenarios**: Conditional modeling with triggers and actions
- ✅ **Waterfall**: Multi-tier equity distribution structures
- ✅ **Extensions**: Support for advanced real estate modeling features
### CLI Commands
- ✅ **`credl run`**: Process and evaluate CREDL files with complete IR generation
- ✅ **`credl validate`**: Validate CREDL files with detailed reporting
- ✅ **`credl convert`**: Convert CREDL files to IR format
- ✅ **`credl init`**: Initialize new CREDL projects with templates
- ✅ **`credl test`**: Run tests and validation (developer command)
- ✅ **`credl benchmark`**: Performance benchmarking and analysis
### Data Types Supported
- ✅ **All Assumption Types**: fixed, distribution, expression, table
- ✅ **All Property Types**: office, retail, residential, industrial, mixed-use
- ✅ **All Distribution Types**: normal, triangular, uniform, lognormal
- ✅ **All Simulation Types**: monte_carlo with various stochastic processes
### Input/Output Options
- ✅ **Multiple Input Sources**: strings, files, streams, glob patterns
- ✅ **Multiple Output Formats**: JSON, pretty JSON, table, CSV, summary
- ✅ **Async/Await Support**: Full async support for file I/O operations
- ✅ **Concurrent Processing**: Process multiple files simultaneously
- ✅ **Batch Operations**: CLI supports processing multiple files with glob patterns
### Documentation and Export
- ✅ **Comprehensive Reference Manual**: 4,280+ line professional documentation
- ✅ **Export-Ready Formats**: HTML, PDF, Word (DOCX) conversion support
- ✅ **Cross-Reference System**: Complete navigation and field reference tables
- ✅ **80+ Working Examples**: All documented features with validated code examples
- ✅ **Validation Appendices**: Comprehensive validation rules and best practices
- ✅ **IP Protection**: Copyright and licensing framework established
## Installation
### Library Installation
For programmatic use in your TypeScript/JavaScript projects:
```bash
npm install credl-parser-evaluator
```
### CLI Installation
For command-line usage, install globally:
```bash
npm install -g credl-parser-evaluator
```
Or use without installing:
```bash
npx credl-parser-evaluator --help
```
### Development Installation
For contributing to the project:
```bash
git clone https://github.com/your-org/credl-parser-evaluator.git
cd credl-parser-evaluator
npm install
npm run build
npm link # Makes CLI available globally
```
### Requirements
- Node.js 18.0 or higher
- TypeScript 5.0 or higher (for development)
### Verify Installation
```bash
# Check CLI installation
credl --version
# Check library installation
npm list credl-parser-evaluator
```
## Quick Start
### CLI Quick Start
```bash
# 1. Initialize a new CREDL project
credl init --type office --name "My Office Building" --location "Chicago, IL"
# 2. Validate your CREDL file
credl validate my-office-building.credl
# 3. Process the file to generate IR
credl run my-office-building.credl --format pretty
# 4. Convert to IR format for analysis
credl convert my-office-building.credl --output my-property-ir.json
# 5. Run performance benchmarks
credl benchmark --file my-office-building.credl --memory
# 6. Run tests for development
credl test --coverage
```
### Library Quick Start
#### Basic Usage
```typescript
import { processFile, parse, validate, generateIR } from 'credl-parser-evaluator';
// Parse, validate, and generate IR in one step
const yamlContent = `
metadata:
version: 0.2
name: "My Property"
description: "Simple office building"
created_date: "2025-06-21"
assets:
- id: "asset-1"
name: "Downtown Office"
property_type: "Office"
location: "Chicago, IL"
total_area_sf: 50000
buildings:
- id: "building-1"
name: "Main Building"
floors: 10
total_area_sf: 50000
spaces:
- id: "suite-100"
parent_building: "building-1"
type: "office"
area_sf: 5000
lease:
status: "leased"
tenant: "Tech Corp"
rent_psf: 45
lease_type: "gross"
assumptions:
- name: "discount_rate"
type: "fixed"
value: 0.08
models:
- name: "base_dcf"
type: "deterministic"
duration_years: 10
steps_per_year: 12
inputs: ["discount_rate"]
outputs: ["IRR", "NPV"]
simulation:
type: "monte_carlo"
iterations: 1000
processes: {}
outputs:
summary_metrics: ["IRR", "NPV"]
outputs:
format: "json"
metrics: ["IRR", "NPV"]
`;
// Process the CREDL content
const ir = await processFile(yamlContent);
console.log(`Processed ${ir.spaces.length} spaces`);
console.log(`Validation: ${ir.validation.isValid ? 'Valid' : 'Invalid'}`);
```
### File Processing
```typescript
import { processFileFromPath, writeIRToFile } from 'credl-parser-evaluator';
// Process a CREDL file from disk
const ir = await processFileFromPath('./my-property.credl');
// Write the IR to a JSON file
await writeIRToFile(ir, './output/my-property-ir.json');
```
### Step-by-Step Processing
```typescript
import { parse, validate, generateIR } from 'credl-parser-evaluator';
// Step 1: Parse CREDL content
const credlFile = await parse(yamlContent);
// Step 2: Validate the parsed content
const validationResult = await validate(credlFile);
if (!validationResult.isValid) {
console.error('Validation errors:', validationResult.errors);
return;
}
// Step 3: Generate IR
const ir = await generateIR(credlFile);
console.log('IR generated successfully!');
```
### Stream Processing
```typescript
import { processStream, createStreamFromString } from 'credl-parser-evaluator';
import { createReadStream } from 'fs';
// Process from a file stream
const fileStream = createReadStream('./large-property.credl');
const ir = await processStream(fileStream);
// Process from a string stream
const stringStream = createStreamFromString(yamlContent);
const ir2 = await processStream(stringStream);
```
## CLI Usage
The CREDL CLI provides six powerful commands for working with CREDL files:
### CLI Commands
#### `credl run <file>`
Process and evaluate a CREDL file to generate complete IR.
```bash
# Basic usage
credl run my-property.credl
# With output options
credl run my-property.credl --output results.json --format pretty --verbose
# Process with specific settings
credl run my-property.credl --fail-fast --include-metadata --resolve-templates
```
**Options:**
- `-o, --output <path>` - Output file path (default: console)
- `-f, --format <format>` - Output format: json, pretty, summary (default: pretty)
- `-v, --verbose` - Verbose output with processing details
- `-q, --quiet` - Suppress output except errors
- `--fail-fast` - Stop on first validation error
- `--include-metadata` - Include processing metadata (default: true)
- `--resolve-presets` - Resolve preset references (default: true)
- `--resolve-templates` - Resolve template definitions (default: true)
- `--validate-references` - Validate cross-references (default: true)
#### `credl validate <files...>`
Validate CREDL files for syntax and specification compliance.
```bash
# Validate single file
credl validate my-property.credl
# Validate multiple files
credl validate *.credl **/*.yaml
# With different output formats
credl validate my-property.credl --format table --verbose
credl validate my-property.credl --format json --output validation-report.json
```
**Options:**
- `-o, --output <path>` - Output validation results to file
- `-f, --format <format>` - Output format: table, json, summary (default: table)
- `-v, --verbose` - Verbose validation output
- `-q, --quiet` - Suppress output except errors
- `--fail-fast` - Stop validation on first error per file
- `--strict` - Enable strict validation mode
- `--check-references` - Enable cross-reference validation (default: true)
- `--exit-code` - Exit with non-zero code if files are invalid (default: true)
#### `credl convert <file>`
Convert CREDL files to Intermediate Representation (IR).
```bash
# Basic conversion
credl convert my-property.credl
# Convert with specific output
credl convert my-property.credl --output my-property-ir.json --format json
# Skip validation for faster processing
credl convert my-property.credl --skip-validation --format pretty
```
**Options:**
- `-o, --output <path>` - Output file path (default: console)
- `-f, --format <format>` - Output format: json, pretty (default: json)
- `-v, --verbose` - Verbose conversion output
- `-q, --quiet` - Suppress output except errors
- `--skip-validation` - Skip validation for faster processing
- `--include-metadata` - Include processing metadata (default: true)
- `--resolve-presets` - Resolve preset references (default: true)
- `--resolve-templates` - Resolve template definitions (default: true)
- `--validate-references` - Validate cross-references (default: true)
- `--generate-ids` - Generate unique IDs for elements (default: true)
#### `credl init`
Initialize a new CREDL project with interactive prompts.
```bash
# Interactive mode
credl init
# Non-interactive with options
credl init --type office --name "My Office" --location "Chicago, IL" --output my-office.credl
# Force overwrite existing files
credl init --type retail --force
```
**Options:**
- `-t, --type <type>` - Property type: office, retail, mixed-use, industrial, residential
- `-n, --name <name>` - Project name (skip interactive prompt)
- `-l, --location <location>` - Property location (skip interactive prompt)
- `-o, --output <path>` - Output file path (default: {name}.credl)
- `-f, --force` - Overwrite existing files without confirmation
- `-v, --verbose` - Verbose output with detailed information
- `-q, --quiet` - Suppress output except errors
#### `credl test`
Run CREDL tests and validation (developer command).
```bash
# Run all tests
credl test
# Run specific test file
credl test --single src/parser/CREDLParser.test.ts
# Run with coverage and watch mode
credl test --coverage --watch --verbose
# CI mode
credl test --ci --max-workers 4
```
**Options:**
- `--single <file>` - Run a specific test file
- `--watch` - Watch mode for continuous testing
- `--coverage` - Generate test coverage report
- `--ci` - CI mode with appropriate settings
- `--performance` - Include performance tests
- `--examples` - Include example file tests
- `--pattern <pattern>` - Test file pattern (default: **/*.test.ts)
- `--max-workers <number>` - Maximum number of worker processes
- `--timeout <number>` - Test timeout in milliseconds
- `-v, --verbose` - Verbose test output
- `-q, --quiet` - Suppress output except errors
#### `credl benchmark`
Run performance benchmarks on CREDL files and processing.
```bash
# Run standard benchmark suite
credl benchmark
# Benchmark specific file
credl benchmark --file large-property.credl --memory --verbose
# Run comprehensive benchmarks with comparison
credl benchmark --suite comprehensive --compare previous-results.json --history
# Performance threshold testing
credl benchmark --threshold 100 --format json --output benchmark-results.json
```
**Options:**
- `-f, --file <path>` - Benchmark a specific CREDL file
- `-o, --output <path>` - Output benchmark results to file
- `--format <format>` - Output format: table, json, csv (default: table)
- `-i, --iterations <number>` - Number of benchmark iterations (default: 10)
- `-w, --warmup <number>` - Number of warmup iterations (default: 3)
- `-v, --verbose` - Verbose benchmark output
- `-q, --quiet` - Suppress output except results
- `-c, --compare <path>` - Compare with previous benchmark results
- `--history` - Save results to benchmark history
- `-s, --suite <suite>` - Run predefined suite: quick, standard, comprehensive (default: standard)
- `-t, --threshold <ms>` - Performance threshold in milliseconds
- `--memory` - Include memory usage analysis
- `--concurrent <number>` - Run concurrent benchmark tests
- `--profile` - Enable detailed profiling
### CLI Examples
#### Initialize and Process a New Project
```bash
# Create a new office building project
credl init --type office --name "Downtown Office Tower" --location "Seattle, WA"
# Validate the generated file
credl validate downtown-office-tower.credl --format table --verbose
# Process the file with detailed output
credl run downtown-office-tower.credl --format pretty --verbose
# Convert to IR for analysis
credl convert downtown-office-tower.credl --output tower-ir.json
```
#### Batch Validation and Processing
```bash
# Validate all CREDL files in current directory
credl validate *.credl --format summary
# Validate files in subdirectories
credl validate **/*.credl --format json --output validation-report.json
# Process multiple files (not supported directly, but can use shell)
for file in *.credl; do
credl run "$file" --output "${file%.credl}-ir.json"
done
```
#### Development Workflow
```bash
# Create a new project
credl init --type mixed-use --name "Mixed Use Development"
# Watch for changes and validate continuously
credl test --watch --examples
# Run performance benchmarks
credl benchmark --file mixed-use-development.credl --memory --verbose
# Full validation and processing
credl validate mixed-use-development.credl --strict
credl run mixed-use-development.credl --format summary
```
### CLI Workflows
#### 1. New Project Development
```bash
credl init → credl validate → credl run → credl convert
```
#### 2. CI/CD Pipeline
```bash
credl validate → credl test --ci → credl benchmark --threshold 100
```
#### 3. Performance Analysis
```bash
credl benchmark → credl run --verbose → credl convert --output analysis.json
```
#### 4. Batch Processing
```bash
credl validate *.credl → process each file → credl benchmark --suite comprehensive
```
## API Reference
### Core Functions
#### `processFile(yamlContent, validationOptions?, irOptions?)`
Parse, validate, and generate IR from CREDL content in one step.
**Parameters:**
- `yamlContent: string` - The YAML content as a string
- `validationOptions?: ValidationOptions` - Optional validation configuration
- `irOptions?: IRBuilderOptions` - Optional IR builder configuration
**Returns:** `Promise<IR>` - Complete intermediate representation
#### `parse(yamlContent)`
Parse CREDL YAML content into typed objects.
#### `validate(credlFile, options?)`
Validate a parsed CREDL file structure.
#### `generateIR(credlFile, options?)`
Generate complete IR from parsed and validated CREDL data.
### File I/O Functions
#### `processFileFromPath(filePath, validationOptions?, irOptions?)`
Process a CREDL file from disk using async file I/O.
#### `writeIRToFile(ir, outputPath, pretty?)`
Write IR results to a JSON file.
#### `processMultipleFiles(filePaths, validationOptions?, irOptions?, maxConcurrency?)`
Process multiple CREDL files concurrently.
### Stream Functions
#### `processStream(stream, validationOptions?, irOptions?)`
Process CREDL content from a readable stream.
#### `parseStream(stream)`
Parse CREDL content from a readable stream.
#### `createStreamFromString(content)`
Create a readable stream from a string (utility function).
### Utility Functions
#### `validateFile(yamlContent, options?)`
Validate CREDL content without generating full IR.
#### `checkFileExists(filePath)`
Check if a file exists and is readable.
#### `getFileStats(filePath)`
Get file stats using async file I/O.
#### `getVersion()`
Get library version and metadata.
## CREDL Language Guide
### Basic Structure
Every CREDL file must include these core blocks:
```yaml
metadata:
version: 0.2
name: "Property Name"
description: "Description"
created_date: "2025-06-21"
assets:
- id: "asset-1"
# Asset definition
spaces:
- id: "space-1"
# Space definition
assumptions:
- name: "assumption_1"
# Assumption definition
models:
- name: "model_1"
# Model definition
simulation:
type: "monte_carlo"
# Simulation configuration
outputs:
format: "json"
# Output specification
```
### Assumption Types
#### Fixed Assumptions
```yaml
assumptions:
- name: "discount_rate"
type: "fixed"
value: 0.08
description: "Required return rate"
tags: ["capital_market"]
```
#### Distribution Assumptions
```yaml
assumptions:
- name: "rent_growth"
type: "distribution"
distribution: "normal"
parameters:
mean: 0.025
stddev: 0.01
scope: "space_type:office"
tags: ["revenue"]
```
#### Expression Assumptions
```yaml
assumptions:
- name: "effective_rent"
type: "expression"
formula: "base_rent * (1 - vacancy_rate)"
scope: "space_type:office"
tags: ["revenue", "calculated"]
```
#### Table Assumptions
```yaml
assumptions:
- name: "operating_expenses"
type: "table"
values:
- name: "Property Taxes"
amount_per_sf: 3.50
- name: "Insurance"
amount_per_sf: 1.25
scope: "space_type:office"
tags: ["expenses"]
```
### Presets and Templates
#### Using Presets
```yaml
presets:
lease_profiles:
office_standard:
rent_psf: 45
lease_type: "gross"
escalation_rate: 0.025
spaces:
- id: "suite-100"
parent_building: "building-1"
type: "office"
area_sf: 5000
preset_lease: "office_standard" # Reference to preset
```
#### Using Templates
```yaml
templates:
office_floor:
spaces:
- id_prefix: "Suite"
type: "office"
area_sf: 2500
count: 4
use_templates:
- template: "office_floor"
parent_building: "building-1"
start_index: 100
```
## Documentation
The CREDL project includes comprehensive documentation for users, developers, and implementers:
### CREDL Reference Manual
**Primary Documentation: [`docs/CREDL_REFERENCE.md`](docs/CREDL_REFERENCE.md)**
- **4,280+ lines** of comprehensive technical documentation
- **Complete language specification** with all block types and field definitions
- **80+ working examples** demonstrating every documented feature
- **Comprehensive appendices** with validation rules, best practices, and error codes
- **Professional formatting** with cross-references and navigation
### Documentation Export and Publishing
**Export-Ready Version: [`docs/CREDL_REFERENCE_EXPORT.md`](docs/CREDL_REFERENCE_EXPORT.md)**
- Optimized for HTML, PDF, and Word (DOCX) conversion
- Pandoc metadata headers and CSS styling included
- Professional layout with page breaks and formatting
**Export Script: [`scripts/export-documentation.sh`](scripts/export-documentation.sh)**
```bash
# Export to multiple formats
./scripts/export-documentation.sh
# Creates:
# - HTML with responsive design and CSS styling
# - PDF with LaTeX formatting and professional layout
# - Word (DOCX) for collaborative editing
# - Standalone HTML with embedded styles
```
### Additional Documentation
**Validation and Compliance:**
- [`docs/internal/FINAL_VALIDATION_REPORT.md`](docs/internal/FINAL_VALIDATION_REPORT.md) - Implementation compliance certification
- [`docs/internal/CREDL_BEHAVIORAL_SPECIFICATION.md`](docs/internal/CREDL_BEHAVIORAL_SPECIFICATION.md) - Behavioral decisions and specifications
**Developer Resources:**
- [`docs/internal/DEVELOPER_ONBOARDING.md`](docs/internal/DEVELOPER_ONBOARDING.md) - Developer onboarding guide
- [`docs/internal/DEVELOPER_WORKFLOW.md`](docs/internal/DEVELOPER_WORKFLOW.md) - Development workflows and guidelines
- [`docs/internal/FILE_NAMING_CONVENTIONS.md`](docs/internal/FILE_NAMING_CONVENTIONS.md) - Codebase naming standards
**Additional Guides:**
- [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) - Comprehensive troubleshooting guide
- [`docs/CLI_REFERENCE.md`](docs/CLI_REFERENCE.md) - Complete CLI command reference
- [`docs/API_REFERENCE.md`](docs/API_REFERENCE.md) - Programmatic API documentation
### Documentation Quality Standards
**Production Ready:**
- ✅ **100% specification compliance** - All documented features implemented
- ✅ **Complete validation** - All examples pass parser validation
- ✅ **Professional formatting** - Ready for publication and distribution
- ✅ **IP protection** - Copyright and licensing framework established
- ✅ **Export capabilities** - Multiple format support with automation
## Examples
The library includes comprehensive example files in the `examples/` directory:
### 1. Minimal Office (`01-minimal-office.credl`)
Basic CREDL structure with simple office building
### 2. Comprehensive Mixed-Use (`02-comprehensive-mixed-use.credl`)
Advanced features with all assumption types and property types
### 3. Presets and Templates (`03-presets-and-templates.credl`)
Reusable constructs and automated space generation
### 4. Extensions and Scenarios (`04-extensions-scenarios-waterfall.credl`)
Advanced modeling with scenarios and waterfall structures
### 5. Industrial Portfolio (`05-industrial-portfolio.credl`)
Portfolio-level analysis across multiple assets
### Running Examples
```typescript
import { processFileFromPath } from 'credl-parser-evaluator';
// Process an example file
const ir = await processFileFromPath('./examples/01-minimal-office.credl');
console.log(`Processed ${ir.spaces.length} spaces`);
console.log(`Assets: ${ir.assets.length}`);
console.log(`Valid: ${ir.validation.isValid}`);
```
## Performance
The CREDL Parser and Evaluator is highly optimized for performance:
### Benchmarks
- **25 spaces**: ~43ms (23x faster than 1s requirement)
- **50 spaces**: ~30ms (33x faster than 1s requirement)
- **75 spaces**: ~59ms (17x faster than 1s requirement)
- **100 spaces**: ~28ms (36x faster than 1s requirement)
### Performance Characteristics
- **Processing Speed**: ~0.2ms per space on average
- **Memory Efficiency**: <0.02MB per space
- **Scaling**: Better than linear (efficiency improves with size)
- **Concurrency**: Efficient parallel processing support
### Performance Testing
```bash
# Run performance tests
npx jest src/performance/performance.test.ts
# Run comprehensive benchmarks
npm run benchmark
# Export performance reports
./scripts/export-documentation.sh
```
## Testing
The library includes comprehensive test coverage:
### Test Statistics
- **Total Tests**: 542 test cases (100% passing)
- **Coverage**: 90%+ across all modules
- **Test Types**: Unit, integration, performance, and example tests
- **Quality Assurance**: All examples validate successfully against parser
### Running Tests
```bash
# Run all tests
npm test
# Run specific test files
npx jest src/parser/CREDLParser.test.ts
npx jest src/engine/IRBuilder.test.ts
npx jest examples/examples.test.ts
npx jest src/performance/performance.test.ts
# Run tests with coverage
npm test -- --coverage
```
### Test Structure
- **Unit Tests**: Individual component testing (`*.test.ts`)
- **Integration Tests**: End-to-end workflow testing (`api/index.test.ts`)
- **Performance Tests**: Performance benchmarking (`performance/performance.test.ts`)
- **Example Tests**: Example file validation (`examples/examples.test.ts`)
## Troubleshooting
### CLI Issues
#### Command Not Found
```bash
# Error: credl: command not found
# Solutions:
# 1. Install globally
npm install -g credl-parser-evaluator
# 2. Use npx
npx credl-parser-evaluator --help
# 3. Check installation
npm list -g credl-parser-evaluator
```
#### Permission Errors
```bash
# Error: EACCES permission denied
# Solutions:
# 1. Use sudo (not recommended)
sudo npm install -g credl-parser-evaluator
# 2. Configure npm to use different directory (recommended)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profile
npm install -g credl-parser-evaluator
```
#### File Processing Errors
```bash
# Error: Cannot read file or Invalid CREDL format
# Check file exists and is readable
ls -la my-property.credl
# Validate file format
credl validate my-property.credl --verbose
# Check file encoding (should be UTF-8)
file -bi my-property.credl
# Test with minimal example
credl init --type office --name "Test" --output test.credl
credl validate test.credl
```
### Library Issues
#### Import Errors
```typescript
// Error: Cannot find module 'credl-parser-evaluator'
// Solutions:
// 1. Check installation
import { processFile } from 'credl-parser-evaluator';
// 2. Try relative import if in development
import { processFile } from './src/api/index';
// 3. Check node_modules
ls node_modules/credl-parser-evaluator/
```
#### TypeScript Compilation Errors
```bash
# Error: TypeScript compilation issues
# Solutions:
# 1. Update TypeScript version
npm install typescript@latest
# 2. Check tsconfig.json compatibility
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true
}
}
# 3. Clear cache and rebuild
rm -rf node_modules package-lock.json
npm install
```
### Performance Issues
#### Large File Processing
```bash
# For files with >1000 spaces or complex structures
# Use CLI with optimization flags
credl run large-property.credl --skip-validation --format json
# Use streaming for very large files
credl convert large-property.credl --format json --output results.json
# Monitor performance
credl benchmark --file large-property.credl --memory --verbose
```
#### Memory Issues
```bash
# Error: JavaScript heap out of memory
# Solutions:
# 1. Increase Node.js memory limit
NODE_OPTIONS="--max-old-space-size=4096" credl run large-file.credl
# 2. Process files individually rather than batch
for file in *.credl; do credl run "$file"; done
# 3. Use convert command for minimal processing
credl convert large-file.credl --skip-validation
```
### Common CREDL File Issues
#### Validation Errors
```yaml
# Common validation issues and fixes
# Issue: Missing required fields
# Fix: Add all required metadata fields
metadata:
version: 0.2 # Required
name: "Property Name" # Required
description: "Description" # Required
created_date: "2025-01-21" # Required
# Issue: Invalid cross-references
# Fix: Ensure all referenced IDs exist
spaces:
- id: "suite-100"
parent_building: "building-1" # Must exist in buildings
# Issue: Invalid assumption types
# Fix: Use correct assumption types
assumptions:
- name: "discount_rate"
type: "fixed" # Must be: fixed, distribution, expression, table
value: 0.08
```
#### Template Issues
```yaml
# Issue: Template resolution failures
# Fix: Ensure templates are properly defined
templates:
office_floor: # Template definition
spaces:
- id_prefix: "Suite"
type: "office"
area_sf: 2500
use_templates: # Template usage
- template: "office_floor" # Must match template name exactly
parent_building: "building-1" # Parent must exist
```
### Getting Help
- **Documentation**: See this README and `/docs` directory
- **Examples**: Check `/examples` directory for working examples
- **Verbose Mode**: Use `-v` or `--verbose` flags for detailed output
- **Validation**: Always run `credl validate` first to check file structure
- **Benchmarking**: Use `credl benchmark` to identify performance bottlenecks
## Project Status
### Production Ready ✅
The CREDL Parser and Evaluator is **production-ready** with complete implementation:
**Implementation Status:**
- ✅ **542/542 tests passing** (100% test success rate)
- ✅ **All documented features implemented** with full specification compliance
- ✅ **Complete validation system** with comprehensive error reporting
- ✅ **Performance optimized** - exceeds requirements significantly
- ✅ **Professional documentation** ready for publication
**Quality Assurance:**
- ✅ **Final validation report** confirming 100% specification compliance
- ✅ **All examples validate successfully** against parser implementation
- ✅ **Comprehensive test coverage** across all components
- ✅ **Export-ready documentation** with multiple format support
**Business Ready:**
- ✅ **IP protection** with copyright and licensing framework
- ✅ **Commercial licensing** terms established
- ✅ **Professional documentation** suitable for distribution
- ✅ **Multi-format publishing** capabilities (HTML, PDF, Word)
### Release Information
**Current Version:** 1.0 (Production Release)
- **CREDL Specification:** v0.2 fully supported
- **Node.js Compatibility:** 18.0+ (tested)
- **TypeScript:** 5.0+ (fully typed)
- **Documentation:** Complete with export capabilities
## Contributing
We welcome contributions! Please see our contributing guidelines:
### Development Setup
```bash
# Clone the repository
git clone https://github.com/your-org/credl-parser-evaluator.git
cd credl-parser-evaluator
# Install dependencies
npm install
# Run tests
npm test
# Build the project
npm run build
```
### Code Style
- TypeScript with strict mode enabled
- ESLint and Prettier for code formatting
- Jest for testing
- Comprehensive JSDoc documentation
## License
MIT License - see LICENSE file for details.
## Support
- **Documentation**: This README and inline JSDoc comments
- **Examples**: See `examples/` directory for comprehensive examples
- **Issues**: Report bugs and request features on GitHub
- **Performance**: Library exceeds performance requirements significantly
---
**CREDL Parser and Evaluator** - Comprehensive commercial real estate modeling made simple.