refactor: Add types, errors, config modules and architecture documentation #4
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
This PR implements foundational improvements to the Trotsky codebase, adding new organizational modules and comprehensive architecture documentation. These changes establish a solid foundation for future development without breaking any existing functionality.
What's New
1. Type Definitions Module (
lib/types/)2. Custom Error Classes (
lib/errors/)TrotskyError- Base error class with error codes, step context, and timestampsPaginationError- Pagination-specific failuresAuthenticationError- Auth and permission failuresRateLimitError- Rate limit handling with retry informationValidationError- Input validation failures with detailed contextisTrotskyError(),fromXRPCError()3. Configuration System (
lib/config/)mergeConfig()helper4. Architecture Documentation (
docs/guide/architecture.md)Key Benefits
✅ Better Organization - Clear separation of concerns with dedicated modules
✅ Type Safety - Centralized, reusable type definitions
✅ Error Handling - Structured error classes with rich context
✅ Future-Ready - Configuration system ready for advanced features
✅ Developer Experience - Comprehensive architecture documentation
✅ No Breaking Changes - All additions are opt-in and backward compatible
Files Changed
New Modules:
lib/types/)lib/errors/)lib/config/)docs/guide/architecture.md)Total: 15 new files, 1,413 lines added
Code Examples
Using Type Definitions:
Using Error Classes:
Using Configuration (Future):
Testing
dist/Documentation
docs/guide/architecture.mdNext Steps
These foundational modules enable future improvements:
Trotsky.init()This PR establishes a stronger foundation for Trotsky's continued development while maintaining full backward compatibility.