ts-procedures 10.1.2 → 10.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/CHANGELOG.md +33 -86
  2. package/README.md +11 -6
  3. package/agent_config/bin/postinstall.mjs +20 -89
  4. package/agent_config/bin/setup.mjs +51 -264
  5. package/agent_config/lib/install-skills.mjs +108 -0
  6. package/agent_config/{claude-code/skills → skills}/ts-procedures/anti-patterns.md +8 -0
  7. package/agent_config/{claude-code/skills → skills}/ts-procedures/api-reference.md +25 -22
  8. package/agent_config/{claude-code/skills → skills}/ts-procedures/patterns.md +24 -13
  9. package/build/adapters/hono/envelope-parity.test.js +6 -17
  10. package/build/adapters/hono/envelope-parity.test.js.map +1 -1
  11. package/build/adapters/hono/handlers/http-stream.d.ts +2 -1
  12. package/build/adapters/hono/handlers/http-stream.js +9 -2
  13. package/build/adapters/hono/handlers/http-stream.js.map +1 -1
  14. package/build/adapters/hono/handlers/http.d.ts +2 -1
  15. package/build/adapters/hono/handlers/http.js +9 -2
  16. package/build/adapters/hono/handlers/http.js.map +1 -1
  17. package/build/adapters/hono/handlers/rpc.d.ts +2 -1
  18. package/build/adapters/hono/handlers/rpc.js +9 -2
  19. package/build/adapters/hono/handlers/rpc.js.map +1 -1
  20. package/build/adapters/hono/handlers/stream.d.ts +2 -1
  21. package/build/adapters/hono/handlers/stream.js +9 -2
  22. package/build/adapters/hono/handlers/stream.js.map +1 -1
  23. package/build/adapters/hono/index.d.ts +14 -7
  24. package/build/adapters/hono/index.js +45 -5
  25. package/build/adapters/hono/index.js.map +1 -1
  26. package/build/adapters/hono/index.test.js +55 -0
  27. package/build/adapters/hono/index.test.js.map +1 -1
  28. package/build/adapters/hono/request.d.ts +7 -0
  29. package/build/adapters/hono/request.js +15 -0
  30. package/build/adapters/hono/request.js.map +1 -1
  31. package/build/adapters/hono/types.d.ts +31 -0
  32. package/build/adapters/hono/types.js.map +1 -1
  33. package/build/codegen/bin/cli.js +1 -1
  34. package/build/codegen/bin/cli.js.map +1 -1
  35. package/build/codegen/constants.js +2 -2
  36. package/build/codegen/constants.js.map +1 -1
  37. package/build/codegen/emit/api-route.js +1 -1
  38. package/build/codegen/emit/api-route.js.map +1 -1
  39. package/build/codegen/emit/scope-file.js +1 -1
  40. package/build/codegen/emit/scope-file.js.map +1 -1
  41. package/build/codegen/emit-errors.integration.test.js +2 -2
  42. package/build/codegen/emit-errors.integration.test.js.map +1 -1
  43. package/build/codegen/resolve-envelope.js +1 -1
  44. package/build/codegen/resolve-envelope.js.map +1 -1
  45. package/build/codegen/test-helpers/run-tsc.js +1 -1
  46. package/build/codegen/test-helpers/run-tsc.js.map +1 -1
  47. package/build/core/create-http-stream.d.ts +3 -14
  48. package/build/core/create-http-stream.js +4 -2
  49. package/build/core/create-http-stream.js.map +1 -1
  50. package/build/core/create-http.d.ts +2 -9
  51. package/build/core/create-http.js +3 -2
  52. package/build/core/create-http.js.map +1 -1
  53. package/build/core/create-http.test-d.js +104 -0
  54. package/build/core/create-http.test-d.js.map +1 -0
  55. package/build/core/create-stream.js +6 -2
  56. package/build/core/create-stream.js.map +1 -1
  57. package/build/core/create.js +5 -4
  58. package/build/core/create.js.map +1 -1
  59. package/build/core/create.test.js +63 -0
  60. package/build/core/create.test.js.map +1 -1
  61. package/build/core/internal.d.ts +16 -0
  62. package/build/core/internal.js +22 -0
  63. package/build/core/internal.js.map +1 -1
  64. package/build/core/procedures.d.ts +9 -16
  65. package/build/core/procedures.js +4 -0
  66. package/build/core/procedures.js.map +1 -1
  67. package/build/core/types.d.ts +85 -4
  68. package/build/errors.d.ts +33 -0
  69. package/build/errors.js +91 -0
  70. package/build/errors.js.map +1 -0
  71. package/build/errors.test.d.ts +1 -0
  72. package/build/errors.test.js +122 -0
  73. package/build/errors.test.js.map +1 -0
  74. package/build/exports.d.ts +1 -2
  75. package/build/exports.js +0 -4
  76. package/build/exports.js.map +1 -1
  77. package/build/implementations/http/doc-registry.d.ts +28 -0
  78. package/build/implementations/http/doc-registry.js +96 -0
  79. package/build/implementations/http/doc-registry.js.map +1 -0
  80. package/build/implementations/http/doc-registry.test.d.ts +1 -0
  81. package/build/implementations/http/doc-registry.test.js +516 -0
  82. package/build/implementations/http/doc-registry.test.js.map +1 -0
  83. package/build/implementations/http/error-taxonomy.d.ts +249 -0
  84. package/build/implementations/http/error-taxonomy.js +252 -0
  85. package/build/implementations/http/error-taxonomy.js.map +1 -0
  86. package/build/implementations/http/error-taxonomy.test.d.ts +1 -0
  87. package/build/implementations/http/error-taxonomy.test.js +399 -0
  88. package/build/implementations/http/error-taxonomy.test.js.map +1 -0
  89. package/build/implementations/http/express-rpc/error-taxonomy.test.d.ts +1 -0
  90. package/build/implementations/http/express-rpc/error-taxonomy.test.js +83 -0
  91. package/build/implementations/http/express-rpc/error-taxonomy.test.js.map +1 -0
  92. package/build/implementations/http/express-rpc/index.d.ts +125 -0
  93. package/build/implementations/http/express-rpc/index.js +216 -0
  94. package/build/implementations/http/express-rpc/index.js.map +1 -0
  95. package/build/implementations/http/express-rpc/index.test.d.ts +1 -0
  96. package/build/implementations/http/express-rpc/index.test.js +684 -0
  97. package/build/implementations/http/express-rpc/index.test.js.map +1 -0
  98. package/build/implementations/http/express-rpc/types.d.ts +11 -0
  99. package/build/implementations/http/express-rpc/types.js +2 -0
  100. package/build/implementations/http/express-rpc/types.js.map +1 -0
  101. package/build/implementations/http/hono-api/error-taxonomy.test.d.ts +1 -0
  102. package/build/implementations/http/hono-api/error-taxonomy.test.js +137 -0
  103. package/build/implementations/http/hono-api/error-taxonomy.test.js.map +1 -0
  104. package/build/implementations/http/hono-api/index.d.ts +151 -0
  105. package/build/implementations/http/hono-api/index.js +344 -0
  106. package/build/implementations/http/hono-api/index.js.map +1 -0
  107. package/build/implementations/http/hono-api/index.test.d.ts +1 -0
  108. package/build/implementations/http/hono-api/index.test.js +992 -0
  109. package/build/implementations/http/hono-api/index.test.js.map +1 -0
  110. package/build/implementations/http/hono-api/types.d.ts +13 -0
  111. package/build/implementations/http/hono-api/types.js +2 -0
  112. package/build/implementations/http/hono-api/types.js.map +1 -0
  113. package/build/implementations/http/hono-rpc/error-taxonomy.test.d.ts +1 -0
  114. package/build/implementations/http/hono-rpc/error-taxonomy.test.js +64 -0
  115. package/build/implementations/http/hono-rpc/error-taxonomy.test.js.map +1 -0
  116. package/build/implementations/http/hono-rpc/index.d.ts +130 -0
  117. package/build/implementations/http/hono-rpc/index.js +209 -0
  118. package/build/implementations/http/hono-rpc/index.js.map +1 -0
  119. package/build/implementations/http/hono-rpc/index.test.d.ts +1 -0
  120. package/build/implementations/http/hono-rpc/index.test.js +828 -0
  121. package/build/implementations/http/hono-rpc/index.test.js.map +1 -0
  122. package/build/implementations/http/hono-rpc/types.d.ts +11 -0
  123. package/build/implementations/http/hono-rpc/types.js +2 -0
  124. package/build/implementations/http/hono-rpc/types.js.map +1 -0
  125. package/build/implementations/http/hono-stream/error-taxonomy.test.d.ts +1 -0
  126. package/build/implementations/http/hono-stream/error-taxonomy.test.js +159 -0
  127. package/build/implementations/http/hono-stream/error-taxonomy.test.js.map +1 -0
  128. package/build/implementations/http/hono-stream/index.d.ts +171 -0
  129. package/build/implementations/http/hono-stream/index.js +415 -0
  130. package/build/implementations/http/hono-stream/index.js.map +1 -0
  131. package/build/implementations/http/hono-stream/index.test.d.ts +1 -0
  132. package/build/implementations/http/hono-stream/index.test.js +1383 -0
  133. package/build/implementations/http/hono-stream/index.test.js.map +1 -0
  134. package/build/implementations/http/hono-stream/types.d.ts +15 -0
  135. package/build/implementations/http/hono-stream/types.js +2 -0
  136. package/build/implementations/http/hono-stream/types.js.map +1 -0
  137. package/build/implementations/http/on-request-error.test.d.ts +1 -0
  138. package/build/implementations/http/on-request-error.test.js +173 -0
  139. package/build/implementations/http/on-request-error.test.js.map +1 -0
  140. package/build/implementations/http/route-errors.test.d.ts +1 -0
  141. package/build/implementations/http/route-errors.test.js +139 -0
  142. package/build/implementations/http/route-errors.test.js.map +1 -0
  143. package/build/implementations/types.d.ts +192 -0
  144. package/build/implementations/types.js +2 -0
  145. package/build/implementations/types.js.map +1 -0
  146. package/build/index.d.ts +165 -0
  147. package/build/index.js +258 -0
  148. package/build/index.js.map +1 -0
  149. package/build/index.test.d.ts +1 -0
  150. package/build/index.test.js +920 -0
  151. package/build/index.test.js.map +1 -0
  152. package/build/schema/compute-schema.js +1 -5
  153. package/build/schema/compute-schema.js.map +1 -1
  154. package/build/schema/compute-schema.test.js +0 -13
  155. package/build/schema/compute-schema.test.js.map +1 -1
  156. package/build/schema/extract-json-schema.d.ts +2 -0
  157. package/build/schema/extract-json-schema.js +12 -0
  158. package/build/schema/extract-json-schema.js.map +1 -0
  159. package/build/schema/extract-json-schema.test.d.ts +1 -0
  160. package/build/schema/extract-json-schema.test.js +23 -0
  161. package/build/schema/extract-json-schema.test.js.map +1 -0
  162. package/build/schema/parser.d.ts +28 -0
  163. package/build/schema/parser.js +170 -0
  164. package/build/schema/parser.js.map +1 -0
  165. package/build/schema/parser.test.d.ts +1 -0
  166. package/build/schema/parser.test.js +120 -0
  167. package/build/schema/parser.test.js.map +1 -0
  168. package/build/schema/resolve-schema-lib.d.ts +12 -0
  169. package/build/schema/resolve-schema-lib.js +11 -0
  170. package/build/schema/resolve-schema-lib.js.map +1 -0
  171. package/build/schema/resolve-schema-lib.test.d.ts +1 -0
  172. package/build/schema/resolve-schema-lib.test.js +17 -0
  173. package/build/schema/resolve-schema-lib.test.js.map +1 -0
  174. package/build/schema/typebox.d.ts +1 -1
  175. package/build/schema/typebox.js +2 -20
  176. package/build/schema/typebox.js.map +1 -1
  177. package/build/schema/typebox.test.js +0 -10
  178. package/build/schema/typebox.test.js.map +1 -1
  179. package/build/schema/types.d.ts +8 -0
  180. package/build/schema/types.js +2 -0
  181. package/build/schema/types.js.map +1 -0
  182. package/build/server/context.d.ts +12 -2
  183. package/build/server/context.js +49 -4
  184. package/build/server/context.js.map +1 -1
  185. package/build/server/context.test.js +32 -1
  186. package/build/server/context.test.js.map +1 -1
  187. package/build/server/doc-registry.js +0 -3
  188. package/build/server/doc-registry.js.map +1 -1
  189. package/build/server/doc-registry.test.js +0 -31
  190. package/build/server/doc-registry.test.js.map +1 -1
  191. package/build/server/index.d.ts +0 -1
  192. package/build/server/index.js +0 -1
  193. package/build/server/index.js.map +1 -1
  194. package/build/server/types.d.ts +6 -27
  195. package/build/stack-utils.d.ts +25 -0
  196. package/build/stack-utils.js +95 -0
  197. package/build/stack-utils.js.map +1 -0
  198. package/build/stack-utils.test.d.ts +1 -0
  199. package/build/stack-utils.test.js +80 -0
  200. package/build/stack-utils.test.js.map +1 -0
  201. package/docs/ai-agent-setup.md +19 -27
  202. package/docs/client-error-handling.md +1 -1
  203. package/docs/core.md +8 -0
  204. package/docs/http-integrations.md +42 -28
  205. package/package.json +8 -8
  206. package/src/adapters/astro/README.md +2 -0
  207. package/src/adapters/hono/envelope-parity.test.ts +6 -18
  208. package/src/adapters/hono/handlers/http-stream.ts +12 -3
  209. package/src/adapters/hono/handlers/http.ts +12 -3
  210. package/src/adapters/hono/handlers/rpc.ts +12 -3
  211. package/src/adapters/hono/handlers/stream.ts +12 -3
  212. package/src/adapters/hono/index.test.ts +70 -0
  213. package/src/adapters/hono/index.ts +53 -11
  214. package/src/adapters/hono/request.ts +18 -0
  215. package/src/adapters/hono/types.ts +37 -0
  216. package/src/codegen/bin/cli.ts +1 -1
  217. package/src/codegen/constants.ts +2 -2
  218. package/src/codegen/emit/api-route.ts +1 -1
  219. package/src/codegen/emit/scope-file.ts +1 -2
  220. package/src/codegen/emit-errors.integration.test.ts +2 -2
  221. package/src/codegen/resolve-envelope.ts +1 -1
  222. package/src/codegen/test-helpers/run-tsc.ts +0 -1
  223. package/src/core/create-http-stream.ts +20 -13
  224. package/src/core/create-http.test-d.ts +154 -0
  225. package/src/core/create-http.ts +19 -8
  226. package/src/core/create-stream.ts +12 -4
  227. package/src/core/create.test.ts +74 -0
  228. package/src/core/create.ts +10 -5
  229. package/src/core/internal.ts +35 -0
  230. package/src/core/procedures.ts +4 -0
  231. package/src/core/types.ts +99 -4
  232. package/src/exports.ts +6 -4
  233. package/src/schema/compute-schema.test.ts +0 -16
  234. package/src/schema/compute-schema.ts +1 -5
  235. package/src/schema/typebox.test.ts +0 -12
  236. package/src/schema/typebox.ts +2 -21
  237. package/src/server/context.test.ts +39 -1
  238. package/src/server/context.ts +54 -4
  239. package/src/server/doc-registry.test.ts +0 -34
  240. package/src/server/doc-registry.ts +0 -3
  241. package/src/server/index.ts +0 -1
  242. package/src/server/types.ts +8 -27
  243. package/agent_config/claude-code/.claude-plugin/plugin.json +0 -5
  244. package/agent_config/claude-code/agents/ts-procedures-architect.md +0 -138
  245. package/agent_config/copilot/copilot-instructions.md +0 -521
  246. package/agent_config/cursor/cursorrules +0 -521
  247. package/agent_config/lib/install-claude.mjs +0 -57
  248. package/build/schema/strip-internal-keywords.d.ts +0 -18
  249. package/build/schema/strip-internal-keywords.js +0 -33
  250. package/build/schema/strip-internal-keywords.js.map +0 -1
  251. package/build/schema/strip-internal-keywords.test.js +0 -38
  252. package/build/schema/strip-internal-keywords.test.js.map +0 -1
  253. package/build/server/spec-version.d.ts +0 -24
  254. package/build/server/spec-version.js +0 -26
  255. package/build/server/spec-version.js.map +0 -1
  256. package/build/version.d.ts +0 -9
  257. package/build/version.js +0 -11
  258. package/build/version.js.map +0 -1
  259. package/docs/doc-envelope-spec-v1.md +0 -296
  260. package/docs/doc-envelope-v1.schema.json +0 -253
  261. package/src/schema/strip-internal-keywords.test.ts +0 -43
  262. package/src/schema/strip-internal-keywords.ts +0 -36
  263. package/src/server/spec-version.ts +0 -27
  264. package/src/version.ts +0 -11
  265. /package/agent_config/{claude-code/skills → skills}/ts-procedures/SKILL.md +0 -0
  266. /package/agent_config/{claude-code/skills → skills}/ts-procedures/checklist.md +0 -0
  267. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/astro-catchall.md +0 -0
  268. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/client.md +0 -0
  269. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/hono.md +0 -0
  270. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/procedure.md +0 -0
  271. /package/agent_config/{claude-code/skills → skills}/ts-procedures/templates/stream-procedure.md +0 -0
  272. /package/build/{schema/strip-internal-keywords.test.d.ts → core/create-http.test-d.d.ts} +0 -0
