@lovrabet/sdk 1.5.1-beta.0 → 1.5.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/README.md +20 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/src/client/client.d.ts +5 -0
- package/dist/src/personal/bff-client.d.ts +11 -0
- package/dist/src/personal/index.d.ts +11 -0
- package/dist/src/personal/types.d.ts +18 -0
- package/dist/src/types/index.d.ts +37 -22
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { BffClient } from '../api/bff-client';
|
|
|
7
7
|
import { ClientAkBffClient } from '../api/client-ak-bff-client';
|
|
8
8
|
import { UserClient } from '../api/user-client';
|
|
9
9
|
import { ServicesNamespace } from '../services';
|
|
10
|
+
import { PersonalNamespace } from '../personal';
|
|
10
11
|
/**
|
|
11
12
|
* Lovrabet SDK 核心客户端类
|
|
12
13
|
*
|
|
@@ -50,6 +51,10 @@ export declare class LovrabetClient implements ILovrabetClient {
|
|
|
50
51
|
* 平台服务命名空间 - OCR 等不绑定数据集或 BFF 的通用运行态能力
|
|
51
52
|
*/
|
|
52
53
|
readonly services: ServicesNamespace;
|
|
54
|
+
/**
|
|
55
|
+
* 当前用户拥有的资源,如个人 BFF。
|
|
56
|
+
*/
|
|
57
|
+
readonly personal: PersonalNamespace;
|
|
53
58
|
/**
|
|
54
59
|
* API 命名空间 - 别名入口(向后兼容)
|
|
55
60
|
*
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HttpClient } from "../http/http-client";
|
|
2
|
+
import type { AuthMode } from "../types";
|
|
3
|
+
import type { PersonalBffExecuteRequest, PersonalBffService } from "./types";
|
|
4
|
+
/** Personal BFF execution client exposed under `client.personal.bff`. */
|
|
5
|
+
export declare class PersonalBffClient implements PersonalBffService {
|
|
6
|
+
private readonly httpClient;
|
|
7
|
+
private readonly appCode;
|
|
8
|
+
private readonly authMode;
|
|
9
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
10
|
+
execute<T = unknown>(request: PersonalBffExecuteRequest): Promise<T>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HttpClient } from "../http/http-client";
|
|
2
|
+
import type { AuthMode } from "../types";
|
|
3
|
+
import { PersonalBffClient } from "./bff-client";
|
|
4
|
+
import type { LovrabetPersonal } from "./types";
|
|
5
|
+
/** Namespace for resources owned by the current user. */
|
|
6
|
+
export declare class PersonalNamespace implements LovrabetPersonal {
|
|
7
|
+
readonly bff: PersonalBffClient;
|
|
8
|
+
constructor(httpClient: HttpClient, appCode: string, authMode: AuthMode);
|
|
9
|
+
}
|
|
10
|
+
export { PersonalBffClient } from "./bff-client";
|
|
11
|
+
export type { LovrabetPersonal, PersonalBffExecuteRequest, PersonalBffService, PersonalRequestOptions, } from "./types";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Per-request options supported by personal resource clients. */
|
|
2
|
+
export type PersonalRequestOptions = Omit<RequestInit, "method" | "body">;
|
|
3
|
+
/** Input accepted when executing a personal BFF. */
|
|
4
|
+
export interface PersonalBffExecuteRequest {
|
|
5
|
+
/** Positive integer identifier of the personal BFF script. */
|
|
6
|
+
scriptId: number;
|
|
7
|
+
/** Parameters passed to the personal BFF script. */
|
|
8
|
+
params?: Record<string, unknown>;
|
|
9
|
+
/** Optional fetch settings. The HTTP method and body are controlled by the SDK. */
|
|
10
|
+
options?: PersonalRequestOptions;
|
|
11
|
+
}
|
|
12
|
+
export interface PersonalBffService {
|
|
13
|
+
execute<T = unknown>(request: PersonalBffExecuteRequest): Promise<T>;
|
|
14
|
+
}
|
|
15
|
+
/** Personal resources exposed under `client.personal`. */
|
|
16
|
+
export interface LovrabetPersonal {
|
|
17
|
+
readonly bff: PersonalBffService;
|
|
18
|
+
}
|
|
@@ -105,15 +105,17 @@ export interface ListResponse<T> {
|
|
|
105
105
|
* 支持的操作符:
|
|
106
106
|
* - $eq: 等于
|
|
107
107
|
* - $ne: 不等于
|
|
108
|
-
* - $
|
|
109
|
-
* - $
|
|
108
|
+
* - $gt: 大于
|
|
109
|
+
* - $lt: 小于
|
|
110
|
+
* - $gte: 大于等于(推荐);$gteq 为兼容旧写法的别名,后端同样映射为 >=
|
|
111
|
+
* - $lte: 小于等于(推荐);$lteq 为兼容旧写法的别名,后端同样映射为 <=
|
|
110
112
|
* - $in: 在集合内
|
|
111
113
|
* - $contain: 包含(模糊匹配)
|
|
112
114
|
* - $startWith: 以...开头
|
|
113
115
|
* - $endWith: 以...结尾
|
|
114
116
|
* - $notNull: 非空判断
|
|
115
117
|
*/
|
|
116
|
-
export type ConditionOperator = "$eq" | "$ne" | "$gte" | "$gteq" | "$lte" | "$lteq" | "$in" | "$contain" | "$startWith" | "$endWith" | "$notNull";
|
|
118
|
+
export type ConditionOperator = "$eq" | "$ne" | "$gt" | "$lt" | "$gte" | "$gteq" | "$lte" | "$lteq" | "$in" | "$contain" | "$startWith" | "$endWith" | "$notNull";
|
|
117
119
|
/**
|
|
118
120
|
* 字段条件类型
|
|
119
121
|
* @description 单个字段的查询条件
|
|
@@ -423,7 +425,7 @@ export interface ClientConfig {
|
|
|
423
425
|
env?: Environment;
|
|
424
426
|
/** 官方运行节点,默认为 'cn';显式 runtimeDomain 的优先级更高。 */
|
|
425
427
|
region?: Region;
|
|
426
|
-
/**
|
|
428
|
+
/** 预计算 OpenAPI token,配合 timestamp 通过 X-Token / X-Time-Stamp 传递,不是 Authorization: Bearer */
|
|
427
429
|
token?: string;
|
|
428
430
|
/** 与 token 配对的时间戳(OpenAPI 模式必需) */
|
|
429
431
|
timestamp?: number;
|
|
@@ -433,9 +435,17 @@ export interface ClientConfig {
|
|
|
433
435
|
secretKey?: string;
|
|
434
436
|
/** Cookie 字符串,用于 Cookie 认证(Node.js 环境专用) */
|
|
435
437
|
cookie?: string;
|
|
436
|
-
/**
|
|
438
|
+
/**
|
|
439
|
+
* 显式要求当前 authMode 下的凭据已经齐全时设为 true。
|
|
440
|
+
* 未设置时不做强制检查(没有默认 true)。
|
|
441
|
+
* 校验按 authMode:client-ak 需要 accessKey;openapi 需要 accessKey,或 token + timestamp;
|
|
442
|
+
* cookie / 缺省不能把 token、accessKey 当成已生效的 Cookie 认证。
|
|
443
|
+
*/
|
|
437
444
|
requiresAuth?: boolean;
|
|
438
|
-
/**
|
|
445
|
+
/**
|
|
446
|
+
* 显式声明鉴权模式。**未设置时固定回退到 cookie 模式**,不会根据 accessKey / token 等字段自动推断;
|
|
447
|
+
* 需要 Client AK / OpenAPI 鉴权时必须显式设置(`"client-ak"` 或 `"openapi"`)。
|
|
448
|
+
*/
|
|
439
449
|
authMode?: AuthMode;
|
|
440
450
|
/**
|
|
441
451
|
* 模型配置
|
|
@@ -492,7 +502,7 @@ export interface BaseModelMethods {
|
|
|
492
502
|
* @template T 返回数据的类型
|
|
493
503
|
* @param params Filter 查询参数,支持复杂条件、字段选择、排序和分页
|
|
494
504
|
* @returns 返回分页数据
|
|
495
|
-
* @description 提供比 getList 更强大的查询能力,支持复杂的 where
|
|
505
|
+
* @description 提供比 getList 更强大的查询能力,支持复杂的 where 条件、字段选择等(filter 在 WebAPI / OpenAPI / Client AK 模式均支持;delete、excelExport、getSelectOptions 当前不支持 OpenAPI 模式,WebAPI 与 Client AK 均支持)
|
|
496
506
|
* @example
|
|
497
507
|
* ```typescript
|
|
498
508
|
* // 使用枚举
|
|
@@ -573,7 +583,7 @@ export interface BaseModelMethods {
|
|
|
573
583
|
update<T = any>(id: string | number | (string | number)[], data: Record<string, any>): Promise<T>;
|
|
574
584
|
/**
|
|
575
585
|
* 删除数据,支持单条和批量
|
|
576
|
-
* @throws Error OpenAPI
|
|
586
|
+
* @throws Error OpenAPI 模式暂不支持此操作;WebAPI 与 Client AK 模式均可用
|
|
577
587
|
*
|
|
578
588
|
* **推荐写法(对象传入)**:
|
|
579
589
|
* ```typescript
|
|
@@ -595,7 +605,7 @@ export interface BaseModelMethods {
|
|
|
595
605
|
* 获取下拉选项
|
|
596
606
|
* @param params 字段映射参数,指定用作 value 和 label 的字段名
|
|
597
607
|
* @returns 返回下拉选项数组
|
|
598
|
-
* @description 用于获取数据表的下拉选项数据,适用于 Select
|
|
608
|
+
* @description 用于获取数据表的下拉选项数据,适用于 Select 组件(WebAPI 与 Client AK 模式支持,OpenAPI 模式不支持)
|
|
599
609
|
* @example
|
|
600
610
|
* ```typescript
|
|
601
611
|
* // 获取用户下拉选项
|
|
@@ -611,7 +621,7 @@ export interface BaseModelMethods {
|
|
|
611
621
|
* 导出数据为 Excel 文件
|
|
612
622
|
* @param params 查询参数(可选),与 getList 参数一致,用于按条件筛选导出数据
|
|
613
623
|
* @returns 返回导出文件的 URL 地址(字符串),可直接用于下载
|
|
614
|
-
* @description 导出当前数据集的数据为 Excel
|
|
624
|
+
* @description 导出当前数据集的数据为 Excel 文件(WebAPI 与 Client AK 模式支持,OpenAPI 模式不支持)
|
|
615
625
|
* @example
|
|
616
626
|
* ```typescript
|
|
617
627
|
* // 导出所有数据
|
|
@@ -738,14 +748,14 @@ export interface ModelManager {
|
|
|
738
748
|
}
|
|
739
749
|
/**
|
|
740
750
|
* 认证请求头接口
|
|
741
|
-
* @description 包含认证信息的 HTTP
|
|
751
|
+
* @description 包含认证信息的 HTTP 请求头。实际字段由 authMode 决定,不是 Authorization: Bearer。
|
|
742
752
|
* @example
|
|
743
753
|
* ```typescript
|
|
744
|
-
* //
|
|
745
|
-
* { "
|
|
754
|
+
* // OpenAPI:预计算 token 或 accessKey 签名
|
|
755
|
+
* { "X-Token": "…", "X-Time-Stamp": "…", "X-App-Code": "app-xxx", "X-Dataset-Code": "…" }
|
|
746
756
|
*
|
|
747
|
-
* //
|
|
748
|
-
* { "X-
|
|
757
|
+
* // Client AK
|
|
758
|
+
* { "X-User-AK": "your-access-key" }
|
|
749
759
|
* ```
|
|
750
760
|
*/
|
|
751
761
|
export interface AuthHeaders {
|
|
@@ -770,16 +780,14 @@ export interface OpenApiAuthConfig {
|
|
|
770
780
|
}
|
|
771
781
|
/**
|
|
772
782
|
* 认证管理器接口
|
|
773
|
-
* @description
|
|
774
|
-
* 认证优先级:Token > OpenAPI密钥 > Cookie
|
|
783
|
+
* @description 按显式 authMode 选择认证策略;未设置 authMode 时固定为 cookie,不会按 token / accessKey 自动升级。
|
|
775
784
|
* @example
|
|
776
785
|
* ```typescript
|
|
777
|
-
* //
|
|
778
|
-
* authManager.setToken('your-token');
|
|
786
|
+
* // OpenAPI 预计算 token 必须配对 timestamp
|
|
787
|
+
* authManager.setToken('your-token', Date.now());
|
|
779
788
|
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
* // 返回: { "Authorization": "Bearer your-token" }
|
|
789
|
+
* const headers = await authManager.getAuthHeaders(appCode, datasetCode);
|
|
790
|
+
* // 返回: { "X-Token": "…", "X-Time-Stamp": "…" }
|
|
783
791
|
* ```
|
|
784
792
|
*/
|
|
785
793
|
export interface AuthManager {
|
|
@@ -836,6 +844,13 @@ export interface AuthManager {
|
|
|
836
844
|
export interface LovrabetClient {
|
|
837
845
|
/** 运行态通用服务,如文件与 OCR。 */
|
|
838
846
|
readonly services: import("../services/types").LovrabetServices;
|
|
847
|
+
/**
|
|
848
|
+
* 当前用户拥有的资源,如个人 BFF。
|
|
849
|
+
*
|
|
850
|
+
* 该公共接口允许兼容旧版或外部注入的 client;createClient() 返回的
|
|
851
|
+
* 具体 LovrabetClient 实例始终提供 personal。
|
|
852
|
+
*/
|
|
853
|
+
readonly personal?: import("../personal/types").LovrabetPersonal;
|
|
839
854
|
/**
|
|
840
855
|
* 模型访问接口 - 纯粹的语法糖,支持 client.models.ModelName 访问
|
|
841
856
|
* @description 内部调用 client.getModel() 方法,提供更简洁的访问方式
|