ts-procedures 8.6.0 → 9.0.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 (627) hide show
  1. package/README.md +166 -101
  2. package/agent_config/claude-code/.claude-plugin/plugin.json +1 -1
  3. package/agent_config/claude-code/agents/ts-procedures-architect.md +11 -10
  4. package/agent_config/claude-code/skills/ts-procedures/SKILL.md +25 -12
  5. package/agent_config/claude-code/skills/ts-procedures/anti-patterns.md +10 -12
  6. package/agent_config/claude-code/skills/ts-procedures/api-reference.md +141 -45
  7. package/agent_config/claude-code/skills/ts-procedures/checklist.md +7 -6
  8. package/agent_config/claude-code/skills/ts-procedures/patterns.md +45 -6
  9. package/agent_config/claude-code/skills/ts-procedures/templates/client.md +1 -1
  10. package/agent_config/claude-code/skills/ts-procedures/templates/hono.md +1 -1
  11. package/agent_config/copilot/copilot-instructions.md +50 -33
  12. package/agent_config/cursor/cursorrules +50 -33
  13. package/build/adapters/astro/astro-context.js.map +1 -0
  14. package/build/adapters/astro/create-handler.js.map +1 -0
  15. package/build/adapters/astro/index.js.map +1 -0
  16. package/build/{implementations/http → adapters}/astro/index.test.js +1 -1
  17. package/build/adapters/astro/index.test.js.map +1 -0
  18. package/build/adapters/astro/rewrite-request.js.map +1 -0
  19. package/build/adapters/hono/envelope-parity.test.js +98 -0
  20. package/build/adapters/hono/envelope-parity.test.js.map +1 -0
  21. package/build/{implementations/http → adapters}/hono/handlers/http-stream.d.ts +1 -1
  22. package/build/adapters/hono/handlers/http-stream.js +55 -0
  23. package/build/adapters/hono/handlers/http-stream.js.map +1 -0
  24. package/build/{implementations/http → adapters}/hono/handlers/http-stream.test.js +1 -1
  25. package/build/adapters/hono/handlers/http-stream.test.js.map +1 -0
  26. package/build/{implementations/http → adapters}/hono/handlers/http.d.ts +1 -1
  27. package/build/adapters/hono/handlers/http.js +50 -0
  28. package/build/adapters/hono/handlers/http.js.map +1 -0
  29. package/build/{implementations/http → adapters}/hono/handlers/http.test.js +1 -1
  30. package/build/adapters/hono/handlers/http.test.js.map +1 -0
  31. package/build/{implementations/http → adapters}/hono/handlers/rpc.d.ts +2 -2
  32. package/build/adapters/hono/handlers/rpc.js +23 -0
  33. package/build/adapters/hono/handlers/rpc.js.map +1 -0
  34. package/build/{implementations/http → adapters}/hono/handlers/rpc.test.js +1 -1
  35. package/build/adapters/hono/handlers/rpc.test.js.map +1 -0
  36. package/build/adapters/hono/handlers/stream.d.ts +12 -0
  37. package/build/adapters/hono/handlers/stream.js +89 -0
  38. package/build/adapters/hono/handlers/stream.js.map +1 -0
  39. package/build/{implementations/http → adapters}/hono/handlers/stream.test.js +3 -2
  40. package/build/adapters/hono/handlers/stream.test.js.map +1 -0
  41. package/build/{implementations/http → adapters}/hono/index.d.ts +24 -12
  42. package/build/{implementations/http → adapters}/hono/index.js +19 -8
  43. package/build/adapters/hono/index.js.map +1 -0
  44. package/build/{implementations/http → adapters}/hono/index.test.js +2 -4
  45. package/build/adapters/hono/index.test.js.map +1 -0
  46. package/build/{implementations/http → adapters/hono}/on-request-error.test.js +2 -2
  47. package/build/adapters/hono/on-request-error.test.js.map +1 -0
  48. package/build/adapters/hono/request.d.ts +7 -0
  49. package/build/adapters/hono/request.js +22 -0
  50. package/build/adapters/hono/request.js.map +1 -0
  51. package/build/{implementations/http → adapters/hono}/route-errors.test.js +4 -4
  52. package/build/adapters/hono/route-errors.test.js.map +1 -0
  53. package/build/adapters/hono/types.d.ts +55 -0
  54. package/build/adapters/hono/types.js +19 -0
  55. package/build/adapters/hono/types.js.map +1 -0
  56. package/build/client/freeze.test.js +39 -0
  57. package/build/client/freeze.test.js.map +1 -0
  58. package/build/client/typed-error-dispatch.test.js +2 -2
  59. package/build/client/typed-error-dispatch.test.js.map +1 -1
  60. package/build/codegen/__fixtures__/make-envelope.d.ts +1 -1
  61. package/build/codegen/bin/cli.d.ts +5 -0
  62. package/build/codegen/bin/cli.js +139 -182
  63. package/build/codegen/bin/cli.js.map +1 -1
  64. package/build/codegen/bin/cli.test.js +12 -2
  65. package/build/codegen/bin/cli.test.js.map +1 -1
  66. package/build/codegen/bin/flag-specs.d.ts +9 -0
  67. package/build/codegen/bin/flag-specs.js +33 -31
  68. package/build/codegen/bin/flag-specs.js.map +1 -1
  69. package/build/codegen/bin/flag-specs.test.js +14 -1
  70. package/build/codegen/bin/flag-specs.test.js.map +1 -1
  71. package/build/codegen/collect-models.d.ts +1 -1
  72. package/build/codegen/emit/api-route.d.ts +8 -0
  73. package/build/codegen/emit/api-route.js +156 -0
  74. package/build/codegen/emit/api-route.js.map +1 -0
  75. package/build/codegen/emit/context.d.ts +30 -0
  76. package/build/codegen/emit/context.js +2 -0
  77. package/build/codegen/emit/context.js.map +1 -0
  78. package/build/codegen/emit/declarations.d.ts +24 -0
  79. package/build/codegen/emit/declarations.js +48 -0
  80. package/build/codegen/emit/declarations.js.map +1 -0
  81. package/build/codegen/emit/format-types.d.ts +61 -0
  82. package/build/codegen/emit/format-types.js +188 -0
  83. package/build/codegen/emit/format-types.js.map +1 -0
  84. package/build/codegen/emit/http-stream-route.d.ts +7 -0
  85. package/build/codegen/emit/http-stream-route.js +138 -0
  86. package/build/codegen/emit/http-stream-route.js.map +1 -0
  87. package/build/codegen/emit/route-shared.d.ts +35 -0
  88. package/build/codegen/emit/route-shared.js +88 -0
  89. package/build/codegen/emit/route-shared.js.map +1 -0
  90. package/build/codegen/emit/rpc-route.d.ts +7 -0
  91. package/build/codegen/emit/rpc-route.js +37 -0
  92. package/build/codegen/emit/rpc-route.js.map +1 -0
  93. package/build/codegen/emit/scope-file.d.ts +39 -0
  94. package/build/codegen/emit/scope-file.js +166 -0
  95. package/build/codegen/emit/scope-file.js.map +1 -0
  96. package/build/codegen/emit/stream-route.d.ts +7 -0
  97. package/build/codegen/emit/stream-route.js +62 -0
  98. package/build/codegen/emit/stream-route.js.map +1 -0
  99. package/build/codegen/emit-errors.d.ts +1 -1
  100. package/build/codegen/emit-errors.integration.test.js +1 -1
  101. package/build/codegen/emit-errors.integration.test.js.map +1 -1
  102. package/build/codegen/emit-scope.d.ts +13 -30
  103. package/build/codegen/emit-scope.js +15 -844
  104. package/build/codegen/emit-scope.js.map +1 -1
  105. package/build/codegen/goldens.test.js +69 -0
  106. package/build/codegen/goldens.test.js.map +1 -0
  107. package/build/codegen/group-routes.d.ts +1 -1
  108. package/build/codegen/pipeline.d.ts +1 -1
  109. package/build/codegen/resolve-envelope.d.ts +1 -1
  110. package/build/codegen/targets/_shared/error-schemas.d.ts +1 -1
  111. package/build/codegen/targets/_shared/route-slots.d.ts +1 -1
  112. package/build/codegen/targets/_shared/target-run.d.ts +1 -1
  113. package/build/codegen/targets/kotlin/emit-route-kotlin.d.ts +1 -1
  114. package/build/codegen/targets/swift/emit-route-swift.d.ts +1 -1
  115. package/build/core/create-http-stream.d.ts +50 -0
  116. package/build/core/create-http-stream.js +108 -0
  117. package/build/core/create-http-stream.js.map +1 -0
  118. package/build/{create-http-stream.test.js → core/create-http-stream.test.js} +1 -1
  119. package/build/core/create-http-stream.test.js.map +1 -0
  120. package/build/core/create-http.d.ts +51 -0
  121. package/build/core/create-http.js +65 -0
  122. package/build/core/create-http.js.map +1 -0
  123. package/build/{create-http.test.js → core/create-http.test.js} +13 -4
  124. package/build/core/create-http.test.js.map +1 -0
  125. package/build/core/create-stream.d.ts +26 -0
  126. package/build/core/create-stream.js +80 -0
  127. package/build/core/create-stream.js.map +1 -0
  128. package/build/{create-stream.test.js → core/create-stream.test.js} +23 -28
  129. package/build/core/create-stream.test.js.map +1 -0
  130. package/build/core/create.d.ts +22 -0
  131. package/build/core/create.js +71 -0
  132. package/build/core/create.js.map +1 -0
  133. package/build/{create.test.js → core/create.test.js} +25 -46
  134. package/build/core/create.test.js.map +1 -0
  135. package/build/core/definition-site.d.ts +24 -0
  136. package/build/{stack-utils.js → core/definition-site.js} +20 -20
  137. package/build/core/definition-site.js.map +1 -0
  138. package/build/{stack-utils.test.js → core/definition-site.test.js} +12 -3
  139. package/build/core/definition-site.test.js.map +1 -0
  140. package/build/{errors.d.ts → core/errors.d.ts} +19 -8
  141. package/build/{errors.js → core/errors.js} +21 -26
  142. package/build/core/errors.js.map +1 -0
  143. package/build/core/errors.test.js.map +1 -0
  144. package/build/core/factory-options.test.js +82 -0
  145. package/build/core/factory-options.test.js.map +1 -0
  146. package/build/core/http-route.d.ts +13 -0
  147. package/build/core/http-route.js +54 -0
  148. package/build/core/http-route.js.map +1 -0
  149. package/build/core/internal.d.ts +72 -0
  150. package/build/core/internal.js +128 -0
  151. package/build/core/internal.js.map +1 -0
  152. package/build/{migration.test.js → core/migration.test.js} +17 -1
  153. package/build/core/migration.test.js.map +1 -0
  154. package/build/core/procedures.d.ts +143 -0
  155. package/build/core/procedures.js +64 -0
  156. package/build/core/procedures.js.map +1 -0
  157. package/build/{index.test.js → core/procedures.test.js} +14 -11
  158. package/build/core/procedures.test.js.map +1 -0
  159. package/build/core/types.d.ts +182 -0
  160. package/build/{schema → core}/types.js.map +1 -1
  161. package/build/exports.d.ts +31 -11
  162. package/build/exports.js +23 -8
  163. package/build/exports.js.map +1 -1
  164. package/build/schema/adapter.d.ts +35 -0
  165. package/build/schema/adapter.js +13 -0
  166. package/build/schema/adapter.js.map +1 -0
  167. package/build/schema/adapter.test.js +53 -0
  168. package/build/schema/adapter.test.js.map +1 -0
  169. package/build/schema/compile.d.ts +37 -0
  170. package/build/schema/compile.js +38 -0
  171. package/build/schema/compile.js.map +1 -0
  172. package/build/schema/compile.test.js +78 -0
  173. package/build/schema/compile.test.js.map +1 -0
  174. package/build/schema/compute-schema.d.ts +47 -37
  175. package/build/schema/compute-schema.js +86 -29
  176. package/build/schema/compute-schema.js.map +1 -1
  177. package/build/schema/compute-schema.test.js +158 -40
  178. package/build/schema/compute-schema.test.js.map +1 -1
  179. package/build/schema/json-schema.d.ts +17 -0
  180. package/build/schema/json-schema.js +2 -0
  181. package/build/schema/json-schema.js.map +1 -0
  182. package/build/schema/typebox.d.ts +11 -0
  183. package/build/schema/typebox.js +24 -0
  184. package/build/schema/typebox.js.map +1 -0
  185. package/build/schema/typebox.test.js +34 -0
  186. package/build/schema/typebox.test.js.map +1 -0
  187. package/build/server/context.d.ts +8 -0
  188. package/build/server/context.js +7 -0
  189. package/build/server/context.js.map +1 -0
  190. package/build/server/context.test.js +16 -0
  191. package/build/server/context.test.js.map +1 -0
  192. package/build/{doc-envelope.d.ts → server/doc-envelope.d.ts} +1 -1
  193. package/build/server/doc-envelope.js.map +1 -0
  194. package/build/server/doc-envelope.test.d.ts +1 -0
  195. package/build/server/doc-envelope.test.js.map +1 -0
  196. package/build/{implementations/http → server}/doc-registry.d.ts +7 -2
  197. package/build/{implementations/http → server}/doc-registry.js +9 -5
  198. package/build/server/doc-registry.js.map +1 -0
  199. package/build/server/doc-registry.test.d.ts +1 -0
  200. package/build/{implementations/http → server}/doc-registry.test.js +27 -24
  201. package/build/server/doc-registry.test.js.map +1 -0
  202. package/build/server/docs/docs.test.d.ts +1 -0
  203. package/build/server/docs/docs.test.js +237 -0
  204. package/build/server/docs/docs.test.js.map +1 -0
  205. package/build/{implementations/http/hono → server}/docs/http-doc.d.ts +2 -2
  206. package/build/{implementations/http/hono → server}/docs/http-doc.js +1 -1
  207. package/build/server/docs/http-doc.js.map +1 -0
  208. package/build/{implementations/http/hono → server}/docs/http-stream-doc.d.ts +2 -2
  209. package/build/{implementations/http/hono → server}/docs/http-stream-doc.js +1 -1
  210. package/build/server/docs/http-stream-doc.js.map +1 -0
  211. package/build/{implementations/http/hono → server}/docs/rpc-doc.d.ts +2 -2
  212. package/build/{implementations/http/hono → server}/docs/rpc-doc.js +1 -1
  213. package/build/server/docs/rpc-doc.js.map +1 -0
  214. package/build/{implementations/http/hono → server}/docs/stream-doc.d.ts +2 -2
  215. package/build/{implementations/http/hono → server}/docs/stream-doc.js +1 -1
  216. package/build/server/docs/stream-doc.js.map +1 -0
  217. package/build/server/errors/dispatch.d.ts +96 -0
  218. package/build/{implementations/http/error-dispatch.js → server/errors/dispatch.js} +20 -10
  219. package/build/server/errors/dispatch.js.map +1 -0
  220. package/build/server/errors/dispatch.test.d.ts +1 -0
  221. package/build/server/errors/dispatch.test.js +418 -0
  222. package/build/server/errors/dispatch.test.js.map +1 -0
  223. package/build/{implementations/http/error-taxonomy.d.ts → server/errors/taxonomy.d.ts} +8 -17
  224. package/build/{implementations/http/error-taxonomy.js → server/errors/taxonomy.js} +6 -15
  225. package/build/server/errors/taxonomy.js.map +1 -0
  226. package/build/server/errors/taxonomy.test.d.ts +1 -0
  227. package/build/{implementations/http/error-taxonomy.test.js → server/errors/taxonomy.test.js} +45 -39
  228. package/build/server/errors/taxonomy.test.js.map +1 -0
  229. package/build/server/index.d.ts +29 -0
  230. package/build/server/index.js +27 -0
  231. package/build/server/index.js.map +1 -0
  232. package/build/server/no-framework-imports.test.d.ts +1 -0
  233. package/build/server/no-framework-imports.test.js +40 -0
  234. package/build/server/no-framework-imports.test.js.map +1 -0
  235. package/build/{implementations/http/hono/path.d.ts → server/paths.d.ts} +2 -3
  236. package/build/{implementations/http/hono/path.js → server/paths.js} +1 -1
  237. package/build/server/paths.js.map +1 -0
  238. package/build/server/paths.test.d.ts +1 -0
  239. package/build/server/paths.test.js +111 -0
  240. package/build/server/paths.test.js.map +1 -0
  241. package/build/server/request/params.d.ts +29 -0
  242. package/build/server/request/params.js +43 -0
  243. package/build/server/request/params.js.map +1 -0
  244. package/build/server/request/params.test.d.ts +1 -0
  245. package/build/server/request/params.test.js +91 -0
  246. package/build/server/request/params.test.js.map +1 -0
  247. package/build/server/request/query.d.ts +9 -0
  248. package/build/server/request/query.js +22 -0
  249. package/build/server/request/query.js.map +1 -0
  250. package/build/server/request/query.test.d.ts +1 -0
  251. package/build/server/request/query.test.js +60 -0
  252. package/build/server/request/query.test.js.map +1 -0
  253. package/build/server/sse.d.ts +70 -0
  254. package/build/server/sse.js +94 -0
  255. package/build/server/sse.js.map +1 -0
  256. package/build/server/sse.test.d.ts +1 -0
  257. package/build/server/sse.test.js +98 -0
  258. package/build/server/sse.test.js.map +1 -0
  259. package/build/{implementations → server}/types.d.ts +17 -15
  260. package/build/{implementations → server}/types.js.map +1 -1
  261. package/docs/astro-adapter.md +8 -9
  262. package/docs/client-and-codegen.md +4 -4
  263. package/docs/client-error-handling.md +5 -5
  264. package/docs/codegen-kotlin.md +2 -3
  265. package/docs/codegen-swift.md +1 -2
  266. package/docs/core.md +135 -54
  267. package/docs/http-integrations.md +58 -6
  268. package/docs/migration-v8-to-v9.md +192 -0
  269. package/docs/plans/2026-06-09-v9-rewrite.md +130 -0
  270. package/docs/specs/2026-06-09-v9-rewrite-design.md +221 -0
  271. package/docs/streaming.md +12 -0
  272. package/package.json +23 -47
  273. package/src/{implementations/http → adapters}/astro/index.test.ts +2 -2
  274. package/src/adapters/hono/__fixtures__/parity-envelope.json +389 -0
  275. package/src/adapters/hono/envelope-parity.test.ts +126 -0
  276. package/src/{implementations/http → adapters}/hono/handlers/http-stream.test.ts +1 -1
  277. package/src/adapters/hono/handlers/http-stream.ts +73 -0
  278. package/src/{implementations/http → adapters}/hono/handlers/http.test.ts +1 -1
  279. package/src/adapters/hono/handlers/http.ts +70 -0
  280. package/src/{implementations/http → adapters}/hono/handlers/rpc.test.ts +2 -2
  281. package/src/adapters/hono/handlers/rpc.ts +39 -0
  282. package/src/{implementations/http → adapters}/hono/handlers/stream.test.ts +4 -3
  283. package/src/{implementations/http → adapters}/hono/handlers/stream.ts +19 -92
  284. package/src/{implementations/http → adapters}/hono/index.test.ts +14 -16
  285. package/src/{implementations/http → adapters}/hono/index.ts +35 -30
  286. package/src/{implementations/http → adapters/hono}/on-request-error.test.ts +3 -3
  287. package/src/adapters/hono/request.ts +28 -0
  288. package/src/{implementations/http → adapters/hono}/route-errors.test.ts +5 -5
  289. package/src/{implementations/http → adapters}/hono/types.ts +43 -20
  290. package/src/client/freeze.test.ts +41 -0
  291. package/src/client/typed-error-dispatch.test.ts +3 -3
  292. package/src/codegen/__fixtures__/make-envelope.ts +1 -1
  293. package/src/codegen/__fixtures__/models-envelope.json +310 -0
  294. package/src/codegen/__goldens__/MANIFEST.json +85 -0
  295. package/src/codegen/__goldens__/kotlin-default--models/Billing.kt +112 -0
  296. package/src/codegen/__goldens__/kotlin-default--models/BillingReports.kt +26 -0
  297. package/src/codegen/__goldens__/kotlin-default--models/Orders.kt +88 -0
  298. package/src/codegen/__goldens__/kotlin-default--users/Users.kt +189 -0
  299. package/src/codegen/__goldens__/swift-default--models/Billing.swift +97 -0
  300. package/src/codegen/__goldens__/swift-default--models/BillingReports.swift +20 -0
  301. package/src/codegen/__goldens__/swift-default--models/Orders.swift +81 -0
  302. package/src/codegen/__goldens__/swift-default--users/Users.swift +204 -0
  303. package/src/codegen/__goldens__/ts-default--models/_client.ts +1319 -0
  304. package/src/codegen/__goldens__/ts-default--models/_errors.ts +90 -0
  305. package/src/codegen/__goldens__/ts-default--models/_models.ts +10 -0
  306. package/src/codegen/__goldens__/ts-default--models/_types.ts +502 -0
  307. package/src/codegen/__goldens__/ts-default--models/billing-reports.ts +29 -0
  308. package/src/codegen/__goldens__/ts-default--models/billing.ts +67 -0
  309. package/src/codegen/__goldens__/ts-default--models/index.ts +48 -0
  310. package/src/codegen/__goldens__/ts-default--models/orders.ts +80 -0
  311. package/src/codegen/__goldens__/ts-default--users/_client.ts +1319 -0
  312. package/src/codegen/__goldens__/ts-default--users/_errors.ts +90 -0
  313. package/src/codegen/__goldens__/ts-default--users/_types.ts +502 -0
  314. package/src/codegen/__goldens__/ts-default--users/index.ts +38 -0
  315. package/src/codegen/__goldens__/ts-default--users/users.ts +169 -0
  316. package/src/codegen/__goldens__/ts-external-runtime--models/_errors.ts +90 -0
  317. package/src/codegen/__goldens__/ts-external-runtime--models/_models.ts +10 -0
  318. package/src/codegen/__goldens__/ts-external-runtime--models/billing-reports.ts +29 -0
  319. package/src/codegen/__goldens__/ts-external-runtime--models/billing.ts +67 -0
  320. package/src/codegen/__goldens__/ts-external-runtime--models/index.ts +48 -0
  321. package/src/codegen/__goldens__/ts-external-runtime--models/orders.ts +80 -0
  322. package/src/codegen/__goldens__/ts-external-runtime--users/_errors.ts +90 -0
  323. package/src/codegen/__goldens__/ts-external-runtime--users/index.ts +38 -0
  324. package/src/codegen/__goldens__/ts-external-runtime--users/users.ts +169 -0
  325. package/src/codegen/__goldens__/ts-flat--models/_client.ts +1319 -0
  326. package/src/codegen/__goldens__/ts-flat--models/_errors.ts +87 -0
  327. package/src/codegen/__goldens__/ts-flat--models/_models.ts +10 -0
  328. package/src/codegen/__goldens__/ts-flat--models/_types.ts +502 -0
  329. package/src/codegen/__goldens__/ts-flat--models/billing-reports.ts +28 -0
  330. package/src/codegen/__goldens__/ts-flat--models/billing.ts +51 -0
  331. package/src/codegen/__goldens__/ts-flat--models/index.ts +42 -0
  332. package/src/codegen/__goldens__/ts-flat--models/orders.ts +73 -0
  333. package/src/codegen/__goldens__/ts-flat--users/_client.ts +1319 -0
  334. package/src/codegen/__goldens__/ts-flat--users/_errors.ts +87 -0
  335. package/src/codegen/__goldens__/ts-flat--users/_types.ts +502 -0
  336. package/src/codegen/__goldens__/ts-flat--users/index.ts +34 -0
  337. package/src/codegen/__goldens__/ts-flat--users/users.ts +126 -0
  338. package/src/codegen/__goldens__/ts-no-share-models--models/_client.ts +1319 -0
  339. package/src/codegen/__goldens__/ts-no-share-models--models/_errors.ts +90 -0
  340. package/src/codegen/__goldens__/ts-no-share-models--models/_types.ts +502 -0
  341. package/src/codegen/__goldens__/ts-no-share-models--models/billing-reports.ts +29 -0
  342. package/src/codegen/__goldens__/ts-no-share-models--models/billing.ts +111 -0
  343. package/src/codegen/__goldens__/ts-no-share-models--models/index.ts +48 -0
  344. package/src/codegen/__goldens__/ts-no-share-models--models/orders.ts +112 -0
  345. package/src/codegen/__goldens__/ts-no-share-models--users/_client.ts +1319 -0
  346. package/src/codegen/__goldens__/ts-no-share-models--users/_errors.ts +90 -0
  347. package/src/codegen/__goldens__/ts-no-share-models--users/_types.ts +502 -0
  348. package/src/codegen/__goldens__/ts-no-share-models--users/index.ts +38 -0
  349. package/src/codegen/__goldens__/ts-no-share-models--users/users.ts +169 -0
  350. package/src/codegen/__goldens__/ts-shared-models-module--models/_client.ts +1319 -0
  351. package/src/codegen/__goldens__/ts-shared-models-module--models/_errors.ts +90 -0
  352. package/src/codegen/__goldens__/ts-shared-models-module--models/_models.ts +7 -0
  353. package/src/codegen/__goldens__/ts-shared-models-module--models/_types.ts +502 -0
  354. package/src/codegen/__goldens__/ts-shared-models-module--models/billing-reports.ts +29 -0
  355. package/src/codegen/__goldens__/ts-shared-models-module--models/billing.ts +67 -0
  356. package/src/codegen/__goldens__/ts-shared-models-module--models/index.ts +48 -0
  357. package/src/codegen/__goldens__/ts-shared-models-module--models/orders.ts +80 -0
  358. package/src/codegen/bin/cli.test.ts +13 -2
  359. package/src/codegen/bin/cli.ts +181 -144
  360. package/src/codegen/bin/flag-specs.test.ts +16 -1
  361. package/src/codegen/bin/flag-specs.ts +43 -31
  362. package/src/codegen/bundle-size.test.ts +1 -1
  363. package/src/codegen/collect-models.ts +1 -1
  364. package/src/codegen/e2e.test.ts +1 -1
  365. package/src/codegen/emit/api-route.ts +184 -0
  366. package/src/codegen/emit/context.ts +32 -0
  367. package/src/codegen/emit/declarations.ts +49 -0
  368. package/src/codegen/emit/format-types.ts +232 -0
  369. package/src/codegen/emit/http-stream-route.ts +162 -0
  370. package/src/codegen/emit/route-shared.ts +102 -0
  371. package/src/codegen/emit/rpc-route.ts +49 -0
  372. package/src/codegen/emit/scope-file.ts +226 -0
  373. package/src/codegen/emit/stream-route.ts +81 -0
  374. package/src/codegen/emit-errors.integration.test.ts +2 -2
  375. package/src/codegen/emit-errors.test.ts +1 -1
  376. package/src/codegen/emit-errors.ts +1 -1
  377. package/src/codegen/emit-scope.test.ts +2 -2
  378. package/src/codegen/emit-scope.ts +15 -1048
  379. package/src/codegen/goldens.test.ts +89 -0
  380. package/src/codegen/group-routes.test.ts +1 -1
  381. package/src/codegen/group-routes.ts +1 -1
  382. package/src/codegen/pipeline.test.ts +1 -1
  383. package/src/codegen/pipeline.ts +1 -1
  384. package/src/codegen/resolve-envelope.test.ts +1 -1
  385. package/src/codegen/resolve-envelope.ts +1 -1
  386. package/src/codegen/targets/_shared/error-schemas.test.ts +1 -1
  387. package/src/codegen/targets/_shared/error-schemas.ts +1 -1
  388. package/src/codegen/targets/_shared/route-slots.test.ts +1 -1
  389. package/src/codegen/targets/_shared/route-slots.ts +1 -1
  390. package/src/codegen/targets/_shared/target-run.ts +1 -1
  391. package/src/codegen/targets/kotlin/emit-route-kotlin.test.ts +1 -1
  392. package/src/codegen/targets/kotlin/emit-route-kotlin.ts +1 -1
  393. package/src/codegen/targets/kotlin/emit-scope-kotlin.test.ts +1 -1
  394. package/src/codegen/targets/swift/access-level.test.ts +1 -1
  395. package/src/codegen/targets/swift/emit-route-swift.test.ts +1 -1
  396. package/src/codegen/targets/swift/emit-route-swift.ts +1 -1
  397. package/src/codegen/targets/swift/emit-scope-swift.test.ts +1 -1
  398. package/src/codegen/targets/ts/shared-models.test.ts +1 -1
  399. package/src/{create-http-stream.test.ts → core/create-http-stream.test.ts} +1 -1
  400. package/src/core/create-http-stream.ts +207 -0
  401. package/src/{create-http.test.ts → core/create-http.test.ts} +15 -4
  402. package/src/core/create-http.ts +126 -0
  403. package/src/{create-stream.test.ts → core/create-stream.test.ts} +28 -31
  404. package/src/core/create-stream.ts +142 -0
  405. package/src/{create.test.ts → core/create.test.ts} +25 -57
  406. package/src/core/create.ts +121 -0
  407. package/src/{stack-utils.test.ts → core/definition-site.test.ts} +14 -3
  408. package/src/{stack-utils.ts → core/definition-site.ts} +20 -23
  409. package/src/{errors.test.ts → core/errors.test.ts} +1 -1
  410. package/src/{errors.ts → core/errors.ts} +30 -28
  411. package/src/core/factory-options.test.ts +112 -0
  412. package/src/core/http-route.ts +73 -0
  413. package/src/core/internal.ts +203 -0
  414. package/src/{migration.test.ts → core/migration.test.ts} +23 -1
  415. package/src/{index.test.ts → core/procedures.test.ts} +13 -11
  416. package/src/core/procedures.ts +75 -0
  417. package/src/core/types.ts +195 -0
  418. package/src/exports.ts +60 -11
  419. package/src/schema/adapter.test.ts +58 -0
  420. package/src/schema/adapter.ts +45 -0
  421. package/src/schema/compile.test.ts +95 -0
  422. package/src/schema/compile.ts +64 -0
  423. package/src/schema/compute-schema.test.ts +222 -41
  424. package/src/schema/compute-schema.ts +145 -71
  425. package/src/schema/json-schema.ts +21 -0
  426. package/src/schema/typebox.test.ts +40 -0
  427. package/src/schema/typebox.ts +27 -0
  428. package/src/server/context.test.ts +22 -0
  429. package/src/server/context.ts +18 -0
  430. package/src/{doc-envelope.test.ts → server/doc-envelope.test.ts} +2 -2
  431. package/src/{doc-envelope.ts → server/doc-envelope.ts} +1 -1
  432. package/src/{implementations/http → server}/doc-registry.test.ts +32 -26
  433. package/src/{implementations/http → server}/doc-registry.ts +11 -7
  434. package/src/server/docs/docs.test.ts +287 -0
  435. package/src/{implementations/http/hono → server}/docs/http-doc.ts +3 -3
  436. package/src/{implementations/http/hono → server}/docs/http-stream-doc.ts +3 -3
  437. package/src/{implementations/http/hono → server}/docs/rpc-doc.ts +3 -3
  438. package/src/{implementations/http/hono → server}/docs/stream-doc.ts +3 -3
  439. package/src/server/errors/dispatch.test.ts +450 -0
  440. package/src/server/errors/dispatch.ts +189 -0
  441. package/src/{implementations/http/error-taxonomy.test.ts → server/errors/taxonomy.test.ts} +45 -39
  442. package/src/{implementations/http/error-taxonomy.ts → server/errors/taxonomy.ts} +8 -17
  443. package/src/server/index.ts +29 -0
  444. package/src/server/no-framework-imports.test.ts +43 -0
  445. package/src/server/paths.test.ts +141 -0
  446. package/src/{implementations/http/hono/path.ts → server/paths.ts} +2 -13
  447. package/src/server/request/params.test.ts +143 -0
  448. package/src/server/request/params.ts +68 -0
  449. package/src/server/request/query.test.ts +70 -0
  450. package/src/server/request/query.ts +24 -0
  451. package/src/server/sse.test.ts +113 -0
  452. package/src/server/sse.ts +117 -0
  453. package/src/{implementations → server}/types.ts +17 -16
  454. package/build/create-http-stream.d.ts +0 -58
  455. package/build/create-http-stream.js +0 -122
  456. package/build/create-http-stream.js.map +0 -1
  457. package/build/create-http-stream.test.js.map +0 -1
  458. package/build/create-http.d.ts +0 -49
  459. package/build/create-http.js +0 -108
  460. package/build/create-http.js.map +0 -1
  461. package/build/create-http.test.js.map +0 -1
  462. package/build/create-stream.d.ts +0 -35
  463. package/build/create-stream.js +0 -123
  464. package/build/create-stream.js.map +0 -1
  465. package/build/create-stream.test.js.map +0 -1
  466. package/build/create.d.ts +0 -28
  467. package/build/create.js +0 -82
  468. package/build/create.js.map +0 -1
  469. package/build/create.test.js.map +0 -1
  470. package/build/doc-envelope.js.map +0 -1
  471. package/build/doc-envelope.test.js.map +0 -1
  472. package/build/errors.js.map +0 -1
  473. package/build/errors.test.js.map +0 -1
  474. package/build/implementations/http/astro/astro-context.js.map +0 -1
  475. package/build/implementations/http/astro/create-handler.js.map +0 -1
  476. package/build/implementations/http/astro/index.js.map +0 -1
  477. package/build/implementations/http/astro/index.test.js.map +0 -1
  478. package/build/implementations/http/astro/rewrite-request.js.map +0 -1
  479. package/build/implementations/http/doc-registry.js.map +0 -1
  480. package/build/implementations/http/doc-registry.test.js.map +0 -1
  481. package/build/implementations/http/error-dispatch.d.ts +0 -76
  482. package/build/implementations/http/error-dispatch.js.map +0 -1
  483. package/build/implementations/http/error-dispatch.test.js +0 -254
  484. package/build/implementations/http/error-dispatch.test.js.map +0 -1
  485. package/build/implementations/http/error-taxonomy.js.map +0 -1
  486. package/build/implementations/http/error-taxonomy.test.js.map +0 -1
  487. package/build/implementations/http/hono/docs/http-doc.js.map +0 -1
  488. package/build/implementations/http/hono/docs/http-stream-doc.js.map +0 -1
  489. package/build/implementations/http/hono/docs/rpc-doc.js.map +0 -1
  490. package/build/implementations/http/hono/docs/stream-doc.js.map +0 -1
  491. package/build/implementations/http/hono/handlers/http-stream.js +0 -123
  492. package/build/implementations/http/hono/handlers/http-stream.js.map +0 -1
  493. package/build/implementations/http/hono/handlers/http-stream.test.js.map +0 -1
  494. package/build/implementations/http/hono/handlers/http.js +0 -110
  495. package/build/implementations/http/hono/handlers/http.js.map +0 -1
  496. package/build/implementations/http/hono/handlers/http.test.js.map +0 -1
  497. package/build/implementations/http/hono/handlers/rpc.js +0 -32
  498. package/build/implementations/http/hono/handlers/rpc.js.map +0 -1
  499. package/build/implementations/http/hono/handlers/rpc.test.js.map +0 -1
  500. package/build/implementations/http/hono/handlers/stream.d.ts +0 -23
  501. package/build/implementations/http/hono/handlers/stream.js +0 -147
  502. package/build/implementations/http/hono/handlers/stream.js.map +0 -1
  503. package/build/implementations/http/hono/handlers/stream.test.js.map +0 -1
  504. package/build/implementations/http/hono/index.js.map +0 -1
  505. package/build/implementations/http/hono/index.test.js.map +0 -1
  506. package/build/implementations/http/hono/path.js.map +0 -1
  507. package/build/implementations/http/hono/path.test.js +0 -83
  508. package/build/implementations/http/hono/path.test.js.map +0 -1
  509. package/build/implementations/http/hono/types.d.ts +0 -51
  510. package/build/implementations/http/hono/types.js.map +0 -1
  511. package/build/implementations/http/on-request-error.test.js.map +0 -1
  512. package/build/implementations/http/route-errors.test.js.map +0 -1
  513. package/build/index.d.ts +0 -175
  514. package/build/index.js +0 -47
  515. package/build/index.js.map +0 -1
  516. package/build/index.test.js.map +0 -1
  517. package/build/migration.test.js.map +0 -1
  518. package/build/schema/extract-json-schema.d.ts +0 -2
  519. package/build/schema/extract-json-schema.js +0 -12
  520. package/build/schema/extract-json-schema.js.map +0 -1
  521. package/build/schema/extract-json-schema.test.js +0 -23
  522. package/build/schema/extract-json-schema.test.js.map +0 -1
  523. package/build/schema/parser.d.ts +0 -36
  524. package/build/schema/parser.js +0 -210
  525. package/build/schema/parser.js.map +0 -1
  526. package/build/schema/parser.test.js +0 -120
  527. package/build/schema/parser.test.js.map +0 -1
  528. package/build/schema/resolve-schema-lib.d.ts +0 -12
  529. package/build/schema/resolve-schema-lib.js +0 -11
  530. package/build/schema/resolve-schema-lib.js.map +0 -1
  531. package/build/schema/resolve-schema-lib.test.js +0 -17
  532. package/build/schema/resolve-schema-lib.test.js.map +0 -1
  533. package/build/schema/types.d.ts +0 -8
  534. package/build/schema/types.js +0 -2
  535. package/build/stack-utils.d.ts +0 -25
  536. package/build/stack-utils.js.map +0 -1
  537. package/build/stack-utils.test.js.map +0 -1
  538. package/build/types.d.ts +0 -142
  539. package/build/types.js +0 -2
  540. package/build/types.js.map +0 -1
  541. package/docs/decisions/2026-06-02-monorepo-split-evaluation.md +0 -80
  542. package/docs/handoffs/2026-06-08-dx-round2-declines.md +0 -45
  543. package/docs/handoffs/ajsc-named-type-collision.md +0 -134
  544. package/docs/handoffs/ajsc-named-type-support.md +0 -181
  545. package/docs/handoffs/shared-models-auto-resolve-response.md +0 -181
  546. package/docs/npm-workspaces-migration-plan.md +0 -611
  547. package/docs/superpowers/plans/2026-04-24-doc-registry-simplification.md +0 -886
  548. package/docs/superpowers/plans/2026-04-24-kotlin-codegen-target.md +0 -1265
  549. package/docs/superpowers/plans/2026-04-25-ajsc-v7-kotlin-polish.md +0 -1993
  550. package/docs/superpowers/plans/2026-04-29-safe-result-api.md +0 -2293
  551. package/docs/superpowers/plans/2026-05-07-astro-adapter.md +0 -1391
  552. package/docs/superpowers/plans/2026-05-08-create-http.md +0 -3355
  553. package/docs/superpowers/plans/2026-05-08-hono-app-builder-convergence.md +0 -3365
  554. package/docs/superpowers/plans/2026-06-05-dx-feedback-round.md +0 -1292
  555. package/docs/superpowers/plans/2026-06-06-shared-models-convention-and-diagnostics.md +0 -659
  556. package/docs/superpowers/plans/2026-06-08-codegen-dx-surfacing.md +0 -428
  557. package/docs/superpowers/specs/2026-04-24-kotlin-swift-codegen-design.md +0 -401
  558. package/docs/superpowers/specs/2026-04-25-ajsc-v7-kotlin-polish-design.md +0 -314
  559. package/docs/superpowers/specs/2026-04-25-swift-codegen-design.md +0 -264
  560. package/docs/superpowers/specs/2026-04-29-safe-result-api-design.md +0 -324
  561. package/docs/superpowers/specs/2026-05-07-astro-adapter-design.md +0 -252
  562. package/docs/superpowers/specs/2026-05-08-create-http-design.md +0 -409
  563. package/docs/superpowers/specs/2026-05-08-hono-app-builder-convergence-design.md +0 -411
  564. package/docs/superpowers/specs/2026-06-05-dx-feedback-round-design.md +0 -285
  565. package/docs/superpowers/specs/2026-06-08-dx-feedback-round-2-design.md +0 -376
  566. package/src/create-http-stream.ts +0 -191
  567. package/src/create-http.ts +0 -210
  568. package/src/create-stream.ts +0 -228
  569. package/src/create.ts +0 -172
  570. package/src/implementations/http/README.md +0 -390
  571. package/src/implementations/http/error-dispatch.test.ts +0 -283
  572. package/src/implementations/http/error-dispatch.ts +0 -176
  573. package/src/implementations/http/hono/handlers/http-stream.ts +0 -152
  574. package/src/implementations/http/hono/handlers/http.ts +0 -145
  575. package/src/implementations/http/hono/handlers/rpc.ts +0 -54
  576. package/src/implementations/http/hono/path.test.ts +0 -96
  577. package/src/index.ts +0 -101
  578. package/src/schema/extract-json-schema.test.ts +0 -25
  579. package/src/schema/extract-json-schema.ts +0 -15
  580. package/src/schema/parser.test.ts +0 -182
  581. package/src/schema/parser.ts +0 -265
  582. package/src/schema/resolve-schema-lib.test.ts +0 -19
  583. package/src/schema/resolve-schema-lib.ts +0 -29
  584. package/src/schema/types.ts +0 -20
  585. package/src/types.ts +0 -133
  586. /package/build/{implementations/http → adapters}/astro/astro-context.d.ts +0 -0
  587. /package/build/{implementations/http → adapters}/astro/astro-context.js +0 -0
  588. /package/build/{implementations/http → adapters}/astro/create-handler.d.ts +0 -0
  589. /package/build/{implementations/http → adapters}/astro/create-handler.js +0 -0
  590. /package/build/{implementations/http → adapters}/astro/index.d.ts +0 -0
  591. /package/build/{implementations/http → adapters}/astro/index.js +0 -0
  592. /package/build/{implementations/http → adapters}/astro/index.test.d.ts +0 -0
  593. /package/build/{implementations/http → adapters}/astro/rewrite-request.d.ts +0 -0
  594. /package/build/{implementations/http → adapters}/astro/rewrite-request.js +0 -0
  595. /package/build/{create-http-stream.test.d.ts → adapters/hono/envelope-parity.test.d.ts} +0 -0
  596. /package/build/{implementations/http → adapters}/hono/handlers/http-stream.test.d.ts +0 -0
  597. /package/build/{implementations/http → adapters}/hono/handlers/http.test.d.ts +0 -0
  598. /package/build/{implementations/http → adapters}/hono/handlers/rpc.test.d.ts +0 -0
  599. /package/build/{implementations/http → adapters}/hono/handlers/stream.test.d.ts +0 -0
  600. /package/build/{implementations/http → adapters}/hono/index.test.d.ts +0 -0
  601. /package/build/{implementations/http → adapters/hono}/on-request-error.test.d.ts +0 -0
  602. /package/build/{implementations/http → adapters/hono}/route-errors.test.d.ts +0 -0
  603. /package/build/{create-http.test.d.ts → client/freeze.test.d.ts} +0 -0
  604. /package/build/{create-stream.test.d.ts → codegen/goldens.test.d.ts} +0 -0
  605. /package/build/{create.test.d.ts → core/create-http-stream.test.d.ts} +0 -0
  606. /package/build/{doc-envelope.test.d.ts → core/create-http.test.d.ts} +0 -0
  607. /package/build/{errors.test.d.ts → core/create-stream.test.d.ts} +0 -0
  608. /package/build/{implementations/http/doc-registry.test.d.ts → core/create.test.d.ts} +0 -0
  609. /package/build/{implementations/http/error-dispatch.test.d.ts → core/definition-site.test.d.ts} +0 -0
  610. /package/build/{implementations/http/error-taxonomy.test.d.ts → core/errors.test.d.ts} +0 -0
  611. /package/build/{errors.test.js → core/errors.test.js} +0 -0
  612. /package/build/{implementations/http/hono/path.test.d.ts → core/factory-options.test.d.ts} +0 -0
  613. /package/build/{migration.test.d.ts → core/migration.test.d.ts} +0 -0
  614. /package/build/{index.test.d.ts → core/procedures.test.d.ts} +0 -0
  615. /package/build/{implementations/http/hono → core}/types.js +0 -0
  616. /package/build/schema/{extract-json-schema.test.d.ts → adapter.test.d.ts} +0 -0
  617. /package/build/schema/{parser.test.d.ts → compile.test.d.ts} +0 -0
  618. /package/build/schema/{resolve-schema-lib.test.d.ts → typebox.test.d.ts} +0 -0
  619. /package/build/{stack-utils.test.d.ts → server/context.test.d.ts} +0 -0
  620. /package/build/{doc-envelope.js → server/doc-envelope.js} +0 -0
  621. /package/build/{doc-envelope.test.js → server/doc-envelope.test.js} +0 -0
  622. /package/build/{implementations → server}/types.js +0 -0
  623. /package/src/{implementations/http → adapters}/astro/README.md +0 -0
  624. /package/src/{implementations/http → adapters}/astro/astro-context.ts +0 -0
  625. /package/src/{implementations/http → adapters}/astro/create-handler.ts +0 -0
  626. /package/src/{implementations/http → adapters}/astro/index.ts +0 -0
  627. /package/src/{implementations/http → adapters}/astro/rewrite-request.ts +0 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Shared per-route emission contracts for the TS scope emitter.