@@ -77,6 +77,28 @@ export function appendDefinitionSite(error, name, definitionInfo) {
77
77
  export function combineSignals(incoming, own) {
78
78
  return incoming ? AbortSignal.any([incoming, own]) : own;
79
79
  }
80
+ /**
81
+ * Apply factory-defined middlewares around a core invocation.
82
+ * Middlewares run from first to last; each sees the (possibly augmented) ctx + input.
83
+ * Supports both unary results and async generators (for streams).
84
+ */
85
+ export function runWithMiddlewares(middlewares, ctx, input, core) {
86
+ if (!middlewares.length) {
87
+ return core(ctx, input);
88
+ }
89
+ // Build the chain from the inside out
90
+ let current = core;
91
+ for (let i = middlewares.length - 1; i >= 0; i--) {
92
+ const mw = middlewares[i];
93
+ const previous = current;
94
+ current = (c, i) => mw({
95
+ ctx: c,
96
+ input: i,
97
+ next: (o = {}) => previous(o.ctx ?? c, o.input ?? i),
98
+ });
99
+ }
100
+ return current(ctx, input);
101
+ }
80
102
  /**
81
103
  * Drives a user stream iterator with the framework guarantees shared by
82
104
  * CreateStream and CreateHttpStream:
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/core/internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAoBjI,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,CAAU,CAAA;AAE9E,uFAAuF;AACvF,MAAM,UAAU,kBAAkB,CAChC,WAAsC,EACtC,aAAqB,EACrB,MAA+B,EAC/B,cAA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AAM,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;YAC1B,IAAI,cAAc,IAAI,aAAa,EAAE,CAAC;gBACpC,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;gBACvC,IAAI,MAAM,EAAE,CAAC;oBACX,MAAM,IAAI,6BAA6B,CACrC,IAAI,EACJ,8BAA8B,IAAI,EAAE,EACpC,MAAM,EACN,cAAc,CACf,CAAA;gBACH,CAAC;YACH,CAAC;YACD,MAAM,KAAK,CAAA;YACX,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAA;QACpC,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAA;IACrB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,cAAc,CAAC,CAAA;QACjD,MAAM,KAAK,CAAA;IACb,CAAC;YAAS,CAAC;QACT,0EAA0E;QAC1E,0EAA0E;QAC1E,aAAa;QACb,IAAI,CAAC;YACH,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAA;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,yDAAyD;QAC3D,CAAC;QACD,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAC3C,CAAC;AACH,CAAC"}
@@ -10,6 +10,7 @@ import type { AnyProcedureRegistration, ProceduresOptions, TNoContextProvided }
10
10
  * schema: { adapters: [myZodAdapter] }, // TypeBox is built in
11
11
  * http: { pathPrefix: '/v1', scope: 'billing' }, // CreateHttp* defaults
12
12
  * onCreate: (procedure) => log(procedure.kind, procedure.name),
13
+ * // middleware: [ myFactoryGuard ], // runs with final ctx + input for every proc
13
14
  * })
14
15
  * ```
15
16
  *
@@ -18,6 +19,8 @@ import type { AnyProcedureRegistration, ProceduresOptions, TNoContextProvided }
18
19
  * - `TExtendedConfig` — extra per-procedure config fields (e.g. `scope`,
19
20
  * `version`, auth flags) carried through to registrations, `info`, and
20
21
  * `onCreate`.
22
+ * - `middleware` — factory-level middleware with access to the final ctx + input
23
+ * ("parse the incoming call") for authz, enrichment, etc. See `FactoryMiddleware`.
21
24
  */
22
25
  export declare function Procedures<TContext = TNoContextProvided, TExtendedConfig = unknown>(options?: ProceduresOptions<TContext, TExtendedConfig>): {
23
26
  /** All registered procedures, in registration order. */
@@ -70,10 +73,7 @@ export declare function Procedures<TContext = TNoContextProvided, TExtendedConfi
70
73
  yield?: import("../schema/compile.js").Validate;
71
74
  } | undefined;
72
75
  } & TExtendedConfig>;
