@ontrails/http 1.0.0-beta.14 → 1.0.0-beta.16
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 +54 -0
- package/README.md +54 -17
- package/package.json +10 -9
- package/src/build.ts +1137 -78
- package/src/index.ts +18 -4
- package/src/method.ts +24 -0
- package/src/openapi.ts +357 -0
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/dist/blaze.d.ts +0 -25
- package/dist/blaze.d.ts.map +0 -1
- package/dist/blaze.js +0 -69
- package/dist/blaze.js.map +0 -1
- package/dist/build.d.ts +0 -54
- package/dist/build.d.ts.map +0 -1
- package/dist/build.js +0 -127
- package/dist/build.js.map +0 -1
- package/dist/hono/blaze.d.ts +0 -33
- package/dist/hono/blaze.d.ts.map +0 -1
- package/dist/hono/blaze.js +0 -232
- package/dist/hono/blaze.js.map +0 -1
- package/dist/hono/index.d.ts +0 -2
- package/dist/hono/index.d.ts.map +0 -1
- package/dist/hono/index.js +0 -2
- package/dist/hono/index.js.map +0 -1
- package/dist/hono/trailhead.d.ts +0 -36
- package/dist/hono/trailhead.d.ts.map +0 -1
- package/dist/hono/trailhead.js +0 -222
- package/dist/hono/trailhead.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/src/__tests__/build.test.ts +0 -494
- package/src/hono/__tests__/trailhead.test.ts +0 -527
- package/src/hono/index.ts +0 -1
- package/src/hono/trailhead.ts +0 -340
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @ontrails/http
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.16
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2bf239e: Move OpenAPI generation ownership to the HTTP surface.
|
|
8
|
+
|
|
9
|
+
**http**: Export `deriveOpenApiSpec()` and its OpenAPI types from `@ontrails/http`.
|
|
10
|
+
|
|
11
|
+
**schema**: Remove the OpenAPI helper export so schema stays focused on surface maps, locks, and semantic diffing.
|
|
12
|
+
|
|
13
|
+
- 26f9ffd: Project typed-layer `input` schemas onto MCP and HTTP surfaces. Closes Phase 7. Lifts `collectAttachedTypedLayers` and `projectLayerFieldName` (collision-rename rule) into `@ontrails/core/internal/layer-projection` so all three surfaces share one source of truth. The CLI surface refactors to consume the lifted helpers (no behavior change). MCP merges layer fields into each tool's `inputSchema` and partitions inbound args at invocation time. HTTP merges layer fields into the route's request schema (query for reads, body for writes) and exposes new optional `HttpRouteDefinition.inputSchema` + `layerInputProjections` for surface adapters / OpenAPI generators. Collision rule matches TRL-473's: deterministic rename to a layer-prefixed camelCase name with the original captured in the routing table. Side fix: MCP and HTTP handlers now forward `topoLayers: graph.layers` + `surfaceLayers: layers` so topo-scope layers actually compose at runtime (previously the handlers used the deprecated `layers` alias and never read `graph.layers`).
|
|
14
|
+
- 22c6c06: Accept ADR-0041 Unified Observability and ship the first activation and
|
|
15
|
+
observability primitives it depends on: activation trace records, topo-level
|
|
16
|
+
observe configuration, webhook activation materialization, signal/webhook
|
|
17
|
+
warden coaching, the `@ontrails/observe` package, sink composition, and
|
|
18
|
+
zero-dependency observe sinks.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 6300f70: Refresh source comments and test labels for retired connector terminology as adapter guardrails become strict.
|
|
23
|
+
- 95bf132: Wire HTTP permit resolution through the Hono adapter, including request headers for Bearer Authorization handling.
|
|
24
|
+
- 49c2e7d: Refresh published package README taxonomy to use adapter language instead of retired connector vocabulary.
|
|
25
|
+
- df9a7d0: Add project-aware public export-map governance for @ontrails workspace docs,
|
|
26
|
+
imports, root barrels, and bin-only package surfaces.
|
|
27
|
+
- Updated dependencies [73622ae]
|
|
28
|
+
- Updated dependencies [6300f70]
|
|
29
|
+
- Updated dependencies [d172013]
|
|
30
|
+
- Updated dependencies [c3fc5c3]
|
|
31
|
+
- Updated dependencies [20d7a5c]
|
|
32
|
+
- Updated dependencies [be5fb46]
|
|
33
|
+
- Updated dependencies [e898cc4]
|
|
34
|
+
- Updated dependencies [3395234]
|
|
35
|
+
- Updated dependencies [bcdc484]
|
|
36
|
+
- Updated dependencies [331e3a9]
|
|
37
|
+
- Updated dependencies [4399fdb]
|
|
38
|
+
- Updated dependencies [4b8d13b]
|
|
39
|
+
- Updated dependencies [112b9f2]
|
|
40
|
+
- Updated dependencies [893025e]
|
|
41
|
+
- Updated dependencies [eec5e9d]
|
|
42
|
+
- Updated dependencies [ebd4434]
|
|
43
|
+
- Updated dependencies [863d473]
|
|
44
|
+
- Updated dependencies [344f2f7]
|
|
45
|
+
- Updated dependencies [26f9ffd]
|
|
46
|
+
- Updated dependencies [10eae9a]
|
|
47
|
+
- Updated dependencies [22c6c06]
|
|
48
|
+
- @ontrails/core@1.0.0-beta.16
|
|
49
|
+
|
|
50
|
+
## 1.0.0-beta.15
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [4ad6b25]
|
|
55
|
+
- @ontrails/core@1.0.0-beta.15
|
|
56
|
+
|
|
3
57
|
## 1.0.0-beta.14
|
|
4
58
|
|
|
5
59
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @ontrails/http
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Framework-agnostic HTTP route derivation for Trails. Pair this package with `@ontrails/hono` when you want the Hono surface adapter.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
8
|
import { trail, topo, Result } from '@ontrails/core';
|
|
9
|
-
import {
|
|
9
|
+
import { surface } from '@ontrails/hono';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
|
|
12
12
|
const greet = trail('greet', {
|
|
@@ -16,8 +16,8 @@ const greet = trail('greet', {
|
|
|
16
16
|
blaze: (input) => Result.ok({ message: `Hello, ${input.name}!` }),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
await
|
|
19
|
+
const graph = topo('myapp', { greet });
|
|
20
|
+
await surface(graph, { port: 3000 });
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
This starts a Hono-based HTTP server. The `greet` trail becomes `GET /greet?name=...` because its `intent` is `'read'`.
|
|
@@ -25,23 +25,34 @@ This starts a Hono-based HTTP server. The `greet` trail becomes `GET /greet?name
|
|
|
25
25
|
For more control, build the routes yourself:
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import {
|
|
28
|
+
import { deriveHttpRoutes } from '@ontrails/http';
|
|
29
29
|
|
|
30
|
-
const result =
|
|
30
|
+
const result = deriveHttpRoutes(graph);
|
|
31
31
|
if (result.isErr()) throw result.error; // ValidationError on route collision
|
|
32
32
|
for (const route of result.value) {
|
|
33
33
|
console.log(`${route.method} ${route.path} → ${route.trailId}`);
|
|
34
34
|
}
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
`
|
|
37
|
+
`deriveHttpRoutes` returns `Result<HttpRouteDefinition[], Error>` rather than a bare array. It returns `Result.err(ValidationError)` if two trails derive the same `(method, path)` pair.
|
|
38
|
+
|
|
39
|
+
OpenAPI is the HTTP surface's persisted client contract projection:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { deriveOpenApiSpec } from '@ontrails/http';
|
|
43
|
+
|
|
44
|
+
const spec = deriveOpenApiSpec(graph, { basePath: '/api' });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`deriveOpenApiSpec()` emits an OpenAPI 3.1 document from the same trail
|
|
48
|
+
contracts used by `deriveHttpRoutes()`.
|
|
38
49
|
|
|
39
50
|
## API
|
|
40
51
|
|
|
41
52
|
| Export | What it does |
|
|
42
53
|
| --- | --- |
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
54
|
+
| `deriveHttpRoutes(graph, options?)` | Build framework-agnostic route definitions from a topo |
|
|
55
|
+
| `deriveOpenApiSpec(graph, options?)` | Generate an OpenAPI 3.1 document for the HTTP surface |
|
|
45
56
|
|
|
46
57
|
## Route derivation
|
|
47
58
|
|
|
@@ -58,19 +69,32 @@ Trail IDs map to paths: `entity.show` becomes `/entity/show`. Dots become slashe
|
|
|
58
69
|
|
|
59
70
|
## Collision detection
|
|
60
71
|
|
|
61
|
-
`
|
|
72
|
+
`deriveHttpRoutes` detects when two trails would produce the same `(method, path)` pair and returns `Result.err(ValidationError)` describing both trail IDs. The `surface()` helper from `@ontrails/hono` throws on collision.
|
|
73
|
+
|
|
74
|
+
## Resource resolution
|
|
75
|
+
|
|
76
|
+
Declared resources on each trail are resolved into the context before the implementation runs.
|
|
62
77
|
|
|
63
|
-
##
|
|
78
|
+
## Filtering
|
|
64
79
|
|
|
65
|
-
|
|
80
|
+
```typescript
|
|
81
|
+
const result = deriveHttpRoutes(graph, {
|
|
82
|
+
include: ['entity.**'],
|
|
83
|
+
exclude: ['dev.**'],
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`*` matches one dotted segment and `**` matches any depth. Trails declared
|
|
88
|
+
with `visibility: 'internal'` stay hidden unless you include their exact trail
|
|
89
|
+
ID intentionally.
|
|
66
90
|
|
|
67
|
-
##
|
|
91
|
+
## Request context and abort propagation
|
|
68
92
|
|
|
69
|
-
The `execute` function on each `HttpRouteDefinition` accepts
|
|
93
|
+
The `execute` function on each `HttpRouteDefinition` accepts optional `requestId`, `abortSignal`, and request context arguments. HTTP adapters should pass the request's `AbortSignal` so client disconnects propagate into trail execution, and pass headers in the request context when Bearer auth should resolve into `ctx.permit`.
|
|
70
94
|
|
|
71
95
|
## `HttpRouteDefinition`
|
|
72
96
|
|
|
73
|
-
Each route definition produced by `
|
|
97
|
+
Each route definition produced by `deriveHttpRoutes` includes:
|
|
74
98
|
|
|
75
99
|
| Field | Type | What it is |
|
|
76
100
|
| --- | --- | --- |
|
|
@@ -79,10 +103,23 @@ Each route definition produced by `buildHttpRoutes` includes:
|
|
|
79
103
|
| `trailId` | `string` | The trail ID this route was derived from |
|
|
80
104
|
| `inputSource` | `'query' \| 'body'` | Where to read input |
|
|
81
105
|
| `trail` | `Trail` | The original trail definition |
|
|
82
|
-
| `execute` | `(input, requestId?, abortSignal?) => Promise<Result>` | Validates,
|
|
106
|
+
| `execute` | `(input, requestId?, abortSignal?, context?) => Promise<Result>` | Validates, layers, resolves request auth when configured, and runs the implementation |
|
|
107
|
+
|
|
108
|
+
For GET routes on the Hono surface, repeated query keys are passed through as
|
|
109
|
+
arrays (`?tag=one&tag=two` -> `{ tag: ['one', 'two'] }`) while a single
|
|
110
|
+
occurrence stays a scalar string. The adapter does not coerce singleton query
|
|
111
|
+
values into arrays.
|
|
83
112
|
|
|
84
113
|
## Installation
|
|
85
114
|
|
|
86
115
|
```bash
|
|
87
|
-
bun add @ontrails/http hono
|
|
116
|
+
bun add @ontrails/http @ontrails/hono
|
|
88
117
|
```
|
|
118
|
+
|
|
119
|
+
## Migration
|
|
120
|
+
|
|
121
|
+
Hono integration now lives in `@ontrails/hono`.
|
|
122
|
+
|
|
123
|
+
<!-- warden-ignore-next-line -->
|
|
124
|
+
- Replace `import { trailhead } from '@ontrails/http/hono'` with `import { surface } from '@ontrails/hono'`
|
|
125
|
+
- Keep `deriveHttpRoutes()` and the route model imports on `@ontrails/http`
|
package/package.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/http",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.16",
|
|
4
|
+
"files": [
|
|
5
|
+
"src/**/*.ts",
|
|
6
|
+
"!src/**/__tests__/**",
|
|
7
|
+
"!src/**/*.test.ts",
|
|
8
|
+
"!src/**/*.test-d.ts",
|
|
9
|
+
"README.md",
|
|
10
|
+
"CHANGELOG.md"
|
|
11
|
+
],
|
|
4
12
|
"type": "module",
|
|
5
13
|
"exports": {
|
|
6
14
|
".": "./src/index.ts",
|
|
7
|
-
"./hono": "./src/hono/index.ts",
|
|
8
15
|
"./package.json": "./package.json"
|
|
9
16
|
},
|
|
10
17
|
"scripts": {
|
|
@@ -15,15 +22,9 @@
|
|
|
15
22
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
16
23
|
},
|
|
17
24
|
"dependencies": {
|
|
18
|
-
"@ontrails/core": "^1.0.0-beta.
|
|
25
|
+
"@ontrails/core": "^1.0.0-beta.15"
|
|
19
26
|
},
|
|
20
27
|
"peerDependencies": {
|
|
21
|
-
"hono": "^4.7.0",
|
|
22
28
|
"zod": "^4.3.5"
|
|
23
|
-
},
|
|
24
|
-
"peerDependenciesMeta": {
|
|
25
|
-
"hono": {
|
|
26
|
-
"optional": true
|
|
27
|
-
}
|
|
28
29
|
}
|
|
29
30
|
}
|