@voyant-travel/hono 0.117.0 → 0.117.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/dist/app.d.ts CHANGED
@@ -1,10 +1,22 @@
1
1
  import type { Hono } from "hono";
2
+ import { type LazyRoutesLoader } from "./lazy-routes.js";
2
3
  import type { VoyantAppConfig, VoyantBindings, VoyantVariables } from "./types.js";
3
4
  /** The composed app's Hono env (bindings + framework request variables). */
4
5
  type MountEnv<TBindings extends VoyantBindings> = {
5
6
  Bindings: TBindings;
6
7
  Variables: VoyantVariables;
7
8
  };
9
+ /**
10
+ * A lazy route family recorded at mount time so a build-time OpenAPI generator
11
+ * can eager-load it and merge its `.openapi()` operations (voyant#2114). Mirrors
12
+ * `LazyMount` in `./openapi.ts` (kept structurally identical, but declared here
13
+ * to avoid pulling the build-time-only openapi module into the runtime path).
14
+ */
15
+ export interface LazyMount {
16
+ /** Absolute surface mount prefix, or `"/"` for absolute `lazyRoutes`. */
17
+ prefix: string;
18
+ load: LazyRoutesLoader;
19
+ }
8
20
  /**
9
21
  * App handle returned alongside the Hono instance. Carries `ready()` for
10
22
  * headless / sibling-process deployments that need to fire the lazy
@@ -40,6 +52,13 @@ export interface VoyantAppExtensions<TBindings = unknown> {
40
52
  * await withDbFromEnv(env, (db) => drainOutbox(db, app.eventBus))
41
53
  */
42
54
  eventBus: import("@voyant-travel/core").EventBus;
55
+ /**
56
+ * Lazy route families recorded at mount time (the wildcard dispatch stubs in
57
+ * `lazy-routes.ts` don't reach the composed `OpenAPIHono` registry). A
58
+ * build-time OpenAPI generator reads this to eager-load + merge their
59
+ * `.openapi()` operations via `mergeLazyOpenApiPaths`. Never read at runtime.
60
+ */
61
+ lazyMounts: LazyMount[];
43
62
  }
