qing-client 0.0.24 → 0.0.25
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/lib/client/index.d.ts +2 -0
- package/lib/client/index.js +8 -0
- package/package.json +1 -1
package/lib/client/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { UserService } from "../service/UserService";
|
|
|
7
7
|
import { AuditLogService } from "../service/AuditLogService";
|
|
8
8
|
import { ProviderService } from "../service/ProviderService";
|
|
9
9
|
import { UsageService } from "../service/UsageService";
|
|
10
|
+
import { FrontHostService } from "../service/FrontHostService";
|
|
10
11
|
import { ClientConfig, UserContext } from "../types";
|
|
11
12
|
export declare class Client {
|
|
12
13
|
protected config: ClientConfig;
|
|
@@ -19,6 +20,7 @@ export declare class Client {
|
|
|
19
20
|
readonly audit: AuditLogService;
|
|
20
21
|
readonly provider: ProviderService;
|
|
21
22
|
readonly usage: UsageService;
|
|
23
|
+
readonly frontHost: FrontHostService;
|
|
22
24
|
protected isFrontendMode: boolean;
|
|
23
25
|
constructor(config: ClientConfig);
|
|
24
26
|
setUserContext(context: UserContext): this;
|
package/lib/client/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const UserService_1 = require("../service/UserService");
|
|
|
10
10
|
const AuditLogService_1 = require("../service/AuditLogService");
|
|
11
11
|
const ProviderService_1 = require("../service/ProviderService");
|
|
12
12
|
const UsageService_1 = require("../service/UsageService");
|
|
13
|
+
const FrontHostService_1 = require("../service/FrontHostService");
|
|
13
14
|
class Client {
|
|
14
15
|
constructor(config) {
|
|
15
16
|
this.config = config;
|
|
@@ -23,6 +24,7 @@ class Client {
|
|
|
23
24
|
this.audit = new AuditLogService_1.AuditLogService(config);
|
|
24
25
|
this.provider = new ProviderService_1.ProviderService(config);
|
|
25
26
|
this.usage = new UsageService_1.UsageService(config);
|
|
27
|
+
this.frontHost = new FrontHostService_1.FrontHostService(config);
|
|
26
28
|
}
|
|
27
29
|
// 后端模式:设置用户上下文
|
|
28
30
|
setUserContext(context) {
|
|
@@ -36,6 +38,7 @@ class Client {
|
|
|
36
38
|
this.audit.setUserContext(context);
|
|
37
39
|
this.provider.setUserContext(context);
|
|
38
40
|
this.usage.setUserContext(context);
|
|
41
|
+
this.frontHost.setUserContext(context);
|
|
39
42
|
}
|
|
40
43
|
else {
|
|
41
44
|
console.warn("setUserContext() 仅在后端模式下有效");
|
|
@@ -54,6 +57,7 @@ class Client {
|
|
|
54
57
|
this.audit.setProjectId(projectId);
|
|
55
58
|
this.provider.setProjectId(projectId);
|
|
56
59
|
this.usage.setProjectId(projectId);
|
|
60
|
+
this.frontHost.setProjectId(projectId);
|
|
57
61
|
}
|
|
58
62
|
else {
|
|
59
63
|
console.warn("setProjectId() 仅在前端模式下有效");
|
|
@@ -72,6 +76,7 @@ class Client {
|
|
|
72
76
|
this.audit.setAppId(appId);
|
|
73
77
|
this.provider.setAppId(appId);
|
|
74
78
|
this.usage.setAppId(appId);
|
|
79
|
+
this.frontHost.setAppId(appId);
|
|
75
80
|
}
|
|
76
81
|
else {
|
|
77
82
|
console.warn("setAppId() 仅在前端模式下有效");
|
|
@@ -90,6 +95,7 @@ class Client {
|
|
|
90
95
|
this.audit.setProjectAndApp(projectId, appId);
|
|
91
96
|
this.provider.setProjectAndApp(projectId, appId);
|
|
92
97
|
this.usage.setProjectAndApp(projectId, appId);
|
|
98
|
+
this.frontHost.setProjectAndApp(projectId, appId);
|
|
93
99
|
}
|
|
94
100
|
else {
|
|
95
101
|
console.warn("setProjectAndApp() 仅在前端模式下有效");
|
|
@@ -107,6 +113,7 @@ class Client {
|
|
|
107
113
|
await this.audit.setToken(token);
|
|
108
114
|
await this.provider.setToken(token);
|
|
109
115
|
await this.usage.setToken(token);
|
|
116
|
+
await this.frontHost.setToken(token);
|
|
110
117
|
}
|
|
111
118
|
// 清除认证令牌(两种模式都需要)
|
|
112
119
|
async clearToken() {
|
|
@@ -119,6 +126,7 @@ class Client {
|
|
|
119
126
|
await this.audit.clearToken();
|
|
120
127
|
await this.provider.clearToken();
|
|
121
128
|
await this.usage.clearToken();
|
|
129
|
+
await this.frontHost.clearToken();
|
|
122
130
|
}
|
|
123
131
|
}
|
|
124
132
|
exports.Client = Client;
|