@lovrabet/sdk 1.6.1-beta.1 → 1.6.1-beta.3
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/dist/index.d.ts +3592 -25
- package/dist/index.js +1 -1
- package/package.json +6 -4
- package/dist/src/api/app-client.d.ts +0 -77
- package/dist/src/api/approval-client.d.ts +0 -141
- package/dist/src/api/artifact-client.d.ts +0 -67
- package/dist/src/api/bff-client.d.ts +0 -65
- package/dist/src/api/client-ak-bff-client.d.ts +0 -76
- package/dist/src/api/client-ak-sql-client.d.ts +0 -32
- package/dist/src/api/dataset-meta-client.d.ts +0 -31
- package/dist/src/api/get-user-list.d.ts +0 -4
- package/dist/src/api/index.d.ts +0 -114
- package/dist/src/api/management-client.d.ts +0 -33
- package/dist/src/api/openapi-sql-client.d.ts +0 -62
- package/dist/src/api/permit-client.d.ts +0 -325
- package/dist/src/api/sql-client.d.ts +0 -51
- package/dist/src/api/types.d.ts +0 -157
- package/dist/src/api/user-client.d.ts +0 -20
- package/dist/src/auth/auth-manager.d.ts +0 -17
- package/dist/src/auth/auth-utils.d.ts +0 -73
- package/dist/src/auth/client-ak-auth.d.ts +0 -13
- package/dist/src/auth/cookie-auth.d.ts +0 -23
- package/dist/src/auth/index.d.ts +0 -6
- package/dist/src/auth/openapi-auth.d.ts +0 -13
- package/dist/src/auth/token-generator.d.ts +0 -141
- package/dist/src/client/client.d.ts +0 -188
- package/dist/src/client/index.d.ts +0 -70
- package/dist/src/config/api-prefix.d.ts +0 -35
- package/dist/src/config/constants.d.ts +0 -82
- package/dist/src/config/endpoints.d.ts +0 -37
- package/dist/src/config/generated-region-endpoints.d.ts +0 -19
- package/dist/src/config/model-registry.d.ts +0 -42
- package/dist/src/flow/flow-client.d.ts +0 -46
- package/dist/src/flow/index.d.ts +0 -2
- package/dist/src/flow/types.d.ts +0 -203
- package/dist/src/http/cookie.d.ts +0 -2
- package/dist/src/http/get.d.ts +0 -1
- package/dist/src/http/http-client.d.ts +0 -39
- package/dist/src/http/index.d.ts +0 -2
- package/dist/src/http/post-form.d.ts +0 -2
- package/dist/src/http/post.d.ts +0 -1
- package/dist/src/http/process-response.d.ts +0 -4
- package/dist/src/http/transport.d.ts +0 -14
- package/dist/src/models/abstract-base-model.d.ts +0 -87
- package/dist/src/models/client-ak-model.d.ts +0 -72
- package/dist/src/models/index.d.ts +0 -8
- package/dist/src/models/model-factory.d.ts +0 -16
- package/dist/src/models/model-manager.d.ts +0 -89
- package/dist/src/models/openapi-model.d.ts +0 -28
- package/dist/src/models/webapi-model.d.ts +0 -16
- package/dist/src/personal/bff-client.d.ts +0 -20
- package/dist/src/personal/index.d.ts +0 -11
- package/dist/src/personal/types.d.ts +0 -52
- package/dist/src/services/file-client.d.ts +0 -13
- package/dist/src/services/index.d.ts +0 -15
- package/dist/src/services/ocr-client.d.ts +0 -17
- package/dist/src/services/types.d.ts +0 -99
- package/dist/src/types/index.d.ts +0 -969
- package/dist/src/utils/browser-detection.d.ts +0 -22
- package/dist/src/utils/errors.d.ts +0 -26
- package/dist/src/utils/index.d.ts +0 -6
- package/dist/src/utils/safe.d.ts +0 -54
- package/dist/src/utils/sql-safe.d.ts +0 -78
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,3592 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
declare class HttpClient {
|
|
2
|
+
private config;
|
|
3
|
+
private authManager;
|
|
4
|
+
private errorHandler;
|
|
5
|
+
constructor(config: ClientConfig, authManager: AuthManager$1);
|
|
6
|
+
/**
|
|
7
|
+
* 获取 API 基础地址
|
|
8
|
+
* 优先级:runtimeDomain > serverUrl >
|
|
9
|
+
* window.__GLOBAL__.deploymentConfig.RUNTIME_API_DOMAIN > getApiEndpoint(env, region)
|
|
10
|
+
*
|
|
11
|
+
* 注:serverUrl 为 runtimeDomain 的旧名称,向下兼容保留;两者均设置时以 runtimeDomain 优先。
|
|
12
|
+
*/
|
|
13
|
+
getBaseUrl(): string;
|
|
14
|
+
private getFullUrl;
|
|
15
|
+
/**
|
|
16
|
+
* 准备请求的通用逻辑:认证头、Cookie配置等
|
|
17
|
+
*/
|
|
18
|
+
private prepareRequestInit;
|
|
19
|
+
/**
|
|
20
|
+
* 通用的错误处理包装器
|
|
21
|
+
*/
|
|
22
|
+
private executeWithErrorHandling;
|
|
23
|
+
/** Apply the request deadline until response parsing finishes, preserving caller cancellation. */
|
|
24
|
+
private withTimeout;
|
|
25
|
+
/**
|
|
26
|
+
* 通用的fetch请求方法(用于PUT/DELETE等没有专门优化函数的方法)
|
|
27
|
+
*/
|
|
28
|
+
private makeRequest;
|
|
29
|
+
get<T = any>(url: string, params?: Record<string, any>, options?: RequestInit, datasetCode?: string): Promise<T>;
|
|
30
|
+
post<T = any>(url: string, data?: any, options?: RequestInit, datasetCode?: string): Promise<T>;
|
|
31
|
+
/**
|
|
32
|
+
* 调用绑定应用与操作人的 Flow OpenAPI。
|
|
33
|
+
* Flow 签名使用 operatorUserId,不使用 datasetCode;签名字段也必须随请求体发送。
|
|
34
|
+
*/
|
|
35
|
+
postFlow<T = any>(url: string, paramMap: Record<string, any>, appCode: string, operatorUserId: string, options?: RequestInit): Promise<T>;
|
|
36
|
+
postForm<T = any>(url: string, data: FormData, options?: RequestInit): Promise<T>;
|
|
37
|
+
put<T = any>(url: string, data?: any, options?: RequestInit, datasetCode?: string): Promise<T>;
|
|
38
|
+
delete<T = any>(url: string, options?: RequestInit, datasetCode?: string): Promise<T>;
|
|
39
|
+
request<T = any>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', url: string, data?: any, options?: RequestInit, datasetCode?: string): Promise<T>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 脚本日志查询参数(`GET /api/dev/script-logs/search`)
|
|
44
|
+
*/
|
|
45
|
+
interface ScriptLogQuery {
|
|
46
|
+
/** 起始时间(毫秒时间戳) */
|
|
47
|
+
startTime: number;
|
|
48
|
+
/** 结束时间(毫秒时间戳) */
|
|
49
|
+
endTime: number;
|
|
50
|
+
/** 日志级别 */
|
|
51
|
+
level?: string;
|
|
52
|
+
/** 关键字 */
|
|
53
|
+
keyword?: string;
|
|
54
|
+
/** 返回条数上限 */
|
|
55
|
+
limit?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 研发管理客户端(仅 cookie 会话态)。
|
|
59
|
+
*
|
|
60
|
+
* 后端脚本缓存与日志诊断接口只注册在 `/api` 下,未提供 `/client` 镜像。
|
|
61
|
+
*/
|
|
62
|
+
declare class ManagementClient {
|
|
63
|
+
private readonly httpClient;
|
|
64
|
+
private readonly appCode;
|
|
65
|
+
private readonly authMode;
|
|
66
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
67
|
+
/** 清理脚本缓存(`POST /api/management/script/cache/clear`) */
|
|
68
|
+
clearScriptCache(): Promise<string>;
|
|
69
|
+
/** 查询脚本运行日志(`GET /api/dev/script-logs/search`) */
|
|
70
|
+
searchScriptLogs(query: ScriptLogQuery): Promise<string[]>;
|
|
71
|
+
private assertMode;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* SQL 执行请求参数
|
|
76
|
+
*/
|
|
77
|
+
interface SqlExecuteRequest {
|
|
78
|
+
/** SQL 代码(字符串格式 "appCode-sqlId" 或数字 ID) */
|
|
79
|
+
sqlCode: string | number;
|
|
80
|
+
/** SQL 参数对象(可选) */
|
|
81
|
+
params?: Record<string, string | number>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* SQL 执行结果数据
|
|
85
|
+
*/
|
|
86
|
+
interface SqlExecuteResult<T = Record<string, any>> {
|
|
87
|
+
/** SQL 执行是否成功 */
|
|
88
|
+
execSuccess: boolean;
|
|
89
|
+
/** SQL 查询结果数组 */
|
|
90
|
+
execResult?: T[];
|
|
91
|
+
/** 写操作影响行数(后端 `SqlExecResult`)。 */
|
|
92
|
+
affectedRows?: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 通用分页结果(后端 `PageResult<T>`)
|
|
96
|
+
*/
|
|
97
|
+
interface PageResult<T> {
|
|
98
|
+
/** 当前页数据 */
|
|
99
|
+
records: T[];
|
|
100
|
+
/** 当前页码 */
|
|
101
|
+
currentPage?: number;
|
|
102
|
+
/** 每页条数 */
|
|
103
|
+
pageSize?: number;
|
|
104
|
+
/** 总条数 */
|
|
105
|
+
totalCount?: number;
|
|
106
|
+
/** 总页数 */
|
|
107
|
+
totalPages?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 通用分页元信息(后端 `Paging`)
|
|
111
|
+
*/
|
|
112
|
+
interface Paging$1 {
|
|
113
|
+
currentPage?: number;
|
|
114
|
+
totalCount?: number;
|
|
115
|
+
pageSize?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 通用数据列表(后端 `DataList<T>`)
|
|
119
|
+
*/
|
|
120
|
+
interface DataList<T> {
|
|
121
|
+
tableData: T[];
|
|
122
|
+
paging?: Paging$1;
|
|
123
|
+
tableColumns?: Array<Record<string, unknown>>;
|
|
124
|
+
execResult?: string;
|
|
125
|
+
extend?: unknown;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 自定义 SQL 列表查询参数(`POST /client/sql/query`)
|
|
129
|
+
*/
|
|
130
|
+
interface CustomSqlQueryRequest {
|
|
131
|
+
/** 自定义 SQL 主键 */
|
|
132
|
+
id?: number;
|
|
133
|
+
/** SQL 编码 */
|
|
134
|
+
sqlCode?: string;
|
|
135
|
+
/** 绑定的数据集主键 */
|
|
136
|
+
datasetId?: number;
|
|
137
|
+
/** SQL 内容 */
|
|
138
|
+
sqlContent?: string;
|
|
139
|
+
/** 查询参数 */
|
|
140
|
+
params?: Record<string, unknown>;
|
|
141
|
+
/** 是否驼峰输出,默认 false */
|
|
142
|
+
camelCaseFlag?: boolean;
|
|
143
|
+
/** 应用编码 */
|
|
144
|
+
appCode?: string;
|
|
145
|
+
/** SQL 名称(模糊匹配) */
|
|
146
|
+
sqlName?: string;
|
|
147
|
+
/** 当前页,默认 1 */
|
|
148
|
+
currentPage?: number;
|
|
149
|
+
/** 每页条数,默认 10 */
|
|
150
|
+
pageSize?: number;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* 自定义 SQL 元信息(后端 `UserCustomSqlDTO`)
|
|
154
|
+
*/
|
|
155
|
+
interface UserCustomSqlDTO {
|
|
156
|
+
id?: number;
|
|
157
|
+
tenantCode?: string;
|
|
158
|
+
appCode?: string;
|
|
159
|
+
dbId?: number;
|
|
160
|
+
sqlName?: string;
|
|
161
|
+
sqlCode?: string;
|
|
162
|
+
sqlContent?: string;
|
|
163
|
+
sqlConfig?: string;
|
|
164
|
+
params?: Record<string, unknown>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 数据集查询参数(`POST /client/dataset/list`)
|
|
168
|
+
*/
|
|
169
|
+
interface DatasetRequest {
|
|
170
|
+
appCode?: string;
|
|
171
|
+
datasetId?: number;
|
|
172
|
+
code?: string;
|
|
173
|
+
name?: string;
|
|
174
|
+
tableName?: string;
|
|
175
|
+
deleted?: boolean;
|
|
176
|
+
currentPage?: number;
|
|
177
|
+
pageSize?: number;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 数据集元信息(后端 `Dataset`,仅列出 SDK 使用到的字段)
|
|
181
|
+
*/
|
|
182
|
+
interface DatasetMeta {
|
|
183
|
+
dbtableConfig?: {
|
|
184
|
+
dbId?: number;
|
|
185
|
+
tableName?: string;
|
|
186
|
+
datasetKey?: string;
|
|
187
|
+
pkField?: string;
|
|
188
|
+
allFields?: string;
|
|
189
|
+
[key: string]: unknown;
|
|
190
|
+
};
|
|
191
|
+
id?: number;
|
|
192
|
+
name?: string;
|
|
193
|
+
code?: string;
|
|
194
|
+
source?: string;
|
|
195
|
+
description?: string;
|
|
196
|
+
appCode?: string;
|
|
197
|
+
tableName?: string;
|
|
198
|
+
version?: number;
|
|
199
|
+
relations?: Record<string, unknown>;
|
|
200
|
+
columns?: Array<Record<string, unknown>>;
|
|
201
|
+
relationPages?: Array<Record<string, unknown>>;
|
|
202
|
+
operations?: Record<string, unknown>;
|
|
203
|
+
extend?: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* 数据集驱动配置查询参数(`GET /client/dataset/get-driven-data`)
|
|
207
|
+
*/
|
|
208
|
+
interface DatasetDrivenDataQuery {
|
|
209
|
+
/** 数据集主键(与 code 至少提供一个) */
|
|
210
|
+
id?: number;
|
|
211
|
+
/** 数据集编码(与 id 至少提供一个) */
|
|
212
|
+
code?: string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 用户信息
|
|
216
|
+
*/
|
|
217
|
+
interface User {
|
|
218
|
+
/** 用户代码 */
|
|
219
|
+
code: string;
|
|
220
|
+
/** 用户名 */
|
|
221
|
+
userName: string;
|
|
222
|
+
/** 昵称 */
|
|
223
|
+
nickName?: string | null;
|
|
224
|
+
/** 手机号 */
|
|
225
|
+
mobile: string;
|
|
226
|
+
/** 邮箱 */
|
|
227
|
+
email?: string | null;
|
|
228
|
+
/** 头像 */
|
|
229
|
+
avatar?: string | null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 数据集元信息客户端(仅 client-ak 模式)。
|
|
234
|
+
*
|
|
235
|
+
* 后端 `DatasetClientController` 只注册在 `/client/dataset` 下;
|
|
236
|
+
* 数据集 CRUD 仍由 `ClientAkModel` 负责。
|
|
237
|
+
*/
|
|
238
|
+
declare class DatasetMetaClient {
|
|
239
|
+
private readonly httpClient;
|
|
240
|
+
private readonly appCode;
|
|
241
|
+
private readonly authMode;
|
|
242
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
243
|
+
/** 查询数据集元信息(`POST /client/dataset/list`) */
|
|
244
|
+
list(request?: DatasetRequest): Promise<DatasetMeta[]>;
|
|
245
|
+
/**
|
|
246
|
+
* 按 code 查询单个数据集(`GET /client/dataset/query`)。
|
|
247
|
+
*
|
|
248
|
+
* @deprecated 后端已标记该接口待下线,请优先使用 `getDrivenData({ code })`。
|
|
249
|
+
*/
|
|
250
|
+
queryByCode(code: string): Promise<DatasetMeta | null>;
|
|
251
|
+
/**
|
|
252
|
+
* 查询数据集驱动配置(`GET /client/dataset/get-driven-data`)。
|
|
253
|
+
*
|
|
254
|
+
* 返回结构随数据集 `doVersion` 不同:v1 为 `DatasetDrivenData`,v2 为 `DoProtocol`,
|
|
255
|
+
* 因此保持泛型由调用方声明。
|
|
256
|
+
*/
|
|
257
|
+
getDrivenData<T = unknown>(query: DatasetDrivenDataQuery): Promise<T>;
|
|
258
|
+
private assertMode;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 登录用户信息(后端 `UserSessionHolder.getUser()` 返回的 `User`)。
|
|
263
|
+
*/
|
|
264
|
+
interface LoginUserInfo {
|
|
265
|
+
id?: string;
|
|
266
|
+
userId?: number;
|
|
267
|
+
username?: string;
|
|
268
|
+
nickname?: string;
|
|
269
|
+
name?: string | null;
|
|
270
|
+
mobile?: string;
|
|
271
|
+
email?: string;
|
|
272
|
+
avatar?: string;
|
|
273
|
+
appCode?: string;
|
|
274
|
+
tenantCode?: string;
|
|
275
|
+
roleType?: string;
|
|
276
|
+
roleId?: number;
|
|
277
|
+
roleName?: string;
|
|
278
|
+
roleCode?: string;
|
|
279
|
+
[key: string]: unknown;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* 智能应用(后端 `SmartApp`,仅列出常用字段)
|
|
283
|
+
*/
|
|
284
|
+
interface SmartApp {
|
|
285
|
+
id?: number;
|
|
286
|
+
appCode?: string;
|
|
287
|
+
appName?: string;
|
|
288
|
+
tenantCode?: string;
|
|
289
|
+
appPublishStatus?: string;
|
|
290
|
+
appDesc?: string;
|
|
291
|
+
appLogo?: string;
|
|
292
|
+
appDomain?: string;
|
|
293
|
+
appOwnerId?: string;
|
|
294
|
+
appOwnerName?: string;
|
|
295
|
+
createTime?: string;
|
|
296
|
+
updateTime?: string;
|
|
297
|
+
[key: string]: unknown;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* 外部账号绑定参数(后端 `UserAccountBindRequest`)
|
|
301
|
+
*/
|
|
302
|
+
interface UserAccountBindRequest {
|
|
303
|
+
provider: string;
|
|
304
|
+
accountId: string;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* 通知渠道配置(后端 `NotificationChannelConfigViewDTO`)
|
|
308
|
+
*/
|
|
309
|
+
interface NotificationChannelConfig {
|
|
310
|
+
configCode?: string;
|
|
311
|
+
configName?: string;
|
|
312
|
+
channelType?: string;
|
|
313
|
+
description?: string;
|
|
314
|
+
}
|
|
315
|
+
/** Client AK 应用/用户接口配置;身份查询不需要 appCode。 */
|
|
316
|
+
type AppClientConfig = Pick<ClientConfig, 'appCode' | 'runtimeDomain' | 'serverUrl' | 'env' | 'region' | 'options'> & {
|
|
317
|
+
accessKey: string;
|
|
318
|
+
};
|
|
319
|
+
/** 创建应用/用户客户端,适用于尚未选定应用的身份查询。 */
|
|
320
|
+
declare function createAppClient(config: AppClientConfig): AppClient;
|
|
321
|
+
/**
|
|
322
|
+
* 应用与用户配置客户端(仅 client-ak 模式)。
|
|
323
|
+
*
|
|
324
|
+
* 对应后端 `/client/app`、`/client/user`、`/client/user-accounts`、
|
|
325
|
+
* `/client/app-config`、`/client/notification/channel-config`,均无 `/api` 镜像。
|
|
326
|
+
*/
|
|
327
|
+
declare class AppClient {
|
|
328
|
+
private readonly httpClient;
|
|
329
|
+
private readonly appCode;
|
|
330
|
+
private readonly authMode;
|
|
331
|
+
constructor(httpClient: HttpClient, appCode: string | undefined, authMode: AuthMode);
|
|
332
|
+
/** 当前用户可见的应用(`GET /client/app/my-apps`) */
|
|
333
|
+
myApps(): Promise<SmartApp[]>;
|
|
334
|
+
/** 当前登录用户信息(`GET /client/user/loginUserInfo`) */
|
|
335
|
+
loginUserInfo<T = LoginUserInfo>(): Promise<T>;
|
|
336
|
+
/** 绑定外部账号(`POST /client/user-accounts/bind`) */
|
|
337
|
+
bindAccount(request: UserAccountBindRequest): Promise<boolean>;
|
|
338
|
+
/** 按 key 读取应用配置(`GET /client/app-config/getByKey`) */
|
|
339
|
+
getConfigByKey<T = unknown>(key: string): Promise<T>;
|
|
340
|
+
/** 查询通知渠道配置(`GET /client/notification/channel-config/list`) */
|
|
341
|
+
listNotificationChannels(channelType?: string): Promise<NotificationChannelConfig[]>;
|
|
342
|
+
private assertMode;
|
|
343
|
+
private requireAppCode;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* 审批任务列表查询参数
|
|
348
|
+
*/
|
|
349
|
+
interface ApprovalTodoQuery {
|
|
350
|
+
currentPage?: number;
|
|
351
|
+
pageSize?: number;
|
|
352
|
+
}
|
|
353
|
+
/** 审批任务转办候选人(后端 `ApprovalFlowTransferCandidateDTO`)。 */
|
|
354
|
+
interface ApprovalFlowTransferCandidate {
|
|
355
|
+
userId?: string;
|
|
356
|
+
userName?: string | null;
|
|
357
|
+
}
|
|
358
|
+
/** 审批任务身份链接(后端 `ApprovalFlowIdentityLinkDTO`)。 */
|
|
359
|
+
interface ApprovalFlowIdentityLink {
|
|
360
|
+
type?: string;
|
|
361
|
+
userId?: string | null;
|
|
362
|
+
groupId?: string | null;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* 审批任务列表项(后端 `ApprovalFlowTaskItemDTO`,仅列出常用字段)
|
|
366
|
+
*/
|
|
367
|
+
interface ApprovalFlowTaskItem {
|
|
368
|
+
id?: string;
|
|
369
|
+
name?: string;
|
|
370
|
+
taskDefinitionKey?: string;
|
|
371
|
+
taskMode?: string;
|
|
372
|
+
assignee?: string;
|
|
373
|
+
assigneeName?: string;
|
|
374
|
+
transferCandidates?: ApprovalFlowTransferCandidate[];
|
|
375
|
+
handleMode?: string;
|
|
376
|
+
processInstanceId?: string;
|
|
377
|
+
flowCode?: string;
|
|
378
|
+
flowName?: string;
|
|
379
|
+
appCode?: string;
|
|
380
|
+
pageMode?: string;
|
|
381
|
+
initiatorUserId?: string;
|
|
382
|
+
initiatorUsername?: string;
|
|
383
|
+
datasetCode?: string;
|
|
384
|
+
pageId?: number;
|
|
385
|
+
path?: string;
|
|
386
|
+
operationType?: string;
|
|
387
|
+
dataId?: unknown;
|
|
388
|
+
detailUrl?: string;
|
|
389
|
+
taskStatus?: string;
|
|
390
|
+
processStatus?: string;
|
|
391
|
+
createTime?: number;
|
|
392
|
+
endTime?: number;
|
|
393
|
+
processStartTime?: number;
|
|
394
|
+
businessVariables?: Record<string, unknown>;
|
|
395
|
+
[key: string]: unknown;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* 审批任务详情(后端 `ApprovalFlowTaskDetailDTO`,仅列出常用字段)
|
|
399
|
+
*/
|
|
400
|
+
interface ApprovalFlowTaskDetail {
|
|
401
|
+
id?: string;
|
|
402
|
+
name?: string;
|
|
403
|
+
taskDefinitionKey?: string;
|
|
404
|
+
taskMode?: string;
|
|
405
|
+
assignee?: string;
|
|
406
|
+
assigneeName?: string;
|
|
407
|
+
transferCandidates?: ApprovalFlowTransferCandidate[];
|
|
408
|
+
processInstanceId?: string;
|
|
409
|
+
appCode?: string;
|
|
410
|
+
flowType?: string;
|
|
411
|
+
pageMode?: string;
|
|
412
|
+
path?: string;
|
|
413
|
+
detailUrl?: string;
|
|
414
|
+
dataId?: unknown;
|
|
415
|
+
createTime?: number;
|
|
416
|
+
endTime?: number;
|
|
417
|
+
status?: string;
|
|
418
|
+
canHandle?: boolean;
|
|
419
|
+
handleMode?: string;
|
|
420
|
+
canCancel?: boolean;
|
|
421
|
+
canWithdraw?: boolean;
|
|
422
|
+
canResubmit?: boolean;
|
|
423
|
+
canVoid?: boolean;
|
|
424
|
+
canReturn?: boolean;
|
|
425
|
+
canReturnToStarter?: boolean;
|
|
426
|
+
processStatus?: string;
|
|
427
|
+
returnReason?: string;
|
|
428
|
+
approvalRound?: number;
|
|
429
|
+
formData?: Record<string, unknown>;
|
|
430
|
+
businessVariables?: Record<string, unknown>;
|
|
431
|
+
formSchema?: Record<string, unknown>;
|
|
432
|
+
formPermissions?: Record<string, unknown>;
|
|
433
|
+
identityLinks?: ApprovalFlowIdentityLink[];
|
|
434
|
+
timeline?: Record<string, unknown>;
|
|
435
|
+
[key: string]: unknown;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* 审批办理参数(后端 `ApprovalFlowApproveRequestDTO`)
|
|
439
|
+
*/
|
|
440
|
+
interface ApprovalFlowApproveRequest {
|
|
441
|
+
appCode?: string;
|
|
442
|
+
/** Flowable 任务 id */
|
|
443
|
+
taskId: string;
|
|
444
|
+
/** true 通过,false 拒绝 */
|
|
445
|
+
approved: boolean;
|
|
446
|
+
/** 审批意见 */
|
|
447
|
+
comment?: string;
|
|
448
|
+
/** 当前节点可编辑字段的 Patch */
|
|
449
|
+
formPatch?: Record<string, unknown>;
|
|
450
|
+
/** 表单数据版本,必须原样回传 task 详情返回值 */
|
|
451
|
+
formDataVersion?: number;
|
|
452
|
+
/** 额外流程变量 */
|
|
453
|
+
variables?: Record<string, unknown>;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* 审批转办参数(后端 `ApprovalFlowTransferRequestDTO`)
|
|
457
|
+
*/
|
|
458
|
+
interface ApprovalFlowTransferRequest {
|
|
459
|
+
appCode?: string;
|
|
460
|
+
taskId: string;
|
|
461
|
+
targetUserId: string;
|
|
462
|
+
comment?: string;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* 审批任务客户端(仅 client-ak 模式)。
|
|
466
|
+
*
|
|
467
|
+
* 后端 `ApprovalFlowClientController` 只注册在 `/client` 下,没有 `/api` 镜像。
|
|
468
|
+
*/
|
|
469
|
+
declare class ApprovalClient {
|
|
470
|
+
private readonly httpClient;
|
|
471
|
+
private readonly appCode;
|
|
472
|
+
private readonly authMode;
|
|
473
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
474
|
+
/** 查询当前用户待办(`GET /client/approve/todo`) */
|
|
475
|
+
listTodo(query?: ApprovalTodoQuery): Promise<PageResult<ApprovalFlowTaskItem>>;
|
|
476
|
+
/** 查询审批任务详情(`GET /client/flow/task/{taskId}`) */
|
|
477
|
+
getTask(taskId: string): Promise<ApprovalFlowTaskDetail>;
|
|
478
|
+
/** 通过或拒绝审批任务(`POST /client/flow/approve`) */
|
|
479
|
+
approve(request: ApprovalFlowApproveRequest): Promise<void>;
|
|
480
|
+
/** 转办审批任务(`POST /client/flow/task/transfer`) */
|
|
481
|
+
transfer(request: ApprovalFlowTransferRequest): Promise<void>;
|
|
482
|
+
private assertMode;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Artifact 创建/更新参数(后端 `ArtifactUpsertRequest`)
|
|
487
|
+
*/
|
|
488
|
+
interface ArtifactUpsertRequest {
|
|
489
|
+
appCode?: string;
|
|
490
|
+
/** 产物类型 */
|
|
491
|
+
artifactType?: string;
|
|
492
|
+
/** 产物名称 */
|
|
493
|
+
name?: string;
|
|
494
|
+
/** 产物内容 */
|
|
495
|
+
content?: string;
|
|
496
|
+
/** 结构化元信息 */
|
|
497
|
+
metadata?: Record<string, unknown>;
|
|
498
|
+
/** 产物来源 */
|
|
499
|
+
source?: string;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Artifact 列表筛选条件
|
|
503
|
+
*/
|
|
504
|
+
interface ArtifactListQuery {
|
|
505
|
+
artifactType?: string;
|
|
506
|
+
source?: string;
|
|
507
|
+
favorite?: boolean;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Artifact 详情(后端 `RuntimeArtifactDTO`)
|
|
511
|
+
*/
|
|
512
|
+
interface RuntimeArtifactDTO {
|
|
513
|
+
id?: number;
|
|
514
|
+
appCode?: string;
|
|
515
|
+
artifactType?: string;
|
|
516
|
+
name?: string;
|
|
517
|
+
content?: string;
|
|
518
|
+
compiledContent?: string;
|
|
519
|
+
metadata?: Record<string, unknown>;
|
|
520
|
+
source?: string;
|
|
521
|
+
favorite?: boolean;
|
|
522
|
+
deleted?: number;
|
|
523
|
+
createTime?: string;
|
|
524
|
+
updateTime?: string;
|
|
525
|
+
createUserId?: string;
|
|
526
|
+
updateUserId?: string;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Artifact 客户端(仅 client-ak 模式)。
|
|
530
|
+
*
|
|
531
|
+
* 后端只在 `/client/artifact` 暴露该能力,没有 `/api` 镜像。
|
|
532
|
+
*/
|
|
533
|
+
declare class ArtifactClient {
|
|
534
|
+
private readonly httpClient;
|
|
535
|
+
private readonly appCode;
|
|
536
|
+
private readonly authMode;
|
|
537
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
538
|
+
/** 列出当前应用的 Artifact(`GET /client/artifact/list`) */
|
|
539
|
+
list(query?: ArtifactListQuery): Promise<RuntimeArtifactDTO[]>;
|
|
540
|
+
/** 获取 Artifact 详情(`GET /client/artifact/{id}`) */
|
|
541
|
+
get(id: number): Promise<RuntimeArtifactDTO | null>;
|
|
542
|
+
/** 创建 Artifact(`POST /client/artifact/create`) */
|
|
543
|
+
create(request: ArtifactUpsertRequest): Promise<RuntimeArtifactDTO>;
|
|
544
|
+
/** 更新 Artifact(`POST /client/artifact/{id}/update`) */
|
|
545
|
+
update(id: number, request: ArtifactUpsertRequest): Promise<RuntimeArtifactDTO>;
|
|
546
|
+
/** 更新收藏状态(`POST /client/artifact/{id}/favorite`) */
|
|
547
|
+
updateFavorite(id: number, favorite: boolean): Promise<RuntimeArtifactDTO>;
|
|
548
|
+
private assertMode;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* 角色查询参数(后端 `AppRoleRequest`)
|
|
553
|
+
*/
|
|
554
|
+
interface AppRoleRequest {
|
|
555
|
+
id?: number;
|
|
556
|
+
appCode?: string;
|
|
557
|
+
roleId?: number;
|
|
558
|
+
roleName?: string;
|
|
559
|
+
currentPage?: number;
|
|
560
|
+
pageSize?: number;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* 角色创建参数(后端 `AppRoleCreateParam`,仅允许 CUSTOM)
|
|
564
|
+
*/
|
|
565
|
+
interface AppRoleCreateParam {
|
|
566
|
+
appCode?: string;
|
|
567
|
+
roleType?: string;
|
|
568
|
+
roleName: string;
|
|
569
|
+
roleCode?: string;
|
|
570
|
+
permits?: Record<string, string[]>;
|
|
571
|
+
remark?: string;
|
|
572
|
+
extend?: string;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* 角色更新参数(后端 `AppRoleUpdateParam`,仅允许 CUSTOM)
|
|
576
|
+
*/
|
|
577
|
+
interface AppRoleUpdateParam {
|
|
578
|
+
id: number;
|
|
579
|
+
appCode?: string;
|
|
580
|
+
roleType?: string;
|
|
581
|
+
roleName?: string;
|
|
582
|
+
roleCode?: string;
|
|
583
|
+
permits?: Record<string, string[]>;
|
|
584
|
+
remark?: string;
|
|
585
|
+
extend?: string;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* 权限角色查询参数(后端 `AppRolePermitQueryParam`)
|
|
589
|
+
*/
|
|
590
|
+
interface AppRolePermitQueryParam {
|
|
591
|
+
appCode?: string;
|
|
592
|
+
/** 是否补充「仅自己」内置角色 */
|
|
593
|
+
needSelf?: boolean;
|
|
594
|
+
/** 是否补充「全部」内置角色 */
|
|
595
|
+
needPublic?: boolean;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* 角色视图对象(后端 `AppRoleVO`)
|
|
599
|
+
*/
|
|
600
|
+
interface AppRoleVO {
|
|
601
|
+
id?: number;
|
|
602
|
+
appCode?: string;
|
|
603
|
+
roleName?: string;
|
|
604
|
+
roleCode?: string;
|
|
605
|
+
roleType?: string;
|
|
606
|
+
permits?: Record<string, string[]>;
|
|
607
|
+
remark?: string;
|
|
608
|
+
extend?: string;
|
|
609
|
+
userCount?: number;
|
|
610
|
+
permitCount?: number;
|
|
611
|
+
gmtCreate?: string;
|
|
612
|
+
gmtModified?: string;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* 用户角色查询参数(后端 `UserAppRelationQueryParam`)
|
|
616
|
+
*/
|
|
617
|
+
interface UserAppRelationQueryParam {
|
|
618
|
+
appCode?: string;
|
|
619
|
+
userId?: string;
|
|
620
|
+
roleType?: string;
|
|
621
|
+
roleId?: number;
|
|
622
|
+
tenantCode?: string;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* 应用用户基础信息(后端 `AppUserBaseVO`,字段随租户扩展)
|
|
626
|
+
*/
|
|
627
|
+
interface AppUserBaseVO {
|
|
628
|
+
userId?: string;
|
|
629
|
+
username?: string;
|
|
630
|
+
nickname?: string;
|
|
631
|
+
userName?: string;
|
|
632
|
+
nickName?: string;
|
|
633
|
+
mobile?: string;
|
|
634
|
+
email?: string;
|
|
635
|
+
avatar?: string;
|
|
636
|
+
[key: string]: unknown;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* 角色与用户关联(后端 `AppRoleUserVO`)
|
|
640
|
+
*/
|
|
641
|
+
interface AppRoleUserVO {
|
|
642
|
+
id?: number;
|
|
643
|
+
roleName?: string;
|
|
644
|
+
roleCode?: string;
|
|
645
|
+
roleType?: string;
|
|
646
|
+
userList?: AppUserBaseVO[];
|
|
647
|
+
applyUserList?: AppUserBaseVO[];
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* 角色成员更新参数(后端 `RoleUserUpdateParam`)
|
|
651
|
+
*/
|
|
652
|
+
interface RoleUserUpdateParam {
|
|
653
|
+
appCode?: string;
|
|
654
|
+
roleList: AppRoleUserVO[];
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* 应用成员(后端 `YtEmployee`)
|
|
658
|
+
*/
|
|
659
|
+
interface AppEmployee {
|
|
660
|
+
code?: string | number;
|
|
661
|
+
userName?: string;
|
|
662
|
+
nickName?: string;
|
|
663
|
+
displayName?: string;
|
|
664
|
+
mobile?: string;
|
|
665
|
+
email?: string;
|
|
666
|
+
avatar?: string;
|
|
667
|
+
status?: string;
|
|
668
|
+
extend?: Record<string, unknown>;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* 资源权限中的角色条目(后端 `BaseRoleVO`)
|
|
672
|
+
*/
|
|
673
|
+
interface BaseRoleVO {
|
|
674
|
+
id?: number;
|
|
675
|
+
roleName?: string;
|
|
676
|
+
roleCode?: string;
|
|
677
|
+
roleType?: string;
|
|
678
|
+
allowed?: boolean;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* 资源权限(后端 `ResourcePermitDTO`)
|
|
682
|
+
*/
|
|
683
|
+
interface ResourcePermitDTO {
|
|
684
|
+
id?: number;
|
|
685
|
+
appCode?: string;
|
|
686
|
+
menuId?: number | null;
|
|
687
|
+
pageId?: number | null;
|
|
688
|
+
resourceCode?: string;
|
|
689
|
+
resourceType?: string;
|
|
690
|
+
resourceName?: string;
|
|
691
|
+
rolePermit?: BaseRoleVO[] | null;
|
|
692
|
+
dataPermit?: BaseRoleVO[] | null;
|
|
693
|
+
fieldPermit?: string;
|
|
694
|
+
extend?: string;
|
|
695
|
+
gmtCreate?: string;
|
|
696
|
+
gmtModified?: string;
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* 页面权限保存参数(后端 `MenuPermitDTO`)
|
|
700
|
+
*/
|
|
701
|
+
interface MenuPermitDTO {
|
|
702
|
+
menuId?: number;
|
|
703
|
+
pageId?: number;
|
|
704
|
+
appCode?: string;
|
|
705
|
+
datasetCode?: string;
|
|
706
|
+
menuPermit?: ResourcePermitDTO;
|
|
707
|
+
dataCreate?: ResourcePermitDTO | null;
|
|
708
|
+
dataUpdate?: ResourcePermitDTO | null;
|
|
709
|
+
dataDelete?: ResourcePermitDTO | null;
|
|
710
|
+
dataDetail?: ResourcePermitDTO | null;
|
|
711
|
+
dataExport?: ResourcePermitDTO | null;
|
|
712
|
+
dataPermit?: ResourcePermitDTO | null;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* 资源菜单查询参数(后端 `AppResourceMenuParam`)
|
|
716
|
+
*/
|
|
717
|
+
interface AppResourceMenuParam {
|
|
718
|
+
appCode?: string;
|
|
719
|
+
roleId?: number;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* 资源批量保存参数(后端 `ResourcePermitParam`)
|
|
723
|
+
*/
|
|
724
|
+
interface ResourcePermitParam {
|
|
725
|
+
appCode?: string;
|
|
726
|
+
permitList: ResourcePermitDTO[];
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* 菜单角色权限列表(后端 `MenuRolePermitListVO`)
|
|
730
|
+
*/
|
|
731
|
+
interface MenuRolePermitListVO {
|
|
732
|
+
permitList?: MenuRolePermitNodeVO[];
|
|
733
|
+
}
|
|
734
|
+
/** 按角色求值后的资源权限(后端 `AppPermitBaseVO`)。 */
|
|
735
|
+
interface AppPermitBaseVO {
|
|
736
|
+
resourceType?: string;
|
|
737
|
+
resourceCode?: string;
|
|
738
|
+
resourceName?: string;
|
|
739
|
+
allowed?: boolean;
|
|
740
|
+
allowedActions?: string[];
|
|
741
|
+
}
|
|
742
|
+
/** 菜单及页面资源的权限求值结果(后端 `AppMenuPermitVO`)。 */
|
|
743
|
+
interface AppMenuPermitVO extends AppPermitBaseVO {
|
|
744
|
+
appCode?: string;
|
|
745
|
+
menuType?: string;
|
|
746
|
+
pageId?: number | null;
|
|
747
|
+
pageNodeList?: AppPermitBaseVO[] | null;
|
|
748
|
+
}
|
|
749
|
+
/** 菜单角色权限树;未配置权限时 rolePermit/permitId 为 null。 */
|
|
750
|
+
interface MenuRolePermitNodeVO {
|
|
751
|
+
id?: number;
|
|
752
|
+
parentId?: number;
|
|
753
|
+
label?: string;
|
|
754
|
+
type?: string | null;
|
|
755
|
+
path?: string;
|
|
756
|
+
pageId?: number | null;
|
|
757
|
+
permitId?: number | null;
|
|
758
|
+
rolePermit?: BaseRoleVO[] | null;
|
|
759
|
+
children?: MenuRolePermitNodeVO[];
|
|
760
|
+
[key: string]: unknown;
|
|
761
|
+
}
|
|
762
|
+
/** 数据集各动作按角色求值后的权限。 */
|
|
763
|
+
interface AppDatasetPermitVO {
|
|
764
|
+
appCode?: string;
|
|
765
|
+
datasetCode?: string;
|
|
766
|
+
datasetName?: string;
|
|
767
|
+
dataPermitList?: AppPermitBaseVO[];
|
|
768
|
+
}
|
|
769
|
+
interface DatasetPermitListVO {
|
|
770
|
+
permitList?: AppDatasetPermitVO[];
|
|
771
|
+
}
|
|
772
|
+
/** 数据动作的原始角色配置,区别于按角色求值后的 allowed。 */
|
|
773
|
+
interface AppDatasetActionRolePermitVO {
|
|
774
|
+
permitId?: number | null;
|
|
775
|
+
resourceType?: string;
|
|
776
|
+
resourceCode?: string;
|
|
777
|
+
resourceName?: string;
|
|
778
|
+
rolePermit?: BaseRoleVO[] | null;
|
|
779
|
+
}
|
|
780
|
+
interface AppDatasetRolePermitVO {
|
|
781
|
+
appCode?: string;
|
|
782
|
+
datasetCode?: string;
|
|
783
|
+
datasetName?: string;
|
|
784
|
+
dataPermitList?: AppDatasetActionRolePermitVO[];
|
|
785
|
+
}
|
|
786
|
+
interface DatasetRolePermitListVO {
|
|
787
|
+
permitList?: AppDatasetRolePermitVO[];
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* 运行态身份权限快照(后端 `RuntimeIdentityPermissionVO`)
|
|
791
|
+
*/
|
|
792
|
+
interface RuntimeIdentityPermission {
|
|
793
|
+
appCode?: string;
|
|
794
|
+
appExists?: boolean;
|
|
795
|
+
sampleEnabled?: boolean;
|
|
796
|
+
appRoles?: string[];
|
|
797
|
+
platformRoles?: string[];
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* 应用用户关系(后端 `UserAppRelationDTO`)
|
|
801
|
+
*/
|
|
802
|
+
interface UserAppRelation {
|
|
803
|
+
id?: number;
|
|
804
|
+
appCode?: string;
|
|
805
|
+
appName?: string;
|
|
806
|
+
userId?: string;
|
|
807
|
+
username?: string;
|
|
808
|
+
status?: string;
|
|
809
|
+
roleType?: string;
|
|
810
|
+
roleId?: number;
|
|
811
|
+
roleName?: string;
|
|
812
|
+
tenantCode?: string;
|
|
813
|
+
roleCode?: string;
|
|
814
|
+
approve?: string;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* 权限、角色与成员客户端。
|
|
818
|
+
*
|
|
819
|
+
* 后端成对提供了 `/api/permit/*`、`/api/dept/*`、`/api/menu/*` 镜像 controller,
|
|
820
|
+
* 因此本类同时支持 cookie 与 client-ak 两种模式;OpenAPI 模式不支持。
|
|
821
|
+
*/
|
|
822
|
+
declare class PermitClient {
|
|
823
|
+
private readonly httpClient;
|
|
824
|
+
private readonly appCode;
|
|
825
|
+
private readonly authMode;
|
|
826
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
827
|
+
/** 查询角色分页列表(`POST {prefix}/permit/role/get-list`) */
|
|
828
|
+
getRoleList<T = DataList<AppRoleVO>>(request?: AppRoleRequest): Promise<T>;
|
|
829
|
+
/** 创建自定义角色(`POST {prefix}/permit/role/create`) */
|
|
830
|
+
createRole(request: AppRoleCreateParam): Promise<AppRoleVO>;
|
|
831
|
+
/** 更新自定义角色(`POST {prefix}/permit/role/update`) */
|
|
832
|
+
updateRole(request: AppRoleUpdateParam): Promise<AppRoleVO>;
|
|
833
|
+
/** 删除自定义角色(`POST {prefix}/permit/role/delete`) */
|
|
834
|
+
deleteRole(roleId: number): Promise<void>;
|
|
835
|
+
/** 查询权限场景下的角色列表(`POST {prefix}/permit/role/get-permit-list`) */
|
|
836
|
+
getRolePermitList<T = BaseRoleVO[]>(request?: AppRolePermitQueryParam): Promise<T>;
|
|
837
|
+
/** 查询角色成员(`POST {prefix}/permit/user-role/get-user-list`) */
|
|
838
|
+
getRoleUserList<T = AppRoleUserVO[]>(request?: UserAppRelationQueryParam): Promise<T>;
|
|
839
|
+
/** 更新角色成员(`POST {prefix}/permit/user-role/update-user-list`) */
|
|
840
|
+
updateRoleUserList(request: RoleUserUpdateParam): Promise<void>;
|
|
841
|
+
/** 查询应用成员(`GET {prefix}/dept/queryAppUser`) */
|
|
842
|
+
queryAppUsers(): Promise<AppEmployee[]>;
|
|
843
|
+
/** 查询页面权限(`GET {prefix}/permit/page/get-one`) */
|
|
844
|
+
getPagePermit<T = MenuPermitDTO>(menuId: number): Promise<T>;
|
|
845
|
+
/** 保存页面权限(`POST {prefix}/permit/page/save`) */
|
|
846
|
+
savePagePermit(request: MenuPermitDTO): Promise<MenuPermitDTO>;
|
|
847
|
+
/** 查询资源菜单权限(`POST {prefix}/permit/resource/get-menu-list`) */
|
|
848
|
+
getResourceMenuList<T = AppMenuPermitVO[]>(request?: AppResourceMenuParam): Promise<T>;
|
|
849
|
+
/** 批量保存菜单权限(`POST {prefix}/permit/resource/batch-save-menu`) */
|
|
850
|
+
saveMenuPermits(request: ResourcePermitParam): Promise<void>;
|
|
851
|
+
/** 批量保存数据集权限(`POST {prefix}/permit/resource/batch-save-dataset`) */
|
|
852
|
+
saveDatasetPermits(request: ResourcePermitParam): Promise<void>;
|
|
853
|
+
/** 查询数据集权限列表(`GET {prefix}/permit/dataset/list`) */
|
|
854
|
+
getDatasetPermitList<T = DatasetPermitListVO>(roleId: number): Promise<T>;
|
|
855
|
+
/** 查询数据集权限元信息(`GET {prefix}/permit/dataset/permit-list`) */
|
|
856
|
+
getDatasetPermitMeta<T = DatasetRolePermitListVO>(): Promise<T>;
|
|
857
|
+
/** 查询菜单角色权限列表(`GET {prefix}/menu/permit-list`) */
|
|
858
|
+
getMenuPermitList<T = MenuRolePermitListVO>(): Promise<T>;
|
|
859
|
+
/**
|
|
860
|
+
* 查询当前用户的运行态应用权限(`POST /client/permit/identity/resolve`)。
|
|
861
|
+
*
|
|
862
|
+
* 后端仅在 `/client` 注册该接口,cookie 模式下会 fail-closed。
|
|
863
|
+
*/
|
|
864
|
+
resolveIdentity(): Promise<RuntimeIdentityPermission>;
|
|
865
|
+
/**
|
|
866
|
+
* 应用邀请审批回调(`POST /api/user/app-invite-callback` 或 `/client/user/app-invite-callback`)。
|
|
867
|
+
*/
|
|
868
|
+
appInviteCallback(request?: UserAppRelation): Promise<boolean>;
|
|
869
|
+
private path;
|
|
870
|
+
/** 后端多数参数要求显式 appCode;调用方可以覆盖。 */
|
|
871
|
+
private withAppCode;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* BFF 客户端请求参数
|
|
876
|
+
*/
|
|
877
|
+
interface ClientAkBffExecuteRequest {
|
|
878
|
+
/** 脚本名称(endpoint 函数名) */
|
|
879
|
+
scriptName: string;
|
|
880
|
+
/** 请求体参数(可选),序列化为 JSON 作为 POST body */
|
|
881
|
+
params?: Record<string, any>;
|
|
882
|
+
/** Fetch 请求选项(可选) */
|
|
883
|
+
options?: RequestInit;
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* 脚本端点摘要(后端 `EndpointScriptSummaryDTO`)
|
|
887
|
+
*/
|
|
888
|
+
interface EndpointScriptSummary {
|
|
889
|
+
id?: number;
|
|
890
|
+
appCode?: string;
|
|
891
|
+
functionName?: string;
|
|
892
|
+
description?: string;
|
|
893
|
+
version?: number;
|
|
894
|
+
gmtModified?: number;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* 脚本详情(后端 `ScriptDefinitionDTO`)
|
|
898
|
+
*/
|
|
899
|
+
interface ScriptDefinition {
|
|
900
|
+
id?: number;
|
|
901
|
+
appCode?: string;
|
|
902
|
+
functionName?: string;
|
|
903
|
+
functionNode?: string;
|
|
904
|
+
scriptType?: string;
|
|
905
|
+
description?: string;
|
|
906
|
+
scriptContent?: string;
|
|
907
|
+
dependencyRefs?: string;
|
|
908
|
+
enableTransaction?: boolean;
|
|
909
|
+
apiPattern?: string;
|
|
910
|
+
operationType?: string;
|
|
911
|
+
version?: number;
|
|
912
|
+
[key: string]: unknown;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Client AK BFF 客户端 ——「执行 BFF 独立端点」(client-ak 模式)。
|
|
916
|
+
*
|
|
917
|
+
* **与自定义 SQL 无关**(SQL 见 `ClientAkSqlClient` / `client.sql.execute` → `POST /client/sql/execute`)。
|
|
918
|
+
*
|
|
919
|
+
* 与服务端约定一致(路径中拼写为 **excute**,非 execute):
|
|
920
|
+
* `POST /client/bff/excute/{appCode}/{scriptName}`
|
|
921
|
+
* - Header:`X-User-AK`、`Content-Type: application/json`(由 HttpClient 注入)
|
|
922
|
+
* - Body:业务 JSON,例如 `{ "testCase": "basic_insert" }` → 对应本类 `params`
|
|
923
|
+
*
|
|
924
|
+
* 示例:`appCode=app-cf50ad43`,`scriptName=sqlTest` →
|
|
925
|
+
* `POST .../client/bff/excute/app-cf50ad43/sqlTest`,body `{ "testCase": "basic_insert" }`。
|
|
926
|
+
*/
|
|
927
|
+
declare class ClientAkBffClient {
|
|
928
|
+
private httpClient;
|
|
929
|
+
private appCode;
|
|
930
|
+
constructor(httpClient: HttpClient, appCode: string);
|
|
931
|
+
execute<T = any>(request: ClientAkBffExecuteRequest): Promise<T>;
|
|
932
|
+
/**
|
|
933
|
+
* 按函数名查询独立端点脚本摘要(`GET /client/bff/endpoint/{appCode}/{functionName}`)。
|
|
934
|
+
*
|
|
935
|
+
* 脚本不存在或为 personalOnly 时后端返回 `null`,SDK 原样透传。
|
|
936
|
+
*/
|
|
937
|
+
getEndpoint(functionName: string): Promise<EndpointScriptSummary | null>;
|
|
938
|
+
/**
|
|
939
|
+
* 查询当前应用下全部独立端点脚本(`GET /client/bff/endpoint/{appCode}/functions`)。
|
|
940
|
+
*/
|
|
941
|
+
listEndpoints(): Promise<EndpointScriptSummary[]>;
|
|
942
|
+
/**
|
|
943
|
+
* 按脚本主键查询脚本详情(`GET /client/bff/query/{scriptId}`)。
|
|
944
|
+
*
|
|
945
|
+
* personalOnly 脚本仅创建者本人可读,其他用户会被后端拒绝。
|
|
946
|
+
*/
|
|
947
|
+
getScript<T = ScriptDefinition>(scriptId: number): Promise<T>;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* BFF 客户端请求参数
|
|
952
|
+
*/
|
|
953
|
+
interface BffExecuteRequest {
|
|
954
|
+
/** 脚本名称(endpoint 函数名) */
|
|
955
|
+
scriptName: string;
|
|
956
|
+
/** 请求体参数(可选) */
|
|
957
|
+
params?: Record<string, any>;
|
|
958
|
+
/** Fetch 请求选项(可选) */
|
|
959
|
+
options?: RequestInit;
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* BFF 客户端 - 调用 Backend For Frontend 端点
|
|
963
|
+
*
|
|
964
|
+
* 与其他 SDK 接口保持一致的响应处理逻辑:
|
|
965
|
+
* - 成功:返回 data(业务数据)
|
|
966
|
+
* - 失败:抛出 LovrabetError 异常(由 processResponse 处理)
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```typescript
|
|
970
|
+
* // 无参数调用
|
|
971
|
+
* const templates = await client.bff.execute({
|
|
972
|
+
* scriptName: 'getBundleTemplates'
|
|
973
|
+
* });
|
|
974
|
+
* templates.forEach(template => console.log(template.name));
|
|
975
|
+
*
|
|
976
|
+
* // 带参数调用
|
|
977
|
+
* const price = await client.bff.execute({
|
|
978
|
+
* scriptName: 'calculatePrice',
|
|
979
|
+
* params: { productId: '123', quantity: 10 }
|
|
980
|
+
* });
|
|
981
|
+
* console.log('Price:', price);
|
|
982
|
+
*
|
|
983
|
+
* // 带 Fetch 选项
|
|
984
|
+
* const result = await client.bff.execute({
|
|
985
|
+
* scriptName: 'getData',
|
|
986
|
+
* params: { id: '123' },
|
|
987
|
+
* options: { headers: { 'X-Custom-Header': 'value' } }
|
|
988
|
+
* });
|
|
989
|
+
*
|
|
990
|
+
* // 带类型提示
|
|
991
|
+
* interface BundleTemplate {
|
|
992
|
+
* id: string;
|
|
993
|
+
* name: string;
|
|
994
|
+
* items: string[];
|
|
995
|
+
* }
|
|
996
|
+
* const templates = await client.bff.execute<BundleTemplate>({
|
|
997
|
+
* scriptName: 'getBundleTemplates'
|
|
998
|
+
* });
|
|
999
|
+
* ```
|
|
1000
|
+
*/
|
|
1001
|
+
declare class BffClient {
|
|
1002
|
+
private httpClient;
|
|
1003
|
+
private appCode;
|
|
1004
|
+
constructor(httpClient: HttpClient, appCode: string);
|
|
1005
|
+
/**
|
|
1006
|
+
* 调用 Backend For Frontend (BFF) 端点
|
|
1007
|
+
*
|
|
1008
|
+
* @param request 请求参数
|
|
1009
|
+
* @returns BFF 函数返回的业务数据
|
|
1010
|
+
* @throws {LovrabetError} 当 HTTP 请求失败时抛出异常
|
|
1011
|
+
*/
|
|
1012
|
+
execute<T = any>(request: BffExecuteRequest): Promise<T>;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Client AK SQL 客户端 - 执行自定义 SQL 查询(client-ak 模式)
|
|
1017
|
+
*
|
|
1018
|
+
* 端点:`POST /client/sql/execute`,请求体:`{ sqlCode, params? }`(与运行态技术文档 curl 一致)。
|
|
1019
|
+
* 鉴权:X-User-AK(由 HttpClient 通过 AuthManager 自动注入)。
|
|
1020
|
+
*
|
|
1021
|
+
* BFF 调用请使用 `ClientAkBffClient`,勿与本类混用。
|
|
1022
|
+
*/
|
|
1023
|
+
declare class ClientAkSqlClient {
|
|
1024
|
+
private httpClient;
|
|
1025
|
+
private appCode?;
|
|
1026
|
+
constructor(httpClient: HttpClient, appCode?: string);
|
|
1027
|
+
execute<T = Record<string, any>>(sqlCode: string | number, params?: Record<string, string | number>): Promise<SqlExecuteResult<T>>;
|
|
1028
|
+
execute<T = Record<string, any>>(options: {
|
|
1029
|
+
sqlCode: string | number;
|
|
1030
|
+
params?: Record<string, string | number>;
|
|
1031
|
+
}): Promise<SqlExecuteResult<T>>;
|
|
1032
|
+
/**
|
|
1033
|
+
* 分页查询自定义 SQL 元信息(`POST /client/sql/query`)。
|
|
1034
|
+
*
|
|
1035
|
+
* 与 `execute` 不同:这里只查询 SQL 定义列表,不执行 SQL。
|
|
1036
|
+
*/
|
|
1037
|
+
query(request?: CustomSqlQueryRequest): Promise<DataList<UserCustomSqlDTO>>;
|
|
1038
|
+
/**
|
|
1039
|
+
* 查询当前应用下全部自定义 SQL(`GET /client/sql/list/{appCode}`)。
|
|
1040
|
+
*
|
|
1041
|
+
* 与 `query` 不同:该接口不分页、不接收筛选条件,返回完整列表。
|
|
1042
|
+
*/
|
|
1043
|
+
listSqls(): Promise<UserCustomSqlDTO[]>;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* OpenAPI SQL 客户端 - 执行自定义 SQL 查询(OpenAPI 模式)
|
|
1048
|
+
*
|
|
1049
|
+
* OpenAPI 模式的参数格式:
|
|
1050
|
+
* - Body: { sqlCode, paramMap }
|
|
1051
|
+
* - Headers: X-App-Code, X-Dataset-Code, X-Token, X-Time-Stamp(由 HttpClient 自动添加)
|
|
1052
|
+
*
|
|
1053
|
+
* 注意:
|
|
1054
|
+
* - custom-sql 业务上不绑定特定数据集(可能跨多个数据集)
|
|
1055
|
+
* - 但 OpenAPI 认证需要 datasetCode 来生成 token
|
|
1056
|
+
* - 解决方案:自动使用配置的第一个数据集的 datasetCode
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```typescript
|
|
1060
|
+
* // 推荐:对象参数
|
|
1061
|
+
* const data = await client.sql.execute({
|
|
1062
|
+
* sqlCode: '8cbdd953-8d5fa8e5',
|
|
1063
|
+
* params: { storeId: 1 }
|
|
1064
|
+
* });
|
|
1065
|
+
*
|
|
1066
|
+
* // 兼容:直接传参
|
|
1067
|
+
* const data = await client.sql.execute('8cbdd953-8d5fa8e5', { storeId: 1 });
|
|
1068
|
+
*
|
|
1069
|
+
* // 带类型提示
|
|
1070
|
+
* interface OrderStat {
|
|
1071
|
+
* driver_name: string;
|
|
1072
|
+
* total_completed: number;
|
|
1073
|
+
* total_payment: number;
|
|
1074
|
+
* }
|
|
1075
|
+
* const data = await client.sql.execute<OrderStat>({
|
|
1076
|
+
* sqlCode: '8cbdd953-8d5fa8e5',
|
|
1077
|
+
* params: { storeId: 1 }
|
|
1078
|
+
* });
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
declare class OpenApiSqlClient {
|
|
1082
|
+
private httpClient;
|
|
1083
|
+
private config;
|
|
1084
|
+
constructor(httpClient: HttpClient, config: ClientConfig);
|
|
1085
|
+
/**
|
|
1086
|
+
* 自动获取第一个数据集的 datasetCode
|
|
1087
|
+
* 用于 OpenAPI token 生成(业务上 custom-sql 不绑定数据集,但 token 计算需要)
|
|
1088
|
+
*/
|
|
1089
|
+
private getFirstDatasetCode;
|
|
1090
|
+
/**
|
|
1091
|
+
* 执行自定义 SQL 查询
|
|
1092
|
+
*
|
|
1093
|
+
* 支持两种调用方式:
|
|
1094
|
+
* 1. execute({ sqlCode, params }) - 对象参数(推荐)
|
|
1095
|
+
* 2. execute(sqlCode, params) - 直接传参(兼容)
|
|
1096
|
+
*
|
|
1097
|
+
* @returns SQL执行结果(包含 execSuccess 和 execResult)
|
|
1098
|
+
*/
|
|
1099
|
+
execute<T = Record<string, any>>(sqlCode: string | number, params?: Record<string, string | number>): Promise<SqlExecuteResult<T>>;
|
|
1100
|
+
execute<T = Record<string, any>>(options: {
|
|
1101
|
+
sqlCode: string | number;
|
|
1102
|
+
params?: Record<string, string | number>;
|
|
1103
|
+
}): Promise<SqlExecuteResult<T>>;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* SQL 客户端 - 执行自定义 SQL 查询(WebAPI 模式)
|
|
1108
|
+
*
|
|
1109
|
+
* WebAPI 模式的参数格式:
|
|
1110
|
+
* - Body: { sqlCode, params }
|
|
1111
|
+
* - 使用 Cookie 认证
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```typescript
|
|
1115
|
+
* // 推荐:对象参数
|
|
1116
|
+
* const data = await client.sql.execute({
|
|
1117
|
+
* sqlCode: 'fc8e7777-06e3847d',
|
|
1118
|
+
* params: { userId: '123', startDate: '2025-01-01' }
|
|
1119
|
+
* });
|
|
1120
|
+
*
|
|
1121
|
+
* // 兼容:直接传参
|
|
1122
|
+
* const data = await client.sql.execute('fc8e7777-06e3847d', {
|
|
1123
|
+
* userId: '123',
|
|
1124
|
+
* startDate: '2025-01-01'
|
|
1125
|
+
* });
|
|
1126
|
+
*
|
|
1127
|
+
* // 带类型提示
|
|
1128
|
+
* interface PageStat {
|
|
1129
|
+
* creation_date: string;
|
|
1130
|
+
* page_count: number;
|
|
1131
|
+
* }
|
|
1132
|
+
* const data = await client.sql.execute<PageStat>({
|
|
1133
|
+
* sqlCode: 'fc8e7777-06e3847d'
|
|
1134
|
+
* });
|
|
1135
|
+
* ```
|
|
1136
|
+
*/
|
|
1137
|
+
declare class SqlClient {
|
|
1138
|
+
private httpClient;
|
|
1139
|
+
constructor(httpClient: HttpClient);
|
|
1140
|
+
/**
|
|
1141
|
+
* 执行自定义 SQL 查询
|
|
1142
|
+
*
|
|
1143
|
+
* 支持两种调用方式:
|
|
1144
|
+
* 1. execute({ sqlCode, params }) - 对象参数(推荐)
|
|
1145
|
+
* 2. execute(sqlCode, params) - 直接传参(兼容)
|
|
1146
|
+
*
|
|
1147
|
+
* @returns SQL执行结果(包含 execSuccess 和 execResult)
|
|
1148
|
+
*/
|
|
1149
|
+
execute<T = Record<string, any>>(sqlCode: string | number, params?: Record<string, string | number>): Promise<SqlExecuteResult<T>>;
|
|
1150
|
+
execute<T = Record<string, any>>(options: {
|
|
1151
|
+
sqlCode: string | number;
|
|
1152
|
+
params?: Record<string, string | number>;
|
|
1153
|
+
}): Promise<SqlExecuteResult<T>>;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/** Per-request options supported by personal resource clients. */
|
|
1157
|
+
type PersonalRequestOptions = Omit<RequestInit, "method" | "body">;
|
|
1158
|
+
/** Input accepted when executing a personal BFF. */
|
|
1159
|
+
interface PersonalBffExecuteRequest {
|
|
1160
|
+
/** Positive integer identifier of the personal BFF script. */
|
|
1161
|
+
scriptId: number;
|
|
1162
|
+
/** Parameters passed to the personal BFF script. */
|
|
1163
|
+
params?: Record<string, unknown>;
|
|
1164
|
+
/** Optional fetch settings. The HTTP method and body are controlled by the SDK. */
|
|
1165
|
+
options?: PersonalRequestOptions;
|
|
1166
|
+
}
|
|
1167
|
+
/** Input accepted when creating or updating a personal BFF. */
|
|
1168
|
+
interface PersonalBffUpsertRequest {
|
|
1169
|
+
/** Function name exposed by the personal BFF. */
|
|
1170
|
+
functionName?: string;
|
|
1171
|
+
/** Human readable description. */
|
|
1172
|
+
description?: string;
|
|
1173
|
+
/** Script content. */
|
|
1174
|
+
scriptContent?: string;
|
|
1175
|
+
/** Session that produced the script, used for traceability. */
|
|
1176
|
+
sourceSessionId?: string;
|
|
1177
|
+
}
|
|
1178
|
+
/** Personal BFF metadata (backend `AppScriptDTO`, only common fields). */
|
|
1179
|
+
interface PersonalBffScript {
|
|
1180
|
+
id?: number;
|
|
1181
|
+
appCode?: string;
|
|
1182
|
+
scriptType?: string;
|
|
1183
|
+
scriptContent?: string;
|
|
1184
|
+
dependencyRefs?: unknown;
|
|
1185
|
+
description?: string;
|
|
1186
|
+
functionName?: string;
|
|
1187
|
+
functionNode?: unknown;
|
|
1188
|
+
version?: number;
|
|
1189
|
+
enableTransaction?: boolean;
|
|
1190
|
+
config?: Record<string, unknown>;
|
|
1191
|
+
createUserId?: string;
|
|
1192
|
+
updateUserId?: string;
|
|
1193
|
+
gmtCreate?: string;
|
|
1194
|
+
gmtModified?: string;
|
|
1195
|
+
[key: string]: unknown;
|
|
1196
|
+
}
|
|
1197
|
+
interface PersonalBffService {
|
|
1198
|
+
execute<T = unknown>(request: PersonalBffExecuteRequest): Promise<T>;
|
|
1199
|
+
list(): Promise<PersonalBffScript[]>;
|
|
1200
|
+
get<T = PersonalBffScript>(scriptId: number): Promise<T>;
|
|
1201
|
+
create<T = PersonalBffScript>(request: PersonalBffUpsertRequest): Promise<T>;
|
|
1202
|
+
update<T = PersonalBffScript>(scriptId: number, request: PersonalBffUpsertRequest): Promise<T>;
|
|
1203
|
+
}
|
|
1204
|
+
/** Personal resources exposed under `client.personal`. */
|
|
1205
|
+
interface LovrabetPersonal {
|
|
1206
|
+
readonly bff: PersonalBffService;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
type FlowRecord = Record<string, any>;
|
|
1210
|
+
/** SDK 可见的独立流程定义;服务端只返回业务自定义页面类型。 */
|
|
1211
|
+
interface FlowCustomPageDefinition {
|
|
1212
|
+
flowCode: string;
|
|
1213
|
+
flowName?: string;
|
|
1214
|
+
flowDesc?: string;
|
|
1215
|
+
version?: number;
|
|
1216
|
+
pageMode: "CUSTOM_PAGE";
|
|
1217
|
+
}
|
|
1218
|
+
/** 业务自定义页面独立流程的发起结果。 */
|
|
1219
|
+
interface FlowCustomPageStartResponse {
|
|
1220
|
+
flowCode: string;
|
|
1221
|
+
processInstanceId: string;
|
|
1222
|
+
idempotentReplay?: boolean;
|
|
1223
|
+
}
|
|
1224
|
+
/** 业务自定义页面独立流程的待办或已办列表项。 */
|
|
1225
|
+
interface FlowCustomPageTaskItem {
|
|
1226
|
+
taskId: string;
|
|
1227
|
+
taskName?: string;
|
|
1228
|
+
taskDefinitionKey?: string;
|
|
1229
|
+
taskMode?: string;
|
|
1230
|
+
assignee?: string;
|
|
1231
|
+
assigneeName?: string;
|
|
1232
|
+
handleMode?: string;
|
|
1233
|
+
transferCandidates?: FlowRecord[];
|
|
1234
|
+
processInstanceId: string;
|
|
1235
|
+
flowCode?: string;
|
|
1236
|
+
flowName?: string;
|
|
1237
|
+
initiatorUserId?: string;
|
|
1238
|
+
initiatorUsername?: string;
|
|
1239
|
+
taskStatus?: string;
|
|
1240
|
+
processStatus?: string;
|
|
1241
|
+
createTime?: number;
|
|
1242
|
+
endTime?: number;
|
|
1243
|
+
processStartTime?: number;
|
|
1244
|
+
businessVariables?: FlowRecord;
|
|
1245
|
+
}
|
|
1246
|
+
/** 业务自定义页面独立流程的已发起列表项。 */
|
|
1247
|
+
interface FlowCustomPageSubmittedProcess {
|
|
1248
|
+
processInstanceId: string;
|
|
1249
|
+
flowCode?: string;
|
|
1250
|
+
flowName?: string;
|
|
1251
|
+
startTime?: number;
|
|
1252
|
+
endTime?: number;
|
|
1253
|
+
status?: string;
|
|
1254
|
+
cancelReason?: string;
|
|
1255
|
+
currentNodeNames?: string[];
|
|
1256
|
+
currentNodes?: FlowRecord[];
|
|
1257
|
+
nextNodes?: FlowRecord[];
|
|
1258
|
+
businessVariables?: FlowRecord;
|
|
1259
|
+
}
|
|
1260
|
+
/** 不包含数据集、平台页面或业务数据主键的独立流程轨迹。 */
|
|
1261
|
+
interface FlowCustomPageTimeline {
|
|
1262
|
+
processInstanceId: string;
|
|
1263
|
+
flowCode?: string;
|
|
1264
|
+
flowName?: string;
|
|
1265
|
+
startUserId?: string;
|
|
1266
|
+
startUserName?: string;
|
|
1267
|
+
startTime?: number;
|
|
1268
|
+
endTime?: number;
|
|
1269
|
+
status?: string;
|
|
1270
|
+
cancelReason?: string;
|
|
1271
|
+
canCancel: boolean;
|
|
1272
|
+
canWithdraw: boolean;
|
|
1273
|
+
canResubmit: boolean;
|
|
1274
|
+
canVoid: boolean;
|
|
1275
|
+
approvalRound?: number;
|
|
1276
|
+
steps?: FlowRecord[];
|
|
1277
|
+
flowDiagram?: FlowRecord;
|
|
1278
|
+
}
|
|
1279
|
+
/** 业务自定义页面独立流程详情;保留 formData,不返回平台表单渲染配置。 */
|
|
1280
|
+
interface FlowCustomPageTaskDetail {
|
|
1281
|
+
taskId?: string;
|
|
1282
|
+
taskName?: string;
|
|
1283
|
+
taskDefinitionKey?: string;
|
|
1284
|
+
taskMode?: string;
|
|
1285
|
+
assignee?: string;
|
|
1286
|
+
assigneeName?: string;
|
|
1287
|
+
processInstanceId: string;
|
|
1288
|
+
flowCode?: string;
|
|
1289
|
+
flowName?: string;
|
|
1290
|
+
initiatorUserId?: string;
|
|
1291
|
+
initiatorUsername?: string;
|
|
1292
|
+
taskCreateTime?: number;
|
|
1293
|
+
taskEndTime?: number;
|
|
1294
|
+
processStartTime?: number;
|
|
1295
|
+
processEndTime?: number;
|
|
1296
|
+
taskStatus?: string;
|
|
1297
|
+
processStatus?: string;
|
|
1298
|
+
canHandle: boolean;
|
|
1299
|
+
handleMode?: string;
|
|
1300
|
+
canCancel: boolean;
|
|
1301
|
+
canWithdraw: boolean;
|
|
1302
|
+
canResubmit: boolean;
|
|
1303
|
+
canVoid: boolean;
|
|
1304
|
+
canReturn: boolean;
|
|
1305
|
+
returnTargets?: FlowReturnTarget[];
|
|
1306
|
+
approvalRound?: number;
|
|
1307
|
+
transferCandidates?: FlowRecord[];
|
|
1308
|
+
formData?: FlowRecord;
|
|
1309
|
+
businessVariables?: FlowRecord;
|
|
1310
|
+
timeline?: FlowCustomPageTimeline;
|
|
1311
|
+
}
|
|
1312
|
+
interface FlowCustomPageCcDetail {
|
|
1313
|
+
ccRecord: FlowRecord;
|
|
1314
|
+
processDetail: FlowCustomPageTaskDetail;
|
|
1315
|
+
approvalRecords: FlowRecord;
|
|
1316
|
+
}
|
|
1317
|
+
interface FlowPage<T = FlowRecord> {
|
|
1318
|
+
records: T[];
|
|
1319
|
+
currentPage: number;
|
|
1320
|
+
pageSize: number;
|
|
1321
|
+
totalCount: number;
|
|
1322
|
+
totalPages: number;
|
|
1323
|
+
}
|
|
1324
|
+
interface FlowPageQuery {
|
|
1325
|
+
currentPage?: number;
|
|
1326
|
+
pageSize?: number;
|
|
1327
|
+
}
|
|
1328
|
+
interface FlowVariableProjectionQuery extends FlowPageQuery {
|
|
1329
|
+
/** 指定响应 businessVariables 中需要返回的普通业务变量名。 */
|
|
1330
|
+
variableKeys?: string[];
|
|
1331
|
+
}
|
|
1332
|
+
interface FlowVariableQuery extends FlowVariableProjectionQuery {
|
|
1333
|
+
/** 按流程变量精确匹配;服务端会屏蔽 sys 前缀变量。 */
|
|
1334
|
+
variables?: FlowRecord;
|
|
1335
|
+
}
|
|
1336
|
+
interface FlowSubmittedQuery extends FlowVariableProjectionQuery {
|
|
1337
|
+
status?: string;
|
|
1338
|
+
}
|
|
1339
|
+
interface FlowDefinitionQuery extends FlowPageQuery {
|
|
1340
|
+
flowName?: string;
|
|
1341
|
+
}
|
|
1342
|
+
interface FlowStartRequest {
|
|
1343
|
+
flowCode: string;
|
|
1344
|
+
formData?: FlowRecord;
|
|
1345
|
+
variables?: FlowRecord;
|
|
1346
|
+
/** 同一应用内相同幂等键返回首次创建的流程实例。 */
|
|
1347
|
+
idempotencyKey?: string;
|
|
1348
|
+
}
|
|
1349
|
+
interface FlowUpdateVariablesRequest {
|
|
1350
|
+
processInstanceId: string;
|
|
1351
|
+
/** 可设置普通业务变量,也可包含 formData;系统变量不可修改。 */
|
|
1352
|
+
set?: FlowRecord;
|
|
1353
|
+
/** 仅允许删除普通业务变量。 */
|
|
1354
|
+
remove?: string[];
|
|
1355
|
+
}
|
|
1356
|
+
interface FlowTaskActionRequest {
|
|
1357
|
+
taskId: string;
|
|
1358
|
+
formPatch?: FlowRecord;
|
|
1359
|
+
formDataVersion?: number;
|
|
1360
|
+
variables?: FlowRecord;
|
|
1361
|
+
comment?: string;
|
|
1362
|
+
}
|
|
1363
|
+
interface FlowBatchTaskActionRequest {
|
|
1364
|
+
taskIds: string[];
|
|
1365
|
+
comment?: string;
|
|
1366
|
+
variables?: FlowRecord;
|
|
1367
|
+
}
|
|
1368
|
+
interface FlowTransferRequest {
|
|
1369
|
+
taskId: string;
|
|
1370
|
+
targetUserId: string;
|
|
1371
|
+
comment?: string;
|
|
1372
|
+
}
|
|
1373
|
+
interface FlowBatchTransferRequest {
|
|
1374
|
+
taskIds: string[];
|
|
1375
|
+
targetUserId: string;
|
|
1376
|
+
comment?: string;
|
|
1377
|
+
}
|
|
1378
|
+
interface FlowProcessReasonRequest {
|
|
1379
|
+
processInstanceId: string;
|
|
1380
|
+
reason?: string;
|
|
1381
|
+
}
|
|
1382
|
+
interface FlowResubmitRequest {
|
|
1383
|
+
processInstanceId: string;
|
|
1384
|
+
formPatch?: FlowRecord;
|
|
1385
|
+
/** 重新提交时同步更新的普通业务流程变量;系统变量仍由 Runtime 拒绝。 */
|
|
1386
|
+
variables?: FlowRecord;
|
|
1387
|
+
/** 动态表单流程必填;非动态表单或没有版本号的自定义页面流程可省略。 */
|
|
1388
|
+
formDataVersion?: number;
|
|
1389
|
+
comment?: string;
|
|
1390
|
+
}
|
|
1391
|
+
interface FlowReturnRequest {
|
|
1392
|
+
taskId: string;
|
|
1393
|
+
targetNodeId: string;
|
|
1394
|
+
reason?: string;
|
|
1395
|
+
}
|
|
1396
|
+
interface FlowCcRequest {
|
|
1397
|
+
processInstanceId: string;
|
|
1398
|
+
taskId?: string;
|
|
1399
|
+
recipientUserIds: string[];
|
|
1400
|
+
comment?: string;
|
|
1401
|
+
/** 调用方幂等请求号。 */
|
|
1402
|
+
requestId?: string;
|
|
1403
|
+
}
|
|
1404
|
+
interface FlowCcQuery extends FlowPageQuery {
|
|
1405
|
+
readStatus?: string;
|
|
1406
|
+
}
|
|
1407
|
+
interface FlowReturnTarget {
|
|
1408
|
+
nodeId: string;
|
|
1409
|
+
nodeName: string;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/** 使用当前登录用户身份的独立流程自定义页面客户端。 */
|
|
1413
|
+
declare class LovrabetFlowClient {
|
|
1414
|
+
private readonly httpClient;
|
|
1415
|
+
private readonly appCode;
|
|
1416
|
+
constructor(httpClient: HttpClient, appCode: string);
|
|
1417
|
+
start<T = FlowCustomPageStartResponse>(request: FlowStartRequest): Promise<T>;
|
|
1418
|
+
listTodo<T = FlowCustomPageTaskItem>(query?: FlowVariableQuery): Promise<FlowPage<T>>;
|
|
1419
|
+
listAppTodo<T = FlowCustomPageTaskItem>(query?: FlowVariableQuery): Promise<FlowPage<T>>;
|
|
1420
|
+
listDone<T = FlowCustomPageTaskItem>(query?: FlowVariableQuery): Promise<FlowPage<T>>;
|
|
1421
|
+
listAppDone<T = FlowCustomPageTaskItem>(query?: FlowVariableQuery): Promise<FlowPage<T>>;
|
|
1422
|
+
listSubmitted<T = FlowCustomPageSubmittedProcess>(query?: FlowSubmittedQuery): Promise<FlowPage<T>>;
|
|
1423
|
+
listAppSubmitted<T = FlowCustomPageSubmittedProcess>(query?: FlowSubmittedQuery): Promise<FlowPage<T>>;
|
|
1424
|
+
/** 列出 SDK 可发起的独立流程;服务端仅返回 CUSTOM_PAGE。 */
|
|
1425
|
+
listIndependentFlows<T = FlowCustomPageDefinition>(query?: FlowDefinitionQuery): Promise<FlowPage<T>>;
|
|
1426
|
+
getTaskDetail<T = FlowCustomPageTaskDetail>(taskId: string, variableKeys?: string[]): Promise<T>;
|
|
1427
|
+
getProcessDetail<T = FlowCustomPageTaskDetail>(processInstanceId: string, variableKeys?: string[]): Promise<T>;
|
|
1428
|
+
getCurrentTask<T = FlowCustomPageTaskDetail>(processInstanceId: string, variableKeys?: string[]): Promise<T>;
|
|
1429
|
+
getTimeline<T = FlowCustomPageTimeline>(processInstanceId: string): Promise<T>;
|
|
1430
|
+
getRecords<T = FlowRecord>(processInstanceId: string): Promise<T>;
|
|
1431
|
+
updateVariables(request: FlowUpdateVariablesRequest): Promise<void>;
|
|
1432
|
+
approve(request: FlowTaskActionRequest): Promise<void>;
|
|
1433
|
+
reject(request: FlowTaskActionRequest): Promise<void>;
|
|
1434
|
+
complete(request: FlowTaskActionRequest): Promise<void>;
|
|
1435
|
+
batchApprove<T = FlowRecord>(request: FlowBatchTaskActionRequest): Promise<T>;
|
|
1436
|
+
batchReject<T = FlowRecord>(request: FlowBatchTaskActionRequest): Promise<T>;
|
|
1437
|
+
transfer(request: FlowTransferRequest): Promise<void>;
|
|
1438
|
+
batchTransfer<T = FlowRecord>(request: FlowBatchTransferRequest): Promise<T>;
|
|
1439
|
+
cancel(request: FlowProcessReasonRequest): Promise<void>;
|
|
1440
|
+
withdraw(request: FlowProcessReasonRequest): Promise<void>;
|
|
1441
|
+
resubmit(request: FlowResubmitRequest): Promise<void>;
|
|
1442
|
+
getReturnTargets(taskId: string): Promise<FlowReturnTarget[]>;
|
|
1443
|
+
returnTask(request: FlowReturnRequest): Promise<void>;
|
|
1444
|
+
voidProcess(request: FlowProcessReasonRequest): Promise<void>;
|
|
1445
|
+
ccProcess<T = FlowRecord>(request: FlowCcRequest): Promise<T[]>;
|
|
1446
|
+
listCc<T = FlowRecord>(query?: FlowCcQuery): Promise<FlowPage<T>>;
|
|
1447
|
+
getCcDetail<T = FlowCustomPageCcDetail>(ccRecordId: number | string): Promise<T>;
|
|
1448
|
+
markCcRead(ccRecordId: number | string): Promise<void>;
|
|
1449
|
+
private completeTask;
|
|
1450
|
+
private completeTasks;
|
|
1451
|
+
private processReason;
|
|
1452
|
+
private executePage;
|
|
1453
|
+
private executeCustomPage;
|
|
1454
|
+
private post;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
/** Per-request options supported by runtime service clients. */
|
|
1458
|
+
type ServiceRequestOptions = Omit<RequestInit, "method" | "body">;
|
|
1459
|
+
/**
|
|
1460
|
+
* OCR recognition types supported by the runtime service.
|
|
1461
|
+
*
|
|
1462
|
+
* This is a runtime value as well as the source of the `OcrType` type, so
|
|
1463
|
+
* JavaScript and TypeScript callers can both avoid handwritten strings.
|
|
1464
|
+
*/
|
|
1465
|
+
declare const OcrType: Readonly<{
|
|
1466
|
+
readonly General: "General";
|
|
1467
|
+
readonly Invoice: "Invoice";
|
|
1468
|
+
readonly Advanced: "Advanced";
|
|
1469
|
+
readonly AdvancedCoordinate: "AdvancedCoordinate";
|
|
1470
|
+
readonly AdvancedGeneral: "AdvancedGeneral";
|
|
1471
|
+
readonly IdCard: "IdCard";
|
|
1472
|
+
readonly BankCard: "BankCard";
|
|
1473
|
+
readonly BusinessLicense: "BusinessLicense";
|
|
1474
|
+
readonly DrivingLicense: "DrivingLicense";
|
|
1475
|
+
readonly CarNumber: "CarNumber";
|
|
1476
|
+
readonly Table: "Table";
|
|
1477
|
+
}>;
|
|
1478
|
+
type OcrType = (typeof OcrType)[keyof typeof OcrType];
|
|
1479
|
+
/** Read-only OCR type list for selects, discovery, and schema generation. */
|
|
1480
|
+
declare const OCR_TYPES: readonly OcrType[];
|
|
1481
|
+
/** Input accepted by the public OCR service. */
|
|
1482
|
+
interface OcrRecognizeRequest {
|
|
1483
|
+
/** Publicly accessible image or file URL. */
|
|
1484
|
+
url: string;
|
|
1485
|
+
/** Runtime OCR recognition type. */
|
|
1486
|
+
type: OcrType;
|
|
1487
|
+
/** Optional fetch settings. The HTTP method and body are controlled by the SDK. */
|
|
1488
|
+
options?: ServiceRequestOptions;
|
|
1489
|
+
}
|
|
1490
|
+
/** OCR result returned by both the WebAPI and Client API routes. */
|
|
1491
|
+
interface OcrRecognizeResponse {
|
|
1492
|
+
requestId?: string;
|
|
1493
|
+
type?: OcrType;
|
|
1494
|
+
text?: string;
|
|
1495
|
+
lines?: string[];
|
|
1496
|
+
kvData?: Record<string, string>;
|
|
1497
|
+
width?: number;
|
|
1498
|
+
height?: number;
|
|
1499
|
+
pageNo?: number | null;
|
|
1500
|
+
subImageCount?: number | null;
|
|
1501
|
+
algoVersion?: string | null;
|
|
1502
|
+
kvExcelUrl?: string | null;
|
|
1503
|
+
xmlResult?: string | null;
|
|
1504
|
+
rawData?: string | null;
|
|
1505
|
+
[key: string]: unknown;
|
|
1506
|
+
}
|
|
1507
|
+
interface OcrService {
|
|
1508
|
+
recognize(request: OcrRecognizeRequest): Promise<OcrRecognizeResponse>;
|
|
1509
|
+
}
|
|
1510
|
+
/** Input accepted by the runtime file upload service. */
|
|
1511
|
+
interface FileUploadRequest {
|
|
1512
|
+
/** Browser File or a standards-compatible Blob. */
|
|
1513
|
+
file: Blob;
|
|
1514
|
+
/** Optional filename for Blob inputs. File.name is used when available. */
|
|
1515
|
+
fileName?: string;
|
|
1516
|
+
options?: ServiceRequestOptions;
|
|
1517
|
+
}
|
|
1518
|
+
interface FileUploadResponse {
|
|
1519
|
+
fileName?: string | null;
|
|
1520
|
+
filePath?: string | null;
|
|
1521
|
+
fileUrl?: string | null;
|
|
1522
|
+
downloadFlag?: boolean;
|
|
1523
|
+
longTerm?: boolean;
|
|
1524
|
+
fileType?: string | null;
|
|
1525
|
+
size?: number | null;
|
|
1526
|
+
sourceDir?: string | null;
|
|
1527
|
+
[key: string]: unknown;
|
|
1528
|
+
}
|
|
1529
|
+
interface FileQueryUrlRequest {
|
|
1530
|
+
/** Durable filePath returned by upload. */
|
|
1531
|
+
filePath: string;
|
|
1532
|
+
/** Request a download URL instead of a preview URL. */
|
|
1533
|
+
download?: boolean;
|
|
1534
|
+
/** Request a long-term URL for URL-only content embedding. */
|
|
1535
|
+
longTerm?: boolean;
|
|
1536
|
+
options?: ServiceRequestOptions;
|
|
1537
|
+
}
|
|
1538
|
+
interface FileUrlResponse {
|
|
1539
|
+
fileName?: string | null;
|
|
1540
|
+
filePath?: string | null;
|
|
1541
|
+
fileUrl?: string | null;
|
|
1542
|
+
downloadFlag?: boolean;
|
|
1543
|
+
longTerm?: boolean;
|
|
1544
|
+
expiresInDays?: number | null;
|
|
1545
|
+
[key: string]: unknown;
|
|
1546
|
+
}
|
|
1547
|
+
interface FileService {
|
|
1548
|
+
upload(request: FileUploadRequest): Promise<FileUploadResponse>;
|
|
1549
|
+
queryUrl(request: FileQueryUrlRequest): Promise<FileUrlResponse>;
|
|
1550
|
+
}
|
|
1551
|
+
/** Runtime services exposed under `client.services`. */
|
|
1552
|
+
interface LovrabetServices {
|
|
1553
|
+
readonly ocr: OcrService;
|
|
1554
|
+
readonly file: FileService;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
interface OpenApiAuthContext {
|
|
1558
|
+
timestamp: number;
|
|
1559
|
+
token: string;
|
|
1560
|
+
headers: AuthHeaders;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
declare const GENERATED_REGION_API_ENDPOINTS: {
|
|
1564
|
+
readonly cn: {
|
|
1565
|
+
readonly production: "https://runtime.lovrabet.com";
|
|
1566
|
+
readonly online: "https://runtime.lovrabet.com";
|
|
1567
|
+
readonly development: "https://dev.lovrabet.com";
|
|
1568
|
+
readonly daily: "https://daily-runtime.lovrabet.com";
|
|
1569
|
+
};
|
|
1570
|
+
readonly id: {
|
|
1571
|
+
readonly production: "https://runtime.lovrabet.id";
|
|
1572
|
+
readonly online: "https://runtime.lovrabet.id";
|
|
1573
|
+
readonly development: "https://dev.lovrabet.id";
|
|
1574
|
+
};
|
|
1575
|
+
};
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* Lovrabet SDK 核心类型定义
|
|
1579
|
+
*
|
|
1580
|
+
* 本文件包含 SDK 的所有核心类型定义,包括:
|
|
1581
|
+
* - 环境配置类型
|
|
1582
|
+
* - 请求和响应类型
|
|
1583
|
+
* - 模型配置类型
|
|
1584
|
+
* - 客户端配置类型
|
|
1585
|
+
* - 认证相关类型
|
|
1586
|
+
*/
|
|
1587
|
+
/**
|
|
1588
|
+
* 环境类型定义
|
|
1589
|
+
* @description 支持的运行环境,用于区分不同的 API 端点
|
|
1590
|
+
* - production: 线上环境(推荐使用)
|
|
1591
|
+
* - online: 线上环境(向下兼容,等同于 production)
|
|
1592
|
+
* - daily: 日常/测试环境
|
|
1593
|
+
* - development: 本地开发环境
|
|
1594
|
+
*/
|
|
1595
|
+
type Environment$1 = "production" | "online" | "daily" | "development";
|
|
1596
|
+
/** Official Lovrabet Runtime region. Mainland China is the default. */
|
|
1597
|
+
type Region = keyof typeof GENERATED_REGION_API_ENDPOINTS;
|
|
1598
|
+
/**
|
|
1599
|
+
* 排序方向枚举
|
|
1600
|
+
* @description 定义数据排序的方向
|
|
1601
|
+
*/
|
|
1602
|
+
declare enum SortOrder {
|
|
1603
|
+
/** 升序 */
|
|
1604
|
+
ASC = "asc",
|
|
1605
|
+
/** 降序 */
|
|
1606
|
+
DESC = "desc"
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* 排序方向类型(同时支持枚举和字符串)
|
|
1610
|
+
* @description 支持使用 SortOrder.ASC/DESC 或直接使用 "asc"/"desc" 字符串
|
|
1611
|
+
*/
|
|
1612
|
+
type SortOrderValue = SortOrder | "asc" | "desc";
|
|
1613
|
+
/**
|
|
1614
|
+
* 排序配置类型
|
|
1615
|
+
* @description 定义排序规则的 key-value 格式,key 为字段名,value 为排序方向
|
|
1616
|
+
* @example
|
|
1617
|
+
* ```typescript
|
|
1618
|
+
* // 使用枚举
|
|
1619
|
+
* const sortList1: SortList = [
|
|
1620
|
+
* { "id": SortOrder.DESC },
|
|
1621
|
+
* { "name": SortOrder.ASC }
|
|
1622
|
+
* ];
|
|
1623
|
+
*
|
|
1624
|
+
* // 使用字符串(更简洁)
|
|
1625
|
+
* const sortList2: SortList = [
|
|
1626
|
+
* { "id": "desc" },
|
|
1627
|
+
* { "name": "asc" }
|
|
1628
|
+
* ];
|
|
1629
|
+
* ```
|
|
1630
|
+
*/
|
|
1631
|
+
type SortList = Record<string, SortOrderValue>[];
|
|
1632
|
+
/**
|
|
1633
|
+
* 列表查询参数接口
|
|
1634
|
+
* @description 用于分页查询的通用参数接口
|
|
1635
|
+
*/
|
|
1636
|
+
interface ListParams {
|
|
1637
|
+
/** 当前页码,从 1 开始 */
|
|
1638
|
+
currentPage?: number;
|
|
1639
|
+
/** 每页数量 */
|
|
1640
|
+
pageSize?: number;
|
|
1641
|
+
/** 其他查询参数,支持任意字段 */
|
|
1642
|
+
[key: string]: any;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* 分页信息(服务端原始格式)
|
|
1646
|
+
*/
|
|
1647
|
+
interface Paging {
|
|
1648
|
+
/** 当前页码 */
|
|
1649
|
+
currentPage: number;
|
|
1650
|
+
/** 总数量 */
|
|
1651
|
+
totalCount: number;
|
|
1652
|
+
/** 每页数量 */
|
|
1653
|
+
pageSize: number;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* 列表响应数据接口
|
|
1657
|
+
* @template T 数据项的类型
|
|
1658
|
+
* @description 与服务端 data 结构完全对应
|
|
1659
|
+
*
|
|
1660
|
+
* 读取总数/当前页/页大小使用 paging:
|
|
1661
|
+
* - result.paging.totalCount
|
|
1662
|
+
* - result.paging.currentPage
|
|
1663
|
+
* - result.paging.pageSize
|
|
1664
|
+
*/
|
|
1665
|
+
interface ListResponse<T> {
|
|
1666
|
+
/** 数据列表 */
|
|
1667
|
+
tableData: T[];
|
|
1668
|
+
/** 分页信息 */
|
|
1669
|
+
paging: Paging;
|
|
1670
|
+
/** 列定义 */
|
|
1671
|
+
tableColumns: any[];
|
|
1672
|
+
/** 执行结果(一般为 null) */
|
|
1673
|
+
execResult?: any;
|
|
1674
|
+
/** 扩展信息(creator / modifier 等) */
|
|
1675
|
+
extend?: Record<string, any>;
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* 条件操作符类型
|
|
1679
|
+
* @description 用于构建查询条件的操作符
|
|
1680
|
+
*
|
|
1681
|
+
* 支持的操作符:
|
|
1682
|
+
* - $eq: 等于
|
|
1683
|
+
* - $ne: 不等于
|
|
1684
|
+
* - $gt: 大于
|
|
1685
|
+
* - $lt: 小于
|
|
1686
|
+
* - $gte: 大于等于(推荐);$gteq 为兼容旧写法的别名,后端同样映射为 >=
|
|
1687
|
+
* - $lte: 小于等于(推荐);$lteq 为兼容旧写法的别名,后端同样映射为 <=
|
|
1688
|
+
* - $in: 在集合内
|
|
1689
|
+
* - $contain: 包含(模糊匹配)
|
|
1690
|
+
* - $startWith: 以...开头
|
|
1691
|
+
* - $endWith: 以...结尾
|
|
1692
|
+
* - $notNull: 非空判断
|
|
1693
|
+
*/
|
|
1694
|
+
type ConditionOperator = "$eq" | "$ne" | "$gt" | "$lt" | "$gte" | "$gteq" | "$lte" | "$lteq" | "$in" | "$contain" | "$startWith" | "$endWith" | "$notNull";
|
|
1695
|
+
/**
|
|
1696
|
+
* 字段条件类型
|
|
1697
|
+
* @description 单个字段的查询条件
|
|
1698
|
+
* @example
|
|
1699
|
+
* ```typescript
|
|
1700
|
+
* // 等于
|
|
1701
|
+
* { age: { $eq: 18 } }
|
|
1702
|
+
* // 区间
|
|
1703
|
+
* { age: { $gte: 18, $lte: 45 } }
|
|
1704
|
+
* // 包含
|
|
1705
|
+
* { country: { $in: ['中国', '美国', '日本'] } }
|
|
1706
|
+
* // 模糊匹配
|
|
1707
|
+
* { name: { $contain: 'hello' } }
|
|
1708
|
+
* // 非空判断
|
|
1709
|
+
* { app_code: { $notNull: true } }
|
|
1710
|
+
* ```
|
|
1711
|
+
*/
|
|
1712
|
+
type FieldCondition = {
|
|
1713
|
+
[K in ConditionOperator]?: any;
|
|
1714
|
+
};
|
|
1715
|
+
/**
|
|
1716
|
+
* Where 条件类型
|
|
1717
|
+
* @description 支持字段条件和逻辑连接符的递归定义
|
|
1718
|
+
*/
|
|
1719
|
+
type WhereCondition = {
|
|
1720
|
+
$and?: WhereCondition[];
|
|
1721
|
+
$or?: WhereCondition[];
|
|
1722
|
+
[field: string]: FieldCondition | WhereCondition[] | any;
|
|
1723
|
+
};
|
|
1724
|
+
/**
|
|
1725
|
+
* Filter 参数接口
|
|
1726
|
+
* @description 用于 filter 方法的查询参数
|
|
1727
|
+
* @example
|
|
1728
|
+
* ```typescript
|
|
1729
|
+
* // 使用枚举
|
|
1730
|
+
* const filterParams1: FilterParams = {
|
|
1731
|
+
* where: {
|
|
1732
|
+
* $and: [
|
|
1733
|
+
* { age: { $gte: 18, $lte: 45 } },
|
|
1734
|
+
* { country: { $in: ['中国', '美国', '日本'] } }
|
|
1735
|
+
* ]
|
|
1736
|
+
* },
|
|
1737
|
+
* select: ['id', 'name', 'age', 'country'],
|
|
1738
|
+
* orderBy: [
|
|
1739
|
+
* { lastLoginAt: SortOrder.DESC },
|
|
1740
|
+
* { name: SortOrder.ASC }
|
|
1741
|
+
* ],
|
|
1742
|
+
* currentPage: 1,
|
|
1743
|
+
* pageSize: 20
|
|
1744
|
+
* };
|
|
1745
|
+
*
|
|
1746
|
+
* // 或使用字符串(更简洁)
|
|
1747
|
+
* const filterParams2: FilterParams = {
|
|
1748
|
+
* orderBy: [
|
|
1749
|
+
* { lastLoginAt: "desc" },
|
|
1750
|
+
* { name: "asc" }
|
|
1751
|
+
* ]
|
|
1752
|
+
* };
|
|
1753
|
+
* ```
|
|
1754
|
+
*/
|
|
1755
|
+
interface FilterParams {
|
|
1756
|
+
/** Where 条件 */
|
|
1757
|
+
where?: WhereCondition;
|
|
1758
|
+
/** 选择返回的字段列表 */
|
|
1759
|
+
select?: string[];
|
|
1760
|
+
/** 排序规则 */
|
|
1761
|
+
orderBy?: SortList;
|
|
1762
|
+
/** 当前页码,从 1 开始 */
|
|
1763
|
+
currentPage?: number;
|
|
1764
|
+
/** 每页数量 */
|
|
1765
|
+
pageSize?: number;
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* 聚合类型
|
|
1769
|
+
*/
|
|
1770
|
+
type AggregateType = 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX';
|
|
1771
|
+
/**
|
|
1772
|
+
* 聚合字段配置
|
|
1773
|
+
*/
|
|
1774
|
+
interface AggregateField {
|
|
1775
|
+
/** 聚合类型 */
|
|
1776
|
+
type: AggregateType;
|
|
1777
|
+
/** 聚合列名 */
|
|
1778
|
+
column?: string;
|
|
1779
|
+
/**
|
|
1780
|
+
* 聚合列名的旧别名。
|
|
1781
|
+
* @deprecated Use `column`. The SDK normalizes `field` to `column` before sending requests.
|
|
1782
|
+
*/
|
|
1783
|
+
field?: string;
|
|
1784
|
+
/** 字段别名 */
|
|
1785
|
+
alias?: string;
|
|
1786
|
+
/** 是否 distinct */
|
|
1787
|
+
distinct?: boolean;
|
|
1788
|
+
/** 是否 round */
|
|
1789
|
+
round?: boolean;
|
|
1790
|
+
/** round 精度 */
|
|
1791
|
+
precision?: number;
|
|
1792
|
+
}
|
|
1793
|
+
/**
|
|
1794
|
+
* Join 类型
|
|
1795
|
+
*/
|
|
1796
|
+
type JoinType = 'LEFT' | 'RIGHT' | 'INNER';
|
|
1797
|
+
/**
|
|
1798
|
+
* Join 配置
|
|
1799
|
+
*/
|
|
1800
|
+
interface JoinConfig {
|
|
1801
|
+
/** Join 类型 */
|
|
1802
|
+
type: JoinType;
|
|
1803
|
+
/** 关联表名 */
|
|
1804
|
+
table: string;
|
|
1805
|
+
/** 关联条件,key 为当前表字段,value 为关联表字段 */
|
|
1806
|
+
condition: Record<string, string>;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Having 条件
|
|
1810
|
+
*/
|
|
1811
|
+
interface HavingCondition {
|
|
1812
|
+
/** 列名(通常是聚合字段的别名) */
|
|
1813
|
+
columnName: string;
|
|
1814
|
+
/** 条件 */
|
|
1815
|
+
condition: FieldCondition;
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* Aggregate 参数接口
|
|
1819
|
+
* @description 用于 aggregate 方法的聚合查询参数
|
|
1820
|
+
* @example
|
|
1821
|
+
* ```typescript
|
|
1822
|
+
* // 使用枚举
|
|
1823
|
+
* const aggregateParams1: AggregateParams = {
|
|
1824
|
+
* select: ['category_id'],
|
|
1825
|
+
* aggregate: [
|
|
1826
|
+
* { type: 'SUM', column: 'amount', alias: 'total_amount', round: true, precision: 2 }
|
|
1827
|
+
* ],
|
|
1828
|
+
* where: { status: { $eq: 'active' } },
|
|
1829
|
+
* groupBy: ['category_id'],
|
|
1830
|
+
* having: [
|
|
1831
|
+
* { columnName: 'total_amount', condition: { $gte: 1000 } }
|
|
1832
|
+
* ],
|
|
1833
|
+
* orderBy: [{ total_amount: SortOrder.DESC }],
|
|
1834
|
+
* currentPage: 1,
|
|
1835
|
+
* pageSize: 20
|
|
1836
|
+
* };
|
|
1837
|
+
*
|
|
1838
|
+
* // 或使用字符串
|
|
1839
|
+
* const aggregateParams2: AggregateParams = {
|
|
1840
|
+
* orderBy: [{ total_amount: "desc" }]
|
|
1841
|
+
* };
|
|
1842
|
+
* ```
|
|
1843
|
+
*/
|
|
1844
|
+
interface AggregateParams {
|
|
1845
|
+
/** 选择返回的字段列表 */
|
|
1846
|
+
select?: string[];
|
|
1847
|
+
/** 聚合字段配置 */
|
|
1848
|
+
aggregate?: AggregateField[];
|
|
1849
|
+
/** Where 条件 */
|
|
1850
|
+
where?: WhereCondition;
|
|
1851
|
+
/** Group By 字段列表 */
|
|
1852
|
+
groupBy?: string[];
|
|
1853
|
+
/** Having 条件 */
|
|
1854
|
+
having?: HavingCondition[];
|
|
1855
|
+
/** Join 配置 */
|
|
1856
|
+
join?: JoinConfig[];
|
|
1857
|
+
/** 排序规则 */
|
|
1858
|
+
orderBy?: SortList;
|
|
1859
|
+
/** 当前页码,从 1 开始 */
|
|
1860
|
+
currentPage?: number;
|
|
1861
|
+
/** 每页数量 */
|
|
1862
|
+
pageSize?: number;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* 下拉选项接口
|
|
1866
|
+
* @description 用于 Select 组件的选项数据格式
|
|
1867
|
+
*/
|
|
1868
|
+
interface SelectOption {
|
|
1869
|
+
/** 显示文本 */
|
|
1870
|
+
label: string;
|
|
1871
|
+
/** 选项值 */
|
|
1872
|
+
value: string;
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* 获取下拉选项的参数接口
|
|
1876
|
+
* @description 指定用于生成下拉选项的字段映射
|
|
1877
|
+
* @example
|
|
1878
|
+
* ```typescript
|
|
1879
|
+
* // 获取用户列表的下拉选项
|
|
1880
|
+
* const options = await model.getSelectOptions({
|
|
1881
|
+
* code: 'user_id', // 将 user_id 字段作为 value
|
|
1882
|
+
* label: 'user_name' // 将 user_name 字段作为 label
|
|
1883
|
+
* });
|
|
1884
|
+
* // 返回: [{ label: '张三', value: 'user001' }, ...]
|
|
1885
|
+
* ```
|
|
1886
|
+
*/
|
|
1887
|
+
interface SelectOptionsParams {
|
|
1888
|
+
/** 用作选项值的字段名 */
|
|
1889
|
+
code: string;
|
|
1890
|
+
/** 用作显示文本的字段名 */
|
|
1891
|
+
label: string;
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* 单个模型配置接口
|
|
1895
|
+
* @description 定义数据模型的基本配置信息
|
|
1896
|
+
*/
|
|
1897
|
+
interface ModelConfig {
|
|
1898
|
+
/** 数据表名称 */
|
|
1899
|
+
tableName: string;
|
|
1900
|
+
/** 数据集代码(唯一标识) */
|
|
1901
|
+
datasetCode: string;
|
|
1902
|
+
/** 数据集名称 */
|
|
1903
|
+
name?: string;
|
|
1904
|
+
/** 别名,用于人类友好的访问方式(可选) */
|
|
1905
|
+
alias?: string;
|
|
1906
|
+
/** 数据库名称(可选,用于区分不同数据库中的同名表) */
|
|
1907
|
+
dbName?: string;
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* 模型配置集合接口
|
|
1911
|
+
* @description 包含应用代码和所有模型配置的集合
|
|
1912
|
+
*
|
|
1913
|
+
* 支持两种格式:
|
|
1914
|
+
* 1. 数组格式(推荐):ModelConfig[]
|
|
1915
|
+
* 2. 对象格式(向下兼容):Record<string, ModelConfig>,key 作为默认 alias
|
|
1916
|
+
*
|
|
1917
|
+
* @example
|
|
1918
|
+
* ```typescript
|
|
1919
|
+
* // 新格式(数组)
|
|
1920
|
+
* const config: ModelsConfig = {
|
|
1921
|
+
* appCode: 'my-app',
|
|
1922
|
+
* models: [
|
|
1923
|
+
* { tableName: 'users', datasetCode: 'dataset_abc', alias: 'users' },
|
|
1924
|
+
* { tableName: 'posts', datasetCode: 'dataset_def' }
|
|
1925
|
+
* ]
|
|
1926
|
+
* };
|
|
1927
|
+
*
|
|
1928
|
+
* // 老格式(对象,向下兼容)
|
|
1929
|
+
* const config: ModelsConfig = {
|
|
1930
|
+
* appCode: 'my-app',
|
|
1931
|
+
* models: {
|
|
1932
|
+
* Users: { tableName: 'users', datasetCode: 'user-dataset-code' },
|
|
1933
|
+
* Posts: { tableName: 'posts', datasetCode: 'post-dataset-code' }
|
|
1934
|
+
* }
|
|
1935
|
+
* };
|
|
1936
|
+
* ```
|
|
1937
|
+
*/
|
|
1938
|
+
interface ModelsConfig {
|
|
1939
|
+
/** 应用代码,用于标识不同的应用 */
|
|
1940
|
+
appCode: string;
|
|
1941
|
+
/**
|
|
1942
|
+
* 模型配置
|
|
1943
|
+
* - 数组格式(推荐):直接使用 datasetCode 访问
|
|
1944
|
+
* - 对象格式(兼容):key 作为默认 alias
|
|
1945
|
+
*/
|
|
1946
|
+
models: ModelConfig[] | Record<string, ModelConfig>;
|
|
1947
|
+
}
|
|
1948
|
+
/**
|
|
1949
|
+
* 客户端配置接口
|
|
1950
|
+
* @description Lovrabet 客户端的完整配置选项
|
|
1951
|
+
* @example
|
|
1952
|
+
* ```typescript
|
|
1953
|
+
* // 基本配置(推荐使用 production)
|
|
1954
|
+
* const config: ClientConfig = {
|
|
1955
|
+
* appCode: 'my-app',
|
|
1956
|
+
* env: 'production',
|
|
1957
|
+
* token: 'your-token'
|
|
1958
|
+
* };
|
|
1959
|
+
*
|
|
1960
|
+
* // 向下兼容(online 等同于 production)
|
|
1961
|
+
* const config: ClientConfig = {
|
|
1962
|
+
* appCode: 'my-app',
|
|
1963
|
+
* env: 'online',
|
|
1964
|
+
* token: 'your-token'
|
|
1965
|
+
* };
|
|
1966
|
+
*
|
|
1967
|
+
* // 引用预注册配置
|
|
1968
|
+
* const config: ClientConfig = {
|
|
1969
|
+
* apiConfigName: 'prod',
|
|
1970
|
+
* token: 'override-token'
|
|
1971
|
+
* };
|
|
1972
|
+
* ```
|
|
1973
|
+
*/
|
|
1974
|
+
/**
|
|
1975
|
+
* 鉴权模式类型
|
|
1976
|
+
* - "openapi": OpenAPI 签名模式(accessKey + secretKey),走 /openapi/ 前缀
|
|
1977
|
+
* - "client-ak": Client AK 模式(仅 accessKey),走 /client/ 前缀,X-User-AK 鉴权
|
|
1978
|
+
* - "cookie": Cookie 模式,走 /api/ 前缀
|
|
1979
|
+
*/
|
|
1980
|
+
type AuthMode = "openapi" | "client-ak" | "cookie";
|
|
1981
|
+
interface ClientConfig {
|
|
1982
|
+
/** 应用代码,用于标识不同的应用 */
|
|
1983
|
+
appCode?: string;
|
|
1984
|
+
/**
|
|
1985
|
+
* 运行态 API 域名,优先级最高,可覆盖环境默认端点与部署配置注入的地址。
|
|
1986
|
+
* 适用于私有化部署或本地联调。
|
|
1987
|
+
*
|
|
1988
|
+
* 与 rabetbase-cli/.rabetbase.json 中的 `runtimeDomain` 字段命名对齐。
|
|
1989
|
+
*
|
|
1990
|
+
* @example 'https://runtime.my-company.com'
|
|
1991
|
+
*/
|
|
1992
|
+
runtimeDomain?: string;
|
|
1993
|
+
/**
|
|
1994
|
+
* @deprecated 请使用 `runtimeDomain` 替代。
|
|
1995
|
+
* 为向下兼容而保留,优先级低于 `runtimeDomain`;
|
|
1996
|
+
* 两者均设置时以 `runtimeDomain` 为准。
|
|
1997
|
+
* 下一个大版本将移除此字段。
|
|
1998
|
+
*/
|
|
1999
|
+
serverUrl?: string;
|
|
2000
|
+
/** 运行环境,默认为 'production'(向下兼容 'online') */
|
|
2001
|
+
env?: Environment$1;
|
|
2002
|
+
/** 官方运行节点,默认为 'cn';显式 runtimeDomain 的优先级更高。 */
|
|
2003
|
+
region?: Region;
|
|
2004
|
+
/** 预计算 OpenAPI token,配合 timestamp 通过 X-Token / X-Time-Stamp 传递,不是 Authorization: Bearer */
|
|
2005
|
+
token?: string;
|
|
2006
|
+
/** 与 token 配对的时间戳(OpenAPI 模式必需) */
|
|
2007
|
+
timestamp?: number;
|
|
2008
|
+
/** API 访问密钥,用于签名认证 */
|
|
2009
|
+
accessKey?: string;
|
|
2010
|
+
/** API 密钥,用于签名认证 */
|
|
2011
|
+
secretKey?: string;
|
|
2012
|
+
/** Cookie 字符串,用于 Cookie 认证(Node.js 环境专用) */
|
|
2013
|
+
cookie?: string;
|
|
2014
|
+
/**
|
|
2015
|
+
* 显式要求当前 authMode 下的凭据已经齐全时设为 true。
|
|
2016
|
+
* 未设置时不做强制检查(没有默认 true)。
|
|
2017
|
+
* 校验按 authMode:client-ak 需要 accessKey;openapi 需要 accessKey,或 token + timestamp;
|
|
2018
|
+
* cookie / 缺省不能把 token、accessKey 当成已生效的 Cookie 认证。
|
|
2019
|
+
*/
|
|
2020
|
+
requiresAuth?: boolean;
|
|
2021
|
+
/**
|
|
2022
|
+
* 显式声明鉴权模式。**未设置时固定回退到 cookie 模式**,不会根据 accessKey / token 等字段自动推断;
|
|
2023
|
+
* 需要 Client AK / OpenAPI 鉴权时必须显式设置(`"client-ak"` 或 `"openapi"`)。
|
|
2024
|
+
*/
|
|
2025
|
+
authMode?: AuthMode;
|
|
2026
|
+
/**
|
|
2027
|
+
* 模型配置
|
|
2028
|
+
* - 数组格式(推荐):直接使用 datasetCode 访问
|
|
2029
|
+
* - 对象格式(兼容):key 作为默认 alias
|
|
2030
|
+
*/
|
|
2031
|
+
models?: ModelConfig[] | Record<string, ModelConfig>;
|
|
2032
|
+
/**
|
|
2033
|
+
* 引用已注册的 API 配置名称
|
|
2034
|
+
* @description 当指定此字段时,会从配置注册表中获取对应的模型配置
|
|
2035
|
+
* @example 'default', 'prod', 'dev'
|
|
2036
|
+
*/
|
|
2037
|
+
apiConfigName?: string;
|
|
2038
|
+
/** 额外配置选项 */
|
|
2039
|
+
options?: {
|
|
2040
|
+
/** 请求超时时间(毫秒),包含响应体读取;未配置时保留原行为(PUT/DELETE 默认 30000,其他不限时)。 */
|
|
2041
|
+
timeout?: number;
|
|
2042
|
+
/** Fetch 重定向策略;未配置时沿用 Fetch 默认行为。 */
|
|
2043
|
+
redirect?: RequestRedirect;
|
|
2044
|
+
/** 重试次数 */
|
|
2045
|
+
retryCount?: number;
|
|
2046
|
+
/** 错误处理回调函数 */
|
|
2047
|
+
onError?: (error: any) => void;
|
|
2048
|
+
/** 需要重新登录时的回调函数 */
|
|
2049
|
+
onRedirectToLogin?: () => void;
|
|
2050
|
+
/** 是否启用调试日志(打印请求 URL、Headers 和 Body) */
|
|
2051
|
+
debug?: boolean;
|
|
2052
|
+
/** 附加到每个请求的自定义 HTTP 请求头 */
|
|
2053
|
+
headers?: Record<string, string>;
|
|
2054
|
+
};
|
|
2055
|
+
}
|
|
2056
|
+
/**
|
|
2057
|
+
* 基础模型方法接口
|
|
2058
|
+
* @description 定义所有模型实例的标准 CRUD 操作方法
|
|
2059
|
+
* @template T 数据类型,默认为 any
|
|
2060
|
+
* @example
|
|
2061
|
+
* ```typescript
|
|
2062
|
+
* // 使用示例
|
|
2063
|
+
* const users: BaseModelMethods = client.models.Users;
|
|
2064
|
+
* const userList = await users.getList({ currentPage: 1, pageSize: 10 });
|
|
2065
|
+
* const user = await users.getOne('123');
|
|
2066
|
+
* const newUser = await users.create({ name: 'John', email: 'john@example.com' });
|
|
2067
|
+
* ```
|
|
2068
|
+
*/
|
|
2069
|
+
interface BaseModelMethods {
|
|
2070
|
+
/**
|
|
2071
|
+
* 获取数据列表
|
|
2072
|
+
* @template T 返回数据的类型
|
|
2073
|
+
* @param params 查询参数,包含分页等信息
|
|
2074
|
+
* @param sortList 排序配置列表,可选参数
|
|
2075
|
+
* @returns 返回分页数据
|
|
2076
|
+
*/
|
|
2077
|
+
getList<T = any>(params?: ListParams, sortList?: SortList): Promise<ListResponse<T>>;
|
|
2078
|
+
/**
|
|
2079
|
+
* 高级过滤查询(推荐使用)
|
|
2080
|
+
* @template T 返回数据的类型
|
|
2081
|
+
* @param params Filter 查询参数,支持复杂条件、字段选择、排序和分页
|
|
2082
|
+
* @returns 返回分页数据
|
|
2083
|
+
* @description 提供比 getList 更强大的查询能力,支持复杂的 where 条件、字段选择等(filter 在 WebAPI / OpenAPI / Client AK 模式均支持;delete、excelExport、getSelectOptions 当前不支持 OpenAPI 模式,WebAPI 与 Client AK 均支持)
|
|
2084
|
+
* @example
|
|
2085
|
+
* ```typescript
|
|
2086
|
+
* // 使用枚举
|
|
2087
|
+
* const result1 = await model.filter({
|
|
2088
|
+
* where: {
|
|
2089
|
+
* $and: [
|
|
2090
|
+
* { age: { $gte: 18, $lte: 45 } },
|
|
2091
|
+
* { country: { $in: ['中国', '美国', '日本'] } },
|
|
2092
|
+
* { name: { $contain: 'hello' } }
|
|
2093
|
+
* ]
|
|
2094
|
+
* },
|
|
2095
|
+
* select: ['id', 'name', 'age', 'country'],
|
|
2096
|
+
* orderBy: [{ lastLoginAt: SortOrder.DESC }],
|
|
2097
|
+
* currentPage: 1,
|
|
2098
|
+
* pageSize: 20
|
|
2099
|
+
* });
|
|
2100
|
+
*
|
|
2101
|
+
* // 或使用字符串(更简洁)
|
|
2102
|
+
* const result2 = await model.filter({
|
|
2103
|
+
* orderBy: [{ lastLoginAt: "desc" }]
|
|
2104
|
+
* });
|
|
2105
|
+
* ```
|
|
2106
|
+
*/
|
|
2107
|
+
filter<T = any>(params?: FilterParams): Promise<ListResponse<T>>;
|
|
2108
|
+
/**
|
|
2109
|
+
* 获取单条数据
|
|
2110
|
+
* @template T 返回数据的类型
|
|
2111
|
+
* @param idOrParams 数据 ID(字符串或数字),或包含 id 字段的对象
|
|
2112
|
+
* @returns 返回单条数据
|
|
2113
|
+
* @example
|
|
2114
|
+
* ```typescript
|
|
2115
|
+
* // 直接传 ID
|
|
2116
|
+
* const user = await model.getOne(123);
|
|
2117
|
+
* const user = await model.getOne('abc');
|
|
2118
|
+
*
|
|
2119
|
+
* // 传对象(兼容格式)
|
|
2120
|
+
* const user = await model.getOne({ id: 123 });
|
|
2121
|
+
* const user = await model.getOne({ id: String(id) });
|
|
2122
|
+
* ```
|
|
2123
|
+
*/
|
|
2124
|
+
getOne<T = any>(idOrParams: string | number | {
|
|
2125
|
+
id: string | number;
|
|
2126
|
+
}): Promise<T>;
|
|
2127
|
+
/**
|
|
2128
|
+
* 创建新数据
|
|
2129
|
+
* @template T 返回数据的类型
|
|
2130
|
+
* @param data 要创建的数据对象
|
|
2131
|
+
* @returns 返回创建后的数据
|
|
2132
|
+
*/
|
|
2133
|
+
create<T = any>(data: Record<string, any>): Promise<T>;
|
|
2134
|
+
/**
|
|
2135
|
+
* 批量创建数据
|
|
2136
|
+
* @template T 返回数据的类型
|
|
2137
|
+
* @param items 要创建的数据对象数组,最多 1000 条
|
|
2138
|
+
* @returns 返回创建后的数据
|
|
2139
|
+
*/
|
|
2140
|
+
batchCreate<T = any>(items: Record<string, any>[]): Promise<T>;
|
|
2141
|
+
/**
|
|
2142
|
+
* 更新数据,支持单条和批量
|
|
2143
|
+
* @template T 返回数据的类型
|
|
2144
|
+
*
|
|
2145
|
+
* **推荐写法(对象合并)**:将 id 与更新字段合并为一个对象传入:
|
|
2146
|
+
* ```typescript
|
|
2147
|
+
* await model.update({ id: 1001, name: '张三' });
|
|
2148
|
+
* await model.update({ id: [1001, 1002], status: 'active' });
|
|
2149
|
+
* ```
|
|
2150
|
+
*
|
|
2151
|
+
* **兼容写法(id 分离)**:
|
|
2152
|
+
* ```typescript
|
|
2153
|
+
* await model.update(1001, { name: '张三' });
|
|
2154
|
+
* await model.update([1001, 1002], { status: 'active' });
|
|
2155
|
+
* ```
|
|
2156
|
+
*/
|
|
2157
|
+
update<T = any>(dataWithId: {
|
|
2158
|
+
id: string | number | (string | number)[];
|
|
2159
|
+
[key: string]: any;
|
|
2160
|
+
}): Promise<T>;
|
|
2161
|
+
update<T = any>(id: string | number | (string | number)[], data: Record<string, any>): Promise<T>;
|
|
2162
|
+
/**
|
|
2163
|
+
* 删除数据,支持单条和批量
|
|
2164
|
+
* @throws Error OpenAPI 模式暂不支持此操作;WebAPI 与 Client AK 模式均可用
|
|
2165
|
+
*
|
|
2166
|
+
* **推荐写法(对象传入)**:
|
|
2167
|
+
* ```typescript
|
|
2168
|
+
* await model.delete({ id: 1001 });
|
|
2169
|
+
* await model.delete({ id: [1001, 1002, 1003] });
|
|
2170
|
+
* ```
|
|
2171
|
+
*
|
|
2172
|
+
* **兼容写法(直接传 id)**:
|
|
2173
|
+
* ```typescript
|
|
2174
|
+
* await model.delete(1001);
|
|
2175
|
+
* await model.delete([1001, 1002, 1003]);
|
|
2176
|
+
* ```
|
|
2177
|
+
*/
|
|
2178
|
+
delete(params: {
|
|
2179
|
+
id: string | number | (string | number)[];
|
|
2180
|
+
}): Promise<void>;
|
|
2181
|
+
delete(id: string | number | (string | number)[]): Promise<void>;
|
|
2182
|
+
/**
|
|
2183
|
+
* 获取下拉选项
|
|
2184
|
+
* @param params 字段映射参数,指定用作 value 和 label 的字段名
|
|
2185
|
+
* @returns 返回下拉选项数组
|
|
2186
|
+
* @description 用于获取数据表的下拉选项数据,适用于 Select 组件(WebAPI 与 Client AK 模式支持,OpenAPI 模式不支持)
|
|
2187
|
+
* @example
|
|
2188
|
+
* ```typescript
|
|
2189
|
+
* // 获取用户下拉选项
|
|
2190
|
+
* const options = await model.getSelectOptions({
|
|
2191
|
+
* code: 'user_id',
|
|
2192
|
+
* label: 'user_name'
|
|
2193
|
+
* });
|
|
2194
|
+
* // 返回: [{ label: '张三', value: 'user001' }, { label: '李四', value: 'user002' }]
|
|
2195
|
+
* ```
|
|
2196
|
+
*/
|
|
2197
|
+
getSelectOptions(params: SelectOptionsParams): Promise<SelectOption[]>;
|
|
2198
|
+
/**
|
|
2199
|
+
* 导出数据为 Excel 文件
|
|
2200
|
+
* @param params 查询参数(可选),与 getList 参数一致,用于按条件筛选导出数据
|
|
2201
|
+
* @returns 返回导出文件的 URL 地址(字符串),可直接用于下载
|
|
2202
|
+
* @description 导出当前数据集的数据为 Excel 文件(WebAPI 与 Client AK 模式支持,OpenAPI 模式不支持)
|
|
2203
|
+
* @example
|
|
2204
|
+
* ```typescript
|
|
2205
|
+
* // 导出所有数据
|
|
2206
|
+
* const fileUrl = await model.excelExport();
|
|
2207
|
+
* // fileUrl: "https://yuntoo-export-import.oss-cn-hangzhou.aliyuncs.com/xxx.xlsx?..."
|
|
2208
|
+
* window.open(fileUrl, '_blank');
|
|
2209
|
+
*
|
|
2210
|
+
* // 按条件筛选导出
|
|
2211
|
+
* const fileUrl = await model.excelExport({
|
|
2212
|
+
* status: 'active',
|
|
2213
|
+
* createTime: '2025-01-01'
|
|
2214
|
+
* });
|
|
2215
|
+
* window.open(fileUrl, '_blank');
|
|
2216
|
+
* ```
|
|
2217
|
+
*/
|
|
2218
|
+
excelExport<T = string>(params?: ListParams): Promise<T>;
|
|
2219
|
+
/**
|
|
2220
|
+
* 聚合查询
|
|
2221
|
+
* @template T 返回数据的类型
|
|
2222
|
+
* @param params 聚合查询参数,支持 SUM、COUNT、AVG、MIN、MAX 等聚合函数,以及 GROUP BY、HAVING、JOIN
|
|
2223
|
+
* @returns 返回分页数据
|
|
2224
|
+
* @example
|
|
2225
|
+
* ```typescript
|
|
2226
|
+
* // 使用枚举
|
|
2227
|
+
* const result1 = await model.aggregate({
|
|
2228
|
+
* select: ['category_id'],
|
|
2229
|
+
* aggregate: [
|
|
2230
|
+
* { type: 'SUM', column: 'amount', alias: 'total_amount', round: true, precision: 2 }
|
|
2231
|
+
* ],
|
|
2232
|
+
* groupBy: ['category_id'],
|
|
2233
|
+
* having: [{ columnName: 'total_amount', condition: { $gte: 1000 } }],
|
|
2234
|
+
* orderBy: [{ total_amount: SortOrder.DESC }]
|
|
2235
|
+
* });
|
|
2236
|
+
*
|
|
2237
|
+
* // 或使用字符串
|
|
2238
|
+
* const result2 = await model.aggregate({
|
|
2239
|
+
* orderBy: [{ total_amount: "desc" }]
|
|
2240
|
+
* });
|
|
2241
|
+
* ```
|
|
2242
|
+
*/
|
|
2243
|
+
aggregate<T = any>(params?: AggregateParams): Promise<ListResponse<T>>;
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* 认证请求头接口
|
|
2247
|
+
* @description 包含认证信息的 HTTP 请求头。实际字段由 authMode 决定,不是 Authorization: Bearer。
|
|
2248
|
+
* @example
|
|
2249
|
+
* ```typescript
|
|
2250
|
+
* // OpenAPI:预计算 token 或 accessKey 签名
|
|
2251
|
+
* { "X-Token": "…", "X-Time-Stamp": "…", "X-App-Code": "app-xxx", "X-Dataset-Code": "…" }
|
|
2252
|
+
*
|
|
2253
|
+
* // Client AK
|
|
2254
|
+
* { "X-User-AK": "your-access-key" }
|
|
2255
|
+
* ```
|
|
2256
|
+
*/
|
|
2257
|
+
interface AuthHeaders {
|
|
2258
|
+
/** 请求头键值对 */
|
|
2259
|
+
[key: string]: string;
|
|
2260
|
+
}
|
|
2261
|
+
/**
|
|
2262
|
+
* 认证管理器接口
|
|
2263
|
+
* @description 按显式 authMode 选择认证策略;未设置 authMode 时固定为 cookie,不会按 token / accessKey 自动升级。
|
|
2264
|
+
* @example
|
|
2265
|
+
* ```typescript
|
|
2266
|
+
* // OpenAPI 预计算 token 必须配对 timestamp
|
|
2267
|
+
* authManager.setToken('your-token', Date.now());
|
|
2268
|
+
*
|
|
2269
|
+
* const headers = await authManager.getAuthHeaders(appCode, datasetCode);
|
|
2270
|
+
* // 返回: { "X-Token": "…", "X-Time-Stamp": "…" }
|
|
2271
|
+
* ```
|
|
2272
|
+
*/
|
|
2273
|
+
interface AuthManager$1 {
|
|
2274
|
+
/**
|
|
2275
|
+
* 获取认证请求头
|
|
2276
|
+
* @description 根据当前配置的认证方式生成对应的请求头
|
|
2277
|
+
* @param appCode 应用代码(OpenAPI 认证时必需)
|
|
2278
|
+
* @param datasetCode 数据集代码(OpenAPI 认证时必需)
|
|
2279
|
+
* @returns 包含认证信息的请求头对象
|
|
2280
|
+
*/
|
|
2281
|
+
getAuthHeaders(appCode?: string, datasetCode?: string): Promise<AuthHeaders>;
|
|
2282
|
+
/** 为绑定应用和操作人的审批 Flow OpenAPI 生成签名上下文。 */
|
|
2283
|
+
getFlowAuthContext(appCode: string, operatorUserId: string): Promise<OpenApiAuthContext>;
|
|
2284
|
+
/**
|
|
2285
|
+
* 验证当前认证是否有效
|
|
2286
|
+
* @returns 认证是否有效
|
|
2287
|
+
*/
|
|
2288
|
+
validateAuth(): Promise<boolean>;
|
|
2289
|
+
/**
|
|
2290
|
+
* 设置用户 Token
|
|
2291
|
+
* @param token 用户认证 Token
|
|
2292
|
+
* @param timestamp 与 token 配对的时间戳(OpenAPI 模式必需)
|
|
2293
|
+
*/
|
|
2294
|
+
setToken(token: string, timestamp?: number): void;
|
|
2295
|
+
/**
|
|
2296
|
+
* 检查是否使用 Cookie 认证
|
|
2297
|
+
* @description 当没有 Token 和 API 密钥时,会降级到 Cookie 认证
|
|
2298
|
+
* @returns 是否使用 Cookie 认证
|
|
2299
|
+
*/
|
|
2300
|
+
isCookieAuth(): boolean;
|
|
2301
|
+
/**
|
|
2302
|
+
* 检查是否提供了显式的 Cookie 字符串
|
|
2303
|
+
* @description 用于区分浏览器自动 Cookie (credentials: 'include') 和用户显式提供的 Cookie 字符串
|
|
2304
|
+
* @returns 是否提供了显式 Cookie
|
|
2305
|
+
*/
|
|
2306
|
+
hasExplicitCookie(): boolean;
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2309
|
+
* Lovrabet 客户端接口
|
|
2310
|
+
* @description SDK 的主要客户端接口,提供模型访问和配置管理功能
|
|
2311
|
+
* @example
|
|
2312
|
+
* ```typescript
|
|
2313
|
+
* // 创建客户端
|
|
2314
|
+
* const client = createClient();
|
|
2315
|
+
*
|
|
2316
|
+
* // 使用模型
|
|
2317
|
+
* const users = await client.models.Users.getList();
|
|
2318
|
+
*
|
|
2319
|
+
* // 设置认证
|
|
2320
|
+
* client.setToken('new-token');
|
|
2321
|
+
*
|
|
2322
|
+
* // 获取配置
|
|
2323
|
+
* const config = client.getConfig();
|
|
2324
|
+
* ```
|
|
2325
|
+
*/
|
|
2326
|
+
interface LovrabetClient$1 {
|
|
2327
|
+
/** 运行态通用服务,如文件与 OCR。 */
|
|
2328
|
+
readonly services: LovrabetServices;
|
|
2329
|
+
/** 创建使用当前登录用户身份的独立流程自定义页面客户端。 */
|
|
2330
|
+
flow(): LovrabetFlowClient;
|
|
2331
|
+
/**
|
|
2332
|
+
* 当前用户拥有的资源,如个人 BFF。
|
|
2333
|
+
*
|
|
2334
|
+
* 该公共接口允许兼容旧版或外部注入的 client;createClient() 返回的
|
|
2335
|
+
* 具体 LovrabetClient 实例始终提供 personal。
|
|
2336
|
+
*/
|
|
2337
|
+
readonly personal?: LovrabetPersonal;
|
|
2338
|
+
/**
|
|
2339
|
+
* SQL 执行客户端,按认证模式自动选择实现。
|
|
2340
|
+
*
|
|
2341
|
+
* `query()` 仅 `ClientAkSqlClient` 提供,使用前需 `instanceof` 收窄。
|
|
2342
|
+
*/
|
|
2343
|
+
readonly sql: SqlClient | OpenApiSqlClient | ClientAkSqlClient;
|
|
2344
|
+
/**
|
|
2345
|
+
* BFF 端点客户端,按认证模式自动选择实现。
|
|
2346
|
+
*
|
|
2347
|
+
* `getEndpoint()` 仅 `ClientAkBffClient` 提供,使用前需 `instanceof` 收窄。
|
|
2348
|
+
*/
|
|
2349
|
+
readonly bff: BffClient | ClientAkBffClient;
|
|
2350
|
+
/**
|
|
2351
|
+
* 权限、角色与成员能力(cookie / client-ak 双模式)。
|
|
2352
|
+
*
|
|
2353
|
+
* 对应后端成对存在的 `/api/permit/*` 与 `/client/permit/*`;
|
|
2354
|
+
* OpenAPI 模式调用时会抛出 `API_AUTH_MODE_UNSUPPORTED`。
|
|
2355
|
+
*/
|
|
2356
|
+
readonly permit: PermitClient;
|
|
2357
|
+
/** Artifact 产物管理(仅 client-ak)。 */
|
|
2358
|
+
readonly artifact: ArtifactClient;
|
|
2359
|
+
/** 审批任务(仅 client-ak)。 */
|
|
2360
|
+
readonly approval: ApprovalClient;
|
|
2361
|
+
/** 应用、登录用户、应用配置与通知渠道(仅 client-ak)。 */
|
|
2362
|
+
readonly app: AppClient;
|
|
2363
|
+
/** 数据集元信息与驱动配置(仅 client-ak)。 */
|
|
2364
|
+
readonly datasetMeta: DatasetMetaClient;
|
|
2365
|
+
/** 脚本缓存与日志诊断(仅 cookie)。 */
|
|
2366
|
+
readonly management: ManagementClient;
|
|
2367
|
+
/**
|
|
2368
|
+
* 模型访问接口 - 纯粹的语法糖,支持 client.models.ModelName 访问
|
|
2369
|
+
* @description 内部调用 client.getModel() 方法,提供更简洁的访问方式
|
|
2370
|
+
* @example
|
|
2371
|
+
* ```typescript
|
|
2372
|
+
* // 两种方式等价:
|
|
2373
|
+
* const model1 = client.getModel('Requirements');
|
|
2374
|
+
* const model2 = client.models.Requirements;
|
|
2375
|
+
*
|
|
2376
|
+
* // 推荐的简洁用法:
|
|
2377
|
+
* const data = await client.models.Requirements.getList();
|
|
2378
|
+
* ```
|
|
2379
|
+
*/
|
|
2380
|
+
models: {
|
|
2381
|
+
[modelName: string]: BaseModelMethods;
|
|
2382
|
+
};
|
|
2383
|
+
/**
|
|
2384
|
+
* 设置用户认证 Token
|
|
2385
|
+
* @param token 用户认证 Token
|
|
2386
|
+
* @param timestamp 与 token 配对的时间戳(OpenAPI 模式必需)
|
|
2387
|
+
* @description 设置后所有 API 请求将使用此 Token 进行认证
|
|
2388
|
+
*/
|
|
2389
|
+
setToken(token: string, timestamp?: number): void;
|
|
2390
|
+
/**
|
|
2391
|
+
* 获取客户端配置
|
|
2392
|
+
* @returns 当前客户端的完整配置信息
|
|
2393
|
+
*/
|
|
2394
|
+
getConfig(): ClientConfig;
|
|
2395
|
+
/**
|
|
2396
|
+
* 获取所有可用模型列表
|
|
2397
|
+
* @returns 返回已配置的所有模型名称数组
|
|
2398
|
+
* @example
|
|
2399
|
+
* ```typescript
|
|
2400
|
+
* const models = client.getModelList();
|
|
2401
|
+
* console.log('可用模型:', models); // ['Requirements', 'Projects', 'Users']
|
|
2402
|
+
*
|
|
2403
|
+
* // 使用第一个模型
|
|
2404
|
+
* if (models.length > 0) {
|
|
2405
|
+
* const firstModel = client.getModel(0);
|
|
2406
|
+
* const data = await firstModel.getList();
|
|
2407
|
+
* }
|
|
2408
|
+
* ```
|
|
2409
|
+
*/
|
|
2410
|
+
getModelList(): string[];
|
|
2411
|
+
/**
|
|
2412
|
+
* 根据索引或名称获取模型实例
|
|
2413
|
+
* @param indexOrName 模型索引(数字)或模型名称(字符串)
|
|
2414
|
+
* @returns 返回对应的模型实例,可直接调用 getList(), getOne() 等方法
|
|
2415
|
+
* @throws 当索引超出范围或模型名称不存在时抛出错误
|
|
2416
|
+
* @example
|
|
2417
|
+
* ```typescript
|
|
2418
|
+
* // 通过索引获取模型
|
|
2419
|
+
* const firstModel = client.getModel(0);
|
|
2420
|
+
* const data = await firstModel.getList();
|
|
2421
|
+
*
|
|
2422
|
+
* // 通过名称获取模型
|
|
2423
|
+
* const usersModel = client.getModel('Users');
|
|
2424
|
+
* const user = await usersModel.getOne(123);
|
|
2425
|
+
*
|
|
2426
|
+
* // 错误处理
|
|
2427
|
+
* try {
|
|
2428
|
+
* const model = client.getModel(999); // 索引超出范围
|
|
2429
|
+
* } catch (error) {
|
|
2430
|
+
* console.error('Model not found:', error.message);
|
|
2431
|
+
* }
|
|
2432
|
+
* ```
|
|
2433
|
+
*/
|
|
2434
|
+
getModel(indexOrName: number | string): BaseModelMethods;
|
|
2435
|
+
/**
|
|
2436
|
+
* 检查当前是否为 OpenAPI 模式
|
|
2437
|
+
* @returns 如果配置了 accessKey 或 token 则返回 true,否则返回 false
|
|
2438
|
+
* @description OpenAPI 模式会使用不同的 URL 路径和认证方式
|
|
2439
|
+
* @example
|
|
2440
|
+
* ```typescript
|
|
2441
|
+
* const client = createClient({ accessKey: 'ak-xxx' });
|
|
2442
|
+
* console.log(client.isOpenApiMode()); // true
|
|
2443
|
+
*
|
|
2444
|
+
* const cookieClient = createClient({});
|
|
2445
|
+
* console.log(cookieClient.isOpenApiMode()); // false
|
|
2446
|
+
* ```
|
|
2447
|
+
*/
|
|
2448
|
+
isOpenApiMode(): boolean;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
/**
|
|
2452
|
+
* User 客户端 - 用户信息相关 API
|
|
2453
|
+
*
|
|
2454
|
+
* @example
|
|
2455
|
+
* ```typescript
|
|
2456
|
+
* const userList = await client.user.getList();
|
|
2457
|
+
* console.log(userList);
|
|
2458
|
+
* ```
|
|
2459
|
+
*/
|
|
2460
|
+
declare class UserClient {
|
|
2461
|
+
private httpClient;
|
|
2462
|
+
constructor(httpClient: HttpClient);
|
|
2463
|
+
/**
|
|
2464
|
+
* 获取用户列表
|
|
2465
|
+
*
|
|
2466
|
+
* @returns 用户列表数组
|
|
2467
|
+
*/
|
|
2468
|
+
getList: () => Promise<User[]>;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
/**
|
|
2472
|
+
* API 命名空间 - 别名入口
|
|
2473
|
+
*
|
|
2474
|
+
* 推荐使用客户端方式:
|
|
2475
|
+
* - SQL: `client.sql.execute()`
|
|
2476
|
+
* - BFF: `client.bff.execute()`
|
|
2477
|
+
* - User: `client.user.getList()`
|
|
2478
|
+
*
|
|
2479
|
+
* 此命名空间提供向后兼容的别名:
|
|
2480
|
+
* - `client.api.sql()` → `client.sql.execute()`
|
|
2481
|
+
* - `client.api.bff()` → `client.bff.execute()`
|
|
2482
|
+
* - `client.api.getUserList()` → `client.user.getList()`
|
|
2483
|
+
*/
|
|
2484
|
+
declare class ApiNamespace {
|
|
2485
|
+
private httpClient;
|
|
2486
|
+
private appCode;
|
|
2487
|
+
constructor(httpClient: HttpClient, appCode: string);
|
|
2488
|
+
/**
|
|
2489
|
+
* SQL 客户端实例
|
|
2490
|
+
*/
|
|
2491
|
+
private _sql?;
|
|
2492
|
+
/**
|
|
2493
|
+
* SQL 查询别名 - 推荐使用 `client.sql.execute()`
|
|
2494
|
+
*
|
|
2495
|
+
* @example
|
|
2496
|
+
* ```typescript
|
|
2497
|
+
* // 推荐用法(对象参数)
|
|
2498
|
+
* const data = await client.sql.execute({
|
|
2499
|
+
* sqlCode: 'fc8e7777-06e3847d',
|
|
2500
|
+
* params: { userId: '123' }
|
|
2501
|
+
* });
|
|
2502
|
+
*
|
|
2503
|
+
* // 别名用法(兼容)
|
|
2504
|
+
* const data = await client.api.sql({
|
|
2505
|
+
* sqlCode: 'fc8e7777-06e3847d',
|
|
2506
|
+
* params: { userId: '123' }
|
|
2507
|
+
* });
|
|
2508
|
+
* ```
|
|
2509
|
+
*/
|
|
2510
|
+
get sql(): SqlClient["execute"];
|
|
2511
|
+
/**
|
|
2512
|
+
* SQL 查询别名(旧名称)- 向后兼容
|
|
2513
|
+
*
|
|
2514
|
+
* @deprecated 使用 `client.sql.execute()` 或 `client.api.sql()`
|
|
2515
|
+
*/
|
|
2516
|
+
get executeSql(): SqlClient["execute"];
|
|
2517
|
+
/**
|
|
2518
|
+
* BFF 客户端实例
|
|
2519
|
+
*/
|
|
2520
|
+
private _bff?;
|
|
2521
|
+
/**
|
|
2522
|
+
* BFF 查询别名 - 推荐使用 `client.bff.execute()`
|
|
2523
|
+
*
|
|
2524
|
+
* @example
|
|
2525
|
+
* ```typescript
|
|
2526
|
+
* // 推荐用法(对象参数)
|
|
2527
|
+
* const result = await client.bff.execute({
|
|
2528
|
+
* scriptName: 'getBundleTemplates'
|
|
2529
|
+
* });
|
|
2530
|
+
*
|
|
2531
|
+
* // 别名用法(兼容)
|
|
2532
|
+
* const result = await client.api.bff({
|
|
2533
|
+
* scriptName: 'getBundleTemplates'
|
|
2534
|
+
* });
|
|
2535
|
+
* ```
|
|
2536
|
+
*/
|
|
2537
|
+
get bff(): BffClient["execute"];
|
|
2538
|
+
/**
|
|
2539
|
+
* User 客户端实例
|
|
2540
|
+
*/
|
|
2541
|
+
private _user?;
|
|
2542
|
+
/**
|
|
2543
|
+
* User 查询别名 - 推荐使用 `client.user.getList()`
|
|
2544
|
+
*
|
|
2545
|
+
* @example
|
|
2546
|
+
* ```typescript
|
|
2547
|
+
* // 推荐用法
|
|
2548
|
+
* const userList = await client.user.getList();
|
|
2549
|
+
*
|
|
2550
|
+
* // 别名用法(兼容)
|
|
2551
|
+
* const userList = await client.api.getUserList();
|
|
2552
|
+
* ```
|
|
2553
|
+
*/
|
|
2554
|
+
get getUserList(): UserClient["getList"];
|
|
2555
|
+
/**
|
|
2556
|
+
* User 客户端别名 - 推荐使用 `client.user.getList()`
|
|
2557
|
+
*
|
|
2558
|
+
* @deprecated 使用 `client.user.getList()`
|
|
2559
|
+
*/
|
|
2560
|
+
get user(): {
|
|
2561
|
+
getList: UserClient["getList"];
|
|
2562
|
+
};
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
/**
|
|
2566
|
+
* Runtime OCR service.
|
|
2567
|
+
*
|
|
2568
|
+
* The public method is stable while the transport follows the configured auth mode:
|
|
2569
|
+
* - cookie: GET /api/ocr/recognize-text
|
|
2570
|
+
* - client-ak: POST /client/ocr
|
|
2571
|
+
*/
|
|
2572
|
+
declare class OcrClient implements OcrService {
|
|
2573
|
+
private readonly httpClient;
|
|
2574
|
+
private readonly appCode;
|
|
2575
|
+
private readonly authMode;
|
|
2576
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
2577
|
+
recognize(request: OcrRecognizeRequest): Promise<OcrRecognizeResponse>;
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
/** Runtime file upload and URL service. */
|
|
2581
|
+
declare class FileClient implements FileService {
|
|
2582
|
+
private readonly httpClient;
|
|
2583
|
+
private readonly appCode;
|
|
2584
|
+
private readonly authMode;
|
|
2585
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
2586
|
+
upload(request: FileUploadRequest): Promise<FileUploadResponse>;
|
|
2587
|
+
queryUrl(request: FileQueryUrlRequest): Promise<FileUrlResponse>;
|
|
2588
|
+
private assertSupportedAuthMode;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
/** Namespace for runtime services. */
|
|
2592
|
+
declare class ServicesNamespace implements LovrabetServices {
|
|
2593
|
+
readonly ocr: OcrClient;
|
|
2594
|
+
readonly file: FileClient;
|
|
2595
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
/** Personal BFF execution client exposed under `client.personal.bff`. */
|
|
2599
|
+
declare class PersonalBffClient implements PersonalBffService {
|
|
2600
|
+
private readonly httpClient;
|
|
2601
|
+
private readonly appCode;
|
|
2602
|
+
private readonly authMode;
|
|
2603
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
2604
|
+
execute<T = unknown>(request: PersonalBffExecuteRequest): Promise<T>;
|
|
2605
|
+
/** 列出当前用户的 Personal BFF(`GET {prefix}/runtime-bff/personal/list`) */
|
|
2606
|
+
list(): Promise<PersonalBffScript[]>;
|
|
2607
|
+
/** 获取 Personal BFF 详情(`GET {prefix}/runtime-bff/personal/{id}`) */
|
|
2608
|
+
get<T = PersonalBffScript>(scriptId: number): Promise<T>;
|
|
2609
|
+
/** 创建 Personal BFF(`POST {prefix}/runtime-bff/personal/create`) */
|
|
2610
|
+
create<T = PersonalBffScript>(request: PersonalBffUpsertRequest): Promise<T>;
|
|
2611
|
+
/** 更新 Personal BFF(`POST {prefix}/runtime-bff/personal/{id}/update`) */
|
|
2612
|
+
update<T = PersonalBffScript>(scriptId: number, request: PersonalBffUpsertRequest): Promise<T>;
|
|
2613
|
+
private path;
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
/** Namespace for resources owned by the current user. */
|
|
2617
|
+
declare class PersonalNamespace implements LovrabetPersonal {
|
|
2618
|
+
readonly bff: PersonalBffClient;
|
|
2619
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
/**
|
|
2623
|
+
* Lovrabet SDK 核心客户端类
|
|
2624
|
+
*
|
|
2625
|
+
* 设计原则:
|
|
2626
|
+
* 1. 实例化设计 - 避免全局状态,支持多项目并存
|
|
2627
|
+
* 2. 依赖注入 - 通过构造函数注入依赖,便于测试和扩展
|
|
2628
|
+
* 3. 配置不可变 - 创建后配置基本不可变,提高安全性
|
|
2629
|
+
* 4. 职责分离 - 认证、HTTP、模型管理各司其职
|
|
2630
|
+
*/
|
|
2631
|
+
declare class LovrabetClient implements LovrabetClient$1 {
|
|
2632
|
+
private config;
|
|
2633
|
+
private authManager;
|
|
2634
|
+
private httpClient;
|
|
2635
|
+
/**
|
|
2636
|
+
* 模型管理器 - 提供管理方法
|
|
2637
|
+
*/
|
|
2638
|
+
private modelManager;
|
|
2639
|
+
/**
|
|
2640
|
+
* 模型访问 Proxy - 纯粹的语法糖,支持 client.models.ModelName 访问
|
|
2641
|
+
* 内部调用 client.getModel() 方法,避免命名冲突
|
|
2642
|
+
*/
|
|
2643
|
+
models: {
|
|
2644
|
+
[modelName: string]: BaseModelMethods;
|
|
2645
|
+
};
|
|
2646
|
+
/**
|
|
2647
|
+
* SQL 客户端 - 执行自定义 SQL 查询
|
|
2648
|
+
* 根据认证模式自动选择:
|
|
2649
|
+
* - OpenAPI 模式:使用 OpenApiSqlClient(/openapi/data/custom-sql)
|
|
2650
|
+
* - WebAPI 模式:使用 SqlClient(/api/custom/executeSql)
|
|
2651
|
+
*/
|
|
2652
|
+
readonly sql: SqlClient | OpenApiSqlClient | ClientAkSqlClient;
|
|
2653
|
+
/**
|
|
2654
|
+
* BFF 客户端 - 调用 Backend For Frontend 端点
|
|
2655
|
+
*/
|
|
2656
|
+
readonly bff: BffClient | ClientAkBffClient;
|
|
2657
|
+
/**
|
|
2658
|
+
* User 客户端 - 用户信息相关 API
|
|
2659
|
+
*/
|
|
2660
|
+
readonly user: UserClient;
|
|
2661
|
+
/**
|
|
2662
|
+
* 平台服务命名空间 - OCR 等不绑定数据集或 BFF 的通用运行态能力
|
|
2663
|
+
*/
|
|
2664
|
+
readonly services: ServicesNamespace;
|
|
2665
|
+
/**
|
|
2666
|
+
* 当前用户拥有的资源,如个人 BFF。
|
|
2667
|
+
*/
|
|
2668
|
+
readonly personal: PersonalNamespace;
|
|
2669
|
+
/**
|
|
2670
|
+
* 权限、角色与成员(cookie / client-ak 双模式)。
|
|
2671
|
+
*
|
|
2672
|
+
* 后端同时提供 `/api/permit/*` 与 `/client/permit/*` 镜像。
|
|
2673
|
+
*/
|
|
2674
|
+
readonly permit: PermitClient;
|
|
2675
|
+
/**
|
|
2676
|
+
* Artifact 产物管理(仅 client-ak)。
|
|
2677
|
+
*/
|
|
2678
|
+
readonly artifact: ArtifactClient;
|
|
2679
|
+
/**
|
|
2680
|
+
* 审批任务(仅 client-ak)。
|
|
2681
|
+
*/
|
|
2682
|
+
readonly approval: ApprovalClient;
|
|
2683
|
+
/**
|
|
2684
|
+
* 应用、登录用户、应用配置与通知渠道(仅 client-ak)。
|
|
2685
|
+
*/
|
|
2686
|
+
readonly app: AppClient;
|
|
2687
|
+
/**
|
|
2688
|
+
* 数据集元信息与驱动配置(仅 client-ak)。
|
|
2689
|
+
*/
|
|
2690
|
+
readonly datasetMeta: DatasetMetaClient;
|
|
2691
|
+
/**
|
|
2692
|
+
* 脚本缓存与日志诊断(仅 cookie)。
|
|
2693
|
+
*/
|
|
2694
|
+
readonly management: ManagementClient;
|
|
2695
|
+
/**
|
|
2696
|
+
* API 命名空间 - 别名入口(向后兼容)
|
|
2697
|
+
*
|
|
2698
|
+
* 推荐使用命名空间方式:
|
|
2699
|
+
* - `client.sql.execute()` 而非 `client.api.sql()`
|
|
2700
|
+
* - `client.bff.execute()` 而非 `client.api.bff()`
|
|
2701
|
+
* - `client.user.getList()` 而非 `client.api.getUserList()`
|
|
2702
|
+
*/
|
|
2703
|
+
readonly api: ApiNamespace;
|
|
2704
|
+
constructor(config: ClientConfig);
|
|
2705
|
+
private validateConfig;
|
|
2706
|
+
/**
|
|
2707
|
+
* 运行时动态设置 token
|
|
2708
|
+
* 为什么需要这个方法:
|
|
2709
|
+
* 1. 用户登录后可能需要更新 token
|
|
2710
|
+
* 2. token 可能会过期需要刷新
|
|
2711
|
+
* 3. 支持动态认证切换(比如用户切换账号)
|
|
2712
|
+
*
|
|
2713
|
+
* @param token - 认证 token
|
|
2714
|
+
* @param timestamp - 与 token 配对的时间戳(OpenAPI 模式必需)
|
|
2715
|
+
*/
|
|
2716
|
+
setToken(token: string, timestamp?: number): void;
|
|
2717
|
+
/**
|
|
2718
|
+
* 获取当前配置的副本
|
|
2719
|
+
* 为什么返回副本而不是原始对象:
|
|
2720
|
+
* 1. 防止外部代码意外修改内部配置
|
|
2721
|
+
* 2. 遵循不可变性原则,保证配置稳定性
|
|
2722
|
+
*/
|
|
2723
|
+
getConfig(): ClientConfig;
|
|
2724
|
+
/**
|
|
2725
|
+
* 获取当前环境的 API 基础地址
|
|
2726
|
+
* 为什么需要这个方法:
|
|
2727
|
+
* 1. 用户可能需要知道当前使用的 API 地址用于调试
|
|
2728
|
+
* 2. 某些场景可能需要直接使用基础地址构造 URL
|
|
2729
|
+
* 3. 支持自定义服务器地址的覆盖逻辑
|
|
2730
|
+
*
|
|
2731
|
+
* 透传调用 HttpClient.getBaseUrl(),确保单一数据源
|
|
2732
|
+
*/
|
|
2733
|
+
getBaseUrl(): string;
|
|
2734
|
+
/**
|
|
2735
|
+
* 动态切换环境
|
|
2736
|
+
* 为什么允许运行时切换环境:
|
|
2737
|
+
* 1. 开发调试时可能需要在不同环境间切换
|
|
2738
|
+
* 2. 某些应用场景需要动态环境选择
|
|
2739
|
+
* 注意:这不会影响已缓存的模型实例
|
|
2740
|
+
*/
|
|
2741
|
+
setEnvironment(env: Environment$1): void;
|
|
2742
|
+
/**
|
|
2743
|
+
* 获取当前环境
|
|
2744
|
+
* 为什么提供这个方法:用户可能需要根据当前环境执行不同的逻辑
|
|
2745
|
+
*/
|
|
2746
|
+
getEnvironment(): Environment$1;
|
|
2747
|
+
/**
|
|
2748
|
+
* 获取所有可用模型列表
|
|
2749
|
+
* 为什么提供这个方法:
|
|
2750
|
+
* 1. 提供简单直接的模型发现方式
|
|
2751
|
+
* 2. 支持动态获取配置中的所有模型
|
|
2752
|
+
*/
|
|
2753
|
+
getModelList(): string[];
|
|
2754
|
+
/**
|
|
2755
|
+
* 获取所有模型的详细信息,包含别名和名称
|
|
2756
|
+
* 用于 UI 展示人类友好的模型列表
|
|
2757
|
+
*
|
|
2758
|
+
* @returns 模型详情数组,每个元素包含:
|
|
2759
|
+
* - value: 用于访问的 dataset_xxx 格式
|
|
2760
|
+
* - label: 人类友好的显示名称,格式为 "alias[name]" 或 "dataset_xxx"
|
|
2761
|
+
* - alias: 别名(如果有)
|
|
2762
|
+
* - name: 模型名称(如果有)
|
|
2763
|
+
* - datasetCode: 原始 datasetCode
|
|
2764
|
+
*/
|
|
2765
|
+
getModelListDetails(): Array<{
|
|
2766
|
+
value: string;
|
|
2767
|
+
label: string;
|
|
2768
|
+
alias?: string;
|
|
2769
|
+
name?: string;
|
|
2770
|
+
datasetCode: string;
|
|
2771
|
+
}>;
|
|
2772
|
+
/**
|
|
2773
|
+
* 根据索引或名称获取模型实例
|
|
2774
|
+
* 为什么提供这个方法:
|
|
2775
|
+
* 1. 提供统一的错误处理和类型安全
|
|
2776
|
+
* 2. 支持按索引快速获取第一个模型,便于演示和快速开发
|
|
2777
|
+
* 3. 作为 models.xxx 语法糖的底层实现
|
|
2778
|
+
*/
|
|
2779
|
+
getModel(indexOrName: number | string): BaseModelMethods;
|
|
2780
|
+
/**
|
|
2781
|
+
* 检查当前是否为 OpenAPI 模式
|
|
2782
|
+
*/
|
|
2783
|
+
isOpenApiMode(): boolean;
|
|
2784
|
+
/**
|
|
2785
|
+
* 创建使用当前登录用户身份的独立流程自定义页面客户端。
|
|
2786
|
+
*/
|
|
2787
|
+
flow(): LovrabetFlowClient;
|
|
2788
|
+
/**
|
|
2789
|
+
* 解析鉴权模式。无 authMode → cookie;有则严格遵循。
|
|
2790
|
+
*/
|
|
2791
|
+
private resolveAuthMode;
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
/**
|
|
2795
|
+
* 创建 Lovrabet 客户端实例 - SDK 的主要入口函数
|
|
2796
|
+
*
|
|
2797
|
+
* 设计理念:
|
|
2798
|
+
* 1. 多重载设计 - 支持 4 种不同的调用方式,满足各种使用场景
|
|
2799
|
+
* 2. 智能类型推断 - 根据参数类型自动选择不同的处理逻辑
|
|
2800
|
+
* 3. 配置优先级 - 明确的配置合并和覆盖规则
|
|
2801
|
+
* 4. 错误优先 - 在客户端创建阶段就发现配置问题
|
|
2802
|
+
*
|
|
2803
|
+
* 四种调用方式:
|
|
2804
|
+
*
|
|
2805
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
2806
|
+
* 方式 1:字符串 — 引用预注册的配置名称
|
|
2807
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
2808
|
+
* 适用场景:已在启动时通过 registerModels() 注册过配置,直接按名引用。
|
|
2809
|
+
* 示例:
|
|
2810
|
+
* registerModels({ appCode: 'my-app', models: [...] }, 'prod');
|
|
2811
|
+
* const client = createClient('prod');
|
|
2812
|
+
* 省略参数时等价于 createClient('default')。
|
|
2813
|
+
*
|
|
2814
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
2815
|
+
* 方式 2:ModelsConfig — 纯模型配置对象(仅 appCode + models)
|
|
2816
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
2817
|
+
* 适用场景:一次性创建客户端,无需预注册;传入最少字段即可。
|
|
2818
|
+
* 判断依据:对象同时包含 appCode 和 models,且不包含 env 等 ClientConfig 字段。
|
|
2819
|
+
* 示例:
|
|
2820
|
+
* const client = createClient({
|
|
2821
|
+
* appCode: 'my-app',
|
|
2822
|
+
* models: { chat: { modelId: 'gpt-4o' } },
|
|
2823
|
+
* });
|
|
2824
|
+
* 额外字段(如 runtimeDomain、token)会被透传到最终配置。
|
|
2825
|
+
*
|
|
2826
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
2827
|
+
* 方式 3:ClientConfig & { apiConfigName } — 引用注册配置 + 覆盖选项
|
|
2828
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
2829
|
+
* 适用场景:想复用预注册的模型定义,但需要自定义环境、认证等。
|
|
2830
|
+
* 合并策略:注册配置提供 appCode + models;其余字段由传入对象覆盖。
|
|
2831
|
+
* 示例:
|
|
2832
|
+
* registerModels({ appCode: 'my-app', models: [...] }, 'prod');
|
|
2833
|
+
* const client = createClient({
|
|
2834
|
+
* apiConfigName: 'prod', // 从注册表取模型
|
|
2835
|
+
* env: 'staging', // 覆盖为 staging 环境
|
|
2836
|
+
* token: 'xxx', // 附加认证信息
|
|
2837
|
+
* });
|
|
2838
|
+
*
|
|
2839
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
2840
|
+
* 方式 4:ClientConfig — 完整配置对象
|
|
2841
|
+
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
2842
|
+
* 适用场景:不依赖任何预注册配置,显式传入全部所需字段。
|
|
2843
|
+
* 示例:
|
|
2844
|
+
* const client = createClient({
|
|
2845
|
+
* appCode: 'my-app',
|
|
2846
|
+
* env: 'production',
|
|
2847
|
+
* models: { chat: { modelId: 'gpt-4o' } },
|
|
2848
|
+
* token: 'xxx',
|
|
2849
|
+
* });
|
|
2850
|
+
* env 缺省时自动填充 DEFAULTS.ENV;models 缺省时为 {}。
|
|
2851
|
+
*
|
|
2852
|
+
* @param config - 客户端配置,支持以下类型:
|
|
2853
|
+
* - string: 注册的配置名称(如 'default', 'prod')
|
|
2854
|
+
* - ModelsConfig: 纯模型配置对象
|
|
2855
|
+
* - ClientConfig: 完整的客户端配置对象
|
|
2856
|
+
* - ClientConfig & {apiConfigName}: 引用注册配置 + 额外选项
|
|
2857
|
+
* @returns Lovrabet client instance
|
|
2858
|
+
*/
|
|
2859
|
+
declare function createClient(config?: Partial<ClientConfig> | ModelsConfig | string): LovrabetClient;
|
|
2860
|
+
|
|
2861
|
+
/**
|
|
2862
|
+
* 模型配置注册器 - 全局配置管理中心
|
|
2863
|
+
*
|
|
2864
|
+
* 设计目的:
|
|
2865
|
+
* 1. 配置复用 - 避免在多处重复定义相同的模型配置
|
|
2866
|
+
* 2. 多项目支持 - 在同一应用中管理多个项目的配置
|
|
2867
|
+
* 3. 简化 API - 让 createClient() 可以无参数调用
|
|
2868
|
+
* 4. 类型安全 - 通过命名常量避免字符串拼写错误
|
|
2869
|
+
*/
|
|
2870
|
+
|
|
2871
|
+
/**
|
|
2872
|
+
* 注册模型配置
|
|
2873
|
+
*
|
|
2874
|
+
* 为什么需要这个函数:
|
|
2875
|
+
* 1. CLI 自动生成 - CLI 工具会调用此函数自动注册配置
|
|
2876
|
+
* 2. 手动配置场景 - 用户可以手动注册多个环境或项目的配置
|
|
2877
|
+
* 3. 配置集中管理 - 统一的地方管理所有模型配置
|
|
2878
|
+
*
|
|
2879
|
+
* @param config 模型配置对象
|
|
2880
|
+
* @param name 配置名称,默认为 'default'
|
|
2881
|
+
*/
|
|
2882
|
+
declare function registerModels(config: ModelsConfig, name?: string): void;
|
|
2883
|
+
/**
|
|
2884
|
+
* 获取已注册的模型配置
|
|
2885
|
+
* @param name 配置名称
|
|
2886
|
+
* @returns 模型配置对象
|
|
2887
|
+
*/
|
|
2888
|
+
declare function getRegisteredModels(name: string): ModelsConfig | undefined;
|
|
2889
|
+
/**
|
|
2890
|
+
* 获取所有已注册的配置名称
|
|
2891
|
+
* @returns 配置名称数组
|
|
2892
|
+
*/
|
|
2893
|
+
declare function getRegisteredConfigNames(): string[];
|
|
2894
|
+
/**
|
|
2895
|
+
* 清除指定配置
|
|
2896
|
+
* @param name 配置名称
|
|
2897
|
+
*/
|
|
2898
|
+
declare function unregisterModels(name: string): boolean;
|
|
2899
|
+
/**
|
|
2900
|
+
* 清除所有配置
|
|
2901
|
+
*/
|
|
2902
|
+
declare function clearAllRegistrations(): void;
|
|
2903
|
+
|
|
2904
|
+
/** Mainland China endpoints retained as the backward-compatible public export. */
|
|
2905
|
+
declare const API_ENDPOINTS: {
|
|
2906
|
+
readonly production: "https://runtime.lovrabet.com";
|
|
2907
|
+
readonly online: "https://runtime.lovrabet.com";
|
|
2908
|
+
readonly development: "https://dev.lovrabet.com";
|
|
2909
|
+
readonly daily: "https://daily-runtime.lovrabet.com";
|
|
2910
|
+
};
|
|
2911
|
+
type Environment = keyof typeof API_ENDPOINTS;
|
|
2912
|
+
/**
|
|
2913
|
+
* 获取指定环境的 API 端点(支持向下兼容)
|
|
2914
|
+
* @param env - 环境名称(支持 "production", "online", "daily", "dev", "development")
|
|
2915
|
+
* @param region - 官方节点;支持值来自生成的节点目录,省略时使用目录默认节点
|
|
2916
|
+
* @returns API 端点 URL
|
|
2917
|
+
*/
|
|
2918
|
+
declare function getApiEndpoint(env: Environment | string, region?: Region | string): string;
|
|
2919
|
+
/** Returns official regions supported by the SDK's built-in Runtime mapping. */
|
|
2920
|
+
declare function getAvailableRegions(): Region[];
|
|
2921
|
+
/**
|
|
2922
|
+
* 获取所有可用的环境
|
|
2923
|
+
* @returns 环境列表(返回标准化的环境名)
|
|
2924
|
+
*/
|
|
2925
|
+
declare function getAvailableEnvironments(): string[];
|
|
2926
|
+
|
|
2927
|
+
/**
|
|
2928
|
+
* 默认配置名称常量
|
|
2929
|
+
*/
|
|
2930
|
+
declare const CONFIG_NAMES: {
|
|
2931
|
+
/** 默认配置名称 */
|
|
2932
|
+
readonly DEFAULT: "default";
|
|
2933
|
+
/** 生产环境配置 */
|
|
2934
|
+
readonly PROD: "prod";
|
|
2935
|
+
/** 开发环境配置 */
|
|
2936
|
+
readonly DEV: "dev";
|
|
2937
|
+
/** 测试环境配置 */
|
|
2938
|
+
readonly TEST: "test";
|
|
2939
|
+
};
|
|
2940
|
+
/**
|
|
2941
|
+
* 环境常量
|
|
2942
|
+
*/
|
|
2943
|
+
declare const ENVIRONMENTS: {
|
|
2944
|
+
/** 线上环境(推荐使用 production) */
|
|
2945
|
+
readonly ONLINE: "online";
|
|
2946
|
+
/** 线上环境(新版推荐) */
|
|
2947
|
+
readonly PRODUCTION: "production";
|
|
2948
|
+
/** 日常环境 */
|
|
2949
|
+
readonly DAILY: "daily";
|
|
2950
|
+
/** 开发环境 */
|
|
2951
|
+
readonly DEVELOPMENT: "development";
|
|
2952
|
+
};
|
|
2953
|
+
/**
|
|
2954
|
+
* Lovrabet official deployment regions.
|
|
2955
|
+
*/
|
|
2956
|
+
declare const REGIONS: {
|
|
2957
|
+
readonly CN: "cn";
|
|
2958
|
+
readonly ID: "id";
|
|
2959
|
+
};
|
|
2960
|
+
/**
|
|
2961
|
+
* HTTP 状态码常量
|
|
2962
|
+
*/
|
|
2963
|
+
declare const HTTP_STATUS: {
|
|
2964
|
+
readonly OK: 200;
|
|
2965
|
+
readonly UNAUTHORIZED: 401;
|
|
2966
|
+
readonly FORBIDDEN: 403;
|
|
2967
|
+
readonly NOT_FOUND: 404;
|
|
2968
|
+
readonly INTERNAL_ERROR: 500;
|
|
2969
|
+
};
|
|
2970
|
+
/**
|
|
2971
|
+
* 默认配置值
|
|
2972
|
+
*/
|
|
2973
|
+
declare const DEFAULTS: {
|
|
2974
|
+
/** 默认环境(向下兼容 online,推荐使用 production) */
|
|
2975
|
+
readonly ENV: "production";
|
|
2976
|
+
/** 默认超时时间(毫秒) */
|
|
2977
|
+
readonly TIMEOUT: 30000;
|
|
2978
|
+
/** 默认重试次数 */
|
|
2979
|
+
readonly RETRY_COUNT: 3;
|
|
2980
|
+
/** 默认页大小 */
|
|
2981
|
+
readonly PAGE_SIZE: 20;
|
|
2982
|
+
/** 默认当前页 */
|
|
2983
|
+
readonly CURRENT_PAGE: 1;
|
|
2984
|
+
};
|
|
2985
|
+
/**
|
|
2986
|
+
* 错误消息常量
|
|
2987
|
+
*/
|
|
2988
|
+
declare const ERROR_MESSAGES: {
|
|
2989
|
+
readonly APP_CODE_REQUIRED: "appCode is required. Please provide it in the config or register models first.";
|
|
2990
|
+
readonly CONFIG_NOT_FOUND: (name: string) => string;
|
|
2991
|
+
readonly INVALID_ENV: "Invalid environment. Must be \"production\", \"online\" (deprecated), \"daily\", or \"development\".";
|
|
2992
|
+
readonly NETWORK_ERROR: "Network request failed";
|
|
2993
|
+
readonly UNAUTHORIZED: "Unauthorized access";
|
|
2994
|
+
readonly FORBIDDEN: "Access forbidden";
|
|
2995
|
+
readonly NOT_FOUND: "Resource not found";
|
|
2996
|
+
readonly SERVER_ERROR: "Internal server error";
|
|
2997
|
+
};
|
|
2998
|
+
/**
|
|
2999
|
+
* API 路径模板
|
|
3000
|
+
*/
|
|
3001
|
+
declare const API_PATHS: {
|
|
3002
|
+
/** 基础 API 路径模板 */
|
|
3003
|
+
readonly BASE: "/api/{appCode}/{datasetCode}";
|
|
3004
|
+
/** 列表查询路径 */
|
|
3005
|
+
readonly LIST: "";
|
|
3006
|
+
/** 单条记录路径 */
|
|
3007
|
+
readonly DETAIL: "/{id}";
|
|
3008
|
+
};
|
|
3009
|
+
|
|
3010
|
+
type ErrorDescription = string | Record<string, unknown> | unknown[];
|
|
3011
|
+
declare class LovrabetError extends Error {
|
|
3012
|
+
readonly name = "LovrabetError";
|
|
3013
|
+
readonly status?: number;
|
|
3014
|
+
readonly code?: string;
|
|
3015
|
+
readonly response?: any;
|
|
3016
|
+
readonly retryAfter?: string;
|
|
3017
|
+
readonly description?: ErrorDescription;
|
|
3018
|
+
readonly cause?: unknown;
|
|
3019
|
+
constructor(message: string, options?: {
|
|
3020
|
+
status?: number;
|
|
3021
|
+
code?: string;
|
|
3022
|
+
response?: any;
|
|
3023
|
+
retryAfter?: string;
|
|
3024
|
+
description?: ErrorDescription;
|
|
3025
|
+
cause?: unknown;
|
|
3026
|
+
});
|
|
3027
|
+
toJSON(): {
|
|
3028
|
+
description: ErrorDescription;
|
|
3029
|
+
cause: unknown;
|
|
3030
|
+
retryAfter?: string;
|
|
3031
|
+
name: string;
|
|
3032
|
+
message: string;
|
|
3033
|
+
status: number;
|
|
3034
|
+
code: string;
|
|
3035
|
+
response: any;
|
|
3036
|
+
};
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
/**
|
|
3040
|
+
* 安全执行结果类型
|
|
3041
|
+
*
|
|
3042
|
+
* @example
|
|
3043
|
+
* ```typescript
|
|
3044
|
+
* const { data, error } = await safe(client.models.customer.filter({ ... }));
|
|
3045
|
+
* if (error) {
|
|
3046
|
+
* console.error(error.message, error.description);
|
|
3047
|
+
* return;
|
|
3048
|
+
* }
|
|
3049
|
+
* // 使用 data
|
|
3050
|
+
* ```
|
|
3051
|
+
*/
|
|
3052
|
+
interface SafeResult<T> {
|
|
3053
|
+
/** 成功时的数据,失败时为 null */
|
|
3054
|
+
data: T | null;
|
|
3055
|
+
/** 失败时的错误对象,成功时为 null */
|
|
3056
|
+
error: LovrabetError | null;
|
|
3057
|
+
}
|
|
3058
|
+
/**
|
|
3059
|
+
* Promise 或返回 Promise 的函数类型
|
|
3060
|
+
*/
|
|
3061
|
+
type PromiseLike<T> = Promise<T> | (() => Promise<T>);
|
|
3062
|
+
/**
|
|
3063
|
+
* 安全执行 Promise,将异常转换为返回值
|
|
3064
|
+
*
|
|
3065
|
+
* @param fn - Promise 或返回 Promise 的函数
|
|
3066
|
+
* @returns 包含 data 和 error 的结果对象
|
|
3067
|
+
*
|
|
3068
|
+
* @example
|
|
3069
|
+
* ```typescript
|
|
3070
|
+
* // 直接传入 Promise
|
|
3071
|
+
* const { data, error } = await safe(client.models.customer.filter({ where: { status: 'active' } }));
|
|
3072
|
+
* if (error) {
|
|
3073
|
+
* console.error(error.message);
|
|
3074
|
+
* return;
|
|
3075
|
+
* }
|
|
3076
|
+
* console.log(data);
|
|
3077
|
+
*
|
|
3078
|
+
* // 传入函数(延迟执行)
|
|
3079
|
+
* const { data, error } = await safe(() => client.models.customer.filter({ ... }));
|
|
3080
|
+
*
|
|
3081
|
+
* // 旧代码继续工作(抛异常模式)
|
|
3082
|
+
* try {
|
|
3083
|
+
* const data = await client.models.customer.filter({ ... });
|
|
3084
|
+
* console.log(data);
|
|
3085
|
+
* } catch (error) {
|
|
3086
|
+
* console.error(error);
|
|
3087
|
+
* }
|
|
3088
|
+
* ```
|
|
3089
|
+
*/
|
|
3090
|
+
declare function safe<T>(fn: PromiseLike<T>): Promise<SafeResult<T>>;
|
|
3091
|
+
|
|
3092
|
+
/**
|
|
3093
|
+
* sqlSafe 执行结果类型
|
|
3094
|
+
*
|
|
3095
|
+
* @example
|
|
3096
|
+
* ```typescript
|
|
3097
|
+
* const { data, error } = await sqlSafe(() => client.sql.execute(...));
|
|
3098
|
+
* if (error) {
|
|
3099
|
+
* console.error(error.message, error.code, error.cause);
|
|
3100
|
+
* return;
|
|
3101
|
+
* }
|
|
3102
|
+
* // data 直接是查询结果数组
|
|
3103
|
+
* data.forEach(row => console.log(row));
|
|
3104
|
+
* ```
|
|
3105
|
+
*/
|
|
3106
|
+
interface SqlSafeResult<T> {
|
|
3107
|
+
/** 成功时的查询结果数组,失败时为 null */
|
|
3108
|
+
data: T[] | null;
|
|
3109
|
+
/** 失败时的错误对象,成功时为 null */
|
|
3110
|
+
error: LovrabetError | null;
|
|
3111
|
+
}
|
|
3112
|
+
/**
|
|
3113
|
+
* Promise 或返回 Promise 的函数类型
|
|
3114
|
+
*/
|
|
3115
|
+
type SqlPromiseLike<T> = Promise<SqlExecuteResult<T>> | (() => Promise<SqlExecuteResult<T>>);
|
|
3116
|
+
/**
|
|
3117
|
+
* 安全执行 SQL 查询,统一处理 HTTP 错误和业务逻辑错误
|
|
3118
|
+
*
|
|
3119
|
+
* @param fn - 返回 SqlExecuteResult 的 Promise 或函数
|
|
3120
|
+
* @returns 包含 data(查询结果数组)和 error 的结果对象
|
|
3121
|
+
*
|
|
3122
|
+
* @example
|
|
3123
|
+
* ```typescript
|
|
3124
|
+
* // 基础用法
|
|
3125
|
+
* const { data, error } = await sqlSafe(() =>
|
|
3126
|
+
* client.sql.execute({ sqlCode: 'fc8e7777-06e3847d' })
|
|
3127
|
+
* );
|
|
3128
|
+
*
|
|
3129
|
+
* if (error) {
|
|
3130
|
+
* console.error('查询失败:', error.message);
|
|
3131
|
+
* return;
|
|
3132
|
+
* }
|
|
3133
|
+
*
|
|
3134
|
+
* // data 直接是查询结果数组
|
|
3135
|
+
* console.log(`查询到 ${data.length} 条记录`);
|
|
3136
|
+
* data.forEach(row => console.log(row));
|
|
3137
|
+
*
|
|
3138
|
+
* // 带类型提示
|
|
3139
|
+
* interface UserStat {
|
|
3140
|
+
* id: number;
|
|
3141
|
+
* name: string;
|
|
3142
|
+
* login_count: number;
|
|
3143
|
+
* }
|
|
3144
|
+
*
|
|
3145
|
+
* const { data, error } = await sqlSafe<UserStat>(() =>
|
|
3146
|
+
* client.sql.execute({ sqlCode: 'user-stats' })
|
|
3147
|
+
* );
|
|
3148
|
+
*
|
|
3149
|
+
* if (error) {
|
|
3150
|
+
* if (error.code === 'SQL_ERROR') {
|
|
3151
|
+
* // 业务逻辑失败(execSuccess = false)
|
|
3152
|
+
* console.error('SQL 执行失败:', error.cause);
|
|
3153
|
+
* } else {
|
|
3154
|
+
* // HTTP 错误(404、500 等)
|
|
3155
|
+
* console.error('请求失败:', error.status, error.message);
|
|
3156
|
+
* }
|
|
3157
|
+
* return;
|
|
3158
|
+
* }
|
|
3159
|
+
*
|
|
3160
|
+
* // data 是 UserStat[]
|
|
3161
|
+
* data.forEach(stat => {
|
|
3162
|
+
* console.log(`${stat.name}: ${stat.login_count} 次登录`);
|
|
3163
|
+
* });
|
|
3164
|
+
* ```
|
|
3165
|
+
*/
|
|
3166
|
+
declare function sqlSafe<T>(fn: SqlPromiseLike<T>): Promise<SqlSafeResult<T>>;
|
|
3167
|
+
|
|
3168
|
+
/**
|
|
3169
|
+
* 抽象基础模型类
|
|
3170
|
+
* 定义所有模型的通用接口和基础实现
|
|
3171
|
+
*/
|
|
3172
|
+
declare abstract class AbstractBaseModel implements BaseModelMethods {
|
|
3173
|
+
/** 数据集代码(用于 API 调用) */
|
|
3174
|
+
protected datasetCode: string;
|
|
3175
|
+
/**
|
|
3176
|
+
* 模型名称,对应 ModelConfig.alias(人类可读别名)
|
|
3177
|
+
* @deprecated 直接使用 config.alias 或 datasetCode
|
|
3178
|
+
*/
|
|
3179
|
+
protected modelName: string;
|
|
3180
|
+
protected httpClient: HttpClient;
|
|
3181
|
+
protected config: ModelConfig;
|
|
3182
|
+
protected appCode: string;
|
|
3183
|
+
protected globalConfig: ClientConfig;
|
|
3184
|
+
/**
|
|
3185
|
+
* 构造函数
|
|
3186
|
+
* @param datasetCode 数据集代码
|
|
3187
|
+
* @param httpClient HTTP 客户端
|
|
3188
|
+
* @param globalConfig 全局配置
|
|
3189
|
+
* @param modelConfig 模型配置(直接传入,不再从 globalConfig 中查找)
|
|
3190
|
+
*/
|
|
3191
|
+
constructor(datasetCode: string, httpClient: HttpClient, globalConfig: ClientConfig, modelConfig: ModelConfig);
|
|
3192
|
+
protected abstract getApiPath(method: string): string;
|
|
3193
|
+
protected abstract buildRequestBody(method: string, data: any, sortList?: SortList): any;
|
|
3194
|
+
/**
|
|
3195
|
+
* 规范化列表响应:确保 paging 字段存在(兜底空对象)
|
|
3196
|
+
*/
|
|
3197
|
+
private normalizeListResponse;
|
|
3198
|
+
private normalizeAggregateParams;
|
|
3199
|
+
getList<T = any>(params?: ListParams, sortList?: SortList): Promise<ListResponse<T>>;
|
|
3200
|
+
filter<T = any>(params?: FilterParams): Promise<ListResponse<T>>;
|
|
3201
|
+
getOne<T = any>(idOrParams: string | number | {
|
|
3202
|
+
id: string | number;
|
|
3203
|
+
}): Promise<T>;
|
|
3204
|
+
create<T = any>(data: Record<string, any>): Promise<T>;
|
|
3205
|
+
batchCreate<T = any>(items: Record<string, any>[]): Promise<T>;
|
|
3206
|
+
/**
|
|
3207
|
+
* 更新记录,支持单条和批量。
|
|
3208
|
+
*
|
|
3209
|
+
* **推荐写法(对象合并)**:将 id 与更新字段合并为一个对象传入:
|
|
3210
|
+
* ```typescript
|
|
3211
|
+
* await model.update({ id: 1001, name: '张三' });
|
|
3212
|
+
* await model.update({ id: [1001, 1002], status: 'active' });
|
|
3213
|
+
* ```
|
|
3214
|
+
*
|
|
3215
|
+
* **兼容写法(id 分离)**:
|
|
3216
|
+
* ```typescript
|
|
3217
|
+
* await model.update(1001, { name: '张三' });
|
|
3218
|
+
* await model.update([1001, 1002, 1003], { status: 'active' });
|
|
3219
|
+
* ```
|
|
3220
|
+
*/
|
|
3221
|
+
update<T = any>(idOrData: string | number | (string | number)[] | {
|
|
3222
|
+
id: string | number | (string | number)[];
|
|
3223
|
+
[key: string]: any;
|
|
3224
|
+
}, data?: Record<string, any>): Promise<T>;
|
|
3225
|
+
/**
|
|
3226
|
+
* 删除记录,支持单条和批量。
|
|
3227
|
+
*
|
|
3228
|
+
* **推荐写法(对象传入)**:
|
|
3229
|
+
* ```typescript
|
|
3230
|
+
* await model.delete({ id: 1001 });
|
|
3231
|
+
* await model.delete({ id: [1001, 1002, 1003] });
|
|
3232
|
+
* ```
|
|
3233
|
+
*
|
|
3234
|
+
* **兼容写法(直接传 id)**:
|
|
3235
|
+
* ```typescript
|
|
3236
|
+
* await model.delete(1001);
|
|
3237
|
+
* await model.delete([1001, 1002, 1003]);
|
|
3238
|
+
* ```
|
|
3239
|
+
*/
|
|
3240
|
+
delete(idOrParams: string | number | (string | number)[] | {
|
|
3241
|
+
id: string | number | (string | number)[];
|
|
3242
|
+
}): Promise<void>;
|
|
3243
|
+
getSelectOptions(params: SelectOptionsParams): Promise<SelectOption[]>;
|
|
3244
|
+
excelExport<T = any>(params?: ListParams): Promise<T>;
|
|
3245
|
+
aggregate<T = any>(params?: AggregateParams): Promise<ListResponse<T>>;
|
|
3246
|
+
getConfig(): ModelConfig;
|
|
3247
|
+
/**
|
|
3248
|
+
* 获取模型名称(alias 优先,降级为 datasetCode)
|
|
3249
|
+
* @deprecated 建议直接使用 getConfig().alias 或 getConfig().datasetCode
|
|
3250
|
+
*/
|
|
3251
|
+
getModelName(): string;
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
/**
|
|
3255
|
+
* OpenAPI 模型实现
|
|
3256
|
+
* 处理 OpenAPI 模式下的 URL 生成和请求体构建
|
|
3257
|
+
*/
|
|
3258
|
+
declare class OpenApiModel extends AbstractBaseModel {
|
|
3259
|
+
/**
|
|
3260
|
+
* OpenAPI 模式的 URL 生成策略
|
|
3261
|
+
*/
|
|
3262
|
+
protected getApiPath(sdkMethod: string): string;
|
|
3263
|
+
/**
|
|
3264
|
+
* OpenAPI 模式的请求体构建策略
|
|
3265
|
+
* 认证信息(token、timeStamp)由 HttpClient 自动添加到请求头(Header)中
|
|
3266
|
+
* 请求体格式:{ appCode, datasetCode, paramMap };batchCreate 为数组体,使用 paramList(与 paramMap 互斥语义)
|
|
3267
|
+
*/
|
|
3268
|
+
protected buildRequestBody(method: string, data: any, sortList?: SortList): any;
|
|
3269
|
+
/**
|
|
3270
|
+
* OpenAPI 模式暂不支持 delete 操作
|
|
3271
|
+
* @throws LovrabetError 当尝试调用 delete 时抛出错误
|
|
3272
|
+
*/
|
|
3273
|
+
delete(): Promise<void>;
|
|
3274
|
+
/**
|
|
3275
|
+
* OpenAPI 模式暂不支持 excelExport 操作
|
|
3276
|
+
* @throws LovrabetError 当尝试调用 excelExport 时抛出错误
|
|
3277
|
+
*/
|
|
3278
|
+
excelExport(params?: any): Promise<any>;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
/**
|
|
3282
|
+
* WebAPI 模型实现
|
|
3283
|
+
* 处理 WebAPI 模式下的 URL 生成和请求体构建
|
|
3284
|
+
*/
|
|
3285
|
+
declare class WebApiModel extends AbstractBaseModel {
|
|
3286
|
+
/**
|
|
3287
|
+
* WebAPI 模式的 URL 生成策略
|
|
3288
|
+
*/
|
|
3289
|
+
protected getApiPath(sdkMethod: string): string;
|
|
3290
|
+
/**
|
|
3291
|
+
* WebAPI 模式的请求体构建策略
|
|
3292
|
+
*/
|
|
3293
|
+
protected buildRequestBody(method: string, data: any, sortList?: SortList): any;
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3296
|
+
/** 导入协商结果(后端 DatasetImportService.contract)。 */
|
|
3297
|
+
interface DatasetImportContract {
|
|
3298
|
+
schemaVersion: number;
|
|
3299
|
+
strategy: string;
|
|
3300
|
+
source: string;
|
|
3301
|
+
appCode: string;
|
|
3302
|
+
datasetCode: string;
|
|
3303
|
+
actorId: string;
|
|
3304
|
+
schemaFingerprint: string;
|
|
3305
|
+
maxBatchSize: number;
|
|
3306
|
+
maxBatchBytes: number;
|
|
3307
|
+
imageImport?: {
|
|
3308
|
+
version: number;
|
|
3309
|
+
maxFileBytes: number;
|
|
3310
|
+
maxPixels: number;
|
|
3311
|
+
types: string[];
|
|
3312
|
+
uploadId: string;
|
|
3313
|
+
};
|
|
3314
|
+
}
|
|
3315
|
+
/**
|
|
3316
|
+
* 可恢复导入的批次请求体(后端 `import-batch`)。
|
|
3317
|
+
*
|
|
3318
|
+
* 请求体必须包含 `schemaFingerprint` 与 `items`(1~500 条);
|
|
3319
|
+
* 传入 `taskId` 时走 auto-id 分支。
|
|
3320
|
+
*/
|
|
3321
|
+
interface DatasetImportBatchRequest {
|
|
3322
|
+
schemaFingerprint: string;
|
|
3323
|
+
items: Record<string, unknown>[];
|
|
3324
|
+
/** 正安全整数,以 JSON 数字发送。 */
|
|
3325
|
+
taskId?: number;
|
|
3326
|
+
}
|
|
3327
|
+
/**
|
|
3328
|
+
* 可恢复导入的批次响应(后端返回 `{ ids, count }`)。
|
|
3329
|
+
*/
|
|
3330
|
+
interface DatasetImportBatchResult {
|
|
3331
|
+
ids: number[];
|
|
3332
|
+
count: number;
|
|
3333
|
+
}
|
|
3334
|
+
/** 回读请求只允许 ids 或 taskId;ID 均须为安全整数。 */
|
|
3335
|
+
type DatasetImportReadbackRequest = {
|
|
3336
|
+
ids: number[];
|
|
3337
|
+
taskId?: never;
|
|
3338
|
+
} | {
|
|
3339
|
+
taskId: number;
|
|
3340
|
+
ids?: never;
|
|
3341
|
+
};
|
|
3342
|
+
/** 导入回读结果。 */
|
|
3343
|
+
interface DatasetImportReadbackResult<T = Record<string, unknown>> {
|
|
3344
|
+
items: T[];
|
|
3345
|
+
}
|
|
3346
|
+
/**
|
|
3347
|
+
* 图片上传参数(`import-image` 为 multipart/form-data)。
|
|
3348
|
+
*/
|
|
3349
|
+
interface DatasetImportImageRequest {
|
|
3350
|
+
importId: string;
|
|
3351
|
+
contentHash: string;
|
|
3352
|
+
file: Blob;
|
|
3353
|
+
fileName?: string;
|
|
3354
|
+
}
|
|
3355
|
+
/**
|
|
3356
|
+
* 图片回读参数(`import-image-readback` 的 body 必须恰好包含这四个字段)。
|
|
3357
|
+
*/
|
|
3358
|
+
interface DatasetImportImageReadbackRequest {
|
|
3359
|
+
importId: string;
|
|
3360
|
+
contentHash: string;
|
|
3361
|
+
type: string;
|
|
3362
|
+
size: number;
|
|
3363
|
+
}
|
|
3364
|
+
/** 图片上传及回读结果;missing 时仅返回 status 和 contentHash。 */
|
|
3365
|
+
interface DatasetImportImageResult {
|
|
3366
|
+
status: 'succeeded' | 'missing';
|
|
3367
|
+
contentHash: string;
|
|
3368
|
+
filePath?: string;
|
|
3369
|
+
fileName?: string;
|
|
3370
|
+
type?: string;
|
|
3371
|
+
size?: number;
|
|
3372
|
+
}
|
|
3373
|
+
/**
|
|
3374
|
+
* Client AK 模型实现
|
|
3375
|
+
*
|
|
3376
|
+
* 路由到 /client/{appCode}/{datasetCode}/ 前缀,
|
|
3377
|
+
* 鉴权使用 X-User-AK(由 AuthManager 在 HttpClient 层自动注入)。
|
|
3378
|
+
*
|
|
3379
|
+
* 请求体策略:直接透传(不包装 paramMap)。
|
|
3380
|
+
*
|
|
3381
|
+
* 除标准 CRUD 外,本类还承载 `import-*` 可恢复导入能力。
|
|
3382
|
+
* 这些方法只在 client-ak 模式可用,因此没有放进 `AbstractBaseModel`。
|
|
3383
|
+
* 通过 `client.models.X` 访问时需要显式收窄类型:
|
|
3384
|
+
* `client.getModel('X') as ClientAkModel`。
|
|
3385
|
+
*/
|
|
3386
|
+
declare class ClientAkModel extends AbstractBaseModel {
|
|
3387
|
+
protected getApiPath(sdkMethod: string): string;
|
|
3388
|
+
protected buildRequestBody(method: string, data: any, sortList?: SortList): any;
|
|
3389
|
+
/** 导入契约(`GET /client/{appCode}/{datasetCode}/import-contract`) */
|
|
3390
|
+
importContract<T = DatasetImportContract>(): Promise<T>;
|
|
3391
|
+
/** 批量导入(`POST /client/{appCode}/{datasetCode}/import-batch`) */
|
|
3392
|
+
importBatch(request: DatasetImportBatchRequest): Promise<DatasetImportBatchResult>;
|
|
3393
|
+
/** 回读导入结果(`POST /client/{appCode}/{datasetCode}/import-readback`) */
|
|
3394
|
+
importReadback<T = Record<string, unknown>>(request: number[] | DatasetImportReadbackRequest): Promise<DatasetImportReadbackResult<T>>;
|
|
3395
|
+
/** 上传导入图片(`POST /client/{appCode}/{datasetCode}/import-image`,multipart) */
|
|
3396
|
+
importImage<T = DatasetImportImageResult>(request: DatasetImportImageRequest): Promise<T>;
|
|
3397
|
+
/** 回读导入图片(`POST /client/{appCode}/{datasetCode}/import-image-readback`) */
|
|
3398
|
+
importImageReadback<T = DatasetImportImageResult>(request: DatasetImportImageReadbackRequest): Promise<T>;
|
|
3399
|
+
private importPath;
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
/**
|
|
3403
|
+
* 模型工厂类
|
|
3404
|
+
* 根据配置决定创建 OpenAPI、WebAPI 或 ClientAK 模型实例
|
|
3405
|
+
*
|
|
3406
|
+
* 规则:无 authMode → cookie(即 webapi);有 authMode 则严格遵循。
|
|
3407
|
+
*/
|
|
3408
|
+
declare class ModelFactory {
|
|
3409
|
+
static createModel(datasetCode: string, httpClient: HttpClient, globalConfig: ClientConfig, modelConfig: ModelConfig): BaseModelMethods;
|
|
3410
|
+
/**
|
|
3411
|
+
* 无 authMode → cookie(webapi);有 authMode 则严格遵循
|
|
3412
|
+
*/
|
|
3413
|
+
private static resolveAuthMode;
|
|
3414
|
+
static getModeName(config: ClientConfig): 'OpenAPI' | 'WebAPI' | 'ClientAK';
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3417
|
+
declare class AuthManager {
|
|
3418
|
+
private config;
|
|
3419
|
+
private openApiAuth?;
|
|
3420
|
+
private cookieAuth?;
|
|
3421
|
+
private clientAkAuth?;
|
|
3422
|
+
constructor(config: ClientConfig);
|
|
3423
|
+
private initAuthMethods;
|
|
3424
|
+
getAuthHeaders(appCode?: string, datasetCode?: string): Promise<AuthHeaders>;
|
|
3425
|
+
getFlowAuthContext(appCode: string, operatorUserId: string): Promise<OpenApiAuthContext>;
|
|
3426
|
+
validateAuth(): Promise<boolean>;
|
|
3427
|
+
isCookieAuth(): boolean;
|
|
3428
|
+
isClientAkAuth(): boolean;
|
|
3429
|
+
hasExplicitCookie(): boolean;
|
|
3430
|
+
setToken(token: string, timestamp?: number): void;
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
/**
|
|
3434
|
+
* 检查 Token 是否即将过期
|
|
3435
|
+
*
|
|
3436
|
+
* @param timestamp Token 的时间戳
|
|
3437
|
+
* @param bufferMinutes 提前多少分钟认为过期(默认1分钟)
|
|
3438
|
+
* @returns 是否即将过期
|
|
3439
|
+
*/
|
|
3440
|
+
declare function isTokenExpiring$1(timestamp: number, bufferMinutes?: number): boolean;
|
|
3441
|
+
/**
|
|
3442
|
+
* 计算 Token 剩余有效时间
|
|
3443
|
+
*
|
|
3444
|
+
* @param timestamp Token 的时间戳
|
|
3445
|
+
* @returns 剩余有效时间(毫秒),如果已过期返回 0
|
|
3446
|
+
*/
|
|
3447
|
+
declare function getTokenRemainingTime$1(timestamp: number): number;
|
|
3448
|
+
|
|
3449
|
+
/**
|
|
3450
|
+
* OpenAPI Token 生成工具
|
|
3451
|
+
*
|
|
3452
|
+
* 为 Node.js 服务端提供 token 生成功能,用于:
|
|
3453
|
+
* 1. 后端生成 token 和 timestamp 配对
|
|
3454
|
+
* 2. 返回给前端使用,避免前端存储 accessKey
|
|
3455
|
+
* 3. 保证 token 和 timestamp 的正确配对
|
|
3456
|
+
*/
|
|
3457
|
+
|
|
3458
|
+
/**
|
|
3459
|
+
* Token 生成参数
|
|
3460
|
+
*/
|
|
3461
|
+
interface GenerateTokenParams {
|
|
3462
|
+
/** 应用代码 */
|
|
3463
|
+
appCode: string;
|
|
3464
|
+
/** 数据集代码 */
|
|
3465
|
+
datasetCode: string;
|
|
3466
|
+
/** API 访问密钥 */
|
|
3467
|
+
accessKey: string;
|
|
3468
|
+
/** API 密钥(可选,有默认值) */
|
|
3469
|
+
secretKey?: string;
|
|
3470
|
+
/** 自定义时间戳(可选,默认为当前时间) */
|
|
3471
|
+
timestamp?: number;
|
|
3472
|
+
}
|
|
3473
|
+
/** Flow OpenAPI Token 生成参数。 */
|
|
3474
|
+
interface GenerateFlowTokenParams {
|
|
3475
|
+
/** 应用代码 */
|
|
3476
|
+
appCode: string;
|
|
3477
|
+
/** 本次 Flow 调用绑定的操作人用户 ID */
|
|
3478
|
+
operatorUserId: string;
|
|
3479
|
+
/** API 访问密钥 */
|
|
3480
|
+
accessKey: string;
|
|
3481
|
+
/** API 密钥(可选,有默认值) */
|
|
3482
|
+
secretKey?: string;
|
|
3483
|
+
/** 自定义时间戳(可选,默认为当前时间) */
|
|
3484
|
+
timestamp?: number;
|
|
3485
|
+
}
|
|
3486
|
+
/**
|
|
3487
|
+
* Token 生成结果
|
|
3488
|
+
*/
|
|
3489
|
+
interface TokenResult {
|
|
3490
|
+
/** 生成的 token */
|
|
3491
|
+
token: string;
|
|
3492
|
+
/** 配对的时间戳 */
|
|
3493
|
+
timestamp: number;
|
|
3494
|
+
/** Token 过期时间(10分钟后) */
|
|
3495
|
+
expiresAt: number;
|
|
3496
|
+
}
|
|
3497
|
+
/**
|
|
3498
|
+
* 生成 OpenAPI 认证 Token
|
|
3499
|
+
*
|
|
3500
|
+
* @description
|
|
3501
|
+
* 用于后端生成 token 和 timestamp 配对,返回给前端使用。
|
|
3502
|
+
* Token 有效期为 10 分钟,由服务端验证。
|
|
3503
|
+
*
|
|
3504
|
+
* @example
|
|
3505
|
+
* ```typescript
|
|
3506
|
+
* // Node.js 后端代码
|
|
3507
|
+
* import { generateOpenApiToken } from '@lovrabet/sdk';
|
|
3508
|
+
*
|
|
3509
|
+
* // 生成 token
|
|
3510
|
+
* const result = await generateOpenApiToken({
|
|
3511
|
+
* appCode: 'app-123',
|
|
3512
|
+
* datasetCode: 'dataset-456',
|
|
3513
|
+
* accessKey: process.env.ACCESS_KEY,
|
|
3514
|
+
* secretKey: process.env.SECRET_KEY // 可选
|
|
3515
|
+
* });
|
|
3516
|
+
*
|
|
3517
|
+
* // 返回给前端
|
|
3518
|
+
* res.json({
|
|
3519
|
+
* token: result.token,
|
|
3520
|
+
* timestamp: result.timestamp,
|
|
3521
|
+
* expiresAt: result.expiresAt
|
|
3522
|
+
* });
|
|
3523
|
+
* ```
|
|
3524
|
+
*
|
|
3525
|
+
* @param params Token 生成参数
|
|
3526
|
+
* @returns Token 和配对的 timestamp
|
|
3527
|
+
*/
|
|
3528
|
+
declare function generateOpenApiToken(params: GenerateTokenParams): Promise<TokenResult>;
|
|
3529
|
+
/**
|
|
3530
|
+
* 为浏览器或其他不保存 accessKey 的调用方生成 Flow OpenAPI Token。
|
|
3531
|
+
* Token 与 appCode、operatorUserId、timestamp 绑定,三者必须原样用于请求。
|
|
3532
|
+
*/
|
|
3533
|
+
declare function generateFlowOpenApiToken(params: GenerateFlowTokenParams): Promise<TokenResult>;
|
|
3534
|
+
/**
|
|
3535
|
+
* Token 生成器类(可选的面向对象接口)
|
|
3536
|
+
*
|
|
3537
|
+
* @example
|
|
3538
|
+
* ```typescript
|
|
3539
|
+
* const generator = new TokenGenerator({
|
|
3540
|
+
* accessKey: 'ak-xxx',
|
|
3541
|
+
* secretKey: 'sk-xxx'
|
|
3542
|
+
* });
|
|
3543
|
+
*
|
|
3544
|
+
* const result = await generator.generate({
|
|
3545
|
+
* appCode: 'app-123',
|
|
3546
|
+
* datasetCode: 'dataset-456'
|
|
3547
|
+
* });
|
|
3548
|
+
* ```
|
|
3549
|
+
*/
|
|
3550
|
+
declare class TokenGenerator {
|
|
3551
|
+
private accessKey;
|
|
3552
|
+
private secretKey;
|
|
3553
|
+
constructor(config: {
|
|
3554
|
+
accessKey: string;
|
|
3555
|
+
secretKey?: string;
|
|
3556
|
+
});
|
|
3557
|
+
/**
|
|
3558
|
+
* 生成 Token
|
|
3559
|
+
*/
|
|
3560
|
+
generate(params: {
|
|
3561
|
+
appCode: string;
|
|
3562
|
+
datasetCode: string;
|
|
3563
|
+
timestamp?: number;
|
|
3564
|
+
}): Promise<TokenResult>;
|
|
3565
|
+
/** 为指定操作人生成 Flow OpenAPI Token。 */
|
|
3566
|
+
generateFlow(params: {
|
|
3567
|
+
appCode: string;
|
|
3568
|
+
operatorUserId: string;
|
|
3569
|
+
timestamp?: number;
|
|
3570
|
+
}): Promise<TokenResult>;
|
|
3571
|
+
/**
|
|
3572
|
+
* 批量生成 Token(为多个数据集生成 token)
|
|
3573
|
+
*/
|
|
3574
|
+
generateBatch(params: {
|
|
3575
|
+
appCode: string;
|
|
3576
|
+
datasetCodes: string[];
|
|
3577
|
+
timestamp?: number;
|
|
3578
|
+
}): Promise<Map<string, TokenResult>>;
|
|
3579
|
+
}
|
|
3580
|
+
/**
|
|
3581
|
+
* 验证 Token 是否即将过期
|
|
3582
|
+
* @description 重新导出共享工具函数
|
|
3583
|
+
*/
|
|
3584
|
+
declare const isTokenExpiring: typeof isTokenExpiring$1;
|
|
3585
|
+
/**
|
|
3586
|
+
* 计算 Token 剩余有效时间
|
|
3587
|
+
* @description 重新导出共享工具函数
|
|
3588
|
+
*/
|
|
3589
|
+
declare const getTokenRemainingTime: typeof getTokenRemainingTime$1;
|
|
3590
|
+
|
|
3591
|
+
export { API_PATHS, AbstractBaseModel, ApiNamespace, AppClient, ApprovalClient, ArtifactClient, AuthManager, CONFIG_NAMES, ClientAkBffClient, ClientAkModel, ClientAkSqlClient, DEFAULTS, DatasetMetaClient, ENVIRONMENTS, ERROR_MESSAGES, FileClient, HTTP_STATUS, LovrabetError, LovrabetFlowClient, ManagementClient, ModelFactory, OCR_TYPES, OcrClient, OcrType, OpenApiModel, PermitClient, PersonalBffClient, PersonalNamespace, REGIONS, ServicesNamespace, SortOrder, TokenGenerator, WebApiModel, clearAllRegistrations, createAppClient, createClient, generateFlowOpenApiToken, generateOpenApiToken, getApiEndpoint, getAvailableEnvironments, getAvailableRegions, getRegisteredConfigNames, getRegisteredModels, getTokenRemainingTime, isTokenExpiring, registerModels, safe, sqlSafe, unregisterModels };
|
|
3592
|
+
export type { AggregateField, AggregateParams, AppClientConfig, AppDatasetActionRolePermitVO, AppDatasetPermitVO, AppDatasetRolePermitVO, AppEmployee, AppMenuPermitVO, AppPermitBaseVO, AppResourceMenuParam, AppRoleCreateParam, AppRolePermitQueryParam, AppRoleRequest, AppRoleUpdateParam, AppRoleUserVO, AppRoleVO, AppUserBaseVO, ApprovalFlowApproveRequest, ApprovalFlowIdentityLink, ApprovalFlowTaskDetail, ApprovalFlowTaskItem, ApprovalFlowTransferCandidate, ApprovalFlowTransferRequest, ApprovalTodoQuery, ArtifactListQuery, ArtifactUpsertRequest, AuthMode, BaseModelMethods, BaseRoleVO, ClientAkBffExecuteRequest, ClientConfig, ConditionOperator, CustomSqlQueryRequest, DataList, DatasetDrivenDataQuery, DatasetImportBatchRequest, DatasetImportBatchResult, DatasetImportContract, DatasetImportImageReadbackRequest, DatasetImportImageRequest, DatasetImportImageResult, DatasetImportReadbackRequest, DatasetImportReadbackResult, DatasetMeta, DatasetPermitListVO, DatasetRequest, DatasetRolePermitListVO, EndpointScriptSummary, Environment$1 as Environment, FieldCondition, FileQueryUrlRequest, FileService, FileUploadRequest, FileUploadResponse, FileUrlResponse, FilterParams, FlowBatchTaskActionRequest, FlowBatchTransferRequest, FlowCcQuery, FlowCcRequest, FlowCustomPageCcDetail, FlowCustomPageDefinition, FlowCustomPageStartResponse, FlowCustomPageSubmittedProcess, FlowCustomPageTaskDetail, FlowCustomPageTaskItem, FlowCustomPageTimeline, FlowDefinitionQuery, FlowPage, FlowPageQuery, FlowProcessReasonRequest, FlowRecord, FlowResubmitRequest, FlowReturnRequest, FlowReturnTarget, FlowStartRequest, FlowSubmittedQuery, FlowTaskActionRequest, FlowTransferRequest, FlowUpdateVariablesRequest, FlowVariableProjectionQuery, FlowVariableQuery, GenerateFlowTokenParams, GenerateTokenParams, HavingCondition, ListParams, ListResponse, LoginUserInfo, LovrabetClient$1 as LovrabetClient, LovrabetPersonal, LovrabetServices, MenuPermitDTO, MenuRolePermitListVO, MenuRolePermitNodeVO, ModelConfig, ModelsConfig, NotificationChannelConfig, OcrRecognizeRequest, OcrRecognizeResponse, OcrService, PageResult, Paging$1 as Paging, PersonalBffExecuteRequest, PersonalBffScript, PersonalBffService, PersonalBffUpsertRequest, PersonalRequestOptions, Region, ResourcePermitDTO, ResourcePermitParam, RoleUserUpdateParam, RuntimeArtifactDTO, RuntimeIdentityPermission, SafeResult, ScriptDefinition, ScriptLogQuery, SelectOption, SelectOptionsParams, ServiceRequestOptions, SmartApp, SortList, SqlExecuteRequest, SqlExecuteResult, SqlSafeResult, TokenResult, UserAccountBindRequest, UserAppRelation, UserAppRelationQueryParam, UserCustomSqlDTO, WhereCondition };
|