44
63
  /**
45
64
  * Low-level app factory: given an already-resolved `modules`/`extensions` set
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/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IACd,IAAI,EAAE,gBAAgB,CAAA;CACvB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB,CAAC,SAAS,GAAG,OAAO;IACtD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C;;;;;;;;OAQG;IACH,QAAQ,EAAE,OAAO,qBAAqB,EAAE,QAAQ,CAAA;IAChD;;;;;OAKG;IACH,UAAU,EAAE,SAAS,EAAE,CAAA;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,SAAS,SAAS,cAAc,EACvD,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,GACjC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAsf5D"}
package/dist/app.js CHANGED
@@ -416,6 +416,13 @@ export function mountApp(config) {
416
416
  scopes: c.get("scopes"),
417
417
  }));
418
418
  }
419
+ // Lazy route families recorded for build-time OpenAPI merging. The wildcard
420
+ // dispatch stubs registered by `mountLazyRoutesAt`/`mountLazyRoutePaths` never
421
+ // reach the composed OpenAPIHono registry, so the spec generator replays these
422
+ // loaders (see `mergeLazyOpenApiPaths`). Recorded in the same loop that mounts
423
+ // them so the prefix logic is single-sourced here. Cheap array pushes — no
424
+ // eager `import()` and no runtime read.
425
+ const lazyMounts = [];
419
426
  // Mount module routes
420
427
  for (const mod of allModules) {
421
428
  const adminPrefix = `/v1/admin/${mod.module.name}`;
@@ -428,12 +435,15 @@ export function mountApp(config) {
428
435
  }
429
436
  if (mod.lazyAdminRoutes) {
430
437
  mountLazyRoutesAt(app, adminPrefix, mod.lazyAdminRoutes);
438
+ lazyMounts.push({ prefix: adminPrefix, load: mod.lazyAdminRoutes });
431
439
  }
432
440
  if (mod.lazyPublicRoutes) {
433
441
  mountLazyRoutesAt(app, publicPrefix, mod.lazyPublicRoutes);
442
+ lazyMounts.push({ prefix: publicPrefix, load: mod.lazyPublicRoutes });
434
443
  }
435
444
  if (mod.lazyRoutes) {
436
445
  mountLazyRoutePaths(app, mod.lazyRoutes.paths, mod.lazyRoutes.load);
446
+ lazyMounts.push({ prefix: "/", load: mod.lazyRoutes.load });
437
447
  }
438
448
  if (mod.routes) {
439
449
  app.route(`/v1/${mod.module.name}`, mod.routes);
@@ -451,12 +461,15 @@ export function mountApp(config) {
451
461
  }
452
462
  if (ext.lazyAdminRoutes) {
453
463
  mountLazyRoutesAt(app, adminPrefix, ext.lazyAdminRoutes);
464
+ lazyMounts.push({ prefix: adminPrefix, load: ext.lazyAdminRoutes });
454
465
  }
455
466
  if (ext.lazyPublicRoutes) {
456
467
  mountLazyRoutesAt(app, publicPrefix, ext.lazyPublicRoutes);
468
+ lazyMounts.push({ prefix: publicPrefix, load: ext.lazyPublicRoutes });
457
469
  }
458
470
  if (ext.lazyRoutes) {
459
471
  mountLazyRoutePaths(app, ext.lazyRoutes.paths, ext.lazyRoutes.load);
472
+ lazyMounts.push({ prefix: "/", load: ext.lazyRoutes.load });
460
473
  }
461
474
  if (ext.routes) {
462
475
  app.route(`/v1/${ext.extension.module}`, ext.routes);
@@ -476,6 +489,7 @@ export function mountApp(config) {
476
489
  // the real `env`.
477
490
  const augmented = app;
478
491
  augmented.eventBus = eventBus;
492
+ augmented.lazyMounts = lazyMounts;
479
493
  augmented.ready = (bindings) => ensureRuntimeBootstrapped(bindings ?? {});
480
494
  return augmented;
481
495
  }
package/dist/openapi.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { OpenAPIHono } from "@hono/zod-openapi";
1
+ import { OpenAPIHono } from "@hono/zod-openapi";
2
2
  import type { Hono } from "hono";
3
+ import type { LazyRoutesLoader } from "./lazy-routes.js";
3
4
  /**
4
5
  * OpenAPI document generation for composed Voyant apps (voyant#2114).
5
6
  *
@@ -54,5 +55,36 @@ export type ApiSurface = "admin" | "storefront";
54
55
  * over-include shared component schemas, which is harmless).
55
56
  */
56
57
  export declare function selectSurface(doc: OpenApiDocument, surface: ApiSurface): OpenApiDocument;
58
+ /**
59
+ * A lazy-mounted route family recorded by `mountApp` for build-time spec
60
+ * merging. `prefix` is the absolute surface mount (`/v1/admin/<name>`,
61
+ * `/v1/public/...`) for relative-route loaders, or `"/"` for absolute
62
+ * `lazyRoutes` loaders. `load` is the same loader the runtime dispatcher caches
63
+ * — it constructs (but does not serve) the sub-app via `import(...)`.
64
+ */
65
+ export interface LazyMount {
66
+ prefix: string;
67
+ load: LazyRoutesLoader;
68
+ }
69
+ /**
70
+ * Eager-merge lazy route families into a generated base document (voyant#2114).
71
+ *
72
+ * Lazy families mount at runtime as wildcard dispatch stubs (see
73
+ * `lazy-routes.ts`), so their `.openapi()` operations never reach the composed
74
+ * `OpenAPIHono` registry and are invisible to `generateOpenApiDocument`. This
75
+ * runs each loader at build time, and for any that return an `OpenAPIHono`,
76
+ * re-mounts it into a throwaway `OpenAPIHono` at its real prefix — reusing the
77
+ * exact prefix-merge semantics `OpenAPIHono.route(...)` applies to eager mounts
78
+ * — then shallow-merges the resulting `paths` + `components.*` into `base`.
79
+ *
80
+ * Plain `Hono` sub-apps (no `.openapi()` routes) carry no registry and are
81
+ * skipped without error. A loader that throws is skipped with a warning so one
82
+ * bad family can't break generation. `base` wins on path/component collisions
83
+ * (which shouldn't happen given distinct prefixes), with a dev-time warning.
84
+ *
85
+ * Build-time only — same module-level constraint as the rest of this file
86
+ * (`@asteasolutions/zod-to-openapi` stays out of the Worker bundle).
87
+ */
88
+ export declare function mergeLazyOpenApiPaths(base: OpenApiDocument, mounts: readonly LazyMount[], options: GenerateOpenApiOptions): Promise<OpenApiDocument>;
57
89
  export {};