73
- CreateHttp: <TName extends string, TReq extends Record<string, unknown> | undefined = undefined, TRes extends {
74
- body?: unknown;
75
- headers?: unknown;
76
- } | undefined = undefined, TErrorKey extends string = string>(name: TName, config: import("./types.js").TCreateHttpConfig<TReq, TRes, TErrorKey>, handler: (ctx: TContext & import("./types.js").TLocalContext extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }]: { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }[Key_1]; } : undefined) => Promise<import("./create-http.js").HttpReturn<TRes>>) => import("./types.js").ProcedureResult<TName, (ctx: { [Key in keyof TContext]: TContext[Key]; }, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }]: { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }[Key_1]; } : undefined) => Promise<import("./create-http.js").HttpReturn<TRes>>, {
76
+ CreateHttp: <TName extends string, TReq extends import("./types.js").THttpReqInput | undefined = undefined, TRes extends import("./types.js").THttpResInput | undefined = undefined, TErrorKey extends string = string>(name: TName, config: import("./types.js").TCreateHttpConfig<TReq, TRes, TErrorKey>, handler: (ctx: TContext & import("./types.js").TLocalContext extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: import("./types.js").HttpReq<TReq>) => Promise<import("./create-http.js").HttpReturn<TRes>>) => import("./types.js").ProcedureResult<TName, (ctx: { [Key in keyof TContext]: TContext[Key]; }, req: import("./types.js").HttpReq<TReq>) => Promise<import("./create-http.js").HttpReturn<TRes>>, {
77
77
  path: string;
78
78
  method: import("./types.js").HttpMethod;
79
79
  successStatus?: number;
@@ -93,29 +93,22 @@ export declare function Procedures<TContext = TNoContextProvided, TExtendedConfi
93
93
  name: TName;
94
94
  kind: "http";
95
95
  }>;
96
- CreateHttpStream: <TName extends string, TReq extends Record<string, unknown> | undefined, TYieldType, TReturnType = void, TResHeaders = undefined, TErrorKey extends string = string>(name: TName, config: {
96
+ CreateHttpStream: <TName extends string, TReq extends import("./types.js").THttpReqInput | undefined, TYieldType, TReturnType = void, TResHeaders = undefined, TErrorKey extends string = string>(name: TName, config: {
97
97
  path: string;
98
98
  method: import("./types.js").HttpMethod;
99
99
  scope?: string;
100
100
  errors?: TErrorKey[] | undefined;
101
101
  description?: string;
102
- schema: {
103
- req?: TReq | undefined;
104
- yield?: TYieldType | undefined;
105
- returnType?: TReturnType | undefined;
106
- res?: (TResHeaders extends undefined ? undefined : {
107
- headers: TResHeaders;
108
- }) | undefined;
109
- };
102
+ schema: import("./types.js").THttpStreamSchema<TReq, TYieldType, TReturnType, TResHeaders>;
110
103
  validateYields?: boolean;
111
104
  }, handler: TResHeaders extends undefined ? (ctx: TContext & import("./types.js").TLocalContext & {
112
105
  signal: AbortSignal;
113
- } extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }]: { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }[Key_1]; } : undefined) => AsyncGenerator<import("../exports.js").Infer<TYieldType>, void | import("../exports.js").Infer<TReturnType>, unknown> : (ctx: TContext & import("./types.js").TLocalContext & {
106
+ } extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: import("./types.js").HttpReq<TReq>) => AsyncGenerator<import("../exports.js").Infer<TYieldType>, void | import("../exports.js").Infer<TReturnType>, unknown> : (ctx: TContext & import("./types.js").TLocalContext & {
114
107
  signal: AbortSignal;
115
- } extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }]: { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }[Key_1]; } : undefined) => Promise<{
108
+ } extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: import("./types.js").HttpReq<TReq>) => Promise<{
116
109
  headers: import("../exports.js").Infer<TResHeaders>;
117
110
  stream: AsyncGenerator<import("../exports.js").Infer<TYieldType>, void | import("../exports.js").Infer<TReturnType>, unknown>;
118
- }>) => import("./types.js").ProcedureResult<TName, (ctx: { [Key in keyof TContext]: TContext[Key]; }, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }]: { [K in keyof TReq]: import("../exports.js").Infer<TReq[K]>; }[Key_1]; } : undefined) => Promise<{
111
+ }>) => import("./types.js").ProcedureResult<TName, (ctx: { [Key in keyof TContext]: TContext[Key]; }, req: import("./types.js").HttpReq<TReq>) => Promise<{
119
112
  stream: AsyncGenerator<import("../exports.js").Infer<TYieldType>, void | import("../exports.js").Infer<TReturnType>, unknown>;
120
113
  initialHeaders?: Record<string, string>;
121
114
  }>, {
@@ -15,6 +15,7 @@ import { typeboxAdapter } from '../schema/typebox.js';
15
15
  * schema: { adapters: [myZodAdapter] }, // TypeBox is built in
16
16
  * http: { pathPrefix: '/v1', scope: 'billing' }, // CreateHttp* defaults
17
17
  * onCreate: (procedure) => log(procedure.kind, procedure.name),
18
+ * // middleware: [ myFactoryGuard ], // runs with final ctx + input for every proc
18
19
  * })
