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

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@h-ai/cli",
3
3
  "type": "module",
4
- "version": "0.1.0-alpha.15",
4
+ "version": "0.1.0-alpha.16",
5
5
  "description": "Hai Framework CLI for project scaffolding and code generation.",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
@@ -34,7 +34,7 @@
34
34
  "ora": "^9.1.0",
35
35
  "prompts": "^2.4.2",
36
36
  "yaml": "^2.7.0",
37
- "@h-ai/core": "0.1.0-alpha.15"
37
+ "@h-ai/core": "0.1.0-alpha.16"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/fs-extra": "^11.0.4",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "{{projectName}}",
3
- "version": "0.1.0-alpha.15",
3
+ "version": "0.1.0-alpha.16",
4
4
  "private": true,
5
5
  "description": "{{#if_eq appType 'admin'}}Enterprise management system built with hai Agent Framework{{/if_eq}}{{#if_eq appType 'website'}}Enterprise website built with hai Agent Framework{{/if_eq}}{{#if_eq appType 'h5'}}Mobile H5 app built with hai Agent Framework{{/if_eq}}{{#if_eq appType 'api'}}REST API service built with hai Agent Framework{{/if_eq}}{{#if_eq appType 'android-app'}}Android app built with hai Agent Framework{{/if_eq}}",
6
6
  "keywords": ["hai", "sveltekit", "svelte5", "{{appType}}"],
@@ -21,26 +21,26 @@
21
21
  "clean": "rimraf .svelte-kit build .turbo"
22
22
  },
