feat: remove legacy ImportManager, standardize getStats() API
- Removed ImportManager class and exports (use brain.import() instead) - Fixed all documentation: getStatistics() → getStats() - Updated 41 files across codebase for consistency - Removed ImportManager section from API docs - Added v3.30.0 migration guide to CHANGELOG Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
68c989e4f7
commit
58daf09403
31 changed files with 87 additions and 481 deletions
|
|
@ -1071,93 +1071,6 @@ console.log(`Types:`, Object.keys(nounTypes))
|
|||
|
||||
---
|
||||
|
||||
## Import API
|
||||
|
||||
### `createImportManager(brain: Brainy): ImportManager`
|
||||
Creates an import manager for intelligent data import.
|
||||
|
||||
**Example:**
|
||||
```typescript
|
||||
import { Brainy, createImportManager } from '@soulcraft/brainy'
|
||||
|
||||
const brain = new Brainy({ preset: 'memory' })
|
||||
await brain.init()
|
||||
|
||||
const importer = createImportManager(brain)
|
||||
await importer.init()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `async ImportManager.import(source, options?): Promise<ImportResult>`
|
||||
Import data from various sources with AI-powered entity detection.
|
||||
|
||||
**Parameters:**
|
||||
- `source` - String, Buffer, array, or object to import
|
||||
- `options.source` - 'data' | 'file' | 'url' | 'auto' (default: 'auto')
|
||||
- `options.format` - 'json' | 'csv' | 'text' | 'yaml' | 'auto' (default: 'auto')
|
||||
- `options.batchSize` - Batch size for processing (default: 50)
|
||||
- `options.autoDetect` - Auto-detect entity types (default: true)
|
||||
- `options.typeHint` - Suggested entity type
|
||||
- `options.extractRelationships` - Extract relationships (default: true)
|
||||
- `options.csvDelimiter` - CSV delimiter character
|
||||
- `options.csvHeaders` - CSV has headers (default: true)
|
||||
- `options.parallel` - Process in parallel (default: true)
|
||||
- `options.maxConcurrency` - Max concurrent operations
|
||||
|
||||
**Returns:**
|
||||
```typescript
|
||||
{
|
||||
success: boolean
|
||||
nouns: string[] // IDs of imported entities
|
||||
verbs: string[] // IDs of created relationships
|
||||
errors: string[]
|
||||
stats: {
|
||||
total: number
|
||||
imported: number
|
||||
failed: number
|
||||
relationships: number
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
|
||||
```typescript
|
||||
// Import from CSV file
|
||||
const result = await importer.importFile('./data.csv', {
|
||||
format: 'csv',
|
||||
extractRelationships: true
|
||||
})
|
||||
|
||||
// Import from URL
|
||||
const result = await importer.importUrl('https://api.example.com/data.json')
|
||||
|
||||
// Import array of objects
|
||||
const data = [
|
||||
{ name: 'Alice', role: 'Developer' },
|
||||
{ name: 'Bob', role: 'Designer' }
|
||||
]
|
||||
const result = await importer.import(data, {
|
||||
typeHint: NounType.Person,
|
||||
extractRelationships: true
|
||||
})
|
||||
|
||||
console.log(`Imported ${result.stats.imported}/${result.stats.total} items`)
|
||||
console.log(`Created ${result.stats.relationships} relationships`)
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- 🧠 **AI Entity Detection** - Auto-detect entity types from data
|
||||
- 🔗 **Relationship Extraction** - Discover connections automatically
|
||||
- 📊 **Multi-Format Support** - CSV, JSON, YAML, text files
|
||||
- 🚀 **Batch Processing** - Efficient handling of large datasets
|
||||
- 💡 **Neural Analysis** - Confidence scoring and insights
|
||||
- 🎯 **Smart CSV Parsing** - Auto-delimiter detection
|
||||
- 🌐 **URL Imports** - Direct import from web sources
|
||||
|
||||
---
|
||||
|
||||
## Query API
|
||||
|
||||
Access via: `brain.query`
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ monitor.getThrottlingMetrics() // Rate limiting info
|
|||
## 📊 Statistics System (Fully Working!)
|
||||
|
||||
```typescript
|
||||
const stats = await brain.getStatistics()
|
||||
const stats = await brain.getStats()
|
||||
// Returns comprehensive metrics:
|
||||
{
|
||||
nouns: {
|
||||
|
|
@ -269,7 +269,7 @@ await brain.neuralImport('data.csv')
|
|||
### Access Statistics
|
||||
```typescript
|
||||
// Get comprehensive stats
|
||||
const stats = await brain.getStatistics()
|
||||
const stats = await brain.getStats()
|
||||
|
||||
// Get specific service stats
|
||||
const nounStats = await brain.getStatistics({
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ brain.find({ where: { category: 'tech' } })
|
|||
**Auto-enabled**: Always active
|
||||
**Purpose**: Performance metrics and statistics collection
|
||||
```typescript
|
||||
brain.getStatistics() // Comprehensive metrics
|
||||
brain.getStats() // Comprehensive metrics
|
||||
```
|
||||
|
||||
### MonitoringAugmentation
|
||||
|
|
@ -403,7 +403,7 @@ brain.disableAugmentation('cache')
|
|||
### Performance issues?
|
||||
```typescript
|
||||
// Check augmentation overhead
|
||||
const stats = brain.getStatistics()
|
||||
const stats = brain.getStats()
|
||||
console.log(stats.augmentations)
|
||||
|
||||
// Disable non-critical augmentations
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export class MyFirstAugmentation extends BaseAugmentation {
|
|||
if (operation === 'add') {
|
||||
console.log('Noun added:', params.noun)
|
||||
// You can access the brain instance
|
||||
const stats = await context?.brain.getStatistics()
|
||||
const stats = await context?.brain.getStats()
|
||||
console.log('Total nouns:', stats.totalNouns)
|
||||
}
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ class ContextAwareAugmentation extends BaseAugmentation {
|
|||
if (!brain) return
|
||||
|
||||
// Use any brain method
|
||||
const stats = await brain.getStatistics()
|
||||
const stats = await brain.getStats()
|
||||
const size = await brain.size()
|
||||
const results = await brain.search('query')
|
||||
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ const cacheConfig = {
|
|||
## 📊 Comprehensive Statistics
|
||||
|
||||
```typescript
|
||||
const stats = await brain.getStatistics()
|
||||
const stats = await brain.getStats()
|
||||
// Returns detailed metrics:
|
||||
{
|
||||
nouns: {
|
||||
|
|
|
|||
|
|
@ -218,10 +218,10 @@ const results = await brain.import(problematicData)
|
|||
|
||||
## Performance
|
||||
|
||||
- **Parallel processing** - Fast imports
|
||||
- **Batch operations** - Memory efficient
|
||||
- **Lazy loading** - ImportManager loads only when needed
|
||||
- **Smart caching** - Type detection results are cached
|
||||
- **Parallel processing** - Fast imports with concurrent operations
|
||||
- **Batch operations** - Memory efficient chunk processing
|
||||
- **Lazy loading** - Import system loads only when needed
|
||||
- **Smart caching** - Type detection and format parsing results cached
|
||||
|
||||
## Use Cases
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ const brain = new Brainy({
|
|||
|
||||
1. **Check if data exists**
|
||||
```typescript
|
||||
const stats = await brain.getStatistics()
|
||||
const stats = await brain.getStats()
|
||||
console.log(`Total items: ${stats.nounCount}`)
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue