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

@ -3,7 +3,7 @@
*
* Comprehensive testing of batch operations including:
* - addMany: Bulk entity creation
* - deleteMany: Bulk deletion
* - removeMany: Bulk deletion
* - Performance validation at scale
* - Memory efficiency testing
* - Error recovery scenarios
@ -353,7 +353,7 @@ describe('Batch Operations - Public API Testing', () => {
})
})
describe('deleteMany - Bulk Deletion', () => {
describe('removeMany - Bulk Deletion', () => {
let testIds: string[] = []
beforeEach(async () => {
@ -374,14 +374,14 @@ describe('Batch Operations - Public API Testing', () => {
const startMemory = process.memoryUsage().heapUsed
const startTime = performance.now()
// Use deleteMany if available, otherwise individual deletes
// Use removeMany if available, otherwise individual deletes
let results: any[]
if ('deleteMany' in brainy && typeof brainy.deleteMany === 'function') {
const result = await brainy.deleteMany({ ids: toDelete })
if ('removeMany' in brainy && typeof brainy.removeMany === 'function') {
const result = await brainy.removeMany({ ids: toDelete })
results = result.successful
} else {
results = await Promise.all(
toDelete.map(id => brainy.delete(id))
toDelete.map(id => brainy.remove(id))
)
}
@ -389,7 +389,7 @@ describe('Batch Operations - Public API Testing', () => {
const memoryUsed = process.memoryUsage().heapUsed - startMemory
metricsCollector.recordBatch(
'deleteMany-100',
'removeMany-100',
toDelete.length,
results,
duration,
@ -426,13 +426,13 @@ describe('Batch Operations - Public API Testing', () => {
const batchSize = 100
for (let i = 0; i < idsToDelete.length; i += batchSize) {
const batch = idsToDelete.slice(i, i + batchSize)
await Promise.all(batch.map(id => brainy.delete(id)))
await Promise.all(batch.map(id => brainy.remove(id)))
}
const duration = performance.now() - startTime
metricsCollector.recordBatch(
'deleteMany-1k',
'removeMany-1k',
idsToDelete.length,
idsToDelete.map(() => true),
duration,
@ -553,7 +553,7 @@ describe('Batch Operations - Public API Testing', () => {
Promise.all(updateIds.map(id =>
brainy.update({ id, metadata: { updated: true } })
)),
Promise.all(deleteIds.map(id => brainy.delete(id)))
Promise.all(deleteIds.map(id => brainy.remove(id)))
])
const duration = performance.now() - startTime

View file

@ -309,7 +309,7 @@ describe('Enhanced CRUD Operations - Public API Validation', () => {
// Delete all entities
for (const id of ids) {
await brainy.delete(id)
await brainy.remove(id)
}
if (global.gc) global.gc()
@ -612,7 +612,7 @@ describe('Enhanced CRUD Operations - Public API Validation', () => {
})
const startTime = metricsCollector.startOperation('delete-single')
const result = await brainy.delete(id)
const result = await brainy.remove(id)
metricsCollector.endOperation('delete-single', 1, startTime)
expect(result).toBe(true)
@ -633,7 +633,7 @@ describe('Enhanced CRUD Operations - Public API Validation', () => {
const startTime = metricsCollector.startOperation('delete-bulk', ids.length)
const results = await Promise.all(
ids.map(id => brainy.delete(id))
ids.map(id => brainy.remove(id))
)
metricsCollector.endOperation('delete-bulk', ids.length, startTime)

View file

@ -174,7 +174,7 @@ describe('Error Handling and Recovery', () => {
it('should handle deletion of non-existent entities', async () => {
// Should not throw, just return void
await expect(
brainy.delete('non-existent-id')
brainy.remove('non-existent-id')
).resolves.toBeUndefined()
})
@ -184,9 +184,9 @@ describe('Error Handling and Recovery', () => {
type: 'document'
})
await brainy.delete(id)
await brainy.remove(id)
// Second delete should not throw
await expect(brainy.delete(id)).resolves.toBeUndefined()
await expect(brainy.remove(id)).resolves.toBeUndefined()
})
})
@ -364,7 +364,7 @@ describe('Error Handling and Recovery', () => {
})
// Attempt concurrent deletes
const deletes = Array(5).fill(null).map(() => brainy.delete(id))
const deletes = Array(5).fill(null).map(() => brainy.remove(id))
// Should not throw
await expect(Promise.all(deletes)).resolves.toBeDefined()
@ -428,7 +428,7 @@ describe('Error Handling and Recovery', () => {
)
break
case 3:
promises.push(brainy.delete(`rapid-${i}`).catch(() => null))
promises.push(brainy.remove(`rapid-${i}`).catch(() => null))
break
}
}
@ -578,7 +578,7 @@ describe('Error Handling and Recovery', () => {
type: 'document'
})
await brainy.delete(id)
await brainy.remove(id)
// Operations on deleted entity should handle gracefully
const getResult = await brainy.get(id)
@ -592,7 +592,7 @@ describe('Error Handling and Recovery', () => {
).rejects.toThrow(/not found/i)
// Should not throw for delete
await expect(brainy.delete(id)).resolves.toBeUndefined()
await expect(brainy.remove(id)).resolves.toBeUndefined()
})
it('should handle rapid create-delete cycles', async () => {
@ -605,7 +605,7 @@ describe('Error Handling and Recovery', () => {
})
// Immediately delete
await brainy.delete(id)
await brainy.remove(id)
// Verify it's gone
const result = await brainy.get(id)

View file

@ -231,7 +231,7 @@ describe('Performance Benchmarks - SLA Validation', () => {
for (const id of ids) {
const start = performance.now()
await brainy.delete(id)
await brainy.remove(id)
const latency = performance.now() - start
benchmark.recordOperation(latency)
}
@ -419,7 +419,7 @@ describe('Performance Benchmarks - SLA Validation', () => {
}
for (const id of ids) {
await brainy.delete(id)
await brainy.remove(id)
}
if (global.gc) global.gc()