@h-ai/api-contract 0.1.0-alpha.66 → 0.1.0-alpha.68
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/README.en.md +29 -9
- package/README.ja.md +30 -10
- package/README.md +30 -10
- package/dist/ai/index.d.ts +981 -200
- package/dist/ai/index.js +2 -2
- package/dist/{chunk-RVSGP2GF.js → chunk-G3SME6V5.js} +4 -5
- package/dist/chunk-G3SME6V5.js.map +1 -0
- package/dist/{chunk-VSPYX4DD.js → chunk-G55ATYDA.js} +64 -39
- package/dist/chunk-G55ATYDA.js.map +1 -0
- package/dist/{chunk-3QSKWVLP.js → chunk-IVZVAWEF.js} +30 -17
- package/dist/chunk-IVZVAWEF.js.map +1 -0
- package/dist/{chunk-CUU2F6YD.js → chunk-JKPLID6E.js} +2 -2
- package/dist/chunk-JKPLID6E.js.map +1 -0
- package/dist/{chunk-JIQINMLG.js → chunk-R5GDWFYC.js} +7 -7
- package/dist/chunk-R5GDWFYC.js.map +1 -0
- package/dist/iam/index.d.ts +845 -32
- package/dist/iam/index.js +2 -2
- package/dist/index.d.ts +196 -89
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/payment/index.d.ts +218 -28
- package/dist/payment/index.js +2 -2
- package/dist/storage/index.d.ts +414 -161
- package/dist/storage/index.js +2 -2
- package/package.json +3 -2
- package/dist/chunk-3QSKWVLP.js.map +0 -1
- package/dist/chunk-CUU2F6YD.js.map +0 -1
- package/dist/chunk-JIQINMLG.js.map +0 -1
- package/dist/chunk-RVSGP2GF.js.map +0 -1
- package/dist/chunk-VSPYX4DD.js.map +0 -1
package/README.en.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[Framework home](../../README.en.md) · Related modules: [@h-ai/core](../core/README.en.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Introduction
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Public HTTP API contracts for hai-framework, with oRPC contract + Zod as the single source of truth.
|
|
10
|
+
|
|
11
|
+
## Core features
|
|
10
12
|
|
|
11
13
|
- `apiContract.iam`, `apiContract.storage`, `apiContract.ai`, `apiContract.payment`: domain contracts.
|
|
12
14
|
- `apiContract.create()`: compose enabled domain contracts for an application.
|
|
@@ -17,7 +19,11 @@
|
|
|
17
19
|
- IAM token DTOs support httpOnly cookies: `refreshToken` may be absent from the response body and managed by the server through `Set-Cookie`.
|
|
18
20
|
- IAM `auth.currentUser` returns the user profile and the current server session's `roles` / `permissions`; clients need not persist a permission snapshot to restore a session.
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
Payment creation inputs and outputs accept WeChat `jsapi`, Alipay `h5`, and Stripe `h5` only; WeChat requires `userId` (openid). App, Native, mini-program, and other combinations fail validation. Alipay returns `{ gateway, fields }` page parameters; creation success does not establish payment. See [Payment](../payment/README.en.md) for client handling.
|
|
23
|
+
|
|
24
|
+
## Getting started
|
|
25
|
+
|
|
26
|
+
### Quick start
|
|
21
27
|
|
|
22
28
|
```ts
|
|
23
29
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -42,7 +48,9 @@ export const appContract = {
|
|
|
42
48
|
}
|
|
43
49
|
```
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
### API contracts
|
|
52
|
+
|
|
53
|
+
For standalone contract declaration builds, this package re-exports the upstream public types `ContractProcedureBuilderWithInputOutput`, `ContractProcedureBuilderWithOutput`, and `Schema`, preserving inference for custom routes. Import explicit types from `@h-ai/api-contract` with `import type`; do not reference internal dependency installation paths.
|
|
46
54
|
|
|
47
55
|
```ts
|
|
48
56
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -54,6 +62,8 @@ myContract.storage.presignedUrls.createUpload
|
|
|
54
62
|
myContract.ai.chats.createCompletion
|
|
55
63
|
```
|
|
56
64
|
|
|
65
|
+
`ai.chats.createCompletion` is `POST /ai/chats/completions` and returns a non-streaming `HaiResult<AiChatCompletionData>`. Its strict input rejects undeclared fields, including `stream`. Function tools preserve their complete nested JSON Schema and `strict`; choices support `auto`, `none`, `required`, or a supplied function name. Role-specific messages accept text for system/assistant/tool and images for user; tool results require a nonempty `tool_call_id`, and assistants require content or `tool_calls`. Applications authorize and execute tools and define a separate contract for streaming.
|
|
66
|
+
|
|
57
67
|
Clients call nested methods directly through `@h-ai/api-client`:
|
|
58
68
|
|
|
59
69
|
```ts
|
|
@@ -79,7 +89,7 @@ const app = serv.createApp({
|
|
|
79
89
|
})
|
|
80
90
|
```
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
### API overview
|
|
83
93
|
|
|
84
94
|
- `apiContract.create(options)`: omit domains set to `false` / `undefined` and compose the application contract.
|
|
85
95
|
- `apiContract.route(routeConfig)`: define method/path/operationId/tags and other route metadata for a custom endpoint.
|
|
@@ -87,13 +97,17 @@ const app = serv.createApp({
|
|
|
87
97
|
- `apiContract.haiResultSchema(dataSchema)` / `apiContract.voidResultSchema` / `apiContract.paginatedSchema(itemSchema)`: shared DTO schema factories.
|
|
88
98
|
- `Iam*Schema` / `Storage*Schema` / `Ai*Schema` / `Payment*Schema`: inputs and data structures reused across APIs and layers.
|
|
89
99
|
|
|
100
|
+
Batch deletion via `storage.files.deleteMany` returns `{ deletedKeys, failures: [] }` on success. Failures preserve progress in `error.ext.deleteMany` (`failed / unknown / notAttempted`); HTTP 200 alone does not mean completion. See [Storage batch deletion](../storage/README.en.md#api-overview).
|
|
101
|
+
|
|
90
102
|
Write each business path directly in its `*-contract.ts` file. Inline output schemas used only once in `.output(...)`; schemas reused within the same contract file may be private constants, but must not be exported from schemas.
|
|
91
103
|
|
|
92
|
-
|
|
104
|
+
### Configuration
|
|
93
105
|
|
|
94
106
|
This package has no runtime configuration and does not read environment variables.
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
### Configuration driven authentication
|
|
109
|
+
|
|
110
|
+
Password login submits only `identifier` and `password`; `AuthPanel` maps the `LoginForm` field `username` to `identifier`. Server settings `session.maxAge` / `session.refreshTokenMaxAge` control session lifetimes. The login form has no per-login persistent-session option.
|
|
97
111
|
|
|
98
112
|
Agreements support configuration-loaded userAgreementMarkdown/privacyPolicyMarkdown and URLs. Markdown takes priority for the same agreement and is safely rendered in a modal.
|
|
99
113
|
|
|
@@ -101,17 +115,23 @@ IAM adds GET /auth/config and POST /auth/login/ldap, /auth/password-reset/reques
|
|
|
101
115
|
|
|
102
116
|
[完整 IAM 配置 / IAM configuration](../iam/README.en.md)
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
### Error handling
|
|
105
119
|
|
|
106
120
|
Contracts describe input and output structures only. Procedures express business errors with `HaiResult<T>`, so clients need not catch business exceptions.
|
|
107
121
|
|
|
108
|
-
##
|
|
122
|
+
## Input limits and HTTP capabilities
|
|
123
|
+
|
|
124
|
+
Object keys are limited to 1024 UTF-8 bytes and reject absolute paths, backslashes, control characters and dot segments. Each public HTTP batch delete accepts 1–1000 entries. `@h-ai/storage/schemas` exposes the shared browser-safe rules. Presign expiry is an integer from 1 to 604800 seconds (Node default 3600, HTTP default 900). Upload signing accepts only key/contentType/expiresIn; contentLength/maxSize/metadata/checksum are unsupported. Invalid input returns HTTP 400 and the typed client maps it to VALIDATION_FAILED. FileUpload limits guide file selection; applications must validate actual objects on the server. Node streaming/checksum/conditional-write options have no default HTTP endpoints. See the [capability and authorization matrix (Chinese)](../storage/README.md#存储输入约束与跨端能力).
|
|
125
|
+
|
|
126
|
+
## Development and testing
|
|
109
127
|
|
|
110
128
|
```bash
|
|
111
129
|
pnpm --filter @h-ai/api-contract test
|
|
112
130
|
pnpm --filter @h-ai/api-contract typecheck
|
|
113
131
|
```
|
|
114
132
|
|
|
133
|
+
Schemas, inferred types and composition helpers include typechecked examples; see the [JSDoc conventions (Chinese)](../../.agents/instructions/module-conventions.md#jsdoc-与示例验证). Schema samples use validated local data and do not prove provider execution.
|
|
134
|
+
|
|
115
135
|
## License
|
|
116
136
|
|
|
117
137
|
Apache-2.0
|
package/README.ja.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[フレームワークのホーム](../../README.ja.md) · 関連モジュール:[@h-ai/core](../core/README.ja.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 概要
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
hai-framework の公開 HTTP API 契約パッケージ。oRPC contract + Zod を唯一の定義元として使用します。
|
|
10
|
+
|
|
11
|
+
## 主な機能
|
|
10
12
|
|
|
11
13
|
- `apiContract.iam`、`apiContract.storage`、`apiContract.ai`、`apiContract.payment`:ドメイン単位の contract。
|
|
12
14
|
- `apiContract.create()`:アプリケーションに必要なドメインの contract を組み合わせる。
|
|
@@ -17,7 +19,11 @@
|
|
|
17
19
|
- IAM Token DTO は httpOnly cookie に対応。レスポンス本文に `refreshToken` が含まれない場合は、サーバーが `Set-Cookie` で管理します。
|
|
18
20
|
- IAM の `auth.currentUser` はユーザー情報と現在のサーバーセッションの `roles` / `permissions` を返します。セッション復元のためにクライアントが権限のスナップショットを永続化する必要はありません。
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
支払い作成の入出力は WeChat `jsapi`・Alipay `h5`・Stripe `h5` のみ受け付け、WeChat は `userId`(openid)が必須です。App・Native・ミニプログラムなどは検証で拒否します。Alipay は `{ gateway, fields }` のページパラメーターを返し、作成成功は支払い完了を意味しません。クライアント処理は [Payment](../payment/README.ja.md) を参照してください。
|
|
23
|
+
|
|
24
|
+
## 使い始める
|
|
25
|
+
|
|
26
|
+
### クイックスタート
|
|
21
27
|
|
|
22
28
|
```ts
|
|
23
29
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -42,7 +48,9 @@ export const appContract = {
|
|
|
42
48
|
}
|
|
43
49
|
```
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
### API 契約
|
|
52
|
+
|
|
53
|
+
独立した contract パッケージの宣言ファイルを生成するため、上流の公開型 `ContractProcedureBuilderWithInputOutput`、`ContractProcedureBuilderWithOutput`、`Schema` を本パッケージから再エクスポートしています。独自ルートの入出力の型推論を維持し、明示的な型が必要な場合は `@h-ai/api-contract` から `import type` で取得してください。依存パッケージの内部インストールパスは参照しないでください。
|
|
46
54
|
|
|
47
55
|
```ts
|
|
48
56
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -54,6 +62,8 @@ myContract.storage.presignedUrls.createUpload
|
|
|
54
62
|
myContract.ai.chats.createCompletion
|
|
55
63
|
```
|
|
56
64
|
|
|
65
|
+
`ai.chats.createCompletion` は `POST /ai/chats/completions` で、非ストリーミングの `HaiResult<AiChatCompletionData>` を返します。厳密な入力 Schema は `stream` など未定義のフィールドを拒否します。function ツールのネストした JSON Schema と `strict` を保持し、選択は `auto` / `none` / `required` / 提供した関数名に対応します。system/assistant/tool はテキスト、user は画像にも対応し、ツール結果の空でない `tool_call_id`、助手の内容または `tool_calls` が必須です。アプリがツールを認可・実行し、ストリーミング用には別の契約を定義します。
|
|
66
|
+
|
|
57
67
|
クライアントは `@h-ai/api-client` でネストしたメソッドを直接呼び出します:
|
|
58
68
|
|
|
59
69
|
```ts
|
|
@@ -79,7 +89,7 @@ const app = serv.createApp({
|
|
|
79
89
|
})
|
|
80
90
|
```
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
### API 一覧
|
|
83
93
|
|
|
84
94
|
- `apiContract.create(options)`:`false` / `undefined` のドメインを除外し、アプリケーション contract を構成。
|
|
85
95
|
- `apiContract.route(routeConfig)`:独自 endpoint の method/path/operationId/tags などのルートメタデータを定義。
|
|
@@ -87,13 +97,17 @@ const app = serv.createApp({
|
|
|
87
97
|
- `apiContract.haiResultSchema(dataSchema)` / `apiContract.voidResultSchema` / `apiContract.paginatedSchema(itemSchema)`:共通 DTO Schema のファクトリー。
|
|
88
98
|
- `Iam*Schema` / `Storage*Schema` / `Ai*Schema` / `Payment*Schema`:複数の API・層で再利用する入力とデータ構造。
|
|
89
99
|
|
|
100
|
+
`storage.files.deleteMany` の成功データは `{ deletedKeys, failures: [] }` です。失敗進捗は `error.ext.deleteMany`(`failed / unknown / notAttempted`)にあり、HTTP 200 だけで完了と判断しません。[Storage の一括削除](../storage/README.ja.md#api-一覧)を参照してください。
|
|
101
|
+
|
|
90
102
|
業務 path は対応する `*-contract.ts` に直接記述します。一度しか使わない出力 Schema は `.output(...)` にインラインで定義します。同じ contract ファイル内で再利用する場合は非公開の定数にできますが、schemas からエクスポートしてはいけません。
|
|
91
103
|
|
|
92
|
-
|
|
104
|
+
### 設定
|
|
93
105
|
|
|
94
106
|
このパッケージには実行時設定がなく、環境変数も読み込みません。
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
### 設定による認証画面
|
|
109
|
+
|
|
110
|
+
パスワードログインの送信項目は `identifier` と `password` のみです。`AuthPanel` は `LoginForm` の `username` を `identifier` に変換します。有効期間はサーバーの `session.maxAge` / `session.refreshTokenMaxAge` で設定し、フォームにログインごとの永続セッション選択肢はありません。
|
|
97
111
|
|
|
98
112
|
規約は設定の userAgreementMarkdown/privacyPolicyMarkdown または URL を使用できます。同じ規約は Markdown 本文を優先して安全な Modal で描画します。
|
|
99
113
|
|
|
@@ -101,17 +115,23 @@ IAM に公開設定、LDAP、復旧要求と確定の標準 route を追加し
|
|
|
101
115
|
|
|
102
116
|
[完整 IAM 配置 / IAM configuration](../iam/README.ja.md)
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
### エラー処理
|
|
105
119
|
|
|
106
120
|
Contract は入出力構造のみを定義します。業務エラーは procedure が返す `HaiResult<T>` で表し、クライアント側で業務例外を捕捉する必要はありません。
|
|
107
121
|
|
|
108
|
-
##
|
|
122
|
+
## 入力制約と HTTP 機能
|
|
123
|
+
|
|
124
|
+
キーは UTF-8 で最大 1024 バイトで、絶対パス、バックスラッシュ、制御文字、ドットセグメントを拒否します。公開 HTTP 一括削除は一度に 1–1000 件です。共通規則はブラウザー対応の `@h-ai/storage/schemas` から参照できます。署名有効期限は整数 1–604800 秒(Node 既定 3600、HTTP 既定 900)。アップロード署名の入力は key/contentType/expiresIn のみで、contentLength/maxSize/metadata/checksum は未対応です。不正入力は HTTP 400、typed client では VALIDATION_FAILED です。FileUpload の制限は選択時の補助であり、実際のオブジェクトはサーバーで検証してください。Node のストリーム/checksum/条件付き書き込みには既定の HTTP エンドポイントがありません。[機能と認可の対応表(中国語)](../storage/README.md#存储输入约束与跨端能力)を参照してください。
|
|
125
|
+
|
|
126
|
+
## 開発とテスト
|
|
109
127
|
|
|
110
128
|
```bash
|
|
111
129
|
pnpm --filter @h-ai/api-contract test
|
|
112
130
|
pnpm --filter @h-ai/api-contract typecheck
|
|
113
131
|
```
|
|
114
132
|
|
|
115
|
-
|
|
133
|
+
Schema、推論型と組合せツールには型検査できる例があります。[JSDoc 規約(中国語)](../../.agents/instructions/module-conventions.md#jsdoc-与示例验证) を参照してください。Schema のローカル例は provider の実行証明ではありません。
|
|
134
|
+
|
|
135
|
+
## ライセンス
|
|
116
136
|
|
|
117
137
|
Apache-2.0
|
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[框架首页](../../README.md) · 相关模块:[@h-ai/core](../core/README.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 简介
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
hai-framework 的公共 HTTP API 契约包,用 oRPC contract 和 Zod 让前后端共用接口路径、输入输出校验与类型。
|
|
10
|
+
|
|
11
|
+
## 核心功能清单
|
|
10
12
|
|
|
11
13
|
- `apiContract.iam`、`apiContract.storage`、`apiContract.ai`、`apiContract.payment`:领域级 contract。
|
|
12
14
|
- `apiContract.create()`:按应用场景组合启用的领域 contract。
|
|
@@ -17,7 +19,11 @@
|
|
|
17
19
|
- IAM token DTO 兼容 httpOnly cookie 模式:响应体中 `refreshToken` 可能不存在,由服务端 `Set-Cookie` 管理。
|
|
18
20
|
- IAM `auth.currentUser` 返回用户资料以及服务端当前会话的 `roles` / `permissions`,客户端恢复会话时无需持久化权限快照。
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
支付创建输入和输出仅接受微信 `jsapi`、支付宝 `h5`、Stripe `h5`;微信输入必填 `userId`(openid)。App、Native、小程序与其它组合会在输入校验时失败。支付宝输出是 `{ gateway, fields }` 页面参数,创建成功不代表支付完成;客户端处理见 [Payment](../payment/README.md)。
|
|
23
|
+
|
|
24
|
+
## 使用入门
|
|
25
|
+
|
|
26
|
+
### 快速开始
|
|
21
27
|
|
|
22
28
|
```ts
|
|
23
29
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -42,7 +48,9 @@ export const appContract = {
|
|
|
42
48
|
}
|
|
43
49
|
```
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
### API 契约
|
|
52
|
+
|
|
53
|
+
独立 contract 包构建声明文件时,`ContractProcedureBuilderWithInputOutput`、`ContractProcedureBuilderWithOutput` 和 `Schema` 由本包按上游真实类型公开转出,保持自定义路由的输入输出推导。需要显式类型时从 `@h-ai/api-contract` 使用 `import type`,不要引用依赖的内部安装路径。
|
|
46
54
|
|
|
47
55
|
```ts
|
|
48
56
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -54,6 +62,8 @@ myContract.storage.presignedUrls.createUpload
|
|
|
54
62
|
myContract.ai.chats.createCompletion
|
|
55
63
|
```
|
|
56
64
|
|
|
65
|
+
`ai.chats.createCompletion` 为 `POST /ai/chats/completions`,只返回非流式 `HaiResult<AiChatCompletionData>`;输入严格拒绝 `stream` 等未声明字段。function 工具保留完整嵌套 JSON Schema 和 `strict`,工具选择支持 `auto` / `none` / `required` / 已提供的函数名。消息按角色校验:system/assistant/tool 接收文本,user 另支持图片;工具结果必填非空 `tool_call_id`,助手必须包含内容或 `tool_calls`。默认工具调用由业务方授权与执行,流式能力由应用定义独立契约。
|
|
66
|
+
|
|
57
67
|
客户端通过 `@h-ai/api-client` 直接调用嵌套方法:
|
|
58
68
|
|
|
59
69
|
```ts
|
|
@@ -79,7 +89,7 @@ const app = serv.createApp({
|
|
|
79
89
|
})
|
|
80
90
|
```
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
### API 概览
|
|
83
93
|
|
|
84
94
|
- `apiContract.create(options)`:过滤 `false` / `undefined` 领域并组合应用级 contract。
|
|
85
95
|
- `apiContract.route(routeConfig)`:定义自定义 endpoint 的 method/path/operationId/tags 等路由元数据。
|
|
@@ -87,13 +97,17 @@ const app = serv.createApp({
|
|
|
87
97
|
- `apiContract.haiResultSchema(dataSchema)` / `apiContract.voidResultSchema` / `apiContract.paginatedSchema(itemSchema)`:公共 DTO Schema 工厂。
|
|
88
98
|
- `Iam*Schema` / `Storage*Schema` / `Ai*Schema` / `Payment*Schema`:真正跨接口、跨层复用的输入与数据结构。
|
|
89
99
|
|
|
100
|
+
批量删除 `storage.files.deleteMany` 成功时返回 `{ deletedKeys, failures: [] }`;失败进度位于 `error.ext.deleteMany`(`failed / unknown / notAttempted`),不能只根据 HTTP 200 判断完成。详见 [Storage 批量删除](../storage/README.md#api-概览)。
|
|
101
|
+
|
|
90
102
|
业务 path 必须直接写在对应 `*-contract.ts`。只使用一次的输出 Schema 直接内联到 `.output(...)`;同一 contract 文件内重复使用时可保留私有常量,但不得从 schemas 导出。
|
|
91
103
|
|
|
92
|
-
|
|
104
|
+
### 配置
|
|
93
105
|
|
|
94
106
|
本包无运行时配置,不读取环境变量。
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
### 配置驱动认证页面
|
|
109
|
+
|
|
110
|
+
密码登录只提交 `identifier` 和 `password`;`AuthPanel` 将 `LoginForm` 的 `username` 映射为 `identifier`。会话有效期由服务端 `session.maxAge` / `session.refreshTokenMaxAge` 配置决定,登录表单不提供按次登录的持久会话选项。
|
|
97
111
|
|
|
98
112
|
协议支持配置中的 userAgreementMarkdown/privacyPolicyMarkdown 正文及 URL;同主题优先 Markdown,由安全渲染器在弹窗显示。
|
|
99
113
|
|
|
@@ -101,17 +115,23 @@ const app = serv.createApp({
|
|
|
101
115
|
|
|
102
116
|
[完整 IAM 配置 / IAM configuration](../iam/README.md)
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
### 错误处理
|
|
105
119
|
|
|
106
120
|
Contract 只描述输入输出结构。业务错误由 procedure 返回 `HaiResult<T>` 表达,客户端不需要捕获业务异常。
|
|
107
121
|
|
|
108
|
-
##
|
|
122
|
+
## 输入约束与 HTTP 能力
|
|
123
|
+
|
|
124
|
+
存储 key 按 UTF-8 最多 1024 字节,并拒绝绝对路径、反斜线、控制字符及点路径段;公开 HTTP 批量删除每次 1–1000 项。`@h-ai/storage/schemas` 提供浏览器安全的共同规则。预签名有效期为整数 1–604800 秒(Node 默认 3600,HTTP 默认 900);HTTP 上传仅接受 key/contentType/expiresIn,不支持 contentLength/maxSize/metadata/checksum。无效输入返回 HTTP 400,typed client 映射 VALIDATION_FAILED。FileUpload 的大小/类型限制仅为前端体验,实际对象须由应用服务端复核。Node 流式读写/checksum/条件写等没有默认 HTTP 端点。完整映射与授权边界见 [存储 API 能力](../storage/README.md#存储输入约束与跨端能力)。
|
|
125
|
+
|
|
126
|
+
## 开发测试
|
|
109
127
|
|
|
110
128
|
```bash
|
|
111
129
|
pnpm --filter @h-ai/api-contract test
|
|
112
130
|
pnpm --filter @h-ai/api-contract typecheck
|
|
113
131
|
```
|
|
114
132
|
|
|
115
|
-
|
|
133
|
+
Schema、推导类型与组合工具均提供可类型检查的示例;见[模块 JSDoc 约定](../../.agents/instructions/module-conventions.md#jsdoc-与示例验证)。Schema 示例使用受约束的本地数据,不代表 provider 已执行。
|
|
134
|
+
|
|
135
|
+
## 许可证
|
|
116
136
|
|
|
117
137
|
Apache-2.0
|