@h-ai/storage 0.1.0-alpha.65 → 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 CHANGED
@@ -4,16 +4,20 @@
4
4
 
5
5
  [Framework home](../../README.en.md) · Related modules: [@h-ai/core](../core/README.en.md)
6
6
 
7
+ ## Introduction
8
+
7
9
  An object storage module with a unified `storage` entry point for S3-compatible storage and local filesystems.
8
10
 
9
- ## Supported backends
11
+ ## Core features
10
12
 
11
13
  - S3 protocol (AWS S3 / MinIO / RustFS / OSS, etc.)
12
14
  - Local filesystem
13
15
 
14
- ## Quick start
16
+ ## Getting started
17
+
18
+ ### Quick start
15
19
 
16
- ### Node.js server
20
+ #### Node.js server
17
21
 
18
22
  ```ts
19
23
  import { storage } from '@h-ai/storage'
@@ -44,7 +48,7 @@ if (!closeResult.success) {
44
48
  }
45
49
  ```
46
50
 
47
- ### Browser client
51
+ #### Browser client
48
52
 
49
53
  The browser entry exports only client capabilities (signed URL uploads/downloads), without the `storage` service object.
50
54
 
@@ -58,7 +62,7 @@ await uploadWithPresignedUrl(uploadUrl, file)
58
62
 
59
63
  > Note: `@h-ai/storage` does not include HTTP routes. Implement the signed URL API in the application layer.
60
64
 
61
- ## HTTP API contracts
65
+ ### HTTP API contracts
62
66
 
63
67
  Public HTTP contracts come from `@h-ai/api-contract`; `createStorageProcedures({ storage })` in `@h-ai/serv` binds them to this module.
64
68
 
@@ -68,7 +72,7 @@ import { apiClient } from '@h-ai/api-client'
68
72
  const result = await apiClient.storage.presignedUrls.createUpload({ key: 'avatar.png' })
69
73
  ```
70
74
 
71
- ## API overview
75
+ ### API overview
72
76
 
73
77
  - `storage.file`
74
78
  - `put/get/getStream/head/exists/delete/deleteMany/copy`
@@ -91,7 +95,7 @@ Cancelling a checksum stops waiting for the next chunk and requests closure of t
91
95
 
92
96
  > Note: `storage.config` returns a **redacted configuration snapshot**. S3 secret fields are replaced with `[REDACTED]`, so it cannot be used for reinitialization.
93
97
 
94
- ## Client helpers
98
+ ### Client helpers
95
99
 
96
100
  `@h-ai/storage/client` also provides these browser utilities:
97
101
 
@@ -102,7 +106,7 @@ Cancelling a checksum stops waiting for the next chunk and requests closure of t
102
106
  - `getMimeType(extension)`
103
107
  - `formatFileSize(bytes)`
104
108
 
105
- ## Configuration
109
+ ### Configuration
106
110
 
107
111
  - **S3**: requires `bucket / region / accessKeyId / secretAccessKey`; optional `endpoint / forcePathStyle / prefix / publicUrl`.
108
112
  - **Local**: requires `root`; optional `directoryMode / fileMode`.
@@ -124,7 +128,7 @@ if (!initResult.success) {
124
128
  }
125
129
  ```
126
130
 
127
- ### Operation logging
131
+ #### Operation logging
128
132
 
129
133
  Enable file, directory, and presigned URL operation logs with `operationLog`. Logs are emitted at the actual Local/S3 provider operations, without a shared wrapper in `storage-main.ts`. File contents are never logged; uploads log only the byte length.
130
134
 
