feat: enhance framework integration and simplify codebase

- Simplify universal modules to be more framework-friendly
- Add comprehensive framework integration documentation (Next.js, Vue, React)
- Implement missing relateMany() batch relationship creation method
- Clean up obsolete test files and improve test coverage
- Reduce browser polyfill complexity while maintaining compatibility
- Remove unused browserFramework entry points for cleaner API surface

📄 3,120 lines added, 3,679 lines removed for net simplification
This commit is contained in:
David Snelling 2025-09-15 14:53:59 -07:00
parent 203ddaccf6
commit 8d5b4cd263
18 changed files with 3120 additions and 3679 deletions

View file

@ -34,6 +34,7 @@ import {
GetRelationsParams,
AddManyParams,
DeleteManyParams,
RelateManyParams,
BatchResult,
BrainyConfig
} from './types/brainy.types.js'
@ -833,6 +834,74 @@ export class Brainy<T = any> {
return result
}
/**
* Create multiple relationships with batch processing
*/
async relateMany(params: RelateManyParams<T>): Promise<string[]> {
await this.ensureInitialized()
const result: BatchResult<string> = {
successful: [],
failed: [],
total: params.items.length,
duration: 0
}
const startTime = Date.now()
const chunkSize = params.chunkSize || 100
for (let i = 0; i < params.items.length; i += chunkSize) {
const chunk = params.items.slice(i, i + chunkSize)
if (params.parallel) {
// Process chunk in parallel
const promises = chunk.map(async (item) => {
try {
const relationId = await this.relate(item)
result.successful.push(relationId)
} catch (error: any) {
result.failed.push({
item,
error: error.message || 'Unknown error'
})
if (!params.continueOnError) {
throw error
}
}
})
await Promise.all(promises)
} else {
// Process chunk sequentially
for (const item of chunk) {
try {
const relationId = await this.relate(item)
result.successful.push(relationId)
} catch (error: any) {
result.failed.push({
item,
error: error.message || 'Unknown error'
})
if (!params.continueOnError) {
throw error
}
}
}
}
// Report progress
if (params.onProgress) {
params.onProgress(
result.successful.length + result.failed.length,
result.total
)
}
}
result.duration = Date.now() - startTime
return result.successful
}
/**
* Clear all data from the database
*/