Consolidate @shieldai/db and @shieldsai/shared-db packages (FRE-4603)
- Merged singleton pattern + type exports from shared-db - Kept FieldEncryptionService from original db package - Upgraded to Prisma v6.2.0 (newer version) - Adopted shared-db's complete schema for multi-service platform - Updated 17 consumer imports across darkwatch, voiceprint, jobs, api - Standardized on @shieldai/db namespace Files changed: - packages/db/package.json (v0.1.0 → v0.2.0) - packages/db/src/index.ts (consolidated exports) - packages/db/prisma/schema.prisma (merged schema) - packages/db/prisma/seed.ts (updated for new schema) - 17 consumer files updated Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,7 +1,71 @@
|
||||
// ============================================
|
||||
// Consolidated @shieldai/db package
|
||||
// ============================================
|
||||
// Merges functionality from:
|
||||
// - @shieldai/db (Prisma v6.2.0, FieldEncryptionService)
|
||||
// - @shieldsai/shared-db (singleton pattern, type exports)
|
||||
// ============================================
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { FieldEncryptionService } from './services/field-encryption.service';
|
||||
|
||||
export const prisma = new PrismaClient();
|
||||
// ============================================
|
||||
// Singleton Pattern (from shared-db)
|
||||
// ============================================
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined;
|
||||
};
|
||||
|
||||
export const prisma =
|
||||
globalForPrisma.prisma ??
|
||||
new PrismaClient({
|
||||
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
globalForPrisma.prisma = prisma;
|
||||
}
|
||||
|
||||
export default prisma;
|
||||
|
||||
// ============================================
|
||||
// Services (from @shieldai/db)
|
||||
// ============================================
|
||||
export { FieldEncryptionService };
|
||||
|
||||
// ============================================
|
||||
// Type Exports (from shared-db)
|
||||
// ============================================
|
||||
export type {
|
||||
User,
|
||||
Account,
|
||||
Session,
|
||||
FamilyGroup,
|
||||
FamilyGroupMember,
|
||||
Subscription,
|
||||
WatchlistItem,
|
||||
Exposure,
|
||||
Alert,
|
||||
VoiceEnrollment,
|
||||
VoiceAnalysis,
|
||||
SpamFeedback,
|
||||
SpamRule,
|
||||
AuditLog,
|
||||
KPISnapshot,
|
||||
UserRole,
|
||||
FamilyMemberRole,
|
||||
SubscriptionTier,
|
||||
SubscriptionStatus,
|
||||
WatchlistType,
|
||||
ExposureSource,
|
||||
ExposureSeverity,
|
||||
AlertType,
|
||||
AlertSeverity,
|
||||
AlertChannel,
|
||||
FeedbackType,
|
||||
RuleType,
|
||||
RuleAction,
|
||||
} from '@prisma/client';
|
||||
|
||||
export * as PrismaModels from '@prisma/client';
|
||||
export type { PrismaClient };
|
||||
|
||||
Reference in New Issue
Block a user