Commit Graph
728 Commits
Author SHA1 Message Date
Lucas Berger dd02207318 feat(01-03): implement broker client, syncCalendar, and events route (CAL-01)
- client.ts: createFastmailClient(email, appPassword) → tsdav DAVClient via Basic auth
- sync.ts: syncCalendar upserts calendar row, selects ID, fetches+parses VEVENTs with ical.js
  - all-day DATE → dtstartDate (Date obj at T00:00:00Z), dtstartUtc=null, allDay=true
  - timed → dtstartUtc (JS Date), dtstartDate=null, allDay=false (D-13/Pitfall #3)
  - onDuplicateKeyUpdate on calendarId+uid composite key (idempotent)
- routes/events.ts: GET /api/events reads cache only — no tsdav import (T-03-02)
- tsc --noEmit clean; all 6 sync tests pass
2026-06-04 10:33:28 -04:00
Lucas Berger 90b99296e8 test(01-03): refine sync RED tests with richer db mock (select + insert)
- Use separate mock functions for insert/select chain to enable per-test assertions
- Reset mock implementations in beforeEach after vi.clearAllMocks
- Mock returns {id:42} from select (calendar ID for event upsert)
2026-06-04 10:30:53 -04:00
Lucas Berger ae21541e97 test(01-03): add failing tests for syncCalendar (D-13 all-day DATE handling)
- 6 tests: all-day DATE vs timed TIMESTAMP, allDay flag, upsert on dup UID, rawVevent blob, ctag update
- Mocks db singleton at module level with vi.mock hoisting pattern
- Uses SAMPLE_VEVENT_TIMED/ALLDAY fixtures from tests/helpers/db.ts
- RED gate: all fail (src/broker/sync.ts does not exist yet)
2026-06-04 10:29:29 -04:00
Lucas Berger d6d91201b1 feat(01-03): implement AES-256-GCM app-password encryption (T-03-01)
- encryptPassword: randomBytes(12) IV, aes-256-gcm, returns JSON {iv,authTag,ciphertext}
- decryptPassword: verifies GCM auth tag; throws on tamper
- Key from APP_PASSWORD_ENCRYPTION_KEY env (64-char hex); validated on each call
- No logging of plaintext or key
2026-06-04 10:27:40 -04:00
Lucas Berger 04d7c23e94 test(01-03): add failing tests for AES-256-GCM crypto helpers
- 5 tests covering roundtrip, IV uniqueness, tamper detection, payload shape
- Dynamic import with env key set in beforeAll for module-level KEY eval
- RED gate: all fail (src/broker/crypto.ts does not exist yet)
2026-06-04 10:26:59 -04:00
Lucas Berger 3bfffd60ae docs(01-02): complete OIDC auth slice plan summary 2026-06-04 10:24:18 -04:00
Lucas Berger 668ed9be0d feat(01-02): wire OIDC middleware, /api/me route, and authenticated PWA shell
- src/auth/middleware.ts: re-exports oidcAuthMiddleware, processOAuthCallback,
  getAuth from @hono/oidc-auth; documents required env vars and AUTH-02
  refresh-token rotation (no iframe, D-12)
- src/routes/me.ts: GET / calls getAuth → upsertUser(iss, sub, email) →
  returns { user: { id, displayName, color } }; identity keyed on iss+sub
- src/index.ts: /callback registered before oidcAuthMiddleware; /api/*
  guarded; /health remains unauthenticated; /api/me mounted
- apps/pwa/src/api/client.ts: typed fetchMe() with credentials: 'include'
- apps/pwa/src/App.tsx: useQuery(['me'], fetchMe); renders member name and
  color swatch; retains /health stack indicator from Plan 01
- tsc --noEmit: clean; all tests pass
2026-06-04 10:22:46 -04:00
Lucas Berger baabfce9e2 feat(01-02): implement upsertUser with stable color assignment (AUTH-03)
- Export COLOR_PALETTE (6 accessible hex hues, round-robin assignment)
- upsertUser(oidcIss, oidcSub, displayName?) keyed on iss+sub never email
- First login: COUNT existing users → assign COLOR_PALETTE[count % len]
- Re-upsert: returns existing row unchanged (idempotent, no duplicate insert)
- Uses $returningId() + re-select pattern (mysql2 no RETURNING clause)
- All 6 tests pass (GREEN)
2026-06-04 10:21:04 -04:00
Lucas Berger 61c258c021 test(01-02): add failing tests for upsertUser color assignment + identity
- Replace it.todo stubs with real failing tests (RED gate)
- Tests cover palette[0] first user, palette[1] second user, idempotent
  re-upsert, iss+sub identity key, full row shape
- Tests fail: src/auth/user.ts does not exist yet
2026-06-04 10:20:27 -04:00
Lucas Berger ee4c71fa46 docs(01-01): clear Task 3 checkpoint, mark plan complete
Stack verified live (/health green, 4 tables pushed). Record Docker deviation in
SUMMARY, mark 01-01 complete in ROADMAP, clean up paused-setup handoff files.
2026-06-04 10:17:21 -04:00
Lucas Berger 00efbab107 fix(01-01): build Docker image from repo-root pnpm workspace context
The walking-skeleton Dockerfile built from a ./apps/api context and could not
work in a pnpm workspace: the lockfile lives at the repo root, pnpm 11 refused
esbuild's build script without the root pnpm-workspace.yaml, the dev stage never
compiled src->dist, and the production stage had invalid COPY syntax referencing
a path outside its context.

Switch to the correct monorepo pattern: build from the repo-root context, copy
the workspace manifest + lockfile + both package.jsons, and install with
--frozen-lockfile --filter @familysync/api...  Reorder stages so production is
default; dev reuses builder output. Fix the dev volume mount path.

Surfaced while clearing the Task 3 checkpoint (stack bring-up): drizzle-kit push
applied the 4 tables and /health returned {ok:true,db:up} end-to-end.
2026-06-04 10:17:06 -04:00
Lucas Berger 6b500170ab docs(01-01): complete walking skeleton plan — SUMMARY
Tasks 1-2 done: monorepo scaffold, Drizzle schema, /health slice.
Stopped at Task 3 checkpoint (drizzle-kit push requires live Docker stack).
2026-06-04 09:54:10 -04:00
Lucas Berger 96cda58509 feat(01-01): Drizzle schema + DB client + /health slice (GREEN)
- src/db/schema.ts: users, memberCredentials, calendars, calendarEvents tables
  - users: composite unique on oidc_iss+oidc_sub (D-10 identity)
  - calendar_events: separate dtstart_utc (TIMESTAMP) and dtstart_date (DATE) + allDay boolean (D-13)
- src/db/client.ts: drizzle(mysql2 pool) singleton export `db`
- drizzle.config.ts: dialect mysql, schema → migrations, dbCredentials from env
- src/routes/health.ts: GET / with real SELECT 1 DB round-trip, 200 or 503
- src/index.ts: Hono app with /health mounted before auth, serveStatic for PWA
- tests/health.test.ts: 2 tests pass (mocked DB); TDD GREEN gate
- apps/pwa/src/App.tsx: React shell fetching /health via TanStack Query
2026-06-04 09:52:36 -04:00
Lucas Berger f31711af27 test(01-01): add failing health test (RED gate)
- Tests GET /health returns 200 { ok, db } on success and 503 on DB error
- Fails because src/index.ts and src/routes/health.ts don't exist yet
2026-06-04 09:50:43 -04:00
Lucas Berger 3f591566d1 chore(01-01): scaffold monorepo, Docker Compose stack, and Vitest harness
- pnpm workspace with apps/api (Hono/Drizzle) and apps/pwa (Vite/React 19)
- Pinned versions per RESEARCH: hono@4.12.23, drizzle-orm@0.45.2, mysql2@3.22.4, tsdav@2.2.2, ical.js@2.2.1, zod@^3.25.0, node-cron@^4.2.1
- docker-compose.yml with mariadb:11 healthcheck, api depends_on service_healthy, redis stub
- docker-compose.dev.yml overrides for local dev (bind mounts, exposed ports)
- .env.example lists all env vars (DB_*, OIDC_*, APP_PASSWORD_ENCRYPTION_KEY)
- .gitignore excludes .env (never commit secrets)
- apps/api/vitest.config.ts with environment: node
- Wave 0 test stubs: health, auth/user, broker/crypto, broker/sync, broker/poller
2026-06-04 09:50:16 -04:00
Lucas Berger fb849605b1 docs(01): mark research open questions deferred-to-spike 2026-06-04 08:19:12 -04:00
Lucas Berger 3c51e423ff docs(01-foundation-broker-spike): create phase plan (4 plans, 3 waves) + SKELETON + validation map 2026-06-04 08:16:48 -04:00
Lucas Berger 25460c9bd9 docs(01): add research + validation strategy 2026-06-04 08:06:51 -04:00
Lucas BergerandClaude Sonnet 4.6 ac41270fa1 docs(01): research phase 1 foundation + broker spike
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 08:05:44 -04:00
Lucas Berger d70a159dd0 docs(state): record phase 1 context session 2026-06-04 07:55:08 -04:00
Lucas Berger d6a8e99578 docs(01): capture phase context 2026-06-04 07:55:02 -04:00
Lucas Berger 31c78965a7 wip: project setup paused pre-Phase-1 (0/5 phases) 2026-06-03 16:35:19 -04:00
Lucas Berger ac82d32a36 docs: create roadmap (5 phases) 2026-06-03 16:15:27 -04:00
Lucas Berger a20afd472a docs: define v1 requirements 2026-06-03 16:05:16 -04:00
Lucas Berger 0f79277942 docs: complete project research (stack, features, architecture, pitfalls, summary) 2026-06-03 15:01:33 -04:00
Lucas Berger 1ce0348914 chore: add project config 2026-06-03 14:48:13 -04:00
Lucas Berger ad2aad83a8 docs: initialize project 2026-06-03 14:45:59 -04:00
Lucas Berger 16db88dabf initial commit 2026-06-03 14:34:58 -04:00