@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/dist/build.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build framework-agnostic HTTP route definitions from a Trails topo.
|
|
3
|
-
*
|
|
4
|
-
* Each route definition describes the path, method, input source, and an
|
|
5
|
-
* `execute` function that validates input, composes gates, and runs the
|
|
6
|
-
* implementation -- all without referencing any HTTP framework types.
|
|
7
|
-
*/
|
|
8
|
-
import { Result, TRAILHEAD_KEY, ValidationError, executeTrail, validateEstablishedTopo, } from '@ontrails/core';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Internal helpers
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
/** Explicit intent → HTTP method mapping. */
|
|
13
|
-
const intentToMethod = {
|
|
14
|
-
destroy: 'DELETE',
|
|
15
|
-
read: 'GET',
|
|
16
|
-
write: 'POST',
|
|
17
|
-
};
|
|
18
|
-
/** Derive HTTP method from trail intent. */
|
|
19
|
-
const deriveMethod = (trail) => intentToMethod[trail.intent] ?? 'POST';
|
|
20
|
-
/** Derive HTTP path from trail ID: `entity.show` -> `/entity/show`. */
|
|
21
|
-
const derivePath = (basePath, trailId) => {
|
|
22
|
-
const segments = trailId.replaceAll('.', '/');
|
|
23
|
-
const base = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
|
|
24
|
-
return `${base}/${segments}`;
|
|
25
|
-
};
|
|
26
|
-
/** Derive input source from HTTP method. */
|
|
27
|
-
const deriveInputSource = (method) => method === 'GET' ? 'query' : 'body';
|
|
28
|
-
/** Check if a trail should be included (skip internal trails). */
|
|
29
|
-
const shouldInclude = (trail) => trail.meta?.['internal'] !== true;
|
|
30
|
-
/** Build per-request context overrides with the HTTP trailhead marker. */
|
|
31
|
-
const withHttpTrailhead = (requestId) => ({
|
|
32
|
-
...(requestId === undefined ? {} : { requestId }),
|
|
33
|
-
extensions: {
|
|
34
|
-
[TRAILHEAD_KEY]: 'http',
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
// Execute factory
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
/**
|
|
41
|
-
* Create an `execute` function for a single trail.
|
|
42
|
-
*
|
|
43
|
-
* Delegates to the centralized `executeTrail` pipeline in core.
|
|
44
|
-
* The returned function returns a `Result` and never throws.
|
|
45
|
-
*/
|
|
46
|
-
const createExecute = (t, gates, options) => (input, requestId, abortSignal) => executeTrail(t, input, {
|
|
47
|
-
abortSignal,
|
|
48
|
-
configValues: options.configValues,
|
|
49
|
-
createContext: options.createContext,
|
|
50
|
-
ctx: withHttpTrailhead(requestId),
|
|
51
|
-
gates,
|
|
52
|
-
provisions: options.provisions,
|
|
53
|
-
});
|
|
54
|
-
// ---------------------------------------------------------------------------
|
|
55
|
-
// Builder helpers
|
|
56
|
-
// ---------------------------------------------------------------------------
|
|
57
|
-
/** Filter topo items to eligible trails. */
|
|
58
|
-
const eligibleTrails = (app) => app.list().filter((trail) => shouldInclude(trail));
|
|
59
|
-
/** Build a single route definition from a trail. */
|
|
60
|
-
const buildRoute = (trail, basePath, gates, options) => {
|
|
61
|
-
const method = deriveMethod(trail);
|
|
62
|
-
const path = derivePath(basePath, trail.id);
|
|
63
|
-
return {
|
|
64
|
-
execute: createExecute(trail, gates, options),
|
|
65
|
-
inputSource: deriveInputSource(method),
|
|
66
|
-
method,
|
|
67
|
-
path,
|
|
68
|
-
trail,
|
|
69
|
-
trailId: trail.id,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
// ---------------------------------------------------------------------------
|
|
73
|
-
// Collision detection
|
|
74
|
-
// ---------------------------------------------------------------------------
|
|
75
|
-
/** Derive the lookup key for (method, path) collision detection. */
|
|
76
|
-
const routeKey = (route) => `${route.method} ${route.path}`;
|
|
77
|
-
/** Register a route, checking for (path, method) collisions. */
|
|
78
|
-
const registerRoute = (route, seenRoutes, routes) => {
|
|
79
|
-
const key = routeKey(route);
|
|
80
|
-
const existingId = seenRoutes.get(key);
|
|
81
|
-
if (existingId !== undefined) {
|
|
82
|
-
return Result.err(new ValidationError(`HTTP route collision: trails "${existingId}" and "${route.trailId}" both derive ${route.method} ${route.path}`));
|
|
83
|
-
}
|
|
84
|
-
seenRoutes.set(key, route.trailId);
|
|
85
|
-
routes.push(route);
|
|
86
|
-
return Result.ok();
|
|
87
|
-
};
|
|
88
|
-
/** Accumulate route definitions, returning early on the first collision. */
|
|
89
|
-
const accumulateRoutes = (trails, basePath, gates, options) => {
|
|
90
|
-
const routes = [];
|
|
91
|
-
const seenRoutes = new Map();
|
|
92
|
-
for (const trail of trails) {
|
|
93
|
-
const route = buildRoute(trail, basePath, gates, options);
|
|
94
|
-
const registered = registerRoute(route, seenRoutes, routes);
|
|
95
|
-
if (registered.isErr()) {
|
|
96
|
-
return registered;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return Result.ok(routes);
|
|
100
|
-
};
|
|
101
|
-
// ---------------------------------------------------------------------------
|
|
102
|
-
// Builder
|
|
103
|
-
// ---------------------------------------------------------------------------
|
|
104
|
-
/**
|
|
105
|
-
* Build HTTP route definitions from a topo.
|
|
106
|
-
*
|
|
107
|
-
* Each trail becomes an HttpRouteDefinition with:
|
|
108
|
-
* - An HTTP method derived from intent (read -> GET, write -> POST, destroy -> DELETE)
|
|
109
|
-
* - A path derived from the trail ID (dots become slashes)
|
|
110
|
-
* - An input source derived from the method (GET -> query, others -> body)
|
|
111
|
-
* - An `execute` function that validates, gates, and runs the implementation
|
|
112
|
-
*
|
|
113
|
-
* Returns `Result.err(ValidationError)` if two trails derive the same
|
|
114
|
-
* (method, path) pair. Returns `Result.ok(routes)` on success.
|
|
115
|
-
*/
|
|
116
|
-
export const buildHttpRoutes = (app, options = {}) => {
|
|
117
|
-
if (options.validate !== false) {
|
|
118
|
-
const validated = validateEstablishedTopo(app);
|
|
119
|
-
if (validated.isErr()) {
|
|
120
|
-
return Result.err(validated.error);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const basePath = (options.basePath ?? '').replace(/\/+$/, '');
|
|
124
|
-
const gates = options.gates ?? [];
|
|
125
|
-
return accumulateRoutes(eligibleTrails(app), basePath, gates, options);
|
|
126
|
-
};
|
|
127
|
-
//# sourceMappingURL=build.js.map
|
package/dist/build.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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,IAAI,OAAO,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,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.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hono adapter 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 blaze(app, { port: 3000 });
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
import type { Layer, ServiceOverrideMap, Topo, TrailContextInit } from '@ontrails/core';
|
|
13
|
-
import { Hono } from 'hono';
|
|
14
|
-
export interface BlazeHttpOptions {
|
|
15
|
-
readonly basePath?: string | undefined;
|
|
16
|
-
/** Config values for services that declare a `config` schema, keyed by service 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 layers?: readonly Layer[] | undefined;
|
|
21
|
-
readonly name?: string | undefined;
|
|
22
|
-
readonly port?: number | undefined;
|
|
23
|
-
readonly services?: ServiceOverrideMap | 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 blaze: (app: Topo, options?: BlazeHttpOptions) => Promise<Hono>;
|
|
33
|
-
//# sourceMappingURL=blaze.d.ts.map
|
package/dist/hono/blaze.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blaze.d.ts","sourceRoot":"","sources":["../../src/hono/blaze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,KAAK,EACL,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,sFAAsF;IACtF,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,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACnD,kEAAkE;IAClE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC;AAyQD;;GAEG;AAEH,eAAO,MAAM,KAAK,GAChB,KAAK,IAAI,EACT,UAAS,gBAAqB,KAC7B,OAAO,CAAC,IAAI,CA8Bd,CAAC"}
|
package/dist/hono/blaze.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hono adapter 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 blaze(app, { port: 3000 });
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
import { isTrailsError, statusCodeMap, validateTopo } from '@ontrails/core';
|
|
13
|
-
import { Hono } from 'hono';
|
|
14
|
-
import { buildHttpRoutes } from '../build.js';
|
|
15
|
-
/** Unwrap optional/default wrappers to reach the underlying Zod type name. */
|
|
16
|
-
const unwrapZodType = (node) => {
|
|
17
|
-
let current = node;
|
|
18
|
-
while (current._zod.def['type'] === 'optional' ||
|
|
19
|
-
current._zod.def['type'] === 'default') {
|
|
20
|
-
current = current._zod.def['innerType'];
|
|
21
|
-
}
|
|
22
|
-
return current._zod.def['type'];
|
|
23
|
-
};
|
|
24
|
-
/** Extract the object shape from a Zod schema, or undefined if not an object. */
|
|
25
|
-
const extractShape = (schema) => {
|
|
26
|
-
const s = schema;
|
|
27
|
-
if (s._zod.def['type'] !== 'object') {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
return s._zod.def['shape'];
|
|
31
|
-
};
|
|
32
|
-
/** Collect top-level field names whose underlying type is array. */
|
|
33
|
-
const collectArrayKeys = (inputSchema) => {
|
|
34
|
-
const shape = inputSchema ? extractShape(inputSchema) : undefined;
|
|
35
|
-
if (!shape) {
|
|
36
|
-
return new Set();
|
|
37
|
-
}
|
|
38
|
-
const keys = new Set();
|
|
39
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
40
|
-
if (unwrapZodType(value) === 'array') {
|
|
41
|
-
keys.add(key);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return keys;
|
|
45
|
-
};
|
|
46
|
-
/** Parse query params into a plain object, preserving raw strings for Zod. */
|
|
47
|
-
const parseQueryParams = (c, inputSchema) => {
|
|
48
|
-
const result = {};
|
|
49
|
-
const url = new URL(c.req.url);
|
|
50
|
-
const arrayKeys = collectArrayKeys(inputSchema);
|
|
51
|
-
for (const key of url.searchParams.keys()) {
|
|
52
|
-
// Already collected via getAll
|
|
53
|
-
if (key in result) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const all = url.searchParams.getAll(key);
|
|
57
|
-
result[key] = all.length > 1 || arrayKeys.has(key) ? all : all[0];
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
/** Sentinel indicating a JSON parse failure. */
|
|
62
|
-
const JSON_PARSE_ERROR = Symbol('JSON_PARSE_ERROR');
|
|
63
|
-
/** Return true when the request has no body content. */
|
|
64
|
-
const isEmptyBody = (c) => {
|
|
65
|
-
const contentLength = c.req.header('Content-Length');
|
|
66
|
-
if (contentLength !== undefined) {
|
|
67
|
-
return Number.parseInt(contentLength, 10) === 0;
|
|
68
|
-
}
|
|
69
|
-
// No Content-Length header — treat as empty when Content-Type is also absent.
|
|
70
|
-
return c.req.header('Content-Type') === undefined;
|
|
71
|
-
};
|
|
72
|
-
/** Read input from request based on input source. */
|
|
73
|
-
const readInput = async (c, inputSource, inputSchema) => {
|
|
74
|
-
if (inputSource === 'query') {
|
|
75
|
-
return parseQueryParams(c, inputSchema);
|
|
76
|
-
}
|
|
77
|
-
if (isEmptyBody(c)) {
|
|
78
|
-
return {};
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
return await c.req.json();
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return JSON_PARSE_ERROR;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
// ---------------------------------------------------------------------------
|
|
88
|
-
// Response mapping
|
|
89
|
-
// ---------------------------------------------------------------------------
|
|
90
|
-
/** Map a TrailsError or generic Error to an HTTP error response. */
|
|
91
|
-
const mapErrorResponse = (error) => {
|
|
92
|
-
if (isTrailsError(error)) {
|
|
93
|
-
return {
|
|
94
|
-
body: {
|
|
95
|
-
error: {
|
|
96
|
-
category: error.category,
|
|
97
|
-
code: error.name,
|
|
98
|
-
message: error.message,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
status: statusCodeMap[error.category],
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
body: {
|
|
106
|
-
error: {
|
|
107
|
-
category: 'internal',
|
|
108
|
-
code: 'InternalError',
|
|
109
|
-
message: error.message,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
status: 500,
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
116
|
-
// Route registration
|
|
117
|
-
// ---------------------------------------------------------------------------
|
|
118
|
-
/** Map a Result to an HTTP response via Hono context. */
|
|
119
|
-
const mapResultToResponse = (result, c) => {
|
|
120
|
-
if (result.isOk()) {
|
|
121
|
-
return c.json({ data: result.value }, 200);
|
|
122
|
-
}
|
|
123
|
-
const { body, status } = mapErrorResponse(result.error ?? new Error('Unknown error'));
|
|
124
|
-
return c.json(body, status);
|
|
125
|
-
};
|
|
126
|
-
/** Convert a caught unknown value to an error response. */
|
|
127
|
-
const handleCaughtError = (error, c) => {
|
|
128
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
129
|
-
const { body, status } = mapErrorResponse(err);
|
|
130
|
-
return c.json(body, status);
|
|
131
|
-
};
|
|
132
|
-
/** Create a Hono handler from a route definition. */
|
|
133
|
-
const createHonoHandler = (route) => async (c) => {
|
|
134
|
-
const rawInput = await readInput(c, route.inputSource, route.trail.input);
|
|
135
|
-
if (rawInput === JSON_PARSE_ERROR) {
|
|
136
|
-
return c.json({
|
|
137
|
-
error: {
|
|
138
|
-
category: 'validation',
|
|
139
|
-
code: 'ValidationError',
|
|
140
|
-
message: 'Invalid JSON in request body',
|
|
141
|
-
},
|
|
142
|
-
}, 400);
|
|
143
|
-
}
|
|
144
|
-
const requestId = c.req.header('X-Request-ID') ?? undefined;
|
|
145
|
-
const { signal: abortSignal } = c.req.raw;
|
|
146
|
-
try {
|
|
147
|
-
const result = await route.execute(rawInput, requestId, abortSignal);
|
|
148
|
-
return mapResultToResponse(result, c);
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
return handleCaughtError(error, c);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
/** Route registration keyed by HTTP method. */
|
|
155
|
-
const routeRegistrars = {
|
|
156
|
-
DELETE: (hono, path, handler) => {
|
|
157
|
-
hono.delete(path, handler);
|
|
158
|
-
},
|
|
159
|
-
GET: (hono, path, handler) => {
|
|
160
|
-
hono.get(path, handler);
|
|
161
|
-
},
|
|
162
|
-
POST: (hono, path, handler) => {
|
|
163
|
-
hono.post(path, handler);
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
const registerRoutes = (hono, routes) => {
|
|
167
|
-
for (const route of routes) {
|
|
168
|
-
const handler = createHonoHandler(route);
|
|
169
|
-
routeRegistrars[route.method](hono, route.path, handler);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
// ---------------------------------------------------------------------------
|
|
173
|
-
// Global error handler
|
|
174
|
-
// ---------------------------------------------------------------------------
|
|
175
|
-
const registerErrorHandler = (hono) => {
|
|
176
|
-
// oxlint-disable-next-line prefer-await-to-callbacks -- Hono's onError API requires a callback
|
|
177
|
-
hono.onError((err, c) => c.json({
|
|
178
|
-
error: {
|
|
179
|
-
category: 'internal',
|
|
180
|
-
code: 'InternalError',
|
|
181
|
-
message: err.message,
|
|
182
|
-
},
|
|
183
|
-
}, 500));
|
|
184
|
-
};
|
|
185
|
-
// ---------------------------------------------------------------------------
|
|
186
|
-
// Validation
|
|
187
|
-
// ---------------------------------------------------------------------------
|
|
188
|
-
/**
|
|
189
|
-
* Throw a ValidationError if the topo has structural issues.
|
|
190
|
-
* Pass `skip: true` to bypass validation (e.g. when `validate: false` is set).
|
|
191
|
-
*/
|
|
192
|
-
const assertValidTopo = (app, skip = false) => {
|
|
193
|
-
if (skip) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const validated = validateTopo(app);
|
|
197
|
-
if (validated.isErr()) {
|
|
198
|
-
throw validated.error;
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
// ---------------------------------------------------------------------------
|
|
202
|
-
// blaze
|
|
203
|
-
// ---------------------------------------------------------------------------
|
|
204
|
-
/**
|
|
205
|
-
* Build HTTP routes from a topo, create a Hono app, and optionally start serving.
|
|
206
|
-
*/
|
|
207
|
-
// oxlint-disable-next-line require-await -- async for consistency with other blaze() surfaces
|
|
208
|
-
export const blaze = async (app, options = {}) => {
|
|
209
|
-
assertValidTopo(app, options.validate === false);
|
|
210
|
-
const hono = new Hono();
|
|
211
|
-
registerErrorHandler(hono);
|
|
212
|
-
const routesResult = buildHttpRoutes(app, {
|
|
213
|
-
basePath: options.basePath,
|
|
214
|
-
configValues: options.configValues,
|
|
215
|
-
createContext: options.createContext,
|
|
216
|
-
layers: options.layers,
|
|
217
|
-
services: options.services,
|
|
218
|
-
});
|
|
219
|
-
if (routesResult.isErr()) {
|
|
220
|
-
throw routesResult.error;
|
|
221
|
-
}
|
|
222
|
-
registerRoutes(hono, routesResult.value);
|
|
223
|
-
if (options.serve !== false) {
|
|
224
|
-
Bun.serve({
|
|
225
|
-
fetch: hono.fetch,
|
|
226
|
-
hostname: options.hostname ?? '0.0.0.0',
|
|
227
|
-
port: options.port ?? 3000,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
return hono;
|
|
231
|
-
};
|
|
232
|
-
//# sourceMappingURL=blaze.js.map
|
package/dist/hono/blaze.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blaze.js","sourceRoot":"","sources":["../../src/hono/blaze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAO5E,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAM5B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwC9C,8EAA8E;AAC9E,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE;IAC7C,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,OACG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAY,KAAK,UAAU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AK,CAAC,CAAC;IAEzC,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;QAC5B,GAAG,CAAC,KAAK,CAAC;YACR,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;YACvC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/dist/hono/index.d.ts
DELETED
package/dist/hono/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
package/dist/hono/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,gBAAgB,CAAC"}
|
package/dist/hono/trailhead.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
* Topo validation runs before route construction — pass `validate: false`
|
|
33
|
-
* to skip it (e.g. during hot-reload or progressive startup).
|
|
34
|
-
*/
|
|
35
|
-
export declare const trailhead: (app: Topo, options?: TrailheadHttpOptions) => Promise<Hono>;
|
|
36
|
-
//# sourceMappingURL=trailhead.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,C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