From 7204dd6b60e8b2b2da5aa267b4d481afc88c0417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Mon, 30 Nov 2026 21:20:13 +0100 Subject: [PATCH] feat: v2.2 batch (calendar, self-service, sort, description, filename search, stats, collab, invoice) on pre-redesign base --- AI_MEMORY.md | 20 +- CLAUDE.md | 71 + drizzle/0002_release_notes_calendar.sql | 45 + drizzle/0003_collab_invoice_activity.sql | 35 + drizzle/meta/0002_snapshot.json | 2285 +++++++++++++++ drizzle/meta/0003_snapshot.json | 2491 +++++++++++++++++ drizzle/meta/_journal.json | 14 + public/brand/logo-black-header.png | Bin 0 -> 27121 bytes public/brand/logo-white-header.png | Bin 0 -> 3626 bytes scripts/render-pdf-fixture.ts | 1 + .../[editorialId]/BillingSelection.test.tsx | 3 + .../[editorialId]/BillingSelection.tsx | 184 +- .../[editorialId]/page-content.ts | 12 + src/app/admin/kalender/CalendarEventForm.tsx | 99 + .../kalender/DeleteCalendarEventButton.tsx | 44 + src/app/admin/kalender/actions.ts | 84 + src/app/admin/kalender/page.tsx | 107 + src/app/admin/layout.tsx | 3 + src/app/admin/redaktionen/[id]/actions.ts | 34 + .../redaktionen/[id]/alben/page.test.tsx | 1 + src/app/admin/redaktionen/[id]/page.tsx | 1 + src/app/admin/statistiken/page.tsx | 358 +++ .../admin/statistiken/stats-charts-lazy.tsx | 15 + src/app/admin/statistiken/stats-charts.tsx | 177 ++ .../versionen/DeleteReleaseNoteButton.tsx | 31 + src/app/admin/versionen/ReleaseNoteForm.tsx | 91 + src/app/admin/versionen/actions.ts | 83 + src/app/admin/versionen/page.tsx | 66 + src/app/api/activity/route.ts | 41 + .../[reportId]/invoice/invoice-handler.ts | 156 ++ .../[reportId]/invoice/resend/route.ts | 3 + .../[reportId]/invoice/route.ts | 4 + .../api/billing-reports/finalize-handler.ts | 36 +- .../api/download-intents/intent-handler.ts | 4 + src/app/api/download-intents/route.test.ts | 44 + .../lightbox/bulk-download/bulk-handler.ts | 16 +- .../usages/[usageId]/collab/collab-handler.ts | 79 + src/app/api/usages/[usageId]/collab/route.ts | 3 + src/app/globals.css | 157 +- src/app/redaktion/alben/[albumId]/page.tsx | 30 +- src/app/redaktion/alben/page.tsx | 37 +- .../redaktion/kalender/EventRsvpButtons.tsx | 71 + .../redaktion/kalender/SelfGrantButton.tsx | 47 + src/app/redaktion/kalender/actions.ts | 89 + src/app/redaktion/kalender/page.tsx | 84 + src/app/redaktion/layout.tsx | 2 + .../leuchtkasten/DownloadLightboxForm.tsx | 31 +- src/app/redaktion/leuchtkasten/page.tsx | 19 +- src/app/redaktion/neuigkeiten/page.tsx | 40 + src/components/brand/logo.tsx | 4 +- src/components/download/usage-dialog.test.tsx | 52 + src/components/download/usage-dialog.tsx | 27 +- src/components/layout/portal-shell.tsx | 4 +- src/db/schema/activity.ts | 34 + src/db/schema/albums.ts | 6 + src/db/schema/billing.ts | 19 + src/db/schema/calendar.ts | 42 + src/db/schema/editorials.ts | 1 + src/db/schema/index.ts | 3 + src/db/schema/releases.ts | 27 + src/db/schema/usages.ts | 1 + src/modules/activity/service.test.ts | 84 + src/modules/activity/service.ts | 83 + src/modules/albums/auto-rules.test.ts | 5 +- src/modules/albums/auto-rules.ts | 1 + src/modules/albums/catalog-content.test.tsx | 3 +- src/modules/albums/catalog-content.tsx | 11 +- src/modules/albums/catalog.test.ts | 33 + src/modules/albums/catalog.ts | 38 +- src/modules/albums/filter.test.ts | 33 +- src/modules/albums/filter.ts | 31 + src/modules/albums/grants.test.ts | 62 +- src/modules/albums/grants.ts | 66 + src/modules/albums/photo-gallery.tsx | 35 +- src/modules/billing/invoice.test.ts | 141 + src/modules/billing/invoice.ts | 302 ++ src/modules/billing/queries.test.ts | 8 + src/modules/billing/queries.ts | 4 + src/modules/billing/reports.test.ts | 1 + src/modules/billing/reports.ts | 4 + src/modules/billing/types.ts | 2 + src/modules/calendar/event-albums.test.ts | 57 + src/modules/calendar/event-albums.ts | 46 + src/modules/calendar/service.test.ts | 266 ++ src/modules/calendar/service.ts | 468 ++++ src/modules/downloads/stream.ts | 11 +- src/modules/editorials/admin-detail.tsx | 34 +- src/modules/email/invoice-message.test.ts | 11 + src/modules/email/invoice-message.ts | 21 + src/modules/email/service.ts | 35 + src/modules/immich/client.ts | 2 + src/modules/immich/types.ts | 3 +- src/modules/pdf/document.ts | 2 +- src/modules/releases/service.test.ts | 98 + src/modules/releases/service.ts | 203 ++ src/modules/security/rate-limit.ts | 3 + src/modules/stats/queries.test.ts | 56 + src/modules/stats/queries.ts | 364 +++ src/modules/usages/collab-admin.test.ts | 70 + src/modules/usages/collab-admin.ts | 118 + src/modules/usages/service.ts | 29 +- src/modules/usages/types.ts | 8 +- test-results/.last-run.json | 4 + tests/db/accounting-migration.test.ts | 4 + tests/db/album-grants.test.ts | 4 + tests/db/postgres.ts | 11 +- tests/db/usage-accounting.test.ts | 61 + tests/fixtures/billing-report.ts | 1 + 108 files changed, 10400 insertions(+), 105 deletions(-) create mode 100644 CLAUDE.md create mode 100644 drizzle/0002_release_notes_calendar.sql create mode 100644 drizzle/0003_collab_invoice_activity.sql create mode 100644 drizzle/meta/0002_snapshot.json create mode 100644 drizzle/meta/0003_snapshot.json create mode 100644 public/brand/logo-black-header.png create mode 100644 public/brand/logo-white-header.png create mode 100644 src/app/admin/kalender/CalendarEventForm.tsx create mode 100644 src/app/admin/kalender/DeleteCalendarEventButton.tsx create mode 100644 src/app/admin/kalender/actions.ts create mode 100644 src/app/admin/kalender/page.tsx create mode 100644 src/app/admin/statistiken/page.tsx create mode 100644 src/app/admin/statistiken/stats-charts-lazy.tsx create mode 100644 src/app/admin/statistiken/stats-charts.tsx create mode 100644 src/app/admin/versionen/DeleteReleaseNoteButton.tsx create mode 100644 src/app/admin/versionen/ReleaseNoteForm.tsx create mode 100644 src/app/admin/versionen/actions.ts create mode 100644 src/app/admin/versionen/page.tsx create mode 100644 src/app/api/activity/route.ts create mode 100644 src/app/api/billing-reports/[reportId]/invoice/invoice-handler.ts create mode 100644 src/app/api/billing-reports/[reportId]/invoice/resend/route.ts create mode 100644 src/app/api/billing-reports/[reportId]/invoice/route.ts create mode 100644 src/app/api/usages/[usageId]/collab/collab-handler.ts create mode 100644 src/app/api/usages/[usageId]/collab/route.ts create mode 100644 src/app/redaktion/kalender/EventRsvpButtons.tsx create mode 100644 src/app/redaktion/kalender/SelfGrantButton.tsx create mode 100644 src/app/redaktion/kalender/actions.ts create mode 100644 src/app/redaktion/kalender/page.tsx create mode 100644 src/app/redaktion/neuigkeiten/page.tsx create mode 100644 src/db/schema/activity.ts create mode 100644 src/db/schema/calendar.ts create mode 100644 src/db/schema/releases.ts create mode 100644 src/modules/activity/service.test.ts create mode 100644 src/modules/activity/service.ts create mode 100644 src/modules/billing/invoice.test.ts create mode 100644 src/modules/billing/invoice.ts create mode 100644 src/modules/calendar/event-albums.test.ts create mode 100644 src/modules/calendar/event-albums.ts create mode 100644 src/modules/calendar/service.test.ts create mode 100644 src/modules/calendar/service.ts create mode 100644 src/modules/email/invoice-message.test.ts create mode 100644 src/modules/email/invoice-message.ts create mode 100644 src/modules/releases/service.test.ts create mode 100644 src/modules/releases/service.ts create mode 100644 src/modules/stats/queries.test.ts create mode 100644 src/modules/stats/queries.ts create mode 100644 src/modules/usages/collab-admin.test.ts create mode 100644 src/modules/usages/collab-admin.ts create mode 100644 test-results/.last-run.json diff --git a/AI_MEMORY.md b/AI_MEMORY.md index c893e5d..3c8b5b5 100644 --- a/AI_MEMORY.md +++ b/AI_MEMORY.md @@ -31,7 +31,8 @@ Redaktionen können Bilder durchsuchen, einen Leuchtkasten verwenden, Bilder her - Diese Logik befindet sich in `src/modules/editorials/service.ts` unter `hardDeleteEditorial`. ## 4. UI & Styling Quirks -- **Logo Skalierung:** Das Hauptlogo (`logo-black.png` / `logo-white.png`) darf im ``-Tag **keine** harten `width` und `height`-Attribute (z.B. `1000`) haben, sonst wird das Layout in den Page-Headern gesprengt. Die Skalierung wird dynamisch in `src/app/globals.css` über `.brand-logo` (`max-height: 2.5rem; width: min(10rem, 35vw); object-fit: contain`) geregelt. +- **Logo Skalierung:** Das Hauptlogo (`logo-black.png` / `logo-white.png`) darf im ``-Tag **keine** harten `width` und `height`-Attribute (z.B. `1000`) haben, sonst wird das Layout in den Page-Headern gesprengt. Die Skalierung wird in `src/app/globals.css` über `.brand-logo` geregelt (height-led: `height: 2.25rem; width: auto; max-width: min(12rem, 40vw)` plus `aspect-ratio` je Variante). +- **Header-Logo-Varianten (Stand 2026-11, v2.1):** Die Originale haben riesige transparente/weiße Ränder (`logo-black.png` ist 1000×1000 mit weißem 900×900-Block, Motiv nur ~776×417). Unter der alten `width`+`max-height`-Letterboxung schrumpfte das Motiv auf ~17px und war praktisch unsichtbar. Der Header (`BrandLogo`) nutzt deshalb **beschnittene Varianten** `public/brand/logo-black-header.png` (800×441, weißer Grund) und `logo-white-header.png` (194×104, transparent). Die Originale bleiben unverändert für Wasserzeichen (`thumbnail-handler.ts`), E-Mails und PDF. Nie die Originale für den Header verwenden, nie die Header-Varianten fürs Wasserzeichen (Skalierung dort = 50% Bildbreite). - **E-Mails & Dark Mode:** Die E-Mail-Templates befinden sich in `src/modules/email/service.ts` und `src/modules/mail/mailer.ts`. Beide unterstützen nativ Dark Mode via CSS (`@media (prefers-color-scheme: dark)`). Im Dark Mode wird `logo-black.png` durch `logo-white.png` ausgetauscht. Die Layouts sind responsiv (`max-width: 100%` für Bilder) aufgebaut, sodass sie auch auf mobilen Geräten gut lesbar bleiben. ## 5. Laufende Prozesse & Downloads - **Bulk Downloads:** Zip-Downloads (`archiver`) von mehreren Bildern nutzen Node.js Streams (`PassThrough`). Da Next.js die Response direkt an den Browser streamt, muss sichergestellt werden, dass der Stream nicht blockiert wird (`Readable.toWeb`). Siehe `src/app/api/lightbox/bulk-download/route.ts`. @@ -62,3 +63,20 @@ Redaktionen können Bilder durchsuchen, einen Leuchtkasten verwenden, Bilder her - **Diagnose-Kette, wenn Migrationen „nicht funktionieren":** (1) Server-Checkout prüfen: `git log --oneline -1` + `ls drizzle/`. (2) Image-Inhalt prüfen: `docker compose run --rm --no-deps migrate ls /app/drizzle` — weichen Checkout und Image ab, war der Build nicht/nicht für das Profil gelaufen (Falle oben). (3) DB-Wasserstand prüfen: `SELECT id, hash, created_at FROM drizzle.__drizzle_migrations ORDER BY id;` — der Drizzle-Migrator wendet nur Journal-Einträge mit `when` > max(`created_at`) an. PROD hatte 6 Zeilen / Wasserstand `1786379282947` (= alt-0005); die Baseline (`when=1786299825190`, bewusst alt-0000-Timestamp, siehe Abschnitt 7) liegt darunter und wird korrekt übersprungen — nur tatsächlich neue Migrationen (z. B. `0001_add_announcements`, `when=1789139950413`) laufen. Ein Exit 1 ohne sichtbare Fehlerzeile bedeutet fast immer: altes Image versucht alte Migrationen erneut → „already exists". - **Fehlerbild „Verbindung unterbrochen / Diese Seite konnte nicht geladen werden":** Das ist das eigene Error-Boundary (`src/app/error.tsx`) für Server-Fehler beim Rendern — die App läuft also, aber eine Seite wirft. Nach jedem Deploy zuerst `docker compose logs --tail 50 portal-app` lesen. Typischer Kandidat: neue App-Version fragt eine frische Migration-Tabelle ab, die (wegen der Build-Falle oben) noch nicht existiert → Migration nachholen genügt, App muss dafür nicht neu gestartet werden. - **Git-Remotes:** `origin` ist SSH (`git@gitlab.tonhaeuser.cloud:leon/…`) — der `git`-User ist der feste GitLab-SSH-Systembenutzer, **nicht** der Account-Name; Auth läuft über den SSH-Key des Kontos. `Permission denied (publickey)` = Key fehlt im GitLab-Konto (Preferences → SSH Keys), nicht falscher Username in der URL. Ersatz-Remote `origin-https` (HTTPS + Passwort/PAT) existiert für den Notfall; Push-Status prüfen mit `git status -sb` („ahead" = noch nicht gepusht — dann kam auf dem Server auch nichts an, und `git pull` meldet fälschlich „Already up to date"). + +## 9. Kalender, Selbstbedienung & Versionshinweise (Stand 2026-11, v2.1) +- **Versionierung ist Projektpflicht:** `CLAUDE.md` verlangt bei JEDER Änderung aktualisierte Versionshinweise für Admins und Redaktionen plus fortlaufende Nummer (Patch/Minor/Major je Umfang). Nummer wird dem Nutzer vorgeschlagen und von ihm approved. Pflege: `/admin/versionen` (Tabelle `release_notes`, unique je Version+Zielgruppe), Anzeige für Redaktionen: `/redaktion/neuigkeiten`. Migration `0002` seedet idempotent `2.0.0` (Basis) und `2.1.0`. +- **Kalender (`calendar_events`):** Admin legt Termine an (`/admin/kalender`, Titel + Datum + optional explizite Album-ID). Album-Verknüpfung passiert automatisch per **exaktem Namens-Match**: Album heißt `{Titel}` oder `{Titel} | {TT.MM.JJJJ}` (Datum des Termins) — siehe `matchEventAlbum` in `src/modules/calendar/event-albums.ts`. Albumnamen des Fotografen folgen genau diesem Schema. Private Alben matchen nie, solange der Admin ihren Namen nicht bewusst als Termin-Titel wählt (die Trust Boundary ist der admin-erstellte Termin). +- **Selbstbedienung (`album_grants.source`):** Redaktionen können das verknüpfte Album eines Termins unter `/redaktion/kalender` selbst freischalten (`selfGrantAlbum`, Rate-Limit `calendarSelfGrantPolicy`, Audit `album_self_granted`, `source: 'self_service'`). Grants ohne Kalender-Termin sind nicht self-servicebar. **Auto-Regeln stehen über dem Kalender:** `source: 'auto_rule'` und `admin`-Grants werden nie vom Kalender angetastet. Löscht der Admin einen Termin, entzieht `revokeSelfServiceGrantsForAlbum` NUR die `self_service`-Grants dieses Albums (Audit `album_revoked` mit `reason: calendar_event_deleted`). +- **RSVP (`event_responses`):** Je Termin und Redaktion genau eine Zeile (`attending`/`not_attending`, Upsert). Admin sieht Zusagen/Absagen als Chips je Termin. Audit `event_response_recorded` (actorType `editorial`). +- **Sichtbarkeitsfenster Redaktion:** Termine ab `heute - 30 Tage` (`CALENDAR_PAST_DAYS`), kommende aufsteigend, vergangene absteigend. Immich-Ausfall degradiert nur die Album-Verknüpfung (`immichUnavailable`), Termine/RSVP funktionieren weiter. +- **Sortierung Fotos:** `sortierung=neueste|aelteste` (Default neueste) in Album-Suche UND Cross-Alben-Suche; `sortPhotos` in `src/modules/albums/filter.ts` sortiert das gesamte geholte Set VOR dem Paginieren (auch über gemergte Per-Album-Seiten). Pagination-Links (`pageHref`, `globalPageHref`) führen den Parameter mit, ebenso Format/Jahr. +- **Bildbeschreibung:** Immich liefert sie in `exifInfo.description` (`withExif: true` war schon aktiv). Schema/Typ erweitert, Anzeige in der Lightbox (`PhotoLightbox` in `photo-gallery.tsx`, Klasse `.lightbox-description`, scrollbar bei >24vh). Nur React-Text, kein HTML. + +## 10. Dateiname-Suche, Collab, Rechnungsversand & Statistiken (Stand 2026-11, v2.2) +- **Dateiname-Suche (2.1.1):** Immich verknüpft Metadaten-Filter mit UND. Deshalb sucht `searchAlbumMerged` (`src/modules/albums/catalog.ts`) bei Query je Album zweimal (description ODER originalFileName) und merged dedupliziert. Merkzettel-Deep-Links (`?suche={dateiname}`) funktionieren damit. Gleiche Grant-Prüfung wie bisher. +- **Collab (2.2.0):** `editorial_accounts.collab_enabled` (Admin-Toggle unter `/admin/redaktionen/[id]`, Audit `editorial_collab_updated`). Nur freigeschaltete Redaktionen sehen die Checkbox „Collab-Nutzung (kostenfrei)" im UsageDialog und im Merkzettel-Bulk-Download. `usages.collab` + `priceCents = 0`; Collab zählt NICHT gegen das Flatrate-Limit (`eq(usages.collab, false)` im Limit-Count). Fehler `COLLAB_NOT_ENABLED` → 403. Admin kann offene/wiedereröffnete Nutzungen unter Abrechnungen nachträglich markieren/entmarken (`POST /api/usages/[usageId]/collab`, Preis 0 ↔ currentPriceCents, Audit `usage_collab_updated`). Nutzungsnachweis-PDF zeigt `(Collab)` hinter dem Zweck, `billing_report_items.collab` als Snapshot. +- **Fingerprint-Kompatibilität (WICHTIG):** `requestFingerprint` für `new_usage` DARF nicht um neue Felder (z. B. collab) erweitert werden — die historischen Migrationen 0001/0002 rekonstruieren Legacy-Fingerprints aus der alten Payload-Form. Tests in `tests/db/accounting-migration.test.ts` prüfen das. +- **Rechnungsversand (2.2.0):** Finalisieren verschickt KEINE E-Mail mehr (Nutzungsnachweis dient der Prüfung; Korrekturen via Collab-Toggle oder Storno + Neu-Finalisierung). Admin lädt die Rechnungs-PDF unter Abrechnungen hoch (`POST /api/billing-reports/[reportId]/invoice`, multipart, %PDF-Magic, max 20 MB, Rate-Limit `invoiceUploadPolicy`). Der Upload speichert (`invoice_pdf`, `invoice_pdf_sha256`, …) und sendet automatisch GEBÜNDELT Rechnung + Nutzungsnachweis (`emailService.sendInvoiceBundle`, Vorlage `invoice-message.ts`). Status `invoice_email_status` (not_sent/sent/failed) + `invoice_email_sent_at`/`invoice_email_error`; „Erneut senden" via `POST …/invoice/resend`, Download via `GET …/invoice`. Audit: `invoice_uploaded`, `invoice_email_sent`, `invoice_email_failed`. +- **Activity-Tracking (2.2.0):** `activity_events` (album_view/search/lightbox_view) nur für Browsing; Downloads bleiben in `download_events`. Server-Hooks in den Albumseiten, Lightbox-Beacon `POST /api/activity` (nur lightbox_view). `recordActivity` ist fire-and-forget: validiert, rate-limited (`activityPolicy` 240/60s), schluckt alle Fehler. Statistikseite `/admin/statistiken` (`src/modules/stats/queries.ts`, Zeitraum 7/30/90 Tage via `zeitraum`): KPI-Karten mit Trend-Pills (Vorperiode), Recharts Area/Bar (lazy, ssr:false, Theme-Farben), Top-Redaktionen/Alben, offene Umsätze, letzte Aktivitäten. SakaniUI-Elemente: Pill-Segmented-Control, Uppercase-Muted-Labels, Tabular-Nums, Hover-Shadow. +- **Lokale Verifikation (tmp/, gitignored):** Dev-Server `NEXT_DISABLE_TURBOPACK=1 next dev` (Port 3000), Mock-Immich :2283 (inkl. `/original`), Mock-SMTP :587 (`tmp/mock-smtp.mjs`, loggt nach `tmp/mock-smtp.log`), DB-Container `portal-clickthrough-db` :5433. BetterAuth-Sign-In-Limit 5/15min liegt IM SPEICHER des Dev-Servers — vor jedem Click-Through-Lauf Dev-Server neu starten; die Spec cached Session-Cookies nach dem ersten Login (`loginCached`). `tmp/dev-seed.ts` ist idempotent: User per E-Mail auflösen (signUp mit existierender E-Mail liefert Phantom-User ohne Persistenz!), 2FA-Setup überspringen wenn verified, Rechnungsadresse anlegen. Click-Through: `node_modules/.bin/playwright test --config tmp/playwright.config.ts` (7 Tests, Reset via beforeAll, FK-Reihenfolge beachten: items → download_events → usages → billing_reports). diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..0705601 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,71 @@ +# CLAUDE.md — Projektregeln für das Immich-Redaktions-Portal + +Technisches Wissen (Immich-API-Eigenheiten, Migrationen, Deployment, Auth-Härtung) +steht in `AI_MEMORY.md`. Diese Datei hier regelt den Arbeitsablauf. + +## Versionierung & Versionshinweise (PFLICHT bei jeder Änderung) + +Bei jedem neuen Feature, jeder Änderung und jedem Fix im Portal: + +1. **Versionshinweise aktualisieren** — für Admins UND Redaktionen (Zielgruppen + `admin`, `editorial`, `both`). Pflege im Portal unter `/admin/versionen` + (Tabelle `release_notes`), für Deployments zusätzlich als Seed in der + jeweiligen Drizzle-Migration (`ON CONFLICT DO NOTHING`). +2. **Versionsnummer fortführen** — nie neu starten, nie überspringen. + Größenordnung nach Umfang der Änderung: + - kleiner Fix / Politur: Patch, z. B. `2.1.1` + - neues Feature / spürbare Erweiterung: Minor, z. B. `2.2` + - großer Umbau / breaking: Major, z. B. `3.0` +3. **Nummer vorschlagen und absegnen lassen** — vor der Umsetzung eine konkrete + Nummer vorschlagen; der Nutzer approved sie oder nennt eine eigene. Ohne + Antwort keine eigenmächtige Major-/Minor-Sprünge. +4. Hinweis-Texte kurz und konkret auf Deutsch, aus Nutzersicht formuliert + (was ist neu, wo findet man es). Keine Marketing-Floskeln. + +Aktueller Stand: siehe neueste Einträge in `release_notes` (Basis `2.0.0`, +Kalender/Selbstbedienung/Sortierung/Beschreibung: `2.1.0`, +Dateiname-Suche: `2.1.1`, Statistik/Collab/Rechnungsversand: `2.2.0`). + +## Sicherheit (bei jeder Änderung mitprüfen) + +- Album-Zugriff läuft ausschließlich über `album_grants` (Service + `albumGrantService`). Neue Zugriffswege nur mit Audit-Event und + Admin-Entzugsmöglichkeit; Selbstbedienung nur über Kalender-Events + (`source: 'self_service'`), Auto-Regeln stehen über dem Kalender. +- Niemals `asset.albums` für Berechtigungen vertrauen (siehe AI_MEMORY §2). +- Nutzertexte (Immich-Beschreibungen, Albumnamen, Hinweise) immer als + React-Text rendern, nie als HTML (`dangerouslySetInnerHTML` ist tabu). +- Neue mutierende Endpoints/Actions: Session-Guard (`requireAdmin` / + `requireActiveEditorial`) und bei Missbrauchspotenzial Rate-Limit + (`src/modules/security/rate-limit.ts`). +- Lösch-Actions mit Folgewirkung (z. B. Kalender-Event löschen entzieht + Selbstzugriffe) im UI bestätigen lassen. + +## UI & Design + +- Vor UI-Arbeit `~/.claude/DESIGN.md` lesen; Projekt-Tokens stehen in + `src/app/globals.css` (Projekt-Werte haben Vorrang). +- Stil an bestehende Flächen anlehnen: Admin nutzt Tailwind-Karten + (`bg-card rounded-xl border-border`), Redaktions-Browsing die + `.editorial-*`/`.album-search-*`-Klassen. Beide Themes (hell/dunkel) prüfen. +- Header-Logo nutzt die beschnittenen Varianten `logo-*-header.png` + (Originale bleiben für Wasserzeichen/E-Mail/PDF unverändert). + +## Tests & Verifikation + +- `pnpm typecheck`, `pnpm lint`, `pnpm test` (Vitest) vor Abschluss. +- `tests/db/*` brauchen Docker (Testcontainers); ohne Docker laufen nur die + Unit-Tests — das im Abschlussbericht offen benennen. +- Migrationen: `drizzle-kit generate`, nie manuellSnapshots editieren; + Seed-Daten idempotent anhängen. Deploy-Reihenfolge siehe AI_MEMORY §8 + (`docker compose --profile ops build`!). + + + +# This is NOT the Next.js you know + +This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices. + +This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean. + + diff --git a/drizzle/0002_release_notes_calendar.sql b/drizzle/0002_release_notes_calendar.sql new file mode 100644 index 0000000..5ac2c48 --- /dev/null +++ b/drizzle/0002_release_notes_calendar.sql @@ -0,0 +1,45 @@ +CREATE TABLE "calendar_events" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "title" text NOT NULL, + "event_date" date NOT NULL, + "immich_album_id" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "created_by_user_id" uuid +); +--> statement-breakpoint +CREATE TABLE "event_responses" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "event_id" uuid NOT NULL, + "editorial_account_id" uuid NOT NULL, + "status" text NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "event_responses_status_check" CHECK ("event_responses"."status" in ('attending', 'not_attending')) +); +--> statement-breakpoint +CREATE TABLE "release_notes" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "version" text NOT NULL, + "audience" text DEFAULT 'both' NOT NULL, + "body" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "created_by_user_id" uuid, + CONSTRAINT "release_notes_audience_check" CHECK ("release_notes"."audience" in ('admin', 'editorial', 'both')), + CONSTRAINT "release_notes_version_check" CHECK ("release_notes"."version" ~ '^[0-9]+\.[0-9]+(\.[0-9]+)?$') +); +--> statement-breakpoint +ALTER TABLE "album_grants" ADD COLUMN "source" text DEFAULT 'admin' NOT NULL;--> statement-breakpoint +ALTER TABLE "calendar_events" ADD CONSTRAINT "calendar_events_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "event_responses" ADD CONSTRAINT "event_responses_event_id_calendar_events_id_fk" FOREIGN KEY ("event_id") REFERENCES "public"."calendar_events"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "event_responses" ADD CONSTRAINT "event_responses_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "release_notes" ADD CONSTRAINT "release_notes_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "event_responses_event_editorial_unique" ON "event_responses" USING btree ("event_id","editorial_account_id");--> statement-breakpoint +CREATE UNIQUE INDEX "release_notes_version_audience_unique" ON "release_notes" USING btree ("version","audience");--> statement-breakpoint +ALTER TABLE "album_grants" ADD CONSTRAINT "album_grants_source_check" CHECK ("album_grants"."source" in ('admin', 'auto_rule', 'self_service'));--> statement-breakpoint +-- Seed the version notes: 2.0.0 documents the existing portal as the baseline, +-- 2.1.0 documents this release. Idempotent so re-runs never duplicate rows. +INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id") +VALUES + ('2.0.0', 'both', 'Basisversion des Redaktionsportals: Albumfreigaben mit automatischen Regeln, Suche über alle Alben, Merkzettel, Wasserzeichen-Vorschauen, lizenzierte Downloads mit automatischer Abrechnung, Hinweise des Fotografen und Zwei-Faktor-Schutz für Admins.', NULL), + ('2.1.0', 'editorial', 'Neu in 2.1: Fotos lassen sich in der Album-Suche und in der Suche über alle Alben nach ältesten und neuesten sortieren. Die Bildbeschreibung wird jetzt in der Großansicht angezeigt. Der neue Kalender zeigt kommende Termine, Sie können je Termin zurückmelden, ob Sie da sind. Event-Alben aus dem Kalender können Sie selbst freischalten und sofort öffnen. Das Logo im Kopfbereich ist wieder sichtbar.', NULL), + ('2.1.0', 'admin', 'Neu in 2.1: Kalender unter /admin/kalender (Termine anlegen, Alben verknüpfen, Zusagen der Redaktionen einsehen). Redaktionen schalten Kalender-Alben selbst frei, jeder Selbstzugriff wird im Audit protokolliert und lässt sich unter Alben entziehen. Versionshinweise werden unter /admin/versionen gepflegt. Sortierung und Bildbeschreibung in der Redaktionssuche, Logo im Kopfbereich korrigiert.', NULL) +ON CONFLICT ("version", "audience") DO NOTHING; \ No newline at end of file diff --git a/drizzle/0003_collab_invoice_activity.sql b/drizzle/0003_collab_invoice_activity.sql new file mode 100644 index 0000000..ef272cf --- /dev/null +++ b/drizzle/0003_collab_invoice_activity.sql @@ -0,0 +1,35 @@ +CREATE TABLE "activity_events" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "editorial_account_id" uuid NOT NULL, + "event_type" text NOT NULL, + "immich_album_id" text, + "immich_asset_id" text, + "query" text, + "occurred_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "activity_events_event_type_check" CHECK ("activity_events"."event_type" in ('album_view', 'search', 'lightbox_view')) +); +--> statement-breakpoint +ALTER TABLE "billing_report_items" ADD COLUMN "collab" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "billing_reports" ADD COLUMN "invoice_pdf" "bytea";--> statement-breakpoint +ALTER TABLE "billing_reports" ADD COLUMN "invoice_pdf_sha256" varchar(64);--> statement-breakpoint +ALTER TABLE "billing_reports" ADD COLUMN "invoice_pdf_filename" text;--> statement-breakpoint +ALTER TABLE "billing_reports" ADD COLUMN "invoice_uploaded_at" timestamp with time zone;--> statement-breakpoint +ALTER TABLE "billing_reports" ADD COLUMN "invoice_email_status" text DEFAULT 'not_sent' NOT NULL;--> statement-breakpoint +ALTER TABLE "billing_reports" ADD COLUMN "invoice_email_sent_at" timestamp with time zone;--> statement-breakpoint +ALTER TABLE "billing_reports" ADD COLUMN "invoice_email_error" text;--> statement-breakpoint +ALTER TABLE "editorial_accounts" ADD COLUMN "collab_enabled" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "usages" ADD COLUMN "collab" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "activity_events" ADD CONSTRAINT "activity_events_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "activity_events_occurred_at_idx" ON "activity_events" USING btree ("occurred_at" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "activity_events_editorial_occurred_idx" ON "activity_events" USING btree ("editorial_account_id","occurred_at" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "activity_events_type_occurred_idx" ON "activity_events" USING btree ("event_type","occurred_at" DESC NULLS LAST);--> statement-breakpoint +ALTER TABLE "billing_reports" ADD CONSTRAINT "billing_reports_invoice_pdf_sha256_hex_check" CHECK ("billing_reports"."invoice_pdf_sha256" IS NULL OR "billing_reports"."invoice_pdf_sha256" ~ '^[0-9a-f]{64}$');--> statement-breakpoint +ALTER TABLE "billing_reports" ADD CONSTRAINT "billing_reports_invoice_email_status_check" CHECK ("billing_reports"."invoice_email_status" in ('not_sent', 'sent', 'failed')); +-- Seed the version notes for this release chain. Idempotent so re-runs never +-- duplicate rows (unique on version + audience). +INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id") +VALUES + ('2.1.1', 'editorial', 'Die Suche in Alben und über alle Alben findet jetzt auch Dateinamen. Links vom Merkzettel führen damit direkt zum richtigen Bild.', NULL), + ('2.2.0', 'admin', 'Neu in 2.2: Statistik-Seite unter /admin/statistiken mit Downloads, Datenmenge, Aufrufen, Suchen, Umsatz und Collab-Nutzungen. Collab-Nutzung je Redaktion unter Redaktionen freischalten; Collab-Positionen erscheinen mit 0,00 € in der Abrechnung und lassen sich dort vor dem Versand korrigieren. Rechnungen: PDF je Abrechnung unter Abrechnungen hochladen, danach geht die Rechnung gebündelt mit dem Nutzungsnachweis automatisch per E-Mail an die Redaktion. Der Nutzungsnachweis wird beim Finalisieren nicht mehr automatisch verschickt.', NULL), + ('2.2.0', 'editorial', 'Neu in 2.2: Wenn Ihre Redaktion für Collab freigeschaltet ist, können Sie beim Download die Option Collab (kostenfrei) wählen, auch für mehrere Bilder vom Merkzettel. Rechnung und Nutzungsnachweis kommen gebündelt per E-Mail, sobald die Rechnung vorliegt.', NULL) +ON CONFLICT ("version", "audience") DO NOTHING; \ No newline at end of file diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json new file mode 100644 index 0000000..805ec5a --- /dev/null +++ b/drizzle/meta/0002_snapshot.json @@ -0,0 +1,2285 @@ +{ + "id": "f708aa98-0633-4a85-9d4b-879142f89a62", + "prevId": "b98d41ae-a5a1-4e1c-bb31-99cc096528a0", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.album_grants": { + "name": "album_grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "granted_by_user_id": { + "name": "granted_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'admin'" + } + }, + "indexes": { + "album_grants_editorial_account_id_idx": { + "name": "album_grants_editorial_account_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_immich_album_id_idx": { + "name": "album_grants_immich_album_id_idx", + "columns": [ + { + "expression": "immich_album_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_editorial_active_album_unique": { + "name": "album_grants_editorial_active_album_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"immich_album_id\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"album_grants\".\"revoked_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "album_grants_editorial_account_id_editorial_accounts_id_fk": { + "name": "album_grants_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "album_grants", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "album_grants_granted_by_user_id_user_id_fk": { + "name": "album_grants_granted_by_user_id_user_id_fk", + "tableFrom": "album_grants", + "tableTo": "user", + "columnsFrom": [ + "granted_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "album_grants_immich_album_id_uuid_check": { + "name": "album_grants_immich_album_id_uuid_check", + "value": "\"album_grants\".\"immich_album_id\" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + }, + "album_grants_source_check": { + "name": "album_grants_source_check", + "value": "\"album_grants\".\"source\" in ('admin', 'auto_rule', 'self_service')" + } + }, + "isRLSEnabled": false + }, + "public.announcements": { + "name": "announcements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "announcements_created_by_user_id_user_id_fk": { + "name": "announcements_created_by_user_id_user_id_fk", + "tableFrom": "announcements", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_events": { + "name": "audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "previous_values": { + "name": "previous_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_values": { + "name": "new_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "audit_events_actor_user_id_user_id_fk": { + "name": "audit_events_actor_user_id_user_id_fk", + "tableFrom": "audit_events", + "tableTo": "user", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.two_factor": { + "name": "two_factor", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "backup_codes": { + "name": "backup_codes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "failed_verification_count": { + "name": "failed_verification_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "two_factor_user_id_user_id_fk": { + "name": "two_factor_user_id_user_id_fk", + "tableFrom": "two_factor", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "two_factor_user_id_unique": { + "name": "two_factor_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "portal_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'EDITORIAL'" + }, + "two_factor_enabled": { + "name": "two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.album_auto_rules": { + "name": "album_auto_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "album_auto_rules_editorial_account_id_keyword_idx": { + "name": "album_auto_rules_editorial_account_id_keyword_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"keyword\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "album_auto_rules_editorial_account_id_editorial_accounts_id_fk": { + "name": "album_auto_rules_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "album_auto_rules", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "album_auto_rules_created_by_user_id_user_id_fk": { + "name": "album_auto_rules_created_by_user_id_user_id_fk", + "tableFrom": "album_auto_rules", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_report_items": { + "name": "billing_report_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id_snapshot": { + "name": "immich_asset_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose_snapshot": { + "name": "purpose_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference_snapshot": { + "name": "internal_reference_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "billing_report_items_report_usage_unique": { + "name": "billing_report_items_report_usage_unique", + "columns": [ + { + "expression": "billing_report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "usage_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_report_items_billing_report_id_billing_reports_id_fk": { + "name": "billing_report_items_billing_report_id_billing_reports_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_report_items_usage_id_usages_id_fk": { + "name": "billing_report_items_usage_id_usages_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_reports": { + "name": "billing_reports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "report_number": { + "name": "report_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "period_starts_at": { + "name": "period_starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "period_ends_at": { + "name": "period_ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "billing_address_snapshot": { + "name": "billing_address_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "net_total_cents": { + "name": "net_total_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "flatrate_cents_snapshot": { + "name": "flatrate_cents_snapshot", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "report_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "pdf": { + "name": "pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "pdf_sha256": { + "name": "pdf_sha256", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finalized_at": { + "name": "finalized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_by_user_id": { + "name": "cancelled_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "billing_reports_report_number_unique": { + "name": "billing_reports_report_number_unique", + "columns": [ + { + "expression": "report_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "billing_reports_invoice_number_unique": { + "name": "billing_reports_invoice_number_unique", + "columns": [ + { + "expression": "invoice_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_reports_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_reports_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_reports", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_created_by_user_id_user_id_fk": { + "name": "billing_reports_created_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_cancelled_by_user_id_user_id_fk": { + "name": "billing_reports_cancelled_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "cancelled_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "billing_reports_pdf_sha256_hex_check": { + "name": "billing_reports_pdf_sha256_hex_check", + "value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'" + }, + "billing_reports_final_pdf_check": { + "name": "billing_reports_final_pdf_check", + "value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.calendar_events": { + "name": "calendar_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "calendar_events_created_by_user_id_user_id_fk": { + "name": "calendar_events_created_by_user_id_user_id_fk", + "tableFrom": "calendar_events", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.event_responses": { + "name": "event_responses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "event_responses_event_editorial_unique": { + "name": "event_responses_event_editorial_unique", + "columns": [ + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "event_responses_event_id_calendar_events_id_fk": { + "name": "event_responses_event_id_calendar_events_id_fk", + "tableFrom": "event_responses", + "tableTo": "calendar_events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "event_responses_editorial_account_id_editorial_accounts_id_fk": { + "name": "event_responses_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "event_responses", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "event_responses_status_check": { + "name": "event_responses_status_check", + "value": "\"event_responses\".\"status\" in ('attending', 'not_attending')" + } + }, + "isRLSEnabled": false + }, + "public.billing_address_versions": { + "name": "billing_address_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_1": { + "name": "address_line_1", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_2": { + "name": "address_line_2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "superseded_by_id": { + "name": "superseded_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "billing_address_versions_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_address_versions_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_superseded_by_id_billing_address_versions_id_fk": { + "name": "billing_address_versions_superseded_by_id_billing_address_versions_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "superseded_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_created_by_user_id_user_id_fk": { + "name": "billing_address_versions_created_by_user_id_user_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.editorial_accounts": { + "name": "editorial_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "login_email": { + "name": "login_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "account_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending_email'" + }, + "current_price_cents": { + "name": "current_price_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "flatrate_active": { + "name": "flatrate_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "flatrate_price_cents": { + "name": "flatrate_price_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "flatrate_asset_limit": { + "name": "flatrate_asset_limit", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "approval_notice_status": { + "name": "approval_notice_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_requested'" + }, + "current_billing_address_version_id": { + "name": "current_billing_address_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_version": { + "name": "accepted_terms_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_at": { + "name": "accepted_terms_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "privacy_acknowledged_at": { + "name": "privacy_acknowledged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_by_user_id": { + "name": "archived_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "editorial_accounts_user_id_user_id_fk": { + "name": "editorial_accounts_user_id_user_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk": { + "name": "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "current_billing_address_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "editorial_accounts_archived_by_user_id_user_id_fk": { + "name": "editorial_accounts_archived_by_user_id_user_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "user", + "columnsFrom": [ + "archived_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "editorial_accounts_user_id_unique": { + "name": "editorial_accounts_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + }, + "editorial_accounts_login_email_unique": { + "name": "editorial_accounts_login_email_unique", + "nullsNotDistinct": false, + "columns": [ + "login_email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lightbox_items": { + "name": "lightbox_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "lightbox_items_editorial_asset_idx": { + "name": "lightbox_items_editorial_asset_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "asset_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "lightbox_items_editorial_account_id_editorial_accounts_id_fk": { + "name": "lightbox_items_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "lightbox_items", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limits": { + "name": "rate_limits", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "window_boundary": { + "name": "window_boundary", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "rate_limits_key_window_boundary_pk": { + "name": "rate_limits_key_window_boundary_pk", + "columns": [ + "key", + "window_boundary" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.release_notes": { + "name": "release_notes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'both'" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "release_notes_version_audience_unique": { + "name": "release_notes_version_audience_unique", + "columns": [ + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "audience", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "release_notes_created_by_user_id_user_id_fk": { + "name": "release_notes_created_by_user_id_user_id_fk", + "tableFrom": "release_notes", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "release_notes_audience_check": { + "name": "release_notes_audience_check", + "value": "\"release_notes\".\"audience\" in ('admin', 'editorial', 'both')" + }, + "release_notes_version_check": { + "name": "release_notes_version_check", + "value": "\"release_notes\".\"version\" ~ '^[0-9]+\\.[0-9]+(\\.[0-9]+)?$'" + } + }, + "isRLSEnabled": false + }, + "public.download_events": { + "name": "download_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authorized_at": { + "name": "authorized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "download_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'authorized'" + }, + "transferred_bytes": { + "name": "transferred_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "repeat_download_note": { + "name": "repeat_download_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent_kind": { + "name": "intent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'new_usage'" + }, + "request_fingerprint": { + "name": "request_fingerprint", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "legacy_intent": { + "name": "legacy_intent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "download_events_editorial_authorized_id_idx": { + "name": "download_events_editorial_authorized_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "authorized_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "download_events_editorial_idempotency_key_unique": { + "name": "download_events_editorial_idempotency_key_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "download_events_editorial_account_id_editorial_accounts_id_fk": { + "name": "download_events_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "download_events", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "download_events_usage_id_usages_id_fk": { + "name": "download_events_usage_id_usages_id_fk", + "tableFrom": "download_events", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "download_events_intent_kind_check": { + "name": "download_events_intent_kind_check", + "value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download', 'legacy')" + }, + "download_events_request_fingerprint_hex_check": { + "name": "download_events_request_fingerprint_hex_check", + "value": "\"download_events\".\"request_fingerprint\" ~ '^[0-9a-f]{64}$'" + }, + "download_events_canonical_idempotency_key_check": { + "name": "download_events_canonical_idempotency_key_check", + "value": "\"download_events\".\"legacy_intent\" OR \"download_events\".\"idempotency_key\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + }, + "download_events_canonical_immich_asset_id_check": { + "name": "download_events_canonical_immich_asset_id_check", + "value": "\"download_events\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + } + }, + "isRLSEnabled": false + }, + "public.usages": { + "name": "usages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "immich_album_id_snapshot": { + "name": "immich_album_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference": { + "name": "internal_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "billing_status": { + "name": "billing_status", + "type": "usage_billing_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "usages_editorial_created_id_idx": { + "name": "usages_editorial_created_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usages_created_at_idx": { + "name": "usages_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "usages_editorial_account_id_editorial_accounts_id_fk": { + "name": "usages_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "usages", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "usages_billing_report_id_billing_reports_id_fk": { + "name": "usages_billing_report_id_billing_reports_id_fk", + "tableFrom": "usages", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "usages_canonical_immich_asset_id_check": { + "name": "usages_canonical_immich_asset_id_check", + "value": "\"usages\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + }, + "usages_canonical_immich_album_id_check": { + "name": "usages_canonical_immich_album_id_check", + "value": "\"usages\".\"immich_album_id_snapshot\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + } + }, + "isRLSEnabled": false + } + }, + "enums": { + "public.portal_role": { + "name": "portal_role", + "schema": "public", + "values": [ + "ADMIN", + "EDITORIAL" + ] + }, + "public.report_status": { + "name": "report_status", + "schema": "public", + "values": [ + "draft", + "final", + "cancelled" + ] + }, + "public.account_status": { + "name": "account_status", + "schema": "public", + "values": [ + "pending_email", + "pending_approval", + "active", + "suspended", + "rejected" + ] + }, + "public.download_status": { + "name": "download_status", + "schema": "public", + "values": [ + "authorized", + "streaming", + "completed", + "failed_before_delivery", + "interrupted" + ] + }, + "public.usage_billing_status": { + "name": "usage_billing_status", + "schema": "public", + "values": [ + "open", + "billed", + "reopened", + "voided" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/0003_snapshot.json b/drizzle/meta/0003_snapshot.json new file mode 100644 index 0000000..371f1ca --- /dev/null +++ b/drizzle/meta/0003_snapshot.json @@ -0,0 +1,2491 @@ +{ + "id": "2da521e8-f513-403e-84a8-db5502923df2", + "prevId": "f708aa98-0633-4a85-9d4b-879142f89a62", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity_events": { + "name": "activity_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "query": { + "name": "query", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "activity_events_occurred_at_idx": { + "name": "activity_events_occurred_at_idx", + "columns": [ + { + "expression": "occurred_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_events_editorial_occurred_idx": { + "name": "activity_events_editorial_occurred_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurred_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "activity_events_type_occurred_idx": { + "name": "activity_events_type_occurred_idx", + "columns": [ + { + "expression": "event_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurred_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_events_editorial_account_id_editorial_accounts_id_fk": { + "name": "activity_events_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "activity_events", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "activity_events_event_type_check": { + "name": "activity_events_event_type_check", + "value": "\"activity_events\".\"event_type\" in ('album_view', 'search', 'lightbox_view')" + } + }, + "isRLSEnabled": false + }, + "public.album_grants": { + "name": "album_grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "granted_by_user_id": { + "name": "granted_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'admin'" + } + }, + "indexes": { + "album_grants_editorial_account_id_idx": { + "name": "album_grants_editorial_account_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_immich_album_id_idx": { + "name": "album_grants_immich_album_id_idx", + "columns": [ + { + "expression": "immich_album_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_editorial_active_album_unique": { + "name": "album_grants_editorial_active_album_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"immich_album_id\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"album_grants\".\"revoked_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "album_grants_editorial_account_id_editorial_accounts_id_fk": { + "name": "album_grants_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "album_grants", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "album_grants_granted_by_user_id_user_id_fk": { + "name": "album_grants_granted_by_user_id_user_id_fk", + "tableFrom": "album_grants", + "tableTo": "user", + "columnsFrom": [ + "granted_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "album_grants_immich_album_id_uuid_check": { + "name": "album_grants_immich_album_id_uuid_check", + "value": "\"album_grants\".\"immich_album_id\" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + }, + "album_grants_source_check": { + "name": "album_grants_source_check", + "value": "\"album_grants\".\"source\" in ('admin', 'auto_rule', 'self_service')" + } + }, + "isRLSEnabled": false + }, + "public.announcements": { + "name": "announcements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "announcements_created_by_user_id_user_id_fk": { + "name": "announcements_created_by_user_id_user_id_fk", + "tableFrom": "announcements", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_events": { + "name": "audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "previous_values": { + "name": "previous_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_values": { + "name": "new_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "audit_events_actor_user_id_user_id_fk": { + "name": "audit_events_actor_user_id_user_id_fk", + "tableFrom": "audit_events", + "tableTo": "user", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.two_factor": { + "name": "two_factor", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "backup_codes": { + "name": "backup_codes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "failed_verification_count": { + "name": "failed_verification_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "two_factor_user_id_user_id_fk": { + "name": "two_factor_user_id_user_id_fk", + "tableFrom": "two_factor", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "two_factor_user_id_unique": { + "name": "two_factor_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "portal_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'EDITORIAL'" + }, + "two_factor_enabled": { + "name": "two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.album_auto_rules": { + "name": "album_auto_rules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "album_auto_rules_editorial_account_id_keyword_idx": { + "name": "album_auto_rules_editorial_account_id_keyword_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"keyword\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "album_auto_rules_editorial_account_id_editorial_accounts_id_fk": { + "name": "album_auto_rules_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "album_auto_rules", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "album_auto_rules_created_by_user_id_user_id_fk": { + "name": "album_auto_rules_created_by_user_id_user_id_fk", + "tableFrom": "album_auto_rules", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_report_items": { + "name": "billing_report_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id_snapshot": { + "name": "immich_asset_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose_snapshot": { + "name": "purpose_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference_snapshot": { + "name": "internal_reference_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "collab": { + "name": "collab", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "billing_report_items_report_usage_unique": { + "name": "billing_report_items_report_usage_unique", + "columns": [ + { + "expression": "billing_report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "usage_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_report_items_billing_report_id_billing_reports_id_fk": { + "name": "billing_report_items_billing_report_id_billing_reports_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_report_items_usage_id_usages_id_fk": { + "name": "billing_report_items_usage_id_usages_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_reports": { + "name": "billing_reports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "report_number": { + "name": "report_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "period_starts_at": { + "name": "period_starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "period_ends_at": { + "name": "period_ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "billing_address_snapshot": { + "name": "billing_address_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "net_total_cents": { + "name": "net_total_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "flatrate_cents_snapshot": { + "name": "flatrate_cents_snapshot", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "report_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "pdf": { + "name": "pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "pdf_sha256": { + "name": "pdf_sha256", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "invoice_pdf": { + "name": "invoice_pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "invoice_pdf_sha256": { + "name": "invoice_pdf_sha256", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "invoice_pdf_filename": { + "name": "invoice_pdf_filename", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invoice_uploaded_at": { + "name": "invoice_uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "invoice_email_status": { + "name": "invoice_email_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_sent'" + }, + "invoice_email_sent_at": { + "name": "invoice_email_sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "invoice_email_error": { + "name": "invoice_email_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finalized_at": { + "name": "finalized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_by_user_id": { + "name": "cancelled_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "billing_reports_report_number_unique": { + "name": "billing_reports_report_number_unique", + "columns": [ + { + "expression": "report_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "billing_reports_invoice_number_unique": { + "name": "billing_reports_invoice_number_unique", + "columns": [ + { + "expression": "invoice_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_reports_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_reports_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_reports", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_created_by_user_id_user_id_fk": { + "name": "billing_reports_created_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_cancelled_by_user_id_user_id_fk": { + "name": "billing_reports_cancelled_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "cancelled_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "billing_reports_pdf_sha256_hex_check": { + "name": "billing_reports_pdf_sha256_hex_check", + "value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'" + }, + "billing_reports_invoice_pdf_sha256_hex_check": { + "name": "billing_reports_invoice_pdf_sha256_hex_check", + "value": "\"billing_reports\".\"invoice_pdf_sha256\" IS NULL OR \"billing_reports\".\"invoice_pdf_sha256\" ~ '^[0-9a-f]{64}$'" + }, + "billing_reports_invoice_email_status_check": { + "name": "billing_reports_invoice_email_status_check", + "value": "\"billing_reports\".\"invoice_email_status\" in ('not_sent', 'sent', 'failed')" + }, + "billing_reports_final_pdf_check": { + "name": "billing_reports_final_pdf_check", + "value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.calendar_events": { + "name": "calendar_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_date": { + "name": "event_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "calendar_events_created_by_user_id_user_id_fk": { + "name": "calendar_events_created_by_user_id_user_id_fk", + "tableFrom": "calendar_events", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.event_responses": { + "name": "event_responses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "event_responses_event_editorial_unique": { + "name": "event_responses_event_editorial_unique", + "columns": [ + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "event_responses_event_id_calendar_events_id_fk": { + "name": "event_responses_event_id_calendar_events_id_fk", + "tableFrom": "event_responses", + "tableTo": "calendar_events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "event_responses_editorial_account_id_editorial_accounts_id_fk": { + "name": "event_responses_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "event_responses", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "event_responses_status_check": { + "name": "event_responses_status_check", + "value": "\"event_responses\".\"status\" in ('attending', 'not_attending')" + } + }, + "isRLSEnabled": false + }, + "public.billing_address_versions": { + "name": "billing_address_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_1": { + "name": "address_line_1", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_2": { + "name": "address_line_2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "superseded_by_id": { + "name": "superseded_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "billing_address_versions_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_address_versions_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_superseded_by_id_billing_address_versions_id_fk": { + "name": "billing_address_versions_superseded_by_id_billing_address_versions_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "superseded_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_created_by_user_id_user_id_fk": { + "name": "billing_address_versions_created_by_user_id_user_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.editorial_accounts": { + "name": "editorial_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "login_email": { + "name": "login_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "account_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending_email'" + }, + "current_price_cents": { + "name": "current_price_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "flatrate_active": { + "name": "flatrate_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "flatrate_price_cents": { + "name": "flatrate_price_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "flatrate_asset_limit": { + "name": "flatrate_asset_limit", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "collab_enabled": { + "name": "collab_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "approval_notice_status": { + "name": "approval_notice_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_requested'" + }, + "current_billing_address_version_id": { + "name": "current_billing_address_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_version": { + "name": "accepted_terms_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_at": { + "name": "accepted_terms_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "privacy_acknowledged_at": { + "name": "privacy_acknowledged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_by_user_id": { + "name": "archived_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "editorial_accounts_user_id_user_id_fk": { + "name": "editorial_accounts_user_id_user_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk": { + "name": "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "current_billing_address_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "editorial_accounts_archived_by_user_id_user_id_fk": { + "name": "editorial_accounts_archived_by_user_id_user_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "user", + "columnsFrom": [ + "archived_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "editorial_accounts_user_id_unique": { + "name": "editorial_accounts_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + }, + "editorial_accounts_login_email_unique": { + "name": "editorial_accounts_login_email_unique", + "nullsNotDistinct": false, + "columns": [ + "login_email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lightbox_items": { + "name": "lightbox_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "lightbox_items_editorial_asset_idx": { + "name": "lightbox_items_editorial_asset_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "asset_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "lightbox_items_editorial_account_id_editorial_accounts_id_fk": { + "name": "lightbox_items_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "lightbox_items", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limits": { + "name": "rate_limits", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "window_boundary": { + "name": "window_boundary", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "rate_limits_key_window_boundary_pk": { + "name": "rate_limits_key_window_boundary_pk", + "columns": [ + "key", + "window_boundary" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.release_notes": { + "name": "release_notes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'both'" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "release_notes_version_audience_unique": { + "name": "release_notes_version_audience_unique", + "columns": [ + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "audience", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "release_notes_created_by_user_id_user_id_fk": { + "name": "release_notes_created_by_user_id_user_id_fk", + "tableFrom": "release_notes", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "release_notes_audience_check": { + "name": "release_notes_audience_check", + "value": "\"release_notes\".\"audience\" in ('admin', 'editorial', 'both')" + }, + "release_notes_version_check": { + "name": "release_notes_version_check", + "value": "\"release_notes\".\"version\" ~ '^[0-9]+\\.[0-9]+(\\.[0-9]+)?$'" + } + }, + "isRLSEnabled": false + }, + "public.download_events": { + "name": "download_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authorized_at": { + "name": "authorized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "download_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'authorized'" + }, + "transferred_bytes": { + "name": "transferred_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "repeat_download_note": { + "name": "repeat_download_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent_kind": { + "name": "intent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'new_usage'" + }, + "request_fingerprint": { + "name": "request_fingerprint", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "legacy_intent": { + "name": "legacy_intent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "download_events_editorial_authorized_id_idx": { + "name": "download_events_editorial_authorized_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "authorized_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "download_events_editorial_idempotency_key_unique": { + "name": "download_events_editorial_idempotency_key_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "download_events_editorial_account_id_editorial_accounts_id_fk": { + "name": "download_events_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "download_events", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "download_events_usage_id_usages_id_fk": { + "name": "download_events_usage_id_usages_id_fk", + "tableFrom": "download_events", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "download_events_intent_kind_check": { + "name": "download_events_intent_kind_check", + "value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download', 'legacy')" + }, + "download_events_request_fingerprint_hex_check": { + "name": "download_events_request_fingerprint_hex_check", + "value": "\"download_events\".\"request_fingerprint\" ~ '^[0-9a-f]{64}$'" + }, + "download_events_canonical_idempotency_key_check": { + "name": "download_events_canonical_idempotency_key_check", + "value": "\"download_events\".\"legacy_intent\" OR \"download_events\".\"idempotency_key\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + }, + "download_events_canonical_immich_asset_id_check": { + "name": "download_events_canonical_immich_asset_id_check", + "value": "\"download_events\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + } + }, + "isRLSEnabled": false + }, + "public.usages": { + "name": "usages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "immich_album_id_snapshot": { + "name": "immich_album_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference": { + "name": "internal_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "collab": { + "name": "collab", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_status": { + "name": "billing_status", + "type": "usage_billing_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "usages_editorial_created_id_idx": { + "name": "usages_editorial_created_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usages_created_at_idx": { + "name": "usages_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "usages_editorial_account_id_editorial_accounts_id_fk": { + "name": "usages_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "usages", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "usages_billing_report_id_billing_reports_id_fk": { + "name": "usages_billing_report_id_billing_reports_id_fk", + "tableFrom": "usages", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "usages_canonical_immich_asset_id_check": { + "name": "usages_canonical_immich_asset_id_check", + "value": "\"usages\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + }, + "usages_canonical_immich_album_id_check": { + "name": "usages_canonical_immich_album_id_check", + "value": "\"usages\".\"immich_album_id_snapshot\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + } + }, + "isRLSEnabled": false + } + }, + "enums": { + "public.portal_role": { + "name": "portal_role", + "schema": "public", + "values": [ + "ADMIN", + "EDITORIAL" + ] + }, + "public.report_status": { + "name": "report_status", + "schema": "public", + "values": [ + "draft", + "final", + "cancelled" + ] + }, + "public.account_status": { + "name": "account_status", + "schema": "public", + "values": [ + "pending_email", + "pending_approval", + "active", + "suspended", + "rejected" + ] + }, + "public.download_status": { + "name": "download_status", + "schema": "public", + "values": [ + "authorized", + "streaming", + "completed", + "failed_before_delivery", + "interrupted" + ] + }, + "public.usage_billing_status": { + "name": "usage_billing_status", + "schema": "public", + "values": [ + "open", + "billed", + "reopened", + "voided" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 081a29d..c8eb1b4 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -15,6 +15,20 @@ "when": 1789139950413, "tag": "0001_add_announcements", "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1796065000672, + "tag": "0002_release_notes_calendar", + "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1796067598623, + "tag": "0003_collab_invoice_activity", + "breakpoints": true } ] } \ No newline at end of file diff --git a/public/brand/logo-black-header.png b/public/brand/logo-black-header.png new file mode 100644 index 0000000000000000000000000000000000000000..5d9f74c44374fe2926cded5500ecb81cf46d1e57 GIT binary patch literal 27121 zcmeEubyStx*Dl+A+@Mkh(xCz>2+~Mz=`QIIlx}J1jiewU3P^XCNJ=B!Y?@6e-6-AM zwNcOU{O&i#z2lDWzxz3cLk7OF-nHhM^O?_l=6WqJD~5BK+S76XIv4*DCeJ+NWLTSz zg|Fk7q_*vb(tIhC*6X3SFoE%TFh7JqXZ7ipzkhA@U8$xC;xF@F-K6A6>-^Hz$m zIStv{Ir8wZm6Mx0ecJI^Yk0+;EI}`RhIqavzvtjIe)xbtvPazj3Uv9SITs`41mqu)ofK$n}K$yu$4N`I0JwrM@&nRI!QS@%|6Pk&n;PJ*5$Q*Nf(`FePC(y>XK9{AjH#)Zq?qT%Mk23zN{tz4XsSHlA5~v>A`~G z{`YUlo7t!mGajqJgaDnh!{K@GvK(S|)A#D1^k1)RJNejo-aQOdIu<@afBXS1=j*{mU0?w(&yvc0aVy zyFR=Xq6@FPWS9BvYX`<1IfWZg7MERf+moH)7#Yrq0jKW%;N~FG7){I1O|FMa8R@P2 zeFAL8y>$Ih=4X2>O21|Y0X8iIM&i6+S3-Q9mGNKubK zoXK*< zG6{zC;%MVm#Gn$D45){~6rs=7b!ssVQehvKwi zQo7=64=ix|CHbsp%PW7Z`et_aqW3Xo6s7xq{Ve3qxw1!GwedEFvwf(X3FdiK&f7bz zW>vk@8G1{|ri5hL_UwBd6z>D?pD*FZV-gJN#rE%Zj5jVK#2jIrn>wW@k1*s^!}t+-z{P*T_r z`_DP%uft*%WTGM|HmM9<(VF8j9n3cH#UZ`9j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--- a/scripts/render-pdf-fixture.ts +++ b/scripts/render-pdf-fixture.ts @@ -41,6 +41,7 @@ function basePosition(priceCents = 6_000) { purpose: "Print Nutzung", reference: "REF-001" as string | null, priceCents, + collab: false, createdAt: new Date("2026-03-15T10:00:00.000Z"), }; } diff --git a/src/app/admin/abrechnungen/[editorialId]/BillingSelection.test.tsx b/src/app/admin/abrechnungen/[editorialId]/BillingSelection.test.tsx index bda4e34..1e8036e 100644 --- a/src/app/admin/abrechnungen/[editorialId]/BillingSelection.test.tsx +++ b/src/app/admin/abrechnungen/[editorialId]/BillingSelection.test.tsx @@ -17,6 +17,7 @@ const openPosition: BillingPosition = { purpose: "Titelgeschichte", reference: "Ausgabe 8/26", priceCents: 6_000, + collab: false, status: "open", selectable: true, createdAt: new Date("2026-08-05T10:00:00.000Z"), @@ -32,6 +33,7 @@ const billedPosition: BillingPosition = { purpose: "Sportbericht", reference: null, priceCents: 1_500, + collab: false, status: "billed", selectable: false, createdAt: new Date("2026-08-06T10:00:00.000Z"), @@ -47,6 +49,7 @@ const reopenedPosition: BillingPosition = { purpose: "Reopened", reference: null, priceCents: 1_500, + collab: false, status: "reopened", selectable: true, createdAt: new Date("2026-08-07T10:00:00.000Z"), diff --git a/src/app/admin/abrechnungen/[editorialId]/BillingSelection.tsx b/src/app/admin/abrechnungen/[editorialId]/BillingSelection.tsx index 8e0464d..6d84508 100644 --- a/src/app/admin/abrechnungen/[editorialId]/BillingSelection.tsx +++ b/src/app/admin/abrechnungen/[editorialId]/BillingSelection.tsx @@ -162,6 +162,28 @@ export function BillingSelection({ } } + async function handleToggleCollab(position: BillingPosition) { + setActionState({ loading: true, message: null, isError: false }); + try { + const response = await fetch(`/api/usages/${encodeURIComponent(position.id)}/collab`, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ collab: !position.collab }), + }); + if (!response.ok) { + const body = await response.json().catch(() => ({ code: "ERROR" })); + throw new Error(body.code ?? "Collab-Kennzeichnung fehlgeschlagen"); + } + window.location.reload(); + } catch (error) { + setActionState({ + loading: false, + message: error instanceof Error ? error.message : "Collab-Kennzeichnung fehlgeschlagen", + isError: true, + }); + } + } + const quarterParam = isQuarter ? null : Math.ceil((month ?? 1) / 3); const quarterHref = quarter ? `/admin/abrechnungen/${editorialId}?year=${year}&quarter=${quarter}` @@ -228,7 +250,20 @@ export function BillingSelection({ {position.albumName} {position.purpose} {position.reference ?? "—"} - {formatCents(position.priceCents)} + + {formatCents(position.priceCents)} + {position.collab && Collab} + {position.selectable && ( + + )} + {STATUS_LABELS[position.status]} @@ -334,13 +369,48 @@ export function BillingSelection({ {report.status === "final" && ( <> +
+

