@telorun/http-server 0.1.6 → 0.1.8
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/CHANGELOG.md +14 -0
- package/LICENSE +17 -0
- package/README.md +150 -0
- package/package.json +26 -7
package/CHANGELOG.md
CHANGED
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SUSTAINABLE USE LICENSE (Fair-code)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DiglyAI
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
1. ANTI-COMPETITION RESTRICTION: The Software may not be provided to third parties as a managed service, commercial SaaS (Software-as-a-Service), PaaS (Platform-as-a-Service), BaaS (Backend-as-a-Service), or similar offering where the primary value provided to the user is the functionality of the Software itself, without a separate commercial license from the copyright holder.
|
|
8
|
+
|
|
9
|
+
2. PERMITTED COMMERCIAL USE: You are free to use the Software to build, host, and monetize your own commercial applications, products, and services, provided such use does not violate Clause 1.
|
|
10
|
+
|
|
11
|
+
3. ATTRIBUTION: This copyright notice and license must be included in all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
4. CONTRIBUTIONS: Contributions to the Software are welcome and encouraged. By contributing, you agree that your contributions may be incorporated into the Software and distributed under this license.
|
|
14
|
+
|
|
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
|
+
|
|
17
|
+
For commercial licensing, managed hosting exemptions, or enterprise inquiries, please contact DiglyAI.
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Telo HTTP Standard Specification (v1.0 Draft)
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The `Http.Server` and `Http.Api` manifests in Telo are designed to be strictly **language-agnostic** and **framework-agnostic**. To maintain the "Zero Lock-in" promise, the underlying HTTP engine (e.g., Fastify in Node.js, Actix in Rust) is treated purely as an implementation detail.
|
|
6
|
+
|
|
7
|
+
All HTTP modules integrated into the Telo kernel **must** adhere to this behavioral contract. This ensures that a YAML manifest written today will execute with exactly the same I/O and validation behavior regardless of the underlying language or framework.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Routing Contract (Path Definitions)
|
|
12
|
+
|
|
13
|
+
Different web frameworks use different syntaxes for path parameters (e.g., `/users/:id` vs. `/users/{id}`).
|
|
14
|
+
|
|
15
|
+
Telo standardizes on the **OpenAPI specification format** for paths.
|
|
16
|
+
|
|
17
|
+
- **Standard:** Path parameters MUST be enclosed in curly braces: `{parameterName}`.
|
|
18
|
+
- **Module Responsibility:** The underlying HTTP module must parse the Telo path and translate it into its framework's native routing syntax at startup.
|
|
19
|
+
|
|
20
|
+
**Example Manifest Path:** `/api/v1/users/{userId}`
|
|
21
|
+
|
|
22
|
+
- _Node.js (Fastify) Adapter translates to:_ `/api/v1/users/:userId`
|
|
23
|
+
- _Rust (Actix) Adapter translates to:_ `/api/v1/users/{userId}`
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. The I/O Context Contract
|
|
28
|
+
|
|
29
|
+
When an incoming HTTP request is received, the underlying framework must normalize it into a standard **Telo Request Object** before passing it to the Handler/CEL engine. Conversely, it must accept a standard **Telo Response Object** to send back to the client.
|
|
30
|
+
|
|
31
|
+
### 2.1. Standardized Telo Request Object (Input)
|
|
32
|
+
|
|
33
|
+
The HTTP module must construct and pass the following exact payload to the execution environment:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"request": {
|
|
38
|
+
"method": "POST",
|
|
39
|
+
"path": "/api/v1/users/123",
|
|
40
|
+
"params": { "userId": "123" },
|
|
41
|
+
"query": { "active": "true" },
|
|
42
|
+
"headers": {
|
|
43
|
+
"content-type": "application/json",
|
|
44
|
+
"authorization": "Bearer token..."
|
|
45
|
+
},
|
|
46
|
+
"body": {
|
|
47
|
+
"name": "Alice",
|
|
48
|
+
"age": 30
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- **Constraint:** All `headers` keys MUST be normalized to lowercase.
|
|
55
|
+
- **Constraint:** If the `content-type` is `application/json`, the `body` MUST be parsed into a native object/dictionary before evaluation.
|
|
56
|
+
|
|
57
|
+
### 2.2. Standardized Telo Response Object (Output)
|
|
58
|
+
|
|
59
|
+
After the Handler executes and the `response.mapping` evaluates, the engine will return an object to the HTTP module. The module must map this directly to the native HTTP response.
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"status": 200,
|
|
64
|
+
"headers": {
|
|
65
|
+
"x-telo-runtime": "0.1.0",
|
|
66
|
+
"content-type": "application/json"
|
|
67
|
+
},
|
|
68
|
+
"body": {
|
|
69
|
+
"id": "123",
|
|
70
|
+
"status": "created"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 3. Validation & Error Handling Contract
|
|
78
|
+
|
|
79
|
+
When a request fails schema validation (defined in the `request.schema` of the manifest), the underlying engine (e.g., AJV in Fastify) will generate native errors. **These internal errors must not leak to the client.**
|
|
80
|
+
|
|
81
|
+
All Telo HTTP modules MUST intercept framework-specific validation errors and return a standardized HTTP 400 Bad Request payload.
|
|
82
|
+
|
|
83
|
+
### Standardized Validation Error Format
|
|
84
|
+
|
|
85
|
+
The response body must strictly follow this JSON structure:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"error": "ValidationError",
|
|
90
|
+
"message": "Request validation failed",
|
|
91
|
+
"status": 400,
|
|
92
|
+
"details": [
|
|
93
|
+
{
|
|
94
|
+
"location": "body",
|
|
95
|
+
"path": "user.age",
|
|
96
|
+
"message": "must be an integer"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"location": "query",
|
|
100
|
+
"path": "active",
|
|
101
|
+
"message": "is a required property"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- **`location` enum:** `body` | `query` | `params` | `headers`
|
|
108
|
+
- **Module Responsibility:** The module author must write an error handler/mapper that transforms the native framework's validation output into the Telo `details` array.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 4. Manifest Schema Upgrades
|
|
113
|
+
|
|
114
|
+
To fully support this contract, the `Http.Api` JSON Schema definition includes the following structural definitions for the `request` block:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
request:
|
|
118
|
+
type: "object"
|
|
119
|
+
properties:
|
|
120
|
+
path:
|
|
121
|
+
type: "string"
|
|
122
|
+
description: "Must use OpenAPI style path parameters, e.g., /users/{id}"
|
|
123
|
+
method:
|
|
124
|
+
type: "string"
|
|
125
|
+
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]
|
|
126
|
+
consumes:
|
|
127
|
+
type: "array"
|
|
128
|
+
items: { type: "string" }
|
|
129
|
+
default: ["application/json"]
|
|
130
|
+
produces:
|
|
131
|
+
type: "array"
|
|
132
|
+
items: { type: "string" }
|
|
133
|
+
default: ["application/json"]
|
|
134
|
+
schema:
|
|
135
|
+
type: "object"
|
|
136
|
+
properties:
|
|
137
|
+
params:
|
|
138
|
+
type: "object"
|
|
139
|
+
description: "Validation schema for path parameters"
|
|
140
|
+
query:
|
|
141
|
+
type: "object"
|
|
142
|
+
description: "Validation schema for query string parameters"
|
|
143
|
+
headers:
|
|
144
|
+
type: "object"
|
|
145
|
+
description: "Validation schema for HTTP headers"
|
|
146
|
+
body:
|
|
147
|
+
type: "object"
|
|
148
|
+
description: "Validation schema for the request payload"
|
|
149
|
+
required: ["path", "method"]
|
|
150
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/http-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"description": "Telo HTTP Server module - HTTP server and API resource kinds for Telo manifests.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"telo",
|
|
7
|
+
"http",
|
|
8
|
+
"server",
|
|
9
|
+
"api",
|
|
10
|
+
"fastify"
|
|
11
|
+
],
|
|
12
|
+
"author": "Bartosz Pasiński <bartosz.pasinski@codenet.pl>",
|
|
13
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/telorun/telo.git",
|
|
17
|
+
"directory": "modules/http-server/nodejs"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/telorun/telo#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/telorun/telo/issues"
|
|
22
|
+
},
|
|
4
23
|
"type": "module",
|
|
5
24
|
"main": "./dist/index.js",
|
|
6
25
|
"module": "./dist/index.js",
|
|
@@ -16,21 +35,21 @@
|
|
|
16
35
|
"import": "./dist/http-api-controller.js"
|
|
17
36
|
}
|
|
18
37
|
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsc -p tsconfig.lib.json"
|
|
21
|
-
},
|
|
22
38
|
"dependencies": {
|
|
23
39
|
"@fastify/cors": "^11.2.0",
|
|
24
40
|
"@fastify/swagger": "^9.6.1",
|
|
25
41
|
"@scalar/fastify-api-reference": "^1.44.6",
|
|
26
42
|
"@sinclair/typebox": "^0.34.48",
|
|
27
|
-
"@telorun/sdk": "workspace:*",
|
|
28
43
|
"ajv": "^8.17.1",
|
|
29
44
|
"ajv-formats": "^3.0.1",
|
|
30
|
-
"fastify": "^5.7.2"
|
|
45
|
+
"fastify": "^5.7.2",
|
|
46
|
+
"@telorun/sdk": "0.2.8"
|
|
31
47
|
},
|
|
32
48
|
"devDependencies": {
|
|
33
49
|
"@types/node": "^20.0.0",
|
|
34
50
|
"typescript": "^5.0.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc -p tsconfig.lib.json"
|
|
35
54
|
}
|
|
36
|
-
}
|
|
55
|
+
}
|