feat(forgejo): add validation, cached issues, sync service, and human issue APIs (Issues 5-8); add connection and repository admin UI (Issues 3-4); fix migration graph and client bugs
Backend Issues 5-8:
- POST /forgejo/connections/{id}/validate and /repositories/{id}/validate
- ForgejoIssue model with unique constraint (repo_id, issue_number)
- IssueSyncService with pagination and upsert
- GET /forgejo/issues with filtering, search, pagination
- GET /forgejo/issues/{id} with org-scoped access
- Fixed ForgejoAPIClient /api/v1 path prefix
- Fixed get_forgejo_client async context (was async def, now regular def)
- Fixed Forgejo API response parsing (list, not dict with items)
- Fixed None-safe handling for labels/assignees
Frontend Issues 3-4:
- Connections list, new, edit pages with token masking
- Repositories list, new, edit pages with connection selector
- ForgejoConnectionForm, ForgejoConnectionsTable components
- ForgejoRepositoryForm, ForgejoRepositoriesTable components
- api-forgejo.ts client library
Migration cleanup:
- Consolidated forgejo_issues table into f5a2b3c4d5e6 migration
- Removed orphan branch migrations for already-existing tables
- Fixed migration graph to single head (f5a2b3c4d5e6)
- Stamped DB to correct revision
2026-05-19 03:10:32 -05:00
|
|
|
"""Schemas for Forgejo issue operations."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from datetime import datetime
|
2026-05-22 00:12:15 -05:00
|
|
|
from typing import Any, Literal
|
feat(forgejo): add validation, cached issues, sync service, and human issue APIs (Issues 5-8); add connection and repository admin UI (Issues 3-4); fix migration graph and client bugs
Backend Issues 5-8:
- POST /forgejo/connections/{id}/validate and /repositories/{id}/validate
- ForgejoIssue model with unique constraint (repo_id, issue_number)
- IssueSyncService with pagination and upsert
- GET /forgejo/issues with filtering, search, pagination
- GET /forgejo/issues/{id} with org-scoped access
- Fixed ForgejoAPIClient /api/v1 path prefix
- Fixed get_forgejo_client async context (was async def, now regular def)
- Fixed Forgejo API response parsing (list, not dict with items)
- Fixed None-safe handling for labels/assignees
Frontend Issues 3-4:
- Connections list, new, edit pages with token masking
- Repositories list, new, edit pages with connection selector
- ForgejoConnectionForm, ForgejoConnectionsTable components
- ForgejoRepositoryForm, ForgejoRepositoriesTable components
- api-forgejo.ts client library
Migration cleanup:
- Consolidated forgejo_issues table into f5a2b3c4d5e6 migration
- Removed orphan branch migrations for already-existing tables
- Fixed migration graph to single head (f5a2b3c4d5e6)
- Stamped DB to correct revision
2026-05-19 03:10:32 -05:00
|
|
|
from uuid import UUID
|
|
|
|
|
|
|
|
|
|
from sqlmodel import SQLModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoIssueBase(SQLModel):
|
|
|
|
|
"""Shared issue fields used across create/read payloads."""
|
|
|
|
|
|
|
|
|
|
forgejo_issue_number: int
|
|
|
|
|
title: str
|
2026-05-19 21:49:45 -05:00
|
|
|
body: str | None = None
|
feat(forgejo): add validation, cached issues, sync service, and human issue APIs (Issues 5-8); add connection and repository admin UI (Issues 3-4); fix migration graph and client bugs
Backend Issues 5-8:
- POST /forgejo/connections/{id}/validate and /repositories/{id}/validate
- ForgejoIssue model with unique constraint (repo_id, issue_number)
- IssueSyncService with pagination and upsert
- GET /forgejo/issues with filtering, search, pagination
- GET /forgejo/issues/{id} with org-scoped access
- Fixed ForgejoAPIClient /api/v1 path prefix
- Fixed get_forgejo_client async context (was async def, now regular def)
- Fixed Forgejo API response parsing (list, not dict with items)
- Fixed None-safe handling for labels/assignees
Frontend Issues 3-4:
- Connections list, new, edit pages with token masking
- Repositories list, new, edit pages with connection selector
- ForgejoConnectionForm, ForgejoConnectionsTable components
- ForgejoRepositoryForm, ForgejoRepositoriesTable components
- api-forgejo.ts client library
Migration cleanup:
- Consolidated forgejo_issues table into f5a2b3c4d5e6 migration
- Removed orphan branch migrations for already-existing tables
- Fixed migration graph to single head (f5a2b3c4d5e6)
- Stamped DB to correct revision
2026-05-19 03:10:32 -05:00
|
|
|
body_preview: str | None = None
|
|
|
|
|
state: str
|
|
|
|
|
is_pull_request: bool
|
|
|
|
|
labels: list[dict[str, Any]] = []
|
|
|
|
|
assignees: list[dict[str, Any]] = []
|
2026-05-19 21:49:45 -05:00
|
|
|
milestone: dict[str, Any] | None = None
|
feat(forgejo): add validation, cached issues, sync service, and human issue APIs (Issues 5-8); add connection and repository admin UI (Issues 3-4); fix migration graph and client bugs
Backend Issues 5-8:
- POST /forgejo/connections/{id}/validate and /repositories/{id}/validate
- ForgejoIssue model with unique constraint (repo_id, issue_number)
- IssueSyncService with pagination and upsert
- GET /forgejo/issues with filtering, search, pagination
- GET /forgejo/issues/{id} with org-scoped access
- Fixed ForgejoAPIClient /api/v1 path prefix
- Fixed get_forgejo_client async context (was async def, now regular def)
- Fixed Forgejo API response parsing (list, not dict with items)
- Fixed None-safe handling for labels/assignees
Frontend Issues 3-4:
- Connections list, new, edit pages with token masking
- Repositories list, new, edit pages with connection selector
- ForgejoConnectionForm, ForgejoConnectionsTable components
- ForgejoRepositoryForm, ForgejoRepositoriesTable components
- api-forgejo.ts client library
Migration cleanup:
- Consolidated forgejo_issues table into f5a2b3c4d5e6 migration
- Removed orphan branch migrations for already-existing tables
- Fixed migration graph to single head (f5a2b3c4d5e6)
- Stamped DB to correct revision
2026-05-19 03:10:32 -05:00
|
|
|
author: str
|
|
|
|
|
html_url: str
|
|
|
|
|
forgejo_created_at: datetime
|
|
|
|
|
forgejo_updated_at: datetime
|
|
|
|
|
forgejo_closed_at: datetime | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoIssueCreate(ForgejoIssueBase):
|
|
|
|
|
"""Payload for creating a Forgejo issue record."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoIssueRead(ForgejoIssueBase):
|
|
|
|
|
"""Issue payload returned from read endpoints."""
|
|
|
|
|
|
|
|
|
|
id: UUID
|
|
|
|
|
organization_id: UUID
|
|
|
|
|
repository_id: UUID
|
|
|
|
|
created_at: datetime
|
|
|
|
|
updated_at: datetime
|
|
|
|
|
|
|
|
|
|
|
2026-05-21 22:47:24 -05:00
|
|
|
class ForgejoIssueDetailRead(ForgejoIssueRead):
|
|
|
|
|
"""Issue detail payload including full cached Forgejo source payload."""
|
|
|
|
|
|
|
|
|
|
forgejo_payload: dict[str, Any] | None = None
|
2026-05-21 22:53:02 -05:00
|
|
|
forgejo_comments_payload: list[dict[str, Any]] = []
|
|
|
|
|
forgejo_timeline_payload: list[dict[str, Any]] = []
|
|
|
|
|
forgejo_reactions_payload: list[dict[str, Any]] = []
|
2026-05-21 22:47:24 -05:00
|
|
|
|
|
|
|
|
|
feat(forgejo): add validation, cached issues, sync service, and human issue APIs (Issues 5-8); add connection and repository admin UI (Issues 3-4); fix migration graph and client bugs
Backend Issues 5-8:
- POST /forgejo/connections/{id}/validate and /repositories/{id}/validate
- ForgejoIssue model with unique constraint (repo_id, issue_number)
- IssueSyncService with pagination and upsert
- GET /forgejo/issues with filtering, search, pagination
- GET /forgejo/issues/{id} with org-scoped access
- Fixed ForgejoAPIClient /api/v1 path prefix
- Fixed get_forgejo_client async context (was async def, now regular def)
- Fixed Forgejo API response parsing (list, not dict with items)
- Fixed None-safe handling for labels/assignees
Frontend Issues 3-4:
- Connections list, new, edit pages with token masking
- Repositories list, new, edit pages with connection selector
- ForgejoConnectionForm, ForgejoConnectionsTable components
- ForgejoRepositoryForm, ForgejoRepositoriesTable components
- api-forgejo.ts client library
Migration cleanup:
- Consolidated forgejo_issues table into f5a2b3c4d5e6 migration
- Removed orphan branch migrations for already-existing tables
- Fixed migration graph to single head (f5a2b3c4d5e6)
- Stamped DB to correct revision
2026-05-19 03:10:32 -05:00
|
|
|
class ForgejoIssueListResponse(SQLModel):
|
|
|
|
|
"""Paginated list response for issues."""
|
|
|
|
|
|
|
|
|
|
items: list[ForgejoIssueRead]
|
|
|
|
|
total: int
|
|
|
|
|
page: int
|
|
|
|
|
limit: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoIssueUpsertResponse(SQLModel):
|
|
|
|
|
"""Response for issue sync operations."""
|
|
|
|
|
|
|
|
|
|
created: int = 0
|
|
|
|
|
updated: int = 0
|
|
|
|
|
open: int = 0
|
|
|
|
|
closed: int = 0
|
|
|
|
|
total: int = 0
|
2026-05-19 04:02:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class CloseIssueResponse(SQLModel):
|
|
|
|
|
"""Response for issue close operations."""
|
|
|
|
|
|
|
|
|
|
success: bool
|
|
|
|
|
issue_id: UUID
|
|
|
|
|
forgejo_issue_number: int
|
|
|
|
|
state: str
|
|
|
|
|
forgejo_closed_at: str | None = None
|
|
|
|
|
last_synced_at: str
|
2026-05-21 23:30:19 -05:00
|
|
|
|
|
|
|
|
|
2026-05-22 01:44:39 -05:00
|
|
|
class CreateIssueRequest(SQLModel):
|
|
|
|
|
"""Request body for creating a new Forgejo issue."""
|
|
|
|
|
|
|
|
|
|
repository_id: UUID
|
|
|
|
|
title: str
|
|
|
|
|
body: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CreateIssueResponse(SQLModel):
|
|
|
|
|
"""Response for issue creation."""
|
|
|
|
|
|
|
|
|
|
success: bool
|
|
|
|
|
issue_id: UUID
|
|
|
|
|
forgejo_issue_number: int
|
|
|
|
|
html_url: str
|
|
|
|
|
repository_id: UUID
|
|
|
|
|
|
|
|
|
|
|
2026-05-21 23:30:19 -05:00
|
|
|
class PostCommentRequest(SQLModel):
|
|
|
|
|
"""Request body for posting a comment on an issue."""
|
|
|
|
|
|
|
|
|
|
body: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PostCommentResponse(SQLModel):
|
|
|
|
|
"""Response for comment post operations."""
|
|
|
|
|
|
|
|
|
|
success: bool
|
|
|
|
|
issue_id: UUID
|
|
|
|
|
comment_id: int | str | None = None
|
|
|
|
|
body: str
|
|
|
|
|
created_at: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EditIssueRequest(SQLModel):
|
|
|
|
|
"""Request body for editing an issue. All fields are optional."""
|
|
|
|
|
|
|
|
|
|
title: str | None = None
|
|
|
|
|
body: str | None = None
|
|
|
|
|
state: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EditIssueResponse(SQLModel):
|
|
|
|
|
"""Response for issue edit operations."""
|
|
|
|
|
|
|
|
|
|
success: bool
|
|
|
|
|
issue_id: UUID
|
|
|
|
|
forgejo_issue_number: int
|
|
|
|
|
title: str
|
|
|
|
|
body: str | None = None
|
|
|
|
|
state: str
|
|
|
|
|
forgejo_updated_at: str
|
2026-05-22 00:12:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoIssueTaskRequest(SQLModel):
|
|
|
|
|
"""Request to create or update a Pipeline task for a Forgejo issue."""
|
|
|
|
|
|
|
|
|
|
board_id: UUID | None = None
|
|
|
|
|
assigned_agent_id: UUID | None = None
|
|
|
|
|
priority: str = "medium"
|
|
|
|
|
status: Literal["inbox", "in_progress"] | None = None
|
|
|
|
|
start_immediately: bool = True
|
|
|
|
|
instructions: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoIssueTaskResponse(SQLModel):
|
|
|
|
|
"""Response for creating or finding a Pipeline task from a Forgejo issue."""
|
|
|
|
|
|
|
|
|
|
success: bool
|
|
|
|
|
created: bool
|
|
|
|
|
issue_id: UUID
|
|
|
|
|
task_id: UUID
|
|
|
|
|
board_id: UUID
|
|
|
|
|
assigned_agent_id: UUID | None = None
|
|
|
|
|
status: str
|
|
|
|
|
title: str
|