58
90
  //# sourceMappingURL=openapi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,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@@ -1,3 +1,4 @@
1
+ import { OpenAPIHono } from "@hono/zod-openapi";
1
2
  /**
2
3
  * Generate a single OpenAPI 3.1 document covering every `.openapi()` route
3
4
  * mounted on the composed app, with module base paths already merged in
@@ -28,3 +29,86 @@ export function selectSurface(doc, surface) {
28
29
  const paths = Object.fromEntries(Object.entries(doc.paths ?? {}).filter(([path]) => path.startsWith(prefix)));
29
30
  return { ...doc, paths };
30
31
  }
32
+ /** Detect an `OpenAPIHono` sub-app (carries the `.openapi()` route registry). */
33
+ function isOpenApiHono(value) {
34
+ return (typeof value === "object" &&
35
+ value !== null &&
36
+ typeof value.getOpenAPI31Document === "function" &&
37
+ "openAPIRegistry" in value);
38
+ }
39
+ /**
40
+ * Eager-merge lazy route families into a generated base document (voyant#2114).
41
+ *
42
+ * Lazy families mount at runtime as wildcard dispatch stubs (see
43
+ * `lazy-routes.ts`), so their `.openapi()` operations never reach the composed
44
+ * `OpenAPIHono` registry and are invisible to `generateOpenApiDocument`. This
45
+ * runs each loader at build time, and for any that return an `OpenAPIHono`,
46
+ * re-mounts it into a throwaway `OpenAPIHono` at its real prefix — reusing the
47
+ * exact prefix-merge semantics `OpenAPIHono.route(...)` applies to eager mounts
48
+ * — then shallow-merges the resulting `paths` + `components.*` into `base`.
49
+ *
50
+ * Plain `Hono` sub-apps (no `.openapi()` routes) carry no registry and are
51
+ * skipped without error. A loader that throws is skipped with a warning so one
52
+ * bad family can't break generation. `base` wins on path/component collisions
53
+ * (which shouldn't happen given distinct prefixes), with a dev-time warning.
54
+ *
55
+ * Build-time only — same module-level constraint as the rest of this file
56
+ * (`@asteasolutions/zod-to-openapi` stays out of the Worker bundle).
57
+ */
58
+ export async function mergeLazyOpenApiPaths(base, mounts, options) {
59
+ const throwaway = new OpenAPIHono();
60
+ let mergedAny = false;
61
+ for (const { prefix, load } of mounts) {
62
+ let subApp;
63
+ try {
64
+ subApp = await load();
65
+ }
66
+ catch (error) {
67
+ const message = error instanceof Error ? error.message : String(error);
68
+ console.warn(`[voyant] openapi: lazy loader for "${prefix}" failed, skipping: ${message}`);
69
+ continue;
70
+ }
71
+ if (!isOpenApiHono(subApp)) {
72
+ // Plain Hono (or anything without the registry) contributes no docs.
73
+ continue;
74
+ }
75
+ // `route("/", subApp)` reproduces what an absolute-path (`lazyRoutes`)
76
+ // family does at runtime; a relative-surface loader merges at its prefix.
77
+ throwaway.route(prefix === "/" ? "/" : prefix, subApp);
78
+ mergedAny = true;
79
+ }
80
+ if (!mergedAny)
81
+ return base;
82
+ const lazyDoc = throwaway.getOpenAPI31Document({
83
+ openapi: "3.1.0",
84
+ info: options.info,
85
+ ...(options.servers ? { servers: options.servers } : {}),
86
+ });
87
+ const paths = { ...(base.paths ?? {}) };
88
+ for (const [path, item] of Object.entries(lazyDoc.paths ?? {})) {
89
+ if (path in paths) {
90
+ console.warn(`[voyant] openapi: lazy path "${path}" collides with an eager route; keeping eager.`);
91
+ continue;
92
+ }
93
+ paths[path] = item;
94
+ }
95
+ const merged = { ...base, paths };
96
+ const lazyComponents = lazyDoc.components;
97
+ if (lazyComponents) {
98
+ const baseComponents = (base.components ?? {});
99
+ const mergedComponents = {};
100
+ const groups = new Set([...Object.keys(baseComponents), ...Object.keys(lazyComponents)]);
101
+ for (const group of groups) {
102
+ const baseGroup = (baseComponents[group] ?? {});
103
+ const lazyGroup = lazyComponents[group] ?? {};
104
+ const combined = { ...lazyGroup };
105
+ for (const [key, value] of Object.entries(baseGroup)) {
106
+ combined[key] = value; // base wins
107
+ }
108
+ mergedComponents[group] = combined;
109
+ }
110
+ ;
111
+ merged.components = mergedComponents;
112
+ }
113
+ return merged;
114
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,KAAK,CAAA;AAI5C,qBAAa,YAAa,SAAQ,KAAK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CAAC,EAAE,MAAM,CAAA;CAAE,GACxF,OAAO,CAAC,CAAC,CAAC,CAWZ;AAED,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,CAAC,EAAE,OAAO,EACV,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,OAAO,CAAC,EAAE;IACR,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GACA,OAAO,CAAC,CAAC,CAAC,CAcZ;AAkBD,wBAAgB,UAAU,CAAC,CAAC,EAC1B,CAAC,EAAE,OAAO,EACV,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,OAAO,CAAC,EAAE;IAAE,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,CAAC,CAMH;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAsBjF"}
@@ -1,3 +1,4 @@
1
+ import { HTTPException } from "hono/http-exception";
1
2
  import { ZodError } from "zod";
2
3
  import { DEFAULT_REQUEST_BODY_LIMIT_BYTES } from "./middleware/body-size.js";
3
4
  export class ApiHttpError extends Error {
@@ -102,5 +103,16 @@ export function normalizeValidationError(error) {
102
103
  if (error instanceof ZodError) {
103
104
  return toValidationError(error);
104
105
  }
106
+ if (error instanceof HTTPException) {
107
+ // Hono's request validators throw HTTPException before our validation hook
108
+ // runs — most notably HTTPException(400, "Malformed JSON in request body")
109
+ // from the JSON body parser on `.openapi()` routes. Map it onto the
110
+ // framework error contract so bad client input is a structured 4xx, not a
111
+ // 500 (voyant#2114).
112
+ return new ApiHttpError(error.message, {
113
+ status: error.status,
114
+ code: error.status === 400 ? "invalid_request" : undefined,
115
+ });
116
+ }
105
117
  return undefined;
106
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/hono",
3
- "version": "0.117.0",
3
+ "version": "0.117.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -146,8 +146,8 @@
146
146
  "@cloudflare/workers-types": "^4.20260426.1",
147
147
  "typescript": "^6.0.2",
148
148
  "vitest": "^4.1.2",
149
- "@voyant-travel/voyant-typescript-config": "^0.1.0",
150
- "@voyant-travel/workflows-orchestrator": "^0.111.9"
149
+ "@voyant-travel/workflows-orchestrator": "^0.111.9",
150
+ "@voyant-travel/voyant-typescript-config": "^0.1.0"
151
151
  },
152
152
  "files": [
153
153
  "dist"