chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase

This commit is contained in:
David Snelling 2026-06-11 14:51:00 -07:00
parent 970e08c466
commit 1f7e365a4e
237 changed files with 1951 additions and 49413 deletions

View file

@ -61,7 +61,7 @@ describe('Brainy.relate()', () => {
expect(typeof relationId).toBe('string')
// Verify relationship exists
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
expect(relations.length).toBeGreaterThan(0)
expect(relations.some(r => r.to === entity2Id)).toBe(true)
})
@ -76,7 +76,7 @@ describe('Brainy.relate()', () => {
})
// Assert
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
const relation = relations.find(r => r.to === entity2Id)
expect(relation).toBeDefined()
expect(relation!.weight).toBe(0.8)
@ -99,7 +99,7 @@ describe('Brainy.relate()', () => {
})
// Assert
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
const relation = relations.find(r => r.to === entity2Id)
expect(relation).toBeDefined()
expect(relation!.metadata || {}).toMatchObject(metadata)
@ -115,8 +115,8 @@ describe('Brainy.relate()', () => {
})
// Assert - Check both directions
const forwardRelations = await brain.getRelations({ from: entity1Id })
const reverseRelations = await brain.getRelations({ from: entity2Id })
const forwardRelations = await brain.related({ from: entity1Id })
const reverseRelations = await brain.related({ from: entity2Id })
expect(forwardRelations.some(r => r.to === entity2Id)).toBe(true)
expect(reverseRelations.some(r => r.to === entity1Id)).toBe(true)
@ -137,7 +137,7 @@ describe('Brainy.relate()', () => {
})
// Assert
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
expect(relations.length).toBe(2)
expect(relations.some(r => r.to === entity2Id)).toBe(true)
expect(relations.some(r => r.to === entity3Id)).toBe(true)
@ -158,7 +158,7 @@ describe('Brainy.relate()', () => {
})
// Assert
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
const toEntity2 = relations.filter(r => r.to === entity2Id)
expect(toEntity2.length).toBe(2)
expect(toEntity2.some(r => r.type === 'worksWith')).toBe(true)
@ -175,7 +175,7 @@ describe('Brainy.relate()', () => {
})
// Assert
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
const selfRelation = relations.find(r => r.to === entity1Id)
expect(selfRelation).toBeDefined()
expect(selfRelation!.metadata?.type).toBe('self-reference')
@ -241,7 +241,7 @@ describe('Brainy.relate()', () => {
// Second call should return existing relationship ID instead of creating duplicate
expect(id1).toBe(id2)
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
const matches = relations.filter(r =>
r.to === entity2Id && r.type === 'worksWith'
)
@ -267,7 +267,7 @@ describe('Brainy.relate()', () => {
})
// Assert
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
const relation = relations.find(r => r.to === entity2Id)
expect(relation).toBeDefined()
expect(relation!.metadata?.bigArray).toHaveLength(100)
@ -291,7 +291,7 @@ describe('Brainy.relate()', () => {
})
// Assert
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
const relation = relations.find(r => r.to === entity2Id)
expect(relation!.metadata || {}).toMatchObject(specialMetadata)
})
@ -356,8 +356,8 @@ describe('Brainy.relate()', () => {
})
// Assert - Multiple queries should return same data
const relations1 = await brain.getRelations({ from: entity1Id })
const relations2 = await brain.getRelations({ from: entity1Id })
const relations1 = await brain.related({ from: entity1Id })
const relations2 = await brain.related({ from: entity1Id })
expect(relations1.length).toBe(relations2.length)
const rel1 = relations1.find(r => r.to === entity2Id)
@ -386,7 +386,7 @@ describe('Brainy.relate()', () => {
})
// Assert - Relationship should still exist
const relations = await brain.getRelations({ from: entity1Id })
const relations = await brain.related({ from: entity1Id })
expect(relations.some(r => r.to === entity2Id)).toBe(true)
})
})
@ -407,8 +407,8 @@ describe('Brainy.relate()', () => {
})
// Act - Get relationships step by step
const step1 = await brain.getRelations({ from: entity1Id })
const entity2Relations = await brain.getRelations({ from: entity2Id })
const step1 = await brain.related({ from: entity1Id })
const entity2Relations = await brain.related({ from: entity2Id })
// Assert
expect(step1.some(r => r.to === entity2Id)).toBe(true)
@ -436,9 +436,9 @@ describe('Brainy.relate()', () => {
})
// Assert - All relationships should exist
const rel1 = await brain.getRelations({ from: entity1Id })
const rel2 = await brain.getRelations({ from: entity2Id })
const rel3 = await brain.getRelations({ from: entity3Id })
const rel1 = await brain.related({ from: entity1Id })
const rel2 = await brain.related({ from: entity2Id })
const rel3 = await brain.related({ from: entity3Id })
expect(rel1.some(r => r.to === entity2Id)).toBe(true)
expect(rel2.some(r => r.to === entity3Id)).toBe(true)