Local dev gets an unauthenticated Adminer instance bound to loopback only. In production, any account with is_admin=true can open it - the app mints a short-lived token from a live admin session, which Nginx's new db.ciagent.org block exchanges for a session cookie that re-checks admin status on every request, instead of a shared static password that wouldn't scale to multiple admins or revoke live. Co-Authored-By: Claude Sonnet 5 <[email protected]>
179 lines
4.6 KiB
Python
179 lines
4.6 KiB
Python
"""Shared string enums for ORM models. Mirrored in apps/web/lib/types.ts and
|
|
packages/shared/src/index.ts - keep those in sync by hand when changing this."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from enum import StrEnum
|
|
|
|
|
|
class CompanyStatus(StrEnum):
|
|
ACTIVE = "active"
|
|
PAUSED = "paused"
|
|
|
|
|
|
class MonitoringFrequency(StrEnum):
|
|
HOURLY = "hourly"
|
|
EVERY_6_HOURS = "every_6_hours"
|
|
EVERY_12_HOURS = "every_12_hours"
|
|
DAILY = "daily"
|
|
EVERY_2_DAYS = "every_2_days"
|
|
WEEKLY = "weekly"
|
|
EVERY_2_WEEKS = "every_2_weeks"
|
|
MONTHLY = "monthly"
|
|
CUSTOM = "custom"
|
|
|
|
|
|
# Minimum minutes represented by each non-custom frequency, used both to
|
|
# compute next_run and to enforce MINIMUM_MONITORING_INTERVAL_MINUTES.
|
|
FREQUENCY_MINUTES: dict[MonitoringFrequency, int] = {
|
|
MonitoringFrequency.HOURLY: 60,
|
|
MonitoringFrequency.EVERY_6_HOURS: 6 * 60,
|
|
MonitoringFrequency.EVERY_12_HOURS: 12 * 60,
|
|
MonitoringFrequency.DAILY: 24 * 60,
|
|
MonitoringFrequency.EVERY_2_DAYS: 2 * 24 * 60,
|
|
MonitoringFrequency.WEEKLY: 7 * 24 * 60,
|
|
MonitoringFrequency.EVERY_2_WEEKS: 14 * 24 * 60,
|
|
MonitoringFrequency.MONTHLY: 30 * 24 * 60,
|
|
}
|
|
|
|
|
|
class SeverityLevel(StrEnum):
|
|
CRITICAL = "critical"
|
|
HIGH = "high"
|
|
MEDIUM = "medium"
|
|
LOW = "low"
|
|
|
|
|
|
# Ordering for threshold comparisons (index 0 = most severe).
|
|
SEVERITY_ORDER: list[SeverityLevel] = [
|
|
SeverityLevel.CRITICAL,
|
|
SeverityLevel.HIGH,
|
|
SeverityLevel.MEDIUM,
|
|
SeverityLevel.LOW,
|
|
]
|
|
|
|
|
|
class NotificationType(StrEnum):
|
|
EMAIL = "email"
|
|
SMS = "sms"
|
|
CONSOLE = "console"
|
|
|
|
|
|
class SourceType(StrEnum):
|
|
WEBSITE = "website"
|
|
RSS = "rss"
|
|
CUSTOM_URL = "custom_url"
|
|
SEC_EDGAR = "sec_edgar"
|
|
GITHUB = "github"
|
|
JOB_POSTING = "job_posting"
|
|
PATENT = "patent"
|
|
REVIEW = "review"
|
|
GOV_CONTRACT = "gov_contract"
|
|
|
|
|
|
class SourceStatus(StrEnum):
|
|
ACTIVE = "active"
|
|
DISABLED = "disabled"
|
|
RATE_LIMITED = "rate_limited"
|
|
AUTH_REQUIRED = "auth_required"
|
|
BLOCKED_BY_POLICY = "blocked_by_policy"
|
|
FAILED = "failed"
|
|
|
|
|
|
class MonitoringRunTrigger(StrEnum):
|
|
SCHEDULED = "scheduled"
|
|
MANUAL = "manual"
|
|
INITIAL = "initial"
|
|
RETRY = "retry"
|
|
|
|
|
|
class MonitoringRunStatus(StrEnum):
|
|
QUEUED = "queued"
|
|
RUNNING = "running"
|
|
SUCCESSFUL = "successful"
|
|
PARTIAL = "partial"
|
|
FAILED = "failed"
|
|
|
|
|
|
class ChangeType(StrEnum):
|
|
NEW_DOCUMENT = "new_document"
|
|
REMOVED_DOCUMENT = "removed_document"
|
|
CONTENT_MODIFIED = "content_modified"
|
|
PRICE_CHANGE = "price_change"
|
|
LEADERSHIP_CHANGE = "leadership_change"
|
|
FILING_NEW = "filing_new"
|
|
|
|
|
|
class ChangeStatus(StrEnum):
|
|
NEW = "new"
|
|
ACKNOWLEDGED = "acknowledged"
|
|
DISMISSED = "dismissed"
|
|
|
|
|
|
class ReportType(StrEnum):
|
|
BASELINE = "baseline"
|
|
UPDATE = "update"
|
|
MONTHLY = "monthly"
|
|
MANUAL = "manual"
|
|
|
|
|
|
class NotificationDeliveryStatus(StrEnum):
|
|
PENDING = "pending"
|
|
SENT = "sent"
|
|
FAILED = "failed"
|
|
|
|
|
|
class EnrichmentStatus(StrEnum):
|
|
PENDING = "pending"
|
|
PARTIAL = "partial"
|
|
COMPLETE = "complete"
|
|
FAILED = "failed"
|
|
|
|
|
|
class EmailCodePurpose(StrEnum):
|
|
VERIFY_EMAIL = "verify_email"
|
|
PASSWORD_RESET = "password_reset"
|
|
|
|
|
|
class ThrottleAction(StrEnum):
|
|
RESEND_VERIFICATION = "resend_verification"
|
|
RESEND_RESET = "resend_reset"
|
|
FAILED_LOGIN = "failed_login"
|
|
VERIFY_EMAIL_CODE = "verify_email_code"
|
|
CONFIRM_RESET_CODE = "confirm_reset_code"
|
|
|
|
|
|
class SecurityEventType(StrEnum):
|
|
LOGIN_SUCCESS = "login_success"
|
|
LOGIN_FAILED = "login_failed"
|
|
ACCOUNT_LOCKED = "account_locked"
|
|
PASSWORD_RESET_REQUESTED = "password_reset_requested"
|
|
PASSWORD_RESET_COMPLETED = "password_reset_completed"
|
|
EMAIL_VERIFICATION_SENT = "email_verification_sent"
|
|
EMAIL_VERIFIED = "email_verified"
|
|
SERVER_SECRET_UPDATED = "server_secret_updated"
|
|
API_KEY_UPDATED = "api_key_updated"
|
|
DB_VIEWER_SESSION_CREATED = "db_viewer_session_created"
|
|
|
|
|
|
class ApiKeyProvider(StrEnum):
|
|
"""Third-party providers a user can supply their own key for - see
|
|
app/services/user_api_key_service.py's PROVIDER_META for the matching
|
|
Settings field, display label, and credits/notes shown in Settings."""
|
|
|
|
ANTHROPIC = "anthropic"
|
|
BRAVE_SEARCH = "brave_search"
|
|
NINJAPEAR = "ninjapear"
|
|
USPTO = "uspto"
|
|
|
|
|
|
class SystemSecretKey(StrEnum):
|
|
"""Server-wide (not per-user) secrets an admin can configure from the
|
|
Settings page instead of only via .env - see
|
|
app/services/system_secret_service.py's META for the matching Settings
|
|
field and display label."""
|
|
|
|
TURNSTILE_SITE_KEY = "turnstile_site_key"
|
|
TURNSTILE_SECRET = "turnstile_secret"
|
|
RESEND_API_KEY = "resend_api_key"
|