@telorun/http-client 0.2.3 → 1.0.0

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.

Potentially problematic release.


This version of @telorun/http-client might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +64 -38
  3. package/package.json +4 -4
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  # SUSTAINABLE USE LICENSE (Fair-code)
2
2
 
3
- Copyright (c) 2026 DiglyAI
3
+ Copyright (c) 2026 CodeNet Sp. z o.o.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, and distribute the Software for any purpose—including commercial purposes—subject to the following conditions:
6
6
 
@@ -14,4 +14,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
14
14
 
15
15
  5. DISCLAIMER: The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.
16
16
 
17
- For commercial licensing, managed hosting exemptions, or enterprise inquiries, please contact DiglyAI.
17
+ For commercial licensing, managed hosting exemptions, or enterprise inquiries, please contact <contact@codenet.pl>.
package/README.md CHANGED
@@ -1,29 +1,63 @@
1
- # Telo HTTP Client Standard Specification (v1.0 Draft)
1
+ # HTTP Client
2
2
 
3
- ## Overview
3
+ Outgoing HTTP calls for Telo. Language- and engine-neutral request/response contract, with shared `Http.Client` defaults and per-call `Http.Request` overrides.
4
4
 
5
- The `Http.Request` (and optionally `Http.Client`) definitions represent outgoing HTTP calls made by the Telo kernel to external services.
6
- Because different programming languages implement HTTP clients differently (e.g., `fetch` in Node.js, `reqwest` in Rust), all Telo HTTP Client modules MUST adhere to this exact behavior to ensure cross-language compatibility.
5
+ ## Why use this
7
6
 
8
- ---
7
+ - **Engine-neutral contract** — `fetch`, `reqwest`, or anything else; the same manifest serializes input and deserializes output the same way.
8
+ - **Shared client defaults** — `Http.Client` defines base URL, headers, timeout, and redirect behaviour once; `Http.Request` overrides per call.
9
+ - **Network vs. HTTP errors** — 4xx/5xx return a normal response object; only true network failures throw a structured `NetworkError`.
10
+ - **JSON-aware** — `content-type: application/json` request bodies are serialized; JSON responses are parsed automatically.
11
+ - **Buffer or stream** — pick `mode: stream` to receive a readable stream without buffering the response body.
12
+ - **Built-in retries** — `retries: N` retries on network errors only, leaving HTTP responses to manifest logic.
9
13
 
10
- ## 1. The Request Contract (Input Serialization)
14
+ ## Kinds
11
15
 
12
- When the Telo kernel executes an `Http.Request`, the underlying module must construct the outgoing request according to strict rules.
16
+ | Kind | Purpose |
17
+ | --- | --- |
18
+ | `Http.Client` | Long-lived client carrying base URL, default headers, timeout, and redirect policy. |
19
+ | `Http.Request` | Per-call HTTP request invocable; references an `Http.Client` for shared defaults. |
13
20
 
14
- - **Headers Normalization:** All header keys provided in the manifest MUST be normalized to lowercase before sending.
15
- - **Query Parameters:** If `query` is provided as an object, the module MUST safely URL-encode the keys and values and append them to the `url`.
16
- - **Payload Serialization (Body):**
17
- - If the `headers` include `content-type: application/json` (which should be the default if `body` is an object), the module MUST serialize the `body` to a JSON string.
18
- - If the `content-type` is `application/x-www-form-urlencoded`, the module MUST serialize the object into a URL-encoded string.
21
+ ## Example
19
22
 
23
+ ```yaml
24
+ kind: Telo.Application
25
+ metadata: { name: fetcher, version: 1.0.0 }
26
+ ---
27
+ kind: Telo.Import
28
+ metadata: { name: Http }
29
+ source: pkg:npm/@telorun/http-client@^1.0.0
30
+ ---
31
+ kind: Http.Client
32
+ metadata: { name: GitHub }
33
+ baseUrl: https://api.github.com
34
+ headers:
35
+ accept: application/vnd.github+json
36
+ timeout: 5000
20
37
  ---
38
+ kind: Http.Request
39
+ metadata: { name: GetUser }
40
+ client: GitHub
41
+ inputs:
42
+ url: /users/octocat
43
+ method: GET
44
+ ```
45
+
46
+ ## Implementation Contract
21
47
 
22
- ## 2. The Response Contract (Output Deserialization)
48
+ ### 1. Request contract (input serialization)
49
+
50
+ When the Telo kernel executes an `Http.Request`, the underlying module must construct the outgoing request according to strict rules.
23
51
 
24
- The output of an `Http.Request` becomes available to the Telo engine (e.g., for mapping via CEL expressions). The underlying engine MUST return a standardized **Telo Response Object**.
52
+ - **Headers normalization:** all header keys provided in the manifest MUST be normalized to lowercase before sending.
53
+ - **Query parameters:** if `query` is provided as an object, the module MUST safely URL-encode the keys and values and append them to the `url`.
54
+ - **Payload serialization (body):**
55
+ - If the `headers` include `content-type: application/json` (the default when `body` is an object), the module MUST serialize the `body` to a JSON string.
56
+ - If the `content-type` is `application/x-www-form-urlencoded`, the module MUST serialize the object into a URL-encoded string.
25
57
 
26
- ### Standardized Return Object
58
+ ### 2. Response contract (output deserialization)
59
+
60
+ The output of an `Http.Request` becomes available to the Telo engine (e.g. for mapping via CEL expressions). The underlying engine MUST return a standardized Telo Response Object.
27
61
 
