refactor: domain-scoped src/ folder structure#7
Merged
Conversation
Split server.ts (458 LOC) into thin orchestrator (~130 LOC) + domain modules: - src/tools/ — register.ts (tool registration + hooks), helpers.ts (query/mutation/action), types.ts - src/resources/ — register.ts (resource registration), helpers.ts (resource wrapper), types.ts - src/pagination/ — handlers.ts (handler overrides), cursor.ts (HMAC), context.ts (config), types.ts - src/types.ts — shared types only (ConvexValidator, ConvexClient, AuthConfig, ServerConfig) - src/auth.ts, src/validators.ts — unchanged (standalone) Zero public API changes. 103 tests pass. DTS output identical (4.90 KB).
- Replace inline import() in ServerConfig with re-exported type names - Restore assertCanSetRequestHandler explanation comment - Make PreparedTool/PreparedResource non-exported (internal only)
- Add direct decodeCursor tests for version/method/offset validation branches - Remove unused tool list cache (per-request server creation means cache never hits) - Restore branch threshold to 100% (was 98%) - 108 tests, 100% on all coverage metrics
…asts
- validators.ts: type guards for literal values, record validators, tuple construction
- cursor.ts: isCursorPayload runtime validator replaces as CursorPayload cast
- register.ts: typed callback params, guard-proven narrowing for hook phases
- resources/register.ts: typed params removes as Record cast
- 113 tests, 100% coverage on all metrics
Remaining as assertions (3, all guard-proven or unfixable):
- cursor.ts: as Record<string, unknown> inside type guard (TS limitation)
- handlers.ts: as unknown as { _requestHandlers } (SDK private API, unfixable)
- register.ts: ctx as CallContext & { phase: "error" } (if-guarded narrowing)
- CLAUDE.md/AGENTS.md: domain-scoped architecture, 113 tests, 100% coverage - CHANGELOG.md: add refactor + type safety notes to v0.2.0 entry - docs/api-reference.md: version 0.2.0, PaginationConfig section, pagination docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/(8 files, server.ts at 458 LOC) into domain-scoped folderssrc/tools/— registration, hooks, helpers (query/mutation/action)src/resources/— registration, helpers (resource)src/pagination/— cursor HMAC, handler overrides, config validationsrc/server.tsreduced from 458 to ~130 LOC (thin orchestrator)Structure
Test plan