fix(core): Refactor smartrequest usage, update dependency versions, and improve documentation and tests

This commit is contained in:
2025-08-08 12:17:25 +00:00
parent b6c13cc44d
commit 88e377c425
10 changed files with 5263 additions and 1393 deletions

View File

@@ -0,0 +1,39 @@
# SmartRequest API Update - January 2025
## Context
The @push.rocks/smartrequest package (v4.2.1) uses a new chainable API that replaced the old function-based API.
## Changes Made
### Old API (v2.x)
```typescript
const response = await plugins.smartrequest.request(url, {
headers: this.headers,
method: 'GET',
queryParams: { key: value }
});
const data = response.body;
```
### New API (v4.x)
```typescript
const requestBuilder = plugins.smartrequest.SmartRequest.create()
.url(url)
.headers(this.headers)
.query({ key: value });
const response = await requestBuilder.get();
const data = await response.json();
```
## Key Differences
1. **Request Creation**: Use `SmartRequest.create()` instead of direct function call
2. **Chainable Methods**: Configure requests with `.url()`, `.headers()`, `.query()`
3. **HTTP Methods**: Use `.get()`, `.post()`, `.delete()` etc. instead of method parameter
4. **Response Parsing**: Call `.json()` on response to get parsed data (was `.body` before)
## Files Updated
- `ts/classes.giteaassets.ts` - Updated the `getFiles()` method to use new API
## Testing
All tests pass successfully, including the GiteaAssets tests that fetch real data from code.foss.global.