@springbrand/http 0.1.0-alpha.3 → 0.1.0-alpha.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.
@@ -15,6 +15,7 @@ Read the installed declarations and README before configuring a client. Public e
15
15
  | @springbrand/http/query | Optional TanStack React Query integration |
16
16
  | @springbrand/http/catalog | Project error catalog: typed HttpError, Zod response schemas, client decoder (zod peer) |
17
17
  | @springbrand/http/hono | Hono responders with TypedResponse types for zod-openapi (hono peer) |
18
+ | @springbrand/http/types | Type-only entry for every public type, so consumers emitting declarations stay portable |
18
19
  | @springbrand/http/server | Standard Response helpers, bounded body reading, If-Match, Content-Disposition, log diagnostics and service authentication |
19
20
 
20
21
  ## Client setup
package/README.md CHANGED
@@ -20,6 +20,7 @@ pnpm add @springbrand/http@alpha
20
20
  | `@springbrand/http/query` | createHttpQueryClient、读取重试策略 |
21
21
  | `@springbrand/http/catalog` | defineErrorCatalog:项目错误码目录、HttpError、Zod Schema、客户端解码 |
22
22
  | `@springbrand/http/hono` | createHonoHttp:ok、httpError 等带 TypedResponse 类型的 Hono 响应 |
23
+ | `@springbrand/http/types` | 只含类型的入口:公共 API 用到的全部类型,供开启 declaration 的使用方生成可移植的声明文件 |
23
24
  | `@springbrand/http/server` | ok、fail、toErrorResponse、请求体限长读取、If-Match、Content-Disposition、服务鉴权与日志诊断 |
24
25
 
25
26
  客户端依赖 Axios。Query、catalog、hono 是独立入口,分别以 `@tanstack/react-query`、`zod`、`hono` 作为可选 peer;只用到哪个入口才需要安装对应依赖,核心和 server 入口都不需要。服务端要求标准 Request、Response 和 Web Crypto,建议 Node.js 24 或兼容运行时。
package/dist/catalog.d.ts CHANGED
@@ -16,7 +16,7 @@ export type ServerErrorCode<D extends ErrorDefinitions> = {
16
16
  export type DetailSchemas<D extends ErrorDefinitions> = {
17
17
  readonly [K in ServerErrorCode<D>]?: z.ZodType;
18
18
  };
19
- type DetailsOf<S, C> = C extends keyof S ? S[C] extends z.ZodType ? z.output<S[C]> : undefined : undefined;
19
+ export type DetailsOf<S, C> = C extends keyof S ? S[C] extends z.ZodType ? z.output<S[C]> : undefined : undefined;
20
20
  export type HttpErrorOptions<T> = ErrorOptions & {
21
21
  errors?: FieldError[];
22
22
  details?: T;
@@ -111,4 +111,3 @@ export declare function defineErrorCatalog<const D extends ErrorDefinitions & Re
111
111
  }, z.core.$strip>;
112
112
  };
113
113
  export type ErrorCatalogOf<D extends ErrorDefinitions & Record<RequiredErrorCode, ErrorDefinition>, S extends DetailSchemas<D> = Record<never, never>> = ReturnType<typeof defineErrorCatalog<D, S>>;
114
- export {};
package/dist/hono.d.ts CHANGED
@@ -4,19 +4,19 @@ import type { ContentfulStatusCode } from "hono/utils/http-status";
4
4
  import type { ErrorDefinition, ErrorDefinitions, RequiredErrorCode } from "./catalog.js";
5
5
  import type { ApiError } from "./errors.js";
6
6
  import type { FieldError } from "./types.js";
7
- type CatalogError<D extends ErrorDefinitions, C extends keyof D & string> = ApiError & {
7
+ export type CatalogError<D extends ErrorDefinitions, C extends keyof D & string> = ApiError & {
8
8
  readonly code: C;
9
9
  readonly status: D[C]["status"];
10
10
  };
11
- type SuccessResponse<T, S extends 200 | 201 | 202> = Response & TypedResponse<JSONParsed<{
11
+ export type SuccessResponse<T, S extends 200 | 201 | 202> = Response & TypedResponse<JSONParsed<{
12
12
  success: true;
13
13
  msg: T;
14
14
  errMsg: "";
15
15
  code: "";
16
16
  }>, S, "json">;
17
- type ErrorStatus<D extends ErrorDefinitions, C extends keyof D> = D[C]["status"] & ContentfulStatusCode;
17
+ export type ErrorStatus<D extends ErrorDefinitions, C extends keyof D> = D[C]["status"] & ContentfulStatusCode;
18
18
  /** 显式写出响应类型:让 Hono 在泛型 C 未确定时推导 JSONParsed,会在声明文件里丢掉 code 字段。 */
19
- type ErrorResponse<D extends ErrorDefinitions, C extends keyof D & string> = Response & TypedResponse<{
19
+ export type ErrorResponse<D extends ErrorDefinitions, C extends keyof D & string> = Response & TypedResponse<{
20
20
  errMsg: string;
21
21
  code: C;
22
22
  requestId?: string;
@@ -47,4 +47,3 @@ export declare function createHonoHttp<const D extends ErrorDefinitions & Record
47
47
  httpInternalError: (c: Context, message?: string) => ErrorResponse<D, "INTERNAL_ERROR">;
48
48
  httpValidationError(c: Context, errors: FieldError[]): ErrorResponse<D, "REQUEST_VALIDATION_FAILED">;
49
49
  };
50
- export {};
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { ApiError, errorDefinitions, isApiError, isRequestCancelled, isTransientHttpError } from "./errors.js";
2
2
  export type { ApiErrorOptions, ApiErrorKind } from "./errors.js";
3
- export type { ApiSuccessResponse, HttpErrorResponse, FieldError, HttpResult, ErrorContext, RequestNotice, RequestFailure, HttpClientConfig, HttpMessages, HttpRequestOptions, HttpMethod, ResponseMode } from "./types.js";
3
+ export type { ApiSuccessResponse, HttpErrorResponse, FieldError, HttpResult, ErrorContext, RequestContext, RequestNotice, RequestFailure, ResponseInfo, HttpClientConfig, HttpMessages, HttpRequestOptions, HttpMethod, ResponseMode, Feedback, FeedbackOwner, QueryScalar, UploadProgress, } from "./types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@springbrand/http",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -53,8 +53,18 @@
53
53
  "import": "./dist/server/index.js",
54
54
  "default": "./dist/server/index.js"
55
55
  },
56
+ "./types": {
57
+ "types": "./dist/types.d.ts"
58
+ },
56
59
  "./package.json": "./package.json"
57
60
  },
61
+ "scripts": {
62
+ "build": "vite build && tsc -p tsconfig.build.json",
63
+ "watch": "vite build --watch",
64
+ "typecheck": "tsc --noEmit",
65
+ "lint": "eslint src tests --ext ts --max-warnings 0",
66
+ "test": "vitest run"
67
+ },
58
68
  "dependencies": {
59
69
  "axios": "1.20.0",
60
70
  "content-disposition": "2.0.1"
@@ -85,12 +95,5 @@
85
95
  "vite": "^5.4.19",
86
96
  "vitest": "3.2.6",
87
97
  "zod": "4.6.5"
88
- },
89
- "scripts": {
90
- "build": "vite build && tsc -p tsconfig.build.json",
91
- "watch": "vite build --watch",
92
- "typecheck": "tsc --noEmit",
93
- "lint": "eslint src tests --ext ts --max-warnings 0",
94
- "test": "vitest run"
95
98
  }
96
- }
99
+ }