Compare commits
77
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8748cc1098 | ||
|
|
cba70310f9 | ||
|
|
2775b406bf | ||
|
|
4fb6f2d373 | ||
|
|
d479e1e79b | ||
|
|
71110208a9 | ||
|
|
c0c2425dda | ||
|
|
7204dd6b60 | ||
|
|
58a28e391c | ||
|
|
319e3dc101 | ||
|
|
f899417b1e | ||
|
|
e8da50c998 | ||
|
|
69264ce165 | ||
|
|
c40ccf77cf | ||
|
|
affa046b4a | ||
|
|
9e938e4d07 | ||
|
|
453bece72c | ||
|
|
bdf6399b35 | ||
|
|
abe072b2d1 | ||
|
|
2a5a2f3815 | ||
|
|
0931ffc777 | ||
|
|
0b65fbba16 | ||
|
|
2949149170 | ||
|
|
11cde23cdb | ||
|
|
f42f4d5d2d | ||
|
|
0d939593c8 | ||
|
|
9308b46d84 | ||
|
|
c9d3f3d1dc | ||
|
|
c6b69eb88d | ||
|
|
dd60fd6ee6 | ||
|
|
a3dc56778d | ||
|
|
9aa79cbce9 | ||
|
|
cccb214229 | ||
|
|
9903d18b84 | ||
|
|
61b1dbe350 | ||
|
|
d8c3508db2 | ||
|
|
3e0221b149 | ||
|
|
f7a311dece | ||
|
|
60d5a95651 | ||
|
|
e328267763 | ||
|
|
844b8f7afd | ||
|
|
0085c721af | ||
|
|
1279f46b1f | ||
|
|
9089dce74a | ||
|
|
b1ef4a8186 | ||
|
|
ec5ed8b22a | ||
|
|
56f21a5289 | ||
|
|
a98c7bc8ee | ||
|
|
3a1f4274a4 | ||
|
|
c1bd620d91 | ||
|
|
60ef5ddab9 | ||
|
|
86dfe8053d | ||
|
|
52dce168dd | ||
|
|
21d41c7017 | ||
|
|
5a76c4fbb4 | ||
|
|
8eadd1f408 | ||
|
|
ca5f79e193 | ||
|
|
6a31e5f411 | ||
|
|
962e2c7dc2 | ||
|
|
f1ed89ea67 | ||
|
|
a7df6bd60a | ||
|
|
a3ec068cac | ||
|
|
b81cd7c3e2 | ||
|
|
dad8e07ec5 | ||
|
|
fe2f82244d | ||
|
|
7e85b35486 | ||
|
|
986828893b | ||
|
|
ed957e6559 | ||
|
|
9fdd76645c | ||
|
|
4667615ed0 | ||
|
|
8dd1e10fea | ||
|
|
d9d69ed861 | ||
|
|
0576d946c5 | ||
|
|
f4c06cbc95 | ||
|
|
6631530dcb | ||
|
|
64147a3282 | ||
|
|
70ebcc9cd5 |
No files matched your search
@@ -0,0 +1,56 @@
|
|||||||
|
**
|
||||||
|
!Dockerfile
|
||||||
|
!package.json
|
||||||
|
!pnpm-lock.yaml
|
||||||
|
!pnpm-workspace.yaml
|
||||||
|
!next.config.ts
|
||||||
|
!next-env.d.ts
|
||||||
|
!postcss.config.mjs
|
||||||
|
!tsconfig.json
|
||||||
|
!drizzle.config.ts
|
||||||
|
!src/
|
||||||
|
!src/**/*.ts
|
||||||
|
!src/**/*.tsx
|
||||||
|
!src/**/*.css
|
||||||
|
!src/modules/pdf/fonts/*.ttf
|
||||||
|
!src/modules/pdf/fonts/LICENSE.txt
|
||||||
|
# The production TypeScript build only needs application sources.
|
||||||
|
src/**/*.test.ts
|
||||||
|
src/**/*.test.tsx
|
||||||
|
!public/
|
||||||
|
!public/brand/
|
||||||
|
!public/brand/logo-black.png
|
||||||
|
!public/brand/logo-white.png
|
||||||
|
!drizzle/
|
||||||
|
# Every migration must ship, or `migrate` fails on journal entries without files.
|
||||||
|
!drizzle/*.sql
|
||||||
|
!drizzle/meta/
|
||||||
|
!drizzle/meta/_journal.json
|
||||||
|
!scripts/
|
||||||
|
!scripts/backup-db.sh
|
||||||
|
!scripts/check-smtp.ts
|
||||||
|
!scripts/create-admin.ts
|
||||||
|
!scripts/preflight.ts
|
||||||
|
**/.*
|
||||||
|
**/.*/**
|
||||||
|
**/*.env
|
||||||
|
**/worktrees
|
||||||
|
**/worktrees/**
|
||||||
|
**/*credentials*
|
||||||
|
**/secrets
|
||||||
|
**/secrets.*
|
||||||
|
**/*.pem
|
||||||
|
**/*.key
|
||||||
|
**/*.p12
|
||||||
|
**/*.pfx
|
||||||
|
**/*.sql
|
||||||
|
!drizzle/*.sql
|
||||||
|
**/*.dump
|
||||||
|
**/*.backup
|
||||||
|
**/*.bak
|
||||||
|
**/*.tar
|
||||||
|
**/*.gz
|
||||||
|
**/*.zip
|
||||||
|
**/*.sqlite*
|
||||||
|
**/backup
|
||||||
|
**/backups
|
||||||
+9
-3
@@ -17,6 +17,12 @@ SMTP_PASSWORD=replace-with-an-smtp-password
|
|||||||
SMTP_FROM=portal@example.com
|
SMTP_FROM=portal@example.com
|
||||||
|
|
||||||
# Legal pages managed outside the application
|
# Legal pages managed outside the application
|
||||||
LEGAL_IMPRINT_URL=https://example.com/impressum
|
LEGAL_IMPRINT_URL=https://leon-tonhaeuser.de/impressum
|
||||||
LEGAL_PRIVACY_URL=https://example.com/datenschutz
|
LEGAL_PRIVACY_URL=https://leon-tonhaeuser.de/datenschutz
|
||||||
LEGAL_TERMS_URL=https://example.com/nutzungsbedingungen
|
LEGAL_TERMS_URL=https://leon-tonhaeuser.de/agb
|
||||||
|
|
||||||
|
# Album auto-rule sync: runs automatically every N seconds (default 120).
|
||||||
|
# AUTO_RULE_SYNC_INTERVAL_SECONDS=120
|
||||||
|
# Optional bearer token to trigger the sync externally via
|
||||||
|
# POST /api/cron/album-sync (Authorization: Bearer <CRON_SECRET>).
|
||||||
|
# CRON_SECRET=replace-with-a-long-random-secret
|
||||||
@@ -11,3 +11,5 @@ dist/
|
|||||||
coverage/
|
coverage/
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
test-results/
|
||||||
|
playwright-report/
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
# AGENTS.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`,
|
||||||
|
Quartalsabrechnung + Sakani-Formulare: `2.2.1`, Versionshistorie: `2.2.2`,
|
||||||
|
Kategorien/Vormerken/Monatskalender/Dashboard: `2.3.0`,
|
||||||
|
Mehrfach-Download/Toasts/Sakani-Feinschliff: `2.4.0`, Album-Import im Kalender: `2.4.1`).
|
||||||
|
|
||||||
|
## 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; das Portal ist auf **SakaniUI**
|
||||||
|
aufgebaut (`@sakaniui/react`). Server Components importieren Sakani über
|
||||||
|
die Client-Grenze `src/components/ui/sakani.tsx` (Card, StatCard, Badge,
|
||||||
|
Button, Checkbox, Input, FormSelect, DataTable, BarChart, EmptyState, …).
|
||||||
|
Projekt-Tokens stehen in `src/app/globals.css` (alte Tailwind-Namen wie
|
||||||
|
`bg-card`/`border-border` sind auf Sakani-Tokens gemappt). Beide Themes
|
||||||
|
(hell/dunkel) prüfen.
|
||||||
|
- Navigation lebt in `src/components/layout/app-shell.tsx` (AREAS), nicht in
|
||||||
|
den Layouts. Release-Popup: `src/components/layout/release-notes.tsx`
|
||||||
|
(RELEASE.version bei jedem Release bumpen); die pflegbare Historie liegt
|
||||||
|
in `release_notes` und wird über `ReleaseHistory`
|
||||||
|
(`src/modules/releases/release-history.tsx`, nach Version gruppiert)
|
||||||
|
unter /admin/versionen und /redaktion/neuigkeiten angezeigt; das Popup
|
||||||
|
verlinkt mit „Frühere Änderungen ansehen“ dorthin.
|
||||||
|
- Header-Logo: `/brand/logo-black.png` / `logo-white.png` (AppShell/PublicShell).
|
||||||
|
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`!).
|
||||||
|
|
||||||
|
<!-- BEGIN:nextjs-agent-rules -->
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
<!-- END:nextjs-agent-rules -->
|
||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
# AI Memory & Context für Immich-Redaktions-Plugin
|
||||||
|
|
||||||
|
Dieses Dokument dient als zentrale Wissensbasis ("Memory") für zukünftige KI-Assistenten, die an diesem Projekt weiterarbeiten.
|
||||||
|
|
||||||
|
## 1. Projekt-Überblick
|
||||||
|
Dieses Projekt ist ein Kundenportal für "Leon Tonhäuser Sportfotografie". Es verbindet sich mit einer bestehenden **Immich-Instanz** und erlaubt es, ausgewählten Redaktionen gezielt Zugriff auf spezifische Immich-Alben zu geben.
|
||||||
|
Redaktionen können Bilder durchsuchen, einen Leuchtkasten verwenden, Bilder herunterladen (mit Wasserzeichen versehen oder in Originalqualität lizenziert) und werden automatisch abgerechnet.
|
||||||
|
|
||||||
|
**Tech-Stack:**
|
||||||
|
- **Framework:** Next.js (App Router, Server Actions)
|
||||||
|
- **Datenbank:** PostgreSQL via Drizzle ORM
|
||||||
|
- **Authentifizierung:** BetterAuth
|
||||||
|
- **Styling:** TailwindCSS, UI-Komponenten via shadcn/ui
|
||||||
|
- **E-Mails:** React Email (HTML Templates mit Resend/SMTP)
|
||||||
|
- **PDF-Generierung:** pdfmake (für Rechnungen)
|
||||||
|
|
||||||
|
## 2. Immich API & Spezifische Eigenheiten (WICHTIG!)
|
||||||
|
- **Album-Zuordnung von Assets:** Die Immich-API gibt im Endpoint `getAsset` in der Response `asset.albums` oft einen **leeren Array** für ältere Bilder zurück. **Verlasse dich niemals auf `asset.albums` für die Berechtigungsprüfung!**
|
||||||
|
- *Best Practice (aktuell):* Prüfe die Album-Mitgliedschaft eines Assets über `/search/metadata` mit einem `id` + `albumIds` Filter — der Aufruf liefert das Asset nur zurück, wenn es im angegebenen Album liegt (`isAssetInAlbum` in `src/modules/usages/service.ts`). Für Bulk-Download wird pro freigegebenem Album per `searchPhotos({ albumIds: [albumId], size: 1000 })` die Asset-Liste geholt und eine `assetId → albumId`-Map gebaut (`src/app/api/lightbox/bulk-download/route.ts`).
|
||||||
|
- **WICHTIG (Stand 2026):** `GET /albums/:id` liefert auf aktuelleren Immich-Versionen **keine Assets mehr** zurück (`AlbumService.get` nutzt intern `{ withAssets: false }`, der `withoutAssets`-Query-Param existiert nicht mehr). `album.assets` ist daher immer leer — die frühere "getAlbum + iteriere album.assets"-Strategie funktioniert NICHT mehr und war die Ursache des Download-404-Bugs. `getAlbum` jetzt nur noch für Metadaten wie `albumName` verwenden.
|
||||||
|
- **Wasserzeichen & Thumbnails:** Wasserzeichen für Vorschaubilder werden auf dem Server generiert.
|
||||||
|
- Hole Bilder aus Immich mit `size=preview` (ca. 1440px Auflösung), anstatt der kleinen Thumbnails, da sie sonst beim Skalieren sehr unscharf werden.
|
||||||
|
- **WICHTIG:** Nicht alle Bilder in Immich haben zwingend eine `preview`-Größe (oft bei älteren Uploads). Der `getThumbnail`-Aufruf im `immichClient` (`src/modules/immich/client.ts`) beinhaltet daher einen Fallback-Mechanismus, der bei einem Fehler automatisch die normale `thumbnail`-Größe anfragt, um kaputte Bilder zu vermeiden.
|
||||||
|
- Aufgrund der oben erwähnten `asset.albums`-Problematik prüft die Autorisierung für das Redaktions-Thumbnail (`isGrantedEditorialAsset`) lediglich, ob die Redaktion *überhaupt* Alben zugewiesen hat. Da Asset-IDs (UUIDs) nicht erratbar sind, reicht dies aus, da Redaktionen die IDs ohnehin nur durch zugewiesene Alben erhalten können.
|
||||||
|
- Das Wasserzeichen (`logo-white.png`) wird mit `sharp` auf 60% Deckkraft als SVG-Overlay auf das Bild gerechnet (`src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts`). **WICHTIG:** Bei der SVG-Generierung für `librsvg` (verwendet von `sharp`) MÜSSEN die XML-Namespaces `xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"` sowie das Attribut `xlink:href` für eingebettete Base64-Bilder verwendet werden, da sonst Fehler auftreten (Vierecke statt des Logos).
|
||||||
|
- Um abzuschneidende Hochformate zu vermeiden, werden Thumbnails auf dem Server mit `fit: "inside"` in eine 800x800 Box gerendert und im Frontend (`globals.css`) via `object-fit: contain` angezeigt.
|
||||||
|
## 3. Datenbank-Struktur & Hard-Delete
|
||||||
|
- Die Datenbank verwendet strenges **`onDelete: "restrict"`** für alle Relationen.
|
||||||
|
- Wenn ein Redaktions-Account gelöscht wird, müssen alle abhängigen Tabellen **manuell und in korrekter Reihenfolge** in einer Transaktion gelöscht werden, um Foreign-Key-Constraints nicht zu verletzen.
|
||||||
|
- *Reihenfolge:* `downloadEvents` -> `usages` -> `lightboxItems` -> `billingReports` -> `albumAutoRules` -> `albumGrants` -> `billingAddressVersions` -> `auditEvents` -> `editorialAccounts` -> `accounts` / `sessions` / `users` (aus BetterAuth).
|
||||||
|
- 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 `<img>`-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`.
|
||||||
|
- **WICHTIG (archiver v8):** `require("archiver")` ist ab v8 **keine Funktion mehr**, sondern ein Objekt `{ Archiver, ZipArchive, TarArchive, JsonArchive }`. `archiver('zip', opts)` wirft `TypeError: archiver is not a function` → 500. Korrekt: `new archiver.ZipArchive(opts)` (gleiche `pipe`/`append`/`finalize`/`abort`-API). Dieser Fehler war lange durch den früheren 404 ("No valid assets found", leere Map) maskiert, bevor die Mitgliedschaftsprüfung repariert war.
|
||||||
|
- **E-Mail-Benachrichtigungen bei Auto-Regeln:** Die Funktion für E-Mail-Benachrichtigungen bei Auto-Regeln (`src/modules/albums/auto-rules.ts`) verschickt *gebündelte* E-Mails. Wenn mehrere Alben gleichzeitig greifen, erhält die Redaktion genau **eine** E-Mail mit einer Auflistung aller Alben, anstatt für jedes Album einzeln benachrichtigt zu werden (`emailService.sendNewAlbumNotification` akzeptiert Arrays).
|
||||||
|
- **Automatischer Auto-Regel-Sync (Stand 2026):** `autoRuleService.applyAllRules()` wendet die Keyword-Regeln **aller** aktiven, nicht archivierten Redaktionen auf die komplette Immich-Albenliste an (ein einziger `listAlbums`-Call pro Lauf; Grants mit `adminUserId: null` → Audit `actorType: "system"`). Trigger: (1) In-Prozess-Scheduler via `src/instrumentation.ts` + `src/modules/albums/auto-rule-scheduler.ts` (Intervall `AUTO_RULE_SYNC_INTERVAL_SECONDS`, Default 120s, erste Ausführung 15s nach Serverstart), (2) geschützter Endpoint `POST /api/cron/album-sync` (Bearer `CRON_SECRET`; ohne Secret antwortet er mit 404), (3) manueller Admin-Button „Regeln jetzt anwenden" (pro Redaktion, `applyRules`). Gleichzeitige Läufe werden über eine In-Memory-Mutex in `createAutoRuleService` koalesziert, damit es keine doppelten Grants/E-Mails gibt.
|
||||||
|
|
||||||
|
## 6. Admin-Bereich & Freigaben
|
||||||
|
- **Redaktions-Freigabe:** Wenn eine Redaktion den Status `pending_approval` hat, wird sie im Admin-Detail-Dashboard über die `ApproveForm` freigegeben. In diesem Schritt *muss* der Admin zwingend einen individuellen Nettopreis für die Redaktion festlegen. Ohne das Setzen des Preises bleibt die Redaktion gesperrt.
|
||||||
|
- **Admin-Alben-Tab (Stand 2026-09):** Unter `/admin/alben` gibt es eine zentrale Albumzugriffs-Übersicht: alle Immich-Alben mit den Redaktionen, die Zugriff haben (Chips mit Link + Ein-Klick-Entziehen pro Paar), plus **Bulk-Zuweisung** (mehrere Alben × mehrere Redaktionen per Checkbox, „Alle auswählen", ein Submit). Logik: `albumGrantService.listAlbumAccessOverview()` + `bulkGrantAlbums()` in `src/modules/albums/grants.ts` (Album-Existenz wird EINMAL per `listAlbums` geprüft statt `getAlbum` pro Paar; bereits aktive Paare werden übersprungen; jedes Paar committet in eigener Transaktion und schreibt ein `album_granted`-Audit-Event; ein fehlgeschlagenes Paar bricht den Rest nicht ab). Actions: `src/app/admin/alben/actions.ts` (bulkGrant/revoke, revalidiert `/admin/alben` + jede betroffene `/admin/redaktionen/[id]/alben`). Bulk-Auswahl: nur nicht-archivierte Redaktionen; archivierte erscheinen weiterhin als Chip in der Übersicht.
|
||||||
|
- **„Offen"-Beträge:** „Nicht abgerechnet" bedeutet überall im Portal `usages.billingStatus in ('open', 'reopened')` — derselbe Status-Set, den auch die Abrechnung als wählbar behandelt (`billing/queries.ts`: `selectable`); `voided` und `billed` zählen nie. Stornierte Berichte setzen Nutzungen auf `reopened` zurück, erscheinen also wieder als offen. Die Redaktionsübersicht (`/admin/redaktionen`) zeigt diesen Betrag je Redaktion als „Offen …" neben dem Nettopreis (gruppierte SUM-Query,amber wenn > 0).
|
||||||
|
- **Admin-Hinweise (Stand 2026-09):** Unter `/admin/hinweise` legt der Admin zeitlich begrenzte Meldungen für ALLE Redaktionen an (z. B. „Fotograf beim HSV-Spiel, verzögerte Antworten"). Tabelle `announcements` (message ≤ 500 Zeichen, `event_date`, `created_by_user_id` → users; Migration `0001_add_announcements`). Sichtbarkeitsfenster: ab Erstellung bis `event_date + 3 Tage` (Kalendertage, Europe/Berlin via `isoDateInBerlin` in `src/modules/announcements/service.ts`) — kein Aufräum-Job nötig, abgelaufene Zeilen bleiben unsichtbar liegen und sind im Admin löschbar. Anzeige: Banner (`AnnouncementBanner`) oben auf `/redaktion/alben` in Übersicht UND Suche. Audit: `announcement_created` / `announcement_deleted`; die Actions revalidieren `/admin/hinweise` + `/redaktion/alben`.
|
||||||
|
|
||||||
|
## 7. Auth-Härtung (Stand 2026)
|
||||||
|
- **PROD-MIGRATION-BASELINE (erledigt 2026-08-25):** Die frühere Abweichung zwischen Prod-Journal (Stand 0006) und Schema wurde per History-Squash behoben: `drizzle/` enthält nur noch `0000_baseline.sql` (aus dem aktuellen Schema generiert, Snapshot = altes 0012-Snapshot semantisch identisch, via pg_dump-Diff gegen die alte Migrationskette verifiziert). Der Journal-Eintrag der Baseline trägt bewusst das **Original-Timestamp der alten Migration 0000** (`1786299825190`) – der Drizzle-Migrator vergleicht `created_at` der Tabelle `drizzle.__drizzle_migrations` mit dem Journal-`when`, daher wird die Baseline auf jeder bestehenden DB (Prod, Dev) übersprungen und nur auf frischen DBs angewendet. Zukünftige Migrationen (`drizzle-kit generate`) greifen damit auf allen Umgebungen automatisch. Alte Migrationsdateien + Snapshots liegen in `drizzle-history/pre-squash-2026-08/` und werden NUR von den Historie-Tests genutzt (`tests/db/postgres.ts` akzeptiert dafür `migrationsDir`). Erste Ausführung von `docker compose --profile ops run --rm migrate` auf PROD ist ein No-op (Baseline skippt), danach laufen neue Migrationen normal. **Aber: Der Migrate-Container muss dafür ein aktuelles Image haben — siehe Abschnitt 8 (OPS-Profile-Build-Falle).**
|
||||||
|
- **Zwei-Faktor (TOTP) für Admins Pflicht:** Better-Auth-`twoFactor`-Plugin aktiviert; `requireAdmin` (principal.ts) wirft `TWO_FACTOR_REQUIRED`, wenn `user.two_factor_enabled` false ist. `requirePageAccess` leitet dann auf `/zwei-faktor` weiter (Wizard LIEGT AUSSERHALB von `/admin`, sonst Redirect-Loop mit dem Layout-Guard). Der Wizard nutzt den schwachen Guard `requireAdminForSetup`/`requireTwoFactorSetupPage` (`allowWithoutTwoFactor: true`). Login-Challenge: `signIn.email` antwortet mit `twoFactorRedirect: true` → LoginForm fragt TOTP-Code ab (`authClient.twoFactor.verifyTotp`). Schema der Tabelle `two_factor`: `id`, `user_id`, `secret`, `backup_codes`, `verified`, `failed_verification_count`, `locked_until` – die Feldliste MUSS exakt der Plugin-Deklaration in better-auth `plugins/two-factor/schema.mjs` entsprechen, sonst wirft der Drizzle-Adapter "field does not exist" bei jedem Two-Factor-Endpoint (Migrationen 0010–0012, historisch in `drizzle-history/pre-squash-2026-08/`).
|
||||||
|
- **Step-up für destruktive Aktionen:** `hardDeleteEditorialAction` und `resetUsageDataAction` verlangen Sessions jünger als `DESTRUCTIVE_ACTION_MAX_SESSION_AGE_SECONDS` (15 min), sonst `SESSION_STALE` → deutsche Meldung im UI. Beide Actions geben `{ok,message}` zurück statt zu werfen.
|
||||||
|
- **Passwort-Policy:** `MIN_PASSWORD_LENGTH = 12` + Common-Password-Denylist in `src/modules/security/password-policy.ts`. Gilt für Registrierung (validateRegistration) UND Passwort-Reset/-Änderung (Better-Auth-`hooks.before`-Middleware in auth.ts; wirft APIError BAD_REQUEST mit deutscher Message).
|
||||||
|
|
||||||
|
## 8. Deployment & Migrationen (Stand 2026-09) — WICHTIG, hier hatten wir lange ein Problem!
|
||||||
|
- **OPS-PROFILE-BUILD-FALLE (Root Cause des „Migrationen funktionieren nicht mehr"-Debakels):** `docker compose build` baut **nur aktive Services** — alles mit `profiles: ["ops"]` (`migrate`, `seed`, `preflight`) wird stillschweigend **übersprungen** (im Build-Log erscheint nur `✔ portal-app Built`). Und `docker compose run` baut **nie** selbst, es nutzt das bereits existierende (ggf. monatelange alte!) Image. Folge auf PROD: Der Migrate-Container lief über mehrere Deploys mit einem **prae-Squash-Image** (Journal `0000_initial.sql … 0010_two-factor.sql`), dessen alte Journal-Einträge 0006+ gegen die längst aktuelle DB-Schema-Version mit „already exists" crashten → Exit 1, scheinbar „Migrationen kaputt". Das APP-Image war dabei stets frisch gebaut — nur die OPS-Images nicht. Deshalb: **Deploy IMMER mit `docker compose --profile ops build`, nie mit bloßem `docker compose build`.**
|
||||||
|
- **DOCKERIGNORE-FALLE (2026-11-30):** `.dockerignore` ist eine Whitelist. Bis v2.2.2 waren nur `0000_baseline.sql` und `0001_add_announcements.sql` freigegeben, 0002+ fehlten im Image (Gegenprobe zeigte nur 0000/0001 + meta), obwohl das Journal sie kennt. Jetzt `!drizzle/*.sql` (zweimal: nach `!drizzle/` und nach `**/*.sql`). Neue Dateiarten, die ins Image müssen, immer dort freigeben.
|
||||||
|
- **Korrekter Deploy-Ablauf auf dem Server:**
|
||||||
|
1. `git pull --ff-only origin main`
|
||||||
|
2. `docker compose --profile ops build` (baut portal-app UND migrate/seed/preflight)
|
||||||
|
3. Gegenprobe: `docker compose run --rm --no-deps migrate ls /app/drizzle` → muss `0000_baseline.sql` + die neueste Migration enthalten
|
||||||
|
4. `docker compose --profile ops run --rm migrate; echo EXIT=$?` → muss mit `[✓] migrations applied successfully!` und `EXIT=0` enden
|
||||||
|
5. `docker compose up -d`
|
||||||
|
- **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 schalten das verknüpfte Album eines Termins unter `/redaktion/kalender` frei (ab v2.3 über `reserve`, siehe §11; 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`):** ab v2.3 entfernt (Migration 0007), ersetzt durch Vormerkungen, siehe §11.
|
||||||
|
- **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.
|
||||||
|
- **Quartalsabrechnung (2.2.1):** Abgerechnet wird immer quartalsweise. `resolvePeriod` (`src/app/admin/abrechnungen/[editorialId]/page-content.ts`) liefert nur Quartale; alte `?month=`-Links landen im passenden Quartal, ungültige Werte im aktuellen. Die Billing-APIs akzeptieren weiter `month`, das UI sendet nur `quarter`. Mail-Betreff: `Ihre Rechnung für Q4 2026`. Seed der Versionshinweise: `drizzle/0004_release_notes_2_2_1.sql` (Custom-Migration ohne Schemaänderung).
|
||||||
|
- **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).
|
||||||
|
|
||||||
|
## 11. Kategorien, Vormerken, Monatskalender, Dashboard (Stand 2026-11, v2.3)
|
||||||
|
- **Kategorien (`event_categories`):** Name (unique über `lower(name)`) + eine von 8 Sakani-Farben (`blue|green|orange|purple|teal|gold|red|neutral`, Check-Constraint; Quelle `src/modules/calendar/colors.ts`, dort auch die CSS-Variablen, mit denen Sakani die Chips malt). Admin-Seite `/admin/kalender/kategorien`; Löschen nur ohne Termine (FK `calendar_events.category_id` RESTRICT, Service prüft vorher und mappt 23503). Audit `event_category_created/deleted`.
|
||||||
|
- **Vormerken (`event_reservations`):** "Zu meinen Alben hinzufügen" = `calendarService.reserve`. Album schon da: sofort `grantAlbum(source: self_service)` + `granted_at`. Sonst bleibt die Vormerkung offen; `resolvePendingReservations` läuft im Auto-Regel-Scheduler-Tick (`auto-rule-scheduler.ts`, Default 120 s, erster Tick 15 s nach Start) und schaltet frei, sobald das Album matcht. Nur offene Vormerkungen sind zurücknehmbar (`unreserve`). Termin löschen löscht Vormerkungen mit. Audit `event_reserved`, `event_reservation_removed`, `album_self_granted` (beim Job `actorType: system`, `viaReservation: true`).
|
||||||
|
- **Status je Termin (`eventAccessState`):** granted (admin/self_service) > auto_granted (Grant mit `source: auto_rule`) > auto_rule (Stichwort der Redaktion steckt im Titel oder Albumnamen, `matchesAutoRule`, gleiche Logik wie der Job) > reserved > available.
|
||||||
|
- **Monatskalender:** `src/components/calendar/event-month.tsx` (Sakani `MonthCalendar`, `hideHeader` + eigene deutsche Kopfzeile, Wochentage per CSS `.event-month` in `globals.css`, weil Sakani nur Englisch kann; "Dec 1"-Labels am Monatsersten bleiben englisch). Klick auf Chip scrollt zum Listeneintrag `#termin-{id}` und fokussiert ihn.
|
||||||
|
- **Bildraster:** `.photo-gallery` ist ein CSS-Grid (zeilenweise), Kacheln 3:2 `object-fit: cover`, `object-position: center 30%`; die Lightbox zeigt das ganze Bild.
|
||||||
|
- **Dashboard (`/admin`):** `src/modules/dashboard/tasks.ts` (rein, getestet) + `queries.ts` (Aufgaben-Zähler), Rest aus `statsQueries.loadOverview(30)` und `calendarService.listAdminEvents()`.
|
||||||
|
- **drizzle-kit generate ohne TTY:** Fragt bei "neue Tabelle + gelöschte Tabelle" interaktiv nach Umbenennung und bricht ohne Terminal ab. Lösung: in zwei Schritten generieren (erst hinzufügen, dann löschen), so entstanden 0006 und 0007.
|
||||||
|
|
||||||
|
## 12. Mehrfach-Download, Toasts, Sakani-Feinschliff (Stand 2026-11, v2.4)
|
||||||
|
- **Toasts:** Ein `<AppToaster />` (Sakani `Toaster`, unten rechts) im Root-Layout. Helfer in `src/components/ui/feedback.tsx`: `notifyResult(result, fallback)` für Actions mit `{ ok, message }`, `useResultToast(state)` für `useActionState`, `ToastForm` für Server-Actions ohne Rückgabe (Speichern + `router.refresh()`). Bei Seiten, die vorher `window.location.reload()` nutzten (Abrechnungen), jetzt `router.refresh()`, sonst wäre der Toast weg.
|
||||||
|
- **Toasts nicht in modalen Dialogen:** Native `<dialog>.showModal()` liegt im Top-Layer; ein Toast landet dahinter. Fehler in Nutzungsdialog und ZIP-Dialog bleiben deshalb als `Alert` im Dialog; Erfolg kommt als Toast nach dem Schließen.
|
||||||
|
- **Mehrfach-Download (`DownloadLightboxForm`):** Standard ist für jedes Bild "Neue Nutzung" (gemeinsamer Zweck, optional eigener je Bild). Nur Bilder mit früheren Nutzungen bekommen einen `SegmentedControl` "Neue Nutzung / Bereits genutzt" (Voreinstellung neue Nutzung, vom Nutzer so gewählt); bei mehreren früheren Nutzungen Auswahl per `Select`, sonst die eine. "Bild auslassen" gibt es nicht mehr (Bilder werden über den Merkzettel entfernt). API-Payload unverändert.
|
||||||
|
- **Pagination:** `UrlPagination` (`src/components/ui/url-pagination.tsx`, Sakani `Pagination`) für Album, Cross-Album-Suche und Nutzungshistorie. Die Quellen liefern nur "hat nächste Seite", daher `total = page + 1` solange es weitergeht. Cursor-basierte Auslieferungsliste bleibt bei `PageLinks`.
|
||||||
|
- **Albenübersicht:** Blog-Listing-Optik (randloses 3:2-Cover, Anzahl, Titel, Beschreibung); Cover ist dekorativ (`alt=""`), der Titel im Link benennt es. Skeletons hinter Covern/Fotokacheln und in `loading.tsx`.
|
||||||
|
- **Registrierung:** `RegistrationSteps` (Sakani `Stepper`, mobil vertikal). Die Bestätigungsmail führt auf `/registrieren/bestaetigt?schritt=freigabe` (Schritt 3), das Formular auf die Seite ohne Parameter (Schritt 2).
|
||||||
|
- **Redaktionen:** `EditorialsTable` (Client, Sakani `Table` + Suche + Statusfilter; "Alle" ohne Archivierte). **Audit:** Ereignis als Auswahl der vorhandenen Typen (`selectDistinct`), deutsche Bezeichnungen (`EVENT_LABELS` in `src/app/admin/audit/page.tsx`, neue Audit-Typen dort ergänzen), Details aufklappbar.
|
||||||
|
- **Album-Import (2.4.1):** `/admin/kalender` → "Ältere Alben übernehmen". `parseAlbumEventName` (`event-albums.ts`) liest `Titel | TT.MM.JJJJ`; `listImportableAlbums` bietet nur datierte Alben ohne passenden Termin an (private Alben ohne Datum nie), `importAlbums` rechnet die Liste serverseitig neu, legt Termine mit expliziter `immich_album_id` in einer Transaktion an (max. 500), optional mit Kategorie, Audit `calendar_events_imported`. Redaktionen sehen seitdem ALLE vergangenen Termine (kein 30-Tage-Fenster mehr); die Liste "Vergangene Termine" ist einklappbar, ein Klick im Monatskalender öffnet sie.
|
||||||
|
|
||||||
+6
-6
@@ -6,13 +6,17 @@ RUN corepack enable && corepack prepare pnpm@10.34.5 --activate
|
|||||||
|
|
||||||
FROM base AS dependencies
|
FROM base AS dependencies
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=dependencies /app/node_modules ./node_modules
|
COPY --from=dependencies /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml next.config.ts next-env.d.ts tsconfig.json postcss.config.mjs drizzle.config.ts ./
|
||||||
|
COPY src ./src
|
||||||
|
COPY public ./public
|
||||||
|
COPY drizzle ./drizzle
|
||||||
|
COPY scripts ./scripts
|
||||||
|
|
||||||
# Set build-time dummy env vars required for static layout evaluation during next build
|
# Set build-time dummy env vars required for static layout evaluation during next build
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
@@ -27,10 +31,6 @@ ENV SMTP_PORT=587
|
|||||||
ENV SMTP_USER=portal@localhost
|
ENV SMTP_USER=portal@localhost
|
||||||
ENV SMTP_PASSWORD=dummy-password
|
ENV SMTP_PASSWORD=dummy-password
|
||||||
ENV SMTP_FROM=portal@localhost
|
ENV SMTP_FROM=portal@localhost
|
||||||
ENV LEGAL_IMPRINT_URL=https://example.com/impressum
|
|
||||||
ENV LEGAL_PRIVACY_URL=https://example.com/datenschutz
|
|
||||||
ENV LEGAL_TERMS_URL=https://example.com/nutzungsbedingungen
|
|
||||||
|
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
FROM node:24-alpine AS runner
|
FROM node:24-alpine AS runner
|
||||||
|
|||||||
+8
-7
@@ -12,9 +12,11 @@ x-portal-env: &portal-env
|
|||||||
SMTP_USER: ${SMTP_USER}
|
SMTP_USER: ${SMTP_USER}
|
||||||
SMTP_PASSWORD: ${SMTP_PASSWORD}
|
SMTP_PASSWORD: ${SMTP_PASSWORD}
|
||||||
SMTP_FROM: ${SMTP_FROM}
|
SMTP_FROM: ${SMTP_FROM}
|
||||||
LEGAL_IMPRINT_URL: ${LEGAL_IMPRINT_URL}
|
LEGAL_IMPRINT_URL: ${LEGAL_IMPRINT_URL:-https://leon-tonhaeuser.de/impressum}
|
||||||
LEGAL_PRIVACY_URL: ${LEGAL_PRIVACY_URL}
|
LEGAL_PRIVACY_URL: ${LEGAL_PRIVACY_URL:-https://leon-tonhaeuser.de/datenschutz}
|
||||||
LEGAL_TERMS_URL: ${LEGAL_TERMS_URL}
|
LEGAL_TERMS_URL: ${LEGAL_TERMS_URL:-https://leon-tonhaeuser.de/agb}
|
||||||
|
CRON_SECRET: ${CRON_SECRET:-}
|
||||||
|
AUTO_RULE_SYNC_INTERVAL_SECONDS: ${AUTO_RULE_SYNC_INTERVAL_SECONDS:-}
|
||||||
|
|
||||||
services:
|
services:
|
||||||
portal-db:
|
portal-db:
|
||||||
@@ -68,16 +70,15 @@ services:
|
|||||||
- portal-internal
|
- portal-internal
|
||||||
profiles: ["ops"]
|
profiles: ["ops"]
|
||||||
|
|
||||||
# One-shot: seed the first admin. Override the command to pass credentials:
|
# One-shot: create a new admin. See docs/operations.md for the stdin workflow.
|
||||||
# docker compose --profile ops run --rm seed \
|
|
||||||
# pnpm tsx scripts/create-admin.ts admin@example.de "Password!" "Name"
|
|
||||||
seed:
|
seed:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
target: builder
|
target: builder
|
||||||
environment: *portal-env
|
environment: *portal-env
|
||||||
command: ["pnpm", "tsx", "scripts/create-admin.ts"]
|
entrypoint: ["node", "--conditions=react-server", "--import", "tsx", "scripts/create-admin.ts"]
|
||||||
|
command: []
|
||||||
depends_on:
|
depends_on:
|
||||||
portal-db:
|
portal-db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
# AGB sowie Nutzungs- und Lizenzbedingungen – Arbeitsentwurf
|
||||||
|
|
||||||
|
> **Wichtiger Hinweis:** Dieser Text ist ein auf das derzeit beschriebene Geschäftsmodell zugeschnittener Arbeitsentwurf und keine Rechtsberatung. Vor Veröffentlichung sollte er von einer in Deutschland zugelassenen, auf Medien-, Urheber- und Vertragsrecht spezialisierten Rechtsanwältin oder einem entsprechenden Rechtsanwalt geprüft werden. Anbieterangaben, Zahlungsfrist, Leistungsumfang und Gerichtsstand müssen noch mit dem Impressum und der tatsächlichen Arbeitsweise abgeglichen werden.
|
||||||
|
|
||||||
|
## Vor der Implementierung ersetzen oder entscheiden
|
||||||
|
|
||||||
|
- `[VOLLSTÄNDIGER NAME/FIRMA]`, `[ANSCHRIFT]`, `[E-MAIL]` und gegebenenfalls `[UST-ID]` exakt aus dem Impressum übernehmen.
|
||||||
|
- `[ORT DES GERICHTSSTANDS]` nur einsetzen, wenn Leon dort seinen allgemeinen Gerichtsstand hat; die Klausel gilt außerdem nur im gesetzlich zulässigen Umfang.
|
||||||
|
- Prüfen, ob die Zahlungsfrist von 14 Tagen der tatsächlichen Rechnungspraxis entspricht.
|
||||||
|
- Den Versionsstand sichtbar angeben und diese Version bei Portalregistrierung protokollieren.
|
||||||
|
- Auf der Website vor Vertragsschluss deutlich auf die AGB verlinken und eine zumutbare Speichermöglichkeit anbieten.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Allgemeine Geschäftsbedingungen sowie Nutzungs- und Lizenzbedingungen
|
||||||
|
|
||||||
|
**Stand: 11. August 2026**
|
||||||
|
|
||||||
|
## 1. Anbieter und Geltungsbereich
|
||||||
|
|
||||||
|
1. Anbieter der fotografischen Leistungen und Bildlizenzen ist `[VOLLSTÄNDIGER NAME/FIRMA]`, `[ANSCHRIFT]`, E-Mail: `[E-MAIL]` – nachfolgend „Fotograf“ genannt.
|
||||||
|
2. Diese Bedingungen gelten für Verträge über Fotoaufträge, die Bereitstellung von Fotografien sowie die Einräumung von Nutzungsrechten, insbesondere über die Website und das Redaktionsportal des Fotografen.
|
||||||
|
3. Das Angebot richtet sich ausschließlich an Unternehmer im Sinne des § 14 BGB, juristische Personen des öffentlichen Rechts und öffentlich-rechtliche Sondervermögen. Verträge mit Verbrauchern werden auf Grundlage dieser Bedingungen nicht geschlossen.
|
||||||
|
4. Abweichende Bedingungen des Auftraggebers oder Lizenznehmers – nachfolgend gemeinsam „Kunde“ genannt – gelten nur, wenn der Fotograf ihrer Geltung ausdrücklich in Textform zugestimmt hat.
|
||||||
|
5. Individuelle Vereinbarungen, Angebote und Lizenzangaben gehen diesen Bedingungen vor.
|
||||||
|
|
||||||
|
## 2. Vertragsschluss und Kommunikation
|
||||||
|
|
||||||
|
1. Darstellungen auf der Website und im Redaktionsportal sind noch kein verbindliches Angebot, sofern sie nicht ausdrücklich als solches bezeichnet sind.
|
||||||
|
2. Ein Vertrag über einen Fotoauftrag kommt durch Annahme eines Angebots, eine Auftragsbestätigung in Textform oder durch Beginn der vereinbarten Leistung zustande.
|
||||||
|
3. Beim Redaktionsportal gibt der Kunde mit der verbindlichen Auswahl eines Fotos, des Nutzungszwecks und der Downloadart eine Bestellung der angezeigten Lizenz ab. Der Vertrag kommt mit der Bereitstellung des Downloads zustande.
|
||||||
|
4. Der Kunde muss Angaben zu Medium, Beitrag, Verwendungszweck, Umfang und gegebenenfalls Kampagne vollständig und wahrheitsgemäß machen. Unklare oder nachträglich geänderte Nutzungen sind vorab mit dem Fotografen abzustimmen.
|
||||||
|
|
||||||
|
## 3. Fotoaufträge
|
||||||
|
|
||||||
|
1. Inhalt, Termin, Ort, Umfang, Honorar und Lieferformat eines Fotoauftrags ergeben sich aus dem jeweiligen Angebot oder der Auftragsbestätigung.
|
||||||
|
2. Die gestalterische und technische Umsetzung liegt im künstlerischen Ermessen des Fotografen, soweit keine konkreten Vorgaben in Textform vereinbart wurden. Ein Anspruch auf einen bestimmten Stil, einzelne Motive oder eine bestimmte Zahl gelungener Aufnahmen besteht nur, wenn dies ausdrücklich vereinbart wurde.
|
||||||
|
3. Termine und Lieferfristen sind nur verbindlich, wenn sie ausdrücklich als verbindlich bestätigt wurden. Verzögerungen aufgrund höherer Gewalt oder anderer vom Fotografen nicht zu vertretender Umstände verlängern die Leistungsfrist angemessen.
|
||||||
|
4. Sagt der Kunde einen bestätigten Termin ab oder verschiebt ihn, kann der Fotograf die bis dahin erbrachten Leistungen und nachweislich angefallenen, nicht mehr vermeidbaren Aufwendungen abrechnen. Weitergehende gesetzliche Ansprüche bleiben unberührt; ersparte Aufwendungen werden angerechnet.
|
||||||
|
5. Rohdateien, unbearbeitete Aufnahmen und offene Bearbeitungsdateien gehören nicht zum Lieferumfang, sofern dies nicht ausdrücklich vereinbart wurde.
|
||||||
|
|
||||||
|
## 4. Redaktionsportal und Benutzerkonto
|
||||||
|
|
||||||
|
1. Der Zugang zum Redaktionsportal bedarf der Registrierung, E-Mail-Bestätigung und Freigabe durch den Fotografen. Ein Anspruch auf Freigabe oder dauerhafte Bereitstellung besteht nicht.
|
||||||
|
2. Ein Redaktionskonto darf innerhalb der freigeschalteten Redaktion gemeinsam genutzt werden. Der Kunde stellt sicher, dass Zugangsdaten nur befugten Mitarbeitenden zugänglich sind, sicher verwahrt und bei Verdacht auf Missbrauch unverzüglich geändert werden.
|
||||||
|
3. Sämtliche über das Redaktionskonto vorgenommenen lizenz- und abrechnungsrelevanten Handlungen werden der freigeschalteten Redaktion zugerechnet, soweit der Kunde keinen vom Fotografen zu vertretenden Missbrauch nachweist.
|
||||||
|
4. Der Fotograf darf Zugänge bei Sicherheitsrisiken, Zahlungsverzug, vertragswidriger Nutzung oder Wegfall der Geschäftsbeziehung vorübergehend sperren. Bereits wirksam eingeräumte und bezahlte Nutzungsrechte bleiben hiervon unberührt.
|
||||||
|
5. Das Portal wird mit angemessener Sorgfalt betrieben. Wartung, Sicherheitsmaßnahmen und Störungen bei technischen Dienstleistern können die Verfügbarkeit zeitweise einschränken. Eine ununterbrochene Verfügbarkeit wird nicht geschuldet.
|
||||||
|
|
||||||
|
## 5. Urheberrecht und Umfang der Bildlizenz
|
||||||
|
|
||||||
|
1. Sämtliche Fotografien bleiben urheber- beziehungsweise leistungsschutzrechtlich geschützt. Eigentum an Dateien oder Datenträgern und Nutzungsrechte sind voneinander zu unterscheiden.
|
||||||
|
2. Soweit nichts anderes ausdrücklich vereinbart ist, erhält der Kunde ein einfaches, nicht ausschließliches und nicht übertragbares Nutzungsrecht ausschließlich für den bei Bestellung angegebenen Zweck. Inhaltlicher, zeitlicher, räumlicher und medialer Umfang richten sich nach dem Angebot, der Portalangabe und dem erkennbaren Vertragszweck.
|
||||||
|
3. Eine Nutzung für einen neuen Beitrag, ein neues Projekt, eine neue Ausgabe, eine neue Kampagne oder einen sonstigen neuen Zweck ist eine neue lizenzpflichtige Nutzung. Sie muss im Portal als „neuer Zweck“ ausgewählt oder gesondert vereinbart werden.
|
||||||
|
4. Ein erneuter Download für denselben bereits lizenzierten Zweck löst nur dann keine zusätzliche nutzungsabhängige Vergütung aus, wenn das Portal ihn ausdrücklich als kostenfreie Wiederholung bestätigt. Ein neuer Nutzungszweck bleibt auch bei identischer Datei gesondert vergütungspflichtig.
|
||||||
|
5. Online- und Social-Media-Nutzungen, Werbung, Eigenwerbung, Presseverteilung, Syndikation, Archivdatenbanken, Print, Bewegtbild, Merchandising und sonstige Verwertungsarten sind nur umfasst, soweit sie vom vereinbarten Zweck oder Lizenzumfang erfasst sind.
|
||||||
|
6. Ausschließliche Nutzungsrechte, Sperrfristen und Branchen- oder Gebietsexklusivität bedürfen einer ausdrücklichen Vereinbarung in Textform.
|
||||||
|
|
||||||
|
## 6. Unzulässige Nutzungen und Bearbeitungen
|
||||||
|
|
||||||
|
1. Ohne vorherige Zustimmung in Textform ist es insbesondere unzulässig,
|
||||||
|
- Fotografien weiterzuverkaufen, unterzulizenzieren oder Dritten zur eigenständigen Nutzung zu überlassen,
|
||||||
|
- Fotografien als Logo, Marke, Produktmotiv oder für Merchandising zu verwenden,
|
||||||
|
- Fotografien in Bilddatenbanken, Stockplattformen, Datensätzen oder vergleichbaren Sammlungen bereitzustellen,
|
||||||
|
- Fotografien zum Training, zur Feinabstimmung, Bewertung oder sonstigen Entwicklung generativer oder analytischer KI-Systeme zu verwenden,
|
||||||
|
- den Aussagegehalt zu verfälschen, Personen oder Gegenstände sinnverändernd hinzuzufügen oder zu entfernen oder irreführende Montagen herzustellen.
|
||||||
|
2. Zulässig sind technisch erforderliche Anpassungen wie maßvolle Ausschnitte, Skalierung sowie übliche Helligkeits- und Farbkorrekturen, soweit Aussage, Urheberpersönlichkeitsrecht und berechtigte Interessen abgebildeter Personen nicht beeinträchtigt werden.
|
||||||
|
3. Bei redaktioneller Nutzung darf das Foto nicht in einen rechtswidrigen, herabwürdigenden, diskriminierenden oder irreführenden Zusammenhang gestellt werden.
|
||||||
|
|
||||||
|
## 7. Urhebervermerk und Metadaten
|
||||||
|
|
||||||
|
1. Soweit nicht ausdrücklich anders vereinbart oder im konkreten Medium branchenüblich ausgeschlossen, ist bei jeder Veröffentlichung gut lesbar und dem Bild zuordenbar der Urhebervermerk **„© Leon Tonhäuser“** anzubringen.
|
||||||
|
2. Vorhandene Urheber-, Rechte- und Herkunftsangaben in Datei-Metadaten dürfen nicht entfernt oder verfälscht werden, soweit dies nicht technisch unvermeidbar ist.
|
||||||
|
3. Der Kunde informiert den Fotografen auf Anfrage über Art und Umfang der erfolgten Nutzung und stellt nach Möglichkeit ein Belegexemplar oder einen Veröffentlichungslink bereit.
|
||||||
|
|
||||||
|
## 8. Rechte abgebildeter Personen und redaktioneller Kontext
|
||||||
|
|
||||||
|
1. Die Einräumung urheberrechtlicher Nutzungsrechte bedeutet nicht automatisch, dass jede denkbare Veröffentlichung persönlichkeits-, presse-, marken-, haus- oder datenschutzrechtlich zulässig ist.
|
||||||
|
2. Der Fotograf informiert den Kunden über ihm bekannte, konkret vereinbarte Model-, Property- oder Veranstaltungsfreigaben und bekannte Nutzungsbeschränkungen. Eine weitergehende Freigabe gilt nur, wenn sie ausdrücklich bestätigt wurde.
|
||||||
|
3. Der Kunde prüft eigenverantwortlich, ob die konkrete Nutzung, Bildunterschrift, Berichterstattung und Einbettung in ihrem jeweiligen Kontext zulässig ist. Das gilt insbesondere bei Werbung, sensiblen Themen, Montagen und Nutzungen außerhalb aktueller redaktioneller Berichterstattung.
|
||||||
|
|
||||||
|
## 9. Vergütung, Nutzungsnachweis und Rechnung
|
||||||
|
|
||||||
|
1. Es gelten die im Angebot, in der Preisliste oder im Redaktionsportal für die jeweilige Redaktion angezeigten beziehungsweise vereinbarten Preise. Alle Preise verstehen sich netto zuzüglich der gesetzlich geschuldeten Umsatzsteuer.
|
||||||
|
2. Nutzungen können einzeln oder aufgrund einer individuell vereinbarten Monats- oder Quartalspauschale abgerechnet werden. Umfang, Preis und gegebenenfalls enthaltene Nutzungseinheiten einer Pauschale ergeben sich aus der Individualvereinbarung.
|
||||||
|
3. Der im Portal oder per E-Mail bereitgestellte Nutzungsnachweis dokumentiert Downloads, Nutzungszwecke und Beträge. **Er ist keine Rechnung. Die Rechnung wird separat übermittelt.** Bei Widersprüchen hat die separate Rechnung Vorrang; offensichtliche Fehler im Nutzungsnachweis sind dem Fotografen unverzüglich mitzuteilen.
|
||||||
|
4. Rechnungen sind innerhalb von 14 Kalendertagen ab Zugang ohne Abzug zahlbar, sofern auf der Rechnung keine andere Frist angegeben ist.
|
||||||
|
5. Bei Zahlungsverzug gelten die gesetzlichen Vorschriften. Der Fotograf kann weitere Downloads bis zum Ausgleich fälliger Forderungen sperren.
|
||||||
|
|
||||||
|
## 10. Mitwirkung, Archivierung und Datensicherung
|
||||||
|
|
||||||
|
1. Der Kunde stellt benötigte Informationen, Freigaben, Ansprechpartner und Zutrittsberechtigungen rechtzeitig zur Verfügung. Mehraufwand und Verzögerungen aufgrund verspäteter oder unzutreffender Angaben können gesondert berechnet werden, soweit der Kunde sie zu vertreten hat.
|
||||||
|
2. Der Kunde ist für die eigene, rechtmäßige Archivierung ausgelieferter Dateien verantwortlich. Der Fotograf schuldet keine zeitlich unbegrenzte Aufbewahrung oder erneute Bereitstellung.
|
||||||
|
3. Beschreibungen, Dateinamen, Albumzuordnung und sonstige Metadaten dienen der Recherche. Sie ersetzen keine eigene redaktionelle Prüfung und werden nicht als vollständig oder fehlerfrei garantiert.
|
||||||
|
|
||||||
|
## 11. Mängel und Beanstandungen
|
||||||
|
|
||||||
|
1. Technisch fehlerhafte oder unvollständige Lieferungen sind nach Entdeckung nachvollziehbar zu melden. Der Fotograf erhält zunächst Gelegenheit zur Nacherfüllung, soweit diese möglich und zumutbar ist.
|
||||||
|
2. Subjektive gestalterische Abweichungen begründen keinen Mangel, wenn sie sich innerhalb des vereinbarten Gestaltungsspielraums bewegen.
|
||||||
|
3. Gesetzliche Untersuchungs- und Rügepflichten, insbesondere nach § 377 HGB, bleiben unberührt.
|
||||||
|
|
||||||
|
## 12. Haftung
|
||||||
|
|
||||||
|
1. Der Fotograf haftet unbeschränkt für Vorsatz und grobe Fahrlässigkeit, für Schäden aus der Verletzung von Leben, Körper oder Gesundheit, nach dem Produkthaftungsgesetz sowie im Umfang ausdrücklich übernommener Garantien.
|
||||||
|
2. Bei leicht fahrlässiger Verletzung einer wesentlichen Vertragspflicht, deren Erfüllung die ordnungsgemäße Durchführung des Vertrags erst ermöglicht und auf deren Einhaltung der Kunde regelmäßig vertrauen darf, ist die Haftung auf den vertragstypischen, bei Vertragsschluss vorhersehbaren Schaden begrenzt.
|
||||||
|
3. Im Übrigen ist die Haftung für leichte Fahrlässigkeit ausgeschlossen. Die vorstehenden Beschränkungen gelten entsprechend zugunsten der Beschäftigten und Erfüllungsgehilfen des Fotografen.
|
||||||
|
4. Für vom Kunden bereitgestellte Inhalte, Weisungen, Bildunterschriften und Nutzungskontexte sowie für Nutzungen außerhalb der eingeräumten Lizenz ist der Kunde verantwortlich. Der Kunde stellt den Fotografen von berechtigten Ansprüchen Dritter frei, soweit diese auf einer vom Kunden zu vertretenden Pflichtverletzung beruhen; die angemessenen Kosten der Rechtsverteidigung sind umfasst. Der Fotograf informiert den Kunden unverzüglich und stimmt die Rechtsverteidigung angemessen mit ihm ab.
|
||||||
|
|
||||||
|
## 13. Vertragsdauer und Beendigung des Portalzugangs
|
||||||
|
|
||||||
|
1. Der Portalnutzungsvertrag läuft auf unbestimmte Zeit und kann von beiden Seiten mit einer Frist von 14 Tagen in Textform gekündigt werden, sofern keine individuelle Mindestlaufzeit vereinbart wurde.
|
||||||
|
2. Das Recht zur außerordentlichen Kündigung aus wichtigem Grund bleibt unberührt. Ein wichtiger Grund liegt insbesondere bei schwerwiegender oder wiederholter vertragswidriger Bildnutzung, Manipulation von Abrechnungsdaten oder erheblichem Zahlungsverzug vor.
|
||||||
|
3. Mit Vertragsende endet der Zugang zum Portal. Ordnungsgemäß erworbene und bezahlte Nutzungsrechte bleiben im vereinbarten Umfang bestehen; offene Zahlungs-, Auskunfts- und Unterlassungsansprüche bleiben unberührt.
|
||||||
|
|
||||||
|
## 14. Datenschutz
|
||||||
|
|
||||||
|
Informationen zur Verarbeitung personenbezogener Daten stehen in der gesonderten Datenschutzerklärung unter `[URL ZUR DATENSCHUTZERKLÄRUNG]`. Das Impressum ist unter `[URL ZUM IMPRESSUM]` erreichbar.
|
||||||
|
|
||||||
|
## 15. Schlussbestimmungen
|
||||||
|
|
||||||
|
1. Es gilt das Recht der Bundesrepublik Deutschland unter Ausschluss des UN-Kaufrechts.
|
||||||
|
2. Ist der Kunde Kaufmann, juristische Person des öffentlichen Rechts oder öffentlich-rechtliches Sondervermögen, ist – soweit gesetzlich zulässig – ausschließlicher Gerichtsstand `[ORT DES GERICHTSSTANDS]`. Gesetzliche ausschließliche Gerichtsstände bleiben unberührt.
|
||||||
|
3. Sollten einzelne Bestimmungen unwirksam sein oder werden, bleibt die Wirksamkeit der übrigen Bestimmungen unberührt. An die Stelle der unwirksamen Bestimmung treten die gesetzlichen Vorschriften.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Hinweise für die KI im Website-Projekt
|
||||||
|
|
||||||
|
1. Den Text als eigene öffentliche Seite „AGB & Lizenzbedingungen“ ausgeben, nicht mit Impressum oder Datenschutz vermischen.
|
||||||
|
2. Permanente URL empfehlen: `/agb` oder `/nutzungsbedingungen`.
|
||||||
|
3. Im Footer sowie bei Kontakt-/Anfrageformularen verlinken. Im Redaktionsportal muss `LEGAL_TERMS_URL` auf genau diese öffentliche Seite zeigen.
|
||||||
|
4. Bei einer verbindlichen Portalregistrierung eine nicht vorangekreuzte Checkbox mit Link und protokolliertem Versionsstand verwenden.
|
||||||
|
5. Inhalt semantisch als `article` mit einer `h1` und fortlaufenden `h2`-Überschriften auszeichnen; druckfreundliche Darstellung vorsehen.
|
||||||
|
6. Anbieterangaben und URLs aus dem bestehenden Impressum/Datenschutz übernehmen, nicht erraten.
|
||||||
|
|
||||||
|
## Verwendete amtliche Grundlagen
|
||||||
|
|
||||||
|
- §§ 305, 307 und 310 BGB: Einbeziehung und Inhaltskontrolle Allgemeiner Geschäftsbedingungen, auch im B2B-Bereich.
|
||||||
|
- §§ 13, 15, 19a, 31 und 72 UrhG: Urheberbezeichnung, Verwertungsrechte, öffentliche Zugänglichmachung, Nutzungsrechte und Schutz von Lichtbildern.
|
||||||
|
- §§ 22 und 23 KunstUrhG: Recht am eigenen Bild und gesetzliche Ausnahmen.
|
||||||
|
- § 38 ZPO: Gerichtsstandsvereinbarungen insbesondere zwischen Kaufleuten.
|
||||||
|
- § 5 DDG: gesonderte Anbieterkennzeichnung im Impressum.
|
||||||
+61
-6
@@ -31,9 +31,11 @@ All production configuration is provided via environment variables (e.g. `.env`
|
|||||||
| `SMTP_USER` | SMTP username | `portal@example.de` |
|
| `SMTP_USER` | SMTP username | `portal@example.de` |
|
||||||
| `SMTP_PASSWORD` | SMTP password | Confidential |
|
| `SMTP_PASSWORD` | SMTP password | Confidential |
|
||||||
| `SMTP_FROM` | Default From email address | `Leon Tonhäuser Presse <portal@example.de>` |
|
| `SMTP_FROM` | Default From email address | `Leon Tonhäuser Presse <portal@example.de>` |
|
||||||
| `LEGAL_IMPRINT_URL` | Public Impressum link | `https://example.de/impressum` |
|
| `LEGAL_IMPRINT_URL` | Public Impressum link | `https://leon-tonhaeuser.de/impressum` |
|
||||||
| `LEGAL_PRIVACY_URL` | Public Datenschutz link | `https://example.de/datenschutz` |
|
| `LEGAL_PRIVACY_URL` | Public Datenschutz link | `https://leon-tonhaeuser.de/datenschutz` |
|
||||||
| `LEGAL_TERMS_URL` | Public Nutzungsbedingungen link | `https://example.de/terms` |
|
| `LEGAL_TERMS_URL` | Public Nutzungsbedingungen link | `https://leon-tonhaeuser.de/agb` |
|
||||||
|
| `AUTO_RULE_SYNC_INTERVAL_SECONDS` | Interval of the album auto-rule sync in seconds (min 30) | `120` (default) |
|
||||||
|
| `CRON_SECRET` | Optional bearer token for `POST /api/cron/album-sync`; unset disables the endpoint | `openssl rand -hex 32` |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -52,6 +54,7 @@ When placing Nginx or Traefik in front of the portal:
|
|||||||
```
|
```
|
||||||
2. **Body Size Limits**: Unused (portal handles photo downloads only, not uploads).
|
2. **Body Size Limits**: Unused (portal handles photo downloads only, not uploads).
|
||||||
3. **Security Headers**: Managed by Next.js (`next.config.ts`), including restrictive CSP, frame denial (`DENY`), and strict Referrer-Policy.
|
3. **Security Headers**: Managed by Next.js (`next.config.ts`), including restrictive CSP, frame denial (`DENY`), and strict Referrer-Policy.
|
||||||
|
4. **Client-IP headers**: The portal accepts the proxy-appended final hop of `X-Forwarded-For` (the normal Zoraxy/Go reverse-proxy path) and alternatively `X-Real-IP` for abuse protection. Keep the application port unreachable from the public network so clients cannot bypass the trusted proxy. If a proxy sets `X-Real-IP`, it must overwrite rather than pass through a public client value.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -78,11 +81,31 @@ the `ops` compose profile and do not start with `docker compose up`.
|
|||||||
```bash
|
```bash
|
||||||
docker compose --profile ops run --rm migrate
|
docker compose --profile ops run --rm migrate
|
||||||
```
|
```
|
||||||
- **Seed the first admin** (override the command to pass credentials):
|
|
||||||
|
Migrations are safe to run on every environment, including production. The
|
||||||
|
history was squashed into a single baseline (`drizzle/0000_baseline.sql`) in
|
||||||
|
August 2026: the baseline carries the timestamp of the original first
|
||||||
|
migration, so `drizzle-kit migrate` skips it on any database that already has
|
||||||
|
tables (its recorded journal entry is newer) and applies it only on fresh
|
||||||
|
databases. New migrations generated with `pnpm exec drizzle-kit generate` are
|
||||||
|
picked up automatically on all environments — no manual psql steps required
|
||||||
|
anymore. Historical (pre-squash) migration files live in
|
||||||
|
`drizzle-history/pre-squash-2026-08/` and are referenced by integration tests
|
||||||
|
only; do not point `drizzle.config.ts` at that folder.
|
||||||
|
- **Seed a new admin** after migrations. In Bash, enter a unique password of
|
||||||
|
at least 12 characters at the hidden prompt. Compose forwards it on standard
|
||||||
|
input. The email and display name are the two arguments.
|
||||||
```bash
|
```bash
|
||||||
docker compose --profile ops run --rm seed \
|
(
|
||||||
pnpm tsx scripts/create-admin.ts admin@example.de "AdminPassword!" "Name"
|
set +x
|
||||||
|
read -rs -p 'Admin password: ' seed_password || exit 1
|
||||||
|
printf '\n' >&2
|
||||||
|
printf '%s\n' "$seed_password" | docker compose --profile ops run --rm -i -T seed \
|
||||||
|
admin@example.de "Portal Admin"
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
The seed creates a verified account. An existing email or a failed insert
|
||||||
|
exits with an error. After the first sign-in, complete the TOTP setup.
|
||||||
- **Smoke-test env + connectivity** (DB, Better Auth, SMTP, Immich):
|
- **Smoke-test env + connectivity** (DB, Better Auth, SMTP, Immich):
|
||||||
```bash
|
```bash
|
||||||
docker compose --profile ops run --rm preflight
|
docker compose --profile ops run --rm preflight
|
||||||
@@ -125,3 +148,35 @@ docker compose start portal-app
|
|||||||
- `GET /api/health/live` -> 200 OK (Process liveness).
|
- `GET /api/health/live` -> 200 OK (Process liveness).
|
||||||
- `GET /api/health/ready` -> 200 OK (Database & Immich connectivity).
|
- `GET /api/health/ready` -> 200 OK (Database & Immich connectivity).
|
||||||
- **Audit Log Inspection**: Accessible in portal UI under `/admin/audit` (Admin role required).
|
- **Audit Log Inspection**: Accessible in portal UI under `/admin/audit` (Admin role required).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. Rolling Out a New App Version (e.g. the Sakani UI, v2.0)
|
||||||
|
|
||||||
|
UI releases such as v2.0 change no database schema; the app keeps using the
|
||||||
|
existing `portal-db`, so all editorials, grants, usages, billing reports and
|
||||||
|
announcements carry over unchanged.
|
||||||
|
|
||||||
|
1. Back up the database (see §6):
|
||||||
|
```bash
|
||||||
|
scripts/backup-db.sh /var/backups/immich-portal
|
||||||
|
```
|
||||||
|
2. Note the running commit for a rollback: `git rev-parse HEAD`.
|
||||||
|
3. Update and rebuild:
|
||||||
|
```bash
|
||||||
|
git pull
|
||||||
|
docker compose build portal-app
|
||||||
|
docker compose --profile ops run --rm migrate # no-op when there are no new migrations
|
||||||
|
docker compose up -d portal-app
|
||||||
|
```
|
||||||
|
4. Verify: `GET /api/health/ready` → 200, then log in as admin and as an
|
||||||
|
editorial account.
|
||||||
|
|
||||||
|
**Rollback**: check out the noted commit (`git checkout <commit>`), then
|
||||||
|
`docker compose build portal-app && docker compose up -d portal-app`, and
|
||||||
|
return to `main` with `git checkout main` afterwards. A UI-only release needs no
|
||||||
|
database restore.
|
||||||
|
|
||||||
|
**Release notes popup**: users see "Was ist neu?" once per version after
|
||||||
|
signing in. For the next release, bump `RELEASE.version` and replace the notes
|
||||||
|
in `src/components/layout/release-notes.tsx`.
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
# Mobile Menu Active Contrast Implementation Plan
|
||||||
|
|
||||||
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||||
|
|
||||||
|
**Goal:** Make the active mobile portal navigation item readable in both light and dark themes.
|
||||||
|
|
||||||
|
**Architecture:** Keep the existing theme tokens and navigation logic. Add one unlayered semantic CSS class whose `var(--ink)` background and `var(--paper)` foreground outrank the global inherited anchor color, and apply it only to the active mobile link.
|
||||||
|
|
||||||
|
**Tech Stack:** Next.js 16, React 19, Tailwind CSS 4, Vitest, Testing Library
|
||||||
|
|
||||||
|
## Global Constraints
|
||||||
|
|
||||||
|
- Light mode must render the active item with white text on a dark surface.
|
||||||
|
- Dark mode must render the active item with black text on a light surface.
|
||||||
|
- Inactive links, desktop navigation, theme tokens, spacing, motion, and routing must remain unchanged.
|
||||||
|
- Production code must follow a witnessed RED/GREEN TDD cycle.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Task 1: Active Mobile Navigation Contrast
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/components/layout/mobile-portal-menu.test.tsx`
|
||||||
|
- Modify: `src/components/layout/mobile-portal-menu.tsx`
|
||||||
|
- Modify: `src/app/globals.css`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: existing `MobilePortalMenu` props and the `--ink` / `--paper` theme tokens
|
||||||
|
- Produces: the CSS class `mobile-portal-menu-active` on the single active navigation link
|
||||||
|
|
||||||
|
- [ ] **Step 1: Write the failing regression test**
|
||||||
|
|
||||||
|
Extend the first component test after opening the menu:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const activeLink = screen.getByRole("link", { name: "Redaktionen" });
|
||||||
|
const inactiveLink = screen.getByRole("link", { name: "Dashboard" });
|
||||||
|
|
||||||
|
expect(activeLink.getAttribute("class")).toContain("mobile-portal-menu-active");
|
||||||
|
expect(inactiveLink.getAttribute("class")).not.toContain("mobile-portal-menu-active");
|
||||||
|
```
|
||||||
|
|
||||||
|
This test catches removal or accidental application of the semantic inverse-color class.
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the focused test and verify RED**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/components/layout/mobile-portal-menu.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: the active-link assertion fails because the class is not yet present; the test must not fail from a render or selector error.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Implement the minimal component and CSS change**
|
||||||
|
|
||||||
|
In the active branch of `mobile-portal-menu.tsx`, replace the inverse Tailwind color utilities with the semantic class while preserving layout classes:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
"mobile-portal-menu-active flex min-h-11 items-center rounded-lg px-3 font-semibold"
|
||||||
|
```
|
||||||
|
|
||||||
|
In `globals.css`, directly after the existing mobile menu panel rule, add:
|
||||||
|
|
||||||
|
```css
|
||||||
|
.mobile-portal-menu-active {
|
||||||
|
background: var(--ink);
|
||||||
|
color: var(--paper);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 4: Run the focused test and verify GREEN**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/components/layout/mobile-portal-menu.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: all mobile-menu tests pass with no warnings.
|
||||||
|
|
||||||
|
- [ ] **Step 5: Run full deterministic verification**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src
|
||||||
|
./node_modules/.bin/tsc --noEmit
|
||||||
|
./node_modules/.bin/eslint .
|
||||||
|
./node_modules/.bin/drizzle-kit check
|
||||||
|
git diff --check
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: every command exits with status 0.
|
||||||
|
|
||||||
|
- [ ] **Step 6: Run the production build**
|
||||||
|
|
||||||
|
Run `./node_modules/.bin/next build --webpack` with the documented non-secret build-time environment values.
|
||||||
|
|
||||||
|
Expected: the optimized production build completes with exit status 0.
|
||||||
|
|
||||||
|
- [ ] **Step 7: Commit the implementation**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add src/components/layout/mobile-portal-menu.test.tsx src/components/layout/mobile-portal-menu.tsx src/app/globals.css
|
||||||
|
git commit -m "fix: restore mobile menu active contrast"
|
||||||
|
```
|
||||||
@@ -0,0 +1,405 @@
|
|||||||
|
# Mobile Portal Navigation Implementation Plan
|
||||||
|
|
||||||
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||||
|
|
||||||
|
**Goal:** Add an accessible mobile-only dropdown that exposes every role-specific portal destination, theme control and sign-out action while leaving desktop navigation unchanged.
|
||||||
|
|
||||||
|
**Architecture:** A focused client component owns the dropdown interaction and receives the existing `NavItem[]` from the server-rendered `PortalShell`. `PortalShell` renders this component only for mobile layouts and keeps its existing desktop controls behind the `sm` breakpoint, avoiding duplicated route catalogues or new dependencies.
|
||||||
|
|
||||||
|
**Tech Stack:** Next.js 16 App Router, React 19, TypeScript, Tailwind CSS 4, Lucide React, Vitest, Testing Library, jsdom.
|
||||||
|
|
||||||
|
## Global Constraints
|
||||||
|
|
||||||
|
- The mobile menu is visible only below the Tailwind `sm` breakpoint.
|
||||||
|
- The existing desktop navigation, route names, authorization and sign-out behavior remain unchanged.
|
||||||
|
- The component consumes the existing role-specific `nav: NavItem[]`; no second navigation catalogue is allowed.
|
||||||
|
- The menu closes on link activation, Escape and outside pointer interaction.
|
||||||
|
- Escape returns focus to the trigger.
|
||||||
|
- The active route uses `aria-current="page"` and a high-contrast visual state.
|
||||||
|
- Touch targets are at least 44 pixels high.
|
||||||
|
- No new runtime dependency or animation framework may be added.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Task 1: Accessible mobile dropdown behavior
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Create: `src/components/layout/mobile-portal-menu.tsx`
|
||||||
|
- Create: `src/components/layout/mobile-portal-menu.test.tsx`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: `NavItem` from `@/components/layout/portal-shell`, `ThemeToggle`, `LogoutButton`, and `usePathname()`.
|
||||||
|
- Produces: `MobilePortalMenu({ nav, sectionLabel }: { nav: NavItem[]; sectionLabel: string }): JSX.Element`.
|
||||||
|
|
||||||
|
- [ ] **Step 1: Write the failing interaction tests**
|
||||||
|
|
||||||
|
Create `src/components/layout/mobile-portal-menu.test.tsx` with jsdom, a controlled `usePathname()` mock, and real child controls:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// @vitest-environment jsdom
|
||||||
|
|
||||||
|
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||||
|
import { afterEach, beforeEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
const { usePathname } = vi.hoisted(() => ({
|
||||||
|
usePathname: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("next/navigation", () => ({ usePathname }));
|
||||||
|
|
||||||
|
import { MobilePortalMenu } from "./mobile-portal-menu";
|
||||||
|
|
||||||
|
const nav = [
|
||||||
|
{ href: "/admin", label: "Dashboard" },
|
||||||
|
{ href: "/admin/redaktionen", label: "Redaktionen" },
|
||||||
|
{ href: "/admin/abrechnungen", label: "Abrechnungen" },
|
||||||
|
{ href: "/admin/audit", label: "Audit" },
|
||||||
|
];
|
||||||
|
|
||||||
|
beforeEach(() => usePathname.mockReturnValue("/admin/redaktionen/abc"));
|
||||||
|
afterEach(cleanup);
|
||||||
|
|
||||||
|
test("opens every mobile portal action and marks the most specific active route", () => {
|
||||||
|
render(<MobilePortalMenu nav={nav} sectionLabel="Administration" />);
|
||||||
|
|
||||||
|
const trigger = screen.getByRole("button", { name: /menü öffnen/i });
|
||||||
|
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
||||||
|
expect(screen.queryByRole("navigation", { name: /mobile navigation/i })).toBeNull();
|
||||||
|
|
||||||
|
fireEvent.click(trigger);
|
||||||
|
|
||||||
|
expect(trigger.getAttribute("aria-expanded")).toBe("true");
|
||||||
|
expect(screen.getByRole("link", { name: "Dashboard" })).toBeTruthy();
|
||||||
|
expect(screen.getByRole("link", { name: "Redaktionen" }).getAttribute("aria-current")).toBe("page");
|
||||||
|
expect(screen.getByRole("link", { name: "Abrechnungen" })).toBeTruthy();
|
||||||
|
expect(screen.getByRole("link", { name: "Audit" })).toBeTruthy();
|
||||||
|
expect(screen.getByRole("button", { name: /design umschalten/i })).toBeTruthy();
|
||||||
|
expect(screen.getByRole("button", { name: /abmelden/i })).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("closes after navigation, Escape and an outside pointer interaction", () => {
|
||||||
|
render(
|
||||||
|
<div>
|
||||||
|
<MobilePortalMenu nav={nav} sectionLabel="Administration" />
|
||||||
|
<button type="button">Außerhalb</button>
|
||||||
|
</div>,
|
||||||
|
);
|
||||||
|
|
||||||
|
const trigger = screen.getByRole("button", { name: /menü öffnen/i });
|
||||||
|
fireEvent.click(trigger);
|
||||||
|
fireEvent.click(screen.getByRole("link", { name: "Audit" }));
|
||||||
|
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
||||||
|
|
||||||
|
fireEvent.click(trigger);
|
||||||
|
fireEvent.keyDown(document, { key: "Escape" });
|
||||||
|
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
||||||
|
expect(document.activeElement).toBe(trigger);
|
||||||
|
|
||||||
|
fireEvent.click(trigger);
|
||||||
|
fireEvent.pointerDown(screen.getByRole("button", { name: "Außerhalb" }));
|
||||||
|
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the focused test and verify RED**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/components/layout/mobile-portal-menu.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: FAIL because `./mobile-portal-menu` does not exist.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Implement the minimal client component**
|
||||||
|
|
||||||
|
Create `src/components/layout/mobile-portal-menu.tsx`:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
|
import { Menu, X } from "lucide-react";
|
||||||
|
|
||||||
|
import type { NavItem } from "@/components/layout/portal-shell";
|
||||||
|
import { LogoutButton } from "@/components/layout/logout-button";
|
||||||
|
import { ThemeToggle } from "@/components/theme-toggle";
|
||||||
|
|
||||||
|
type MobilePortalMenuProps = {
|
||||||
|
nav: NavItem[];
|
||||||
|
sectionLabel: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function MobilePortalMenu({ nav, sectionLabel }: Readonly<MobilePortalMenuProps>) {
|
||||||
|
const pathname = usePathname();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const triggerRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const menuId = "mobile-portal-menu";
|
||||||
|
|
||||||
|
const activeHref = useMemo(
|
||||||
|
() => nav
|
||||||
|
.filter(({ href }) => pathname === href || pathname.startsWith(`${href}/`))
|
||||||
|
.sort((left, right) => right.href.length - left.href.length)[0]?.href,
|
||||||
|
[nav, pathname],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return;
|
||||||
|
|
||||||
|
function closeOnOutsidePointer(event: PointerEvent) {
|
||||||
|
if (!containerRef.current?.contains(event.target as Node)) setOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeOnEscape(event: KeyboardEvent) {
|
||||||
|
if (event.key !== "Escape") return;
|
||||||
|
setOpen(false);
|
||||||
|
triggerRef.current?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("pointerdown", closeOnOutsidePointer);
|
||||||
|
document.addEventListener("keydown", closeOnEscape);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("pointerdown", closeOnOutsidePointer);
|
||||||
|
document.removeEventListener("keydown", closeOnEscape);
|
||||||
|
};
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={containerRef} className="relative sm:hidden">
|
||||||
|
<button
|
||||||
|
ref={triggerRef}
|
||||||
|
type="button"
|
||||||
|
aria-controls={menuId}
|
||||||
|
aria-expanded={open}
|
||||||
|
aria-label={open ? "Menü schließen" : "Menü öffnen"}
|
||||||
|
className="inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-background px-3 text-sm font-semibold"
|
||||||
|
onClick={() => setOpen((current) => !current)}
|
||||||
|
>
|
||||||
|
{open ? <X aria-hidden="true" className="size-5" /> : <Menu aria-hidden="true" className="size-5" />}
|
||||||
|
Menü
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{open ? (
|
||||||
|
<div
|
||||||
|
id={menuId}
|
||||||
|
className="absolute right-0 top-[calc(100%+0.75rem)] z-50 w-[min(22rem,calc(100vw-2rem))] animate-in fade-in slide-in-from-top-2 rounded-xl border border-border bg-background p-2 shadow-xl duration-150 motion-reduce:animate-none"
|
||||||
|
>
|
||||||
|
<p className="px-3 py-2 text-xs font-bold uppercase tracking-widest text-muted-foreground">
|
||||||
|
{sectionLabel}
|
||||||
|
</p>
|
||||||
|
<nav aria-label="Mobile Navigation" className="grid gap-1">
|
||||||
|
{nav.map((item) => {
|
||||||
|
const active = item.href === activeHref;
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
key={item.href}
|
||||||
|
href={item.href}
|
||||||
|
aria-current={active ? "page" : undefined}
|
||||||
|
className={active
|
||||||
|
? "flex min-h-11 items-center rounded-lg bg-foreground px-3 font-semibold text-background"
|
||||||
|
: "flex min-h-11 items-center rounded-lg px-3 font-medium hover:bg-muted"}
|
||||||
|
onClick={() => setOpen(false)}
|
||||||
|
>
|
||||||
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</nav>
|
||||||
|
<div className="mt-2 flex min-h-11 items-center justify-between border-t border-border px-3 pt-2">
|
||||||
|
<span className="text-sm text-muted-foreground">Darstellung</span>
|
||||||
|
<ThemeToggle />
|
||||||
|
</div>
|
||||||
|
<div className="mt-2 border-t border-border px-3 pt-2">
|
||||||
|
<LogoutButton />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 4: Run the focused test and verify GREEN**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/components/layout/mobile-portal-menu.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: 1 file and 2 tests PASS.
|
||||||
|
|
||||||
|
- [ ] **Step 5: Run typecheck and lint for the new boundary**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/tsc --noEmit
|
||||||
|
./node_modules/.bin/eslint src/components/layout/mobile-portal-menu.tsx src/components/layout/mobile-portal-menu.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: both commands exit 0 with no errors.
|
||||||
|
|
||||||
|
- [ ] **Step 6: Commit the independently tested component**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add src/components/layout/mobile-portal-menu.tsx src/components/layout/mobile-portal-menu.test.tsx
|
||||||
|
git commit -m "feat: add accessible mobile portal menu"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Task 2: Integrate the menu into the shared portal shell
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/components/layout/portal-shell.tsx`
|
||||||
|
- Modify: `src/components/brand/logo.test.tsx`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: `MobilePortalMenu({ nav, sectionLabel })` from Task 1 and the existing `PortalShellProps`.
|
||||||
|
- Produces: one shared responsive header used unchanged by `src/app/admin/layout.tsx` and `src/app/redaktion/layout.tsx`.
|
||||||
|
|
||||||
|
- [ ] **Step 1: Extend the existing shell test with the mobile contract**
|
||||||
|
|
||||||
|
In `src/components/brand/logo.test.tsx`, mock `usePathname()` before imports and extend the `PortalShell` test:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { fireEvent, render, screen } from "@testing-library/react";
|
||||||
|
import { expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
vi.mock("next/navigation", () => ({
|
||||||
|
usePathname: () => "/redaktion/alben",
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Existing tests remain. In the PortalShell test, add:
|
||||||
|
const menuTrigger = screen.getByRole("button", { name: /menü öffnen/i });
|
||||||
|
expect(menuTrigger.parentElement?.className).toContain("sm:hidden");
|
||||||
|
fireEvent.click(menuTrigger);
|
||||||
|
expect(screen.getAllByRole("link", { name: "Alben" })).toHaveLength(2);
|
||||||
|
expect(screen.getByRole("navigation", { name: /mobile navigation/i })).toBeTruthy();
|
||||||
|
```
|
||||||
|
|
||||||
|
The two `Alben` links demonstrate that the unchanged desktop link and the
|
||||||
|
mobile dropdown consume the same supplied `nav` entry. The CSS visibility
|
||||||
|
classes ensure only one is exposed visually at a given breakpoint.
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the shell test and verify RED**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/components/brand/logo.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: FAIL because `PortalShell` does not yet expose the mobile trigger.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Integrate mobile and desktop control groups**
|
||||||
|
|
||||||
|
Modify `src/components/layout/portal-shell.tsx`:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { MobilePortalMenu } from "@/components/layout/mobile-portal-menu";
|
||||||
|
|
||||||
|
// Inside the right-hand header container, preserve sectionLabel and desktop nav,
|
||||||
|
// replace the always-visible controls with:
|
||||||
|
<div className="hidden items-center gap-4 sm:flex">
|
||||||
|
<ThemeToggle />
|
||||||
|
<LogoutButton />
|
||||||
|
</div>
|
||||||
|
<MobilePortalMenu nav={nav} sectionLabel={sectionLabel} />
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep the existing desktop `<nav className="hidden sm:flex ...">` unchanged.
|
||||||
|
Use `px-4 sm:px-6 lg:px-12` on the header row so the mobile trigger and logo fit
|
||||||
|
at 320 pixels without altering tablet/desktop spacing.
|
||||||
|
|
||||||
|
- [ ] **Step 4: Run component tests and verify GREEN**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/components/layout/mobile-portal-menu.test.tsx src/components/brand/logo.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: 2 files and all tests PASS.
|
||||||
|
|
||||||
|
- [ ] **Step 5: Verify admin and editorial route catalogues remain unchanged**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rg -n 'Dashboard|Redaktionen|Abrechnungen|Audit' src/app/admin/layout.tsx
|
||||||
|
rg -n 'Alben|Merkzettel|Nutzungen|Profil' src/app/redaktion/layout.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: all four role-specific destinations remain present in their existing
|
||||||
|
layout and no duplicate catalogue exists in `mobile-portal-menu.tsx`.
|
||||||
|
|
||||||
|
- [ ] **Step 6: Commit shell integration**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add src/components/layout/portal-shell.tsx src/components/brand/logo.test.tsx
|
||||||
|
git commit -m "feat: expose portal navigation on mobile"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Task 3: Full verification and production handoff
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Verify only; no production files are added by this task.
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: completed component and shared-shell integration from Tasks 1–2.
|
||||||
|
- Produces: verified Git history ready for push and container rebuild.
|
||||||
|
|
||||||
|
- [ ] **Step 1: Run the complete deterministic suite**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src
|
||||||
|
./node_modules/.bin/tsc --noEmit
|
||||||
|
./node_modules/.bin/eslint .
|
||||||
|
./node_modules/.bin/drizzle-kit check
|
||||||
|
git diff --check
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: all commands exit 0, with no failed tests or lint/type errors.
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the production build with non-secret verification values**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
env \
|
||||||
|
DATABASE_URL=postgres://portal:change-me@portal-db:5432/portal \
|
||||||
|
BETTER_AUTH_SECRET=replace-with-a-long-random-secret \
|
||||||
|
BETTER_AUTH_URL=https://redaktionen.leon-tonhaeuser.de \
|
||||||
|
IMMICH_BASE_URL=http://immich-server:2283 \
|
||||||
|
IMMICH_API_KEY=replace-with-a-restricted-immich-api-key \
|
||||||
|
SMTP_HOST=smtp.example.com SMTP_PORT=587 \
|
||||||
|
SMTP_USER=portal@example.com SMTP_PASSWORD=replace-with-an-smtp-password \
|
||||||
|
SMTP_FROM=portal@example.com \
|
||||||
|
LEGAL_IMPRINT_URL=https://leon-tonhaeuser.de/impressum \
|
||||||
|
LEGAL_PRIVACY_URL=https://leon-tonhaeuser.de/datenschutz \
|
||||||
|
LEGAL_TERMS_URL=https://leon-tonhaeuser.de/agb \
|
||||||
|
NEXT_DISABLE_TURBOPACK=1 \
|
||||||
|
./node_modules/.bin/next build --webpack
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: optimized production build exits 0 and lists the authenticated admin
|
||||||
|
and editorial routes.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Inspect final scope and repository state**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git status --short
|
||||||
|
git log -4 --oneline
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: no uncommitted production changes; the design, component and shell
|
||||||
|
integration commits are visible.
|
||||||
|
|
||||||
|
- [ ] **Step 4: Push after user-authorized integration choice**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git push origin-https main
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: GitLab advances `main` to the verified shell integration commit.
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
# Produktionshärtung und Nutzertexte – Implementierungsplan
|
||||||
|
|
||||||
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||||
|
|
||||||
|
**Goal:** Die bestätigten Sicherheits- und Abrechnungsfehler schließen und die gewünschten Passwort-/Nutzungsnachweis-Texte ergänzen.
|
||||||
|
|
||||||
|
**Architecture:** Bestehende Servicegrenzen bleiben erhalten. Autorisierung und Abrechnung werden an ihren serverseitigen Wahrheitsquellen korrigiert; UI und E-Mail konsumieren nur daraus abgeleitete, testbare Ergebnisse.
|
||||||
|
|
||||||
|
**Tech Stack:** Node.js 24, Next.js 16, React 19, TypeScript, Drizzle/PostgreSQL, Better Auth, Vitest.
|
||||||
|
|
||||||
|
## Global Constraints
|
||||||
|
|
||||||
|
- Keine Clientdaten bestimmen Editorial-ID oder Preis.
|
||||||
|
- Keine Historie wird gelöscht, um Abrechnungsfehler zu kaschieren.
|
||||||
|
- Alle Geldbeträge bleiben Integer-Cents.
|
||||||
|
- Alle Monatsgrenzen verwenden Europe/Berlin und halb offene UTC-Spannen.
|
||||||
|
- Jede Produktionsänderung benötigt vorher einen fehlschlagenden Regressionstest.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Task 1: Thumbnail-Autorisierung
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts`
|
||||||
|
- Test: `src/app/api/assets/[assetId]/thumbnail/route.test.ts`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: `ImmichClient.listAlbumsForAsset`, `ImmichClient.getAlbum`.
|
||||||
|
- Produces: generischer 404 oder autorisierte Thumbnail-Response.
|
||||||
|
|
||||||
|
- [ ] Test ergänzen: bekannte Fremd-Asset-ID trotz vorhandener Grants ergibt 404; Admin ohne passende Album-Cover-Bindung ergibt 404.
|
||||||
|
- [ ] Fokussierten Test ausführen und erwartetes RED bestätigen.
|
||||||
|
- [ ] Asset-Alben mit Grants schneiden und Admin-Cover-Bindung wiederherstellen.
|
||||||
|
- [ ] Test erneut ausführen und GREEN bestätigen.
|
||||||
|
|
||||||
|
### Task 2: Flatrate-Wahrheit
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/app/admin/redaktionen/[id]/actions.ts`
|
||||||
|
- Modify: `src/modules/usages/service.ts`
|
||||||
|
- Modify: `src/modules/billing/reports.ts`
|
||||||
|
- Test: `src/app/admin/redaktionen/[id]/actions.test.ts`
|
||||||
|
- Test: `src/modules/usages/service.test.ts`
|
||||||
|
- Test: `src/modules/billing/reports.test.ts`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Produces: validierte Flatrate-Konfiguration und konsistenter `flatrateCentsSnapshot`.
|
||||||
|
|
||||||
|
- [ ] RED: aktive Flatrate ohne positiven Preis wird abgelehnt.
|
||||||
|
- [ ] RED: Berliner Monatsrand wird korrekt gezählt.
|
||||||
|
- [ ] RED: gerenderter/persistierter Snapshot enthält denselben Pauschalbetrag wie `netTotalCents`.
|
||||||
|
- [ ] Minimale Validierungs-, Perioden- und Snapshotkorrektur implementieren.
|
||||||
|
- [ ] Fokussierte Tests GREEN ausführen.
|
||||||
|
|
||||||
|
### Task 3: ZIP-Abrechnung
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/app/api/lightbox/bulk-download/route.ts`
|
||||||
|
- Create: `src/app/api/lightbox/bulk-download/route.test.ts`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Produces: Same-Origin-geschützten ZIP-Stream und terminale Downloadzustände.
|
||||||
|
|
||||||
|
- [ ] RED: Cross-Origin wird vor Seiteneffekten abgewiesen.
|
||||||
|
- [ ] RED: Archivfehler nach Bytes markiert `interrupted`; Fehler vor Bytes voidet neue Nutzung; erfolgreicher Abschluss markiert erst nach Archivfinalisierung `completed`.
|
||||||
|
- [ ] RED: Response enthält `private, no-store` und `nosniff`.
|
||||||
|
- [ ] Handler-Abhängigkeiten isolieren und minimale Stream-/Settlement-Logik implementieren.
|
||||||
|
- [ ] Fokussierte Tests GREEN ausführen.
|
||||||
|
|
||||||
|
### Task 4: Rate-Limit-Verdrahtung
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/modules/auth/auth.ts`
|
||||||
|
- Modify: `src/app/(public)/registrieren/page.tsx`
|
||||||
|
- Modify: `src/app/api/download-intents/intent-handler.ts`
|
||||||
|
- Modify: `src/modules/albums/catalog.ts`
|
||||||
|
- Modify: `src/app/api/lightbox/bulk-download/route.ts`
|
||||||
|
- Test: zugehörige Auth-, Intent-, Catalog- und Bulk-Tests.
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Produces: 429 plus `Retry-After`; persistente Portal-Limits und explizite Better-Auth-Regeln.
|
||||||
|
|
||||||
|
- [ ] RED-Tests pro produktivem Pfad ergänzen.
|
||||||
|
- [ ] Stabile gehashte Schlüssel und 429-Response zentral implementieren.
|
||||||
|
- [ ] Better-Auth-Regeln für Anmeldung und Reset konfigurieren.
|
||||||
|
- [ ] Fokussierte Tests GREEN ausführen.
|
||||||
|
|
||||||
|
### Task 5: Nutzertexte
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/modules/auth/public-forms.tsx`
|
||||||
|
- Modify: `src/modules/auth/public-forms.test.tsx`
|
||||||
|
- Modify: `src/modules/email/service.ts`
|
||||||
|
- Create/Modify: `src/modules/email/service.test.ts`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Produces: wahrheitsgemäße Passwort-Erfolgsmeldung mit Anmeldelink und eindeutig bezeichneten Nutzungsnachweis.
|
||||||
|
|
||||||
|
- [ ] RED: erfolgreicher Reset zeigt „Passwort wurde aktualisiert“ und Link `/anmelden`; API-Fehler zeigt keinen Erfolg.
|
||||||
|
- [ ] RED: Billing-Mail enthält in Text und HTML „keine Rechnung“ sowie Hinweis auf separate Rechnung.
|
||||||
|
- [ ] Minimale UI- und Mail-Content-Änderung implementieren.
|
||||||
|
- [ ] Fokussierte Tests GREEN ausführen.
|
||||||
|
|
||||||
|
### Task 6: Quality Gates und Übergabe
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/modules/mail/mailer.test.ts`
|
||||||
|
- Modify: `src/components/brand/logo.test.tsx`
|
||||||
|
- Modify: `src/components/theme-toggle.tsx`
|
||||||
|
- Modify: `eslint.config.mjs`
|
||||||
|
- Delete: `drizzle/0007_album_auto_rules_and_archive.sql`
|
||||||
|
- Create: `docs/legal/agb-und-lizenzbedingungen-entwurf.md`
|
||||||
|
|
||||||
|
- [ ] Veraltete Erwartungen an bewusst geändertes HTML/Logo aktualisieren.
|
||||||
|
- [ ] Theme-Toggle lint-konform und hydration-sicher gestalten; `.worktrees/**` ignorieren.
|
||||||
|
- [ ] Verwaiste, nicht journalisierte Doppel-Migration entfernen.
|
||||||
|
- [ ] AGB-/Lizenzentwurf auf Basis offizieller deutscher Rechtsquellen erstellen.
|
||||||
|
- [ ] Vollsuite, Typecheck, Lint, Drizzle-Check, Build und `git diff --check` ausführen.
|
||||||
@@ -0,0 +1,353 @@
|
|||||||
|
# Session Expiry and Error Recovery Implementation Plan
|
||||||
|
|
||||||
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||||
|
|
||||||
|
**Goal:** Redirect expired protected-page sessions to `/anmelden` and provide a branded retry/sign-in recovery page for genuine unexpected rendering failures.
|
||||||
|
|
||||||
|
**Architecture:** A server-only page-access wrapper classifies the existing `PrincipalAuthorizationError` before protected layouts render. Only `AUTHENTICATION_REQUIRED` becomes a Next.js redirect; every other error propagates to a root route error boundary implemented as a small client component.
|
||||||
|
|
||||||
|
**Tech Stack:** Next.js 16 App Router, React 19, TypeScript, Tailwind CSS 4, Vitest, Testing Library, jsdom.
|
||||||
|
|
||||||
|
## Global Constraints
|
||||||
|
|
||||||
|
- Expired sessions redirect exactly to `/anmelden`.
|
||||||
|
- Only `PrincipalAuthorizationError("AUTHENTICATION_REQUIRED")` is redirected.
|
||||||
|
- Other authorization, database, Immich and programming errors are rethrown unchanged.
|
||||||
|
- Existing API response behavior, account-status rules and session duration remain unchanged.
|
||||||
|
- The unexpected-error UI exposes no stack, raw message or digest.
|
||||||
|
- Recovery controls are labelled exactly `Erneut versuchen` and `Zur Anmeldung`.
|
||||||
|
- No database migration or new dependency is allowed.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Task 1: Protected-page authentication boundary
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Create: `src/modules/auth/page-access.ts`
|
||||||
|
- Create: `src/modules/auth/page-access.test.ts`
|
||||||
|
- Modify: `src/app/admin/layout.tsx`
|
||||||
|
- Modify: `src/app/redaktion/layout.tsx`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: `PrincipalAuthorizationError`, Next.js `redirect`, existing `requireAdmin` and `requireEditorial` page guards.
|
||||||
|
- Produces: `requirePageAccess<T>(loadPrincipal: () => Promise<T>): Promise<T>`.
|
||||||
|
|
||||||
|
- [ ] **Step 1: Write the failing page-access tests**
|
||||||
|
|
||||||
|
Create `src/modules/auth/page-access.test.ts`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { afterEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
const { redirect } = vi.hoisted(() => ({
|
||||||
|
redirect: vi.fn((destination: string): never => {
|
||||||
|
throw new Error(`NEXT_REDIRECT:${destination}`);
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("next/navigation", () => ({ redirect }));
|
||||||
|
|
||||||
|
import { PrincipalAuthorizationError } from "./principal";
|
||||||
|
import { requirePageAccess } from "./page-access";
|
||||||
|
|
||||||
|
afterEach(() => vi.clearAllMocks());
|
||||||
|
|
||||||
|
test("redirects an expired protected-page session to sign-in", async () => {
|
||||||
|
const expired = new PrincipalAuthorizationError("AUTHENTICATION_REQUIRED");
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
requirePageAccess(async () => {
|
||||||
|
throw expired;
|
||||||
|
}),
|
||||||
|
).rejects.toThrow("NEXT_REDIRECT:/anmelden");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("rethrows non-session failures unchanged", async () => {
|
||||||
|
const unavailable = new Error("database unavailable");
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
requirePageAccess(async () => {
|
||||||
|
throw unavailable;
|
||||||
|
}),
|
||||||
|
).rejects.toBe(unavailable);
|
||||||
|
expect(redirect).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("returns the principal when the page guard succeeds", async () => {
|
||||||
|
const principal = { userId: "admin-1" };
|
||||||
|
|
||||||
|
await expect(requirePageAccess(async () => principal)).resolves.toBe(principal);
|
||||||
|
expect(redirect).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the focused test and verify RED**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/modules/auth/page-access.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: FAIL because `./page-access` does not exist.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Implement the minimal server-only boundary**
|
||||||
|
|
||||||
|
Create `src/modules/auth/page-access.ts`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import "server-only";
|
||||||
|
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
import { PrincipalAuthorizationError } from "@/modules/auth/principal";
|
||||||
|
|
||||||
|
export async function requirePageAccess<T>(
|
||||||
|
loadPrincipal: () => Promise<T>,
|
||||||
|
): Promise<T> {
|
||||||
|
try {
|
||||||
|
return await loadPrincipal();
|
||||||
|
} catch (error) {
|
||||||
|
if (
|
||||||
|
error instanceof PrincipalAuthorizationError &&
|
||||||
|
error.code === "AUTHENTICATION_REQUIRED"
|
||||||
|
) {
|
||||||
|
redirect("/anmelden");
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 4: Run the focused test and verify GREEN**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/modules/auth/page-access.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: 1 file and 3 tests PASS.
|
||||||
|
|
||||||
|
- [ ] **Step 5: Integrate both protected layouts**
|
||||||
|
|
||||||
|
In `src/app/admin/layout.tsx`, import `requirePageAccess` and replace the direct
|
||||||
|
guard call with:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await requirePageAccess(() => requireAdmin(new Headers(await headers())));
|
||||||
|
```
|
||||||
|
|
||||||
|
In `src/app/redaktion/layout.tsx`, import `requirePageAccess` and replace the
|
||||||
|
direct guard call with:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await requirePageAccess(requireEditorial);
|
||||||
|
```
|
||||||
|
|
||||||
|
Do not alter either layout's `PortalShell`, role navigation or principal guard.
|
||||||
|
|
||||||
|
- [ ] **Step 6: Run focused tests, typecheck and lint**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/modules/auth/page-access.test.ts src/modules/auth/principal.test.ts
|
||||||
|
./node_modules/.bin/tsc --noEmit
|
||||||
|
./node_modules/.bin/eslint src/modules/auth/page-access.ts src/modules/auth/page-access.test.ts src/app/admin/layout.tsx src/app/redaktion/layout.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: all commands exit 0.
|
||||||
|
|
||||||
|
- [ ] **Step 7: Commit the page-access behavior**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add src/modules/auth/page-access.ts src/modules/auth/page-access.test.ts src/app/admin/layout.tsx src/app/redaktion/layout.tsx
|
||||||
|
git commit -m "fix: redirect expired portal sessions"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Task 2: Branded unexpected-error recovery page
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Create: `src/app/error.tsx`
|
||||||
|
- Create: `src/app/error.test.tsx`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: Next.js error-boundary props `{ error: Error & { digest?: string }; reset: () => void }`, `Link`, and the existing `Button` component.
|
||||||
|
- Produces: the root route error UI for uncaught child-segment rendering errors.
|
||||||
|
|
||||||
|
- [ ] **Step 1: Write the failing recovery UI test**
|
||||||
|
|
||||||
|
Create `src/app/error.test.tsx`:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// @vitest-environment jsdom
|
||||||
|
|
||||||
|
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||||
|
import { afterEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
import PortalError from "./error";
|
||||||
|
|
||||||
|
afterEach(cleanup);
|
||||||
|
|
||||||
|
test("offers retry and sign-in without exposing server details", () => {
|
||||||
|
const reset = vi.fn();
|
||||||
|
render(
|
||||||
|
<PortalError
|
||||||
|
error={Object.assign(new Error("database password leaked"), {
|
||||||
|
digest: "private-digest",
|
||||||
|
})}
|
||||||
|
reset={reset}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
screen.getByRole("heading", { name: "Diese Seite konnte nicht geladen werden." }),
|
||||||
|
).toBeTruthy();
|
||||||
|
fireEvent.click(screen.getByRole("button", { name: "Erneut versuchen" }));
|
||||||
|
expect(reset).toHaveBeenCalledTimes(1);
|
||||||
|
expect(screen.getByRole("link", { name: "Zur Anmeldung" }).getAttribute("href")).toBe(
|
||||||
|
"/anmelden",
|
||||||
|
);
|
||||||
|
expect(document.body.textContent).not.toContain("database password leaked");
|
||||||
|
expect(document.body.textContent).not.toContain("private-digest");
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the focused test and verify RED**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/app/error.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: FAIL because `src/app/error.tsx` does not exist.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Implement the minimal recovery page**
|
||||||
|
|
||||||
|
Create `src/app/error.tsx`:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
|
type PortalErrorProps = {
|
||||||
|
error: Error & { digest?: string };
|
||||||
|
reset: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function PortalError({ reset }: Readonly<PortalErrorProps>) {
|
||||||
|
return (
|
||||||
|
<main className="public-account-page">
|
||||||
|
<header className="masthead">
|
||||||
|
<span className="wordmark">Leon Tonhäuser</span>
|
||||||
|
<span className="section-label">Redaktionsportal</span>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section className="account-panel" aria-labelledby="error-title">
|
||||||
|
<p className="eyebrow">Verbindung unterbrochen</p>
|
||||||
|
<h1 id="error-title">Diese Seite konnte nicht geladen werden.</h1>
|
||||||
|
<p className="lede">
|
||||||
|
Versuchen Sie es erneut oder melden Sie sich wieder am Redaktionsportal an.
|
||||||
|
</p>
|
||||||
|
<div className="mt-8 flex flex-wrap gap-3">
|
||||||
|
<Button className="min-h-11" size="lg" type="button" onClick={reset}>
|
||||||
|
Erneut versuchen
|
||||||
|
</Button>
|
||||||
|
<Button asChild className="min-h-11" size="lg" variant="outline">
|
||||||
|
<Link href="/anmelden">Zur Anmeldung</Link>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The `error` prop remains part of the required Next.js interface but is not
|
||||||
|
rendered or logged by this component.
|
||||||
|
|
||||||
|
- [ ] **Step 4: Run the focused test and verify GREEN**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/app/error.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: 1 file and 1 test PASS.
|
||||||
|
|
||||||
|
- [ ] **Step 5: Run typecheck and focused lint**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/tsc --noEmit
|
||||||
|
./node_modules/.bin/eslint src/app/error.tsx src/app/error.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: both commands exit 0.
|
||||||
|
|
||||||
|
- [ ] **Step 6: Commit the recovery UI**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add src/app/error.tsx src/app/error.test.tsx
|
||||||
|
git commit -m "feat: add portal error recovery page"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Task 3: Full verification and deployment handoff
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Verify only; no production file is added by this task.
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: completed page-access and recovery-page tasks.
|
||||||
|
- Produces: verified commits ready for integration and a container-only deployment.
|
||||||
|
|
||||||
|
- [ ] **Step 1: Run the full deterministic verification**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src
|
||||||
|
./node_modules/.bin/tsc --noEmit
|
||||||
|
./node_modules/.bin/eslint .
|
||||||
|
./node_modules/.bin/drizzle-kit check
|
||||||
|
git diff --check
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: all commands exit 0 with no failed tests, type errors, lint errors or
|
||||||
|
migration inconsistencies.
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the production build**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
env \
|
||||||
|
DATABASE_URL=postgres://portal:change-me@portal-db:5432/portal \
|
||||||
|
BETTER_AUTH_SECRET=replace-with-a-long-random-secret \
|
||||||
|
BETTER_AUTH_URL=https://redaktionen.leon-tonhaeuser.de \
|
||||||
|
IMMICH_BASE_URL=http://immich-server:2283 \
|
||||||
|
IMMICH_API_KEY=replace-with-a-restricted-immich-api-key \
|
||||||
|
SMTP_HOST=smtp.example.com SMTP_PORT=587 \
|
||||||
|
SMTP_USER=portal@example.com SMTP_PASSWORD=replace-with-an-smtp-password \
|
||||||
|
SMTP_FROM=portal@example.com \
|
||||||
|
LEGAL_IMPRINT_URL=https://leon-tonhaeuser.de/impressum \
|
||||||
|
LEGAL_PRIVACY_URL=https://leon-tonhaeuser.de/datenschutz \
|
||||||
|
LEGAL_TERMS_URL=https://leon-tonhaeuser.de/agb \
|
||||||
|
NEXT_DISABLE_TURBOPACK=1 \
|
||||||
|
./node_modules/.bin/next build --webpack
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: production build exits 0 and includes `/anmelden`, `/admin` and
|
||||||
|
`/redaktion` routes.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Verify scope and history**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git status --short
|
||||||
|
git log -5 --oneline
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: no uncommitted implementation changes and both feature commits are
|
||||||
|
present.
|
||||||
|
|
||||||
|
- [ ] **Step 4: Deploy without database migration**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git pull --ff-only origin main
|
||||||
|
docker compose build --pull portal-app
|
||||||
|
docker compose up -d --no-deps --force-recreate portal-app
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: the refreshed container serves the redirect and recovery UI; Zoraxy
|
||||||
|
and PostgreSQL require no change.
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
# Search Result Download Implementation Plan
|
||||||
|
|
||||||
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||||
|
|
||||||
|
**Goal:** Show the existing `Original laden` workflow on every authorized global search result, even when Immich omits the asset's album association.
|
||||||
|
|
||||||
|
**Architecture:** The server-side album catalog already fans a global search out into one request per granted album. Normalize each returned page at that boundary by adding the queried granted album ID when the asset does not include it; the existing gallery then receives enough trusted context to render its unchanged `UsageDialog` on both the tile and lightbox.
|
||||||
|
|
||||||
|
**Tech Stack:** Next.js 16, React 19, TypeScript, Vitest, Testing Library, Immich API adapter
|
||||||
|
|
||||||
|
## Global Constraints
|
||||||
|
|
||||||
|
- Reuse the existing `UsageDialog`, download API, pricing, prior-usage, authorization, and accounting logic.
|
||||||
|
- Album context must come from the server-side granted-album query, never from browser input.
|
||||||
|
- Do not issue an additional Immich request per search result.
|
||||||
|
- Preserve album associations already returned by Immich.
|
||||||
|
- Do not change the database schema or add a migration.
|
||||||
|
- Production code must follow a witnessed RED/GREEN TDD cycle.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Task 1: Restore Authorized Album Context on Search Results
|
||||||
|
|
||||||
|
**Files:**
|
||||||
|
- Modify: `src/modules/albums/catalog.test.ts`
|
||||||
|
- Modify: `src/modules/albums/catalog.ts`
|
||||||
|
- Modify: `src/modules/albums/catalog-content.test.tsx`
|
||||||
|
|
||||||
|
**Interfaces:**
|
||||||
|
- Consumes: `ImmichSearchPage`, the granted `albumIds` passed to the existing private `searchAlbum` function, and `PhotoGallery`'s existing `downloadOptions`
|
||||||
|
- Produces: each returned `ImmichAsset` contains the queried authorized `{ id: string }` album association; `PhotoGallery` therefore renders its existing `UsageDialog`
|
||||||
|
|
||||||
|
- [ ] **Step 1: Write the failing catalog regression test**
|
||||||
|
|
||||||
|
Add an asset fixture whose `albums` array is empty, make `searchPhotos` return it for the granted album `allowed`, and assert the catalog result contains the server-selected association:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
test("restores the queried granted album when Immich omits an asset album association", async () => {
|
||||||
|
const { catalog, immich } = createCatalog({ grantedAlbumIds: ["allowed"] });
|
||||||
|
immich.searchPhotos.mockResolvedValue({
|
||||||
|
items: [{
|
||||||
|
id: "asset-1",
|
||||||
|
type: "IMAGE",
|
||||||
|
originalFileName: "tor.jpg",
|
||||||
|
originalMimeType: "image/jpeg",
|
||||||
|
localDateTime: null,
|
||||||
|
fileCreatedAt: null,
|
||||||
|
albums: [],
|
||||||
|
}],
|
||||||
|
total: 1,
|
||||||
|
nextPage: null,
|
||||||
|
previousPage: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await catalog.searchVisiblePhotos("editorial-1", { page: 1 });
|
||||||
|
|
||||||
|
expect(result.items[0]?.albums).toEqual([{ id: "allowed" }]);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 2: Run the focused catalog test and verify RED**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/modules/albums/catalog.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: the new assertion fails with `[]` instead of `[{ id: "allowed" }]`; existing tests remain green.
|
||||||
|
|
||||||
|
- [ ] **Step 3: Implement minimal album-context normalization**
|
||||||
|
|
||||||
|
In `searchAlbum`, await the existing Immich response and return a copied page. For every item, preserve it unchanged when its `albums` already contains the queried album. Otherwise prepend the queried album association:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const searchPage = await immich.searchPhotos({
|
||||||
|
albumIds,
|
||||||
|
...(description === undefined ? {} : { description }),
|
||||||
|
type: "IMAGE",
|
||||||
|
page,
|
||||||
|
size,
|
||||||
|
});
|
||||||
|
const queriedAlbumId = albumIds[0];
|
||||||
|
return {
|
||||||
|
...searchPage,
|
||||||
|
items: queriedAlbumId
|
||||||
|
? searchPage.items.map((asset) => asset.albums.some(({ id }) => id === queriedAlbumId)
|
||||||
|
? asset
|
||||||
|
: { ...asset, albums: [{ id: queriedAlbumId }, ...asset.albums] })
|
||||||
|
: searchPage.items,
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
- [ ] **Step 4: Run the focused catalog test and verify GREEN**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/modules/albums/catalog.test.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: all catalog tests pass.
|
||||||
|
|
||||||
|
- [ ] **Step 5: Add the gallery regression test**
|
||||||
|
|
||||||
|
In `catalog-content.test.tsx`, render `PhotoGallery` without its top-level `albumId`, but with an item containing the restored album association and valid `downloadOptions`. Assert the tile offers `Original laden`, open the photo lightbox, and assert the lightbox dialog also contains `Original laden`:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
test("offers the existing download workflow on a global search result and its lightbox", () => {
|
||||||
|
render(
|
||||||
|
<PhotoGallery
|
||||||
|
albumName="Alle Alben"
|
||||||
|
downloadOptions={{ priceCents: 100, priorUsagesByAsset: {} }}
|
||||||
|
items={[{
|
||||||
|
...photo,
|
||||||
|
id: "22222222-2222-4222-8222-222222222222",
|
||||||
|
albums: [{ id: "33333333-3333-4333-8333-333333333333" }],
|
||||||
|
}]}
|
||||||
|
showAlbumName
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByRole("button", { name: /original laden/i })).not.toBeNull();
|
||||||
|
fireEvent.click(screen.getByRole("button", { name: /tor-des-sieges\.jpg vergrößern/i }));
|
||||||
|
expect(within(screen.getByRole("dialog")).getByRole("button", { name: /original laden/i })).not.toBeNull();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Import `within` from Testing Library. This test protects reuse of the existing dialog in both search-result surfaces without testing framework internals.
|
||||||
|
|
||||||
|
- [ ] **Step 6: Run both focused suites**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src/modules/albums/catalog.test.ts src/modules/albums/catalog-content.test.tsx
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: both files and all contained tests pass without warnings.
|
||||||
|
|
||||||
|
- [ ] **Step 7: Run full deterministic verification**
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./node_modules/.bin/vitest run src
|
||||||
|
./node_modules/.bin/tsc --noEmit
|
||||||
|
./node_modules/.bin/eslint .
|
||||||
|
./node_modules/.bin/drizzle-kit check
|
||||||
|
git diff --check
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: every command exits with status 0.
|
||||||
|
|
||||||
|
- [ ] **Step 8: Run the production build**
|
||||||
|
|
||||||
|
Run `./node_modules/.bin/next build --webpack` with the documented non-secret build-time environment values.
|
||||||
|
|
||||||
|
Expected: the optimized production build completes with exit status 0.
|
||||||
|
|
||||||
|
- [ ] **Step 9: Commit the implementation**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add src/modules/albums/catalog.test.ts src/modules/albums/catalog.ts src/modules/albums/catalog-content.test.tsx
|
||||||
|
git commit -m "feat: enable downloads from search results"
|
||||||
|
```
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Kalender, Kategorien, Vormerken, Dashboard (v2.3.0) Implementation Plan
|
||||||
|
|
||||||
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||||
|
|
||||||
|
**Goal:** Kategorien mit Farben, Monatskalender mit Legende, "Zu meinen Alben hinzufügen" (Vormerken mit automatischer Freischaltung), neues Admin-Dashboard, Bildraster zeilenweise.
|
||||||
|
|
||||||
|
**Architecture:** Neue Tabellen `event_categories` und `event_reservations` (Drizzle-Migration, `event_responses` entfällt). Der Kalender-Service bekommt `reserve`/`unreserve`/`resolvePendingReservations` und eine reine Statusfunktion; der bestehende Auto-Regel-Scheduler ruft `resolvePendingReservations` je Tick. UI mit Sakani `MonthCalendar`, `Badge`, `Card`, `FormSelect`.
|
||||||
|
|
||||||
|
**Tech Stack:** Next.js 16, Drizzle/Postgres, @sakaniui/react 0.23, Vitest, Playwright (tmp/clickthrough.spec.ts).
|
||||||
|
|
||||||
|
**Spec:** docs/superpowers/specs/2026-11-30-kalender-kategorien-dashboard-design.md
|
||||||
|
|
||||||
|
## Global Constraints
|
||||||
|
|
||||||
|
- Version 2.3.0; Seeds als eigene Custom-Migration mit Zeilenumbruch nach dem Kommentar.
|
||||||
|
- Keine Em-Dashes in neuen UI-Texten; beide Themes; Actions mit Guards; Vormerken mit `calendarSelfGrantPolicy`.
|
||||||
|
- Farben exakt: `blue|green|orange|purple|teal|gold|red|neutral`.
|
||||||
|
- Freischaltung nur über `grants.grantAlbum({ source: "self_service" })`.
|
||||||
|
|
||||||
|
## Review Focus
|
||||||
|
|
||||||
|
- Vormerken, während Immich nicht erreichbar ist: Vormerkung wird gespeichert, kein Fehler; Job holt es nach.
|
||||||
|
- Termin gelöscht mit offenen und eingelösten Vormerkungen: beide weg, self_service entzogen, Auto-Regel-Freigaben bleiben.
|
||||||
|
- Doppelter Kategoriename mit anderer Groß-/Kleinschreibung: klare Fehlermeldung statt 500.
|
||||||
|
- Kategorie löschen, die ein Termin nutzt: abgelehnt mit Hinweis.
|
||||||
|
- `eventDate` am Monatsende/Zeitzone: Chip erscheint am richtigen Tag (lokales Datum, allDay).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Task 1: Schema + Migration
|
||||||
|
**Files:** Modify `src/db/schema/calendar.ts`; generate `drizzle/0006_*.sql`; Test `tests/db/` (bestehende Migrationstests laufen mit).
|
||||||
|
- [ ] `eventCategories` (unique index auf `lower(name)`, Check auf Farben), `calendarEvents.categoryId` (FK restrict, nullable), `eventReservations` (unique event+editorial, `grantedAt` nullable, FK event restrict), `eventResponses` entfernen.
|
||||||
|
- [ ] `drizzle-kit generate --name calendar_categories_reservations`, gegen Test-DB migrieren, `vitest run tests/db` grün.
|
||||||
|
|
||||||
|
### Task 2: Kategorie-Service
|
||||||
|
**Files:** Create `src/modules/calendar/categories.ts` (+ `.test.ts`).
|
||||||
|
**Produces:** `CATEGORY_COLORS`, `type CategoryColor`, `categoryService.{listCategories(): Promise<EventCategory[] & {eventCount}>, createCategory({name,color,adminUserId}), deleteCategory({id,adminUserId})}`, Fehler `INVALID_NAME|INVALID_COLOR|DUPLICATE_NAME|CATEGORY_IN_USE|CATEGORY_NOT_FOUND`.
|
||||||
|
- [ ] Tests: leerer/zu langer Name (max 80) → INVALID_NAME; Farbe "pink" → INVALID_COLOR; Duplikat (Unique-Verletzung 23505) → DUPLICATE_NAME; benutzte Kategorie → CATEGORY_IN_USE. Audit `event_category_created/deleted`.
|
||||||
|
|
||||||
|
### Task 3: Kalender-Service: Vormerken + Status
|
||||||
|
**Files:** Modify `src/modules/calendar/service.ts`, `service.test.ts`, `src/modules/albums/auto-rule-scheduler.ts`.
|
||||||
|
**Produces:** `type EventAccessState = "granted" | "auto_granted" | "auto_rule" | "reserved" | "available"`; `eventAccessState({ isGranted, grantSource, autoRuleMatch, reserved }): EventAccessState`; `EditorialCalendarEvent` mit `category`, `access`, `album`; `AdminCalendarEvent` mit `category`, `reservations: {editorialId, editorialName, grantedAt}[]`; `reserve`, `unreserve`, `resolvePendingReservations(): Promise<{granted:number}>`; `createEvent` nimmt `categoryId`.
|
||||||
|
- [ ] Tests: reserve ohne Album → Vormerkung, kein Grant; reserve mit Album → Grant self_service + grantedAt; Immich down → Vormerkung bleibt; unreserve nur ohne grantedAt; resolve löst passende ein, überspringt andere; deleteEvent löscht Vormerkungen; Statusreihenfolge; Auto-Regel-Match über Titel/Albumname (case-insensitive).
|
||||||
|
- [ ] Scheduler-Tick ruft nach `applyAllRules` `calendarService.resolvePendingReservations()`.
|
||||||
|
|
||||||
|
### Task 4: Admin: Kategorien-Seite, Termin-Formular, Kalenderansicht
|
||||||
|
**Files:** Create `src/app/admin/kalender/kategorien/{page.tsx,CategoryForm.tsx,DeleteCategoryButton.tsx,actions.ts}`, `src/components/calendar/{event-month.tsx,category-legend.tsx}`; Modify `src/app/admin/kalender/{page.tsx,CalendarEventForm.tsx,actions.ts}`.
|
||||||
|
- [ ] `EventMonth` (client): `MonthCalendar` mit `events` aus `{id,title,eventDate,color}` (Datum lokal, allDay), Klick → `onSelect(id)`; `CategoryLegend`: Farbpunkte + Namen.
|
||||||
|
- [ ] Admin-Liste zeigt Kategorie-Badge, Albumstatus, Vormerkungen.
|
||||||
|
|
||||||
|
### Task 5: Redaktions-Kalender
|
||||||
|
**Files:** Modify `src/app/redaktion/kalender/{page.tsx,actions.ts}`; Create `EventAccessAction.tsx`; Delete `EventRsvpButtons.tsx`, `SelfGrantButton.tsx`.
|
||||||
|
- [ ] Monatsansicht + Legende + Detailkarte des gewählten Termins + Liste "Kommende Termine"; Aktion nach `access`.
|
||||||
|
|
||||||
|
### Task 6: Bildraster
|
||||||
|
**Files:** Modify `src/app/globals.css` (`.photo-gallery`), `src/modules/albums/photo-gallery.tsx`.
|
||||||
|
- [ ] CSS-Grid `repeat(auto-fill, minmax(17rem, 1fr))`, Kacheln 3:2 `object-fit: cover`, Reihenfolge zeilenweise; Großansicht unverändert.
|
||||||
|
|
||||||
|
### Task 7: Admin-Dashboard
|
||||||
|
**Files:** Modify `src/app/admin/page.tsx`; Create `src/modules/dashboard/queries.ts` (+ test der reinen Teile).
|
||||||
|
- [ ] Aufgaben (pending_approval, final ohne Rechnungs-PDF, Rechnungsmail failed, offener Umsatz Quartal), nächste 5 Termine, Kurzzahlen 30 Tage, letzte Aktivitäten.
|
||||||
|
|
||||||
|
### Task 8: Release 2.3.0 + Verifikation
|
||||||
|
- [ ] `RELEASE.version = "2.3"`/Notes, Seed-Migration, AGENTS/AI_MEMORY, Click-Through angepasst; tsc, eslint, vitest, build, Playwright 7/7+; Commit.
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Mobile Menu Active Contrast Design
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
The active navigation link in the mobile portal menu uses Tailwind's
|
||||||
|
`text-background` utility. The project also defines an unlayered global
|
||||||
|
`a { color: inherit; }` rule. Unlayered CSS outranks Tailwind utilities in the
|
||||||
|
cascade, so the link inherits the surrounding text color instead of using the
|
||||||
|
intended inverse color. This produces dark text on a dark active background in
|
||||||
|
light mode and the corresponding low-contrast result in dark mode.
|
||||||
|
|
||||||
|
## Design
|
||||||
|
|
||||||
|
Give the active mobile navigation link one semantic class owned by the mobile
|
||||||
|
menu component. Define that class in the existing global stylesheet, outside
|
||||||
|
Tailwind's utility layer, with the portal's established inverse theme tokens:
|
||||||
|
|
||||||
|
- background: `var(--ink)`
|
||||||
|
- text: `var(--paper)`
|
||||||
|
|
||||||
|
The existing tokens already reverse with the selected theme. The result is a
|
||||||
|
dark surface with white text in light mode and a light surface with black text
|
||||||
|
in dark mode. Inactive links, menu spacing, motion, routing, and interaction
|
||||||
|
remain unchanged.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
Extend the existing mobile-menu component test to assert that the active link
|
||||||
|
receives the semantic contrast class while an inactive link does not. Observe
|
||||||
|
the new test fail before adding the production class, then pass after the CSS
|
||||||
|
and component changes. Run the focused test, all source tests, TypeScript,
|
||||||
|
ESLint, and the production webpack build.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This change is limited to:
|
||||||
|
|
||||||
|
- `src/components/layout/mobile-portal-menu.tsx`
|
||||||
|
- `src/components/layout/mobile-portal-menu.test.tsx`
|
||||||
|
- `src/app/globals.css`
|
||||||
|
|
||||||
|
No theme tokens, desktop navigation, or other link styles will be changed.
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
# Mobile Portal Navigation Design
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Authenticated admin and editorial users must be able to reach every portal
|
||||||
|
section on a mobile viewport. The existing desktop navigation remains
|
||||||
|
unchanged.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
The shared `PortalShell` gains one mobile-only dropdown trigger. The dropdown
|
||||||
|
uses the same role-specific `nav` items already supplied by the admin and
|
||||||
|
editorial layouts, so no second navigation catalogue is introduced.
|
||||||
|
|
||||||
|
The mobile header contains:
|
||||||
|
|
||||||
|
- the existing brand link;
|
||||||
|
- one labelled menu button with a menu/close icon.
|
||||||
|
|
||||||
|
The open dropdown contains:
|
||||||
|
|
||||||
|
- every role-specific navigation destination;
|
||||||
|
- the existing theme control;
|
||||||
|
- the existing sign-out action in a visually separated action row.
|
||||||
|
|
||||||
|
On `sm` and larger viewports, the current inline navigation, theme control and
|
||||||
|
sign-out button remain visible and the mobile trigger and dropdown are hidden.
|
||||||
|
|
||||||
|
## Interaction
|
||||||
|
|
||||||
|
- The trigger exposes its state with `aria-expanded` and references the menu
|
||||||
|
with `aria-controls`.
|
||||||
|
- Activating the trigger toggles the dropdown.
|
||||||
|
- Selecting a navigation link closes the dropdown before navigation.
|
||||||
|
- Pressing Escape closes the dropdown and returns focus to the trigger.
|
||||||
|
- Clicking outside the dropdown closes it.
|
||||||
|
- The current route is indicated visually and with `aria-current="page"`.
|
||||||
|
- All interactive rows provide a touch target of at least 44 pixels.
|
||||||
|
|
||||||
|
## Visual Direction
|
||||||
|
|
||||||
|
The menu follows the portal's restrained black-and-white identity. It appears
|
||||||
|
directly below the sticky masthead, inset from the viewport edges, with a solid
|
||||||
|
background, fine border and modest shadow. Navigation rows use clear spacing
|
||||||
|
and typography rather than decorative elements. The active destination uses a
|
||||||
|
high-contrast filled state. Motion is limited to a short opacity/position
|
||||||
|
transition and is disabled when reduced motion is requested.
|
||||||
|
|
||||||
|
## Component Boundary
|
||||||
|
|
||||||
|
A focused client component, `MobilePortalMenu`, owns open state, focus,
|
||||||
|
outside-click handling, Escape handling and active-route detection. It receives
|
||||||
|
only `nav` and `sectionLabel`. `PortalShell` remains a server component and
|
||||||
|
renders this client boundary alongside the unchanged desktop controls.
|
||||||
|
|
||||||
|
The existing `ThemeToggle` and `LogoutButton` are reused inside the mobile
|
||||||
|
dropdown. Separate desktop instances remain in the desktop-only control group;
|
||||||
|
CSS breakpoints ensure only one instance of each control is interactive at a
|
||||||
|
time.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
Component tests cover:
|
||||||
|
|
||||||
|
- the closed initial state and correct accessible trigger state;
|
||||||
|
- opening the menu and exposing all supplied navigation destinations;
|
||||||
|
- rendering the theme and sign-out actions inside the open mobile menu;
|
||||||
|
- indicating the active destination;
|
||||||
|
- closing on link activation, Escape and outside click.
|
||||||
|
|
||||||
|
The existing full test, typecheck, lint and production-build checks must remain
|
||||||
|
green. A mobile viewport smoke check verifies that desktop controls are hidden
|
||||||
|
and the dropdown provides every role-specific destination.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
|
||||||
|
- Changing desktop navigation or route names.
|
||||||
|
- Adding nested navigation levels.
|
||||||
|
- Changing authentication, authorization or sign-out behavior.
|
||||||
|
- Adding a full-screen drawer or animation framework.
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# Produktionshärtung und Nutzertexte – Design
|
||||||
|
|
||||||
|
## Ziel
|
||||||
|
|
||||||
|
Die nach dem Portal-Audit bestätigten Autorisierungs-, Abrechnungs- und Schutzlücken werden geschlossen. Zusätzlich erhalten Nutzer nach einem erfolgreichen Passwortwechsel eine eindeutige Anmeldung-Aufforderung, und der per E-Mail versandte PDF-Anhang wird unmissverständlich als Nutzungsnachweis statt als Rechnung bezeichnet.
|
||||||
|
|
||||||
|
## Freigegebener Umfang
|
||||||
|
|
||||||
|
Der Nutzer hat die im Audit vorgeschlagene Reihenfolge und die dort beschriebenen Korrekturen freigegeben. Änderungen bleiben auf folgende Bereiche begrenzt:
|
||||||
|
|
||||||
|
1. Thumbnail-Zugriff nur für Assets in aktuell freigegebenen Alben; Admin-Zugriff nur auf ein an ein Album gebundenes Cover.
|
||||||
|
2. Flatrate nur mit positivem Preis; Berlin-sichere Monatsgrenzen; derselbe serverseitig ermittelte Pauschal-Snapshot in Summe, PDF und Datenbank.
|
||||||
|
3. ZIP-Downloads mit Same-Origin-Prüfung, privaten No-Store-Headern, Abbruchpropagierung und wahrheitsgemäßen Terminalzuständen.
|
||||||
|
4. Bestehende Rate-Limit-Policies werden an die produktiven Pfade angebunden. Auth-Endpunkte verwenden die Better-Auth-Regeln; registrierungs- und portalspezifische Pfade verwenden den vorhandenen PostgreSQL-Limiter.
|
||||||
|
5. Passwort-Reset zeigt nur bei bestätigtem API-Erfolg einen Link zur Anmeldung; Fehler bleiben sichtbar.
|
||||||
|
6. Abrechnungs-E-Mails heißen „Nutzungsnachweis“ und weisen in Text und HTML darauf hin, dass die Rechnung separat folgt.
|
||||||
|
7. Veraltete Tests und die verwaiste Doppel-Migration werden bereinigt.
|
||||||
|
|
||||||
|
## Datenfluss und Sicherheitsgrenzen
|
||||||
|
|
||||||
|
### Thumbnails
|
||||||
|
|
||||||
|
Die Redaktion wird wie bisher aus der Session bestimmt. Danach werden die aktuellen Grant-IDs mit den durch Immich für das Asset gelieferten Album-IDs geschnitten. Eine leere Schnittmenge ergibt denselben generischen 404 wie ein unbekanntes Asset. Admins müssen `albumId` übergeben; nur `album.albumThumbnailAssetId === assetId` ist zulässig.
|
||||||
|
|
||||||
|
### Flatrate
|
||||||
|
|
||||||
|
Aktivierung ohne positiven Preis wird abgelehnt. `buildSnapshot` ist die einzige Quelle für den Pauschalbetrag. Der zurückgegebene Wert wird für PDF, Gesamtbetrag und persistierten Report wiederverwendet. Monatslimits verwenden `monthPeriod(..., "Europe/Berlin")` und eine halb offene UTC-Spanne.
|
||||||
|
|
||||||
|
### ZIP
|
||||||
|
|
||||||
|
Jeder Claim bleibt einem Asset zugeordnet. Ein vollständig erzeugtes und geschlossenenes Archiv setzt erfolgreich eingebrachte Events auf `completed`. Vor dem ersten Byte wird `failed_before_delivery` verwendet, nach Bytes `interrupted`. Abbruch oder Archivfehler terminalisiert alle bereits geclaimten, noch offenen Events; noch nicht begonnene Assets erzeugen keine Nutzung. Der Response ist `private, no-store` und `nosniff`.
|
||||||
|
|
||||||
|
### Rate-Limits
|
||||||
|
|
||||||
|
Authentifizierte Portalpfade verwenden stabile Schlüssel aus der serverseitigen Editorial-ID. Registrierung verwendet einen SHA-256-Schlüssel aus normalisierter E-Mail und einer vom Reverse Proxy gesetzten Clientadresse; Rohdaten werden nicht gespeichert. Eine Überschreitung liefert 429 und `Retry-After`. Better Auth erhält explizite Produktionsregeln für Anmeldung und Passwort-Reset.
|
||||||
|
|
||||||
|
## Fehlerbehandlung
|
||||||
|
|
||||||
|
- Autorisierungsfehler verraten weder Asset-Existenz noch Fremdzugriff.
|
||||||
|
- Abrechnungsfehler löschen keine Historie.
|
||||||
|
- Ein ungültiger oder verbrauchter Passwort-Reset-Link zeigt keine falsche Erfolgsmeldung.
|
||||||
|
- E-Mail-Versandfehler ändern nicht den bereits atomar finalisierten Report.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
Jede Verhaltensänderung beginnt mit einem reproduzierenden RED-Test. Danach laufen fokussierte Tests, die vollständige deterministische Suite, Typecheck, Lint, Drizzle-Check und Produktionsbuild. Testcontainers-/E2E-Tests werden ausgeführt, sofern Docker verfügbar ist; andernfalls bleibt der externe Blocker dokumentiert.
|
||||||
|
|
||||||
|
## AGB-Übergabe
|
||||||
|
|
||||||
|
Der AGB-/Lizenzbedingungen-Entwurf wird getrennt von der Portalimplementierung erstellt. Er ist eine Arbeitsvorlage für die Hauptwebsite, enthält markierte Betreiber-/Vergütungsplatzhalter und muss vor Veröffentlichung anwaltlich geprüft werden.
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# Session Expiry and Error Recovery Design
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Refreshing a protected page after the session expires must not produce the
|
||||||
|
generic Next.js server error screen. Users must be returned to the existing
|
||||||
|
sign-in page, while genuine unexpected rendering failures receive a branded
|
||||||
|
recovery screen.
|
||||||
|
|
||||||
|
## Root Cause
|
||||||
|
|
||||||
|
The admin and editorial layouts call principal guards during server rendering.
|
||||||
|
An expired session causes `PrincipalAuthorizationError` with code
|
||||||
|
`AUTHENTICATION_REQUIRED`. Neither protected layout handles this expected
|
||||||
|
state, and the application has no route-level `error.tsx`, so Next.js renders
|
||||||
|
its generic production error page.
|
||||||
|
|
||||||
|
## Expected Authentication Handling
|
||||||
|
|
||||||
|
A small server-only page-access boundary executes the existing principal guard.
|
||||||
|
It handles only `PrincipalAuthorizationError("AUTHENTICATION_REQUIRED")` by
|
||||||
|
calling `redirect("/anmelden")`. Every other authorization or infrastructure
|
||||||
|
error is rethrown unchanged.
|
||||||
|
|
||||||
|
Both `src/app/admin/layout.tsx` and `src/app/redaktion/layout.tsx` use this
|
||||||
|
boundary. API routes retain their existing HTTP error behavior. Authentication,
|
||||||
|
session duration and account status rules are not changed.
|
||||||
|
|
||||||
|
## Unexpected Error Recovery
|
||||||
|
|
||||||
|
`src/app/error.tsx` provides a client-side route error boundary for unexpected
|
||||||
|
rendering failures below the root layout. It follows the portal's black-and-
|
||||||
|
white visual language and contains:
|
||||||
|
|
||||||
|
- the heading `Diese Seite konnte nicht geladen werden.`;
|
||||||
|
- a short instruction to retry or sign in again;
|
||||||
|
- `Erneut versuchen`, which invokes Next.js' supplied `reset()` callback;
|
||||||
|
- `Zur Anmeldung`, which navigates directly to `/anmelden`.
|
||||||
|
|
||||||
|
The page does not expose stack traces, database errors or the Next.js error
|
||||||
|
digest. It does not turn authorization failures other than an expired session
|
||||||
|
into login redirects; those remain visible as unexpected failures for diagnosis.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
Automated tests prove that:
|
||||||
|
|
||||||
|
- an expired page session redirects exactly to `/anmelden`;
|
||||||
|
- non-authentication errors are rethrown;
|
||||||
|
- the error boundary renders both recovery controls;
|
||||||
|
- `Erneut versuchen` calls `reset()` once;
|
||||||
|
- `Zur Anmeldung` links exactly to `/anmelden`.
|
||||||
|
|
||||||
|
The complete deterministic suite, typecheck, lint and production build must
|
||||||
|
remain green. No database migration or new dependency is required.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
|
||||||
|
- Changing session expiry duration.
|
||||||
|
- Automatically retrying database or Immich failures.
|
||||||
|
- Changing API response status codes.
|
||||||
|
- Creating a separate public home-page recovery action.
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# Download aus Suchergebnissen – Design
|
||||||
|
|
||||||
|
Stand: 12. August 2026
|
||||||
|
Status: fachlich freigegeben
|
||||||
|
|
||||||
|
## Ziel
|
||||||
|
|
||||||
|
Redaktionen können ein Foto direkt aus der albumübergreifenden Suche genauso
|
||||||
|
herunterladen wie aus einer einzelnen Albumansicht. Der bestehende Dialog für
|
||||||
|
neue Nutzungen und kostenfreie Wiederholungsdownloads wird unverändert
|
||||||
|
wiederverwendet.
|
||||||
|
|
||||||
|
## Ursache
|
||||||
|
|
||||||
|
Die globale Suchseite lädt bereits die serverseitigen Downloadoptionen und
|
||||||
|
rendert dieselbe `PhotoGallery` wie die Albumansicht. Der Downloadbutton wird
|
||||||
|
jedoch nur angezeigt, wenn für den Treffer eine freigegebene Album-ID bekannt
|
||||||
|
ist. Immich liefert im Ergebnis von `POST /search/metadata` nicht zuverlässig
|
||||||
|
eine `albums`-Zuordnung pro Asset. Dadurch fehlt der Galerie bei einzelnen oder
|
||||||
|
allen Suchtreffern der notwendige Albumkontext und sie blendet den Button aus.
|
||||||
|
|
||||||
|
## Lösung
|
||||||
|
|
||||||
|
Die bestehende albumbezogene Suche im Portal kennt für jeden Immich-Aufruf
|
||||||
|
bereits die serverseitig geprüfte Album-ID. Wenn Immich einen Treffer ohne diese
|
||||||
|
Albumzuordnung zurückgibt, ergänzt der Albumkatalog den Treffer um die geprüfte
|
||||||
|
Album-ID, über die er gefunden wurde.
|
||||||
|
|
||||||
|
Die Galerie erhält dadurch auch in der globalen Suche einen gültigen
|
||||||
|
`activeAlbumId` und zeigt den vorhandenen `UsageDialog`:
|
||||||
|
|
||||||
|
- direkt auf der Fotokarte;
|
||||||
|
- in der vergrößerten Lightbox;
|
||||||
|
- mit dem redaktionsbezogenen Preis;
|
||||||
|
- mit früheren Nutzungen des Bildes;
|
||||||
|
- mit derselben API-, Berechtigungs- und Abrechnungslogik wie innerhalb eines
|
||||||
|
Albums.
|
||||||
|
|
||||||
|
Bereits von Immich gelieferte Albumdaten bleiben erhalten. Es werden keine
|
||||||
|
zusätzlichen Immich-Anfragen pro Foto eingeführt.
|
||||||
|
|
||||||
|
## Sicherheit und Fehlerverhalten
|
||||||
|
|
||||||
|
Die ergänzte Album-ID stammt ausschließlich aus der serverseitig ermittelten
|
||||||
|
Liste aktuell freigegebener Alben. Browserdaten werden nicht als
|
||||||
|
Berechtigungsnachweis verwendet. Die bestehende Download-API prüft Album,
|
||||||
|
Asset, Redaktion und Nutzung weiterhin erneut, bevor ein Original ausgeliefert
|
||||||
|
wird.
|
||||||
|
|
||||||
|
Ist kein freigegebenes Album vorhanden oder schlägt die Immich-Suche fehl,
|
||||||
|
bleibt das bestehende Leer- beziehungsweise Fehlerverhalten unverändert.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
Ein Katalogtest bildet den Fehlerfall nach: Immich liefert in einer
|
||||||
|
albumbezogenen Suche ein Asset mit leerem `albums`-Array. Der Albumkatalog muss
|
||||||
|
dieses Asset mit der serverseitig angefragten Album-ID zurückgeben.
|
||||||
|
|
||||||
|
Ein Galerietest bestätigt, dass ein globaler Suchtreffer mit ergänzter Album-ID
|
||||||
|
den Button `Original laden` sowohl in der Kartenansicht als auch nach Öffnen der
|
||||||
|
Lightbox anbietet. Anschließend werden die vollständigen Quelltests,
|
||||||
|
TypeScript, ESLint, Drizzle und der Produktions-Build ausgeführt.
|
||||||
|
|
||||||
|
## Umfang
|
||||||
|
|
||||||
|
Voraussichtlich geändert werden ausschließlich:
|
||||||
|
|
||||||
|
- `src/modules/albums/catalog.ts`
|
||||||
|
- `src/modules/albums/catalog.test.ts`
|
||||||
|
- `src/modules/albums/catalog-content.test.tsx`
|
||||||
|
|
||||||
|
Die Download-API, Abrechnung, Datenbank und Migrationen werden nicht verändert.
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
# Kalender mit Kategorien, Vormerken und neues Admin-Dashboard (Paket 1, v2.3.0)
|
||||||
|
|
||||||
|
Stand: 2026-11-30. Paket 2 (Sakani-Feinschliff: Pagination, Stepper, Blog-Listing-Albenübersicht, Toasts, Lade-Zustände, Audit, Redaktionen-Tabelle) folgt separat.
|
||||||
|
|
||||||
|
## Warum
|
||||||
|
|
||||||
|
Die meisten Redaktionen sind bei Spielen nicht vor Ort, sie wollen die Bilder. "Bin da / Bin nicht da" passt deshalb nicht. Redaktionen sollen ein Spiel vormerken können, auch bevor das Album existiert, und sehen, ob sie es über eine Auto-Regel ohnehin bekommen. Der Admin will Termine nach Sportart/Liga einordnen und den Kalender als farbige Monatsansicht sehen. Das Dashboard zeigt bisher nur Umsatz und Downloads; inzwischen gibt es Kalender, Statistiken und Rechnungsversand.
|
||||||
|
|
||||||
|
## Ziele
|
||||||
|
|
||||||
|
- Kategorien (Name + Farbe) im Admin anlegen, als Liste speichern, beim Termin auswählen.
|
||||||
|
- Kalender als Sakani `MonthCalendar` (Redaktion und Admin), Termine in Kategoriefarbe, Legende darunter.
|
||||||
|
- Redaktion: "Zu meinen Alben hinzufügen" (Vormerken). Album schon da: sofort freigeschaltet. Sonst automatisch, sobald es auftaucht.
|
||||||
|
- Sichtbar, wenn eine Auto-Regel den Zugriff ohnehin gibt.
|
||||||
|
- Admin-Dashboard mit Aufgaben, nächsten Terminen, Kurzzahlen und letzten Aktivitäten.
|
||||||
|
|
||||||
|
## Nicht-Ziele
|
||||||
|
|
||||||
|
- Termine bearbeiten oder per Drag & Drop verschieben (wie bisher: anlegen und löschen).
|
||||||
|
- Freie Hex-Farben (Sakani-Kalender kennt 8 Farben; nur die ziehen im Dunkelmodus mit).
|
||||||
|
- Anfrage-Workflow mit Admin-Freigabe (bewusst Variante "Vormerken" gewählt).
|
||||||
|
- Paket-2-Themen (Toasts usw.); neue Formulare nutzen vorerst das bestehende Alert-Muster.
|
||||||
|
|
||||||
|
## Anti-Ziele
|
||||||
|
|
||||||
|
- Vormerken darf nie Zugriff auf ein Album geben, das nicht über einen vom Admin angelegten Termin verknüpft ist (gleiche Vertrauensgrenze wie die heutige Selbstbedienung).
|
||||||
|
- Kein Verlust von Auto-Regel- oder Admin-Freigaben beim Löschen von Terminen (nur `self_service` wird entzogen, wie heute).
|
||||||
|
|
||||||
|
## Ansätze
|
||||||
|
|
||||||
|
1. **Gewählt: eigene Tabelle `event_reservations`, Freischaltung durch den bestehenden Auto-Regel-Job.** Der Job läuft ohnehin alle 120 s (`AUTO_RULE_SYNC_INTERVAL_SECONDS`) und kennt die Immich-Albenliste. Er löst offene Vormerkungen ein, sobald das Album zum Termin passt. Existiert das Album beim Vormerken schon, wird sofort freigeschaltet.
|
||||||
|
2. Verworfen: Freischaltung erst beim nächsten Seitenaufruf der Redaktion. Kein Job nötig, aber das Album fehlt in "Meine Alben", bis die Redaktion zufällig den Kalender öffnet.
|
||||||
|
3. Verworfen: `event_responses` umdeuten (Status `attending` = vorgemerkt). Spart eine Tabelle, aber Name und Bedeutung passen nicht mehr, und `granted_at` fehlt. Da 2.1 noch nicht deployt ist, gibt es keine echten Zusagen, die erhalten werden müssten.
|
||||||
|
|
||||||
|
## Datenmodell (neue Drizzle-Migration, generiert)
|
||||||
|
|
||||||
|
- `event_categories`: `id` uuid, `name` text (unique, case-insensitive über `lower(name)`), `color` text mit Check auf `blue|green|orange|purple|teal|gold|red|neutral`, `created_at`, `created_by_user_id`.
|
||||||
|
- `calendar_events.category_id` uuid null, FK auf `event_categories` mit `ON DELETE RESTRICT` (Kategorie nur löschbar, wenn kein Termin sie nutzt; UI zeigt das).
|
||||||
|
- `event_reservations`: `id`, `event_id` FK, `editorial_account_id` FK restrict, `created_at`, `granted_at` null; unique (`event_id`, `editorial_account_id`).
|
||||||
|
- `event_responses` wird entfernt (keine Produktionsdaten, 2.1 nicht deployt).
|
||||||
|
- Versionshinweise 2.3.0 als eigene Custom-Migration (Seed, `ON CONFLICT DO NOTHING`).
|
||||||
|
|
||||||
|
## Verhalten
|
||||||
|
|
||||||
|
**Kategorien (Admin, `/admin/kalender/kategorien`, verlinkt vom Kalender):** Liste mit Farbpunkt, Name, Anzahl Termine, Löschen (deaktiviert mit Hinweis, wenn benutzt). Formular: Name + Farbauswahl (8 Farben als Auswahl mit Farbvorschau). Audit: `event_category_created/deleted`.
|
||||||
|
|
||||||
|
**Termin anlegen:** zusätzliches Feld "Kategorie" (Auswahl, "Ohne Kategorie" erlaubt, dann Farbe Grau).
|
||||||
|
|
||||||
|
**Redaktions-Kalender (`/redaktion/kalender`):**
|
||||||
|
- `MonthCalendar` mit Monatsnavigation, Termine als Chips in Kategoriefarbe, Legende aller Kategorien darunter.
|
||||||
|
- Klick auf Termin: Detailkarte (Titel, Datum, Kategorie, Status, Aktion).
|
||||||
|
- Darunter Liste "Kommende Termine" mit denselben Aktionen (auf dem Handy die Hauptansicht, weil das Monatsraster dort eng wird).
|
||||||
|
- Aktion je Termin, in dieser Reihenfolge geprüft:
|
||||||
|
1. Zugriff besteht: Badge "Freigeschaltet" (bzw. "Automatisch freigegeben" bei `auto_rule`) + "Album öffnen".
|
||||||
|
2. Auto-Regel passt (ein Stichwort der Redaktion steckt im Termintitel oder im verknüpften Albumnamen, gleiche Logik wie der Job): Badge "Automatisch freigegeben (Auto-Regel)", kein Button.
|
||||||
|
3. Vorgemerkt, noch kein Album: Badge "Vorgemerkt" + "Vormerkung entfernen".
|
||||||
|
4. Sonst: Button "Zu meinen Alben hinzufügen".
|
||||||
|
- Vergangene Termine (bis 30 Tage, wie heute) bleiben vormerkbar, solange das Album verknüpfbar ist.
|
||||||
|
|
||||||
|
**Service:**
|
||||||
|
- `reserve(eventId, editorial)`: Rate-Limit (bestehende `calendarSelfGrantPolicy`), Reservierung anlegen (idempotent). Passt ein Album: `grantAlbum(source: self_service)`, `granted_at` setzen, Audit `album_self_granted`. Sonst Audit `event_reserved`.
|
||||||
|
- `unreserve(eventId, editorial)`: nur offene Vormerkungen (ohne `granted_at`) löschbar. Audit `event_reservation_removed`.
|
||||||
|
- `resolvePendingReservations()`: im Scheduler-Tick nach dem Auto-Regel-Sync. Für jede offene Vormerkung: Album matchen, freischalten, `granted_at` setzen. Fehler werden geloggt, nicht geworfen (wie der Auto-Regel-Sync).
|
||||||
|
- `deleteEvent`: löscht Vormerkungen mit und entzieht `self_service`-Freigaben wie heute.
|
||||||
|
|
||||||
|
**Admin-Kalender (`/admin/kalender`):** `MonthCalendar` + Legende; Liste aller Termine mit Kategorie-Badge, Albumstatus und Vormerkungen (Anzahl + Namen, je mit Status "vorgemerkt" / "freigeschaltet") statt Zusagen.
|
||||||
|
|
||||||
|
**Admin-Dashboard (`/admin`):**
|
||||||
|
1. "Zu erledigen": Redaktionen in `pending_approval`, finalisierte Abrechnungen ohne Rechnungs-PDF, Rechnungsmails mit Status `failed`, offener Umsatz im laufenden Quartal. Jede Zeile verlinkt zur passenden Seite; leere Aufgaben werden ausgeblendet, ganz leer: "Alles erledigt".
|
||||||
|
2. "Nächste Termine": die nächsten 5 mit Kategorie, Vormerkungen und Albumstatus.
|
||||||
|
3. Kurzzahlen 30 Tage (Downloads, Umsatz, Album-Aufrufe) mit Link zu `/admin/statistiken`, Download-Diagramm bleibt.
|
||||||
|
4. "Letzte Aktivitäten" (aus `activity_events`, wie auf der Statistikseite, 8 Einträge).
|
||||||
|
|
||||||
|
## Sicherheit
|
||||||
|
|
||||||
|
- Alle neuen Actions mit `requireAdmin` / `requireActiveEditorial`; Vormerken mit Rate-Limit.
|
||||||
|
- Freischaltung nur über `albumGrantService` mit `source: 'self_service'` und Audit.
|
||||||
|
- Kategorienamen als React-Text rendern.
|
||||||
|
|
||||||
|
## Versionierung
|
||||||
|
|
||||||
|
v2.3.0 (Minor, neues Feature). Popup-Version und Notes bumpen, Seeds für admin + editorial.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
- Unit: Kategorie-Validierung, Aktions-Status-Logik (Reihenfolge oben), `reserve`/`unreserve`/`resolvePendingReservations`, Auto-Regel-Vorhersage.
|
||||||
|
- DB-Test: Migration (Tabellen, Constraints, `event_responses` weg).
|
||||||
|
- Click-Through: Kategorie anlegen, Termin mit Kategorie, Monatsansicht + Legende, Vormerken ohne Album (Status "Vorgemerkt"), Album erscheint (Mock-Immich), Job löst ein, "Album öffnen"; Auto-Regel-Fall; Dashboard-Aufgaben.
|
||||||
|
|
||||||
|
## Dem Builder überlassen
|
||||||
|
|
||||||
|
- Genaue Komponentenwahl für die Detailkarte (Sakani `Popover` oder Karte unter dem Kalender).
|
||||||
|
- Datumsumrechnung `eventDate` (ISO-Tag) zu `Date` für `MonthCalendar` ohne Zeitzonenverschiebung (lokales Mitternacht-Datum, `allDay: true`).
|
||||||
|
- Texte im Detail, solange ohne Em-Dashes und aus Nutzersicht.
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1 @@
|
|||||||
|
CREATE INDEX "usages_created_at_idx" ON "usages" USING btree ("created_at");
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE "two_factor" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"user_id" uuid NOT NULL,
|
||||||
|
"secret" text NOT NULL,
|
||||||
|
"backup_codes" text,
|
||||||
|
CONSTRAINT "two_factor_user_id_unique" UNIQUE("user_id")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "user" ADD COLUMN "two_factor_enabled" boolean DEFAULT false NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "two_factor" ADD CONSTRAINT "two_factor_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "two_factor" ADD COLUMN "verified" boolean DEFAULT false NOT NULL;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "two_factor" ADD COLUMN "failed_verification_count" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "two_factor" ADD COLUMN "locked_until" timestamp with time zone;
|
||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,97 @@
|
|||||||
|
{
|
||||||
|
"version": "7",
|
||||||
|
"dialect": "postgresql",
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"idx": 0,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786299825190,
|
||||||
|
"tag": "0000_initial",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 1,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786303607054,
|
||||||
|
"tag": "0001_editorial_approval_notice",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 2,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786354215684,
|
||||||
|
"tag": "0002_accounting_intents",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 3,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786358492749,
|
||||||
|
"tag": "0003_stream_delivery",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 4,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786363479515,
|
||||||
|
"tag": "0004_download_history_indexes",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 5,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786379282947,
|
||||||
|
"tag": "0005_rate_limits",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 6,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786410282719,
|
||||||
|
"tag": "0006_chubby_screwball",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 7,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786410724623,
|
||||||
|
"tag": "0007_amused_franklin_storm",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 8,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786411419497,
|
||||||
|
"tag": "0008_overjoyed_wrecking_crew",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 9,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1786455754414,
|
||||||
|
"tag": "0009_usage_created_at_index",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 10,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1787617368189,
|
||||||
|
"tag": "0010_two-factor",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 11,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1787620365940,
|
||||||
|
"tag": "0011_two-factor-verified",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 12,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1787621254728,
|
||||||
|
"tag": "0012_two-factor-plugin-fields",
|
||||||
|
"breakpoints": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,265 @@
|
|||||||
|
CREATE TYPE "public"."portal_role" AS ENUM('ADMIN', 'EDITORIAL');--> statement-breakpoint
|
||||||
|
CREATE TYPE "public"."report_status" AS ENUM('draft', 'final', 'cancelled');--> statement-breakpoint
|
||||||
|
CREATE TYPE "public"."account_status" AS ENUM('pending_email', 'pending_approval', 'active', 'suspended', 'rejected');--> statement-breakpoint
|
||||||
|
CREATE TYPE "public"."download_status" AS ENUM('authorized', 'streaming', 'completed', 'failed_before_delivery', 'interrupted');--> statement-breakpoint
|
||||||
|
CREATE TYPE "public"."usage_billing_status" AS ENUM('open', 'billed', 'reopened', 'voided');--> statement-breakpoint
|
||||||
|
CREATE TABLE "album_grants" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"editorial_account_id" uuid NOT NULL,
|
||||||
|
"immich_album_id" text NOT NULL,
|
||||||
|
"granted_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"revoked_at" timestamp with time zone,
|
||||||
|
"granted_by_user_id" uuid,
|
||||||
|
CONSTRAINT "album_grants_immich_album_id_uuid_check" CHECK ("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}$')
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "audit_events" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"event_type" text NOT NULL,
|
||||||
|
"actor_user_id" uuid,
|
||||||
|
"actor_type" text DEFAULT 'system' NOT NULL,
|
||||||
|
"entity_type" text NOT NULL,
|
||||||
|
"entity_id" text NOT NULL,
|
||||||
|
"previous_values" jsonb,
|
||||||
|
"new_values" jsonb,
|
||||||
|
"occurred_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"request_id" uuid
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "account" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"account_id" text NOT NULL,
|
||||||
|
"provider_id" text NOT NULL,
|
||||||
|
"user_id" uuid NOT NULL,
|
||||||
|
"access_token" text,
|
||||||
|
"refresh_token" text,
|
||||||
|
"id_token" text,
|
||||||
|
"access_token_expires_at" timestamp with time zone,
|
||||||
|
"refresh_token_expires_at" timestamp with time zone,
|
||||||
|
"scope" text,
|
||||||
|
"password" text,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "session" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"expires_at" timestamp with time zone NOT NULL,
|
||||||
|
"token" text NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"ip_address" text,
|
||||||
|
"user_agent" text,
|
||||||
|
"user_id" uuid NOT NULL,
|
||||||
|
CONSTRAINT "session_token_unique" UNIQUE("token")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "two_factor" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"user_id" uuid NOT NULL,
|
||||||
|
"secret" text NOT NULL,
|
||||||
|
"backup_codes" text,
|
||||||
|
"verified" boolean DEFAULT false NOT NULL,
|
||||||
|
"failed_verification_count" integer DEFAULT 0 NOT NULL,
|
||||||
|
"locked_until" timestamp with time zone,
|
||||||
|
CONSTRAINT "two_factor_user_id_unique" UNIQUE("user_id")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "user" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"email" text NOT NULL,
|
||||||
|
"email_verified" boolean DEFAULT false NOT NULL,
|
||||||
|
"image" text,
|
||||||
|
"role" "portal_role" DEFAULT 'EDITORIAL' NOT NULL,
|
||||||
|
"two_factor_enabled" boolean DEFAULT false NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
CONSTRAINT "user_email_unique" UNIQUE("email")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "verification" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"identifier" text NOT NULL,
|
||||||
|
"value" text NOT NULL,
|
||||||
|
"expires_at" timestamp with time zone NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "album_auto_rules" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"editorial_account_id" uuid NOT NULL,
|
||||||
|
"keyword" text NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_by_user_id" uuid
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "billing_report_items" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"billing_report_id" uuid NOT NULL,
|
||||||
|
"usage_id" uuid NOT NULL,
|
||||||
|
"immich_asset_id_snapshot" text NOT NULL,
|
||||||
|
"filename_snapshot" text NOT NULL,
|
||||||
|
"album_name_snapshot" text NOT NULL,
|
||||||
|
"purpose_snapshot" text NOT NULL,
|
||||||
|
"internal_reference_snapshot" text,
|
||||||
|
"price_cents" integer NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "billing_reports" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"report_number" integer NOT NULL,
|
||||||
|
"editorial_account_id" uuid NOT NULL,
|
||||||
|
"period_starts_at" timestamp with time zone NOT NULL,
|
||||||
|
"period_ends_at" timestamp with time zone NOT NULL,
|
||||||
|
"billing_address_snapshot" jsonb NOT NULL,
|
||||||
|
"invoice_number" text,
|
||||||
|
"net_total_cents" integer NOT NULL,
|
||||||
|
"flatrate_cents_snapshot" integer,
|
||||||
|
"status" "report_status" DEFAULT 'draft' NOT NULL,
|
||||||
|
"pdf" "bytea",
|
||||||
|
"pdf_sha256" varchar(64),
|
||||||
|
"created_by_user_id" uuid NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"finalized_at" timestamp with time zone,
|
||||||
|
"cancelled_at" timestamp with time zone,
|
||||||
|
"cancellation_reason" text,
|
||||||
|
"cancelled_by_user_id" uuid,
|
||||||
|
CONSTRAINT "billing_reports_pdf_sha256_hex_check" CHECK ("billing_reports"."pdf_sha256" ~ '^[0-9a-f]{64}$'),
|
||||||
|
CONSTRAINT "billing_reports_final_pdf_check" CHECK ("billing_reports"."status" <> 'final' OR ("billing_reports"."pdf" IS NOT NULL AND "billing_reports"."pdf_sha256" IS NOT NULL))
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "billing_address_versions" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"editorial_account_id" uuid NOT NULL,
|
||||||
|
"company_name" text NOT NULL,
|
||||||
|
"contact_name" text NOT NULL,
|
||||||
|
"address_line_1" text NOT NULL,
|
||||||
|
"address_line_2" text,
|
||||||
|
"postal_code" text NOT NULL,
|
||||||
|
"city" text NOT NULL,
|
||||||
|
"country_code" text NOT NULL,
|
||||||
|
"valid_from" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"superseded_by_id" uuid,
|
||||||
|
"created_by_user_id" uuid,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "editorial_accounts" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"user_id" uuid NOT NULL,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"contact_name" text NOT NULL,
|
||||||
|
"login_email" text NOT NULL,
|
||||||
|
"status" "account_status" DEFAULT 'pending_email' NOT NULL,
|
||||||
|
"current_price_cents" integer,
|
||||||
|
"flatrate_active" boolean DEFAULT false NOT NULL,
|
||||||
|
"flatrate_price_cents" integer,
|
||||||
|
"flatrate_asset_limit" integer,
|
||||||
|
"approval_notice_status" text DEFAULT 'not_requested' NOT NULL,
|
||||||
|
"current_billing_address_version_id" uuid,
|
||||||
|
"email_verified_at" timestamp with time zone,
|
||||||
|
"accepted_terms_version" text,
|
||||||
|
"accepted_terms_at" timestamp with time zone,
|
||||||
|
"privacy_acknowledged_at" timestamp with time zone,
|
||||||
|
"archived_at" timestamp with time zone,
|
||||||
|
"archived_by_user_id" uuid,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
CONSTRAINT "editorial_accounts_user_id_unique" UNIQUE("user_id"),
|
||||||
|
CONSTRAINT "editorial_accounts_login_email_unique" UNIQUE("login_email")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "lightbox_items" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"editorial_account_id" uuid NOT NULL,
|
||||||
|
"asset_id" text NOT NULL,
|
||||||
|
"added_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "rate_limits" (
|
||||||
|
"key" text NOT NULL,
|
||||||
|
"window_boundary" integer NOT NULL,
|
||||||
|
"count" integer DEFAULT 1 NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
CONSTRAINT "rate_limits_key_window_boundary_pk" PRIMARY KEY("key","window_boundary")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "download_events" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"editorial_account_id" uuid NOT NULL,
|
||||||
|
"usage_id" uuid NOT NULL,
|
||||||
|
"immich_asset_id" text NOT NULL,
|
||||||
|
"authorized_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"started_at" timestamp with time zone,
|
||||||
|
"completed_at" timestamp with time zone,
|
||||||
|
"status" "download_status" DEFAULT 'authorized' NOT NULL,
|
||||||
|
"transferred_bytes" bigint,
|
||||||
|
"repeat_download_note" text,
|
||||||
|
"request_id" uuid NOT NULL,
|
||||||
|
"idempotency_key" text NOT NULL,
|
||||||
|
"intent_kind" text DEFAULT 'new_usage' NOT NULL,
|
||||||
|
"request_fingerprint" varchar(64) NOT NULL,
|
||||||
|
"legacy_intent" boolean DEFAULT false NOT NULL,
|
||||||
|
CONSTRAINT "download_events_intent_kind_check" CHECK ("download_events"."intent_kind" in ('new_usage', 'repeat_download', 'legacy')),
|
||||||
|
CONSTRAINT "download_events_request_fingerprint_hex_check" CHECK ("download_events"."request_fingerprint" ~ '^[0-9a-f]{64}$'),
|
||||||
|
CONSTRAINT "download_events_canonical_idempotency_key_check" CHECK ("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}$'),
|
||||||
|
CONSTRAINT "download_events_canonical_immich_asset_id_check" CHECK ("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}$')
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "usages" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"editorial_account_id" uuid NOT NULL,
|
||||||
|
"immich_asset_id" text NOT NULL,
|
||||||
|
"filename_snapshot" text NOT NULL,
|
||||||
|
"immich_album_id_snapshot" text NOT NULL,
|
||||||
|
"album_name_snapshot" text NOT NULL,
|
||||||
|
"purpose" text NOT NULL,
|
||||||
|
"internal_reference" text,
|
||||||
|
"price_cents" integer NOT NULL,
|
||||||
|
"billing_status" "usage_billing_status" DEFAULT 'open' NOT NULL,
|
||||||
|
"billing_report_id" uuid,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
CONSTRAINT "usages_canonical_immich_asset_id_check" CHECK ("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}$'),
|
||||||
|
CONSTRAINT "usages_canonical_immich_album_id_check" CHECK ("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}$')
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "album_grants" ADD CONSTRAINT "album_grants_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 "album_grants" ADD CONSTRAINT "album_grants_granted_by_user_id_user_id_fk" FOREIGN KEY ("granted_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "audit_events" ADD CONSTRAINT "audit_events_actor_user_id_user_id_fk" FOREIGN KEY ("actor_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "two_factor" ADD CONSTRAINT "two_factor_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "album_auto_rules" ADD CONSTRAINT "album_auto_rules_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 "album_auto_rules" ADD CONSTRAINT "album_auto_rules_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 "billing_report_items" ADD CONSTRAINT "billing_report_items_billing_report_id_billing_reports_id_fk" FOREIGN KEY ("billing_report_id") REFERENCES "public"."billing_reports"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "billing_report_items" ADD CONSTRAINT "billing_report_items_usage_id_usages_id_fk" FOREIGN KEY ("usage_id") REFERENCES "public"."usages"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "billing_reports" ADD CONSTRAINT "billing_reports_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 "billing_reports" ADD CONSTRAINT "billing_reports_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 "billing_reports" ADD CONSTRAINT "billing_reports_cancelled_by_user_id_user_id_fk" FOREIGN KEY ("cancelled_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "billing_address_versions" ADD CONSTRAINT "billing_address_versions_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 "billing_address_versions" ADD CONSTRAINT "billing_address_versions_superseded_by_id_billing_address_versions_id_fk" FOREIGN KEY ("superseded_by_id") REFERENCES "public"."billing_address_versions"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "billing_address_versions" ADD CONSTRAINT "billing_address_versions_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 "editorial_accounts" ADD CONSTRAINT "editorial_accounts_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "editorial_accounts" ADD CONSTRAINT "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk" FOREIGN KEY ("current_billing_address_version_id") REFERENCES "public"."billing_address_versions"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "editorial_accounts" ADD CONSTRAINT "editorial_accounts_archived_by_user_id_user_id_fk" FOREIGN KEY ("archived_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "lightbox_items" ADD CONSTRAINT "lightbox_items_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "download_events" ADD CONSTRAINT "download_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
|
||||||
|
ALTER TABLE "download_events" ADD CONSTRAINT "download_events_usage_id_usages_id_fk" FOREIGN KEY ("usage_id") REFERENCES "public"."usages"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE "usages" ADD CONSTRAINT "usages_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 "usages" ADD CONSTRAINT "usages_billing_report_id_billing_reports_id_fk" FOREIGN KEY ("billing_report_id") REFERENCES "public"."billing_reports"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||||
|
CREATE INDEX "album_grants_editorial_account_id_idx" ON "album_grants" USING btree ("editorial_account_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "album_grants_immich_album_id_idx" ON "album_grants" USING btree ("immich_album_id");--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "album_grants_editorial_active_album_unique" ON "album_grants" USING btree ("editorial_account_id",lower("immich_album_id")) WHERE "album_grants"."revoked_at" is null;--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "album_auto_rules_editorial_account_id_keyword_idx" ON "album_auto_rules" USING btree ("editorial_account_id",lower("keyword"));--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "billing_report_items_report_usage_unique" ON "billing_report_items" USING btree ("billing_report_id","usage_id");--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "billing_reports_report_number_unique" ON "billing_reports" USING btree ("report_number");--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "billing_reports_invoice_number_unique" ON "billing_reports" USING btree ("invoice_number");--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "lightbox_items_editorial_asset_idx" ON "lightbox_items" USING btree ("editorial_account_id","asset_id");--> statement-breakpoint
|
||||||
|
CREATE INDEX "download_events_editorial_authorized_id_idx" ON "download_events" USING btree ("editorial_account_id","authorized_at" DESC NULLS LAST,"id" DESC NULLS LAST);--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "download_events_editorial_idempotency_key_unique" ON "download_events" USING btree ("editorial_account_id","idempotency_key");--> statement-breakpoint
|
||||||
|
CREATE INDEX "usages_editorial_created_id_idx" ON "usages" USING btree ("editorial_account_id","created_at" DESC NULLS LAST,"id" DESC NULLS LAST);--> statement-breakpoint
|
||||||
|
CREATE INDEX "usages_created_at_idx" ON "usages" USING btree ("created_at");
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
CREATE TABLE "announcements" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"message" text NOT NULL,
|
||||||
|
"event_date" date NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_by_user_id" uuid
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "announcements" ADD CONSTRAINT "announcements_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;
|
||||||
@@ -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;
|
||||||
@@ -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;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- Custom SQL migration file, put your code below! --
|
||||||
|
INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id")
|
||||||
|
VALUES
|
||||||
|
('2.2.1', 'admin', 'Abrechnungen laufen jetzt immer quartalsweise: Die Abrechnungsseite öffnet direkt das aktuelle Quartal, die Monatsansicht entfällt. Das Logo in der Seitenleiste ist im dunklen Design wieder sichtbar. Die Formulare für Kalender und Versionshinweise nutzen jetzt das einheitliche Portal-Design.', NULL),
|
||||||
|
('2.2.1', 'editorial', 'Die Rückmeldung zu Kalender-Terminen (Bin da / Bin nicht da) passt sich jetzt dem hellen und dunklen Design an, und das Logo in der Seitenleiste ist im dunklen Design wieder sichtbar.', NULL)
|
||||||
|
ON CONFLICT ("version", "audience") DO NOTHING;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- Custom SQL migration file, put your code below! --
|
||||||
|
INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id")
|
||||||
|
VALUES
|
||||||
|
('2.2.2', 'admin', 'Versionshistorie: Unter /admin/versionen sind alle Hinweise jetzt nach Version gruppiert, neueste zuerst. Das Fenster „Was ist neu?“ verlinkt direkt auf die früheren Änderungen.', NULL),
|
||||||
|
('2.2.2', 'editorial', 'Neu: Unter Neuigkeiten steht die komplette Versionshistorie mit allen Änderungen seit Version 2.0. Das Fenster „Was ist neu?“ führt über „Frühere Änderungen ansehen“ direkt dorthin.', NULL)
|
||||||
|
ON CONFLICT ("version", "audience") DO NOTHING;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
CREATE TABLE "event_categories" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"color" text NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"created_by_user_id" uuid,
|
||||||
|
CONSTRAINT "event_categories_color_check" CHECK ("event_categories"."color" in ('blue', 'green', 'orange', 'purple', 'teal', 'gold', 'red', 'neutral'))
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "event_reservations" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"event_id" uuid NOT NULL,
|
||||||
|
"editorial_account_id" uuid NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"granted_at" timestamp with time zone
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "calendar_events" ADD COLUMN "category_id" uuid;--> statement-breakpoint
|
||||||
|
ALTER TABLE "event_categories" ADD CONSTRAINT "event_categories_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_reservations" ADD CONSTRAINT "event_reservations_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_reservations" ADD CONSTRAINT "event_reservations_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 UNIQUE INDEX "event_categories_name_lower_unique" ON "event_categories" USING btree (lower("name"));--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "event_reservations_event_editorial_unique" ON "event_reservations" USING btree ("event_id","editorial_account_id");--> statement-breakpoint
|
||||||
|
ALTER TABLE "calendar_events" ADD CONSTRAINT "calendar_events_category_id_event_categories_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."event_categories"("id") ON DELETE restrict ON UPDATE no action;
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
-- 1. Create the album_auto_rules table
|
|
||||||
CREATE TABLE IF NOT EXISTS "album_auto_rules" (
|
|
||||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
||||||
"editorial_account_id" uuid NOT NULL,
|
|
||||||
"keyword" text NOT NULL,
|
|
||||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
||||||
"created_by_user_id" uuid
|
|
||||||
);
|
|
||||||
|
|
||||||
DO $$ BEGIN
|
|
||||||
ALTER TABLE "album_auto_rules" ADD CONSTRAINT "album_auto_rules_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;
|
|
||||||
EXCEPTION
|
|
||||||
WHEN duplicate_object THEN null;
|
|
||||||
END $$;
|
|
||||||
|
|
||||||
DO $$ BEGIN
|
|
||||||
ALTER TABLE "album_auto_rules" ADD CONSTRAINT "album_auto_rules_created_by_user_id_users_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;
|
|
||||||
EXCEPTION
|
|
||||||
WHEN duplicate_object THEN null;
|
|
||||||
END $$;
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS "album_auto_rules_editorial_account_id_keyword_idx" ON "album_auto_rules" ("editorial_account_id", lower("keyword"));
|
|
||||||
|
|
||||||
-- 2. Add archived_at and archived_by_user_id to editorial_accounts
|
|
||||||
ALTER TABLE "editorial_accounts" ADD COLUMN "archived_at" timestamp with time zone;
|
|
||||||
ALTER TABLE "editorial_accounts" ADD COLUMN "archived_by_user_id" uuid;
|
|
||||||
|
|
||||||
DO $$ BEGIN
|
|
||||||
ALTER TABLE "editorial_accounts" ADD CONSTRAINT "editorial_accounts_archived_by_user_id_users_id_fk" FOREIGN KEY ("archived_by_user_id") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action;
|
|
||||||
EXCEPTION
|
|
||||||
WHEN duplicate_object THEN null;
|
|
||||||
END $$;
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE "event_responses" CASCADE;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- Custom SQL migration file, put your code below! --
|
||||||
|
INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id")
|
||||||
|
VALUES
|
||||||
|
('2.3.0', 'admin', 'Neu in 2.3: Kategorien (Name und Farbe) unter Kalender, Kategorien verwalten. Der Kalender ist jetzt eine Monatsansicht mit Legende. Statt Zusagen merken Redaktionen Termine vor; das Album wird automatisch freigeschaltet, sobald es in Immich erscheint. Neues Dashboard mit offenen Aufgaben, nächsten Terminen, Kurzzahlen und letzten Aktivitäten.', NULL),
|
||||||
|
('2.3.0', 'editorial', 'Neu in 2.3: Der Kalender ist jetzt eine Monatsansicht, farbig nach Sportart und Liga. Mit „Zu meinen Alben hinzufügen“ merken Sie ein Spiel vor; das Album wird automatisch freigeschaltet, sobald es da ist. Ob Sie ein Album über eine automatische Regel bekommen, sehen Sie direkt am Termin. Die Fotos im Album stehen jetzt in gleich großen Kacheln, zeilenweise von links nach rechts.', NULL)
|
||||||
|
ON CONFLICT ("version", "audience") DO NOTHING;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- Custom SQL migration file, put your code below! --
|
||||||
|
INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id")
|
||||||
|
VALUES
|
||||||
|
('2.4.0', 'admin', 'Neu in 2.4: Speichern und Ändern bestätigt das Portal mit einer kurzen Meldung, Fehler bei Abrechnungen sind verständlich formuliert. Redaktionen erscheinen als Tabelle mit Suche, Statusfilter und offenen Beträgen. Das Audit-Protokoll hat eine Ereignisauswahl, lesbare Bezeichnungen und aufklappbare Details. Die Registrierung zeigt den Ablauf in Schritten.', NULL),
|
||||||
|
('2.4.0', 'editorial', 'Neu in 2.4: Beim ZIP-Download vom Merkzettel laufen alle Bilder als neue Nutzung; nur bei schon geladenen Bildern wählen Sie zwischen neuer Nutzung und kostenloser Wiederholung. Die Albenübersicht zeigt große Vorschaubilder, unter den Fotos gibt es Seitenzahlen, und Bestätigungen erscheinen als kurze Meldung unten rechts.', NULL)
|
||||||
|
ON CONFLICT ("version", "audience") DO NOTHING;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- Custom SQL migration file, put your code below! --
|
||||||
|
INSERT INTO "release_notes" ("version", "audience", "body", "created_by_user_id")
|
||||||
|
VALUES
|
||||||
|
('2.4.1', 'admin', 'Ältere Alben übernehmen: Unter Kalender zeigt „Alben aus Immich anzeigen“ alle Alben im Format „Titel | TT.MM.JJJJ“, die noch keinen Termin haben. Auswählen, optional eine Kategorie setzen und übernehmen; Titel und Datum kommen aus dem Albumnamen.', NULL),
|
||||||
|
('2.4.1', 'editorial', 'Im Kalender stehen jetzt auch ältere Spiele. Sie können sie wie neue mit „Zu meinen Alben hinzufügen“ freischalten.', NULL)
|
||||||
|
ON CONFLICT ("version", "audience") DO NOTHING;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"id": "64eb37ed-2ab5-4c12-a8be-4375e8f6a732",
|
"id": "5ac645f2-0e76-4853-b029-724095bf1138",
|
||||||
"prevId": "00000000-0000-0000-0000-000000000000",
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
@@ -77,6 +77,28 @@
|
|||||||
"concurrently": false,
|
"concurrently": false,
|
||||||
"method": "btree",
|
"method": "btree",
|
||||||
"with": {}
|
"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": {
|
"foreignKeys": {
|
||||||
@@ -110,7 +132,12 @@
|
|||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
"uniqueConstraints": {},
|
"uniqueConstraints": {},
|
||||||
"policies": {},
|
"policies": {},
|
||||||
"checkConstraints": {},
|
"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}$'"
|
||||||
|
}
|
||||||
|
},
|
||||||
"isRLSEnabled": false
|
"isRLSEnabled": false
|
||||||
},
|
},
|
||||||
"public.audit_events": {
|
"public.audit_events": {
|
||||||
@@ -397,6 +424,86 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.user": {
|
||||||
"name": "user",
|
"name": "user",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -441,6 +548,13 @@
|
|||||||
"notNull": true,
|
"notNull": true,
|
||||||
"default": "'EDITORIAL'"
|
"default": "'EDITORIAL'"
|
||||||
},
|
},
|
||||||
|
"two_factor_enabled": {
|
||||||
|
"name": "two_factor_enabled",
|
||||||
|
"type": "boolean",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamp with time zone",
|
"type": "timestamp with time zone",
|
||||||
@@ -524,6 +638,100 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.billing_report_items": {
|
||||||
"name": "billing_report_items",
|
"name": "billing_report_items",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -701,6 +909,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"flatrate_cents_snapshot": {
|
||||||
|
"name": "flatrate_cents_snapshot",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "report_status",
|
"type": "report_status",
|
||||||
@@ -1030,6 +1244,32 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": 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": {
|
"current_billing_address_version_id": {
|
||||||
"name": "current_billing_address_version_id",
|
"name": "current_billing_address_version_id",
|
||||||
"type": "uuid",
|
"type": "uuid",
|
||||||
@@ -1060,6 +1300,18 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": 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": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamp with time zone",
|
"type": "timestamp with time zone",
|
||||||
@@ -1102,6 +1354,19 @@
|
|||||||
],
|
],
|
||||||
"onDelete": "restrict",
|
"onDelete": "restrict",
|
||||||
"onUpdate": "no action"
|
"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": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -1125,6 +1390,135 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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.download_events": {
|
"public.download_events": {
|
||||||
"name": "download_events",
|
"name": "download_events",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -1204,9 +1598,56 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"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": {
|
"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": {
|
"download_events_editorial_idempotency_key_unique": {
|
||||||
"name": "download_events_editorial_idempotency_key_unique",
|
"name": "download_events_editorial_idempotency_key_unique",
|
||||||
"columns": [
|
"columns": [
|
||||||
@@ -1260,7 +1701,24 @@
|
|||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
"uniqueConstraints": {},
|
"uniqueConstraints": {},
|
||||||
"policies": {},
|
"policies": {},
|
||||||
"checkConstraints": {},
|
"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
|
"isRLSEnabled": false
|
||||||
},
|
},
|
||||||
"public.usages": {
|
"public.usages": {
|
||||||
@@ -1344,7 +1802,50 @@
|
|||||||
"default": "now()"
|
"default": "now()"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"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": {
|
"foreignKeys": {
|
||||||
"usages_editorial_account_id_editorial_accounts_id_fk": {
|
"usages_editorial_account_id_editorial_accounts_id_fk": {
|
||||||
"name": "usages_editorial_account_id_editorial_accounts_id_fk",
|
"name": "usages_editorial_account_id_editorial_accounts_id_fk",
|
||||||
@@ -1376,7 +1877,16 @@
|
|||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
"uniqueConstraints": {},
|
"uniqueConstraints": {},
|
||||||
"policies": {},
|
"policies": {},
|
||||||
"checkConstraints": {},
|
"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
|
"isRLSEnabled": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1426,7 +1936,8 @@
|
|||||||
"values": [
|
"values": [
|
||||||
"open",
|
"open",
|
||||||
"billed",
|
"billed",
|
||||||
"reopened"
|
"reopened",
|
||||||
|
"voided"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"id": "cfd5f4d1-55ac-46d9-9667-cd156f26e070",
|
"id": "b98d41ae-a5a1-4e1c-bb31-99cc096528a0",
|
||||||
"prevId": "64eb37ed-2ab5-4c12-a8be-4375e8f6a732",
|
"prevId": "5ac645f2-0e76-4853-b029-724095bf1138",
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
"tables": {
|
"tables": {
|
||||||
@@ -77,6 +77,28 @@
|
|||||||
"concurrently": false,
|
"concurrently": false,
|
||||||
"method": "btree",
|
"method": "btree",
|
||||||
"with": {}
|
"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": {
|
"foreignKeys": {
|
||||||
@@ -110,6 +132,70 @@
|
|||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
"uniqueConstraints": {},
|
"uniqueConstraints": {},
|
||||||
"policies": {},
|
"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}$'"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"isRLSEnabled": false
|
||||||
},
|
},
|
||||||
@@ -397,6 +483,86 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.user": {
|
||||||
"name": "user",
|
"name": "user",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -441,6 +607,13 @@
|
|||||||
"notNull": true,
|
"notNull": true,
|
||||||
"default": "'EDITORIAL'"
|
"default": "'EDITORIAL'"
|
||||||
},
|
},
|
||||||
|
"two_factor_enabled": {
|
||||||
|
"name": "two_factor_enabled",
|
||||||
|
"type": "boolean",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamp with time zone",
|
"type": "timestamp with time zone",
|
||||||
@@ -524,6 +697,100 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.billing_report_items": {
|
||||||
"name": "billing_report_items",
|
"name": "billing_report_items",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -701,6 +968,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"flatrate_cents_snapshot": {
|
||||||
|
"name": "flatrate_cents_snapshot",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "report_status",
|
"type": "report_status",
|
||||||
@@ -1030,6 +1303,25 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": 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": {
|
"approval_notice_status": {
|
||||||
"name": "approval_notice_status",
|
"name": "approval_notice_status",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -1067,6 +1359,18 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": 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": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamp with time zone",
|
"type": "timestamp with time zone",
|
||||||
@@ -1109,6 +1413,19 @@
|
|||||||
],
|
],
|
||||||
"onDelete": "restrict",
|
"onDelete": "restrict",
|
||||||
"onUpdate": "no action"
|
"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": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -1132,6 +1449,135 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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.download_events": {
|
"public.download_events": {
|
||||||
"name": "download_events",
|
"name": "download_events",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -1211,9 +1657,56 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"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": {
|
"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": {
|
"download_events_editorial_idempotency_key_unique": {
|
||||||
"name": "download_events_editorial_idempotency_key_unique",
|
"name": "download_events_editorial_idempotency_key_unique",
|
||||||
"columns": [
|
"columns": [
|
||||||
@@ -1267,7 +1760,24 @@
|
|||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
"uniqueConstraints": {},
|
"uniqueConstraints": {},
|
||||||
"policies": {},
|
"policies": {},
|
||||||
"checkConstraints": {},
|
"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
|
"isRLSEnabled": false
|
||||||
},
|
},
|
||||||
"public.usages": {
|
"public.usages": {
|
||||||
@@ -1351,7 +1861,50 @@
|
|||||||
"default": "now()"
|
"default": "now()"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"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": {
|
"foreignKeys": {
|
||||||
"usages_editorial_account_id_editorial_accounts_id_fk": {
|
"usages_editorial_account_id_editorial_accounts_id_fk": {
|
||||||
"name": "usages_editorial_account_id_editorial_accounts_id_fk",
|
"name": "usages_editorial_account_id_editorial_accounts_id_fk",
|
||||||
@@ -1383,7 +1936,16 @@
|
|||||||
"compositePrimaryKeys": {},
|
"compositePrimaryKeys": {},
|
||||||
"uniqueConstraints": {},
|
"uniqueConstraints": {},
|
||||||
"policies": {},
|
"policies": {},
|
||||||
"checkConstraints": {},
|
"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
|
"isRLSEnabled": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1433,7 +1995,8 @@
|
|||||||
"values": [
|
"values": [
|
||||||
"open",
|
"open",
|
||||||
"billed",
|
"billed",
|
||||||
"reopened"
|
"reopened",
|
||||||
|
"voided"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"id": "8944c4e7-b3ab-47b5-a05b-91be6fb5c915",
|
"id": "f708aa98-0633-4a85-9d4b-879142f89a62",
|
||||||
"prevId": "cfd5f4d1-55ac-46d9-9667-cd156f26e070",
|
"prevId": "b98d41ae-a5a1-4e1c-bb31-99cc096528a0",
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
"tables": {
|
"tables": {
|
||||||
@@ -45,6 +45,13 @@
|
|||||||
"type": "uuid",
|
"type": "uuid",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": false
|
"notNull": false
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"name": "source",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "'admin'"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {
|
"indexes": {
|
||||||
@@ -136,10 +143,73 @@
|
|||||||
"album_grants_immich_album_id_uuid_check": {
|
"album_grants_immich_album_id_uuid_check": {
|
||||||
"name": "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}$'"
|
"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
|
"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": {
|
"public.audit_events": {
|
||||||
"name": "audit_events",
|
"name": "audit_events",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -424,6 +494,86 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.user": {
|
||||||
"name": "user",
|
"name": "user",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -468,6 +618,13 @@
|
|||||||
"notNull": true,
|
"notNull": true,
|
||||||
"default": "'EDITORIAL'"
|
"default": "'EDITORIAL'"
|
||||||
},
|
},
|
||||||
|
"two_factor_enabled": {
|
||||||
|
"name": "two_factor_enabled",
|
||||||
|
"type": "boolean",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamp with time zone",
|
"type": "timestamp with time zone",
|
||||||
@@ -551,6 +708,100 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.billing_report_items": {
|
||||||
"name": "billing_report_items",
|
"name": "billing_report_items",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -728,6 +979,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"flatrate_cents_snapshot": {
|
||||||
|
"name": "flatrate_cents_snapshot",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "report_status",
|
"type": "report_status",
|
||||||
@@ -874,6 +1131,170 @@
|
|||||||
},
|
},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.billing_address_versions": {
|
||||||
"name": "billing_address_versions",
|
"name": "billing_address_versions",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -1057,6 +1478,25 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": 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": {
|
"approval_notice_status": {
|
||||||
"name": "approval_notice_status",
|
"name": "approval_notice_status",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -1094,6 +1534,18 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": 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": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamp with time zone",
|
"type": "timestamp with time zone",
|
||||||
@@ -1136,6 +1588,19 @@
|
|||||||
],
|
],
|
||||||
"onDelete": "restrict",
|
"onDelete": "restrict",
|
||||||
"onUpdate": "no action"
|
"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": {},
|
"compositePrimaryKeys": {},
|
||||||
@@ -1159,6 +1624,232 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.download_events": {
|
||||||
"name": "download_events",
|
"name": "download_events",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -1261,6 +1952,33 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {
|
"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": {
|
"download_events_editorial_idempotency_key_unique": {
|
||||||
"name": "download_events_editorial_idempotency_key_unique",
|
"name": "download_events_editorial_idempotency_key_unique",
|
||||||
"columns": [
|
"columns": [
|
||||||
@@ -1415,7 +2133,50 @@
|
|||||||
"default": "now()"
|
"default": "now()"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {},
|
"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": {
|
"foreignKeys": {
|
||||||
"usages_editorial_account_id_editorial_accounts_id_fk": {
|
"usages_editorial_account_id_editorial_accounts_id_fk": {
|
||||||
"name": "usages_editorial_account_id_editorial_accounts_id_fk",
|
"name": "usages_editorial_account_id_editorial_accounts_id_fk",
|
||||||
@@ -1506,7 +2267,8 @@
|
|||||||
"values": [
|
"values": [
|
||||||
"open",
|
"open",
|
||||||
"billed",
|
"billed",
|
||||||
"reopened"
|
"reopened",
|
||||||
|
"voided"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
+1000
-88
File diff suppressed because it is too large.
Load diff
+946
-88
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,9 +1,143 @@
|
|||||||
{
|
{
|
||||||
"id": "36b1cd5a-b01a-44f7-9cb6-507237e962e5",
|
"id": "2b9ca46f-852c-4b19-9124-d4c5588422c8",
|
||||||
"prevId": "0335bf0f-c89b-4c9d-bc8a-659768032679",
|
"prevId": "5f74d5ee-94c3-45c2-b187-22a9f1f14a9e",
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
"tables": {
|
"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": {
|
"public.album_grants": {
|
||||||
"name": "album_grants",
|
"name": "album_grants",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -45,6 +179,13 @@
|
|||||||
"type": "uuid",
|
"type": "uuid",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": false
|
"notNull": false
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"name": "source",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "'admin'"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {
|
"indexes": {
|
||||||
@@ -136,10 +277,73 @@
|
|||||||
"album_grants_immich_album_id_uuid_check": {
|
"album_grants_immich_album_id_uuid_check": {
|
||||||
"name": "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}$'"
|
"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
|
"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": {
|
"public.audit_events": {
|
||||||
"name": "audit_events",
|
"name": "audit_events",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -424,6 +628,86 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.user": {
|
||||||
"name": "user",
|
"name": "user",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -468,6 +752,13 @@
|
|||||||
"notNull": true,
|
"notNull": true,
|
||||||
"default": "'EDITORIAL'"
|
"default": "'EDITORIAL'"
|
||||||
},
|
},
|
||||||
|
"two_factor_enabled": {
|
||||||
|
"name": "two_factor_enabled",
|
||||||
|
"type": "boolean",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamp with time zone",
|
"type": "timestamp with time zone",
|
||||||
@@ -704,6 +995,13 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"collab": {
|
||||||
|
"name": "collab",
|
||||||
|
"type": "boolean",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type": "timestamp with time zone",
|
"type": "timestamp with time zone",
|
||||||
@@ -822,6 +1120,12 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"flatrate_cents_snapshot": {
|
||||||
|
"name": "flatrate_cents_snapshot",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"name": "status",
|
"name": "status",
|
||||||
"type": "report_status",
|
"type": "report_status",
|
||||||
@@ -842,6 +1146,49 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": 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": {
|
"created_by_user_id": {
|
||||||
"name": "created_by_user_id",
|
"name": "created_by_user_id",
|
||||||
"type": "uuid",
|
"type": "uuid",
|
||||||
@@ -961,6 +1308,14 @@
|
|||||||
"name": "billing_reports_pdf_sha256_hex_check",
|
"name": "billing_reports_pdf_sha256_hex_check",
|
||||||
"value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'"
|
"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": {
|
"billing_reports_final_pdf_check": {
|
||||||
"name": "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)"
|
"value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)"
|
||||||
@@ -968,6 +1323,264 @@
|
|||||||
},
|
},
|
||||||
"isRLSEnabled": false
|
"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
|
||||||
|
},
|
||||||
|
"category_id": {
|
||||||
|
"name": "category_id",
|
||||||
|
"type": "uuid",
|
||||||
|
"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_category_id_event_categories_id_fk": {
|
||||||
|
"name": "calendar_events_category_id_event_categories_id_fk",
|
||||||
|
"tableFrom": "calendar_events",
|
||||||
|
"tableTo": "event_categories",
|
||||||
|
"columnsFrom": [
|
||||||
|
"category_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "restrict",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"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_categories": {
|
||||||
|
"name": "event_categories",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "uuid",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "gen_random_uuid()"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"color": {
|
||||||
|
"name": "color",
|
||||||
|
"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": {
|
||||||
|
"event_categories_name_lower_unique": {
|
||||||
|
"name": "event_categories_name_lower_unique",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "lower(\"name\")",
|
||||||
|
"asc": true,
|
||||||
|
"isExpression": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": true,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "btree",
|
||||||
|
"with": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreignKeys": {
|
||||||
|
"event_categories_created_by_user_id_user_id_fk": {
|
||||||
|
"name": "event_categories_created_by_user_id_user_id_fk",
|
||||||
|
"tableFrom": "event_categories",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"created_by_user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "restrict",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {
|
||||||
|
"event_categories_color_check": {
|
||||||
|
"name": "event_categories_color_check",
|
||||||
|
"value": "\"event_categories\".\"color\" in ('blue', 'green', 'orange', 'purple', 'teal', 'gold', 'red', 'neutral')"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
|
"public.event_reservations": {
|
||||||
|
"name": "event_reservations",
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "timestamp with time zone",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": "now()"
|
||||||
|
},
|
||||||
|
"granted_at": {
|
||||||
|
"name": "granted_at",
|
||||||
|
"type": "timestamp with time zone",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {
|
||||||
|
"event_reservations_event_editorial_unique": {
|
||||||
|
"name": "event_reservations_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_reservations_event_id_calendar_events_id_fk": {
|
||||||
|
"name": "event_reservations_event_id_calendar_events_id_fk",
|
||||||
|
"tableFrom": "event_reservations",
|
||||||
|
"tableTo": "calendar_events",
|
||||||
|
"columnsFrom": [
|
||||||
|
"event_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "restrict",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
},
|
||||||
|
"event_reservations_editorial_account_id_editorial_accounts_id_fk": {
|
||||||
|
"name": "event_reservations_editorial_account_id_editorial_accounts_id_fk",
|
||||||
|
"tableFrom": "event_reservations",
|
||||||
|
"tableTo": "editorial_accounts",
|
||||||
|
"columnsFrom": [
|
||||||
|
"editorial_account_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "restrict",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"policies": {},
|
||||||
|
"checkConstraints": {},
|
||||||
|
"isRLSEnabled": false
|
||||||
|
},
|
||||||
"public.billing_address_versions": {
|
"public.billing_address_versions": {
|
||||||
"name": "billing_address_versions",
|
"name": "billing_address_versions",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -1151,6 +1764,32 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": 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": {
|
"approval_notice_status": {
|
||||||
"name": "approval_notice_status",
|
"name": "approval_notice_status",
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -1407,6 +2046,103 @@
|
|||||||
"checkConstraints": {},
|
"checkConstraints": {},
|
||||||
"isRLSEnabled": false
|
"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": {
|
"public.download_events": {
|
||||||
"name": "download_events",
|
"name": "download_events",
|
||||||
"schema": "",
|
"schema": "",
|
||||||
@@ -1668,6 +2404,13 @@
|
|||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
"collab": {
|
||||||
|
"name": "collab",
|
||||||
|
"type": "boolean",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true,
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"billing_status": {
|
"billing_status": {
|
||||||
"name": "billing_status",
|
"name": "billing_status",
|
||||||
"type": "usage_billing_status",
|
"type": "usage_billing_status",
|
||||||
@@ -1717,6 +2460,21 @@
|
|||||||
"concurrently": false,
|
"concurrently": false,
|
||||||
"method": "btree",
|
"method": "btree",
|
||||||
"with": {}
|
"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": {
|
"foreignKeys": {
|
||||||
|
|||||||
+838
-105
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+31
-17
@@ -6,63 +6,77 @@
|
|||||||
"idx": 0,
|
"idx": 0,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786299825190,
|
"when": 1786299825190,
|
||||||
"tag": "0000_initial",
|
"tag": "0000_baseline",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786303607054,
|
"when": 1789139950413,
|
||||||
"tag": "0001_editorial_approval_notice",
|
"tag": "0001_add_announcements",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 2,
|
"idx": 2,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786354215684,
|
"when": 1796065000672,
|
||||||
"tag": "0002_accounting_intents",
|
"tag": "0002_release_notes_calendar",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 3,
|
"idx": 3,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786358492749,
|
"when": 1796067598623,
|
||||||
"tag": "0003_stream_delivery",
|
"tag": "0003_collab_invoice_activity",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 4,
|
"idx": 4,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786363479515,
|
"when": 1796073940910,
|
||||||
"tag": "0004_download_history_indexes",
|
"tag": "0004_release_notes_2_2_1",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 5,
|
"idx": 5,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786379282947,
|
"when": 1796074977959,
|
||||||
"tag": "0005_rate_limits",
|
"tag": "0005_release_notes_2_2_2",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 6,
|
"idx": 6,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786410282719,
|
"when": 1796077322641,
|
||||||
"tag": "0006_chubby_screwball",
|
"tag": "0006_calendar_categories_reservations",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 7,
|
"idx": 7,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786410724623,
|
"when": 1796077322892,
|
||||||
"tag": "0007_amused_franklin_storm",
|
"tag": "0007_drop_event_responses",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idx": 8,
|
"idx": 8,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1786411419497,
|
"when": 1796077763423,
|
||||||
"tag": "0008_overjoyed_wrecking_crew",
|
"tag": "0008_release_notes_2_3_0",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 9,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1796079496182,
|
||||||
|
"tag": "0009_release_notes_2_4_0",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 10,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1796081618450,
|
||||||
|
"tag": "0010_release_notes_2_4_1",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
+4
-1
@@ -1,5 +1,8 @@
|
|||||||
import nextVitals from "eslint-config-next/core-web-vitals";
|
import nextVitals from "eslint-config-next/core-web-vitals";
|
||||||
|
|
||||||
const eslintConfig = [...nextVitals];
|
const eslintConfig = [
|
||||||
|
{ ignores: [".next/**", ".worktrees/**"] },
|
||||||
|
...nextVitals,
|
||||||
|
];
|
||||||
|
|
||||||
export default eslintConfig;
|
export default eslintConfig;
|
||||||
+5
-3
@@ -3,6 +3,9 @@ import type { NextConfig } from "next";
|
|||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
poweredByHeader: false,
|
poweredByHeader: false,
|
||||||
|
experimental: {
|
||||||
|
optimizePackageImports: ["lucide-react", "recharts"],
|
||||||
|
},
|
||||||
async headers() {
|
async headers() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -13,9 +16,8 @@ const nextConfig: NextConfig = {
|
|||||||
// ponytail: Next.js App Router injects inline scripts (RSC flight
|
// ponytail: Next.js App Router injects inline scripts (RSC flight
|
||||||
// data + bootstrap) to hydrate client components. Without
|
// data + bootstrap) to hydrate client components. Without
|
||||||
// 'unsafe-inline' or a nonce in script-src the browser blocks them,
|
// 'unsafe-inline' or a nonce in script-src the browser blocks them,
|
||||||
// hydration never runs, and every client form (login, registration,
|
// client forms cannot hydrate. 'unsafe-inline' for scripts is
|
||||||
// reset) falls back to a native GET submit. 'unsafe-inline' for
|
// the pragmatic fix; upgrade path is per-request nonces
|
||||||
// scripts is the pragmatic fix; upgrade path is per-request nonces
|
|
||||||
// via middleware (Next attaches the nonce to its inline scripts).
|
// via middleware (Next attaches the nonce to its inline scripts).
|
||||||
value: [
|
value: [
|
||||||
"default-src 'self'",
|
"default-src 'self'",
|
||||||
|
|||||||
+10
-10
@@ -16,26 +16,26 @@
|
|||||||
"test:e2e": "playwright test"
|
"test:e2e": "playwright test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@better-auth/drizzle-adapter": "^1.6.26",
|
"@better-auth/drizzle-adapter": "^1.7.29",
|
||||||
|
"@fontsource-variable/geist": "^5.3.0",
|
||||||
"@js-temporal/polyfill": "^0.5.1",
|
"@js-temporal/polyfill": "^0.5.1",
|
||||||
"@radix-ui/react-slot": "^1.3.3",
|
"@radix-ui/react-slot": "^1.3.3",
|
||||||
|
"@sakaniui/react": "^0.23.0",
|
||||||
"archiver": "^8.0.0",
|
"archiver": "^8.0.0",
|
||||||
"better-auth": "^1.6.26",
|
"better-auth": "^1.7.29",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"drizzle-orm": "^0.45.2",
|
"drizzle-orm": "^0.45.2",
|
||||||
"lucide-react": "^1.31.0",
|
"next": "^16.4.6",
|
||||||
"next": "^16.3.0",
|
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
"nodemailer": "^9.0.5",
|
"nodemailer": "^10.6.2",
|
||||||
"pdfmake": "~0.3.11",
|
"pdfmake": "~0.3.11",
|
||||||
"pg": "^8.22.0",
|
"pg": "^8.22.0",
|
||||||
"react": "^19.2.8",
|
"react": "^19.2.8",
|
||||||
"react-dom": "^19.2.8",
|
"react-dom": "^19.2.8",
|
||||||
"recharts": "^3.10.1",
|
|
||||||
"server-only": "^0.0.1",
|
"server-only": "^0.0.1",
|
||||||
"sharp": "^0.35.3",
|
"sharp": "^0.35.6",
|
||||||
"tailwind-merge": "^3.6.0",
|
"tailwind-merge": "^3.6.0",
|
||||||
"zod": "^4.4.3"
|
"zod": "^4.6.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.50.0",
|
"@playwright/test": "^1.50.0",
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
"@vitejs/plugin-react": "^6.0.5",
|
"@vitejs/plugin-react": "^6.0.5",
|
||||||
"drizzle-kit": "^0.31.10",
|
"drizzle-kit": "^0.31.10",
|
||||||
"eslint": "^9.39.5",
|
"eslint": "^9.39.5",
|
||||||
"eslint-config-next": "^16.3.0",
|
"eslint-config-next": "^16.4.6",
|
||||||
"jsdom": "^30.0.1",
|
"jsdom": "^30.0.1",
|
||||||
"msw": "^2.15.0",
|
"msw": "^2.15.0",
|
||||||
"pdfjs-dist": "^6.2.108",
|
"pdfjs-dist": "^6.2.108",
|
||||||
@@ -61,6 +61,6 @@
|
|||||||
"testcontainers": "^12.1.0",
|
"testcontainers": "^12.1.0",
|
||||||
"tsx": "^4.23.11",
|
"tsx": "^4.23.11",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vitest": "^4.1.10"
|
"vitest": "^4.1.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+665
-741
File diff suppressed because it is too large.
Load diff
@@ -4,3 +4,15 @@ allowBuilds:
|
|||||||
protobufjs: false
|
protobufjs: false
|
||||||
ssh2: false
|
ssh2: false
|
||||||
unrs-resolver: true
|
unrs-resolver: true
|
||||||
|
|
||||||
|
overrides:
|
||||||
|
"@grpc/grpc-js@1.14.4": 1.14.7
|
||||||
|
brace-expansion@1.1.18: 1.1.22
|
||||||
|
brace-expansion@2.1.4: 2.1.8
|
||||||
|
brace-expansion@5.0.9: 5.0.12
|
||||||
|
"@esbuild-kit/core-utils>esbuild": 0.25.12
|
||||||
|
js-yaml@4.3.1: 4.3.2
|
||||||
|
"readdir-glob@3>minimatch": 11.0.9
|
||||||
|
source-map-js@1.2.1: 1.2.2
|
||||||
|
undici@8.10.0: 8.12.4
|
||||||
|
vite@8.2.1: 8.2.4
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
+19
-39
@@ -1,44 +1,24 @@
|
|||||||
import { eq } from "drizzle-orm";
|
import { text } from "node:stream/consumers";
|
||||||
import { auth } from "../src/modules/auth/auth";
|
|
||||||
import { db } from "../src/db/client";
|
import { insertAdminCredential, seedAdmin } from "../src/modules/auth/admin-bootstrap";
|
||||||
import { users } from "../src/db/schema";
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const email = process.argv[2] || "mail@leon-tonhaeuser.de";
|
const [email, name, ...extra] = process.argv.slice(2);
|
||||||
const password = process.argv[3] || "AdminPassword123!";
|
if (!email || !name || extra.length > 0 || process.stdin.isTTY) {
|
||||||
const name = process.argv[4] || "Leon Tonhäuser";
|
throw new Error("Supply email and name as arguments and the password on stdin");
|
||||||
|
}
|
||||||
console.log(`Creating Admin user: ${email}...`);
|
|
||||||
|
|
||||||
|
const password = (await text(process.stdin)).replace(/\r?\n$/, "");
|
||||||
|
const { db, pool } = await import("../src/db/client");
|
||||||
try {
|
try {
|
||||||
const res = await auth.api.signUpEmail({
|
await seedAdmin({ email, name, password }, (credential) => insertAdminCredential(db, credential));
|
||||||
body: {
|
} finally {
|
||||||
email,
|
await pool.end();
|
||||||
name,
|
}
|
||||||
password,
|
console.log("Admin account created.");
|
||||||
},
|
}
|
||||||
});
|
|
||||||
|
main().catch(() => {
|
||||||
const userId = res.user.id;
|
console.error("Admin seed failed. Check the input, database connectivity and whether the email is already registered.");
|
||||||
await db.update(users).set({ role: "ADMIN", emailVerified: true }).where(eq(users.id, userId));
|
process.exitCode = 1;
|
||||||
|
|
||||||
console.log(`Successfully created Admin account!`);
|
|
||||||
console.log(`Email: ${email}`);
|
|
||||||
console.log(`Password: ${password}`);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error creating admin user:", error);
|
|
||||||
// If user already exists, update to admin
|
|
||||||
const [existing] = await db.select().from(users).where(eq(users.email, email));
|
|
||||||
if (existing) {
|
|
||||||
await db.update(users).set({ role: "ADMIN", emailVerified: true }).where(eq(users.id, existing.id));
|
|
||||||
console.log(`Updated existing user ${email} to ADMIN role.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
main().catch((err) => {
|
|
||||||
console.error("Fatal error:", err);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
});
|
||||||
@@ -41,6 +41,7 @@ function basePosition(priceCents = 6_000) {
|
|||||||
purpose: "Print Nutzung",
|
purpose: "Print Nutzung",
|
||||||
reference: "REF-001" as string | null,
|
reference: "REF-001" as string | null,
|
||||||
priceCents,
|
priceCents,
|
||||||
|
collab: false,
|
||||||
createdAt: new Date("2026-03-15T10:00:00.000Z"),
|
createdAt: new Date("2026-03-15T10:00:00.000Z"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,21 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
import { env } from "@/config/env";
|
import { PublicShell } from "@/components/layout/public-shell";
|
||||||
import { LoginForm } from "@/modules/auth/public-forms";
|
import { LoginForm } from "@/modules/auth/public-forms";
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
return (
|
return (
|
||||||
<main className="public-account-page">
|
<PublicShell
|
||||||
<header className="masthead">
|
kicker="Zugang"
|
||||||
<Link className="wordmark" href="/">
|
title="Anmelden"
|
||||||
Leon Tonhäuser
|
titleId="login-title"
|
||||||
</Link>
|
lede="Melden Sie sich mit der E-Mail-Adresse Ihrer Redaktion an."
|
||||||
<span className="section-label">Redaktionsportal</span>
|
>
|
||||||
</header>
|
|
||||||
<section className="account-panel" aria-labelledby="login-title">
|
|
||||||
<p className="eyebrow">Zugang</p>
|
|
||||||
<h1 id="login-title">Anmelden</h1>
|
|
||||||
<p className="lede">Melden Sie sich mit der E-Mail-Adresse Ihrer Redaktion an.</p>
|
|
||||||
<LoginForm />
|
<LoginForm />
|
||||||
<nav className="account-links" aria-label="Zugang verwalten">
|
<nav aria-label="Zugang verwalten" className="flex flex-wrap justify-between gap-x-4 gap-y-2 text-sm">
|
||||||
<Link href="/passwort-vergessen">Passwort vergessen?</Link>
|
<Link className="font-medium text-[var(--color-brand-fg)] hover:underline" href="/passwort-vergessen">Passwort vergessen?</Link>
|
||||||
<Link href="/registrieren">Neue Redaktion registrieren</Link>
|
<Link className="font-medium text-[var(--color-brand-fg)] hover:underline" href="/registrieren">Neue Redaktion registrieren</Link>
|
||||||
</nav>
|
</nav>
|
||||||
</section>
|
</PublicShell>
|
||||||
<LegalFooter imprint={env.LEGAL_IMPRINT_URL} privacy={env.LEGAL_PRIVACY_URL} terms={env.LEGAL_TERMS_URL} />
|
|
||||||
</main>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function LegalFooter({ imprint, privacy, terms }: { imprint: string; privacy: string; terms: string }) {
|
|
||||||
return (
|
|
||||||
<footer className="public-footer">
|
|
||||||
<a href={imprint}>Impressum</a>
|
|
||||||
<a href={privacy}>Datenschutz</a>
|
|
||||||
<a href={terms}>Nutzungsbedingungen</a>
|
|
||||||
</footer>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,15 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
|
import { PublicShell } from "@/components/layout/public-shell";
|
||||||
import { PasswordResetRequestForm } from "@/modules/auth/public-forms";
|
import { PasswordResetRequestForm } from "@/modules/auth/public-forms";
|
||||||
|
|
||||||
export default function ForgotPasswordPage() {
|
export default function ForgotPasswordPage() {
|
||||||
return (
|
return (
|
||||||
<main className="public-account-page">
|
<PublicShell kicker="Zugang" title="Passwort vergessen?" titleId="forgot-password-title" lede="Fordern Sie einen Link zum Zurücksetzen Ihres Passworts an.">
|
||||||
<header className="masthead">
|
|
||||||
<Link className="wordmark" href="/">
|
|
||||||
Leon Tonhäuser
|
|
||||||
</Link>
|
|
||||||
<span className="section-label">Redaktionsportal</span>
|
|
||||||
</header>
|
|
||||||
<section className="account-panel" aria-labelledby="forgot-password-title">
|
|
||||||
<p className="eyebrow">Zugang</p>
|
|
||||||
<h1 id="forgot-password-title">Passwort vergessen?</h1>
|
|
||||||
<p className="lede">Fordern Sie einen Link zum Zurücksetzen Ihres Passworts an.</p>
|
|
||||||
<PasswordResetRequestForm />
|
<PasswordResetRequestForm />
|
||||||
<nav className="account-links" aria-label="Zurück zur Anmeldung">
|
<nav aria-label="Zurück zur Anmeldung" className="text-sm">
|
||||||
<Link href="/anmelden">Zur Anmeldung</Link>
|
<Link className="font-medium text-[var(--color-brand-fg)] hover:underline" href="/anmelden">Zur Anmeldung</Link>
|
||||||
</nav>
|
</nav>
|
||||||
</section>
|
</PublicShell>
|
||||||
</main>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
|
import { PublicShell } from "@/components/layout/public-shell";
|
||||||
import { PasswordResetForm } from "@/modules/auth/public-forms";
|
import { PasswordResetForm } from "@/modules/auth/public-forms";
|
||||||
|
|
||||||
export default async function ResetPasswordPage({
|
export default async function ResetPasswordPage({
|
||||||
@@ -10,22 +11,11 @@ export default async function ResetPasswordPage({
|
|||||||
const { token } = await searchParams;
|
const { token } = await searchParams;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="public-account-page">
|
<PublicShell kicker="Zugang" title="Neues Passwort setzen" titleId="reset-password-title" lede="Wählen Sie ein neues Passwort für den Zugang Ihrer Redaktion.">
|
||||||
<header className="masthead">
|
|
||||||
<Link className="wordmark" href="/">
|
|
||||||
Leon Tonhäuser
|
|
||||||
</Link>
|
|
||||||
<span className="section-label">Redaktionsportal</span>
|
|
||||||
</header>
|
|
||||||
<section className="account-panel" aria-labelledby="reset-password-title">
|
|
||||||
<p className="eyebrow">Zugang</p>
|
|
||||||
<h1 id="reset-password-title">Neues Passwort setzen</h1>
|
|
||||||
<p className="lede">Wählen Sie ein neues Passwort für den Zugang Ihrer Redaktion.</p>
|
|
||||||
<PasswordResetForm token={token} />
|
<PasswordResetForm token={token} />
|
||||||
<nav className="account-links" aria-label="Zurück zur Anmeldung">
|
<nav aria-label="Zurück zur Anmeldung" className="text-sm">
|
||||||
<Link href="/anmelden">Zur Anmeldung</Link>
|
<Link className="font-medium text-[var(--color-brand-fg)] hover:underline" href="/anmelden">Zur Anmeldung</Link>
|
||||||
</nav>
|
</nav>
|
||||||
</section>
|
</PublicShell>
|
||||||
</main>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,35 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
export default function RegistrationConfirmedPage() {
|
import { PublicShell } from "@/components/layout/public-shell";
|
||||||
|
import { RegistrationSteps } from "@/components/layout/registration-steps";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
|
// Two arrivals share this page: right after the form (e-mail still to
|
||||||
|
// confirm) and from the confirmation link (?schritt=freigabe, see auth.ts).
|
||||||
|
export default async function RegistrationConfirmedPage({
|
||||||
|
searchParams,
|
||||||
|
}: Readonly<{ searchParams: Promise<Record<string, string | string[] | undefined>> }>) {
|
||||||
|
const { schritt } = await searchParams;
|
||||||
|
const confirmed = schritt === "freigabe";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="public-account-page">
|
<PublicShell
|
||||||
<header className="masthead">
|
kicker="Registrierung"
|
||||||
<Link className="wordmark" href="/">
|
title={confirmed ? "E-Mail bestätigt." : "Vielen Dank."}
|
||||||
Leon Tonhäuser
|
titleId="confirmation-title"
|
||||||
</Link>
|
lede={
|
||||||
<span className="section-label">Redaktionsportal</span>
|
confirmed
|
||||||
</header>
|
? "Wir prüfen jetzt Ihre Registrierung und melden uns per E-Mail, sobald Ihr Zugang freigeschaltet ist."
|
||||||
<section className="account-panel" aria-labelledby="confirmation-title">
|
: "Wir haben Ihnen eine E-Mail geschickt. Bitte bestätigen Sie Ihre Adresse über den Link darin. Danach prüfen wir Ihre Registrierung."
|
||||||
<p className="eyebrow">Registrierung</p>
|
}
|
||||||
<h1 id="confirmation-title">Vielen Dank.</h1>
|
wide
|
||||||
<p className="lede">
|
>
|
||||||
Bitte folgen Sie den weiteren Hinweisen, die wir Ihnen gegebenenfalls zusenden. Danach
|
<RegistrationSteps current={confirmed ? 2 : 1} />
|
||||||
prüfen wir Ihre Registrierung.
|
<div>
|
||||||
</p>
|
<Button asChild>
|
||||||
<Link className="primary-action" href="/anmelden">
|
<Link href="/anmelden">Zur Anmeldung</Link>
|
||||||
Zur Anmeldung
|
</Button>
|
||||||
</Link>
|
</div>
|
||||||
</section>
|
</PublicShell>
|
||||||
</main>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import Link from "next/link";
|
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
|
||||||
|
import { PublicShell } from "@/components/layout/public-shell";
|
||||||
|
import { RegistrationSteps } from "@/components/layout/registration-steps";
|
||||||
import { env } from "@/config/env";
|
import { env } from "@/config/env";
|
||||||
import { registerEditorial } from "@/modules/auth/auth";
|
import { registerEditorial } from "@/modules/auth/auth";
|
||||||
import {
|
import {
|
||||||
@@ -11,22 +13,18 @@ import {
|
|||||||
RegistrationForm,
|
RegistrationForm,
|
||||||
type RegistrationFormState,
|
type RegistrationFormState,
|
||||||
} from "@/modules/auth/public-forms";
|
} from "@/modules/auth/public-forms";
|
||||||
|
import { RateLimitExceededError } from "@/modules/security/rate-limit-guard";
|
||||||
|
|
||||||
export default function RegistrationPage() {
|
export default function RegistrationPage() {
|
||||||
return (
|
return (
|
||||||
<main className="public-account-page">
|
<PublicShell
|
||||||
<header className="masthead">
|
kicker="B2B-Zugang"
|
||||||
<Link className="wordmark" href="/">
|
title="Redaktion registrieren"
|
||||||
Leon Tonhäuser
|
titleId="registration-title"
|
||||||
</Link>
|
lede="Das Redaktionsportal steht ausschließlich Unternehmen und Redaktionen zur Verfügung."
|
||||||
<span className="section-label">Redaktionsportal</span>
|
wide
|
||||||
</header>
|
>
|
||||||
<section className="account-panel account-panel-wide" aria-labelledby="registration-title">
|
<RegistrationSteps current={0} />
|
||||||
<p className="eyebrow">B2B-Zugang</p>
|
|
||||||
<h1 id="registration-title">Redaktion registrieren</h1>
|
|
||||||
<p className="lede">
|
|
||||||
Das Redaktionsportal steht ausschließlich Unternehmen und Redaktionen zur Verfügung.
|
|
||||||
</p>
|
|
||||||
<RegistrationForm
|
<RegistrationForm
|
||||||
action={registerAction}
|
action={registerAction}
|
||||||
legalUrls={{
|
legalUrls={{
|
||||||
@@ -35,8 +33,7 @@ export default function RegistrationPage() {
|
|||||||
terms: env.LEGAL_TERMS_URL,
|
terms: env.LEGAL_TERMS_URL,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</section>
|
</PublicShell>
|
||||||
</main>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,8 +59,15 @@ async function registerAction(
|
|||||||
actsForBusiness: formData.has("actsForBusiness"),
|
actsForBusiness: formData.has("actsForBusiness"),
|
||||||
termsVersion: formData.has("termsAccepted") ? CURRENT_TERMS_VERSION : "",
|
termsVersion: formData.has("termsAccepted") ? CURRENT_TERMS_VERSION : "",
|
||||||
privacyAcknowledged: formData.has("privacyAcknowledged"),
|
privacyAcknowledged: formData.has("privacyAcknowledged"),
|
||||||
});
|
}, await headers());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof RateLimitExceededError) {
|
||||||
|
return {
|
||||||
|
errors: {
|
||||||
|
form: "Es wurden zu viele Registrierungsversuche gesendet. Bitte versuchen Sie es später erneut.",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
if (error instanceof RegistrationValidationError) {
|
if (error instanceof RegistrationValidationError) {
|
||||||
return { errors: { [error.field]: error.message } };
|
return { errors: { [error.field]: error.message } };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
// @vitest-environment jsdom
|
// @vitest-environment jsdom
|
||||||
|
|
||||||
import { render, screen, fireEvent, cleanup } from "@testing-library/react";
|
import { render, screen, fireEvent, cleanup } from "@testing-library/react";
|
||||||
import { afterEach, expect, test } from "vitest";
|
import { afterEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
vi.mock("next/navigation", () => ({ useRouter: () => ({ refresh: vi.fn(), push: vi.fn() }) }));
|
||||||
|
|
||||||
import { BillingSelection } from "./BillingSelection";
|
import { BillingSelection } from "./BillingSelection";
|
||||||
import type { FinalizedReportSummary } from "./page-content";
|
import type { FinalizedReportSummary } from "./page-content";
|
||||||
@@ -17,6 +19,7 @@ const openPosition: BillingPosition = {
|
|||||||
purpose: "Titelgeschichte",
|
purpose: "Titelgeschichte",
|
||||||
reference: "Ausgabe 8/26",
|
reference: "Ausgabe 8/26",
|
||||||
priceCents: 6_000,
|
priceCents: 6_000,
|
||||||
|
collab: false,
|
||||||
status: "open",
|
status: "open",
|
||||||
selectable: true,
|
selectable: true,
|
||||||
createdAt: new Date("2026-08-05T10:00:00.000Z"),
|
createdAt: new Date("2026-08-05T10:00:00.000Z"),
|
||||||
@@ -32,6 +35,7 @@ const billedPosition: BillingPosition = {
|
|||||||
purpose: "Sportbericht",
|
purpose: "Sportbericht",
|
||||||
reference: null,
|
reference: null,
|
||||||
priceCents: 1_500,
|
priceCents: 1_500,
|
||||||
|
collab: false,
|
||||||
status: "billed",
|
status: "billed",
|
||||||
selectable: false,
|
selectable: false,
|
||||||
createdAt: new Date("2026-08-06T10:00:00.000Z"),
|
createdAt: new Date("2026-08-06T10:00:00.000Z"),
|
||||||
@@ -47,6 +51,7 @@ const reopenedPosition: BillingPosition = {
|
|||||||
purpose: "Reopened",
|
purpose: "Reopened",
|
||||||
reference: null,
|
reference: null,
|
||||||
priceCents: 1_500,
|
priceCents: 1_500,
|
||||||
|
collab: false,
|
||||||
status: "reopened",
|
status: "reopened",
|
||||||
selectable: true,
|
selectable: true,
|
||||||
createdAt: new Date("2026-08-07T10:00:00.000Z"),
|
createdAt: new Date("2026-08-07T10:00:00.000Z"),
|
||||||
@@ -67,10 +72,8 @@ const defaultProps = {
|
|||||||
editorialId: "e1",
|
editorialId: "e1",
|
||||||
repeatDownloads: [] as RepeatDownloadPosition[],
|
repeatDownloads: [] as RepeatDownloadPosition[],
|
||||||
year: 2026,
|
year: 2026,
|
||||||
month: 8 as number | null,
|
quarter: 3,
|
||||||
quarter: null as number | null,
|
periodLabel: "Q3 2026",
|
||||||
isQuarter: false,
|
|
||||||
periodLabel: "August 2026",
|
|
||||||
reports: [] as FinalizedReportSummary[],
|
reports: [] as FinalizedReportSummary[],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,7 +110,7 @@ test("disables the checkbox for billed positions and shows report reference", ()
|
|||||||
expect(screen.getByText(/RE-2026-042/)).toBeTruthy();
|
expect(screen.getByText(/RE-2026-042/)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("selects all open positions via Alle offenen im Monat", () => {
|
test("selects all open positions via Alle offenen im Quartal", () => {
|
||||||
render(
|
render(
|
||||||
<BillingSelection
|
<BillingSelection
|
||||||
{...defaultProps}
|
{...defaultProps}
|
||||||
@@ -115,7 +118,7 @@ test("selects all open positions via Alle offenen im Monat", () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /Alle offenen im Monat/i }));
|
fireEvent.click(screen.getByRole("button", { name: /Alle offenen im Quartal/i }));
|
||||||
|
|
||||||
expect(getCheckbox("jubel.jpg").checked).toBe(true);
|
expect(getCheckbox("jubel.jpg").checked).toBe(true);
|
||||||
expect(getCheckbox("redaktion.jpg").checked).toBe(true);
|
expect(getCheckbox("redaktion.jpg").checked).toBe(true);
|
||||||
@@ -146,7 +149,7 @@ test("displays selected count and cents-derived EUR total", () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /Alle offenen im Monat/i }));
|
fireEvent.click(screen.getByRole("button", { name: /Alle offenen im Quartal/i }));
|
||||||
|
|
||||||
const summary = container.querySelector(".billing-summary");
|
const summary = container.querySelector(".billing-summary");
|
||||||
expect(summary?.textContent ?? "").toMatch(/2 Nutzungen ausgewählt/);
|
expect(summary?.textContent ?? "").toMatch(/2 Nutzungen ausgewählt/);
|
||||||
@@ -177,30 +180,11 @@ test("shows empty state when no billable positions exist", () => {
|
|||||||
expect(screen.getByText(/Keine abrechenbaren Nutzungen/)).toBeTruthy();
|
expect(screen.getByText(/Keine abrechenbaren Nutzungen/)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("links to quarter view from month view", () => {
|
test("offers only quarterly periods", () => {
|
||||||
render(
|
render(<BillingSelection {...defaultProps} positions={[openPosition]} />);
|
||||||
<BillingSelection
|
|
||||||
{...defaultProps}
|
|
||||||
positions={[openPosition]}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
|
|
||||||
const quarterLink = screen.getByRole("link", { name: /Ganzes Quartal/i });
|
expect(screen.queryByRole("link", { name: /Monatsansicht/i })).toBeNull();
|
||||||
expect(quarterLink.getAttribute("href") ?? "").toContain("quarter=3");
|
expect(screen.queryByText("Monat")).toBeNull();
|
||||||
});
|
expect(screen.getByText("Quartal")).toBeTruthy();
|
||||||
|
expect(screen.getByText(/Zeitraum: Q3 2026/)).toBeTruthy();
|
||||||
test("links to month view from quarter view", () => {
|
|
||||||
render(
|
|
||||||
<BillingSelection
|
|
||||||
{...defaultProps}
|
|
||||||
positions={[openPosition]}
|
|
||||||
month={null}
|
|
||||||
quarter={3}
|
|
||||||
isQuarter={true}
|
|
||||||
periodLabel="Q3 2026"
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
|
|
||||||
const monthLink = screen.getByRole("link", { name: /Monatsansicht/i });
|
|
||||||
expect(monthLink.getAttribute("href") ?? "").toContain("month=");
|
|
||||||
});
|
});
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import Link from "next/link";
|
import { useRouter } from "next/navigation";
|
||||||
|
import { Badge, Checkbox, EmptyState, Table, Textarea, toast } from "@sakaniui/react";
|
||||||
|
import { IconDownload, IconFileText } from "@sakaniui/react/icons";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Card, FormSelect } from "@/components/ui/sakani";
|
||||||
|
|
||||||
import type { BillingPosition, RepeatDownloadPosition } from "@/modules/billing/queries";
|
import type { BillingPosition, RepeatDownloadPosition } from "@/modules/billing/queries";
|
||||||
import { formatCents } from "@/modules/billing/format";
|
import { formatCents } from "@/modules/billing/format";
|
||||||
@@ -12,34 +17,23 @@ type BillingSelectionProps = {
|
|||||||
positions: BillingPosition[];
|
positions: BillingPosition[];
|
||||||
repeatDownloads: RepeatDownloadPosition[];
|
repeatDownloads: RepeatDownloadPosition[];
|
||||||
year: number;
|
year: number;
|
||||||
month: number | null;
|
quarter: number;
|
||||||
quarter: number | null;
|
|
||||||
isQuarter: boolean;
|
|
||||||
periodLabel: string;
|
periodLabel: string;
|
||||||
reports: FinalizedReportSummary[];
|
reports: FinalizedReportSummary[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const MONTHS = [
|
|
||||||
"Januar",
|
|
||||||
"Februar",
|
|
||||||
"März",
|
|
||||||
"April",
|
|
||||||
"Mai",
|
|
||||||
"Juni",
|
|
||||||
"Juli",
|
|
||||||
"August",
|
|
||||||
"September",
|
|
||||||
"Oktober",
|
|
||||||
"November",
|
|
||||||
"Dezember",
|
|
||||||
];
|
|
||||||
|
|
||||||
const STATUS_LABELS: Record<BillingPosition["status"], string> = {
|
const STATUS_LABELS: Record<BillingPosition["status"], string> = {
|
||||||
open: "Offen",
|
open: "Offen",
|
||||||
billed: "Abgerechnet",
|
billed: "Abgerechnet",
|
||||||
reopened: "Wiedereröffnet",
|
reopened: "Wiedereröffnet",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const STATUS_BADGES: Record<BillingPosition["status"], "warning" | "success"> = {
|
||||||
|
open: "warning",
|
||||||
|
billed: "success",
|
||||||
|
reopened: "warning",
|
||||||
|
};
|
||||||
|
|
||||||
const REPORT_STATUS_LABELS: Record<string, string> = {
|
const REPORT_STATUS_LABELS: Record<string, string> = {
|
||||||
draft: "Entwurf",
|
draft: "Entwurf",
|
||||||
final: "Erstellt",
|
final: "Erstellt",
|
||||||
@@ -51,18 +45,13 @@ export function BillingSelection({
|
|||||||
positions,
|
positions,
|
||||||
repeatDownloads,
|
repeatDownloads,
|
||||||
year,
|
year,
|
||||||
month,
|
|
||||||
quarter,
|
quarter,
|
||||||
isQuarter,
|
|
||||||
periodLabel,
|
periodLabel,
|
||||||
reports,
|
reports,
|
||||||
}: BillingSelectionProps) {
|
}: BillingSelectionProps) {
|
||||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
|
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
|
||||||
const [actionState, setActionState] = useState<{
|
const router = useRouter();
|
||||||
loading: boolean;
|
const [actionState, setActionState] = useState({ loading: false });
|
||||||
message: string | null;
|
|
||||||
isError: boolean;
|
|
||||||
}>({ loading: false, message: null, isError: false });
|
|
||||||
|
|
||||||
const selectablePositions = useMemo(
|
const selectablePositions = useMemo(
|
||||||
() => positions.filter((p) => p.selectable),
|
() => positions.filter((p) => p.selectable),
|
||||||
@@ -96,11 +85,11 @@ export function BillingSelection({
|
|||||||
setSelectedIds(new Set());
|
setSelectedIds(new Set());
|
||||||
}
|
}
|
||||||
|
|
||||||
const periodPayload = { year, ...(isQuarter ? { quarter: quarter ?? 1 } : { month: month ?? 1 }) };
|
const periodPayload = { year, quarter };
|
||||||
|
|
||||||
async function handlePreview() {
|
async function handlePreview() {
|
||||||
if (selectedIds.size === 0) return;
|
if (selectedIds.size === 0) return;
|
||||||
setActionState({ loading: true, message: null, isError: false });
|
setActionState({ loading: true });
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/api/billing-reports/preview", {
|
const response = await fetch("/api/billing-reports/preview", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -113,25 +102,22 @@ export function BillingSelection({
|
|||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const body = await response.json().catch(() => ({ code: "ERROR" }));
|
const body = await response.json().catch(() => ({ code: "ERROR" }));
|
||||||
throw new Error(body.code ?? "Vorschau fehlgeschlagen");
|
throw new Error(billingErrorMessage(body.code));
|
||||||
}
|
}
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
setActionState({ loading: false, message: null, isError: false });
|
setActionState({ loading: false });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setActionState({
|
setActionState({ loading: false });
|
||||||
loading: false,
|
toast.error(error instanceof Error ? error.message : billingErrorMessage(null));
|
||||||
message: error instanceof Error ? error.message : "Vorschau fehlgeschlagen",
|
|
||||||
isError: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleFinalize() {
|
async function handleFinalize() {
|
||||||
if (selectedIds.size === 0) return;
|
if (selectedIds.size === 0) return;
|
||||||
setActionState({ loading: true, message: null, isError: false });
|
setActionState({ loading: true });
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/api/billing-reports", {
|
const response = await fetch("/api/billing-reports", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -144,206 +130,247 @@ export function BillingSelection({
|
|||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const body = await response.json().catch(() => ({ code: "ERROR" }));
|
const body = await response.json().catch(() => ({ code: "ERROR" }));
|
||||||
throw new Error(body.code ?? "Abrechnung konnte nicht erstellt werden");
|
throw new Error(billingErrorMessage(body.code));
|
||||||
}
|
}
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
setActionState({
|
setActionState({ loading: false });
|
||||||
loading: false,
|
setSelectedIds(new Set());
|
||||||
message: `Abrechnung Nr. ${result.reportNumber} wurde erstellt.`,
|
toast.success(`Abrechnung Nr. ${result.reportNumber} wurde erstellt.`);
|
||||||
isError: false,
|
router.refresh();
|
||||||
});
|
|
||||||
window.location.reload();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setActionState({
|
setActionState({ loading: false });
|
||||||
loading: false,
|
toast.error(error instanceof Error ? error.message : billingErrorMessage(null));
|
||||||
message: error instanceof Error ? error.message : "Abrechnung fehlgeschlagen",
|
}
|
||||||
isError: true,
|
}
|
||||||
});
|
|
||||||
|
async function handleToggleCollab(position: BillingPosition) {
|
||||||
|
setActionState({ loading: true });
|
||||||
|
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(billingErrorMessage(body.code));
|
||||||
|
}
|
||||||
|
setActionState({ loading: false });
|
||||||
|
toast.success(position.collab ? "Collab-Kennzeichnung entfernt." : "Als Collab-Nutzung markiert.");
|
||||||
|
router.refresh();
|
||||||
|
} catch (error) {
|
||||||
|
setActionState({ loading: false });
|
||||||
|
toast.error(error instanceof Error ? error.message : billingErrorMessage(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const quarterParam = isQuarter ? null : Math.ceil((month ?? 1) / 3);
|
|
||||||
const quarterHref = quarter
|
|
||||||
? `/admin/abrechnungen/${editorialId}?year=${year}&quarter=${quarter}`
|
|
||||||
: `/admin/abrechnungen/${editorialId}?year=${year}&quarter=${quarterParam}`;
|
|
||||||
const monthHref = `/admin/abrechnungen/${editorialId}?year=${year}&month=${month ?? (quarter ? (quarter - 1) * 3 + 1 : new Date().getUTCMonth() + 1)}`;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PeriodSelector year={year} month={month} quarter={quarter} isQuarter={isQuarter} />
|
<PeriodSelector year={year} quarter={quarter} />
|
||||||
|
|
||||||
<div className="billing-selection-controls">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
<button type="button" onClick={selectAllOpen} disabled={selectablePositions.length === 0}>
|
<Button type="button" variant="secondary" onClick={selectAllOpen} disabled={selectablePositions.length === 0}>
|
||||||
{isQuarter ? "Alle offenen im Quartal" : "Alle offenen im Monat"}
|
Alle offenen im Quartal
|
||||||
</button>
|
</Button>
|
||||||
{isQuarter ? (
|
<Button type="button" variant="ghost" onClick={clearSelection} disabled={selectedCount === 0}>
|
||||||
<Link href={monthHref} className="billing-nav-link">
|
|
||||||
Monatsansicht
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<Link href={quarterHref} className="billing-nav-link">
|
|
||||||
Ganzes Quartal
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
<button type="button" onClick={clearSelection} disabled={selectedCount === 0}>
|
|
||||||
Auswahl aufheben
|
Auswahl aufheben
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
<p className="ml-auto text-sm text-[var(--color-fg-muted)]" aria-live="polite">
|
||||||
|
|
||||||
<p className="billing-period-label" aria-live="polite">
|
|
||||||
Zeitraum: {periodLabel}
|
Zeitraum: {periodLabel}
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section className="flex flex-col gap-3" aria-labelledby="positions-title">
|
||||||
|
<h2 id="positions-title" className="text-lg font-semibold">Abrechenbare Nutzungen</h2>
|
||||||
{positions.length === 0 ? (
|
{positions.length === 0 ? (
|
||||||
<p className="billing-empty">Keine abrechenbaren Nutzungen in diesem Zeitraum.</p>
|
<EmptyState title="Keine abrechenbaren Nutzungen in diesem Zeitraum." description="Wählen Sie oben ein anderes Quartal." />
|
||||||
) : (
|
) : (
|
||||||
<table className="billing-table">
|
<Table<BillingPosition>
|
||||||
<caption className="billing-caption">
|
rowKey={(position) => position.id}
|
||||||
Abrechenbare Nutzungen
|
rows={positions}
|
||||||
</caption>
|
columns={[
|
||||||
<thead>
|
{
|
||||||
<tr>
|
key: "id",
|
||||||
<th scope="col">Auswahl</th>
|
header: "Auswahl",
|
||||||
<th scope="col">Datei</th>
|
render: (position) => (
|
||||||
<th scope="col">Album</th>
|
<Checkbox
|
||||||
<th scope="col">Zweck</th>
|
|
||||||
<th scope="col">Referenz</th>
|
|
||||||
<th scope="col">Preis</th>
|
|
||||||
<th scope="col">Status</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{positions.map((position) => (
|
|
||||||
<tr key={position.id} className={position.selectable ? "" : "billing-row-billed"}>
|
|
||||||
<td>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={selectedIds.has(position.id)}
|
|
||||||
onChange={() => togglePosition(position.id)}
|
|
||||||
disabled={!position.selectable}
|
|
||||||
aria-label={`${position.filename} auswählen`}
|
aria-label={`${position.filename} auswählen`}
|
||||||
|
checked={selectedIds.has(position.id)}
|
||||||
|
disabled={!position.selectable}
|
||||||
|
onChange={() => togglePosition(position.id)}
|
||||||
/>
|
/>
|
||||||
</td>
|
),
|
||||||
<td>{position.filename}</td>
|
},
|
||||||
<td>{position.albumName}</td>
|
{ key: "filename", header: "Datei" },
|
||||||
<td>{position.purpose}</td>
|
{ key: "albumName", header: "Album" },
|
||||||
<td>{position.reference ?? "—"}</td>
|
{ key: "purpose", header: "Zweck" },
|
||||||
<td className="billing-price">{formatCents(position.priceCents)}</td>
|
{ key: "reference", header: "Referenz", render: (position) => position.reference ?? "—" },
|
||||||
<td>
|
{
|
||||||
<span className="billing-status">
|
key: "priceCents",
|
||||||
{STATUS_LABELS[position.status]}
|
header: "Preis",
|
||||||
|
align: "right",
|
||||||
|
render: (position) => (
|
||||||
|
<span className="flex flex-col items-end gap-1">
|
||||||
|
<span className="flex items-center gap-2 tabular-nums">
|
||||||
|
{formatCents(position.priceCents)}
|
||||||
|
{position.collab && <Badge variant="neutral">Collab</Badge>}
|
||||||
|
</span>
|
||||||
|
{position.selectable && (
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => handleToggleCollab(position)}
|
||||||
|
disabled={actionState.loading}
|
||||||
|
>
|
||||||
|
{position.collab ? "Collab entfernen" : "Als Collab markieren"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "status",
|
||||||
|
header: "Status",
|
||||||
|
render: (position) => (
|
||||||
|
<span className="flex flex-wrap items-center gap-2">
|
||||||
|
<Badge variant={STATUS_BADGES[position.status] ?? "neutral"}>{STATUS_LABELS[position.status]}</Badge>
|
||||||
{position.status === "billed" && position.reportNumber !== null && (
|
{position.status === "billed" && position.reportNumber !== null && (
|
||||||
<span className="billing-report-ref">
|
<span className="text-xs text-[var(--color-fg-muted)]">
|
||||||
{" "}· Bericht Nr. {position.reportNumber}
|
Bericht Nr. {position.reportNumber}
|
||||||
{position.invoiceNumber ? ` · ${position.invoiceNumber}` : ""}
|
{position.invoiceNumber ? ` · ${position.invoiceNumber}` : ""}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
),
|
||||||
</tr>
|
},
|
||||||
))}
|
]}
|
||||||
</tbody>
|
/>
|
||||||
</table>
|
|
||||||
)}
|
)}
|
||||||
|
</section>
|
||||||
|
|
||||||
{repeatDownloads.length > 0 && (
|
{repeatDownloads.length > 0 && (
|
||||||
<section aria-labelledby="repeat-downloads-title" className="billing-repeat-section">
|
<section aria-labelledby="repeat-downloads-title" className="flex flex-col gap-3">
|
||||||
<h2 id="repeat-downloads-title">Kostenlose Wiederabrufe</h2>
|
<h2 id="repeat-downloads-title" className="text-lg font-semibold">Kostenlose Wiederabrufe</h2>
|
||||||
<p className="form-note">
|
<p className="text-sm text-[var(--color-fg-muted)]">
|
||||||
Wiederholte Downloads rufen bereits abgerechnete Nutzungen erneut ab und sind nicht
|
Wiederholte Downloads rufen bereits abgerechnete Nutzungen erneut ab und sind nicht
|
||||||
abrechenbar.
|
abrechenbar.
|
||||||
</p>
|
</p>
|
||||||
<table className="billing-table billing-table-repeat">
|
<Table<RepeatDownloadPosition>
|
||||||
<caption className="billing-caption">Wiederabrufe im Zeitraum</caption>
|
rowKey={(download) => download.id}
|
||||||
<thead>
|
rows={repeatDownloads}
|
||||||
<tr>
|
columns={[
|
||||||
<th scope="col">Datei</th>
|
{ key: "assetId", header: "Datei" },
|
||||||
<th scope="col">Datum</th>
|
{
|
||||||
<th scope="col">Status</th>
|
key: "authorizedAt",
|
||||||
<th scope="col">Notiz</th>
|
header: "Datum",
|
||||||
</tr>
|
render: (download) => (
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{repeatDownloads.map((download) => (
|
|
||||||
<tr key={download.id}>
|
|
||||||
<td>{download.assetId}</td>
|
|
||||||
<td>
|
|
||||||
<time dateTime={download.authorizedAt.toISOString()} suppressHydrationWarning>
|
<time dateTime={download.authorizedAt.toISOString()} suppressHydrationWarning>
|
||||||
{download.authorizedAt.toLocaleDateString("de-DE")}
|
{download.authorizedAt.toLocaleDateString("de-DE")}
|
||||||
</time>
|
</time>
|
||||||
</td>
|
),
|
||||||
<td>{download.status}</td>
|
},
|
||||||
<td>{download.repeatDownloadNote ?? "—"}</td>
|
{ key: "status", header: "Status" },
|
||||||
</tr>
|
{ key: "repeatDownloadNote", header: "Notiz", render: (download) => download.repeatDownloadNote ?? "—" },
|
||||||
))}
|
]}
|
||||||
</tbody>
|
/>
|
||||||
</table>
|
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="billing-summary" aria-live="polite">
|
<Card>
|
||||||
<p>
|
<div className="flex flex-wrap items-center justify-between gap-4">
|
||||||
<strong>{selectedCount}</strong> {selectedCount === 1 ? "Nutzung" : "Nutzungen"} ausgewählt
|
<div aria-live="polite" className="billing-summary flex flex-col gap-1">
|
||||||
|
<p className="text-sm text-[var(--color-fg-muted)]">
|
||||||
|
<strong className="text-[var(--color-fg-default)]">{selectedCount}</strong> {selectedCount === 1 ? "Nutzung" : "Nutzungen"} ausgewählt
|
||||||
</p>
|
</p>
|
||||||
<p className="billing-summary-total">
|
<p className="text-2xl font-semibold tabular-nums">
|
||||||
Summe: <strong>{formatCents(selectedTotalCents)}</strong>
|
Summe: <strong>{formatCents(selectedTotalCents)}</strong>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-wrap gap-3">
|
||||||
<div className="billing-actions">
|
<Button type="button" variant="outline" onClick={handlePreview} disabled={selectedCount === 0 || actionState.loading}>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={handlePreview}
|
|
||||||
disabled={selectedCount === 0 || actionState.loading}
|
|
||||||
>
|
|
||||||
Vorschau
|
Vorschau
|
||||||
</button>
|
</Button>
|
||||||
<button
|
<Button type="button" onClick={handleFinalize} disabled={selectedCount === 0 || actionState.loading}>
|
||||||
type="button"
|
|
||||||
className="billing-action-primary"
|
|
||||||
onClick={handleFinalize}
|
|
||||||
disabled={selectedCount === 0 || actionState.loading}
|
|
||||||
>
|
|
||||||
Abrechnung erstellen
|
Abrechnung erstellen
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{actionState.message && (
|
</Card>
|
||||||
<p className="billing-status-message" role={actionState.isError ? "alert" : "status"}>
|
|
||||||
{actionState.message}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{reports.length > 0 && (
|
{reports.length > 0 && (
|
||||||
<section aria-labelledby="reports-title" className="billing-reports-section">
|
<section aria-labelledby="reports-title" className="flex flex-col gap-3">
|
||||||
<h2 id="reports-title">Erstellte Abrechnungen</h2>
|
<h2 id="reports-title" className="text-lg font-semibold">Erstellte Abrechnungen</h2>
|
||||||
<ul className="billing-reports-list">
|
<ul className="flex flex-col gap-3">
|
||||||
{reports.map((report) => (
|
{reports.map((report) => (
|
||||||
<li key={report.id}>
|
<li key={report.id}>
|
||||||
<div className="billing-report-meta">
|
<Card>
|
||||||
<span>Bericht Nr. {report.reportNumber}</span>
|
<div className="flex flex-wrap items-center gap-x-4 gap-y-2 text-sm">
|
||||||
|
<span className="inline-flex items-center gap-2 font-semibold">
|
||||||
|
<IconFileText size={16} aria-hidden="true" />
|
||||||
|
Bericht Nr. {report.reportNumber}
|
||||||
|
</span>
|
||||||
{report.invoiceNumber && <span>{report.invoiceNumber}</span>}
|
{report.invoiceNumber && <span>{report.invoiceNumber}</span>}
|
||||||
<span>Summe: {formatCents(report.netTotalCents)}</span>
|
<span className="tabular-nums">Summe: {formatCents(report.netTotalCents)}</span>
|
||||||
<span>Status: {REPORT_STATUS_LABELS[report.status] ?? report.status}</span>
|
<Badge variant={report.status === "final" ? "success" : "neutral"}>
|
||||||
<span>
|
{REPORT_STATUS_LABELS[report.status] ?? report.status}
|
||||||
|
</Badge>
|
||||||
|
<span className="text-[var(--color-fg-muted)]">
|
||||||
Erstellt am:{" "}
|
Erstellt am:{" "}
|
||||||
<time dateTime={report.createdAt.toISOString()} suppressHydrationWarning>
|
<time dateTime={report.createdAt.toISOString()} suppressHydrationWarning>
|
||||||
{report.createdAt.toLocaleDateString("de-DE")}
|
{report.createdAt.toLocaleDateString("de-DE")}
|
||||||
</time>
|
</time>
|
||||||
</span>
|
</span>
|
||||||
|
{report.status === "final" && (
|
||||||
|
<Button asChild variant="outline">
|
||||||
|
<a className="ml-auto" href={`/api/billing-reports/${encodeURIComponent(report.id)}`} download>
|
||||||
|
<IconDownload size={16} aria-hidden="true" />
|
||||||
|
Nutzungsnachweis herunterladen
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{report.status === "final" && (
|
{report.status === "final" && (
|
||||||
|
<div className="flex flex-col gap-3 rounded-[var(--radius-lg)] border border-[var(--color-border-subtle)] bg-[var(--color-bg-subtle)] p-4">
|
||||||
|
<p className="text-sm font-medium">
|
||||||
|
Rechnung:{" "}
|
||||||
|
{report.invoiceEmailStatus === "sent" ? (
|
||||||
<>
|
<>
|
||||||
<CancelReportForm reportId={report.id} reportNumber={report.reportNumber} />
|
versendet am{" "}
|
||||||
<a
|
<time
|
||||||
href={`/api/billing-reports/${encodeURIComponent(report.id)}`}
|
dateTime={report.invoiceEmailSentAt?.toISOString()}
|
||||||
className="billing-report-download"
|
suppressHydrationWarning
|
||||||
download
|
|
||||||
>
|
>
|
||||||
PDF herunterladen
|
{report.invoiceEmailSentAt?.toLocaleDateString("de-DE")}
|
||||||
</a>
|
</time>
|
||||||
</>
|
</>
|
||||||
|
) : report.hasInvoicePdf ? (
|
||||||
|
"PDF hinterlegt, Versand fehlgeschlagen"
|
||||||
|
) : (
|
||||||
|
"noch keine PDF hinterlegt"
|
||||||
)}
|
)}
|
||||||
|
</p>
|
||||||
|
<InvoiceUploadForm
|
||||||
|
reportId={report.id}
|
||||||
|
reportNumber={report.reportNumber}
|
||||||
|
hasInvoice={report.hasInvoicePdf}
|
||||||
|
emailFailed={report.hasInvoicePdf && report.invoiceEmailStatus === "failed"}
|
||||||
|
/>
|
||||||
|
{report.hasInvoicePdf && (
|
||||||
|
<Button asChild variant="outline">
|
||||||
|
<a href={`/api/billing-reports/${encodeURIComponent(report.id)}/invoice`} download>
|
||||||
|
<IconDownload size={16} aria-hidden="true" />
|
||||||
|
Rechnungs-PDF herunterladen
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{report.status === "final" && (
|
||||||
|
<CancelReportForm reportId={report.id} reportNumber={report.reportNumber} />
|
||||||
|
)}
|
||||||
|
</Card>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -355,64 +382,146 @@ export function BillingSelection({
|
|||||||
|
|
||||||
type PeriodSelectorProps = {
|
type PeriodSelectorProps = {
|
||||||
year: number;
|
year: number;
|
||||||
month: number | null;
|
quarter: number;
|
||||||
quarter: number | null;
|
|
||||||
isQuarter: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function PeriodSelector({ year, month, quarter, isQuarter }: PeriodSelectorProps) {
|
function PeriodSelector({ year, quarter }: PeriodSelectorProps) {
|
||||||
const years = [2025, 2026, 2027];
|
const years = [2025, 2026, 2027];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="billing-period-selector" method="get">
|
<Card>
|
||||||
<label>
|
<form className="flex flex-wrap items-end gap-4" method="get">
|
||||||
<span>Jahr</span>
|
<div className="w-32">
|
||||||
<select name="year" defaultValue={year}>
|
<FormSelect name="year" label="Jahr" defaultValue={String(year)} options={years.map((y) => ({ label: String(y), value: String(y) }))} />
|
||||||
{years.map((y) => (
|
</div>
|
||||||
<option key={y} value={y}>
|
<div className="w-32">
|
||||||
{y}
|
<FormSelect
|
||||||
</option>
|
name="quarter"
|
||||||
))}
|
label="Quartal"
|
||||||
</select>
|
defaultValue={String(quarter)}
|
||||||
</label>
|
options={[1, 2, 3, 4].map((q) => ({ label: `Q${q}`, value: String(q) }))}
|
||||||
{isQuarter ? (
|
/>
|
||||||
<label>
|
</div>
|
||||||
<span>Quartal</span>
|
<Button type="submit" variant="secondary">Zeitraum laden</Button>
|
||||||
<select name="quarter" defaultValue={quarter ?? 1}>
|
</form>
|
||||||
{[1, 2, 3, 4].map((q) => (
|
</Card>
|
||||||
<option key={q} value={q}>
|
);
|
||||||
Q{q}
|
}
|
||||||
</option>
|
|
||||||
))}
|
type InvoiceUploadFormProps = {
|
||||||
</select>
|
reportId: string;
|
||||||
</label>
|
reportNumber: number;
|
||||||
) : (
|
hasInvoice: boolean;
|
||||||
<label>
|
emailFailed: boolean;
|
||||||
<span>Monat</span>
|
};
|
||||||
<select name="month" defaultValue={month ?? 8}>
|
|
||||||
{MONTHS.map((name, index) => (
|
function InvoiceUploadForm({ reportId, reportNumber, hasInvoice, emailFailed }: InvoiceUploadFormProps) {
|
||||||
<option key={index} value={index + 1}>
|
const router = useRouter();
|
||||||
{name}
|
const [file, setFile] = useState<File | null>(null);
|
||||||
</option>
|
const [loading, setLoading] = useState(false);
|
||||||
))}
|
|
||||||
</select>
|
async function handleUpload(event: React.FormEvent) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (!file || loading) return;
|
||||||
|
setLoading(true);
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
toast.success(`Rechnung zu Bericht Nr. ${reportNumber} hochgeladen. Der Versand an die Redaktion läuft.`);
|
||||||
|
router.refresh();
|
||||||
|
} catch (err) {
|
||||||
|
toast.error(err instanceof Error ? err.message : invoiceErrorMessage(null));
|
||||||
|
}
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleResend() {
|
||||||
|
if (loading) return;
|
||||||
|
setLoading(true);
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
toast.success("Rechnung erneut versendet.");
|
||||||
|
router.refresh();
|
||||||
|
} catch (err) {
|
||||||
|
toast.error(err instanceof Error ? err.message : invoiceErrorMessage(null));
|
||||||
|
}
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form className="flex flex-col gap-3" onSubmit={handleUpload}>
|
||||||
|
<label className="flex flex-col gap-1 text-sm font-medium">
|
||||||
|
<span>
|
||||||
|
{hasInvoice ? "Rechnungs-PDF ersetzen" : "Rechnungs-PDF hochladen"} (Bericht Nr. {reportNumber})
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
accept="application/pdf,.pdf"
|
||||||
|
required
|
||||||
|
disabled={loading}
|
||||||
|
onChange={(event) => setFile(event.target.files?.[0] ?? null)}
|
||||||
|
aria-label={`Rechnungs-PDF für Bericht Nr. ${reportNumber}`}
|
||||||
|
className="text-sm text-[var(--color-fg-muted)] file:mr-3 file:rounded-[var(--radius-md)] file:border file:border-[var(--color-border-subtle)] file:bg-[var(--color-bg-surface)] file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-[var(--color-fg-default)]"
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<Button type="submit" disabled={!file || loading}>
|
||||||
|
{loading ? "Wird gesendet…" : "Hochladen & senden"}
|
||||||
|
</Button>
|
||||||
|
{hasInvoice && (
|
||||||
|
<Button type="button" variant="outline" onClick={handleResend} disabled={loading}>
|
||||||
|
{emailFailed ? "Erneut senden" : "Nochmal senden"}
|
||||||
|
</Button>
|
||||||
)}
|
)}
|
||||||
<button type="submit">Zeitraum laden</button>
|
</div>
|
||||||
|
<p className="text-xs text-[var(--color-fg-muted)]">
|
||||||
|
Nach dem Upload geht die Rechnung gebündelt mit dem Nutzungsnachweis automatisch per
|
||||||
|
E-Mail an die Redaktion.
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = {
|
type CancelReportFormProps = {
|
||||||
reportId: string;
|
reportId: string;
|
||||||
reportNumber: number;
|
reportNumber: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
|
function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
|
||||||
|
const router = useRouter();
|
||||||
const [reason, setReason] = useState("");
|
const [reason, setReason] = useState("");
|
||||||
const [confirmed, setConfirmed] = useState(false);
|
const [confirmed, setConfirmed] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
|
|
||||||
const trimmed = reason.trim();
|
const trimmed = reason.trim();
|
||||||
const valid = trimmed.length >= 5 && trimmed.length <= 500 && confirmed;
|
const valid = trimmed.length >= 5 && trimmed.length <= 500 && confirmed;
|
||||||
@@ -421,7 +530,6 @@ function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/billing-reports/${encodeURIComponent(reportId)}/cancel`, {
|
const response = await fetch(`/api/billing-reports/${encodeURIComponent(reportId)}/cancel`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -430,48 +538,62 @@ function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
|
|||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const body = await response.json().catch(() => ({ code: "ERROR" }));
|
const body = await response.json().catch(() => ({ code: "ERROR" }));
|
||||||
throw new Error(body.code ?? "Stornierung fehlgeschlagen");
|
throw new Error(billingErrorMessage(body.code));
|
||||||
}
|
}
|
||||||
window.location.reload();
|
toast.success(`Bericht Nr. ${reportNumber} storniert. Die Nutzungen sind wieder offen.`);
|
||||||
|
router.refresh();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : "Stornierung fehlgeschlagen");
|
toast.error(err instanceof Error ? err.message : billingErrorMessage(null));
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="billing-cancel-form" onSubmit={handleSubmit}>
|
<form className="flex flex-col gap-3 border-t border-[var(--color-border-subtle)] pt-4" onSubmit={handleSubmit}>
|
||||||
<label>
|
<Textarea
|
||||||
<span>Stornierungsgrund (5–500 Zeichen)</span>
|
|
||||||
<textarea
|
|
||||||
value={reason}
|
|
||||||
onChange={(e) => setReason(e.target.value)}
|
|
||||||
rows={2}
|
|
||||||
maxLength={500}
|
|
||||||
aria-label={`Stornierungsgrund für Bericht Nr. ${reportNumber}`}
|
aria-label={`Stornierungsgrund für Bericht Nr. ${reportNumber}`}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
|
label="Stornierungsgrund (5–500 Zeichen)"
|
||||||
|
maxLength={500}
|
||||||
|
onChange={(e) => setReason(e.target.value)}
|
||||||
|
rows={2}
|
||||||
|
value={reason}
|
||||||
/>
|
/>
|
||||||
</label>
|
<div className="flex flex-wrap items-center gap-4">
|
||||||
<div className="billing-cancel-controls">
|
<Checkbox
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={confirmed}
|
checked={confirmed}
|
||||||
onChange={(e) => setConfirmed(e.target.checked)}
|
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
aria-label="Stornierung bestätigen"
|
label="Stornierung bestätigen"
|
||||||
|
onChange={(e) => setConfirmed(e.target.checked)}
|
||||||
/>
|
/>
|
||||||
<span>Stornierung bestätigen</span>
|
<Button type="submit" variant="destructive" disabled={!valid || loading}>
|
||||||
</label>
|
|
||||||
<button type="submit" disabled={!valid || loading}>
|
|
||||||
{loading ? "Wird storniert …" : "Stornieren"}
|
{loading ? "Wird storniert …" : "Stornieren"}
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{error && (
|
|
||||||
<p className="billing-status-message" role="alert">
|
|
||||||
{error}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function billingErrorMessage(code: unknown): string {
|
||||||
|
switch (code) {
|
||||||
|
case "NO_USAGES_SELECTED":
|
||||||
|
return "Bitte mindestens eine offene Nutzung auswählen.";
|
||||||
|
case "USAGE_NOT_ELIGIBLE":
|
||||||
|
case "USAGE_NOT_FOUND":
|
||||||
|
return "Eine der gewählten Nutzungen ist nicht mehr abrechenbar. Bitte die Seite neu laden.";
|
||||||
|
case "ADDRESS_NOT_FOUND":
|
||||||
|
return "Für diese Redaktion fehlt die Rechnungsadresse.";
|
||||||
|
case "EDITORIAL_NOT_FOUND":
|
||||||
|
return "Diese Redaktion existiert nicht mehr.";
|
||||||
|
case "REPORT_NOT_FOUND":
|
||||||
|
return "Dieser Bericht existiert nicht mehr.";
|
||||||
|
case "INVALID_CANCELLATION_REASON":
|
||||||
|
return "Bitte einen Stornierungsgrund mit 5 bis 500 Zeichen angeben.";
|
||||||
|
case "REPORT_NUMBER_COLLISION":
|
||||||
|
return "Die Berichtsnummer war gerade vergeben. Bitte erneut versuchen.";
|
||||||
|
case "RATE_LIMITED":
|
||||||
|
return "Zu viele Versuche. Bitte kurz warten.";
|
||||||
|
default:
|
||||||
|
return "Der Vorgang ist fehlgeschlagen. Bitte erneut versuchen.";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { expect, test } from "vitest";
|
||||||
|
|
||||||
|
import { resolvePeriod } from "./page-content";
|
||||||
|
|
||||||
|
test("resolvePeriod is always quarterly", () => {
|
||||||
|
expect(resolvePeriod({ year: "2026", quarter: "4" })).toMatchObject({ year: 2026, quarter: 4, periodLabel: "Q4 2026" });
|
||||||
|
// Old month links land in their quarter.
|
||||||
|
expect(resolvePeriod({ year: "2026", month: "8" })).toMatchObject({ quarter: 3, periodLabel: "Q3 2026" });
|
||||||
|
// Invalid quarters fall back to the current one instead of throwing.
|
||||||
|
const current = Math.floor(new Date().getUTCMonth() / 3) + 1;
|
||||||
|
expect(resolvePeriod({ year: "2026", quarter: "7" }).quarter).toBe(current);
|
||||||
|
expect(resolvePeriod({}).quarter).toBe(current);
|
||||||
|
});
|
||||||
@@ -5,7 +5,7 @@ import { desc, eq } from "drizzle-orm";
|
|||||||
import { db } from "@/db/client";
|
import { db } from "@/db/client";
|
||||||
import { billingReports, editorialAccounts } from "@/db/schema";
|
import { billingReports, editorialAccounts } from "@/db/schema";
|
||||||
import { queries } from "@/modules/billing/queries";
|
import { queries } from "@/modules/billing/queries";
|
||||||
import { monthPeriod, quarterPeriod, type BillingPeriod } from "@/modules/billing/period";
|
import { quarterPeriod, type BillingPeriod } from "@/modules/billing/period";
|
||||||
import type { BillingPosition, RepeatDownloadPosition } from "@/modules/billing/queries";
|
import type { BillingPosition, RepeatDownloadPosition } from "@/modules/billing/queries";
|
||||||
|
|
||||||
export type FinalizedReportSummary = {
|
export type FinalizedReportSummary = {
|
||||||
@@ -15,16 +15,18 @@ export type FinalizedReportSummary = {
|
|||||||
netTotalCents: number;
|
netTotalCents: number;
|
||||||
status: string;
|
status: string;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
hasInvoicePdf: boolean;
|
||||||
|
invoiceUploadedAt: Date | null;
|
||||||
|
invoiceEmailStatus: string;
|
||||||
|
invoiceEmailSentAt: Date | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BillingSelectionData = {
|
export type BillingSelectionData = {
|
||||||
editorial: { id: string; name: string };
|
editorial: { id: string; name: string };
|
||||||
period: BillingPeriod;
|
period: BillingPeriod;
|
||||||
periodLabel: string;
|
periodLabel: string;
|
||||||
isQuarter: boolean;
|
|
||||||
year: number;
|
year: number;
|
||||||
month: number | null;
|
quarter: number;
|
||||||
quarter: number | null;
|
|
||||||
positions: BillingPosition[];
|
positions: BillingPosition[];
|
||||||
repeatDownloads: RepeatDownloadPosition[];
|
repeatDownloads: RepeatDownloadPosition[];
|
||||||
reports: FinalizedReportSummary[];
|
reports: FinalizedReportSummary[];
|
||||||
@@ -41,7 +43,7 @@ export async function loadBillingSelection(
|
|||||||
.limit(1);
|
.limit(1);
|
||||||
if (!editorial) return null;
|
if (!editorial) return null;
|
||||||
|
|
||||||
const { period, isQuarter, year, month, quarter, periodLabel } = resolvePeriod(searchParams);
|
const { period, year, quarter, periodLabel } = resolvePeriod(searchParams);
|
||||||
|
|
||||||
const [positions, repeatDownloads, reportRows] = await Promise.all([
|
const [positions, repeatDownloads, reportRows] = await Promise.all([
|
||||||
queries.listBillablePositions(editorialId, period),
|
queries.listBillablePositions(editorialId, period),
|
||||||
@@ -54,6 +56,10 @@ export async function loadBillingSelection(
|
|||||||
netTotalCents: billingReports.netTotalCents,
|
netTotalCents: billingReports.netTotalCents,
|
||||||
status: billingReports.status,
|
status: billingReports.status,
|
||||||
createdAt: billingReports.createdAt,
|
createdAt: billingReports.createdAt,
|
||||||
|
invoicePdfSha256: billingReports.invoicePdfSha256,
|
||||||
|
invoiceUploadedAt: billingReports.invoiceUploadedAt,
|
||||||
|
invoiceEmailStatus: billingReports.invoiceEmailStatus,
|
||||||
|
invoiceEmailSentAt: billingReports.invoiceEmailSentAt,
|
||||||
})
|
})
|
||||||
.from(billingReports)
|
.from(billingReports)
|
||||||
.where(eq(billingReports.editorialAccountId, editorialId))
|
.where(eq(billingReports.editorialAccountId, editorialId))
|
||||||
@@ -64,9 +70,7 @@ export async function loadBillingSelection(
|
|||||||
editorial,
|
editorial,
|
||||||
period,
|
period,
|
||||||
periodLabel,
|
periodLabel,
|
||||||
isQuarter,
|
|
||||||
year,
|
year,
|
||||||
month,
|
|
||||||
quarter,
|
quarter,
|
||||||
positions,
|
positions,
|
||||||
repeatDownloads,
|
repeatDownloads,
|
||||||
@@ -77,64 +81,34 @@ export async function loadBillingSelection(
|
|||||||
netTotalCents: row.netTotalCents,
|
netTotalCents: row.netTotalCents,
|
||||||
status: row.status,
|
status: row.status,
|
||||||
createdAt: row.createdAt,
|
createdAt: row.createdAt,
|
||||||
|
hasInvoicePdf: row.invoicePdfSha256 !== null,
|
||||||
|
invoiceUploadedAt: row.invoiceUploadedAt,
|
||||||
|
invoiceEmailStatus: row.invoiceEmailStatus,
|
||||||
|
invoiceEmailSentAt: row.invoiceEmailSentAt,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Billing is always quarterly. An old `?month=` link resolves to its quarter;
|
||||||
|
* invalid values fall back to the current quarter.
|
||||||
|
*/
|
||||||
export function resolvePeriod(searchParams: Record<string, string | string[] | undefined>): {
|
export function resolvePeriod(searchParams: Record<string, string | string[] | undefined>): {
|
||||||
period: BillingPeriod;
|
period: BillingPeriod;
|
||||||
isQuarter: boolean;
|
|
||||||
year: number;
|
year: number;
|
||||||
month: number | null;
|
quarter: number;
|
||||||
quarter: number | null;
|
|
||||||
periodLabel: string;
|
periodLabel: string;
|
||||||
} {
|
} {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const defaultYear = now.getUTCFullYear();
|
const currentQuarter = Math.floor(now.getUTCMonth() / 3) + 1;
|
||||||
const defaultMonth = now.getUTCMonth() + 1;
|
const year = parseNumberParam(searchParams.year, now.getUTCFullYear());
|
||||||
|
const month = parseNumberParam(searchParams.month, 0);
|
||||||
const year = parseNumberParam(searchParams.year, defaultYear);
|
const requested = parseNumberParam(
|
||||||
const quarterParam = firstParam(searchParams.quarter);
|
searchParams.quarter,
|
||||||
|
month >= 1 && month <= 12 ? Math.floor((month - 1) / 3) + 1 : currentQuarter,
|
||||||
if (quarterParam !== undefined) {
|
);
|
||||||
const quarter = parseNumberParam(searchParams.quarter, Math.floor((defaultMonth - 1) / 3) + 1);
|
const quarter = requested >= 1 && requested <= 4 ? requested : currentQuarter;
|
||||||
return {
|
return { period: quarterPeriod(year, quarter), year, quarter, periodLabel: `Q${quarter} ${year}` };
|
||||||
period: quarterPeriod(year, quarter),
|
|
||||||
isQuarter: true,
|
|
||||||
year,
|
|
||||||
month: null,
|
|
||||||
quarter,
|
|
||||||
periodLabel: `Q${quarter} ${year}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const month = parseNumberParam(searchParams.month, defaultMonth);
|
|
||||||
return {
|
|
||||||
period: monthPeriod(year, month),
|
|
||||||
isQuarter: false,
|
|
||||||
year,
|
|
||||||
month,
|
|
||||||
quarter: null,
|
|
||||||
periodLabel: monthLabel(year, month),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function monthLabel(year: number, month: number): string {
|
|
||||||
const names = [
|
|
||||||
"Januar",
|
|
||||||
"Februar",
|
|
||||||
"März",
|
|
||||||
"April",
|
|
||||||
"Mai",
|
|
||||||
"Juni",
|
|
||||||
"Juli",
|
|
||||||
"August",
|
|
||||||
"September",
|
|
||||||
"Oktober",
|
|
||||||
"November",
|
|
||||||
"Dezember",
|
|
||||||
];
|
|
||||||
return `${names[month - 1]} ${year}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseNumberParam(
|
function parseNumberParam(
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { PageHeader } from "@/components/ui/page-header";
|
||||||
|
|
||||||
import { loadBillingSelection } from "./page-content";
|
import { loadBillingSelection } from "./page-content";
|
||||||
import { BillingSelection } from "./BillingSelection";
|
import { BillingSelection } from "./BillingSelection";
|
||||||
|
|
||||||
@@ -17,21 +20,19 @@ export default async function BillingSelectionPage({
|
|||||||
if (!data) notFound();
|
if (!data) notFound();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="content-section" aria-labelledby="billing-selection-title">
|
<section className="flex flex-col gap-6" aria-labelledby="billing-selection-title">
|
||||||
<p className="eyebrow">Abrechnungen</p>
|
<PageHeader kicker="Abrechnungen" title={data.editorial.name} titleId="billing-selection-title">
|
||||||
<h1 id="billing-selection-title">{data.editorial.name}</h1>
|
<Button asChild variant="outline">
|
||||||
<p>
|
|
||||||
<Link href="/admin/abrechnungen">Zurück zur Übersicht</Link>
|
<Link href="/admin/abrechnungen">Zurück zur Übersicht</Link>
|
||||||
</p>
|
</Button>
|
||||||
|
</PageHeader>
|
||||||
|
|
||||||
<BillingSelection
|
<BillingSelection
|
||||||
editorialId={data.editorial.id}
|
editorialId={data.editorial.id}
|
||||||
positions={data.positions}
|
positions={data.positions}
|
||||||
repeatDownloads={data.repeatDownloads}
|
repeatDownloads={data.repeatDownloads}
|
||||||
year={data.year}
|
year={data.year}
|
||||||
month={data.month}
|
|
||||||
quarter={data.quarter}
|
quarter={data.quarter}
|
||||||
isQuarter={data.isQuarter}
|
|
||||||
periodLabel={data.periodLabel}
|
periodLabel={data.periodLabel}
|
||||||
reports={data.reports}
|
reports={data.reports}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { desc } from "drizzle-orm";
|
import { desc } from "drizzle-orm";
|
||||||
|
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
import { PageHeader } from "@/components/ui/page-header";
|
||||||
|
import { Badge, Card, EmptyState } from "@/components/ui/sakani";
|
||||||
import { db } from "@/db/client";
|
import { db } from "@/db/client";
|
||||||
import { editorialAccounts } from "@/db/schema";
|
import { editorialAccounts } from "@/db/schema";
|
||||||
import { formatCents } from "@/modules/billing/format";
|
import { formatCents } from "@/modules/billing/format";
|
||||||
@@ -18,26 +22,40 @@ export default async function BillingOverviewPage() {
|
|||||||
.orderBy(desc(editorialAccounts.createdAt));
|
.orderBy(desc(editorialAccounts.createdAt));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="content-section" aria-labelledby="billing-title">
|
<section className="flex flex-col gap-6" aria-labelledby="billing-title">
|
||||||
<p className="eyebrow">Abrechnungen</p>
|
<PageHeader
|
||||||
<h1 id="billing-title">Redaktionen</h1>
|
kicker="Abrechnungen"
|
||||||
<p className="form-note">
|
title="Redaktionen"
|
||||||
Wählen Sie eine Redaktion, um deren abrechenbare Nutzungen für einen Monat oder ein Quartal
|
titleId="billing-title"
|
||||||
auszuwählen.
|
description="Wählen Sie eine Redaktion, um deren abrechenbare Nutzungen für ein Quartal auszuwählen."
|
||||||
</p>
|
/>
|
||||||
{editorials.length === 0 ? (
|
{editorials.length === 0 ? (
|
||||||
<p>Noch keine Redaktionen registriert.</p>
|
<EmptyState title="Noch keine Redaktionen registriert." description="Registrierte Redaktionen erscheinen hier zur Abrechnung." />
|
||||||
) : (
|
) : (
|
||||||
<ul className="billing-editorial-list">
|
<ul className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{editorials.map((editorial) => (
|
{editorials.map((editorial) => (
|
||||||
<li key={editorial.id}>
|
<li key={editorial.id}>
|
||||||
<a href={`/admin/abrechnungen/${editorial.id}`}>{editorial.name}</a>
|
<Link
|
||||||
<p>
|
className="block h-full rounded-[var(--radius-xl)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-border-focus)]"
|
||||||
{editorial.contactName} · {editorial.loginEmail} · Status: {editorial.status}
|
href={`/admin/abrechnungen/${editorial.id}`}
|
||||||
{editorial.currentPriceCents === null
|
>
|
||||||
? " · Preis noch nicht festgelegt"
|
<Card interactive className="h-full">
|
||||||
: ` · Netto ${formatCents(editorial.currentPriceCents)}`}
|
<div className="flex items-start justify-between gap-3">
|
||||||
|
<h2 className="text-base font-semibold">{editorial.name}</h2>
|
||||||
|
<Badge variant={editorial.status === "active" ? "success" : editorial.status === "pending_approval" ? "warning" : "danger"}>
|
||||||
|
{editorial.status === "active" ? "Aktiv" : editorial.status === "pending_approval" ? "Ausstehend" : "Gesperrt"}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
<p className="text-sm text-[var(--color-fg-muted)]">
|
||||||
|
{editorial.contactName} · {editorial.loginEmail}
|
||||||
</p>
|
</p>
|
||||||
|
<p className="text-sm font-medium">
|
||||||
|
{editorial.currentPriceCents === null
|
||||||
|
? "Preis noch nicht festgelegt"
|
||||||
|
: `Netto ${formatCents(editorial.currentPriceCents)}`}
|
||||||
|
</p>
|
||||||
|
</Card>
|
||||||
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { beforeEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
const mocks = vi.hoisted(() => {
|
||||||
|
class PrincipalAuthorizationError extends Error {
|
||||||
|
constructor(readonly code: string) {
|
||||||
|
super(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
PrincipalAuthorizationError,
|
||||||
|
headers: vi.fn(),
|
||||||
|
redirect: vi.fn((destination: string): never => {
|
||||||
|
throw new Error(`NEXT_REDIRECT:${destination}`);
|
||||||
|
}),
|
||||||
|
requireAdmin: vi.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
vi.mock("react", () => ({ cache: (callback: unknown) => callback }));
|
||||||
|
vi.mock("next/headers", () => ({ headers: mocks.headers }));
|
||||||
|
vi.mock("next/navigation", () => ({ redirect: mocks.redirect }));
|
||||||
|
vi.mock("@/modules/auth/principal", () => ({
|
||||||
|
PrincipalAuthorizationError: mocks.PrincipalAuthorizationError,
|
||||||
|
requireAdmin: mocks.requireAdmin,
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { PrincipalAuthorizationError } from "@/modules/auth/principal";
|
||||||
|
|
||||||
|
import { requireAdminPage } from "./access";
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
mocks.headers.mockResolvedValue(new Headers());
|
||||||
|
});
|
||||||
|
|
||||||
|
test("redirects an expired admin page loader session to sign-in", async () => {
|
||||||
|
mocks.requireAdmin.mockRejectedValue(
|
||||||
|
new PrincipalAuthorizationError("AUTHENTICATION_REQUIRED"),
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(requireAdminPage()).rejects.toThrow("NEXT_REDIRECT:/anmelden");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("rethrows non-session admin page loader failures unchanged", async () => {
|
||||||
|
const unavailable = new Error("database unavailable");
|
||||||
|
mocks.requireAdmin.mockRejectedValue(unavailable);
|
||||||
|
|
||||||
|
await expect(requireAdminPage()).rejects.toBe(unavailable);
|
||||||
|
});
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import "server-only";
|
||||||
|
|
||||||
|
import { cache } from "react";
|
||||||
|
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
|
||||||
|
import { requirePageAccess } from "@/modules/auth/page-access";
|
||||||
|
import { requireAdmin, requireAdminForSetup } from "@/modules/auth/principal";
|
||||||
|
|
||||||
|
/** Strict guard: valid admin session with finished two-factor setup. */
|
||||||
|
export const requireAdminPage = cache(async () =>
|
||||||
|
requirePageAccess(async () => requireAdmin(new Headers(await headers()))),
|
||||||
|
);
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
// @vitest-environment jsdom
|
||||||
|
|
||||||
|
import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
|
||||||
|
import { afterEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
import {
|
||||||
|
AlbumAccessManager,
|
||||||
|
type AlbumAccessManagerAlbum,
|
||||||
|
type AlbumAccessManagerEditorial,
|
||||||
|
} from "./AlbumAccessManager";
|
||||||
|
import type { AlbumAccessActionResult } from "./actions";
|
||||||
|
|
||||||
|
afterEach(cleanup);
|
||||||
|
|
||||||
|
const albumOne = "11111111-1111-4111-8111-111111111111";
|
||||||
|
const albumTwo = "22222222-2222-4222-8222-222222222222";
|
||||||
|
const editorialOne = "33333333-3333-4333-8333-333333333333";
|
||||||
|
const editorialTwo = "44444444-4444-4444-8444-444444444444";
|
||||||
|
|
||||||
|
const albums: AlbumAccessManagerAlbum[] = [
|
||||||
|
{
|
||||||
|
id: albumOne,
|
||||||
|
albumName: "Pressefotos",
|
||||||
|
albumThumbnailAssetId: null,
|
||||||
|
assetCount: 4,
|
||||||
|
grants: [
|
||||||
|
{ editorialId: editorialOne, editorialName: "Kicker Daily", archived: false },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: albumTwo,
|
||||||
|
albumName: "Spieltagfotos",
|
||||||
|
albumThumbnailAssetId: null,
|
||||||
|
assetCount: 12,
|
||||||
|
grants: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const editorials: AlbumAccessManagerEditorial[] = [
|
||||||
|
{ id: editorialOne, name: "Kicker Daily" },
|
||||||
|
{ id: editorialTwo, name: "Sport Woche" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const okResult: AlbumAccessActionResult = { ok: true, message: "", grantedCount: 0 };
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
const bulkGrantAction = vi.fn().mockResolvedValue(okResult);
|
||||||
|
const revokeAction = vi.fn().mockResolvedValue(okResult);
|
||||||
|
render(
|
||||||
|
<AlbumAccessManager
|
||||||
|
albums={albums}
|
||||||
|
editorials={editorials}
|
||||||
|
bulkGrantAction={bulkGrantAction}
|
||||||
|
revokeAction={revokeAction}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
return { bulkGrantAction, revokeAction };
|
||||||
|
}
|
||||||
|
|
||||||
|
function bulkFieldset() {
|
||||||
|
return within(
|
||||||
|
screen
|
||||||
|
.getByLabelText("Alben für die Bulk-Zuweisung durchsuchen")
|
||||||
|
.closest("fieldset") as HTMLFieldSetElement,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function overviewTable() {
|
||||||
|
return within(screen.getByRole("table"));
|
||||||
|
}
|
||||||
|
|
||||||
|
test("lists every album with its granted editorials and a link to the editorial", () => {
|
||||||
|
setup();
|
||||||
|
|
||||||
|
const overview = overviewTable();
|
||||||
|
const pressefotosRow = overview.getByText("Pressefotos").closest("tr");
|
||||||
|
expect(pressefotosRow?.textContent).toContain("Kicker Daily");
|
||||||
|
expect(
|
||||||
|
overview
|
||||||
|
.getByRole("link", { name: "Kicker Daily" })
|
||||||
|
.getAttribute("href")
|
||||||
|
?.startsWith("/admin/redaktionen/33333333"),
|
||||||
|
).toBe(true);
|
||||||
|
const spieltagRow = overview.getByText("Spieltagfotos").closest("tr");
|
||||||
|
expect(spieltagRow?.textContent).toContain("Noch keine Redaktion");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the grant button stays disabled until an album and an editorial are selected", () => {
|
||||||
|
setup();
|
||||||
|
|
||||||
|
const grantButton = screen.getByRole("button", {
|
||||||
|
name: "Zugriff gewähren",
|
||||||
|
}) as HTMLButtonElement;
|
||||||
|
expect(grantButton.disabled).toBe(true);
|
||||||
|
|
||||||
|
fireEvent.click(bulkFieldset().getByRole("checkbox", { name: /Pressefotos/ }));
|
||||||
|
expect(grantButton.disabled).toBe(true);
|
||||||
|
|
||||||
|
fireEvent.click(screen.getByRole("checkbox", { name: "Sport Woche" }));
|
||||||
|
expect(
|
||||||
|
screen.getByRole("button", { name: "Zugriff gewähren (1 Album, 1 Redaktion)" }),
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("selects all albums via Alle auswählen and clears them again", () => {
|
||||||
|
setup();
|
||||||
|
|
||||||
|
fireEvent.click(bulkFieldset().getByRole("button", { name: /Alle auswählen/i }));
|
||||||
|
expect(
|
||||||
|
screen.getByRole("button", { name: "Zugriff gewähren (2 Alben, 0 Redaktionen)" }),
|
||||||
|
).toBeTruthy();
|
||||||
|
|
||||||
|
fireEvent.click(bulkFieldset().getByRole("button", { name: /Auswahl aufheben/i }));
|
||||||
|
expect(screen.getByRole("button", { name: "Zugriff gewähren" })).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the album search narrows the bulk selection and select-all respects the filter", () => {
|
||||||
|
setup();
|
||||||
|
|
||||||
|
fireEvent.change(screen.getByLabelText("Alben für die Bulk-Zuweisung durchsuchen"), {
|
||||||
|
target: { value: "Spieltag" },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(bulkFieldset().queryByRole("checkbox", { name: /Pressefotos/ })).toBeNull();
|
||||||
|
fireEvent.click(bulkFieldset().getByRole("button", { name: /Alle auswählen/i }));
|
||||||
|
expect(
|
||||||
|
screen.getByRole("button", { name: "Zugriff gewähren (1 Album, 0 Redaktionen)" }),
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the selected checkboxes carry album and editorial ids for the server action", () => {
|
||||||
|
const { bulkGrantAction } = setup();
|
||||||
|
const form = screen
|
||||||
|
.getByRole("button", { name: "Zugriff gewähren" })
|
||||||
|
.closest("form") as HTMLFormElement;
|
||||||
|
|
||||||
|
fireEvent.click(bulkFieldset().getByRole("checkbox", { name: /Pressefotos/ }));
|
||||||
|
fireEvent.click(bulkFieldset().getByRole("checkbox", { name: /Spieltagfotos/ }));
|
||||||
|
fireEvent.click(screen.getByRole("checkbox", { name: "Sport Woche" }));
|
||||||
|
|
||||||
|
const albumValues = [...form.querySelectorAll<HTMLInputElement>('input[name="immichAlbumIds"]')]
|
||||||
|
.filter((input) => input.checked)
|
||||||
|
.map((input) => input.value);
|
||||||
|
const editorialValues = [...form.querySelectorAll<HTMLInputElement>('input[name="editorialIds"]')]
|
||||||
|
.filter((input) => input.checked)
|
||||||
|
.map((input) => input.value);
|
||||||
|
|
||||||
|
expect(albumValues).toEqual([albumOne, albumTwo]);
|
||||||
|
expect(editorialValues).toEqual([editorialTwo]);
|
||||||
|
expect(bulkGrantAction).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the overview search matches album names and granted editorial names", () => {
|
||||||
|
setup();
|
||||||
|
|
||||||
|
fireEvent.change(screen.getByLabelText("Albumzugriffe durchsuchen"), {
|
||||||
|
target: { value: "Kicker" },
|
||||||
|
});
|
||||||
|
|
||||||
|
const overview = overviewTable();
|
||||||
|
expect(overview.queryByText("Spieltagfotos")).toBeNull();
|
||||||
|
expect(overview.getByText("Pressefotos")).toBeTruthy();
|
||||||
|
});
|
||||||
@@ -0,0 +1,370 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
/* eslint-disable @next/next/no-img-element */
|
||||||
|
|
||||||
|
import { useActionState, useMemo, useState, useTransition } from "react";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
import { Checkbox, EmptyState, Input, Table } from "@sakaniui/react";
|
||||||
|
import { IconSearch, IconX } from "@sakaniui/react/icons";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
import type { AlbumAccessActionResult } from "./actions";
|
||||||
|
import { notifyResult, useResultToast } from "@/components/ui/feedback";
|
||||||
|
|
||||||
|
type AccessAction = (
|
||||||
|
state: AlbumAccessActionResult,
|
||||||
|
formData: FormData,
|
||||||
|
) => Promise<AlbumAccessActionResult>;
|
||||||
|
|
||||||
|
type OverviewRow = AlbumAccessManagerAlbum;
|
||||||
|
|
||||||
|
export type AlbumAccessManagerAlbum = {
|
||||||
|
id: string;
|
||||||
|
albumName: string;
|
||||||
|
albumThumbnailAssetId: string | null;
|
||||||
|
assetCount: number;
|
||||||
|
grants: Array<{ editorialId: string; editorialName: string; archived: boolean }>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AlbumAccessManagerEditorial = { id: string; name: string };
|
||||||
|
|
||||||
|
const INITIAL_RESULT: AlbumAccessActionResult = { ok: true, message: "", grantedCount: 0 };
|
||||||
|
|
||||||
|
export function AlbumAccessManager({
|
||||||
|
albums,
|
||||||
|
editorials,
|
||||||
|
bulkGrantAction,
|
||||||
|
revokeAction,
|
||||||
|
}: Readonly<{
|
||||||
|
albums: AlbumAccessManagerAlbum[];
|
||||||
|
editorials: AlbumAccessManagerEditorial[];
|
||||||
|
bulkGrantAction: AccessAction;
|
||||||
|
revokeAction: AccessAction;
|
||||||
|
}>) {
|
||||||
|
const [bulkPending, startBulkTransition] = useTransition();
|
||||||
|
const [revokeState, revokeFormAction, revokePending] = useActionState(
|
||||||
|
revokeAction,
|
||||||
|
INITIAL_RESULT,
|
||||||
|
);
|
||||||
|
useResultToast(revokeState);
|
||||||
|
const [selectedAlbumIds, setSelectedAlbumIds] = useState<ReadonlySet<string>>(new Set());
|
||||||
|
const [selectedEditorialIds, setSelectedEditorialIds] = useState<ReadonlySet<string>>(new Set());
|
||||||
|
const [bulkSearch, setBulkSearch] = useState("");
|
||||||
|
const [overviewSearch, setOverviewSearch] = useState("");
|
||||||
|
|
||||||
|
// Same selection flow as the single-editorial AlbumGrid: call the action in a
|
||||||
|
// transition so the result can clear the checkboxes without an effect.
|
||||||
|
const handleBulkSubmit = (formData: FormData) => {
|
||||||
|
startBulkTransition(async () => {
|
||||||
|
const result = await bulkGrantAction(INITIAL_RESULT, formData);
|
||||||
|
notifyResult(result);
|
||||||
|
if (result.ok && result.grantedCount > 0) {
|
||||||
|
setSelectedAlbumIds(new Set());
|
||||||
|
setSelectedEditorialIds(new Set());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const bulkQuery = bulkSearch.trim().toLowerCase();
|
||||||
|
const bulkAlbums = useMemo(
|
||||||
|
() =>
|
||||||
|
bulkQuery
|
||||||
|
? albums.filter((album) => album.albumName.toLowerCase().includes(bulkQuery))
|
||||||
|
: albums,
|
||||||
|
[albums, bulkQuery],
|
||||||
|
);
|
||||||
|
|
||||||
|
const overviewQuery = overviewSearch.trim().toLowerCase();
|
||||||
|
const overviewAlbums = useMemo(
|
||||||
|
() =>
|
||||||
|
overviewQuery
|
||||||
|
? albums.filter(
|
||||||
|
(album) =>
|
||||||
|
album.albumName.toLowerCase().includes(overviewQuery) ||
|
||||||
|
album.grants.some((holder) =>
|
||||||
|
holder.editorialName.toLowerCase().includes(overviewQuery),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: albums,
|
||||||
|
[albums, overviewQuery],
|
||||||
|
);
|
||||||
|
|
||||||
|
const allBulkAlbumsSelected =
|
||||||
|
bulkAlbums.length > 0 && bulkAlbums.every((album) => selectedAlbumIds.has(album.id));
|
||||||
|
const allEditorialsSelected =
|
||||||
|
editorials.length > 0 && editorials.every((editorial) => selectedEditorialIds.has(editorial.id));
|
||||||
|
|
||||||
|
const toggleAlbumSelection = (albumId: string, selected: boolean) => {
|
||||||
|
setSelectedAlbumIds((previous) => {
|
||||||
|
const next = new Set(previous);
|
||||||
|
if (selected) {
|
||||||
|
next.add(albumId);
|
||||||
|
} else {
|
||||||
|
next.delete(albumId);
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleEditorialSelection = (editorialId: string, selected: boolean) => {
|
||||||
|
setSelectedEditorialIds((previous) => {
|
||||||
|
const next = new Set(previous);
|
||||||
|
if (selected) {
|
||||||
|
next.add(editorialId);
|
||||||
|
} else {
|
||||||
|
next.delete(editorialId);
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleAllBulkAlbums = () => {
|
||||||
|
setSelectedAlbumIds((previous) => {
|
||||||
|
const next = new Set(previous);
|
||||||
|
for (const album of bulkAlbums) {
|
||||||
|
if (allBulkAlbumsSelected) {
|
||||||
|
next.delete(album.id);
|
||||||
|
} else {
|
||||||
|
next.add(album.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleAllEditorials = () => {
|
||||||
|
setSelectedEditorialIds((previous) => {
|
||||||
|
const next = new Set(previous);
|
||||||
|
for (const editorial of editorials) {
|
||||||
|
if (allEditorialsSelected) {
|
||||||
|
next.delete(editorial.id);
|
||||||
|
} else {
|
||||||
|
next.add(editorial.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const canSubmit = selectedAlbumIds.size > 0 && selectedEditorialIds.size > 0;
|
||||||
|
const submitLabel =
|
||||||
|
selectedAlbumIds.size === 0 && selectedEditorialIds.size === 0
|
||||||
|
? "Zugriff gewähren"
|
||||||
|
: `Zugriff gewähren (${selectedAlbumIds.size} ${
|
||||||
|
selectedAlbumIds.size === 1 ? "Album" : "Alben"
|
||||||
|
}, ${selectedEditorialIds.size} ${
|
||||||
|
selectedEditorialIds.size === 1 ? "Redaktion" : "Redaktionen"
|
||||||
|
})`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-6">
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Bulk-Zuweisung</CardTitle>
|
||||||
|
<CardDescription>
|
||||||
|
Alben und Redaktionen auswählen und allen ausgewählten Redaktionen mit einem Klick
|
||||||
|
Zugriff auf alle ausgewählten Alben geben. Bereits bestehende Zuweisungen werden
|
||||||
|
übersprungen.
|
||||||
|
</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<form action={handleBulkSubmit} className="flex flex-col gap-6">
|
||||||
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||||
|
<fieldset className="flex min-w-0 flex-col gap-3">
|
||||||
|
<legend className="mb-3 text-sm font-medium text-[var(--color-fg-muted)]">
|
||||||
|
Alben ({selectedAlbumIds.size} ausgewählt)
|
||||||
|
</legend>
|
||||||
|
<div className="flex flex-col sm:flex-row gap-2">
|
||||||
|
<Input
|
||||||
|
leadingIcon={<IconSearch size={16} />}
|
||||||
|
type="search"
|
||||||
|
value={bulkSearch}
|
||||||
|
onChange={(event) => setBulkSearch(event.target.value)}
|
||||||
|
placeholder="Alben suchen…"
|
||||||
|
aria-label="Alben für die Bulk-Zuweisung durchsuchen"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="whitespace-nowrap"
|
||||||
|
onClick={toggleAllBulkAlbums}
|
||||||
|
disabled={bulkAlbums.length === 0}
|
||||||
|
>
|
||||||
|
{allBulkAlbumsSelected ? "Auswahl aufheben" : "Alle auswählen"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="max-h-80 divide-y divide-[var(--color-border-subtle)] overflow-y-auto rounded-[var(--radius-md)] border border-[var(--color-border-subtle)]">
|
||||||
|
{bulkAlbums.length === 0 ? (
|
||||||
|
<p className="p-4 text-sm text-[var(--color-fg-muted)]">Keine Alben gefunden.</p>
|
||||||
|
) : (
|
||||||
|
bulkAlbums.map((album) => (
|
||||||
|
<div key={album.id} className="flex items-center gap-3 px-4 py-2.5 hover:bg-[var(--color-bg-subtle)]">
|
||||||
|
<Checkbox
|
||||||
|
checked={selectedAlbumIds.has(album.id)}
|
||||||
|
label={album.albumName}
|
||||||
|
name="immichAlbumIds"
|
||||||
|
onChange={(event) => toggleAlbumSelection(album.id, event.target.checked)}
|
||||||
|
value={album.id}
|
||||||
|
/>
|
||||||
|
<span className="ml-auto shrink-0 text-xs text-[var(--color-fg-muted)]">
|
||||||
|
{album.assetCount} Fotos
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset className="flex min-w-0 flex-col gap-3">
|
||||||
|
<legend className="mb-3 text-sm font-medium text-[var(--color-fg-muted)]">
|
||||||
|
Redaktionen ({selectedEditorialIds.size} ausgewählt)
|
||||||
|
</legend>
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={toggleAllEditorials}
|
||||||
|
disabled={editorials.length === 0}
|
||||||
|
>
|
||||||
|
{allEditorialsSelected ? "Auswahl aufheben" : "Alle auswählen"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="max-h-80 divide-y divide-[var(--color-border-subtle)] overflow-y-auto rounded-[var(--radius-md)] border border-[var(--color-border-subtle)]">
|
||||||
|
{editorials.length === 0 ? (
|
||||||
|
<p className="p-4 text-sm text-[var(--color-fg-muted)]">
|
||||||
|
Keine aktiven Redaktionen vorhanden.
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
editorials.map((editorial) => (
|
||||||
|
<div key={editorial.id} className="px-4 py-2.5 hover:bg-[var(--color-bg-subtle)]">
|
||||||
|
<Checkbox
|
||||||
|
checked={selectedEditorialIds.has(editorial.id)}
|
||||||
|
label={editorial.name}
|
||||||
|
name="editorialIds"
|
||||||
|
onChange={(event) => toggleEditorialSelection(editorial.id, event.target.checked)}
|
||||||
|
value={editorial.id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-col sm:flex-row sm:items-center gap-3 sm:justify-between">
|
||||||
|
<p className="text-sm text-[var(--color-fg-muted)]">
|
||||||
|
Wähle mindestens ein Album und eine Redaktion aus.
|
||||||
|
</p>
|
||||||
|
<Button type="submit" disabled={!canSubmit || bulkPending} className="shrink-0">
|
||||||
|
{bulkPending ? "Wird verarbeitet…" : submitLabel}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardHeader className="gap-4">
|
||||||
|
<div>
|
||||||
|
<CardTitle>Albumzugriffe</CardTitle>
|
||||||
|
<CardDescription>
|
||||||
|
Welche Redaktionen Zugriff auf welches Album hat. Ein Klick auf das × entzieht den
|
||||||
|
Zugriff für die einzelne Redaktion.
|
||||||
|
</CardDescription>
|
||||||
|
</div>
|
||||||
|
<div className="sm:max-w-sm">
|
||||||
|
<Input
|
||||||
|
leadingIcon={<IconSearch size={16} />}
|
||||||
|
type="search"
|
||||||
|
value={overviewSearch}
|
||||||
|
onChange={(event) => setOverviewSearch(event.target.value)}
|
||||||
|
placeholder="Album oder Redaktion suchen…"
|
||||||
|
aria-label="Albumzugriffe durchsuchen"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="flex flex-col gap-4">
|
||||||
|
|
||||||
|
{albums.length === 0 ? (
|
||||||
|
<EmptyState title="Derzeit sind keine Alben vorhanden." description="Alben erscheinen hier, sobald der Immich-Zugang sie lesen kann." />
|
||||||
|
) : overviewAlbums.length === 0 ? (
|
||||||
|
<EmptyState type="no-results" title="Keine Alben gefunden." description="Versuchen Sie einen anderen Suchbegriff." />
|
||||||
|
) : (
|
||||||
|
<Table<OverviewRow>
|
||||||
|
rowKey={(album) => album.id}
|
||||||
|
rows={overviewAlbums}
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
key: "albumName",
|
||||||
|
header: "Album",
|
||||||
|
render: (album) => (
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
{album.albumThumbnailAssetId ? (
|
||||||
|
<img
|
||||||
|
className="h-10 w-14 shrink-0 rounded-[var(--radius-sm)] bg-[var(--color-bg-subtle)] object-cover"
|
||||||
|
alt=""
|
||||||
|
loading="lazy"
|
||||||
|
src={`/api/assets/${encodeURIComponent(album.albumThumbnailAssetId)}/thumbnail?albumId=${encodeURIComponent(album.id)}`}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div aria-hidden="true" className="grid h-10 w-14 shrink-0 place-items-center rounded-[var(--radius-sm)] bg-[var(--color-bg-subtle)] text-[10px] text-[var(--color-fg-muted)]">
|
||||||
|
Kein Cover
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="min-w-0">
|
||||||
|
<p className="truncate font-medium" title={album.albumName}>{album.albumName}</p>
|
||||||
|
<p className="text-xs text-[var(--color-fg-muted)]">{album.assetCount} Fotos</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "grants",
|
||||||
|
header: "Redaktionen mit Zugriff",
|
||||||
|
render: (album) =>
|
||||||
|
album.grants.length === 0 ? (
|
||||||
|
<span className="text-[var(--color-fg-muted)]">Noch keine Redaktion</span>
|
||||||
|
) : (
|
||||||
|
<div className="flex flex-wrap gap-1.5">
|
||||||
|
{album.grants.map((holder) => (
|
||||||
|
<form
|
||||||
|
key={holder.editorialId}
|
||||||
|
action={revokeFormAction}
|
||||||
|
className="inline-flex items-center overflow-hidden rounded-[var(--radius-full)] border border-[var(--color-border-default)] bg-[var(--color-bg-subtle)] text-[var(--color-fg-default)]"
|
||||||
|
>
|
||||||
|
<input type="hidden" name="immichAlbumId" value={album.id} />
|
||||||
|
<input type="hidden" name="editorialId" value={holder.editorialId} />
|
||||||
|
<Link
|
||||||
|
href={`/admin/redaktionen/${holder.editorialId}`}
|
||||||
|
className="py-0.5 pl-2.5 text-xs font-medium hover:underline"
|
||||||
|
>
|
||||||
|
{holder.editorialName}
|
||||||
|
{holder.archived ? " (archiviert)" : ""}
|
||||||
|
</Link>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={revokePending}
|
||||||
|
aria-label={`Zugriff auf ${album.albumName} für ${holder.editorialName} entziehen`}
|
||||||
|
title={`Zugriff für ${holder.editorialName} entziehen`}
|
||||||
|
className="grid place-items-center px-1.5 py-1 hover:bg-[var(--color-bg-muted)] disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<IconX size={12} aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{ key: "assetCount", header: "Anzahl", align: "right", render: (album) => <span className="tabular-nums">{album.grants.length}</span> },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
import { beforeEach, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
const mocks = vi.hoisted(() => ({
|
||||||
|
bulkGrantAlbums: vi.fn(),
|
||||||
|
headers: vi.fn(),
|
||||||
|
requireAdmin: vi.fn(),
|
||||||
|
revalidatePath: vi.fn(),
|
||||||
|
revokeAlbum: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
vi.mock("next/headers", () => ({ headers: mocks.headers }));
|
||||||
|
vi.mock("next/cache", () => ({ revalidatePath: mocks.revalidatePath }));
|
||||||
|
vi.mock("@/modules/auth/principal", () => ({ requireAdmin: mocks.requireAdmin }));
|
||||||
|
vi.mock("@/modules/albums/grants", () => ({
|
||||||
|
AlbumGrantError: class AlbumGrantError extends Error {
|
||||||
|
constructor(readonly code: string) {
|
||||||
|
super(code);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
albumGrantService: { bulkGrantAlbums: mocks.bulkGrantAlbums, revokeAlbum: mocks.revokeAlbum },
|
||||||
|
}));
|
||||||
|
|
||||||
|
import { bulkGrantAlbumAccessAction, revokeAlbumAccessAction } from "./actions";
|
||||||
|
|
||||||
|
const initial = { ok: true, message: "", grantedCount: 0 };
|
||||||
|
const albumOne = "11111111-1111-4111-8111-111111111111";
|
||||||
|
const albumTwo = "22222222-2222-4222-8222-222222222222";
|
||||||
|
const editorialOne = "33333333-3333-4333-8333-333333333333";
|
||||||
|
const editorialTwo = "44444444-4444-4444-8444-444444444444";
|
||||||
|
|
||||||
|
function bulkFormData(): FormData {
|
||||||
|
const formData = new FormData();
|
||||||
|
for (const albumId of [albumOne, albumTwo]) {
|
||||||
|
formData.append("immichAlbumIds", albumId);
|
||||||
|
}
|
||||||
|
for (const editorialId of [editorialOne, editorialTwo]) {
|
||||||
|
formData.append("editorialIds", editorialId);
|
||||||
|
}
|
||||||
|
return formData;
|
||||||
|
}
|
||||||
|
|
||||||
|
test("the bulk action rejects unauthenticated callers before touching the service", async () => {
|
||||||
|
mocks.headers.mockResolvedValue(new Headers());
|
||||||
|
mocks.requireAdmin.mockRejectedValue(new Error("ADMIN_REQUIRED"));
|
||||||
|
|
||||||
|
await expect(bulkGrantAlbumAccessAction(initial, bulkFormData())).rejects.toThrow(
|
||||||
|
"ADMIN_REQUIRED",
|
||||||
|
);
|
||||||
|
expect(mocks.bulkGrantAlbums).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the bulk action demands at least one album and one editorial", async () => {
|
||||||
|
mocks.headers.mockResolvedValue(new Headers());
|
||||||
|
mocks.requireAdmin.mockResolvedValue({ userId: "admin-1" });
|
||||||
|
|
||||||
|
const result = await bulkGrantAlbumAccessAction(initial, new FormData());
|
||||||
|
|
||||||
|
expect(result).toMatchObject({ ok: false, grantedCount: 0 });
|
||||||
|
expect(result.message).toContain("mindestens ein Album und eine Redaktion");
|
||||||
|
expect(mocks.bulkGrantAlbums).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the bulk action grants every selected combination and revalidates affected pages", async () => {
|
||||||
|
mocks.headers.mockResolvedValue(new Headers());
|
||||||
|
mocks.requireAdmin.mockResolvedValue({ userId: "admin-1" });
|
||||||
|
mocks.bulkGrantAlbums.mockResolvedValue({ granted: 4, skipped: 0, failed: 0 });
|
||||||
|
|
||||||
|
const result = await bulkGrantAlbumAccessAction(initial, bulkFormData());
|
||||||
|
|
||||||
|
expect(mocks.bulkGrantAlbums).toHaveBeenCalledWith({
|
||||||
|
albumIds: [albumOne, albumTwo],
|
||||||
|
editorialIds: [editorialOne, editorialTwo],
|
||||||
|
adminUserId: "admin-1",
|
||||||
|
});
|
||||||
|
expect(result).toMatchObject({ ok: true, grantedCount: 4 });
|
||||||
|
expect(result.message).toContain("4 Zuweisung(en) erstellt");
|
||||||
|
expect(mocks.revalidatePath).toHaveBeenCalledWith("/admin/alben");
|
||||||
|
expect(mocks.revalidatePath).toHaveBeenCalledWith(`/admin/redaktionen/${editorialOne}/alben`);
|
||||||
|
expect(mocks.revalidatePath).toHaveBeenCalledWith(`/admin/redaktionen/${editorialTwo}/alben`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the bulk action reports skipped and failed pairs in German", async () => {
|
||||||
|
mocks.headers.mockResolvedValue(new Headers());
|
||||||
|
mocks.requireAdmin.mockResolvedValue({ userId: "admin-1" });
|
||||||
|
mocks.bulkGrantAlbums.mockResolvedValue({ granted: 1, skipped: 2, failed: 1 });
|
||||||
|
|
||||||
|
const result = await bulkGrantAlbumAccessAction(initial, bulkFormData());
|
||||||
|
|
||||||
|
expect(result.ok).toBe(false);
|
||||||
|
expect(result.message).toContain("1 Zuweisung(en) erstellt");
|
||||||
|
expect(result.message).toContain("2 bestand(en) bereits");
|
||||||
|
expect(result.message).toContain("1 fehlgeschlagen");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the bulk action returns a German message when Immich is down", async () => {
|
||||||
|
mocks.headers.mockResolvedValue(new Headers());
|
||||||
|
mocks.requireAdmin.mockResolvedValue({ userId: "admin-1" });
|
||||||
|
const { AlbumGrantError } = await import("@/modules/albums/grants");
|
||||||
|
mocks.bulkGrantAlbums.mockRejectedValue(new AlbumGrantError("IMMICH_UNAVAILABLE"));
|
||||||
|
|
||||||
|
const result = await bulkGrantAlbumAccessAction(initial, bulkFormData());
|
||||||
|
|
||||||
|
expect(result).toMatchObject({
|
||||||
|
ok: false,
|
||||||
|
grantedCount: 0,
|
||||||
|
message: "Immich ist momentan nicht erreichbar. Bitte später erneut versuchen.",
|
||||||
|
});
|
||||||
|
expect(mocks.revalidatePath).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the revoke action entzieht a single album-editorial pair", async () => {
|
||||||
|
mocks.headers.mockResolvedValue(new Headers());
|
||||||
|
mocks.requireAdmin.mockResolvedValue({ userId: "admin-1" });
|
||||||
|
mocks.revokeAlbum.mockResolvedValue(undefined);
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.set("immichAlbumId", albumOne);
|
||||||
|
formData.set("editorialId", editorialOne);
|
||||||
|
|
||||||
|
const result = await revokeAlbumAccessAction(initial, formData);
|
||||||
|
|
||||||
|
expect(mocks.revokeAlbum).toHaveBeenCalledWith({
|
||||||
|
editorialId: editorialOne,
|
||||||
|
immichAlbumId: albumOne,
|
||||||
|
adminUserId: "admin-1",
|
||||||
|
});
|
||||||
|
expect(result).toEqual({ ok: true, message: "", grantedCount: 0 });
|
||||||
|
expect(mocks.revalidatePath).toHaveBeenCalledWith("/admin/alben");
|
||||||
|
expect(mocks.revalidatePath).toHaveBeenCalledWith(`/admin/redaktionen/${editorialOne}/alben`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the revoke action rejects malformed identifiers", async () => {
|
||||||
|
mocks.headers.mockResolvedValue(new Headers());
|
||||||
|
mocks.requireAdmin.mockResolvedValue({ userId: "admin-1" });
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.set("immichAlbumId", "not-a-uuid");
|
||||||
|
formData.set("editorialId", editorialOne);
|
||||||
|
|
||||||
|
const result = await revokeAlbumAccessAction(initial, formData);
|
||||||
|
|
||||||
|
expect(result).toMatchObject({ ok: false, grantedCount: 0 });
|
||||||
|
expect(mocks.revokeAlbum).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { revalidatePath } from "next/cache";
|
||||||
|
import { headers } from "next/headers";
|
||||||
|
|
||||||
|
import { AlbumGrantError, albumGrantService } from "@/modules/albums/grants";
|
||||||
|
import { requireAdmin } from "@/modules/auth/principal";
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// becomes a 500 with a digest the user can't read).
|
||||||
|
export type AlbumAccessActionResult = {
|
||||||
|
ok: boolean;
|
||||||
|
message: string;
|
||||||
|
grantedCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const INITIAL_RESULT: AlbumAccessActionResult = { ok: true, message: "", grantedCount: 0 };
|
||||||
|
|
||||||
|
const UUID_PATTERN =
|
||||||
|
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||||
|
|
||||||
|
export async function bulkGrantAlbumAccessAction(
|
||||||
|
_prevState: AlbumAccessActionResult,
|
||||||
|
formData: FormData,
|
||||||
|
): Promise<AlbumAccessActionResult> {
|
||||||
|
const principal = await requireAdmin(new Headers(await headers()));
|
||||||
|
const albumIds = formData.getAll("immichAlbumIds").filter(isValidUuid);
|
||||||
|
const editorialIds = formData.getAll("editorialIds").filter(isValidUuid);
|
||||||
|
|
||||||
|
if (albumIds.length === 0 || editorialIds.length === 0) {
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
message: "Bitte mindestens ein Album und eine Redaktion auswählen.",
|
||||||
|
grantedCount: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let result: Awaited<ReturnType<typeof albumGrantService.bulkGrantAlbums>>;
|
||||||
|
try {
|
||||||
|
result = await albumGrantService.bulkGrantAlbums({
|
||||||
|
albumIds,
|
||||||
|
editorialIds,
|
||||||
|
adminUserId: principal.userId,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return { ok: false, message: albumGrantErrorMessage(error), grantedCount: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
revalidatePath("/admin/alben");
|
||||||
|
for (const editorialId of editorialIds) {
|
||||||
|
revalidatePath(`/admin/redaktionen/${editorialId}/alben`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parts: string[] = [];
|
||||||
|
if (result.granted > 0) parts.push(`${result.granted} Zuweisung(en) erstellt`);
|
||||||
|
if (result.skipped > 0) parts.push(`${result.skipped} bestand(en) bereits`);
|
||||||
|
if (result.failed > 0) parts.push(`${result.failed} fehlgeschlagen`);
|
||||||
|
return {
|
||||||
|
ok: result.failed === 0,
|
||||||
|
message:
|
||||||
|
parts.length > 0
|
||||||
|
? `${parts.join(", ")}.`
|
||||||
|
: "Es gab nichts zu zuweisen — alle ausgewählten Kombinationen bestanden bereits.",
|
||||||
|
grantedCount: result.granted,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function revokeAlbumAccessAction(
|
||||||
|
_prevState: AlbumAccessActionResult,
|
||||||
|
formData: FormData,
|
||||||
|
): Promise<AlbumAccessActionResult> {
|
||||||
|
const principal = await requireAdmin(new Headers(await headers()));
|
||||||
|
const immichAlbumId = formData.get("immichAlbumId");
|
||||||
|
const editorialId = formData.get("editorialId");
|
||||||
|
if (!isValidUuid(immichAlbumId) || !isValidUuid(editorialId)) {
|
||||||
|
return { ok: false, message: "Ungültige Kennung.", grantedCount: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await albumGrantService.revokeAlbum({
|
||||||
|
editorialId,
|
||||||
|
immichAlbumId,
|
||||||
|
adminUserId: principal.userId,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return { ok: false, message: albumGrantErrorMessage(error), grantedCount: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
revalidatePath("/admin/alben");
|
||||||
|
revalidatePath(`/admin/redaktionen/${editorialId}/alben`);
|
||||||
|
return INITIAL_RESULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidUuid(value: FormDataEntryValue | null): value is string {
|
||||||
|
return typeof value === "string" && UUID_PATTERN.test(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function albumGrantErrorMessage(error: unknown): string {
|
||||||
|
if (error instanceof AlbumGrantError) {
|
||||||
|
const messages: Record<AlbumGrantError["code"], string> = {
|
||||||
|
ALBUM_NOT_ASSIGNABLE:
|
||||||
|
"Mindestens ein Album konnte nicht gefunden werden oder lässt sich nicht zuweisen.",
|
||||||
|
IMMICH_UNAVAILABLE:
|
||||||
|
"Immich ist momentan nicht erreichbar. Bitte später erneut versuchen.",
|
||||||
|
EDITORIAL_NOT_FOUND: "Redaktion nicht gefunden.",
|
||||||
|
INVALID_ALBUM_GRANT_INPUT: "Ungültige Auswahl.",
|
||||||
|
};
|
||||||
|
return messages[error.code] ?? "Die Zuweisung ist fehlgeschlagen.";
|
||||||
|
}
|
||||||
|
return "Die Zuweisung ist fehlgeschlagen.";
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
import { AlbumGrantError } from "@/modules/albums/grants";
|
||||||
|
|
||||||
|
import { loadAlbumAccess } from "./page-content";
|
||||||
|
|
||||||
|
test("only an explicit Immich-unavailable error renders the unavailable album state", async () => {
|
||||||
|
const unavailableService = {
|
||||||
|
listAlbumAccessOverview: vi.fn().mockRejectedValue(new AlbumGrantError("IMMICH_UNAVAILABLE")),
|
||||||
|
};
|
||||||
|
|
||||||
|
await expect(loadAlbumAccess(unavailableService)).resolves.toEqual({
|
||||||
|
albums: [],
|
||||||
|
unavailable: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("database and programming errors propagate instead of being displayed as Immich unavailable", async () => {
|
||||||
|
const databaseFailure = new Error("database connection lost");
|
||||||
|
const failingService = {
|
||||||
|
listAlbumAccessOverview: vi.fn().mockRejectedValue(databaseFailure),
|
||||||
|
};
|
||||||
|
|
||||||
|
await expect(loadAlbumAccess(failingService)).rejects.toBe(databaseFailure);
|
||||||
|
});
|
||||||
Loaded 100 of 326 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user