@output.ai/http 0.1.0 → 0.1.1

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 CHANGED
@@ -1,6 +1,9 @@
1
1
  # @output.ai/http
2
2
 
3
- TypeScript HTTP client that wraps [ky](https://github.com/sindresorhus/ky) with Output SDK tracing hooks.
3
+ HTTP client with built-in tracing for Output Framework workflows.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@output.ai/http)](https://www.npmjs.com/package/@output.ai/http)
6
+ [![Documentation](https://img.shields.io/badge/docs-docs.output.ai-blue)](https://docs.output.ai/packages/http)
4
7
 
5
8
  ## Installation
6
9
 
@@ -18,9 +21,65 @@ const client = httpClient({
18
21
  });
19
22
 
20
23
  const response = await client.get('users/1');
21
- const userData = await response.json();
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');
22
45
  ```
23
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
+
24
74
  ## Environment Variables
25
75
 
26
- - `LOG_HTTP_VERBOSE=true` - Enables detailed request/response logging including headers and body
76
+ | Variable | Description |
77
+ |----------|-------------|
78
+ | `LOG_HTTP_VERBOSE` | Set to `true` for detailed request/response logging |
79
+
80
+ ## Documentation
81
+
82
+ For comprehensive documentation, visit:
83
+
84
+ - [Package Reference](https://docs.output.ai/packages/http)
85
+ - [Getting Started](https://docs.output.ai/quickstart)
package/dist/index.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import type { Options } from 'ky';
2
2
  /**
3
- * Creates an HTTP client with Output SDK tracing
3
+ * Creates a ky client.
4
4
  *
5
- * @param options - ky options to extend the base client with
6
- * @returns Extended ky instance with Output SDK hooks
5
+ * This client is customized with hooks to integrate with Output SDK tracing.
7
6
  *
8
7
  * @example
9
- * ```typescript
8
+ * ```ts
10
9
  * import { httpClient } from '@output.ai/http';
11
10
  *
12
11
  * const client = httpClient({
@@ -18,6 +17,9 @@ import type { Options } from 'ky';
18
17
  * const response = await client.get('users/1');
19
18
  * const data = await response.json();
20
19
  * ```
20
+ *
21
+ * @param options - The ky options to extend the base client.
22
+ * @returns A ky instance extended with Output SDK tracing hooks.
21
23
  */
22
24
  export declare function httpClient(options?: Options): import("ky").KyInstance;
23
25
  export { HTTPError, TimeoutError } from 'ky';
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import ky from 'ky';
2
2
  import { assignRequestId, traceRequest, traceResponse, traceError } from './hooks/index.js';
3
3
  import { applyFetchErrorTracing } from '#hooks/trace_error.js';
4
- // Create base HTTP client with standard Output SDK tracing hooks
5
4
  const baseHttpClient = ky.create({
6
5
  hooks: {
7
6
  beforeRequest: [
@@ -25,13 +24,12 @@ const applyDefaultOptions = (userOptions) => (parentOptions) => {
25
24
  };
26
25
  };
27
26
  /**
28
- * Creates an HTTP client with Output SDK tracing
27
+ * Creates a ky client.
29
28
  *
30
- * @param options - ky options to extend the base client with
31
- * @returns Extended ky instance with Output SDK hooks
29
+ * This client is customized with hooks to integrate with Output SDK tracing.
32
30
  *
33
31
  * @example
34
- * ```typescript
32
+ * ```ts
35
33
  * import { httpClient } from '@output.ai/http';
36
34
  *
37
35
  * const client = httpClient({
@@ -43,6 +41,9 @@ const applyDefaultOptions = (userOptions) => (parentOptions) => {
43
41
  * const response = await client.get('users/1');
44
42
  * const data = await response.json();
45
43
  * ```
44
+ *
45
+ * @param options - The ky options to extend the base client.
46
+ * @returns A ky instance extended with Output SDK tracing hooks.
46
47
  */
47
48
  export function httpClient(options = {}) {
48
49
  return baseHttpClient.extend(applyDefaultOptions(options));
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@output.ai/http",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Framework abstraction to make HTTP calls with tracing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
- "types": "dist/index.d.js",
7
+ "types": "dist/index.d.ts",
8
8
  "files": [
9
9
  "dist"
10
10
  ],
@@ -15,7 +15,10 @@
15
15
  "@output.ai/core": ">=0.0.1",
16
16
  "ky": "~1.9.1"
17
17
  },
18
- "license": "UNLICENSED",
18
+ "license": "Apache-2.0",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
19
22
  "imports": {
20
23
  "#*": "./dist/*"
21
24
  }