@h-ai/cli 0.1.0-alpha.12 → 0.1.0-alpha.15

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.
@@ -130,55 +130,16 @@ const downloadUrl = await storage.presign.getUrl('uploads/doc.pdf', {
130
130
 
131
131
  ---
132
132
 
133
- ## API 契约(`@h-ai/storage/api`)
133
+ ## HTTP API 契约
134
134
 
135
- `@h-ai/storage/api` 子路径导出所有存储端点的 Zod Schema 和端点契约定义,客户端与服务端共享同一份真相源,编译时保证 I/O 一致性。
136
-
137
- ### 端点定义 — `storageEndpoints`
138
-
139
- | 端点名 | method | path | input Schema | output Schema |
140
- | ------------------ | ------ | ---------------------------- | ------------------------ | ------------------------ |
141
- | `presignDownload` | POST | `/storage/presign/download` | `PresignGetInputSchema` | `PresignUrlOutputSchema` |
142
- | `presignUpload` | POST | `/storage/presign/upload` | `PresignPutInputSchema` | `PresignUrlOutputSchema` |
143
- | `fileInfo` | POST | `/storage/file/info` | `FileInfoInputSchema` | `FileMetadataSchema` |
144
- | `listFiles` | GET | `/storage/files` | inline(prefix/maxKeys) | `ListFilesOutputSchema` |
145
- | `deleteFile` | POST | `/storage/file/delete` | `DeleteFileInputSchema` | `z.void()` |
146
- | `deleteFiles` | POST | `/storage/files/delete` | `DeleteFilesInputSchema` | `z.void()` |
147
-
148
- ### 使用示例
135
+ 公共 HTTP API 统一由 `@h-ai/api-contract` 提供,并由 `@h-ai/serv/features/storage` 绑定到本模块。
149
136
 
150
137
  ```typescript
151
- import { storageEndpoints, PresignPutInputSchema } from '@h-ai/storage/api'
152
-
153
- // 客户端:通过 api-client 调用端点
154
- const { url } = await api.call(storageEndpoints.presignUpload, { key: 'avatar.png' })
155
-
156
- // 服务端:基于契约定义路由
157
- export const POST = kit.fromContract(storageEndpoints.presignUpload, async (input) => {
158
- const result = await storage.presign.putUrl(input.key, input)
159
- return result.success ? result.data : kit.response.internalError(result.error.message)
160
- })
138
+ import { apiClient } from '@h-ai/api-client'
161
139
 
162
- // 独立 Schema 校验
163
- const parsed = PresignPutInputSchema.safeParse(requestBody)
164
- if (!parsed.success) { /* 校验失败 */ }
140
+ const result = await apiClient.storage.presignedUrls.createUpload({ key: 'avatar.png' })
165
141
  ```
166
142
 
167
- ### 导出的 Schema
168
-
169
- - `FileMetadataSchema` — 文件元数据(key / size / contentType / lastModified / etag? / metadata?)
170
- - `PresignGetInputSchema` — 下载签名入参(key + expiresIn?)
171
- - `PresignPutInputSchema` — 上传签名入参(key + contentType? + contentLength? + expiresIn?)
172
- - `PresignUrlOutputSchema` — 签名 URL 出参(url + key + expiresAt?)
173
- - `ListFilesOutputSchema` — 文件列表出参(files + commonPrefixes + isTruncated + nextContinuationToken?)
174
- - `DeleteFileInputSchema` — 删除单文件入参(key)
175
- - `DeleteFilesInputSchema` — 批量删除入参(keys[])
176
- - `FileInfoInputSchema` — 文件信息入参(key)
177
-
178
- ### 导出的推导类型
179
-
180
- `PresignGetInput` / `PresignPutInput` / `PresignUrlOutput` / `ListFilesOutput` / `DeleteFileInput` / `DeleteFilesInput` / `FileInfoInput`
181
-
182
143
  ---
183
144
 
184
145
  ## 常见模式
@@ -251,13 +212,12 @@ await fetch(url, {
251
212
  })
252
213
  ```
253
214
 
254
- 也可使用契约调用(需配合 `@h-ai/api-client`):
215
+ 也可使用 typed client(需配合 `@h-ai/api-client`):
255
216
 
256
217
  ```typescript
257
- import { api } from '@h-ai/api-client'
258
- import { storageEndpoints } from '@h-ai/storage/api'
218
+ import { apiClient } from '@h-ai/api-client'
259
219
 
260
- const result = await api.call(storageEndpoints.presignUpload, {
220
+ const result = await apiClient.storage.presignedUrls.createUpload({
261
221
  key: `avatars/${userId}.png`,
262
222
  contentType: 'image/png',
263
223
  })
@@ -109,7 +109,8 @@ export default defineConfig({
109
109
  @import '@h-ai/ui/styles/mobile.css'; /* 安全区域/触摸优化/键盘适配 */
110
110
 
111
111
  /* ─── 扫描 @h-ai/ui 组件中使用的 Tailwind 类名 ─── */
112
- @source "../node_modules/@h-ai/ui/dist/**/*.{svelte,ts}";
112
+ @source "../node_modules/@h-ai/ui/dist/**/*.{svelte,js,ts}";
113
+ @source "../../../node_modules/@h-ai/ui/dist/**/*.{svelte,js,ts}";
113
114
 
114
115
  /* ─── DaisyUI 主题 ─── */
115
116
  @plugin "daisyui" {