Add multi-user automation features and per-user error tracking. - Database migrations: add workflow_configs/workflow_runs (004), app_errors (005), pipeline_configs/pipeline_runs (006), and add user_token_hash to app_errors (007). - Backend: introduce per-request token handling (X-API-Token) via app.api.deps and update many API routes (auth, automations, bank, characters, dashboard, events, exchange, logs) to use user-scoped Artifacts client and character scoping. Auth endpoints no longer store tokens server-side (validate-only); clear is a no-op on server. - New Errors API and services: endpoint to list, filter, resolve, and report errors scoped to the requesting user; add error models, schemas, middleware/error handler and error_service for recording/hashing tokens. - Pipelines & Workflows: add API routers, models, schemas and engine modules (pipeline/worker/coordinator, workflow runner/conditions) and action_executor updates to support workflow/pipeline execution. - Logs: logs endpoint now prefers fetching recent action logs from the game API (with fallback to local DB), supports paging and filtering, and scopes results to the user. - Frontend: add pipeline/workflow builders, lists, progress components and hooks (use-errors, use-pipelines, use-workflows), sentry client config, and updates to API client/constants/types. - Misc: add middleware error handler, various engine strategy tweaks, tests adjusted. Overall this change enables per-user API tokens, scopes DB queries to each user, introduces pipelines/workflows runtime support, and centralizes application error tracking.
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""Application error model for tracking errors across the system."""
|
|
|
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String, Text
|
|
from sqlalchemy.dialects.postgresql import JSON
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class AppError(Base):
|
|
__tablename__ = "app_errors"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
severity = Column(
|
|
String(20),
|
|
nullable=False,
|
|
default="error",
|
|
comment="error | warning | critical",
|
|
)
|
|
source = Column(
|
|
String(50),
|
|
nullable=False,
|
|
comment="backend | frontend | automation | middleware",
|
|
)
|
|
error_type = Column(
|
|
String(200),
|
|
nullable=False,
|
|
comment="Exception class name or error category",
|
|
)
|
|
message = Column(Text, nullable=False)
|
|
stack_trace = Column(Text, nullable=True)
|
|
context = Column(JSON, nullable=True, comment="Arbitrary JSON context")
|
|
user_token_hash = Column(
|
|
String(64),
|
|
nullable=True,
|
|
index=True,
|
|
comment="SHA-256 hash of the user API token (for scoping errors per user)",
|
|
)
|
|
correlation_id = Column(
|
|
String(36),
|
|
nullable=True,
|
|
index=True,
|
|
comment="Request correlation ID (UUID)",
|
|
)
|
|
resolved = Column(Boolean, nullable=False, default=False, server_default="false")
|
|
created_at = Column(
|
|
DateTime(timezone=True),
|
|
server_default=func.now(),
|
|
nullable=False,
|
|
index=True,
|
|
)
|