@sudobility/ratelimit_client 0.0.46 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @sudobility/ratelimit_client
|
|
2
|
+
|
|
3
|
+
React client library for the Rate Limit API with hooks for fetching rate limit config and usage history.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @sudobility/ratelimit_client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Peer Dependencies
|
|
12
|
+
|
|
13
|
+
- `react` >= 18.0.0
|
|
14
|
+
- `@sudobility/types`
|
|
15
|
+
- `@sudobility/di`
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { RateLimitClient, useRateLimits } from '@sudobility/ratelimit_client';
|
|
21
|
+
|
|
22
|
+
// Direct client usage
|
|
23
|
+
const client = new RateLimitClient({ baseUrl, networkClient });
|
|
24
|
+
const config = await client.getRateLimitsConfig(token, rateLimitUserId);
|
|
25
|
+
const history = await client.getRateLimitHistory('hour', token, rateLimitUserId);
|
|
26
|
+
|
|
27
|
+
// React hook usage
|
|
28
|
+
const { config, isLoadingConfig, history, refreshConfig, refreshHistory, error } =
|
|
29
|
+
useRateLimits(networkClient, baseUrl);
|
|
30
|
+
|
|
31
|
+
await refreshConfig(token, rateLimitUserId);
|
|
32
|
+
await refreshHistory('day', token, rateLimitUserId);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
### RateLimitClient
|
|
38
|
+
|
|
39
|
+
| Method | Description |
|
|
40
|
+
|--------|-------------|
|
|
41
|
+
| `getRateLimitsConfig(token, rateLimitUserId)` | Get rate limit config and current usage |
|
|
42
|
+
| `getRateLimitHistory(period, token, rateLimitUserId)` | Get usage history (`'hour'` / `'day'` / `'month'`) |
|
|
43
|
+
|
|
44
|
+
### useRateLimits Hook
|
|
45
|
+
|
|
46
|
+
Returns: `config`, `isLoadingConfig`, `history`, `isLoadingHistory`, `error`, `refreshConfig`, `refreshHistory`, `clearError`, `reset`.
|
|
47
|
+
|
|
48
|
+
### Types (from `@sudobility/types`)
|
|
49
|
+
|
|
50
|
+
`RateLimitsConfigData`, `RateLimitHistoryData`, `RateLimitPeriodType`
|
|
51
|
+
|
|
52
|
+
### Local Exports
|
|
53
|
+
|
|
54
|
+
`FirebaseIdToken` (type), `QUERY_KEYS`
|
|
55
|
+
|
|
56
|
+
## Development
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
bun run build # Build to dist/
|
|
60
|
+
bun run build:watch # Watch mode build
|
|
61
|
+
bun run clean # Remove dist/
|
|
62
|
+
bun run test # Run Vitest tests
|
|
63
|
+
bun run lint # Run ESLint
|
|
64
|
+
bun run lint:fix # Fix lint issues
|
|
65
|
+
bun run typecheck # TypeScript check
|
|
66
|
+
bun run format # Format with Prettier
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Pre-commit:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
bun run typecheck && bun run lint && bun run test && bun run build
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
BUSL-1.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudobility/ratelimit_client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"description": "React client library for Rate Limit API with TanStack Query hooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"author": "John Huang",
|
|
35
35
|
"license": "BUSL-1.1",
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@sudobility/types": "^1.9.
|
|
37
|
+
"@sudobility/types": "^1.9.57",
|
|
38
38
|
"@tanstack/react-query": ">=5.0.0",
|
|
39
39
|
"react": ">=18.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@eslint/js": "^9.39.2",
|
|
43
|
-
"@sudobility/di": "^1.5.
|
|
44
|
-
"@sudobility/types": "^1.9.
|
|
43
|
+
"@sudobility/di": "^1.5.45",
|
|
44
|
+
"@sudobility/types": "^1.9.57",
|
|
45
45
|
"@tanstack/react-query": "^5.90.5",
|
|
46
46
|
"@testing-library/dom": "^10.4.1",
|
|
47
47
|
"@testing-library/react": "^16.3.1",
|