From fffb6db2fb8698f523466848b312e79eaa8f823f Mon Sep 17 00:00:00 2001 From: Graham Barber Date: Mon, 13 Jul 2026 00:48:58 -0700 Subject: [PATCH] scaffold sveltekit on deno with sqlite foundation --- .env.example | 14 + .gitignore | 26 + .npmrc | 1 + .vscode/extensions.json | 3 + README.md | 42 + deno.json | 11 + deno.lock | 831 ++++++++++++++++++ migrations/001_init.sql | 127 +++ .../changes/bootstrap-finance-app/tasks.md | 10 +- package.json | 24 + scripts/generate-oauth-key.ts | 14 + src/app.d.ts | 13 + src/app.html | 12 + src/hooks.server.ts | 10 + src/lib/assets/favicon.svg | 1 + src/lib/index.ts | 1 + src/lib/server/README.md | 22 + src/lib/server/config.test.ts | 59 ++ src/lib/server/config.ts | 79 ++ src/lib/server/db.test.ts | 52 ++ src/lib/server/db.ts | 70 ++ src/routes/+layout.svelte | 11 + src/routes/+page.svelte | 2 + src/routes/healthz/+server.ts | 5 + static/robots.txt | 3 + tsconfig.json | 23 + vite.config.ts | 18 + 27 files changed, 1479 insertions(+), 5 deletions(-) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 .npmrc create mode 100644 .vscode/extensions.json create mode 100644 README.md create mode 100644 deno.json create mode 100644 deno.lock create mode 100644 migrations/001_init.sql create mode 100644 package.json create mode 100644 scripts/generate-oauth-key.ts create mode 100644 src/app.d.ts create mode 100644 src/app.html create mode 100644 src/hooks.server.ts create mode 100644 src/lib/assets/favicon.svg create mode 100644 src/lib/index.ts create mode 100644 src/lib/server/README.md create mode 100644 src/lib/server/config.test.ts create mode 100644 src/lib/server/config.ts create mode 100644 src/lib/server/db.test.ts create mode 100644 src/lib/server/db.ts create mode 100644 src/routes/+layout.svelte create mode 100644 src/routes/+page.svelte create mode 100644 src/routes/healthz/+server.ts create mode 100644 static/robots.txt create mode 100644 tsconfig.json create mode 100644 vite.config.ts diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e63d6fa --- /dev/null +++ b/.env.example @@ -0,0 +1,14 @@ +# Public HTTPS origin of this instance (behind Caddy). Drives the ATProto OAuth +# client identity — changing it later forces both users to re-consent. +APP_URL=https://quantum.example.com + +# Comma-separated DIDs allowed to log in. Everyone else gets a 403. +ALLOWED_DIDS=did:plc:replace-with-yours,did:plc:replace-with-spouses + +# SQLite database file. Treat this file as secret-grade: it holds the SimpleFIN +# Access URL and all financial history. Back it up. +DB_PATH=./data/quantum.db + +# ES256 private key (JWK, single line) for OAuth client authentication. +# Generate with: deno task generate-key +OAUTH_PRIVATE_KEY_JWK= diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc44067 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +node_modules + +# Output +.output +.vercel +.netlify +.wrangler +/.svelte-kit +/build + +# Local database +/data + +# OS +.DS_Store +Thumbs.db + +# Env +.env +.env.* +!.env.example +!.env.test + +# Vite +vite.config.js.timestamp-* +vite.config.ts.timestamp-* diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..b6f27f1 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..28d1e67 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["svelte.svelte-vscode"] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..a075c20 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# sv + +Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli). + +## Creating a project + +If you're seeing this, you've probably already done this step. Congrats! + +```sh +# create a new project +npx sv create my-app +``` + +To recreate this project with the same configuration: + +```sh +# recreate this project +deno run npm:sv@0.16.2 create --template minimal --types ts --install deno quantum-scaffold +``` + +## Developing + +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: + +```sh +npm run dev + +# or start the server and open the app in a new browser tab +npm run dev -- --open +``` + +## Building + +To create a production version of your app: + +```sh +npm run build +``` + +You can preview the production build with `npm run preview`. + +> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..a41dd33 --- /dev/null +++ b/deno.json @@ -0,0 +1,11 @@ +{ + "nodeModulesDir": "auto", + "tasks": { + "dev": "deno run --env-file -A npm:vite dev", + "build": "deno run -A npm:vite build", + "start": "deno run --env-file --unstable-cron -A build/index.js", + "check": "deno run -A npm:@sveltejs/kit/svelte-kit sync && deno run -A npm:svelte-check --tsconfig ./tsconfig.json", + "test": "deno test -A src", + "generate-key": "deno run scripts/generate-oauth-key.ts" + } +} diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..becf6a4 --- /dev/null +++ b/deno.lock @@ -0,0 +1,831 @@ +{ + "version": "5", + "specifiers": { + "npm:@sveltejs/adapter-node@^5.5.0": "5.5.7_@sveltejs+kit@2.69.2__@sveltejs+vite-plugin-svelte@7.2.0___svelte@5.56.4___vite@8.1.4____@types+node@26.1.1___@types+node@26.1.1__svelte@5.56.4__typescript@6.0.3__vite@8.1.4___@types+node@26.1.1__@types+node@26.1.1_@types+node@26.1.1", + "npm:@sveltejs/kit@*": "2.69.2_@sveltejs+vite-plugin-svelte@7.2.0__svelte@5.56.4__vite@8.1.4___@types+node@26.1.1__@types+node@26.1.1_svelte@5.56.4_typescript@6.0.3_vite@8.1.4__@types+node@26.1.1_@types+node@26.1.1", + "npm:@sveltejs/kit@^2.63.0": "2.69.2_@sveltejs+vite-plugin-svelte@7.2.0__svelte@5.56.4__vite@8.1.4___@types+node@26.1.1__@types+node@26.1.1_svelte@5.56.4_typescript@6.0.3_vite@8.1.4__@types+node@26.1.1_@types+node@26.1.1", + "npm:@sveltejs/vite-plugin-svelte@^7.1.2": "7.2.0_svelte@5.56.4_vite@8.1.4__@types+node@26.1.1_@types+node@26.1.1", + "npm:@types/node@^26.1.1": "26.1.1", + "npm:svelte-check@*": "4.7.2_svelte@5.56.4_typescript@6.0.3", + "npm:svelte-check@^4.6.0": "4.7.2_svelte@5.56.4_typescript@6.0.3", + "npm:svelte@^5.56.1": "5.56.4", + "npm:typescript@^6.0.3": "6.0.3", + "npm:vite@*": "8.1.4_@types+node@26.1.1", + "npm:vite@^8.0.16": "8.1.4_@types+node@26.1.1" + }, + "npm": { + "@emnapi/core@1.11.1": { + "integrity": "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==", + "dependencies": [ + "@emnapi/wasi-threads", + "tslib" + ] + }, + "@emnapi/runtime@1.11.1": { + "integrity": "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==", + "dependencies": [ + "tslib" + ] + }, + "@emnapi/wasi-threads@1.2.2": { + "integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==", + "dependencies": [ + "tslib" + ] + }, + "@jridgewell/gen-mapping@0.3.13": { + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dependencies": [ + "@jridgewell/sourcemap-codec", + "@jridgewell/trace-mapping" + ] + }, + "@jridgewell/remapping@2.3.5": { + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dependencies": [ + "@jridgewell/gen-mapping", + "@jridgewell/trace-mapping" + ] + }, + "@jridgewell/resolve-uri@3.1.2": { + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==" + }, + "@jridgewell/sourcemap-codec@1.5.5": { + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==" + }, + "@jridgewell/trace-mapping@0.3.31": { + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dependencies": [ + "@jridgewell/resolve-uri", + "@jridgewell/sourcemap-codec" + ] + }, + "@napi-rs/wasm-runtime@1.1.6_@emnapi+core@1.11.1_@emnapi+runtime@1.11.1": { + "integrity": "sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==", + "dependencies": [ + "@emnapi/core", + "@emnapi/runtime", + "@tybys/wasm-util" + ] + }, + "@oxc-project/types@0.139.0": { + "integrity": "sha512-r9gHphtCs+1M7J0pw6Sn/hh/Wpa/iQrOOkrNAlVLF/gHq+/CJmHIWKKUUhdWjcD6CIa8idarspCsASiXCXvFUw==" + }, + "@polka/url@1.0.0-next.29": { + "integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==" + }, + "@rolldown/binding-android-arm64@1.1.5": { + "integrity": "sha512-lZg8fqIv2v7FF237bwMgzGZEJvGL79/s5knJ/i6FmsGF4XXlzccZ4jb+TrFIxtSSxFtIpdsgrPZeMk1I9AFcyQ==", + "os": ["android"], + "cpu": ["arm64"] + }, + "@rolldown/binding-darwin-arm64@1.1.5": { + "integrity": "sha512-51Bnx9pNiMRKSUNtBfySkNJ9vMU9Hh3I1ozDd6gyPPYzaXCfnptUcEZxXGYFn+ul2dtcMUiqGR1Yai2K10uoTw==", + "os": ["darwin"], + "cpu": ["arm64"] + }, + "@rolldown/binding-darwin-x64@1.1.5": { + "integrity": "sha512-Tm+gbfC0aHu1tBA/JvKQh32S0K6YgCHkiAF4/W6xX0K0RmNuc94VeK419dJoE65R5aRxmo+noZQSWrAMF6yb6g==", + "os": ["darwin"], + "cpu": ["x64"] + }, + "@rolldown/binding-freebsd-x64@1.1.5": { + "integrity": "sha512-JMzDKCCXq93YccG5gz3hvOs1oXRKAf0XYpfOS88e+wZrC8Iugj6j68867vrYZkvpDDpKn/KoKORThmchMpF6TA==", + "os": ["freebsd"], + "cpu": ["x64"] + }, + "@rolldown/binding-linux-arm-gnueabihf@1.1.5": { + "integrity": "sha512-uML21j2K5TfPGutKxub+M+nLjZIrWjXQ5Grx4lCe/nimTj9B4L63zHpjXLl4y0L3mcm2htEQIb06oCG/szerNw==", + "os": ["linux"], + "cpu": ["arm"] + }, + "@rolldown/binding-linux-arm64-gnu@1.1.5": { + "integrity": "sha512-navSiuTMogvnQoZoM/v+l3ZWo50/NTwSHSzheABx/RCnmUPaKwq9qSo4Br2OYRs21+Fz8uFqITZM3H4opOB0/Q==", + "os": ["linux"], + "cpu": ["arm64"] + }, + "@rolldown/binding-linux-arm64-musl@1.1.5": { + "integrity": "sha512-lAryqH7IteztmCXQXk0etKj4wBQ7Gx5S6LjKhsgp9zb8I5bsuvU/2llH1hDQcjsFeqIsovMVN339/8pUDDBXxA==", + "os": ["linux"], + "cpu": ["arm64"] + }, + "@rolldown/binding-linux-ppc64-gnu@1.1.5": { + "integrity": "sha512-fsK/sNBnxzBlL4O1JNrZakVQxPspqpED5dLtNsZS9oOKmtSpdNIzxH2kkol5HYTWJN47sE20ztMJPxfZ89qGOg==", + "os": ["linux"], + "cpu": ["ppc64"] + }, + "@rolldown/binding-linux-s390x-gnu@1.1.5": { + "integrity": "sha512-gLYb4BIadlfTOYT5gO503n8zQjXflgzpD0FcyKh0Mzx3rqCZKnHoJWV9xe1KXUJ5lx2JfcSHr/mhzS0PC/McAA==", + "os": ["linux"], + "cpu": ["s390x"] + }, + "@rolldown/binding-linux-x64-gnu@1.1.5": { + "integrity": "sha512-FjcpEKUyJygHgs1o50VYNvkt5+7Le/VEdYt0AkRpkL33MnyQfwr8l5mXwMmfmTbyMPr5vJLC+8/Gd9gXnwU1QQ==", + "os": ["linux"], + "cpu": ["x64"] + }, + "@rolldown/binding-linux-x64-musl@1.1.5": { + "integrity": "sha512-Me+PfPI2TMeOQk0gYWfLQZtTktrmzbr8cDboqX83XKc7UrgAi55gF+2dUkWdxd19n55Essp2yeca+O9N5rBxHg==", + "os": ["linux"], + "cpu": ["x64"] + }, + "@rolldown/binding-openharmony-arm64@1.1.5": { + "integrity": "sha512-yc5WrLzXks6zCQfn9Oxr8pORKyl/pF+QjHmW/Qx3qu0oyrrNC+y2JLTU1E2rcWYAmzlnqngWXHQjy51VzW70Vw==", + "os": ["openharmony"], + "cpu": ["arm64"] + }, + "@rolldown/binding-wasm32-wasi@1.1.5": { + "integrity": "sha512-VbQGPX2b4r48TAMIM2cjgluIM1HYutm4pcTEJsle7iEP7sB1dFqtPLBVbdLAZCxy1txCcPxf4QFf4v8uvltPqA==", + "dependencies": [ + "@emnapi/core", + "@emnapi/runtime", + "@napi-rs/wasm-runtime" + ], + "cpu": ["wasm32"] + }, + "@rolldown/binding-win32-arm64-msvc@1.1.5": { + "integrity": "sha512-gHv82k63z4qpV5+Q1y/12KrK0ltWBukVDI8nZcbT7Tt/ZlOIVwppazneq0F93oDxTo3IgAMEDIoQh3E2n6mVsw==", + "os": ["win32"], + "cpu": ["arm64"] + }, + "@rolldown/binding-win32-x64-msvc@1.1.5": { + "integrity": "sha512-tTZuDBPw85tEN5PQi1pnEBzDy0Z49HtScLAbD5t6hyeU92A95pRWaSMw1GZZi/RwgSgUIl0xrSlXIT/9QzvYSA==", + "os": ["win32"], + "cpu": ["x64"] + }, + "@rolldown/pluginutils@1.0.1": { + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==" + }, + "@rollup/plugin-commonjs@29.0.3_rollup@4.62.2": { + "integrity": "sha512-ZaOxZceP7SOUW7Lqw5IRVweSQYWaeIPnXIGLiB690EBA3FGJTO40EEr2L5yZplJWsgTCogILRSpcAe7+U0Otdg==", + "dependencies": [ + "@rollup/pluginutils", + "commondir", + "estree-walker", + "fdir", + "is-reference@1.2.1", + "magic-string", + "picomatch", + "rollup" + ], + "optionalPeers": [ + "rollup" + ] + }, + "@rollup/plugin-json@6.1.0_rollup@4.62.2": { + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dependencies": [ + "@rollup/pluginutils", + "rollup" + ], + "optionalPeers": [ + "rollup" + ] + }, + "@rollup/plugin-node-resolve@16.0.3_rollup@4.62.2": { + "integrity": "sha512-lUYM3UBGuM93CnMPG1YocWu7X802BrNF3jW2zny5gQyLQgRFJhV1Sq0Zi74+dh/6NBx1DxFC4b4GXg9wUCG5Qg==", + "dependencies": [ + "@rollup/pluginutils", + "@types/resolve", + "deepmerge", + "is-module", + "resolve", + "rollup" + ], + "optionalPeers": [ + "rollup" + ] + }, + "@rollup/plugin-replace@6.0.3_rollup@4.62.2": { + "integrity": "sha512-J4RZarRvQAm5IF0/LwUUg+obsm+xZhYnbMXmXROyoSE1ATJe3oXSb9L5MMppdxP2ylNSjv6zFBwKYjcKMucVfA==", + "dependencies": [ + "@rollup/pluginutils", + "magic-string", + "rollup" + ], + "optionalPeers": [ + "rollup" + ] + }, + "@rollup/pluginutils@5.4.0_rollup@4.62.2": { + "integrity": "sha512-MfPp06CjRLfXQ3wY0R8vJDYBy/MvVcc9OulEfR0B8Iv9ko+GCNaRZ+EpJYFl27LhKsZK0o420sYCRHCjfCgeUg==", + "dependencies": [ + "@types/estree", + "estree-walker", + "picomatch", + "rollup" + ], + "optionalPeers": [ + "rollup" + ] + }, + "@rollup/rollup-android-arm-eabi@4.62.2": { + "integrity": "sha512-6o7ZLZK+BeenkZCFNDXqpbjw9bD6nuWonvS/lwQJp7NoVVxm6p3qE7qQ5jGuBjiFsgvqjD8mZAU5oWxTmbOeOg==", + "os": ["android"], + "cpu": ["arm"] + }, + "@rollup/rollup-android-arm64@4.62.2": { + "integrity": "sha512-BaH7BllCACHoH1LguOU56UItGfUWjujlO65kS9LAodViaN4bwIKd7oeW/ZHJ/4ljr/7MIiENnNy3HJ0zXv8Zkw==", + "os": ["android"], + "cpu": ["arm64"] + }, + "@rollup/rollup-darwin-arm64@4.62.2": { + "integrity": "sha512-v39RCCvj4He82I9sFmk+M1VZ0PLM9sfsLVikjfx2hYBNALhrrOR2D3JjQA6AhlaSOgcR+RzrKY7e1+bT6SUO/A==", + "os": ["darwin"], + "cpu": ["arm64"] + }, + "@rollup/rollup-darwin-x64@4.62.2": { + "integrity": "sha512-yl0y2vq3S3lHeuXhEdss6TWfKW8vkujImO12tn4ZkG/4oghr09LvdYm2RElVjokTQiUvDUGXLGsYeLqUMCKpGA==", + "os": ["darwin"], + "cpu": ["x64"] + }, + "@rollup/rollup-freebsd-arm64@4.62.2": { + "integrity": "sha512-tT4pvt4qXD+vEoezupCWi+a1F0vvDiksiHc+PxRlYTOH1I6/X4id9jPxTP+Fg+545euaFT1jJVs4CEdHZAU1vw==", + "os": ["freebsd"], + "cpu": ["arm64"] + }, + "@rollup/rollup-freebsd-x64@4.62.2": { + "integrity": "sha512-6nU5F2wCW+qvCBhTn1pdIU3bzsIoF7EUwsCDRxilWGprQR6yd508YnH9+OKFCwpfS8pjZqDUmnCAr7exax0XCg==", + "os": ["freebsd"], + "cpu": ["x64"] + }, + "@rollup/rollup-linux-arm-gnueabihf@4.62.2": { + "integrity": "sha512-n1GJHPOvpIfhi3TmrCeh6S6URt9BFCt0KQE3qvexyGCTAKpR4Lg+eWvNZEqu7epxwus/8ElT3hacYEucm49SZg==", + "os": ["linux"], + "cpu": ["arm"] + }, + "@rollup/rollup-linux-arm-musleabihf@4.62.2": { + "integrity": "sha512-JqgflS8wEB+UXV/vS1RpRbifGBeN4D5lz8D8oOFbFZw4vedvdOgCFAjfBmIMdW3yL10XpQQ0Ambepw6MXrhOnA==", + "os": ["linux"], + "cpu": ["arm"] + }, + "@rollup/rollup-linux-arm64-gnu@4.62.2": { + "integrity": "sha512-wnFJkogWvN4jm/hQRF2UBaeUmk20j5+DmHvoyWii2b8HJDyvz1MF2OU/6ynXt2KR63rbZLWkFpoytpdc/yBuSA==", + "os": ["linux"], + "cpu": ["arm64"] + }, + "@rollup/rollup-linux-arm64-musl@4.62.2": { + "integrity": "sha512-HVu2bp0zhvJ8xHEV9+UUs7S90VadmBSY3LcIMvozbPo4AuMGDWlz3ymHLHZPX4hR67TKTt8Qp5PJ5RBg/i+RMQ==", + "os": ["linux"], + "cpu": ["arm64"] + }, + "@rollup/rollup-linux-loong64-gnu@4.62.2": { + "integrity": "sha512-mQqqAV8QaoSgr9I2fKDLY2BAVvmKjWoGiu/cSYQonsLvtqwEn1E4QYfnCOcp5zoEqNhsDYin1s6jx/VJmrxlZg==", + "os": ["linux"], + "cpu": ["loong64"] + }, + "@rollup/rollup-linux-loong64-musl@4.62.2": { + "integrity": "sha512-IxKLoxCQ2IWi6bT2akyDUBGsOImDKB+sPp4EsTmwFQ/fMwpCKm8uLSSgP/Kx/QYUgKis6SEZ5/Nlhup0DIA0PQ==", + "os": ["linux"], + "cpu": ["loong64"] + }, + "@rollup/rollup-linux-ppc64-gnu@4.62.2": { + "integrity": "sha512-Mk5ha2RQSgyFfmYYLkBpPnUk8D8FriBxesO1u9O75X0mHgXL1UQcH5Itl2lurWL2tj0RxV9b9tJgipac0hRY9A==", + "os": ["linux"], + "cpu": ["ppc64"] + }, + "@rollup/rollup-linux-ppc64-musl@4.62.2": { + "integrity": "sha512-CjvEnqJL/0/TQ3TXX3OPIJ/kmBellrWd4heXUmHeJlTnmwjKpSJzoehLaL6Xk0ZnMHBu9dZuFADNOrtjF4v+2w==", + "os": ["linux"], + "cpu": ["ppc64"] + }, + "@rollup/rollup-linux-riscv64-gnu@4.62.2": { + "integrity": "sha512-1SiZbzwdkaDURsew/tSOrooKiYy7EQGT6m8ufavAi9NEyQb/6VuIxFXAL1fqa4iZe3g4NbNk4P7J32z2tw5Mgg==", + "os": ["linux"], + "cpu": ["riscv64"] + }, + "@rollup/rollup-linux-riscv64-musl@4.62.2": { + "integrity": "sha512-nQts12zJ3NQRoE6uYljOH89v7szzLDvG2JD/vsX+vGXU8w/At1GowTZ5/7qeFQ8m7L55rpR8Okugnuo5bgjy2Q==", + "os": ["linux"], + "cpu": ["riscv64"] + }, + "@rollup/rollup-linux-s390x-gnu@4.62.2": { + "integrity": "sha512-E9/ll019jhPIJgpzfZoIkBGhcz+kKNgVWYRY0zr9srBdPPFVpvOKW8VaJKUbeK+eZXyQF9ltME+Kk6affeaPgg==", + "os": ["linux"], + "cpu": ["s390x"] + }, + "@rollup/rollup-linux-x64-gnu@4.62.2": { + "integrity": "sha512-5BqxR/pshjey51iliyzTD5Xi3EN0aLmQ2lZ3lvefVV9c82BvrLo2/6OT55iifpWBufs6kdwWbuOKS841DrmK9A==", + "os": ["linux"], + "cpu": ["x64"] + }, + "@rollup/rollup-linux-x64-musl@4.62.2": { + "integrity": "sha512-uNN83XxQrRAh/w0/pmAfibcwyb6YWt4gP+dpnQKPVJshAloQ785ii8CT8ZCIxkGg9opVsvAlGhFitSm6D1Jjpg==", + "os": ["linux"], + "cpu": ["x64"] + }, + "@rollup/rollup-openbsd-x64@4.62.2": { + "integrity": "sha512-srjEIxSH3LRnJN6THczDHWQplqEMFiAJrTab0msUryh9kwNpkICf3Ea6q6MN/2cZwRFUNx5w+h6Hpi4QuHS6Zg==", + "os": ["openbsd"], + "cpu": ["x64"] + }, + "@rollup/rollup-openharmony-arm64@4.62.2": { + "integrity": "sha512-8hOJnxgbyObnCm5AlRA3A931xX19xq80RjVTKgJOvEKWqJruP/Uf12IbAOaDjjEXYRewwHLfmF0YRIdK3OwKWA==", + "os": ["openharmony"], + "cpu": ["arm64"] + }, + "@rollup/rollup-win32-arm64-msvc@4.62.2": { + "integrity": "sha512-mmF4AY1i0hG/bLWUctUq59gtmgaSIRa3cu/A3JFRp/sCNEme2bgDEiDS22P9FbnJB8NJNF4jPJiSP5RHQpUTDg==", + "os": ["win32"], + "cpu": ["arm64"] + }, + "@rollup/rollup-win32-ia32-msvc@4.62.2": { + "integrity": "sha512-DZgkknc6jhHrk46V25vbAM0zZkyP0nSDkJB8/dRkLTxv470dOmWDqGoEJl/9A0dFfS7yE3REOwNDxpHwSLSt0Q==", + "os": ["win32"], + "cpu": ["ia32"] + }, + "@rollup/rollup-win32-x64-gnu@4.62.2": { + "integrity": "sha512-T6xr6ucWSFto+VGajA8YH26LdpHRuP4YLHEKAtCWvJDOlnmWcDZVCI2Jmjr+IFHDlt2zRaTAKE4tfjTaWLgJBg==", + "os": ["win32"], + "cpu": ["x64"] + }, + "@rollup/rollup-win32-x64-msvc@4.62.2": { + "integrity": "sha512-BfzEnDJOt9T8M989/lA37EcJgat01wLRnoi5dQf3QzOH7jzpqTAzdDbVfRljVr5r+jzKqpbHeyOfAaXxAd0PAA==", + "os": ["win32"], + "cpu": ["x64"] + }, + "@standard-schema/spec@1.1.0": { + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==" + }, + "@sveltejs/acorn-typescript@1.0.11_acorn@8.17.0": { + "integrity": "sha512-LFuZUkjJ9iF7JZye/aG5XM0SFcQ5VyL0oVX4WJ9dc0Va3R3s0OauX1BESVCb+YN/ol8TAfqGDDAQsTG627Y5kw==", + "dependencies": [ + "acorn" + ] + }, + "@sveltejs/adapter-node@5.5.7_@sveltejs+kit@2.69.2__@sveltejs+vite-plugin-svelte@7.2.0___svelte@5.56.4___vite@8.1.4____@types+node@26.1.1___@types+node@26.1.1__svelte@5.56.4__typescript@6.0.3__vite@8.1.4___@types+node@26.1.1__@types+node@26.1.1_@types+node@26.1.1": { + "integrity": "sha512-uOfc9eVlI3A37RRSaKcgrheBYPrfJwC9VMqDp8x/O6tlKdcLLvHThSWD0KNIbjQ/d+7bwLGx3vx6aowAcRfd2g==", + "dependencies": [ + "@rollup/plugin-commonjs", + "@rollup/plugin-json", + "@rollup/plugin-node-resolve", + "@rollup/plugin-replace", + "@sveltejs/kit", + "rollup" + ] + }, + "@sveltejs/kit@2.69.2_@sveltejs+vite-plugin-svelte@7.2.0__svelte@5.56.4__vite@8.1.4___@types+node@26.1.1__@types+node@26.1.1_svelte@5.56.4_typescript@6.0.3_vite@8.1.4__@types+node@26.1.1_@types+node@26.1.1": { + "integrity": "sha512-CMdPDbYjRwRu4KXTxBVMuOpFPCt1i/v0ANennotec+K9Cmb2e3w2yYzJiC6Vh/WSvm9Khi5sJMZa0rJPqfHlDw==", + "dependencies": [ + "@standard-schema/spec", + "@sveltejs/acorn-typescript", + "@sveltejs/vite-plugin-svelte", + "@types/cookie", + "acorn", + "cookie", + "devalue", + "esm-env", + "kleur", + "magic-string", + "mrmime", + "set-cookie-parser", + "sirv", + "svelte", + "typescript", + "vite" + ], + "optionalPeers": [ + "typescript" + ], + "bin": true + }, + "@sveltejs/load-config@0.2.0": { + "integrity": "sha512-1LgZ/qUqSoq+QorD83lk2hka79Px0wXNW2q5V1nZlxGhQgw1jrsIbVz5YiCeucVLo4XvFLjXukUaQjIiqowkcg==" + }, + "@sveltejs/vite-plugin-svelte@7.2.0_svelte@5.56.4_vite@8.1.4__@types+node@26.1.1_@types+node@26.1.1": { + "integrity": "sha512-1SpkuMSRLfugrVX+IrKfE1RUegzo8AQzKQ6qQPfVzbcWi5IhuTPaKb5ZrLpucleFznkc4/RTeSPoRnGWFxX+EQ==", + "dependencies": [ + "deepmerge", + "magic-string", + "obug", + "svelte", + "vite", + "vitefu" + ] + }, + "@tybys/wasm-util@0.10.3": { + "integrity": "sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==", + "dependencies": [ + "tslib" + ] + }, + "@types/cookie@0.6.0": { + "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==" + }, + "@types/estree@1.0.9": { + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==" + }, + "@types/node@26.1.1": { + "integrity": "sha512-nxAkRSVkN1Y0JC1W8ky/fTfkGsMmcrRsbx+3XoZE+rMOX71kLYTV7fLXpqud1GpbpP5TuffXFqfX7fH2GgZREw==", + "dependencies": [ + "undici-types" + ] + }, + "@types/resolve@1.20.2": { + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==" + }, + "@types/trusted-types@2.0.7": { + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" + }, + "acorn@8.17.0": { + "integrity": "sha512-xRQbDb9BnwDafYNn6Vwl839DYVjqXYb1XVGtWAZ1kcDc6iwAL4hg3B1dZlRiuENFeO2H53gFG3in621AdERVAg==", + "bin": true + }, + "aria-query@5.3.1": { + "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==" + }, + "axobject-query@4.1.0": { + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==" + }, + "chokidar@4.0.3": { + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dependencies": [ + "readdirp" + ] + }, + "clsx@2.1.1": { + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==" + }, + "commondir@1.0.1": { + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==" + }, + "cookie@0.6.0": { + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==" + }, + "deepmerge@4.3.1": { + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==" + }, + "detect-libc@2.1.2": { + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==" + }, + "devalue@5.8.1": { + "integrity": "sha512-4CXDYRBGqN+57wVJkuXBYmpAVUSg3L6JAQa/DFqm238G73E1wuyc/JhGQJzN7vUf/CMphYau2zXbfWzDR5aTEw==" + }, + "esm-env@1.2.2": { + "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==" + }, + "esrap@2.2.13": { + "integrity": "sha512-m8jH5hZgJE2RRUK/jjkGPcJEDAV+dYnZYFkosQaPTcE+Yw4xynXHOo6FUdwaWBtdR3b1MMa7wEDTSHeR2VWsGA==", + "dependencies": [ + "@jridgewell/sourcemap-codec" + ] + }, + "estree-walker@2.0.2": { + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, + "fdir@6.5.0_picomatch@4.0.5": { + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dependencies": [ + "picomatch" + ], + "optionalPeers": [ + "picomatch" + ] + }, + "fsevents@2.3.3": { + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "os": ["darwin"], + "scripts": true + }, + "function-bind@1.1.2": { + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==" + }, + "hasown@2.0.4": { + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "dependencies": [ + "function-bind" + ] + }, + "is-core-module@2.16.1": { + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dependencies": [ + "hasown" + ] + }, + "is-module@1.0.0": { + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==" + }, + "is-reference@1.2.1": { + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dependencies": [ + "@types/estree" + ] + }, + "is-reference@3.0.3": { + "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==", + "dependencies": [ + "@types/estree" + ] + }, + "kleur@4.1.5": { + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==" + }, + "lightningcss-android-arm64@1.32.0": { + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "os": ["android"], + "cpu": ["arm64"] + }, + "lightningcss-darwin-arm64@1.32.0": { + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "os": ["darwin"], + "cpu": ["arm64"] + }, + "lightningcss-darwin-x64@1.32.0": { + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "os": ["darwin"], + "cpu": ["x64"] + }, + "lightningcss-freebsd-x64@1.32.0": { + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "os": ["freebsd"], + "cpu": ["x64"] + }, + "lightningcss-linux-arm-gnueabihf@1.32.0": { + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "os": ["linux"], + "cpu": ["arm"] + }, + "lightningcss-linux-arm64-gnu@1.32.0": { + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "os": ["linux"], + "cpu": ["arm64"] + }, + "lightningcss-linux-arm64-musl@1.32.0": { + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "os": ["linux"], + "cpu": ["arm64"] + }, + "lightningcss-linux-x64-gnu@1.32.0": { + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "os": ["linux"], + "cpu": ["x64"] + }, + "lightningcss-linux-x64-musl@1.32.0": { + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "os": ["linux"], + "cpu": ["x64"] + }, + "lightningcss-win32-arm64-msvc@1.32.0": { + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "os": ["win32"], + "cpu": ["arm64"] + }, + "lightningcss-win32-x64-msvc@1.32.0": { + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "os": ["win32"], + "cpu": ["x64"] + }, + "lightningcss@1.32.0": { + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "dependencies": [ + "detect-libc" + ], + "optionalDependencies": [ + "lightningcss-android-arm64", + "lightningcss-darwin-arm64", + "lightningcss-darwin-x64", + "lightningcss-freebsd-x64", + "lightningcss-linux-arm-gnueabihf", + "lightningcss-linux-arm64-gnu", + "lightningcss-linux-arm64-musl", + "lightningcss-linux-x64-gnu", + "lightningcss-linux-x64-musl", + "lightningcss-win32-arm64-msvc", + "lightningcss-win32-x64-msvc" + ] + }, + "locate-character@3.0.0": { + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==" + }, + "magic-string@0.30.21": { + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dependencies": [ + "@jridgewell/sourcemap-codec" + ] + }, + "mri@1.2.0": { + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==" + }, + "mrmime@2.0.1": { + "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==" + }, + "nanoid@3.3.15": { + "integrity": "sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA==", + "bin": true + }, + "obug@2.1.3": { + "integrity": "sha512-9miFgM2OFba7hB+pRgvtV84pYTBaoTHohvmIgiRt6dRIzbwEOIaNaP+dIlGs2fNFoB0SeISs0Jz5WFVRid6Xyg==" + }, + "path-parse@1.0.7": { + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "picocolors@1.1.1": { + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" + }, + "picomatch@4.0.5": { + "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==" + }, + "postcss@8.5.17": { + "integrity": "sha512-J7EF+8X+CzRPaJPOv9Ck2wNWJvGnnl3PcNPAdGg6GTLjyVpyQ0yATMSXRFRV01BviT/9Gwuc3rjEyJbDJG9a4w==", + "dependencies": [ + "nanoid", + "picocolors", + "source-map-js" + ] + }, + "readdirp@4.1.2": { + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==" + }, + "resolve@1.22.11": { + "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", + "dependencies": [ + "is-core-module", + "path-parse", + "supports-preserve-symlinks-flag" + ], + "bin": true + }, + "rolldown@1.1.5": { + "integrity": "sha512-t9z29cJjXf/vxQ8dyhCSpt6H6aSwHTk8cT5I3iy6SMXuFpk5mB6PL6XfC8PCwrPTx93udwKUm9HRteAlTGBLiA==", + "dependencies": [ + "@oxc-project/types", + "@rolldown/pluginutils" + ], + "optionalDependencies": [ + "@rolldown/binding-android-arm64", + "@rolldown/binding-darwin-arm64", + "@rolldown/binding-darwin-x64", + "@rolldown/binding-freebsd-x64", + "@rolldown/binding-linux-arm-gnueabihf", + "@rolldown/binding-linux-arm64-gnu", + "@rolldown/binding-linux-arm64-musl", + "@rolldown/binding-linux-ppc64-gnu", + "@rolldown/binding-linux-s390x-gnu", + "@rolldown/binding-linux-x64-gnu", + "@rolldown/binding-linux-x64-musl", + "@rolldown/binding-openharmony-arm64", + "@rolldown/binding-wasm32-wasi", + "@rolldown/binding-win32-arm64-msvc", + "@rolldown/binding-win32-x64-msvc" + ], + "bin": true + }, + "rollup@4.62.2": { + "integrity": "sha512-RFnrW4lhXA3s3eqHDZvN654g8OTjzRfqpIRJYczCGB6HzphckVAi/Qh4tbPUbRuDi7s1Llv8g/NspLkttY3gTA==", + "dependencies": [ + "@types/estree" + ], + "optionalDependencies": [ + "@rollup/rollup-android-arm-eabi", + "@rollup/rollup-android-arm64", + "@rollup/rollup-darwin-arm64", + "@rollup/rollup-darwin-x64", + "@rollup/rollup-freebsd-arm64", + "@rollup/rollup-freebsd-x64", + "@rollup/rollup-linux-arm-gnueabihf", + "@rollup/rollup-linux-arm-musleabihf", + "@rollup/rollup-linux-arm64-gnu", + "@rollup/rollup-linux-arm64-musl", + "@rollup/rollup-linux-loong64-gnu", + "@rollup/rollup-linux-loong64-musl", + "@rollup/rollup-linux-ppc64-gnu", + "@rollup/rollup-linux-ppc64-musl", + "@rollup/rollup-linux-riscv64-gnu", + "@rollup/rollup-linux-riscv64-musl", + "@rollup/rollup-linux-s390x-gnu", + "@rollup/rollup-linux-x64-gnu", + "@rollup/rollup-linux-x64-musl", + "@rollup/rollup-openbsd-x64", + "@rollup/rollup-openharmony-arm64", + "@rollup/rollup-win32-arm64-msvc", + "@rollup/rollup-win32-ia32-msvc", + "@rollup/rollup-win32-x64-gnu", + "@rollup/rollup-win32-x64-msvc", + "fsevents" + ], + "bin": true + }, + "sade@1.8.1": { + "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", + "dependencies": [ + "mri" + ] + }, + "set-cookie-parser@3.0.1": { + "integrity": "sha512-n7Z7dXZhJbwuAHhNzkTti6Aw9QDDjZtm3JTpTGATIdNzdQz5GuFs22w90BcvF4INfnrL5xrX3oGsuqO5Dx3A1Q==" + }, + "sirv@3.0.2": { + "integrity": "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==", + "dependencies": [ + "@polka/url", + "mrmime", + "totalist" + ] + }, + "source-map-js@1.2.1": { + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==" + }, + "supports-preserve-symlinks-flag@1.0.0": { + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" + }, + "svelte-check@4.7.2_svelte@5.56.4_typescript@6.0.3": { + "integrity": "sha512-GoS4XJdGswlq0rIT1vtFLzJY1bvHtY37McY9H9Gkm1Ggw/ICdZYn8J/Z8Yi0BEL0i3R4+jtaWVePjyppMlij/A==", + "dependencies": [ + "@jridgewell/trace-mapping", + "@sveltejs/load-config", + "chokidar", + "fdir", + "picocolors", + "sade", + "svelte", + "typescript" + ], + "bin": true + }, + "svelte@5.56.4": { + "integrity": "sha512-/d0QHehmRuJW8gVz395MTkPcPozxzdjBMBE8oEYGz8O3b9KTMzzQ9ZHJQLuFKOHOPQbU6kx/X4iid/EBBzH7iw==", + "dependencies": [ + "@jridgewell/remapping", + "@jridgewell/sourcemap-codec", + "@sveltejs/acorn-typescript", + "@types/estree", + "@types/trusted-types", + "acorn", + "aria-query", + "axobject-query", + "clsx", + "devalue", + "esm-env", + "esrap", + "is-reference@3.0.3", + "locate-character", + "magic-string", + "zimmerframe" + ] + }, + "tinyglobby@0.2.17": { + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dependencies": [ + "fdir", + "picomatch" + ] + }, + "totalist@3.0.1": { + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==" + }, + "tslib@2.8.1": { + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==" + }, + "typescript@6.0.3": { + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", + "bin": true + }, + "undici-types@8.3.0": { + "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==" + }, + "vite@8.1.4_@types+node@26.1.1": { + "integrity": "sha512-bTT9PsdWO+MQMNG9ZXIP/qM9wGh37DFxTV/sPq9cFpHr3w4jkgef032PkAL9jAqhk3Nz8NQw3O8n6/xFkqO4QQ==", + "dependencies": [ + "@types/node", + "lightningcss", + "picomatch", + "postcss", + "rolldown", + "tinyglobby" + ], + "optionalDependencies": [ + "fsevents" + ], + "optionalPeers": [ + "@types/node" + ], + "bin": true + }, + "vitefu@1.1.3_vite@8.1.4__@types+node@26.1.1_@types+node@26.1.1": { + "integrity": "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==", + "dependencies": [ + "vite" + ], + "optionalPeers": [ + "vite" + ] + }, + "zimmerframe@1.1.4": { + "integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==" + } + }, + "workspace": { + "packageJson": { + "dependencies": [ + "npm:@sveltejs/adapter-node@^5.5.0", + "npm:@sveltejs/kit@^2.63.0", + "npm:@sveltejs/vite-plugin-svelte@^7.1.2", + "npm:@types/node@^26.1.1", + "npm:svelte-check@^4.6.0", + "npm:svelte@^5.56.1", + "npm:typescript@^6.0.3", + "npm:vite@^8.0.16" + ] + } + } +} diff --git a/migrations/001_init.sql b/migrations/001_init.sql new file mode 100644 index 0000000..8b1e674 --- /dev/null +++ b/migrations/001_init.sql @@ -0,0 +1,127 @@ +-- Quantum initial schema. +-- App-generated timestamps are ISO-8601 UTC strings; SimpleFIN-native +-- timestamps (posted, transacted_at) are Unix epoch seconds as provided. +-- All monetary values are integer cents. + +CREATE TABLE users ( + did TEXT PRIMARY KEY, + handle TEXT NOT NULL, + created_at TEXT NOT NULL, + last_login_at TEXT +); + +CREATE TABLE sessions ( + token TEXT PRIMARY KEY, + user_did TEXT NOT NULL REFERENCES users (did), + created_at TEXT NOT NULL, + expires_at TEXT NOT NULL +); +CREATE INDEX idx_sessions_expires ON sessions (expires_at); + +-- Key/value stores backing @atproto/oauth-client-node. +CREATE TABLE oauth_state ( + key TEXT PRIMARY KEY, + data TEXT NOT NULL, + created_at TEXT NOT NULL +); +CREATE TABLE oauth_session ( + key TEXT PRIMARY KEY, + data TEXT NOT NULL, + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL +); + +CREATE TABLE connections ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + access_url TEXT NOT NULL, + claimed_at TEXT NOT NULL +); + +CREATE TABLE accounts ( + id TEXT PRIMARY KEY, -- SimpleFIN account id + connection_id INTEGER NOT NULL REFERENCES connections (id), + org_name TEXT, + org_domain TEXT, + org_sfin_url TEXT, + name TEXT NOT NULL, + currency TEXT NOT NULL, + state TEXT NOT NULL DEFAULT 'NEW' + CHECK (state IN ('NEW', 'ACTIVE', 'INACTIVE', 'HIDDEN')), + account_type TEXT + CHECK (account_type IN ('checking', 'savings', 'credit', 'investment', 'loan', 'other')), + display_name TEXT, + last_successful_data_at TEXT, + created_at TEXT NOT NULL +); + +CREATE TABLE categories ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL UNIQUE, + kind TEXT NOT NULL CHECK (kind IN ('income', 'expense', 'transfer')), + builtin INTEGER NOT NULL DEFAULT 0, + active INTEGER NOT NULL DEFAULT 1, + created_at TEXT NOT NULL +); + +CREATE TABLE transactions ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + account_id TEXT NOT NULL REFERENCES accounts (id), + sfin_id TEXT NOT NULL, + posted INTEGER, -- Unix seconds; NULL while pending + transacted_at INTEGER, -- Unix seconds; as provided by SimpleFIN + amount_cents INTEGER NOT NULL, + description TEXT NOT NULL, + pending INTEGER NOT NULL DEFAULT 0, + extra TEXT, -- verbatim SimpleFIN extra JSON + category_id INTEGER REFERENCES categories (id), -- cache of latest categorization event + created_at TEXT NOT NULL, + UNIQUE (account_id, sfin_id) +); +CREATE INDEX idx_transactions_posted ON transactions (posted); +CREATE INDEX idx_transactions_category ON transactions (category_id); +CREATE INDEX idx_transactions_account ON transactions (account_id); + +CREATE TABLE balance_snapshots ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + account_id TEXT NOT NULL REFERENCES accounts (id), + captured_at TEXT NOT NULL, + balance_cents INTEGER NOT NULL, + available_balance_cents INTEGER +); +CREATE INDEX idx_snapshots_account_time ON balance_snapshots (account_id, captured_at); + +CREATE TABLE raw_syncs ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + connection_id INTEGER REFERENCES connections (id), + fetched_at TEXT NOT NULL, + ok INTEGER NOT NULL, + payload TEXT, -- verbatim response body; never mutated + error TEXT +); + +CREATE TABLE rules ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + match_type TEXT NOT NULL CHECK (match_type IN ('exact', 'contains')), + pattern TEXT NOT NULL, + category_id INTEGER NOT NULL REFERENCES categories (id), + created_by_did TEXT NOT NULL REFERENCES users (did), + active INTEGER NOT NULL DEFAULT 1, + created_at TEXT NOT NULL +); + +CREATE TABLE categorization_events ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + transaction_id INTEGER NOT NULL REFERENCES transactions (id), + category_id INTEGER REFERENCES categories (id), -- NULL clears the category + source TEXT NOT NULL CHECK (source IN ('rule', 'manual', 'reconciliation')), + rule_id INTEGER REFERENCES rules (id), + actor_did TEXT REFERENCES users (did), + created_at TEXT NOT NULL, + CHECK (source != 'rule' OR rule_id IS NOT NULL), + CHECK (source != 'manual' OR actor_did IS NOT NULL) +); +CREATE INDEX idx_catevents_transaction ON categorization_events (transaction_id); + +-- Built-in, non-deletable Transfer category (see specs/categorization). +INSERT INTO categories (name, kind, builtin, created_at) +VALUES ('Transfer', 'transfer', 1, strftime('%Y-%m-%dT%H:%M:%fZ', 'now')); diff --git a/openspec/changes/bootstrap-finance-app/tasks.md b/openspec/changes/bootstrap-finance-app/tasks.md index 7f952d9..08c694e 100644 --- a/openspec/changes/bootstrap-finance-app/tasks.md +++ b/openspec/changes/bootstrap-finance-app/tasks.md @@ -1,10 +1,10 @@ ## 1. Foundation -- [ ] 1.1 Scaffold SvelteKit project running under Deno 2.9 (deno.json tasks for dev/build/start, adapter choice per design D1) with a health-check route -- [ ] 1.2 Implement SQLite bootstrap via `node:sqlite`: open `DB_PATH`, enable WAL, numbered-migration runner with `schema_version` table applied at startup -- [ ] 1.3 Write migration 001: users, sessions, oauth state/session stores, connections, accounts, transactions, balance_snapshots, raw_syncs, categories (seed built-in Transfer), rules, categorization_events -- [ ] 1.4 Add config module reading and validating `APP_URL`, `ALLOWED_DIDS`, `DB_PATH`, and OAuth signing key; fail fast with clear errors on missing config -- [ ] 1.5 Establish the service-layer convention (design D6): domain operations as transport-agnostic modules under `src/lib/server/`, SvelteKit loads/actions as thin adapters only — no SQL or domain logic in routes +- [x] 1.1 Scaffold SvelteKit project running under Deno 2.9 (deno.json tasks for dev/build/start, adapter choice per design D1) with a health-check route +- [x] 1.2 Implement SQLite bootstrap via `node:sqlite`: open `DB_PATH`, enable WAL, numbered-migration runner with `schema_version` table applied at startup +- [x] 1.3 Write migration 001: users, sessions, oauth state/session stores, connections, accounts, transactions, balance_snapshots, raw_syncs, categories (seed built-in Transfer), rules, categorization_events +- [x] 1.4 Add config module reading and validating `APP_URL`, `ALLOWED_DIDS`, `DB_PATH`, and OAuth signing key; fail fast with clear errors on missing config +- [x] 1.5 Establish the service-layer convention (design D6): domain operations as transport-agnostic modules under `src/lib/server/`, SvelteKit loads/actions as thin adapters only — no SQL or domain logic in routes ## 2. Authentication (specs/auth) diff --git a/package.json b/package.json new file mode 100644 index 0000000..7bb9a1c --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "quantum", + "private": true, + "version": "0.0.1", + "type": "module", + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview", + "prepare": "svelte-kit sync || echo ''", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" + }, + "devDependencies": { + "@sveltejs/adapter-node": "^5.5.0", + "@sveltejs/kit": "^2.63.0", + "@sveltejs/vite-plugin-svelte": "^7.1.2", + "@types/node": "^26.1.1", + "svelte": "^5.56.1", + "svelte-check": "^4.6.0", + "typescript": "^6.0.3", + "vite": "^8.0.16" + } +} diff --git a/scripts/generate-oauth-key.ts b/scripts/generate-oauth-key.ts new file mode 100644 index 0000000..90ad367 --- /dev/null +++ b/scripts/generate-oauth-key.ts @@ -0,0 +1,14 @@ +/// +// Generates the ES256 private key used for ATProto OAuth client authentication. +// Usage: deno task generate-key +// Put the output in your environment as OAUTH_PRIVATE_KEY_JWK (single line). + +const keyPair = await crypto.subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, [ + 'sign', + 'verify' +]); + +const jwk = await crypto.subtle.exportKey('jwk', keyPair.privateKey); +jwk.kid = crypto.randomUUID(); + +console.log(JSON.stringify(jwk)); diff --git a/src/app.d.ts b/src/app.d.ts new file mode 100644 index 0000000..da08e6d --- /dev/null +++ b/src/app.d.ts @@ -0,0 +1,13 @@ +// See https://svelte.dev/docs/kit/types#app.d.ts +// for information about these interfaces +declare global { + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface PageState {} + // interface Platform {} + } +} + +export {}; diff --git a/src/app.html b/src/app.html new file mode 100644 index 0000000..6a2bb58 --- /dev/null +++ b/src/app.html @@ -0,0 +1,12 @@ + + + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/src/hooks.server.ts b/src/hooks.server.ts new file mode 100644 index 0000000..614e89c --- /dev/null +++ b/src/hooks.server.ts @@ -0,0 +1,10 @@ +import { building } from '$app/environment'; +import { getConfig } from '$lib/server/config'; +import { initDb } from '$lib/server/db'; +import type { ServerInit } from '@sveltejs/kit'; + +export const init: ServerInit = () => { + if (building) return; + const config = getConfig(); // fails fast with a clear error on missing/invalid env + initDb(config.dbPath, 'migrations'); +}; diff --git a/src/lib/assets/favicon.svg b/src/lib/assets/favicon.svg new file mode 100644 index 0000000..cc5dc66 --- /dev/null +++ b/src/lib/assets/favicon.svg @@ -0,0 +1 @@ +svelte-logo \ No newline at end of file diff --git a/src/lib/index.ts b/src/lib/index.ts new file mode 100644 index 0000000..856f2b6 --- /dev/null +++ b/src/lib/index.ts @@ -0,0 +1 @@ +// place files you want to import through the `$lib` alias in this folder. diff --git a/src/lib/server/README.md b/src/lib/server/README.md new file mode 100644 index 0000000..ce7dbf3 --- /dev/null +++ b/src/lib/server/README.md @@ -0,0 +1,22 @@ +# Server core conventions (design D6: transport-agnostic core) + +A future native frontend (Deno desktop, mobile) must be able to target a +standalone Quantum backend. To keep that cheap, the server core follows these +rules: + +1. **Domain logic lives in `services/`.** Every domain operation (ledger + queries, categorization, rules, reports, sync, account classification) is a + plain function in `src/lib/server/services/` taking typed inputs and + returning plain data. No `Request`/`Response`, no cookies, no SvelteKit + imports. +2. **Routes are thin adapters.** `+page.server.ts` loads and form actions only + parse input, call a service, and shape the response. No SQL and no domain + logic in routes. When native clients arrive, `/api/*` JSON routes become a + second adapter over the same services. +3. **No SQL outside `services/` and `db.ts`.** +4. **Relative imports within `src/lib/server/`** (not `$lib/...`) so modules + and their tests run under plain `deno test` without Vite alias resolution. +5. **Sessions are opaque tokens.** Delivered via HTTP-only cookie today; + the token format must never assume cookie transport (bearer support later). +6. **Money is integer cents.** Conversion from SimpleFIN's numeric strings + happens exactly once, at normalization. Floats never touch amounts. diff --git a/src/lib/server/config.test.ts b/src/lib/server/config.test.ts new file mode 100644 index 0000000..b4e69aa --- /dev/null +++ b/src/lib/server/config.test.ts @@ -0,0 +1,59 @@ +/// +import { loadConfig } from './config.ts'; + +const VALID_JWK = JSON.stringify({ + kty: 'EC', + crv: 'P-256', + d: 'x', + x: 'x', + y: 'y', + kid: 'test-key' +}); + +const VALID_ENV = { + APP_URL: 'https://quantum.example.com', + ALLOWED_DIDS: 'did:plc:aaa, did:plc:bbb', + DB_PATH: './data/test.db', + OAUTH_PRIVATE_KEY_JWK: VALID_JWK +}; + +Deno.test('valid env parses', () => { + const config = loadConfig(VALID_ENV); + if (config.appUrl !== 'https://quantum.example.com') throw new Error('appUrl mismatch'); + if (config.allowedDids.length !== 2 || config.allowedDids[1] !== 'did:plc:bbb') { + throw new Error(`allowedDids mismatch: ${config.allowedDids}`); + } +}); + +Deno.test('missing env reports every problem at once', () => { + try { + loadConfig({}); + throw new Error('expected loadConfig to throw'); + } catch (err) { + const msg = err instanceof Error ? err.message : String(err); + for (const name of ['APP_URL', 'ALLOWED_DIDS', 'DB_PATH', 'OAUTH_PRIVATE_KEY_JWK']) { + if (!msg.includes(name)) throw new Error(`error message missing ${name}: ${msg}`); + } + } +}); + +Deno.test('http APP_URL rejected unless localhost', () => { + let threw = false; + try { + loadConfig({ ...VALID_ENV, APP_URL: 'http://quantum.example.com' }); + } catch { + threw = true; + } + if (!threw) throw new Error('expected http APP_URL to be rejected'); + loadConfig({ ...VALID_ENV, APP_URL: 'http://localhost:5173' }); // must not throw +}); + +Deno.test('non-DID allowlist entry rejected', () => { + let threw = false; + try { + loadConfig({ ...VALID_ENV, ALLOWED_DIDS: 'did:plc:aaa,alice.example.com' }); + } catch { + threw = true; + } + if (!threw) throw new Error('expected non-DID entry to be rejected'); +}); diff --git a/src/lib/server/config.ts b/src/lib/server/config.ts new file mode 100644 index 0000000..41a2555 --- /dev/null +++ b/src/lib/server/config.ts @@ -0,0 +1,79 @@ +import process from 'node:process'; + +export interface Config { + /** Public HTTPS origin, no trailing slash. Drives OAuth client_id, redirect URI, JWKS URL. */ + appUrl: string; + /** DIDs permitted to use this instance. */ + allowedDids: string[]; + /** Path to the SQLite database file. */ + dbPath: string; + /** ES256 private key (JWK with kid) used for OAuth client authentication. */ + oauthPrivateKeyJwk: Record; +} + +export function loadConfig(env: Record = process.env): Config { + const problems: string[] = []; + + const appUrlRaw = env.APP_URL?.trim(); + let appUrl = ''; + if (!appUrlRaw) { + problems.push('APP_URL is required (public origin, e.g. https://quantum.example.com)'); + } else { + try { + const parsed = new URL(appUrlRaw); + if (parsed.protocol !== 'https:' && parsed.hostname !== 'localhost') { + problems.push(`APP_URL must be https (got ${parsed.protocol}//) unless localhost`); + } + appUrl = parsed.origin; + } catch { + problems.push(`APP_URL is not a valid URL: ${appUrlRaw}`); + } + } + + const allowedDids = (env.ALLOWED_DIDS ?? '') + .split(',') + .map((d) => d.trim()) + .filter((d) => d.length > 0); + if (allowedDids.length === 0) { + problems.push('ALLOWED_DIDS is required (comma-separated DIDs, e.g. did:plc:abc,did:plc:def)'); + } else { + for (const did of allowedDids) { + if (!did.startsWith('did:')) problems.push(`ALLOWED_DIDS entry is not a DID: ${did}`); + } + } + + const dbPath = env.DB_PATH?.trim(); + if (!dbPath) problems.push('DB_PATH is required (path to the SQLite database file)'); + + let oauthPrivateKeyJwk: Record = {}; + const jwkRaw = env.OAUTH_PRIVATE_KEY_JWK?.trim(); + if (!jwkRaw) { + problems.push( + 'OAUTH_PRIVATE_KEY_JWK is required (ES256 private JWK; generate with `deno task generate-key`)' + ); + } else { + try { + oauthPrivateKeyJwk = JSON.parse(jwkRaw); + if (oauthPrivateKeyJwk.kty !== 'EC' || oauthPrivateKeyJwk.crv !== 'P-256') { + problems.push('OAUTH_PRIVATE_KEY_JWK must be an EC P-256 (ES256) key'); + } + if (!oauthPrivateKeyJwk.d) problems.push('OAUTH_PRIVATE_KEY_JWK must be a private key'); + if (!oauthPrivateKeyJwk.kid) problems.push('OAUTH_PRIVATE_KEY_JWK must include a kid'); + } catch { + problems.push('OAUTH_PRIVATE_KEY_JWK is not valid JSON'); + } + } + + if (problems.length > 0) { + throw new Error(`Invalid configuration:\n - ${problems.join('\n - ')}`); + } + + return { appUrl, allowedDids, dbPath: dbPath!, oauthPrivateKeyJwk }; +} + +let cached: Config | null = null; + +export function getConfig(): Config { + cached ??= loadConfig(); + return cached; +} diff --git a/src/lib/server/db.test.ts b/src/lib/server/db.test.ts new file mode 100644 index 0000000..2e6376d --- /dev/null +++ b/src/lib/server/db.test.ts @@ -0,0 +1,52 @@ +/// +import { openDatabase, runMigrations } from './db.ts'; + +const MIGRATIONS_DIR = new URL('../../../migrations', import.meta.url).pathname.replace( + /^\/([A-Za-z]:)/, + '$1' +); + +Deno.test('migrations apply once and are idempotent across runs', () => { + const dbPath = join(Deno.makeTempDirSync(), 'test.db'); + const db = openDatabase(dbPath, MIGRATIONS_DIR); + + const versions = db.prepare('SELECT version, name FROM schema_version ORDER BY version').all(); + if (versions.length === 0) throw new Error('no migrations applied'); + + // second run applies nothing + const applied = runMigrations(db, MIGRATIONS_DIR); + if (applied !== 0) throw new Error(`expected 0 re-applied migrations, got ${applied}`); + db.close(); +}); + +Deno.test('built-in Transfer category is seeded', () => { + const dbPath = join(Deno.makeTempDirSync(), 'test.db'); + const db = openDatabase(dbPath, MIGRATIONS_DIR); + const row = db + .prepare('SELECT name, kind, builtin FROM categories WHERE name = ?') + .get('Transfer') as { name: string; kind: string; builtin: number } | undefined; + if (!row || row.kind !== 'transfer' || row.builtin !== 1) { + throw new Error(`Transfer category missing or wrong: ${JSON.stringify(row)}`); + } + db.close(); +}); + +Deno.test('foreign keys are enforced', () => { + const dbPath = join(Deno.makeTempDirSync(), 'test.db'); + const db = openDatabase(dbPath, MIGRATIONS_DIR); + let threw = false; + try { + db.prepare( + `INSERT INTO transactions (account_id, sfin_id, amount_cents, description, created_at) + VALUES ('nonexistent', 't1', 100, 'x', ?)` + ).run(new Date().toISOString()); + } catch { + threw = true; + } + if (!threw) throw new Error('expected FK violation'); + db.close(); +}); + +function join(...parts: string[]) { + return parts.join('/'); +} diff --git a/src/lib/server/db.ts b/src/lib/server/db.ts new file mode 100644 index 0000000..7417ea5 --- /dev/null +++ b/src/lib/server/db.ts @@ -0,0 +1,70 @@ +import { DatabaseSync } from 'node:sqlite'; +import { mkdirSync, readFileSync, readdirSync } from 'node:fs'; +import { dirname, join } from 'node:path'; + +const MIGRATION_FILE = /^(\d+)_.*\.sql$/; + +let instance: DatabaseSync | null = null; + +/** Process-wide database handle, initialized once at server startup. */ +export function initDb(dbPath: string, migrationsDir: string): DatabaseSync { + instance ??= openDatabase(dbPath, migrationsDir); + return instance; +} + +export function getDb(): DatabaseSync { + if (!instance) throw new Error('Database not initialized — initDb() runs at server startup'); + return instance; +} + +export function openDatabase(dbPath: string, migrationsDir: string): DatabaseSync { + if (dbPath !== ':memory:') mkdirSync(dirname(dbPath), { recursive: true }); + const db = new DatabaseSync(dbPath); + db.exec('PRAGMA journal_mode = WAL'); + db.exec('PRAGMA foreign_keys = ON'); + runMigrations(db, migrationsDir); + return db; +} + +export function runMigrations(db: DatabaseSync, migrationsDir: string): number { + db.exec(`CREATE TABLE IF NOT EXISTS schema_version ( + version INTEGER PRIMARY KEY, + name TEXT NOT NULL, + applied_at TEXT NOT NULL + )`); + + const applied = new Set( + (db.prepare('SELECT version FROM schema_version').all() as { version: number }[]).map( + (r) => r.version + ) + ); + + const migrations = readdirSync(migrationsDir) + .map((file) => { + const match = file.match(MIGRATION_FILE); + return match ? { version: Number(match[1]), file } : null; + }) + .filter((m) => m !== null) + .sort((a, b) => a.version - b.version); + + let count = 0; + for (const { version, file } of migrations) { + if (applied.has(version)) continue; + const sql = readFileSync(join(migrationsDir, file), 'utf-8'); + db.exec('BEGIN'); + try { + db.exec(sql); + db.prepare('INSERT INTO schema_version (version, name, applied_at) VALUES (?, ?, ?)').run( + version, + file, + new Date().toISOString() + ); + db.exec('COMMIT'); + } catch (err) { + db.exec('ROLLBACK'); + throw new Error(`Migration ${file} failed: ${err instanceof Error ? err.message : err}`); + } + count++; + } + return count; +} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte new file mode 100644 index 0000000..9cebde5 --- /dev/null +++ b/src/routes/+layout.svelte @@ -0,0 +1,11 @@ + + + + + + +{@render children()} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte new file mode 100644 index 0000000..cc88df0 --- /dev/null +++ b/src/routes/+page.svelte @@ -0,0 +1,2 @@ +

