@h-ai/api-contract 0.1.0-alpha.41 → 0.1.0-alpha.43
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 +6 -4
- package/dist/ai/index.d.ts +5 -244
- package/dist/ai/index.js +2 -2
- package/dist/{chunk-DKBPLQMI.js → chunk-3QSKWVLP.js} +11 -14
- package/dist/chunk-3QSKWVLP.js.map +1 -0
- package/dist/{chunk-3GZQUVY3.js → chunk-CUU2F6YD.js} +9 -3
- package/dist/chunk-CUU2F6YD.js.map +1 -0
- package/dist/{chunk-HJMSMLTZ.js → chunk-JIQINMLG.js} +11 -15
- package/dist/chunk-JIQINMLG.js.map +1 -0
- package/dist/{chunk-OUYWNVEX.js → chunk-MBNBQY2J.js} +31 -49
- package/dist/chunk-MBNBQY2J.js.map +1 -0
- package/dist/{chunk-EZVXYX3T.js → chunk-VSPYX4DD.js} +10 -16
- package/dist/chunk-VSPYX4DD.js.map +1 -0
- package/dist/iam/index.d.ts +7 -414
- package/dist/iam/index.js +2 -2
- package/dist/index.d.ts +28 -8
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/payment/index.d.ts +3 -122
- package/dist/payment/index.js +2 -2
- package/dist/storage/index.d.ts +4 -90
- package/dist/storage/index.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-3GZQUVY3.js.map +0 -1
- package/dist/chunk-DKBPLQMI.js.map +0 -1
- package/dist/chunk-EZVXYX3T.js.map +0 -1
- package/dist/chunk-HJMSMLTZ.js.map +0 -1
- package/dist/chunk-OUYWNVEX.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- `apiContract.iam`、`apiContract.storage`、`apiContract.ai`、`apiContract.payment`:领域级 contract。
|
|
8
8
|
- `apiContract.create()`:按应用场景组合启用的领域 contract。
|
|
9
9
|
- `apiContract.route()`:定义自定义 HTTP 路由元数据,供应用级 contract 复用。
|
|
10
|
+
- `apiContract.pathOf()`:从 contract procedure 读取唯一业务路径,供 middleware/client 复用。
|
|
10
11
|
- `apiContract.haiResultSchema()` / `apiContract.voidResultSchema` / `apiContract.paginatedSchema()`:公共 DTO Schema 工厂。
|
|
11
12
|
- 公共 DTO Schema:所有 HTTP 输出统一包装为 `HaiResult<T>`。
|
|
12
13
|
- IAM token DTO 兼容 httpOnly cookie 模式:响应体中 `refreshToken` 可能不存在,由服务端 `Set-Cookie` 管理。
|
|
@@ -30,12 +31,10 @@ export const contract = apiContract.create({
|
|
|
30
31
|
import { apiContract } from '@h-ai/api-contract'
|
|
31
32
|
import { z } from 'zod'
|
|
32
33
|
|
|
33
|
-
const PingOutput = apiContract.haiResultSchema(z.object({ pong: z.boolean() }))
|
|
34
|
-
|
|
35
34
|
export const appContract = {
|
|
36
35
|
ping: apiContract
|
|
37
36
|
.route({ method: 'POST', path: '/app/ping', operationId: 'app.ping', tags: ['app'] })
|
|
38
|
-
.output(
|
|
37
|
+
.output(apiContract.haiResultSchema(z.object({ pong: z.boolean() }))),
|
|
39
38
|
}
|
|
40
39
|
```
|
|
41
40
|
|
|
@@ -80,8 +79,11 @@ const app = serv.createApp({
|
|
|
80
79
|
|
|
81
80
|
- `apiContract.create(options)`:过滤 `false` / `undefined` 领域并组合应用级 contract。
|
|
82
81
|
- `apiContract.route(routeConfig)`:定义自定义 endpoint 的 method/path/operationId/tags 等路由元数据。
|
|
82
|
+
- `apiContract.pathOf(procedure)`:读取 procedure 在 `*-contract.ts` 中声明的业务路径,不维护独立 routes 常量。
|
|
83
83
|
- `apiContract.haiResultSchema(dataSchema)` / `apiContract.voidResultSchema` / `apiContract.paginatedSchema(itemSchema)`:公共 DTO Schema 工厂。
|
|
84
|
-
- `Iam*Schema` / `Storage*Schema` / `Ai*Schema` / `Payment*Schema
|
|
84
|
+
- `Iam*Schema` / `Storage*Schema` / `Ai*Schema` / `Payment*Schema`:真正跨接口、跨层复用的输入与数据结构。
|
|
85
|
+
|
|
86
|
+
业务 path 必须直接写在对应 `*-contract.ts`。只使用一次的输出 Schema 直接内联到 `.output(...)`;同一 contract 文件内重复使用时可保留私有常量,但不得从 schemas 导出。
|
|
85
87
|
|
|
86
88
|
## 配置
|
|
87
89
|
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as zod from 'zod';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import * as _orpc_contract from '@orpc/contract';
|
|
4
4
|
import * as zod_v4_core from 'zod/v4/core';
|
|
5
|
+
import { HaiResult } from '@h-ai/core';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Audio WebSocket 传输协议的运行时 Schema。
|
|
@@ -442,7 +443,7 @@ type AiContract = typeof aiContract;
|
|
|
442
443
|
*
|
|
443
444
|
* 包含聊天补全、消息占位、记忆召回与历史会话相关的 input/output Zod Schema。
|
|
444
445
|
* 聊天补全结构对齐 OpenAI Chat Completions API,支持 tool calling。
|
|
445
|
-
*
|
|
446
|
+
* 仅保留跨接口、跨层复用的数据结构;一次性输出包装在 contract 中内联。
|
|
446
447
|
* @module ai-schemas
|
|
447
448
|
*/
|
|
448
449
|
|
|
@@ -951,256 +952,16 @@ declare const AiChatHistoryDataSchema: z.ZodObject<{
|
|
|
951
952
|
duration: z.ZodNumber;
|
|
952
953
|
}, z.core.$strip>>;
|
|
953
954
|
}, z.core.$strip>;
|
|
954
|
-
declare const AiChatCompletionOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
955
|
-
success: z.ZodLiteral<true>;
|
|
956
|
-
data: z.ZodObject<{
|
|
957
|
-
id: z.ZodString;
|
|
958
|
-
object: z.ZodLiteral<"chat.completion">;
|
|
959
|
-
created: z.ZodNumber;
|
|
960
|
-
model: z.ZodString;
|
|
961
|
-
choices: z.ZodArray<z.ZodObject<{
|
|
962
|
-
index: z.ZodNumber;
|
|
963
|
-
message: z.ZodObject<{
|
|
964
|
-
role: z.ZodLiteral<"assistant">;
|
|
965
|
-
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
966
|
-
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
967
|
-
id: z.ZodString;
|
|
968
|
-
type: z.ZodLiteral<"function">;
|
|
969
|
-
function: z.ZodObject<{
|
|
970
|
-
name: z.ZodString;
|
|
971
|
-
arguments: z.ZodString;
|
|
972
|
-
}, z.core.$strip>;
|
|
973
|
-
}, z.core.$strip>>>;
|
|
974
|
-
}, z.core.$strip>;
|
|
975
|
-
finish_reason: z.ZodEnum<{
|
|
976
|
-
length: "length";
|
|
977
|
-
tool_calls: "tool_calls";
|
|
978
|
-
stop: "stop";
|
|
979
|
-
content_filter: "content_filter";
|
|
980
|
-
}>;
|
|
981
|
-
}, z.core.$strip>>;
|
|
982
|
-
usage: z.ZodObject<{
|
|
983
|
-
prompt_tokens: z.ZodNumber;
|
|
984
|
-
completion_tokens: z.ZodNumber;
|
|
985
|
-
total_tokens: z.ZodNumber;
|
|
986
|
-
}, z.core.$strip>;
|
|
987
|
-
}, z.core.$strip>;
|
|
988
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
989
|
-
success: z.ZodLiteral<false>;
|
|
990
|
-
error: z.ZodObject<{
|
|
991
|
-
code: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
992
|
-
message: z.ZodString;
|
|
993
|
-
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
994
|
-
system: z.ZodOptional<z.ZodString>;
|
|
995
|
-
module: z.ZodOptional<z.ZodString>;
|
|
996
|
-
cause: z.ZodOptional<z.ZodUnknown>;
|
|
997
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
998
|
-
ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
999
|
-
}, z.core.$strip>;
|
|
1000
|
-
}, z.core.$strip>], "success">;
|
|
1001
|
-
declare const AiSendMessageOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1002
|
-
success: z.ZodLiteral<true>;
|
|
1003
|
-
data: z.ZodObject<{
|
|
1004
|
-
content: z.ZodString;
|
|
1005
|
-
model: z.ZodString;
|
|
1006
|
-
usage: z.ZodOptional<z.ZodObject<{
|
|
1007
|
-
prompt_tokens: z.ZodNumber;
|
|
1008
|
-
completion_tokens: z.ZodNumber;
|
|
1009
|
-
total_tokens: z.ZodNumber;
|
|
1010
|
-
}, z.core.$strip>>;
|
|
1011
|
-
}, z.core.$strip>;
|
|
1012
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1013
|
-
success: z.ZodLiteral<false>;
|
|
1014
|
-
error: z.ZodObject<{
|
|
1015
|
-
code: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
1016
|
-
message: z.ZodString;
|
|
1017
|
-
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
1018
|
-
system: z.ZodOptional<z.ZodString>;
|
|
1019
|
-
module: z.ZodOptional<z.ZodString>;
|
|
1020
|
-
cause: z.ZodOptional<z.ZodUnknown>;
|
|
1021
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
1022
|
-
ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1023
|
-
}, z.core.$strip>;
|
|
1024
|
-
}, z.core.$strip>], "success">;
|
|
1025
|
-
declare const AiMemoryRecallOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1026
|
-
success: z.ZodLiteral<true>;
|
|
1027
|
-
data: z.ZodObject<{
|
|
1028
|
-
items: z.ZodArray<z.ZodObject<{
|
|
1029
|
-
id: z.ZodString;
|
|
1030
|
-
content: z.ZodString;
|
|
1031
|
-
type: z.ZodEnum<{
|
|
1032
|
-
instruction: "instruction";
|
|
1033
|
-
fact: "fact";
|
|
1034
|
-
preference: "preference";
|
|
1035
|
-
event: "event";
|
|
1036
|
-
entity: "entity";
|
|
1037
|
-
}>;
|
|
1038
|
-
importance: z.ZodNumber;
|
|
1039
|
-
objectId: z.ZodOptional<z.ZodString>;
|
|
1040
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1041
|
-
createdAt: z.ZodNumber;
|
|
1042
|
-
lastAccessedAt: z.ZodNumber;
|
|
1043
|
-
accessCount: z.ZodNumber;
|
|
1044
|
-
}, z.core.$strip>>;
|
|
1045
|
-
}, z.core.$strip>;
|
|
1046
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1047
|
-
success: z.ZodLiteral<false>;
|
|
1048
|
-
error: z.ZodObject<{
|
|
1049
|
-
code: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
1050
|
-
message: z.ZodString;
|
|
1051
|
-
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
1052
|
-
system: z.ZodOptional<z.ZodString>;
|
|
1053
|
-
module: z.ZodOptional<z.ZodString>;
|
|
1054
|
-
cause: z.ZodOptional<z.ZodUnknown>;
|
|
1055
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
1056
|
-
ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1057
|
-
}, z.core.$strip>;
|
|
1058
|
-
}, z.core.$strip>], "success">;
|
|
1059
|
-
declare const AiMemoryListOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1060
|
-
success: z.ZodLiteral<true>;
|
|
1061
|
-
data: z.ZodObject<{
|
|
1062
|
-
items: z.ZodArray<z.ZodObject<{
|
|
1063
|
-
id: z.ZodString;
|
|
1064
|
-
content: z.ZodString;
|
|
1065
|
-
type: z.ZodEnum<{
|
|
1066
|
-
instruction: "instruction";
|
|
1067
|
-
fact: "fact";
|
|
1068
|
-
preference: "preference";
|
|
1069
|
-
event: "event";
|
|
1070
|
-
entity: "entity";
|
|
1071
|
-
}>;
|
|
1072
|
-
importance: z.ZodNumber;
|
|
1073
|
-
objectId: z.ZodOptional<z.ZodString>;
|
|
1074
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1075
|
-
createdAt: z.ZodNumber;
|
|
1076
|
-
lastAccessedAt: z.ZodNumber;
|
|
1077
|
-
accessCount: z.ZodNumber;
|
|
1078
|
-
}, z.core.$strip>>;
|
|
1079
|
-
total: z.ZodNumber;
|
|
1080
|
-
}, z.core.$strip>;
|
|
1081
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1082
|
-
success: z.ZodLiteral<false>;
|
|
1083
|
-
error: z.ZodObject<{
|
|
1084
|
-
code: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
1085
|
-
message: z.ZodString;
|
|
1086
|
-
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
1087
|
-
system: z.ZodOptional<z.ZodString>;
|
|
1088
|
-
module: z.ZodOptional<z.ZodString>;
|
|
1089
|
-
cause: z.ZodOptional<z.ZodUnknown>;
|
|
1090
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
1091
|
-
ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1092
|
-
}, z.core.$strip>;
|
|
1093
|
-
}, z.core.$strip>], "success">;
|
|
1094
|
-
declare const AiSessionListOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1095
|
-
success: z.ZodLiteral<true>;
|
|
1096
|
-
data: z.ZodObject<{
|
|
1097
|
-
items: z.ZodArray<z.ZodObject<{
|
|
1098
|
-
objectId: z.ZodString;
|
|
1099
|
-
sessionId: z.ZodString;
|
|
1100
|
-
createdAt: z.ZodNumber;
|
|
1101
|
-
updatedAt: z.ZodNumber;
|
|
1102
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1103
|
-
}, z.core.$strip>>;
|
|
1104
|
-
}, z.core.$strip>;
|
|
1105
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1106
|
-
success: z.ZodLiteral<false>;
|
|
1107
|
-
error: z.ZodObject<{
|
|
1108
|
-
code: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
1109
|
-
message: z.ZodString;
|
|
1110
|
-
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
1111
|
-
system: z.ZodOptional<z.ZodString>;
|
|
1112
|
-
module: z.ZodOptional<z.ZodString>;
|
|
1113
|
-
cause: z.ZodOptional<z.ZodUnknown>;
|
|
1114
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
1115
|
-
ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1116
|
-
}, z.core.$strip>;
|
|
1117
|
-
}, z.core.$strip>], "success">;
|
|
1118
|
-
declare const AiChatHistoryOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1119
|
-
success: z.ZodLiteral<true>;
|
|
1120
|
-
data: z.ZodObject<{
|
|
1121
|
-
items: z.ZodArray<z.ZodObject<{
|
|
1122
|
-
id: z.ZodString;
|
|
1123
|
-
objectId: z.ZodString;
|
|
1124
|
-
sessionId: z.ZodString;
|
|
1125
|
-
request: z.ZodObject<{
|
|
1126
|
-
model: z.ZodString;
|
|
1127
|
-
messages: z.ZodArray<z.ZodObject<{
|
|
1128
|
-
role: z.ZodEnum<{
|
|
1129
|
-
system: "system";
|
|
1130
|
-
user: "user";
|
|
1131
|
-
assistant: "assistant";
|
|
1132
|
-
tool: "tool";
|
|
1133
|
-
}>;
|
|
1134
|
-
content: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1135
|
-
type: z.ZodLiteral<"text">;
|
|
1136
|
-
text: z.ZodString;
|
|
1137
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1138
|
-
type: z.ZodLiteral<"image_url">;
|
|
1139
|
-
image_url: z.ZodObject<{
|
|
1140
|
-
url: z.ZodString;
|
|
1141
|
-
detail: z.ZodOptional<z.ZodEnum<{
|
|
1142
|
-
auto: "auto";
|
|
1143
|
-
low: "low";
|
|
1144
|
-
high: "high";
|
|
1145
|
-
}>>;
|
|
1146
|
-
}, z.core.$strip>;
|
|
1147
|
-
}, z.core.$strip>]>>]>>;
|
|
1148
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1149
|
-
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1150
|
-
id: z.ZodString;
|
|
1151
|
-
type: z.ZodLiteral<"function">;
|
|
1152
|
-
function: z.ZodObject<{
|
|
1153
|
-
name: z.ZodString;
|
|
1154
|
-
arguments: z.ZodString;
|
|
1155
|
-
}, z.core.$strip>;
|
|
1156
|
-
}, z.core.$strip>>>;
|
|
1157
|
-
tool_call_id: z.ZodOptional<z.ZodString>;
|
|
1158
|
-
}, z.core.$strip>>;
|
|
1159
|
-
}, z.core.$strip>;
|
|
1160
|
-
response: z.ZodObject<{
|
|
1161
|
-
content: z.ZodString;
|
|
1162
|
-
toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1163
|
-
id: z.ZodString;
|
|
1164
|
-
type: z.ZodLiteral<"function">;
|
|
1165
|
-
function: z.ZodObject<{
|
|
1166
|
-
name: z.ZodString;
|
|
1167
|
-
arguments: z.ZodString;
|
|
1168
|
-
}, z.core.$strip>;
|
|
1169
|
-
}, z.core.$strip>>>;
|
|
1170
|
-
finishReason: z.ZodString;
|
|
1171
|
-
usage: z.ZodObject<{
|
|
1172
|
-
prompt_tokens: z.ZodNumber;
|
|
1173
|
-
completion_tokens: z.ZodNumber;
|
|
1174
|
-
total_tokens: z.ZodNumber;
|
|
1175
|
-
}, z.core.$strip>;
|
|
1176
|
-
}, z.core.$strip>;
|
|
1177
|
-
createdAt: z.ZodNumber;
|
|
1178
|
-
duration: z.ZodNumber;
|
|
1179
|
-
}, z.core.$strip>>;
|
|
1180
|
-
}, z.core.$strip>;
|
|
1181
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1182
|
-
success: z.ZodLiteral<false>;
|
|
1183
|
-
error: z.ZodObject<{
|
|
1184
|
-
code: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
1185
|
-
message: z.ZodString;
|
|
1186
|
-
httpStatus: z.ZodOptional<z.ZodNumber>;
|
|
1187
|
-
system: z.ZodOptional<z.ZodString>;
|
|
1188
|
-
module: z.ZodOptional<z.ZodString>;
|
|
1189
|
-
cause: z.ZodOptional<z.ZodUnknown>;
|
|
1190
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
1191
|
-
ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1192
|
-
}, z.core.$strip>;
|
|
1193
|
-
}, z.core.$strip>], "success">;
|
|
1194
955
|
type AiChatCompletionInput = z.infer<typeof AiChatCompletionInputSchema>;
|
|
1195
956
|
type AiChatCompletionData = z.infer<typeof AiChatCompletionDataSchema>;
|
|
1196
|
-
type AiChatCompletionOutput =
|
|
957
|
+
type AiChatCompletionOutput = HaiResult<AiChatCompletionData>;
|
|
1197
958
|
type AiSendMessageInput = z.infer<typeof AiSendMessageInputSchema>;
|
|
1198
959
|
type AiSendMessageData = z.infer<typeof AiSendMessageDataSchema>;
|
|
1199
|
-
type AiSendMessageOutput =
|
|
960
|
+
type AiSendMessageOutput = HaiResult<AiSendMessageData>;
|
|
1200
961
|
type AiMemoryRecallInput = z.infer<typeof AiMemoryRecallInputSchema>;
|
|
1201
962
|
type AiMemoryListInput = z.infer<typeof AiMemoryListInputSchema>;
|
|
1202
963
|
type AiSessionListInput = z.infer<typeof AiSessionListInputSchema>;
|
|
1203
964
|
type AiChatHistoryInput = z.infer<typeof AiChatHistoryInputSchema>;
|
|
1204
965
|
type AiChatRecord = z.infer<typeof AiChatRecordSchema>;
|
|
1205
966
|
|
|
1206
|
-
export { AUDIO_WS_PATH, AiAssistantMessageSchema, AiChatCompletionChoiceSchema, type AiChatCompletionData, AiChatCompletionDataSchema, type AiChatCompletionInput, AiChatCompletionInputSchema, type AiChatCompletionOutput,
|
|
967
|
+
export { AUDIO_WS_PATH, AiAssistantMessageSchema, AiChatCompletionChoiceSchema, type AiChatCompletionData, AiChatCompletionDataSchema, type AiChatCompletionInput, AiChatCompletionInputSchema, type AiChatCompletionOutput, AiChatHistoryDataSchema, type AiChatHistoryInput, AiChatHistoryInputSchema, AiChatMessageSchema, type AiChatRecord, AiChatRecordSchema, type AiContract, AiImageContentSchema, AiMemoryEntrySchema, AiMemoryListDataSchema, type AiMemoryListInput, AiMemoryListInputSchema, AiMemoryRecallDataSchema, type AiMemoryRecallInput, AiMemoryRecallInputSchema, AiMemoryTypeSchema, AiMessageContentSchema, AiMessageRoleSchema, type AiSendMessageData, AiSendMessageDataSchema, type AiSendMessageInput, AiSendMessageInputSchema, type AiSendMessageOutput, AiSessionInfoSchema, AiSessionListDataSchema, type AiSessionListInput, AiSessionListInputSchema, AiTextContentSchema, AiTokenUsageSchema, AiToolCallSchema, AiToolDefinitionSchema, AiToolParameterSchema, AudioFormatSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, aiContract };
|
package/dist/ai/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AUDIO_WS_PATH, AiAssistantMessageSchema, AiChatCompletionChoiceSchema, AiChatCompletionDataSchema, AiChatCompletionInputSchema,
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { AUDIO_WS_PATH, AiAssistantMessageSchema, AiChatCompletionChoiceSchema, AiChatCompletionDataSchema, AiChatCompletionInputSchema, AiChatHistoryDataSchema, AiChatHistoryInputSchema, AiChatMessageSchema, AiChatRecordSchema, AiImageContentSchema, AiMemoryEntrySchema, AiMemoryListDataSchema, AiMemoryListInputSchema, AiMemoryRecallDataSchema, AiMemoryRecallInputSchema, AiMemoryTypeSchema, AiMessageContentSchema, AiMessageRoleSchema, AiSendMessageDataSchema, AiSendMessageInputSchema, AiSessionInfoSchema, AiSessionListDataSchema, AiSessionListInputSchema, AiTextContentSchema, AiTokenUsageSchema, AiToolCallSchema, AiToolDefinitionSchema, AiToolParameterSchema, AudioFormatSchema, AudioWsClientMessageSchema, AudioWsDoneMessageSchema, AudioWsStartMessageSchema, AudioWsTextMessageSchema, aiContract } from '../chunk-VSPYX4DD.js';
|
|
2
|
+
import '../chunk-CUU2F6YD.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { haiResultSchema, route } from './chunk-
|
|
1
|
+
import { haiResultSchema, route, HaiVoidResultSchema } from './chunk-CUU2F6YD.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
var StorageFileMetadataSchema = z.object({
|
|
@@ -42,25 +42,22 @@ var StorageFileKeyInputSchema = z.object({
|
|
|
42
42
|
var StorageDeleteFilesInputSchema = z.object({
|
|
43
43
|
keys: z.array(z.string().min(1)).min(1)
|
|
44
44
|
});
|
|
45
|
-
var StoragePresignedUrlOutputSchema = haiResultSchema(StoragePresignedUrlSchema);
|
|
46
|
-
var StorageFileMetadataOutputSchema = haiResultSchema(StorageFileMetadataSchema);
|
|
47
|
-
var StorageListFilesOutputSchema = haiResultSchema(StorageListFilesDataSchema);
|
|
48
|
-
var StorageVoidOutputSchema = haiResultSchema(z.void());
|
|
49
45
|
|
|
50
46
|
// src/storage/storage-contract.ts
|
|
47
|
+
var presignedUrlOutputSchema = haiResultSchema(StoragePresignedUrlSchema);
|
|
51
48
|
var storageContract = {
|
|
52
49
|
presignedUrls: {
|
|
53
|
-
createDownload: route({ method: "POST", path: "/storage/presigned-urls/download", operationId: "storage.presignedUrls.createDownload", summary: "Create presigned download URL", tags: ["storage"] }).input(StoragePresignDownloadInputSchema).output(
|
|
54
|
-
createUpload: route({ method: "POST", path: "/storage/presigned-urls/upload", operationId: "storage.presignedUrls.createUpload", summary: "Create presigned upload URL", tags: ["storage"] }).input(StoragePresignUploadInputSchema).output(
|
|
50
|
+
createDownload: route({ method: "POST", path: "/storage/presigned-urls/download", operationId: "storage.presignedUrls.createDownload", summary: "Create presigned download URL", tags: ["storage"] }).input(StoragePresignDownloadInputSchema).output(presignedUrlOutputSchema),
|
|
51
|
+
createUpload: route({ method: "POST", path: "/storage/presigned-urls/upload", operationId: "storage.presignedUrls.createUpload", summary: "Create presigned upload URL", tags: ["storage"] }).input(StoragePresignUploadInputSchema).output(presignedUrlOutputSchema)
|
|
55
52
|
},
|
|
56
53
|
files: {
|
|
57
|
-
list: route({ method: "GET", path: "/storage/files", operationId: "storage.files.list", summary: "List files", tags: ["storage"] }).input(StorageListFilesInputSchema).output(
|
|
58
|
-
getMetadata: route({ method: "POST", path: "/storage/files/metadata", operationId: "storage.files.getMetadata", summary: "Get file metadata", tags: ["storage"] }).input(StorageFileKeyInputSchema).output(
|
|
59
|
-
delete: route({ method: "DELETE", path: "/storage/files", operationId: "storage.files.delete", summary: "Delete file", tags: ["storage"] }).input(StorageFileKeyInputSchema).output(
|
|
60
|
-
deleteMany: route({ method: "POST", path: "/storage/files/delete-many", operationId: "storage.files.deleteMany", summary: "Delete files", tags: ["storage"] }).input(StorageDeleteFilesInputSchema).output(
|
|
54
|
+
list: route({ method: "GET", path: "/storage/files", operationId: "storage.files.list", summary: "List files", tags: ["storage"] }).input(StorageListFilesInputSchema).output(haiResultSchema(StorageListFilesDataSchema)),
|
|
55
|
+
getMetadata: route({ method: "POST", path: "/storage/files/metadata", operationId: "storage.files.getMetadata", summary: "Get file metadata", tags: ["storage"] }).input(StorageFileKeyInputSchema).output(haiResultSchema(StorageFileMetadataSchema)),
|
|
56
|
+
delete: route({ method: "DELETE", path: "/storage/files", operationId: "storage.files.delete", summary: "Delete file", tags: ["storage"] }).input(StorageFileKeyInputSchema).output(HaiVoidResultSchema),
|
|
57
|
+
deleteMany: route({ method: "POST", path: "/storage/files/delete-many", operationId: "storage.files.deleteMany", summary: "Delete files", tags: ["storage"] }).input(StorageDeleteFilesInputSchema).output(HaiVoidResultSchema)
|
|
61
58
|
}
|
|
62
59
|
};
|
|
63
60
|
|
|
64
|
-
export { StorageDeleteFilesInputSchema, StorageFileKeyInputSchema,
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
export { StorageDeleteFilesInputSchema, StorageFileKeyInputSchema, StorageFileMetadataSchema, StorageListFilesDataSchema, StorageListFilesInputSchema, StoragePresignDownloadInputSchema, StoragePresignUploadInputSchema, StoragePresignedUrlSchema, storageContract };
|
|
62
|
+
//# sourceMappingURL=chunk-3QSKWVLP.js.map
|
|
63
|
+
//# sourceMappingURL=chunk-3QSKWVLP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/storage/storage-schemas.ts","../src/storage/storage-contract.ts"],"names":[],"mappings":";;;AAYO,IAAM,yBAAA,GAA4B,EAAE,MAAA,CAAO;AAAA,EAChD,GAAA,EAAK,EAAE,MAAA,EAAO;AAAA,EACd,IAAA,EAAM,EAAE,MAAA,EAAO;AAAA,EACf,WAAA,EAAa,EAAE,MAAA,EAAO;AAAA,EACtB,YAAA,EAAc,CAAA,CAAE,MAAA,CAAO,IAAA,EAAK;AAAA,EAC5B,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAC1B,QAAA,EAAU,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,MAAA,IAAU,CAAA,CAAE,MAAA,EAAQ,CAAA,CAAE,QAAA;AAC7C,CAAC;AAGM,IAAM,iCAAA,GAAoC,EAAE,MAAA,CAAO;AAAA,EACxD,GAAA,EAAK,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACrB,SAAA,EAAW,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA;AACrC,CAAC;AAGM,IAAM,+BAAA,GAAkC,EAAE,MAAA,CAAO;AAAA,EACtD,GAAA,EAAK,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACrB,WAAA,EAAa,CAA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AA,EAAG,CAAA,CAC9J,KAAA,CAAM,yBAAyB,CAAA,CAC/B,MAAA,CAAO,eAAA,CAAgB,yBAAyB,CAAC,CAAA;AAAA,IACpD,MAAA,EAAQ,MAAM,EAAE,MAAA,EAAQ,UAAU,IAAA,EAAM,gBAAA,EAAkB,aAAa,sBAAA,EAAwB,OAAA,EAAS,eAAe,IAAA,EAAM,CAAC,SAAS,CAAA,EAAG,EACvI,KAAA,CAAM,yBAAyB,CAAA,CAC/B,MAAA,CAAO,mBAAmB,CAAA;AAAA,IAC7B,UAAA,EAAY,MAAM,EAAE,MAAA,EAAQ,QAAQ,IAAA,EAAM,4BAAA,EAA8B,aAAa,0BAAA,EAA4B,OAAA,EAAS,gBAAgB,IAAA,EAAM,CAAC,SAAS,CAAA,EAAG,EAC1J,KAAA,CAAM,6BAA6B,CAAA,CACnC,MAAA,CAAO,mBAAmB;AAAA;AAEjC","file":"chunk-3QSKWVLP.js","sourcesContent":["/**\n * @h-ai/api-contract — Storage 领域 Schema\n *\n * 包含文件元数据、预签名 URL、文件列表与删除相关的 input/output Zod Schema。\n * 仅保留跨接口、跨层复用的数据结构;一次性输出包装在 contract 中内联。\n * @module storage-schemas\n */\n\nimport type { HaiResult } from '@h-ai/core'\nimport { z } from 'zod'\n\n/** 文件元数据 Schema。 */\nexport const StorageFileMetadataSchema = z.object({\n key: z.string(),\n size: z.number(),\n contentType: z.string(),\n lastModified: z.coerce.date(),\n etag: z.string().optional(),\n metadata: z.record(z.string(), z.string()).optional(),\n})\n\n/** 获取下载签名 URL 入参 Schema。 */\nexport const StoragePresignDownloadInputSchema = z.object({\n key: z.string().min(1),\n expiresIn: z.number().int().min(1).optional(),\n})\n\n/** 获取上传签名 URL 入参 Schema。 */\nexport const StoragePresignUploadInputSchema = z.object({\n key: z.string().min(1),\n contentType: z.string().optional(),\n contentLength: z.number().int().min(1).optional(),\n expiresIn: z.number().int().min(1).optional(),\n})\n\n/** 签名 URL 业务数据 Schema。 */\nexport const StoragePresignedUrlSchema = z.object({\n url: z.string(),\n key: z.string(),\n expiresAt: z.coerce.date().optional(),\n})\n\n/** 文件列表查询入参 Schema。 */\nexport const StorageListFilesInputSchema = z.object({\n prefix: z.string().optional(),\n maxKeys: z.coerce.number().int().min(1).max(1000).optional(),\n continuationToken: z.string().optional(),\n delimiter: z.string().optional(),\n})\n\n/** 文件列表业务数据 Schema。 */\nexport const StorageListFilesDataSchema = z.object({\n files: z.array(StorageFileMetadataSchema),\n commonPrefixes: z.array(z.string()),\n nextContinuationToken: z.string().optional(),\n isTruncated: z.boolean(),\n})\n\n/** 单文件操作入参 Schema。 */\nexport const StorageFileKeyInputSchema = z.object({\n key: z.string().min(1),\n})\n\n/** 批量删除文件入参 Schema。 */\nexport const StorageDeleteFilesInputSchema = z.object({\n keys: z.array(z.string().min(1)).min(1),\n})\n\nexport type StoragePresignDownloadInput = z.infer<typeof StoragePresignDownloadInputSchema>\nexport type StoragePresignUploadInput = z.infer<typeof StoragePresignUploadInputSchema>\nexport type StoragePresignedUrlOutput = HaiResult<z.infer<typeof StoragePresignedUrlSchema>>\nexport type StorageListFilesInput = z.infer<typeof StorageListFilesInputSchema>\nexport type StorageFileKeyInput = z.infer<typeof StorageFileKeyInputSchema>\nexport type StorageDeleteFilesInput = z.infer<typeof StorageDeleteFilesInputSchema>\n","/**\n * @h-ai/api-contract — Storage 领域 contract\n *\n * 定义文件存储相关 API 的接口边界:预签名 URL 生成与文件管理。\n * 所有接口均需 Bearer Token 认证(由 `@h-ai/serv` 的 feature 层强制)。\n * @module storage-contract\n */\n\nimport { haiResultSchema, HaiVoidResultSchema } from '../common/result-schemas.js'\nimport { route } from '../common/route.js'\nimport {\n StorageDeleteFilesInputSchema,\n StorageFileKeyInputSchema,\n StorageFileMetadataSchema,\n StorageListFilesDataSchema,\n StorageListFilesInputSchema,\n StoragePresignDownloadInputSchema,\n StoragePresignedUrlSchema,\n StoragePresignUploadInputSchema,\n} from './storage-schemas.js'\n\n// 下载与上传接口共享同一响应结构,仅在本 contract 内复用。\nconst presignedUrlOutputSchema = haiResultSchema(StoragePresignedUrlSchema)\n\n/** Storage 领域 oRPC contract。 */\nexport const storageContract = {\n presignedUrls: {\n createDownload: route({ method: 'POST', path: '/storage/presigned-urls/download', operationId: 'storage.presignedUrls.createDownload', summary: 'Create presigned download URL', tags: ['storage'] })\n .input(StoragePresignDownloadInputSchema)\n .output(presignedUrlOutputSchema),\n createUpload: route({ method: 'POST', path: '/storage/presigned-urls/upload', operationId: 'storage.presignedUrls.createUpload', summary: 'Create presigned upload URL', tags: ['storage'] })\n .input(StoragePresignUploadInputSchema)\n .output(presignedUrlOutputSchema),\n },\n files: {\n list: route({ method: 'GET', path: '/storage/files', operationId: 'storage.files.list', summary: 'List files', tags: ['storage'] })\n .input(StorageListFilesInputSchema)\n .output(haiResultSchema(StorageListFilesDataSchema)),\n getMetadata: route({ method: 'POST', path: '/storage/files/metadata', operationId: 'storage.files.getMetadata', summary: 'Get file metadata', tags: ['storage'] })\n .input(StorageFileKeyInputSchema)\n .output(haiResultSchema(StorageFileMetadataSchema)),\n delete: route({ method: 'DELETE', path: '/storage/files', operationId: 'storage.files.delete', summary: 'Delete file', tags: ['storage'] })\n .input(StorageFileKeyInputSchema)\n .output(HaiVoidResultSchema),\n deleteMany: route({ method: 'POST', path: '/storage/files/delete-many', operationId: 'storage.files.deleteMany', summary: 'Delete files', tags: ['storage'] })\n .input(StorageDeleteFilesInputSchema)\n .output(HaiVoidResultSchema),\n },\n}\n\nexport type StorageContract = typeof storageContract\n"]}
|
|
@@ -26,7 +26,13 @@ function haiResultSchema(dataSchema) {
|
|
|
26
26
|
}
|
|
27
27
|
var HaiVoidResultSchema = haiResultSchema(z.void());
|
|
28
28
|
var route = (...args) => oc.route(...args);
|
|
29
|
+
function pathOf(procedure) {
|
|
30
|
+
const path = procedure["~orpc"].route.path;
|
|
31
|
+
if (!path)
|
|
32
|
+
throw new Error("Contract procedure must define an HTTP path");
|
|
33
|
+
return path;
|
|
34
|
+
}
|
|
29
35
|
|
|
30
|
-
export { HaiErrorSchema, HaiVoidResultSchema, haiResultSchema, route };
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
36
|
+
export { HaiErrorSchema, HaiVoidResultSchema, haiResultSchema, pathOf, route };
|
|
37
|
+
//# sourceMappingURL=chunk-CUU2F6YD.js.map
|
|
38
|
+
//# sourceMappingURL=chunk-CUU2F6YD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/result-schemas.ts","../src/common/route.ts"],"names":[],"mappings":";;;;AAeO,IAAM,cAAA,GAAiB,EAAE,MAAA,CAAO;AAAA,EACrC,IAAA,EAAM,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CAAE,QAAO,EAAG,CAAA,CAAE,MAAA,EAAQ,CAAC,CAAA;AAAA,EACtC,OAAA,EAAS,EAAE,MAAA,EAAO;AAAA,EAClB,UAAA,EAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAChC,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAC5B,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAC5B,KAAA,EAAO,CAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA,EAC5B,UAAA,EAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAChC,GAAA,EAAK,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,MAAA,IAAU,CAAA,CAAE,OAAA,EAAS,CAAA,CAAE,QAAA;AACzC,CAAC;AAaM,SAAS,gBAAqC,UAAA,EAAe;AAClE,EAAA,OAAO,CAAA,CAAE,mBAAmB,SAAA,EAAW;AAAA,IACrC,EAAE,MAAA,CAAO;AAAA,MACP,OAAA,EAAS,CAAA,CAAE,OAAA,CAAQ,IAAI,CAAA;AAAA,MACvB,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,IACD,EAAE,MAAA,CAAO;AAAA,MACP,OAAA,EAAS,CAAA,CAAE,OAAA,CAAQ,KAAK,CAAA;AAAA,MACxB,KAAA,EAAO;AAAA,KACR;AAAA,GACF,CAAA;AACH;AAGO,IAAM,mBAAA,GAAsB,eAAA,CAAgB,CAAA,CAAE,IAAA,EAAM;ACxCpD,IAAM,QAAyB,CAAA,GAAI,IAAA,KAAS,EAAA,CAAG,KAAA,CAAM,GAAG,IAAI;AAW5D,SAAS,OAAO,SAAA,EAA+C;AACpE,EAAA,MAAM,IAAA,GAAO,SAAA,CAAU,OAAO,CAAA,CAAE,KAAA,CAAM,IAAA;AACtC,EAAA,IAAI,CAAC,IAAA;AACH,IAAA,MAAM,IAAI,MAAM,6CAA6C,CAAA;AAC/D,EAAA,OAAO,IAAA;AACT","file":"chunk-CUU2F6YD.js","sourcesContent":["/**\n * @h-ai/api-contract — HaiResult Schema\n *\n * 提供与 `@h-ai/core` HaiResult<T> 结构一致的 Zod Schema 工厂,\n * 用于 oRPC contract 的 output 定义和客户端响应校验。\n * @module result-schemas\n */\n\nimport { z } from 'zod'\n\n/**\n * HaiError 的跨端 JSON Schema。\n *\n * 仅描述公共错误字段,不暴露内部异常对象结构。\n */\nexport const HaiErrorSchema = z.object({\n code: z.union([z.string(), z.number()]),\n message: z.string(),\n httpStatus: z.number().optional(),\n system: z.string().optional(),\n module: z.string().optional(),\n cause: z.unknown().optional(),\n suggestion: z.string().optional(),\n ext: z.record(z.string(), z.unknown()).optional(),\n})\n\n/**\n * 创建与 @h-ai/core HaiResult<T> 一致的响应 Schema。\n *\n * @param dataSchema - 成功分支 data 字段 Schema\n * @returns HaiResult<T> 的 Zod Schema\n *\n * @example\n * ```ts\n * const OutputSchema = haiResultSchema(z.object({ id: z.string() }))\n * ```\n */\nexport function haiResultSchema<T extends z.ZodType>(dataSchema: T) {\n return z.discriminatedUnion('success', [\n z.object({\n success: z.literal(true),\n data: dataSchema,\n }),\n z.object({\n success: z.literal(false),\n error: HaiErrorSchema,\n }),\n ])\n}\n\n/** 无内容成功响应 Schema。 */\nexport const HaiVoidResultSchema = haiResultSchema(z.void())\n","/**\n * @h-ai/api-contract — route builder\n *\n * 统一封装 oRPC 的 route builder。应用与契约包通过 `apiContract.route(...)`\n * 定义 HTTP 路由元数据,不需要直接依赖 `@orpc/contract` 或 `@h-ai/serv`。\n */\n\nimport type { AnyContractProcedure } from '@orpc/contract'\nimport { oc } from '@orpc/contract'\n\n/** 创建 oRPC contract 路由节点。 */\nexport const route: typeof oc.route = (...args) => oc.route(...args)\n\n/**\n * 读取 contract procedure 中声明的业务路径。\n *\n * 路径只在对应 `*-contract.ts` 的 route 定义中维护;transport、client 与\n * middleware 通过本函数读取,避免再维护一份路由常量。\n *\n * @param procedure - 已声明 HTTP route 的 oRPC contract procedure\n * @returns contract 中的绝对业务路径\n */\nexport function pathOf(procedure: AnyContractProcedure): `/${string}` {\n const path = procedure['~orpc'].route.path\n if (!path)\n throw new Error('Contract procedure must define an HTTP path')\n return path\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { haiResultSchema, route } from './chunk-
|
|
1
|
+
import { haiResultSchema, route } from './chunk-CUU2F6YD.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
var PaymentProviderSchema = z.enum(["wechat", "alipay", "stripe"]);
|
|
@@ -47,25 +47,21 @@ var PaymentNotifyMessageSchema = z.object({
|
|
|
47
47
|
var PaymentStripeNotifyDataSchema = z.object({
|
|
48
48
|
received: z.boolean()
|
|
49
49
|
});
|
|
50
|
-
var PaymentCreateOrderOutputSchema = haiResultSchema(PaymentCreateOrderDataSchema);
|
|
51
|
-
var PaymentQueryOrderOutputSchema = haiResultSchema(PaymentOrderSchema);
|
|
52
|
-
var PaymentRefundOutputSchema = haiResultSchema(PaymentRefundDataSchema);
|
|
53
|
-
var PaymentNotifyMessageOutputSchema = haiResultSchema(PaymentNotifyMessageSchema);
|
|
54
|
-
var PaymentStripeNotifyOutputSchema = haiResultSchema(PaymentStripeNotifyDataSchema);
|
|
55
50
|
var WebhookBodySchema = z.unknown();
|
|
51
|
+
var notifyMessageOutputSchema = haiResultSchema(PaymentNotifyMessageSchema);
|
|
56
52
|
var paymentContract = {
|
|
57
53
|
orders: {
|
|
58
|
-
create: route({ method: "POST", path: "/payment/orders", operationId: "payment.orders.create", summary: "Create payment order", tags: ["payment", "orders"] }).input(PaymentCreateOrderInputSchema).output(
|
|
59
|
-
get: route({ method: "GET", path: "/payment/orders/{orderNo}", operationId: "payment.orders.get", summary: "Get payment order", tags: ["payment", "orders"] }).input(PaymentQueryOrderInputSchema).output(
|
|
60
|
-
refund: route({ method: "POST", path: "/payment/orders/{orderNo}/refunds", operationId: "payment.orders.refund", summary: "Refund payment order", tags: ["payment", "orders"] }).input(PaymentRefundInputSchema).output(
|
|
54
|
+
create: route({ method: "POST", path: "/payment/orders", operationId: "payment.orders.create", summary: "Create payment order", tags: ["payment", "orders"] }).input(PaymentCreateOrderInputSchema).output(haiResultSchema(PaymentCreateOrderDataSchema)),
|
|
55
|
+
get: route({ method: "GET", path: "/payment/orders/{orderNo}", operationId: "payment.orders.get", summary: "Get payment order", tags: ["payment", "orders"] }).input(PaymentQueryOrderInputSchema).output(haiResultSchema(PaymentOrderSchema)),
|
|
56
|
+
refund: route({ method: "POST", path: "/payment/orders/{orderNo}/refunds", operationId: "payment.orders.refund", summary: "Refund payment order", tags: ["payment", "orders"] }).input(PaymentRefundInputSchema).output(haiResultSchema(PaymentRefundDataSchema))
|
|
61
57
|
},
|
|
62
58
|
notifications: {
|
|
63
|
-
wechat: route({ method: "POST", path: "/payment/notifications/wechat", operationId: "payment.notifications.wechat", summary: "Handle WeChat payment notification", tags: ["payment", "notifications"] }).input(WebhookBodySchema).output(
|
|
64
|
-
alipay: route({ method: "POST", path: "/payment/notifications/alipay", operationId: "payment.notifications.alipay", summary: "Handle Alipay payment notification", tags: ["payment", "notifications"] }).input(WebhookBodySchema).output(
|
|
65
|
-
stripe: route({ method: "POST", path: "/payment/notifications/stripe", operationId: "payment.notifications.stripe", summary: "Handle Stripe payment notification", tags: ["payment", "notifications"] }).input(WebhookBodySchema).output(
|
|
59
|
+
wechat: route({ method: "POST", path: "/payment/notifications/wechat", operationId: "payment.notifications.wechat", summary: "Handle WeChat payment notification", tags: ["payment", "notifications"] }).input(WebhookBodySchema).output(notifyMessageOutputSchema),
|
|
60
|
+
alipay: route({ method: "POST", path: "/payment/notifications/alipay", operationId: "payment.notifications.alipay", summary: "Handle Alipay payment notification", tags: ["payment", "notifications"] }).input(WebhookBodySchema).output(notifyMessageOutputSchema),
|
|
61
|
+
stripe: route({ method: "POST", path: "/payment/notifications/stripe", operationId: "payment.notifications.stripe", summary: "Handle Stripe payment notification", tags: ["payment", "notifications"] }).input(WebhookBodySchema).output(haiResultSchema(PaymentStripeNotifyDataSchema))
|
|
66
62
|
}
|
|
67
63
|
};
|
|
68
64
|
|
|
69
|
-
export { PaymentCreateOrderDataSchema, PaymentCreateOrderInputSchema,
|
|
70
|
-
//# sourceMappingURL=chunk-
|
|
71
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
export { PaymentCreateOrderDataSchema, PaymentCreateOrderInputSchema, PaymentNotifyMessageSchema, PaymentOrderSchema, PaymentProviderSchema, PaymentQueryOrderInputSchema, PaymentRefundDataSchema, PaymentRefundInputSchema, PaymentStripeNotifyDataSchema, PaymentTradeTypeSchema, paymentContract };
|
|
66
|
+
//# sourceMappingURL=chunk-JIQINMLG.js.map
|
|
67
|
+
//# sourceMappingURL=chunk-JIQINMLG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/payment/payment-schemas.ts","../src/payment/payment-contract.ts"],"names":["z"],"mappings":";;;AAIO,IAAM,wBAAwB,CAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,QAAA,EAAU,QAAQ,CAAC;AAGnE,IAAM,sBAAA,GAAyB,E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,WAAA,EAAa,8BAAA,EAAgC,OAAA,EAAS,oCAAA,EAAsC,IAAA,EAAM,CAAC,SAAA,EAAW,eAAe,CAAA,EAAG,CAAA,CACpM,KAAA,CAAM,iBAAiB,CAAA,CACvB,MAAA,CAAO,eAAA,CAAgB,6BAA6B,CAAC;AAAA;AAE5D","file":"chunk-JIQINMLG.js","sourcesContent":["import type { HaiResult } from '@h-ai/core'\nimport { z } from 'zod'\n\n/** 支付渠道 Schema。 */\nexport const PaymentProviderSchema = z.enum(['wechat', 'alipay', 'stripe'])\n\n/** 支付交易类型 Schema。 */\nexport const PaymentTradeTypeSchema = z.enum(['jsapi', 'h5', 'app', 'native', 'mini_program'])\n\n/** 创建支付订单入参 Schema。 */\nexport const PaymentCreateOrderInputSchema = z.object({\n provider: PaymentProviderSchema,\n amount: z.number().int().min(1),\n description: z.string().min(1),\n tradeType: PaymentTradeTypeSchema,\n userId: z.string().optional(),\n metadata: z.record(z.string(), z.string()).optional(),\n})\n\n/** 创建支付订单业务数据 Schema。 */\nexport const PaymentCreateOrderDataSchema = z.object({\n provider: PaymentProviderSchema,\n tradeType: PaymentTradeTypeSchema,\n clientParams: z.record(z.string(), z.unknown()),\n prepayId: z.string().optional(),\n})\n\n/** 查询支付订单入参 Schema。 */\nexport const PaymentQueryOrderInputSchema = z.object({\n orderNo: z.string().min(1),\n})\n\n/** 支付订单业务数据 Schema。 */\nexport const PaymentOrderSchema = z.object({\n orderNo: z.string(),\n transactionId: z.string().optional(),\n status: z.enum(['pending', 'paid', 'closed', 'refunded', 'failed']),\n amount: z.number(),\n // ISO 8601 时间戳(例如 `2024-01-02T03:04:05.000Z`),由服务端以 `Date#toISOString()` 序列化。\n paidAt: z.iso.datetime().optional(),\n})\n\n/** 退款入参 Schema。 */\nexport const PaymentRefundInputSchema = z.object({\n provider: PaymentProviderSchema,\n orderNo: z.string(),\n refundNo: z.string(),\n amount: z.number().int().min(1),\n reason: z.string().optional(),\n})\n\n/** 退款业务数据 Schema。 */\nexport const PaymentRefundDataSchema = z.object({\n refundNo: z.string(),\n refundId: z.string(),\n status: z.enum(['processing', 'success', 'failed']),\n})\n\n/** 微信/支付宝通知响应 Schema。 */\nexport const PaymentNotifyMessageSchema = z.object({\n code: z.string(),\n message: z.string(),\n})\n\n/** Stripe 通知响应 Schema。 */\nexport const PaymentStripeNotifyDataSchema = z.object({\n received: z.boolean(),\n})\n\nexport type PaymentCreateOrderInput = z.infer<typeof PaymentCreateOrderInputSchema>\nexport type PaymentCreateOrderOutput = HaiResult<z.infer<typeof PaymentCreateOrderDataSchema>>\nexport type PaymentRefundInput = z.infer<typeof PaymentRefundInputSchema>\n","import { z } from 'zod'\nimport { haiResultSchema } from '../common/result-schemas.js'\nimport { route } from '../common/route.js'\nimport {\n PaymentCreateOrderDataSchema,\n PaymentCreateOrderInputSchema,\n PaymentNotifyMessageSchema,\n PaymentOrderSchema,\n PaymentQueryOrderInputSchema,\n PaymentRefundDataSchema,\n PaymentRefundInputSchema,\n PaymentStripeNotifyDataSchema,\n} from './payment-schemas.js'\n\n// Webhook 通知体由各支付渠道决定(且通常需要原始 raw body 校验签名),\n// 因此 contract 层只声明为 unknown,由 procedure 实现负责按渠道解析。\nconst WebhookBodySchema = z.unknown()\n// 微信与支付宝通知共享同一响应结构,仅在本 contract 内复用。\nconst notifyMessageOutputSchema = haiResultSchema(PaymentNotifyMessageSchema)\n\n/** Payment 领域 oRPC contract。 */\nexport const paymentContract = {\n orders: {\n create: route({ method: 'POST', path: '/payment/orders', operationId: 'payment.orders.create', summary: 'Create payment order', tags: ['payment', 'orders'] })\n .input(PaymentCreateOrderInputSchema)\n .output(haiResultSchema(PaymentCreateOrderDataSchema)),\n get: route({ method: 'GET', path: '/payment/orders/{orderNo}', operationId: 'payment.orders.get', summary: 'Get payment order', tags: ['payment', 'orders'] })\n .input(PaymentQueryOrderInputSchema)\n .output(haiResultSchema(PaymentOrderSchema)),\n refund: route({ method: 'POST', path: '/payment/orders/{orderNo}/refunds', operationId: 'payment.orders.refund', summary: 'Refund payment order', tags: ['payment', 'orders'] })\n .input(PaymentRefundInputSchema)\n .output(haiResultSchema(PaymentRefundDataSchema)),\n },\n notifications: {\n wechat: route({ method: 'POST', path: '/payment/notifications/wechat', operationId: 'payment.notifications.wechat', summary: 'Handle WeChat payment notification', tags: ['payment', 'notifications'] })\n .input(WebhookBodySchema)\n .output(notifyMessageOutputSchema),\n alipay: route({ method: 'POST', path: '/payment/notifications/alipay', operationId: 'payment.notifications.alipay', summary: 'Handle Alipay payment notification', tags: ['payment', 'notifications'] })\n .input(WebhookBodySchema)\n .output(notifyMessageOutputSchema),\n stripe: route({ method: 'POST', path: '/payment/notifications/stripe', operationId: 'payment.notifications.stripe', summary: 'Handle Stripe payment notification', tags: ['payment', 'notifications'] })\n .input(WebhookBodySchema)\n .output(haiResultSchema(PaymentStripeNotifyDataSchema)),\n },\n}\n\nexport type PaymentContract = typeof paymentContract\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { haiResultSchema, route } from './chunk-
|
|
1
|
+
import { haiResultSchema, route, HaiVoidResultSchema } from './chunk-CUU2F6YD.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
var PaginationQuerySchema = z.object({
|
|
@@ -171,64 +171,46 @@ var IamCreatePermissionInputSchema = z.object({
|
|
|
171
171
|
action: z.string().optional(),
|
|
172
172
|
type: IamPermissionTypeSchema.optional()
|
|
173
173
|
});
|
|
174
|
-
var IamAuthResultOutputSchema = haiResultSchema(IamAuthResultSchema);
|
|
175
|
-
var IamCurrentUserOutputSchema = haiResultSchema(IamCurrentUserSchema);
|
|
176
|
-
var IamRefreshTokenOutputSchema = haiResultSchema(IamRefreshTokenDataSchema);
|
|
177
|
-
var IamSendOtpOutputSchema = haiResultSchema(IamSendOtpDataSchema);
|
|
178
|
-
var IamUserOutputSchema = haiResultSchema(IamUserSchema);
|
|
179
|
-
var IamNullableUserOutputSchema = haiResultSchema(IamUserSchema.nullable());
|
|
180
|
-
var IamUsersPageOutputSchema = haiResultSchema(paginatedSchema(IamUserSchema));
|
|
181
|
-
var IamRoleOutputSchema = haiResultSchema(IamRoleSchema);
|
|
182
|
-
var IamNullableRoleOutputSchema = haiResultSchema(IamRoleSchema.nullable());
|
|
183
|
-
var IamRolesPageOutputSchema = haiResultSchema(paginatedSchema(IamRoleSchema));
|
|
184
|
-
var IamPermissionOutputSchema = haiResultSchema(IamPermissionSchema);
|
|
185
|
-
var IamNullablePermissionOutputSchema = haiResultSchema(IamPermissionSchema.nullable());
|
|
186
|
-
var IamPermissionsPageOutputSchema = haiResultSchema(paginatedSchema(IamPermissionSchema));
|
|
187
|
-
var IamVoidOutputSchema = haiResultSchema(z.void());
|
|
188
174
|
|
|
189
175
|
// src/iam/iam-contract.ts
|
|
190
|
-
var
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
register: "/auth/register",
|
|
194
|
-
logout: "/auth/logout",
|
|
195
|
-
refresh: "/auth/refresh"
|
|
196
|
-
};
|
|
176
|
+
var authResultOutputSchema = haiResultSchema(IamAuthResultSchema);
|
|
177
|
+
var userOutputSchema = haiResultSchema(IamUserSchema);
|
|
178
|
+
var roleOutputSchema = haiResultSchema(IamRoleSchema);
|
|
197
179
|
var iamContract = {
|
|
198
180
|
auth: {
|
|
199
|
-
login: route({ method: "POST", path:
|
|
200
|
-
loginWithOtp: route({ method: "POST", path:
|
|
201
|
-
logout: route({ method: "POST", path:
|
|
202
|
-
currentUser: route({ method: "GET", path: "/auth/me", operationId: "iam.auth.currentUser", summary: "Get current user and access scope", tags: ["iam", "auth"] }).output(
|
|
203
|
-
refresh: route({ method: "POST", path:
|
|
204
|
-
sendOtp: route({ method: "POST", path: "/auth/otp/send", operationId: "iam.auth.sendOtp", summary: "Send OTP", tags: ["iam", "auth"] }).input(IamSendOtpInputSchema).output(
|
|
205
|
-
register: route({ method: "POST", path:
|
|
206
|
-
changePassword: route({ method: "POST", path: "/auth/change-password", operationId: "iam.auth.changePassword", summary: "Change current user password", tags: ["iam", "auth"] }).input(IamChangePasswordInputSchema).output(
|
|
207
|
-
updateCurrentUser: route({ method: "PUT", path: "/auth/me", operationId: "iam.auth.updateCurrentUser", summary: "Update current user", tags: ["iam", "auth"] }).input(IamUpdateCurrentUserInputSchema).output(
|
|
181
|
+
login: route({ method: "POST", path: "/auth/login", operationId: "iam.auth.login", summary: "Password login", tags: ["iam", "auth"] }).input(IamLoginInputSchema).output(authResultOutputSchema),
|
|
182
|
+
loginWithOtp: route({ method: "POST", path: "/auth/login/otp", operationId: "iam.auth.loginWithOtp", summary: "OTP login", tags: ["iam", "auth"] }).input(IamOtpLoginInputSchema).output(authResultOutputSchema),
|
|
183
|
+
logout: route({ method: "POST", path: "/auth/logout", operationId: "iam.auth.logout", summary: "Logout", tags: ["iam", "auth"] }).input(IamLogoutInputSchema).output(HaiVoidResultSchema),
|
|
184
|
+
currentUser: route({ method: "GET", path: "/auth/me", operationId: "iam.auth.currentUser", summary: "Get current user and access scope", tags: ["iam", "auth"] }).output(haiResultSchema(IamCurrentUserSchema)),
|
|
185
|
+
refresh: route({ method: "POST", path: "/auth/refresh", operationId: "iam.auth.refresh", summary: "Refresh access token", tags: ["iam", "auth"] }).input(IamRefreshTokenInputSchema).output(haiResultSchema(IamRefreshTokenDataSchema)),
|
|
186
|
+
sendOtp: route({ method: "POST", path: "/auth/otp/send", operationId: "iam.auth.sendOtp", summary: "Send OTP", tags: ["iam", "auth"] }).input(IamSendOtpInputSchema).output(haiResultSchema(IamSendOtpDataSchema)),
|
|
187
|
+
register: route({ method: "POST", path: "/auth/register", operationId: "iam.auth.register", summary: "Register and login", tags: ["iam", "auth"] }).input(IamRegisterInputSchema).output(authResultOutputSchema),
|
|
188
|
+
changePassword: route({ method: "POST", path: "/auth/change-password", operationId: "iam.auth.changePassword", summary: "Change current user password", tags: ["iam", "auth"] }).input(IamChangePasswordInputSchema).output(HaiVoidResultSchema),
|
|
189
|
+
updateCurrentUser: route({ method: "PUT", path: "/auth/me", operationId: "iam.auth.updateCurrentUser", summary: "Update current user", tags: ["iam", "auth"] }).input(IamUpdateCurrentUserInputSchema).output(userOutputSchema)
|
|
208
190
|
},
|
|
209
191
|
users: {
|
|
210
|
-
list: route({ method: "GET", path: "/iam/users", operationId: "iam.users.list", summary: "List users", tags: ["iam", "users"] }).input(IamListUsersInputSchema).output(
|
|
211
|
-
get: route({ method: "GET", path: "/iam/users/{id}", operationId: "iam.users.get", summary: "Get user", tags: ["iam", "users"] }).input(IamUserIdInputSchema).output(
|
|
212
|
-
create: route({ method: "POST", path: "/iam/users", operationId: "iam.users.create", summary: "Create user", tags: ["iam", "users"] }).input(IamAdminCreateUserInputSchema).output(
|
|
213
|
-
update: route({ method: "PUT", path: "/iam/users/{id}", operationId: "iam.users.update", summary: "Update user", tags: ["iam", "users"] }).input(IamAdminUpdateUserInputSchema).output(
|
|
214
|
-
delete: route({ method: "DELETE", path: "/iam/users/{id}", operationId: "iam.users.delete", summary: "Delete user", tags: ["iam", "users"] }).input(IamUserIdInputSchema).output(
|
|
215
|
-
resetPassword: route({ method: "POST", path: "/iam/users/{id}/reset-password", operationId: "iam.users.resetPassword", summary: "Reset user password", tags: ["iam", "users"] }).input(IamAdminResetPasswordInputSchema).output(
|
|
192
|
+
list: route({ method: "GET", path: "/iam/users", operationId: "iam.users.list", summary: "List users", tags: ["iam", "users"] }).input(IamListUsersInputSchema).output(haiResultSchema(paginatedSchema(IamUserSchema))),
|
|
193
|
+
get: route({ method: "GET", path: "/iam/users/{id}", operationId: "iam.users.get", summary: "Get user", tags: ["iam", "users"] }).input(IamUserIdInputSchema).output(haiResultSchema(IamUserSchema.nullable())),
|
|
194
|
+
create: route({ method: "POST", path: "/iam/users", operationId: "iam.users.create", summary: "Create user", tags: ["iam", "users"] }).input(IamAdminCreateUserInputSchema).output(userOutputSchema),
|
|
195
|
+
update: route({ method: "PUT", path: "/iam/users/{id}", operationId: "iam.users.update", summary: "Update user", tags: ["iam", "users"] }).input(IamAdminUpdateUserInputSchema).output(userOutputSchema),
|
|
196
|
+
delete: route({ method: "DELETE", path: "/iam/users/{id}", operationId: "iam.users.delete", summary: "Delete user", tags: ["iam", "users"] }).input(IamUserIdInputSchema).output(HaiVoidResultSchema),
|
|
197
|
+
resetPassword: route({ method: "POST", path: "/iam/users/{id}/reset-password", operationId: "iam.users.resetPassword", summary: "Reset user password", tags: ["iam", "users"] }).input(IamAdminResetPasswordInputSchema).output(HaiVoidResultSchema)
|
|
216
198
|
},
|
|
217
199
|
roles: {
|
|
218
|
-
list: route({ method: "GET", path: "/iam/roles", operationId: "iam.roles.list", summary: "List roles", tags: ["iam", "roles"] }).output(
|
|
219
|
-
get: route({ method: "GET", path: "/iam/roles/{id}", operationId: "iam.roles.get", summary: "Get role", tags: ["iam", "roles"] }).input(IamUserIdInputSchema).output(
|
|
220
|
-
create: route({ method: "POST", path: "/iam/roles", operationId: "iam.roles.create", summary: "Create role", tags: ["iam", "roles"] }).input(IamCreateRoleInputSchema).output(
|
|
221
|
-
update: route({ method: "PUT", path: "/iam/roles/{id}", operationId: "iam.roles.update", summary: "Update role", tags: ["iam", "roles"] }).input(IamUpdateRoleInputSchema).output(
|
|
222
|
-
delete: route({ method: "DELETE", path: "/iam/roles/{id}", operationId: "iam.roles.delete", summary: "Delete role", tags: ["iam", "roles"] }).input(IamUserIdInputSchema).output(
|
|
200
|
+
list: route({ method: "GET", path: "/iam/roles", operationId: "iam.roles.list", summary: "List roles", tags: ["iam", "roles"] }).output(haiResultSchema(paginatedSchema(IamRoleSchema))),
|
|
201
|
+
get: route({ method: "GET", path: "/iam/roles/{id}", operationId: "iam.roles.get", summary: "Get role", tags: ["iam", "roles"] }).input(IamUserIdInputSchema).output(haiResultSchema(IamRoleSchema.nullable())),
|
|
202
|
+
create: route({ method: "POST", path: "/iam/roles", operationId: "iam.roles.create", summary: "Create role", tags: ["iam", "roles"] }).input(IamCreateRoleInputSchema).output(roleOutputSchema),
|
|
203
|
+
update: route({ method: "PUT", path: "/iam/roles/{id}", operationId: "iam.roles.update", summary: "Update role", tags: ["iam", "roles"] }).input(IamUpdateRoleInputSchema).output(roleOutputSchema),
|
|
204
|
+
delete: route({ method: "DELETE", path: "/iam/roles/{id}", operationId: "iam.roles.delete", summary: "Delete role", tags: ["iam", "roles"] }).input(IamUserIdInputSchema).output(HaiVoidResultSchema)
|
|
223
205
|
},
|
|
224
206
|
permissions: {
|
|
225
|
-
list: route({ method: "GET", path: "/iam/permissions", operationId: "iam.permissions.list", summary: "List permissions", tags: ["iam", "permissions"] }).input(IamListPermissionsInputSchema).output(
|
|
226
|
-
get: route({ method: "GET", path: "/iam/permissions/{id}", operationId: "iam.permissions.get", summary: "Get permission", tags: ["iam", "permissions"] }).input(IamUserIdInputSchema).output(
|
|
227
|
-
create: route({ method: "POST", path: "/iam/permissions", operationId: "iam.permissions.create", summary: "Create permission", tags: ["iam", "permissions"] }).input(IamCreatePermissionInputSchema).output(
|
|
228
|
-
delete: route({ method: "DELETE", path: "/iam/permissions/{id}", operationId: "iam.permissions.delete", summary: "Delete permission", tags: ["iam", "permissions"] }).input(IamUserIdInputSchema).output(
|
|
207
|
+
list: route({ method: "GET", path: "/iam/permissions", operationId: "iam.permissions.list", summary: "List permissions", tags: ["iam", "permissions"] }).input(IamListPermissionsInputSchema).output(haiResultSchema(paginatedSchema(IamPermissionSchema))),
|
|
208
|
+
get: route({ method: "GET", path: "/iam/permissions/{id}", operationId: "iam.permissions.get", summary: "Get permission", tags: ["iam", "permissions"] }).input(IamUserIdInputSchema).output(haiResultSchema(IamPermissionSchema.nullable())),
|
|
209
|
+
create: route({ method: "POST", path: "/iam/permissions", operationId: "iam.permissions.create", summary: "Create permission", tags: ["iam", "permissions"] }).input(IamCreatePermissionInputSchema).output(haiResultSchema(IamPermissionSchema)),
|
|
210
|
+
delete: route({ method: "DELETE", path: "/iam/permissions/{id}", operationId: "iam.permissions.delete", summary: "Delete permission", tags: ["iam", "permissions"] }).input(IamUserIdInputSchema).output(HaiVoidResultSchema)
|
|
229
211
|
}
|
|
230
212
|
};
|
|
231
213
|
|
|
232
|
-
export {
|
|
233
|
-
//# sourceMappingURL=chunk-
|
|
234
|
-
//# sourceMappingURL=chunk-
|
|
214
|
+
export { IamAdminCreateUserInputSchema, IamAdminResetPasswordInputSchema, IamAdminUpdateUserInputSchema, IamAgreementDisplaySchema, IamAuthResultSchema, IamChangePasswordInputSchema, IamCreatePermissionInputSchema, IamCreateRoleInputSchema, IamCurrentUserSchema, IamListPermissionsInputSchema, IamListUsersInputSchema, IamLoginInputSchema, IamLogoutInputSchema, IamOtpLoginInputSchema, IamPermissionSchema, IamPermissionTypeSchema, IamRefreshTokenDataSchema, IamRefreshTokenInputSchema, IamRegisterInputSchema, IamRoleSchema, IamSendOtpDataSchema, IamSendOtpInputSchema, IamTokenPairSchema, IamUpdateCurrentUserInputSchema, IamUpdateRoleInputSchema, IamUserIdInputSchema, IamUserSchema, PaginationQuerySchema, iamContract, paginatedSchema };
|
|
215
|
+
//# sourceMappingURL=chunk-MBNBQY2J.js.map
|
|
216
|
+
//# sourceMappingURL=chunk-MBNBQY2J.js.map
|