ts-procedures 10.1.2 → 10.2.0

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.
Files changed (257) hide show
  1. package/CHANGELOG.md +26 -91
  2. package/README.md +2 -0
  3. package/agent_config/claude-code/skills/ts-procedures/anti-patterns.md +8 -0
  4. package/agent_config/claude-code/skills/ts-procedures/api-reference.md +25 -22
  5. package/agent_config/claude-code/skills/ts-procedures/patterns.md +24 -13
  6. package/agent_config/copilot/copilot-instructions.md +1 -1
  7. package/agent_config/cursor/cursorrules +1 -1
  8. package/build/adapters/hono/envelope-parity.test.js +6 -17
  9. package/build/adapters/hono/envelope-parity.test.js.map +1 -1
  10. package/build/adapters/hono/handlers/http-stream.d.ts +2 -1
  11. package/build/adapters/hono/handlers/http-stream.js +9 -2
  12. package/build/adapters/hono/handlers/http-stream.js.map +1 -1
  13. package/build/adapters/hono/handlers/http.d.ts +2 -1
  14. package/build/adapters/hono/handlers/http.js +9 -2
  15. package/build/adapters/hono/handlers/http.js.map +1 -1
  16. package/build/adapters/hono/handlers/rpc.d.ts +2 -1
  17. package/build/adapters/hono/handlers/rpc.js +9 -2
  18. package/build/adapters/hono/handlers/rpc.js.map +1 -1
  19. package/build/adapters/hono/handlers/stream.d.ts +2 -1
  20. package/build/adapters/hono/handlers/stream.js +9 -2
  21. package/build/adapters/hono/handlers/stream.js.map +1 -1
  22. package/build/adapters/hono/index.d.ts +14 -7
  23. package/build/adapters/hono/index.js +45 -5
  24. package/build/adapters/hono/index.js.map +1 -1
  25. package/build/adapters/hono/index.test.js +55 -0
  26. package/build/adapters/hono/index.test.js.map +1 -1
  27. package/build/adapters/hono/request.d.ts +7 -0
  28. package/build/adapters/hono/request.js +15 -0
  29. package/build/adapters/hono/request.js.map +1 -1
  30. package/build/adapters/hono/types.d.ts +31 -0
  31. package/build/adapters/hono/types.js.map +1 -1
  32. package/build/codegen/bin/cli.js +1 -1
  33. package/build/codegen/bin/cli.js.map +1 -1
  34. package/build/codegen/constants.js +2 -2
  35. package/build/codegen/constants.js.map +1 -1
  36. package/build/codegen/emit/api-route.js +1 -1
  37. package/build/codegen/emit/api-route.js.map +1 -1
  38. package/build/codegen/emit/scope-file.js +1 -1
  39. package/build/codegen/emit/scope-file.js.map +1 -1
  40. package/build/codegen/emit-errors.integration.test.js +2 -2
  41. package/build/codegen/emit-errors.integration.test.js.map +1 -1
  42. package/build/codegen/resolve-envelope.js +1 -1
  43. package/build/codegen/resolve-envelope.js.map +1 -1
  44. package/build/codegen/test-helpers/run-tsc.js +1 -1
  45. package/build/codegen/test-helpers/run-tsc.js.map +1 -1
  46. package/build/core/create-http-stream.d.ts +3 -14
  47. package/build/core/create-http-stream.js +4 -2
  48. package/build/core/create-http-stream.js.map +1 -1
  49. package/build/core/create-http.d.ts +2 -9
  50. package/build/core/create-http.js +3 -2
  51. package/build/core/create-http.js.map +1 -1
  52. package/build/core/create-http.test-d.js +104 -0
  53. package/build/core/create-http.test-d.js.map +1 -0
  54. package/build/core/create-stream.js +6 -2
  55. package/build/core/create-stream.js.map +1 -1
  56. package/build/core/create.js +5 -4
  57. package/build/core/create.js.map +1 -1
  58. package/build/core/create.test.js +63 -0
  59. package/build/core/create.test.js.map +1 -1
  60. package/build/core/internal.d.ts +16 -0
  61. package/build/core/internal.js +22 -0
  62. package/build/core/internal.js.map +1 -1
  63. package/build/core/procedures.d.ts +9 -16
  64. package/build/core/procedures.js +4 -0
  65. package/build/core/procedures.js.map +1 -1
  66. package/build/core/types.d.ts +85 -4
  67. package/build/errors.d.ts +33 -0
  68. package/build/errors.js +91 -0
  69. package/build/errors.js.map +1 -0
  70. package/build/errors.test.d.ts +1 -0
  71. package/build/errors.test.js +122 -0
  72. package/build/errors.test.js.map +1 -0
  73. package/build/exports.d.ts +1 -2
  74. package/build/exports.js +0 -4
  75. package/build/exports.js.map +1 -1
  76. package/build/implementations/http/doc-registry.d.ts +28 -0
  77. package/build/implementations/http/doc-registry.js +96 -0
  78. package/build/implementations/http/doc-registry.js.map +1 -0
  79. package/build/implementations/http/doc-registry.test.d.ts +1 -0
  80. package/build/implementations/http/doc-registry.test.js +516 -0
  81. package/build/implementations/http/doc-registry.test.js.map +1 -0
  82. package/build/implementations/http/error-taxonomy.d.ts +249 -0
  83. package/build/implementations/http/error-taxonomy.js +252 -0
  84. package/build/implementations/http/error-taxonomy.js.map +1 -0
  85. package/build/implementations/http/error-taxonomy.test.d.ts +1 -0
  86. package/build/implementations/http/error-taxonomy.test.js +399 -0
  87. package/build/implementations/http/error-taxonomy.test.js.map +1 -0
  88. package/build/implementations/http/express-rpc/error-taxonomy.test.d.ts +1 -0
  89. package/build/implementations/http/express-rpc/error-taxonomy.test.js +83 -0
  90. package/build/implementations/http/express-rpc/error-taxonomy.test.js.map +1 -0
  91. package/build/implementations/http/express-rpc/index.d.ts +125 -0
  92. package/build/implementations/http/express-rpc/index.js +216 -0
  93. package/build/implementations/http/express-rpc/index.js.map +1 -0
  94. package/build/implementations/http/express-rpc/index.test.d.ts +1 -0
  95. package/build/implementations/http/express-rpc/index.test.js +684 -0
  96. package/build/implementations/http/express-rpc/index.test.js.map +1 -0
  97. package/build/implementations/http/express-rpc/types.d.ts +11 -0
  98. package/build/implementations/http/express-rpc/types.js +2 -0
  99. package/build/implementations/http/express-rpc/types.js.map +1 -0
  100. package/build/implementations/http/hono-api/error-taxonomy.test.d.ts +1 -0
  101. package/build/implementations/http/hono-api/error-taxonomy.test.js +137 -0
  102. package/build/implementations/http/hono-api/error-taxonomy.test.js.map +1 -0
  103. package/build/implementations/http/hono-api/index.d.ts +151 -0
  104. package/build/implementations/http/hono-api/index.js +344 -0
  105. package/build/implementations/http/hono-api/index.js.map +1 -0
  106. package/build/implementations/http/hono-api/index.test.d.ts +1 -0
  107. package/build/implementations/http/hono-api/index.test.js +992 -0
  108. package/build/implementations/http/hono-api/index.test.js.map +1 -0
  109. package/build/implementations/http/hono-api/types.d.ts +13 -0
  110. package/build/implementations/http/hono-api/types.js +2 -0
  111. package/build/implementations/http/hono-api/types.js.map +1 -0
  112. package/build/implementations/http/hono-rpc/error-taxonomy.test.d.ts +1 -0
  113. package/build/implementations/http/hono-rpc/error-taxonomy.test.js +64 -0
  114. package/build/implementations/http/hono-rpc/error-taxonomy.test.js.map +1 -0
  115. package/build/implementations/http/hono-rpc/index.d.ts +130 -0
  116. package/build/implementations/http/hono-rpc/index.js +209 -0
  117. package/build/implementations/http/hono-rpc/index.js.map +1 -0
  118. package/build/implementations/http/hono-rpc/index.test.d.ts +1 -0
  119. package/build/implementations/http/hono-rpc/index.test.js +828 -0
  120. package/build/implementations/http/hono-rpc/index.test.js.map +1 -0
  121. package/build/implementations/http/hono-rpc/types.d.ts +11 -0
  122. package/build/implementations/http/hono-rpc/types.js +2 -0
  123. package/build/implementations/http/hono-rpc/types.js.map +1 -0
  124. package/build/implementations/http/hono-stream/error-taxonomy.test.d.ts +1 -0
  125. package/build/implementations/http/hono-stream/error-taxonomy.test.js +159 -0
  126. package/build/implementations/http/hono-stream/error-taxonomy.test.js.map +1 -0
  127. package/build/implementations/http/hono-stream/index.d.ts +171 -0
  128. package/build/implementations/http/hono-stream/index.js +415 -0
  129. package/build/implementations/http/hono-stream/index.js.map +1 -0
  130. package/build/implementations/http/hono-stream/index.test.d.ts +1 -0
  131. package/build/implementations/http/hono-stream/index.test.js +1383 -0
  132. package/build/implementations/http/hono-stream/index.test.js.map +1 -0
  133. package/build/implementations/http/hono-stream/types.d.ts +15 -0
  134. package/build/implementations/http/hono-stream/types.js +2 -0
  135. package/build/implementations/http/hono-stream/types.js.map +1 -0
  136. package/build/implementations/http/on-request-error.test.d.ts +1 -0
  137. package/build/implementations/http/on-request-error.test.js +173 -0
  138. package/build/implementations/http/on-request-error.test.js.map +1 -0
  139. package/build/implementations/http/route-errors.test.d.ts +1 -0
  140. package/build/implementations/http/route-errors.test.js +139 -0
  141. package/build/implementations/http/route-errors.test.js.map +1 -0
  142. package/build/implementations/types.d.ts +192 -0
  143. package/build/implementations/types.js +2 -0
  144. package/build/implementations/types.js.map +1 -0
  145. package/build/index.d.ts +165 -0
  146. package/build/index.js +258 -0
  147. package/build/index.js.map +1 -0
  148. package/build/index.test.d.ts +1 -0
  149. package/build/index.test.js +920 -0
  150. package/build/index.test.js.map +1 -0
  151. package/build/schema/compute-schema.js +1 -5
  152. package/build/schema/compute-schema.js.map +1 -1
  153. package/build/schema/compute-schema.test.js +0 -13
  154. package/build/schema/compute-schema.test.js.map +1 -1
  155. package/build/schema/extract-json-schema.d.ts +2 -0
  156. package/build/schema/extract-json-schema.js +12 -0
  157. package/build/schema/extract-json-schema.js.map +1 -0
  158. package/build/schema/extract-json-schema.test.d.ts +1 -0
  159. package/build/schema/extract-json-schema.test.js +23 -0
  160. package/build/schema/extract-json-schema.test.js.map +1 -0
  161. package/build/schema/parser.d.ts +28 -0
  162. package/build/schema/parser.js +170 -0
  163. package/build/schema/parser.js.map +1 -0
  164. package/build/schema/parser.test.d.ts +1 -0
  165. package/build/schema/parser.test.js +120 -0
  166. package/build/schema/parser.test.js.map +1 -0
  167. package/build/schema/resolve-schema-lib.d.ts +12 -0
  168. package/build/schema/resolve-schema-lib.js +11 -0
  169. package/build/schema/resolve-schema-lib.js.map +1 -0
  170. package/build/schema/resolve-schema-lib.test.d.ts +1 -0
  171. package/build/schema/resolve-schema-lib.test.js +17 -0
  172. package/build/schema/resolve-schema-lib.test.js.map +1 -0
  173. package/build/schema/typebox.d.ts +1 -1
  174. package/build/schema/typebox.js +2 -20
  175. package/build/schema/typebox.js.map +1 -1
  176. package/build/schema/typebox.test.js +0 -10
  177. package/build/schema/typebox.test.js.map +1 -1
  178. package/build/schema/types.d.ts +8 -0
  179. package/build/schema/types.js +2 -0
  180. package/build/schema/types.js.map +1 -0
  181. package/build/server/context.d.ts +12 -2
  182. package/build/server/context.js +49 -4
  183. package/build/server/context.js.map +1 -1
  184. package/build/server/context.test.js +32 -1
  185. package/build/server/context.test.js.map +1 -1
  186. package/build/server/doc-registry.js +0 -3
  187. package/build/server/doc-registry.js.map +1 -1
  188. package/build/server/doc-registry.test.js +0 -31
  189. package/build/server/doc-registry.test.js.map +1 -1
  190. package/build/server/index.d.ts +0 -1
  191. package/build/server/index.js +0 -1
  192. package/build/server/index.js.map +1 -1
  193. package/build/server/types.d.ts +6 -27
  194. package/build/stack-utils.d.ts +25 -0
  195. package/build/stack-utils.js +95 -0
  196. package/build/stack-utils.js.map +1 -0
  197. package/build/stack-utils.test.d.ts +1 -0
  198. package/build/stack-utils.test.js +80 -0
  199. package/build/stack-utils.test.js.map +1 -0
  200. package/docs/core.md +8 -0
  201. package/docs/http-integrations.md +41 -27
  202. package/package.json +8 -8
  203. package/src/adapters/astro/README.md +2 -0
  204. package/src/adapters/hono/envelope-parity.test.ts +6 -18
  205. package/src/adapters/hono/handlers/http-stream.ts +12 -3
  206. package/src/adapters/hono/handlers/http.ts +12 -3
  207. package/src/adapters/hono/handlers/rpc.ts +12 -3
  208. package/src/adapters/hono/handlers/stream.ts +12 -3
  209. package/src/adapters/hono/index.test.ts +70 -0
  210. package/src/adapters/hono/index.ts +53 -11
  211. package/src/adapters/hono/request.ts +18 -0
  212. package/src/adapters/hono/types.ts +37 -0
  213. package/src/codegen/bin/cli.ts +1 -1
  214. package/src/codegen/constants.ts +2 -2
  215. package/src/codegen/emit/api-route.ts +1 -1
  216. package/src/codegen/emit/scope-file.ts +1 -2
  217. package/src/codegen/emit-errors.integration.test.ts +2 -2
  218. package/src/codegen/resolve-envelope.ts +1 -1
  219. package/src/codegen/test-helpers/run-tsc.ts +0 -1
  220. package/src/core/create-http-stream.ts +20 -13
  221. package/src/core/create-http.test-d.ts +154 -0
  222. package/src/core/create-http.ts +19 -8
  223. package/src/core/create-stream.ts +12 -4
  224. package/src/core/create.test.ts +74 -0
  225. package/src/core/create.ts +10 -5
  226. package/src/core/internal.ts +35 -0
  227. package/src/core/procedures.ts +4 -0
  228. package/src/core/types.ts +99 -4
  229. package/src/exports.ts +6 -4
  230. package/src/schema/compute-schema.test.ts +0 -16
  231. package/src/schema/compute-schema.ts +1 -5
  232. package/src/schema/typebox.test.ts +0 -12
  233. package/src/schema/typebox.ts +2 -21
  234. package/src/server/context.test.ts +39 -1
  235. package/src/server/context.ts +54 -4
  236. package/src/server/doc-registry.test.ts +0 -34
  237. package/src/server/doc-registry.ts +0 -3
  238. package/src/server/index.ts +0 -1
  239. package/src/server/types.ts +8 -27
  240. package/build/schema/strip-internal-keywords.d.ts +0 -18
  241. package/build/schema/strip-internal-keywords.js +0 -33
  242. package/build/schema/strip-internal-keywords.js.map +0 -1
  243. package/build/schema/strip-internal-keywords.test.js +0 -38
  244. package/build/schema/strip-internal-keywords.test.js.map +0 -1
  245. package/build/server/spec-version.d.ts +0 -24
  246. package/build/server/spec-version.js +0 -26
  247. package/build/server/spec-version.js.map +0 -1
  248. package/build/version.d.ts +0 -9
  249. package/build/version.js +0 -11
  250. package/build/version.js.map +0 -1
  251. package/docs/doc-envelope-spec-v1.md +0 -296
  252. package/docs/doc-envelope-v1.schema.json +0 -253
  253. package/src/schema/strip-internal-keywords.test.ts +0 -43
  254. package/src/schema/strip-internal-keywords.ts +0 -36
  255. package/src/server/spec-version.ts +0 -27
  256. package/src/version.ts +0 -11
  257. /package/build/{schema/strip-internal-keywords.test.d.ts → core/create-http.test-d.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -4,111 +4,46 @@ All notable changes to **ts-procedures** are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 10.1.2 — 2026-06-24
7
+ ## Unreleased
8
8
 
9
- Fixes a registration crash and output leak when TypeBox internal markers escape
10
- as enumerable properties. Complements the detection fix in 10.1.1.
9
+ ## 10.2.0 2026-06-25
11
10
 
12
- ### Fixed
13
-
14
- - **`Type.Optional(Type.Unsafe({...}))` no longer crashes registration or leaks
15
- markers.** Most TypeBox `~`-prefixed markers are non-enumerable and stay out of
16
- the JSON Schema, but some compositions — notably `Type.Optional` wrapping
17
- `Type.Unsafe` — emit `~unsafe`/`~optional` as **enumerable** own properties.
18
- Those then (a) made strict AJV throw `unknown keyword: "~unsafe"` at
19
- registration and (b) leaked into serialized DocEnvelope/codegen output. JSON
20
- Schema extracted from any channel is now deep-stripped of `~`-prefixed keys
21
- (`stripInternalKeywords`) at the single extraction chokepoint, so both runtime
22
- validation and emitted docs/codegen are clean. Stripping by the `~`-prefix
23
- convention (not a fixed name list) stays robust against future markers.
24
-
25
- ### Notes
26
-
27
- - AJV stays strict (no `strictSchema: false`) — stripping cleans the output too
28
- and keeps AJV's unknown-keyword safety net for genuine schema typos.
29
- - 10.1.1 fixed *recognition* of a bare top-level `Type.Unsafe(...)`; this release
30
- fixes the distinct *enumerable-marker leak* in nested compositions. Schemas
31
- built only from `Type.Object`/primitives were never affected by either.
32
-
33
- ## 10.1.1 — 2026-06-24
34
-
35
- Fixes TypeBox schema detection for `Type.Unsafe(...)` on typebox ≥ 1.2.0. No
36
- change to generated output, docs, or validation behavior.
37
-
38
- ### Fixed
39
-
40
- - **Top-level `Type.Unsafe(...)` channel schemas are recognized again.** TypeBox
41
- 1.2.0 tags `Type.Unsafe(...)` with a `~unsafe` marker *instead of* `~kind`, so
42
- the built-in TypeBox adapter — which only looked for `~kind` — failed to detect
43
- a bare top-level `Type.Unsafe(...)` used as a channel schema (e.g.
44
- `schema: { params: Type.Unsafe(...) }`), throwing a `ProcedureRegistrationError`
45
- at registration. Detection now keys off TypeBox v1's `~`-prefix marker
46
- *convention* (via `Reflect.ownKeys`, since the markers are non-enumerable)
47
- rather than a fixed list of names, so current and future `~*` markers are
48
- recognized without further changes. `Type.Unsafe` nested inside a
49
- `Type.Object(...)` was never affected.
50
-
51
- ### Notes
52
-
53
- - Serialized JSON Schema was never affected: TypeBox's `~` markers are
54
- non-enumerable, so they never reached `JSON.stringify` (DocEnvelope, codegen)
55
- or AJV. The frozen codegen goldens and DocEnvelope parity fixtures are
56
- unchanged. App devs only need to upgrade; no code changes required.
57
-
58
- ## 10.1.0 — 2026-06-24
11
+ ### Added
59
12
 
60
- Adds explicit versioning to the DocEnvelope so downstream consumers (docs
61
- viewers, codegen, dashboards) can detect the wire format and stay forward
62
- compatible. Purely additive — existing envelopes and consumers are unaffected.
13
+ - **Factory middleware via `Procedures({ middleware })`.** Declare middleware at the factory level that runs with the *final* resolved context (your `TContext` + injected `error()` + `signal`) and the validated incoming call data. Enables "parse the incoming call" patterns for authorization, tenancy enforcement, enrichment, etc.
63
14
 
64
- ### Added
15
+ ```ts
16
+ const Protected = Procedures<Ctx>({
17
+ middleware: [({ ctx, input, next }) => {
18
+ // ctx is fully resolved; input is schema-validated
19
+ if (input && 'orgId' in input && !ctx.user.tenants.includes(input.orgId)) {
20
+ throw ctx.error('tenant violation')
21
+ }
22
+ return next({ ctx: { ...ctx, checked: true } }) // optional augmentation
23
+ }]
24
+ })
25
+ ```
65
26
 
66
- - **`DocEnvelope.specVersion`** a small monotonic integer (currently `1`)
67
- identifying the envelope wire format, emitted on every envelope produced by
68
- `DocRegistry.toJSON()` / `builder.toDocEnvelope()`. Bumped **only** when the
69
- envelope shape changes — never on routine package releases — so consumers get
70
- a stable signal to branch their parser on. An absent `specVersion` MUST be
71
- treated as `1`. Exported as `DOC_ENVELOPE_SPEC_VERSION` from `ts-procedures`
72
- and `ts-procedures/server`.
73
- - **`DocEnvelope.generatorVersion`** — the ts-procedures package version that
74
- produced the envelope (e.g. `"10.1.0"`), for telemetry/debugging only; not a
75
- parse-compatibility signal. Exported as `DOC_ENVELOPE_GENERATOR_VERSION` from
76
- `ts-procedures/server`. Strippable via the `transform` hook for servers that
77
- don't want to advertise the version on a public docs endpoint.
78
- - **DocEnvelope wire-contract docs** — `docs/doc-envelope-spec-v1.md` plus a
79
- validatable JSON Schema at `docs/doc-envelope-v1.schema.json` (filenames pinned
80
- to the envelope `specVersion`), for building third-party tools against the
81
- served envelope.
27
+ Works for `Create*` / `CreateHttp*`, direct calls, and all adapters. Complements (runs after) builder-level middleware.
82
28
 
83
- ### Internal
29
+ - **HonoAppBuilder middleware & context composition.** First-class support on the builder:
84
30
 
85
- - Single source of truth for the package version (`src/version.ts`), consumed by
86
- both the codegen file header and the doc-envelope metadata.
31
+ - `new HonoAppBuilder({ middleware: [mw...] })`
32
+ - `builder.use(mw)` (or `use(pattern, mw)`)
33
+ - `.register(factory, ctx, { middleware: [...], context?: extraLayer })`
87
34
 
88
- ## 10.0.0 2026-06-24
35
+ Added `HonoRequestMiddleware`, `RegisterOptions`, and improved server `resolveFactoryContext` / `composeContextInits` to support arrays of context initializers (left-to-right shallow merge).
89
36
 
90
- A maintenance major: the toolchain and supported peer ranges move up a major
91
- across the board. There are **no source API changes** — every public export,
92
- the codegen output (byte-identical against the frozen goldens), the client
93
- runtime, and the DocEnvelope shape are unchanged. The version is bumped to major
94
- purely to signal the dependency floor shift below.
37
+ - Updated documentation in `docs/core.md`, `docs/http-integrations.md`, `README.md`, and agent guidance to cover both layers and the recommended patterns (replacing manual `app.use` + stashing for protected surfaces).
95
38
 
96
39
  ### Changed
97
40
 
98
- - **Toolchain upgraded a major.** `typescript` 5 6, `eslint` & `@eslint/js`
99
- 9 → 10, `globals` 15 → 17. The full gate (typecheck + 1251 tests including the
100
- frozen codegen goldens + lint) passes on the new versions. The only code touched
101
- was lint conformance for ESLint 10's newly-recommended rules
102
- (`preserve-caught-error`, `no-useless-assignment`) — internal, no behavior change.
103
- - **Astro optional peer: 6 → 7.** The optional peer range remains
104
- `6.x.x || 7.x.x`, so existing Astro 6 consumers are unaffected; Astro 7 is now
105
- tested and supported.
41
+ - Agent config now recommends "Prefer middleware + layered context for access levels" instead of always using separate factories.
106
42
 
107
- ### Migration
43
+ ## 9.3.0 — 2026-06-25
108
44
 
109
- Nothing to do for consumers staying on their current peer versions. If you build
110
- against this package's types with a local TypeScript, note the dev/CI toolchain
111
- now targets TypeScript 6.
45
+ ### Improved
46
+ - **DX: autocomplete for HTTP procedure schema channels.** `CreateHttp` and `CreateHttpStream` now surface `THttpReqInput` (and its alias `APIInput`) / `THttpResInput` inside `TCreateHttpConfig` so IDEs offer `pathParams | query | body | headers` (and `body | headers` for res) when writing `schema: { req: { ... }, res: { ... } }`. A small `HttpSchemaInput` helper keeps the public bag generics (`TReq`/`TRes`) while making literal keys visible. `satisfies APIInput` continues to work for extra checking. Same shapes are reused by `CreateHttpStream` for consistency.
112
47
 
113
48
  ## 9.2.0 — 2026-06-19
114
49
 
package/README.md CHANGED
@@ -155,6 +155,8 @@ for await (const event of api.users.WatchUsers({})) { ... } // TypedStream
155
155
  still fail fast at registration).
