ts-procedures 8.6.0 → 9.1.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 (630) hide show
  1. package/CHANGELOG.md +540 -0
  2. package/README.md +166 -101
  3. package/agent_config/claude-code/.claude-plugin/plugin.json +1 -1
  4. package/agent_config/claude-code/agents/ts-procedures-architect.md +11 -10
  5. package/agent_config/claude-code/skills/ts-procedures/SKILL.md +25 -12
  6. package/agent_config/claude-code/skills/ts-procedures/anti-patterns.md +10 -12
  7. package/agent_config/claude-code/skills/ts-procedures/api-reference.md +141 -45
  8. package/agent_config/claude-code/skills/ts-procedures/checklist.md +7 -6
  9. package/agent_config/claude-code/skills/ts-procedures/patterns.md +45 -6
  10. package/agent_config/claude-code/skills/ts-procedures/templates/client.md +1 -1
  11. package/agent_config/claude-code/skills/ts-procedures/templates/hono.md +1 -1
  12. package/agent_config/copilot/copilot-instructions.md +50 -33
  13. package/agent_config/cursor/cursorrules +50 -33
  14. package/build/adapters/astro/astro-context.js.map +1 -0
  15. package/build/adapters/astro/create-handler.js.map +1 -0
  16. package/build/adapters/astro/index.js.map +1 -0
  17. package/build/{implementations/http → adapters}/astro/index.test.js +1 -1
  18. package/build/adapters/astro/index.test.js.map +1 -0
  19. package/build/adapters/astro/rewrite-request.js.map +1 -0
  20. package/build/adapters/hono/envelope-parity.test.js +98 -0
  21. package/build/adapters/hono/envelope-parity.test.js.map +1 -0
  22. package/build/{implementations/http → adapters}/hono/handlers/http-stream.d.ts +1 -1
  23. package/build/adapters/hono/handlers/http-stream.js +55 -0
  24. package/build/adapters/hono/handlers/http-stream.js.map +1 -0
  25. package/build/{implementations/http → adapters}/hono/handlers/http-stream.test.js +1 -1
  26. package/build/adapters/hono/handlers/http-stream.test.js.map +1 -0
  27. package/build/{implementations/http → adapters}/hono/handlers/http.d.ts +1 -1
  28. package/build/adapters/hono/handlers/http.js +50 -0
  29. package/build/adapters/hono/handlers/http.js.map +1 -0
  30. package/build/{implementations/http → adapters}/hono/handlers/http.test.js +1 -1
  31. package/build/adapters/hono/handlers/http.test.js.map +1 -0
  32. package/build/{implementations/http → adapters}/hono/handlers/rpc.d.ts +2 -2
  33. package/build/adapters/hono/handlers/rpc.js +23 -0
  34. package/build/adapters/hono/handlers/rpc.js.map +1 -0
  35. package/build/{implementations/http → adapters}/hono/handlers/rpc.test.js +1 -1
  36. package/build/adapters/hono/handlers/rpc.test.js.map +1 -0
  37. package/build/adapters/hono/handlers/stream.d.ts +12 -0
  38. package/build/adapters/hono/handlers/stream.js +89 -0
  39. package/build/adapters/hono/handlers/stream.js.map +1 -0
  40. package/build/{implementations/http → adapters}/hono/handlers/stream.test.js +3 -2
  41. package/build/adapters/hono/handlers/stream.test.js.map +1 -0
  42. package/build/{implementations/http → adapters}/hono/index.d.ts +24 -12
  43. package/build/{implementations/http → adapters}/hono/index.js +19 -8
  44. package/build/adapters/hono/index.js.map +1 -0
  45. package/build/{implementations/http → adapters}/hono/index.test.js +2 -4
  46. package/build/adapters/hono/index.test.js.map +1 -0
  47. package/build/{implementations/http → adapters/hono}/on-request-error.test.js +2 -2
  48. package/build/adapters/hono/on-request-error.test.js.map +1 -0
  49. package/build/adapters/hono/request.d.ts +7 -0
  50. package/build/adapters/hono/request.js +22 -0
  51. package/build/adapters/hono/request.js.map +1 -0
  52. package/build/{implementations/http → adapters/hono}/route-errors.test.js +4 -4
  53. package/build/adapters/hono/route-errors.test.js.map +1 -0
  54. package/build/adapters/hono/types.d.ts +55 -0
  55. package/build/adapters/hono/types.js +19 -0
  56. package/build/adapters/hono/types.js.map +1 -0
  57. package/build/client/freeze.test.js +39 -0
  58. package/build/client/freeze.test.js.map +1 -0
  59. package/build/client/typed-error-dispatch.test.js +2 -2
  60. package/build/client/typed-error-dispatch.test.js.map +1 -1
  61. package/build/codegen/__fixtures__/make-envelope.d.ts +1 -1
  62. package/build/codegen/bin/cli.d.ts +5 -0
  63. package/build/codegen/bin/cli.js +139 -182
  64. package/build/codegen/bin/cli.js.map +1 -1
  65. package/build/codegen/bin/cli.test.js +12 -2
  66. package/build/codegen/bin/cli.test.js.map +1 -1
  67. package/build/codegen/bin/flag-specs.d.ts +9 -0
  68. package/build/codegen/bin/flag-specs.js +33 -31
  69. package/build/codegen/bin/flag-specs.js.map +1 -1
  70. package/build/codegen/bin/flag-specs.test.js +14 -1
  71. package/build/codegen/bin/flag-specs.test.js.map +1 -1
  72. package/build/codegen/collect-models.d.ts +1 -1
  73. package/build/codegen/emit/api-route.d.ts +8 -0
  74. package/build/codegen/emit/api-route.js +156 -0
  75. package/build/codegen/emit/api-route.js.map +1 -0
  76. package/build/codegen/emit/context.d.ts +30 -0
  77. package/build/codegen/emit/context.js +2 -0
  78. package/build/codegen/emit/context.js.map +1 -0
  79. package/build/codegen/emit/declarations.d.ts +24 -0
  80. package/build/codegen/emit/declarations.js +48 -0
  81. package/build/codegen/emit/declarations.js.map +1 -0
  82. package/build/codegen/emit/format-types.d.ts +61 -0
  83. package/build/codegen/emit/format-types.js +188 -0
  84. package/build/codegen/emit/format-types.js.map +1 -0
  85. package/build/codegen/emit/http-stream-route.d.ts +7 -0
  86. package/build/codegen/emit/http-stream-route.js +138 -0
  87. package/build/codegen/emit/http-stream-route.js.map +1 -0
  88. package/build/codegen/emit/route-shared.d.ts +37 -0
  89. package/build/codegen/emit/route-shared.js +88 -0
  90. package/build/codegen/emit/route-shared.js.map +1 -0
  91. package/build/codegen/emit/rpc-route.d.ts +7 -0
  92. package/build/codegen/emit/rpc-route.js +37 -0
  93. package/build/codegen/emit/rpc-route.js.map +1 -0
  94. package/build/codegen/emit/scope-file.d.ts +39 -0
  95. package/build/codegen/emit/scope-file.js +166 -0
  96. package/build/codegen/emit/scope-file.js.map +1 -0
  97. package/build/codegen/emit/stream-route.d.ts +7 -0
  98. package/build/codegen/emit/stream-route.js +62 -0
  99. package/build/codegen/emit/stream-route.js.map +1 -0
  100. package/build/codegen/emit-errors.d.ts +1 -1
  101. package/build/codegen/emit-errors.integration.test.js +1 -1
  102. package/build/codegen/emit-errors.integration.test.js.map +1 -1
  103. package/build/codegen/emit-scope.d.ts +13 -30
  104. package/build/codegen/emit-scope.js +15 -844
  105. package/build/codegen/emit-scope.js.map +1 -1
  106. package/build/codegen/emit-scope.test.js +67 -0
  107. package/build/codegen/emit-scope.test.js.map +1 -1
  108. package/build/codegen/goldens.test.js +69 -0
  109. package/build/codegen/goldens.test.js.map +1 -0
  110. package/build/codegen/group-routes.d.ts +1 -1
  111. package/build/codegen/pipeline.d.ts +1 -1
  112. package/build/codegen/resolve-envelope.d.ts +1 -1
  113. package/build/codegen/targets/_shared/error-schemas.d.ts +1 -1
  114. package/build/codegen/targets/_shared/route-slots.d.ts +1 -1
  115. package/build/codegen/targets/_shared/target-run.d.ts +1 -1
  116. package/build/codegen/targets/kotlin/emit-route-kotlin.d.ts +1 -1
  117. package/build/codegen/targets/swift/emit-route-swift.d.ts +1 -1
  118. package/build/core/create-http-stream.d.ts +50 -0
  119. package/build/core/create-http-stream.js +108 -0
  120. package/build/core/create-http-stream.js.map +1 -0
  121. package/build/{create-http-stream.test.js → core/create-http-stream.test.js} +1 -1
  122. package/build/core/create-http-stream.test.js.map +1 -0
  123. package/build/core/create-http.d.ts +51 -0
  124. package/build/core/create-http.js +65 -0
  125. package/build/core/create-http.js.map +1 -0
  126. package/build/{create-http.test.js → core/create-http.test.js} +27 -4
  127. package/build/core/create-http.test.js.map +1 -0
  128. package/build/core/create-stream.d.ts +26 -0
  129. package/build/core/create-stream.js +80 -0
  130. package/build/core/create-stream.js.map +1 -0
  131. package/build/{create-stream.test.js → core/create-stream.test.js} +23 -28
  132. package/build/core/create-stream.test.js.map +1 -0
  133. package/build/core/create.d.ts +22 -0
  134. package/build/core/create.js +71 -0
  135. package/build/core/create.js.map +1 -0
  136. package/build/{create.test.js → core/create.test.js} +25 -46
  137. package/build/core/create.test.js.map +1 -0
  138. package/build/core/definition-site.d.ts +24 -0
  139. package/build/{stack-utils.js → core/definition-site.js} +20 -20
  140. package/build/core/definition-site.js.map +1 -0
  141. package/build/{stack-utils.test.js → core/definition-site.test.js} +12 -3
  142. package/build/core/definition-site.test.js.map +1 -0
  143. package/build/{errors.d.ts → core/errors.d.ts} +19 -8
  144. package/build/{errors.js → core/errors.js} +21 -26
  145. package/build/core/errors.js.map +1 -0
  146. package/build/core/errors.test.js.map +1 -0
  147. package/build/core/factory-options.test.js +82 -0
  148. package/build/core/factory-options.test.js.map +1 -0
  149. package/build/core/http-route.d.ts +13 -0
  150. package/build/core/http-route.js +54 -0
  151. package/build/core/http-route.js.map +1 -0
  152. package/build/core/internal.d.ts +72 -0
  153. package/build/core/internal.js +128 -0
  154. package/build/core/internal.js.map +1 -0
  155. package/build/{migration.test.js → core/migration.test.js} +17 -1
  156. package/build/core/migration.test.js.map +1 -0
  157. package/build/core/procedures.d.ts +143 -0
  158. package/build/core/procedures.js +64 -0
  159. package/build/core/procedures.js.map +1 -0
  160. package/build/{index.test.js → core/procedures.test.js} +14 -11
  161. package/build/core/procedures.test.js.map +1 -0
  162. package/build/core/types.d.ts +183 -0
  163. package/build/{schema → core}/types.js.map +1 -1
  164. package/build/exports.d.ts +31 -11
  165. package/build/exports.js +23 -8
  166. package/build/exports.js.map +1 -1
  167. package/build/schema/adapter.d.ts +35 -0
  168. package/build/schema/adapter.js +13 -0
  169. package/build/schema/adapter.js.map +1 -0
  170. package/build/schema/adapter.test.js +53 -0
  171. package/build/schema/adapter.test.js.map +1 -0
  172. package/build/schema/compile.d.ts +37 -0
  173. package/build/schema/compile.js +38 -0
  174. package/build/schema/compile.js.map +1 -0
  175. package/build/schema/compile.test.js +78 -0
  176. package/build/schema/compile.test.js.map +1 -0
  177. package/build/schema/compute-schema.d.ts +47 -37
  178. package/build/schema/compute-schema.js +86 -29
  179. package/build/schema/compute-schema.js.map +1 -1
  180. package/build/schema/compute-schema.test.js +158 -40
  181. package/build/schema/compute-schema.test.js.map +1 -1
  182. package/build/schema/json-schema.d.ts +17 -0
  183. package/build/schema/json-schema.js +2 -0
  184. package/build/schema/json-schema.js.map +1 -0
  185. package/build/schema/typebox.d.ts +11 -0
  186. package/build/schema/typebox.js +24 -0
  187. package/build/schema/typebox.js.map +1 -0
  188. package/build/schema/typebox.test.js +34 -0
  189. package/build/schema/typebox.test.js.map +1 -0
  190. package/build/server/context.d.ts +8 -0
  191. package/build/server/context.js +7 -0
  192. package/build/server/context.js.map +1 -0
  193. package/build/server/context.test.js +16 -0
  194. package/build/server/context.test.js.map +1 -0
  195. package/build/{doc-envelope.d.ts → server/doc-envelope.d.ts} +1 -1
  196. package/build/server/doc-envelope.js.map +1 -0
  197. package/build/server/doc-envelope.test.d.ts +1 -0
  198. package/build/server/doc-envelope.test.js.map +1 -0
  199. package/build/{implementations/http → server}/doc-registry.d.ts +7 -2
  200. package/build/{implementations/http → server}/doc-registry.js +9 -5
  201. package/build/server/doc-registry.js.map +1 -0
  202. package/build/server/doc-registry.test.d.ts +1 -0
  203. package/build/{implementations/http → server}/doc-registry.test.js +27 -24
  204. package/build/server/doc-registry.test.js.map +1 -0
  205. package/build/server/docs/docs.test.d.ts +1 -0
  206. package/build/server/docs/docs.test.js +237 -0
  207. package/build/server/docs/docs.test.js.map +1 -0
  208. package/build/{implementations/http/hono → server}/docs/http-doc.d.ts +2 -2
  209. package/build/{implementations/http/hono → server}/docs/http-doc.js +1 -1
  210. package/build/server/docs/http-doc.js.map +1 -0
  211. package/build/{implementations/http/hono → server}/docs/http-stream-doc.d.ts +2 -2
  212. package/build/{implementations/http/hono → server}/docs/http-stream-doc.js +1 -1
  213. package/build/server/docs/http-stream-doc.js.map +1 -0
  214. package/build/{implementations/http/hono → server}/docs/rpc-doc.d.ts +2 -2
  215. package/build/{implementations/http/hono → server}/docs/rpc-doc.js +1 -1
  216. package/build/server/docs/rpc-doc.js.map +1 -0
  217. package/build/{implementations/http/hono → server}/docs/stream-doc.d.ts +2 -2
  218. package/build/{implementations/http/hono → server}/docs/stream-doc.js +1 -1
  219. package/build/server/docs/stream-doc.js.map +1 -0
  220. package/build/server/errors/dispatch.d.ts +96 -0
  221. package/build/{implementations/http/error-dispatch.js → server/errors/dispatch.js} +20 -10
  222. package/build/server/errors/dispatch.js.map +1 -0
  223. package/build/server/errors/dispatch.test.d.ts +1 -0
  224. package/build/server/errors/dispatch.test.js +418 -0
  225. package/build/server/errors/dispatch.test.js.map +1 -0
  226. package/build/{implementations/http/error-taxonomy.d.ts → server/errors/taxonomy.d.ts} +8 -17
  227. package/build/{implementations/http/error-taxonomy.js → server/errors/taxonomy.js} +6 -15
  228. package/build/server/errors/taxonomy.js.map +1 -0
  229. package/build/server/errors/taxonomy.test.d.ts +1 -0
  230. package/build/{implementations/http/error-taxonomy.test.js → server/errors/taxonomy.test.js} +45 -39
  231. package/build/server/errors/taxonomy.test.js.map +1 -0
  232. package/build/server/index.d.ts +29 -0
  233. package/build/server/index.js +27 -0
  234. package/build/server/index.js.map +1 -0
  235. package/build/server/no-framework-imports.test.d.ts +1 -0
  236. package/build/server/no-framework-imports.test.js +40 -0
  237. package/build/server/no-framework-imports.test.js.map +1 -0
  238. package/build/{implementations/http/hono/path.d.ts → server/paths.d.ts} +2 -3
  239. package/build/{implementations/http/hono/path.js → server/paths.js} +1 -1
  240. package/build/server/paths.js.map +1 -0
  241. package/build/server/paths.test.d.ts +1 -0
  242. package/build/server/paths.test.js +111 -0
  243. package/build/server/paths.test.js.map +1 -0
  244. package/build/server/request/params.d.ts +29 -0
  245. package/build/server/request/params.js +43 -0
  246. package/build/server/request/params.js.map +1 -0
  247. package/build/server/request/params.test.d.ts +1 -0
  248. package/build/server/request/params.test.js +91 -0
  249. package/build/server/request/params.test.js.map +1 -0
  250. package/build/server/request/query.d.ts +9 -0
  251. package/build/server/request/query.js +22 -0
  252. package/build/server/request/query.js.map +1 -0
  253. package/build/server/request/query.test.d.ts +1 -0
  254. package/build/server/request/query.test.js +60 -0
  255. package/build/server/request/query.test.js.map +1 -0
  256. package/build/server/sse.d.ts +70 -0
  257. package/build/server/sse.js +94 -0
  258. package/build/server/sse.js.map +1 -0
  259. package/build/server/sse.test.d.ts +1 -0
  260. package/build/server/sse.test.js +98 -0
  261. package/build/server/sse.test.js.map +1 -0
  262. package/build/{implementations → server}/types.d.ts +17 -15
  263. package/build/{implementations → server}/types.js.map +1 -1
  264. package/docs/astro-adapter.md +8 -9
  265. package/docs/client-and-codegen.md +10 -4
  266. package/docs/client-error-handling.md +5 -5
  267. package/docs/codegen-kotlin.md +2 -3
  268. package/docs/codegen-swift.md +1 -2
  269. package/docs/core.md +135 -54
  270. package/docs/http-integrations.md +58 -6
  271. package/docs/migration-v8-to-v9.md +200 -0
  272. package/docs/plans/2026-06-09-v9-rewrite.md +130 -0
  273. package/docs/specs/2026-06-09-v9-rewrite-design.md +221 -0
  274. package/docs/streaming.md +12 -0
  275. package/package.json +25 -48
  276. package/src/{implementations/http → adapters}/astro/index.test.ts +2 -2
  277. package/src/adapters/hono/__fixtures__/parity-envelope.json +389 -0
  278. package/src/adapters/hono/envelope-parity.test.ts +126 -0
  279. package/src/{implementations/http → adapters}/hono/handlers/http-stream.test.ts +1 -1
  280. package/src/adapters/hono/handlers/http-stream.ts +73 -0
  281. package/src/{implementations/http → adapters}/hono/handlers/http.test.ts +1 -1
  282. package/src/adapters/hono/handlers/http.ts +70 -0
  283. package/src/{implementations/http → adapters}/hono/handlers/rpc.test.ts +2 -2
  284. package/src/adapters/hono/handlers/rpc.ts +39 -0
  285. package/src/{implementations/http → adapters}/hono/handlers/stream.test.ts +4 -3
  286. package/src/{implementations/http → adapters}/hono/handlers/stream.ts +19 -92
  287. package/src/{implementations/http → adapters}/hono/index.test.ts +14 -16
  288. package/src/{implementations/http → adapters}/hono/index.ts +35 -30
  289. package/src/{implementations/http → adapters/hono}/on-request-error.test.ts +3 -3
  290. package/src/adapters/hono/request.ts +28 -0
  291. package/src/{implementations/http → adapters/hono}/route-errors.test.ts +5 -5
  292. package/src/{implementations/http → adapters}/hono/types.ts +43 -20
  293. package/src/client/freeze.test.ts +41 -0
  294. package/src/client/typed-error-dispatch.test.ts +3 -3
  295. package/src/codegen/__fixtures__/make-envelope.ts +1 -1
  296. package/src/codegen/__fixtures__/models-envelope.json +310 -0
  297. package/src/codegen/__goldens__/MANIFEST.json +85 -0
  298. package/src/codegen/__goldens__/kotlin-default--models/Billing.kt +112 -0
  299. package/src/codegen/__goldens__/kotlin-default--models/BillingReports.kt +26 -0
  300. package/src/codegen/__goldens__/kotlin-default--models/Orders.kt +88 -0
  301. package/src/codegen/__goldens__/kotlin-default--users/Users.kt +189 -0
  302. package/src/codegen/__goldens__/swift-default--models/Billing.swift +97 -0
  303. package/src/codegen/__goldens__/swift-default--models/BillingReports.swift +20 -0
  304. package/src/codegen/__goldens__/swift-default--models/Orders.swift +81 -0
  305. package/src/codegen/__goldens__/swift-default--users/Users.swift +204 -0
  306. package/src/codegen/__goldens__/ts-default--models/_client.ts +1319 -0
  307. package/src/codegen/__goldens__/ts-default--models/_errors.ts +90 -0
  308. package/src/codegen/__goldens__/ts-default--models/_models.ts +10 -0
  309. package/src/codegen/__goldens__/ts-default--models/_types.ts +502 -0
  310. package/src/codegen/__goldens__/ts-default--models/billing-reports.ts +29 -0
  311. package/src/codegen/__goldens__/ts-default--models/billing.ts +67 -0
  312. package/src/codegen/__goldens__/ts-default--models/index.ts +48 -0
  313. package/src/codegen/__goldens__/ts-default--models/orders.ts +80 -0
  314. package/src/codegen/__goldens__/ts-default--users/_client.ts +1319 -0
  315. package/src/codegen/__goldens__/ts-default--users/_errors.ts +90 -0
  316. package/src/codegen/__goldens__/ts-default--users/_types.ts +502 -0
  317. package/src/codegen/__goldens__/ts-default--users/index.ts +38 -0
  318. package/src/codegen/__goldens__/ts-default--users/users.ts +169 -0
  319. package/src/codegen/__goldens__/ts-external-runtime--models/_errors.ts +90 -0
  320. package/src/codegen/__goldens__/ts-external-runtime--models/_models.ts +10 -0
  321. package/src/codegen/__goldens__/ts-external-runtime--models/billing-reports.ts +29 -0
  322. package/src/codegen/__goldens__/ts-external-runtime--models/billing.ts +67 -0
  323. package/src/codegen/__goldens__/ts-external-runtime--models/index.ts +48 -0
  324. package/src/codegen/__goldens__/ts-external-runtime--models/orders.ts +80 -0
  325. package/src/codegen/__goldens__/ts-external-runtime--users/_errors.ts +90 -0
  326. package/src/codegen/__goldens__/ts-external-runtime--users/index.ts +38 -0
  327. package/src/codegen/__goldens__/ts-external-runtime--users/users.ts +169 -0
  328. package/src/codegen/__goldens__/ts-flat--models/_client.ts +1319 -0
  329. package/src/codegen/__goldens__/ts-flat--models/_errors.ts +87 -0
  330. package/src/codegen/__goldens__/ts-flat--models/_models.ts +10 -0
  331. package/src/codegen/__goldens__/ts-flat--models/_types.ts +502 -0
  332. package/src/codegen/__goldens__/ts-flat--models/billing-reports.ts +28 -0
  333. package/src/codegen/__goldens__/ts-flat--models/billing.ts +51 -0
  334. package/src/codegen/__goldens__/ts-flat--models/index.ts +42 -0
  335. package/src/codegen/__goldens__/ts-flat--models/orders.ts +73 -0
  336. package/src/codegen/__goldens__/ts-flat--users/_client.ts +1319 -0
  337. package/src/codegen/__goldens__/ts-flat--users/_errors.ts +87 -0
  338. package/src/codegen/__goldens__/ts-flat--users/_types.ts +502 -0
  339. package/src/codegen/__goldens__/ts-flat--users/index.ts +34 -0
  340. package/src/codegen/__goldens__/ts-flat--users/users.ts +126 -0
  341. package/src/codegen/__goldens__/ts-no-share-models--models/_client.ts +1319 -0
  342. package/src/codegen/__goldens__/ts-no-share-models--models/_errors.ts +90 -0
  343. package/src/codegen/__goldens__/ts-no-share-models--models/_types.ts +502 -0
  344. package/src/codegen/__goldens__/ts-no-share-models--models/billing-reports.ts +29 -0
  345. package/src/codegen/__goldens__/ts-no-share-models--models/billing.ts +111 -0
  346. package/src/codegen/__goldens__/ts-no-share-models--models/index.ts +48 -0
  347. package/src/codegen/__goldens__/ts-no-share-models--models/orders.ts +112 -0
  348. package/src/codegen/__goldens__/ts-no-share-models--users/_client.ts +1319 -0
  349. package/src/codegen/__goldens__/ts-no-share-models--users/_errors.ts +90 -0
  350. package/src/codegen/__goldens__/ts-no-share-models--users/_types.ts +502 -0
  351. package/src/codegen/__goldens__/ts-no-share-models--users/index.ts +38 -0
  352. package/src/codegen/__goldens__/ts-no-share-models--users/users.ts +169 -0
  353. package/src/codegen/__goldens__/ts-shared-models-module--models/_client.ts +1319 -0
  354. package/src/codegen/__goldens__/ts-shared-models-module--models/_errors.ts +90 -0
  355. package/src/codegen/__goldens__/ts-shared-models-module--models/_models.ts +7 -0
  356. package/src/codegen/__goldens__/ts-shared-models-module--models/_types.ts +502 -0
  357. package/src/codegen/__goldens__/ts-shared-models-module--models/billing-reports.ts +29 -0
  358. package/src/codegen/__goldens__/ts-shared-models-module--models/billing.ts +67 -0
  359. package/src/codegen/__goldens__/ts-shared-models-module--models/index.ts +48 -0
  360. package/src/codegen/__goldens__/ts-shared-models-module--models/orders.ts +80 -0
  361. package/src/codegen/bin/cli.test.ts +13 -2
  362. package/src/codegen/bin/cli.ts +181 -144
  363. package/src/codegen/bin/flag-specs.test.ts +16 -1
  364. package/src/codegen/bin/flag-specs.ts +43 -31
  365. package/src/codegen/bundle-size.test.ts +1 -1
  366. package/src/codegen/collect-models.ts +1 -1
  367. package/src/codegen/e2e.test.ts +1 -1
  368. package/src/codegen/emit/api-route.ts +184 -0
  369. package/src/codegen/emit/context.ts +32 -0
  370. package/src/codegen/emit/declarations.ts +49 -0
  371. package/src/codegen/emit/format-types.ts +232 -0
  372. package/src/codegen/emit/http-stream-route.ts +162 -0
  373. package/src/codegen/emit/route-shared.ts +104 -0
  374. package/src/codegen/emit/rpc-route.ts +49 -0
  375. package/src/codegen/emit/scope-file.ts +226 -0
  376. package/src/codegen/emit/stream-route.ts +81 -0
  377. package/src/codegen/emit-errors.integration.test.ts +2 -2
  378. package/src/codegen/emit-errors.test.ts +1 -1
  379. package/src/codegen/emit-errors.ts +1 -1
  380. package/src/codegen/emit-scope.test.ts +75 -2
  381. package/src/codegen/emit-scope.ts +15 -1048
  382. package/src/codegen/goldens.test.ts +89 -0
  383. package/src/codegen/group-routes.test.ts +1 -1
  384. package/src/codegen/group-routes.ts +1 -1
  385. package/src/codegen/pipeline.test.ts +1 -1
  386. package/src/codegen/pipeline.ts +1 -1
  387. package/src/codegen/resolve-envelope.test.ts +1 -1
  388. package/src/codegen/resolve-envelope.ts +1 -1
  389. package/src/codegen/targets/_shared/error-schemas.test.ts +1 -1
  390. package/src/codegen/targets/_shared/error-schemas.ts +1 -1
  391. package/src/codegen/targets/_shared/route-slots.test.ts +1 -1
  392. package/src/codegen/targets/_shared/route-slots.ts +1 -1
  393. package/src/codegen/targets/_shared/target-run.ts +1 -1
  394. package/src/codegen/targets/kotlin/emit-route-kotlin.test.ts +1 -1
  395. package/src/codegen/targets/kotlin/emit-route-kotlin.ts +1 -1
  396. package/src/codegen/targets/kotlin/emit-scope-kotlin.test.ts +1 -1
  397. package/src/codegen/targets/swift/access-level.test.ts +1 -1
  398. package/src/codegen/targets/swift/emit-route-swift.test.ts +1 -1
  399. package/src/codegen/targets/swift/emit-route-swift.ts +1 -1
  400. package/src/codegen/targets/swift/emit-scope-swift.test.ts +1 -1
  401. package/src/codegen/targets/ts/shared-models.test.ts +1 -1
  402. package/src/{create-http-stream.test.ts → core/create-http-stream.test.ts} +1 -1
  403. package/src/core/create-http-stream.ts +207 -0
  404. package/src/{create-http.test.ts → core/create-http.test.ts} +31 -4
  405. package/src/core/create-http.ts +126 -0
  406. package/src/{create-stream.test.ts → core/create-stream.test.ts} +28 -31
  407. package/src/core/create-stream.ts +142 -0
  408. package/src/{create.test.ts → core/create.test.ts} +25 -57
  409. package/src/core/create.ts +121 -0
  410. package/src/{stack-utils.test.ts → core/definition-site.test.ts} +14 -3
  411. package/src/{stack-utils.ts → core/definition-site.ts} +20 -23
  412. package/src/{errors.test.ts → core/errors.test.ts} +1 -1
  413. package/src/{errors.ts → core/errors.ts} +30 -28
  414. package/src/core/factory-options.test.ts +112 -0
  415. package/src/core/http-route.ts +73 -0
  416. package/src/core/internal.ts +203 -0
  417. package/src/{migration.test.ts → core/migration.test.ts} +23 -1
  418. package/src/{index.test.ts → core/procedures.test.ts} +13 -11
  419. package/src/core/procedures.ts +75 -0
  420. package/src/core/types.ts +196 -0
  421. package/src/exports.ts +60 -11
  422. package/src/schema/adapter.test.ts +58 -0
  423. package/src/schema/adapter.ts +45 -0
  424. package/src/schema/compile.test.ts +95 -0
  425. package/src/schema/compile.ts +64 -0
  426. package/src/schema/compute-schema.test.ts +222 -41
  427. package/src/schema/compute-schema.ts +145 -71
  428. package/src/schema/json-schema.ts +21 -0
  429. package/src/schema/typebox.test.ts +40 -0
  430. package/src/schema/typebox.ts +27 -0
  431. package/src/server/context.test.ts +22 -0
  432. package/src/server/context.ts +18 -0
  433. package/src/{doc-envelope.test.ts → server/doc-envelope.test.ts} +2 -2
  434. package/src/{doc-envelope.ts → server/doc-envelope.ts} +1 -1
  435. package/src/{implementations/http → server}/doc-registry.test.ts +32 -26
  436. package/src/{implementations/http → server}/doc-registry.ts +11 -7
  437. package/src/server/docs/docs.test.ts +287 -0
  438. package/src/{implementations/http/hono → server}/docs/http-doc.ts +3 -3
  439. package/src/{implementations/http/hono → server}/docs/http-stream-doc.ts +3 -3
  440. package/src/{implementations/http/hono → server}/docs/rpc-doc.ts +3 -3
  441. package/src/{implementations/http/hono → server}/docs/stream-doc.ts +3 -3
  442. package/src/server/errors/dispatch.test.ts +450 -0
  443. package/src/server/errors/dispatch.ts +189 -0
  444. package/src/{implementations/http/error-taxonomy.test.ts → server/errors/taxonomy.test.ts} +45 -39
  445. package/src/{implementations/http/error-taxonomy.ts → server/errors/taxonomy.ts} +8 -17
  446. package/src/server/index.ts +29 -0
  447. package/src/server/no-framework-imports.test.ts +43 -0
  448. package/src/server/paths.test.ts +141 -0
  449. package/src/{implementations/http/hono/path.ts → server/paths.ts} +2 -13
  450. package/src/server/request/params.test.ts +143 -0
  451. package/src/server/request/params.ts +68 -0
  452. package/src/server/request/query.test.ts +70 -0
  453. package/src/server/request/query.ts +24 -0
  454. package/src/server/sse.test.ts +113 -0
  455. package/src/server/sse.ts +117 -0
  456. package/src/{implementations → server}/types.ts +17 -16
  457. package/build/create-http-stream.d.ts +0 -58
  458. package/build/create-http-stream.js +0 -122
  459. package/build/create-http-stream.js.map +0 -1
  460. package/build/create-http-stream.test.js.map +0 -1
  461. package/build/create-http.d.ts +0 -49
  462. package/build/create-http.js +0 -108
  463. package/build/create-http.js.map +0 -1
  464. package/build/create-http.test.js.map +0 -1
  465. package/build/create-stream.d.ts +0 -35
  466. package/build/create-stream.js +0 -123
  467. package/build/create-stream.js.map +0 -1
  468. package/build/create-stream.test.js.map +0 -1
  469. package/build/create.d.ts +0 -28
  470. package/build/create.js +0 -82
  471. package/build/create.js.map +0 -1
  472. package/build/create.test.js.map +0 -1
  473. package/build/doc-envelope.js.map +0 -1
  474. package/build/doc-envelope.test.js.map +0 -1
  475. package/build/errors.js.map +0 -1
  476. package/build/errors.test.js.map +0 -1
  477. package/build/implementations/http/astro/astro-context.js.map +0 -1
  478. package/build/implementations/http/astro/create-handler.js.map +0 -1
  479. package/build/implementations/http/astro/index.js.map +0 -1
  480. package/build/implementations/http/astro/index.test.js.map +0 -1
  481. package/build/implementations/http/astro/rewrite-request.js.map +0 -1
  482. package/build/implementations/http/doc-registry.js.map +0 -1
  483. package/build/implementations/http/doc-registry.test.js.map +0 -1
  484. package/build/implementations/http/error-dispatch.d.ts +0 -76
  485. package/build/implementations/http/error-dispatch.js.map +0 -1
  486. package/build/implementations/http/error-dispatch.test.js +0 -254
  487. package/build/implementations/http/error-dispatch.test.js.map +0 -1
  488. package/build/implementations/http/error-taxonomy.js.map +0 -1
  489. package/build/implementations/http/error-taxonomy.test.js.map +0 -1
  490. package/build/implementations/http/hono/docs/http-doc.js.map +0 -1
  491. package/build/implementations/http/hono/docs/http-stream-doc.js.map +0 -1
  492. package/build/implementations/http/hono/docs/rpc-doc.js.map +0 -1
  493. package/build/implementations/http/hono/docs/stream-doc.js.map +0 -1
  494. package/build/implementations/http/hono/handlers/http-stream.js +0 -123
  495. package/build/implementations/http/hono/handlers/http-stream.js.map +0 -1
  496. package/build/implementations/http/hono/handlers/http-stream.test.js.map +0 -1
  497. package/build/implementations/http/hono/handlers/http.js +0 -110
  498. package/build/implementations/http/hono/handlers/http.js.map +0 -1
  499. package/build/implementations/http/hono/handlers/http.test.js.map +0 -1
  500. package/build/implementations/http/hono/handlers/rpc.js +0 -32
  501. package/build/implementations/http/hono/handlers/rpc.js.map +0 -1
  502. package/build/implementations/http/hono/handlers/rpc.test.js.map +0 -1
  503. package/build/implementations/http/hono/handlers/stream.d.ts +0 -23
  504. package/build/implementations/http/hono/handlers/stream.js +0 -147
  505. package/build/implementations/http/hono/handlers/stream.js.map +0 -1
  506. package/build/implementations/http/hono/handlers/stream.test.js.map +0 -1
  507. package/build/implementations/http/hono/index.js.map +0 -1
  508. package/build/implementations/http/hono/index.test.js.map +0 -1
  509. package/build/implementations/http/hono/path.js.map +0 -1
  510. package/build/implementations/http/hono/path.test.js +0 -83
  511. package/build/implementations/http/hono/path.test.js.map +0 -1
  512. package/build/implementations/http/hono/types.d.ts +0 -51
  513. package/build/implementations/http/hono/types.js.map +0 -1
  514. package/build/implementations/http/on-request-error.test.js.map +0 -1
  515. package/build/implementations/http/route-errors.test.js.map +0 -1
  516. package/build/index.d.ts +0 -175
  517. package/build/index.js +0 -47
  518. package/build/index.js.map +0 -1
  519. package/build/index.test.js.map +0 -1
  520. package/build/migration.test.js.map +0 -1
  521. package/build/schema/extract-json-schema.d.ts +0 -2
  522. package/build/schema/extract-json-schema.js +0 -12
  523. package/build/schema/extract-json-schema.js.map +0 -1
  524. package/build/schema/extract-json-schema.test.js +0 -23
  525. package/build/schema/extract-json-schema.test.js.map +0 -1
  526. package/build/schema/parser.d.ts +0 -36
  527. package/build/schema/parser.js +0 -210
  528. package/build/schema/parser.js.map +0 -1
  529. package/build/schema/parser.test.js +0 -120
  530. package/build/schema/parser.test.js.map +0 -1
  531. package/build/schema/resolve-schema-lib.d.ts +0 -12
  532. package/build/schema/resolve-schema-lib.js +0 -11
  533. package/build/schema/resolve-schema-lib.js.map +0 -1
  534. package/build/schema/resolve-schema-lib.test.js +0 -17
  535. package/build/schema/resolve-schema-lib.test.js.map +0 -1
  536. package/build/schema/types.d.ts +0 -8
  537. package/build/schema/types.js +0 -2
  538. package/build/stack-utils.d.ts +0 -25
  539. package/build/stack-utils.js.map +0 -1
  540. package/build/stack-utils.test.js.map +0 -1
  541. package/build/types.d.ts +0 -142
  542. package/build/types.js +0 -2
  543. package/build/types.js.map +0 -1
  544. package/docs/decisions/2026-06-02-monorepo-split-evaluation.md +0 -80
  545. package/docs/handoffs/2026-06-08-dx-round2-declines.md +0 -45
  546. package/docs/handoffs/ajsc-named-type-collision.md +0 -134
  547. package/docs/handoffs/ajsc-named-type-support.md +0 -181
  548. package/docs/handoffs/shared-models-auto-resolve-response.md +0 -181
  549. package/docs/npm-workspaces-migration-plan.md +0 -611
  550. package/docs/superpowers/plans/2026-04-24-doc-registry-simplification.md +0 -886
  551. package/docs/superpowers/plans/2026-04-24-kotlin-codegen-target.md +0 -1265
  552. package/docs/superpowers/plans/2026-04-25-ajsc-v7-kotlin-polish.md +0 -1993
  553. package/docs/superpowers/plans/2026-04-29-safe-result-api.md +0 -2293
  554. package/docs/superpowers/plans/2026-05-07-astro-adapter.md +0 -1391
  555. package/docs/superpowers/plans/2026-05-08-create-http.md +0 -3355
  556. package/docs/superpowers/plans/2026-05-08-hono-app-builder-convergence.md +0 -3365
  557. package/docs/superpowers/plans/2026-06-05-dx-feedback-round.md +0 -1292
  558. package/docs/superpowers/plans/2026-06-06-shared-models-convention-and-diagnostics.md +0 -659
  559. package/docs/superpowers/plans/2026-06-08-codegen-dx-surfacing.md +0 -428
  560. package/docs/superpowers/specs/2026-04-24-kotlin-swift-codegen-design.md +0 -401
  561. package/docs/superpowers/specs/2026-04-25-ajsc-v7-kotlin-polish-design.md +0 -314
  562. package/docs/superpowers/specs/2026-04-25-swift-codegen-design.md +0 -264
  563. package/docs/superpowers/specs/2026-04-29-safe-result-api-design.md +0 -324
  564. package/docs/superpowers/specs/2026-05-07-astro-adapter-design.md +0 -252
  565. package/docs/superpowers/specs/2026-05-08-create-http-design.md +0 -409
  566. package/docs/superpowers/specs/2026-05-08-hono-app-builder-convergence-design.md +0 -411
  567. package/docs/superpowers/specs/2026-06-05-dx-feedback-round-design.md +0 -285
  568. package/docs/superpowers/specs/2026-06-08-dx-feedback-round-2-design.md +0 -376
  569. package/src/create-http-stream.ts +0 -191
  570. package/src/create-http.ts +0 -210
  571. package/src/create-stream.ts +0 -228
  572. package/src/create.ts +0 -172
  573. package/src/implementations/http/README.md +0 -390
  574. package/src/implementations/http/error-dispatch.test.ts +0 -283
  575. package/src/implementations/http/error-dispatch.ts +0 -176
  576. package/src/implementations/http/hono/handlers/http-stream.ts +0 -152
  577. package/src/implementations/http/hono/handlers/http.ts +0 -145
  578. package/src/implementations/http/hono/handlers/rpc.ts +0 -54
  579. package/src/implementations/http/hono/path.test.ts +0 -96
  580. package/src/index.ts +0 -101
  581. package/src/schema/extract-json-schema.test.ts +0 -25
  582. package/src/schema/extract-json-schema.ts +0 -15
  583. package/src/schema/parser.test.ts +0 -182
  584. package/src/schema/parser.ts +0 -265
  585. package/src/schema/resolve-schema-lib.test.ts +0 -19
  586. package/src/schema/resolve-schema-lib.ts +0 -29
  587. package/src/schema/types.ts +0 -20
  588. package/src/types.ts +0 -133
  589. /package/build/{implementations/http → adapters}/astro/astro-context.d.ts +0 -0
  590. /package/build/{implementations/http → adapters}/astro/astro-context.js +0 -0
  591. /package/build/{implementations/http → adapters}/astro/create-handler.d.ts +0 -0
  592. /package/build/{implementations/http → adapters}/astro/create-handler.js +0 -0
  593. /package/build/{implementations/http → adapters}/astro/index.d.ts +0 -0
  594. /package/build/{implementations/http → adapters}/astro/index.js +0 -0
  595. /package/build/{implementations/http → adapters}/astro/index.test.d.ts +0 -0
  596. /package/build/{implementations/http → adapters}/astro/rewrite-request.d.ts +0 -0
  597. /package/build/{implementations/http → adapters}/astro/rewrite-request.js +0 -0
  598. /package/build/{create-http-stream.test.d.ts → adapters/hono/envelope-parity.test.d.ts} +0 -0
  599. /package/build/{implementations/http → adapters}/hono/handlers/http-stream.test.d.ts +0 -0
  600. /package/build/{implementations/http → adapters}/hono/handlers/http.test.d.ts +0 -0
  601. /package/build/{implementations/http → adapters}/hono/handlers/rpc.test.d.ts +0 -0
  602. /package/build/{implementations/http → adapters}/hono/handlers/stream.test.d.ts +0 -0
  603. /package/build/{implementations/http → adapters}/hono/index.test.d.ts +0 -0
  604. /package/build/{implementations/http → adapters/hono}/on-request-error.test.d.ts +0 -0
  605. /package/build/{implementations/http → adapters/hono}/route-errors.test.d.ts +0 -0
  606. /package/build/{create-http.test.d.ts → client/freeze.test.d.ts} +0 -0
  607. /package/build/{create-stream.test.d.ts → codegen/goldens.test.d.ts} +0 -0
  608. /package/build/{create.test.d.ts → core/create-http-stream.test.d.ts} +0 -0
  609. /package/build/{doc-envelope.test.d.ts → core/create-http.test.d.ts} +0 -0
  610. /package/build/{errors.test.d.ts → core/create-stream.test.d.ts} +0 -0
  611. /package/build/{implementations/http/doc-registry.test.d.ts → core/create.test.d.ts} +0 -0
  612. /package/build/{implementations/http/error-dispatch.test.d.ts → core/definition-site.test.d.ts} +0 -0
  613. /package/build/{implementations/http/error-taxonomy.test.d.ts → core/errors.test.d.ts} +0 -0
  614. /package/build/{errors.test.js → core/errors.test.js} +0 -0
  615. /package/build/{implementations/http/hono/path.test.d.ts → core/factory-options.test.d.ts} +0 -0
  616. /package/build/{migration.test.d.ts → core/migration.test.d.ts} +0 -0
  617. /package/build/{index.test.d.ts → core/procedures.test.d.ts} +0 -0
  618. /package/build/{implementations/http/hono → core}/types.js +0 -0
  619. /package/build/schema/{extract-json-schema.test.d.ts → adapter.test.d.ts} +0 -0
  620. /package/build/schema/{parser.test.d.ts → compile.test.d.ts} +0 -0
  621. /package/build/schema/{resolve-schema-lib.test.d.ts → typebox.test.d.ts} +0 -0
  622. /package/build/{stack-utils.test.d.ts → server/context.test.d.ts} +0 -0
  623. /package/build/{doc-envelope.js → server/doc-envelope.js} +0 -0
  624. /package/build/{doc-envelope.test.js → server/doc-envelope.test.js} +0 -0
  625. /package/build/{implementations → server}/types.js +0 -0
  626. /package/src/{implementations/http → adapters}/astro/README.md +0 -0
  627. /package/src/{implementations/http → adapters}/astro/astro-context.ts +0 -0
  628. /package/src/{implementations/http → adapters}/astro/create-handler.ts +0 -0
  629. /package/src/{implementations/http → adapters}/astro/index.ts +0 -0
  630. /package/src/{implementations/http → adapters}/astro/rewrite-request.ts +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,540 @@
