Add Anthropic API, test environment, remove locale settings
Feature 1: Anthropic API Integration - Add @anthropic-ai/sdk with adapter wrapping OpenAI-shaped interface - Support Claude models (opus, sonnet, haiku) with extended thinking - Auto-reset model on provider switch, JSON retry logic - Add Claude model pricing to ai-usage tracker - Update AI settings form with Anthropic provider option Feature 2: Remove Locale Settings UI - Strip Localization tab from admin settings - Remove i18n settings from router inferCategory and getFeatureFlags - Keep franc document language detection intact Feature 3: Test Environment with Role Impersonation - Add isTest field to User, Program, Project, Competition models - Test environment service: create/teardown with realistic dummy data - JWT-based impersonation for test users (@test.local emails) - Impersonation banner with quick-switch between test roles - Test environment panel in admin settings (SUPER_ADMIN only) - Email redirect: @test.local emails routed to admin with [TEST] prefix - Complete data isolation: 45+ isTest:false filters across platform - All global queries on User/Project/Program/Competition - AI services blocked from processing test data - Cron jobs skip test rounds/users - Analytics/exports exclude test data - Admin layout/pickers hide test programs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
-- Add isTest field to User, Program, Project, Competition for test environment isolation
|
||||
ALTER TABLE "User" ADD COLUMN "isTest" BOOLEAN NOT NULL DEFAULT false;
|
||||
ALTER TABLE "Program" ADD COLUMN "isTest" BOOLEAN NOT NULL DEFAULT false;
|
||||
ALTER TABLE "Project" ADD COLUMN "isTest" BOOLEAN NOT NULL DEFAULT false;
|
||||
ALTER TABLE "Competition" ADD COLUMN "isTest" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- Index for efficient test data filtering
|
||||
CREATE INDEX "Competition_isTest_idx" ON "Competition"("isTest");
|
||||
|
||||
-- Add provider field to AIUsageLog for cross-provider cost tracking
|
||||
ALTER TABLE "AIUsageLog" ADD COLUMN "provider" TEXT;
|
||||
|
||||
-- Remove LOCALIZATION from SettingCategory enum
|
||||
-- First delete any rows using this category to avoid FK constraint errors
|
||||
DELETE FROM "SystemSettings" WHERE "category" = 'LOCALIZATION';
|
||||
|
||||
-- Remove the enum value (PostgreSQL does not support DROP VALUE directly,
|
||||
-- so we recreate the enum type without the removed value)
|
||||
-- Step 1: Create new enum without LOCALIZATION
|
||||
CREATE TYPE "SettingCategory_new" AS ENUM ('AI', 'BRANDING', 'EMAIL', 'STORAGE', 'SECURITY', 'DEFAULTS', 'WHATSAPP', 'AUDIT_CONFIG', 'DIGEST', 'ANALYTICS', 'INTEGRATIONS', 'COMMUNICATION', 'FEATURE_FLAGS');
|
||||
|
||||
-- Step 2: Alter column to use new enum
|
||||
ALTER TABLE "SystemSettings" ALTER COLUMN "category" TYPE "SettingCategory_new" USING ("category"::text::"SettingCategory_new");
|
||||
|
||||
-- Step 3: Drop old enum and rename new one
|
||||
DROP TYPE "SettingCategory";
|
||||
ALTER TYPE "SettingCategory_new" RENAME TO "SettingCategory";
|
||||
Reference in New Issue
Block a user