fix: resolve getRelations() empty array bug and add string ID shorthand

**Problem**: brain.getRelations() returned empty array when called without
parameters, making 524 imported relationships inaccessible for Workshop team.

**Root Cause**: Method only queried storage when `from` or `to` parameters
were provided. Without params, it returned empty array.

**Solution**:
- Add support for "get all" via storage.getVerbs() when no from/to provided
- Add string ID shorthand: getRelations(id) → getRelations({ from: id })
- Default limit: 100 (matching storage layer pattern)
- Production safety: warn for >10k queries without filters
- Fix broken improvedNeuralAPI.ts calls (getVerbsForNoun → getRelations)
- Fix property bugs: verb.target → verb.to, verb.verb → verb.type

**Testing**:
- 14 new integration tests covering all query patterns
- All critical tests passing (25/25)
- Backward compatible - no breaking changes

**Impact**: Resolves Workshop bug where imported relationships were invisible
This commit is contained in:
David Snelling 2025-10-21 13:10:34 -07:00
parent 0a9d7ffa65
commit 8d217f3b84
5 changed files with 605 additions and 28 deletions

View file

@ -2,6 +2,23 @@
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.1.3](https://github.com/soulcraftlabs/brainy/compare/v4.1.2...v4.1.3) (2025-10-21)
### 🐛 Bug Fixes
* **api**: fix getRelations() returning empty array when called without parameters
- Fixed critical bug where `brain.getRelations()` returned `[]` instead of all relationships
- Added support for retrieving all relationships with pagination (default limit: 100)
- Added string ID shorthand syntax: `brain.getRelations(entityId)` as alias for `brain.getRelations({ from: entityId })`
- Production safety: Warns when fetching >10k relationships without filters
- Fixed broken method calls in improvedNeuralAPI.ts (replaced non-existent `getVerbsForNoun` with `getRelations`)
- Fixed property access bugs: `verb.target``verb.to`, `verb.verb``verb.type`
- Added comprehensive integration tests (14 tests covering all query patterns)
- Updated JSDoc documentation with usage examples
- **Impact**: Resolves Workshop team bug where 524 imported relationships were inaccessible
- **Breaking**: None - fully backward compatible
### [4.1.2](https://github.com/soulcraftlabs/brainy/compare/v4.1.1...v4.1.2) (2025-10-21)