@lovrozagar/honey 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/README.md +1596 -6
  2. package/dist/accepts.d.ts +6 -0
  3. package/dist/accepts.d.ts.map +1 -0
  4. package/dist/body-limit.d.ts +22 -0
  5. package/dist/body-limit.d.ts.map +1 -0
  6. package/dist/build/index.d.ts +42 -0
  7. package/dist/build/index.d.ts.map +1 -0
  8. package/dist/cli.d.ts +3 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/client/error.d.ts +14 -0
  11. package/dist/client/error.d.ts.map +1 -0
  12. package/dist/client/http.d.ts +88 -0
  13. package/dist/client/http.d.ts.map +1 -0
  14. package/dist/client/index.d.ts +22 -0
  15. package/dist/client/index.d.ts.map +1 -0
  16. package/dist/client/sdk.d.ts +34 -0
  17. package/dist/client/sdk.d.ts.map +1 -0
  18. package/dist/client/sse.d.ts +10 -0
  19. package/dist/client/sse.d.ts.map +1 -0
  20. package/dist/client/types.d.ts +124 -0
  21. package/dist/client/types.d.ts.map +1 -0
  22. package/dist/client/ws.d.ts +15 -0
  23. package/dist/client/ws.d.ts.map +1 -0
  24. package/dist/client-mcp/server.d.ts +10 -0
  25. package/dist/client-mcp/server.d.ts.map +1 -0
  26. package/dist/client-mcp/types.d.ts +16 -0
  27. package/dist/client-mcp/types.d.ts.map +1 -0
  28. package/dist/cloudflare/realtime.d.ts +30 -0
  29. package/dist/cloudflare/realtime.d.ts.map +1 -0
  30. package/dist/codegen-go-cli.d.ts +22 -0
  31. package/dist/codegen-go-cli.d.ts.map +1 -0
  32. package/dist/codegen-go.d.ts +29 -0
  33. package/dist/codegen-go.d.ts.map +1 -0
  34. package/dist/codegen-hash.d.ts +3 -0
  35. package/dist/codegen-hash.d.ts.map +1 -0
  36. package/dist/codegen-ir.d.ts +123 -0
  37. package/dist/codegen-ir.d.ts.map +1 -0
  38. package/dist/codegen-loaders.d.ts +12 -0
  39. package/dist/codegen-loaders.d.ts.map +1 -0
  40. package/dist/codegen-mcp.d.ts +13 -0
  41. package/dist/codegen-mcp.d.ts.map +1 -0
  42. package/dist/codegen-python.d.ts +21 -0
  43. package/dist/codegen-python.d.ts.map +1 -0
  44. package/dist/codegen-rust.d.ts +18 -0
  45. package/dist/codegen-rust.d.ts.map +1 -0
  46. package/dist/codegen-sanitize.d.ts +3 -0
  47. package/dist/codegen-sanitize.d.ts.map +1 -0
  48. package/dist/codegen-schema-naming.d.ts +22 -0
  49. package/dist/codegen-schema-naming.d.ts.map +1 -0
  50. package/dist/codegen.d.ts +178 -0
  51. package/dist/codegen.d.ts.map +1 -0
  52. package/dist/context.d.ts +56 -0
  53. package/dist/context.d.ts.map +1 -0
  54. package/dist/cookie-sign.d.ts +3 -0
  55. package/dist/cookie-sign.d.ts.map +1 -0
  56. package/dist/cookie.d.ts +12 -0
  57. package/dist/cookie.d.ts.map +1 -0
  58. package/dist/cors.d.ts +13 -0
  59. package/dist/cors.d.ts.map +1 -0
  60. package/dist/crypto.d.ts +2 -0
  61. package/dist/crypto.d.ts.map +1 -0
  62. package/dist/csrf.d.ts +9 -0
  63. package/dist/csrf.d.ts.map +1 -0
  64. package/dist/curl-logger.d.ts +33 -0
  65. package/dist/curl-logger.d.ts.map +1 -0
  66. package/dist/detect-runtime.d.ts +16 -0
  67. package/dist/detect-runtime.d.ts.map +1 -0
  68. package/dist/error.d.ts +21 -0
  69. package/dist/error.d.ts.map +1 -0
  70. package/dist/errors.d.ts +40 -0
  71. package/dist/errors.d.ts.map +1 -0
  72. package/dist/etag.d.ts +9 -0
  73. package/dist/etag.d.ts.map +1 -0
  74. package/dist/feature-load.d.ts +3 -0
  75. package/dist/feature-load.d.ts.map +1 -0
  76. package/dist/go-type-emitter.d.ts +33 -0
  77. package/dist/go-type-emitter.d.ts.map +1 -0
  78. package/dist/honey-response.d.ts +82 -0
  79. package/dist/honey-response.d.ts.map +1 -0
  80. package/dist/i18n-slot.d.ts +7 -0
  81. package/dist/i18n-slot.d.ts.map +1 -0
  82. package/dist/i18n.d.ts +26 -0
  83. package/dist/i18n.d.ts.map +1 -0
  84. package/dist/index.d.ts +470 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/init.d.ts +7 -0
  87. package/dist/init.d.ts.map +1 -0
  88. package/dist/input.d.ts +6 -0
  89. package/dist/input.d.ts.map +1 -0
  90. package/dist/ip-restrict.d.ts +12 -0
  91. package/dist/ip-restrict.d.ts.map +1 -0
  92. package/dist/logger.d.ts +45 -0
  93. package/dist/logger.d.ts.map +1 -0
  94. package/dist/meta-spec.d.ts +81 -0
  95. package/dist/meta-spec.d.ts.map +1 -0
  96. package/dist/middleware.d.ts +60 -0
  97. package/dist/middleware.d.ts.map +1 -0
  98. package/dist/node-request.d.ts +59 -0
  99. package/dist/node-request.d.ts.map +1 -0
  100. package/dist/node.d.ts +13 -0
  101. package/dist/node.d.ts.map +1 -0
  102. package/dist/openapi/register.d.ts +3 -0
  103. package/dist/openapi/register.d.ts.map +1 -0
  104. package/dist/openapi/scalar.d.ts +12 -0
  105. package/dist/openapi/scalar.d.ts.map +1 -0
  106. package/dist/openapi/spec-factory.d.ts +31 -0
  107. package/dist/openapi/spec-factory.d.ts.map +1 -0
  108. package/dist/openapi/spec.d.ts +19 -0
  109. package/dist/openapi/spec.d.ts.map +1 -0
  110. package/dist/openapi/swagger.d.ts +12 -0
  111. package/dist/openapi/swagger.d.ts.map +1 -0
  112. package/dist/plugin.d.ts +167 -0
  113. package/dist/plugin.d.ts.map +1 -0
  114. package/dist/powered-by.d.ts +7 -0
  115. package/dist/powered-by.d.ts.map +1 -0
  116. package/dist/pretty-json.d.ts +10 -0
  117. package/dist/pretty-json.d.ts.map +1 -0
  118. package/dist/proxy.d.ts +51 -0
  119. package/dist/proxy.d.ts.map +1 -0
  120. package/dist/python-type-emitter.d.ts +11 -0
  121. package/dist/python-type-emitter.d.ts.map +1 -0
  122. package/dist/realtime/buffer.d.ts +18 -0
  123. package/dist/realtime/buffer.d.ts.map +1 -0
  124. package/dist/realtime/bus.d.ts +11 -0
  125. package/dist/realtime/bus.d.ts.map +1 -0
  126. package/dist/realtime/longpoll.d.ts +23 -0
  127. package/dist/realtime/longpoll.d.ts.map +1 -0
  128. package/dist/realtime/protocol.d.ts +50 -0
  129. package/dist/realtime/protocol.d.ts.map +1 -0
  130. package/dist/realtime/route.d.ts +42 -0
  131. package/dist/realtime/route.d.ts.map +1 -0
  132. package/dist/realtime/runtime.d.ts +74 -0
  133. package/dist/realtime/runtime.d.ts.map +1 -0
  134. package/dist/request-id.d.ts +12 -0
  135. package/dist/request-id.d.ts.map +1 -0
  136. package/dist/request-to-curl.d.ts +9 -0
  137. package/dist/request-to-curl.d.ts.map +1 -0
  138. package/dist/response.d.ts +57 -0
  139. package/dist/response.d.ts.map +1 -0
  140. package/dist/rust-type-emitter.d.ts +32 -0
  141. package/dist/rust-type-emitter.d.ts.map +1 -0
  142. package/dist/secure-headers.d.ts +16 -0
  143. package/dist/secure-headers.d.ts.map +1 -0
  144. package/dist/serve-register.d.ts +2 -0
  145. package/dist/serve-register.d.ts.map +1 -0
  146. package/dist/serve-slot.d.ts +6 -0
  147. package/dist/serve-slot.d.ts.map +1 -0
  148. package/dist/serve.d.ts +21 -0
  149. package/dist/serve.d.ts.map +1 -0
  150. package/dist/server-timing.d.ts +9 -0
  151. package/dist/server-timing.d.ts.map +1 -0
  152. package/dist/static.d.ts +12 -0
  153. package/dist/static.d.ts.map +1 -0
  154. package/dist/telemetry/otel.d.ts +59 -0
  155. package/dist/telemetry/otel.d.ts.map +1 -0
  156. package/dist/testing.d.ts +24 -0
  157. package/dist/testing.d.ts.map +1 -0
  158. package/dist/timeout.d.ts +7 -0
  159. package/dist/timeout.d.ts.map +1 -0
  160. package/dist/tree.d.ts +90 -0
  161. package/dist/tree.d.ts.map +1 -0
  162. package/dist/ts-type-emitter.d.ts +4 -0
  163. package/dist/ts-type-emitter.d.ts.map +1 -0
  164. package/dist/type-emitter.d.ts +8 -0
  165. package/dist/type-emitter.d.ts.map +1 -0
  166. package/dist/type-extractor.d.ts +39 -0
  167. package/dist/type-extractor.d.ts.map +1 -0
  168. package/dist/types.d.ts +451 -0
  169. package/dist/types.d.ts.map +1 -0
  170. package/dist/validation.d.ts +18 -0
  171. package/dist/validation.d.ts.map +1 -0
  172. package/dist/ws/bun.d.ts +28 -0
  173. package/dist/ws/bun.d.ts.map +1 -0
  174. package/dist/ws/cloudflare.d.ts +55 -0
  175. package/dist/ws/cloudflare.d.ts.map +1 -0
  176. package/dist/ws/deno.d.ts +13 -0
  177. package/dist/ws/deno.d.ts.map +1 -0
  178. package/dist/ws/node.d.ts +10 -0
  179. package/dist/ws/node.d.ts.map +1 -0
  180. package/dist/yaml.d.ts +4 -0
  181. package/dist/yaml.d.ts.map +1 -0
  182. package/docs/api-ref/go.md +82 -82
  183. package/docs/api-ref/python.md +82 -82
  184. package/docs/api-ref/rust.md +82 -82
  185. package/docs/api-ref/typescript.md +82 -82
  186. package/docs/invalidate-spec.md +13 -13
  187. package/docs/meta-spec.md +513 -0
  188. package/docs/packaging.md +85 -0
  189. package/docs/sdk.md +87 -73
  190. package/package.json +195 -51
  191. package/src/body-limit.ts +2 -1
  192. package/src/build/index.ts +2 -9
  193. package/src/cli.ts +2 -3
  194. package/src/client/http.ts +204 -223
  195. package/src/client/index.ts +6 -14
  196. package/src/client/sdk.ts +24 -17
  197. package/src/client/types.ts +4 -9
  198. package/src/client/ws.ts +3 -5
  199. package/src/client-mcp/server.ts +1 -4
  200. package/src/cloudflare/realtime.ts +8 -10
  201. package/src/codegen-go-cli.ts +74 -67
  202. package/src/codegen-go.ts +71 -51
  203. package/src/codegen-ir.ts +16 -27
  204. package/src/codegen-loaders.ts +5 -8
  205. package/src/codegen-mcp.ts +9 -27
  206. package/src/codegen-python.ts +47 -27
  207. package/src/codegen-rust.ts +110 -66
  208. package/src/codegen-sanitize.ts +1 -7
  209. package/src/codegen-schema-naming.ts +8 -2
  210. package/src/codegen.ts +299 -196
  211. package/src/context.ts +91 -95
  212. package/src/cookie-sign.ts +5 -13
  213. package/src/cookie.ts +1 -2
  214. package/src/cors.ts +4 -6
  215. package/src/crypto.ts +1 -4
  216. package/src/csrf.ts +3 -3
  217. package/src/curl-logger.ts +14 -32
  218. package/src/detect-runtime.ts +1 -3
  219. package/src/errors.ts +1 -3
  220. package/src/etag.ts +3 -4
  221. package/src/go-type-emitter.ts +45 -40
  222. package/src/honey-response.ts +1 -3
  223. package/src/i18n.ts +3 -12
  224. package/src/index.ts +1168 -1412
  225. package/src/ip-restrict.ts +2 -1
  226. package/src/logger.ts +13 -13
  227. package/src/meta-spec.ts +0 -0
  228. package/src/middleware.ts +111 -79
  229. package/src/node-request.ts +2 -1
  230. package/src/node.ts +9 -10
  231. package/src/openapi/register.ts +1 -2
  232. package/src/openapi/scalar.ts +9 -9
  233. package/src/openapi/spec-factory.ts +2 -2
  234. package/src/openapi/spec.ts +26 -19
  235. package/src/openapi/swagger.ts +9 -9
  236. package/src/plugin.ts +226 -256
  237. package/src/powered-by.ts +2 -1
  238. package/src/pretty-json.ts +2 -1
  239. package/src/proxy.ts +1 -3
  240. package/src/python-type-emitter.ts +37 -12
  241. package/src/realtime/route.ts +1 -1
  242. package/src/realtime/runtime.ts +9 -12
  243. package/src/request-id.ts +3 -4
  244. package/src/request-to-curl.ts +1 -4
  245. package/src/response.ts +150 -199
  246. package/src/rust-type-emitter.ts +66 -25
  247. package/src/secure-headers.ts +2 -1
  248. package/src/serve.ts +3 -12
  249. package/src/server-timing.ts +2 -1
  250. package/src/static.ts +3 -4
  251. package/src/telemetry/otel.ts +1 -6
  252. package/src/testing.ts +2 -11
  253. package/src/timeout.ts +2 -1
  254. package/src/tree.ts +12 -27
  255. package/src/ts-type-emitter.ts +71 -15
  256. package/src/type-emitter.ts +226 -237
  257. package/src/type-extractor.ts +260 -334
  258. package/src/types.ts +168 -68
  259. package/src/validation.ts +7 -30
  260. package/src/ws/bun.ts +2 -9
  261. package/src/ws/cloudflare.ts +13 -16
  262. package/src/ws/deno.ts +31 -40
  263. package/src/ws/node.ts +4 -19
