From 763098b129a3846cf60a349f0b9de450b30ebae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 20:14:31 +0200 Subject: [PATCH 01/29] chore: bootstrap portal application --- .env.example | 22 + .gitignore | 1 + .../2026-08-08-immich-redaktionsportal.md | 2 +- eslint.config.mjs | 5 + next-env.d.ts | 7 + next.config.ts | 8 + package.json | 40 + pnpm-lock.yaml | 5299 +++++++++++++++++ pnpm-workspace.yaml | 2 + postcss.config.mjs | 7 + src/app/api/health/live/route.test.ts | 9 + src/app/api/health/live/route.ts | 3 + src/app/globals.css | 140 + src/app/layout.tsx | 16 + src/app/page.tsx | 26 + src/config/env.test.ts | 10 + src/config/env.ts | 33 + src/test/server-only.ts | 1 + tsconfig.json | 41 + vitest.config.ts | 32 + 20 files changed, 5703 insertions(+), 1 deletion(-) create mode 100644 .env.example create mode 100644 eslint.config.mjs create mode 100644 next-env.d.ts create mode 100644 next.config.ts create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml create mode 100644 postcss.config.mjs create mode 100644 src/app/api/health/live/route.test.ts create mode 100644 src/app/api/health/live/route.ts create mode 100644 src/app/globals.css create mode 100644 src/app/layout.tsx create mode 100644 src/app/page.tsx create mode 100644 src/config/env.test.ts create mode 100644 src/config/env.ts create mode 100644 src/test/server-only.ts create mode 100644 tsconfig.json create mode 100644 vitest.config.ts diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..278ead3 --- /dev/null +++ b/.env.example @@ -0,0 +1,22 @@ +# Portal database (separate from Immich) +DATABASE_URL=postgres://portal:change-me@postgres:5432/portal + +# Better Auth +BETTER_AUTH_SECRET=replace-with-a-long-random-secret +BETTER_AUTH_URL=http://localhost:3000 + +# Internal Immich API access; never expose these values to browsers +IMMICH_BASE_URL=http://immich-server:2283 +IMMICH_API_KEY=replace-with-a-restricted-immich-api-key + +# SMTP +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 pages managed outside the application +LEGAL_IMPRINT_URL=https://example.com/impressum +LEGAL_PRIVACY_URL=https://example.com/datenschutz +LEGAL_TERMS_URL=https://example.com/nutzungsbedingungen diff --git a/.gitignore b/.gitignore index 8e117f4..22240e2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ node_modules/ .next/ dist/ coverage/ +*.tsbuildinfo diff --git a/docs/superpowers/plans/2026-08-08-immich-redaktionsportal.md b/docs/superpowers/plans/2026-08-08-immich-redaktionsportal.md index 628a3aa..27e1757 100644 --- a/docs/superpowers/plans/2026-08-08-immich-redaktionsportal.md +++ b/docs/superpowers/plans/2026-08-08-immich-redaktionsportal.md @@ -161,7 +161,7 @@ Create `package.json` with these scripts and engine policy; install the named de ```json { "private": true, - "packageManager": "pnpm@10", + "packageManager": "pnpm@10.34.5", "engines": { "node": ">=24 <25" }, "scripts": { "dev": "next dev", diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..8322747 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,5 @@ +import nextVitals from "eslint-config-next/core-web-vitals"; + +const eslintConfig = [...nextVitals]; + +export default eslintConfig; diff --git a/next-env.d.ts b/next-env.d.ts new file mode 100644 index 0000000..ce4e94a --- /dev/null +++ b/next-env.d.ts @@ -0,0 +1,7 @@ +/// +/// +import "./.next/types/routes.d.ts"; +import "./.next/types/root-params.d.ts"; + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/next.config.ts b/next.config.ts new file mode 100644 index 0000000..2d0e244 --- /dev/null +++ b/next.config.ts @@ -0,0 +1,8 @@ +import type { NextConfig } from "next"; + +const nextConfig: NextConfig = { + output: "standalone", + poweredByHeader: false, +}; + +export default nextConfig; diff --git a/package.json b/package.json new file mode 100644 index 0000000..964f3e1 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "private": true, + "type": "module", + "packageManager": "pnpm@10.34.5", + "engines": { + "node": ">=24 <25" + }, + "scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start", + "lint": "eslint .", + "typecheck": "tsc --noEmit", + "test": "vitest run", + "test:watch": "vitest", + "test:e2e": "playwright test" + }, + "dependencies": { + "next": "^16.3.0", + "react": "^19.2.8", + "react-dom": "^19.2.8", + "server-only": "^0.0.1", + "zod": "^4.4.3" + }, + "devDependencies": { + "@tailwindcss/postcss": "^4.3.3", + "@testing-library/jest-dom": "^7.0.0", + "@testing-library/react": "^16.3.2", + "@types/node": "^24.13.3", + "@types/react": "^19.2.18", + "@types/react-dom": "^19.2.4", + "@vitejs/plugin-react": "^6.0.5", + "eslint": "^9.39.5", + "eslint-config-next": "^16.3.0", + "jsdom": "^30.0.1", + "tailwindcss": "^4.3.3", + "typescript": "^5.9.3", + "vitest": "^4.1.10" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..02bbc47 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,5299 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + next: + specifier: ^16.3.0 + version: 16.3.0(@babel/core@7.29.7)(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8) + react: + specifier: ^19.2.8 + version: 19.2.8 + react-dom: + specifier: ^19.2.8 + version: 19.2.8(react@19.2.8) + server-only: + specifier: ^0.0.1 + version: 0.0.1 + zod: + specifier: ^4.4.3 + version: 4.4.3 + devDependencies: + '@tailwindcss/postcss': + specifier: ^4.3.3 + version: 4.3.3 + '@testing-library/jest-dom': + specifier: ^7.0.0 + version: 7.0.0(@testing-library/dom@10.4.1) + '@testing-library/react': + specifier: ^16.3.2 + version: 16.3.2(@testing-library/dom@10.4.1)(@types/react-dom@19.2.4(@types/react@19.2.18))(@types/react@19.2.18)(react-dom@19.2.8(react@19.2.8))(react@19.2.8) + '@types/node': + specifier: ^24.13.3 + version: 24.13.3 + '@types/react': + specifier: ^19.2.18 + version: 19.2.18 + '@types/react-dom': + specifier: ^19.2.4 + version: 19.2.4(@types/react@19.2.18) + '@vitejs/plugin-react': + specifier: ^6.0.5 + version: 6.0.5(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0)) + eslint: + specifier: ^9.39.5 + version: 9.39.5(jiti@2.7.0) + eslint-config-next: + specifier: ^16.3.0 + version: 16.3.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + jsdom: + specifier: ^30.0.1 + version: 30.0.1 + tailwindcss: + specifier: ^4.3.3 + version: 4.3.3 + typescript: + specifier: ^5.9.3 + version: 5.9.3 + vitest: + specifier: ^4.1.10 + version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1)(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0)) + +packages: + + '@adobe/css-tools@4.5.0': + resolution: {integrity: sha512-6OzddxPio9UiWTCemp4N8cYLV2ZN1ncRnV1cVGtve7dhPOtRkleRyx32GQCYSwDYgaHU3USMm84tNsvKzRCa1Q==} + + '@alloc/quick-lru@5.2.0': + resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==} + engines: {node: '>=10'} + + '@asamuzakjp/css-color@6.0.5': + resolution: {integrity: sha512-mbhpPMmnw/kwW19aRNmSUl1QzLbdGo1SCuE49BT98MNwqF6zaHb3o2owssFc/PEO/4t2UjqtCNwocuDtJornzA==} + engines: {node: ^22.13.0 || >=24.0.0} + + '@asamuzakjp/dom-selector@8.3.2': + resolution: {integrity: sha512-93Z1N+BQNXysodoicpOIyNh2drHfz/CTf9nnT0FEx72GJcIiwgydD7tGAr78j41LsYn3hlRn+LdGPuBLn1Bl8Q==} + engines: {node: ^22.13.0 || >=24.0.0} + + '@babel/code-frame@7.29.7': + resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==} + engines: {node: '>=6.9.0'} + + '@babel/compat-data@7.29.7': + resolution: {integrity: sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==} + engines: {node: '>=6.9.0'} + + '@babel/core@7.29.7': + resolution: {integrity: sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==} + engines: {node: '>=6.9.0'} + + '@babel/generator@7.29.8': + resolution: {integrity: sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==} + engines: {node: '>=6.9.0'} + + '@babel/helper-compilation-targets@7.29.7': + resolution: {integrity: sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==} + engines: {node: '>=6.9.0'} + + '@babel/helper-globals@7.29.7': + resolution: {integrity: sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-imports@7.29.7': + resolution: {integrity: sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-transforms@7.29.7': + resolution: {integrity: sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + + '@babel/helper-string-parser@7.29.7': + resolution: {integrity: sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-identifier@7.29.7': + resolution: {integrity: sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-option@7.29.7': + resolution: {integrity: sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==} + engines: {node: '>=6.9.0'} + + '@babel/helpers@7.29.7': + resolution: {integrity: sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==} + engines: {node: '>=6.9.0'} + + '@babel/parser@7.29.8': + resolution: {integrity: sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==} + engines: {node: '>=6.0.0'} + hasBin: true + + '@babel/runtime@7.29.7': + resolution: {integrity: sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==} + engines: {node: '>=6.9.0'} + + '@babel/template@7.29.7': + resolution: {integrity: sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==} + engines: {node: '>=6.9.0'} + + '@babel/traverse@7.29.8': + resolution: {integrity: sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==} + engines: {node: '>=6.9.0'} + + '@babel/types@7.29.8': + resolution: {integrity: sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==} + engines: {node: '>=6.9.0'} + + '@bramus/specificity@2.4.2': + resolution: {integrity: sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==} + hasBin: true + + '@csstools/color-helpers@6.1.0': + resolution: {integrity: sha512-064IFJdjTfUqnjpCVpMOdbr8FLQBhinbZj6yRv2An2E41O/pLEXqfFRWqGq/SxlE5PEUYTlvWsG2r8MswAVvkg==} + engines: {node: '>=20.19.0'} + + '@csstools/css-calc@3.3.0': + resolution: {integrity: sha512-c5ihYsPkdG6JCkU2zTMm4+k6r7RXuGxtWYhu5DHMIiF1FHzrfmHL5so11AoFpUv/tu61xfcmT4AmKoFfMPoqdQ==} + engines: {node: '>=20.19.0'} + peerDependencies: + '@csstools/css-parser-algorithms': ^4.0.0 + '@csstools/css-tokenizer': ^4.0.0 + + '@csstools/css-color-parser@4.1.10': + resolution: {integrity: sha512-UZhQLIUyJaaMepqehrCODwCg2KW25vFvLWBmqYFaPclYvvxzj/sG8LBOhBFCp11i9uE7t1EyS+RAoV9tztPFyw==} + engines: {node: '>=20.19.0'} + peerDependencies: + '@csstools/css-parser-algorithms': ^4.0.0 + '@csstools/css-tokenizer': ^4.0.0 + + '@csstools/css-parser-algorithms@4.0.0': + resolution: {integrity: sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==} + engines: {node: '>=20.19.0'} + peerDependencies: + '@csstools/css-tokenizer': ^4.0.0 + + '@csstools/css-syntax-patches-for-csstree@1.1.7': + resolution: {integrity: sha512-fQ+05118eQS1cofO3aJpB5efgpBZMvIzwr/sbC8kDLVA5XLG8q1kJV5yzrUAI1f7lvhPnm8fgIjzFB8/O/5Dig==} + peerDependencies: + css-tree: ^3.2.1 + peerDependenciesMeta: + css-tree: + optional: true + + '@csstools/css-tokenizer@4.0.0': + resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==} + engines: {node: '>=20.19.0'} + + '@emnapi/core@1.10.0': + resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==} + + '@emnapi/runtime@1.10.0': + resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==} + + '@emnapi/runtime@1.11.3': + resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==} + + '@emnapi/wasi-threads@1.2.1': + resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==} + + '@eslint-community/eslint-utils@4.10.1': + resolution: {integrity: sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + + '@eslint-community/eslint-utils@4.9.1': + resolution: {integrity: sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + + '@eslint-community/regexpp@4.12.2': + resolution: {integrity: sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + + '@eslint/config-array@0.21.2': + resolution: {integrity: sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/config-helpers@0.4.2': + resolution: {integrity: sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/core@0.17.0': + resolution: {integrity: sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/eslintrc@3.3.6': + resolution: {integrity: sha512-l2Ul9PrHsPCKcEY/ac7VgFj9D80C7S68sOKc618SyHDPK36s1XcFebXY0iTzUVn4Yq+YbwvSnDmCz9yxjX+QrA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/js@9.39.5': + resolution: {integrity: sha512-QywQuszQh77pIXCsq998c8hbhSTI/azTty1Z6N53dmAudKHhy573j3yvRLsX2BSp8YpLtoCEG8E9DJe+8zUh4A==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/object-schema@2.1.7': + resolution: {integrity: sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/plugin-kit@0.4.1': + resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@exodus/bytes@1.15.1': + resolution: {integrity: sha512-S6mL0yNB/Abt9Ei4tq8gDhcczc4S3+vQ4ra7vxnAf+YHC02srtqxKKZghx2Dq6p0e66THKwR6r8N6P95wEty7Q==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + peerDependencies: + '@noble/hashes': ^1.8.0 || ^2.0.0 + peerDependenciesMeta: + '@noble/hashes': + optional: true + + '@humanfs/core@0.19.2': + resolution: {integrity: sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==} + engines: {node: '>=18.18.0'} + + '@humanfs/node@0.16.8': + resolution: {integrity: sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==} + engines: {node: '>=18.18.0'} + + '@humanfs/types@0.15.0': + resolution: {integrity: sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==} + engines: {node: '>=18.18.0'} + + '@humanwhocodes/module-importer@1.0.1': + resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} + engines: {node: '>=12.22'} + + '@humanwhocodes/retry@0.4.3': + resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==} + engines: {node: '>=18.18'} + + '@img/colour@1.1.0': + resolution: {integrity: sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==} + engines: {node: '>=18'} + + '@img/sharp-darwin-arm64@0.35.3': + resolution: {integrity: sha512-RMnFX7YQsMoh7lWfcM4NEHHymBX/rLuKNPVM84XE9ONPcaSCDgE7CHIHpSgPcO2xcRthgBy1HfNO319mwhIAkg==} + engines: {node: '>=20.9.0'} + cpu: [arm64] + os: [darwin] + + '@img/sharp-darwin-x64@0.35.3': + resolution: {integrity: sha512-Xo+5uFBtLN0BKqieTxiFzFPQAUlBbbH5iBKyRX/z1JrbnYsHTfKJnUfL8+p2TPXr1pXqao4eeL4Rl144uDpK9w==} + engines: {node: '>=20.9.0'} + cpu: [x64] + os: [darwin] + + '@img/sharp-freebsd-wasm32@0.35.3': + resolution: {integrity: sha512-lUxcqWIj2wMQ9BrwNjngcr1gWUr5xgaGThBRqPPalIC2n67Cqj1uPh8NnA/ZhAg8hUbKl+kVHKwgUIwe6ZYPrg==} + engines: {node: '>=20.9.0'} + os: [freebsd] + + '@img/sharp-libvips-darwin-arm64@1.3.2': + resolution: {integrity: sha512-9J6ypZFpQBj4YnePGoq/S38w6nz+vqg5WZLrLGY4YuSemdMq47GMLBPO42MzwdGwpg/agZ7xzZcFHa48xlywfg==} + cpu: [arm64] + os: [darwin] + + '@img/sharp-libvips-darwin-x64@1.3.2': + resolution: {integrity: sha512-m2pW1n6cns9VaubNwsZ+c3CRYjxNQWgJ5gPlnL1nbBcpkBvFm6SCFN5o0psFHI8w9n11NKhFkeEDns98tiqbEw==} + cpu: [x64] + os: [darwin] + + '@img/sharp-libvips-linux-arm64@1.3.2': + resolution: {integrity: sha512-dqVSFynCox4C/J8kT16V7SIFAns0IjgLwkvYT7p8LQVmJ5OS5b6tI9IGflxTeuBS//zXeFIUbwt5dwxyZ17cnA==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-arm@1.3.2': + resolution: {integrity: sha512-1eMLzy92I4J6rmi4mAT8yC3HxOtniyGELlzGbNMLLeqe052ahFQ0h6LFq+lh5DsDIdYViIDst08abvSbcEdLXQ==} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-ppc64@1.3.2': + resolution: {integrity: sha512-3z0NHDxD6n5I9gc05U1eW1AyRm+Gznzq3naMrthPNqE6oYykcogW0l/jfpJdjYnuNl8R7yI9pNbE1XiUeyq0Aw==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-riscv64@1.3.2': + resolution: {integrity: sha512-bsb4rI+NldGOsXuej2r8OdSS8+zXDVaCWxyWrcv6kneTOlgAHtZABRzBBCwdsPiD90J4myNJuHpg6kA20ImW/w==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-s390x@1.3.2': + resolution: {integrity: sha512-/ABshyj8gCpyIrNXnHn4LorDJ0HHm1VhXPBlxZ8zAtfVPAaSafXPGn+sUSIRiwaSBy0mmFjSjiXI5mkcwdChKQ==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linux-x64@1.3.2': + resolution: {integrity: sha512-ITPEtgffGJ0S6G9dRyw/366tJQqFRcHWPHhC+Stpg3Z8AEMrDrTr2lhdz4f/Y/HMbRh//7Z5mBzEpVdi62Oc3w==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@img/sharp-libvips-linuxmusl-arm64@1.3.2': + resolution: {integrity: sha512-zE9EdiUzUmg5mDT5a1rk5fYJ6GWPloTwWBYDS14naqHsL+EaMpDj1AWnpLgh3u0YCORv2Tt50wrcrpYqkP97Kw==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@img/sharp-libvips-linuxmusl-x64@1.3.2': + resolution: {integrity: sha512-m0lrLiUt+lBYnCFr8qV/65yMR4E/c7/wf78I5eKTdkEakFAlZ9QlzEM3QIhhAwVeUhLAHLcCq7a7Vszq/oFNZQ==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@img/sharp-linux-arm64@0.35.3': + resolution: {integrity: sha512-QgKDspHPnrU+GQ55XPhGwyhC8acLVOOSyAvo1oVfFmrIXLkDNmGWzAfDZ4xK8oSA1qBQrALcHX0G5UZni/SuFQ==} + engines: {node: '>=20.9.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-arm@0.35.3': + resolution: {integrity: sha512-affVWCTLooy8TSxbDx2qkzuDeaWLNVBA+P//FNBirHsXpP2fuBhk5AuboYUnrDnzoXes8GFjpTx0SBFOCRg+FA==} + engines: {node: '>=20.9.0'} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-ppc64@0.35.3': + resolution: {integrity: sha512-sMd8rDxmpLOwv/7N44klFjOD5DUO7FLdjiXDI0hoxYaf7Ar262dQIEkosE98bps+5HPLtp/EvNqeqQtOycP/IA==} + engines: {node: '>=20.9.0'} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-riscv64@0.35.3': + resolution: {integrity: sha512-0Eob78yjlYPfL5vMNWAW55l3R9Y6BQS/gOfe0ZcP9mEz9ohhKSt4im1hayiknXgf8AWrFqMvJcKIdmLmEe7yeQ==} + engines: {node: '>=20.9.0'} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-s390x@0.35.3': + resolution: {integrity: sha512-KgAxQ0DxpNOq1rG2t5cgTgShJFGSuU7XO45cqC+1NVOuZnP6tlgZRuSYOfNupGkHID0o3cJOsw4DVeJpMovcGw==} + engines: {node: '>=20.9.0'} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@img/sharp-linux-x64@0.35.3': + resolution: {integrity: sha512-8pqvxubL2PGdhlPy6GLqzDYMUjyRmKAwKHYKixpdJYBUK7PJ0C029XdsnpFIdgRZG68fZiGdHVWcKPvtiPB4cA==} + engines: {node: '>=20.9.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@img/sharp-linuxmusl-arm64@0.35.3': + resolution: {integrity: sha512-Vz0iQjzzcSX3HCbfwFfCSG/9SCIqyO0mH2sXyiHaAYfBk0cRsCWXRyQYX0ovCK/PAQBbTzQ0dsPQHh5MAFL59w==} + engines: {node: '>=20.9.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@img/sharp-linuxmusl-x64@0.35.3': + resolution: {integrity: sha512-6O1NPKcDVj9QEdg7Hx549EX8U0rp6yXQERqru6yRN7fGBn32UvIRJUlWnk+8xDCiG76hXVBbX82NZ/ZKr0euIg==} + engines: {node: '>=20.9.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@img/sharp-wasm32@0.35.3': + resolution: {integrity: sha512-cZ0XkcYGpHZkqW6iCkqTcmUC0CD9DhD5d/qeZlZkfRBn6GnHniZXLUo5+9xw8Iv76YE6LQFN9YNBlKREcCG76w==} + engines: {node: '>=20.9.0'} + + '@img/sharp-webcontainers-wasm32@0.35.3': + resolution: {integrity: sha512-2rnq7bX3NzeR2T4YWgz8qiG4h3TSdMe+vN1iQXpJleSJ3SM5zQ8Fy2SyyXAWlbxpEZ2Y+Z4u1BePgJEYbSy80Q==} + engines: {node: '>=20.9.0'} + cpu: [wasm32] + + '@img/sharp-win32-arm64@0.35.3': + resolution: {integrity: sha512-4bPwFdMbeC4JQ8L8LOyWp6nsHcboP5fxkp6iPOXz2Vg49R42TuMs2whkJ5OAP4/Ul035qOzy0AecOF9VOscn4w==} + engines: {node: '>=20.9.0'} + cpu: [arm64] + os: [win32] + + '@img/sharp-win32-ia32@0.35.3': + resolution: {integrity: sha512-r53mXsBN6lFUDiST764SvgwUdHAqM4rPAiDzAmf4fLoB6X/rkfyTrLCg6+g17wJJiCmB3JYgHuUldCWUIRFSXw==} + engines: {node: ^20.9.0} + cpu: [ia32] + os: [win32] + + '@img/sharp-win32-x64@0.35.3': + resolution: {integrity: sha512-D4y1vNeZrIIJCN+uHaWVtH86B+aCrdMYYjicy9pXHvbGZeGYLLSd3wdVuC37FxVXlU1ARsk84eKWfWMXGYEqvA==} + engines: {node: '>=20.9.0'} + cpu: [x64] + os: [win32] + + '@jridgewell/gen-mapping@0.3.13': + resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + + '@jridgewell/remapping@2.3.5': + resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.5.5': + resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} + + '@jridgewell/trace-mapping@0.3.31': + resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + + '@napi-rs/wasm-runtime@1.2.2': + resolution: {integrity: sha512-JfB4kuJQjaoHuCTseIINHtHWeJnvgEcxjwA5t/Y00ZgaOO1Crz3fjT/p8kT28zA/Caz7oiUMn3d6H2yOVCVwuw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || ^2.0.0-alpha.3 + '@emnapi/runtime': ^1.7.1 || ^2.0.0-alpha.3 + + '@next/env@16.3.0': + resolution: {integrity: sha512-o9r1S0BNiNreHP9Vs+Qnqd9kviDkJh8xIACY7UFZSmiGbbQRzPBBosvHzAU4TULHOIuOj/18RSsyz2qrREmIFw==} + + '@next/eslint-plugin-next@16.3.0': + resolution: {integrity: sha512-OqgJ8PN0d04KcPhDX/PTY5tJUJZxlbrt7O7FBsm4XE0XW2JDrKnDXsc9uo9WUimJGPoo2j+JRGhyXApC//mvbw==} + + '@next/swc-darwin-arm64@16.3.0': + resolution: {integrity: sha512-55hpqq18bEVAlxedlTt3tFqZmKg2nUXT1kn1G/BGEy0R13h3LwtwHPVzzjG6P4LLeOHE32PFDQUVaJEWvBEZBw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + + '@next/swc-darwin-x64@16.3.0': + resolution: {integrity: sha512-SOi96kSaF5T+0wW4koiM1bWzSPwjzTesC1p3df+FjdOi5LIQkBK/blxh7HdoKnNuI4PURF1OO7TZqtfnbWDSgw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + + '@next/swc-linux-arm64-gnu@16.3.0': + resolution: {integrity: sha512-P0gZAoPMF4dyTRzhmkV4PrqVzSOB6t4mC1oI3c4dqijJ+OVEVx5clIXAKR4/uQpsqw2KKM/0D5tVumcR2r5blg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@next/swc-linux-arm64-musl@16.3.0': + resolution: {integrity: sha512-tXXGKJw0m37O0eKJARVTX/TheKPhz0QFVtVVZXmOig+9YKLQOSP6hvf2pxv5DO7CLEJyTHx3Pg043CDQkv1G4Q==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@next/swc-linux-x64-gnu@16.3.0': + resolution: {integrity: sha512-pjGxK5EY7yWml78ALejFkWmgHsU7wbFQrISiugpH6FbUJhgEvw3xFZ/EBAtLl7QtL0WdQKiG9eWJ3mOKGTukHw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@next/swc-linux-x64-musl@16.3.0': + resolution: {integrity: sha512-sjo++Xx+lomlPs3HRsHWhVDyGG6ms1kGW5EtHLERdII8AyG1i+f6aq68xHREO6AEMlhjTNEWBSmfJfqm9orf7g==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@next/swc-win32-arm64-msvc@16.3.0': + resolution: {integrity: sha512-C5JSgiO54wURdaxdEUIXqkz04uMqC9UmPX1gtDrV/5Tf1UowdWYI8uA5hfFbPolTlp0q4KZ60xlHePNibf0VIw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + + '@next/swc-win32-x64-msvc@16.3.0': + resolution: {integrity: sha512-fDOggsweNb5SSw0ZKVk6U+gxSyGFFlIBY/LBc1r8GUj4u/6t6oArL+Pmkg0MBnsgR+KkdsURilVH4F3GXUGepA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + + '@nodelib/fs.scandir@2.1.5': + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + + '@nodelib/fs.stat@2.0.5': + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + + '@nodelib/fs.walk@1.2.8': + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + + '@nolyfill/is-core-module@1.0.39': + resolution: {integrity: sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==} + engines: {node: '>=12.4.0'} + + '@oxc-project/types@0.143.0': + resolution: {integrity: sha512-u6JZdLBTLotrNC9Vd6vPssINdzcCzleKAH6EJKImQb7GtYvX5keN2dxkoK44stCc4tffE6QQRtZTXVSzsLUlWA==} + + '@rolldown/binding-android-arm64@1.2.3': + resolution: {integrity: sha512-zrJtHDcaZJ1Fp7xf4hNl+7seH9Cn/N5TwLYkhgXREtBwAd/jaqW3uqeHxpDugJLVICWg4eW44kOQEGJ1r6jCGw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.2.3': + resolution: {integrity: sha512-ieIiibVCp0tX7TLu2cafoNPv8wJyYi01ekXpbf8q2j7F4rGAhhXb/eQh7ge9DRBY78GwmRQtvjZDux7EDbA8kA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.2.3': + resolution: {integrity: sha512-Zh9tCon19eDXJoihx0rqKhMUlMYqzwj3aPsSuHmI4RWZh62dWUL+DJN4C5YQya5TcQBJU/Fe8+rY0jhXTQITqA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.2.3': + resolution: {integrity: sha512-nGbJWewA1wrXXZiQhjAT5rhibGfns5ZNkDVqxsO6zJ3f3YvpoDNNmGMSbbhLuXKjNScaBJVOAboztAWVespQMg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.2.3': + resolution: {integrity: sha512-QNniJr5Kml0kDEB98jiDOJjXNroxIIi0IXIbdYzY26Xt1pVbeP62+KnoIZLwirOymX/0jDk/2gI/bNUv7A7OIw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.2.3': + resolution: {integrity: sha512-TkqEAcmmvH3I/q4114NB4RVt6241Dao48pF45uLcFGrwAaIn0iITgTAKP/dLjbN0R4buJjGb91+UHSoFmpgIWw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.2.3': + resolution: {integrity: sha512-NHqjnxpsndf4MPymxteFAWHHfkTL8HjWh1KB7z23ofZ6QO2euONuxDXjat69dKZRALnGypg8k8SsK8vZJoXv1Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.2.3': + resolution: {integrity: sha512-6tbrbwfz5GB9DQ4Jwo6hy9v+vR31xZlvzZ6n5Xut6Hhx5PvrA9q/HsK8KMaYQp063iqZGXwNvZtYNLD7EM/x0w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.2.3': + resolution: {integrity: sha512-oyuXxXmoZHjXC917IAPFAAv4wWAa0cM9afk8nx1+9/jNNOX1uPf8yDA6p7G0RypOfw/X0PQt5IfoquY1um+zSg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.2.3': + resolution: {integrity: sha512-TytMwF2KVGqP2tgd0I1OY0PAv78dZRAYcF5ssDzjM34SUXCED3uXvSd5+lHoC0bTD6eEdFz7LdQNCO1y0oVk9w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.2.3': + resolution: {integrity: sha512-/E9m3qstrJFVPoULV25mVQblSNExY2+kBsYe4sy0Tn0yOOgJ8wZbZt3KnRbF/XeU2Gl1STKUQnDNTqhIE5MD4A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.2.3': + resolution: {integrity: sha512-Kr0OcsoQI816i6HOl3vFHpd1K0eZyh76zgfj4c1nTyaTsd5r2Mj1lwM4R90y/qaCfmTn9eHy0SKwi98eitRxug==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-win32-arm64-msvc@1.2.3': + resolution: {integrity: sha512-hOtMwTqnME+/gJcH/PCZ0wn0zPUjiWOgkHpxbSJpfGKMezHltx1S7/k1SitzVa7Ww2cqrDDaFbZEhcJZO8o+Jw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.2.3': + resolution: {integrity: sha512-ekcqMMkI2PlhYnfzQnB/cEdYUVVJViWvoUyLrbzgDoi3Snfc1mVBwdnc306ufA5ejy8JSPjT2RlW1nQSjW7efg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.0.1': + resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==} + + '@rtsao/scc@1.1.0': + resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==} + + '@standard-schema/spec@1.1.0': + resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} + + '@swc/helpers@0.5.15': + resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==} + + '@tailwindcss/node@4.3.3': + resolution: {integrity: sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg==} + + '@tailwindcss/oxide-android-arm64@4.3.3': + resolution: {integrity: sha512-Y85A2gmPSkl5Ve5qR86GL4HT509cFqQh1aes9p3sSkyTPwt0Pppf3GkwGe4JPACcRYjgJIEhQgM6dBClnr0NYw==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [android] + + '@tailwindcss/oxide-darwin-arm64@4.3.3': + resolution: {integrity: sha512-BiaWatpBcERQFDlOjRDpIVXuFK5PJez5SA4JMg6VYZdBYU+qKfV/vqjcIs+IYmtitf1xYQZTwXvU/8y4lfZUGw==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [darwin] + + '@tailwindcss/oxide-darwin-x64@4.3.3': + resolution: {integrity: sha512-fAeUqfV5ndhxRwai8cXGzdLvul9utWOmeTkv69unv4ZXixjn61Z+p9lCWdwOwA3TYboG3BwdVuN/RDjhBRl0mw==} + engines: {node: '>= 20'} + cpu: [x64] + os: [darwin] + + '@tailwindcss/oxide-freebsd-x64@4.3.3': + resolution: {integrity: sha512-iyf5bV6+wnAlflVeEy7R25dupxTNECZN5QMI0qNT6eT+EgaGdZcKhGkr5SdoaWiLJ3spLqIY9VCeSGrwmtg4kw==} + engines: {node: '>= 20'} + cpu: [x64] + os: [freebsd] + + '@tailwindcss/oxide-linux-arm-gnueabihf@4.3.3': + resolution: {integrity: sha512-aAYUprJAJQWWbRrPvtjdroZ56Md+JM8pMiopS6xGEwDfLhqj+2ver2p4nU4Mb3CRqcMmNBjo8KkUgcxhkzVQGQ==} + engines: {node: '>= 20'} + cpu: [arm] + os: [linux] + + '@tailwindcss/oxide-linux-arm64-gnu@4.3.3': + resolution: {integrity: sha512-nDxldcEENOxZRzC2uu9jrutZdAAQtb+8WWDCSnWL1zvBk1+FN+x6MtDViPB5AJMfttVCUhehGWus3XBPgatM/w==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@tailwindcss/oxide-linux-arm64-musl@4.3.3': + resolution: {integrity: sha512-Md44bD6veX/PC5iyF8cDVnw4HBIANZepRZZ7a8DQOvkfo5WUBwcp6iAuCUz23u+4SUkhJlD3eL7hNdW8ezd/kA==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@tailwindcss/oxide-linux-x64-gnu@4.3.3': + resolution: {integrity: sha512-tx7us1muwOKAKWao2v/GaafFeQboE6aj88vC6ziN2NCGcRm8gWUhwjzg+YdVB1e4boAtdtma4L43onunI6NS4w==} + engines: {node: '>= 20'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@tailwindcss/oxide-linux-x64-musl@4.3.3': + resolution: {integrity: sha512-SJxX60smvHgasZoBy11dX6YRjXJFovwWBoedhbQPOBzgFWBHGB+TVPWB9BxzR7TTxU8FQZAI2AyiNCMzFm8Img==} + engines: {node: '>= 20'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@tailwindcss/oxide-wasm32-wasi@4.3.3': + resolution: {integrity: sha512-jx1+rPhY/5Ympkktd656HBWEBLxP7dH06losBLjjf5vgCODXvi9KhtftWcMIwTFIDqBr7cRnQkdLnAG+IOlGvQ==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + bundledDependencies: + - '@napi-rs/wasm-runtime' + - '@emnapi/core' + - '@emnapi/runtime' + - '@tybys/wasm-util' + - '@emnapi/wasi-threads' + - tslib + + '@tailwindcss/oxide-win32-arm64-msvc@4.3.3': + resolution: {integrity: sha512-3rc292Ca2ceK6Ulcc/bAVnTs/3nDtoPhyEKlgPv+yQJQi/JS/AMJlqzxvlDacL1nekbrcf6bTqp/jV4qgnPxNQ==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [win32] + + '@tailwindcss/oxide-win32-x64-msvc@4.3.3': + resolution: {integrity: sha512-yJ0pwIVc/nYeGoV02WtsN8KYyLQv7kyI2wDnkezyJlGGjkd4QLwDGAwl47YpPJeuI0M0ObaXGSPjvWDPeTPggw==} + engines: {node: '>= 20'} + cpu: [x64] + os: [win32] + + '@tailwindcss/oxide@4.3.3': + resolution: {integrity: sha512-krXjAikiaFSPaK/FkAQT5UTx3VormQaiZ5hBFlJZ9UFQGB/rwg1MZIhHAG9smMQRTdyJxP6Qt5MwMtdyU5FWrA==} + engines: {node: '>= 20'} + + '@tailwindcss/postcss@4.3.3': + resolution: {integrity: sha512-JTSZZGQi1AyKirbLN3azmjVzef92tcX7h+iSqPdaeStyFpGpDlKvvpxeOE8njhbUanbRwr3z8DyzhICWnMtQeg==} + + '@testing-library/dom@10.4.1': + resolution: {integrity: sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==} + engines: {node: '>=18'} + + '@testing-library/jest-dom@7.0.0': + resolution: {integrity: sha512-HKAH9C6mBo5yBG6yRO5i43L2iisencAo5z+o5P/saHUoY+miC5ivXRxHBJcFyB5ypPNxHJdK3BoF/3O4DIptMg==} + engines: {node: '>=22', npm: '>=6', yarn: '>=1'} + peerDependencies: + '@testing-library/dom': '>=10 <11' + + '@testing-library/react@16.3.2': + resolution: {integrity: sha512-XU5/SytQM+ykqMnAnvB2umaJNIOsLF3PVv//1Ew4CTcpz0/BRyy/af40qqrt7SjKpDdT1saBMc42CUok5gaw+g==} + engines: {node: '>=18'} + peerDependencies: + '@testing-library/dom': ^10.0.0 + '@types/react': ^18.0.0 || ^19.0.0 + '@types/react-dom': ^18.0.0 || ^19.0.0 + react: ^18.0.0 || ^19.0.0 + react-dom: ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + + '@tybys/wasm-util@0.10.3': + resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==} + + '@types/aria-query@5.0.4': + resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==} + + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + + '@types/estree@1.0.9': + resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} + + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + + '@types/json5@0.0.29': + resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} + + '@types/node@24.13.3': + resolution: {integrity: sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==} + + '@types/react-dom@19.2.4': + resolution: {integrity: sha512-Bsc+QHgp+P/F02XDzNCY9jnZNCUuLki36KT7VKrTXXLdHf+vHMNZnW1rVu5DNW/rCK+fya3DATySbLM4yhtKUw==} + peerDependencies: + '@types/react': ^19.2.0 + + '@types/react@19.2.18': + resolution: {integrity: sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==} + + '@typescript-eslint/eslint-plugin@8.66.0': + resolution: {integrity: sha512-p088eaGrzYz1s+7cov0aMOCkNGTJlVxF4jgubf28c8L0Cv9Rloj8YBHnv4hXLq6IIEE1AsjNWavO+k+8kP2Y0A==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + '@typescript-eslint/parser': ^8.66.0 + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/parser@8.66.0': + resolution: {integrity: sha512-X6ypGChaWYk6PBtUg2BwuTZEFFcHJAtGTVJ9/lCTOufhZ4i9fNolQNnktq+kkMCwMj7V8Svsq7+TxSDslmhE0g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/project-service@8.66.0': + resolution: {integrity: sha512-7MthGPTt4BP69lSryqpqq8HQqxuzynssckL/jyDyk3+TNMQ3y2jFWkptCrktWvBrP+EH787Nl5N5Qpw7WZg+5g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/scope-manager@8.66.0': + resolution: {integrity: sha512-8TGcH25j9zqJ/IULB/ppyhRvxA8QYfFEZ7nfbg6/BN9spDgb8fPWQXlE5l8TWBL50EtUx007uZ1o9VOwrq2/9g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/tsconfig-utils@8.66.0': + resolution: {integrity: sha512-9D5gLYZG4rOjcoag8MQ/fWI8WqA9wcPDyOGyWtWFhvM1lHRbliqUSPIY5J3zqCU1tvSwzXxnnjhQhz5Ne7mJ4g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/type-utils@8.66.0': + resolution: {integrity: sha512-LG2dWfjZQQp0ADtAu/EWJVayefGL2UEZ3CDeI44D9v3rXB/WYUqE/jpO28KrEKul5AySrmI+Zh1v6v+xW2U9+g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/types@8.66.0': + resolution: {integrity: sha512-H6gcYaSDOyvL3AD/jHUtUFo2jqGgn/F6nuyuZSu0QTesxL+cP4dQoIMrODRofuJC09g64+WgZ6tE19Y1N2YIFQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/typescript-estree@8.66.0': + resolution: {integrity: sha512-8/x4INiiQb10jGgXYD7116/zQ+OL84ZIFn0za68wwFHCanT/VLbBEroWht8RV8fn0/ZCAoazHLQgwUC0UQcDfg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/utils@8.66.0': + resolution: {integrity: sha512-jasearZPolBw5NJNYGMwxzHMF83niVWmMU1VdHzG1CyfI2VS7f7nZltnKtHcg20hW+7Uo5GfK4MeDPoU3qI8EA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/visitor-keys@8.66.0': + resolution: {integrity: sha512-dkKR8q+lKciskj1Y3vthHktl+3cMLWGyVUP23bRiPZ5O9BRT++4EqDDV+TVeIKBL1VXVEqrJlz8MYbcnvJcAlg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@unrs/resolver-binding-android-arm-eabi@1.12.2': + resolution: {integrity: sha512-g5T90pqg1bo/7mytQx6F4iBNC0Wsh9cu+z9veDbFjc7HjpesJFWD7QMS0NGStXM075+7dJPPVvBbpZlnrdpi/w==} + cpu: [arm] + os: [android] + + '@unrs/resolver-binding-android-arm64@1.12.2': + resolution: {integrity: sha512-YGCRZv/9GLhwmz6mYDeTsm/92BAyR28l6c2ReweVW5pWgfsitWLY8upvfRlGdoyD8HjeTHSYJWyZGD4KJA/nFQ==} + cpu: [arm64] + os: [android] + + '@unrs/resolver-binding-darwin-arm64@1.12.2': + resolution: {integrity: sha512-u9DiNT1auQMO20A9SyTuG3wUgQWB9Z7KjAg0uFuCDR1FsAY8A0CG2S6JpHS1xwm/w1G08bjXZDcyOCjv1WAm2w==} + cpu: [arm64] + os: [darwin] + + '@unrs/resolver-binding-darwin-x64@1.12.2': + resolution: {integrity: sha512-f7rPLi/T1HVKZu/u6t87lroib16n8vrSzcyxI7lg4BGO9UF26KhQL44sd9eOUgrTYhvRXtWOIZT5PejdPyJfUA==} + cpu: [x64] + os: [darwin] + + '@unrs/resolver-binding-freebsd-x64@1.12.2': + resolution: {integrity: sha512-BpcOjWCJub6nRZUS2zA20pmLvjtqAtGejETaIyRLiZiQf++cbrjltLA5NN/xaXfqeOBOSlMFbemIl5/S5tljmg==} + cpu: [x64] + os: [freebsd] + + '@unrs/resolver-binding-linux-arm-gnueabihf@1.12.2': + resolution: {integrity: sha512-vZTDvdSISZjJx66OzJqtsOhzifbqRjbmI1Mnu49fQDwog5GtDI4QidRiEAYbZCRj9C8YZEW+3ZjqsyS9GR4k2A==} + cpu: [arm] + os: [linux] + + '@unrs/resolver-binding-linux-arm-musleabihf@1.12.2': + resolution: {integrity: sha512-BiPI+IrIlwcW4nLLMM21+B1dFPzd55yAVgVGrdgDjNef+ch03GdxrcyaIz8X9SsQirh/kCQ7mviyWlMxdh2D7g==} + cpu: [arm] + os: [linux] + + '@unrs/resolver-binding-linux-arm64-gnu@1.12.2': + resolution: {integrity: sha512-zJc0H99FEPoFfSrNpa91HYfxzfAJCr502oxNK1cfdC9hlaFI43RT+JFCann9JUgZmLzzntChHyn13Sgn9ljHNg==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-arm64-musl@1.12.2': + resolution: {integrity: sha512-KQ3Lki6l+Pz1k/eBipN41ES+YUK30beLGb9YqcB1O542cyLCNE6GaxrfcY3T6EezmGGk84wb5XyO9loTM9tkcA==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@unrs/resolver-binding-linux-loong64-gnu@1.12.2': + resolution: {integrity: sha512-3SJGEh1DborhG6pyxvhPzCT4bbSIVihsvgJc13P1bHG7KLdNDaF9T3gsTwFc7Jw/5Y5/iWOjkEx7Zy0NvCGX3Q==} + cpu: [loong64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-loong64-musl@1.12.2': + resolution: {integrity: sha512-jiuG/Obbel7uw1PwHNFfrkiKhLAF6mnyZ6aWlOAVN9WqKm8v0OFGnciJIHu8+CMvXLQ8AD51LPzAoUfT21D5Ew==} + cpu: [loong64] + os: [linux] + libc: [musl] + + '@unrs/resolver-binding-linux-ppc64-gnu@1.12.2': + resolution: {integrity: sha512-q7xRvVpmcfeL+LlZg8Pbbo6QaTZwDU5BaGZbwfhkEsXJn3Was8xYfE0RBH266xZt0rM6B7i8xAYIvjthuUIWHg==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-riscv64-gnu@1.12.2': + resolution: {integrity: sha512-0CVdx6lcnT3Q9inOH8tsMIOJ6ImndllMjqJHg8RLVdB7Vq4SfkEXl9mCSsVNuNA4MCYycRicCUxPCabVHJRr6A==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-riscv64-musl@1.12.2': + resolution: {integrity: sha512-iOwlRo9vnp6R6ohHQS11n0NnfdXx/omhkocmIfaPRpQhKZ+3BDMkkdRVh53qjkFkpPddf+FETA28NwGN7l5l+w==} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@unrs/resolver-binding-linux-s390x-gnu@1.12.2': + resolution: {integrity: sha512-HYJtLfXq94q8iZNFT1lknx258wlkkWhZeUXJRqzKBBUJ00CvZ+N33zgbCqimLjsyw5Va6uUxhVa12mI+kaveEw==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-x64-gnu@1.12.2': + resolution: {integrity: sha512-mPsUhunKKDih5O96Y6enDQyHc1SqBPlY1E/SfMWDM3EdJ95Z9CArPeCVwCCqbP45ljvivdEk8Fxn+SIb1rDAJQ==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-x64-musl@1.12.2': + resolution: {integrity: sha512-azrt6+5ydLd8Vt210AAFis/lZevSfPw93EJRIJG+xPu4WCJ8K0kppCTpMyLPcKT7H15M4Jnt2tMp5bOvCkRC6A==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@unrs/resolver-binding-openharmony-arm64@1.12.2': + resolution: {integrity: sha512-YZ9hP4O0X9PQb8eO980qmLNGH4zT3I9+SZTdt0Pr0YyuGQhYKoOZkV02VzrzyOZJ5xIJ3UFIenKkUkGg8GjgWQ==} + cpu: [arm64] + os: [openharmony] + + '@unrs/resolver-binding-wasm32-wasi@1.12.2': + resolution: {integrity: sha512-tYFDIkMxSflfEc/h92ZWNsZlHSwgimbNHSO3PL2JWQHfCuC2q316jMyYU9TIWZsFK2bQwyK5VAdYgn8ygPj69A==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + + '@unrs/resolver-binding-win32-arm64-msvc@1.12.2': + resolution: {integrity: sha512-qzNyg3xL0VPQmCaUh+N5jSitce6k+uCBfMDesWRnlULOZaqUkaJ0ybdT+UqlAWJoQjuqfIU/0Ptx9bteN4D82g==} + cpu: [arm64] + os: [win32] + + '@unrs/resolver-binding-win32-ia32-msvc@1.12.2': + resolution: {integrity: sha512-WD9sY00OfpHVGfsnHZoA8jVT+esS/Bg8z8jzxp5BnDCjjwsuKsPQrzswwpFy4J1AUJbXPRfkpcX0mXrzeXW79g==} + cpu: [ia32] + os: [win32] + + '@unrs/resolver-binding-win32-x64-msvc@1.12.2': + resolution: {integrity: sha512-nAB74NfSNKknqQ1RrYj6uz8FcXEomu/MATJZxh/x+BArzN2U3JbOYC0APYzUIGhVY3m5hRxA8VPNdPBoG8txlA==} + cpu: [x64] + os: [win32] + + '@vitejs/plugin-react@6.0.5': + resolution: {integrity: sha512-BOVzne/NL162sMdResB25mUv+vWMF5NoAjNf09TeGlE7ZpszZWSD3winycicLJw72yeVsoCn/2kOhEuCvEShMA==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + '@rolldown/plugin-babel': ^0.1.7 || ^0.2.0 + babel-plugin-react-compiler: ^1.0.0 + vite: ^8.0.0 + peerDependenciesMeta: + '@rolldown/plugin-babel': + optional: true + babel-plugin-react-compiler: + optional: true + + '@vitest/expect@4.1.10': + resolution: {integrity: sha512-YsCn+qAk1GWjQOWFEsEcL2gNQ0zmVmQu3T03qP6UyjhtmdtwtbuI+DASn/7iQB3HGTXkdBwGddzxPlmiql5vlA==} + + '@vitest/mocker@4.1.10': + resolution: {integrity: sha512-v0xaezt+DKEmKfaxg133ldzADrwLGd7Ze1MfQQTYfvs8OqZIwbxyxaYURivwV7sWy5fqn3rH5uOrSp07bp44Ow==} + peerDependencies: + msw: ^2.4.9 + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + + '@vitest/pretty-format@4.1.10': + resolution: {integrity: sha512-W1HsjSH4MXQ9YfmmhLAoIYf1HRfekQCGngeIgcei6MP5QQGWUe0gkopdZQaVCFO+JDJMrAJGwa5pRpNpvy4P8Q==} + + '@vitest/runner@4.1.10': + resolution: {integrity: sha512-IKI6kpIH+LmpROplyLwBBaCfMgOZOMsygVa6BARD6ahA04VRuJSa6OaVG7kRvSEMD870Vd91rSSw0eegtWyLGg==} + + '@vitest/snapshot@4.1.10': + resolution: {integrity: sha512-xRkfOT1qpTAi/Ti4Y1LtfRc3kEuqxGw59eN2jN9pRWMtS/XDevekhcFSqvQqjUNGksfjMJu3Y+oJ+4Ypn2OaJw==} + + '@vitest/spy@4.1.10': + resolution: {integrity: sha512-PLf/Ugvoq5wO/b4rwYCR1h2PSIdXz7wnkQFMiUpLdtM7l6pqVFcQIBEHyT1+l+cj7mNwAfZHzqXqDyjvOuwbDw==} + + '@vitest/utils@4.1.10': + resolution: {integrity: sha512-fy9am/HWxbaGt/Sawrp90vt6Y6jQwf1RX77cz3uwoJwJVMli/e1IEwRPnMNJ7vKfPTwo0diXifkpPvwH9v7nGA==} + + acorn-jsx@5.3.2: + resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + + acorn@8.18.0: + resolution: {integrity: sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==} + engines: {node: '>=0.4.0'} + hasBin: true + + ajv@6.15.0: + resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==} + + ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} + engines: {node: '>=8'} + + ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + + ansi-styles@5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + + argparse@2.0.1: + resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} + + aria-query@5.3.0: + resolution: {integrity: sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==} + + aria-query@5.3.2: + resolution: {integrity: sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==} + engines: {node: '>= 0.4'} + + array-buffer-byte-length@1.0.2: + resolution: {integrity: sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==} + engines: {node: '>= 0.4'} + + array-includes@3.1.9: + resolution: {integrity: sha512-FmeCCAenzH0KH381SPT5FZmiA/TmpndpcaShhfgEN9eCVjnFBqq3l1xrI42y8+PPLI6hypzou4GXw00WHmPBLQ==} + engines: {node: '>= 0.4'} + + array.prototype.findlast@1.2.5: + resolution: {integrity: sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==} + engines: {node: '>= 0.4'} + + array.prototype.findlastindex@1.2.6: + resolution: {integrity: sha512-F/TKATkzseUExPlfvmwQKGITM3DGTK+vkAsCZoDc5daVygbJBnjEUCbgkAvVFsgfXfX4YIqZ/27G3k3tdXrTxQ==} + engines: {node: '>= 0.4'} + + array.prototype.flat@1.3.3: + resolution: {integrity: sha512-rwG/ja1neyLqCuGZ5YYrznA62D4mZXg0i1cIskIUKSiqF3Cje9/wXAls9B9s1Wa2fomMsIv8czB8jZcPmxCXFg==} + engines: {node: '>= 0.4'} + + array.prototype.flatmap@1.3.3: + resolution: {integrity: sha512-Y7Wt51eKJSyi80hFrJCePGGNo5ktJCslFuboqJsbf57CCPcm5zztluPlc4/aD8sWsKvlwatezpV4U1efk8kpjg==} + engines: {node: '>= 0.4'} + + array.prototype.tosorted@1.1.4: + resolution: {integrity: sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==} + engines: {node: '>= 0.4'} + + arraybuffer.prototype.slice@1.0.4: + resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==} + engines: {node: '>= 0.4'} + + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + + ast-types-flow@0.0.8: + resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==} + + async-function@1.0.0: + resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==} + engines: {node: '>= 0.4'} + + available-typed-arrays@1.0.7: + resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} + engines: {node: '>= 0.4'} + + axe-core@4.13.0: + resolution: {integrity: sha512-UzGt8zg7Ny8djbYMhxl2zuEevVa7r2gJjYY5Lwr1xM7+XU2nd6CkIWFTVcCIbAP63vSz71NaVyyuSk9lHKcy0A==} + engines: {node: '>=4'} + + axobject-query@4.1.0: + resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==} + engines: {node: '>= 0.4'} + + balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + + balanced-match@4.0.4: + resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} + engines: {node: 18 || 20 || >=22} + + baseline-browser-mapping@2.11.12: + resolution: {integrity: sha512-r7WnVImvVCeFpf2DOXfy41aPWzeNg3H/A2X4dKmy1QL0MSyyk/e7z8ihJ3N6Nn2PsdhkVlqnEfnUE4a05P2aTA==} + engines: {node: '>=6.0.0'} + hasBin: true + + bidi-js@1.0.3: + resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==} + + brace-expansion@1.1.18: + resolution: {integrity: sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==} + + brace-expansion@5.0.9: + resolution: {integrity: sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==} + engines: {node: 20 || >=22} + + braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} + engines: {node: '>=8'} + + browserslist@4.28.7: + resolution: {integrity: sha512-JxV13hNrFxqjOc8alRbq9dK1MM79NEXYpma2B2J4wAtpWS5zIEIKqWPGCl7N4o7Uc7B7itylh7SuDujATRyyTw==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + + call-bind-apply-helpers@1.0.2: + resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} + engines: {node: '>= 0.4'} + + call-bind@1.0.9: + resolution: {integrity: sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==} + engines: {node: '>= 0.4'} + + call-bound@1.0.4: + resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} + engines: {node: '>= 0.4'} + + callsites@3.1.0: + resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} + engines: {node: '>=6'} + + caniuse-lite@1.0.30001809: + resolution: {integrity: sha512-xxWVywk6a6Arlk+hymeycyn/VgqEfLDxupvhH/xiY5SJ/18kmi9o6MiO320DCUzypORHLtvh0I4i04tUhCNHNQ==} + + chai@6.2.2: + resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==} + engines: {node: '>=18'} + + chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + + client-only@0.0.1: + resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} + + color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + + color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + + concat-map@0.0.1: + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + + convert-source-map@2.0.0: + resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} + engines: {node: '>= 8'} + + css-tree@3.2.1: + resolution: {integrity: sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==} + engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0} + + css.escape@1.5.1: + resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==} + + csstype@3.2.3: + resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} + + damerau-levenshtein@1.0.8: + resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} + + data-urls@7.0.0: + resolution: {integrity: sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + + data-view-buffer@1.0.2: + resolution: {integrity: sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==} + engines: {node: '>= 0.4'} + + data-view-byte-length@1.0.2: + resolution: {integrity: sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==} + engines: {node: '>= 0.4'} + + data-view-byte-offset@1.0.1: + resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==} + engines: {node: '>= 0.4'} + + debug@3.2.7: + resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + debug@4.4.3: + resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + decimal.js@10.6.0: + resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==} + + deep-is@0.1.4: + resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + + define-data-property@1.1.4: + resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} + engines: {node: '>= 0.4'} + + define-properties@1.2.1: + resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} + engines: {node: '>= 0.4'} + + dequal@2.0.3: + resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} + engines: {node: '>=6'} + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + doctrine@2.1.0: + resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} + engines: {node: '>=0.10.0'} + + dom-accessibility-api@0.5.16: + resolution: {integrity: sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==} + + dom-accessibility-api@0.6.3: + resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==} + + dunder-proto@1.0.1: + resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} + engines: {node: '>= 0.4'} + + electron-to-chromium@1.5.402: + resolution: {integrity: sha512-/oOpMaPT6Yg+6/1XQhyIPlzgj7Ye9zf+nNM2Uh6OcE2G2oNptWazFa+qB2Pdqqbsc9KnIDzgAntoYN0dbwOXwA==} + + emoji-regex@9.2.2: + resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + + enhanced-resolve@5.24.5: + resolution: {integrity: sha512-L1l8TNvomm6UVW5B253AGxQagSQr+vGwhMlrrfRS2qmhx46AMpMVJKQYLvWYbysTMY8VoicOvzHzoHMbyzB+4A==} + engines: {node: '>=10.13.0'} + + entities@8.0.0: + resolution: {integrity: sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==} + engines: {node: '>=20.19.0'} + + es-abstract-get@1.0.0: + resolution: {integrity: sha512-6PMWXpdhshVvFp+FoWYs1EvG1Nj0tvk0dZM+XcK0xMEM1czRVcP6ohqPWHy6qPagSpC8j4+p89WXlT+xXJs/fg==} + engines: {node: '>= 0.4'} + + es-abstract@1.24.2: + resolution: {integrity: sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==} + engines: {node: '>= 0.4'} + + es-define-property@1.0.1: + resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} + engines: {node: '>= 0.4'} + + es-errors@1.3.0: + resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} + engines: {node: '>= 0.4'} + + es-iterator-helpers@1.4.0: + resolution: {integrity: sha512-c/A0P0oxkACDc+cKWw8evLXK83oBKgn0qPOqCYT4x9uolpCIJAcYvJC9QYKNDRPsTeGyCrQ326jrvgZWdCdK5Q==} + engines: {node: '>= 0.4'} + + es-module-lexer@2.3.1: + resolution: {integrity: sha512-shc1dbU90Yl/xq1QrC7QRtfcwURZuVRfPhZbDoldJ1cn1gzDvBaBWlv0eFolj5+0znnPJz5TXLxsN77X/12KTA==} + + es-object-atoms@1.1.2: + resolution: {integrity: sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==} + engines: {node: '>= 0.4'} + + es-set-tostringtag@2.1.0: + resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==} + engines: {node: '>= 0.4'} + + es-shim-unscopables@1.1.0: + resolution: {integrity: sha512-d9T8ucsEhh8Bi1woXCf+TIKDIROLG5WCkxg8geBCbvk22kzwC5G2OnXVMO6FUsvQlgUUXQ2itephWDLqDzbeCw==} + engines: {node: '>= 0.4'} + + es-to-primitive@1.3.4: + resolution: {integrity: sha512-yPDz7wqpg1/mmHLmS3tcfTfbw5f1eryXvyghYBffGdERwe+mV7ZcWzTR8LR17Kvqt3qfPurjlonmnq3MKXIOXw==} + engines: {node: '>= 0.4'} + + escalade@3.2.0: + resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} + engines: {node: '>=6'} + + escape-string-regexp@4.0.0: + resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} + engines: {node: '>=10'} + + eslint-config-next@16.3.0: + resolution: {integrity: sha512-lPrf1kHsMJEZqO0uXkNB400c5MGrhrTk3BNX7P0ol4gt61+iUlQfjy9TyIOEA9eOXrf+5+mYbT/JsY8+zqUByQ==} + peerDependencies: + eslint: '>=9.0.0' + typescript: '>=3.3.1' + peerDependenciesMeta: + typescript: + optional: true + + eslint-import-resolver-node@0.3.10: + resolution: {integrity: sha512-tRrKqFyCaKict5hOd244sL6EQFNycnMQnBe+j8uqGNXYzsImGbGUU4ibtoaBmv5FLwJwcFJNeg1GeVjQfbMrDQ==} + + eslint-import-resolver-typescript@3.10.1: + resolution: {integrity: sha512-A1rHYb06zjMGAxdLSkN2fXPBwuSaQ0iO5M/hdyS0Ajj1VBaRp0sPD3dn1FhME3c/JluGFbwSxyCfqdSbtQLAHQ==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + eslint: '*' + eslint-plugin-import: '*' + eslint-plugin-import-x: '*' + peerDependenciesMeta: + eslint-plugin-import: + optional: true + eslint-plugin-import-x: + optional: true + + eslint-module-utils@2.14.0: + resolution: {integrity: sha512-W2WCRZ9Dqntd+2u8jJcVMV2PKulc6RdLgUUoh/yQr3uB6lo/ZOeGx11sv60/8S4QFFKNslAlWhr9u0Ef7ZW6Ig==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: '*' + eslint-import-resolver-node: '*' + eslint-import-resolver-typescript: '*' + eslint-import-resolver-webpack: '*' + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + eslint: + optional: true + eslint-import-resolver-node: + optional: true + eslint-import-resolver-typescript: + optional: true + eslint-import-resolver-webpack: + optional: true + + eslint-plugin-import@2.32.0: + resolution: {integrity: sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9 + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + + eslint-plugin-jsx-a11y@6.10.2: + resolution: {integrity: sha512-scB3nz4WmG75pV8+3eRUQOHZlNSUhFNq37xnpgRkCCELU3XMvXAxLk1eqWWyE22Ki4Q01Fnsw9BA3cJHDPgn2Q==} + engines: {node: '>=4.0'} + peerDependencies: + eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9 + + eslint-plugin-react-hooks@7.1.1: + resolution: {integrity: sha512-f2I7Gw6JbvCexzIInuSbZpfdQ44D7iqdWX01FKLvrPgqxoE7oMj8clOfto8U6vYiz4yd5oKu39rRSVOe1zRu0g==} + engines: {node: '>=18'} + peerDependencies: + eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 || ^10.0.0 + + eslint-plugin-react@7.37.5: + resolution: {integrity: sha512-Qteup0SqU15kdocexFNAJMvCJEfa2xUKNV4CC1xsVMrIIqEy3SQ/rqyxCWNzfrd3/ldy6HMlD2e0JDVpDg2qIA==} + engines: {node: '>=4'} + peerDependencies: + eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7 + + eslint-scope@8.4.0: + resolution: {integrity: sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + eslint-visitor-keys@3.4.3: + resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + eslint-visitor-keys@4.2.1: + resolution: {integrity: sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + eslint-visitor-keys@5.0.1: + resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + eslint@9.39.5: + resolution: {integrity: sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + hasBin: true + peerDependencies: + jiti: '*' + peerDependenciesMeta: + jiti: + optional: true + + espree@10.4.0: + resolution: {integrity: sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + esquery@1.7.0: + resolution: {integrity: sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==} + engines: {node: '>=0.10'} + + esrecurse@4.3.0: + resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} + engines: {node: '>=4.0'} + + estraverse@5.3.0: + resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} + engines: {node: '>=4.0'} + + estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + + esutils@2.0.3: + resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} + engines: {node: '>=0.10.0'} + + expect-type@1.4.0: + resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} + engines: {node: '>=12.0.0'} + + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + fast-glob@3.3.1: + resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==} + engines: {node: '>=8.6.0'} + + fast-json-stable-stringify@2.1.0: + resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} + + fast-levenshtein@2.0.6: + resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + + fastq@1.20.1: + resolution: {integrity: sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + file-entry-cache@8.0.0: + resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} + engines: {node: '>=16.0.0'} + + fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} + engines: {node: '>=8'} + + find-up@5.0.0: + resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} + engines: {node: '>=10'} + + flat-cache@4.0.1: + resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} + engines: {node: '>=16'} + + flatted@3.4.4: + resolution: {integrity: sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==} + + for-each@0.3.5: + resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} + engines: {node: '>= 0.4'} + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + + function.prototype.name@1.2.0: + resolution: {integrity: sha512-jObKIik1P2QjPHP5nz5BaOtUlfgS0fWo8IUByNXkM+o+02sJOi94em77GwJKQSJ3gfPHdgzLNrHc1uokV4P/ew==} + engines: {node: '>= 0.4'} + + functions-have-names@1.2.3: + resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} + + generator-function@2.0.1: + resolution: {integrity: sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==} + engines: {node: '>= 0.4'} + + gensync@1.0.0-beta.2: + resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} + engines: {node: '>=6.9.0'} + + get-intrinsic@1.3.0: + resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} + engines: {node: '>= 0.4'} + + get-proto@1.0.1: + resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} + engines: {node: '>= 0.4'} + + get-symbol-description@1.1.0: + resolution: {integrity: sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==} + engines: {node: '>= 0.4'} + + get-tsconfig@4.14.1: + resolution: {integrity: sha512-Dz/6HxkrxgNehhxLVeyv8sad9UzF2xBVeaKBQNDfJ5XiSXmp2gTR0eO0RWiT2NCKS5aGP9jjkOMggTN90qU50A==} + + glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + + glob-parent@6.0.2: + resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} + engines: {node: '>=10.13.0'} + + globals@14.0.0: + resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} + engines: {node: '>=18'} + + globals@16.4.0: + resolution: {integrity: sha512-ob/2LcVVaVGCYN+r14cnwnoDPUufjiYgSqRhiFD0Q1iI4Odora5RE8Iv1D24hAz5oMophRGkGz+yuvQmmUMnMw==} + engines: {node: '>=18'} + + globalthis@1.0.4: + resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} + engines: {node: '>= 0.4'} + + gopd@1.2.0: + resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} + engines: {node: '>= 0.4'} + + graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + + has-bigints@1.1.0: + resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} + engines: {node: '>= 0.4'} + + has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + + has-property-descriptors@1.0.2: + resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} + + has-proto@1.2.0: + resolution: {integrity: sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==} + engines: {node: '>= 0.4'} + + has-symbols@1.1.0: + resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==} + engines: {node: '>= 0.4'} + + has-tostringtag@1.0.2: + resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} + engines: {node: '>= 0.4'} + + hasown@2.0.4: + resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} + engines: {node: '>= 0.4'} + + hermes-estree@0.25.1: + resolution: {integrity: sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==} + + hermes-parser@0.25.1: + resolution: {integrity: sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==} + + html-encoding-sniffer@6.0.0: + resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + + ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} + engines: {node: '>= 4'} + + ignore@7.0.6: + resolution: {integrity: sha512-BAg6QkE8W+TuQLrrw0Ugr7HegXduRuuj8/ti2kSOc+jz1dmx8/WNcjr6XGnq5YpDWxFwwaavqD0+jIUOKelTsw==} + engines: {node: '>= 4'} + + import-fresh@3.3.1: + resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} + engines: {node: '>=6'} + + imurmurhash@0.1.4: + resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} + engines: {node: '>=0.8.19'} + + indent-string@4.0.0: + resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} + engines: {node: '>=8'} + + internal-slot@1.1.0: + resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==} + engines: {node: '>= 0.4'} + + is-array-buffer@3.0.5: + resolution: {integrity: sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==} + engines: {node: '>= 0.4'} + + is-async-function@2.1.1: + resolution: {integrity: sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==} + engines: {node: '>= 0.4'} + + is-bigint@1.1.0: + resolution: {integrity: sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==} + engines: {node: '>= 0.4'} + + is-boolean-object@1.2.2: + resolution: {integrity: sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==} + engines: {node: '>= 0.4'} + + is-bun-module@2.0.0: + resolution: {integrity: sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ==} + + is-callable@1.2.7: + resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} + engines: {node: '>= 0.4'} + + is-core-module@2.16.2: + resolution: {integrity: sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==} + engines: {node: '>= 0.4'} + + is-data-view@1.0.2: + resolution: {integrity: sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==} + engines: {node: '>= 0.4'} + + is-date-object@1.1.0: + resolution: {integrity: sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==} + engines: {node: '>= 0.4'} + + is-document.all@1.0.0: + resolution: {integrity: sha512-+XSoyS05OdBbhFuELhgTCpFNHkpBOJqtsZfUFFpe5QTw+9Sjbh8zitxhQkYAo6wV7e1Vb8cAPvpCk9jGam/82g==} + engines: {node: '>= 0.4'} + + is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + + is-finalizationregistry@1.1.1: + resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==} + engines: {node: '>= 0.4'} + + is-generator-function@1.1.2: + resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==} + engines: {node: '>= 0.4'} + + is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + + is-map@2.0.3: + resolution: {integrity: sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==} + engines: {node: '>= 0.4'} + + is-negative-zero@2.0.3: + resolution: {integrity: sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==} + engines: {node: '>= 0.4'} + + is-number-object@1.1.1: + resolution: {integrity: sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==} + engines: {node: '>= 0.4'} + + is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + + is-potential-custom-element-name@1.0.1: + resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==} + + is-regex@1.2.1: + resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} + engines: {node: '>= 0.4'} + + is-set@2.0.3: + resolution: {integrity: sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==} + engines: {node: '>= 0.4'} + + is-shared-array-buffer@1.0.4: + resolution: {integrity: sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==} + engines: {node: '>= 0.4'} + + is-string@1.1.1: + resolution: {integrity: sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==} + engines: {node: '>= 0.4'} + + is-symbol@1.1.1: + resolution: {integrity: sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==} + engines: {node: '>= 0.4'} + + is-typed-array@1.1.15: + resolution: {integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==} + engines: {node: '>= 0.4'} + + is-weakmap@2.0.2: + resolution: {integrity: sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==} + engines: {node: '>= 0.4'} + + is-weakref@1.1.1: + resolution: {integrity: sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==} + engines: {node: '>= 0.4'} + + is-weakset@2.0.4: + resolution: {integrity: sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==} + engines: {node: '>= 0.4'} + + isarray@2.0.5: + resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + iterator.prototype@1.1.5: + resolution: {integrity: sha512-H0dkQoCa3b2VEeKQBOxFph+JAbcrQdE7KC0UkqwpLmv2EC4P41QXP+rqo9wYodACiG5/WM5s9oDApTU8utwj9g==} + engines: {node: '>= 0.4'} + + jiti@2.7.0: + resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==} + hasBin: true + + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + + js-yaml@4.3.1: + resolution: {integrity: sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==} + hasBin: true + + jsdom@30.0.1: + resolution: {integrity: sha512-52v7mUVUfNQVYYqE1lcdaymWL0njO7lTLUog6ZvW2U5KsbiLk/GnZlVJ+qx0xfNJZ6Gn+KSpPNE52vurbxZwrA==} + engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0} + peerDependencies: + canvas: ^3.2.3 + peerDependenciesMeta: + canvas: + optional: true + + jsesc@3.1.0: + resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} + engines: {node: '>=6'} + hasBin: true + + json-buffer@3.0.1: + resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} + + json-schema-traverse@0.4.1: + resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} + + json-stable-stringify-without-jsonify@1.0.1: + resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} + + json5@1.0.2: + resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} + hasBin: true + + json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + + jsx-ast-utils@3.3.5: + resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==} + engines: {node: '>=4.0'} + + keyv@4.5.4: + resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} + + language-subtag-registry@0.3.23: + resolution: {integrity: sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==} + + language-tags@1.0.9: + resolution: {integrity: sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==} + engines: {node: '>=0.10'} + + levn@0.4.1: + resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} + engines: {node: '>= 0.8.0'} + + lightningcss-android-arm64@1.32.0: + resolution: {integrity: sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.32.0: + resolution: {integrity: sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.32.0: + resolution: {integrity: sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.32.0: + resolution: {integrity: sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.32.0: + resolution: {integrity: sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.32.0: + resolution: {integrity: sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.32.0: + resolution: {integrity: sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.32.0: + resolution: {integrity: sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.32.0: + resolution: {integrity: sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.32.0: + resolution: {integrity: sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.32.0: + resolution: {integrity: sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.32.0: + resolution: {integrity: sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==} + engines: {node: '>= 12.0.0'} + + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + + locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + + lodash.merge@4.6.2: + resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + + loose-envify@1.4.0: + resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} + hasBin: true + + lru-cache@11.5.2: + resolution: {integrity: sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==} + engines: {node: 20 || >=22} + + lru-cache@5.1.1: + resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + + lz-string@1.5.0: + resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==} + hasBin: true + + magic-string@0.30.21: + resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + + math-intrinsics@1.1.0: + resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} + engines: {node: '>= 0.4'} + + mdn-data@2.27.1: + resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==} + + merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + + micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + + min-indent@1.0.1: + resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} + engines: {node: '>=4'} + + minimatch@10.2.6: + resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==} + engines: {node: 18 || 20 || >=22} + + minimatch@3.1.5: + resolution: {integrity: sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==} + + minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + nanoid@3.3.18: + resolution: {integrity: sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + napi-postinstall@0.3.4: + resolution: {integrity: sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ==} + engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + hasBin: true + + natural-compare@1.4.0: + resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + + next@16.3.0: + resolution: {integrity: sha512-NEdGOzH+08eTXMUp9UYkA99Nhi5N6Thrhc1jgFOQgfgnGK/dA2hRwBpXep+exdFQrnwlRf/3Wixyp8lLBUpE2A==} + engines: {node: '>=20.9.0'} + hasBin: true + peerDependencies: + '@opentelemetry/api': ^1.1.0 + '@playwright/test': ^1.51.1 + babel-plugin-react-compiler: '*' + react: ^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0 + react-dom: ^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0 + sass: ^1.3.0 + peerDependenciesMeta: + '@opentelemetry/api': + optional: true + '@playwright/test': + optional: true + babel-plugin-react-compiler: + optional: true + sass: + optional: true + + node-exports-info@1.6.2: + resolution: {integrity: sha512-kXs9Go0cah0qHVV2v389IXQLdLCeE1xfFtjOAF+iobu0OIoG1pje8At2vMHyaPMiPMnG/LWP50twML21eMcAag==} + engines: {node: '>= 0.4'} + + node-releases@2.0.53: + resolution: {integrity: sha512-D9UOmYG3UH1V+ENW56t5QXBwJw1YEY18ruVeus89Rw+SyIgjPkCO84bRzO3uNIYosJbNwiabWVn48o3uJLjxFQ==} + engines: {node: '>=18'} + + object-assign@4.1.1: + resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} + engines: {node: '>=0.10.0'} + + object-inspect@1.13.4: + resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==} + engines: {node: '>= 0.4'} + + object-keys@1.1.1: + resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} + engines: {node: '>= 0.4'} + + object.assign@4.1.7: + resolution: {integrity: sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==} + engines: {node: '>= 0.4'} + + object.entries@1.1.9: + resolution: {integrity: sha512-8u/hfXFRBD1O0hPUjioLhoWFHRmt6tKA4/vZPyckBr18l1KE9uHrFaFaUi8MDRTpi4uak2goyPTSNJLXX2k2Hw==} + engines: {node: '>= 0.4'} + + object.fromentries@2.0.8: + resolution: {integrity: sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==} + engines: {node: '>= 0.4'} + + object.groupby@1.0.3: + resolution: {integrity: sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==} + engines: {node: '>= 0.4'} + + object.values@1.2.1: + resolution: {integrity: sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==} + engines: {node: '>= 0.4'} + + obug@2.1.4: + resolution: {integrity: sha512-4a+OsYv9UktOJKE+l1A4OufDgdRF9PifWj+tJnHURo/P+WOxpG4GzUFL9qCalmWauao6ogiG+QvnCovwPoyAWA==} + engines: {node: '>=12.20.0'} + + optionator@0.9.4: + resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} + engines: {node: '>= 0.8.0'} + + own-keys@1.0.2: + resolution: {integrity: sha512-19YVAg7T+WTrxggPukVq7DjTv6+PJ867TmhCvBsYwmbFCsZd344rq2Ld1p0wo8f8Qrrhgp82c6FJRqdXWtSEhg==} + engines: {node: '>= 0.4'} + + p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + + p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + + parent-module@1.0.1: + resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} + engines: {node: '>=6'} + + parse5@8.0.1: + resolution: {integrity: sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==} + + path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@2.3.2: + resolution: {integrity: sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==} + engines: {node: '>=8.6'} + + picomatch@4.0.5: + resolution: {integrity: sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==} + engines: {node: '>=12'} + + possible-typed-array-names@1.1.0: + resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} + engines: {node: '>= 0.4'} + + postcss@8.5.23: + resolution: {integrity: sha512-g50586zr4bZmwFiTlflMu8E0bDTb5I5gertgwAKmsdUlTQIhZtunzUlD1WSzwcVWPoAVpsrA6vlfCD7oXvRwgg==} + engines: {node: ^10 || ^12 || >=14} + + postcss@8.5.26: + resolution: {integrity: sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==} + engines: {node: ^10 || ^12 || >=14} + + prelude-ls@1.2.1: + resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} + engines: {node: '>= 0.8.0'} + + pretty-format@27.5.1: + resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} + engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} + + prop-types@15.8.1: + resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} + + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + + queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + + react-dom@19.2.8: + resolution: {integrity: sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==} + peerDependencies: + react: ^19.2.8 + + react-is@16.13.1: + resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} + + react-is@17.0.2: + resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} + + react@19.2.8: + resolution: {integrity: sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==} + engines: {node: '>=0.10.0'} + + redent@3.0.0: + resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} + engines: {node: '>=8'} + + reflect.getprototypeof@1.0.10: + resolution: {integrity: sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==} + engines: {node: '>= 0.4'} + + regexp.prototype.flags@1.5.4: + resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==} + engines: {node: '>= 0.4'} + + require-from-string@2.0.2: + resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} + engines: {node: '>=0.10.0'} + + resolve-from@4.0.0: + resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} + engines: {node: '>=4'} + + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + + resolve@2.0.0-next.7: + resolution: {integrity: sha512-tqt+NBWwyaMgw3zDsnygx4CByWjQEJHOPMdslYhppaQSJUtL/D4JO9CcBBlhPoI8lz9oJIDXkwXfhF4aWqP8xQ==} + engines: {node: '>= 0.4'} + hasBin: true + + reusify@1.1.0: + resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + + rolldown@1.2.3: + resolution: {integrity: sha512-rn9wpmxplLf7NLNyCk9FyWh3FM43DbY8jOzCdEPzH7uflhTftRbCEpqi6Ly2osgoU8OwObtmavMbWLaWy4LX7A==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + + safe-array-concat@1.1.4: + resolution: {integrity: sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==} + engines: {node: '>=0.4'} + + safe-push-apply@1.0.0: + resolution: {integrity: sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==} + engines: {node: '>= 0.4'} + + safe-regex-test@1.1.0: + resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==} + engines: {node: '>= 0.4'} + + saxes@6.0.0: + resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==} + engines: {node: '>=v12.22.7'} + + scheduler@0.27.0: + resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==} + + semver@6.3.1: + resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} + hasBin: true + + semver@7.8.5: + resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} + engines: {node: '>=10'} + hasBin: true + + server-only@0.0.1: + resolution: {integrity: sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA==} + + set-function-length@1.2.2: + resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} + engines: {node: '>= 0.4'} + + set-function-name@2.0.2: + resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} + engines: {node: '>= 0.4'} + + set-proto@1.0.0: + resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==} + engines: {node: '>= 0.4'} + + sharp@0.35.3: + resolution: {integrity: sha512-ej0zVHuZGHCiABXcNxeYhpRnPNPAcvbG8RMdBAhDAxLKkCRVSpK3Iyu7qbqw3JMzoj0REeM6f3tJLtVwl0023Q==} + engines: {node: '>=20.9.0'} + peerDependencies: + '@types/node': '*' + peerDependenciesMeta: + '@types/node': + optional: true + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + side-channel-list@1.0.1: + resolution: {integrity: sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==} + engines: {node: '>= 0.4'} + + side-channel-map@1.0.1: + resolution: {integrity: sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==} + engines: {node: '>= 0.4'} + + side-channel-weakmap@1.0.2: + resolution: {integrity: sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==} + engines: {node: '>= 0.4'} + + side-channel@1.1.1: + resolution: {integrity: sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==} + engines: {node: '>= 0.4'} + + siginfo@2.0.0: + resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + + source-map-js@1.2.1: + resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} + engines: {node: '>=0.10.0'} + + stable-hash@0.0.5: + resolution: {integrity: sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==} + + stackback@0.0.2: + resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + + std-env@4.2.0: + resolution: {integrity: sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==} + + stop-iteration-iterator@1.1.0: + resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} + engines: {node: '>= 0.4'} + + string.prototype.includes@2.0.1: + resolution: {integrity: sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==} + engines: {node: '>= 0.4'} + + string.prototype.matchall@4.0.12: + resolution: {integrity: sha512-6CC9uyBL+/48dYizRf7H7VAYCMCNTBeM78x/VTUe9bFEaxBepPJDa1Ow99LqI/1yF7kuy7Q3cQsYMrcjGUcskA==} + engines: {node: '>= 0.4'} + + string.prototype.repeat@1.0.0: + resolution: {integrity: sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==} + + string.prototype.trim@1.2.11: + resolution: {integrity: sha512-PwvK7BU+CMTJGYQCTZb5RWXIML92lftJLhQz1tBzgKiqGxJaMlBAa48POXaNAC2s4y8jr3EFqrkF9+44neS46w==} + engines: {node: '>= 0.4'} + + string.prototype.trimend@1.0.10: + resolution: {integrity: sha512-2+3aDAOmPTmuFwjDnmJG2ctEkQKVki7vOSqaxkv42Mowj1V6PnvuwFCRrR5lChUux1TBskPjfkeTOhqczDMxTw==} + engines: {node: '>= 0.4'} + + string.prototype.trimstart@1.0.8: + resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} + engines: {node: '>= 0.4'} + + strip-bom@3.0.0: + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} + engines: {node: '>=4'} + + strip-indent@3.0.0: + resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} + engines: {node: '>=8'} + + strip-json-comments@3.1.1: + resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} + engines: {node: '>=8'} + + styled-jsx@5.1.6: + resolution: {integrity: sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==} + engines: {node: '>= 12.0.0'} + peerDependencies: + '@babel/core': '*' + babel-plugin-macros: '*' + react: '>= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0' + peerDependenciesMeta: + '@babel/core': + optional: true + babel-plugin-macros: + optional: true + + supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + + supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + + symbol-tree@3.2.4: + resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==} + + tailwindcss@4.3.3: + resolution: {integrity: sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==} + + tapable@2.3.3: + resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==} + engines: {node: '>=6'} + + tinybench@2.9.0: + resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} + + tinyexec@1.3.0: + resolution: {integrity: sha512-QKAl9m8gWWGHV8jZcPeym6j+XULi6tOf1mT83WYJ4Lk2ytW/uwAWkrP0uFsdoYMdueVJ0qs26wZ+23xeB4ibNQ==} + engines: {node: '>=18'} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + tinyrainbow@3.1.1: + resolution: {integrity: sha512-yau8yJdTt989Mm0Bd/236QnzEiPf2xLLTqUZRUJOo/3CB078LSwzei343DgtJVmfJKJE3TMINY1u42SQsP6mXw==} + engines: {node: '>=14.0.0'} + + tldts-core@7.4.10: + resolution: {integrity: sha512-KnQjp53ZekKgm/r3l+u8kJGGzYgrWdP8+Mql7a4vijh2WE0IrZWspQj/TpTxDho/YxO+AnOZnIjQcCD+q6iJsw==} + + tldts@7.4.10: + resolution: {integrity: sha512-GgouD1B+sWwvkaEq8vXC15DjQitxbvs12oIXELpconwm+Tg3zfcEv4jgzq3vtKverDXsg3VI8aRgNL2Nra0Iog==} + hasBin: true + + to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + + tough-cookie@6.0.2: + resolution: {integrity: sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==} + engines: {node: '>=16'} + + tr46@6.0.0: + resolution: {integrity: sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==} + engines: {node: '>=20'} + + ts-api-utils@2.5.0: + resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==} + engines: {node: '>=18.12'} + peerDependencies: + typescript: '>=4.8.4' + + tsconfig-paths@3.15.0: + resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} + + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + + type-check@0.4.0: + resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} + engines: {node: '>= 0.8.0'} + + typed-array-buffer@1.0.3: + resolution: {integrity: sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==} + engines: {node: '>= 0.4'} + + typed-array-byte-length@1.0.3: + resolution: {integrity: sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==} + engines: {node: '>= 0.4'} + + typed-array-byte-offset@1.0.4: + resolution: {integrity: sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ==} + engines: {node: '>= 0.4'} + + typed-array-length@1.0.8: + resolution: {integrity: sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==} + engines: {node: '>= 0.4'} + + typescript-eslint@8.66.0: + resolution: {integrity: sha512-QlEbBPz/RuJ1XUHj29nm3t0F/O/cSlEnntozqPOYHnnTGAXFamnMBu5i9Vn6vhUPHGAjR+Vl+5J8vPN/BMUrJw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} + hasBin: true + + unbox-primitive@1.1.0: + resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} + engines: {node: '>= 0.4'} + + undici-types@7.18.2: + resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==} + + undici@8.10.0: + resolution: {integrity: sha512-HvltHd7avK13QIw/oLe4qoOLyoVSoafqJ2jYOrtMRBkbYT31eiBQ8O0ehRKZiEZCMEyLFQNIADpgCWC5fALvYQ==} + engines: {node: '>=22.19.0'} + + unrs-resolver@1.12.2: + resolution: {integrity: sha512-dmlRxBJJayXjqTwC+JtF1HhJmgf3ftQ3YejFcZrf4+KKtJv0qDsK1pjqaaVjG7wJ5NJ6UVP1OqRMQ71Z4C3rxQ==} + + update-browserslist-db@1.3.0: + resolution: {integrity: sha512-x/M6q3w4Ybp91CNaS4S69UnliqR3BzRpOT6LWbksjth0S/+jhfaPJsWjt/TewpT8j9eLIojUf5jr29WextHroA==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + + uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + + vite@8.2.1: + resolution: {integrity: sha512-EU/eS7BH3XROHh2YnBefjM6DBKA6ZeMZEYQbj7NLWg5wHYlhB8B/Mayd5XsgWq+NFYccDOTemRpdETWR6Ka/lw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.4.0 + esbuild: ^0.27.0 || ^0.28.0 + jiti: '>=1.21.0' + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + + vitest@4.1.10: + resolution: {integrity: sha512-R9jUTe5S4Qb0HCd4TNqpC7oGcrMssMRGXLW80ubjWsW9VH5GF8y1Y0SFLY9AbqSk6nt0PnOx4H4WNJYZ13GUPw==} + engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@opentelemetry/api': ^1.9.0 + '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0 + '@vitest/browser-playwright': 4.1.10 + '@vitest/browser-preview': 4.1.10 + '@vitest/browser-webdriverio': 4.1.10 + '@vitest/coverage-istanbul': 4.1.10 + '@vitest/coverage-v8': 4.1.10 + '@vitest/ui': 4.1.10 + happy-dom: '*' + jsdom: '*' + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@opentelemetry/api': + optional: true + '@types/node': + optional: true + '@vitest/browser-playwright': + optional: true + '@vitest/browser-preview': + optional: true + '@vitest/browser-webdriverio': + optional: true + '@vitest/coverage-istanbul': + optional: true + '@vitest/coverage-v8': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + + w3c-xmlserializer@5.0.0: + resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==} + engines: {node: '>=18'} + + webidl-conversions@8.0.1: + resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==} + engines: {node: '>=20'} + + whatwg-mimetype@5.0.0: + resolution: {integrity: sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==} + engines: {node: '>=20'} + + whatwg-url@16.0.1: + resolution: {integrity: sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + + whatwg-url@17.1.0: + resolution: {integrity: sha512-3GeworPmc2ZfEEHP7lEbUfBX/L75wdEsi0rLNhXcXxnoN5jyq0SL5gCy06SGW2cyTIZdTvWIDQNQoza++vKeaw==} + engines: {node: ^22.14.0 || >=24.0.0} + + which-boxed-primitive@1.1.1: + resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} + engines: {node: '>= 0.4'} + + which-builtin-type@1.2.1: + resolution: {integrity: sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==} + engines: {node: '>= 0.4'} + + which-collection@1.0.2: + resolution: {integrity: sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==} + engines: {node: '>= 0.4'} + + which-typed-array@1.1.22: + resolution: {integrity: sha512-fvO4ExWMFsqyhG3AiPAObMuY1lxaqgYcxbc49CNdWDDECOJNgQyvsOWVwbZc+qf3rzRtxojBK+CMEv0Ld5CYpw==} + engines: {node: '>= 0.4'} + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + why-is-node-running@2.3.0: + resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} + engines: {node: '>=8'} + hasBin: true + + word-wrap@1.2.5: + resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} + engines: {node: '>=0.10.0'} + + xml-name-validator@5.0.0: + resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} + engines: {node: '>=18'} + + xmlchars@2.2.0: + resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} + + yallist@3.1.1: + resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} + + yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + + zod-validation-error@4.0.2: + resolution: {integrity: sha512-Q6/nZLe6jxuU80qb/4uJ4t5v2VEZ44lzQjPDhYJNztRQ4wyWc6VF3D3Kb/fAuPetZQnhS3hnajCf9CsWesghLQ==} + engines: {node: '>=18.0.0'} + peerDependencies: + zod: ^3.25.0 || ^4.0.0 + + zod@4.4.3: + resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==} + +snapshots: + + '@adobe/css-tools@4.5.0': {} + + '@alloc/quick-lru@5.2.0': {} + + '@asamuzakjp/css-color@6.0.5': + dependencies: + '@csstools/css-calc': 3.3.0(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0) + '@csstools/css-color-parser': 4.1.10(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0) + '@csstools/css-parser-algorithms': 4.0.0(@csstools/css-tokenizer@4.0.0) + '@csstools/css-tokenizer': 4.0.0 + lru-cache: 11.5.2 + + '@asamuzakjp/dom-selector@8.3.2': + dependencies: + bidi-js: 1.0.3 + css-tree: 3.2.1 + is-potential-custom-element-name: 1.0.1 + lru-cache: 11.5.2 + + '@babel/code-frame@7.29.7': + dependencies: + '@babel/helper-validator-identifier': 7.29.7 + js-tokens: 4.0.0 + picocolors: 1.1.1 + + '@babel/compat-data@7.29.7': {} + + '@babel/core@7.29.7': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.8 + '@babel/helper-compilation-targets': 7.29.7 + '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7) + '@babel/helpers': 7.29.7 + '@babel/parser': 7.29.8 + '@babel/template': 7.29.7 + '@babel/traverse': 7.29.8 + '@babel/types': 7.29.8 + '@jridgewell/remapping': 2.3.5 + convert-source-map: 2.0.0 + debug: 4.4.3 + gensync: 1.0.0-beta.2 + json5: 2.2.3 + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + + '@babel/generator@7.29.8': + dependencies: + '@babel/parser': 7.29.8 + '@babel/types': 7.29.8 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + jsesc: 3.1.0 + + '@babel/helper-compilation-targets@7.29.7': + dependencies: + '@babel/compat-data': 7.29.7 + '@babel/helper-validator-option': 7.29.7 + browserslist: 4.28.7 + lru-cache: 5.1.1 + semver: 6.3.1 + + '@babel/helper-globals@7.29.7': {} + + '@babel/helper-module-imports@7.29.7': + dependencies: + '@babel/traverse': 7.29.8 + '@babel/types': 7.29.8 + transitivePeerDependencies: + - supports-color + + '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7)': + dependencies: + '@babel/core': 7.29.7 + '@babel/helper-module-imports': 7.29.7 + '@babel/helper-validator-identifier': 7.29.7 + '@babel/traverse': 7.29.8 + transitivePeerDependencies: + - supports-color + + '@babel/helper-string-parser@7.29.7': {} + + '@babel/helper-validator-identifier@7.29.7': {} + + '@babel/helper-validator-option@7.29.7': {} + + '@babel/helpers@7.29.7': + dependencies: + '@babel/template': 7.29.7 + '@babel/types': 7.29.8 + + '@babel/parser@7.29.8': + dependencies: + '@babel/types': 7.29.8 + + '@babel/runtime@7.29.7': {} + + '@babel/template@7.29.7': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/parser': 7.29.8 + '@babel/types': 7.29.8 + + '@babel/traverse@7.29.8': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.8 + '@babel/helper-globals': 7.29.7 + '@babel/parser': 7.29.8 + '@babel/template': 7.29.7 + '@babel/types': 7.29.8 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + + '@babel/types@7.29.8': + dependencies: + '@babel/helper-string-parser': 7.29.7 + '@babel/helper-validator-identifier': 7.29.7 + + '@bramus/specificity@2.4.2': + dependencies: + css-tree: 3.2.1 + + '@csstools/color-helpers@6.1.0': {} + + '@csstools/css-calc@3.3.0(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0)': + dependencies: + '@csstools/css-parser-algorithms': 4.0.0(@csstools/css-tokenizer@4.0.0) + '@csstools/css-tokenizer': 4.0.0 + + '@csstools/css-color-parser@4.1.10(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0)': + dependencies: + '@csstools/color-helpers': 6.1.0 + '@csstools/css-calc': 3.3.0(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0) + '@csstools/css-parser-algorithms': 4.0.0(@csstools/css-tokenizer@4.0.0) + '@csstools/css-tokenizer': 4.0.0 + + '@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0)': + dependencies: + '@csstools/css-tokenizer': 4.0.0 + + '@csstools/css-syntax-patches-for-csstree@1.1.7(css-tree@3.2.1)': + optionalDependencies: + css-tree: 3.2.1 + + '@csstools/css-tokenizer@4.0.0': {} + + '@emnapi/core@1.10.0': + dependencies: + '@emnapi/wasi-threads': 1.2.1 + tslib: 2.8.1 + optional: true + + '@emnapi/runtime@1.10.0': + dependencies: + tslib: 2.8.1 + optional: true + + '@emnapi/runtime@1.11.3': + dependencies: + tslib: 2.8.1 + optional: true + + '@emnapi/wasi-threads@1.2.1': + dependencies: + tslib: 2.8.1 + optional: true + + '@eslint-community/eslint-utils@4.10.1(eslint@9.39.5(jiti@2.7.0))': + dependencies: + eslint: 9.39.5(jiti@2.7.0) + eslint-visitor-keys: 3.4.3 + + '@eslint-community/eslint-utils@4.9.1(eslint@9.39.5(jiti@2.7.0))': + dependencies: + eslint: 9.39.5(jiti@2.7.0) + eslint-visitor-keys: 3.4.3 + + '@eslint-community/regexpp@4.12.2': {} + + '@eslint/config-array@0.21.2': + dependencies: + '@eslint/object-schema': 2.1.7 + debug: 4.4.3 + minimatch: 3.1.5 + transitivePeerDependencies: + - supports-color + + '@eslint/config-helpers@0.4.2': + dependencies: + '@eslint/core': 0.17.0 + + '@eslint/core@0.17.0': + dependencies: + '@types/json-schema': 7.0.15 + + '@eslint/eslintrc@3.3.6': + dependencies: + ajv: 6.15.0 + debug: 4.4.3 + espree: 10.4.0 + globals: 14.0.0 + ignore: 5.3.2 + import-fresh: 3.3.1 + js-yaml: 4.3.1 + minimatch: 3.1.5 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + + '@eslint/js@9.39.5': {} + + '@eslint/object-schema@2.1.7': {} + + '@eslint/plugin-kit@0.4.1': + dependencies: + '@eslint/core': 0.17.0 + levn: 0.4.1 + + '@exodus/bytes@1.15.1': {} + + '@humanfs/core@0.19.2': + dependencies: + '@humanfs/types': 0.15.0 + + '@humanfs/node@0.16.8': + dependencies: + '@humanfs/core': 0.19.2 + '@humanfs/types': 0.15.0 + '@humanwhocodes/retry': 0.4.3 + + '@humanfs/types@0.15.0': {} + + '@humanwhocodes/module-importer@1.0.1': {} + + '@humanwhocodes/retry@0.4.3': {} + + '@img/colour@1.1.0': + optional: true + + '@img/sharp-darwin-arm64@0.35.3': + optionalDependencies: + '@img/sharp-libvips-darwin-arm64': 1.3.2 + optional: true + + '@img/sharp-darwin-x64@0.35.3': + optionalDependencies: + '@img/sharp-libvips-darwin-x64': 1.3.2 + optional: true + + '@img/sharp-freebsd-wasm32@0.35.3': + dependencies: + '@img/sharp-wasm32': 0.35.3 + optional: true + + '@img/sharp-libvips-darwin-arm64@1.3.2': + optional: true + + '@img/sharp-libvips-darwin-x64@1.3.2': + optional: true + + '@img/sharp-libvips-linux-arm64@1.3.2': + optional: true + + '@img/sharp-libvips-linux-arm@1.3.2': + optional: true + + '@img/sharp-libvips-linux-ppc64@1.3.2': + optional: true + + '@img/sharp-libvips-linux-riscv64@1.3.2': + optional: true + + '@img/sharp-libvips-linux-s390x@1.3.2': + optional: true + + '@img/sharp-libvips-linux-x64@1.3.2': + optional: true + + '@img/sharp-libvips-linuxmusl-arm64@1.3.2': + optional: true + + '@img/sharp-libvips-linuxmusl-x64@1.3.2': + optional: true + + '@img/sharp-linux-arm64@0.35.3': + optionalDependencies: + '@img/sharp-libvips-linux-arm64': 1.3.2 + optional: true + + '@img/sharp-linux-arm@0.35.3': + optionalDependencies: + '@img/sharp-libvips-linux-arm': 1.3.2 + optional: true + + '@img/sharp-linux-ppc64@0.35.3': + optionalDependencies: + '@img/sharp-libvips-linux-ppc64': 1.3.2 + optional: true + + '@img/sharp-linux-riscv64@0.35.3': + optionalDependencies: + '@img/sharp-libvips-linux-riscv64': 1.3.2 + optional: true + + '@img/sharp-linux-s390x@0.35.3': + optionalDependencies: + '@img/sharp-libvips-linux-s390x': 1.3.2 + optional: true + + '@img/sharp-linux-x64@0.35.3': + optionalDependencies: + '@img/sharp-libvips-linux-x64': 1.3.2 + optional: true + + '@img/sharp-linuxmusl-arm64@0.35.3': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-arm64': 1.3.2 + optional: true + + '@img/sharp-linuxmusl-x64@0.35.3': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-x64': 1.3.2 + optional: true + + '@img/sharp-wasm32@0.35.3': + dependencies: + '@emnapi/runtime': 1.11.3 + optional: true + + '@img/sharp-webcontainers-wasm32@0.35.3': + dependencies: + '@img/sharp-wasm32': 0.35.3 + optional: true + + '@img/sharp-win32-arm64@0.35.3': + optional: true + + '@img/sharp-win32-ia32@0.35.3': + optional: true + + '@img/sharp-win32-x64@0.35.3': + optional: true + + '@jridgewell/gen-mapping@0.3.13': + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/remapping@2.3.5': + dependencies: + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/resolve-uri@3.1.2': {} + + '@jridgewell/sourcemap-codec@1.5.5': {} + + '@jridgewell/trace-mapping@0.3.31': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.5 + + '@napi-rs/wasm-runtime@1.2.2(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)': + dependencies: + '@emnapi/core': 1.10.0 + '@emnapi/runtime': 1.10.0 + '@tybys/wasm-util': 0.10.3 + optional: true + + '@next/env@16.3.0': {} + + '@next/eslint-plugin-next@16.3.0(eslint@9.39.5(jiti@2.7.0))': + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(jiti@2.7.0)) + fast-glob: 3.3.1 + transitivePeerDependencies: + - eslint + + '@next/swc-darwin-arm64@16.3.0': + optional: true + + '@next/swc-darwin-x64@16.3.0': + optional: true + + '@next/swc-linux-arm64-gnu@16.3.0': + optional: true + + '@next/swc-linux-arm64-musl@16.3.0': + optional: true + + '@next/swc-linux-x64-gnu@16.3.0': + optional: true + + '@next/swc-linux-x64-musl@16.3.0': + optional: true + + '@next/swc-win32-arm64-msvc@16.3.0': + optional: true + + '@next/swc-win32-x64-msvc@16.3.0': + optional: true + + '@nodelib/fs.scandir@2.1.5': + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + + '@nodelib/fs.stat@2.0.5': {} + + '@nodelib/fs.walk@1.2.8': + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.20.1 + + '@nolyfill/is-core-module@1.0.39': {} + + '@oxc-project/types@0.143.0': {} + + '@rolldown/binding-android-arm64@1.2.3': + optional: true + + '@rolldown/binding-darwin-arm64@1.2.3': + optional: true + + '@rolldown/binding-darwin-x64@1.2.3': + optional: true + + '@rolldown/binding-freebsd-x64@1.2.3': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.2.3': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.2.3': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.2.3': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.2.3': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.2.3': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.2.3': + optional: true + + '@rolldown/binding-linux-x64-musl@1.2.3': + optional: true + + '@rolldown/binding-openharmony-arm64@1.2.3': + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.2.3': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.2.3': + optional: true + + '@rolldown/pluginutils@1.0.1': {} + + '@rtsao/scc@1.1.0': {} + + '@standard-schema/spec@1.1.0': {} + + '@swc/helpers@0.5.15': + dependencies: + tslib: 2.8.1 + + '@tailwindcss/node@4.3.3': + dependencies: + '@jridgewell/remapping': 2.3.5 + enhanced-resolve: 5.24.5 + jiti: 2.7.0 + lightningcss: 1.32.0 + magic-string: 0.30.21 + source-map-js: 1.2.1 + tailwindcss: 4.3.3 + + '@tailwindcss/oxide-android-arm64@4.3.3': + optional: true + + '@tailwindcss/oxide-darwin-arm64@4.3.3': + optional: true + + '@tailwindcss/oxide-darwin-x64@4.3.3': + optional: true + + '@tailwindcss/oxide-freebsd-x64@4.3.3': + optional: true + + '@tailwindcss/oxide-linux-arm-gnueabihf@4.3.3': + optional: true + + '@tailwindcss/oxide-linux-arm64-gnu@4.3.3': + optional: true + + '@tailwindcss/oxide-linux-arm64-musl@4.3.3': + optional: true + + '@tailwindcss/oxide-linux-x64-gnu@4.3.3': + optional: true + + '@tailwindcss/oxide-linux-x64-musl@4.3.3': + optional: true + + '@tailwindcss/oxide-wasm32-wasi@4.3.3': + optional: true + + '@tailwindcss/oxide-win32-arm64-msvc@4.3.3': + optional: true + + '@tailwindcss/oxide-win32-x64-msvc@4.3.3': + optional: true + + '@tailwindcss/oxide@4.3.3': + optionalDependencies: + '@tailwindcss/oxide-android-arm64': 4.3.3 + '@tailwindcss/oxide-darwin-arm64': 4.3.3 + '@tailwindcss/oxide-darwin-x64': 4.3.3 + '@tailwindcss/oxide-freebsd-x64': 4.3.3 + '@tailwindcss/oxide-linux-arm-gnueabihf': 4.3.3 + '@tailwindcss/oxide-linux-arm64-gnu': 4.3.3 + '@tailwindcss/oxide-linux-arm64-musl': 4.3.3 + '@tailwindcss/oxide-linux-x64-gnu': 4.3.3 + '@tailwindcss/oxide-linux-x64-musl': 4.3.3 + '@tailwindcss/oxide-wasm32-wasi': 4.3.3 + '@tailwindcss/oxide-win32-arm64-msvc': 4.3.3 + '@tailwindcss/oxide-win32-x64-msvc': 4.3.3 + + '@tailwindcss/postcss@4.3.3': + dependencies: + '@alloc/quick-lru': 5.2.0 + '@tailwindcss/node': 4.3.3 + '@tailwindcss/oxide': 4.3.3 + postcss: 8.5.23 + tailwindcss: 4.3.3 + + '@testing-library/dom@10.4.1': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/runtime': 7.29.7 + '@types/aria-query': 5.0.4 + aria-query: 5.3.0 + dom-accessibility-api: 0.5.16 + lz-string: 1.5.0 + picocolors: 1.1.1 + pretty-format: 27.5.1 + + '@testing-library/jest-dom@7.0.0(@testing-library/dom@10.4.1)': + dependencies: + '@adobe/css-tools': 4.5.0 + '@testing-library/dom': 10.4.1 + aria-query: 5.3.2 + css.escape: 1.5.1 + dom-accessibility-api: 0.6.3 + picocolors: 1.1.1 + redent: 3.0.0 + + '@testing-library/react@16.3.2(@testing-library/dom@10.4.1)(@types/react-dom@19.2.4(@types/react@19.2.18))(@types/react@19.2.18)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)': + dependencies: + '@babel/runtime': 7.29.7 + '@testing-library/dom': 10.4.1 + react: 19.2.8 + react-dom: 19.2.8(react@19.2.8) + optionalDependencies: + '@types/react': 19.2.18 + '@types/react-dom': 19.2.4(@types/react@19.2.18) + + '@tybys/wasm-util@0.10.3': + dependencies: + tslib: 2.8.1 + optional: true + + '@types/aria-query@5.0.4': {} + + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + + '@types/deep-eql@4.0.2': {} + + '@types/estree@1.0.9': {} + + '@types/json-schema@7.0.15': {} + + '@types/json5@0.0.29': {} + + '@types/node@24.13.3': + dependencies: + undici-types: 7.18.2 + + '@types/react-dom@19.2.4(@types/react@19.2.18)': + dependencies: + '@types/react': 19.2.18 + + '@types/react@19.2.18': + dependencies: + csstype: 3.2.3 + + '@typescript-eslint/eslint-plugin@8.66.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)': + dependencies: + '@eslint-community/regexpp': 4.12.2 + '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/scope-manager': 8.66.0 + '@typescript-eslint/type-utils': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/visitor-keys': 8.66.0 + eslint: 9.39.5(jiti@2.7.0) + ignore: 7.0.6 + natural-compare: 1.4.0 + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)': + dependencies: + '@typescript-eslint/scope-manager': 8.66.0 + '@typescript-eslint/types': 8.66.0 + '@typescript-eslint/typescript-estree': 8.66.0(typescript@5.9.3) + '@typescript-eslint/visitor-keys': 8.66.0 + debug: 4.4.3 + eslint: 9.39.5(jiti@2.7.0) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/project-service@8.66.0(typescript@5.9.3)': + dependencies: + '@typescript-eslint/tsconfig-utils': 8.66.0(typescript@5.9.3) + '@typescript-eslint/types': 8.66.0 + debug: 4.4.3 + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/scope-manager@8.66.0': + dependencies: + '@typescript-eslint/types': 8.66.0 + '@typescript-eslint/visitor-keys': 8.66.0 + + '@typescript-eslint/tsconfig-utils@8.66.0(typescript@5.9.3)': + dependencies: + typescript: 5.9.3 + + '@typescript-eslint/type-utils@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)': + dependencies: + '@typescript-eslint/types': 8.66.0 + '@typescript-eslint/typescript-estree': 8.66.0(typescript@5.9.3) + '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + debug: 4.4.3 + eslint: 9.39.5(jiti@2.7.0) + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/types@8.66.0': {} + + '@typescript-eslint/typescript-estree@8.66.0(typescript@5.9.3)': + dependencies: + '@typescript-eslint/project-service': 8.66.0(typescript@5.9.3) + '@typescript-eslint/tsconfig-utils': 8.66.0(typescript@5.9.3) + '@typescript-eslint/types': 8.66.0 + '@typescript-eslint/visitor-keys': 8.66.0 + debug: 4.4.3 + minimatch: 10.2.6 + semver: 7.8.5 + tinyglobby: 0.2.17 + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)': + dependencies: + '@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0)) + '@typescript-eslint/scope-manager': 8.66.0 + '@typescript-eslint/types': 8.66.0 + '@typescript-eslint/typescript-estree': 8.66.0(typescript@5.9.3) + eslint: 9.39.5(jiti@2.7.0) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/visitor-keys@8.66.0': + dependencies: + '@typescript-eslint/types': 8.66.0 + eslint-visitor-keys: 5.0.1 + + '@unrs/resolver-binding-android-arm-eabi@1.12.2': + optional: true + + '@unrs/resolver-binding-android-arm64@1.12.2': + optional: true + + '@unrs/resolver-binding-darwin-arm64@1.12.2': + optional: true + + '@unrs/resolver-binding-darwin-x64@1.12.2': + optional: true + + '@unrs/resolver-binding-freebsd-x64@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-arm-gnueabihf@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-arm-musleabihf@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-arm64-gnu@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-arm64-musl@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-loong64-gnu@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-loong64-musl@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-ppc64-gnu@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-riscv64-gnu@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-riscv64-musl@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-s390x-gnu@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-x64-gnu@1.12.2': + optional: true + + '@unrs/resolver-binding-linux-x64-musl@1.12.2': + optional: true + + '@unrs/resolver-binding-openharmony-arm64@1.12.2': + optional: true + + '@unrs/resolver-binding-wasm32-wasi@1.12.2': + dependencies: + '@emnapi/core': 1.10.0 + '@emnapi/runtime': 1.10.0 + '@napi-rs/wasm-runtime': 1.2.2(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + optional: true + + '@unrs/resolver-binding-win32-arm64-msvc@1.12.2': + optional: true + + '@unrs/resolver-binding-win32-ia32-msvc@1.12.2': + optional: true + + '@unrs/resolver-binding-win32-x64-msvc@1.12.2': + optional: true + + '@vitejs/plugin-react@6.0.5(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0))': + dependencies: + '@rolldown/pluginutils': 1.0.1 + vite: 8.2.1(@types/node@24.13.3)(jiti@2.7.0) + + '@vitest/expect@4.1.10': + dependencies: + '@standard-schema/spec': 1.1.0 + '@types/chai': 5.2.3 + '@vitest/spy': 4.1.10 + '@vitest/utils': 4.1.10 + chai: 6.2.2 + tinyrainbow: 3.1.1 + + '@vitest/mocker@4.1.10(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0))': + dependencies: + '@vitest/spy': 4.1.10 + estree-walker: 3.0.3 + magic-string: 0.30.21 + optionalDependencies: + vite: 8.2.1(@types/node@24.13.3)(jiti@2.7.0) + + '@vitest/pretty-format@4.1.10': + dependencies: + tinyrainbow: 3.1.1 + + '@vitest/runner@4.1.10': + dependencies: + '@vitest/utils': 4.1.10 + pathe: 2.0.3 + + '@vitest/snapshot@4.1.10': + dependencies: + '@vitest/pretty-format': 4.1.10 + '@vitest/utils': 4.1.10 + magic-string: 0.30.21 + pathe: 2.0.3 + + '@vitest/spy@4.1.10': {} + + '@vitest/utils@4.1.10': + dependencies: + '@vitest/pretty-format': 4.1.10 + convert-source-map: 2.0.0 + tinyrainbow: 3.1.1 + + acorn-jsx@5.3.2(acorn@8.18.0): + dependencies: + acorn: 8.18.0 + + acorn@8.18.0: {} + + ajv@6.15.0: + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + + ansi-regex@5.0.1: {} + + ansi-styles@4.3.0: + dependencies: + color-convert: 2.0.1 + + ansi-styles@5.2.0: {} + + argparse@2.0.1: {} + + aria-query@5.3.0: + dependencies: + dequal: 2.0.3 + + aria-query@5.3.2: {} + + array-buffer-byte-length@1.0.2: + dependencies: + call-bound: 1.0.4 + is-array-buffer: 3.0.5 + + array-includes@3.1.9: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-object-atoms: 1.1.2 + get-intrinsic: 1.3.0 + is-string: 1.1.1 + math-intrinsics: 1.1.0 + + array.prototype.findlast@1.2.5: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + es-shim-unscopables: 1.1.0 + + array.prototype.findlastindex@1.2.6: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + es-shim-unscopables: 1.1.0 + + array.prototype.flat@1.3.3: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-shim-unscopables: 1.1.0 + + array.prototype.flatmap@1.3.3: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-shim-unscopables: 1.1.0 + + array.prototype.tosorted@1.1.4: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-shim-unscopables: 1.1.0 + + arraybuffer.prototype.slice@1.0.4: + dependencies: + array-buffer-byte-length: 1.0.2 + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + is-array-buffer: 3.0.5 + + assertion-error@2.0.1: {} + + ast-types-flow@0.0.8: {} + + async-function@1.0.0: {} + + available-typed-arrays@1.0.7: + dependencies: + possible-typed-array-names: 1.1.0 + + axe-core@4.13.0: {} + + axobject-query@4.1.0: {} + + balanced-match@1.0.2: {} + + balanced-match@4.0.4: {} + + baseline-browser-mapping@2.11.12: {} + + bidi-js@1.0.3: + dependencies: + require-from-string: 2.0.2 + + brace-expansion@1.1.18: + dependencies: + balanced-match: 1.0.2 + concat-map: 0.0.1 + + brace-expansion@5.0.9: + dependencies: + balanced-match: 4.0.4 + + braces@3.0.3: + dependencies: + fill-range: 7.1.1 + + browserslist@4.28.7: + dependencies: + baseline-browser-mapping: 2.11.12 + caniuse-lite: 1.0.30001809 + electron-to-chromium: 1.5.402 + node-releases: 2.0.53 + update-browserslist-db: 1.3.0(browserslist@4.28.7) + + call-bind-apply-helpers@1.0.2: + dependencies: + es-errors: 1.3.0 + function-bind: 1.1.2 + + call-bind@1.0.9: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-define-property: 1.0.1 + get-intrinsic: 1.3.0 + set-function-length: 1.2.2 + + call-bound@1.0.4: + dependencies: + call-bind-apply-helpers: 1.0.2 + get-intrinsic: 1.3.0 + + callsites@3.1.0: {} + + caniuse-lite@1.0.30001809: {} + + chai@6.2.2: {} + + chalk@4.1.2: + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + + client-only@0.0.1: {} + + color-convert@2.0.1: + dependencies: + color-name: 1.1.4 + + color-name@1.1.4: {} + + concat-map@0.0.1: {} + + convert-source-map@2.0.0: {} + + cross-spawn@7.0.6: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + css-tree@3.2.1: + dependencies: + mdn-data: 2.27.1 + source-map-js: 1.2.1 + + css.escape@1.5.1: {} + + csstype@3.2.3: {} + + damerau-levenshtein@1.0.8: {} + + data-urls@7.0.0: + dependencies: + whatwg-mimetype: 5.0.0 + whatwg-url: 16.0.1 + transitivePeerDependencies: + - '@noble/hashes' + + data-view-buffer@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + + data-view-byte-length@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + + data-view-byte-offset@1.0.1: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + + debug@3.2.7: + dependencies: + ms: 2.1.3 + + debug@4.4.3: + dependencies: + ms: 2.1.3 + + decimal.js@10.6.0: {} + + deep-is@0.1.4: {} + + define-data-property@1.1.4: + dependencies: + es-define-property: 1.0.1 + es-errors: 1.3.0 + gopd: 1.2.0 + + define-properties@1.2.1: + dependencies: + define-data-property: 1.1.4 + has-property-descriptors: 1.0.2 + object-keys: 1.1.1 + + dequal@2.0.3: {} + + detect-libc@2.1.2: {} + + doctrine@2.1.0: + dependencies: + esutils: 2.0.3 + + dom-accessibility-api@0.5.16: {} + + dom-accessibility-api@0.6.3: {} + + dunder-proto@1.0.1: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-errors: 1.3.0 + gopd: 1.2.0 + + electron-to-chromium@1.5.402: {} + + emoji-regex@9.2.2: {} + + enhanced-resolve@5.24.5: + dependencies: + graceful-fs: 4.2.11 + tapable: 2.3.3 + + entities@8.0.0: {} + + es-abstract-get@1.0.0: + dependencies: + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + is-callable: 1.2.7 + object-inspect: 1.13.4 + + es-abstract@1.24.2: + dependencies: + array-buffer-byte-length: 1.0.2 + arraybuffer.prototype.slice: 1.0.4 + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + call-bound: 1.0.4 + data-view-buffer: 1.0.2 + data-view-byte-length: 1.0.2 + data-view-byte-offset: 1.0.1 + es-define-property: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + es-set-tostringtag: 2.1.0 + es-to-primitive: 1.3.4 + function.prototype.name: 1.2.0 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + get-symbol-description: 1.1.0 + globalthis: 1.0.4 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + has-proto: 1.2.0 + has-symbols: 1.1.0 + hasown: 2.0.4 + internal-slot: 1.1.0 + is-array-buffer: 3.0.5 + is-callable: 1.2.7 + is-data-view: 1.0.2 + is-negative-zero: 2.0.3 + is-regex: 1.2.1 + is-set: 2.0.3 + is-shared-array-buffer: 1.0.4 + is-string: 1.1.1 + is-typed-array: 1.1.15 + is-weakref: 1.1.1 + math-intrinsics: 1.1.0 + object-inspect: 1.13.4 + object-keys: 1.1.1 + object.assign: 4.1.7 + own-keys: 1.0.2 + regexp.prototype.flags: 1.5.4 + safe-array-concat: 1.1.4 + safe-push-apply: 1.0.0 + safe-regex-test: 1.1.0 + set-proto: 1.0.0 + stop-iteration-iterator: 1.1.0 + string.prototype.trim: 1.2.11 + string.prototype.trimend: 1.0.10 + string.prototype.trimstart: 1.0.8 + typed-array-buffer: 1.0.3 + typed-array-byte-length: 1.0.3 + typed-array-byte-offset: 1.0.4 + typed-array-length: 1.0.8 + unbox-primitive: 1.1.0 + which-typed-array: 1.1.22 + + es-define-property@1.0.1: {} + + es-errors@1.3.0: {} + + es-iterator-helpers@1.4.0: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-set-tostringtag: 2.1.0 + function-bind: 1.1.2 + get-intrinsic: 1.3.0 + globalthis: 1.0.4 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + has-proto: 1.2.0 + has-symbols: 1.1.0 + internal-slot: 1.1.0 + iterator.prototype: 1.1.5 + math-intrinsics: 1.1.0 + + es-module-lexer@2.3.1: {} + + es-object-atoms@1.1.2: + dependencies: + es-errors: 1.3.0 + + es-set-tostringtag@2.1.0: + dependencies: + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + has-tostringtag: 1.0.2 + hasown: 2.0.4 + + es-shim-unscopables@1.1.0: + dependencies: + hasown: 2.0.4 + + es-to-primitive@1.3.4: + dependencies: + es-abstract-get: 1.0.0 + es-define-property: 1.0.1 + es-errors: 1.3.0 + is-callable: 1.2.7 + is-date-object: 1.1.0 + is-symbol: 1.1.1 + + escalade@3.2.0: {} + + escape-string-regexp@4.0.0: {} + + eslint-config-next@16.3.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3): + dependencies: + '@next/eslint-plugin-next': 16.3.0(eslint@9.39.5(jiti@2.7.0)) + eslint: 9.39.5(jiti@2.7.0) + eslint-import-resolver-node: 0.3.10 + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)) + eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.5(jiti@2.7.0)) + eslint-plugin-react: 7.37.5(eslint@9.39.5(jiti@2.7.0)) + eslint-plugin-react-hooks: 7.1.1(eslint@9.39.5(jiti@2.7.0)) + globals: 16.4.0 + typescript-eslint: 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + optionalDependencies: + typescript: 5.9.3 + transitivePeerDependencies: + - '@typescript-eslint/parser' + - eslint-import-resolver-webpack + - eslint-plugin-import-x + - supports-color + + eslint-import-resolver-node@0.3.10: + dependencies: + debug: 3.2.7 + is-core-module: 2.16.2 + resolve: 2.0.0-next.7 + transitivePeerDependencies: + - supports-color + + eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)): + dependencies: + '@nolyfill/is-core-module': 1.0.39 + debug: 4.4.3 + eslint: 9.39.5(jiti@2.7.0) + get-tsconfig: 4.14.1 + is-bun-module: 2.0.0 + stable-hash: 0.0.5 + tinyglobby: 0.2.17 + unrs-resolver: 1.12.2 + optionalDependencies: + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)) + transitivePeerDependencies: + - supports-color + + eslint-module-utils@2.14.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-node@0.3.10)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)): + dependencies: + debug: 3.2.7 + optionalDependencies: + '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + eslint: 9.39.5(jiti@2.7.0) + eslint-import-resolver-node: 0.3.10 + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)) + transitivePeerDependencies: + - supports-color + + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)): + dependencies: + '@rtsao/scc': 1.1.0 + array-includes: 3.1.9 + array.prototype.findlastindex: 1.2.6 + array.prototype.flat: 1.3.3 + array.prototype.flatmap: 1.3.3 + debug: 3.2.7 + doctrine: 2.1.0 + eslint: 9.39.5(jiti@2.7.0) + eslint-import-resolver-node: 0.3.10 + eslint-module-utils: 2.14.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-node@0.3.10)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)) + hasown: 2.0.4 + is-core-module: 2.16.2 + is-glob: 4.0.3 + minimatch: 3.1.5 + object.fromentries: 2.0.8 + object.groupby: 1.0.3 + object.values: 1.2.1 + semver: 6.3.1 + string.prototype.trimend: 1.0.10 + tsconfig-paths: 3.15.0 + optionalDependencies: + '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + + eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.5(jiti@2.7.0)): + dependencies: + aria-query: 5.3.2 + array-includes: 3.1.9 + array.prototype.flatmap: 1.3.3 + ast-types-flow: 0.0.8 + axe-core: 4.13.0 + axobject-query: 4.1.0 + damerau-levenshtein: 1.0.8 + emoji-regex: 9.2.2 + eslint: 9.39.5(jiti@2.7.0) + hasown: 2.0.4 + jsx-ast-utils: 3.3.5 + language-tags: 1.0.9 + minimatch: 3.1.5 + object.fromentries: 2.0.8 + safe-regex-test: 1.1.0 + string.prototype.includes: 2.0.1 + + eslint-plugin-react-hooks@7.1.1(eslint@9.39.5(jiti@2.7.0)): + dependencies: + '@babel/core': 7.29.7 + '@babel/parser': 7.29.8 + eslint: 9.39.5(jiti@2.7.0) + hermes-parser: 0.25.1 + zod: 4.4.3 + zod-validation-error: 4.0.2(zod@4.4.3) + transitivePeerDependencies: + - supports-color + + eslint-plugin-react@7.37.5(eslint@9.39.5(jiti@2.7.0)): + dependencies: + array-includes: 3.1.9 + array.prototype.findlast: 1.2.5 + array.prototype.flatmap: 1.3.3 + array.prototype.tosorted: 1.1.4 + doctrine: 2.1.0 + es-iterator-helpers: 1.4.0 + eslint: 9.39.5(jiti@2.7.0) + estraverse: 5.3.0 + hasown: 2.0.4 + jsx-ast-utils: 3.3.5 + minimatch: 3.1.5 + object.entries: 1.1.9 + object.fromentries: 2.0.8 + object.values: 1.2.1 + prop-types: 15.8.1 + resolve: 2.0.0-next.7 + semver: 6.3.1 + string.prototype.matchall: 4.0.12 + string.prototype.repeat: 1.0.0 + + eslint-scope@8.4.0: + dependencies: + esrecurse: 4.3.0 + estraverse: 5.3.0 + + eslint-visitor-keys@3.4.3: {} + + eslint-visitor-keys@4.2.1: {} + + eslint-visitor-keys@5.0.1: {} + + eslint@9.39.5(jiti@2.7.0): + dependencies: + '@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0)) + '@eslint-community/regexpp': 4.12.2 + '@eslint/config-array': 0.21.2 + '@eslint/config-helpers': 0.4.2 + '@eslint/core': 0.17.0 + '@eslint/eslintrc': 3.3.6 + '@eslint/js': 9.39.5 + '@eslint/plugin-kit': 0.4.1 + '@humanfs/node': 0.16.8 + '@humanwhocodes/module-importer': 1.0.1 + '@humanwhocodes/retry': 0.4.3 + '@types/estree': 1.0.9 + ajv: 6.15.0 + chalk: 4.1.2 + cross-spawn: 7.0.6 + debug: 4.4.3 + escape-string-regexp: 4.0.0 + eslint-scope: 8.4.0 + eslint-visitor-keys: 4.2.1 + espree: 10.4.0 + esquery: 1.7.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 8.0.0 + find-up: 5.0.0 + glob-parent: 6.0.2 + ignore: 5.3.2 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + json-stable-stringify-without-jsonify: 1.0.1 + lodash.merge: 4.6.2 + minimatch: 3.1.5 + natural-compare: 1.4.0 + optionator: 0.9.4 + optionalDependencies: + jiti: 2.7.0 + transitivePeerDependencies: + - supports-color + + espree@10.4.0: + dependencies: + acorn: 8.18.0 + acorn-jsx: 5.3.2(acorn@8.18.0) + eslint-visitor-keys: 4.2.1 + + esquery@1.7.0: + dependencies: + estraverse: 5.3.0 + + esrecurse@4.3.0: + dependencies: + estraverse: 5.3.0 + + estraverse@5.3.0: {} + + estree-walker@3.0.3: + dependencies: + '@types/estree': 1.0.9 + + esutils@2.0.3: {} + + expect-type@1.4.0: {} + + fast-deep-equal@3.1.3: {} + + fast-glob@3.3.1: + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.8 + + fast-json-stable-stringify@2.1.0: {} + + fast-levenshtein@2.0.6: {} + + fastq@1.20.1: + dependencies: + reusify: 1.1.0 + + fdir@6.5.0(picomatch@4.0.5): + optionalDependencies: + picomatch: 4.0.5 + + file-entry-cache@8.0.0: + dependencies: + flat-cache: 4.0.1 + + fill-range@7.1.1: + dependencies: + to-regex-range: 5.0.1 + + find-up@5.0.0: + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 + + flat-cache@4.0.1: + dependencies: + flatted: 3.4.4 + keyv: 4.5.4 + + flatted@3.4.4: {} + + for-each@0.3.5: + dependencies: + is-callable: 1.2.7 + + fsevents@2.3.3: + optional: true + + function-bind@1.1.2: {} + + function.prototype.name@1.2.0: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + es-define-property: 1.0.1 + es-errors: 1.3.0 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.2 + hasown: 2.0.4 + is-callable: 1.2.7 + is-document.all: 1.0.0 + + functions-have-names@1.2.3: {} + + generator-function@2.0.1: {} + + gensync@1.0.0-beta.2: {} + + get-intrinsic@1.3.0: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-define-property: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + function-bind: 1.1.2 + get-proto: 1.0.1 + gopd: 1.2.0 + has-symbols: 1.1.0 + hasown: 2.0.4 + math-intrinsics: 1.1.0 + + get-proto@1.0.1: + dependencies: + dunder-proto: 1.0.1 + es-object-atoms: 1.1.2 + + get-symbol-description@1.1.0: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + + get-tsconfig@4.14.1: + dependencies: + resolve-pkg-maps: 1.0.0 + + glob-parent@5.1.2: + dependencies: + is-glob: 4.0.3 + + glob-parent@6.0.2: + dependencies: + is-glob: 4.0.3 + + globals@14.0.0: {} + + globals@16.4.0: {} + + globalthis@1.0.4: + dependencies: + define-properties: 1.2.1 + gopd: 1.2.0 + + gopd@1.2.0: {} + + graceful-fs@4.2.11: {} + + has-bigints@1.1.0: {} + + has-flag@4.0.0: {} + + has-property-descriptors@1.0.2: + dependencies: + es-define-property: 1.0.1 + + has-proto@1.2.0: + dependencies: + dunder-proto: 1.0.1 + + has-symbols@1.1.0: {} + + has-tostringtag@1.0.2: + dependencies: + has-symbols: 1.1.0 + + hasown@2.0.4: + dependencies: + function-bind: 1.1.2 + + hermes-estree@0.25.1: {} + + hermes-parser@0.25.1: + dependencies: + hermes-estree: 0.25.1 + + html-encoding-sniffer@6.0.0: + dependencies: + '@exodus/bytes': 1.15.1 + transitivePeerDependencies: + - '@noble/hashes' + + ignore@5.3.2: {} + + ignore@7.0.6: {} + + import-fresh@3.3.1: + dependencies: + parent-module: 1.0.1 + resolve-from: 4.0.0 + + imurmurhash@0.1.4: {} + + indent-string@4.0.0: {} + + internal-slot@1.1.0: + dependencies: + es-errors: 1.3.0 + hasown: 2.0.4 + side-channel: 1.1.1 + + is-array-buffer@3.0.5: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + + is-async-function@2.1.1: + dependencies: + async-function: 1.0.0 + call-bound: 1.0.4 + get-proto: 1.0.1 + has-tostringtag: 1.0.2 + safe-regex-test: 1.1.0 + + is-bigint@1.1.0: + dependencies: + has-bigints: 1.1.0 + + is-boolean-object@1.2.2: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-bun-module@2.0.0: + dependencies: + semver: 7.8.5 + + is-callable@1.2.7: {} + + is-core-module@2.16.2: + dependencies: + hasown: 2.0.4 + + is-data-view@1.0.2: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + is-typed-array: 1.1.15 + + is-date-object@1.1.0: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-document.all@1.0.0: + dependencies: + call-bound: 1.0.4 + + is-extglob@2.1.1: {} + + is-finalizationregistry@1.1.1: + dependencies: + call-bound: 1.0.4 + + is-generator-function@1.1.2: + dependencies: + call-bound: 1.0.4 + generator-function: 2.0.1 + get-proto: 1.0.1 + has-tostringtag: 1.0.2 + safe-regex-test: 1.1.0 + + is-glob@4.0.3: + dependencies: + is-extglob: 2.1.1 + + is-map@2.0.3: {} + + is-negative-zero@2.0.3: {} + + is-number-object@1.1.1: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-number@7.0.0: {} + + is-potential-custom-element-name@1.0.1: {} + + is-regex@1.2.1: + dependencies: + call-bound: 1.0.4 + gopd: 1.2.0 + has-tostringtag: 1.0.2 + hasown: 2.0.4 + + is-set@2.0.3: {} + + is-shared-array-buffer@1.0.4: + dependencies: + call-bound: 1.0.4 + + is-string@1.1.1: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-symbol@1.1.1: + dependencies: + call-bound: 1.0.4 + has-symbols: 1.1.0 + safe-regex-test: 1.1.0 + + is-typed-array@1.1.15: + dependencies: + which-typed-array: 1.1.22 + + is-weakmap@2.0.2: {} + + is-weakref@1.1.1: + dependencies: + call-bound: 1.0.4 + + is-weakset@2.0.4: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + + isarray@2.0.5: {} + + isexe@2.0.0: {} + + iterator.prototype@1.1.5: + dependencies: + define-data-property: 1.1.4 + es-object-atoms: 1.1.2 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + has-symbols: 1.1.0 + set-function-name: 2.0.2 + + jiti@2.7.0: {} + + js-tokens@4.0.0: {} + + js-yaml@4.3.1: + dependencies: + argparse: 2.0.1 + + jsdom@30.0.1: + dependencies: + '@asamuzakjp/css-color': 6.0.5 + '@asamuzakjp/dom-selector': 8.3.2 + '@bramus/specificity': 2.4.2 + '@csstools/css-syntax-patches-for-csstree': 1.1.7(css-tree@3.2.1) + '@exodus/bytes': 1.15.1 + css-tree: 3.2.1 + data-urls: 7.0.0 + decimal.js: 10.6.0 + html-encoding-sniffer: 6.0.0 + is-potential-custom-element-name: 1.0.1 + lru-cache: 11.5.2 + parse5: 8.0.1 + saxes: 6.0.0 + symbol-tree: 3.2.4 + tough-cookie: 6.0.2 + undici: 8.10.0 + w3c-xmlserializer: 5.0.0 + webidl-conversions: 8.0.1 + whatwg-mimetype: 5.0.0 + whatwg-url: 17.1.0 + xml-name-validator: 5.0.0 + transitivePeerDependencies: + - '@noble/hashes' + + jsesc@3.1.0: {} + + json-buffer@3.0.1: {} + + json-schema-traverse@0.4.1: {} + + json-stable-stringify-without-jsonify@1.0.1: {} + + json5@1.0.2: + dependencies: + minimist: 1.2.8 + + json5@2.2.3: {} + + jsx-ast-utils@3.3.5: + dependencies: + array-includes: 3.1.9 + array.prototype.flat: 1.3.3 + object.assign: 4.1.7 + object.values: 1.2.1 + + keyv@4.5.4: + dependencies: + json-buffer: 3.0.1 + + language-subtag-registry@0.3.23: {} + + language-tags@1.0.9: + dependencies: + language-subtag-registry: 0.3.23 + + levn@0.4.1: + dependencies: + prelude-ls: 1.2.1 + type-check: 0.4.0 + + lightningcss-android-arm64@1.32.0: + optional: true + + lightningcss-android-arm64@1.33.0: + optional: true + + lightningcss-darwin-arm64@1.32.0: + optional: true + + lightningcss-darwin-arm64@1.33.0: + optional: true + + lightningcss-darwin-x64@1.32.0: + optional: true + + lightningcss-darwin-x64@1.33.0: + optional: true + + lightningcss-freebsd-x64@1.32.0: + optional: true + + lightningcss-freebsd-x64@1.33.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.32.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + + lightningcss-linux-arm64-gnu@1.32.0: + optional: true + + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + + lightningcss-linux-arm64-musl@1.32.0: + optional: true + + lightningcss-linux-arm64-musl@1.33.0: + optional: true + + lightningcss-linux-x64-gnu@1.32.0: + optional: true + + lightningcss-linux-x64-gnu@1.33.0: + optional: true + + lightningcss-linux-x64-musl@1.32.0: + optional: true + + lightningcss-linux-x64-musl@1.33.0: + optional: true + + lightningcss-win32-arm64-msvc@1.32.0: + optional: true + + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + + lightningcss-win32-x64-msvc@1.32.0: + optional: true + + lightningcss-win32-x64-msvc@1.33.0: + optional: true + + lightningcss@1.32.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.32.0 + lightningcss-darwin-arm64: 1.32.0 + lightningcss-darwin-x64: 1.32.0 + lightningcss-freebsd-x64: 1.32.0 + lightningcss-linux-arm-gnueabihf: 1.32.0 + lightningcss-linux-arm64-gnu: 1.32.0 + lightningcss-linux-arm64-musl: 1.32.0 + lightningcss-linux-x64-gnu: 1.32.0 + lightningcss-linux-x64-musl: 1.32.0 + lightningcss-win32-arm64-msvc: 1.32.0 + lightningcss-win32-x64-msvc: 1.32.0 + + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.33.0 + lightningcss-darwin-arm64: 1.33.0 + lightningcss-darwin-x64: 1.33.0 + lightningcss-freebsd-x64: 1.33.0 + lightningcss-linux-arm-gnueabihf: 1.33.0 + lightningcss-linux-arm64-gnu: 1.33.0 + lightningcss-linux-arm64-musl: 1.33.0 + lightningcss-linux-x64-gnu: 1.33.0 + lightningcss-linux-x64-musl: 1.33.0 + lightningcss-win32-arm64-msvc: 1.33.0 + lightningcss-win32-x64-msvc: 1.33.0 + + locate-path@6.0.0: + dependencies: + p-locate: 5.0.0 + + lodash.merge@4.6.2: {} + + loose-envify@1.4.0: + dependencies: + js-tokens: 4.0.0 + + lru-cache@11.5.2: {} + + lru-cache@5.1.1: + dependencies: + yallist: 3.1.1 + + lz-string@1.5.0: {} + + magic-string@0.30.21: + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + + math-intrinsics@1.1.0: {} + + mdn-data@2.27.1: {} + + merge2@1.4.1: {} + + micromatch@4.0.8: + dependencies: + braces: 3.0.3 + picomatch: 2.3.2 + + min-indent@1.0.1: {} + + minimatch@10.2.6: + dependencies: + brace-expansion: 5.0.9 + + minimatch@3.1.5: + dependencies: + brace-expansion: 1.1.18 + + minimist@1.2.8: {} + + ms@2.1.3: {} + + nanoid@3.3.18: {} + + napi-postinstall@0.3.4: {} + + natural-compare@1.4.0: {} + + next@16.3.0(@babel/core@7.29.7)(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8): + dependencies: + '@next/env': 16.3.0 + '@swc/helpers': 0.5.15 + baseline-browser-mapping: 2.11.12 + caniuse-lite: 1.0.30001809 + postcss: 8.5.23 + react: 19.2.8 + react-dom: 19.2.8(react@19.2.8) + styled-jsx: 5.1.6(@babel/core@7.29.7)(react@19.2.8) + optionalDependencies: + '@next/swc-darwin-arm64': 16.3.0 + '@next/swc-darwin-x64': 16.3.0 + '@next/swc-linux-arm64-gnu': 16.3.0 + '@next/swc-linux-arm64-musl': 16.3.0 + '@next/swc-linux-x64-gnu': 16.3.0 + '@next/swc-linux-x64-musl': 16.3.0 + '@next/swc-win32-arm64-msvc': 16.3.0 + '@next/swc-win32-x64-msvc': 16.3.0 + sharp: 0.35.3(@types/node@24.13.3) + transitivePeerDependencies: + - '@babel/core' + - '@types/node' + - babel-plugin-macros + + node-exports-info@1.6.2: + dependencies: + array.prototype.flatmap: 1.3.3 + es-errors: 1.3.0 + object.entries: 1.1.9 + semver: 6.3.1 + + node-releases@2.0.53: {} + + object-assign@4.1.1: {} + + object-inspect@1.13.4: {} + + object-keys@1.1.1: {} + + object.assign@4.1.7: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + has-symbols: 1.1.0 + object-keys: 1.1.1 + + object.entries@1.1.9: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + object.fromentries@2.0.8: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-object-atoms: 1.1.2 + + object.groupby@1.0.3: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + + object.values@1.2.1: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + obug@2.1.4: {} + + optionator@0.9.4: + dependencies: + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.4.1 + prelude-ls: 1.2.1 + type-check: 0.4.0 + word-wrap: 1.2.5 + + own-keys@1.0.2: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + object-keys: 1.1.1 + safe-push-apply: 1.0.0 + + p-limit@3.1.0: + dependencies: + yocto-queue: 0.1.0 + + p-locate@5.0.0: + dependencies: + p-limit: 3.1.0 + + parent-module@1.0.1: + dependencies: + callsites: 3.1.0 + + parse5@8.0.1: + dependencies: + entities: 8.0.0 + + path-exists@4.0.0: {} + + path-key@3.1.1: {} + + path-parse@1.0.7: {} + + pathe@2.0.3: {} + + picocolors@1.1.1: {} + + picomatch@2.3.2: {} + + picomatch@4.0.5: {} + + possible-typed-array-names@1.1.0: {} + + postcss@8.5.23: + dependencies: + nanoid: 3.3.18 + picocolors: 1.1.1 + source-map-js: 1.2.1 + + postcss@8.5.26: + dependencies: + nanoid: 3.3.18 + picocolors: 1.1.1 + source-map-js: 1.2.1 + + prelude-ls@1.2.1: {} + + pretty-format@27.5.1: + dependencies: + ansi-regex: 5.0.1 + ansi-styles: 5.2.0 + react-is: 17.0.2 + + prop-types@15.8.1: + dependencies: + loose-envify: 1.4.0 + object-assign: 4.1.1 + react-is: 16.13.1 + + punycode@2.3.1: {} + + queue-microtask@1.2.3: {} + + react-dom@19.2.8(react@19.2.8): + dependencies: + react: 19.2.8 + scheduler: 0.27.0 + + react-is@16.13.1: {} + + react-is@17.0.2: {} + + react@19.2.8: {} + + redent@3.0.0: + dependencies: + indent-string: 4.0.0 + strip-indent: 3.0.0 + + reflect.getprototypeof@1.0.10: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + which-builtin-type: 1.2.1 + + regexp.prototype.flags@1.5.4: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-errors: 1.3.0 + get-proto: 1.0.1 + gopd: 1.2.0 + set-function-name: 2.0.2 + + require-from-string@2.0.2: {} + + resolve-from@4.0.0: {} + + resolve-pkg-maps@1.0.0: {} + + resolve@2.0.0-next.7: + dependencies: + es-errors: 1.3.0 + is-core-module: 2.16.2 + node-exports-info: 1.6.2 + object-keys: 1.1.1 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + + reusify@1.1.0: {} + + rolldown@1.2.3: + dependencies: + '@oxc-project/types': 0.143.0 + '@rolldown/pluginutils': 1.0.1 + optionalDependencies: + '@rolldown/binding-android-arm64': 1.2.3 + '@rolldown/binding-darwin-arm64': 1.2.3 + '@rolldown/binding-darwin-x64': 1.2.3 + '@rolldown/binding-freebsd-x64': 1.2.3 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.3 + '@rolldown/binding-linux-arm64-gnu': 1.2.3 + '@rolldown/binding-linux-arm64-musl': 1.2.3 + '@rolldown/binding-linux-ppc64-gnu': 1.2.3 + '@rolldown/binding-linux-s390x-gnu': 1.2.3 + '@rolldown/binding-linux-x64-gnu': 1.2.3 + '@rolldown/binding-linux-x64-musl': 1.2.3 + '@rolldown/binding-openharmony-arm64': 1.2.3 + '@rolldown/binding-win32-arm64-msvc': 1.2.3 + '@rolldown/binding-win32-x64-msvc': 1.2.3 + + run-parallel@1.2.0: + dependencies: + queue-microtask: 1.2.3 + + safe-array-concat@1.1.4: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + has-symbols: 1.1.0 + isarray: 2.0.5 + + safe-push-apply@1.0.0: + dependencies: + es-errors: 1.3.0 + isarray: 2.0.5 + + safe-regex-test@1.1.0: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-regex: 1.2.1 + + saxes@6.0.0: + dependencies: + xmlchars: 2.2.0 + + scheduler@0.27.0: {} + + semver@6.3.1: {} + + semver@7.8.5: {} + + server-only@0.0.1: {} + + set-function-length@1.2.2: + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + function-bind: 1.1.2 + get-intrinsic: 1.3.0 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + + set-function-name@2.0.2: + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.2 + + set-proto@1.0.0: + dependencies: + dunder-proto: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + + sharp@0.35.3(@types/node@24.13.3): + dependencies: + '@img/colour': 1.1.0 + detect-libc: 2.1.2 + semver: 7.8.5 + optionalDependencies: + '@img/sharp-darwin-arm64': 0.35.3 + '@img/sharp-darwin-x64': 0.35.3 + '@img/sharp-freebsd-wasm32': 0.35.3 + '@img/sharp-libvips-darwin-arm64': 1.3.2 + '@img/sharp-libvips-darwin-x64': 1.3.2 + '@img/sharp-libvips-linux-arm': 1.3.2 + '@img/sharp-libvips-linux-arm64': 1.3.2 + '@img/sharp-libvips-linux-ppc64': 1.3.2 + '@img/sharp-libvips-linux-riscv64': 1.3.2 + '@img/sharp-libvips-linux-s390x': 1.3.2 + '@img/sharp-libvips-linux-x64': 1.3.2 + '@img/sharp-libvips-linuxmusl-arm64': 1.3.2 + '@img/sharp-libvips-linuxmusl-x64': 1.3.2 + '@img/sharp-linux-arm': 0.35.3 + '@img/sharp-linux-arm64': 0.35.3 + '@img/sharp-linux-ppc64': 0.35.3 + '@img/sharp-linux-riscv64': 0.35.3 + '@img/sharp-linux-s390x': 0.35.3 + '@img/sharp-linux-x64': 0.35.3 + '@img/sharp-linuxmusl-arm64': 0.35.3 + '@img/sharp-linuxmusl-x64': 0.35.3 + '@img/sharp-webcontainers-wasm32': 0.35.3 + '@img/sharp-win32-arm64': 0.35.3 + '@img/sharp-win32-ia32': 0.35.3 + '@img/sharp-win32-x64': 0.35.3 + '@types/node': 24.13.3 + optional: true + + shebang-command@2.0.0: + dependencies: + shebang-regex: 3.0.0 + + shebang-regex@3.0.0: {} + + side-channel-list@1.0.1: + dependencies: + es-errors: 1.3.0 + object-inspect: 1.13.4 + + side-channel-map@1.0.1: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + object-inspect: 1.13.4 + + side-channel-weakmap@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + object-inspect: 1.13.4 + side-channel-map: 1.0.1 + + side-channel@1.1.1: + dependencies: + es-errors: 1.3.0 + object-inspect: 1.13.4 + side-channel-list: 1.0.1 + side-channel-map: 1.0.1 + side-channel-weakmap: 1.0.2 + + siginfo@2.0.0: {} + + source-map-js@1.2.1: {} + + stable-hash@0.0.5: {} + + stackback@0.0.2: {} + + std-env@4.2.0: {} + + stop-iteration-iterator@1.1.0: + dependencies: + es-errors: 1.3.0 + internal-slot: 1.1.0 + + string.prototype.includes@2.0.1: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + + string.prototype.matchall@4.0.12: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + get-intrinsic: 1.3.0 + gopd: 1.2.0 + has-symbols: 1.1.0 + internal-slot: 1.1.0 + regexp.prototype.flags: 1.5.4 + set-function-name: 2.0.2 + side-channel: 1.1.1 + + string.prototype.repeat@1.0.0: + dependencies: + define-properties: 1.2.1 + es-abstract: 1.24.2 + + string.prototype.trim@1.2.11: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-data-property: 1.1.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-object-atoms: 1.1.2 + has-property-descriptors: 1.0.2 + safe-regex-test: 1.1.0 + + string.prototype.trimend@1.0.10: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + string.prototype.trimstart@1.0.8: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + strip-bom@3.0.0: {} + + strip-indent@3.0.0: + dependencies: + min-indent: 1.0.1 + + strip-json-comments@3.1.1: {} + + styled-jsx@5.1.6(@babel/core@7.29.7)(react@19.2.8): + dependencies: + client-only: 0.0.1 + react: 19.2.8 + optionalDependencies: + '@babel/core': 7.29.7 + + supports-color@7.2.0: + dependencies: + has-flag: 4.0.0 + + supports-preserve-symlinks-flag@1.0.0: {} + + symbol-tree@3.2.4: {} + + tailwindcss@4.3.3: {} + + tapable@2.3.3: {} + + tinybench@2.9.0: {} + + tinyexec@1.3.0: {} + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.5) + picomatch: 4.0.5 + + tinyrainbow@3.1.1: {} + + tldts-core@7.4.10: {} + + tldts@7.4.10: + dependencies: + tldts-core: 7.4.10 + + to-regex-range@5.0.1: + dependencies: + is-number: 7.0.0 + + tough-cookie@6.0.2: + dependencies: + tldts: 7.4.10 + + tr46@6.0.0: + dependencies: + punycode: 2.3.1 + + ts-api-utils@2.5.0(typescript@5.9.3): + dependencies: + typescript: 5.9.3 + + tsconfig-paths@3.15.0: + dependencies: + '@types/json5': 0.0.29 + json5: 1.0.2 + minimist: 1.2.8 + strip-bom: 3.0.0 + + tslib@2.8.1: {} + + type-check@0.4.0: + dependencies: + prelude-ls: 1.2.1 + + typed-array-buffer@1.0.3: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-typed-array: 1.1.15 + + typed-array-byte-length@1.0.3: + dependencies: + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + has-proto: 1.2.0 + is-typed-array: 1.1.15 + + typed-array-byte-offset@1.0.4: + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + has-proto: 1.2.0 + is-typed-array: 1.1.15 + reflect.getprototypeof: 1.0.10 + + typed-array-length@1.0.8: + dependencies: + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + is-typed-array: 1.1.15 + possible-typed-array-names: 1.1.0 + reflect.getprototypeof: 1.0.10 + + typescript-eslint@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3): + dependencies: + '@typescript-eslint/eslint-plugin': 8.66.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.66.0(typescript@5.9.3) + '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + eslint: 9.39.5(jiti@2.7.0) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + typescript@5.9.3: {} + + unbox-primitive@1.1.0: + dependencies: + call-bound: 1.0.4 + has-bigints: 1.1.0 + has-symbols: 1.1.0 + which-boxed-primitive: 1.1.1 + + undici-types@7.18.2: {} + + undici@8.10.0: {} + + unrs-resolver@1.12.2: + dependencies: + napi-postinstall: 0.3.4 + optionalDependencies: + '@unrs/resolver-binding-android-arm-eabi': 1.12.2 + '@unrs/resolver-binding-android-arm64': 1.12.2 + '@unrs/resolver-binding-darwin-arm64': 1.12.2 + '@unrs/resolver-binding-darwin-x64': 1.12.2 + '@unrs/resolver-binding-freebsd-x64': 1.12.2 + '@unrs/resolver-binding-linux-arm-gnueabihf': 1.12.2 + '@unrs/resolver-binding-linux-arm-musleabihf': 1.12.2 + '@unrs/resolver-binding-linux-arm64-gnu': 1.12.2 + '@unrs/resolver-binding-linux-arm64-musl': 1.12.2 + '@unrs/resolver-binding-linux-loong64-gnu': 1.12.2 + '@unrs/resolver-binding-linux-loong64-musl': 1.12.2 + '@unrs/resolver-binding-linux-ppc64-gnu': 1.12.2 + '@unrs/resolver-binding-linux-riscv64-gnu': 1.12.2 + '@unrs/resolver-binding-linux-riscv64-musl': 1.12.2 + '@unrs/resolver-binding-linux-s390x-gnu': 1.12.2 + '@unrs/resolver-binding-linux-x64-gnu': 1.12.2 + '@unrs/resolver-binding-linux-x64-musl': 1.12.2 + '@unrs/resolver-binding-openharmony-arm64': 1.12.2 + '@unrs/resolver-binding-wasm32-wasi': 1.12.2 + '@unrs/resolver-binding-win32-arm64-msvc': 1.12.2 + '@unrs/resolver-binding-win32-ia32-msvc': 1.12.2 + '@unrs/resolver-binding-win32-x64-msvc': 1.12.2 + + update-browserslist-db@1.3.0(browserslist@4.28.7): + dependencies: + browserslist: 4.28.7 + escalade: 3.2.0 + picocolors: 1.1.1 + + uri-js@4.4.1: + dependencies: + punycode: 2.3.1 + + vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0): + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.5 + postcss: 8.5.26 + rolldown: 1.2.3 + tinyglobby: 0.2.17 + optionalDependencies: + '@types/node': 24.13.3 + fsevents: 2.3.3 + jiti: 2.7.0 + + vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1)(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0)): + dependencies: + '@vitest/expect': 4.1.10 + '@vitest/mocker': 4.1.10(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0)) + '@vitest/pretty-format': 4.1.10 + '@vitest/runner': 4.1.10 + '@vitest/snapshot': 4.1.10 + '@vitest/spy': 4.1.10 + '@vitest/utils': 4.1.10 + es-module-lexer: 2.3.1 + expect-type: 1.4.0 + magic-string: 0.30.21 + obug: 2.1.4 + pathe: 2.0.3 + picomatch: 4.0.5 + std-env: 4.2.0 + tinybench: 2.9.0 + tinyexec: 1.3.0 + tinyglobby: 0.2.17 + tinyrainbow: 3.1.1 + vite: 8.2.1(@types/node@24.13.3)(jiti@2.7.0) + why-is-node-running: 2.3.0 + optionalDependencies: + '@types/node': 24.13.3 + jsdom: 30.0.1 + transitivePeerDependencies: + - msw + + w3c-xmlserializer@5.0.0: + dependencies: + xml-name-validator: 5.0.0 + + webidl-conversions@8.0.1: {} + + whatwg-mimetype@5.0.0: {} + + whatwg-url@16.0.1: + dependencies: + '@exodus/bytes': 1.15.1 + tr46: 6.0.0 + webidl-conversions: 8.0.1 + transitivePeerDependencies: + - '@noble/hashes' + + whatwg-url@17.1.0: + dependencies: + '@exodus/bytes': 1.15.1 + tr46: 6.0.0 + webidl-conversions: 8.0.1 + transitivePeerDependencies: + - '@noble/hashes' + + which-boxed-primitive@1.1.1: + dependencies: + is-bigint: 1.1.0 + is-boolean-object: 1.2.2 + is-number-object: 1.1.1 + is-string: 1.1.1 + is-symbol: 1.1.1 + + which-builtin-type@1.2.1: + dependencies: + call-bound: 1.0.4 + function.prototype.name: 1.2.0 + has-tostringtag: 1.0.2 + is-async-function: 2.1.1 + is-date-object: 1.1.0 + is-finalizationregistry: 1.1.1 + is-generator-function: 1.1.2 + is-regex: 1.2.1 + is-weakref: 1.1.1 + isarray: 2.0.5 + which-boxed-primitive: 1.1.1 + which-collection: 1.0.2 + which-typed-array: 1.1.22 + + which-collection@1.0.2: + dependencies: + is-map: 2.0.3 + is-set: 2.0.3 + is-weakmap: 2.0.2 + is-weakset: 2.0.4 + + which-typed-array@1.1.22: + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + call-bound: 1.0.4 + for-each: 0.3.5 + get-proto: 1.0.1 + gopd: 1.2.0 + has-tostringtag: 1.0.2 + + which@2.0.2: + dependencies: + isexe: 2.0.0 + + why-is-node-running@2.3.0: + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 + + word-wrap@1.2.5: {} + + xml-name-validator@5.0.0: {} + + xmlchars@2.2.0: {} + + yallist@3.1.1: {} + + yocto-queue@0.1.0: {} + + zod-validation-error@4.0.2(zod@4.4.3): + dependencies: + zod: 4.4.3 + + zod@4.4.3: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..6c750ff --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +allowBuilds: + unrs-resolver: true diff --git a/postcss.config.mjs b/postcss.config.mjs new file mode 100644 index 0000000..999cd7b --- /dev/null +++ b/postcss.config.mjs @@ -0,0 +1,7 @@ +const postcssConfig = { + plugins: { + "@tailwindcss/postcss": {}, + }, +}; + +export default postcssConfig; diff --git a/src/app/api/health/live/route.test.ts b/src/app/api/health/live/route.test.ts new file mode 100644 index 0000000..82c8fba --- /dev/null +++ b/src/app/api/health/live/route.test.ts @@ -0,0 +1,9 @@ +import { expect, test } from "vitest"; +import { GET } from "./route"; + +test("returns a process liveness response", async () => { + const response = await GET(); + + expect(response.status).toBe(200); + await expect(response.json()).resolves.toEqual({ status: "ok" }); +}); diff --git a/src/app/api/health/live/route.ts b/src/app/api/health/live/route.ts new file mode 100644 index 0000000..02b3d5f --- /dev/null +++ b/src/app/api/health/live/route.ts @@ -0,0 +1,3 @@ +export async function GET(): Promise { + return Response.json({ status: "ok" }); +} diff --git a/src/app/globals.css b/src/app/globals.css new file mode 100644 index 0000000..2c0ebc3 --- /dev/null +++ b/src/app/globals.css @@ -0,0 +1,140 @@ +@import "tailwindcss"; + +:root { + --paper: #ffffff; + --ink: #0a0a0a; + --muted: #5f5f5f; + --line: #d8d8d8; + --soft: #f3f3f3; + color-scheme: light; +} + +* { + box-sizing: border-box; +} + +html { + background: var(--paper); +} + +body { + min-height: 100vh; + margin: 0; + background: var(--paper); + color: var(--ink); + font-family: Inter, "Helvetica Neue", Arial, sans-serif; + font-synthesis: none; +} + +a { + color: inherit; +} + +:focus-visible { + outline: 3px solid var(--ink); + outline-offset: 4px; +} + +.landing { + display: grid; + min-height: 100vh; + grid-template-rows: auto 1fr auto; + padding: clamp(1.25rem, 3vw, 2.75rem); +} + +.masthead { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 2rem; + padding-bottom: 1rem; + border-bottom: 1px solid var(--line); +} + +.wordmark { + font-size: 0.8125rem; + font-weight: 700; + letter-spacing: -0.01em; + text-transform: uppercase; +} + +.section-label, +.eyebrow, +.landing-footer { + color: var(--muted); + font-size: 0.75rem; + letter-spacing: 0.09em; + text-transform: uppercase; +} + +.intro { + display: grid; + align-content: center; + max-width: 70rem; + padding-block: clamp(5rem, 14vh, 10rem); +} + +.eyebrow { + margin: 0 0 1.5rem; +} + +.intro h1 { + max-width: 12ch; + margin: 0; + font-size: clamp(3rem, 9vw, 8.5rem); + font-weight: 600; + letter-spacing: -0.065em; + line-height: 0.88; +} + +.lede { + max-width: 37rem; + margin: clamp(2rem, 5vw, 4rem) 0 0; + font-size: clamp(1rem, 1.6vw, 1.25rem); + line-height: 1.55; +} + +.primary-action { + width: fit-content; + margin-top: 2.25rem; + padding: 0.9rem 1.25rem; + border: 1px solid var(--ink); + background: var(--ink); + color: var(--paper); + font-size: 0.875rem; + font-weight: 650; + text-decoration: none; + transition: background-color 140ms ease, color 140ms ease; +} + +.primary-action:hover { + background: var(--paper); + color: var(--ink); +} + +.landing-footer { + padding-top: 1rem; + border-top: 1px solid var(--line); +} + +.landing-footer p { + margin: 0; +} + +@media (max-width: 40rem) { + .masthead { + align-items: flex-start; + flex-direction: column; + gap: 0.5rem; + } + + .intro h1 { + letter-spacing: -0.055em; + } +} + +@media (prefers-reduced-motion: reduce) { + .primary-action { + transition: none; + } +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx new file mode 100644 index 0000000..b76a743 --- /dev/null +++ b/src/app/layout.tsx @@ -0,0 +1,16 @@ +import type { Metadata } from "next"; +import type { ReactNode } from "react"; +import "./globals.css"; + +export const metadata: Metadata = { + title: "Redaktionsportal | Leon Tonhäuser", + description: "Ausgewählte Pressefotos sicher finden und nutzen.", +}; + +export default function RootLayout({ children }: Readonly<{ children: ReactNode }>) { + return ( + + {children} + + ); +} diff --git a/src/app/page.tsx b/src/app/page.tsx new file mode 100644 index 0000000..3145025 --- /dev/null +++ b/src/app/page.tsx @@ -0,0 +1,26 @@ +export default function HomePage() { + return ( +
+
+ Leon Tonhäuser + Redaktionsportal +
+ +
+

Pressefotografie

+

Bilder für Ihre Redaktion.

+

+ Freigegebene Fotoalben durchsuchen, Nutzungen dokumentieren und + Originaldateien herunterladen. +

+ + Zum Portal + +
+ +
+

Der geschützte Zugang wird im nächsten Schritt eingerichtet.

+
+
+ ); +} diff --git a/src/config/env.test.ts b/src/config/env.test.ts new file mode 100644 index 0000000..5d919e6 --- /dev/null +++ b/src/config/env.test.ts @@ -0,0 +1,10 @@ +import { describe, expect, test } from "vitest"; +import { parseServerEnv } from "./env"; + +describe("parseServerEnv", () => { + test("rejects a missing Immich API key", () => { + expect(() => parseServerEnv({ DATABASE_URL: "postgres://db/app" })).toThrow( + /IMMICH_API_KEY/, + ); + }); +}); diff --git a/src/config/env.ts b/src/config/env.ts new file mode 100644 index 0000000..b38502e --- /dev/null +++ b/src/config/env.ts @@ -0,0 +1,33 @@ +import "server-only"; + +import { z } from "zod"; + +const serverEnvSchema = z.object({ + DATABASE_URL: z.url(), + BETTER_AUTH_SECRET: z.string().min(32), + BETTER_AUTH_URL: z.url(), + IMMICH_BASE_URL: z.url(), + IMMICH_API_KEY: z.string().min(1), + SMTP_HOST: z.string().min(1), + SMTP_PORT: z.coerce.number().int().min(1).max(65_535), + SMTP_USER: z.string().min(1), + SMTP_PASSWORD: z.string().min(1), + SMTP_FROM: z.string().min(1), + LEGAL_IMPRINT_URL: z.url(), + LEGAL_PRIVACY_URL: z.url(), + LEGAL_TERMS_URL: z.url(), +}); + +export type ServerEnv = z.infer; + +export function parseServerEnv(input: NodeJS.ProcessEnv): ServerEnv; +export function parseServerEnv( + input: Record, +): ServerEnv; +export function parseServerEnv( + input: NodeJS.ProcessEnv | Record, +): ServerEnv { + return serverEnvSchema.parse(input); +} + +export const env = parseServerEnv(process.env); diff --git a/src/test/server-only.ts b/src/test/server-only.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/test/server-only.ts @@ -0,0 +1 @@ +export {}; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ea6d6f6 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,41 @@ +{ + "compilerOptions": { + "target": "ES2022", + "lib": [ + "dom", + "dom.iterable", + "es2022" + ], + "allowJs": false, + "skipLibCheck": true, + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "react-jsx", + "incremental": true, + "plugins": [ + { + "name": "next" + } + ], + "paths": { + "@/*": [ + "./src/*" + ] + } + }, + "include": [ + "next-env.d.ts", + ".next/types/**/*.ts", + "**/*.ts", + "**/*.tsx", + ".next/dev/types/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..f7bd1bb --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,32 @@ +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { defineConfig } from "vitest/config"; + +const rootDirectory = path.dirname(fileURLToPath(import.meta.url)); + +export default defineConfig({ + resolve: { + alias: { + "server-only": path.join(rootDirectory, "src/test/server-only.ts"), + }, + }, + test: { + environment: "node", + env: { + DATABASE_URL: "postgres://db/portal", + BETTER_AUTH_SECRET: "test-secret-at-least-thirty-two-characters", + BETTER_AUTH_URL: "http://localhost:3000", + IMMICH_BASE_URL: "http://immich:2283", + IMMICH_API_KEY: "test-immich-key", + SMTP_HOST: "smtp.example.com", + SMTP_PORT: "587", + SMTP_USER: "portal@example.com", + SMTP_PASSWORD: "test-smtp-password", + SMTP_FROM: "portal@example.com", + LEGAL_IMPRINT_URL: "https://example.com/impressum", + LEGAL_PRIVACY_URL: "https://example.com/datenschutz", + LEGAL_TERMS_URL: "https://example.com/nutzungsbedingungen", + }, + include: ["src/**/*.test.ts", "src/**/*.test.tsx"], + }, +}); From 7acaacb92eec468f850119682b610a82d0a997b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 20:26:18 +0200 Subject: [PATCH 02/29] feat: add portal database schema --- drizzle.config.ts | 10 + drizzle/0000_initial.sql | 201 +++ drizzle/meta/0000_snapshot.json | 1443 +++++++++++++++++++ drizzle/meta/_journal.json | 13 + package.json | 6 + pnpm-lock.yaml | 2389 +++++++++++++++++++++++++++++-- src/db/client.ts | 10 + src/db/schema/albums.ts | 24 + src/db/schema/audit.ts | 16 + src/db/schema/auth.ts | 55 + src/db/schema/billing.ts | 91 ++ src/db/schema/editorials.ts | 78 + src/db/schema/index.ts | 6 + src/db/schema/usages.ts | 63 + tests/db/postgres.ts | 97 ++ tests/db/schema.test.ts | 16 + vitest.config.ts | 3 +- 17 files changed, 4410 insertions(+), 111 deletions(-) create mode 100644 drizzle.config.ts create mode 100644 drizzle/0000_initial.sql create mode 100644 drizzle/meta/0000_snapshot.json create mode 100644 drizzle/meta/_journal.json create mode 100644 src/db/client.ts create mode 100644 src/db/schema/albums.ts create mode 100644 src/db/schema/audit.ts create mode 100644 src/db/schema/auth.ts create mode 100644 src/db/schema/billing.ts create mode 100644 src/db/schema/editorials.ts create mode 100644 src/db/schema/index.ts create mode 100644 src/db/schema/usages.ts create mode 100644 tests/db/postgres.ts create mode 100644 tests/db/schema.test.ts diff --git a/drizzle.config.ts b/drizzle.config.ts new file mode 100644 index 0000000..843123f --- /dev/null +++ b/drizzle.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "drizzle-kit"; + +export default defineConfig({ + dialect: "postgresql", + schema: "./src/db/schema/index.ts", + out: "./drizzle", + dbCredentials: { + url: process.env.DATABASE_URL ?? "postgresql://portal:portal@localhost:5432/portal", + }, +}); diff --git a/drizzle/0000_initial.sql b/drizzle/0000_initial.sql new file mode 100644 index 0000000..e84de6a --- /dev/null +++ b/drizzle/0000_initial.sql @@ -0,0 +1,201 @@ +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');--> 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 +); +--> 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 "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, + "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 "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, + "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, + "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, + "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 "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 +); +--> 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 +); +--> 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 "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 "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 "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 "download_events_editorial_idempotency_key_unique" ON "download_events" USING btree ("editorial_account_id","idempotency_key"); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..fefb1a2 --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,1443 @@ +{ + "id": "64eb37ed-2ab5-4c12-a8be-4375e8f6a732", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.album_grants": { + "name": "album_grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "granted_by_user_id": { + "name": "granted_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "album_grants_editorial_account_id_idx": { + "name": "album_grants_editorial_account_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_immich_album_id_idx": { + "name": "album_grants_immich_album_id_idx", + "columns": [ + { + "expression": "immich_album_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "album_grants_editorial_account_id_editorial_accounts_id_fk": { + "name": "album_grants_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "album_grants", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "album_grants_granted_by_user_id_user_id_fk": { + "name": "album_grants_granted_by_user_id_user_id_fk", + "tableFrom": "album_grants", + "tableTo": "user", + "columnsFrom": [ + "granted_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_events": { + "name": "audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "previous_values": { + "name": "previous_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_values": { + "name": "new_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "audit_events_actor_user_id_user_id_fk": { + "name": "audit_events_actor_user_id_user_id_fk", + "tableFrom": "audit_events", + "tableTo": "user", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "portal_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'EDITORIAL'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_report_items": { + "name": "billing_report_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id_snapshot": { + "name": "immich_asset_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose_snapshot": { + "name": "purpose_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference_snapshot": { + "name": "internal_reference_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "billing_report_items_report_usage_unique": { + "name": "billing_report_items_report_usage_unique", + "columns": [ + { + "expression": "billing_report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "usage_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_report_items_billing_report_id_billing_reports_id_fk": { + "name": "billing_report_items_billing_report_id_billing_reports_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_report_items_usage_id_usages_id_fk": { + "name": "billing_report_items_usage_id_usages_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_reports": { + "name": "billing_reports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "report_number": { + "name": "report_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "period_starts_at": { + "name": "period_starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "period_ends_at": { + "name": "period_ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "billing_address_snapshot": { + "name": "billing_address_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "net_total_cents": { + "name": "net_total_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "report_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "pdf": { + "name": "pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "pdf_sha256": { + "name": "pdf_sha256", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finalized_at": { + "name": "finalized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_by_user_id": { + "name": "cancelled_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "billing_reports_report_number_unique": { + "name": "billing_reports_report_number_unique", + "columns": [ + { + "expression": "report_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "billing_reports_invoice_number_unique": { + "name": "billing_reports_invoice_number_unique", + "columns": [ + { + "expression": "invoice_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_reports_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_reports_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_reports", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_created_by_user_id_user_id_fk": { + "name": "billing_reports_created_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_cancelled_by_user_id_user_id_fk": { + "name": "billing_reports_cancelled_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "cancelled_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "billing_reports_pdf_sha256_hex_check": { + "name": "billing_reports_pdf_sha256_hex_check", + "value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'" + }, + "billing_reports_final_pdf_check": { + "name": "billing_reports_final_pdf_check", + "value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.billing_address_versions": { + "name": "billing_address_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_1": { + "name": "address_line_1", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_2": { + "name": "address_line_2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "superseded_by_id": { + "name": "superseded_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "billing_address_versions_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_address_versions_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_superseded_by_id_billing_address_versions_id_fk": { + "name": "billing_address_versions_superseded_by_id_billing_address_versions_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "superseded_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_created_by_user_id_user_id_fk": { + "name": "billing_address_versions_created_by_user_id_user_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.editorial_accounts": { + "name": "editorial_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "login_email": { + "name": "login_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "account_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending_email'" + }, + "current_price_cents": { + "name": "current_price_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "current_billing_address_version_id": { + "name": "current_billing_address_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_version": { + "name": "accepted_terms_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_at": { + "name": "accepted_terms_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "privacy_acknowledged_at": { + "name": "privacy_acknowledged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "editorial_accounts_user_id_user_id_fk": { + "name": "editorial_accounts_user_id_user_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk": { + "name": "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "current_billing_address_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "editorial_accounts_user_id_unique": { + "name": "editorial_accounts_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + }, + "editorial_accounts_login_email_unique": { + "name": "editorial_accounts_login_email_unique", + "nullsNotDistinct": false, + "columns": [ + "login_email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.download_events": { + "name": "download_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authorized_at": { + "name": "authorized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "download_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'authorized'" + }, + "transferred_bytes": { + "name": "transferred_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "repeat_download_note": { + "name": "repeat_download_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "download_events_editorial_idempotency_key_unique": { + "name": "download_events_editorial_idempotency_key_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "download_events_editorial_account_id_editorial_accounts_id_fk": { + "name": "download_events_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "download_events", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "download_events_usage_id_usages_id_fk": { + "name": "download_events_usage_id_usages_id_fk", + "tableFrom": "download_events", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.usages": { + "name": "usages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "immich_album_id_snapshot": { + "name": "immich_album_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference": { + "name": "internal_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "billing_status": { + "name": "billing_status", + "type": "usage_billing_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "usages_editorial_account_id_editorial_accounts_id_fk": { + "name": "usages_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "usages", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "usages_billing_report_id_billing_reports_id_fk": { + "name": "usages_billing_report_id_billing_reports_id_fk", + "tableFrom": "usages", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.portal_role": { + "name": "portal_role", + "schema": "public", + "values": [ + "ADMIN", + "EDITORIAL" + ] + }, + "public.report_status": { + "name": "report_status", + "schema": "public", + "values": [ + "draft", + "final", + "cancelled" + ] + }, + "public.account_status": { + "name": "account_status", + "schema": "public", + "values": [ + "pending_email", + "pending_approval", + "active", + "suspended", + "rejected" + ] + }, + "public.download_status": { + "name": "download_status", + "schema": "public", + "values": [ + "authorized", + "streaming", + "completed", + "failed_before_delivery", + "interrupted" + ] + }, + "public.usage_billing_status": { + "name": "usage_billing_status", + "schema": "public", + "values": [ + "open", + "billed", + "reopened" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..1819924 --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1786299825190, + "tag": "0000_initial", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 964f3e1..1216348 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "test:e2e": "playwright test" }, "dependencies": { + "drizzle-orm": "^0.45.2", "next": "^16.3.0", + "pg": "^8.22.0", "react": "^19.2.8", "react-dom": "^19.2.8", "server-only": "^0.0.1", @@ -24,16 +26,20 @@ }, "devDependencies": { "@tailwindcss/postcss": "^4.3.3", + "@testcontainers/postgresql": "^12.1.0", "@testing-library/jest-dom": "^7.0.0", "@testing-library/react": "^16.3.2", "@types/node": "^24.13.3", + "@types/pg": "^8.21.0", "@types/react": "^19.2.18", "@types/react-dom": "^19.2.4", "@vitejs/plugin-react": "^6.0.5", + "drizzle-kit": "^0.31.10", "eslint": "^9.39.5", "eslint-config-next": "^16.3.0", "jsdom": "^30.0.1", "tailwindcss": "^4.3.3", + "testcontainers": "^12.1.0", "typescript": "^5.9.3", "vitest": "^4.1.10" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02bbc47..25e8b18 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,15 @@ importers: .: dependencies: + drizzle-orm: + specifier: ^0.45.2 + version: 0.45.2(@types/pg@8.21.0)(pg@8.22.0) next: specifier: ^16.3.0 - version: 16.3.0(@babel/core@7.29.7)(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8) + version: 16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8) + pg: + specifier: ^8.22.0 + version: 8.22.0 react: specifier: ^19.2.8 version: 19.2.8 @@ -27,6 +33,9 @@ importers: '@tailwindcss/postcss': specifier: ^4.3.3 version: 4.3.3 + '@testcontainers/postgresql': + specifier: ^12.1.0 + version: 12.1.0(supports-color@7.2.0) '@testing-library/jest-dom': specifier: ^7.0.0 version: 7.0.0(@testing-library/dom@10.4.1) @@ -36,6 +45,9 @@ importers: '@types/node': specifier: ^24.13.3 version: 24.13.3 + '@types/pg': + specifier: ^8.21.0 + version: 8.21.0 '@types/react': specifier: ^19.2.18 version: 19.2.18 @@ -44,25 +56,31 @@ importers: version: 19.2.4(@types/react@19.2.18) '@vitejs/plugin-react': specifier: ^6.0.5 - version: 6.0.5(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0)) + version: 6.0.5(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) + drizzle-kit: + specifier: ^0.31.10 + version: 0.31.10 eslint: specifier: ^9.39.5 - version: 9.39.5(jiti@2.7.0) + version: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) eslint-config-next: specifier: ^16.3.0 - version: 16.3.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + version: 16.3.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) jsdom: specifier: ^30.0.1 version: 30.0.1 tailwindcss: specifier: ^4.3.3 version: 4.3.3 + testcontainers: + specifier: ^12.1.0 + version: 12.1.0(supports-color@7.2.0) typescript: specifier: ^5.9.3 version: 5.9.3 vitest: specifier: ^4.1.10 - version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1)(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0)) + version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1)(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) packages: @@ -152,6 +170,9 @@ packages: resolution: {integrity: sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==} engines: {node: '>=6.9.0'} + '@balena/dockerignore@1.0.2': + resolution: {integrity: sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==} + '@bramus/specificity@2.4.2': resolution: {integrity: sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==} hasBin: true @@ -192,6 +213,9 @@ packages: resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==} engines: {node: '>=20.19.0'} + '@drizzle-team/brocli@0.10.2': + resolution: {integrity: sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w==} + '@emnapi/core@1.10.0': resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==} @@ -204,6 +228,458 @@ packages: '@emnapi/wasi-threads@1.2.1': resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==} + '@esbuild-kit/core-utils@3.3.2': + resolution: {integrity: sha512-sPRAnw9CdSsRmEtnsl2WXWdyquogVpB3yZ3dgwJfe8zrOzTsV7cJvmwrKVa+0ma5BoiGJ+BoqkMvawbayKUsqQ==} + deprecated: 'Merged into tsx: https://tsx.hirok.io' + + '@esbuild-kit/esm-loader@2.6.5': + resolution: {integrity: sha512-FxEMIkJKnodyA1OaCUoEvbYRkoZlLZ4d/eXFu9Fh8CbBBgP5EmZxrfTRyN0qpXZ4vOvqnE5YdRdcrmUUXuU+dA==} + deprecated: 'Merged into tsx: https://tsx.hirok.io' + + '@esbuild/aix-ppc64@0.25.12': + resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/aix-ppc64@0.28.1': + resolution: {integrity: sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.18.20': + resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm64@0.25.12': + resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm64@0.28.1': + resolution: {integrity: sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.18.20': + resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + + '@esbuild/android-arm@0.25.12': + resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-arm@0.28.1': + resolution: {integrity: sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.18.20': + resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + + '@esbuild/android-x64@0.25.12': + resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/android-x64@0.28.1': + resolution: {integrity: sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.18.20': + resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-arm64@0.25.12': + resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-arm64@0.28.1': + resolution: {integrity: sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.18.20': + resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + + '@esbuild/darwin-x64@0.25.12': + resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/darwin-x64@0.28.1': + resolution: {integrity: sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.18.20': + resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-arm64@0.25.12': + resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-arm64@0.28.1': + resolution: {integrity: sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.18.20': + resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.25.12': + resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.28.1': + resolution: {integrity: sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.18.20': + resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm64@0.25.12': + resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm64@0.28.1': + resolution: {integrity: sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.18.20': + resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-arm@0.25.12': + resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-arm@0.28.1': + resolution: {integrity: sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.18.20': + resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-ia32@0.25.12': + resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-ia32@0.28.1': + resolution: {integrity: sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.18.20': + resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-loong64@0.25.12': + resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-loong64@0.28.1': + resolution: {integrity: sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.18.20': + resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-mips64el@0.25.12': + resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-mips64el@0.28.1': + resolution: {integrity: sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.18.20': + resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-ppc64@0.25.12': + resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-ppc64@0.28.1': + resolution: {integrity: sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.18.20': + resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-riscv64@0.25.12': + resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-riscv64@0.28.1': + resolution: {integrity: sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.18.20': + resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-s390x@0.25.12': + resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-s390x@0.28.1': + resolution: {integrity: sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.18.20': + resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + + '@esbuild/linux-x64@0.25.12': + resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/linux-x64@0.28.1': + resolution: {integrity: sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.25.12': + resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-arm64@0.28.1': + resolution: {integrity: sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.18.20': + resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.25.12': + resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.28.1': + resolution: {integrity: sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.25.12': + resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-arm64@0.28.1': + resolution: {integrity: sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.18.20': + resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.25.12': + resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.28.1': + resolution: {integrity: sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openharmony-arm64@0.25.12': + resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/openharmony-arm64@0.28.1': + resolution: {integrity: sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.18.20': + resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + + '@esbuild/sunos-x64@0.25.12': + resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/sunos-x64@0.28.1': + resolution: {integrity: sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.18.20': + resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-arm64@0.25.12': + resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-arm64@0.28.1': + resolution: {integrity: sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.18.20': + resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-ia32@0.25.12': + resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-ia32@0.28.1': + resolution: {integrity: sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.18.20': + resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + + '@esbuild/win32-x64@0.25.12': + resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@esbuild/win32-x64@0.28.1': + resolution: {integrity: sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + '@eslint-community/eslint-utils@4.10.1': resolution: {integrity: sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -257,6 +733,20 @@ packages: '@noble/hashes': optional: true + '@grpc/grpc-js@1.14.4': + resolution: {integrity: sha512-k9Dj3DV/itK9D06Y8f190Qgop7/Ui+D0njFV3LHMPwPT75DpXLQohE9Wmz0QElrJnzsjB7KPWiKJbOl7IPDArQ==} + engines: {node: '>=12.10.0'} + + '@grpc/proto-loader@0.7.15': + resolution: {integrity: sha512-tMXdRCfYVixjuFK+Hk0Q1s38gV9zDiDJfWL3h1rv4Qc39oILCu1TRTDt7+fGUI8K4G1Fj125Hx/ru3azECWTyQ==} + engines: {node: '>=6'} + hasBin: true + + '@grpc/proto-loader@0.8.1': + resolution: {integrity: sha512-wtF6h+DY6M3YaDBPAmvuuA6jV8Sif9MjtOI5euKFWRgCDl5PeDpPsHR9u2l6St5ceY8AZgoNDww5+HvEsXFsGg==} + engines: {node: '>=6'} + hasBin: true + '@humanfs/core@0.19.2': resolution: {integrity: sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==} engines: {node: '>=18.18.0'} @@ -439,6 +929,10 @@ packages: cpu: [x64] os: [win32] + '@isaacs/cliui@8.0.2': + resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} + engines: {node: '>=12'} + '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} @@ -455,6 +949,12 @@ packages: '@jridgewell/trace-mapping@0.3.31': resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + '@js-sdsl/ordered-map@4.4.2': + resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==} + + '@kwsites/file-exists@1.1.1': + resolution: {integrity: sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==} + '@napi-rs/wasm-runtime@1.2.2': resolution: {integrity: sha512-JfB4kuJQjaoHuCTseIINHtHWeJnvgEcxjwA5t/Y00ZgaOO1Crz3fjT/p8kT28zA/Caz7oiUMn3d6H2yOVCVwuw==} engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} @@ -539,6 +1039,37 @@ packages: '@oxc-project/types@0.143.0': resolution: {integrity: sha512-u6JZdLBTLotrNC9Vd6vPssINdzcCzleKAH6EJKImQb7GtYvX5keN2dxkoK44stCc4tffE6QQRtZTXVSzsLUlWA==} + '@pkgjs/parseargs@0.11.0': + resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} + engines: {node: '>=14'} + + '@protobufjs/aspromise@1.1.2': + resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} + + '@protobufjs/base64@1.1.2': + resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} + + '@protobufjs/codegen@2.0.5': + resolution: {integrity: sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==} + + '@protobufjs/eventemitter@1.1.1': + resolution: {integrity: sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==} + + '@protobufjs/fetch@1.1.1': + resolution: {integrity: sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==} + + '@protobufjs/float@1.0.2': + resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} + + '@protobufjs/path@1.1.2': + resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} + + '@protobufjs/pool@1.1.0': + resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} + + '@protobufjs/utf8@1.1.2': + resolution: {integrity: sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==} + '@rolldown/binding-android-arm64@1.2.3': resolution: {integrity: sha512-zrJtHDcaZJ1Fp7xf4hNl+7seH9Cn/N5TwLYkhgXREtBwAd/jaqW3uqeHxpDugJLVICWg4eW44kOQEGJ1r6jCGw==} engines: {node: ^20.19.0 || >=22.12.0} @@ -733,6 +1264,9 @@ packages: '@tailwindcss/postcss@4.3.3': resolution: {integrity: sha512-JTSZZGQi1AyKirbLN3azmjVzef92tcX7h+iSqPdaeStyFpGpDlKvvpxeOE8njhbUanbRwr3z8DyzhICWnMtQeg==} + '@testcontainers/postgresql@12.1.0': + resolution: {integrity: sha512-Pjf2VSVNirEPfz36nidyrVAnZvc2YhajOznY4VgyEsvfTd5qiMNOuPq96drREvxAUtXl5SFLX7vXj7sSq4aTcA==} + '@testing-library/dom@10.4.1': resolution: {integrity: sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==} engines: {node: '>=18'} @@ -770,6 +1304,12 @@ packages: '@types/deep-eql@4.0.2': resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + '@types/docker-modem@3.0.6': + resolution: {integrity: sha512-yKpAGEuKRSS8wwx0joknWxsmLha78wNMe9R2S3UNsVOkZded8UqOrV8KoeDXoXsjndxwyF3eIhyClGbO1SEhEg==} + + '@types/dockerode@4.0.1': + resolution: {integrity: sha512-cmUpB+dPN955PxBEuXE3f6lKO1hHiIGYJA46IVF3BJpNsZGvtBDcRnlrHYHtOH/B6vtDOyl2kZ2ShAu3mgc27Q==} + '@types/estree@1.0.9': resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} @@ -779,9 +1319,15 @@ packages: '@types/json5@0.0.29': resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} + '@types/node@18.19.130': + resolution: {integrity: sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==} + '@types/node@24.13.3': resolution: {integrity: sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==} + '@types/pg@8.21.0': + resolution: {integrity: sha512-AYdtudzabjLZgVgRZmAnU8bAnVUXzuJX2IYHeSIiIHm68olD+LgQYCGWdtcNYnP0uq9c4S4NibVG3Ni7VbKW7Q==} + '@types/react-dom@19.2.4': resolution: {integrity: sha512-Bsc+QHgp+P/F02XDzNCY9jnZNCUuLki36KT7VKrTXXLdHf+vHMNZnW1rVu5DNW/rCK+fya3DATySbLM4yhtKUw==} peerDependencies: @@ -790,6 +1336,15 @@ packages: '@types/react@19.2.18': resolution: {integrity: sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==} + '@types/ssh2-streams@0.1.13': + resolution: {integrity: sha512-faHyY3brO9oLEA0QlcO8N2wT7R0+1sHWZvQ+y3rMLwdY1ZyS1z0W3t65j9PqT4HmQ6ALzNe7RZlNuCNE0wBSWA==} + + '@types/ssh2@0.5.52': + resolution: {integrity: sha512-lbLLlXxdCZOSJMCInKH2+9V/77ET2J6NPQHpFI0kda61Dd1KglJs+fPQBchizmzYSOJBgdTajhPqBO1xxLywvg==} + + '@types/ssh2@1.15.5': + resolution: {integrity: sha512-N1ASjp/nXH3ovBHddRJpli4ozpk6UdDYIX4RJWFa9L1YKnzdhTlVmiGHm4DZnj/jLbqZpes4aeR30EFGQtvhQQ==} + '@typescript-eslint/eslint-plugin@8.66.0': resolution: {integrity: sha512-p088eaGrzYz1s+7cov0aMOCkNGTJlVxF4jgubf28c8L0Cv9Rloj8YBHnv4hXLq6IIEE1AsjNWavO+k+8kP2Y0A==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -1011,6 +1566,10 @@ packages: '@vitest/utils@4.1.10': resolution: {integrity: sha512-fy9am/HWxbaGt/Sawrp90vt6Y6jQwf1RX77cz3uwoJwJVMli/e1IEwRPnMNJ7vKfPTwo0diXifkpPvwH9v7nGA==} + abort-controller@3.0.0: + resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} + engines: {node: '>=6.5'} + acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -1028,6 +1587,10 @@ packages: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} + ansi-regex@6.2.2: + resolution: {integrity: sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==} + engines: {node: '>=12'} + ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} @@ -1036,6 +1599,18 @@ packages: resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} engines: {node: '>=10'} + ansi-styles@6.2.3: + resolution: {integrity: sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==} + engines: {node: '>=12'} + + archiver-utils@5.0.2: + resolution: {integrity: sha512-wuLJMmIBQYCsGZgYLTy5FIB2pF6Lfb6cXMSF8Qywwk3t20zWnAi7zLcQFdKQmIB8wyZpY5ER38x08GbwtR2cLA==} + engines: {node: '>= 14'} + + archiver@7.0.1: + resolution: {integrity: sha512-ZcbTaIqJOfCc03QwD468Unz/5Ir8ATtvAHsK+FdXbDIbGfihqh9mrvdcYunQzqn4HrvWWaFyaxJhGZagaJJpPQ==} + engines: {node: '>= 14'} + argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -1078,6 +1653,9 @@ packages: resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==} engines: {node: '>= 0.4'} + asn1@0.2.6: + resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==} + assertion-error@2.0.1: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} @@ -1089,6 +1667,12 @@ packages: resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==} engines: {node: '>= 0.4'} + async-lock@1.4.1: + resolution: {integrity: sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ==} + + async@3.2.6: + resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==} + available-typed-arrays@1.0.7: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} @@ -1101,6 +1685,14 @@ packages: resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==} engines: {node: '>= 0.4'} + b4a@1.8.1: + resolution: {integrity: sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==} + peerDependencies: + react-native-b4a: '*' + peerDependenciesMeta: + react-native-b4a: + optional: true + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -1108,17 +1700,66 @@ packages: resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} engines: {node: 18 || 20 || >=22} + bare-events@2.9.1: + resolution: {integrity: sha512-Z0oHEHAFDZkffN8Qc39zNZjQlMDkPJRyyyZieU1VH7u8c5S+qHZ2S8ixdKIAxEjfHO7FJxXmJWgteOghVanIsg==} + peerDependencies: + bare-abort-controller: '*' + peerDependenciesMeta: + bare-abort-controller: + optional: true + + bare-fs@4.8.0: + resolution: {integrity: sha512-fM+MhCvdQhZ7NV6S95a07gPSqjIYKn6mFaXfx266wN3ajZGl/+1AzH+ubkXQ0fFZvOe2nk9VHkzdYkQE5zMV3Q==} + engines: {bare: '>=1.28.0'} + peerDependencies: + bare-buffer: '*' + peerDependenciesMeta: + bare-buffer: + optional: true + + bare-path@3.1.1: + resolution: {integrity: sha512-JprUlveX3QjApC1cTpsUOiscADftCGVWkzitbHsRqv84hzYwYHw2mbluddsq5TvI8mH/8Ov1f4BiMAdcB0oYnQ==} + + bare-stream@2.13.3: + resolution: {integrity: sha512-Kc+brLqvEqGkjyfiwJmImAOqLZL7OsoLKuavx+hJjgVV3nLTOjloJyPMFxjUPerGGHrNH0fLU06jjykMLWrERQ==} + peerDependencies: + bare-abort-controller: '*' + bare-buffer: '*' + bare-events: '*' + peerDependenciesMeta: + bare-abort-controller: + optional: true + bare-buffer: + optional: true + bare-events: + optional: true + + bare-url@2.5.1: + resolution: {integrity: sha512-cD5ciQuKlx+eumTCfqbfiL+fhQm+dHbVNB/cX4+d+I/nx4JsVop9VoFEPAs5RJ6I84QR6bZIBjpd2kjDOYeWcg==} + + base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + baseline-browser-mapping@2.11.12: resolution: {integrity: sha512-r7WnVImvVCeFpf2DOXfy41aPWzeNg3H/A2X4dKmy1QL0MSyyk/e7z8ihJ3N6Nn2PsdhkVlqnEfnUE4a05P2aTA==} engines: {node: '>=6.0.0'} hasBin: true + bcrypt-pbkdf@1.0.2: + resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==} + bidi-js@1.0.3: resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==} + bl@4.1.0: + resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + brace-expansion@1.1.18: resolution: {integrity: sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==} + brace-expansion@2.1.4: + resolution: {integrity: sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==} + brace-expansion@5.0.9: resolution: {integrity: sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==} engines: {node: 20 || >=22} @@ -1132,6 +1773,27 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true + buffer-crc32@1.0.0: + resolution: {integrity: sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==} + engines: {node: '>=8.0.0'} + + buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + + buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + + buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + + buildcheck@0.0.7: + resolution: {integrity: sha512-lHblz4ahamxpTmnsk+MNTRWsjYKv965MwOrSJyeD588rR3Jcu7swE+0wN5F+PbL5cjgu/9ObkhfzEPuofEMwLA==} + engines: {node: '>=10.0.0'} + + byline@5.0.0: + resolution: {integrity: sha512-s6webAy+R4SR8XVuJWt2V2rGvhnrhxN+9S15GNuTK3wKPOXFF6RNc+8ug2XhH+2s4f+uudG4kUVYmYOQWL2g0Q==} + engines: {node: '>=0.10.0'} + call-bind-apply-helpers@1.0.2: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} @@ -1159,9 +1821,16 @@ packages: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} + chownr@1.1.4: + resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + client-only@0.0.1: resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} + cliui@8.0.1: + resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} + engines: {node: '>=12'} + color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -1169,12 +1838,32 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + compress-commons@6.0.2: + resolution: {integrity: sha512-6FqVXeETqWPoGcfzrXb37E50NP0LXT8kAMu5ooZayhWWdgEY4lBEEcbQNXtkuKQsGduxiIcI4gOTsxTmuq/bSg==} + engines: {node: '>= 14'} + concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + core-util-is@1.0.3: + resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} + + cpu-features@0.0.10: + resolution: {integrity: sha512-9IkYqtX3YHPCzoVg1Py+o9057a3i0fp7S530UWokCSaFVTc7CwXPRiOjRjBQQ18ZCNafx78YfnG+HALxtVmOGA==} + engines: {node: '>=10.0.0'} + + crc-32@1.2.2: + resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} + engines: {node: '>=0.8'} + hasBin: true + + crc32-stream@6.0.0: + resolution: {integrity: sha512-piICUB6ei4IlTv1+653yq5+KoqfBYmj9bw6LqXoOneTMDXk5nM1qt12mFW1caG3LlJXEKW1Bp0WggEmIfQB34g==} + engines: {node: '>= 14'} + cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -1247,6 +1936,18 @@ packages: resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} engines: {node: '>=8'} + docker-compose@1.4.2: + resolution: {integrity: sha512-rPHigTKGaEHpkUmfd69QgaOp+Os5vGJwG/Ry8lcr8W/382AmI+z/D7qoa9BybKIkqNppaIbs8RYeHSevdQjWww==} + engines: {node: '>= 6.0.0'} + + docker-modem@5.0.7: + resolution: {integrity: sha512-XJgGhoR/CLpqshm4d3L7rzH6t8NgDFUIIpztYlLHIApeJjMZKYJMz2zxPsYxnejq5h3ELYSw/RBsi3t5h7gNTA==} + engines: {node: '>= 8.0'} + + dockerode@5.0.1: + resolution: {integrity: sha512-avsq/xk4YPIrn0CgleX5bjT9Y8IT1p9PxrNQ++RBQ2WEyFfHCTDsT9kmyxz+H/axnjAwg8wJWEIuPGOUuNupiA==} + engines: {node: '>= 14.17'} + doctrine@2.1.0: resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} engines: {node: '>=0.10.0'} @@ -1257,16 +1958,121 @@ packages: dom-accessibility-api@0.6.3: resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==} + drizzle-kit@0.31.10: + resolution: {integrity: sha512-7OZcmQUrdGI+DUNNsKBn1aW8qSoKuTH7d0mYgSP8bAzdFzKoovxEFnoGQp2dVs82EOJeYycqRtciopszwUf8bw==} + hasBin: true + + drizzle-orm@0.45.2: + resolution: {integrity: sha512-kY0BSaTNYWnoDMVoyY8uxmyHjpJW1geOmBMdSSicKo9CIIWkSxMIj2rkeSR51b8KAPB7m+qysjuHme5nKP+E5Q==} + peerDependencies: + '@aws-sdk/client-rds-data': '>=3' + '@cloudflare/workers-types': '>=4' + '@electric-sql/pglite': '>=0.2.0' + '@libsql/client': '>=0.10.0' + '@libsql/client-wasm': '>=0.10.0' + '@neondatabase/serverless': '>=0.10.0' + '@op-engineering/op-sqlite': '>=2' + '@opentelemetry/api': ^1.4.1 + '@planetscale/database': '>=1.13' + '@prisma/client': '*' + '@tidbcloud/serverless': '*' + '@types/better-sqlite3': '*' + '@types/pg': '*' + '@types/sql.js': '*' + '@upstash/redis': '>=1.34.7' + '@vercel/postgres': '>=0.8.0' + '@xata.io/client': '*' + better-sqlite3: '>=7' + bun-types: '*' + expo-sqlite: '>=14.0.0' + gel: '>=2' + knex: '*' + kysely: '*' + mysql2: '>=2' + pg: '>=8' + postgres: '>=3' + prisma: '*' + sql.js: '>=1' + sqlite3: '>=5' + peerDependenciesMeta: + '@aws-sdk/client-rds-data': + optional: true + '@cloudflare/workers-types': + optional: true + '@electric-sql/pglite': + optional: true + '@libsql/client': + optional: true + '@libsql/client-wasm': + optional: true + '@neondatabase/serverless': + optional: true + '@op-engineering/op-sqlite': + optional: true + '@opentelemetry/api': + optional: true + '@planetscale/database': + optional: true + '@prisma/client': + optional: true + '@tidbcloud/serverless': + optional: true + '@types/better-sqlite3': + optional: true + '@types/pg': + optional: true + '@types/sql.js': + optional: true + '@upstash/redis': + optional: true + '@vercel/postgres': + optional: true + '@xata.io/client': + optional: true + better-sqlite3: + optional: true + bun-types: + optional: true + expo-sqlite: + optional: true + gel: + optional: true + knex: + optional: true + kysely: + optional: true + mysql2: + optional: true + pg: + optional: true + postgres: + optional: true + prisma: + optional: true + sql.js: + optional: true + sqlite3: + optional: true + dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} + eastasianwidth@0.2.0: + resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + electron-to-chromium@1.5.402: resolution: {integrity: sha512-/oOpMaPT6Yg+6/1XQhyIPlzgj7Ye9zf+nNM2Uh6OcE2G2oNptWazFa+qB2Pdqqbsc9KnIDzgAntoYN0dbwOXwA==} + emoji-regex@8.0.0: + resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + end-of-stream@1.4.5: + resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==} + enhanced-resolve@5.24.5: resolution: {integrity: sha512-L1l8TNvomm6UVW5B253AGxQagSQr+vGwhMlrrfRS2qmhx46AMpMVJKQYLvWYbysTMY8VoicOvzHzoHMbyzB+4A==} engines: {node: '>=10.13.0'} @@ -1314,6 +2120,21 @@ packages: resolution: {integrity: sha512-yPDz7wqpg1/mmHLmS3tcfTfbw5f1eryXvyghYBffGdERwe+mV7ZcWzTR8LR17Kvqt3qfPurjlonmnq3MKXIOXw==} engines: {node: '>= 0.4'} + esbuild@0.18.20: + resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} + engines: {node: '>=12'} + hasBin: true + + esbuild@0.25.12: + resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==} + engines: {node: '>=18'} + hasBin: true + + esbuild@0.28.1: + resolution: {integrity: sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==} + engines: {node: '>=18'} + hasBin: true + escalade@3.2.0: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} @@ -1445,6 +2266,17 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} + event-target-shim@5.0.1: + resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} + engines: {node: '>=6'} + + events-universal@1.0.1: + resolution: {integrity: sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==} + + events@3.3.0: + resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} + engines: {node: '>=0.8.x'} + expect-type@1.4.0: resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} engines: {node: '>=12.0.0'} @@ -1452,6 +2284,9 @@ packages: fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + fast-fifo@1.3.2: + resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==} + fast-glob@3.3.1: resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==} engines: {node: '>=8.6.0'} @@ -1497,6 +2332,13 @@ packages: resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} engines: {node: '>= 0.4'} + foreground-child@3.3.1: + resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==} + engines: {node: '>=14'} + + fs-constants@1.0.0: + resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -1520,10 +2362,18 @@ packages: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} + get-caller-file@2.0.5: + resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} + engines: {node: 6.* || 8.* || >= 10.*} + get-intrinsic@1.3.0: resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} engines: {node: '>= 0.4'} + get-port@5.1.1: + resolution: {integrity: sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==} + engines: {node: '>=8'} + get-proto@1.0.1: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} @@ -1543,6 +2393,11 @@ packages: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} + glob@10.5.0: + resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==} + deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + hasBin: true + globals@14.0.0: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} @@ -1599,6 +2454,9 @@ packages: resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==} engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + ignore@5.3.2: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} @@ -1619,6 +2477,9 @@ packages: resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} engines: {node: '>=8'} + inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + internal-slot@1.1.0: resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==} engines: {node: '>= 0.4'} @@ -1670,6 +2531,10 @@ packages: resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==} engines: {node: '>= 0.4'} + is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} + engines: {node: '>=8'} + is-generator-function@1.1.2: resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==} engines: {node: '>= 0.4'} @@ -1709,6 +2574,10 @@ packages: resolution: {integrity: sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==} engines: {node: '>= 0.4'} + is-stream@2.0.1: + resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} + engines: {node: '>=8'} + is-string@1.1.1: resolution: {integrity: sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==} engines: {node: '>= 0.4'} @@ -1733,6 +2602,9 @@ packages: resolution: {integrity: sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==} engines: {node: '>= 0.4'} + isarray@1.0.0: + resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + isarray@2.0.5: resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} @@ -1743,6 +2615,9 @@ packages: resolution: {integrity: sha512-H0dkQoCa3b2VEeKQBOxFph+JAbcrQdE7KC0UkqwpLmv2EC4P41QXP+rqo9wYodACiG5/WM5s9oDApTU8utwj9g==} engines: {node: '>= 0.4'} + jackspeak@3.4.3: + resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} + jiti@2.7.0: resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==} hasBin: true @@ -1800,6 +2675,10 @@ packages: resolution: {integrity: sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==} engines: {node: '>=0.10'} + lazystream@1.0.1: + resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==} + engines: {node: '>= 0.6.3'} + levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -1956,13 +2835,25 @@ packages: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} + lodash.camelcase@4.3.0: + resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} + lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + lodash@4.18.1: + resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==} + + long@5.3.2: + resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==} + loose-envify@1.4.0: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true + lru-cache@10.4.3: + resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} + lru-cache@11.5.2: resolution: {integrity: sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==} engines: {node: 20 || >=22} @@ -2003,12 +2894,35 @@ packages: minimatch@3.1.5: resolution: {integrity: sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==} + minimatch@5.1.9: + resolution: {integrity: sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==} + engines: {node: '>=10'} + + minimatch@9.0.9: + resolution: {integrity: sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==} + engines: {node: '>=16 || 14 >=14.17'} + minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + minipass@7.1.3: + resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==} + engines: {node: '>=16 || 14 >=14.17'} + + mkdirp-classic@0.5.3: + resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + + mkdirp@3.0.1: + resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==} + engines: {node: '>=10'} + hasBin: true + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + nan@2.28.0: + resolution: {integrity: sha512-fTsDz99OTq2sVePhGdp4qQhggZFtKr64ZNVyVajRKtMOkJxYekplBh577PiJB12v/D3s2E5cGtOI45LWp6rnLQ==} + nanoid@3.3.18: resolution: {integrity: sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -2051,6 +2965,10 @@ packages: resolution: {integrity: sha512-D9UOmYG3UH1V+ENW56t5QXBwJw1YEY18ruVeus89Rw+SyIgjPkCO84bRzO3uNIYosJbNwiabWVn48o3uJLjxFQ==} engines: {node: '>=18'} + normalize-path@3.0.0: + resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} + engines: {node: '>=0.10.0'} + object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} @@ -2087,6 +3005,9 @@ packages: resolution: {integrity: sha512-4a+OsYv9UktOJKE+l1A4OufDgdRF9PifWj+tJnHURo/P+WOxpG4GzUFL9qCalmWauao6ogiG+QvnCovwPoyAWA==} engines: {node: '>=12.20.0'} + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -2103,6 +3024,9 @@ packages: resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} engines: {node: '>=10'} + package-json-from-dist@1.0.1: + resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==} + parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} @@ -2121,9 +3045,47 @@ packages: path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + path-scurry@1.11.1: + resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} + engines: {node: '>=16 || 14 >=14.18'} + pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + pg-cloudflare@1.4.0: + resolution: {integrity: sha512-Vo7z/6rrQYxpNRylp4Tlob2elzbh+N/MOQbxFVWCxS7oEx6jF53GTJFxK2WWpKuBRkmiin4Mt+xofFDjx09R0A==} + + pg-connection-string@2.14.0: + resolution: {integrity: sha512-XwWDGcLRGCXAR8F/AM5bG7Q+A3Wm2s6QeEjlOKZLlH3UYcguiqCWKyWXVag5TLTIjR7oOJUY8kcADaZgWPyLeg==} + + pg-int8@1.0.1: + resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==} + engines: {node: '>=4.0.0'} + + pg-pool@3.14.0: + resolution: {integrity: sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==} + peerDependencies: + pg: '>=8.0' + + pg-protocol@1.15.0: + resolution: {integrity: sha512-cq9sECI5s0+uPUXjbz8ioyPJni6RzsRib0US67i5IoTZKw8fNeYlVE7u8F4dG7vEJJtc5wdD1K189lCCUwqWTQ==} + + pg-types@2.2.0: + resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==} + engines: {node: '>=4'} + + pg@8.22.0: + resolution: {integrity: sha512-8wih1vVIBMxoUM2oB4soJsD9tDnDpLv4OXBJ+EJzFsvycD+lfyIreC2gGHq78f8jbLLt+bvlPTFdFZfJkOuzAA==} + engines: {node: '>= 16.0.0'} + peerDependencies: + pg-native: '>=3.0.1' + peerDependenciesMeta: + pg-native: + optional: true + + pgpass@1.0.5: + resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -2147,6 +3109,22 @@ packages: resolution: {integrity: sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==} engines: {node: ^10 || ^12 || >=14} + postgres-array@2.0.0: + resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==} + engines: {node: '>=4'} + + postgres-bytea@1.0.1: + resolution: {integrity: sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==} + engines: {node: '>=0.10.0'} + + postgres-date@1.0.7: + resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==} + engines: {node: '>=0.10.0'} + + postgres-interval@1.2.0: + resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} + engines: {node: '>=0.10.0'} + prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -2155,9 +3133,30 @@ packages: resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} + process-nextick-args@2.0.1: + resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + + process@0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} + proper-lockfile@4.1.2: + resolution: {integrity: sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==} + + properties-reader@3.0.1: + resolution: {integrity: sha512-WPn+h9RGEExOKdu4bsF4HksG/uzd3cFq3MFtq8PsFeExPse5Ha/VOjQNyHhjboBFwGXGev6muJYTSPAOkROq2g==} + engines: {node: '>=18'} + + protobufjs@7.6.5: + resolution: {integrity: sha512-/FPD0nUc9jH6rfFjji9IBqOz4pcSE3CsT1m7Ep6Mdb0LxSUMj8hgl6GomOvZzpNpAqqGaXA0P3VSrZLFzIhQrw==} + engines: {node: '>=12.0.0'} + + pump@3.0.4: + resolution: {integrity: sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==} + punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -2180,6 +3179,20 @@ packages: resolution: {integrity: sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==} engines: {node: '>=0.10.0'} + readable-stream@2.3.8: + resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} + + readable-stream@3.6.2: + resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} + engines: {node: '>= 6'} + + readable-stream@4.7.0: + resolution: {integrity: sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + readdir-glob@1.1.3: + resolution: {integrity: sha512-v05I2k7xN8zXvPD9N+z/uhXPaj0sUFCe2rcWZIpBsqxfP7xXFQ0tipAd/wjj1YxWyWtUS5IDJpOG82JKt2EAVA==} + redent@3.0.0: resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} engines: {node: '>=8'} @@ -2192,6 +3205,10 @@ packages: resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==} engines: {node: '>= 0.4'} + require-directory@2.1.1: + resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} + engines: {node: '>=0.10.0'} + require-from-string@2.0.2: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} @@ -2208,6 +3225,10 @@ packages: engines: {node: '>= 0.4'} hasBin: true + retry@0.12.0: + resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} + engines: {node: '>= 4'} + reusify@1.1.0: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} @@ -2224,6 +3245,12 @@ packages: resolution: {integrity: sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==} engines: {node: '>=0.4'} + safe-buffer@5.1.2: + resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} + + safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + safe-push-apply@1.0.0: resolution: {integrity: sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==} engines: {node: '>= 0.4'} @@ -2232,6 +3259,9 @@ packages: resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==} engines: {node: '>= 0.4'} + safer-buffer@2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + saxes@6.0.0: resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==} engines: {node: '>=v12.22.7'} @@ -2299,10 +3329,38 @@ packages: siginfo@2.0.0: resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + signal-exit@3.0.7: + resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + + signal-exit@4.1.0: + resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} + engines: {node: '>=14'} + source-map-js@1.2.1: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} + source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + split-ca@1.0.1: + resolution: {integrity: sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ==} + + split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + + ssh-remote-port-forward@1.0.4: + resolution: {integrity: sha512-x0LV1eVDwjf1gmG7TTnfqIzf+3VPRz7vrNIjX6oYLbeCrf/PeVY6hkT68Mg+q02qXxQhrLjB0jfgvhevoCRmLQ==} + + ssh2@1.17.0: + resolution: {integrity: sha512-wPldCk3asibAjQ/kziWQQt1Wh3PgDFpC0XpwclzKcdT1vql6KeYxf5LIt4nlFkUeR8WuphYMKqUA56X4rjbfgQ==} + engines: {node: '>=10.16.0'} + stable-hash@0.0.5: resolution: {integrity: sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==} @@ -2316,6 +3374,17 @@ packages: resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} engines: {node: '>= 0.4'} + streamx@2.28.0: + resolution: {integrity: sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==} + + string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + + string-width@5.1.2: + resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} + engines: {node: '>=12'} + string.prototype.includes@2.0.1: resolution: {integrity: sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==} engines: {node: '>= 0.4'} @@ -2339,6 +3408,20 @@ packages: resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} engines: {node: '>= 0.4'} + string_decoder@1.1.1: + resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} + + string_decoder@1.3.0: + resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + + strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + + strip-ansi@7.2.0: + resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==} + engines: {node: '>=12'} + strip-bom@3.0.0: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} @@ -2382,6 +3465,29 @@ packages: resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==} engines: {node: '>=6'} + tar-fs@2.1.5: + resolution: {integrity: sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw==} + + tar-fs@3.1.3: + resolution: {integrity: sha512-/hU4AXnIdZu+Gvl1pk0oI5f5HxWsCJRtY2aFaJdk9VvyL48DWU6iU5WAIPG+wIi1YvWA6eTJvIviP/tMAZZNwQ==} + + tar-stream@2.2.0: + resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} + engines: {node: '>=6'} + + tar-stream@3.2.0: + resolution: {integrity: sha512-ojzvCvVaNp6aOTFmG7jaRD0meowIAuPc3cMMhSgKiVWws1GyHbGd/xvnyuRKcKlMpt3qvxx6r0hreCNITP9hIg==} + + teex@1.0.1: + resolution: {integrity: sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==} + + testcontainers@12.1.0: + resolution: {integrity: sha512-YjDLqIITuhGLMnM10yhg3oV6lIG5IMpz1R1DPBZoOOks83q7i7IVpeSWRTiyl7roozjiyLmwIoLK/KY8OnZmIA==} + engines: {node: '>= 22.22'} + + text-decoder@1.2.7: + resolution: {integrity: sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==} + tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} @@ -2404,6 +3510,10 @@ packages: resolution: {integrity: sha512-GgouD1B+sWwvkaEq8vXC15DjQitxbvs12oIXELpconwm+Tg3zfcEv4jgzq3vtKverDXsg3VI8aRgNL2Nra0Iog==} hasBin: true + tmp@0.2.7: + resolution: {integrity: sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==} + engines: {node: '>=14.14'} + to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -2428,6 +3538,14 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + tsx@4.23.11: + resolution: {integrity: sha512-Ry2oTEUnhBdeEdWIztY8kf3/nBGnPnjMLVGL0YfdRXMORuPER5NlKmayqxtxRxwB1xBN+RivRaJfe7PM1rtiyw==} + engines: {node: '>=18.0.0'} + hasBin: true + + tweetnacl@0.14.5: + resolution: {integrity: sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==} + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -2464,6 +3582,9 @@ packages: resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} engines: {node: '>= 0.4'} + undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + undici-types@7.18.2: resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==} @@ -2483,6 +3604,9 @@ packages: uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + util-deprecate@1.0.2: + resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + vite@8.2.1: resolution: {integrity: sha512-EU/eS7BH3XROHh2YnBefjM6DBKA6ZeMZEYQbj7NLWg5wHYlhB8B/Mayd5XsgWq+NFYccDOTemRpdETWR6Ka/lw==} engines: {node: ^20.19.0 || >=22.12.0} @@ -2617,6 +3741,17 @@ packages: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} + wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + + wrap-ansi@8.1.0: + resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} + engines: {node: '>=12'} + + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + xml-name-validator@5.0.0: resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} engines: {node: '>=18'} @@ -2624,13 +3759,38 @@ packages: xmlchars@2.2.0: resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} + xtend@4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + + y18n@5.0.8: + resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} + engines: {node: '>=10'} + yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} + yaml@2.9.0: + resolution: {integrity: sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==} + engines: {node: '>= 14.6'} + hasBin: true + + yargs-parser@21.1.1: + resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} + engines: {node: '>=12'} + + yargs@17.7.3: + resolution: {integrity: sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==} + engines: {node: '>=12'} + yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} + zip-stream@6.0.1: + resolution: {integrity: sha512-zK7YHHz4ZXpW89AHXUPbQVGKI7uvkd3hzusTdotCg1UxyaVtg0zFJSTfW/Dq5f7OBBVnq6cZIaC8Ti4hb6dtCA==} + engines: {node: '>= 14'} + zod-validation-error@4.0.2: resolution: {integrity: sha512-Q6/nZLe6jxuU80qb/4uJ4t5v2VEZ44lzQjPDhYJNztRQ4wyWc6VF3D3Kb/fAuPetZQnhS3hnajCf9CsWesghLQ==} engines: {node: '>=18.0.0'} @@ -2669,20 +3829,20 @@ snapshots: '@babel/compat-data@7.29.7': {} - '@babel/core@7.29.7': + '@babel/core@7.29.7(supports-color@7.2.0)': dependencies: '@babel/code-frame': 7.29.7 '@babel/generator': 7.29.8 '@babel/helper-compilation-targets': 7.29.7 - '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7) + '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) '@babel/helpers': 7.29.7 '@babel/parser': 7.29.8 '@babel/template': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.8(supports-color@7.2.0) '@babel/types': 7.29.8 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -2707,19 +3867,19 @@ snapshots: '@babel/helper-globals@7.29.7': {} - '@babel/helper-module-imports@7.29.7': + '@babel/helper-module-imports@7.29.7(supports-color@7.2.0)': dependencies: - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.8(supports-color@7.2.0) '@babel/types': 7.29.8 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7)': + '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.7 - '@babel/helper-module-imports': 7.29.7 + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-module-imports': 7.29.7(supports-color@7.2.0) '@babel/helper-validator-identifier': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.8(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -2746,7 +3906,7 @@ snapshots: '@babel/parser': 7.29.8 '@babel/types': 7.29.8 - '@babel/traverse@7.29.8': + '@babel/traverse@7.29.8(supports-color@7.2.0)': dependencies: '@babel/code-frame': 7.29.7 '@babel/generator': 7.29.8 @@ -2754,7 +3914,7 @@ snapshots: '@babel/parser': 7.29.8 '@babel/template': 7.29.7 '@babel/types': 7.29.8 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -2763,6 +3923,8 @@ snapshots: '@babel/helper-string-parser': 7.29.7 '@babel/helper-validator-identifier': 7.29.7 + '@balena/dockerignore@1.0.2': {} + '@bramus/specificity@2.4.2': dependencies: css-tree: 3.2.1 @@ -2791,6 +3953,8 @@ snapshots: '@csstools/css-tokenizer@4.0.0': {} + '@drizzle-team/brocli@0.10.2': {} + '@emnapi/core@1.10.0': dependencies: '@emnapi/wasi-threads': 1.2.1 @@ -2812,22 +3976,254 @@ snapshots: tslib: 2.8.1 optional: true - '@eslint-community/eslint-utils@4.10.1(eslint@9.39.5(jiti@2.7.0))': + '@esbuild-kit/core-utils@3.3.2': dependencies: - eslint: 9.39.5(jiti@2.7.0) + esbuild: 0.18.20 + source-map-support: 0.5.21 + + '@esbuild-kit/esm-loader@2.6.5': + dependencies: + '@esbuild-kit/core-utils': 3.3.2 + get-tsconfig: 4.14.1 + + '@esbuild/aix-ppc64@0.25.12': + optional: true + + '@esbuild/aix-ppc64@0.28.1': + optional: true + + '@esbuild/android-arm64@0.18.20': + optional: true + + '@esbuild/android-arm64@0.25.12': + optional: true + + '@esbuild/android-arm64@0.28.1': + optional: true + + '@esbuild/android-arm@0.18.20': + optional: true + + '@esbuild/android-arm@0.25.12': + optional: true + + '@esbuild/android-arm@0.28.1': + optional: true + + '@esbuild/android-x64@0.18.20': + optional: true + + '@esbuild/android-x64@0.25.12': + optional: true + + '@esbuild/android-x64@0.28.1': + optional: true + + '@esbuild/darwin-arm64@0.18.20': + optional: true + + '@esbuild/darwin-arm64@0.25.12': + optional: true + + '@esbuild/darwin-arm64@0.28.1': + optional: true + + '@esbuild/darwin-x64@0.18.20': + optional: true + + '@esbuild/darwin-x64@0.25.12': + optional: true + + '@esbuild/darwin-x64@0.28.1': + optional: true + + '@esbuild/freebsd-arm64@0.18.20': + optional: true + + '@esbuild/freebsd-arm64@0.25.12': + optional: true + + '@esbuild/freebsd-arm64@0.28.1': + optional: true + + '@esbuild/freebsd-x64@0.18.20': + optional: true + + '@esbuild/freebsd-x64@0.25.12': + optional: true + + '@esbuild/freebsd-x64@0.28.1': + optional: true + + '@esbuild/linux-arm64@0.18.20': + optional: true + + '@esbuild/linux-arm64@0.25.12': + optional: true + + '@esbuild/linux-arm64@0.28.1': + optional: true + + '@esbuild/linux-arm@0.18.20': + optional: true + + '@esbuild/linux-arm@0.25.12': + optional: true + + '@esbuild/linux-arm@0.28.1': + optional: true + + '@esbuild/linux-ia32@0.18.20': + optional: true + + '@esbuild/linux-ia32@0.25.12': + optional: true + + '@esbuild/linux-ia32@0.28.1': + optional: true + + '@esbuild/linux-loong64@0.18.20': + optional: true + + '@esbuild/linux-loong64@0.25.12': + optional: true + + '@esbuild/linux-loong64@0.28.1': + optional: true + + '@esbuild/linux-mips64el@0.18.20': + optional: true + + '@esbuild/linux-mips64el@0.25.12': + optional: true + + '@esbuild/linux-mips64el@0.28.1': + optional: true + + '@esbuild/linux-ppc64@0.18.20': + optional: true + + '@esbuild/linux-ppc64@0.25.12': + optional: true + + '@esbuild/linux-ppc64@0.28.1': + optional: true + + '@esbuild/linux-riscv64@0.18.20': + optional: true + + '@esbuild/linux-riscv64@0.25.12': + optional: true + + '@esbuild/linux-riscv64@0.28.1': + optional: true + + '@esbuild/linux-s390x@0.18.20': + optional: true + + '@esbuild/linux-s390x@0.25.12': + optional: true + + '@esbuild/linux-s390x@0.28.1': + optional: true + + '@esbuild/linux-x64@0.18.20': + optional: true + + '@esbuild/linux-x64@0.25.12': + optional: true + + '@esbuild/linux-x64@0.28.1': + optional: true + + '@esbuild/netbsd-arm64@0.25.12': + optional: true + + '@esbuild/netbsd-arm64@0.28.1': + optional: true + + '@esbuild/netbsd-x64@0.18.20': + optional: true + + '@esbuild/netbsd-x64@0.25.12': + optional: true + + '@esbuild/netbsd-x64@0.28.1': + optional: true + + '@esbuild/openbsd-arm64@0.25.12': + optional: true + + '@esbuild/openbsd-arm64@0.28.1': + optional: true + + '@esbuild/openbsd-x64@0.18.20': + optional: true + + '@esbuild/openbsd-x64@0.25.12': + optional: true + + '@esbuild/openbsd-x64@0.28.1': + optional: true + + '@esbuild/openharmony-arm64@0.25.12': + optional: true + + '@esbuild/openharmony-arm64@0.28.1': + optional: true + + '@esbuild/sunos-x64@0.18.20': + optional: true + + '@esbuild/sunos-x64@0.25.12': + optional: true + + '@esbuild/sunos-x64@0.28.1': + optional: true + + '@esbuild/win32-arm64@0.18.20': + optional: true + + '@esbuild/win32-arm64@0.25.12': + optional: true + + '@esbuild/win32-arm64@0.28.1': + optional: true + + '@esbuild/win32-ia32@0.18.20': + optional: true + + '@esbuild/win32-ia32@0.25.12': + optional: true + + '@esbuild/win32-ia32@0.28.1': + optional: true + + '@esbuild/win32-x64@0.18.20': + optional: true + + '@esbuild/win32-x64@0.25.12': + optional: true + + '@esbuild/win32-x64@0.28.1': + optional: true + + '@eslint-community/eslint-utils@4.10.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))': + dependencies: + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) eslint-visitor-keys: 3.4.3 - '@eslint-community/eslint-utils@4.9.1(eslint@9.39.5(jiti@2.7.0))': + '@eslint-community/eslint-utils@4.9.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))': dependencies: - eslint: 9.39.5(jiti@2.7.0) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.2': {} - '@eslint/config-array@0.21.2': + '@eslint/config-array@0.21.2(supports-color@7.2.0)': dependencies: '@eslint/object-schema': 2.1.7 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) minimatch: 3.1.5 transitivePeerDependencies: - supports-color @@ -2840,10 +4236,10 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 - '@eslint/eslintrc@3.3.6': + '@eslint/eslintrc@3.3.6(supports-color@7.2.0)': dependencies: ajv: 6.15.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) espree: 10.4.0 globals: 14.0.0 ignore: 5.3.2 @@ -2865,6 +4261,25 @@ snapshots: '@exodus/bytes@1.15.1': {} + '@grpc/grpc-js@1.14.4': + dependencies: + '@grpc/proto-loader': 0.8.1 + '@js-sdsl/ordered-map': 4.4.2 + + '@grpc/proto-loader@0.7.15': + dependencies: + lodash.camelcase: 4.3.0 + long: 5.3.2 + protobufjs: 7.6.5 + yargs: 17.7.3 + + '@grpc/proto-loader@0.8.1': + dependencies: + lodash.camelcase: 4.3.0 + long: 5.3.2 + protobufjs: 7.6.5 + yargs: 17.7.3 + '@humanfs/core@0.19.2': dependencies: '@humanfs/types': 0.15.0 @@ -2988,6 +4403,15 @@ snapshots: '@img/sharp-win32-x64@0.35.3': optional: true + '@isaacs/cliui@8.0.2': + dependencies: + string-width: 5.1.2 + string-width-cjs: string-width@4.2.3 + strip-ansi: 7.2.0 + strip-ansi-cjs: strip-ansi@6.0.1 + wrap-ansi: 8.1.0 + wrap-ansi-cjs: wrap-ansi@7.0.0 + '@jridgewell/gen-mapping@0.3.13': dependencies: '@jridgewell/sourcemap-codec': 1.5.5 @@ -3007,6 +4431,14 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 + '@js-sdsl/ordered-map@4.4.2': {} + + '@kwsites/file-exists@1.1.1(supports-color@7.2.0)': + dependencies: + debug: 4.4.3(supports-color@7.2.0) + transitivePeerDependencies: + - supports-color + '@napi-rs/wasm-runtime@1.2.2(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)': dependencies: '@emnapi/core': 1.10.0 @@ -3016,9 +4448,9 @@ snapshots: '@next/env@16.3.0': {} - '@next/eslint-plugin-next@16.3.0(eslint@9.39.5(jiti@2.7.0))': + '@next/eslint-plugin-next@16.3.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))': dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(jiti@2.7.0)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)) fast-glob: 3.3.1 transitivePeerDependencies: - eslint @@ -3063,6 +4495,29 @@ snapshots: '@oxc-project/types@0.143.0': {} + '@pkgjs/parseargs@0.11.0': + optional: true + + '@protobufjs/aspromise@1.1.2': {} + + '@protobufjs/base64@1.1.2': {} + + '@protobufjs/codegen@2.0.5': {} + + '@protobufjs/eventemitter@1.1.1': {} + + '@protobufjs/fetch@1.1.1': + dependencies: + '@protobufjs/aspromise': 1.1.2 + + '@protobufjs/float@1.0.2': {} + + '@protobufjs/path@1.1.2': {} + + '@protobufjs/pool@1.1.0': {} + + '@protobufjs/utf8@1.1.2': {} + '@rolldown/binding-android-arm64@1.2.3': optional: true @@ -3184,6 +4639,15 @@ snapshots: postcss: 8.5.23 tailwindcss: 4.3.3 + '@testcontainers/postgresql@12.1.0(supports-color@7.2.0)': + dependencies: + testcontainers: 12.1.0(supports-color@7.2.0) + transitivePeerDependencies: + - bare-abort-controller + - bare-buffer + - react-native-b4a + - supports-color + '@testing-library/dom@10.4.1': dependencies: '@babel/code-frame': 7.29.7 @@ -3229,16 +4693,37 @@ snapshots: '@types/deep-eql@4.0.2': {} + '@types/docker-modem@3.0.6': + dependencies: + '@types/node': 24.13.3 + '@types/ssh2': 1.15.5 + + '@types/dockerode@4.0.1': + dependencies: + '@types/docker-modem': 3.0.6 + '@types/node': 24.13.3 + '@types/ssh2': 1.15.5 + '@types/estree@1.0.9': {} '@types/json-schema@7.0.15': {} '@types/json5@0.0.29': {} + '@types/node@18.19.130': + dependencies: + undici-types: 5.26.5 + '@types/node@24.13.3': dependencies: undici-types: 7.18.2 + '@types/pg@8.21.0': + dependencies: + '@types/node': 24.13.3 + pg-protocol: 1.15.0 + pg-types: 2.2.0 + '@types/react-dom@19.2.4(@types/react@19.2.18)': dependencies: '@types/react': 19.2.18 @@ -3247,15 +4732,28 @@ snapshots: dependencies: csstype: 3.2.3 - '@typescript-eslint/eslint-plugin@8.66.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)': + '@types/ssh2-streams@0.1.13': + dependencies: + '@types/node': 24.13.3 + + '@types/ssh2@0.5.52': + dependencies: + '@types/node': 24.13.3 + '@types/ssh2-streams': 0.1.13 + + '@types/ssh2@1.15.5': + dependencies: + '@types/node': 18.19.130 + + '@typescript-eslint/eslint-plugin@8.66.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/scope-manager': 8.66.0 - '@typescript-eslint/type-utils': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) - '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/type-utils': 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.66.0 - eslint: 9.39.5(jiti@2.7.0) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) ignore: 7.0.6 natural-compare: 1.4.0 ts-api-utils: 2.5.0(typescript@5.9.3) @@ -3263,23 +4761,23 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)': + '@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/scope-manager': 8.66.0 '@typescript-eslint/types': 8.66.0 - '@typescript-eslint/typescript-estree': 8.66.0(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.66.0(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.66.0 - debug: 4.4.3 - eslint: 9.39.5(jiti@2.7.0) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.66.0(typescript@5.9.3)': + '@typescript-eslint/project-service@8.66.0(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/tsconfig-utils': 8.66.0(typescript@5.9.3) '@typescript-eslint/types': 8.66.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -3293,13 +4791,13 @@ snapshots: dependencies: typescript: 5.9.3 - '@typescript-eslint/type-utils@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)': + '@typescript-eslint/type-utils@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/types': 8.66.0 - '@typescript-eslint/typescript-estree': 8.66.0(typescript@5.9.3) - '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) - debug: 4.4.3 - eslint: 9.39.5(jiti@2.7.0) + '@typescript-eslint/typescript-estree': 8.66.0(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) ts-api-utils: 2.5.0(typescript@5.9.3) typescript: 5.9.3 transitivePeerDependencies: @@ -3307,13 +4805,13 @@ snapshots: '@typescript-eslint/types@8.66.0': {} - '@typescript-eslint/typescript-estree@8.66.0(typescript@5.9.3)': + '@typescript-eslint/typescript-estree@8.66.0(supports-color@7.2.0)(typescript@5.9.3)': dependencies: - '@typescript-eslint/project-service': 8.66.0(typescript@5.9.3) + '@typescript-eslint/project-service': 8.66.0(supports-color@7.2.0)(typescript@5.9.3) '@typescript-eslint/tsconfig-utils': 8.66.0(typescript@5.9.3) '@typescript-eslint/types': 8.66.0 '@typescript-eslint/visitor-keys': 8.66.0 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) minimatch: 10.2.6 semver: 7.8.5 tinyglobby: 0.2.17 @@ -3322,13 +4820,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3)': + '@typescript-eslint/utils@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0)) + '@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)) '@typescript-eslint/scope-manager': 8.66.0 '@typescript-eslint/types': 8.66.0 - '@typescript-eslint/typescript-estree': 8.66.0(typescript@5.9.3) - eslint: 9.39.5(jiti@2.7.0) + '@typescript-eslint/typescript-estree': 8.66.0(supports-color@7.2.0)(typescript@5.9.3) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -3408,10 +4906,10 @@ snapshots: '@unrs/resolver-binding-win32-x64-msvc@1.12.2': optional: true - '@vitejs/plugin-react@6.0.5(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0))': + '@vitejs/plugin-react@6.0.5(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))': dependencies: '@rolldown/pluginutils': 1.0.1 - vite: 8.2.1(@types/node@24.13.3)(jiti@2.7.0) + vite: 8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0) '@vitest/expect@4.1.10': dependencies: @@ -3422,13 +4920,13 @@ snapshots: chai: 6.2.2 tinyrainbow: 3.1.1 - '@vitest/mocker@4.1.10(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0))': + '@vitest/mocker@4.1.10(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))': dependencies: '@vitest/spy': 4.1.10 estree-walker: 3.0.3 magic-string: 0.30.21 optionalDependencies: - vite: 8.2.1(@types/node@24.13.3)(jiti@2.7.0) + vite: 8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0) '@vitest/pretty-format@4.1.10': dependencies: @@ -3454,6 +4952,10 @@ snapshots: convert-source-map: 2.0.0 tinyrainbow: 3.1.1 + abort-controller@3.0.0: + dependencies: + event-target-shim: 5.0.1 + acorn-jsx@5.3.2(acorn@8.18.0): dependencies: acorn: 8.18.0 @@ -3469,12 +4971,40 @@ snapshots: ansi-regex@5.0.1: {} + ansi-regex@6.2.2: {} + ansi-styles@4.3.0: dependencies: color-convert: 2.0.1 ansi-styles@5.2.0: {} + ansi-styles@6.2.3: {} + + archiver-utils@5.0.2: + dependencies: + glob: 10.5.0 + graceful-fs: 4.2.11 + is-stream: 2.0.1 + lazystream: 1.0.1 + lodash: 4.18.1 + normalize-path: 3.0.0 + readable-stream: 4.7.0 + + archiver@7.0.1: + dependencies: + archiver-utils: 5.0.2 + async: 3.2.6 + buffer-crc32: 1.0.0 + readable-stream: 4.7.0 + readdir-glob: 1.1.3 + tar-stream: 3.2.0 + zip-stream: 6.0.1 + transitivePeerDependencies: + - bare-abort-controller + - bare-buffer + - react-native-b4a + argparse@2.0.1: {} aria-query@5.3.0: @@ -3550,12 +5080,20 @@ snapshots: get-intrinsic: 1.3.0 is-array-buffer: 3.0.5 + asn1@0.2.6: + dependencies: + safer-buffer: 2.1.2 + assertion-error@2.0.1: {} ast-types-flow@0.0.8: {} async-function@1.0.0: {} + async-lock@1.4.1: {} + + async@3.2.6: {} + available-typed-arrays@1.0.7: dependencies: possible-typed-array-names: 1.1.0 @@ -3564,21 +5102,68 @@ snapshots: axobject-query@4.1.0: {} + b4a@1.8.1: {} + balanced-match@1.0.2: {} balanced-match@4.0.4: {} + bare-events@2.9.1: {} + + bare-fs@4.8.0: + dependencies: + bare-events: 2.9.1 + bare-path: 3.1.1 + bare-stream: 2.13.3(bare-events@2.9.1) + bare-url: 2.5.1 + fast-fifo: 1.3.2 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + + bare-path@3.1.1: {} + + bare-stream@2.13.3(bare-events@2.9.1): + dependencies: + b4a: 1.8.1 + streamx: 2.28.0 + teex: 1.0.1 + optionalDependencies: + bare-events: 2.9.1 + transitivePeerDependencies: + - react-native-b4a + + bare-url@2.5.1: + dependencies: + bare-path: 3.1.1 + + base64-js@1.5.1: {} + baseline-browser-mapping@2.11.12: {} + bcrypt-pbkdf@1.0.2: + dependencies: + tweetnacl: 0.14.5 + bidi-js@1.0.3: dependencies: require-from-string: 2.0.2 + bl@4.1.0: + dependencies: + buffer: 5.7.1 + inherits: 2.0.4 + readable-stream: 3.6.2 + brace-expansion@1.1.18: dependencies: balanced-match: 1.0.2 concat-map: 0.0.1 + brace-expansion@2.1.4: + dependencies: + balanced-match: 1.0.2 + brace-expansion@5.0.9: dependencies: balanced-match: 4.0.4 @@ -3595,6 +5180,25 @@ snapshots: node-releases: 2.0.53 update-browserslist-db: 1.3.0(browserslist@4.28.7) + buffer-crc32@1.0.0: {} + + buffer-from@1.1.2: {} + + buffer@5.7.1: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + buffer@6.0.3: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + buildcheck@0.0.7: + optional: true + + byline@5.0.0: {} + call-bind-apply-helpers@1.0.2: dependencies: es-errors: 1.3.0 @@ -3623,18 +5227,49 @@ snapshots: ansi-styles: 4.3.0 supports-color: 7.2.0 + chownr@1.1.4: {} + client-only@0.0.1: {} + cliui@8.0.1: + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + color-convert@2.0.1: dependencies: color-name: 1.1.4 color-name@1.1.4: {} + compress-commons@6.0.2: + dependencies: + crc-32: 1.2.2 + crc32-stream: 6.0.0 + is-stream: 2.0.1 + normalize-path: 3.0.0 + readable-stream: 4.7.0 + concat-map@0.0.1: {} convert-source-map@2.0.0: {} + core-util-is@1.0.3: {} + + cpu-features@0.0.10: + dependencies: + buildcheck: 0.0.7 + nan: 2.28.0 + optional: true + + crc-32@1.2.2: {} + + crc32-stream@6.0.0: + dependencies: + crc-32: 1.2.2 + readable-stream: 4.7.0 + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 @@ -3677,13 +5312,17 @@ snapshots: es-errors: 1.3.0 is-data-view: 1.0.2 - debug@3.2.7: + debug@3.2.7(supports-color@7.2.0): dependencies: ms: 2.1.3 + optionalDependencies: + supports-color: 7.2.0 - debug@4.4.3: + debug@4.4.3(supports-color@7.2.0): dependencies: ms: 2.1.3 + optionalDependencies: + supports-color: 7.2.0 decimal.js@10.6.0: {} @@ -3705,6 +5344,30 @@ snapshots: detect-libc@2.1.2: {} + docker-compose@1.4.2: + dependencies: + yaml: 2.9.0 + + docker-modem@5.0.7(supports-color@7.2.0): + dependencies: + debug: 4.4.3(supports-color@7.2.0) + readable-stream: 3.6.2 + split-ca: 1.0.1 + ssh2: 1.17.0 + transitivePeerDependencies: + - supports-color + + dockerode@5.0.1(supports-color@7.2.0): + dependencies: + '@balena/dockerignore': 1.0.2 + '@grpc/grpc-js': 1.14.4 + '@grpc/proto-loader': 0.7.15 + docker-modem: 5.0.7(supports-color@7.2.0) + protobufjs: 7.6.5 + tar-fs: 2.1.5 + transitivePeerDependencies: + - supports-color + doctrine@2.1.0: dependencies: esutils: 2.0.3 @@ -3713,16 +5376,36 @@ snapshots: dom-accessibility-api@0.6.3: {} + drizzle-kit@0.31.10: + dependencies: + '@drizzle-team/brocli': 0.10.2 + '@esbuild-kit/esm-loader': 2.6.5 + esbuild: 0.25.12 + tsx: 4.23.11 + + drizzle-orm@0.45.2(@types/pg@8.21.0)(pg@8.22.0): + optionalDependencies: + '@types/pg': 8.21.0 + pg: 8.22.0 + dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 es-errors: 1.3.0 gopd: 1.2.0 + eastasianwidth@0.2.0: {} + electron-to-chromium@1.5.402: {} + emoji-regex@8.0.0: {} + emoji-regex@9.2.2: {} + end-of-stream@1.4.5: + dependencies: + once: 1.4.0 + enhanced-resolve@5.24.5: dependencies: graceful-fs: 4.2.11 @@ -3843,22 +5526,105 @@ snapshots: is-date-object: 1.1.0 is-symbol: 1.1.1 + esbuild@0.18.20: + optionalDependencies: + '@esbuild/android-arm': 0.18.20 + '@esbuild/android-arm64': 0.18.20 + '@esbuild/android-x64': 0.18.20 + '@esbuild/darwin-arm64': 0.18.20 + '@esbuild/darwin-x64': 0.18.20 + '@esbuild/freebsd-arm64': 0.18.20 + '@esbuild/freebsd-x64': 0.18.20 + '@esbuild/linux-arm': 0.18.20 + '@esbuild/linux-arm64': 0.18.20 + '@esbuild/linux-ia32': 0.18.20 + '@esbuild/linux-loong64': 0.18.20 + '@esbuild/linux-mips64el': 0.18.20 + '@esbuild/linux-ppc64': 0.18.20 + '@esbuild/linux-riscv64': 0.18.20 + '@esbuild/linux-s390x': 0.18.20 + '@esbuild/linux-x64': 0.18.20 + '@esbuild/netbsd-x64': 0.18.20 + '@esbuild/openbsd-x64': 0.18.20 + '@esbuild/sunos-x64': 0.18.20 + '@esbuild/win32-arm64': 0.18.20 + '@esbuild/win32-ia32': 0.18.20 + '@esbuild/win32-x64': 0.18.20 + + esbuild@0.25.12: + optionalDependencies: + '@esbuild/aix-ppc64': 0.25.12 + '@esbuild/android-arm': 0.25.12 + '@esbuild/android-arm64': 0.25.12 + '@esbuild/android-x64': 0.25.12 + '@esbuild/darwin-arm64': 0.25.12 + '@esbuild/darwin-x64': 0.25.12 + '@esbuild/freebsd-arm64': 0.25.12 + '@esbuild/freebsd-x64': 0.25.12 + '@esbuild/linux-arm': 0.25.12 + '@esbuild/linux-arm64': 0.25.12 + '@esbuild/linux-ia32': 0.25.12 + '@esbuild/linux-loong64': 0.25.12 + '@esbuild/linux-mips64el': 0.25.12 + '@esbuild/linux-ppc64': 0.25.12 + '@esbuild/linux-riscv64': 0.25.12 + '@esbuild/linux-s390x': 0.25.12 + '@esbuild/linux-x64': 0.25.12 + '@esbuild/netbsd-arm64': 0.25.12 + '@esbuild/netbsd-x64': 0.25.12 + '@esbuild/openbsd-arm64': 0.25.12 + '@esbuild/openbsd-x64': 0.25.12 + '@esbuild/openharmony-arm64': 0.25.12 + '@esbuild/sunos-x64': 0.25.12 + '@esbuild/win32-arm64': 0.25.12 + '@esbuild/win32-ia32': 0.25.12 + '@esbuild/win32-x64': 0.25.12 + + esbuild@0.28.1: + optionalDependencies: + '@esbuild/aix-ppc64': 0.28.1 + '@esbuild/android-arm': 0.28.1 + '@esbuild/android-arm64': 0.28.1 + '@esbuild/android-x64': 0.28.1 + '@esbuild/darwin-arm64': 0.28.1 + '@esbuild/darwin-x64': 0.28.1 + '@esbuild/freebsd-arm64': 0.28.1 + '@esbuild/freebsd-x64': 0.28.1 + '@esbuild/linux-arm': 0.28.1 + '@esbuild/linux-arm64': 0.28.1 + '@esbuild/linux-ia32': 0.28.1 + '@esbuild/linux-loong64': 0.28.1 + '@esbuild/linux-mips64el': 0.28.1 + '@esbuild/linux-ppc64': 0.28.1 + '@esbuild/linux-riscv64': 0.28.1 + '@esbuild/linux-s390x': 0.28.1 + '@esbuild/linux-x64': 0.28.1 + '@esbuild/netbsd-arm64': 0.28.1 + '@esbuild/netbsd-x64': 0.28.1 + '@esbuild/openbsd-arm64': 0.28.1 + '@esbuild/openbsd-x64': 0.28.1 + '@esbuild/openharmony-arm64': 0.28.1 + '@esbuild/sunos-x64': 0.28.1 + '@esbuild/win32-arm64': 0.28.1 + '@esbuild/win32-ia32': 0.28.1 + '@esbuild/win32-x64': 0.28.1 + escalade@3.2.0: {} escape-string-regexp@4.0.0: {} - eslint-config-next@16.3.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3): + eslint-config-next@16.3.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3): dependencies: - '@next/eslint-plugin-next': 16.3.0(eslint@9.39.5(jiti@2.7.0)) - eslint: 9.39.5(jiti@2.7.0) - eslint-import-resolver-node: 0.3.10 - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)) - eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.5(jiti@2.7.0)) - eslint-plugin-react: 7.37.5(eslint@9.39.5(jiti@2.7.0)) - eslint-plugin-react-hooks: 7.1.1(eslint@9.39.5(jiti@2.7.0)) + '@next/eslint-plugin-next': 16.3.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) + eslint-import-resolver-node: 0.3.10(supports-color@7.2.0) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)) + eslint-plugin-react: 7.37.5(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)) + eslint-plugin-react-hooks: 7.1.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) globals: 16.4.0 - typescript-eslint: 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + typescript-eslint: 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) optionalDependencies: typescript: 5.9.3 transitivePeerDependencies: @@ -3867,52 +5633,52 @@ snapshots: - eslint-plugin-import-x - supports-color - eslint-import-resolver-node@0.3.10: + eslint-import-resolver-node@0.3.10(supports-color@7.2.0): dependencies: - debug: 3.2.7 + debug: 3.2.7(supports-color@7.2.0) is-core-module: 2.16.2 resolve: 2.0.0-next.7 transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)): + eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: '@nolyfill/is-core-module': 1.0.39 - debug: 4.4.3 - eslint: 9.39.5(jiti@2.7.0) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) get-tsconfig: 4.14.1 is-bun-module: 2.0.0 stable-hash: 0.0.5 tinyglobby: 0.2.17 unrs-resolver: 1.12.2 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) transitivePeerDependencies: - supports-color - eslint-module-utils@2.14.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-node@0.3.10)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)): + eslint-module-utils@2.14.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-node@0.3.10(supports-color@7.2.0))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: - debug: 3.2.7 + debug: 3.2.7(supports-color@7.2.0) optionalDependencies: - '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) - eslint: 9.39.5(jiti@2.7.0) - eslint-import-resolver-node: 0.3.10 - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)) + '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) + eslint-import-resolver-node: 0.3.10(supports-color@7.2.0) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 array.prototype.findlastindex: 1.2.6 array.prototype.flat: 1.3.3 array.prototype.flatmap: 1.3.3 - debug: 3.2.7 + debug: 3.2.7(supports-color@7.2.0) doctrine: 2.1.0 - eslint: 9.39.5(jiti@2.7.0) - eslint-import-resolver-node: 0.3.10 - eslint-module-utils: 2.14.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint-import-resolver-node@0.3.10)(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) + eslint-import-resolver-node: 0.3.10(supports-color@7.2.0) + eslint-module-utils: 2.14.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint-import-resolver-node@0.3.10(supports-color@7.2.0))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) hasown: 2.0.4 is-core-module: 2.16.2 is-glob: 4.0.3 @@ -3924,13 +5690,13 @@ snapshots: string.prototype.trimend: 1.0.10 tsconfig-paths: 3.15.0 optionalDependencies: - '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) + '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color - eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.5(jiti@2.7.0)): + eslint-plugin-jsx-a11y@6.10.2(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)): dependencies: aria-query: 5.3.2 array-includes: 3.1.9 @@ -3940,7 +5706,7 @@ snapshots: axobject-query: 4.1.0 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 9.39.5(jiti@2.7.0) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) hasown: 2.0.4 jsx-ast-utils: 3.3.5 language-tags: 1.0.9 @@ -3949,18 +5715,18 @@ snapshots: safe-regex-test: 1.1.0 string.prototype.includes: 2.0.1 - eslint-plugin-react-hooks@7.1.1(eslint@9.39.5(jiti@2.7.0)): + eslint-plugin-react-hooks@7.1.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: - '@babel/core': 7.29.7 + '@babel/core': 7.29.7(supports-color@7.2.0) '@babel/parser': 7.29.8 - eslint: 9.39.5(jiti@2.7.0) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) hermes-parser: 0.25.1 zod: 4.4.3 zod-validation-error: 4.0.2(zod@4.4.3) transitivePeerDependencies: - supports-color - eslint-plugin-react@7.37.5(eslint@9.39.5(jiti@2.7.0)): + eslint-plugin-react@7.37.5(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)): dependencies: array-includes: 3.1.9 array.prototype.findlast: 1.2.5 @@ -3968,7 +5734,7 @@ snapshots: array.prototype.tosorted: 1.1.4 doctrine: 2.1.0 es-iterator-helpers: 1.4.0 - eslint: 9.39.5(jiti@2.7.0) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) estraverse: 5.3.0 hasown: 2.0.4 jsx-ast-utils: 3.3.5 @@ -3993,14 +5759,14 @@ snapshots: eslint-visitor-keys@5.0.1: {} - eslint@9.39.5(jiti@2.7.0): + eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0): dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0)) + '@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)) '@eslint-community/regexpp': 4.12.2 - '@eslint/config-array': 0.21.2 + '@eslint/config-array': 0.21.2(supports-color@7.2.0) '@eslint/config-helpers': 0.4.2 '@eslint/core': 0.17.0 - '@eslint/eslintrc': 3.3.6 + '@eslint/eslintrc': 3.3.6(supports-color@7.2.0) '@eslint/js': 9.39.5 '@eslint/plugin-kit': 0.4.1 '@humanfs/node': 0.16.8 @@ -4010,7 +5776,7 @@ snapshots: ajv: 6.15.0 chalk: 4.1.2 cross-spawn: 7.0.6 - debug: 4.4.3 + debug: 4.4.3(supports-color@7.2.0) escape-string-regexp: 4.0.0 eslint-scope: 8.4.0 eslint-visitor-keys: 4.2.1 @@ -4056,10 +5822,22 @@ snapshots: esutils@2.0.3: {} + event-target-shim@5.0.1: {} + + events-universal@1.0.1: + dependencies: + bare-events: 2.9.1 + transitivePeerDependencies: + - bare-abort-controller + + events@3.3.0: {} + expect-type@1.4.0: {} fast-deep-equal@3.1.3: {} + fast-fifo@1.3.2: {} + fast-glob@3.3.1: dependencies: '@nodelib/fs.stat': 2.0.5 @@ -4104,6 +5882,13 @@ snapshots: dependencies: is-callable: 1.2.7 + foreground-child@3.3.1: + dependencies: + cross-spawn: 7.0.6 + signal-exit: 4.1.0 + + fs-constants@1.0.0: {} + fsevents@2.3.3: optional: true @@ -4127,6 +5912,8 @@ snapshots: gensync@1.0.0-beta.2: {} + get-caller-file@2.0.5: {} + get-intrinsic@1.3.0: dependencies: call-bind-apply-helpers: 1.0.2 @@ -4140,6 +5927,8 @@ snapshots: hasown: 2.0.4 math-intrinsics: 1.1.0 + get-port@5.1.1: {} + get-proto@1.0.1: dependencies: dunder-proto: 1.0.1 @@ -4163,6 +5952,15 @@ snapshots: dependencies: is-glob: 4.0.3 + glob@10.5.0: + dependencies: + foreground-child: 3.3.1 + jackspeak: 3.4.3 + minimatch: 9.0.9 + minipass: 7.1.3 + package-json-from-dist: 1.0.1 + path-scurry: 1.11.1 + globals@14.0.0: {} globals@16.4.0: {} @@ -4210,6 +6008,8 @@ snapshots: transitivePeerDependencies: - '@noble/hashes' + ieee754@1.2.1: {} + ignore@5.3.2: {} ignore@7.0.6: {} @@ -4223,6 +6023,8 @@ snapshots: indent-string@4.0.0: {} + inherits@2.0.4: {} + internal-slot@1.1.0: dependencies: es-errors: 1.3.0 @@ -4283,6 +6085,8 @@ snapshots: dependencies: call-bound: 1.0.4 + is-fullwidth-code-point@3.0.0: {} + is-generator-function@1.1.2: dependencies: call-bound: 1.0.4 @@ -4321,6 +6125,8 @@ snapshots: dependencies: call-bound: 1.0.4 + is-stream@2.0.1: {} + is-string@1.1.1: dependencies: call-bound: 1.0.4 @@ -4347,6 +6153,8 @@ snapshots: call-bound: 1.0.4 get-intrinsic: 1.3.0 + isarray@1.0.0: {} + isarray@2.0.5: {} isexe@2.0.0: {} @@ -4360,6 +6168,12 @@ snapshots: has-symbols: 1.1.0 set-function-name: 2.0.2 + jackspeak@3.4.3: + dependencies: + '@isaacs/cliui': 8.0.2 + optionalDependencies: + '@pkgjs/parseargs': 0.11.0 + jiti@2.7.0: {} js-tokens@4.0.0: {} @@ -4425,6 +6239,10 @@ snapshots: dependencies: language-subtag-registry: 0.3.23 + lazystream@1.0.1: + dependencies: + readable-stream: 2.3.8 + levn@0.4.1: dependencies: prelude-ls: 1.2.1 @@ -4532,12 +6350,20 @@ snapshots: dependencies: p-locate: 5.0.0 + lodash.camelcase@4.3.0: {} + lodash.merge@4.6.2: {} + lodash@4.18.1: {} + + long@5.3.2: {} + loose-envify@1.4.0: dependencies: js-tokens: 4.0.0 + lru-cache@10.4.3: {} + lru-cache@11.5.2: {} lru-cache@5.1.1: @@ -4571,17 +6397,34 @@ snapshots: dependencies: brace-expansion: 1.1.18 + minimatch@5.1.9: + dependencies: + brace-expansion: 2.1.4 + + minimatch@9.0.9: + dependencies: + brace-expansion: 2.1.4 + minimist@1.2.8: {} + minipass@7.1.3: {} + + mkdirp-classic@0.5.3: {} + + mkdirp@3.0.1: {} + ms@2.1.3: {} + nan@2.28.0: + optional: true + nanoid@3.3.18: {} napi-postinstall@0.3.4: {} natural-compare@1.4.0: {} - next@16.3.0(@babel/core@7.29.7)(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8): + next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8): dependencies: '@next/env': 16.3.0 '@swc/helpers': 0.5.15 @@ -4590,7 +6433,7 @@ snapshots: postcss: 8.5.23 react: 19.2.8 react-dom: 19.2.8(react@19.2.8) - styled-jsx: 5.1.6(@babel/core@7.29.7)(react@19.2.8) + styled-jsx: 5.1.6(@babel/core@7.29.7(supports-color@7.2.0))(react@19.2.8) optionalDependencies: '@next/swc-darwin-arm64': 16.3.0 '@next/swc-darwin-x64': 16.3.0 @@ -4615,6 +6458,8 @@ snapshots: node-releases@2.0.53: {} + normalize-path@3.0.0: {} + object-assign@4.1.1: {} object-inspect@1.13.4: {} @@ -4659,6 +6504,10 @@ snapshots: obug@2.1.4: {} + once@1.4.0: + dependencies: + wrappy: 1.0.2 + optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -4683,6 +6532,8 @@ snapshots: dependencies: p-limit: 3.1.0 + package-json-from-dist@1.0.1: {} + parent-module@1.0.1: dependencies: callsites: 3.1.0 @@ -4697,8 +6548,48 @@ snapshots: path-parse@1.0.7: {} + path-scurry@1.11.1: + dependencies: + lru-cache: 10.4.3 + minipass: 7.1.3 + pathe@2.0.3: {} + pg-cloudflare@1.4.0: + optional: true + + pg-connection-string@2.14.0: {} + + pg-int8@1.0.1: {} + + pg-pool@3.14.0(pg@8.22.0): + dependencies: + pg: 8.22.0 + + pg-protocol@1.15.0: {} + + pg-types@2.2.0: + dependencies: + pg-int8: 1.0.1 + postgres-array: 2.0.0 + postgres-bytea: 1.0.1 + postgres-date: 1.0.7 + postgres-interval: 1.2.0 + + pg@8.22.0: + dependencies: + pg-connection-string: 2.14.0 + pg-pool: 3.14.0(pg@8.22.0) + pg-protocol: 1.15.0 + pg-types: 2.2.0 + pgpass: 1.0.5 + optionalDependencies: + pg-cloudflare: 1.4.0 + + pgpass@1.0.5: + dependencies: + split2: 4.2.0 + picocolors@1.1.1: {} picomatch@2.3.2: {} @@ -4719,6 +6610,16 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + postgres-array@2.0.0: {} + + postgres-bytea@1.0.1: {} + + postgres-date@1.0.7: {} + + postgres-interval@1.2.0: + dependencies: + xtend: 4.0.2 + prelude-ls@1.2.1: {} pretty-format@27.5.1: @@ -4727,12 +6628,48 @@ snapshots: ansi-styles: 5.2.0 react-is: 17.0.2 + process-nextick-args@2.0.1: {} + + process@0.11.10: {} + prop-types@15.8.1: dependencies: loose-envify: 1.4.0 object-assign: 4.1.1 react-is: 16.13.1 + proper-lockfile@4.1.2: + dependencies: + graceful-fs: 4.2.11 + retry: 0.12.0 + signal-exit: 3.0.7 + + properties-reader@3.0.1(supports-color@7.2.0): + dependencies: + '@kwsites/file-exists': 1.1.1(supports-color@7.2.0) + mkdirp: 3.0.1 + transitivePeerDependencies: + - supports-color + + protobufjs@7.6.5: + dependencies: + '@protobufjs/aspromise': 1.1.2 + '@protobufjs/base64': 1.1.2 + '@protobufjs/codegen': 2.0.5 + '@protobufjs/eventemitter': 1.1.1 + '@protobufjs/fetch': 1.1.1 + '@protobufjs/float': 1.0.2 + '@protobufjs/path': 1.1.2 + '@protobufjs/pool': 1.1.0 + '@protobufjs/utf8': 1.1.2 + '@types/node': 24.13.3 + long: 5.3.2 + + pump@3.0.4: + dependencies: + end-of-stream: 1.4.5 + once: 1.4.0 + punycode@2.3.1: {} queue-microtask@1.2.3: {} @@ -4748,6 +6685,34 @@ snapshots: react@19.2.8: {} + readable-stream@2.3.8: + dependencies: + core-util-is: 1.0.3 + inherits: 2.0.4 + isarray: 1.0.0 + process-nextick-args: 2.0.1 + safe-buffer: 5.1.2 + string_decoder: 1.1.1 + util-deprecate: 1.0.2 + + readable-stream@3.6.2: + dependencies: + inherits: 2.0.4 + string_decoder: 1.3.0 + util-deprecate: 1.0.2 + + readable-stream@4.7.0: + dependencies: + abort-controller: 3.0.0 + buffer: 6.0.3 + events: 3.3.0 + process: 0.11.10 + string_decoder: 1.3.0 + + readdir-glob@1.1.3: + dependencies: + minimatch: 5.1.9 + redent@3.0.0: dependencies: indent-string: 4.0.0 @@ -4773,6 +6738,8 @@ snapshots: gopd: 1.2.0 set-function-name: 2.0.2 + require-directory@2.1.1: {} + require-from-string@2.0.2: {} resolve-from@4.0.0: {} @@ -4788,6 +6755,8 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 + retry@0.12.0: {} + reusify@1.1.0: {} rolldown@1.2.3: @@ -4822,6 +6791,10 @@ snapshots: has-symbols: 1.1.0 isarray: 2.0.5 + safe-buffer@5.1.2: {} + + safe-buffer@5.2.1: {} + safe-push-apply@1.0.0: dependencies: es-errors: 1.3.0 @@ -4833,6 +6806,8 @@ snapshots: es-errors: 1.3.0 is-regex: 1.2.1 + safer-buffer@2.1.2: {} + saxes@6.0.0: dependencies: xmlchars: 2.2.0 @@ -4937,8 +6912,36 @@ snapshots: siginfo@2.0.0: {} + signal-exit@3.0.7: {} + + signal-exit@4.1.0: {} + source-map-js@1.2.1: {} + source-map-support@0.5.21: + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + + source-map@0.6.1: {} + + split-ca@1.0.1: {} + + split2@4.2.0: {} + + ssh-remote-port-forward@1.0.4: + dependencies: + '@types/ssh2': 0.5.52 + ssh2: 1.17.0 + + ssh2@1.17.0: + dependencies: + asn1: 0.2.6 + bcrypt-pbkdf: 1.0.2 + optionalDependencies: + cpu-features: 0.0.10 + nan: 2.28.0 + stable-hash@0.0.5: {} stackback@0.0.2: {} @@ -4950,6 +6953,27 @@ snapshots: es-errors: 1.3.0 internal-slot: 1.1.0 + streamx@2.28.0: + dependencies: + events-universal: 1.0.1 + fast-fifo: 1.3.2 + text-decoder: 1.2.7 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + + string-width@4.2.3: + dependencies: + emoji-regex: 8.0.0 + is-fullwidth-code-point: 3.0.0 + strip-ansi: 6.0.1 + + string-width@5.1.2: + dependencies: + eastasianwidth: 0.2.0 + emoji-regex: 9.2.2 + strip-ansi: 7.2.0 + string.prototype.includes@2.0.1: dependencies: call-bind: 1.0.9 @@ -5001,6 +7025,22 @@ snapshots: define-properties: 1.2.1 es-object-atoms: 1.1.2 + string_decoder@1.1.1: + dependencies: + safe-buffer: 5.1.2 + + string_decoder@1.3.0: + dependencies: + safe-buffer: 5.2.1 + + strip-ansi@6.0.1: + dependencies: + ansi-regex: 5.0.1 + + strip-ansi@7.2.0: + dependencies: + ansi-regex: 6.2.2 + strip-bom@3.0.0: {} strip-indent@3.0.0: @@ -5009,12 +7049,12 @@ snapshots: strip-json-comments@3.1.1: {} - styled-jsx@5.1.6(@babel/core@7.29.7)(react@19.2.8): + styled-jsx@5.1.6(@babel/core@7.29.7(supports-color@7.2.0))(react@19.2.8): dependencies: client-only: 0.0.1 react: 19.2.8 optionalDependencies: - '@babel/core': 7.29.7 + '@babel/core': 7.29.7(supports-color@7.2.0) supports-color@7.2.0: dependencies: @@ -5028,6 +7068,80 @@ snapshots: tapable@2.3.3: {} + tar-fs@2.1.5: + dependencies: + chownr: 1.1.4 + mkdirp-classic: 0.5.3 + pump: 3.0.4 + tar-stream: 2.2.0 + + tar-fs@3.1.3: + dependencies: + pump: 3.0.4 + tar-stream: 3.2.0 + optionalDependencies: + bare-fs: 4.8.0 + bare-path: 3.1.1 + transitivePeerDependencies: + - bare-abort-controller + - bare-buffer + - react-native-b4a + + tar-stream@2.2.0: + dependencies: + bl: 4.1.0 + end-of-stream: 1.4.5 + fs-constants: 1.0.0 + inherits: 2.0.4 + readable-stream: 3.6.2 + + tar-stream@3.2.0: + dependencies: + b4a: 1.8.1 + bare-fs: 4.8.0 + fast-fifo: 1.3.2 + streamx: 2.28.0 + transitivePeerDependencies: + - bare-abort-controller + - bare-buffer + - react-native-b4a + + teex@1.0.1: + dependencies: + streamx: 2.28.0 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + + testcontainers@12.1.0(supports-color@7.2.0): + dependencies: + '@balena/dockerignore': 1.0.2 + '@types/dockerode': 4.0.1 + archiver: 7.0.1 + async-lock: 1.4.1 + byline: 5.0.0 + debug: 4.4.3(supports-color@7.2.0) + docker-compose: 1.4.2 + dockerode: 5.0.1(supports-color@7.2.0) + get-port: 5.1.1 + proper-lockfile: 4.1.2 + properties-reader: 3.0.1(supports-color@7.2.0) + ssh-remote-port-forward: 1.0.4 + tar-fs: 3.1.3 + tmp: 0.2.7 + undici: 8.10.0 + transitivePeerDependencies: + - bare-abort-controller + - bare-buffer + - react-native-b4a + - supports-color + + text-decoder@1.2.7: + dependencies: + b4a: 1.8.1 + transitivePeerDependencies: + - react-native-b4a + tinybench@2.9.0: {} tinyexec@1.3.0: {} @@ -5045,6 +7159,8 @@ snapshots: dependencies: tldts-core: 7.4.10 + tmp@0.2.7: {} + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 @@ -5070,6 +7186,14 @@ snapshots: tslib@2.8.1: {} + tsx@4.23.11: + dependencies: + esbuild: 0.28.1 + optionalDependencies: + fsevents: 2.3.3 + + tweetnacl@0.14.5: {} + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 @@ -5107,13 +7231,13 @@ snapshots: possible-typed-array-names: 1.1.0 reflect.getprototypeof: 1.0.10 - typescript-eslint@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3): + typescript-eslint@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.66.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) - '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) - '@typescript-eslint/typescript-estree': 8.66.0(typescript@5.9.3) - '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0))(typescript@5.9.3) - eslint: 9.39.5(jiti@2.7.0) + '@typescript-eslint/eslint-plugin': 8.66.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/parser': 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.66.0(supports-color@7.2.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) + eslint: 9.39.5(jiti@2.7.0)(supports-color@7.2.0) typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -5127,6 +7251,8 @@ snapshots: has-symbols: 1.1.0 which-boxed-primitive: 1.1.1 + undici-types@5.26.5: {} + undici-types@7.18.2: {} undici@8.10.0: {} @@ -5168,7 +7294,9 @@ snapshots: dependencies: punycode: 2.3.1 - vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0): + util-deprecate@1.0.2: {} + + vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0): dependencies: lightningcss: 1.33.0 picomatch: 4.0.5 @@ -5177,13 +7305,16 @@ snapshots: tinyglobby: 0.2.17 optionalDependencies: '@types/node': 24.13.3 + esbuild: 0.28.1 fsevents: 2.3.3 jiti: 2.7.0 + tsx: 4.23.11 + yaml: 2.9.0 - vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1)(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0)): + vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1)(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)): dependencies: '@vitest/expect': 4.1.10 - '@vitest/mocker': 4.1.10(vite@8.2.1(@types/node@24.13.3)(jiti@2.7.0)) + '@vitest/mocker': 4.1.10(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) '@vitest/pretty-format': 4.1.10 '@vitest/runner': 4.1.10 '@vitest/snapshot': 4.1.10 @@ -5200,7 +7331,7 @@ snapshots: tinyexec: 1.3.0 tinyglobby: 0.2.17 tinyrainbow: 3.1.1 - vite: 8.2.1(@types/node@24.13.3)(jiti@2.7.0) + vite: 8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 24.13.3 @@ -5284,14 +7415,52 @@ snapshots: word-wrap@1.2.5: {} + wrap-ansi@7.0.0: + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + + wrap-ansi@8.1.0: + dependencies: + ansi-styles: 6.2.3 + string-width: 5.1.2 + strip-ansi: 7.2.0 + + wrappy@1.0.2: {} + xml-name-validator@5.0.0: {} xmlchars@2.2.0: {} + xtend@4.0.2: {} + + y18n@5.0.8: {} + yallist@3.1.1: {} + yaml@2.9.0: {} + + yargs-parser@21.1.1: {} + + yargs@17.7.3: + dependencies: + cliui: 8.0.1 + escalade: 3.2.0 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 21.1.1 + yocto-queue@0.1.0: {} + zip-stream@6.0.1: + dependencies: + archiver-utils: 5.0.2 + compress-commons: 6.0.2 + readable-stream: 4.7.0 + zod-validation-error@4.0.2(zod@4.4.3): dependencies: zod: 4.4.3 diff --git a/src/db/client.ts b/src/db/client.ts new file mode 100644 index 0000000..827695a --- /dev/null +++ b/src/db/client.ts @@ -0,0 +1,10 @@ +import "server-only"; + +import { drizzle, type NodePgDatabase } from "drizzle-orm/node-postgres"; +import { Pool } from "pg"; + +import { env } from "@/config/env"; +import * as schema from "./schema"; + +export const pool = new Pool({ connectionString: env.DATABASE_URL }); +export const db: NodePgDatabase = drizzle({ client: pool, schema }); diff --git a/src/db/schema/albums.ts b/src/db/schema/albums.ts new file mode 100644 index 0000000..85a8475 --- /dev/null +++ b/src/db/schema/albums.ts @@ -0,0 +1,24 @@ +import { index, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; + +import { users } from "./auth"; +import { editorialAccounts } from "./editorials"; + +export const albumGrants = pgTable( + "album_grants", + { + id: uuid("id").defaultRandom().primaryKey(), + editorialAccountId: uuid("editorial_account_id") + .notNull() + .references(() => editorialAccounts.id, { onDelete: "restrict" }), + immichAlbumId: text("immich_album_id").notNull(), + grantedAt: timestamp("granted_at", { withTimezone: true }).notNull().defaultNow(), + revokedAt: timestamp("revoked_at", { withTimezone: true }), + grantedByUserId: uuid("granted_by_user_id").references(() => users.id, { + onDelete: "restrict", + }), + }, + (table) => [ + index("album_grants_editorial_account_id_idx").on(table.editorialAccountId), + index("album_grants_immich_album_id_idx").on(table.immichAlbumId), + ], +); diff --git a/src/db/schema/audit.ts b/src/db/schema/audit.ts new file mode 100644 index 0000000..dd630f7 --- /dev/null +++ b/src/db/schema/audit.ts @@ -0,0 +1,16 @@ +import { jsonb, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; + +import { users } from "./auth"; + +export const auditEvents = pgTable("audit_events", { + id: uuid("id").defaultRandom().primaryKey(), + eventType: text("event_type").notNull(), + actorUserId: uuid("actor_user_id").references(() => users.id, { onDelete: "restrict" }), + actorType: text("actor_type").notNull().default("system"), + entityType: text("entity_type").notNull(), + entityId: text("entity_id").notNull(), + previousValues: jsonb("previous_values"), + newValues: jsonb("new_values"), + occurredAt: timestamp("occurred_at", { withTimezone: true }).notNull().defaultNow(), + requestId: uuid("request_id"), +}); diff --git a/src/db/schema/auth.ts b/src/db/schema/auth.ts new file mode 100644 index 0000000..42c003f --- /dev/null +++ b/src/db/schema/auth.ts @@ -0,0 +1,55 @@ +import { boolean, pgEnum, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; + +export const portalRoles = ["ADMIN", "EDITORIAL"] as const; +export const portalRole = pgEnum("portal_role", portalRoles); + +export const users = pgTable("user", { + id: uuid("id").defaultRandom().primaryKey(), + name: text("name").notNull(), + email: text("email").notNull().unique(), + emailVerified: boolean("email_verified").notNull().default(false), + image: text("image"), + role: portalRole("role").notNull().default("EDITORIAL"), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(), +}); + +export const accounts = pgTable("account", { + id: uuid("id").defaultRandom().primaryKey(), + accountId: text("account_id").notNull(), + providerId: text("provider_id").notNull(), + userId: uuid("user_id") + .notNull() + .references(() => users.id, { onDelete: "restrict" }), + accessToken: text("access_token"), + refreshToken: text("refresh_token"), + idToken: text("id_token"), + accessTokenExpiresAt: timestamp("access_token_expires_at", { withTimezone: true }), + refreshTokenExpiresAt: timestamp("refresh_token_expires_at", { withTimezone: true }), + scope: text("scope"), + password: text("password"), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(), +}); + +export const sessions = pgTable("session", { + id: uuid("id").defaultRandom().primaryKey(), + expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(), + token: text("token").notNull().unique(), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(), + ipAddress: text("ip_address"), + userAgent: text("user_agent"), + userId: uuid("user_id") + .notNull() + .references(() => users.id, { onDelete: "restrict" }), +}); + +export const verifications = pgTable("verification", { + id: uuid("id").defaultRandom().primaryKey(), + identifier: text("identifier").notNull(), + value: text("value").notNull(), + expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(), +}); diff --git a/src/db/schema/billing.ts b/src/db/schema/billing.ts new file mode 100644 index 0000000..bcd7f75 --- /dev/null +++ b/src/db/schema/billing.ts @@ -0,0 +1,91 @@ +import { sql } from "drizzle-orm"; +import { + check, + customType, + integer, + jsonb, + pgEnum, + pgTable, + text, + timestamp, + uniqueIndex, + uuid, + varchar, +} from "drizzle-orm/pg-core"; + +import { users } from "./auth"; +import { editorialAccounts } from "./editorials"; +import { usages } from "./usages"; + +export const reportStatuses = ["draft", "final", "cancelled"] as const; +export const reportStatus = pgEnum("report_status", reportStatuses); + +const bytea = customType<{ data: Buffer; driverData: Buffer }>({ + dataType() { + return "bytea"; + }, +}); + +export const billingReports = pgTable( + "billing_reports", + { + id: uuid("id").defaultRandom().primaryKey(), + reportNumber: integer("report_number").notNull(), + editorialAccountId: uuid("editorial_account_id") + .notNull() + .references(() => editorialAccounts.id, { onDelete: "restrict" }), + periodStartsAt: timestamp("period_starts_at", { withTimezone: true }).notNull(), + periodEndsAt: timestamp("period_ends_at", { withTimezone: true }).notNull(), + billingAddressSnapshot: jsonb("billing_address_snapshot").notNull(), + invoiceNumber: text("invoice_number"), + netTotalCents: integer("net_total_cents").notNull(), + status: reportStatus("status").notNull().default("draft"), + pdf: bytea("pdf"), + pdfSha256: varchar("pdf_sha256", { length: 64 }), + createdByUserId: uuid("created_by_user_id") + .notNull() + .references(() => users.id, { onDelete: "restrict" }), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + finalizedAt: timestamp("finalized_at", { withTimezone: true }), + cancelledAt: timestamp("cancelled_at", { withTimezone: true }), + cancellationReason: text("cancellation_reason"), + cancelledByUserId: uuid("cancelled_by_user_id").references(() => users.id, { + onDelete: "restrict", + }), + }, + (table) => [ + uniqueIndex("billing_reports_report_number_unique").on(table.reportNumber), + uniqueIndex("billing_reports_invoice_number_unique").on(table.invoiceNumber), + check("billing_reports_pdf_sha256_hex_check", sql`${table.pdfSha256} ~ '^[0-9a-f]{64}$'`), + check( + "billing_reports_final_pdf_check", + sql`${table.status} <> 'final' OR (${table.pdf} IS NOT NULL AND ${table.pdfSha256} IS NOT NULL)`, + ), + ], +); + +export const billingReportItems = pgTable( + "billing_report_items", + { + id: uuid("id").defaultRandom().primaryKey(), + billingReportId: uuid("billing_report_id") + .notNull() + .references(() => billingReports.id, { onDelete: "restrict" }), + usageId: uuid("usage_id") + .notNull() + .references(() => usages.id, { onDelete: "restrict" }), + immichAssetIdSnapshot: text("immich_asset_id_snapshot").notNull(), + filenameSnapshot: text("filename_snapshot").notNull(), + albumNameSnapshot: text("album_name_snapshot").notNull(), + purposeSnapshot: text("purpose_snapshot").notNull(), + internalReferenceSnapshot: text("internal_reference_snapshot"), + priceCents: integer("price_cents").notNull(), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + }, + (table) => [ + uniqueIndex("billing_report_items_report_usage_unique").on( + table.billingReportId, + table.usageId, + ), + ], +); diff --git a/src/db/schema/editorials.ts b/src/db/schema/editorials.ts new file mode 100644 index 0000000..3f58e82 --- /dev/null +++ b/src/db/schema/editorials.ts @@ -0,0 +1,78 @@ +import { relations } from "drizzle-orm"; +import { type AnyPgColumn, integer, pgEnum, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; + +import { users } from "./auth"; + +export const accountStatuses = [ + "pending_email", + "pending_approval", + "active", + "suspended", + "rejected", +] as const; +export const accountStatus = pgEnum("account_status", accountStatuses); + +export const editorialAccounts = pgTable("editorial_accounts", { + id: uuid("id").defaultRandom().primaryKey(), + userId: uuid("user_id") + .notNull() + .unique() + .references(() => users.id, { onDelete: "restrict" }), + name: text("name").notNull(), + contactName: text("contact_name").notNull(), + loginEmail: text("login_email").notNull().unique(), + status: accountStatus("status").notNull().default("pending_email"), + currentPriceCents: integer("current_price_cents"), + currentBillingAddressVersionId: uuid("current_billing_address_version_id").references( + (): AnyPgColumn => billingAddressVersions.id, + { onDelete: "restrict" }, + ), + emailVerifiedAt: timestamp("email_verified_at", { withTimezone: true }), + acceptedTermsVersion: text("accepted_terms_version"), + acceptedTermsAt: timestamp("accepted_terms_at", { withTimezone: true }), + privacyAcknowledgedAt: timestamp("privacy_acknowledged_at", { withTimezone: true }), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(), +}); + +export const billingAddressVersions = pgTable("billing_address_versions", { + id: uuid("id").defaultRandom().primaryKey(), + editorialAccountId: uuid("editorial_account_id") + .notNull() + .references(() => editorialAccounts.id, { onDelete: "restrict" }), + companyName: text("company_name").notNull(), + contactName: text("contact_name").notNull(), + addressLine1: text("address_line_1").notNull(), + addressLine2: text("address_line_2"), + postalCode: text("postal_code").notNull(), + city: text("city").notNull(), + countryCode: text("country_code").notNull(), + validFrom: timestamp("valid_from", { withTimezone: true }).notNull().defaultNow(), + supersededById: uuid("superseded_by_id").references((): AnyPgColumn => billingAddressVersions.id, { + onDelete: "restrict", + }), + createdByUserId: uuid("created_by_user_id").references(() => users.id, { + onDelete: "restrict", + }), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), +}); + +export const editorialAccountsRelations = relations(editorialAccounts, ({ one, many }) => ({ + user: one(users, { + fields: [editorialAccounts.userId], + references: [users.id], + }), + billingAddressVersions: many(billingAddressVersions), +})); + +export const billingAddressVersionsRelations = relations(billingAddressVersions, ({ one }) => ({ + editorialAccount: one(editorialAccounts, { + fields: [billingAddressVersions.editorialAccountId], + references: [editorialAccounts.id], + }), + supersededBy: one(billingAddressVersions, { + fields: [billingAddressVersions.supersededById], + references: [billingAddressVersions.id], + relationName: "supersededBillingAddressVersion", + }), +})); diff --git a/src/db/schema/index.ts b/src/db/schema/index.ts new file mode 100644 index 0000000..d8ec443 --- /dev/null +++ b/src/db/schema/index.ts @@ -0,0 +1,6 @@ +export * from "./albums"; +export * from "./audit"; +export * from "./auth"; +export * from "./billing"; +export * from "./editorials"; +export * from "./usages"; diff --git a/src/db/schema/usages.ts b/src/db/schema/usages.ts new file mode 100644 index 0000000..11c7bed --- /dev/null +++ b/src/db/schema/usages.ts @@ -0,0 +1,63 @@ +import { integer, pgEnum, pgTable, text, timestamp, uniqueIndex, uuid, bigint } from "drizzle-orm/pg-core"; + +import { editorialAccounts } from "./editorials"; +import { billingReports } from "./billing"; + +export const usageBillingStatuses = ["open", "billed", "reopened"] as const; +export const usageBillingStatus = pgEnum("usage_billing_status", usageBillingStatuses); + +export const downloadStatuses = [ + "authorized", + "streaming", + "completed", + "failed_before_delivery", + "interrupted", +] as const; +export const downloadStatus = pgEnum("download_status", downloadStatuses); + +export const usages = pgTable("usages", { + id: uuid("id").defaultRandom().primaryKey(), + editorialAccountId: uuid("editorial_account_id") + .notNull() + .references(() => editorialAccounts.id, { onDelete: "restrict" }), + immichAssetId: text("immich_asset_id").notNull(), + filenameSnapshot: text("filename_snapshot").notNull(), + immichAlbumIdSnapshot: text("immich_album_id_snapshot").notNull(), + albumNameSnapshot: text("album_name_snapshot").notNull(), + purpose: text("purpose").notNull(), + internalReference: text("internal_reference"), + priceCents: integer("price_cents").notNull(), + billingStatus: usageBillingStatus("billing_status").notNull().default("open"), + billingReportId: uuid("billing_report_id").references(() => billingReports.id, { + onDelete: "restrict", + }), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), +}); + +export const downloadEvents = pgTable( + "download_events", + { + id: uuid("id").defaultRandom().primaryKey(), + editorialAccountId: uuid("editorial_account_id") + .notNull() + .references(() => editorialAccounts.id, { onDelete: "restrict" }), + usageId: uuid("usage_id") + .notNull() + .references(() => usages.id, { onDelete: "restrict" }), + immichAssetId: text("immich_asset_id").notNull(), + authorizedAt: timestamp("authorized_at", { withTimezone: true }).notNull().defaultNow(), + startedAt: timestamp("started_at", { withTimezone: true }), + completedAt: timestamp("completed_at", { withTimezone: true }), + status: downloadStatus("status").notNull().default("authorized"), + transferredBytes: bigint("transferred_bytes", { mode: "number" }), + repeatDownloadNote: text("repeat_download_note"), + requestId: uuid("request_id").notNull(), + idempotencyKey: text("idempotency_key").notNull(), + }, + (table) => [ + uniqueIndex("download_events_editorial_idempotency_key_unique").on( + table.editorialAccountId, + table.idempotencyKey, + ), + ], +); diff --git a/tests/db/postgres.ts b/tests/db/postgres.ts new file mode 100644 index 0000000..ff9364a --- /dev/null +++ b/tests/db/postgres.ts @@ -0,0 +1,97 @@ +import { randomUUID } from "node:crypto"; +import { readFile } from "node:fs/promises"; +import path from "node:path"; + +import { PostgreSqlContainer, type StartedPostgreSqlContainer } from "@testcontainers/postgresql"; +import { drizzle, type NodePgDatabase } from "drizzle-orm/node-postgres"; +import { Pool } from "pg"; + +import * as schema from "@/db/schema"; + +type DownloadSeed = { + editorialId: string; + usageId: string; + assetId: string; +}; + +export type PostgresTestDatabase = { + seedEditorialWithUsage(): Promise; + insertDownload(input: DownloadSeed & { idempotencyKey: string }): Promise; + stop(): Promise; +}; + +export async function startPostgres(): Promise { + const container = await new PostgreSqlContainer("postgres:17-alpine") + .withDatabase("portal") + .withUsername("portal") + .withPassword("portal") + .start(); + const pool = new Pool({ connectionString: container.getConnectionUri() }); + + await applyMigration(pool); + + const db = drizzle({ client: pool, schema }); + + return { + async seedEditorialWithUsage() { + return seedEditorialWithUsage(db); + }, + async insertDownload(input) { + await db.insert(schema.downloadEvents).values({ + editorialAccountId: input.editorialId, + usageId: input.usageId, + immichAssetId: input.assetId, + requestId: randomUUID(), + idempotencyKey: input.idempotencyKey, + }); + }, + async stop() { + await pool.end(); + await stopContainer(container); + }, + }; +} + +async function applyMigration(pool: Pool) { + const migration = await readFile(path.join(process.cwd(), "drizzle/0000_initial.sql"), "utf8"); + await pool.query(migration); +} + +async function seedEditorialWithUsage(db: NodePgDatabase): Promise { + const userId = randomUUID(); + const editorialId = randomUUID(); + const usageId = randomUUID(); + const assetId = "immich-asset-1"; + + await db.insert(schema.users).values({ + id: userId, + name: "Test Redaktion", + email: `test-${userId}@example.com`, + emailVerified: true, + }); + await db.insert(schema.editorialAccounts).values({ + id: editorialId, + userId, + name: "Test Redaktion", + contactName: "Testkontakt", + loginEmail: `test-${userId}@example.com`, + status: "active", + currentPriceCents: 1500, + }); + await db.insert(schema.usages).values({ + id: usageId, + editorialAccountId: editorialId, + immichAssetId: assetId, + filenameSnapshot: "bild.jpg", + immichAlbumIdSnapshot: "immich-album-1", + albumNameSnapshot: "Presse", + purpose: "Artikel", + priceCents: 1500, + }); + + return { editorialId, usageId, assetId }; +} + +async function stopContainer(container: StartedPostgreSqlContainer) { + await container.stop(); +} diff --git a/tests/db/schema.test.ts b/tests/db/schema.test.ts new file mode 100644 index 0000000..9923674 --- /dev/null +++ b/tests/db/schema.test.ts @@ -0,0 +1,16 @@ +import { afterAll, expect, test } from "vitest"; +import { startPostgres } from "./postgres"; + +const testDb = await startPostgres(); + +afterAll(() => testDb.stop()); + +test("rejects duplicate download idempotency keys for one editorial", async () => { + const seed = await testDb.seedEditorialWithUsage(); + + await testDb.insertDownload({ ...seed, idempotencyKey: "same-request" }); + + await expect( + testDb.insertDownload({ ...seed, idempotencyKey: "same-request" }), + ).rejects.toThrow(); +}); diff --git a/vitest.config.ts b/vitest.config.ts index f7bd1bb..24cdc9f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -7,6 +7,7 @@ const rootDirectory = path.dirname(fileURLToPath(import.meta.url)); export default defineConfig({ resolve: { alias: { + "@": path.join(rootDirectory, "src"), "server-only": path.join(rootDirectory, "src/test/server-only.ts"), }, }, @@ -27,6 +28,6 @@ export default defineConfig({ LEGAL_PRIVACY_URL: "https://example.com/datenschutz", LEGAL_TERMS_URL: "https://example.com/nutzungsbedingungen", }, - include: ["src/**/*.test.ts", "src/**/*.test.tsx"], + include: ["src/**/*.test.ts", "src/**/*.test.tsx", "tests/**/*.test.ts"], }, }); From 9b22752ef26abbbad290674f9c65664c720c3e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 20:48:43 +0200 Subject: [PATCH 03/29] feat: add editorial registration and authentication --- package.json | 4 + pnpm-lock.yaml | 367 +++++++++++++++++- pnpm-workspace.yaml | 4 + src/app/(public)/anmelden/page.tsx | 38 ++ src/app/(public)/passwort-vergessen/page.tsx | 25 ++ .../(public)/passwort-zuruecksetzen/page.tsx | 31 ++ .../(public)/registrieren/bestaetigt/page.tsx | 25 ++ src/app/(public)/registrieren/page.tsx | 75 ++++ src/app/api/auth/[...all]/route.ts | 5 + src/app/globals.css | 138 +++++++ src/modules/auth/admin-bootstrap.ts | 80 ++++ src/modules/auth/auth.test.ts | 19 + src/modules/auth/auth.ts | 90 +++++ src/modules/auth/client.ts | 5 + src/modules/auth/public-forms.test.tsx | 41 ++ src/modules/auth/public-forms.tsx | 256 ++++++++++++ src/modules/auth/registration.test.ts | 169 ++++++++ src/modules/auth/registration.ts | 276 +++++++++++++ src/modules/mail/mailer.test.ts | 36 ++ src/modules/mail/mailer.ts | 64 +++ 20 files changed, 1728 insertions(+), 20 deletions(-) create mode 100644 src/app/(public)/anmelden/page.tsx create mode 100644 src/app/(public)/passwort-vergessen/page.tsx create mode 100644 src/app/(public)/passwort-zuruecksetzen/page.tsx create mode 100644 src/app/(public)/registrieren/bestaetigt/page.tsx create mode 100644 src/app/(public)/registrieren/page.tsx create mode 100644 src/app/api/auth/[...all]/route.ts create mode 100644 src/modules/auth/admin-bootstrap.ts create mode 100644 src/modules/auth/auth.test.ts create mode 100644 src/modules/auth/auth.ts create mode 100644 src/modules/auth/client.ts create mode 100644 src/modules/auth/public-forms.test.tsx create mode 100644 src/modules/auth/public-forms.tsx create mode 100644 src/modules/auth/registration.test.ts create mode 100644 src/modules/auth/registration.ts create mode 100644 src/modules/mail/mailer.test.ts create mode 100644 src/modules/mail/mailer.ts diff --git a/package.json b/package.json index 1216348..866ee79 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,11 @@ "test:e2e": "playwright test" }, "dependencies": { + "@better-auth/drizzle-adapter": "^1.6.26", + "better-auth": "^1.6.26", "drizzle-orm": "^0.45.2", "next": "^16.3.0", + "nodemailer": "^9.0.5", "pg": "^8.22.0", "react": "^19.2.8", "react-dom": "^19.2.8", @@ -30,6 +33,7 @@ "@testing-library/jest-dom": "^7.0.0", "@testing-library/react": "^16.3.2", "@types/node": "^24.13.3", + "@types/nodemailer": "^8.0.1", "@types/pg": "^8.21.0", "@types/react": "^19.2.18", "@types/react-dom": "^19.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 25e8b18..2e7374c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,12 +8,21 @@ importers: .: dependencies: + '@better-auth/drizzle-adapter': + specifier: ^1.6.26 + version: 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0)) + better-auth: + specifier: ^1.6.26 + version: 1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))) drizzle-orm: specifier: ^0.45.2 - version: 0.45.2(@types/pg@8.21.0)(pg@8.22.0) + version: 0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0) next: specifier: ^16.3.0 version: 16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8) + nodemailer: + specifier: ^9.0.5 + version: 9.0.5 pg: specifier: ^8.22.0 version: 8.22.0 @@ -45,6 +54,9 @@ importers: '@types/node': specifier: ^24.13.3 version: 24.13.3 + '@types/nodemailer': + specifier: ^8.0.1 + version: 8.0.1 '@types/pg': specifier: ^8.21.0 version: 8.21.0 @@ -68,7 +80,7 @@ importers: version: 16.3.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3) jsdom: specifier: ^30.0.1 - version: 30.0.1 + version: 30.0.1(@noble/hashes@2.3.0) tailwindcss: specifier: ^4.3.3 version: 4.3.3 @@ -80,7 +92,7 @@ importers: version: 5.9.3 vitest: specifier: ^4.1.10 - version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1)(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) + version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) packages: @@ -173,6 +185,88 @@ packages: '@balena/dockerignore@1.0.2': resolution: {integrity: sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==} + '@better-auth/core@1.6.26': + resolution: {integrity: sha512-Ud4FqnjIJDvmeo+3bN+OsuVVAiuvFjNERbW7G8/65ictSxCox62gNgTOsJ4YXmbwXzBzyyekStzrupg2qNGEkA==} + peerDependencies: + '@better-auth/utils': 0.4.2 + '@better-fetch/fetch': 1.3.1 + '@cloudflare/workers-types': '>=4' + '@opentelemetry/api': ^1.9.0 + better-call: 1.3.7 + jose: ^6.1.0 + kysely: ^0.28.5 || ^0.29.0 + nanostores: ^1.0.1 + peerDependenciesMeta: + '@cloudflare/workers-types': + optional: true + '@opentelemetry/api': + optional: true + + '@better-auth/drizzle-adapter@1.6.26': + resolution: {integrity: sha512-SMvAeeUqEsz0BLtWVVp+HdStAVOwcxs4vPkL/AVmFJ0e9dDKItXl881xWeB/Ze4NgBW6NYmUId9qI4LrdQu3hA==} + peerDependencies: + '@better-auth/core': ^1.6.26 + '@better-auth/utils': 0.4.2 + drizzle-orm: ^0.45.2 + peerDependenciesMeta: + drizzle-orm: + optional: true + + '@better-auth/kysely-adapter@1.6.26': + resolution: {integrity: sha512-Y0Kdqn8JQMR8dHMtUnbBNqq7Mk8mDf18DwTves2uhjtRfcOWByVTGxsFMDVUbedMuoM+Ab+v04bwCk94sAo8NA==} + peerDependencies: + '@better-auth/core': ^1.6.26 + '@better-auth/utils': 0.4.2 + kysely: ^0.28.17 || ^0.29.0 + peerDependenciesMeta: + kysely: + optional: true + + '@better-auth/memory-adapter@1.6.26': + resolution: {integrity: sha512-kb5ahphEp9jyMleXU4T8I/xgWPa8gjOLFKKsnaVqR/BU+h7xqTOsjJwTY3evY+PFYHvjNFUlrjZ1Km8A/w1p/w==} + peerDependencies: + '@better-auth/core': ^1.6.26 + '@better-auth/utils': 0.4.2 + + '@better-auth/mongo-adapter@1.6.26': + resolution: {integrity: sha512-jYGhuIQqj48h69ROLPYdc8jgqDaMmRRLLFiRViZFYarNyBuYUV07DywJXvRuw8l9ADx+M1TB+BJZGnLE2nnmwQ==} + peerDependencies: + '@better-auth/core': ^1.6.26 + '@better-auth/utils': 0.4.2 + mongodb: ^6.0.0 || ^7.0.0 + peerDependenciesMeta: + mongodb: + optional: true + + '@better-auth/prisma-adapter@1.6.26': + resolution: {integrity: sha512-ILQoYmnoYyghDP4iN1h/Gkd9Jt7Xs/vxoNAt4AuuJJbqs73u27LlQM4P1YiP7nJ+bM1iVTBI1dDF73myIAtjzQ==} + peerDependencies: + '@better-auth/core': ^1.6.26 + '@better-auth/utils': 0.4.2 + '@prisma/client': ^5.0.0 || ^6.0.0 || ^7.0.0 + prisma: ^5.0.0 || ^6.0.0 || ^7.0.0 + peerDependenciesMeta: + '@prisma/client': + optional: true + prisma: + optional: true + + '@better-auth/telemetry@1.6.26': + resolution: {integrity: sha512-pBs69RORUSJHRF9r5PdeY7pzLRga09YSWew8igFYrBvT2tLt7DktrbD5WjryLZpAZOuKAMZ+Xo0DlJbnvLWGpQ==} + peerDependencies: + '@better-auth/core': ^1.6.26 + '@better-auth/utils': 0.4.2 + '@better-fetch/fetch': 1.3.1 + + '@better-auth/utils@0.4.2': + resolution: {integrity: sha512-AUxrvu+HaaODsUyzDxFgwd/8RZ1yZaYo42LXKSrU2oGgR38pS1ij8nqQKNgtTWoYGpNevNXtCfgTy6loHveW9A==} + + '@better-auth/utils@0.4.3': + resolution: {integrity: sha512-/X4gRYJBwRuLFjjANVpTDJJkAhLD6Sf8SIBypQ+Q2kDW1MnCsyxUujJzdKYsp59i4c41+AaMtpY/WQAQumqtOA==} + + '@better-fetch/fetch@1.3.1': + resolution: {integrity: sha512-ABkD1WhyfPZprKRQI3bhATjeiFuNWC9PXhfGWqL+sg/gKrM977oFrYkdb4msM3hgUGonr7KlOsOFT5TU2rht9g==} + '@bramus/specificity@2.4.2': resolution: {integrity: sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==} hasBin: true @@ -1020,6 +1114,14 @@ packages: cpu: [x64] os: [win32] + '@noble/ciphers@2.3.0': + resolution: {integrity: sha512-Clu/xdfgVTf9o7ngLOURaxePwR0j8sjclKEtVij10/jGulwFsPWCvvRgG/XjUVf8Nei+jLG6uwyXzUTGY1DQrw==} + engines: {node: '>= 20.19.0'} + + '@noble/hashes@2.3.0': + resolution: {integrity: sha512-oN+QwyX7VSHotibwubG3kpzbwKrfnyR6OOO+3Nk/53ADL7FmgHHz4TgrbaYKvvOw09u6QTx0oiH1cNCIOuN0CQ==} + engines: {node: '>= 20.19.0'} + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1036,6 +1138,10 @@ packages: resolution: {integrity: sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==} engines: {node: '>=12.4.0'} + '@opentelemetry/semantic-conventions@1.43.0': + resolution: {integrity: sha512-eSYWTm620tTk45EKSedaUL8MFYI8hW164hIXsgIHyxu3VobUB3fFCu5t0hQby6OoWRPsG1KkKUG2M5UadiLiVg==} + engines: {node: '>=14'} + '@oxc-project/types@0.143.0': resolution: {integrity: sha512-u6JZdLBTLotrNC9Vd6vPssINdzcCzleKAH6EJKImQb7GtYvX5keN2dxkoK44stCc4tffE6QQRtZTXVSzsLUlWA==} @@ -1325,6 +1431,9 @@ packages: '@types/node@24.13.3': resolution: {integrity: sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==} + '@types/nodemailer@8.0.1': + resolution: {integrity: sha512-PxpaInm8V1JQDd4j0ds5HfvWQk8JupS1C0Picb96QJsrrRDjBH+DlK7L4ZdNSqNULhiZRQHc40nLVShaGxXAMw==} + '@types/pg@8.21.0': resolution: {integrity: sha512-AYdtudzabjLZgVgRZmAnU8bAnVUXzuJX2IYHeSIiIHm68olD+LgQYCGWdtcNYnP0uq9c4S4NibVG3Ni7VbKW7Q==} @@ -1748,6 +1857,76 @@ packages: bcrypt-pbkdf@1.0.2: resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==} + better-auth@1.6.26: + resolution: {integrity: sha512-nhXWrDDj+EnZsHq1j0z1c6DowOMFZWZHe6LCaXbBfLIgHHZm6dyazBQcbRspM4spUIcUt250Mc1BFOSuP7eniQ==} + peerDependencies: + '@lynx-js/react': '*' + '@prisma/client': ^5.0.0 || ^6.0.0 || ^7.0.0 + '@sveltejs/kit': ^2.0.0 + '@tanstack/react-start': ^1.0.0 + '@tanstack/solid-start': ^1.0.0 + better-sqlite3: ^12.0.0 + drizzle-kit: '>=0.31.4' + drizzle-orm: ^0.45.2 + mongodb: ^6.0.0 || ^7.0.0 + mysql2: ^3.0.0 + next: ^14.0.0 || ^15.0.0 || ^16.0.0 + pg: ^8.0.0 + prisma: ^5.0.0 || ^6.0.0 || ^7.0.0 + react: ^18.0.0 || ^19.0.0 + react-dom: ^18.0.0 || ^19.0.0 + solid-js: ^1.0.0 + svelte: ^4.0.0 || ^5.0.0 + vitest: ^2.0.0 || ^3.0.0 || ^4.0.0 + vue: ^3.0.0 + peerDependenciesMeta: + '@lynx-js/react': + optional: true + '@prisma/client': + optional: true + '@sveltejs/kit': + optional: true + '@tanstack/react-start': + optional: true + '@tanstack/solid-start': + optional: true + better-sqlite3: + optional: true + drizzle-kit: + optional: true + drizzle-orm: + optional: true + mongodb: + optional: true + mysql2: + optional: true + next: + optional: true + pg: + optional: true + prisma: + optional: true + react: + optional: true + react-dom: + optional: true + solid-js: + optional: true + svelte: + optional: true + vitest: + optional: true + vue: + optional: true + + better-call@1.3.7: + resolution: {integrity: sha512-Al51/hjp2SSp6CRTa3F2ptcx4yQVS1xWKoY6jcVXqNYOap6mHFP2jUBn5EwIL4iIed1/Sq4hlQ+Umm6EflZG+w==} + peerDependencies: + zod: ^4.0.0 + peerDependenciesMeta: + zod: + optional: true + bidi-js@1.0.3: resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==} @@ -1928,6 +2107,9 @@ packages: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} + defu@6.1.7: + resolution: {integrity: sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==} + dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} @@ -2622,6 +2804,9 @@ packages: resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==} hasBin: true + jose@6.2.8: + resolution: {integrity: sha512-Bsdjwm3Qsd/P0jR+BHDe3LytDfY7WBq2HmCCLIwuVRHMuEC9ae7/R474GIUdF1NgCyZjzVo/A9DOiOBtXq8ZoQ==} + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -2668,6 +2853,10 @@ packages: keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} + kysely@0.29.4: + resolution: {integrity: sha512-y5mVgQNkMbs1eK9Xyc0pmNdabN2wHhRYY/5r4W5HrUT1rYCEPeVNSj1RUJeSDKT3U0p+mXCvLgkrFuIafYI6BA==} + engines: {node: '>=22.0.0'} + language-subtag-registry@0.3.23: resolution: {integrity: sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==} @@ -2928,6 +3117,10 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + nanostores@1.4.2: + resolution: {integrity: sha512-Wxv8Roefr2nqtiRG0bnaFlpYqpIVtOEeJZHaH+4nGgOK1/7n6OHOuHCb/bhqrNQgZM8fyd0s1PqhdrJc9Ib44g==} + engines: {node: ^20.0.0 || >=22.0.0} + napi-postinstall@0.3.4: resolution: {integrity: sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} @@ -2965,6 +3158,10 @@ packages: resolution: {integrity: sha512-D9UOmYG3UH1V+ENW56t5QXBwJw1YEY18ruVeus89Rw+SyIgjPkCO84bRzO3uNIYosJbNwiabWVn48o3uJLjxFQ==} engines: {node: '>=18'} + nodemailer@9.0.5: + resolution: {integrity: sha512-wvjiKvjczmsN7U/8006JOdXubgBk2XFAbioDMbT+sM7cPs0QrhJTa6KBRX7P5REGGkDcLUz/EarWidb8G8C1jQ==} + engines: {node: '>=6.0.0'} + normalize-path@3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} @@ -3238,6 +3435,9 @@ packages: engines: {node: ^20.19.0 || >=22.12.0} hasBin: true + rou3@0.7.12: + resolution: {integrity: sha512-iFE4hLDuloSWcD7mjdCDhx2bKcIsYbtOTpfH5MHHLSKMOUyjqQXTeZVa289uuwEGEKFoE/BAPbhaU4B774nceg==} + run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -3281,6 +3481,9 @@ packages: server-only@0.0.1: resolution: {integrity: sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA==} + set-cookie-parser@3.1.2: + resolution: {integrity: sha512-5/r/lTwbJ3zQ+qwdUFZYeRNqda7P5HD8zQKqlSjdGt1/S0cjLAphHusj4Y58ahDtWn/g32xrIS58/ikOvwl0Lw==} + set-function-length@1.2.2: resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} engines: {node: '>= 0.4'} @@ -3925,6 +4128,63 @@ snapshots: '@balena/dockerignore@1.0.2': {} + '@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2)': + dependencies: + '@better-auth/utils': 0.4.2 + '@better-fetch/fetch': 1.3.1 + '@opentelemetry/semantic-conventions': 1.43.0 + '@standard-schema/spec': 1.1.0 + better-call: 1.3.7(zod@4.4.3) + jose: 6.2.8 + kysely: 0.29.4 + nanostores: 1.4.2 + zod: 4.4.3 + + '@better-auth/drizzle-adapter@1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))': + dependencies: + '@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2) + '@better-auth/utils': 0.4.2 + optionalDependencies: + drizzle-orm: 0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0) + + '@better-auth/kysely-adapter@1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(kysely@0.29.4)': + dependencies: + '@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2) + '@better-auth/utils': 0.4.2 + optionalDependencies: + kysely: 0.29.4 + + '@better-auth/memory-adapter@1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)': + dependencies: + '@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2) + '@better-auth/utils': 0.4.2 + + '@better-auth/mongo-adapter@1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)': + dependencies: + '@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2) + '@better-auth/utils': 0.4.2 + + '@better-auth/prisma-adapter@1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)': + dependencies: + '@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2) + '@better-auth/utils': 0.4.2 + + '@better-auth/telemetry@1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)': + dependencies: + '@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2) + '@better-auth/utils': 0.4.2 + '@better-fetch/fetch': 1.3.1 + + '@better-auth/utils@0.4.2': + dependencies: + '@noble/hashes': 2.3.0 + + '@better-auth/utils@0.4.3': + dependencies: + '@noble/hashes': 2.3.0 + + '@better-fetch/fetch@1.3.1': {} + '@bramus/specificity@2.4.2': dependencies: css-tree: 3.2.1 @@ -4259,7 +4519,9 @@ snapshots: '@eslint/core': 0.17.0 levn: 0.4.1 - '@exodus/bytes@1.15.1': {} + '@exodus/bytes@1.15.1(@noble/hashes@2.3.0)': + optionalDependencies: + '@noble/hashes': 2.3.0 '@grpc/grpc-js@1.14.4': dependencies: @@ -4479,6 +4741,10 @@ snapshots: '@next/swc-win32-x64-msvc@16.3.0': optional: true + '@noble/ciphers@2.3.0': {} + + '@noble/hashes@2.3.0': {} + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -4493,6 +4759,8 @@ snapshots: '@nolyfill/is-core-module@1.0.39': {} + '@opentelemetry/semantic-conventions@1.43.0': {} + '@oxc-project/types@0.143.0': {} '@pkgjs/parseargs@0.11.0': @@ -4718,6 +4986,10 @@ snapshots: dependencies: undici-types: 7.18.2 + '@types/nodemailer@8.0.1': + dependencies: + '@types/node': 24.13.3 + '@types/pg@8.21.0': dependencies: '@types/node': 24.13.3 @@ -5145,6 +5417,46 @@ snapshots: dependencies: tweetnacl: 0.14.5 + better-auth@1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))): + dependencies: + '@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2) + '@better-auth/drizzle-adapter': 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0)) + '@better-auth/kysely-adapter': 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(kysely@0.29.4) + '@better-auth/memory-adapter': 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2) + '@better-auth/mongo-adapter': 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2) + '@better-auth/prisma-adapter': 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2) + '@better-auth/telemetry': 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1) + '@better-auth/utils': 0.4.2 + '@better-fetch/fetch': 1.3.1 + '@noble/ciphers': 2.3.0 + '@noble/hashes': 2.3.0 + better-call: 1.3.7(zod@4.4.3) + defu: 6.1.7 + jose: 6.2.8 + kysely: 0.29.4 + nanostores: 1.4.2 + zod: 4.4.3 + optionalDependencies: + drizzle-kit: 0.31.10 + drizzle-orm: 0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0) + next: 16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8) + pg: 8.22.0 + react: 19.2.8 + react-dom: 19.2.8(react@19.2.8) + vitest: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) + transitivePeerDependencies: + - '@cloudflare/workers-types' + - '@opentelemetry/api' + + better-call@1.3.7(zod@4.4.3): + dependencies: + '@better-auth/utils': 0.4.3 + '@better-fetch/fetch': 1.3.1 + rou3: 0.7.12 + set-cookie-parser: 3.1.2 + optionalDependencies: + zod: 4.4.3 + bidi-js@1.0.3: dependencies: require-from-string: 2.0.2 @@ -5287,10 +5599,10 @@ snapshots: damerau-levenshtein@1.0.8: {} - data-urls@7.0.0: + data-urls@7.0.0(@noble/hashes@2.3.0): dependencies: whatwg-mimetype: 5.0.0 - whatwg-url: 16.0.1 + whatwg-url: 16.0.1(@noble/hashes@2.3.0) transitivePeerDependencies: - '@noble/hashes' @@ -5340,6 +5652,8 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 + defu@6.1.7: {} + dequal@2.0.3: {} detect-libc@2.1.2: {} @@ -5383,9 +5697,10 @@ snapshots: esbuild: 0.25.12 tsx: 4.23.11 - drizzle-orm@0.45.2(@types/pg@8.21.0)(pg@8.22.0): + drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0): optionalDependencies: '@types/pg': 8.21.0 + kysely: 0.29.4 pg: 8.22.0 dunder-proto@1.0.1: @@ -6002,9 +6317,9 @@ snapshots: dependencies: hermes-estree: 0.25.1 - html-encoding-sniffer@6.0.0: + html-encoding-sniffer@6.0.0(@noble/hashes@2.3.0): dependencies: - '@exodus/bytes': 1.15.1 + '@exodus/bytes': 1.15.1(@noble/hashes@2.3.0) transitivePeerDependencies: - '@noble/hashes' @@ -6176,23 +6491,25 @@ snapshots: jiti@2.7.0: {} + jose@6.2.8: {} + js-tokens@4.0.0: {} js-yaml@4.3.1: dependencies: argparse: 2.0.1 - jsdom@30.0.1: + jsdom@30.0.1(@noble/hashes@2.3.0): dependencies: '@asamuzakjp/css-color': 6.0.5 '@asamuzakjp/dom-selector': 8.3.2 '@bramus/specificity': 2.4.2 '@csstools/css-syntax-patches-for-csstree': 1.1.7(css-tree@3.2.1) - '@exodus/bytes': 1.15.1 + '@exodus/bytes': 1.15.1(@noble/hashes@2.3.0) css-tree: 3.2.1 - data-urls: 7.0.0 + data-urls: 7.0.0(@noble/hashes@2.3.0) decimal.js: 10.6.0 - html-encoding-sniffer: 6.0.0 + html-encoding-sniffer: 6.0.0(@noble/hashes@2.3.0) is-potential-custom-element-name: 1.0.1 lru-cache: 11.5.2 parse5: 8.0.1 @@ -6203,7 +6520,7 @@ snapshots: w3c-xmlserializer: 5.0.0 webidl-conversions: 8.0.1 whatwg-mimetype: 5.0.0 - whatwg-url: 17.1.0 + whatwg-url: 17.1.0(@noble/hashes@2.3.0) xml-name-validator: 5.0.0 transitivePeerDependencies: - '@noble/hashes' @@ -6233,6 +6550,8 @@ snapshots: dependencies: json-buffer: 3.0.1 + kysely@0.29.4: {} + language-subtag-registry@0.3.23: {} language-tags@1.0.9: @@ -6420,6 +6739,8 @@ snapshots: nanoid@3.3.18: {} + nanostores@1.4.2: {} + napi-postinstall@0.3.4: {} natural-compare@1.4.0: {} @@ -6458,6 +6779,8 @@ snapshots: node-releases@2.0.53: {} + nodemailer@9.0.5: {} + normalize-path@3.0.0: {} object-assign@4.1.1: {} @@ -6779,6 +7102,8 @@ snapshots: '@rolldown/binding-win32-arm64-msvc': 1.2.3 '@rolldown/binding-win32-x64-msvc': 1.2.3 + rou3@0.7.12: {} + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 @@ -6820,6 +7145,8 @@ snapshots: server-only@0.0.1: {} + set-cookie-parser@3.1.2: {} + set-function-length@1.2.2: dependencies: define-data-property: 1.1.4 @@ -7311,7 +7638,7 @@ snapshots: tsx: 4.23.11 yaml: 2.9.0 - vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1)(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)): + vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)): dependencies: '@vitest/expect': 4.1.10 '@vitest/mocker': 4.1.10(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) @@ -7335,7 +7662,7 @@ snapshots: why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 24.13.3 - jsdom: 30.0.1 + jsdom: 30.0.1(@noble/hashes@2.3.0) transitivePeerDependencies: - msw @@ -7347,17 +7674,17 @@ snapshots: whatwg-mimetype@5.0.0: {} - whatwg-url@16.0.1: + whatwg-url@16.0.1(@noble/hashes@2.3.0): dependencies: - '@exodus/bytes': 1.15.1 + '@exodus/bytes': 1.15.1(@noble/hashes@2.3.0) tr46: 6.0.0 webidl-conversions: 8.0.1 transitivePeerDependencies: - '@noble/hashes' - whatwg-url@17.1.0: + whatwg-url@17.1.0(@noble/hashes@2.3.0): dependencies: - '@exodus/bytes': 1.15.1 + '@exodus/bytes': 1.15.1(@noble/hashes@2.3.0) tr46: 6.0.0 webidl-conversions: 8.0.1 transitivePeerDependencies: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 6c750ff..7d44de6 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,2 +1,6 @@ allowBuilds: + cpu-features: false + esbuild: true + protobufjs: false + ssh2: false unrs-resolver: true diff --git a/src/app/(public)/anmelden/page.tsx b/src/app/(public)/anmelden/page.tsx new file mode 100644 index 0000000..21269b4 --- /dev/null +++ b/src/app/(public)/anmelden/page.tsx @@ -0,0 +1,38 @@ +import Link from "next/link"; + +import { env } from "@/config/env"; +import { LoginForm } from "@/modules/auth/public-forms"; + +export default function LoginPage() { + return ( +
+
+ + Leon Tonhäuser + + Redaktionsportal +
+
+

Zugang

+

Anmelden

+

Melden Sie sich mit der E-Mail-Adresse Ihrer Redaktion an.

+ + +
+ +
+ ); +} + +function LegalFooter({ imprint, privacy, terms }: { imprint: string; privacy: string; terms: string }) { + return ( + + ); +} diff --git a/src/app/(public)/passwort-vergessen/page.tsx b/src/app/(public)/passwort-vergessen/page.tsx new file mode 100644 index 0000000..74da6ac --- /dev/null +++ b/src/app/(public)/passwort-vergessen/page.tsx @@ -0,0 +1,25 @@ +import Link from "next/link"; + +import { PasswordResetRequestForm } from "@/modules/auth/public-forms"; + +export default function ForgotPasswordPage() { + return ( +
+
+ + Leon Tonhäuser + + Redaktionsportal +
+
+

Zugang

+

Passwort vergessen?

+

Fordern Sie einen Link zum Zurücksetzen Ihres Passworts an.

+ + +
+
+ ); +} diff --git a/src/app/(public)/passwort-zuruecksetzen/page.tsx b/src/app/(public)/passwort-zuruecksetzen/page.tsx new file mode 100644 index 0000000..70413b8 --- /dev/null +++ b/src/app/(public)/passwort-zuruecksetzen/page.tsx @@ -0,0 +1,31 @@ +import Link from "next/link"; + +import { PasswordResetForm } from "@/modules/auth/public-forms"; + +export default async function ResetPasswordPage({ + searchParams, +}: { + searchParams: Promise<{ token?: string }>; +}) { + const { token } = await searchParams; + + return ( +
+
+ + Leon Tonhäuser + + Redaktionsportal +
+
+

Zugang

+

Neues Passwort setzen

+

Wählen Sie ein neues Passwort für den Zugang Ihrer Redaktion.

+ + +
+
+ ); +} diff --git a/src/app/(public)/registrieren/bestaetigt/page.tsx b/src/app/(public)/registrieren/bestaetigt/page.tsx new file mode 100644 index 0000000..082f879 --- /dev/null +++ b/src/app/(public)/registrieren/bestaetigt/page.tsx @@ -0,0 +1,25 @@ +import Link from "next/link"; + +export default function RegistrationConfirmedPage() { + return ( +
+
+ + Leon Tonhäuser + + Redaktionsportal +
+
+

Registrierung

+

Vielen Dank.

+

+ Bitte folgen Sie den weiteren Hinweisen, die wir Ihnen gegebenenfalls zusenden. Danach + prüfen wir Ihre Registrierung. +

+ + Zur Anmeldung + +
+
+ ); +} diff --git a/src/app/(public)/registrieren/page.tsx b/src/app/(public)/registrieren/page.tsx new file mode 100644 index 0000000..bff3a1f --- /dev/null +++ b/src/app/(public)/registrieren/page.tsx @@ -0,0 +1,75 @@ +import Link from "next/link"; +import { redirect } from "next/navigation"; + +import { env } from "@/config/env"; +import { registerEditorial } from "@/modules/auth/auth"; +import { RegistrationValidationError } from "@/modules/auth/registration"; +import { + RegistrationForm, + type RegistrationFormState, +} from "@/modules/auth/public-forms"; + +export default function RegistrationPage() { + return ( +
+
+ + Leon Tonhäuser + + Redaktionsportal +
+
+

B2B-Zugang

+

Redaktion registrieren

+

+ Das Redaktionsportal steht ausschließlich Unternehmen und Redaktionen zur Verfügung. +

+ +
+
+ ); +} + +async function registerAction( + _state: RegistrationFormState, + formData: FormData, +): Promise { + "use server"; + + try { + await registerEditorial({ + companyName: text(formData, "companyName"), + contactName: text(formData, "contactName"), + email: text(formData, "email"), + password: text(formData, "password"), + billingAddress: { + addressLine1: text(formData, "addressLine1"), + addressLine2: text(formData, "addressLine2") || undefined, + postalCode: text(formData, "postalCode"), + city: text(formData, "city"), + countryCode: text(formData, "countryCode"), + }, + actsForBusiness: formData.has("actsForBusiness"), + termsVersion: formData.has("termsAccepted") ? text(formData, "termsVersion") : "", + privacyAcknowledged: formData.has("privacyAcknowledged"), + }); + } catch (error) { + if (error instanceof RegistrationValidationError) { + return { errors: { [error.field]: error.message } }; + } + } + + redirect("/registrieren/bestaetigt"); +} + +function text(formData: FormData, name: string): string { + const value = formData.get(name); + return typeof value === "string" ? value : ""; +} diff --git a/src/app/api/auth/[...all]/route.ts b/src/app/api/auth/[...all]/route.ts new file mode 100644 index 0000000..3e0413c --- /dev/null +++ b/src/app/api/auth/[...all]/route.ts @@ -0,0 +1,5 @@ +import { toNextJsHandler } from "better-auth/next-js"; + +import { auth } from "@/modules/auth/auth"; + +export const { GET, POST } = toNextJsHandler(auth); diff --git a/src/app/globals.css b/src/app/globals.css index 2c0ebc3..9c971cb 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -138,3 +138,141 @@ a { transition: none; } } + +.public-account-page { + display: grid; + min-height: 100vh; + grid-template-rows: auto 1fr auto; + padding: clamp(1.25rem, 3vw, 2.75rem); +} + +.account-panel { + width: min(100%, 37rem); + align-self: center; + padding-block: clamp(4rem, 10vh, 7rem); +} + +.account-panel-wide { + width: min(100%, 48rem); +} + +.account-panel h1 { + max-width: 12ch; + margin: 0; + font-size: clamp(2.6rem, 6vw, 5.5rem); + font-weight: 600; + letter-spacing: -0.06em; + line-height: 0.92; +} + +.account-panel .lede { + margin-top: 1.75rem; +} + +.account-form { + display: grid; + gap: 1.25rem; + margin-top: 2.5rem; +} + +.account-form label, +.acknowledgements legend { + display: grid; + gap: 0.5rem; + font-size: 0.8125rem; + font-weight: 650; + letter-spacing: 0.01em; +} + +.account-form input:not([type="checkbox"]) { + width: 100%; + min-height: 3.1rem; + border: 1px solid var(--ink); + border-radius: 0; + background: var(--paper); + color: var(--ink); + font: inherit; + font-weight: 400; + padding: 0.75rem; +} + +.form-grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 1rem; +} + +.acknowledgements { + display: grid; + gap: 0.75rem; + margin: 0; + padding: 1.25rem 0; + border: 0; + border-top: 1px solid var(--line); + border-bottom: 1px solid var(--line); +} + +.acknowledgements legend { + padding: 0; + margin-bottom: 0.25rem; +} + +.checkbox-label { + grid-template-columns: 1rem minmax(0, 1fr); + align-items: start; + font-weight: 400 !important; + line-height: 1.45; +} + +.checkbox-label input { + width: 1rem; + height: 1rem; + margin: 0.12rem 0 0; + accent-color: var(--ink); +} + +.checkbox-label a, +.account-links a, +.public-footer a, +.legal-link { + text-underline-offset: 0.17em; +} + +.field-error { + margin: -0.25rem 0 0; + color: #9d0e0e; + font-size: 0.875rem; + line-height: 1.4; +} + +.form-note { + max-width: 44rem; + margin: 0; + color: var(--muted); + font-size: 0.875rem; + line-height: 1.55; +} + +.account-links, +.public-footer { + display: flex; + flex-wrap: wrap; + gap: 0.75rem 1.25rem; + margin-top: 1rem; + font-size: 0.875rem; +} + +.public-footer { + padding-top: 1rem; + border-top: 1px solid var(--line); + color: var(--muted); + font-size: 0.75rem; + letter-spacing: 0.06em; + text-transform: uppercase; +} + +@media (max-width: 40rem) { + .form-grid { + grid-template-columns: 1fr; + } +} diff --git a/src/modules/auth/admin-bootstrap.ts b/src/modules/auth/admin-bootstrap.ts new file mode 100644 index 0000000..9ecfb9e --- /dev/null +++ b/src/modules/auth/admin-bootstrap.ts @@ -0,0 +1,80 @@ +import "server-only"; + +import { eq, sql } from "drizzle-orm"; +import type { NodePgDatabase } from "drizzle-orm/node-postgres"; + +import { users } from "@/db/schema"; +import type * as schema from "@/db/schema"; + +export type AdminBootstrapInput = { + email: string; + name: string; + password: string; +}; + +export type AdminBootstrapAuth = { + signUpEmail(input: { email: string; name: string; password: string }): Promise<{ user: { id: string } }>; + sendVerificationEmail(input: { email: string }): Promise; +}; + +export type AdminBootstrapRepository = { + countAdmins(): Promise; + findUserByEmail(email: string): Promise<{ id: string } | undefined>; + promoteUserToAdmin(userId: string): Promise; +}; + +export function createAdminBootstrapService({ + auth, + repo, +}: { + auth: AdminBootstrapAuth; + repo: AdminBootstrapRepository; +}) { + return { + async bootstrap(input: AdminBootstrapInput): Promise<{ status: "created" | "already_configured" }> { + if ((await repo.countAdmins()) > 0) { + return { status: "already_configured" }; + } + + const email = input.email.trim().toLowerCase(); + const existingUser = await repo.findUserByEmail(email); + const user = + existingUser ?? + (await auth.signUpEmail({ + email, + name: input.name.trim(), + password: input.password, + })).user; + + await repo.promoteUserToAdmin(user.id); + await auth.sendVerificationEmail({ email }); + return { status: "created" }; + }, + }; +} + +export function createAdminBootstrapRepository(database: NodePgDatabase): AdminBootstrapRepository { + return { + async countAdmins() { + const [result] = await database + .select({ count: sql`count(*)::int` }) + .from(users) + .where(eq(users.role, "ADMIN")); + return result.count; + }, + async findUserByEmail(email) { + const [user] = await database + .select({ id: users.id }) + .from(users) + .where(eq(users.email, email)) + .limit(1); + return user; + }, + async promoteUserToAdmin(userId) { + await database + .update(users) + .set({ role: "ADMIN", updatedAt: new Date() }) + .where(eq(users.id, userId)); + }, + }; +} diff --git a/src/modules/auth/auth.test.ts b/src/modules/auth/auth.test.ts new file mode 100644 index 0000000..4ce2e44 --- /dev/null +++ b/src/modules/auth/auth.test.ts @@ -0,0 +1,19 @@ +import { expect, test } from "vitest"; + +import { auth } from "./auth"; + +test("rejects direct Better Auth sign-up requests that bypass B2B registration", async () => { + const response = await auth.handler( + new Request("http://localhost:3000/api/auth/sign-up/email", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ + email: "bypass@example.com", + name: "Bypass", + password: "sicheres-passwort-123", + }), + }), + ); + + expect(response.status).toBe(403); +}); diff --git a/src/modules/auth/auth.ts b/src/modules/auth/auth.ts new file mode 100644 index 0000000..1c95a76 --- /dev/null +++ b/src/modules/auth/auth.ts @@ -0,0 +1,90 @@ +import "server-only"; + +import { drizzleAdapter } from "@better-auth/drizzle-adapter"; +import { betterAuth } from "better-auth"; +import { APIError, createAuthMiddleware } from "better-auth/api"; + +import { env } from "@/config/env"; +import { db } from "@/db/client"; +import { accounts, sessions, users, verifications } from "@/db/schema"; +import { mailer } from "@/modules/mail/mailer"; + +import { + createEditorialRegistrationRepository, + createRegistrationService, + type RegistrationInput, +} from "./registration"; + +const registrationRepository = createEditorialRegistrationRepository(db); + +export const auth = betterAuth({ + baseURL: env.BETTER_AUTH_URL, + secret: env.BETTER_AUTH_SECRET, + database: drizzleAdapter(db, { + provider: "pg", + schema: { + user: users, + account: accounts, + session: sessions, + verification: verifications, + }, + }), + hooks: { + before: createAuthMiddleware(async (context) => { + if (context.path === "/sign-up/email") { + throw new APIError("FORBIDDEN", { + message: "Bitte verwenden Sie die Registrierung des Redaktionsportals.", + }); + } + }), + }, + emailAndPassword: { + enabled: true, + requireEmailVerification: true, + autoSignIn: false, + resetPasswordTokenExpiresIn: 60 * 60, + revokeSessionsOnPasswordReset: true, + async sendResetPassword({ user, url }) { + await mailer.sendPasswordReset({ to: user.email, resetUrl: url }); + }, + }, + emailVerification: { + sendOnSignUp: false, + autoSignInAfterVerification: false, + expiresIn: 60 * 60, + async sendVerificationEmail({ user, url }) { + await mailer.sendVerification({ to: user.email, verificationUrl: url }); + }, + async afterEmailVerification(user) { + await registrationService.onEmailVerified(user.id); + }, + }, + databaseHooks: { + session: { + create: { + async before(session) { + return registrationRepository.canCreateSession(session.userId); + }, + }, + }, + }, +}); + +export const registrationService = createRegistrationService({ + auth: { + async signUpEmail({ email, name, password }) { + return auth.api.signUpEmail({ body: { email, name, password } }); + }, + async sendVerificationEmail({ email }) { + await auth.api.sendVerificationEmail({ + body: { email, callbackURL: "/registrieren/bestaetigt" }, + }); + }, + }, + repo: registrationRepository, + audit: registrationRepository, +}); + +export function registerEditorial(input: RegistrationInput): Promise<{ status: "pending_email" }> { + return registrationService.register(input); +} diff --git a/src/modules/auth/client.ts b/src/modules/auth/client.ts new file mode 100644 index 0000000..2f75fd4 --- /dev/null +++ b/src/modules/auth/client.ts @@ -0,0 +1,5 @@ +"use client"; + +import { createAuthClient } from "better-auth/react"; + +export const authClient = createAuthClient(); diff --git a/src/modules/auth/public-forms.test.tsx b/src/modules/auth/public-forms.test.tsx new file mode 100644 index 0000000..5d5aefe --- /dev/null +++ b/src/modules/auth/public-forms.test.tsx @@ -0,0 +1,41 @@ +// @vitest-environment jsdom + +import { render, screen } from "@testing-library/react"; +import { expect, test, vi } from "vitest"; + +import { RegistrationForm } from "./public-forms"; + +test("registration presents separate B2B, terms, and privacy acknowledgements", () => { + render( + , + ); + + expect( + screen.getByRole("checkbox", { + name: /im namen einer redaktion oder eines unternehmens/i, + }), + ).toHaveProperty("required", true); + expect(screen.getByRole("checkbox", { name: /nutzungs- und lizenzbedingungen/i })).toHaveProperty( + "required", + true, + ); + expect(screen.getByRole("checkbox", { name: /datenschutzerklärung/i })).toHaveProperty( + "required", + true, + ); + expect(screen.getByRole("link", { name: /nutzungs- und lizenzbedingungen/i })).toHaveProperty( + "href", + "https://example.com/nutzungsbedingungen", + ); + expect(screen.getByRole("link", { name: /datenschutzerklärung/i })).toHaveProperty( + "href", + "https://example.com/datenschutz", + ); +}); diff --git a/src/modules/auth/public-forms.tsx b/src/modules/auth/public-forms.tsx new file mode 100644 index 0000000..6f39b60 --- /dev/null +++ b/src/modules/auth/public-forms.tsx @@ -0,0 +1,256 @@ +"use client"; + +import { type FormEvent, useActionState, useState } from "react"; + +import { authClient } from "./client"; + +export type RegistrationFormState = { + errors?: Partial< + Record<"actsForBusiness" | "termsVersion" | "privacyAcknowledged", string> + >; +}; + +export type RegistrationFormAction = ( + state: RegistrationFormState, + formData: FormData, +) => Promise; + +export type LegalUrls = { + imprint: string; + privacy: string; + terms: string; +}; + +const initialRegistrationState: RegistrationFormState = {}; + +export function RegistrationForm({ + action, + legalUrls, +}: { + action: RegistrationFormAction; + legalUrls: LegalUrls; +}) { + const [state, formAction, pending] = useActionState(action, initialRegistrationState); + + return ( +
+ +
+ + + + + + + + + +
+ +
+ Verbindliche Angaben + + + + + + +
+ + +

+ Wir informieren Sie auf der nächsten Seite über den weiteren Ablauf. +

+ + Impressum + +
+ ); +} + +export function LoginForm() { + const [error, setError] = useState(); + const [pending, setPending] = useState(false); + + async function submit(event: FormEvent) { + event.preventDefault(); + setPending(true); + setError(undefined); + + const formData = new FormData(event.currentTarget); + const result = await authClient.signIn.email({ + email: readText(formData, "email").trim().toLowerCase(), + password: readText(formData, "password"), + callbackURL: "/", + }); + + if (result.error) { + setError("Die Anmeldung war nicht erfolgreich. Bitte prüfen Sie Ihre Angaben."); + setPending(false); + return; + } + + window.location.assign(result.data?.url ?? "/"); + } + + return ( +
+ + + + + + ); +} + +export function PasswordResetRequestForm() { + const [submitted, setSubmitted] = useState(false); + const [pending, setPending] = useState(false); + + async function submit(event: FormEvent) { + event.preventDefault(); + setPending(true); + const formData = new FormData(event.currentTarget); + + try { + await authClient.requestPasswordReset({ + email: readText(formData, "email").trim().toLowerCase(), + redirectTo: `${window.location.origin}/passwort-zuruecksetzen`, + }); + } finally { + setSubmitted(true); + setPending(false); + } + } + + if (submitted) { + return ( +

+ Falls ein Zugang zu dieser Adresse gehört, erhalten Sie in Kürze weitere Hinweise. +

+ ); + } + + return ( +
+ + +
+ ); +} + +export function PasswordResetForm({ token }: { token?: string }) { + const [message, setMessage] = useState(); + const [pending, setPending] = useState(false); + + async function submit(event: FormEvent) { + event.preventDefault(); + setPending(true); + const formData = new FormData(event.currentTarget); + + try { + await authClient.resetPassword({ newPassword: readText(formData, "password"), token }); + } finally { + setMessage("Wenn der Link gültig war, wurde Ihr Passwort aktualisiert."); + setPending(false); + } + } + + if (message) { + return ( +

+ {message} +

+ ); + } + + return ( +
+ + +
+ ); +} + +function FieldError({ message }: { message?: string }) { + return message ? ( +

+ {message} +

+ ) : null; +} + +function readText(formData: FormData, name: string): string { + const value = formData.get(name); + return typeof value === "string" ? value : ""; +} diff --git a/src/modules/auth/registration.test.ts b/src/modules/auth/registration.test.ts new file mode 100644 index 0000000..1e9b398 --- /dev/null +++ b/src/modules/auth/registration.test.ts @@ -0,0 +1,169 @@ +import { describe, expect, test, vi } from "vitest"; + +import { + RegistrationValidationError, + createRegistrationService, + type RegistrationInput, +} from "./registration"; +import { createAdminBootstrapService } from "./admin-bootstrap"; + +const validRegistration: RegistrationInput = { + companyName: "Neue Redaktion GmbH", + contactName: "Mara Muster", + email: "Mara.Muster@Example.com", + password: "sicheres-passwort-123", + billingAddress: { + addressLine1: "Presseweg 1", + addressLine2: "Haus B", + postalCode: "10115", + city: "Berlin", + countryCode: "DE", + }, + actsForBusiness: true, + termsVersion: "2026-08", + privacyAcknowledged: true, +}; + +function createService() { + const auth = { + signUpEmail: vi.fn().mockResolvedValue({ user: { id: "user-1" } }), + sendVerificationEmail: vi.fn().mockResolvedValue(undefined), + }; + const repo = { + createEditorial: vi.fn().mockResolvedValue(undefined), + markPendingApproval: vi.fn().mockResolvedValue(true), + }; + const audit = { + recordVerificationInconsistency: vi.fn().mockResolvedValue(undefined), + }; + const now = new Date("2026-08-09T10:00:00.000Z"); + + return { + auth, + repo, + audit, + service: createRegistrationService({ auth, repo, audit, now: () => now }), + }; +} + +describe("editorial registration", () => { + test("creates a pending editorial and sends verification mail", async () => { + const { auth, repo, service } = createService(); + + await expect(service.register(validRegistration)).resolves.toEqual({ status: "pending_email" }); + + expect(auth.signUpEmail).toHaveBeenCalledWith({ + email: "mara.muster@example.com", + name: "Mara Muster", + password: "sicheres-passwort-123", + }); + expect(repo.createEditorial).toHaveBeenCalledWith({ + userId: "user-1", + name: "Neue Redaktion GmbH", + contactName: "Mara Muster", + loginEmail: "mara.muster@example.com", + status: "pending_email", + acceptedTermsVersion: "2026-08", + acceptedTermsAt: new Date("2026-08-09T10:00:00.000Z"), + privacyAcknowledgedAt: new Date("2026-08-09T10:00:00.000Z"), + billingAddress: { + companyName: "Neue Redaktion GmbH", + contactName: "Mara Muster", + addressLine1: "Presseweg 1", + addressLine2: "Haus B", + postalCode: "10115", + city: "Berlin", + countryCode: "DE", + }, + }); + expect(auth.sendVerificationEmail).toHaveBeenCalledWith({ + email: "mara.muster@example.com", + }); + }); + + test("rejects a registration that is not made for a business", async () => { + const { auth, repo, service } = createService(); + + await expect( + service.register({ ...validRegistration, actsForBusiness: false }), + ).rejects.toEqual( + new RegistrationValidationError( + "actsForBusiness", + "Bitte bestätigen Sie, dass Sie im Namen eines Unternehmens oder einer Redaktion handeln.", + ), + ); + + expect(auth.signUpEmail).not.toHaveBeenCalled(); + expect(repo.createEditorial).not.toHaveBeenCalled(); + }); + + test("rejects missing terms and privacy acknowledgements with stable German field errors", async () => { + const { service } = createService(); + + await expect( + service.register({ ...validRegistration, termsVersion: "" }), + ).rejects.toEqual( + new RegistrationValidationError( + "termsVersion", + "Bitte akzeptieren Sie die Nutzungs- und Lizenzbedingungen.", + ), + ); + await expect( + service.register({ ...validRegistration, privacyAcknowledged: false }), + ).rejects.toEqual( + new RegistrationValidationError( + "privacyAcknowledged", + "Bitte bestätigen Sie die Kenntnisnahme der Datenschutzerklärung.", + ), + ); + }); + + test("moves a verified account from pending email to pending approval", async () => { + const { audit, repo, service } = createService(); + + await service.onEmailVerified("user-1"); + + expect(repo.markPendingApproval).toHaveBeenCalledWith("user-1"); + expect(audit.recordVerificationInconsistency).not.toHaveBeenCalled(); + }); + + test("audits a verified user without an editorial account without raw request data", async () => { + const { audit, repo, service } = createService(); + repo.markPendingApproval.mockResolvedValue(false); + + await service.onEmailVerified("user-without-editorial"); + + expect(audit.recordVerificationInconsistency).toHaveBeenCalledWith({ + userId: "user-without-editorial", + }); + }); +}); + +test("bootstraps the first admin only once", async () => { + const auth = { + signUpEmail: vi.fn().mockResolvedValue({ user: { id: "admin-1" } }), + sendVerificationEmail: vi.fn().mockResolvedValue(undefined), + }; + const repo = { + countAdmins: vi.fn().mockResolvedValue(0), + findUserByEmail: vi.fn().mockResolvedValue(undefined), + promoteUserToAdmin: vi.fn().mockResolvedValue(undefined), + }; + const service = createAdminBootstrapService({ auth, repo }); + + await expect( + service.bootstrap({ + email: "ADMIN@EXAMPLE.COM", + name: "Portal Admin", + password: "sicheres-passwort-123", + }), + ).resolves.toEqual({ status: "created" }); + + expect(auth.signUpEmail).toHaveBeenCalledWith({ + email: "admin@example.com", + name: "Portal Admin", + password: "sicheres-passwort-123", + }); + expect(repo.promoteUserToAdmin).toHaveBeenCalledWith("admin-1"); + expect(auth.sendVerificationEmail).toHaveBeenCalledWith({ email: "admin@example.com" }); +}); diff --git a/src/modules/auth/registration.ts b/src/modules/auth/registration.ts new file mode 100644 index 0000000..f1eb232 --- /dev/null +++ b/src/modules/auth/registration.ts @@ -0,0 +1,276 @@ +import "server-only"; + +import { and, eq } from "drizzle-orm"; +import type { NodePgDatabase } from "drizzle-orm/node-postgres"; + +import { auditEvents, billingAddressVersions, editorialAccounts, users } from "@/db/schema"; +import type * as schema from "@/db/schema"; + +export type BillingAddressInput = { + addressLine1: string; + addressLine2?: string; + postalCode: string; + city: string; + countryCode: string; +}; + +export type RegistrationInput = { + companyName: string; + contactName: string; + email: string; + password: string; + billingAddress: BillingAddressInput; + actsForBusiness: boolean; + termsVersion: string; + privacyAcknowledged: boolean; +}; + +export type PendingEditorial = { + userId: string; + name: string; + contactName: string; + loginEmail: string; + status: "pending_email"; + acceptedTermsVersion: string; + acceptedTermsAt: Date; + privacyAcknowledgedAt: Date; + billingAddress: BillingAddressInput & { companyName: string; contactName: string }; +}; + +export type RegistrationAuth = { + signUpEmail(input: { email: string; name: string; password: string }): Promise<{ user: { id: string } }>; + sendVerificationEmail(input: { email: string }): Promise; +}; + +export type EditorialRegistrationRepository = { + createEditorial(input: PendingEditorial): Promise; + markPendingApproval(userId: string): Promise; +}; + +export type RegistrationAudit = { + recordVerificationInconsistency(input: { userId: string }): Promise; +}; + +export class RegistrationValidationError extends Error { + readonly name = "RegistrationValidationError"; + + constructor( + readonly field: "actsForBusiness" | "termsVersion" | "privacyAcknowledged", + message: string, + ) { + super(message); + } +} + +export function createRegistrationService({ + auth, + repo, + audit, + now = () => new Date(), +}: { + auth: RegistrationAuth; + repo: EditorialRegistrationRepository; + audit: RegistrationAudit; + now?: () => Date; +}) { + return { + async register(input: RegistrationInput): Promise<{ status: "pending_email" }> { + const registration = validateRegistration(input); + const result = await auth.signUpEmail({ + email: registration.loginEmail, + name: registration.contactName, + password: registration.password, + }); + const acceptedAt = now(); + + await repo.createEditorial({ + userId: result.user.id, + name: registration.companyName, + contactName: registration.contactName, + loginEmail: registration.loginEmail, + status: "pending_email", + acceptedTermsVersion: registration.termsVersion, + acceptedTermsAt: acceptedAt, + privacyAcknowledgedAt: acceptedAt, + billingAddress: { + companyName: registration.companyName, + contactName: registration.contactName, + ...registration.billingAddress, + }, + }); + + await auth.sendVerificationEmail({ email: registration.loginEmail }); + return { status: "pending_email" }; + }, + + async onEmailVerified(userId: string): Promise { + const transitioned = await repo.markPendingApproval(userId); + if (!transitioned) { + await audit.recordVerificationInconsistency({ userId }); + } + }, + }; +} + +export function createEditorialRegistrationRepository(database: NodePgDatabase): { + createEditorial(input: PendingEditorial): Promise; + markPendingApproval(userId: string): Promise; + recordVerificationInconsistency(input: { userId: string }): Promise; + canCreateSession(userId: string): Promise; +} { + return { + async createEditorial(input) { + await database.transaction(async (transaction) => { + const [user] = await transaction + .select({ id: users.id }) + .from(users) + .where(eq(users.id, input.userId)) + .limit(1); + + if (!user) { + return; + } + + const [existingEditorial] = await transaction + .select({ id: editorialAccounts.id }) + .from(editorialAccounts) + .where(eq(editorialAccounts.userId, input.userId)) + .limit(1); + + if (existingEditorial) { + return; + } + + const [editorial] = await transaction + .insert(editorialAccounts) + .values({ + userId: input.userId, + name: input.name, + contactName: input.contactName, + loginEmail: input.loginEmail, + status: input.status, + acceptedTermsVersion: input.acceptedTermsVersion, + acceptedTermsAt: input.acceptedTermsAt, + privacyAcknowledgedAt: input.privacyAcknowledgedAt, + }) + .returning({ id: editorialAccounts.id }); + + const [billingAddress] = await transaction + .insert(billingAddressVersions) + .values({ + editorialAccountId: editorial.id, + companyName: input.billingAddress.companyName, + contactName: input.billingAddress.contactName, + addressLine1: input.billingAddress.addressLine1, + addressLine2: input.billingAddress.addressLine2, + postalCode: input.billingAddress.postalCode, + city: input.billingAddress.city, + countryCode: input.billingAddress.countryCode, + validFrom: input.acceptedTermsAt, + createdByUserId: input.userId, + }) + .returning({ id: billingAddressVersions.id }); + + await transaction + .update(editorialAccounts) + .set({ currentBillingAddressVersionId: billingAddress.id, updatedAt: input.acceptedTermsAt }) + .where(eq(editorialAccounts.id, editorial.id)); + }); + }, + + async markPendingApproval(userId) { + const verifiedAt = new Date(); + const [transitioned] = await database + .update(editorialAccounts) + .set({ + status: "pending_approval", + emailVerifiedAt: verifiedAt, + updatedAt: verifiedAt, + }) + .where( + and( + eq(editorialAccounts.userId, userId), + eq(editorialAccounts.status, "pending_email"), + ), + ) + .returning({ id: editorialAccounts.id }); + + if (transitioned) { + return true; + } + + const [existingEditorial] = await database + .select({ id: editorialAccounts.id }) + .from(editorialAccounts) + .where(eq(editorialAccounts.userId, userId)) + .limit(1); + + return Boolean(existingEditorial); + }, + + async recordVerificationInconsistency({ userId }) { + await database.insert(auditEvents).values({ + eventType: "email_verification_without_editorial_account", + actorUserId: userId, + actorType: "system", + entityType: "user", + entityId: userId, + newValues: { reason: "no_editorial_account" }, + }); + }, + + async canCreateSession(userId) { + const [principal] = await database + .select({ role: users.role, status: editorialAccounts.status }) + .from(users) + .leftJoin(editorialAccounts, eq(editorialAccounts.userId, users.id)) + .where(eq(users.id, userId)) + .limit(1); + + return principal?.role === "ADMIN" || principal?.status === "active"; + }, + }; +} + +function validateRegistration(input: RegistrationInput): { + companyName: string; + contactName: string; + loginEmail: string; + password: string; + termsVersion: string; + billingAddress: BillingAddressInput; +} { + if (!input.actsForBusiness) { + throw new RegistrationValidationError( + "actsForBusiness", + "Bitte bestätigen Sie, dass Sie im Namen eines Unternehmens oder einer Redaktion handeln.", + ); + } + if (!input.termsVersion.trim()) { + throw new RegistrationValidationError( + "termsVersion", + "Bitte akzeptieren Sie die Nutzungs- und Lizenzbedingungen.", + ); + } + if (!input.privacyAcknowledged) { + throw new RegistrationValidationError( + "privacyAcknowledged", + "Bitte bestätigen Sie die Kenntnisnahme der Datenschutzerklärung.", + ); + } + + return { + companyName: input.companyName.trim(), + contactName: input.contactName.trim(), + loginEmail: input.email.trim().toLowerCase(), + password: input.password, + termsVersion: input.termsVersion.trim(), + billingAddress: { + addressLine1: input.billingAddress.addressLine1.trim(), + addressLine2: input.billingAddress.addressLine2?.trim() || undefined, + postalCode: input.billingAddress.postalCode.trim(), + city: input.billingAddress.city.trim(), + countryCode: input.billingAddress.countryCode.trim().toUpperCase(), + }, + }; +} diff --git a/src/modules/mail/mailer.test.ts b/src/modules/mail/mailer.test.ts new file mode 100644 index 0000000..9253f25 --- /dev/null +++ b/src/modules/mail/mailer.test.ts @@ -0,0 +1,36 @@ +import { expect, test, vi } from "vitest"; + +import { createMailer } from "./mailer"; + +test("sends a verification link through the configured SMTP boundary", async () => { + const transport = { sendMail: vi.fn().mockResolvedValue({ messageId: "message-1" }) }; + const mailer = createMailer({ from: "portal@example.com", transport }); + + await mailer.sendVerification({ + to: "editorial@example.com", + verificationUrl: "https://portal.example.com/api/auth/verify-email?token=secret-token", + }); + + expect(transport.sendMail).toHaveBeenCalledWith({ + from: "portal@example.com", + to: "editorial@example.com", + subject: "Bitte bestätigen Sie Ihre E-Mail-Adresse", + text: expect.stringContaining( + "https://portal.example.com/api/auth/verify-email?token=secret-token", + ), + }); +}); + +test("sends an approval notice without leaking SMTP credentials", async () => { + const transport = { sendMail: vi.fn().mockResolvedValue({ messageId: "message-2" }) }; + const mailer = createMailer({ from: "portal@example.com", transport }); + + await mailer.sendApprovalNotice({ to: "editorial@example.com", editorialName: "Neue Redaktion" }); + + expect(transport.sendMail).toHaveBeenCalledWith({ + from: "portal@example.com", + to: "editorial@example.com", + subject: "Ihr Zugang zum Redaktionsportal ist freigegeben", + text: expect.stringContaining("Neue Redaktion"), + }); +}); diff --git a/src/modules/mail/mailer.ts b/src/modules/mail/mailer.ts new file mode 100644 index 0000000..0c79d78 --- /dev/null +++ b/src/modules/mail/mailer.ts @@ -0,0 +1,64 @@ +import "server-only"; + +import nodemailer from "nodemailer"; + +import { env } from "@/config/env"; + +export type MailMessage = { + from: string; + to: string; + subject: string; + text: string; +}; + +export type MailTransport = { + sendMail(message: MailMessage): Promise; +}; + +export type Mailer = { + sendVerification(input: { to: string; verificationUrl: string }): Promise; + sendPasswordReset(input: { to: string; resetUrl: string }): Promise; + sendApprovalNotice(input: { to: string; editorialName: string }): Promise; +}; + +export function createMailer({ from, transport }: { from: string; transport: MailTransport }): Mailer { + async function send(message: Omit): Promise { + await transport.sendMail({ from, ...message }); + } + + return { + async sendVerification({ to, verificationUrl }) { + await send({ + to, + subject: "Bitte bestätigen Sie Ihre E-Mail-Adresse", + text: `Bitte bestätigen Sie Ihre E-Mail-Adresse für das Redaktionsportal:\n\n${verificationUrl}`, + }); + }, + async sendPasswordReset({ to, resetUrl }) { + await send({ + to, + subject: "Passwort für das Redaktionsportal zurücksetzen", + text: `Setzen Sie Ihr Passwort für das Redaktionsportal zurück:\n\n${resetUrl}`, + }); + }, + async sendApprovalNotice({ to, editorialName }) { + await send({ + to, + subject: "Ihr Zugang zum Redaktionsportal ist freigegeben", + text: `Der Zugang für ${editorialName} wurde freigegeben. Sie können sich jetzt im Redaktionsportal anmelden.`, + }); + }, + }; +} + +const smtpTransport = nodemailer.createTransport({ + host: env.SMTP_HOST, + port: env.SMTP_PORT, + secure: env.SMTP_PORT === 465, + auth: { + user: env.SMTP_USER, + pass: env.SMTP_PASSWORD, + }, +}); + +export const mailer = createMailer({ from: env.SMTP_FROM, transport: smtpTransport }); From a8d4e54ffb11a443e76bd4989bac99540928e278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 21:04:50 +0200 Subject: [PATCH 04/29] fix: harden editorial registration flow --- src/app/(public)/registrieren/page.tsx | 7 +- src/app/api/auth/[...all]/route.ts | 21 ++- src/modules/auth/auth.test.ts | 50 +++++- src/modules/auth/auth.ts | 133 ++++++++------- src/modules/auth/public-forms.test.tsx | 1 + src/modules/auth/public-forms.tsx | 24 ++- src/modules/auth/registration.test.ts | 94 ++++++++++- src/modules/auth/registration.ts | 224 ++++++++++++++++++++----- 8 files changed, 445 insertions(+), 109 deletions(-) diff --git a/src/app/(public)/registrieren/page.tsx b/src/app/(public)/registrieren/page.tsx index bff3a1f..fa79b03 100644 --- a/src/app/(public)/registrieren/page.tsx +++ b/src/app/(public)/registrieren/page.tsx @@ -3,7 +3,10 @@ import { redirect } from "next/navigation"; import { env } from "@/config/env"; import { registerEditorial } from "@/modules/auth/auth"; -import { RegistrationValidationError } from "@/modules/auth/registration"; +import { + CURRENT_TERMS_VERSION, + RegistrationValidationError, +} from "@/modules/auth/registration"; import { RegistrationForm, type RegistrationFormState, @@ -57,7 +60,7 @@ async function registerAction( countryCode: text(formData, "countryCode"), }, actsForBusiness: formData.has("actsForBusiness"), - termsVersion: formData.has("termsAccepted") ? text(formData, "termsVersion") : "", + termsVersion: formData.has("termsAccepted") ? CURRENT_TERMS_VERSION : "", privacyAcknowledged: formData.has("privacyAcknowledged"), }); } catch (error) { diff --git a/src/app/api/auth/[...all]/route.ts b/src/app/api/auth/[...all]/route.ts index 3e0413c..7f0a52e 100644 --- a/src/app/api/auth/[...all]/route.ts +++ b/src/app/api/auth/[...all]/route.ts @@ -1,5 +1,24 @@ import { toNextJsHandler } from "better-auth/next-js"; +import { NextResponse } from "next/server"; import { auth } from "@/modules/auth/auth"; -export const { GET, POST } = toNextJsHandler(auth); +const handlers = toNextJsHandler(auth); + +export const GET = handlers.GET; + +export async function POST( + request: Request, + { params }: { params: Promise<{ all: string[] }> }, +): Promise { + const { all } = await params; + + if (all.join("/") === "sign-up/email") { + return NextResponse.json( + { message: "Bitte verwenden Sie die Registrierung des Redaktionsportals." }, + { status: 403 }, + ); + } + + return handlers.POST(request); +} diff --git a/src/modules/auth/auth.test.ts b/src/modules/auth/auth.test.ts index 4ce2e44..09aac07 100644 --- a/src/modules/auth/auth.test.ts +++ b/src/modules/auth/auth.test.ts @@ -1,9 +1,50 @@ -import { expect, test } from "vitest"; +import { memoryAdapter } from "better-auth/adapters/memory"; +import { expect, test, vi } from "vitest"; -import { auth } from "./auth"; +import { POST } from "@/app/api/auth/[...all]/route"; -test("rejects direct Better Auth sign-up requests that bypass B2B registration", async () => { - const response = await auth.handler( +import { createPortalAuth } from "./auth"; +import { CURRENT_TERMS_VERSION } from "./registration"; + +test("allows the trusted registration service ingress while rejecting public direct sign-up", async () => { + const registrationRepository = { + createEditorial: vi.fn(), + markPendingApproval: vi.fn(), + removeUnverifiedAuthIdentity: vi.fn(), + recordRegistrationCompensationFailure: vi.fn(), + recordVerificationInconsistency: vi.fn(), + canCreateSession: vi.fn().mockResolvedValue(false), + }; + const { registrationService } = createPortalAuth({ + database: memoryAdapter({ user: [], account: [], session: [], verification: [] }), + mailerService: { + sendPasswordReset: vi.fn(), + sendVerification: vi.fn(), + }, + registrationRepository, + }); + + await expect( + registrationService.register({ + companyName: "Registration GmbH", + contactName: "Registration Service", + email: "registration@example.com", + password: "sicheres-passwort-123", + billingAddress: { + addressLine1: "Presseweg 1", + postalCode: "10115", + city: "Berlin", + countryCode: "DE", + }, + actsForBusiness: true, + termsVersion: CURRENT_TERMS_VERSION, + privacyAcknowledged: true, + }), + ).resolves.toEqual({ status: "pending_email" }); + + expect(registrationRepository.createEditorial).toHaveBeenCalledTimes(1); + + const response = await POST( new Request("http://localhost:3000/api/auth/sign-up/email", { method: "POST", headers: { "content-type": "application/json" }, @@ -13,6 +54,7 @@ test("rejects direct Better Auth sign-up requests that bypass B2B registration", password: "sicheres-passwort-123", }), }), + { params: Promise.resolve({ all: ["sign-up", "email"] }) }, ); expect(response.status).toBe(403); diff --git a/src/modules/auth/auth.ts b/src/modules/auth/auth.ts index 1c95a76..c69e7e9 100644 --- a/src/modules/auth/auth.ts +++ b/src/modules/auth/auth.ts @@ -1,8 +1,7 @@ import "server-only"; import { drizzleAdapter } from "@better-auth/drizzle-adapter"; -import { betterAuth } from "better-auth"; -import { APIError, createAuthMiddleware } from "better-auth/api"; +import { betterAuth, type BetterAuthOptions } from "better-auth"; import { env } from "@/config/env"; import { db } from "@/db/client"; @@ -15,11 +14,76 @@ import { type RegistrationInput, } from "./registration"; -const registrationRepository = createEditorialRegistrationRepository(db); +export function createPortalAuth({ + database, + mailerService, + registrationRepository, +}: { + database: NonNullable; + mailerService: Pick; + registrationRepository: ReturnType; +}) { + let registrationService: ReturnType | undefined; -export const auth = betterAuth({ - baseURL: env.BETTER_AUTH_URL, - secret: env.BETTER_AUTH_SECRET, + const auth = betterAuth({ + baseURL: env.BETTER_AUTH_URL, + secret: env.BETTER_AUTH_SECRET, + database, + emailAndPassword: { + enabled: true, + requireEmailVerification: true, + autoSignIn: false, + resetPasswordTokenExpiresIn: 60 * 60, + revokeSessionsOnPasswordReset: true, + async sendResetPassword({ user, url }) { + await mailerService.sendPasswordReset({ to: user.email, resetUrl: url }); + }, + }, + emailVerification: { + sendOnSignUp: false, + autoSignInAfterVerification: false, + expiresIn: 60 * 60, + async sendVerificationEmail({ user, url }) { + await mailerService.sendVerification({ to: user.email, verificationUrl: url }); + }, + async afterEmailVerification(user) { + if (!registrationService) { + throw new Error("Registration service is unavailable."); + } + await registrationService.onEmailVerified(user.id); + }, + }, + databaseHooks: { + session: { + create: { + async before(session) { + return registrationRepository.canCreateSession(session.userId); + }, + }, + }, + }, + }); + + registrationService = createRegistrationService({ + auth: { + async signUpEmail({ email, name, password }) { + return auth.api.signUpEmail({ body: { email, name, password } }); + }, + async sendVerificationEmail({ email }) { + await auth.api.sendVerificationEmail({ + body: { email, callbackURL: "/registrieren/bestaetigt" }, + }); + }, + }, + repo: registrationRepository, + audit: registrationRepository, + }); + + return { auth, registrationService }; +} + +const registrationRepository = createEditorialRegistrationRepository(db); +const portalAuth = createPortalAuth({ database: drizzleAdapter(db, { provider: "pg", schema: { @@ -29,61 +93,12 @@ export const auth = betterAuth({ verification: verifications, }, }), - hooks: { - before: createAuthMiddleware(async (context) => { - if (context.path === "/sign-up/email") { - throw new APIError("FORBIDDEN", { - message: "Bitte verwenden Sie die Registrierung des Redaktionsportals.", - }); - } - }), - }, - emailAndPassword: { - enabled: true, - requireEmailVerification: true, - autoSignIn: false, - resetPasswordTokenExpiresIn: 60 * 60, - revokeSessionsOnPasswordReset: true, - async sendResetPassword({ user, url }) { - await mailer.sendPasswordReset({ to: user.email, resetUrl: url }); - }, - }, - emailVerification: { - sendOnSignUp: false, - autoSignInAfterVerification: false, - expiresIn: 60 * 60, - async sendVerificationEmail({ user, url }) { - await mailer.sendVerification({ to: user.email, verificationUrl: url }); - }, - async afterEmailVerification(user) { - await registrationService.onEmailVerified(user.id); - }, - }, - databaseHooks: { - session: { - create: { - async before(session) { - return registrationRepository.canCreateSession(session.userId); - }, - }, - }, - }, + mailerService: mailer, + registrationRepository, }); -export const registrationService = createRegistrationService({ - auth: { - async signUpEmail({ email, name, password }) { - return auth.api.signUpEmail({ body: { email, name, password } }); - }, - async sendVerificationEmail({ email }) { - await auth.api.sendVerificationEmail({ - body: { email, callbackURL: "/registrieren/bestaetigt" }, - }); - }, - }, - repo: registrationRepository, - audit: registrationRepository, -}); +export const auth = portalAuth.auth; +export const registrationService = portalAuth.registrationService; export function registerEditorial(input: RegistrationInput): Promise<{ status: "pending_email" }> { return registrationService.register(input); diff --git a/src/modules/auth/public-forms.test.tsx b/src/modules/auth/public-forms.test.tsx index 5d5aefe..2db2575 100644 --- a/src/modules/auth/public-forms.test.tsx +++ b/src/modules/auth/public-forms.test.tsx @@ -38,4 +38,5 @@ test("registration presents separate B2B, terms, and privacy acknowledgements", "href", "https://example.com/datenschutz", ); + expect(document.querySelector('input[name="termsVersion"]')).toBeNull(); }); diff --git a/src/modules/auth/public-forms.tsx b/src/modules/auth/public-forms.tsx index 6f39b60..4accdaa 100644 --- a/src/modules/auth/public-forms.tsx +++ b/src/modules/auth/public-forms.tsx @@ -6,7 +6,20 @@ import { authClient } from "./client"; export type RegistrationFormState = { errors?: Partial< - Record<"actsForBusiness" | "termsVersion" | "privacyAcknowledged", string> + Record< + | "companyName" + | "contactName" + | "email" + | "password" + | "addressLine1" + | "postalCode" + | "city" + | "countryCode" + | "actsForBusiness" + | "termsVersion" + | "privacyAcknowledged", + string + > >; }; @@ -34,28 +47,32 @@ export function RegistrationForm({ return (
-
+ + + + + + + +
diff --git a/src/modules/auth/registration.test.ts b/src/modules/auth/registration.test.ts index 1e9b398..617b8e0 100644 --- a/src/modules/auth/registration.test.ts +++ b/src/modules/auth/registration.test.ts @@ -1,6 +1,7 @@ import { describe, expect, test, vi } from "vitest"; import { + CURRENT_TERMS_VERSION, RegistrationValidationError, createRegistrationService, type RegistrationInput, @@ -20,10 +21,14 @@ const validRegistration: RegistrationInput = { countryCode: "DE", }, actsForBusiness: true, - termsVersion: "2026-08", + termsVersion: CURRENT_TERMS_VERSION, privacyAcknowledged: true, }; +type RegistrationChange = Partial> & { + billingAddress?: RegistrationInput["billingAddress"]; +}; + function createService() { const auth = { signUpEmail: vi.fn().mockResolvedValue({ user: { id: "user-1" } }), @@ -32,8 +37,10 @@ function createService() { const repo = { createEditorial: vi.fn().mockResolvedValue(undefined), markPendingApproval: vi.fn().mockResolvedValue(true), + removeUnverifiedAuthIdentity: vi.fn().mockResolvedValue(true), }; const audit = { + recordRegistrationCompensationFailure: vi.fn().mockResolvedValue(undefined), recordVerificationInconsistency: vi.fn().mockResolvedValue(undefined), }; const now = new Date("2026-08-09T10:00:00.000Z"); @@ -63,7 +70,7 @@ describe("editorial registration", () => { contactName: "Mara Muster", loginEmail: "mara.muster@example.com", status: "pending_email", - acceptedTermsVersion: "2026-08", + acceptedTermsVersion: CURRENT_TERMS_VERSION, acceptedTermsAt: new Date("2026-08-09T10:00:00.000Z"), privacyAcknowledgedAt: new Date("2026-08-09T10:00:00.000Z"), billingAddress: { @@ -105,7 +112,7 @@ describe("editorial registration", () => { ).rejects.toEqual( new RegistrationValidationError( "termsVersion", - "Bitte akzeptieren Sie die Nutzungs- und Lizenzbedingungen.", + "Bitte akzeptieren Sie die aktuell gültigen Nutzungs- und Lizenzbedingungen.", ), ); await expect( @@ -118,6 +125,87 @@ describe("editorial registration", () => { ); }); + test.each<[string, RegistrationChange, string]>([ + ["companyName", { companyName: " " }, "Bitte geben Sie den Namen der Redaktion oder des Unternehmens an."], + ["contactName", { contactName: " " }, "Bitte geben Sie eine Ansprechperson an."], + ["email", { email: "keine-adresse" }, "Bitte geben Sie eine gültige E-Mail-Adresse an."], + ["password", { password: "" }, "Bitte geben Sie ein Passwort an."], + [ + "addressLine1", + { billingAddress: { ...validRegistration.billingAddress, addressLine1: " " } }, + "Bitte geben Sie Straße und Hausnummer an.", + ], + [ + "postalCode", + { billingAddress: { ...validRegistration.billingAddress, postalCode: " " } }, + "Bitte geben Sie die Postleitzahl an.", + ], + [ + "city", + { billingAddress: { ...validRegistration.billingAddress, city: " " } }, + "Bitte geben Sie den Ort an.", + ], + [ + "countryCode", + { billingAddress: { ...validRegistration.billingAddress, countryCode: "Deutschland" } }, + "Bitte geben Sie einen zweistelligen ISO-Ländercode an.", + ], + ])("rejects missing or malformed required %s data on the server", async (field, change, message) => { + const { auth, repo, service } = createService(); + const input = { + ...validRegistration, + ...change, + billingAddress: change.billingAddress ?? validRegistration.billingAddress, + }; + + await expect(service.register(input)).rejects.toEqual( + new RegistrationValidationError(field as RegistrationValidationError["field"], message), + ); + + expect(auth.signUpEmail).not.toHaveBeenCalled(); + expect(repo.createEditorial).not.toHaveBeenCalled(); + }); + + test("pins the accepted terms to the server-owned current version", async () => { + const { auth, service } = createService(); + + await expect( + service.register({ ...validRegistration, termsVersion: "arbitrary-browser-value" }), + ).rejects.toEqual( + new RegistrationValidationError( + "termsVersion", + "Bitte akzeptieren Sie die aktuell gültigen Nutzungs- und Lizenzbedingungen.", + ), + ); + + expect(auth.signUpEmail).not.toHaveBeenCalled(); + }); + + test("compensates a failed editorial transaction by removing the new unverified auth identity", async () => { + const { audit, repo, service } = createService(); + const persistenceError = new Error("editorial persistence failed"); + repo.createEditorial.mockRejectedValue(persistenceError); + + await expect(service.register(validRegistration)).rejects.toBe(persistenceError); + + expect(repo.removeUnverifiedAuthIdentity).toHaveBeenCalledWith({ + email: "mara.muster@example.com", + userId: "user-1", + }); + expect(audit.recordRegistrationCompensationFailure).not.toHaveBeenCalled(); + }); + + test("keeps the original persistence failure and audits a failed compensation without request data", async () => { + const { audit, repo, service } = createService(); + const persistenceError = new Error("editorial persistence failed"); + repo.createEditorial.mockRejectedValue(persistenceError); + repo.removeUnverifiedAuthIdentity.mockRejectedValue(new Error("cleanup failed")); + + await expect(service.register(validRegistration)).rejects.toBe(persistenceError); + + expect(audit.recordRegistrationCompensationFailure).toHaveBeenCalledWith({ userId: "user-1" }); + }); + test("moves a verified account from pending email to pending approval", async () => { const { audit, repo, service } = createService(); diff --git a/src/modules/auth/registration.ts b/src/modules/auth/registration.ts index f1eb232..54188c6 100644 --- a/src/modules/auth/registration.ts +++ b/src/modules/auth/registration.ts @@ -2,10 +2,34 @@ import "server-only"; import { and, eq } from "drizzle-orm"; import type { NodePgDatabase } from "drizzle-orm/node-postgres"; +import { z } from "zod"; -import { auditEvents, billingAddressVersions, editorialAccounts, users } from "@/db/schema"; +import { + accounts, + auditEvents, + billingAddressVersions, + editorialAccounts, + sessions, + users, + verifications, +} from "@/db/schema"; import type * as schema from "@/db/schema"; +export const CURRENT_TERMS_VERSION = "2026-08"; + +export type RegistrationField = + | "companyName" + | "contactName" + | "email" + | "password" + | "addressLine1" + | "postalCode" + | "city" + | "countryCode" + | "actsForBusiness" + | "termsVersion" + | "privacyAcknowledged"; + export type BillingAddressInput = { addressLine1: string; addressLine2?: string; @@ -45,19 +69,18 @@ export type RegistrationAuth = { export type EditorialRegistrationRepository = { createEditorial(input: PendingEditorial): Promise; markPendingApproval(userId: string): Promise; + removeUnverifiedAuthIdentity(input: { userId: string; email: string }): Promise; }; export type RegistrationAudit = { recordVerificationInconsistency(input: { userId: string }): Promise; + recordRegistrationCompensationFailure(input: { userId: string }): Promise; }; export class RegistrationValidationError extends Error { readonly name = "RegistrationValidationError"; - constructor( - readonly field: "actsForBusiness" | "termsVersion" | "privacyAcknowledged", - message: string, - ) { + constructor(readonly field: RegistrationField, message: string) { super(message); } } @@ -83,21 +106,37 @@ export function createRegistrationService({ }); const acceptedAt = now(); - await repo.createEditorial({ - userId: result.user.id, - name: registration.companyName, - contactName: registration.contactName, - loginEmail: registration.loginEmail, - status: "pending_email", - acceptedTermsVersion: registration.termsVersion, - acceptedTermsAt: acceptedAt, - privacyAcknowledgedAt: acceptedAt, - billingAddress: { - companyName: registration.companyName, + try { + await repo.createEditorial({ + userId: result.user.id, + name: registration.companyName, contactName: registration.contactName, - ...registration.billingAddress, - }, - }); + loginEmail: registration.loginEmail, + status: "pending_email", + acceptedTermsVersion: CURRENT_TERMS_VERSION, + acceptedTermsAt: acceptedAt, + privacyAcknowledgedAt: acceptedAt, + billingAddress: { + companyName: registration.companyName, + contactName: registration.contactName, + ...registration.billingAddress, + }, + }); + } catch (error) { + try { + await repo.removeUnverifiedAuthIdentity({ + userId: result.user.id, + email: registration.loginEmail, + }); + } catch { + try { + await audit.recordRegistrationCompensationFailure({ userId: result.user.id }); + } catch { + // Preserve the original editorial persistence error. + } + } + throw error; + } await auth.sendVerificationEmail({ email: registration.loginEmail }); return { status: "pending_email" }; @@ -112,12 +151,12 @@ export function createRegistrationService({ }; } -export function createEditorialRegistrationRepository(database: NodePgDatabase): { - createEditorial(input: PendingEditorial): Promise; - markPendingApproval(userId: string): Promise; - recordVerificationInconsistency(input: { userId: string }): Promise; - canCreateSession(userId: string): Promise; -} { +export function createEditorialRegistrationRepository( + database: NodePgDatabase, +): EditorialRegistrationRepository & + RegistrationAudit & { + canCreateSession(userId: string): Promise; + } { return { async createEditorial(input) { await database.transaction(async (transaction) => { @@ -219,6 +258,58 @@ export function createEditorialRegistrationRepository(database: NodePgDatabase { + const [user] = await transaction + .select({ id: users.id, emailVerified: users.emailVerified, role: users.role }) + .from(users) + .where(eq(users.id, userId)) + .limit(1); + + if (!user || user.emailVerified || user.role !== "EDITORIAL") { + return false; + } + + const [existingEditorial] = await transaction + .select({ id: editorialAccounts.id }) + .from(editorialAccounts) + .where(eq(editorialAccounts.userId, userId)) + .limit(1); + + if (existingEditorial) { + return false; + } + + await transaction.delete(sessions).where(eq(sessions.userId, userId)); + await transaction.delete(accounts).where(eq(accounts.userId, userId)); + await transaction.delete(verifications).where(eq(verifications.identifier, email)); + + const [deletedUser] = await transaction + .delete(users) + .where( + and( + eq(users.id, userId), + eq(users.emailVerified, false), + eq(users.role, "EDITORIAL"), + ), + ) + .returning({ id: users.id }); + + return Boolean(deletedUser); + }); + }, + async canCreateSession(userId) { const [principal] = await database .select({ role: users.role, status: editorialAccounts.status }) @@ -237,7 +328,6 @@ function validateRegistration(input: RegistrationInput): { contactName: string; loginEmail: string; password: string; - termsVersion: string; billingAddress: BillingAddressInput; } { if (!input.actsForBusiness) { @@ -246,10 +336,10 @@ function validateRegistration(input: RegistrationInput): { "Bitte bestätigen Sie, dass Sie im Namen eines Unternehmens oder einer Redaktion handeln.", ); } - if (!input.termsVersion.trim()) { + if (trim(input.termsVersion) !== CURRENT_TERMS_VERSION) { throw new RegistrationValidationError( "termsVersion", - "Bitte akzeptieren Sie die Nutzungs- und Lizenzbedingungen.", + "Bitte akzeptieren Sie die aktuell gültigen Nutzungs- und Lizenzbedingungen.", ); } if (!input.privacyAcknowledged) { @@ -259,18 +349,76 @@ function validateRegistration(input: RegistrationInput): { ); } + const companyName = trim(input.companyName); + if (!companyName) { + throw new RegistrationValidationError( + "companyName", + "Bitte geben Sie den Namen der Redaktion oder des Unternehmens an.", + ); + } + + const contactName = trim(input.contactName); + if (!contactName) { + throw new RegistrationValidationError("contactName", "Bitte geben Sie eine Ansprechperson an."); + } + + const loginEmail = trim(input.email).toLowerCase(); + if (!z.email().safeParse(loginEmail).success) { + throw new RegistrationValidationError("email", "Bitte geben Sie eine gültige E-Mail-Adresse an."); + } + + const password = typeof input.password === "string" ? input.password : ""; + if (!password) { + throw new RegistrationValidationError("password", "Bitte geben Sie ein Passwort an."); + } + if (password.length < 8) { + throw new RegistrationValidationError( + "password", + "Bitte verwenden Sie ein Passwort mit mindestens acht Zeichen.", + ); + } + + const addressLine1 = trim(input.billingAddress?.addressLine1); + if (!addressLine1) { + throw new RegistrationValidationError( + "addressLine1", + "Bitte geben Sie Straße und Hausnummer an.", + ); + } + + const postalCode = trim(input.billingAddress?.postalCode); + if (!postalCode) { + throw new RegistrationValidationError("postalCode", "Bitte geben Sie die Postleitzahl an."); + } + + const city = trim(input.billingAddress?.city); + if (!city) { + throw new RegistrationValidationError("city", "Bitte geben Sie den Ort an."); + } + + const countryCode = trim(input.billingAddress?.countryCode).toUpperCase(); + if (!/^[A-Z]{2}$/.test(countryCode)) { + throw new RegistrationValidationError( + "countryCode", + "Bitte geben Sie einen zweistelligen ISO-Ländercode an.", + ); + } + return { - companyName: input.companyName.trim(), - contactName: input.contactName.trim(), - loginEmail: input.email.trim().toLowerCase(), - password: input.password, - termsVersion: input.termsVersion.trim(), + companyName, + contactName, + loginEmail, + password, billingAddress: { - addressLine1: input.billingAddress.addressLine1.trim(), - addressLine2: input.billingAddress.addressLine2?.trim() || undefined, - postalCode: input.billingAddress.postalCode.trim(), - city: input.billingAddress.city.trim(), - countryCode: input.billingAddress.countryCode.trim().toUpperCase(), + addressLine1, + addressLine2: trim(input.billingAddress?.addressLine2) || undefined, + postalCode, + city, + countryCode, }, }; } + +function trim(value: unknown): string { + return typeof value === "string" ? value.trim() : ""; +} From 3584b4a7a7921250b1ff021df2ccf2e74e3a5193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 21:15:30 +0200 Subject: [PATCH 05/29] feat: add editorial approval and account guards --- src/app/admin/layout.tsx | 25 ++ src/app/admin/redaktionen/[id]/page.tsx | 74 +++++ src/app/admin/redaktionen/page.tsx | 47 +++ src/app/redaktion/profil/page.tsx | 61 ++++ src/modules/auth/principal.test.ts | 46 +++ src/modules/auth/principal.ts | 131 +++++++++ src/modules/editorials/service.test.ts | 113 +++++++ src/modules/editorials/service.ts | 376 ++++++++++++++++++++++++ src/modules/mail/mailer.ts | 6 +- 9 files changed, 878 insertions(+), 1 deletion(-) create mode 100644 src/app/admin/layout.tsx create mode 100644 src/app/admin/redaktionen/[id]/page.tsx create mode 100644 src/app/admin/redaktionen/page.tsx create mode 100644 src/app/redaktion/profil/page.tsx create mode 100644 src/modules/auth/principal.test.ts create mode 100644 src/modules/auth/principal.ts create mode 100644 src/modules/editorials/service.test.ts create mode 100644 src/modules/editorials/service.ts diff --git a/src/app/admin/layout.tsx b/src/app/admin/layout.tsx new file mode 100644 index 0000000..9b5f245 --- /dev/null +++ b/src/app/admin/layout.tsx @@ -0,0 +1,25 @@ +import type { ReactNode } from "react"; + +import { headers } from "next/headers"; +import Link from "next/link"; + +import { requireAdmin } from "@/modules/auth/principal"; + +export default async function AdminLayout({ children }: Readonly<{ children: ReactNode }>) { + await requireAdmin(new Headers(await headers())); + + return ( +
+
+ + Leon Tonhäuser + + Administration +
+ + {children} +
+ ); +} diff --git a/src/app/admin/redaktionen/[id]/page.tsx b/src/app/admin/redaktionen/[id]/page.tsx new file mode 100644 index 0000000..dd2e7e0 --- /dev/null +++ b/src/app/admin/redaktionen/[id]/page.tsx @@ -0,0 +1,74 @@ +import { and, eq, isNull } from "drizzle-orm"; +import { notFound } from "next/navigation"; + +import { db } from "@/db/client"; +import { albumGrants, editorialAccounts } from "@/db/schema"; + +export default async function EditorialDetailPage({ + params, +}: Readonly<{ params: Promise<{ id: string }> }>) { + const { id } = await params; + const [editorial] = await db + .select({ + id: editorialAccounts.id, + name: editorialAccounts.name, + contactName: editorialAccounts.contactName, + loginEmail: editorialAccounts.loginEmail, + status: editorialAccounts.status, + emailVerifiedAt: editorialAccounts.emailVerifiedAt, + currentPriceCents: editorialAccounts.currentPriceCents, + }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, id)) + .limit(1); + if (!editorial) { + notFound(); + } + + const [grant] = await db + .select({ id: albumGrants.id }) + .from(albumGrants) + .where( + and(eq(albumGrants.editorialAccountId, editorial.id), isNull(albumGrants.revokedAt)), + ) + .limit(1); + + return ( +
+

Redaktion

+

{editorial.name}

+
+
Ansprechperson
+
{editorial.contactName}
+
Anmelde-E-Mail
+
{editorial.loginEmail}
+
Status
+
{editorial.status}
+
E-Mail bestätigt
+
{editorial.emailVerifiedAt ? "Ja" : "Nein"}
+
Individueller Nettopreis
+
+ {editorial.currentPriceCents === null + ? "Noch nicht festgelegt" + : formatCents(editorial.currentPriceCents)} +
+
+ +
+

Freigabe

+ +

+ {grant + ? "Die Freigabe bleibt bis zur Verwaltungsoberfläche für Albumrechte deaktiviert." + : "Eine Freigabe ist erst möglich, wenn mindestens ein aktives Albumrecht zugewiesen wurde. Die Verwaltung der Albumrechte folgt im nächsten Schritt."} +

+
+
+ ); +} + +function formatCents(cents: number): string { + return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(cents / 100); +} diff --git a/src/app/admin/redaktionen/page.tsx b/src/app/admin/redaktionen/page.tsx new file mode 100644 index 0000000..c498233 --- /dev/null +++ b/src/app/admin/redaktionen/page.tsx @@ -0,0 +1,47 @@ +import { desc } from "drizzle-orm"; + +import { db } from "@/db/client"; +import { editorialAccounts } from "@/db/schema"; + +export default async function EditorialsPage() { + const editorials = await db + .select({ + id: editorialAccounts.id, + name: editorialAccounts.name, + contactName: editorialAccounts.contactName, + loginEmail: editorialAccounts.loginEmail, + status: editorialAccounts.status, + currentPriceCents: editorialAccounts.currentPriceCents, + createdAt: editorialAccounts.createdAt, + }) + .from(editorialAccounts) + .orderBy(desc(editorialAccounts.createdAt)); + + return ( +
+

Kontoverwaltung

+

Redaktionen

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

Noch keine Redaktionen registriert.

+ ) : ( +
    + {editorials.map((editorial) => ( +
  • + {editorial.name} +

    + {editorial.contactName} · {editorial.loginEmail} · Status: {editorial.status} + {editorial.currentPriceCents === null + ? " · Preis noch nicht festgelegt" + : ` · Netto ${formatCents(editorial.currentPriceCents)}`} +

    +
  • + ))} +
+ )} +
+ ); +} + +function formatCents(cents: number): string { + return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(cents / 100); +} diff --git a/src/app/redaktion/profil/page.tsx b/src/app/redaktion/profil/page.tsx new file mode 100644 index 0000000..1510157 --- /dev/null +++ b/src/app/redaktion/profil/page.tsx @@ -0,0 +1,61 @@ +import { eq } from "drizzle-orm"; +import { headers } from "next/headers"; + +import { db } from "@/db/client"; +import { billingAddressVersions, editorialAccounts } from "@/db/schema"; +import { requireActiveEditorial } from "@/modules/auth/principal"; + +export default async function EditorialProfilePage() { + const principal = await requireActiveEditorial(new Headers(await headers())); + const [editorial] = await db + .select({ + name: editorialAccounts.name, + contactName: editorialAccounts.contactName, + loginEmail: editorialAccounts.loginEmail, + addressLine1: billingAddressVersions.addressLine1, + addressLine2: billingAddressVersions.addressLine2, + postalCode: billingAddressVersions.postalCode, + city: billingAddressVersions.city, + countryCode: billingAddressVersions.countryCode, + }) + .from(editorialAccounts) + .leftJoin( + billingAddressVersions, + eq(editorialAccounts.currentBillingAddressVersionId, billingAddressVersions.id), + ) + .where(eq(editorialAccounts.id, principal.editorialId)) + .limit(1); + + return ( +
+
+

Redaktionskonto

+

Profil

+
+
Redaktion
+
{editorial?.name}
+
Ansprechperson
+
{editorial?.contactName}
+
Anmelde-E-Mail
+
{editorial?.loginEmail}
+
Rechnungsadresse
+
+ {editorial?.addressLine1 ? ( +
+ {editorial.addressLine1} + {editorial.addressLine2 ?
: null} + {editorial.addressLine2} +
+ {editorial.postalCode} {editorial.city} +
+ {editorial.countryCode} +
+ ) : ( + "Keine Rechnungsadresse hinterlegt." + )} +
+
+
+
+ ); +} diff --git a/src/modules/auth/principal.test.ts b/src/modules/auth/principal.test.ts new file mode 100644 index 0000000..02e1a33 --- /dev/null +++ b/src/modules/auth/principal.test.ts @@ -0,0 +1,46 @@ +import { expect, test } from "vitest"; + +import { createPrincipalGuard } from "./principal"; + +const editorialSession = { + user: { id: "editorial-user", role: "EDITORIAL" as const }, +}; + +test("rejects a suspended editorial after session authentication", async () => { + const guard = createPrincipalGuard({ + getSession: async () => editorialSession, + getAccount: async () => ({ id: "editorial-1", status: "suspended" as const }), + }); + + await expect(guard.requireActiveEditorial(new Headers())).rejects.toMatchObject({ + code: "ACCOUNT_SUSPENDED", + }); +}); + +test("uses the authenticated session user to resolve an editorial principal", async () => { + let accountUserId: string | undefined; + const guard = createPrincipalGuard({ + getSession: async () => editorialSession, + getAccount: async (userId) => { + accountUserId = userId; + return { id: "editorial-1", status: "active" }; + }, + }); + + await expect(guard.requireActiveEditorial(new Headers({ "x-editorial-id": "forged" }))).resolves.toEqual({ + userId: "editorial-user", + role: "EDITORIAL", + editorialId: "editorial-1", + status: "active", + }); + expect(accountUserId).toBe("editorial-user"); +}); + +test("rejects non-admin users from the admin guard", async () => { + const guard = createPrincipalGuard({ + getSession: async () => editorialSession, + getAccount: async () => ({ id: "editorial-1", status: "active" as const }), + }); + + await expect(guard.requireAdmin(new Headers())).rejects.toMatchObject({ code: "ADMIN_REQUIRED" }); +}); diff --git a/src/modules/auth/principal.ts b/src/modules/auth/principal.ts new file mode 100644 index 0000000..b344578 --- /dev/null +++ b/src/modules/auth/principal.ts @@ -0,0 +1,131 @@ +import "server-only"; + +import { eq } from "drizzle-orm"; + +import { auth } from "@/modules/auth/auth"; +import { db } from "@/db/client"; +import { editorialAccounts } from "@/db/schema"; +import { accountStatuses } from "@/db/schema/editorials"; + +export type AccountStatus = (typeof accountStatuses)[number]; + +export type PortalPrincipal = { + userId: string; + role: "ADMIN" | "EDITORIAL"; + editorialId: string | null; + status: AccountStatus; +}; + +type Session = { user: { id: string; role: "ADMIN" | "EDITORIAL" } } | null; +type EditorialAccount = { id: string; status: AccountStatus } | null; + +export type PrincipalGuardDependencies = { + getSession(requestHeaders: Headers): Promise; + getAccount(userId: string): Promise; +}; + +export class PrincipalAuthorizationError extends Error { + readonly name = "PrincipalAuthorizationError"; + + constructor( + readonly code: + | "AUTHENTICATION_REQUIRED" + | "ADMIN_REQUIRED" + | "EDITORIAL_ACCOUNT_NOT_FOUND" + | "ACCOUNT_PENDING_EMAIL" + | "ACCOUNT_PENDING_APPROVAL" + | "ACCOUNT_SUSPENDED" + | "ACCOUNT_REJECTED", + ) { + super(code); + } +} + +export function createPrincipalGuard({ getSession, getAccount }: PrincipalGuardDependencies) { + async function getAuthenticatedSession(requestHeaders: Headers): Promise> { + const session = await getSession(requestHeaders); + if (!session) { + throw new PrincipalAuthorizationError("AUTHENTICATION_REQUIRED"); + } + return session; + } + + return { + async requireAdmin(requestHeaders: Headers): Promise { + const session = await getAuthenticatedSession(requestHeaders); + if (session.user.role !== "ADMIN") { + throw new PrincipalAuthorizationError("ADMIN_REQUIRED"); + } + + return { + userId: session.user.id, + role: "ADMIN", + editorialId: null, + status: "active", + }; + }, + + async requireActiveEditorial( + requestHeaders: Headers, + ): Promise { + const session = await getAuthenticatedSession(requestHeaders); + if (session.user.role !== "EDITORIAL") { + throw new PrincipalAuthorizationError("ADMIN_REQUIRED"); + } + + const account = await getAccount(session.user.id); + if (!account) { + throw new PrincipalAuthorizationError("EDITORIAL_ACCOUNT_NOT_FOUND"); + } + if (account.status !== "active") { + throw new PrincipalAuthorizationError(accountStatusErrorCode(account.status)); + } + + return { + userId: session.user.id, + role: "EDITORIAL", + editorialId: account.id, + status: account.status, + }; + }, + }; +} + +function accountStatusErrorCode( + status: Exclude, +): PrincipalAuthorizationError["code"] { + const codes = { + pending_email: "ACCOUNT_PENDING_EMAIL", + pending_approval: "ACCOUNT_PENDING_APPROVAL", + suspended: "ACCOUNT_SUSPENDED", + rejected: "ACCOUNT_REJECTED", + } as const; + return codes[status]; +} + +export const principalGuard = createPrincipalGuard({ + async getSession(requestHeaders) { + const session = await auth.api.getSession({ headers: requestHeaders }); + if (!session) { + return null; + } + + const role = (session.user as { role?: unknown }).role; + if (role !== "ADMIN" && role !== "EDITORIAL") { + return null; + } + return { user: { id: session.user.id, role } }; + }, + + async getAccount(userId) { + const [account] = await db + .select({ id: editorialAccounts.id, status: editorialAccounts.status }) + .from(editorialAccounts) + .where(eq(editorialAccounts.userId, userId)) + .limit(1); + return account ?? null; + }, +}); + +export const requireAdmin = principalGuard.requireAdmin; +export const requireActiveEditorial = principalGuard.requireActiveEditorial; diff --git a/src/modules/editorials/service.test.ts b/src/modules/editorials/service.test.ts new file mode 100644 index 0000000..3f61cc5 --- /dev/null +++ b/src/modules/editorials/service.test.ts @@ -0,0 +1,113 @@ +import { expect, test, vi } from "vitest"; + +import { + createEditorialService, + type EditorialServiceRepository, +} from "./service"; + +function createRepository(): EditorialServiceRepository & { + prepareApproval: ReturnType; + recordApprovalNoticeSent: ReturnType; + recordApprovalNoticeFailure: ReturnType; + replaceBillingAddress: ReturnType; + transitionStatus: ReturnType; +} { + return { + prepareApproval: vi.fn().mockResolvedValue({ + editorialId: "e1", + to: "editorial@example.com", + editorialName: "Neue Redaktion", + }), + recordApprovalNoticeSent: vi.fn().mockResolvedValue(undefined), + recordApprovalNoticeFailure: vi.fn().mockResolvedValue(undefined), + replaceBillingAddress: vi.fn().mockResolvedValue("address-2"), + transitionStatus: vi.fn().mockResolvedValue(undefined), + }; +} + +test("approval requires a positive price in cents", async () => { + const repository = createRepository(); + const service = createEditorialService({ + repository, + mailer: { sendApprovalNotice: vi.fn() }, + }); + + await expect( + service.approveEditorial({ editorialId: "e1", priceCents: 0, adminUserId: "a1" }), + ).rejects.toMatchObject({ code: "INVALID_PRICE" }); + expect(repository.prepareApproval).not.toHaveBeenCalled(); +}); + +test("approval activates the account and sends the approval notice", async () => { + const repository = createRepository(); + const mailer = { sendApprovalNotice: vi.fn().mockResolvedValue(undefined) }; + const service = createEditorialService({ repository, mailer }); + + await service.approveEditorial({ editorialId: "e1", priceCents: 1500, adminUserId: "a1" }); + + expect(repository.prepareApproval).toHaveBeenCalledWith({ + editorialId: "e1", + priceCents: 1500, + adminUserId: "a1", + }); + expect(mailer.sendApprovalNotice).toHaveBeenCalledWith( + expect.objectContaining({ editorialId: "e1" }), + ); + expect(repository.recordApprovalNoticeSent).toHaveBeenCalledWith({ + editorialId: "e1", + adminUserId: "a1", + }); +}); + +test("records a failed approval notice without undoing approval", async () => { + const repository = createRepository(); + const mailer = { sendApprovalNotice: vi.fn().mockRejectedValue(new Error("SMTP unavailable")) }; + const service = createEditorialService({ repository, mailer }); + + await expect( + service.approveEditorial({ editorialId: "e1", priceCents: 1500, adminUserId: "a1" }), + ).rejects.toThrow("SMTP unavailable"); + expect(repository.recordApprovalNoticeFailure).toHaveBeenCalledWith({ + editorialId: "e1", + adminUserId: "a1", + }); +}); + +test("rejects approval until an active album grant exists", async () => { + const repository = createRepository(); + repository.prepareApproval.mockRejectedValueOnce( + Object.assign(new Error("Album grant required"), { code: "ALBUM_GRANT_REQUIRED" }), + ); + const service = createEditorialService({ repository, mailer: { sendApprovalNotice: vi.fn() } }); + + await expect( + service.approveEditorial({ editorialId: "e1", priceCents: 1500, adminUserId: "a1" }), + ).rejects.toMatchObject({ code: "ALBUM_GRANT_REQUIRED" }); +}); + +test("creates a new billing-address version instead of changing an existing address", async () => { + const repository = createRepository(); + const service = createEditorialService({ repository, mailer: { sendApprovalNotice: vi.fn() } }); + + await expect( + service.replaceBillingAddress("e1", { + companyName: "Neue Redaktion GmbH", + contactName: "Neue Ansprechperson", + addressLine1: "Presseweg 2", + postalCode: "10115", + city: "Berlin", + countryCode: "de", + }), + ).resolves.toBe("address-2"); + expect(repository.replaceBillingAddress).toHaveBeenCalledWith({ + editorialId: "e1", + input: { + companyName: "Neue Redaktion GmbH", + contactName: "Neue Ansprechperson", + addressLine1: "Presseweg 2", + postalCode: "10115", + city: "Berlin", + countryCode: "DE", + }, + }); +}); diff --git a/src/modules/editorials/service.ts b/src/modules/editorials/service.ts new file mode 100644 index 0000000..a687c65 --- /dev/null +++ b/src/modules/editorials/service.ts @@ -0,0 +1,376 @@ +import "server-only"; + +import { and, desc, eq, inArray, isNull } from "drizzle-orm"; +import type { NodePgDatabase } from "drizzle-orm/node-postgres"; + +import { db } from "@/db/client"; +import { + albumGrants, + auditEvents, + billingAddressVersions, + editorialAccounts, +} from "@/db/schema"; +import type * as schema from "@/db/schema"; +import type { AccountStatus } from "@/modules/auth/principal"; +import { mailer, type Mailer } from "@/modules/mail/mailer"; + +export type BillingAddressInput = { + companyName: string; + contactName: string; + addressLine1: string; + addressLine2?: string; + postalCode: string; + city: string; + countryCode: string; +}; + +type ApprovalNotice = { + editorialId: string; + to: string; + editorialName: string; +}; + +export type EditorialServiceRepository = { + prepareApproval(input: { + editorialId: string; + priceCents: number; + adminUserId: string; + }): Promise; + recordApprovalNoticeSent(input: { editorialId: string; adminUserId: string }): Promise; + recordApprovalNoticeFailure(input: { editorialId: string; adminUserId: string }): Promise; + replaceBillingAddress(input: { + editorialId: string; + input: BillingAddressInput; + }): Promise; + transitionStatus(input: { + editorialId: string; + from: AccountStatus; + to: AccountStatus; + adminUserId: string; + }): Promise; +}; + +export class EditorialServiceError extends Error { + readonly name = "EditorialServiceError"; + + constructor( + readonly code: + | "INVALID_PRICE" + | "INVALID_ADDRESS" + | "EDITORIAL_NOT_FOUND" + | "EMAIL_NOT_VERIFIED" + | "ALBUM_GRANT_REQUIRED" + | "APPROVAL_NOTICE_DELIVERY_UNKNOWN" + | "INVALID_ACCOUNT_TRANSITION", + ) { + super(code); + } +} + +export function createEditorialService({ + repository, + mailer: mailerService, +}: { + repository: EditorialServiceRepository; + mailer: Pick; +}) { + return { + async approveEditorial(input: { + editorialId: string; + priceCents: number; + adminUserId: string; + }): Promise { + if (!Number.isSafeInteger(input.priceCents) || input.priceCents <= 0) { + throw new EditorialServiceError("INVALID_PRICE"); + } + + const notice = await repository.prepareApproval(input); + if (!notice) { + return; + } + + try { + await mailerService.sendApprovalNotice(notice); + } catch (error) { + try { + await repository.recordApprovalNoticeFailure({ + editorialId: input.editorialId, + adminUserId: input.adminUserId, + }); + } catch { + // Preserve the SMTP failure for the caller; approval is already committed. + } + throw error; + } + + await repository.recordApprovalNoticeSent({ + editorialId: input.editorialId, + adminUserId: input.adminUserId, + }); + }, + + async replaceBillingAddress(editorialId: string, input: BillingAddressInput): Promise { + return repository.replaceBillingAddress({ editorialId, input: validateBillingAddress(input) }); + }, + + async transitionEditorialStatus(input: { + editorialId: string; + from: AccountStatus; + to: AccountStatus; + adminUserId: string; + }): Promise { + if (!isAllowedTransition(input.from, input.to)) { + throw new EditorialServiceError("INVALID_ACCOUNT_TRANSITION"); + } + await repository.transitionStatus(input); + }, + }; +} + +export function createEditorialServiceRepository( + database: NodePgDatabase, +): EditorialServiceRepository { + return { + async prepareApproval({ editorialId, priceCents, adminUserId }) { + return database.transaction(async (transaction) => { + const [editorial] = await transaction + .select({ + id: editorialAccounts.id, + status: editorialAccounts.status, + emailVerifiedAt: editorialAccounts.emailVerifiedAt, + loginEmail: editorialAccounts.loginEmail, + name: editorialAccounts.name, + }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, editorialId)) + .limit(1); + + if (!editorial) { + throw new EditorialServiceError("EDITORIAL_NOT_FOUND"); + } + + const notice = { + editorialId: editorial.id, + to: editorial.loginEmail, + editorialName: editorial.name, + }; + + if (editorial.status === "active") { + const [delivery] = await transaction + .select({ eventType: auditEvents.eventType }) + .from(auditEvents) + .where( + and( + eq(auditEvents.entityType, "editorial_account"), + eq(auditEvents.entityId, editorial.id), + inArray(auditEvents.eventType, [ + "editorial_approval_notice_dispatch_started", + "editorial_approval_notice_sent", + "editorial_approval_notice_failed", + ]), + ), + ) + .orderBy(desc(auditEvents.occurredAt)) + .limit(1); + if (delivery?.eventType === "editorial_approval_notice_sent") { + return null; + } + if (delivery?.eventType === "editorial_approval_notice_dispatch_started") { + throw new EditorialServiceError("APPROVAL_NOTICE_DELIVERY_UNKNOWN"); + } + await transaction.insert(auditEvents).values({ + eventType: "editorial_approval_notice_dispatch_started", + actorUserId: adminUserId, + actorType: "admin", + entityType: "editorial_account", + entityId: editorial.id, + newValues: { delivery: "dispatching" }, + }); + return notice; + } + + if (editorial.status !== "pending_approval") { + throw new EditorialServiceError("INVALID_ACCOUNT_TRANSITION"); + } + if (!editorial.emailVerifiedAt) { + throw new EditorialServiceError("EMAIL_NOT_VERIFIED"); + } + + const [grant] = await transaction + .select({ id: albumGrants.id }) + .from(albumGrants) + .where( + and( + eq(albumGrants.editorialAccountId, editorial.id), + isNull(albumGrants.revokedAt), + ), + ) + .limit(1); + if (!grant) { + throw new EditorialServiceError("ALBUM_GRANT_REQUIRED"); + } + + const approvedAt = new Date(); + const [approved] = await transaction + .update(editorialAccounts) + .set({ status: "active", currentPriceCents: priceCents, updatedAt: approvedAt }) + .where( + and( + eq(editorialAccounts.id, editorial.id), + eq(editorialAccounts.status, "pending_approval"), + ), + ) + .returning({ id: editorialAccounts.id }); + if (!approved) { + throw new EditorialServiceError("INVALID_ACCOUNT_TRANSITION"); + } + + await transaction.insert(auditEvents).values({ + eventType: "editorial_approved", + actorUserId: adminUserId, + actorType: "admin", + entityType: "editorial_account", + entityId: editorial.id, + previousValues: { status: "pending_approval" }, + newValues: { status: "active", priceCents }, + occurredAt: approvedAt, + }); + await transaction.insert(auditEvents).values({ + eventType: "editorial_approval_notice_dispatch_started", + actorUserId: adminUserId, + actorType: "admin", + entityType: "editorial_account", + entityId: editorial.id, + newValues: { delivery: "dispatching" }, + occurredAt: approvedAt, + }); + return notice; + }); + }, + + async recordApprovalNoticeSent({ editorialId, adminUserId }) { + await database.insert(auditEvents).values({ + eventType: "editorial_approval_notice_sent", + actorUserId: adminUserId, + actorType: "admin", + entityType: "editorial_account", + entityId: editorialId, + newValues: { delivery: "sent" }, + }); + }, + + async recordApprovalNoticeFailure({ editorialId, adminUserId }) { + await database.insert(auditEvents).values({ + eventType: "editorial_approval_notice_failed", + actorUserId: adminUserId, + actorType: "admin", + entityType: "editorial_account", + entityId: editorialId, + newValues: { delivery: "failed" }, + }); + }, + + async replaceBillingAddress({ editorialId, input }) { + return database.transaction(async (transaction) => { + const [editorial] = await transaction + .select({ id: editorialAccounts.id }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, editorialId)) + .limit(1); + if (!editorial) { + throw new EditorialServiceError("EDITORIAL_NOT_FOUND"); + } + + const changedAt = new Date(); + const [address] = await transaction + .insert(billingAddressVersions) + .values({ + editorialAccountId: editorial.id, + ...input, + validFrom: changedAt, + }) + .returning({ id: billingAddressVersions.id }); + + await transaction + .update(editorialAccounts) + .set({ currentBillingAddressVersionId: address.id, updatedAt: changedAt }) + .where(eq(editorialAccounts.id, editorial.id)); + return address.id; + }); + }, + + async transitionStatus({ editorialId, from, to, adminUserId }) { + await database.transaction(async (transaction) => { + const changedAt = new Date(); + const [changed] = await transaction + .update(editorialAccounts) + .set({ status: to, updatedAt: changedAt }) + .where( + and(eq(editorialAccounts.id, editorialId), eq(editorialAccounts.status, from)), + ) + .returning({ id: editorialAccounts.id }); + if (!changed) { + throw new EditorialServiceError("INVALID_ACCOUNT_TRANSITION"); + } + + await transaction.insert(auditEvents).values({ + eventType: "editorial_status_changed", + actorUserId: adminUserId, + actorType: "admin", + entityType: "editorial_account", + entityId: editorialId, + previousValues: { status: from }, + newValues: { status: to }, + occurredAt: changedAt, + }); + }); + }, + }; +} + +function validateBillingAddress(input: BillingAddressInput): BillingAddressInput { + const companyName = trim(input.companyName); + const contactName = trim(input.contactName); + const addressLine1 = trim(input.addressLine1); + const addressLine2 = trim(input.addressLine2) || undefined; + const postalCode = trim(input.postalCode); + const city = trim(input.city); + const countryCode = trim(input.countryCode).toUpperCase(); + if ( + !companyName || + !contactName || + !addressLine1 || + !postalCode || + !city || + !/^[A-Z]{2}$/.test(countryCode) + ) { + throw new EditorialServiceError("INVALID_ADDRESS"); + } + return { + companyName, + contactName, + addressLine1, + ...(addressLine2 ? { addressLine2 } : {}), + postalCode, + city, + countryCode, + }; +} + +function trim(value: unknown): string { + return typeof value === "string" ? value.trim() : ""; +} + +function isAllowedTransition(from: AccountStatus, to: AccountStatus): boolean { + return ( + (from === "pending_approval" && (to === "active" || to === "rejected")) || + (from === "active" && to === "suspended") || + (from === "suspended" && to === "active") || + (from === "pending_email" && to === "rejected") + ); +} + +export const editorialService = createEditorialService({ + repository: createEditorialServiceRepository(db), + mailer, +}); diff --git a/src/modules/mail/mailer.ts b/src/modules/mail/mailer.ts index 0c79d78..8d34b9f 100644 --- a/src/modules/mail/mailer.ts +++ b/src/modules/mail/mailer.ts @@ -18,7 +18,11 @@ export type MailTransport = { export type Mailer = { sendVerification(input: { to: string; verificationUrl: string }): Promise; sendPasswordReset(input: { to: string; resetUrl: string }): Promise; - sendApprovalNotice(input: { to: string; editorialName: string }): Promise; + sendApprovalNotice(input: { + to: string; + editorialName: string; + editorialId?: string; + }): Promise; }; export function createMailer({ from, transport }: { from: string; transport: MailTransport }): Mailer { From 3f84b840d9ace91b42fee48829d97251123eb455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 21:23:32 +0200 Subject: [PATCH 06/29] fix: serialize editorial approval delivery --- drizzle/0001_editorial_approval_notice.sql | 1 + drizzle/meta/_journal.json | 9 +- src/db/schema/editorials.ts | 1 + src/modules/editorials/service.test.ts | 60 +++++++ src/modules/editorials/service.ts | 190 +++++++++++++++------ tests/db/postgres.ts | 11 +- 6 files changed, 215 insertions(+), 57 deletions(-) create mode 100644 drizzle/0001_editorial_approval_notice.sql diff --git a/drizzle/0001_editorial_approval_notice.sql b/drizzle/0001_editorial_approval_notice.sql new file mode 100644 index 0000000..5f3ca31 --- /dev/null +++ b/drizzle/0001_editorial_approval_notice.sql @@ -0,0 +1 @@ +ALTER TABLE "editorial_accounts" ADD COLUMN "approval_notice_status" text DEFAULT 'not_requested' NOT NULL; diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 1819924..9578f4a 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1786299825190, "tag": "0000_initial", "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1786351200000, + "tag": "0001_editorial_approval_notice", + "breakpoints": true } ] -} \ No newline at end of file +} diff --git a/src/db/schema/editorials.ts b/src/db/schema/editorials.ts index 3f58e82..d23ce71 100644 --- a/src/db/schema/editorials.ts +++ b/src/db/schema/editorials.ts @@ -23,6 +23,7 @@ export const editorialAccounts = pgTable("editorial_accounts", { loginEmail: text("login_email").notNull().unique(), status: accountStatus("status").notNull().default("pending_email"), currentPriceCents: integer("current_price_cents"), + approvalNoticeStatus: text("approval_notice_status").notNull().default("not_requested"), currentBillingAddressVersionId: uuid("current_billing_address_version_id").references( (): AnyPgColumn => billingAddressVersions.id, { onDelete: "restrict" }, diff --git a/src/modules/editorials/service.test.ts b/src/modules/editorials/service.test.ts index 3f61cc5..23a9081 100644 --- a/src/modules/editorials/service.test.ts +++ b/src/modules/editorials/service.test.ts @@ -2,6 +2,7 @@ import { expect, test, vi } from "vitest"; import { createEditorialService, + EDITORIAL_MUTATION_LOCK_ORDER, type EditorialServiceRepository, } from "./service"; @@ -11,6 +12,7 @@ function createRepository(): EditorialServiceRepository & { recordApprovalNoticeFailure: ReturnType; replaceBillingAddress: ReturnType; transitionStatus: ReturnType; + claimApprovalNotice: ReturnType; } { return { prepareApproval: vi.fn().mockResolvedValue({ @@ -22,6 +24,7 @@ function createRepository(): EditorialServiceRepository & { recordApprovalNoticeFailure: vi.fn().mockResolvedValue(undefined), replaceBillingAddress: vi.fn().mockResolvedValue("address-2"), transitionStatus: vi.fn().mockResolvedValue(undefined), + claimApprovalNotice: vi.fn().mockResolvedValue(true), }; } @@ -111,3 +114,60 @@ test("creates a new billing-address version instead of changing an existing addr }, }); }); + +test("rejects generic pending-approval activation so approval preconditions cannot be bypassed", async () => { + const repository = createRepository(); + const service = createEditorialService({ repository, mailer: { sendApprovalNotice: vi.fn() } }); + + await expect( + service.transitionEditorialStatus({ + editorialId: "e1", + from: "pending_approval", + to: "active", + adminUserId: "a1", + }), + ).rejects.toMatchObject({ code: "INVALID_ACCOUNT_TRANSITION" }); + expect(repository.transitionStatus).not.toHaveBeenCalled(); +}); + +test("does not resend an approval notice after a successful idempotent retry", async () => { + const repository = createRepository(); + repository.claimApprovalNotice.mockResolvedValueOnce(true).mockResolvedValueOnce(false); + const mailer = { sendApprovalNotice: vi.fn().mockResolvedValue(undefined) }; + const service = createEditorialService({ repository, mailer }); + + await service.approveEditorial({ editorialId: "e1", priceCents: 1500, adminUserId: "a1" }); + await service.approveEditorial({ editorialId: "e1", priceCents: 1500, adminUserId: "a1" }); + + expect(mailer.sendApprovalNotice).toHaveBeenCalledTimes(1); + expect(repository.claimApprovalNotice).toHaveBeenCalledTimes(2); +}); + +test("allows at most one concurrent failed-notice retry to claim SMTP dispatch", async () => { + const repository = createRepository(); + let claimed = false; + repository.claimApprovalNotice.mockImplementation(async () => { + if (claimed) { + return false; + } + claimed = true; + return true; + }); + const mailer = { sendApprovalNotice: vi.fn().mockResolvedValue(undefined) }; + const service = createEditorialService({ repository, mailer }); + + await Promise.all([ + service.approveEditorial({ editorialId: "e1", priceCents: 1500, adminUserId: "a1" }), + service.approveEditorial({ editorialId: "e1", priceCents: 1500, adminUserId: "a1" }), + ]); + + expect(mailer.sendApprovalNotice).toHaveBeenCalledTimes(1); +}); + +test("documents the shared editorial lock order for grant revocation", () => { + expect(EDITORIAL_MUTATION_LOCK_ORDER).toEqual([ + "pg_advisory_xact_lock(editorial account)", + "editorial_accounts FOR UPDATE", + "album_grants FOR UPDATE", + ]); +}); diff --git a/src/modules/editorials/service.ts b/src/modules/editorials/service.ts index a687c65..09ab2e7 100644 --- a/src/modules/editorials/service.ts +++ b/src/modules/editorials/service.ts @@ -1,6 +1,6 @@ import "server-only"; -import { and, desc, eq, inArray, isNull } from "drizzle-orm"; +import { and, eq, inArray, isNull, sql } from "drizzle-orm"; import type { NodePgDatabase } from "drizzle-orm/node-postgres"; import { db } from "@/db/client"; @@ -36,6 +36,7 @@ export type EditorialServiceRepository = { priceCents: number; adminUserId: string; }): Promise; + claimApprovalNotice(input: { editorialId: string; adminUserId: string }): Promise; recordApprovalNoticeSent(input: { editorialId: string; adminUserId: string }): Promise; recordApprovalNoticeFailure(input: { editorialId: string; adminUserId: string }): Promise; replaceBillingAddress(input: { @@ -50,6 +51,16 @@ export type EditorialServiceRepository = { }): Promise; }; +/** + * All editorial/grant mutations must take these locks in this exact order. + * Task 6 grant and revocation transactions must use the same order. + */ +export const EDITORIAL_MUTATION_LOCK_ORDER = [ + "pg_advisory_xact_lock(editorial account)", + "editorial_accounts FOR UPDATE", + "album_grants FOR UPDATE", +] as const; + export class EditorialServiceError extends Error { readonly name = "EditorialServiceError"; @@ -85,7 +96,7 @@ export function createEditorialService({ } const notice = await repository.prepareApproval(input); - if (!notice) { + if (!notice || !(await repository.claimApprovalNotice(input))) { return; } @@ -133,6 +144,7 @@ export function createEditorialServiceRepository( return { async prepareApproval({ editorialId, priceCents, adminUserId }) { return database.transaction(async (transaction) => { + await lockEditorialForMutation(transaction, editorialId); const [editorial] = await transaction .select({ id: editorialAccounts.id, @@ -143,6 +155,7 @@ export function createEditorialServiceRepository( }) .from(editorialAccounts) .where(eq(editorialAccounts.id, editorialId)) + .for("update") .limit(1); if (!editorial) { @@ -156,36 +169,6 @@ export function createEditorialServiceRepository( }; if (editorial.status === "active") { - const [delivery] = await transaction - .select({ eventType: auditEvents.eventType }) - .from(auditEvents) - .where( - and( - eq(auditEvents.entityType, "editorial_account"), - eq(auditEvents.entityId, editorial.id), - inArray(auditEvents.eventType, [ - "editorial_approval_notice_dispatch_started", - "editorial_approval_notice_sent", - "editorial_approval_notice_failed", - ]), - ), - ) - .orderBy(desc(auditEvents.occurredAt)) - .limit(1); - if (delivery?.eventType === "editorial_approval_notice_sent") { - return null; - } - if (delivery?.eventType === "editorial_approval_notice_dispatch_started") { - throw new EditorialServiceError("APPROVAL_NOTICE_DELIVERY_UNKNOWN"); - } - await transaction.insert(auditEvents).values({ - eventType: "editorial_approval_notice_dispatch_started", - actorUserId: adminUserId, - actorType: "admin", - entityType: "editorial_account", - entityId: editorial.id, - newValues: { delivery: "dispatching" }, - }); return notice; } @@ -205,6 +188,7 @@ export function createEditorialServiceRepository( isNull(albumGrants.revokedAt), ), ) + .for("update") .limit(1); if (!grant) { throw new EditorialServiceError("ALBUM_GRANT_REQUIRED"); @@ -213,7 +197,12 @@ export function createEditorialServiceRepository( const approvedAt = new Date(); const [approved] = await transaction .update(editorialAccounts) - .set({ status: "active", currentPriceCents: priceCents, updatedAt: approvedAt }) + .set({ + status: "active", + currentPriceCents: priceCents, + approvalNoticeStatus: "not_requested", + updatedAt: approvedAt, + }) .where( and( eq(editorialAccounts.id, editorial.id), @@ -235,6 +224,51 @@ export function createEditorialServiceRepository( newValues: { status: "active", priceCents }, occurredAt: approvedAt, }); + return notice; + }); + }, + + async claimApprovalNotice({ editorialId, adminUserId }) { + return database.transaction(async (transaction) => { + await lockEditorialForMutation(transaction, editorialId); + const [editorial] = await transaction + .select({ + id: editorialAccounts.id, + status: editorialAccounts.status, + approvalNoticeStatus: editorialAccounts.approvalNoticeStatus, + }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, editorialId)) + .for("update") + .limit(1); + if (!editorial) { + throw new EditorialServiceError("EDITORIAL_NOT_FOUND"); + } + if (editorial.status !== "active") { + throw new EditorialServiceError("INVALID_ACCOUNT_TRANSITION"); + } + if (editorial.approvalNoticeStatus === "sent") { + return false; + } + if (editorial.approvalNoticeStatus === "dispatching") { + throw new EditorialServiceError("APPROVAL_NOTICE_DELIVERY_UNKNOWN"); + } + + const [claimed] = await transaction + .update(editorialAccounts) + .set({ approvalNoticeStatus: "dispatching", updatedAt: new Date() }) + .where( + and( + eq(editorialAccounts.id, editorial.id), + eq(editorialAccounts.status, "active"), + inArray(editorialAccounts.approvalNoticeStatus, ["not_requested", "failed"]), + ), + ) + .returning({ id: editorialAccounts.id }); + if (!claimed) { + throw new EditorialServiceError("APPROVAL_NOTICE_DELIVERY_UNKNOWN"); + } + await transaction.insert(auditEvents).values({ eventType: "editorial_approval_notice_dispatch_started", actorUserId: adminUserId, @@ -242,40 +276,73 @@ export function createEditorialServiceRepository( entityType: "editorial_account", entityId: editorial.id, newValues: { delivery: "dispatching" }, - occurredAt: approvedAt, }); - return notice; + return true; }); }, async recordApprovalNoticeSent({ editorialId, adminUserId }) { - await database.insert(auditEvents).values({ - eventType: "editorial_approval_notice_sent", - actorUserId: adminUserId, - actorType: "admin", - entityType: "editorial_account", - entityId: editorialId, - newValues: { delivery: "sent" }, + await database.transaction(async (transaction) => { + await lockEditorialForMutation(transaction, editorialId); + const [updated] = await transaction + .update(editorialAccounts) + .set({ approvalNoticeStatus: "sent", updatedAt: new Date() }) + .where( + and( + eq(editorialAccounts.id, editorialId), + eq(editorialAccounts.approvalNoticeStatus, "dispatching"), + ), + ) + .returning({ id: editorialAccounts.id }); + if (!updated) { + throw new EditorialServiceError("APPROVAL_NOTICE_DELIVERY_UNKNOWN"); + } + await transaction.insert(auditEvents).values({ + eventType: "editorial_approval_notice_sent", + actorUserId: adminUserId, + actorType: "admin", + entityType: "editorial_account", + entityId: editorialId, + newValues: { delivery: "sent" }, + }); }); }, async recordApprovalNoticeFailure({ editorialId, adminUserId }) { - await database.insert(auditEvents).values({ - eventType: "editorial_approval_notice_failed", - actorUserId: adminUserId, - actorType: "admin", - entityType: "editorial_account", - entityId: editorialId, - newValues: { delivery: "failed" }, + await database.transaction(async (transaction) => { + await lockEditorialForMutation(transaction, editorialId); + const [updated] = await transaction + .update(editorialAccounts) + .set({ approvalNoticeStatus: "failed", updatedAt: new Date() }) + .where( + and( + eq(editorialAccounts.id, editorialId), + eq(editorialAccounts.approvalNoticeStatus, "dispatching"), + ), + ) + .returning({ id: editorialAccounts.id }); + if (!updated) { + throw new EditorialServiceError("APPROVAL_NOTICE_DELIVERY_UNKNOWN"); + } + await transaction.insert(auditEvents).values({ + eventType: "editorial_approval_notice_failed", + actorUserId: adminUserId, + actorType: "admin", + entityType: "editorial_account", + entityId: editorialId, + newValues: { delivery: "failed" }, + }); }); }, async replaceBillingAddress({ editorialId, input }) { return database.transaction(async (transaction) => { + await lockEditorialForMutation(transaction, editorialId); const [editorial] = await transaction .select({ id: editorialAccounts.id }) .from(editorialAccounts) .where(eq(editorialAccounts.id, editorialId)) + .for("update") .limit(1); if (!editorial) { throw new EditorialServiceError("EDITORIAL_NOT_FOUND"); @@ -301,13 +368,21 @@ export function createEditorialServiceRepository( async transitionStatus({ editorialId, from, to, adminUserId }) { await database.transaction(async (transaction) => { + await lockEditorialForMutation(transaction, editorialId); + const [editorial] = await transaction + .select({ id: editorialAccounts.id, status: editorialAccounts.status }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, editorialId)) + .for("update") + .limit(1); + if (!editorial || editorial.status !== from) { + throw new EditorialServiceError("INVALID_ACCOUNT_TRANSITION"); + } const changedAt = new Date(); const [changed] = await transaction .update(editorialAccounts) .set({ status: to, updatedAt: changedAt }) - .where( - and(eq(editorialAccounts.id, editorialId), eq(editorialAccounts.status, from)), - ) + .where(eq(editorialAccounts.id, editorialId)) .returning({ id: editorialAccounts.id }); if (!changed) { throw new EditorialServiceError("INVALID_ACCOUNT_TRANSITION"); @@ -363,13 +438,22 @@ function trim(value: unknown): string { function isAllowedTransition(from: AccountStatus, to: AccountStatus): boolean { return ( - (from === "pending_approval" && (to === "active" || to === "rejected")) || + (from === "pending_approval" && to === "rejected") || (from === "active" && to === "suspended") || (from === "suspended" && to === "active") || (from === "pending_email" && to === "rejected") ); } +async function lockEditorialForMutation( + transaction: NodePgDatabase, + editorialId: string, +): Promise { + await transaction.execute( + sql`select pg_advisory_xact_lock(hashtextextended(${editorialId}, 0))`, + ); +} + export const editorialService = createEditorialService({ repository: createEditorialServiceRepository(db), mailer, diff --git a/tests/db/postgres.ts b/tests/db/postgres.ts index ff9364a..3527c75 100644 --- a/tests/db/postgres.ts +++ b/tests/db/postgres.ts @@ -1,5 +1,5 @@ import { randomUUID } from "node:crypto"; -import { readFile } from "node:fs/promises"; +import { readdir, readFile } from "node:fs/promises"; import path from "node:path"; import { PostgreSqlContainer, type StartedPostgreSqlContainer } from "@testcontainers/postgresql"; @@ -53,8 +53,13 @@ export async function startPostgres(): Promise { } async function applyMigration(pool: Pool) { - const migration = await readFile(path.join(process.cwd(), "drizzle/0000_initial.sql"), "utf8"); - await pool.query(migration); + const migrationDirectory = path.join(process.cwd(), "drizzle"); + const migrationFiles = (await readdir(migrationDirectory)) + .filter((file) => /^\d+_.*\.sql$/.test(file)) + .sort(); + for (const file of migrationFiles) { + await pool.query(await readFile(path.join(migrationDirectory, file), "utf8")); + } } async function seedEditorialWithUsage(db: NodePgDatabase): Promise { From b84562ad52196f68c55c0bc1d85ecdc2bb04049d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 21:27:50 +0200 Subject: [PATCH 07/29] fix: add approval migration snapshot --- drizzle/0001_editorial_approval_notice.sql | 2 +- drizzle/meta/0001_snapshot.json | 1450 ++++++++++++++++++++ drizzle/meta/_journal.json | 4 +- 3 files changed, 1453 insertions(+), 3 deletions(-) create mode 100644 drizzle/meta/0001_snapshot.json diff --git a/drizzle/0001_editorial_approval_notice.sql b/drizzle/0001_editorial_approval_notice.sql index 5f3ca31..205d82f 100644 --- a/drizzle/0001_editorial_approval_notice.sql +++ b/drizzle/0001_editorial_approval_notice.sql @@ -1 +1 @@ -ALTER TABLE "editorial_accounts" ADD COLUMN "approval_notice_status" text DEFAULT 'not_requested' NOT NULL; +ALTER TABLE "editorial_accounts" ADD COLUMN "approval_notice_status" text DEFAULT 'not_requested' NOT NULL; \ No newline at end of file diff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.json new file mode 100644 index 0000000..c897032 --- /dev/null +++ b/drizzle/meta/0001_snapshot.json @@ -0,0 +1,1450 @@ +{ + "id": "cfd5f4d1-55ac-46d9-9667-cd156f26e070", + "prevId": "64eb37ed-2ab5-4c12-a8be-4375e8f6a732", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.album_grants": { + "name": "album_grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "granted_by_user_id": { + "name": "granted_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "album_grants_editorial_account_id_idx": { + "name": "album_grants_editorial_account_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_immich_album_id_idx": { + "name": "album_grants_immich_album_id_idx", + "columns": [ + { + "expression": "immich_album_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "album_grants_editorial_account_id_editorial_accounts_id_fk": { + "name": "album_grants_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "album_grants", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "album_grants_granted_by_user_id_user_id_fk": { + "name": "album_grants_granted_by_user_id_user_id_fk", + "tableFrom": "album_grants", + "tableTo": "user", + "columnsFrom": [ + "granted_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_events": { + "name": "audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "previous_values": { + "name": "previous_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_values": { + "name": "new_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "audit_events_actor_user_id_user_id_fk": { + "name": "audit_events_actor_user_id_user_id_fk", + "tableFrom": "audit_events", + "tableTo": "user", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "portal_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'EDITORIAL'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_report_items": { + "name": "billing_report_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id_snapshot": { + "name": "immich_asset_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose_snapshot": { + "name": "purpose_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference_snapshot": { + "name": "internal_reference_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "billing_report_items_report_usage_unique": { + "name": "billing_report_items_report_usage_unique", + "columns": [ + { + "expression": "billing_report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "usage_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_report_items_billing_report_id_billing_reports_id_fk": { + "name": "billing_report_items_billing_report_id_billing_reports_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_report_items_usage_id_usages_id_fk": { + "name": "billing_report_items_usage_id_usages_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_reports": { + "name": "billing_reports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "report_number": { + "name": "report_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "period_starts_at": { + "name": "period_starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "period_ends_at": { + "name": "period_ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "billing_address_snapshot": { + "name": "billing_address_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "net_total_cents": { + "name": "net_total_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "report_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "pdf": { + "name": "pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "pdf_sha256": { + "name": "pdf_sha256", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finalized_at": { + "name": "finalized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_by_user_id": { + "name": "cancelled_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "billing_reports_report_number_unique": { + "name": "billing_reports_report_number_unique", + "columns": [ + { + "expression": "report_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "billing_reports_invoice_number_unique": { + "name": "billing_reports_invoice_number_unique", + "columns": [ + { + "expression": "invoice_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_reports_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_reports_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_reports", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_created_by_user_id_user_id_fk": { + "name": "billing_reports_created_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_cancelled_by_user_id_user_id_fk": { + "name": "billing_reports_cancelled_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "cancelled_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "billing_reports_pdf_sha256_hex_check": { + "name": "billing_reports_pdf_sha256_hex_check", + "value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'" + }, + "billing_reports_final_pdf_check": { + "name": "billing_reports_final_pdf_check", + "value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.billing_address_versions": { + "name": "billing_address_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_1": { + "name": "address_line_1", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_2": { + "name": "address_line_2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "superseded_by_id": { + "name": "superseded_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "billing_address_versions_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_address_versions_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_superseded_by_id_billing_address_versions_id_fk": { + "name": "billing_address_versions_superseded_by_id_billing_address_versions_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "superseded_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_created_by_user_id_user_id_fk": { + "name": "billing_address_versions_created_by_user_id_user_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.editorial_accounts": { + "name": "editorial_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "login_email": { + "name": "login_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "account_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending_email'" + }, + "current_price_cents": { + "name": "current_price_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "approval_notice_status": { + "name": "approval_notice_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_requested'" + }, + "current_billing_address_version_id": { + "name": "current_billing_address_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_version": { + "name": "accepted_terms_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_at": { + "name": "accepted_terms_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "privacy_acknowledged_at": { + "name": "privacy_acknowledged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "editorial_accounts_user_id_user_id_fk": { + "name": "editorial_accounts_user_id_user_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk": { + "name": "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "current_billing_address_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "editorial_accounts_user_id_unique": { + "name": "editorial_accounts_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + }, + "editorial_accounts_login_email_unique": { + "name": "editorial_accounts_login_email_unique", + "nullsNotDistinct": false, + "columns": [ + "login_email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.download_events": { + "name": "download_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authorized_at": { + "name": "authorized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "download_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'authorized'" + }, + "transferred_bytes": { + "name": "transferred_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "repeat_download_note": { + "name": "repeat_download_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "download_events_editorial_idempotency_key_unique": { + "name": "download_events_editorial_idempotency_key_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "download_events_editorial_account_id_editorial_accounts_id_fk": { + "name": "download_events_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "download_events", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "download_events_usage_id_usages_id_fk": { + "name": "download_events_usage_id_usages_id_fk", + "tableFrom": "download_events", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.usages": { + "name": "usages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "immich_album_id_snapshot": { + "name": "immich_album_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference": { + "name": "internal_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "billing_status": { + "name": "billing_status", + "type": "usage_billing_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "usages_editorial_account_id_editorial_accounts_id_fk": { + "name": "usages_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "usages", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "usages_billing_report_id_billing_reports_id_fk": { + "name": "usages_billing_report_id_billing_reports_id_fk", + "tableFrom": "usages", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.portal_role": { + "name": "portal_role", + "schema": "public", + "values": [ + "ADMIN", + "EDITORIAL" + ] + }, + "public.report_status": { + "name": "report_status", + "schema": "public", + "values": [ + "draft", + "final", + "cancelled" + ] + }, + "public.account_status": { + "name": "account_status", + "schema": "public", + "values": [ + "pending_email", + "pending_approval", + "active", + "suspended", + "rejected" + ] + }, + "public.download_status": { + "name": "download_status", + "schema": "public", + "values": [ + "authorized", + "streaming", + "completed", + "failed_before_delivery", + "interrupted" + ] + }, + "public.usage_billing_status": { + "name": "usage_billing_status", + "schema": "public", + "values": [ + "open", + "billed", + "reopened" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 9578f4a..3201171 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -12,9 +12,9 @@ { "idx": 1, "version": "7", - "when": 1786351200000, + "when": 1786303607054, "tag": "0001_editorial_approval_notice", "breakpoints": true } ] -} +} \ No newline at end of file From a5973bfaf19f83850928611b27acc74d284df0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 21:39:12 +0200 Subject: [PATCH 08/29] feat: add typed immich api adapter --- package.json | 1 + pnpm-lock.yaml | 264 +++++++++++++++++++++++++++++- src/modules/immich/client.test.ts | 146 +++++++++++++++++ src/modules/immich/client.ts | 220 +++++++++++++++++++++++++ src/modules/immich/errors.ts | 34 ++++ src/modules/immich/types.ts | 46 ++++++ tests/fixtures/immich.ts | 31 ++++ 7 files changed, 735 insertions(+), 7 deletions(-) create mode 100644 src/modules/immich/client.test.ts create mode 100644 src/modules/immich/client.ts create mode 100644 src/modules/immich/errors.ts create mode 100644 src/modules/immich/types.ts create mode 100644 tests/fixtures/immich.ts diff --git a/package.json b/package.json index 866ee79..ae790a3 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "eslint": "^9.39.5", "eslint-config-next": "^16.3.0", "jsdom": "^30.0.1", + "msw": "^2.15.0", "tailwindcss": "^4.3.3", "testcontainers": "^12.1.0", "typescript": "^5.9.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e7374c..5603f6b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ importers: version: 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0)) better-auth: specifier: ^1.6.26 - version: 1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))) + version: 1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))) drizzle-orm: specifier: ^0.45.2 version: 0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0) @@ -81,6 +81,9 @@ importers: jsdom: specifier: ^30.0.1 version: 30.0.1(@noble/hashes@2.3.0) + msw: + specifier: ^2.15.0 + version: 2.15.0(@types/node@24.13.3)(typescript@5.9.3) tailwindcss: specifier: ^4.3.3 version: 4.3.3 @@ -92,7 +95,7 @@ importers: version: 5.9.3 vitest: specifier: ^4.1.10 - version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) + version: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) packages: @@ -1023,6 +1026,41 @@ packages: cpu: [x64] os: [win32] + '@inquirer/ansi@2.0.7': + resolution: {integrity: sha512-3eTuUO1vH2cZm2ZKHeQxnOqlTi9EfZDGgIe3BL3I4u+rJHocr9Fz86M4fjYABPvFnQG/gGK551HqDiIcETwU6Q==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'} + + '@inquirer/confirm@6.1.1': + resolution: {integrity: sha512-eb8DBZcz/2qHWQda4rk2JiQk5h9QV/cVHi1yjt0f69WFZMRFn0sJTye3EAP8icut8UDMjQPsaH5KbcOogefrFQ==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + + '@inquirer/core@11.2.1': + resolution: {integrity: sha512-Qd6GJT1yVyrZZCfN8W2qKF5ApmqryXRhRKCuip8h01x2w/esJQ2XIYc6f9abMIHgKQdBfFTSOdbHRLAhuM09UA==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + + '@inquirer/figures@2.0.7': + resolution: {integrity: sha512-aJ8TBPOGB6f/2qziPfElISTCEd5XOYTFckA2SGjhNmiKzfK/u4ot3v0DUzGVdUnKjN10EqnnEPck36BkyfLnJw==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'} + + '@inquirer/type@4.0.7': + resolution: {integrity: sha512-t28inv14nMQ1PhKpsJPY+kEs/c00qzeCOS2gTNRyTjG5d6qsVA2fItxW4hkvGZ5lvanGLdtCzVIx5dwdRpN1+g==} + engines: {node: '>=23.5.0 || ^22.13.0 || ^20.17.0'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@isaacs/cliui@8.0.2': resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -1049,6 +1087,10 @@ packages: '@kwsites/file-exists@1.1.1': resolution: {integrity: sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==} + '@mswjs/interceptors@0.41.9': + resolution: {integrity: sha512-VVPPgHyQ6ShqnrmDWuxjmUIsO9gWyOZFmuOfLd9LfBGQJwZfy0gvv9pbHSJuoFNIYC7ZDX9aoFwowjcdSC4E8w==} + engines: {node: '>=18'} + '@napi-rs/wasm-runtime@1.2.2': resolution: {integrity: sha512-JfB4kuJQjaoHuCTseIINHtHWeJnvgEcxjwA5t/Y00ZgaOO1Crz3fjT/p8kT28zA/Caz7oiUMn3d6H2yOVCVwuw==} engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} @@ -1138,6 +1180,18 @@ packages: resolution: {integrity: sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==} engines: {node: '>=12.4.0'} + '@open-draft/deferred-promise@2.2.0': + resolution: {integrity: sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==} + + '@open-draft/deferred-promise@3.0.0': + resolution: {integrity: sha512-XW375UK8/9SqUVNVa6M0yEy8+iTi4QN5VZ7aZuRFQmy76LRwI9wy5F4YIBU6T+eTe2/DNDo8tqu8RHlwLHM6RA==} + + '@open-draft/logger@0.3.0': + resolution: {integrity: sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==} + + '@open-draft/until@2.1.0': + resolution: {integrity: sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==} + '@opentelemetry/semantic-conventions@1.43.0': resolution: {integrity: sha512-eSYWTm620tTk45EKSedaUL8MFYI8hW164hIXsgIHyxu3VobUB3fFCu5t0hQby6OoWRPsG1KkKUG2M5UadiLiVg==} engines: {node: '>=14'} @@ -1445,6 +1499,9 @@ packages: '@types/react@19.2.18': resolution: {integrity: sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==} + '@types/set-cookie-parser@2.4.10': + resolution: {integrity: sha512-GGmQVGpQWUe5qglJozEjZV/5dyxbOOZ0LHe/lqyWssB88Y4svNfst0uqBVscdDeIKl5Jy5+aPSvy7mI9tYRguw==} + '@types/ssh2-streams@0.1.13': resolution: {integrity: sha512-faHyY3brO9oLEA0QlcO8N2wT7R0+1sHWZvQ+y3rMLwdY1ZyS1z0W3t65j9PqT4HmQ6ALzNe7RZlNuCNE0wBSWA==} @@ -1454,6 +1511,9 @@ packages: '@types/ssh2@1.15.5': resolution: {integrity: sha512-N1ASjp/nXH3ovBHddRJpli4ozpk6UdDYIX4RJWFa9L1YKnzdhTlVmiGHm4DZnj/jLbqZpes4aeR30EFGQtvhQQ==} + '@types/statuses@2.0.6': + resolution: {integrity: sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==} + '@typescript-eslint/eslint-plugin@8.66.0': resolution: {integrity: sha512-p088eaGrzYz1s+7cov0aMOCkNGTJlVxF4jgubf28c8L0Cv9Rloj8YBHnv4hXLq6IIEE1AsjNWavO+k+8kP2Y0A==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2003,6 +2063,10 @@ packages: chownr@1.1.4: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + cli-width@4.1.0: + resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==} + engines: {node: '>= 12'} + client-only@0.0.1: resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} @@ -2027,6 +2091,10 @@ packages: convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + cookie@1.1.1: + resolution: {integrity: sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==} + engines: {node: '>=18'} + core-util-is@1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} @@ -2479,6 +2547,15 @@ packages: fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + fast-string-truncated-width@3.0.3: + resolution: {integrity: sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==} + + fast-string-width@3.0.2: + resolution: {integrity: sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==} + + fast-wrap-ansi@0.2.2: + resolution: {integrity: sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==} + fastq@1.20.1: resolution: {integrity: sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==} @@ -2599,6 +2676,10 @@ packages: graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + graphql@16.14.2: + resolution: {integrity: sha512-Chq1s4CY7jmh8gO2qvLIJyfCDIN+EHLFW/9iShnp1z8FjBQMoodWP1kDC36VAMXXIvAjj4ARa7ntfAV2BrjsbA==} + engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} + has-bigints@1.1.0: resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} engines: {node: '>= 0.4'} @@ -2626,6 +2707,9 @@ packages: resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} engines: {node: '>= 0.4'} + headers-polyfill@5.0.1: + resolution: {integrity: sha512-1TJ6Fih/b8h5TIcv+1+Hw0PDQWJTKDKzFZzcKOiW1wJza3XoAQlkCuXLbymPYB8+ZQyw8mHvdw560e8zVFIWyA==} + hermes-estree@0.25.1: resolution: {integrity: sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==} @@ -2733,6 +2817,9 @@ packages: resolution: {integrity: sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==} engines: {node: '>= 0.4'} + is-node-process@1.2.0: + resolution: {integrity: sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==} + is-number-object@1.1.1: resolution: {integrity: sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==} engines: {node: '>= 0.4'} @@ -3109,6 +3196,20 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + msw@2.15.0: + resolution: {integrity: sha512-2wQAmKkQKxRuXvYJxVhPGG0wZNBQyD06oJvxqw90XqLvptdqxdlHrFUfEteKkpaNORX3Xzc+HtEl/q0nfmN2wQ==} + engines: {node: '>=18'} + hasBin: true + peerDependencies: + typescript: '>= 4.8.x' + peerDependenciesMeta: + typescript: + optional: true + + mute-stream@3.0.0: + resolution: {integrity: sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==} + engines: {node: ^20.17.0 || >=22.9.0} + nan@2.28.0: resolution: {integrity: sha512-fTsDz99OTq2sVePhGdp4qQhggZFtKr64ZNVyVajRKtMOkJxYekplBh577PiJB12v/D3s2E5cGtOI45LWp6rnLQ==} @@ -3209,6 +3310,9 @@ packages: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} + outvariant@1.4.3: + resolution: {integrity: sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==} + own-keys@1.0.2: resolution: {integrity: sha512-19YVAg7T+WTrxggPukVq7DjTv6+PJ867TmhCvBsYwmbFCsZd344rq2Ld1p0wo8f8Qrrhgp82c6FJRqdXWtSEhg==} engines: {node: '>= 0.4'} @@ -3246,6 +3350,9 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} + path-to-regexp@6.3.0: + resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} + pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} @@ -3426,6 +3533,9 @@ packages: resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} engines: {node: '>= 4'} + rettime@0.11.11: + resolution: {integrity: sha512-ILJRqVWBCTlg9r42fFgwVZx1gnFAcQF8mRoMkbgQfIrjEDf9nbBFDFx00oloOa+Q869FUtaYDXZvEfnecQSCoQ==} + reusify@1.1.0: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} @@ -3570,6 +3680,10 @@ packages: stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + statuses@2.0.2: + resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==} + engines: {node: '>= 0.8'} + std-env@4.2.0: resolution: {integrity: sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==} @@ -3580,6 +3694,9 @@ packages: streamx@2.28.0: resolution: {integrity: sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==} + strict-event-emitter@0.5.1: + resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==} + string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -3661,6 +3778,10 @@ packages: symbol-tree@3.2.4: resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==} + tagged-tag@1.0.0: + resolution: {integrity: sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==} + engines: {node: '>=20'} + tailwindcss@4.3.3: resolution: {integrity: sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==} @@ -3753,6 +3874,10 @@ packages: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} + type-fest@5.8.0: + resolution: {integrity: sha512-YGYEVz3Fm5iy/AybuA0oyNFq7H4CgQNfRp/qfe8nurE1kuCeNm3/vfm9X4Mtl+qLyaKJUh5xrFZwogr41SMjYA==} + engines: {node: '>=20'} + typed-array-buffer@1.0.3: resolution: {integrity: sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==} engines: {node: '>= 0.4'} @@ -3798,6 +3923,9 @@ packages: unrs-resolver@1.12.2: resolution: {integrity: sha512-dmlRxBJJayXjqTwC+JtF1HhJmgf3ftQ3YejFcZrf4+KKtJv0qDsK1pjqaaVjG7wJ5NJ6UVP1OqRMQ71Z4C3rxQ==} + until-async@3.0.2: + resolution: {integrity: sha512-IiSk4HlzAMqTUseHHe3VhIGyuFmN90zMTpD3Z3y8jeQbzLIq500MVM7Jq2vUAnTKAFPJrqwkzr6PoTcPhGcOiw==} + update-browserslist-db@1.3.0: resolution: {integrity: sha512-x/M6q3w4Ybp91CNaS4S69UnliqR3BzRpOT6LWbksjth0S/+jhfaPJsWjt/TewpT8j9eLIojUf5jr29WextHroA==} hasBin: true @@ -4665,6 +4793,33 @@ snapshots: '@img/sharp-win32-x64@0.35.3': optional: true + '@inquirer/ansi@2.0.7': {} + + '@inquirer/confirm@6.1.1(@types/node@24.13.3)': + dependencies: + '@inquirer/core': 11.2.1(@types/node@24.13.3) + '@inquirer/type': 4.0.7(@types/node@24.13.3) + optionalDependencies: + '@types/node': 24.13.3 + + '@inquirer/core@11.2.1(@types/node@24.13.3)': + dependencies: + '@inquirer/ansi': 2.0.7 + '@inquirer/figures': 2.0.7 + '@inquirer/type': 4.0.7(@types/node@24.13.3) + cli-width: 4.1.0 + fast-wrap-ansi: 0.2.2 + mute-stream: 3.0.0 + signal-exit: 4.1.0 + optionalDependencies: + '@types/node': 24.13.3 + + '@inquirer/figures@2.0.7': {} + + '@inquirer/type@4.0.7(@types/node@24.13.3)': + optionalDependencies: + '@types/node': 24.13.3 + '@isaacs/cliui@8.0.2': dependencies: string-width: 5.1.2 @@ -4701,6 +4856,15 @@ snapshots: transitivePeerDependencies: - supports-color + '@mswjs/interceptors@0.41.9': + dependencies: + '@open-draft/deferred-promise': 2.2.0 + '@open-draft/logger': 0.3.0 + '@open-draft/until': 2.1.0 + is-node-process: 1.2.0 + outvariant: 1.4.3 + strict-event-emitter: 0.5.1 + '@napi-rs/wasm-runtime@1.2.2(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)': dependencies: '@emnapi/core': 1.10.0 @@ -4759,6 +4923,17 @@ snapshots: '@nolyfill/is-core-module@1.0.39': {} + '@open-draft/deferred-promise@2.2.0': {} + + '@open-draft/deferred-promise@3.0.0': {} + + '@open-draft/logger@0.3.0': + dependencies: + is-node-process: 1.2.0 + outvariant: 1.4.3 + + '@open-draft/until@2.1.0': {} + '@opentelemetry/semantic-conventions@1.43.0': {} '@oxc-project/types@0.143.0': {} @@ -5004,6 +5179,10 @@ snapshots: dependencies: csstype: 3.2.3 + '@types/set-cookie-parser@2.4.10': + dependencies: + '@types/node': 24.13.3 + '@types/ssh2-streams@0.1.13': dependencies: '@types/node': 24.13.3 @@ -5017,6 +5196,8 @@ snapshots: dependencies: '@types/node': 18.19.130 + '@types/statuses@2.0.6': {} + '@typescript-eslint/eslint-plugin@8.66.0(@typescript-eslint/parser@8.66.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.2 @@ -5192,12 +5373,13 @@ snapshots: chai: 6.2.2 tinyrainbow: 3.1.1 - '@vitest/mocker@4.1.10(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))': + '@vitest/mocker@4.1.10(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))': dependencies: '@vitest/spy': 4.1.10 estree-walker: 3.0.3 magic-string: 0.30.21 optionalDependencies: + msw: 2.15.0(@types/node@24.13.3)(typescript@5.9.3) vite: 8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0) '@vitest/pretty-format@4.1.10': @@ -5417,7 +5599,7 @@ snapshots: dependencies: tweetnacl: 0.14.5 - better-auth@1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))): + better-auth@1.6.26(drizzle-kit@0.31.10)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0))(next@16.3.0(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@24.13.3)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(pg@8.22.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0))): dependencies: '@better-auth/core': 1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2) '@better-auth/drizzle-adapter': 1.6.26(@better-auth/core@1.6.26(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(better-call@1.3.7(zod@4.4.3))(jose@6.2.8)(kysely@0.29.4)(nanostores@1.4.2))(@better-auth/utils@0.4.2)(drizzle-orm@0.45.2(@types/pg@8.21.0)(kysely@0.29.4)(pg@8.22.0)) @@ -5443,7 +5625,7 @@ snapshots: pg: 8.22.0 react: 19.2.8 react-dom: 19.2.8(react@19.2.8) - vitest: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) + vitest: 4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) transitivePeerDependencies: - '@cloudflare/workers-types' - '@opentelemetry/api' @@ -5541,6 +5723,8 @@ snapshots: chownr@1.1.4: {} + cli-width@4.1.0: {} + client-only@0.0.1: {} cliui@8.0.1: @@ -5567,6 +5751,8 @@ snapshots: convert-source-map@2.0.0: {} + cookie@1.1.1: {} + core-util-is@1.0.3: {} cpu-features@0.0.10: @@ -6165,6 +6351,16 @@ snapshots: fast-levenshtein@2.0.6: {} + fast-string-truncated-width@3.0.3: {} + + fast-string-width@3.0.2: + dependencies: + fast-string-truncated-width: 3.0.3 + + fast-wrap-ansi@0.2.2: + dependencies: + fast-string-width: 3.0.2 + fastq@1.20.1: dependencies: reusify: 1.1.0 @@ -6289,6 +6485,8 @@ snapshots: graceful-fs@4.2.11: {} + graphql@16.14.2: {} + has-bigints@1.1.0: {} has-flag@4.0.0: {} @@ -6311,6 +6509,11 @@ snapshots: dependencies: function-bind: 1.1.2 + headers-polyfill@5.0.1: + dependencies: + '@types/set-cookie-parser': 2.4.10 + set-cookie-parser: 3.1.2 + hermes-estree@0.25.1: {} hermes-parser@0.25.1: @@ -6418,6 +6621,8 @@ snapshots: is-negative-zero@2.0.3: {} + is-node-process@1.2.0: {} + is-number-object@1.1.1: dependencies: call-bound: 1.0.4 @@ -6734,6 +6939,33 @@ snapshots: ms@2.1.3: {} + msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3): + dependencies: + '@inquirer/confirm': 6.1.1(@types/node@24.13.3) + '@mswjs/interceptors': 0.41.9 + '@open-draft/deferred-promise': 3.0.0 + '@types/statuses': 2.0.6 + cookie: 1.1.1 + graphql: 16.14.2 + headers-polyfill: 5.0.1 + is-node-process: 1.2.0 + outvariant: 1.4.3 + path-to-regexp: 6.3.0 + picocolors: 1.1.1 + rettime: 0.11.11 + statuses: 2.0.2 + strict-event-emitter: 0.5.1 + tough-cookie: 6.0.2 + type-fest: 5.8.0 + until-async: 3.0.2 + yargs: 17.7.3 + optionalDependencies: + typescript: 5.9.3 + transitivePeerDependencies: + - '@types/node' + + mute-stream@3.0.0: {} + nan@2.28.0: optional: true @@ -6840,6 +7072,8 @@ snapshots: type-check: 0.4.0 word-wrap: 1.2.5 + outvariant@1.4.3: {} + own-keys@1.0.2: dependencies: call-bound: 1.0.4 @@ -6876,6 +7110,8 @@ snapshots: lru-cache: 10.4.3 minipass: 7.1.3 + path-to-regexp@6.3.0: {} + pathe@2.0.3: {} pg-cloudflare@1.4.0: @@ -7080,6 +7316,8 @@ snapshots: retry@0.12.0: {} + rettime@0.11.11: {} + reusify@1.1.0: {} rolldown@1.2.3: @@ -7273,6 +7511,8 @@ snapshots: stackback@0.0.2: {} + statuses@2.0.2: {} + std-env@4.2.0: {} stop-iteration-iterator@1.1.0: @@ -7289,6 +7529,8 @@ snapshots: - bare-abort-controller - react-native-b4a + strict-event-emitter@0.5.1: {} + string-width@4.2.3: dependencies: emoji-regex: 8.0.0 @@ -7391,6 +7633,8 @@ snapshots: symbol-tree@3.2.4: {} + tagged-tag@1.0.0: {} + tailwindcss@4.3.3: {} tapable@2.3.3: {} @@ -7525,6 +7769,10 @@ snapshots: dependencies: prelude-ls: 1.2.1 + type-fest@5.8.0: + dependencies: + tagged-tag: 1.0.0 + typed-array-buffer@1.0.3: dependencies: call-bound: 1.0.4 @@ -7611,6 +7859,8 @@ snapshots: '@unrs/resolver-binding-win32-ia32-msvc': 1.12.2 '@unrs/resolver-binding-win32-x64-msvc': 1.12.2 + until-async@3.0.2: {} + update-browserslist-db@1.3.0(browserslist@4.28.7): dependencies: browserslist: 4.28.7 @@ -7638,10 +7888,10 @@ snapshots: tsx: 4.23.11 yaml: 2.9.0 - vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)): + vitest@4.1.10(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.3.0))(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)): dependencies: '@vitest/expect': 4.1.10 - '@vitest/mocker': 4.1.10(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) + '@vitest/mocker': 4.1.10(msw@2.15.0(@types/node@24.13.3)(typescript@5.9.3))(vite@8.2.1(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(tsx@4.23.11)(yaml@2.9.0)) '@vitest/pretty-format': 4.1.10 '@vitest/runner': 4.1.10 '@vitest/snapshot': 4.1.10 diff --git a/src/modules/immich/client.test.ts b/src/modules/immich/client.test.ts new file mode 100644 index 0000000..c21de7b --- /dev/null +++ b/src/modules/immich/client.test.ts @@ -0,0 +1,146 @@ +import { afterEach, beforeEach, expect, test } from "vitest"; +import { HttpResponse, http } from "msw"; +import { setupServer } from "msw/node"; + +import { createImmichClient } from "./client"; +import { + immichAlbum, + immichAlbumDetail, + immichMetadataSearchResponse, +} from "../../../tests/fixtures/immich"; + +const baseUrl = "http://immich.test"; +const apiKey = "test-api-key"; +const server = setupServer(); +const client = createImmichClient({ baseUrl, apiKey, timeoutMs: 1_000 }); + +beforeEach(() => server.listen({ onUnhandledRequest: "error" })); +afterEach(() => server.resetHandlers()); +afterEach(() => server.close()); + +test("lists albums through the documented API with server-side authentication", async () => { + server.use( + http.get(`${baseUrl}/api/albums`, ({ request }) => { + expect(request.headers.get("x-api-key")).toBe(apiKey); + expect(request.headers.get("authorization")).toBeNull(); + return HttpResponse.json([immichAlbum]); + }), + ); + + await expect(client.listAlbums()).resolves.toEqual([immichAlbum]); +}); + +test("gets album details from the documented album endpoint", async () => { + server.use( + http.get(`${baseUrl}/api/albums/album-1`, ({ request }) => { + expect(request.method).toBe("GET"); + expect(request.headers.get("x-api-key")).toBe(apiKey); + return HttpResponse.json(immichAlbumDetail); + }), + ); + + await expect(client.getAlbum("album-1")).resolves.toEqual(immichAlbumDetail); +}); + +test("forces IMAGE and authorized album IDs in metadata search", async () => { + server.use( + http.post(`${baseUrl}/api/search/metadata`, async ({ request }) => { + expect(request.method).toBe("POST"); + expect(request.headers.get("x-api-key")).toBe(apiKey); + expect(request.headers.get("content-type")).toBe("application/json"); + await expect(request.json()).resolves.toEqual({ + albumIds: ["album-1"], + description: "jubel", + type: "IMAGE", + page: 1, + size: 60, + }); + return HttpResponse.json(immichMetadataSearchResponse); + }), + ); + + await expect( + client.searchPhotos({ albumIds: ["album-1"], description: "jubel", page: 1, size: 60 }), + ).resolves.toEqual({ + items: immichMetadataSearchResponse.assets.items, + total: 1, + nextPage: null, + previousPage: null, + }); +}); + +test("maps an Immich outage to IMMICH_UNAVAILABLE", async () => { + server.use(http.get(`${baseUrl}/api/albums`, () => HttpResponse.error())); + + await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_UNAVAILABLE" }); +}); + +test("maps upstream authorization, missing, rate-limit, server, and malformed failures", async () => { + server.use(http.get(`${baseUrl}/api/albums`, () => new HttpResponse(null, { status: 401 }))); + await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_AUTH_FAILED" }); + + server.use(http.get(`${baseUrl}/api/albums`, () => new HttpResponse(null, { status: 403 }))); + await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_AUTH_FAILED" }); + + server.use(http.get(`${baseUrl}/api/albums/hidden`, () => new HttpResponse(null, { status: 404 }))); + await expect(client.getAlbum("hidden")).rejects.toMatchObject({ code: "IMMICH_NOT_FOUND" }); + + server.use(http.get(`${baseUrl}/api/albums`, () => new HttpResponse(null, { status: 429 }))); + await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_RATE_LIMITED" }); + + server.use(http.get(`${baseUrl}/api/albums`, () => new HttpResponse(null, { status: 503 }))); + await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_UNAVAILABLE" }); + + server.use(http.get(`${baseUrl}/api/albums`, () => HttpResponse.json([{ id: "malformed" }]))); + await expect(client.listAlbums()).rejects.toMatchObject({ code: "IMMICH_INVALID_RESPONSE" }); +}); + +test("maps an aborted timeout signal to IMMICH_TIMEOUT", async () => { + const timedOutClient = createImmichClient({ + baseUrl, + apiKey, + timeoutMs: 1, + fetch: (_input, init) => + new Promise((_resolve, reject) => { + init?.signal?.addEventListener("abort", () => reject(init.signal?.reason)); + }), + }); + + await expect(timedOutClient.listAlbums()).rejects.toMatchObject({ code: "IMMICH_TIMEOUT" }); +}); + +test("streams binary endpoints without buffering and preserves safe response metadata", async () => { + const bytes = new Uint8Array([1, 2, 3]); + server.use( + http.get(`${baseUrl}/api/assets/asset-1/thumbnail`, ({ request }) => { + expect(request.method).toBe("GET"); + expect(request.headers.get("x-api-key")).toBe(apiKey); + return new HttpResponse(bytes, { + headers: { + "content-type": "image/jpeg", + "content-length": "3", + "content-disposition": 'inline; filename="jubel.jpg"', + }, + }); + }), + http.get(`${baseUrl}/api/assets/asset-1/original`, ({ request }) => { + expect(request.method).toBe("GET"); + expect(request.headers.get("x-api-key")).toBe(apiKey); + return new HttpResponse(bytes, { + headers: { + "content-type": "image/jpeg", + "content-length": "3", + "content-disposition": 'attachment; filename="jubel.jpg"', + }, + }); + }), + ); + + const thumbnail = await client.getThumbnail("asset-1"); + expect(thumbnail).toMatchObject({ contentType: "image/jpeg", contentLength: 3, filename: "jubel.jpg" }); + await expect(new Response(thumbnail.body).arrayBuffer()).resolves.toEqual(bytes.buffer); + + const original = await client.getOriginal("asset-1"); + expect(original).toMatchObject({ contentType: "image/jpeg", contentLength: 3, filename: "jubel.jpg" }); + await expect(new Response(original.body).arrayBuffer()).resolves.toEqual(bytes.buffer); +}); diff --git a/src/modules/immich/client.ts b/src/modules/immich/client.ts new file mode 100644 index 0000000..50a182f --- /dev/null +++ b/src/modules/immich/client.ts @@ -0,0 +1,220 @@ +import "server-only"; + +import { z } from "zod"; + +import { env } from "@/config/env"; + +import { ImmichClientError, type ImmichErrorCode } from "./errors"; +import type { + ImmichAlbum, + ImmichAlbumSummary, + ImmichAsset, + ImmichBinary, + ImmichClient, + ImmichSearchPage, +} from "./types"; + +const nullableString = z.string().nullable().optional().transform((value) => value ?? null); + +const assetSchema = z + .object({ + id: z.string(), + type: z.literal("IMAGE"), + originalFileName: z.string(), + originalMimeType: z.string(), + localDateTime: nullableString, + fileCreatedAt: nullableString, + albums: z.array(z.object({ id: z.string() }).passthrough()).optional().default([]), + }) + .passthrough(); + +const albumSummarySchema = z + .object({ + id: z.string(), + albumName: z.string(), + description: nullableString, + albumThumbnailAssetId: nullableString, + assetCount: z.number().int().nonnegative(), + }) + .passthrough(); + +const albumSchema = albumSummarySchema.extend({ + assets: z.array(assetSchema), +}); + +const metadataSearchSchema = z + .object({ + assets: z + .object({ + items: z.array(assetSchema), + total: z.number().int().nonnegative(), + nextPage: z.number().int().nullable().optional().transform((value) => value ?? null), + previousPage: z.number().int().nullable().optional().transform((value) => value ?? null), + }) + .passthrough(), + }) + .passthrough(); + +type FetchLike = typeof globalThis.fetch; + +export type CreateImmichClientOptions = { + baseUrl?: string; + apiKey?: string; + fetch?: FetchLike; + timeoutMs?: number; +}; + +function errorForStatus(status: number): ImmichClientError { + const code: ImmichErrorCode = + status === 401 || status === 403 + ? "IMMICH_AUTH_FAILED" + : status === 404 + ? "IMMICH_NOT_FOUND" + : status === 429 + ? "IMMICH_RATE_LIMITED" + : status >= 500 + ? "IMMICH_UNAVAILABLE" + : "IMMICH_REQUEST_FAILED"; + + return new ImmichClientError(code, status); +} + +function responseFilename(response: Response, fallback: string): string { + const contentDisposition = response.headers.get("content-disposition"); + const match = contentDisposition?.match(/filename\*?=(?:UTF-8''|\")(.*?)(?:\"|;|$)/i); + const filename = match?.[1]?.trim(); + + if (!filename) { + return fallback; + } + + try { + return decodeURIComponent(filename); + } catch { + return filename; + } +} + +function contentLength(response: Response): number | null { + const value = response.headers.get("content-length"); + if (!value || !/^\d+$/.test(value)) { + return null; + } + + const length = Number(value); + return Number.isSafeInteger(length) ? length : null; +} + +export function createImmichClient({ + baseUrl = env.IMMICH_BASE_URL, + apiKey = env.IMMICH_API_KEY, + fetch: fetchImpl, + timeoutMs = 15_000, +}: CreateImmichClientOptions = {}): ImmichClient { + const apiBaseUrl = `${baseUrl.replace(/\/+$/, "")}/api`; + + async function request(path: string, init: RequestInit, signal?: AbortSignal): Promise { + const timeoutSignal = AbortSignal.timeout(timeoutMs); + const requestSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal; + + let response: Response; + try { + response = await (fetchImpl ?? globalThis.fetch)(`${apiBaseUrl}${path}`, { + ...init, + headers: { + "x-api-key": apiKey, + ...init.headers, + }, + signal: requestSignal, + }); + } catch { + if (timeoutSignal.aborted) { + throw new ImmichClientError("IMMICH_TIMEOUT"); + } + if (signal?.aborted) { + throw new ImmichClientError("IMMICH_ABORTED"); + } + throw new ImmichClientError("IMMICH_UNAVAILABLE"); + } + + if (!response.ok) { + throw errorForStatus(response.status); + } + + return response; + } + + async function requestJson( + path: string, + init: RequestInit, + schema: z.ZodType, + signal?: AbortSignal, + ): Promise { + const response = await request(path, init, signal); + + try { + return schema.parse(await response.json()); + } catch { + throw new ImmichClientError("IMMICH_INVALID_RESPONSE"); + } + } + + async function requestBinary(path: string, signal?: AbortSignal): Promise { + const response = await request(path, { method: "GET" }, signal); + if (!response.body) { + throw new ImmichClientError("IMMICH_INVALID_RESPONSE"); + } + + return { + body: response.body, + contentType: response.headers.get("content-type") ?? "application/octet-stream", + contentLength: contentLength(response), + filename: responseFilename(response, "asset"), + }; + } + + return { + listAlbums(signal) { + return requestJson("/albums", { method: "GET" }, z.array(albumSummarySchema), signal); + }, + getAlbum(albumId, signal) { + return requestJson( + `/albums/${encodeURIComponent(albumId)}`, + { method: "GET" }, + albumSchema, + signal, + ); + }, + searchPhotos(input, signal) { + return requestJson( + "/search/metadata", + { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ + albumIds: input.albumIds, + ...(input.description === undefined ? {} : { description: input.description }), + type: "IMAGE", + page: input.page, + size: input.size, + }), + }, + metadataSearchSchema.transform(({ assets }) => ({ + items: assets.items, + total: assets.total, + nextPage: assets.nextPage, + previousPage: assets.previousPage, + })), + signal, + ); + }, + getThumbnail(assetId, signal) { + return requestBinary(`/assets/${encodeURIComponent(assetId)}/thumbnail`, signal); + }, + getOriginal(assetId, signal) { + return requestBinary(`/assets/${encodeURIComponent(assetId)}/original`, signal); + }, + }; +} + +export const immichClient = createImmichClient(); diff --git a/src/modules/immich/errors.ts b/src/modules/immich/errors.ts new file mode 100644 index 0000000..a8988ff --- /dev/null +++ b/src/modules/immich/errors.ts @@ -0,0 +1,34 @@ +export const IMMICH_ERROR_CODES = [ + "IMMICH_AUTH_FAILED", + "IMMICH_NOT_FOUND", + "IMMICH_RATE_LIMITED", + "IMMICH_TIMEOUT", + "IMMICH_ABORTED", + "IMMICH_UNAVAILABLE", + "IMMICH_INVALID_RESPONSE", + "IMMICH_REQUEST_FAILED", +] as const; + +export type ImmichErrorCode = (typeof IMMICH_ERROR_CODES)[number]; + +const errorMessages: Record = { + IMMICH_AUTH_FAILED: "Immich authentication failed", + IMMICH_NOT_FOUND: "Immich resource not found", + IMMICH_RATE_LIMITED: "Immich rate limit exceeded", + IMMICH_TIMEOUT: "Immich request timed out", + IMMICH_ABORTED: "Immich request aborted", + IMMICH_UNAVAILABLE: "Immich is unavailable", + IMMICH_INVALID_RESPONSE: "Immich returned an invalid response", + IMMICH_REQUEST_FAILED: "Immich request failed", +}; + +export class ImmichClientError extends Error { + readonly name = "ImmichClientError"; + + constructor( + readonly code: ImmichErrorCode, + readonly status?: number, + ) { + super(errorMessages[code]); + } +} diff --git a/src/modules/immich/types.ts b/src/modules/immich/types.ts new file mode 100644 index 0000000..6f5962f --- /dev/null +++ b/src/modules/immich/types.ts @@ -0,0 +1,46 @@ +export type ImmichAlbumSummary = { + id: string; + albumName: string; + description: string | null; + albumThumbnailAssetId: string | null; + assetCount: number; +}; + +export type ImmichAsset = { + id: string; + type: "IMAGE"; + originalFileName: string; + originalMimeType: string; + localDateTime: string | null; + fileCreatedAt: string | null; + albums: Array<{ id: string }>; +}; + +export type ImmichAlbum = ImmichAlbumSummary & { + assets: ImmichAsset[]; +}; + +export type ImmichSearchPage = { + items: ImmichAsset[]; + total: number; + nextPage: number | null; + previousPage: number | null; +}; + +export type ImmichBinary = { + body: ReadableStream; + contentType: string; + contentLength: number | null; + filename: string; +}; + +export interface ImmichClient { + listAlbums(signal?: AbortSignal): Promise; + getAlbum(albumId: string, signal?: AbortSignal): Promise; + searchPhotos( + input: { albumIds: string[]; description?: string; page: number; size: number }, + signal?: AbortSignal, + ): Promise; + getThumbnail(assetId: string, signal?: AbortSignal): Promise; + getOriginal(assetId: string, signal?: AbortSignal): Promise; +} diff --git a/tests/fixtures/immich.ts b/tests/fixtures/immich.ts new file mode 100644 index 0000000..9c70229 --- /dev/null +++ b/tests/fixtures/immich.ts @@ -0,0 +1,31 @@ +export const immichAlbum = { + id: "album-1", + albumName: "Jubel", + description: "Bilder vom Jubel", + albumThumbnailAssetId: "asset-1", + assetCount: 1, +}; + +export const immichAsset = { + id: "asset-1", + type: "IMAGE", + originalFileName: "jubel.jpg", + originalMimeType: "image/jpeg", + localDateTime: "2026-08-08T12:00:00.000Z", + fileCreatedAt: "2026-08-08T12:00:00.000Z", + albums: [{ id: "album-1" }], +}; + +export const immichAlbumDetail = { + ...immichAlbum, + assets: [immichAsset], +}; + +export const immichMetadataSearchResponse = { + assets: { + items: [immichAsset], + total: 1, + nextPage: null, + previousPage: null, + }, +}; From 653e5ca050b9aef06e4367663e03174507156ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 21:45:59 +0200 Subject: [PATCH 09/29] fix: manage immich request lifecycles --- src/modules/immich/client.test.ts | 138 ++++++++++++++++++++++ src/modules/immich/client.ts | 183 +++++++++++++++++++++++++----- 2 files changed, 295 insertions(+), 26 deletions(-) diff --git a/src/modules/immich/client.test.ts b/src/modules/immich/client.test.ts index c21de7b..b76e3cc 100644 --- a/src/modules/immich/client.test.ts +++ b/src/modules/immich/client.test.ts @@ -18,6 +18,14 @@ beforeEach(() => server.listen({ onUnhandledRequest: "error" })); afterEach(() => server.resetHandlers()); afterEach(() => server.close()); +function wait(milliseconds: number): Promise { + return new Promise((resolve) => setTimeout(resolve, milliseconds)); +} + +function albumsResponse(body: ReadableStream | string): Response { + return new Response(body, { headers: { "content-type": "application/json" } }); +} + test("lists albums through the documented API with server-side authentication", async () => { server.use( http.get(`${baseUrl}/api/albums`, ({ request }) => { @@ -109,6 +117,136 @@ test("maps an aborted timeout signal to IMMICH_TIMEOUT", async () => { await expect(timedOutClient.listAlbums()).rejects.toMatchObject({ code: "IMMICH_TIMEOUT" }); }); +test("cleans up the request timeout after a successful JSON response", async () => { + let requestSignal: AbortSignal | undefined; + const fastClient = createImmichClient({ + baseUrl, + apiKey, + timeoutMs: 5, + fetch: async (_input, init) => { + requestSignal = init?.signal ?? undefined; + return albumsResponse(JSON.stringify([immichAlbum])); + }, + }); + + await expect(fastClient.listAlbums()).resolves.toEqual([immichAlbum]); + await wait(20); + expect(requestSignal?.aborted).toBe(false); +}); + +test("clears the request timeout after binary headers so a long stream continues", async () => { + let sourceController: ReadableStreamDefaultController | undefined; + let requestAborts = 0; + const streamingClient = createImmichClient({ + baseUrl, + apiKey, + timeoutMs: 5, + fetch: async (_input, init) => { + const body = new ReadableStream({ + start(controller) { + sourceController = controller; + init?.signal?.addEventListener("abort", () => { + requestAborts += 1; + controller.error(init.signal?.reason); + }); + }, + }); + return new Response(body, { headers: { "content-type": "image/jpeg" } }); + }, + }); + + const original = await streamingClient.getOriginal("asset-1"); + await wait(20); + sourceController?.enqueue(new Uint8Array([1, 2, 3])); + sourceController?.close(); + + await expect(new Response(original.body).arrayBuffer()).resolves.toEqual(new Uint8Array([1, 2, 3]).buffer); + expect(requestAborts).toBe(0); +}); + +test("maps a caller abort during a binary stream to IMMICH_ABORTED", async () => { + const caller = new AbortController(); + const streamingClient = createImmichClient({ + baseUrl, + apiKey, + fetch: async () => { + const body = new ReadableStream(); + return new Response(body, { headers: { "content-type": "image/jpeg" } }); + }, + }); + + const original = await streamingClient.getOriginal("asset-1", caller.signal); + const read = original.body.getReader().read(); + caller.abort(); + + await expect(read).rejects.toMatchObject({ code: "IMMICH_ABORTED" }); +}); + +test("preserves abort, timeout, and network failures while reading JSON bodies", async () => { + const caller = new AbortController(); + const abortedClient = createImmichClient({ + baseUrl, + apiKey, + fetch: async (_input, init) => + albumsResponse( + new ReadableStream({ + start(controller) { + init?.signal?.addEventListener("abort", () => controller.error(init.signal?.reason)); + }, + }), + ), + }); + const aborted = abortedClient.listAlbums(caller.signal); + await Promise.resolve(); + caller.abort(); + await expect(aborted).rejects.toMatchObject({ code: "IMMICH_ABORTED" }); + + const timedOutClient = createImmichClient({ + baseUrl, + apiKey, + timeoutMs: 5, + fetch: async (_input, init) => + albumsResponse( + new ReadableStream({ + start(controller) { + init?.signal?.addEventListener("abort", () => controller.error(init.signal?.reason)); + }, + }), + ), + }); + await expect(timedOutClient.listAlbums()).rejects.toMatchObject({ code: "IMMICH_TIMEOUT" }); + + const unavailableClient = createImmichClient({ + baseUrl, + apiKey, + fetch: async () => + albumsResponse( + new ReadableStream({ + start(controller) { + queueMicrotask(() => controller.error(new TypeError("connection lost"))); + }, + }), + ), + }); + await expect(unavailableClient.listAlbums()).rejects.toMatchObject({ code: "IMMICH_UNAVAILABLE" }); +}); + +test("maps malformed JSON and schema failures to IMMICH_INVALID_RESPONSE", async () => { + const malformedJsonClient = createImmichClient({ + baseUrl, + apiKey, + fetch: async () => albumsResponse("{"), + }); + await expect(malformedJsonClient.listAlbums()).rejects.toMatchObject({ code: "IMMICH_INVALID_RESPONSE" }); + + const malformedSchemaClient = createImmichClient({ + baseUrl, + apiKey, + fetch: async () => albumsResponse(JSON.stringify([{ id: "missing-required-fields" }])), + }); + await expect(malformedSchemaClient.listAlbums()).rejects.toMatchObject({ code: "IMMICH_INVALID_RESPONSE" }); +}); + test("streams binary endpoints without buffering and preserves safe response metadata", async () => { const bytes = new Uint8Array([1, 2, 3]); server.use( diff --git a/src/modules/immich/client.ts b/src/modules/immich/client.ts index 50a182f..58628c1 100644 --- a/src/modules/immich/client.ts +++ b/src/modules/immich/client.ts @@ -8,7 +8,6 @@ import { ImmichClientError, type ImmichErrorCode } from "./errors"; import type { ImmichAlbum, ImmichAlbumSummary, - ImmichAsset, ImmichBinary, ImmichClient, ImmichSearchPage, @@ -57,6 +56,13 @@ const metadataSearchSchema = z type FetchLike = typeof globalThis.fetch; +type RequestLifecycle = { + signal: AbortSignal; + cleanup(): void; + clearTimeout(): void; + failureCode(): Extract | undefined; +}; + export type CreateImmichClientOptions = { baseUrl?: string; apiKey?: string; @@ -105,6 +111,51 @@ function contentLength(response: Response): number | null { return Number.isSafeInteger(length) ? length : null; } +function createRequestLifecycle(callerSignal: AbortSignal | undefined, timeoutMs: number): RequestLifecycle { + const controller = new AbortController(); + let timedOut = false; + let timeoutId: ReturnType | undefined = setTimeout(() => { + timedOut = true; + controller.abort(); + }, timeoutMs); + + const abortFromCaller = () => controller.abort(); + if (callerSignal?.aborted) { + abortFromCaller(); + } else { + callerSignal?.addEventListener("abort", abortFromCaller, { once: true }); + } + + function clearTimeout() { + if (timeoutId !== undefined) { + globalThis.clearTimeout(timeoutId); + timeoutId = undefined; + } + } + + return { + signal: controller.signal, + cleanup() { + clearTimeout(); + callerSignal?.removeEventListener("abort", abortFromCaller); + }, + clearTimeout, + failureCode() { + if (timedOut) { + return "IMMICH_TIMEOUT"; + } + if (callerSignal?.aborted) { + return "IMMICH_ABORTED"; + } + return undefined; + }, + }; +} + +function failureError(lifecycle: RequestLifecycle): ImmichClientError { + return new ImmichClientError(lifecycle.failureCode() ?? "IMMICH_UNAVAILABLE"); +} + export function createImmichClient({ baseUrl = env.IMMICH_BASE_URL, apiKey = env.IMMICH_API_KEY, @@ -113,35 +164,35 @@ export function createImmichClient({ }: CreateImmichClientOptions = {}): ImmichClient { const apiBaseUrl = `${baseUrl.replace(/\/+$/, "")}/api`; - async function request(path: string, init: RequestInit, signal?: AbortSignal): Promise { - const timeoutSignal = AbortSignal.timeout(timeoutMs); - const requestSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal; + async function request( + path: string, + init: RequestInit, + signal?: AbortSignal, + ): Promise<{ response: Response; lifecycle: RequestLifecycle }> { + const lifecycle = createRequestLifecycle(signal, timeoutMs); - let response: Response; try { - response = await (fetchImpl ?? globalThis.fetch)(`${apiBaseUrl}${path}`, { + const response = await (fetchImpl ?? globalThis.fetch)(`${apiBaseUrl}${path}`, { ...init, headers: { "x-api-key": apiKey, ...init.headers, }, - signal: requestSignal, + signal: lifecycle.signal, }); - } catch { - if (timeoutSignal.aborted) { - throw new ImmichClientError("IMMICH_TIMEOUT"); - } - if (signal?.aborted) { - throw new ImmichClientError("IMMICH_ABORTED"); - } - throw new ImmichClientError("IMMICH_UNAVAILABLE"); - } - if (!response.ok) { - throw errorForStatus(response.status); - } + if (!response.ok) { + throw errorForStatus(response.status); + } - return response; + return { response, lifecycle }; + } catch (error) { + lifecycle.cleanup(); + if (error instanceof ImmichClientError) { + throw error; + } + throw failureError(lifecycle); + } } async function requestJson( @@ -150,23 +201,103 @@ export function createImmichClient({ schema: z.ZodType, signal?: AbortSignal, ): Promise { - const response = await request(path, init, signal); + const { response, lifecycle } = await request(path, init, signal); try { - return schema.parse(await response.json()); - } catch { - throw new ImmichClientError("IMMICH_INVALID_RESPONSE"); + let body: unknown; + try { + body = await response.json(); + } catch (error) { + const code = lifecycle.failureCode(); + if (code) { + throw new ImmichClientError(code); + } + if (error instanceof SyntaxError) { + throw new ImmichClientError("IMMICH_INVALID_RESPONSE"); + } + throw new ImmichClientError("IMMICH_UNAVAILABLE"); + } + + try { + return schema.parse(body); + } catch (error) { + if (error instanceof z.ZodError) { + throw new ImmichClientError("IMMICH_INVALID_RESPONSE"); + } + throw error; + } + } finally { + lifecycle.cleanup(); } } async function requestBinary(path: string, signal?: AbortSignal): Promise { - const response = await request(path, { method: "GET" }, signal); + const { response, lifecycle } = await request(path, { method: "GET" }, signal); if (!response.body) { + lifecycle.cleanup(); throw new ImmichClientError("IMMICH_INVALID_RESPONSE"); } + lifecycle.clearTimeout(); + const reader = response.body.getReader(); + let completed = false; + let abortStream: (() => void) | undefined; + const finish = () => { + if (completed) { + return; + } + completed = true; + if (abortStream) { + lifecycle.signal.removeEventListener("abort", abortStream); + } + lifecycle.cleanup(); + }; + + const body = new ReadableStream({ + start(controller) { + abortStream = () => { + if (completed) { + return; + } + const error = failureError(lifecycle); + finish(); + void reader.cancel(error); + controller.error(error); + }; + lifecycle.signal.addEventListener("abort", abortStream, { once: true }); + if (lifecycle.signal.aborted) { + abortStream(); + } + }, + async pull(controller) { + if (completed) { + return; + } + try { + const { done, value } = await reader.read(); + if (done) { + finish(); + controller.close(); + return; + } + controller.enqueue(value); + } catch { + if (completed) { + return; + } + const error = failureError(lifecycle); + finish(); + controller.error(error); + } + }, + cancel(reason) { + finish(); + return reader.cancel(reason); + }, + }); + return { - body: response.body, + body, contentType: response.headers.get("content-type") ?? "application/octet-stream", contentLength: contentLength(response), filename: responseFilename(response, "asset"), From 0fe2c80cda9b551fe43e38f096fb65d32b1adca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 21:49:34 +0200 Subject: [PATCH 10/29] fix: contain immich stream cancel races --- src/modules/immich/client.test.ts | 22 ++++++++++++++++++++++ src/modules/immich/client.ts | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/modules/immich/client.test.ts b/src/modules/immich/client.test.ts index b76e3cc..6183811 100644 --- a/src/modules/immich/client.test.ts +++ b/src/modules/immich/client.test.ts @@ -182,6 +182,28 @@ test("maps a caller abort during a binary stream to IMMICH_ABORTED", async () => await expect(read).rejects.toMatchObject({ code: "IMMICH_ABORTED" }); }); +test("contains an upstream binary cancel rejection after caller abort", async () => { + const caller = new AbortController(); + const streamingClient = createImmichClient({ + baseUrl, + apiKey, + fetch: async () => { + const body = new ReadableStream({ + cancel() { + return Promise.reject(new Error("upstream cancel race")); + }, + }); + return new Response(body, { headers: { "content-type": "image/jpeg" } }); + }, + }); + + const original = await streamingClient.getOriginal("asset-1", caller.signal); + const read = original.body.getReader().read(); + caller.abort(); + + await expect(read).rejects.toMatchObject({ code: "IMMICH_ABORTED" }); +}); + test("preserves abort, timeout, and network failures while reading JSON bodies", async () => { const caller = new AbortController(); const abortedClient = createImmichClient({ diff --git a/src/modules/immich/client.ts b/src/modules/immich/client.ts index 58628c1..0d4025c 100644 --- a/src/modules/immich/client.ts +++ b/src/modules/immich/client.ts @@ -261,7 +261,7 @@ export function createImmichClient({ } const error = failureError(lifecycle); finish(); - void reader.cancel(error); + void reader.cancel(error).catch(() => undefined); controller.error(error); }; lifecycle.signal.addEventListener("abort", abortStream, { once: true }); From 4af86f6eb9eb912a877148694562f8ec01447e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 22:00:15 +0200 Subject: [PATCH 11/29] feat: add editorial album permissions --- .../redaktionen/[id]/alben/actions.test.ts | 51 ++++ .../admin/redaktionen/[id]/alben/actions.ts | 45 +++ src/app/admin/redaktionen/[id]/alben/page.tsx | 97 +++++++ src/modules/albums/grants.test.ts | 182 ++++++++++++ src/modules/albums/grants.ts | 258 ++++++++++++++++++ 5 files changed, 633 insertions(+) create mode 100644 src/app/admin/redaktionen/[id]/alben/actions.test.ts create mode 100644 src/app/admin/redaktionen/[id]/alben/actions.ts create mode 100644 src/app/admin/redaktionen/[id]/alben/page.tsx create mode 100644 src/modules/albums/grants.test.ts create mode 100644 src/modules/albums/grants.ts diff --git a/src/app/admin/redaktionen/[id]/alben/actions.test.ts b/src/app/admin/redaktionen/[id]/alben/actions.test.ts new file mode 100644 index 0000000..4c6e717 --- /dev/null +++ b/src/app/admin/redaktionen/[id]/alben/actions.test.ts @@ -0,0 +1,51 @@ +import { expect, test, vi } from "vitest"; + +const mocks = vi.hoisted(() => ({ + grantAlbum: vi.fn(), + headers: vi.fn(), + requireAdmin: vi.fn(), + revalidatePath: vi.fn(), + revokeAlbum: vi.fn(), +})); + +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", () => ({ + albumGrantService: { grantAlbum: mocks.grantAlbum, revokeAlbum: mocks.revokeAlbum }, +})); + +import { grantAlbumAction } from "./actions"; + +test("the grant action rejects unauthenticated callers before accepting submitted identifiers", async () => { + mocks.headers.mockResolvedValue(new Headers()); + mocks.requireAdmin.mockRejectedValue(new Error("ADMIN_REQUIRED")); + const formData = new FormData(); + formData.set("immichAlbumId", "11111111-1111-4111-8111-111111111111"); + formData.set("adminUserId", "forged-user"); + + await expect( + grantAlbumAction("00000000-0000-4000-8000-000000000001", formData), + ).rejects.toThrow("ADMIN_REQUIRED"); + expect(mocks.grantAlbum).not.toHaveBeenCalled(); +}); + +test("the grant action uses the authenticated principal instead of a submitted admin user ID", async () => { + mocks.headers.mockResolvedValue(new Headers()); + mocks.requireAdmin.mockResolvedValue({ userId: "admin-1" }); + mocks.grantAlbum.mockResolvedValue(undefined); + const formData = new FormData(); + formData.set("immichAlbumId", "11111111-1111-4111-8111-111111111111"); + formData.set("adminUserId", "forged-user"); + + await grantAlbumAction("00000000-0000-4000-8000-000000000001", formData); + + expect(mocks.grantAlbum).toHaveBeenCalledWith({ + editorialId: "00000000-0000-4000-8000-000000000001", + immichAlbumId: "11111111-1111-4111-8111-111111111111", + adminUserId: "admin-1", + }); + expect(mocks.revalidatePath).toHaveBeenCalledWith( + "/admin/redaktionen/00000000-0000-4000-8000-000000000001/alben", + ); +}); diff --git a/src/app/admin/redaktionen/[id]/alben/actions.ts b/src/app/admin/redaktionen/[id]/alben/actions.ts new file mode 100644 index 0000000..719093d --- /dev/null +++ b/src/app/admin/redaktionen/[id]/alben/actions.ts @@ -0,0 +1,45 @@ +"use server"; + +import { revalidatePath } from "next/cache"; +import { headers } from "next/headers"; + +import { albumGrantService } from "@/modules/albums/grants"; +import { requireAdmin } from "@/modules/auth/principal"; + +export async function grantAlbumAction(editorialId: string, formData: FormData): Promise { + const principal = await getAdminPrincipal(); + const safeEditorialId = requiredId(editorialId); + const immichAlbumId = requiredId(formData.get("immichAlbumId")); + await albumGrantService.grantAlbum({ + editorialId: safeEditorialId, + immichAlbumId, + adminUserId: principal.userId, + }); + revalidatePath(`/admin/redaktionen/${safeEditorialId}/alben`); +} + +export async function revokeAlbumAction(editorialId: string, formData: FormData): Promise { + const principal = await getAdminPrincipal(); + const safeEditorialId = requiredId(editorialId); + const immichAlbumId = requiredId(formData.get("immichAlbumId")); + await albumGrantService.revokeAlbum({ + editorialId: safeEditorialId, + immichAlbumId, + adminUserId: principal.userId, + }); + revalidatePath(`/admin/redaktionen/${safeEditorialId}/alben`); +} + +async function getAdminPrincipal() { + return requireAdmin(new Headers(await headers())); +} + +function requiredId(value: unknown): string { + if ( + typeof value !== "string" || + !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value) + ) { + throw new Error("INVALID_ID"); + } + return value; +} diff --git a/src/app/admin/redaktionen/[id]/alben/page.tsx b/src/app/admin/redaktionen/[id]/alben/page.tsx new file mode 100644 index 0000000..1083504 --- /dev/null +++ b/src/app/admin/redaktionen/[id]/alben/page.tsx @@ -0,0 +1,97 @@ +import Image from "next/image"; +import Link from "next/link"; +import { eq } from "drizzle-orm"; +import { notFound } from "next/navigation"; + +import { db } from "@/db/client"; +import { editorialAccounts } from "@/db/schema"; +import { albumGrantService } from "@/modules/albums/grants"; + +import { grantAlbumAction, revokeAlbumAction } from "./actions"; + +export default async function EditorialAlbumsPage({ + params, +}: Readonly<{ params: Promise<{ id: string }> }>) { + const { id } = await params; + const [editorial] = await db + .select({ id: editorialAccounts.id, name: editorialAccounts.name }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, id)) + .limit(1); + if (!editorial) { + notFound(); + } + + const albumResult = await albumGrantService + .listAssignableAlbums(editorial.id) + .then((albums) => ({ albums, unavailable: false })) + .catch(() => ({ albums: [], unavailable: true })); + + if (albumResult.unavailable) { + return ( +
+

Redaktion · Albumrechte

+

Alben für {editorial.name}

+

+ Die Immich-Alben sind momentan nicht erreichbar. Bereits bestehende Zuweisungen bleiben + unverändert. +

+

+ Zurück zur Redaktion +

+
+ ); + } + + return ( +
+

Redaktion · Albumrechte

+

Alben für {editorial.name}

+

+ Nur Alben, die der technische Immich-Zugang lesen kann, lassen sich zuweisen. +

+

+ Zurück zur Redaktion +

+ + {albumResult.albums.length === 0 ? ( +

Derzeit sind keine zuweisbaren Alben vorhanden.

+ ) : ( +
    + {albumResult.albums.map((album) => { + const action = album.isGranted ? revokeAlbumAction : grantAlbumAction; + return ( +
  • +
    + {album.albumThumbnailAssetId ? ( + {`Titelbild + ) : ( +
    + Kein Cover +
    + )} +

    {album.albumName}

    +

    {album.assetCount} Fotos

    +

    + Status: {album.isGranted ? "Zugewiesen" : "Nicht zugewiesen"} +

    + + + + +
    +
  • + ); + })} +
+ )} +
+ ); +} diff --git a/src/modules/albums/grants.test.ts b/src/modules/albums/grants.test.ts new file mode 100644 index 0000000..ac210b4 --- /dev/null +++ b/src/modules/albums/grants.test.ts @@ -0,0 +1,182 @@ +import { expect, test, vi } from "vitest"; + +import { + ALBUM_GRANT_LOCK_ORDER, + AlbumGrantError, + createAlbumGrantService, + type AlbumGrantRepository, +} from "./grants"; +import { EDITORIAL_MUTATION_LOCK_ORDER } from "@/modules/editorials/service"; + +type Grant = { editorialId: string; albumId: string; revokedAt: Date | null }; +type Audit = { + eventType: string; + actorUserId: string; + editorialId: string; + albumId: string; + previousValues: Record; + newValues: Record; +}; + +function createRepository(initial: Grant[] = []) { + const grants = [...initial]; + const audit: Audit[] = []; + const repository: AlbumGrantRepository = { + async listActiveAlbumIds(editorialId) { + return grants + .filter((grant) => grant.editorialId === editorialId && grant.revokedAt === null) + .map((grant) => grant.albumId); + }, + async grant(input) { + const active = grants.find( + (grant) => + grant.editorialId === input.editorialId && + grant.albumId === input.immichAlbumId && + grant.revokedAt === null, + ); + if (active) return false; + + const revoked = grants.find( + (grant) => + grant.editorialId === input.editorialId && + grant.albumId === input.immichAlbumId && + grant.revokedAt !== null, + ); + if (revoked) { + revoked.revokedAt = null; + } else { + grants.push({ editorialId: input.editorialId, albumId: input.immichAlbumId, revokedAt: null }); + } + audit.push({ + eventType: "album_granted", + actorUserId: input.adminUserId, + editorialId: input.editorialId, + albumId: input.immichAlbumId, + previousValues: { granted: false }, + newValues: { granted: true }, + }); + return true; + }, + async revoke(input) { + const active = grants.find( + (grant) => + grant.editorialId === input.editorialId && + grant.albumId === input.immichAlbumId && + grant.revokedAt === null, + ); + if (!active) return false; + active.revokedAt = new Date(); + audit.push({ + eventType: "album_revoked", + actorUserId: input.adminUserId, + editorialId: input.editorialId, + albumId: input.immichAlbumId, + previousValues: { granted: true }, + newValues: { granted: false }, + }); + return true; + }, + }; + return { repository, grants, audit }; +} + +function createService(initial: Grant[] = []) { + const { repository, grants, audit } = createRepository(initial); + const immich = { + getAlbum: vi.fn().mockResolvedValue({ + id: "album-1", + albumName: "Pressefotos", + description: null, + albumThumbnailAssetId: "cover-1", + assetCount: 4, + assets: [], + }), + listAlbums: vi.fn().mockResolvedValue([ + { + id: "album-1", + albumName: "Pressefotos", + description: null, + albumThumbnailAssetId: "cover-1", + assetCount: 4, + }, + ]), + }; + return { + service: createAlbumGrantService({ repository, immich }), + immich, + grants, + audit, + }; +} + +test("refuses to grant an album that the service user cannot read", async () => { + const { service, immich } = createService(); + immich.getAlbum.mockRejectedValue({ code: "IMMICH_NOT_FOUND" }); + + await expect( + service.grantAlbum({ editorialId: "e1", immichAlbumId: "hidden", adminUserId: "a1" }), + ).rejects.toMatchObject({ code: "ALBUM_NOT_ASSIGNABLE" }); +}); + +test("granting an album is idempotent and records one state-change audit event", async () => { + const { service, audit } = createService(); + + await service.grantAlbum({ editorialId: "e1", immichAlbumId: "album-1", adminUserId: "a1" }); + await service.grantAlbum({ editorialId: "e1", immichAlbumId: "album-1", adminUserId: "a1" }); + + await expect(service.getGrantedAlbumIds("e1")).resolves.toEqual(["album-1"]); + expect(audit).toEqual([ + expect.objectContaining({ + eventType: "album_granted", + actorUserId: "a1", + editorialId: "e1", + albumId: "album-1", + previousValues: { granted: false }, + newValues: { granted: true }, + }), + ]); +}); + +test("a revoked album can be re-granted without creating another current grant", async () => { + const { service, grants } = createService([ + { editorialId: "e1", albumId: "album-1", revokedAt: new Date("2026-08-08T00:00:00Z") }, + ]); + + await service.grantAlbum({ editorialId: "e1", immichAlbumId: "album-1", adminUserId: "a1" }); + + expect(grants).toHaveLength(1); + await expect(service.getGrantedAlbumIds("e1")).resolves.toEqual(["album-1"]); +}); + +test("revocation immediately removes the album from visible IDs and records the actor", async () => { + const { service, audit } = createService([ + { editorialId: "e1", albumId: "album-1", revokedAt: null }, + ]); + + await service.revokeAlbum({ editorialId: "e1", immichAlbumId: "album-1", adminUserId: "a1" }); + + await expect(service.getGrantedAlbumIds("e1")).resolves.not.toContain("album-1"); + expect(audit).toContainEqual( + expect.objectContaining({ + eventType: "album_revoked", + actorUserId: "a1", + editorialId: "e1", + albumId: "album-1", + previousValues: { granted: true }, + newValues: { granted: false }, + }), + ); +}); + +test("uses the same lock order as approval so concurrent approval and revocation serialize", () => { + expect(ALBUM_GRANT_LOCK_ORDER).toEqual(EDITORIAL_MUTATION_LOCK_ORDER); +}); + +test("reports a stable unavailable error when the Immich album list cannot be loaded", async () => { + const { service, immich } = createService(); + immich.listAlbums.mockRejectedValue({ code: "IMMICH_TIMEOUT" }); + + await expect(service.listAssignableAlbums("e1")).rejects.toEqual( + new AlbumGrantError("IMMICH_UNAVAILABLE"), + ); +}); diff --git a/src/modules/albums/grants.ts b/src/modules/albums/grants.ts new file mode 100644 index 0000000..9e57733 --- /dev/null +++ b/src/modules/albums/grants.ts @@ -0,0 +1,258 @@ +import "server-only"; + +import { and, eq, isNull, sql } from "drizzle-orm"; +import type { NodePgDatabase } from "drizzle-orm/node-postgres"; + +import { db } from "@/db/client"; +import { albumGrants, auditEvents, editorialAccounts } from "@/db/schema"; +import type * as schema from "@/db/schema"; +import { EDITORIAL_MUTATION_LOCK_ORDER } from "@/modules/editorials/service"; +import { immichClient } from "@/modules/immich/client"; +import type { ImmichAlbumSummary, ImmichClient } from "@/modules/immich/types"; + +export type AssignableAlbum = ImmichAlbumSummary & { isGranted: boolean }; + +export type AlbumGrantInput = { + editorialId: string; + immichAlbumId: string; + adminUserId: string; +}; + +export type AlbumGrantRepository = { + listActiveAlbumIds(editorialId: string): Promise; + grant(input: AlbumGrantInput): Promise; + revoke(input: AlbumGrantInput): Promise; +}; + +export const ALBUM_GRANT_LOCK_ORDER = EDITORIAL_MUTATION_LOCK_ORDER; + +export class AlbumGrantError extends Error { + readonly name = "AlbumGrantError"; + + constructor( + readonly code: + | "ALBUM_NOT_ASSIGNABLE" + | "IMMICH_UNAVAILABLE" + | "EDITORIAL_NOT_FOUND" + | "INVALID_ALBUM_GRANT_INPUT", + ) { + super(code); + } +} + +export function createAlbumGrantService({ + repository, + immich, +}: { + repository: AlbumGrantRepository; + immich: Pick; +}) { + return { + async listAssignableAlbums(editorialId: string): Promise { + assertIdentifier(editorialId); + const [albums, grantedAlbumIds] = await Promise.all([ + loadAlbums(immich), + repository.listActiveAlbumIds(editorialId), + ]); + const granted = new Set(grantedAlbumIds); + return albums.map((album) => ({ ...album, isGranted: granted.has(album.id) })); + }, + + async grantAlbum(input: AlbumGrantInput): Promise { + assertInput(input); + try { + await immich.getAlbum(input.immichAlbumId); + } catch (error) { + if (hasCode(error, "IMMICH_NOT_FOUND")) { + throw new AlbumGrantError("ALBUM_NOT_ASSIGNABLE"); + } + throw new AlbumGrantError("IMMICH_UNAVAILABLE"); + } + await repository.grant(input); + }, + + async revokeAlbum(input: AlbumGrantInput): Promise { + assertInput(input); + await repository.revoke(input); + }, + + async getGrantedAlbumIds(editorialId: string): Promise { + assertIdentifier(editorialId); + return repository.listActiveAlbumIds(editorialId); + }, + }; +} + +export function createAlbumGrantRepository( + database: NodePgDatabase, +): AlbumGrantRepository { + return { + async listActiveAlbumIds(editorialId) { + const grants = await database + .select({ immichAlbumId: albumGrants.immichAlbumId }) + .from(albumGrants) + .where(and(eq(albumGrants.editorialAccountId, editorialId), isNull(albumGrants.revokedAt))); + return grants.map((grant) => grant.immichAlbumId); + }, + + async grant(input) { + return database.transaction(async (transaction) => { + await lockEditorialAlbumMutation(transaction, input.editorialId); + const editorial = await lockEditorial(transaction, input.editorialId); + const grants = await lockAlbumGrants(transaction, input.editorialId, input.immichAlbumId); + const activeGrant = grants.find((grant) => grant.revokedAt === null); + if (activeGrant) { + return false; + } + + const changedAt = new Date(); + const previousGrant = grants[0]; + if (previousGrant) { + await transaction + .update(albumGrants) + .set({ + grantedAt: changedAt, + grantedByUserId: input.adminUserId, + revokedAt: null, + }) + .where(eq(albumGrants.id, previousGrant.id)); + } else { + await transaction.insert(albumGrants).values({ + editorialAccountId: editorial.id, + immichAlbumId: input.immichAlbumId, + grantedAt: changedAt, + grantedByUserId: input.adminUserId, + }); + } + + await transaction.insert(auditEvents).values({ + eventType: "album_granted", + actorUserId: input.adminUserId, + actorType: "admin", + entityType: "album_grant", + entityId: input.immichAlbumId, + previousValues: { + editorialId: editorial.id, + immichAlbumId: input.immichAlbumId, + granted: false, + }, + newValues: { + editorialId: editorial.id, + immichAlbumId: input.immichAlbumId, + granted: true, + }, + occurredAt: changedAt, + }); + return true; + }); + }, + + async revoke(input) { + return database.transaction(async (transaction) => { + await lockEditorialAlbumMutation(transaction, input.editorialId); + const editorial = await lockEditorial(transaction, input.editorialId); + const grants = await lockAlbumGrants(transaction, input.editorialId, input.immichAlbumId); + const activeGrant = grants.find((grant) => grant.revokedAt === null); + if (!activeGrant) { + return false; + } + + const changedAt = new Date(); + await transaction + .update(albumGrants) + .set({ revokedAt: changedAt }) + .where(and(eq(albumGrants.id, activeGrant.id), isNull(albumGrants.revokedAt))); + await transaction.insert(auditEvents).values({ + eventType: "album_revoked", + actorUserId: input.adminUserId, + actorType: "admin", + entityType: "album_grant", + entityId: input.immichAlbumId, + previousValues: { + editorialId: editorial.id, + immichAlbumId: input.immichAlbumId, + granted: true, + }, + newValues: { + editorialId: editorial.id, + immichAlbumId: input.immichAlbumId, + granted: false, + }, + occurredAt: changedAt, + }); + return true; + }); + }, + }; +} + +async function loadAlbums(immich: Pick): Promise { + try { + return await immich.listAlbums(); + } catch { + throw new AlbumGrantError("IMMICH_UNAVAILABLE"); + } +} + +function assertInput(input: AlbumGrantInput): void { + assertIdentifier(input.editorialId); + assertIdentifier(input.immichAlbumId); + assertIdentifier(input.adminUserId); +} + +function assertIdentifier(value: string): void { + if (!value.trim()) { + throw new AlbumGrantError("INVALID_ALBUM_GRANT_INPUT"); + } +} + +function hasCode(error: unknown, code: string): boolean { + return typeof error === "object" && error !== null && "code" in error && error.code === code; +} + +async function lockEditorialAlbumMutation( + transaction: NodePgDatabase, + editorialId: string, +): Promise { + await transaction.execute( + sql`select pg_advisory_xact_lock(hashtextextended(${editorialId}, 0))`, + ); +} + +async function lockEditorial( + transaction: NodePgDatabase, + editorialId: string, +): Promise<{ id: string }> { + const [editorial] = await transaction + .select({ id: editorialAccounts.id }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, editorialId)) + .for("update") + .limit(1); + if (!editorial) { + throw new AlbumGrantError("EDITORIAL_NOT_FOUND"); + } + return editorial; +} + +async function lockAlbumGrants( + transaction: NodePgDatabase, + editorialId: string, + immichAlbumId: string, +) { + return transaction + .select({ id: albumGrants.id, revokedAt: albumGrants.revokedAt }) + .from(albumGrants) + .where( + and( + eq(albumGrants.editorialAccountId, editorialId), + eq(albumGrants.immichAlbumId, immichAlbumId), + ), + ) + .for("update"); +} + +export const albumGrantService = createAlbumGrantService({ + repository: createAlbumGrantRepository(db), + immich: immichClient, +}); From f6e6018cc1ed1221cea6b8783df45d90df8ecf24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 22:06:34 +0200 Subject: [PATCH 12/29] fix: link album assignment and narrow errors --- .../redaktionen/[id]/alben/page-content.ts | 16 ++++++ .../redaktionen/[id]/alben/page.test.tsx | 47 ++++++++++++++++ src/app/admin/redaktionen/[id]/alben/page.tsx | 6 +- src/app/admin/redaktionen/[id]/page.tsx | 40 +------------ src/modules/editorials/admin-detail.tsx | 56 +++++++++++++++++++ 5 files changed, 123 insertions(+), 42 deletions(-) create mode 100644 src/app/admin/redaktionen/[id]/alben/page-content.ts create mode 100644 src/app/admin/redaktionen/[id]/alben/page.test.tsx create mode 100644 src/modules/editorials/admin-detail.tsx diff --git a/src/app/admin/redaktionen/[id]/alben/page-content.ts b/src/app/admin/redaktionen/[id]/alben/page-content.ts new file mode 100644 index 0000000..a8eb8c9 --- /dev/null +++ b/src/app/admin/redaktionen/[id]/alben/page-content.ts @@ -0,0 +1,16 @@ +import { AlbumGrantError, albumGrantService } from "@/modules/albums/grants"; + +export async function loadAssignableAlbums( + editorialId: string, + service: Pick = albumGrantService, +) { + try { + const albums = await service.listAssignableAlbums(editorialId); + return { albums, unavailable: false }; + } catch (error) { + if (error instanceof AlbumGrantError && error.code === "IMMICH_UNAVAILABLE") { + return { albums: [], unavailable: true }; + } + throw error; + } +} diff --git a/src/app/admin/redaktionen/[id]/alben/page.test.tsx b/src/app/admin/redaktionen/[id]/alben/page.test.tsx new file mode 100644 index 0000000..abad4cd --- /dev/null +++ b/src/app/admin/redaktionen/[id]/alben/page.test.tsx @@ -0,0 +1,47 @@ +// @vitest-environment jsdom + +import { render, screen } from "@testing-library/react"; +import { expect, test, vi } from "vitest"; + +import { EditorialDetailContent } from "@/modules/editorials/admin-detail"; +import { AlbumGrantError } from "@/modules/albums/grants"; +import { loadAssignableAlbums } from "./page-content"; + +const editorial = { + id: "00000000-0000-4000-8000-000000000001", + name: "Neue Redaktion", + contactName: "Mara Muster", + loginEmail: "mara@example.com", + status: "pending_approval" as const, + emailVerifiedAt: null, + currentPriceCents: null, +}; + +test("the editorial detail links admins to its album-assignment page", () => { + render(); + + expect(screen.getByRole("link", { name: /albumrechte verwalten/i }).getAttribute("href")).toBe( + "/admin/redaktionen/00000000-0000-4000-8000-000000000001/alben", + ); + expect(screen.queryByText(/folgt im nächsten schritt/i)).toBeNull(); +}); + +test("only an explicit Immich-unavailable error renders the unavailable album state", async () => { + const service = { + listAssignableAlbums: vi.fn().mockRejectedValue(new AlbumGrantError("IMMICH_UNAVAILABLE")), + }; + + await expect(loadAssignableAlbums(editorial.id, service)).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 service = { + listAssignableAlbums: vi.fn().mockRejectedValue(databaseFailure), + }; + + await expect(loadAssignableAlbums(editorial.id, service)).rejects.toBe(databaseFailure); +}); diff --git a/src/app/admin/redaktionen/[id]/alben/page.tsx b/src/app/admin/redaktionen/[id]/alben/page.tsx index 1083504..d1659d8 100644 --- a/src/app/admin/redaktionen/[id]/alben/page.tsx +++ b/src/app/admin/redaktionen/[id]/alben/page.tsx @@ -8,6 +8,7 @@ import { editorialAccounts } from "@/db/schema"; import { albumGrantService } from "@/modules/albums/grants"; import { grantAlbumAction, revokeAlbumAction } from "./actions"; +import { loadAssignableAlbums } from "./page-content"; export default async function EditorialAlbumsPage({ params, @@ -22,10 +23,7 @@ export default async function EditorialAlbumsPage({ notFound(); } - const albumResult = await albumGrantService - .listAssignableAlbums(editorial.id) - .then((albums) => ({ albums, unavailable: false })) - .catch(() => ({ albums: [], unavailable: true })); + const albumResult = await loadAssignableAlbums(editorial.id, albumGrantService); if (albumResult.unavailable) { return ( diff --git a/src/app/admin/redaktionen/[id]/page.tsx b/src/app/admin/redaktionen/[id]/page.tsx index dd2e7e0..5149293 100644 --- a/src/app/admin/redaktionen/[id]/page.tsx +++ b/src/app/admin/redaktionen/[id]/page.tsx @@ -3,6 +3,7 @@ import { notFound } from "next/navigation"; import { db } from "@/db/client"; import { albumGrants, editorialAccounts } from "@/db/schema"; +import { EditorialDetailContent } from "@/modules/editorials/admin-detail"; export default async function EditorialDetailPage({ params, @@ -33,42 +34,5 @@ export default async function EditorialDetailPage({ ) .limit(1); - return ( -
-

Redaktion

-

{editorial.name}

-
-
Ansprechperson
-
{editorial.contactName}
-
Anmelde-E-Mail
-
{editorial.loginEmail}
-
Status
-
{editorial.status}
-
E-Mail bestätigt
-
{editorial.emailVerifiedAt ? "Ja" : "Nein"}
-
Individueller Nettopreis
-
- {editorial.currentPriceCents === null - ? "Noch nicht festgelegt" - : formatCents(editorial.currentPriceCents)} -
-
- -
-

Freigabe

- -

- {grant - ? "Die Freigabe bleibt bis zur Verwaltungsoberfläche für Albumrechte deaktiviert." - : "Eine Freigabe ist erst möglich, wenn mindestens ein aktives Albumrecht zugewiesen wurde. Die Verwaltung der Albumrechte folgt im nächsten Schritt."} -

-
-
- ); -} - -function formatCents(cents: number): string { - return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(cents / 100); + return ; } diff --git a/src/modules/editorials/admin-detail.tsx b/src/modules/editorials/admin-detail.tsx new file mode 100644 index 0000000..b1da0f5 --- /dev/null +++ b/src/modules/editorials/admin-detail.tsx @@ -0,0 +1,56 @@ +import Link from "next/link"; + +export type EditorialDetail = { + id: string; + name: string; + contactName: string; + loginEmail: string; + status: string; + emailVerifiedAt: Date | null; + currentPriceCents: number | null; +}; + +export function EditorialDetailContent({ + editorial, + hasActiveGrant, +}: Readonly<{ editorial: EditorialDetail; hasActiveGrant: boolean }>) { + return ( +
+

Redaktion

+

{editorial.name}

+
+
Ansprechperson
+
{editorial.contactName}
+
Anmelde-E-Mail
+
{editorial.loginEmail}
+
Status
+
{editorial.status}
+
E-Mail bestätigt
+
{editorial.emailVerifiedAt ? "Ja" : "Nein"}
+
Individueller Nettopreis
+
+ {editorial.currentPriceCents === null + ? "Noch nicht festgelegt" + : formatCents(editorial.currentPriceCents)} +
+
+ +
+

Freigabe

+ +

+ {hasActiveGrant + ? "Mindestens ein Albumrecht ist zugewiesen. Die Freigabe bleibt bis zur weiteren Verwaltungsoberfläche deaktiviert." + : "Eine Freigabe ist erst möglich, wenn mindestens ein aktives Albumrecht zugewiesen wurde."} +

+ Albumrechte verwalten +
+
+ ); +} + +function formatCents(cents: number): string { + return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(cents / 100); +} From 66f05996530d540706635bfdbc5049e48fec7838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 22:22:31 +0200 Subject: [PATCH 13/29] feat: add branded editorial photo catalog --- public/brand/logo-black.png | Bin 0 -> 41154 bytes public/brand/logo-white.png | Bin 0 -> 7820 bytes .../assets/[assetId]/thumbnail/route.test.ts | 131 +++++++ .../api/assets/[assetId]/thumbnail/route.ts | 3 + .../[assetId]/thumbnail/thumbnail-handler.ts | 115 ++++++ src/app/globals.css | 345 +++++++++++++++++- src/app/redaktion/access.ts | 11 + src/app/redaktion/alben/[albumId]/loading.tsx | 8 + src/app/redaktion/alben/[albumId]/page.tsx | 104 ++++++ src/app/redaktion/alben/loading.tsx | 8 + src/app/redaktion/alben/page.tsx | 49 +++ src/app/redaktion/layout.tsx | 11 + src/app/redaktion/profil/page.tsx | 64 ++-- src/components/brand/logo.tsx | 19 + src/components/layout/portal-shell.tsx | 25 ++ src/modules/albums/catalog-content.test.tsx | 62 ++++ src/modules/albums/catalog-content.tsx | 136 +++++++ src/modules/albums/catalog.test.ts | 127 +++++++ src/modules/albums/catalog.ts | 115 ++++++ src/modules/immich/types.ts | 2 +- 20 files changed, 1299 insertions(+), 36 deletions(-) create mode 100644 public/brand/logo-black.png create mode 100644 public/brand/logo-white.png create mode 100644 src/app/api/assets/[assetId]/thumbnail/route.test.ts create mode 100644 src/app/api/assets/[assetId]/thumbnail/route.ts create mode 100644 src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts create mode 100644 src/app/redaktion/access.ts create mode 100644 src/app/redaktion/alben/[albumId]/loading.tsx create mode 100644 src/app/redaktion/alben/[albumId]/page.tsx create mode 100644 src/app/redaktion/alben/loading.tsx create mode 100644 src/app/redaktion/alben/page.tsx create mode 100644 src/app/redaktion/layout.tsx create mode 100644 src/components/brand/logo.tsx create mode 100644 src/components/layout/portal-shell.tsx create mode 100644 src/modules/albums/catalog-content.test.tsx create mode 100644 src/modules/albums/catalog-content.tsx create mode 100644 src/modules/albums/catalog.test.ts create mode 100644 src/modules/albums/catalog.ts diff --git a/public/brand/logo-black.png b/public/brand/logo-black.png new file mode 100644 index 0000000000000000000000000000000000000000..2b797ab2c085abb0420503c0757c560834318853 GIT binary patch literal 41154 zcmeFZcR1C5{6Bme8kCk68HG8QxKessD-pt+ZD-d67a9;wJwVxyH#jQz%i6)MK(*u8;fLTwJxZf0Pfq z?Ay+8q?`BYhQ*84uPAm=TgtHXn9i}|Zy5`En(fsy`_r6uM>SD4Gw})SIDU_-cr&e7 zaphY5#oKv!{!VlMP;Hbm8)&^~{%7{knl;sFt(U)DzxPq{ck9Jd90Bqe0)U1NBSGvyu6vo4_-^uYUp3Jr!Y#;KVd#ByPW(`wule2!|TBR z++_Lxxyk>tYjXG*jY9Fz+)LdX^g&5rXJT}$Mv&rM-*`|^G>?zc9i6$--$62k@}D{9 z*(j71LYsNc&GmUk1_pEU&sNMk>(tUXJtL;R4$AYgPY>(%1b8xgUCTSf5kOmY__P*P zV>i_yC~0mY`AIpV@gt!;rc% zD9B?*%4qWKp;snCu#L*VxS8k@&D#A`HqRON-hlblUT^ujy~G3*73YR^V>mqn?*H5$ zx&pQ$b0I{ga;`YmNoH=Y_)plUB}0oC*!l9JgTfUow0N6&RMl#(%INBA7*N@HvNh*c9b^++OrgwV-u)1H(wN7hB=&943D%EG4sbBA zPh_9@Al%u;;}oc6yp4*7b|fF7KH`m2n9`{|l6n8o5EF|dm+|x1WFEuqiP^DxVk}_0 z-o`nxaY4TnrsO88vzGX_8|Et)% zKb5XBUDcr%zZ}34h(u_5s7DG~gvS0g>!gfDMR7MBrxxgFcyrR>}wPKa|q9Qq2 z`6x?anh@1Jq%@XzcODl_i8{zP|JaEu3U^kxqf~GbcP{xZh!5>^b_ab66_uT2`?Sbk zURIv#8NbDY*cP7SY~;=uybx^()sEV1dVp!@CSSMxbLSuqt+^9@+izsyYOahf{`tHd zUEbaM9y3g+us9x2xfN^0BPEa+LcjZp6O}x(O0|t2ga^F1)oQ-8JPoo99?6JxqhB3m z-?W3qOWnY0DEgQoD(ZFKj-X{qZbv4o!^xUBx9p-Fq|OHhZ!fF;TB=w+GGbpjl9}KgyACQ0yutO7dr>UOzM;`JhZWNT2y{XNr;AW^H|N0=gRC4z{$H+h8!Aq{Z z66qe&-b)o$(&zp_K4Oey{@}TL=J_Aa(WOP@t0b;CWXI<6Xp68f#fSD@vq3kMrkXL> z{}?5T)YY-4k@OjQEl~*+Rn|zNajg&(bdZ;A15L1KA2r{#`Wo z%*Vv6GG4JzU8sr}Ow}>jia{Db&ArQR1xXEMtcgLkVWO`c*B)4-)H+=HinlmzCT2VR zc3#;60`u8pY(YC#nO}Xq=bC?{(!G(y*t7Jd@Oss8nd%w%;*&k|fu$ndc|SK%laC)H zx9kf_nQ83Eec-n!!DJcxabCYo?JRhka=%=uKvyIF`?fu|yp8hSDuoN0eIon6Q%{&C zL6uZles!y$gK*K*ZQg#o>vdmLYtG8i|DaGTU$>9ytyptjcOm{}`%UClr7Wp4jXl+O zN_4t2-W1#OZ?}k!O;%Y>?lzQQrohTW^QCcREN3Vldd5vl=JX`PTDv7jsb{uxaK#0| zhkV-#6!ib2@7vn*J$&=oS2klYJy}LNTnb}P1}Q#dCazkxD=v6G+~XOIYe<;UZHO@t zRx{4CaqnXWeCTC&N5M^ZGJTllAbZEW=9=d9KjPOqT?u^PnotgOjENPjlQr3m>-ghl zK6NzzyQSSGY7aLp_WQPswG2{uTK7dYHKgifaS>&rZ4*_Br(c|X>6fUe~IUFB6e--7?4UXa~kTzpmgAI2L@aD*yQkY8r6QD&r%4E6Je=VwmuluTbRBSaCfo|7c+#A(B%(tAESiyM1^vmK( zry%K&pZga+>g*CIjrD}Z3at_8zS^lz-LPOD_Lo|Nq;)*P4pU5)N$nX?n=@N;=pw-{ zQBlu%M?;7y&g^9@`0J!IC&S}xMYgUZRgfyh`w7!54e%bY-p%tVRO^-FS~9jpgTAr5 zcvJV_BR}tfQ=`1@I};x-Ow_yFp)0+%?X1KK4}7E?!n=EV*o9n^Q7cPL^_XF2ekC+e zrFo=QS-px_&V>BAE*EBwIHxU)1zFdXrZhBy{@qAFC^nsEqZs?rc|3lbE%koL{2}6q zlnI07)JTESy98fV4X>dVE8iqys7J}>44I{L?kF&srfWU^m4t+G>i7! z$AffpJIuwm-QxM5!d2FXWpk^~Q&+3dr|Y%&JfDRxZLJRjLmS6Yp0+a*B<4|Eznf8W z!*@yzZmkj{zAe9+l0%BZ$4O;NYM(DuiR0d!nPJ<+oBF@o0?a*d#zZ0rPgrzdR!7kgId9 zOV~zuA;wZBzHX)74q^^xUN87SHup>6!rJp~Q{*dM@^S}@V{a=TO<-Y#%j9&a1#ca1 znP9c7w1Qup)Ua4^=`ynfo(9difq|h#BHdqHH5Z2AqsiapvSZ@bR>$_yV9~aPIqpdb zi%nO#x#BE~WBW0F&&Dy!g-!B0Jsnb-JbkiGcJW4~R`JpPczWy=lvaous z1oi2^uOB@XTz{-~8NR+wr2Cr#m31LIQD#m(i_Hygf2ekt#c^=vxQ67vpngnklOLd@rJ9Xum*LjOiFDvelyLEwHUwFm_{VCkQ=(TmkJ5j)*Fm}bi zS$=;WEOWP{-SOVxm#f@f&KzBsX5O}SK}LJncih`^&0{j0s=wWto0x@HWmjOmMy(=7 zh(!q-+_>O;QCz2jjP|qdP*bZBR#kOKVI`w*jfwapxp8i(QtSMwTd~i;F|1R4w{@Q^>=SJq+ zc1m-ScTE!3cDd}uw3O~BNeJ?PSO}qfXR8#G1WCq>-)s7K(Cpu8Ugx7;Q@Lrs*sSKS zO^{amf|>Hg=G;0_zN+9)?x^sHG2K*5)TFvNFB?8nuZb&EA<>#b=@zP6q`a$7skM?S z!N>pc-(!A0=hY5$#BZ96)2pUT{yk>pE1tIV64$9d?#tY-#quneB_$}ECYV379FwI2qpeNLR--7WrrZqSqoL!aka8_RhI-txvN3Ro`KONaP5#Uws{ zgql0Wwt&xw=X+TD|me#Em-Ho(ak&| zVZpW%w+tCuR=KGzOq6Tw^t@!$qRU1y1aM6{wQI* zni?mmzg3oJ9z7i{J1Dp?`K3Y89|kY@962q}?bGv>01(QG^*-^H8$)>qgs9Uz+F}Ix zBK7RK$)g>}GSZcu@i9t#Jw0qw7OV4ixfDd{>M^>x{38>LcCkdHWw4CwQeN0H*Hksf zf>%SU-1bs;27A7fBKP7NI;$kWO-rG1&1r2htC9Q{2CfP!Pqqm?+jztK+ouI1^s4qQ zX~FMC=b5v~?Yy`)jkF0hMal~ArsXkKu&pC^Tl?`3Pl)auhp8-o(_Je`hWQG*`S{4* zip_~XI-!{n*693iR|V_7IZ`|s$Gka43TH^>JiL8{wjr9$)g60gT9 z*U8Roe_&qo=+1)kz2woFG!*7zxF~C9v9M2N7i3#Tz4N1T_t4j!Vsentjbds0zdn@Q z%9irzjrP4@%Z0>MCM=*RVJUIF!P{w>)YpGgY!`)}ae8M*iSJ*yONY4Z*Gc@oysMC( z%#T8qZ6?3(e6(O&LyykZEt=WBMf~>N;Nb1=Z5E8HO!yDaajJx!#H|o-hh@e73!c69 z;}ITSn0vN~VE5?19hoq!aVjOh|8uJU`CWEgh_F_a4qflGX$Di-^mG3vGWbJzd4_&Q z|BrznM;#6Ie~aYdWTdf|DywOE&1P9~(8A-?wj5Igw!9wVof@^gZ9Uxr$_A4xB)mcv zcp|UE8?`RqV=$0SxBPeW{o1&>M#jdGsHsY_Bb1q^QQ@(xbG$jUJn5B@mkf*6{TDBF zYOeJN({DI*)7vs=e^ZsL%ufH4#5TQN?a-Vwf4bbqBwRM&pJg)Mhgo~eZhye&cKn}Z z<}if|ZBb?@ehfZ^yjnuU*~DesBBTXg8HUulMJY!Xh_R*5gW{Ly`7H2fE6&DYl8Spajzs@6MC;91 z6K(IrDEWu~bFl+1Ua!m`)%rgV^Nwd)rYS3I_HUt_W&h@hEHHIz-+BLX_-!K4{q%os z_j~`sSm-ObLht`RDG_`o6i{I*aZTI%*An_ySZ-B1Qg$t^TeWcWMR)%X(f9u{Z+V?= zC65RDzGg|d4n_HMNF~+RYq3jT(UTA0(AL)v_ve&J(@Z!)>;4?`;nSxEAEwPL92`Pa z#x-knAMQJ+RdVH0$S&Oz=RO3h`!H@~VPi}F(^a`^|9+hi0d0+A$F6@5K!*BDysTsM ziN^ish5^zlooLGsBgGt2sCfjy1s=@S#KA$;nu(oGjr zIz<0>3n@FXb?a9BT-ykp6uqZgMa<5>^k#_XrUn(b45lTg6)1iR7t?%wW3~2+^Xheh z6iQVWLKq{9W7NHtqDxupH*B!ky6aX+`PTMUZqe`_V?Eb z_o`Z{Y}h+GDvOE&)#sR*S-e^Glhmh2Zzf%t{L|Btn=U=kv7{pGB2~g=;PE%N-ra`o zqYVNEIVm^RaHdWE{oVV@hbcbhyS!$+@@LQaY2&)R6s{d-T`;gKjyn+{k%)h8y{Wm5-8I|mGP!8qE)OFmm0smxkk6^Lx@wm`?$s5U!UT+H(FNs zv)BEtma&sqMp-IIB8u#r&f)V|3f4U)UaaD_+lI2b7>0j6vJ=?5SN+=ZHD8*utyC)b zUwm`zT)q2LUX9}_$_fQS(|f;(S9v7rI%JY<{Z+&G%CHaZK)Lec1L`W_qM!S7+tXkN zkNh?HRE&Ti{jGPv{!0o=(VDvVr>Pdr?rH?>6M|E%M}$AYTgBM zJNixSj~@N z-ruRpe2cyJ+S`}_>7?BTIS>37Q5KO9c$m_he=)&rv?uP7UCGIW6A}B^D~2^RHJxTh z8+)gE(;G|Nr@R^TM& z@Z*?Soz0%hW7h6dv;_JHi4U*k@@JQfCl7LIby(h2yZq$IldOkaGj1@mC%t$fTIb;X zE#vg-0|^`yp$+tf$RGxa#f!Z1=QfQ`*0eRx!Llyi?@P)_Qwc>iB~{hN`>N9XBz`hd z2**sJEdT3zDExp!w0^c_T=C`caQ_XC&V5Z!e|>snRU1oXQIMI!{)?GcZG(-K4HKU{ zpylkGGdDM0YBkjHGCpQ$c2Uux)!PoJ#mM<-oH*f6J0NS-lyO?Zed+~m3#H>cnftcx z*8GbFf2$-%Uoi9WzXTdcoh-$ zxSFXymBLPKPK~sm@9$%Laiw#k=>_)Ry~%LscDC(@#z9pobuYfFM5TWATC{|Z=8xM93^sP!u|v=#jBlkjmk2ZHVbv9 z6%N#5ek$@W=O?hQqSj4&&Y7D(@?Wn7`w~6#W<^(5*F*os6n~OW%c5FaPf7iG$2~Pt zr;1AkC%R(-MkYD~H2>Q@_SHNxvvDzHW)1P8Wq$0EI(9|FH)vZXHl&wKC4F-rH>}(1 zT~$2(Et%{-He~M+0(_z}6fq6FZ6$F-_l&7&L(!#+4T+la4N2OX`4_qnd()zi-%UFI zIr>9orKXNfXw?&`WHNHZ=jK9}^c=hPv~!iA3_tgpxwO0Iu3x{tKGRgbPTjlw`|F#d z)t+;jbnoD!bgUq|xvB}*OpWzhNtB-}oa#wN_>dQ~Zc-cVY0y+w_B|yOraO)Y)xEs7 zJo{YbChV0CKRw zNDkz^c3f%@jDY?w4>n)Wn^qY7{5Y{P}Jjd{#Nqb1q+cx=*CC{CRVtW`g5*n~POXeInA3IQ!1?t(dER zp8eB1n|52m9kz7+aXl0-qQ`q)dTrT>N8)xmXU;_LHf8uc&c;1a$jC82Q6WP%vu>}4 zCO+YC?N~&Q%El!{fvc9U;i!LMQ8&_Tm2T0PW+=CB=Aq|oud&_NM>f^4&o51xuyed+#UU?-+i z#hZAc>qEisCzoG1bjr<+m(FY7|4+sD+@w^1^wcxtv(plCYLhMPbMZDUIS&z`vt!2*_o+ct^1y*ynq%jd{ckqCOe zW+fas8d11gMNjWRTJe}Z+3xwN#!}^q$@d>Zc8$U#!u{82#j8f9y}!Tn5k^@~I z0^{EV`~S#}jpcFw`$?Sj;DuNk zUr=m9q(`_)v7lp5J-^g+U)Gfqi&zwiMbB6dwB}FE{H^vgyLIbU4R%uW!cT?c$Bu3J zbjAm+)AP{$$>(5x&7aPNerA(>S=GToL1#pdW?Y)?&lR)#c8Iv5GyO(A8%ce7u=gkoNi_7O(D3kZxYXsG&p~q-c@LlixfHOWJ^S?Q zWn}34=|lh7Vpl5WoT5MZr%TMKM+^Sc@NVM2Hx(6Dzdk-J4=qeTnI+fmF`XKidF?Cg zxU6#tg>f~p43B$ZVF|j%?hWsnY;z6j5>$1sTqz11Rw3yZOX=%3|6x~p#&q6WB$b5Q z8+L}n26E_8c6nu(aO2G6Uq9d3;R;Ry=j6(ry*KUF@9qqc*}rcLA0eCV<2GHMb$PH@ zcRBO6JxKa9BuIF1`m%{vy~|r8JrT8R)fSVp);lLFjpw3Cu$L=;vgfpSpu@G3h;>g~ zf2`EmNm=1WCMg&i9-cJb?%6)(@JQ4m8up+s6jnKw8ByMK!J__|Izf~Drlr#Zg^DUF z+3u$b9s8Rb-sNrBd7|ETtB9}fYKk*K4knqjx&*eZE+gHa1&oUF0y87{Bqa1>r!lZdjE4&`H%Nrk&;9 z>hkT<&hufWJ9&9&#`9BQftllj?df609$()zQB0PTW!}`BWAlhuNAH6;#gKhtMNV9< z9aooYC28>+RGcby%Z5Xl^*(TB-EaLMuwpq6jdOnDCJ7Q}ttms|^gD!0x}^1+mQ4J( zTV6HCytJz_OnhIb)eozeLdWlJ5*wTF3Z9Rz1itk1TSJ+nXR95MSa7M?Sedt1-(VX5T&SkLu7NY+jN@~!x?4SSvK8kw04torG*eba-b#sC8Q_U)%kFcE{k zn{q0@_RH{&9Xm*dFsN8{)_r0E>_E8sb~@+yQYg3}PLxI344$yd%5!8oDHoRhr=0ia!!9TIFWc5>;N^NOwFOzIg{6L1 zRrTe~?F}~US-|Z%{+n0z89D3$NJCz4k%(_YiX#)5J~0`#3SblfSOlZi^COdHaPDu8 zOGy!IDYrt30(h`y6V?+wUvoHBKl`~&QA$e6k>SUV*48QCJf>~9O*tiyRgN6-PL;p*bu#<3{;5;+%7fd~t~F1cZrYe3LBL)CRgp63aY|v$ z`@aD?v8;a;U~lJh{rdSbuSGe2xsEiA2pP|BIm60@qhAafo*rG!Z7MU?Wa{%Pa53fO z?Z^Rigt~8XdSo~ih3+;WV|_k-@%(t>Eh>_e8&I^L-+ax{HT*kwRuJd8t41h~D${X? z({noU%3BSc8nitM=Mhn7oCn)A5a|pmnB<&2naBHE5|AyhJyaA3^(aWvcRq1_HI|7| zAyrjoR!h9i@qWMQ60dZCSTEzPfYG!Sp(q_AjhUtZRc4(B=Qplf_q3-Wxn;jmMv_r+ z0W8m2lC`=jeO&@cjw66)76`>T0a5^gP6MqcQN`xC!)O?kS{G4<0wcPTFaEA#WMay) zDKgo(X;XYvge2~DTCiJPUA=t2&HskK&t9PnZ6Zd_`8EGdF%m(J-^RYanN!WPTdr%q zuxdQ9Mr!0adO9v*@%Lv`0u&gksyA>=a9YSE&1;x7N61@cP8Nsy`byY%p!nds$Ug-30@&W~;RL5X^7dXFUSM)C*uD2J>~j zMmBeikWtYyRP!z6yL8hY+n6#)O3H-6z<1Tldye*f)y!?Za5peB(tYeC!Qco^YHGx4 zuh@_EoiwP}b@F*^YA1t8p-kBCs)#J7LpvSvPq_``|7Kxlw>djQTzs?8sXcfa%ToI6 zn+$92Zro+o>-zHJKy_T3@vak^i5k3qTSdy>HQn7T{3Xw!lSEwxdZJ&xS=i`>Q_-_$ zeAsg{XHTL2Iemxd-tsg2Tehr<*AD`SkVTLJt2j443(LnX_l=0d1r-Qm=BGsy;b% z(%5}81P#Sh? zT^%XT{RuA6$qlQ?4Tlz0Utdlrj9%9(sWTd|xY3Uy)myes69gH= zt3(#W^E!RA`i%bjbn)XCc>DXHDdWQVx#^Gx56)X#>%>y*SxLy3&bTbz^U5PMC!}xg zRCrT&80cem2H?wKso`sGP$ZcPSy&vM+j8lVbz*nd{kj8UMXH~FEqU6iM^e?YqV#1cj zS+fl`Wt#r8@=yV7MRo#}Qc1E@Zn1W{Q8A(^7q{sew*9`I29#~kydWl7Hm2FM=t(;FW!R*cnE(D=Ta_Mo z7y)!7z;ov4x^?Sv0^EW6z-N3Iiy5c<&l5oY*sxjQzyITYlVa=NC21v|u{IwCDI&nj z`xYi{zmjfD+G(f0=41k$y!rZR)4Pu!>wyfd*$^HA54*fxE&dGTms~lA^p(8Yx;j7X z(Ry4p#CC{7Rc&_a$6eu>smbSsSNdD?>#%TvZIQ1PLj=A`7;!PJUfr-Oz39x()(OCP z+GwM3uKOuU9({uYlC+cI9H>TeoQh1&j{nX8^MHKRjT&tPs0v2$erII;)MzhxAl(s3 zEo4w(fWijm8-o654Ms76TmI?;71N5Ry0cD{LyIo&Xru7+Z z3SsHs4!{=%xwhEPj~~K>)3FlRllht7GGd-{R}eY)PLX(|_vVe6$u)0PVB zFDVcEO_ya!yHB0(D7%V)53l$0Ws0(=Bhx?-p}f4jUnPE_6bKFvx9ojzl}}7e8|=(; zr;n(I-d0q!NSI|Xtz7w8W`0t2BfrL*vCNAXFWPW!IQ;!6+0Y%^w{K_NclK7Q>93zZ zn@X%D*CHOvAynr0A4K)-bA3po66Lpco#bGVDXOpu1{pE54Aek|S#$oSB}9HfrDnq^ zu4dg{VpuIbozmagT)b2E^gb|qh7NBxg5L7#qR)(vpPz~f74R2TQ4nul>2`5(U2b{* z7w)YXX_d@)%#P!Cy0aUNL;(8*<;mcV0MWpda0#kOQqAWC^g0qA^mnAE?Q|Y$dhyDZ z*%V|1H&6>;H7QEN_t9CoYk2XKm|Qu#gd<-?+U!SIqGO|>%hs(e^^J#5U&N1z7IpDt zWasE3OCg0fE&h=;=XiahCM%r!c~+JUXN!f~r@%Le0@ZK{ z;TG$=3&3f1q>j+Ws4zN6N%Y*RkOx$WK3q<0pY!Q4!p)NEeHCSBD~VAu_JwV3-A`|# z<_asFISw=;w!eh`;;)aNL7o9v!Sg@#JF~HsW(XitBjVEc&zG2ZB#N2W?*gsD96=j1 zZ4%tGzoc!Gpk5S*l-m|Il3_`upE=A_2>OzSSR#roxk87Ls)!7u^_r?%*<`SNh6Rr5 zfZmy_oF9sq`xiLU&Ws37Bs_6bL=Y}77w!Xge&R7@5yG!o4#H=MPWQWn2U(~z5&`|)<|cou$g8)PxHo{(uiHDsjc`Gj9RZElTQok3nhA+aGavh% zd-H!k5n(?XG=e0}fAHW*V~@$WKY#v!3eLckz+lr+>Bom6Diwh|gnVFJ`JFf9etpVG zO}paJP;irKCNrXoC}qoT-@fgy*CRyTdEzl5-Ynt6Nz!n9T$uwljqsdHmNRR)xfRe3 z1pNuidDNQ7SvnYMV5<(qr2-azF+C34Cxx)0va%?9Cw%MAZ3Mwo5J@Kz6BFY*XVNfD z%b)K8lZ;DCN@o5j)j4wwRHghg5(XM#oz0Kq>8l ze`>)xM?shL0>|%R|Gkq0RuIdHhzbXPt-Bg|`FDg1%f^l8B$mw`hC*y^vf7gr{b8TF zhFz7-GZbsCaCt@SxBF(@;`@!%fm8hU~1NDnsGygmB_}R)0|20WC%MvPCReCa(wngUq^y@)MbW9M>6VN1j z=zrns;{J=P4qPV-;-!YlmVmFwaBuzi zQJI7aLRa>iZa#)WZJ?l6$f>8EivEGl=jh|J`%Yl-QHZAo2eS~478^BGc|eC&8+RAf zlP!(Sz9c$oJ`>HKXYkW_(^ENzXSOZDF$0$eQIm%$lIk_HJMS^M{jYA)yCw`;3jx}3 zp!Fbk=VmPhgZZqEVKx}TMVi_e0lU0Gkf*F;Z^WrSW$@%jGf>=Z-$ z&Fi3yq_D6miBKSFJcj4RLF1A~g2uhGSvc+8yLXXhq16$R34ecA@8ae@N_bAJZnkL! z^M>Kwf7|Eh8XdZ}h5aV<9N6}3&v_3Jh8->>wo(o@!ib)Z3UY z&i;B6p|yb$K=>DF6*yWH&yKb9e2%#Zj~Xg$dW%4IjdZ#YXDeWiE9ahg9~~cPb3$|_ zW>iW#yk4?TpFVY?#f8@fCI3+!jZciFaKWXeigTfjpJv7kRbQ zOXLhf<$)&G3==X`23y~a9RmpNea7DM{ZUhso*#!)GeRlReWPa)b@qJ_0O>y7Hd#cm zXr!B65)vS(^{i3o_Oun|!e@te(Z3q)NUJ5-Rl>2`L_+bYOX6cZ0biZC+S308?7~M= zCdxKCkhm5sWT=nU*734!rJH=oE`PYRT`gH>ck$$}N5}wW!X$OrKLD3viT(?*d>Wrm z)$ZKZXk=2~3q}g9NHQsUi#qt|PbRz*r^m$8xv|{RhiI%E8h*2ZRnj@-4vH!XM(g#U z{t44Z?yO33%K_ZP zqj{B#oEYD^Gy=uvZsU?u;@@0j@FDHMo}Y8mgSz0vu^^-?!nGF0BnPNj>(ppy4w8Qh zW)Ui6n1n?4z<=@U=;&xsvyWTAJd!gxhohe9WkyR+{@g%N#`f(qE5>yKcN`!2ev{Mk z)%BGE;MZvf>~DcppP_DRo zG-S6yXxsqBmmt)&QLkRT5(VP10geHm9!dIx$hf2zO*RIVq)Nrr*Q5(jfZapvRZ}2_ zzrudwE}eRmrD^ECK2iDU@hkq3Z7tC5D5`)zDF=lfRd&^0td^?yz(SFuSCH%BbM>** z`!DRj9|0b!blhf2auN7BD=Yz8B~NGvRvZS<_=1iNdCm&@b9M-YDfKsJ*8!nqpLxsJ z=2)i^&;9im=|{o2L@jE0{7+n~CXN9wB$n+1AwPsiKQH9hqeZ0hV2>>6yfFzEMQOw- zKJ-7A4<{%_N2eL^mC#eXJ3-iA=UT_gnxt!V$%lLOqNY28I3=<)A2uL0H_<6!-{FOr z$1#-E1JGE|=`SgYRw2fuwC2!|SCUSurNkz0HT*t0=sDj)MzDg6;K&XE0Y$0HWA)cp zZXnGXcNky+2(Kk)Zqy)^`b!SfkhV6vl$(}mg}-*LZ5zwhtrilj-mNuHk2VxIS;2N# z*8gu^{=VQxk4Q)Bf&aSTSFc}pITvD;=IX)HW}AItCA}bH&)IC9v{M!mK|G1LCy6#l zDT$!*_yq($IPy@uF6KknvKYgo%p9?_Od?%Sl}Gz6upgvLxvF*16B>_lEnYBfvrkUD5|SEAe{ z0T{3U&m0HkDnp^z_3Iaq4ktazUqHo6K#gxC3$f0nlob--&Pe?R!&N6IDk)`d;6K!W zO~LcVz!l!3n*}VWsHCJRCwBuStBJuT6fQsB-ra@3yP8#04Kl130Bcaxs6y$WsH&=q z6|%WR;o1@+cv2(Vsu9>ob0% z6Qn%&jnw2c;jhaw9z39&!v(&B5Z8b zXmmLhj~jtHtbgIK&UcAqGOH5p2cX+XhrqniHKCO=bk{G>K~Pq(sabAUwL3sRQx3yKYn`Qf8ocugv3{ z%oM&9`am-vAR@H^8a1P|DP(cIPz#JqnmvRRyywi!^h3!ilNJD1S;PT{BY>6~&d$zP z(?7j?R|9+8z55NDxNSX}IK>6du*l|IyU6OSAxDAlL4?%cDuWAx{yh#Rgs;Zw;lqan-=pL*r}>V4j*%Y) zO}jboJn4x;=s4Qrhcj*7I06j&vLESIMaNUvAP7>p z|M~geZLoM8fZ|t}poN76k!YbEb&zlaX!aAx4CLxDC4ycuSgZ92hx9aA!5g9T`|Fejd%29!=cUs99d-_JZ|r;;?{?hp&zSQ4zq|h=(}gnV=U`z#Y`1&**o>mjN``Y66C2iWNqVBc7Xm z3Xg+YgdbeLw^QOuhdfe{nYQE~KXd($e3Otz6K&M#K2k zI<{LRaq?|NZ|j1ioXkC9nT>0 zDxEg#j64ZgCOtoM@vi19v@7H4I4aoWnaXsa;}FiGrI0r=|r?3-w}slllh*meTHiAD>9IWHLwz3M!M@DXUs~S8hxH z-&rD&h76``Z}lVHM2+J_p^N6dZX-ICU-e{55qOGA=1>7XFODi~vqe}>M!%VOIQB37 z=g*&ui?@5yRHEUhvpp&yq>qDO{Aj;TEkbKHglBN)5>X(lh?y_kQ83?J7UcrjWyA?JS6A1o=`s+Mo|CjnNJyA= zw6V2K<2`sKXVG!I{ZUAN>n0 zVFPf}2vXJ~|HU(D_wKDl6Dax8-(N;j%)W@?MOz53N0SWIRdsb7=$zKYc(@549X$>1=?{@1~+sHoo$FqfGBJP zp|4!A$U_qr;@F?vD1bu!`Q6d2t&pTAhtBfh|CqP=nSSx&+5pW4){zW} z^zuN?i^zxkC6WQ{gcIyi;MS(lL2*R>o;r6h)&k+b5sQj`!cZYl;xntX{PJY^?H&P@ zT^g7mA)G1)R+_IwgI8PEFb+>NKn8%W(=*L=_y?ho=-Pg;&E-12FE8OS8#y`CAz(jc zS27tNbpQVD%dx97SljcxxClEBIA}Bf?sDMIYRd;3Hg1d~Jw~hr*;~P{EE_V=tXZ)bY6sQ>_EB@QgPvCJ?rk^XJ1M;}7Bt-y)SvUS%y_3=2WKNHl_uLDp=l=(CWflcEWw%tru;3|VJ&>%NM z<4GzG2~g7VznCcC3Q{fjZP|N-2+IU?)2t1Bc0PD&+ZSbUE5;c)BTj_oUR3|?&2{34Mq#f364KBnv{AyS~m=H}vDbIcy~;G$>v zfJkOUaelR_5GAgB zTAl|5izW7U(d>8=sQb~u_Q>C#haVxRr$B%j5z+P?B6F@Xt+Z1o(aO)WEgsdWQ@5@| z`wcn*jg10Yd)VKaYbR-amKtx}u(sN6hby6l(7e6l=Qld72c*^mTK^6U|Bvy^4o*@+ z#RUlb?COHj){vkF_;H3!M-q-{kS!30@GHs+Glu7iX#AR zJcu`idK=?pdWGR84PJ|uG>I(nFY{lqX9o|@_0aQAR3#(<=H$D8k>Z;ONZ-PRWG7#3`0J ztrFs7%T}}U0mlNrkW>YPb@u&7mn^eSj-w5_RzNU>k*pqPIy)y===mQSJw*Smuit#m zt|}Cm1~3IHP6eEXxJ?t}NnG*@q^Lx|0TpgJUo{+HIycV1c*mQW8;ccu|Ne&h$}Hgu z^bD9rexqlUvi<0diP@%TlvwBC-Vzsn-Xgfmu3h@lp(l}wc@>@NXiE?&5aULHXGn00 zCr*s@{xyIlk>ga5F(jd}uZt>exJ7Sn6Y343BqPNLaGkjXGvibA^qQX+%?82MNzF?L z?5?cnp>#wrz2|G*;p36W`5Ad+CJ1{QP;W!&o>){=WIU4(PSy$nH*z=)kXtMI*h(T& zAjfRbk^WI<+k%1w35SGQQRp%_Wum<$J?Dy`ZB530Y?bmXMCYGODRX$uwgXX{ja&)G zSllN*E?m59CGLu;LBx)vfE_|!LsWirxBd$?fCZA|Dn*Dm zi>Ru{AV4PRrp(U%02QnX$PF3N3AxG4zK?ymj{>~C;rThG<8pG%`^{iN4TUatDi8M^ zhj8YF&8dlaumuFCs21k@?&_jJ^FX(2j1nhlI#tv2U5BHI)({#68l*7fAmJvVQ_lw4 z3VVrC2?4P25`iWN?QHzrr16MeW-JVx&F~BdN*NTwtZeg8vy*CHRc1QJwk-)|Q#bl9 zld4O_@g_mB>60 z;)2AHa+AYN0s8yU_RCd|4^E-^oqeH8ksN_TJyDv{i;65bBxJNsc?=`W#426#I`&z?F9PM}pIk_r{HGoQjh3PAihUyS9#XM$Q%{HEX1lvp^0#N_0m=$cF zP&4|^&)!ZoeJzRI`h+5zEXKKgU@=hjKOvaGrmdi%SCEwV<$i1=oT1gwQ!+iE3DTjs zKo__Twi^wr>p_WYWd5fdH4{N+1WbN$i1?3(=S|SoLBdV76=;)=84?4T9{Nxp6J{;Z zLTQMRUqjk5ERI+*`5Huw;6`Bq6s-_@puI9Han0i(LceW(*CvFmhFV?+BG*hgnKgow zdZ?VWL)*rOzP~0F-mj{NWYjSy&<4`1ej?S7Y9L-|whD(nVu*ATwGvbJ@6Wr?;Wn_% zKMvPvfZ3>2$Zr3P1d{$_=a}muiHpB{u~oksZrDM0tOIWy#euM19J*pC;TR(^3FQhA z!l$Q|!mQ??UFeAmGpdD3SnxgRs=NPrzmtSGh(c(iH;lwA>(y|Q##$Ke@W^!k>{&t@ zp(KMuQw%*rqD@Jj&O@!l%bN%~HO2PY-o78q2MBG9U*izX^m3M5K(&L_Pk_pp&f~;& z&3KY?lccxJ;W^__jGP}@tZ+XTqe#LUhqhG*BLxx+qX~CWk(b?WpZLHv>-!gM&Is&_ z^c9W#*nvS|0g3468yT*-oZn^(cmCLWBp*HZ;<09{P>=SoKe~BnO{oy!NTbMOSX!pd z{bNl#(JwJA_x%h2nS$ElvU}uuUPaeg_w}T!WuJl2+WqA6KxSY5U!=Gm0M|y-0I7H! z&egwAU76|JuTL-wosmj6wtFwt`Qrx>`bR!F?&wYGR9c-p30O2fzNK#C1F10PO%oCU z6)^yjRv2B64= z^n&nJKhDkzqsPa2W#}qW+T2hzc&u(59ca!n5BOCbnGS7hce>|nGC90gdhXgu7=kv+ zSx7{S3%+$-;Q#Nx@}S>87uhWxOV;PQ1--&?LPqn-ClS_|U|5{iVCsAns1hk{sCsDl zI!eBue-EY*f(VE@_})Deb%~3_D8bI$e|UUC1+fq6j^ctb9Q%^lI6@Esq=!ar65pBMepqKaNa&97et~*x!VnMx!?a6GXa9I2e8e zU5@7G=k5~O4%Y5G%!AMf2;INyMBcAB)RJr0INVuLTq6D7e>YaonxIi`9|b-gdH4i+ zD?>DC!tIfsK1#Fl3EL5wFyJCc^Pe5Ny`J=9R7E;K7HS|giGl5nkalk_xW{lWFz_kD zqFZsxFfaHr`bj>VXR5k$BM!uU407G&>>WD+O!1{Tn!?-G*49X~&p0=t-7yVr6m{(h zvS^JW!$ZPhm2nV5y1M_lQPDYU8R_j^fJhfAcrqGBq6QLJM#{qh3g@`ExPv{vIr<1a z80q1U^FMpJ%xi#Rx&JfmU<=J#!c6LJA;W?R#{dKgvew}^EX8dc3nu71g7Opuu2+nl zIZ=tC-N1Tz(=5WQe*T3x9K9c?d+v@t(texfXP_F$L5Drt8M81f0#lJ~LUny`R9qWe z`=~G@IoRbc!I}Z1lN~;28iaWcf7wZG5|yNOa7b=fB^0F}srza$6XpUa3cu#NdBA^{%++X>Te z%FBC_lGFB$9ev;LYz1nL&XxxTey=Nr@WTmGj?3;P!b7D*;rYSQ9rHw|1m1=}U9DHT|*WW@y zl^}l?S2cjINcX>TZQihXvb9CrgaChFpc^5F_xvX+TAw_4DeN(h=AF7n8mEjOb3M#&>20;XMgGV8Z@kru}Q~Qt_ zoN(;kB&_M>R)QBGD0%z#?Iow#G{eFXd}-#FCt_U$FkQD(4)`VTj+fn~W=N7Elr_>$ zQGqms58%m&z=Mxz4~etV{Y)287?GyWgLfQ4VY@m4o-n`{AKzHbHua)N3RmOMQY~0U zLFF!EcpH(Oc{X4Fz(zWtKtH6zb^3XwOQJ$Laxn?Zs+@O&=Z9PEU#})fY2&b(!rM1* zy1_V&_4qvj>?4>KOE~{&{t4;~IJ}$T4}#a3*(EYGpD(#|hyyv~U4psmF7VPwElIFZ z6btx6IYYm%7;3vfzXDpm>eaEbu9&DL%gpZ<3!nX!pK*d%J3-|buu*mN z=3P3<$lqcmy_VoG|5JVtg~&BAqdX(lc#2@6CySS)uHahTI~ zQw~sE>dCC~USD8S(qV0EeC-J?E*i4Ti4k`IFf*cxBbggv&-<%m(+*KlEzDr3APP8~ zUra0{W|AJ>?m;7z1m;k>&6L0&oasJ(yYC|M0Vo3(>0;A}d-tM1!|OlzAW7Dl&93Mv zJap2L6Oo9JjR;Pgc$vV!R_ra@yS(|c7>R#iZ;Pd;uK>w-y6H?JrN6+r)${>jD%Mp8 zl}}L#$J~9CULe>f58c%RLspE_h;$tvh*vZ+Pr&8*UsT$EJ>4=7!ZZ!NGX(=TELv1h2S>d;HO zB0ca?msEa;(g+^M*} zbm?4JaOvsO7>{DjH>lIMI5r29CCv=YCdzkA@LTV6Z1tn5$2e$(e5`#|D z26>R_R0^=N7L6Yw8eY*9@m^RSVy6)tYBxlN7@g#K3}@L`5SeSwjJU)Ft^pkec*()3 z*1s|+%eG>bl(1_?yFFK}T&a#sqAK$s^~J^CC)|hMZbnyTgvMZt0=^z)=x(E;rr#o+ zOH@ESI=0y4(x7}O4|^kb?AX$end*q6mSDXar#IsiNZ<1Si$jjx_e$obtVpm=_Ph)$ z)Il|jL(uh$jhW`5qQEJZEYj`4CsogSjA)UENh}@bW)W0k4NYM#4Imgg{svjzhu0DLFA^~Xpao@(Hvtw%^t5?y zo{b1V{(=cPCa)^|j`Vm?ul!%_eP>iuXV*3;R;)2fj1-jtG*XNpN*k~{B4DRFSSX?* zQWO}vQPF5X2Px8x!l)>d0E#HZ*l-jCsnS)3CP**R-)oO~*81M{y=#5HzJKqpL>T6r zbKm>k<=WT2&Ji4OZQqec=cdKve?1Kr$Q!rI{xC1sQ!Pa=TU$-l1>hwF~!80x8Il>=)D=#E<_3BYziQoStDb@DB#_`8Q~U4Yv#W>lI*AgT;IR zyb>h?&#~-D0L(C>^1b%LwA(mN?J+@54b^dIqme~Z$q!(pb1;_7T+=ZUiKkDt)JGMv z16-lYA-oFxC4b%Y97q5=`$ckAfKa#S*sVy z(R#xhA3mmL07~NuZVrl^rz7fTc@7 z;U&@b!?$M?r#YYxhsMUTx-;t9-ZE8WH73+S{vP*SLDJAdFkGDJf9ll&%ndU_JCm3XTBS4;q!uooU^9Q@?q%a`|H z%2K&TMY_x)+dG346krE6ZrAGO%gEeEP#1v*$nn}DcI$n#0w7ofA%I(`h(Yh(iY`IW zr`Eh*yR`;gBe0~fz}B4cQGP-2(lp1aeG@0o*a2`-Wn16@M2sn-obf(}qEIc6P!m77 z09sXudzrO+t5C9H@aSmuqhHnIW>L5&Ml{A&D4$oZxL74e{T}#bJ&Yf58n4?EU#0l! z#~p+gqT!QBc zV|d;^gteO1T;`liWRbT}(Hns$Q;ZP;BlI)DFOnu_(R5hv%%_?HHWSQ!@VLxe4YTP960ibSD@} zAz`fHNq6QTp0=RHSA>bNWE8cn$R45kl86q`Oc`y_96VTh2eoHOA3_R1xfhY`cfI?x zmJTc3FgO5l?K=@n{n>e5RSQpWLN0{gz>|wolN*Ks$L9ZNzen zDr$Ik+o1EE>vqo?n0Yx3JP>XsQiKs{CeeAPVL}2@j5h?xQ#rWStN)&fdJdXrh}F)* zS&iWO~4_I#0zUC)`ijxIEm51EjJZ##SJI)yG9bB#{GCI;{z}le-Wc{-9 z&$C3=M94?_`?L91qAt~-Y_h=il}9a^d>4@9q?atUNvA$Nn}oPT)OgBDvq$?ab5ER@ zYDI=EEIR&MdhRoTu`E<%Q$IA_!5Ky77Z2;h*#^pna4(bdV)O^ZImj4o#npGlF@3xr zm(#)NqGe@gT`$1Mh+(-ZwKWMBUcPEok#p3X&0tm_xUFpxm!KUn}UiHI=&5qE)xi;GSygHq3va;N~F`G$U9PVdLD8pl*rl zo$!4P0KI9$qXJ)OFYP0`EpW95xQk0674pET(6`%#m}Oc{jS=LIOs9wTJY4S!f*xs0 z!HG2V`A`i?p`APe@Uk)DtbYceQl**7@l%#-?NjW)Q-G2(H9`Ys6;9(o_Rl zO=kNFQ&Us-W_mcIfaTW}9ziq$*Nhq{mfUImZ}am<9Ts*WnSf8$M6o*3n}pb!v#bqJ z8_E8Gezqwm=Jn2GD=iw5L}Q~I8>f;pE?1G|l};0!=!v~4b50n^xrFquikUnO5rqS> zrPT+YNf1kuXA(CnBJ`9$#)zbC5&9@Q#MnBjeoXx$nOeY0F+m21u3u|kA5aHWpiWQo z;tdDYjljHtc3KK`!1*HQhM9{ROw3Su<6S$m4#u!54KgYGg0hE2D9NP`#FF^K7zUpHVg9*g)p%LV zZ_+R|6i94qIRKr&i{Y!wo8&Xw7GO{nCE8%xB2OfLMEfPGYee2S9!3L#OVr=z<=0X~ z0$s!bBu{MR^~0L>-J4*wWJ?#$$j+Vn=~2U1LW01(Gf}TY4s%MlT#RlWHFqCCeUVn9 z^fwkv0f5qIQcYSoKtepyFN%trss9U!BZ#-P_OT}EOF?=Qw7esjG<&EzeELZZ)A7vD z%GCG+&6&h_hHCU(N!kG198i0=26S||WDphSD0p2oHKn#wT%Mk}4Fjr8OQAj`k5X^> z$LSovSrjJwx_w#H0zxTtO#QMRVe8;XU;PlJF(q%O*%@IWLSO8MHWMNTE~9iNKJz0J%%m;}$K z?%1=EN7BTU1l5OhBgfn00M=fn4ghr{R&Rzn7co|d+tyUPOYF(~?61<|Q*=-w(WKAr zJG4wFPL3b^WgHA6lx6`y#XgljY1lQ^-H#e!a$Ea7>c4?ta3ABRFL=XNmG6hCx6}3c zrH}SPv3L6rH4zFFZx={{CY-2{duZ^ncU{S%{WvG=V434imC{g5CF0~f6Wtq_KQ3vK zPr)|JmN=czGRKx93mFXbv%{TI#){{nzBIK|Rib83*oQQ0Rw`A#kx3Fq`c&LQA$Y6 zmrWN(0D0a4rI5%G-kclI`y-{-NhPz|b8Kkn>WYZUKPl}!)LOWID?sOm?MW<-vb`W4zLYN zFiTeBJNy-%@mj6lxDQdhm@(^j?g-B|Nd_~#bq$+9VobYDfBYLz1v3&rGjU1=Ty15# z|5WJJH6O&BC=;mw5Tkkg!^dJhS{y2nk*cOI3mty}tP!$V0}ik1(7*uvYXP%(Dwn_w z4NXAIK8D`1u6|G*v5oLp$vf^{xsBZf1YBR78;K=AV&yeDdIR+Wv*5GT9lP_E&3ROrCJ#slx#PZD^FCb9Pb=7`XB6y`vqZzEYH_A@)U;Sb)OKfnQ?cUEl=}|T3WCS&dp#TM2r?ztWKnBJLNQ9Aa zyC78#ki|mG9yAy05qu5YVsdYHe;g?tQ4t~(+92Q*xPh35t~cS+#lIf^1XeUW1wvMC zYpy=ZM{n)Yc(4V22f+$ONLKcib=cA2Jsbou$&vGC(FVksqGv!InDo6M_#4r&zqq1- zMn4`WlPF3~z*XRicxV#pY~4LoH70#l6O}J^;P!(qQrGH*iO7v;C>9}_N{@1;K04d6 z&3_`rd1w&!wa5Z$0A=boH+Wz3Yi~Fx)XNFKW1r7LFAI~S^0$3EldUp#;m8U-mXBaA z;sVf$yKrXLgAPUEKP_lFbaUnj5Fjvk4b0YUPyXnfawx{3T0 zNd}`N2g*!*E~I%!s~+AzClDLQG|eoc{Nt9NHw~A70_ZnfRYz<@$zA422tlO8>N6H_ z9Y7OOm?J1n*6l6q>Fy>iTnD%t5Wfym;6uK#zHhrN+>6`G`KBJDzuJSni^2sDhPbmA zf9F_L{152TC^$%+7zqvN_$n$!VBKP90x=$?+uvYH??JSiFu$G14am|a{qZFPMGyRg z_U-I}`f|b+P$Uk!1tT5#qUJYvY12iqaq@3&ROeeg+JO`Z9k_6|kUEM)mEY9j4YJNA z$_XB$C!Q5M_lXV87PiCUsne_hODbZ}g?2Vp^SyzfjZx~0Ek8YU0aX+LEnwyLy{sHS zQdE=_NBvCxgn;YpF_--oOWp%3jSGs=g~nHaec^05W?SF#rG(lDw`QK13g{78LKZvG z7tOXeK4M#e4kCr~;Vj4^(kc2gU|u{sJoBV(_ImL^lI$z6KV&$lc6_`$Jf|6)Jvs;~ zTN|Tbz%+$aM3oLUaL|p9Cg4$sQC*AAB(jp0pEgrR3}^?qHz2Ru+t`qVG+QbK7&017JK+ci?#^K+qrF5O zn4ICvfrhOBU6GYa>gtR@uJj02mK|J$T#?FL{Bh5aY&iANFxk+W^%KY)efZQjw=nIt z5cKVc7>qHa9!}{7I5wKqLPKPzuWseX6}9UpNFN7AMK}Wuh1~{SSJaZDV@CH!92^z% zl#PHsQkJ#ICBgktvjR!u9b$Tn9LR$_6xb3CJ$9Uc1HejYLnkcU9Ww(^nlO(r&Gg0=M=>X+dW zvuY#S0Vxst#pKEGb2gCsaw3q-mEY_!>huU%8g)%bbNObSWPm=Ec*^qf8>p57A-n_= zc!up2cpe2s#iPK%sU8Fi=q5F5Tp*|iya@H_7owoUwGxo8=3HO<5!zPg!4xbS6-rRC13p0HVoFk<44O?s?} zTf*_#hr-Nciy2YGNrD!f%Rj-bA!B9NwQ?_9nEJq}jt#725ru%jo-B@pHx=lM-fyo*{Vp7&dCHajz@gFk9~yd@n4`VB4a3H#{Ei=s>P_NDZ3z&kiF@?9p&T+3 zl{Fp$WqTUhNtj&wd6;^$Xl7YM{GRP2jo?EQ@8xeJaTZ(q)XVfusr3feNzz8h0J3Vm zRRNtKoh~DX^e;JlK&uLINd$e_pC>_5AQD4q+VNoVlTsrgXM?smXHn$PPzzILwFmk? zabZ1P&+EH7&-(`xM{@b@#AX;6yY43H%P+;eVB})xf|)@ML&6`|I|@lGZBFlP+kqKq z?xV@m2Z}wVCuMMe_rYq}4QztlA#DZxyvDmHUvwr(i4g@bHFQl1c8!G*2LdLi>ek`S z$M6a$SetK{ul668LRpW50V7;xNv%jHNKH15U1DJijEL!@hGgO~MT62j2Ure-4BGpQ z8}v=FpcH60r0(m{`Ef$Q+Hf=`F`61fY)x`>)Nb-Tl}9!N&?SzUgHpp3<4XZ+B8IJD zz@@~L!78C~@(<5z)C&1)9|_Uvae6z4WbvxzT217#K=%S&sxfk&QJ3rdJ6mtE|gwP_rGF@i)1;r#y=t9=Q zltdYPn19X+pa4J*%}MMBxrtb)b+Y!$FF*l@7=-ApviGAjEP3c?NqWnZn5QvxW=ZlYF>aeV@2LAcX*Y;Tm#2neqv0y~plj4egscUnRi2}t9|QEKE@FV>P{Pdzq=SuZGw*MvJ}53VpZZT^sbDTr zwhkN;()1u!Era)>gn&k|0QkHO=FmhqGE?MjpL?>1UI2F}^343oN4IE(0ou0IS_D(k z0WL*^zkzU01QE1%cbq=mZ*s1xzU#H9*SL+UEsRGXrwj!W2wyvt=I4J+f8rAyN1~+i zhCOaVLWeL7&}uKgyCsF0BdopThcoS69-=lJQgl)JJkWv<0Wr`qiqS58eA0gs&0$dW z#r7SvB`gLIhp!AI!VVD}Yn{970zlv9P*e7M;HE}fetm-~47m`Ia1gF;qTWTrz@DfJ z2!=kD((Uj%eV&4pP!g;Gdz>Z<*!!)Kl9Lo7_~UGuR1b%qd_1`4>M^L&DM674t>=c}g0q2vQ9&O==p_~iu&~Ima;G$)EiCwyLUff# zN9EGI3ANy$h}!|4`8_D8jJy!yWMt6cOGpuk>0E|DI=#lVDaRfJG%P?!az^9NZ{xZG zU5W0hsCXA|I$*0^guv}zU@vyuK9lV`${~Jw>lxLCxUFC_&fo`GRD*I&5?pZnd+(XO zZ=GT64Ez(#l6-DOk0B*mXyL5@z=~j*)|S0%?1y73;tX@FfRhzLqv;0v=#|We#cL0) z{zDB-K}Dm;TQG{d;BT_)nn*PYuuvZwUX~HFI%n$a6%$v)nvyp`1(5(C`+88lI~`(T zgyWVxP9;12MGbhsr3VE;B`1^N=m;#KH2C{mC3VH%4^@mCqmXZ*$8(CAe+Zed8CW!I zYkk0PL=oO>x9dJg-82Eao|xdh*=XTnFNvWhGtgImAMuZ-uY*2Z63?yz<}6}KY3AIs zcyO1roZ{pfL~6_vb^v`N;-(&ik5Pkq7QXw%2{J_m`s10KgJtvIYvde+hd~-VT}|^h zGuVy@zcpn^L-7V@_>?dw4r_E2hRU|K28EA$cCER($e{Z$qC_3a>CF`{NPi5HRZd>6 z-e79eXxj0*uIi)otR&2>;iS3P8diux@oTXjZ0asLDi+tKcFJIkYX>G%$jnIa60?F5 zrEM-KCWwK*Mb>j8N;_AZjFZ3PhOKZvGn>x@)HR|Jl;i7z08-fM)draj1l-fYoEwNs z!{Ry>K(GHXlE{dVae2V0Vii3`qsm6h%(GcW{C-ygO2kckt-D5YVic0ww*1T;Z}cG|?DnUhDD=wKjLk~}`MMhT!c zF?ToJ5vzmL+~U7bfK#SGuYi~^bX|x^$5v8FBb{;--78mkFNEb&>xAwf_mf!vbUgyI zC`~Kxz?cE-E_LPAJ_OH1#4?VL53m|S@Cm>42{v4D`agZy*5MBh;ImRoz7I{=5B(iu zzB?p{-W|sJFDx)DBh2$k=<-(6L)3xU? z@XQ3_*Py82jE@c=b{*6%vV9B24`Tl*sFfeV?DiyP)uX?3@O?PF!k!ruqHm%|A_xL* zEHgV7^b{Xo&Eh)BNoa_f=T(xtpXO+~TV%sEH+o^bl4uMd`VG11`_V86rMY_FKK@1l z_iJhetu#SM(CDu$lBpj>Z8ei%I{2NfTC-hfP6i$w0_&gqZvKK)7&!61@v%`At$lMk zCs_v=%*jB352%mos8--VrqmIGfnwaZ+AXclt?Tn9nvsPsrECUPVynIDDb?%b*x;$} zu0J;&d$NUSAutF?38Qm?G6Rgr5(IP=W4rq}84gG!hXAWmbmh0t1tJY<;!(^@GMmhi zCQz4PS2=?IvCUi{JrmDHd0{;5Z!h$0a&g%+K7v<^7RsTUcw;Wl=5M?r=b z$zM9xqTNEeYarRZ zhgHzqVo-+FwvPUAk6s)>tydx;;~hkJ56uZ>$+mFdQdAhgrU_73zdqBF5skcoMmW9t z+qxX;wVq1RH1xlMg5@YL;DpquxWh^5cc{3hHVczjIC94T9Fq3(hYxv&$eLU)(XD zp{Ze%dR3!kRfu4hU6Ea-@z}Oyj161YFN~P=(qr;Z(f${@HXoi6{Hu)Q;UAVi6i%A9 zn)}zeA0zyf80{y-PW}r3DjdwTcVYYD-zB_v$OAYpX7;nG{ zP*ppdF}FFb3>`L|>@+U~vc3CL)>tEpeT{R_ebK~wDPZ!wwWICsOs){XLVgIk${ z0uwug0U5tI{5GN9Y={Q{aWy}#>b^|RYS5g!IzmCrLK{TEb*L`8#mMPR!B|_t>E2e| zuQ-kZJZMv&-hwv(Q(dvLcJLYI2y0vF>Txa$z+DJ2@f#}k#E9$ThmObz2UGQjQ@z_= zX2pYO5B7{rxmOziF-?@LTfbOD3t^5x4yx=T!whSA)u ziC*8Ha=-h2cUAZ^adMgbxVjcwAu9!WeezhXXC+!KP#EY(X|2%V-K3*4#zYn2={p$i zrzJPm8QAk;o{5|DlDt0*cn=hnlzM0d!p`ss zLnJ5J-T<550i|1oxrVPX6}hior2sVxS~`lj2{fYRpSvMz@K^M7m@<8b)V#vES{CD$ z$J_&JQ|(Q1dH>*)-)VfmRbF1+6G2T~SJ%5pf8bkJy(_a+2hzEzh%`ZR!4HvA90yzH zW}M|407#?9YcsVvIOR{Yv)2`a_L7Q-(N>p}(^{Y*w{W3=$Lzb~-Jcqlze#HUHL(7d zI(fde?EYe!qm8ypJ_ekS@JGV!P`^!WsOdGlRw9o_&xg^G?Z(E9Kt(H1--1?{T#d+B zf!2{C66VpK?sK{bTZ4sx%xkFe>pk<2u|vwU`yY7rMAb!OqRs~88fN?6fF=+-=$>aK z4F&U%kdW(81(W|I3AfD&~(w9AKPI5@%62g}0aPzZ}U*mEYDdx*`>x_;c zM5U$o{hk8}Ke{su>G6TX%m@@_JISv5pFWHk+1( zrPOtLr`>ul$YfI-4DNDJ&}sKQwg_`!fQIf_Wvs&dwjJ<7(bhvypa62lQ9#aZandq` zT*KHNS4d~1x_8uKN%i4M^YIFxE2yy%N5{92{j-(@~PD zj~1iWa0VC{hl|K#F83g9v3h~7I(iIm)ipG(fdtd!RX5BAnIjyRwqM$T6zwf+w>zf8 zTM1N)Z|Z(_5B~wKmV(+JqT5d#zvJGn)Ef0iGqcyqJx+Sl(5-bNBAu3uR=! zRz&fklvaSsP1`rs3GIf05%mvFYZhjLob3v1Xh8TTl=;3QCw_%|;c$cjuL^0-HMmvm zV|Spjc5FvVEp7r^0rj+{AeL$2Wma}}b}m5LjvDKVFL;LXiq5sNb+#_jnLK#!RJ?fd z9(1*lpZhizyyfvVA|oO^8Vd@3J~8xg2N=&-uHL*-3zPA0-cB4NV`IDH$Cc@J7cF`V zXkhY}@fFQ4z`2RRo7z-)F{dqBmM5ewE!_WkmhNG)0?b_|+25Xc4O8jAu2GEojc1Y_ zQ2UdNOg@UTnq?0QN}Zb^yeX!w$z(D+h9!5z8sNQl&91ne_HU^JB^w~eDrPWAf`l&j z82tbL2S+X{Hda*+%7Ff=bDMpRqY#5C*UpxOxV~F}LC0ZKHF*$TFf70i;w2?Ga`T$- ze_xjr4u3%Nxn&xC?jk*d|MaO46BfJe|G)qEpVy$5si~tA1$!-0r`I35t<#x`A8Bb_ z$ASF*BlrdvWYk6K5xj(iDTNsrCD%ud`x+4_Otmll2fQlrJz#2=Pv@lU;5B-GY;@Rp zN%h>3e9^ntm27vmh}V4l0g}Q0y9@u<8W==P7`;b-t#3advt zvmqf6-&MFfgtbpWi_O`Zp7vE@)Poz7u!Vl?s#E;uT9ZntW>$BMXm^@3${tuRn&{&t z+MC|$Anc8i=&HdM<-U$Hddspd(Hgm?C688~mKtD~Ul(qT)Ok$z#Z+gV50PG>cPpyW z@#KAmT>FbPMMui0jKM>PPebDRAK5{I6+~@mMwy%id-wzmb7cEJl z`u!Qbnzam77CX$wuZ3P$-}|D1m2J)0nEs$oVsw}#tD=Wn@K5$qR=M1BD=Q$DQKu~0 z-{dOnJwHvWu;crFCqLoiLJqF+>HYiX<1fU^D$9J*fm4Pu^Ak0 zbeIj}tDii+DgLV+H#$_FwGVkOonzDV3qyp*L{GTV$sGoF z?6*11>EX0OPcui2@YQAg1@TIPlaX&1hlPvoY>Q$@bnF8CLn;d|&+EO(YF{pT?4X*E zuw2hoKLy0jc$$FsSBt4=&M{iEEMTnk`v!h6(5PALJz0;nK%pW;m|3&|A6dIRIME@a zEVng2I=(26E3rjPYta^|9a$XZI7bbC z+`y7Gbg>X!e&mW0H#)>7rT5A?&D%=NA*>V2MC;h}XvxH%ngkywbGTNfqCYR_x?VJK z+rkpV>bU;dEYeq!0 zES&vaZ{p+P<+i3|h}I`XYoc`1MVxh$YqZS(h^LZt>9p`g$hO@%oOATp!kXLt6fyR&FV-mOhcz8T2_ie$6b~r%p|9OFLel zn%l&}C#%jgX6Hsh*HcW=R#6bFP+`v5I`c*I?6&PLyG83fQJ8q4$9`(BT>pEKg-pIM z*=s@gBmHtc7Tc5q9dU!VH6g;830q2DOdE3bx!sGe@)z&?R5bBuy~Jq70;LRn!6uOx zNh=9rgfr&eD)@|_+i^!&qVHGf&z;*;@JV8HP{pWwD_2r<(?_m%BzmS*y0t8M;CyCm zBr#-U=l2iy{&S(HsX=1&oQh%h$>=|^ziw~aHF!xHYCVcEZD%>ca6^Lj*KqGqL7ip zElWn9;WvZ13^|br#m^qu^kR_Ze8#u?d~x)jah4qHyg@?0(%|2WK*QNBO2&mIweK0@ zBBSyDebg5pc0E&jeG{vFTlXu``TeEm4~Ek=*D3DCXAC;3ZCUMxDQUep`~KUuD-B*` zSW0#@8>%{YR6k_+u|+$&X>94|%)`coP4;UA6CGr8pc=dKb-!Z9vV5N>&HnRx2el%F z>7r%6{nTl5bipNqxSS}i_unF;Jd+)r_(#N)@JH^s6|B@f8tknV$!nG1IKl6XX}G&1x*iD` zWwAqTZuMSy=zP)3NqT$tB39-w{yt4`oa-m$Tsv<%mQ}7aSXv}MIl#brZ4$RSq|q6tNNn`um`0qA+zLILIa7Pj z^}%5qr92evQuxWW0uzQOZhhS+^=8S|s~${k*h@|YBS+RbJ6>Yw+3+DQE{%ujT*{0{ z+;3)}>a2E{#a$GVc~kTaexJ)2rb>w4ujA)7H{3Jo@$7|h;i@0cZsBGs3T_l_n0(c+ z`mNTr#{J93KjKuaUVBYg^M2XOsl6$(#x9Or0X?OEfadi?BiUc{Y_3e}?amGpx{DrY za%D%N!@TJ~G@tsmksB=9lo_}5jfxpRHYz&znQ?7gBMTDnoyuqVw=&XdWU5vyE^JNt zMIggsTa#@Ra_Y8smoW|}1QyO|?lX@Pwll&-!8NUHlvT^6koZkJfX(aSR=a*i-r;|u zGQ9C_jZZ>g=ksbtvhgt2iZ&Jo9lv)oH&gF(=C%o0?AZ)YQ|@z-(u7b-MeS|l#!FXgT)P)l%_ zI&{{cLqE=>ThciL%D|l?iA5UErMAufBvg)!iBZW4c$cXpn8^y0s>K$T99|{JG43uu z=UyltP+M1fy^$L_Uv!a|Mhs7DZj|Bd8|o9X#5vBU5|(KU@>`Gnzyzs~pjxkg-Y-RJ0*N-`&|M7!J~A zMenz+Y>oCUO|F0tb0{x&-K0|T5Kgvo@f5}#+D^+ z;Ra5;E{y`_2=XAxiF`B!1qq({CT}0HtcFJe8FGdx_e6hkxR~X;LZF04aF-Z5@J)&} z_KV=LXlXc*YB#lUZv7ypVg#$>u#? zePWDj%0}s4!7X^%M%I1%Zf)=sQyl8BxvQ)`Ge2a92v4z?yFK7KW;`yq<>{#UZc2oK zy|RFxka5}WUMC{vPa20=zIyq`T==mZ_{p?bHyF9?TF=1Z%tT)&{I)aG>hn9Rm~f$= zLdIQMoM!oSg~0(9Dunf;(edi0!#EoGI({Z$F^D#$UaRttHKlKfR^MV=*z!WlpkhbNSlf=Z1{;iaMOn6NGU5megJ@dpi7iX@% z(W?C(lCZ&5F^#LcUOKSlH*B%`Y@BWtD=Y}fywizN#B8gzNw*H`;ey(Al55xTEFUU* zx^k^Ay!C`v&dDvx?Duhfp|$_BL=5{ULS_n%9LsYzCZHm+`M==z|s z;EG}Oa$8UCfYKnJHD+G1Tukf=W6+Pqj1UenLTq^}FGy%7APHIF&_3jQ@RJJ6B(Y|2 zU4+T}+Gk?(noACuN4~w_t0qW%W(iA~FAjDL3!O+6e`7noHV@SYx{*54dlD88seO%%52|rXeVobPB-cw@lIJ3e&kG7Tncz zyM@-XlrmHWxu03<_ZY_)o0Q$k=o$9g?y{3^r^Im!*Ca8ctLoD;%LB#|+M{21#b<{e zILKBYnuoA7dDD8HOm_+hQ7mk6w^tZ^sS%!IZ9xlUTOHT9s=q)%3(MuUJ-%3RTvxzX z96ZP1g~D#rA?y4{|#T7tGZ8jr4`rA;I#?@I9H^pyA zSte+3FfQe9?;i4STO?+{H&U$N3Z1yskv7MEaDHYmuesCexkGH~n7V^;g&J#K7w+tINix zjN_jREMpq4xAJwm`YIW%msBT+E$evCsN3#ZF%+gzpy+qEd1sm_}!v^tvA8R5OlD37D0Yx=QehA*GbDOpwS}WbA!^*&|7@ z1FEk=+H|}64sc~0m>b4+==RUxtdD>G%<@{}-zQ)L^I7lw%E~>Je67rn%ZRO97KCE0 zvCGaYwy&>-@x*v!;E?!&D+YnuGkJqn!`GFv-?3c2q-K}Jd~-gwERQ;&E#NH=( z_h-A)VuhQFSwXt3`f}S=g$hq{FKWaM%NlhHFUrM@ag+tGFY>q4&-$`MMg*|TKRIy) oa+UuXBKuze@&5^;J{_M@ulj46&$2}}SVl3{CgY9C>kpjyFLPJ^IRF3v literal 0 HcmV?d00001 diff --git a/public/brand/logo-white.png b/public/brand/logo-white.png new file mode 100644 index 0000000000000000000000000000000000000000..706d59f33ae4a065807aeb79e5552518407a0f65 GIT binary patch literal 7820 zcmeI0={FSM+xW+pof0Ob$y(WWvP%jP5e8Yul4VeKG6vcAFtVmBMS~eBJCnWaWQ={X zYlg9oEW@ww`Mr4FJm3G|dGWcg7x%f(xz2U2bFR;ICz?Kf$jZda1ONb74fOAu{fj66 zf#K4>Gl6KM0RS)=c+CpIBrb49+^@)?7StWw*SC z+d=1gM*#$dkPQ8otv_6T18{nMnM1oLHi5~Klj};MzD0NRB$Iwo!cxiYMt7a01e;`w zXDZvExsP8X!bn?Nr&Fh`>xJuQ!=WSW@GBgmnQI?B0e8(})m3qzbQAsVA8l}IE`2=h z&C6>8o$ho!0Kg7SXb3C-rFBMC>kFU;_)SU)bM*bbh-o$zwF2DC1mFcZ)|sg?%mDpT zPy0Cm{nr2}^Diz;fNTK3JM`5(K|mENfOue_Ne94HX3YTsxDVGW833tNfV|reg{ie$ z0FD+>W)jqxPCyA#TTqG?Q$q!}{wDX38s0_+2ucHIuxmR4;Cc5X1_3u!r~$e+t`5=M zG@>by8SlVXI{3vl>QezQ135#vkH+OW8*@f^gZFmuO9D%s-spQyz&n@S7*_-fa|?v7 z>aWun4YL3MyvJkT&sDTC*4I{kueq&zlMZ@5oO|u~3Tg`ME}plhP}2e~KOP~?IION> zY5e-AP=Os@m9~HxOThERV>|g-#u6K*(Xiv>P?a<78^!NU`_=icGchx7i8#M+lUYvI zypaFxi%*7;|J|O?hV1}eEh(U% zNpL0Yf)g7}1&#Yco6Iur3;f7g;@FIo+XW#gj9I~~0A!pA=J7ZBuLIr~*fte)G8=e2 z2%rtymrUVh&IDX`SC9)m0syi)j?=ZpsQ^Q{Wy=6S>&CTbpR$2Qy$k@r{gNm#lny=1 zcTOaRt?)a4D+WmIbm_h}i!et0^1Vwd@as(PuOW1Jo?=vSv|mv)yd_uie_yWuE~~=2 zj^}t5MeqY&a=cdDd95{$kyfXl;i{8>YQh!gG@Rft128X*R?tab;SId(=4Jxt6TzPT zmu1wI_dGN0^o8~$Uvl0}eWrbqG24GrF6k_(^`UHbRNWJrU(|uxO`kx#NxdchV*v{6 zc5uW8uQA^G8yfI$A3lyf+6W8)L?op_;A66EZYk4F&r;&`923F3qJ7+uRj{IEx*~)h ztQ^F}hbeX|bB*^p4KRcnCHE>wXd;3e|HoGgvXkyq4{}C7AWeq+TS9 zE6e6ERCLu^r7eFacQ3D` z>d8=L@h^s|1l4yo2GEiqQ)%<~%Bu>2`65FF+`0p0lBJWQ`5x{bN6)1<1DYA zj^>VgZP0J7Z^j%1v#`do#`Nhs-{$e+3FrBEt${~6&!~cKA~&!9smzodU!MD0_P4$k zU@@}TE3V9+9672vmN~GT^{S^9{uWx3p;gRJKU=VWwzrI^cwq6xbh(o87x(AMN`8x$ zN~M}%vtYAy(~&0*rR@%s=o1KQU0m#gk~sa+r;vtTo>T$uUOCrY@ICBHOB#ZN*IQ#} z+qz?-Q4rlJUyyXTk-4sal^fD6)2(Rj#Sj%+FB-pdce>DUSYViSI9!rOQcDtz^{jTQ zhE*%igw3?iIB&h&;@%?6kOKXRw2LH)4ppJ5M}dsZO3hE2W1D9KNB(F|KnS6mjE6rD z**53L9v(suN)Lg5NLbPsNLfaKK`DdBTUG_KGnfI{@OtafIJWcp_opiZ&zm#5pO=mq zl-_C--Hvx(Rty1Zx*>h9J0leqT<5&hot!=7X3M(EdRE%+3}t)eyETv1PXr7O_Djqm zamXLUw7ZjqUd2xB)2*{-sj=mHg*}GJO38hQ8N{mrI)pLe2>I4h(=ycZ&~gfCfPF@g zAV9HJ-llw31uO-s1q0tcRToru2NggUIhQ!o?~LC$H20a2C7uzPi21}zTX)G$WDzoy zJiNWN&SM+IGX_OQC2nRtDNX+ii<)8wht))zol38Q!GP?A4@x7xpf`y`o)k zQKMZ5hK1$9=+BBz)lLQ|>3=(ZhwgFjKBjY|`cAb<)fUAY^@YZZ21J`jTTZV?mrB=i zNt#8I>mCaut2O9lmM;dl$9D{opL3VUALIJTP{d`!cOo+=YIFm8B`t1*VevA|x8m4n zbMPBO0{)?QLL zr(_y#H<-AIi)XQ}gswq<@@2*UJX#St_TQi7@{TncE3G%HF=gX6lKvzfVtdUtq*1?3 z-{zP6qTBhOVS zK`~tdn_296hR*G!nZ=Bkm+Oj0TPfsJX8#!QsX4G|f^a$IxLA-pb0=*rBgKF@4oE-b zr<%X02aRh>R*xMfUmb=*XJ!@*8-8vP^a*7IALNmBN3CI-r_SVP+zx9s-)`zEp99oz zA>e(O=V97V{m{=L8bv3?E!)9w$l1O3N~PqmqDZ>|OG@?UhW2UE8EnUVaQHr33_q9J z0x6r=`c*u{%BxK;;?QS&J9<8y*O{-mV+}Un_%PU{r#L;lJe;1aMSn(=+*>vOmaMxVd&|+R>!yyAfKU92N zwIdKISqd%Dc;80aNGUDix95M@-f#gU$u2_z`xMiyic5-aYwRAcL}x93bop3Z^jJ&d zSKeIckn+PR=)$mBj;I>hDX&JH5w0Lew5$( zwYI(l*Q0?gEA^Uy17m{P7-=H%#1k{=KlOJ?%I;lg8>yGb*We>Mf4xzp`S5QLc?%fK zv~4tJ7nUAUd)7Wf`9pug{wK2j9PNsM;{Q5g97npW*-31S@x|xa7ZdTn#~%(poD_N> zl$u@y0`al(w(YqLXZ`+I_wnk;PnhLJD8c{p`XXiN^w9|T47bC4oIKJ|6I!|dlJvQ< zR<%#457asws0ymQx`sJ47;6fz{%M46ONVeB0?4MY|F$|q>6|qN`FEiBflJz*Pv$XFq zBpM8XI(&Q&n=C$7omw7kwRartt5fD|?ItY(Psz4{e+tb%#)}w4C$K=f=)>vnmr*za zuF(G<|9cG{u#njTqAcLmQODY5;Xc<;oPO*wUpk>sfH&=6_4A0*C>~4}4Y=kdluqdqk!;u8?f)Ki`+I50}fJpqCq>q_yV>m6Z-W} zH20Bfi?9J~zLRWk_-3U{*x~xAFmf#1GO}B zbaRZvU!7!2ns)j@s`j}~!u!7w*De*##vL}7mmHnPm*!C}sCTaKNOO4yGvYhor|?yA zu)}j|KmDxQ&BF`V+1neiLiT64xI>>R2q2QPMB;U7Wg;?Woi z=2YCC#DvM?s+|y-Yz~g6{mX|+SYvDV0(@aY+(o<;co#ESwa9!%2WCj2QKHqP^S0SJ zd4d_jX6v{qm1FxxUas}T?tmbP{u-YR9XYPmL}^*M=ymJ zdp(Ga`$U~U4WxP}iF5lhT&|IO$>-C?f(Cav3=wfw6f&Be)YjnGv&?*_razyG$U?M5 z&FO&kY;u&SA6JJI)!g3Do!Z9q3GUZ+N4MOrGeUSpZT-u!@<$-zg&fM74@-!S)(qh1 z&pQJ6;Q`nPpr4=1d3++sWpA+S57S=ZY^N$6UBo9FkecoK-EYy*XP4$K=S6BW6AGyc zx$`cb;FBehQyO#;&rd>J7A~kK#Ab%ACAW2p6{AQrQ}+?aR9H2W{E`xOW3<=C9WI~s zApBTiD5<>BKuV#CyuTwsd5jK8Qmgg@Ox z_qSSx{bc=2QRl)j;{@HC{NV*~I!W&?ey;g&TWtKR=^3GcWGF6vU1-0T&2Jtpc&3Wk zq}bLPpwa&4!9Xbc>@k4srC!kO-kC< zotV!IZLw-BGDbhK`qIjDhVFz82`&U4Jtqduww^FfaUQ(iY{(3K*LBiq^;MTfJ>ouc%kZ(KB`jdJ7 z5UKw(ry!n>Zr~L^-|G*9{gPein69jDT^LB|k9SMYA9~@EwXcmJC+M&>zxkd-6y0xA zTv28tUV?5p)z+1&DK@S{k_xC zkNi)Z^TgC&^M|z0zu!7kpwsYy*nlDeRz(r~I)ov6TaJz!S}ZNe$WJDJ>AljU{<2si zN!b_O+kU6o^bONlPXm14xzXEsuLo&H7gf$~%2e_H`hWx^(TA;Yhb zT~oEZx|#29lR;8SM2pdvDi~-D!tWs*FShJ`yNnsGTv@Rdtb)2ett&B~GFjDO z_B{yWc?8jwTF+yD#r*l}0{`dHnM-`pp5WfSFX;T^MJg-6NIhz(9(m-%gVYND+_q5D z)y^Fz#LKSPg?_P7)tpsxi}ex5e5d#YibLuC#7nUD8pIen;xq&uFa6KV3rLk(f=B-k z7)OQL)Lu53Dmu>eIHxv7+pVtAnFsXmv6L&`NOWG&0!kkUrfLN8RWw5`EvK|QZ@FWi z7Yp7yprhHRMgAJ|F9Y(OjO_ z(4Ui#ahAefJnJjHJNicWB955+3j9r9M+&x0Gn#J}otOsHCu~mYxQ<|2eXPYq?0s zOCFw_ivp3i%0hkUDyHoB*--2Ifg(!J;)(%2-RBF|xbT)hmw6Ma4oo{N zOp0vZ4#Lr#hOJA;qmNjUOq?0X$1|+Bn}=uB7>Y~e1K=dKg`2E60b%-mcaDOU|C zCM??b#}uo{o0Yf12Hf}0*VNg+q2AGi1)M5|apiIg#cWQY4; z!YXTgox6_wb|U*T5(A=XPYqPxeDGznrDEu%h~zuY_X{Xuo#TG)4@MC~W;n0u)2@UzXa zsoNE_Ck@k45RPGTl#X}azIbY6!vY5`TvfGh_{h--lyI_YK)El^=9L*j_gMnjk|V_y z)&QJ`EHG9;91a!O-*T!4|8sSd(_s8Be3JpDAahD0J?H*-nj~)6(ZC@-op!iyW{_~B zXSlv-C)Y7-t8kS}4YRa8r&@BbREfm5R`;0SZDvK3$ndN|DX2nn*~O9a z>p%h@*T1)nf~{;yl{buoe|hQUQK{uuri9VX);60sJ6(jJo;~RSTUatzjPzUkSl}-c zz3qgN0OYv%_W*gCs(@DGmf7TOi{l8HHsv8!xa<`b4aEp$%NNGP+-iJR8QJ<0j9Z&xBn4pw_+0q^*Y zq!(8RR%{iJsg2F8BA|LC-L7-w$7k`1ir6hiiGutEX>hxF&ym-U?O+FG&|fX$-jY0* zcdb$7_Dj49a&^T8e+%q!6Izn%3SAf3aI)$_mFi`p41A^s%TH!`R0Kn|8)rs>fU%Go zmWmEeBa$KH&YBW()~zKK^M_TcFW(SSkr8?P6svvek&MHZ%NaEMmwpOqDWX zBOA$5v43LYewR-zc}m>3nCiUXWsZRds52koHqjv(q7t+fNgWg!I>-$EVl#gYS$z%Z zKejZ}+zI^^URwUo1D$WB`Pm~&e@1=n;{)%WULi&X31O8#{L9`StmljvLLHqzPaH}| z-aqrloq*l*;yu*yAQM=u)6_1<0ra`IeM@n#SBK!#r3rL_>^%tFKZ?d|r0Cv$F1y#0 zxhBXw2O;ksq#C5uT07GAfkO#e-n?Y(awMmme;(Z5mEcL%$o6qzR zJJxY13fZ^i$wEJheT0rNoUbSLv}EOeIHl!HCYg*XcN%6gqw;5)%cD$`nufo(a{7iBg zElTm7WMSthxHJJ=^FC5Ua)?XXd7sN$ez|alo_r`g)Lw35&WN;?$nMY)5w$yER09|3 zu+NQB!=l+NpV{9E*)}EKAT2s6ZYHA%C|k4{ChGg%=LuZ#LdtHov|jxqTz#-AcMTAY zicJrXUah4$&(B{FdK*bkhG|A|EnlPsR#IeAry2<3IIRfk)bAbiUL)+f2clT-JjB!p zKT>nq0%<_pP3h}8@Xbt|&g~`d}qSsQ-otvc+7E2_TSSq7JGR`MPJJ|!pmm+h=2QKtq8X15o-8L z^l|*^nTEKift-^2LM+d0-W&AXcw(DFys&|sfWaHr=wpJY!JdyNfBK5IH2JRw3Pex0 z-*qt{9do?=W=(6N8PqoPt-Ged>c`t7HYMZ>Y~Z{KlH8EAV4_v!$Y0Ii>o}eIGWVua zcpy$8SazB}W1$2c*Sfub(2+u|W?Ot+{YVNsbcO(8A5k=N4FoSAS zX?hK0h?wne9i!!$dghX4{BN-DH>-q2IxZ!yp5Cp6Yb{<JIxE(fqSV=&s_qgW&+#A_TZ88RK;vIE4+*yBxBeN zAt*1r9HL8Xy243uRXRgsW+)x~vq~HVqn932Zl4JP?>nmmy+R~{P1-7P3>qeo$ct-4 zjhU?8E1na*kc)}eOY#xXsj@)C12)Y0Fc*sBz9n$R1QL9rVQ#zaak9<2VK}d;Qr2&J zpn}zEhlDk4NR5A1Emr&g;+SGNs(1ZbN(likIPMg4rCIC*l&pXCKl=ML0Qf@t{nZ!R zI{)H-!BHl9VIamX;pzM3Ccc!>q3#Ecj2&zG-7zl|l=r+vE({ + start(controller) { + controller.enqueue(new Uint8Array([1, 2, 3])); + controller.close(); + }, + }), + contentType: "image/jpeg", + contentLength: 3, + filename: "tor.jpg", + }; +} + +function createHandler(options?: { + editorialError?: Error; + grantedAlbumIds?: string[]; + albumAssets?: Array<{ id: string; type: "IMAGE"; albums: Array<{ id: string }> }>; + albumError?: Error; + adminAlbums?: typeof grantedAlbum[]; +}) { + const dependencies = { + requireActiveEditorial: vi + .fn() + .mockImplementation(async () => { + if (options?.editorialError) throw options.editorialError; + return { editorialId: "editorial-1" }; + }), + requireAdmin: vi.fn().mockResolvedValue({ userId: "admin-1" }), + getGrantedAlbumIds: vi.fn().mockResolvedValue(options?.grantedAlbumIds ?? ["allowed"]), + immich: { + listAlbums: vi.fn().mockResolvedValue(options?.adminAlbums ?? [grantedAlbum]), + getAlbum: vi.fn().mockImplementation(async () => { + if (options?.albumError) throw options.albumError; + return { + ...grantedAlbum, + assets: options?.albumAssets ?? [ + { id: "asset-1", type: "IMAGE", albums: [{ id: "allowed" }] }, + ], + }; + }), + getThumbnail: vi.fn().mockResolvedValue(thumbnail()), + }, + }; + return { handler: createThumbnailHandler(dependencies), dependencies }; +} + +function call(handler: ReturnType, assetId = "asset-1") { + return handler(new Request("http://portal.test/api/assets/asset-1/thumbnail"), { + params: Promise.resolve({ assetId }), + }); +} + +test("streams a thumbnail when the requested asset belongs to any current grant", async () => { + const { handler, dependencies } = createHandler({ + albumAssets: [{ id: "asset-1", type: "IMAGE", albums: [{ id: "other" }, { id: "allowed" }] }], + }); + + const response = await call(handler); + + expect(response.status).toBe(200); + expect(response.headers.get("cache-control")).toBe("private, no-store"); + await expect(response.arrayBuffer()).resolves.toEqual(new Uint8Array([1, 2, 3]).buffer); + expect(dependencies.immich.getThumbnail).toHaveBeenCalledWith("asset-1"); +}); + +test("refuses a thumbnail immediately after its last grant is revoked", async () => { + const { handler, dependencies } = createHandler({ grantedAlbumIds: [] }); + + const response = await call(handler); + + expect(response.status).toBe(404); + expect(dependencies.immich.getAlbum).not.toHaveBeenCalled(); + expect(dependencies.immich.getThumbnail).not.toHaveBeenCalled(); +}); + +test("uses an identical generic 404 for forbidden and missing assets", async () => { + const forbidden = createHandler({ albumAssets: [{ id: "different", type: "IMAGE", albums: [{ id: "allowed" }] }] }); + const missing = createHandler({ albumError: new Error("IMMICH_NOT_FOUND") }); + + const [forbiddenResponse, missingResponse] = await Promise.all([ + call(forbidden.handler), + call(missing.handler), + ]); + + expect({ status: forbiddenResponse.status, body: await forbiddenResponse.text() }).toEqual({ + status: missingResponse.status, + body: await missingResponse.text(), + }); + expect(forbidden.dependencies.immich.getThumbnail).not.toHaveBeenCalled(); + expect(missing.dependencies.immich.getThumbnail).not.toHaveBeenCalled(); +}); + +test("allows an admin only to load an existing Immich album cover", async () => { + const { handler, dependencies } = createHandler({ + editorialError: new PrincipalAuthorizationError("ADMIN_REQUIRED"), + adminAlbums: [grantedAlbum], + }); + + const response = await call(handler, "cover-1"); + + expect(response.status).toBe(200); + expect(dependencies.requireAdmin).toHaveBeenCalledTimes(1); + expect(dependencies.getGrantedAlbumIds).not.toHaveBeenCalled(); + expect(dependencies.immich.getThumbnail).toHaveBeenCalledWith("cover-1"); +}); + +test("does not let an admin proxy an arbitrary non-cover asset", async () => { + const { handler, dependencies } = createHandler({ + editorialError: new PrincipalAuthorizationError("ADMIN_REQUIRED"), + adminAlbums: [grantedAlbum], + }); + + const response = await call(handler, "asset-not-a-cover"); + + expect(response.status).toBe(404); + expect(dependencies.immich.getThumbnail).not.toHaveBeenCalled(); +}); diff --git a/src/app/api/assets/[assetId]/thumbnail/route.ts b/src/app/api/assets/[assetId]/thumbnail/route.ts new file mode 100644 index 0000000..d371571 --- /dev/null +++ b/src/app/api/assets/[assetId]/thumbnail/route.ts @@ -0,0 +1,3 @@ +import { authorizedThumbnailHandler } from "./thumbnail-handler"; + +export const GET = authorizedThumbnailHandler; diff --git a/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts b/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts new file mode 100644 index 0000000..e4660cf --- /dev/null +++ b/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts @@ -0,0 +1,115 @@ +import "server-only"; + +import { requireActiveEditorial, requireAdmin, PrincipalAuthorizationError } from "@/modules/auth/principal"; +import { albumGrantService } from "@/modules/albums/grants"; +import { immichClient } from "@/modules/immich/client"; +import type { ImmichBinary } from "@/modules/immich/types"; + +type ThumbnailRouteContext = Readonly<{ params: Promise<{ assetId: string }> }>; + +type ThumbnailImmich = { + listAlbums(): Promise>; + getAlbum(albumId: string): Promise<{ assets: Array<{ id: string; type: "IMAGE" }> }>; + getThumbnail(assetId: string): Promise; +}; + +export type ThumbnailHandlerDependencies = { + requireActiveEditorial: typeof requireActiveEditorial; + requireAdmin: typeof requireAdmin; + getGrantedAlbumIds: typeof albumGrantService.getGrantedAlbumIds; + immich: ThumbnailImmich; +}; + +type Access = { kind: "admin" } | { kind: "editorial"; editorialId: string }; + +export function createThumbnailHandler(dependencies: ThumbnailHandlerDependencies) { + return async function GET(request: Request, context: ThumbnailRouteContext): Promise { + try { + const { assetId } = await context.params; + if (!isSafeAssetId(assetId)) { + return genericNotFound(); + } + + const access = await authorizeRequest(dependencies, request.headers); + const authorized = + access.kind === "admin" + ? await isAdminAlbumCover(dependencies.immich, assetId) + : await isGrantedEditorialAsset(dependencies, access.editorialId, assetId); + if (!authorized) { + return genericNotFound(); + } + + const thumbnail = await dependencies.immich.getThumbnail(assetId); + return thumbnailResponse(thumbnail); + } catch { + return genericNotFound(); + } + }; +} + +async function authorizeRequest( + dependencies: ThumbnailHandlerDependencies, + requestHeaders: Headers, +): Promise { + try { + const principal = await dependencies.requireActiveEditorial(requestHeaders); + return { kind: "editorial", editorialId: principal.editorialId }; + } catch (error) { + if (!(error instanceof PrincipalAuthorizationError) || error.code !== "ADMIN_REQUIRED") { + throw error; + } + } + + await dependencies.requireAdmin(requestHeaders); + return { kind: "admin" }; +} + +async function isGrantedEditorialAsset( + dependencies: ThumbnailHandlerDependencies, + editorialId: string, + assetId: string, +): Promise { + const grantedAlbumIds = [...new Set(await dependencies.getGrantedAlbumIds(editorialId))]; + if (grantedAlbumIds.length === 0) { + return false; + } + + const grantedAlbums = await Promise.all( + grantedAlbumIds.map((albumId) => dependencies.immich.getAlbum(albumId)), + ); + return grantedAlbums.some((album) => + album.assets.some((asset) => asset.id === assetId && asset.type === "IMAGE"), + ); +} + +async function isAdminAlbumCover(immich: ThumbnailImmich, assetId: string): Promise { + const albums = await immich.listAlbums(); + return albums.some((album) => album.albumThumbnailAssetId === assetId); +} + +function thumbnailResponse(thumbnail: ImmichBinary): Response { + const responseHeaders = new Headers({ + "cache-control": "private, no-store", + "content-type": thumbnail.contentType, + "x-content-type-options": "nosniff", + }); + if (thumbnail.contentLength !== null) { + responseHeaders.set("content-length", String(thumbnail.contentLength)); + } + return new Response(thumbnail.body, { headers: responseHeaders }); +} + +function genericNotFound(): Response { + return new Response(null, { status: 404 }); +} + +function isSafeAssetId(assetId: string): boolean { + return /^[A-Za-z0-9_-]{1,200}$/.test(assetId); +} + +export const authorizedThumbnailHandler = createThumbnailHandler({ + requireActiveEditorial, + requireAdmin, + getGrantedAlbumIds: albumGrantService.getGrantedAlbumIds, + immich: immichClient, +}); diff --git a/src/app/globals.css b/src/app/globals.css index 9c971cb..85490aa 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -2,8 +2,11 @@ :root { --paper: #ffffff; - --ink: #0a0a0a; - --muted: #5f5f5f; + --ink: #050505; + --graphite: #242424; + --contact-sheet: #ececec; + --metadata: #6b6b6b; + --muted: var(--metadata); --line: #d8d8d8; --soft: #f3f3f3; color-scheme: light; @@ -276,3 +279,341 @@ a { grid-template-columns: 1fr; } } + +.editorial-shell { + min-height: 100vh; + background: var(--paper); +} + +.portal-masthead { + display: flex; + align-items: center; + justify-content: space-between; + gap: 2rem; + min-height: 5.25rem; + padding: 0.9rem clamp(1.25rem, 4vw, 5rem); + background: var(--ink); + color: var(--paper); +} + +.portal-brand { + display: inline-flex; + align-items: center; + min-width: 0; +} + +.brand-logo { + display: block; + width: min(14rem, 48vw); + height: auto; + object-fit: contain; +} + +.portal-masthead-meta, +.portal-masthead nav { + display: flex; + align-items: center; + gap: clamp(1rem, 2.2vw, 2.25rem); +} + +.portal-masthead-meta { + color: #d4d4d4; + font-size: 0.6875rem; + font-weight: 600; + letter-spacing: 0.1em; + text-transform: uppercase; +} + +.portal-masthead nav a { + color: var(--paper); + text-decoration: none; +} + +.portal-masthead nav a:hover { + text-decoration: underline; + text-underline-offset: 0.28em; +} + +.editorial-work-surface { + width: min(100%, 108rem); + margin: 0 auto; + padding: clamp(2rem, 5vw, 5.5rem) clamp(1.25rem, 4vw, 5rem) 5rem; +} + +.editorial-section { + max-width: 100%; +} + +.editorial-kicker { + margin: 0 0 1rem; + color: var(--metadata); + font-size: 0.6875rem; + font-weight: 700; + letter-spacing: 0.12em; + text-transform: uppercase; +} + +.editorial-title-row { + display: flex; + align-items: end; + justify-content: space-between; + gap: 2rem; + margin-bottom: clamp(2rem, 4vw, 3.5rem); + padding-bottom: 1.25rem; + border-bottom: 1px solid var(--ink); +} + +.editorial-title-row h1, +.editorial-state h1, +.editorial-section > h1 { + max-width: 15ch; + margin: 0; + font-size: clamp(2.5rem, 5vw, 5.5rem); + font-weight: 600; + letter-spacing: -0.065em; + line-height: 0.9; +} + +.editorial-title-row > p { + max-width: 27rem; + margin: 0; + color: var(--graphite); + font-size: 0.95rem; + line-height: 1.5; +} + +.album-title-row { + align-items: center; +} + +.quiet-link { + flex: none; + color: var(--graphite); + font-size: 0.8125rem; + font-weight: 650; + text-underline-offset: 0.2em; +} + +.album-contact-sheet, +.photo-contact-sheet { + display: grid; + gap: clamp(1.25rem, 2.25vw, 2.5rem); + padding: 0; + list-style: none; +} + +.album-contact-sheet { + grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); +} + +.photo-contact-sheet { + grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr)); +} + +.contact-sheet-link { + display: block; + color: inherit; + text-decoration: none; +} + +.album-contact-frame, +.photo-contact-frame { + margin: 0; + background: var(--contact-sheet); +} + +.album-contact-frame { + border: 1px solid var(--ink); +} + +.photo-contact-frame { + border-top: 1px solid var(--ink); +} + +.contact-sheet-image, +.missing-contact-image { + display: block; + width: 100%; + aspect-ratio: 3 / 2; + object-fit: cover; + background: var(--contact-sheet); + transition: transform 150ms ease-out; +} + +.photo-contact-frame .contact-sheet-image { + aspect-ratio: 3 / 2; +} + +.missing-contact-image { + display: grid; + place-items: center; + color: var(--metadata); + font-size: 0.75rem; + letter-spacing: 0.08em; + text-transform: uppercase; +} + +.contact-sheet-link:hover .contact-sheet-image, +.contact-sheet-link:focus-visible .contact-sheet-image { + transform: scale(1.015); +} + +.album-contact-frame, +.photo-contact-frame { + overflow: hidden; +} + +.contact-strip { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 0.75rem; + min-height: 2.35rem; + margin: 0; + padding: 0.5rem 0.625rem; + border-top: 1px solid var(--ink); + background: var(--contact-sheet); + color: var(--graphite); + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + font-size: 0.625rem; + letter-spacing: 0.035em; + line-height: 1.25; + text-transform: uppercase; +} + +.contact-strip-name { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.photo-search { + display: grid; + gap: 0.55rem; + width: min(100%, 42rem); + margin-bottom: 1.25rem; +} + +.photo-search label { + font-size: 0.75rem; + font-weight: 700; + letter-spacing: 0.06em; + text-transform: uppercase; +} + +.photo-search-controls { + display: flex; + align-items: stretch; +} + +.photo-search input { + min-width: 0; + flex: 1; + min-height: 3rem; + border: 1px solid var(--ink); + border-right: 0; + border-radius: 0; + background: var(--paper); + color: var(--ink); + font: inherit; + padding: 0.7rem 0.8rem; +} + +.photo-search button { + min-height: 3rem; + border: 1px solid var(--ink); + border-radius: 0; + background: var(--ink); + color: var(--paper); + cursor: pointer; + font: inherit; + font-size: 0.8125rem; + font-weight: 700; + padding-inline: 1rem; +} + +.photo-search button:hover { + background: var(--graphite); +} + +.result-summary { + margin: 0 0 1.5rem; + color: var(--metadata); + font-size: 0.8125rem; +} + +.catalog-empty, +.editorial-state > p:not(.editorial-kicker) { + max-width: 38rem; + color: var(--graphite); + font-size: 1rem; + line-height: 1.55; +} + +.photo-pagination { + display: flex; + justify-content: space-between; + gap: 1rem; + margin-top: 2.5rem; + padding-top: 1rem; + border-top: 1px solid var(--ink); + font-size: 0.8125rem; + font-weight: 650; +} + +.editorial-section dl { + display: grid; + grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr); + gap: 0.85rem 1.5rem; + max-width: 48rem; + margin: 2rem 0 0; + padding-top: 1.25rem; + border-top: 1px solid var(--ink); +} + +.editorial-section dt { + color: var(--metadata); + font-size: 0.75rem; + font-weight: 700; + letter-spacing: 0.06em; + text-transform: uppercase; +} + +.editorial-section dd { + margin: 0; + line-height: 1.45; +} + +@media (max-width: 44rem) { + .portal-masthead { + align-items: flex-start; + flex-direction: column; + gap: 0.8rem; + } + + .portal-masthead-meta { + width: 100%; + justify-content: space-between; + } + + .editorial-title-row { + align-items: flex-start; + flex-direction: column; + gap: 1.25rem; + } + + .editorial-section dl { + grid-template-columns: 1fr; + gap: 0.25rem; + } + + .editorial-section dd { + margin-bottom: 0.75rem; + } +} + +@media (prefers-reduced-motion: reduce) { + .contact-sheet-image { + transition: none; + } +} diff --git a/src/app/redaktion/access.ts b/src/app/redaktion/access.ts new file mode 100644 index 0000000..9e8d45e --- /dev/null +++ b/src/app/redaktion/access.ts @@ -0,0 +1,11 @@ +import "server-only"; + +import { cache } from "react"; + +import { headers } from "next/headers"; + +import { requireActiveEditorial } from "@/modules/auth/principal"; + +export const requireEditorial = cache(async () => + requireActiveEditorial(new Headers(await headers())), +); diff --git a/src/app/redaktion/alben/[albumId]/loading.tsx b/src/app/redaktion/alben/[albumId]/loading.tsx new file mode 100644 index 0000000..1cdf460 --- /dev/null +++ b/src/app/redaktion/alben/[albumId]/loading.tsx @@ -0,0 +1,8 @@ +export default function AlbumLoading() { + return ( +
+

Bildarchiv

+

Fotos werden geladen.

+
+ ); +} diff --git a/src/app/redaktion/alben/[albumId]/page.tsx b/src/app/redaktion/alben/[albumId]/page.tsx new file mode 100644 index 0000000..c138973 --- /dev/null +++ b/src/app/redaktion/alben/[albumId]/page.tsx @@ -0,0 +1,104 @@ +import Link from "next/link"; +import { notFound } from "next/navigation"; + +import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog"; +import { PhotoContactSheet } from "@/modules/albums/catalog-content"; + +import { requireEditorial } from "../../access"; + +type AlbumPageProps = Readonly<{ + params: Promise<{ albumId: string }>; + searchParams: Promise<{ page?: string | string[]; suche?: string | string[] }>; +}>; + +export default async function AlbumPage({ params, searchParams }: AlbumPageProps) { + const [{ albumId }, rawSearchParams, principal] = await Promise.all([ + params, + searchParams, + requireEditorial(), + ]); + const query = normalizedQuery(singleValue(rawSearchParams.suche)); + const result = await loadAlbumPage({ + editorialId: principal.editorialId, + albumId, + query, + page: singleValue(rawSearchParams.page), + }); + + if (result.unavailable) { + return ; + } + if (!result.album) { + notFound(); + } + + return ( +
+

Bildarchiv · {result.album.assetCount} freigegebene Fotos

+
+

{result.album.albumName}

+ + Alle Alben + +
+ +
+ ); +} + +async function loadAlbumPage({ + editorialId, + albumId, + query, + page, +}: { + editorialId: string; + albumId: string; + query: string; + page: string | undefined; +}) { + try { + const albums = await albumCatalog.getVisibleAlbums(editorialId); + const album = albums.find((candidate) => candidate.id === albumId); + if (!album) { + return { album: null, page: null, unavailable: false as const }; + } + const results = await albumCatalog.searchVisiblePhotos(editorialId, { + requestedAlbumId: album.id, + description: query, + page, + }); + return { album, page: results, unavailable: false as const }; + } catch (error) { + if (error instanceof AlbumCatalogError && error.code === "IMMICH_UNAVAILABLE") { + return { album: null, page: null, unavailable: true as const }; + } + throw error; + } +} + +function singleValue(value: string | string[] | undefined): string | undefined { + return typeof value === "string" ? value : undefined; +} + +function normalizedQuery(value: string | undefined): string { + return (value ?? "").replace(/\s+/g, " ").trim().slice(0, 200); +} + +function ImmichUnavailable() { + return ( +
+

Bildarchiv

+

Fotos momentan nicht erreichbar

+

Bitte laden Sie diese Seite in wenigen Minuten erneut.

+ + Zurück zu den Alben + +
+ ); +} diff --git a/src/app/redaktion/alben/loading.tsx b/src/app/redaktion/alben/loading.tsx new file mode 100644 index 0000000..080dc86 --- /dev/null +++ b/src/app/redaktion/alben/loading.tsx @@ -0,0 +1,8 @@ +export default function AlbumsLoading() { + return ( +
+

Bildarchiv

+

Alben werden geladen.

+
+ ); +} diff --git a/src/app/redaktion/alben/page.tsx b/src/app/redaktion/alben/page.tsx new file mode 100644 index 0000000..70dd57f --- /dev/null +++ b/src/app/redaktion/alben/page.tsx @@ -0,0 +1,49 @@ +import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog"; +import { AlbumContactSheet } from "@/modules/albums/catalog-content"; + +import { requireEditorial } from "../access"; + +export default async function AlbumsPage() { + const principal = await requireEditorial(); + const result = await loadAlbums(principal.editorialId); + + if (result.unavailable) { + return ; + } + + return ( +
+

Bildarchiv · Freigaben

+
+

Ihre Alben

+

Wählen Sie ein Spiel oder eine Serie, um die freigegebenen Fotos zu durchsuchen.

+
+ {result.albums.length === 0 ? ( +

Für Ihre Redaktion sind noch keine Fotoalben freigegeben.

+ ) : ( + + )} +
+ ); +} + +async function loadAlbums(editorialId: string) { + try { + return { albums: await albumCatalog.getVisibleAlbums(editorialId), unavailable: false as const }; + } catch (error) { + if (error instanceof AlbumCatalogError && error.code === "IMMICH_UNAVAILABLE") { + return { albums: [], unavailable: true as const }; + } + throw error; + } +} + +function ImmichUnavailable() { + return ( +
+

Bildarchiv

+

Alben momentan nicht erreichbar

+

Bitte laden Sie diese Seite in wenigen Minuten erneut. Ihre Freigaben bleiben unverändert.

+
+ ); +} diff --git a/src/app/redaktion/layout.tsx b/src/app/redaktion/layout.tsx new file mode 100644 index 0000000..58aecb1 --- /dev/null +++ b/src/app/redaktion/layout.tsx @@ -0,0 +1,11 @@ +import type { ReactNode } from "react"; + +import { PortalShell } from "@/components/layout/portal-shell"; + +import { requireEditorial } from "./access"; + +export default async function EditorialLayout({ children }: Readonly<{ children: ReactNode }>) { + await requireEditorial(); + + return {children}; +} diff --git a/src/app/redaktion/profil/page.tsx b/src/app/redaktion/profil/page.tsx index 1510157..9eb1595 100644 --- a/src/app/redaktion/profil/page.tsx +++ b/src/app/redaktion/profil/page.tsx @@ -1,12 +1,12 @@ import { eq } from "drizzle-orm"; -import { headers } from "next/headers"; import { db } from "@/db/client"; import { billingAddressVersions, editorialAccounts } from "@/db/schema"; -import { requireActiveEditorial } from "@/modules/auth/principal"; + +import { requireEditorial } from "../access"; export default async function EditorialProfilePage() { - const principal = await requireActiveEditorial(new Headers(await headers())); + const principal = await requireEditorial(); const [editorial] = await db .select({ name: editorialAccounts.name, @@ -27,35 +27,33 @@ export default async function EditorialProfilePage() { .limit(1); return ( -
-
-

Redaktionskonto

-

Profil

-
-
Redaktion
-
{editorial?.name}
-
Ansprechperson
-
{editorial?.contactName}
-
Anmelde-E-Mail
-
{editorial?.loginEmail}
-
Rechnungsadresse
-
- {editorial?.addressLine1 ? ( -
- {editorial.addressLine1} - {editorial.addressLine2 ?
: null} - {editorial.addressLine2} -
- {editorial.postalCode} {editorial.city} -
- {editorial.countryCode} -
- ) : ( - "Keine Rechnungsadresse hinterlegt." - )} -
-
-
-
+
+

Redaktionskonto

+

Profil

+
+
Redaktion
+
{editorial?.name}
+
Ansprechperson
+
{editorial?.contactName}
+
Anmelde-E-Mail
+
{editorial?.loginEmail}
+
Rechnungsadresse
+
+ {editorial?.addressLine1 ? ( +
+ {editorial.addressLine1} + {editorial.addressLine2 ?
: null} + {editorial.addressLine2} +
+ {editorial.postalCode} {editorial.city} +
+ {editorial.countryCode} +
+ ) : ( + "Keine Rechnungsadresse hinterlegt." + )} +
+
+
); } diff --git a/src/components/brand/logo.tsx b/src/components/brand/logo.tsx new file mode 100644 index 0000000..95398f6 --- /dev/null +++ b/src/components/brand/logo.tsx @@ -0,0 +1,19 @@ +/* eslint-disable @next/next/no-img-element */ + +type BrandLogoProps = { + variant: "black" | "white"; +}; + +export function BrandLogo({ variant }: Readonly) { + const source = variant === "white" ? "/brand/logo-white.png" : "/brand/logo-black.png"; + + return ( + Leon Tonhäuser Sportfotografie + ); +} diff --git a/src/components/layout/portal-shell.tsx b/src/components/layout/portal-shell.tsx new file mode 100644 index 0000000..772809b --- /dev/null +++ b/src/components/layout/portal-shell.tsx @@ -0,0 +1,25 @@ +import type { ReactNode } from "react"; + +import Link from "next/link"; + +import { BrandLogo } from "@/components/brand/logo"; + +export function PortalShell({ children }: Readonly<{ children: ReactNode }>) { + return ( +
+
+ + + +
+ Redaktionsarchiv + +
+
+
{children}
+
+ ); +} diff --git a/src/modules/albums/catalog-content.test.tsx b/src/modules/albums/catalog-content.test.tsx new file mode 100644 index 0000000..8630a18 --- /dev/null +++ b/src/modules/albums/catalog-content.test.tsx @@ -0,0 +1,62 @@ +// @vitest-environment jsdom + +import { render, screen } from "@testing-library/react"; +import { expect, test } from "vitest"; + +import { AlbumContactSheet, PhotoContactSheet } from "./catalog-content"; + +test("renders granted albums as labelled contact-sheet links", () => { + render( + , + ); + + const album = screen.getByRole("link", { name: /heimspiel gegen nord/i }); + expect(album.getAttribute("href")).toBe("/redaktion/alben/heimspiel"); + expect(screen.getByText("24 Fotos")).not.toBeNull(); + expect(screen.getByAltText("Titelbild: Heimspiel gegen Nord").getAttribute("src")).toBe( + "/api/assets/cover-1/thumbnail", + ); +}); + +test("renders a labelled photo search and descriptive contact-sheet metadata", () => { + render( + , + ); + + expect(screen.getByRole("search", { name: /fotos in heimspiel gegen nord durchsuchen/i })).not.toBeNull(); + expect((screen.getByRole("searchbox", { name: /suchbegriff/i }) as HTMLInputElement).value).toBe("Tor"); + expect(screen.getByAltText("tor-des-sieges.jpg").getAttribute("src")).toBe( + "/api/assets/asset-1/thumbnail", + ); + expect(screen.getByText("tor-des-sieges.jpg")).not.toBeNull(); + expect(screen.getByText(/1 foto gefunden/i)).not.toBeNull(); +}); diff --git a/src/modules/albums/catalog-content.tsx b/src/modules/albums/catalog-content.tsx new file mode 100644 index 0000000..0ab8f50 --- /dev/null +++ b/src/modules/albums/catalog-content.tsx @@ -0,0 +1,136 @@ +/* eslint-disable @next/next/no-img-element */ + +import Link from "next/link"; + +import type { ImmichSearchPage } from "@/modules/immich/types"; + +import type { VisibleAlbum } from "./catalog"; + +export function AlbumContactSheet({ albums }: Readonly<{ albums: VisibleAlbum[] }>) { + return ( +
    + {albums.map((album) => ( +
  • + +
    + {album.albumThumbnailAssetId ? ( + {`Titelbild: + ) : ( +
    + Kein Titelbild +
    + )} +
    + {album.albumName} + {formatCount(album.assetCount, "Foto")} +
    +
    + +
  • + ))} +
+ ); +} + +export function PhotoContactSheet({ + albumId, + albumName, + page, + query, +}: Readonly<{ + albumId?: string; + albumName: string; + page: ImmichSearchPage; + query: string; +}>) { + return ( + <> +
+ +
+ + +
+
+ +

+ {formatCount(page.total, "Foto")} gefunden +

+ + {page.items.length === 0 ? ( +

Keine Fotos passen zu dieser Suche. Ändern Sie den Suchbegriff oder wählen Sie ein anderes Album.

+ ) : ( +
    + {page.items.map((asset) => ( +
  • +
    + {asset.originalFileName} +
    + {asset.originalFileName} + {formatDate(asset.localDateTime ?? asset.fileCreatedAt)} +
    +
    +
  • + ))} +
+ )} + + {albumId ? : null} + + ); +} + +function PhotoPagination({ albumId, page, query }: Readonly<{ albumId: string; page: ImmichSearchPage; query: string }>) { + if (page.previousPage === null && page.nextPage === null) { + return null; + } + + return ( + + ); +} + +function thumbnailUrl(assetId: string): string { + return `/api/assets/${encodeURIComponent(assetId)}/thumbnail`; +} + +function pageHref(albumId: string, page: number, query: string): string { + const parameters = new URLSearchParams({ page: String(page) }); + if (query) { + parameters.set("suche", query); + } + return `/redaktion/alben/${encodeURIComponent(albumId)}?${parameters.toString()}`; +} + +function formatCount(count: number, noun: string): string { + return `${count} ${noun}${count === 1 ? "" : "s"}`; +} + +function formatDate(value: string | null): string { + if (!value) { + return "Ohne Zeitangabe"; + } + + const date = new Date(value); + if (Number.isNaN(date.valueOf())) { + return "Ohne Zeitangabe"; + } + return new Intl.DateTimeFormat("de-DE", { dateStyle: "medium" }).format(date); +} diff --git a/src/modules/albums/catalog.test.ts b/src/modules/albums/catalog.test.ts new file mode 100644 index 0000000..552d625 --- /dev/null +++ b/src/modules/albums/catalog.test.ts @@ -0,0 +1,127 @@ +import { expect, test, vi } from "vitest"; + +import { + AlbumCatalogError, + createAlbumCatalog, +} from "./catalog"; +import type { ImmichClient } from "@/modules/immich/types"; + +const allowedAlbum = { + id: "allowed", + albumName: "Heimspiel gegen Nord", + description: null, + albumThumbnailAssetId: "cover-1", + assetCount: 12, +}; + +function createCatalog(options?: { + grantedAlbumIds?: string[]; + searchError?: Error; +}) { + const grants = { + getGrantedAlbumIds: vi.fn().mockResolvedValue(options?.grantedAlbumIds ?? ["allowed"]), + }; + const immich = { + listAlbums: vi.fn().mockResolvedValue([allowedAlbum, { ...allowedAlbum, id: "other" }]), + searchPhotos: vi.fn().mockImplementation(async () => { + if (options?.searchError) throw options.searchError; + return { items: [], total: 0, nextPage: null, previousPage: null }; + }), + }; + + return { + catalog: createAlbumCatalog({ grants, immich }), + grants, + immich, + }; +} + +test("ignores a caller-supplied album outside the editorial grants", async () => { + const { catalog, immich } = createCatalog({ grantedAlbumIds: ["allowed"] }); + + await catalog.searchVisiblePhotos("editorial-1", { + requestedAlbumId: "forbidden", + description: "tor", + page: 1, + }); + + expect(immich.searchPhotos).toHaveBeenCalledWith( + expect.objectContaining({ albumIds: ["allowed"], description: "tor", type: "IMAGE" }), + ); +}); + +test("uses a requested album only when it is in the current editorial grants", async () => { + const { catalog, immich } = createCatalog({ grantedAlbumIds: ["allowed", "also-allowed"] }); + + await catalog.searchVisiblePhotos("editorial-1", { requestedAlbumId: "also-allowed", page: 1 }); + + expect(immich.searchPhotos).toHaveBeenCalledWith( + expect.objectContaining({ albumIds: ["also-allowed"], type: "IMAGE" }), + ); +}); + +test("does not call Immich when an editorial has no current album grants", async () => { + const { catalog, immich } = createCatalog({ grantedAlbumIds: [] }); + + await expect(catalog.searchVisiblePhotos("editorial-1", { page: 1 })).resolves.toEqual({ + items: [], + total: 0, + nextPage: null, + previousPage: null, + }); + expect(immich.searchPhotos).not.toHaveBeenCalled(); +}); + +test("reads grants for every search so a revoked grant is immediately excluded", async () => { + const { catalog, grants, immich } = createCatalog({ grantedAlbumIds: ["allowed"] }); + grants.getGrantedAlbumIds.mockResolvedValueOnce(["allowed"]).mockResolvedValueOnce([]); + + await catalog.searchVisiblePhotos("editorial-1", { page: 1 }); + await catalog.searchVisiblePhotos("editorial-1", { page: 1 }); + + expect(immich.searchPhotos).toHaveBeenCalledTimes(1); +}); + +test("normalizes descriptions and bounds invalid pagination before sending an upstream request", async () => { + const { catalog, immich } = createCatalog(); + + await catalog.searchVisiblePhotos("editorial-1", { + description: " Tor\n des\tSieges ", + page: Number.POSITIVE_INFINITY, + }); + + expect(immich.searchPhotos).toHaveBeenCalledWith({ + albumIds: ["allowed"], + description: "Tor des Sieges", + type: "IMAGE", + page: 1, + size: 60, + }); + + await catalog.searchVisiblePhotos("editorial-1", { page: 100_000 }); + expect(immich.searchPhotos).toHaveBeenLastCalledWith( + expect.objectContaining({ page: 1_000 }), + ); +}); + +test("only returns the current editorial's albums from the Immich album list", async () => { + const { catalog } = createCatalog({ grantedAlbumIds: ["allowed"] }); + + await expect(catalog.getVisibleAlbums("editorial-1")).resolves.toEqual([allowedAlbum]); +}); + +test("maps an Immich search outage to the catalog's stable unavailable state", async () => { + const { catalog } = createCatalog({ searchError: new Error("upstream down") }); + + await expect(catalog.searchVisiblePhotos("editorial-1", { page: 1 })).rejects.toEqual( + new AlbumCatalogError("IMMICH_UNAVAILABLE"), + ); +}); + +test("does not expose a caller-controlled asset type in the catalog contract", async () => { + const { catalog, immich } = createCatalog(); + + await catalog.searchVisiblePhotos("editorial-1", { page: 2, type: "VIDEO" } as never); + + expect(immich.searchPhotos).toHaveBeenCalledWith(expect.objectContaining({ type: "IMAGE" })); +}); diff --git a/src/modules/albums/catalog.ts b/src/modules/albums/catalog.ts new file mode 100644 index 0000000..1ba04ff --- /dev/null +++ b/src/modules/albums/catalog.ts @@ -0,0 +1,115 @@ +import "server-only"; + +import { albumGrantService } from "@/modules/albums/grants"; +import { immichClient } from "@/modules/immich/client"; +import type { ImmichAlbumSummary, ImmichClient, ImmichSearchPage } from "@/modules/immich/types"; + +export const PHOTO_PAGE_SIZE = 60; +export const MAX_PHOTO_PAGE = 1_000; +const MAX_DESCRIPTION_LENGTH = 200; + +export type VisibleAlbum = ImmichAlbumSummary; + +export type SearchVisiblePhotosInput = { + requestedAlbumId?: string; + description?: unknown; + page?: unknown; +}; + +export type AlbumCatalogDependencies = { + grants: Pick; + immich: Pick; +}; + +export class AlbumCatalogError extends Error { + readonly name = "AlbumCatalogError"; + + constructor(readonly code: "IMMICH_UNAVAILABLE") { + super(code); + } +} + +export function createAlbumCatalog({ grants, immich }: AlbumCatalogDependencies) { + return { + async getVisibleAlbums(editorialId: string): Promise { + const [grantedAlbumIds, albums] = await Promise.all([ + currentGrantIds(grants, editorialId), + loadAlbums(immich), + ]); + const granted = new Set(grantedAlbumIds); + return albums.filter((album) => granted.has(album.id)); + }, + + async searchVisiblePhotos( + editorialId: string, + input: SearchVisiblePhotosInput, + ): Promise { + const grantedAlbumIds = await currentGrantIds(grants, editorialId); + const albumIds = authorizedSearchAlbums(grantedAlbumIds, input.requestedAlbumId); + if (albumIds.length === 0) { + return emptySearchPage(); + } + + const description = normalizeDescription(input.description); + try { + return await immich.searchPhotos({ + albumIds, + ...(description === undefined ? {} : { description }), + type: "IMAGE", + page: normalizePage(input.page), + size: PHOTO_PAGE_SIZE, + }); + } catch { + throw new AlbumCatalogError("IMMICH_UNAVAILABLE"); + } + }, + }; +} + +function emptySearchPage(): ImmichSearchPage { + return { items: [], total: 0, nextPage: null, previousPage: null }; +} + +async function currentGrantIds( + grants: Pick, + editorialId: string, +): Promise { + return [...new Set(await grants.getGrantedAlbumIds(editorialId))]; +} + +function authorizedSearchAlbums(grantedAlbumIds: string[], requestedAlbumId: string | undefined): string[] { + if (requestedAlbumId && grantedAlbumIds.includes(requestedAlbumId)) { + return [requestedAlbumId]; + } + return grantedAlbumIds; +} + +function normalizeDescription(description: unknown): string | undefined { + if (typeof description !== "string") { + return undefined; + } + const normalized = description.replace(/\s+/g, " ").trim().slice(0, MAX_DESCRIPTION_LENGTH); + return normalized || undefined; +} + +function normalizePage(page: unknown): number { + if (typeof page !== "number" || !Number.isFinite(page) || !Number.isInteger(page)) { + return 1; + } + return Math.min(MAX_PHOTO_PAGE, Math.max(1, page)); +} + +async function loadAlbums( + immich: Pick, +): Promise { + try { + return await immich.listAlbums(); + } catch { + throw new AlbumCatalogError("IMMICH_UNAVAILABLE"); + } +} + +export const albumCatalog = createAlbumCatalog({ + grants: albumGrantService, + immich: immichClient, +}); diff --git a/src/modules/immich/types.ts b/src/modules/immich/types.ts index 6f5962f..a04a2b8 100644 --- a/src/modules/immich/types.ts +++ b/src/modules/immich/types.ts @@ -38,7 +38,7 @@ export interface ImmichClient { listAlbums(signal?: AbortSignal): Promise; getAlbum(albumId: string, signal?: AbortSignal): Promise; searchPhotos( - input: { albumIds: string[]; description?: string; page: number; size: number }, + input: { albumIds: string[]; description?: string; page: number; size: number; type?: "IMAGE" }, signal?: AbortSignal, ): Promise; getThumbnail(assetId: string, signal?: AbortSignal): Promise; From 846904f3dba6eb9b505c0b054693b16f2bae6828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 22:32:18 +0200 Subject: [PATCH 14/29] fix: harden editorial thumbnail authorization --- src/app/admin/redaktionen/[id]/alben/page.tsx | 2 +- .../assets/[assetId]/thumbnail/route.test.ts | 68 ++++++++++++++----- .../[assetId]/thumbnail/thumbnail-handler.ts | 33 +++++---- src/app/globals.css | 4 ++ src/components/brand/logo.test.tsx | 34 ++++++++++ src/components/brand/logo.tsx | 11 +-- src/modules/albums/catalog.test.ts | 16 +++++ src/modules/albums/catalog.ts | 17 ++++- src/modules/immich/client.test.ts | 23 +++++++ src/modules/immich/client.ts | 9 +++ src/modules/immich/types.ts | 1 + 11 files changed, 182 insertions(+), 36 deletions(-) create mode 100644 src/components/brand/logo.test.tsx diff --git a/src/app/admin/redaktionen/[id]/alben/page.tsx b/src/app/admin/redaktionen/[id]/alben/page.tsx index d1659d8..728f642 100644 --- a/src/app/admin/redaktionen/[id]/alben/page.tsx +++ b/src/app/admin/redaktionen/[id]/alben/page.tsx @@ -65,7 +65,7 @@ export default async function EditorialAlbumsPage({ {`Titelbild ) : ( diff --git a/src/app/api/assets/[assetId]/thumbnail/route.test.ts b/src/app/api/assets/[assetId]/thumbnail/route.test.ts index e4452fc..f0d2767 100644 --- a/src/app/api/assets/[assetId]/thumbnail/route.test.ts +++ b/src/app/api/assets/[assetId]/thumbnail/route.test.ts @@ -28,9 +28,9 @@ function thumbnail() { function createHandler(options?: { editorialError?: Error; grantedAlbumIds?: string[]; - albumAssets?: Array<{ id: string; type: "IMAGE"; albums: Array<{ id: string }> }>; - albumError?: Error; - adminAlbums?: typeof grantedAlbum[]; + assetAlbumIds?: string[]; + assetAlbumLookupError?: Error; + adminAlbumThumbnailAssetId?: string | null; }) { const dependencies = { requireActiveEditorial: vi @@ -42,14 +42,14 @@ function createHandler(options?: { requireAdmin: vi.fn().mockResolvedValue({ userId: "admin-1" }), getGrantedAlbumIds: vi.fn().mockResolvedValue(options?.grantedAlbumIds ?? ["allowed"]), immich: { - listAlbums: vi.fn().mockResolvedValue(options?.adminAlbums ?? [grantedAlbum]), + listAlbumsForAsset: vi.fn().mockImplementation(async () => { + if (options?.assetAlbumLookupError) throw options.assetAlbumLookupError; + return (options?.assetAlbumIds ?? ["allowed"]).map((id) => ({ id })); + }), getAlbum: vi.fn().mockImplementation(async () => { - if (options?.albumError) throw options.albumError; return { ...grantedAlbum, - assets: options?.albumAssets ?? [ - { id: "asset-1", type: "IMAGE", albums: [{ id: "allowed" }] }, - ], + albumThumbnailAssetId: options?.adminAlbumThumbnailAssetId ?? "cover-1", }; }), getThumbnail: vi.fn().mockResolvedValue(thumbnail()), @@ -58,15 +58,20 @@ function createHandler(options?: { return { handler: createThumbnailHandler(dependencies), dependencies }; } -function call(handler: ReturnType, assetId = "asset-1") { - return handler(new Request("http://portal.test/api/assets/asset-1/thumbnail"), { +function call( + handler: ReturnType, + assetId = "asset-1", + albumId?: string, +) { + const query = albumId ? `?albumId=${encodeURIComponent(albumId)}` : ""; + return handler(new Request(`http://portal.test/api/assets/${assetId}/thumbnail${query}`), { params: Promise.resolve({ assetId }), }); } test("streams a thumbnail when the requested asset belongs to any current grant", async () => { const { handler, dependencies } = createHandler({ - albumAssets: [{ id: "asset-1", type: "IMAGE", albums: [{ id: "other" }, { id: "allowed" }] }], + assetAlbumIds: ["other", "allowed"], }); const response = await call(handler); @@ -83,13 +88,14 @@ test("refuses a thumbnail immediately after its last grant is revoked", async () const response = await call(handler); expect(response.status).toBe(404); + expect(dependencies.immich.listAlbumsForAsset).not.toHaveBeenCalled(); expect(dependencies.immich.getAlbum).not.toHaveBeenCalled(); expect(dependencies.immich.getThumbnail).not.toHaveBeenCalled(); }); test("uses an identical generic 404 for forbidden and missing assets", async () => { - const forbidden = createHandler({ albumAssets: [{ id: "different", type: "IMAGE", albums: [{ id: "allowed" }] }] }); - const missing = createHandler({ albumError: new Error("IMMICH_NOT_FOUND") }); + const forbidden = createHandler({ assetAlbumIds: ["different"] }); + const missing = createHandler({ assetAlbumLookupError: new Error("IMMICH_NOT_FOUND") }); const [forbiddenResponse, missingResponse] = await Promise.all([ call(forbidden.handler), @@ -107,25 +113,53 @@ test("uses an identical generic 404 for forbidden and missing assets", async () test("allows an admin only to load an existing Immich album cover", async () => { const { handler, dependencies } = createHandler({ editorialError: new PrincipalAuthorizationError("ADMIN_REQUIRED"), - adminAlbums: [grantedAlbum], + adminAlbumThumbnailAssetId: "cover-1", }); - const response = await call(handler, "cover-1"); + const response = await call(handler, "cover-1", "allowed"); expect(response.status).toBe(200); expect(dependencies.requireAdmin).toHaveBeenCalledTimes(1); expect(dependencies.getGrantedAlbumIds).not.toHaveBeenCalled(); + expect(dependencies.immich.getAlbum).toHaveBeenCalledWith("allowed"); expect(dependencies.immich.getThumbnail).toHaveBeenCalledWith("cover-1"); }); test("does not let an admin proxy an arbitrary non-cover asset", async () => { const { handler, dependencies } = createHandler({ editorialError: new PrincipalAuthorizationError("ADMIN_REQUIRED"), - adminAlbums: [grantedAlbum], + adminAlbumThumbnailAssetId: "cover-1", }); - const response = await call(handler, "asset-not-a-cover"); + const response = await call(handler, "asset-not-a-cover", "allowed"); expect(response.status).toBe(404); expect(dependencies.immich.getThumbnail).not.toHaveBeenCalled(); }); + +test("uses one asset-album membership lookup for a 60-photo gallery regardless of grant count", async () => { + const grantedAlbumIds = Array.from({ length: 60 }, (_, index) => `grant-${index}`); + const { handler, dependencies } = createHandler({ + grantedAlbumIds, + assetAlbumIds: ["grant-59"], + }); + + const response = await call(handler); + + expect(response.status).toBe(200); + expect(dependencies.immich.listAlbumsForAsset).toHaveBeenCalledTimes(1); + expect(dependencies.immich.listAlbumsForAsset).toHaveBeenCalledWith("asset-1"); + expect(dependencies.immich.getAlbum).not.toHaveBeenCalled(); +}); + +test("does not let an admin use a cover without binding it to an album", async () => { + const { handler, dependencies } = createHandler({ + editorialError: new PrincipalAuthorizationError("ADMIN_REQUIRED"), + }); + + const response = await call(handler, "cover-1"); + + expect(response.status).toBe(404); + expect(dependencies.immich.getAlbum).not.toHaveBeenCalled(); + expect(dependencies.immich.getThumbnail).not.toHaveBeenCalled(); +}); diff --git a/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts b/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts index e4660cf..33793b2 100644 --- a/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts +++ b/src/app/api/assets/[assetId]/thumbnail/thumbnail-handler.ts @@ -8,8 +8,8 @@ import type { ImmichBinary } from "@/modules/immich/types"; type ThumbnailRouteContext = Readonly<{ params: Promise<{ assetId: string }> }>; type ThumbnailImmich = { - listAlbums(): Promise>; - getAlbum(albumId: string): Promise<{ assets: Array<{ id: string; type: "IMAGE" }> }>; + listAlbumsForAsset(assetId: string): Promise>; + getAlbum(albumId: string): Promise<{ albumThumbnailAssetId: string | null }>; getThumbnail(assetId: string): Promise; }; @@ -25,6 +25,7 @@ type Access = { kind: "admin" } | { kind: "editorial"; editorialId: string }; export function createThumbnailHandler(dependencies: ThumbnailHandlerDependencies) { return async function GET(request: Request, context: ThumbnailRouteContext): Promise { try { + const requestedUrl = new URL(request.url); const { assetId } = await context.params; if (!isSafeAssetId(assetId)) { return genericNotFound(); @@ -33,7 +34,11 @@ export function createThumbnailHandler(dependencies: ThumbnailHandlerDependencie const access = await authorizeRequest(dependencies, request.headers); const authorized = access.kind === "admin" - ? await isAdminAlbumCover(dependencies.immich, assetId) + ? await isAdminAlbumCover( + dependencies.immich, + assetId, + requestedUrl.searchParams.get("albumId"), + ) : await isGrantedEditorialAsset(dependencies, access.editorialId, assetId); if (!authorized) { return genericNotFound(); @@ -74,17 +79,21 @@ async function isGrantedEditorialAsset( return false; } - const grantedAlbums = await Promise.all( - grantedAlbumIds.map((albumId) => dependencies.immich.getAlbum(albumId)), - ); - return grantedAlbums.some((album) => - album.assets.some((asset) => asset.id === assetId && asset.type === "IMAGE"), - ); + const assetAlbums = await dependencies.immich.listAlbumsForAsset(assetId); + const granted = new Set(grantedAlbumIds); + return assetAlbums.some((album) => granted.has(album.id)); } -async function isAdminAlbumCover(immich: ThumbnailImmich, assetId: string): Promise { - const albums = await immich.listAlbums(); - return albums.some((album) => album.albumThumbnailAssetId === assetId); +async function isAdminAlbumCover( + immich: ThumbnailImmich, + assetId: string, + albumId: string | null, +): Promise { + if (!albumId || !isSafeAssetId(albumId)) { + return false; + } + const album = await immich.getAlbum(albumId); + return album.albumThumbnailAssetId === assetId; } function thumbnailResponse(thumbnail: ImmichBinary): Response { diff --git a/src/app/globals.css b/src/app/globals.css index 85490aa..814ba9e 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -334,6 +334,10 @@ a { text-underline-offset: 0.28em; } +.portal-masthead :focus-visible { + outline-color: var(--paper); +} + .editorial-work-surface { width: min(100%, 108rem); margin: 0 auto; diff --git a/src/components/brand/logo.test.tsx b/src/components/brand/logo.test.tsx new file mode 100644 index 0000000..8319c65 --- /dev/null +++ b/src/components/brand/logo.test.tsx @@ -0,0 +1,34 @@ +// @vitest-environment jsdom + +import { readFileSync } from "node:fs"; + +import { render, screen } from "@testing-library/react"; +import { expect, test } from "vitest"; + +import { PortalShell } from "@/components/layout/portal-shell"; +import { BrandLogo } from "./logo"; + +test("uses each supplied logo's true intrinsic dimensions", () => { + const { rerender } = render(); + const logo = screen.getByAltText("Leon Tonhäuser Sportfotografie"); + expect(logo.getAttribute("width")).toBe("250"); + expect(logo.getAttribute("height")).toBe("250"); + + rerender(); + expect(logo.getAttribute("width")).toBe("1000"); + expect(logo.getAttribute("height")).toBe("1000"); +}); + +test("keeps masthead controls keyboard-focusable with a paper-coloured focus outline", () => { + render( + +

Archiv

+
, + ); + + expect(screen.getByRole("link", { name: /zur albenübersicht/i }).tagName).toBe("A"); + expect(screen.getByRole("link", { name: "Alben" }).tagName).toBe("A"); + const styles = readFileSync("src/app/globals.css", "utf8"); + expect(styles).toContain(".portal-masthead :focus-visible"); + expect(styles).toContain("outline-color: var(--paper)"); +}); diff --git a/src/components/brand/logo.tsx b/src/components/brand/logo.tsx index 95398f6..5c23c5b 100644 --- a/src/components/brand/logo.tsx +++ b/src/components/brand/logo.tsx @@ -5,15 +5,18 @@ type BrandLogoProps = { }; export function BrandLogo({ variant }: Readonly) { - const source = variant === "white" ? "/brand/logo-white.png" : "/brand/logo-black.png"; + const logo = + variant === "white" + ? { source: "/brand/logo-white.png", width: 250, height: 250 } + : { source: "/brand/logo-black.png", width: 1000, height: 1000 }; return ( Leon Tonhäuser Sportfotografie ); } diff --git a/src/modules/albums/catalog.test.ts b/src/modules/albums/catalog.test.ts index 552d625..1989e8a 100644 --- a/src/modules/albums/catalog.test.ts +++ b/src/modules/albums/catalog.test.ts @@ -104,6 +104,22 @@ test("normalizes descriptions and bounds invalid pagination before sending an up ); }); +test("passes a bounded decimal page string from the SSR query through to Immich", async () => { + const { catalog, immich } = createCatalog(); + + await catalog.searchVisiblePhotos("editorial-1", { page: "2" }); + expect(immich.searchPhotos).toHaveBeenLastCalledWith(expect.objectContaining({ page: 2 })); + + await catalog.searchVisiblePhotos("editorial-1", { page: "not-a-page" }); + expect(immich.searchPhotos).toHaveBeenLastCalledWith(expect.objectContaining({ page: 1 })); + + await catalog.searchVisiblePhotos("editorial-1", { page: "-2" }); + expect(immich.searchPhotos).toHaveBeenLastCalledWith(expect.objectContaining({ page: 1 })); + + await catalog.searchVisiblePhotos("editorial-1", { page: "100000" }); + expect(immich.searchPhotos).toHaveBeenLastCalledWith(expect.objectContaining({ page: 1_000 })); +}); + test("only returns the current editorial's albums from the Immich album list", async () => { const { catalog } = createCatalog({ grantedAlbumIds: ["allowed"] }); diff --git a/src/modules/albums/catalog.ts b/src/modules/albums/catalog.ts index 1ba04ff..3c506b6 100644 --- a/src/modules/albums/catalog.ts +++ b/src/modules/albums/catalog.ts @@ -93,10 +93,23 @@ function normalizeDescription(description: unknown): string | undefined { } function normalizePage(page: unknown): number { - if (typeof page !== "number" || !Number.isFinite(page) || !Number.isInteger(page)) { + const parsed = parsePage(page); + if (parsed === null) { return 1; } - return Math.min(MAX_PHOTO_PAGE, Math.max(1, page)); + return Math.min(MAX_PHOTO_PAGE, Math.max(1, parsed)); +} + +function parsePage(page: unknown): number | null { + if (typeof page === "number") { + return Number.isFinite(page) && Number.isInteger(page) ? page : null; + } + if (typeof page !== "string" || !/^\d+$/.test(page)) { + return null; + } + + const parsed = Number(page); + return Number.isSafeInteger(parsed) ? parsed : MAX_PHOTO_PAGE; } async function loadAlbums( diff --git a/src/modules/immich/client.test.ts b/src/modules/immich/client.test.ts index 6183811..b700169 100644 --- a/src/modules/immich/client.test.ts +++ b/src/modules/immich/client.test.ts @@ -38,6 +38,29 @@ test("lists albums through the documented API with server-side authentication", await expect(client.listAlbums()).resolves.toEqual([immichAlbum]); }); +test("lists only the albums containing an asset through the documented assetId query", async () => { + server.use( + http.get(`${baseUrl}/api/albums`, ({ request }) => { + const url = new URL(request.url); + expect(url.searchParams.get("assetId")).toBe("asset-1"); + expect(request.headers.get("x-api-key")).toBe(apiKey); + return HttpResponse.json([immichAlbum]); + }), + ); + + await expect(client.listAlbumsForAsset("asset-1")).resolves.toEqual([immichAlbum]); +}); + +test("validates the narrow asset-album response before authorizing a thumbnail", async () => { + server.use( + http.get(`${baseUrl}/api/albums`, () => HttpResponse.json([{ id: "missing-album-fields" }])), + ); + + await expect(client.listAlbumsForAsset("asset-1")).rejects.toMatchObject({ + code: "IMMICH_INVALID_RESPONSE", + }); +}); + test("gets album details from the documented album endpoint", async () => { server.use( http.get(`${baseUrl}/api/albums/album-1`, ({ request }) => { diff --git a/src/modules/immich/client.ts b/src/modules/immich/client.ts index 0d4025c..a5f1e2e 100644 --- a/src/modules/immich/client.ts +++ b/src/modules/immich/client.ts @@ -308,6 +308,15 @@ export function createImmichClient({ listAlbums(signal) { return requestJson("/albums", { method: "GET" }, z.array(albumSummarySchema), signal); }, + listAlbumsForAsset(assetId, signal) { + const query = new URLSearchParams({ assetId }); + return requestJson( + `/albums?${query.toString()}`, + { method: "GET" }, + z.array(albumSummarySchema), + signal, + ); + }, getAlbum(albumId, signal) { return requestJson( `/albums/${encodeURIComponent(albumId)}`, diff --git a/src/modules/immich/types.ts b/src/modules/immich/types.ts index a04a2b8..242bcac 100644 --- a/src/modules/immich/types.ts +++ b/src/modules/immich/types.ts @@ -36,6 +36,7 @@ export type ImmichBinary = { export interface ImmichClient { listAlbums(signal?: AbortSignal): Promise; + listAlbumsForAsset(assetId: string, signal?: AbortSignal): Promise; getAlbum(albumId: string, signal?: AbortSignal): Promise; searchPhotos( input: { albumIds: string[]; description?: string; page: number; size: number; type?: "IMAGE" }, From 22fe6bf6591b46faed0f334c6ccc4d270e80faa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Sun, 9 Aug 2026 22:52:27 +0200 Subject: [PATCH 15/29] feat: add usage and download intent accounting --- drizzle/0002_accounting_intents.sql | 7 + drizzle/meta/0002_snapshot.json | 1472 +++++++++++++++++++++++++ drizzle/meta/_journal.json | 7 + src/db/schema/usages.ts | 24 +- src/modules/downloads/service.test.ts | 150 +++ src/modules/downloads/service.ts | 177 +++ src/modules/immich/client.test.ts | 13 + src/modules/immich/client.ts | 13 + src/modules/immich/types.ts | 3 +- src/modules/usages/service.test.ts | 271 +++++ src/modules/usages/service.ts | 422 +++++++ src/modules/usages/types.ts | 113 ++ tests/db/postgres.ts | 5 + tests/db/usage-accounting.test.ts | 333 ++++++ 14 files changed, 3008 insertions(+), 2 deletions(-) create mode 100644 drizzle/0002_accounting_intents.sql create mode 100644 drizzle/meta/0002_snapshot.json create mode 100644 src/modules/downloads/service.test.ts create mode 100644 src/modules/downloads/service.ts create mode 100644 src/modules/usages/service.test.ts create mode 100644 src/modules/usages/service.ts create mode 100644 src/modules/usages/types.ts create mode 100644 tests/db/usage-accounting.test.ts diff --git a/drizzle/0002_accounting_intents.sql b/drizzle/0002_accounting_intents.sql new file mode 100644 index 0000000..c386136 --- /dev/null +++ b/drizzle/0002_accounting_intents.sql @@ -0,0 +1,7 @@ +ALTER TABLE "download_events" ADD COLUMN "intent_kind" text DEFAULT 'new_usage' NOT NULL;--> statement-breakpoint +ALTER TABLE "download_events" ADD COLUMN "request_fingerprint" varchar(64);--> statement-breakpoint +UPDATE "download_events" +SET "request_fingerprint" = md5("editorial_account_id"::text || ':' || "id"::text) || md5("id"::text || ':' || "editorial_account_id"::text);--> statement-breakpoint +ALTER TABLE "download_events" ALTER COLUMN "request_fingerprint" SET NOT NULL;--> statement-breakpoint +ALTER TABLE "download_events" ADD CONSTRAINT "download_events_intent_kind_check" CHECK ("download_events"."intent_kind" in ('new_usage', 'repeat_download'));--> statement-breakpoint +ALTER TABLE "download_events" ADD CONSTRAINT "download_events_request_fingerprint_hex_check" CHECK ("download_events"."request_fingerprint" ~ '^[0-9a-f]{64}$'); diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json new file mode 100644 index 0000000..6f1926f --- /dev/null +++ b/drizzle/meta/0002_snapshot.json @@ -0,0 +1,1472 @@ +{ + "id": "0cdb7b32-1eb5-4dcf-9949-3862dbbad2b4", + "prevId": "cfd5f4d1-55ac-46d9-9667-cd156f26e070", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.album_grants": { + "name": "album_grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "granted_by_user_id": { + "name": "granted_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "album_grants_editorial_account_id_idx": { + "name": "album_grants_editorial_account_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_immich_album_id_idx": { + "name": "album_grants_immich_album_id_idx", + "columns": [ + { + "expression": "immich_album_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "album_grants_editorial_account_id_editorial_accounts_id_fk": { + "name": "album_grants_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "album_grants", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "album_grants_granted_by_user_id_user_id_fk": { + "name": "album_grants_granted_by_user_id_user_id_fk", + "tableFrom": "album_grants", + "tableTo": "user", + "columnsFrom": [ + "granted_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_events": { + "name": "audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "previous_values": { + "name": "previous_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_values": { + "name": "new_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "audit_events_actor_user_id_user_id_fk": { + "name": "audit_events_actor_user_id_user_id_fk", + "tableFrom": "audit_events", + "tableTo": "user", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "portal_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'EDITORIAL'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_report_items": { + "name": "billing_report_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id_snapshot": { + "name": "immich_asset_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose_snapshot": { + "name": "purpose_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference_snapshot": { + "name": "internal_reference_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "billing_report_items_report_usage_unique": { + "name": "billing_report_items_report_usage_unique", + "columns": [ + { + "expression": "billing_report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "usage_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_report_items_billing_report_id_billing_reports_id_fk": { + "name": "billing_report_items_billing_report_id_billing_reports_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_report_items_usage_id_usages_id_fk": { + "name": "billing_report_items_usage_id_usages_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_reports": { + "name": "billing_reports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "report_number": { + "name": "report_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "period_starts_at": { + "name": "period_starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "period_ends_at": { + "name": "period_ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "billing_address_snapshot": { + "name": "billing_address_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "net_total_cents": { + "name": "net_total_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "report_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "pdf": { + "name": "pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "pdf_sha256": { + "name": "pdf_sha256", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finalized_at": { + "name": "finalized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_by_user_id": { + "name": "cancelled_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "billing_reports_report_number_unique": { + "name": "billing_reports_report_number_unique", + "columns": [ + { + "expression": "report_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "billing_reports_invoice_number_unique": { + "name": "billing_reports_invoice_number_unique", + "columns": [ + { + "expression": "invoice_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_reports_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_reports_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_reports", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_created_by_user_id_user_id_fk": { + "name": "billing_reports_created_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_cancelled_by_user_id_user_id_fk": { + "name": "billing_reports_cancelled_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "cancelled_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "billing_reports_pdf_sha256_hex_check": { + "name": "billing_reports_pdf_sha256_hex_check", + "value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'" + }, + "billing_reports_final_pdf_check": { + "name": "billing_reports_final_pdf_check", + "value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.billing_address_versions": { + "name": "billing_address_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_1": { + "name": "address_line_1", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_2": { + "name": "address_line_2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "superseded_by_id": { + "name": "superseded_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "billing_address_versions_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_address_versions_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_superseded_by_id_billing_address_versions_id_fk": { + "name": "billing_address_versions_superseded_by_id_billing_address_versions_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "superseded_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_created_by_user_id_user_id_fk": { + "name": "billing_address_versions_created_by_user_id_user_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.editorial_accounts": { + "name": "editorial_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "login_email": { + "name": "login_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "account_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending_email'" + }, + "current_price_cents": { + "name": "current_price_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "approval_notice_status": { + "name": "approval_notice_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_requested'" + }, + "current_billing_address_version_id": { + "name": "current_billing_address_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_version": { + "name": "accepted_terms_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_at": { + "name": "accepted_terms_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "privacy_acknowledged_at": { + "name": "privacy_acknowledged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "editorial_accounts_user_id_user_id_fk": { + "name": "editorial_accounts_user_id_user_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk": { + "name": "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "current_billing_address_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "editorial_accounts_user_id_unique": { + "name": "editorial_accounts_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + }, + "editorial_accounts_login_email_unique": { + "name": "editorial_accounts_login_email_unique", + "nullsNotDistinct": false, + "columns": [ + "login_email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.download_events": { + "name": "download_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authorized_at": { + "name": "authorized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "download_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'authorized'" + }, + "transferred_bytes": { + "name": "transferred_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "repeat_download_note": { + "name": "repeat_download_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent_kind": { + "name": "intent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'new_usage'" + }, + "request_fingerprint": { + "name": "request_fingerprint", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "download_events_editorial_idempotency_key_unique": { + "name": "download_events_editorial_idempotency_key_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "download_events_editorial_account_id_editorial_accounts_id_fk": { + "name": "download_events_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "download_events", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "download_events_usage_id_usages_id_fk": { + "name": "download_events_usage_id_usages_id_fk", + "tableFrom": "download_events", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "download_events_intent_kind_check": { + "name": "download_events_intent_kind_check", + "value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download')" + }, + "download_events_request_fingerprint_hex_check": { + "name": "download_events_request_fingerprint_hex_check", + "value": "\"download_events\".\"request_fingerprint\" ~ '^[0-9a-f]{64}$'" + } + }, + "isRLSEnabled": false + }, + "public.usages": { + "name": "usages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "immich_album_id_snapshot": { + "name": "immich_album_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference": { + "name": "internal_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "billing_status": { + "name": "billing_status", + "type": "usage_billing_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "usages_editorial_account_id_editorial_accounts_id_fk": { + "name": "usages_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "usages", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "usages_billing_report_id_billing_reports_id_fk": { + "name": "usages_billing_report_id_billing_reports_id_fk", + "tableFrom": "usages", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.portal_role": { + "name": "portal_role", + "schema": "public", + "values": [ + "ADMIN", + "EDITORIAL" + ] + }, + "public.report_status": { + "name": "report_status", + "schema": "public", + "values": [ + "draft", + "final", + "cancelled" + ] + }, + "public.account_status": { + "name": "account_status", + "schema": "public", + "values": [ + "pending_email", + "pending_approval", + "active", + "suspended", + "rejected" + ] + }, + "public.download_status": { + "name": "download_status", + "schema": "public", + "values": [ + "authorized", + "streaming", + "completed", + "failed_before_delivery", + "interrupted" + ] + }, + "public.usage_billing_status": { + "name": "usage_billing_status", + "schema": "public", + "values": [ + "open", + "billed", + "reopened" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 3201171..6a7c747 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -15,6 +15,13 @@ "when": 1786303607054, "tag": "0001_editorial_approval_notice", "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1786308409516, + "tag": "0002_accounting_intents", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/db/schema/usages.ts b/src/db/schema/usages.ts index 11c7bed..bba0bb7 100644 --- a/src/db/schema/usages.ts +++ b/src/db/schema/usages.ts @@ -1,4 +1,16 @@ -import { integer, pgEnum, pgTable, text, timestamp, uniqueIndex, uuid, bigint } from "drizzle-orm/pg-core"; +import { sql } from "drizzle-orm"; +import { + bigint, + check, + integer, + pgEnum, + pgTable, + text, + timestamp, + uniqueIndex, + uuid, + varchar, +} from "drizzle-orm/pg-core"; import { editorialAccounts } from "./editorials"; import { billingReports } from "./billing"; @@ -53,11 +65,21 @@ export const downloadEvents = pgTable( repeatDownloadNote: text("repeat_download_note"), requestId: uuid("request_id").notNull(), idempotencyKey: text("idempotency_key").notNull(), + intentKind: text("intent_kind").notNull().default("new_usage"), + requestFingerprint: varchar("request_fingerprint", { length: 64 }).notNull(), }, (table) => [ uniqueIndex("download_events_editorial_idempotency_key_unique").on( table.editorialAccountId, table.idempotencyKey, ), + check( + "download_events_intent_kind_check", + sql`${table.intentKind} in ('new_usage', 'repeat_download')`, + ), + check( + "download_events_request_fingerprint_hex_check", + sql`${table.requestFingerprint} ~ '^[0-9a-f]{64}$'`, + ), ], ); diff --git a/src/modules/downloads/service.test.ts b/src/modules/downloads/service.test.ts new file mode 100644 index 0000000..12052fa --- /dev/null +++ b/src/modules/downloads/service.test.ts @@ -0,0 +1,150 @@ +import { expect, test, vi } from "vitest"; + +import { + createDownloadService, + type PersistedRepeatIntent, + type RepeatDownloadRepository, + type RepeatIntentInput, +} from "./service"; +import { UsageAccountingError } from "@/modules/usages/types"; + +const editorialId = "11111111-1111-4111-8111-111111111111"; +const usageId = "44444444-4444-4444-8444-444444444444"; +const idempotencyKey = "55555555-5555-4555-8555-555555555555"; + +function createService() { + const intents = new Map(); + const events: RepeatIntentInput[] = []; + let active = true; + let usageOwner = editorialId; + let snapshotPrice = 1_500; + + const repository: RepeatDownloadRepository = { + async findIntent(requestEditorialId, key) { + return intents.get(`${requestEditorialId}:${key}`) ?? null; + }, + async createRepeatIntent(input) { + if (!active) throw new UsageAccountingError("EDITORIAL_NOT_ACTIVE"); + if (usageOwner !== input.editorialId) throw new UsageAccountingError("USAGE_NOT_FOUND"); + const key = `${input.editorialId}:${input.idempotencyKey}`; + const existing = intents.get(key); + if (existing) return existing; + events.push(input); + const intent: PersistedRepeatIntent = { + id: `download-${events.length}`, + usageId: input.usageId, + assetId: "asset-1", + priceCents: 0, + billable: false, + status: "authorized", + authorizedAt: new Date("2026-08-09T09:00:00.000Z"), + requestFingerprint: input.requestFingerprint, + kind: "repeat_download", + }; + intents.set(key, intent); + return intent; + }, + }; + + return { + service: createDownloadService({ repository }), + repository, + events, + setActive(value: boolean) { + active = value; + }, + setUsageOwner(value: string) { + usageOwner = value; + }, + setSnapshotPrice(value: number) { + snapshotPrice = value; + }, + getSnapshotPrice() { + return snapshotPrice; + }, + }; +} + +test("creates only a free authorized event for an owned prior usage", async () => { + const { service, events, getSnapshotPrice } = createService(); + + const intent = await service.createRepeatDownload({ + editorialId, + usageId, + note: " erneuter Abruf ", + idempotencyKey, + }); + + expect(intent).toMatchObject({ + usageId, + assetId: "asset-1", + priceCents: 0, + billable: false, + status: "authorized", + }); + expect(events).toEqual([expect.objectContaining({ note: "erneuter Abruf" })]); + expect(getSnapshotPrice()).toBe(1_500); +}); + +test("a changed usage snapshot price never changes the free repeat price", async () => { + const { service, setSnapshotPrice } = createService(); + setSnapshotPrice(9_900); + + await expect( + service.createRepeatDownload({ editorialId, usageId, idempotencyKey }), + ).resolves.toMatchObject({ priceCents: 0, billable: false }); +}); + +test("rejects a usage owned by another editorial without creating an event", async () => { + const { service, events, setUsageOwner } = createService(); + setUsageOwner("66666666-6666-4666-8666-666666666666"); + + await expect( + service.createRepeatDownload({ editorialId, usageId, idempotencyKey }), + ).rejects.toMatchObject({ code: "USAGE_NOT_FOUND" }); + expect(events).toHaveLength(0); +}); + +test("rejects a repeat for an inactive editorial", async () => { + const { service, events, setActive } = createService(); + setActive(false); + + await expect( + service.createRepeatDownload({ editorialId, usageId, idempotencyKey }), + ).rejects.toMatchObject({ code: "EDITORIAL_NOT_ACTIVE" }); + expect(events).toHaveLength(0); +}); + +test("returns the same free intent once for an equivalent retry", async () => { + const { service, events } = createService(); + const input = { editorialId, usageId, note: "noch einmal", idempotencyKey }; + + const first = await service.createRepeatDownload(input); + const second = await service.createRepeatDownload(input); + + expect(second).toEqual(first); + expect(events).toHaveLength(1); +}); + +test("rejects reuse of a repeat key with a materially different note", async () => { + const { service, events } = createService(); + await service.createRepeatDownload({ editorialId, usageId, note: "Web", idempotencyKey }); + + await expect( + service.createRepeatDownload({ editorialId, usageId, note: "Print", idempotencyKey }), + ).rejects.toMatchObject({ code: "IDEMPOTENCY_CONFLICT" }); + expect(events).toHaveLength(1); +}); + +test.each([ + ["x".repeat(201), idempotencyKey], + [undefined, "not-a-uuid"], +] as const)("rejects malformed repeat input before repository side effects", async (note, key) => { + const { service, repository } = createService(); + const findIntent = vi.spyOn(repository, "findIntent"); + + await expect( + service.createRepeatDownload({ editorialId, usageId, note, idempotencyKey: key }), + ).rejects.toMatchObject({ code: "INVALID_INPUT" }); + expect(findIntent).not.toHaveBeenCalled(); +}); diff --git a/src/modules/downloads/service.ts b/src/modules/downloads/service.ts new file mode 100644 index 0000000..d507155 --- /dev/null +++ b/src/modules/downloads/service.ts @@ -0,0 +1,177 @@ +import "server-only"; + +import { randomUUID } from "node:crypto"; + +import { and, eq } from "drizzle-orm"; +import type { NodePgDatabase } from "drizzle-orm/node-postgres"; + +import { db } from "@/db/client"; +import { downloadEvents, editorialAccounts, usages } from "@/db/schema"; +import type * as schema from "@/db/schema"; +import { + assertUuid, + type CreateRepeatDownloadInput, + type DownloadIntent, + normalizeOptionalText, + requestFingerprint, + UsageAccountingError, +} from "@/modules/usages/types"; +import { + findPersistedIntent, + lockEditorialAccounting, + resolveIntent, + type PersistedDownloadIntent, +} from "@/modules/usages/service"; + +export type PersistedRepeatIntent = PersistedDownloadIntent & { kind: "repeat_download" }; + +export type RepeatIntentInput = { + editorialId: string; + usageId: string; + note?: string; + idempotencyKey: string; + requestFingerprint: string; +}; + +export type RepeatDownloadRepository = { + findIntent(editorialId: string, idempotencyKey: string): Promise; + createRepeatIntent(input: RepeatIntentInput): Promise; +}; + +export function createDownloadService({ repository }: { repository: RepeatDownloadRepository }) { + return { + async createRepeatDownload(rawInput: CreateRepeatDownloadInput): Promise { + const input = normalizeRepeatInput(rawInput); + const fingerprint = requestFingerprint({ + kind: "repeat_download", + editorialId: input.editorialId, + usageId: input.usageId, + note: input.note ?? null, + }); + const existing = await repository.findIntent(input.editorialId, input.idempotencyKey); + if (existing) return resolveIntent(existing, fingerprint, "repeat_download"); + const persisted = await repository.createRepeatIntent({ + ...input, + requestFingerprint: fingerprint, + }); + return resolveIntent(persisted, fingerprint, "repeat_download"); + }, + }; +} + +export function createRepeatDownloadRepository( + database: NodePgDatabase, +): RepeatDownloadRepository { + return { + findIntent(editorialId, idempotencyKey) { + return findPersistedIntent(database, editorialId, idempotencyKey); + }, + + async createRepeatIntent(input) { + try { + return await database.transaction(async (transaction) => { + await lockEditorialAccounting(transaction, input.editorialId); + const [editorial] = await transaction + .select({ id: editorialAccounts.id, status: editorialAccounts.status }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, input.editorialId)) + .for("update") + .limit(1); + if (!editorial || editorial.status !== "active") { + throw new UsageAccountingError("EDITORIAL_NOT_ACTIVE"); + } + + const existing = await findPersistedIntent( + transaction, + input.editorialId, + input.idempotencyKey, + ); + if (existing) return asRepeatIntent(existing); + + const [usage] = await transaction + .select({ id: usages.id, assetId: usages.immichAssetId }) + .from(usages) + .where( + and( + eq(usages.id, input.usageId), + eq(usages.editorialAccountId, input.editorialId), + ), + ) + .for("update") + .limit(1); + if (!usage) throw new UsageAccountingError("USAGE_NOT_FOUND"); + + const authorizedAt = new Date(); + const [event] = await transaction + .insert(downloadEvents) + .values({ + editorialAccountId: input.editorialId, + usageId: usage.id, + immichAssetId: usage.assetId, + authorizedAt, + status: "authorized", + repeatDownloadNote: input.note, + requestId: randomUUID(), + idempotencyKey: input.idempotencyKey, + intentKind: "repeat_download", + requestFingerprint: input.requestFingerprint, + }) + .onConflictDoNothing({ + target: [downloadEvents.editorialAccountId, downloadEvents.idempotencyKey], + }) + .returning({ id: downloadEvents.id }); + if (!event) throw new RepeatIdempotencyRaceError(); + return { + id: event.id, + usageId: usage.id, + assetId: usage.assetId, + priceCents: 0, + billable: false, + status: "authorized" as const, + authorizedAt, + requestFingerprint: input.requestFingerprint, + kind: "repeat_download" as const, + }; + }); + } catch (error) { + if (!(error instanceof RepeatIdempotencyRaceError)) throw error; + const existing = await findPersistedIntent( + database, + input.editorialId, + input.idempotencyKey, + ); + if (existing) return asRepeatIntent(existing); + throw error; + } + }, + }; +} + +function normalizeRepeatInput(input: CreateRepeatDownloadInput): CreateRepeatDownloadInput { + if (!input || typeof input !== "object") throw new UsageAccountingError("INVALID_INPUT"); + assertUuid(input.editorialId); + assertUuid(input.usageId); + assertUuid(input.idempotencyKey); + const note = normalizeOptionalText(input.note, 200); + return { + editorialId: input.editorialId, + usageId: input.usageId, + ...(note === undefined ? {} : { note }), + idempotencyKey: input.idempotencyKey, + }; +} + +function asRepeatIntent(intent: PersistedDownloadIntent): PersistedRepeatIntent { + if (intent.kind !== "repeat_download") { + throw new UsageAccountingError("IDEMPOTENCY_CONFLICT"); + } + return { ...intent, kind: "repeat_download" }; +} + +class RepeatIdempotencyRaceError extends Error {} + +export const downloadService = createDownloadService({ + repository: createRepeatDownloadRepository(db), +}); + +export const createRepeatDownload = downloadService.createRepeatDownload; diff --git a/src/modules/immich/client.test.ts b/src/modules/immich/client.test.ts index b700169..568dde7 100644 --- a/src/modules/immich/client.test.ts +++ b/src/modules/immich/client.test.ts @@ -6,6 +6,7 @@ import { createImmichClient } from "./client"; import { immichAlbum, immichAlbumDetail, + immichAsset, immichMetadataSearchResponse, } from "../../../tests/fixtures/immich"; @@ -73,6 +74,18 @@ test("gets album details from the documented album endpoint", async () => { await expect(client.getAlbum("album-1")).resolves.toEqual(immichAlbumDetail); }); +test("gets current asset metadata immediately before accounting", async () => { + server.use( + http.get(`${baseUrl}/api/assets/asset-1`, ({ request }) => { + expect(request.method).toBe("GET"); + expect(request.headers.get("x-api-key")).toBe(apiKey); + return HttpResponse.json(immichAsset); + }), + ); + + await expect(client.getAsset("asset-1")).resolves.toEqual(immichAsset); +}); + test("forces IMAGE and authorized album IDs in metadata search", async () => { server.use( http.post(`${baseUrl}/api/search/metadata`, async ({ request }) => { diff --git a/src/modules/immich/client.ts b/src/modules/immich/client.ts index a5f1e2e..1ea6d5a 100644 --- a/src/modules/immich/client.ts +++ b/src/modules/immich/client.ts @@ -8,6 +8,7 @@ import { ImmichClientError, type ImmichErrorCode } from "./errors"; import type { ImmichAlbum, ImmichAlbumSummary, + ImmichAsset, ImmichBinary, ImmichClient, ImmichSearchPage, @@ -27,6 +28,10 @@ const assetSchema = z }) .passthrough(); +const currentAssetSchema = assetSchema.extend({ + type: z.enum(["IMAGE", "VIDEO"]), +}); + const albumSummarySchema = z .object({ id: z.string(), @@ -325,6 +330,14 @@ export function createImmichClient({ signal, ); }, + getAsset(assetId, signal) { + return requestJson( + `/assets/${encodeURIComponent(assetId)}`, + { method: "GET" }, + currentAssetSchema, + signal, + ); + }, searchPhotos(input, signal) { return requestJson( "/search/metadata", diff --git a/src/modules/immich/types.ts b/src/modules/immich/types.ts index 242bcac..74e8ba9 100644 --- a/src/modules/immich/types.ts +++ b/src/modules/immich/types.ts @@ -8,7 +8,7 @@ export type ImmichAlbumSummary = { export type ImmichAsset = { id: string; - type: "IMAGE"; + type: "IMAGE" | "VIDEO"; originalFileName: string; originalMimeType: string; localDateTime: string | null; @@ -38,6 +38,7 @@ export interface ImmichClient { listAlbums(signal?: AbortSignal): Promise; listAlbumsForAsset(assetId: string, signal?: AbortSignal): Promise; getAlbum(albumId: string, signal?: AbortSignal): Promise; + getAsset(assetId: string, signal?: AbortSignal): Promise; searchPhotos( input: { albumIds: string[]; description?: string; page: number; size: number; type?: "IMAGE" }, signal?: AbortSignal, diff --git a/src/modules/usages/service.test.ts b/src/modules/usages/service.test.ts new file mode 100644 index 0000000..a1360e9 --- /dev/null +++ b/src/modules/usages/service.test.ts @@ -0,0 +1,271 @@ +import { expect, test, vi } from "vitest"; + +import { + createUsageService, + type BillableIntentInput, + type PersistedDownloadIntent, + type UsageRepository, +} from "./service"; +import { UsageAccountingError, type PriorUsage } from "./types"; + +const editorialId = "11111111-1111-4111-8111-111111111111"; +const idempotencyKey = "22222222-2222-4222-8222-222222222222"; + +const newUsageInput = { + editorialId, + assetId: "asset-1", + albumId: "album-1", + purpose: "Titelgeschichte", + reference: "Ausgabe 8/26", + idempotencyKey, +}; + +function createRepository() { + const intents = new Map(); + const usages: BillableIntentInput[] = []; + const priorUsages: PriorUsage[] = []; + let priceCents: number | null = 1_500; + let status = "active"; + + const repository: UsageRepository = { + async findIntent(requestEditorialId, key) { + return intents.get(`${requestEditorialId}:${key}`) ?? null; + }, + async createBillableIntent(input) { + if (status !== "active") { + throw new UsageAccountingError("EDITORIAL_NOT_ACTIVE"); + } + if (!Number.isSafeInteger(priceCents) || (priceCents ?? 0) <= 0) { + throw new UsageAccountingError("INVALID_PRICE"); + } + const key = `${input.editorialId}:${input.idempotencyKey}`; + const existing = intents.get(key); + if (existing) return existing; + + usages.push(input); + const intent: PersistedDownloadIntent = { + id: `download-${intents.size + 1}`, + usageId: `usage-${usages.length}`, + assetId: input.assetId, + priceCents: priceCents!, + billable: true, + status: "authorized", + authorizedAt: new Date("2026-08-09T08:00:00.000Z"), + requestFingerprint: input.requestFingerprint, + kind: "new_usage", + }; + intents.set(key, intent); + return intent; + }, + async listPriorUsages() { + return priorUsages; + }, + }; + + return { + repository, + intents, + usages, + priorUsages, + setPrice(value: number | null) { + priceCents = value; + }, + setStatus(value: string) { + status = value; + }, + }; +} + +function createService() { + const state = createRepository(); + const immich = { + listAlbumsForAsset: vi.fn().mockResolvedValue([ + { + id: "album-1", + albumName: "Presse 2026", + description: null, + albumThumbnailAssetId: "asset-1", + assetCount: 1, + }, + ]), + getAsset: vi.fn().mockResolvedValue({ + id: "asset-1", + type: "IMAGE" as const, + originalFileName: "jubel.jpg", + originalMimeType: "image/jpeg", + localDateTime: null, + fileCreatedAt: null, + albums: [{ id: "album-1" }], + }), + }; + return { ...state, immich, service: createUsageService({ repository: state.repository, immich }) }; +} + +test("snapshots the current editorial price and normalized Immich metadata", async () => { + const { service, usages } = createService(); + + const intent = await service.createNewUsage({ + ...newUsageInput, + purpose: " Titelgeschichte ", + reference: " Ausgabe 8/26 ", + }); + + expect(intent).toMatchObject({ priceCents: 1_500, billable: true, status: "authorized" }); + expect(usages).toEqual([ + expect.objectContaining({ + assetId: "asset-1", + albumId: "album-1", + albumName: "Presse 2026", + filename: "jubel.jpg", + purpose: "Titelgeschichte", + reference: "Ausgabe 8/26", + }), + ]); +}); + +test("returns the exact persisted intent for an equivalent idempotent retry", async () => { + const { service, usages, immich } = createService(); + + const first = await service.createNewUsage(newUsageInput); + const second = await service.createNewUsage(newUsageInput); + + expect(second).toEqual(first); + expect(usages).toHaveLength(1); + expect(immich.getAsset).toHaveBeenCalledTimes(1); +}); + +test("keeps the original snapshot after a price change while a new key uses the new price", async () => { + const { service, setPrice } = createService(); + const original = await service.createNewUsage(newUsageInput); + setPrice(2_100); + + await expect(service.createNewUsage(newUsageInput)).resolves.toEqual(original); + await expect( + service.createNewUsage({ + ...newUsageInput, + idempotencyKey: "33333333-3333-4333-8333-333333333333", + }), + ).resolves.toMatchObject({ priceCents: 2_100 }); +}); + +test.each([ + ["zero", 0], + ["missing", null], +] as const)("rejects a %s current price", async (_label, price) => { + const { service, setPrice } = createService(); + setPrice(price); + + await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ + code: "INVALID_PRICE", + }); +}); + +test.each(["suspended", "pending_approval"])("rejects a %s editorial account", async (status) => { + const { service, setStatus } = createService(); + setStatus(status); + + await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ + code: "EDITORIAL_NOT_ACTIVE", + }); +}); + +test.each([ + ["ab", "INVALID_INPUT"], + ["x".repeat(201), "INVALID_INPUT"], + ["Titelgeschichte", "INVALID_INPUT", "x".repeat(201)], + ["Titelgeschichte", "INVALID_INPUT", undefined, "not-a-uuid"], +] as const)( + "rejects malformed purpose, reference, or idempotency input before side effects", + async (purpose: string, code: string, reference?: string, key?: string) => { + const { service, repository, immich } = createService(); + const findIntent = vi.spyOn(repository, "findIntent"); + + await expect( + service.createNewUsage({ + ...newUsageInput, + purpose, + reference: reference ?? "Ausgabe 8/26", + idempotencyKey: key ?? idempotencyKey, + }), + ).rejects.toMatchObject({ code }); + expect(findIntent).not.toHaveBeenCalled(); + expect(immich.listAlbumsForAsset).not.toHaveBeenCalled(); + expect(immich.getAsset).not.toHaveBeenCalled(); + }, +); + +test("rejects an asset outside the exact requested album", async () => { + const { service, immich, usages } = createService(); + immich.listAlbumsForAsset.mockResolvedValue([ + { + id: "album-2", + albumName: "Andere Bilder", + description: null, + albumThumbnailAssetId: null, + assetCount: 1, + }, + ]); + + await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ + code: "ASSET_NOT_IN_ALBUM", + }); + expect(immich.getAsset).not.toHaveBeenCalled(); + expect(usages).toHaveLength(0); +}); + +test("rejects a missing asset immediately before accounting", async () => { + const { service, immich, usages } = createService(); + immich.getAsset.mockRejectedValue({ code: "IMMICH_NOT_FOUND" }); + + await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ + code: "ASSET_NOT_FOUND", + }); + expect(usages).toHaveLength(0); +}); + +test("rejects a non-image asset immediately before accounting", async () => { + const { service, immich, usages } = createService(); + immich.getAsset.mockResolvedValue({ + id: "asset-1", + type: "VIDEO", + originalFileName: "clip.mp4", + originalMimeType: "video/mp4", + localDateTime: null, + fileCreatedAt: null, + albums: [{ id: "album-1" }], + }); + + await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ + code: "ASSET_NOT_IMAGE", + }); + expect(usages).toHaveLength(0); +}); + +test("rejects reuse of an idempotency key for a materially different new usage", async () => { + const { service, usages, immich } = createService(); + await service.createNewUsage(newUsageInput); + + await expect( + service.createNewUsage({ ...newUsageInput, purpose: "Online-Aufmacher" }), + ).rejects.toMatchObject({ code: "IDEMPOTENCY_CONFLICT" }); + expect(usages).toHaveLength(1); + expect(immich.getAsset).toHaveBeenCalledTimes(1); +}); + +test("lists only the repository's prior usages for the requested editorial asset", async () => { + const { service, priorUsages } = createService(); + priorUsages.push({ + id: "usage-1", + assetId: "asset-1", + filename: "jubel.jpg", + albumId: "album-1", + albumName: "Presse 2026", + purpose: "Titelgeschichte", + reference: undefined, + priceCents: 1_500, + billingStatus: "open", + createdAt: new Date("2026-08-09T08:00:00.000Z"), + }); + + await expect(service.listPriorUsages(editorialId, "asset-1")).resolves.toEqual(priorUsages); +}); diff --git a/src/modules/usages/service.ts b/src/modules/usages/service.ts new file mode 100644 index 0000000..fa8f658 --- /dev/null +++ b/src/modules/usages/service.ts @@ -0,0 +1,422 @@ +import "server-only"; + +import { randomUUID } from "node:crypto"; + +import { and, desc, eq, isNull, sql } from "drizzle-orm"; +import type { NodePgDatabase } from "drizzle-orm/node-postgres"; + +import { db } from "@/db/client"; +import { + albumGrants, + auditEvents, + downloadEvents, + editorialAccounts, + usages, +} from "@/db/schema"; +import type * as schema from "@/db/schema"; +import { immichClient } from "@/modules/immich/client"; +import type { ImmichAlbumSummary } from "@/modules/immich/types"; + +import { + assertImmichIdentifier, + assertUuid, + type CreateNewUsageInput, + type DownloadIntent, + normalizeOptionalText, + normalizeRequiredText, + type PriorUsage, + requestFingerprint, + UsageAccountingError, +} from "./types"; + +export type PersistedDownloadIntent = DownloadIntent & { + requestFingerprint: string; + kind: "new_usage" | "repeat_download"; +}; + +export type BillableIntentInput = { + editorialId: string; + assetId: string; + albumId: string; + albumName: string; + filename: string; + purpose: string; + reference?: string; + idempotencyKey: string; + requestFingerprint: string; +}; + +export type UsageRepository = { + findIntent(editorialId: string, idempotencyKey: string): Promise; + createBillableIntent(input: BillableIntentInput): Promise; + listPriorUsages(editorialId: string, assetId: string): Promise; +}; + +type UsageImmich = { + listAlbumsForAsset(assetId: string): Promise; + getAsset(assetId: string): Promise<{ + id: string; + type: string; + originalFileName: string; + }>; +}; + +export function createUsageService({ + repository, + immich, +}: { + repository: UsageRepository; + immich: UsageImmich; +}) { + return { + async createNewUsage(rawInput: CreateNewUsageInput): Promise { + const input = normalizeNewUsageInput(rawInput); + const fingerprint = requestFingerprint({ + kind: "new_usage", + editorialId: input.editorialId, + assetId: input.assetId, + albumId: input.albumId, + purpose: input.purpose, + reference: input.reference ?? null, + }); + + const existing = await repository.findIntent(input.editorialId, input.idempotencyKey); + if (existing) return resolveIntent(existing, fingerprint, "new_usage"); + + const album = await loadRequestedAlbum(immich, input.assetId, input.albumId); + const asset = await loadImageAsset(immich, input.assetId); + const persisted = await repository.createBillableIntent({ + ...input, + albumName: normalizeUpstreamSnapshot(album.albumName), + filename: normalizeUpstreamSnapshot(asset.originalFileName), + requestFingerprint: fingerprint, + }); + return resolveIntent(persisted, fingerprint, "new_usage"); + }, + + async listPriorUsages(editorialId: string, assetId: string): Promise { + assertUuid(editorialId); + assertImmichIdentifier(assetId); + return repository.listPriorUsages(editorialId, assetId); + }, + }; +} + +export function createUsageServiceRepository( + database: NodePgDatabase, +): UsageRepository { + return { + findIntent(editorialId, idempotencyKey) { + return findPersistedIntent(database, editorialId, idempotencyKey); + }, + + async createBillableIntent(input) { + try { + return await database.transaction(async (transaction) => { + await lockEditorialAccounting(transaction, input.editorialId); + const [editorial] = await transaction + .select({ + id: editorialAccounts.id, + status: editorialAccounts.status, + currentPriceCents: editorialAccounts.currentPriceCents, + }) + .from(editorialAccounts) + .where(eq(editorialAccounts.id, input.editorialId)) + .for("update") + .limit(1); + if (!editorial || editorial.status !== "active") { + throw new UsageAccountingError("EDITORIAL_NOT_ACTIVE"); + } + if ( + !Number.isSafeInteger(editorial.currentPriceCents) || + (editorial.currentPriceCents ?? 0) <= 0 + ) { + throw new UsageAccountingError("INVALID_PRICE"); + } + + const [grant] = await transaction + .select({ id: albumGrants.id }) + .from(albumGrants) + .where( + and( + eq(albumGrants.editorialAccountId, input.editorialId), + eq(albumGrants.immichAlbumId, input.albumId), + isNull(albumGrants.revokedAt), + ), + ) + .for("update") + .limit(1); + if (!grant) throw new UsageAccountingError("ALBUM_NOT_GRANTED"); + + const existing = await findPersistedIntentInTransaction( + transaction, + input.editorialId, + input.idempotencyKey, + ); + if (existing) return existing; + + const createdAt = new Date(); + const [usage] = await transaction + .insert(usages) + .values({ + editorialAccountId: input.editorialId, + immichAssetId: input.assetId, + filenameSnapshot: input.filename, + immichAlbumIdSnapshot: input.albumId, + albumNameSnapshot: input.albumName, + purpose: input.purpose, + internalReference: input.reference, + priceCents: editorial.currentPriceCents!, + billingStatus: "open", + createdAt, + }) + .returning({ id: usages.id }); + const requestId = randomUUID(); + const [event] = await transaction + .insert(downloadEvents) + .values({ + editorialAccountId: input.editorialId, + usageId: usage.id, + immichAssetId: input.assetId, + authorizedAt: createdAt, + status: "authorized", + requestId, + idempotencyKey: input.idempotencyKey, + intentKind: "new_usage", + requestFingerprint: input.requestFingerprint, + }) + .onConflictDoNothing({ + target: [downloadEvents.editorialAccountId, downloadEvents.idempotencyKey], + }) + .returning({ id: downloadEvents.id }); + if (!event) throw new IdempotencyRaceError(); + + await transaction.insert(auditEvents).values({ + eventType: "billable_usage_created", + actorType: "editorial", + entityType: "usage", + entityId: usage.id, + newValues: { + editorialId: input.editorialId, + assetId: input.assetId, + albumId: input.albumId, + priceCents: editorial.currentPriceCents, + downloadId: event.id, + }, + occurredAt: createdAt, + requestId, + }); + return { + id: event.id, + usageId: usage.id, + assetId: input.assetId, + priceCents: editorial.currentPriceCents!, + billable: true, + status: "authorized" as const, + authorizedAt: createdAt, + requestFingerprint: input.requestFingerprint, + kind: "new_usage" as const, + }; + }); + } catch (error) { + if (!(error instanceof IdempotencyRaceError)) throw error; + const existing = await findPersistedIntent( + database, + input.editorialId, + input.idempotencyKey, + ); + if (existing) return existing; + throw error; + } + }, + + async listPriorUsages(editorialId, assetId) { + const rows = await database + .select({ + id: usages.id, + assetId: usages.immichAssetId, + filename: usages.filenameSnapshot, + albumId: usages.immichAlbumIdSnapshot, + albumName: usages.albumNameSnapshot, + purpose: usages.purpose, + reference: usages.internalReference, + priceCents: usages.priceCents, + billingStatus: usages.billingStatus, + createdAt: usages.createdAt, + }) + .from(usages) + .where( + and( + eq(usages.editorialAccountId, editorialId), + eq(usages.immichAssetId, assetId), + ), + ) + .orderBy(desc(usages.createdAt)); + return rows.map((row) => ({ ...row, reference: row.reference ?? undefined })); + }, + }; +} + +function normalizeNewUsageInput(input: CreateNewUsageInput): CreateNewUsageInput { + if (!input || typeof input !== "object") throw new UsageAccountingError("INVALID_INPUT"); + assertUuid(input.editorialId); + assertImmichIdentifier(input.assetId); + assertImmichIdentifier(input.albumId); + assertUuid(input.idempotencyKey); + const purpose = normalizeRequiredText(input.purpose, 3, 200); + const reference = normalizeOptionalText(input.reference, 200); + return { + editorialId: input.editorialId, + assetId: input.assetId, + albumId: input.albumId, + purpose, + ...(reference === undefined ? {} : { reference }), + idempotencyKey: input.idempotencyKey, + }; +} + +async function loadRequestedAlbum( + immich: UsageImmich, + assetId: string, + albumId: string, +): Promise { + let albums: ImmichAlbumSummary[]; + try { + albums = await immich.listAlbumsForAsset(assetId); + } catch { + throw new UsageAccountingError("IMMICH_UNAVAILABLE"); + } + const album = albums.find((candidate) => candidate.id === albumId); + if (!album) throw new UsageAccountingError("ASSET_NOT_IN_ALBUM"); + return album; +} + +async function loadImageAsset(immich: UsageImmich, assetId: string) { + let asset: Awaited>; + try { + asset = await immich.getAsset(assetId); + } catch (error) { + if (hasCode(error, "IMMICH_NOT_FOUND")) throw new UsageAccountingError("ASSET_NOT_FOUND"); + throw new UsageAccountingError("IMMICH_UNAVAILABLE"); + } + if (asset.id !== assetId) throw new UsageAccountingError("IMMICH_UNAVAILABLE"); + if (asset.type !== "IMAGE") throw new UsageAccountingError("ASSET_NOT_IMAGE"); + return asset; +} + +function normalizeUpstreamSnapshot(value: string): string { + const normalized = value.trim(); + if (!normalized) throw new UsageAccountingError("IMMICH_UNAVAILABLE"); + return normalized; +} + +function hasCode(error: unknown, code: string): boolean { + return typeof error === "object" && error !== null && "code" in error && error.code === code; +} + +export function resolveIntent( + persisted: PersistedDownloadIntent, + fingerprint: string, + kind: PersistedDownloadIntent["kind"], +): DownloadIntent { + if (persisted.requestFingerprint !== fingerprint || persisted.kind !== kind) { + throw new UsageAccountingError("IDEMPOTENCY_CONFLICT"); + } + const { requestFingerprint: _fingerprint, kind: _kind, ...intent } = persisted; + return intent; +} + +class IdempotencyRaceError extends Error {} + +export async function findPersistedIntent( + database: NodePgDatabase, + editorialId: string, + idempotencyKey: string, +): Promise { + const [row] = await database + .select(intentSelection) + .from(downloadEvents) + .innerJoin(usages, eq(usages.id, downloadEvents.usageId)) + .where( + and( + eq(downloadEvents.editorialAccountId, editorialId), + eq(downloadEvents.idempotencyKey, idempotencyKey), + ), + ) + .limit(1); + return row ? persistedIntent(row) : null; +} + +async function findPersistedIntentInTransaction( + transaction: NodePgDatabase, + editorialId: string, + idempotencyKey: string, +): Promise { + const [row] = await transaction + .select(intentSelection) + .from(downloadEvents) + .innerJoin(usages, eq(usages.id, downloadEvents.usageId)) + .where( + and( + eq(downloadEvents.editorialAccountId, editorialId), + eq(downloadEvents.idempotencyKey, idempotencyKey), + ), + ) + .limit(1); + return row ? persistedIntent(row) : null; +} + +const intentSelection = { + id: downloadEvents.id, + usageId: downloadEvents.usageId, + assetId: downloadEvents.immichAssetId, + authorizedAt: downloadEvents.authorizedAt, + intentKind: downloadEvents.intentKind, + requestFingerprint: downloadEvents.requestFingerprint, + usagePriceCents: usages.priceCents, +}; + +function persistedIntent(row: { + id: string; + usageId: string; + assetId: string; + authorizedAt: Date; + intentKind: string; + requestFingerprint: string; + usagePriceCents: number; +}): PersistedDownloadIntent { + if ( + row.intentKind !== "new_usage" && + row.intentKind !== "repeat_download" + ) { + throw new UsageAccountingError("IDEMPOTENCY_CONFLICT"); + } + return { + id: row.id, + usageId: row.usageId, + assetId: row.assetId, + priceCents: row.intentKind === "new_usage" ? row.usagePriceCents : 0, + billable: row.intentKind === "new_usage", + status: "authorized", + authorizedAt: row.authorizedAt, + requestFingerprint: row.requestFingerprint, + kind: row.intentKind, + }; +} + +export async function lockEditorialAccounting( + transaction: NodePgDatabase, + editorialId: string, +): Promise { + await transaction.execute( + sql`select pg_advisory_xact_lock(hashtextextended(${editorialId}, 0))`, + ); +} + +export const usageService = createUsageService({ + repository: createUsageServiceRepository(db), + immich: immichClient, +}); + +export const createNewUsage = usageService.createNewUsage; +export const listPriorUsages = usageService.listPriorUsages; diff --git a/src/modules/usages/types.ts b/src/modules/usages/types.ts new file mode 100644 index 0000000..53c4d09 --- /dev/null +++ b/src/modules/usages/types.ts @@ -0,0 +1,113 @@ +import { createHash } from "node:crypto"; + +export type CreateNewUsageInput = { + editorialId: string; + assetId: string; + albumId: string; + purpose: string; + reference?: string; + idempotencyKey: string; +}; + +export type CreateRepeatDownloadInput = { + editorialId: string; + usageId: string; + note?: string; + idempotencyKey: string; +}; + +export type DownloadIntent = { + id: string; + usageId: string; + assetId: string; + priceCents: number; + billable: boolean; + status: "authorized"; + authorizedAt: Date; +}; + +export type PriorUsage = { + id: string; + assetId: string; + filename: string; + albumId: string; + albumName: string; + purpose: string; + reference: string | undefined; + priceCents: number; + billingStatus: "open" | "billed" | "reopened"; + createdAt: Date; +}; + +export type UsageAccountingErrorCode = + | "INVALID_INPUT" + | "IDEMPOTENCY_CONFLICT" + | "EDITORIAL_NOT_ACTIVE" + | "INVALID_PRICE" + | "ALBUM_NOT_GRANTED" + | "ASSET_NOT_IN_ALBUM" + | "ASSET_NOT_FOUND" + | "ASSET_NOT_IMAGE" + | "IMMICH_UNAVAILABLE" + | "USAGE_NOT_FOUND"; + +export class UsageAccountingError extends Error { + readonly name = "UsageAccountingError"; + + constructor(readonly code: UsageAccountingErrorCode) { + super(code); + } +} + +type FingerprintPayload = + | { + kind: "new_usage"; + editorialId: string; + assetId: string; + albumId: string; + purpose: string; + reference: string | null; + } + | { + kind: "repeat_download"; + editorialId: string; + usageId: string; + note: string | null; + }; + +export function requestFingerprint(payload: FingerprintPayload): string { + return createHash("sha256").update(JSON.stringify(payload)).digest("hex"); +} + +export function normalizeRequiredText(value: unknown, minimum: number, maximum: number): string { + if (typeof value !== "string") throw new UsageAccountingError("INVALID_INPUT"); + const normalized = value.trim(); + const length = [...normalized].length; + if (length < minimum || length > maximum) { + throw new UsageAccountingError("INVALID_INPUT"); + } + return normalized; +} + +export function normalizeOptionalText(value: unknown, maximum: number): string | undefined { + if (value === undefined) return undefined; + if (typeof value !== "string") throw new UsageAccountingError("INVALID_INPUT"); + const normalized = value.trim(); + if ([...normalized].length > maximum) throw new UsageAccountingError("INVALID_INPUT"); + return normalized || undefined; +} + +export function assertUuid(value: unknown): asserts value is string { + if ( + typeof value !== "string" || + !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value) + ) { + throw new UsageAccountingError("INVALID_INPUT"); + } +} + +export function assertImmichIdentifier(value: unknown): asserts value is string { + if (typeof value !== "string" || !/^[A-Za-z0-9_-]{1,200}$/.test(value)) { + throw new UsageAccountingError("INVALID_INPUT"); + } +} diff --git a/tests/db/postgres.ts b/tests/db/postgres.ts index 3527c75..f2faefb 100644 --- a/tests/db/postgres.ts +++ b/tests/db/postgres.ts @@ -15,6 +15,8 @@ type DownloadSeed = { }; export type PostgresTestDatabase = { + database: NodePgDatabase; + pool: Pool; seedEditorialWithUsage(): Promise; insertDownload(input: DownloadSeed & { idempotencyKey: string }): Promise; stop(): Promise; @@ -33,6 +35,8 @@ export async function startPostgres(): Promise { const db = drizzle({ client: pool, schema }); return { + database: db, + pool, async seedEditorialWithUsage() { return seedEditorialWithUsage(db); }, @@ -43,6 +47,7 @@ export async function startPostgres(): Promise { immichAssetId: input.assetId, requestId: randomUUID(), idempotencyKey: input.idempotencyKey, + requestFingerprint: "0".repeat(64), }); }, async stop() { diff --git a/tests/db/usage-accounting.test.ts b/tests/db/usage-accounting.test.ts new file mode 100644 index 0000000..e47d776 --- /dev/null +++ b/tests/db/usage-accounting.test.ts @@ -0,0 +1,333 @@ +import { randomUUID } from "node:crypto"; + +import { and, count, eq } from "drizzle-orm"; +import { afterAll, expect, test, vi } from "vitest"; + +import { + albumGrants, + auditEvents, + downloadEvents, + editorialAccounts, + usages, + users, +} from "@/db/schema"; +import { + createUsageService, + createUsageServiceRepository, +} from "@/modules/usages/service"; +import { + createDownloadService, + createRepeatDownloadRepository, +} from "@/modules/downloads/service"; +import { startPostgres } from "./postgres"; + +const testDb = await startPostgres(); +const database = testDb.database; + +afterAll(() => testDb.stop()); + +const asset = { + id: "asset-1", + type: "IMAGE" as const, + originalFileName: "jubel.jpg", + originalMimeType: "image/jpeg", + localDateTime: null, + fileCreatedAt: null, + albums: [{ id: "album-1" }], +}; + +function createServices() { + const immich = { + listAlbumsForAsset: vi.fn().mockResolvedValue([ + { + id: "album-1", + albumName: "Presse 2026", + description: null, + albumThumbnailAssetId: "asset-1", + assetCount: 1, + }, + ]), + getAsset: vi.fn().mockResolvedValue(asset), + }; + return { + usageService: createUsageService({ + repository: createUsageServiceRepository(database), + immich, + }), + downloadService: createDownloadService({ + repository: createRepeatDownloadRepository(database), + }), + immich, + }; +} + +async function seedEditorial({ + status = "active", + priceCents = 1_500, + albumId = "album-1", + revoked = false, +}: { + status?: "active" | "suspended" | "pending_approval"; + priceCents?: number | null; + albumId?: string; + revoked?: boolean; +} = {}) { + const userId = randomUUID(); + const editorialId = randomUUID(); + await database.insert(users).values({ + id: userId, + name: "Test Redaktion", + email: `${userId}@example.com`, + emailVerified: true, + }); + await database.insert(editorialAccounts).values({ + id: editorialId, + userId, + name: "Test Redaktion", + contactName: "Testkontakt", + loginEmail: `${userId}@example.com`, + status, + currentPriceCents: priceCents, + }); + await database.insert(albumGrants).values({ + editorialAccountId: editorialId, + immichAlbumId: albumId, + revokedAt: revoked ? new Date("2026-08-08T00:00:00.000Z") : null, + }); + return editorialId; +} + +function newInput(editorialId: string, idempotencyKey = randomUUID()) { + return { + editorialId, + assetId: "asset-1", + albumId: "album-1", + purpose: "Titelgeschichte", + reference: "Ausgabe 8/26", + idempotencyKey, + }; +} + +test("atomically snapshots price and metadata, authorizes one event, and audits no secrets", async () => { + const editorialId = await seedEditorial(); + const { usageService } = createServices(); + const input = newInput(editorialId); + + const intent = await usageService.createNewUsage(input); + + const [usage] = await database.select().from(usages).where(eq(usages.id, intent.usageId)); + const [event] = await database.select().from(downloadEvents).where(eq(downloadEvents.id, intent.id)); + const [audit] = await database + .select() + .from(auditEvents) + .where(and(eq(auditEvents.eventType, "billable_usage_created"), eq(auditEvents.entityId, intent.usageId))); + expect(usage).toMatchObject({ + editorialAccountId: editorialId, + immichAssetId: "asset-1", + filenameSnapshot: "jubel.jpg", + immichAlbumIdSnapshot: "album-1", + albumNameSnapshot: "Presse 2026", + purpose: "Titelgeschichte", + internalReference: "Ausgabe 8/26", + priceCents: 1_500, + billingStatus: "open", + }); + expect(event).toMatchObject({ + editorialAccountId: editorialId, + usageId: intent.usageId, + status: "authorized", + intentKind: "new_usage", + }); + expect(audit).toMatchObject({ actorType: "editorial", entityType: "usage" }); + expect(JSON.stringify(audit)).not.toContain(input.idempotencyKey); + expect(JSON.stringify(audit)).not.toContain("test-immich-key"); +}); + +test.each([ + ["zero price", "active", 0, false, "INVALID_PRICE"], + ["missing price", "active", null, false, "INVALID_PRICE"], + ["suspended account", "suspended", 1_500, false, "EDITORIAL_NOT_ACTIVE"], + ["revoked grant", "active", 1_500, true, "ALBUM_NOT_GRANTED"], +] as const)("rejects %s transactionally without accounting rows", async (_label, status, priceCents, revoked, code) => { + const editorialId = await seedEditorial({ status, priceCents, revoked }); + const { usageService } = createServices(); + + await expect(usageService.createNewUsage(newInput(editorialId))).rejects.toMatchObject({ code }); + const [usageCount] = await database + .select({ value: count() }) + .from(usages) + .where(eq(usages.editorialAccountId, editorialId)); + const [eventCount] = await database + .select({ value: count() }) + .from(downloadEvents) + .where(eq(downloadEvents.editorialAccountId, editorialId)); + expect({ usages: usageCount.value, events: eventCount.value }).toEqual({ usages: 0, events: 0 }); +}); + +test("requires an active grant for the exact requested album", async () => { + const editorialId = await seedEditorial({ albumId: "album-2" }); + const { usageService } = createServices(); + + await expect(usageService.createNewUsage(newInput(editorialId))).rejects.toMatchObject({ + code: "ALBUM_NOT_GRANTED", + }); +}); + +test("same-key concurrency across database clients creates exactly one usage, event, and audit", async () => { + const editorialId = await seedEditorial(); + const { usageService } = createServices(); + const input = newInput(editorialId); + + const [first, second] = await Promise.all([ + usageService.createNewUsage(input), + usageService.createNewUsage(input), + ]); + + expect(second).toEqual(first); + const [usageCount] = await database + .select({ value: count() }) + .from(usages) + .where(eq(usages.editorialAccountId, editorialId)); + const [eventCount] = await database + .select({ value: count() }) + .from(downloadEvents) + .where(eq(downloadEvents.editorialAccountId, editorialId)); + const [auditCount] = await database + .select({ value: count() }) + .from(auditEvents) + .where(and(eq(auditEvents.eventType, "billable_usage_created"), eq(auditEvents.entityId, first.usageId))); + expect({ usages: usageCount.value, events: eventCount.value, audits: auditCount.value }).toEqual({ + usages: 1, + events: 1, + audits: 1, + }); +}); + +test("the same key may be reused by a different editorial but not for a different payload", async () => { + const firstEditorialId = await seedEditorial(); + const secondEditorialId = await seedEditorial(); + const { usageService } = createServices(); + const key = randomUUID(); + await usageService.createNewUsage(newInput(firstEditorialId, key)); + + await expect( + usageService.createNewUsage({ ...newInput(firstEditorialId, key), purpose: "Online-Aufmacher" }), + ).rejects.toMatchObject({ code: "IDEMPOTENCY_CONFLICT" }); + await expect(usageService.createNewUsage(newInput(secondEditorialId, key))).resolves.toMatchObject({ + billable: true, + }); +}); + +test("an audit failure rolls back both the usage and authorized event", async () => { + const editorialId = await seedEditorial(); + const { usageService } = createServices(); + await testDb.pool.query(` + create function reject_billable_usage_audit() returns trigger language plpgsql as $$ + begin + if new.event_type = 'billable_usage_created' then raise exception 'audit rejected'; end if; + return new; + end $$ + `); + await testDb.pool.query(` + create trigger reject_billable_usage_audit before insert on audit_events + for each row execute function reject_billable_usage_audit() + `); + + try { + await expect(usageService.createNewUsage(newInput(editorialId))).rejects.toThrow("audit rejected"); + } finally { + await testDb.pool.query("drop trigger reject_billable_usage_audit on audit_events"); + await testDb.pool.query("drop function reject_billable_usage_audit()"); + } + + const [usageCount] = await database + .select({ value: count() }) + .from(usages) + .where(eq(usages.editorialAccountId, editorialId)); + const [eventCount] = await database + .select({ value: count() }) + .from(downloadEvents) + .where(eq(downloadEvents.editorialAccountId, editorialId)); + expect({ usages: usageCount.value, events: eventCount.value }).toEqual({ usages: 0, events: 0 }); +}); + +test("a repeat remains free after a price change and creates no additional usage", async () => { + const editorialId = await seedEditorial(); + const { usageService, downloadService } = createServices(); + const first = await usageService.createNewUsage(newInput(editorialId)); + await database + .update(editorialAccounts) + .set({ currentPriceCents: 2_100 }) + .where(eq(editorialAccounts.id, editorialId)); + + const repeat = await downloadService.createRepeatDownload({ + editorialId, + usageId: first.usageId, + note: "Web-Ausgabe", + idempotencyKey: randomUUID(), + }); + + expect(repeat).toMatchObject({ usageId: first.usageId, priceCents: 0, billable: false }); + const [usageCount] = await database + .select({ value: count() }) + .from(usages) + .where(eq(usages.editorialAccountId, editorialId)); + expect(usageCount.value).toBe(1); +}); + +test("same-key repeat concurrency creates one free event", async () => { + const editorialId = await seedEditorial(); + const { usageService, downloadService } = createServices(); + const first = await usageService.createNewUsage(newInput(editorialId)); + const repeatInput = { + editorialId, + usageId: first.usageId, + note: "Web-Ausgabe", + idempotencyKey: randomUUID(), + }; + + const [repeatOne, repeatTwo] = await Promise.all([ + downloadService.createRepeatDownload(repeatInput), + downloadService.createRepeatDownload(repeatInput), + ]); + + expect(repeatTwo).toEqual(repeatOne); + const [eventCount] = await database + .select({ value: count() }) + .from(downloadEvents) + .where(and(eq(downloadEvents.usageId, first.usageId), eq(downloadEvents.intentKind, "repeat_download"))); + expect(eventCount.value).toBe(1); +}); + +test("a suspended owner cannot create a repeat event", async () => { + const editorialId = await seedEditorial(); + const { usageService, downloadService } = createServices(); + const first = await usageService.createNewUsage(newInput(editorialId)); + await database + .update(editorialAccounts) + .set({ status: "suspended" }) + .where(eq(editorialAccounts.id, editorialId)); + + await expect( + downloadService.createRepeatDownload({ + editorialId, + usageId: first.usageId, + idempotencyKey: randomUUID(), + }), + ).rejects.toMatchObject({ code: "EDITORIAL_NOT_ACTIVE" }); +}); + +test("repeat ownership is scoped to the active editorial", async () => { + const ownerId = await seedEditorial(); + const otherEditorialId = await seedEditorial(); + const { usageService, downloadService } = createServices(); + const first = await usageService.createNewUsage(newInput(ownerId)); + + await expect( + downloadService.createRepeatDownload({ + editorialId: otherEditorialId, + usageId: first.usageId, + idempotencyKey: randomUUID(), + }), + ).rejects.toMatchObject({ code: "USAGE_NOT_FOUND" }); +}); From 3de153007465ab435effd79cdadc0d05ae90fbbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Mon, 10 Aug 2026 10:59:12 +0200 Subject: [PATCH 16/29] fix: harden usage accounting idempotency --- drizzle/0002_accounting_intents.sql | 83 +++++++- drizzle/meta/0002_snapshot.json | 21 +- drizzle/meta/_journal.json | 2 +- src/db/schema/albums.ts | 4 +- src/db/schema/usages.ts | 12 +- src/modules/downloads/service.test.ts | 28 ++- src/modules/downloads/service.ts | 25 +-- src/modules/usages/service.test.ts | 141 ++++++++++--- src/modules/usages/service.ts | 72 ++++--- src/modules/usages/types.ts | 5 + tests/db/accounting-migration.test.ts | 116 +++++++++++ tests/db/postgres.ts | 25 ++- tests/db/schema.test.ts | 5 +- tests/db/usage-accounting.test.ts | 276 +++++++++++++++++++++++++- 14 files changed, 708 insertions(+), 107 deletions(-) create mode 100644 tests/db/accounting-migration.test.ts diff --git a/drizzle/0002_accounting_intents.sql b/drizzle/0002_accounting_intents.sql index c386136..095e566 100644 --- a/drizzle/0002_accounting_intents.sql +++ b/drizzle/0002_accounting_intents.sql @@ -1,7 +1,82 @@ -ALTER TABLE "download_events" ADD COLUMN "intent_kind" text DEFAULT 'new_usage' NOT NULL;--> statement-breakpoint +ALTER TABLE "album_grants" ALTER COLUMN "immich_album_id" SET DATA TYPE uuid USING lower("immich_album_id")::uuid;--> statement-breakpoint +ALTER TABLE "download_events" ALTER COLUMN "immich_asset_id" SET DATA TYPE uuid USING lower("immich_asset_id")::uuid;--> statement-breakpoint +ALTER TABLE "usages" ALTER COLUMN "immich_asset_id" SET DATA TYPE uuid USING lower("immich_asset_id")::uuid;--> statement-breakpoint +ALTER TABLE "usages" ALTER COLUMN "immich_album_id_snapshot" SET DATA TYPE uuid USING lower("immich_album_id_snapshot")::uuid;--> statement-breakpoint +ALTER TABLE "download_events" ADD COLUMN "intent_kind" text;--> statement-breakpoint ALTER TABLE "download_events" ADD COLUMN "request_fingerprint" varchar(64);--> statement-breakpoint -UPDATE "download_events" -SET "request_fingerprint" = md5("editorial_account_id"::text || ':' || "id"::text) || md5("id"::text || ':' || "editorial_account_id"::text);--> statement-breakpoint +ALTER TABLE "download_events" ADD COLUMN "legacy_intent" boolean;--> statement-breakpoint +-- Preserve arbitrary legacy keys, while canonicalizing every legacy UUID key that +-- can be retried through the new UUID-only API. New rows are protected below. +UPDATE "download_events" AS target +SET "idempotency_key" = lower("idempotency_key") +WHERE + target."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}$' + AND NOT EXISTS ( + SELECT 1 + FROM "download_events" AS sibling + WHERE + sibling."editorial_account_id" = target."editorial_account_id" + AND sibling."id" <> target."id" + AND lower(sibling."idempotency_key") = lower(target."idempotency_key") + );--> statement-breakpoint +-- Legacy accounting deterministically treats the earliest event for each usage as +-- its billable creation intent. Later events are repeat downloads. These are the +-- only intent shapes whose original request can be reconstructed from stored data. +WITH ranked_legacy_events AS ( + SELECT + "id", + row_number() OVER ( + PARTITION BY "usage_id" + ORDER BY "authorized_at", "id" + ) AS usage_event_number + FROM "download_events" +) +UPDATE "download_events" AS events +SET "intent_kind" = CASE + WHEN ranked.usage_event_number = 1 THEN 'new_usage' + ELSE 'repeat_download' +END +FROM ranked_legacy_events AS ranked +WHERE ranked."id" = events."id";--> statement-breakpoint +-- The string assembled here deliberately matches JSON.stringify's runtime field +-- order. Valid legacy rows therefore receive the same SHA-256 as an equivalent +-- retry; inconsistent rows receive a deterministic fingerprint no request can use. +UPDATE "download_events" AS events +SET "request_fingerprint" = CASE + WHEN + events."editorial_account_id" = usage."editorial_account_id" + AND events."immich_asset_id" = usage."immich_asset_id" + AND events."intent_kind" = 'new_usage' + THEN encode(sha256(convert_to( + '{"kind":"new_usage","editorialId":' || to_json(events."editorial_account_id"::text)::text || + ',"assetId":' || to_json(events."immich_asset_id"::text)::text || + ',"albumId":' || to_json(usage."immich_album_id_snapshot"::text)::text || + ',"purpose":' || to_json(btrim(usage."purpose"))::text || + ',"reference":' || coalesce(to_json(nullif(btrim(usage."internal_reference"), ''))::text, 'null') || + '}', + 'UTF8' + )), 'hex') + WHEN + events."editorial_account_id" = usage."editorial_account_id" + AND events."immich_asset_id" = usage."immich_asset_id" + AND events."intent_kind" = 'repeat_download' + THEN encode(sha256(convert_to( + '{"kind":"repeat_download","editorialId":' || to_json(events."editorial_account_id"::text)::text || + ',"usageId":' || to_json(events."usage_id"::text)::text || + ',"note":' || coalesce(to_json(nullif(btrim(events."repeat_download_note"), ''))::text, 'null') || + '}', + 'UTF8' + )), 'hex') + ELSE encode(sha256(convert_to('unprovable-legacy-intent:' || events."id"::text, 'UTF8')), 'hex') +END +FROM "usages" AS usage +WHERE usage."id" = events."usage_id";--> statement-breakpoint +UPDATE "download_events" SET "legacy_intent" = true;--> statement-breakpoint +ALTER TABLE "download_events" ALTER COLUMN "intent_kind" SET DEFAULT 'new_usage';--> statement-breakpoint +ALTER TABLE "download_events" ALTER COLUMN "intent_kind" SET NOT NULL;--> statement-breakpoint ALTER TABLE "download_events" ALTER COLUMN "request_fingerprint" SET NOT NULL;--> statement-breakpoint +ALTER TABLE "download_events" ALTER COLUMN "legacy_intent" SET DEFAULT false;--> statement-breakpoint +ALTER TABLE "download_events" ALTER COLUMN "legacy_intent" SET NOT NULL;--> statement-breakpoint ALTER TABLE "download_events" ADD CONSTRAINT "download_events_intent_kind_check" CHECK ("download_events"."intent_kind" in ('new_usage', 'repeat_download'));--> statement-breakpoint -ALTER TABLE "download_events" ADD CONSTRAINT "download_events_request_fingerprint_hex_check" CHECK ("download_events"."request_fingerprint" ~ '^[0-9a-f]{64}$'); +ALTER TABLE "download_events" ADD CONSTRAINT "download_events_request_fingerprint_hex_check" CHECK ("download_events"."request_fingerprint" ~ '^[0-9a-f]{64}$');--> statement-breakpoint +ALTER TABLE "download_events" ADD 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}$'); diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json index 6f1926f..65a9bc4 100644 --- a/drizzle/meta/0002_snapshot.json +++ b/drizzle/meta/0002_snapshot.json @@ -1,5 +1,5 @@ { - "id": "0cdb7b32-1eb5-4dcf-9949-3862dbbad2b4", + "id": "f650c8ba-ebde-411d-92d0-caf0f9885c44", "prevId": "cfd5f4d1-55ac-46d9-9667-cd156f26e070", "version": "7", "dialect": "postgresql", @@ -23,7 +23,7 @@ }, "immich_album_id": { "name": "immich_album_id", - "type": "text", + "type": "uuid", "primaryKey": false, "notNull": true }, @@ -1157,7 +1157,7 @@ }, "immich_asset_id": { "name": "immich_asset_id", - "type": "text", + "type": "uuid", "primaryKey": false, "notNull": true }, @@ -1224,6 +1224,13 @@ "type": "varchar(64)", "primaryKey": false, "notNull": true + }, + "legacy_intent": { + "name": "legacy_intent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false } }, "indexes": { @@ -1288,6 +1295,10 @@ "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}$'" } }, "isRLSEnabled": false @@ -1311,7 +1322,7 @@ }, "immich_asset_id": { "name": "immich_asset_id", - "type": "text", + "type": "uuid", "primaryKey": false, "notNull": true }, @@ -1323,7 +1334,7 @@ }, "immich_album_id_snapshot": { "name": "immich_album_id_snapshot", - "type": "text", + "type": "uuid", "primaryKey": false, "notNull": true }, diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 6a7c747..6b7c036 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -19,7 +19,7 @@ { "idx": 2, "version": "7", - "when": 1786308409516, + "when": 1786352073526, "tag": "0002_accounting_intents", "breakpoints": true } diff --git a/src/db/schema/albums.ts b/src/db/schema/albums.ts index 85a8475..e35cb6a 100644 --- a/src/db/schema/albums.ts +++ b/src/db/schema/albums.ts @@ -1,4 +1,4 @@ -import { index, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; +import { index, pgTable, timestamp, uuid } from "drizzle-orm/pg-core"; import { users } from "./auth"; import { editorialAccounts } from "./editorials"; @@ -10,7 +10,7 @@ export const albumGrants = pgTable( editorialAccountId: uuid("editorial_account_id") .notNull() .references(() => editorialAccounts.id, { onDelete: "restrict" }), - immichAlbumId: text("immich_album_id").notNull(), + immichAlbumId: uuid("immich_album_id").notNull(), grantedAt: timestamp("granted_at", { withTimezone: true }).notNull().defaultNow(), revokedAt: timestamp("revoked_at", { withTimezone: true }), grantedByUserId: uuid("granted_by_user_id").references(() => users.id, { diff --git a/src/db/schema/usages.ts b/src/db/schema/usages.ts index bba0bb7..cf63588 100644 --- a/src/db/schema/usages.ts +++ b/src/db/schema/usages.ts @@ -1,6 +1,7 @@ import { sql } from "drizzle-orm"; import { bigint, + boolean, check, integer, pgEnum, @@ -32,9 +33,9 @@ export const usages = pgTable("usages", { editorialAccountId: uuid("editorial_account_id") .notNull() .references(() => editorialAccounts.id, { onDelete: "restrict" }), - immichAssetId: text("immich_asset_id").notNull(), + immichAssetId: uuid("immich_asset_id").notNull(), filenameSnapshot: text("filename_snapshot").notNull(), - immichAlbumIdSnapshot: text("immich_album_id_snapshot").notNull(), + immichAlbumIdSnapshot: uuid("immich_album_id_snapshot").notNull(), albumNameSnapshot: text("album_name_snapshot").notNull(), purpose: text("purpose").notNull(), internalReference: text("internal_reference"), @@ -56,7 +57,7 @@ export const downloadEvents = pgTable( usageId: uuid("usage_id") .notNull() .references(() => usages.id, { onDelete: "restrict" }), - immichAssetId: text("immich_asset_id").notNull(), + immichAssetId: uuid("immich_asset_id").notNull(), authorizedAt: timestamp("authorized_at", { withTimezone: true }).notNull().defaultNow(), startedAt: timestamp("started_at", { withTimezone: true }), completedAt: timestamp("completed_at", { withTimezone: true }), @@ -67,6 +68,7 @@ export const downloadEvents = pgTable( idempotencyKey: text("idempotency_key").notNull(), intentKind: text("intent_kind").notNull().default("new_usage"), requestFingerprint: varchar("request_fingerprint", { length: 64 }).notNull(), + legacyIntent: boolean("legacy_intent").notNull().default(false), }, (table) => [ uniqueIndex("download_events_editorial_idempotency_key_unique").on( @@ -81,5 +83,9 @@ export const downloadEvents = pgTable( "download_events_request_fingerprint_hex_check", sql`${table.requestFingerprint} ~ '^[0-9a-f]{64}$'`, ), + check( + "download_events_canonical_idempotency_key_check", + sql`${table.legacyIntent} OR ${table.idempotencyKey} ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`, + ), ], ); diff --git a/src/modules/downloads/service.test.ts b/src/modules/downloads/service.test.ts index 12052fa..edc8e69 100644 --- a/src/modules/downloads/service.test.ts +++ b/src/modules/downloads/service.test.ts @@ -8,9 +8,10 @@ import { } from "./service"; import { UsageAccountingError } from "@/modules/usages/types"; -const editorialId = "11111111-1111-4111-8111-111111111111"; -const usageId = "44444444-4444-4444-8444-444444444444"; -const idempotencyKey = "55555555-5555-4555-8555-555555555555"; +const editorialId = "1111111a-1111-4111-8111-11111111111a"; +const usageId = "4444444d-4444-4444-8444-44444444444d"; +const idempotencyKey = "5555555e-5555-4555-8555-55555555555e"; +const assetId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; function createService() { const intents = new Map(); @@ -33,7 +34,7 @@ function createService() { const intent: PersistedRepeatIntent = { id: `download-${events.length}`, usageId: input.usageId, - assetId: "asset-1", + assetId, priceCents: 0, billable: false, status: "authorized", @@ -77,7 +78,7 @@ test("creates only a free authorized event for an owned prior usage", async () = expect(intent).toMatchObject({ usageId, - assetId: "asset-1", + assetId, priceCents: 0, billable: false, status: "authorized", @@ -126,6 +127,23 @@ test("returns the same free intent once for an equivalent retry", async () => { expect(events).toHaveLength(1); }); +test("treats mixed-case UUID input as the same repeat intent", async () => { + const { service, events } = createService(); + const uppercaseInput = { + editorialId: editorialId.toUpperCase(), + usageId: usageId.toUpperCase(), + idempotencyKey: idempotencyKey.toUpperCase(), + }; + + const first = await service.createRepeatDownload(uppercaseInput); + const second = await service.createRepeatDownload({ editorialId, usageId, idempotencyKey }); + + expect(second).toEqual(first); + expect(events).toEqual([ + expect.objectContaining({ editorialId, usageId, idempotencyKey }), + ]); +}); + test("rejects reuse of a repeat key with a materially different note", async () => { const { service, events } = createService(); await service.createRepeatDownload({ editorialId, usageId, note: "Web", idempotencyKey }); diff --git a/src/modules/downloads/service.ts b/src/modules/downloads/service.ts index d507155..1d61ee7 100644 --- a/src/modules/downloads/service.ts +++ b/src/modules/downloads/service.ts @@ -9,10 +9,10 @@ import { db } from "@/db/client"; import { downloadEvents, editorialAccounts, usages } from "@/db/schema"; import type * as schema from "@/db/schema"; import { - assertUuid, type CreateRepeatDownloadInput, type DownloadIntent, normalizeOptionalText, + normalizeUuid, requestFingerprint, UsageAccountingError, } from "@/modules/usages/types"; @@ -71,6 +71,13 @@ export function createRepeatDownloadRepository( try { return await database.transaction(async (transaction) => { await lockEditorialAccounting(transaction, input.editorialId); + const existing = await findPersistedIntent( + transaction, + input.editorialId, + input.idempotencyKey, + ); + if (existing) return asRepeatIntent(existing); + const [editorial] = await transaction .select({ id: editorialAccounts.id, status: editorialAccounts.status }) .from(editorialAccounts) @@ -81,13 +88,6 @@ export function createRepeatDownloadRepository( throw new UsageAccountingError("EDITORIAL_NOT_ACTIVE"); } - const existing = await findPersistedIntent( - transaction, - input.editorialId, - input.idempotencyKey, - ); - if (existing) return asRepeatIntent(existing); - const [usage] = await transaction .select({ id: usages.id, assetId: usages.immichAssetId }) .from(usages) @@ -149,15 +149,12 @@ export function createRepeatDownloadRepository( function normalizeRepeatInput(input: CreateRepeatDownloadInput): CreateRepeatDownloadInput { if (!input || typeof input !== "object") throw new UsageAccountingError("INVALID_INPUT"); - assertUuid(input.editorialId); - assertUuid(input.usageId); - assertUuid(input.idempotencyKey); const note = normalizeOptionalText(input.note, 200); return { - editorialId: input.editorialId, - usageId: input.usageId, + editorialId: normalizeUuid(input.editorialId), + usageId: normalizeUuid(input.usageId), ...(note === undefined ? {} : { note }), - idempotencyKey: input.idempotencyKey, + idempotencyKey: normalizeUuid(input.idempotencyKey), }; } diff --git a/src/modules/usages/service.test.ts b/src/modules/usages/service.test.ts index a1360e9..9c31178 100644 --- a/src/modules/usages/service.test.ts +++ b/src/modules/usages/service.test.ts @@ -8,13 +8,16 @@ import { } from "./service"; import { UsageAccountingError, type PriorUsage } from "./types"; -const editorialId = "11111111-1111-4111-8111-111111111111"; -const idempotencyKey = "22222222-2222-4222-8222-222222222222"; +const editorialId = "1111111a-1111-4111-8111-11111111111a"; +const idempotencyKey = "2222222b-2222-4222-8222-22222222222b"; +const assetId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; +const albumId = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"; +const otherAlbumId = "cccccccc-cccc-4ccc-8ccc-cccccccccccc"; const newUsageInput = { editorialId, - assetId: "asset-1", - albumId: "album-1", + assetId, + albumId, purpose: "Titelgeschichte", reference: "Ausgabe 8/26", idempotencyKey, @@ -31,18 +34,22 @@ function createRepository() { async findIntent(requestEditorialId, key) { return intents.get(`${requestEditorialId}:${key}`) ?? null; }, - async createBillableIntent(input) { + async createBillableIntent( + input, + refreshCurrentAsset?: () => Promise<{ albumName: string; filename: string }>, + ) { + const key = `${input.editorialId}:${input.idempotencyKey}`; + const existing = intents.get(key); + if (existing) return existing; if (status !== "active") { throw new UsageAccountingError("EDITORIAL_NOT_ACTIVE"); } if (!Number.isSafeInteger(priceCents) || (priceCents ?? 0) <= 0) { throw new UsageAccountingError("INVALID_PRICE"); } - const key = `${input.editorialId}:${input.idempotencyKey}`; - const existing = intents.get(key); - if (existing) return existing; - usages.push(input); + const refreshed = await refreshCurrentAsset?.(); + usages.push({ ...input, ...refreshed }); const intent: PersistedDownloadIntent = { id: `download-${intents.size + 1}`, usageId: `usage-${usages.length}`, @@ -81,21 +88,21 @@ function createService() { const immich = { listAlbumsForAsset: vi.fn().mockResolvedValue([ { - id: "album-1", + id: albumId, albumName: "Presse 2026", description: null, - albumThumbnailAssetId: "asset-1", + albumThumbnailAssetId: assetId, assetCount: 1, }, ]), getAsset: vi.fn().mockResolvedValue({ - id: "asset-1", + id: assetId, type: "IMAGE" as const, originalFileName: "jubel.jpg", originalMimeType: "image/jpeg", localDateTime: null, fileCreatedAt: null, - albums: [{ id: "album-1" }], + albums: [{ id: albumId }], }), }; return { ...state, immich, service: createUsageService({ repository: state.repository, immich }) }; @@ -113,8 +120,8 @@ test("snapshots the current editorial price and normalized Immich metadata", asy expect(intent).toMatchObject({ priceCents: 1_500, billable: true, status: "authorized" }); expect(usages).toEqual([ expect.objectContaining({ - assetId: "asset-1", - albumId: "album-1", + assetId, + albumId, albumName: "Presse 2026", filename: "jubel.jpg", purpose: "Titelgeschichte", @@ -131,7 +138,26 @@ test("returns the exact persisted intent for an equivalent idempotent retry", as expect(second).toEqual(first); expect(usages).toHaveLength(1); - expect(immich.getAsset).toHaveBeenCalledTimes(1); + expect(immich.getAsset).toHaveBeenCalledTimes(2); +}); + +test("canonicalizes every UUID before fingerprinting, lookup, Immich calls, and persistence", async () => { + const { service, usages, immich } = createService(); + const uppercaseInput = Object.fromEntries( + Object.entries(newUsageInput).map(([key, value]) => [ + key, + key === "purpose" || key === "reference" ? value : value.toUpperCase(), + ]), + ) as typeof newUsageInput; + + const first = await service.createNewUsage(uppercaseInput); + const second = await service.createNewUsage(newUsageInput); + + expect(second).toEqual(first); + expect(usages).toHaveLength(1); + expect(usages[0]).toMatchObject({ editorialId, assetId, albumId, idempotencyKey }); + expect(immich.listAlbumsForAsset).toHaveBeenCalledWith(assetId); + expect(immich.getAsset).toHaveBeenCalledWith(assetId); }); test("keeps the original snapshot after a price change while a new key uses the new price", async () => { @@ -198,7 +224,7 @@ test("rejects an asset outside the exact requested album", async () => { const { service, immich, usages } = createService(); immich.listAlbumsForAsset.mockResolvedValue([ { - id: "album-2", + id: otherAlbumId, albumName: "Andere Bilder", description: null, albumThumbnailAssetId: null, @@ -213,6 +239,73 @@ test("rejects an asset outside the exact requested album", async () => { expect(usages).toHaveLength(0); }); +test("rejects removal from the requested album between preflight and locked refresh", async () => { + const { service, immich, usages } = createService(); + immich.listAlbumsForAsset + .mockResolvedValueOnce([ + { + id: albumId, + albumName: "Presse 2026", + description: null, + albumThumbnailAssetId: assetId, + assetCount: 1, + }, + ]) + .mockResolvedValueOnce([]); + + await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ + code: "ASSET_NOT_IN_ALBUM", + }); + expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(2); + expect(usages).toHaveLength(0); +}); + +test("persists metadata from the locked final Immich refresh", async () => { + const { service, immich, usages } = createService(); + immich.listAlbumsForAsset + .mockResolvedValueOnce([ + { + id: albumId, + albumName: "Presse 2026", + description: null, + albumThumbnailAssetId: assetId, + assetCount: 1, + }, + ]) + .mockResolvedValueOnce([ + { + id: albumId, + albumName: "Presse final", + description: null, + albumThumbnailAssetId: assetId, + assetCount: 1, + }, + ]); + const currentAsset = { + id: assetId, + type: "IMAGE" as const, + originalFileName: "jubel.jpg", + originalMimeType: "image/jpeg", + localDateTime: null, + fileCreatedAt: null, + albums: [{ id: albumId }], + }; + immich.getAsset.mockResolvedValueOnce({ + ...currentAsset, + originalFileName: "vorher.jpg", + }).mockResolvedValueOnce({ + ...currentAsset, + originalFileName: "final.jpg", + }); + + await service.createNewUsage(newUsageInput); + + expect(immich.getAsset).toHaveBeenCalledTimes(2); + expect(usages).toEqual([ + expect.objectContaining({ albumName: "Presse final", filename: "final.jpg" }), + ]); +}); + test("rejects a missing asset immediately before accounting", async () => { const { service, immich, usages } = createService(); immich.getAsset.mockRejectedValue({ code: "IMMICH_NOT_FOUND" }); @@ -226,13 +319,13 @@ test("rejects a missing asset immediately before accounting", async () => { test("rejects a non-image asset immediately before accounting", async () => { const { service, immich, usages } = createService(); immich.getAsset.mockResolvedValue({ - id: "asset-1", + id: assetId, type: "VIDEO", originalFileName: "clip.mp4", originalMimeType: "video/mp4", localDateTime: null, fileCreatedAt: null, - albums: [{ id: "album-1" }], + albums: [{ id: albumId }], }); await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ @@ -249,16 +342,16 @@ test("rejects reuse of an idempotency key for a materially different new usage", service.createNewUsage({ ...newUsageInput, purpose: "Online-Aufmacher" }), ).rejects.toMatchObject({ code: "IDEMPOTENCY_CONFLICT" }); expect(usages).toHaveLength(1); - expect(immich.getAsset).toHaveBeenCalledTimes(1); + expect(immich.getAsset).toHaveBeenCalledTimes(2); }); test("lists only the repository's prior usages for the requested editorial asset", async () => { const { service, priorUsages } = createService(); priorUsages.push({ id: "usage-1", - assetId: "asset-1", + assetId, filename: "jubel.jpg", - albumId: "album-1", + albumId, albumName: "Presse 2026", purpose: "Titelgeschichte", reference: undefined, @@ -267,5 +360,7 @@ test("lists only the repository's prior usages for the requested editorial asset createdAt: new Date("2026-08-09T08:00:00.000Z"), }); - await expect(service.listPriorUsages(editorialId, "asset-1")).resolves.toEqual(priorUsages); + await expect(service.listPriorUsages(editorialId.toUpperCase(), assetId.toUpperCase())).resolves.toEqual( + priorUsages, + ); }); diff --git a/src/modules/usages/service.ts b/src/modules/usages/service.ts index fa8f658..fbf6570 100644 --- a/src/modules/usages/service.ts +++ b/src/modules/usages/service.ts @@ -18,12 +18,11 @@ import { immichClient } from "@/modules/immich/client"; import type { ImmichAlbumSummary } from "@/modules/immich/types"; import { - assertImmichIdentifier, - assertUuid, type CreateNewUsageInput, type DownloadIntent, normalizeOptionalText, normalizeRequiredText, + normalizeUuid, type PriorUsage, requestFingerprint, UsageAccountingError, @@ -48,7 +47,10 @@ export type BillableIntentInput = { export type UsageRepository = { findIntent(editorialId: string, idempotencyKey: string): Promise; - createBillableIntent(input: BillableIntentInput): Promise; + createBillableIntent( + input: BillableIntentInput, + refreshCurrentAsset: () => Promise<{ albumName: string; filename: string }>, + ): Promise; listPriorUsages(editorialId: string, assetId: string): Promise; }; @@ -90,14 +92,19 @@ export function createUsageService({ albumName: normalizeUpstreamSnapshot(album.albumName), filename: normalizeUpstreamSnapshot(asset.originalFileName), requestFingerprint: fingerprint, + }, async () => { + const currentAlbum = await loadRequestedAlbum(immich, input.assetId, input.albumId); + const currentAsset = await loadImageAsset(immich, input.assetId); + return { + albumName: normalizeUpstreamSnapshot(currentAlbum.albumName), + filename: normalizeUpstreamSnapshot(currentAsset.originalFileName), + }; }); return resolveIntent(persisted, fingerprint, "new_usage"); }, async listPriorUsages(editorialId: string, assetId: string): Promise { - assertUuid(editorialId); - assertImmichIdentifier(assetId); - return repository.listPriorUsages(editorialId, assetId); + return repository.listPriorUsages(normalizeUuid(editorialId), normalizeUuid(assetId)); }, }; } @@ -110,10 +117,17 @@ export function createUsageServiceRepository( return findPersistedIntent(database, editorialId, idempotencyKey); }, - async createBillableIntent(input) { + async createBillableIntent(input, refreshCurrentAsset) { try { return await database.transaction(async (transaction) => { await lockEditorialAccounting(transaction, input.editorialId); + const existing = await findPersistedIntentInTransaction( + transaction, + input.editorialId, + input.idempotencyKey, + ); + if (existing) return existing; + const [editorial] = await transaction .select({ id: editorialAccounts.id, @@ -148,12 +162,10 @@ export function createUsageServiceRepository( .limit(1); if (!grant) throw new UsageAccountingError("ALBUM_NOT_GRANTED"); - const existing = await findPersistedIntentInTransaction( - transaction, - input.editorialId, - input.idempotencyKey, - ); - if (existing) return existing; + // This is the last cross-system authorization snapshot available to the + // portal. Immich may still change after it returns, but no portal work is + // allowed between this refresh and the accounting inserts. + const currentAsset = await refreshCurrentAsset(); const createdAt = new Date(); const [usage] = await transaction @@ -161,9 +173,9 @@ export function createUsageServiceRepository( .values({ editorialAccountId: input.editorialId, immichAssetId: input.assetId, - filenameSnapshot: input.filename, + filenameSnapshot: currentAsset.filename, immichAlbumIdSnapshot: input.albumId, - albumNameSnapshot: input.albumName, + albumNameSnapshot: currentAsset.albumName, purpose: input.purpose, internalReference: input.reference, priceCents: editorial.currentPriceCents!, @@ -259,19 +271,15 @@ export function createUsageServiceRepository( function normalizeNewUsageInput(input: CreateNewUsageInput): CreateNewUsageInput { if (!input || typeof input !== "object") throw new UsageAccountingError("INVALID_INPUT"); - assertUuid(input.editorialId); - assertImmichIdentifier(input.assetId); - assertImmichIdentifier(input.albumId); - assertUuid(input.idempotencyKey); const purpose = normalizeRequiredText(input.purpose, 3, 200); const reference = normalizeOptionalText(input.reference, 200); return { - editorialId: input.editorialId, - assetId: input.assetId, - albumId: input.albumId, + editorialId: normalizeUuid(input.editorialId), + assetId: normalizeUuid(input.assetId), + albumId: normalizeUuid(input.albumId), purpose, ...(reference === undefined ? {} : { reference }), - idempotencyKey: input.idempotencyKey, + idempotencyKey: normalizeUuid(input.idempotencyKey), }; } @@ -333,18 +341,19 @@ export async function findPersistedIntent( editorialId: string, idempotencyKey: string, ): Promise { - const [row] = await database + const rows = await database .select(intentSelection) .from(downloadEvents) .innerJoin(usages, eq(usages.id, downloadEvents.usageId)) .where( and( eq(downloadEvents.editorialAccountId, editorialId), - eq(downloadEvents.idempotencyKey, idempotencyKey), + sql`lower(${downloadEvents.idempotencyKey}) = ${idempotencyKey}`, ), ) - .limit(1); - return row ? persistedIntent(row) : null; + .limit(2); + if (rows.length > 1) throw new UsageAccountingError("IDEMPOTENCY_CONFLICT"); + return rows[0] ? persistedIntent(rows[0]) : null; } async function findPersistedIntentInTransaction( @@ -352,18 +361,19 @@ async function findPersistedIntentInTransaction( editorialId: string, idempotencyKey: string, ): Promise { - const [row] = await transaction + const rows = await transaction .select(intentSelection) .from(downloadEvents) .innerJoin(usages, eq(usages.id, downloadEvents.usageId)) .where( and( eq(downloadEvents.editorialAccountId, editorialId), - eq(downloadEvents.idempotencyKey, idempotencyKey), + sql`lower(${downloadEvents.idempotencyKey}) = ${idempotencyKey}`, ), ) - .limit(1); - return row ? persistedIntent(row) : null; + .limit(2); + if (rows.length > 1) throw new UsageAccountingError("IDEMPOTENCY_CONFLICT"); + return rows[0] ? persistedIntent(rows[0]) : null; } const intentSelection = { diff --git a/src/modules/usages/types.ts b/src/modules/usages/types.ts index 53c4d09..d6741f2 100644 --- a/src/modules/usages/types.ts +++ b/src/modules/usages/types.ts @@ -106,6 +106,11 @@ export function assertUuid(value: unknown): asserts value is string { } } +export function normalizeUuid(value: unknown): string { + assertUuid(value); + return value.toLowerCase(); +} + export function assertImmichIdentifier(value: unknown): asserts value is string { if (typeof value !== "string" || !/^[A-Za-z0-9_-]{1,200}$/.test(value)) { throw new UsageAccountingError("INVALID_INPUT"); diff --git a/tests/db/accounting-migration.test.ts b/tests/db/accounting-migration.test.ts new file mode 100644 index 0000000..f7fd030 --- /dev/null +++ b/tests/db/accounting-migration.test.ts @@ -0,0 +1,116 @@ +import { randomUUID } from "node:crypto"; + +import { eq } from "drizzle-orm"; +import { afterAll, expect, test, vi } from "vitest"; + +import { downloadEvents } from "@/db/schema"; +import { createUsageService, createUsageServiceRepository } from "@/modules/usages/service"; +import { requestFingerprint } from "@/modules/usages/types"; +import { startPostgres } from "./postgres"; + +const testDb = await startPostgres({ through: "0001_editorial_approval_notice.sql" }); + +afterAll(() => testDb.stop()); + +test("0002 preserves an equivalent retry of a populated legacy accounting intent", async () => { + const userId = randomUUID(); + const editorialId = randomUUID(); + const usageId = randomUUID(); + const eventId = randomUUID(); + const requestId = randomUUID(); + const assetId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; + const albumId = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"; + const idempotencyKey = "cccccccc-cccc-4ccc-8ccc-cccccccccccc"; + const authorizedAt = new Date("2026-08-09T08:00:00.000Z"); + + await testDb.pool.query( + `insert into users (id, name, email, email_verified) + values ($1, 'Legacy Redaktion', $2, true)`, + [userId, `${userId}@example.com`], + ); + await testDb.pool.query( + `insert into editorial_accounts ( + id, user_id, name, contact_name, login_email, status, current_price_cents + ) values ($1, $2, 'Legacy Redaktion', 'Legacy Kontakt', $3, 'active', 2300)`, + [editorialId, userId, `${userId}@example.com`], + ); + await testDb.pool.query( + `insert into album_grants (editorial_account_id, immich_album_id) + values ($1, $2)`, + [editorialId, albumId.toUpperCase()], + ); + await testDb.pool.query( + `insert into usages ( + id, editorial_account_id, immich_asset_id, filename_snapshot, + immich_album_id_snapshot, album_name_snapshot, purpose, + internal_reference, price_cents, billing_status, created_at + ) values ($1, $2, $3, 'legacy.jpg', $4, 'Legacy Album', + 'Titelgeschichte', 'Ausgabe 8/26', 2300, 'open', $5)`, + [usageId, editorialId, assetId.toUpperCase(), albumId.toUpperCase(), authorizedAt], + ); + await testDb.pool.query( + `insert into download_events ( + id, editorial_account_id, usage_id, immich_asset_id, authorized_at, + status, request_id, idempotency_key + ) values ($1, $2, $3, $4, $5, 'authorized', $6, $7)`, + [ + eventId, + editorialId, + usageId, + assetId.toUpperCase(), + authorizedAt, + requestId, + idempotencyKey.toUpperCase(), + ], + ); + + await testDb.applyRemainingMigrations(); + + const immich = { + listAlbumsForAsset: vi.fn(), + getAsset: vi.fn(), + }; + const usageService = createUsageService({ + repository: createUsageServiceRepository(testDb.database), + immich, + }); + const input = { + editorialId: editorialId.toUpperCase(), + assetId: assetId.toUpperCase(), + albumId: albumId.toUpperCase(), + purpose: "Titelgeschichte", + reference: "Ausgabe 8/26", + idempotencyKey: idempotencyKey.toUpperCase(), + }; + + await expect(usageService.createNewUsage(input)).resolves.toEqual({ + id: eventId, + usageId, + assetId, + priceCents: 2300, + billable: true, + status: "authorized", + authorizedAt, + }); + expect(immich.listAlbumsForAsset).not.toHaveBeenCalled(); + expect(immich.getAsset).not.toHaveBeenCalled(); + + const [migrated] = await testDb.database + .select() + .from(downloadEvents) + .where(eq(downloadEvents.id, eventId)); + expect(migrated).toMatchObject({ + immichAssetId: assetId, + idempotencyKey, + intentKind: "new_usage", + legacyIntent: true, + requestFingerprint: requestFingerprint({ + kind: "new_usage", + editorialId, + assetId, + albumId, + purpose: "Titelgeschichte", + reference: "Ausgabe 8/26", + }), + }); +}); diff --git a/tests/db/postgres.ts b/tests/db/postgres.ts index f2faefb..6fb3131 100644 --- a/tests/db/postgres.ts +++ b/tests/db/postgres.ts @@ -19,10 +19,11 @@ export type PostgresTestDatabase = { pool: Pool; seedEditorialWithUsage(): Promise; insertDownload(input: DownloadSeed & { idempotencyKey: string }): Promise; + applyRemainingMigrations(): Promise; stop(): Promise; }; -export async function startPostgres(): Promise { +export async function startPostgres({ through }: { through?: string } = {}): Promise { const container = await new PostgreSqlContainer("postgres:17-alpine") .withDatabase("portal") .withUsername("portal") @@ -30,7 +31,11 @@ export async function startPostgres(): Promise { .start(); const pool = new Pool({ connectionString: container.getConnectionUri() }); - await applyMigration(pool); + const migrationFiles = await listMigrationFiles(); + const throughIndex = through ? migrationFiles.indexOf(through) : migrationFiles.length - 1; + if (through && throughIndex < 0) throw new Error(`Unknown migration: ${through}`); + let appliedMigrationCount = throughIndex + 1; + await applyMigrationFiles(pool, migrationFiles.slice(0, appliedMigrationCount)); const db = drizzle({ client: pool, schema }); @@ -50,6 +55,10 @@ export async function startPostgres(): Promise { requestFingerprint: "0".repeat(64), }); }, + async applyRemainingMigrations() { + await applyMigrationFiles(pool, migrationFiles.slice(appliedMigrationCount)); + appliedMigrationCount = migrationFiles.length; + }, async stop() { await pool.end(); await stopContainer(container); @@ -57,11 +66,15 @@ export async function startPostgres(): Promise { }; } -async function applyMigration(pool: Pool) { +async function listMigrationFiles() { const migrationDirectory = path.join(process.cwd(), "drizzle"); - const migrationFiles = (await readdir(migrationDirectory)) + return (await readdir(migrationDirectory)) .filter((file) => /^\d+_.*\.sql$/.test(file)) .sort(); +} + +async function applyMigrationFiles(pool: Pool, migrationFiles: string[]) { + const migrationDirectory = path.join(process.cwd(), "drizzle"); for (const file of migrationFiles) { await pool.query(await readFile(path.join(migrationDirectory, file), "utf8")); } @@ -71,7 +84,7 @@ async function seedEditorialWithUsage(db: NodePgDatabase): Promis const userId = randomUUID(); const editorialId = randomUUID(); const usageId = randomUUID(); - const assetId = "immich-asset-1"; + const assetId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; await db.insert(schema.users).values({ id: userId, @@ -93,7 +106,7 @@ async function seedEditorialWithUsage(db: NodePgDatabase): Promis editorialAccountId: editorialId, immichAssetId: assetId, filenameSnapshot: "bild.jpg", - immichAlbumIdSnapshot: "immich-album-1", + immichAlbumIdSnapshot: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb", albumNameSnapshot: "Presse", purpose: "Artikel", priceCents: 1500, diff --git a/tests/db/schema.test.ts b/tests/db/schema.test.ts index 9923674..f16aa99 100644 --- a/tests/db/schema.test.ts +++ b/tests/db/schema.test.ts @@ -7,10 +7,11 @@ afterAll(() => testDb.stop()); test("rejects duplicate download idempotency keys for one editorial", async () => { const seed = await testDb.seedEditorialWithUsage(); + const idempotencyKey = "cccccccc-cccc-4ccc-8ccc-cccccccccccc"; - await testDb.insertDownload({ ...seed, idempotencyKey: "same-request" }); + await testDb.insertDownload({ ...seed, idempotencyKey }); await expect( - testDb.insertDownload({ ...seed, idempotencyKey: "same-request" }), + testDb.insertDownload({ ...seed, idempotencyKey }), ).rejects.toThrow(); }); diff --git a/tests/db/usage-accounting.test.ts b/tests/db/usage-accounting.test.ts index e47d776..e1d5c42 100644 --- a/tests/db/usage-accounting.test.ts +++ b/tests/db/usage-accounting.test.ts @@ -1,6 +1,7 @@ import { randomUUID } from "node:crypto"; import { and, count, eq } from "drizzle-orm"; +import type { PoolClient } from "pg"; import { afterAll, expect, test, vi } from "vitest"; import { @@ -19,6 +20,7 @@ import { createDownloadService, createRepeatDownloadRepository, } from "@/modules/downloads/service"; +import { requestFingerprint } from "@/modules/usages/types"; import { startPostgres } from "./postgres"; const testDb = await startPostgres(); @@ -26,24 +28,28 @@ const database = testDb.database; afterAll(() => testDb.stop()); +const assetId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; +const albumId = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"; +const otherAlbumId = "cccccccc-cccc-4ccc-8ccc-cccccccccccc"; + const asset = { - id: "asset-1", + id: assetId, type: "IMAGE" as const, originalFileName: "jubel.jpg", originalMimeType: "image/jpeg", localDateTime: null, fileCreatedAt: null, - albums: [{ id: "album-1" }], + albums: [{ id: albumId }], }; function createServices() { const immich = { listAlbumsForAsset: vi.fn().mockResolvedValue([ { - id: "album-1", + id: albumId, albumName: "Presse 2026", description: null, - albumThumbnailAssetId: "asset-1", + albumThumbnailAssetId: assetId, assetCount: 1, }, ]), @@ -64,7 +70,7 @@ function createServices() { async function seedEditorial({ status = "active", priceCents = 1_500, - albumId = "album-1", + albumId: grantedAlbumId = albumId, revoked = false, }: { status?: "active" | "suspended" | "pending_approval"; @@ -91,7 +97,7 @@ async function seedEditorial({ }); await database.insert(albumGrants).values({ editorialAccountId: editorialId, - immichAlbumId: albumId, + immichAlbumId: grantedAlbumId, revokedAt: revoked ? new Date("2026-08-08T00:00:00.000Z") : null, }); return editorialId; @@ -100,14 +106,59 @@ async function seedEditorial({ function newInput(editorialId: string, idempotencyKey = randomUUID()) { return { editorialId, - assetId: "asset-1", - albumId: "album-1", + assetId, + albumId, purpose: "Titelgeschichte", reference: "Ausgabe 8/26", idempotencyKey, }; } +async function insertWinner( + client: PoolClient, + input: ReturnType, + fingerprint: string, + kind: "new_usage" | "repeat_download" = "new_usage", +) { + const usageId = randomUUID(); + const eventId = randomUUID(); + const authorizedAt = new Date("2026-08-09T10:00:00.000Z"); + await client.query( + `insert into usages ( + id, editorial_account_id, immich_asset_id, filename_snapshot, + immich_album_id_snapshot, album_name_snapshot, purpose, + internal_reference, price_cents, billing_status, created_at + ) values ($1, $2, $3, 'winner.jpg', $4, 'Presse 2026', $5, $6, 1500, 'open', $7)`, + [ + usageId, + input.editorialId, + input.assetId, + input.albumId, + input.purpose, + input.reference, + authorizedAt, + ], + ); + await client.query( + `insert into download_events ( + id, editorial_account_id, usage_id, immich_asset_id, authorized_at, + status, request_id, idempotency_key, intent_kind, request_fingerprint + ) values ($1, $2, $3, $4, $5, 'authorized', $6, $7, $8, $9)`, + [ + eventId, + input.editorialId, + usageId, + input.assetId, + authorizedAt, + randomUUID(), + input.idempotencyKey, + kind, + fingerprint, + ], + ); + return { eventId, usageId, authorizedAt }; +} + test("atomically snapshots price and metadata, authorizes one event, and audits no secrets", async () => { const editorialId = await seedEditorial(); const { usageService } = createServices(); @@ -123,9 +174,9 @@ test("atomically snapshots price and metadata, authorizes one event, and audits .where(and(eq(auditEvents.eventType, "billable_usage_created"), eq(auditEvents.entityId, intent.usageId))); expect(usage).toMatchObject({ editorialAccountId: editorialId, - immichAssetId: "asset-1", + immichAssetId: assetId, filenameSnapshot: "jubel.jpg", - immichAlbumIdSnapshot: "album-1", + immichAlbumIdSnapshot: albumId, albumNameSnapshot: "Presse 2026", purpose: "Titelgeschichte", internalReference: "Ausgabe 8/26", @@ -165,7 +216,7 @@ test.each([ }); test("requires an active grant for the exact requested album", async () => { - const editorialId = await seedEditorial({ albumId: "album-2" }); + const editorialId = await seedEditorial({ albumId: otherAlbumId }); const { usageService } = createServices(); await expect(usageService.createNewUsage(newInput(editorialId))).rejects.toMatchObject({ @@ -173,6 +224,132 @@ test("requires an active grant for the exact requested album", async () => { }); }); +test("rechecks exact album membership after database locks before inserting", async () => { + const editorialId = await seedEditorial(); + const { usageService, immich } = createServices(); + immich.listAlbumsForAsset + .mockResolvedValueOnce([ + { + id: albumId, + albumName: "Presse 2026", + description: null, + albumThumbnailAssetId: assetId, + assetCount: 1, + }, + ]) + .mockResolvedValueOnce([]); + + await expect(usageService.createNewUsage(newInput(editorialId))).rejects.toMatchObject({ + code: "ASSET_NOT_IN_ALBUM", + }); + const [usageCount] = await database + .select({ value: count() }) + .from(usages) + .where(eq(usages.editorialAccountId, editorialId)); + expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(2); + expect(usageCount.value).toBe(0); +}); + +test("returns a winner committed while waiting before later mutable state is checked", async () => { + const editorialId = await seedEditorial(); + const input = newInput(editorialId); + const immich = createServices().immich; + const realRepository = createUsageServiceRepository(database); + let releaseFastMiss!: () => void; + const fastMiss = new Promise((resolve) => { + releaseFastMiss = resolve; + }); + const usageService = createUsageService({ + repository: { + ...realRepository, + async findIntent(requestEditorialId, key) { + const intent = await realRepository.findIntent(requestEditorialId, key); + releaseFastMiss(); + return intent; + }, + }, + immich, + }); + const locker = await testDb.pool.connect(); + await locker.query("begin"); + await locker.query("select pg_advisory_xact_lock(hashtextextended($1, 0))", [editorialId]); + + try { + const pending = usageService.createNewUsage(input); + await fastMiss; + const winner = await insertWinner( + locker, + input, + requestFingerprint({ + kind: "new_usage", + editorialId, + assetId, + albumId, + purpose: input.purpose, + reference: input.reference, + }), + ); + await locker.query("update editorial_accounts set status = 'suspended' where id = $1", [ + editorialId, + ]); + await locker.query("commit"); + + await expect(pending).resolves.toMatchObject({ + id: winner.eventId, + usageId: winner.usageId, + authorizedAt: winner.authorizedAt, + billable: true, + }); + expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(1); + expect(immich.getAsset).toHaveBeenCalledTimes(1); + } finally { + await locker.query("rollback"); + locker.release(); + } +}); + +test("reports a conflicting winner committed while waiting before later state errors", async () => { + const editorialId = await seedEditorial(); + const input = newInput(editorialId); + const { immich } = createServices(); + const realRepository = createUsageServiceRepository(database); + let releaseFastMiss!: () => void; + const fastMiss = new Promise((resolve) => { + releaseFastMiss = resolve; + }); + const usageService = createUsageService({ + repository: { + ...realRepository, + async findIntent(requestEditorialId, key) { + const intent = await realRepository.findIntent(requestEditorialId, key); + releaseFastMiss(); + return intent; + }, + }, + immich, + }); + const locker = await testDb.pool.connect(); + await locker.query("begin"); + await locker.query("select pg_advisory_xact_lock(hashtextextended($1, 0))", [editorialId]); + + try { + const pending = usageService.createNewUsage(input); + await fastMiss; + await insertWinner(locker, input, "0".repeat(64)); + await locker.query("update editorial_accounts set status = 'suspended' where id = $1", [ + editorialId, + ]); + await locker.query("commit"); + + await expect(pending).rejects.toMatchObject({ code: "IDEMPOTENCY_CONFLICT" }); + expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(1); + expect(immich.getAsset).toHaveBeenCalledTimes(1); + } finally { + await locker.query("rollback"); + locker.release(); + } +}); + test("same-key concurrency across database clients creates exactly one usage, event, and audit", async () => { const editorialId = await seedEditorial(); const { usageService } = createServices(); @@ -299,6 +476,83 @@ test("same-key repeat concurrency creates one free event", async () => { expect(eventCount.value).toBe(1); }); +test("returns a repeat winner committed while waiting before later suspension is checked", async () => { + const editorialId = await seedEditorial(); + const { usageService } = createServices(); + const first = await usageService.createNewUsage(newInput(editorialId)); + const input = { + editorialId, + usageId: first.usageId, + note: "Web-Ausgabe", + idempotencyKey: randomUUID(), + }; + const realRepository = createRepeatDownloadRepository(database); + let releaseFastMiss!: () => void; + const fastMiss = new Promise((resolve) => { + releaseFastMiss = resolve; + }); + const downloadService = createDownloadService({ + repository: { + ...realRepository, + async findIntent(requestEditorialId, key) { + const intent = await realRepository.findIntent(requestEditorialId, key); + releaseFastMiss(); + return intent; + }, + }, + }); + const eventId = randomUUID(); + const authorizedAt = new Date("2026-08-09T11:00:00.000Z"); + const locker = await testDb.pool.connect(); + await locker.query("begin"); + await locker.query("select pg_advisory_xact_lock(hashtextextended($1, 0))", [editorialId]); + + try { + const pending = downloadService.createRepeatDownload(input); + await fastMiss; + await locker.query( + `insert into download_events ( + id, editorial_account_id, usage_id, immich_asset_id, authorized_at, + status, repeat_download_note, request_id, idempotency_key, + intent_kind, request_fingerprint + ) values ($1, $2, $3, $4, $5, 'authorized', $6, $7, $8, 'repeat_download', $9)`, + [ + eventId, + editorialId, + first.usageId, + assetId, + authorizedAt, + input.note, + randomUUID(), + input.idempotencyKey, + requestFingerprint({ + kind: "repeat_download", + editorialId, + usageId: first.usageId, + note: input.note, + }), + ], + ); + await locker.query("update editorial_accounts set status = 'suspended' where id = $1", [ + editorialId, + ]); + await locker.query("commit"); + + await expect(pending).resolves.toEqual({ + id: eventId, + usageId: first.usageId, + assetId, + priceCents: 0, + billable: false, + status: "authorized", + authorizedAt, + }); + } finally { + await locker.query("rollback"); + locker.release(); + } +}); + test("a suspended owner cannot create a repeat event", async () => { const editorialId = await seedEditorial(); const { usageService, downloadService } = createServices(); From 3cdca5c82c01308006165b79891669f6320b3d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Mon, 10 Aug 2026 11:39:44 +0200 Subject: [PATCH 17/29] fix: preserve legacy accounting migration data --- drizzle/0002_accounting_intents.sql | 172 +++++++++++---- drizzle/meta/0002_snapshot.json | 34 ++- drizzle/meta/_journal.json | 2 +- src/db/schema/albums.ts | 9 +- src/db/schema/usages.ts | 57 +++-- src/modules/albums/grants.test.ts | 118 ++++++++-- src/modules/albums/grants.ts | 52 +++-- src/modules/usages/service.ts | 2 +- tests/db/accounting-migration-sql.test.ts | 33 +++ tests/db/accounting-migration.test.ts | 257 +++++++++++++++++----- 10 files changed, 559 insertions(+), 177 deletions(-) create mode 100644 tests/db/accounting-migration-sql.test.ts diff --git a/drizzle/0002_accounting_intents.sql b/drizzle/0002_accounting_intents.sql index 095e566..a472b75 100644 --- a/drizzle/0002_accounting_intents.sql +++ b/drizzle/0002_accounting_intents.sql @@ -1,73 +1,149 @@ -ALTER TABLE "album_grants" ALTER COLUMN "immich_album_id" SET DATA TYPE uuid USING lower("immich_album_id")::uuid;--> statement-breakpoint -ALTER TABLE "download_events" ALTER COLUMN "immich_asset_id" SET DATA TYPE uuid USING lower("immich_asset_id")::uuid;--> statement-breakpoint -ALTER TABLE "usages" ALTER COLUMN "immich_asset_id" SET DATA TYPE uuid USING lower("immich_asset_id")::uuid;--> statement-breakpoint -ALTER TABLE "usages" ALTER COLUMN "immich_album_id_snapshot" SET DATA TYPE uuid USING lower("immich_album_id_snapshot")::uuid;--> statement-breakpoint ALTER TABLE "download_events" ADD COLUMN "intent_kind" text;--> statement-breakpoint ALTER TABLE "download_events" ADD COLUMN "request_fingerprint" varchar(64);--> statement-breakpoint ALTER TABLE "download_events" ADD COLUMN "legacy_intent" boolean;--> statement-breakpoint --- Preserve arbitrary legacy keys, while canonicalizing every legacy UUID key that --- can be retried through the new UUID-only API. New rows are protected below. +-- UUID-shaped legacy keys are canonicalized only when doing so is unambiguous. +-- Arbitrary and case-colliding historical keys remain byte-for-byte unchanged. +WITH case_colliding_idempotency_keys AS ( + SELECT "editorial_account_id", lower("idempotency_key") AS canonical_key + FROM "download_events" + GROUP BY "editorial_account_id", lower("idempotency_key") + HAVING count(*) > 1 +) UPDATE "download_events" AS target -SET "idempotency_key" = lower("idempotency_key") +SET "idempotency_key" = lower(target."idempotency_key") WHERE target."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}$' AND NOT EXISTS ( SELECT 1 - FROM "download_events" AS sibling + FROM case_colliding_idempotency_keys AS collision WHERE - sibling."editorial_account_id" = target."editorial_account_id" - AND sibling."id" <> target."id" - AND lower(sibling."idempotency_key") = lower(target."idempotency_key") + collision."editorial_account_id" = target."editorial_account_id" + AND collision.canonical_key = lower(target."idempotency_key") );--> statement-breakpoint --- Legacy accounting deterministically treats the earliest event for each usage as --- its billable creation intent. Later events are repeat downloads. These are the --- only intent shapes whose original request can be reconstructed from stored data. -WITH ranked_legacy_events AS ( - SELECT - "id", - row_number() OVER ( - PARTITION BY "usage_id" - ORDER BY "authorized_at", "id" - ) AS usage_event_number +-- A legacy new usage is reconstructible only when it has one unique earliest, +-- note-free event and every runtime fingerprint field already satisfies the new +-- normalized input contract. A repeat additionally needs a normalized non-null +-- repeat note after that provable initial event. Every other row is explicit legacy. +WITH earliest_event_times AS ( + SELECT "usage_id", min("authorized_at") AS earliest_authorized_at FROM "download_events" + GROUP BY "usage_id" +), +case_colliding_idempotency_keys AS ( + SELECT "editorial_account_id", lower("idempotency_key") AS canonical_key + FROM "download_events" + GROUP BY "editorial_account_id", lower("idempotency_key") + HAVING count(*) > 1 +), +legacy_event_candidates AS ( + SELECT + events."id", + events."usage_id", + events."authorized_at", + earliest.earliest_authorized_at, + ( + events."repeat_download_note" IS NULL + AND events."editorial_account_id" = usage."editorial_account_id" + AND lower(events."immich_asset_id") = lower(usage."immich_asset_id") + AND 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}$' + AND usage."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}$' + AND usage."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}$' + AND 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}$' + AND usage."purpose" = btrim(usage."purpose") + AND char_length(usage."purpose") BETWEEN 3 AND 200 + AND ( + usage."internal_reference" IS NULL + OR ( + usage."internal_reference" = btrim(usage."internal_reference") + AND usage."internal_reference" <> '' + AND char_length(usage."internal_reference") <= 200 + ) + ) + AND NOT EXISTS ( + SELECT 1 + FROM case_colliding_idempotency_keys AS collision + WHERE + collision."editorial_account_id" = events."editorial_account_id" + AND collision.canonical_key = lower(events."idempotency_key") + ) + ) AS can_be_initial, + ( + events."editorial_account_id" = usage."editorial_account_id" + AND lower(events."immich_asset_id") = lower(usage."immich_asset_id") + AND 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}$' + AND 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}$' + AND events."repeat_download_note" = btrim(events."repeat_download_note") + AND events."repeat_download_note" <> '' + AND char_length(events."repeat_download_note") <= 200 + AND NOT EXISTS ( + SELECT 1 + FROM case_colliding_idempotency_keys AS collision + WHERE + collision."editorial_account_id" = events."editorial_account_id" + AND collision.canonical_key = lower(events."idempotency_key") + ) + ) AS can_be_repeat + FROM "download_events" AS events + INNER JOIN "usages" AS usage ON usage."id" = events."usage_id" + INNER JOIN earliest_event_times AS earliest ON earliest."usage_id" = events."usage_id" +), +usage_event_summary AS ( + SELECT + candidate."usage_id", + candidate.earliest_authorized_at, + count(*) FILTER ( + WHERE candidate."authorized_at" = candidate.earliest_authorized_at + ) AS earliest_event_count, + bool_and( + CASE + WHEN candidate."authorized_at" = candidate.earliest_authorized_at + THEN candidate.can_be_initial + ELSE true + END + ) AS earliest_event_is_provable + FROM legacy_event_candidates AS candidate + GROUP BY candidate."usage_id", candidate.earliest_authorized_at ) UPDATE "download_events" AS events SET "intent_kind" = CASE - WHEN ranked.usage_event_number = 1 THEN 'new_usage' - ELSE 'repeat_download' + WHEN + candidate."authorized_at" = summary.earliest_authorized_at + AND summary.earliest_event_count = 1 + AND candidate.can_be_initial + THEN 'new_usage' + WHEN + candidate."authorized_at" > summary.earliest_authorized_at + AND summary.earliest_event_count = 1 + AND summary.earliest_event_is_provable + AND candidate.can_be_repeat + THEN 'repeat_download' + ELSE 'legacy' END -FROM ranked_legacy_events AS ranked -WHERE ranked."id" = events."id";--> statement-breakpoint --- The string assembled here deliberately matches JSON.stringify's runtime field --- order. Valid legacy rows therefore receive the same SHA-256 as an equivalent --- retry; inconsistent rows receive a deterministic fingerprint no request can use. +FROM legacy_event_candidates AS candidate, usage_event_summary AS summary +WHERE + candidate."id" = events."id" + AND summary."usage_id" = candidate."usage_id";--> statement-breakpoint +-- Runtime-compatible rows receive the exact SHA-256 used by JSON.stringify in the +-- application. Explicit legacy rows receive a deterministic non-runtime hash. UPDATE "download_events" AS events SET "request_fingerprint" = CASE - WHEN - events."editorial_account_id" = usage."editorial_account_id" - AND events."immich_asset_id" = usage."immich_asset_id" - AND events."intent_kind" = 'new_usage' - THEN encode(sha256(convert_to( + WHEN events."intent_kind" = 'new_usage' THEN encode(sha256(convert_to( '{"kind":"new_usage","editorialId":' || to_json(events."editorial_account_id"::text)::text || - ',"assetId":' || to_json(events."immich_asset_id"::text)::text || - ',"albumId":' || to_json(usage."immich_album_id_snapshot"::text)::text || - ',"purpose":' || to_json(btrim(usage."purpose"))::text || - ',"reference":' || coalesce(to_json(nullif(btrim(usage."internal_reference"), ''))::text, 'null') || + ',"assetId":' || to_json(lower(events."immich_asset_id"))::text || + ',"albumId":' || to_json(lower(usage."immich_album_id_snapshot"))::text || + ',"purpose":' || to_json(usage."purpose")::text || + ',"reference":' || coalesce(to_json(usage."internal_reference")::text, 'null') || '}', 'UTF8' )), 'hex') - WHEN - events."editorial_account_id" = usage."editorial_account_id" - AND events."immich_asset_id" = usage."immich_asset_id" - AND events."intent_kind" = 'repeat_download' - THEN encode(sha256(convert_to( + WHEN events."intent_kind" = 'repeat_download' THEN encode(sha256(convert_to( '{"kind":"repeat_download","editorialId":' || to_json(events."editorial_account_id"::text)::text || ',"usageId":' || to_json(events."usage_id"::text)::text || - ',"note":' || coalesce(to_json(nullif(btrim(events."repeat_download_note"), ''))::text, 'null') || + ',"note":' || to_json(events."repeat_download_note")::text || '}', 'UTF8' )), 'hex') - ELSE encode(sha256(convert_to('unprovable-legacy-intent:' || events."id"::text, 'UTF8')), 'hex') + ELSE encode(sha256(convert_to('legacy-intent-v1:' || events."id"::text, 'UTF8')), 'hex') END FROM "usages" AS usage WHERE usage."id" = events."usage_id";--> statement-breakpoint @@ -77,6 +153,10 @@ ALTER TABLE "download_events" ALTER COLUMN "intent_kind" SET NOT NULL;--> statem ALTER TABLE "download_events" ALTER COLUMN "request_fingerprint" SET NOT NULL;--> statement-breakpoint ALTER TABLE "download_events" ALTER COLUMN "legacy_intent" SET DEFAULT false;--> statement-breakpoint ALTER TABLE "download_events" ALTER COLUMN "legacy_intent" SET NOT NULL;--> statement-breakpoint -ALTER TABLE "download_events" ADD CONSTRAINT "download_events_intent_kind_check" CHECK ("download_events"."intent_kind" in ('new_usage', 'repeat_download'));--> statement-breakpoint +ALTER TABLE "download_events" ADD CONSTRAINT "download_events_intent_kind_check" CHECK ("download_events"."intent_kind" in ('new_usage', 'repeat_download', 'legacy'));--> statement-breakpoint ALTER TABLE "download_events" ADD CONSTRAINT "download_events_request_fingerprint_hex_check" CHECK ("download_events"."request_fingerprint" ~ '^[0-9a-f]{64}$');--> statement-breakpoint -ALTER TABLE "download_events" ADD 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}$'); +ALTER TABLE "download_events" ADD 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}$');--> statement-breakpoint +ALTER TABLE "album_grants" ADD CONSTRAINT "album_grants_canonical_immich_album_id_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}$') NOT VALID;--> statement-breakpoint +ALTER TABLE "download_events" ADD 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}$') NOT VALID;--> statement-breakpoint +ALTER TABLE "usages" ADD 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}$') NOT VALID;--> statement-breakpoint +ALTER TABLE "usages" ADD 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}$') NOT VALID; diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json index 65a9bc4..006cf5a 100644 --- a/drizzle/meta/0002_snapshot.json +++ b/drizzle/meta/0002_snapshot.json @@ -1,5 +1,5 @@ { - "id": "f650c8ba-ebde-411d-92d0-caf0f9885c44", + "id": "8944c4e7-b3ab-47b5-a05b-91be6fb5c915", "prevId": "cfd5f4d1-55ac-46d9-9667-cd156f26e070", "version": "7", "dialect": "postgresql", @@ -23,7 +23,7 @@ }, "immich_album_id": { "name": "immich_album_id", - "type": "uuid", + "type": "text", "primaryKey": false, "notNull": true }, @@ -110,7 +110,12 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "album_grants_canonical_immich_album_id_check": { + "name": "album_grants_canonical_immich_album_id_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.audit_events": { @@ -1157,7 +1162,7 @@ }, "immich_asset_id": { "name": "immich_asset_id", - "type": "uuid", + "type": "text", "primaryKey": false, "notNull": true }, @@ -1290,7 +1295,7 @@ "checkConstraints": { "download_events_intent_kind_check": { "name": "download_events_intent_kind_check", - "value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download')" + "value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download', 'legacy')" }, "download_events_request_fingerprint_hex_check": { "name": "download_events_request_fingerprint_hex_check", @@ -1299,6 +1304,10 @@ "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 @@ -1322,7 +1331,7 @@ }, "immich_asset_id": { "name": "immich_asset_id", - "type": "uuid", + "type": "text", "primaryKey": false, "notNull": true }, @@ -1334,7 +1343,7 @@ }, "immich_album_id_snapshot": { "name": "immich_album_id_snapshot", - "type": "uuid", + "type": "text", "primaryKey": false, "notNull": true }, @@ -1416,7 +1425,16 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {}, "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 } }, diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 6b7c036..688ba50 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -19,7 +19,7 @@ { "idx": 2, "version": "7", - "when": 1786352073526, + "when": 1786354215684, "tag": "0002_accounting_intents", "breakpoints": true } diff --git a/src/db/schema/albums.ts b/src/db/schema/albums.ts index e35cb6a..e0c1bb8 100644 --- a/src/db/schema/albums.ts +++ b/src/db/schema/albums.ts @@ -1,4 +1,5 @@ -import { index, pgTable, timestamp, uuid } from "drizzle-orm/pg-core"; +import { sql } from "drizzle-orm"; +import { check, index, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; import { users } from "./auth"; import { editorialAccounts } from "./editorials"; @@ -10,7 +11,7 @@ export const albumGrants = pgTable( editorialAccountId: uuid("editorial_account_id") .notNull() .references(() => editorialAccounts.id, { onDelete: "restrict" }), - immichAlbumId: uuid("immich_album_id").notNull(), + immichAlbumId: text("immich_album_id").notNull(), grantedAt: timestamp("granted_at", { withTimezone: true }).notNull().defaultNow(), revokedAt: timestamp("revoked_at", { withTimezone: true }), grantedByUserId: uuid("granted_by_user_id").references(() => users.id, { @@ -20,5 +21,9 @@ export const albumGrants = pgTable( (table) => [ index("album_grants_editorial_account_id_idx").on(table.editorialAccountId), index("album_grants_immich_album_id_idx").on(table.immichAlbumId), + check( + "album_grants_canonical_immich_album_id_check", + sql`${table.immichAlbumId} ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`, + ), ], ); diff --git a/src/db/schema/usages.ts b/src/db/schema/usages.ts index cf63588..c24dd63 100644 --- a/src/db/schema/usages.ts +++ b/src/db/schema/usages.ts @@ -28,24 +28,37 @@ export const downloadStatuses = [ ] as const; export const downloadStatus = pgEnum("download_status", downloadStatuses); -export const usages = pgTable("usages", { - id: uuid("id").defaultRandom().primaryKey(), - editorialAccountId: uuid("editorial_account_id") - .notNull() - .references(() => editorialAccounts.id, { onDelete: "restrict" }), - immichAssetId: uuid("immich_asset_id").notNull(), - filenameSnapshot: text("filename_snapshot").notNull(), - immichAlbumIdSnapshot: uuid("immich_album_id_snapshot").notNull(), - albumNameSnapshot: text("album_name_snapshot").notNull(), - purpose: text("purpose").notNull(), - internalReference: text("internal_reference"), - priceCents: integer("price_cents").notNull(), - billingStatus: usageBillingStatus("billing_status").notNull().default("open"), - billingReportId: uuid("billing_report_id").references(() => billingReports.id, { - onDelete: "restrict", - }), - createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), -}); +export const usages = pgTable( + "usages", + { + id: uuid("id").defaultRandom().primaryKey(), + editorialAccountId: uuid("editorial_account_id") + .notNull() + .references(() => editorialAccounts.id, { onDelete: "restrict" }), + immichAssetId: text("immich_asset_id").notNull(), + filenameSnapshot: text("filename_snapshot").notNull(), + immichAlbumIdSnapshot: text("immich_album_id_snapshot").notNull(), + albumNameSnapshot: text("album_name_snapshot").notNull(), + purpose: text("purpose").notNull(), + internalReference: text("internal_reference"), + priceCents: integer("price_cents").notNull(), + billingStatus: usageBillingStatus("billing_status").notNull().default("open"), + billingReportId: uuid("billing_report_id").references(() => billingReports.id, { + onDelete: "restrict", + }), + createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(), + }, + (table) => [ + check( + "usages_canonical_immich_asset_id_check", + sql`${table.immichAssetId} ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`, + ), + check( + "usages_canonical_immich_album_id_check", + sql`${table.immichAlbumIdSnapshot} ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`, + ), + ], +); export const downloadEvents = pgTable( "download_events", @@ -57,7 +70,7 @@ export const downloadEvents = pgTable( usageId: uuid("usage_id") .notNull() .references(() => usages.id, { onDelete: "restrict" }), - immichAssetId: uuid("immich_asset_id").notNull(), + immichAssetId: text("immich_asset_id").notNull(), authorizedAt: timestamp("authorized_at", { withTimezone: true }).notNull().defaultNow(), startedAt: timestamp("started_at", { withTimezone: true }), completedAt: timestamp("completed_at", { withTimezone: true }), @@ -77,7 +90,7 @@ export const downloadEvents = pgTable( ), check( "download_events_intent_kind_check", - sql`${table.intentKind} in ('new_usage', 'repeat_download')`, + sql`${table.intentKind} in ('new_usage', 'repeat_download', 'legacy')`, ), check( "download_events_request_fingerprint_hex_check", @@ -87,5 +100,9 @@ export const downloadEvents = pgTable( "download_events_canonical_idempotency_key_check", sql`${table.legacyIntent} OR ${table.idempotencyKey} ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`, ), + check( + "download_events_canonical_immich_asset_id_check", + sql`${table.immichAssetId} ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`, + ), ], ); diff --git a/src/modules/albums/grants.test.ts b/src/modules/albums/grants.test.ts index ac210b4..a9bd7aa 100644 --- a/src/modules/albums/grants.test.ts +++ b/src/modules/albums/grants.test.ts @@ -18,6 +18,11 @@ type Audit = { newValues: Record; }; +const editorialUuid = "1111111a-1111-4111-8111-11111111111a"; +const albumUuid = "2222222b-2222-4222-8222-22222222222b"; +const adminUuid = "3333333c-3333-4333-8333-33333333333c"; +const unavailableAlbumUuid = "4444444d-4444-4444-8444-44444444444d"; + function createRepository(initial: Grant[] = []) { const grants = [...initial]; const audit: Audit[] = []; @@ -31,7 +36,7 @@ function createRepository(initial: Grant[] = []) { const active = grants.find( (grant) => grant.editorialId === input.editorialId && - grant.albumId === input.immichAlbumId && + grant.albumId.toLowerCase() === input.immichAlbumId && grant.revokedAt === null, ); if (active) return false; @@ -39,7 +44,7 @@ function createRepository(initial: Grant[] = []) { const revoked = grants.find( (grant) => grant.editorialId === input.editorialId && - grant.albumId === input.immichAlbumId && + grant.albumId.toLowerCase() === input.immichAlbumId && grant.revokedAt !== null, ); if (revoked) { @@ -61,7 +66,7 @@ function createRepository(initial: Grant[] = []) { const active = grants.find( (grant) => grant.editorialId === input.editorialId && - grant.albumId === input.immichAlbumId && + grant.albumId.toLowerCase() === input.immichAlbumId && grant.revokedAt === null, ); if (!active) return false; @@ -84,7 +89,7 @@ function createService(initial: Grant[] = []) { const { repository, grants, audit } = createRepository(initial); const immich = { getAlbum: vi.fn().mockResolvedValue({ - id: "album-1", + id: albumUuid, albumName: "Pressefotos", description: null, albumThumbnailAssetId: "cover-1", @@ -93,7 +98,7 @@ function createService(initial: Grant[] = []) { }), listAlbums: vi.fn().mockResolvedValue([ { - id: "album-1", + id: albumUuid, albumName: "Pressefotos", description: null, albumThumbnailAssetId: "cover-1", @@ -114,23 +119,80 @@ test("refuses to grant an album that the service user cannot read", async () => immich.getAlbum.mockRejectedValue({ code: "IMMICH_NOT_FOUND" }); await expect( - service.grantAlbum({ editorialId: "e1", immichAlbumId: "hidden", adminUserId: "a1" }), + service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: unavailableAlbumUuid, + adminUserId: adminUuid, + }), ).rejects.toMatchObject({ code: "ALBUM_NOT_ASSIGNABLE" }); }); +test("canonicalizes UUID grant input before Immich and repository side effects", async () => { + const { service, immich, grants } = createService(); + + await service.grantAlbum({ + editorialId: editorialUuid.toUpperCase(), + immichAlbumId: albumUuid.toUpperCase(), + adminUserId: adminUuid.toUpperCase(), + }); + + expect(immich.getAlbum).toHaveBeenCalledWith(albumUuid); + expect(grants).toEqual([ + { editorialId: editorialUuid, albumId: albumUuid, revokedAt: null }, + ]); +}); + +test("treats an uppercase historical album grant as the canonical active grant", async () => { + const { service, grants, audit } = createService([ + { editorialId: editorialUuid, albumId: albumUuid.toUpperCase(), revokedAt: null }, + ]); + + await expect(service.getGrantedAlbumIds(editorialUuid)).resolves.toEqual([albumUuid]); + await service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); + + expect(grants).toHaveLength(1); + expect(audit).toHaveLength(0); +}); + +test("rejects a non-UUID grant before external side effects", async () => { + const { service, immich, grants } = createService(); + + await expect( + service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: "legacy-album", + adminUserId: adminUuid, + }), + ).rejects.toMatchObject({ code: "INVALID_ALBUM_GRANT_INPUT" }); + expect(immich.getAlbum).not.toHaveBeenCalled(); + expect(grants).toHaveLength(0); +}); + test("granting an album is idempotent and records one state-change audit event", async () => { const { service, audit } = createService(); - await service.grantAlbum({ editorialId: "e1", immichAlbumId: "album-1", adminUserId: "a1" }); - await service.grantAlbum({ editorialId: "e1", immichAlbumId: "album-1", adminUserId: "a1" }); + await service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); + await service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); - await expect(service.getGrantedAlbumIds("e1")).resolves.toEqual(["album-1"]); + await expect(service.getGrantedAlbumIds(editorialUuid)).resolves.toEqual([albumUuid]); expect(audit).toEqual([ expect.objectContaining({ eventType: "album_granted", - actorUserId: "a1", - editorialId: "e1", - albumId: "album-1", + actorUserId: adminUuid, + editorialId: editorialUuid, + albumId: albumUuid, previousValues: { granted: false }, newValues: { granted: true }, }), @@ -139,29 +201,41 @@ test("granting an album is idempotent and records one state-change audit event", test("a revoked album can be re-granted without creating another current grant", async () => { const { service, grants } = createService([ - { editorialId: "e1", albumId: "album-1", revokedAt: new Date("2026-08-08T00:00:00Z") }, + { + editorialId: editorialUuid, + albumId: albumUuid, + revokedAt: new Date("2026-08-08T00:00:00Z"), + }, ]); - await service.grantAlbum({ editorialId: "e1", immichAlbumId: "album-1", adminUserId: "a1" }); + await service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); expect(grants).toHaveLength(1); - await expect(service.getGrantedAlbumIds("e1")).resolves.toEqual(["album-1"]); + await expect(service.getGrantedAlbumIds(editorialUuid)).resolves.toEqual([albumUuid]); }); test("revocation immediately removes the album from visible IDs and records the actor", async () => { const { service, audit } = createService([ - { editorialId: "e1", albumId: "album-1", revokedAt: null }, + { editorialId: editorialUuid, albumId: albumUuid, revokedAt: null }, ]); - await service.revokeAlbum({ editorialId: "e1", immichAlbumId: "album-1", adminUserId: "a1" }); + await service.revokeAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); - await expect(service.getGrantedAlbumIds("e1")).resolves.not.toContain("album-1"); + await expect(service.getGrantedAlbumIds(editorialUuid)).resolves.not.toContain(albumUuid); expect(audit).toContainEqual( expect.objectContaining({ eventType: "album_revoked", - actorUserId: "a1", - editorialId: "e1", - albumId: "album-1", + actorUserId: adminUuid, + editorialId: editorialUuid, + albumId: albumUuid, previousValues: { granted: true }, newValues: { granted: false }, }), @@ -176,7 +250,7 @@ test("reports a stable unavailable error when the Immich album list cannot be lo const { service, immich } = createService(); immich.listAlbums.mockRejectedValue({ code: "IMMICH_TIMEOUT" }); - await expect(service.listAssignableAlbums("e1")).rejects.toEqual( + await expect(service.listAssignableAlbums(editorialUuid)).rejects.toEqual( new AlbumGrantError("IMMICH_UNAVAILABLE"), ); }); diff --git a/src/modules/albums/grants.ts b/src/modules/albums/grants.ts index 9e57733..5f2ec56 100644 --- a/src/modules/albums/grants.ts +++ b/src/modules/albums/grants.ts @@ -49,36 +49,38 @@ export function createAlbumGrantService({ }) { return { async listAssignableAlbums(editorialId: string): Promise { - assertIdentifier(editorialId); + const normalizedEditorialId = normalizeIdentifier(editorialId); const [albums, grantedAlbumIds] = await Promise.all([ loadAlbums(immich), - repository.listActiveAlbumIds(editorialId), + repository.listActiveAlbumIds(normalizedEditorialId), ]); - const granted = new Set(grantedAlbumIds); - return albums.map((album) => ({ ...album, isGranted: granted.has(album.id) })); + const granted = new Set(grantedAlbumIds.map(canonicalizeStoredIdentifier)); + return albums.map((album) => ({ + ...album, + isGranted: granted.has(canonicalizeStoredIdentifier(album.id)), + })); }, async grantAlbum(input: AlbumGrantInput): Promise { - assertInput(input); + const normalizedInput = normalizeInput(input); try { - await immich.getAlbum(input.immichAlbumId); + await immich.getAlbum(normalizedInput.immichAlbumId); } catch (error) { if (hasCode(error, "IMMICH_NOT_FOUND")) { throw new AlbumGrantError("ALBUM_NOT_ASSIGNABLE"); } throw new AlbumGrantError("IMMICH_UNAVAILABLE"); } - await repository.grant(input); + await repository.grant(normalizedInput); }, async revokeAlbum(input: AlbumGrantInput): Promise { - assertInput(input); - await repository.revoke(input); + await repository.revoke(normalizeInput(input)); }, async getGrantedAlbumIds(editorialId: string): Promise { - assertIdentifier(editorialId); - return repository.listActiveAlbumIds(editorialId); + const albumIds = await repository.listActiveAlbumIds(normalizeIdentifier(editorialId)); + return albumIds.map(canonicalizeStoredIdentifier); }, }; } @@ -194,16 +196,30 @@ async function loadAlbums(immich: Pick): Promise { + expect(migration).not.toMatch(/ALTER COLUMN "immich_[^"]+" SET DATA TYPE uuid/); + expect(migration).toContain( + 'ADD CONSTRAINT "album_grants_canonical_immich_album_id_check"', + ); + expect(migration).toContain( + 'ADD CONSTRAINT "usages_canonical_immich_asset_id_check"', + ); + expect(migration).toContain( + 'ADD CONSTRAINT "usages_canonical_immich_album_id_check"', + ); + expect(migration).toContain( + 'ADD CONSTRAINT "download_events_canonical_immich_asset_id_check"', + ); + expect(migration.match(/NOT VALID/g)).toHaveLength(4); +}); + +test("0002 uses an explicit legacy kind instead of random UUID ordering for ambiguity", () => { + expect(migration).not.toContain('ORDER BY "authorized_at", "id"'); + expect(migration).toContain("ELSE 'legacy'"); + expect(migration).toContain("in ('new_usage', 'repeat_download', 'legacy')"); + expect(migration).toContain("case_colliding_idempotency_keys"); +}); diff --git a/tests/db/accounting-migration.test.ts b/tests/db/accounting-migration.test.ts index f7fd030..f3d742e 100644 --- a/tests/db/accounting-migration.test.ts +++ b/tests/db/accounting-migration.test.ts @@ -12,17 +12,66 @@ const testDb = await startPostgres({ through: "0001_editorial_approval_notice.sq afterAll(() => testDb.stop()); -test("0002 preserves an equivalent retry of a populated legacy accounting intent", async () => { +const validAssetId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; +const validAlbumId = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"; +const cleanKey = "cccccccc-cccc-4ccc-8ccc-cccccccccccc"; +const collidingKey = "dddddddd-dddd-4ddd-8ddd-dddddddddddd"; +const authorizedAt = new Date("2026-08-09T08:00:00.000Z"); + +async function insertLegacyUsage({ + editorialId, + assetId = validAssetId, + albumId = validAlbumId, + purpose = "Titelgeschichte", + reference = "Ausgabe 8/26", +}: { + editorialId: string; + assetId?: string; + albumId?: string; + purpose?: string; + reference?: string | null; +}) { + const usageId = randomUUID(); + await testDb.pool.query( + `insert into usages ( + id, editorial_account_id, immich_asset_id, filename_snapshot, + immich_album_id_snapshot, album_name_snapshot, purpose, + internal_reference, price_cents, billing_status, created_at + ) values ($1, $2, $3, 'legacy.jpg', $4, 'Legacy Album', $5, $6, 2300, 'open', $7)`, + [usageId, editorialId, assetId, albumId, purpose, reference, authorizedAt], + ); + return usageId; +} + +async function insertLegacyEvent({ + editorialId, + usageId, + assetId = validAssetId, + idempotencyKey = randomUUID(), + note = null, + at = authorizedAt, +}: { + editorialId: string; + usageId: string; + assetId?: string; + idempotencyKey?: string; + note?: string | null; + at?: Date; +}) { + const eventId = randomUUID(); + await testDb.pool.query( + `insert into download_events ( + id, editorial_account_id, usage_id, immich_asset_id, authorized_at, + status, repeat_download_note, request_id, idempotency_key + ) values ($1, $2, $3, $4, $5, 'authorized', $6, $7, $8)`, + [eventId, editorialId, usageId, assetId, at, note, randomUUID(), idempotencyKey], + ); + return eventId; +} + +test("0002 preserves dirty rows and reconstructs only provable legacy intents", async () => { const userId = randomUUID(); const editorialId = randomUUID(); - const usageId = randomUUID(); - const eventId = randomUUID(); - const requestId = randomUUID(); - const assetId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; - const albumId = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"; - const idempotencyKey = "cccccccc-cccc-4ccc-8ccc-cccccccccccc"; - const authorizedAt = new Date("2026-08-09T08:00:00.000Z"); - await testDb.pool.query( `insert into users (id, name, email, email_verified) values ($1, 'Legacy Redaktion', $2, true)`, @@ -36,33 +85,69 @@ test("0002 preserves an equivalent retry of a populated legacy accounting intent ); await testDb.pool.query( `insert into album_grants (editorial_account_id, immich_album_id) - values ($1, $2)`, - [editorialId, albumId.toUpperCase()], + values ($1, $2), ($1, $3)`, + [editorialId, validAlbumId.toUpperCase(), "legacy album / 2019"], ); - await testDb.pool.query( - `insert into usages ( - id, editorial_account_id, immich_asset_id, filename_snapshot, - immich_album_id_snapshot, album_name_snapshot, purpose, - internal_reference, price_cents, billing_status, created_at - ) values ($1, $2, $3, 'legacy.jpg', $4, 'Legacy Album', - 'Titelgeschichte', 'Ausgabe 8/26', 2300, 'open', $5)`, - [usageId, editorialId, assetId.toUpperCase(), albumId.toUpperCase(), authorizedAt], - ); - await testDb.pool.query( - `insert into download_events ( - id, editorial_account_id, usage_id, immich_asset_id, authorized_at, - status, request_id, idempotency_key - ) values ($1, $2, $3, $4, $5, 'authorized', $6, $7)`, - [ - eventId, + + const cleanUsageId = await insertLegacyUsage({ + editorialId, + assetId: validAssetId.toUpperCase(), + albumId: validAlbumId.toUpperCase(), + }); + const cleanEventId = await insertLegacyEvent({ + editorialId, + usageId: cleanUsageId, + assetId: validAssetId.toUpperCase(), + idempotencyKey: cleanKey.toUpperCase(), + }); + + const dirtyAssetId = "legacy-asset/not-a-uuid"; + const dirtyAlbumId = "legacy album / 2019"; + const dirtyUsageId = await insertLegacyUsage({ + editorialId, + assetId: dirtyAssetId, + albumId: dirtyAlbumId, + }); + const dirtyEventId = await insertLegacyEvent({ + editorialId, + usageId: dirtyUsageId, + assetId: dirtyAssetId, + idempotencyKey: "legacy-request", + }); + + const equalTimeUsageId = await insertLegacyUsage({ editorialId }); + const equalTimeEventIds = await Promise.all([ + insertLegacyEvent({ editorialId, usageId: equalTimeUsageId }), + insertLegacyEvent({ editorialId, - usageId, - assetId.toUpperCase(), - authorizedAt, - requestId, - idempotencyKey.toUpperCase(), - ], - ); + usageId: equalTimeUsageId, + note: "Wiederholung", + }), + ]); + + const contradictoryUsageId = await insertLegacyUsage({ editorialId }); + const contradictoryEventId = await insertLegacyEvent({ + editorialId, + usageId: contradictoryUsageId, + note: "Als Wiederholung markiert", + }); + + const collisionUsageIds = await Promise.all([ + insertLegacyUsage({ editorialId }), + insertLegacyUsage({ editorialId }), + ]); + const collisionEventIds = await Promise.all([ + insertLegacyEvent({ + editorialId, + usageId: collisionUsageIds[0], + idempotencyKey: collidingKey.toUpperCase(), + }), + insertLegacyEvent({ + editorialId, + usageId: collisionUsageIds[1], + idempotencyKey: collidingKey, + }), + ]); await testDb.applyRemainingMigrations(); @@ -74,19 +159,19 @@ test("0002 preserves an equivalent retry of a populated legacy accounting intent repository: createUsageServiceRepository(testDb.database), immich, }); - const input = { - editorialId: editorialId.toUpperCase(), - assetId: assetId.toUpperCase(), - albumId: albumId.toUpperCase(), - purpose: "Titelgeschichte", - reference: "Ausgabe 8/26", - idempotencyKey: idempotencyKey.toUpperCase(), - }; - - await expect(usageService.createNewUsage(input)).resolves.toEqual({ - id: eventId, - usageId, - assetId, + await expect( + usageService.createNewUsage({ + editorialId: editorialId.toUpperCase(), + assetId: validAssetId.toUpperCase(), + albumId: validAlbumId.toUpperCase(), + purpose: "Titelgeschichte", + reference: "Ausgabe 8/26", + idempotencyKey: cleanKey.toUpperCase(), + }), + ).resolves.toEqual({ + id: cleanEventId, + usageId: cleanUsageId, + assetId: validAssetId.toUpperCase(), priceCents: 2300, billable: true, status: "authorized", @@ -95,22 +180,76 @@ test("0002 preserves an equivalent retry of a populated legacy accounting intent expect(immich.listAlbumsForAsset).not.toHaveBeenCalled(); expect(immich.getAsset).not.toHaveBeenCalled(); - const [migrated] = await testDb.database - .select() - .from(downloadEvents) - .where(eq(downloadEvents.id, eventId)); - expect(migrated).toMatchObject({ - immichAssetId: assetId, - idempotencyKey, - intentKind: "new_usage", - legacyIntent: true, - requestFingerprint: requestFingerprint({ + const migratedEvents = await testDb.pool.query<{ + id: string; + idempotency_key: string; + immich_asset_id: string; + intent_kind: string; + request_fingerprint: string; + }>( + `select id, idempotency_key, immich_asset_id, intent_kind, request_fingerprint + from download_events`, + ); + expect(migratedEvents.rows).toHaveLength(7); + const byId = new Map(migratedEvents.rows.map((row) => [row.id, row])); + expect(byId.get(cleanEventId)).toMatchObject({ + idempotency_key: cleanKey, + immich_asset_id: validAssetId.toUpperCase(), + intent_kind: "new_usage", + request_fingerprint: requestFingerprint({ kind: "new_usage", editorialId, - assetId, - albumId, + assetId: validAssetId, + albumId: validAlbumId, purpose: "Titelgeschichte", reference: "Ausgabe 8/26", }), }); + expect(byId.get(dirtyEventId)).toMatchObject({ + idempotency_key: "legacy-request", + immich_asset_id: dirtyAssetId, + intent_kind: "legacy", + }); + for (const id of [ + ...equalTimeEventIds, + contradictoryEventId, + ...collisionEventIds, + ]) { + expect(byId.get(id)?.intent_kind).toBe("legacy"); + expect(byId.get(id)?.request_fingerprint).toMatch(/^[0-9a-f]{64}$/); + } + expect(collisionEventIds.map((id) => byId.get(id)?.idempotency_key).sort()).toEqual( + [collidingKey.toUpperCase(), collidingKey].sort(), + ); + + const dirtySnapshots = await testDb.pool.query<{ + immich_asset_id: string; + immich_album_id_snapshot: string; + }>("select immich_asset_id, immich_album_id_snapshot from usages where id = $1", [dirtyUsageId]); + expect(dirtySnapshots.rows[0]).toEqual({ + immich_asset_id: dirtyAssetId, + immich_album_id_snapshot: dirtyAlbumId, + }); + const dirtyGrant = await testDb.pool.query<{ immich_album_id: string }>( + "select immich_album_id from album_grants where immich_album_id = $1", + [dirtyAlbumId], + ); + expect(dirtyGrant.rows).toEqual([{ immich_album_id: dirtyAlbumId }]); + + await expect( + usageService.createNewUsage({ + editorialId, + assetId: validAssetId, + albumId: validAlbumId, + purpose: "Titelgeschichte", + reference: "Ausgabe 8/26", + idempotencyKey: collidingKey, + }), + ).rejects.toMatchObject({ code: "IDEMPOTENCY_CONFLICT" }); + + const [cleanEvent] = await testDb.database + .select() + .from(downloadEvents) + .where(eq(downloadEvents.id, cleanEventId)); + expect(cleanEvent).toMatchObject({ legacyIntent: true, intentKind: "new_usage" }); }); From 74ab2eb85fc8ae8d36931d10524b0ce0580cafff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Mon, 10 Aug 2026 11:53:28 +0200 Subject: [PATCH 18/29] fix: harden legacy normalization and grants --- drizzle/0002_accounting_intents.sql | 15 ++- src/modules/albums/grants.test.ts | 40 +++++++- src/modules/albums/grants.ts | 33 ++++-- tests/db/accounting-migration-sql.test.ts | 10 ++ tests/db/accounting-migration.test.ts | 120 +++++++++++++++++++++- 5 files changed, 198 insertions(+), 20 deletions(-) diff --git a/drizzle/0002_accounting_intents.sql b/drizzle/0002_accounting_intents.sql index a472b75..5bd80a1 100644 --- a/drizzle/0002_accounting_intents.sql +++ b/drizzle/0002_accounting_intents.sql @@ -49,12 +49,18 @@ legacy_event_candidates AS ( AND usage."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}$' AND usage."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}$' AND 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}$' - AND usage."purpose" = btrim(usage."purpose") + AND octet_length(usage."purpose") = char_length(usage."purpose") + AND usage."purpose" !~ '[[:cntrl:]]' + AND left(usage."purpose", 1) <> ' ' + AND right(usage."purpose", 1) <> ' ' AND char_length(usage."purpose") BETWEEN 3 AND 200 AND ( usage."internal_reference" IS NULL OR ( - usage."internal_reference" = btrim(usage."internal_reference") + octet_length(usage."internal_reference") = char_length(usage."internal_reference") + AND usage."internal_reference" !~ '[[:cntrl:]]' + AND left(usage."internal_reference", 1) <> ' ' + AND right(usage."internal_reference", 1) <> ' ' AND usage."internal_reference" <> '' AND char_length(usage."internal_reference") <= 200 ) @@ -72,7 +78,10 @@ legacy_event_candidates AS ( AND lower(events."immich_asset_id") = lower(usage."immich_asset_id") AND 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}$' AND 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}$' - AND events."repeat_download_note" = btrim(events."repeat_download_note") + AND octet_length(events."repeat_download_note") = char_length(events."repeat_download_note") + AND events."repeat_download_note" !~ '[[:cntrl:]]' + AND left(events."repeat_download_note", 1) <> ' ' + AND right(events."repeat_download_note", 1) <> ' ' AND events."repeat_download_note" <> '' AND char_length(events."repeat_download_note") <= 200 AND NOT EXISTS ( diff --git a/src/modules/albums/grants.test.ts b/src/modules/albums/grants.test.ts index a9bd7aa..bc16183 100644 --- a/src/modules/albums/grants.test.ts +++ b/src/modules/albums/grants.test.ts @@ -33,13 +33,16 @@ function createRepository(initial: Grant[] = []) { .map((grant) => grant.albumId); }, async grant(input) { - const active = grants.find( + const active = grants.filter( (grant) => grant.editorialId === input.editorialId && grant.albumId.toLowerCase() === input.immichAlbumId && grant.revokedAt === null, ); - if (active) return false; + if (active.length > 0) { + for (const grant of active) grant.albumId = input.immichAlbumId; + return false; + } const revoked = grants.find( (grant) => @@ -48,6 +51,7 @@ function createRepository(initial: Grant[] = []) { grant.revokedAt !== null, ); if (revoked) { + revoked.albumId = input.immichAlbumId; revoked.revokedAt = null; } else { grants.push({ editorialId: input.editorialId, albumId: input.immichAlbumId, revokedAt: null }); @@ -63,14 +67,17 @@ function createRepository(initial: Grant[] = []) { return true; }, async revoke(input) { - const active = grants.find( + const active = grants.filter( (grant) => grant.editorialId === input.editorialId && grant.albumId.toLowerCase() === input.immichAlbumId && grant.revokedAt === null, ); - if (!active) return false; - active.revokedAt = new Date(); + if (active.length === 0) return false; + for (const grant of active) { + grant.albumId = input.immichAlbumId; + grant.revokedAt = new Date(); + } audit.push({ eventType: "album_revoked", actorUserId: input.adminUserId, @@ -158,6 +165,29 @@ test("treats an uppercase historical album grant as the canonical active grant", expect(audit).toHaveLength(0); }); +test("revokes and regrants case-duplicate historical rows as one canonical grant", async () => { + const { service, grants, audit } = createService([ + { editorialId: editorialUuid, albumId: albumUuid.toUpperCase(), revokedAt: null }, + { editorialId: editorialUuid, albumId: albumUuid, revokedAt: null }, + ]); + + await service.revokeAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); + expect(grants.filter((grant) => grant.revokedAt === null)).toHaveLength(0); + expect(grants.every((grant) => grant.albumId === albumUuid)).toBe(true); + + await service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); + expect(grants.filter((grant) => grant.revokedAt === null)).toHaveLength(1); + expect(audit.map((event) => event.eventType)).toEqual(["album_revoked", "album_granted"]); +}); + test("rejects a non-UUID grant before external side effects", async () => { const { service, immich, grants } = createService(); diff --git a/src/modules/albums/grants.ts b/src/modules/albums/grants.ts index 5f2ec56..e7fec23 100644 --- a/src/modules/albums/grants.ts +++ b/src/modules/albums/grants.ts @@ -1,6 +1,6 @@ import "server-only"; -import { and, eq, isNull, sql } from "drizzle-orm"; +import { and, eq, inArray, isNull, sql } from "drizzle-orm"; import type { NodePgDatabase } from "drizzle-orm/node-postgres"; import { db } from "@/db/client"; @@ -102,17 +102,23 @@ export function createAlbumGrantRepository( await lockEditorialAlbumMutation(transaction, input.editorialId); const editorial = await lockEditorial(transaction, input.editorialId); const grants = await lockAlbumGrants(transaction, input.editorialId, input.immichAlbumId); - const activeGrant = grants.find((grant) => grant.revokedAt === null); - if (activeGrant) { + const activeGrants = grants.filter((grant) => grant.revokedAt === null); + if (activeGrants.length > 0) { + await transaction + .update(albumGrants) + .set({ immichAlbumId: input.immichAlbumId }) + .where(inArray(albumGrants.id, activeGrants.map((grant) => grant.id))); return false; } const changedAt = new Date(); - const previousGrant = grants[0]; + const previousGrant = + grants.find((grant) => grant.immichAlbumId === input.immichAlbumId) ?? grants[0]; if (previousGrant) { await transaction .update(albumGrants) .set({ + immichAlbumId: input.immichAlbumId, grantedAt: changedAt, grantedByUserId: input.adminUserId, revokedAt: null, @@ -154,16 +160,21 @@ export function createAlbumGrantRepository( await lockEditorialAlbumMutation(transaction, input.editorialId); const editorial = await lockEditorial(transaction, input.editorialId); const grants = await lockAlbumGrants(transaction, input.editorialId, input.immichAlbumId); - const activeGrant = grants.find((grant) => grant.revokedAt === null); - if (!activeGrant) { + const activeGrants = grants.filter((grant) => grant.revokedAt === null); + if (activeGrants.length === 0) { return false; } const changedAt = new Date(); await transaction .update(albumGrants) - .set({ revokedAt: changedAt }) - .where(and(eq(albumGrants.id, activeGrant.id), isNull(albumGrants.revokedAt))); + .set({ immichAlbumId: input.immichAlbumId, revokedAt: changedAt }) + .where( + and( + inArray(albumGrants.id, activeGrants.map((grant) => grant.id)), + isNull(albumGrants.revokedAt), + ), + ); await transaction.insert(auditEvents).values({ eventType: "album_revoked", actorUserId: input.adminUserId, @@ -257,7 +268,11 @@ async function lockAlbumGrants( immichAlbumId: string, ) { return transaction - .select({ id: albumGrants.id, revokedAt: albumGrants.revokedAt }) + .select({ + id: albumGrants.id, + immichAlbumId: albumGrants.immichAlbumId, + revokedAt: albumGrants.revokedAt, + }) .from(albumGrants) .where( and( diff --git a/tests/db/accounting-migration-sql.test.ts b/tests/db/accounting-migration-sql.test.ts index 0b02e6d..042d796 100644 --- a/tests/db/accounting-migration-sql.test.ts +++ b/tests/db/accounting-migration-sql.test.ts @@ -31,3 +31,13 @@ test("0002 uses an explicit legacy kind instead of random UUID ordering for ambi expect(migration).toContain("in ('new_usage', 'repeat_download', 'legacy')"); expect(migration).toContain("case_colliding_idempotency_keys"); }); + +test("0002 reconstructs only already-normalized printable ASCII text", () => { + expect(migration).not.toContain("btrim("); + expect(migration).toContain( + 'octet_length(usage."purpose") = char_length(usage."purpose")', + ); + expect(migration).toContain("!~ '[[:cntrl:]]'"); + expect(migration).toContain("left(usage.\"purpose\", 1) <> ' '"); + expect(migration).toContain("right(events.\"repeat_download_note\", 1) <> ' '"); +}); diff --git a/tests/db/accounting-migration.test.ts b/tests/db/accounting-migration.test.ts index f3d742e..a575e05 100644 --- a/tests/db/accounting-migration.test.ts +++ b/tests/db/accounting-migration.test.ts @@ -4,6 +4,7 @@ import { eq } from "drizzle-orm"; import { afterAll, expect, test, vi } from "vitest"; import { downloadEvents } from "@/db/schema"; +import { createAlbumGrantRepository, createAlbumGrantService } from "@/modules/albums/grants"; import { createUsageService, createUsageServiceRepository } from "@/modules/usages/service"; import { requestFingerprint } from "@/modules/usages/types"; import { startPostgres } from "./postgres"; @@ -17,6 +18,8 @@ const validAlbumId = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"; const cleanKey = "cccccccc-cccc-4ccc-8ccc-cccccccccccc"; const collidingKey = "dddddddd-dddd-4ddd-8ddd-dddddddddddd"; const authorizedAt = new Date("2026-08-09T08:00:00.000Z"); +const repeatAt = new Date("2026-08-09T08:01:00.000Z"); +const laterNullAt = new Date("2026-08-09T08:02:00.000Z"); async function insertLegacyUsage({ editorialId, @@ -85,8 +88,8 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", ); await testDb.pool.query( `insert into album_grants (editorial_account_id, immich_album_id) - values ($1, $2), ($1, $3)`, - [editorialId, validAlbumId.toUpperCase(), "legacy album / 2019"], + values ($1, $2), ($1, $3), ($1, $4)`, + [editorialId, validAlbumId.toUpperCase(), "legacy album / 2019", validAlbumId], ); const cleanUsageId = await insertLegacyUsage({ @@ -101,6 +104,48 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", idempotencyKey: cleanKey.toUpperCase(), }); + const repeatUsageId = await insertLegacyUsage({ editorialId }); + const repeatInitialEventId = await insertLegacyEvent({ editorialId, usageId: repeatUsageId }); + const provableRepeatEventId = await insertLegacyEvent({ + editorialId, + usageId: repeatUsageId, + note: "Web-Ausgabe", + at: repeatAt, + }); + const laterNullEventId = await insertLegacyEvent({ + editorialId, + usageId: repeatUsageId, + at: laterNullAt, + }); + + const tabPurposeUsageId = await insertLegacyUsage({ + editorialId, + purpose: "\tTitelgeschichte", + }); + const tabPurposeEventId = await insertLegacyEvent({ + editorialId, + usageId: tabPurposeUsageId, + }); + const newlineReferenceUsageId = await insertLegacyUsage({ + editorialId, + reference: "Ausgabe 8/26\n", + }); + const newlineReferenceEventId = await insertLegacyEvent({ + editorialId, + usageId: newlineReferenceUsageId, + }); + const nbspNoteUsageId = await insertLegacyUsage({ editorialId }); + const nbspNoteInitialEventId = await insertLegacyEvent({ + editorialId, + usageId: nbspNoteUsageId, + }); + const nbspNoteEventId = await insertLegacyEvent({ + editorialId, + usageId: nbspNoteUsageId, + note: "\u00a0Web-Ausgabe", + at: repeatAt, + }); + const dirtyAssetId = "legacy-asset/not-a-uuid"; const dirtyAlbumId = "legacy album / 2019"; const dirtyUsageId = await insertLegacyUsage({ @@ -190,7 +235,7 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", `select id, idempotency_key, immich_asset_id, intent_kind, request_fingerprint from download_events`, ); - expect(migratedEvents.rows).toHaveLength(7); + expect(migratedEvents.rows).toHaveLength(14); const byId = new Map(migratedEvents.rows.map((row) => [row.id, row])); expect(byId.get(cleanEventId)).toMatchObject({ idempotency_key: cleanKey, @@ -210,7 +255,21 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", immich_asset_id: dirtyAssetId, intent_kind: "legacy", }); + expect(byId.get(repeatInitialEventId)?.intent_kind).toBe("new_usage"); + expect(byId.get(provableRepeatEventId)).toMatchObject({ + intent_kind: "repeat_download", + request_fingerprint: requestFingerprint({ + kind: "repeat_download", + editorialId, + usageId: repeatUsageId, + note: "Web-Ausgabe", + }), + }); for (const id of [ + laterNullEventId, + tabPurposeEventId, + newlineReferenceEventId, + nbspNoteEventId, ...equalTimeEventIds, contradictoryEventId, ...collisionEventIds, @@ -218,6 +277,7 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", expect(byId.get(id)?.intent_kind).toBe("legacy"); expect(byId.get(id)?.request_fingerprint).toMatch(/^[0-9a-f]{64}$/); } + expect(byId.get(nbspNoteInitialEventId)?.intent_kind).toBe("new_usage"); expect(collisionEventIds.map((id) => byId.get(id)?.idempotency_key).sort()).toEqual( [collidingKey.toUpperCase(), collidingKey].sort(), ); @@ -236,6 +296,60 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", ); expect(dirtyGrant.rows).toEqual([{ immich_album_id: dirtyAlbumId }]); + await expect( + testDb.pool.query( + "insert into album_grants (editorial_account_id, immich_album_id) values ($1, $2)", + [editorialId, "new-invalid-album"], + ), + ).rejects.toThrow(/album_grants_canonical_immich_album_id_check/); + await expect( + testDb.pool.query( + "update album_grants set revoked_at = now() where immich_album_id = $1", + [dirtyAlbumId], + ), + ).rejects.toThrow(/album_grants_canonical_immich_album_id_check/); + + const grantService = createAlbumGrantService({ + repository: createAlbumGrantRepository(testDb.database), + immich: { + getAlbum: vi.fn().mockResolvedValue({ + id: validAlbumId, + albumName: "Legacy Album", + description: null, + albumThumbnailAssetId: null, + assetCount: 0, + assets: [], + }), + listAlbums: vi.fn(), + }, + }); + await grantService.revokeAlbum({ + editorialId, + immichAlbumId: validAlbumId, + adminUserId: userId, + }); + let canonicalGrantRows = await testDb.pool.query<{ + immich_album_id: string; + revoked_at: Date | null; + }>( + "select immich_album_id, revoked_at from album_grants where lower(immich_album_id) = $1", + [validAlbumId], + ); + expect(canonicalGrantRows.rows).toHaveLength(2); + expect(canonicalGrantRows.rows.every((row) => row.immich_album_id === validAlbumId)).toBe(true); + expect(canonicalGrantRows.rows.every((row) => row.revoked_at !== null)).toBe(true); + + await grantService.grantAlbum({ + editorialId, + immichAlbumId: validAlbumId, + adminUserId: userId, + }); + canonicalGrantRows = await testDb.pool.query( + "select immich_album_id, revoked_at from album_grants where lower(immich_album_id) = $1", + [validAlbumId], + ); + expect(canonicalGrantRows.rows.filter((row) => row.revoked_at === null)).toHaveLength(1); + await expect( usageService.createNewUsage({ editorialId, From c400167b8f2682ca5414c2ccffbffb31e767fdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Mon, 10 Aug 2026 12:14:38 +0200 Subject: [PATCH 19/29] fix: enforce one active logical album grant --- drizzle/0002_accounting_intents.sql | 17 +- drizzle/meta/0002_snapshot.json | 30 ++- drizzle/meta/_journal.json | 2 +- src/db/schema/albums.ts | 9 +- src/modules/albums/grants.test.ts | 153 ++++++++++-- src/modules/albums/grants.ts | 102 ++++++-- tests/db/accounting-migration-sql.test.ts | 24 +- tests/db/accounting-migration.test.ts | 8 +- tests/db/album-grants.test.ts | 277 ++++++++++++++++++++++ 9 files changed, 577 insertions(+), 45 deletions(-) create mode 100644 tests/db/album-grants.test.ts diff --git a/drizzle/0002_accounting_intents.sql b/drizzle/0002_accounting_intents.sql index 5bd80a1..0c6cd9a 100644 --- a/drizzle/0002_accounting_intents.sql +++ b/drizzle/0002_accounting_intents.sql @@ -165,7 +165,22 @@ ALTER TABLE "download_events" ALTER COLUMN "legacy_intent" SET NOT NULL;--> stat ALTER TABLE "download_events" ADD CONSTRAINT "download_events_intent_kind_check" CHECK ("download_events"."intent_kind" in ('new_usage', 'repeat_download', 'legacy'));--> statement-breakpoint ALTER TABLE "download_events" ADD CONSTRAINT "download_events_request_fingerprint_hex_check" CHECK ("download_events"."request_fingerprint" ~ '^[0-9a-f]{64}$');--> statement-breakpoint ALTER TABLE "download_events" ADD 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}$');--> statement-breakpoint -ALTER TABLE "album_grants" ADD CONSTRAINT "album_grants_canonical_immich_album_id_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}$') NOT VALID;--> statement-breakpoint +WITH ranked_active_album_grants AS ( + SELECT + "id", + row_number() OVER ( + PARTITION BY "editorial_account_id", lower("immich_album_id") + ORDER BY ("immich_album_id" = lower("immich_album_id")) DESC, "granted_at", "id" + ) AS survivor_order + FROM "album_grants" + WHERE "revoked_at" IS NULL +) +UPDATE "album_grants" AS grants +SET "revoked_at" = now() +FROM ranked_active_album_grants AS ranked +WHERE grants."id" = ranked."id" AND ranked.survivor_order > 1;--> statement-breakpoint +CREATE UNIQUE INDEX "album_grants_editorial_active_album_unique" ON "album_grants" ("editorial_account_id", lower("immich_album_id")) WHERE "revoked_at" IS NULL;--> statement-breakpoint +ALTER TABLE "album_grants" ADD 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}$') NOT VALID;--> statement-breakpoint ALTER TABLE "download_events" ADD 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}$') NOT VALID;--> statement-breakpoint ALTER TABLE "usages" ADD 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}$') NOT VALID;--> statement-breakpoint ALTER TABLE "usages" ADD 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}$') NOT VALID; diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json index 006cf5a..82cc37a 100644 --- a/drizzle/meta/0002_snapshot.json +++ b/drizzle/meta/0002_snapshot.json @@ -77,6 +77,28 @@ "concurrently": false, "method": "btree", "with": {} + }, + "album_grants_editorial_active_album_unique": { + "name": "album_grants_editorial_active_album_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"immich_album_id\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"album_grants\".\"revoked_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { @@ -111,9 +133,9 @@ "uniqueConstraints": {}, "policies": {}, "checkConstraints": { - "album_grants_canonical_immich_album_id_check": { - "name": "album_grants_canonical_immich_album_id_check", - "value": "\"album_grants\".\"immich_album_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + "album_grants_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 @@ -1498,4 +1520,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 688ba50..c9e805a 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -24,4 +24,4 @@ "breakpoints": true } ] -} \ No newline at end of file +} diff --git a/src/db/schema/albums.ts b/src/db/schema/albums.ts index e0c1bb8..bc50eaf 100644 --- a/src/db/schema/albums.ts +++ b/src/db/schema/albums.ts @@ -1,5 +1,5 @@ import { sql } from "drizzle-orm"; -import { check, index, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; +import { check, index, pgTable, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core"; import { users } from "./auth"; import { editorialAccounts } from "./editorials"; @@ -21,9 +21,12 @@ export const albumGrants = pgTable( (table) => [ index("album_grants_editorial_account_id_idx").on(table.editorialAccountId), index("album_grants_immich_album_id_idx").on(table.immichAlbumId), + uniqueIndex("album_grants_editorial_active_album_unique") + .on(table.editorialAccountId, sql`lower(${table.immichAlbumId})`) + .where(sql`${table.revokedAt} is null`), check( - "album_grants_canonical_immich_album_id_check", - sql`${table.immichAlbumId} ~ '^[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_immich_album_id_uuid_check", + sql`${table.immichAlbumId} ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'`, ), ], ); diff --git a/src/modules/albums/grants.test.ts b/src/modules/albums/grants.test.ts index bc16183..fc86878 100644 --- a/src/modules/albums/grants.test.ts +++ b/src/modules/albums/grants.test.ts @@ -4,6 +4,8 @@ import { ALBUM_GRANT_LOCK_ORDER, AlbumGrantError, createAlbumGrantService, + planAlbumGrantMutation, + planAlbumRevokeMutation, type AlbumGrantRepository, } from "./grants"; import { EDITORIAL_MUTATION_LOCK_ORDER } from "@/modules/editorials/service"; @@ -23,6 +25,96 @@ const albumUuid = "2222222b-2222-4222-8222-22222222222b"; const adminUuid = "3333333c-3333-4333-8333-33333333333c"; const unavailableAlbumUuid = "4444444d-4444-4444-8444-44444444444d"; +const earlierGrant = new Date("2026-08-07T08:00:00.000Z"); +const laterGrant = new Date("2026-08-08T08:00:00.000Z"); + +test("direct grant keeps the exact canonical row and retires every active case variant", () => { + expect( + planAlbumGrantMutation( + [ + { + id: "00000000-0000-4000-8000-000000000001", + immichAlbumId: albumUuid.toUpperCase(), + grantedAt: earlierGrant, + revokedAt: null, + }, + { + id: "00000000-0000-4000-8000-000000000002", + immichAlbumId: albumUuid, + grantedAt: laterGrant, + revokedAt: null, + }, + ], + albumUuid, + ), + ).toEqual({ + survivorId: "00000000-0000-4000-8000-000000000002", + activeLoserIds: ["00000000-0000-4000-8000-000000000001"], + hadActiveGrant: true, + }); +}); + +test("regrant chooses the oldest revoked case variant then its stable id", () => { + const revokedAt = new Date("2026-08-09T08:00:00.000Z"); + expect( + planAlbumGrantMutation( + [ + { + id: "00000000-0000-4000-8000-000000000003", + immichAlbumId: albumUuid.toUpperCase(), + grantedAt: laterGrant, + revokedAt, + }, + { + id: "00000000-0000-4000-8000-000000000002", + immichAlbumId: "2222222B-2222-4222-8222-22222222222b", + grantedAt: earlierGrant, + revokedAt, + }, + { + id: "00000000-0000-4000-8000-000000000001", + immichAlbumId: "2222222b-2222-4222-8222-22222222222B", + grantedAt: earlierGrant, + revokedAt, + }, + ], + albumUuid, + ), + ).toEqual({ + survivorId: "00000000-0000-4000-8000-000000000001", + activeLoserIds: [], + hadActiveGrant: false, + }); +}); + +test("revoke targets every active case-equivalent row", () => { + expect( + planAlbumRevokeMutation([ + { + id: "00000000-0000-4000-8000-000000000003", + immichAlbumId: albumUuid.toUpperCase(), + grantedAt: laterGrant, + revokedAt: null, + }, + { + id: "00000000-0000-4000-8000-000000000001", + immichAlbumId: albumUuid, + grantedAt: earlierGrant, + revokedAt: null, + }, + { + id: "00000000-0000-4000-8000-000000000002", + immichAlbumId: albumUuid, + grantedAt: earlierGrant, + revokedAt: new Date("2026-08-09T08:00:00.000Z"), + }, + ]), + ).toEqual([ + "00000000-0000-4000-8000-000000000001", + "00000000-0000-4000-8000-000000000003", + ]); +}); + function createRepository(initial: Grant[] = []) { const grants = [...initial]; const audit: Audit[] = []; @@ -33,26 +125,28 @@ function createRepository(initial: Grant[] = []) { .map((grant) => grant.albumId); }, async grant(input) { - const active = grants.filter( + const matching = grants.filter( (grant) => grant.editorialId === input.editorialId && - grant.albumId.toLowerCase() === input.immichAlbumId && - grant.revokedAt === null, + grant.albumId.toLowerCase() === input.immichAlbumId, ); + const survivor = + matching.find((grant) => grant.albumId === input.immichAlbumId) ?? matching[0]; + const active = matching.filter((grant) => grant.revokedAt === null); if (active.length > 0) { - for (const grant of active) grant.albumId = input.immichAlbumId; + for (const grant of active) { + if (grant !== survivor) grant.revokedAt = new Date(); + } + if (survivor) { + survivor.albumId = input.immichAlbumId; + survivor.revokedAt = null; + } return false; } - const revoked = grants.find( - (grant) => - grant.editorialId === input.editorialId && - grant.albumId.toLowerCase() === input.immichAlbumId && - grant.revokedAt !== null, - ); - if (revoked) { - revoked.albumId = input.immichAlbumId; - revoked.revokedAt = null; + if (survivor) { + survivor.albumId = input.immichAlbumId; + survivor.revokedAt = null; } else { grants.push({ editorialId: input.editorialId, albumId: input.immichAlbumId, revokedAt: null }); } @@ -75,7 +169,6 @@ function createRepository(initial: Grant[] = []) { ); if (active.length === 0) return false; for (const grant of active) { - grant.albumId = input.immichAlbumId; grant.revokedAt = new Date(); } audit.push({ @@ -165,6 +258,37 @@ test("treats an uppercase historical album grant as the canonical active grant", expect(audit).toHaveLength(0); }); +test("returns one canonical active ID when historical rows contain case duplicates", async () => { + const { service } = createService([ + { editorialId: editorialUuid, albumId: albumUuid.toUpperCase(), revokedAt: null }, + { editorialId: editorialUuid, albumId: albumUuid, revokedAt: null }, + ]); + + await expect(service.getGrantedAlbumIds(editorialUuid)).resolves.toEqual([albumUuid]); +}); + +test("direct grant consolidates active case variants without a second logical audit", async () => { + const { service, grants, audit } = createService([ + { editorialId: editorialUuid, albumId: albumUuid.toUpperCase(), revokedAt: null }, + { editorialId: editorialUuid, albumId: albumUuid, revokedAt: null }, + ]); + + await service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); + await service.grantAlbum({ + editorialId: editorialUuid, + immichAlbumId: albumUuid, + adminUserId: adminUuid, + }); + + expect(grants.filter((grant) => grant.revokedAt === null)).toHaveLength(1); + await expect(service.getGrantedAlbumIds(editorialUuid)).resolves.toEqual([albumUuid]); + expect(audit).toHaveLength(0); +}); + test("revokes and regrants case-duplicate historical rows as one canonical grant", async () => { const { service, grants, audit } = createService([ { editorialId: editorialUuid, albumId: albumUuid.toUpperCase(), revokedAt: null }, @@ -177,7 +301,6 @@ test("revokes and regrants case-duplicate historical rows as one canonical grant adminUserId: adminUuid, }); expect(grants.filter((grant) => grant.revokedAt === null)).toHaveLength(0); - expect(grants.every((grant) => grant.albumId === albumUuid)).toBe(true); await service.grantAlbum({ editorialId: editorialUuid, diff --git a/src/modules/albums/grants.ts b/src/modules/albums/grants.ts index e7fec23..15c46b5 100644 --- a/src/modules/albums/grants.ts +++ b/src/modules/albums/grants.ts @@ -1,6 +1,6 @@ import "server-only"; -import { and, eq, inArray, isNull, sql } from "drizzle-orm"; +import { and, asc, eq, inArray, isNull, sql } from "drizzle-orm"; import type { NodePgDatabase } from "drizzle-orm/node-postgres"; import { db } from "@/db/client"; @@ -24,6 +24,19 @@ export type AlbumGrantRepository = { revoke(input: AlbumGrantInput): Promise; }; +export type AlbumGrantMutationCandidate = { + id: string; + immichAlbumId: string; + grantedAt: Date; + revokedAt: Date | null; +}; + +export type AlbumGrantMutationPlan = { + survivorId: string | null; + activeLoserIds: string[]; + hadActiveGrant: boolean; +}; + export const ALBUM_GRANT_LOCK_ORDER = EDITORIAL_MUTATION_LOCK_ORDER; export class AlbumGrantError extends Error { @@ -80,7 +93,7 @@ export function createAlbumGrantService({ async getGrantedAlbumIds(editorialId: string): Promise { const albumIds = await repository.listActiveAlbumIds(normalizeIdentifier(editorialId)); - return albumIds.map(canonicalizeStoredIdentifier); + return uniqueCanonicalIdentifiers(albumIds); }, }; } @@ -94,7 +107,7 @@ export function createAlbumGrantRepository( .select({ immichAlbumId: albumGrants.immichAlbumId }) .from(albumGrants) .where(and(eq(albumGrants.editorialAccountId, editorialId), isNull(albumGrants.revokedAt))); - return grants.map((grant) => grant.immichAlbumId); + return uniqueCanonicalIdentifiers(grants.map((grant) => grant.immichAlbumId)); }, async grant(input) { @@ -102,19 +115,27 @@ export function createAlbumGrantRepository( await lockEditorialAlbumMutation(transaction, input.editorialId); const editorial = await lockEditorial(transaction, input.editorialId); const grants = await lockAlbumGrants(transaction, input.editorialId, input.immichAlbumId); - const activeGrants = grants.filter((grant) => grant.revokedAt === null); - if (activeGrants.length > 0) { + const plan = planAlbumGrantMutation(grants, input.immichAlbumId); + const changedAt = new Date(); + + if (plan.activeLoserIds.length > 0) { await transaction .update(albumGrants) - .set({ immichAlbumId: input.immichAlbumId }) - .where(inArray(albumGrants.id, activeGrants.map((grant) => grant.id))); + .set({ revokedAt: changedAt }) + .where( + and(inArray(albumGrants.id, plan.activeLoserIds), isNull(albumGrants.revokedAt)), + ); + } + + if (plan.hadActiveGrant) { + await transaction + .update(albumGrants) + .set({ immichAlbumId: input.immichAlbumId, revokedAt: null }) + .where(eq(albumGrants.id, plan.survivorId!)); return false; } - const changedAt = new Date(); - const previousGrant = - grants.find((grant) => grant.immichAlbumId === input.immichAlbumId) ?? grants[0]; - if (previousGrant) { + if (plan.survivorId) { await transaction .update(albumGrants) .set({ @@ -123,7 +144,7 @@ export function createAlbumGrantRepository( grantedByUserId: input.adminUserId, revokedAt: null, }) - .where(eq(albumGrants.id, previousGrant.id)); + .where(eq(albumGrants.id, plan.survivorId)); } else { await transaction.insert(albumGrants).values({ editorialAccountId: editorial.id, @@ -160,18 +181,18 @@ export function createAlbumGrantRepository( await lockEditorialAlbumMutation(transaction, input.editorialId); const editorial = await lockEditorial(transaction, input.editorialId); const grants = await lockAlbumGrants(transaction, input.editorialId, input.immichAlbumId); - const activeGrants = grants.filter((grant) => grant.revokedAt === null); - if (activeGrants.length === 0) { + const activeGrantIds = planAlbumRevokeMutation(grants); + if (activeGrantIds.length === 0) { return false; } const changedAt = new Date(); await transaction .update(albumGrants) - .set({ immichAlbumId: input.immichAlbumId, revokedAt: changedAt }) + .set({ revokedAt: changedAt }) .where( and( - inArray(albumGrants.id, activeGrants.map((grant) => grant.id)), + inArray(albumGrants.id, activeGrantIds), isNull(albumGrants.revokedAt), ), ); @@ -233,6 +254,49 @@ function canonicalizeStoredIdentifier(value: string): string { : value; } +function uniqueCanonicalIdentifiers(values: string[]): string[] { + return [...new Set(values.map(canonicalizeStoredIdentifier))]; +} + +export function planAlbumGrantMutation( + grants: AlbumGrantMutationCandidate[], + canonicalImmichAlbumId: string, +): AlbumGrantMutationPlan { + const ordered = [...grants].sort((left, right) => + compareGrantCandidates(left, right, canonicalImmichAlbumId), + ); + const survivorId = ordered[0]?.id ?? null; + return { + survivorId, + activeLoserIds: ordered + .filter((grant) => grant.revokedAt === null && grant.id !== survivorId) + .map((grant) => grant.id), + hadActiveGrant: ordered.some((grant) => grant.revokedAt === null), + }; +} + +export function planAlbumRevokeMutation(grants: AlbumGrantMutationCandidate[]): string[] { + return grants + .filter((grant) => grant.revokedAt === null) + .map((grant) => grant.id) + .sort(); +} + +function compareGrantCandidates( + left: AlbumGrantMutationCandidate, + right: AlbumGrantMutationCandidate, + canonicalImmichAlbumId: string, +): number { + const exactCaseOrder = + Number(left.immichAlbumId !== canonicalImmichAlbumId) - + Number(right.immichAlbumId !== canonicalImmichAlbumId); + if (exactCaseOrder !== 0) return exactCaseOrder; + + const grantedAtOrder = left.grantedAt.getTime() - right.grantedAt.getTime(); + if (grantedAtOrder !== 0) return grantedAtOrder; + return left.id < right.id ? -1 : left.id > right.id ? 1 : 0; +} + function hasCode(error: unknown, code: string): boolean { return typeof error === "object" && error !== null && "code" in error && error.code === code; } @@ -271,6 +335,7 @@ async function lockAlbumGrants( .select({ id: albumGrants.id, immichAlbumId: albumGrants.immichAlbumId, + grantedAt: albumGrants.grantedAt, revokedAt: albumGrants.revokedAt, }) .from(albumGrants) @@ -280,6 +345,11 @@ async function lockAlbumGrants( sql`lower(${albumGrants.immichAlbumId}) = ${immichAlbumId}`, ), ) + .orderBy( + sql`case when ${albumGrants.immichAlbumId} = ${immichAlbumId} then 0 else 1 end`, + asc(albumGrants.grantedAt), + asc(albumGrants.id), + ) .for("update"); } diff --git a/tests/db/accounting-migration-sql.test.ts b/tests/db/accounting-migration-sql.test.ts index 042d796..2efbe05 100644 --- a/tests/db/accounting-migration-sql.test.ts +++ b/tests/db/accounting-migration-sql.test.ts @@ -8,11 +8,12 @@ const migration = await readFile( "utf8", ); -test("0002 retains legacy Immich text and gates only new non-canonical rows", () => { +test("0002 retains legacy Immich text and accepts case-variant historical UUIDs", () => { expect(migration).not.toMatch(/ALTER COLUMN "immich_[^"]+" SET DATA TYPE uuid/); expect(migration).toContain( - 'ADD CONSTRAINT "album_grants_canonical_immich_album_id_check"', + 'ADD CONSTRAINT "album_grants_immich_album_id_uuid_check"', ); + expect(migration).toContain('CHECK ("album_grants"."immich_album_id" ~*'); expect(migration).toContain( 'ADD CONSTRAINT "usages_canonical_immich_asset_id_check"', ); @@ -25,6 +26,25 @@ test("0002 retains legacy Immich text and gates only new non-canonical rows", () expect(migration.match(/NOT VALID/g)).toHaveLength(4); }); +test("0002 consolidates active case duplicates before adding their partial unique index", () => { + const consolidation = migration.indexOf('ranked_active_album_grants AS'); + const activeIndex = migration.indexOf( + 'CREATE UNIQUE INDEX "album_grants_editorial_active_album_unique"', + ); + + expect(consolidation).toBeGreaterThan(-1); + expect(migration).toContain( + 'PARTITION BY "editorial_account_id", lower("immich_album_id")', + ); + expect(migration).toContain( + 'ORDER BY ("immich_album_id" = lower("immich_album_id")) DESC, "granted_at", "id"', + ); + expect(activeIndex).toBeGreaterThan(consolidation); + expect(migration).toContain( + 'ON "album_grants" ("editorial_account_id", lower("immich_album_id")) WHERE "revoked_at" IS NULL', + ); +}); + test("0002 uses an explicit legacy kind instead of random UUID ordering for ambiguity", () => { expect(migration).not.toContain('ORDER BY "authorized_at", "id"'); expect(migration).toContain("ELSE 'legacy'"); diff --git a/tests/db/accounting-migration.test.ts b/tests/db/accounting-migration.test.ts index a575e05..fe8dfff 100644 --- a/tests/db/accounting-migration.test.ts +++ b/tests/db/accounting-migration.test.ts @@ -301,13 +301,13 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", "insert into album_grants (editorial_account_id, immich_album_id) values ($1, $2)", [editorialId, "new-invalid-album"], ), - ).rejects.toThrow(/album_grants_canonical_immich_album_id_check/); + ).rejects.toThrow(/album_grants_immich_album_id_uuid_check/); await expect( testDb.pool.query( "update album_grants set revoked_at = now() where immich_album_id = $1", [dirtyAlbumId], ), - ).rejects.toThrow(/album_grants_canonical_immich_album_id_check/); + ).rejects.toThrow(/album_grants_immich_album_id_uuid_check/); const grantService = createAlbumGrantService({ repository: createAlbumGrantRepository(testDb.database), @@ -336,7 +336,9 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents", [validAlbumId], ); expect(canonicalGrantRows.rows).toHaveLength(2); - expect(canonicalGrantRows.rows.every((row) => row.immich_album_id === validAlbumId)).toBe(true); + expect(canonicalGrantRows.rows.map((row) => row.immich_album_id).sort()).toEqual( + [validAlbumId.toUpperCase(), validAlbumId].sort(), + ); expect(canonicalGrantRows.rows.every((row) => row.revoked_at !== null)).toBe(true); await grantService.grantAlbum({ diff --git a/tests/db/album-grants.test.ts b/tests/db/album-grants.test.ts new file mode 100644 index 0000000..e965260 --- /dev/null +++ b/tests/db/album-grants.test.ts @@ -0,0 +1,277 @@ +import { randomUUID } from "node:crypto"; + +import { afterAll, expect, test, vi } from "vitest"; + +import { createAlbumGrantRepository, createAlbumGrantService } from "@/modules/albums/grants"; +import { startPostgres } from "./postgres"; + +const testDb = await startPostgres({ through: "0001_editorial_approval_notice.sql" }); + +afterAll(() => testDb.stop()); + +const directAlbumId = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"; +const revokeAlbumId = "cccccccc-cccc-4ccc-8ccc-cccccccccccc"; +const regrantAlbumId = "dddddddd-dddd-4ddd-8ddd-dddddddddddd"; +const listAlbumId = "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee"; +const migrationAlbumId = "ffffffff-ffff-4fff-8fff-ffffffffffff"; +const earlierGrant = new Date("2026-08-07T08:00:00.000Z"); +const laterGrant = new Date("2026-08-08T08:00:00.000Z"); +const revokedAt = new Date("2026-08-09T08:00:00.000Z"); + +test("grant mutations and migration preserve one deterministic active logical grant", async () => { + const adminUserId = randomUUID(); + const editorialId = randomUUID(); + await testDb.pool.query( + `insert into users (id, name, email, email_verified) + values ($1, 'Grant Admin', $2, true)`, + [adminUserId, `${adminUserId}@example.com`], + ); + await testDb.pool.query( + `insert into editorial_accounts ( + id, user_id, name, contact_name, login_email, status, current_price_cents + ) values ($1, $2, 'Grant Redaktion', 'Grant Kontakt', $3, 'active', 2300)`, + [editorialId, adminUserId, `${adminUserId}@example.com`], + ); + + await insertGrantRows(editorialId, adminUserId, [ + { + id: "10000000-0000-4000-8000-000000000001", + albumId: directAlbumId.toUpperCase(), + grantedAt: earlierGrant, + revokedAt: null, + }, + { + id: "10000000-0000-4000-8000-000000000002", + albumId: directAlbumId, + grantedAt: laterGrant, + revokedAt: null, + }, + ]); + await insertGrantRows(editorialId, adminUserId, [ + { + id: "20000000-0000-4000-8000-000000000001", + albumId: revokeAlbumId.toUpperCase(), + grantedAt: earlierGrant, + revokedAt: null, + }, + { + id: "20000000-0000-4000-8000-000000000002", + albumId: revokeAlbumId, + grantedAt: laterGrant, + revokedAt: null, + }, + ]); + await insertGrantRows(editorialId, adminUserId, [ + { + id: "30000000-0000-4000-8000-000000000003", + albumId: regrantAlbumId.toUpperCase(), + grantedAt: laterGrant, + revokedAt, + }, + { + id: "30000000-0000-4000-8000-000000000002", + albumId: "Dddddddd-dddd-4ddd-8ddd-dddddddddddd", + grantedAt: earlierGrant, + revokedAt, + }, + { + id: "30000000-0000-4000-8000-000000000001", + albumId: "dddddddD-dddd-4ddd-8ddd-dddddddddddd", + grantedAt: earlierGrant, + revokedAt, + }, + ]); + await insertGrantRows(editorialId, adminUserId, [ + { + id: "40000000-0000-4000-8000-000000000001", + albumId: listAlbumId.toUpperCase(), + grantedAt: earlierGrant, + revokedAt: null, + }, + { + id: "40000000-0000-4000-8000-000000000002", + albumId: listAlbumId, + grantedAt: laterGrant, + revokedAt: null, + }, + ]); + await insertGrantRows(editorialId, adminUserId, [ + { + id: "50000000-0000-4000-8000-000000000001", + albumId: migrationAlbumId.toUpperCase(), + grantedAt: earlierGrant, + revokedAt: null, + }, + { + id: "50000000-0000-4000-8000-000000000002", + albumId: migrationAlbumId, + grantedAt: laterGrant, + revokedAt: null, + }, + ]); + + const grantService = createAlbumGrantService({ + repository: createAlbumGrantRepository(testDb.database), + immich: { + getAlbum: vi.fn().mockImplementation(async (id: string) => ({ + id, + albumName: "Grant Album", + description: null, + albumThumbnailAssetId: null, + assetCount: 0, + assets: [], + })), + listAlbums: vi.fn(), + }, + }); + + const listedBeforeCleanup = await grantService.getGrantedAlbumIds(editorialId); + expect(listedBeforeCleanup.filter((id) => id === listAlbumId)).toEqual([listAlbumId]); + + await grantService.grantAlbum({ + editorialId, + immichAlbumId: directAlbumId, + adminUserId, + }); + await grantService.grantAlbum({ + editorialId, + immichAlbumId: directAlbumId, + adminUserId, + }); + expect(await activeGrantRows(editorialId, directAlbumId)).toEqual([ + { + id: "10000000-0000-4000-8000-000000000002", + immich_album_id: directAlbumId, + }, + ]); + await expect(auditCount(editorialId, directAlbumId, "album_granted")).resolves.toBe(0); + + await grantService.revokeAlbum({ + editorialId, + immichAlbumId: revokeAlbumId, + adminUserId, + }); + await expect(activeGrantRows(editorialId, revokeAlbumId)).resolves.toEqual([]); + await expect(auditCount(editorialId, revokeAlbumId, "album_revoked")).resolves.toBe(1); + + await grantService.grantAlbum({ + editorialId, + immichAlbumId: regrantAlbumId, + adminUserId, + }); + await grantService.grantAlbum({ + editorialId, + immichAlbumId: regrantAlbumId, + adminUserId, + }); + expect(await activeGrantRows(editorialId, regrantAlbumId)).toEqual([ + { + id: "30000000-0000-4000-8000-000000000001", + immich_album_id: regrantAlbumId, + }, + ]); + await expect(auditCount(editorialId, regrantAlbumId, "album_granted")).resolves.toBe(1); + + await testDb.applyRemainingMigrations(); + + expect(await allGrantRows(editorialId, migrationAlbumId)).toEqual([ + { + id: "50000000-0000-4000-8000-000000000001", + immich_album_id: migrationAlbumId.toUpperCase(), + revoked: true, + }, + { + id: "50000000-0000-4000-8000-000000000002", + immich_album_id: migrationAlbumId, + revoked: false, + }, + ]); + + await expect( + testDb.pool.query( + `insert into album_grants ( + editorial_account_id, immich_album_id, granted_by_user_id + ) values ($1, $2, $3)`, + [editorialId, migrationAlbumId.toUpperCase(), adminUserId], + ), + ).rejects.toThrow(/album_grants_editorial_active_album_unique/); + await expect( + testDb.pool.query( + `insert into album_grants ( + editorial_account_id, immich_album_id, revoked_at, granted_by_user_id + ) values ($1, $2, now(), $3)`, + [editorialId, migrationAlbumId.toUpperCase(), adminUserId], + ), + ).resolves.toBeDefined(); + await expect( + testDb.pool.query( + "insert into album_grants (editorial_account_id, immich_album_id) values ($1, $2)", + [editorialId, "new-invalid-album"], + ), + ).rejects.toThrow(/album_grants_immich_album_id_uuid_check/); + await expect( + testDb.pool.query( + "update album_grants set revoked_at = revoked_at where id = $1", + ["50000000-0000-4000-8000-000000000001"], + ), + ).resolves.toBeDefined(); +}); + +type GrantSeed = { + id: string; + albumId: string; + grantedAt: Date; + revokedAt: Date | null; +}; + +async function insertGrantRows(editorialId: string, adminUserId: string, rows: GrantSeed[]) { + for (const row of rows) { + await testDb.pool.query( + `insert into album_grants ( + id, editorial_account_id, immich_album_id, granted_at, revoked_at, granted_by_user_id + ) values ($1, $2, $3, $4, $5, $6)`, + [row.id, editorialId, row.albumId, row.grantedAt, row.revokedAt, adminUserId], + ); + } +} + +async function activeGrantRows(editorialId: string, albumId: string) { + const result = await testDb.pool.query<{ + id: string; + immich_album_id: string; + }>( + `select id, immich_album_id + from album_grants + where editorial_account_id = $1 and lower(immich_album_id) = $2 and revoked_at is null + order by id`, + [editorialId, albumId], + ); + return result.rows; +} + +async function allGrantRows(editorialId: string, albumId: string) { + const result = await testDb.pool.query<{ + id: string; + immich_album_id: string; + revoked: boolean; + }>( + `select id, immich_album_id, revoked_at is not null as revoked + from album_grants + where editorial_account_id = $1 and lower(immich_album_id) = $2 + order by id`, + [editorialId, albumId], + ); + return result.rows; +} + +async function auditCount(editorialId: string, albumId: string, eventType: string) { + const result = await testDb.pool.query<{ count: string }>( + `select count(*)::text as count + from audit_events + where event_type = $1 + and entity_id = $2 + and new_values->>'editorialId' = $3`, + [eventType, albumId, editorialId], + ); + return Number(result.rows[0]?.count ?? 0); +} From 8871e4794a1a81d76e3eb2bb82b252b5162d2717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Mon, 10 Aug 2026 13:10:13 +0200 Subject: [PATCH 20/29] feat: stream originals with download accounting --- drizzle/0003_stream_delivery.sql | 1 + drizzle/meta/0003_snapshot.json | 1524 +++++++++++++++++ drizzle/meta/_journal.json | 7 + .../api/download-intents/intent-handler.ts | 124 ++ src/app/api/download-intents/route.test.ts | 140 ++ src/app/api/download-intents/route.ts | 3 + .../[downloadId]/file/download-handler.ts | 162 ++ .../downloads/[downloadId]/file/route.test.ts | 228 +++ .../api/downloads/[downloadId]/file/route.ts | 3 + src/app/globals.css | 305 ++++ src/app/redaktion/alben/[albumId]/page.tsx | 8 +- src/app/redaktion/nutzungen/page.test.tsx | 84 + src/app/redaktion/nutzungen/page.tsx | 40 + .../nutzungen/usage-history-content.tsx | 120 ++ src/components/download/usage-dialog.test.tsx | 137 ++ src/components/download/usage-dialog.tsx | 224 +++ src/components/layout/portal-shell.tsx | 1 + src/db/schema/usages.ts | 2 +- src/modules/albums/catalog-content.test.tsx | 46 +- src/modules/albums/catalog-content.tsx | 13 + src/modules/downloads/service.ts | 3 +- src/modules/downloads/stream.test.ts | 223 +++ src/modules/downloads/stream.ts | 510 ++++++ src/modules/usages/service.ts | 3 +- src/modules/usages/types.ts | 2 +- .../download-delivery-migration-sql.test.ts | 14 + tests/db/download-delivery.test.ts | 152 ++ tests/db/postgres.ts | 10 +- 28 files changed, 4081 insertions(+), 8 deletions(-) create mode 100644 drizzle/0003_stream_delivery.sql create mode 100644 drizzle/meta/0003_snapshot.json create mode 100644 src/app/api/download-intents/intent-handler.ts create mode 100644 src/app/api/download-intents/route.test.ts create mode 100644 src/app/api/download-intents/route.ts create mode 100644 src/app/api/downloads/[downloadId]/file/download-handler.ts create mode 100644 src/app/api/downloads/[downloadId]/file/route.test.ts create mode 100644 src/app/api/downloads/[downloadId]/file/route.ts create mode 100644 src/app/redaktion/nutzungen/page.test.tsx create mode 100644 src/app/redaktion/nutzungen/page.tsx create mode 100644 src/app/redaktion/nutzungen/usage-history-content.tsx create mode 100644 src/components/download/usage-dialog.test.tsx create mode 100644 src/components/download/usage-dialog.tsx create mode 100644 src/modules/downloads/stream.test.ts create mode 100644 src/modules/downloads/stream.ts create mode 100644 tests/db/download-delivery-migration-sql.test.ts create mode 100644 tests/db/download-delivery.test.ts diff --git a/drizzle/0003_stream_delivery.sql b/drizzle/0003_stream_delivery.sql new file mode 100644 index 0000000..358dae5 --- /dev/null +++ b/drizzle/0003_stream_delivery.sql @@ -0,0 +1 @@ +ALTER TYPE "public"."usage_billing_status" ADD VALUE 'voided'; \ No newline at end of file diff --git a/drizzle/meta/0003_snapshot.json b/drizzle/meta/0003_snapshot.json new file mode 100644 index 0000000..af23c8e --- /dev/null +++ b/drizzle/meta/0003_snapshot.json @@ -0,0 +1,1524 @@ +{ + "id": "090a698a-550f-4283-8632-f9c3d22d236d", + "prevId": "8944c4e7-b3ab-47b5-a05b-91be6fb5c915", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.album_grants": { + "name": "album_grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_album_id": { + "name": "immich_album_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "granted_by_user_id": { + "name": "granted_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "album_grants_editorial_account_id_idx": { + "name": "album_grants_editorial_account_id_idx", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_immich_album_id_idx": { + "name": "album_grants_immich_album_id_idx", + "columns": [ + { + "expression": "immich_album_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "album_grants_editorial_active_album_unique": { + "name": "album_grants_editorial_active_album_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lower(\"immich_album_id\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"album_grants\".\"revoked_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "album_grants_editorial_account_id_editorial_accounts_id_fk": { + "name": "album_grants_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "album_grants", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "album_grants_granted_by_user_id_user_id_fk": { + "name": "album_grants_granted_by_user_id_user_id_fk", + "tableFrom": "album_grants", + "tableTo": "user", + "columnsFrom": [ + "granted_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "album_grants_immich_album_id_uuid_check": { + "name": "album_grants_immich_album_id_uuid_check", + "value": "\"album_grants\".\"immich_album_id\" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + } + }, + "isRLSEnabled": false + }, + "public.audit_events": { + "name": "audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_type": { + "name": "actor_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "previous_values": { + "name": "previous_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "new_values": { + "name": "new_values", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "audit_events_actor_user_id_user_id_fk": { + "name": "audit_events_actor_user_id_user_id_fk", + "tableFrom": "audit_events", + "tableTo": "user", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "portal_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'EDITORIAL'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_report_items": { + "name": "billing_report_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id_snapshot": { + "name": "immich_asset_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose_snapshot": { + "name": "purpose_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference_snapshot": { + "name": "internal_reference_snapshot", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "billing_report_items_report_usage_unique": { + "name": "billing_report_items_report_usage_unique", + "columns": [ + { + "expression": "billing_report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "usage_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_report_items_billing_report_id_billing_reports_id_fk": { + "name": "billing_report_items_billing_report_id_billing_reports_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_report_items_usage_id_usages_id_fk": { + "name": "billing_report_items_usage_id_usages_id_fk", + "tableFrom": "billing_report_items", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.billing_reports": { + "name": "billing_reports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "report_number": { + "name": "report_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "period_starts_at": { + "name": "period_starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "period_ends_at": { + "name": "period_ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "billing_address_snapshot": { + "name": "billing_address_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "invoice_number": { + "name": "invoice_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "net_total_cents": { + "name": "net_total_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "report_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "pdf": { + "name": "pdf", + "type": "bytea", + "primaryKey": false, + "notNull": false + }, + "pdf_sha256": { + "name": "pdf_sha256", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finalized_at": { + "name": "finalized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancelled_by_user_id": { + "name": "cancelled_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "billing_reports_report_number_unique": { + "name": "billing_reports_report_number_unique", + "columns": [ + { + "expression": "report_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "billing_reports_invoice_number_unique": { + "name": "billing_reports_invoice_number_unique", + "columns": [ + { + "expression": "invoice_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "billing_reports_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_reports_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_reports", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_created_by_user_id_user_id_fk": { + "name": "billing_reports_created_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_reports_cancelled_by_user_id_user_id_fk": { + "name": "billing_reports_cancelled_by_user_id_user_id_fk", + "tableFrom": "billing_reports", + "tableTo": "user", + "columnsFrom": [ + "cancelled_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "billing_reports_pdf_sha256_hex_check": { + "name": "billing_reports_pdf_sha256_hex_check", + "value": "\"billing_reports\".\"pdf_sha256\" ~ '^[0-9a-f]{64}$'" + }, + "billing_reports_final_pdf_check": { + "name": "billing_reports_final_pdf_check", + "value": "\"billing_reports\".\"status\" <> 'final' OR (\"billing_reports\".\"pdf\" IS NOT NULL AND \"billing_reports\".\"pdf_sha256\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.billing_address_versions": { + "name": "billing_address_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "company_name": { + "name": "company_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_1": { + "name": "address_line_1", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address_line_2": { + "name": "address_line_2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "postal_code": { + "name": "postal_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "city": { + "name": "city", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "superseded_by_id": { + "name": "superseded_by_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "billing_address_versions_editorial_account_id_editorial_accounts_id_fk": { + "name": "billing_address_versions_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_superseded_by_id_billing_address_versions_id_fk": { + "name": "billing_address_versions_superseded_by_id_billing_address_versions_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "superseded_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "billing_address_versions_created_by_user_id_user_id_fk": { + "name": "billing_address_versions_created_by_user_id_user_id_fk", + "tableFrom": "billing_address_versions", + "tableTo": "user", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.editorial_accounts": { + "name": "editorial_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "contact_name": { + "name": "contact_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "login_email": { + "name": "login_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "account_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending_email'" + }, + "current_price_cents": { + "name": "current_price_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "approval_notice_status": { + "name": "approval_notice_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'not_requested'" + }, + "current_billing_address_version_id": { + "name": "current_billing_address_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_version": { + "name": "accepted_terms_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accepted_terms_at": { + "name": "accepted_terms_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "privacy_acknowledged_at": { + "name": "privacy_acknowledged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "editorial_accounts_user_id_user_id_fk": { + "name": "editorial_accounts_user_id_user_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk": { + "name": "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk", + "tableFrom": "editorial_accounts", + "tableTo": "billing_address_versions", + "columnsFrom": [ + "current_billing_address_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "editorial_accounts_user_id_unique": { + "name": "editorial_accounts_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + }, + "editorial_accounts_login_email_unique": { + "name": "editorial_accounts_login_email_unique", + "nullsNotDistinct": false, + "columns": [ + "login_email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.download_events": { + "name": "download_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "usage_id": { + "name": "usage_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authorized_at": { + "name": "authorized_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "download_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'authorized'" + }, + "transferred_bytes": { + "name": "transferred_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "repeat_download_note": { + "name": "repeat_download_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent_kind": { + "name": "intent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'new_usage'" + }, + "request_fingerprint": { + "name": "request_fingerprint", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "legacy_intent": { + "name": "legacy_intent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "download_events_editorial_idempotency_key_unique": { + "name": "download_events_editorial_idempotency_key_unique", + "columns": [ + { + "expression": "editorial_account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "download_events_editorial_account_id_editorial_accounts_id_fk": { + "name": "download_events_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "download_events", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "download_events_usage_id_usages_id_fk": { + "name": "download_events_usage_id_usages_id_fk", + "tableFrom": "download_events", + "tableTo": "usages", + "columnsFrom": [ + "usage_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "download_events_intent_kind_check": { + "name": "download_events_intent_kind_check", + "value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download', 'legacy')" + }, + "download_events_request_fingerprint_hex_check": { + "name": "download_events_request_fingerprint_hex_check", + "value": "\"download_events\".\"request_fingerprint\" ~ '^[0-9a-f]{64}$'" + }, + "download_events_canonical_idempotency_key_check": { + "name": "download_events_canonical_idempotency_key_check", + "value": "\"download_events\".\"legacy_intent\" OR \"download_events\".\"idempotency_key\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + }, + "download_events_canonical_immich_asset_id_check": { + "name": "download_events_canonical_immich_asset_id_check", + "value": "\"download_events\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + } + }, + "isRLSEnabled": false + }, + "public.usages": { + "name": "usages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "editorial_account_id": { + "name": "editorial_account_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "immich_asset_id": { + "name": "immich_asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename_snapshot": { + "name": "filename_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "immich_album_id_snapshot": { + "name": "immich_album_id_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "album_name_snapshot": { + "name": "album_name_snapshot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "internal_reference": { + "name": "internal_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price_cents": { + "name": "price_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "billing_status": { + "name": "billing_status", + "type": "usage_billing_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "billing_report_id": { + "name": "billing_report_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "usages_editorial_account_id_editorial_accounts_id_fk": { + "name": "usages_editorial_account_id_editorial_accounts_id_fk", + "tableFrom": "usages", + "tableTo": "editorial_accounts", + "columnsFrom": [ + "editorial_account_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "usages_billing_report_id_billing_reports_id_fk": { + "name": "usages_billing_report_id_billing_reports_id_fk", + "tableFrom": "usages", + "tableTo": "billing_reports", + "columnsFrom": [ + "billing_report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "usages_canonical_immich_asset_id_check": { + "name": "usages_canonical_immich_asset_id_check", + "value": "\"usages\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + }, + "usages_canonical_immich_album_id_check": { + "name": "usages_canonical_immich_album_id_check", + "value": "\"usages\".\"immich_album_id_snapshot\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'" + } + }, + "isRLSEnabled": false + } + }, + "enums": { + "public.portal_role": { + "name": "portal_role", + "schema": "public", + "values": [ + "ADMIN", + "EDITORIAL" + ] + }, + "public.report_status": { + "name": "report_status", + "schema": "public", + "values": [ + "draft", + "final", + "cancelled" + ] + }, + "public.account_status": { + "name": "account_status", + "schema": "public", + "values": [ + "pending_email", + "pending_approval", + "active", + "suspended", + "rejected" + ] + }, + "public.download_status": { + "name": "download_status", + "schema": "public", + "values": [ + "authorized", + "streaming", + "completed", + "failed_before_delivery", + "interrupted" + ] + }, + "public.usage_billing_status": { + "name": "usage_billing_status", + "schema": "public", + "values": [ + "open", + "billed", + "reopened", + "voided" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index c9e805a..c2f8c87 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -22,6 +22,13 @@ "when": 1786354215684, "tag": "0002_accounting_intents", "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1786358492749, + "tag": "0003_stream_delivery", + "breakpoints": true } ] } diff --git a/src/app/api/download-intents/intent-handler.ts b/src/app/api/download-intents/intent-handler.ts new file mode 100644 index 0000000..526d459 --- /dev/null +++ b/src/app/api/download-intents/intent-handler.ts @@ -0,0 +1,124 @@ +import { z } from "zod"; + +import { createRepeatDownload } from "@/modules/downloads/service"; +import { requireActiveEditorial, PrincipalAuthorizationError } from "@/modules/auth/principal"; +import { createNewUsage } from "@/modules/usages/service"; +import { UsageAccountingError } from "@/modules/usages/types"; + +const newUsagePayload = z + .object({ + kind: z.literal("new_usage"), + assetId: z.string(), + albumId: z.string(), + purpose: z.string(), + reference: z.string().optional(), + idempotencyKey: z.string(), + }) + .strict(); + +const repeatDownloadPayload = z + .object({ + kind: z.literal("repeat_download"), + usageId: z.string(), + note: z.string().optional(), + idempotencyKey: z.string(), + }) + .strict(); + +const intentPayload = z.discriminatedUnion("kind", [newUsagePayload, repeatDownloadPayload]); + +type IntentHandlerDependencies = { + requireActiveEditorial: typeof requireActiveEditorial; + createNewUsage: typeof createNewUsage; + createRepeatDownload: typeof createRepeatDownload; +}; + +export function createDownloadIntentHandler(dependencies: IntentHandlerDependencies) { + return async function POST(request: Request): Promise { + try { + const principal = await dependencies.requireActiveEditorial(request.headers); + const payload = intentPayload.safeParse(await readJson(request)); + if (!payload.success) return errorResponse(400, "INVALID_REQUEST"); + + const intent = + payload.data.kind === "new_usage" + ? await dependencies.createNewUsage({ + editorialId: principal.editorialId, + assetId: payload.data.assetId, + albumId: payload.data.albumId, + purpose: payload.data.purpose, + ...(payload.data.reference === undefined + ? {} + : { reference: payload.data.reference }), + idempotencyKey: payload.data.idempotencyKey, + }) + : await dependencies.createRepeatDownload({ + editorialId: principal.editorialId, + usageId: payload.data.usageId, + ...(payload.data.note === undefined ? {} : { note: payload.data.note }), + idempotencyKey: payload.data.idempotencyKey, + }); + + return Response.json( + { + downloadId: intent.id, + fileUrl: `/api/downloads/${encodeURIComponent(intent.id)}/file`, + priceCents: intent.priceCents, + billable: intent.billable, + }, + { status: 201, headers: { "cache-control": "private, no-store" } }, + ); + } catch (error) { + return mappedError(error); + } + }; +} + +async function readJson(request: Request): Promise { + try { + return await request.json(); + } catch { + return null; + } +} + +function mappedError(error: unknown): Response { + if (error instanceof PrincipalAuthorizationError) { + return errorResponse(error.code === "AUTHENTICATION_REQUIRED" ? 401 : 403, "FORBIDDEN"); + } + if (error instanceof UsageAccountingError) { + switch (error.code) { + case "INVALID_INPUT": + return errorResponse(400, "INVALID_REQUEST"); + case "IDEMPOTENCY_CONFLICT": + return errorResponse(409, "IDEMPOTENCY_CONFLICT"); + case "ALBUM_NOT_GRANTED": + case "ASSET_NOT_FOUND": + case "ASSET_NOT_IN_ALBUM": + case "USAGE_NOT_FOUND": + return errorResponse(404, "NOT_FOUND"); + case "IMMICH_UNAVAILABLE": + return errorResponse(503, "UPSTREAM_UNAVAILABLE"); + case "ASSET_NOT_IMAGE": + return errorResponse(422, "INVALID_ASSET"); + case "EDITORIAL_NOT_ACTIVE": + return errorResponse(403, "FORBIDDEN"); + case "INVALID_PRICE": + return errorResponse(409, "ACCOUNTING_UNAVAILABLE"); + } + } + return errorResponse(500, "REQUEST_FAILED"); +} + +function errorResponse(status: number, code: string): Response { + return Response.json( + { code }, + { status, headers: { "cache-control": "private, no-store" } }, + ); +} + +export const authorizedDownloadIntentHandler = createDownloadIntentHandler({ + requireActiveEditorial, + createNewUsage, + createRepeatDownload, +}); diff --git a/src/app/api/download-intents/route.test.ts b/src/app/api/download-intents/route.test.ts new file mode 100644 index 0000000..2402017 --- /dev/null +++ b/src/app/api/download-intents/route.test.ts @@ -0,0 +1,140 @@ +import { expect, test, vi } from "vitest"; + +import { createDownloadIntentHandler } from "./intent-handler"; + +const editorialId = "11111111-1111-4111-8111-111111111111"; +const assetId = "22222222-2222-4222-8222-222222222222"; +const albumId = "33333333-3333-4333-8333-333333333333"; +const usageId = "44444444-4444-4444-8444-444444444444"; +const idempotencyKey = "55555555-5555-4555-8555-555555555555"; +const downloadId = "66666666-6666-4666-8666-666666666666"; + +function dependencies() { + return { + requireActiveEditorial: vi.fn().mockResolvedValue({ editorialId }), + createNewUsage: vi.fn().mockResolvedValue({ + id: downloadId, + usageId, + assetId, + priceCents: 1_500, + billable: true, + status: "authorized", + authorizedAt: new Date("2026-08-10T10:00:00.000Z"), + }), + createRepeatDownload: vi.fn().mockResolvedValue({ + id: downloadId, + usageId, + assetId, + priceCents: 0, + billable: false, + status: "authorized", + authorizedAt: new Date("2026-08-10T10:00:00.000Z"), + }), + }; +} + +function post(handler: ReturnType, body: unknown) { + return handler( + new Request("http://portal.test/api/download-intents", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify(body), + }), + ); +} + +test("derives editorial scope and billable price exclusively on the server", async () => { + const deps = dependencies(); + const response = await post(createDownloadIntentHandler(deps), { + kind: "new_usage", + assetId, + albumId, + purpose: "Titelgeschichte", + idempotencyKey, + }); + + expect(response.status).toBe(201); + await expect(response.json()).resolves.toEqual({ + downloadId, + fileUrl: `/api/downloads/${downloadId}/file`, + priceCents: 1_500, + billable: true, + }); + expect(deps.createNewUsage).toHaveBeenCalledWith({ + editorialId, + assetId, + albumId, + purpose: "Titelgeschichte", + idempotencyKey, + }); +}); + +test("creates a zero-cost repeat intent scoped to the authenticated editorial", async () => { + const deps = dependencies(); + const response = await post(createDownloadIntentHandler(deps), { + kind: "repeat_download", + usageId, + note: "erneuter Abruf", + idempotencyKey, + }); + + expect(response.status).toBe(201); + expect(deps.createRepeatDownload).toHaveBeenCalledWith({ + editorialId, + usageId, + note: "erneuter Abruf", + idempotencyKey, + }); + await expect(response.json()).resolves.toMatchObject({ priceCents: 0, billable: false }); +}); + +test.each([ + { field: "editorialId", value: "77777777-7777-4777-8777-777777777777" }, + { field: "priceCents", value: 1 }, +])("rejects a client-controlled $field before any accounting side effect", async ({ field, value }) => { + const deps = dependencies(); + const response = await post(createDownloadIntentHandler(deps), { + kind: "new_usage", + assetId, + albumId, + purpose: "Titelgeschichte", + idempotencyKey, + [field]: value, + }); + + expect(response.status).toBe(400); + expect(deps.createNewUsage).not.toHaveBeenCalled(); + expect(deps.createRepeatDownload).not.toHaveBeenCalled(); +}); + +test("rejects mixed new and repeat fields as an invalid discriminated payload", async () => { + const deps = dependencies(); + const response = await post(createDownloadIntentHandler(deps), { + kind: "repeat_download", + usageId, + assetId, + idempotencyKey, + }); + + expect(response.status).toBe(400); + expect(deps.createRepeatDownload).not.toHaveBeenCalled(); +}); + +test("passes one submitted idempotency key through unchanged", async () => { + const deps = dependencies(); + const handler = createDownloadIntentHandler(deps); + const body = { + kind: "new_usage", + assetId, + albumId, + purpose: "Titelgeschichte", + idempotencyKey, + }; + + const [first, retry] = await Promise.all([post(handler, body), post(handler, body)]); + + expect(first.status).toBe(201); + expect(retry.status).toBe(201); + expect(deps.createNewUsage).toHaveBeenNthCalledWith(1, expect.objectContaining({ idempotencyKey })); + expect(deps.createNewUsage).toHaveBeenNthCalledWith(2, expect.objectContaining({ idempotencyKey })); +}); diff --git a/src/app/api/download-intents/route.ts b/src/app/api/download-intents/route.ts new file mode 100644 index 0000000..dca3d5b --- /dev/null +++ b/src/app/api/download-intents/route.ts @@ -0,0 +1,3 @@ +import { authorizedDownloadIntentHandler } from "./intent-handler"; + +export const POST = authorizedDownloadIntentHandler; diff --git a/src/app/api/downloads/[downloadId]/file/download-handler.ts b/src/app/api/downloads/[downloadId]/file/download-handler.ts new file mode 100644 index 0000000..d1cfb31 --- /dev/null +++ b/src/app/api/downloads/[downloadId]/file/download-handler.ts @@ -0,0 +1,162 @@ +import { downloadDeliveryRepository, streamWithAccounting } from "@/modules/downloads/stream"; +import { requireActiveEditorial, PrincipalAuthorizationError } from "@/modules/auth/principal"; +import { immichClient } from "@/modules/immich/client"; +import type { ImmichBinary } from "@/modules/immich/types"; +import { normalizeUuid } from "@/modules/usages/types"; + +type DownloadFileRouteContext = Readonly<{ params: Promise<{ downloadId: string }> }>; + +type DownloadFileHandlerDependencies = { + requireActiveEditorial: typeof requireActiveEditorial; + repository: typeof downloadDeliveryRepository; + immich: { getOriginal(assetId: string, signal?: AbortSignal): Promise }; +}; + +export function createDownloadFileHandler(dependencies: DownloadFileHandlerDependencies) { + return async function GET( + request: Request, + context: DownloadFileRouteContext, + ): Promise { + try { + const principal = await dependencies.requireActiveEditorial(request.headers); + const downloadId = safeDownloadId((await context.params).downloadId); + if (!downloadId) return genericNotFound(); + + const claim = await dependencies.repository.claimAuthorized( + principal.editorialId, + downloadId, + ); + if (claim.outcome === "not_found") return genericNotFound(); + if (claim.outcome === "not_authorized") { + return jsonError(409, "DOWNLOAD_NOT_AVAILABLE"); + } + + let original: ImmichBinary; + try { + original = await dependencies.immich.getOriginal( + claim.download.assetId, + request.signal, + ); + } catch { + await failClaimBeforeDelivery(dependencies, downloadId, claim.download.intentKind); + return jsonError(503, "DOWNLOAD_UNAVAILABLE"); + } + + try { + const body = streamWithAccounting({ + downloadId, + upstream: original.body, + voidNewUsageOnFailure: claim.download.intentKind === "new_usage", + repository: dependencies.repository, + }); + return new Response(body, { + headers: downloadHeaders(original, claim.download.filename), + }); + } catch { + const cancellation = Promise.resolve().then(() => original.body.cancel()); + await Promise.allSettled([ + cancellation, + failClaimBeforeDelivery(dependencies, downloadId, claim.download.intentKind), + ]); + return jsonError(503, "DOWNLOAD_UNAVAILABLE"); + } + } catch (error) { + if (error instanceof PrincipalAuthorizationError) { + return jsonError(error.code === "AUTHENTICATION_REQUIRED" ? 401 : 403, "FORBIDDEN"); + } + return jsonError(503, "DOWNLOAD_UNAVAILABLE"); + } + }; +} + +async function failClaimBeforeDelivery( + dependencies: DownloadFileHandlerDependencies, + downloadId: string, + intentKind: "new_usage" | "repeat_download" | "legacy", +) { + await dependencies.repository + .failBeforeDelivery(downloadId, { voidNewUsage: intentKind === "new_usage" }) + .catch(() => undefined); +} + +function safeDownloadId(value: string): string | null { + try { + return normalizeUuid(value); + } catch { + return null; + } +} + +function downloadHeaders(original: ImmichBinary, snapshotFilename: string): Headers { + const headers = new Headers({ + "cache-control": "private, no-store", + "content-disposition": contentDisposition(original.filename || snapshotFilename), + "content-type": safeContentType(original.contentType), + "x-content-type-options": "nosniff", + }); + if ( + original.contentLength !== null && + Number.isSafeInteger(original.contentLength) && + original.contentLength >= 0 + ) { + headers.set("content-length", String(original.contentLength)); + } + return headers; +} + +export function contentDisposition(filename: string): string { + const cleaned = cleanFilename(filename); + const fallback = asciiFilename(cleaned); + const encoded = encodeURIComponent(cleaned).replace(/[!'()*]/g, (character) => + `%${character.charCodeAt(0).toString(16).toUpperCase()}`, + ); + return `attachment; filename="${fallback}"; filename*=UTF-8''${encoded}`; +} + +function cleanFilename(filename: string): string { + const cleaned = [...filename.normalize("NFC").replace(/[\uD800-\uDFFF]/gu, "_")] + .slice(0, 180) + .join("") + .replace(/[\\/]/g, "_") + .replace(/[\u0000-\u001f\u007f-\u009f]/g, "") + .trim(); + return cleaned && cleaned !== "." && cleaned !== ".." ? cleaned : "download"; +} + +function asciiFilename(filename: string): string { + const fallback = filename + .normalize("NFKD") + .replace(/[\u0300-\u036f]/g, "") + .replace(/[^A-Za-z0-9._ ()+-]/g, "_") + .replace(/[";]/g, "_") + .trim(); + return fallback && fallback !== "." && fallback !== ".." ? fallback : "download"; +} + +function safeContentType(value: string): string { + return /^[A-Za-z0-9!#$&^_.+-]+\/[A-Za-z0-9!#$&^_.+-]+(?:[ \t]*;[ \t]*[A-Za-z0-9!#$&^_.+-]+=[A-Za-z0-9!#$&^_.+"'()-]+)*$/.test( + value, + ) + ? value + : "application/octet-stream"; +} + +function genericNotFound(): Response { + return new Response(null, { + status: 404, + headers: { "cache-control": "private, no-store" }, + }); +} + +function jsonError(status: number, code: string): Response { + return Response.json( + { code }, + { status, headers: { "cache-control": "private, no-store" } }, + ); +} + +export const authorizedDownloadFileHandler = createDownloadFileHandler({ + requireActiveEditorial, + repository: downloadDeliveryRepository, + immich: immichClient, +}); diff --git a/src/app/api/downloads/[downloadId]/file/route.test.ts b/src/app/api/downloads/[downloadId]/file/route.test.ts new file mode 100644 index 0000000..2a4c2cb --- /dev/null +++ b/src/app/api/downloads/[downloadId]/file/route.test.ts @@ -0,0 +1,228 @@ +import { expect, test, vi } from "vitest"; + +import { PrincipalAuthorizationError } from "@/modules/auth/principal"; +import { contentDisposition, createDownloadFileHandler } from "./download-handler"; + +const editorialId = "11111111-1111-4111-8111-111111111111"; +const otherEditorialId = "22222222-2222-4222-8222-222222222222"; +const downloadId = "33333333-3333-4333-8333-333333333333"; +const usageId = "44444444-4444-4444-8444-444444444444"; +const assetId = "55555555-5555-4555-8555-555555555555"; + +function binary(overrides: Partial<{ + body: ReadableStream; + contentType: string; + contentLength: number | null; + filename: string; +}> = {}) { + return { + body: new ReadableStream({ + start(controller) { + controller.enqueue(new Uint8Array([1, 2, 3])); + controller.close(); + }, + }), + contentType: "image/jpeg", + contentLength: 3, + filename: "heimspiel.jpg", + ...overrides, + }; +} + +function dependencies(options: { + claim?: "claimed" | "not_found" | "not_authorized"; + editorialError?: Error; + original?: ReturnType; + originalError?: Error; + intentKind?: "new_usage" | "repeat_download"; +} = {}) { + const repository = { + claimAuthorized: vi.fn().mockResolvedValue( + options.claim === "not_found" + ? { outcome: "not_found" } + : options.claim === "not_authorized" + ? { outcome: "not_authorized" } + : { + outcome: "claimed", + download: { + id: downloadId, + usageId, + assetId, + filename: "snapshot.jpg", + intentKind: options.intentKind ?? "new_usage", + }, + }, + ), + failBeforeDelivery: vi.fn().mockResolvedValue(true), + markCompleted: vi.fn().mockResolvedValue(true), + markInterrupted: vi.fn().mockResolvedValue(true), + }; + const values = { + requireActiveEditorial: vi.fn().mockImplementation(async () => { + if (options.editorialError) throw options.editorialError; + return { editorialId }; + }), + repository, + immich: { + getOriginal: vi.fn().mockImplementation(async () => { + if (options.originalError) throw options.originalError; + return options.original ?? binary(); + }), + }, + }; + return values; +} + +function call( + handler: ReturnType, + id = downloadId, + signal?: AbortSignal, +) { + return handler(new Request(`http://portal.test/api/downloads/${id}/file`, { signal }), { + params: Promise.resolve({ downloadId: id }), + }); +} + +test("claims an owned authorized event before requesting and streaming the original", async () => { + const deps = dependencies(); + const handler = createDownloadFileHandler(deps); + + const response = await call(handler); + + expect(response.status).toBe(200); + expect(deps.repository.claimAuthorized).toHaveBeenCalledWith(editorialId, downloadId); + expect(deps.immich.getOriginal).toHaveBeenCalledWith(assetId, expect.any(AbortSignal)); + expect(await response.arrayBuffer()).toEqual(new Uint8Array([1, 2, 3]).buffer); + expect(deps.repository.markCompleted).toHaveBeenCalledWith(downloadId, 3); +}); + +test("returns the same generic 404 for an invalid id, missing event, and another editorial's event", async () => { + const invalid = dependencies(); + const missing = dependencies({ claim: "not_found" }); + const foreign = dependencies({ claim: "not_found" }); + foreign.requireActiveEditorial.mockResolvedValue({ editorialId: otherEditorialId }); + + const responses = await Promise.all([ + call(createDownloadFileHandler(invalid), "not-a-uuid"), + call(createDownloadFileHandler(missing)), + call(createDownloadFileHandler(foreign)), + ]); + const results = await Promise.all( + responses.map(async (response) => ({ status: response.status, body: await response.text() })), + ); + + expect(results[1]).toEqual(results[0]); + expect(results[2]).toEqual(results[0]); + expect(invalid.repository.claimAuthorized).not.toHaveBeenCalled(); + expect(foreign.immich.getOriginal).not.toHaveBeenCalled(); +}); + +test.each(["streaming", "completed", "interrupted", "failed_before_delivery"])( + "denies reuse of a %s attempt before reaching Immich", + async () => { + const deps = dependencies({ claim: "not_authorized" }); + const response = await call(createDownloadFileHandler(deps)); + + expect(response.status).toBe(409); + await expect(response.json()).resolves.toEqual({ code: "DOWNLOAD_NOT_AVAILABLE" }); + expect(deps.immich.getOriginal).not.toHaveBeenCalled(); + }, +); + +test("marks a pre-response Immich failure failed and voids a new usage", async () => { + const deps = dependencies({ originalError: new Error("IMMICH_UNAVAILABLE") }); + + const response = await call(createDownloadFileHandler(deps)); + + expect(response.status).toBe(503); + expect(deps.repository.failBeforeDelivery).toHaveBeenCalledWith(downloadId, { + voidNewUsage: true, + }); +}); + +test("a repeat pre-response failure retains the original usage", async () => { + const deps = dependencies({ + originalError: new Error("IMMICH_UNAVAILABLE"), + intentKind: "repeat_download", + }); + + await call(createDownloadFileHandler(deps)); + + expect(deps.repository.failBeforeDelivery).toHaveBeenCalledWith(downloadId, { + voidNewUsage: false, + }); +}); + +test("accounts for a claimed attempt when the upstream body cannot be consumed", async () => { + const original = binary(); + const lock = original.body.getReader(); + const deps = dependencies({ original }); + + const response = await call(createDownloadFileHandler(deps)); + + expect(response.status).toBe(503); + expect(deps.repository.failBeforeDelivery).toHaveBeenCalledWith(downloadId, { + voidNewUsage: true, + }); + lock.releaseLock(); +}); + +test("emits only safe download headers for an injected Unicode filename", async () => { + const deps = dependencies({ + original: binary({ + filename: "../München\r\nX-Internal: secret\\final.jpg", + contentType: "image/jpeg", + contentLength: 3, + }), + }); + + const response = await call(createDownloadFileHandler(deps)); + const disposition = response.headers.get("content-disposition") ?? ""; + + expect(response.headers.get("cache-control")).toBe("private, no-store"); + expect(response.headers.get("content-type")).toBe("image/jpeg"); + expect(response.headers.get("content-length")).toBe("3"); + expect(response.headers.has("x-api-key")).toBe(false); + expect(disposition).not.toMatch(/[\r\n\\/]/); + expect(disposition).toContain("filename*=UTF-8''"); + expect(disposition).toContain("M%C3%BCnchen"); +}); + +test("falls back from an untrustworthy media type and length without forwarding header injection", async () => { + const deps = dependencies({ + original: binary({ + contentType: "image/jpeg;\r\nx-api-key=secret", + contentLength: -1, + }), + }); + + const response = await call(createDownloadFileHandler(deps)); + + expect(response.status).toBe(200); + expect(response.headers.get("content-type")).toBe("application/octet-stream"); + expect(response.headers.has("content-length")).toBe(false); + expect(response.headers.has("x-api-key")).toBe(false); +}); + +test("builds a standards-safe disposition for malformed Unicode", () => { + expect(() => contentDisposition("foto-\ud800.jpg")).not.toThrow(); + expect(contentDisposition("foto-\ud800.jpg")).toContain("filename*=UTF-8''foto-_.jpg"); +}); + +test("returns stable authentication semantics without exposing guard details", async () => { + const unauthenticated = dependencies({ + editorialError: new PrincipalAuthorizationError("AUTHENTICATION_REQUIRED"), + }); + const inactive = dependencies({ + editorialError: new PrincipalAuthorizationError("ACCOUNT_SUSPENDED"), + }); + + const [first, second] = await Promise.all([ + call(createDownloadFileHandler(unauthenticated)), + call(createDownloadFileHandler(inactive)), + ]); + + expect(first.status).toBe(401); + expect(second.status).toBe(403); + expect(await second.text()).not.toContain("SUSPENDED"); +}); diff --git a/src/app/api/downloads/[downloadId]/file/route.ts b/src/app/api/downloads/[downloadId]/file/route.ts new file mode 100644 index 0000000..2fee8e1 --- /dev/null +++ b/src/app/api/downloads/[downloadId]/file/route.ts @@ -0,0 +1,3 @@ +import { authorizedDownloadFileHandler } from "./download-handler"; + +export const GET = authorizedDownloadFileHandler; diff --git a/src/app/globals.css b/src/app/globals.css index 814ba9e..de83a9d 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -621,3 +621,308 @@ a { transition: none; } } + +.download-trigger { + width: 100%; + min-height: 2.45rem; + border: 0; + border-top: 1px solid var(--ink); + border-radius: 0; + background: var(--paper); + color: var(--ink); + cursor: pointer; + font: inherit; + font-size: 0.7rem; + font-weight: 750; + letter-spacing: 0.07em; + text-transform: uppercase; +} + +.download-trigger:hover { + background: var(--ink); + color: var(--paper); +} + +.usage-dialog { + width: min(calc(100% - 2rem), 46rem); + max-height: calc(100vh - 2rem); + padding: 0; + border: 1px solid var(--ink); + border-radius: 0; + background: var(--paper); + color: var(--ink); +} + +.usage-dialog::backdrop { + background: rgb(0 0 0 / 70%); +} + +.usage-dialog form { + display: grid; + gap: 1.5rem; + padding: clamp(1.25rem, 4vw, 2.5rem); +} + +.usage-dialog-heading { + padding-bottom: 1.25rem; + border-bottom: 1px solid var(--ink); +} + +.usage-dialog-heading h2 { + margin: 0; + font-size: clamp(2rem, 6vw, 4rem); + font-weight: 600; + letter-spacing: -0.055em; + line-height: 0.95; +} + +.usage-dialog-heading > p:last-child { + max-width: 38rem; + margin: 1rem 0 0; + color: var(--graphite); + line-height: 1.5; +} + +.usage-options { + display: grid; + gap: 0; + margin: 0; + padding: 0; + border: 0; +} + +.usage-options legend, +.usage-purpose { + margin-bottom: 0.6rem; + font-size: 0.7rem; + font-weight: 750; + letter-spacing: 0.08em; + text-transform: uppercase; +} + +.usage-option { + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + align-items: center; + gap: 0.9rem; + padding: 0.9rem 0; + border-top: 1px solid var(--line); + cursor: pointer; +} + +.usage-option:last-child { + border-bottom: 1px solid var(--line); +} + +.usage-option input { + width: 1.05rem; + height: 1.05rem; + accent-color: var(--ink); +} + +.usage-option span { + display: grid; + gap: 0.2rem; + min-width: 0; +} + +.usage-option strong, +.usage-option b { + font-size: 0.875rem; +} + +.usage-option small { + overflow: hidden; + color: var(--metadata); + font-size: 0.7rem; + text-overflow: ellipsis; + white-space: nowrap; +} + +.usage-purpose { + display: grid; + gap: 0.5rem; + margin: 0; +} + +.usage-purpose textarea { + width: 100%; + resize: vertical; + border: 1px solid var(--ink); + border-radius: 0; + background: var(--paper); + color: var(--ink); + font: inherit; + padding: 0.75rem; +} + +.usage-purpose textarea:disabled { + border-color: var(--line); + background: var(--soft); +} + +.usage-dialog [role="alert"] { + margin: 0; + color: #8d1010; + font-size: 0.875rem; +} + +.usage-dialog-actions { + display: flex; + justify-content: flex-end; + gap: 0.75rem; +} + +.usage-dialog-actions button { + min-height: 2.8rem; + border: 1px solid var(--ink); + border-radius: 0; + background: var(--paper); + color: var(--ink); + cursor: pointer; + font: inherit; + font-size: 0.8rem; + font-weight: 700; + padding-inline: 1rem; +} + +.usage-dialog-actions .download-confirm { + background: var(--ink); + color: var(--paper); +} + +.usage-dialog-actions button:disabled { + cursor: wait; + opacity: 0.55; +} + +.usage-history-empty { + max-width: 38rem; +} + +.usage-history-empty p { + color: var(--graphite); + line-height: 1.55; +} + +.usage-ledger, +.usage-attempts { + margin: 0; + padding: 0; + list-style: none; +} + +.usage-ledger { + display: grid; + gap: 2.5rem; +} + +.usage-ledger-entry { + border-top: 2px solid var(--ink); +} + +.usage-ledger-entry > header { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 1rem; + padding: 0.8rem 0; + border-bottom: 1px solid var(--line); +} + +.usage-ledger-entry > header p { + margin: 0; + color: var(--metadata); + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + font-size: 0.65rem; + letter-spacing: 0.04em; + text-transform: uppercase; +} + +.usage-ledger-entry h2 { + overflow-wrap: anywhere; + margin: 0; + font-size: clamp(1.35rem, 3vw, 2.25rem); + font-weight: 600; + letter-spacing: -0.035em; +} + +.usage-snapshot { + display: grid !important; + grid-template-columns: repeat(3, minmax(0, 1fr)) !important; + gap: 1rem !important; + max-width: none !important; + margin: 0 !important; + padding: 1rem 0 !important; + border-top: 0 !important; +} + +.usage-snapshot div { + min-width: 0; +} + +.usage-snapshot dd { + overflow-wrap: anywhere; + margin-top: 0.25rem; +} + +.usage-attempts { + border-top: 1px solid var(--ink); +} + +.usage-attempts li { + display: grid; + grid-template-columns: minmax(9rem, 1.2fr) minmax(11rem, 1.5fr) minmax(8rem, 1fr) 0.7fr 0.7fr; + gap: 1rem; + align-items: baseline; + padding: 0.7rem 0; + border-bottom: 1px solid var(--line); + font-size: 0.75rem; +} + +.usage-attempts time, +.usage-attempts span { + color: var(--metadata); +} + +.usage-attempts b { + text-align: right; +} + +.usage-attempt-empty { + margin: 0; + padding: 1rem 0; + border-top: 1px solid var(--line); + color: var(--metadata); + font-size: 0.8rem; +} + +@media (max-width: 52rem) { + .usage-snapshot { + grid-template-columns: 1fr !important; + } + + .usage-attempts li { + grid-template-columns: 1fr auto; + } + + .usage-attempts li > :nth-child(3), + .usage-attempts li > :nth-child(4) { + display: none; + } +} + +@media (max-width: 40rem) { + .usage-dialog-actions { + flex-direction: column-reverse; + } + + .usage-dialog-actions button { + width: 100%; + } + + .usage-ledger-entry > header { + align-items: flex-start; + flex-direction: column-reverse; + } +} diff --git a/src/app/redaktion/alben/[albumId]/page.tsx b/src/app/redaktion/alben/[albumId]/page.tsx index c138973..bc054ca 100644 --- a/src/app/redaktion/alben/[albumId]/page.tsx +++ b/src/app/redaktion/alben/[albumId]/page.tsx @@ -3,6 +3,7 @@ import { notFound } from "next/navigation"; import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog"; import { PhotoContactSheet } from "@/modules/albums/catalog-content"; +import { loadEditorialDownloadOptions } from "@/modules/downloads/stream"; import { requireEditorial } from "../../access"; @@ -44,6 +45,7 @@ export default async function AlbumPage({ params, searchParams }: AlbumPageProps @@ -73,7 +75,11 @@ async function loadAlbumPage({ description: query, page, }); - return { album, page: results, unavailable: false as const }; + const downloadOptions = await loadEditorialDownloadOptions( + editorialId, + results.items.map((asset) => asset.id), + ); + return { album, page: results, downloadOptions, unavailable: false as const }; } catch (error) { if (error instanceof AlbumCatalogError && error.code === "IMMICH_UNAVAILABLE") { return { album: null, page: null, unavailable: true as const }; diff --git a/src/app/redaktion/nutzungen/page.test.tsx b/src/app/redaktion/nutzungen/page.test.tsx new file mode 100644 index 0000000..5e3952d --- /dev/null +++ b/src/app/redaktion/nutzungen/page.test.tsx @@ -0,0 +1,84 @@ +// @vitest-environment jsdom + +import { cleanup, render, screen } from "@testing-library/react"; +import { afterEach, expect, test } from "vitest"; + +import { UsageHistoryContent } from "./usage-history-content"; + +afterEach(cleanup); + +test("renders every terminal attempt with its immutable usage snapshot", () => { + render( + , + ); + + expect(screen.getByRole("heading", { name: /tor-des-monats\.jpg/i })).not.toBeNull(); + expect(screen.getByText("Heimspiel gegen Nord")).not.toBeNull(); + expect(screen.getByText("Titelgeschichte")).not.toBeNull(); + expect(screen.getByText("Abgeschlossen")).not.toBeNull(); + expect(screen.getByText("Unterbrochen")).not.toBeNull(); + expect(screen.getByText("Vor Auslieferung fehlgeschlagen")).not.toBeNull(); + expect(screen.getByText(/15,00\s*€/)).not.toBeNull(); + expect(screen.getAllByText(/0,00\s*€/)).toHaveLength(2); + expect(screen.getByRole("link", { name: /nächste seite/i }).getAttribute("href")).toBe( + "/redaktion/nutzungen?page=2", + ); +}); + +test("renders a directional empty state", () => { + render( + , + ); + + expect(screen.getByText(/noch keine nutzungen/i)).not.toBeNull(); + expect(screen.getByRole("link", { name: /zu den alben/i })).not.toBeNull(); +}); diff --git a/src/app/redaktion/nutzungen/page.tsx b/src/app/redaktion/nutzungen/page.tsx new file mode 100644 index 0000000..82cad2e --- /dev/null +++ b/src/app/redaktion/nutzungen/page.tsx @@ -0,0 +1,40 @@ +import { listEditorialUsageHistory } from "@/modules/downloads/stream"; + +import { requireEditorial } from "../access"; +import { UsageHistoryContent } from "./usage-history-content"; + +type UsageHistoryPageProps = Readonly<{ + searchParams: Promise<{ page?: string | string[] }>; +}>; + +export default async function UsagesPage({ searchParams }: UsageHistoryPageProps) { + const [principal, parameters] = await Promise.all([requireEditorial(), searchParams]); + const result = await loadHistory(principal.editorialId, singleValue(parameters.page)); + if (result.unavailable) return ; + return ; +} + +async function loadHistory(editorialId: string, page: string | undefined) { + try { + return { + history: await listEditorialUsageHistory(editorialId, page), + unavailable: false as const, + }; + } catch { + return { history: null, unavailable: true as const }; + } +} + +function HistoryUnavailable() { + return ( +
+

Abrechnung

+

Nutzungen momentan nicht erreichbar

+

Bitte laden Sie diese Seite in wenigen Minuten erneut.

+
+ ); +} + +function singleValue(value: string | string[] | undefined): string | undefined { + return typeof value === "string" ? value : undefined; +} diff --git a/src/app/redaktion/nutzungen/usage-history-content.tsx b/src/app/redaktion/nutzungen/usage-history-content.tsx new file mode 100644 index 0000000..539aff9 --- /dev/null +++ b/src/app/redaktion/nutzungen/usage-history-content.tsx @@ -0,0 +1,120 @@ +import Link from "next/link"; + +import type { UsageHistoryAttempt, UsageHistoryPage } from "@/modules/downloads/stream"; + +const dateTimeFormatter = new Intl.DateTimeFormat("de-DE", { + dateStyle: "medium", + timeStyle: "short", +}); +const priceFormatter = new Intl.NumberFormat("de-DE", { + style: "currency", + currency: "EUR", +}); +const byteFormatter = new Intl.NumberFormat("de-DE", { + style: "unit", + unit: "byte", + unitDisplay: "short", + maximumFractionDigits: 0, +}); + +export function UsageHistoryContent({ history }: Readonly<{ history: UsageHistoryPage }>) { + return ( +
+

Abrechnung · Downloadprotokoll

+
+

Ihre Nutzungen

+

Verwendungszwecke, Kosten und Auslieferungsversuche Ihrer Redaktion.

+
+ + {history.items.length === 0 ? ( +
+

Noch keine Nutzungen erfasst. Wählen Sie ein Foto aus einem freigegebenen Album.

+ + Zu den Alben + +
+ ) : ( +
    + {history.items.map((usage) => ( +
  1. +
    +
    +

    {formatDateTime(usage.createdAt)}

    +

    {usage.filename}

    +
    +
    +
    +
    Album
    +
    {usage.albumName}
    +
    +
    +
    Verwendungszweck
    +
    {usage.purpose}
    +
    + {usage.reference ? ( +
    +
    Interne Referenz
    +
    {usage.reference}
    +
    + ) : null} +
    + {usage.attempts.length === 0 ? ( +

    Noch kein abgeschlossener Auslieferungsversuch.

    + ) : ( +
      + {usage.attempts.map((attempt) => ( + + ))} +
    + )} +
    +
  2. + ))} +
+ )} + + +
+ ); +} + +function AttemptRow({ attempt }: Readonly<{ attempt: UsageHistoryAttempt }>) { + return ( +
  • + + {statusLabel(attempt.status)} + {attempt.repeat ? "Wiederholter Abruf" : "Neue Nutzung"} + {byteFormatter.format(attempt.transferredBytes)} + {priceFormatter.format(attempt.billableCents / 100)} +
  • + ); +} + +function HistoryPagination({ history }: Readonly<{ history: UsageHistoryPage }>) { + if (history.page === 1 && !history.hasNext) return null; + return ( + + ); +} + +function statusLabel(status: UsageHistoryAttempt["status"]): string { + const labels: Record = { + completed: "Abgeschlossen", + interrupted: "Unterbrochen", + failed_before_delivery: "Vor Auslieferung fehlgeschlagen", + }; + return labels[status]; +} + +function formatDateTime(value: Date): string { + return dateTimeFormatter.format(value); +} diff --git a/src/components/download/usage-dialog.test.tsx b/src/components/download/usage-dialog.test.tsx new file mode 100644 index 0000000..76e194a --- /dev/null +++ b/src/components/download/usage-dialog.test.tsx @@ -0,0 +1,137 @@ +// @vitest-environment jsdom + +import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"; +import { afterEach, beforeEach, expect, test, vi } from "vitest"; + +import { UsageDialog } from "./usage-dialog"; + +const idempotencyKey = "55555555-5555-4555-8555-555555555555"; + +beforeEach(() => { + Object.defineProperty(HTMLDialogElement.prototype, "showModal", { + configurable: true, + value() { + this.setAttribute("open", ""); + }, + }); + Object.defineProperty(HTMLDialogElement.prototype, "close", { + configurable: true, + value() { + this.removeAttribute("open"); + this.dispatchEvent(new Event("close")); + }, + }); +}); + +afterEach(() => { + cleanup(); + vi.restoreAllMocks(); + vi.unstubAllGlobals(); +}); + +function renderDialog() { + return render( + , + ); +} + +test("offers an existing free use and a new server-priced use with required purpose", () => { + renderDialog(); + fireEvent.click(screen.getByRole("button", { name: /original laden/i })); + + expect(screen.getByRole("dialog", { name: /nutzung auswählen/i })).not.toBeNull(); + expect( + (screen.getByRole("radio", { + name: /online-nachbericht.*0,00\s*€/i, + }) as HTMLInputElement).checked, + ).toBe(true); + expect( + (screen.getByRole("radio", { name: /neue nutzung.*15,00\s*€/i }) as HTMLInputElement) + .checked, + ).toBe(false); + expect( + (screen.getByRole("textbox", { name: /^verwendungszweck$/i }) as HTMLTextAreaElement) + .disabled, + ).toBe(true); + + fireEvent.click(screen.getByRole("radio", { name: /neue nutzung/i })); + expect( + (screen.getByRole("textbox", { name: /^verwendungszweck$/i }) as HTMLTextAreaElement) + .required, + ).toBe(true); +}); + +test("reuses one idempotency key when the same failed submission is retried", async () => { + const randomUUID = vi.spyOn(globalThis.crypto, "randomUUID").mockReturnValue(idempotencyKey); + const fetch = vi + .fn() + .mockResolvedValueOnce(new Response(null, { status: 503 })) + .mockResolvedValueOnce( + Response.json({ + downloadId: "66666666-6666-4666-8666-666666666666", + fileUrl: "/api/downloads/66666666-6666-4666-8666-666666666666/file", + priceCents: 1_500, + billable: true, + }), + ); + vi.stubGlobal("fetch", fetch); + const anchorClick = vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => {}); + renderDialog(); + fireEvent.click(screen.getByRole("button", { name: /original laden/i })); + fireEvent.click(screen.getByRole("radio", { name: /neue nutzung/i })); + fireEvent.change(screen.getByRole("textbox", { name: /^verwendungszweck$/i }), { + target: { value: "Titelgeschichte" }, + }); + + fireEvent.click(screen.getByRole("button", { name: /download anfordern/i })); + await screen.findByRole("alert"); + fireEvent.click(screen.getByRole("button", { name: /download erneut anfordern/i })); + + await waitFor(() => expect(anchorClick).toHaveBeenCalledOnce()); + expect(randomUUID).toHaveBeenCalledOnce(); + expect(fetch).toHaveBeenCalledTimes(2); + for (const [, init] of fetch.mock.calls) { + expect(JSON.parse(String(init?.body))).toMatchObject({ idempotencyKey }); + } +}); + +test("suppresses double-click submission while one request is pending", async () => { + vi.spyOn(globalThis.crypto, "randomUUID").mockReturnValue(idempotencyKey); + let resolveRequest: ((response: Response) => void) | undefined; + const fetch = vi.fn().mockReturnValue( + new Promise((resolve) => { + resolveRequest = resolve; + }), + ); + vi.stubGlobal("fetch", fetch); + vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => {}); + renderDialog(); + fireEvent.click(screen.getByRole("button", { name: /original laden/i })); + const submit = screen.getByRole("button", { name: /download anfordern/i }); + + fireEvent.click(submit); + fireEvent.click(submit); + + expect(fetch).toHaveBeenCalledOnce(); + resolveRequest?.( + Response.json({ + downloadId: "66666666-6666-4666-8666-666666666666", + fileUrl: "/api/downloads/66666666-6666-4666-8666-666666666666/file", + priceCents: 0, + billable: false, + }), + ); + await waitFor(() => expect((submit as HTMLButtonElement).disabled).toBe(false)); +}); diff --git a/src/components/download/usage-dialog.tsx b/src/components/download/usage-dialog.tsx new file mode 100644 index 0000000..8346b5d --- /dev/null +++ b/src/components/download/usage-dialog.tsx @@ -0,0 +1,224 @@ +"use client"; + +import { useRef, useState, type FormEvent } from "react"; + +import type { DownloadDialogUsage } from "@/modules/downloads/stream"; + +type UsageDialogProps = Readonly<{ + albumId: string; + assetId: string; + filename: string; + newUsagePriceCents: number; + priorUsages: DownloadDialogUsage[]; +}>; + +type IntentResponse = { + downloadId: string; + fileUrl: string; + priceCents: number; + billable: boolean; +}; + +const priceFormatter = new Intl.NumberFormat("de-DE", { + style: "currency", + currency: "EUR", +}); +const dateFormatter = new Intl.DateTimeFormat("de-DE", { + dateStyle: "medium", +}); + +export function UsageDialog({ + albumId, + assetId, + filename, + newUsagePriceCents, + priorUsages, +}: UsageDialogProps) { + const dialogRef = useRef(null); + const firstChoiceRef = useRef(null); + const idempotencyKeyRef = useRef(null); + const initialChoice = priorUsages[0] ? `repeat:${priorUsages[0].id}` : "new_usage"; + const [choice, setChoice] = useState(initialChoice); + const [purpose, setPurpose] = useState(""); + const [pending, setPending] = useState(false); + const [error, setError] = useState(null); + + function openDialog() { + setChoice(initialChoice); + setPurpose(""); + setPending(false); + setError(null); + idempotencyKeyRef.current = null; + dialogRef.current?.showModal(); + requestAnimationFrame(() => firstChoiceRef.current?.focus()); + } + + function closeDialog() { + if (!pending) dialogRef.current?.close(); + } + + function resetSubmission() { + idempotencyKeyRef.current = null; + setError(null); + } + + async function submit(event: FormEvent) { + event.preventDefault(); + if (pending) return; + setPending(true); + setError(null); + idempotencyKeyRef.current ??= crypto.randomUUID(); + + const payload = choice.startsWith("repeat:") + ? { + kind: "repeat_download" as const, + usageId: choice.slice("repeat:".length), + idempotencyKey: idempotencyKeyRef.current, + } + : { + kind: "new_usage" as const, + assetId, + albumId, + purpose, + idempotencyKey: idempotencyKeyRef.current, + }; + + try { + const response = await fetch("/api/download-intents", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify(payload), + }); + if (!response.ok) throw new Error("intent failed"); + const intent = (await response.json()) as IntentResponse; + if (!isLocalDownloadUrl(intent.fileUrl, intent.downloadId)) { + throw new Error("invalid download url"); + } + const link = document.createElement("a"); + link.href = intent.fileUrl; + link.download = filename; + link.click(); + dialogRef.current?.close(); + idempotencyKeyRef.current = null; + } catch { + setError( + "Der Download konnte nicht vorbereitet werden. Versuchen Sie dieselbe Anfrage erneut.", + ); + } finally { + setPending(false); + } + } + + const isNewUsage = choice === "new_usage"; + + return ( + <> + + { + if (pending) event.preventDefault(); + }} + onClose={() => { + setError(null); + idempotencyKeyRef.current = null; + }} + ref={dialogRef} + > +
    +
    +

    Download · {filename}

    +

    Nutzung auswählen

    +

    Ordnen Sie das Original einer bestehenden oder einer neuen Nutzung zu.

    +
    + +
    + Abrechnung + {priorUsages.map((usage, index) => ( + + ))} + +
    + +