Welcome to SvelteKit

+

Visit svelte.dev/docs/kit to read the documentation

diff --git a/src/routes/healthz/+server.ts b/src/routes/healthz/+server.ts new file mode 100644 index 0000000..60261a6 --- /dev/null +++ b/src/routes/healthz/+server.ts @@ -0,0 +1,5 @@ +import { json } from '@sveltejs/kit'; + +export function GET() { + return json({ ok: true }); +} diff --git a/static/robots.txt b/static/robots.txt new file mode 100644 index 0000000..b6dd667 --- /dev/null +++ b/static/robots.txt @@ -0,0 +1,3 @@ +# allow crawling everything by default +User-agent: * +Disallow: diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a201a2c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "rewriteRelativeImportExtensions": true, + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler" + }, + // *.test.ts files run (and are type-checked) under `deno test` with Deno globals; + // they are excluded here so svelte-check only covers app code. + "exclude": ["node_modules/**", "src/**/*.test.ts"] + // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias + // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files + // + // To make changes to top-level options such as include and exclude, we recommend extending + // the generated config; see https://svelte.dev/docs/kit/configuration#typescript +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..b213906 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,18 @@ +import adapter from '@sveltejs/adapter-node'; +import { sveltekit } from '@sveltejs/kit/vite'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [ + sveltekit({ + compilerOptions: { + // Force runes mode for the project, except for libraries. Can be removed in svelte 6. + runes: ({ filename }) => + filename.split(/[/\\]/).includes('node_modules') ? undefined : true + }, + + // adapter-node output runs under Deno in production (deno task start) + adapter: adapter() + }) + ] +}); -- 2.51.2