qing-client 0.0.53 → 0.0.55
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 +4 -0
- package/lib/client/BaseClient.js +1 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +8 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -1
- package/lib/service/ImService.d.ts +19 -0
- package/lib/service/ImService.js +35 -0
- package/lib/types/im.d.ts +28 -0
- package/lib/types/im.js +4 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* **提供商与用量**(provider、usage)
|
|
11
11
|
* **组织与多租户**(org)
|
|
12
12
|
* **投递流与 Ez 能力**(deliveryStream、ezAbility)
|
|
13
|
+
* **IM 群组**(im:群组创建、列表、入群门槛等)
|
|
13
14
|
* **静态 HTML 托管**(gateway-h5,frontHost)
|
|
14
15
|
|
|
15
16
|
该 SDK 为 **公开 npm 包**,任何 **拥有合法账号的第三方开发者** 均可使用。
|
|
@@ -142,6 +143,7 @@ const client = new Client({
|
|
|
142
143
|
gatewayH5ServiceUrl: "http://gateway-h5-service",
|
|
143
144
|
deliveryStreamServiceUrl: "http://delivery-stream-service",
|
|
144
145
|
ezAbilityServiceUrl: "http://ez-ability-service",
|
|
146
|
+
imServiceUrl: "http://im-service",
|
|
145
147
|
});
|
|
146
148
|
```
|
|
147
149
|
|
|
@@ -182,6 +184,7 @@ client.setUserContext({
|
|
|
182
184
|
| `client.frontHost` | 静态 HTML 托管(gateway-h5) |
|
|
183
185
|
| `client.deliveryStream` | 投递流 |
|
|
184
186
|
| `client.ezAbility` | Ez 能力 |
|
|
187
|
+
| `client.im` | IM 群组(群组管理、入群门槛等) |
|
|
185
188
|
|
|
186
189
|
`client.files` 与 `client.file` 指向同一后端(fileServiceUrl),仅路径前缀不同;也可单独 `import { FileService } from "qing-client"` 并传入配置(如 `new FileService(config, 'files')` 或 `'file'`)。
|
|
187
190
|
|
|
@@ -277,6 +280,7 @@ client.setUserContext({
|
|
|
277
280
|
- **client.org**:组织/项目/应用 CRUD、解析等,见 `OrgService` 与 `types/org`。
|
|
278
281
|
- **client.deliveryStream**:投递流、版本、需求等,见 `DeliveryStreamService` 与 `types/delivery-stream`。
|
|
279
282
|
- **client.ezAbility**:需求枚举、PRD/MVPRD 生成、任务查询等,见 `EzAbilityService` 与 `types/ez-ability`。
|
|
283
|
+
- **client.im**:群组创建、列表;支持 `pid`/`org_id`、`memberIds`、入群门槛(requireAdmin/requireSuperAdmin),见 `ImService` 与 `types/im`。
|
|
280
284
|
- **client.files / client.file**:文件服务(files 为新路由,file 兼容老项目);方法同下。
|
|
281
285
|
- **FileService**(独立实例):`createFile`、`getFileById`、`listFiles`、`getStorageStats`、`generateOSSUploadSign`、`getFolderTree`、`getDownloadUrl` 等,见 `FileService` 与 `types/file`。构造时可选 `new FileService(config, 'files')` 或 `'file'`。
|
|
282
286
|
|
package/lib/client/BaseClient.js
CHANGED
|
@@ -164,6 +164,7 @@ class BaseClient {
|
|
|
164
164
|
case "org": return this.config.orgServiceUrl; // 组织感知服务
|
|
165
165
|
case "gateway-h5": return this.config.gatewayH5ServiceUrl;
|
|
166
166
|
case "ez-ability": return this.config.ezAbilityServiceUrl; // EzAI 能力服务
|
|
167
|
+
case "im": return this.config.imServiceUrl; // IM 群组服务
|
|
167
168
|
default: throw new Error(`Unsupported service: ${this.serviceName}`);
|
|
168
169
|
}
|
|
169
170
|
}
|
package/lib/client/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { FrontHostService } from "../service/FrontHostService";
|
|
|
12
12
|
import { OrgService } from "../service/OrgService";
|
|
13
13
|
import { DeliveryStreamService } from "../service/DeliveryStreamService";
|
|
14
14
|
import { EzAbilityService } from "../service/EzAbilityService";
|
|
15
|
+
import { ImService } from "../service/ImService";
|
|
15
16
|
import { ClientConfig, UserContext } from "../types";
|
|
16
17
|
export declare class Client {
|
|
17
18
|
protected config: ClientConfig;
|
|
@@ -32,6 +33,8 @@ export declare class Client {
|
|
|
32
33
|
readonly org: OrgService;
|
|
33
34
|
readonly deliveryStream: DeliveryStreamService;
|
|
34
35
|
readonly ezAbility: EzAbilityService;
|
|
36
|
+
/** IM 群组服务(群组创建、列表等) */
|
|
37
|
+
readonly im: ImService;
|
|
35
38
|
protected isFrontendMode: boolean;
|
|
36
39
|
constructor(config: ClientConfig);
|
|
37
40
|
setUserContext(context: UserContext): this;
|
package/lib/client/index.js
CHANGED
|
@@ -15,6 +15,7 @@ const FrontHostService_1 = require("../service/FrontHostService");
|
|
|
15
15
|
const OrgService_1 = require("../service/OrgService");
|
|
16
16
|
const DeliveryStreamService_1 = require("../service/DeliveryStreamService");
|
|
17
17
|
const EzAbilityService_1 = require("../service/EzAbilityService");
|
|
18
|
+
const ImService_1 = require("../service/ImService");
|
|
18
19
|
class Client {
|
|
19
20
|
constructor(config) {
|
|
20
21
|
this.config = config;
|
|
@@ -34,6 +35,7 @@ class Client {
|
|
|
34
35
|
this.org = new OrgService_1.OrgService(config);
|
|
35
36
|
this.deliveryStream = new DeliveryStreamService_1.DeliveryStreamService(config);
|
|
36
37
|
this.ezAbility = new EzAbilityService_1.EzAbilityService(config);
|
|
38
|
+
this.im = new ImService_1.ImService(config);
|
|
37
39
|
}
|
|
38
40
|
// 后端模式:设置用户上下文
|
|
39
41
|
setUserContext(context) {
|
|
@@ -53,6 +55,7 @@ class Client {
|
|
|
53
55
|
this.org.setUserContext(context);
|
|
54
56
|
this.deliveryStream.setUserContext(context);
|
|
55
57
|
this.ezAbility.setUserContext(context);
|
|
58
|
+
this.im.setUserContext(context);
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
58
61
|
console.warn("setUserContext() 仅在后端模式下有效");
|
|
@@ -77,6 +80,7 @@ class Client {
|
|
|
77
80
|
this.org.setProjectId(projectId);
|
|
78
81
|
this.deliveryStream.setProjectId(projectId);
|
|
79
82
|
this.ezAbility.setProjectId(projectId);
|
|
83
|
+
this.im.setProjectId(projectId);
|
|
80
84
|
}
|
|
81
85
|
else {
|
|
82
86
|
console.warn("setProjectId() 仅在前端模式下有效");
|
|
@@ -101,6 +105,7 @@ class Client {
|
|
|
101
105
|
this.org.setAppId(appId);
|
|
102
106
|
this.deliveryStream.setAppId(appId);
|
|
103
107
|
this.ezAbility.setAppId(appId);
|
|
108
|
+
this.im.setAppId(appId);
|
|
104
109
|
}
|
|
105
110
|
else {
|
|
106
111
|
console.warn("setAppId() 仅在前端模式下有效");
|
|
@@ -125,6 +130,7 @@ class Client {
|
|
|
125
130
|
this.org.setProjectAndApp(projectId, appId);
|
|
126
131
|
this.deliveryStream.setProjectAndApp(projectId, appId);
|
|
127
132
|
this.ezAbility.setProjectAndApp(projectId, appId);
|
|
133
|
+
this.im.setProjectAndApp(projectId, appId);
|
|
128
134
|
}
|
|
129
135
|
else {
|
|
130
136
|
console.warn("setProjectAndApp() 仅在前端模式下有效");
|
|
@@ -148,6 +154,7 @@ class Client {
|
|
|
148
154
|
await this.org.setToken(token);
|
|
149
155
|
await this.deliveryStream.setToken(token);
|
|
150
156
|
await this.ezAbility.setToken(token);
|
|
157
|
+
await this.im.setToken(token);
|
|
151
158
|
}
|
|
152
159
|
// 清除认证令牌(两种模式都需要)
|
|
153
160
|
async clearToken() {
|
|
@@ -166,6 +173,7 @@ class Client {
|
|
|
166
173
|
await this.org.clearToken();
|
|
167
174
|
await this.deliveryStream.clearToken();
|
|
168
175
|
await this.ezAbility.clearToken();
|
|
176
|
+
await this.im.clearToken();
|
|
169
177
|
}
|
|
170
178
|
}
|
|
171
179
|
exports.Client = Client;
|
package/lib/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { UsageService } from "./service/UsageService";
|
|
|
12
12
|
export { OrgService } from "./service/OrgService";
|
|
13
13
|
export { DeliveryStreamService } from "./service/DeliveryStreamService";
|
|
14
14
|
export { EzAbilityService } from "./service/EzAbilityService";
|
|
15
|
+
export { ImService } from "./service/ImService";
|
|
15
16
|
export * from './types';
|
|
16
17
|
export * from './types/msg';
|
|
17
18
|
export * from './types/token';
|
|
@@ -27,3 +28,4 @@ export * from "./types/usage";
|
|
|
27
28
|
export * from "./types/org";
|
|
28
29
|
export * from "./types/delivery-stream";
|
|
29
30
|
export * from "./types/ez-ability";
|
|
31
|
+
export * from "./types/im";
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.BaseClient = exports.EzAbilityService = exports.DeliveryStreamService = exports.OrgService = exports.UsageService = exports.ProviderService = exports.FrontHostService = exports.AuditLogService = exports.AigcService = exports.FileService = exports.UserService = exports.TokenService = exports.MsgService = exports.AuthService = exports.Client = void 0;
|
|
17
|
+
exports.BaseClient = exports.ImService = exports.EzAbilityService = exports.DeliveryStreamService = exports.OrgService = exports.UsageService = exports.ProviderService = exports.FrontHostService = exports.AuditLogService = exports.AigcService = exports.FileService = exports.UserService = exports.TokenService = exports.MsgService = exports.AuthService = exports.Client = void 0;
|
|
18
18
|
// 导出核心客户端类
|
|
19
19
|
var client_1 = require("./client");
|
|
20
20
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
@@ -45,6 +45,8 @@ var DeliveryStreamService_1 = require("./service/DeliveryStreamService");
|
|
|
45
45
|
Object.defineProperty(exports, "DeliveryStreamService", { enumerable: true, get: function () { return DeliveryStreamService_1.DeliveryStreamService; } });
|
|
46
46
|
var EzAbilityService_1 = require("./service/EzAbilityService");
|
|
47
47
|
Object.defineProperty(exports, "EzAbilityService", { enumerable: true, get: function () { return EzAbilityService_1.EzAbilityService; } });
|
|
48
|
+
var ImService_1 = require("./service/ImService");
|
|
49
|
+
Object.defineProperty(exports, "ImService", { enumerable: true, get: function () { return ImService_1.ImService; } });
|
|
48
50
|
// 导出所有类型定义
|
|
49
51
|
__exportStar(require("./types"), exports);
|
|
50
52
|
__exportStar(require("./types/msg"), exports);
|
|
@@ -61,3 +63,4 @@ __exportStar(require("./types/usage"), exports);
|
|
|
61
63
|
__exportStar(require("./types/org"), exports);
|
|
62
64
|
__exportStar(require("./types/delivery-stream"), exports);
|
|
63
65
|
__exportStar(require("./types/ez-ability"), exports);
|
|
66
|
+
__exportStar(require("./types/im"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseClient } from "../client/BaseClient";
|
|
2
|
+
import { ClientConfig, RequestOptions, PaginatedResponse } from "../types";
|
|
3
|
+
import { Group, CreateGroupRequest, GroupListQuery } from "../types/im";
|
|
4
|
+
/**
|
|
5
|
+
* IM 群组服务 SDK(im-service /api/v1/groups)
|
|
6
|
+
*/
|
|
7
|
+
export declare class ImService extends BaseClient {
|
|
8
|
+
constructor(config: ClientConfig);
|
|
9
|
+
/**
|
|
10
|
+
* 创建群组
|
|
11
|
+
* POST /groups
|
|
12
|
+
*/
|
|
13
|
+
createGroup(request: CreateGroupRequest, options?: RequestOptions): Promise<Group>;
|
|
14
|
+
/**
|
|
15
|
+
* 群组列表(当前项目+组织下)
|
|
16
|
+
* GET /groups
|
|
17
|
+
*/
|
|
18
|
+
listGroups(query?: GroupListQuery, options?: RequestOptions): Promise<PaginatedResponse<Group>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImService = void 0;
|
|
4
|
+
const BaseClient_1 = require("../client/BaseClient");
|
|
5
|
+
/**
|
|
6
|
+
* IM 群组服务 SDK(im-service /api/v1/groups)
|
|
7
|
+
*/
|
|
8
|
+
class ImService extends BaseClient_1.BaseClient {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super(config, "im");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 创建群组
|
|
14
|
+
* POST /groups
|
|
15
|
+
*/
|
|
16
|
+
async createGroup(request, options) {
|
|
17
|
+
return this.request("/groups", {
|
|
18
|
+
...options,
|
|
19
|
+
method: "POST",
|
|
20
|
+
body: request,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 群组列表(当前项目+组织下)
|
|
25
|
+
* GET /groups
|
|
26
|
+
*/
|
|
27
|
+
async listGroups(query, options) {
|
|
28
|
+
return this.paginatedRequest("/groups", {
|
|
29
|
+
...options,
|
|
30
|
+
method: "GET",
|
|
31
|
+
params: query,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ImService = ImService;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface Group {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
pid: string;
|
|
5
|
+
org_id: string;
|
|
6
|
+
ownerId: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateGroupRequest {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface GroupListQuery {
|
|
16
|
+
page?: number;
|
|
17
|
+
pageSize?: number;
|
|
18
|
+
}
|
|
19
|
+
/** 群组列表返回格式(im-service 使用 data + pagination) */
|
|
20
|
+
export interface GroupListResult {
|
|
21
|
+
data: Group[];
|
|
22
|
+
pagination: {
|
|
23
|
+
page: number;
|
|
24
|
+
per_page: number;
|
|
25
|
+
total: number;
|
|
26
|
+
total_pages: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
package/lib/types/im.js
ADDED
package/lib/types/index.d.ts
CHANGED