- 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
29 lines
827 B
TypeScript
29 lines
827 B
TypeScript
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;
|
|
}
|