@h-ai/serv 0.1.0-alpha.56 → 0.1.0-alpha.58
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 +657 -0
- package/README.ja.md +657 -0
- package/README.md +11 -1
- package/dist/{chunk-KIWHKWLD.js → chunk-R354OMWL.js} +5 -2
- package/dist/chunk-R354OMWL.js.map +1 -0
- package/dist/features/ai.d.ts +19 -19
- package/dist/features/ai.js +1 -1
- package/dist/features/iam.d.ts +57 -57
- package/dist/features/iam.js +1 -1
- package/dist/features/storage.d.ts +17 -17
- package/dist/features/storage.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +17 -12
- package/dist/index.js.map +1 -1
- package/dist/{serv-context-jc3rZxbj.d.ts → serv-context-CkbS0M9G.d.ts} +4 -4
- package/package.json +23 -22
- package/dist/chunk-KIWHKWLD.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# @h-ai/serv
|
|
2
2
|
|
|
3
|
+
[简体中文](./README.md) | [English](./README.en.md) | [日本語](./README.ja.md)
|
|
4
|
+
|
|
5
|
+
[框架首页](../../README.md) · 相关模块:[@h-ai/ai](../ai/README.md) · [@h-ai/api-contract](../api-contract/README.md) · [@h-ai/core](../core/README.md) · [@h-ai/crypto](../crypto/README.md) · [@h-ai/iam](../iam/README.md) · [@h-ai/storage](../storage/README.md)
|
|
6
|
+
|
|
3
7
|
> hai-framework 的 API 服务运行时:对外暴露稳定的 HTTP App 抽象,把 `@h-ai/api-contract` 契约挂载为跨端可访问的 HTTP API;Hono 仅作为内部运行时实现。
|
|
4
8
|
|
|
5
9
|
## 能力概览
|
|
@@ -10,6 +14,8 @@
|
|
|
10
14
|
- 自定义 pipeline:`createApp({ middlewares })` 挂 HTTP middleware;请求级字段通过 context 工厂注入
|
|
11
15
|
- 只读 Storage 资源:`serv.storageAssets(...)` 统一处理安全 key、MIME 白名单、GET/HEAD、ETag 与缓存头
|
|
12
16
|
- 默认 feature procedures:`createIamProcedures()`、`createStorageProcedures()`、`createAiProcedures()`
|
|
17
|
+
- `build()` 同步返回普通 router,可按嵌套属性选取默认 feature procedures;挂载的 contract 与所选 procedures 保持一致,未选入口不开放。
|
|
18
|
+
- 缺失路由返回本地化的 HaiResult JSON 404,启用传输加密后保留 404,不误报为非 JSON 响应导致的 500。
|
|
13
19
|
- 内置安全响应头、健康检查、可选 OpenAPI JSON、可选 Scalar 文档页、可选内部 RPC endpoint
|
|
14
20
|
- 可选传输加密:`serv.createApp({ transport: { crypto } })` 自动挂载密钥协商与请求/响应加解密
|
|
15
21
|
- 可选语音入口:`serv.createApp({ audio: { ai, verifyTicket, authorize } })` 挂载统一语音 WebSocket;连接建立即用一次性 ticket 鉴权(返回 `{ session, grant? }`,独立预鉴权超时),每帧运行时 Zod 校验 + 严格状态机,输入/积压/发送缓冲背压与级联取消;授权回调负责服务端确认操作、模型、音色、配额与并发占用
|
|
@@ -376,7 +382,7 @@ const procedures = serv
|
|
|
376
382
|
|
|
377
383
|
约束:
|
|
378
384
|
|
|
379
|
-
- `.permission()` 与 `.role()`
|
|
385
|
+
- `.permission()` 与 `.role()` 自动要求认证;未登录/授权不足返回失败 HaiResult,`error.httpStatus` 分别为 401/403;普通 procedure 的 HTTP 响应默认仍为 200。
|
|
380
386
|
- 同一路由声明多个 permission/role 时必须全部满足;`serv.WILDCARD_PERMISSION` / `serv.WILDCARD_ROLE` 可放行对应类别。
|
|
381
387
|
- handler 抛出的未处理异常统一转成 INTERNAL_ERROR HaiResult;预期业务失败仍应直接返回 `err(...)`。
|
|
382
388
|
- 路径、input、output 从 contract 推导;重复或未知路径会被拒绝,未实现完整 contract 时不能调用 `.build()`。
|
|
@@ -589,6 +595,10 @@ const app = serv.createApp({
|
|
|
589
595
|
|
|
590
596
|
## 错误处理
|
|
591
597
|
|
|
598
|
+
普通 procedure 的认证、授权、业务失败和被捕获的 handler 异常都作为 `HaiResult` 输出,默认通过 HTTP 200 返回;`error.httpStatus` 是领域错误元数据,不会自动改写响应状态。客户端必须检查 `success` 与 `error.code`。例如未登录为 `error.httpStatus=401`,数据库查询失败或 INTERNAL_ERROR 为 500。
|
|
599
|
+
|
|
600
|
+
oRPC contract 输入校验在 procedure 之前失败时返回 HTTP 400,本地化失败体包含 `error.httpStatus=400` 和字段错误;procedure 内 `serv.validateInputOrFail` 返回的失败仍为 HTTP 200。HTTP middleware、refresh-cookie、OpenAPI/RPC 权限与 transport 协议错误另按自身契约返回真实 HTTP 状态。api-client 在真实 HTTP 401 或 HTTP 200 的有效失败 HaiResult(`success=false`、字符串 `error.code/message`、`error.httpStatus=401`)后自动刷新,成功后只重试一次;内置登录、注册和配置的刷新路径除外,403/500 不刷新。启用 transport 时刷新和重试复用加密链路。
|
|
601
|
+
|
|
592
602
|
- Default procedures 全部返回 `HaiResult<T>`,客户端直接判断 `result.success`
|
|
593
603
|
- 认证失败 → `HaiCommonError.UNAUTHORIZED`(由 `.auth()` 按 `context.locale` 本地化)
|
|
594
604
|
- 授权失败 → `HaiCommonError.FORBIDDEN`(由 `.permission()` / `.role()` 按 `context.locale` 本地化)
|
|
@@ -184,6 +184,7 @@ var ServRouterBuilderRuntime = class {
|
|
|
184
184
|
this.expectedPaths = new Set(collectProcedurePaths(contract));
|
|
185
185
|
this.implementedRoutes = createRouterShape(contract);
|
|
186
186
|
}
|
|
187
|
+
implementer;
|
|
187
188
|
expectedPaths;
|
|
188
189
|
implementedRoutes;
|
|
189
190
|
registeredPaths = /* @__PURE__ */ new Set();
|
|
@@ -231,6 +232,8 @@ var ServRouteRegistrationRuntime = class {
|
|
|
231
232
|
this.parent = parent;
|
|
232
233
|
this.path = path;
|
|
233
234
|
}
|
|
235
|
+
parent;
|
|
236
|
+
path;
|
|
234
237
|
authRequired = false;
|
|
235
238
|
permissions = /* @__PURE__ */ new Set();
|
|
236
239
|
roles = /* @__PURE__ */ new Set();
|
|
@@ -313,5 +316,5 @@ function getHandlerMethod(value) {
|
|
|
313
316
|
}
|
|
314
317
|
|
|
315
318
|
export { WILDCARD_PERMISSION, WILDCARD_ROLE, buildHaiErrorBody, implement, normalizeServLocale, servM };
|
|
316
|
-
//# sourceMappingURL=chunk-
|
|
317
|
-
//# sourceMappingURL=chunk-
|
|
319
|
+
//# sourceMappingURL=chunk-R354OMWL.js.map
|
|
320
|
+
//# sourceMappingURL=chunk-R354OMWL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../messages/en-US.json","../messages/zh-CN.json","../src/serv-i18n.ts","../src/pipelines/serv-pipeline-guard.ts","../src/pipelines/serv-pipeline-helper.ts","../src/serv-router.ts"],"names":["err","HaiCommonError","orpcImplement"],"mappings":";;;;;;AAAA,IAAA,aAAA,GAAA;AAAA,EACE,OAAA,EAAW,iDAAA;AAAA,EACX,qBAAA,EAAyB,mBAAA;AAAA,EACzB,uBAAA,EAA2B,wBAAA;AAAA,EAC3B,sBAAA,EAA0B,sBAAA;AAAA,EAC1B,0BAAA,EAA8B,oBAAA;AAAA,EAC9B,wBAAA,EAA4B,iCAAA;AAAA,EAC5B,wBAAA,EAA4B,gCAAA;AAAA,EAC5B,wBAAA,EAA4B,8BAAA;AAAA,EAC5B,wBAAA,EAA4B,6BAAA;AAAA,EAC5B,uBAAA,EAA2B,+BAAA;AAAA,EAC3B,uBAAA,EAA2B,8BAAA;AAAA,EAC3B,uBAAA,EAA2B,8BAAA;AAAA,EAC3B,qBAAA,EAAyB,6BAAA;AAAA,EACzB,oBAAA,EAAwB,6BAAA;AAAA,EACxB,kBAAA,EAAsB,mBAAA;AAAA,EACtB,mBAAA,EAAuB,oBAAA;AAAA,EACvB,mBAAA,EAAuB,uBAAA;AAAA,EACvB,sBAAA,EAA0B,cAAA;AAAA,EAC1B,mBAAA,EAAuB,WAAA;AAAA,EACvB,kBAAA,EAAsB,uBAAA;AAAA,EACtB,uBAAA,EAA2B,+BAAA;AAAA,EAC3B,sBAAA,EAA0B,8CAAA;AAAA,EAC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KAAY,UAAA,GACtB,OAAA,GACA,MAAA;AACN","file":"chunk-R354OMWL.js","sourcesContent":["{\n \"$schema\": \"https://inlang.com/schema/inlang-message-format\",\n \"serv_validationFailed\": \"Validation failed\",\n \"serv_validationRequired\": \"This field is required\",\n \"serv_validationInvalid\": \"Invalid input format\",\n \"serv_validationInvalidType\": \"Invalid field type\",\n \"serv_validationStringMin\": \"Enter at least {min} characters\",\n \"serv_validationStringMax\": \"Enter at most {max} characters\",\n \"serv_validationNumberMin\": \"Value must be at least {min}\",\n \"serv_validationNumberMax\": \"Value must be at most {max}\",\n \"serv_validationArrayMin\": \"Select at least {min} item(s)\",\n \"serv_validationArrayMax\": \"Select at most {max} item(s)\",\n \"serv_validationTooSmall\": \"Value must be at least {min}\",\n \"serv_validationTooBig\": \"Value must be at most {max}\",\n \"serv_validationEmail\": \"Enter a valid email address\",\n \"serv_validationUrl\": \"Enter a valid URL\",\n \"serv_validationUuid\": \"Enter a valid UUID\",\n \"serv_validationEnum\": \"Select a valid option\",\n \"serv_errorUnauthorized\": \"Unauthorized\",\n \"serv_errorForbidden\": \"Forbidden\",\n \"serv_errorInternal\": \"Internal server error\",\n \"serv_storageKeyRequired\": \"Storage key must not be empty\",\n \"serv_storageKeyTooLong\": \"Storage key must not exceed {max} characters\",\n \"serv_storageKeyIllegalChars\": \"Storage key contains illegal characters\",\n \"serv_storageKeyDotSegments\": \"Storage key must not contain . or .. path segments\",\n \"serv_iamCannotDeleteCurrentUser\": \"Cannot delete the current logged-in user\",\n \"serv_transportInvalidPayload\": \"Invalid encrypted transport payload\",\n \"serv_transportUnknownClient\": \"Unknown encryption client; key exchange required\",\n \"serv_transportClientIdRequired\": \"Missing X-Client-Id header; key exchange required\",\n \"serv_transportClientKeyNotFound\": \"Client not registered or session expired; complete key exchange again\",\n \"serv_transportDecryptFailed\": \"Failed to decrypt request\",\n \"serv_transportEncryptFailed\": \"Failed to encrypt response\",\n \"serv_transportKeyExchangeFailed\": \"Key exchange failed\"\n}\n","{\n \"$schema\": \"https://inlang.com/schema/inlang-message-format\",\n \"serv_validationFailed\": \"数据验证失败\",\n \"serv_validationRequired\": \"此字段必填\",\n \"serv_validationInvalid\": \"输入格式无效\",\n \"serv_validationInvalidType\": \"字段类型不正确\",\n \"serv_validationStringMin\": \"至少输入 {min} 个字符\",\n \"serv_validationStringMax\": \"最多输入 {max} 个字符\",\n \"serv_validationNumberMin\": \"数值不能小于 {min}\",\n \"serv_validationNumberMax\": \"数值不能大于 {max}\",\n \"serv_validationArrayMin\": \"至少选择 {min} 项\",\n \"serv_validationArrayMax\": \"最多选择 {max} 项\",\n \"serv_validationTooSmall\": \"不能小于 {min}\",\n \"serv_validationTooBig\": \"不能大于 {max}\",\n \"serv_validationEmail\": \"请输入有效的邮箱地址\",\n \"serv_validationUrl\": \"请输入有效的网址\",\n \"serv_validationUuid\": \"请输入有效的 UUID\",\n \"serv_validationEnum\": \"请选择有效选项\",\n \"serv_errorUnauthorized\": \"未登录或登录已失效\",\n \"serv_errorForbidden\": \"无权执行该操作\",\n \"serv_errorInternal\": \"服务器内部错误\",\n \"serv_storageKeyRequired\": \"存储 key 不能为空\",\n \"serv_storageKeyTooLong\": \"存储 key 不能超过 {max} 个字符\",\n \"serv_storageKeyIllegalChars\": \"存储 key 包含非法字符\",\n \"serv_storageKeyDotSegments\": \"存储 key 不能包含 . 或 .. 路径段\",\n \"serv_iamCannotDeleteCurrentUser\": \"不能删除当前登录用户\",\n \"serv_transportInvalidPayload\": \"传输层加密载荷格式无效\",\n \"serv_transportUnknownClient\": \"未识别的加密客户端,请先完成密钥协商\",\n \"serv_transportClientIdRequired\": \"缺少 X-Client-Id 请求头,请先完成密钥协商\",\n \"serv_transportClientKeyNotFound\": \"客户端未注册或会话已过期,请重新完成密钥协商\",\n \"serv_transportDecryptFailed\": \"请求解密失败\",\n \"serv_transportEncryptFailed\": \"响应加密失败\",\n \"serv_transportKeyExchangeFailed\": \"密钥协商失败\"\n}\n","/**\n * @h-ai/serv — i18n 工具\n *\n * Serv 模块的国际化消息工具,从 @h-ai/core 调用 i18n API。\n * 与 kit-i18n 结构对齐,便于跨包统一维护。\n * @module serv-i18n\n */\n\nimport { core } from '@h-ai/core'\nimport messagesEnUS from '../messages/en-US.json'\nimport messagesZhCN from '../messages/zh-CN.json'\n\ntype ServMessageKey = keyof typeof messagesZhCN\n\nconst SUPPORTED_SERV_LOCALES = ['zh-CN', 'en-US'] as const\nconst DEFAULT_SERV_LOCALE = 'zh-CN'\n\n/**\n * 规范化 serv 请求 locale。\n *\n * 支持:\n * - 完整 locale:`zh-CN` / `en-US`\n * - 简写:`zh` / `en`\n * - `Accept-Language` 风格值:`en-US,en;q=0.9`\n *\n * 未识别时回退到默认 `zh-CN`。\n */\nexport function normalizeServLocale(locale: string | undefined): string {\n const candidate = locale?.split(',')[0]?.trim()\n if (!candidate)\n return DEFAULT_SERV_LOCALE\n\n const exact = SUPPORTED_SERV_LOCALES.find(item => item.toLowerCase() === candidate.toLowerCase())\n if (exact)\n return exact\n\n const baseLanguage = candidate.split('-')[0]?.toLowerCase()\n if (baseLanguage === 'en')\n return 'en-US'\n if (baseLanguage === 'zh')\n return 'zh-CN'\n\n return DEFAULT_SERV_LOCALE\n}\n\n/**\n * 获取 Serv 模块的 i18n 消息。\n *\n * 单次调用可通过 `options.locale` 指定该次调用使用的语言,\n * 用于在请求处理过程中根据 `Accept-Language` 头本地化错误消息,\n * 而不污染全局 locale(多并发请求安全)。\n *\n * @example\n * ```ts\n * // 使用全局 locale\n * servM('serv_validationRequired')\n *\n * // 使用请求自身的 locale\n * servM('serv_validationStringMin', { locale: 'en-US', params: { min: 3 } })\n * ```\n */\nexport const servM\n = core.i18n.createMessageGetter<ServMessageKey>({ 'zh-CN': messagesZhCN, 'en-US': messagesEnUS })\n\nexport type { ServMessageKey }\n","/**\n * @h-ai/serv — procedure 认证与授权 guard\n *\n * 将认证、权限、角色及异常映射合并为单个 handler 包装层,并在类型上把\n * `context.session` 收窄为非空。\n *\n * @module pipelines/serv-pipeline-guard\n */\n\nimport type { HaiResult } from '@h-ai/core'\nimport type { ErrorMap, Meta, ProcedureHandler } from '@orpc/server'\nimport type { ServContext } from '../serv-context.js'\nimport type { AuthenticatedServContext } from '../serv-router.js'\nimport { err, HaiCommonError } from '@h-ai/core'\nimport { servM } from '../serv-i18n.js'\n\n/**\n * 通配符权限。仅应授予受信任的超级管理员,可通过任意 permission guard。\n */\nexport const WILDCARD_PERMISSION = '*'\n\n/**\n * 通配符角色。仅应授予受信任的超级管理员,可通过任意 role guard。\n */\nexport const WILDCARD_ROLE = '*'\n\nexport interface ServGuardRequirements {\n readonly auth?: boolean\n readonly permissions?: readonly string[]\n readonly roles?: readonly string[]\n}\n\n/**\n * 将 guard 应用于一个使用 HaiResult 输出的 oRPC handler。\n *\n * 完整保留 oRPC 的 `path`、`procedure`、`signal`、`lastEventId`、`errors` 等\n * options;只在校验成功后把 `context` 收窄为带非空 session 的类型。\n */\nexport function applyServGuards<\n TContext extends ServContext,\n TInput,\n TData,\n TErrorMap extends ErrorMap,\n TMeta extends Meta,\n>(\n requirements: ServGuardRequirements,\n handler: ProcedureHandler<\n AuthenticatedServContext<TContext>,\n TInput,\n HaiResult<TData>,\n TErrorMap,\n TMeta\n >,\n): ProcedureHandler<TContext, TInput, HaiResult<TData>, TErrorMap, TMeta> {\n return async (options) => {\n try {\n if (!hasAuthenticatedSession(options.context)) {\n return err(\n HaiCommonError.UNAUTHORIZED,\n servM('serv_errorUnauthorized', { locale: options.context.locale }),\n )\n }\n\n const { session } = options.context\n if (requirements.permissions?.length) {\n const allowed = session.permissions.includes(WILDCARD_PERMISSION)\n || requirements.permissions.every(\n permission => session.permissions.includes(permission),\n )\n if (!allowed) {\n return err(\n HaiCommonError.FORBIDDEN,\n servM('serv_errorForbidden', { locale: options.context.locale }),\n )\n }\n }\n\n if (requirements.roles?.length) {\n const allowed = session.roles.includes(WILDCARD_ROLE)\n || requirements.roles.every(\n role => session.roles.includes(role),\n )\n if (!allowed) {\n return err(\n HaiCommonError.FORBIDDEN,\n servM('serv_errorForbidden', { locale: options.context.locale }),\n )\n }\n }\n\n return await handler({\n ...options,\n context: options.context,\n })\n }\n catch (error) {\n return err(\n HaiCommonError.INTERNAL_ERROR,\n servM('serv_errorInternal', { locale: options.context.locale }),\n error,\n )\n }\n }\n}\n\nfunction hasAuthenticatedSession<TContext extends ServContext>(\n context: TContext,\n): context is AuthenticatedServContext<TContext> {\n return context.session !== undefined && context.session !== null\n}\n","/**\n * @h-ai/serv — Pipeline 公共 helper\n *\n * 放置不属于 Hono middleware / route guard 默认实现本身、\n * 但会被多个 pipeline 复用的公共工具。\n * @module pipelines/serv-pipeline-helper\n */\n\nimport type { ServProcedureHandler } from './serv-pipeline-types.js'\nimport { err, HaiCommonError } from '@h-ai/core'\nimport { servM } from '../serv-i18n.js'\n\n/** 构造 `HaiResult` 失败分支同构的 HTTP 错误定义。 */\nexport interface ServErrorBodyDef {\n readonly code: string | number\n readonly httpStatus: number\n readonly system: string\n readonly module: string\n}\n\n/**\n * 构造与 `HaiResult` 失败分支同构的 HTTP 响应体。\n *\n * - 字段顺序与 `haiResultSchema()` 输出一致,便于客户端统一解析。\n * - 仅暴露最小信息(code/message/httpStatus),避免泄漏内部细节。\n */\nexport function buildHaiErrorBody(def: ServErrorBodyDef, message: string) {\n return {\n success: false as const,\n error: {\n code: def.code,\n message,\n httpStatus: def.httpStatus,\n system: def.system,\n module: def.module,\n },\n }\n}\n\n/**\n * 捕获未处理异常并转换为 HaiResult。\n *\n * 由 contract router 在注册 handler 时统一应用,业务代码无需手动包装。\n *\n * @param handler - 被包装的 procedure handler\n * @returns 带异常保护的新 handler\n */\nexport function mapHaiError<TInput, TOutput>(handler: ServProcedureHandler<TInput, TOutput>): ServProcedureHandler<TInput, TOutput> {\n return async (options) => {\n try {\n return await handler(options)\n }\n catch (error) {\n // 所有未捕获异常统一在这里收口,避免直接把异常冒泡到 HTTP 层。\n return err(HaiCommonError.INTERNAL_ERROR, servM('serv_errorInternal', { locale: options.context.locale }), error)\n }\n }\n}\n","/**\n * @h-ai/serv — contract-first 链式 procedure 实现器\n *\n * 在 oRPC `implement()` 之上提供 route 名只出现一次的链式 DSL。\n * 应用只接触 contract 路径、上下文与 guard,不需要组装 oRPC router 对象。\n *\n * @module serv-router\n */\n\nimport type { HaiResult } from '@h-ai/core'\nimport type {\n Context,\n ContractProcedure,\n ContractRouter,\n ErrorMap,\n Implementer,\n InferSchemaInput,\n InferSchemaOutput,\n Meta,\n ProcedureHandler,\n Router,\n UnlaziedRouter,\n} from '@orpc/server'\nimport type { ServGuardRequirements } from './pipelines/serv-pipeline-guard.js'\nimport type { ServContext } from './serv-context.js'\nimport { implement as orpcImplement } from '@orpc/server'\nimport { applyServGuards } from './pipelines/serv-pipeline-guard.js'\nimport { mapHaiError } from './pipelines/serv-pipeline-helper.js'\n\ntype EmptyContext = Record<never, never>\ntype StringKey<T> = Extract<keyof T, string>\ntype ServContract = ContractRouter<Meta>\n\n/** contract 中所有 procedure 的点分路径。 */\nexport type ServRoutePath<TContract extends ServContract>\n = TContract extends ContractProcedure<\n infer _TInputSchema,\n infer _TOutputSchema,\n infer _TErrorMap,\n infer _TMeta\n >\n ? never\n : {\n [K in StringKey<TContract>]: TContract[K] extends ContractProcedure<\n infer _TChildInputSchema,\n infer _TChildOutputSchema,\n infer _TChildErrorMap,\n infer _TChildMeta\n >\n ? K\n : TContract[K] extends ServContract\n ? ServRoutePath<TContract[K]> extends infer TChild extends string\n ? `${K}.${TChild}`\n : never\n : never\n }[StringKey<TContract>]\n\ntype ContractAtPath<TContract, TPath extends string>\n = TPath extends `${infer THead}.${infer TTail}`\n ? THead extends keyof TContract\n ? ContractAtPath<TContract[THead], TTail>\n : never\n : TPath extends keyof TContract\n ? TContract[TPath]\n : never\n\ntype RouteContract<\n TContract extends ServContract,\n TPath extends ServRoutePath<TContract>,\n> = ContractAtPath<TContract, TPath>\n\n/** `.auth()`、`.permission()`、`.role()` 后的非空会话上下文。 */\nexport type AuthenticatedServContext<TContext extends ServContext = ServContext>\n = TContext & {\n readonly session: NonNullable<TContext['session']>\n }\n\ntype RouteHandler<\n TRouteContract,\n TContext extends Context,\n> = TRouteContract extends ContractProcedure<\n infer TInputSchema,\n infer TOutputSchema,\n infer TErrorMap,\n infer TMeta\n>\n ? InferSchemaInput<TOutputSchema> extends HaiResult<unknown>\n ? ProcedureHandler<\n TContext,\n InferSchemaOutput<TInputSchema>,\n InferSchemaInput<TOutputSchema>,\n TErrorMap,\n TMeta\n >\n : never\n : never\n\n/** 从 contract procedure 精确推导当前 route 的 HaiResult handler。 */\nexport type ServRouteHandler<\n TContract extends ServContract,\n TPath extends ServRoutePath<TContract>,\n TContext extends Context,\n> = RouteHandler<RouteContract<TContract, TPath>, TContext>\n\ntype ServGuardedRouteHandler<\n TContract extends ServContract,\n TPath extends ServRoutePath<TContract>,\n TContext extends ServContext,\n> = RouteHandler<RouteContract<TContract, TPath>, AuthenticatedServContext<TContext>>\n\ntype NextBuilder<\n TContract extends ServContract,\n TInitialContext extends Context,\n TCurrentContext extends ServContext,\n TRemaining extends ServRoutePath<TContract>,\n TPath extends TRemaining,\n> = ServRouterBuilder<\n TContract,\n TInitialContext,\n TCurrentContext,\n Exclude<TRemaining, TPath>\n>\n\n/** 尚未声明 guard 的单 route 注册器。 */\nexport interface ServRouteRegistration<\n TContract extends ServContract,\n TInitialContext extends Context,\n TCurrentContext extends ServContext,\n TRemaining extends ServRoutePath<TContract>,\n TPath extends TRemaining,\n> {\n readonly auth: () => ServGuardedRouteRegistration<\n TContract,\n TInitialContext,\n TCurrentContext,\n TRemaining,\n TPath\n >\n readonly permission: (permission: string) => ServGuardedRouteRegistration<\n TContract,\n TInitialContext,\n TCurrentContext,\n TRemaining,\n TPath\n >\n readonly role: (role: string) => ServGuardedRouteRegistration<\n TContract,\n TInitialContext,\n TCurrentContext,\n TRemaining,\n TPath\n >\n}\n\n/** 已声明认证或授权 guard 的单 route 注册器。 */\nexport interface ServGuardedRouteRegistration<\n TContract extends ServContract,\n TInitialContext extends Context,\n TCurrentContext extends ServContext,\n TRemaining extends ServRoutePath<TContract>,\n TPath extends TRemaining,\n> {\n readonly auth: () => ServGuardedRouteRegistration<\n TContract,\n TInitialContext,\n TCurrentContext,\n TRemaining,\n TPath\n >\n readonly permission: (permission: string) => ServGuardedRouteRegistration<\n TContract,\n TInitialContext,\n TCurrentContext,\n TRemaining,\n TPath\n >\n readonly role: (role: string) => ServGuardedRouteRegistration<\n TContract,\n TInitialContext,\n TCurrentContext,\n TRemaining,\n TPath\n >\n readonly handle: (\n handler: ServGuardedRouteHandler<TContract, TPath, TCurrentContext>,\n ) => NextBuilder<TContract, TInitialContext, TCurrentContext, TRemaining, TPath>\n}\n\ninterface ServRouteMethod<\n TContract extends ServContract,\n TInitialContext extends Context,\n TCurrentContext extends ServContext,\n TRemaining extends ServRoutePath<TContract>,\n> {\n <TPath extends TRemaining>(\n path: TPath,\n handler: ServRouteHandler<TContract, TPath, TCurrentContext>,\n ): NextBuilder<TContract, TInitialContext, TCurrentContext, TRemaining, TPath>\n <TPath extends TRemaining>(\n path: TPath,\n ): ServRouteRegistration<\n TContract,\n TInitialContext,\n TCurrentContext,\n TRemaining,\n TPath\n >\n}\n\ntype ServRouterBuilderBuild<\n TContract extends ServContract,\n TInitialContext extends Context,\n TRemaining,\n> = [TRemaining] extends [never]\n ? {\n /** 同步返回完整的普通 router,允许按需选用嵌套的默认 procedures。 */\n readonly build: () => UnlaziedRouter<Router<TContract, TInitialContext>>\n }\n : {\n /** 仅供 TypeScript/IDE 展示尚未实现的 route;运行时不存在。 */\n readonly missingRoutes: TRemaining\n }\n\n/**\n * 链式 router builder。\n *\n * `TRemaining` 会随着 `.route()` 注册逐步收窄;未实现完整 contract 时没有 `.build()`。\n */\nexport type ServRouterBuilder<\n TContract extends ServContract,\n TInitialContext extends Context,\n TCurrentContext extends ServContext,\n TRemaining extends ServRoutePath<TContract> = ServRoutePath<TContract>,\n> = {\n readonly route: ServRouteMethod<\n TContract,\n TInitialContext,\n TCurrentContext,\n TRemaining\n >\n} & ServRouterBuilderBuild<TContract, TInitialContext, TRemaining>\n\n/** hai-framework 链式 contract 实现器。 */\nexport interface ServImplementer<TContract extends ServContract> {\n readonly context: <TContext extends ServContext>() => ServRouterBuilder<\n TContract,\n TContext & EmptyContext,\n TContext\n >\n}\n\n/**\n * 创建链式 contract 实现器。\n *\n * @example\n * ```ts\n * serv\n * .implement(contract)\n * .context<ServContext>()\n * .route('info', infoHandler)\n * .route('echo')\n * .auth()\n * .handle(echoHandler)\n * .build()\n * ```\n */\nexport function implement<TContract extends ServContract>(\n contract: TContract,\n): ServImplementer<TContract> {\n return {\n context: <TContext extends ServContext>() => {\n const native = orpcImplement(contract).$context<TContext>()\n return createServRouterBuilder(contract, native)\n },\n }\n}\n\nfunction createServRouterBuilder<\n TContract extends ServContract,\n TInitialContext extends Context,\n TCurrentContext extends ServContext,\n>(\n contract: TContract,\n implementer: Implementer<TContract, TInitialContext, TCurrentContext>,\n): ServRouterBuilder<TContract, TInitialContext, TCurrentContext> {\n const runtime = new ServRouterBuilderRuntime(contract, implementer)\n\n // oRPC 的 contract 泛型只能在编译期表示;运行时 builder 由同一 contract\n // 创建并逐项校验路径,因此这里将动态实现收敛到唯一的类型边界。\n return runtime as unknown as ServRouterBuilder<\n TContract,\n TInitialContext,\n TCurrentContext\n >\n}\n\ntype RuntimeProcedureHandler = ProcedureHandler<\n ServContext,\n unknown,\n HaiResult<unknown>,\n ErrorMap,\n Meta\n>\ntype AuthenticatedRuntimeProcedureHandler = ProcedureHandler<\n AuthenticatedServContext,\n unknown,\n HaiResult<unknown>,\n ErrorMap,\n Meta\n>\n\nclass ServRouterBuilderRuntime {\n private readonly expectedPaths: ReadonlySet<string>\n private readonly implementedRoutes: Record<string, unknown>\n private readonly registeredPaths = new Set<string>()\n\n constructor(\n contract: ServContract,\n private readonly implementer: object,\n ) {\n this.expectedPaths = new Set(collectProcedurePaths(contract))\n this.implementedRoutes = createRouterShape(contract)\n }\n\n route(path: string, handler?: unknown): unknown {\n if (handler !== undefined)\n return this.register(path, {}, handler)\n\n return new ServRouteRegistrationRuntime(this, path)\n }\n\n register(path: string, guards: ServGuardRequirements, handler: unknown): this {\n if (!this.expectedPaths.has(path))\n throw new TypeError(`Contract path is not implementable: ${path}`)\n if (this.registeredPaths.has(path))\n throw new TypeError(`Duplicate procedure implementation: ${path}`)\n if (typeof handler !== 'function')\n throw new TypeError(`Procedure handler must be a function: ${path}`)\n\n const procedureImplementer = getAtPath(this.implementer, path)\n const implementHandler = getHandlerMethod(procedureImplementer)\n if (!implementHandler)\n throw new TypeError(`Contract path is not implementable: ${path}`)\n\n // 点路径反射会丢失单条 contract 的泛型;路径已由 expectedPaths 校验,\n // handler 的精确 input/output 则由公开的 ServRouteHandler 在调用侧保证。\n const safeHandler = hasGuards(guards)\n ? applyServGuards(guards, handler as AuthenticatedRuntimeProcedureHandler)\n : mapHaiError(handler as RuntimeProcedureHandler)\n const implemented = Reflect.apply(\n implementHandler,\n procedureImplementer,\n [safeHandler],\n )\n\n setAtPath(this.implementedRoutes, path, implemented)\n this.registeredPaths.add(path)\n return this\n }\n\n build(): unknown {\n const missingPaths = [...this.expectedPaths]\n .filter(path => !this.registeredPaths.has(path))\n .sort()\n if (missingPaths.length > 0) {\n throw new TypeError(\n `Cannot build router. Missing procedures: ${missingPaths.join(', ')}`,\n )\n }\n\n const routerMethod = Reflect.get(this.implementer, 'router')\n if (typeof routerMethod !== 'function')\n throw new TypeError('The oRPC implementer does not expose router()')\n\n return Reflect.apply(routerMethod, this.implementer, [this.implementedRoutes])\n }\n}\n\nclass ServRouteRegistrationRuntime {\n private authRequired = false\n private readonly permissions = new Set<string>()\n private readonly roles = new Set<string>()\n\n constructor(\n private readonly parent: ServRouterBuilderRuntime,\n private readonly path: string,\n ) {}\n\n auth(): this {\n this.authRequired = true\n return this\n }\n\n permission(permission: string): this {\n this.authRequired = true\n this.permissions.add(permission)\n return this\n }\n\n role(role: string): this {\n this.authRequired = true\n this.roles.add(role)\n return this\n }\n\n handle(handler: unknown): ServRouterBuilderRuntime {\n return this.parent.register(this.path, {\n auth: this.authRequired,\n permissions: [...this.permissions],\n roles: [...this.roles],\n }, handler)\n }\n}\n\nfunction hasGuards(guards: ServGuardRequirements): boolean {\n return guards.auth === true\n || (guards.permissions?.length ?? 0) > 0\n || (guards.roles?.length ?? 0) > 0\n}\n\nfunction collectProcedurePaths(\n contract: ServContract,\n prefix: readonly string[] = [],\n): string[] {\n if (isContractProcedure(contract))\n return prefix.length > 0 ? [prefix.join('.')] : []\n\n return Object.entries(contract).flatMap(([key, child]) =>\n collectProcedurePaths(child, [...prefix, key]))\n}\n\nfunction isContractProcedure(contract: ServContract): boolean {\n return '~orpc' in contract\n}\n\nfunction createRouterShape(contract: ServContract): Record<string, unknown> {\n const shape: Record<string, unknown> = Object.create(null)\n\n for (const [key, child] of Object.entries(contract)) {\n if (!isContractProcedure(child))\n shape[key] = createRouterShape(child)\n }\n\n return shape\n}\n\nfunction getAtPath(root: object, path: string): unknown {\n let current: unknown = root\n\n for (const segment of path.split('.')) {\n if (\n (typeof current !== 'object' && typeof current !== 'function')\n || current === null\n || !(segment in current)\n ) {\n return undefined\n }\n\n current = Reflect.get(current, segment)\n }\n\n return current\n}\n\nfunction setAtPath(root: Record<string, unknown>, path: string, value: unknown): void {\n const segments = path.split('.')\n const leaf = segments.pop()\n if (!leaf)\n throw new TypeError('Procedure path cannot be empty')\n\n let current = root\n for (const segment of segments) {\n const existing = current[segment]\n if (existing === undefined) {\n const child: Record<string, unknown> = Object.create(null)\n current[segment] = child\n current = child\n continue\n }\n\n if (!existing || typeof existing !== 'object')\n throw new TypeError(`Procedure path conflicts with an existing route: ${path}`)\n\n current = existing as Record<string, unknown>\n }\n\n current[leaf] = value\n}\n\nfunction getHandlerMethod(value: unknown): ((handler: unknown) => unknown) | undefined {\n if ((typeof value !== 'object' && typeof value !== 'function') || value === null)\n return undefined\n\n const handler = Reflect.get(value, 'handler')\n return typeof handler === 'function'\n ? handler as (handler: unknown) => unknown\n : undefined\n}\n"]}
|
package/dist/features/ai.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _orpc_server from '@orpc/server';
|
|
|
2
2
|
import * as zod_v4_core from 'zod/v4/core';
|
|
3
3
|
import * as zod from 'zod';
|
|
4
4
|
import { AIFunctions } from '@h-ai/ai';
|
|
5
|
-
import {
|
|
5
|
+
import { S as ServContext } from '../serv-context-CkbS0M9G.js';
|
|
6
6
|
import '@h-ai/core';
|
|
7
7
|
|
|
8
8
|
/** AI 默认 procedures 依赖。 */
|
|
@@ -11,8 +11,8 @@ interface AiProcedureDeps {
|
|
|
11
11
|
}
|
|
12
12
|
/** 创建 AI 默认 procedures。 */
|
|
13
13
|
declare function createAiProcedures(deps: AiProcedureDeps): {
|
|
14
|
-
chats:
|
|
15
|
-
createCompletion: _orpc_server.
|
|
14
|
+
chats: {
|
|
15
|
+
createCompletion: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
16
16
|
model: zod.ZodOptional<zod.ZodString>;
|
|
17
17
|
messages: zod.ZodArray<zod.ZodObject<{
|
|
18
18
|
role: zod.ZodEnum<{
|
|
@@ -118,8 +118,8 @@ declare function createAiProcedures(deps: AiProcedureDeps): {
|
|
|
118
118
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
119
119
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
120
120
|
}, zod_v4_core.$strip>;
|
|
121
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
122
|
-
sendMessage: _orpc_server.
|
|
121
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
122
|
+
sendMessage: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
123
123
|
message: zod.ZodString;
|
|
124
124
|
systemPrompt: zod.ZodOptional<zod.ZodString>;
|
|
125
125
|
model: zod.ZodOptional<zod.ZodString>;
|
|
@@ -147,8 +147,8 @@ declare function createAiProcedures(deps: AiProcedureDeps): {
|
|
|
147
147
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
148
148
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
149
149
|
}, zod_v4_core.$strip>;
|
|
150
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
151
|
-
listHistory: _orpc_server.
|
|
150
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
151
|
+
listHistory: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
152
152
|
objectId: zod.ZodString;
|
|
153
153
|
sessionId: zod.ZodString;
|
|
154
154
|
limit: zod.ZodOptional<zod.ZodNumber>;
|
|
@@ -231,10 +231,10 @@ declare function createAiProcedures(deps: AiProcedureDeps): {
|
|
|
231
231
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
232
232
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
233
233
|
}, zod_v4_core.$strip>;
|
|
234
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
235
|
-
}
|
|
236
|
-
memories:
|
|
237
|
-
recall: _orpc_server.
|
|
234
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
235
|
+
};
|
|
236
|
+
memories: {
|
|
237
|
+
recall: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
238
238
|
query: zod.ZodString;
|
|
239
239
|
topK: zod.ZodOptional<zod.ZodNumber>;
|
|
240
240
|
types: zod.ZodOptional<zod.ZodArray<zod.ZodEnum<{
|
|
@@ -279,8 +279,8 @@ declare function createAiProcedures(deps: AiProcedureDeps): {
|
|
|
279
279
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
280
280
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
281
281
|
}, zod_v4_core.$strip>;
|
|
282
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
283
|
-
list: _orpc_server.
|
|
282
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
283
|
+
list: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
284
284
|
types: zod.ZodOptional<zod.ZodArray<zod.ZodEnum<{
|
|
285
285
|
instruction: "instruction";
|
|
286
286
|
fact: "fact";
|
|
@@ -325,10 +325,10 @@ declare function createAiProcedures(deps: AiProcedureDeps): {
|
|
|
325
325
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
326
326
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
327
327
|
}, zod_v4_core.$strip>;
|
|
328
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
329
|
-
}
|
|
330
|
-
sessions:
|
|
331
|
-
list: _orpc_server.
|
|
328
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
329
|
+
};
|
|
330
|
+
sessions: {
|
|
331
|
+
list: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
332
332
|
objectId: zod.ZodString;
|
|
333
333
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
334
334
|
success: zod.ZodLiteral<true>;
|
|
@@ -353,8 +353,8 @@ declare function createAiProcedures(deps: AiProcedureDeps): {
|
|
|
353
353
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
354
354
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
355
355
|
}, zod_v4_core.$strip>;
|
|
356
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
357
|
-
}
|
|
356
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
357
|
+
};
|
|
358
358
|
};
|
|
359
359
|
|
|
360
360
|
export { type AiProcedureDeps, createAiProcedures };
|
package/dist/features/ai.js
CHANGED
package/dist/features/iam.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as zod_v4_core from 'zod/v4/core';
|
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { IamFunctions } from '@h-ai/iam';
|
|
6
6
|
export { TokenPair } from '@h-ai/iam';
|
|
7
|
-
import {
|
|
7
|
+
import { S as ServContext } from '../serv-context-CkbS0M9G.js';
|
|
8
8
|
import '@h-ai/core';
|
|
9
9
|
|
|
10
10
|
/** IAM 默认 procedures 依赖。 */
|
|
@@ -13,8 +13,8 @@ interface IamProcedureDeps {
|
|
|
13
13
|
}
|
|
14
14
|
/** 创建 IAM 默认 procedures。 */
|
|
15
15
|
declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
16
|
-
auth:
|
|
17
|
-
login: _orpc_server.
|
|
16
|
+
auth: {
|
|
17
|
+
login: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
18
18
|
identifier: zod.ZodString;
|
|
19
19
|
password: zod.ZodString;
|
|
20
20
|
rememberMe: zod.ZodOptional<zod.ZodBoolean>;
|
|
@@ -62,8 +62,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
62
62
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
63
63
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
64
64
|
}, zod_v4_core.$strip>;
|
|
65
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
66
|
-
loginWithOtp: _orpc_server.
|
|
65
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
66
|
+
loginWithOtp: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
67
67
|
identifier: zod.ZodString;
|
|
68
68
|
code: zod.ZodString;
|
|
69
69
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
@@ -110,8 +110,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
110
110
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
111
111
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
112
112
|
}, zod_v4_core.$strip>;
|
|
113
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
114
|
-
logout: _orpc_server.
|
|
113
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
114
|
+
logout: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
115
115
|
accessToken: zod.ZodOptional<zod.ZodString>;
|
|
116
116
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
117
117
|
success: zod.ZodLiteral<true>;
|
|
@@ -128,8 +128,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
128
128
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
129
129
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
130
130
|
}, zod_v4_core.$strip>;
|
|
131
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
132
|
-
currentUser: _orpc_server.
|
|
131
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
132
|
+
currentUser: _orpc_server.Procedure<ServContext & {}, any, _orpc_contract.Schema<unknown, unknown>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
133
133
|
success: zod.ZodLiteral<true>;
|
|
134
134
|
data: zod.ZodObject<{
|
|
135
135
|
id: zod.ZodString;
|
|
@@ -159,8 +159,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
159
159
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
160
160
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
161
161
|
}, zod_v4_core.$strip>;
|
|
162
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
163
|
-
refresh: _orpc_server.
|
|
162
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
163
|
+
refresh: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
164
164
|
refreshToken: zod.ZodString;
|
|
165
165
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
166
166
|
success: zod.ZodLiteral<true>;
|
|
@@ -184,8 +184,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
184
184
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
185
185
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
186
186
|
}, zod_v4_core.$strip>;
|
|
187
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
188
|
-
sendOtp: _orpc_server.
|
|
187
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
188
|
+
sendOtp: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
189
189
|
identifier: zod.ZodString;
|
|
190
190
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
191
191
|
success: zod.ZodLiteral<true>;
|
|
@@ -204,8 +204,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
204
204
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
205
205
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
206
206
|
}, zod_v4_core.$strip>;
|
|
207
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
208
|
-
register: _orpc_server.
|
|
207
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
208
|
+
register: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
209
209
|
username: zod.ZodString;
|
|
210
210
|
password: zod.ZodString;
|
|
211
211
|
email: zod.ZodOptional<zod.ZodString>;
|
|
@@ -256,8 +256,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
256
256
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
257
257
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
258
258
|
}, zod_v4_core.$strip>;
|
|
259
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
260
|
-
changePassword: _orpc_server.
|
|
259
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
260
|
+
changePassword: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
261
261
|
oldPassword: zod.ZodString;
|
|
262
262
|
newPassword: zod.ZodString;
|
|
263
263
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
@@ -275,8 +275,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
275
275
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
276
276
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
277
277
|
}, zod_v4_core.$strip>;
|
|
278
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
279
|
-
updateCurrentUser: _orpc_server.
|
|
278
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
279
|
+
updateCurrentUser: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
280
280
|
username: zod.ZodOptional<zod.ZodString>;
|
|
281
281
|
email: zod.ZodOptional<zod.ZodString>;
|
|
282
282
|
displayName: zod.ZodOptional<zod.ZodString>;
|
|
@@ -311,10 +311,10 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
311
311
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
312
312
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
313
313
|
}, zod_v4_core.$strip>;
|
|
314
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
315
|
-
}
|
|
316
|
-
users:
|
|
317
|
-
list: _orpc_server.
|
|
314
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
315
|
+
};
|
|
316
|
+
users: {
|
|
317
|
+
list: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
318
318
|
page: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
|
|
319
319
|
pageSize: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
|
|
320
320
|
search: zod.ZodOptional<zod.ZodString>;
|
|
@@ -355,8 +355,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
355
355
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
356
356
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
357
357
|
}, zod_v4_core.$strip>;
|
|
358
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
359
|
-
get: _orpc_server.
|
|
358
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
359
|
+
get: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
360
360
|
id: zod.ZodString;
|
|
361
361
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
362
362
|
success: zod.ZodLiteral<true>;
|
|
@@ -386,8 +386,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
386
386
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
387
387
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
388
388
|
}, zod_v4_core.$strip>;
|
|
389
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
390
|
-
create: _orpc_server.
|
|
389
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
390
|
+
create: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
391
391
|
username: zod.ZodString;
|
|
392
392
|
email: zod.ZodOptional<zod.ZodString>;
|
|
393
393
|
phone: zod.ZodOptional<zod.ZodString>;
|
|
@@ -424,8 +424,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
424
424
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
425
425
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
426
426
|
}, zod_v4_core.$strip>;
|
|
427
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
428
|
-
update: _orpc_server.
|
|
427
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
428
|
+
update: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
429
429
|
id: zod.ZodString;
|
|
430
430
|
username: zod.ZodOptional<zod.ZodString>;
|
|
431
431
|
email: zod.ZodOptional<zod.ZodString>;
|
|
@@ -463,8 +463,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
463
463
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
464
464
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
465
465
|
}, zod_v4_core.$strip>;
|
|
466
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
467
|
-
delete: _orpc_server.
|
|
466
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
467
|
+
delete: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
468
468
|
id: zod.ZodString;
|
|
469
469
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
470
470
|
success: zod.ZodLiteral<true>;
|
|
@@ -481,8 +481,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
481
481
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
482
482
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
483
483
|
}, zod_v4_core.$strip>;
|
|
484
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
485
|
-
resetPassword: _orpc_server.
|
|
484
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
485
|
+
resetPassword: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
486
486
|
id: zod.ZodString;
|
|
487
487
|
newPassword: zod.ZodString;
|
|
488
488
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
@@ -500,10 +500,10 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
500
500
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
501
501
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
502
502
|
}, zod_v4_core.$strip>;
|
|
503
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
504
|
-
}
|
|
505
|
-
roles:
|
|
506
|
-
list: _orpc_server.
|
|
503
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
504
|
+
};
|
|
505
|
+
roles: {
|
|
506
|
+
list: _orpc_server.Procedure<ServContext & {}, any, _orpc_contract.Schema<unknown, unknown>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
507
507
|
success: zod.ZodLiteral<true>;
|
|
508
508
|
data: zod.ZodObject<{
|
|
509
509
|
items: zod.ZodArray<zod.ZodObject<{
|
|
@@ -531,8 +531,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
531
531
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
532
532
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
533
533
|
}, zod_v4_core.$strip>;
|
|
534
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
535
|
-
get: _orpc_server.
|
|
534
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
535
|
+
get: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
536
536
|
id: zod.ZodString;
|
|
537
537
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
538
538
|
success: zod.ZodLiteral<true>;
|
|
@@ -557,8 +557,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
557
557
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
558
558
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
559
559
|
}, zod_v4_core.$strip>;
|
|
560
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
561
|
-
create: _orpc_server.
|
|
560
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
561
|
+
create: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
562
562
|
code: zod.ZodString;
|
|
563
563
|
name: zod.ZodString;
|
|
564
564
|
description: zod.ZodOptional<zod.ZodString>;
|
|
@@ -586,8 +586,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
586
586
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
587
587
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
588
588
|
}, zod_v4_core.$strip>;
|
|
589
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
590
|
-
update: _orpc_server.
|
|
589
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
590
|
+
update: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
591
591
|
id: zod.ZodString;
|
|
592
592
|
name: zod.ZodOptional<zod.ZodString>;
|
|
593
593
|
description: zod.ZodOptional<zod.ZodString>;
|
|
@@ -614,8 +614,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
614
614
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
615
615
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
616
616
|
}, zod_v4_core.$strip>;
|
|
617
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
618
|
-
delete: _orpc_server.
|
|
617
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
618
|
+
delete: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
619
619
|
id: zod.ZodString;
|
|
620
620
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
621
621
|
success: zod.ZodLiteral<true>;
|
|
@@ -632,10 +632,10 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
632
632
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
633
633
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
634
634
|
}, zod_v4_core.$strip>;
|
|
635
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
636
|
-
}
|
|
637
|
-
permissions:
|
|
638
|
-
list: _orpc_server.
|
|
635
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
636
|
+
};
|
|
637
|
+
permissions: {
|
|
638
|
+
list: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
639
639
|
page: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
|
|
640
640
|
pageSize: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
|
|
641
641
|
search: zod.ZodOptional<zod.ZodString>;
|
|
@@ -678,8 +678,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
678
678
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
679
679
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
680
680
|
}, zod_v4_core.$strip>;
|
|
681
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
682
|
-
get: _orpc_server.
|
|
681
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
682
|
+
get: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
683
683
|
id: zod.ZodString;
|
|
684
684
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
685
685
|
success: zod.ZodLiteral<true>;
|
|
@@ -710,8 +710,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
710
710
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
711
711
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
712
712
|
}, zod_v4_core.$strip>;
|
|
713
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
714
|
-
create: _orpc_server.
|
|
713
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
714
|
+
create: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
715
715
|
code: zod.ZodString;
|
|
716
716
|
name: zod.ZodString;
|
|
717
717
|
description: zod.ZodOptional<zod.ZodString>;
|
|
@@ -751,8 +751,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
751
751
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
752
752
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
753
753
|
}, zod_v4_core.$strip>;
|
|
754
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
755
|
-
delete: _orpc_server.
|
|
754
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
755
|
+
delete: _orpc_server.Procedure<ServContext & {}, any, zod.ZodObject<{
|
|
756
756
|
id: zod.ZodString;
|
|
757
757
|
}, zod_v4_core.$strip>, zod.ZodDiscriminatedUnion<[zod.ZodObject<{
|
|
758
758
|
success: zod.ZodLiteral<true>;
|
|
@@ -769,8 +769,8 @@ declare function createIamProcedures(deps: IamProcedureDeps): {
|
|
|
769
769
|
suggestion: zod.ZodOptional<zod.ZodString>;
|
|
770
770
|
ext: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
|
|
771
771
|
}, zod_v4_core.$strip>;
|
|
772
|
-
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never
|
|
773
|
-
}
|
|
772
|
+
}, zod_v4_core.$strip>], "success">, Record<never, never>, Record<never, never>>;
|
|
773
|
+
};
|
|
774
774
|
};
|
|
775
775
|
|
|
776
776
|
export { type IamProcedureDeps, createIamProcedures };
|
package/dist/features/iam.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mapHaiResult } from '../chunk-27PCPE37.js';
|
|
2
|
-
import { implement, servM } from '../chunk-
|
|
2
|
+
import { implement, servM } from '../chunk-R354OMWL.js';
|
|
3
3
|
import { apiContract } from '@h-ai/api-contract';
|
|
4
4
|
import { core, err, HaiCommonError, ok } from '@h-ai/core';
|
|
5
5
|
|