package/dist/tree.d.ts ADDED
@@ -0,0 +1,90 @@
1
+ import type { HttpMethod, InputSchemasDef, OutputSchemaDef } from "./types.ts";
2
+ import type { WSHandler } from "./ws/cloudflare.ts";
3
+ export type { HttpMethod };
4
+ export type OutputValidator = (statusKey: string, data: unknown) => Promise<void>;
5
+ export type RouteHandler = {
6
+ /** cached compiled middleware chain (set lazily at first request) */
7
+ _compiled?: (ctx: object) => Response | Promise<Response>;
8
+ /** internal route — excluded from codegen output */
9
+ _skip?: boolean;
10
+ /** boundary error key — wraps undeclared/unexpected errors (null = use default or internal_server_error) */
11
+ bek: string | null;
12
+ /** pre-computed error factory subset (null = use global factory) */
13
+ ef: Record<string, (...args: never[]) => unknown> | null;
14
+ /** declared error keys for this route — used for runtime enforcement */
15
+ ek: Set<string>;
16
+ /** handler function */
17
+ fn: (ctx: unknown) => Response | Promise<Response>;
18
+ /** input validation schemas (null = no input validation) */
19
+ iv: InputSchemasDef | null;
20
+ /** route metadata — frozen object, accessible via ctx.meta */
21
+ mt: Record<string, unknown> | null;
22
+ /** middleware chain — same as RuntimeMiddleware, inlined to avoid circular dep */
23
+ mw: Array<(ctx: Record<string, unknown>, next: (additions?: Record<string, unknown>) => Promise<Response>) => Promise<Response>>;
24
+ /** output schemas by content-type (null = no output validation) */
25
+ os: OutputSchemaDef | null;
26
+ /** output validator function — validates response body against schema */
27
+ ov: OutputValidator | null;
28
+ /** registered path pattern (e.g. "/users/:id") */
29
+ rp: string;
30
+ };
31
+ export type { OutputSchemaDef };
32
+ export type WSRouteHandler = {
33
+ bek: string | null;
34
+ ek: Set<string>;
35
+ fn: WSHandler<unknown>;
36
+ iv: InputSchemasDef | null;
37
+ mt: Record<string, unknown> | null;
38
+ mw: Array<(ctx: Record<string, unknown>, next: (additions?: Record<string, unknown>) => Promise<Response>) => Promise<Response>>;
39
+ /** registered ws path pattern — used by scoped-mw prefix filter */
40
+ rp: string;
41
+ };
42
+ export type TreeNode = {
43
+ /** dynamic param child — { n: param name, c: child subtree } */
44
+ d: {
45
+ c: TreeNode;
46
+ n: string;
47
+ } | null;
48
+ /** route-graph generation — bumped on insert/merge so served specs can invalidate */
49
+ g?: number;
50
+ /** method handlers — maps HTTP method (or ALL) to route handler */
51
+ m: Record<HttpMethod | "ALL", RouteHandler> | null;
52
+ /** static children — maps literal path segment to child subtree */
53
+ s: Record<string, TreeNode>;
54
+ /** wildcard handler — { n: wildcard name, m: method→handler map } */
55
+ w: {
56
+ m: Record<HttpMethod | "ALL", RouteHandler>;
57
+ n: string;
58
+ } | null;
59
+ /** websocket handler for this path */
60
+ ws: WSRouteHandler | null;
61
+ };
62
+ export declare function bumpGeneration(root: TreeNode): number;
63
+ export type MatchResult = {
64
+ allowed: HttpMethod[];
65
+ matched: false;
66
+ } | {
67
+ handler: RouteHandler;
68
+ matched: true;
69
+ params: Record<string, string>;
70
+ } | null;
71
+ export interface RouteMeta {
72
+ }
73
+ export type RouteTree = {
74
+ handlers?: Record<string, RouteHandler>;
75
+ meta: Record<string, RouteMeta>;
76
+ root: TreeNode;
77
+ };
78
+ export declare function createNode(): TreeNode;
79
+ export declare function insertRoute(root: TreeNode, method: HttpMethod | "ALL", path: string, handler: RouteHandler): void;
80
+ export declare function matchRoute(root: TreeNode, method: HttpMethod, path: string): MatchResult;
81
+ export declare function insertWsRoute(root: TreeNode, path: string, handler: WSRouteHandler): void;
82
+ export declare function matchWsRoute(root: TreeNode, path: string): {
83
+ handler: WSRouteHandler;
84
+ params: Record<string, string>;
85
+ } | null;
86
+ /** Merge source tree nodes into target tree (mutates target) */
87
+ export declare function mergeInto(target: TreeNode, source: TreeNode): void;
88
+ type TreeInput = RouteTree | [RouteTree, Record<string, unknown>];
89
+ export declare function mergeTree(...trees: TreeInput[]): RouteTree;
90
+ //# sourceMappingURL=tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,CAqCpE;AAyED,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CAGlE;AAED,KAAK,SAAS,GAAG,SAAS,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAmBjE,wBAAgB,SAAS,CAAC,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,CAc1D"}
@@ -0,0 +1,4 @@
1
+ /** JSON Schema IR → TypeScript type string emitter. Mirrors jsonSchemaToTS logic case-for-case. */
2
+ import type { IRSchema } from "./codegen-ir.ts";
3
+ export declare function irToTs(ir: IRSchema, depth?: number): string;
4
+ //# sourceMappingURL=ts-type-emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-type-emitter.d.ts","sourceRoot":"","sources":["../src/ts-type-emitter.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AA2E/C,wBAAgB,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,SAAI,GAAG,MAAM,CA8CtD"}
@@ -0,0 +1,8 @@
1
+ import type { StandardSchemaLike } from "./types.ts";
2
+ /**
3
+ * Emit a TypeScript type string from a Standard Schema compatible schema.
4
+ * Supports Zod (+ mini), Valibot, ArkType, Yup, and Effect.
5
+ * Unknown vendors return "unknown".
6
+ */
7
+ export declare function emitSchemaType(schema: StandardSchemaLike): string;
8
+ //# sourceMappingURL=type-emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-emitter.d.ts","sourceRoot":"","sources":["../src/type-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAapD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAQjE"}
@@ -0,0 +1,39 @@
1
+ export type ExtractedBaseCtx = {
2
+ envType: string;
3
+ middlewareType: string | null;
4
+ tapsType: string | null;
5
+ };
6
+ /**
7
+ * Uses ts-morph to extract the middleware context type from a Honey app export.
8
+ * Returns inline type strings so the gen file has zero imports from user code.
9
+ */
10
+ export declare function extractBaseCtx(options: {
11
+ entryPath: string;
12
+ exportName: string;
13
+ outputDir?: string;
14
+ tsconfigPath?: string;
15
+ }): Promise<ExtractedBaseCtx>;
16
+ export type ExtractedChainTypes = {
17
+ base: ExtractedBaseCtx;
18
+ /** per-route middleware additions keyed by "method /path" */
19
+ routeMiddleware: Record<string, string>;
20
+ /** structured per-property middleware data for sub-type dedup */
21
+ routeMiddlewareProps: Record<string, Array<{
22
+ name: string;
23
+ opt: boolean;
24
+ type: string;
25
+ }>>;
26
+ };
27
+ /**
28
+ * Extracts base ctx and per-route middleware additions from sub-chains.
29
+ * Traces HTTP method calls (`.get()`, `.post()`, etc.) back to their
30
+ * Honey instance receiver, computes the ctx diff vs the base export,
31
+ * and returns per-route additions keyed by "method /path".
32
+ */
33
+ export declare function extractChainTypes(options: {
34
+ entryPath: string;
35
+ exportName: string;
36
+ outputDir?: string;
37
+ tsconfigPath?: string;
38
+ }): Promise<ExtractedChainTypes>;
39
+ //# sourceMappingURL=type-extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-extractor.d.ts","sourceRoot":"","sources":["../src/type-extractor.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB,CAAA;AAcD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE;IAC7C,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkE5B;AAoYD,MAAM,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,gBAAgB,CAAA;IACtB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,iEAAiE;IACjE,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAA;CACzF,CAAA;AAID;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAwK/B"}
@@ -0,0 +1,451 @@
1
+ export type HttpMethod = "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
2
+ /** Overwrite keys in T with keys from U -- used by .use() to support narrowing middleware */
3
+ export type Overwrite<T, U> = Omit<T, keyof U> & U;
4
+ export type WSReadyState = 0 | 1 | 2 | 3;
5
+ /** All HTTP status codes 2xx–5xx as snake_case keys */
6
+ export type StatusKey = "accepted" | "already_reported" | "created" | "im_used" | "multi_status" | "no_content" | "non_authoritative_information" | "ok" | "partial_content" | "reset_content" | "found" | "moved_permanently" | "multiple_choices" | "not_modified" | "permanent_redirect" | "see_other" | "temporary_redirect" | "bad_request" | "conflict" | "expectation_failed" | "failed_dependency" | "forbidden" | "gone" | "im_a_teapot" | "length_required" | "locked" | "method_not_allowed" | "misdirected_request" | "not_acceptable" | "not_found" | "content_too_large" | "payment_required" | "precondition_failed" | "precondition_required" | "proxy_authentication_required" | "range_not_satisfiable" | "request_header_fields_too_large" | "request_timeout" | "too_early" | "too_many_requests" | "unauthorized" | "unavailable_for_legal_reasons" | "unprocessable_entity" | "unsupported_media_type" | "upgrade_required" | "uri_too_long" | "bad_gateway" | "gateway_timeout" | "http_version_not_supported" | "insufficient_storage" | "internal_server_error" | "loop_detected" | "network_authentication_required" | "not_extended" | "not_implemented" | "service_unavailable" | "variant_also_negotiates";
7
+ export declare const statusKeyToCode: Record<StatusKey, number>;
8
+ export declare const codeToStatusKey: Record<number, StatusKey>;
9
+ /** Framework error keys — centralized to prevent typo-induced silent failures */
10
+ export declare const EK: {
11
+ readonly bad_gateway: "bad_gateway";
12
+ readonly content_too_large: "content_too_large";
13
+ readonly forbidden: "forbidden";
14
+ readonly gateway_timeout: "gateway_timeout";
15
+ readonly internal_server_error: "internal_server_error";
16
+ readonly method_not_allowed: "method_not_allowed";
17
+ readonly not_found: "not_found";
18
+ readonly output_content_type_mismatch: "output_content_type_mismatch";
19
+ readonly output_validation_failed: "output_validation_failed";
20
+ readonly request_timeout: "request_timeout";
21
+ readonly too_many_requests: "too_many_requests";
22
+ readonly unsupported_media_type: "unsupported_media_type";
23
+ readonly validation_failed: "validation_failed";
24
+ };
25
+ /** Framework status keys — centralized subset of StatusKey used internally */
26
+ export declare const SK: {
27
+ readonly bad_gateway: "bad_gateway";
28
+ readonly bad_request: "bad_request";
29
+ readonly content_too_large: "content_too_large";
30
+ readonly forbidden: "forbidden";
31
+ readonly gateway_timeout: "gateway_timeout";
32
+ readonly internal_server_error: "internal_server_error";
33
+ readonly method_not_allowed: "method_not_allowed";
34
+ readonly not_found: "not_found";
35
+ readonly unprocessable_entity: "unprocessable_entity";
36
+ readonly unsupported_media_type: "unsupported_media_type";
37
+ };
38
+ export type FieldError = {
39
+ error_key: string;
40
+ message: string;
41
+ path: string;
42
+ };
43
+ export declare const EMPTY_OBJ: Record<string, never>;
44
+ export declare const EMPTY_FIELDS: Record<string, FieldError[]>;
45
+ export type NormalizedIssue = {
46
+ code: string;
47
+ message: string;
48
+ meta: {
49
+ expected?: string;
50
+ field?: string;
51
+ max?: number;
52
+ min?: number;
53
+ multipleOf?: number;
54
+ received?: string;
55
+ };
56
+ path: PropertyKey[];
57
+ };
58
+ export type SchemaDefinition = {
59
+ input: unknown;
60
+ output: unknown;
61
+ };
62
+ /**
63
+ * Minimal Standard Schema interface (StandardSchemaV1).
64
+ * Compatible with Zod, Valibot, ArkType, etc.
65
+ */
66
+ export type StandardSchemaLike = {
67
+ readonly "~standard": {
68
+ readonly types?: {
69
+ readonly input: unknown;
70
+ readonly output: unknown;
71
+ } | undefined;
72
+ readonly validate: (value: unknown) => {
73
+ readonly issues?: ReadonlyArray<StandardSchemaIssue> | undefined;
74
+ readonly value?: unknown;
75
+ } | Promise<{
76
+ readonly issues?: ReadonlyArray<StandardSchemaIssue> | undefined;
77
+ readonly value?: unknown;
78
+ }>;
79
+ readonly vendor: string;
80
+ readonly version: number;
81
+ };
82
+ };
83
+ export type StandardSchemaIssue = {
84
+ readonly message: string;
85
+ readonly path?: ReadonlyArray<PropertyKey | {
86
+ readonly key: PropertyKey;
87
+ }> | undefined;
88
+ };
89
+ /** Extract the output type from a Standard Schema compatible schema */
90
+ export type InferOutput<T> = T extends {
91
+ readonly "~standard": {
92
+ readonly types?: infer TTypes;
93
+ };
94
+ } ? NonNullable<TTypes> extends {
95
+ readonly output: infer O;
96
+ } ? O : unknown : unknown;
97
+ /** Map input schema definitions to their inferred output types, dropping undefined keys */
98
+ export type InferInputMap<T> = {
99
+ [K in keyof T as T[K] extends undefined | null ? never : K]-?: InferOutput<UnwrapInputSchema<NonNullable<T[K]>>>;
100
+ };
101
+ /**
102
+ * Extract param names from a route path string.
103
+ * "/users/:id/posts/:postId" → "id" | "postId"
104
+ * Handles optional params (:id?) and wildcards (*name)
105
+ */
106
+ export type ParamKeys<Path extends string> = Path extends `${string}:${infer Param}/${infer Rest}` ? ParamKey<Param> | ParamKeys<`/${Rest}`> : Path extends `${string}:${infer Param}` ? ParamKey<Param> : Path extends `${string}*${infer Name}` ? Name extends "" ? "*" : Name : never;
107
+ type ParamKey<T extends string> = T extends `${infer Name}?` ? Name : T;
108
+ /** Build a params record from a route path string */
109
+ export type ParamsFromPath<Path extends string> = [ParamKeys<Path>] extends [never] ? Record<string, string> : {
110
+ [K in ParamKeys<Path>]: string;
111
+ };
112
+ /** Tagged schema wrapper for runtime behavior control */
113
+ type TaggedSchema = {
114
+ readonly _tag: "readableStream";
115
+ readonly schema: StandardSchemaLike;
116
+ };
117
+ /** A schema entry: plain StandardSchema or wrapped with readableStream() */
118
+ export type InputSchemaEntry = StandardSchemaLike | TaggedSchema;
119
+ /** Unwrap tagged schemas to get the inner StandardSchemaLike for type inference */
120
+ type UnwrapInputSchema<T> = T extends {
121
+ readonly _tag: string;
122
+ readonly schema: infer S;
123
+ } ? S : T;
124
+ /** Non-body input sources — combine freely */
125
+ type InputNonBody = {
126
+ cookies?: InputSchemaEntry;
127
+ headers?: InputSchemaEntry;
128
+ params?: InputSchemaEntry;
129
+ search?: InputSchemaEntry;
130
+ };
131
+ /** Input schema definition — json and form are mutually exclusive (one Content-Type per request) */
132
+ export type InputSchemasDef = (InputNonBody & {
133
+ form?: InputSchemaEntry;
134
+ json?: never;
135
+ }) | (InputNonBody & {
136
+ form?: never;
137
+ json?: InputSchemaEntry;
138
+ });
139
+ /** 2xx-only status keys for output declarations */
140
+ export type SuccessStatusKey = "accepted" | "already_reported" | "created" | "im_used" | "multi_status" | "no_content" | "non_authoritative_information" | "ok" | "partial_content" | "reset_content";
141
+ /** Status-key → schema map for a single content type (2xx only) */
142
+ type StatusSchemaMap = Partial<Record<SuccessStatusKey, StandardSchemaLike>>;
143
+ /** 3xx redirect status keys (excludes not_modified — cache, not redirect) */
144
+ export type RedirectStatusKey = "found" | "moved_permanently" | "multiple_choices" | "permanent_redirect" | "see_other" | "temporary_redirect";
145
+ /** Redirect declaration map — no body schema, just status keys */
146
+ type RedirectSchemaMap = Partial<Record<RedirectStatusKey, true>>;
147
+ /** Output schema definition — maps content-type → status-key → schema */
148
+ export type OutputSchemaDef = {
149
+ "application/cbor"?: StatusSchemaMap;
150
+ "application/json"?: StatusSchemaMap;
151
+ "application/msgpack"?: StatusSchemaMap;
152
+ "application/octet-stream"?: StatusSchemaMap;
153
+ "application/pdf"?: StatusSchemaMap;
154
+ "application/xml"?: StatusSchemaMap;
155
+ redirect?: RedirectSchemaMap;
156
+ "text/csv"?: StatusSchemaMap;
157
+ "text/event-stream"?: StatusSchemaMap;
158
+ "text/html"?: StatusSchemaMap;
159
+ "text/plain"?: StatusSchemaMap;
160
+ };
161
+ /** Maps content-type strings to HoneyRes method names */
162
+ export type ContentTypeMethodMap = {
163
+ "application/json": "json";
164
+ "application/octet-stream": "binary";
165
+ "application/xml": "xml";
166
+ "text/csv": "csv";
167
+ "text/event-stream": "sse";
168
+ "text/html": "html";
169
+ "text/plain": "text";
170
+ };
171
+ /** Methods always available on ctx.res regardless of output declaration */
172
+ export type UniversalResMethods = "noContent" | "raw" | "redirect" | "stream";
173
+ /** Derive allowed response methods from declared output content types */
174
+ export type AllowedResMethods<TOutput> = {
175
+ [CT in keyof ContentTypeMethodMap]: CT extends keyof TOutput ? ContentTypeMethodMap[CT] : never;
176
+ }[keyof ContentTypeMethodMap];
177
+ /** Extract schemas for any content type from an OutputSchemaDef */
178
+ export type ExtractSchemas<T, CT extends string> = T extends {
179
+ [K in CT]: infer S extends Record<string, unknown>;
180
+ } ? S : never;
181
+ /** Extract JSON output schemas from an OutputSchemaDef */
182
+ export type ExtractJsonSchemas<T> = ExtractSchemas<T, "application/json">;
183
+ /** Infer output types from a JSON output schema map */
184
+ export type InferJsonOutputMap<T extends Record<string, StandardSchemaLike>> = {
185
+ [K in keyof T]: InferOutput<T[K]>;
186
+ };
187
+ /** OpenAPI operation-level metadata (also serves as built-in meta base) */
188
+ export type OpenApiMeta = {
189
+ internal?: boolean;
190
+ deprecated?: boolean;
191
+ description?: string;
192
+ /** Escape hatch — emitted verbatim at the highest precedence. Prefer a `.metaSpec()` entry. */
193
+ extensions?: Record<`x-${string}`, unknown>;
194
+ invalidate?: readonly string[] | null;
195
+ mcp?: boolean;
196
+ operationId?: string;
197
+ security?: Array<Record<string, string[]>> | string | string[];
198
+ summary?: string;
199
+ tags?: string | string[];
200
+ };
201
+ /** Which operation kinds a policy entry applies to */
202
+ export type MetaSpecTarget = "both" | "http" | "ws";
203
+ /** Where a schema-derived policy entry reads its source key from */
204
+ export type MetaSpecSchemaSource = "input.cookies" | "input.form" | "input.headers" | "input.json" | "input.search" | "output";
205
+ /** Passed to a policy entry's `map` / `expand` */
206
+ export type MetaSpecContext = {
207
+ meta: Record<string, unknown>;
208
+ method: string;
209
+ path: string;
210
+ profile: string;
211
+ /** Where the source value came from — `"meta"`, or the schema source for schema entries */
212
+ source: "meta" | MetaSpecSchemaSource;
213
+ };
214
+ type MetaSpecEntryBase = {
215
+ /** Which operation kinds this entry applies to. Default `"both"` */
216
+ on?: MetaSpecTarget;
217
+ /** Restrict this entry to named profiles. Default: every profile */
218
+ profiles?: readonly string[];
219
+ /** Validates the produced value at codegen time. A failure is a build error */
220
+ schema?: StandardSchemaLike;
221
+ };
222
+ /** Policy entry writing one operation key */
223
+ export type MetaSpecSingle<TValue = unknown> = MetaSpecEntryBase & {
224
+ /** Target operation key — an `x-*` extension or an allowed standard field */
225
+ key: string;
226
+ /** Transform the source value. Returning `undefined` omits the key for that operation */
227
+ map?: (value: TValue, ctx: MetaSpecContext) => unknown;
228
+ };
229
+ /** Policy entry fanning one source value out to several operation keys */
230
+ export type MetaSpecExpand<TValue = unknown> = MetaSpecEntryBase & {
231
+ /** Returns operation keys → values. `undefined` (returned or per key) omits */
232
+ expand: (value: TValue, ctx: MetaSpecContext) => Record<string, unknown> | undefined;
233
+ };
234
+ /** One policy entry: hidden (`false`), verbatim (`"x-foo"`), single target, or fan-out */
235
+ export type MetaSpecEntry<TValue = unknown> = false | MetaSpecExpand<TValue> | MetaSpecSingle<TValue> | string;
236
+ /**
237
+ * How deeply to look for a schema-metadata key.
238
+ * `"root"` reads the schema root, reading through one level of `items` for a bare array output.
239
+ * `"deep"` walks the schema (properties, items, composition members) and takes the shallowest
240
+ * match — for envelope shapes like `{ articles: [Article], nextCursor, count }`.
241
+ */
242
+ export type MetaSpecSchemaSearch = "deep" | "root";
243
+ /** Refuse a descriptor whose publisher contract version is newer than this policy understands */
244
+ export type MetaSpecVersionGuard = {
245
+ /** Field carrying the contract version. Default `"v"` */
246
+ field?: string;
247
+ /** Highest version this entry's `map`/`expand` was written against */
248
+ max: number;
249
+ };
250
+ /**
251
+ * Policy entry reading its source key off a route schema instead of route meta.
252
+ *
253
+ * The object key names the entry; `read` says which schema-metadata key it reads, so several
254
+ * entries can read one reserved key — the shape a publisher takes when it stamps a
255
+ * discriminated union under a single key.
256
+ */
257
+ export type MetaSpecSchemaEntry<TValue = unknown> = (MetaSpecExpand<TValue> | MetaSpecSingle<TValue>) & {
258
+ /** Schema sources to search, in order. First one carrying a matching descriptor wins */
259
+ from?: readonly MetaSpecSchemaSource[];
260
+ /**
261
+ * Shallow subset the descriptor must satisfy for this entry to claim it — the discriminant
262
+ * of a union, e.g. `{ kind: "entity" }`. A descriptor found under `read` that satisfies no
263
+ * entry's `match` is a build error, never a silently missing tag.
264
+ */
265
+ match?: Record<string, unknown>;
266
+ /** Schema-metadata key to read. Defaults to this entry's own name */
267
+ read?: string;
268
+ /** Where in the schema to look. Default `"root"` */
269
+ search?: MetaSpecSchemaSearch;
270
+ /** Fail the build on a descriptor from a newer publisher contract than this entry handles */
271
+ version?: MetaSpecVersionGuard;
272
+ };
273
+ /** Per-document filter over emitted operation keys */
274
+ export type MetaSpecProfile = {
275
+ /** Denylist of emitted keys */
276
+ exclude?: readonly string[];
277
+ /** Allowlist of emitted `x-*` keys — standard fields are always kept unless excluded */
278
+ include?: readonly string[];
279
+ };
280
+ /** How an unmapped meta key is reported at codegen time */
281
+ export type MetaSpecStrictness = "error" | "off" | "warn";
282
+ type MetaSpecSections<TMetaSection> = {
283
+ /** Route-meta entries, keyed by meta key */
284
+ meta?: TMetaSection;
285
+ /** Named per-document filters. `"default"` filters nothing */
286
+ profiles?: Record<string, MetaSpecProfile>;
287
+ /** Schema-derived entries, keyed by the key read off the schema's metadata */
288
+ schema?: Record<string, MetaSpecSchemaEntry<never>>;
289
+ /** How to report a meta key with no entry. Default `"error"` */
290
+ strict?: MetaSpecStrictness;
291
+ };
292
+ /** Built-in meta keys ship with a default policy — overriding them is optional */
293
+ type MetaSpecOptionalKeys<TMeta> = {
294
+ [K in Extract<keyof TMeta, keyof OpenApiMeta>]?: MetaSpecEntry<Exclude<TMeta[K], undefined>>;
295
+ };
296
+ /** Every app-defined meta key must have an entry — a missing key is a type error */
297
+ type MetaSpecRequiredKeys<TMeta> = {
298
+ [K in Exclude<keyof TMeta, keyof OpenApiMeta>]-?: MetaSpecEntry<Exclude<TMeta[K], undefined>>;
299
+ };
300
+ /** Declarative policy for what flows from route meta and route schemas into the document */
301
+ export type HoneyMetaSpec<TMeta = unknown> = [TMeta] extends [never] ? MetaSpecSections<Record<string, MetaSpecEntry>> : TMeta extends Record<string, unknown> ? MetaSpecSections<MetaSpecOptionalKeys<TMeta> & MetaSpecRequiredKeys<TMeta>> : MetaSpecSections<Record<string, MetaSpecEntry>>;
302
+ /** Erased runtime shape of a resolved policy — what codegen consumes */
303
+ export type MetaSpecConfig = {
304
+ meta?: Record<string, MetaSpecEntry>;
305
+ profiles?: Record<string, MetaSpecProfile>;
306
+ schema?: Record<string, MetaSpecSchemaEntry>;
307
+ strict?: MetaSpecStrictness;
308
+ };
309
+ /** Built-in meta shape — always available on .meta() */
310
+ export type DefaultMeta = OpenApiMeta;
311
+ /** Augmented by generated code per-app to narrow invalidate selectors */
312
+ export interface HoneyCodegen {
313
+ }
314
+ type ResolveSelector = HoneyCodegen extends {
315
+ routeSelector: infer R;
316
+ } ? (R extends string ? R : string) : string;
317
+ /** Utility: merges built-in meta, custom meta T, and type-safe invalidate from codegen */
318
+ export type HoneyMeta<T = {}> = DefaultMeta & T & {
319
+ invalidate?: readonly ResolveSelector[] | null;
320
+ };
321
+ /** Accumulated route schema entry for RPC client generation */
322
+ export type RouteRecord<TMethod extends string, TPath extends string, TInput, TOutput, TCtx = unknown, TErrors extends string = never, TErrorsByStatus = never> = {
323
+ [P in TPath]: {
324
+ [M in Lowercase<TMethod>]: {
325
+ ctx: TCtx;
326
+ errors: TErrors;
327
+ errorsByStatus: TErrorsByStatus;
328
+ input: TInput;
329
+ output: TOutput;
330
+ };
331
+ };
332
+ };
333
+ /** Merge a new route record into accumulated routes via flat intersection */
334
+ export type MergeRoute<TRoutes, TPath extends string, TMethod extends string, TInput, TOutput, TCtx, TMeta = {}, TErrors extends string = never, TErrorsByStatus = never> = TRoutes & {
335
+ [P in TPath]: {
336
+ [M in Lowercase<TMethod>]: {
337
+ ctx: TCtx;
338
+ errors: TErrors;
339
+ errorsByStatus: TErrorsByStatus;
340
+ input: TInput;
341
+ meta: TMeta;
342
+ output: TOutput;
343
+ };
344
+ };
345
+ };
346
+ /** Extract accumulated routes from a Honey instance type */
347
+ export type InferRoutes<T> = T extends {
348
+ readonly $routes: infer R;
349
+ } ? R : never;
350
+ /** Extract accumulated middleware context. `res` is omitted so handler ctx is assignable into services. Use InferRouteCtx for the route's constrained `res`. */
351
+ export type InferCtx<T> = T extends {
352
+ readonly $ctx: infer TCtx;
353
+ } ? Omit<TCtx, "res"> : never;
354
+ /** Extract environment type (TEnv) from a Honey instance */
355
+ export type InferEnv<T> = T extends {
356
+ readonly $env: infer TEnv;
357
+ } ? TEnv : never;
358
+ /** All HTTP methods used across all routes */
359
+ export type InferMethods<T> = InferRoutes<T> extends infer R ? {
360
+ [P in keyof R]: keyof R[P] & string;
361
+ }[keyof R] : never;
362
+ /** Available route paths registered on a Honey instance */
363
+ export type InferRoutePaths<T> = keyof InferRoutes<T> & string;
364
+ /** Available methods for a given path ("get", "post", etc.) */
365
+ export type InferRouteMethods<T, TPath extends InferRoutePaths<T>> = InferRoutes<T>[TPath] extends infer M ? keyof M & string : never;
366
+ /** Lookup a specific route's record from the accumulated route map */
367
+ type RouteLookup<T, TPath extends string, TMethod extends string> = InferRoutes<T> extends infer R ? TPath extends keyof R ? R[TPath] extends infer Methods ? TMethod extends keyof Methods ? Methods[TMethod] : never : never : never : never;
368
+ /** Extract the meta type generic (TMeta) from a Honey instance */
369
+ export type InferMeta<T> = T extends {
370
+ readonly $meta: infer M;
371
+ } ? M : never;
372
+ /** Extract the full handler context type for a specific route */
373
+ export type InferRouteCtx<T, TPath extends InferRoutePaths<T>, TMethod extends InferRouteMethods<T, TPath>> = RouteLookup<T, TPath, TMethod> extends {
374
+ ctx: infer C;
375
+ } ? C : never;
376
+ /** Extract input type for a specific route */
377
+ export type InferRouteInput<T, TPath extends InferRoutePaths<T>, TMethod extends InferRouteMethods<T, TPath>> = RouteLookup<T, TPath, TMethod> extends {
378
+ input: infer I;
379
+ } ? I : never;
380
+ /** Extract meta type for a specific route */
381
+ export type InferRouteMeta<T, TPath extends InferRoutePaths<T>, TMethod extends InferRouteMethods<T, TPath>> = RouteLookup<T, TPath, TMethod> extends {
382
+ meta: infer M;
383
+ } ? M : never;
384
+ /** Extract output type for a specific route */
385
+ export type InferRouteOutput<T, TPath extends InferRoutePaths<T>, TMethod extends InferRouteMethods<T, TPath>> = RouteLookup<T, TPath, TMethod> extends {
386
+ output: infer O;
387
+ } ? O : never;
388
+ /** Extract error keys for a specific route */
389
+ export type InferRouteErrors<T, TPath extends InferRoutePaths<T>, TMethod extends InferRouteMethods<T, TPath>> = RouteLookup<T, TPath, TMethod> extends {
390
+ errors: infer E;
391
+ } ? E : never;
392
+ /** Extract the error factory type from a Honey instance */
393
+ export type InferErrorFactory<T> = T extends {
394
+ readonly $errorFactory: infer F;
395
+ } ? F : never;
396
+ /**
397
+ * Compute errorsByStatus from error factory + declared error keys.
398
+ * Maps status codes to body shapes for client-side discrimination.
399
+ */
400
+ export type ComputeErrorsByStatus<TFactory, TErrorKeys extends string, TMetaSymbol extends symbol> = TFactory extends {
401
+ readonly [K in TMetaSymbol]: infer TMeta;
402
+ } ? TMeta extends Record<string, {
403
+ schema: infer _S;
404
+ statusKey: infer _SK;
405
+ }> ? _BuildByStatus<TMeta, TErrorKeys> : never : never;
406
+ /** Internal: build { [statusCode]: bodyShape } from meta + error keys */
407
+ type _BuildByStatus<TMeta extends Record<string, {
408
+ schema: unknown;
409
+ statusKey: unknown;
410
+ }>, TKeys extends string> = {
411
+ [SK in _UsedStatusKeys<TMeta, TKeys> & StatusKey as StatusKeyToCodeType<SK>]: _ShapesForStatus<TMeta, TKeys, SK>;
412
+ };
413
+ /** Internal: collect all statusKeys used by the declared error keys */
414
+ type _UsedStatusKeys<TMeta extends Record<string, {
415
+ schema: unknown;
416
+ statusKey: unknown;
417
+ }>, TKeys extends string> = TKeys extends keyof TMeta ? TMeta[TKeys]["statusKey"] : never;
418
+ /** Internal: union of shapes for all error keys that map to a given statusKey */
419
+ type _ShapesForStatus<TMeta extends Record<string, {
420
+ schema: unknown;
421
+ statusKey: unknown;
422
+ }>, TKeys extends string, TSK extends StatusKey> = TKeys extends keyof TMeta ? TMeta[TKeys]["statusKey"] extends TSK ? TMeta[TKeys]["schema"] extends StandardSchemaLike ? InferOutput<TMeta[TKeys]["schema"]> : null : never : never;
423
+ /** Map StatusKey string to numeric status code at the type level */
424
+ type StatusKeyToCodeType<SK extends StatusKey> = SK extends "ok" ? 200 : SK extends "created" ? 201 : SK extends "accepted" ? 202 : SK extends "no_content" ? 204 : SK extends "bad_request" ? 400 : SK extends "unauthorized" ? 401 : SK extends "payment_required" ? 402 : SK extends "forbidden" ? 403 : SK extends "not_found" ? 404 : SK extends "method_not_allowed" ? 405 : SK extends "not_acceptable" ? 406 : SK extends "conflict" ? 409 : SK extends "gone" ? 410 : SK extends "unprocessable_entity" ? 422 : SK extends "too_many_requests" ? 429 : SK extends "internal_server_error" ? 500 : SK extends "not_implemented" ? 501 : SK extends "bad_gateway" ? 502 : SK extends "service_unavailable" ? 503 : SK extends "gateway_timeout" ? 504 : number;
425
+ /** Extract the base path type from a Honey instance */
426
+ export type InferBasePath<T> = T extends {
427
+ readonly $basePath: infer P;
428
+ } ? P : never;
429
+ /** Merge two path segments — "/" is identity */
430
+ export type MergePath<A extends string, B extends string> = A extends "/" ? B : B extends "/" ? A : `${A}${B}`;
431
+ /** Queued side-effect emitted by c.tap() inside a handler */
432
+ export type PendingTap = {
433
+ key: string;
434
+ payload: unknown;
435
+ };
436
+ /** Handler registered via app.tap(key, handler) — receives context + payload */
437
+ export type TapHandler<TEnv = unknown> = (ctx: TapContext<TEnv>, payload: unknown) => void | Promise<void>;
438
+ /** Subset of HoneyContext exposed to tap handlers — no res, no recursive tap */
439
+ export type TapContext<TEnv = unknown> = {
440
+ readonly background: (p: Promise<unknown>) => void;
441
+ readonly env: TEnv;
442
+ readonly headers: Record<string, string>;
443
+ readonly meta: Record<string, unknown>;
444
+ readonly params: Record<string, string>;
445
+ readonly path: string;
446
+ readonly req: Request;
447
+ readonly routePattern: string;
448
+ readonly search: Record<string, string>;
449
+ };
450
+ export {};
451
+ //# sourceMappingURL=types.d.ts.map