- Added download() method to get statements as Buffer without saving to disk - Added downloadAsArrayBuffer() method for web API compatibility - Enhanced documentation for getAccountStatement() method - Updated README with comprehensive examples - No breaking changes, backward compatible
1.8 KiB
1.8 KiB
Migration Plan: @push.rocks/smartrequest
To re-read CLAUDE.md: cat ~/.claude/CLAUDE.md
Objective
Migrate the Bunq HTTP client from native fetch
to @push.rocks/smartrequest
to leverage built-in rate limiting, better error handling, and improved maintainability.
Tasks
1. Setup
- Install @push.rocks/smartrequest dependency using pnpm
- Update ts/bunq.plugins.ts to import smartrequest
2. Refactor BunqHttpClient
- Replace fetch-based makeRequest method with SmartRequest implementation
- Preserve all custom headers (X-Bunq-*)
- Maintain request signing functionality
- Keep response signature verification
- Map LIST method to GET (SmartRequest doesn't have LIST)
- Replace manual retry logic with built-in handle429Backoff()
3. Error Handling
- Ensure BunqApiError is still thrown for API errors
- Map SmartRequest errors to appropriate error messages
- Preserve error message format for backward compatibility
4. Testing
- Run existing tests to ensure no regression (tests passing)
- Verify rate limiting behavior works correctly
- Test signature creation and verification
- Ensure all HTTP methods (GET, POST, PUT, DELETE, LIST) work
5. Cleanup
- Remove unused code from the old implementation (manual retry logic removed)
- Update any relevant documentation or comments
Implementation Notes
Key Changes
- Replace native fetch with SmartRequest fluent API
- Use built-in handle429Backoff() instead of manual retry logic
- Leverage SmartRequest's response methods (.json(), .text())
- Maintain all Bunq-specific behavior (signatures, custom headers)
Risk Mitigation
- All Bunq-specific logic remains unchanged
- Public API of BunqHttpClient stays the same
- Error handling maintains same format