1
+ # Changelog
2
+
3
+ All notable changes to **ts-procedures** are documented in this file.
4
+
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
+
7
+ ## 9.1.0 — 2026-06-10
8
+
9
+ ### Added
10
+
11
+ - `CreateHttp` no longer requires a `schema` key — a no-input, no-output route
12
+ (e.g. `successStatus: 204` with only `errors`) can omit it instead of
13
+ passing `schema: {}`.
14
+
15
+ ### Fixed
16
+
17
+ - Codegen: a route that declares `errors` but no req/res (e.g. a 204 logout)
18
+ now emits a per-route namespace housing its `Errors` union. Previously the
19
+ typed callable referenced `Scope.Route.Errors` while the namespace was never
20
+ written, so the generated artifact failed `tsc` with
21
+ `Namespace '…' has no exported member '…'`. Applies to `api` and `rpc`
22
+ routes in namespace mode; flat mode was already correct. Parity-safe: the
23
+ affected output never typechecked, so no working consumer's bytes change.
24
+ - `CHANGELOG.md` is now included in the published npm package (it existed in
25
+ the repo but was missing from the `files` allowlist).
26
+
27
+ ### Docs
28
+
29
+ - Migration guide: documented that the byte-parity guarantee carried known v8
30
+ codegen issues into 9.0.0 unchanged, and when fixes can land.
31
+ - Client/codegen guide: cross-origin `basePath` CORS callout (browser clients
32
+ need server CORS or a same-origin dev proxy), HTTP-vs-WebSocket auth-seam
33
+ note, and the `Type.Record` / `$id` shared-model limitation.
34
+
35
+ ## 9.0.0 — 2026-06-10
36
+
37
+ Ground-up restructuring of the library. **Generated codegen output is
38
+ byte-identical to v8.6.0** across all targets (TypeScript, Kotlin, Swift) and
39
+ all modes — verified by a committed golden corpus captured from the v8 build.
40
+ Full upgrade guide: [docs/migration-v8-to-v9.md](docs/migration-v8-to-v9.md).
41
+
42
+ ### Breaking
43
+
44
+ - `Procedures({ config: { noRuntimeValidation: true } })` → `Procedures({ validation: false })`.
45
+ - Suretype support removed (deprecated since v8). TypeBox is the built-in
46
+ schema library; other libraries plug in via the new `SchemaAdapter`.
47
+ - `TStreamProcedureRegistration.isStream` removed — use the `kind` discriminant.
48
+ - Duplicate-name registration throws `ProcedureRegistrationError` instead of a
49
+ bare `Error` (message unchanged).
50
+ - Low-level schema utilities reshaped: `schemaParser` removed (use
51
+ `computeSchema(name, schema, { adapters, compile })`); `extractJsonSchema`
52
+ takes an explicit adapter list; `isSuretypeSchema` removed.
53
+ - `dispatchPreStreamError` / `dispatchMidStreamError` are transport-agnostic:
54
+ they return plain data (`{ type: 'body', statusCode, body }` /
55
+ `{ data, sseEvent, runOnCatch }`) instead of Hono responses. Only relevant
56
+ to custom adapter authors; `HonoAppBuilder` behavior is unchanged.
57
+
58
+ ### Fixed
59
+
60
+ - `CreateHttpStream` registrations now expose `schema.yield` and
61
+ `schema.res.headers` under the keys route-doc builders read. In v8, live
62
+ envelopes silently dropped the yield/response-header schemas for
63
+ `http-stream` routes, so generated clients lost those types unless the
64
+ envelope was hand-authored.
65
+ - SSE wire behavior is now identical for `rpc-stream` and `http-stream`
66
+ routes (both served by one `SseEventSequencer`). Two v8 accidents
67
+ normalized: `http-stream` yields/error events now honor `sse()` metadata
68
+ (v8 ignored it on that path), and `null` yields serialize as empty SSE data
69
+ on both paths (v8's `http-stream` wrote the string `null`).
70
+
71
+ ### Added
72
+
73
+ - `Procedures({ validation: { ajv } })` — per-factory AJV options or instance
74
+ (the module-level AJV singleton is gone).
75
+ - `Procedures({ schema: { adapters } })` — pluggable schema libraries via the
76
+ 3-method `SchemaAdapter` interface.
77
+ - `Procedures({ http: { pathPrefix, scope } })` — factory-level defaults for
78
+ `CreateHttp` / `CreateHttpStream`, removing per-route boilerplate.
79
+ - `ts-procedures/server` subpath — the transport-agnostic server toolkit
80
+ (route-doc builders, taxonomy dispatch, request channel extraction via
81
+ `RequestSource`, SSE metadata, `DocRegistry`). Writing a Fastify/Express
82
+ adapter is now a thin-glue exercise; `src/adapters/hono/` is the reference.
83
+ - `Infer<T>` as the primary inference type (`TSchemaLib` kept as an alias);
84
+ `ProcedureError.kind` discriminant.
85
+
86
+ ### Internal
87
+
88
+ - Package restructured into `core/` (factory + creators), `schema/`
89
+ (adapters + AJV compilation), `server/` (framework-free HTTP machinery),
90
+ `adapters/{hono,astro}`, `client/` (content-frozen — bundled verbatim into
91
+ self-contained codegen output), `codegen/`.
92
+ - Codegen output is pinned by a 13-case golden matrix (2 fixture envelopes ×
93
+ TS default/flat/external-runtime/no-share-models/shared-models-module +
94
+ Kotlin + Swift) plus a DocEnvelope parity test against a v8-captured
95
+ envelope and sha256 freeze tests on the bundled client runtime.
96
+
97
+ ## 8.6.0 — 2026-06-08
98
+
99
+ ### Added
100
+
101
+ - **Per-scope client interfaces.** The generated index now exports a `${ServiceName}Client` type (the bindings factory's return type) plus one `<Scope>Client` per scope (e.g. `UsersClient = ApiClient['users']`). A consumer can type a dependency as the narrow scope it actually uses — `constructor(client: UsersClient = api.users)` — and a fake satisfies just that scope, instead of casting `as unknown as typeof api` at every DI seam. Derived from the existing factory return type, so no new naming scheme. TypeScript target.
102
+ - **Callable JSDoc surfaces the per-call options bag and declared errors.** Every generated callable's JSDoc now documents its optional second argument (`ProcedureCallOptions` — `signal`, `timeout`, `headers`, `basePath`) and, for routes that declare `errors`, a `@throws` breadcrumb naming the route's `Errors` type and how to reach it (narrow with `instanceof` on the throwing path, or call `.safe()` for a `Result`). The capabilities already existed; they're now discoverable at the call site without reading `_types.ts`.
103
+
104
+ ### Changed
105
+
106
+ - **Generated-output change (input-less routes):** a route with no inputs (no path params, query, body, or params) now generates a `void` params type instead of `unknown`, so `api.auth.Me()` is callable with **no argument** and a stray `api.auth.Me({})` is a **type error** (previously `unknown` silently accepted any object). Type-only and opt-in on regeneration — runtime is unaffected. **Migration:** when you regenerate, drop the empty `({})` argument from no-input calls (`api.auth.Me()`, `api.users.ListUsers()`). Routes *with* input are byte-identical to 8.5.0.
107
+
108
+ ### Notes
109
+
110
+ - Documentation only (no API change): a no-content (204) procedure recipe (`docs/http-integrations.md` — omit `schema.res`, return `undefined`, get `Promise<void>` and a clean 204), client-side discoverability prose for declared errors + per-call options (`docs/client-error-handling.md`), and a design note on typed errors across a state-management boundary.
111
+
112
+ ## 8.5.0 — 2026-06-06
113
+
114
+ ### Added
115
+
116
+ - **`sharedModelsModule` — one-value shared-types convention.** A single module path (`--shared-models-module <module>`, the `sharedModelsModule` config key, or `generateClient({ sharedModelsModule })`) re-exports every `$id`-bearing model from that module under its derived name (`$id`/`title`), collapsing a hand-maintained `sharedTypesImport` map to one line. Precedence: explicit `sharedTypesImport[$id]` → `sharedModelsModule` convention → generate locally. The per-`$id` map is unchanged and remains the override for rename / per-package / multi-consumer cases. TypeScript target only.
117
+ - **Shared-models diagnostics.** The CLI now prints a neutral one-line summary on every run with `$id`-bearing models (`Shared models: N total — X re-exported, Y generated locally.`), surfacing a silently-generated structural twin. `--strict-shared-models` (`strictSharedModels` config; default **off**) promotes that to a hard error listing every `$id` that would be generated locally — a CI guard that replaces a hand-written `toEqualTypeOf` contract test.
118
+ - **`logger` codegen option.** `generateClient` / `runPipeline` accept an optional `logger?: (message: string) => void`. The shared-models summary is routed through it: the CLI wires it to `console.log`, while programmatic callers stay silent by default (no stray stdout in build scripts/tests) and opt in by passing `logger`.
119
+
120
+ ### Notes
121
+
122
+ - Source-tree scanning (a requested `--shared-types-from <dir|glob>`) was deliberately **not** added: codegen's input contract stays the DocEnvelope, so `--url`/offline `--file` generation never depends on a local source tree. Rationale in `docs/handoffs/shared-models-auto-resolve-response.md`.
123
+ - Schemas without `$id`, and projects setting none of the new options, produce byte-identical output to 8.4.0.
124
+
125
+ ## 8.4.0 — 2026-06-06
126
+
127
+ ### Added
128
+
129
+ - **`writeDocEnvelope(source, path)`** — serialize a `DocEnvelope` to disk for offline codegen. Accepts a built `HonoAppBuilder`/`DocRegistry` (anything exposing `toDocEnvelope()`/`toJSON()`) or a plain envelope, so `ts-procedures-codegen --file <path>` no longer needs a running server. Exported from the package root.
130
+ - **`ts-procedures-codegen --help` / `-h`** (and bare invocation) now print grouped usage and exit 0. The flag catalog is a single structured table that drives both flag validation and the help text — flags can no longer drift from their docs — and `--help` is excluded from the did-you-mean suggester (previously it errored with `Did you mean --url?`).
131
+ - **Function-valued client headers + `auth` convenience.** `headers` (client defaults and per-call) now accepts `ClientHeadersInit = Record<string,string> | (() => Record | Promise<Record>)`, resolved per request — the right home for a rotating bearer token, which goes stale in a static record. A first-class `auth` option, `createClient({ auth: () => session.token })`, wires `Authorization: Bearer <token>` per request and composes with any existing default headers.
132
+ - **Shared client types keyed on `$id`.** When a schema carries a `$id`, codegen hoists it into a single `_models.ts` and has every route reference that one named type via `import type { X } from './_models'`, instead of inlining a fresh structural copy per route — so a value returned by one route is the *same* named type another route (and your `@shared/schemas`) uses. Identity is keyed on the declared `$id` (named from `title`), never on structure; an `$id` reused with a divergent body is a hard error. On by default (`--share-models`; opt out with `--no-share-models`). A `sharedTypesImport` config map (`$id → { module, name }`) makes `_models.ts` re-export the type from your own package instead of generating it. TypeScript target only.
133
+ - **Scaffolder `fileNameStyle` + `groupBy`.** The `ts-procedures` scaffold skill accepts `fileNameStyle` (`PascalCase | kebab.concern`) and `groupBy` (`flat | scope`), inferring the default from the target directory's existing layout.
134
+
135
+ ### Changed
136
+
137
+ - **Codegen now requires `ajsc` ≥ 7.3.0** and uses its `x-named-type` keyword + `referencedNamedTypes` to emit shared-model references directly (replacing an internal placeholder-token mechanism; generated output is unchanged). A shared-model name that collides with a property-derived sub-type name is detected via ajsc's documented signal (`referencedNamedTypes ∩ extractedTypeNames`) and rejected with an actionable, route-qualified error, pending an ajsc root fix that will let the reference win.
138
+ - **Generated-output change (shared models, on by default):** clients whose schemas set `$id` will see those types relocate into `_models.ts` (referenced from each scope) when regenerated. This is a codegen-output change, not a runtime API break; schemas without `$id` produce byte-identical output to 8.3.0. Pass `--no-share-models` to keep the previous per-route inlining.
139
+
140
+ ## 8.3.0 — 2026-06-05
141
+
142
+ ### Fixed
143
+
144
+ - **`CreateHttp` response handling now honors the documented schema-gated contract.** The `{ body, headers }` envelope is unwrapped **only** when the route declares `schema.res.headers` (the contract stated since 8.0.0). Previously the Hono builder duck-typed the handler's return value, unwrapping **any** object with a top-level `body` key — so a domain model with its own `body` (or `headers`) field was silently truncated to just that field, with a `200`. Returns are now serialized verbatim unless `schema.res.headers` is declared.
145
+ - **Behavioral change (potentially breaking):** if you returned `{ body }` to *trigger* unwrapping without declaring `schema.res.headers`, that no longer unwraps. Declare `schema.res.headers` and return `{ body, headers }`, or return the body value bare.
146
+ - A handler that returns `undefined` (a headers-only `res: { headers }` envelope, or a `void` handler) now emits a clean bodyless response instead of an empty, unparseable `application/json` body.
147
+
148
+ ### Changed
149
+
150
+ - **Taxonomy errors are typed on the client with zero ceremony.** An entry declared with just `{ class, statusCode }` now gets a synthesized `{ name, message }` body schema in the `DocEnvelope`, so `ts-procedures-codegen` emits a typed client error class and registry entry for it automatically — matching the framework's own (schema-carrying) default errors. Previously such entries reached codegen schema-less and fell back to the untyped `ClientHttpError`. Entries that supply a custom `toResponse` (shape unknown) or are documented as raw `ErrorDoc`s still need an explicit `schema` to become typed — see the typed-client note in `docs/http-integrations.md`.
151
+
152
+ ### Docs
153
+
154
+ - Corrected the per-route `errors` example (use a `satisfies` clause, not a single explicit `CreateHttp` generic, which binds `TName` and breaks `schema.req`/`schema.res` inference); documented that the bundled TypeBox has no `Type.Composite` (compose via a flat `Type.Object({ ...Base.properties })` spread); noted the client `basePath` must be the origin only (generated paths already include the server `pathPrefix`); and added an ESM-only setup callout.
155
+
156
+ ## 8.2.0 — 2026-06-04
157
+
158
+ ### Changed
159
+
160
+ - **`cleanOutDir` no longer wipes the output directory — it prunes only orphaned _generated_ files, and is now on by default.** Previously `cleanOutDir`/`--clean-out-dir` ran `rm -rf <outDir>`, which could delete hand-written or co-located files and so had to stay opt-out. It now removes only top-level files carrying the `ts-procedures-codegen` signature that the current run no longer emits (e.g. a deleted scope's stale file); files without the signature and any subdirectories are never touched. Because the operation can only ever delete generator-owned files, it now **defaults to `true`** — regenerating a client automatically prunes orphaned scope files. Opt out with `cleanOutDir: false` / `--no-clean-out-dir`. The signature is version-agnostic, so orphans left by an older release of this package are still pruned (relevant in monorepos pinning multiple versions). Dry-run reports `[dry-run] Would remove orphaned generated file: <path>` instead of mutating.
161
+ - **Every generated file now carries a stable package signature.** The TypeScript and Swift headers already mentioned `ts-procedures-codegen`; the Kotlin header gains a `// ts-procedures-codegen — do not edit` line above its source-hash comment so generated Kotlin files are identifiable by the prune. The TypeScript header also includes the package version (`vX.Y.Z`) for downstream visibility in monorepos.
162
+
163
+ ## 8.1.1 — 2026-06-02
164
+
165
+ ### Changed
166
+
167
+ - **Package marked side-effect-free (`sideEffects: false`).** Bundlers can now tree-shake any subpath you don't import — a Hono-only app drops the codegen/client code it never references, and vice versa. Verified safe: no module performs import-time side effects.
168
+ - **`typebox` is no longer imported at runtime.** Schema-library detection is duck-typed, so the schema layer imports `typebox`/`suretype` as types only. Slightly leaner runtime; no behavior change.
169
+
170
+ ### Added
171
+
172
+ - **Optional-integration guidance in the README** — which peer dependency to install for the Hono server, Astro adapter, and Kotlin/Swift codegen targets (`hono`, `astro`, `ajsc` are `optionalDependencies`, never pulled by a plain install).
173
+
174
+ ## 8.1.0 — 2026-06-01
175
+
176
+ ### Fixed
177
+
178
+ - **Duplicate-identifier in generated clients when a sub-type is shared between a route's request and response (namespace mode).** ajsc (`inlineTypes: false`) joins sibling extracted declarations with a single newline but separates the root with a blank line; the codegen parser split only on blank lines, fusing siblings into one element. The rename/dedup logic then only saw the first sibling, so a route whose body and response each produced two or more sub-types emitted the non-first sub-types twice — `error TS2300: Duplicate identifier` — and cross-references inside renamed sibling types silently resolved to a different schema's sub-type of the same name. `jsonSchemaToExtractedTypes` now splits each ajsc block into individual declarations (brace-depth aware, so multi-line enums and per-property JSDoc stay intact), `renameExtractedTypes` patches renamed references across all sibling declarations (not just the root body), and a `DeclarationCollector` guard fails fast on any unresolved same-name collision instead of emitting code that breaks downstream.
179
+
180
+ ## 8.0.0 — 2026-05-08
181
+
182
+ ### Breaking changes
183
+
184
+ - **`ExpressRPCAppBuilder` removed.** The Express integration (`ts-procedures/express-rpc`) is gone — `HonoAppBuilder` is the single supported HTTP builder. Apps using Express must migrate to Hono (which works on Node, Bun, Deno, and Cloudflare Workers via `@hono/node-server` or similar). The `express` and `@types/express` packages are no longer optional/dev dependencies of this package.
185
+ - **`schema.input` removed** from `Create` / `CreateStream`. HTTP-specific multi-channel input is now `schema.req` on `CreateHttp` / `CreateHttpStream`.
186
+ - **HTTP routes use `CreateHttp`**, not `Create` + `APIConfig`. HTTP fields (`path`, `method`, `successStatus`, `scope`, `errors`) are first-class on `CreateHttp` config.
187
+ - **`schema.input.X` → `schema.req.X`** — channels (`pathParams`, `query`, `body`, `headers`) are unchanged; only the property name changed.
188
+ - **`APIInput` and `APIConfig` no longer required as factory type parameters.** `CreateHttp` accepts HTTP config directly without a factory type parameter. The types remain exported from `ts-procedures/hono-api` for use as helper types (e.g., `satisfies APIInput` for channel-name typo checks).
189
+ - **`APIHttpRouteDoc.jsonSchema` regrouped** — input channels are now under `jsonSchema.req`, response under `jsonSchema.res`. Consumers reading `base.jsonSchema.body` in `extendProcedureDoc` need to read `base.jsonSchema.req.body`.
190
+ - **`Procedures<Ctx, APIConfig>()` → `Procedures<Ctx>()`** for HTTP-only factories. `Create` on these factories now throws if HTTP fields are present; use `CreateHttp` instead.
191
+ - **Generated client flat-mode aliases renamed** — `<Route>Params` → `<Route>ReqPathParams` (and similar per-channel suffixes). Namespace-mode users get `Users.GetUser.Req.PathParams` automatically with no rename needed.
192
+ - **`kind` discriminant on every registration** — `'rpc' | 'rpc-stream' | 'http' | 'http-stream'`. Builder routing and `skippedProcedures` warnings now use this discriminant; code that inspected `isStream` for routing needs to check `kind`.
193
+
194
+ ### New
195
+
196
+ - **`CreateHttp(name, config, handler)`** — first-class HTTP creator with `schema.req` channels (`pathParams`, `query`, `body`, `headers`) and `schema.res` (`body`, `headers`). No factory type parameter required.
197
+ - **`CreateHttpStream(name, config, handler)`** — streaming counterpart to `CreateHttp`. Yields SSE events; headers declared on `schema.res.headers` surface on `TypedStream.headers`.
198
+ - **Conditional return shape** — `CreateHttp` handler returns body bare when `schema.res.headers` is not declared; returns `{ body, headers }` when it is. TypeScript narrows automatically.
199
+ - **`TypedStream.headers`** — initial response headers surfaced on streams that declare `schema.res.headers`.
200
+ - **`kind` discriminant** on every registration (`'rpc' | 'rpc-stream' | 'http' | 'http-stream'`) drives builder routing and codegen scope grouping.
201
+
202
+ ### Migration
203
+
204
+ Quick checklist (see `docs/superpowers/specs/2026-05-08-create-http-design.md` for the full migration table):
205
+
206
+ 1. Replace `Procedures<Ctx, APIConfig>()` with `Procedures<Ctx>()` for HTTP factories. (`APIConfig` and `APIInput` still export for other uses.)
207
+ 2. Replace `.Create('Foo', { path, method, schema: { input } }, h)` with `.CreateHttp('Foo', { path, method, schema: { req } }, h)`.
208
+ 3. Rename `schema.input.X` → `schema.req.X` (channels are identical; only the wrapper key changed).
209
+ 4. Update any `extendProcedureDoc` callbacks that read `base.jsonSchema.body` to read `base.jsonSchema.req?.body`.
210
+ 5. Re-run `npx ts-procedures-codegen` — regenerated clients use the new type shapes.
211
+ 6. Update flat-mode-alias call sites if applicable (see generated `index.ts` diff for renamed exports).
212
+
213
+ ---
214
+
215
+ ## v7.2.0 - Astro.js adapter
216
+
217
+ Added optional Astro.js api endpoint adapter
218
+
219
+ ## v7.1.1 — Stream typed errors & builder coverage
220
+
221
+ Six bug fixes around streaming procedures and HTTP-builder coverage, surfaced by a downstream consumer who'd been patching the package locally. The release brings stream typed-error dispatch in line with the call-path contract, fixes a generator-cleanup leak, and adds explicit warnings when procedures are silently dropped from the doc envelope.
222
+
223
+ This release contains four behavior changes — see "Behavior changes" below. All fixes target streams or builder filtering; non-streaming RPC/API call paths are unchanged.
224
+
225
+ ### Fixed — Stream typed-error dispatch (`event: 'error'`)
226
+
227
+ `createTypedStream` now recognizes SSE items with `event: 'error'` as terminal, mirroring the call-path contract: the `data` payload is dispatched through the optional `errorRegistry` (looked up by `body.name`), the resulting typed error rejects `.result` and is thrown from the iterator. When no registry entry matches (or no registry is configured), the iterator throws a `ClientStreamError` that exposes the raw body via `error.cause`. Previously, error events were yielded as data — defeating route-declared typed-error narrowing on streams. `executeStream` now plumbs `errorRegistry` and `descriptor` (name/scope) into `createTypedStream`.
228
+
229
+ ### Fixed — `HonoStreamAppBuilder` consults the taxonomy mid-stream
230
+
231
+ Mid-stream throws now flow through `resolveErrorResponse` against the configured `errors` taxonomy, mirroring `HonoRPCAppBuilder`'s dispatch chain. The resolved body is written as the SSE `event: 'error'` data (or as a JSON line in text mode), which the client decodes through its registry and surfaces as a typed `Error`. `onMidStreamError` remains as a fallback when no taxonomy entry matches; the hard default (`{ error: message }`) is the last resort. The HTTP status is still committed to 200 once streaming starts — the taxonomy only drives the wire-protocol body shape mid-stream.
232
+
233
+ ### Fixed — Streaming `Procedures` wrapper preserves typed-error class identity
234
+
235
+ `CreateStream` no longer boxes user-thrown errors inside `ProcedureError` with `cause`. Instead, it rethrows the original error (with the procedure's definition site appended to the stack trace in place) so HTTP builders' taxonomies and `onMidStreamError` callbacks see the actual thrown class. Without this, a user-defined error subclass would never match its taxonomy entry by `class:` instanceof — the resolver would have to unwrap `cause` manually. (`Create` is unchanged for now; only the streaming wrapper is affected.)
236
+
237
+ ### Fixed — `CreateStream` propagates `.return()` to the user generator
238
+
239
+ When a consumer closes a stream early — calling `iterator.return()` or breaking out of `for await` — the wrapped generator now forwards the `.return()` signal to the user's generator so its `finally` blocks run (DB handles, subscriptions, signal-driven teardown). Previously the wrapper iterated via `userIterator.next()` in a loop and never propagated cleanup; user generators leaked resources on early close.
240
+
241
+ ### Changed — Stream procedures emit `methods: ['post', 'get']`
242
+
243
+ `HonoStreamAppBuilder.buildStreamHttpRouteDoc` now emits `methods: ['post', 'get']` instead of `['get', 'post']`. Codegen uses `methods[0]` as the default invocation method for the generated callable, so streams now default to POST (which can carry a body). GET is retained as a peer route for query-string callers. Server routes still register both methods — only the doc array order changed.
244
+
245
+ ### Fixed — `HonoRPCAppBuilder` skips streaming procedures with a warning
246
+
247
+ Streaming procedures registered with `HonoRPCAppBuilder` are now filtered out at `build()` time with `console.warn(...)` rather than getting silently mounted at a POST route that returns the async generator object as JSON. Skipped procedures surface via `builder.skippedProcedures`. Symmetrically, `HonoStreamAppBuilder` already filtered non-stream procedures; it now also tracks them in `skippedProcedures` and warns. Register stream procedures with `HonoStreamAppBuilder` (and regular procedures with `HonoRPCAppBuilder` / `HonoApiAppBuilder`).
248
+
249
+ ### Added — `DocSource.skippedProcedures` + `DocRegistry` coverage warning
250
+
251
+ `DocSource` gains an optional `skippedProcedures: { name: string; reason: string }[]`. When `DocRegistry.toJSON()` runs, it aggregates `skippedProcedures` across every source and emits a single consolidated warning so consumers who only call `registry.toJSON()` (e.g. dumping the envelope to disk for codegen) see coverage gaps without running the builder under a TTY. Set `TS_PROCEDURES_SUPPRESS_COVERAGE_WARNINGS=1` to silence in CI.
252
+
253
+ ### Fixed — `createTypedStream`: no spurious unhandled-rejection on iterator throw
254
+
255
+ `createTypedStream` and the `client.stream()` deferred wrapper now attach a no-op rejection sink (`resultPromise.catch(() => undefined)`) so consumers that iterate without `await stream.result` don't trip Node's strict unhandled-rejection trackers (notably `node:test`'s default failure mode). Consumers that DO await `.result` still observe the rejection — `.catch` returns a new promise without suppressing the original.
256
+
257
+ ### Behavior changes
258
+
259
+ These four are intentional contract changes — most consumers won't notice, but the cases below do flip:
260
+
261
+ 1. **SSE `event: 'error'` is now terminal, not yielded.** Anyone treating `event: 'error'` as data needs to handle it in `catch` instead.
262
+ 2. **Taxonomy now wins over `onMidStreamError`.** If both are configured, taxonomy hits no longer fall through to `onMidStreamError`.
263
+ 3. **`CreateStream` no longer wraps user errors in `ProcedureError`.** Code matching `instanceof ProcedureError` for user-thrown stream errors will miss them; `.cause` is no longer set. (Framework errors — `ProcedureValidationError`, `ProcedureYieldValidationError`, `ctx.error()` — still throw `ProcedureError` subclasses.)
264
+ 4. **Generated stream callables default to POST.** Transparent for `HonoStreamAppBuilder` (mounts both); custom servers that only implemented GET must add POST.
265
+
266
+ ---
267
+
268
+ ## v7.1.0 — Codegen correctness & DX
269
+
270
+ Three correctness fixes in the TypeScript codegen, two CLI/DX improvements. All changes are non-breaking for consumers using the documented entry points (`create${Name}Bindings`, `create${Name}Client`).
271
+
272
+ ### Fixed — `Cannot find name 'RootType'` for array-root schemas
273
+
274
+ `jsonSchemaToExtractedTypes` (in `src/codegen/emit-types.ts`) used `block.startsWith('export type Root')` to detect the root type block from ajsc's output. That predicate also matched `RootType` — the items type ajsc emits for `Array<RootType>` root schemas — and silently consumed it as the body, leaving the `Array<RootType>` reference dangling. The matcher is now a strict regex requiring `=` after `Root`, so `RootType` (and any other `Root*` sibling) flows correctly to the declarations branch.
275
+
276
+ ### Fixed — Generated client failed to compile under `verbatimModuleSyntax: true`
277
+
278
+ The index's `export namespace ${Name} { export import <Scope> = _scope.<Scope> }` re-exports tripped TS1269/TS1288 because each scope namespace was type-only. Namespace-mode scope files now emit the scope's `bindScope(client)` function as a member of `export namespace ${Pascal}` (e.g. `Users.bindScope(client)`), making the namespace value+type. The index's `export import` re-exports compile cleanly under verbatim, and the factory in `index.ts` now calls `_users.${Pascal}.bindScope(client)` in namespace mode. Flat mode is unchanged — `bind${Pascal}Scope` stays at module level.
279
+
280
+ Most consumers go through `create${Name}Bindings(client)` or `create${Name}Client(config)` and won't notice. Direct callers of `bindUsersScope` in namespace mode should switch to `Users.bindScope` (the standalone export was only ever generated in flat mode anyway).
281
+
282
+ ### Fixed — Duplicate `Params` / `Scope` identifiers when a property name shadows a route shortName
283
+
284
+ Schemas with a property named `params` (or `scope`, `body`, etc.) caused ajsc to extract `export type Params = {…}`, which then collided with the route's own `Params` shortName. The new `renameExtractedTypes` helper detects collisions per-route and aliases the extracted sub-type to `${name}Inner` (then `Inner2`, `Inner3`, …), patching every word-boundary occurrence in the body string so references still resolve. `formatTypes` accepts an `extraReserved` set so `emitApiRoute` can pre-reserve the structured `Params` it injects after the fact. No public API change.
285
+
286
+ ### Added — Strict CLI flag parsing with did-you-mean suggestions
287
+
288
+ `parseArgs` previously ignored any unrecognized `--…` token, which let a typo like `--targt` silently produce wrong output (or empty envelopes when paired with another bug). It now throws immediately:
289
+
290
+ ```
291
+ [ts-procedures-codegen] Unknown CLI flag: --targt. Did you mean `--target`?
292
+ ```
293
+
294
+ The suggestion uses prefix-containment as the primary heuristic (so `--service` suggests `--service-name`) and falls back to edit distance ≤ 3 (so `--targt` suggests `--target`). When nothing's close enough, the error points at the README instead of suggesting a misleading match.
295
+
296
+ ### Added — `builder.build()` hint in the empty-routes error
297
+
298
+ `resolveEnvelope` rejects an envelope with zero routes; the message now calls out the most common cause:
299
+
300
+ ```
301
+ DocEnvelope has an empty "routes" array. Common causes:
302
+ (1) you forgot to call `builder.build()` before passing the builder to `DocRegistry.from(...)` —
303
+ hono builders only populate `docs` inside `build()`;
304
+ (2) no procedures registered with the builder.
305
+ ```
306
+
307
+ ### Internal — `runTsc` test helper
308
+
309
+ E2E tests that shell out to `tsc --noEmit` now share `src/codegen/test-helpers/run-tsc.ts` instead of duplicating the try/execSync/stderr-capture dance in five places. Failures surface stderr in the assertion message uniformly.
310
+
311
+ ---
312
+
313
+ ## v7.0.0 — Normalized client errors & `.safe()` Result API
314
+
315
+ This major release reshapes how generated clients surface errors to consumers. Every platform error (`TypeError`, `DOMException`) now arrives as a typed framework class, and every RPC/API callable gets a `.safe()` sibling that returns a discriminated `Result<T, E>` instead of throwing. The throwing form remains canonical; `.safe()` is opt-in for sites that want exhaustive failure handling.
316
+
317
+ See `docs/client-error-handling.md` for the full consumer guide and migration walkthrough.
318
+
319
+ ### Added — Normalized framework error classes
320
+
321
+ - `ClientNetworkError` — wraps `TypeError` thrown by the adapter (network failure / DNS / refused / CORS). Carries `procedureName`, `scope`, and `cause`.
322
+ - `ClientTimeoutError` — `AbortError` triggered by the per-call/per-default `timeout`. Carries `timeoutMs`.
323
+ - `ClientAbortError` — `AbortError` triggered by a user-supplied `signal`. Carries `reason`.
324
+ - `ClientParseError` — reserved for adapter authors who want to flag an unparseable response body. Default fetch adapter does not raise it (current behavior preserved).
325
+ - All new classes (and the renamed `ClientHttpError`) accept an optional `cause?: unknown` argument and assign it via the standard `Error.cause` property.
326
+
327
+ ### Added — `.safe()` form on generated callables
328
+
329
+ - Every emitted RPC and API callable now exposes both forms via two new `ClientInstance` helpers: `bindCallable<P, R>(descriptor)` (routes without typed errors) and `bindCallableTyped<P, R, E>(descriptor)` (routes with typed errors). Codegen emits a single one-line call to the helper per route; the helper owns the `Object.assign(fn, { safe })` wiring internally. Per-route emission is ~7 lines vs ~25 for the inline form.
330
+ - Invoke `client.users.GetUser(params)` for the throwing form, or `client.users.GetUser.safe(params)` for the Result form.
331
+ - Routes with declared `errors` produce `Result<Response, RouteErrors>` (carries the `'typed'` arm); routes without get `ResultNoTyped<Response>` (the `'typed'` arm is omitted so IDE hovers stay clean).
332
+ - Generated callable's `.name` is preserved (set via `Object.defineProperty` inside the helper) so stack traces still show the route name.
333
+ - Streams keep the throwing form — `Result<T, E>` doesn't fit their three-way failure surface (pre-stream, mid-stream, completion). Their pre-stream errors still flow through the classifier.
334
+
335
+ ### Added — Augmentable `ClientErrorMap`
336
+
337
+ - New `ClientErrorMap` interface lets downstream apps add custom `kind` discriminants via TypeScript declaration merging — same pattern as `RequestMeta`.
338
+ - Default keys: `http`, `network`, `timeout`, `aborted`, `parse`, `usage`, `unknown`. The `'typed'` discriminant is reserved for route-declared errors and is not part of `ClientErrorMap`.
339
+ - Pair augmentation with an adapter-side `classifyError` function (composes with `defaultClassifyError`) to make custom kinds first-class members of `Result`.
340
+
341
+ ### Added — Adapter-level error classifier
342
+
343
+ - `ClientAdapter` interface gains optional `classifyError?: ErrorClassifier`.
344
+ - `createFetchAdapter({ classifyError })` accepts the same.
345
+ - `defaultClassifyError` is exported for adapter authors who want to compose their own classifier with the default fallthrough.
346
+
347
+ ### Changed — `ClientRequestError` renamed to `ClientHttpError`
348
+
349
+ - Reflects the class's actual role: HTTP-protocol-level failure (4xx/5xx without a registry match), distinct from network/timeout/abort errors.
350
+ - A deprecated alias (`export const ClientRequestError = ClientHttpError`) is retained for one minor release after 7.0.0. Migrate to the new name; `instanceof ClientRequestError` continues to work via the alias until the deprecation window closes.
351
+
352
+ ### Changed — `executeCall` normalizes platform errors at the adapter boundary
353
+
354
+ - Before: a thrown `TypeError` / `DOMException` propagated to the consumer's catch block as-is.
355
+ - After: the classifier composition (`adapter.classifyError ?? defaultClassifyError`) wraps the raw error in the appropriate framework class. Hooks (`onError`) receive the normalized error.
356
+ - Same change applies to `executeStream`'s pre-stream connection path. Mid-stream errors are unchanged.
357
+
358
+ ### Breaking changes
359
+
360
+ 1. **`ClientRequestError` → `ClientHttpError`** (deprecated alias retained for one minor cycle).
361
+ 2. **Raw `DOMException` / `TypeError` no longer reach consumer catch blocks.** They are wrapped in `ClientNetworkError` / `ClientTimeoutError` / `ClientAbortError`. The original platform error is preserved on `error.cause` for inspection.
362
+ 3. **`onError` hook receives the normalized framework error in `ctx.error`** (not the raw platform error). Consumers inspecting the raw shape need to update; most just log `error.message` and don't notice.
363
+
364
+ ### Migration
365
+
366
+ ```ts
367
+ // Before (6.x)
368
+ catch (e) {
369
+ if (e instanceof ClientRequestError) Alerts.error(`Server ${e.status}`)
370
+ else if (e instanceof DOMException && e.name === 'AbortError') {
371
+ if (timedOut) Alerts.error('Timed out')
372
+ else { /* user cancelled */ }
373
+ } else if (e instanceof TypeError) Alerts.error('Network error')
374
+ }
375
+
376
+ // After (7.x) — throwing form
377
+ catch (e) {
378
+ if (e instanceof ClientHttpError) Alerts.error(`Server ${e.status}`)
379
+ else if (e instanceof ClientTimeoutError) Alerts.error('Timed out')
380
+ else if (e instanceof ClientAbortError) { /* user cancelled */ }
381
+ else if (e instanceof ClientNetworkError) Alerts.error('Network error')
382
+ }
383
+
384
+ // After (7.x) — safe form (alternative)
385
+ const r = await client.X.GetUser.safe(params)
386
+ if (!r.ok) {
387
+ switch (r.kind) {
388
+ case 'http': Alerts.error(`Server ${r.error.status}`); break
389
+ case 'timeout': Alerts.error('Timed out'); break
390
+ case 'aborted': break
391
+ case 'network': Alerts.error('Network error'); break
392
+ case 'typed': /* registry-dispatched typed error */; break
393
+ default: throw r.error
394
+ }
395
+ }
396
+ ```
397
+
398
+ See `docs/client-error-handling.md` for the full guide including custom-kind augmentation and the `.safe()` retry-loop FAQ.
399
+
400
+ ---
401
+
402
+ ## v6.0.1 — DocRegistry constructor simplification
403
+
404
+ ### Changed
405
+
406
+ - `DocRegistry` constructor now accepts `errors: ErrorTaxonomy | ErrorDoc[]` (polymorphic). Pass your taxonomy directly instead of converting it beforehand.
407
+ - Framework error defaults are now auto-merged into every `DocRegistry` envelope (user entries override defaults via dedupe). Opt out via `includeDefaults: false`.
408
+ - New fluent method `DocRegistry.prototype.documentError(...docs: ErrorDoc[])` for documenting errors not in the taxonomy (middleware-level, infrastructure, doc-only meta errors).
409
+
410
+ ### Removed
411
+
412
+ - `DocRegistry.fromTaxonomy(taxonomy, config?)` — superseded by `new DocRegistry({ errors: taxonomy, ...config })`. The new form is strictly more capable (auto-defaults + dedupe applies to plain-constructor call sites too).
413
+ - `taxonomyToErrorDocs` — still exists internally but marked `@internal` and no longer recommended as a public entry point. Pass your taxonomy directly to `DocRegistry`.
414
+
415
+ ### Migration
416
+
417
+ ```typescript
418
+ // before (v6.0.0)
419
+ DocRegistry.fromTaxonomy(appErrors, { basePath: '/api' })
420
+
421
+ // after (v6.0.1)
422
+ new DocRegistry({ errors: appErrors, basePath: '/api' })
423
+ ```
424
+
425
+ If you were constructing `new DocRegistry({ errors: [myDoc] })` in v6.0.0 and relied on framework defaults NOT being auto-included, add `includeDefaults: false` to preserve v6.0.0 behavior.
426
+
427
+ ---
428
+
429
+ ## [6.0.0]
430
+
431
+ This is a feature-heavy major release built around a comprehensive overhaul of error handling. Every HTTP builder gains a declarative error taxonomy, typed client-side error dispatch, a cross-cutting observability hook, and per-route error documentation. The familiar `onError` callback is now framed as a first-class peer of the taxonomy, not a legacy fallback.
432
+
433
+ See the **Migration from 5.x** section at the end for the two breaking changes.
434
+
435
+ ### Added — Declarative error taxonomy (HTTP builders)
436
+
437
+ `defineErrorTaxonomy({ ... })` registers error classes once with `statusCode`, optional `toResponse`, `onCatch`, and `schema`. Pass to any HTTP builder via the new `errors` option; `unknownError` catches anything not declared. Exported from every builder subpath and from the dedicated `ts-procedures/http-errors` subpath.
438
+
439
+ - `src/implementations/http/error-taxonomy.ts` — `defineErrorTaxonomy`, `defaultErrorTaxonomy`, `resolveErrorResponse`, `taxonomyToErrorDocs`, `UnknownErrorConfig`, `ErrorTaxonomy`, `ErrorTaxonomyEntry`.
440
+ - `HonoAPIAppBuilder`, `HonoRPCAppBuilder`, and `HonoStreamAppBuilder` (pre-stream) now accept `errors` and `unknownError`. Mid-stream errors continue to flow through `onMidStreamError`.
441
+ - `defineErrorTaxonomy` topologically sorts `class:` entries so subclasses precede their base classes regardless of declared order; predicate (`match:`) entries retain declared order.
442
+ - Response bodies auto-inject `{ name: <key> }` when `toResponse` returns an object without a `name`, guaranteeing wire-protocol consistency.
443
+
444
+ ### Added — Per-route error declarations + `DocRegistry.fromTaxonomy`
445
+
446
+ - `APIConfig<TErrorKey extends string = string>` and `RPCConfig<TErrorKey extends string = string>` gained an optional `errors?: TErrorKey[]` field. Narrow to a taxonomy via `APIConfig<keyof typeof appErrors & string>` for compile-time typo protection.
447
+ - `APIHttpRouteDoc`, `RPCHttpRouteDoc`, and `StreamHttpRouteDoc` carry `errors?: string[]`. Each builder's `buildXxxRouteDoc` method copies `config.errors` onto the route doc.
448
+ - `DocRegistry.fromTaxonomy(taxonomy, config?)` convenience constructor seeds envelope errors from a taxonomy plus framework defaults (deduped — user entries win when keys overlap).
449
+ - `DocRegistry.defaultErrors()` now derives from `defaultErrorTaxonomy` via `taxonomyToErrorDocs` — single source of truth for runtime and documented shapes.
450
+
451
+ ### Added — Client-side runtime error classes + registry dispatch
452
+
453
+ - `emit-errors.ts` now emits real runtime classes (not just types) extending a shared `${ServiceName}ProcedureError<TBody>` base, each with a static `fromResponse(body, meta)` factory. `${ServiceName}ErrorRegistry` maps `body.name` to class for runtime dispatch. `${ServiceName}ProcedureErrorUnion` remains as a typed union.
454
+ - `emit-scope.ts` emits per-route `Errors` type unions inside each route's namespace when `route.errors` is declared, derived from the generated classes.
455
+ - `emit-index.ts` emits a new `create${ServiceName}Client(config)` convenience factory alongside `create${ServiceName}Bindings(client)`. The convenience form calls `createClient` with the error registry pre-wired so non-2xx responses arrive as typed class instances.
456
+ - `src/client/error-dispatch.ts` exports `dispatchTypedError(registry, body, meta)` — pure dispatch helper consumed by `executeCall` and `executeStream`. Falls back to `ClientRequestError` when no registry is configured or `body.name` doesn't match.
457
+ - `CreateClientConfig.errorRegistry` and new client types `ErrorRegistry`, `ErrorFactory`, `ErrorResponseMeta` (from `ts-procedures/client`).
458
+ - `AdapterStreamResponse.errorBody?` surfaces the parsed JSON body on non-2xx stream responses so pre-stream errors dispatch through the same registry as regular calls. The fetch adapter populates it automatically.
459
+ - Self-contained codegen (`selfContained: true`, the default) bundles `error-dispatch.ts` into `_client.ts`; `emit-index.ts` threads a separate `clientRuntimeImportPath` so the runtime `createClient` value import points at `./_client` while type imports stay at `./_types`.
460
+
461
+ ### Added — `onRequestError` observer hook on all HTTP builders
462
+
463
+ Fires for every caught error, **before** dispatch (taxonomy / `onError` / hard default). Awaited. Cannot mutate the response — it's an observer for cross-cutting logging, tracing, and metrics (Sentry, Datadog, OpenTelemetry). Errors thrown inside the observer are swallowed and logged to `console.error` so a broken instrumentation hook cannot disrupt the primary flow.
464
+
465
+ ```typescript
466
+ new HonoAPIAppBuilder({
467
+ errors: appErrors,
468
+ onRequestError: async ({ err, procedure, raw }) => {
469
+ sentry.captureException(err, { tags: { procedure: procedure.name } })
470
+ },
471
+ })
472
+ ```
473
+
474
+ Each builder exports an `OnRequestErrorContext` type with framework-specific typing for `raw` (Hono `Context`).
475
+
476
+ ### Changed — `onError` is a first-class peer, not legacy
477
+
478
+ Every HTTP builder supports two peer error-handling modes — **declarative** (`errors` taxonomy + `unknownError`) and **imperative** (`onError` callback). Neither is deprecated. The reframe touches JSDoc, all `*.md` docs, and the `scripts/check-docs-consistency.sh` guard; no runtime behavior change from the reframe alone.
479
+
480
+ Dispatch order inside each catch block: `onRequestError` → `errors` taxonomy → `onError` → hard default.
481
+
482
+ ### Changed — generated client output shape
483
+
484
+ - `_errors.ts` emits runtime classes + registry instead of type-only declarations. The `${ServiceName}ProcedureErrorUnion` export remains; its members are now class instances rather than interfaces.
485
+ - `DocRegistry.defaultErrors()` returns entries in topologically-sorted order (subclasses first). Code that depended on positional indexing must key by name instead.
486
+ - Generated `index.ts` imports `createClient` as a runtime value (not `import type`) when the envelope contains errors, so the registry can be wired into `create${ServiceName}Client`.
487
+
488
+ ### Migration from 5.x
489
+
490
+ Two breaking changes. Both have straightforward mitigations.
491
+
492
+ **1. `HonoStreamAppBuilder.onPreStreamError` renamed to `onError`**
493
+
494
+ For consistency with the other three HTTP builders. Signature unchanged.
495
+
496
+ ```ts
497
+ // Before (5.x)
498
+ new HonoStreamAppBuilder({
499
+ onPreStreamError: (proc, c, err) => c.json({ error: err.message }, 400),
500
+ })
501
+
502
+ // After (6.0)
503
+ new HonoStreamAppBuilder({
504
+ onError: (proc, c, err) => c.json({ error: err.message }, 400),
505
+ })
506
+ ```
507
+
508
+ **2. `HonoStreamAppBuilder` hard-default status for `ProcedureValidationError` changed from 400 to 500**
509
+
510
+ Previously, if no `errors` / `onError` was configured and a handler validation failed, hono-stream returned status **400**. All other builders returned **500** in the equivalent no-config case. v6 drops that special case — the hard default is now a flat 500 across all four builders.
511
+
512
+ Pick one migration path:
513
+
514
+ ```ts
515
+ // Option A — configure the taxonomy (empty object engages framework defaults,
516
+ // which includes ProcedureValidationError → 400).
517
+ new HonoStreamAppBuilder({ errors: {} })
518
+
519
+ // Option B — handle in onError and pick your own status.
520
+ new HonoStreamAppBuilder({
521
+ onError: (_p, c, err) =>
522
+ err instanceof ProcedureValidationError
523
+ ? c.json({ error: err.message }, 400)
524
+ : c.json({ error: err.message }, 500),
525
+ })
526
+
527
+ // Option C — accept the new 500 default.
528
+ ```
529
+
530
+ **Other changes are additive:**
531
+
532
+ - The error taxonomy, per-route errors, client runtime error classes, and `onRequestError` observer are all optional. Code that doesn't opt in continues to work.
533
+ - `APIConfig` / `RPCConfig` default their `TErrorKey` generic to `string`, so `Procedures<Ctx, APIConfig>()` still works without the generic argument.
534
+ - `createClient` without `errorRegistry` throws `ClientRequestError` as before.
535
+
536
+ ---
537
+
538
+ ## Earlier versions
539
+
540
+ Release history prior to v6 is available in the Git log — each release is tagged as a commit with the version number (for example, commit `5.16.0`).