Files
KomediruzeckiandGitHub 3685f23910 feat(settings): add target profile selection to danger zone and modernize ui (#360)
* feat(settings): profile-scoped danger zone actions and filtered household exports

- Add target profile selection to Settings Danger Zone with full UX validation
- Restrict default profile deletion and single remaining profile deletion
- Filter data exports dynamically by active selected household profile IDs
- Implement correct CSV format exports for categories, budgets, accounts, loans, and recurring
- Reorganize Settings tabs: move exports into Household card, Danger Zone to General tab
- Configure Cloudflare PR preview deployments with automatic PR comment links
- Resolve parallel E2E database mutations and flaky test race conditions

* fix(settings): make Danger Zone profile targeting re-entrancy-safe

The profile-scoped Danger Zone actions carried the target profile in a shared
mutable field on the singleton adapter (_profileIdOverride), set from the
X-Profile-Id header and cleared in an unconditional finally. The destructive
handlers resolve the profile only AFTER `await getDB()`, so any concurrent
request (e.g. a background list refresh, which also carries a profile header)
overwrote/cleared the override mid-flight — a delete targeting a non-active
profile could fall back to and wipe the ACTIVE profile instead.

Remove the shared override and resolve the target per-request from the headers
inside each handler (targetProfileIdsFromHeaders), mirroring how export already
worked, so concurrent requests can never clobber one another's target.

- idb: drop _profileIdOverride + set/clear; deleteAllTransactions(pids?) takes an
  explicit target.
- handlers: deleteAllTransactions / deleteAllCategories / profileResetData resolve
  the target from the request header (fallback: active profile, never "all").
- router: no per-request adapter state; pass headers to the destructive routes.
- export: also accept X-Profile-Ids (JSON) so a multi-profile household export is
  not truncated to the first profile by backend/worker (which read that shape).
- Settings: send X-Profile-Ids for households; add the profile name to export
  filenames (finance-export-<profile>-<date>.json, <type>-<profile>-<date>.<fmt>).

Tests (dangerZone-profile-scoping): cross-profile isolation for delete-all-
transactions / reset-categories / clear-profile-data, a concurrency regression
that fails on the old shared-override code, and household export scoping. Full
suite green; backend + worker paths are already request-scoped (no re-entrancy).
2026-07-20 18:18:24 +02:00

37 lines
1.7 KiB
JSON

{
"$schema": "https://raw.githubusercontent.com/cloudflare/workers-sdk/main/packages/wrangler/config-schema.json",
"name": "finance-manager",
"compatibility_date": "2026-05-12",
// A tiny Worker runs in front of the assets so a MISS on a hashed asset returns a real 404
// instead of index.html (200, text/html). See server/assets-worker.ts for the full why —
// in short, the old "single-page-application" fallback turned a stale chunk after a deploy
// into a fatal "Failed to load module script: MIME type text/html" white screen.
"main": "server/assets-worker.ts",
"assets": {
"directory": "./dist",
"binding": "ASSETS",
// The Worker owns the SPA fallback (navigations → index.html); asset misses stay 404s.
"not_found_handling": "none",
},
// Two deploy environments (assets + compatibility_date above are inherited by both).
// pnpm run deploy:dev -> finance-manager-dev on dev.tokencircles.com (built with --mode dev)
// pnpm run deploy:prod -> finance-manager on the apex tokencircles.com
// The app is the brand front door at the apex; the marketing site lives on
// about.tokencircles.com (packages/tokencircles in the disjoint-colliders repo).
// Point www.tokencircles.com + http -> https://tokencircles.com with a Cloudflare
// Redirect Rule (dashboard), and add a GSC Domain property for tokencircles.com.
"env": {
"dev": {
"name": "finance-manager-dev",
"routes": [{ "pattern": "dev.tokencircles.com", "custom_domain": true }],
},
"prod": {
"name": "finance-manager",
"routes": [{ "pattern": "tokencircles.com", "custom_domain": true }],
},
"preview": {
"name": "finance-manager-preview",
},
},
}