Add cross-service alert correlation system FRE-4500
- Unified alert types (AlertSource, AlertCategory, CorrelationStatus, EntityType) - NormalizedAlert and CorrelationGroup Prisma models - AlertNormalizer for all 4 services (DarkWatch, SpamShield, VoicePrint, CallAnalysis) - CorrelationEngine with temporal + entity-based correlation detection - CorrelationService orchestrator with dashboard API - Correlation API routes (/api/v1/correlation/*) - Service emitters wired to DarkWatch, SpamShield, VoicePrint - pnpm workspace config for monorepo
This commit is contained in:
28
packages/integration-tests/src/fixtures/test-db.ts
Normal file
28
packages/integration-tests/src/fixtures/test-db.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { PrismaClient } from '@shieldai/db';
|
||||
|
||||
let prisma: PrismaClient | null = null;
|
||||
|
||||
export async function initializeTestDB(): Promise<PrismaClient> {
|
||||
if (!prisma) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
process.env.DATABASE_URL = process.env.DATABASE_URL || 'postgresql://test:test@localhost:5432/test';
|
||||
const db = await import('@shieldai/db');
|
||||
const PC = (db as unknown as { PrismaClient: new () => PrismaClient }).PrismaClient;
|
||||
prisma = new PC();
|
||||
}
|
||||
return prisma;
|
||||
}
|
||||
|
||||
export async function cleanupTestDB(): Promise<void> {
|
||||
if (prisma) {
|
||||
await prisma.$disconnect();
|
||||
prisma = null;
|
||||
}
|
||||
}
|
||||
|
||||
export function getTestDB(): PrismaClient {
|
||||
if (!prisma) {
|
||||
throw new Error('Test database not initialized. Call initializeTestDB() first.');
|
||||
}
|
||||
return prisma;
|
||||
}
|
||||
Reference in New Issue
Block a user