qing-client 0.0.30 → 0.0.32
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/BaseClient.js +1 -0
- package/lib/client/index.d.ts +2 -0
- package/lib/client/index.js +8 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -1
- package/lib/service/OrgService.d.ts +160 -0
- package/lib/service/OrgService.js +264 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +1 -0
- package/lib/types/org.d.ts +121 -0
- package/lib/types/org.js +4 -0
- package/package.json +1 -1
package/lib/client/BaseClient.js
CHANGED
|
@@ -132,6 +132,7 @@ class BaseClient {
|
|
|
132
132
|
case 'aigc': return this.config.aigcServiceUrl;
|
|
133
133
|
case "logs": return this.config.auditLogServiceUrl;
|
|
134
134
|
case "providers": return this.config.providerServiceUrl;
|
|
135
|
+
case "org": return this.config.orgServiceUrl; // 组织感知服务
|
|
135
136
|
case "gateway-h5": return this.config.gatewayH5ServiceUrl;
|
|
136
137
|
default: throw new Error(`Unsupported service: ${this.serviceName}`);
|
|
137
138
|
}
|
package/lib/client/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { AuditLogService } from "../service/AuditLogService";
|
|
|
8
8
|
import { ProviderService } from "../service/ProviderService";
|
|
9
9
|
import { UsageService } from "../service/UsageService";
|
|
10
10
|
import { FrontHostService } from "../service/FrontHostService";
|
|
11
|
+
import { OrgService } from "../service/OrgService";
|
|
11
12
|
import { ClientConfig, UserContext } from "../types";
|
|
12
13
|
export declare class Client {
|
|
13
14
|
protected config: ClientConfig;
|
|
@@ -21,6 +22,7 @@ export declare class Client {
|
|
|
21
22
|
readonly provider: ProviderService;
|
|
22
23
|
readonly usage: UsageService;
|
|
23
24
|
readonly frontHost: FrontHostService;
|
|
25
|
+
readonly org: OrgService;
|
|
24
26
|
protected isFrontendMode: boolean;
|
|
25
27
|
constructor(config: ClientConfig);
|
|
26
28
|
setUserContext(context: UserContext): this;
|
package/lib/client/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const AuditLogService_1 = require("../service/AuditLogService");
|
|
|
11
11
|
const ProviderService_1 = require("../service/ProviderService");
|
|
12
12
|
const UsageService_1 = require("../service/UsageService");
|
|
13
13
|
const FrontHostService_1 = require("../service/FrontHostService");
|
|
14
|
+
const OrgService_1 = require("../service/OrgService");
|
|
14
15
|
class Client {
|
|
15
16
|
constructor(config) {
|
|
16
17
|
this.config = config;
|
|
@@ -25,6 +26,7 @@ class Client {
|
|
|
25
26
|
this.provider = new ProviderService_1.ProviderService(config);
|
|
26
27
|
this.usage = new UsageService_1.UsageService(config);
|
|
27
28
|
this.frontHost = new FrontHostService_1.FrontHostService(config);
|
|
29
|
+
this.org = new OrgService_1.OrgService(config);
|
|
28
30
|
}
|
|
29
31
|
// 后端模式:设置用户上下文
|
|
30
32
|
setUserContext(context) {
|
|
@@ -39,6 +41,7 @@ class Client {
|
|
|
39
41
|
this.provider.setUserContext(context);
|
|
40
42
|
this.usage.setUserContext(context);
|
|
41
43
|
this.frontHost.setUserContext(context);
|
|
44
|
+
this.org.setUserContext(context);
|
|
42
45
|
}
|
|
43
46
|
else {
|
|
44
47
|
console.warn("setUserContext() 仅在后端模式下有效");
|
|
@@ -58,6 +61,7 @@ class Client {
|
|
|
58
61
|
this.provider.setProjectId(projectId);
|
|
59
62
|
this.usage.setProjectId(projectId);
|
|
60
63
|
this.frontHost.setProjectId(projectId);
|
|
64
|
+
this.org.setProjectId(projectId);
|
|
61
65
|
}
|
|
62
66
|
else {
|
|
63
67
|
console.warn("setProjectId() 仅在前端模式下有效");
|
|
@@ -77,6 +81,7 @@ class Client {
|
|
|
77
81
|
this.provider.setAppId(appId);
|
|
78
82
|
this.usage.setAppId(appId);
|
|
79
83
|
this.frontHost.setAppId(appId);
|
|
84
|
+
this.org.setAppId(appId);
|
|
80
85
|
}
|
|
81
86
|
else {
|
|
82
87
|
console.warn("setAppId() 仅在前端模式下有效");
|
|
@@ -96,6 +101,7 @@ class Client {
|
|
|
96
101
|
this.provider.setProjectAndApp(projectId, appId);
|
|
97
102
|
this.usage.setProjectAndApp(projectId, appId);
|
|
98
103
|
this.frontHost.setProjectAndApp(projectId, appId);
|
|
104
|
+
this.org.setProjectAndApp(projectId, appId);
|
|
99
105
|
}
|
|
100
106
|
else {
|
|
101
107
|
console.warn("setProjectAndApp() 仅在前端模式下有效");
|
|
@@ -114,6 +120,7 @@ class Client {
|
|
|
114
120
|
await this.provider.setToken(token);
|
|
115
121
|
await this.usage.setToken(token);
|
|
116
122
|
await this.frontHost.setToken(token);
|
|
123
|
+
await this.org.setToken(token);
|
|
117
124
|
}
|
|
118
125
|
// 清除认证令牌(两种模式都需要)
|
|
119
126
|
async clearToken() {
|
|
@@ -127,6 +134,7 @@ class Client {
|
|
|
127
134
|
await this.provider.clearToken();
|
|
128
135
|
await this.usage.clearToken();
|
|
129
136
|
await this.frontHost.clearToken();
|
|
137
|
+
await this.org.clearToken();
|
|
130
138
|
}
|
|
131
139
|
}
|
|
132
140
|
exports.Client = Client;
|
package/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { AuditLogService } from "./service/AuditLogService";
|
|
|
9
9
|
export { FrontHostService } from "./service/FrontHostService";
|
|
10
10
|
export { ProviderService } from "./service/ProviderService";
|
|
11
11
|
export { UsageService } from "./service/UsageService";
|
|
12
|
+
export { OrgService } from "./service/OrgService";
|
|
12
13
|
export * from './types';
|
|
13
14
|
export * from './types/msg';
|
|
14
15
|
export * from './types/token';
|
|
@@ -21,3 +22,4 @@ export { ApiSuccessResponse, ApiErrorResponse, PaginatedResponse, ChatCompletion
|
|
|
21
22
|
export { BaseClient } from './client/BaseClient';
|
|
22
23
|
export * from "./types/provider";
|
|
23
24
|
export * from "./types/usage";
|
|
25
|
+
export * from "./types/org";
|
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.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.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; } });
|
|
@@ -39,6 +39,8 @@ var ProviderService_1 = require("./service/ProviderService");
|
|
|
39
39
|
Object.defineProperty(exports, "ProviderService", { enumerable: true, get: function () { return ProviderService_1.ProviderService; } });
|
|
40
40
|
var UsageService_1 = require("./service/UsageService");
|
|
41
41
|
Object.defineProperty(exports, "UsageService", { enumerable: true, get: function () { return UsageService_1.UsageService; } });
|
|
42
|
+
var OrgService_1 = require("./service/OrgService");
|
|
43
|
+
Object.defineProperty(exports, "OrgService", { enumerable: true, get: function () { return OrgService_1.OrgService; } });
|
|
42
44
|
// 导出所有类型定义
|
|
43
45
|
__exportStar(require("./types"), exports);
|
|
44
46
|
__exportStar(require("./types/msg"), exports);
|
|
@@ -52,3 +54,4 @@ var BaseClient_1 = require("./client/BaseClient");
|
|
|
52
54
|
Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function () { return BaseClient_1.BaseClient; } });
|
|
53
55
|
__exportStar(require("./types/provider"), exports);
|
|
54
56
|
__exportStar(require("./types/usage"), exports);
|
|
57
|
+
__exportStar(require("./types/org"), exports);
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { BaseClient } from "../client/BaseClient";
|
|
2
|
+
import { ClientConfig, RequestOptions } from "../types";
|
|
3
|
+
import { Organization, CreateOrganizationRequest, UpdateOrganizationRequest, OrganizationListQuery, OrganizationListResponse, Project, Application, ProjectAppsResponse, OrgResolutionRule, CreateOrgResolutionRuleRequest, UpdateOrgResolutionRuleRequest, OrgResolutionRuleListQuery, OrgResolutionRuleListResponse, OrgResolveRequest, OrgResolveResponse, ProjectsSyncRequest, ProjectsSyncResponse } from "../types/org";
|
|
4
|
+
/**
|
|
5
|
+
* 组织感知服务(Org-Aware Service)
|
|
6
|
+
*
|
|
7
|
+
* 提供组织、项目、应用的元数据管理和组织识别能力
|
|
8
|
+
*
|
|
9
|
+
* 权限要求:SUPER_ADMIN 或 SYSTEM
|
|
10
|
+
*/
|
|
11
|
+
export declare class OrgService extends BaseClient {
|
|
12
|
+
constructor(config: ClientConfig);
|
|
13
|
+
/**
|
|
14
|
+
* 组织识别
|
|
15
|
+
* POST /org/resolve
|
|
16
|
+
*
|
|
17
|
+
* 根据 host 或 header 识别请求属于哪个组织
|
|
18
|
+
*/
|
|
19
|
+
resolve(request: OrgResolveRequest, options?: RequestOptions): Promise<OrgResolveResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* 获取项目详情(仅 enabled)
|
|
22
|
+
* GET /projects/:configId
|
|
23
|
+
*/
|
|
24
|
+
getProject(configId: string, options?: RequestOptions): Promise<Project>;
|
|
25
|
+
/**
|
|
26
|
+
* 获取项目下的应用列表(仅 enabled)
|
|
27
|
+
* GET /projects/:configId/apps
|
|
28
|
+
*/
|
|
29
|
+
getProjectApps(configId: string, options?: RequestOptions): Promise<ProjectAppsResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* 获取应用详情(仅 enabled)
|
|
32
|
+
* GET /apps/:configId
|
|
33
|
+
*/
|
|
34
|
+
getApp(configId: string, options?: RequestOptions): Promise<Application>;
|
|
35
|
+
/**
|
|
36
|
+
* [Admin] 获取项目详情(包含 disabled)
|
|
37
|
+
* GET /admin/projects/:configId
|
|
38
|
+
*/
|
|
39
|
+
adminGetProject(configId: string, options?: RequestOptions): Promise<Project>;
|
|
40
|
+
/**
|
|
41
|
+
* [Admin] 获取项目下所有应用(包含 disabled)
|
|
42
|
+
* GET /admin/projects/:configId/apps
|
|
43
|
+
*/
|
|
44
|
+
adminGetProjectApps(configId: string, options?: RequestOptions): Promise<ProjectAppsResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* [Admin] 启用项目
|
|
47
|
+
* POST /admin/projects/:configId/enable
|
|
48
|
+
*/
|
|
49
|
+
adminEnableProject(configId: string, options?: RequestOptions): Promise<{
|
|
50
|
+
ok: boolean;
|
|
51
|
+
configId: string;
|
|
52
|
+
id: string;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* [Admin] 禁用项目
|
|
56
|
+
* POST /admin/projects/:configId/disable
|
|
57
|
+
*/
|
|
58
|
+
adminDisableProject(configId: string, options?: RequestOptions): Promise<{
|
|
59
|
+
ok: boolean;
|
|
60
|
+
configId: string;
|
|
61
|
+
id: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* [Admin] 同步项目配置
|
|
65
|
+
* POST /admin/projects/sync
|
|
66
|
+
*/
|
|
67
|
+
adminSyncProjects(request: ProjectsSyncRequest, options?: RequestOptions): Promise<ProjectsSyncResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* [Admin] 获取应用详情(包含 disabled)
|
|
70
|
+
* GET /admin/apps/:configId
|
|
71
|
+
*/
|
|
72
|
+
adminGetApp(configId: string, options?: RequestOptions): Promise<Application>;
|
|
73
|
+
/**
|
|
74
|
+
* [Admin] 启用应用
|
|
75
|
+
* POST /admin/apps/:configId/enable
|
|
76
|
+
*/
|
|
77
|
+
adminEnableApp(configId: string, options?: RequestOptions): Promise<{
|
|
78
|
+
ok: boolean;
|
|
79
|
+
configId: string;
|
|
80
|
+
id: string;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* [Admin] 禁用应用
|
|
84
|
+
* POST /admin/apps/:configId/disable
|
|
85
|
+
*/
|
|
86
|
+
adminDisableApp(configId: string, options?: RequestOptions): Promise<{
|
|
87
|
+
ok: boolean;
|
|
88
|
+
configId: string;
|
|
89
|
+
id: string;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* [Admin] 获取组织列表
|
|
93
|
+
* GET /admin/orgs
|
|
94
|
+
*/
|
|
95
|
+
adminListOrganizations(query?: OrganizationListQuery, options?: RequestOptions): Promise<OrganizationListResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* [Admin] 获取组织详情
|
|
98
|
+
* GET /admin/orgs/:orgCode
|
|
99
|
+
*/
|
|
100
|
+
adminGetOrganization(orgCode: string, options?: RequestOptions): Promise<Organization>;
|
|
101
|
+
/**
|
|
102
|
+
* [Admin] 创建组织
|
|
103
|
+
* POST /admin/orgs
|
|
104
|
+
*/
|
|
105
|
+
adminCreateOrganization(request: CreateOrganizationRequest, options?: RequestOptions): Promise<Organization>;
|
|
106
|
+
/**
|
|
107
|
+
* [Admin] 更新组织
|
|
108
|
+
* PATCH /admin/orgs/:id
|
|
109
|
+
*/
|
|
110
|
+
adminUpdateOrganization(id: string, request: UpdateOrganizationRequest, options?: RequestOptions): Promise<Organization>;
|
|
111
|
+
/**
|
|
112
|
+
* [Admin] 启用组织
|
|
113
|
+
* POST /admin/orgs/:id/enable
|
|
114
|
+
*/
|
|
115
|
+
adminEnableOrganization(id: string, options?: RequestOptions): Promise<{
|
|
116
|
+
ok: boolean;
|
|
117
|
+
id: string;
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* [Admin] 禁用组织
|
|
121
|
+
* POST /admin/orgs/:id/disable
|
|
122
|
+
*/
|
|
123
|
+
adminDisableOrganization(id: string, options?: RequestOptions): Promise<{
|
|
124
|
+
ok: boolean;
|
|
125
|
+
id: string;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* [Admin] 获取组织识别规则列表
|
|
129
|
+
* GET /admin/org-resolution-rules
|
|
130
|
+
*/
|
|
131
|
+
adminListOrgResolutionRules(query?: OrgResolutionRuleListQuery, options?: RequestOptions): Promise<OrgResolutionRuleListResponse>;
|
|
132
|
+
/**
|
|
133
|
+
* [Admin] 创建组织识别规则
|
|
134
|
+
* POST /admin/org-resolution-rules
|
|
135
|
+
*/
|
|
136
|
+
adminCreateOrgResolutionRule(request: CreateOrgResolutionRuleRequest, options?: RequestOptions): Promise<OrgResolutionRule>;
|
|
137
|
+
/**
|
|
138
|
+
* [Admin] 更新组织识别规则
|
|
139
|
+
* PATCH /admin/org-resolution-rules/:type/:matchValue
|
|
140
|
+
*/
|
|
141
|
+
adminUpdateOrgResolutionRule(type: string, matchValue: string, request: UpdateOrgResolutionRuleRequest, options?: RequestOptions): Promise<OrgResolutionRule>;
|
|
142
|
+
/**
|
|
143
|
+
* [Admin] 启用组织识别规则
|
|
144
|
+
* POST /admin/org-resolution-rules/:type/:matchValue/enable
|
|
145
|
+
*/
|
|
146
|
+
adminEnableOrgResolutionRule(type: string, matchValue: string, options?: RequestOptions): Promise<{
|
|
147
|
+
ok: boolean;
|
|
148
|
+
type: string;
|
|
149
|
+
matchValue: string;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* [Admin] 禁用组织识别规则
|
|
153
|
+
* POST /admin/org-resolution-rules/:type/:matchValue/disable
|
|
154
|
+
*/
|
|
155
|
+
adminDisableOrgResolutionRule(type: string, matchValue: string, options?: RequestOptions): Promise<{
|
|
156
|
+
ok: boolean;
|
|
157
|
+
type: string;
|
|
158
|
+
matchValue: string;
|
|
159
|
+
}>;
|
|
160
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrgService = void 0;
|
|
4
|
+
const BaseClient_1 = require("../client/BaseClient");
|
|
5
|
+
/**
|
|
6
|
+
* 组织感知服务(Org-Aware Service)
|
|
7
|
+
*
|
|
8
|
+
* 提供组织、项目、应用的元数据管理和组织识别能力
|
|
9
|
+
*
|
|
10
|
+
* 权限要求:SUPER_ADMIN 或 SYSTEM
|
|
11
|
+
*/
|
|
12
|
+
class OrgService extends BaseClient_1.BaseClient {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(config, "org");
|
|
15
|
+
}
|
|
16
|
+
// ==================== 组织识别(核心接口) ====================
|
|
17
|
+
/**
|
|
18
|
+
* 组织识别
|
|
19
|
+
* POST /org/resolve
|
|
20
|
+
*
|
|
21
|
+
* 根据 host 或 header 识别请求属于哪个组织
|
|
22
|
+
*/
|
|
23
|
+
async resolve(request, options) {
|
|
24
|
+
return this.request("/org/resolve", {
|
|
25
|
+
...options,
|
|
26
|
+
method: "POST",
|
|
27
|
+
body: request,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// ==================== Project(项目) ====================
|
|
31
|
+
/**
|
|
32
|
+
* 获取项目详情(仅 enabled)
|
|
33
|
+
* GET /projects/:configId
|
|
34
|
+
*/
|
|
35
|
+
async getProject(configId, options) {
|
|
36
|
+
return this.request(`/projects/${configId}`, {
|
|
37
|
+
...options,
|
|
38
|
+
method: "GET",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 获取项目下的应用列表(仅 enabled)
|
|
43
|
+
* GET /projects/:configId/apps
|
|
44
|
+
*/
|
|
45
|
+
async getProjectApps(configId, options) {
|
|
46
|
+
return this.request(`/projects/${configId}/apps`, {
|
|
47
|
+
...options,
|
|
48
|
+
method: "GET",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// ==================== Application(应用) ====================
|
|
52
|
+
/**
|
|
53
|
+
* 获取应用详情(仅 enabled)
|
|
54
|
+
* GET /apps/:configId
|
|
55
|
+
*/
|
|
56
|
+
async getApp(configId, options) {
|
|
57
|
+
return this.request(`/apps/${configId}`, {
|
|
58
|
+
...options,
|
|
59
|
+
method: "GET",
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// ==================== Admin: Project ====================
|
|
63
|
+
/**
|
|
64
|
+
* [Admin] 获取项目详情(包含 disabled)
|
|
65
|
+
* GET /admin/projects/:configId
|
|
66
|
+
*/
|
|
67
|
+
async adminGetProject(configId, options) {
|
|
68
|
+
return this.request(`/admin/projects/${configId}`, {
|
|
69
|
+
...options,
|
|
70
|
+
method: "GET",
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* [Admin] 获取项目下所有应用(包含 disabled)
|
|
75
|
+
* GET /admin/projects/:configId/apps
|
|
76
|
+
*/
|
|
77
|
+
async adminGetProjectApps(configId, options) {
|
|
78
|
+
return this.request(`/admin/projects/${configId}/apps`, {
|
|
79
|
+
...options,
|
|
80
|
+
method: "GET",
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* [Admin] 启用项目
|
|
85
|
+
* POST /admin/projects/:configId/enable
|
|
86
|
+
*/
|
|
87
|
+
async adminEnableProject(configId, options) {
|
|
88
|
+
return this.request(`/admin/projects/${configId}/enable`, {
|
|
89
|
+
...options,
|
|
90
|
+
method: "POST",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* [Admin] 禁用项目
|
|
95
|
+
* POST /admin/projects/:configId/disable
|
|
96
|
+
*/
|
|
97
|
+
async adminDisableProject(configId, options) {
|
|
98
|
+
return this.request(`/admin/projects/${configId}/disable`, {
|
|
99
|
+
...options,
|
|
100
|
+
method: "POST",
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* [Admin] 同步项目配置
|
|
105
|
+
* POST /admin/projects/sync
|
|
106
|
+
*/
|
|
107
|
+
async adminSyncProjects(request, options) {
|
|
108
|
+
return this.request("/admin/projects/sync", {
|
|
109
|
+
...options,
|
|
110
|
+
method: "POST",
|
|
111
|
+
body: request,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// ==================== Admin: Application ====================
|
|
115
|
+
/**
|
|
116
|
+
* [Admin] 获取应用详情(包含 disabled)
|
|
117
|
+
* GET /admin/apps/:configId
|
|
118
|
+
*/
|
|
119
|
+
async adminGetApp(configId, options) {
|
|
120
|
+
return this.request(`/admin/apps/${configId}`, {
|
|
121
|
+
...options,
|
|
122
|
+
method: "GET",
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* [Admin] 启用应用
|
|
127
|
+
* POST /admin/apps/:configId/enable
|
|
128
|
+
*/
|
|
129
|
+
async adminEnableApp(configId, options) {
|
|
130
|
+
return this.request(`/admin/apps/${configId}/enable`, {
|
|
131
|
+
...options,
|
|
132
|
+
method: "POST",
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* [Admin] 禁用应用
|
|
137
|
+
* POST /admin/apps/:configId/disable
|
|
138
|
+
*/
|
|
139
|
+
async adminDisableApp(configId, options) {
|
|
140
|
+
return this.request(`/admin/apps/${configId}/disable`, {
|
|
141
|
+
...options,
|
|
142
|
+
method: "POST",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// ==================== Admin: Organization ====================
|
|
146
|
+
/**
|
|
147
|
+
* [Admin] 获取组织列表
|
|
148
|
+
* GET /admin/orgs
|
|
149
|
+
*/
|
|
150
|
+
async adminListOrganizations(query, options) {
|
|
151
|
+
return this.request("/admin/orgs", {
|
|
152
|
+
...options,
|
|
153
|
+
method: "GET",
|
|
154
|
+
params: query,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* [Admin] 获取组织详情
|
|
159
|
+
* GET /admin/orgs/:orgCode
|
|
160
|
+
*/
|
|
161
|
+
async adminGetOrganization(orgCode, options) {
|
|
162
|
+
return this.request(`/admin/orgs/${orgCode}`, {
|
|
163
|
+
...options,
|
|
164
|
+
method: "GET",
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* [Admin] 创建组织
|
|
169
|
+
* POST /admin/orgs
|
|
170
|
+
*/
|
|
171
|
+
async adminCreateOrganization(request, options) {
|
|
172
|
+
return this.request("/admin/orgs", {
|
|
173
|
+
...options,
|
|
174
|
+
method: "POST",
|
|
175
|
+
body: request,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* [Admin] 更新组织
|
|
180
|
+
* PATCH /admin/orgs/:id
|
|
181
|
+
*/
|
|
182
|
+
async adminUpdateOrganization(id, request, options) {
|
|
183
|
+
return this.request(`/admin/orgs/${id}`, {
|
|
184
|
+
...options,
|
|
185
|
+
method: "PATCH",
|
|
186
|
+
body: request,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* [Admin] 启用组织
|
|
191
|
+
* POST /admin/orgs/:id/enable
|
|
192
|
+
*/
|
|
193
|
+
async adminEnableOrganization(id, options) {
|
|
194
|
+
return this.request(`/admin/orgs/${id}/enable`, {
|
|
195
|
+
...options,
|
|
196
|
+
method: "POST",
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* [Admin] 禁用组织
|
|
201
|
+
* POST /admin/orgs/:id/disable
|
|
202
|
+
*/
|
|
203
|
+
async adminDisableOrganization(id, options) {
|
|
204
|
+
return this.request(`/admin/orgs/${id}/disable`, {
|
|
205
|
+
...options,
|
|
206
|
+
method: "POST",
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// ==================== Admin: OrgResolutionRule ====================
|
|
210
|
+
/**
|
|
211
|
+
* [Admin] 获取组织识别规则列表
|
|
212
|
+
* GET /admin/org-resolution-rules
|
|
213
|
+
*/
|
|
214
|
+
async adminListOrgResolutionRules(query, options) {
|
|
215
|
+
return this.request("/admin/org-resolution-rules", {
|
|
216
|
+
...options,
|
|
217
|
+
method: "GET",
|
|
218
|
+
params: query,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* [Admin] 创建组织识别规则
|
|
223
|
+
* POST /admin/org-resolution-rules
|
|
224
|
+
*/
|
|
225
|
+
async adminCreateOrgResolutionRule(request, options) {
|
|
226
|
+
return this.request("/admin/org-resolution-rules", {
|
|
227
|
+
...options,
|
|
228
|
+
method: "POST",
|
|
229
|
+
body: request,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* [Admin] 更新组织识别规则
|
|
234
|
+
* PATCH /admin/org-resolution-rules/:type/:matchValue
|
|
235
|
+
*/
|
|
236
|
+
async adminUpdateOrgResolutionRule(type, matchValue, request, options) {
|
|
237
|
+
return this.request(`/admin/org-resolution-rules/${type}/${encodeURIComponent(matchValue)}`, {
|
|
238
|
+
...options,
|
|
239
|
+
method: "PATCH",
|
|
240
|
+
body: request,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* [Admin] 启用组织识别规则
|
|
245
|
+
* POST /admin/org-resolution-rules/:type/:matchValue/enable
|
|
246
|
+
*/
|
|
247
|
+
async adminEnableOrgResolutionRule(type, matchValue, options) {
|
|
248
|
+
return this.request(`/admin/org-resolution-rules/${type}/${encodeURIComponent(matchValue)}/enable`, {
|
|
249
|
+
...options,
|
|
250
|
+
method: "POST",
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* [Admin] 禁用组织识别规则
|
|
255
|
+
* POST /admin/org-resolution-rules/:type/:matchValue/disable
|
|
256
|
+
*/
|
|
257
|
+
async adminDisableOrgResolutionRule(type, matchValue, options) {
|
|
258
|
+
return this.request(`/admin/org-resolution-rules/${type}/${encodeURIComponent(matchValue)}/disable`, {
|
|
259
|
+
...options,
|
|
260
|
+
method: "POST",
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exports.OrgService = OrgService;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface ClientConfig {
|
|
|
32
32
|
auditLogServiceUrl?: string;
|
|
33
33
|
providerServiceUrl?: string;
|
|
34
34
|
gatewayH5ServiceUrl?: string;
|
|
35
|
+
orgServiceUrl?: string;
|
|
35
36
|
tokenStorage?: TokenStorage;
|
|
36
37
|
projectId?: string;
|
|
37
38
|
appId?: string;
|
|
@@ -53,3 +54,4 @@ export interface RequestOptions {
|
|
|
53
54
|
}
|
|
54
55
|
export * from "./provider";
|
|
55
56
|
export * from "./usage";
|
|
57
|
+
export * from "./audit";
|
package/lib/types/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./provider"), exports);
|
|
18
18
|
__exportStar(require("./usage"), exports);
|
|
19
|
+
__exportStar(require("./audit"), exports);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export interface Organization {
|
|
2
|
+
id: string;
|
|
3
|
+
orgCode: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string | null;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
updatedAt: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CreateOrganizationRequest {
|
|
11
|
+
orgCode: string;
|
|
12
|
+
name: string;
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface UpdateOrganizationRequest {
|
|
16
|
+
name?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface OrganizationListQuery {
|
|
19
|
+
status?: 'all' | 'active' | 'inactive';
|
|
20
|
+
keyword?: string;
|
|
21
|
+
limit?: number;
|
|
22
|
+
offset?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface OrganizationListResponse {
|
|
25
|
+
items: Organization[];
|
|
26
|
+
}
|
|
27
|
+
export interface Project {
|
|
28
|
+
id?: string;
|
|
29
|
+
configId: string;
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string | null;
|
|
32
|
+
homepage?: string | null;
|
|
33
|
+
wechatOfficialAccountId?: string | null;
|
|
34
|
+
wechatMiniProgramId?: string | null;
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
createdAt?: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
}
|
|
39
|
+
export type ApplicationType = 'web' | 'mobile_web' | 'mobile_app' | 'wechat_miniprogram' | 'wechat_minigame' | 'wechat_official_account' | 'unknown';
|
|
40
|
+
export interface Application {
|
|
41
|
+
id?: string;
|
|
42
|
+
configId: string;
|
|
43
|
+
projectId: string;
|
|
44
|
+
name: string;
|
|
45
|
+
description?: string | null;
|
|
46
|
+
type: ApplicationType;
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
createdAt?: string;
|
|
49
|
+
updatedAt: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ProjectAppsResponse {
|
|
52
|
+
projectId?: string;
|
|
53
|
+
projectConfigId: string;
|
|
54
|
+
apps: Application[];
|
|
55
|
+
}
|
|
56
|
+
export type OrgResolutionRuleType = 'host' | 'header';
|
|
57
|
+
export interface OrgResolutionRule {
|
|
58
|
+
type: OrgResolutionRuleType;
|
|
59
|
+
matchValue: string;
|
|
60
|
+
orgCode: string;
|
|
61
|
+
enabled: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface CreateOrgResolutionRuleRequest {
|
|
64
|
+
type: OrgResolutionRuleType;
|
|
65
|
+
matchValue: string;
|
|
66
|
+
orgCode: string;
|
|
67
|
+
enabled?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface UpdateOrgResolutionRuleRequest {
|
|
70
|
+
orgCode?: string;
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface OrgResolutionRuleListQuery {
|
|
74
|
+
type?: OrgResolutionRuleType;
|
|
75
|
+
orgCode?: string;
|
|
76
|
+
enabled?: boolean;
|
|
77
|
+
limit?: number;
|
|
78
|
+
offset?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface OrgResolutionRuleListResponse {
|
|
81
|
+
items: OrgResolutionRule[];
|
|
82
|
+
}
|
|
83
|
+
export interface OrgResolveRequest {
|
|
84
|
+
host?: string;
|
|
85
|
+
headers?: Record<string, string | undefined>;
|
|
86
|
+
}
|
|
87
|
+
export interface OrgResolveResponse {
|
|
88
|
+
status: 'matched' | 'not_matched';
|
|
89
|
+
org?: {
|
|
90
|
+
orgId: string;
|
|
91
|
+
orgCode: string;
|
|
92
|
+
};
|
|
93
|
+
matchedBy?: 'host' | 'header';
|
|
94
|
+
matchValue?: string;
|
|
95
|
+
reason?: 'NO_RULE' | 'ORG_NOT_FOUND' | 'ORG_DISABLED';
|
|
96
|
+
}
|
|
97
|
+
export interface ProjectConfig {
|
|
98
|
+
name: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
homepage?: string;
|
|
101
|
+
wechatOfficialAccountId?: string;
|
|
102
|
+
wechatMiniProgramId?: string;
|
|
103
|
+
apps?: Record<string, AppConfig>;
|
|
104
|
+
}
|
|
105
|
+
export interface AppConfig {
|
|
106
|
+
name: string;
|
|
107
|
+
description?: string;
|
|
108
|
+
type?: ApplicationType;
|
|
109
|
+
}
|
|
110
|
+
export interface ProjectsSyncRequest {
|
|
111
|
+
projects: Record<string, ProjectConfig>;
|
|
112
|
+
}
|
|
113
|
+
export interface ProjectsSyncResponse {
|
|
114
|
+
ok: boolean;
|
|
115
|
+
result: {
|
|
116
|
+
projectsCreated: number;
|
|
117
|
+
projectsUpdated: number;
|
|
118
|
+
appsCreated: number;
|
|
119
|
+
appsUpdated: number;
|
|
120
|
+
};
|
|
121
|
+
}
|
package/lib/types/org.js
ADDED