BREAKING CHANGE(core): Refactor to v3: introduce modular core/domain architecture, plugin system, observability and strict TypeScript configuration; remove legacy classes

This commit is contained in:
2025-11-29 18:32:00 +00:00
parent 53673e37cb
commit 7e89b6ebf5
68 changed files with 17020 additions and 720 deletions

View File

@@ -1,3 +1,97 @@
# Project Readme Hints
This is the initial readme hints file.
## v3.0 Transformation Progress
### Completed Components
**Phase 1: Foundation (100%)** - Complete
- Error handling with typed hierarchy
- Observability (logging, metrics, tracing)
- Configuration management with fluent builder
- Connection management with health checks and circuit breaker
**Phase 2: Domain APIs (100%)** - Complete! 🎉
- **Document API (100%)** - Complete fluent CRUD operations with sessions, iteration, snapshots
- **Query Builder (100%)** - Type-safe query construction with aggregations
- **Logging API (100%)** - Enterprise structured logging with:
- Batched bulk indexing with auto-flush
- Log enrichment pipeline (host, environment, service, sanitization)
- Sampling strategies (all, errors-only, percentage, rate-limit)
- ILM (Index Lifecycle Management) integration
- Metric extraction from logs
- Dynamic tagging based on content
- Queue overflow protection
- Example at `ts/examples/logging/logging-example.ts`
- **Bulk Indexer (100%)** - High-throughput document ingestion with:
- Fixed, adaptive, and size-based batching strategies
- Parallel workers for concurrent processing
- Backpressure handling with queue management
- Dead-letter queue for failed operations
- Progress callbacks with ETA estimation
- Automatic retries with exponential backoff
- Mixed operations (index, update, delete)
- Comprehensive statistics tracking
- Example at `ts/examples/bulk/bulk-indexer-example.ts`
- **KV Store (100%)** - Distributed key-value storage with:
- Time-to-live (TTL) support with automatic expiration
- In-memory caching layer with multiple eviction policies (LRU, LFU, FIFO, TTL)
- Batch operations (mget, mset, mdelete)
- Scan/cursor support for large keyspaces with wildcard patterns
- Automatic compression for large values
- Optimistic concurrency control
- Cache hit/miss statistics
- Example at `ts/examples/kv/kv-store-example.ts`
**Phase 3: Advanced Features**
- **Plugin Architecture (100%)** - Extensible request/response middleware:
- Plugin lifecycle hooks (beforeRequest, afterResponse, onError)
- Plugin priority and execution ordering
- Plugin statistics and monitoring
- Built-in plugins:
- Logging plugin - automatic request/response logging
- Metrics plugin - automatic metrics collection
- Cache plugin - response caching for GET requests
- Retry plugin - automatic retry with exponential backoff
- Rate limit plugin - token bucket rate limiting
- Custom plugin creation with factories
- Dynamic plugin registration/unregistration
- Shared context between plugins
- Timeout protection for plugin hooks
- Example at `ts/examples/plugins/plugin-example.ts`
### Query Builder Usage
```typescript
import { createQuery } from './ts';
// Simple query
const results = await createQuery<Product>('products')
.match('name', 'laptop')
.range('price', { gte: 100, lte: 1000 })
.sort('price', 'asc')
.execute();
// With aggregations
const stats = await createQuery<Product>('products')
.matchAll()
.aggregations((agg) => {
agg.terms('brands', 'brand.keyword')
.subAggregation('avg_price', (sub) => sub.avg('avg_price', 'price'));
})
.execute();
```
### Next Priorities
1. **Transaction Support** (Phase 3) - Distributed transactions across multiple documents
2. **Schema Management** (Phase 3) - Index mapping management and migrations
3. **Comprehensive Test Suite** (Phase 4) - Full test coverage
4. **Migration Guide** (Phase 4) - Guide from v2 to v3
### Structure
- Single `ts/` directory (no parallel structures)
- Single `tsconfig.json` with strict mode enabled
- All v3.0 code lives in `ts/` directory
### Known Issues
- Minor TypeScript strict mode import issues documented in `ts/QUICK_FIXES.md`
- Need to apply `import type` fixes for verbatimModuleSyntax compliance