@telorun/http-server 0.14.0 → 0.14.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @telorun/http-server
2
2
 
3
+ ## 0.14.1
4
+
5
+ ### Patch Changes
6
+
7
+ - dded615: Templated definitions can now produce a mountable HTTP surface, and their dispatch targets are created once instead of per call.
8
+
9
+ - **`mount:` template dispatch** — a `Telo.Definition` with `capability: Telo.Mount` may declare `mount: <child>` (sibling to `invoke:` / `run:` / `provide:`) naming a `resources:` entry that is itself a `Telo.Mount` (e.g. an `Http.Api`). The template instance's `register()` delegates to that persistent child, so a library can ship a self-contained, declarative HTTP resource. The analyzer validates the new field (`MOUNT_ON_NON_MOUNT`, `MOUNT_DISPATCHER_CONFLICT`, `MOUNT_TARGET_UNKNOWN`, `MOUNT_TARGET_NOT_MOUNTABLE`).
10
+ - **Persistent dispatch targets** — the template controller no longer re-creates its `invoke:` / `run:` / `provide:` target on every call (`withEphemeral` is removed). Every `resources:` entry is created once at `init()` and reused; per-call data flows exclusively through the top-level `inputs:` sibling. A resource body may reference only `self`; `${{ inputs.* }}` inside a target body is no longer supported (move it to the top-level `inputs:`).
11
+ - **Library-scoped child resolution** — a template's `resources:` are spawned in a child context rooted on the _defining_ library's module context (new `EvaluationContext.spawnChildContext()`), so their internal kind aliases and `!ref`s resolve against the library's own imports rather than the consumer's.
12
+ - **http-server** — a route declared at `/` now sits at the mount root (`/todos` + `/` → `/todos`) instead of a trailing-slash variant Fastify treats as a distinct, unmatched URL, so collection-style mounts respond at the mount path itself.
13
+ - @telorun/http-dispatch@0.4.1
14
+
3
15
  ## 0.14.0
4
16
 
5
17
  ### Minor Changes
@@ -55,7 +55,7 @@ export class HttpServerApi {
55
55
  const handlerRef = this.handlerRefs.get(route);
56
56
  const handlerKind = handlerRef?.kind ?? "";
57
57
  const handlerName = handlerRef?.name ?? "";
58
- const translatedPath = prefix + translateOpenApiPath(route.request.path);
58
+ const translatedPath = joinMountPath(prefix, translateOpenApiPath(route.request.path));
59
59
  const schema = { response: {} };
60
60
  // A stream-marked body is delivered as a raw `Stream<Uint8Array>` (see the
61
61
  // server's `contentTypeParsers[].stream`); it is opaque to AJV, so skip
@@ -205,6 +205,15 @@ function normalizeMountPrefix(prefix) {
205
205
  return "";
206
206
  return prefix.endsWith("/") ? prefix.slice(0, -1) : prefix;
207
207
  }
208
+ /** Join a normalized mount prefix with a translated route path. A collection
209
+ * route declared at `/` sits at the mount root itself (`/todos` + `/` → `/todos`),
210
+ * not a trailing-slash variant Fastify would treat as a distinct, unmatched URL.
211
+ * An empty prefix (root mount) keeps `/`. */
212
+ function joinMountPath(prefix, path) {
213
+ if (path === "/")
214
+ return prefix || "/";
215
+ return prefix + path;
216
+ }
208
217
  /**
209
218
  * Wraps an incoming request's raw body as a `Stream<Uint8Array>`. Requires a
210
219
  * stream content-type parser (`contentTypeParsers[].stream`) for the request's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/http-server",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Telo HTTP Server module - HTTP server and API resource kinds for Telo manifests.",
5
5
  "keywords": [
6
6
  "telo",
@@ -55,7 +55,7 @@
55
55
  "@types/node": "^20.0.0",
56
56
  "typescript": "^5.0.0",
57
57
  "vitest": "^2.1.8",
58
- "@telorun/sdk": "0.34.0"
58
+ "@telorun/sdk": "0.36.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@telorun/sdk": "*"
@@ -87,7 +87,7 @@ export class HttpServerApi implements ResourceInstance {
87
87
  const handlerRef = this.handlerRefs.get(route as unknown as object);
88
88
  const handlerKind = handlerRef?.kind ?? "";
89
89
  const handlerName = handlerRef?.name ?? "";
90
- const translatedPath = prefix + translateOpenApiPath(route.request.path);
90
+ const translatedPath = joinMountPath(prefix, translateOpenApiPath(route.request.path));
91
91
 
92
92
  const schema: any = { response: {} };
93
93
 
@@ -269,6 +269,15 @@ function normalizeMountPrefix(prefix: string): string {
269
269
  return prefix.endsWith("/") ? prefix.slice(0, -1) : prefix;
270
270
  }
271
271
 
272
+ /** Join a normalized mount prefix with a translated route path. A collection
273
+ * route declared at `/` sits at the mount root itself (`/todos` + `/` → `/todos`),
274
+ * not a trailing-slash variant Fastify would treat as a distinct, unmatched URL.
275
+ * An empty prefix (root mount) keeps `/`. */
276
+ function joinMountPath(prefix: string, path: string): string {
277
+ if (path === "/") return prefix || "/";
278
+ return prefix + path;
279
+ }
280
+
272
281
  /**
273
282
  * Wraps an incoming request's raw body as a `Stream<Uint8Array>`. Requires a
274
283
  * stream content-type parser (`contentTypeParsers[].stream`) for the request's