@marcohefti/request-network-api-client 0.5.1 → 0.5.5
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 +107 -49
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +51 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -6
package/README.md
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
# Request Network API Client (TypeScript)
|
|
2
2
|
|
|
3
|
-
TypeScript client for the Request Network hosted REST API.
|
|
4
|
-
helpers for core API domains such as requests, payouts, payer/compliance, client IDs,
|
|
5
|
-
currencies, and payments, with runtime validation and webhook utilities built in.
|
|
3
|
+
TypeScript client for the Request Network hosted REST API. Provides typed, ergonomic helpers for requests, payouts, payer/compliance, client IDs, currencies, and payments, with runtime validation and webhook utilities built in.
|
|
6
4
|
|
|
7
|
-
This
|
|
5
|
+
**Note**: This targets the hosted REST API, not the protocol SDK. See [SCOPE.md](docs/SCOPE.md) for when to use which.
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
11
|
-
Install via npm or pnpm:
|
|
12
|
-
|
|
13
9
|
```bash
|
|
14
|
-
# npm
|
|
15
10
|
npm install @marcohefti/request-network-api-client
|
|
16
|
-
|
|
17
|
-
# pnpm
|
|
11
|
+
# or
|
|
18
12
|
pnpm add @marcohefti/request-network-api-client
|
|
13
|
+
# or
|
|
14
|
+
yarn add @marcohefti/request-network-api-client
|
|
19
15
|
```
|
|
20
16
|
|
|
21
|
-
##
|
|
17
|
+
## Features
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
- **Typed API**: Full TypeScript support with types generated from OpenAPI spec
|
|
20
|
+
- **Runtime Validation**: Zod schemas validate requests/responses (configurable)
|
|
21
|
+
- **Webhook Helpers**: Signature verification, middleware, and event dispatchers
|
|
22
|
+
- **Error Handling**: Consistent error model with retry/backoff
|
|
23
|
+
- **Tree-Shakable**: Subpath exports for minimal bundle size
|
|
24
|
+
- **Universal**: Works in Node 20+, browsers, and edge runtimes
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
24
27
|
|
|
25
28
|
```ts
|
|
26
29
|
import {
|
|
@@ -34,64 +37,119 @@ const client = createRequestClient({
|
|
|
34
37
|
apiKey: process.env.REQUEST_API_KEY!,
|
|
35
38
|
});
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
// Create a request
|
|
41
|
+
const request = await client.requests.create({
|
|
42
|
+
amount: '12.5',
|
|
43
|
+
invoiceCurrency: 'USD',
|
|
44
|
+
paymentCurrency: 'USDC-sepolia',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// List currencies
|
|
48
|
+
const tokens = await client.currencies.list({ network: 'sepolia' });
|
|
49
|
+
|
|
50
|
+
// Error handling
|
|
51
|
+
try {
|
|
52
|
+
await client.payments.search({ walletAddress: '0xabc' });
|
|
53
|
+
} catch (err) {
|
|
54
|
+
if (isRequestApiError(err)) {
|
|
55
|
+
console.error('API error', err.status, err.code, err.requestId);
|
|
47
56
|
}
|
|
48
57
|
}
|
|
49
|
-
|
|
50
|
-
main();
|
|
51
58
|
```
|
|
52
59
|
|
|
53
|
-
From
|
|
60
|
+
**From environment variables**:
|
|
54
61
|
|
|
55
62
|
```ts
|
|
56
63
|
import { createRequestClientFromEnv } from '@marcohefti/request-network-api-client';
|
|
57
64
|
|
|
58
65
|
const client = createRequestClientFromEnv();
|
|
59
|
-
// Reads REQUEST_API_URL, REQUEST_API_KEY, REQUEST_CLIENT_ID
|
|
66
|
+
// Reads: REQUEST_API_URL, REQUEST_API_KEY, REQUEST_CLIENT_ID
|
|
60
67
|
```
|
|
61
68
|
|
|
62
|
-
##
|
|
69
|
+
## Documentation
|
|
63
70
|
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
71
|
+
- **[Quick Start](docs/QUICK-START.md)** - Installation, environment setup, common recipes
|
|
72
|
+
- **[Domains](docs/DOMAINS.md)** - API reference for all domains (requests, payouts, payer, payments, currencies, client IDs)
|
|
73
|
+
- **[HTTP & Errors](docs/HTTP-AND-ERRORS.md)** - HTTP client configuration, error handling, retry behavior
|
|
74
|
+
- **[Webhooks](docs/WEBHOOKS.md)** - Signature verification, middleware, event handlers, local dev setup
|
|
75
|
+
- **[Scope](docs/SCOPE.md)** - When to use this client vs the protocol SDK
|
|
76
|
+
- **[Architecture](docs/ARCHITECTURE.md)** - System design and internals
|
|
77
|
+
- **[Testing](docs/TESTING.md)** - Test strategy, commands, and coverage
|
|
78
|
+
- **[Publishing](docs/PUBLISHING.md)** - Release checklist
|
|
79
|
+
- **[Endpoints](docs/ENDPOINTS.md)** - API endpoint reference
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
## Compatibility
|
|
70
82
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
| Runtime | Versions |
|
|
84
|
+
|---------|----------|
|
|
85
|
+
| Node.js | 20.x, 22.x, 24.x |
|
|
86
|
+
| Browsers | Modern browsers with Fetch API |
|
|
87
|
+
| Edge Runtimes | Cloudflare Workers, Vercel Edge, Deno, Bun |
|
|
76
88
|
|
|
77
|
-
|
|
89
|
+
**Package Manager**: pnpm 10.17.1 recommended (`corepack enable pnpm@10.17.1`)
|
|
90
|
+
|
|
91
|
+
## Versioning
|
|
92
|
+
|
|
93
|
+
This package follows SemVer. While on `0.x`, minor/patch releases may include breaking changes as the API surface stabilizes. Once `1.0.0` is reached, breaking changes will require a major version bump.
|
|
94
|
+
|
|
95
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
96
|
+
|
|
97
|
+
## Troubleshooting
|
|
98
|
+
|
|
99
|
+
**API Key Issues**
|
|
100
|
+
- Ensure `REQUEST_API_KEY` is set and has necessary permissions
|
|
101
|
+
- Test with a simple call: `await client.currencies.list({ network: 'sepolia' })`
|
|
102
|
+
|
|
103
|
+
**Runtime Validation Errors**
|
|
104
|
+
- The API response didn't match the expected schema
|
|
105
|
+
- Check you're using the latest client version
|
|
106
|
+
- Temporarily disable validation to debug: `runtimeValidation: false`
|
|
78
107
|
|
|
79
|
-
|
|
80
|
-
-
|
|
108
|
+
**Timeout Issues**
|
|
109
|
+
- Set custom timeout: `await client.currencies.list({ network: 'sepolia' }, { timeoutMs: 10_000 })`
|
|
81
110
|
|
|
82
|
-
|
|
111
|
+
**Rate Limiting (429)**
|
|
112
|
+
- The client auto-retries with exponential backoff
|
|
113
|
+
- Override retry policy: `meta: { retry: { maxAttempts: 5 } }`
|
|
83
114
|
|
|
84
|
-
-
|
|
85
|
-
|
|
115
|
+
See [HTTP-AND-ERRORS.md](docs/HTTP-AND-ERRORS.md) for detailed error handling patterns.
|
|
116
|
+
|
|
117
|
+
## Support & Security
|
|
118
|
+
|
|
119
|
+
- **Issues**: Report bugs or request features via [GitHub Issues](https://github.com/marcohefti/request-network-api-client-ts/issues)
|
|
120
|
+
- **Security**: See [SECURITY.md](SECURITY.md) for disclosure policy
|
|
121
|
+
- **Contributing**: See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines
|
|
86
122
|
|
|
87
123
|
## Development
|
|
88
124
|
|
|
89
|
-
|
|
125
|
+
**Prerequisites**: Node 20/22/24, pnpm 10.17.1
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Install dependencies
|
|
129
|
+
pnpm install
|
|
130
|
+
|
|
131
|
+
# Type-check
|
|
132
|
+
pnpm typecheck
|
|
133
|
+
|
|
134
|
+
# Lint
|
|
135
|
+
pnpm lint
|
|
136
|
+
|
|
137
|
+
# Run tests
|
|
138
|
+
pnpm test
|
|
139
|
+
|
|
140
|
+
# Build
|
|
141
|
+
pnpm build
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Full validation** (before submitting PRs):
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pnpm coverage:matrix # Node 20/22/24 coverage matrix
|
|
148
|
+
pnpm build # Verify packaging
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
See [TESTING.md](docs/TESTING.md) for test strategy and [CONTRIBUTING.md](CONTRIBUTING.md) for coding guidelines.
|
|
90
152
|
|
|
91
|
-
|
|
92
|
-
- `pnpm typecheck` – run TypeScript diagnostics (`tsc`).
|
|
93
|
-
- `pnpm test` – run the Vitest suite (MSW + OpenAPI parity guards).
|
|
94
|
-
- `pnpm build` – build CJS/ESM + types into `dist/`.
|
|
153
|
+
## License
|
|
95
154
|
|
|
96
|
-
See [
|
|
97
|
-
[`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for the HTTP pipeline and domain layout.
|
|
155
|
+
MIT - See [LICENSE](LICENSE) for details.
|
package/dist/cjs/index.js
CHANGED
|
@@ -3385,8 +3385,8 @@ function isAgreementRejected(payload) {
|
|
|
3385
3385
|
}
|
|
3386
3386
|
function complianceStatusSummary(payload) {
|
|
3387
3387
|
const parts = [];
|
|
3388
|
-
const kyc = payload.kycStatus ?
|
|
3389
|
-
const agreement = payload.agreementStatus ?
|
|
3388
|
+
const kyc = payload.kycStatus ? payload.kycStatus.replace(/_/g, " ") : "unknown";
|
|
3389
|
+
const agreement = payload.agreementStatus ? payload.agreementStatus.replace(/_/g, " ") : "unknown";
|
|
3390
3390
|
parts.push(`KYC: ${kyc}`);
|
|
3391
3391
|
parts.push(`Agreement: ${agreement}`);
|
|
3392
3392
|
if (payload.clientUserId) {
|