@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.
- package/README.md +7 -6
- package/dist/index.js +1 -1
- package/dist/{src-XJ6YXNAF.js → src-RZ4DPYNJ.js} +4 -4
- package/dist/{src-XJ6YXNAF.js.map → src-RZ4DPYNJ.js.map} +1 -1
- package/package.json +2 -2
- package/templates/apps/android-app/src/lib/api.ts.hbs +5 -4
- package/templates/base/package.json.hbs +21 -21
- package/templates/base/src/app.css.hbs +2 -1
- package/templates/skills/AGENTS.md +1 -0
- package/templates/skills/copilot-instructions.md +3 -0
- package/templates/skills/hai-ai/SKILL.md +44 -30
- package/templates/skills/hai-api-client/SKILL.md +94 -295
- package/templates/skills/hai-api-contract/SKILL.md +272 -0
- package/templates/skills/hai-build/SKILL.md +25 -13
- package/templates/skills/hai-capacitor/SKILL.md +7 -7
- package/templates/skills/hai-ci/SKILL.md +112 -0
- package/templates/skills/hai-core/SKILL.md +65 -2
- package/templates/skills/hai-crypto/SKILL.md +42 -1
- package/templates/skills/hai-framework-sync/SKILL.md +98 -0
- package/templates/skills/hai-iam/SKILL.md +13 -35
- package/templates/skills/hai-kit/SKILL.md +85 -412
- package/templates/skills/hai-payment/SKILL.md +8 -10
- package/templates/skills/hai-pr-review/SKILL.md +109 -0
- package/templates/skills/hai-reldb/SKILL.md +1 -1
- package/templates/skills/hai-serv/SKILL.md +658 -0
- package/templates/skills/hai-storage/SKILL.md +7 -47
- package/templates/skills/hai-ui/SKILL.md +2 -1
|
@@ -130,55 +130,16 @@ const downloadUrl = await storage.presign.getUrl('uploads/doc.pdf', {
|
|
|
130
130
|
|
|
131
131
|
---
|
|
132
132
|
|
|
133
|
-
## API
|
|
133
|
+
## HTTP API 契约
|
|
134
134
|
|
|
135
|
-
`@h-ai/
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
215
|
+
也可使用 typed client(需配合 `@h-ai/api-client`):
|
|
255
216
|
|
|
256
217
|
```typescript
|
|
257
|
-
import {
|
|
258
|
-
import { storageEndpoints } from '@h-ai/storage/api'
|
|
218
|
+
import { apiClient } from '@h-ai/api-client'
|
|
259
219
|
|
|
260
|
-
const result = await
|
|
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" {
|