mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-28 00:35:28 +00:00
Rewrite the account layer using Effect for typed error handling, schema validation, and structured concurrency. Split into three concerns: - schema.ts: branded types (AccountID, OrgID, AccessToken) and shared data classes - repo.ts: AccountRepo service owning all DB operations via drizzle - service.ts: AccountService owning HTTP orchestration (OAuth device flow, token refresh, org/config fetching) with AccountRepo as a dependency Key improvements: - Branded types enforce type safety at API boundaries - Option used consistently instead of null/undefined in internal APIs - User and orgs fetches parallelized during login poll - Schema-validated HTTP request/response bodies - Transient read retry with exponential backoff - Clock.currentTimeMillis instead of Date.now() for testability - 11 new repo tests covering all DB operations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3.2 KiB
3.2 KiB