@h-ai/api-contract 0.1.0-alpha.66 → 0.1.0-alpha.67
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 +13 -9
- package/README.ja.md +14 -10
- package/README.md +14 -10
- package/package.json +2 -2
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,9 @@
|
|
|
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
|
+
## Getting started
|
|
23
|
+
|
|
24
|
+
### Quick start
|
|
21
25
|
|
|
22
26
|
```ts
|
|
23
27
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -42,7 +46,7 @@ export const appContract = {
|
|
|
42
46
|
}
|
|
43
47
|
```
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
### API contracts
|
|
46
50
|
|
|
47
51
|
```ts
|
|
48
52
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -79,7 +83,7 @@ const app = serv.createApp({
|
|
|
79
83
|
})
|
|
80
84
|
```
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
### API overview
|
|
83
87
|
|
|
84
88
|
- `apiContract.create(options)`: omit domains set to `false` / `undefined` and compose the application contract.
|
|
85
89
|
- `apiContract.route(routeConfig)`: define method/path/operationId/tags and other route metadata for a custom endpoint.
|
|
@@ -89,11 +93,11 @@ const app = serv.createApp({
|
|
|
89
93
|
|
|
90
94
|
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
95
|
|
|
92
|
-
|
|
96
|
+
### Configuration
|
|
93
97
|
|
|
94
98
|
This package has no runtime configuration and does not read environment variables.
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
### Configuration driven authentication
|
|
97
101
|
|
|
98
102
|
Agreements support configuration-loaded userAgreementMarkdown/privacyPolicyMarkdown and URLs. Markdown takes priority for the same agreement and is safely rendered in a modal.
|
|
99
103
|
|
|
@@ -101,11 +105,11 @@ IAM adds GET /auth/config and POST /auth/login/ldap, /auth/password-reset/reques
|
|
|
101
105
|
|
|
102
106
|
[完整 IAM 配置 / IAM configuration](../iam/README.en.md)
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
### Error handling
|
|
105
109
|
|
|
106
110
|
Contracts describe input and output structures only. Procedures express business errors with `HaiResult<T>`, so clients need not catch business exceptions.
|
|
107
111
|
|
|
108
|
-
##
|
|
112
|
+
## Development and testing
|
|
109
113
|
|
|
110
114
|
```bash
|
|
111
115
|
pnpm --filter @h-ai/api-contract test
|
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,9 @@
|
|
|
17
19
|
- IAM Token DTO は httpOnly cookie に対応。レスポンス本文に `refreshToken` が含まれない場合は、サーバーが `Set-Cookie` で管理します。
|
|
18
20
|
- IAM の `auth.currentUser` はユーザー情報と現在のサーバーセッションの `roles` / `permissions` を返します。セッション復元のためにクライアントが権限のスナップショットを永続化する必要はありません。
|
|
19
21
|
|
|
20
|
-
##
|
|
22
|
+
## 使い始める
|
|
23
|
+
|
|
24
|
+
### クイックスタート
|
|
21
25
|
|
|
22
26
|
```ts
|
|
23
27
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -42,7 +46,7 @@ export const appContract = {
|
|
|
42
46
|
}
|
|
43
47
|
```
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
### API 契約
|
|
46
50
|
|
|
47
51
|
```ts
|
|
48
52
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -79,7 +83,7 @@ const app = serv.createApp({
|
|
|
79
83
|
})
|
|
80
84
|
```
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
### API 一覧
|
|
83
87
|
|
|
84
88
|
- `apiContract.create(options)`:`false` / `undefined` のドメインを除外し、アプリケーション contract を構成。
|
|
85
89
|
- `apiContract.route(routeConfig)`:独自 endpoint の method/path/operationId/tags などのルートメタデータを定義。
|
|
@@ -89,11 +93,11 @@ const app = serv.createApp({
|
|
|
89
93
|
|
|
90
94
|
業務 path は対応する `*-contract.ts` に直接記述します。一度しか使わない出力 Schema は `.output(...)` にインラインで定義します。同じ contract ファイル内で再利用する場合は非公開の定数にできますが、schemas からエクスポートしてはいけません。
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
### 設定
|
|
93
97
|
|
|
94
98
|
このパッケージには実行時設定がなく、環境変数も読み込みません。
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
### 設定による認証画面
|
|
97
101
|
|
|
98
102
|
規約は設定の userAgreementMarkdown/privacyPolicyMarkdown または URL を使用できます。同じ規約は Markdown 本文を優先して安全な Modal で描画します。
|
|
99
103
|
|
|
@@ -101,17 +105,17 @@ IAM に公開設定、LDAP、復旧要求と確定の標準 route を追加し
|
|
|
101
105
|
|
|
102
106
|
[完整 IAM 配置 / IAM configuration](../iam/README.ja.md)
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
### エラー処理
|
|
105
109
|
|
|
106
110
|
Contract は入出力構造のみを定義します。業務エラーは procedure が返す `HaiResult<T>` で表し、クライアント側で業務例外を捕捉する必要はありません。
|
|
107
111
|
|
|
108
|
-
##
|
|
112
|
+
## 開発とテスト
|
|
109
113
|
|
|
110
114
|
```bash
|
|
111
115
|
pnpm --filter @h-ai/api-contract test
|
|
112
116
|
pnpm --filter @h-ai/api-contract typecheck
|
|
113
117
|
```
|
|
114
118
|
|
|
115
|
-
##
|
|
119
|
+
## ライセンス
|
|
116
120
|
|
|
117
121
|
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,9 @@
|
|
|
17
19
|
- IAM token DTO 兼容 httpOnly cookie 模式:响应体中 `refreshToken` 可能不存在,由服务端 `Set-Cookie` 管理。
|
|
18
20
|
- IAM `auth.currentUser` 返回用户资料以及服务端当前会话的 `roles` / `permissions`,客户端恢复会话时无需持久化权限快照。
|
|
19
21
|
|
|
20
|
-
##
|
|
22
|
+
## 使用入门
|
|
23
|
+
|
|
24
|
+
### 快速开始
|
|
21
25
|
|
|
22
26
|
```ts
|
|
23
27
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -42,7 +46,7 @@ export const appContract = {
|
|
|
42
46
|
}
|
|
43
47
|
```
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
### API 契约
|
|
46
50
|
|
|
47
51
|
```ts
|
|
48
52
|
import { apiContract } from '@h-ai/api-contract'
|
|
@@ -79,7 +83,7 @@ const app = serv.createApp({
|
|
|
79
83
|
})
|
|
80
84
|
```
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
### API 概览
|
|
83
87
|
|
|
84
88
|
- `apiContract.create(options)`:过滤 `false` / `undefined` 领域并组合应用级 contract。
|
|
85
89
|
- `apiContract.route(routeConfig)`:定义自定义 endpoint 的 method/path/operationId/tags 等路由元数据。
|
|
@@ -89,11 +93,11 @@ const app = serv.createApp({
|
|
|
89
93
|
|
|
90
94
|
业务 path 必须直接写在对应 `*-contract.ts`。只使用一次的输出 Schema 直接内联到 `.output(...)`;同一 contract 文件内重复使用时可保留私有常量,但不得从 schemas 导出。
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
### 配置
|
|
93
97
|
|
|
94
98
|
本包无运行时配置,不读取环境变量。
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
### 配置驱动认证页面
|
|
97
101
|
|
|
98
102
|
协议支持配置中的 userAgreementMarkdown/privacyPolicyMarkdown 正文及 URL;同主题优先 Markdown,由安全渲染器在弹窗显示。
|
|
99
103
|
|
|
@@ -101,17 +105,17 @@ const app = serv.createApp({
|
|
|
101
105
|
|
|
102
106
|
[完整 IAM 配置 / IAM configuration](../iam/README.md)
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
### 错误处理
|
|
105
109
|
|
|
106
110
|
Contract 只描述输入输出结构。业务错误由 procedure 返回 `HaiResult<T>` 表达,客户端不需要捕获业务异常。
|
|
107
111
|
|
|
108
|
-
##
|
|
112
|
+
## 开发测试
|
|
109
113
|
|
|
110
114
|
```bash
|
|
111
115
|
pnpm --filter @h-ai/api-contract test
|
|
112
116
|
pnpm --filter @h-ai/api-contract typecheck
|
|
113
117
|
```
|
|
114
118
|
|
|
115
|
-
##
|
|
119
|
+
## 许可证
|
|
116
120
|
|
|
117
121
|
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/api-contract",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.67",
|
|
5
5
|
"description": "Hai Framework public API contracts powered by oRPC and Zod.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"exports": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@h-ai/core": "0.1.0-alpha.
|
|
42
|
+
"@h-ai/core": "0.1.0-alpha.67",
|
|
43
43
|
"@orpc/contract": "^1.15.5",
|
|
44
44
|
"zod": "^4.6.5"
|
|
45
45
|
},
|