+ Rechnung:{" "} + {report.invoiceEmailStatus === "sent" ? ( + <> + versendet am{" "} + + + ) : report.hasInvoicePdf ? ( + "PDF hinterlegt, Versand fehlgeschlagen" + ) : ( + "noch keine PDF hinterlegt" + )} +

+ + {report.hasInvoicePdf && ( + + Rechnungs-PDF herunterladen + + )} +
- - PDF herunterladen + Nutzungsnachweis herunterladen )} @@ -403,6 +473,114 @@ function PeriodSelector({ year, month, quarter, isQuarter }: PeriodSelectorProps ); } +type InvoiceUploadFormProps = { + reportId: string; + reportNumber: number; + hasInvoice: boolean; + emailFailed: boolean; +}; + +function InvoiceUploadForm({ reportId, reportNumber, hasInvoice, emailFailed }: InvoiceUploadFormProps) { + const [file, setFile] = useState(null); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + + async function handleUpload(event: React.FormEvent) { + event.preventDefault(); + if (!file || loading) return; + setLoading(true); + setError(null); + try { + const formData = new FormData(); + formData.set("invoice", file); + const response = await fetch(`/api/billing-reports/${encodeURIComponent(reportId)}/invoice`, { + method: "POST", + body: formData, + }); + if (!response.ok) { + const body = await response.json().catch(() => ({ code: "ERROR" })); + throw new Error(invoiceErrorMessage(body.code)); + } + window.location.reload(); + } catch (err) { + setError(err instanceof Error ? err.message : "Upload fehlgeschlagen"); + setLoading(false); + } + } + + async function handleResend() { + if (loading) return; + setLoading(true); + setError(null); + try { + const response = await fetch( + `/api/billing-reports/${encodeURIComponent(reportId)}/invoice/resend`, + { method: "POST" }, + ); + if (!response.ok) { + const body = await response.json().catch(() => ({ code: "ERROR" })); + throw new Error(invoiceErrorMessage(body.code)); + } + window.location.reload(); + } catch (err) { + setError(err instanceof Error ? err.message : "Versand fehlgeschlagen"); + setLoading(false); + } + } + + return ( +
+ +
+ + {hasInvoice && ( + + )} +
+

+ Nach dem Upload geht die Rechnung gebündelt mit dem Nutzungsnachweis automatisch per + E-Mail an die Redaktion. +

+ {error && ( +

+ {error} +

+ )} +
+ ); +} + +function invoiceErrorMessage(code: unknown): string { + switch (code) { + case "INVALID_PDF": + return "Die Datei ist keine gültige PDF (max. 20 MB)."; + case "REPORT_NOT_FINAL": + return "Der Bericht ist nicht finalisiert."; + case "INVOICE_NOT_UPLOADED": + return "Es ist noch keine Rechnungs-PDF hinterlegt."; + case "RATE_LIMITED": + return "Zu viele Versuche. Bitte kurz warten."; + default: + return "Der Vorgang ist fehlgeschlagen. Bitte erneut versuchen."; + } +} + type CancelReportFormProps = { reportId: string; reportNumber: number; diff --git a/src/app/admin/abrechnungen/[editorialId]/page-content.ts b/src/app/admin/abrechnungen/[editorialId]/page-content.ts index 1a6d853..d9b229f 100644 --- a/src/app/admin/abrechnungen/[editorialId]/page-content.ts +++ b/src/app/admin/abrechnungen/[editorialId]/page-content.ts @@ -15,6 +15,10 @@ export type FinalizedReportSummary = { netTotalCents: number; status: string; createdAt: Date; + hasInvoicePdf: boolean; + invoiceUploadedAt: Date | null; + invoiceEmailStatus: string; + invoiceEmailSentAt: Date | null; }; export type BillingSelectionData = { @@ -54,6 +58,10 @@ export async function loadBillingSelection( netTotalCents: billingReports.netTotalCents, status: billingReports.status, createdAt: billingReports.createdAt, + invoicePdfSha256: billingReports.invoicePdfSha256, + invoiceUploadedAt: billingReports.invoiceUploadedAt, + invoiceEmailStatus: billingReports.invoiceEmailStatus, + invoiceEmailSentAt: billingReports.invoiceEmailSentAt, }) .from(billingReports) .where(eq(billingReports.editorialAccountId, editorialId)) @@ -77,6 +85,10 @@ export async function loadBillingSelection( netTotalCents: row.netTotalCents, status: row.status, createdAt: row.createdAt, + hasInvoicePdf: row.invoicePdfSha256 !== null, + invoiceUploadedAt: row.invoiceUploadedAt, + invoiceEmailStatus: row.invoiceEmailStatus, + invoiceEmailSentAt: row.invoiceEmailSentAt, })), }; } diff --git a/src/app/admin/kalender/CalendarEventForm.tsx b/src/app/admin/kalender/CalendarEventForm.tsx new file mode 100644 index 0000000..4340d10 --- /dev/null +++ b/src/app/admin/kalender/CalendarEventForm.tsx @@ -0,0 +1,99 @@ +"use client"; + +import { useId, useState, useTransition } from "react"; + +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; + +import type { CalendarActionResult } from "./actions"; + +export function CalendarEventForm({ + action, + defaultEventDate, + albums, +}: Readonly<{ + action: (state: CalendarActionResult, formData: FormData) => Promise; + defaultEventDate: string; + albums: Array<{ id: string; albumName: string }>; +}>) { + const titleId = useId(); + const dateId = useId(); + const albumId = useId(); + const [state, setState] = useState({ ok: true, message: "" }); + const [pending, startTransition] = useTransition(); + const [title, setTitle] = useState(""); + + const handleSubmit = (formData: FormData) => { + startTransition(async () => { + const result = await action({ ok: true, message: "" }, formData); + setState(result); + if (result.ok) { + setTitle(""); + } + }); + }; + + return ( +
+
+ + setTitle(event.target.value)} + maxLength={200} + required + placeholder="z. B. Hamburger SV - VfL Wolfsburg" + /> +

+ Ohne direkte Album-Auswahl wird automatisch verknüpft, sobald ein Album exakt + {" „{Titel}“ "}oder{" „{Titel} | TT.MM.JJJJ“ "}heißt (Datum dieses Termins). +

+
+
+
+ + +
+
+ + +
+
+ + {state.message ? ( +

+ {state.message} +

+ ) : null} +
+ ); +} diff --git a/src/app/admin/kalender/DeleteCalendarEventButton.tsx b/src/app/admin/kalender/DeleteCalendarEventButton.tsx new file mode 100644 index 0000000..4b0ff7b --- /dev/null +++ b/src/app/admin/kalender/DeleteCalendarEventButton.tsx @@ -0,0 +1,44 @@ +"use client"; + +import { useState, useTransition } from "react"; + +import { Button } from "@/components/ui/button"; + +import type { CalendarActionResult } from "./actions"; + +// Deleting an event also revokes self-service grants on its linked album, so +// the admin confirms once before the action runs. +export function DeleteCalendarEventButton({ + action, + eventId, +}: Readonly<{ + action: (state: CalendarActionResult, formData: FormData) => Promise; + eventId: string; +}>) { + const [state, setState] = useState({ ok: true, message: "" }); + const [pending, startTransition] = useTransition(); + + const handleClick = () => { + if (!window.confirm("Termin löschen? Selbst freigeschaltete Zugriffe auf das verknüpfte Album werden entzogen.")) { + return; + } + const formData = new FormData(); + formData.set("eventId", eventId); + startTransition(async () => { + setState(await action({ ok: true, message: "" }, formData)); + }); + }; + + return ( +
+ + {state.ok ? null : ( +

+ {state.message} +

+ )} +
+ ); +} diff --git a/src/app/admin/kalender/actions.ts b/src/app/admin/kalender/actions.ts new file mode 100644 index 0000000..1477285 --- /dev/null +++ b/src/app/admin/kalender/actions.ts @@ -0,0 +1,84 @@ +"use server"; + +import { revalidatePath } from "next/cache"; +import { headers } from "next/headers"; + +import { requireAdmin } from "@/modules/auth/principal"; +import { CalendarServiceError, calendarService } from "@/modules/calendar/service"; + +export type CalendarActionResult = { + ok: boolean; + message: string; +}; + +export async function createCalendarEventAction( + _prevState: CalendarActionResult, + formData: FormData, +): Promise { + const principal = await requireAdmin(new Headers(await headers())); + const title = formData.get("title"); + const eventDate = formData.get("eventDate"); + const immichAlbumId = formData.get("immichAlbumId"); + + if (typeof title !== "string" || typeof eventDate !== "string") { + return { ok: false, message: "Bitte Titel und Datum ausfüllen." }; + } + + try { + await calendarService.createEvent({ + title, + eventDate, + immichAlbumId: typeof immichAlbumId === "string" && immichAlbumId ? immichAlbumId : null, + adminUserId: principal.userId, + }); + } catch (error) { + return { ok: false, message: calendarErrorMessage(error) }; + } + + revalidatePath("/admin/kalender"); + revalidatePath("/redaktion/kalender"); + return { + ok: true, + message: + "Termin angelegt. Sobald ein passendes Album in Immich erscheint, können Redaktionen es selbst freischalten.", + }; +} + +export async function deleteCalendarEventAction( + _prevState: CalendarActionResult, + formData: FormData, +): Promise { + const principal = await requireAdmin(new Headers(await headers())); + const eventId = formData.get("eventId"); + if (typeof eventId !== "string" || eventId.length === 0) { + return { ok: false, message: "Ungültige Kennung." }; + } + + try { + await calendarService.deleteEvent({ id: eventId, adminUserId: principal.userId }); + } catch (error) { + return { ok: false, message: calendarErrorMessage(error) }; + } + + revalidatePath("/admin/kalender"); + revalidatePath("/redaktion/kalender"); + revalidatePath("/redaktion/alben"); + return { ok: true, message: "" }; +} + +function calendarErrorMessage(error: unknown): string { + if (error instanceof CalendarServiceError) { + const messages: Record = { + INVALID_TITLE: "Bitte geben Sie einen Titel mit 1 bis 200 Zeichen ein.", + INVALID_EVENT_DATE: "Bitte wählen Sie ein gültiges Datum.", + INVALID_ALBUM: "Das gewählte Album existiert nicht mehr in Immich.", + INVALID_STATUS: "Ungültige Rückmeldung.", + EVENT_NOT_FOUND: "Dieser Termin existiert nicht mehr.", + EVENT_ALBUM_UNAVAILABLE: "Zu diesem Termin ist noch kein Album verknüpft.", + IMMICH_UNAVAILABLE: "Immich ist gerade nicht erreichbar. Bitte später erneut versuchen.", + RATE_LIMITED: "Zu viele Anfragen. Bitte kurz warten.", + }; + return messages[error.code] ?? "Der Termin konnte nicht gespeichert werden."; + } + return "Der Termin konnte nicht gespeichert werden."; +} diff --git a/src/app/admin/kalender/page.tsx b/src/app/admin/kalender/page.tsx new file mode 100644 index 0000000..81919ec --- /dev/null +++ b/src/app/admin/kalender/page.tsx @@ -0,0 +1,107 @@ +import { PageHeader } from "@/components/ui/page-header"; +import { formatIsoDateGerman, isoDateInBerlin } from "@/modules/announcements/service"; +import { calendarService } from "@/modules/calendar/service"; +import { immichClient } from "@/modules/immich/client"; + +import { CalendarEventForm } from "./CalendarEventForm"; +import { DeleteCalendarEventButton } from "./DeleteCalendarEventButton"; +import { createCalendarEventAction, deleteCalendarEventAction } from "./actions"; + +export default async function AdminCalendarPage() { + const [{ events, immichUnavailable }, albums] = await Promise.all([ + calendarService.listAdminEvents(), + immichClient.listAlbums().catch(() => []), + ]); + const today = isoDateInBerlin(new Date()); + + return ( +
+ + + ({ id: album.id, albumName: album.albumName }))} + /> + + {immichUnavailable ? ( +

+ Immich ist gerade nicht erreichbar. Verknüpfte Alben werden angezeigt, sobald die Verbindung wieder steht. +

+ ) : null} + +
+
+