3
+ *
4
+ * `EmitRouteContext` is threaded through every route emitter and formatting
5
+ * helper; `RouteChunks` is what each per-kind emitter returns to
6
+ * `emitScopeFile` for final assembly.
7
+ */
8
+ import type { AjscOptions } from '../emit-types.js';
9
+ export interface RouteChunks {
10
+ typeDeclarations: string[];
11
+ callable: string;
12
+ hasStream: boolean;
13
+ /** True when this route emitted an `Errors` type (drives the `_errors` import at the top of the scope file). */
14
+ hasErrors: boolean;
15
+ }
16
+ export interface EmitRouteContext {
17
+ ajsc?: AjscOptions;
18
+ namespaceTypes: boolean;
19
+ scopePascal: string;
20
+ serviceName: string;
21
+ errorKeys?: Set<string>;
22
+ /** `$id` → shared model type name; drives the substitute wrappers. */
23
+ idToModelName?: Map<string, string>;
24
+ /**
25
+ * Accumulates the model names ajsc reported as `referencedNamedTypes` across
26
+ * every route in the scope. Drives the `import type { … } from './_models'`
27
+ * line assembled in `emitScopeFile`.
28
+ */
29
+ referencedModels: Set<string>;
30
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/codegen/emit/context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ /** Indent each line of a multi-line string by a given prefix. */
2
+ export declare function indent(text: string, prefix: string): string;
3
+ /**
4
+ * Tracks extracted declarations emitted into a single namespace, guarding
5
+ * against duplicate identifiers (defense-in-depth on top of the rename pass).
6
+ *
7
+ * - Exact-string duplicates (the same sub-type extracted from two schemas) are
8
+ * silently skipped.
9
+ * - A same-name-but-different-body declaration is a genuine collision the
10
+ * rename pass failed to resolve; emitting it would produce an opaque
11
+ * `TS2300: Duplicate identifier` in the consumer's build. We fail fast at
12
+ * codegen with a message that names the offending identifier instead.
13
+ *
14
+ * Returns the indented declaration line to push, or `null` when it should be
15
+ * skipped (exact duplicate).
16
+ */
17
+ export declare class DeclarationCollector {
18
+ private readonly context;
19
+ private readonly seenStrings;
20
+ private readonly seenNames;
21
+ constructor(context: string);
22
+ /** Returns the indented line to emit, or `null` for an exact duplicate. */
23
+ accept(decl: string, indentPrefix: string): string | null;
24
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Declaration bookkeeping for namespace-mode emission: the `indent` text
3
+ * helper and the `DeclarationCollector` duplicate-identifier guard.
4
+ */
5
+ import { extractedDeclName } from '../emit-types.js';
6
+ /** Indent each line of a multi-line string by a given prefix. */
7
+ export function indent(text, prefix) {
8
+ return text.split('\n').map((line) => (line ? prefix + line : line)).join('\n');
9
+ }
10
+ /**
11
+ * Tracks extracted declarations emitted into a single namespace, guarding
12
+ * against duplicate identifiers (defense-in-depth on top of the rename pass).
13
+ *
14
+ * - Exact-string duplicates (the same sub-type extracted from two schemas) are
15
+ * silently skipped.
16
+ * - A same-name-but-different-body declaration is a genuine collision the
17
+ * rename pass failed to resolve; emitting it would produce an opaque
18
+ * `TS2300: Duplicate identifier` in the consumer's build. We fail fast at
19
+ * codegen with a message that names the offending identifier instead.
20
+ *
21
+ * Returns the indented declaration line to push, or `null` when it should be
22
+ * skipped (exact duplicate).
23
+ */
24
+ export class DeclarationCollector {
25
+ context;
26
+ seenStrings = new Set();
27
+ seenNames = new Map();
28
+ constructor(context) {
29
+ this.context = context;
30
+ }
31
+ /** Returns the indented line to emit, or `null` for an exact duplicate. */
32
+ accept(decl, indentPrefix) {
33
+ if (this.seenStrings.has(decl))
34
+ return null;
35
+ const name = extractedDeclName(decl);
36
+ if (name != null) {
37
+ if (this.seenNames.has(name)) {
38
+ throw new Error(`[ts-procedures-codegen] duplicate identifier '${name}' while emitting ${this.context}. ` +
39
+ `An extracted sub-type collided with another of the same name and could not be renamed. ` +
40
+ `This is a codegen bug — please report it with the offending schema.`);
41
+ }
42
+ this.seenNames.set(name, decl);
43
+ }
44
+ this.seenStrings.add(decl);
45
+ return indent(decl, indentPrefix);
46
+ }
47
+ }
48
+ //# sourceMappingURL=declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../../src/codegen/emit/declarations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,iEAAiE;AACjE,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,MAAc;IACjD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACjF,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,oBAAoB;IAIF;IAHZ,WAAW,GAAG,IAAI,GAAG,EAAU,CAAA;IAC/B,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAA;IAEtD,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEhD,2EAA2E;IAC3E,MAAM,CAAC,IAAY,EAAE,YAAoB;QACvC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAA;QAC3C,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;QACpC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACb,iDAAiD,IAAI,oBAAoB,IAAI,CAAC,OAAO,IAAI;oBACvF,yFAAyF;oBACzF,qEAAqE,CACxE,CAAA;YACH,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC1B,OAAO,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;IACnC,CAAC;CACF"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Schema → TypeScript conversion layer for the scope emitter: shared-model
3
+ * conversion wrappers (`convertExtracted` / `convertBody`), the
4
+ * `assertNoModelNameCollision` guard, and the `formatTypes` /
5
+ * `formatSubNamespace` declaration builders used by the per-kind route
6
+ * emitters.
7
+ */
8
+ import { type ExtractedTypeOutput } from '../emit-types.js';
9
+ import type { EmitRouteContext } from './context.js';
10
+ /**
11
+ * Drop-in replacement for `jsonSchemaToExtractedTypes` that, when shared models
12
+ * are in play, rewrites every `$id` subschema into an `x-named-type` node before
13
+ * ajsc. ajsc emits each as a bare verbatim reference and reports it via
14
+ * `referencedNamedTypes`; this wrapper folds those names into
15
+ * `ctx.referencedModels` so `emitScopeFile` can build the `_models` import.
16
+ *
17
+ * Short-circuits to the exact original call when no models are configured, so
18
+ * output is byte-identical for envelopes without `$id` models.
19
+ */
20
+ export declare function convertExtracted(schema: Record<string, unknown>, ctx: EmitRouteContext): Promise<ExtractedTypeOutput | undefined>;
21
+ /**
22
+ * Drop-in replacement for `jsonSchemaToTypeBody` mirroring {@link convertExtracted}
23
+ * for the bare-body (flat / merged-alias) conversion path.
24
+ */
25
+ export declare function convertBody(schema: Record<string, unknown>, ctx: EmitRouteContext): Promise<string | undefined>;
26
+ export interface NamedType {
27
+ /** Short name for namespace mode (e.g., 'Params', 'Response'). */
28
+ shortName: string;
29
+ /** Schema to convert, or undefined if not present. */
30
+ schema: Record<string, unknown> | undefined;
31
+ }
32
+ export interface FormattedTypes {
33
+ /** Type declarations to add to the file. */
34
+ declarations: string[];
35
+ /** Map of shortName → qualified type reference (for callables). */
36
+ refs: Record<string, string>;
37
+ }
38
+ /**
39
+ * Converts multiple schemas into type declarations and type references.
40
+ * In flat mode: `export type ${routePascal}${shortName} = <body>`
41
+ * In namespace mode: extracted sub-types + named types inside `export namespace ${routePascal} { ... }`
42
+ *
43
+ * `extraReserved` lets the caller pre-reserve identifier names that the route
44
+ * will inject AFTER formatTypes returns (e.g. emitApiRoute's structured
45
+ * `Params`). Without this, an ajsc-extracted sub-type could shadow the
46
+ * injected one and produce duplicate `export type Params` declarations.
47
+ */
48
+ export declare function formatTypes(routePascal: string, types: NamedType[], ctx: EmitRouteContext, extraReserved?: ReadonlySet<string>): Promise<FormattedTypes>;
49
+ /**
50
+ * Formats a group of named types into a nested sub-namespace block (for namespace mode).
51
+ * Returns an array of lines to be inserted into the parent namespace, and a map of
52
+ * shortName → qualified type reference for use in callables.
53
+ *
54
+ * In flat mode, returns declarations like `export type ${prefix}${shortName} = ...`
55
+ * and refs like `${prefix}${shortName}`.
56
+ */
57
+ export declare function formatSubNamespace(routePascal: string, nsName: string, // e.g. 'Req' or 'Response'
58
+ types: NamedType[], ctx: EmitRouteContext, taken: Set<string>): Promise<{
59
+ nsBlock: string | null;
60
+ refs: Record<string, string>;
61
+ }>;
@@ -0,0 +1,188 @@
1
+ /**
2
+ * Schema → TypeScript conversion layer for the scope emitter: shared-model
3
+ * conversion wrappers (`convertExtracted` / `convertBody`), the
4
+ * `assertNoModelNameCollision` guard, and the `formatTypes` /
5
+ * `formatSubNamespace` declaration builders used by the per-kind route
6
+ * emitters.
7
+ */
8
+ import { jsonSchemaToTypeBody, jsonSchemaToTypeBodyWithRefs, jsonSchemaToExtractedTypes, renameExtractedTypes, } from '../emit-types.js';
9
+ import { substituteModelRefs } from '../model-refs.js';
10
+ import { DeclarationCollector } from './declarations.js';
11
+ // ---------------------------------------------------------------------------
12
+ // Shared-model conversion wrappers (ajsc x-named-type)
13
+ // ---------------------------------------------------------------------------
14
+ /**
15
+ * Drop-in replacement for `jsonSchemaToExtractedTypes` that, when shared models
16
+ * are in play, rewrites every `$id` subschema into an `x-named-type` node before
17
+ * ajsc. ajsc emits each as a bare verbatim reference and reports it via
18
+ * `referencedNamedTypes`; this wrapper folds those names into
19
+ * `ctx.referencedModels` so `emitScopeFile` can build the `_models` import.
20
+ *
21
+ * Short-circuits to the exact original call when no models are configured, so
22
+ * output is byte-identical for envelopes without `$id` models.
23
+ */
24
+ export async function convertExtracted(schema, ctx) {
25
+ if (ctx.idToModelName == null || ctx.idToModelName.size === 0) {
26
+ return jsonSchemaToExtractedTypes(schema, ctx.ajsc);
27
+ }
28
+ const { schema: sub } = substituteModelRefs(schema, ctx.idToModelName);
29
+ const result = await jsonSchemaToExtractedTypes(sub, ctx.ajsc);
30
+ if (result != null) {
31
+ assertNoModelNameCollision(result);
32
+ for (const name of result.referencedNamedTypes)
33
+ ctx.referencedModels.add(name);
34
+ }
35
+ return result;
36
+ }
37
+ /**
38
+ * Guards ajsc's documented `x-named-type` collision caveat. If a shared-model
39
+ * name (referenced via `x-named-type`) also matches the name ajsc derives for a
40
+ * sibling *structural* sub-type, ajsc silently MERGES them — the model reference
41
+ * resolves to the unrelated structural type. The merge happens inside ajsc's own
42
+ * pass, so it can't be disentangled afterward (a post-hoc rename would rewrite
43
+ * the model reference too, producing a silently-wrong type). Instead we detect
44
+ * the collision — a name present in BOTH `referencedNamedTypes` AND
45
+ * `extractedTypeNames` (ajsc's own documented collision signal) — and fail fast
46
+ * with an actionable message. The throw is wrapped with the route's name/scope
47
+ * by `emitScopeFile`.
48
+ */
49
+ function assertNoModelNameCollision(result) {
50
+ if (result.referencedNamedTypes.length === 0 || result.extractedTypeNames.length === 0)
51
+ return;
52
+ const extracted = new Set(result.extractedTypeNames);
53
+ const collisions = result.referencedNamedTypes.filter((name) => extracted.has(name));
54
+ if (collisions.length === 0)
55
+ return;
56
+ const names = collisions.map((n) => `'${n}'`).join(', ');
57
+ throw new Error(`shared model ${names} collides with a generated type of the same name derived ` +
58
+ `from a property in this route's schema — ajsc would silently merge them. Rename ` +
59
+ `the colliding property, or change the model's $id/title so the generated names differ`);
60
+ }
61
+ /**
62
+ * Drop-in replacement for `jsonSchemaToTypeBody` mirroring {@link convertExtracted}
63
+ * for the bare-body (flat / merged-alias) conversion path.
64
+ */
65
+ export async function convertBody(schema, ctx) {
66
+ if (ctx.idToModelName == null || ctx.idToModelName.size === 0) {
67
+ return jsonSchemaToTypeBody(schema, ctx.ajsc);
68
+ }
69
+ const { schema: sub } = substituteModelRefs(schema, ctx.idToModelName);
70
+ const result = await jsonSchemaToTypeBodyWithRefs(sub, ctx.ajsc);
71
+ if (result == null)
72
+ return undefined;
73
+ for (const name of result.referencedNamedTypes)
74
+ ctx.referencedModels.add(name);
75
+ return result.body;
76
+ }
77
+ /**
78
+ * Converts multiple schemas into type declarations and type references.
79
+ * In flat mode: `export type ${routePascal}${shortName} = <body>`
80
+ * In namespace mode: extracted sub-types + named types inside `export namespace ${routePascal} { ... }`
81
+ *
82
+ * `extraReserved` lets the caller pre-reserve identifier names that the route
83
+ * will inject AFTER formatTypes returns (e.g. emitApiRoute's structured
84
+ * `Params`). Without this, an ajsc-extracted sub-type could shadow the
85
+ * injected one and produce duplicate `export type Params` declarations.
86
+ */
87
+ export async function formatTypes(routePascal, types, ctx, extraReserved) {
88
+ const declarations = [];
89
+ const refs = {};
90
+ if (ctx.namespaceTypes) {
91
+ const nsLines = [];
92
+ const collector = new DeclarationCollector(`namespace ${routePascal}`);
93
+ // Pre-reserve every name the route will declare itself (each shortName +
94
+ // any caller-supplied extras). Extracted sub-types whose names land in
95
+ // this set get renamed (e.g. `Params` → `Params_`) by renameExtractedTypes,
96
+ // and the body string is patched in lockstep so the reference still
97
+ // resolves. The set is mutated as we go, so a sub-type renamed in schema A
98
+ // is also reserved against schema B.
99
+ const taken = new Set(extraReserved ?? []);
100
+ for (const t of types) {
101
+ if (t.schema != null)
102
+ taken.add(t.shortName);
103
+ }
104
+ for (const { shortName, schema } of types) {
105
+ if (schema == null)
106
+ continue;
107
+ const rawResult = await convertExtracted(schema, ctx);
108
+ if (rawResult == null)
109
+ continue;
110
+ const result = renameExtractedTypes(rawResult, taken);
111
+ // Collect extracted sub-types (dedupe exact dups; throw on real collisions)
112
+ for (const decl of result.declarations) {
113
+ const line = collector.accept(decl, ' ');
114
+ if (line != null)
115
+ nsLines.push(line);
116
+ }
117
+ nsLines.push(` export type ${shortName} = ${result.body}`);
118
+ refs[shortName] = `${ctx.scopePascal}.${routePascal}.${shortName}`;
119
+ }
120
+ if (nsLines.length > 0) {
121
+ declarations.push(` export namespace ${routePascal} {\n${nsLines.join('\n')}\n }`);
122
+ }
123
+ }
124
+ else {
125
+ for (const { shortName, schema } of types) {
126
+ if (schema == null)
127
+ continue;
128
+ const flatName = `${routePascal}${shortName}`;
129
+ const body = await convertBody(schema, ctx);
130
+ if (body == null)
131
+ continue;
132
+ declarations.push(`export type ${flatName} = ${body}`);
133
+ refs[shortName] = flatName;
134
+ }
135
+ }
136
+ return { declarations, refs };
137
+ }
138
+ /**
139
+ * Formats a group of named types into a nested sub-namespace block (for namespace mode).
140
+ * Returns an array of lines to be inserted into the parent namespace, and a map of
141
+ * shortName → qualified type reference for use in callables.
142
+ *
143
+ * In flat mode, returns declarations like `export type ${prefix}${shortName} = ...`
144
+ * and refs like `${prefix}${shortName}`.
145
+ */
146
+ export async function formatSubNamespace(routePascal, nsName, // e.g. 'Req' or 'Response'
147
+ types, ctx, taken) {
148
+ const refs = {};
149
+ const nsLines = [];
150
+ const collector = new DeclarationCollector(`namespace ${routePascal}.${nsName}`);
151
+ // Pre-reserve short names to prevent sub-type extraction collision
152
+ for (const t of types) {
153
+ if (t.schema != null)
154
+ taken.add(t.shortName);
155
+ }
156
+ for (const { shortName, schema } of types) {
157
+ if (schema == null)
158
+ continue;
159
+ if (ctx.namespaceTypes) {
160
+ const rawResult = await convertExtracted(schema, ctx);
161
+ if (rawResult == null)
162
+ continue;
163
+ const result = renameExtractedTypes(rawResult, taken);
164
+ for (const decl of result.declarations) {
165
+ const line = collector.accept(decl, ' ');
166
+ if (line != null)
167
+ nsLines.push(line);
168
+ }
169
+ nsLines.push(` export type ${shortName} = ${result.body}`);
170
+ refs[shortName] = `${ctx.scopePascal}.${routePascal}.${nsName}.${shortName}`;
171
+ }
172
+ else {
173
+ const flatName = `${routePascal}${nsName}${shortName}`;
174
+ const body = await convertBody(schema, ctx);
175
+ if (body == null)
176
+ continue;
177
+ refs[shortName] = flatName;
178
+ }
179
+ }
180
+ if (ctx.namespaceTypes) {
181
+ if (nsLines.length === 0)
182
+ return { nsBlock: null, refs };
183
+ const nsBlock = ` export namespace ${nsName} {\n${nsLines.join('\n')}\n }`;
184
+ return { nsBlock, refs };
185
+ }
186
+ return { nsBlock: null, refs };
187
+ }
188
+ //# sourceMappingURL=format-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-types.js","sourceRoot":"","sources":["../../../src/codegen/emit/format-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,GAErB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAExD,8EAA8E;AAC9E,uDAAuD;AACvD,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA+B,EAC/B,GAAqB;IAErB,IAAI,GAAG,CAAC,aAAa,IAAI,IAAI,IAAI,GAAG,CAAC,aAA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I,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;gBAC7C,IAAI,IAAI,IAAI,IAAI;oBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACtC,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,qBAAqB,SAAS,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;YAC/D,IAAI,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,CAAC,WAAW,IAAI,WAAW,IAAI,MAAM,IAAI,SAAS,EAAE,CAAA;QAC9E,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,EAAE,CAAA;YACtD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;YAC3C,IAAI,IAAI,IAAI,IAAI;gBAAE,SAAQ;YAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QACxD,MAAM,OAAO,GAAG,wBAAwB,MAAM,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAA;QAChF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AAChC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Emitter for `kind: 'http-stream'` routes — structured multi-channel `Req`
3
+ * types plus `Yield` / `ReturnType` and a `client.stream(...)` callable.
4
+ */
5
+ import type { HttpStreamRouteDoc } from '../../server/types.js';
6
+ import type { EmitRouteContext, RouteChunks } from './context.js';
7
+ export declare function emitHttpStreamRoute(route: HttpStreamRouteDoc, ctx: EmitRouteContext): Promise<RouteChunks>;
@@ -0,0 +1,138 @@
1
+ import { renameExtractedTypes } from '../emit-types.js';
2
+ import { toPascalCase } from '../naming.js';
3
+ import { DeclarationCollector } from './declarations.js';
4
+ import { convertBody, convertExtracted, formatSubNamespace } from './format-types.js';
5
+ import { buildCallableJsDoc, buildErrorUnion, injectRouteErrors } from './route-shared.js';
6
+ export async function emitHttpStreamRoute(route, ctx) {
7
+ const pascal = toPascalCase(route.name);
8
+ const req = route.jsonSchema.req ?? {};
9
+ const res = route.jsonSchema.res ?? {};
10
+ // Request channels
11
+ const reqChannelKeys = ['pathParams', 'query', 'body', 'headers'];
12
+ const reqTypes = [];
13
+ const presentChannels = [];
14
+ for (const channel of reqChannelKeys) {
15
+ const schema = req[channel];
16
+ if (schema != null) {
17
+ reqTypes.push({ shortName: toPascalCase(channel), schema });
18
+ presentChannels.push(channel);
19
+ }
20
+ }
21
+ // Yield + ReturnType
22
+ const yieldSchema = route.jsonSchema.yield;
23
+ const returnSchema = route.jsonSchema.returnType;
24
+ const resHeadersSchema = res.headers;
25
+ const scopeStr = route.scope ?? 'default';
26
+ const declarations = [];
27
+ let paramsTypeName = 'void';
28
+ let yieldTypeName = 'unknown';
29
+ let returnTypeName = 'void';
30
+ const taken = new Set(['Req', 'Response', 'Yield', 'ReturnType']);
31
+ if (ctx.namespaceTypes) {
32
+ const nsLines = [];
33
+ // Req sub-namespace
34
+ const { nsBlock: reqBlock, refs: reqRefs } = await formatSubNamespace(pascal, 'Req', reqTypes, ctx, taken);
35
+ if (reqBlock) {
36
+ nsLines.push(reqBlock);
37
+ // Merged type alias so Req can be used as a generic type arg (same pattern as emitApiRoute)
38
+ const reqFields = presentChannels
39
+ .map((ch) => `${ch}: Req.${toPascalCase(ch)}`)
40
+ .join('; ');
41
+ nsLines.push(` export type Req = { ${reqFields} }`);
42
+ }
43
+ // Response sub-namespace (headers only for http-stream)
44
+ const resTypes = [{ shortName: 'Headers', schema: resHeadersSchema }];
45
+ const { nsBlock: resBlock } = await formatSubNamespace(pascal, 'Response', resTypes, ctx, taken);
46
+ if (resBlock)
47
+ nsLines.push(resBlock);
48
+ // Yield and ReturnType directly in the route namespace
49
+ const directTypes = [
50
+ { shortName: 'Yield', schema: yieldSchema },
51
+ { shortName: 'ReturnType', schema: returnSchema },
52
+ ];
53
+ const collector = new DeclarationCollector(`namespace ${pascal}`);
54
+ for (const { shortName, schema } of directTypes) {
55
+ if (schema == null)
56
+ continue;
57
+ const rawResult = await convertExtracted(schema, ctx);
58
+ if (rawResult == null)
59
+ continue;
60
+ const result = renameExtractedTypes(rawResult, taken);
61
+ for (const decl of result.declarations) {
62
+ const line = collector.accept(decl, ' ');
63
+ if (line != null)
64
+ nsLines.push(line);
65
+ }
66
+ nsLines.push(` export type ${shortName} = ${result.body}`);
67
+ }
68
+ if (nsLines.length > 0) {
69
+ declarations.push(` export namespace ${pascal} {\n${nsLines.join('\n')}\n }`);
70
+ }
71
+ if (presentChannels.length > 0) {
72
+ paramsTypeName = `${ctx.scopePascal}.${pascal}.Req`;
73
+ }
74
+ if (yieldSchema != null)
75
+ yieldTypeName = `${ctx.scopePascal}.${pascal}.Yield`;
76
+ if (returnSchema != null)
77
+ returnTypeName = `${ctx.scopePascal}.${pascal}.ReturnType`;
78
+ }
79
+ else {
80
+ // Flat mode
81
+ for (const { shortName, schema } of reqTypes) {
82
+ if (schema == null)
83
+ continue;
84
+ const flatName = `${pascal}Req${shortName}`;
85
+ const body = await convertBody(schema, ctx);
86
+ if (body == null)
87
+ continue;
88
+ declarations.push(`export type ${flatName} = ${body}`);
89
+ }
90
+ if (presentChannels.length > 0) {
91
+ const structureFields = presentChannels
92
+ .map((ch) => `${ch}: ${pascal}Req${toPascalCase(ch)}`)
93
+ .join('; ');
94
+ declarations.push(`export type ${pascal}Req = { ${structureFields} }`);
95
+ paramsTypeName = `${pascal}Req`;
96
+ }
97
+ if (resHeadersSchema != null) {
98
+ const body = await convertBody(resHeadersSchema, ctx);
99
+ if (body != null)
100
+ declarations.push(`export type ${pascal}ResponseHeaders = ${body}`);
101
+ }
102
+ if (yieldSchema != null) {
103
+ const body = await convertBody(yieldSchema, ctx);
104
+ if (body != null) {
105
+ declarations.push(`export type ${pascal}Yield = ${body}`);
106
+ yieldTypeName = `${pascal}Yield`;
107
+ }
108
+ }
109
+ if (returnSchema != null) {
110
+ const body = await convertBody(returnSchema, ctx);
111
+ if (body != null) {
112
+ declarations.push(`export type ${pascal}ReturnType = ${body}`);
113
+ returnTypeName = `${pascal}ReturnType`;
114
+ }
115
+ }
116
+ }
117
+ const callable = [
118
+ buildCallableJsDoc({
119
+ methodLabel: route.method.toUpperCase(),
120
+ path: route.fullPath,
121
+ errorsRef: null,
122
+ }),
123
+ ` ${route.name}(req: ${paramsTypeName}, options?: ProcedureCallOptions): TypedStream<${yieldTypeName}, ${returnTypeName}> {`,
124
+ ` return client.stream<${yieldTypeName}, ${returnTypeName}>({`,
125
+ ` name: '${route.name}',`,
126
+ ` scope: '${scopeStr}',`,
127
+ ` path: '${route.fullPath}',`,
128
+ ` method: '${route.method}',`,
129
+ ` kind: 'http-stream',`,
130
+ ` streamMode: '${route.streamMode}',`,
131
+ ` params: req,`,
132
+ ` }, options)`,
133
+ ` },`,
134
+ ].join('\n');
135
+ const hasErrors = injectRouteErrors(declarations, pascal, buildErrorUnion(route.errors, ctx), ctx.namespaceTypes);
136
+ return { typeDeclarations: declarations, callable, hasStream: true, hasErrors };
137
+ }
138
+ //# sourceMappingURL=http-stream-route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-stream-route.js","sourceRoot":"","sources":["../../../src/codegen/emit/http-stream-route.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,WAA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F,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { EmitRouteContext } from './context.js';
2
+ /**
3
+ * Returns the PascalCase display name for a route, appending `V{version}`
4
+ * when version > 1. Version 1 produces no suffix for backward compatibility.
5
+ */
6
+ export declare function versionedPascal(name: string, version: number | undefined): string;
7
+ /**
8
+ * Builds the body of an `Errors` type union from the route's declared error
9
+ * keys. Filters to keys actually emitted in `_errors.ts` so generated code
10
+ * never references undefined types.
11
+ *
12
+ * In namespace mode the union uses qualified names (`ApiErrors.UseCaseError`);
13
+ * in flat mode it uses the bundled wildcard import alias (`_errors.UseCaseError`).
14
+ * Returns `null` when no keys remain.
15
+ */
16
+ export declare function buildErrorUnion(routeErrors: string[] | undefined, ctx: EmitRouteContext): string | null;
17
+ /**
18
+ * Injects `export type Errors = ...` into an existing route namespace block
19
+ * (namespace mode) or appends a flat `export type ${pascal}Errors = ...` in
20
+ * flat mode. Mutates the `declarations` array in place and returns whether an
21
+ * injection happened.
22
+ */
23
+ export declare function injectRouteErrors(declarations: string[], routePascal: string, errorUnion: string | null, namespaceTypes: boolean): boolean;
24
+ /**
25
+ * Builds the multi-line JSDoc comment for a route callable. Surfaces the
26
+ * second `options` argument (the per-call AbortSignal/timeout seam — DX #8) and,
27
+ * for routes that declare typed errors, points at the route's `Errors` type and
28
+ * how to narrow it on the throwing path (DX #10). Indented for placement inside
29
+ * the bind-object (4 spaces).
30
+ */
31
+ export declare function buildCallableJsDoc(opts: {
32
+ methodLabel: string;
33
+ path: string;
34
+ errorsRef: string | null;
35
+ }): string;