28
62
  ```json
29
63
  {
@@ -39,27 +73,23 @@ The output of an `Http.Request` becomes available to the Telo engine (e.g., for
39
73
  }
40
74
  ```
41
75
 
42
- - **Header Normalization:** The module MUST normalize all incoming response headers to lowercase keys.
43
- - **Body Deserialization Rules:**
44
- - **JSON:** If the response header `content-type` includes `application/json`, the module MUST attempt to parse the response body as a JSON object. _Edge Case:_ If the response is empty (0 bytes) but claims to be JSON, the module MUST return `null` for the body, not throw a parsing error.
45
- - **Text/Other:** For any other content type, or if JSON parsing fails gracefully, the `body` MUST be returned as a raw String.
46
-
47
- ---
48
-
49
- ## 3. Error Handling Contract (Network vs. HTTP)
76
+ - **Header normalization:** the module MUST normalize all incoming response headers to lowercase keys.
77
+ - **Body deserialization:**
78
+ - **JSON:** if the response `content-type` includes `application/json`, the module MUST attempt to parse the body as JSON. If the response is empty (0 bytes) but claims to be JSON, the module MUST return `null` for the body rather than throw.
79
+ - **Text/other:** for any other content type, or if JSON parsing fails gracefully, the `body` MUST be returned as a raw string.
50
80
 
51
- It is crucial to differentiate between an HTTP error (the external server responded) and a Network error (the kernel couldn't reach the server).
81
+ ### 3. Error handling (network vs. HTTP)
52
82
 
53
- ### 3.1. HTTP Status Errors (4xx and 5xx)
83
+ It is crucial to differentiate between an HTTP error (the external server responded) and a network error (the kernel couldn't reach the server).
54
84
 
55
- - **Standard:** By default, HTTP status codes like `400`, `404`, or `500` **MUST NOT** throw a kernel execution error.
56
- - They are considered successful _network_ executions. The module MUST return the standard Telo Response Object with the respective `status` code. It is up to the Telo manifest author to handle these via CEL mappings (e.g., `${{ result.status == 200 ? result.body : throw('API Failed') }}`).
85
+ #### 3.1 HTTP status errors (4xx and 5xx)
57
86
 
58
- ### 3.2. Network & Engine Errors
87
+ - **Standard:** by default, HTTP status codes like `400`, `404`, or `500` MUST NOT throw a kernel execution error.
88
+ - They are considered successful network executions. The module MUST return the standard Telo Response Object with the respective `status` code. Manifest authors handle these via CEL mappings (e.g. `${{ result.status == 200 ? result.body : throw('API Failed') }}`).
59
89
 
60
- If the request fails at the network layer (e.g., DNS resolution failure, connection refused, SSL error), the module MUST throw a standardized **Telo Network Error** that stops execution.
90
+ #### 3.2 Network and engine errors
61
91
 
62
- **Standardized Error Format:**
92
+ If the request fails at the network layer (e.g. DNS resolution failure, connection refused, SSL error), the module MUST throw a standardized Telo Network Error that stops execution.
63
93
 
64
94
  ```json
65
95
  {
@@ -72,13 +102,9 @@ If the request fails at the network layer (e.g., DNS resolution failure, connect
72
102
  }
73
103
  ```
74
104
 
75
- _Valid `code` enumerations MUST include:_ `TIMEOUT`, `CONNECTION_REFUSED`, `DNS_RESOLUTION_FAILED`, `SSL_ERROR`. Modules must map their native engine errors to these generic codes.
76
-
77
- ---
78
-
79
- ## 4. Execution Policies (Timeouts & Redirects)
105
+ Valid `code` values MUST include: `TIMEOUT`, `CONNECTION_REFUSED`, `DNS_RESOLUTION_FAILED`, `SSL_ERROR`. Modules must map their native engine errors to these generic codes.
80
106
 
81
- To prevent hanging processes, Telo enforces strict default limits on outgoing requests.
107
+ ### 4. Execution policies (timeouts and redirects)
82
108
 
83
- - **Timeouts:** The module MUST enforce a default request timeout of **10,000 milliseconds (10 seconds)** unless overridden in the manifest. If the timeout is reached, it MUST throw a `NetworkError` with the code `TIMEOUT`.
84
- - **Redirects:** The module MUST automatically follow `301` and `302` redirects, up to a maximum of **5 redirects**, to prevent infinite redirect loops.
109
+ - **Timeouts:** the module MUST enforce a default request timeout of 10,000 ms unless overridden. Timeout failures MUST throw a `NetworkError` with code `TIMEOUT`.
110
+ - **Redirects:** the module MUST automatically follow `301` and `302` redirects, up to a maximum of 5, to prevent infinite redirect loops.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/http-client",
3
- "version": "0.2.3",
3
+ "version": "1.0.0",
4
4
  "description": "Telo HTTP Client module - HTTP client resource kinds for Telo manifests.",
5
5
  "keywords": [
6
6
  "telo",
@@ -34,13 +34,13 @@
34
34
  "dist",
35
35
  "src/**"
36
36
  ],
37
- "dependencies": {
38
- "@telorun/sdk": "0.11.1"
39
- },
40
37
  "devDependencies": {
41
38
  "@types/node": "^20.0.0",
42
39
  "typescript": "^5.0.0"
43
40
  },
41
+ "peerDependencies": {
42
+ "@telorun/sdk": "1.0.0"
43
+ },
44
44
  "scripts": {
45
45
  "build": "tsc -p tsconfig.lib.json"
46
46
  }