@@ -156,7 +160,7 @@ await storage.init({
156
160
 
157
161
  For local storage, `storage.dir.list()` recursively scans files under the matching prefix. It supports `maxKeys` truncation but no true pagination with `continuationToken`. For large directories, narrow `prefix` or use the S3 provider's native pagination.
158
162
 
159
- ## Error handling
163
+ ### Error handling
160
164
 
161
165
  ```ts
162
166
  import { HaiStorageError, storage } from '@h-ai/storage'
@@ -179,7 +183,7 @@ Common error codes:
179
183
  | `HaiStorageError.PRESIGN_FAILED` | `hai:storage:013` | Presigned URL generation failed |
180
184
  | `HaiStorageError.CONFIG_ERROR` | `hai:storage:012` | Invalid configuration |
181
185
 
182
- ## Tests
186
+ ## Development and testing
183
187
 
184
188
  ```bash
185
189
  pnpm --filter @h-ai/storage test
package/README.ja.md CHANGED
@@ -4,16 +4,20 @@
4
4
 
5
5
  [フレームワークのホーム](../../README.ja.md) · 関連モジュール:[@h-ai/core](../core/README.ja.md)
6
6
 
7
+ ## 概要
8
+
7
9
  共通の `storage` 入口で S3 互換ストレージとローカルファイルシステムを操作するオブジェクトストレージモジュールです。
8
10
 
9
- ## 対応バックエンド
11
+ ## 主な機能
10
12
 
11
13
  - S3 プロトコル(AWS S3 / MinIO / RustFS / OSS など)
12
14
  - ローカルファイルシステム
13
15
 
14
- ## クイックスタート
16
+ ## 使い始める
17
+
18
+ ### クイックスタート
15
19
 
16
- ### Node.js サーバー
20
+ #### Node.js サーバー
17
21
 
18
22
  ```ts
19
23
  import { storage } from '@h-ai/storage'
@@ -44,7 +48,7 @@ if (!closeResult.success) {
44
48
  }
45
49
  ```
46
50
 
47
- ### ブラウザークライアント
51
+ #### ブラウザークライアント
48
52
 
49
53
  ブラウザー環境ではクライアント機能(署名付き URL のアップロード・ダウンロード)のみをエクスポートし、`storage` サービスオブジェクトは含みません。
50
54
 
@@ -58,7 +62,7 @@ await uploadWithPresignedUrl(uploadUrl, file)
58
62
 
59
63
  > 注:`@h-ai/storage` に HTTP ルートは組み込まれていません。署名付き URL API はアプリケーション層で実装してください。
60
64
 
61
- ## HTTP API 契約
65
+ ### HTTP API 契約
62
66
 
63
67
  公開 HTTP API は `@h-ai/api-contract` で定義し、`@h-ai/serv` の `createStorageProcedures({ storage })` で本モジュールの機能に接続します。
64
68
 
@@ -68,7 +72,7 @@ import { apiClient } from '@h-ai/api-client'
68
72
  const result = await apiClient.storage.presignedUrls.createUpload({ key: 'avatar.png' })
69
73
  ```
70
74
 
71
- ## API 一覧
75
+ ### API 一覧
72
76
 
73
77
  - `storage.file`
74
78
  - `put/get/getStream/head/exists/delete/deleteMany/copy`
@@ -91,7 +95,7 @@ checksum の中止時は次のチャンクを待つ処理を終了し、入力
91
95
 
92
96
  > 注:`storage.config` は**機密情報をマスクした設定スナップショット**を返します。S3 の秘密情報は `[REDACTED]` に置換され、再初期化には使用できません。
93
97
 
94
- ## クライアントヘルパー
98
+ ### クライアントヘルパー
95
99
 
96
100
  `@h-ai/storage/client` は以下のブラウザー用ツールも提供します:
97
101
 
@@ -102,7 +106,7 @@ checksum の中止時は次のチャンクを待つ処理を終了し、入力
102
106
  - `getMimeType(extension)`
103
107
  - `formatFileSize(bytes)`
104
108
 
105
- ## 設定
109
+ ### 設定
106
110
 
107
111
  - **S3**:`bucket / region / accessKeyId / secretAccessKey` は必須。`endpoint / forcePathStyle / prefix / publicUrl` は任意。
108
112
  - **Local**:`root` は必須。`directoryMode / fileMode` は任意。
@@ -124,7 +128,7 @@ if (!initResult.success) {
124
128
  }
125
129
  ```
126
130
 
127
- ### 操作ログ
131
+ #### 操作ログ
128
132
 
129
133
  `operationLog` でファイル・ディレクトリー・署名付き URL の操作ログを有効にできます。Local/S3 Provider の実際の操作箇所で出力し、`storage-main.ts` で一括ラップしません。ファイル内容は記録せず、アップロードデータはバイト数のみを記録します。
130
134
 
@@ -156,7 +160,7 @@ await storage.init({
156
160
 
157
161
  ローカルの `storage.dir.list()` は prefix に一致するファイルを再帰的に走査します。`maxKeys` による打ち切りのみ対応し、`continuationToken` による実際のページ分割はありません。大きなディレクトリーでは `prefix` を絞るか、S3 Provider のページ分割を使用してください。
158
162
 
159
- ## エラー処理
163
+ ### エラー処理
160
164
 
161
165
  ```ts
162
166
  import { HaiStorageError, storage } from '@h-ai/storage'
@@ -179,7 +183,7 @@ if (!result.success && result.error.code === HaiStorageError.NOT_INITIALIZED.cod
179
183
  | `HaiStorageError.PRESIGN_FAILED` | `hai:storage:013` | 署名付き URL の生成に失敗 |
180
184
  | `HaiStorageError.CONFIG_ERROR` | `hai:storage:012` | 設定エラー |
181
185
 
182
- ## テスト
186
+ ## 開発とテスト
183
187
 
184
188
  ```bash
185
189
  pnpm --filter @h-ai/storage test
@@ -192,6 +196,6 @@ S3 統合テストには Docker または互換ランタイムが必要です。
192
196
 
193
197
  コンテナーは一時生成したテスト認証情報を使用します。サービスの準備完了後に S3 API でバケットを作成し、最後のリース解放時にコンテナーと匿名ボリュームを削除します。
194
198
 
195
- ## License
199
+ ## ライセンス
196
200
 
197
201
  Apache-2.0
package/README.md CHANGED
@@ -4,16 +4,20 @@
4
4
 
5
5
  [框架首页](../../README.md) · 相关模块:[@h-ai/core](../core/README.md)
6
6
 
7
+ ## 简介
8
+
7
9
  对象存储模块,提供统一 `storage` 访问入口,支持 S3 兼容存储与本地文件系统。
8
10
 
9
- ## 支持的后端
11
+ ## 核心功能清单
10
12
 
11
13
  - S3 协议(AWS S3 / MinIO / RustFS / OSS 等)
12
14
  - 本地文件系统
13
15
 
14
- ## 快速开始
16
+ ## 使用入门
17
+
18
+ ### 快速开始
15
19
 
16
- ### Node.js 服务端
20
+ #### Node.js 服务端
17
21
 
18
22
  ```ts
19
23
  import { storage } from '@h-ai/storage'
@@ -44,7 +48,7 @@ if (!closeResult.success) {
44
48
  }
45
49
  ```
46
50
 
47
- ### 浏览器客户端
51
+ #### 浏览器客户端
48
52
 
49
53
  浏览器环境下仅导出客户端能力(签名 URL 上传/下载),不包含 `storage` 服务对象。
50
54
 
@@ -58,7 +62,7 @@ await uploadWithPresignedUrl(uploadUrl, file)
58
62
 
59
63
  > 注意:`@h-ai/storage` 不内置 HTTP 路由;请在应用层自行实现签名 URL API。
60
64
 
61
- ## HTTP API 契约
65
+ ### HTTP API 契约
62
66
 
63
67
  公共 HTTP API 统一由 `@h-ai/api-contract` 提供,并由 `@h-ai/serv` 的 `createStorageProcedures({ storage })` 绑定到本模块能力。
64
68
 
@@ -68,7 +72,7 @@ import { apiClient } from '@h-ai/api-client'
68
72
  const result = await apiClient.storage.presignedUrls.createUpload({ key: 'avatar.png' })
69
73
  ```
70
74
 
71
- ## API 概览
75
+ ### API 概览
72
76
 
73
77
  - `storage.file`
74
78
  - `put/get/getStream/head/exists/delete/deleteMany/copy`
@@ -91,7 +95,7 @@ const result = await apiClient.storage.presignedUrls.createUpload({ key: 'avatar
91
95
 
92
96
  > 注意:`storage.config` 返回的是**脱敏配置快照**;S3 密钥类字段会被替换为 `[REDACTED]`,不能用于重新初始化。
93
97
 
94
- ## 客户端辅助函数
98
+ ### 客户端辅助函数
95
99
 
96
100
  `@h-ai/storage/client` 还提供以下浏览器侧工具:
97
101
 
@@ -102,7 +106,7 @@ const result = await apiClient.storage.presignedUrls.createUpload({ key: 'avatar
102
106
  - `getMimeType(extension)`
103
107
  - `formatFileSize(bytes)`
104
108
 
105
- ## 配置
109
+ ### 配置
106
110
 
107
111
  - **S3**:`bucket / region / accessKeyId / secretAccessKey` 必填,可选 `endpoint / forcePathStyle / prefix / publicUrl`
108
112
  - **Local**:`root` 必填,可选 `directoryMode / fileMode`
@@ -124,7 +128,7 @@ if (!initResult.success) {
124
128
  }
125
129
  ```
126
130
 
127
- ### 操作日志
131
+ #### 操作日志
128
132
 
129
133
  可在存储配置中通过 `operationLog` 开启文件、目录和预签名 URL 操作日志。日志在 Local/S3 Provider 的真实操作处输出,不在 `storage-main.ts` 中做统一包装;文件内容不会写入日志,上传数据只记录字节长度。
130
134
 
@@ -156,7 +160,7 @@ await storage.init({
156
160
 
157
161
  本地存储的 `storage.dir.list()` 会递归扫描匹配前缀下的文件,仅支持 `maxKeys` 截断,不支持 `continuationToken` 真分页;大目录场景建议优先使用更窄的 `prefix`,或改用 S3 Provider 获取原生分页能力。
158
162
 
159
- ## 错误处理
163
+ ### 错误处理
160
164
 
161
165
  ```ts
162
166
  import { HaiStorageError, storage } from '@h-ai/storage'
@@ -179,7 +183,7 @@ if (!result.success && result.error.code === HaiStorageError.NOT_INITIALIZED.cod
179
183
  | `HaiStorageError.PRESIGN_FAILED` | `hai:storage:013` | 预签名 URL 生成失败 |
180
184
  | `HaiStorageError.CONFIG_ERROR` | `hai:storage:012` | 配置错误 |
181
185
 
182
- ## 测试
186
+ ## 开发测试
183
187
 
184
188
  ```bash
185
189
  pnpm --filter @h-ai/storage test
@@ -192,6 +196,6 @@ S3 集成测试需要可用的 Docker 或兼容运行时;同一套初始化、
192
196
 
193
197
  容器使用临时生成的测试凭据,等待服务就绪后通过 S3 API 建桶;最后一个租约释放时移除容器及匿名卷。
194
198
 
195
- ## License
199
+ ## 许可证
196
200
 
197
201
  Apache-2.0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@h-ai/storage",
3
3
  "type": "module",
4
- "version": "0.1.0-alpha.65",
4
+ "version": "0.1.0-alpha.67",
5
5
  "description": "Hai Framework object storage module for S3-compatible and local backends.",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
@@ -32,7 +32,7 @@
32
32
  "@aws-sdk/client-s3": "^3.1149.0",
33
33
  "@aws-sdk/lib-storage": "^3.1149.0",
34
34
  "@aws-sdk/s3-request-presigner": "^3.1149.0",
35
- "@h-ai/core": "0.1.0-alpha.65",
35
+ "@h-ai/core": "0.1.0-alpha.67",
36
36
  "zod": "^4.6.5"
37
37
  },
38
38
  "devDependencies": {