+ Alle Termine +

+

{events.length} insgesamt

+
+ + {events.length === 0 ? ( +

+ Noch keine Termine vorhanden. Legen Sie oben den ersten Termin an. +

+ ) : ( +
    + {events.map((event) => { + const attending = event.responses.filter((response) => response.status === "attending"); + const notAttending = event.responses.filter((response) => response.status === "not_attending"); + return ( +
  • +
    +

    + {event.title} + {event.eventDate < today ? ( + vorbei + ) : null} +

    +

    + {formatIsoDateGerman(event.eventDate)} ·{" "} + {event.album ? ( + Album: {event.album.albumName} + ) : ( + Noch kein Album verknüpft + )} +

    + {event.responses.length > 0 ? ( +
    + {attending.map((response) => ( + + {response.editorialName}: da + + ))} + {notAttending.map((response) => ( + + {response.editorialName}: nicht da + + ))} +
    + ) : ( +

    Noch keine Rückmeldungen.

    + )} +
    + +
  • + ); + })} +
+ )} +
+
+ ); +} + diff --git a/src/app/admin/layout.tsx b/src/app/admin/layout.tsx index 522189f..e2bf94a 100644 --- a/src/app/admin/layout.tsx +++ b/src/app/admin/layout.tsx @@ -13,9 +13,12 @@ export default async function AdminLayout({ children }: Readonly<{ children: Rea sectionLabel="Administration" nav={[ { href: "/admin", label: "Dashboard" }, + { href: "/admin/statistiken", label: "Statistiken" }, { href: "/admin/redaktionen", label: "Redaktionen" }, { href: "/admin/alben", label: "Alben" }, + { href: "/admin/kalender", label: "Kalender" }, { href: "/admin/hinweise", label: "Hinweise" }, + { href: "/admin/versionen", label: "Versionen" }, { href: "/admin/abrechnungen", label: "Abrechnungen" }, { href: "/admin/audit", label: "Audit" }, ]} diff --git a/src/app/admin/redaktionen/[id]/actions.ts b/src/app/admin/redaktionen/[id]/actions.ts index 8678c84..913d520 100644 --- a/src/app/admin/redaktionen/[id]/actions.ts +++ b/src/app/admin/redaktionen/[id]/actions.ts @@ -9,6 +9,7 @@ import { editorialAccounts } from "@/db/schema"; import { requireAdmin, PrincipalAuthorizationError, DESTRUCTIVE_ACTION_MAX_SESSION_AGE_SECONDS } from "@/modules/auth/principal"; import { editorialService, EditorialServiceError } from "@/modules/editorials/service"; +import { writeAudit } from "@/modules/audit/write"; // Returned to the client form so failures surface as inline German text // instead of an opaque Next.js error-digest page (a thrown server action @@ -203,6 +204,39 @@ export async function updateFlatrateAction(editorialId: string, formData: FormDa revalidatePath(`/admin/redaktionen/${safeEditorialId}`); } +export async function updateCollabAction(editorialId: string, formData: FormData): Promise { + const admin = await requireAdmin(new Headers(await headers())); + const safeEditorialId = requiredId(editorialId); + const collabEnabled = formData.get("collabEnabled") === "on"; + + const [previous] = await db + .select({ collabEnabled: editorialAccounts.collabEnabled }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, safeEditorialId)) + .limit(1); + if (!previous) throw new Error("EDITORIAL_NOT_FOUND"); + + await db + .update(editorialAccounts) + .set({ collabEnabled }) + .where(eq(editorialAccounts.id, safeEditorialId)); + + try { + await writeAudit({ + type: "editorial_collab_updated", + actorUserId: admin.userId, + actorType: "admin", + entityType: "editorial_account", + entityId: safeEditorialId, + metadata: { from: previous.collabEnabled, to: collabEnabled }, + }); + } catch { + // Audit is observability, not a transaction participant. + } + + revalidatePath(`/admin/redaktionen/${safeEditorialId}`); +} + function parsePriceCents( value: unknown, ): { ok: true; cents: number } | { ok: false; message: string } { diff --git a/src/app/admin/redaktionen/[id]/alben/page.test.tsx b/src/app/admin/redaktionen/[id]/alben/page.test.tsx index 19b703b..00a0824 100644 --- a/src/app/admin/redaktionen/[id]/alben/page.test.tsx +++ b/src/app/admin/redaktionen/[id]/alben/page.test.tsx @@ -18,6 +18,7 @@ const editorial = { flatrateActive: false, flatratePriceCents: null, flatrateAssetLimit: null, + collabEnabled: false, archivedAt: null, }; diff --git a/src/app/admin/redaktionen/[id]/page.tsx b/src/app/admin/redaktionen/[id]/page.tsx index f96327a..dfea4c7 100644 --- a/src/app/admin/redaktionen/[id]/page.tsx +++ b/src/app/admin/redaktionen/[id]/page.tsx @@ -21,6 +21,7 @@ export default async function EditorialDetailPage({ flatrateActive: editorialAccounts.flatrateActive, flatratePriceCents: editorialAccounts.flatratePriceCents, flatrateAssetLimit: editorialAccounts.flatrateAssetLimit, + collabEnabled: editorialAccounts.collabEnabled, archivedAt: editorialAccounts.archivedAt, }) .from(editorialAccounts) diff --git a/src/app/admin/statistiken/page.tsx b/src/app/admin/statistiken/page.tsx new file mode 100644 index 0000000..ce87a29 --- /dev/null +++ b/src/app/admin/statistiken/page.tsx @@ -0,0 +1,358 @@ +import Link from "next/link"; + +import { PageHeader } from "@/components/ui/page-header"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { + formatBytes, + normalizeStatsDays, + percentChange, + STATS_PERIOD_OPTIONS, + statsQueries, +} from "@/modules/stats/queries"; + +import { requireAdminPage } from "../access"; +import { ActivityChart, RevenueChart } from "./stats-charts-lazy"; + +const euroFormatter = new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }); + +const ACTIVITY_LABELS: Record = { + album_view: "Album geöffnet", + search: "Suche", + lightbox_view: "Großansicht", +}; + +export default async function AdminStatsPage({ + searchParams, +}: Readonly<{ searchParams: Promise> }>) { + await requireAdminPage(); + const sp = await searchParams; + const rawDays = Array.isArray(sp.zeitraum) ? sp.zeitraum[0] : sp.zeitraum; + const days = normalizeStatsDays(rawDays); + const stats = await statsQueries.loadOverview(days); + const { kpis, previousKpis } = stats; + + return ( +
+ + +
+ +

+ Zeitraum: {stats.window.fromUtc.toLocaleDateString("de-DE")} bis{" "} + {stats.window.toUtcExclusive.toLocaleDateString("de-DE")} +

+
+ +
+ + + + + + + + +
+ +
+ + +

+ Offener Umsatz gesamt +

+

+ {euroFormatter.format(stats.openRevenueCents / 100)} +

+

+ Noch nicht abgerechnete Nutzungen +

+
+
+ + +

+ Abrechnungen im Zeitraum +

+

{stats.finalizedReports}

+

Finalisierte Nutzungsnachweise

+
+
+ + +

+ Collab-Quote +

+

+ {kpis.newUsages > 0 + ? `${Math.round((kpis.collabUsages / kpis.newUsages) * 100)} %` + : "0 %"} +

+

+ Anteil kostenfreier Collab-Nutzungen +

+
+
+
+ + + + Aktivität der letzten {days} Tage + + Downloads, Album-Aufrufe und Suchen pro Tag über alle Redaktionen. + + + + + + + + + + Umsatz pro Tag + Netto-Umsatz aus neuen Nutzungen im Zeitraum. + + + + + + +
+ + + Redaktionen im Zeitraum + Nach Downloads sortiert. + + + {stats.topEditorials.length === 0 ? ( +

Noch keine Daten vorhanden.

+ ) : ( +
+ + + + + + + + + + + + + {stats.topEditorials.map((row, index) => ( + + + + + + + + + ))} + +
RedaktionDownloadsCollabUmsatzAufrufeSuchen
+ + {row.name} + + {row.downloads} + {row.collabUsages > 0 ? ( + + {row.collabUsages} + + ) : ( + "0" + )} + + {euroFormatter.format(row.revenueCents / 100)} + {row.views}{row.searches}
+
+ )} +
+
+ + + + Alben im Zeitraum + Nach Downloads und Aufrufen sortiert. + + + {stats.topAlbums.length === 0 ? ( +

Noch keine Daten vorhanden.

+ ) : ( +
+ + + + + + + + + + + {stats.topAlbums.map((row, index) => ( + + + + + + + ))} + +
AlbumDownloadsAufrufeUmsatz
{row.albumName}{row.downloads}{row.views} + {euroFormatter.format(row.revenueCents / 100)} +
+
+ )} +
+
+
+ + + + Letzte Aktivitäten + Die neuesten erfassten Aktionen der Redaktionen. + + + {stats.recentActivity.length === 0 ? ( +

+ Noch keine Aktivitäten erfasst. Aufrufe und Suchen werden ab Version 2.2 gezählt. +

+ ) : ( +
    + {stats.recentActivity.map((event) => ( +
  • + + {ACTIVITY_LABELS[event.eventType] ?? event.eventType} + + {event.editorialName} + {event.query ? ( + „{event.query}“ + ) : null} + +
  • + ))} +
+ )} +
+
+
+ ); +} + +type KpiCardProps = { + label: string; + value: string; + hint: string; + change?: number | null; +}; + +function KpiCard({ label, value, hint, change }: KpiCardProps) { + return ( + + +
+

+ {label} +

+ {change !== undefined && change !== null ? ( + 0 + ? "border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-400" + : change < 0 + ? "border-red-300 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-950/40 dark:text-red-400" + : "border-border bg-muted/40 text-muted-foreground" + }`} + title="Veränderung gegenüber dem vorherigen Zeitraum" + > + {change > 0 ? "+" : ""} + {change} % + + ) : null} +
+

{value}

+

{hint}

+
+
+ ); +} diff --git a/src/app/admin/statistiken/stats-charts-lazy.tsx b/src/app/admin/statistiken/stats-charts-lazy.tsx new file mode 100644 index 0000000..2526b8b --- /dev/null +++ b/src/app/admin/statistiken/stats-charts-lazy.tsx @@ -0,0 +1,15 @@ +"use client"; + +import dynamic from "next/dynamic"; + +const ActivityChart = dynamic( + () => import("./stats-charts").then((mod) => mod.ActivityChart), + { ssr: false }, +); + +const RevenueChart = dynamic( + () => import("./stats-charts").then((mod) => mod.RevenueChart), + { ssr: false }, +); + +export { ActivityChart, RevenueChart }; diff --git a/src/app/admin/statistiken/stats-charts.tsx b/src/app/admin/statistiken/stats-charts.tsx new file mode 100644 index 0000000..87fa57c --- /dev/null +++ b/src/app/admin/statistiken/stats-charts.tsx @@ -0,0 +1,177 @@ +"use client"; + +import { useTheme } from "next-themes"; +import { + Area, + AreaChart, + Bar, + BarChart, + CartesianGrid, + Legend, + ResponsiveContainer, + Tooltip, + XAxis, + YAxis, +} from "recharts"; + +import type { DailyPoint } from "@/modules/stats/queries"; + +type StatsChartsProps = { + data: DailyPoint[]; +}; + +const euroFormatter = new Intl.NumberFormat("de-DE", { + style: "currency", + currency: "EUR", +}); + +function useChartColors() { + const { theme } = useTheme(); + const dark = theme === "dark"; + return { + grid: dark ? "#333333" : "#e5e5e5", + axis: "#888888", + tooltip: { + backgroundColor: dark ? "#1f2937" : "#ffffff", + borderColor: dark ? "#374151" : "#e5e7eb", + color: dark ? "#f3f4f6" : "#111827", + }, + cursor: dark ? "#ffffff10" : "#00000005", + downloads: dark ? "#6366f1" : "#4f46e5", + views: dark ? "#34d399" : "#059669", + searches: dark ? "#fbbf24" : "#d97706", + }; +} + +function formatDay(value: string): string { + return new Date(value).toLocaleDateString("de-DE", { day: "2-digit", month: "short" }); +} + +function formatDayLong(value: string): string { + return new Date(value).toLocaleDateString("de-DE", { + weekday: "long", + day: "2-digit", + month: "long", + year: "numeric", + }); +} + +export function ActivityChart({ data }: StatsChartsProps) { + const colors = useChartColors(); + return ( +
+ + + + + + + + + + + + + + + + formatDayLong(String(label))} + /> + + + + + + +
+ ); +} + +export function RevenueChart({ data }: StatsChartsProps) { + const colors = useChartColors(); + return ( +
+ + + + + `${value} €`} + /> + formatDayLong(String(label))} + formatter={(value) => [euroFormatter.format(Number(value) / 100), "Umsatz"]} + /> + + + +
+ ); +} diff --git a/src/app/admin/versionen/DeleteReleaseNoteButton.tsx b/src/app/admin/versionen/DeleteReleaseNoteButton.tsx new file mode 100644 index 0000000..2c1d3d9 --- /dev/null +++ b/src/app/admin/versionen/DeleteReleaseNoteButton.tsx @@ -0,0 +1,31 @@ +"use client"; + +import { useActionState } from "react"; + +import { Button } from "@/components/ui/button"; + +import type { ReleaseNoteActionResult } from "./actions"; + +export function DeleteReleaseNoteButton({ + action, + noteId, +}: Readonly<{ + action: (state: ReleaseNoteActionResult, formData: FormData) => Promise; + noteId: string; +}>) { + const [state, formAction, pending] = useActionState(action, { ok: true, message: "" }); + + return ( +
+ + + {state.ok ? null : ( +

+ {state.message} +

+ )} +
+ ); +} diff --git a/src/app/admin/versionen/ReleaseNoteForm.tsx b/src/app/admin/versionen/ReleaseNoteForm.tsx new file mode 100644 index 0000000..0f2346e --- /dev/null +++ b/src/app/admin/versionen/ReleaseNoteForm.tsx @@ -0,0 +1,91 @@ +"use client"; + +import { useId, useState, useTransition } from "react"; + +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; + +import type { ReleaseNoteActionResult } from "./actions"; + +export function ReleaseNoteForm({ + action, +}: Readonly<{ + action: (state: ReleaseNoteActionResult, formData: FormData) => Promise; +}>) { + const versionId = useId(); + const audienceId = useId(); + const bodyId = useId(); + const [state, setState] = useState({ ok: true, message: "" }); + const [pending, startTransition] = useTransition(); + const [body, setBody] = useState(""); + + const handleSubmit = (formData: FormData) => { + startTransition(async () => { + const result = await action({ ok: true, message: "" }, formData); + setState(result); + if (result.ok) { + setBody(""); + } + }); + }; + + return ( +
+
+
+ + +
+
+ + +
+
+
+ +