Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6.1 KiB
6.1 KiB
phase, plan, subsystem, tags, requires, provides, affects, tech-stack, key-files, key-decisions, requirements-completed, duration, completed
| phase | plan | subsystem | tags | requires | provides | affects | tech-stack | key-files | key-decisions | requirements-completed | duration | completed | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 18-auto-timezone-detection-and-ability-to-change-timezone | 02 | api |
|
|
|
|
|
|
|
|
3min | 2026-06-15 |
Phase 18 Plan 02: Admin Timezone API Endpoints Summary
Three role-gated admin endpoints (GET + PUT + seed) added to adminRouter with server-side IANA validation via isValidIanaTimezone and D-03 no-overwrite seed semantics enforced by SELECT-before-INSERT
Performance
- Duration: 3 min
- Started: 2026-06-15T02:09:38Z
- Completed: 2026-06-15T02:12:39Z
- Tasks: 2 (TDD RED + GREEN)
- Files modified: 2
Accomplishments
- Added
describe('admin timezone config')toadmin.test.tswith 8 test cases covering all boundary conditions - Implemented
GET /api/admin/config/timezone,PUT /api/admin/config/timezone, andPOST /api/admin/config/timezone/seedon the existingadminRouter - All routes inherit the line-41
requireAdminguard (Pitfall 9 / T-18-03) — no per-route auth addition needed timezoneSchemausesisValidIanaTimezonefrom Plan 18-01 in a Zod.refine()— nonoEchoHook(T-18-06)PUTusesonDuplicateKeyUpdatefor a true upsert;seeduses SELECT-then-INSERT to enforce D-03 no-overwrite- 25/25
admin.test.tstests pass; 366/366 full API suite green;tsc --noEmitclean
Task Commits
- Task 1: RED — failing integration tests -
f109b3c(test) - Task 2: GREEN — implement GET/PUT/seed timezone endpoints -
3bd6a5d(feat)
Files Created/Modified
apps/api/src/routes/admin.ts— added appConfig + householdTimezone imports, timezoneSchema, and three new route handlersapps/api/tests/routes/admin.test.ts— added appConfig import +describe('admin timezone config')with 8 test cases + per-test afterEach cleanup
Decisions Made
timezoneSchemadoes NOT usenoEchoHookbecause timezone strings are non-sensitive (not credentials/PII); standardzValidatorerror responses are safe (T-18-06 accepted disposition).GET /config/timezonedoes a direct single-row read (notgetHouseholdTimezone) so the handler can computeisExplicitlySetfromrow?.value != nullbefore deciding whether to invoke the fallback chain — usinggetHouseholdTimezonewould discard the "was it stored?" signal.POST /api/admin/config/timezone/seeduses a SELECT-then-INSERT (notonDuplicateKeyUpdate) so that D-03 no-overwrite is an explicit code branch, not an implicit race. The test asserts the stored value after a second seed attempt remains unchanged.
Deviations from Plan
None — plan executed exactly as written.
Issues Encountered
- Running
pnpm --filter @familysync/api exec vitest runrequiresDB_ROOT_PASSWORDfrom.envsourced into the shell (the global-setup provisionsfamilysync_testusing the root credential). This is the established pattern from quick 260613-ndv and documented infamilysync-dev-stack-setup.md.
Known Stubs
None — all three endpoints are fully wired to the database. No placeholder data.
Threat Flags
No new threat surface beyond the plan's threat model. All three endpoints are behind requireAdmin (T-18-03). IANA validation enforced by isValidIanaTimezone (T-18-04). No SQL injection surface — key is a hard-coded literal, value is IANA-validated, Drizzle parameterizes the insert/upsert (T-18-07).
TDD Gate Compliance
- RED gate:
f109b3c—test(18-02): add failing integration tests for admin timezone endpoints - GREEN gate:
3bd6a5d—feat(18-02): admin timezone GET/PUT/seed endpoints - REFACTOR gate: N/A (implementation was clean on first pass)
Next Phase Readiness
- Plan 18-03 (broker rewire) can import
getHouseholdTimezone(db)from../lib/householdTimezone.jsto replace the bareprocess.env.TZ ?? Intl…lookups inreminderScheduler.ts:247andoutboxWorker.ts:501,607. - Plan 18-04 (PWA settings UI) can wire to
GET /api/admin/config/timezoneandPUT /api/admin/config/timezone. The seed endpoint is also available for the Phase 12 wizard auto-detect flow.
Self-Check: PASSED
apps/api/src/routes/admin.ts— FOUND (modified)apps/api/tests/routes/admin.test.ts— FOUND (modified)- Commit
f109b3c— FOUND - Commit
3bd6a5d— FOUND
Phase: 18-auto-timezone-detection-and-ability-to-change-timezone Completed: 2026-06-15