@soulcraft/brainy 4.1.3 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -7
- package/dist/brainy.d.ts +74 -16
- package/dist/brainy.js +74 -16
- package/dist/import/ImportCoordinator.d.ts +53 -1
- package/dist/import/ImportCoordinator.js +98 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [4.1.4](https://github.com/soulcraftlabs/brainy/compare/v4.1.3...v4.1.4) (2025-10-21)
|
|
6
|
+
|
|
7
|
+
- feat: add import API validation and v4.x migration guide (a1a0576)
|
|
8
|
+
|
|
9
|
+
|
|
5
10
|
### [4.1.3](https://github.com/soulcraftlabs/brainy/compare/v4.1.2...v4.1.3) (2025-10-21)
|
|
6
11
|
|
|
7
12
|
- perf: make getRelations() pagination consistent and efficient (54d819c)
|
|
@@ -223,22 +228,110 @@ $ brainy import ./research-papers --extract-concepts --progress
|
|
|
223
228
|
|
|
224
229
|
### ⚠️ Breaking Changes
|
|
225
230
|
|
|
226
|
-
|
|
231
|
+
#### 💥 Import API Redesign
|
|
232
|
+
|
|
233
|
+
The import API has been redesigned for clarity and better feature control. **Old v3.x option names are no longer recognized** and will throw errors.
|
|
234
|
+
|
|
235
|
+
**What Changed:**
|
|
236
|
+
|
|
237
|
+
| v3.x Option | v4.x Option | Action Required |
|
|
238
|
+
|-------------|-------------|-----------------|
|
|
239
|
+
| `extractRelationships` | `enableRelationshipInference` | **Rename option** |
|
|
240
|
+
| `autoDetect` | *(removed)* | **Delete option** (always enabled) |
|
|
241
|
+
| `createFileStructure` | `vfsPath` | **Replace** with VFS path |
|
|
242
|
+
| `excelSheets` | *(removed)* | **Delete option** (all sheets processed) |
|
|
243
|
+
| `pdfExtractTables` | *(removed)* | **Delete option** (always enabled) |
|
|
244
|
+
| - | `enableNeuralExtraction` | **Add option** (new in v4.x) |
|
|
245
|
+
| - | `enableConceptExtraction` | **Add option** (new in v4.x) |
|
|
246
|
+
| - | `preserveSource` | **Add option** (new in v4.x) |
|
|
247
|
+
|
|
248
|
+
**Why These Changes?**
|
|
249
|
+
|
|
250
|
+
1. **Clearer option names**: `enableRelationshipInference` explicitly indicates AI-powered relationship inference
|
|
251
|
+
2. **Separation of concerns**: Neural extraction, relationship inference, and VFS are now separate, explicit options
|
|
252
|
+
3. **Better defaults**: Auto-detection and AI features are enabled by default
|
|
253
|
+
4. **Reduced confusion**: Removed redundant options like `autoDetect` and format-specific options
|
|
254
|
+
|
|
255
|
+
**Migration Examples:**
|
|
256
|
+
|
|
257
|
+
<details>
|
|
258
|
+
<summary>Example 1: Basic Excel Import</summary>
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// v3.x (OLD - Will throw error)
|
|
262
|
+
await brain.import('./glossary.xlsx', {
|
|
263
|
+
extractRelationships: true,
|
|
264
|
+
createFileStructure: true
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
// v4.x (NEW - Use this)
|
|
268
|
+
await brain.import('./glossary.xlsx', {
|
|
269
|
+
enableRelationshipInference: true,
|
|
270
|
+
vfsPath: '/imports/glossary'
|
|
271
|
+
})
|
|
272
|
+
```
|
|
273
|
+
</details>
|
|
274
|
+
|
|
275
|
+
<details>
|
|
276
|
+
<summary>Example 2: Full-Featured Import</summary>
|
|
227
277
|
|
|
228
|
-
|
|
278
|
+
```typescript
|
|
279
|
+
// v3.x (OLD - Will throw error)
|
|
280
|
+
await brain.import('./data.xlsx', {
|
|
281
|
+
extractRelationships: true,
|
|
282
|
+
autoDetect: true,
|
|
283
|
+
createFileStructure: true
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
// v4.x (NEW - Use this)
|
|
287
|
+
await brain.import('./data.xlsx', {
|
|
288
|
+
enableNeuralExtraction: true, // Extract entity names
|
|
289
|
+
enableRelationshipInference: true, // Infer semantic relationships
|
|
290
|
+
enableConceptExtraction: true, // Extract entity types
|
|
291
|
+
vfsPath: '/imports/data', // VFS directory
|
|
292
|
+
preserveSource: true // Save original file
|
|
293
|
+
})
|
|
294
|
+
```
|
|
295
|
+
</details>
|
|
296
|
+
|
|
297
|
+
**Error Messages:**
|
|
298
|
+
|
|
299
|
+
If you use old v3.x options, you'll get a clear error message:
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
❌ Invalid import options detected (Brainy v4.x breaking changes)
|
|
303
|
+
|
|
304
|
+
The following v3.x options are no longer supported:
|
|
305
|
+
|
|
306
|
+
❌ extractRelationships
|
|
307
|
+
→ Use: enableRelationshipInference
|
|
308
|
+
→ Why: Option renamed for clarity in v4.x
|
|
309
|
+
|
|
310
|
+
📖 Migration Guide: https://brainy.dev/docs/guides/migrating-to-v4
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Other v4.0.0 Features (Non-Breaking):**
|
|
314
|
+
|
|
315
|
+
All other v4.0.0 features are:
|
|
229
316
|
- ✅ Opt-in (lifecycle, compression, batch operations)
|
|
230
317
|
- ✅ Additive (new CLI commands, new methods)
|
|
231
318
|
- ✅ Non-breaking (existing code continues to work)
|
|
232
319
|
|
|
233
320
|
### 📝 Migration
|
|
234
321
|
|
|
235
|
-
**
|
|
322
|
+
**Import API migration required** if you use `brain.import()` with the old v3.x option names.
|
|
236
323
|
|
|
237
|
-
|
|
324
|
+
#### Required Changes:
|
|
238
325
|
1. Update to v4.0.0: `npm install @soulcraft/brainy@4.0.0`
|
|
239
|
-
2.
|
|
240
|
-
3.
|
|
241
|
-
|
|
326
|
+
2. Update import calls to use new option names (see table above)
|
|
327
|
+
3. Test your imports - you'll get clear error messages if you use old options
|
|
328
|
+
|
|
329
|
+
#### Optional Enhancements:
|
|
330
|
+
- Enable lifecycle policies: `brainy storage lifecycle set`
|
|
331
|
+
- Use batch operations: `brainy storage batch-delete entities.txt`
|
|
332
|
+
- See full migration guide: `docs/guides/migrating-to-v4.md`
|
|
333
|
+
|
|
334
|
+
**Complete Migration Guide:** [docs/guides/migrating-to-v4.md](./docs/guides/migrating-to-v4.md)
|
|
242
335
|
|
|
243
336
|
### 🎓 What This Means
|
|
244
337
|
|
package/dist/brainy.d.ts
CHANGED
|
@@ -686,33 +686,91 @@ export declare class Brainy<T = any> implements BrainyInterface<T> {
|
|
|
686
686
|
limit?: number;
|
|
687
687
|
}): Promise<string[]>;
|
|
688
688
|
/**
|
|
689
|
-
* Import files with
|
|
689
|
+
* Import files with intelligent extraction and dual storage (VFS + Knowledge Graph)
|
|
690
690
|
*
|
|
691
691
|
* Unified import system that:
|
|
692
692
|
* - Auto-detects format (Excel, PDF, CSV, JSON, Markdown)
|
|
693
|
-
* - Extracts entities
|
|
693
|
+
* - Extracts entities with AI-powered name/type detection
|
|
694
|
+
* - Infers semantic relationships from context
|
|
694
695
|
* - Stores in both VFS (organized files) and Knowledge Graph (connected entities)
|
|
695
696
|
* - Links VFS files to graph entities
|
|
696
697
|
*
|
|
697
|
-
* @
|
|
698
|
-
* // Import from file path
|
|
699
|
-
* const result = await brain.import('/path/to/file.xlsx')
|
|
698
|
+
* @since 4.0.0
|
|
700
699
|
*
|
|
701
|
-
* @example
|
|
702
|
-
*
|
|
700
|
+
* @example Quick Start (All AI features enabled by default)
|
|
701
|
+
* ```typescript
|
|
702
|
+
* const result = await brain.import('./glossary.xlsx')
|
|
703
|
+
* // Auto-detects format, extracts entities, infers relationships
|
|
704
|
+
* ```
|
|
705
|
+
*
|
|
706
|
+
* @example Full-Featured Import (v4.x)
|
|
707
|
+
* ```typescript
|
|
708
|
+
* const result = await brain.import('./data.xlsx', {
|
|
709
|
+
* // AI features
|
|
710
|
+
* enableNeuralExtraction: true, // Extract entity names/metadata
|
|
711
|
+
* enableRelationshipInference: true, // Detect semantic relationships
|
|
712
|
+
* enableConceptExtraction: true, // Extract types/concepts
|
|
713
|
+
*
|
|
714
|
+
* // VFS features
|
|
715
|
+
* vfsPath: '/imports/my-data', // Store in VFS directory
|
|
716
|
+
* groupBy: 'type', // Organize by entity type
|
|
717
|
+
* preserveSource: true, // Keep original file
|
|
718
|
+
*
|
|
719
|
+
* // Progress tracking
|
|
720
|
+
* onProgress: (p) => console.log(p.message)
|
|
721
|
+
* })
|
|
722
|
+
* ```
|
|
723
|
+
*
|
|
724
|
+
* @example Performance Tuning (Large Files)
|
|
725
|
+
* ```typescript
|
|
726
|
+
* const result = await brain.import('./huge-file.csv', {
|
|
727
|
+
* enableDeduplication: false, // Skip dedup for speed
|
|
728
|
+
* confidenceThreshold: 0.8, // Higher threshold = fewer entities
|
|
729
|
+
* onProgress: (p) => console.log(`${p.processed}/${p.total}`)
|
|
730
|
+
* })
|
|
731
|
+
* ```
|
|
732
|
+
*
|
|
733
|
+
* @example Import from Buffer or Object
|
|
734
|
+
* ```typescript
|
|
735
|
+
* // From buffer
|
|
703
736
|
* const result = await brain.import(buffer, { format: 'pdf' })
|
|
704
737
|
*
|
|
705
|
-
*
|
|
706
|
-
* // Import JSON object
|
|
738
|
+
* // From object
|
|
707
739
|
* const result = await brain.import({ entities: [...] })
|
|
740
|
+
* ```
|
|
708
741
|
*
|
|
709
|
-
* @
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
742
|
+
* @throws {Error} If invalid options are provided (v4.x breaking changes)
|
|
743
|
+
*
|
|
744
|
+
* @see {@link https://brainy.dev/docs/api/import API Documentation}
|
|
745
|
+
* @see {@link https://brainy.dev/docs/guides/migrating-to-v4 Migration Guide}
|
|
746
|
+
*
|
|
747
|
+
* @remarks
|
|
748
|
+
* **⚠️ Breaking Changes from v3.x:**
|
|
749
|
+
*
|
|
750
|
+
* The import API was redesigned in v4.0.0 for clarity and better feature control.
|
|
751
|
+
* Old v3.x option names are **no longer recognized** and will throw errors.
|
|
752
|
+
*
|
|
753
|
+
* **Option Changes:**
|
|
754
|
+
* - ❌ `extractRelationships` → ✅ `enableRelationshipInference`
|
|
755
|
+
* - ❌ `createFileStructure` → ✅ `vfsPath: '/your/path'`
|
|
756
|
+
* - ❌ `autoDetect` → ✅ *(removed - always enabled)*
|
|
757
|
+
* - ❌ `excelSheets` → ✅ *(removed - all sheets processed)*
|
|
758
|
+
* - ❌ `pdfExtractTables` → ✅ *(removed - always enabled)*
|
|
759
|
+
*
|
|
760
|
+
* **New Options:**
|
|
761
|
+
* - ✅ `enableNeuralExtraction` - Extract entity names via AI
|
|
762
|
+
* - ✅ `enableConceptExtraction` - Extract entity types via AI
|
|
763
|
+
* - ✅ `preserveSource` - Save original file in VFS
|
|
764
|
+
*
|
|
765
|
+
* **If you get an error:**
|
|
766
|
+
* The error message includes migration instructions and examples.
|
|
767
|
+
* See the complete migration guide for all details.
|
|
768
|
+
*
|
|
769
|
+
* **Why these changes?**
|
|
770
|
+
* - Clearer option names (explicitly describe what they do)
|
|
771
|
+
* - Separation of concerns (neural, relationships, VFS are separate)
|
|
772
|
+
* - Better defaults (AI features enabled by default)
|
|
773
|
+
* - Reduced confusion (removed redundant options)
|
|
716
774
|
*/
|
|
717
775
|
import(source: Buffer | string | object, options?: {
|
|
718
776
|
format?: 'excel' | 'pdf' | 'csv' | 'json' | 'markdown';
|
package/dist/brainy.js
CHANGED
|
@@ -1593,33 +1593,91 @@ export class Brainy {
|
|
|
1593
1593
|
return options?.limit ? concepts.slice(0, options.limit) : concepts;
|
|
1594
1594
|
}
|
|
1595
1595
|
/**
|
|
1596
|
-
* Import files with
|
|
1596
|
+
* Import files with intelligent extraction and dual storage (VFS + Knowledge Graph)
|
|
1597
1597
|
*
|
|
1598
1598
|
* Unified import system that:
|
|
1599
1599
|
* - Auto-detects format (Excel, PDF, CSV, JSON, Markdown)
|
|
1600
|
-
* - Extracts entities
|
|
1600
|
+
* - Extracts entities with AI-powered name/type detection
|
|
1601
|
+
* - Infers semantic relationships from context
|
|
1601
1602
|
* - Stores in both VFS (organized files) and Knowledge Graph (connected entities)
|
|
1602
1603
|
* - Links VFS files to graph entities
|
|
1603
1604
|
*
|
|
1604
|
-
* @
|
|
1605
|
-
* // Import from file path
|
|
1606
|
-
* const result = await brain.import('/path/to/file.xlsx')
|
|
1605
|
+
* @since 4.0.0
|
|
1607
1606
|
*
|
|
1608
|
-
* @example
|
|
1609
|
-
*
|
|
1607
|
+
* @example Quick Start (All AI features enabled by default)
|
|
1608
|
+
* ```typescript
|
|
1609
|
+
* const result = await brain.import('./glossary.xlsx')
|
|
1610
|
+
* // Auto-detects format, extracts entities, infers relationships
|
|
1611
|
+
* ```
|
|
1612
|
+
*
|
|
1613
|
+
* @example Full-Featured Import (v4.x)
|
|
1614
|
+
* ```typescript
|
|
1615
|
+
* const result = await brain.import('./data.xlsx', {
|
|
1616
|
+
* // AI features
|
|
1617
|
+
* enableNeuralExtraction: true, // Extract entity names/metadata
|
|
1618
|
+
* enableRelationshipInference: true, // Detect semantic relationships
|
|
1619
|
+
* enableConceptExtraction: true, // Extract types/concepts
|
|
1620
|
+
*
|
|
1621
|
+
* // VFS features
|
|
1622
|
+
* vfsPath: '/imports/my-data', // Store in VFS directory
|
|
1623
|
+
* groupBy: 'type', // Organize by entity type
|
|
1624
|
+
* preserveSource: true, // Keep original file
|
|
1625
|
+
*
|
|
1626
|
+
* // Progress tracking
|
|
1627
|
+
* onProgress: (p) => console.log(p.message)
|
|
1628
|
+
* })
|
|
1629
|
+
* ```
|
|
1630
|
+
*
|
|
1631
|
+
* @example Performance Tuning (Large Files)
|
|
1632
|
+
* ```typescript
|
|
1633
|
+
* const result = await brain.import('./huge-file.csv', {
|
|
1634
|
+
* enableDeduplication: false, // Skip dedup for speed
|
|
1635
|
+
* confidenceThreshold: 0.8, // Higher threshold = fewer entities
|
|
1636
|
+
* onProgress: (p) => console.log(`${p.processed}/${p.total}`)
|
|
1637
|
+
* })
|
|
1638
|
+
* ```
|
|
1639
|
+
*
|
|
1640
|
+
* @example Import from Buffer or Object
|
|
1641
|
+
* ```typescript
|
|
1642
|
+
* // From buffer
|
|
1610
1643
|
* const result = await brain.import(buffer, { format: 'pdf' })
|
|
1611
1644
|
*
|
|
1612
|
-
*
|
|
1613
|
-
* // Import JSON object
|
|
1645
|
+
* // From object
|
|
1614
1646
|
* const result = await brain.import({ entities: [...] })
|
|
1647
|
+
* ```
|
|
1615
1648
|
*
|
|
1616
|
-
* @
|
|
1617
|
-
*
|
|
1618
|
-
*
|
|
1619
|
-
*
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1622
|
-
*
|
|
1649
|
+
* @throws {Error} If invalid options are provided (v4.x breaking changes)
|
|
1650
|
+
*
|
|
1651
|
+
* @see {@link https://brainy.dev/docs/api/import API Documentation}
|
|
1652
|
+
* @see {@link https://brainy.dev/docs/guides/migrating-to-v4 Migration Guide}
|
|
1653
|
+
*
|
|
1654
|
+
* @remarks
|
|
1655
|
+
* **⚠️ Breaking Changes from v3.x:**
|
|
1656
|
+
*
|
|
1657
|
+
* The import API was redesigned in v4.0.0 for clarity and better feature control.
|
|
1658
|
+
* Old v3.x option names are **no longer recognized** and will throw errors.
|
|
1659
|
+
*
|
|
1660
|
+
* **Option Changes:**
|
|
1661
|
+
* - ❌ `extractRelationships` → ✅ `enableRelationshipInference`
|
|
1662
|
+
* - ❌ `createFileStructure` → ✅ `vfsPath: '/your/path'`
|
|
1663
|
+
* - ❌ `autoDetect` → ✅ *(removed - always enabled)*
|
|
1664
|
+
* - ❌ `excelSheets` → ✅ *(removed - all sheets processed)*
|
|
1665
|
+
* - ❌ `pdfExtractTables` → ✅ *(removed - always enabled)*
|
|
1666
|
+
*
|
|
1667
|
+
* **New Options:**
|
|
1668
|
+
* - ✅ `enableNeuralExtraction` - Extract entity names via AI
|
|
1669
|
+
* - ✅ `enableConceptExtraction` - Extract entity types via AI
|
|
1670
|
+
* - ✅ `preserveSource` - Save original file in VFS
|
|
1671
|
+
*
|
|
1672
|
+
* **If you get an error:**
|
|
1673
|
+
* The error message includes migration instructions and examples.
|
|
1674
|
+
* See the complete migration guide for all details.
|
|
1675
|
+
*
|
|
1676
|
+
* **Why these changes?**
|
|
1677
|
+
* - Clearer option names (explicitly describe what they do)
|
|
1678
|
+
* - Separation of concerns (neural, relationships, VFS are separate)
|
|
1679
|
+
* - Better defaults (AI features enabled by default)
|
|
1680
|
+
* - Reduced confusion (removed redundant options)
|
|
1623
1681
|
*/
|
|
1624
1682
|
async import(source, options) {
|
|
1625
1683
|
// Lazy load ImportCoordinator
|
|
@@ -21,7 +21,10 @@ export interface ImportSource {
|
|
|
21
21
|
/** Optional filename hint */
|
|
22
22
|
filename?: string;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Valid import options for v4.x
|
|
26
|
+
*/
|
|
27
|
+
export interface ValidImportOptions {
|
|
25
28
|
/** Force specific format (skip auto-detection) */
|
|
26
29
|
format?: SupportedFormat;
|
|
27
30
|
/** VFS root path for imported files */
|
|
@@ -55,6 +58,45 @@ export interface ImportOptions {
|
|
|
55
58
|
/** Progress callback */
|
|
56
59
|
onProgress?: (progress: ImportProgress) => void;
|
|
57
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Deprecated import options from v3.x
|
|
63
|
+
* Using these will cause TypeScript compile errors
|
|
64
|
+
*
|
|
65
|
+
* @deprecated These options are no longer supported in v4.x
|
|
66
|
+
* @see {@link https://brainy.dev/docs/guides/migrating-to-v4 Migration Guide}
|
|
67
|
+
*/
|
|
68
|
+
export interface DeprecatedImportOptions {
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use `enableRelationshipInference` instead
|
|
71
|
+
* @see {@link https://brainy.dev/docs/guides/migrating-to-v4 Migration Guide}
|
|
72
|
+
*/
|
|
73
|
+
extractRelationships?: never;
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Removed in v4.x - auto-detection is now always enabled
|
|
76
|
+
* @see {@link https://brainy.dev/docs/guides/migrating-to-v4 Migration Guide}
|
|
77
|
+
*/
|
|
78
|
+
autoDetect?: never;
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Use `vfsPath` to specify the directory path instead
|
|
81
|
+
* @see {@link https://brainy.dev/docs/guides/migrating-to-v4 Migration Guide}
|
|
82
|
+
*/
|
|
83
|
+
createFileStructure?: never;
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Removed in v4.x - all sheets are now processed automatically
|
|
86
|
+
* @see {@link https://brainy.dev/docs/guides/migrating-to-v4 Migration Guide}
|
|
87
|
+
*/
|
|
88
|
+
excelSheets?: never;
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Removed in v4.x - table extraction is now automatic for PDF imports
|
|
91
|
+
* @see {@link https://brainy.dev/docs/guides/migrating-to-v4 Migration Guide}
|
|
92
|
+
*/
|
|
93
|
+
pdfExtractTables?: never;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Complete import options interface
|
|
97
|
+
* Combines valid v4.x options with deprecated v3.x options (which cause TypeScript errors)
|
|
98
|
+
*/
|
|
99
|
+
export type ImportOptions = ValidImportOptions & DeprecatedImportOptions;
|
|
58
100
|
export interface ImportProgress {
|
|
59
101
|
stage: 'detecting' | 'extracting' | 'storing-vfs' | 'storing-graph' | 'relationships' | 'complete';
|
|
60
102
|
/** Phase of import - extraction or relationship building (v3.49.0) */
|
|
@@ -165,4 +207,14 @@ export declare class ImportCoordinator {
|
|
|
165
207
|
* Normalize extraction result to unified format (Excel-like structure)
|
|
166
208
|
*/
|
|
167
209
|
private normalizeExtractionResult;
|
|
210
|
+
/**
|
|
211
|
+
* Validate options and reject deprecated v3.x options (v4.0.0+)
|
|
212
|
+
* Throws clear errors with migration guidance
|
|
213
|
+
*/
|
|
214
|
+
private validateOptions;
|
|
215
|
+
/**
|
|
216
|
+
* Build detailed error message for invalid options
|
|
217
|
+
* Respects LOG_LEVEL for verbosity (detailed in dev, concise in prod)
|
|
218
|
+
*/
|
|
219
|
+
private buildValidationErrorMessage;
|
|
168
220
|
}
|
|
@@ -62,6 +62,8 @@ export class ImportCoordinator {
|
|
|
62
62
|
async import(source, options = {}) {
|
|
63
63
|
const startTime = Date.now();
|
|
64
64
|
const importId = uuidv4();
|
|
65
|
+
// Validate options (v4.0.0+: Reject deprecated v3.x options)
|
|
66
|
+
this.validateOptions(options);
|
|
65
67
|
// Normalize source
|
|
66
68
|
const normalizedSource = this.normalizeSource(source, options.format);
|
|
67
69
|
// Report detection stage
|
|
@@ -558,5 +560,101 @@ export class ImportCoordinator {
|
|
|
558
560
|
// Fallback: return as-is
|
|
559
561
|
return result;
|
|
560
562
|
}
|
|
563
|
+
/**
|
|
564
|
+
* Validate options and reject deprecated v3.x options (v4.0.0+)
|
|
565
|
+
* Throws clear errors with migration guidance
|
|
566
|
+
*/
|
|
567
|
+
validateOptions(options) {
|
|
568
|
+
const invalidOptions = [];
|
|
569
|
+
// Check for v3.x deprecated options
|
|
570
|
+
if ('extractRelationships' in options) {
|
|
571
|
+
invalidOptions.push({
|
|
572
|
+
old: 'extractRelationships',
|
|
573
|
+
new: 'enableRelationshipInference',
|
|
574
|
+
message: 'Option renamed for clarity in v4.x - explicitly indicates AI-powered relationship inference'
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
if ('autoDetect' in options) {
|
|
578
|
+
invalidOptions.push({
|
|
579
|
+
old: 'autoDetect',
|
|
580
|
+
new: '(removed)',
|
|
581
|
+
message: 'Auto-detection is now always enabled - no need to specify this option'
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
if ('createFileStructure' in options) {
|
|
585
|
+
invalidOptions.push({
|
|
586
|
+
old: 'createFileStructure',
|
|
587
|
+
new: 'vfsPath',
|
|
588
|
+
message: 'Use vfsPath to explicitly specify the virtual filesystem directory path'
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
if ('excelSheets' in options) {
|
|
592
|
+
invalidOptions.push({
|
|
593
|
+
old: 'excelSheets',
|
|
594
|
+
new: '(removed)',
|
|
595
|
+
message: 'All sheets are now processed automatically - no configuration needed'
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
if ('pdfExtractTables' in options) {
|
|
599
|
+
invalidOptions.push({
|
|
600
|
+
old: 'pdfExtractTables',
|
|
601
|
+
new: '(removed)',
|
|
602
|
+
message: 'Table extraction is now automatic for PDF imports'
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
// If invalid options found, throw error with detailed message
|
|
606
|
+
if (invalidOptions.length > 0) {
|
|
607
|
+
const errorMessage = this.buildValidationErrorMessage(invalidOptions);
|
|
608
|
+
throw new Error(errorMessage);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Build detailed error message for invalid options
|
|
613
|
+
* Respects LOG_LEVEL for verbosity (detailed in dev, concise in prod)
|
|
614
|
+
*/
|
|
615
|
+
buildValidationErrorMessage(invalidOptions) {
|
|
616
|
+
// Check environment for verbosity level
|
|
617
|
+
const verbose = process.env.LOG_LEVEL === 'debug' ||
|
|
618
|
+
process.env.LOG_LEVEL === 'verbose' ||
|
|
619
|
+
process.env.NODE_ENV === 'development' ||
|
|
620
|
+
process.env.NODE_ENV === 'dev';
|
|
621
|
+
if (verbose) {
|
|
622
|
+
// DETAILED mode (development)
|
|
623
|
+
const optionDetails = invalidOptions
|
|
624
|
+
.map((opt) => `
|
|
625
|
+
❌ ${opt.old}
|
|
626
|
+
→ Use: ${opt.new}
|
|
627
|
+
→ Why: ${opt.message}`)
|
|
628
|
+
.join('\n');
|
|
629
|
+
return `
|
|
630
|
+
❌ Invalid import options detected (Brainy v4.x breaking changes)
|
|
631
|
+
|
|
632
|
+
The following v3.x options are no longer supported:
|
|
633
|
+
${optionDetails}
|
|
634
|
+
|
|
635
|
+
📖 Migration Guide: https://brainy.dev/docs/guides/migrating-to-v4
|
|
636
|
+
💡 Quick Fix Examples:
|
|
637
|
+
|
|
638
|
+
Before (v3.x):
|
|
639
|
+
await brain.import(file, {
|
|
640
|
+
extractRelationships: true,
|
|
641
|
+
createFileStructure: true
|
|
642
|
+
})
|
|
643
|
+
|
|
644
|
+
After (v4.x):
|
|
645
|
+
await brain.import(file, {
|
|
646
|
+
enableRelationshipInference: true,
|
|
647
|
+
vfsPath: '/imports/my-data'
|
|
648
|
+
})
|
|
649
|
+
|
|
650
|
+
🔗 Full API docs: https://brainy.dev/docs/api/import
|
|
651
|
+
`.trim();
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
// CONCISE mode (production)
|
|
655
|
+
const optionsList = invalidOptions.map((o) => `'${o.old}'`).join(', ');
|
|
656
|
+
return `Invalid import options: ${optionsList}. See https://brainy.dev/docs/guides/migrating-to-v4`;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
561
659
|
}
|
|
562
660
|
//# sourceMappingURL=ImportCoordinator.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|