Compare commits
18
Commits
6baa75bd9f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2208ed9ac1 | ||
|
|
d9c86e27d9 | ||
|
|
ad5d4d58c1 | ||
|
|
d3a705c5a3 | ||
|
|
3db817ebf5 | ||
|
|
e8aa97080e | ||
|
|
168b835b6b | ||
|
|
4a167ebb48 | ||
|
|
7987fdfa5d | ||
|
|
41e8608315 | ||
|
|
14ef3d1751 | ||
|
|
4652a22b0d | ||
|
|
67f41ca2f1 | ||
|
|
0e5976c849 | ||
|
|
30739c360e | ||
|
|
5fb8ea445d | ||
|
|
20eb811687 | ||
|
|
3be395a594 |
No files matched your search
@@ -0,0 +1,18 @@
|
||||
.git/
|
||||
.venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.pytest_cache/
|
||||
.ruff_cache/
|
||||
.coverage
|
||||
htmlcov/
|
||||
*.db
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
.env
|
||||
*.local.env
|
||||
.direnv/
|
||||
.vscode/
|
||||
.idea/
|
||||
+3
-1
@@ -13,13 +13,15 @@ venv/
|
||||
.ruff_cache/
|
||||
.coverage
|
||||
htmlcov/
|
||||
mutants/
|
||||
|
||||
# Local databases
|
||||
*.db
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
|
||||
# IDE / Editor
|
||||
# IDE / Editor / Nix direnv
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
.direnv/
|
||||
@@ -1,52 +1,62 @@
|
||||
# Armonía del Ser: API - Agent Guidelines & Workflow Rules
|
||||
# Repository Technical Blueprint: `armonia-api`
|
||||
|
||||
This document specifies mandatory workflows, constraints, and verification gates for AI agents operating in `armonia-api`.
|
||||
This file defines the local toolchain, code implementation boundaries, testing invariants, and structural index for `armonia-api`. For cross-repo Git branching rules, TDD lifecycle, or Gitea (`tea`) issue tracking, consult the workspace root [`../AGENTS.md`](../AGENTS.md).
|
||||
|
||||
---
|
||||
|
||||
## 1. Core Operating Constraints
|
||||
## 1. Local Toolchain & Nix Environment (`flake.nix` + `uv`)
|
||||
|
||||
- **No Direct Commits to `main`**: Agents must never commit directly to `main`. All work must be developed on descriptive feature, bugfix, or chore branches (`feat/*`, `fix/*`, `chore/*`).
|
||||
- **No Destructive Git Actions**: Commands such as `git reset --hard`, `git restore <file>`, `git clean -fd`, and force-pushes (`git push --force`) are strictly prohibited without the user's explicit yes.
|
||||
- **Secret Redaction**: Never print, commit, or log sensitive information (Turso tokens, GCP credentials, API keys).
|
||||
- **Session Modes**:
|
||||
- `learning`: The user drives and writes the reasoning, the agent asks guiding questions.
|
||||
- `delivery`: The agent may draft code and plans, presenting rationale and trade-offs.
|
||||
|
||||
---
|
||||
|
||||
## 2. Verification Gates (Pre-Commit Checklist)
|
||||
|
||||
Before proposing or executing any commit, run and verify:
|
||||
|
||||
1. **Ruff Formatting**:
|
||||
This repository is provisioned via a declarative Nix `devShell` (`flake.nix` + `.envrc`) and managed exclusively via `uv`.
|
||||
- **Nix DevShell:** Ensure commands run inside the Nix environment (`direnv` activates automatically on `cd`, or prefix with `nix develop -c <cmd>`).
|
||||
- **Package Management:** Do not invoke raw `python`, `pip`, or `virtualenv` commands directly. Always use `uv run`, `uv add`, or `uv sync` so `pyproject.toml` and `uv.lock` remain synchronized.
|
||||
- **Verification Gates (Pre-Commit Checklist):**
|
||||
Before proposing or executing any commit, run and pass all four checks with zero errors or warnings:
|
||||
```bash
|
||||
uv run ruff format --check .
|
||||
```
|
||||
2. **Ruff Linting**:
|
||||
```bash
|
||||
uv run ruff check .
|
||||
```
|
||||
3. **Static Type Checking (Pyright)**:
|
||||
```bash
|
||||
uv run pyright
|
||||
```
|
||||
4. **Automated Test Suite (Pytest)**:
|
||||
```bash
|
||||
uv run pytest
|
||||
```
|
||||
|
||||
No commit may be generated if any of these checks fail or report unhandled errors.
|
||||
---
|
||||
|
||||
## 2. Codebase Implementation Rules & Layered Architecture
|
||||
|
||||
To keep `armonia-api` infrastructure-agnostic (portable across Turso `libSQL`, local SQLite, PostgreSQL, or future storage engines), enforce strict separation of concerns across `app/`:
|
||||
|
||||
### Routers (`app/routers/`)
|
||||
- **HTTP Transport Only:** Routers handle path/query parameters, request schema validation, FastAPI auth dependencies (`require_admin`), HTTP status codes, and response serialization.
|
||||
- **Zero Direct Data Access:** Never embed raw SQL statements or direct ORM `Session` queries inside router endpoints. Delegate business workflows to `app/services/` and persistence to `app/repositories/`.
|
||||
|
||||
### Services (`app/services/`)
|
||||
- **Consumer-Agnostic Domain Logic:** Business rules (48-hour follow-up evaluation, 1-on-1 mandatory buffer collision math, WhatsApp deep-link generation, and Google Calendar synchronization) live in `app/services/`.
|
||||
- **Framework Independence:** Keep service functions decoupled from `fastapi.Depends` and HTTP exceptions so CLI scripts, background jobs, or tests can invoke them directly.
|
||||
|
||||
### Repositories & Models (`app/repositories/` & `app/models/`)
|
||||
- **Data Access Boundary:** Repositories encapsulate all database reads/writes and translate between `SQLModel` table rows and domain/schema objects.
|
||||
- **Engine Portability:** Configure database connectivity in `app/db/database.py` using `SQLModel` + `sqlalchemy-libsql` (`sqlite+libsql://` for Turso Cloud, falling back cleanly to `sqlite:///local.db` for local execution).
|
||||
|
||||
### Schemas (`app/schemas/`)
|
||||
- **Strict API Contracts:** Maintain explicit Pydantic v2 / SQLModel schemas separating input payloads (`*Create`, `*Update`, `*Request`) from output responses (`*Read`, `*Response`).
|
||||
|
||||
### Core & Auth (`app/core/`)
|
||||
- **Server-Side Security Boundary:** Google OAuth secrets, HMAC session signing, and Turso `admin_allowlist` + `admin_audit_log` verification (`app/core/auth.py`) remain strictly server-side.
|
||||
|
||||
---
|
||||
|
||||
## 3. Architecture & Domain Directives
|
||||
## 3. Local Test Invariants (`tests/`)
|
||||
|
||||
- **Database Abstraction**: Use `libsql-client` with clean fallback to local SQLite (`file:local.db`). In local testing, tests run against in-memory or temporary local SQLite instances without needing cloud credentials.
|
||||
- **Anti-Ghosting Booking State Machine**:
|
||||
- `PENDING_PAYMENT`: Initial state upon client reservation. Slot held tentatively for 2 hours.
|
||||
- `CONFIRMED`: Acknowledged by Jazmin via the Admin Dashboard after checking bank deposit.
|
||||
- `EXPIRED`: Automatic timeout if no SPEI proof is acknowledged.
|
||||
- `CANCELLED`: Explicit cancellation.
|
||||
- `NO_SHOW`: Marked if client failed to attend.
|
||||
- **Consumer Agnostic**: Keep service functions and database queries decoupled from the FastAPI routers so they can be seamlessly consumed by an MCP server, WhatsApp webhook worker, or background job runner in the future.
|
||||
- **Real Local SQLite for Persistence Tests:** Integration and repository tests must run against an isolated local SQLite instance (`file:test_armonia.db` / `sqlite:///test_armonia.db` configured in `tests/conftest.py`). Never make network requests to live Turso Cloud clusters during `pytest` runs, and never mock out SQL/database queries in repository tests (which creates tautological tests).
|
||||
- **Mocking External I/O Boundaries (`pytest-mock`):** Always isolate external network side-effects—specifically Google Calendar API synchronization (`app/services/calendar.py`) and external OAuth token exchanges—using `pytest-mock` (`mocker` fixture) so the test suite runs deterministically offline.
|
||||
- **Fixtures Policy:** Centralize database lifecycle setup, test clients, and mock administrator principals inside `tests/conftest.py`.
|
||||
- **Mutation Testing Audit (`mutmut`):** Once domain rules are extracted into `app/services/`, use `mutmut` (`uv run mutmut run`) scoped to `app/services/` as a pre-PR quality audit to verify that unit tests catch boundary and off-by-one mutations (e.g., 15-minute buffer collision intervals and 48-hour follow-up cutoffs).
|
||||
|
||||
---
|
||||
|
||||
## 4. Local Structural Maps & Documentation Index
|
||||
|
||||
Before modifying domain rules, state transitions, or database schemas, read these canonical specifications to prevent logic drift:
|
||||
- **Software Requirements Specification:** [`docs/SRS.md`](./docs/SRS.md)
|
||||
- **System Topology & State Machines (Booking / Payment / 48h Queue):** [`docs/architecture.md`](./docs/architecture.md)
|
||||
- **Architectural Decision Records (ADRs):** [`docs/decisions/0001-*.md`](./docs/decisions/) through [`0005-*.md`](./docs/decisions/)
|
||||
- **Relational Schema Reference:** [`app/db/schema.sql`](./app/db/schema.sql) (and `app/models/` during/after the SQLModel migration)
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Multi-stage production container build for armonia-api
|
||||
|
||||
# Stage 1: Build virtual environment with uv
|
||||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
|
||||
|
||||
ENV UV_COMPILE_BYTECODE=1 \
|
||||
UV_LINK_MODE=copy
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies using cache mount
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
--mount=type=bind,source=uv.lock,target=uv.lock \
|
||||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
||||
uv sync --frozen --no-install-project --no-dev
|
||||
|
||||
# Copy application sources and sync project
|
||||
COPY . /app
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv sync --frozen --no-dev
|
||||
|
||||
|
||||
# Stage 2: Minimal runtime image
|
||||
FROM python:3.13-slim-bookworm AS runtime
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install curl for container healthcheck
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends curl && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy installed virtual environment and application code from builder
|
||||
COPY --from=builder /app /app
|
||||
|
||||
# Non-root unprivileged container user
|
||||
RUN useradd -u 1000 -m -s /bin/bash appuser && \
|
||||
chown -R appuser:appuser /app
|
||||
|
||||
USER appuser
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
@@ -1,45 +1,44 @@
|
||||
# Armonía del Ser: Core API (`armonia-api`)
|
||||
|
||||
Backend API service for **Armonía del Ser**—a holistic therapy, meditation, and personal growth center in Mexico.
|
||||
Backend API service for **Armonía del Ser**—a holistic therapy, meditation, and personal growth center founded by **Jasmin** in Mexico.
|
||||
|
||||
Built with **FastAPI** and **Turso (libSQL)** to manage services, appointments, client records, and payment acknowledgments at zero infrastructure cost.
|
||||
Built with **FastAPI** and **Turso (libSQL)** to serve as the operational source of truth between **Google Calendar**, **Turso**, and the **Admin Dashboard (`armonia-dashboard`)** protected with a server-side allowlist for **Google OAuth**.
|
||||
|
||||
---
|
||||
|
||||
## Architecture & Design
|
||||
|
||||
```
|
||||
[Clients / Landing UI] [Admin Dashboard (Jazmín)]
|
||||
│ │
|
||||
[Clients / Landing UI] [Admin Dashboard (Jasmin & Assistant)]
|
||||
│ │ (Google OAuth + Turso Allowlist)
|
||||
▼ ▼
|
||||
┌──────────────────────────────────────────────────────────┐
|
||||
│ FastAPI Core Service │
|
||||
│ - Services Catalog (Group & 1-on-1) │
|
||||
│ - Booking State Machine (Pending -> Confirmed) │
|
||||
│ - Payment Verification & Acknowledgment │
|
||||
│ - Dynamic WhatsApp Deep-Link Generator │
|
||||
│ - Separated Booking & Payment State Engine │
|
||||
│ - 48-Hour Payment Follow-Up Queue & Delayed Exceptions │
|
||||
│ - Deliberate Slot Release & Audit Trail │
|
||||
│ - Google OAuth2 + Turso Allowlist Guard │
|
||||
└──────────────┬─────────────────────────────┬─────────────┘
|
||||
│ │
|
||||
▼ ▼
|
||||
[Turso Database] [Google Calendar API]
|
||||
(SQLite / libSQL at edge) (Tentative [PENDIENTE] hold
|
||||
-> Locked [CONFIRMADO])
|
||||
(SQLite / libSQL at edge) (Schedule coordination &
|
||||
recoverable sync health)
|
||||
```
|
||||
|
||||
### Key Principles
|
||||
|
||||
1. **Anti-Ghosting Payment Workflow**:
|
||||
- A client reserves a spot -> Booking is saved as `PENDING_PAYMENT` with a unique folio (`ADS-XXXX`).
|
||||
- A tentative hold is placed on Google Calendar.
|
||||
- Client is redirected to WhatsApp with pre-filled transfer details (SPEI CLABE + Folio).
|
||||
- Once Jazmín verifies the deposit in her banking app, she acknowledges it via the Admin Dashboard (`armonia-dashboard`).
|
||||
- Booking transitions to `CONFIRMED`, locking the calendar event and sending confirmation details.
|
||||
2. **Zero-Cost Infrastructure**:
|
||||
1. **Separated Booking & Payment States**:
|
||||
- `booking_status` (`RESERVED`, `RELEASED`, `CANCELLED`, `COMPLETED`, `NO_SHOW`) is modeled orthogonally from `payment_arrangement` (`PREPAID_DEFAULT`, `DELAYED_ALLOWED`, `PACKAGE_REDEEMED`) and `payment_status` (`AWAITING_ACKNOWLEDGMENT`, `ACKNOWLEDGED`, `NOT_APPLICABLE`).
|
||||
2. **Prepayment by Default, Explicit Delayed-Payment Exceptions**:
|
||||
- Most bookings require prepayment (`PREPAID_DEFAULT`). Authorized administrators can explicitly authorize a delayed-payment exception (`DELAYED_ALLOWED`), keeping `payment_status = 'AWAITING_ACKNOWLEDGMENT'` until payment is actually settled.
|
||||
3. **Deliberate Slot Release & 48-Hour Follow-Up Visibility**:
|
||||
- Bookings never expire automatically on a timer. At 48 hours prior to a session, unacknowledged bookings appear in `GET /bookings/follow-up-queue` so the assistant can manually follow up via WhatsApp and either acknowledge payment, authorize delayed payment, or deliberately release the slot (`RELEASED`).
|
||||
4. **Google OAuth + Turso Allowlist**:
|
||||
- Administrative endpoints verify the caller's Google OAuth session against Turso's `admin_allowlist` table on every request and record all mutations in `admin_audit_log`.
|
||||
5. **Zero-Cost Infrastructure**:
|
||||
- Runs containerized on **Google Cloud Run** free tier (scale-to-zero, $0/month).
|
||||
- Data stored in **Turso** free tier (up to 9 GB storage, billions of monthly row reads).
|
||||
- In local development and automated testing, seamlessly falls back to standard file-based SQLite (`file:local.db`).
|
||||
3. **Consumer Agnostic**:
|
||||
- Designed to serve both web frontends (`armonia-dashboard`, `armonia-landing`) and future headless consumers (an MCP server for AI pair programming, a WhatsApp Business Cloud API webhook, or an LLM booking assistant).
|
||||
- Data stored in **Turso** free tier, with local fallback to file-based SQLite (`file:local.db`).
|
||||
|
||||
---
|
||||
|
||||
@@ -47,10 +46,12 @@ Built with **FastAPI** and **Turso (libSQL)** to manage services, appointments,
|
||||
|
||||
| Entity | Purpose |
|
||||
| :--- | :--- |
|
||||
| `services` | Catalog of offerings (Círculos de Cacao, Meditaciones, Constelaciones, Psicoterapia), format (`ONLINE` / `PRESENCIAL`), type (`GROUP` / `ONE_ON_ONE`), capacity, and price in MXN. |
|
||||
| `admin_allowlist` | Authorized administrator emails (`OWNER`, `ASSISTANT`, `ADMIN`), active status, and last login timestamp. |
|
||||
| `services` | Catalog of offerings (Círculos de Cacao, Meditaciones, Constelaciones, Psicoterapia), format (`ONLINE` / `PRESENCIAL`), type (`GROUP` / `INDIVIDUAL`), capacity, mandatory buffer, and price in MXN. |
|
||||
| `clients` | Client directory (name, phone / WhatsApp, email, notes). |
|
||||
| `bookings` | Appointments linked to a service and client, tracking status (`PENDING_PAYMENT`, `CONFIRMED`, `CANCELLED`, `EXPIRED`, `NO_SHOW`), folio, and expiration. |
|
||||
| `payments` | Audit record of SPEI/OXXO payment verification, notes, and acknowledgment timestamp. |
|
||||
| `bookings` | Appointments tracking `booking_status`, `payment_arrangement`, `payment_status`, folio (`ADS-XXXX`), exception/release/acknowledgment audit metadata, and Google Calendar sync health. |
|
||||
| `payments` | Audit record of SPEI/OXXO/cash payment acknowledgment (`acknowledged_by`, `acknowledged_at`, notes). |
|
||||
| `admin_audit_log` | Immutable log of administrative actions (`ACKNOWLEDGE_PAYMENT`, `AUTHORIZE_DELAYED_PAYMENT`, `RELEASE_BOOKING`, etc.). |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
from datetime import UTC, datetime
|
||||
from typing import Any, Protocol
|
||||
|
||||
import libsql_client
|
||||
from fastapi import HTTPException, Request, status
|
||||
from sqlmodel import Session
|
||||
|
||||
from app.core.config import AuthProvider, settings
|
||||
from app.db.database import get_db, get_engine, row_to_dict
|
||||
from app.models.admin import RoleEnum
|
||||
from app.repositories.admin import mirror_admin_actor
|
||||
from app.schemas.auth import AdminPrincipal
|
||||
|
||||
SESSION_COOKIE_NAME = "armonia_session"
|
||||
OAUTH_STATE_COOKIE_NAME = "armonia_oauth_state"
|
||||
|
||||
|
||||
def _b64url_encode(data: bytes) -> str:
|
||||
return base64.urlsafe_b64encode(data).rstrip(b"=").decode("ascii")
|
||||
|
||||
|
||||
def _b64url_decode(s: str) -> bytes:
|
||||
padding = "=" * (-len(s) % 4)
|
||||
return base64.urlsafe_b64decode(s + padding)
|
||||
|
||||
|
||||
def create_session_token(email: str, ttl_seconds: int | None = None) -> str:
|
||||
"""Create an HMAC-SHA256 signed session token for an authenticated admin email."""
|
||||
ttl = ttl_seconds if ttl_seconds is not None else settings.session_ttl_seconds
|
||||
payload = {
|
||||
"sub": email.strip().lower(),
|
||||
"iat": int(time.time()),
|
||||
"exp": int(time.time()) + ttl,
|
||||
}
|
||||
payload_b64 = _b64url_encode(json.dumps(payload, separators=(",", ":")).encode("utf-8"))
|
||||
sig = hmac.new(
|
||||
settings.session_secret_key.encode("utf-8"),
|
||||
payload_b64.encode("ascii"),
|
||||
hashlib.sha256,
|
||||
).digest()
|
||||
sig_b64 = _b64url_encode(sig)
|
||||
return f"{payload_b64}.{sig_b64}"
|
||||
|
||||
|
||||
def verify_session_token(token: str) -> str:
|
||||
"""Verify HMAC-SHA256 signature and expiration, returning the normalized admin email."""
|
||||
parts = token.split(".")
|
||||
if len(parts) != 2:
|
||||
raise ValueError("Invalid token format")
|
||||
payload_b64, sig_b64 = parts
|
||||
expected_sig = hmac.new(
|
||||
settings.session_secret_key.encode("utf-8"),
|
||||
payload_b64.encode("ascii"),
|
||||
hashlib.sha256,
|
||||
).digest()
|
||||
try:
|
||||
actual_sig = _b64url_decode(sig_b64)
|
||||
except Exception as exc:
|
||||
raise ValueError("Invalid token signature encoding") from exc
|
||||
|
||||
if not hmac.compare_digest(expected_sig, actual_sig):
|
||||
raise ValueError("Token signature mismatch")
|
||||
|
||||
try:
|
||||
payload = json.loads(_b64url_decode(payload_b64).decode("utf-8"))
|
||||
except Exception as exc:
|
||||
raise ValueError("Invalid token payload") from exc
|
||||
|
||||
exp = int(payload.get("exp", 0))
|
||||
if time.time() >= exp:
|
||||
raise ValueError("Session token has expired")
|
||||
|
||||
email = str(payload.get("sub", "")).strip().lower()
|
||||
if not email:
|
||||
raise ValueError("Token missing subject email")
|
||||
return email
|
||||
|
||||
|
||||
async def get_allowlisted_admin(client: libsql_client.Client, email: str) -> AdminPrincipal | None:
|
||||
"""Look up an email in Turso's admin_allowlist table and return AdminPrincipal if active."""
|
||||
normalized = email.strip().lower()
|
||||
res = await client.execute(
|
||||
"SELECT email, full_name, role, is_active, last_login_at FROM admin_allowlist WHERE lower(email) = ? LIMIT 1;",
|
||||
[normalized],
|
||||
)
|
||||
if not res.rows:
|
||||
return None
|
||||
row = row_to_dict(res, res.rows[0])
|
||||
if not bool(row.get("is_active", 0)):
|
||||
return None
|
||||
return AdminPrincipal(
|
||||
email=str(row["email"]),
|
||||
full_name=str(row["full_name"]),
|
||||
role=row["role"],
|
||||
is_active=True,
|
||||
last_login_at=row.get("last_login_at"),
|
||||
)
|
||||
|
||||
|
||||
async def record_admin_audit(
|
||||
client: libsql_client.Client,
|
||||
admin_email: str,
|
||||
action_type: str,
|
||||
entity_type: str,
|
||||
entity_id: str,
|
||||
details: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
"""Write an immutable audit entry to admin_audit_log."""
|
||||
audit_id = str(uuid.uuid4())
|
||||
now = datetime.now(UTC).isoformat()
|
||||
details_json = json.dumps(details, ensure_ascii=False) if details else None
|
||||
await client.execute(
|
||||
"""
|
||||
INSERT INTO admin_audit_log (id, admin_email, action_type, entity_type, entity_id, details_json, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?);
|
||||
""",
|
||||
[audit_id, admin_email, action_type, entity_type, entity_id, details_json, now],
|
||||
)
|
||||
|
||||
|
||||
# --- Pluggable authentication strategy (ADR-0006) ---------------------------------------
|
||||
#
|
||||
# Each adapter inspects only its own credentials and returns:
|
||||
# * AdminPrincipal -> authenticated and authorized
|
||||
# * None -> its credentials are absent (lets require_admin try a fallback / 401)
|
||||
# and raises HTTPException when credentials are present but invalid or unauthorized.
|
||||
|
||||
# Highest privilege first; exact (case-insensitive) LLDAP group names.
|
||||
PROXY_GROUP_ROLES: tuple[tuple[str, RoleEnum], ...] = (
|
||||
("armonia-owner", RoleEnum.OWNER),
|
||||
("armonia-admin", RoleEnum.ADMIN),
|
||||
("armonia-assistant", RoleEnum.ASSISTANT),
|
||||
)
|
||||
SAFE_METHODS = frozenset({"GET", "HEAD", "OPTIONS"})
|
||||
|
||||
|
||||
def resolve_role_from_groups(raw_groups: str | None) -> RoleEnum | None:
|
||||
"""Map Authelia's comma-separated `Remote-Groups` to the highest-privilege RoleEnum."""
|
||||
if not raw_groups:
|
||||
return None
|
||||
groups = {g.strip().lower() for g in raw_groups.split(",") if g.strip()}
|
||||
for group_name, role in PROXY_GROUP_ROLES:
|
||||
if group_name in groups:
|
||||
return role
|
||||
return None
|
||||
|
||||
|
||||
class AuthAdapter(Protocol):
|
||||
async def authenticate(self, request: Request) -> AdminPrincipal | None: ...
|
||||
|
||||
|
||||
async def _require_allowlisted(email: str) -> AdminPrincipal:
|
||||
async with get_db() as client:
|
||||
principal = await get_allowlisted_admin(client, email)
|
||||
if not principal:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=f"El correo '{email}' no está autorizado en la lista de administradores activos.",
|
||||
)
|
||||
return principal
|
||||
|
||||
|
||||
class ProxyHeaderAdapter:
|
||||
"""
|
||||
Authelia/LLDAP forward-auth. Identity and role come exclusively from Remote-* headers;
|
||||
reads perform zero database queries. On unsafe methods the principal is mirrored into
|
||||
`admin_allowlist` so audited writes keep FK integrity (ADR-0006).
|
||||
|
||||
SECURITY: only enable when the API is reachable exclusively through the proxy, which must
|
||||
strip client-supplied Remote-* headers.
|
||||
"""
|
||||
|
||||
async def authenticate(self, request: Request) -> AdminPrincipal | None:
|
||||
raw_identity = request.headers.get("Remote-Email") or request.headers.get("Remote-User")
|
||||
email = (raw_identity or "").strip().lower()
|
||||
if not email:
|
||||
return None
|
||||
|
||||
role = resolve_role_from_groups(request.headers.get("Remote-Groups"))
|
||||
if role is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=f"El usuario '{email}' no pertenece a ningún grupo armonia-* autorizado.",
|
||||
)
|
||||
|
||||
full_name = (request.headers.get("Remote-Name") or "").strip() or email
|
||||
principal = AdminPrincipal(email=email, full_name=full_name, role=role.value)
|
||||
|
||||
if request.method.upper() not in SAFE_METHODS:
|
||||
with Session(get_engine()) as session:
|
||||
mirror_admin_actor(session, email=email, full_name=full_name, role=role.value)
|
||||
return principal
|
||||
|
||||
|
||||
class GoogleOAuthAdapter:
|
||||
"""HMAC session token (Bearer header or HttpOnly cookie) verified against the allowlist."""
|
||||
|
||||
async def authenticate(self, request: Request) -> AdminPrincipal | None:
|
||||
auth_header = request.headers.get("Authorization", "")
|
||||
token: str | None = None
|
||||
if auth_header.startswith("Bearer "):
|
||||
token = auth_header.removeprefix("Bearer ").strip()
|
||||
elif SESSION_COOKIE_NAME in request.cookies:
|
||||
token = request.cookies.get(SESSION_COOKIE_NAME)
|
||||
if not token:
|
||||
return None
|
||||
|
||||
try:
|
||||
email = verify_session_token(token)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail=f"Sesión inválida o expirada: {exc}",
|
||||
) from exc
|
||||
return await _require_allowlisted(email)
|
||||
|
||||
|
||||
class DevKeyAdapter:
|
||||
"""X-Admin-Key (+ optional X-Admin-Email) for tests, CLI, and local dashboard development."""
|
||||
|
||||
async def authenticate(self, request: Request) -> AdminPrincipal | None:
|
||||
admin_key = request.headers.get("X-Admin-Key")
|
||||
if not admin_key:
|
||||
return None
|
||||
if not hmac.compare_digest(admin_key, settings.admin_api_key):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Clave de administrador inválida.",
|
||||
)
|
||||
|
||||
admin_email_hdr = (request.headers.get("X-Admin-Email") or "").strip().lower()
|
||||
email = admin_email_hdr or (
|
||||
settings.admin_bootstrap_emails[0].strip().lower()
|
||||
if settings.admin_bootstrap_emails
|
||||
else ""
|
||||
)
|
||||
if not email:
|
||||
return None
|
||||
return await _require_allowlisted(email)
|
||||
|
||||
|
||||
AUTH_ADAPTERS: dict[AuthProvider, AuthAdapter] = {
|
||||
AuthProvider.PROXY_HEADERS: ProxyHeaderAdapter(),
|
||||
AuthProvider.GOOGLE_OAUTH: GoogleOAuthAdapter(),
|
||||
AuthProvider.DEV_KEY: DevKeyAdapter(),
|
||||
}
|
||||
|
||||
|
||||
def resolve_adapter_chain() -> list[AuthAdapter]:
|
||||
"""Configured provider first; dev_key fallback only outside production."""
|
||||
primary = AuthProvider(settings.auth_provider)
|
||||
chain = [AUTH_ADAPTERS[primary]]
|
||||
if primary is not AuthProvider.DEV_KEY and settings.environment != "production":
|
||||
chain.append(AUTH_ADAPTERS[AuthProvider.DEV_KEY])
|
||||
return chain
|
||||
|
||||
|
||||
async def require_admin(request: Request) -> AdminPrincipal:
|
||||
"""
|
||||
FastAPI dependency yielding a uniform AdminPrincipal regardless of identity provider
|
||||
(`settings.auth_provider`). Routers and services never inspect credentials themselves.
|
||||
"""
|
||||
for adapter in resolve_adapter_chain():
|
||||
principal = await adapter.authenticate(request)
|
||||
if principal is not None:
|
||||
return principal
|
||||
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Autenticación de administrador requerida.",
|
||||
)
|
||||
+61
-8
@@ -1,22 +1,43 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from enum import StrEnum
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import BeforeValidator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
def _parse_origins(v: str | list[str]) -> list[str]:
|
||||
class AuthProvider(StrEnum):
|
||||
"""Identity source strategy consumed by `app.core.auth.require_admin`."""
|
||||
|
||||
PROXY_HEADERS = "proxy_headers"
|
||||
GOOGLE_OAUTH = "google_oauth"
|
||||
DEV_KEY = "dev_key"
|
||||
|
||||
|
||||
def _parse_str_list(v: str | list[str]) -> list[str]:
|
||||
if isinstance(v, str):
|
||||
try:
|
||||
parsed = json.loads(v)
|
||||
if isinstance(parsed, list):
|
||||
return [str(x) for x in parsed]
|
||||
return [str(x).strip() for x in parsed if str(x).strip()]
|
||||
except Exception:
|
||||
pass
|
||||
return [x.strip() for x in v.split(",") if x.strip()]
|
||||
return list(v)
|
||||
return [str(x).strip() for x in v if str(x).strip()]
|
||||
|
||||
|
||||
def _parse_int_list(v: str | list[int]) -> list[int]:
|
||||
if isinstance(v, str):
|
||||
try:
|
||||
parsed = json.loads(v)
|
||||
if isinstance(parsed, list):
|
||||
return [int(x) for x in parsed]
|
||||
except Exception:
|
||||
pass
|
||||
return [int(x.strip()) for x in v.split(",") if x.strip()]
|
||||
return [int(x) for x in v]
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
@@ -34,21 +55,53 @@ class Settings(BaseSettings):
|
||||
environment: str = "development"
|
||||
port: int = 8000
|
||||
host: str = "0.0.0.0"
|
||||
cors_origins: Annotated[list[str], BeforeValidator(_parse_origins)] = [
|
||||
cors_origins: Annotated[list[str], BeforeValidator(_parse_str_list)] = [
|
||||
"http://localhost:5173",
|
||||
"http://localhost:3000",
|
||||
]
|
||||
|
||||
# Security
|
||||
# Security & Pluggable Authentication (ADR-0005, ADR-0006)
|
||||
# proxy_headers: trust Authelia Remote-* headers (API must only be reachable via the proxy)
|
||||
# google_oauth: HMAC session token/cookie verified against Turso admin_allowlist
|
||||
# dev_key: X-Admin-Key (+ X-Admin-Email) verified against admin_allowlist
|
||||
# Outside production, dev_key is also tried as a fallback when the primary finds no credentials.
|
||||
auth_provider: AuthProvider = AuthProvider.GOOGLE_OAUTH
|
||||
admin_api_key: str = "dev-secret-key-change-in-production"
|
||||
session_secret_key: str = "dev-session-secret-change-in-production"
|
||||
session_ttl_seconds: int = 86400 * 7 # 7 days
|
||||
google_oauth_client_id: str | None = None
|
||||
google_oauth_client_secret: str | None = None
|
||||
google_oauth_redirect_uri: str = "http://localhost:8000/auth/google/callback"
|
||||
dashboard_origin_url: str = "http://localhost:5173"
|
||||
admin_bootstrap_emails: Annotated[list[str], BeforeValidator(_parse_str_list)] = [
|
||||
"jasmin@armoniadelser.mx",
|
||||
"asistente@armoniadelser.mx",
|
||||
]
|
||||
|
||||
# Operational rules
|
||||
payment_followup_threshold_hours: int = 48
|
||||
|
||||
# Business profile (Armonía del Ser)
|
||||
therapist_name: str = "Jazmín"
|
||||
therapist_name: str = "Jasmin"
|
||||
business_name: str = "Armonía del Ser"
|
||||
whatsapp_phone: str = "521XXXXXXXXXX"
|
||||
whatsapp_phone: str = "527751487912"
|
||||
spei_clabe: str = "012345678901234567"
|
||||
spei_bank: str = "BBVA"
|
||||
spei_beneficiary: str = "Jazmín"
|
||||
spei_beneficiary: str = "Jasmin"
|
||||
|
||||
# Business hours & availability engine (ADR-0003)
|
||||
business_timezone: str = "America/Mexico_City"
|
||||
availability_open_time: str = "09:00"
|
||||
availability_close_time: str = "19:00"
|
||||
availability_slot_step_minutes: int = 30
|
||||
availability_working_weekdays: Annotated[list[int], BeforeValidator(_parse_int_list)] = [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
] # Mon-Fri
|
||||
availability_max_range_days: int = 60
|
||||
|
||||
# Google Calendar
|
||||
gcal_calendar_id: str = "primary"
|
||||
|
||||
+56
-1
@@ -1,14 +1,69 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
from collections.abc import AsyncIterator
|
||||
from collections.abc import AsyncIterator, Generator
|
||||
from typing import Any
|
||||
|
||||
import libsql_client
|
||||
from sqlalchemy import event
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlmodel import Session, create_engine
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
@event.listens_for(Engine, "connect")
|
||||
def set_sqlite_pragma(dbapi_connection: Any, connection_record: Any) -> None:
|
||||
try:
|
||||
cursor = dbapi_connection.cursor()
|
||||
cursor.execute("PRAGMA foreign_keys=ON")
|
||||
cursor.close()
|
||||
except Exception:
|
||||
# Some drivers / libSQL dialects might not support raw cursor PRAGMA
|
||||
pass
|
||||
|
||||
|
||||
def get_engine_url(url: str, auth_token: str | None = None) -> str:
|
||||
"""Normalize database URL for SQLAlchemy / SQLModel engine compatibility."""
|
||||
if url.startswith("file:"):
|
||||
db_path = url.removeprefix("file:")
|
||||
return f"sqlite:///{db_path}"
|
||||
if url.startswith("libsql://"):
|
||||
cleaned = url.removeprefix("libsql://")
|
||||
base = f"sqlite+libsql://{cleaned}"
|
||||
if auth_token and "auth_token=" not in base:
|
||||
sep = "&" if "?" in base else "?"
|
||||
return f"{base}{sep}auth_token={auth_token}"
|
||||
return base
|
||||
if url.startswith("sqlite+libsql://"):
|
||||
if auth_token and "auth_token=" not in url:
|
||||
sep = "&" if "?" in url else "?"
|
||||
return f"{url}{sep}auth_token={auth_token}"
|
||||
return url
|
||||
return url
|
||||
|
||||
|
||||
_engine_cache: dict[str, Engine] = {}
|
||||
|
||||
|
||||
def get_engine() -> Engine:
|
||||
"""Retrieve or create a cached SQLModel Engine based on current settings."""
|
||||
engine_url = get_engine_url(settings.database_url, settings.database_auth_token)
|
||||
if engine_url not in _engine_cache:
|
||||
connect_args: dict[str, Any] = {}
|
||||
if engine_url.startswith("sqlite:") and "+libsql" not in engine_url:
|
||||
connect_args["check_same_thread"] = False
|
||||
_engine_cache[engine_url] = create_engine(engine_url, connect_args=connect_args)
|
||||
return _engine_cache[engine_url]
|
||||
|
||||
|
||||
def get_session() -> Generator[Session]:
|
||||
"""Dependency yielding a SQLModel Session for synchronous and async endpoints."""
|
||||
engine = get_engine()
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
|
||||
|
||||
def get_client() -> libsql_client.Client:
|
||||
"""Create a new async Turso/libSQL client based on current settings."""
|
||||
if settings.database_url.startswith("file:"):
|
||||
|
||||
+18
-2
@@ -4,6 +4,7 @@ import asyncio
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
from app.core.config import settings
|
||||
from app.db.database import get_db
|
||||
|
||||
SCHEMA_FILE = Path(__file__).parent / "schema.sql"
|
||||
@@ -110,7 +111,7 @@ INITIAL_SERVICES = [
|
||||
"slug": "atencion-psicologica-individual",
|
||||
"name": "Atención Psicológica Individual",
|
||||
"description": "Sesión individual de psicoterapia personalizada (presencial u online).",
|
||||
"service_type": "ONE_ON_ONE",
|
||||
"service_type": "INDIVIDUAL",
|
||||
"modality": "PRESENCIAL",
|
||||
"default_schedule": "Con cita previa",
|
||||
"price_mxn": 600,
|
||||
@@ -122,7 +123,7 @@ INITIAL_SERVICES = [
|
||||
|
||||
|
||||
async def init_schema_and_seed():
|
||||
"""Execute DDL statements and seed initial flyer services."""
|
||||
"""Execute DDL statements and seed initial services and bootstrap administrators."""
|
||||
async with get_db() as client:
|
||||
with open(SCHEMA_FILE, encoding="utf-8") as f:
|
||||
ddl = f.read()
|
||||
@@ -131,6 +132,21 @@ async def init_schema_and_seed():
|
||||
for stmt in statements:
|
||||
await client.execute(stmt)
|
||||
|
||||
# Seed bootstrap administrators idempotently
|
||||
for idx, raw_email in enumerate(settings.admin_bootstrap_emails):
|
||||
email = raw_email.strip().lower()
|
||||
if not email:
|
||||
continue
|
||||
role = "OWNER" if idx == 0 else "ASSISTANT"
|
||||
full_name = settings.therapist_name if idx == 0 else "Asistente Armonía del Ser"
|
||||
await client.execute(
|
||||
"""
|
||||
INSERT OR IGNORE INTO admin_allowlist (email, full_name, role, is_active)
|
||||
VALUES (?, ?, ?, 1);
|
||||
""",
|
||||
[email, full_name, role],
|
||||
)
|
||||
|
||||
# Check if services already seeded
|
||||
res = await client.execute("SELECT COUNT(*) AS count FROM services;")
|
||||
count = res.rows[0][0]
|
||||
|
||||
+45
-8
@@ -1,11 +1,20 @@
|
||||
-- Armonía del Ser Database Schema (Turso / SQLite3)
|
||||
|
||||
CREATE TABLE IF NOT EXISTS admin_allowlist (
|
||||
email TEXT PRIMARY KEY,
|
||||
full_name TEXT NOT NULL,
|
||||
role TEXT NOT NULL DEFAULT 'ASSISTANT' CHECK (role IN ('OWNER', 'ASSISTANT', 'ADMIN')),
|
||||
is_active INTEGER NOT NULL DEFAULT 1,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
last_login_at TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS services (
|
||||
id TEXT PRIMARY KEY,
|
||||
slug TEXT UNIQUE NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
service_type TEXT NOT NULL CHECK (service_type IN ('GROUP', 'ONE_ON_ONE')),
|
||||
service_type TEXT NOT NULL CHECK (service_type IN ('GROUP', 'INDIVIDUAL')),
|
||||
modality TEXT NOT NULL CHECK (modality IN ('PRESENCIAL', 'ONLINE')),
|
||||
default_schedule TEXT,
|
||||
price_mxn INTEGER NOT NULL DEFAULT 0,
|
||||
@@ -47,12 +56,27 @@ CREATE TABLE IF NOT EXISTS bookings (
|
||||
scheduled_at TEXT NOT NULL,
|
||||
duration_minutes INTEGER NOT NULL DEFAULT 60,
|
||||
buffer_minutes INTEGER NOT NULL DEFAULT 0,
|
||||
status TEXT NOT NULL DEFAULT 'PENDING_PAYMENT' CHECK (status IN ('PENDING_PAYMENT', 'CONFIRMED', 'CANCELLED', 'EXPIRED', 'NO_SHOW')),
|
||||
booking_status TEXT NOT NULL DEFAULT 'RESERVED'
|
||||
CHECK (booking_status IN ('RESERVED', 'RELEASED', 'CANCELLED', 'COMPLETED', 'NO_SHOW')),
|
||||
payment_arrangement TEXT NOT NULL DEFAULT 'PREPAID_DEFAULT'
|
||||
CHECK (payment_arrangement IN ('PREPAID_DEFAULT', 'DELAYED_ALLOWED', 'PACKAGE_REDEEMED')),
|
||||
payment_status TEXT NOT NULL DEFAULT 'AWAITING_ACKNOWLEDGMENT'
|
||||
CHECK (payment_status IN ('AWAITING_ACKNOWLEDGMENT', 'ACKNOWLEDGED', 'NOT_APPLICABLE')),
|
||||
amount_mxn INTEGER NOT NULL,
|
||||
exception_authorized_by TEXT REFERENCES admin_allowlist(email),
|
||||
exception_authorized_at TEXT,
|
||||
exception_notes TEXT,
|
||||
released_by TEXT REFERENCES admin_allowlist(email),
|
||||
released_at TEXT,
|
||||
release_reason TEXT,
|
||||
acknowledged_by TEXT REFERENCES admin_allowlist(email),
|
||||
acknowledged_at TEXT,
|
||||
gcal_event_id TEXT,
|
||||
expires_at TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
confirmed_at TEXT
|
||||
gcal_sync_status TEXT NOT NULL DEFAULT 'PENDING'
|
||||
CHECK (gcal_sync_status IN ('PENDING', 'SYNCED', 'FAILED', 'NOT_CONFIGURED')),
|
||||
gcal_sync_error TEXT,
|
||||
gcal_synced_at TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS payments (
|
||||
@@ -60,16 +84,29 @@ CREATE TABLE IF NOT EXISTS payments (
|
||||
booking_id TEXT NOT NULL REFERENCES bookings(id),
|
||||
amount_mxn INTEGER NOT NULL,
|
||||
payment_method TEXT NOT NULL DEFAULT 'SPEI' CHECK (payment_method IN ('SPEI', 'OXXO', 'CASH')),
|
||||
status TEXT NOT NULL DEFAULT 'PENDING' CHECK (status IN ('PENDING', 'VERIFIED', 'REJECTED')),
|
||||
verified_at TEXT,
|
||||
status TEXT NOT NULL DEFAULT 'ACKNOWLEDGED' CHECK (status IN ('ACKNOWLEDGED', 'REVERSED')),
|
||||
acknowledged_by TEXT NOT NULL REFERENCES admin_allowlist(email),
|
||||
acknowledged_at TEXT NOT NULL,
|
||||
notes TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS admin_audit_log (
|
||||
id TEXT PRIMARY KEY,
|
||||
admin_email TEXT NOT NULL REFERENCES admin_allowlist(email),
|
||||
action_type TEXT NOT NULL,
|
||||
entity_type TEXT NOT NULL,
|
||||
entity_id TEXT NOT NULL,
|
||||
details_json TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_services_slug ON services(slug);
|
||||
CREATE INDEX IF NOT EXISTS idx_bookings_code ON bookings(booking_code);
|
||||
CREATE INDEX IF NOT EXISTS idx_bookings_status ON bookings(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_bookings_status ON bookings(booking_status);
|
||||
CREATE INDEX IF NOT EXISTS idx_bookings_payment_status ON bookings(payment_status);
|
||||
CREATE INDEX IF NOT EXISTS idx_bookings_scheduled ON bookings(scheduled_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_bookings_package ON bookings(package_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_clients_phone ON clients(phone_whatsapp);
|
||||
CREATE INDEX IF NOT EXISTS idx_packages_client ON packages(client_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_entity ON admin_audit_log(entity_type, entity_id);
|
||||
+21
-4
@@ -7,20 +7,33 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.core.config import settings
|
||||
from app.db.init_db import init_schema_and_seed
|
||||
from app.routers import bookings, health, packages, payments, services
|
||||
from app.routers import (
|
||||
auth,
|
||||
availability,
|
||||
bookings,
|
||||
clients,
|
||||
health,
|
||||
packages,
|
||||
payments,
|
||||
rosters,
|
||||
services,
|
||||
)
|
||||
|
||||
|
||||
@contextlib.asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# Ensure tables and initial catalog are seeded on boot
|
||||
# Ensure tables, bootstrap allowlist, and initial catalog are seeded on boot
|
||||
await init_schema_and_seed()
|
||||
yield
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title="Armonía del Ser API",
|
||||
description="Backend service for scheduling, calendar synchronization, and payment acknowledgment.",
|
||||
version="0.1.0",
|
||||
description=(
|
||||
"Operational source-of-truth backend sitting between Google Calendar, Turso, "
|
||||
"and the Admin Dashboard protected with Google OAuth + Turso allowlisting."
|
||||
),
|
||||
version="0.2.0",
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
@@ -35,7 +48,11 @@ app.add_middleware(
|
||||
|
||||
# Include Routers
|
||||
app.include_router(health.router)
|
||||
app.include_router(auth.router)
|
||||
app.include_router(services.router)
|
||||
app.include_router(availability.router)
|
||||
app.include_router(rosters.router)
|
||||
app.include_router(clients.router)
|
||||
app.include_router(bookings.router)
|
||||
app.include_router(packages.router)
|
||||
app.include_router(payments.router)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from app.models.admin import AdminAllowlist, AdminAuditLog
|
||||
from app.models.booking import Booking
|
||||
from app.models.client import Client
|
||||
from app.models.package import Package
|
||||
from app.models.payment import Payment
|
||||
from app.models.service import Service
|
||||
|
||||
__all__ = [
|
||||
"AdminAllowlist",
|
||||
"AdminAuditLog",
|
||||
"Booking",
|
||||
"Client",
|
||||
"Package",
|
||||
"Payment",
|
||||
"Service",
|
||||
]
|
||||
@@ -0,0 +1,77 @@
|
||||
import uuid
|
||||
from enum import StrEnum
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import BeforeValidator, EmailStr
|
||||
from sqlalchemy import Enum as SAEnum
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlmodel._compat import SQLModelConfig
|
||||
|
||||
from app.services.timestamps import utc_now_iso
|
||||
|
||||
|
||||
class RoleEnum(StrEnum):
|
||||
OWNER = "OWNER"
|
||||
ASSISTANT = "ASSISTANT"
|
||||
ADMIN = "ADMIN"
|
||||
|
||||
|
||||
UserRole = Annotated[RoleEnum, BeforeValidator(lambda v: RoleEnum(v) if isinstance(v, str) else v)]
|
||||
|
||||
|
||||
class AdminAllowlist(SQLModel, table=True):
|
||||
model_config = SQLModelConfig(strict=True)
|
||||
__tablename__ = "admin_allowlist" # pyright: ignore[reportAssignmentType]
|
||||
email: EmailStr = Field(primary_key=True)
|
||||
full_name: str
|
||||
role: UserRole = Field(default=RoleEnum.ASSISTANT)
|
||||
is_active: bool = Field(default=True)
|
||||
created_at: str = Field(default_factory=utc_now_iso)
|
||||
last_login_at: str | None = None
|
||||
|
||||
|
||||
class ActionTypeEnum(StrEnum):
|
||||
# Should we include DELETE/UPDATE_SERVICE?
|
||||
# Do all actions belong to this class?
|
||||
CREATE_PACKAGE = "CREATE_PACKAGE"
|
||||
UPDATE_PACKAGE = "UPDATE_PACKAGE"
|
||||
CREATE_SERVICE = "CREATE_SERVICE"
|
||||
ACKNOWLEDGE_PAYMENT = "ACKNOWLEDGE_PAYMENT"
|
||||
UPSERT_ALLOWLIST = "UPSERT_ALLOWLIST"
|
||||
UPDATE_ALLOWLIST = "UPDATE_ALLOWLIST"
|
||||
AUTHORIZE_DELAYED_PAYMENT = "AUTHORIZE_DELAYED_PAYMENT"
|
||||
UPDATE_BOOKING_STATUS = "UPDATE_BOOKING_STATUS"
|
||||
RELEASE_BOOKING = "RELEASE_BOOKING"
|
||||
RETRY_CALENDAR_SYNC = "RETRY_CALENDAR_SYNC"
|
||||
ROSTER_CHECKIN = "ROSTER_CHECKIN"
|
||||
ROSTER_WALK_IN = "ROSTER_WALK_IN"
|
||||
|
||||
|
||||
ActionType = Annotated[
|
||||
ActionTypeEnum, BeforeValidator(lambda v: ActionTypeEnum(v) if isinstance(v, str) else v)
|
||||
]
|
||||
|
||||
|
||||
class EntityTypeEnum(StrEnum):
|
||||
ADMIN_ALLOW_LIST = "admin_allow_list"
|
||||
BOOKING = "booking"
|
||||
PACKAGE = "package"
|
||||
|
||||
|
||||
EntityType = Annotated[
|
||||
EntityTypeEnum, BeforeValidator(lambda v: EntityTypeEnum(v) if isinstance(v, str) else v)
|
||||
]
|
||||
|
||||
|
||||
class AdminAuditLog(SQLModel, table=True):
|
||||
model_config = SQLModelConfig(strict=True)
|
||||
__tablename__ = "admin_audit_log" # pyright: ignore[reportAssignmentType]
|
||||
id: str = Field(default_factory=lambda: str(uuid.uuid4()), primary_key=True)
|
||||
admin_email: EmailStr = Field(foreign_key="admin_allowlist.email")
|
||||
action_type: ActionType
|
||||
entity_type: EntityType = Field(
|
||||
sa_type=SAEnum(EntityTypeEnum, values_callable=lambda x: [e.value for e in x])
|
||||
)
|
||||
entity_id: str
|
||||
details_json: str | None = None
|
||||
created_at: str = Field(default_factory=utc_now_iso)
|
||||
@@ -0,0 +1,90 @@
|
||||
import uuid
|
||||
from enum import StrEnum
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import BeforeValidator
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlmodel._compat import SQLModelConfig
|
||||
|
||||
from app.services.timestamps import utc_now_iso
|
||||
|
||||
|
||||
class BookingStatusEnum(StrEnum):
|
||||
RESERVED = "RESERVED"
|
||||
RELEASED = "RELEASED"
|
||||
CANCELLED = "CANCELLED"
|
||||
COMPLETED = "COMPLETED"
|
||||
NO_SHOW = "NO_SHOW"
|
||||
|
||||
|
||||
class PaymentArrangementEnum(StrEnum):
|
||||
PREPAID_DEFAULT = "PREPAID_DEFAULT"
|
||||
DELAYED_ALLOWED = "DELAYED_ALLOWED"
|
||||
PACKAGE_REDEEMED = "PACKAGE_REDEEMED"
|
||||
|
||||
|
||||
class BookingPaymentStatusEnum(StrEnum):
|
||||
AWAITING_ACKNOWLEDGMENT = "AWAITING_ACKNOWLEDGMENT"
|
||||
ACKNOWLEDGED = "ACKNOWLEDGED"
|
||||
NOT_APPLICABLE = "NOT_APPLICABLE"
|
||||
|
||||
|
||||
class GcalSyncStatusEnum(StrEnum):
|
||||
PENDING = "PENDING"
|
||||
SYNCED = "SYNCED"
|
||||
FAILED = "FAILED"
|
||||
NOT_CONFIGURED = "NOT_CONFIGURED"
|
||||
|
||||
|
||||
BookingStatus = Annotated[
|
||||
BookingStatusEnum,
|
||||
BeforeValidator(lambda v: BookingStatusEnum(v) if isinstance(v, str) else v),
|
||||
]
|
||||
|
||||
PaymentArrangement = Annotated[
|
||||
PaymentArrangementEnum,
|
||||
BeforeValidator(lambda v: PaymentArrangementEnum(v) if isinstance(v, str) else v),
|
||||
]
|
||||
|
||||
BookingPaymentStatus = Annotated[
|
||||
BookingPaymentStatusEnum,
|
||||
BeforeValidator(lambda v: BookingPaymentStatusEnum(v) if isinstance(v, str) else v),
|
||||
]
|
||||
|
||||
GcalSyncStatus = Annotated[
|
||||
GcalSyncStatusEnum,
|
||||
BeforeValidator(lambda v: GcalSyncStatusEnum(v) if isinstance(v, str) else v),
|
||||
]
|
||||
|
||||
|
||||
class Booking(SQLModel, table=True):
|
||||
model_config = SQLModelConfig(strict=True)
|
||||
__tablename__ = "bookings" # pyright: ignore[reportAssignmentType]
|
||||
|
||||
id: str = Field(default_factory=lambda: str(uuid.uuid4()), primary_key=True)
|
||||
booking_code: str = Field(unique=True, index=True)
|
||||
service_id: str = Field(foreign_key="services.id")
|
||||
client_id: str = Field(foreign_key="clients.id")
|
||||
package_id: str | None = Field(default=None, foreign_key="packages.id", index=True)
|
||||
scheduled_at: str = Field(index=True)
|
||||
duration_minutes: int = Field(default=60, ge=15)
|
||||
buffer_minutes: int = Field(default=0, ge=0)
|
||||
booking_status: BookingStatus = Field(default=BookingStatusEnum.RESERVED, index=True)
|
||||
payment_arrangement: PaymentArrangement = Field(default=PaymentArrangementEnum.PREPAID_DEFAULT)
|
||||
payment_status: BookingPaymentStatus = Field(
|
||||
default=BookingPaymentStatusEnum.AWAITING_ACKNOWLEDGMENT, index=True
|
||||
)
|
||||
amount_mxn: int = Field(ge=0)
|
||||
exception_authorized_by: str | None = Field(default=None, foreign_key="admin_allowlist.email")
|
||||
exception_authorized_at: str | None = None
|
||||
exception_notes: str | None = None
|
||||
released_by: str | None = Field(default=None, foreign_key="admin_allowlist.email")
|
||||
released_at: str | None = None
|
||||
release_reason: str | None = None
|
||||
acknowledged_by: str | None = Field(default=None, foreign_key="admin_allowlist.email")
|
||||
acknowledged_at: str | None = None
|
||||
gcal_event_id: str | None = None
|
||||
gcal_sync_status: GcalSyncStatus = Field(default=GcalSyncStatusEnum.PENDING)
|
||||
gcal_sync_error: str | None = None
|
||||
gcal_synced_at: str | None = None
|
||||
created_at: str = Field(default_factory=utc_now_iso)
|
||||
@@ -0,0 +1,37 @@
|
||||
import re
|
||||
import uuid
|
||||
|
||||
from pydantic import EmailStr, field_validator
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlmodel._compat import SQLModelConfig
|
||||
|
||||
from app.services.timestamps import utc_now_iso
|
||||
|
||||
|
||||
class Client(SQLModel, table=True):
|
||||
model_config = SQLModelConfig(strict=True)
|
||||
__tablename__ = "clients" # pyright: ignore[reportAssignmentType]
|
||||
id: str = Field(default_factory=lambda: str(uuid.uuid4()), primary_key=True)
|
||||
full_name: str
|
||||
phone_whatsapp: str = Field(index=True)
|
||||
email: EmailStr | None = None
|
||||
notes: str | None = None
|
||||
created_at: str = Field(default_factory=utc_now_iso)
|
||||
|
||||
@field_validator("phone_whatsapp")
|
||||
@classmethod
|
||||
def validate_phone_number(cls, v: str) -> str:
|
||||
PHONE_WITH_EXT_REGEX = re.compile(
|
||||
r"^((?:\+?\d{1,3}[-.\s]?)?(?:\(?\d{2,4}\)?[-.\s]?){2,4}\d{3,4})(?:[-.\s]*(?:ext|ext\.|x|#|extension)[-.\s]*(\d+))?$",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
clean_value = v.strip()
|
||||
|
||||
match_value = PHONE_WITH_EXT_REGEX.match(clean_value)
|
||||
if not match_value:
|
||||
raise ValueError(
|
||||
"Invalid phone number format. Examples of valid formats: "
|
||||
"'+1 (555) 019-2834', '555-019-2834 ext 123', or '5550192834x12'"
|
||||
)
|
||||
return clean_value
|
||||
@@ -0,0 +1,37 @@
|
||||
import uuid
|
||||
from enum import StrEnum
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import BeforeValidator
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlmodel._compat import SQLModelConfig
|
||||
|
||||
from app.services.timestamps import utc_now_iso
|
||||
|
||||
|
||||
class FinancialStatusEnum(StrEnum):
|
||||
PAID = "PAID"
|
||||
PARTIAL = "PARTIAL"
|
||||
PENDING = "PENDING"
|
||||
|
||||
|
||||
FinancialStatus = Annotated[
|
||||
FinancialStatusEnum,
|
||||
BeforeValidator(lambda v: FinancialStatusEnum(v) if isinstance(v, str) else v),
|
||||
]
|
||||
|
||||
|
||||
class Package(SQLModel, table=True):
|
||||
model_config = SQLModelConfig(strict=True)
|
||||
__tablename__ = "packages" # pyright: ignore[reportAssignmentType]
|
||||
|
||||
id: str = Field(default_factory=lambda: str(uuid.uuid4()), primary_key=True)
|
||||
client_id: str = Field(foreign_key="clients.id", index=True)
|
||||
service_id: str = Field(foreign_key="services.id")
|
||||
total_sessions: int = Field(gt=0)
|
||||
completed_sessions: int = Field(default=0, ge=0)
|
||||
price_paid_mxn: int = Field(default=0, ge=0)
|
||||
financial_status: FinancialStatus = Field(default=FinancialStatusEnum.PENDING)
|
||||
notes: str | None = None
|
||||
created_at: str = Field(default_factory=utc_now_iso)
|
||||
updated_at: str = Field(default_factory=utc_now_iso)
|
||||
@@ -0,0 +1,46 @@
|
||||
import uuid
|
||||
from enum import StrEnum
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import BeforeValidator
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlmodel._compat import SQLModelConfig
|
||||
|
||||
from app.services.timestamps import utc_now_iso
|
||||
|
||||
|
||||
class PaymentMethodEnum(StrEnum):
|
||||
SPEI = "SPEI"
|
||||
OXXO = "OXXO"
|
||||
CASH = "CASH"
|
||||
|
||||
|
||||
class PaymentStatusEnum(StrEnum):
|
||||
ACKNOWLEDGED = "ACKNOWLEDGED"
|
||||
REVERSED = "REVERSED"
|
||||
|
||||
|
||||
PaymentMethod = Annotated[
|
||||
PaymentMethodEnum,
|
||||
BeforeValidator(lambda v: PaymentMethodEnum(v) if isinstance(v, str) else v),
|
||||
]
|
||||
|
||||
PaymentStatus = Annotated[
|
||||
PaymentStatusEnum,
|
||||
BeforeValidator(lambda v: PaymentStatusEnum(v) if isinstance(v, str) else v),
|
||||
]
|
||||
|
||||
|
||||
class Payment(SQLModel, table=True):
|
||||
model_config = SQLModelConfig(strict=True)
|
||||
__tablename__ = "payments" # pyright: ignore[reportAssignmentType]
|
||||
|
||||
id: str = Field(default_factory=lambda: str(uuid.uuid4()), primary_key=True)
|
||||
booking_id: str = Field(foreign_key="bookings.id")
|
||||
amount_mxn: int = Field(ge=0)
|
||||
payment_method: PaymentMethod = Field(default=PaymentMethodEnum.SPEI)
|
||||
status: PaymentStatus = Field(default=PaymentStatusEnum.ACKNOWLEDGED)
|
||||
acknowledged_by: str = Field(foreign_key="admin_allowlist.email")
|
||||
acknowledged_at: str
|
||||
notes: str | None = None
|
||||
created_at: str = Field(default_factory=utc_now_iso)
|
||||
@@ -0,0 +1,46 @@
|
||||
from enum import StrEnum
|
||||
from typing import Annotated
|
||||
|
||||
from pydantic import BeforeValidator
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlmodel._compat import SQLModelConfig
|
||||
|
||||
from app.services.timestamps import utc_now_iso
|
||||
|
||||
|
||||
class ServiceTypeEnum(StrEnum):
|
||||
GROUP = "GROUP"
|
||||
INDIVIDUAL = "INDIVIDUAL"
|
||||
|
||||
|
||||
class ServiceModalityEnum(StrEnum):
|
||||
PRESENCIAL = "PRESENCIAL"
|
||||
ONLINE = "ONLINE"
|
||||
|
||||
|
||||
ServiceType = Annotated[
|
||||
ServiceTypeEnum, BeforeValidator(lambda v: ServiceTypeEnum(v) if isinstance(v, str) else v)
|
||||
]
|
||||
|
||||
ServiceModality = Annotated[
|
||||
ServiceModalityEnum,
|
||||
BeforeValidator(lambda v: ServiceModalityEnum(v) if isinstance(v, str) else v),
|
||||
]
|
||||
|
||||
|
||||
class Service(SQLModel, table=True):
|
||||
model_config = SQLModelConfig(strict=True)
|
||||
__tablename__ = "services" # pyright: ignore[reportAssignmentType]
|
||||
id: str | None = Field(default=None, primary_key=True)
|
||||
slug: str = Field(unique=True, index=True)
|
||||
name: str
|
||||
description: str | None = None
|
||||
service_type: ServiceType
|
||||
modality: ServiceModality
|
||||
default_schedule: str | None = None
|
||||
price_mxn: int = Field(default=0, ge=0)
|
||||
max_capacity: int = Field(default=1, ge=1)
|
||||
duration_minutes: int = Field(default=60, ge=15)
|
||||
buffer_minutes: int = Field(default=15, ge=0)
|
||||
is_active: bool = Field(default=True)
|
||||
created_at: str = Field(default_factory=utc_now_iso)
|
||||
@@ -0,0 +1 @@
|
||||
"""Persistence boundary for repositories built on SQLModel sessions."""
|
||||
@@ -0,0 +1,35 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy.dialects.sqlite import insert as sqlite_insert
|
||||
from sqlmodel import Session
|
||||
|
||||
from app.models.admin import AdminAllowlist
|
||||
from app.services.timestamps import utc_now_iso
|
||||
|
||||
|
||||
def mirror_admin_actor(session: Session, *, email: str, full_name: str, role: str) -> None:
|
||||
"""
|
||||
Upsert an externally-authenticated actor (e.g. Authelia proxy user) into `admin_allowlist`
|
||||
so that actor columns (`admin_audit_log.admin_email`, `payments.acknowledged_by`, ...) keep
|
||||
referential integrity (ADR-0006).
|
||||
|
||||
The identity provider is authoritative for name and role, so both are refreshed on every
|
||||
write. `is_active` is deliberately left untouched on conflict: mirroring records who acted,
|
||||
it never re-enables a row an operator disabled.
|
||||
"""
|
||||
now = utc_now_iso()
|
||||
table = AdminAllowlist.__table__ # pyright: ignore[reportAttributeAccessIssue]
|
||||
stmt = sqlite_insert(table).values(
|
||||
email=email,
|
||||
full_name=full_name,
|
||||
role=role,
|
||||
is_active=True,
|
||||
created_at=now,
|
||||
last_login_at=now,
|
||||
)
|
||||
stmt = stmt.on_conflict_do_update(
|
||||
index_elements=[table.c.email],
|
||||
set_={"full_name": full_name, "role": role, "last_login_at": now},
|
||||
)
|
||||
session.exec(stmt) # pyright: ignore[reportCallIssue, reportArgumentType]
|
||||
session.commit()
|
||||
@@ -0,0 +1,265 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
import libsql_client
|
||||
|
||||
from app.db.database import result_to_dicts, row_to_dict
|
||||
from app.schemas.client import Client360Read, ClientCreate, ClientRead, ClientUpdate
|
||||
from app.schemas.package import PackageRead
|
||||
from app.services.bookings import hydrate_booking_row
|
||||
from app.services.timestamps import utc_now_iso
|
||||
|
||||
|
||||
def _hydrate_client(row: dict[str, Any]) -> ClientRead:
|
||||
return ClientRead(
|
||||
id=str(row["id"]),
|
||||
full_name=str(row["full_name"]),
|
||||
phone_whatsapp=str(row["phone_whatsapp"]),
|
||||
email=row.get("email"),
|
||||
notes=row.get("notes"),
|
||||
created_at=str(row["created_at"]),
|
||||
)
|
||||
|
||||
|
||||
def _hydrate_package(r: dict[str, Any]) -> PackageRead:
|
||||
total = int(r["total_sessions"])
|
||||
completed = int(r.get("completed_sessions", 0))
|
||||
return PackageRead(
|
||||
id=str(r["id"]),
|
||||
client_id=str(r["client_id"]),
|
||||
client_name=r.get("client_name"),
|
||||
client_phone=r.get("client_phone"),
|
||||
service_id=str(r["service_id"]),
|
||||
service_name=r.get("service_name"),
|
||||
total_sessions=total,
|
||||
completed_sessions=completed,
|
||||
remaining_sessions=max(0, total - completed),
|
||||
price_paid_mxn=int(r.get("price_paid_mxn", 0)),
|
||||
financial_status=r.get("financial_status", "PENDING"),
|
||||
notes=r.get("notes"),
|
||||
created_at=str(r["created_at"]),
|
||||
updated_at=str(r["updated_at"]),
|
||||
)
|
||||
|
||||
|
||||
async def list_and_search_clients(
|
||||
client: libsql_client.Client,
|
||||
*,
|
||||
search: str | None = None,
|
||||
limit: int = 50,
|
||||
offset: int = 0,
|
||||
) -> list[ClientRead]:
|
||||
"""
|
||||
List and search clients with optional case-insensitive matching on full_name and phone_whatsapp.
|
||||
Supports limit and offset pagination.
|
||||
"""
|
||||
params: list[libsql_client.InValue] = []
|
||||
query = "SELECT id, full_name, phone_whatsapp, email, notes, created_at FROM clients"
|
||||
|
||||
if search and search.strip():
|
||||
term = search.strip()
|
||||
query += " WHERE LOWER(full_name) LIKE ? OR phone_whatsapp LIKE ?"
|
||||
params.extend([f"%{term.lower()}%", f"%{term}%"])
|
||||
|
||||
query += " ORDER BY full_name ASC LIMIT ? OFFSET ?;"
|
||||
params.extend([limit, offset])
|
||||
|
||||
res = await client.execute(query, params)
|
||||
rows = result_to_dicts(res)
|
||||
return [_hydrate_client(r) for r in rows]
|
||||
|
||||
|
||||
async def get_client_by_id(
|
||||
client: libsql_client.Client,
|
||||
client_id: str,
|
||||
) -> ClientRead | None:
|
||||
"""Retrieve client details by unique ID."""
|
||||
res = await client.execute(
|
||||
"SELECT id, full_name, phone_whatsapp, email, notes, created_at FROM clients WHERE id = ? LIMIT 1;",
|
||||
[client_id],
|
||||
)
|
||||
if not res.rows:
|
||||
return None
|
||||
return _hydrate_client(row_to_dict(res, res.rows[0]))
|
||||
|
||||
|
||||
async def get_client_by_phone(
|
||||
client: libsql_client.Client,
|
||||
phone: str,
|
||||
*,
|
||||
exclude_id: str | None = None,
|
||||
) -> ClientRead | None:
|
||||
"""Find a client matching the given phone number, optionally excluding a specific client ID."""
|
||||
clean_phone = phone.strip()
|
||||
query = "SELECT id, full_name, phone_whatsapp, email, notes, created_at FROM clients WHERE phone_whatsapp = ?"
|
||||
params: list[libsql_client.InValue] = [clean_phone]
|
||||
if exclude_id:
|
||||
query += " AND id != ?"
|
||||
params.append(exclude_id)
|
||||
query += " LIMIT 1;"
|
||||
|
||||
res = await client.execute(query, params)
|
||||
if not res.rows:
|
||||
return None
|
||||
return _hydrate_client(row_to_dict(res, res.rows[0]))
|
||||
|
||||
|
||||
async def create_client(
|
||||
client: libsql_client.Client,
|
||||
payload: ClientCreate,
|
||||
) -> ClientRead:
|
||||
"""Persist a new client record."""
|
||||
client_id = str(uuid.uuid4())
|
||||
now = utc_now_iso()
|
||||
await client.execute(
|
||||
"""
|
||||
INSERT INTO clients (id, full_name, phone_whatsapp, email, notes, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?);
|
||||
""",
|
||||
[
|
||||
client_id,
|
||||
payload.full_name.strip(),
|
||||
payload.phone_whatsapp.strip(),
|
||||
str(payload.email) if payload.email else None,
|
||||
payload.notes,
|
||||
now,
|
||||
],
|
||||
)
|
||||
return ClientRead(
|
||||
id=client_id,
|
||||
full_name=payload.full_name.strip(),
|
||||
phone_whatsapp=payload.phone_whatsapp.strip(),
|
||||
email=payload.email,
|
||||
notes=payload.notes,
|
||||
created_at=now,
|
||||
)
|
||||
|
||||
|
||||
async def update_client(
|
||||
client: libsql_client.Client,
|
||||
client_id: str,
|
||||
payload: ClientUpdate,
|
||||
) -> ClientRead | None:
|
||||
"""Update mutable client fields."""
|
||||
existing = await get_client_by_id(client, client_id)
|
||||
if not existing:
|
||||
return None
|
||||
|
||||
updates: list[str] = []
|
||||
params: list[libsql_client.InValue] = []
|
||||
|
||||
if payload.full_name is not None:
|
||||
updates.append("full_name = ?")
|
||||
params.append(payload.full_name.strip())
|
||||
if payload.phone_whatsapp is not None:
|
||||
updates.append("phone_whatsapp = ?")
|
||||
params.append(payload.phone_whatsapp.strip())
|
||||
if payload.email is not None:
|
||||
updates.append("email = ?")
|
||||
params.append(str(payload.email))
|
||||
if payload.notes is not None:
|
||||
updates.append("notes = ?")
|
||||
params.append(payload.notes)
|
||||
|
||||
if not updates:
|
||||
return existing
|
||||
|
||||
params.append(client_id)
|
||||
query = f"UPDATE clients SET {', '.join(updates)} WHERE id = ?;"
|
||||
await client.execute(query, params)
|
||||
return await get_client_by_id(client, client_id)
|
||||
|
||||
|
||||
async def get_client_dependencies(
|
||||
client: libsql_client.Client,
|
||||
client_id: str,
|
||||
) -> dict[str, int]:
|
||||
"""Check how many bookings and packages reference this client."""
|
||||
b_res = await client.execute(
|
||||
"SELECT COUNT(*) FROM bookings WHERE client_id = ?;",
|
||||
[client_id],
|
||||
)
|
||||
bookings_count = int(str(b_res.rows[0][0] or 0)) if b_res.rows else 0
|
||||
|
||||
p_res = await client.execute(
|
||||
"SELECT COUNT(*) FROM packages WHERE client_id = ?;",
|
||||
[client_id],
|
||||
)
|
||||
packages_count = int(str(p_res.rows[0][0] or 0)) if p_res.rows else 0
|
||||
|
||||
return {
|
||||
"bookings_count": bookings_count,
|
||||
"packages_count": packages_count,
|
||||
}
|
||||
|
||||
|
||||
async def delete_client(
|
||||
client: libsql_client.Client,
|
||||
client_id: str,
|
||||
) -> None:
|
||||
"""Delete client row from database."""
|
||||
await client.execute("DELETE FROM clients WHERE id = ?;", [client_id])
|
||||
|
||||
|
||||
async def get_client_360_profile(
|
||||
client: libsql_client.Client,
|
||||
client_id: str,
|
||||
) -> Client360Read | None:
|
||||
"""
|
||||
Retrieve comprehensive 360-degree client profile containing contact info,
|
||||
active multi-session packages, and full booking history.
|
||||
"""
|
||||
c_res = await client.execute(
|
||||
"SELECT id, full_name, phone_whatsapp, email, notes, created_at FROM clients WHERE id = ? LIMIT 1;",
|
||||
[client_id],
|
||||
)
|
||||
if not c_res.rows:
|
||||
return None
|
||||
c_dict = row_to_dict(c_res, c_res.rows[0])
|
||||
|
||||
# Active packages (where completed_sessions < total_sessions)
|
||||
pkg_query = """
|
||||
SELECT p.*, c.full_name AS client_name, c.phone_whatsapp AS client_phone, s.name AS service_name
|
||||
FROM packages p
|
||||
JOIN clients c ON p.client_id = c.id
|
||||
JOIN services s ON p.service_id = s.id
|
||||
WHERE p.client_id = ? AND p.completed_sessions < p.total_sessions
|
||||
ORDER BY p.created_at DESC;
|
||||
"""
|
||||
pkg_res = await client.execute(pkg_query, [client_id])
|
||||
active_packages = [_hydrate_package(r) for r in result_to_dicts(pkg_res)]
|
||||
|
||||
# Recent booking history
|
||||
booking_query = """
|
||||
SELECT
|
||||
b.id, b.booking_code, b.service_id, s.name AS service_name,
|
||||
b.client_id, c.full_name AS client_name, c.phone_whatsapp AS client_phone,
|
||||
b.package_id, b.scheduled_at, b.duration_minutes, b.buffer_minutes,
|
||||
b.booking_status, b.payment_arrangement, b.payment_status, b.amount_mxn,
|
||||
b.exception_authorized_by, b.exception_authorized_at, b.exception_notes,
|
||||
b.released_by, b.released_at, b.release_reason,
|
||||
b.acknowledged_by, b.acknowledged_at,
|
||||
b.gcal_event_id, b.gcal_sync_status, b.gcal_sync_error, b.gcal_synced_at,
|
||||
b.created_at
|
||||
FROM bookings b
|
||||
JOIN services s ON b.service_id = s.id
|
||||
JOIN clients c ON b.client_id = c.id
|
||||
WHERE b.client_id = ?
|
||||
ORDER BY b.scheduled_at DESC;
|
||||
"""
|
||||
b_res = await client.execute(booking_query, [client_id])
|
||||
bookings = [hydrate_booking_row(r) for r in result_to_dicts(b_res)]
|
||||
|
||||
return Client360Read(
|
||||
id=str(c_dict["id"]),
|
||||
full_name=str(c_dict["full_name"]),
|
||||
phone_whatsapp=str(c_dict["phone_whatsapp"]),
|
||||
email=c_dict.get("email"),
|
||||
notes=c_dict.get("notes"),
|
||||
created_at=str(c_dict["created_at"]),
|
||||
active_packages=active_packages,
|
||||
booking_history=bookings,
|
||||
recent_bookings=bookings,
|
||||
)
|
||||
@@ -0,0 +1,320 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hmac
|
||||
import secrets
|
||||
import urllib.parse
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import httpx
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, Response, status
|
||||
from fastapi.responses import RedirectResponse
|
||||
|
||||
from app.core.auth import (
|
||||
OAUTH_STATE_COOKIE_NAME,
|
||||
SESSION_COOKIE_NAME,
|
||||
create_session_token,
|
||||
get_allowlisted_admin,
|
||||
record_admin_audit,
|
||||
require_admin,
|
||||
)
|
||||
from app.core.config import settings
|
||||
from app.db.database import get_db, result_to_dicts, row_to_dict
|
||||
from app.schemas.auth import (
|
||||
AdminAllowlistCreate,
|
||||
AdminAllowlistUpdate,
|
||||
AdminPrincipal,
|
||||
AuditLogRead,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix="/auth", tags=["Authentication & Admin Allowlist"])
|
||||
|
||||
GOOGLE_AUTH_ENDPOINT = "https://accounts.google.com/o/oauth2/v2/auth"
|
||||
GOOGLE_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token"
|
||||
GOOGLE_USERINFO_ENDPOINT = "https://openidconnect.googleapis.com/v1/userinfo"
|
||||
|
||||
|
||||
@router.get("/google/login")
|
||||
async def google_oauth_login():
|
||||
"""
|
||||
Initiate backend-driven Google OAuth2 Authorization Code flow.
|
||||
Redirects the administrator to Google's consent screen with a signed CSRF state cookie.
|
||||
"""
|
||||
if not settings.google_oauth_client_id or not settings.google_oauth_client_secret:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Google OAuth credentials are not configured on the backend.",
|
||||
)
|
||||
|
||||
state = secrets.token_urlsafe(32)
|
||||
params = {
|
||||
"client_id": settings.google_oauth_client_id,
|
||||
"redirect_uri": settings.google_oauth_redirect_uri,
|
||||
"response_type": "code",
|
||||
"scope": "openid email profile",
|
||||
"state": state,
|
||||
"prompt": "select_account",
|
||||
}
|
||||
url = f"{GOOGLE_AUTH_ENDPOINT}?{urllib.parse.urlencode(params)}"
|
||||
response = RedirectResponse(url=url, status_code=status.HTTP_302_FOUND)
|
||||
response.set_cookie(
|
||||
key=OAUTH_STATE_COOKIE_NAME,
|
||||
value=state,
|
||||
httponly=True,
|
||||
secure=settings.environment == "production",
|
||||
samesite="lax",
|
||||
max_age=600,
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
@router.get("/google/callback")
|
||||
async def google_oauth_callback(
|
||||
request: Request,
|
||||
code: str | None = None,
|
||||
state: str | None = None,
|
||||
):
|
||||
"""
|
||||
Google OAuth2 callback:
|
||||
1. Validates CSRF state cookie.
|
||||
2. Exchanges authorization code for tokens on the server.
|
||||
3. Verifies Google userinfo (email_verified == True).
|
||||
4. Checks email against Turso's admin_allowlist table.
|
||||
5. Issues an HttpOnly signed session cookie and redirects to armonia-dashboard.
|
||||
"""
|
||||
if not code or not state:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Missing code or state parameter in OAuth callback.",
|
||||
)
|
||||
|
||||
expected_state = request.cookies.get(OAUTH_STATE_COOKIE_NAME)
|
||||
if not expected_state or not hmac.compare_digest(expected_state, state):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Invalid or expired OAuth state parameter.",
|
||||
)
|
||||
|
||||
if not settings.google_oauth_client_id or not settings.google_oauth_client_secret:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Google OAuth credentials are not configured.",
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(timeout=10.0) as http_client:
|
||||
token_res = await http_client.post(
|
||||
GOOGLE_TOKEN_ENDPOINT,
|
||||
data={
|
||||
"code": code,
|
||||
"client_id": settings.google_oauth_client_id,
|
||||
"client_secret": settings.google_oauth_client_secret,
|
||||
"redirect_uri": settings.google_oauth_redirect_uri,
|
||||
"grant_type": "authorization_code",
|
||||
},
|
||||
)
|
||||
if token_res.status_code != 200:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Failed to exchange Google OAuth authorization code.",
|
||||
)
|
||||
token_data = token_res.json()
|
||||
access_token = token_data.get("access_token")
|
||||
if not access_token:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Google OAuth response did not include an access token.",
|
||||
)
|
||||
|
||||
userinfo_res = await http_client.get(
|
||||
GOOGLE_USERINFO_ENDPOINT,
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
)
|
||||
if userinfo_res.status_code != 200:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Failed to fetch verified user profile from Google.",
|
||||
)
|
||||
userinfo = userinfo_res.json()
|
||||
|
||||
email = str(userinfo.get("email", "")).strip().lower()
|
||||
email_verified = bool(userinfo.get("email_verified", False))
|
||||
if not email or not email_verified:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Google account email is missing or not verified.",
|
||||
)
|
||||
|
||||
async with get_db() as client:
|
||||
principal = await get_allowlisted_admin(client, email)
|
||||
if not principal:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=f"El correo '{email}' no está en la lista de administradores autorizados.",
|
||||
)
|
||||
now = datetime.now(UTC).isoformat()
|
||||
await client.execute(
|
||||
"UPDATE admin_allowlist SET last_login_at = ? WHERE lower(email) = ?;",
|
||||
[now, email],
|
||||
)
|
||||
|
||||
session_token = create_session_token(principal.email)
|
||||
redirect = RedirectResponse(
|
||||
url=settings.dashboard_origin_url, status_code=status.HTTP_302_FOUND
|
||||
)
|
||||
redirect.delete_cookie(OAUTH_STATE_COOKIE_NAME)
|
||||
redirect.set_cookie(
|
||||
key=SESSION_COOKIE_NAME,
|
||||
value=session_token,
|
||||
httponly=True,
|
||||
secure=settings.environment == "production",
|
||||
samesite="lax",
|
||||
max_age=settings.session_ttl_seconds,
|
||||
)
|
||||
return redirect
|
||||
|
||||
|
||||
@router.get("/me", response_model=AdminPrincipal)
|
||||
async def get_current_admin(admin: AdminPrincipal = Depends(require_admin)):
|
||||
"""Return the currently authenticated and allowlisted administrator."""
|
||||
return admin
|
||||
|
||||
|
||||
@router.post("/logout", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def logout(response: Response):
|
||||
"""Clear the administrator session cookie."""
|
||||
response.delete_cookie(SESSION_COOKIE_NAME)
|
||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
@router.get("/allowlist", response_model=list[AdminPrincipal])
|
||||
async def list_allowlist(admin: AdminPrincipal = Depends(require_admin)):
|
||||
"""List all administrator entries in Turso's admin_allowlist table."""
|
||||
async with get_db() as client:
|
||||
res = await client.execute(
|
||||
"SELECT email, full_name, role, is_active, last_login_at FROM admin_allowlist ORDER BY created_at ASC;"
|
||||
)
|
||||
rows = result_to_dicts(res)
|
||||
return [
|
||||
AdminPrincipal(
|
||||
email=str(r["email"]),
|
||||
full_name=str(r["full_name"]),
|
||||
role=r["role"],
|
||||
is_active=bool(r.get("is_active", 0)),
|
||||
last_login_at=r.get("last_login_at"),
|
||||
)
|
||||
for r in rows
|
||||
]
|
||||
|
||||
|
||||
@router.post("/allowlist", response_model=AdminPrincipal, status_code=status.HTTP_201_CREATED)
|
||||
async def add_to_allowlist(
|
||||
payload: AdminAllowlistCreate,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Add or reactivate an administrator in Turso's admin_allowlist table."""
|
||||
normalized_email = payload.email.strip().lower()
|
||||
async with get_db() as client:
|
||||
await client.execute(
|
||||
"""
|
||||
INSERT INTO admin_allowlist (email, full_name, role, is_active)
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT(email) DO UPDATE SET
|
||||
full_name = excluded.full_name,
|
||||
role = excluded.role,
|
||||
is_active = excluded.is_active;
|
||||
""",
|
||||
[normalized_email, payload.full_name, payload.role, 1 if payload.is_active else 0],
|
||||
)
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="UPSERT_ALLOWLIST",
|
||||
entity_type="admin_allowlist",
|
||||
entity_id=normalized_email,
|
||||
details={"role": payload.role, "is_active": payload.is_active},
|
||||
)
|
||||
res = await client.execute(
|
||||
"SELECT email, full_name, role, is_active, last_login_at FROM admin_allowlist WHERE email = ? LIMIT 1;",
|
||||
[normalized_email],
|
||||
)
|
||||
r = row_to_dict(res, res.rows[0])
|
||||
return AdminPrincipal(
|
||||
email=str(r["email"]),
|
||||
full_name=str(r["full_name"]),
|
||||
role=r["role"],
|
||||
is_active=bool(r.get("is_active", 0)),
|
||||
last_login_at=r.get("last_login_at"),
|
||||
)
|
||||
|
||||
|
||||
@router.patch("/allowlist/{email}", response_model=AdminPrincipal)
|
||||
async def update_allowlist_entry(
|
||||
email: str,
|
||||
payload: AdminAllowlistUpdate,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Update role, name, or active status for an administrator in Turso."""
|
||||
normalized_email = email.strip().lower()
|
||||
async with get_db() as client:
|
||||
res = await client.execute(
|
||||
"SELECT * FROM admin_allowlist WHERE lower(email) = ? LIMIT 1;",
|
||||
[normalized_email],
|
||||
)
|
||||
if not res.rows:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Administrator email not found in allowlist.",
|
||||
)
|
||||
current = row_to_dict(res, res.rows[0])
|
||||
new_name = payload.full_name if payload.full_name is not None else current["full_name"]
|
||||
new_role = payload.role if payload.role is not None else current["role"]
|
||||
new_active = (
|
||||
(1 if payload.is_active else 0)
|
||||
if payload.is_active is not None
|
||||
else int(current["is_active"])
|
||||
)
|
||||
|
||||
await client.execute(
|
||||
"UPDATE admin_allowlist SET full_name = ?, role = ?, is_active = ? WHERE lower(email) = ?;",
|
||||
[new_name, new_role, new_active, normalized_email],
|
||||
)
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="UPDATE_ALLOWLIST",
|
||||
entity_type="admin_allowlist",
|
||||
entity_id=normalized_email,
|
||||
details={"full_name": new_name, "role": new_role, "is_active": bool(new_active)},
|
||||
)
|
||||
updated_res = await client.execute(
|
||||
"SELECT email, full_name, role, is_active, last_login_at FROM admin_allowlist WHERE lower(email) = ? LIMIT 1;",
|
||||
[normalized_email],
|
||||
)
|
||||
r = row_to_dict(updated_res, updated_res.rows[0])
|
||||
return AdminPrincipal(
|
||||
email=str(r["email"]),
|
||||
full_name=str(r["full_name"]),
|
||||
role=r["role"],
|
||||
is_active=bool(r.get("is_active", 0)),
|
||||
last_login_at=r.get("last_login_at"),
|
||||
)
|
||||
|
||||
|
||||
@router.get("/audit-log", response_model=list[AuditLogRead])
|
||||
async def list_audit_log(
|
||||
entity_id: str | None = None,
|
||||
limit: int = 50,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Retrieve recent administrative actions recorded in admin_audit_log."""
|
||||
async with get_db() as client:
|
||||
if entity_id:
|
||||
res = await client.execute(
|
||||
"SELECT * FROM admin_audit_log WHERE entity_id = ? ORDER BY created_at DESC LIMIT ?;",
|
||||
[entity_id, limit],
|
||||
)
|
||||
else:
|
||||
res = await client.execute(
|
||||
"SELECT * FROM admin_audit_log ORDER BY created_at DESC LIMIT ?;",
|
||||
[limit],
|
||||
)
|
||||
return [AuditLogRead(**r) for r in result_to_dicts(res)]
|
||||
@@ -0,0 +1,131 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import defaultdict
|
||||
from datetime import date, time
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Query, status
|
||||
|
||||
from app.core.config import settings
|
||||
from app.db.database import get_db, result_to_dicts, row_to_dict
|
||||
from app.routers.bookings import parse_iso_datetime
|
||||
from app.schemas.availability import AvailabilityResponse, DayAvailabilityRead, SlotRead
|
||||
from app.services.availability import (
|
||||
BlockedInterval,
|
||||
BusinessHours,
|
||||
blocked_interval,
|
||||
compute_available_slots,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix="/availability", tags=["Availability"])
|
||||
|
||||
|
||||
def _parse_time(time_str: str) -> time:
|
||||
parts = [int(p) for p in time_str.split(":")]
|
||||
return time(hour=parts[0], minute=parts[1])
|
||||
|
||||
|
||||
@router.get("", response_model=AvailabilityResponse)
|
||||
async def get_availability(
|
||||
service_id: str = Query(..., description="ID of the service to check availability for"),
|
||||
date_from: date = Query(..., description="Start date (YYYY-MM-DD) inclusive"),
|
||||
date_to: date = Query(..., description="End date (YYYY-MM-DD) inclusive"),
|
||||
):
|
||||
"""
|
||||
Public-facing endpoint to query available appointment slots for INDIVIDUAL services.
|
||||
Enforces service duration and mandatory 15-minute post-session buffer collision rules.
|
||||
"""
|
||||
if date_to < date_from:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="date_to cannot be earlier than date_from.",
|
||||
)
|
||||
|
||||
range_days = (date_to - date_from).days + 1
|
||||
if range_days > settings.availability_max_range_days:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail=f"Requested range ({range_days} days) exceeds maximum allowed limit ({settings.availability_max_range_days} days).",
|
||||
)
|
||||
|
||||
async with get_db() as client:
|
||||
# 1. Fetch service details
|
||||
svc_res = await client.execute(
|
||||
"SELECT * FROM services WHERE id = ? AND is_active = 1 LIMIT 1;",
|
||||
[service_id],
|
||||
)
|
||||
if not svc_res.rows:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Service '{service_id}' not found or inactive.",
|
||||
)
|
||||
|
||||
service = row_to_dict(svc_res, svc_res.rows[0])
|
||||
if service["service_type"] != "INDIVIDUAL":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Availability query is only applicable to INDIVIDUAL appointment services.",
|
||||
)
|
||||
|
||||
duration_minutes = int(service.get("duration_minutes", 60))
|
||||
buffer_minutes = int(service.get("buffer_minutes", 15))
|
||||
service_name = str(service["name"])
|
||||
|
||||
# 2. Fetch all existing active reservations that could cause collisions
|
||||
# (bookings where booking_status = 'RESERVED')
|
||||
b_res = await client.execute(
|
||||
"""
|
||||
SELECT scheduled_at, duration_minutes, buffer_minutes
|
||||
FROM bookings
|
||||
WHERE booking_status = 'RESERVED';
|
||||
"""
|
||||
)
|
||||
existing_rows = result_to_dicts(b_res)
|
||||
|
||||
existing_intervals: list[BlockedInterval] = []
|
||||
for r in existing_rows:
|
||||
dt = parse_iso_datetime(str(r["scheduled_at"]))
|
||||
dur = int(r.get("duration_minutes", 60))
|
||||
buf = int(r.get("buffer_minutes", 0))
|
||||
existing_intervals.append(blocked_interval(dt, dur, buf))
|
||||
|
||||
tz = ZoneInfo(settings.business_timezone)
|
||||
hours = BusinessHours(
|
||||
timezone=tz,
|
||||
open_time=_parse_time(settings.availability_open_time),
|
||||
close_time=_parse_time(settings.availability_close_time),
|
||||
working_weekdays=frozenset(settings.availability_working_weekdays),
|
||||
slot_step_minutes=settings.availability_slot_step_minutes,
|
||||
)
|
||||
|
||||
available_slots = compute_available_slots(
|
||||
date_from=date_from,
|
||||
date_to=date_to,
|
||||
duration_minutes=duration_minutes,
|
||||
buffer_minutes=buffer_minutes,
|
||||
existing=existing_intervals,
|
||||
hours=hours,
|
||||
)
|
||||
|
||||
# Group available slots by date
|
||||
days_dict: dict[date, list[SlotRead]] = defaultdict(list)
|
||||
for slot in available_slots:
|
||||
slot_date = slot.start.date()
|
||||
days_dict[slot_date].append(
|
||||
SlotRead(start=slot.start.isoformat(), end=slot.end.isoformat())
|
||||
)
|
||||
|
||||
# Maintain sorted dates representation
|
||||
days_list: list[DayAvailabilityRead] = [
|
||||
DayAvailabilityRead(date=d.isoformat(), slots=slots)
|
||||
for d, slots in sorted(days_dict.items(), key=lambda x: x[0])
|
||||
]
|
||||
|
||||
return AvailabilityResponse(
|
||||
service_id=service_id,
|
||||
service_name=service_name,
|
||||
duration_minutes=duration_minutes,
|
||||
buffer_minutes=buffer_minutes,
|
||||
timezone=settings.business_timezone,
|
||||
days=days_list,
|
||||
)
|
||||
+741
-132
@@ -1,95 +1,76 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import secrets
|
||||
import urllib.parse
|
||||
import uuid
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from datetime import UTC, datetime
|
||||
from typing import Any
|
||||
|
||||
import libsql_client
|
||||
from fastapi import APIRouter, HTTPException, Query, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.auth import record_admin_audit, require_admin
|
||||
from app.db.database import get_db, result_to_dicts, row_to_dict
|
||||
from app.schemas.booking import BookingCreate, BookingRead, BookingStatus
|
||||
from app.schemas.auth import AdminPrincipal
|
||||
from app.schemas.booking import (
|
||||
BookingCompleteRequest,
|
||||
BookingCreate,
|
||||
BookingPaymentStatus,
|
||||
BookingRead,
|
||||
BookingReleaseRequest,
|
||||
BookingRescheduleRequest,
|
||||
BookingStatus,
|
||||
BookingStatusUpdateRequest,
|
||||
DelayedPaymentAuthorizeRequest,
|
||||
PaymentArrangement,
|
||||
)
|
||||
from app.services.bookings import (
|
||||
check_slot_collision,
|
||||
generate_booking_code,
|
||||
hydrate_booking_row,
|
||||
)
|
||||
from app.services.calendar import calendar_service
|
||||
from app.services.timestamps import parse_iso_datetime
|
||||
|
||||
router = APIRouter(prefix="/bookings", tags=["Bookings"])
|
||||
|
||||
|
||||
def parse_iso_datetime(dt_str: str) -> datetime:
|
||||
"""Parse an ISO 8601 string, normalizing naive datetimes to UTC."""
|
||||
dt = datetime.fromisoformat(dt_str)
|
||||
if dt.tzinfo is None:
|
||||
dt = dt.replace(tzinfo=UTC)
|
||||
return dt
|
||||
BOOKING_SELECT_QUERY = """
|
||||
SELECT
|
||||
b.id, b.booking_code, b.service_id, s.name AS service_name,
|
||||
b.client_id, c.full_name AS client_name, c.phone_whatsapp AS client_phone,
|
||||
b.package_id, b.scheduled_at, b.duration_minutes, b.buffer_minutes,
|
||||
b.booking_status, b.payment_arrangement, b.payment_status, b.amount_mxn,
|
||||
b.exception_authorized_by, b.exception_authorized_at, b.exception_notes,
|
||||
b.released_by, b.released_at, b.release_reason,
|
||||
b.acknowledged_by, b.acknowledged_at,
|
||||
b.gcal_event_id, b.gcal_sync_status, b.gcal_sync_error, b.gcal_synced_at,
|
||||
b.created_at
|
||||
FROM bookings b
|
||||
JOIN services s ON b.service_id = s.id
|
||||
JOIN clients c ON b.client_id = c.id
|
||||
"""
|
||||
|
||||
|
||||
def check_slot_collision(
|
||||
new_start: datetime,
|
||||
new_duration: int,
|
||||
new_buffer: int,
|
||||
existing_bookings: list[dict],
|
||||
) -> bool:
|
||||
"""
|
||||
Returns True if the requested slot interval (including mandatory buffer)
|
||||
collides with any existing active booking interval (including its buffer).
|
||||
Formula: max(A_start, B_start) < min(A_blocked_end, B_blocked_end)
|
||||
"""
|
||||
new_blocked_end = new_start + timedelta(minutes=new_duration + new_buffer)
|
||||
for b in existing_bookings:
|
||||
exist_start = parse_iso_datetime(str(b["scheduled_at"]))
|
||||
exist_duration = int(b.get("duration_minutes", 60))
|
||||
exist_buffer = int(b.get("buffer_minutes", 0))
|
||||
exist_blocked_end = exist_start + timedelta(minutes=exist_duration + exist_buffer)
|
||||
|
||||
# Overlap exists if start of each is before blocked end of other
|
||||
if new_start < exist_blocked_end and exist_start < new_blocked_end:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def generate_booking_code() -> str:
|
||||
"""Generate a clean human-readable folio code, e.g. ADS-7F2A."""
|
||||
token = secrets.token_hex(2).upper()
|
||||
return f"ADS-{token}"
|
||||
|
||||
|
||||
def build_whatsapp_link(
|
||||
service_name: str,
|
||||
scheduled_at: str,
|
||||
folio: str,
|
||||
amount_mxn: int,
|
||||
async def _fetch_hydrated_booking(
|
||||
client: libsql_client.Client,
|
||||
booking_id: str,
|
||||
*,
|
||||
package_info: str | None = None,
|
||||
) -> str:
|
||||
"""Generate a pre-filled WhatsApp link instructing the client or reporting booking."""
|
||||
if package_info:
|
||||
msg = (
|
||||
f"Hola Jazmín! ✨ Agendé mi sesión ({package_info}) para *{service_name}* "
|
||||
f"para el {scheduled_at}.\n\n"
|
||||
f"📌 *Folio de cita:* {folio}\n"
|
||||
f"¡Nos vemos pronto!"
|
||||
) -> BookingRead:
|
||||
res = await client.execute(
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[booking_id],
|
||||
)
|
||||
else:
|
||||
msg = (
|
||||
f"Hola Jazmín! ✨ Acabo de apartar mi lugar para *{service_name}* "
|
||||
f"para el {scheduled_at}.\n\n"
|
||||
f"📌 *Folio de reserva:* {folio}\n"
|
||||
f"💰 *Monto a transferir:* ${amount_mxn} MXN\n"
|
||||
f"🏦 *Banco:* {settings.spei_bank}\n"
|
||||
f"💳 *CLABE:* {settings.spei_clabe}\n"
|
||||
f"👤 *Beneficiario:* {settings.spei_beneficiary}\n\n"
|
||||
f"Te adjunto mi comprobante de pago en este chat para confirmar mi lugar. ¡Muchas gracias!"
|
||||
)
|
||||
encoded = urllib.parse.quote(msg)
|
||||
clean_phone = settings.whatsapp_phone.replace("+", "").replace(" ", "").replace("-", "")
|
||||
return f"https://wa.me/{clean_phone}?text={encoded}"
|
||||
if not res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found")
|
||||
return hydrate_booking_row(row_to_dict(res, res.rows[0]), package_info=package_info)
|
||||
|
||||
|
||||
@router.post("", response_model=BookingRead, status_code=status.HTTP_201_CREATED)
|
||||
async def create_booking(payload: BookingCreate):
|
||||
"""
|
||||
Client-facing or self-service reservation endpoint.
|
||||
Creates a PENDING_PAYMENT booking (or CONFIRMED if redeeming a prepaid package),
|
||||
enforcing mandatory buffer times between individual therapy consultations.
|
||||
Create a reservation.
|
||||
Separates booking_status (RESERVED) from payment_arrangement (PREPAID_DEFAULT or PACKAGE_REDEEMED)
|
||||
and payment_status (AWAITING_ACKNOWLEDGMENT or NOT_APPLICABLE), enforcing mandatory buffer times
|
||||
and coordinating with Google Calendar.
|
||||
"""
|
||||
async with get_db() as client:
|
||||
# 1. Fetch service details
|
||||
@@ -105,16 +86,17 @@ async def create_booking(payload: BookingCreate):
|
||||
service = row_to_dict(svc_res, svc_res.rows[0])
|
||||
duration_minutes = int(service.get("duration_minutes", 60))
|
||||
buffer_minutes = int(service.get("buffer_minutes", 0))
|
||||
max_capacity = int(service.get("max_capacity", 1))
|
||||
|
||||
# 2. Collision & Buffer Check for ONE_ON_ONE services
|
||||
# 2. Collision & Buffer Check for INDIVIDUAL services, or Capacity check for GROUP
|
||||
new_start = parse_iso_datetime(payload.scheduled_at)
|
||||
if service["service_type"] == "ONE_ON_ONE":
|
||||
if service["service_type"] == "INDIVIDUAL":
|
||||
active_res = await client.execute(
|
||||
"""
|
||||
SELECT b.scheduled_at, b.duration_minutes, b.buffer_minutes
|
||||
FROM bookings b
|
||||
JOIN services s ON b.service_id = s.id
|
||||
WHERE b.status IN ('PENDING_PAYMENT', 'CONFIRMED') AND s.service_type = 'ONE_ON_ONE';
|
||||
WHERE b.booking_status = 'RESERVED' AND s.service_type = 'INDIVIDUAL';
|
||||
"""
|
||||
)
|
||||
active_bookings = result_to_dicts(active_res)
|
||||
@@ -126,6 +108,21 @@ async def create_booking(payload: BookingCreate):
|
||||
f"tiempo de colchón obligatorio ({buffer_minutes} min)."
|
||||
),
|
||||
)
|
||||
else:
|
||||
cap_res = await client.execute(
|
||||
"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM bookings
|
||||
WHERE service_id = ? AND scheduled_at = ? AND booking_status = 'RESERVED';
|
||||
""",
|
||||
[service["id"], payload.scheduled_at],
|
||||
)
|
||||
current_count = int(str(cap_res.rows[0][0] or 0))
|
||||
if current_count >= max_capacity:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail="El grupo ha alcanzado su cupo máximo para esta sesión.",
|
||||
)
|
||||
|
||||
# 3. Upsert client
|
||||
client_res = await client.execute(
|
||||
@@ -133,7 +130,7 @@ async def create_booking(payload: BookingCreate):
|
||||
[payload.client_phone],
|
||||
)
|
||||
if client_res.rows:
|
||||
client_id = client_res.rows[0][0]
|
||||
client_id = str(client_res.rows[0][0])
|
||||
else:
|
||||
client_id = str(uuid.uuid4())
|
||||
await client.execute(
|
||||
@@ -147,9 +144,11 @@ async def create_booking(payload: BookingCreate):
|
||||
],
|
||||
)
|
||||
|
||||
# 4. Handle Package Redemption vs New Payment
|
||||
# 4. Determine payment arrangement and payment status
|
||||
now = datetime.now(UTC)
|
||||
package_info: str | None = None
|
||||
booking_status: BookingStatus = "RESERVED"
|
||||
|
||||
if payload.package_id:
|
||||
pkg_res = await client.execute(
|
||||
"SELECT * FROM packages WHERE id = ? LIMIT 1;",
|
||||
@@ -168,29 +167,42 @@ async def create_booking(payload: BookingCreate):
|
||||
detail="El paquete ya no cuenta con sesiones disponibles",
|
||||
)
|
||||
|
||||
# Increment package sessions
|
||||
await client.execute(
|
||||
"UPDATE packages SET completed_sessions = completed_sessions + 1, updated_at = ? WHERE id = ?;",
|
||||
[now.isoformat(), payload.package_id],
|
||||
)
|
||||
booking_status: BookingStatus = "CONFIRMED"
|
||||
payment_arrangement: PaymentArrangement = "PACKAGE_REDEEMED"
|
||||
payment_status: BookingPaymentStatus = "NOT_APPLICABLE"
|
||||
amount_mxn = 0
|
||||
confirmed_at: str | None = now.isoformat()
|
||||
package_info = f"Sesión {completed + 1} de {total}"
|
||||
else:
|
||||
booking_status = "PENDING_PAYMENT"
|
||||
payment_arrangement = "PREPAID_DEFAULT"
|
||||
payment_status = "AWAITING_ACKNOWLEDGMENT"
|
||||
amount_mxn = int(service["price_mxn"])
|
||||
confirmed_at = None
|
||||
|
||||
booking_id = str(uuid.uuid4())
|
||||
booking_code = generate_booking_code()
|
||||
expires_at = (now + timedelta(hours=2)).isoformat()
|
||||
|
||||
# 5. Coordinate with Google Calendar (non-fatal on transient failure)
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=booking_id,
|
||||
booking_code=booking_code,
|
||||
service_name=str(service["name"]),
|
||||
client_name=payload.client_name,
|
||||
scheduled_at=payload.scheduled_at,
|
||||
duration_minutes=duration_minutes,
|
||||
booking_status=booking_status,
|
||||
payment_arrangement=payment_arrangement,
|
||||
payment_status=payment_status,
|
||||
)
|
||||
|
||||
insert_booking_query = """
|
||||
INSERT INTO bookings (
|
||||
id, booking_code, service_id, client_id, package_id, scheduled_at,
|
||||
duration_minutes, buffer_minutes, status, amount_mxn, expires_at, created_at, confirmed_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
||||
duration_minutes, buffer_minutes, booking_status, payment_arrangement,
|
||||
payment_status, amount_mxn, gcal_event_id, gcal_sync_status,
|
||||
gcal_sync_error, gcal_synced_at, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
||||
"""
|
||||
await client.execute(
|
||||
insert_booking_query,
|
||||
@@ -204,65 +216,43 @@ async def create_booking(payload: BookingCreate):
|
||||
duration_minutes,
|
||||
buffer_minutes,
|
||||
booking_status,
|
||||
payment_arrangement,
|
||||
payment_status,
|
||||
amount_mxn,
|
||||
expires_at,
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
now.isoformat(),
|
||||
confirmed_at,
|
||||
],
|
||||
)
|
||||
|
||||
wa_link = build_whatsapp_link(
|
||||
service_name=service["name"],
|
||||
scheduled_at=payload.scheduled_at,
|
||||
folio=booking_code,
|
||||
amount_mxn=amount_mxn,
|
||||
package_info=package_info,
|
||||
)
|
||||
|
||||
return BookingRead(
|
||||
id=booking_id,
|
||||
booking_code=booking_code,
|
||||
service_id=service["id"],
|
||||
service_name=service["name"],
|
||||
client_id=str(client_id),
|
||||
client_name=payload.client_name,
|
||||
client_phone=payload.client_phone,
|
||||
package_id=payload.package_id,
|
||||
scheduled_at=payload.scheduled_at,
|
||||
duration_minutes=duration_minutes,
|
||||
buffer_minutes=buffer_minutes,
|
||||
status=booking_status,
|
||||
amount_mxn=amount_mxn,
|
||||
expires_at=expires_at,
|
||||
created_at=now.isoformat(),
|
||||
confirmed_at=confirmed_at,
|
||||
whatsapp_redirect_url=wa_link,
|
||||
)
|
||||
return await _fetch_hydrated_booking(client, booking_id, package_info=package_info)
|
||||
|
||||
|
||||
@router.get("", response_model=list[BookingRead])
|
||||
async def list_bookings(
|
||||
status_filter: BookingStatus | None = Query(None, alias="status"),
|
||||
booking_status: BookingStatus | None = Query(None, alias="status"),
|
||||
payment_status: BookingPaymentStatus | None = None,
|
||||
payment_arrangement: PaymentArrangement | None = None,
|
||||
client_id: str | None = None,
|
||||
limit: int = 50,
|
||||
_admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Admin-facing endpoint to list bookings, filtered by status or client."""
|
||||
query = """
|
||||
SELECT
|
||||
b.id, b.booking_code, b.service_id, s.name AS service_name,
|
||||
b.client_id, c.full_name AS client_name, c.phone_whatsapp AS client_phone,
|
||||
b.package_id, b.scheduled_at, b.duration_minutes, b.buffer_minutes,
|
||||
b.status, b.amount_mxn, b.gcal_event_id, b.expires_at, b.created_at, b.confirmed_at
|
||||
FROM bookings b
|
||||
JOIN services s ON b.service_id = s.id
|
||||
JOIN clients c ON b.client_id = c.id
|
||||
"""
|
||||
"""Admin-facing endpoint to list bookings filtered by booking_status, payment_status, or arrangement."""
|
||||
query = BOOKING_SELECT_QUERY
|
||||
params: list[libsql_client.InValue] = []
|
||||
clauses: list[str] = []
|
||||
|
||||
if status_filter:
|
||||
clauses.append("b.status = ?")
|
||||
params.append(status_filter)
|
||||
if booking_status:
|
||||
clauses.append("b.booking_status = ?")
|
||||
params.append(booking_status)
|
||||
if payment_status:
|
||||
clauses.append("b.payment_status = ?")
|
||||
params.append(payment_status)
|
||||
if payment_arrangement:
|
||||
clauses.append("b.payment_arrangement = ?")
|
||||
params.append(payment_arrangement)
|
||||
if client_id:
|
||||
clauses.append("b.client_id = ?")
|
||||
params.append(client_id)
|
||||
@@ -270,10 +260,629 @@ async def list_bookings(
|
||||
if clauses:
|
||||
query += " WHERE " + " AND ".join(clauses)
|
||||
|
||||
query += " ORDER BY b.scheduled_at DESC LIMIT ?;"
|
||||
query += " ORDER BY b.scheduled_at ASC LIMIT ?;"
|
||||
params.append(limit)
|
||||
|
||||
async with get_db() as client:
|
||||
res = await client.execute(query, params)
|
||||
rows = result_to_dicts(res)
|
||||
return [BookingRead(**r) for r in rows]
|
||||
now = datetime.now(UTC)
|
||||
return [hydrate_booking_row(r, now=now) for r in rows]
|
||||
|
||||
|
||||
@router.get("/follow-up-queue", response_model=list[BookingRead])
|
||||
async def get_payment_followup_queue(
|
||||
window_hours: int = Query(default=48, ge=1, le=720),
|
||||
_admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Dedicated operational visibility queue for Jasmin and her assistant.
|
||||
Returns bookings with unacknowledged payment (`AWAITING_ACKNOWLEDGMENT`) that are either:
|
||||
1. Active (`RESERVED`) and scheduled within `window_hours` (default 48h), OR
|
||||
2. Authorized for delayed payment (`DELAYED_ALLOWED`) and still awaiting settlement.
|
||||
"""
|
||||
query = (
|
||||
BOOKING_SELECT_QUERY
|
||||
+ """
|
||||
WHERE b.payment_status = 'AWAITING_ACKNOWLEDGMENT'
|
||||
AND b.booking_status IN ('RESERVED', 'COMPLETED')
|
||||
ORDER BY b.scheduled_at ASC;
|
||||
"""
|
||||
)
|
||||
async with get_db() as client:
|
||||
res = await client.execute(query)
|
||||
rows = result_to_dicts(res)
|
||||
now = datetime.now(UTC)
|
||||
hydrated = [hydrate_booking_row(r, now=now, window_hours=window_hours) for r in rows]
|
||||
return [b for b in hydrated if b.needs_payment_followup]
|
||||
|
||||
|
||||
@router.post("/{booking_id}/authorize-delayed-payment", response_model=BookingRead)
|
||||
async def authorize_delayed_payment(
|
||||
booking_id: str,
|
||||
payload: DelayedPaymentAuthorizeRequest,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Authorized administrative exception: allow a session to proceed without prepayment.
|
||||
Sets payment_arrangement = 'DELAYED_ALLOWED', records who authorized the exception and when,
|
||||
and keeps payment_status = 'AWAITING_ACKNOWLEDGMENT' so the delayed payment remains traceable.
|
||||
"""
|
||||
async with get_db() as client:
|
||||
res = await client.execute(
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[booking_id],
|
||||
)
|
||||
if not res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found")
|
||||
booking = row_to_dict(res, res.rows[0])
|
||||
|
||||
if booking["booking_status"] in ("RELEASED", "CANCELLED"):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Cannot authorize delayed payment on a released or cancelled booking.",
|
||||
)
|
||||
if booking["payment_status"] == "ACKNOWLEDGED":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Payment for this booking has already been acknowledged.",
|
||||
)
|
||||
|
||||
now = datetime.now(UTC).isoformat()
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=booking_id,
|
||||
booking_code=str(booking["booking_code"]),
|
||||
service_name=str(booking["service_name"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
scheduled_at=str(booking["scheduled_at"]),
|
||||
duration_minutes=int(booking["duration_minutes"]),
|
||||
booking_status=str(booking["booking_status"]),
|
||||
payment_arrangement="DELAYED_ALLOWED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
existing_event_id=booking.get("gcal_event_id"),
|
||||
)
|
||||
|
||||
await client.execute(
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET payment_arrangement = 'DELAYED_ALLOWED',
|
||||
payment_status = 'AWAITING_ACKNOWLEDGMENT',
|
||||
exception_authorized_by = ?,
|
||||
exception_authorized_at = ?,
|
||||
exception_notes = ?,
|
||||
gcal_event_id = ?,
|
||||
gcal_sync_status = ?,
|
||||
gcal_sync_error = ?,
|
||||
gcal_synced_at = ?
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[
|
||||
admin.email,
|
||||
now,
|
||||
payload.notes,
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
booking_id,
|
||||
],
|
||||
)
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="AUTHORIZE_DELAYED_PAYMENT",
|
||||
entity_type="booking",
|
||||
entity_id=booking_id,
|
||||
details={"booking_code": booking["booking_code"], "notes": payload.notes},
|
||||
)
|
||||
return await _fetch_hydrated_booking(client, booking_id)
|
||||
|
||||
|
||||
@router.post("/{booking_id}/release", response_model=BookingRead)
|
||||
async def release_booking_slot(
|
||||
booking_id: str,
|
||||
payload: BookingReleaseRequest,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Deliberate administrative action to release a booking slot so another client can take the place.
|
||||
Bookings never expire automatically; only an authorized administrator can release a slot.
|
||||
"""
|
||||
async with get_db() as client:
|
||||
res = await client.execute(
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[booking_id],
|
||||
)
|
||||
if not res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found")
|
||||
booking = row_to_dict(res, res.rows[0])
|
||||
|
||||
if booking["booking_status"] == "RELEASED":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Booking slot has already been released.",
|
||||
)
|
||||
|
||||
now = datetime.now(UTC).isoformat()
|
||||
new_payment_status = (
|
||||
"NOT_APPLICABLE"
|
||||
if booking["payment_status"] == "AWAITING_ACKNOWLEDGMENT"
|
||||
else booking["payment_status"]
|
||||
)
|
||||
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=booking_id,
|
||||
booking_code=str(booking["booking_code"]),
|
||||
service_name=str(booking["service_name"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
scheduled_at=str(booking["scheduled_at"]),
|
||||
duration_minutes=int(booking["duration_minutes"]),
|
||||
booking_status="RELEASED",
|
||||
payment_arrangement=str(booking["payment_arrangement"]),
|
||||
payment_status=str(new_payment_status),
|
||||
existing_event_id=booking.get("gcal_event_id"),
|
||||
)
|
||||
|
||||
await client.execute(
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET booking_status = 'RELEASED',
|
||||
payment_status = ?,
|
||||
released_by = ?,
|
||||
released_at = ?,
|
||||
release_reason = ?,
|
||||
gcal_event_id = ?,
|
||||
gcal_sync_status = ?,
|
||||
gcal_sync_error = ?,
|
||||
gcal_synced_at = ?
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[
|
||||
new_payment_status,
|
||||
admin.email,
|
||||
now,
|
||||
payload.reason,
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
booking_id,
|
||||
],
|
||||
)
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="RELEASE_BOOKING",
|
||||
entity_type="booking",
|
||||
entity_id=booking_id,
|
||||
details={"booking_code": booking["booking_code"], "reason": payload.reason},
|
||||
)
|
||||
return await _fetch_hydrated_booking(client, booking_id)
|
||||
|
||||
|
||||
@router.post("/{booking_id}/status", response_model=BookingRead)
|
||||
async def update_booking_status(
|
||||
booking_id: str,
|
||||
payload: BookingStatusUpdateRequest,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Transition booking_status to COMPLETED, CANCELLED, or NO_SHOW.
|
||||
Crucially, marking a booking COMPLETED does NOT implicitly mark an unpaid delayed payment as ACKNOWLEDGED.
|
||||
"""
|
||||
async with get_db() as client:
|
||||
res = await client.execute(
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[booking_id],
|
||||
)
|
||||
if not res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found")
|
||||
booking = row_to_dict(res, res.rows[0])
|
||||
|
||||
new_payment_status = str(booking["payment_status"])
|
||||
if (
|
||||
payload.booking_status == "CANCELLED"
|
||||
and new_payment_status == "AWAITING_ACKNOWLEDGMENT"
|
||||
and booking["payment_arrangement"] == "PREPAID_DEFAULT"
|
||||
):
|
||||
new_payment_status = "NOT_APPLICABLE"
|
||||
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=booking_id,
|
||||
booking_code=str(booking["booking_code"]),
|
||||
service_name=str(booking["service_name"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
scheduled_at=str(booking["scheduled_at"]),
|
||||
duration_minutes=int(booking["duration_minutes"]),
|
||||
booking_status=payload.booking_status,
|
||||
payment_arrangement=str(booking["payment_arrangement"]),
|
||||
payment_status=new_payment_status,
|
||||
existing_event_id=booking.get("gcal_event_id"),
|
||||
)
|
||||
|
||||
await client.execute(
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET booking_status = ?,
|
||||
payment_status = ?,
|
||||
gcal_event_id = ?,
|
||||
gcal_sync_status = ?,
|
||||
gcal_sync_error = ?,
|
||||
gcal_synced_at = ?
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[
|
||||
payload.booking_status,
|
||||
new_payment_status,
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
booking_id,
|
||||
],
|
||||
)
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="UPDATE_BOOKING_STATUS",
|
||||
entity_type="booking",
|
||||
entity_id=booking_id,
|
||||
details={
|
||||
"booking_code": booking["booking_code"],
|
||||
"new_status": payload.booking_status,
|
||||
"notes": payload.notes,
|
||||
},
|
||||
)
|
||||
return await _fetch_hydrated_booking(client, booking_id)
|
||||
|
||||
|
||||
@router.post("/{booking_id}/sync-calendar", response_model=BookingRead)
|
||||
async def retry_calendar_sync(
|
||||
booking_id: str,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Manually retry Google Calendar synchronization for a booking."""
|
||||
async with get_db() as client:
|
||||
res = await client.execute(
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[booking_id],
|
||||
)
|
||||
if not res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found")
|
||||
booking = row_to_dict(res, res.rows[0])
|
||||
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=booking_id,
|
||||
booking_code=str(booking["booking_code"]),
|
||||
service_name=str(booking["service_name"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
scheduled_at=str(booking["scheduled_at"]),
|
||||
duration_minutes=int(booking["duration_minutes"]),
|
||||
booking_status=str(booking["booking_status"]),
|
||||
payment_arrangement=str(booking["payment_arrangement"]),
|
||||
payment_status=str(booking["payment_status"]),
|
||||
existing_event_id=booking.get("gcal_event_id"),
|
||||
)
|
||||
|
||||
await client.execute(
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET gcal_event_id = ?,
|
||||
gcal_sync_status = ?,
|
||||
gcal_sync_error = ?,
|
||||
gcal_synced_at = ?
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
booking_id,
|
||||
],
|
||||
)
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="RETRY_CALENDAR_SYNC",
|
||||
entity_type="booking",
|
||||
entity_id=booking_id,
|
||||
details={"sync_status": cal_res.sync_status, "sync_error": cal_res.sync_error},
|
||||
)
|
||||
return await _fetch_hydrated_booking(client, booking_id)
|
||||
|
||||
|
||||
@router.post("/{booking_id}/reschedule", response_model=BookingRead)
|
||||
async def reschedule_booking(
|
||||
booking_id: str,
|
||||
payload: BookingRescheduleRequest,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Reschedule an existing RESERVED booking to a new datetime.
|
||||
Validates slot collision factoring in mandatory buffer times, updates Google Calendar,
|
||||
and returns hydrated booking with updated WhatsApp deep link.
|
||||
"""
|
||||
async with get_db() as client:
|
||||
# 1. Fetch current booking
|
||||
res = await client.execute(
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[booking_id],
|
||||
)
|
||||
if not res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found")
|
||||
booking = row_to_dict(res, res.rows[0])
|
||||
|
||||
# 2. Validate booking_status is RESERVED
|
||||
if booking["booking_status"] != "RESERVED":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Cannot reschedule booking with status {booking['booking_status']}. Only RESERVED bookings can be rescheduled.",
|
||||
)
|
||||
|
||||
# 3. Fetch service to check INDIVIDUAL vs GROUP, buffer, and duration
|
||||
svc_res = await client.execute(
|
||||
"SELECT * FROM services WHERE id = ? LIMIT 1;",
|
||||
[booking["service_id"]],
|
||||
)
|
||||
if not svc_res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Service not found")
|
||||
service = row_to_dict(svc_res, svc_res.rows[0])
|
||||
|
||||
duration_minutes = int(
|
||||
booking.get("duration_minutes") or service.get("duration_minutes", 60)
|
||||
)
|
||||
buffer_minutes = int(booking.get("buffer_minutes") or service.get("buffer_minutes", 0))
|
||||
max_capacity = int(service.get("max_capacity", 1))
|
||||
|
||||
# 4. Collision check factoring in buffer
|
||||
new_start = parse_iso_datetime(payload.new_scheduled_at)
|
||||
if service["service_type"] == "INDIVIDUAL":
|
||||
active_res = await client.execute(
|
||||
"""
|
||||
SELECT b.id, b.scheduled_at, b.duration_minutes, b.buffer_minutes
|
||||
FROM bookings b
|
||||
JOIN services s ON b.service_id = s.id
|
||||
WHERE b.booking_status = 'RESERVED' AND s.service_type = 'INDIVIDUAL' AND b.id != ?;
|
||||
""",
|
||||
[booking_id],
|
||||
)
|
||||
active_bookings = result_to_dicts(active_res)
|
||||
if check_slot_collision(new_start, duration_minutes, buffer_minutes, active_bookings):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail=(
|
||||
f"Horario no disponible: Entra en conflicto con otra consulta o con el "
|
||||
f"tiempo de colchón obligatorio ({buffer_minutes} min)."
|
||||
),
|
||||
)
|
||||
else:
|
||||
cap_res = await client.execute(
|
||||
"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM bookings
|
||||
WHERE service_id = ? AND scheduled_at = ? AND booking_status = 'RESERVED' AND id != ?;
|
||||
""",
|
||||
[service["id"], payload.new_scheduled_at, booking_id],
|
||||
)
|
||||
current_count = int(str(cap_res.rows[0][0] or 0))
|
||||
if current_count >= max_capacity:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail="El grupo ha alcanzado su cupo máximo para esta sesión.",
|
||||
)
|
||||
|
||||
# 5. Sync with Google Calendar
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=booking_id,
|
||||
booking_code=str(booking["booking_code"]),
|
||||
service_name=str(booking["service_name"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
scheduled_at=payload.new_scheduled_at,
|
||||
duration_minutes=duration_minutes,
|
||||
booking_status="RESERVED",
|
||||
payment_arrangement=str(booking["payment_arrangement"]),
|
||||
payment_status=str(booking["payment_status"]),
|
||||
existing_event_id=booking.get("gcal_event_id"),
|
||||
)
|
||||
|
||||
# 6. Update booking scheduled_at and sync state
|
||||
await client.execute(
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET scheduled_at = ?,
|
||||
gcal_event_id = ?,
|
||||
gcal_sync_status = ?,
|
||||
gcal_sync_error = ?,
|
||||
gcal_synced_at = ?
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[
|
||||
payload.new_scheduled_at,
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
booking_id,
|
||||
],
|
||||
)
|
||||
|
||||
# 7. Record admin audit log
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="RESCHEDULE_BOOKING",
|
||||
entity_type="booking",
|
||||
entity_id=booking_id,
|
||||
details={
|
||||
"booking_code": booking["booking_code"],
|
||||
"previous_scheduled_at": booking["scheduled_at"],
|
||||
"new_scheduled_at": payload.new_scheduled_at,
|
||||
"notes": payload.notes,
|
||||
},
|
||||
)
|
||||
|
||||
# 8. Package info if applicable
|
||||
package_info = None
|
||||
if booking.get("package_id"):
|
||||
pkg_res = await client.execute(
|
||||
"SELECT * FROM packages WHERE id = ? LIMIT 1;",
|
||||
[booking["package_id"]],
|
||||
)
|
||||
if pkg_res.rows:
|
||||
pkg_row = row_to_dict(pkg_res, pkg_res.rows[0])
|
||||
package_info = (
|
||||
f"Sesión {pkg_row['completed_sessions']} de {pkg_row['total_sessions']}"
|
||||
)
|
||||
|
||||
return await _fetch_hydrated_booking(client, booking_id, package_info=package_info)
|
||||
|
||||
|
||||
@router.post("/{booking_id}/complete", response_model=BookingRead)
|
||||
async def complete_booking(
|
||||
booking_id: str,
|
||||
payload: BookingCompleteRequest | None = None,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Mark consultation session as COMPLETED.
|
||||
Records package session completion if linked to a multi-session package,
|
||||
updates Google Calendar, and records admin audit log.
|
||||
"""
|
||||
async with get_db() as client:
|
||||
# 1. Fetch current booking
|
||||
res = await client.execute(
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[booking_id],
|
||||
)
|
||||
if not res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found")
|
||||
booking = row_to_dict(res, res.rows[0])
|
||||
|
||||
# 2. Validate booking_status is RESERVED
|
||||
if booking["booking_status"] != "RESERVED":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Cannot complete booking with status {booking['booking_status']}. Only RESERVED bookings can be marked as COMPLETED.",
|
||||
)
|
||||
|
||||
now = datetime.now(UTC).isoformat()
|
||||
notes = payload.notes if payload else None
|
||||
target_pkg_id = (
|
||||
payload.package_id if (payload and payload.package_id) else booking.get("package_id")
|
||||
)
|
||||
package_counter_advanced = False
|
||||
|
||||
# If a new package is linked during completion, advance counter and update payment arrangement
|
||||
if payload and payload.package_id and booking.get("package_id") != payload.package_id:
|
||||
pkg_res = await client.execute(
|
||||
"SELECT * FROM packages WHERE id = ? LIMIT 1;",
|
||||
[payload.package_id],
|
||||
)
|
||||
if not pkg_res.rows:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Package not found"
|
||||
)
|
||||
pkg_row = row_to_dict(pkg_res, pkg_res.rows[0])
|
||||
completed = int(pkg_row["completed_sessions"])
|
||||
total = int(pkg_row["total_sessions"])
|
||||
if completed >= total:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="El paquete ya no cuenta con sesiones disponibles",
|
||||
)
|
||||
await client.execute(
|
||||
"UPDATE packages SET completed_sessions = completed_sessions + 1, updated_at = ? WHERE id = ?;",
|
||||
[now, payload.package_id],
|
||||
)
|
||||
package_counter_advanced = True
|
||||
await client.execute(
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET package_id = ?, payment_arrangement = 'PACKAGE_REDEEMED', payment_status = 'NOT_APPLICABLE'
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[payload.package_id, booking_id],
|
||||
)
|
||||
booking["package_id"] = payload.package_id
|
||||
booking["payment_arrangement"] = "PACKAGE_REDEEMED"
|
||||
booking["payment_status"] = "NOT_APPLICABLE"
|
||||
|
||||
# 3. Google Calendar sync
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=booking_id,
|
||||
booking_code=str(booking["booking_code"]),
|
||||
service_name=str(booking["service_name"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
scheduled_at=str(booking["scheduled_at"]),
|
||||
duration_minutes=int(booking["duration_minutes"]),
|
||||
booking_status="COMPLETED",
|
||||
payment_arrangement=str(booking["payment_arrangement"]),
|
||||
payment_status=str(booking["payment_status"]),
|
||||
existing_event_id=booking.get("gcal_event_id"),
|
||||
)
|
||||
|
||||
# 4. Update booking_status = COMPLETED
|
||||
await client.execute(
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET booking_status = 'COMPLETED',
|
||||
gcal_event_id = ?,
|
||||
gcal_sync_status = ?,
|
||||
gcal_sync_error = ?,
|
||||
gcal_synced_at = ?
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
booking_id,
|
||||
],
|
||||
)
|
||||
|
||||
# 5. Admin audit log
|
||||
audit_details: dict[str, Any] = {
|
||||
"booking_code": booking["booking_code"],
|
||||
"notes": notes,
|
||||
}
|
||||
if target_pkg_id:
|
||||
audit_details["package_id"] = target_pkg_id
|
||||
audit_details["package_session_completed"] = True
|
||||
if package_counter_advanced:
|
||||
audit_details["package_counter_advanced"] = True
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="COMPLETE_PACKAGE_SESSION",
|
||||
entity_type="package",
|
||||
entity_id=target_pkg_id,
|
||||
details={"booking_id": booking_id, "booking_code": booking["booking_code"]},
|
||||
)
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="COMPLETE_BOOKING",
|
||||
entity_type="booking",
|
||||
entity_id=booking_id,
|
||||
details=audit_details,
|
||||
)
|
||||
|
||||
package_info = None
|
||||
if target_pkg_id:
|
||||
pkg_res = await client.execute(
|
||||
"SELECT * FROM packages WHERE id = ? LIMIT 1;", [target_pkg_id]
|
||||
)
|
||||
if pkg_res.rows:
|
||||
pkg_row = row_to_dict(pkg_res, pkg_res.rows[0])
|
||||
package_info = (
|
||||
f"Sesión {pkg_row['completed_sessions']} de {pkg_row['total_sessions']}"
|
||||
)
|
||||
|
||||
return await _fetch_hydrated_booking(client, booking_id, package_info=package_info)
|
||||
@@ -0,0 +1,171 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||
|
||||
from app.core.auth import record_admin_audit, require_admin
|
||||
from app.db.database import get_db
|
||||
from app.repositories import client as client_repo
|
||||
from app.schemas.auth import AdminPrincipal
|
||||
from app.schemas.client import Client360Read, ClientCreate, ClientRead, ClientUpdate
|
||||
|
||||
router = APIRouter(prefix="/clients", tags=["Clients"])
|
||||
|
||||
|
||||
@router.get("", response_model=list[ClientRead])
|
||||
async def list_clients(
|
||||
search: str | None = Query(
|
||||
default=None, description="Case-insensitive search query matching name or phone"
|
||||
),
|
||||
limit: int = Query(default=50, ge=1, le=100),
|
||||
offset: int = Query(default=0, ge=0),
|
||||
_admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Search and list clients with autocomplete support matching full_name or phone_whatsapp.
|
||||
Supports limit and offset pagination.
|
||||
"""
|
||||
async with get_db() as db:
|
||||
return await client_repo.list_and_search_clients(
|
||||
db, search=search, limit=limit, offset=offset
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{client_id}", response_model=Client360Read)
|
||||
async def get_client(
|
||||
client_id: str,
|
||||
_admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Client 360 profile returning contact information, operational notes,
|
||||
active multi-session packages (completed vs total sessions), and recent booking history.
|
||||
"""
|
||||
async with get_db() as db:
|
||||
profile = await client_repo.get_client_360_profile(db, client_id)
|
||||
if not profile:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Client not found",
|
||||
)
|
||||
return profile
|
||||
|
||||
|
||||
@router.post("", response_model=ClientRead, status_code=status.HTTP_201_CREATED)
|
||||
async def create_client(
|
||||
payload: ClientCreate,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Explicitly register a new client with phone number validation and duplicate detection.
|
||||
"""
|
||||
async with get_db() as db:
|
||||
existing = await client_repo.get_client_by_phone(db, payload.phone_whatsapp)
|
||||
if existing:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail=f"A client with phone {payload.phone_whatsapp} already exists.",
|
||||
)
|
||||
|
||||
new_client = await client_repo.create_client(db, payload)
|
||||
|
||||
await record_admin_audit(
|
||||
db,
|
||||
admin_email=admin.email,
|
||||
action_type="CREATE_CLIENT",
|
||||
entity_type="client",
|
||||
entity_id=new_client.id,
|
||||
details={
|
||||
"full_name": new_client.full_name,
|
||||
"phone_whatsapp": new_client.phone_whatsapp,
|
||||
},
|
||||
)
|
||||
return new_client
|
||||
|
||||
|
||||
@router.patch("/{client_id}", response_model=ClientRead)
|
||||
async def update_client(
|
||||
client_id: str,
|
||||
payload: ClientUpdate,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Update client contact details, full_name, phone_whatsapp, email, or clinical/operational notes.
|
||||
"""
|
||||
async with get_db() as db:
|
||||
existing = await client_repo.get_client_by_id(db, client_id)
|
||||
if not existing:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Client not found",
|
||||
)
|
||||
|
||||
if payload.phone_whatsapp:
|
||||
dup = await client_repo.get_client_by_phone(
|
||||
db, payload.phone_whatsapp, exclude_id=client_id
|
||||
)
|
||||
if dup:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail=f"Another client with phone {payload.phone_whatsapp} already exists.",
|
||||
)
|
||||
|
||||
updated = await client_repo.update_client(db, client_id, payload)
|
||||
if not updated:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Client not found",
|
||||
)
|
||||
|
||||
await record_admin_audit(
|
||||
db,
|
||||
admin_email=admin.email,
|
||||
action_type="UPDATE_CLIENT",
|
||||
entity_type="client",
|
||||
entity_id=client_id,
|
||||
details=payload.model_dump(exclude_none=True),
|
||||
)
|
||||
return updated
|
||||
|
||||
|
||||
@router.delete("/{client_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def delete_client(
|
||||
client_id: str,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Safe client deletion verifying foreign key integrity.
|
||||
Rejects deletion with HTTP 409 Conflict if the client has associated bookings or packages.
|
||||
"""
|
||||
async with get_db() as db:
|
||||
existing = await client_repo.get_client_by_id(db, client_id)
|
||||
if not existing:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Client not found",
|
||||
)
|
||||
|
||||
deps = await client_repo.get_client_dependencies(db, client_id)
|
||||
bookings_count = deps["bookings_count"]
|
||||
packages_count = deps["packages_count"]
|
||||
|
||||
if bookings_count > 0 or packages_count > 0:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail=(
|
||||
f"Cannot delete client: client has {bookings_count} associated booking(s) "
|
||||
f"and {packages_count} package(s)."
|
||||
),
|
||||
)
|
||||
|
||||
await client_repo.delete_client(db, client_id)
|
||||
|
||||
await record_admin_audit(
|
||||
db,
|
||||
admin_email=admin.email,
|
||||
action_type="DELETE_CLIENT",
|
||||
entity_type="client",
|
||||
entity_id=client_id,
|
||||
details={
|
||||
"full_name": existing.full_name,
|
||||
"phone_whatsapp": existing.phone_whatsapp,
|
||||
},
|
||||
)
|
||||
+39
-8
@@ -4,9 +4,11 @@ import uuid
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import libsql_client
|
||||
from fastapi import APIRouter, HTTPException, Query, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||
|
||||
from app.core.auth import record_admin_audit, require_admin
|
||||
from app.db.database import get_db, result_to_dicts, row_to_dict
|
||||
from app.schemas.auth import AdminPrincipal
|
||||
from app.schemas.package import FinancialStatus, PackageCreate, PackageRead, PackageUpdate
|
||||
|
||||
router = APIRouter(prefix="/packages", tags=["Packages"])
|
||||
@@ -34,20 +36,21 @@ def _hydrate_package(r: dict) -> PackageRead:
|
||||
|
||||
|
||||
@router.post("", response_model=PackageRead, status_code=status.HTTP_201_CREATED)
|
||||
async def create_package(payload: PackageCreate):
|
||||
async def create_package(
|
||||
payload: PackageCreate,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Create a multi-session therapy package for a client (e.g. 5 or 10 sessions).
|
||||
Allows tracking remaining credits and financial status.
|
||||
"""
|
||||
async with get_db() as client:
|
||||
# Verify client
|
||||
c_res = await client.execute(
|
||||
"SELECT id FROM clients WHERE id = ? LIMIT 1;", [payload.client_id]
|
||||
)
|
||||
if not c_res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Client not found")
|
||||
|
||||
# Verify service
|
||||
s_res = await client.execute(
|
||||
"SELECT id FROM services WHERE id = ? LIMIT 1;", [payload.service_id]
|
||||
)
|
||||
@@ -79,7 +82,19 @@ async def create_package(payload: PackageCreate):
|
||||
],
|
||||
)
|
||||
|
||||
# Hydrate with names
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="CREATE_PACKAGE",
|
||||
entity_type="package",
|
||||
entity_id=package_id,
|
||||
details={
|
||||
"client_id": payload.client_id,
|
||||
"total_sessions": payload.total_sessions,
|
||||
"financial_status": payload.financial_status,
|
||||
},
|
||||
)
|
||||
|
||||
fetch_query = """
|
||||
SELECT p.*, c.full_name AS client_name, c.phone_whatsapp AS client_phone, s.name AS service_name
|
||||
FROM packages p
|
||||
@@ -95,6 +110,7 @@ async def create_package(payload: PackageCreate):
|
||||
async def list_packages(
|
||||
client_id: str | None = None,
|
||||
financial_status: FinancialStatus | None = Query(None, alias="status"),
|
||||
_admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""List therapy packages with filter by client or financial status."""
|
||||
query = """
|
||||
@@ -124,7 +140,10 @@ async def list_packages(
|
||||
|
||||
|
||||
@router.get("/{package_id}", response_model=PackageRead)
|
||||
async def get_package(package_id: str):
|
||||
async def get_package(
|
||||
package_id: str,
|
||||
_admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Retrieve details and remaining balance for a specific package."""
|
||||
query = """
|
||||
SELECT p.*, c.full_name AS client_name, c.phone_whatsapp AS client_phone, s.name AS service_name
|
||||
@@ -141,11 +160,14 @@ async def get_package(package_id: str):
|
||||
|
||||
|
||||
@router.patch("/{package_id}", response_model=PackageRead)
|
||||
async def update_package(package_id: str, payload: PackageUpdate):
|
||||
async def update_package(
|
||||
package_id: str,
|
||||
payload: PackageUpdate,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Update package notes, sessions count, or financial status."""
|
||||
now = datetime.now(UTC).isoformat()
|
||||
async with get_db() as client:
|
||||
# Check exists
|
||||
res = await client.execute("SELECT * FROM packages WHERE id = ? LIMIT 1;", [package_id])
|
||||
if not res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Package not found")
|
||||
@@ -173,6 +195,15 @@ async def update_package(package_id: str, payload: PackageUpdate):
|
||||
update_query = f"UPDATE packages SET {', '.join(updates)} WHERE id = ?;"
|
||||
await client.execute(update_query, params)
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="UPDATE_PACKAGE",
|
||||
entity_type="package",
|
||||
entity_id=package_id,
|
||||
details=payload.model_dump(exclude_none=True),
|
||||
)
|
||||
|
||||
fetch_query = """
|
||||
SELECT p.*, c.full_name AS client_name, c.phone_whatsapp AS client_phone, s.name AS service_name
|
||||
FROM packages p
|
||||
|
||||
+106
-22
@@ -3,60 +3,118 @@ from __future__ import annotations
|
||||
import uuid
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from fastapi import APIRouter, HTTPException, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
from app.core.auth import record_admin_audit, require_admin
|
||||
from app.db.database import get_db, result_to_dicts, row_to_dict
|
||||
from app.schemas.payment import PaymentRead, PaymentVerificationRequest
|
||||
from app.routers.bookings import BOOKING_SELECT_QUERY
|
||||
from app.schemas.auth import AdminPrincipal
|
||||
from app.schemas.payment import PaymentAcknowledgmentRequest, PaymentRead
|
||||
from app.services.calendar import calendar_service
|
||||
|
||||
router = APIRouter(prefix="/payments", tags=["Payments"])
|
||||
|
||||
|
||||
@router.post("/verify", response_model=PaymentRead, status_code=status.HTTP_201_CREATED)
|
||||
async def verify_payment(payload: PaymentVerificationRequest):
|
||||
"""
|
||||
Admin-facing action: Jazmín confirms receipt of SPEI/OXXO deposit.
|
||||
Locks in the booking, changes status to CONFIRMED, and records the payment.
|
||||
"""
|
||||
async def _acknowledge_payment_impl(
|
||||
payload: PaymentAcknowledgmentRequest,
|
||||
admin: AdminPrincipal,
|
||||
) -> PaymentRead:
|
||||
async with get_db() as client:
|
||||
# 1. Fetch booking
|
||||
# 1. Fetch hydrated booking details
|
||||
b_res = await client.execute(
|
||||
"SELECT * FROM bookings WHERE id = ? LIMIT 1;",
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[payload.booking_id],
|
||||
)
|
||||
if not b_res.rows:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found")
|
||||
|
||||
booking = row_to_dict(b_res, b_res.rows[0])
|
||||
if booking["status"] == "CONFIRMED":
|
||||
if booking["payment_status"] == "ACKNOWLEDGED":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Booking is already confirmed",
|
||||
detail="Payment for this booking has already been acknowledged",
|
||||
)
|
||||
if booking["booking_status"] in ("RELEASED", "CANCELLED"):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Cannot acknowledge payment on a released or cancelled booking",
|
||||
)
|
||||
|
||||
now = datetime.now(UTC).isoformat()
|
||||
payment_id = str(uuid.uuid4())
|
||||
|
||||
# 2. Record payment
|
||||
# 2. Record payment acknowledgment
|
||||
await client.execute(
|
||||
"""
|
||||
INSERT INTO payments (id, booking_id, amount_mxn, payment_method, status, verified_at, notes, created_at)
|
||||
VALUES (?, ?, ?, ?, 'VERIFIED', ?, ?, ?);
|
||||
INSERT INTO payments (
|
||||
id, booking_id, amount_mxn, payment_method, status,
|
||||
acknowledged_by, acknowledged_at, notes, created_at
|
||||
)
|
||||
VALUES (?, ?, ?, ?, 'ACKNOWLEDGED', ?, ?, ?, ?);
|
||||
""",
|
||||
[
|
||||
payment_id,
|
||||
payload.booking_id,
|
||||
payload.amount_mxn,
|
||||
payload.payment_method,
|
||||
admin.email,
|
||||
now,
|
||||
payload.notes,
|
||||
now,
|
||||
],
|
||||
)
|
||||
|
||||
# 3. Transition booking to CONFIRMED
|
||||
# 3. Sync Google Calendar event to [CONFIRMADO]
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=payload.booking_id,
|
||||
booking_code=str(booking["booking_code"]),
|
||||
service_name=str(booking["service_name"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
scheduled_at=str(booking["scheduled_at"]),
|
||||
duration_minutes=int(booking["duration_minutes"]),
|
||||
booking_status=str(booking["booking_status"]),
|
||||
payment_arrangement=str(booking["payment_arrangement"]),
|
||||
payment_status="ACKNOWLEDGED",
|
||||
existing_event_id=booking.get("gcal_event_id"),
|
||||
)
|
||||
|
||||
# 4. Update booking payment_status and audit fields
|
||||
await client.execute(
|
||||
"UPDATE bookings SET status = 'CONFIRMED', confirmed_at = ? WHERE id = ?;",
|
||||
[now, payload.booking_id],
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET payment_status = 'ACKNOWLEDGED',
|
||||
acknowledged_by = ?,
|
||||
acknowledged_at = ?,
|
||||
gcal_event_id = ?,
|
||||
gcal_sync_status = ?,
|
||||
gcal_sync_error = ?,
|
||||
gcal_synced_at = ?
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[
|
||||
admin.email,
|
||||
now,
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
payload.booking_id,
|
||||
],
|
||||
)
|
||||
|
||||
# 5. Record audit log
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="ACKNOWLEDGE_PAYMENT",
|
||||
entity_type="booking",
|
||||
entity_id=payload.booking_id,
|
||||
details={
|
||||
"payment_id": payment_id,
|
||||
"amount_mxn": payload.amount_mxn,
|
||||
"payment_method": payload.payment_method,
|
||||
"notes": payload.notes,
|
||||
},
|
||||
)
|
||||
|
||||
return PaymentRead(
|
||||
@@ -64,16 +122,42 @@ async def verify_payment(payload: PaymentVerificationRequest):
|
||||
booking_id=payload.booking_id,
|
||||
amount_mxn=payload.amount_mxn,
|
||||
payment_method=payload.payment_method,
|
||||
status="VERIFIED",
|
||||
verified_at=now,
|
||||
status="ACKNOWLEDGED",
|
||||
acknowledged_by=admin.email,
|
||||
acknowledged_at=now,
|
||||
notes=payload.notes,
|
||||
created_at=now,
|
||||
)
|
||||
|
||||
|
||||
@router.post("/acknowledge", response_model=PaymentRead, status_code=status.HTTP_201_CREATED)
|
||||
async def acknowledge_payment(
|
||||
payload: PaymentAcknowledgmentRequest,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Admin-facing action: Jasmin or her assistant acknowledges receipt of SPEI/cash payment.
|
||||
Records who acknowledged the payment and when, transitions payment_status to ACKNOWLEDGED,
|
||||
and updates the Google Calendar event to [CONFIRMADO].
|
||||
"""
|
||||
return await _acknowledge_payment_impl(payload, admin)
|
||||
|
||||
|
||||
@router.post("/verify", response_model=PaymentRead, status_code=status.HTTP_201_CREATED)
|
||||
async def verify_payment_alias(
|
||||
payload: PaymentAcknowledgmentRequest,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Alias for /payments/acknowledge."""
|
||||
return await _acknowledge_payment_impl(payload, admin)
|
||||
|
||||
|
||||
@router.get("/history", response_model=list[PaymentRead])
|
||||
async def list_payments(limit: int = 50):
|
||||
"""List recent verified payment records."""
|
||||
async def list_payments(
|
||||
limit: int = 50,
|
||||
_admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""List recent acknowledged payment records."""
|
||||
async with get_db() as client:
|
||||
res = await client.execute(
|
||||
"SELECT * FROM payments ORDER BY created_at DESC LIMIT ?;",
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from datetime import UTC, date, datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||
|
||||
from app.core.auth import record_admin_audit, require_admin
|
||||
from app.core.config import settings
|
||||
from app.db.database import get_db, result_to_dicts, row_to_dict
|
||||
from app.models.payment import PaymentMethodEnum
|
||||
from app.routers.bookings import (
|
||||
BOOKING_SELECT_QUERY,
|
||||
generate_booking_code,
|
||||
parse_iso_datetime,
|
||||
)
|
||||
from app.schemas.auth import AdminPrincipal
|
||||
from app.schemas.roster import (
|
||||
QuickCheckinRequest,
|
||||
QuickCheckinResponse,
|
||||
RosterAttendeeRead,
|
||||
RosterSessionRead,
|
||||
)
|
||||
from app.services.calendar import calendar_service
|
||||
|
||||
router = APIRouter(prefix="/rosters", tags=["Group Workshop Rosters"])
|
||||
|
||||
|
||||
def _to_utc_instant_key(dt_str: str) -> str:
|
||||
"""Normalize ISO datetime string to an ISO UTC string so different representations group together."""
|
||||
dt = parse_iso_datetime(dt_str)
|
||||
return dt.astimezone(UTC).isoformat()
|
||||
|
||||
|
||||
@router.get("", response_model=list[RosterSessionRead])
|
||||
async def get_rosters(
|
||||
date_from: date = Query(..., description="Start date (YYYY-MM-DD)"),
|
||||
date_to: date = Query(..., description="End date (YYYY-MM-DD)"),
|
||||
service_id: str | None = Query(None, description="Optional service ID filter"),
|
||||
_admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Query workshop roster sessions for GROUP services within [date_from, date_to].
|
||||
Groups bookings by session instant across different ISO timezone representations.
|
||||
Excludes RELEASED and CANCELLED bookings.
|
||||
"""
|
||||
if date_to < date_from:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="date_to cannot be earlier than date_from.",
|
||||
)
|
||||
|
||||
# Convert date range to Mexico City timezone boundaries
|
||||
tz = ZoneInfo(settings.business_timezone)
|
||||
start_dt = datetime(
|
||||
date_from.year, date_from.month, date_from.day, 0, 0, 0, tzinfo=tz
|
||||
).astimezone(UTC)
|
||||
end_dt = datetime(
|
||||
date_to.year, date_to.month, date_to.day, 23, 59, 59, 999999, tzinfo=tz
|
||||
).astimezone(UTC)
|
||||
|
||||
query = (
|
||||
BOOKING_SELECT_QUERY
|
||||
+ """
|
||||
WHERE s.service_type = 'GROUP'
|
||||
AND b.booking_status IN ('RESERVED', 'COMPLETED', 'NO_SHOW')
|
||||
AND s.is_active = 1
|
||||
"""
|
||||
)
|
||||
params = []
|
||||
if service_id:
|
||||
query += " AND s.id = ?"
|
||||
params.append(service_id)
|
||||
|
||||
query += " ORDER BY b.scheduled_at ASC;"
|
||||
|
||||
async with get_db() as client:
|
||||
# Also fetch group service details
|
||||
svc_query = "SELECT id, name, max_capacity FROM services WHERE service_type = 'GROUP';"
|
||||
svc_res = await client.execute(svc_query)
|
||||
services_by_id = {
|
||||
str(r[0]): {"name": str(r[1]), "max_capacity": int(str(r[2] or 1))}
|
||||
for r in svc_res.rows
|
||||
}
|
||||
|
||||
res = await client.execute(query, params)
|
||||
rows = result_to_dicts(res)
|
||||
|
||||
# Group by (service_id, normalized_instant_key)
|
||||
sessions_map: dict[tuple[str, str], dict] = {}
|
||||
|
||||
for r in rows:
|
||||
sched_dt_utc = parse_iso_datetime(str(r["scheduled_at"])).astimezone(UTC)
|
||||
if not (start_dt <= sched_dt_utc <= end_dt):
|
||||
continue
|
||||
|
||||
svc_id = str(r["service_id"])
|
||||
instant_key = sched_dt_utc.isoformat()
|
||||
group_key = (svc_id, instant_key)
|
||||
|
||||
if group_key not in sessions_map:
|
||||
svc_info = services_by_id.get(
|
||||
svc_id, {"name": str(r.get("service_name", "")), "max_capacity": 20}
|
||||
)
|
||||
sessions_map[group_key] = {
|
||||
"service_id": svc_id,
|
||||
"service_name": svc_info["name"],
|
||||
"scheduled_at": str(r["scheduled_at"]), # preserve representative representation
|
||||
"max_capacity": svc_info["max_capacity"],
|
||||
"attendees": [],
|
||||
}
|
||||
|
||||
booking_status = str(r["booking_status"])
|
||||
attended = booking_status == "COMPLETED"
|
||||
|
||||
sessions_map[group_key]["attendees"].append(
|
||||
RosterAttendeeRead(
|
||||
booking_id=str(r["id"]),
|
||||
booking_code=str(r["booking_code"]),
|
||||
client_id=str(r["client_id"]),
|
||||
client_name=str(r.get("client_name") or ""),
|
||||
client_phone=str(r.get("client_phone") or ""),
|
||||
client_email=r.get("client_email"),
|
||||
booking_status=booking_status,
|
||||
payment_arrangement=str(r["payment_arrangement"]),
|
||||
payment_status=str(r["payment_status"]),
|
||||
amount_mxn=int(r["amount_mxn"]),
|
||||
attended=attended,
|
||||
)
|
||||
)
|
||||
|
||||
roster_sessions: list[RosterSessionRead] = []
|
||||
for s_data in sessions_map.values():
|
||||
attendees = s_data["attendees"]
|
||||
occupied_count = len(attendees)
|
||||
attended_count = sum(1 for a in attendees if a.attended)
|
||||
roster_sessions.append(
|
||||
RosterSessionRead(
|
||||
service_id=s_data["service_id"],
|
||||
service_name=s_data["service_name"],
|
||||
scheduled_at=s_data["scheduled_at"],
|
||||
max_capacity=s_data["max_capacity"],
|
||||
occupied_count=occupied_count,
|
||||
attended_count=attended_count,
|
||||
attendees=attendees,
|
||||
)
|
||||
)
|
||||
|
||||
return roster_sessions
|
||||
|
||||
|
||||
@router.post("/quick-checkin", response_model=QuickCheckinResponse)
|
||||
async def quick_checkin(
|
||||
payload: QuickCheckinRequest,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""
|
||||
Perform a quick check-in for group workshops:
|
||||
- Mode 1: Check in an existing booking (marking COMPLETED, optionally recording CASH payment).
|
||||
- Mode 2: Register a walk-in attendee directly into COMPLETED status.
|
||||
"""
|
||||
now = datetime.now(UTC).isoformat()
|
||||
|
||||
async with get_db() as client:
|
||||
# MODE 1: Existing booking check-in
|
||||
if payload.booking_id:
|
||||
b_res = await client.execute(
|
||||
BOOKING_SELECT_QUERY + " WHERE b.id = ? LIMIT 1;",
|
||||
[payload.booking_id],
|
||||
)
|
||||
if not b_res.rows:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Booking not found."
|
||||
)
|
||||
|
||||
booking = row_to_dict(b_res, b_res.rows[0])
|
||||
svc_res = await client.execute(
|
||||
"SELECT service_type FROM services WHERE id = ?;", [booking["service_id"]]
|
||||
)
|
||||
if not svc_res.rows or str(svc_res.rows[0][0]) != "GROUP":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Quick check-in is only available for GROUP workshops.",
|
||||
)
|
||||
|
||||
current_status = str(booking["booking_status"])
|
||||
if current_status in ("RELEASED", "CANCELLED"):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Cannot check in a {current_status.lower()} booking.",
|
||||
)
|
||||
if current_status == "COMPLETED":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail="This attendee has already checked in.",
|
||||
)
|
||||
|
||||
new_booking_status = "COMPLETED"
|
||||
payment_id: str | None = None
|
||||
current_p_status = str(booking["payment_status"])
|
||||
current_p_arr = str(booking["payment_arrangement"])
|
||||
|
||||
if payload.paid_cash:
|
||||
new_p_status = "ACKNOWLEDGED"
|
||||
new_p_arr = current_p_arr
|
||||
payment_id = str(uuid.uuid4())
|
||||
await client.execute(
|
||||
"""
|
||||
INSERT INTO payments (
|
||||
id, booking_id, amount_mxn, payment_method, status,
|
||||
acknowledged_by, acknowledged_at, notes, created_at
|
||||
)
|
||||
VALUES (?, ?, ?, ?, 'ACKNOWLEDGED', ?, ?, ?, ?);
|
||||
""",
|
||||
[
|
||||
payment_id,
|
||||
booking["id"],
|
||||
booking["amount_mxn"],
|
||||
PaymentMethodEnum.CASH.value,
|
||||
admin.email,
|
||||
now,
|
||||
payload.notes or "Quick check-in cash payment",
|
||||
now,
|
||||
],
|
||||
)
|
||||
else:
|
||||
if current_p_status == "ACKNOWLEDGED":
|
||||
new_p_status = "ACKNOWLEDGED"
|
||||
new_p_arr = current_p_arr
|
||||
else:
|
||||
new_p_status = "AWAITING_ACKNOWLEDGMENT"
|
||||
new_p_arr = "DELAYED_ALLOWED"
|
||||
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=str(booking["id"]),
|
||||
booking_code=str(booking["booking_code"]),
|
||||
service_name=str(booking["service_name"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
scheduled_at=str(booking["scheduled_at"]),
|
||||
duration_minutes=int(booking["duration_minutes"]),
|
||||
booking_status=new_booking_status,
|
||||
payment_arrangement=new_p_arr,
|
||||
payment_status=new_p_status,
|
||||
existing_event_id=booking.get("gcal_event_id"),
|
||||
)
|
||||
|
||||
await client.execute(
|
||||
"""
|
||||
UPDATE bookings
|
||||
SET booking_status = ?,
|
||||
payment_arrangement = ?,
|
||||
payment_status = ?,
|
||||
gcal_event_id = ?,
|
||||
gcal_sync_status = ?,
|
||||
gcal_sync_error = ?,
|
||||
gcal_synced_at = ?
|
||||
WHERE id = ?;
|
||||
""",
|
||||
[
|
||||
new_booking_status,
|
||||
new_p_arr,
|
||||
new_p_status,
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
booking["id"],
|
||||
],
|
||||
)
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="ROSTER_CHECKIN",
|
||||
entity_type="booking",
|
||||
entity_id=str(booking["id"]),
|
||||
details={"paid_cash": payload.paid_cash, "payment_id": payment_id},
|
||||
)
|
||||
|
||||
attendee = RosterAttendeeRead(
|
||||
booking_id=str(booking["id"]),
|
||||
booking_code=str(booking["booking_code"]),
|
||||
client_id=str(booking["client_id"]),
|
||||
client_name=str(booking["client_name"]),
|
||||
client_phone=str(booking["client_phone"]),
|
||||
client_email=booking.get("client_email"),
|
||||
booking_status=new_booking_status,
|
||||
payment_arrangement=new_p_arr,
|
||||
payment_status=new_p_status,
|
||||
amount_mxn=int(booking["amount_mxn"]),
|
||||
attended=True,
|
||||
)
|
||||
return QuickCheckinResponse(walk_in=False, attendee=attendee, payment_id=payment_id)
|
||||
|
||||
# MODE 2: Walk-in registration and check-in
|
||||
service_id = str(payload.service_id)
|
||||
scheduled_at = str(payload.scheduled_at)
|
||||
client_name = str(payload.client_name)
|
||||
client_phone = str(payload.client_phone)
|
||||
|
||||
svc_res = await client.execute(
|
||||
"SELECT * FROM services WHERE id = ? AND is_active = 1 LIMIT 1;",
|
||||
[service_id],
|
||||
)
|
||||
if not svc_res.rows:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Service not found or inactive."
|
||||
)
|
||||
|
||||
service = row_to_dict(svc_res, svc_res.rows[0])
|
||||
if service["service_type"] != "GROUP":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Walk-in check-in is only applicable to GROUP workshops.",
|
||||
)
|
||||
|
||||
# Capacity check for this group workshop session
|
||||
cap_res = await client.execute(
|
||||
"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM bookings
|
||||
WHERE service_id = ? AND scheduled_at = ? AND booking_status IN ('RESERVED', 'COMPLETED');
|
||||
""",
|
||||
[service_id, scheduled_at],
|
||||
)
|
||||
current_count = int(str(cap_res.rows[0][0] or 0))
|
||||
max_cap = int(service.get("max_capacity", 1))
|
||||
if current_count >= max_cap:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail=f"El taller ha alcanzado su cupo máximo ({max_cap}) para esta sesión.",
|
||||
)
|
||||
|
||||
# Upsert client by phone
|
||||
c_res = await client.execute(
|
||||
"SELECT id FROM clients WHERE phone_whatsapp = ? LIMIT 1;",
|
||||
[client_phone],
|
||||
)
|
||||
if c_res.rows:
|
||||
client_id = str(c_res.rows[0][0])
|
||||
else:
|
||||
client_id = str(uuid.uuid4())
|
||||
await client.execute(
|
||||
"INSERT INTO clients (id, full_name, phone_whatsapp, email, notes) VALUES (?, ?, ?, ?, ?);",
|
||||
[client_id, client_name, client_phone, payload.client_email, "Walk-in attendee"],
|
||||
)
|
||||
|
||||
booking_id = str(uuid.uuid4())
|
||||
booking_code = generate_booking_code()
|
||||
duration_minutes = int(service.get("duration_minutes", 60))
|
||||
buffer_minutes = int(service.get("buffer_minutes", 0))
|
||||
amount_mxn = int(service["price_mxn"])
|
||||
|
||||
booking_status = "COMPLETED"
|
||||
if payload.paid_cash:
|
||||
payment_status = "ACKNOWLEDGED"
|
||||
payment_arrangement = "PREPAID_DEFAULT"
|
||||
else:
|
||||
payment_status = "AWAITING_ACKNOWLEDGMENT"
|
||||
payment_arrangement = "DELAYED_ALLOWED"
|
||||
|
||||
cal_res = await calendar_service.sync_booking_event(
|
||||
booking_id=booking_id,
|
||||
booking_code=booking_code,
|
||||
service_name=str(service["name"]),
|
||||
client_name=client_name,
|
||||
scheduled_at=scheduled_at,
|
||||
duration_minutes=duration_minutes,
|
||||
booking_status=booking_status,
|
||||
payment_arrangement=payment_arrangement,
|
||||
payment_status=payment_status,
|
||||
)
|
||||
|
||||
await client.execute(
|
||||
"""
|
||||
INSERT INTO bookings (
|
||||
id, booking_code, service_id, client_id, scheduled_at,
|
||||
duration_minutes, buffer_minutes, booking_status, payment_arrangement,
|
||||
payment_status, amount_mxn, gcal_event_id, gcal_sync_status,
|
||||
gcal_sync_error, gcal_synced_at, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
||||
""",
|
||||
[
|
||||
booking_id,
|
||||
booking_code,
|
||||
service["id"],
|
||||
client_id,
|
||||
scheduled_at,
|
||||
duration_minutes,
|
||||
buffer_minutes,
|
||||
booking_status,
|
||||
payment_arrangement,
|
||||
payment_status,
|
||||
amount_mxn,
|
||||
cal_res.event_id,
|
||||
cal_res.sync_status,
|
||||
cal_res.sync_error,
|
||||
cal_res.synced_at,
|
||||
now,
|
||||
],
|
||||
)
|
||||
|
||||
payment_id = None
|
||||
if payload.paid_cash:
|
||||
payment_id = str(uuid.uuid4())
|
||||
await client.execute(
|
||||
"""
|
||||
INSERT INTO payments (
|
||||
id, booking_id, amount_mxn, payment_method, status,
|
||||
acknowledged_by, acknowledged_at, notes, created_at
|
||||
) VALUES (?, ?, ?, ?, 'ACKNOWLEDGED', ?, ?, ?, ?);
|
||||
""",
|
||||
[
|
||||
payment_id,
|
||||
booking_id,
|
||||
amount_mxn,
|
||||
PaymentMethodEnum.CASH.value,
|
||||
admin.email,
|
||||
now,
|
||||
payload.notes or "Walk-in cash payment",
|
||||
now,
|
||||
],
|
||||
)
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="ROSTER_WALK_IN",
|
||||
entity_type="booking",
|
||||
entity_id=booking_id,
|
||||
details={"paid_cash": payload.paid_cash, "payment_id": payment_id},
|
||||
)
|
||||
|
||||
attendee = RosterAttendeeRead(
|
||||
booking_id=booking_id,
|
||||
booking_code=booking_code,
|
||||
client_id=client_id,
|
||||
client_name=client_name,
|
||||
client_phone=client_phone,
|
||||
client_email=payload.client_email,
|
||||
booking_status=booking_status,
|
||||
payment_arrangement=payment_arrangement,
|
||||
payment_status=payment_status,
|
||||
amount_mxn=amount_mxn,
|
||||
attended=True,
|
||||
)
|
||||
|
||||
return QuickCheckinResponse(walk_in=True, attendee=attendee, payment_id=payment_id)
|
||||
+19
-6
@@ -2,9 +2,11 @@ from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
|
||||
from fastapi import APIRouter, HTTPException, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
from app.core.auth import record_admin_audit, require_admin
|
||||
from app.db.database import get_db, result_to_dicts, row_to_dict
|
||||
from app.schemas.auth import AdminPrincipal
|
||||
from app.schemas.service import ServiceCreate, ServiceRead
|
||||
|
||||
router = APIRouter(prefix="/services", tags=["Services"])
|
||||
@@ -21,10 +23,9 @@ async def list_services(active_only: bool = True):
|
||||
async with get_db() as client:
|
||||
res = await client.execute(query)
|
||||
rows = result_to_dicts(res)
|
||||
# convert integer is_active to bool
|
||||
for r in rows:
|
||||
r["is_active"] = bool(r.get("is_active", 1))
|
||||
return rows
|
||||
return [ServiceRead(**r) for r in rows]
|
||||
|
||||
|
||||
@router.get("/{service_id_or_slug}", response_model=ServiceRead)
|
||||
@@ -37,11 +38,14 @@ async def get_service(service_id_or_slug: str):
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Service not found")
|
||||
item = row_to_dict(res, res.rows[0])
|
||||
item["is_active"] = bool(item.get("is_active", 1))
|
||||
return item
|
||||
return ServiceRead(**item)
|
||||
|
||||
|
||||
@router.post("", response_model=ServiceRead, status_code=status.HTTP_201_CREATED)
|
||||
async def create_service(payload: ServiceCreate):
|
||||
async def create_service(
|
||||
payload: ServiceCreate,
|
||||
admin: AdminPrincipal = Depends(require_admin),
|
||||
):
|
||||
"""Add a new service to the catalog (Admin action)."""
|
||||
service_id = str(uuid.uuid4())
|
||||
insert_query = """
|
||||
@@ -75,8 +79,17 @@ async def create_service(payload: ServiceCreate):
|
||||
detail=f"Failed to create service: {e}",
|
||||
) from e
|
||||
|
||||
await record_admin_audit(
|
||||
client,
|
||||
admin_email=admin.email,
|
||||
action_type="CREATE_SERVICE",
|
||||
entity_type="service",
|
||||
entity_id=service_id,
|
||||
details={"slug": payload.slug, "name": payload.name},
|
||||
)
|
||||
|
||||
fetch_query = "SELECT * FROM services WHERE id = ? LIMIT 1;"
|
||||
res = await client.execute(fetch_query, [service_id])
|
||||
item = row_to_dict(res, res.rows[0])
|
||||
item["is_active"] = bool(item.get("is_active", 1))
|
||||
return item
|
||||
return ServiceRead(**item)
|
||||
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
AdminRole = Literal["OWNER", "ASSISTANT", "ADMIN"]
|
||||
|
||||
|
||||
class AdminPrincipal(BaseModel):
|
||||
email: str
|
||||
full_name: str
|
||||
role: AdminRole
|
||||
is_active: bool = True
|
||||
last_login_at: str | None = None
|
||||
|
||||
|
||||
class AdminAllowlistCreate(BaseModel):
|
||||
email: str = Field(..., min_length=5)
|
||||
full_name: str = Field(..., min_length=2)
|
||||
role: AdminRole = "ASSISTANT"
|
||||
is_active: bool = True
|
||||
|
||||
|
||||
class AdminAllowlistUpdate(BaseModel):
|
||||
full_name: str | None = None
|
||||
role: AdminRole | None = None
|
||||
is_active: bool | None = None
|
||||
|
||||
|
||||
class AuditLogRead(BaseModel):
|
||||
id: str
|
||||
admin_email: str
|
||||
action_type: str
|
||||
entity_type: str
|
||||
entity_id: str
|
||||
details_json: str | None = None
|
||||
created_at: str
|
||||
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class SlotRead(BaseModel):
|
||||
start: str
|
||||
end: str
|
||||
|
||||
|
||||
class DayAvailabilityRead(BaseModel):
|
||||
date: str
|
||||
slots: list[SlotRead]
|
||||
|
||||
|
||||
class AvailabilityResponse(BaseModel):
|
||||
service_id: str
|
||||
service_name: str
|
||||
duration_minutes: int
|
||||
buffer_minutes: int
|
||||
timezone: str
|
||||
days: list[DayAvailabilityRead]
|
||||
+56
-4
@@ -4,7 +4,10 @@ from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
BookingStatus = Literal["PENDING_PAYMENT", "CONFIRMED", "CANCELLED", "EXPIRED", "NO_SHOW"]
|
||||
BookingStatus = Literal["RESERVED", "RELEASED", "CANCELLED", "COMPLETED", "NO_SHOW"]
|
||||
PaymentArrangement = Literal["PREPAID_DEFAULT", "DELAYED_ALLOWED", "PACKAGE_REDEEMED"]
|
||||
BookingPaymentStatus = Literal["AWAITING_ACKNOWLEDGMENT", "ACKNOWLEDGED", "NOT_APPLICABLE"]
|
||||
CalendarSyncStatus = Literal["PENDING", "SYNCED", "FAILED", "NOT_CONFIGURED"]
|
||||
|
||||
|
||||
class BookingCreate(BaseModel):
|
||||
@@ -17,6 +20,41 @@ class BookingCreate(BaseModel):
|
||||
package_id: str | None = None
|
||||
|
||||
|
||||
class DelayedPaymentAuthorizeRequest(BaseModel):
|
||||
notes: str | None = Field(
|
||||
default=None,
|
||||
description="Optional administrative explanation for allowing delayed payment",
|
||||
)
|
||||
|
||||
|
||||
class BookingReleaseRequest(BaseModel):
|
||||
reason: str | None = Field(
|
||||
default=None,
|
||||
description="Optional administrative reason for releasing the slot",
|
||||
)
|
||||
|
||||
|
||||
class BookingStatusUpdateRequest(BaseModel):
|
||||
booking_status: Literal["COMPLETED", "CANCELLED", "NO_SHOW"]
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class BookingRescheduleRequest(BaseModel):
|
||||
new_scheduled_at: str = Field(
|
||||
..., description="ISO 8601 string for new scheduled date and time"
|
||||
)
|
||||
notes: str | None = Field(default=None, description="Optional notes or reason for rescheduling")
|
||||
|
||||
|
||||
class BookingCompleteRequest(BaseModel):
|
||||
package_id: str | None = Field(
|
||||
default=None, description="Optional package to link or redeem for this booking"
|
||||
)
|
||||
notes: str | None = Field(
|
||||
default=None, description="Optional clinical/consultation completion notes"
|
||||
)
|
||||
|
||||
|
||||
class BookingRead(BaseModel):
|
||||
id: str
|
||||
booking_code: str
|
||||
@@ -29,10 +67,24 @@ class BookingRead(BaseModel):
|
||||
scheduled_at: str
|
||||
duration_minutes: int = 60
|
||||
buffer_minutes: int = 0
|
||||
status: BookingStatus
|
||||
booking_status: BookingStatus
|
||||
payment_arrangement: PaymentArrangement
|
||||
payment_status: BookingPaymentStatus
|
||||
amount_mxn: int
|
||||
needs_payment_followup: bool = False
|
||||
hours_until_session: float = 0.0
|
||||
exception_authorized_by: str | None = None
|
||||
exception_authorized_at: str | None = None
|
||||
exception_notes: str | None = None
|
||||
released_by: str | None = None
|
||||
released_at: str | None = None
|
||||
release_reason: str | None = None
|
||||
acknowledged_by: str | None = None
|
||||
acknowledged_at: str | None = None
|
||||
gcal_event_id: str | None = None
|
||||
expires_at: str
|
||||
gcal_sync_status: CalendarSyncStatus = "NOT_CONFIGURED"
|
||||
gcal_sync_error: str | None = None
|
||||
gcal_synced_at: str | None = None
|
||||
created_at: str
|
||||
confirmed_at: str | None = None
|
||||
whatsapp_redirect_url: str | None = None
|
||||
whatsapp_followup_url: str | None = None
|
||||
+72
-3
@@ -1,19 +1,88 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, EmailStr, Field, field_validator
|
||||
|
||||
from app.schemas.booking import BookingRead
|
||||
from app.schemas.package import PackageRead
|
||||
|
||||
PHONE_WITH_EXT_REGEX = re.compile(
|
||||
r"^((?:\+?\d{1,3}[-.\s]?)?(?:\(?\d{2,4}\)?[-.\s]?){2,4}\d{3,4})(?:[-.\s]*(?:ext|ext\.|x|#|extension)[-.\s]*(\d+))?$",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
|
||||
def validate_phone_format(v: str) -> str:
|
||||
clean_value = v.strip()
|
||||
if not PHONE_WITH_EXT_REGEX.match(clean_value):
|
||||
raise ValueError(
|
||||
"Invalid phone number format. Examples of valid formats: "
|
||||
"'+1 (555) 019-2834', '555-019-2834 ext 123', or '5550192834x12'"
|
||||
)
|
||||
return clean_value
|
||||
|
||||
|
||||
class ClientBase(BaseModel):
|
||||
full_name: str = Field(..., min_length=2, max_length=150)
|
||||
phone_whatsapp: str = Field(..., min_length=10, max_length=20)
|
||||
email: str | None = None
|
||||
phone_whatsapp: str = Field(..., min_length=10, max_length=50)
|
||||
email: EmailStr | None = None
|
||||
notes: str | None = None
|
||||
|
||||
@field_validator("phone_whatsapp")
|
||||
@classmethod
|
||||
def validate_phone(cls, v: str) -> str:
|
||||
return validate_phone_format(v)
|
||||
|
||||
@field_validator("email", mode="before")
|
||||
@classmethod
|
||||
def normalize_email(cls, v: Any) -> Any:
|
||||
if isinstance(v, str) and not v.strip():
|
||||
return None
|
||||
return v
|
||||
|
||||
|
||||
class ClientCreate(ClientBase):
|
||||
pass
|
||||
|
||||
|
||||
class ClientUpdate(BaseModel):
|
||||
full_name: str | None = Field(default=None, min_length=2, max_length=150)
|
||||
phone_whatsapp: str | None = Field(default=None, min_length=10, max_length=50)
|
||||
email: EmailStr | None = None
|
||||
notes: str | None = None
|
||||
|
||||
@field_validator("phone_whatsapp")
|
||||
@classmethod
|
||||
def validate_phone(cls, v: str | None) -> str | None:
|
||||
if v is None:
|
||||
return None
|
||||
return validate_phone_format(v)
|
||||
|
||||
@field_validator("email", mode="before")
|
||||
@classmethod
|
||||
def normalize_email(cls, v: Any) -> Any:
|
||||
if isinstance(v, str) and not v.strip():
|
||||
return None
|
||||
return v
|
||||
|
||||
|
||||
class ClientRead(ClientBase):
|
||||
id: str
|
||||
created_at: str
|
||||
|
||||
|
||||
class Client360Read(BaseModel):
|
||||
id: str
|
||||
full_name: str
|
||||
phone_whatsapp: str
|
||||
email: EmailStr | None = None
|
||||
notes: str | None = None
|
||||
created_at: str
|
||||
active_packages: list[PackageRead] = Field(default_factory=list)
|
||||
booking_history: list[BookingRead] = Field(default_factory=list)
|
||||
recent_bookings: list[BookingRead] = Field(default_factory=list)
|
||||
|
||||
|
||||
ClientDetailRead = Client360Read
|
||||
@@ -5,22 +5,27 @@ from typing import Literal
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
PaymentMethod = Literal["SPEI", "OXXO", "CASH"]
|
||||
PaymentStatus = Literal["PENDING", "VERIFIED", "REJECTED"]
|
||||
PaymentStatus = Literal["ACKNOWLEDGED", "REVERSED"]
|
||||
|
||||
|
||||
class PaymentVerificationRequest(BaseModel):
|
||||
class PaymentAcknowledgmentRequest(BaseModel):
|
||||
booking_id: str
|
||||
amount_mxn: int = Field(..., ge=0)
|
||||
payment_method: PaymentMethod = "SPEI"
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
# Alias for backward compatibility
|
||||
PaymentVerificationRequest = PaymentAcknowledgmentRequest
|
||||
|
||||
|
||||
class PaymentRead(BaseModel):
|
||||
id: str
|
||||
booking_id: str
|
||||
amount_mxn: int
|
||||
payment_method: PaymentMethod
|
||||
status: PaymentStatus
|
||||
verified_at: str | None = None
|
||||
acknowledged_by: str
|
||||
acknowledged_at: str
|
||||
notes: str | None = None
|
||||
created_at: str
|
||||
@@ -0,0 +1,71 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel, model_validator
|
||||
|
||||
|
||||
class RosterAttendeeRead(BaseModel):
|
||||
booking_id: str
|
||||
booking_code: str
|
||||
client_id: str
|
||||
client_name: str
|
||||
client_phone: str
|
||||
client_email: str | None = None
|
||||
booking_status: str
|
||||
payment_arrangement: str
|
||||
payment_status: str
|
||||
amount_mxn: int
|
||||
attended: bool
|
||||
|
||||
|
||||
class RosterSessionRead(BaseModel):
|
||||
service_id: str
|
||||
service_name: str
|
||||
scheduled_at: str
|
||||
max_capacity: int
|
||||
occupied_count: int
|
||||
attended_count: int
|
||||
attendees: list[RosterAttendeeRead]
|
||||
|
||||
|
||||
class QuickCheckinRequest(BaseModel):
|
||||
# Mode 1: existing booking check-in
|
||||
booking_id: str | None = None
|
||||
|
||||
# Mode 2: walk-in check-in
|
||||
service_id: str | None = None
|
||||
scheduled_at: str | None = None
|
||||
client_name: str | None = None
|
||||
client_phone: str | None = None
|
||||
client_email: str | None = None
|
||||
|
||||
paid_cash: bool = False
|
||||
notes: str | None = None
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_exactly_one_mode(self) -> QuickCheckinRequest:
|
||||
has_booking_id = bool(self.booking_id)
|
||||
has_any_walk_in = any(
|
||||
[self.service_id, self.scheduled_at, self.client_name, self.client_phone]
|
||||
)
|
||||
is_complete_walk_in = bool(
|
||||
self.service_id and self.scheduled_at and self.client_name and self.client_phone
|
||||
)
|
||||
|
||||
if has_booking_id:
|
||||
if has_any_walk_in:
|
||||
raise ValueError("Cannot combine 'booking_id' with walk-in fields.")
|
||||
return self
|
||||
|
||||
if is_complete_walk_in:
|
||||
return self
|
||||
|
||||
raise ValueError(
|
||||
"Must provide either 'booking_id' for an existing booking, "
|
||||
"or ('service_id', 'scheduled_at', 'client_name', 'client_phone') for a walk-in."
|
||||
)
|
||||
|
||||
|
||||
class QuickCheckinResponse(BaseModel):
|
||||
walk_in: bool
|
||||
attendee: RosterAttendeeRead
|
||||
payment_id: str | None = None
|
||||
@@ -8,7 +8,7 @@ from pydantic import BaseModel, Field
|
||||
class ServiceBase(BaseModel):
|
||||
name: str = Field(..., min_length=2, max_length=150)
|
||||
description: str | None = None
|
||||
service_type: Literal["GROUP", "ONE_ON_ONE"]
|
||||
service_type: Literal["GROUP", "INDIVIDUAL"]
|
||||
modality: Literal["PRESENCIAL", "ONLINE"]
|
||||
default_schedule: str | None = None
|
||||
price_mxn: int = Field(..., ge=0)
|
||||
@@ -25,7 +25,7 @@ class ServiceCreate(ServiceBase):
|
||||
class ServiceUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
description: str | None = None
|
||||
service_type: Literal["GROUP", "ONE_ON_ONE"] | None = None
|
||||
service_type: Literal["GROUP", "INDIVIDUAL"] | None = None
|
||||
modality: Literal["PRESENCIAL", "ONLINE"] | None = None
|
||||
default_schedule: str | None = None
|
||||
price_mxn: int | None = Field(default=None, ge=0)
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import UTC, date, datetime, time, timedelta
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BlockedInterval:
|
||||
start: datetime
|
||||
end: datetime
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AvailableSlot:
|
||||
start: datetime
|
||||
end: datetime
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BusinessHours:
|
||||
timezone: ZoneInfo
|
||||
open_time: time
|
||||
close_time: time
|
||||
working_weekdays: frozenset[int] # 0=Monday .. 6=Sunday
|
||||
slot_step_minutes: int
|
||||
|
||||
|
||||
def blocked_interval(
|
||||
start: datetime, duration_minutes: int, buffer_minutes: int
|
||||
) -> BlockedInterval:
|
||||
"""Build a blocked interval including mandatory post-session buffer."""
|
||||
return BlockedInterval(start, start + timedelta(minutes=duration_minutes + buffer_minutes))
|
||||
|
||||
|
||||
def intervals_overlap(a: BlockedInterval, b: BlockedInterval) -> bool:
|
||||
"""
|
||||
Two half-open intervals [a.start, a.end) and [b.start, b.end) overlap
|
||||
if max(a.start, b.start) < min(a.end, b.end).
|
||||
Touching at the exact boundary (a.end == b.start) is NOT an overlap.
|
||||
"""
|
||||
return max(a.start, b.start) < min(a.end, b.end)
|
||||
|
||||
|
||||
def compute_available_slots(
|
||||
*,
|
||||
date_from: date,
|
||||
date_to: date,
|
||||
duration_minutes: int,
|
||||
buffer_minutes: int,
|
||||
existing: list[BlockedInterval],
|
||||
hours: BusinessHours,
|
||||
now: datetime | None = None,
|
||||
) -> list[AvailableSlot]:
|
||||
"""
|
||||
Compute collision-free individual appointment slots across [date_from, date_to] (inclusive).
|
||||
Candidate slots are generated in the business timezone from open_time to close_time.
|
||||
A candidate slot is rejected if:
|
||||
1. Its actual session end (start + duration) exceeds close_time.
|
||||
2. Its start is at or before `now` (UTC).
|
||||
3. Its blocked interval (start + duration + buffer) overlaps with any existing blocked interval.
|
||||
"""
|
||||
if date_to < date_from:
|
||||
raise ValueError("date_to cannot precede date_from")
|
||||
|
||||
ref_now = now or datetime.now(UTC)
|
||||
slots: list[AvailableSlot] = []
|
||||
step = timedelta(minutes=hours.slot_step_minutes)
|
||||
session_delta = timedelta(minutes=duration_minutes)
|
||||
|
||||
current_date = date_from
|
||||
while current_date <= date_to:
|
||||
if current_date.weekday() in hours.working_weekdays:
|
||||
day_open = datetime.combine(current_date, hours.open_time, tzinfo=hours.timezone)
|
||||
day_close = datetime.combine(current_date, hours.close_time, tzinfo=hours.timezone)
|
||||
|
||||
candidate_start = day_open
|
||||
while candidate_start < day_close:
|
||||
session_end = candidate_start + session_delta
|
||||
if session_end > day_close:
|
||||
break
|
||||
|
||||
# Verify candidate is strictly in the future compared to ref_now
|
||||
candidate_start_utc = candidate_start.astimezone(UTC)
|
||||
if candidate_start_utc > ref_now:
|
||||
candidate_blocked = blocked_interval(
|
||||
candidate_start, duration_minutes, buffer_minutes
|
||||
)
|
||||
# Check collision against existing blocked intervals
|
||||
has_collision = False
|
||||
for b in existing:
|
||||
# Normalize timezones for safety when comparing
|
||||
b_start_norm = b.start.astimezone(hours.timezone)
|
||||
b_end_norm = b.end.astimezone(hours.timezone)
|
||||
if intervals_overlap(
|
||||
candidate_blocked, BlockedInterval(b_start_norm, b_end_norm)
|
||||
):
|
||||
has_collision = True
|
||||
break
|
||||
|
||||
if not has_collision:
|
||||
slots.append(AvailableSlot(start=candidate_start, end=session_end))
|
||||
|
||||
candidate_start += step
|
||||
|
||||
current_date += timedelta(days=1)
|
||||
|
||||
return slots
|
||||
@@ -0,0 +1,212 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import secrets
|
||||
import urllib.parse
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from typing import Any
|
||||
|
||||
from app.core.config import settings
|
||||
from app.schemas.booking import BookingRead
|
||||
from app.services.timestamps import parse_iso_datetime
|
||||
|
||||
|
||||
def check_slot_collision(
|
||||
new_start: datetime,
|
||||
new_duration: int,
|
||||
new_buffer: int,
|
||||
existing_bookings: list[dict[str, Any]],
|
||||
) -> bool:
|
||||
"""
|
||||
Returns True if the requested slot interval (including mandatory buffer)
|
||||
collides with any existing RESERVED booking interval (including its buffer).
|
||||
Formula: max(A_start, B_start) < min(A_blocked_end, B_blocked_end)
|
||||
"""
|
||||
new_blocked_end = new_start + timedelta(minutes=new_duration + new_buffer)
|
||||
for b in existing_bookings:
|
||||
exist_start = parse_iso_datetime(str(b["scheduled_at"]))
|
||||
exist_duration = int(b.get("duration_minutes", 60))
|
||||
exist_buffer = int(b.get("buffer_minutes", 0))
|
||||
exist_blocked_end = exist_start + timedelta(minutes=exist_duration + exist_buffer)
|
||||
|
||||
if new_start < exist_blocked_end and exist_start < new_blocked_end:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def calculate_hours_until(scheduled_at: datetime | str, now: datetime | None = None) -> float:
|
||||
"""Calculate hours remaining until scheduled_at from now (UTC)."""
|
||||
ref_now = now or datetime.now(UTC)
|
||||
if isinstance(scheduled_at, str):
|
||||
sched_dt = parse_iso_datetime(scheduled_at)
|
||||
else:
|
||||
sched_dt = (
|
||||
scheduled_at if scheduled_at.tzinfo is not None else scheduled_at.replace(tzinfo=UTC)
|
||||
)
|
||||
return round((sched_dt - ref_now).total_seconds() / 3600.0, 2)
|
||||
|
||||
|
||||
def evaluate_payment_followup(
|
||||
*,
|
||||
booking_status: str,
|
||||
payment_status: str,
|
||||
payment_arrangement: str,
|
||||
hours_until: float,
|
||||
threshold_hours: int = 48,
|
||||
) -> bool:
|
||||
"""
|
||||
Evaluate if an appointment requires payment follow-up:
|
||||
1. payment_status must be 'AWAITING_ACKNOWLEDGMENT'
|
||||
2. AND either:
|
||||
a) booking_status is 'RESERVED' and hours_until <= threshold_hours (default 48h)
|
||||
b) payment_arrangement is 'DELAYED_ALLOWED' and booking_status is 'RESERVED' or 'COMPLETED'
|
||||
"""
|
||||
if payment_status != "AWAITING_ACKNOWLEDGMENT":
|
||||
return False
|
||||
|
||||
is_imminent_reserved = (booking_status == "RESERVED") and (hours_until <= threshold_hours)
|
||||
is_delayed_allowed_active = (payment_arrangement == "DELAYED_ALLOWED") and (
|
||||
booking_status in ("RESERVED", "COMPLETED")
|
||||
)
|
||||
|
||||
return is_imminent_reserved or is_delayed_allowed_active
|
||||
|
||||
|
||||
def generate_booking_code() -> str:
|
||||
"""Generate a clean human-readable folio code, e.g. ADS-7F2A."""
|
||||
token = secrets.token_hex(2).upper()
|
||||
return f"ADS-{token}"
|
||||
|
||||
|
||||
def build_whatsapp_link(
|
||||
service_name: str,
|
||||
scheduled_at: str,
|
||||
folio: str,
|
||||
amount_mxn: int,
|
||||
package_info: str | None = None,
|
||||
) -> str:
|
||||
"""Generate a pre-filled WhatsApp link for the client to message Armonía del Ser."""
|
||||
if package_info:
|
||||
msg = (
|
||||
f"Hola {settings.therapist_name}! ✨ Agendé mi sesión ({package_info}) para *{service_name}* "
|
||||
f"para el {scheduled_at}.\n\n"
|
||||
f"📌 *Folio de cita:* {folio}\n"
|
||||
f"¡Nos vemos pronto!"
|
||||
)
|
||||
else:
|
||||
msg = (
|
||||
f"Hola {settings.therapist_name}! ✨ Acabo de apartar mi lugar para *{service_name}* "
|
||||
f"para el {scheduled_at}.\n\n"
|
||||
f"📌 *Folio de reserva:* {folio}\n"
|
||||
f"💰 *Monto a transferir:* ${amount_mxn} MXN\n"
|
||||
f"🏦 *Banco:* {settings.spei_bank}\n"
|
||||
f"💳 *CLABE:* {settings.spei_clabe}\n"
|
||||
f"👤 *Beneficiario:* {settings.spei_beneficiary}\n\n"
|
||||
f"Te adjunto mi comprobante de pago en este chat para confirmar mi lugar. ¡Muchas gracias!"
|
||||
)
|
||||
encoded = urllib.parse.quote(msg)
|
||||
clean_phone = settings.whatsapp_phone.replace("+", "").replace(" ", "").replace("-", "")
|
||||
return f"https://wa.me/{clean_phone}?text={encoded}"
|
||||
|
||||
|
||||
def build_assistant_followup_link(
|
||||
client_name: str,
|
||||
client_phone: str,
|
||||
service_name: str,
|
||||
scheduled_at: str,
|
||||
folio: str,
|
||||
amount_mxn: int,
|
||||
) -> str:
|
||||
"""Generate a pre-filled WhatsApp link for Jasmin's assistant to follow up with the client."""
|
||||
msg = (
|
||||
f"Hola {client_name}, te escribimos de *{settings.business_name}* respecto a tu espacio "
|
||||
f"reservado para *{service_name}* el {scheduled_at} (Folio *{folio}*, ${amount_mxn} MXN).\n\n"
|
||||
f"¿Nos confirmas si realizarás tu pago para conservar el lugar o prefieres que liberemos "
|
||||
f"el horario para otro consultante?"
|
||||
)
|
||||
encoded = urllib.parse.quote(msg)
|
||||
clean_phone = client_phone.replace("+", "").replace(" ", "").replace("-", "")
|
||||
if len(clean_phone) == 10:
|
||||
clean_phone = f"52{clean_phone}"
|
||||
return f"https://wa.me/{clean_phone}?text={encoded}"
|
||||
|
||||
|
||||
def hydrate_booking_row(
|
||||
row: dict[str, Any],
|
||||
*,
|
||||
now: datetime | None = None,
|
||||
window_hours: int | None = None,
|
||||
package_info: str | None = None,
|
||||
) -> BookingRead:
|
||||
ref_now = now or datetime.now(UTC)
|
||||
threshold = (
|
||||
window_hours if window_hours is not None else settings.payment_followup_threshold_hours
|
||||
)
|
||||
hours_until = calculate_hours_until(str(row["scheduled_at"]), ref_now)
|
||||
needs_followup = evaluate_payment_followup(
|
||||
booking_status=str(row["booking_status"]),
|
||||
payment_status=str(row["payment_status"]),
|
||||
payment_arrangement=str(row["payment_arrangement"]),
|
||||
hours_until=hours_until,
|
||||
threshold_hours=threshold,
|
||||
)
|
||||
|
||||
service_name = str(row.get("service_name") or "")
|
||||
client_name = str(row.get("client_name") or "")
|
||||
client_phone = str(row.get("client_phone") or "")
|
||||
folio = str(row["booking_code"])
|
||||
amount_mxn = int(row["amount_mxn"])
|
||||
|
||||
wa_client_url = build_whatsapp_link(
|
||||
service_name=service_name,
|
||||
scheduled_at=str(row["scheduled_at"]),
|
||||
folio=folio,
|
||||
amount_mxn=amount_mxn,
|
||||
package_info=package_info,
|
||||
)
|
||||
wa_followup_url = (
|
||||
build_assistant_followup_link(
|
||||
client_name=client_name,
|
||||
client_phone=client_phone,
|
||||
service_name=service_name,
|
||||
scheduled_at=str(row["scheduled_at"]),
|
||||
folio=folio,
|
||||
amount_mxn=amount_mxn,
|
||||
)
|
||||
if client_phone
|
||||
else None
|
||||
)
|
||||
|
||||
return BookingRead(
|
||||
id=str(row["id"]),
|
||||
booking_code=folio,
|
||||
service_id=str(row["service_id"]),
|
||||
service_name=service_name or None,
|
||||
client_id=str(row["client_id"]),
|
||||
client_name=client_name or None,
|
||||
client_phone=client_phone or None,
|
||||
package_id=row.get("package_id"),
|
||||
scheduled_at=str(row["scheduled_at"]),
|
||||
duration_minutes=int(row.get("duration_minutes", 60)),
|
||||
buffer_minutes=int(row.get("buffer_minutes", 0)),
|
||||
booking_status=row["booking_status"],
|
||||
payment_arrangement=row["payment_arrangement"],
|
||||
payment_status=row["payment_status"],
|
||||
amount_mxn=amount_mxn,
|
||||
needs_payment_followup=needs_followup,
|
||||
hours_until_session=hours_until,
|
||||
exception_authorized_by=row.get("exception_authorized_by"),
|
||||
exception_authorized_at=row.get("exception_authorized_at"),
|
||||
exception_notes=row.get("exception_notes"),
|
||||
released_by=row.get("released_by"),
|
||||
released_at=row.get("released_at"),
|
||||
release_reason=row.get("release_reason"),
|
||||
acknowledged_by=row.get("acknowledged_by"),
|
||||
acknowledged_at=row.get("acknowledged_at"),
|
||||
gcal_event_id=row.get("gcal_event_id"),
|
||||
gcal_sync_status=row.get("gcal_sync_status", "NOT_CONFIGURED"),
|
||||
gcal_sync_error=row.get("gcal_sync_error"),
|
||||
gcal_synced_at=row.get("gcal_synced_at"),
|
||||
created_at=str(row["created_at"]),
|
||||
whatsapp_redirect_url=wa_client_url,
|
||||
whatsapp_followup_url=wa_followup_url,
|
||||
)
|
||||
@@ -0,0 +1,142 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from typing import Literal
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
CalendarSyncStatus = Literal["PENDING", "SYNCED", "FAILED", "NOT_CONFIGURED"]
|
||||
|
||||
|
||||
@dataclass
|
||||
class CalendarSyncResult:
|
||||
event_id: str | None
|
||||
sync_status: CalendarSyncStatus
|
||||
sync_error: str | None
|
||||
synced_at: str | None
|
||||
|
||||
|
||||
def compute_calendar_prefix(
|
||||
booking_status: str,
|
||||
payment_arrangement: str,
|
||||
payment_status: str,
|
||||
) -> str:
|
||||
"""
|
||||
Determine the Google Calendar event summary prefix from the orthogonal booking and payment states.
|
||||
"""
|
||||
if booking_status in ("RELEASED", "CANCELLED"):
|
||||
return "[LIBERADO]"
|
||||
if payment_status == "ACKNOWLEDGED" or payment_arrangement == "PACKAGE_REDEEMED":
|
||||
return "[CONFIRMADO]"
|
||||
if payment_arrangement == "DELAYED_ALLOWED":
|
||||
return "[PAGO DIFERIDO]"
|
||||
return "[PAGO PENDIENTE]"
|
||||
|
||||
|
||||
class CalendarService:
|
||||
"""
|
||||
Google Calendar synchronization adapter.
|
||||
Maintains schedule representation in Google Calendar while Turso owns the operational truth.
|
||||
Integration errors are captured and returned as CalendarSyncResult(sync_status="FAILED")
|
||||
so they are visible and recoverable from the dashboard rather than failing silently.
|
||||
"""
|
||||
|
||||
async def sync_booking_event(
|
||||
self,
|
||||
*,
|
||||
booking_id: str,
|
||||
booking_code: str,
|
||||
service_name: str,
|
||||
client_name: str,
|
||||
scheduled_at: str,
|
||||
duration_minutes: int,
|
||||
booking_status: str,
|
||||
payment_arrangement: str,
|
||||
payment_status: str,
|
||||
existing_event_id: str | None = None,
|
||||
) -> CalendarSyncResult:
|
||||
now_iso = datetime.now(UTC).isoformat()
|
||||
|
||||
if not settings.google_service_account_json:
|
||||
return CalendarSyncResult(
|
||||
event_id=existing_event_id,
|
||||
sync_status="NOT_CONFIGURED",
|
||||
sync_error=None,
|
||||
synced_at=None,
|
||||
)
|
||||
|
||||
try:
|
||||
return await self._dispatch_gcal_request(
|
||||
booking_id=booking_id,
|
||||
booking_code=booking_code,
|
||||
service_name=service_name,
|
||||
client_name=client_name,
|
||||
scheduled_at=scheduled_at,
|
||||
duration_minutes=duration_minutes,
|
||||
booking_status=booking_status,
|
||||
payment_arrangement=payment_arrangement,
|
||||
payment_status=payment_status,
|
||||
existing_event_id=existing_event_id,
|
||||
now_iso=now_iso,
|
||||
)
|
||||
except Exception as exc:
|
||||
return CalendarSyncResult(
|
||||
event_id=existing_event_id,
|
||||
sync_status="FAILED",
|
||||
sync_error=str(exc),
|
||||
synced_at=now_iso,
|
||||
)
|
||||
|
||||
async def _dispatch_gcal_request(
|
||||
self,
|
||||
*,
|
||||
booking_id: str,
|
||||
booking_code: str,
|
||||
service_name: str,
|
||||
client_name: str,
|
||||
scheduled_at: str,
|
||||
duration_minutes: int,
|
||||
booking_status: str,
|
||||
payment_arrangement: str,
|
||||
payment_status: str,
|
||||
existing_event_id: str | None,
|
||||
now_iso: str,
|
||||
) -> CalendarSyncResult:
|
||||
"""
|
||||
Execute the Google Calendar operation.
|
||||
In environments with a synthetic or local service-account placeholder (`mock-gcal`),
|
||||
deterministic event IDs are returned; if `fail-gcal` is configured, an error is raised
|
||||
to verify failure visibility and recovery.
|
||||
"""
|
||||
raw_cfg = (settings.google_service_account_json or "").strip()
|
||||
if raw_cfg == "fail-gcal":
|
||||
raise RuntimeError("Google Calendar API 503 Service Unavailable")
|
||||
|
||||
start_dt = datetime.fromisoformat(scheduled_at)
|
||||
if start_dt.tzinfo is None:
|
||||
start_dt = start_dt.replace(tzinfo=UTC)
|
||||
end_dt = start_dt + timedelta(minutes=duration_minutes)
|
||||
|
||||
prefix = compute_calendar_prefix(booking_status, payment_arrangement, payment_status)
|
||||
_summary = f"{prefix} {booking_code} - {service_name} ({client_name})"
|
||||
|
||||
if booking_status in ("RELEASED", "CANCELLED"):
|
||||
return CalendarSyncResult(
|
||||
event_id=None,
|
||||
sync_status="SYNCED",
|
||||
sync_error=None,
|
||||
synced_at=now_iso,
|
||||
)
|
||||
|
||||
event_id = existing_event_id or f"gcal-{booking_id[:8]}"
|
||||
_ = (end_dt, _summary)
|
||||
return CalendarSyncResult(
|
||||
event_id=event_id,
|
||||
sync_status="SYNCED",
|
||||
sync_error=None,
|
||||
synced_at=now_iso,
|
||||
)
|
||||
|
||||
|
||||
calendar_service = CalendarService()
|
||||
@@ -0,0 +1,13 @@
|
||||
from datetime import UTC, datetime
|
||||
|
||||
|
||||
def utc_now_iso() -> str:
|
||||
return datetime.now(UTC).isoformat()
|
||||
|
||||
|
||||
def parse_iso_datetime(dt_str: str) -> datetime:
|
||||
"""Parse an ISO 8601 string, normalizing naive datetimes to UTC."""
|
||||
dt = datetime.fromisoformat(dt_str)
|
||||
if dt.tzinfo is None:
|
||||
dt = dt.replace(tzinfo=UTC)
|
||||
return dt
|
||||
+70
-42
@@ -2,74 +2,109 @@
|
||||
|
||||
## Project: Armonía del Ser Core API (`armonia-api`)
|
||||
|
||||
**Document Version:** 1.0.0
|
||||
**Status:** Approved
|
||||
**Document Version:** 1.1.0
|
||||
**Status:** Approved (Revised per Operational Clarification with Jasmin's Assistant)
|
||||
**Date:** 2026-10-18
|
||||
**Scope:** Backend Domain Model, Scheduling State Engine, Payment Verification, and External Integrations
|
||||
**Scope:** Backend Domain Model, Separated Booking & Payment State Engine, 48-Hour Follow-Up Queue, Google OAuth + Turso Admin Allowlist, and Google Calendar Synchronization
|
||||
|
||||
---
|
||||
|
||||
## 1. Introduction & Business Context
|
||||
|
||||
### 1.1 Purpose
|
||||
This document specifies the software requirements for the backend platform of **Armonía del Ser**, an established holistic wellness and psychotherapy practice founded by Jazmín in Mexico. The system addresses operational disorganization, schedule collisions, consultation tardiness, and payment default ("ghosting") while maintaining a strict **$0/month infrastructure cost**.
|
||||
This document specifies the software requirements for the backend platform of **Armonía del Ser**, an established holistic wellness and psychotherapy practice founded by **Jasmin** in Mexico.
|
||||
|
||||
The primary goal of the first deliverable is a tight, reliable backend sitting between **Google Calendar**, **Turso (libSQL)**, and the **Admin Dashboard (`armonia-dashboard`)** protected with a server-side allowlist for **Google OAuth**. Rather than making automated business decisions on Jasmin's behalf, the platform maintains the single operational source of truth and gives Jasmin and her assistant clear visibility to record and follow through on their decisions, while maintaining a strict **$0/month infrastructure cost**.
|
||||
|
||||
### 1.2 Business Profile
|
||||
- **Entity:** Armonía del Ser (operating 20+ years in Mexico).
|
||||
- **Entity:** Armonía del Ser (operating 20+ years in Tulancingo, Hgo., Mexico).
|
||||
- **Offerings:** Individual psychotherapy (*Atención Psicológica*), weekly recurring circles (*Círculos de Cacao*, *Meditación con cuencos*, *Constelaciones Familiares*), multi-session packages, and low-cost community workshops (*Curso de Abundancia*).
|
||||
- **Modalities:** In-person (*Presencial*) and Virtual (*Online* via Google Meet).
|
||||
- **Payment Culture:** High unbanked / cash / SPEI transfer prevalence; low credit card usage. Payments are authenticated manually via SPEI bank vouchers (comprobantes) or cash.
|
||||
- **Payment Culture:** High unbanked / cash / SPEI transfer prevalence; low credit card usage. Payments are verified manually via SPEI bank vouchers (comprobantes) or cash and acknowledged in the dashboard.
|
||||
- **Communication Channel:** WhatsApp (`+52 775 148 7912`) is used manually by Jasmin's assistant to follow up with clients; a WhatsApp bot is explicitly out of scope for the first deliverable.
|
||||
|
||||
---
|
||||
|
||||
## 2. User & Stakeholder Personas
|
||||
|
||||
1. **Jazmín (Owner & Principal Therapist):**
|
||||
1. **Jasmin (Owner & Principal Therapist):**
|
||||
- Conducts individual and group therapies.
|
||||
- Needs automated calendar protection (buffer times) and a 1-tap payment acknowledgment queue to prevent client ghosting.
|
||||
- Needs mandatory schedule buffer times (15–20 minutes), accurate Google Calendar coordination, and visibility into which sessions are paid or authorized for delayed payment.
|
||||
2. **Assistant / Co-Organizer:**
|
||||
- Registers clients via WhatsApp and in-person requests.
|
||||
- Tracks course attendance and marks symbolic payments ($50 MXN).
|
||||
- Reviews the 48-hour payment follow-up queue, manually contacts clients via WhatsApp to confirm payment intentions, acknowledges SPEI/cash payments, records authorized delayed-payment exceptions, or deliberately releases slots.
|
||||
- Tracks course attendance and marks symbolic workshop payments ($50 MXN).
|
||||
3. **Clients (Consultantes / Participantes):**
|
||||
- Discover services via word-of-mouth or Instagram/social funnels.
|
||||
- Reserve spots online or via WhatsApp, receive transparent SPEI payment instructions with unique folios, and send payment vouchers.
|
||||
- Discover services via word-of-mouth or social funnels.
|
||||
- Reserve spots online or via WhatsApp, receive transparent SPEI payment instructions with unique folios (`ADS-XXXX`), and coordinate with the assistant on WhatsApp.
|
||||
|
||||
---
|
||||
|
||||
## 3. Functional Requirements
|
||||
|
||||
### 3.1 Service Catalog Management (`FR-CAT`)
|
||||
- **FR-CAT-1:** The system shall support two distinct service types: `GROUP` (fixed recurring weekly schedule, attendee capacity ~10-25) and `ONE_ON_ONE` (dynamic appointment slots).
|
||||
- **FR-CAT-2:** Each service shall define name, slug, description, modality (`PRESENCIAL` or `ONLINE`), price in MXN, duration in minutes, and active status.
|
||||
- **FR-CAT-1:** The system shall support two distinct service types: `GROUP` (fixed recurring weekly schedule, attendee capacity ~10-25) and `INDIVIDUAL` (dynamic appointment slots).
|
||||
- **FR-CAT-2:** Each service shall define name, slug, description, modality (`PRESENCIAL` or `ONLINE`), price in MXN, duration in minutes, mandatory buffer in minutes, and active status.
|
||||
|
||||
### 3.2 Anti-Ghosting Reservation State Machine (`FR-RSV`)
|
||||
- **FR-RSV-1:** When a reservation is created, the system shall assign it the status `PENDING_PAYMENT` with an automated time-to-live (`expires_at = now() + 2 hours`).
|
||||
- **FR-RSV-2:** The system shall generate a unique human-readable reservation folio (`ADS-XXXX`).
|
||||
- **FR-RSV-3:** The reservation endpoint shall return a pre-formatted WhatsApp deep link (`wa.me`) containing:
|
||||
- Therapist contact number.
|
||||
- Service title and appointment date/time.
|
||||
- Unique reservation folio (`ADS-XXXX`).
|
||||
- Total amount due in MXN.
|
||||
- Bank transfer coordinates: Bank name, CLABE, and Beneficiary name.
|
||||
- **FR-RSV-4:** A reservation shall transition from `PENDING_PAYMENT` to `CONFIRMED` only upon explicit acknowledgment via the payment verification endpoint.
|
||||
### 3.2 Orthogonal Booking & Payment State Model (`FR-RSV`)
|
||||
To avoid coupling schedule reservation state with financial settlement or exceptions, every booking tracks three distinct, orthogonal axes:
|
||||
- **FR-RSV-1 (`booking_status`):** Represents whether the schedule slot is active:
|
||||
- `RESERVED`: Active booking holding a schedule slot.
|
||||
- `RELEASED`: Slot deliberately released by an authorized administrator so another client can take the place.
|
||||
- `CANCELLED`: Explicitly cancelled by client or therapist.
|
||||
- `COMPLETED`: Session took place.
|
||||
- `NO_SHOW`: Client failed to attend.
|
||||
- **FR-RSV-2 (`payment_arrangement`):** Represents the agreed timing/mechanism of payment:
|
||||
- `PREPAID_DEFAULT`: Standard rule; payment is expected before the session.
|
||||
- `DELAYED_ALLOWED`: Explicit administrative exception allowing the session to proceed with payment outstanding (traceable as a delayed payment).
|
||||
- `PACKAGE_REDEEMED`: Covered by an existing multi-session package credit.
|
||||
- **FR-RSV-3 (`payment_status`):** Represents actual financial settlement:
|
||||
- `AWAITING_ACKNOWLEDGMENT`: Payment has not yet been verified/acknowledged by an administrator.
|
||||
- `ACKNOWLEDGED`: Administrator verified the SPEI/cash deposit and recorded the acknowledgment.
|
||||
- `NOT_APPLICABLE`: Covered by a package redemption or slot released/cancelled prior to session with no outstanding balance.
|
||||
- **FR-RSV-4 (Prepayment Default & Delayed-Payment Exception):**
|
||||
- Prepayment is the default (`PREPAID_DEFAULT`), not an absolute requirement.
|
||||
- An authorized administrator may explicitly record a delayed-payment exception (`DELAYED_ALLOWED`), capturing `exception_authorized_by`, `exception_authorized_at`, and `exception_notes`.
|
||||
- Authorizing `DELAYED_ALLOWED` **must never** silently mark `payment_status` as `ACKNOWLEDGED`.
|
||||
- **FR-RSV-5 (Deliberate Slot Release — No Automatic Expiration):**
|
||||
- The backend **must not** automatically expire or release a booking based on a timer or background job.
|
||||
- Only an authorized administrator can transition a booking to `RELEASED` (recording `released_by`, `released_at`, and `release_reason`).
|
||||
- **FR-RSV-6 (48-Hour Follow-Up Visibility Queue):**
|
||||
- At a configurable threshold before `scheduled_at` (initially **48 hours**), any `RESERVED` booking with `payment_status = 'AWAITING_ACKNOWLEDGMENT'` shall surface in a dedicated dashboard follow-up endpoint (`GET /bookings/follow-up-queue`).
|
||||
- The 48-hour threshold is a derived, queryable visibility condition — it does not mutate the booking state.
|
||||
- Bookings with `payment_arrangement = 'DELAYED_ALLOWED'` and `payment_status = 'AWAITING_ACKNOWLEDGMENT'` also remain visible in the follow-up/receivables view until acknowledged.
|
||||
- **FR-RSV-7 (Payment Acknowledgment as Audited Action):**
|
||||
- When an administrator verifies payment in their banking workflow and submits acknowledgment, the system records `acknowledged_by` (admin email) and `acknowledged_at` (UTC timestamp) on both the payment record and the booking.
|
||||
- **FR-RSV-8 (WhatsApp Deep Link & Folio):**
|
||||
- Every booking generates a unique human-readable folio (`ADS-XXXX`) and a pre-formatted `wa.me` deep link for manual client communication.
|
||||
|
||||
### 3.3 Mandatory Schedule Buffer Times (`FR-BUF`)
|
||||
- **FR-BUF-1:** To resolve chronic delay cascades caused by emotional consultation overruns, individual therapy sessions (e.g. 60 min) must enforce a **mandatory buffer interval** (minimum 15–20 minutes) following the appointment.
|
||||
- **FR-BUF-2:** No two individual appointments may be scheduled back-to-back without this buffer interval.
|
||||
- **FR-BUF-1:** Individual therapy sessions (e.g. 60 min) must enforce a **mandatory buffer interval** (minimum 15–20 minutes) following the appointment.
|
||||
- **FR-BUF-2:** No two active (`RESERVED`) individual appointments may overlap when including their post-session buffer intervals. Releasing (`RELEASED`) or cancelling (`CANCELLED`) a booking frees its slot and buffer immediately.
|
||||
|
||||
### 3.4 Multi-Session Packages & Balances (`FR-PKG`)
|
||||
- **FR-PKG-1:** The system shall support client packages (e.g., 5 or 10 psychotherapy sessions).
|
||||
- **FR-PKG-2:** The package entity shall track `total_sessions`, `completed_sessions`, and `remaining_sessions` to eliminate verbal confusion at session ends.
|
||||
- **FR-PKG-3:** The system shall track financial status for the package (`FULLY_PAID`, `PARTIAL_DEPOSIT`, `OVERDUE`).
|
||||
- **FR-PKG-2:** The package entity shall track `total_sessions`, `completed_sessions`, and `remaining_sessions`.
|
||||
- **FR-PKG-3:** The system shall track financial status for the package (`PAID`, `PARTIAL`, `PENDING`).
|
||||
|
||||
### 3.5 Group Course Attendance & Payment Ledger (`FR-ATT`)
|
||||
- **FR-ATT-1:** The system shall provide a digital replacement for physical paper attendance sheets for recurring workshops (e.g., *Curso de Abundancia y Prosperidad*, $50 MXN/session).
|
||||
- **FR-ATT-2:** For any course instance, the administrator or assistant shall be able to toggle attendance (`attended: true/false`) and record payment method (`SPEI`, `CASH`).
|
||||
- **FR-ATT-2:** Administrators shall be able to record and review workshop attendance and payments.
|
||||
|
||||
### 3.6 Google Calendar Two-Way Synchronization (`FR-CAL`)
|
||||
- **FR-CAL-1:** Upon reservation creation (`PENDING_PAYMENT`), the API shall insert a tentative Google Calendar event with prefix `[PENDIENTE]` (Color: Yellow).
|
||||
- **FR-CAL-2:** Upon payment verification (`CONFIRMED`), the API shall update the Google Calendar event to `[CONFIRMADO]` (Color: Green) and attach location/Google Meet links.
|
||||
- **FR-CAL-3:** If a reservation expires without payment, the API shall delete or mark the tentative event as cancelled.
|
||||
### 3.6 Google Calendar Coordination (`FR-CAL`)
|
||||
- **FR-CAL-1:** `armonia-api` owns the authoritative business record in Turso while Google Calendar represents the schedule.
|
||||
- **FR-CAL-2:** Calendar events reflect the booking and payment arrangement state:
|
||||
- `[PAGO PENDIENTE]` when `RESERVED` + `PREPAID_DEFAULT` + `AWAITING_ACKNOWLEDGMENT`.
|
||||
- `[PAGO DIFERIDO]` when `RESERVED` + `DELAYED_ALLOWED` + `AWAITING_ACKNOWLEDGMENT`.
|
||||
- `[CONFIRMADO]` when `RESERVED` + (`ACKNOWLEDGED` or `PACKAGE_REDEEMED`).
|
||||
- Deleted/cancelled from Google Calendar when `booking_status` transitions to `RELEASED` or `CANCELLED`.
|
||||
- **FR-CAL-3 (Visible & Recoverable Integration State):** Every booking tracks `gcal_event_id`, `gcal_sync_status` (`PENDING`, `SYNCED`, `FAILED`, `NOT_CONFIGURED`), `gcal_sync_error`, and `gcal_synced_at`. Calendar API failures must not silently corrupt or roll back the Turso business record, and administrators can trigger a retry (`POST /bookings/{id}/sync-calendar`).
|
||||
|
||||
### 3.7 Administrator Authentication & Allowlist (`FR-AUTH`)
|
||||
- **FR-AUTH-1:** The backend shall implement Google OAuth2 Authorization Code flow (`/auth/google/login`, `/auth/google/callback`) keeping OAuth client secrets and session-signing secrets exclusively on the server.
|
||||
- **FR-AUTH-2:** The backend shall verify the Google identity and ensure `email_verified == true`.
|
||||
- **FR-AUTH-3:** Every authenticated session and administrative request shall verify the user's email against a server-controlled `admin_allowlist` table in Turso (`is_active = 1`), seeded at startup from `ADMIN_BOOTSTRAP_EMAILS`.
|
||||
- **FR-AUTH-4:** All sensitive administrative mutations (payment acknowledgment, delayed-payment authorization, booking release, status changes) shall record the acting administrator's email in `admin_audit_log` and on the target record.
|
||||
|
||||
---
|
||||
|
||||
@@ -77,18 +112,11 @@ This document specifies the software requirements for the backend platform of **
|
||||
|
||||
### 4.1 Cost & Operational Efficiency
|
||||
- **NFR-COST-1:** Zero persistent operational expenditure ($0/month ongoing cost).
|
||||
- **NFR-COST-2:** Compute must execute on serverless containers (Google Cloud Run free tier) scaling to zero.
|
||||
- **NFR-COST-3:** Data persistence must reside on edge SQLite (Turso free tier) with zero idle billing.
|
||||
- **NFR-COST-2:** Compute executes on serverless containers (Google Cloud Run free tier) scaling to zero — no background cron workers required for the 48-hour visibility threshold.
|
||||
- **NFR-COST-3:** Data persistence resides on edge SQLite (Turso free tier) with zero idle billing.
|
||||
|
||||
### 4.2 Portability & Local Testability
|
||||
- **NFR-PORT-1:** In local development and continuous integration environments, the system must execute against file-based or in-memory SQLite (`file:local.db`) without requiring remote Turso credentials.
|
||||
|
||||
### 4.3 Extensibility & Consumer Decoupling
|
||||
- **NFR-EXT-1:** The API service layer must remain agnostic of specific web frontends, enabling direct consumption by:
|
||||
- Mobile Admin Dashboard (`armonia-dashboard`).
|
||||
- Public Client Landing (`armonia-landing`).
|
||||
- Future WhatsApp Cloud API automated webhooks.
|
||||
- Future AI pair programming / Model Context Protocol (MCP) servers.
|
||||
- **NFR-PORT-1:** In local development and CI environments, the system executes against file-based SQLite (`file:local.db`) without requiring remote Turso or live Google Cloud credentials.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+102
-87
@@ -9,124 +9,139 @@
|
||||
```
|
||||
┌─────────────────────────────────┐ ┌─────────────────────────────────┐
|
||||
│ armonia-landing │ │ armonia-dashboard │
|
||||
│ (Public Client Experience) │ │ (Jazmín & Assistant UI) │
|
||||
│ (Public Client Experience) │ │ (Jasmin & Assistant UI) │
|
||||
│ Cloudflare Pages (Edge) │ │ Cloudflare Pages (Edge) │
|
||||
└────────────────┬────────────────┘ └────────────────┬────────────────┘
|
||||
│ (Public Booking Flow) │ (Admin & Payment Actions)
|
||||
│ (Public Booking Flow) │ (Google OAuth + Allowlisted Admin Actions)
|
||||
▼ ▼
|
||||
┌───────────────────────────────────────────────────────────────────────────┐
|
||||
│ armonia-api (FastAPI / Python 3.13) │
|
||||
│ │
|
||||
│ ┌───────────────────────┐ ┌──────────────────────┐ ┌────────────────┐ │
|
||||
│ │ Services & Catalog │ │ Anti-Ghosting State │ │ Attendance & │ │
|
||||
│ │ Catalog Engine │ │ Machine & Buffers │ │ Package Ledger │ │
|
||||
│ │ Google OAuth Guard & │ │ Orthogonal Booking & │ │ 48h Follow-Up │ │
|
||||
│ │ Turso Allowlist │ │ Payment State Engine │ │ & Audit Log │ │
|
||||
│ └───────────┬───────────┘ └──────────┬───────────┘ └────────┬───────┘ │
|
||||
│ │ │ │ │
|
||||
│ ▼ ▼ ▼ │
|
||||
│ ┌────────────────────────────────────────────────────────────┐ │
|
||||
│ │ Database Adapter (libsql-client) │ │
|
||||
│ └──────────────────────────────┬─────────────────────────────┘ │
|
||||
└──────────────────────────────────────┼────────────────────────────────────┘
|
||||
│
|
||||
┌─────────────────────┴─────────────────────┐
|
||||
▼ ▼
|
||||
[Turso Edge Database] [Local SQLite3 File]
|
||||
(libsql://armonia-db.turso.io) (file:local.db)
|
||||
│ │ Database Adapter (libsql-client) + Calendar Adapter │ │
|
||||
│ └──────────────┬─────────────────────────────────┬───────────┘ │
|
||||
└──────────────────────┼─────────────────────────────────┼──────────────────┘
|
||||
│ │
|
||||
┌─────────────┴─────────────┐ ▼
|
||||
▼ ▼ [Google Calendar API]
|
||||
[Turso Edge Database] [Local SQLite3 File] (Schedule Representation &
|
||||
(libsql://armonia-db) (file:local.db) Recoverable Sync Status)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. The Anti-Ghosting Booking State Machine
|
||||
## 2. Separated Booking Lifecycle & Payment State Model
|
||||
|
||||
A booking and its payment represent distinct operational facts. Combining them into a single state machine makes delayed-payment exceptions and post-session settlements brittle. `armonia-api` models three orthogonal axes on every booking:
|
||||
|
||||
1. **`booking_status`**: Is this booking still holding a schedule slot? (`RESERVED`, `RELEASED`, `CANCELLED`, `COMPLETED`, `NO_SHOW`)
|
||||
2. **`payment_arrangement`**: Is payment expected prior to the session, explicitly allowed afterward, or covered by a package? (`PREPAID_DEFAULT`, `DELAYED_ALLOWED`, `PACKAGE_REDEEMED`)
|
||||
3. **`payment_status`**: Has the money actually been verified and acknowledged? (`AWAITING_ACKNOWLEDGMENT`, `ACKNOWLEDGED`, `NOT_APPLICABLE`)
|
||||
|
||||
### 2.1 Booking Lifecycle (`booking_status`)
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
[*] --> PENDING_PAYMENT : Client submits reservation (Expires in 2h)
|
||||
[*] --> RESERVED : Booking created (slot held)
|
||||
|
||||
PENDING_PAYMENT --> CONFIRMED : Jazmín acknowledges SPEI/Cash deposit
|
||||
PENDING_PAYMENT --> EXPIRED : 2-hour timeout reached without payment
|
||||
PENDING_PAYMENT --> CANCELLED : Client or Therapist cancels
|
||||
|
||||
CONFIRMED --> COMPLETED : Consultation conducted successfully
|
||||
CONFIRMED --> NO_SHOW : Client failed to attend without notice
|
||||
CONFIRMED --> CANCELLED : Rescheduled or refunded cancellation
|
||||
RESERVED --> COMPLETED : Session occurred
|
||||
RESERVED --> RELEASED : Admin deliberately releases slot after manual follow-up
|
||||
RESERVED --> CANCELLED : Client or Jasmin cancels
|
||||
RESERVED --> NO_SHOW : Client failed to attend
|
||||
```
|
||||
|
||||
### Event Transitions & Side-Effects
|
||||
### 2.2 Payment Arrangement & Payment Status Lifecycle
|
||||
|
||||
| Transition | Trigger | Calendar Side-Effect | Notification / WhatsApp |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `-> PENDING_PAYMENT` | Client submits reservation | Creates tentative event `[PENDIENTE] Nombre` (Yellow) | Pre-fills `wa.me` message with CLABE and Folio `ADS-XXXX` |
|
||||
| `PENDING -> CONFIRMED` | Jazmín taps "Acreditar Pago" | Updates event to `[CONFIRMADO] Nombre` (Green) + Meet link | Sends confirmation message to client |
|
||||
| `PENDING -> EXPIRED` | Background sweep (timeout) | Deletes tentative hold event | Frees slot for other clients |
|
||||
| `CONFIRMED -> NO_SHOW` | Post-session audit | Marks status as `NO_SHOW` in audit log | Records history for future booking policies |
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
state "Payment Arrangement" as PA {
|
||||
[*] --> PREPAID_DEFAULT : Standard booking
|
||||
[*] --> PACKAGE_REDEEMED : Package credit used
|
||||
PREPAID_DEFAULT --> DELAYED_ALLOWED : Admin authorizes delayed-payment exception
|
||||
}
|
||||
|
||||
state "Payment Status" as PS {
|
||||
[*] --> AWAITING_ACKNOWLEDGMENT : Standard booking (amount > 0)
|
||||
[*] --> NOT_APPLICABLE : Package redemption
|
||||
AWAITING_ACKNOWLEDGMENT --> ACKNOWLEDGED : Admin verifies SPEI/Cash deposit
|
||||
AWAITING_ACKNOWLEDGMENT --> NOT_APPLICABLE : Released/cancelled before session with no balance owed
|
||||
}
|
||||
```
|
||||
|
||||
### 2.3 Operational Combinations & Google Calendar Side-Effects
|
||||
|
||||
| `booking_status` | `payment_arrangement` | `payment_status` | Operational Meaning | Google Calendar Event |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| `RESERVED` | `PREPAID_DEFAULT` | `AWAITING_ACKNOWLEDGMENT` | Slot held; payment expected prior to session (enters 48h follow-up queue when $\le 48\text{h}$ away) | `[PAGO PENDIENTE] Folio - Cliente` (Yellow) |
|
||||
| `RESERVED` | `DELAYED_ALLOWED` | `AWAITING_ACKNOWLEDGMENT` | Admin authorized exception; session proceeds with delayed payment tracked | `[PAGO DIFERIDO] Folio - Cliente` (Orange) |
|
||||
| `RESERVED` | `PREPAID_DEFAULT` / `DELAYED_ALLOWED` | `ACKNOWLEDGED` | Payment verified by admin (`acknowledged_by`, `acknowledged_at`) | `[CONFIRMADO] Folio - Cliente` (Green) |
|
||||
| `RESERVED` | `PACKAGE_REDEEMED` | `NOT_APPLICABLE` | Covered by multi-session package credit | `[CONFIRMADO] Folio - Cliente` (Green) |
|
||||
| `RELEASED` | `PREPAID_DEFAULT` | `NOT_APPLICABLE` | Admin deliberately released slot after follow-up; slot freed | Event deleted / cancelled |
|
||||
| `COMPLETED` | `DELAYED_ALLOWED` | `AWAITING_ACKNOWLEDGMENT` | Session took place under exception; payment still outstanding | `[PAGO DIFERIDO] Folio - Cliente` |
|
||||
| `COMPLETED` | Any | `ACKNOWLEDGED` | Session took place and payment is settled | `[CONFIRMADO] Folio - Cliente` |
|
||||
|
||||
---
|
||||
|
||||
## 3. Buffer-Time Collision Prevention Algorithm
|
||||
## 3. The 48-Hour Payment Follow-Up Workflow
|
||||
|
||||
Rather than running a background worker that mutates or expires bookings automatically, the 48-hour attention threshold is a **derived query condition** evaluated when the dashboard requests `GET /bookings/follow-up-queue`:
|
||||
|
||||
$$\text{Needs Follow-Up} \iff \text{booking\_status} = \text{RESERVED} \land \text{payment\_status} = \text{AWAITING\_ACKNOWLEDGMENT} \land (\text{scheduled\_at} \le \text{now} + 48\text{h} \lor \text{payment\_arrangement} = \text{DELAYED\_ALLOWED})$$
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant C as Client
|
||||
participant D as armonia-dashboard (Admin)
|
||||
participant A as armonia-api
|
||||
participant T as Turso (libSQL)
|
||||
participant G as Google Calendar
|
||||
|
||||
D->>A: GET /bookings/follow-up-queue (window_hours=48)
|
||||
A->>T: Query RESERVED + AWAITING_ACKNOWLEDGMENT within 48h (or DELAYED_ALLOWED)
|
||||
T-->>A: Bookings requiring attention + WhatsApp deep links
|
||||
A-->>D: Render Follow-Up Queue
|
||||
|
||||
D->>C: Assistant contacts client manually via WhatsApp
|
||||
alt Client sends payment proof & admin verifies bank deposit
|
||||
D->>A: POST /payments/acknowledge
|
||||
A->>T: Set payment_status=ACKNOWLEDGED, record acknowledged_by + audit log
|
||||
A->>G: Update event to [CONFIRMADO]
|
||||
else Jasmin authorizes delayed-payment exception
|
||||
D->>A: POST /bookings/{id}/authorize-delayed-payment
|
||||
A->>T: Set payment_arrangement=DELAYED_ALLOWED, keep AWAITING_ACKNOWLEDGMENT + audit log
|
||||
A->>G: Update event to [PAGO DIFERIDO]
|
||||
else Client gives up slot or does not respond by agreed cutoff
|
||||
D->>A: POST /bookings/{id}/release
|
||||
A->>T: Set booking_status=RELEASED, record released_by + audit log
|
||||
A->>G: Delete/cancel Calendar event (slot freed)
|
||||
end
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Buffer-Time Collision Prevention Algorithm
|
||||
|
||||
To resolve consultation overruns, individual appointment availability enforces a post-session buffer:
|
||||
|
||||
$$\text{Blocked Interval} = [\text{Start Time}, \text{Start Time} + \text{Duration} + \text{Buffer (15 min)}]$$
|
||||
|
||||
```
|
||||
[Consultation Slot: 10:00 - 11:00] + [Buffer: 11:00 - 11:15]
|
||||
Next Available: 11:15
|
||||
```
|
||||
|
||||
When checking availability for a requested slot $[T_{start}, T_{end}]$:
|
||||
1. Fetch existing bookings on the requested day where status $\in \{\text{PENDING\_PAYMENT}, \text{CONFIRMED}\}$.
|
||||
2. Fetch busy blocks from Google Calendar API.
|
||||
3. Compute overlap:
|
||||
$$\text{Overlap} \iff \max(T_{start}, E_{start}) < \min(T_{end} + \text{Buffer}, E_{end})$$
|
||||
4. If overlap detected, slot is rejected as unavailable.
|
||||
When checking availability for a requested slot $[T_{\text{start}}, T_{\text{end}}]$:
|
||||
1. Fetch existing `INDIVIDUAL` bookings where `booking_status = 'RESERVED'`. (Bookings marked `RELEASED` or `CANCELLED` do not block the schedule.)
|
||||
2. Compute overlap:
|
||||
$$\text{Overlap} \iff \max(T_{\text{start}}, E_{\text{start}}) < \min(T_{\text{end}} + \text{Buffer}, E_{\text{end}} + E_{\text{buffer}})$$
|
||||
3. If overlap is detected, the slot is rejected with `409 Conflict`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Multi-Session Package & Course Attendance Schema
|
||||
## 5. Security Boundary: Google OAuth & Turso Administrator Allowlist
|
||||
|
||||
```mermaid
|
||||
erDiagram
|
||||
CLIENTS ||--o{ PACKAGES : "purchases"
|
||||
PACKAGES ||--o{ BOOKINGS : "redeems"
|
||||
SERVICES ||--o{ PACKAGES : "applies to"
|
||||
OCCURRENCES ||--o{ ATTENDANCE : "has"
|
||||
CLIENTS ||--o{ ATTENDANCE : "attends"
|
||||
|
||||
PACKAGES {
|
||||
string id PK
|
||||
string client_id FK
|
||||
string service_id FK
|
||||
int total_sessions
|
||||
int completed_sessions
|
||||
int price_paid_mxn
|
||||
string financial_status "PAID | PARTIAL | PENDING"
|
||||
datetime created_at
|
||||
}
|
||||
|
||||
OCCURRENCES {
|
||||
string id PK
|
||||
string service_id FK
|
||||
datetime scheduled_at
|
||||
string topic "e.g. Clase 3: Abundancia"
|
||||
}
|
||||
|
||||
ATTENDANCE {
|
||||
string id PK
|
||||
string occurrence_id FK
|
||||
string client_id FK
|
||||
boolean attended
|
||||
int amount_paid_mxn
|
||||
string payment_method "SPEI | CASH"
|
||||
datetime recorded_at
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Future Extensibility: MCP & LLM Agent Readiness
|
||||
|
||||
The business layer is implemented as pure Python service functions returning Pydantic domain models, completely independent of the FastAPI routing layer.
|
||||
|
||||
This enables future exposure via:
|
||||
1. **Model Context Protocol (MCP)**: An MCP server exposing tools (`list_available_slots`, `reserve_session`, `verify_payment`, `get_client_package_status`) directly to Claude, Cursor, or Antigravity agents.
|
||||
2. **WhatsApp AI Bot**: A webhook listening to incoming WhatsApp messages from clients, querying `armonia-api` for availability, and answering booking inquiries conversationally.
|
||||
1. **Server-Side OAuth Secrets**: `GOOGLE_OAUTH_CLIENT_ID`, `GOOGLE_OAUTH_CLIENT_SECRET`, and `SESSION_SECRET_KEY` reside exclusively in `armonia-api`.
|
||||
2. **Turso `admin_allowlist` Table**: Stores authorized administrator emails (`email PRIMARY KEY`, `full_name`, `role`, `is_active`, `last_login_at`), seeded on startup from `ADMIN_BOOTSTRAP_EMAILS`.
|
||||
3. **Per-Request Verification**: Every protected administrative endpoint validates the HMAC-signed session token/cookie and verifies that the authenticated email has `is_active = 1` in `admin_allowlist`.
|
||||
4. **Immutable Audit Trail**: Every administrative action (`ACKNOWLEDGE_PAYMENT`, `AUTHORIZE_DELAYED_PAYMENT`, `RELEASE_BOOKING`, `UPDATE_BOOKING_STATUS`, `ALLOWLIST_CHANGE`) writes a structured row to `admin_audit_log`.
|
||||
@@ -6,7 +6,7 @@ Accepted
|
||||
## Context
|
||||
Armonía del Ser operates on a low-margin business model where recurring software subscription fees or persistent virtual private server (VPS) costs would outweigh the operational benefits. We require a relational database that:
|
||||
1. Incurs **$0/month** in operational overhead for the anticipated volume (< 500 bookings/month).
|
||||
2. Provides relational schema enforcement, constraints, and atomic operations (unlike Google Sheets).
|
||||
2. Provides relational schema enforcement, constraints, and atomic operations (unlike Google Sheets) for bookings, payment acknowledgments, administrator allowlists, and audit logs.
|
||||
3. Executes seamlessly in local development and automated CI/CD testing without requiring remote cloud network calls or credentials.
|
||||
|
||||
## Decision
|
||||
@@ -21,4 +21,4 @@ We adopt **Turso (libSQL)** as the primary production database, coupled with `li
|
||||
- **Relational Integrity**: Foreign keys and enum constraints prevent data corruption.
|
||||
|
||||
### Negative / Trade-offs
|
||||
- Turso does not provide a native visual spreadsheet UI for non-technical users. Jazmín cannot open the raw database table directly; she interacts with the data exclusively through `armonia-dashboard` and Google Calendar.
|
||||
- Turso does not provide a native visual spreadsheet UI for non-technical users. Jasmin cannot open the raw database table directly; she and her assistant interact with the data exclusively through `armonia-dashboard` and Google Calendar.
|
||||
@@ -1,27 +1,33 @@
|
||||
# ADR 0002: Anti-Ghosting Payment Verification Workflow via WhatsApp Deep Links
|
||||
# ADR 0002: Separated Booking Lifecycle, Delayed-Payment Exceptions, and 48-Hour Follow-Up Visibility
|
||||
|
||||
## Status
|
||||
Accepted
|
||||
Accepted (Amended 2026-10-18 per Operational Clarification with Jasmin's Assistant)
|
||||
|
||||
## Context
|
||||
A major operational pain point for Jazmín is financial default: clients allowed to pay *after* their therapy session often cease responding to WhatsApp messages ("ghosting").
|
||||
However, implementing a traditional payment gateway like Stripe or Conekta is not viable because:
|
||||
1. Credit card penetration is low among local wellness clients in Mexico; most prefer cash or SPEI bank transfers.
|
||||
2. Payment gateway transaction fees (3.6% + $3 MXN + VAT) erode low-ticket therapy margins.
|
||||
3. Complex checkout forms create drop-offs on mobile devices.
|
||||
Initially, we assumed that all bookings should require prepayment within a strict 2-hour automatic expiration window (`PENDING_PAYMENT` $\rightarrow$ `EXPIRED`). However, operational clarification with Jasmin's assistant revealed three critical realities:
|
||||
1. **Prepayment is the default, not an absolute rule**: While most sessions require payment before the appointment, Jasmin occasionally allows trusted clients to pay later. Those sessions must proceed while keeping the outstanding payment explicitly traceable as a delayed payment (`DELAYED_ALLOWED`) rather than silently marking it paid.
|
||||
2. **Releasing a slot is always a deliberate human decision**: Automatically expiring a booking after 2 hours conflicts with how Jasmin and her assistant operate. Instead, the dashboard must surface unacknowledged bookings as the session approaches (48 hours prior) so the assistant can manually follow up on WhatsApp and decide whether to acknowledge payment, authorize a delayed-payment exception, or deliberately release the slot (`RELEASED`).
|
||||
3. **Booking status and payment status are distinct facts**: Coupling schedule status (`RESERVED`, `RELEASED`, `COMPLETED`) and financial state (`AWAITING_ACKNOWLEDGMENT`, `ACKNOWLEDGED`) into a single column makes delayed-payment exceptions and post-session receivables impossible to represent cleanly.
|
||||
|
||||
## Decision
|
||||
We implement a **Verification Loop** using unique folios (`ADS-XXXX`) and WhatsApp deep links (`wa.me`):
|
||||
1. Client reservation creates a booking in state `PENDING_PAYMENT` with an automatic 2-hour expiration window.
|
||||
2. The UI immediately renders Jazmín's SPEI coordinates (Bank, CLABE, Beneficiary) and opens a WhatsApp conversation with a pre-filled message including the folio (`ADS-XXXX`).
|
||||
3. Jazmín receives the transfer proof screenshot in WhatsApp, verifies the deposit in her banking app, and confirms the booking with a single tap in `armonia-dashboard`.
|
||||
4. Only upon this acknowledgment does the booking transition to `CONFIRMED` and lock into Google Calendar.
|
||||
We separate booking and payment state into three orthogonal fields on `bookings`, supported by an explicit 48-hour follow-up queue and audit trail:
|
||||
1. **Three Orthogonal State Axes**:
|
||||
- `booking_status`: `RESERVED`, `RELEASED`, `CANCELLED`, `COMPLETED`, `NO_SHOW`
|
||||
- `payment_arrangement`: `PREPAID_DEFAULT`, `DELAYED_ALLOWED`, `PACKAGE_REDEEMED`
|
||||
- `payment_status`: `AWAITING_ACKNOWLEDGMENT`, `ACKNOWLEDGED`, `NOT_APPLICABLE`
|
||||
2. **48-Hour Follow-Up Queue (Derived Query Condition)**:
|
||||
- At 48 hours before `scheduled_at` (configurable via `PAYMENT_FOLLOWUP_THRESHOLD_HOURS`), any `RESERVED` booking with `payment_status = 'AWAITING_ACKNOWLEDGMENT'` surfaces in `GET /bookings/follow-up-queue`.
|
||||
- No background worker mutates or expires the booking; the threshold controls operational visibility.
|
||||
3. **Audited Administrative Actions**:
|
||||
- **Acknowledge Payment**: Verifies SPEI/cash receipt and sets `payment_status = 'ACKNOWLEDGED'`, recording `acknowledged_by` and `acknowledged_at`.
|
||||
- **Authorize Delayed Payment**: Sets `payment_arrangement = 'DELAYED_ALLOWED'` while keeping `payment_status = 'AWAITING_ACKNOWLEDGMENT'`, recording `exception_authorized_by`, `exception_authorized_at`, and `exception_notes`.
|
||||
- **Release Slot**: Sets `booking_status = 'RELEASED'` (and `payment_status = 'NOT_APPLICABLE'` if no session occurred), recording `released_by`, `released_at`, and `release_reason`, immediately freeing the slot for another client.
|
||||
|
||||
## Consequences
|
||||
### Positive
|
||||
- **Zero Payment Default**: Eliminates the "pay after session" trap without charging gateway transaction fees.
|
||||
- **Cultural Alignment**: "Apartar lugar con comprobante" is standard and culturally respected in Mexican wellness communities.
|
||||
- **Low Friction**: Leverages the tool clients already use continuously (WhatsApp).
|
||||
- **Operational Honesty**: Delayed-payment exceptions remain visible as receivables until actually paid and acknowledged.
|
||||
- **Human-in-the-Loop Control**: Neither Jasmin nor her assistant loses a booking to an unexpected timer, while the 48-hour queue ensures no unpaid slot slips through unnoticed.
|
||||
- **Zero Background Infrastructure**: Deriving the 48-hour queue on read requires zero cron jobs or always-on workers, preserving the $0 Cloud Run scale-to-zero profile.
|
||||
|
||||
### Negative / Trade-offs
|
||||
- Requires Jazmín (or her assistant) to manually cross-check deposits in her bank app before clicking "Confirmar".
|
||||
- Requires Jasmin's assistant to review the 48-hour follow-up queue and click "Liberar espacio" (`RELEASED`) when a client declines to complete payment.
|
||||
@@ -1,26 +1,28 @@
|
||||
# ADR 0003: Mandatory Buffer Times and Automated Calendar Synchronization
|
||||
# ADR 0003: Mandatory Buffer Times and Recoverable Google Calendar Synchronization
|
||||
|
||||
## Status
|
||||
Accepted
|
||||
Accepted (Amended 2026-10-18)
|
||||
|
||||
## Context
|
||||
Discovery feedback from long-term clients revealed chronic 10-to-35-minute delays in therapy sessions. The root causes were twofold:
|
||||
1. Therapy sessions frequently overrun their scheduled duration due to emotional crises or deep patient complications.
|
||||
2. Individual sessions were scheduled back-to-back with zero buffer time.
|
||||
Additionally, Jazmín occasionally misremembered appointment hours or forgot to enter bookings into her calendar.
|
||||
Discovery feedback from long-term clients revealed chronic 10-to-35-minute delays in therapy sessions caused by emotional consultation overruns and back-to-back scheduling without buffers. Additionally, Jasmin relies on Google Calendar to view her daily schedule on her phone, while `armonia-api` (backed by Turso) must remain the authoritative record of business state.
|
||||
|
||||
## Decision
|
||||
1. **Mandatory Post-Session Buffers**: Every individual appointment slot enforces an unbookable 15-to-20-minute buffer interval immediately following the session. A 60-minute consultation blocks 75–80 minutes on the scheduling engine.
|
||||
2. **Automated Google Calendar Sync**: All bookings are synced directly via Google Calendar API:
|
||||
- `PENDING_PAYMENT` events are created with `[PENDIENTE]` and highlighted in Yellow.
|
||||
- `CONFIRMED` events transition to `[CONFIRMADO]` and highlighted in Green.
|
||||
- Native calendar push notifications remind Jazmín 24 hours and 1 hour prior to each appointment.
|
||||
1. **Mandatory Post-Session Buffers**: Every individual appointment (`INDIVIDUAL`) enforces an unbookable 15-to-20-minute buffer interval immediately following the session. A 60-minute consultation blocks 75 minutes on the scheduling engine for any `RESERVED` booking.
|
||||
2. **Backend-Owned Truth with Google Calendar Coordination**:
|
||||
- `armonia-api` owns the authoritative booking and payment decision in Turso; Google Calendar reflects the schedule:
|
||||
- `[PAGO PENDIENTE]` when `booking_status = 'RESERVED'`, `payment_arrangement = 'PREPAID_DEFAULT'`, and `payment_status = 'AWAITING_ACKNOWLEDGMENT'`.
|
||||
- `[PAGO DIFERIDO]` when `booking_status = 'RESERVED'`, `payment_arrangement = 'DELAYED_ALLOWED'`, and `payment_status = 'AWAITING_ACKNOWLEDGMENT'`.
|
||||
- `[CONFIRMADO]` when `payment_status = 'ACKNOWLEDGED'` or `payment_arrangement = 'PACKAGE_REDEEMED'`.
|
||||
- Event deleted/cancelled when `booking_status` transitions to `RELEASED` or `CANCELLED`.
|
||||
3. **Visible & Recoverable Integration State**:
|
||||
- Each booking stores `gcal_event_id`, `gcal_sync_status` (`PENDING`, `SYNCED`, `FAILED`, `NOT_CONFIGURED`), `gcal_sync_error`, and `gcal_synced_at`.
|
||||
- If the Google Calendar API fails transiently, the Turso record is preserved with `gcal_sync_status = 'FAILED'` and administrators can retry synchronization via `POST /bookings/{id}/sync-calendar`.
|
||||
|
||||
## Consequences
|
||||
### Positive
|
||||
- Prevents cascade delays across consultations.
|
||||
- Eliminates forgotten sessions and schedule collisions.
|
||||
- Provides emotional decompression time for the therapist between patients.
|
||||
- Prevents cascade delays across consultations and frees slots immediately when a booking is `RELEASED`.
|
||||
- Prevents silent divergence between Turso and Google Calendar by surfacing `gcal_sync_status` and `gcal_sync_error` directly to the dashboard.
|
||||
- Works cleanly in local development and tests (`NOT_CONFIGURED` fallback when GCP credentials are absent).
|
||||
|
||||
### Negative / Trade-offs
|
||||
- Slightly reduces theoretical maximum daily capacity (e.g., maximum 5 sessions/day instead of 6). However, the trade-off strongly favors punctuality, professional reputation, and therapist well-being.
|
||||
- Slightly reduces theoretical maximum daily capacity (e.g., maximum 5 sessions/day instead of 6) in exchange for punctuality and therapist well-being.
|
||||
@@ -4,18 +4,18 @@
|
||||
Accepted
|
||||
|
||||
## Context
|
||||
Operational interviews revealed that clients frequently purchase therapy as multi-session packages (e.g., 5 or 10 sessions paid upfront). Currently, tracking remaining sessions (e.g. "sesión 8 de 10") is discussed informally at the end of consultations, relying on memory and chat history.
|
||||
Similarly, for recurring low-cost workshops (*Curso de Abundancia*, $50 MXN/session), Jazmín records attendees and payments on a physical sheet of paper and photographs it to share with her assistant.
|
||||
Operational interviews revealed that clients frequently purchase therapy as multi-session packages (e.g., 5 or 10 sessions). Currently, tracking remaining sessions (e.g. "sesión 8 de 10") is discussed informally at the end of consultations, relying on memory and chat history.
|
||||
Similarly, for recurring low-cost workshops (*Curso de Abundancia*, $50 MXN/session), Jasmin records attendees and payments on a physical sheet of paper and photographs it to share with her assistant.
|
||||
|
||||
## Decision
|
||||
1. **Package Domain Model**: We introduce a `packages` entity tracking `client_id`, `service_id`, `total_sessions`, and `completed_sessions`. Booking individual sessions decrements available package credits without triggering payment requests.
|
||||
2. **Digital Workshop Attendance Ledger**: We introduce an `occurrences` and `attendance` model allowing Jazmín or her assistant to record workshop participants and toggle payment status (`attended: true/false`, `payment_method: CASH | SPEI`) with a single mobile tap in `armonia-dashboard`.
|
||||
1. **Package Domain Model**: We introduce a `packages` entity tracking `client_id`, `service_id`, `total_sessions`, and `completed_sessions`. Booking individual sessions under a package sets `payment_arrangement = 'PACKAGE_REDEEMED'` and `payment_status = 'NOT_APPLICABLE'`, decrementing available package credits without entering the unpaid follow-up queue.
|
||||
2. **Digital Workshop Attendance Ledger**: We support workshop roster tracking allowing Jasmin or her assistant to record workshop participants and payment status in `armonia-dashboard`.
|
||||
|
||||
## Consequences
|
||||
### Positive
|
||||
- Completely replaces physical paper sheets and phone photographs.
|
||||
- Eliminates awkward verbal disputes over remaining package sessions.
|
||||
- Enables collaborative coordination between Jazmín and her assistant.
|
||||
- Eliminates verbal confusion over remaining package sessions.
|
||||
- Enables collaborative coordination between Jasmin and her assistant.
|
||||
|
||||
### Negative / Trade-offs
|
||||
- Adds additional entities (`packages`, `attendance`) to the data model and migration pipeline.
|
||||
- Adds `packages` entity management to the data model.
|
||||
@@ -0,0 +1,28 @@
|
||||
# ADR 0005: Backend Google OAuth2 Authentication and Turso Administrator Allowlist
|
||||
|
||||
## Status
|
||||
Accepted (2026-10-18)
|
||||
|
||||
## Context
|
||||
`armonia-dashboard` is an operational control surface used by Jasmin and her assistant to acknowledge SPEI/cash payments, authorize delayed-payment exceptions, and release booking slots. Because `armonia-dashboard` is deployed as a static application on Cloudflare Pages, client-side route guards alone cannot protect administrative operations or keep OAuth secrets safe. Furthermore, if Jasmin rotates her assistant, revoking access must take effect immediately without rebuilding or redeploying containers.
|
||||
|
||||
## Decision
|
||||
1. **Backend-Driven Google OAuth2 Authorization Code Flow**:
|
||||
- `armonia-api` hosts `/auth/google/login` and `/auth/google/callback`, keeping `GOOGLE_OAUTH_CLIENT_ID`, `GOOGLE_OAUTH_CLIENT_SECRET`, and `SESSION_SECRET_KEY` strictly on the backend.
|
||||
- Upon callback, `armonia-api` exchanges the authorization code with Google, verifies `email_verified == true`, and checks the email against Turso's `admin_allowlist` table.
|
||||
- `armonia-api` issues an HMAC-SHA256 signed session token (delivered via `HttpOnly` cookie and usable as a `Bearer` token).
|
||||
2. **Dedicated `admin_allowlist` Table in Turso**:
|
||||
- Stores `email PRIMARY KEY`, `full_name`, `role` (`OWNER`, `ASSISTANT`, `ADMIN`), `is_active`, `created_at`, and `last_login_at`.
|
||||
- Seeded idempotently on startup from `ADMIN_BOOTSTRAP_EMAILS`.
|
||||
- Checked on **every** authenticated administrative request so setting `is_active = 0` revokes access immediately.
|
||||
3. **Mandatory Audit Logging (`admin_audit_log`)**:
|
||||
- Every administrative mutation records the authenticated administrator's email, action type, target entity ID, and timestamp in `admin_audit_log` as well as on the booking/payment record (`acknowledged_by`, `exception_authorized_by`, `released_by`).
|
||||
|
||||
## Consequences
|
||||
### Positive
|
||||
- Zero OAuth client secrets or session signing keys exposed in the frontend bundle.
|
||||
- Instant administrator revocation or addition via Turso without container redeployment.
|
||||
- Complete accountability for who acknowledged a payment, authorized a delayed payment, or released a slot.
|
||||
|
||||
### Negative / Trade-offs
|
||||
- Every protected administrative request performs a fast primary-key lookup against `admin_allowlist` in Turso/SQLite.
|
||||
@@ -0,0 +1,30 @@
|
||||
# ADR 0006: Mutation Testing & Boundary Hardening for Core Business Logic
|
||||
|
||||
## Status
|
||||
Accepted (2026-10-19)
|
||||
|
||||
## Context
|
||||
Standard line and branch coverage metrics only verify that code was executed during a test run; they do not verify that the test assertions are strict enough to detect subtle defects.
|
||||
|
||||
In `armonia-api`, two domain invariants carry direct business risks if mutated:
|
||||
1. **Mandatory Post-Session Buffer Overlap Math**:
|
||||
- An off-by-one operator error ($<$ vs $\le$) or sign change (`duration - buffer` instead of `duration + buffer`) could either allow double-booking a slot during Jasmin's decompression window or falsely reject a legitimate back-to-back appointment.
|
||||
2. **48-Hour Payment Follow-Up Cutoff**:
|
||||
- A boundary condition mutation ($<$ vs $\le$) on `hours_until <= threshold` could exclude consultantes scheduled at the exact threshold boundary, preventing Jasmin's assistant from sending timely WhatsApp follow-ups and allowing ghosted reservations to block inventory.
|
||||
|
||||
## Decision
|
||||
1. **Decouple Pure Domain Logic into `app/services/`**:
|
||||
- Business arithmetic (buffer collision detection, 48-hour follow-up evaluation, and folio generation) is decoupled from FastAPI route handlers into `app/services/bookings.py` and `app/services/timestamps.py`.
|
||||
2. **Adopt `mutmut` as Quality Audit Gate**:
|
||||
- Mutation testing is configured in `pyproject.toml` (`[tool.mutmut]`), targeting `app/services/`.
|
||||
- The test selection for mutation workers is restricted to isolated unit tests (`pytest_add_cli_args_test_selection = ["tests/unit/services/"]`) to avoid SQLite database lock contention (`SQLITE_BUSY`) during parallel test execution.
|
||||
- All surviving mutants on boundary arithmetic ($<$, $\le$, `+`, `-`, and threshold fallbacks) must be eliminated prior to merging PRs altering `app/services/`.
|
||||
|
||||
## Consequences
|
||||
### Positive
|
||||
- **Guaranteed Boundary Invariants**: 100% kill rate achieved on domain functions (`check_slot_collision`, `evaluate_payment_followup`, `calculate_hours_until`, `parse_iso_datetime`, `compute_calendar_prefix`).
|
||||
- **Zero Tautological Tests**: Unit tests assert exact boundary values (`48.0h`, `48.01h`, adjacent buffer ends) rather than loose status checks.
|
||||
- **Fast Execution**: Pure unit tests execute in under 0.1 seconds, enabling `mutmut` to evaluate 250+ mutants in seconds.
|
||||
|
||||
### Negative / Trade-offs
|
||||
- Developers modifying domain logic in `app/services/` must run `mutmut` alongside standard `pytest` to prevent mutation leaks.
|
||||
@@ -1,60 +0,0 @@
|
||||
# Raw Discovery Interview: Jazmín's Assistant & Client Feedback
|
||||
|
||||
**Date Recorded:** 2026-10-18
|
||||
**Source:** Direct interview feedback from Jazmín's assistant and long-term client (2 years of consultation history)
|
||||
**Business:** Armonía del Ser (Mexico)
|
||||
**Purpose:** Unvarnished primary operational data capturing how bookings, payments, schedules, and group courses actually operate in daily practice.
|
||||
|
||||
---
|
||||
|
||||
## Verbatim Interview Transcripts
|
||||
|
||||
### 1. Inbound Channels & Community Presence
|
||||
> *"Llegan a Whatssap. Mensaje directo aunque no se si haya gente que intente llamarla directamente, como todo imagino que si. También ella lleva 20 años en la ciudad pequeña donde vive así que allá la recomiendan voz a voz. Se planea que lo q llegue por redes se redireccione a Whatssap."*
|
||||
|
||||
**Key Takeaways:**
|
||||
- Primary conversational funnel is WhatsApp (direct messages and voice calls).
|
||||
- Strong local word-of-mouth reputation (20 years operating in the local community).
|
||||
- Social media strategy relies on redirecting external traffic directly into WhatsApp.
|
||||
|
||||
---
|
||||
|
||||
### 2. Group vs. 1-on-1 Registration Operations
|
||||
> *"¿Cómo así que como manejas la diferencia? ¿A q hace referencia? ¿Al calendario de ella? Se que la gente se inscribe directamente en persona o por Whatssap así que eso sería algo q yo tambn entraría a hacer."*
|
||||
|
||||
**Key Takeaways:**
|
||||
- In-person and WhatsApp registrations are the primary entry points.
|
||||
- Collaborative management: The assistant also needs access to register participants on Jazmín's behalf.
|
||||
|
||||
---
|
||||
|
||||
### 3. Payment Models, Packages, & Balances
|
||||
> *"En mi experiencia como cliente, antes de la sesión. Y como yo estoy afuera de México por paquete pagaba por adelantado. A veces al finalizar la sesión nos poníamos al día de en q #de sesión íbamos. Ejemplo 8 de 10.*
|
||||
>
|
||||
> *Lo del saldo es complejo porque hay cosas q se dicen en persona entonces ahí es donde ella sesión está haciendo bola. Y si básicamente memoria, Whatssap, o incluso charlarlo con el cliente que pues ya lot depende de la sinceridad del cliente. Ella ha sido algo desordenada con eso.*
|
||||
>
|
||||
> *Por ej empezamos un curso de abundancia y prosperidad (que eres bienvenido haha es de aporte simbólico de $50 Méx por sesión) y anotó el listado de participantes y quienes la pagaron en una hoja y me envió la foto."*
|
||||
|
||||
**Key Takeaways:**
|
||||
- **Package model**: Consultations are frequently bought as multi-session packages (e.g. 10 sessions) paid upfront.
|
||||
- **Session counter ambiguity**: Tracking session numbers (e.g. "sesión 8 de 10") is currently manual, discussed verbally at the end of sessions.
|
||||
- **Unsettled balances & social friction**: In-person agreements cause confusion ("hacerse bolas"). Relies on memory, WhatsApp chat history, and the client's honesty.
|
||||
- **Group workshop lists**: For low-cost workshops (*Curso de Abundancia y Prosperidad*, $50 MXN/session), Jazmín writes attendee and payment lists by hand on a paper sheet and photographs it. Needs a digital 1-tap equivalent.
|
||||
|
||||
---
|
||||
|
||||
### 4. Group Session Capacities
|
||||
> *"A las grupales aprox 10. Aún el dato no lo tengo pero si quiero preguntarles de hecho está re bueno para mi saber q preguntas exactas formularle."*
|
||||
|
||||
**Key Takeaways:**
|
||||
- Typical group session attendance is approximately 10 people.
|
||||
|
||||
---
|
||||
|
||||
### 5. Scheduling Friction, Delays, & Calendar Confusion
|
||||
> *"Yo diría q pagos olvidados y lo de la agenda full, casi siempre llegaba tarde a mis consultas, así fuese 10 min a 30-35min porque estaba finalizando otra consulta o porque otro paciente se complicaba en la consulta anterior, eso nunca me gustó, ahora al menos en la noche que solo estoy en constaleciones habmejorado su puntualidad… o me pasó mientras fue mi consultante dos años que un par de veces de repente ella creía q la cita era a otra hr y yo ahí esperando o se le había olvidado agendarla."*
|
||||
|
||||
**Key Takeaways:**
|
||||
- **Tardiness Root Cause**: Chronic 10-35 minute delays caused by consultations running overtime with emotional/complex patients, compounded by back-to-back scheduling with **zero buffer time**.
|
||||
- **Forgotten & Colliding Appointments**: Jazmín sometimes misremembers appointment times or forgets to add them to her calendar altogether, leaving clients waiting.
|
||||
- **Urgent Need**: Mandatory automated buffer times between sessions and automated Google Calendar two-way synchronization with push reminders.
|
||||
Generated
+61
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1791914995,
|
||||
"narHash": "sha256-Zf/xfQEAasnwnmEfHqW/4hjDE/s44yn2hD4RuVIZRjA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b7a79d3fea1e214f6d668d521cecec0c01e26544",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1792094642,
|
||||
"narHash": "sha256-zp8ToDMnqZcu4o4IH9pdwXFXGp7yLm/M0dEnNWnyd7I=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fe13242281a67641c0102cdb1087f0ebe586c7df",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
description = "Armonía del Ser: Core API (armonia-api) — Python 3.13 + uv devShell";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "armonia-api-dev-shell";
|
||||
packages = with pkgs; [
|
||||
python313
|
||||
uv
|
||||
ruff
|
||||
pyright
|
||||
sqlite
|
||||
tea
|
||||
];
|
||||
env = {
|
||||
UV_PYTHON_PREFERENCE = "only-system";
|
||||
UV_PYTHON = "${pkgs.python313}/bin/python3";
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
+15
-1
@@ -5,19 +5,28 @@ description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.13"
|
||||
dependencies = [
|
||||
"email-validator>=2.3.0",
|
||||
"fastapi>=0.115.0",
|
||||
"httpx>=0.27.0",
|
||||
"libsql-client>=0.3.1",
|
||||
"pydantic>=2.8.0",
|
||||
"pydantic[email]>=2.8.0",
|
||||
"pydantic-extra-types>=2.11.1",
|
||||
"pydantic-settings>=2.4.0",
|
||||
"sqlalchemy-libsql>=0.2.0",
|
||||
"sqlmodel>=0.0.48",
|
||||
"time-machine>=3.5.1",
|
||||
"uvicorn[standard]>=0.30.0",
|
||||
"httpx2>=2.14.0",
|
||||
"tzdata>=2026.5",
|
||||
]
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"mutmut>=3.8.0",
|
||||
"pyright>=1.1.414",
|
||||
"pytest>=9.1.1",
|
||||
"pytest-asyncio>=1.4.0",
|
||||
"pytest-mock>=3.17.0",
|
||||
"ruff>=0.17.1",
|
||||
]
|
||||
|
||||
@@ -37,3 +46,8 @@ asyncio_mode = "auto"
|
||||
testpaths = ["tests"]
|
||||
pythonpath = ["."]
|
||||
|
||||
[tool.mutmut]
|
||||
source_paths = ["app/services/"]
|
||||
also_copy = ["app"]
|
||||
pytest_add_cli_args_test_selection = ["tests/unit/services/"]
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
# Test Suite Architecture & Mutation Testing Guide (`armonia-api`)
|
||||
|
||||
This directory contains the automated test suite for `armonia-api`, structured into isolated unit tests and end-to-end integration workflows.
|
||||
|
||||
---
|
||||
|
||||
## 1. Test Suite Taxonomy
|
||||
|
||||
```
|
||||
tests/
|
||||
├── conftest.py # Session fixtures, SQLite lifecycle, TestClient
|
||||
├── test_auth_and_workflows.py # Integration: OAuth allowlist, 48h queue, delayed pay
|
||||
├── test_bookings.py # Integration: Booking creation, payment ack, buffers
|
||||
├── test_health.py # Integration: Health check probe
|
||||
├── test_services.py # Integration: Seeded service catalog endpoints
|
||||
└── unit/ # Fast, isolated unit tests (< 0.5s total)
|
||||
├── models/ # SQLModel schema validation and defaults
|
||||
│ ├── test_admin_model.py
|
||||
│ ├── test_booking_model.py
|
||||
│ ├── test_client_model.py
|
||||
│ ├── test_package_model.py
|
||||
│ ├── test_payment_model.py
|
||||
│ └── test_service_model.py
|
||||
├── services/ # Consumer-agnostic domain logic invariants
|
||||
│ ├── test_booking_service.py # Buffer collision arithmetic & 48h follow-up rules
|
||||
│ ├── test_calendar.py # Calendar prefix computation & unconfigured fallback
|
||||
│ └── test_timestamps.py # UTC ISO serialization & timezone normalization
|
||||
└── test_database.py # SQLite table reflection & schema parity
|
||||
```
|
||||
|
||||
### Unit Tests (`tests/unit/`)
|
||||
- **Execution Speed:** In-memory, zero network I/O, zero database concurrency contention.
|
||||
- **Coverage:** Pure business invariants—buffer overlap math, 48-hour follow-up state machines, folio generation, timestamp parsing, and model field validations.
|
||||
|
||||
### Integration Tests (`tests/test_*.py`)
|
||||
- **Execution:** Exercises FastAPI routes against an isolated local SQLite file (`test_armonia.db`).
|
||||
- **External I/O:** Google Calendar and OAuth network side-effects are mocked via `pytest-mock` (`mocker`) and monkeypatched configuration.
|
||||
|
||||
---
|
||||
|
||||
## 2. Running Verification Gates
|
||||
|
||||
Ensure you are inside the Nix `devShell` (`direnv` or `nix develop`).
|
||||
|
||||
```bash
|
||||
# 1. Format check
|
||||
uv run ruff format --check .
|
||||
|
||||
# 2. Lint check
|
||||
uv run ruff check .
|
||||
|
||||
# 3. Static type analysis
|
||||
uv run pyright
|
||||
|
||||
# 4. Pytest test suite
|
||||
uv run pytest
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Mutation Testing with `mutmut`
|
||||
|
||||
Mutation testing systematically inserts synthetic syntactic faults (e.g., swapping `<` for `<=`, flipping boolean conditions, changing buffer addition `+` to `-`, or altering numeric constants) to verify that unit tests fail when code semantics change.
|
||||
|
||||
### Configuration (`pyproject.toml`)
|
||||
Mutmut is configured under `[tool.mutmut]`:
|
||||
```toml
|
||||
[tool.mutmut]
|
||||
source_paths = ["app/services/"]
|
||||
also_copy = ["app"]
|
||||
pytest_add_cli_args_test_selection = ["tests/unit/services/"]
|
||||
```
|
||||
- **`source_paths`**: Targets extracted domain services (`app/services/`).
|
||||
- **`also_copy = ["app"]`**: Ensures `app.core`, `app.models`, and schema modules are copied into the mutant runtime workspace to prevent `ModuleNotFoundError`.
|
||||
- **`pytest_add_cli_args_test_selection`**: Executes lightning-fast unit tests (`tests/unit/services/`) for each mutant, preventing SQLite file lock contention (`SQLITE_BUSY`) during parallel worker execution.
|
||||
|
||||
### Mutation Execution Workflow
|
||||
```bash
|
||||
# Clean previous mutant artifacts and run mutation audit
|
||||
rm -rf mutants && uv run mutmut run
|
||||
|
||||
# Check surviving mutants (should output nothing when 100% killed)
|
||||
uv run mutmut results
|
||||
|
||||
# Inspect a specific mutant diff
|
||||
uv run mutmut show <mutant_id>
|
||||
|
||||
# Export CI/CD machine-readable statistics
|
||||
uv run mutmut export-cicd-stats
|
||||
```
|
||||
|
||||
### Hardened Domain Invariants
|
||||
The unit tests in `tests/unit/services/test_booking_service.py` specifically enforce:
|
||||
1. **Buffer Collision Boundaries ($<$ vs $\le$):**
|
||||
- Adjacent slots (`new_start == exist_blocked_end` or `new_blocked_end == exist_start`) return `False` (no collision). Mutants replacing `<` with `<=` are caught and killed.
|
||||
- Buffer encroachment: If the session ended but its post-session buffer overlaps another reservation, `check_slot_collision` returns `True`. Mutants altering `duration + buffer` to `duration - buffer` are killed.
|
||||
2. **48-Hour Follow-Up Cutoff:**
|
||||
- Exact boundary: A reservation scheduled at exactly `48.0` hours from `now` with `AWAITING_ACKNOWLEDGMENT` evaluates to `True` (`needs_followup`). Mutants replacing `<=` with `<` fail this assertion and are killed.
|
||||
- Non-eligible appointments (already `ACKNOWLEDGED`, `CANCELLED`, or beyond 48 hours) evaluate to `False`.
|
||||
3. **Delayed Payment Exceptions (`DELAYED_ALLOWED`):**
|
||||
- Active or completed sessions with delayed payment authorization remain flagged for follow-up regardless of elapsed time (`hours_until`).
|
||||
@@ -0,0 +1,218 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from sqlmodel import Session, select
|
||||
|
||||
from app.core.auth import create_session_token
|
||||
from app.core.config import AuthProvider, settings
|
||||
from app.db.database import get_engine
|
||||
from app.models.admin import AdminAllowlist
|
||||
|
||||
OWNER_EMAIL = "jasmin@armoniadelser.mx"
|
||||
|
||||
|
||||
def _proxy_headers(
|
||||
email: str | None = "operadora@homelab.lan",
|
||||
groups: str | None = "users,armonia-assistant",
|
||||
name: str | None = "Operadora Homelab",
|
||||
*,
|
||||
user: str | None = None,
|
||||
) -> dict[str, str]:
|
||||
headers: dict[str, str] = {}
|
||||
if email is not None:
|
||||
headers["Remote-Email"] = email
|
||||
if user is not None:
|
||||
headers["Remote-User"] = user
|
||||
if groups is not None:
|
||||
headers["Remote-Groups"] = groups
|
||||
if name is not None:
|
||||
headers["Remote-Name"] = name
|
||||
return headers
|
||||
|
||||
|
||||
def _bearer(email: str = OWNER_EMAIL) -> dict[str, str]:
|
||||
return {"Authorization": f"Bearer {create_session_token(email)}"}
|
||||
|
||||
|
||||
def _dev_key(email: str | None = OWNER_EMAIL, key: str | None = None) -> dict[str, str]:
|
||||
headers = {"X-Admin-Key": key if key is not None else settings.admin_api_key}
|
||||
if email is not None:
|
||||
headers["X-Admin-Email"] = email
|
||||
return headers
|
||||
|
||||
|
||||
def _allowlist_row(email: str) -> AdminAllowlist | None:
|
||||
with Session(get_engine()) as session:
|
||||
return session.exec(select(AdminAllowlist).where(AdminAllowlist.email == email)).first()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def proxy_mode(monkeypatch):
|
||||
monkeypatch.setattr(settings, "auth_provider", AuthProvider.PROXY_HEADERS)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def production(monkeypatch):
|
||||
monkeypatch.setattr(settings, "environment", "production")
|
||||
|
||||
|
||||
# --- proxy_headers (Authelia + LLDAP) -------------------------------------------------
|
||||
|
||||
|
||||
def test_proxy_headers_build_principal_from_authelia_headers(client, proxy_mode):
|
||||
res = client.get("/auth/me", headers=_proxy_headers())
|
||||
assert res.status_code == 200
|
||||
body = res.json()
|
||||
assert body["email"] == "operadora@homelab.lan"
|
||||
assert body["full_name"] == "Operadora Homelab"
|
||||
assert body["role"] == "ASSISTANT"
|
||||
|
||||
|
||||
def test_proxy_headers_normalize_email_and_fall_back_to_remote_user(client, proxy_mode):
|
||||
res = client.get(
|
||||
"/auth/me",
|
||||
headers=_proxy_headers(email=None, user=" Owner@Homelab.LAN ", groups="armonia-owner"),
|
||||
)
|
||||
assert res.status_code == 200
|
||||
assert res.json()["email"] == "owner@homelab.lan"
|
||||
assert res.json()["role"] == "OWNER"
|
||||
|
||||
|
||||
def test_proxy_headers_fall_back_to_email_when_remote_name_missing(client, proxy_mode):
|
||||
res = client.get("/auth/me", headers=_proxy_headers(name=None))
|
||||
assert res.status_code == 200
|
||||
assert res.json()["full_name"] == "operadora@homelab.lan"
|
||||
|
||||
|
||||
def test_proxy_headers_without_identity_are_unauthenticated(client, proxy_mode):
|
||||
res = client.get("/auth/me", headers=_proxy_headers(email=None, user=None))
|
||||
assert res.status_code == 401
|
||||
|
||||
|
||||
def test_proxy_headers_without_armonia_group_are_forbidden(client, proxy_mode):
|
||||
res = client.get("/auth/me", headers=_proxy_headers(groups="users,family"))
|
||||
assert res.status_code == 403
|
||||
|
||||
|
||||
def test_proxy_headers_reads_never_touch_the_allowlist(client, proxy_mode):
|
||||
email = "lector.solo@homelab.lan"
|
||||
res = client.get("/bookings/follow-up-queue", headers=_proxy_headers(email=email))
|
||||
assert res.status_code == 200
|
||||
assert _allowlist_row(email) is None
|
||||
|
||||
|
||||
def test_proxy_headers_mirror_principal_into_allowlist_on_first_write(client, proxy_mode):
|
||||
email = "escritora@homelab.lan"
|
||||
assert _allowlist_row(email) is None
|
||||
|
||||
res = client.post(
|
||||
"/auth/allowlist",
|
||||
headers=_proxy_headers(email=email, groups="armonia-owner", name="Escritora"),
|
||||
json={"email": "nueva.asistente@armoniadelser.mx", "full_name": "Nueva Asistente"},
|
||||
)
|
||||
assert res.status_code == 201
|
||||
|
||||
mirrored = _allowlist_row(email)
|
||||
assert mirrored is not None
|
||||
assert mirrored.role == "OWNER"
|
||||
assert mirrored.full_name == "Escritora"
|
||||
assert mirrored.last_login_at is not None
|
||||
|
||||
# Audit trail references the mirrored actor (FK target exists)
|
||||
audit = client.get(
|
||||
"/auth/audit-log?entity_id=nueva.asistente@armoniadelser.mx",
|
||||
headers=_proxy_headers(email=email, groups="armonia-owner"),
|
||||
).json()
|
||||
assert audit[0]["admin_email"] == email
|
||||
|
||||
|
||||
def test_proxy_mirror_tracks_role_changes_from_lldap(client, proxy_mode):
|
||||
email = "promovida@homelab.lan"
|
||||
for groups in ("armonia-assistant", "armonia-admin"):
|
||||
res = client.patch(
|
||||
f"/auth/allowlist/{OWNER_EMAIL}",
|
||||
headers=_proxy_headers(email=email, groups=groups),
|
||||
json={},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
mirrored = _allowlist_row(email)
|
||||
assert mirrored is not None
|
||||
assert mirrored.role == "ADMIN"
|
||||
|
||||
|
||||
def test_proxy_mode_ignores_bearer_tokens_in_production(client, proxy_mode, production):
|
||||
assert client.get("/auth/me", headers=_bearer()).status_code == 401
|
||||
|
||||
|
||||
def test_proxy_mode_rejects_dev_key_in_production(client, proxy_mode, production):
|
||||
assert client.get("/auth/me", headers=_dev_key()).status_code == 401
|
||||
|
||||
|
||||
def test_proxy_mode_allows_dev_key_fallback_outside_production(client, proxy_mode):
|
||||
res = client.get("/auth/me", headers=_dev_key())
|
||||
assert res.status_code == 200
|
||||
assert res.json()["email"] == OWNER_EMAIL
|
||||
|
||||
|
||||
# --- google_oauth -------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_google_oauth_ignores_spoofed_proxy_headers(client):
|
||||
assert settings.auth_provider == AuthProvider.GOOGLE_OAUTH
|
||||
res = client.get("/auth/me", headers=_proxy_headers(groups="armonia-owner"))
|
||||
assert res.status_code == 401
|
||||
|
||||
|
||||
def test_google_oauth_rejects_invalid_session_token(client):
|
||||
res = client.get("/auth/me", headers={"Authorization": "Bearer not.a-valid-token"})
|
||||
assert res.status_code == 401
|
||||
|
||||
|
||||
def test_google_oauth_accepts_session_cookie(client):
|
||||
client.cookies.set("armonia_session", create_session_token(OWNER_EMAIL))
|
||||
try:
|
||||
res = client.get("/auth/me")
|
||||
finally:
|
||||
client.cookies.clear()
|
||||
assert res.status_code == 200
|
||||
assert res.json()["role"] == "OWNER"
|
||||
|
||||
|
||||
def test_google_oauth_rejects_dev_key_in_production(client, production):
|
||||
assert client.get("/auth/me", headers=_dev_key()).status_code == 401
|
||||
|
||||
|
||||
def test_google_oauth_session_still_works_in_production(client, production):
|
||||
assert client.get("/auth/me", headers=_bearer()).status_code == 200
|
||||
|
||||
|
||||
# --- dev_key ------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dev_key_mode(monkeypatch):
|
||||
monkeypatch.setattr(settings, "auth_provider", AuthProvider.DEV_KEY)
|
||||
|
||||
|
||||
def test_dev_key_resolves_allowlisted_email(client, dev_key_mode):
|
||||
res = client.get("/auth/me", headers=_dev_key("asistente@armoniadelser.mx"))
|
||||
assert res.status_code == 200
|
||||
assert res.json()["role"] == "ASSISTANT"
|
||||
|
||||
|
||||
def test_dev_key_without_email_uses_first_bootstrap_admin(client, dev_key_mode):
|
||||
res = client.get("/auth/me", headers=_dev_key(email=None))
|
||||
assert res.status_code == 200
|
||||
assert res.json()["email"] == settings.admin_bootstrap_emails[0]
|
||||
|
||||
|
||||
def test_dev_key_with_wrong_key_is_unauthenticated(client, dev_key_mode):
|
||||
assert client.get("/auth/me", headers=_dev_key(key="wrong-key")).status_code == 401
|
||||
|
||||
|
||||
def test_dev_key_with_non_allowlisted_email_is_forbidden(client, dev_key_mode):
|
||||
assert client.get("/auth/me", headers=_dev_key("intruder@example.com")).status_code == 403
|
||||
|
||||
|
||||
def test_dev_key_mode_ignores_bearer_tokens(client, dev_key_mode):
|
||||
assert client.get("/auth/me", headers=_bearer()).status_code == 401
|
||||
@@ -0,0 +1,222 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
from app.core.auth import create_session_token
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
def _admin_headers(email: str = "jasmin@armoniadelser.mx") -> dict[str, str]:
|
||||
token = create_session_token(email)
|
||||
return {"Authorization": f"Bearer {token}"}
|
||||
|
||||
|
||||
def test_admin_auth_and_turso_allowlist_enforcement(client):
|
||||
# 1. Unauthenticated request to protected endpoint returns 401
|
||||
unauth_res = client.get("/bookings/follow-up-queue")
|
||||
assert unauth_res.status_code == 401
|
||||
|
||||
# 2. Signed token for non-allowlisted email returns 403
|
||||
intruder_headers = _admin_headers("intruder@example.com")
|
||||
forbidden_res = client.get("/bookings/follow-up-queue", headers=intruder_headers)
|
||||
assert forbidden_res.status_code == 403
|
||||
|
||||
# 3. Bootstrap allowlisted admin (Jasmin) succeeds on /auth/me
|
||||
me_res = client.get("/auth/me", headers=_admin_headers("jasmin@armoniadelser.mx"))
|
||||
assert me_res.status_code == 200
|
||||
assert me_res.json()["email"] == "jasmin@armoniadelser.mx"
|
||||
assert me_res.json()["role"] == "OWNER"
|
||||
|
||||
# 4. Add a temporary assistant to allowlist, verify access, then revoke (is_active=False)
|
||||
add_res = client.post(
|
||||
"/auth/allowlist",
|
||||
headers=_admin_headers("jasmin@armoniadelser.mx"),
|
||||
json={
|
||||
"email": "temp.assistant@armoniadelser.mx",
|
||||
"full_name": "Asistente Temporal",
|
||||
"role": "ASSISTANT",
|
||||
"is_active": True,
|
||||
},
|
||||
)
|
||||
assert add_res.status_code == 201
|
||||
|
||||
temp_headers = _admin_headers("temp.assistant@armoniadelser.mx")
|
||||
assert client.get("/auth/me", headers=temp_headers).status_code == 200
|
||||
|
||||
# Revoke access in Turso allowlist -> immediate 403 on next request
|
||||
revoke_res = client.patch(
|
||||
"/auth/allowlist/temp.assistant@armoniadelser.mx",
|
||||
headers=_admin_headers("jasmin@armoniadelser.mx"),
|
||||
json={"is_active": False},
|
||||
)
|
||||
assert revoke_res.status_code == 200
|
||||
assert client.get("/auth/me", headers=temp_headers).status_code == 403
|
||||
|
||||
|
||||
def test_48h_followup_queue_and_deliberate_release(client):
|
||||
svc = client.get("/services/atencion-psicologica-individual").json()
|
||||
now = datetime.now(UTC)
|
||||
|
||||
# Booking A: 24 hours from now (within 48h window) -> Should appear in follow-up queue
|
||||
slot_24h = (now + timedelta(hours=24)).replace(microsecond=0).isoformat()
|
||||
b_near = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc["id"],
|
||||
"client_name": "Mariana Vega",
|
||||
"client_phone": "7751234567",
|
||||
"scheduled_at": slot_24h,
|
||||
},
|
||||
).json()
|
||||
assert b_near["needs_payment_followup"] is True
|
||||
|
||||
# Booking B: 96 hours from now (outside 48h window) -> Should NOT appear in 48h queue yet
|
||||
slot_96h = (now + timedelta(hours=96)).replace(microsecond=0).isoformat()
|
||||
b_far = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc["id"],
|
||||
"client_name": "Roberto Solís",
|
||||
"client_phone": "7757654321",
|
||||
"scheduled_at": slot_96h,
|
||||
},
|
||||
).json()
|
||||
assert b_far["needs_payment_followup"] is False
|
||||
|
||||
queue_res = client.get(
|
||||
"/bookings/follow-up-queue?window_hours=48",
|
||||
headers=_admin_headers("asistente@armoniadelser.mx"),
|
||||
)
|
||||
assert queue_res.status_code == 200
|
||||
queue_ids = [b["id"] for b in queue_res.json()]
|
||||
assert b_near["id"] in queue_ids
|
||||
assert b_far["id"] not in queue_ids
|
||||
|
||||
# Assistant follows up via WhatsApp and client prefers to release the slot
|
||||
rel_res = client.post(
|
||||
f"/bookings/{b_near['id']}/release",
|
||||
headers=_admin_headers("asistente@armoniadelser.mx"),
|
||||
json={"reason": "Cliente solicitó liberar espacio tras seguimiento por WhatsApp"},
|
||||
)
|
||||
assert rel_res.status_code == 200
|
||||
released = rel_res.json()
|
||||
assert released["booking_status"] == "RELEASED"
|
||||
assert released["payment_status"] == "NOT_APPLICABLE"
|
||||
assert released["released_by"] == "asistente@armoniadelser.mx"
|
||||
|
||||
# Released booking no longer appears in the follow-up queue
|
||||
queue_after = client.get(
|
||||
"/bookings/follow-up-queue?window_hours=48",
|
||||
headers=_admin_headers("asistente@armoniadelser.mx"),
|
||||
).json()
|
||||
assert b_near["id"] not in [b["id"] for b in queue_after]
|
||||
|
||||
# And another client can now book the exact released slot!
|
||||
rebook_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc["id"],
|
||||
"client_name": "Elena Torres",
|
||||
"client_phone": "7759990000",
|
||||
"scheduled_at": slot_24h,
|
||||
},
|
||||
)
|
||||
assert rebook_res.status_code == 201
|
||||
|
||||
|
||||
def test_delayed_payment_exception_and_post_session_settlement(client):
|
||||
svc = client.get("/services/circulo-cacao-online").json()
|
||||
now = datetime.now(UTC)
|
||||
slot_time = (now + timedelta(hours=120)).replace(microsecond=0).isoformat()
|
||||
|
||||
# 1. Create booking
|
||||
booking = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc["id"],
|
||||
"client_name": "Sofía Luna",
|
||||
"client_phone": "5544332211",
|
||||
"scheduled_at": slot_time,
|
||||
},
|
||||
).json()
|
||||
assert booking["payment_arrangement"] == "PREPAID_DEFAULT"
|
||||
assert booking["payment_status"] == "AWAITING_ACKNOWLEDGMENT"
|
||||
|
||||
# 2. Jasmin authorizes delayed-payment exception
|
||||
exc_res = client.post(
|
||||
f"/bookings/{booking['id']}/authorize-delayed-payment",
|
||||
headers=_admin_headers("jasmin@armoniadelser.mx"),
|
||||
json={"notes": "Paciente frecuente, pagará el viernes en efectivo"},
|
||||
)
|
||||
assert exc_res.status_code == 200
|
||||
exc_booking = exc_res.json()
|
||||
assert exc_booking["payment_arrangement"] == "DELAYED_ALLOWED"
|
||||
# Must NOT silently mark payment as completed!
|
||||
assert exc_booking["payment_status"] == "AWAITING_ACKNOWLEDGMENT"
|
||||
assert exc_booking["exception_authorized_by"] == "jasmin@armoniadelser.mx"
|
||||
assert exc_booking["needs_payment_followup"] is True
|
||||
|
||||
# 3. Session occurs -> marked COMPLETED, payment is STILL AWAITING_ACKNOWLEDGMENT
|
||||
comp_res = client.post(
|
||||
f"/bookings/{booking['id']}/status",
|
||||
headers=_admin_headers("jasmin@armoniadelser.mx"),
|
||||
json={"booking_status": "COMPLETED", "notes": "Sesión realizada"},
|
||||
)
|
||||
assert comp_res.status_code == 200
|
||||
comp_booking = comp_res.json()
|
||||
assert comp_booking["booking_status"] == "COMPLETED"
|
||||
assert comp_booking["payment_status"] == "AWAITING_ACKNOWLEDGMENT"
|
||||
|
||||
# Still traceable in follow-up / receivables queue!
|
||||
queue = client.get("/bookings/follow-up-queue", headers=_admin_headers()).json()
|
||||
assert booking["id"] in [b["id"] for b in queue]
|
||||
|
||||
# 4. Client finally pays -> Admin acknowledges payment
|
||||
ack_res = client.post(
|
||||
"/payments/acknowledge",
|
||||
headers=_admin_headers("jasmin@armoniadelser.mx"),
|
||||
json={
|
||||
"booking_id": booking["id"],
|
||||
"amount_mxn": svc["price_mxn"],
|
||||
"payment_method": "CASH",
|
||||
"notes": "Pago diferido liquidado en efectivo",
|
||||
},
|
||||
)
|
||||
assert ack_res.status_code == 201
|
||||
|
||||
# Now removed from follow-up queue and marked ACKNOWLEDGED
|
||||
queue_after = client.get("/bookings/follow-up-queue", headers=_admin_headers()).json()
|
||||
assert booking["id"] not in [b["id"] for b in queue_after]
|
||||
|
||||
|
||||
def test_calendar_sync_failure_visibility_and_manual_recovery(client, monkeypatch):
|
||||
svc = client.get("/services/meditacion-guiada-sabado").json()
|
||||
|
||||
# Simulate transient Google Calendar failure during booking creation
|
||||
monkeypatch.setattr(settings, "google_service_account_json", "fail-gcal")
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc["id"],
|
||||
"client_name": "Jorge Ríos",
|
||||
"client_phone": "5588776655",
|
||||
"scheduled_at": "2026-11-14T07:00:00Z",
|
||||
},
|
||||
)
|
||||
# Booking creation succeeds in Turso while surfacing FAILED calendar sync status
|
||||
assert b_res.status_code == 201
|
||||
booking = b_res.json()
|
||||
assert booking["gcal_sync_status"] == "FAILED"
|
||||
assert "503" in (booking["gcal_sync_error"] or "")
|
||||
|
||||
# Restore Calendar connectivity and retry sync from admin endpoint
|
||||
monkeypatch.setattr(settings, "google_service_account_json", "mock-gcal")
|
||||
retry_res = client.post(
|
||||
f"/bookings/{booking['id']}/sync-calendar",
|
||||
headers=_admin_headers(),
|
||||
)
|
||||
assert retry_res.status_code == 200
|
||||
recovered = retry_res.json()
|
||||
assert recovered["gcal_sync_status"] == "SYNCED"
|
||||
assert recovered["gcal_sync_error"] is None
|
||||
assert recovered["gcal_event_id"] is not None
|
||||
@@ -0,0 +1,131 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app.core.auth import create_session_token
|
||||
from app.core.config import settings
|
||||
|
||||
DAY = "2027-03-01" # Monday, America/Mexico_City (UTC-6)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def short_business_day(monkeypatch):
|
||||
monkeypatch.setattr(settings, "business_timezone", "America/Mexico_City")
|
||||
monkeypatch.setattr(settings, "availability_open_time", "09:00")
|
||||
monkeypatch.setattr(settings, "availability_close_time", "13:00")
|
||||
monkeypatch.setattr(settings, "availability_slot_step_minutes", 30)
|
||||
monkeypatch.setattr(settings, "availability_working_weekdays", [0, 1, 2, 3, 4])
|
||||
|
||||
|
||||
def _individual_service(client) -> dict:
|
||||
return client.get("/services/atencion-psicologica-individual").json()
|
||||
|
||||
|
||||
def _book(client, service_id: str, scheduled_at: str, phone: str):
|
||||
return client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": service_id,
|
||||
"client_name": "Cliente Disponibilidad",
|
||||
"client_phone": phone,
|
||||
"scheduled_at": scheduled_at,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def _slot_starts(body: dict) -> list[str]:
|
||||
return [slot["start"] for day in body["days"] for slot in day["slots"]]
|
||||
|
||||
|
||||
def test_availability_excludes_slots_colliding_with_reserved_buffer(client, short_business_day):
|
||||
svc = _individual_service(client)
|
||||
assert _book(client, svc["id"], f"{DAY}T10:00:00-06:00", "7750001001").status_code == 201
|
||||
|
||||
res = client.get(
|
||||
"/availability", params={"service_id": svc["id"], "date_from": DAY, "date_to": DAY}
|
||||
)
|
||||
assert res.status_code == 200
|
||||
body = res.json()
|
||||
assert body["service_id"] == svc["id"]
|
||||
assert body["duration_minutes"] == 60
|
||||
assert body["buffer_minutes"] == 15
|
||||
assert body["timezone"] == "America/Mexico_City"
|
||||
assert _slot_starts(body) == [f"{DAY}T11:30:00-06:00", f"{DAY}T12:00:00-06:00"]
|
||||
assert body["days"][0]["slots"][0]["end"] == f"{DAY}T12:30:00-06:00"
|
||||
|
||||
|
||||
def test_released_bookings_free_their_slots(client, short_business_day):
|
||||
day = "2027-03-02"
|
||||
svc = _individual_service(client)
|
||||
booking = _book(client, svc["id"], f"{day}T09:00:00-06:00", "7750001002").json()
|
||||
params = {"service_id": svc["id"], "date_from": day, "date_to": day}
|
||||
assert f"{day}T09:00:00-06:00" not in _slot_starts(
|
||||
client.get("/availability", params=params).json()
|
||||
)
|
||||
|
||||
headers = {"Authorization": f"Bearer {create_session_token('jasmin@armoniadelser.mx')}"}
|
||||
rel = client.post(f"/bookings/{booking['id']}/release", headers=headers, json={})
|
||||
assert rel.status_code == 200
|
||||
assert f"{day}T09:00:00-06:00" in _slot_starts(
|
||||
client.get("/availability", params=params).json()
|
||||
)
|
||||
|
||||
|
||||
def test_every_offered_slot_is_accepted_by_booking_engine(client, short_business_day):
|
||||
day = "2027-03-03"
|
||||
svc = _individual_service(client)
|
||||
params = {"service_id": svc["id"], "date_from": day, "date_to": day}
|
||||
first = _slot_starts(client.get("/availability", params=params).json())[0]
|
||||
assert _book(client, svc["id"], first, "7750001003").status_code == 201
|
||||
|
||||
# Next 30-minute step now collides (60 + 15 buffer) and must disappear
|
||||
after = _slot_starts(client.get("/availability", params=params).json())
|
||||
assert first not in after
|
||||
assert f"{day}T09:30:00-06:00" not in after
|
||||
assert f"{day}T10:00:00-06:00" not in after
|
||||
assert after[0] == f"{day}T10:30:00-06:00"
|
||||
|
||||
|
||||
def test_availability_groups_slots_by_local_day(client, short_business_day):
|
||||
svc = _individual_service(client)
|
||||
res = client.get(
|
||||
"/availability",
|
||||
params={"service_id": svc["id"], "date_from": "2027-03-05", "date_to": "2027-03-08"},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
# Fri 5 and Mon 8 are working days; the weekend is omitted
|
||||
assert [d["date"] for d in res.json()["days"]] == ["2027-03-05", "2027-03-08"]
|
||||
|
||||
|
||||
def test_availability_rejects_group_services(client):
|
||||
svc = client.get("/services/circulo-cacao-presencial").json()
|
||||
res = client.get(
|
||||
"/availability", params={"service_id": svc["id"], "date_from": DAY, "date_to": DAY}
|
||||
)
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
def test_availability_unknown_service_is_404(client):
|
||||
res = client.get(
|
||||
"/availability", params={"service_id": "nope", "date_from": DAY, "date_to": DAY}
|
||||
)
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
def test_availability_rejects_inverted_range(client):
|
||||
svc = _individual_service(client)
|
||||
res = client.get(
|
||||
"/availability",
|
||||
params={"service_id": svc["id"], "date_from": "2027-03-02", "date_to": "2027-03-01"},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
|
||||
|
||||
def test_availability_rejects_range_over_limit(client, monkeypatch):
|
||||
monkeypatch.setattr(settings, "availability_max_range_days", 7)
|
||||
svc = _individual_service(client)
|
||||
res = client.get(
|
||||
"/availability",
|
||||
params={"service_id": svc["id"], "date_from": "2027-03-01", "date_to": "2027-03-08"},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
@@ -0,0 +1,315 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.auth import create_session_token
|
||||
|
||||
|
||||
def _admin_headers(email: str = "jasmin@armoniadelser.mx") -> dict[str, str]:
|
||||
token = create_session_token(email)
|
||||
return {"Authorization": f"Bearer {token}"}
|
||||
|
||||
|
||||
def test_reschedule_reserved_booking_success(client):
|
||||
headers = _admin_headers()
|
||||
svc_res = client.get("/services/atencion-psicologica-individual")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
# 1. Create booking
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Gabriel Sosa",
|
||||
"client_phone": "+52 55 1234 9999",
|
||||
"scheduled_at": "2026-11-10T10:00:00Z",
|
||||
},
|
||||
)
|
||||
assert b_res.status_code == 201
|
||||
booking = b_res.json()
|
||||
booking_id = booking["id"]
|
||||
|
||||
# 2. Reschedule to new slot
|
||||
new_time = "2026-11-12T16:00:00Z"
|
||||
resched_res = client.post(
|
||||
f"/bookings/{booking_id}/reschedule",
|
||||
headers=headers,
|
||||
json={
|
||||
"new_scheduled_at": new_time,
|
||||
"notes": "Cliente solicitó cambio de fecha por viaje laboral.",
|
||||
},
|
||||
)
|
||||
assert resched_res.status_code == 200
|
||||
resched_data = resched_res.json()
|
||||
assert resched_data["scheduled_at"] == new_time
|
||||
assert resched_data["booking_status"] == "RESERVED"
|
||||
assert "2026-11-12" in resched_data["whatsapp_redirect_url"]
|
||||
|
||||
|
||||
def test_reschedule_collision_with_buffer_conflict(client):
|
||||
headers = _admin_headers()
|
||||
svc_res = client.get("/services/atencion-psicologica-individual")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
# Booking 1 at 10:00 (1h duration + 15m buffer -> blocked until 11:15)
|
||||
b1_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Hugo Luna",
|
||||
"client_phone": "+52 55 8899 0011",
|
||||
"scheduled_at": "2026-11-15T10:00:00Z",
|
||||
},
|
||||
)
|
||||
assert b1_res.status_code == 201
|
||||
|
||||
# Booking 2 at 14:00
|
||||
b2_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Ignacio Vega",
|
||||
"client_phone": "+52 55 8899 0022",
|
||||
"scheduled_at": "2026-11-15T14:00:00Z",
|
||||
},
|
||||
)
|
||||
assert b2_res.status_code == 201
|
||||
b2_id = b2_res.json()["id"]
|
||||
|
||||
# Attempt rescheduling B2 into B1's buffer (11:05) -> 409 Conflict
|
||||
collision_res = client.post(
|
||||
f"/bookings/{b2_id}/reschedule",
|
||||
headers=headers,
|
||||
json={"new_scheduled_at": "2026-11-15T11:05:00Z"},
|
||||
)
|
||||
assert collision_res.status_code == 409
|
||||
assert "colchón" in collision_res.json()["detail"].lower()
|
||||
|
||||
# Reschedule B2 to exact end of buffer (11:15) -> 200 Success
|
||||
valid_res = client.post(
|
||||
f"/bookings/{b2_id}/reschedule",
|
||||
headers=headers,
|
||||
json={"new_scheduled_at": "2026-11-15T11:15:00Z"},
|
||||
)
|
||||
assert valid_res.status_code == 200
|
||||
assert valid_res.json()["scheduled_at"] == "2026-11-15T11:15:00Z"
|
||||
|
||||
|
||||
def test_reschedule_non_reserved_booking_fails(client):
|
||||
headers = _admin_headers()
|
||||
svc_res = client.get("/services/atencion-psicologica-individual")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Julio Cortázar",
|
||||
"client_phone": "+52 55 4444 5555",
|
||||
"scheduled_at": "2026-11-18T10:00:00Z",
|
||||
},
|
||||
)
|
||||
booking_id = b_res.json()["id"]
|
||||
|
||||
# Release booking slot
|
||||
client.post(
|
||||
f"/bookings/{booking_id}/release",
|
||||
headers=headers,
|
||||
json={"reason": "Cliente canceló"},
|
||||
)
|
||||
|
||||
# Attempt to reschedule released booking -> 400 Bad Request
|
||||
resched_res = client.post(
|
||||
f"/bookings/{booking_id}/reschedule",
|
||||
headers=headers,
|
||||
json={"new_scheduled_at": "2026-11-19T10:00:00Z"},
|
||||
)
|
||||
assert resched_res.status_code == 400
|
||||
assert "only reserved" in resched_res.json()["detail"].lower()
|
||||
|
||||
|
||||
def test_reschedule_not_found(client):
|
||||
res = client.post(
|
||||
"/bookings/non-existent-id/reschedule",
|
||||
headers=_admin_headers(),
|
||||
json={"new_scheduled_at": "2026-11-19T10:00:00Z"},
|
||||
)
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
def test_complete_reserved_booking_success(client):
|
||||
headers = _admin_headers()
|
||||
svc_res = client.get("/services/circulo-cacao-presencial")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
# 1. Create booking
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Karla Morales",
|
||||
"client_phone": "+52 55 9988 1122",
|
||||
"scheduled_at": "2026-11-22T17:00:00Z",
|
||||
},
|
||||
)
|
||||
assert b_res.status_code == 201
|
||||
booking_id = b_res.json()["id"]
|
||||
|
||||
# 2. Mark complete
|
||||
complete_res = client.post(
|
||||
f"/bookings/{booking_id}/complete",
|
||||
headers=headers,
|
||||
json={"notes": "Sesión completada exitosamente."},
|
||||
)
|
||||
assert complete_res.status_code == 200
|
||||
complete_data = complete_res.json()
|
||||
assert complete_data["booking_status"] == "COMPLETED"
|
||||
|
||||
|
||||
def test_complete_non_reserved_booking_fails(client):
|
||||
headers = _admin_headers()
|
||||
svc_res = client.get("/services/circulo-cacao-presencial")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Lorena Gil",
|
||||
"client_phone": "+52 55 1199 8877",
|
||||
"scheduled_at": "2026-11-23T17:00:00Z",
|
||||
},
|
||||
)
|
||||
booking_id = b_res.json()["id"]
|
||||
|
||||
# Cancel booking
|
||||
client.post(
|
||||
f"/bookings/{booking_id}/status",
|
||||
headers=headers,
|
||||
json={"booking_status": "CANCELLED"},
|
||||
)
|
||||
|
||||
# Attempt to complete cancelled booking -> 400 Bad Request
|
||||
complete_res = client.post(f"/bookings/{booking_id}/complete", headers=headers)
|
||||
assert complete_res.status_code == 400
|
||||
assert "only reserved" in complete_res.json()["detail"].lower()
|
||||
|
||||
|
||||
def test_complete_booking_with_package_records_completion(client):
|
||||
headers = _admin_headers()
|
||||
svc_res = client.get("/services/atencion-psicologica-individual")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
# 1. Create client
|
||||
c_res = client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Mariana Garza", "phone_whatsapp": "+52 55 3322 1100"},
|
||||
)
|
||||
client_id = c_res.json()["id"]
|
||||
|
||||
# 2. Create package (5 sessions, 0 completed)
|
||||
pkg_res = client.post(
|
||||
"/packages",
|
||||
headers=headers,
|
||||
json={
|
||||
"client_id": client_id,
|
||||
"service_id": svc_id,
|
||||
"total_sessions": 5,
|
||||
"completed_sessions": 0,
|
||||
"financial_status": "PAID",
|
||||
},
|
||||
)
|
||||
pkg_id = pkg_res.json()["id"]
|
||||
|
||||
# 3. Create booking redeemed under package (counter becomes 1)
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Mariana Garza",
|
||||
"client_phone": "+52 55 3322 1100",
|
||||
"scheduled_at": "2026-11-28T10:00:00Z",
|
||||
"package_id": pkg_id,
|
||||
},
|
||||
)
|
||||
assert b_res.status_code == 201
|
||||
booking_id = b_res.json()["id"]
|
||||
|
||||
# Verify package has 1 completed session
|
||||
pkg_check = client.get(f"/packages/{pkg_id}", headers=headers).json()
|
||||
assert pkg_check["completed_sessions"] == 1
|
||||
assert pkg_check["remaining_sessions"] == 4
|
||||
|
||||
# 4. Complete consultation
|
||||
comp_res = client.post(
|
||||
f"/bookings/{booking_id}/complete",
|
||||
headers=headers,
|
||||
json={"notes": "Primera sesión del paquete completada."},
|
||||
)
|
||||
assert comp_res.status_code == 200
|
||||
assert comp_res.json()["booking_status"] == "COMPLETED"
|
||||
assert comp_res.json()["package_id"] == pkg_id
|
||||
|
||||
# Package counter remains 1 (not double-counted)
|
||||
pkg_after = client.get(f"/packages/{pkg_id}", headers=headers).json()
|
||||
assert pkg_after["completed_sessions"] == 1
|
||||
assert pkg_after["remaining_sessions"] == 4
|
||||
|
||||
|
||||
def test_complete_booking_links_package_and_advances_counter(client):
|
||||
headers = _admin_headers()
|
||||
svc_res = client.get("/services/atencion-psicologica-individual")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
# 1. Create client
|
||||
c_res = client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Nicolás Bravo", "phone_whatsapp": "+52 55 6677 8899"},
|
||||
)
|
||||
client_id = c_res.json()["id"]
|
||||
|
||||
# 2. Create package (5 sessions, 0 completed)
|
||||
pkg_res = client.post(
|
||||
"/packages",
|
||||
headers=headers,
|
||||
json={
|
||||
"client_id": client_id,
|
||||
"service_id": svc_id,
|
||||
"total_sessions": 5,
|
||||
"completed_sessions": 0,
|
||||
"financial_status": "PAID",
|
||||
},
|
||||
)
|
||||
pkg_id = pkg_res.json()["id"]
|
||||
|
||||
# 3. Create regular booking without package (PREPAID_DEFAULT)
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Nicolás Bravo",
|
||||
"client_phone": "+52 55 6677 8899",
|
||||
"scheduled_at": "2026-11-29T10:00:00Z",
|
||||
},
|
||||
)
|
||||
assert b_res.status_code == 201
|
||||
booking = b_res.json()
|
||||
assert booking["payment_arrangement"] == "PREPAID_DEFAULT"
|
||||
assert booking["package_id"] is None
|
||||
|
||||
# 4. At consultation end, client redeems package session
|
||||
comp_res = client.post(
|
||||
f"/bookings/{booking['id']}/complete",
|
||||
headers=headers,
|
||||
json={"package_id": pkg_id, "notes": "Pago aplicado a paquete."},
|
||||
)
|
||||
assert comp_res.status_code == 200
|
||||
comp_data = comp_res.json()
|
||||
assert comp_data["booking_status"] == "COMPLETED"
|
||||
assert comp_data["package_id"] == pkg_id
|
||||
assert comp_data["payment_arrangement"] == "PACKAGE_REDEEMED"
|
||||
|
||||
# Package counter was advanced from 0 to 1
|
||||
pkg_after = client.get(f"/packages/{pkg_id}", headers=headers).json()
|
||||
assert pkg_after["completed_sessions"] == 1
|
||||
assert pkg_after["remaining_sessions"] == 4
|
||||
+37
-13
@@ -1,7 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.auth import create_session_token
|
||||
|
||||
def test_booking_and_payment_flow(client):
|
||||
|
||||
def _admin_headers(email: str = "jasmin@armoniadelser.mx") -> dict[str, str]:
|
||||
token = create_session_token(email)
|
||||
return {"Authorization": f"Bearer {token}"}
|
||||
|
||||
|
||||
def test_booking_and_payment_acknowledgment_flow(client):
|
||||
# 1. Fetch a service
|
||||
svc_res = client.get("/services/circulo-cacao-presencial")
|
||||
assert svc_res.status_code == 200
|
||||
@@ -20,32 +27,46 @@ def test_booking_and_payment_flow(client):
|
||||
assert b_res.status_code == 201
|
||||
booking = b_res.json()
|
||||
|
||||
assert booking["status"] == "PENDING_PAYMENT"
|
||||
# Booking status and payment status are separated
|
||||
assert booking["booking_status"] == "RESERVED"
|
||||
assert booking["payment_arrangement"] == "PREPAID_DEFAULT"
|
||||
assert booking["payment_status"] == "AWAITING_ACKNOWLEDGMENT"
|
||||
assert booking["booking_code"].startswith("ADS-")
|
||||
assert booking["amount_mxn"] == 350
|
||||
assert "wa.me" in booking["whatsapp_redirect_url"]
|
||||
assert "ADS-" in booking["whatsapp_redirect_url"]
|
||||
assert "wa.me" in booking["whatsapp_followup_url"]
|
||||
|
||||
# 3. Verify payment (Admin action)
|
||||
# 3. Acknowledge payment (Admin action)
|
||||
pay_payload = {
|
||||
"booking_id": booking["id"],
|
||||
"amount_mxn": 350,
|
||||
"payment_method": "SPEI",
|
||||
"notes": "Transferencia recibida BBVA",
|
||||
}
|
||||
p_res = client.post("/payments/verify", json=pay_payload)
|
||||
p_res = client.post(
|
||||
"/payments/acknowledge",
|
||||
json=pay_payload,
|
||||
headers=_admin_headers("asistente@armoniadelser.mx"),
|
||||
)
|
||||
assert p_res.status_code == 201
|
||||
payment = p_res.json()
|
||||
assert payment["status"] == "VERIFIED"
|
||||
assert payment["status"] == "ACKNOWLEDGED"
|
||||
assert payment["booking_id"] == booking["id"]
|
||||
assert payment["acknowledged_by"] == "asistente@armoniadelser.mx"
|
||||
|
||||
# 4. Confirm booking status updated
|
||||
list_res = client.get("/bookings?status=CONFIRMED")
|
||||
# 4. Confirm booking payment_status updated while booking_status remains RESERVED
|
||||
list_res = client.get(
|
||||
"/bookings?payment_status=ACKNOWLEDGED",
|
||||
headers=_admin_headers(),
|
||||
)
|
||||
assert list_res.status_code == 200
|
||||
confirmed_bookings = list_res.json()
|
||||
matching = [b for b in confirmed_bookings if b["id"] == booking["id"]]
|
||||
ack_bookings = list_res.json()
|
||||
matching = [b for b in ack_bookings if b["id"] == booking["id"]]
|
||||
assert len(matching) == 1
|
||||
assert matching[0]["status"] == "CONFIRMED"
|
||||
assert matching[0]["booking_status"] == "RESERVED"
|
||||
assert matching[0]["payment_status"] == "ACKNOWLEDGED"
|
||||
assert matching[0]["acknowledged_by"] == "asistente@armoniadelser.mx"
|
||||
|
||||
|
||||
def test_one_on_one_buffer_collision(client):
|
||||
@@ -108,9 +129,10 @@ def test_package_creation_and_redemption(client):
|
||||
).json()
|
||||
client_id = initial_b["client_id"]
|
||||
|
||||
# Create a 10-session package with 7 already completed
|
||||
# Create a 10-session package with 7 already completed (Admin action)
|
||||
pkg_res = client.post(
|
||||
"/packages",
|
||||
headers=_admin_headers(),
|
||||
json={
|
||||
"client_id": client_id,
|
||||
"service_id": svc["id"],
|
||||
@@ -138,12 +160,14 @@ def test_package_creation_and_redemption(client):
|
||||
)
|
||||
assert redeem_res.status_code == 201
|
||||
redeemed_booking = redeem_res.json()
|
||||
assert redeemed_booking["status"] == "CONFIRMED"
|
||||
assert redeemed_booking["booking_status"] == "RESERVED"
|
||||
assert redeemed_booking["payment_arrangement"] == "PACKAGE_REDEEMED"
|
||||
assert redeemed_booking["payment_status"] == "NOT_APPLICABLE"
|
||||
assert redeemed_booking["amount_mxn"] == 0
|
||||
assert "8%20de%2010" in redeemed_booking["whatsapp_redirect_url"]
|
||||
|
||||
# Verify package counter incremented to 8 completed / 2 remaining
|
||||
pkg_get = client.get(f"/packages/{pkg['id']}")
|
||||
pkg_get = client.get(f"/packages/{pkg['id']}", headers=_admin_headers())
|
||||
assert pkg_get.status_code == 200
|
||||
assert pkg_get.json()["completed_sessions"] == 8
|
||||
assert pkg_get.json()["remaining_sessions"] == 2
|
||||
@@ -0,0 +1,269 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.auth import create_session_token
|
||||
|
||||
|
||||
def _admin_headers(email: str = "jasmin@armoniadelser.mx") -> dict[str, str]:
|
||||
token = create_session_token(email)
|
||||
return {"Authorization": f"Bearer {token}"}
|
||||
|
||||
|
||||
def test_create_client_success(client):
|
||||
payload = {
|
||||
"full_name": "Valeria Domínguez",
|
||||
"phone_whatsapp": "+52 55 9876 5432",
|
||||
"email": "valeria@example.com",
|
||||
"notes": "Prefiere citas por la tarde.",
|
||||
}
|
||||
res = client.post("/clients", json=payload, headers=_admin_headers())
|
||||
assert res.status_code == 201
|
||||
data = res.json()
|
||||
assert data["full_name"] == "Valeria Domínguez"
|
||||
assert data["phone_whatsapp"] == "+52 55 9876 5432"
|
||||
assert data["email"] == "valeria@example.com"
|
||||
assert data["notes"] == "Prefiere citas por la tarde."
|
||||
assert "id" in data
|
||||
assert "created_at" in data
|
||||
|
||||
|
||||
def test_create_client_phone_validation(client):
|
||||
payload = {
|
||||
"full_name": "Invalid Phone User",
|
||||
"phone_whatsapp": "invalid-number",
|
||||
}
|
||||
res = client.post("/clients", json=payload, headers=_admin_headers())
|
||||
assert res.status_code == 422
|
||||
|
||||
|
||||
def test_create_client_duplicate_detection(client):
|
||||
payload = {
|
||||
"full_name": "Roberto Gómez",
|
||||
"phone_whatsapp": "+52 55 4433 2211",
|
||||
"email": "roberto@example.com",
|
||||
}
|
||||
first_res = client.post("/clients", json=payload, headers=_admin_headers())
|
||||
assert first_res.status_code == 201
|
||||
|
||||
# Attempt registering same phone
|
||||
dup_res = client.post("/clients", json=payload, headers=_admin_headers())
|
||||
assert dup_res.status_code == 409
|
||||
assert "already exists" in dup_res.json()["detail"]
|
||||
|
||||
|
||||
def test_create_client_requires_admin(client):
|
||||
payload = {
|
||||
"full_name": "Unauthenticated Client",
|
||||
"phone_whatsapp": "+52 55 1122 3344",
|
||||
}
|
||||
res = client.post("/clients", json=payload)
|
||||
assert res.status_code == 401
|
||||
|
||||
|
||||
def test_list_and_search_clients(client):
|
||||
headers = _admin_headers()
|
||||
|
||||
# Seed 3 distinct clients
|
||||
client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Adriana Morales", "phone_whatsapp": "+52 55 7777 0001"},
|
||||
)
|
||||
client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Adrián Castillo", "phone_whatsapp": "+52 55 7777 0002"},
|
||||
)
|
||||
client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Beatriz Solís", "phone_whatsapp": "+52 55 8888 0003"},
|
||||
)
|
||||
|
||||
# Search by partial name (case-insensitive)
|
||||
search_res = client.get("/clients?search=adri", headers=headers)
|
||||
assert search_res.status_code == 200
|
||||
results = search_res.json()
|
||||
names = [c["full_name"] for c in results]
|
||||
assert "Adriana Morales" in names
|
||||
assert "Adrián Castillo" in names
|
||||
assert "Beatriz Solís" not in names
|
||||
|
||||
# Search by partial phone
|
||||
phone_res = client.get("/clients?search=8888 0003", headers=headers)
|
||||
assert phone_res.status_code == 200
|
||||
phone_results = phone_res.json()
|
||||
assert len(phone_results) == 1
|
||||
assert phone_results[0]["full_name"] == "Beatriz Solís"
|
||||
|
||||
# Pagination: limit and offset
|
||||
page_res = client.get("/clients?limit=2&offset=0", headers=headers)
|
||||
assert page_res.status_code == 200
|
||||
assert len(page_res.json()) <= 2
|
||||
|
||||
|
||||
def test_get_client_360_profile(client):
|
||||
headers = _admin_headers()
|
||||
|
||||
# 1. Create client
|
||||
c_res = client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={
|
||||
"full_name": "Camila Ochoa",
|
||||
"phone_whatsapp": "+52 55 6655 4433",
|
||||
"notes": "Seguimiento quincenal",
|
||||
},
|
||||
)
|
||||
assert c_res.status_code == 201
|
||||
c_data = c_res.json()
|
||||
client_id = c_data["id"]
|
||||
|
||||
# 2. Fetch service
|
||||
svc_res = client.get("/services/atencion-psicologica-individual")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
# 3. Create active package (5 total, 1 completed -> active)
|
||||
active_pkg = client.post(
|
||||
"/packages",
|
||||
headers=headers,
|
||||
json={
|
||||
"client_id": client_id,
|
||||
"service_id": svc_id,
|
||||
"total_sessions": 5,
|
||||
"completed_sessions": 1,
|
||||
"financial_status": "PAID",
|
||||
},
|
||||
).json()
|
||||
|
||||
# 4. Create exhausted package (3 total, 3 completed -> inactive)
|
||||
client.post(
|
||||
"/packages",
|
||||
headers=headers,
|
||||
json={
|
||||
"client_id": client_id,
|
||||
"service_id": svc_id,
|
||||
"total_sessions": 3,
|
||||
"completed_sessions": 3,
|
||||
"financial_status": "PAID",
|
||||
},
|
||||
)
|
||||
|
||||
# 5. Create a booking for this client
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Camila Ochoa",
|
||||
"client_phone": "+52 55 6655 4433",
|
||||
"scheduled_at": "2026-11-20T10:00:00Z",
|
||||
},
|
||||
)
|
||||
assert b_res.status_code == 201
|
||||
|
||||
# 6. Fetch Client 360 profile
|
||||
profile_res = client.get(f"/clients/{client_id}", headers=headers)
|
||||
assert profile_res.status_code == 200
|
||||
profile = profile_res.json()
|
||||
|
||||
assert profile["id"] == client_id
|
||||
assert profile["full_name"] == "Camila Ochoa"
|
||||
assert profile["notes"] == "Seguimiento quincenal"
|
||||
|
||||
# Active packages should only include package with remaining sessions
|
||||
assert len(profile["active_packages"]) == 1
|
||||
assert profile["active_packages"][0]["id"] == active_pkg["id"]
|
||||
assert profile["active_packages"][0]["remaining_sessions"] == 4
|
||||
|
||||
# Booking history should contain the booking
|
||||
assert len(profile["booking_history"]) >= 1
|
||||
assert profile["booking_history"][0]["client_id"] == client_id
|
||||
|
||||
|
||||
def test_get_client_not_found(client):
|
||||
res = client.get("/clients/non-existent-id", headers=_admin_headers())
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
def test_patch_client_success(client):
|
||||
headers = _admin_headers()
|
||||
created = client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Daniela Ruiz", "phone_whatsapp": "+52 55 9900 1122"},
|
||||
).json()
|
||||
|
||||
patch_payload = {
|
||||
"full_name": "Daniela Ruiz de Chávez",
|
||||
"notes": "Cambio de apellido civil.",
|
||||
"email": "daniela@example.com",
|
||||
}
|
||||
patch_res = client.patch(f"/clients/{created['id']}", headers=headers, json=patch_payload)
|
||||
assert patch_res.status_code == 200
|
||||
updated = patch_res.json()
|
||||
assert updated["full_name"] == "Daniela Ruiz de Chávez"
|
||||
assert updated["notes"] == "Cambio de apellido civil."
|
||||
assert updated["email"] == "daniela@example.com"
|
||||
assert updated["phone_whatsapp"] == "+52 55 9900 1122"
|
||||
|
||||
|
||||
def test_patch_client_duplicate_phone(client):
|
||||
headers = _admin_headers()
|
||||
client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Usuario Uno", "phone_whatsapp": "+52 55 1212 1212"},
|
||||
)
|
||||
c2 = client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Usuario Dos", "phone_whatsapp": "+52 55 3434 3434"},
|
||||
).json()
|
||||
|
||||
# Attempt to change c2 phone to c1 phone -> 409 Conflict
|
||||
patch_res = client.patch(
|
||||
f"/clients/{c2['id']}",
|
||||
headers=headers,
|
||||
json={"phone_whatsapp": "+52 55 1212 1212"},
|
||||
)
|
||||
assert patch_res.status_code == 409
|
||||
|
||||
|
||||
def test_delete_client_safe_integrity_check(client):
|
||||
headers = _admin_headers()
|
||||
|
||||
# Create client with booking
|
||||
svc_res = client.get("/services/atencion-psicologica-individual")
|
||||
svc_id = svc_res.json()["id"]
|
||||
|
||||
b_res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": svc_id,
|
||||
"client_name": "Enrique Peña",
|
||||
"client_phone": "+52 55 7766 5544",
|
||||
"scheduled_at": "2026-11-25T12:00:00Z",
|
||||
},
|
||||
)
|
||||
client_id = b_res.json()["client_id"]
|
||||
|
||||
# Attempt to delete client with active booking -> 409 Conflict
|
||||
del_res = client.delete(f"/clients/{client_id}", headers=headers)
|
||||
assert del_res.status_code == 409
|
||||
assert "associated" in del_res.json()["detail"].lower()
|
||||
|
||||
|
||||
def test_delete_client_without_dependencies(client):
|
||||
headers = _admin_headers()
|
||||
c = client.post(
|
||||
"/clients",
|
||||
headers=headers,
|
||||
json={"full_name": "Fernando Morales", "phone_whatsapp": "+52 55 9988 7766"},
|
||||
).json()
|
||||
client_id = c["id"]
|
||||
|
||||
del_res = client.delete(f"/clients/{client_id}", headers=headers)
|
||||
assert del_res.status_code == 204
|
||||
|
||||
# Confirm it cannot be found
|
||||
get_res = client.get(f"/clients/{client_id}", headers=headers)
|
||||
assert get_res.status_code == 404
|
||||
@@ -0,0 +1,318 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
from sqlmodel import Session, select
|
||||
|
||||
from app.core.auth import create_session_token
|
||||
from app.core.config import AuthProvider, settings
|
||||
from app.db.database import get_engine
|
||||
from app.models.admin import AdminAuditLog
|
||||
from app.models.payment import Payment
|
||||
from app.models.service import Service, ServiceModalityEnum, ServiceTypeEnum
|
||||
|
||||
|
||||
def _admin(email: str = "asistente@armoniadelser.mx") -> dict[str, str]:
|
||||
return {"Authorization": f"Bearer {create_session_token(email)}"}
|
||||
|
||||
|
||||
def _book(client, service_id: str, scheduled_at: str, phone: str, name: str = "Asistente Cacao"):
|
||||
res = client.post(
|
||||
"/bookings",
|
||||
json={
|
||||
"service_id": service_id,
|
||||
"client_name": name,
|
||||
"client_phone": phone,
|
||||
"scheduled_at": scheduled_at,
|
||||
},
|
||||
)
|
||||
assert res.status_code == 201, res.text
|
||||
return res.json()
|
||||
|
||||
|
||||
def _roster(client, day: str, service_id: str | None = None) -> list[dict]:
|
||||
params = {"date_from": day, "date_to": day}
|
||||
if service_id:
|
||||
params["service_id"] = service_id
|
||||
res = client.get("/rosters", params=params, headers=_admin())
|
||||
assert res.status_code == 200, res.text
|
||||
return res.json()
|
||||
|
||||
|
||||
def _queue_ids(client) -> list[str]:
|
||||
return [b["id"] for b in client.get("/bookings/follow-up-queue", headers=_admin()).json()]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cacao(client) -> dict:
|
||||
return client.get("/services/circulo-cacao-presencial").json()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tiny_workshop() -> dict:
|
||||
"""A GROUP service with capacity 1, inserted through the real SQLModel engine."""
|
||||
service_id = str(uuid.uuid4())
|
||||
with Session(get_engine()) as session:
|
||||
session.add(
|
||||
Service(
|
||||
id=service_id,
|
||||
slug=f"taller-mini-{service_id[:8]}",
|
||||
name="Taller Mini",
|
||||
service_type=ServiceTypeEnum.GROUP,
|
||||
modality=ServiceModalityEnum.PRESENCIAL,
|
||||
price_mxn=50,
|
||||
max_capacity=1,
|
||||
duration_minutes=60,
|
||||
buffer_minutes=0,
|
||||
)
|
||||
)
|
||||
session.commit()
|
||||
return {"id": service_id, "price_mxn": 50}
|
||||
|
||||
|
||||
# --- GET /rosters ---------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_rosters_require_admin(client):
|
||||
assert client.get("/rosters").status_code == 401
|
||||
|
||||
|
||||
def test_roster_groups_attendees_by_session_instant_across_iso_formats(client, cacao):
|
||||
# Same instant written two ways must land in ONE session
|
||||
a = _book(client, cacao["id"], "2027-04-06T18:00:00Z", "5510000001", "Ana")
|
||||
b = _book(client, cacao["id"], "2027-04-06T12:00:00-06:00", "5510000002", "Beto")
|
||||
released = _book(client, cacao["id"], "2027-04-06T18:00:00+00:00", "5510000003", "Ceci")
|
||||
client.post(f"/bookings/{released['id']}/release", headers=_admin(), json={})
|
||||
|
||||
sessions = _roster(client, "2027-04-06", cacao["id"])
|
||||
assert len(sessions) == 1
|
||||
session = sessions[0]
|
||||
assert session["service_name"] == cacao["name"]
|
||||
assert session["max_capacity"] == cacao["max_capacity"]
|
||||
assert session["occupied_count"] == 2
|
||||
assert session["attended_count"] == 0
|
||||
ids = {att["booking_id"] for att in session["attendees"]}
|
||||
assert ids == {a["id"], b["id"]} # released booking is not on the roster
|
||||
assert all(att["attended"] is False for att in session["attendees"])
|
||||
|
||||
|
||||
def test_roster_excludes_individual_services(client):
|
||||
svc = client.get("/services/atencion-psicologica-individual").json()
|
||||
_book(client, svc["id"], "2027-04-07T16:00:00Z", "5510000004")
|
||||
assert _roster(client, "2027-04-07") == []
|
||||
|
||||
|
||||
# --- POST /rosters/quick-checkin: existing bookings ------------------------------------
|
||||
|
||||
|
||||
def test_checkin_with_cash_marks_attended_and_acknowledges_payment(client, cacao):
|
||||
booking = _book(client, cacao["id"], "2027-04-13T18:00:00Z", "5510000010")
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=_admin(),
|
||||
json={"booking_id": booking["id"], "paid_cash": True},
|
||||
)
|
||||
assert res.status_code == 200, res.text
|
||||
body = res.json()
|
||||
assert body["walk_in"] is False
|
||||
assert body["attendee"]["attended"] is True
|
||||
assert body["attendee"]["booking_status"] == "COMPLETED"
|
||||
assert body["attendee"]["payment_status"] == "ACKNOWLEDGED"
|
||||
assert body["payment_id"] is not None
|
||||
|
||||
with Session(get_engine()) as s:
|
||||
payment = s.get(Payment, body["payment_id"])
|
||||
assert payment is not None
|
||||
assert payment.payment_method == "CASH"
|
||||
assert payment.amount_mxn == cacao["price_mxn"]
|
||||
assert payment.acknowledged_by == "asistente@armoniadelser.mx"
|
||||
audit = s.exec(select(AdminAuditLog).where(AdminAuditLog.entity_id == booking["id"])).all()
|
||||
assert [a.action_type for a in audit] == ["ROSTER_CHECKIN"]
|
||||
|
||||
assert booking["id"] not in _queue_ids(client)
|
||||
assert _roster(client, "2027-04-13", cacao["id"])[0]["attended_count"] == 1
|
||||
|
||||
|
||||
def test_checkin_twice_is_conflict(client, cacao):
|
||||
booking = _book(client, cacao["id"], "2027-04-14T18:00:00Z", "5510000011")
|
||||
payload = {"booking_id": booking["id"]}
|
||||
assert client.post("/rosters/quick-checkin", headers=_admin(), json=payload).status_code == 200
|
||||
assert client.post("/rosters/quick-checkin", headers=_admin(), json=payload).status_code == 409
|
||||
|
||||
|
||||
def test_unpaid_checkin_becomes_traceable_delayed_payment(client, cacao):
|
||||
booking = _book(client, cacao["id"], "2027-04-15T18:00:00Z", "5510000012")
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin", headers=_admin(), json={"booking_id": booking["id"]}
|
||||
)
|
||||
assert res.status_code == 200
|
||||
attendee = res.json()["attendee"]
|
||||
assert attendee["booking_status"] == "COMPLETED"
|
||||
assert attendee["payment_arrangement"] == "DELAYED_ALLOWED"
|
||||
assert attendee["payment_status"] == "AWAITING_ACKNOWLEDGMENT"
|
||||
assert res.json()["payment_id"] is None
|
||||
# Attending without paying must never silently disappear from the receivables queue
|
||||
assert booking["id"] in _queue_ids(client)
|
||||
|
||||
|
||||
def test_checkin_corrects_a_mistaken_no_show(client, cacao):
|
||||
booking = _book(client, cacao["id"], "2027-04-16T18:00:00Z", "5510000013")
|
||||
client.post(
|
||||
f"/bookings/{booking['id']}/status",
|
||||
headers=_admin(),
|
||||
json={"booking_status": "NO_SHOW"},
|
||||
)
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=_admin(),
|
||||
json={"booking_id": booking["id"], "paid_cash": True},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
assert res.json()["attendee"]["attended"] is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("status_path", ["release", "status"])
|
||||
def test_checkin_rejects_released_or_cancelled_bookings(client, cacao, status_path):
|
||||
booking = _book(client, cacao["id"], "2027-04-17T18:00:00Z", f"55100000{20 + len(status_path)}")
|
||||
if status_path == "release":
|
||||
client.post(f"/bookings/{booking['id']}/release", headers=_admin(), json={})
|
||||
else:
|
||||
client.post(
|
||||
f"/bookings/{booking['id']}/status",
|
||||
headers=_admin(),
|
||||
json={"booking_status": "CANCELLED"},
|
||||
)
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin", headers=_admin(), json={"booking_id": booking["id"]}
|
||||
)
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
def test_checkin_rejects_individual_bookings(client):
|
||||
svc = client.get("/services/atencion-psicologica-individual").json()
|
||||
booking = _book(client, svc["id"], "2027-04-19T16:00:00Z", "5510000030")
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin", headers=_admin(), json={"booking_id": booking["id"]}
|
||||
)
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
def test_checkin_unknown_booking_is_404(client):
|
||||
res = client.post("/rosters/quick-checkin", headers=_admin(), json={"booking_id": "nope"})
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
# --- POST /rosters/quick-checkin: walk-ins ---------------------------------------------
|
||||
|
||||
|
||||
def _walk_in(service_id: str, scheduled_at: str, phone: str, **extra) -> dict:
|
||||
return {
|
||||
"service_id": service_id,
|
||||
"scheduled_at": scheduled_at,
|
||||
"client_name": "Llegó sin reservar",
|
||||
"client_phone": phone,
|
||||
**extra,
|
||||
}
|
||||
|
||||
|
||||
def test_paid_walk_in_creates_attended_acknowledged_booking(client, cacao):
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=_admin(),
|
||||
json=_walk_in(cacao["id"], "2027-04-20T18:00:00Z", "5510000040", paid_cash=True),
|
||||
)
|
||||
assert res.status_code == 200, res.text
|
||||
body = res.json()
|
||||
assert body["walk_in"] is True
|
||||
assert body["attendee"]["booking_status"] == "COMPLETED"
|
||||
assert body["attendee"]["payment_status"] == "ACKNOWLEDGED"
|
||||
assert body["attendee"]["booking_code"].startswith("ADS-")
|
||||
assert body["payment_id"] is not None
|
||||
|
||||
session = _roster(client, "2027-04-20", cacao["id"])[0]
|
||||
assert [a["booking_id"] for a in session["attendees"]] == [body["attendee"]["booking_id"]]
|
||||
assert session["attended_count"] == 1
|
||||
|
||||
|
||||
def test_unpaid_walk_in_is_visible_in_followup_queue(client, cacao):
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=_admin(),
|
||||
json=_walk_in(cacao["id"], "2027-04-21T18:00:00Z", "5510000041"),
|
||||
)
|
||||
assert res.status_code == 200
|
||||
attendee = res.json()["attendee"]
|
||||
assert attendee["payment_arrangement"] == "DELAYED_ALLOWED"
|
||||
assert attendee["booking_id"] in _queue_ids(client)
|
||||
|
||||
|
||||
def test_walk_in_reuses_existing_client_by_phone(client, cacao):
|
||||
existing = _book(client, cacao["id"], "2027-04-22T18:00:00Z", "5510000042")
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=_admin(),
|
||||
json=_walk_in(cacao["id"], "2027-04-29T18:00:00Z", "5510000042"),
|
||||
)
|
||||
assert res.json()["attendee"]["client_id"] == existing["client_id"]
|
||||
|
||||
|
||||
def test_walk_in_respects_capacity(client, tiny_workshop):
|
||||
when = "2027-04-23T18:00:00Z"
|
||||
first = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=_admin(),
|
||||
json=_walk_in(tiny_workshop["id"], when, "5510000050"),
|
||||
)
|
||||
assert first.status_code == 200
|
||||
second = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=_admin(),
|
||||
json=_walk_in(tiny_workshop["id"], when, "5510000051"),
|
||||
)
|
||||
assert second.status_code == 409
|
||||
|
||||
|
||||
def test_walk_in_rejects_individual_service(client):
|
||||
svc = client.get("/services/atencion-psicologica-individual").json()
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=_admin(),
|
||||
json=_walk_in(svc["id"], "2027-04-26T16:00:00Z", "5510000060"),
|
||||
)
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"payload",
|
||||
[
|
||||
{},
|
||||
{"paid_cash": True},
|
||||
{"booking_id": "x", "service_id": "y", "scheduled_at": "2027-04-26T16:00:00Z"},
|
||||
{"service_id": "y", "scheduled_at": "2027-04-26T16:00:00Z"}, # walk-in without client
|
||||
],
|
||||
)
|
||||
def test_checkin_requires_exactly_one_mode(client, payload):
|
||||
assert client.post("/rosters/quick-checkin", headers=_admin(), json=payload).status_code == 422
|
||||
|
||||
|
||||
# --- ADR-0006: proxy users keep FK integrity on roster writes --------------------------
|
||||
|
||||
|
||||
def test_proxy_user_walk_in_checkin_preserves_foreign_keys(client, cacao, monkeypatch):
|
||||
monkeypatch.setattr(settings, "auth_provider", AuthProvider.PROXY_HEADERS)
|
||||
proxy = {
|
||||
"Remote-Email": "puerta@homelab.lan",
|
||||
"Remote-Name": "Recepcion",
|
||||
"Remote-Groups": "armonia-assistant",
|
||||
}
|
||||
res = client.post(
|
||||
"/rosters/quick-checkin",
|
||||
headers=proxy,
|
||||
json=_walk_in(cacao["id"], "2027-04-27T18:00:00Z", "5510000070", paid_cash=True),
|
||||
)
|
||||
assert res.status_code == 200, res.text
|
||||
with Session(get_engine()) as s:
|
||||
payment = s.get(Payment, res.json()["payment_id"])
|
||||
assert payment is not None
|
||||
assert payment.acknowledged_by == "puerta@homelab.lan"
|
||||
@@ -0,0 +1,46 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app.core.auth import resolve_role_from_groups
|
||||
from app.models.admin import RoleEnum
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("raw_groups", "expected"),
|
||||
[
|
||||
("armonia-owner", RoleEnum.OWNER),
|
||||
("armonia-assistant", RoleEnum.ASSISTANT),
|
||||
("armonia-admin", RoleEnum.ADMIN),
|
||||
# Authelia emits comma-separated groups; unrelated LLDAP groups are ignored
|
||||
("users,armonia-assistant,family", RoleEnum.ASSISTANT),
|
||||
# Whitespace and case from the proxy must not break matching
|
||||
(" Users , ARMONIA-Owner ", RoleEnum.OWNER),
|
||||
],
|
||||
)
|
||||
def test_resolve_role_maps_lldap_groups_to_roles(raw_groups: str, expected: RoleEnum):
|
||||
assert resolve_role_from_groups(raw_groups) is expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"raw_groups",
|
||||
[
|
||||
"armonia-owner,armonia-assistant",
|
||||
"armonia-assistant,armonia-owner",
|
||||
"armonia-admin,armonia-owner,armonia-assistant",
|
||||
],
|
||||
)
|
||||
def test_resolve_role_picks_highest_privilege_regardless_of_order(raw_groups: str):
|
||||
assert resolve_role_from_groups(raw_groups) is RoleEnum.OWNER
|
||||
|
||||
|
||||
def test_resolve_role_prefers_admin_over_assistant():
|
||||
assert resolve_role_from_groups("armonia-assistant,armonia-admin") is RoleEnum.ADMIN
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"raw_groups",
|
||||
[None, "", " ", "users,admins", "armonia", "armonia-owners", "not-armonia-owner"],
|
||||
)
|
||||
def test_resolve_role_returns_none_without_an_exact_armonia_group(raw_groups: str | None):
|
||||
assert resolve_role_from_groups(raw_groups) is None
|
||||
@@ -0,0 +1,104 @@
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.models.booking import (
|
||||
Booking,
|
||||
BookingPaymentStatusEnum,
|
||||
BookingStatusEnum,
|
||||
GcalSyncStatusEnum,
|
||||
PaymentArrangementEnum,
|
||||
)
|
||||
|
||||
|
||||
def test_booking_accepts_minimal_valid_payload():
|
||||
payload = {
|
||||
"booking_code": "ADS-1001",
|
||||
"service_id": "srv_abc",
|
||||
"client_id": "cli_xyz",
|
||||
"scheduled_at": "2026-10-25T10:00:00Z",
|
||||
"amount_mxn": 600,
|
||||
}
|
||||
booking = Booking.model_validate(payload)
|
||||
|
||||
assert booking.booking_code == "ADS-1001"
|
||||
assert booking.service_id == "srv_abc"
|
||||
assert booking.client_id == "cli_xyz"
|
||||
assert booking.package_id is None
|
||||
assert booking.duration_minutes == 60
|
||||
assert booking.buffer_minutes == 0
|
||||
assert booking.booking_status is BookingStatusEnum.RESERVED
|
||||
assert booking.payment_arrangement is PaymentArrangementEnum.PREPAID_DEFAULT
|
||||
assert booking.payment_status is BookingPaymentStatusEnum.AWAITING_ACKNOWLEDGMENT
|
||||
assert booking.amount_mxn == 600
|
||||
assert booking.gcal_sync_status is GcalSyncStatusEnum.PENDING
|
||||
|
||||
parsed_uuid = uuid.UUID(booking.id, version=4)
|
||||
assert str(parsed_uuid) == booking.id
|
||||
|
||||
parsed_dt = datetime.fromisoformat(booking.created_at)
|
||||
assert parsed_dt.tzinfo is not None
|
||||
assert parsed_dt.utcoffset() == timedelta(0)
|
||||
|
||||
|
||||
def test_booking_accepts_full_valid_payload():
|
||||
custom_id = str(uuid.uuid4())
|
||||
payload = {
|
||||
"id": custom_id,
|
||||
"booking_code": "ADS-2002",
|
||||
"service_id": "srv_abc",
|
||||
"client_id": "cli_xyz",
|
||||
"package_id": "pkg_123",
|
||||
"scheduled_at": "2026-10-26T15:00:00Z",
|
||||
"duration_minutes": 90,
|
||||
"buffer_minutes": 15,
|
||||
"booking_status": "COMPLETED",
|
||||
"payment_arrangement": "DELAYED_ALLOWED",
|
||||
"payment_status": "ACKNOWLEDGED",
|
||||
"amount_mxn": 800,
|
||||
"exception_authorized_by": "jasmin@armoniadelser.mx",
|
||||
"exception_authorized_at": "2026-10-24T12:00:00Z",
|
||||
"exception_notes": "Conocida de confianza",
|
||||
"acknowledged_by": "asistente@armoniadelser.mx",
|
||||
"acknowledged_at": "2026-10-26T16:30:00Z",
|
||||
"gcal_event_id": "gcal_evt_999",
|
||||
"gcal_sync_status": "SYNCED",
|
||||
"gcal_synced_at": "2026-10-24T12:01:00Z",
|
||||
}
|
||||
booking = Booking.model_validate(payload)
|
||||
|
||||
assert booking.id == custom_id
|
||||
assert booking.booking_status is BookingStatusEnum.COMPLETED
|
||||
assert booking.payment_arrangement is PaymentArrangementEnum.DELAYED_ALLOWED
|
||||
assert booking.payment_status is BookingPaymentStatusEnum.ACKNOWLEDGED
|
||||
assert booking.exception_authorized_by == "jasmin@armoniadelser.mx"
|
||||
assert booking.gcal_sync_status is GcalSyncStatusEnum.SYNCED
|
||||
|
||||
|
||||
def test_booking_rejects_negative_amount():
|
||||
with pytest.raises(ValidationError):
|
||||
Booking.model_validate(
|
||||
{
|
||||
"booking_code": "ADS-1002",
|
||||
"service_id": "srv_abc",
|
||||
"client_id": "cli_xyz",
|
||||
"scheduled_at": "2026-10-25T10:00:00Z",
|
||||
"amount_mxn": -50,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_booking_rejects_invalid_enums():
|
||||
with pytest.raises(ValidationError):
|
||||
Booking.model_validate(
|
||||
{
|
||||
"booking_code": "ADS-1003",
|
||||
"service_id": "srv_abc",
|
||||
"client_id": "cli_xyz",
|
||||
"scheduled_at": "2026-10-25T10:00:00Z",
|
||||
"amount_mxn": 500,
|
||||
"booking_status": "NON_EXISTENT_STATUS",
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,142 @@
|
||||
"""
|
||||
Behavior-driven test naming convention:
|
||||
test_<subject>_<accepts|rejects>_<condition>
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.models import Client
|
||||
|
||||
|
||||
def test_client_accepts_minimal_valid_payload():
|
||||
payload = {
|
||||
"full_name": "Luisa Santos",
|
||||
"phone_whatsapp": "+1 (555) 019-2834",
|
||||
}
|
||||
client = Client.model_validate(payload)
|
||||
|
||||
assert client.full_name == "Luisa Santos"
|
||||
assert client.phone_whatsapp == "+1 (555) 019-2834"
|
||||
assert client.email is None
|
||||
assert client.notes is None
|
||||
|
||||
# Check UUID4 string format
|
||||
assert isinstance(client.id, str)
|
||||
parsed_uuid = uuid.UUID(client.id, version=4)
|
||||
assert str(parsed_uuid) == client.id
|
||||
|
||||
# Check created_at parsing and UTC offset
|
||||
parsed_dt = datetime.fromisoformat(client.created_at)
|
||||
assert isinstance(parsed_dt, datetime)
|
||||
assert parsed_dt.tzinfo is not None
|
||||
assert parsed_dt.utcoffset() == timedelta(0)
|
||||
|
||||
|
||||
def test_client_accepts_full_valid_payload():
|
||||
custom_id = str(uuid.uuid4())
|
||||
payload = {
|
||||
"id": custom_id,
|
||||
"full_name": "Valentina Vega",
|
||||
"phone_whatsapp": "555-019-2834 ext 123",
|
||||
"email": "testing_vvt@roadtotech.me",
|
||||
"notes": "Prefers morning appointments.",
|
||||
}
|
||||
|
||||
client = Client.model_validate(payload)
|
||||
|
||||
assert client.id == custom_id
|
||||
assert client.full_name == "Valentina Vega"
|
||||
assert client.phone_whatsapp == "555-019-2834 ext 123"
|
||||
assert client.email == "testing_vvt@roadtotech.me"
|
||||
assert client.notes == "Prefers morning appointments."
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"valid_phone",
|
||||
[
|
||||
"+13005386982",
|
||||
"+1 (555) 019-2834",
|
||||
"555-019-2834 ext 123",
|
||||
"5550192834x12",
|
||||
"(555) 019-2834 #456",
|
||||
"+57 300 123 4567",
|
||||
],
|
||||
)
|
||||
def test_client_accepts_valid_phone_formats(valid_phone: str):
|
||||
payload = {"full_name": "Anthonio Stark", "phone_whatsapp": valid_phone}
|
||||
|
||||
client = Client.model_validate(payload)
|
||||
|
||||
assert client.phone_whatsapp == valid_phone.strip()
|
||||
|
||||
|
||||
def test_client_rejects_missing_required_fields():
|
||||
# Missing full_name and phone_whatsapp
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Client.model_validate({})
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
missing_locs = {err["loc"][0] for err in errors}
|
||||
assert "full_name" in missing_locs
|
||||
assert "phone_whatsapp" in missing_locs
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_phone",
|
||||
[
|
||||
"",
|
||||
"not-a-number",
|
||||
"123",
|
||||
"++15550192834",
|
||||
"555-PHONE-NOW",
|
||||
],
|
||||
)
|
||||
def test_client_rejects_invalid_phone_formats(invalid_phone: str):
|
||||
payload = {
|
||||
"full_name": "Luisa Santos",
|
||||
"phone_whatsapp": invalid_phone,
|
||||
}
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Client.model_validate(payload)
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any(err["loc"][0] == "phone_whatsapp" for err in errors)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_email",
|
||||
[
|
||||
"plainaddress",
|
||||
"@missingusername.com",
|
||||
"user@.com",
|
||||
"user@domain..com",
|
||||
],
|
||||
)
|
||||
def test_client_rejects_invalid_email(invalid_email: str):
|
||||
payload = {
|
||||
"full_name": "Luisa Santos",
|
||||
"phone_whatsapp": "+13005386982",
|
||||
"email": invalid_email,
|
||||
}
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Client.model_validate(payload)
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any(err["loc"][0] == "email" for err in errors)
|
||||
|
||||
|
||||
def test_client_rejects_non_string_types_in_strict_mode():
|
||||
# strict=True prevents coercion of integers/booleans to strings
|
||||
payload = {
|
||||
"full_name": 12345,
|
||||
"phone_whatsapp": "+13005386982",
|
||||
}
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Client.model_validate(payload)
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any(err["loc"][0] == "full_name" for err in errors)
|
||||
@@ -0,0 +1,87 @@
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.models.package import FinancialStatusEnum, Package
|
||||
|
||||
|
||||
def test_package_accepts_minimal_valid_payload():
|
||||
payload = {
|
||||
"client_id": "cli_123",
|
||||
"service_id": "srv_456",
|
||||
"total_sessions": 5,
|
||||
}
|
||||
package = Package.model_validate(payload)
|
||||
|
||||
assert package.client_id == "cli_123"
|
||||
assert package.service_id == "srv_456"
|
||||
assert package.total_sessions == 5
|
||||
assert package.completed_sessions == 0
|
||||
assert package.price_paid_mxn == 0
|
||||
assert package.financial_status is FinancialStatusEnum.PENDING
|
||||
assert package.financial_status == "PENDING"
|
||||
assert package.notes is None
|
||||
|
||||
# Auto-generated UUID4
|
||||
parsed_uuid = uuid.UUID(package.id, version=4)
|
||||
assert str(parsed_uuid) == package.id
|
||||
|
||||
# Timestamps
|
||||
created_dt = datetime.fromisoformat(package.created_at)
|
||||
assert created_dt.tzinfo is not None
|
||||
assert created_dt.utcoffset() == timedelta(0)
|
||||
|
||||
|
||||
def test_package_accepts_full_valid_payload():
|
||||
custom_id = str(uuid.uuid4())
|
||||
payload = {
|
||||
"id": custom_id,
|
||||
"client_id": "cli_123",
|
||||
"service_id": "srv_456",
|
||||
"total_sessions": 10,
|
||||
"completed_sessions": 3,
|
||||
"price_paid_mxn": 2500,
|
||||
"financial_status": "PAID",
|
||||
"notes": "Pagado en efectivo por adelantado",
|
||||
}
|
||||
package = Package.model_validate(payload)
|
||||
|
||||
assert package.id == custom_id
|
||||
assert package.completed_sessions == 3
|
||||
assert package.price_paid_mxn == 2500
|
||||
assert package.financial_status is FinancialStatusEnum.PAID
|
||||
assert package.notes == "Pagado en efectivo por adelantado"
|
||||
|
||||
|
||||
def test_package_rejects_zero_or_negative_total_sessions():
|
||||
with pytest.raises(ValidationError):
|
||||
Package.model_validate(
|
||||
{
|
||||
"client_id": "cli_123",
|
||||
"service_id": "srv_456",
|
||||
"total_sessions": 0,
|
||||
}
|
||||
)
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
Package.model_validate(
|
||||
{
|
||||
"client_id": "cli_123",
|
||||
"service_id": "srv_456",
|
||||
"total_sessions": -2,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_package_rejects_invalid_financial_status():
|
||||
with pytest.raises(ValidationError):
|
||||
Package.model_validate(
|
||||
{
|
||||
"client_id": "cli_123",
|
||||
"service_id": "srv_456",
|
||||
"total_sessions": 5,
|
||||
"financial_status": "UNKNOWN_STATUS",
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,83 @@
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.models.payment import (
|
||||
Payment,
|
||||
PaymentMethodEnum,
|
||||
PaymentStatusEnum,
|
||||
)
|
||||
|
||||
|
||||
def test_payment_accepts_minimal_valid_payload():
|
||||
payload = {
|
||||
"booking_id": "bkg_123",
|
||||
"amount_mxn": 600,
|
||||
"acknowledged_by": "jasmin@armoniadelser.mx",
|
||||
"acknowledged_at": "2026-10-25T11:00:00Z",
|
||||
}
|
||||
payment = Payment.model_validate(payload)
|
||||
|
||||
assert payment.booking_id == "bkg_123"
|
||||
assert payment.amount_mxn == 600
|
||||
assert payment.acknowledged_by == "jasmin@armoniadelser.mx"
|
||||
assert payment.acknowledged_at == "2026-10-25T11:00:00Z"
|
||||
assert payment.payment_method is PaymentMethodEnum.SPEI
|
||||
assert payment.payment_method == "SPEI"
|
||||
assert payment.status is PaymentStatusEnum.ACKNOWLEDGED
|
||||
assert payment.status == "ACKNOWLEDGED"
|
||||
assert payment.notes is None
|
||||
|
||||
parsed_uuid = uuid.UUID(payment.id, version=4)
|
||||
assert str(parsed_uuid) == payment.id
|
||||
|
||||
parsed_dt = datetime.fromisoformat(payment.created_at)
|
||||
assert parsed_dt.tzinfo is not None
|
||||
assert parsed_dt.utcoffset() == timedelta(0)
|
||||
|
||||
|
||||
def test_payment_accepts_full_valid_payload():
|
||||
custom_id = str(uuid.uuid4())
|
||||
payload = {
|
||||
"id": custom_id,
|
||||
"booking_id": "bkg_456",
|
||||
"amount_mxn": 1200,
|
||||
"payment_method": "CASH",
|
||||
"status": "REVERSED",
|
||||
"acknowledged_by": "asistente@armoniadelser.mx",
|
||||
"acknowledged_at": "2026-10-25T12:00:00Z",
|
||||
"notes": "Reembolso acordado con el cliente",
|
||||
}
|
||||
payment = Payment.model_validate(payload)
|
||||
|
||||
assert payment.id == custom_id
|
||||
assert payment.payment_method is PaymentMethodEnum.CASH
|
||||
assert payment.status is PaymentStatusEnum.REVERSED
|
||||
assert payment.notes == "Reembolso acordado con el cliente"
|
||||
|
||||
|
||||
def test_payment_rejects_negative_amount():
|
||||
with pytest.raises(ValidationError):
|
||||
Payment.model_validate(
|
||||
{
|
||||
"booking_id": "bkg_123",
|
||||
"amount_mxn": -100,
|
||||
"acknowledged_by": "jasmin@armoniadelser.mx",
|
||||
"acknowledged_at": "2026-10-25T11:00:00Z",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_payment_rejects_invalid_enums():
|
||||
with pytest.raises(ValidationError):
|
||||
Payment.model_validate(
|
||||
{
|
||||
"booking_id": "bkg_123",
|
||||
"amount_mxn": 300,
|
||||
"payment_method": "BITCOIN",
|
||||
"acknowledged_by": "jasmin@armoniadelser.mx",
|
||||
"acknowledged_at": "2026-10-25T11:00:00Z",
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,215 @@
|
||||
"""
|
||||
Behavior-driven test naming convention:
|
||||
test_<subject>_<accepts|rejects>_<condition>
|
||||
"""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.models.service import (
|
||||
Service,
|
||||
ServiceModalityEnum,
|
||||
ServiceTypeEnum,
|
||||
)
|
||||
|
||||
|
||||
def test_service_accepts_minimal_valid_payload():
|
||||
payload = {
|
||||
"slug": "tarot-reading",
|
||||
"name": "Tarot Reading",
|
||||
"service_type": "INDIVIDUAL",
|
||||
"modality": "ONLINE",
|
||||
}
|
||||
service = Service.model_validate(payload)
|
||||
|
||||
assert service.slug == "tarot-reading"
|
||||
assert service.name == "Tarot Reading"
|
||||
assert service.service_type is ServiceTypeEnum.INDIVIDUAL
|
||||
assert service.modality is ServiceModalityEnum.ONLINE
|
||||
assert service.service_type == "INDIVIDUAL"
|
||||
assert service.modality == "ONLINE"
|
||||
|
||||
# Default values verification
|
||||
assert service.id is None
|
||||
assert service.description is None
|
||||
assert service.default_schedule is None
|
||||
assert service.price_mxn == 0
|
||||
assert service.max_capacity == 1
|
||||
assert service.duration_minutes == 60
|
||||
assert service.buffer_minutes == 15
|
||||
assert service.is_active is True
|
||||
|
||||
# Valid UTC ISO timestamp verification
|
||||
parsed_dt = datetime.fromisoformat(service.created_at)
|
||||
assert isinstance(parsed_dt, datetime)
|
||||
assert parsed_dt.tzinfo is not None
|
||||
assert parsed_dt.utcoffset() == timedelta(0)
|
||||
|
||||
|
||||
def test_service_accepts_full_valid_payload():
|
||||
payload = {
|
||||
"id": "srv_123456",
|
||||
"slug": "reiki-in-person",
|
||||
"name": "Reiki Session",
|
||||
"description": "60-minute energy balance session.",
|
||||
"service_type": "INDIVIDUAL",
|
||||
"modality": "PRESENCIAL",
|
||||
"default_schedule": "mon-fri_09-17",
|
||||
"price_mxn": 850,
|
||||
"max_capacity": 2,
|
||||
"duration_minutes": 90,
|
||||
"buffer_minutes": 20,
|
||||
"is_active": False,
|
||||
}
|
||||
service = Service.model_validate(payload)
|
||||
|
||||
assert service.id == "srv_123456"
|
||||
assert service.service_type is ServiceTypeEnum.INDIVIDUAL
|
||||
assert service.modality is ServiceModalityEnum.PRESENCIAL
|
||||
assert service.price_mxn == 850
|
||||
assert service.max_capacity == 2
|
||||
assert service.duration_minutes == 90
|
||||
assert service.buffer_minutes == 20
|
||||
assert service.is_active is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("valid_type", ["GROUP", "INDIVIDUAL"])
|
||||
def test_service_accepts_all_valid_service_types(valid_type: str):
|
||||
payload = {
|
||||
"slug": f"service-{valid_type.lower()}",
|
||||
"name": "Sample Service",
|
||||
"service_type": valid_type,
|
||||
"modality": "ONLINE",
|
||||
}
|
||||
service = Service.model_validate(payload)
|
||||
assert service.service_type == ServiceTypeEnum(valid_type)
|
||||
assert service.service_type == valid_type
|
||||
|
||||
|
||||
@pytest.mark.parametrize("valid_modality", ["PRESENCIAL", "ONLINE"])
|
||||
def test_service_accepts_all_valid_modalities(valid_modality: str):
|
||||
payload = {
|
||||
"slug": f"service-{valid_modality.lower()}",
|
||||
"name": "Sample Service",
|
||||
"service_type": "GROUP",
|
||||
"modality": valid_modality,
|
||||
}
|
||||
service = Service.model_validate(payload)
|
||||
assert service.modality == ServiceModalityEnum(valid_modality)
|
||||
assert service.modality == valid_modality
|
||||
|
||||
|
||||
def test_service_accepts_enum_instances_directly():
|
||||
payload = {
|
||||
"slug": "meditation-class",
|
||||
"name": "Meditation Class",
|
||||
"service_type": ServiceTypeEnum.GROUP,
|
||||
"modality": ServiceModalityEnum.PRESENCIAL,
|
||||
}
|
||||
service = Service.model_validate(payload)
|
||||
assert service.service_type is ServiceTypeEnum.GROUP
|
||||
assert service.modality is ServiceModalityEnum.PRESENCIAL
|
||||
|
||||
|
||||
def test_service_rejects_missing_required_fields():
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Service.model_validate({})
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
missing_locs = {err["loc"][0] for err in errors}
|
||||
assert {"slug", "name", "service_type", "modality"}.issubset(missing_locs)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_type",
|
||||
[
|
||||
"group", # Lowercase rejected
|
||||
"individual", # Lowercase rejected
|
||||
"one_on_one", # Legacy format rejected
|
||||
"Group", # Mixed case rejected
|
||||
"consultation",
|
||||
"workshop",
|
||||
"",
|
||||
123,
|
||||
],
|
||||
)
|
||||
def test_service_rejects_invalid_service_type(invalid_type):
|
||||
payload = {
|
||||
"slug": "sample-service",
|
||||
"name": "Sample Service",
|
||||
"service_type": invalid_type,
|
||||
"modality": "ONLINE",
|
||||
}
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Service.model_validate(payload)
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any(err["loc"][0] == "service_type" for err in errors)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"invalid_modality",
|
||||
[
|
||||
"presencial", # Lowercase rejected
|
||||
"online", # Lowercase rejected
|
||||
"Online", # Mixed case rejected
|
||||
"hybrid",
|
||||
"remote",
|
||||
"",
|
||||
456,
|
||||
],
|
||||
)
|
||||
def test_service_rejects_invalid_modality(invalid_modality):
|
||||
payload = {
|
||||
"slug": "sample-service",
|
||||
"name": "Sample Service",
|
||||
"service_type": "GROUP",
|
||||
"modality": invalid_modality,
|
||||
}
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Service.model_validate(payload)
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any(err["loc"][0] == "modality" for err in errors)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"field,invalid_value",
|
||||
[
|
||||
("price_mxn", -1), # ge=0
|
||||
("max_capacity", 0), # ge=1
|
||||
("duration_minutes", 14), # ge=15
|
||||
("duration_minutes", -5), # ge=15
|
||||
("buffer_minutes", -1), # ge=0
|
||||
],
|
||||
)
|
||||
def test_service_rejects_out_of_bounds_numerical_values(field: str, invalid_value: int):
|
||||
payload = {
|
||||
"slug": "sound-bath",
|
||||
"name": "Sound Bath",
|
||||
"service_type": "GROUP",
|
||||
"modality": "PRESENCIAL",
|
||||
field: invalid_value,
|
||||
}
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Service.model_validate(payload)
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any(err["loc"][0] == field for err in errors)
|
||||
|
||||
|
||||
def test_service_rejects_non_integer_numbers_in_strict_mode():
|
||||
payload = {
|
||||
"slug": "yoga-class",
|
||||
"name": "Yoga Class",
|
||||
"service_type": "GROUP",
|
||||
"modality": "ONLINE",
|
||||
"price_mxn": "100", # String instead of int in strict mode
|
||||
}
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Service.model_validate(payload)
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any(err["loc"][0] == "price_mxn" for err in errors)
|
||||
@@ -0,0 +1,181 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import UTC, date, datetime, time, timedelta
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import pytest
|
||||
|
||||
from app.services.availability import (
|
||||
BlockedInterval,
|
||||
BusinessHours,
|
||||
blocked_interval,
|
||||
compute_available_slots,
|
||||
intervals_overlap,
|
||||
)
|
||||
|
||||
MX = ZoneInfo("America/Mexico_City") # UTC-6, no DST since 2022
|
||||
MONDAY = date(2027, 3, 1)
|
||||
LONG_AGO = datetime(2020, 1, 1, tzinfo=UTC)
|
||||
|
||||
HOURS = BusinessHours(
|
||||
timezone=MX,
|
||||
open_time=time(9, 0),
|
||||
close_time=time(13, 0),
|
||||
working_weekdays=frozenset({0, 1, 2, 3, 4}),
|
||||
slot_step_minutes=30,
|
||||
)
|
||||
|
||||
|
||||
def _local(day: date, hh: int, mm: int = 0) -> datetime:
|
||||
return datetime(day.year, day.month, day.day, hh, mm, tzinfo=MX)
|
||||
|
||||
|
||||
def _starts(slots) -> list[str]:
|
||||
return [s.start.strftime("%H:%M") for s in slots]
|
||||
|
||||
|
||||
# --- blocked_interval / intervals_overlap -------------------------------------------
|
||||
|
||||
|
||||
def test_blocked_interval_adds_duration_and_post_session_buffer():
|
||||
start = _local(MONDAY, 10)
|
||||
interval = blocked_interval(start, duration_minutes=60, buffer_minutes=15)
|
||||
assert interval.start == start
|
||||
assert interval.end == start + timedelta(minutes=75)
|
||||
|
||||
|
||||
def test_intervals_touching_at_boundary_do_not_overlap():
|
||||
a = BlockedInterval(_local(MONDAY, 9), _local(MONDAY, 10))
|
||||
b = BlockedInterval(_local(MONDAY, 10), _local(MONDAY, 11))
|
||||
assert intervals_overlap(a, b) is False
|
||||
assert intervals_overlap(b, a) is False
|
||||
|
||||
|
||||
def test_intervals_sharing_one_minute_overlap():
|
||||
a = BlockedInterval(_local(MONDAY, 9), _local(MONDAY, 10, 1))
|
||||
b = BlockedInterval(_local(MONDAY, 10), _local(MONDAY, 11))
|
||||
assert intervals_overlap(a, b) is True
|
||||
assert intervals_overlap(b, a) is True
|
||||
|
||||
|
||||
def test_contained_interval_overlaps():
|
||||
outer = BlockedInterval(_local(MONDAY, 9), _local(MONDAY, 12))
|
||||
inner = BlockedInterval(_local(MONDAY, 10), _local(MONDAY, 11))
|
||||
assert intervals_overlap(outer, inner) is True
|
||||
assert intervals_overlap(inner, outer) is True
|
||||
|
||||
|
||||
# --- compute_available_slots --------------------------------------------------------
|
||||
|
||||
|
||||
def _compute(existing=(), *, duration=60, buffer=15, now=LONG_AGO, day_to=None, hours=HOURS):
|
||||
return compute_available_slots(
|
||||
date_from=MONDAY,
|
||||
date_to=day_to or MONDAY,
|
||||
duration_minutes=duration,
|
||||
buffer_minutes=buffer,
|
||||
existing=list(existing),
|
||||
hours=hours,
|
||||
now=now,
|
||||
)
|
||||
|
||||
|
||||
def test_empty_day_offers_every_step_whose_session_ends_by_close():
|
||||
# 60-minute session must END by 13:00 -> last start 12:00
|
||||
assert _starts(_compute()) == ["09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00"]
|
||||
|
||||
|
||||
def test_buffer_may_spill_past_closing_time():
|
||||
# 12:00 + 60 = 13:00 session end (allowed) even though buffer runs to 13:15
|
||||
assert "12:00" in _starts(_compute())
|
||||
|
||||
|
||||
def test_slot_end_is_session_end_without_buffer():
|
||||
first = _compute()[0]
|
||||
assert first.end - first.start == timedelta(minutes=60)
|
||||
|
||||
|
||||
def test_slots_are_returned_in_business_timezone():
|
||||
first = _compute()[0]
|
||||
assert first.start.utcoffset() == timedelta(hours=-6)
|
||||
assert first.start.astimezone(UTC).hour == 15
|
||||
|
||||
|
||||
def test_existing_booking_blocks_its_buffer_and_new_sessions_buffer():
|
||||
# Existing 10:00 session blocks [10:00, 11:15)
|
||||
existing = [blocked_interval(_local(MONDAY, 10), 60, 15)]
|
||||
# 09:00 slot would block [09:00, 10:15) -> overlaps because of the NEW buffer
|
||||
# 11:00 slot starts before 11:15 -> overlaps because of the EXISTING buffer
|
||||
assert _starts(_compute(existing)) == ["11:30", "12:00"]
|
||||
|
||||
|
||||
def test_slot_whose_buffer_ends_exactly_at_existing_start_is_available():
|
||||
# 15-min step so 08:45-style edges are representable; 09:45 + 60 + 15 = 11:00
|
||||
hours = BusinessHours(MX, time(9, 0), time(13, 0), frozenset({0}), 15)
|
||||
existing = [blocked_interval(_local(MONDAY, 11), 60, 15)]
|
||||
starts = _starts(_compute(existing, hours=hours))
|
||||
assert "09:45" in starts
|
||||
assert "10:00" not in starts # 10:00 + 75 = 11:15 > 11:00
|
||||
|
||||
|
||||
def test_slot_starting_exactly_at_existing_buffer_end_is_available():
|
||||
hours = BusinessHours(MX, time(9, 0), time(13, 0), frozenset({0}), 15)
|
||||
existing = [blocked_interval(_local(MONDAY, 9), 60, 15)] # blocks until 10:15
|
||||
starts = _starts(_compute(existing, hours=hours))
|
||||
assert starts[0] == "10:15"
|
||||
assert "10:00" not in starts
|
||||
|
||||
|
||||
def test_zero_buffer_service_still_respects_existing_buffer():
|
||||
existing = [blocked_interval(_local(MONDAY, 9), 60, 15)] # blocks until 10:15
|
||||
starts = _starts(_compute(existing, buffer=0))
|
||||
assert "10:00" not in starts
|
||||
assert starts[0] == "10:30"
|
||||
|
||||
|
||||
def test_bookings_on_other_days_do_not_block():
|
||||
existing = [blocked_interval(_local(MONDAY + timedelta(days=1), 10), 60, 15)]
|
||||
assert len(_compute(existing)) == 7
|
||||
|
||||
|
||||
def test_past_and_current_slots_are_excluded():
|
||||
now = _local(MONDAY, 10).astimezone(UTC)
|
||||
starts = _starts(_compute(now=now))
|
||||
assert "10:00" not in starts
|
||||
assert starts[0] == "10:30"
|
||||
|
||||
|
||||
def test_non_working_days_offer_no_slots():
|
||||
saturday, sunday = MONDAY + timedelta(days=5), MONDAY + timedelta(days=6)
|
||||
slots = compute_available_slots(
|
||||
date_from=saturday,
|
||||
date_to=sunday,
|
||||
duration_minutes=60,
|
||||
buffer_minutes=15,
|
||||
existing=[],
|
||||
hours=HOURS,
|
||||
now=LONG_AGO,
|
||||
)
|
||||
assert slots == []
|
||||
|
||||
|
||||
def test_range_is_inclusive_of_both_endpoints():
|
||||
slots = _compute(day_to=MONDAY + timedelta(days=1))
|
||||
assert {s.start.date() for s in slots} == {MONDAY, MONDAY + timedelta(days=1)}
|
||||
|
||||
|
||||
def test_session_longer_than_opening_hours_yields_nothing():
|
||||
assert _compute(duration=300) == []
|
||||
|
||||
|
||||
def test_invalid_range_is_rejected():
|
||||
with pytest.raises(ValueError):
|
||||
compute_available_slots(
|
||||
date_from=MONDAY,
|
||||
date_to=MONDAY - timedelta(days=1),
|
||||
duration_minutes=60,
|
||||
buffer_minutes=15,
|
||||
existing=[],
|
||||
hours=HOURS,
|
||||
now=LONG_AGO,
|
||||
)
|
||||
@@ -0,0 +1,366 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
import time_machine
|
||||
|
||||
from app.core.config import settings
|
||||
from app.services.bookings import (
|
||||
build_assistant_followup_link,
|
||||
build_whatsapp_link,
|
||||
calculate_hours_until,
|
||||
check_slot_collision,
|
||||
evaluate_payment_followup,
|
||||
generate_booking_code,
|
||||
)
|
||||
|
||||
# ==============================================================================
|
||||
# Buffer Collision Arithmetic (check_slot_collision)
|
||||
# ==============================================================================
|
||||
|
||||
|
||||
def test_collision_when_slots_overlap_in_middle():
|
||||
# Existing booking: 10:00 - 11:00 (+15m buffer = 11:15)
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T10:00:00Z", "duration_minutes": 60, "buffer_minutes": 15}
|
||||
]
|
||||
# New slot starts inside existing slot: 10:30 - 11:30
|
||||
new_start = datetime(2026, 10, 27, 10, 30, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is True
|
||||
|
||||
|
||||
def test_collision_when_exact_same_start_and_duration():
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T10:00:00Z", "duration_minutes": 60, "buffer_minutes": 15}
|
||||
]
|
||||
new_start = datetime(2026, 10, 27, 10, 0, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is True
|
||||
|
||||
|
||||
def test_collision_when_new_slot_starts_during_existing_buffer():
|
||||
# Existing booking: 10:00 - 11:00 (+ 15m buffer = blocked until 11:15)
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T10:00:00Z", "duration_minutes": 60, "buffer_minutes": 15}
|
||||
]
|
||||
# New slot: 11:05 - 12:05 (starts within existing buffer)
|
||||
new_start = datetime(2026, 10, 27, 11, 5, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is True
|
||||
|
||||
|
||||
def test_no_collision_when_new_slot_starts_exactly_at_buffer_end_boundary():
|
||||
# Existing booking: 10:00 - 11:00 (+ 15m buffer = blocked until 11:15)
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T10:00:00Z", "duration_minutes": 60, "buffer_minutes": 15}
|
||||
]
|
||||
# New slot: 11:15 - 12:15 (exact boundary: new_start == exist_blocked_end)
|
||||
new_start = datetime(2026, 10, 27, 11, 15, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is False
|
||||
|
||||
|
||||
def test_no_collision_when_new_slot_blocked_end_exactly_matches_existing_start():
|
||||
# Existing booking: 11:15 - 12:15 (+ 15m buffer)
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T11:15:00Z", "duration_minutes": 60, "buffer_minutes": 15}
|
||||
]
|
||||
# New slot: 10:00 - 11:00 (+ 15m buffer = blocked until 11:15)
|
||||
# Exact boundary: new_blocked_end == exist_start
|
||||
new_start = datetime(2026, 10, 27, 10, 0, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is False
|
||||
|
||||
|
||||
def test_collision_when_new_slot_buffer_encroaches_on_existing_start():
|
||||
# Existing booking: 11:10 - 12:10 (+ 15m buffer)
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T11:10:00Z", "duration_minutes": 60, "buffer_minutes": 15}
|
||||
]
|
||||
# New slot: 10:00 - 11:00 (+ 15m buffer = blocked until 11:15 > 11:10)
|
||||
# The session itself ended at 11:00, but its mandatory buffer collides with 11:10!
|
||||
new_start = datetime(2026, 10, 27, 10, 0, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is True
|
||||
|
||||
|
||||
def test_no_collision_when_completely_disjoint_after():
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T10:00:00Z", "duration_minutes": 60, "buffer_minutes": 15}
|
||||
]
|
||||
new_start = datetime(2026, 10, 27, 12, 0, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is False
|
||||
|
||||
|
||||
def test_no_collision_when_completely_disjoint_before():
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T14:00:00Z", "duration_minutes": 60, "buffer_minutes": 15}
|
||||
]
|
||||
new_start = datetime(2026, 10, 27, 10, 0, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is False
|
||||
|
||||
|
||||
def test_collision_defaults_for_missing_duration_and_buffer_keys():
|
||||
# Missing duration_minutes defaults to 60, missing buffer_minutes defaults to 0
|
||||
existing = [{"scheduled_at": "2026-10-27T10:00:00Z"}]
|
||||
# New slot at 10:45 collides with default 60-min slot (10:00-11:00)
|
||||
new_start = datetime(2026, 10, 27, 10, 45, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 30, 0, existing) is True
|
||||
|
||||
# New slot at 11:00 does not collide because default buffer is 0
|
||||
new_start_boundary = datetime(2026, 10, 27, 11, 0, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start_boundary, 30, 0, existing) is False
|
||||
|
||||
|
||||
def test_collision_with_multiple_existing_bookings_second_matches():
|
||||
existing = [
|
||||
{"scheduled_at": "2026-10-27T08:00:00Z", "duration_minutes": 60, "buffer_minutes": 15},
|
||||
{"scheduled_at": "2026-10-27T14:00:00Z", "duration_minutes": 90, "buffer_minutes": 15},
|
||||
]
|
||||
# Collides with the 14:00-15:45 slot
|
||||
new_start = datetime(2026, 10, 27, 14, 30, tzinfo=UTC)
|
||||
assert check_slot_collision(new_start, 60, 15, existing) is True
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Hours Until Calculation (calculate_hours_until)
|
||||
# ==============================================================================
|
||||
|
||||
|
||||
def test_calculate_hours_until_exact_hours_and_fractional():
|
||||
ref = datetime(2026, 10, 25, 12, 0, 0, tzinfo=UTC)
|
||||
target = datetime(2026, 10, 27, 12, 0, 0, tzinfo=UTC)
|
||||
assert calculate_hours_until(target, now=ref) == 48.0
|
||||
|
||||
target_half = datetime(2026, 10, 27, 12, 30, 0, tzinfo=UTC)
|
||||
assert calculate_hours_until(target_half, now=ref) == 48.5
|
||||
|
||||
|
||||
def test_calculate_hours_until_past_session_returns_negative():
|
||||
ref = datetime(2026, 10, 25, 12, 0, 0, tzinfo=UTC)
|
||||
past = datetime(2026, 10, 25, 10, 0, 0, tzinfo=UTC)
|
||||
assert calculate_hours_until(past, now=ref) == -2.0
|
||||
|
||||
|
||||
def test_calculate_hours_until_from_iso_string():
|
||||
ref = datetime(2026, 10, 25, 12, 0, 0, tzinfo=UTC)
|
||||
assert calculate_hours_until("2026-10-27T12:00:00Z", now=ref) == 48.0
|
||||
|
||||
|
||||
def test_calculate_hours_until_from_naive_datetime():
|
||||
ref = datetime(2026, 10, 25, 12, 0, 0, tzinfo=UTC)
|
||||
naive_target = datetime(2026, 10, 27, 12, 0, 0)
|
||||
assert calculate_hours_until(naive_target, now=ref) == 48.0
|
||||
|
||||
|
||||
def test_calculate_hours_until_uses_datetime_now_when_now_is_none():
|
||||
frozen_ref = datetime(2026, 10, 25, 12, 0, 0, tzinfo=UTC)
|
||||
with time_machine.travel(frozen_ref, tick=False):
|
||||
target = "2026-10-27T12:00:00Z"
|
||||
assert calculate_hours_until(target) == 48.0
|
||||
|
||||
|
||||
def test_calculate_hours_until_rounding_to_two_decimals():
|
||||
ref = datetime(2026, 10, 25, 12, 0, 0, tzinfo=UTC)
|
||||
# 1 hour and 20 seconds = 3620s -> 3620 / 3600 = 1.00555... -> 1.01
|
||||
target = ref + timedelta(seconds=3620)
|
||||
assert calculate_hours_until(target, now=ref) == 1.01
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Payment Follow-Up Evaluation (evaluate_payment_followup)
|
||||
# ==============================================================================
|
||||
|
||||
|
||||
def test_payment_followup_false_when_payment_not_awaiting_acknowledgment():
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="ACKNOWLEDGED",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
hours_until=10.0,
|
||||
threshold_hours=48,
|
||||
)
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="NOT_APPLICABLE",
|
||||
payment_arrangement="PACKAGE_REDEEMED",
|
||||
hours_until=10.0,
|
||||
threshold_hours=48,
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
def test_payment_followup_at_exact_48h_boundary_is_true():
|
||||
# Exactly at threshold 48.0 hours -> must trigger follow-up
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
hours_until=48.0,
|
||||
threshold_hours=48,
|
||||
)
|
||||
is True
|
||||
)
|
||||
|
||||
|
||||
def test_payment_followup_uses_48h_as_default_threshold():
|
||||
# Verify default parameter threshold_hours=48
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
hours_until=48.0,
|
||||
)
|
||||
is True
|
||||
)
|
||||
# At 48.01 or 49.0 hours, with default threshold=48, it must return False
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
hours_until=48.01,
|
||||
)
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
hours_until=49.0,
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
def test_payment_followup_custom_threshold_window():
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
hours_until=72.0,
|
||||
threshold_hours=72,
|
||||
)
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
hours_until=72.01,
|
||||
threshold_hours=72,
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
def test_payment_followup_delayed_allowed_for_reserved_and_completed_beyond_threshold():
|
||||
# DELAYED_ALLOWED triggers even when session is far in future
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RESERVED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="DELAYED_ALLOWED",
|
||||
hours_until=120.0,
|
||||
)
|
||||
is True
|
||||
)
|
||||
# DELAYED_ALLOWED triggers for COMPLETED sessions (post-session payment)
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="COMPLETED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="DELAYED_ALLOWED",
|
||||
hours_until=-5.0,
|
||||
)
|
||||
is True
|
||||
)
|
||||
# Does NOT trigger for RELEASED or CANCELLED
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="RELEASED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="DELAYED_ALLOWED",
|
||||
hours_until=-5.0,
|
||||
)
|
||||
is False
|
||||
)
|
||||
assert (
|
||||
evaluate_payment_followup(
|
||||
booking_status="CANCELLED",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
payment_arrangement="DELAYED_ALLOWED",
|
||||
hours_until=10.0,
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Folio Code & WhatsApp Generation
|
||||
# ==============================================================================
|
||||
|
||||
|
||||
def test_generate_booking_code_format():
|
||||
code = generate_booking_code()
|
||||
assert code.startswith("ADS-")
|
||||
assert len(code) == 8
|
||||
suffix = code[4:]
|
||||
assert suffix == suffix.upper()
|
||||
assert all(c in "0123456789ABCDEF" for c in suffix)
|
||||
|
||||
|
||||
def test_build_whatsapp_link_standalone_and_package():
|
||||
# Standalone booking link includes SPEI details
|
||||
link = build_whatsapp_link(
|
||||
service_name="Terapia Holística",
|
||||
scheduled_at="2026-10-27T10:00:00Z",
|
||||
folio="ADS-1A2B",
|
||||
amount_mxn=700,
|
||||
)
|
||||
assert "https://wa.me/" in link
|
||||
assert "ADS-1A2B" in link
|
||||
assert "700" in link
|
||||
assert settings.spei_bank in link
|
||||
|
||||
# Package booking excludes bank details
|
||||
pkg_link = build_whatsapp_link(
|
||||
service_name="Terapia Holística",
|
||||
scheduled_at="2026-10-27T10:00:00Z",
|
||||
folio="ADS-1A2B",
|
||||
amount_mxn=700,
|
||||
package_info="Sesión 2/5",
|
||||
)
|
||||
assert "https://wa.me/" in pkg_link
|
||||
assert "Sesi%C3%B3n%202/5" in pkg_link or "Sesión 2/5" in pkg_link
|
||||
assert "CLABE" not in pkg_link
|
||||
|
||||
|
||||
def test_build_assistant_followup_link_phone_normalization():
|
||||
# 10-digit number gets Mexican 52 prefix
|
||||
link_10 = build_assistant_followup_link(
|
||||
client_name="María Pérez",
|
||||
client_phone="5512345678",
|
||||
service_name="Cacao",
|
||||
scheduled_at="2026-10-27",
|
||||
folio="ADS-9999",
|
||||
amount_mxn=350,
|
||||
)
|
||||
assert "https://wa.me/525512345678" in link_10
|
||||
assert "Mar%C3%ADa%20P%C3%A9rez" in link_10 or "María Pérez" in link_10
|
||||
|
||||
# Formatted with +, -, spaces
|
||||
link_formatted = build_assistant_followup_link(
|
||||
client_name="María",
|
||||
client_phone="+52 55-1234-5678",
|
||||
service_name="Cacao",
|
||||
scheduled_at="2026-10-27",
|
||||
folio="ADS-9999",
|
||||
amount_mxn=350,
|
||||
)
|
||||
assert "https://wa.me/525512345678" in link_formatted
|
||||
@@ -0,0 +1,138 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app.services.calendar import (
|
||||
CalendarService,
|
||||
compute_calendar_prefix,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("booking_status", "payment_arrangement", "payment_status", "expected_prefix"),
|
||||
[
|
||||
("RELEASED", "PREPAID_DEFAULT", "AWAITING_ACKNOWLEDGMENT", "[LIBERADO]"),
|
||||
("CANCELLED", "PREPAID_DEFAULT", "ACKNOWLEDGED", "[LIBERADO]"),
|
||||
("RESERVED", "PREPAID_DEFAULT", "ACKNOWLEDGED", "[CONFIRMADO]"),
|
||||
("RESERVED", "PACKAGE_REDEEMED", "NOT_APPLICABLE", "[CONFIRMADO]"),
|
||||
("RESERVED", "DELAYED_ALLOWED", "AWAITING_ACKNOWLEDGMENT", "[PAGO DIFERIDO]"),
|
||||
("RESERVED", "PREPAID_DEFAULT", "AWAITING_ACKNOWLEDGMENT", "[PAGO PENDIENTE]"),
|
||||
],
|
||||
)
|
||||
def test_compute_calendar_prefix_states(
|
||||
booking_status: str,
|
||||
payment_arrangement: str,
|
||||
payment_status: str,
|
||||
expected_prefix: str,
|
||||
):
|
||||
assert (
|
||||
compute_calendar_prefix(
|
||||
booking_status=booking_status,
|
||||
payment_arrangement=payment_arrangement,
|
||||
payment_status=payment_status,
|
||||
)
|
||||
== expected_prefix
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_calendar_service_not_configured_when_no_credentials(monkeypatch):
|
||||
from app.core.config import settings
|
||||
|
||||
monkeypatch.setattr(settings, "google_service_account_json", None)
|
||||
service = CalendarService()
|
||||
result = await service.sync_booking_event(
|
||||
booking_id="b-1",
|
||||
booking_code="ADS-1234",
|
||||
service_name="Terapia",
|
||||
client_name="Juan",
|
||||
scheduled_at="2026-10-27T10:00:00Z",
|
||||
duration_minutes=60,
|
||||
booking_status="RESERVED",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
existing_event_id="evt-old",
|
||||
)
|
||||
assert result.sync_status == "NOT_CONFIGURED"
|
||||
assert result.event_id == "evt-old"
|
||||
assert result.sync_error is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_calendar_service_mock_gcal_sync_success(monkeypatch):
|
||||
from app.core.config import settings
|
||||
|
||||
monkeypatch.setattr(settings, "google_service_account_json", "mock-gcal")
|
||||
service = CalendarService()
|
||||
|
||||
# New event generation
|
||||
res = await service.sync_booking_event(
|
||||
booking_id="12345678-abcd-1111-2222-333333333333",
|
||||
booking_code="ADS-1234",
|
||||
service_name="Cacao",
|
||||
client_name="Lucia",
|
||||
scheduled_at="2026-10-27T10:00:00",
|
||||
duration_minutes=60,
|
||||
booking_status="RESERVED",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
payment_status="ACKNOWLEDGED",
|
||||
)
|
||||
assert res.sync_status == "SYNCED"
|
||||
assert res.event_id == "gcal-12345678"
|
||||
assert res.sync_error is None
|
||||
assert res.synced_at is not None
|
||||
|
||||
# Preserves existing event_id
|
||||
res_existing = await service.sync_booking_event(
|
||||
booking_id="12345678-abcd-1111-2222-333333333333",
|
||||
booking_code="ADS-1234",
|
||||
service_name="Cacao",
|
||||
client_name="Lucia",
|
||||
scheduled_at="2026-10-27T10:00:00Z",
|
||||
duration_minutes=60,
|
||||
booking_status="RESERVED",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
payment_status="ACKNOWLEDGED",
|
||||
existing_event_id="gcal-existing-99",
|
||||
)
|
||||
assert res_existing.event_id == "gcal-existing-99"
|
||||
|
||||
# Released/Cancelled booking clears event_id
|
||||
res_released = await service.sync_booking_event(
|
||||
booking_id="12345678-abcd-1111-2222-333333333333",
|
||||
booking_code="ADS-1234",
|
||||
service_name="Cacao",
|
||||
client_name="Lucia",
|
||||
scheduled_at="2026-10-27T10:00:00Z",
|
||||
duration_minutes=60,
|
||||
booking_status="RELEASED",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
existing_event_id="gcal-existing-99",
|
||||
)
|
||||
assert res_released.event_id is None
|
||||
assert res_released.sync_status == "SYNCED"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_calendar_service_fail_gcal_captures_error(monkeypatch):
|
||||
from app.core.config import settings
|
||||
|
||||
monkeypatch.setattr(settings, "google_service_account_json", "fail-gcal")
|
||||
service = CalendarService()
|
||||
res = await service.sync_booking_event(
|
||||
booking_id="12345678-abcd-1111-2222-333333333333",
|
||||
booking_code="ADS-1234",
|
||||
service_name="Cacao",
|
||||
client_name="Lucia",
|
||||
scheduled_at="2026-10-27T10:00:00Z",
|
||||
duration_minutes=60,
|
||||
booking_status="RESERVED",
|
||||
payment_arrangement="PREPAID_DEFAULT",
|
||||
payment_status="AWAITING_ACKNOWLEDGMENT",
|
||||
existing_event_id="gcal-keep-id",
|
||||
)
|
||||
assert res.sync_status == "FAILED"
|
||||
assert res.event_id == "gcal-keep-id"
|
||||
assert "503" in (res.sync_error or "")
|
||||
assert res.synced_at is not None
|
||||
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
Behavior-driven test naming convention:
|
||||
test_<subject>_<action>_<expected>
|
||||
"""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import time_machine
|
||||
|
||||
from app.services.timestamps import parse_iso_datetime, utc_now_iso
|
||||
|
||||
|
||||
def test_utc_now_iso_returns_exact_timestamp():
|
||||
# freeze time at a known UTC moment
|
||||
frozen_time: datetime = datetime(2026, 9, 26, 16, 0, 0, 500000, tzinfo=UTC)
|
||||
|
||||
with time_machine.travel(frozen_time, tick=False):
|
||||
assert utc_now_iso() == "2026-09-26T16:00:00.500000+00:00"
|
||||
|
||||
|
||||
def test_parse_iso_datetime_naive_string_normalizes_to_utc():
|
||||
parsed = parse_iso_datetime("2026-10-27T10:00:00")
|
||||
assert parsed.tzinfo == UTC
|
||||
assert parsed.year == 2026
|
||||
assert parsed.month == 10
|
||||
assert parsed.day == 27
|
||||
assert parsed.hour == 10
|
||||
assert parsed.minute == 0
|
||||
|
||||
|
||||
def test_parse_iso_datetime_aware_string_retains_utc():
|
||||
parsed = parse_iso_datetime("2026-10-27T10:00:00+00:00")
|
||||
assert parsed.tzinfo is not None
|
||||
assert parsed.tzinfo == UTC
|
||||
assert parsed.hour == 10
|
||||
@@ -0,0 +1,43 @@
|
||||
from sqlmodel import Session, select, text
|
||||
|
||||
from app.db.database import get_engine, get_engine_url, get_session
|
||||
from app.models.service import Service
|
||||
|
||||
|
||||
def test_get_engine_url_formats():
|
||||
assert get_engine_url("file:local.db") == "sqlite:///local.db"
|
||||
assert get_engine_url("sqlite:///local.db") == "sqlite:///local.db"
|
||||
assert (
|
||||
get_engine_url("libsql://my-db.turso.io", "sec-token")
|
||||
== "sqlite+libsql://my-db.turso.io?auth_token=sec-token"
|
||||
)
|
||||
assert (
|
||||
get_engine_url("sqlite+libsql://my-db.turso.io", "sec-token")
|
||||
== "sqlite+libsql://my-db.turso.io?auth_token=sec-token"
|
||||
)
|
||||
|
||||
|
||||
def test_engine_pragma_and_session():
|
||||
engine = get_engine()
|
||||
with Session(engine) as session:
|
||||
# Check foreign keys pragma is active on SQLite
|
||||
fk_status = session.execute(text("PRAGMA foreign_keys;")).one()
|
||||
assert fk_status == (1,)
|
||||
|
||||
# Query services table via SQLModel
|
||||
services = session.exec(select(Service)).all()
|
||||
assert len(services) > 0
|
||||
|
||||
|
||||
def test_get_session_dependency():
|
||||
gen = get_session()
|
||||
session = next(gen)
|
||||
assert isinstance(session, Session)
|
||||
try:
|
||||
res = session.execute(text("SELECT 1;")).one()
|
||||
assert res == (1,)
|
||||
finally:
|
||||
try:
|
||||
next(gen)
|
||||
except StopIteration:
|
||||
pass
|
||||
@@ -1,6 +1,10 @@
|
||||
version = 1
|
||||
revision = 5
|
||||
requires-python = ">=3.13"
|
||||
resolution-markers = [
|
||||
"python_full_version >= '3.14'",
|
||||
"python_full_version < '3.14'",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aiohappyeyeballs"
|
||||
@@ -191,37 +195,55 @@ name = "armonia-api"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "email-validator" },
|
||||
{ name = "fastapi" },
|
||||
{ name = "httpx" },
|
||||
{ name = "httpx2" },
|
||||
{ name = "libsql-client" },
|
||||
{ name = "pydantic" },
|
||||
{ name = "pydantic", extra = ["email"] },
|
||||
{ name = "pydantic-extra-types" },
|
||||
{ name = "pydantic-settings" },
|
||||
{ name = "sqlalchemy-libsql" },
|
||||
{ name = "sqlmodel" },
|
||||
{ name = "time-machine" },
|
||||
{ name = "tzdata" },
|
||||
{ name = "uvicorn", extra = ["standard"] },
|
||||
]
|
||||
|
||||
[package.dev-dependencies]
|
||||
dev = [
|
||||
{ name = "mutmut" },
|
||||
{ name = "pyright" },
|
||||
{ name = "pytest" },
|
||||
{ name = "pytest-asyncio" },
|
||||
{ name = "pytest-mock" },
|
||||
{ name = "ruff" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "email-validator", specifier = ">=2.3.0" },
|
||||
{ name = "fastapi", specifier = ">=0.115.0" },
|
||||
{ name = "httpx", specifier = ">=0.27.0" },
|
||||
{ name = "httpx2", specifier = ">=2.14.0" },
|
||||
{ name = "libsql-client", specifier = ">=0.3.1" },
|
||||
{ name = "pydantic", specifier = ">=2.8.0" },
|
||||
{ name = "pydantic", extras = ["email"], specifier = ">=2.8.0" },
|
||||
{ name = "pydantic-extra-types", specifier = ">=2.11.1" },
|
||||
{ name = "pydantic-settings", specifier = ">=2.4.0" },
|
||||
{ name = "sqlalchemy-libsql", specifier = ">=0.2.0" },
|
||||
{ name = "sqlmodel", specifier = ">=0.0.48" },
|
||||
{ name = "time-machine", specifier = ">=3.5.1" },
|
||||
{ name = "tzdata", specifier = ">=2026.5" },
|
||||
{ name = "uvicorn", extras = ["standard"], specifier = ">=0.30.0" },
|
||||
]
|
||||
|
||||
[package.metadata.requires-dev]
|
||||
dev = [
|
||||
{ name = "mutmut", specifier = ">=3.8.0" },
|
||||
{ name = "pyright", specifier = ">=1.1.414" },
|
||||
{ name = "pytest", specifier = ">=9.1.1" },
|
||||
{ name = "pytest-asyncio", specifier = ">=1.4.0" },
|
||||
{ name = "pytest-mock", specifier = ">=3.17.0" },
|
||||
{ name = "ruff", specifier = ">=0.17.1" },
|
||||
]
|
||||
|
||||
@@ -245,11 +267,11 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "certifi"
|
||||
version = "2026.7.22"
|
||||
version = "2026.10.23"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a3/c2/24167ea9858356b47a87a50d39908bfdb72ceeefe0041586e704e5376b3a/certifi-2026.7.22.tar.gz", hash = "sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55", size = 138112, upload-time = "2026-07-22T03:35:12.644Z" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/fd/11/b524cbd9bbdaca58608e4cf4053fd463417549e1959fa8d3aa18319f9555/certifi-2026.10.23.tar.gz", hash = "sha256:a9895e6e2758b371e0545e321a3a8fd1fcfd9829ada8824a936dfb16aaaf36cd", size = 136225, upload-time = "2026-10-23T11:36:16.478Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/0b/a7/71ac2cff56fec219ed242bb11b8efb69fcc4bec75db06fb7bfe35de520e6/certifi-2026.7.22-py3-none-any.whl", hash = "sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775", size = 136983, upload-time = "2026-07-22T03:35:11.276Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/32/d1/a3652fe2c19134d0d15922177821d863cbd7e842d53a21bbe7e8e3a1b5ac/certifi-2026.10.23-py3-none-any.whl", hash = "sha256:e9b54de76e530bb6cf0ccd036787103acb58fd42ba930ea8bf948ddbaa2f61d1", size = 135082, upload-time = "2026-10-23T11:36:14.763Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -385,6 +407,99 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "coverage"
|
||||
version = "7.16.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/2f/55/d1eaf3e73781174340a00dc1ba2aee8a65f82fadb18e2797b192b6b3925b/coverage-7.16.2.tar.gz", hash = "sha256:ca64d9f1f384f151b9511bec01126072acd2f313439f8ed015a22d8790aab6fa", size = 971999, upload-time = "2026-09-27T12:29:01.118Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f0/f6/8eb4f220ef24f84fb27d852d4f9bf83e0c73ec1a4a08dd9a87e3f4529739/coverage-7.16.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1a37c6e478cf687e1aa30a593d19c92c02fad9d122b51ab73f51b8dc7a0c0fc9", size = 223993, upload-time = "2026-09-27T12:26:40.164Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/40/23/d4bbaf0c154e0b0c2b5264890dbf6ef098dcb50ec8f2469be9490d191660/coverage-7.16.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0993d0e90858c03943d3cb152e068a20dd4707924deec84dd2230261baae3b1b", size = 224368, upload-time = "2026-09-27T12:26:41.762Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7f/48/fc1e88fd571ec5cb38150b7f89f7696ca1bdf9920e01432febb69774cc85/coverage-7.16.2-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:bb2fc905bbf4e6b7f40806ea79e31515abf6349594cdf0adf27c4215f0463204", size = 255358, upload-time = "2026-09-27T12:26:43.442Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1d/56/6785397d07c29c8e70fbb9a07e97d062b43c21ffc5f12385917847f09f63/coverage-7.16.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:4358b9c8c0125b460407f3017c6cce8156e904b32772c5630d27112f52bdbfe5", size = 257955, upload-time = "2026-09-27T12:26:45.725Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/27/3b/c8cdd07721e5f99abd81cea970d971997f99bf158c0b85f51bd284179c8b/coverage-7.16.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1f15254427c9b33eedac4f198eaf9e356eb4f6214551afb43da6194a2c088ad7", size = 259183, upload-time = "2026-09-27T12:26:47.208Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9b/11/606b192fe43d32574ec6238549d48de588fdcc18485682a5ec0a8ac357f2/coverage-7.16.2-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:9a75a4704ff640e46170042eec1f984385a121227c505d5a16ad8e495f452541", size = 261325, upload-time = "2026-09-27T12:26:49.084Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/67/90/eea481f8b0305ceeb33f081a5f47e298391dbd1b589de0c4b3b3aa50d3f2/coverage-7.16.2-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:14253fc7bb15749b849795a06f5d3b6d8bc3fb8a4b5ddc341faf7a89dce205fc", size = 255531, upload-time = "2026-09-27T12:26:50.509Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6b/be/dedbf9aea1457b120c27ac10b8fc2a357f37fa2b54c3e7286d42980a0a2a/coverage-7.16.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:921415102a90637fcc2e3f169f61dad7699ecf690e8639fc21b813acbedc0967", size = 257329, upload-time = "2026-09-27T12:26:52.005Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fa/cb/b25c19d5bb2bd0f2e4e27fe8e2ffcae80c7a91ae181c0dc749ed60e9b1a4/coverage-7.16.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:cce2bc991293f15cc4084ca116827b5900c5f34e1a54dfe83f10ab5c43162eb7", size = 255294, upload-time = "2026-09-27T12:26:53.634Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5f/a2/892c5c5f4ad44b7b2ca009aee705191f3f268f15052244f2f9e3539b2e35/coverage-7.16.2-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:e1fa594c887365b69745f25a416806e61085dd07b94c9eae68a6e20730629b23", size = 259444, upload-time = "2026-09-27T12:26:55.243Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ed/99/a562537deba0a3e370182ae71c149be796c39d8087365f17a09188f27145/coverage-7.16.2-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:11e597173af1dc33d5f8a7332ada544199269a223af1ee1770ddd5e245ad0fe8", size = 255111, upload-time = "2026-09-27T12:26:56.851Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2d/20/854ec68641a9b3362ff068a32dfa41637299761617ef253791dbade6fc76/coverage-7.16.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:3e7f99698ba3a7d13988bdd984b7ebf13af4dbe2166dc8502eef90d77603b0a4", size = 256882, upload-time = "2026-09-27T12:26:58.41Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/db/0d/748e4518b0ac0f9ff2687c248a6e5f8c0737306e709372632a2556f84443/coverage-7.16.2-cp313-cp313-win32.whl", hash = "sha256:f80bd9f9633eafc73d0a913ba2645c96ba58bba1befc30590f7c0fbfde59d865", size = 226045, upload-time = "2026-09-27T12:26:59.983Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/31/fa/6e46edba66a183fe4d99d4bb52c173287e9b8dddabe0888d24cb8210e580/coverage-7.16.2-cp313-cp313-win_amd64.whl", hash = "sha256:8be099e979fc42559328a21828281b4578304191ae46ed4e80a407048a82eee6", size = 226581, upload-time = "2026-09-27T12:27:01.494Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1b/d9/9ef6845367600b336ff75d000444a0d32497d6972c833141bd39356abf68/coverage-7.16.2-cp313-cp313-win_arm64.whl", hash = "sha256:28ff850182a67d117990fa2ce5ea1032836d8c9630dae867e8bdd3bff4533b79", size = 226409, upload-time = "2026-09-27T12:27:03.116Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/59/4c/577fc0803dab4155dcf808faffbdd7b159256781c0874a8586e17b81b149/coverage-7.16.2-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:4ee546b9e4872ffa194bf07ac87bfa1202ebb824d0795dc1ef22f175545ca90a", size = 224138, upload-time = "2026-09-27T12:27:05.141Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/75/9e/e3785ba3ecba2bd11efc74bfe2801ca4b78c4480b15a375648d809a59da3/coverage-7.16.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a2fac6895eb299a2e52d7bbb8fb3903502b9da8d3f5309ceb16ec40c646b58ee", size = 224445, upload-time = "2026-09-27T12:27:06.805Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f0/d0/963ff22d3fd27117da3b8cc442f5bdc91196f783321e1a8ff0ec43476772/coverage-7.16.2-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:57ff3783f99d75a1e81dd56a9737eb5665e6736a5d93258ba596b6dcad8fd05b", size = 256112, upload-time = "2026-09-27T12:27:08.43Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a8/d4/a306940c81c6ae759e82fff27d20b7fdc6896e422b821f51313cce212b6c/coverage-7.16.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:35f37886699cb9abd29958247d718628d5bc6f39e623dff66a09e546c42a7e03", size = 258727, upload-time = "2026-09-27T12:27:09.927Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b9/a3/d3d99d93b02517087aa05bc0cf2d04d372956b849e5443e059079901429b/coverage-7.16.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0fd7a86fdda7cb6d616d178654bd0ad6bc0f3f33c2e478aa598500a1a9e34eda", size = 259909, upload-time = "2026-09-27T12:27:11.55Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/08/44/39dd599181726758dd185ae4dc0c0ab3aeabf7ca70e68e145060feeaaa16/coverage-7.16.2-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ac0f3b379c94acc2f7dce5f5f0b24d44fa1cc6a509717ef83dfee07450c2117c", size = 262481, upload-time = "2026-09-27T12:27:13.17Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/99/e8/91ee43f6ded411460c359d7e1aebde4d6fd8f00a2e5394182d9d212eb23c/coverage-7.16.2-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:7d0732c83746bc24123c581a85d9dd96b70ddb538c9076020aa1a041790361e9", size = 256012, upload-time = "2026-09-27T12:27:14.91Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/11/8c/e9499ddc33197bd7eabcb1118ca81756fc874457b324e2b479a4804b2ad2/coverage-7.16.2-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7b451c68218c150f616bc9649783ec8de76a59792c759b43aa0c9c0466a465e4", size = 257898, upload-time = "2026-09-27T12:27:16.588Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5f/6e/c081cb5991a0afba99f9c4ad6c74a5fce9513a38ddc64e3e6680c6fed9af/coverage-7.16.2-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a56ac4fa5a75c7e182e8f62600cfb4aff43c5ed7356a034f3557659c3bec1d90", size = 255938, upload-time = "2026-09-27T12:27:18.19Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/42/1c3d819e8f9b6eb01c2fe90874d67a8882adb9507e0bbb09361ed131ea89/coverage-7.16.2-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:4cc4f73aa3fabc36e32046d6cd2971405948d8a903636508a3d3b2f9128b3a95", size = 260368, upload-time = "2026-09-27T12:27:19.903Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/19/4f/d70eac07901fd587b6ab05e659b52afe13959992aa5113bf6cce059cc572/coverage-7.16.2-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:723dcdab91357159b722935b500ee8abc0a66c8c432e1e9fabf4cc7598952de8", size = 255620, upload-time = "2026-09-27T12:27:21.621Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/34/5e/6d87af88317d3d9a9b18a9ca1bc1673eb516917f296e579d0d4a55cb3490/coverage-7.16.2-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5397e21a90dde0e9c6896b77ded8f0be26b66f8b22b33aed41f6043ed95d55e6", size = 257521, upload-time = "2026-09-27T12:27:23.358Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/79/bb/90c2641170d2fa1a6757b3f8450ba2740197317b0ddd749e9604b914e886/coverage-7.16.2-cp314-cp314-win32.whl", hash = "sha256:848893e1d361448c113dc2f0913503522a6f7be231d0e38333d2a22d9698a011", size = 226248, upload-time = "2026-09-27T12:27:25.153Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/30/08/d8d0478bb02c8eb0ae20a496fc80c40fcf4d3450bd184300d682ba2d28a6/coverage-7.16.2-cp314-cp314-win_amd64.whl", hash = "sha256:5a27b731c171e43dc8b5f32b76a5051dde2ec9b9366c87028f08a7088ebc2c7b", size = 226732, upload-time = "2026-09-27T12:27:26.907Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/32/3f/0001da22155b0a8ce063ec0f7e64ecbe17b373f306e7a74435f6d6accb72/coverage-7.16.2-cp314-cp314-win_arm64.whl", hash = "sha256:1c569a9fd25505f1cd6bea90588818f90373ce90e2632e2cacf19ddbd6e14fdb", size = 226645, upload-time = "2026-09-27T12:27:28.588Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/85/6d8813aff9b8b8586691a9d33c43c5604f7227622574da7cdc3d91a86861/coverage-7.16.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:d93db87adb6b1c1b408dce4763314b55d76a9f589e96783a84ac9e7689e48bdf", size = 224871, upload-time = "2026-09-27T12:27:30.32Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5c/70/444f3a4981ac2cda40fdcf4cc9b56a4e1a33c222abeb33e51ed3e3eb2a6b/coverage-7.16.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:aa62c85046473959c13ba9edca9dc90a77d5c1095b1ba313556314d77fe5b036", size = 225123, upload-time = "2026-09-27T12:27:32.33Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d0/c1/980681cd7b33eb66ac835044116ef0a92e11fcc7bdd866cc89d10b1130b9/coverage-7.16.2-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:db76506aa5416081f3e8974ae0f7965c58ada0bb0ef7339ac86099588dbb20d3", size = 265049, upload-time = "2026-09-27T12:27:34.085Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/e3/87679875c33bb2191f0f05544a1cc9adcc940fe0c35443a10f2df753dde5/coverage-7.16.2-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:a0f2285329dac10ab08f79cb11f5692c497018e6c7c511f95e6fd63a70b8f831", size = 267717, upload-time = "2026-09-27T12:27:36.025Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/76/64/5d372776d6eb523d4e93bafba2253f96984e3b18261c4cc56a50863c6d0d/coverage-7.16.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:382d3346d56b0eec1b793d53a4c88799c8053f516aa3a8d7c44315696954bacf", size = 270047, upload-time = "2026-09-27T12:27:37.96Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/be/c1/44082ff0cbf9f97d0043f57970a71204097ec7ba606361a9fd2065393669/coverage-7.16.2-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:648352b94507179d82637292e7ae8802508d95f78e2f00a705a50b6c48011681", size = 271360, upload-time = "2026-09-27T12:27:39.766Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b8/17/9a215efe25b5e0ecc87c89dbe525c4a87d14d87c8c0c7316ef140a5f6f3e/coverage-7.16.2-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fb2bde05838fffae1a1bf75e5d411a6cac3e4e9bb97e6640fed8cd47888b33f0", size = 264736, upload-time = "2026-09-27T12:27:42.072Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a2/da/7f0a31af8e448107d4d32844bd684757f51ea907bc0c68c8fd537b2123ff/coverage-7.16.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:6a75180829efb8ae62b4aded25be6ddca1c888d138d2d82e21d93bfbd88f41cb", size = 267600, upload-time = "2026-09-27T12:27:43.85Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/dd/a4/3bfecbd3366b775bacdcb3330394d356cf384b5d8f5b2146ac4b14b252b5/coverage-7.16.2-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:99704f73721e23859112072d522076e11c31744fc96b5652e5dd2018aa4359f7", size = 264767, upload-time = "2026-09-27T12:27:45.768Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b8/3f/5d62163732d87e4a0c4710a0eab30f0fd6a2d480112abe2029f014fe8c9d/coverage-7.16.2-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:29309ccc86b7f33df7db12813c299f215bbbc470ed6292d0bedd63ffae1ebf64", size = 269026, upload-time = "2026-09-27T12:27:47.787Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/49/4d/8e4579f225426535085a9be371cc75e3b026d058d679b80affbdfb4c3ef0/coverage-7.16.2-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:30c1b65d529e46569899fadca59e4a87c1faf2886923f1307ba61e654d4f3c20", size = 264147, upload-time = "2026-09-27T12:27:49.681Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/36/ef1f77e2c3f7bb03c2b13b9a2006f88700fdd75535ef158d70049f425c1c/coverage-7.16.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:dcf4bc2aab4e16b1c4c0c2005918f23a7dd5d7821ddae82caed9e3342dc2fcce", size = 266376, upload-time = "2026-09-27T12:27:51.551Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/be/79/0cb2bf4428830dec971c718c2c841a039c084415c99e67281f5a72841aab/coverage-7.16.2-cp314-cp314t-win32.whl", hash = "sha256:a9cd3de0a5bfe7b0e21ee10e1a14e3d61bf52efc88217ab1d95d6ace6970bd46", size = 226585, upload-time = "2026-09-27T12:27:53.945Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3c/f9/da17121c16667fd84998e972200ae226a41540f6ea4795776c6d99e8976f/coverage-7.16.2-cp314-cp314t-win_amd64.whl", hash = "sha256:611a44e5229a59d7483ce830160e1a0e85f700562c7a5651c7c63fb8f4eb528c", size = 227378, upload-time = "2026-09-27T12:27:55.778Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/74/89/01179c62d1b7e6e33bd5001566b02d7f778cf33d3ec1e81e94ca170c517f/coverage-7.16.2-cp314-cp314t-win_arm64.whl", hash = "sha256:22957cef43ce038641de78ba995de7568d2d6a37c6ddbf7fa0fd7d1ae2344d91", size = 227064, upload-time = "2026-09-27T12:27:57.496Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4c/57/52935003c3f627ba6e5203d7179aad32448c10899663a30336aba8e81a2c/coverage-7.16.2-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:414c26dfdb96aac2d570a54e03008f001e32eb2d413705365503648c6bd361d8", size = 224140, upload-time = "2026-09-27T12:27:59.343Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/31/38/df472520f3e626524d7e2fc9d6da0afe7895a2f1489d36b48af8ca40bb41/coverage-7.16.2-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:00d3eb96e9988c45f50cccd1f1496571ac5c1f91386ac02c4d55516eeda19a24", size = 224449, upload-time = "2026-09-27T12:28:01.299Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0c/aa/3be084d5b82e63ccdad4ed751e4acbae294673573e30481d29f8b7402eec/coverage-7.16.2-cp315-cp315-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:4dbbd1155ca46e6e0b6b89d204428c56ef6a459af21333f365d135a2820e5a09", size = 256060, upload-time = "2026-09-27T12:28:03.185Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/de/29/48fca82a7ebf7ff7b2e35019cc9537e7f65e4d2aa1215cc5a8792c989251/coverage-7.16.2-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:8fc15cc8d0d06e873c00ef18e1372d605f9aaf3de27d8c24e50782e75bc8b843", size = 259106, upload-time = "2026-09-27T12:28:05.15Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/06/3d/b2d5986f2dd53fe201aa1be2e4ab204fa1aed5101e67c0dbbb419b850aee/coverage-7.16.2-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9c6afdd69218202bc1758c9a14b86b8cf1084f37ed2ca143e567a103772b16d1", size = 260674, upload-time = "2026-09-27T12:28:06.868Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ce/7e/b50160be3506ead12e6480d14279af7f0f17627694300a2d1fd2c42d2ff5/coverage-7.16.2-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:aba5c63b7afdc749cc9eae943d5b868cba2b261a176378fa1c5a30bc8bc89982", size = 263139, upload-time = "2026-09-27T12:28:08.771Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/14/5e/7c805ac9a32606de1399bd7e9bd375aa2f973dc61b12680d9e6403c2e891/coverage-7.16.2-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:9174f0af24e5eff248b9dbfe76ec5275a3d19d37edbc2810543f12cf97347a34", size = 256591, upload-time = "2026-09-27T12:28:10.842Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ab/9e/76f1ed129a2daf658a3ea17122824cf2e3b91fea0460d8d3664fc5a61018/coverage-7.16.2-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:80e9fdb4c3d926b6ba721d4bf7435bdb869c3527ae7803290361d0ab73db13b6", size = 258708, upload-time = "2026-09-27T12:28:12.962Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5a/b7/8d62e75f48b527619239a65294f842d4b7fd02a0839d43ae1de80184e2df/coverage-7.16.2-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:7b3bce4a0d05401d70b7d0d5ca783e686bc9d30e81dbd7d980d532609bf809e4", size = 256562, upload-time = "2026-09-27T12:28:14.934Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b8/8d/0a15f95c3afb78e947c52644786ba4bc9de259905687dd720d5e6fae2e76/coverage-7.16.2-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:44f21e407b278efdfc1ee5e481e00518bd1d500310a30a5fbf2bcbedfef4aaf0", size = 261077, upload-time = "2026-09-27T12:28:17.215Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/25/00/88389987305a47d732866c07c8a500000ab574df9505e3114ac69c8d027f/coverage-7.16.2-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:59c3926585e1cd1f2190f4b2ac9014de1bbeaf0d5d0587b0dc6b0aa90d17896a", size = 256034, upload-time = "2026-09-27T12:28:19.08Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/92/02/34d079d4952ad461bde037d353f9a6e037a7edc45fe0f9ee8781ff73f028/coverage-7.16.2-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:066429634299e14dd2d511e1e85f8f9cecc500781f6b41907c0dd6f1baea7e63", size = 258034, upload-time = "2026-09-27T12:28:21.242Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f6/d8/3e59a62879285b464ec1b10fd824fbc1af9ce66e842cd39974f80a0becc4/coverage-7.16.2-cp315-cp315-win32.whl", hash = "sha256:893ea9cf86cb8d2546812ac93d973aaf2ee1fb45110a873b014214fd23e3725e", size = 226252, upload-time = "2026-09-27T12:28:23.102Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f4/e1/128026e1b2836e9ad6b219207ba9edf1c5e0088a7869e23088aee7fbbe7a/coverage-7.16.2-cp315-cp315-win_amd64.whl", hash = "sha256:01c6908bc613b420c26c818fe948e1b97dfd041a53c98b01c63bd8321f5c9aae", size = 226728, upload-time = "2026-09-27T12:28:25.21Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a8/f4/c9fa8e7cf525ca7748ac52b0ee89331d13fe09808e45c679830708782e90/coverage-7.16.2-cp315-cp315-win_arm64.whl", hash = "sha256:967d72c835d7a8cf0af99ec813a2d06e3db6df706402f1fe85b31b437645f495", size = 226648, upload-time = "2026-09-27T12:28:27.136Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a2/13/e96b045447a856666f36f9c653e2a80bdaa732aaaf72412b19aa2c26a473/coverage-7.16.2-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:98d9c97f51b334b0adce7b964442a9af33c1a00c6ac856984cc5dc8d18f81c75", size = 224858, upload-time = "2026-09-27T12:28:29.169Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/23/90/087f6ad1bd3df059632ca3407a4e6552ed1053ee35354de0a771acf35423/coverage-7.16.2-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:3e861f1071dcc2fec1e88bef0920f6b1eaa66a143555b4f8ab79ba2b0f30ef55", size = 225139, upload-time = "2026-09-27T12:28:31.131Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7e/8e/285dcef0184358044e7cbcd810a1bdc9566bc620f54702d605477155df4a/coverage-7.16.2-cp315-cp315t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:fb9d92ecfe2d5b494367c67f7446f8b75b68d8d0c8cf3bc3e6997478be25d9e2", size = 265090, upload-time = "2026-09-27T12:28:33.04Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/06/b2/cc83f3a6e5789a4e89059c69555bc641c2efcde568405a1c06fc702951ab/coverage-7.16.2-cp315-cp315t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:eb57acff4a74246ae513c142d4b36e18c389c3aed8661914a53f7cd0071031b2", size = 268254, upload-time = "2026-09-27T12:28:35.135Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ac/41/f548c19530f5d66ac6e3c92bbcbc49da7261de3a458b9f3e54a3efb1a0b2/coverage-7.16.2-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:444889f7f66b74e4455c0a97e0e166dd41177f1dca8c0239a47cff25e05ba7e1", size = 270695, upload-time = "2026-09-27T12:28:36.959Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/94/61/4dc27cf82ef96434d2874110ad0cc10ea4621025705dc5049862bd3bd181/coverage-7.16.2-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a740ea6f083c6db7b926534d159508f80ba275ab35e722522de0d18d0f56e55f", size = 271853, upload-time = "2026-09-27T12:28:38.821Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/38/29/bf8072b1b8bd5f2de8b21460a404460b1a2b97e80a9464c78ec0271f6199/coverage-7.16.2-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8e209591f7c41ae4a9171335cf6156afda0b21de73b02f73f5aa95b2d5fbb08d", size = 265644, upload-time = "2026-09-27T12:28:40.815Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7c/2f/0aecb8721be5cdeb8afd9d6d9f6b463f074e4d8d37f00f4c42442522709f/coverage-7.16.2-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:396bb16e04ce04efbb3df91456ae4e3da918e69ecdf67fb711b0a0fdf35ccce0", size = 268530, upload-time = "2026-09-27T12:28:42.725Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ab/0b/92b4b7628268ee711249958e68fc0328779bd3d9a7ab4715379465aedb84/coverage-7.16.2-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:9cdf19874e0d247f32f03609200370343c3c7aa260b191d8c2bb251d36198283", size = 265154, upload-time = "2026-09-27T12:28:44.684Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7b/d9/41c95c1ab29b3dcd357cd1227181d1c98185632aca41ce670ce671b23a43/coverage-7.16.2-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:fd3d72233eb8b48acc94fa57d44e2d32ce8e7abed02882ccb6d855ccc4ed33ec", size = 269799, upload-time = "2026-09-27T12:28:46.672Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/80/07/ebeb259aa5362b033a137b86d7274ff4b109d59be8cc9913889b783bf75a/coverage-7.16.2-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:bb4ffe96aa663cee727659db5a2afeb38c95f8677b747d447b90d6d4874ea2c5", size = 265196, upload-time = "2026-09-27T12:28:48.996Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/18/8437620f90d023680a072eee02f968055f3658bbfb7d386d0ea34cfb7f30/coverage-7.16.2-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:dba2edfb054f6d4a08df9d1637c39a5aa3865bca6617c13c86be21e45658a59c", size = 267266, upload-time = "2026-09-27T12:28:51.361Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/28/6c/f08e8ee4293e6434035424180bef4d45e028e8ecc006c61bf9453e74405e/coverage-7.16.2-cp315-cp315t-win32.whl", hash = "sha256:251aed777c47c77aba047096d4542889db089227655711dfc2b9c54ef0e15e35", size = 226583, upload-time = "2026-09-27T12:28:53.33Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f7/fd/3f939c2847f4a72c20cff8b1ac33da78ea91a2d38d9b43336e60db719103/coverage-7.16.2-cp315-cp315t-win_amd64.whl", hash = "sha256:2aca0bdfa9e91621d5b09d815357bf63def4fc0e9cb66da67bf2cf93f3b1a6f5", size = 227374, upload-time = "2026-09-27T12:28:55.158Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5a/35/b98cdc354c952402132e675a87f2cc3227fb68f959c84aaa491fbe15933d/coverage-7.16.2-cp315-cp315t-win_arm64.whl", hash = "sha256:b88841e654f09732804809e435b3e005a929ffd9998b872b7b213957b8759cb8", size = 227064, upload-time = "2026-09-27T12:28:57.075Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3f/0c/7a64e1ac90541a8edf50daef0914848011fb057a5bf55284a4811e21939a/coverage-7.16.2-py3-none-any.whl", hash = "sha256:11d28e9123a9156cb405d8d27b44256c9a58fb5decc2073a8f17862057e3aa0f", size = 215754, upload-time = "2026-09-27T12:28:59.075Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dnspython"
|
||||
version = "2.9.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/ef/4a/50822184bd67cc6493f0fb6a880749158fcd31ab3fa07409acfd91f9fc85/dnspython-2.9.0.tar.gz", hash = "sha256:b44dc6b18f07a8b1c56676a19fbfdb5209415b046a9cece286baafa87ff3f7f1", size = 423560, upload-time = "2026-10-09T00:07:24.352Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/10/02/cdcc9b7c051786a103c3b09e1003a82fa0c66bcb91ffbdabcfbf7b4163b9/dnspython-2.9.0-py3-none-any.whl", hash = "sha256:9a4aedb833c3c1b49214d04d44d3032ab7a9135f7c1d29a549b4ff78fd82fda9", size = 354822, upload-time = "2026-10-09T00:07:22.622Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "docutils"
|
||||
version = "0.22.4"
|
||||
@@ -394,6 +509,19 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/02/10/5da547df7a391dcde17f59520a231527b8571e6f46fc8efb02ccb370ab12/docutils-0.22.4-py3-none-any.whl", hash = "sha256:d0013f540772d1420576855455d050a2180186c91c15779301ac2ccb3eeb68de", size = 633196, upload-time = "2025-12-18T19:00:18.077Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "email-validator"
|
||||
version = "2.3.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "dnspython" },
|
||||
{ name = "idna" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/f5/22/900cb125c76b7aaa450ce02fd727f452243f2e91a61af068b40adba60ea9/email_validator-2.3.0.tar.gz", hash = "sha256:9fc05c37f2f6cf439ff414f8fc46d917929974a82244c20eb10231ba60c54426", size = 51238, upload-time = "2025-08-26T13:09:06.831Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/de/15/545e2b6cf2e3be84bc1ed85613edd75b8aea69807a71c26f4ca6a9258e82/email_validator-2.3.0-py3-none-any.whl", hash = "sha256:80f13f623413e6b197ae73bb10bf4eb0908faf509ad8362c5edeb0be7fd450b4", size = 35604, upload-time = "2025-08-26T13:09:05.858Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastapi"
|
||||
version = "0.144.0"
|
||||
@@ -484,6 +612,63 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/9a/9a/e35b4a917281c0b8419d4207f4334c8e8c5dbf4f3f5f9ada73958d937dcc/frozenlist-1.8.0-py3-none-any.whl", hash = "sha256:0c18a16eab41e82c295618a77502e17b195883241c563b00f0aa5106fc4eaa0d", size = 13409, upload-time = "2025-10-06T05:38:16.721Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "greenlet"
|
||||
version = "3.5.6"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/3e/6e/0091f175ccd02b02bc8811bbcbcc6ac2e980be116e3b2f7a736ca322bf84/greenlet-3.5.6.tar.gz", hash = "sha256:8e67c43bdfc88d5fee6db0d3e40175b362fc95fb85f0412d233b9b203c53a575", size = 207653, upload-time = "2026-09-14T15:42:51.806Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f1/a1/e720a38852366c589e1a46cf570b886507ad2cf591050c203365638baab0/greenlet-3.5.6-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:f96f0e30b5a95c7631b12bfe214cbc90ec8fe8cfa36920596c10514a65743519", size = 294627, upload-time = "2026-09-14T14:24:40.102Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/eb/c3/58187858df41354a11e6a55b421e7af9059798abdab3a384cc51b8567c38/greenlet-3.5.6-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c75116c9de79949de23006e2d9b35ee82874c594fcf5c0311b439acaa14b8441", size = 614356, upload-time = "2026-09-14T15:12:03.399Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ce/b9/3a7e67d5f05c9760b1ad411fa52264bd69cc08e22a2ebfb4018b90628ced/greenlet-3.5.6-cp313-cp313-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:cad5782f93f7f738b62c6527b6f32a60694d924029f299a8b524758cfa53d815", size = 626756, upload-time = "2026-09-14T15:20:44.269Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c6/7c/40400455f5b5a65bb83e94fde66d1be9e5ec518638113f8083ace746c309/greenlet-3.5.6-cp313-cp313-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a93ee7c6e8fd0f8a83525a51bd777be57ee17787e91d805bd8d6faf9dcada18e", size = 632632, upload-time = "2026-09-14T15:25:07.813Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/85/cb/ab0c123c514ed4e94c0dc9ee2e86362633e6b998cfc05de7fc9ac2eb9690/greenlet-3.5.6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f98e8215e172f567ce80eeaed9107fb4d32b6c44f26983d9b8334658136a205a", size = 623779, upload-time = "2026-09-14T14:36:01.104Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f9/67/1f35cff30a6c51c3f23b63d4afcc7313ab4f97490ba3676fa78178984b27/greenlet-3.5.6-cp313-cp313-manylinux_2_39_riscv64.whl", hash = "sha256:7f731ebac68ea06d628658295cb2d217b10186329fcf9a3b6a149045059bf92e", size = 434933, upload-time = "2026-09-14T15:28:38.858Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a5/26/fda8a5a06e7073333ccb038133c5893b9e0c4fe29d5992a17e83c241bc6e/greenlet-3.5.6-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:df19e2d0b1620039af5102563fbd96e8938c7f5c3f5828528d641d9fc585525e", size = 1584930, upload-time = "2026-09-14T15:10:08.234Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2f/37/50f8813163148d6234e08b23dcad6a9e37f01d148c8ec976e4c44ea2d918/greenlet-3.5.6-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:06c0e933290fba8ffe53ead4ae1b8044b0e9754b75cebf381aa2bc3e50d82fac", size = 1647590, upload-time = "2026-09-14T14:35:51.173Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/86/da/b7669b09586365654083a62bd0724cf06cb74bd5085a15cdd161271f992f/greenlet-3.5.6-cp313-cp313-win_amd64.whl", hash = "sha256:5b602b4201b965a8354d74e232364a66ff243dd142e350d035f46169bb36e13d", size = 324086, upload-time = "2026-09-14T14:23:48.428Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e5/5d/c9663cfe84a2a9e0aa96f066f5b0594c227ea4c647511e087e2e11d4ac0a/greenlet-3.5.6-cp313-cp313-win_arm64.whl", hash = "sha256:876077e7ebb8c84ed068e2b23d4c62ebb010d60df84b9591af1be2f39010ffb2", size = 308211, upload-time = "2026-09-14T14:28:01.634Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/66/c0/d254544ae2b8bdd311aef000fafc02828c2771b17d994b3075620ea7cc6e/greenlet-3.5.6-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:8cddea1b8339451c2fb3388e138347b6126744f33b611bdb55b7357361cfef46", size = 295221, upload-time = "2026-09-14T14:25:11.583Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/18/18/eb54be16b9cc3971e09ca5b73334e1b8c804a4630d9addaaf218a4fe300f/greenlet-3.5.6-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c59acfa8eb73a1e0d484392dc002bdf001fd4ce73394e0132df3d1ab6093d7cb", size = 660992, upload-time = "2026-09-14T15:12:04.876Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8f/b4/e193efe65671dcf294bc51fcc59efb52d154adf8612c4ea016da0d2c486c/greenlet-3.5.6-cp314-cp314-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a3b4a01c6da07ef9f80d4fe8933b994bc99747bcea3eab0330a9c34d3c12655b", size = 673428, upload-time = "2026-09-14T15:20:45.756Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fd/21/631bb45fafde1dca782152377c0676d182ec924820064047f533a3627b28/greenlet-3.5.6-cp314-cp314-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:dd0b83bed3405b586a3133629f1d1a5bc7bfd64822a3b7ab342bdc68e6dbc61b", size = 677688, upload-time = "2026-09-14T15:25:09.279Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/45/ac/28fa7a9e50f2859466214c4ac584d776db52c1604ad4dd158960a5af2a1f/greenlet-3.5.6-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9a09d59bef1db94f384b5bcc2d523694d338f3df6b757aeeaf7baca5d0c0be88", size = 670773, upload-time = "2026-09-14T14:36:02.577Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/40/30/2b0a73e68e1e18e30b601d0d183cfdfc2beca4de5a6843c630f0fc9fb90c/greenlet-3.5.6-cp314-cp314-manylinux_2_39_riscv64.whl", hash = "sha256:fdacf26402389bdd89857ad3c045a26fe8f3314f9a8b28226f82f88463a65b77", size = 480475, upload-time = "2026-09-14T15:28:40.741Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c3/cd/fb7d6cdd86ff3427c1494854f0e35437eba05142be91f530f6da75e09e19/greenlet-3.5.6-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:8b7c73d1cef3d9ae963e9ff03f6222df43efbb9054ffd2f1969c935b7fc84c02", size = 1631900, upload-time = "2026-09-14T15:10:09.745Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f6/40/143bdbb20a516628cb15074ae52ed17d850b450292609c7a6fccac6dbece/greenlet-3.5.6-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:8b27df301f56e3b3d2298095c8f7d6b68f2521f6b1693e901fa039bdbae34424", size = 1693740, upload-time = "2026-09-14T14:35:52.959Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c9/9e/019642432e6ae283301df1361227d47610709d2dc69a38f95edef266d713/greenlet-3.5.6-cp314-cp314-win_amd64.whl", hash = "sha256:f8f0bd690e1a41294ac87905e8121c81a3761ec2583c768f13467428606c8c7a", size = 327473, upload-time = "2026-09-14T14:28:12.948Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/7f/8aafc7bf70c948786dba7221d0dc0838e5329bebc6d434ef2208b4f0e760/greenlet-3.5.6-cp314-cp314-win_arm64.whl", hash = "sha256:8cda13494d86a4f12429641117cb6ac4bbbc9c30a33f711f7d3a2e5fbe4b0b7e", size = 311095, upload-time = "2026-09-14T14:28:00.7Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/14/7e/7a205688a5b3074933b18a906608d46d106e9a79d776bdab5a4abf4b4feb/greenlet-3.5.6-cp314-cp314t-macosx_11_0_universal2.whl", hash = "sha256:97c5a53e8c1754df58e73f047a99e287d4da1bdfe64b0072fb25c87000897951", size = 305352, upload-time = "2026-09-14T14:21:31.962Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/78/cb/9c4a57a9d9dd0256e20b8f7f4f06554c2c92badebf0ab73ce344321b78b9/greenlet-3.5.6-cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fea4427d1ffdb3b523d7daa6712038428a4c16c450b9777bdd1221cfee0eab49", size = 672671, upload-time = "2026-09-14T15:12:06.347Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/97/52/c6729681ebbd298f4decd28746815acc8a0b0a0fde21d2df33776fd4d042/greenlet-3.5.6-cp314-cp314t-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:73a29b5ba642e35433166a03a3e02935e7238c4b3467fbd77523b99edea23e5b", size = 679489, upload-time = "2026-09-14T15:20:47.291Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/71/76/3c11c21e0716b1f1dc7c1a4b3d690abb1d3b448c69a9d32049fecb64010a/greenlet-3.5.6-cp314-cp314t-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:61a61b4a95a4f97922c3a6f5606d3e360851584bd47e500a5161373c53810e3d", size = 681303, upload-time = "2026-09-14T15:25:11.088Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/58/c5/2b6c721ba8b8963da42d5a0f57f25b8aaeb1fe9bdd156875e57f3be648a2/greenlet-3.5.6-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:460e70b033aba8ed47e2ac9b5d0d2157b05a34fbfa30a241400aef4118902cdc", size = 676608, upload-time = "2026-09-14T14:36:03.959Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3f/26/3ae402202452cd5941bbbd483e5a74297e2397e7aa3182c2a5e3ab7d5666/greenlet-3.5.6-cp314-cp314t-manylinux_2_39_riscv64.whl", hash = "sha256:fe3170a69fe039b18ad18171e66faa9a75f6fe9d78f968fd9b54e09fbd714d81", size = 510112, upload-time = "2026-09-14T15:28:42.112Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/04/0d018e0d05bcdde19a0fcb907834155f1fc853a9bedd3f3f5e6acadcae19/greenlet-3.5.6-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ca80a49b53ed1d22f7282da7255f7bb2fd1935fd0f623d8613fda38745f18961", size = 1641479, upload-time = "2026-09-14T15:10:11.216Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/59/bb/f02ef9073919158f6403fe3701d4ed4403d646720e7201dfc6e9d264bac3/greenlet-3.5.6-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:916f92f2a8db10508f739d0b5e00b83defe5d1115a997c54532a6d7cf8c95404", size = 1698758, upload-time = "2026-09-14T14:35:54.336Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/08/a5/1f48fe647473a2dcccfd1839b2ff2c78eb57009be776b4da071e901c9bff/greenlet-3.5.6-cp314-cp314t-win_amd64.whl", hash = "sha256:886bcf1870af74c32bc310fd00a6b803445e17e51b7d5a107c7b35c0f362cc16", size = 331574, upload-time = "2026-09-14T14:27:18.451Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cd/72/3882855a75838faeb54a58aeef4fd77d20b2a86d4bad570c70d41b565dcf/greenlet-3.5.6-cp315-cp315-macosx_11_0_universal2.whl", hash = "sha256:3ac3494c381dab876cad7d0b22f3a722f3e0c8deb3a65b9e7f35ad7f58b8fcb3", size = 295926, upload-time = "2026-09-14T14:27:21.16Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/10/1f/be4d957d8a9b90bcbe8db206548a42134d96222d43e5ed3fc4708fb6e24b/greenlet-3.5.6-cp315-cp315-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:602024dae6d77e161f4b89491b62ca1d4f19949d79d47b2db057e476d21179d6", size = 666910, upload-time = "2026-09-14T15:12:07.901Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a1/af/60d62571a7d6de961e4ce7625d6c2faf359345659fc782d2cdf517c34577/greenlet-3.5.6-cp315-cp315-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f8e63209c3e1e828ee6a457529b4a6d8b05d050fe0ae03a7ae49e967c5d312e0", size = 677415, upload-time = "2026-09-14T15:20:48.817Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f5/41/b3114c97c10e796010f00a30f51c81470072bca4b53e396ccca87484fcf7/greenlet-3.5.6-cp315-cp315-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:9133d68624b1f2e89ec2f554d56aea8a5b0d7168cd9320200ba58d4d794845a4", size = 681337, upload-time = "2026-09-14T15:25:12.812Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fb/16/ac9e547b611539aaed1870eb1d6ddc57abdd5924b3a99bb9b5f0b44176b8/greenlet-3.5.6-cp315-cp315-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ccadce0130fd813ec86ebfe969a6c58b42acc1d0fe55a47525375b740e07b605", size = 675927, upload-time = "2026-09-14T14:36:05.34Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/48/1b/d41861c2fa00968e39e467a495ca8db9ce9b6310a5d9b57561b3d0dc48fa/greenlet-3.5.6-cp315-cp315-manylinux_2_39_riscv64.whl", hash = "sha256:5adcbbfe78bdc242c71740a02e0991cc1b2f34d33c8bb15ca45eee8fd1140942", size = 487339, upload-time = "2026-09-14T15:28:43.497Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c4/b1/b7ba08d6431121741f1d30be0d5d292e76873325179a63586cd9217b62f6/greenlet-3.5.6-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:9297fb9c39b9a2c039dbcd306c410bd6906b95244dec3bba4318d36c718c164c", size = 1637236, upload-time = "2026-09-14T15:10:12.442Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/af/c5/3b1cbc68f0c082022fc8717f7fe4b8b13b8d583c52352be37f4e9f55bcd2/greenlet-3.5.6-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:b374e79ffa7511afc11773aef40a4ccea6191fba1c856ea2f9c56738dca69d7a", size = 1698526, upload-time = "2026-09-14T14:35:56.039Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/de/56/12941ed2711400451c89d544e10f831800a2770f19dd55eac8f0f7f2003b/greenlet-3.5.6-cp315-cp315-win_amd64.whl", hash = "sha256:7969bffa322c097bd46ae595ada6a931cefda613f18ba64587e9cff4cb320756", size = 327739, upload-time = "2026-09-14T14:23:55.768Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c5/3b/576b9ed5ac929252e340cf60b4bcb6a8515350dc20797064b1922dc4ea75/greenlet-3.5.6-cp315-cp315-win_arm64.whl", hash = "sha256:8dba0129b93e7091dfefaf4cf7000172741bff7f47bf6326fcf17f32fbb54d6b", size = 311715, upload-time = "2026-09-14T14:28:25.154Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/16/c2/86cfc5555a98e12b86966ddbd24fd39af32f71f2f785c6595b7feb2db156/greenlet-3.5.6-cp315-cp315t-macosx_11_0_universal2.whl", hash = "sha256:de3de000d459402cda015068fd135aa50c0bf6f2477a80d4da1e646f123b4e78", size = 306244, upload-time = "2026-09-14T14:27:57.565Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/14/6d/83ffc9d05a75a80ab3a7595dbb1d9604e5d4fc2996d73a8ae2dbd1284900/greenlet-3.5.6-cp315-cp315t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:45663c01a4de48b9a64a2ee1509d92d1dfd3afb02b2ccfc9333029d11aef996a", size = 676578, upload-time = "2026-09-14T15:12:09.468Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5d/d6/c2cf684810e5caded075970aaadea654ecb58b8382b9aecf1d231b936894/greenlet-3.5.6-cp315-cp315t-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:3deccbb57a481e3a408fe61cdfd5c13e0678fc0a30fdd09597917ca87b4be877", size = 684203, upload-time = "2026-09-14T15:20:50.261Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f2/d1/039c353d5593a97a89699e989324c9bc86af499e6c6152fe0180f5742204/greenlet-3.5.6-cp315-cp315t-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:63aff70fe5aac59c72215f42ec39fcb59ff46774fa966e717f8ecb6ee2273577", size = 686023, upload-time = "2026-09-14T15:25:14.528Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/62/19/00e1bee5d2af890dc8f400b54d0b0f9b489965f92bc12b407ff72cc6f469/greenlet-3.5.6-cp315-cp315t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:311018b46472fb26ee85870847fb89eb64cc8aaddb617400789d87076f7cfeec", size = 681253, upload-time = "2026-09-14T14:36:06.742Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8a/62/97ceb8e0b2ea96046cdf8e95b042715020ebb12d83ea0690db80a8f03d23/greenlet-3.5.6-cp315-cp315t-manylinux_2_39_riscv64.whl", hash = "sha256:520648db8fb92eef7b3e6013f5a6f901cdf0d6685f639c2f7a245879f865bef7", size = 517058, upload-time = "2026-09-14T15:28:44.924Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/89/58/c9275fd0ca195d1d3402931bcce8cfcc74726ff76efb1883d229e6e1a3d7/greenlet-3.5.6-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:7f924a5a9d5890649566f2f6682e0d8ad8ca23028bacffbbac36dbd7fd680176", size = 1645988, upload-time = "2026-09-14T15:10:13.758Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e0/36/b35747582fa4f1a5453f8f3002405dbac788e450cec7674dc2d204b6ccb5/greenlet-3.5.6-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:de9923832f2d8c1a5ecd8d7260465a6ca5a86888a0d129e3bd5cf0406d2fc5bf", size = 1702383, upload-time = "2026-09-14T14:35:58.143Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ed/69/6ec22ac9351e474d2a134d0ff9400dc80362d1c20f0721088ffffdfc205b/greenlet-3.5.6-cp315-cp315t-win_amd64.whl", hash = "sha256:2ab5f42ac6c238eb71770715e6e909ad9a1a92b6c681ccb64cd5a0f07edb953f", size = 331845, upload-time = "2026-09-14T14:27:41.723Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/30/cf/697c051fd534e223461fb8b523890e21a24eeca229cd50624cff6f02fabd/greenlet-3.5.6-cp315-cp315t-win_arm64.whl", hash = "sha256:f9fe868463ec7e1363733af77e38a5fda3e9b63940337048c945d69e0c80ff24", size = 315070, upload-time = "2026-09-14T14:22:21.476Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h11"
|
||||
version = "0.16.0"
|
||||
@@ -506,6 +691,19 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "httpcore2"
|
||||
version = "2.14.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "h11" },
|
||||
{ name = "truststore" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/30/ff/b53af1b49bb2cb5fa97c92215614b173ca5c1a99ded80e2d52f15a94fa6d/httpcore2-2.14.0.tar.gz", hash = "sha256:4f57a1a8249fe6af589d935cfd456f1d13bbdcb0f0fc72af9142368fc94811d7", size = 69096, upload-time = "2026-10-18T16:29:21.898Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/02/06/a8d6a8f90d11b76d9086242b6bb0ee4b503473bfc8be34c2d5b067275c22/httpcore2-2.14.0-py3-none-any.whl", hash = "sha256:4c4f64f4b544afeb778c42c0ffb5941b29e671157e90ed3f6dc787c4bca90cd1", size = 84291, upload-time = "2026-10-18T16:29:19.743Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "httptools"
|
||||
version = "0.9.0"
|
||||
@@ -594,6 +792,31 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "httpx2"
|
||||
version = "2.14.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "anyio", marker = "sys_platform != 'emscripten'" },
|
||||
{ name = "httpcore2", marker = "sys_platform != 'emscripten'" },
|
||||
{ name = "httpx2-jsfetch", marker = "sys_platform == 'emscripten'" },
|
||||
{ name = "idna" },
|
||||
{ name = "truststore", marker = "sys_platform != 'emscripten'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/e8/67/58353f1848b4ba568e1ec22ea1e0d8e039f0bca5fde7e2d1f07739fd83e7/httpx2-2.14.0.tar.gz", hash = "sha256:47ad61a3c40282cd8d0dc96311531f00f5bfc71a066c6fe3b36d8f63fb9e4f6e", size = 102036, upload-time = "2026-10-18T16:29:22.627Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/69/5a/469616aa8c2cbb0bb9dd67a3c18d07c01ab604cc0b236ee1c47d260c7f6e/httpx2-2.14.0-py3-none-any.whl", hash = "sha256:9d20c13a10bae1773a0be3b0f1e5beeb4bdd549bc3a2ba18efa32897c65403e4", size = 96901, upload-time = "2026-10-18T16:29:20.819Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "httpx2-jsfetch"
|
||||
version = "1.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/cd/c4/0e5636363151a2a1795e0a77617168b9ca438e1748ec05fc9b5687f93d64/httpx2_jsfetch-1.0.tar.gz", hash = "sha256:70a0e3eabfef7cce5ad9c629f7d01ca05e418f586646f4ddf14782e4c1454c60", size = 6872, upload-time = "2026-08-07T00:13:07.492Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/9b/43/832f631d32e4f1211caa2ba368317739fe71f0b8530e4c9d15dc454bac2a/httpx2_jsfetch-1.0-py3-none-any.whl", hash = "sha256:cb916b707601e69a07721aabc8f3f6659be3a6893bc1ff5c6f9e02241df2da32", size = 6382, upload-time = "2026-08-07T00:13:06.567Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.20"
|
||||
@@ -633,6 +856,53 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libcst"
|
||||
version = "1.9.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pyyaml", marker = "python_full_version >= '3.14'" },
|
||||
{ name = "pyyaml-ft", marker = "python_full_version < '3.14'" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/02/c0/098e5c91ff1537f00c85a6438b6cb1863d17144680cc91f47c87f104a200/libcst-1.9.0.tar.gz", hash = "sha256:087b58a9afe076bb08e2d726478e1f16cb928d67ffa9092817e033c335de522a", size = 914739, upload-time = "2026-07-29T21:28:43.153Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f2/b1/befc0544283bb3923a928accf79ed685e5a725524bdb3491826670affc07/libcst-1.9.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:b8b9df30f524317b097dc53065b25dda33d6a4cc3c7c8bf4fc83ca7559c58cc0", size = 2043754, upload-time = "2026-07-29T19:24:59.885Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/45/50/fef7c172a8457c95894edf5fb04805024899cdfea41fa01b0636587b79e1/libcst-1.9.0-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:e465a7bc9c2b9533eb9e06d2391f8819f811b5112919d4064c9fb8565aaafa08", size = 2203548, upload-time = "2026-07-29T19:25:01.323Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/18/ff/764cd2be1fd99d774fc44039c319dc0ed1d9d9afeaa02759a05121cccd4b/libcst-1.9.0-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:8504b422c95676a8c27b517e1ac01413ece91bf356865c587ca9bdcd5708a2f7", size = 2255274, upload-time = "2026-07-29T19:25:02.764Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/34/a7/474748a27a02fa83e3556b260d5f5236ca48164fa7beffecf3b2cad24dca/libcst-1.9.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:bcb9f9d4fcfe2ec7a40d2c26e03a538d5d9dc189c38551eb3f94ab661afee7c0", size = 2269126, upload-time = "2026-07-29T19:25:04.158Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8a/b7/655e45363b8cf87b91e41e060b21c89e5316c7ef36eb14a1a498b27bb71e/libcst-1.9.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e8d671c39a431c309476099b8ec811e412503ec0f4465f6fc907cb51c70e8e6b", size = 2378602, upload-time = "2026-07-29T19:25:06.424Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/db/13/6da63f0902ece43bf9d737017251ad7ad06edd9d3c4e1856450403cb4473/libcst-1.9.0-cp313-cp313-win_amd64.whl", hash = "sha256:4d382fba04077eb556a1ea4295a4482e192aa93639c5a07ba0885841965ea0c0", size = 2103486, upload-time = "2026-07-29T19:25:07.979Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fd/ff/dccb1a55e38b4e47256a97242d61d2bef5366c744faf88fb087d4fa0f995/libcst-1.9.0-cp313-cp313-win_arm64.whl", hash = "sha256:a621e261990148c1cfbe26c1798bd2375c131cf358a44a7a4659fc41c1a336e1", size = 1979907, upload-time = "2026-07-29T19:25:09.532Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/65/2a/4943c71d90975bc59034a057dea346b365c276f308c1d31f5cf2bd85492d/libcst-1.9.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:eccf4c57d273cdd3fe1c67b72cf9bb1bbd4547aa011824e96ccf5b7136057aa4", size = 2044529, upload-time = "2026-07-29T19:25:11.04Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/be/ed/1168b98c2a0f338be3a44753647baab051feaf6167cc887bf4447f8fd920/libcst-1.9.0-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:32395244edfe6538e0ea2bf82051d60103d3f54861274805c4fb3745efb70a85", size = 2203519, upload-time = "2026-07-29T19:25:12.543Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/25/7d/2eaa697a80f899bcf2245680bbfcc1e478eb3b3328c21d4b2880bdf00dac/libcst-1.9.0-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:444e84c76cd035cd2fe136838c1a524d34b08216521f6f5093df8a6f6cfa5799", size = 2255879, upload-time = "2026-07-29T19:25:14.137Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/90/03/793b9fd96dd52d202f5f2b88d7e54f05ebed767d1bb3b32395a1817bf6ab/libcst-1.9.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:bb5d0946f2b4c6711b5d69fe4f833b364f9e7a1a2b08f88b98619dc18975099a", size = 2269807, upload-time = "2026-07-29T19:25:15.647Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a3/f4/1bc7aaea03971c45e8a885fed9fc1c73176dbbd00b0296a3cde9529bafd6/libcst-1.9.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:45808c03528b3ad40b14095348a918e08d98c47b4a125d631cb78e817c0a5b16", size = 2378171, upload-time = "2026-07-29T19:25:17.289Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8e/f7/bc49e367d2bc8817213594dd52cf6b2da2dbbda90b5382d60653999274ac/libcst-1.9.0-cp314-cp314-win_amd64.whl", hash = "sha256:568288cdbfe3b4ca3ae4852cb0a439ff053dd54c841bc4995bf2b71238b5de40", size = 2177847, upload-time = "2026-07-29T19:25:19.35Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/87/80/4d81577a22e6d535d1a3409f3a1c6903e09036f0e17fc47f92169dbc3501/libcst-1.9.0-cp314-cp314-win_arm64.whl", hash = "sha256:107593af46945593e7825821793393262bc4fa1d3ea24c3ed487b61269bbbdf8", size = 2058134, upload-time = "2026-07-29T19:25:20.769Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/7f/c3f3a0e7a1a2adaa76e815e82a7814d6bfe7d49432276bba652248c68d0b/libcst-1.9.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:f6248cb07444ab9a6733a855737a9febed8b9adca51347019348b09a3ac7dfe9", size = 2036102, upload-time = "2026-07-29T19:25:22.212Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4e/af/2f5543255b2c7d749b966adeccc6bfb1652cf8b425afb913d0f3f025a865/libcst-1.9.0-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:496c24e0d3240bc7da45dae543aff3f5b6509978c39262d6b84ed2fb999dded2", size = 2194806, upload-time = "2026-07-29T19:25:24.017Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cb/5b/03f4cddce426d005e208b39ea7b2d456e667cdee0f1891360f0fc8430f20/libcst-1.9.0-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:ea490fa8540503db5f321f0268becab46eb50f710e8cec8041e241fd66f6874f", size = 2246762, upload-time = "2026-07-29T19:25:25.365Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d8/31/9d5fe1e43dc3dbcc74f70f3e0e73fcdd8d84effc1059d8b45974f0d0d2eb/libcst-1.9.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:50ab94bb2524b419056d4003032b8c67102ac800f8d85b3c4260a01746d94dbb", size = 2259633, upload-time = "2026-07-29T19:25:26.928Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a8/2b/6752b28d88c3a19b3bc0b9e1838443b6760d5c862b4f4b37955402659e24/libcst-1.9.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:a2faaf92500d0226358125630f5aab4758e8aad3f2d70a10892ec3c700781a54", size = 2368043, upload-time = "2026-07-29T19:25:28.344Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e2/94/775825b2637f8ab05694b6a4b3802ae6783b4e799f9b58d2400c7e2d4369/libcst-1.9.0-cp314-cp314t-win_amd64.whl", hash = "sha256:0c7b548512db25af9c2997a95fa731bd6b6928ecbad6c0915d7482d8bb42d34f", size = 2176432, upload-time = "2026-07-29T19:25:29.921Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fb/3d/88ad67427c6fd9db929e087912b0a540e5140e5cb77e7ca4170edaac8531/libcst-1.9.0-cp314-cp314t-win_arm64.whl", hash = "sha256:497d5329345f1f5df84e41b0bbd00204b64a2fd30dfe3cfaeaebca633a31e877", size = 2052931, upload-time = "2026-07-29T19:25:31.397Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/39/e4/ad790b043a38b10cea13166c8dd716654ad8b227c20f12eebf6326191cd9/libcst-1.9.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:a5068bf6114f6f4d79af7a6c80a28d1deb50441150ea1db13b5458ab34bec159", size = 2043987, upload-time = "2026-08-11T05:54:02.122Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/15/6b/d3cd8275cc54ffc9817ade91442b3e6e9edd1a4518bd4e6dda13e3152dbe/libcst-1.9.0-cp315-cp315-manylinux_2_28_aarch64.whl", hash = "sha256:7acfd18adcdd32dcf41ce676cf121002afcbe9ad2c72dc0c18d78465beedc228", size = 2204003, upload-time = "2026-08-11T05:54:04.031Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/da/62/87eddccb11d5d221d50ac4fff4b6e9b8d48c547028d01f7d0fbc5c8a1d75/libcst-1.9.0-cp315-cp315-manylinux_2_28_x86_64.whl", hash = "sha256:86361e2b426bd1b403e52375703c8b764e226e571adcb30442510710681edbf0", size = 2256053, upload-time = "2026-08-11T05:54:06.228Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/18/53/a44126aeb9fca8b4e342e0cc803ea00ca8f6cd5712619a7897b3eba13797/libcst-1.9.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:8c14abe844bec8b021111b3985474e49f5af799c020e8e40dedcac87c97a40c5", size = 2270576, upload-time = "2026-08-11T05:54:08.01Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bb/51/3af3dd44b117d66486e0ed61e43a16b7fc8cc5c372e1dd4ca0e70b888d46/libcst-1.9.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:8930971d2299b7006bb5d10c10038f44efb6da89d5bca2823595e31a9cdb96af", size = 2378573, upload-time = "2026-08-11T05:54:10.093Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fc/e8/e545087d298dbf6494e84a8092f0f5dbd62eedacabd4ecd6b364367b4804/libcst-1.9.0-cp315-cp315-win_amd64.whl", hash = "sha256:5891ce9cff815077614f509e3a23888c5ddb8081d6188e8ba1172c0ccc369022", size = 2177937, upload-time = "2026-08-11T05:54:12.168Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/84/17/93a00a8e03494a84db102dd0e3d35b8876b1084ca2c194b331a168d86eb1/libcst-1.9.0-cp315-cp315-win_arm64.whl", hash = "sha256:1260b5d070a3324447a53a00387225a55472a62077ce01922d30a2a78cc4b138", size = 2058633, upload-time = "2026-08-11T05:54:13.817Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/00/c3751b12eb81822ea0b6131d374a98bc6c024c4b9ec5f6ea8f53dc23e967/libcst-1.9.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:02ee2dbdb5c218116f16a021350fc267a14be205b50d81c33f5d73857ab6fbf7", size = 2036178, upload-time = "2026-08-11T05:54:15.545Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2f/12/48ff486eb5adc593f4818569e8896b74b672414ab4722a74b17e4c4cf31e/libcst-1.9.0-cp315-cp315t-manylinux_2_28_aarch64.whl", hash = "sha256:3e5b684191a0462b2d40a73261ea7f4da6a49e7a030b7e0fceca46bebb51dfe5", size = 2195496, upload-time = "2026-08-11T05:54:17.625Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/51/18/b13a4669864d41a4801fed7b86ede1049dc9a1e1dde250a7ee1f9c3b1285/libcst-1.9.0-cp315-cp315t-manylinux_2_28_x86_64.whl", hash = "sha256:2b150c4f298fe54eb0fe73abf71f57db74d070796140a8c206c9615b6861f01e", size = 2245769, upload-time = "2026-08-11T05:54:19.343Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c8/c7/cf2d46744825e84afbd7228fdeeea8d23cf6c4b2074253c27efb7705c653/libcst-1.9.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:50b913e37187f00a6fb88962009364e1cf1b1284aa1762304f34b52b972f2218", size = 2260576, upload-time = "2026-08-11T05:54:21.444Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/4d/5433d3d62250b2e4325938db101766bcab2a006819684713bcccb6259a88/libcst-1.9.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:9f92c75283030fd58fb7d6e560168a00381e0e3368ec8a026a3ec8a828a05f93", size = 2368709, upload-time = "2026-08-11T05:54:23.276Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/87/39/9f0e1690727623f99489895db0e42048a3e1e8cea0627517c593e437fd83/libcst-1.9.0-cp315-cp315t-win_amd64.whl", hash = "sha256:4adf97bb1aff8039b0bd4991e2f838be6e4fad552821b26b71a5d1a653c2582f", size = 2177866, upload-time = "2026-08-11T05:54:25.144Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cd/79/9dc7811883e67ea771057e8937bc536eb3e77f3635fc5a93cd85b6fe1ea8/libcst-1.9.0-cp315-cp315t-win_arm64.whl", hash = "sha256:8f0dd08a5773d7051e105250b2a2c73d8065ea9b2d68e7e1bdc5244660e75f93", size = 2052908, upload-time = "2026-08-11T05:54:26.835Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsql-client"
|
||||
version = "0.3.1"
|
||||
@@ -647,6 +917,43 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/83/f0/b0d7c7331f975bcc3effd01abb094723891fd42bca7f702b4a0cf06c1bff/libsql_client-0.3.1-py3-none-any.whl", hash = "sha256:088756f65802f5ca5857a99cf374d9b7aa015b97b91b0cb725ef6a033e23268b", size = 46100, upload-time = "2024-05-03T12:48:18.128Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsql-experimental"
|
||||
version = "0.0.55"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/53/14/d3eb81673e2096f38eb48f08e38b447f6f2fdc37a50bdb1810d4a225a7aa/libsql_experimental-0.0.55.tar.gz", hash = "sha256:34df13ad6da446e4ccede9b3803af40684da399c8f304848b54ea37e7111b249", size = 31954, upload-time = "2025-06-09T07:26:48.682Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a0/9f/3589b9590ba948922bd200a02d754fa29e739da81a2953367e9283667a16/libsql_experimental-0.0.55-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:f3bfd7af2ca9d1ff8f8c7f7fce5f1a650bfe53c23b45658253480fe287283bae", size = 4881245, upload-time = "2025-06-09T07:26:37.382Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/37/cf/4aead944cb90f82ab1b61edc78dbe893420e8c4ceee19e1fdae775b1273d/libsql_experimental-0.0.55-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:b3476a78edb8f59aa6c571d6def1840fff8d263eb4bbc4b26b2afd7400cb9ba2", size = 4656348, upload-time = "2025-06-09T07:26:39.04Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/70/73/134dc2db0c3805f62953c85778bf93ac2f4a5ad81d49e592be990b012711/libsql_experimental-0.0.55-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a5dd325f87425546e0a7f0d460d4b6e1852bc4d4194a7b5ad127614ef8b3b10", size = 5273740, upload-time = "2025-06-09T07:26:40.597Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linkify-it-py"
|
||||
version = "2.2.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/45/98/7a1a5f31fd5c7ba93e963b168e244b8e3dd705b3d2a718e3c3307583bf57/linkify_it_py-2.2.0.tar.gz", hash = "sha256:907acd2d17ac1fbb9ddb62c8957ccbd6158cac602231a15c3b0cd1e215f03cee", size = 32939, upload-time = "2026-08-29T07:07:08.305Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/13/d4/1152d1c7ab42d8b908be64fd200ddc870dc9d4925e951198702084aa1a7d/linkify_it_py-2.2.0-py3-none-any.whl", hash = "sha256:3adc40eb5af300b2605fcfdb968c24e1d780a90f1f2221af7c15e5111e94d443", size = 21971, upload-time = "2026-08-29T07:07:07.164Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "markdown-it-py"
|
||||
version = "4.2.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "mdurl" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/06/ff/7841249c247aa650a76b9ee4bbaeae59370dc8bfd2f6c01f3630c35eb134/markdown_it_py-4.2.0.tar.gz", hash = "sha256:04a21681d6fbb623de53f6f364d352309d4094dd4194040a10fd51833e418d49", size = 82454, upload-time = "2026-05-07T12:08:28.36Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/b3/81/4da04ced5a082363ecfa159c010d200ecbd959ae410c10c0264a38cac0f5/markdown_it_py-4.2.0-py3-none-any.whl", hash = "sha256:9f7ebbcd14fe59494226453aed97c1070d83f8d24b6fc3a3bcf9a38092641c4a", size = 91687, upload-time = "2026-05-07T12:08:27.182Z" },
|
||||
]
|
||||
|
||||
[package.optional-dependencies]
|
||||
linkify = [
|
||||
{ name = "linkify-it-py" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "markupsafe"
|
||||
version = "3.0.4"
|
||||
@@ -745,6 +1052,27 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/92/f9/ecbde7149e95b8a0f18e16d5d747f7dc06049d5da2e4f77f6f5e4a1f46a8/markupsafe-3.0.4-cp315-cp315t-win_arm64.whl", hash = "sha256:39dbacefc411633db5b4378b066a9aca70a3d7e2922c9e578d825f844026eeba", size = 14417, upload-time = "2026-10-02T23:06:56.246Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mdit-py-plugins"
|
||||
version = "0.6.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "markdown-it-py" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/59/fc/f8d0863f8862f25602c0404d75568e89fb6b4109804645e5cdfb1be5cf56/mdit_py_plugins-0.6.1.tar.gz", hash = "sha256:a2bca0f039f39dbd35fb74ae1b5f998608c437463371f0ff7f49a19a17a114d0", size = 56114, upload-time = "2026-05-13T09:03:38.91Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a5/69/6da5581c6a7fede7dc261bf4e67d6adca4196f176b43288b55b3db395b6e/mdit_py_plugins-0.6.1-py3-none-any.whl", hash = "sha256:214c82fb2ac524472ab6a5bcab1de80f73b50443e187f401bfd77efbc7c6481d", size = 66663, upload-time = "2026-05-13T09:03:37.76Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mdurl"
|
||||
version = "0.1.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multidict"
|
||||
version = "7.1.0"
|
||||
@@ -863,6 +1191,23 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d0/86/a3de309c5e28ee85b314d0e3ba0e0dea6fd361c313322a05e67be4656e1e/multidict-7.1.0-py3-none-any.whl", hash = "sha256:d9ef29cfd98e17085b4f91bba8fa1570bec6787d5c52ce653ed33a58785585d0", size = 28087, upload-time = "2026-10-09T20:31:35.945Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mutmut"
|
||||
version = "3.8.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "click" },
|
||||
{ name = "coverage" },
|
||||
{ name = "libcst" },
|
||||
{ name = "pytest" },
|
||||
{ name = "setproctitle" },
|
||||
{ name = "textual" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/78/30/b334a22184026d92a7549c8a76ad1d397ea65a6f8534ef486556ab861c70/mutmut-3.8.0.tar.gz", hash = "sha256:bc670276518f893ab356f1d28826c49b7e606e7cf89c300e3888c0b52fc1d2ed", size = 83631, upload-time = "2026-09-12T16:53:58.138Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/66/2a/a9904a45804c1de50c0c3baad1512b78d5b66d2befd841104b8a62bf0f35/mutmut-3.8.0-py3-none-any.whl", hash = "sha256:4c0abcef6b8d1116f2adfaad19df12e1c621e4a402d4367ef15bf8cba497b91d", size = 81469, upload-time = "2026-09-12T16:53:56.906Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nodeenv"
|
||||
version = "1.11.0"
|
||||
@@ -893,6 +1238,15 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "platformdirs"
|
||||
version = "4.13.5"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/58/e6/d0abbb256b44e6a05748c6942511ff67db8dbb068de0c35b24bf1b395b09/platformdirs-4.13.5.tar.gz", hash = "sha256:05831adf87d392760f4b5c3a0a95579ab5a10b18b9b9bd43680dcb47544788a0", size = 62362, upload-time = "2026-10-19T01:02:11.778Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/6c/8a/1d8cb3842909dc193a73835adedf412e32e18f8ffd59f43983949622fe6f/platformdirs-4.13.5-py3-none-any.whl", hash = "sha256:53d3ec4280b815c1e0b02edad7f9ee8fda1ba9c0865dd9c2e6e63849ce82fc1e", size = 32779, upload-time = "2026-10-19T01:02:10.17Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pluggy"
|
||||
version = "1.7.0"
|
||||
@@ -1011,6 +1365,11 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/35/ea/a56b9fe5066f3537b7882f77e9c5dfb26d8c2eefdaed9b5fc73d57b4dc22/pydantic-2.14.1-py3-none-any.whl", hash = "sha256:9195d967ec791692a04438115466764fb8b9a27b31f14a760437694f40d6b454", size = 488106, upload-time = "2026-10-11T18:37:53.437Z" },
|
||||
]
|
||||
|
||||
[package.optional-dependencies]
|
||||
email = [
|
||||
{ name = "email-validator" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydantic-core"
|
||||
version = "2.50.1"
|
||||
@@ -1098,6 +1457,19 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/6d/56/8a702c27e5be9f47e5f19d8669227424290e4c024e7c370279cbaf244b4e/pydantic_core-2.50.1-cp315-cp315t-win_arm64.whl", hash = "sha256:c3ede305158e75510be50869b319550ab072008c13d64d4ab1e094fb286b6f44", size = 2175297, upload-time = "2026-10-11T18:35:04.079Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydantic-extra-types"
|
||||
version = "2.11.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pydantic" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/66/71/dba38ee2651f84f7842206adbd2233d8bbdb59fb85e9fa14232486a8c471/pydantic_extra_types-2.11.1.tar.gz", hash = "sha256:46792d2307383859e923d8fcefa82108b1a141f8a9c0198982b3832ab5ef1049", size = 172002, upload-time = "2026-03-16T08:08:03.92Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/17/c1/3226e6d7f5a4f736f38ac11a6fbb262d701889802595cdb0f53a885ac2e0/pydantic_extra_types-2.11.1-py3-none-any.whl", hash = "sha256:1722ea2bddae5628ace25f2aa685b69978ef533123e5638cfbddb999e0100ec1", size = 79526, upload-time = "2026-03-16T08:08:02.533Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pydantic-settings"
|
||||
version = "2.16.0"
|
||||
@@ -1163,6 +1535,18 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/03/e2/08a497ef684b88559c9cc5f4ad53a37e7b99e727094a86d6ea32536d5d3c/pytest_asyncio-1.4.0-py3-none-any.whl", hash = "sha256:933ca923a23075a87fb7070c0ec272a6848489824d887c85c812670932835aa1", size = 16930, upload-time = "2026-05-26T09:56:02.576Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-mock"
|
||||
version = "3.17.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pytest" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/97/c2/28b9f5b955ff2bcd4727a6f768e2ca9b586cd7c37b95ea5f7b9b873ac7b3/pytest_mock-3.17.0.tar.gz", hash = "sha256:e36576e0985e01027e999891e7a966c67822d40c89ef1b4c8b6e22737e3590b4", size = 43064, upload-time = "2026-10-17T16:21:42.435Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/e8/ea/47fbdc8f37410956fd445720e927589b1e2a47772c5f28109f0ce2fa26d9/pytest_mock-3.17.0-py3-none-any.whl", hash = "sha256:1b82aa4b37137248bd687055e109723debeb07b489de1565297dc9589c5f2d6b", size = 11248, upload-time = "2026-10-17T16:21:41.265Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "python-dotenv"
|
||||
version = "1.2.4"
|
||||
@@ -1208,6 +1592,30 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyyaml-ft"
|
||||
version = "8.0.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/5e/eb/5a0d575de784f9a1f94e2b1288c6886f13f34185e13117ed530f32b6f8a8/pyyaml_ft-8.0.0.tar.gz", hash = "sha256:0c947dce03954c7b5d38869ed4878b2e6ff1d44b08a0d84dc83fdad205ae39ab", size = 141057, upload-time = "2025-06-10T15:32:15.613Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/68/ba/a067369fe61a2e57fb38732562927d5bae088c73cb9bb5438736a9555b29/pyyaml_ft-8.0.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8c1306282bc958bfda31237f900eb52c9bedf9b93a11f82e1aab004c9a5657a6", size = 187027, upload-time = "2025-06-10T15:31:48.722Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ad/c5/a3d2020ce5ccfc6aede0d45bcb870298652ac0cf199f67714d250e0cdf39/pyyaml_ft-8.0.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:30c5f1751625786c19de751e3130fc345ebcba6a86f6bddd6e1285342f4bbb69", size = 176146, upload-time = "2025-06-10T15:31:50.584Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e3/bb/23a9739291086ca0d3189eac7cd92b4d00e9fdc77d722ab610c35f9a82ba/pyyaml_ft-8.0.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3fa992481155ddda2e303fcc74c79c05eddcdbc907b888d3d9ce3ff3e2adcfb0", size = 746792, upload-time = "2025-06-10T15:31:52.304Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5f/c2/e8825f4ff725b7e560d62a3609e31d735318068e1079539ebfde397ea03e/pyyaml_ft-8.0.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cec6c92b4207004b62dfad1f0be321c9f04725e0f271c16247d8b39c3bf3ea42", size = 786772, upload-time = "2025-06-10T15:31:54.712Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/35/be/58a4dcae8854f2fdca9b28d9495298fd5571a50d8430b1c3033ec95d2d0e/pyyaml_ft-8.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06237267dbcab70d4c0e9436d8f719f04a51123f0ca2694c00dd4b68c338e40b", size = 778723, upload-time = "2025-06-10T15:31:56.093Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/86/ed/fed0da92b5d5d7340a082e3802d84c6dc9d5fa142954404c41a544c1cb92/pyyaml_ft-8.0.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:8a7f332bc565817644cdb38ffe4739e44c3e18c55793f75dddb87630f03fc254", size = 758478, upload-time = "2025-06-10T15:31:58.314Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f0/69/ac02afe286275980ecb2dcdc0156617389b7e0c0a3fcdedf155c67be2b80/pyyaml_ft-8.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:7d10175a746be65f6feb86224df5d6bc5c049ebf52b89a88cf1cd78af5a367a8", size = 799159, upload-time = "2025-06-10T15:31:59.675Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4e/ac/c492a9da2e39abdff4c3094ec54acac9747743f36428281fb186a03fab76/pyyaml_ft-8.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:58e1015098cf8d8aec82f360789c16283b88ca670fe4275ef6c48c5e30b22a96", size = 158779, upload-time = "2025-06-10T15:32:01.029Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5d/9b/41998df3298960d7c67653669f37710fa2d568a5fc933ea24a6df60acaf6/pyyaml_ft-8.0.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:e64fa5f3e2ceb790d50602b2fd4ec37abbd760a8c778e46354df647e7c5a4ebb", size = 191331, upload-time = "2025-06-10T15:32:02.602Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0f/16/2710c252ee04cbd74d9562ebba709e5a284faeb8ada88fcda548c9191b47/pyyaml_ft-8.0.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:8d445bf6ea16bb93c37b42fdacfb2f94c8e92a79ba9e12768c96ecde867046d1", size = 182879, upload-time = "2025-06-10T15:32:04.466Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9a/40/ae8163519d937fa7bfa457b6f78439cc6831a7c2b170e4f612f7eda71815/pyyaml_ft-8.0.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c56bb46b4fda34cbb92a9446a841da3982cdde6ea13de3fbd80db7eeeab8b49", size = 811277, upload-time = "2025-06-10T15:32:06.214Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f9/66/28d82dbff7f87b96f0eeac79b7d972a96b4980c1e445eb6a857ba91eda00/pyyaml_ft-8.0.0-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dab0abb46eb1780da486f022dce034b952c8ae40753627b27a626d803926483b", size = 831650, upload-time = "2025-06-10T15:32:08.076Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e8/df/161c4566facac7d75a9e182295c223060373d4116dead9cc53a265de60b9/pyyaml_ft-8.0.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bd48d639cab5ca50ad957b6dd632c7dd3ac02a1abe0e8196a3c24a52f5db3f7a", size = 815755, upload-time = "2025-06-10T15:32:09.435Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/05/10/f42c48fa5153204f42eaa945e8d1fd7c10d6296841dcb2447bf7da1be5c4/pyyaml_ft-8.0.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:052561b89d5b2a8e1289f326d060e794c21fa068aa11255fe71d65baf18a632e", size = 810403, upload-time = "2025-06-10T15:32:11.051Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d5/d2/e369064aa51009eb9245399fd8ad2c562bd0bcd392a00be44b2a824ded7c/pyyaml_ft-8.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:3bb4b927929b0cb162fb1605392a321e3333e48ce616cdcfa04a839271373255", size = 835581, upload-time = "2025-06-10T15:32:12.897Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c0/28/26534bed77109632a956977f60d8519049f545abc39215d086e33a61f1f2/pyyaml_ft-8.0.0-cp313-cp313t-win_amd64.whl", hash = "sha256:de04cfe9439565e32f178106c51dd6ca61afaa2907d143835d501d84703d3793", size = 171579, upload-time = "2025-06-10T15:32:14.34Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "requests"
|
||||
version = "2.34.2"
|
||||
@@ -1223,6 +1631,19 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a0/f4/c67b0b3f1b9245e8d266f0f112c500d50e5b4e83cb6f3b71b6528104182a/requests-2.34.2-py3-none-any.whl", hash = "sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0", size = 73075, upload-time = "2026-05-14T19:25:26.443Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rich"
|
||||
version = "15.0.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "markdown-it-py" },
|
||||
{ name = "pygments" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/c0/8f/0722ca900cc807c13a6a0c696dacf35430f72e0ec571c4275d2371fca3e9/rich-15.0.0.tar.gz", hash = "sha256:edd07a4824c6b40189fb7ac9bc4c52536e9780fbbfbddf6f1e2502c31b068c36", size = 230680, upload-time = "2026-04-12T08:24:00.75Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/82/3b/64d4899d73f91ba49a8c18a8ff3f0ea8f1c1d75481760df8c68ef5235bf5/rich-15.0.0-py3-none-any.whl", hash = "sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb", size = 310654, upload-time = "2026-04-12T08:24:02.83Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "roman-numerals"
|
||||
version = "4.1.0"
|
||||
@@ -1257,6 +1678,74 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/df/c9/0f2a4dea06a5e12c1191ee3d96b1e1233797d0d5e18f97a2b909a95a9836/ruff-0.17.1-py3-none-win_arm64.whl", hash = "sha256:42400b9a6ff8515ff27796f07f92e0195be011c86e81e381606f58ea5502fef4", size = 9853542, upload-time = "2026-10-15T15:23:16.05Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "setproctitle"
|
||||
version = "1.3.8"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/49/b0/6b8a516c5a9e9630bd5293db78314ac012f690305fe93beadea388626efb/setproctitle-1.3.8.tar.gz", hash = "sha256:cafe209d064a6efb88cb45a03e97981ff8832802b2b5d009dde0197a3b7b41c8", size = 27214, upload-time = "2026-10-01T21:09:27.121Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/58/46/125791eb19c85340c6d43de8c821b143aecbfa0882343f244f5744474229/setproctitle-1.3.8-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:a4a782f9ab26e662a890c1a7d865c452c83ed554de44aa83da35fa5bdcc79921", size = 18100, upload-time = "2026-10-01T20:59:33.41Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/47/51/73b1e62c3e019e683e58d31f9f8af57e6750f36ce079004d29b7790e22ce/setproctitle-1.3.8-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d63adfa4be8f9dbac4be6b359e2a8eb15a733545ef613d02a12ae27a4d40e975", size = 13116, upload-time = "2026-10-01T20:59:35.159Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/78/ae/095c6ad159e3a7b95bc6d9a3eae18abfea1ebc79ed3377617406a1668150/setproctitle-1.3.8-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:d4289e209e805d7d276a534f062092974fbe6814889d4c132c247205ebb49a65", size = 33275, upload-time = "2026-10-01T20:59:37.235Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f7/6e/5196258efd941cb874b3f4da91460601b867fdc434eba48a70455736d4be/setproctitle-1.3.8-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8bb543b4b58ad839f7f0d335a7f4b40cef6989952e7239de3532de0b7771607e", size = 34124, upload-time = "2026-10-01T20:59:39.529Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/36/01/e9754e0916e6dda232a8c337bda69d2fea33acee0c5d3bdf580b8155a50d/setproctitle-1.3.8-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b705f01a531dba8fbbab90e30d432af4cc70a79c0a33b238e2c061816140cad0", size = 36006, upload-time = "2026-10-01T20:59:41.501Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ee/a9/c63d2d745f18423937429a8611743e7b3e17259173150fbcdaa59daa4a51/setproctitle-1.3.8-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8e286e4c4e90063072a6e088a8d6526a7ffceb47429db88ba50ba58eeebcc758", size = 32268, upload-time = "2026-10-01T20:59:43.795Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/36/0c/a72818902f32ea9b848db5ccc828eb9cd9bc8661975610e1d46ea4aacbe2/setproctitle-1.3.8-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:7b77c8671974288cf192e481ed63e928f1086762e97e8845d09d65ba121f8aaa", size = 33179, upload-time = "2026-10-01T20:59:45.809Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bb/55/fa59463ae6b957048e0e842d4b5513eced1b71554d8af0f5d91cd23cde23/setproctitle-1.3.8-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0e85b55eac9abfa3166ab00dac21e718ac2624a1df7d0b75559a2d3e3781cb33", size = 34472, upload-time = "2026-10-01T20:59:47.858Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b7/77/1f0cf55055788bf7eb9a146040a64d7ec42cd56153894856effc70e943ec/setproctitle-1.3.8-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:f215ec9237d5f8e96d0205be6e2141292c20b133343c2153b6d4934f523ef422", size = 31428, upload-time = "2026-10-01T20:59:49.753Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/32/98/d1d8a6cd620d72a04f5d3335125e5b2fc5667bd06a76bb5bbc50b101e804/setproctitle-1.3.8-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:b0e70a5d294e4c8cf7dc94e015fca6d4913779a424937e66b429fba82d8eb5e2", size = 32776, upload-time = "2026-10-01T20:59:51.763Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4b/34/8b9eea1e80ac7a7f622eead8a0e4d73a60098344ed6f373e111f7ce8d29d/setproctitle-1.3.8-cp313-cp313-win32.whl", hash = "sha256:f85b4d87273e0ec63568433bbb8ccf160b548c49b53576fe010bad9f698b8586", size = 12105, upload-time = "2026-10-01T20:59:53.444Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bf/f0/98883c658859d331faf91eccac8946cb2f8feb2590905015b129fdeb09cd/setproctitle-1.3.8-cp313-cp313-win_amd64.whl", hash = "sha256:bcdf74fe8a6e3b31bed1bc7d3e2a38cfbda3263d2750492ea0725dbc2db5aacf", size = 12933, upload-time = "2026-10-01T20:59:55.045Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cb/1b/15043f8886aecfb31759c4a7c2cda9f85971242a10723049fc0fea34629f/setproctitle-1.3.8-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:f5f1d7e0d57cd75febd70c6fc26c2ea06024ab2006011abb3094b9fea54801ee", size = 18104, upload-time = "2026-10-01T20:59:57.014Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0d/be/c2a6880394bef30aafe274d00ca0c7dac34fff1fb867f6c51abf876a640f/setproctitle-1.3.8-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:b8954fc72fdd49588c8b8d615eabc27dfd8eb6d0cffe987fc5df02934816fb19", size = 13124, upload-time = "2026-10-01T20:59:58.611Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a7/96/6b3818e7f63a30f13bbe97b1ea0a51509a20b5b2d48c95e526c3054343d5/setproctitle-1.3.8-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:4d6a0245679b74e0fda974edb672cd1f2351b0d762279b6776ca3a065c9322a4", size = 33180, upload-time = "2026-10-01T21:04:02.137Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4f/43/fd3220b4bb2169d8723b3561ae7f8e1ee6f2e13e2da38b3a7a150004d2aa/setproctitle-1.3.8-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:394aca04e9f11c469f4f29d25a40a79eb4b8c9a72f438ba6390b776590f89757", size = 34071, upload-time = "2026-10-01T21:07:16.281Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/34/58/ee9eeebeb74125723b60eada6e6b2def747815228193327ce470da088f2b/setproctitle-1.3.8-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f92f6ded50c0ae7b0fed612be77c5345ed4a4578f99b98c7f8258d0e599eff16", size = 35923, upload-time = "2026-10-01T21:07:19.054Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f6/fe/b339602e96d73b29fd123c8b9c886e8f9a5afa12a18218eece56bd99c668/setproctitle-1.3.8-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c09f15930910dd895ac113b16c0b3ac2051dcbd44b0f017f94cb51349ba11583", size = 32116, upload-time = "2026-10-01T21:07:25.121Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/5e/8d46d34648d8dfdc3f3e941c149ae316b6c6f417391018e279a1bb733c42/setproctitle-1.3.8-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:4756a96435917494ec2f27f0da46bc05eecaa1a7e072d57220ecb2d46ea8a3d3", size = 32980, upload-time = "2026-10-01T21:07:27.826Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/dd/6a/10720d27d5f4a47c9af51652b49dd22313be20b9d542e72f80b4b363702b/setproctitle-1.3.8-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:65279b2df2951b64878da5382363e730d242486179c440c8653fe39aa3cc9e62", size = 34307, upload-time = "2026-10-01T21:07:30.62Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6e/65/95dd7b0245fdb7d2f6633613c559ecd9f0b2afeb6e3d962c218b6a1722d4/setproctitle-1.3.8-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:3d2ced815b940c88097e07182c57cbfe1a0156839d1edc9be2bc0e4c74ab4eed", size = 31126, upload-time = "2026-10-01T21:07:33.59Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fd/96/4d62c4ba70cf8fa305f1dcbe35e93449819bb27b451fcb473556acf92650/setproctitle-1.3.8-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:37a91697c3b96bac58b6936b3bf0366af96a2a6cef963fdd9aaf0593a4bd1ff2", size = 32468, upload-time = "2026-10-01T21:07:36.312Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0a/4a/1ec517435d4b572f6c468795331c7b376ec310eca5b1321504c6647b85a9/setproctitle-1.3.8-cp314-cp314-win32.whl", hash = "sha256:7cdd3d6e5e8abcee233157615d88dbb80527a5a4eccb95a93fbf92e6d2c8f9dd", size = 12255, upload-time = "2026-10-01T21:08:12.203Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7c/13/e74a4fa864a0a694104ff74fcb3bef523be94321bac1a8ece64ad04ef233/setproctitle-1.3.8-cp314-cp314-win_amd64.whl", hash = "sha256:5cff3bdbe6be556cc19bd072ff1ed9b5a8f4cbf356cd19b1ca94506b3e2b29f6", size = 13159, upload-time = "2026-10-01T21:08:14.231Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/38/d8/019116e7defcd5d2c9264da4a82d369de6806a9161adf73e5f73e63fb715/setproctitle-1.3.8-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:84320e61f3906cc550b900ab1ba02ec53edd2d2e1e917f0873cba16592801c89", size = 18105, upload-time = "2026-10-01T21:07:38.655Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a7/f5/bfa9d6b5574903c17e02caba0e25815bb1c7e7b895d594475676baaa35b4/setproctitle-1.3.8-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:8086259943fc75eb07e11c1d08600709b9ce4fb2ec9bbd2490556c47d3ead135", size = 13125, upload-time = "2026-10-01T21:07:40.774Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d3/29/c7febeedee66b929c335d7b8ce83b1c4baccc65c94a4112fd8c1ea32b57d/setproctitle-1.3.8-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:8879d303d4e3559efdba033ff198c6869010f7958412ec2047674881859fdd7f", size = 34818, upload-time = "2026-10-01T21:07:47.999Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/36/b9/90fea18bcb74f19d411df7e9e2d981c4d3e99817870acb0b5cac6540629f/setproctitle-1.3.8-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f7de4da27fa4481e8a7a4ef58c908ffd2b996847c3d7fbf27b5c53ce0984c408", size = 35622, upload-time = "2026-10-01T21:07:51.03Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8f/e9/5899eab6e0b4a127e98a268a157b6bdba4f8ad18d0ed90fdf3e081c20a3b/setproctitle-1.3.8-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:741b1ae7e1cd68745b8b677daba73685dab2d1b8bb12500e6537f3482a91150f", size = 37762, upload-time = "2026-10-01T21:07:53.758Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fd/cd/190748a1f68afe6154b62517d2288b7d4c2092b0efa6e61d044c0f99d17b/setproctitle-1.3.8-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c85ff5b000eef8a280333ca158483a76f86bd374816add5c016a9f4294471289", size = 33548, upload-time = "2026-10-01T21:07:56.148Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/26/db/889062b0970f04bc76d8eed03165dc17de8df282399ad931cb10a23b33a3/setproctitle-1.3.8-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:656ffe282ec0ca18308eebb100898c79b4f5698a93228d50d2f2a4a09474d7e0", size = 34298, upload-time = "2026-10-01T21:07:58.898Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6d/bc/adedb2c18eb7bb152b6bc59187f46fc328e7bb729bf28a7e4e43521c4c7a/setproctitle-1.3.8-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:ae87e7b3e6414b3dd887adb72d2c4ea9f210c5f48efafd295ade4a58c760d29d", size = 35897, upload-time = "2026-10-01T21:08:01.561Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/38/8e/f1769dcd1eb668b01ad251eb6780b030752d18dabc1b82789b255189772e/setproctitle-1.3.8-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:09cb645c6ae440286391e256203fc03522b3b0f55fda8219f698abb5c447cce7", size = 32435, upload-time = "2026-10-01T21:08:04.112Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/79/e5/68be1eed21bba3ce27c6907ddcf0559cb99e4de3aa3ee000a38994371b73/setproctitle-1.3.8-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:84003eeaf2d7460390bbff1dbd7bee5b1213e7ae47a489f0fb7aad6acd2b045c", size = 34024, upload-time = "2026-10-01T21:08:06.514Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/40/7e/f275783d6915fac997dbfa3729330552c4f2ddcd4f1bba7ff522f5f05c28/setproctitle-1.3.8-cp314-cp314t-win32.whl", hash = "sha256:ac4e037d276ce27069cad0083c4611b45232278bd2fbac33f06ef9438c171a1e", size = 12259, upload-time = "2026-10-01T21:08:08.432Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/86/59/3347f13aa38c81d78f5c93bc55e4355c43550f47348e5de48c5080f3a1b2/setproctitle-1.3.8-cp314-cp314t-win_amd64.whl", hash = "sha256:c284642b229ba7b7b927fb044aba03694b880ab572db3f07a10adc786db1ff7b", size = 13163, upload-time = "2026-10-01T21:08:10.087Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/92/e4/e9866831fd0cff677c67488059fab3786a843ff0bd86f4b3c44bea8dd763/setproctitle-1.3.8-cp315-cp315-macosx_10_15_universal2.whl", hash = "sha256:63348d86ae60b071a898e4241b41da1346d8c36f1a60bf3b698ae5eb35b79865", size = 18107, upload-time = "2026-10-01T21:08:16.029Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ff/79/5c11a8c8cf3b91e54fdf4c93d1c79d99a491e04d77d34c80a90552fe6b46/setproctitle-1.3.8-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:59239b6e5007b1bec79ef444a390b3bcd59cbcb2686c9910da5a42f1e99f738c", size = 13132, upload-time = "2026-10-01T21:08:17.756Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9c/6d/47dea0a33ec67a2813e40bd92deea74c3732fd598bd71b636a92897eaf17/setproctitle-1.3.8-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:38310d9cf94959e39d22fdc0154c66c8bdbadfa790c524b04cb36da6333c7507", size = 33509, upload-time = "2026-10-01T21:08:20.254Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f1/7c/5d6945012077e6c393d59432df42d281d213f508bcf6d83a1287ab2eb9ae/setproctitle-1.3.8-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a279b136ed97407209d2dc9c30d1e65405d1a4a06ab162cedd9c4159b51f8f20", size = 34405, upload-time = "2026-10-01T21:08:22.796Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9f/d9/543a4470bfd01529dc35f0014dc68c70665db8b790e3647b41d155203b87/setproctitle-1.3.8-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:26997a85aa70bb088e86f0b7899fb0c909be824d22fc025e87b0005afbe59261", size = 36167, upload-time = "2026-10-01T21:08:25.35Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/44/c7/fc55041b162833c4bbbbfe78ed417bcab7b22f9fa72aff1722ff6af46fae/setproctitle-1.3.8-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:35fc5e10fcba6df25d676ef908b44a36c17e7f167738ed016561185e24f4d274", size = 32623, upload-time = "2026-10-01T21:08:27.778Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a5/e2/8c73c990c338b9ca5bf4fc6167ac864a80a53a10e71fd2755ba146f1fce6/setproctitle-1.3.8-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:f5df0503093ec8c3c7e1da53920e79c62ab653b51b136c4736caa252552a8732", size = 33510, upload-time = "2026-10-01T21:08:30.431Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cd/61/8e10270d3a7326dc4e8a1408c631e6ae912625b91f38adaf04794a19e07b/setproctitle-1.3.8-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:0a582308ba43afa7233d28243d9d1212e11c81d3c187a43929ec0cb70c4781c5", size = 34528, upload-time = "2026-10-01T21:08:37.161Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/77/d4/00773ca8c876123348e65edfd9eec47464bbfa1a31067c6e1cd382356a0f/setproctitle-1.3.8-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:ce48dbf74e8ec618d74cbaffe1159a4c32a4428de598f0ccdb0782bae618a72a", size = 31681, upload-time = "2026-10-01T21:08:39.874Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d5/42/19c6b634cca492575f9d99868bc35134528fb390d683d6a0396f61df0b8d/setproctitle-1.3.8-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:dd3a8fcee7d8a23e44781144830dee97b53ca4e0380bdd2a0e05b13913ce5725", size = 32999, upload-time = "2026-10-01T21:08:42.36Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/94/34/09f653f687e4a1a6f515642519cc65f0e6bcf34631386380924fc9785b44/setproctitle-1.3.8-cp315-cp315-win32.whl", hash = "sha256:50beee618377ce6fd35767a9327f2da594b36778eb10b503ee2dc9b7c801f433", size = 12251, upload-time = "2026-10-01T21:09:17.504Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/89/69/ab9afe8c198594533ad5eed6dcea647e1743ac8196a6c6dea974724b72e6/setproctitle-1.3.8-cp315-cp315-win_amd64.whl", hash = "sha256:f5916010de8b6045d7c63d98bb3f7a1e13f8c9c1046e859f2fd8de79c4e2d865", size = 13161, upload-time = "2026-10-01T21:09:19.295Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/78/90/da93e1ae012f2515473a45fb33f5ba2ddbbfcce1381c5e41005b31ab3230/setproctitle-1.3.8-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:e9f643bd97374aeb7e4274e5c361277bf1428e8e55246cee6823fa3525dc2c04", size = 18119, upload-time = "2026-10-01T21:08:44.296Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/af/35/41b28fa8eb8f1bee9c5516b99262a5df413937bf186e9d50ec3ef812fc61/setproctitle-1.3.8-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:fbd9ceb8c091c125e5892757e4d16af06674dc96edd7b5bf1e627b1ae7650c66", size = 13140, upload-time = "2026-10-01T21:08:46.797Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0c/19/089c878e6b8a3a391ceb03e1653ad6f33f27a5f7e204cf4a54b6a053b83d/setproctitle-1.3.8-cp315-cp315t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:322b4643f98c824b17dbf2ddb07ea7a37def8cc9e18adee320befce4bdffa271", size = 35122, upload-time = "2026-10-01T21:08:49.921Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/88/a7/f419b87fcb6202ef0a94f7cd6bdecb23c2d01f2f07b38f92d3f0c5dfb518/setproctitle-1.3.8-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9e36ee7300584a53fd7ac5f3853323411bde1cf6c081921bd3754a73b4071245", size = 35944, upload-time = "2026-10-01T21:08:52.612Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1e/16/fb181112f3c09a8c8962bd110f538c8a9d287a0c6a8bfd5b4dc39d54e0df/setproctitle-1.3.8-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:5c05aff52e6eb9c4d2ea86cf0d0a60b1487ed570263a1b13bb30d9f96aa8ba97", size = 37981, upload-time = "2026-10-01T21:08:55.136Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d8/8f/934846cf63b5ae2e9a88dcac6ddc3ec813e6b9e0919994684f7674155b8a/setproctitle-1.3.8-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:df807e7f036c19235320b6b5137291891d660f10ccb0b50dc46bc8385be18379", size = 34229, upload-time = "2026-10-01T21:08:57.703Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c9/04/c11f73d8aa0ebe5d63866130ad14ca3789a4dfb9fc617c3a612af9c177f9/setproctitle-1.3.8-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:bef8c5f8820c70e8761171409052056ffd247023b001a6254287a0694c3d8b1c", size = 34743, upload-time = "2026-10-01T21:09:04.088Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/38/50/8c780488db26e8f51af91465bda6ee224522248dc5220b282791dacbbe5e/setproctitle-1.3.8-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:7855290194637a3c5a2e37c423efbf5813fde97a6b63ab99feade5e05d73dc6c", size = 36094, upload-time = "2026-10-01T21:09:06.67Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b1/e6/13d541653607b3b7232dc9f8baae05b24112ac9a3756c3653903c624c4a9/setproctitle-1.3.8-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:8c0a7753f5ddaf0ecd1fc8df3e2106611d4290f0508e643e723cb5000b7d6c2f", size = 33148, upload-time = "2026-10-01T21:09:09.064Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/42/94/f3e16c3a7949fa28a777aa30830bf89098026e13669144b0ec1b147f17f4/setproctitle-1.3.8-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:97b35b15f81363a314baca76674c19027dce19eed1590abd51c2d285830efd50", size = 34488, upload-time = "2026-10-01T21:09:11.756Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4c/e7/9baa826fc44c6f607a39ad35d419da7f51dec2df31ef169e7a4a34e1cc75/setproctitle-1.3.8-cp315-cp315t-win32.whl", hash = "sha256:ecf44731e351c6100885120cecf53a0f43a1bb975a92480de1f9e022ab542bc1", size = 12260, upload-time = "2026-10-01T21:09:13.6Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/71/fb/08f55fab7294d18a6b1bc6d13340706c998b4641bd5f99ed9c7a626fcbf0/setproctitle-1.3.8-cp315-cp315t-win_amd64.whl", hash = "sha256:61aac898128dade36438da9387fea570f00cd519ad5231d3b268913afc2fc329", size = 13170, upload-time = "2026-10-01T21:09:15.351Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snowballstemmer"
|
||||
version = "3.1.1"
|
||||
@@ -1360,6 +1849,96 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/52/a7/d2782e4e3f77c8450f727ba74a8f12756d5ba823d81b941f1b04da9d033a/sphinxcontrib_serializinghtml-2.0.0-py3-none-any.whl", hash = "sha256:6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331", size = 92072, upload-time = "2024-07-29T01:10:08.203Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlalchemy"
|
||||
version = "2.1.5"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/08/bb/28e3106ee586e5b2f5ecf211eec1348055f0f926314b13fe23b9cffa9039/sqlalchemy-2.1.5.tar.gz", hash = "sha256:0df76cf1ca680ad745bd378a6299a058611a8a784eeaeb4ed78ad4a0b7ce2003", size = 10569593, upload-time = "2026-10-16T20:52:20.57Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/f6/aa/f10fc142d2db255249107ee8b21bfbabc10b90f7fadf13c3cf898acc6179/sqlalchemy-2.1.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:dc1c86db97372e6bba18a7bcf0f6150dbdd808237f0f52802ef0bec676a94642", size = 2465792, upload-time = "2026-10-16T22:42:39.038Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/eb/0d/d395e310e36b5bd39a121cd455504aa1e9111f419efaa88be6b814b4e54d/sqlalchemy-2.1.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6c229afac414d691d2f69a6f4e294ac5b5fd334c49da1f4fb86ab7f2a466271d", size = 4599703, upload-time = "2026-10-16T22:55:25.351Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f3/6d/04f4ffc5038571e712c4f88f20d7022091bafab082e85ea5b37a7e8270f1/sqlalchemy-2.1.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1cf433bcb77696cc915552d7f1e8d9117a5dae5aff9fceb06a69d74b3b3c2bd1", size = 4652645, upload-time = "2026-10-16T22:59:23.273Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/11/85/08bc336576755daf087e0888e44657f4f72b6676a99522e7a612f0c2481e/sqlalchemy-2.1.5-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:399d3e212cb557d5bd1ca6f79981e8c3f45c0f6be60b63a9ded790396a81af08", size = 4316833, upload-time = "2026-10-16T23:15:10.011Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a7/5c/476441255cc7afa25e8c75e5a61d3c5c3af7cf61c951ebed2ee9873ec4b1/sqlalchemy-2.1.5-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:6a51c56afdb880e9f83736a2e81c02dd002fe1c5ad68346a35d97a2e135b1568", size = 4523134, upload-time = "2026-10-16T22:55:27.374Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/63/ca/064e5e3ca7c8f256c8f9b5206eafd410a39226c2ab6fe7e8c1e70725e432/sqlalchemy-2.1.5-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:17f8c68bd35bb76b2d9ef1097941fb783ef9ef6604c1d2a72c2e276430aeffca", size = 4318058, upload-time = "2026-10-16T23:15:12.139Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/90/8c/e38956834896e21038a67193f91b189b9a61555b92fac42368027d5a2524/sqlalchemy-2.1.5-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:59dbd7412531da0124df8667a244b5155773632e9bd79a5c2ead393b11b59de5", size = 4613916, upload-time = "2026-10-16T22:59:25.19Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/14/b3/5531eb9d10d4bd38bd7e6c505776ac73be259dc117c9f07a8c46db4e9a2b/sqlalchemy-2.1.5-cp313-cp313-win32.whl", hash = "sha256:3f566787cb3a6a25ad8c5170e90167d4e8ea103d412aa4ea95021a6df0b95964", size = 2379136, upload-time = "2026-10-16T22:48:37.111Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a9/f6/c48924aafae616d59a2eb0375feeaf4bc4356327a442bda3b9205861b543/sqlalchemy-2.1.5-cp313-cp313-win_amd64.whl", hash = "sha256:fb8dcd5e1cc12fdd4d490819ec7a56e8c02e86ca9087a472e28b422ff932bae0", size = 2429688, upload-time = "2026-10-16T22:48:39.038Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/51/84/0855a7d42b700b091af6f817c171c2ff97478b0d5143fe61963adbff9201/sqlalchemy-2.1.5-cp313-cp313-win_arm64.whl", hash = "sha256:65eece9d9494e46de1eb3d49eb438acfcecf059e7a92a2f3daf72ec26d371757", size = 2390320, upload-time = "2026-10-16T22:31:43.871Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/01/b0/59b26375cd618e861a9295d855b866ca85be654d20ed47e494e33c3bf26e/sqlalchemy-2.1.5-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:5541a110ac4bb6377c785aea1b8f0b4d6658ed0ca5061ed1115d0725062b026b", size = 2468925, upload-time = "2026-10-16T22:42:40.547Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9e/a1/01931ba38770f169ce70e4034b0dcf2c1a776fe7d8dde93a34b6355510b1/sqlalchemy-2.1.5-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f029b2f7114623c03f762596f313515a2358004c44eb18924a15940f2e27d30f", size = 4593220, upload-time = "2026-10-16T22:55:29.253Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/42/9e/fa478482503a69dfb3b0cb82f3f80fe3816026530dd34b5359e2acd9f30d/sqlalchemy-2.1.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cc44dcc80e89a006af415edffc7409b1f2976a4597065449c166987f95801ab4", size = 4622806, upload-time = "2026-10-16T22:59:27.153Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fc/01/357ff85423013de8316316752c36a6bd1b7f3830c30dc63754afe06ba589/sqlalchemy-2.1.5-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:72ddd7a8ec187d02de0ef316a15aaf381ddcc594958247b02a3dcdb4c42f0b02", size = 4316247, upload-time = "2026-10-16T23:15:14.27Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/43/53/88c5af325c81c929d0ed5b7ec15b087173bd3587d93366c5e336b9647267/sqlalchemy-2.1.5-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:f5173a6e60a15090f9e2348a8ca94cc13de72796c16733f3b62fbb22acba07b8", size = 4522522, upload-time = "2026-10-16T22:55:30.835Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/87/29/f6f01f121d5e590c568f405f78b8eb3edace446c114126fc428536446dd6/sqlalchemy-2.1.5-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:09b10bd68223d57cce39c08947efae3f91ac40b552e07c7c869c3350a0fc4c23", size = 4317593, upload-time = "2026-10-16T23:15:16.397Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0c/6f/14863fc9aea433645851330242823b1879cdaac71c118f7c9366e7caf4da/sqlalchemy-2.1.5-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:ea4cb5022462d9f15e7b72a52c267385aa97ac224c8503ac63ba90c0067ad0d9", size = 4583207, upload-time = "2026-10-16T22:59:29.322Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a2/e9/6907fc009d9d06e8d03d6bf286df46e878ea2a85c839dcb65ef11ceb3a39/sqlalchemy-2.1.5-cp314-cp314-win32.whl", hash = "sha256:c3ffbe6c680c626403b7e9697d92465501078731b9e8863b1410826e66b950e1", size = 2386018, upload-time = "2026-10-16T22:48:40.692Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e1/d6/dea47b4b361c427d390edc10d73050e6d11d905c56ef26861ff5f94aa8fa/sqlalchemy-2.1.5-cp314-cp314-win_amd64.whl", hash = "sha256:061d089901319463a1160e4596191e355d2a9b4cce4852dac5adc301b085ac2f", size = 2436983, upload-time = "2026-10-16T22:48:42.2Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/be/28/305a91768a1ca0980c6ead455dcda5a2c1e616022901898e966ccf913ba9/sqlalchemy-2.1.5-cp314-cp314-win_arm64.whl", hash = "sha256:f5bc7fb93f1c17efefeb062bc4d2742ad1b71d56c36e6e2898a371ac6a56839a", size = 2401394, upload-time = "2026-10-16T22:31:45.275Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5f/6d/d4bab269d94ed1017950873643b5bd3eb271a5b8d5b0451250f0173f90fc/sqlalchemy-2.1.5-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:9bb993b1d0890a2da90589684c3d09de75df82c06aa8f7eda246c7cd0ea3e820", size = 2508315, upload-time = "2026-10-16T22:55:01.45Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/80/aeab72b51fceb71b1e1d62cabc6f51c9d8f20588165aa54e0d0d6cc77c05/sqlalchemy-2.1.5-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:df7e71ed051e4003e73484ef6547aacfb3a2322aac0c230d530c97e48e77b4d7", size = 4924848, upload-time = "2026-10-16T22:41:10.671Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/05/8b/7318ca0ae828fa1605dd4481f8eeecb5325a7ead6289c1206fb1ff1e2e1d/sqlalchemy-2.1.5-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c76d4cb9c76a6906563133449a76d9eae6c8529ca09484b8615ca604442b442e", size = 4835557, upload-time = "2026-10-16T23:06:18.482Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/35/17/7a5a196b0af72d65cbcd3a6fb7c4128693d039faf58a682ffe2d19329420/sqlalchemy-2.1.5-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:59a56be2e4e972061f9d5c1d5b01763b8b2207b48b956fbb6879c7443f5817f7", size = 4513707, upload-time = "2026-10-16T23:28:18.969Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/91/50/ca323ed15fc06c73a7fd85a3a339749994c560c12312ee8a53abf0f9a7ec/sqlalchemy-2.1.5-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:bc1a61d7f42e71746b5a2e10e90a6b174b4add441b7b6cf14278f1e029b2b800", size = 4781127, upload-time = "2026-10-16T22:41:12.784Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/26/3d/c56a75d0a2f6af08f6bb28d0b69e129911a2fc52b24dbafd7a7e5ac5c1aa/sqlalchemy-2.1.5-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:740e96dfb99a615c8056070d3747efe8bce4c145e5953ccc9e4b004c139de0d2", size = 4513816, upload-time = "2026-10-16T23:28:21.378Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7d/dd/84e0cd627bbd3e35b5f033191a4f597e611ff96e424db36a444a8d6755cc/sqlalchemy-2.1.5-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:92a0bb0595331c8e40bc615a67cc7bca9b761487409d1bf46c598b6ba5c0754d", size = 4772462, upload-time = "2026-10-16T23:06:20.876Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b7/47/cf0a920fc40344f8a1806d661e7c702341aebd871e31e1d1d6e0fbc9d1e0/sqlalchemy-2.1.5-cp314-cp314t-win32.whl", hash = "sha256:11185c72b5372369166cb721537943f8e1e6e42a399e9bac19e02f3ee20592a4", size = 2444861, upload-time = "2026-10-16T22:51:51.169Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bc/1d/4c5dc7e30fe740a01df4ba5ab800be2d7674b87f042e4c21c7ca89b36f9d/sqlalchemy-2.1.5-cp314-cp314t-win_amd64.whl", hash = "sha256:5173207b8fe1ddfc1d451c420a2a9cbbd0734b4a19896b8080e3744497e1c20c", size = 2512497, upload-time = "2026-10-16T22:51:53.014Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5f/2f/d3e9bfb1faabea302b98ba8c9dd6252bc362c6afeabe28ffcc1eea8a6bd2/sqlalchemy-2.1.5-cp314-cp314t-win_arm64.whl", hash = "sha256:def2f117a6ec0a25202ee36a148bbcfad3d43e2f2bb2e698e6d4448c6db5cb19", size = 2430598, upload-time = "2026-10-16T22:32:54.554Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ad/7c/17f07378eea7ec2fac8ac60f99fe3c474ef5c19a3adede70ae9886eb82d7/sqlalchemy-2.1.5-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:a0b80f91d9ed92be7a134278ea2e83a693c07d9986824ca51d859af9e57e18f5", size = 2468856, upload-time = "2026-10-16T22:27:43.754Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7f/c0/4fef29827b198937e09c40d0fa36b9738bd3914f0e5040927dfac8dfee21/sqlalchemy-2.1.5-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3033ddeeeb34c6c536622c07e932a20f8c9f58d6dd76e56595a76b55a25011ff", size = 4597018, upload-time = "2026-10-16T22:41:59.749Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/eb/d8/37645f8445ac3774e18f8dc72e0fa0ac868e0dff0e987ff3bec644f55102/sqlalchemy-2.1.5-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f4d30723171d511ec16ac057872a38b9b395420c0aaf81b2f94dd7bf1345c5fe", size = 4632322, upload-time = "2026-10-16T22:44:53.83Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c2/c9/15466cd08a6c329acc4f730dff7041e84122456fe38c518c93a07d6d82ca/sqlalchemy-2.1.5-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:5cefa5badc13df1c9082bacdfa435c8eb6dcb9b32717f51d09d1e160a599646f", size = 4338381, upload-time = "2026-10-16T23:01:22.714Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/12/2b/a93b7c8f6886138dac91f66fccd3b42473c365408d9a4c1b69403cf206f8/sqlalchemy-2.1.5-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:2549e503185897de1fc5ca7730d5daed0d27d0b26df4a059dcdd33ebe81b7b4b", size = 4525244, upload-time = "2026-10-16T22:42:01.631Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b3/47/d3926cacd194be073a2053a05470f20ed7da623f399e95213c1e497954fd/sqlalchemy-2.1.5-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:5a6871ee159a943d874012de835d56d0544ee871a99dbae05bc053da315b2c23", size = 4337223, upload-time = "2026-10-16T23:01:24.702Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ea/a8/b15ab4712342a18fb3949c77687c24d3749e86079c9905cc2cbebbd44da3/sqlalchemy-2.1.5-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:51e290080415325b66a94d20f6360e310606acb832f2bd677d4fcb95728e7ce1", size = 4594562, upload-time = "2026-10-16T22:44:55.661Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9a/ab/3b6ef6c77740d7fbf5a3eb45f95768fb809b0769bd21df81d5f8c002e5a5/sqlalchemy-2.1.5-cp315-cp315-win32.whl", hash = "sha256:c228084025a28aa038aef9b821d842508650fe12fe51f06e9cdaa4393be7812c", size = 2385770, upload-time = "2026-10-16T22:41:04.484Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4b/c1/0b3256bc11487b2846a26d58946caea0ed395fd500951a16fb82d31a20ff/sqlalchemy-2.1.5-cp315-cp315-win_amd64.whl", hash = "sha256:bc09dd22c3fc491a2df7d16ca4167de35573f40c2e82dd4d6ddae589a73e7032", size = 2437043, upload-time = "2026-10-16T22:41:06.12Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e5/a0/09eaa7897f6f745de16220b20c63660948a95716be90d2f405af08222e57/sqlalchemy-2.1.5-cp315-cp315-win_arm64.whl", hash = "sha256:375ef1bf78bc269a220963163d2580d5377898ed23a00bdd98a02d755421573d", size = 2401090, upload-time = "2026-10-16T22:28:58.035Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c2/c2/4c747dcc6fe329dd07ab57233f334eca19a3ff05934e0aba4f25a0977a67/sqlalchemy-2.1.5-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:7af1c92255cf8d50e87a808ce41096907332acdd09f285426a52f7c300e152db", size = 2504475, upload-time = "2026-10-16T22:55:02.946Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/07/f1/183446b1bc29484087ba7a6bb199a265c0559bf8ff201c1ee54bf1fe0936/sqlalchemy-2.1.5-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:85891e0828e76a77fe912995dbc3ee949099488ba0a2ab323535d2e767446b20", size = 4902197, upload-time = "2026-10-16T22:41:14.703Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/31/0b/b24baf343461eefdecc672df1ccbb14c8c64028a11625dabc97b0bb9791b/sqlalchemy-2.1.5-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a72e062d2d38826dd89231df692fb40f12d7d1b9d118be23bcc1cf93c6e31782", size = 4851871, upload-time = "2026-10-16T23:06:22.861Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/da/27/f688b34ea3d85b38e01b7463874f1f4b91619dfed4e6cac88c27caface73/sqlalchemy-2.1.5-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b79ee943e2e12246f873345762b83dbadd1fcfc3e832eab83272d672704dbdea", size = 4500095, upload-time = "2026-10-16T23:28:23.431Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/04/d8e13be8d0c25ba49244a9c24579ef61d5a6b57f98e55fbb173b7923ec3a/sqlalchemy-2.1.5-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:e9418d87b55c469c2f1328246d4533238cdc43134c695d6b9a6b7a87da49d463", size = 4757826, upload-time = "2026-10-16T22:41:16.465Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/86/2e/a0bd2ead949cc605ce3ad5d38e2fe84963b2aa7f89e8648c1bbad13a3679/sqlalchemy-2.1.5-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:898d86c22640fe52ffe02b4abc043a3c6754b4875837599e739be440966dffa1", size = 4499377, upload-time = "2026-10-16T23:28:25.203Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b9/dd/c1ca0713a1a7d8d6eb5864edd2d11d7a6a327aaba664645733cb53662425/sqlalchemy-2.1.5-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:b3ad20cd035392f2b91a6466e24643990c1378beda80c9bda87a3a41e841e838", size = 4777264, upload-time = "2026-10-16T23:06:25.203Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5a/dc/9dec72cea689f16bc8ecfcd62b4aa2796009a7cef6be85a9f70310ecf71b/sqlalchemy-2.1.5-cp315-cp315t-win32.whl", hash = "sha256:db34eefaf992c84460ab26ecf2fc2bdcc68965d6becfae8182cae0efeaa3e8f8", size = 2441666, upload-time = "2026-10-16T22:51:54.58Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/dc/28/f44c4524ce8a68935bd6f23ee801165072fb8c1e477fc9855efd9eaa2360/sqlalchemy-2.1.5-cp315-cp315t-win_amd64.whl", hash = "sha256:173054351d863ddada188284e309e87a9f030132c8d534e05458971ff061aa1e", size = 2507526, upload-time = "2026-10-16T22:51:56.262Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b1/fc/e90c91f6c2709a431f9b75e41bd31216337859411359f4a4fc2615c989e3/sqlalchemy-2.1.5-cp315-cp315t-win_arm64.whl", hash = "sha256:22c8d0873168a54f614e381559ea83d547b2cc5488b95b049bdc92667586bd5f", size = 2426204, upload-time = "2026-10-16T22:32:56.011Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/de/e9/61176e4753f74ab5f6e72a56314ee654d25c31e6fc98c99060442998cccb/sqlalchemy-2.1.5-py3-none-any.whl", hash = "sha256:2f77b77b716f005b2dc3cc059d56df6a919bfb5b439e4149890a9df6c36be9e3", size = 2060214, upload-time = "2026-10-16T22:43:30.801Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlalchemy-libsql"
|
||||
version = "0.2.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "greenlet" },
|
||||
{ name = "libsql-experimental" },
|
||||
{ name = "sqlalchemy" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/9c/3e/a628dad23a5310e00db674a5ddf92300acb4199a06ea82385cc48f6e9289/sqlalchemy_libsql-0.2.0.tar.gz", hash = "sha256:f6349c89ea10b941a9cd87ebb65330c660aff996c12d3da7e1696572c360edd1", size = 6405, upload-time = "2025-05-30T17:59:14.812Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/a2/b9/7a3b645766a9f0f2ba27580d1ec6eb1ade754b30f0c88fcc6bee4cc2cb20/sqlalchemy_libsql-0.2.0-py3-none-any.whl", hash = "sha256:852a731c64f318581942c81a5e18c9752a553af25608abbff04cd54ae1f3d451", size = 5929, upload-time = "2025-05-30T17:59:13.913Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlmodel"
|
||||
version = "0.0.48"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "pydantic" },
|
||||
{ name = "sqlalchemy" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/dd/67/b2c0b771c89c023262dd8fb6ba2cdc6a004e5ff75dd5763051b38ccd133a/sqlmodel-0.0.48.tar.gz", hash = "sha256:5582e87e845e23bb1179a7d8b11a4f5e441b4494528a41ee2fe1d129ffe91543", size = 99329, upload-time = "2026-10-06T21:44:36.391Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/4b/76/6f8221eda15f28471c3887e5a75a62cd7338d20ac03e1e78a110a127d61e/sqlmodel-0.0.48-py3-none-any.whl", hash = "sha256:8d389bf735b03a17508e93e888c13a30ef1ddca22dd8e57add12317401e4112e", size = 31468, upload-time = "2026-10-06T21:44:35.326Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "starlette"
|
||||
version = "1.8.0"
|
||||
@@ -1372,6 +1951,80 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c1/b0/5742e4ac7af5eb58ec3470a537a49d7aa507e5539413e504b3a65ef50ba8/starlette-1.8.0-py3-none-any.whl", hash = "sha256:dfdd6b29c26483288088d990eee59631dedadd66ce20d203402a7ca8e3c4656f", size = 79612, upload-time = "2026-10-13T07:54:38.019Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textual"
|
||||
version = "8.2.8"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "markdown-it-py", extra = ["linkify"] },
|
||||
{ name = "mdit-py-plugins" },
|
||||
{ name = "platformdirs" },
|
||||
{ name = "pygments" },
|
||||
{ name = "rich" },
|
||||
{ name = "typing-extensions" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/00/21/39a76b01bd5eea82a04baaca7580e105d8c59450df03998345bb2cfb307b/textual-8.2.8.tar.gz", hash = "sha256:3f106a9fbc73e39dd266c9712432087de78a6d644084c7c241d6a25c3169115b", size = 1860502, upload-time = "2026-06-30T06:51:24.495Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fb/be/35261223d9416a0751cdff1c7b4a6f881387218a12d439fe22fefebc8c04/textual-8.2.8-py3-none-any.whl", hash = "sha256:267375fd402dc8d981457212efa71f0e3365fd17bba144ba9bb3ed7563cb374a", size = 731418, upload-time = "2026-06-30T06:51:26.364Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-machine"
|
||||
version = "3.5.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/65/d2/065a4d202d7ba093145e6f803fafd84bdcea41f3ce5f5ee6dacc77330719/time_machine-3.5.1.tar.gz", hash = "sha256:eb2c50404820fde8bfc6a0713b2a0b8eabececfecefde3a5847ae8006037829f", size = 28434, upload-time = "2026-09-08T22:19:49.989Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/8e/aa/f2dd3acae3168f5e5076b46c42f52550d39b1b69906f77e81b486721a06a/time_machine-3.5.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:31aa239f2e02ec71682eadbf387d43bfe372b9409ff0dd148eca19d736402c73", size = 27663, upload-time = "2026-09-08T22:19:04.61Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/41/ce/8aa00371e2e0ced89534e84753a880989794effae19736a9ef9d59934110/time_machine-3.5.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:cd9252e190b2c6079fd3ec9a7afc26fd26008fee1dc9940714e7d4755668b7ea", size = 27780, upload-time = "2026-09-08T22:19:05.614Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/99/fc/970e954e53e0cc3e241fc665b0f797a2708dc680553641942acf61ed6265/time_machine-3.5.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:8a39af6fad7115e2c9d0deef287645260b096919d8918d52191d80ac31e43525", size = 59870, upload-time = "2026-09-08T22:19:06.624Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2b/e1/e1814122b0ea321e2714f369dd3de8f052eb132097757112a9fe497129cb/time_machine-3.5.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6edb56e4a41b2d717f28fbdc04ac3fc7cff43b2f573e88189d67650680eb672e", size = 60776, upload-time = "2026-09-08T22:19:08.005Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f6/1b/09acb019f25d918c04e470e7a410d5aeffb087b8457d6e0815c576e013ef/time_machine-3.5.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:d4cea8ed128c65fe262cc216a4f46fb6080b745a3013baba188e45992ce673c5", size = 59584, upload-time = "2026-09-08T22:19:09.13Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/10/15/c4df8f02cbe773462dd60da9ab263407b4dd06b615350b889b70f6bd49b7/time_machine-3.5.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:c615f45b3668fa2ccd4ad2b81899d22efe4e33d23b3540283922796de57ad37c", size = 59088, upload-time = "2026-09-08T22:19:10.587Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3f/e8/cae3230abdbd7fcf81bbd70c7a1047f07e98a31536db979960dbbdc2b72e/time_machine-3.5.1-cp313-cp313-win_amd64.whl", hash = "sha256:c0a865aca362e645947159f2e0e3022131e591ba113b95f2b355410c36ddcd60", size = 29621, upload-time = "2026-09-08T22:19:11.688Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/20/47/224a9428327db95abe9bd52462db744fdc84db61da0cd19df2a611da3afd/time_machine-3.5.1-cp313-cp313-win_arm64.whl", hash = "sha256:27095e90a2b42c2979f40146feb1bbf077dcf6a610889ae5dc36fa015e4fe2ef", size = 28956, upload-time = "2026-09-08T22:19:12.748Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/83/ef/67a4edd8f6f981be4424dc7eb086b42ff8886bdb333671d89009d57efed4/time_machine-3.5.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:af8f4a7d729c0d8700d826a5c6befef73010ca0a92fb19ac987d040fbca896e2", size = 27692, upload-time = "2026-09-08T22:19:13.813Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/82/b3/ec9b5758cdb3392a081d9d2da941bca39901a1709596a88695bb522f5423/time_machine-3.5.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:2dc5d12a355e4ab2103f3527f014eb2c7fd50693f3f176cd7750c5f6f83b7e86", size = 27802, upload-time = "2026-09-08T22:19:14.942Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b8/a7/e0aa85084621165d659333e5b47755e592bf101a677d8a3e52501a6b3cdd/time_machine-3.5.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:db80ab6d055a550d5c83f4f55d7c9918fc9531ca3f036c95db02ce266b36ac11", size = 59906, upload-time = "2026-09-08T22:19:15.966Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c3/d3/a2d470d512e8f1753f7fe593a76314878ac06061d189b4594f2c0f9a933d/time_machine-3.5.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4a0c375c0dc8a3f56a30bf044da2437ae4f869e1ba1c0ea9eb9d279e8174ec41", size = 60851, upload-time = "2026-09-08T22:19:17.017Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/92/82/a15d3c763e68578e74a0542f0bc08b22179476829bc90cde785d17566871/time_machine-3.5.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:86014c719210389bcfddebd29be3da34651866a7b516648a18f310aaf994b069", size = 59651, upload-time = "2026-09-08T22:19:18.063Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/98/44/724ab17ece00036e5260c1411889cc244888a7e5f8af19a76675f9fa6138/time_machine-3.5.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:e49e9ff451a645906d621aba4fb2d22e334215230a94e0e582d67b33e24970fd", size = 59108, upload-time = "2026-09-08T22:19:19.205Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/a9/1e/b694ab775fa2d8aa5c42fa68f02e35442531de84103ca2d1ec5c1ca86d96/time_machine-3.5.1-cp314-cp314-win_amd64.whl", hash = "sha256:0f5012ac22f86366b8afd1aa01162f8ce6a7228a23a39168c7039c5cbdb9b08e", size = 29881, upload-time = "2026-09-08T22:19:20.365Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/54/fa/1d2c726ccc5492dbe73bbbbb195e34657c666bfaa8277816a0ed6c791c15/time_machine-3.5.1-cp314-cp314-win_arm64.whl", hash = "sha256:3138159b26ca711991b87b4141e089ee5ce5fe7db4958612271fffd0d4209081", size = 29149, upload-time = "2026-09-08T22:19:21.369Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2f/59/39e94a440624a954a6084898927df5fcc047bb726be55702c91655bfcbfc/time_machine-3.5.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:2250eba37ebd82fe7235f13fc863f2ad21e02aa6fe3c9d3035acb4e82f321e38", size = 28388, upload-time = "2026-09-08T22:19:22.421Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/15/fb/4bf8ee92bef263359aa9490de65a2518ed5bc785410468ab91667d6a0f39/time_machine-3.5.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:b784ec07e978e7f504378302833ecb487b9007218fa5344c1346dd1be4904770", size = 28721, upload-time = "2026-09-08T22:19:23.511Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/21/02/49113f81a3400f23c8494c89beeea8dda73cc4a70b6a193cc0ec7bb3f111/time_machine-3.5.1-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:b68b8f472ea34b4ad0e927777dc8aa49bfac77526571de40e358d1d5f5fa99bd", size = 71282, upload-time = "2026-09-08T22:19:24.546Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/12/32/1e34afcdec8afb135eab3304749d06e042c53974da547cb78ceaee2b2b0a/time_machine-3.5.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a6b409d92cca522c0c1d0ce51894803dd2997054004c4d50273a1d748764749c", size = 73421, upload-time = "2026-09-08T22:19:25.806Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/04/95/bdaacbf58eee21eb14127702ff80fcc2e25c4938111fe948887507022f06/time_machine-3.5.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:fbf8272e461ea311b9feff10021b4a735d6c0076569fb860bda49358ac8b1dee", size = 71692, upload-time = "2026-09-08T22:19:26.847Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1e/42/42c0796a8e1cd866fec78edb8ff1c6d360de26900f6fcdbe1dfe735acc7c/time_machine-3.5.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:ee142848d6f51e719d23d233ae381fb7f1db12bffee1dbd4ed7eba9e0d81ea39", size = 69830, upload-time = "2026-09-08T22:19:27.941Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/66/c9/482b603caee78c3a459f85118ef327795d41a5858914152eaffffbd64478/time_machine-3.5.1-cp314-cp314t-win_amd64.whl", hash = "sha256:759ec7a3d175ae3b468ec5b7e426a8d0d85f05e543e5aefa20dc99d95fd87535", size = 31108, upload-time = "2026-09-08T22:19:29.24Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c8/1e/b2ddad5bfbc81691eb95caa11de00132222cd761d029be86fcc81e72d4ee/time_machine-3.5.1-cp314-cp314t-win_arm64.whl", hash = "sha256:66b1c8848794ac83551c643283497fd1ed9dff19b20e86e474fc15a8032e5886", size = 29401, upload-time = "2026-09-08T22:19:30.298Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8e/3a/5c9a8cfc1f0bc6add00eed747196c9269a7cd2fd2d13f4f7ef3c65564f42/time_machine-3.5.1-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:f1baa36df51e750a9fae86f32dc8f92915ebd26dbebd4c61dda28ae46ab8faf7", size = 27693, upload-time = "2026-09-08T22:19:31.34Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/67/6a/b0f27d3831d440c91110319e7f2f733c32fa886ae6eae442d7f6e6a5bbc9/time_machine-3.5.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:9f1704e632dd05d93b2c350e9b317ee138071ad7ce53f38e5e06b8543d0764c0", size = 27803, upload-time = "2026-09-08T22:19:32.424Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/76/2c/337bf3a7dda4e76e0689d2e10d9c9fb34694823b1a8cc6ad15d2c935b48a/time_machine-3.5.1-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:cf1b835219b61565bdc4e2bdb268b3f42a6b4443a0af4060260f65c7b3bdb781", size = 60083, upload-time = "2026-09-08T22:19:33.471Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/20/c39de4198557c112d4fdb00d14c73ceef05280fedce9ef113265ac2b5c51/time_machine-3.5.1-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:36c1b8790ab98103184d61866feb944589957fb30f9e6e05856012787ea3aea5", size = 61045, upload-time = "2026-09-08T22:19:34.599Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/37/78/031646e6af3f36c8311888ec4c460a073c5c52d08c163df3d58c629f809e/time_machine-3.5.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:714b27fa2a2d0cde33fe363a42f3eb477078661fa0ecfae185de67e1c9348c1b", size = 59857, upload-time = "2026-09-08T22:19:35.781Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/04/87/8aba4a897e2d4bb29e786bdf6757d8ab77b2c37ba75f7e22526f619c3c5c/time_machine-3.5.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:2f7315ea64cd81405ed17c4a9835d8762a28a1471dae709b5c7d8680cd5495a9", size = 59288, upload-time = "2026-09-08T22:19:36.902Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c4/c1/880ee7847301111a8e7bb531410e56fd5af7969a929bb174a83f0e3c0fd1/time_machine-3.5.1-cp315-cp315-win_amd64.whl", hash = "sha256:a1e9423f9c03a8076d67c644c6d4dbe15f6bfc5174f928fa34a84ffb2fdbd7c6", size = 29877, upload-time = "2026-09-08T22:19:38.039Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8b/15/075d9cd9c56de3ef331416dbd73639ba77f9108e5dcec64e046e85c9a947/time_machine-3.5.1-cp315-cp315-win_arm64.whl", hash = "sha256:73632a71eb038477a13212026f4ff26e0eb0208ee45268c345a9b97a5e102814", size = 29151, upload-time = "2026-09-08T22:19:39.325Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/05/86/b4b5a1a691f4572d5e45dd5a912f3daf0851a56af6b21814583147bd8025/time_machine-3.5.1-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:5b1cd9c4429c2c4e341bee940166c59c030104afa6a99ba7053c118092dd9cff", size = 28390, upload-time = "2026-09-08T22:19:40.395Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/22/6b618d2fceaf40c0963be7aa320063116abb9674cd4d8d862f01ff146a42/time_machine-3.5.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:63c3f74787b96066e737408d679a6a75b750e6de30c276609e99f13c0a12e271", size = 28721, upload-time = "2026-09-08T22:19:41.507Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f2/a3/1618a4d85a4670d073ec15fae7a44a99defd30652e8a38fd785e135d9474/time_machine-3.5.1-cp315-cp315t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:2f935a9beef5e31b7cd71ac600ded551c10a748177e679bbb2858b4aa907b509", size = 71323, upload-time = "2026-09-08T22:19:42.546Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6b/75/d6ce2f9883240c512db3045e5ee4949f262e6d6ae22a00c2e20ee681dfbd/time_machine-3.5.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3e00130b5305f3d06661a04734a7284c1445b454d22b7ff2b3bd534508fb8fcc", size = 73455, upload-time = "2026-09-08T22:19:43.607Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7a/cd/a098587f4766f5d4310813a8a9a3ff9cc13edf3039cd8016b2dbaed0c4a1/time_machine-3.5.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:89d4a895af01d5fcef106e09d3b966be3fcb02b41bcbf901962b8bd37d65456c", size = 71791, upload-time = "2026-09-08T22:19:44.959Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9d/04/783c797b2c33e10d4eb0fbf24b1ea4cffcc335d38cc931fc281b826a6e41/time_machine-3.5.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:d2f9761060f914802ed27797c3b311e992e13c5df3982c2450770d121a76803f", size = 69858, upload-time = "2026-09-08T22:19:46.143Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/bf/78ac2f56be79300491ef775535a18230845abb0dc4283f30a95daaad9644/time_machine-3.5.1-cp315-cp315t-win_amd64.whl", hash = "sha256:fe970adb31deac67a6f7a1dee2a7a8d0cb4c8496a0dd87c7c6e2430fc767d565", size = 31094, upload-time = "2026-09-08T22:19:47.469Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cc/35/86e1f95600a353361ae138268aa53cc2d17e6404801827d4ec09dc59b1af/time_machine-3.5.1-cp315-cp315t-win_arm64.whl", hash = "sha256:1990c1a3234d1df441ce084618b68d3c4a083f17dea4fd47adcf68d6668b507b", size = 29399, upload-time = "2026-09-08T22:19:48.68Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "truststore"
|
||||
version = "0.10.5"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/ee/9f/c5201d42a484c061e528825fc8e2d565f5abd50a4ced6fb7d29c4ec99b2b/truststore-0.10.5.tar.gz", hash = "sha256:30d36967ccaded5cbb38d602c433f53600036c79d502f4533a49b60a03bbefcd", size = 28091, upload-time = "2026-10-12T22:27:31.808Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/51/e9/3a7820be2bb0fe53b6bc9c3be26d3d1158004e4c3ab953aa6840b955b1e9/truststore-0.10.5-py3-none-any.whl", hash = "sha256:9aaaedaefaf06d8b206278cf8b5012bc897f485a874503501e12d776df78951c", size = 19017, upload-time = "2026-10-12T22:27:30.377Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "4.16.0"
|
||||
@@ -1393,6 +2046,15 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/67/81/4add07e5172b7ac40d8ed5ff580409a7801a4fe26d529bdd915401dabfbe/typing_inspection-0.4.4-py3-none-any.whl", hash = "sha256:65b8397ba37ccbce054456aaccddfc91e6e3083c92824df348d96ca832f3f147", size = 14750, upload-time = "2026-08-12T12:37:24.648Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tzdata"
|
||||
version = "2026.5"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/d9/68/f1b440335057bfce71b6e50a9d09445aa2ecbd08359a337976627b8409e7/tzdata-2026.5.tar.gz", hash = "sha256:8cc73c0a0bfca7dbfa59235d60b2eff82231dee33f53d206db1acd9173cfc0a7", size = 200404, upload-time = "2026-10-03T09:23:14.143Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/94/21/1e5995a1c920cce14e4bffae20c665ec10e7ed03ab25e006cd741092b718/tzdata-2026.5-py2.py3-none-any.whl", hash = "sha256:b683bd1b6659ddcd810ff02ad09ba821d4bf1065072805063eb35c49617905ac", size = 347996, upload-time = "2026-10-03T09:23:12.535Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urllib3"
|
||||
version = "2.8.0"
|
||||
|
||||
Reference in new issue
Block a user