156
156
  - Plug in another schema library with a 3-line `SchemaAdapter`
157
157
  (`Procedures({ schema: { adapters: [zodAdapter] } })`).
158
+ - Factory middleware (ctx + input aware, runs for all procedures):
159
+ `Procedures({ middleware: [({ ctx, input, next }) => ...] })`.
158
160
 
159
161
  ## Streaming
160
162
 
@@ -725,6 +725,14 @@ const { CreateUser } = CreateHttp('CreateUser', {
725
725
 
726
726
  **Fix:** Leave validation on for any factory whose handlers can be reached from untrusted callers. Only opt out when the factory is purely internal (e.g., a back-of-house procedure registry called from another already-validated procedure or a fully type-checked compile step).
727
727
 
728
+ ---
729
+
730
+ ## Raw `app.use` + stashing for auth/tenant (instead of builder middleware)
731
+
732
+ **Problem:** Manually doing `app.use('/api/*', authenticate(...))` before `HonoAppBuilder` + having ctx factories read "stashed" values leads to ordering issues, duplicated path logic, and hard-to-follow public vs protected surfaces.
733
+
734
+ **Fix:** Declare auth/tenant as `middleware` on the builder (config, `.use(mw)`, or per-`register({ middleware })`). Use `register(..., { context: extraLayer })` for augmentation. The old separate-factory + raw use style still works but is no longer the recommended default for this concern.
735
+
728
736
  ```typescript
729
737
  // GOOD — public factory keeps runtime validation
730
738
  const { Create: CreatePublic } = Procedures()
@@ -183,26 +183,15 @@ Registers a unary HTTP procedure (v8+). First-class surface for REST-style route
183
183
  ```typescript
184
184
  function CreateHttp<
185
185
  TName extends string,
186
- TReq extends { pathParams?: unknown; query?: unknown; body?: unknown; headers?: unknown } = {},
187
- TRes extends { body?: unknown; headers?: unknown } = {},
186
+ TReq extends THttpReqInput | undefined = undefined,
187
+ TRes extends THttpResInput | undefined = undefined,
188
188
  TErrorKey extends string = string
189
189
  >(
190
190
  name: TName,
191
- config: {
192
- path: string
193
- method: HttpMethod
194
- successStatus?: number
195
- scope?: string
196
- errors?: TErrorKey[]
197
- description?: string
198
- schema: {
199
- req?: TReq
200
- res?: TRes
201
- }
202
- },
191
+ config: TCreateHttpConfig<TReq, TRes, TErrorKey>,
203
192
  handler: (
204
193
  ctx: TContext & TLocalContext,
205
- req: { [K in keyof TReq]: Infer<TReq[K]> }
194
+ req: HttpReq<TReq>
206
195
  ) => Promise<HttpReturn<TRes>>
207
196
  ): {
208
197
  [K in TName]: typeof handler
@@ -215,7 +204,7 @@ function CreateHttp<
215
204
 
216
205
  - `config.path` — Route path. Supports Hono-style path params (`:id`).
217
206
  - `config.method` — HTTP method.
218
- - `config.schema.req` — Per-channel input schemas. Channels: `pathParams`, `query`, `body`, `headers`. Each channel independently validated.
207
+ - `config.schema.req` — Per-channel input schemas. The keys `pathParams`, `query`, `body`, `headers` are surfaced by `THttpReqInput` (and `APIInput`) for autocomplete and `satisfies` checks. Each channel independently validated.
219
208
  - `config.schema.res.body` — Response body schema (documentation; not runtime-validated).
220
209
  - `config.schema.res.headers` — When declared, handler **must** return `{ body, headers }` instead of the body bare. The builder reads `headers` and forwards them to the HTTP response.
221
210
  - `config.errors` — Taxonomy keys this route may emit (populates DocEnvelope for codegen).
@@ -1010,26 +999,40 @@ interface StreamHttpRouteDoc extends RPCConfig {
1010
999
  }
1011
1000
  ```
1012
1001
 
1013
- ### TCreateHttpConfig (v8)
1002
+ ### TCreateHttpConfig
1014
1003
 
1015
1004
  Config type for `CreateHttp`. HTTP fields are first-class — no `APIConfig` type parameter needed on the factory.
1016
1005
 
1006
+ The `schema.req` and `schema.res` use special input shapes (`THttpReqInput`, `THttpResInput`) so that object literals get autocomplete for the channel keys (`pathParams`, `query`, `body`, `headers`). `TReq` / `TRes` carry the user's concrete schema types for inference.
1007
+
1017
1008
  ```typescript
1018
- type TCreateHttpConfig<TReq, TRes, TErrorKey extends string = string> = {
1009
+ type TCreateHttpConfig<
1010
+ TReq extends THttpReqInput | undefined = undefined,
1011
+ TRes extends THttpResInput | undefined = undefined,
1012
+ TErrorKey extends string = string,
1013
+ > = {
1019
1014
  path: string
1020
1015
  method: HttpMethod
1021
1016
  successStatus?: number
1022
1017
  scope?: string
1023
1018
  errors?: TErrorKey[]
1024
1019
  description?: string
1025
- schema: {
1026
- req?: TReq // per-channel input: { pathParams?, query?, body?, headers? }
1027
- res?: TRes // structured response: { body?, headers? }
1020
+ schema?: {
1021
+ req?: HttpSchemaInput<THttpReqInput, TReq>
1022
+ res?: HttpSchemaInput<THttpResInput, TRes>
1028
1023
  }
1029
1024
  }
1030
1025
  ```
1031
1026
 
1032
- ### APIHttpRouteDoc (v8)
1027
+ `APIInput` (re-exported from `ts-procedures/http`) is an alias for `THttpReqInput` and is the recommended type for `satisfies` checks on `req`:
1028
+
1029
+ ```ts
1030
+ req: { pathParams: ..., query: ... } satisfies APIInput
1031
+ ```
1032
+
1033
+ See also `THttpReqInput`, `THttpResInput`, `HttpSchemaInput`, and `APIInput`.
1034
+
1035
+ ### APIHttpRouteDoc
1033
1036
 
1034
1037
  ```typescript
1035
1038
  interface APIHttpRouteDoc {
@@ -796,28 +796,39 @@ const docs = getProcedures().map(proc => ({
796
796
 
797
797
  ---
798
798
 
799
- ## Multiple Factories for Access Control
799
+ ## Access Control with Middleware + Layered Context (preferred)
800
+
801
+ Use builder middleware (`.use()`, config `middleware`, or per-register) + context composition for cross-cutting concerns like auth/tenant. This keeps surfaces on fewer factories/builders and makes ordering explicit.
800
802
 
801
803
  ```typescript
802
- type PublicContext = { requestId: string }
803
- type AuthContext = { userId: string; requestId: string }
804
+ import { HonoAppBuilder, type HonoRequestMiddleware } from 'ts-procedures/hono'
804
805
 
805
- const PublicRPC = Procedures<PublicContext, RPCConfig>()
806
- const AuthRPC = Procedures<AuthContext, RPCConfig>()
806
+ type Base = { requestId: string }
807
+ type Authed = Base & { userId: string; tenant: string }
807
808
 
808
- PublicRPC.Create('HealthCheck', { scope: 'health', version: 1 }, async () => ({ status: 'ok' }))
809
- AuthRPC.Create('GetProfile', { scope: 'users', version: 1 }, async (ctx) => fetchProfile(ctx.userId))
809
+ const RPC = Procedures<Authed | Base, RPCConfig>()
810
810
 
811
- // Register with different context resolvers
812
- const app = new HonoAppBuilder({ pathPrefix: '/api' })
813
- .register(PublicRPC, (c) => ({ requestId: c.req.header('x-request-id') }))
814
- .register(AuthRPC, async (c) => ({
815
- userId: await authenticate(c),
816
- requestId: c.req.header('x-request-id'),
811
+ RPC.Create('HealthCheck', { scope: 'health', version: 1 }, async () => ({ status: 'ok' }))
812
+ RPC.Create('GetProfile', { scope: 'users', version: 1 }, async (ctx) => fetchProfile(ctx.userId))
813
+
814
+ const authenticate: HonoRequestMiddleware = async (c, next) => {
815
+ const token = c.req.header('authorization')
816
+ if (!token) throw new Error('unauthorized')
817
+ ;(c as any).set?.('tenant', 'acme')
818
+ await next()
819
+ }
820
+
821
+ const app = new HonoAppBuilder({ pathPrefix: '/api', middleware: [authenticate] })
822
+ .register(RPC, (c) => ({
823
+ requestId: c.req.header('x-request-id') || 'req',
824
+ tenant: (c as any).get?.('tenant') ?? 'public',
825
+ userId: 'u-123',
817
826
  }))
818
827
  .build()
819
828
  ```
820
829
 
830
+ Separate factories remain valid for truly disjoint context shapes.
831
+
821
832
  ---
822
833
 
823
834
  ## Documentation Generation with extendProcedureDoc
@@ -55,7 +55,7 @@ import type { RequestSource } from 'ts-procedures/server'
55
55
 
56
56
  5. **Use TypeBox for schemas** (`import { Type } from 'typebox'`). Plain JSON Schema objects are not recognized. TypeBox is the built-in schema library; other libraries plug in via the `SchemaAdapter` interface (`Procedures({ schema: { adapters: [myAdapter] } })` — `{ name, detect, toJsonSchema }`). Custom adapters get runtime validation + docs only; compile-time `Infer<T>` inference is TypeBox-only. Default AJV config: `allErrors: true`, `coerceTypes: true`, `removeAdditional: true` — customize per factory via `Procedures({ validation: { ajv } })` (options merged over defaults, or a configured Ajv instance). The bundled TypeBox does **not** export `Type.Composite` — compose schemas with a flat property spread (`Type.Object({ ...Base.properties, name: Type.String() })`), which also keeps the generated JSON Schema a single `object` instead of an `allOf`.
57
57
 
58
- 6. **One factory per access level.** Separate `Procedures()` factories for public, authenticated, admin contexts.
58
+ 6. **Prefer middleware + layered context for access levels.** Use `HonoAppBuilder` `middleware`, `.use()`, or per-`register({ middleware, context })` for tenant/auth. Separate factories are still valid for truly disjoint `TContext` shapes.
59
59
 
60
60
  7. **onCreate callback enables framework integration.** Use for route registration, OpenAPI generation, logging.
61
61
 
@@ -55,7 +55,7 @@ import type { RequestSource } from 'ts-procedures/server'
55
55
 
56
56
  5. **Use TypeBox for schemas** (`import { Type } from 'typebox'`). Plain JSON Schema objects are not recognized. TypeBox is the built-in schema library; other libraries plug in via the `SchemaAdapter` interface (`Procedures({ schema: { adapters: [myAdapter] } })` — `{ name, detect, toJsonSchema }`). Custom adapters get runtime validation + docs only; compile-time `Infer<T>` inference is TypeBox-only. Default AJV config: `allErrors: true`, `coerceTypes: true`, `removeAdditional: true` — customize per factory via `Procedures({ validation: { ajv } })` (options merged over defaults, or a configured Ajv instance). The bundled TypeBox does **not** export `Type.Composite` — compose schemas with a flat property spread (`Type.Object({ ...Base.properties, name: Type.String() })`), which also keeps the generated JSON Schema a single `object` instead of an `allOf`.
57
57
 
58
- 6. **One factory per access level.** Separate `Procedures()` factories for public, authenticated, admin contexts.
58
+ 6. **Prefer middleware + layered context for access levels.** Use `HonoAppBuilder` `middleware`, `.use()`, or per-`register({ middleware, context })` for tenant/auth. Separate factories are still valid for truly disjoint `TContext` shapes.
59
59
 
60
60
  7. **onCreate callback enables framework integration.** Use for route registration, OpenAPI generation, logging.
61
61
 
@@ -3,10 +3,8 @@ import { dirname, resolve } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { describe, expect, it } from 'vitest';
5
5
  import { Type } from 'typebox';
6
- import pkg from '../../../package.json' with { type: 'json' };
7
6
  import { Procedures } from '../../core/procedures.js';
8
7
  import { HonoAppBuilder, defineErrorTaxonomy } from './index.js';
9
- import { DOC_ENVELOPE_SPEC_VERSION } from '../../server/spec-version.js';
10
8
  /**
11
9
  * THE envelope contract test: the v9 builder must emit a DocEnvelope
12
10
  * deep-equal to what v8.6.0 emitted for the same procedure set. The fixture
@@ -16,15 +14,12 @@ import { DOC_ENVELOPE_SPEC_VERSION } from '../../server/spec-version.js';
16
14
  * The envelope is codegen's input; if this test fails, generated client output
17
15
  * WILL drift.
18
16
  *
19
- * TWO documented deviations from the raw v8 capture:
20
- * 1. v8's CreateHttpStream dropped the `yield` schema (and `res.headers`) from
21
- * http-stream route docs — the registration stored `yieldType` while the
22
- * doc builder read `yield`. v9 fixes that, so the fixture's TailUser route
23
- * was patched to include the `yield` schema the builder now emits.
24
- * 2. v9 adds envelope-level `specVersion`/`generatorVersion` metadata that v8
25
- * never emitted. These are asserted explicitly below, then stripped before
26
- * the deep-equal so the rest stays byte-for-byte with the v8 capture.
27
- * Everything else is the untouched v8 capture.
17
+ * ONE documented deviation from the raw v8 capture: v8's CreateHttpStream
18
+ * dropped the `yield` schema (and `res.headers`) from http-stream route docs —
19
+ * the registration stored `yieldType` while the doc builder read `yield`. v9
20
+ * fixes that, so the fixture's TailUser route was patched to include the
21
+ * `yield` schema the builder now (correctly) emits. Everything else is the
22
+ * untouched v8 capture.
28
23
  */
29
24
  class TeapotError extends Error {
30
25
  }
@@ -97,12 +92,6 @@ describe('DocEnvelope parity with v8.6.0', () => {
97
92
  const fixturePath = resolve(dirname(fileURLToPath(import.meta.url)), '__fixtures__/parity-envelope.json');
98
93
  const expected = JSON.parse(await readFile(fixturePath, 'utf-8'));
99
94
  const actual = JSON.parse(JSON.stringify(builder.toDocEnvelope()));
100
- // Deviation #2: assert the new v9 envelope metadata, then strip it so the
101
- // remaining shape matches the untouched v8 capture.
102
- expect(actual.specVersion).toBe(DOC_ENVELOPE_SPEC_VERSION);
103
- expect(actual.generatorVersion).toBe(pkg.version);
104
- delete actual.specVersion;
105
- delete actual.generatorVersion;
106
95
  expect(actual).toEqual(expected);
107
96
  });
108
97
  });
@@ -1 +1 @@
1
- {"version":3,"file":"envelope-parity.test.js","sourceRoot":"","sources":["../../../src/adapters/hono/envelope-parity.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,GAAG,MAAM,uBAAuB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAGxE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAY,SAAQ,KAAK;CAAG;AAElC,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,OAAO,GAAG,UAAU,EAAsB,CAAA;QAChD,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAA;QAEtE,MAAM,CACJ,SAAS,EACT;YACE,KAAK,EAAE,OAAO;YACd,OAAO,E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AW,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,kBAAkB,EAAE;SACjF,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC5E,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;QAC7B,OAAO,CAAC,KAAK,EAAE,CAAA;QAEf,MAAM,WAAW,GAAG,OAAO,CACzB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACvC,mCAAmC,CACpC,CAAA;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;QAElE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,10 +1,11 @@
1
1
  import type { Hono } from 'hono';
2
2
  import type { THttpStreamProcedureRegistration } from '../../../core/types.js';
3
- import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem } from '../types.js';
3
+ import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem, HonoRequestMiddleware } from '../types.js';
4
4
  export declare function installHttpStreamRoute(params: {
5
5
  app: Hono;
6
6
  procedure: THttpStreamProcedureRegistration<any>;
7
7
  factoryItem: HonoFactoryItem;
8
8
  cfg: HonoAppBuilderConfig;
9
9
  docs: DocAccumulator;
10
+ builderMiddleware?: HonoRequestMiddleware[];
10
11
  }): void;
@@ -5,16 +5,23 @@ import { resolveFactoryContext } from '../../../server/context.js';
5
5
  import { extractReqChannels } from '../../../server/request/params.js';
6
6
  import { parseQueryNative } from '../../../server/request/query.js';
7
7
  import { SseEventSequencer } from '../../../server/sse.js';
8
- import { honoRequestSource, respondToDispatch } from '../request.js';
8
+ import { honoRequestSource, respondToDispatch, runMiddlewareList } from '../request.js';
9
9
  import { midStreamErrorConfig, preStreamErrorConfig } from '../types.js';
10
10
  export function installHttpStreamRoute(params) {
11
- const { app, procedure, factoryItem, cfg, docs } = params;
11
+ const { app, procedure, factoryItem, cfg, docs, builderMiddleware } = params;
12
12
  const queryParser = cfg.api?.queryParser ?? parseQueryNative;
13
13
  const route = buildHttpStreamRouteDoc(procedure, cfg.pathPrefix, factoryItem.extendProcedureDoc);
14
14
  docs.push(route);
15
15
  const reqSchema = procedure.config.schema?.req;
16
+ const combinedMw = [
17
+ ...(builderMiddleware ?? []),
18
+ ...(factoryItem.middleware ?? []),
19
+ ];
16
20
  app.on(procedure.config.method.toUpperCase(), route.fullPath, async (c) => {
17
21
  try {
22
+ const early = await runMiddlewareList(c, combinedMw);
23
+ if (early)
24
+ return early;
18
25
  const context = await resolveFactoryContext(factoryItem.factoryContext, c);
19
26
  const reqParams = reqSchema
20
27
  ? await extractReqChannels(honoRequestSource(c), procedure.config.method, reqSchema, queryParser)
@@ -1 +1 @@
1
- {"version":3,"file":"http-stream.js","sourceRoot":"","sources":["../../../../src/adapters/hono/handlers/http-stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAA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EAAE,EAAE;gBACnC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;gBAC/E,IAAI,CAAC;oBACH,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACxB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,UAAU,GAAG,MAAM,sBAAsB,CAAC;wBAC9C,GAAG,EAAE,KAAK;wBACV,SAAS;wBACT,GAAG,EAAE,CAAC;wBACN,GAAG,EAAE,oBAAoB,CAAC,GAAG,CAAC;qBAC/B,CAAC,CAAA;oBACF,MAAM,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;oBACnC,IAAI,UAAU,CAAC,UAAU;wBAAE,MAAM,UAAU,CAAC,UAAU,EAAE,CAAA;gBAC1D,CAAC;wBAAS,CAAC;oBACT,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;oBAC9C,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAA;gBACvB,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CACtB,CAAC,EACD,MAAM,sBAAsB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC,CAChG,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import type { Hono } from 'hono';
2
2
  import type { THttpProcedureRegistration } from '../../../core/types.js';
3
- import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem } from '../types.js';
3
+ import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem, HonoRequestMiddleware } from '../types.js';
4
4
  export declare function installHttpRoute(params: {
5
5
  app: Hono;
6
6
  procedure: THttpProcedureRegistration<any>;
7
7
  factoryItem: HonoFactoryItem;
8
8
  cfg: HonoAppBuilderConfig;
9
9
  docs: DocAccumulator;
10
+ builderMiddleware?: HonoRequestMiddleware[];
10
11
  }): void;
@@ -3,17 +3,24 @@ import { buildHttpRouteDoc } from '../../../server/docs/http-doc.js';
3
3
  import { resolveFactoryContext } from '../../../server/context.js';
4
4
  import { defaultSuccessStatus, extractReqChannels } from '../../../server/request/params.js';
5
5
  import { parseQueryNative } from '../../../server/request/query.js';
6
- import { honoRequestSource, respondToDispatch } from '../request.js';
6
+ import { honoRequestSource, respondToDispatch, runMiddlewareList } from '../request.js';
7
7
  import { preStreamErrorConfig } from '../types.js';
8
8
  export function installHttpRoute(params) {
9
- const { app, procedure, factoryItem, cfg, docs } = params;
9
+ const { app, procedure, factoryItem, cfg, docs, builderMiddleware } = params;
10
10
  const queryParser = cfg.api?.queryParser ?? parseQueryNative;
11
11
  const route = buildHttpRouteDoc(procedure, cfg.pathPrefix, factoryItem.extendProcedureDoc);
12
12
  docs.push(route);
13
13
  const successStatus = procedure.config.successStatus ?? defaultSuccessStatus(procedure.config.method);
14
14
  const reqSchema = procedure.config.schema?.req;
15
+ const combinedMw = [
16
+ ...(builderMiddleware ?? []),
17
+ ...(factoryItem.middleware ?? []),
18
+ ];
15
19
  app.on(procedure.config.method.toUpperCase(), route.fullPath, async (c) => {
16
20
  try {
21
+ const early = await runMiddlewareList(c, combinedMw);
22
+ if (early)
23
+ return early;
17
24
  const context = await resolveFactoryContext(factoryItem.factoryContext, c);
18
25
  const reqParams = reqSchema
19
26
  ? await extractReqChannels(honoRequestSource(c), procedure.config.method, reqSchema, queryParser)
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/adapters/hono/handlers/http.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sB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,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,aAAa;gBACrC,CAAC,CAAE,CAAC,MAAM,IAAI,EAAE,CAA2C;gBAC3D,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;YAExC,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAC3C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAiC,CAAC;oBAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACxF,CAAC;YAED,qEAAqE;YACrE,wEAAwE;YACxE,wEAAwE;YACxE,oEAAoE;YACpE,IAAI,aAAa,KAAK,GAAG,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBAChD,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,aAAoB,CAAC,CAAA;YAC3C,CAAC;YAED,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,aAAoB,CAAC,CAAA;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CACtB,CAAC,EACD,MAAM,sBAAsB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC,CAChG,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import type { Hono } from 'hono';
2
2
  import type { TProcedureRegistration } from '../../../core/types.js';
3
3
  import type { RPCConfig } from '../../../server/types.js';
4
- import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem } from '../types.js';
4
+ import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem, HonoRequestMiddleware } from '../types.js';
5
5
  export declare function installRpcRoute(params: {
6
6
  app: Hono;
7
7
  procedure: TProcedureRegistration<any, RPCConfig>;
8
8
  factoryItem: HonoFactoryItem;
9
9
  cfg: HonoAppBuilderConfig;
10
10
  docs: DocAccumulator;
11
+ builderMiddleware?: HonoRequestMiddleware[];
11
12
  }): void;
@@ -1,14 +1,21 @@
1
1
  import { dispatchPreStreamError } from '../../../server/errors/dispatch.js';
2
2
  import { buildRpcRouteDoc } from '../../../server/docs/rpc-doc.js';
3
3
  import { resolveFactoryContext } from '../../../server/context.js';
4
- import { respondToDispatch } from '../request.js';
4
+ import { respondToDispatch, runMiddlewareList } from '../request.js';
5
5
  import { preStreamErrorConfig } from '../types.js';
6
6
  export function installRpcRoute(params) {
7
- const { app, procedure, factoryItem, cfg, docs } = params;
7
+ const { app, procedure, factoryItem, cfg, docs, builderMiddleware } = params;
8
8
  const route = buildRpcRouteDoc(procedure, cfg.pathPrefix, factoryItem.extendProcedureDoc);
9
9
  docs.push(route);
10
+ const combinedMw = [
11
+ ...(builderMiddleware ?? []),
12
+ ...(factoryItem.middleware ?? []),
13
+ ];
10
14
  app.post(route.path, async (c) => {
11
15
  try {
16
+ const early = await runMiddlewareList(c, combinedMw);
17
+ if (early)
18
+ return early;
12
19
  const context = await resolveFactoryContext(factoryItem.factoryContext, c);
13
20
  const body = await c.req.json().catch(() => ({}));
14
21
  const result = await procedure.handler({ ...context, signal: c.req.raw.signal }, body);
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../../../src/adapters/hono/handlers/rpc.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAGlD,MAAM,UAAU,eAAe,CAAC,M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AAE,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAA;YAEtF,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;YAElC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CACtB,CAAC,EACD,MAAM,sBAAsB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC,CAChG,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { Hono } from 'hono';
2
2
  import type { TStreamProcedureRegistration } from '../../../core/types.js';
3
3
  import type { RPCConfig, StreamMode } from '../../../server/types.js';
4
- import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem } from '../types.js';
4
+ import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem, HonoRequestMiddleware } from '../types.js';
5
5
  export declare function installRpcStreamRoute(params: {
6
6
  app: Hono;
7
7
  procedure: TStreamProcedureRegistration<any, RPCConfig>;
@@ -9,4 +9,5 @@ export declare function installRpcStreamRoute(params: {
9
9
  cfg: HonoAppBuilderConfig;
10
10
  docs: DocAccumulator;
11
11
  streamMode: StreamMode;
12
+ builderMiddleware?: HonoRequestMiddleware[];
12
13
  }): void;
@@ -4,14 +4,21 @@ import { dispatchMidStreamError, dispatchPreStreamError } from '../../../server/
4
4
  import { buildStreamRouteDoc } from '../../../server/docs/stream-doc.js';
5
5
  import { resolveFactoryContext } from '../../../server/context.js';
6
6
  import { SseEventSequencer } from '../../../server/sse.js';
7
- import { respondToDispatch } from '../request.js';
7
+ import { respondToDispatch, runMiddlewareList } from '../request.js';
8
8
  import { midStreamErrorConfig, preStreamErrorConfig } from '../types.js';
9
9
  export function installRpcStreamRoute(params) {
10
- const { app, procedure, factoryItem, cfg, docs, streamMode } = params;
10
+ const { app, procedure, factoryItem, cfg, docs, streamMode, builderMiddleware } = params;
11
11
  const route = buildStreamRouteDoc(procedure, streamMode, cfg.pathPrefix, factoryItem.extendProcedureDoc);
12
12
  docs.push(route);
13
+ const combinedMw = [
14
+ ...(builderMiddleware ?? []),
15
+ ...(factoryItem.middleware ?? []),
16
+ ];
13
17
  const handler = async (c) => {
14
18
  try {
19
+ const early = await runMiddlewareList(c, combinedMw);
20
+ if (early)
21
+ return early;
15
22
  const context = await resolveFactoryContext(factoryItem.factoryContext, c);
16
23
  const reqParams = c.req.method === 'GET'
17
24
  ? Object.fromEntries(new URL(c.req.url).searchParams)