@output.ai/http 0.1.1 → 0.1.2
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 +3 -77
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,83 +3,9 @@
|
|
|
3
3
|
HTTP client with built-in tracing for Output Framework workflows.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@output.ai/http)
|
|
6
|
-
[](https://docs.output.ai/packages/http)
|
|
7
|
-
|
|
8
|
-
## Installation
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm install @output.ai/http
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Quick Start
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
import { httpClient } from '@output.ai/http';
|
|
18
|
-
|
|
19
|
-
const client = httpClient({
|
|
20
|
-
prefixUrl: 'https://api.example.com'
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const response = await client.get('users/1');
|
|
24
|
-
const data = await response.json();
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## HTTP Methods
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
// GET
|
|
31
|
-
const users = await client.get('users').json();
|
|
32
|
-
|
|
33
|
-
// POST
|
|
34
|
-
const newUser = await client.post('users', {
|
|
35
|
-
json: { name: 'John', email: 'john@example.com' }
|
|
36
|
-
}).json();
|
|
37
|
-
|
|
38
|
-
// PUT
|
|
39
|
-
await client.put('users/1', {
|
|
40
|
-
json: { name: 'Jane' }
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// DELETE
|
|
44
|
-
await client.delete('users/1');
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Using in Steps
|
|
48
|
-
|
|
49
|
-
Wrap HTTP calls in steps for automatic retry and tracing:
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
import { step, z } from '@output.ai/core';
|
|
53
|
-
import { httpClient } from '@output.ai/http';
|
|
54
|
-
|
|
55
|
-
const api = httpClient({ prefixUrl: 'https://api.example.com' });
|
|
56
|
-
|
|
57
|
-
export const fetchUser = step({
|
|
58
|
-
name: 'fetchUser',
|
|
59
|
-
inputSchema: z.string(),
|
|
60
|
-
outputSchema: z.object({
|
|
61
|
-
id: z.string(),
|
|
62
|
-
name: z.string()
|
|
63
|
-
}),
|
|
64
|
-
fn: async (userId) => {
|
|
65
|
-
return api.get(`users/${userId}`).json();
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Tracing
|
|
71
|
-
|
|
72
|
-
All HTTP requests are automatically traced and visible in the Temporal UI, including request/response details and timing.
|
|
73
|
-
|
|
74
|
-
## Environment Variables
|
|
75
|
-
|
|
76
|
-
| Variable | Description |
|
|
77
|
-
|----------|-------------|
|
|
78
|
-
| `LOG_HTTP_VERBOSE` | Set to `true` for detailed request/response logging |
|
|
79
6
|
|
|
80
7
|
## Documentation
|
|
8
|
+
- [README](https://docs.output.ai/packages/http)
|
|
9
|
+
- [API Reference](https://output-ai-reference-code-docs.onrender.com/modules/http_src.html)
|
|
81
10
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- [Package Reference](https://docs.output.ai/packages/http)
|
|
85
|
-
- [Getting Started](https://docs.output.ai/quickstart)
|
|
11
|
+
<!-- Internal Dev Note: The documentation for this package is found at docs/guides/packages/http.mdx -->
|