@longzai-intelligence-transport/http-core 0.1.3 → 0.1.4
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.
- package/dist/index.d.ts +9 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -620,7 +620,10 @@ type InferRouteBody<T extends RouteDefinition> = T extends JsonResponseRoute<Htt
|
|
|
620
620
|
/**
|
|
621
621
|
* 从路由定义中推断响应数据类型
|
|
622
622
|
*
|
|
623
|
-
* 自动解包 ApiResponse 和 PaginatedResponse
|
|
623
|
+
* 自动解包 ApiResponse 和 PaginatedResponse。
|
|
624
|
+
* 对联合别名形态鲁棒:当 T 为 tsgo/tsc 类型规范化产物(RouteDefinition 联合别名)时,
|
|
625
|
+
* JSON 路由不联合 BinaryStreamMarker,stream 路由保留 BinaryStreamMarker(不退化为 unknown)。
|
|
626
|
+
* 实现详见 ADR-0005。
|
|
624
627
|
*
|
|
625
628
|
* @example
|
|
626
629
|
* type Data = InferRouteResponse<typeof routes.detail>;
|
|
@@ -628,15 +631,13 @@ type InferRouteBody<T extends RouteDefinition> = T extends JsonResponseRoute<Htt
|
|
|
628
631
|
*
|
|
629
632
|
* @typeParam T - 路由定义类型
|
|
630
633
|
*/
|
|
631
|
-
type InferRouteResponse<T extends RouteDefinition> = T extends
|
|
632
|
-
responseType: 'stream';
|
|
633
|
-
} ? BinaryStreamMarker : T extends {
|
|
634
|
-
response: infer R;
|
|
635
|
-
} ? R extends ZodType ? ExtractData<R['_output']> : never : never;
|
|
634
|
+
type InferRouteResponse<T extends RouteDefinition> = [Extract<T, JsonResponseRoute>] extends [never] ? BinaryStreamMarker : Extract<T, JsonResponseRoute> extends JsonResponseRoute<HttpMethod, string, ZodType | undefined, ZodType | undefined, ZodType | undefined, infer R> ? [ZodType] extends [R] ? BinaryStreamMarker : ExtractData<R['_output']> : never;
|
|
636
635
|
/**
|
|
637
636
|
* 从路由定义中推断完整的响应类型
|
|
638
637
|
*
|
|
639
|
-
* 包含 ApiResponse
|
|
638
|
+
* 包含 ApiResponse 包装。
|
|
639
|
+
* 对联合别名形态鲁棒:JSON 路由不联合 BinaryStreamMarker,stream 路由保留 BinaryStreamMarker。
|
|
640
|
+
* 实现详见 ADR-0005。
|
|
640
641
|
*
|
|
641
642
|
* @example
|
|
642
643
|
* type Response = InferRouteFullResponse<typeof routes.detail>;
|
|
@@ -644,11 +645,7 @@ type InferRouteResponse<T extends RouteDefinition> = T extends {
|
|
|
644
645
|
*
|
|
645
646
|
* @typeParam T - 路由定义类型
|
|
646
647
|
*/
|
|
647
|
-
type InferRouteFullResponse<T extends RouteDefinition> = T extends
|
|
648
|
-
responseType: 'stream';
|
|
649
|
-
} ? BinaryStreamMarker : T extends {
|
|
650
|
-
response: infer R;
|
|
651
|
-
} ? R extends ZodType ? ApiResponse<ExtractData<R['_output']>> : never : never;
|
|
648
|
+
type InferRouteFullResponse<T extends RouteDefinition> = [Extract<T, JsonResponseRoute>] extends [never] ? BinaryStreamMarker : Extract<T, JsonResponseRoute> extends JsonResponseRoute<HttpMethod, string, ZodType | undefined, ZodType | undefined, ZodType | undefined, infer R> ? [ZodType] extends [R] ? BinaryStreamMarker : ApiResponse<ExtractData<R['_output']>> : never;
|
|
652
649
|
/**
|
|
653
650
|
* 从路由定义中推断分页响应的项类型
|
|
654
651
|
*
|