23
23
  "dependencies": {
24
- "@h-ai/core": "^0.1.0-alpha.15",
25
- "@h-ai/kit": "^0.1.0-alpha.15"{{#if hasUi}},
26
- "@h-ai/ui": "^0.1.0-alpha.15"{{/if}}{{#if features.db}},
27
- "@h-ai/reldb": "^0.1.0-alpha.15"{{/if}}{{#if features.cache}},
28
- "@h-ai/cache": "^0.1.0-alpha.15"{{/if}}{{#if features.iam}},
29
- "@h-ai/iam": "^0.1.0-alpha.15"{{/if}}{{#if features.crypto}},
30
- "@h-ai/crypto": "^0.1.0-alpha.15"{{/if}}{{#if features.storage}},
31
- "@h-ai/storage": "^0.1.0-alpha.15"{{/if}}{{#if features.ai}},
32
- "@h-ai/ai": "^0.1.0-alpha.15"{{/if}}{{#if features.audit}},
33
- "@h-ai/audit": "^0.1.0-alpha.15"{{/if}}{{#if features.reach}},
34
- "@h-ai/reach": "^0.1.0-alpha.15"{{/if}}{{#if features.payment}},
35
- "@h-ai/payment": "^0.1.0-alpha.15"{{/if}}{{#if features.vecdb}},
36
- "@h-ai/vecdb": "^0.1.0-alpha.15"{{/if}}{{#if features.datapipe}},
37
- "@h-ai/datapipe": "^0.1.0-alpha.15"{{/if}}{{#if features.scheduler}},
38
- "@h-ai/scheduler": "^0.1.0-alpha.15"{{/if}}{{#if features.deploy}},
39
- "@h-ai/deploy": "^0.1.0-alpha.15"{{/if}}{{#if features.api-client}},
40
- "@h-ai/api-client": "^0.1.0-alpha.15"{{/if}}{{#if features.capacitor}},
41
- "@h-ai/capacitor": "^0.1.0-alpha.15"{{/if}}{{#if isCapacitorApp}}{{#unless features.api-client}},
42
- "@h-ai/api-client": "^0.1.0-alpha.15"{{/unless}}{{#unless features.capacitor}},
43
- "@h-ai/capacitor": "^0.1.0-alpha.15"{{/unless}}{{/if}},
24
+ "@h-ai/core": "^0.1.0-alpha.16",
25
+ "@h-ai/kit": "^0.1.0-alpha.16"{{#if hasUi}},
26
+ "@h-ai/ui": "^0.1.0-alpha.16"{{/if}}{{#if features.db}},
27
+ "@h-ai/reldb": "^0.1.0-alpha.16"{{/if}}{{#if features.cache}},
28
+ "@h-ai/cache": "^0.1.0-alpha.16"{{/if}}{{#if features.iam}},
29
+ "@h-ai/iam": "^0.1.0-alpha.16"{{/if}}{{#if features.crypto}},
30
+ "@h-ai/crypto": "^0.1.0-alpha.16"{{/if}}{{#if features.storage}},
31
+ "@h-ai/storage": "^0.1.0-alpha.16"{{/if}}{{#if features.ai}},
32
+ "@h-ai/ai": "^0.1.0-alpha.16"{{/if}}{{#if features.audit}},
33
+ "@h-ai/audit": "^0.1.0-alpha.16"{{/if}}{{#if features.reach}},
34
+ "@h-ai/reach": "^0.1.0-alpha.16"{{/if}}{{#if features.payment}},
35
+ "@h-ai/payment": "^0.1.0-alpha.16"{{/if}}{{#if features.vecdb}},
36
+ "@h-ai/vecdb": "^0.1.0-alpha.16"{{/if}}{{#if features.datapipe}},
37
+ "@h-ai/datapipe": "^0.1.0-alpha.16"{{/if}}{{#if features.scheduler}},
38
+ "@h-ai/scheduler": "^0.1.0-alpha.16"{{/if}}{{#if features.deploy}},
39
+ "@h-ai/deploy": "^0.1.0-alpha.16"{{/if}}{{#if features.api-client}},
40
+ "@h-ai/api-client": "^0.1.0-alpha.16"{{/if}}{{#if features.capacitor}},
41
+ "@h-ai/capacitor": "^0.1.0-alpha.16"{{/if}}{{#if isCapacitorApp}}{{#unless features.api-client}},
42
+ "@h-ai/api-client": "^0.1.0-alpha.16"{{/unless}}{{#unless features.capacitor}},
43
+ "@h-ai/capacitor": "^0.1.0-alpha.16"{{/unless}}{{/if}},
44
44
  "zod": "^4.3.6"
45
45
  },
46
46
  "devDependencies": {
@@ -343,10 +343,11 @@ const adminOnly = serv.requireAuth(
343
343
 
344
344
  #### HTTP middleware
345
345
 
346
- 适用于请求日志、trace、限流、CORS、租户头校验等 **HTTP 层** 横切逻辑:
346
+ 适用于请求日志、trace、限流、CORS、租户头校验等 **HTTP 层** 横切逻辑。常见 CORS 场景可直接复用 `serv.cors(...)`:
347
347
 
348
348
  ```typescript
349
349
  import type { ServMiddleware } from '@h-ai/serv'
350
+ import { serv } from '@h-ai/serv'
350
351
 
351
352
  const requestMetrics: ServMiddleware = async (c, next) => {
352
353
  const startedAt = Date.now()
@@ -359,6 +360,13 @@ const app = serv.createApp({
359
360
  procedures,
360
361
  http: { apiPrefix: '/api/v1' },
361
362
  middlewares: [
363
+ {
364
+ middleware: serv.cors({
365
+ origin: origin => origin === 'https://app.example.com',
366
+ credentials: true,
367
+ exposedHeaders: ['X-Encrypted', 'X-Request-Id'],
368
+ }),
369
+ },
362
370
  { middleware: requestMetrics },
363
371
  {
364
372
  path: '/api/v1/*',
@@ -372,7 +380,10 @@ const app = serv.createApp({
372
380
  })
373
381
  ```
374
382
 
375
- 执行顺序固定为:`securityHeaders` → `transport`(若启用)→ `middlewares` → health/refresh-cookie/OpenAPI/RPC/docs/oRPC routes。
383
+ 执行顺序固定为:`securityHeaders` → `middlewares` → `transport`(若启用)→ health/refresh-cookie/OpenAPI/RPC/docs/oRPC routes。
384
+
385
+ - `middlewares` 先于 `transport` 执行,因此 CORS 这类 preflight middleware 可以直接短路返回;若需要读取解密后的业务 body,请改用 context / procedure 层扩展。
386
+ - 浏览器若需读取自定义响应头(例如 transport 的 `X-Encrypted`),记得通过 `serv.cors({ exposedHeaders: [...] })` 显式暴露。
376
387
 
377
388
  #### Context pipeline
378
389