@telorun/http-server 0.16.1 → 0.17.1
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 +29 -0
- package/README.md +4 -4
- package/dist/http-api-controller.js +1 -1
- package/dist/http-server-controller.d.ts +1 -1
- package/dist/http-server-controller.js +2 -2
- package/package.json +3 -3
- package/src/http-api-controller.ts +1 -1
- package/src/http-server-controller.ts +4 -4
- package/tests/fastify-telo-logger.test.ts +1 -1
- package/tests/request-cancel.test.ts +1 -1
- package/tests/request-span.test.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @telorun/http-server
|
|
2
2
|
|
|
3
|
+
## 0.17.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [f3b044d]
|
|
8
|
+
- @telorun/http-dispatch@0.4.2
|
|
9
|
+
|
|
10
|
+
## 0.17.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 942c176: Rename `ctx.resolveChildren` to `ctx.ensureKindRef`. The old name stays as a
|
|
15
|
+
deprecated delegate.
|
|
16
|
+
|
|
17
|
+
The method never resolved anything: it takes a nested slot value — an inline
|
|
18
|
+
`{ kind, …config }` definition, a `{ kind, name }` ref, or a `!ref` sentinel —
|
|
19
|
+
and produces a `KindRef`, registering the inline case as a manifest (under a
|
|
20
|
+
supplied or generated name) on the way. `ensure` carries that create-if-needed
|
|
21
|
+
side effect; `KindRef` is what comes back.
|
|
22
|
+
|
|
23
|
+
It also reads correctly next to `ctx.resolveRef`, which runs the other direction
|
|
24
|
+
— ref to live instance. Two `resolve*` methods on one interface returning
|
|
25
|
+
opposite categories was the ambiguity; this fixes it at the source rather than
|
|
26
|
+
lengthening the name of the method that was right.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- @telorun/http-dispatch@0.4.1
|
|
31
|
+
|
|
3
32
|
## 0.16.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -27,8 +27,8 @@ Language- and framework-agnostic HTTP server for Telo. Declarative routes, schem
|
|
|
27
27
|
kind: Telo.Application
|
|
28
28
|
metadata: { name: hello-http, version: 1.0.0 }
|
|
29
29
|
imports:
|
|
30
|
-
Http: std/http-server
|
|
31
|
-
JS: std/javascript
|
|
30
|
+
Http: std/http-server@0.19.1
|
|
31
|
+
JS: std/javascript@0.7.0
|
|
32
32
|
targets: [ !ref Server ]
|
|
33
33
|
---
|
|
34
34
|
kind: Http.Server
|
|
@@ -56,7 +56,7 @@ routes:
|
|
|
56
56
|
description: Name to greet.
|
|
57
57
|
examples: [ "Ada" ]
|
|
58
58
|
inputs:
|
|
59
|
-
name: "
|
|
59
|
+
name: !cel "request.params.name"
|
|
60
60
|
handler: !ref Greet
|
|
61
61
|
returns:
|
|
62
62
|
- status: 200
|
|
@@ -69,7 +69,7 @@ routes:
|
|
|
69
69
|
type: string
|
|
70
70
|
description: The greeting.
|
|
71
71
|
examples: [ "Hello, Ada!" ]
|
|
72
|
-
body: { message: "
|
|
72
|
+
body: { message: !cel "result.message" }
|
|
73
73
|
---
|
|
74
74
|
kind: JS.Script
|
|
75
75
|
metadata: { name: Greet }
|
|
@@ -204,7 +204,7 @@ export async function create(resource, ctx) {
|
|
|
204
204
|
if (!h)
|
|
205
205
|
continue;
|
|
206
206
|
if (typeof h === "object") {
|
|
207
|
-
handlerRefs.set(route, ctx.
|
|
207
|
+
handlerRefs.set(route, ctx.ensureKindRef(h));
|
|
208
208
|
}
|
|
209
209
|
else if (typeof h === "string") {
|
|
210
210
|
// String form (schema oneOf: string | object) — only the resource name
|
|
@@ -2,7 +2,7 @@ import { CatchEntry, ReturnEntry } from "@telorun/http-dispatch";
|
|
|
2
2
|
import { type Invocable, type KindRef, type ResourceContext, type ResourceInstance, type RuntimeResource } from "@telorun/sdk";
|
|
3
3
|
import { FastifyInstance } from "fastify";
|
|
4
4
|
/** A mounted Telo.Mount instance (Http.Api, Mcp.HttpEndpoint, …). The kernel injects the
|
|
5
|
-
* live instance into a mount's `mount` slot (x-telo-ref
|
|
5
|
+
* live instance into a mount's `mount` slot (x-telo-ref `Telo.Mount`) — cross-module refs
|
|
6
6
|
* resolve to an imported library's exported mount — and every mountable exposes register(). */
|
|
7
7
|
interface Mountable {
|
|
8
8
|
register(app: FastifyInstance, prefix: string): void | Promise<void>;
|
|
@@ -189,7 +189,7 @@ class HttpServer {
|
|
|
189
189
|
for (const mount of mounts) {
|
|
190
190
|
const prefix = mount.path || "";
|
|
191
191
|
// `mount.mount` is the live Telo.Mount instance injected by the kernel at Phase 5
|
|
192
|
-
// (x-telo-ref
|
|
192
|
+
// (x-telo-ref `Telo.Mount`) — a same-module or imported-library mount, uniformly.
|
|
193
193
|
const api = mount.mount;
|
|
194
194
|
if (!api || typeof api.register !== "function") {
|
|
195
195
|
throw new Error(`Failed to mount at "${prefix}": mount target did not resolve to a Telo.Mount instance`);
|
|
@@ -285,7 +285,7 @@ export async function create(resource, ctx) {
|
|
|
285
285
|
let kind = "";
|
|
286
286
|
let name = "";
|
|
287
287
|
if (typeof invoke === "object" && invoke !== null) {
|
|
288
|
-
const resolved = ctx.
|
|
288
|
+
const resolved = ctx.ensureKindRef(invoke);
|
|
289
289
|
kind = resolved.kind;
|
|
290
290
|
name = resolved.name;
|
|
291
291
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/http-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Telo HTTP Server module - HTTP server and API resource kinds for Telo manifests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"telo",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"ajv": "^8.17.1",
|
|
50
50
|
"ajv-formats": "^3.0.1",
|
|
51
51
|
"fastify": "^5.7.2",
|
|
52
|
-
"@telorun/http-dispatch": "0.4.
|
|
52
|
+
"@telorun/http-dispatch": "0.4.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^20.0.0",
|
|
56
56
|
"typescript": "^5.0.0",
|
|
57
57
|
"vitest": "^2.1.8",
|
|
58
|
-
"@telorun/sdk": "0.
|
|
58
|
+
"@telorun/sdk": "0.56.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@telorun/sdk": "*"
|
|
@@ -266,7 +266,7 @@ export async function create(resource: any, ctx: ResourceContext): Promise<HttpS
|
|
|
266
266
|
const h = route.handler;
|
|
267
267
|
if (!h) continue;
|
|
268
268
|
if (typeof h === "object") {
|
|
269
|
-
handlerRefs.set(route, ctx.
|
|
269
|
+
handlerRefs.set(route, ctx.ensureKindRef(h));
|
|
270
270
|
} else if (typeof h === "string") {
|
|
271
271
|
// String form (schema oneOf: string | object) — only the resource name
|
|
272
272
|
// is given, not the kind. Phase 5 injects the live instance either way;
|
|
@@ -22,7 +22,7 @@ import Fastify, { FastifyInstance } from "fastify";
|
|
|
22
22
|
import { fastifyReplySink } from "./fastify-reply-sink.js";
|
|
23
23
|
|
|
24
24
|
/** A mounted Telo.Mount instance (Http.Api, Mcp.HttpEndpoint, …). The kernel injects the
|
|
25
|
-
* live instance into a mount's `mount` slot (x-telo-ref
|
|
25
|
+
* live instance into a mount's `mount` slot (x-telo-ref `Telo.Mount`) — cross-module refs
|
|
26
26
|
* resolve to an imported library's exported mount — and every mountable exposes register(). */
|
|
27
27
|
interface Mountable {
|
|
28
28
|
register(app: FastifyInstance, prefix: string): void | Promise<void>;
|
|
@@ -59,7 +59,7 @@ type HttpServerResource = RuntimeResource & {
|
|
|
59
59
|
};
|
|
60
60
|
mounts?: Array<{
|
|
61
61
|
path?: string;
|
|
62
|
-
// x-telo-ref
|
|
62
|
+
// x-telo-ref `Telo.Mount`: Phase 5 replaces this slot with the live mounted
|
|
63
63
|
// instance (Http.Api, Mcp.HttpEndpoint, …), local or imported.
|
|
64
64
|
mount?: Mountable;
|
|
65
65
|
}>;
|
|
@@ -270,7 +270,7 @@ class HttpServer implements ResourceInstance {
|
|
|
270
270
|
for (const mount of mounts) {
|
|
271
271
|
const prefix = mount.path || "";
|
|
272
272
|
// `mount.mount` is the live Telo.Mount instance injected by the kernel at Phase 5
|
|
273
|
-
// (x-telo-ref
|
|
273
|
+
// (x-telo-ref `Telo.Mount`) — a same-module or imported-library mount, uniformly.
|
|
274
274
|
const api = mount.mount;
|
|
275
275
|
if (!api || typeof api.register !== "function") {
|
|
276
276
|
throw new Error(
|
|
@@ -399,7 +399,7 @@ export async function create(
|
|
|
399
399
|
let kind = "";
|
|
400
400
|
let name = "";
|
|
401
401
|
if (typeof invoke === "object" && invoke !== null) {
|
|
402
|
-
const resolved = ctx.
|
|
402
|
+
const resolved = ctx.ensureKindRef(invoke);
|
|
403
403
|
kind = resolved.kind;
|
|
404
404
|
name = resolved.name;
|
|
405
405
|
} else if (typeof invoke === "string") {
|
|
@@ -81,7 +81,7 @@ describe("Http.Server boots with request logging enabled", () => {
|
|
|
81
81
|
return {
|
|
82
82
|
log,
|
|
83
83
|
args: { _: [] },
|
|
84
|
-
|
|
84
|
+
ensureKindRef: () => ({ kind: "Http.Api", name: "x" }),
|
|
85
85
|
moduleContext: { expandWith: (value: unknown) => value },
|
|
86
86
|
validateSchema: () => {},
|
|
87
87
|
} as never;
|
|
@@ -42,7 +42,7 @@ describe("http-server request cancellation", () => {
|
|
|
42
42
|
// Minimal ResourceContext: just the surface the controller touches.
|
|
43
43
|
const ctx = {
|
|
44
44
|
validateSchema: () => {},
|
|
45
|
-
|
|
45
|
+
ensureKindRef: () => ({ kind: "Test.Handler", name: "SlowWork" }),
|
|
46
46
|
moduleContext: { expandWith: (value: unknown) => value },
|
|
47
47
|
createCancellationSource: () => createCancellationSource(),
|
|
48
48
|
invokeResolved: (_kind: string, _name: string, h: typeof handler, input: unknown, c: unknown) =>
|
|
@@ -28,7 +28,7 @@ describe("http-server request span", () => {
|
|
|
28
28
|
|
|
29
29
|
const ctx = {
|
|
30
30
|
validateSchema: () => {},
|
|
31
|
-
|
|
31
|
+
ensureKindRef: () => ({ kind: "JS.Script", name: "Echo" }),
|
|
32
32
|
moduleContext: { expandWith: (value: unknown) => value },
|
|
33
33
|
createCancellationSource: () => createCancellationSource(),
|
|
34
34
|
invokeResolved: (_kind: string, _name: string, h: typeof handler, input: unknown) =>
|