feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
"""Schemas for Forgejo repository CRUD API payloads."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from uuid import UUID
|
|
|
|
|
|
|
|
|
|
from pydantic import field_validator
|
|
|
|
|
from sqlmodel import Field, SQLModel
|
|
|
|
|
|
|
|
|
|
RUNTIME_ANNOTATION_TYPES = (datetime, UUID)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoRepositoryBase(SQLModel):
|
|
|
|
|
"""Shared repository fields used across create/read payloads."""
|
|
|
|
|
|
|
|
|
|
owner: str
|
|
|
|
|
repo: str
|
|
|
|
|
display_name: str = ""
|
|
|
|
|
default_branch: str = "main"
|
|
|
|
|
active: bool = True
|
|
|
|
|
|
|
|
|
|
@field_validator("owner", "repo", mode="before")
|
|
|
|
|
@classmethod
|
|
|
|
|
def normalize_strings(cls, value: object) -> str | None | object:
|
|
|
|
|
"""Normalize whitespace in owner and repo."""
|
|
|
|
|
if value is None:
|
|
|
|
|
return None
|
|
|
|
|
if isinstance(value, str):
|
|
|
|
|
value = value.strip()
|
|
|
|
|
if not value:
|
|
|
|
|
return None
|
|
|
|
|
return value
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoRepositoryCreate(ForgejoRepositoryBase):
|
|
|
|
|
"""Payload for creating a Forgejo repository tracked configuration."""
|
2026-05-19 04:16:32 -05:00
|
|
|
|
feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
connection_id: UUID
|
2026-05-19 04:16:32 -05:00
|
|
|
webhook_secret: str | None = None
|
|
|
|
|
|
|
|
|
|
@field_validator("webhook_secret", mode="before")
|
|
|
|
|
@classmethod
|
|
|
|
|
def normalize_webhook_secret(cls, value: object) -> str | None | object:
|
|
|
|
|
"""Normalize empty webhook secrets to null."""
|
|
|
|
|
if value is None:
|
|
|
|
|
return None
|
|
|
|
|
if isinstance(value, str):
|
|
|
|
|
value = value.strip()
|
|
|
|
|
return value or None
|
|
|
|
|
return value
|
feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoRepositoryUpdate(SQLModel):
|
|
|
|
|
"""Payload for partial Forgejo repository updates."""
|
|
|
|
|
|
|
|
|
|
connection_id: UUID | None = None
|
|
|
|
|
owner: str | None = None
|
|
|
|
|
repo: str | None = None
|
|
|
|
|
display_name: str | None = None
|
|
|
|
|
default_branch: str | None = None
|
|
|
|
|
active: bool | None = None
|
2026-05-19 04:16:32 -05:00
|
|
|
webhook_secret: str | None = None
|
feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
|
|
|
|
|
@field_validator("owner", "repo", mode="before")
|
|
|
|
|
@classmethod
|
|
|
|
|
def normalize_strings(cls, value: object) -> str | None | object:
|
|
|
|
|
"""Normalize whitespace in owner and repo."""
|
|
|
|
|
if value is None:
|
|
|
|
|
return None
|
|
|
|
|
if isinstance(value, str):
|
|
|
|
|
value = value.strip()
|
|
|
|
|
if not value:
|
|
|
|
|
return None
|
|
|
|
|
return value
|
|
|
|
|
return value
|
|
|
|
|
|
2026-05-19 04:16:32 -05:00
|
|
|
@field_validator("webhook_secret", mode="before")
|
|
|
|
|
@classmethod
|
|
|
|
|
def normalize_webhook_secret(cls, value: object) -> str | None | object:
|
|
|
|
|
"""Normalize empty webhook secrets to null."""
|
|
|
|
|
if value is None:
|
|
|
|
|
return None
|
|
|
|
|
if isinstance(value, str):
|
|
|
|
|
value = value.strip()
|
|
|
|
|
return value or None
|
|
|
|
|
return value
|
|
|
|
|
|
feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
|
|
|
|
|
class ForgejoRepositoryConnectionInfo(SQLModel):
|
|
|
|
|
"""Safe connection metadata included in repository read responses."""
|
|
|
|
|
|
|
|
|
|
id: UUID
|
|
|
|
|
organization_id: UUID
|
|
|
|
|
name: str
|
|
|
|
|
base_url: str
|
|
|
|
|
has_token: bool
|
|
|
|
|
token_last_eight: str | None
|
|
|
|
|
active: bool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ForgejoRepositoryRead(ForgejoRepositoryBase):
|
|
|
|
|
"""Repository payload returned from read endpoints."""
|
|
|
|
|
|
|
|
|
|
id: UUID
|
|
|
|
|
organization_id: UUID
|
|
|
|
|
connection_id: UUID
|
|
|
|
|
connection: ForgejoRepositoryConnectionInfo
|
2026-05-19 04:16:32 -05:00
|
|
|
has_webhook_secret: bool = False
|
2026-05-19 21:49:45 -05:00
|
|
|
description: str | None = None
|
|
|
|
|
open_issues_count: int = 0
|
|
|
|
|
is_archived: bool = False
|
|
|
|
|
topics: list[str] = Field(default_factory=list)
|
2026-05-19 21:34:11 -05:00
|
|
|
labels: list[dict[str, object]] = Field(default_factory=list)
|
feat(forgejo): add DB models, CRUD APIs, client service, and Git Projects nav (Issues 1-4, FI2)
Backend:
- ForgejoConnection + ForgejoRepository SQLModel models with migration
- Admin CRUD API for connections (GET/POST/PATCH/DELETE)
- Admin CRUD API for repositories (GET/POST/PATCH/DELETE)
- Token redaction, URL normalization, duplicate prevention
- ForgejoAPIClient service (httpx async, list_issues, close_issue, get_repository)
- Removed stale feast import that crashed startup
Frontend:
- Git Projects sidebar nav item (FolderGit icon)
- /git-projects shell page with empty/loading/error states
Verified: all endpoints live, CRUD tested, migration applied.
2026-05-19 02:46:27 -05:00
|
|
|
last_sync_at: datetime | None
|
|
|
|
|
last_sync_error: str | None
|
|
|
|
|
created_at: datetime
|
|
|
|
|
updated_at: datetime
|