19
20
  * ```
20
21
  *
@@ -23,6 +24,8 @@ import { typeboxAdapter } from '../schema/typebox.js';
23
24
  * - `TExtendedConfig` — extra per-procedure config fields (e.g. `scope`,
24
25
  * `version`, auth flags) carried through to registrations, `info`, and
25
26
  * `onCreate`.
27
+ * - `middleware` — factory-level middleware with access to the final ctx + input
28
+ * ("parse the incoming call") for authz, enrichment, etc. See `FactoryMiddleware`.
26
29
  */
27
30
  export function Procedures(options) {
28
31
  const registry = new Map();
@@ -33,6 +36,7 @@ export function Procedures(options) {
33
36
  adapters: [...(options?.schema?.adapters ?? []), typeboxAdapter],
34
37
  compile: createValidatorCompiler(options?.validation === false ? undefined : options?.validation),
35
38
  httpDefaults: options?.http,
39
+ middlewares: options?.middleware ?? [],
36
40
  };
37
41
  const Create = makeCreate(runtime);
38
42
  const CreateStream = makeCreateStream(runtime);
@@ -1 +1 @@
1
- {"version":3,"file":"procedures.js","sourceRoot":"","sources":["../../src/core/procedures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAIrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,UAAU,CACxB,OAAsD;IAEtD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+D,CAAA;IAEvF,MAAM,OAAO,GAA8C;QACzD,QAAQ;QACR,QAAQ,EAAE,OAAO,EAAE,QAAQ;QAC3B,cAAc,EAAE,OAAO,EAAE,UAAU,KAAK,KAAK;QAC7C,QAAQ,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC,EAAE,cAAc,CAAC;QAChE,OAAO,EAAE,uBAAuB,CAAC,OAAO,EAAE,UAAU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IAAI,CAAC,CAAA;QAC9B,CAAC;QAED,wCAAwC;QACxC,KAAK,EAAE,GAAG,EAAE;YACV,QAAQ,CAAC,KAAK,EAAE,CAAA;QAClB,CAAC;QAED,MAAM;QACN,YAAY;QACZ,UAAU;QACV,gBAAgB;KACjB,CAAA;AACH,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type * as AJV from 'ajv';
2
2
  import type { ProcedureError } from './errors.js';
3
3
  import type { SchemaAdapter } from '../schema/adapter.js';
4
- import type { TJSONSchema } from '../schema/json-schema.js';
4
+ import type { Infer, Prettify, TJSONSchema } from '../schema/json-schema.js';
5
5
  import type { Validate } from '../schema/compile.js';
6
6
  export type TNoContextProvided = unknown;
7
7
  /**
@@ -61,7 +61,52 @@ export type TStreamProcedureRegistration<TContext = unknown, TExtendedConfig = u
61
61
  handler: (ctx: TContext, params?: any) => AsyncGenerator<any, any, unknown>;
62
62
  };
63
63
  export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head';
64
- export type TCreateHttpConfig<TReq, TRes, TErrorKey extends string = string> = {
64
+ /**
65
+ * Canonical shape for `schema.req` channels.
66
+ * Used both to constrain generics and to provide autocomplete when writing
67
+ * `CreateHttp` / `CreateHttpStream` config objects.
68
+ *
69
+ * Note: RPC `Create` / `CreateStream` use a flatter `schema: { params?, yieldType?, returnType? }`
70
+ * directly (no extra container generic), so they don't need an equivalent named input shape.
71
+ */
72
+ export type THttpReqInput = {
73
+ pathParams?: unknown;
74
+ query?: unknown;
75
+ body?: unknown;
76
+ headers?: unknown;
77
+ };
78
+ /**
79
+ * Canonical shape for `schema.res` on CreateHttp (CreateHttpStream only supports `headers`).
80
+ */
81
+ export type THttpResInput = {
82
+ body?: unknown;
83
+ headers?: unknown;
84
+ };
85
+ /**
86
+ * @internal Helper to surface literal channel keys for autocomplete
87
+ * while still threading the user's concrete generic schemas through for inference.
88
+ */
89
+ export type HttpSchemaInput<Base, T> = Base & (T extends undefined ? {} : T);
90
+ /**
91
+ * @internal Shared helper for typing the destructured `req` argument passed to
92
+ * CreateHttp / CreateHttpStream handlers. Mirrors the per-channel Infer.
93
+ */
94
+ export type HttpReq<TReq> = TReq extends Record<string, unknown> ? Prettify<{
95
+ [K in keyof TReq]: Infer<TReq[K]>;
96
+ }> : undefined;
97
+ /**
98
+ * Shape used for the `schema` option of `CreateHttpStream`.
99
+ * Reuses the same req input shape as CreateHttp for autocomplete consistency.
100
+ */
101
+ export type THttpStreamSchema<TReq extends THttpReqInput | undefined = undefined, TYield = unknown, TReturn = void, TResHeaders = undefined> = {
102
+ req?: HttpSchemaInput<THttpReqInput, TReq>;
103
+ yield?: TYield;
104
+ returnType?: TReturn;
105
+ res?: TResHeaders extends undefined ? undefined : {
106
+ headers: TResHeaders;
107
+ };
108
+ };
109
+ export type TCreateHttpConfig<TReq extends THttpReqInput | undefined = undefined, TRes extends THttpResInput | undefined = undefined, TErrorKey extends string = string> = {
65
110
  path: string;
66
111
  method: HttpMethod;
67
112
  successStatus?: number;
@@ -70,8 +115,8 @@ export type TCreateHttpConfig<TReq, TRes, TErrorKey extends string = string> = {
70
115
  description?: string;
71
116
  /** Optional — a no-input, no-output route (e.g. a 204 logout) may omit it. */
72
117
  schema?: {
73
- req?: TReq;
74
- res?: TRes;
118
+ req?: HttpSchemaInput<THttpReqInput, TReq>;
119
+ res?: HttpSchemaInput<THttpResInput, TRes>;
75
120
  };
76
121
  };
77
122
  export type THttpProcedureRegistration<TContext = unknown> = {
@@ -180,4 +225,40 @@ export type ProceduresOptions<TContext = unknown, TExtendedConfig = unknown> = {
180
225
  pathPrefix?: string;
181
226
  scope?: string;
182
227
  };
228
+ /**
229
+ * Optional middleware that runs for *every* procedure defined via this factory.
230
+ * Runs after schema validation but before the user handler, with the *same*
231
+ * context the handler receives (including injected `error()` and `signal`).
232
+ *
233
+ * Use this for cross-cutting logic that needs the resolved `TContext` + the
234
+ * incoming call data ("parse the incoming call"):
235
+ * - Authorization / tenancy checks using `ctx.user` + `input`
236
+ * - Enriching ctx for all procedures on the factory
237
+ * - Auditing, feature flags, etc.
238
+ *
239
+ * The middleware receives a `next` function. Call `await next({ ctx?, input? })`
240
+ * to continue (optionally with augmented ctx or transformed input). You may
241
+ * also return/throw early.
242
+ *
243
+ * Works for both direct calls and all adapters. Complements (runs after)
244
+ * builder-level middleware on HonoAppBuilder.
245
+ */
246
+ middleware?: FactoryMiddleware<TContext>[];
183
247
  };
248
+ /**
249
+ * Middleware defined on a Procedures factory.
250
+ *
251
+ * - `ctx` is the fully resolved context (your TContext + `error()` + `signal`).
252
+ * - `input` is the (already schema-validated) call argument:
253
+ * - For Create / CreateStream: the `params` object
254
+ * - For CreateHttp / CreateHttpStream: the `{ pathParams?, query?, body?, headers? }`
255
+ * - Call `next()` (or `next({ ctx: augmented, input: transformed })`) to proceed.
256
+ */
257
+ export type FactoryMiddleware<TContext = unknown> = (opts: {
258
+ ctx: Prettify<TContext & TLocalContext>;
259
+ input: unknown;
260
+ next: (opts?: {
261
+ ctx?: any;
262
+ input?: unknown;
263
+ }) => Promise<any> | AsyncGenerator<any, any, unknown>;
264
+ }) => Promise<any> | AsyncGenerator<any, any, unknown> | void;
@@ -0,0 +1,33 @@
1
+ import { TSchemaValidationError } from './schema/parser.js';
2
+ import { DefinitionInfo, DefinitionLocation } from './stack-utils.js';
3
+ export declare class ProcedureError extends Error {
4
+ readonly procedureName: string;
5
+ readonly message: string;
6
+ readonly meta?: object | undefined;
7
+ cause?: unknown;
8
+ readonly definedAt?: DefinitionLocation;
9
+ readonly definitionStack?: string;
10
+ constructor(procedureName: string, message: string, meta?: object | undefined, definitionInfo?: DefinitionInfo);
11
+ /**
12
+ * Returns a formatted string showing where the procedure was defined.
13
+ */
14
+ getDefinitionLocation(): string | undefined;
15
+ /**
16
+ * Enhances the error stack with definition location information.
17
+ */
18
+ private enhanceStack;
19
+ }
20
+ export declare class ProcedureValidationError extends ProcedureError {
21
+ readonly procedureName: string;
22
+ readonly errors?: TSchemaValidationError[] | undefined;
23
+ constructor(procedureName: string, message: string, errors?: TSchemaValidationError[] | undefined, definitionInfo?: DefinitionInfo);
24
+ }
25
+ export declare class ProcedureRegistrationError extends ProcedureError {
26
+ readonly procedureName: string;
27
+ constructor(procedureName: string, message: string, definitionInfo?: DefinitionInfo);
28
+ }
29
+ export declare class ProcedureYieldValidationError extends ProcedureError {
30
+ readonly procedureName: string;
31
+ readonly errors?: TSchemaValidationError[] | undefined;
32
+ constructor(procedureName: string, message: string, errors?: TSchemaValidationError[] | undefined, definitionInfo?: DefinitionInfo);
33
+ }
@@ -0,0 +1,91 @@
1
+ import { formatDefinitionInfo } from './stack-utils.js';
2
+ import { kebabCase } from 'es-toolkit/string';
3
+ export class ProcedureError extends Error {
4
+ procedureName;
5
+ message;
6
+ meta;
7
+ cause;
8
+ definedAt;
9
+ definitionStack;
10
+ constructor(procedureName, message, meta,
11
+ // Used for error stack trace details
12
+ definitionInfo) {
13
+ super(message);
14
+ this.procedureName = procedureName;
15
+ this.message = message;
16
+ this.meta = meta;
17
+ this.name = 'ProcedureError';
18
+ if (definitionInfo) {
19
+ this.definedAt = definitionInfo.definedAt;
20
+ this.definitionStack = definitionInfo.definitionStack;
21
+ this.enhanceStack();
22
+ }
23
+ // https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/
24
+ Object.setPrototypeOf(this, ProcedureError.prototype);
25
+ }
26
+ /**
27
+ * Returns a formatted string showing where the procedure was defined.
28
+ */
29
+ getDefinitionLocation() {
30
+ if (!this.definedAt) {
31
+ return undefined;
32
+ }
33
+ return `${this.definedAt.file}:${this.definedAt.line}:${this.definedAt.column}`;
34
+ }
35
+ /**
36
+ * Enhances the error stack with definition location information.
37
+ */
38
+ enhanceStack() {
39
+ if (!this.stack || !this.definedAt) {
40
+ return;
41
+ }
42
+ const definitionSection = formatDefinitionInfo({ definedAt: this.definedAt, definitionStack: this.definitionStack }, this.procedureName);
43
+ if (definitionSection) {
44
+ this.stack = this.stack + definitionSection;
45
+ }
46
+ }
47
+ }
48
+ export class ProcedureValidationError extends ProcedureError {
49
+ procedureName;
50
+ errors;
51
+ constructor(procedureName, message, errors,
52
+ // Used for error stack trace details
53
+ definitionInfo) {
54
+ const readableErrors = errors
55
+ ?.map((err) => `- ${kebabCase(err.instancePath).replace('-', '.')} ${err.message}`)
56
+ .join(', ');
57
+ super(procedureName, message + ' ' + readableErrors, { errors }, definitionInfo);
58
+ this.procedureName = procedureName;
59
+ this.errors = errors;
60
+ this.name = 'ProcedureValidationError';
61
+ // https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/
62
+ Object.setPrototypeOf(this, ProcedureValidationError.prototype);
63
+ }
64
+ }
65
+ export class ProcedureRegistrationError extends ProcedureError {
66
+ procedureName;
67
+ constructor(procedureName, message,
68
+ // Used for error stack trace details
69
+ definitionInfo) {
70
+ super(procedureName, message, undefined, definitionInfo);
71
+ this.procedureName = procedureName;
72
+ this.name = 'ProcedureRegistrationError';
73
+ // https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/
74
+ Object.setPrototypeOf(this, ProcedureRegistrationError.prototype);
75
+ }
76
+ }
77
+ export class ProcedureYieldValidationError extends ProcedureError {
78
+ procedureName;
79
+ errors;
80
+ constructor(procedureName, message, errors,
81
+ // Used for error stack trace details
82
+ definitionInfo) {
83
+ super(procedureName, message, undefined, definitionInfo);
84
+ this.procedureName = procedureName;
85
+ this.errors = errors;
86
+ this.name = 'ProcedureYieldValidationError';
87
+ // https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/
88
+ Object.setPrototypeOf(this, ProcedureYieldValidationError.prototype);
89
+ }
90
+ }
91
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC3F,OAAO,EAAE,SA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Ae,EACN,MAAiC;IAC1C,qCAAqC;IACrC,cAA+B;QAE/B,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,CAAC,CAAA;QAN/C,kBAAa,GAAb,aAAa,CAAQ;QAErB,WAAM,GAAN,MAAM,CAA2B;QAK1C,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAA;QAE3C,mGAAmG;QACnG,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,6BAA6B,CAAC,SAAS,CAAC,CAAA;IACtE,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,122 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { ProcedureError, ProcedureValidationError, ProcedureRegistrationError, } from './errors.js';
3
+ describe('Error Classes', () => {
4
+ test('ProcedureError has correct properties', () => {
5
+ const err = new ProcedureError('TestProc', 'Something failed', { code: 123 });
6
+ expect(err.name).toBe('ProcedureError');
7
+ expect(err.procedureName).toBe('TestProc');
8
+ expect(err.message).toBe('Something failed');
9
+ expect(err.meta).toEqual({ code: 123 });
10
+ expect(err instanceof Error).toBe(true);
11
+ });
12
+ test('ProcedureValidationError extends ProcedureError', () => {
13
+ const err = new ProcedureValidationError('TestProc', 'Validation failed', []);
14
+ expect(err instanceof ProcedureError).toBe(true);
15
+ expect(err instanceof Error).toBe(true);
16
+ expect(err.name).toBe('ProcedureValidationError');
17
+ });
18
+ test('ProcedureRegistrationError extends ProcedureError', () => {
19
+ const err = new ProcedureRegistrationError('TestProc', 'Registration failed');
20
+ expect(err instanceof ProcedureError).toBe(true);
21
+ expect(err instanceof Error).toBe(true);
22
+ expect(err.name).toBe('ProcedureRegistrationError');
23
+ expect(err.procedureName).toBe('TestProc');
24
+ });
25
+ test('ProcedureError supports cause property', () => {
26
+ const cause = new Error('Original error');
27
+ const err = new ProcedureError('TestProc', 'Wrapped error');
28
+ err.cause = cause;
29
+ expect(err.cause).toBe(cause);
30
+ });
31
+ test('All error types have consistent procedureName property', () => {
32
+ const baseErr = new ProcedureError('Proc1', 'message');
33
+ const validationErr = new ProcedureValidationError('Proc2', 'message', []);
34
+ const registrationErr = new ProcedureRegistrationError('Proc3', 'message');
35
+ expect(baseErr.procedureName).toBe('Proc1');
36
+ expect(validationErr.procedureName).toBe('Proc2');
37
+ expect(registrationErr.procedureName).toBe('Proc3');
38
+ });
39
+ });
40
+ describe('Error Classes - Definition Info', () => {
41
+ const mockDefinitionInfo = {
42
+ definedAt: {
43
+ file: '/app/procedures/user.ts',
44
+ line: 25,
45
+ column: 3,
46
+ raw: 'at Object.<anonymous> (/app/procedures/user.ts:25:3)',
47
+ },
48
+ definitionStack: 'Error\n at Object.<anonymous> (/app/procedures/user.ts:25:3)',
49
+ };
50
+ test('ProcedureError includes definedAt when provided', () => {
51
+ const err = new ProcedureError('TestProc', 'Something failed', undefined, mockDefinitionInfo);
52
+ expect(err.definedAt).toBeDefined();
53
+ expect(err.definedAt?.file).toBe('/app/procedures/user.ts');
54
+ expect(err.definedAt?.line).toBe(25);
55
+ expect(err.definedAt?.column).toBe(3);
56
+ });
57
+ test('ProcedureError includes definitionStack when provided', () => {
58
+ const err = new ProcedureError('TestProc', 'Something failed', undefined, mockDefinitionInfo);
59
+ expect(err.definitionStack).toBeDefined();
60
+ expect(err.definitionStack).toContain('/app/procedures/user.ts');
61
+ });
62
+ test('ProcedureError works without definitionInfo (backward compat)', () => {
63
+ const err = new ProcedureError('TestProc', 'Something failed', { code: 123 });
64
+ expect(err.definedAt).toBeUndefined();
65
+ expect(err.definitionStack).toBeUndefined();
66
+ expect(err.procedureName).toBe('TestProc');
67
+ expect(err.message).toBe('Something failed');
68
+ expect(err.meta).toEqual({ code: 123 });
69
+ });
70
+ test('ProcedureValidationError includes definedAt when provided', () => {
71
+ const err = new ProcedureValidationError('TestProc', 'Validation failed', [], mockDefinitionInfo);
72
+ expect(err.definedAt).toBeDefined();
73
+ expect(err.definedAt?.file).toBe('/app/procedures/user.ts');
74
+ expect(err.definedAt?.line).toBe(25);
75
+ });
76
+ test('ProcedureValidationError works without definitionInfo (backward compat)', () => {
77
+ const err = new ProcedureValidationError('TestProc', 'Validation failed', []);
78
+ expect(err.definedAt).toBeUndefined();
79
+ expect(err.definitionStack).toBeUndefined();
80
+ expect(err.name).toBe('ProcedureValidationError');
81
+ });
82
+ test('ProcedureRegistrationError includes definedAt when provided', () => {
83
+ const err = new ProcedureRegistrationError('TestProc', 'Registration failed', mockDefinitionInfo);
84
+ expect(err.definedAt).toBeDefined();
85
+ expect(err.definedAt?.file).toBe('/app/procedures/user.ts');
86
+ });
87
+ test('ProcedureRegistrationError works without definitionInfo (backward compat)', () => {
88
+ const err = new ProcedureRegistrationError('TestProc', 'Registration failed');
89
+ expect(err.definedAt).toBeUndefined();
90
+ expect(err.definitionStack).toBeUndefined();
91
+ expect(err.name).toBe('ProcedureRegistrationError');
92
+ });
93
+ test('getDefinitionLocation returns formatted location string', () => {
94
+ const err = new ProcedureError('TestProc', 'Something failed', undefined, mockDefinitionInfo);
95
+ const location = err.getDefinitionLocation();
96
+ expect(location).toBe('/app/procedures/user.ts:25:3');
97
+ });
98
+ test('getDefinitionLocation returns undefined when no definedAt', () => {
99
+ const err = new ProcedureError('TestProc', 'Something failed');
100
+ const location = err.getDefinitionLocation();
101
+ expect(location).toBeUndefined();
102
+ });
103
+ test('enhanced stack contains definition location', () => {
104
+ const err = new ProcedureError('TestProc', 'Something failed', undefined, mockDefinitionInfo);
105
+ expect(err.stack).toContain('--- Procedure "TestProc" defined at ---');
106
+ expect(err.stack).toContain('/app/procedures/user.ts:25:3');
107
+ });
108
+ test('stack is not modified when no definitionInfo', () => {
109
+ const err = new ProcedureError('TestProc', 'Something failed');
110
+ expect(err.stack).toBeDefined();
111
+ expect(err.stack).not.toContain('--- Procedure');
112
+ });
113
+ test('all error types enhance stack with definition location', () => {
114
+ const baseErr = new ProcedureError('Proc1', 'message', undefined, mockDefinitionInfo);
115
+ const validationErr = new ProcedureValidationError('Proc2', 'message', [], mockDefinitionInfo);
116
+ const registrationErr = new ProcedureRegistrationError('Proc3', 'message', mockDefinitionInfo);
117
+ expect(baseErr.stack).toContain('--- Procedure "Proc1" defined at ---');
118
+ expect(validationErr.stack).toContain('--- Procedure "Proc2" defined at ---');
119
+ expect(registrationErr.stack).toContain('--- Procedure "Proc3" defined at ---');
120
+ });
121
+ });
122
+ //# sourceMappingURL=errors.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.test.js","sourceRoot":"","sources":["../src/errors.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,aAAa,CAAA;AAGpB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;QACjD,MAAM,GAAG,GAAG,IAAI,cAAc,CAAC,UAAU,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;QAE7E,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACvC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC1C,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAC5C,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;QACvC,MAAM,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE;QAC3D,MAAM,GAAG,GAAG,IAAI,wBAAwB,CAAC,UAAU,EAAE,mB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E,SAAS,EAAE,EAAE,EAAE,kBAAkB,CAAC,CAAA;QAC9F,MAAM,eAAe,GAAG,IAAI,0BAA0B,CAAC,OAAO,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAA;QAE9F,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,sCAAsC,CAAC,CAAA;QACvE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,sCAAsC,CAAC,CAAA;QAC7E,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,sCAAsC,CAAC,CAAA;IACjF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -12,7 +12,7 @@
12
12
  * - `ts-procedures/codegen` — client code generation (also: npx ts-procedures-codegen)
13
13
  */
14
14
  export { Procedures } from './core/procedures.js';
15
- export type { ProceduresOptions, ProcedureKind, AnyProcedureRegistration, TProcedureRegistration, TStreamProcedureRegistration, THttpProcedureRegistration, THttpStreamProcedureRegistration, TCreateHttpConfig, TLocalContext, TStreamContext, TNoContextProvided, HttpMethod, } from './core/types.js';
15
+ export type { ProceduresOptions, ProcedureKind, AnyProcedureRegistration, TProcedureRegistration, TStreamProcedureRegistration, THttpProcedureRegistration, THttpStreamProcedureRegistration, TCreateHttpConfig, THttpReqInput, THttpResInput, THttpStreamSchema, HttpSchemaInput, HttpReq, TLocalContext, TStreamContext, TNoContextProvided, HttpMethod, FactoryMiddleware, } from './core/types.js';
16
16
  export type { HttpReturn } from './core/create-http.js';
17
17
  export { ProcedureError, ProcedureValidationError, ProcedureRegistrationError, ProcedureYieldValidationError, } from './core/errors.js';
18
18
  export type { ProcedureErrorKind } from './core/errors.js';
@@ -27,6 +27,5 @@ export { createValidatorCompiler, DEFAULT_AJV_OPTIONS } from './schema/compile.j
27
27
  export type { Validate, ValidatorCompiler, ValidationOptions, TSchemaValidationError, } from './schema/compile.js';
28
28
  export type { Infer, TSchemaLib, TJSONSchema, Prettify } from './schema/json-schema.js';
29
29
  export { writeDocEnvelope } from './server/doc-envelope.js';
30
- export { DOC_ENVELOPE_SPEC_VERSION } from './server/spec-version.js';
31
30
  export type { DocEnvelopeSource } from './server/doc-envelope.js';
32
31
  export type { DocEnvelope } from './server/types.js';
package/build/exports.js CHANGED
@@ -21,8 +21,4 @@ export { computeSchema } from './schema/compute-schema.js';
21
21
  export { createValidatorCompiler, DEFAULT_AJV_OPTIONS } from './schema/compile.js';
22
22
  // Doc envelope — offline codegen input
23
23
  export { writeDocEnvelope } from './server/doc-envelope.js';
24
- // `generatorVersion` metadata lives on `ts-procedures/server`
25
- // (DOC_ENVELOPE_GENERATOR_VERSION) — it's niche telemetry. The spec version is
26
- // the one consumers branch on, so it gets the prominent top-level export.
27
- export { DOC_ENVELOPE_SPEC_VERSION } from './server/spec-version.js';
28
24
  //# sourceMappingURL=exports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,8DAA8D;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAgBjD,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAKvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AASlF,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,8DAA8D;AAC9D,+EAA+E;AAC/E,0EAA0E;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,8DAA8D;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAsBjD,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAKvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AASlF,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,28 @@
1
+ import type { AnyHttpRouteDoc, DocEnvelope, DocRegistryConfig, DocRegistryOutputOptions, DocSource, ErrorDoc } from '../types.js';
2
+ export type { AnyHttpRouteDoc, DocEnvelope, DocRegistryConfig, DocRegistryOutputOptions, DocSource, ErrorDoc, HeaderDoc, } from '../types.js';
3
+ export declare class DocRegistry {
4
+ private readonly basePath;
5
+ private readonly headers;
6
+ private errors;
7
+ private readonly sources;
8
+ constructor(config?: DocRegistryConfig);
9
+ from(source: DocSource<AnyHttpRouteDoc>): this;
10
+ /**
11
+ * Adds one or more {@link ErrorDoc} entries to the envelope. Use for errors
12
+ * outside your runtime taxonomy — middleware-level errors, infrastructure
13
+ * errors (502/503/504), or doc-only meta errors.
14
+ *
15
+ * Deduped by `name` — last write wins.
16
+ */
17
+ documentError(...docs: ErrorDoc[]): this;
18
+ toJSON<T = DocEnvelope>(options?: DocRegistryOutputOptions<T>): T;
19
+ /**
20
+ * Framework error defaults — derived from {@link defaultErrorTaxonomy} plus
21
+ * `ProcedureRegistrationError` (which is thrown only at registration time
22
+ * and therefore lives in the catalog, not the runtime taxonomy).
23
+ *
24
+ * Most consumers do not need to call this directly — the `DocRegistry`
25
+ * constructor auto-includes these unless `includeDefaults: false` is passed.
26
+ */
27
+ static defaultErrors(): ErrorDoc[];
28
+ }