@ontrails/http 1.0.0-beta.12 → 1.0.0-beta.13
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 +51 -23
- package/README.md +10 -10
- package/dist/build.d.ts +9 -9
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +18 -18
- package/dist/build.js.map +1 -1
- package/dist/hono/blaze.js +2 -2
- package/dist/hono/blaze.js.map +1 -1
- package/dist/hono/index.d.ts +1 -1
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +1 -1
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/trailhead.d.ts +33 -0
- package/dist/hono/trailhead.d.ts.map +1 -0
- package/dist/hono/trailhead.js +232 -0
- package/dist/hono/trailhead.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/build.test.ts +45 -44
- package/src/build.ts +27 -27
- package/src/hono/__tests__/{blaze.test.ts → trailhead.test.ts} +79 -77
- package/src/hono/index.ts +1 -1
- package/src/hono/{blaze.ts → trailhead.ts} +16 -16
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
# @ontrails/http
|
|
2
2
|
|
|
3
|
-
## 1.0.0-beta.
|
|
3
|
+
## 1.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Trail-native vocabulary cutover. Breaking API field renames across all packages:
|
|
8
|
+
|
|
9
|
+
- Trail spec: `run:` → `blaze:`, `follow:` → `crosses:`, `services:` → `provisions:`, `metadata:` → `meta:`, `emits:` → `signals:`
|
|
10
|
+
- Runtime: `ctx.follow()` → `ctx.cross()`, `ctx.emit()` → `ctx.signal()`, `ctx.signal` (abort) → `ctx.abortSignal`
|
|
11
|
+
- Entry points: `blaze(app)` → `trailhead(app)`
|
|
12
|
+
- Package rename: `@ontrails/crumbs` → `@ontrails/tracker`
|
|
13
|
+
- Wrapper types: `Layer` → `Gate`, `layers`/`middleware` → `gates`
|
|
14
|
+
- Transport: `surface` → `trailhead`, `adapter` → `connector`
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
6
17
|
|
|
7
|
-
- Complete trifecta for config, permits, and
|
|
18
|
+
- 6944147: Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
8
19
|
|
|
9
|
-
- **config**: Add `
|
|
20
|
+
- **config**: Add `configProvision`, `configGate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
10
21
|
- **permits**: Add `authService` and `auth.verify` trail for runtime authorization checks
|
|
11
|
-
- **
|
|
22
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured signal tracking
|
|
23
|
+
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
24
|
+
- **testing**: Expand test context helpers and example-based testing utilities
|
|
25
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [6944147]
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @ontrails/core@1.0.0-beta.13
|
|
30
|
+
|
|
31
|
+
## 1.0.0-beta.12
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
36
|
+
|
|
37
|
+
- **config**: Add `configProvision`, `config.gate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
38
|
+
- **permits**: Add `authProvision` and `auth.verify` trail for runtime authorization checks
|
|
39
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured event tracking
|
|
12
40
|
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
13
41
|
- **testing**: Expand test context helpers and example-based testing utilities
|
|
14
|
-
- **core/mcp/http**: Internal alignment for
|
|
42
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
15
43
|
|
|
16
44
|
- Updated dependencies
|
|
17
45
|
- @ontrails/core@1.0.0-beta.12
|
|
@@ -20,21 +48,21 @@
|
|
|
20
48
|
|
|
21
49
|
### Patch Changes
|
|
22
50
|
|
|
23
|
-
- Add
|
|
51
|
+
- Add provisions as a first-class primitive.
|
|
24
52
|
|
|
25
|
-
|
|
53
|
+
Provisions make infrastructure dependencies declarative, injectable, and governable. Define a provision with `provision()`, declare it on a trail with `provisions: [db]`, and access it with `db.from(ctx)` or `ctx.provision()`.
|
|
26
54
|
|
|
27
|
-
**Core:** `
|
|
55
|
+
**Core:** `provision()` factory, `ProvisionSpec<T>`, `ProvisionContext`, singleton resolution in `executeTrail`, in-flight creation dedup, `isProvision` guard, `findDuplicateProvisionId`, topo provision discovery and validation, `provisions` field on trail specs.
|
|
28
56
|
|
|
29
|
-
**Testing:** Auto-resolution of `mock` factories in `testAll`, `testExamples`, `testContracts`, and `
|
|
57
|
+
**Testing:** Auto-resolution of `mock` factories in `testAll`, `testExamples`, `testContracts`, and `testCrosses`. Explicit `provisions` overrides with correct precedence (`explicit > ctx.extensions > auto-mock`). Provision mock propagation through crossing graphs.
|
|
30
58
|
|
|
31
|
-
**Warden:** `
|
|
59
|
+
**Warden:** `provision-declarations` rule validates `db.from(ctx)` and `ctx.provision()` usage matches declared `provisions: [...]`. `provision-exists` rule validates declared provision IDs resolve in project context. Scope-aware AST walking skips nested function boundaries.
|
|
32
60
|
|
|
33
|
-
**
|
|
61
|
+
**Trailheads:** Provision overrides thread through `run` and `trailhead` on CLI, MCP, and HTTP.
|
|
34
62
|
|
|
35
|
-
**Introspection:** Survey and
|
|
63
|
+
**Introspection:** Survey and trailhead map outputs include provision graph. Topo exposes `.provisions`, `.getProvision()`, `.hasProvision()`, `.listProvisions()`, `.provisionIds()`, `.provisionCount`.
|
|
36
64
|
|
|
37
|
-
**Docs:** ADR-009 accepted. Unified
|
|
65
|
+
**Docs:** ADR-009 accepted. Unified provisions guide, updated vocabulary, getting-started, architecture, and package READMEs.
|
|
38
66
|
|
|
39
67
|
- Updated dependencies
|
|
40
68
|
- @ontrails/core@1.0.0-beta.11
|
|
@@ -45,13 +73,13 @@
|
|
|
45
73
|
|
|
46
74
|
- Cleanup and hardening pass across all packages.
|
|
47
75
|
|
|
48
|
-
**core**: Deduplicate `DispatchOptions` as type alias of `ExecuteTrailOptions`. Replace `TrailContext` index signature with typed `extensions` field for type safety. Deep-merge `extensions` in `executeTrail` context resolution. Remove unused `
|
|
76
|
+
**core**: Deduplicate `DispatchOptions` as type alias of `ExecuteTrailOptions`. Replace `TrailContext` index signature with typed `extensions` field for type safety. Deep-merge `extensions` in `executeTrail` context resolution. Remove unused `Trailhead` type, `connectors.ts`, `health.ts`, and `job.ts` proof-of-concept from published package.
|
|
49
77
|
|
|
50
|
-
**cli**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
78
|
+
**cli**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out via `validate: false`.
|
|
51
79
|
|
|
52
|
-
**http**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
80
|
+
**http**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out.
|
|
53
81
|
|
|
54
|
-
**mcp**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `
|
|
82
|
+
**mcp**: Remove vestigial `kind` checks from build. Run `validateTopo()` automatically in `trailhead()` with opt-out.
|
|
55
83
|
|
|
56
84
|
**warden**: Project-aware rule context preserved in trail wrappers.
|
|
57
85
|
|
|
@@ -62,9 +90,9 @@
|
|
|
62
90
|
|
|
63
91
|
### Minor Changes
|
|
64
92
|
|
|
65
|
-
- Consolidated improvements across all
|
|
93
|
+
- Consolidated improvements across all trailhead packages.
|
|
66
94
|
|
|
67
|
-
**core**: Add `TrailResult<T>` utility type, `topo.ids()` and `topo.count` accessors, `
|
|
95
|
+
**core**: Add `TrailResult<T>` utility type, `topo.ids()` and `topo.count` accessors, `run()` for headless trail execution, and extract shared `executeTrail` pipeline used by CLI/MCP/HTTP.
|
|
68
96
|
|
|
69
97
|
**http**: Detect route path collisions and return `Result` from `buildHttpRoutes()`, wire request `AbortSignal` through to trail context, and make write → POST mapping explicit in intent-to-method lookup.
|
|
70
98
|
|
|
@@ -72,7 +100,7 @@
|
|
|
72
100
|
|
|
73
101
|
**cli**: Verify exception catching via centralized `executeTrail`.
|
|
74
102
|
|
|
75
|
-
**testing**:
|
|
103
|
+
**testing**: Cross-context awareness improvements.
|
|
76
104
|
|
|
77
105
|
**warden**: Refactor rules as composable trails with examples.
|
|
78
106
|
|
|
@@ -89,7 +117,7 @@
|
|
|
89
117
|
|
|
90
118
|
- Restructure HTTP package and fix Codex review findings.
|
|
91
119
|
|
|
92
|
-
**http**: BREAKING — `
|
|
120
|
+
**http**: BREAKING — `trailhead()` moved to `@ontrails/http/hono` subpath. Hono is now a peer dependency. `buildHttpRoutes()` is framework-agnostic. Fixed: malformed JSON → 400, execute() never throws, query parsing preserves raw strings and supports arrays.
|
|
93
121
|
|
|
94
122
|
**schema**: OpenAPI 200 response wraps in `{ data }` envelope matching wire format. Always includes 400 ValidationError with error schema. basePath trailing slash normalized.
|
|
95
123
|
|
|
@@ -101,9 +129,9 @@
|
|
|
101
129
|
|
|
102
130
|
### Minor Changes
|
|
103
131
|
|
|
104
|
-
- HTTP
|
|
132
|
+
- HTTP trailhead and OpenAPI generation.
|
|
105
133
|
|
|
106
|
-
**http**: New `@ontrails/http` package — Hono-based HTTP
|
|
134
|
+
**http**: New `@ontrails/http` package — Hono-based HTTP connector. `trailhead()` derives routes from trail IDs, maps intent to HTTP verbs (read→GET, write→POST, destroy→DELETE), and maps error taxonomy to status codes. Returns the Hono instance.
|
|
107
135
|
|
|
108
136
|
**schema**: Add `generateOpenApiSpec(topo)` — generates a complete OpenAPI 3.1 spec from the topo. Each trail becomes an operation with path, method, schemas, and error responses derived from the contract.
|
|
109
137
|
|
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
# @ontrails/http
|
|
2
2
|
|
|
3
|
-
HTTP
|
|
3
|
+
HTTP trailhead connector. One `trailhead()` call turns a topo into a Hono-based HTTP server with routes, input validation, and error mapping -- all derived from the trail contracts.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
8
|
import { trail, topo, Result } from '@ontrails/core';
|
|
9
|
-
import {
|
|
9
|
+
import { trailhead } from '@ontrails/http/hono';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
|
|
12
12
|
const greet = trail('greet', {
|
|
13
13
|
input: z.object({ name: z.string().describe('Who to greet') }),
|
|
14
14
|
output: z.object({ message: z.string() }),
|
|
15
15
|
intent: 'read',
|
|
16
|
-
|
|
16
|
+
blaze: (input) => Result.ok({ message: `Hello, ${input.name}!` }),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const app = topo('myapp', { greet });
|
|
20
|
-
await
|
|
20
|
+
await trailhead(app, { 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'`.
|
|
@@ -41,7 +41,7 @@ for (const route of result.value) {
|
|
|
41
41
|
| Export | What it does |
|
|
42
42
|
| --- | --- |
|
|
43
43
|
| `buildHttpRoutes(app, options?)` | Build framework-agnostic route definitions from a topo |
|
|
44
|
-
| `
|
|
44
|
+
| `trailhead(app, options?)` (`@ontrails/http/hono`) | Start a Hono HTTP server with all trails as routes |
|
|
45
45
|
|
|
46
46
|
## Route derivation
|
|
47
47
|
|
|
@@ -58,15 +58,15 @@ Trail IDs map to paths: `entity.show` becomes `/entity/show`. Dots become slashe
|
|
|
58
58
|
|
|
59
59
|
## Collision detection
|
|
60
60
|
|
|
61
|
-
`buildHttpRoutes` detects when two trails would produce the same `(method, path)` pair and returns `Result.err(ValidationError)` describing both trail IDs. The `
|
|
61
|
+
`buildHttpRoutes` detects when two trails would produce the same `(method, path)` pair and returns `Result.err(ValidationError)` describing both trail IDs. The `trailhead()` Hono connector throws on collision.
|
|
62
62
|
|
|
63
|
-
##
|
|
63
|
+
## Provision resolution
|
|
64
64
|
|
|
65
|
-
Declared
|
|
65
|
+
Declared provisions on each trail are resolved into the context before the implementation runs.
|
|
66
66
|
|
|
67
67
|
## AbortSignal propagation
|
|
68
68
|
|
|
69
|
-
The `execute` function on each `HttpRouteDefinition` accepts an optional `
|
|
69
|
+
The `execute` function on each `HttpRouteDefinition` accepts an optional `abortSignal`. The Hono connector extracts `signal` from `c.req.raw` and forwards it as `abortSignal`, so client disconnects propagate into trail execution.
|
|
70
70
|
|
|
71
71
|
## `HttpRouteDefinition`
|
|
72
72
|
|
|
@@ -79,7 +79,7 @@ Each route definition produced by `buildHttpRoutes` includes:
|
|
|
79
79
|
| `trailId` | `string` | The trail ID this route was derived from |
|
|
80
80
|
| `inputSource` | `'query' \| 'body'` | Where to read input |
|
|
81
81
|
| `trail` | `Trail` | The original trail definition |
|
|
82
|
-
| `execute` | `(input, requestId?,
|
|
82
|
+
| `execute` | `(input, requestId?, abortSignal?) => Promise<Result>` | Validates, gates, and runs the implementation |
|
|
83
83
|
|
|
84
84
|
## Installation
|
|
85
85
|
|
package/dist/build.d.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* Build framework-agnostic HTTP route definitions from a Trails topo.
|
|
3
3
|
*
|
|
4
4
|
* Each route definition describes the path, method, input source, and an
|
|
5
|
-
* `execute` function that validates input, composes
|
|
5
|
+
* `execute` function that validates input, composes gates, and runs the
|
|
6
6
|
* implementation -- all without referencing any HTTP framework types.
|
|
7
7
|
*/
|
|
8
8
|
import { Result } from '@ontrails/core';
|
|
9
|
-
import type {
|
|
9
|
+
import type { Gate, ProvisionOverrideMap, Topo, Trail, TrailContextInit } from '@ontrails/core';
|
|
10
10
|
export interface BuildHttpRoutesOptions {
|
|
11
11
|
readonly basePath?: string | undefined;
|
|
12
|
-
/** Config values for
|
|
12
|
+
/** Config values for provisions that declare a `config` schema, keyed by provision ID. */
|
|
13
13
|
readonly configValues?: Readonly<Record<string, Record<string, unknown>>> | undefined;
|
|
14
14
|
readonly createContext?: (() => TrailContextInit | Promise<TrailContextInit>) | undefined;
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
15
|
+
readonly gates?: readonly Gate[] | undefined;
|
|
16
|
+
readonly provisions?: ProvisionOverrideMap | undefined;
|
|
17
17
|
}
|
|
18
18
|
export type HttpMethod = 'GET' | 'POST' | 'DELETE';
|
|
19
19
|
/** Input source derived from the HTTP method. */
|
|
@@ -25,16 +25,16 @@ export interface HttpRouteDefinition {
|
|
|
25
25
|
readonly inputSource: InputSource;
|
|
26
26
|
readonly trail: Trail<unknown, unknown>;
|
|
27
27
|
/**
|
|
28
|
-
* Validate input, compose
|
|
28
|
+
* Validate input, compose gates, and execute the trail implementation.
|
|
29
29
|
*
|
|
30
30
|
* The caller is responsible for parsing raw input from the request and
|
|
31
31
|
* mapping the Result to an HTTP response. This function is framework-agnostic.
|
|
32
32
|
*
|
|
33
|
-
* @param
|
|
33
|
+
* @param abortSignal - Optional AbortSignal from the HTTP request. When provided,
|
|
34
34
|
* it takes final precedence over any context factory signal, allowing
|
|
35
35
|
* client-initiated cancellation to propagate into trail execution.
|
|
36
36
|
*/
|
|
37
|
-
readonly execute: (input: unknown, requestId?: string | undefined,
|
|
37
|
+
readonly execute: (input: unknown, requestId?: string | undefined, abortSignal?: AbortSignal | undefined) => Promise<Result<unknown, Error>>;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Build HTTP route definitions from a topo.
|
|
@@ -43,7 +43,7 @@ export interface HttpRouteDefinition {
|
|
|
43
43
|
* - An HTTP method derived from intent (read -> GET, write -> POST, destroy -> DELETE)
|
|
44
44
|
* - A path derived from the trail ID (dots become slashes)
|
|
45
45
|
* - An input source derived from the method (GET -> query, others -> body)
|
|
46
|
-
* - An `execute` function that validates,
|
|
46
|
+
* - An `execute` function that validates, gates, and runs the implementation
|
|
47
47
|
*
|
|
48
48
|
* Returns `Result.err(ValidationError)` if two trails derive the same
|
|
49
49
|
* (method, path) pair. Returns `Result.ok(routes)` on success.
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EAIP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EAIP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,IAAI,EACJ,oBAAoB,EACpB,IAAI,EACJ,KAAK,EACL,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,CAAC,EAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GACjD,SAAS,CAAC;IACd,QAAQ,CAAC,aAAa,CAAC,EACnB,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,GACpD,SAAS,CAAC;IACd,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;CACxD;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEnD,iDAAiD;AACjD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,EAAE,CAChB,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,KAClC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;CACtC;AAoJD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,IAAI,EACT,UAAS,sBAA2B,KACnC,MAAM,CAAC,mBAAmB,EAAE,EAAE,KAAK,CAIrC,CAAC"}
|
package/dist/build.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Build framework-agnostic HTTP route definitions from a Trails topo.
|
|
3
3
|
*
|
|
4
4
|
* Each route definition describes the path, method, input source, and an
|
|
5
|
-
* `execute` function that validates input, composes
|
|
5
|
+
* `execute` function that validates input, composes gates, and runs the
|
|
6
6
|
* implementation -- all without referencing any HTTP framework types.
|
|
7
7
|
*/
|
|
8
|
-
import { Result,
|
|
8
|
+
import { Result, TRAILHEAD_KEY, ValidationError, executeTrail, } from '@ontrails/core';
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
10
10
|
// Internal helpers
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
@@ -26,12 +26,12 @@ const derivePath = (basePath, trailId) => {
|
|
|
26
26
|
/** Derive input source from HTTP method. */
|
|
27
27
|
const deriveInputSource = (method) => method === 'GET' ? 'query' : 'body';
|
|
28
28
|
/** Check if a trail should be included (skip internal trails). */
|
|
29
|
-
const shouldInclude = (trail) => trail.
|
|
30
|
-
/** Build per-request context overrides with the HTTP
|
|
31
|
-
const
|
|
29
|
+
const shouldInclude = (trail) => trail.meta?.['internal'] !== true;
|
|
30
|
+
/** Build per-request context overrides with the HTTP trailhead marker. */
|
|
31
|
+
const withHttpTrailhead = (requestId) => ({
|
|
32
32
|
...(requestId === undefined ? {} : { requestId }),
|
|
33
33
|
extensions: {
|
|
34
|
-
[
|
|
34
|
+
[TRAILHEAD_KEY]: 'http',
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
// ---------------------------------------------------------------------------
|
|
@@ -43,13 +43,13 @@ const withHttpSurface = (requestId) => ({
|
|
|
43
43
|
* Delegates to the centralized `executeTrail` pipeline in core.
|
|
44
44
|
* The returned function returns a `Result` and never throws.
|
|
45
45
|
*/
|
|
46
|
-
const createExecute = (t,
|
|
46
|
+
const createExecute = (t, gates, options) => (input, requestId, abortSignal) => executeTrail(t, input, {
|
|
47
|
+
abortSignal,
|
|
47
48
|
configValues: options.configValues,
|
|
48
49
|
createContext: options.createContext,
|
|
49
|
-
ctx:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
signal,
|
|
50
|
+
ctx: withHttpTrailhead(requestId),
|
|
51
|
+
gates,
|
|
52
|
+
provisions: options.provisions,
|
|
53
53
|
});
|
|
54
54
|
// ---------------------------------------------------------------------------
|
|
55
55
|
// Builder helpers
|
|
@@ -57,11 +57,11 @@ const createExecute = (t, layers, options) => (input, requestId, signal) => exec
|
|
|
57
57
|
/** Filter topo items to eligible trails. */
|
|
58
58
|
const eligibleTrails = (app) => app.list().filter((trail) => shouldInclude(trail));
|
|
59
59
|
/** Build a single route definition from a trail. */
|
|
60
|
-
const buildRoute = (trail, basePath,
|
|
60
|
+
const buildRoute = (trail, basePath, gates, options) => {
|
|
61
61
|
const method = deriveMethod(trail);
|
|
62
62
|
const path = derivePath(basePath, trail.id);
|
|
63
63
|
return {
|
|
64
|
-
execute: createExecute(trail,
|
|
64
|
+
execute: createExecute(trail, gates, options),
|
|
65
65
|
inputSource: deriveInputSource(method),
|
|
66
66
|
method,
|
|
67
67
|
path,
|
|
@@ -86,11 +86,11 @@ const registerRoute = (route, seenRoutes, routes) => {
|
|
|
86
86
|
return Result.ok();
|
|
87
87
|
};
|
|
88
88
|
/** Accumulate route definitions, returning early on the first collision. */
|
|
89
|
-
const accumulateRoutes = (trails, basePath,
|
|
89
|
+
const accumulateRoutes = (trails, basePath, gates, options) => {
|
|
90
90
|
const routes = [];
|
|
91
91
|
const seenRoutes = new Map();
|
|
92
92
|
for (const trail of trails) {
|
|
93
|
-
const route = buildRoute(trail, basePath,
|
|
93
|
+
const route = buildRoute(trail, basePath, gates, options);
|
|
94
94
|
const registered = registerRoute(route, seenRoutes, routes);
|
|
95
95
|
if (registered.isErr()) {
|
|
96
96
|
return registered;
|
|
@@ -108,14 +108,14 @@ const accumulateRoutes = (trails, basePath, layers, options) => {
|
|
|
108
108
|
* - An HTTP method derived from intent (read -> GET, write -> POST, destroy -> DELETE)
|
|
109
109
|
* - A path derived from the trail ID (dots become slashes)
|
|
110
110
|
* - An input source derived from the method (GET -> query, others -> body)
|
|
111
|
-
* - An `execute` function that validates,
|
|
111
|
+
* - An `execute` function that validates, gates, and runs the implementation
|
|
112
112
|
*
|
|
113
113
|
* Returns `Result.err(ValidationError)` if two trails derive the same
|
|
114
114
|
* (method, path) pair. Returns `Result.ok(routes)` on success.
|
|
115
115
|
*/
|
|
116
116
|
export const buildHttpRoutes = (app, options = {}) => {
|
|
117
117
|
const basePath = (options.basePath ?? '').replace(/\/+$/, '');
|
|
118
|
-
const
|
|
119
|
-
return accumulateRoutes(eligibleTrails(app), basePath,
|
|
118
|
+
const gates = options.gates ?? [];
|
|
119
|
+
return accumulateRoutes(eligibleTrails(app), basePath, gates, options);
|
|
120
120
|
};
|
|
121
121
|
//# sourceMappingURL=build.js.map
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,aAAa,EACb,eAAe,EACf,YAAY,GACb,MAAM,gBAAgB,CAAC;AAsDxB,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,6CAA6C;AAC7C,MAAM,cAAc,GAA+B;IACjD,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,MAAM;CACd,CAAC;AAEF,4CAA4C;AAC5C,MAAM,YAAY,GAAG,CAAC,KAA8B,EAAc,EAAE,CAClE,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC;AAEzC,uEAAuE;AACvE,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAU,EAAE;IAC/D,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACvE,OAAO,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEF,4CAA4C;AAC5C,MAAM,iBAAiB,GAAG,CAAC,MAAkB,EAAe,EAAE,CAC5D,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AAEtC,kEAAkE;AAClE,MAAM,aAAa,GAAG,CAAC,KAA8B,EAAW,EAAE,CAChE,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,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C,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1D,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;YACvB,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,GAAS,EACT,UAAkC,EAAE,EACE,EAAE;IACxC,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;IAClC,OAAO,gBAAgB,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC,CAAC"}
|
package/dist/hono/blaze.js
CHANGED
|
@@ -142,9 +142,9 @@ const createHonoHandler = (route) => async (c) => {
|
|
|
142
142
|
}, 400);
|
|
143
143
|
}
|
|
144
144
|
const requestId = c.req.header('X-Request-ID') ?? undefined;
|
|
145
|
-
const { signal } = c.req.raw;
|
|
145
|
+
const { signal: abortSignal } = c.req.raw;
|
|
146
146
|
try {
|
|
147
|
-
const result = await route.execute(rawInput, requestId,
|
|
147
|
+
const result = await route.execute(rawInput, requestId, abortSignal);
|
|
148
148
|
return mapResultToResponse(result, c);
|
|
149
149
|
}
|
|
150
150
|
catch (error) {
|
package/dist/hono/blaze.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blaze.js","sourceRoot":"","sources":["../../src/hono/blaze.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MappingURL=index.d.ts.map
|
package/dist/hono/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/hono/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { trailhead } from './trailhead.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/hono/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hono connector for Trails HTTP routes.
|
|
3
|
+
*
|
|
4
|
+
* Takes framework-agnostic HttpRouteDefinition[] and wires them into a
|
|
5
|
+
* Hono application, handling request parsing, response mapping, and errors.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const app = topo("myapp", entity);
|
|
9
|
+
* await trailhead(app, { port: 3000 });
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
import type { Gate, ProvisionOverrideMap, Topo, TrailContextInit } from '@ontrails/core';
|
|
13
|
+
import { Hono } from 'hono';
|
|
14
|
+
export interface TrailheadHttpOptions {
|
|
15
|
+
readonly basePath?: string | undefined;
|
|
16
|
+
/** Config values for provisions that declare a `config` schema, keyed by provision ID. */
|
|
17
|
+
readonly configValues?: Readonly<Record<string, Record<string, unknown>>> | undefined;
|
|
18
|
+
readonly createContext?: (() => TrailContextInit | Promise<TrailContextInit>) | undefined;
|
|
19
|
+
readonly hostname?: string | undefined;
|
|
20
|
+
readonly gates?: readonly Gate[] | undefined;
|
|
21
|
+
readonly name?: string | undefined;
|
|
22
|
+
readonly port?: number | undefined;
|
|
23
|
+
readonly provisions?: ProvisionOverrideMap | undefined;
|
|
24
|
+
/** Set false to return the Hono app without starting a server. */
|
|
25
|
+
readonly serve?: boolean | undefined;
|
|
26
|
+
/** Set to `false` to skip topo validation at startup. Defaults to `true`. */
|
|
27
|
+
readonly validate?: boolean | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build HTTP routes from a topo, create a Hono app, and optionally start serving.
|
|
31
|
+
*/
|
|
32
|
+
export declare const trailhead: (app: Topo, options?: TrailheadHttpOptions) => Promise<Hono>;
|
|
33
|
+
//# sourceMappingURL=trailhead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trailhead.d.ts","sourceRoot":"","sources":["../../src/hono/trailhead.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,IAAI,EACJ,oBAAoB,EACpB,IAAI,EACJ,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,CAAC,EAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GACjD,SAAS,CAAC;IACd,QAAQ,CAAC,aAAa,CAAC,EACnB,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,GACpD,SAAS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