@faapi/faapi 6.20.0 → 6.21.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.
@@ -777,7 +777,9 @@ type TaskFailedHandler = (info: TaskFailedInfo) => Promise<void> | void;
777
777
  *
778
778
  * 与 ctx 的集成:
779
779
  * - ctx.sse() 调用 createSseWriter(),并把 response 缓存到 ctx 内部字段
780
- * - invokeHandler 在 handler 返回后检查 ctx 是否持有 SSE response,有则优先使用
780
+ * - 首次写入(send/sendRaw/sendError)经 onFirstWrite 触发 server 层提前接管钩子,
781
+ * 响应立即接入底层连接(流式即产即达);无钩子场景回落为 handler 返回后由
782
+ * invokeHandler 检查 ctx 持有的 SSE response,有则优先使用
781
783
  */
782
784
  /**
783
785
  * SSE 事件字段
@@ -931,14 +933,52 @@ interface FaapiContext {
931
933
  log: Logger;
932
934
  request: Request;
933
935
  /**
934
- * 动态路由参数
936
+ * 动态路由参数(校验转换后的值)
935
937
  *
936
- * handler 声明了 `params: XxxParams` 类型时,管线按声明类型校验并回写
937
- * 转换后的值(number/boolean 字段不再是字符串);未声明时保持 URL 原始
938
- * 字符串。以 handler 形参上的接口声明为准读取(注入即本对象)。
938
+ * 路由匹配后挂载 URL 原始段;handler 声明了 `params: XxxParams` 类型时,管线
939
+ * 按声明类型校验并回写转换后的值(number/boolean 字段不再是字符串,catch-all
940
+ * 等声明之外的段保留原始值);未声明时保持 URL 原始字符串。以 handler 形参上的
941
+ * 接口声明为准读取(注入即本对象)。需要恒原始的段用 rawParams。
939
942
  */
940
943
  params: Record<string, string | number | boolean>;
941
- query: URLSearchParams;
944
+ /**
945
+ * 动态路由参数的原始值(恒为 URL 字符串,管线永不覆盖)
946
+ *
947
+ * 与 ctx.params 同点挂载(路由匹配后),转换/校验不触及。校验失败(422)时
948
+ * 中间件也可用它拿到请求的原始路径段。
949
+ */
950
+ rawParams: Record<string, string>;
951
+ /**
952
+ * URL 查询参数(校验转换后的值)
953
+ *
954
+ * createContext 时挂原始 query 对象(string 值,重复 key 为数组);handler
955
+ * 声明 `query: XxxQuery` 时管线校验并替换为转换值(声明字段 coerce,未声明
956
+ * 字段保留原始字符串);未声明时保持原始对象。与 handler 的 query 注入是
957
+ * 同一对象。需要恒原始的形态用 rawQuery。
958
+ */
959
+ query: Record<string, unknown>;
960
+ /**
961
+ * URL 查询参数的原始值(恒为 URLSearchParams,管线永不覆盖)
962
+ *
963
+ * `rawQuery.get('page')` 恒返回字符串形态。与 ctx.query(转换后对象)互补。
964
+ */
965
+ rawQuery: URLSearchParams;
966
+ /**
967
+ * 请求体的原始文本(body 类方法才有值)
968
+ *
969
+ * POST/PUT/PATCH/DELETE 的 body 解析时挂载:JSON 请求体为未解析的原始字符串
970
+ * (签名验签场景),form-urlencoded 为原始编码文本;GET/HEAD 及 multipart
971
+ * 请求体恒为 undefined(请求体流只能消费一次,全局中间件 await next() 之前
972
+ * 不可读;multipart 是二进制流无文本形态)。
973
+ */
974
+ rawBody?: string;
975
+ /**
976
+ * 请求体(校验转换后的值)
977
+ *
978
+ * 管线校验通过后挂载,与 handler 的 body 注入是同一对象(目录中间件可借此
979
+ * 在 handler 之前读取请求体);GET/HEAD 恒 undefined。
980
+ */
981
+ body?: unknown;
942
982
  headers: Headers;
943
983
  method: string;
944
984
  path: string;
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as FaapiContext, F as FaapiMiddleware, I as InjectorMap, R as RouteManifest, W as WsRouteManifest, C as CorsOptions, H as HelmetOptions } from './routeTypes-DTqdo28V.js';
1
+ import { a as FaapiContext, F as FaapiMiddleware, I as InjectorMap, R as RouteManifest, W as WsRouteManifest, C as CorsOptions, H as HelmetOptions } from './routeTypes-gyz4PMh7.js';
2
2
  import { Server } from 'node:http';
3
3
  import { WebSocket } from 'ws';
4
4