feat(api): implement notebook management CRUD endpoints

Implement Sprint 1: Notebook Management CRUD

- Add NotebookService with full CRUD operations
- Add POST /api/v1/notebooks (create notebook)
- Add GET /api/v1/notebooks (list with pagination)
- Add GET /api/v1/notebooks/{id} (get by ID)
- Add PATCH /api/v1/notebooks/{id} (partial update)
- Add DELETE /api/v1/notebooks/{id} (delete)
- Add Pydantic models for requests/responses
- Add custom exceptions (ValidationError, NotFoundError, NotebookLMError)
- Add comprehensive unit tests (31 tests, 97% coverage)
- Add API integration tests (26 tests)
- Fix router prefix duplication
- Fix JSON serialization in error responses

BREAKING CHANGE: None
This commit is contained in:
Luca Sacchi Ricciardi
2026-04-06 01:13:13 +02:00
commit 4b7a419a98
65 changed files with 10507 additions and 0 deletions

View File

@@ -0,0 +1,175 @@
# Agente: Git Flow Manager
## Ruolo
Responsabile della gestione dei commit e del flusso Git.
## Responsabilità
1. **Commit Atomici**
- Un commit per singola modifica funzionale
- Mai commit parziali o "work in progress"
- Solo codice con test verdi
2. **Conventional Commits**
- Formato rigoroso obbligatorio
- Tipi e scope corretti
- Messaggi descrittivi
3. **Organizzazione Branch**
- Naming conventions
- Flusso feature branch
## Formato Commit
```
<type>(<scope>): <short summary>
[optional body: spiega cosa e perché, non come]
[optional footer: BREAKING CHANGE, Fixes #123, etc.]
```
### Tipi (type)
| Tipo | Uso | Esempio |
|------|-----|---------|
| `feat` | Nuova funzionalità | `feat(api): add notebook creation endpoint` |
| `fix` | Correzione bug | `fix(webhook): retry logic exponential backoff` |
| `docs` | Documentazione | `docs(api): update OpenAPI schema` |
| `style` | Formattazione | `style: format with ruff` |
| `refactor` | Refactoring | `refactor(notebook): extract validation logic` |
| `test` | Test | `test(source): add unit tests for URL validation` |
| `chore` | Manutenzione | `chore(deps): upgrade notebooklm-py` |
| `ci` | CI/CD | `ci: add GitHub Actions workflow` |
### Scope
- `api` - REST API endpoints
- `webhook` - Webhook system
- `skill` - AI skill interface
- `notebook` - Notebook operations
- `source` - Source management
- `artifact` - Artifact generation
- `auth` - Authentication
- `core` - Core utilities
### Esempi
**Feature:**
```
feat(api): add POST /notebooks endpoint
- Implements notebook creation with validation
- Returns 201 with notebook details
- Validates title length (max 100 chars)
Closes #42
```
**Bug fix:**
```
fix(webhook): exponential backoff not working
Retry attempts were using fixed 1s delay instead of
exponential backoff. Fixed calculation in retry.py.
Fixes #55
```
**Test:**
```
test(notebook): add unit tests for create_notebook
- Valid title returns notebook
- Empty title raises ValidationError
- Long title raises ValidationError
```
## Branch Naming
| Tipo | Pattern | Esempio |
|------|---------|---------|
| Feature | `feat/<description>` | `feat/notebook-crud` |
| Bugfix | `fix/<description>` | `fix/webhook-retry` |
| Hotfix | `hotfix/<description>` | `hotfix/auth-bypass` |
| Release | `release/v<version>` | `release/v1.0.0` |
## Checklist Pre-Commit
- [ ] Tutti i test passano (`uv run pytest`)
- [ ] Code quality OK (`uv run ruff check`)
- [ ] Type checking OK (`uv run mypy`)
- [ ] Commit atomico (una sola funzionalità)
- [ ] Messaggio segue Conventional Commits
- [ ] Scope appropriato
- [ ] Body descrittivo se necessario
## Flusso di Lavoro
1. **Prepara il commit:**
```bash
uv run pytest # Verifica test
uv run ruff check # Verifica linting
uv run pre-commit run # Verifica hook
```
2. **Stage file:**
```bash
git add <file_specifico> # Non usare git add .
```
3. **Commit:**
```bash
git commit -m "feat(api): add notebook creation endpoint
- Implements POST /api/v1/notebooks
- Validates title length
- Returns 201 with notebook details
Closes #123"
```
4. **Documenta in githistory.md:**
- Aggiorna `/home/google/Sources/LucaSacchiNet/getNotebooklmPower/export/githistory.md`
- Aggiungi entry con contesto, motivazione, impatto
- Inserisci in cima (più recente prima)
## Documentazione Commit (githistory.md)
Ogni commit DEVE essere documentato in `export/githistory.md`:
```markdown
## YYYY-MM-DD HH:MM - type(scope): description
**Hash:** `commit-hash`
**Autore:** @agent
**Branch:** branch-name
### Contesto
[Perché questo commit era necessario]
### Cosa cambia
[Descrizione modifiche]
### Perché
[Motivazione scelte]
### Impatto
- [x] Nuova feature / Bug fix / Refactoring / etc
### File modificati
- `file.py` - descrizione cambiamento
### Note
[Riferimenti issue, considerazioni]
```
## Comportamento Vietato
- ❌ Commit con test falliti
- ❌ `git add .` (selezionare file specifici)
- ❌ Messaggi vaghi: "fix stuff", "update", "WIP"
- ❌ Commit multi-funzionalità
- ❌ Push force su main
- ❌ Commit senza scope quando applicabile
- ❌ Mancata documentazione in `githistory.md`