qing-client 0.0.23 → 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/lib/service/ProviderService.d.ts +7 -1
- package/lib/service/ProviderService.js +40 -0
- package/lib/types/provider.d.ts +35 -2
- package/package.json +1 -1
- package/lib/srvice/AiService.d.ts +0 -67
- package/lib/srvice/AiService.js +0 -225
- package/lib/srvice/AigcService.d.ts +0 -20
- package/lib/srvice/AigcService.js +0 -118
- package/lib/srvice/AuthService.d.ts +0 -11
- package/lib/srvice/AuthService.js +0 -83
- package/lib/srvice/MsgService.d.ts +0 -22
- package/lib/srvice/MsgService.js +0 -99
- package/lib/srvice/TokenService.d.ts +0 -11
- package/lib/srvice/TokenService.js +0 -50
- package/lib/srvice/UserService.d.ts +0 -18
- package/lib/srvice/UserService.js +0 -95
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseClient } from "../client/BaseClient";
|
|
2
2
|
import { ClientConfig, RequestOptions } from "../types";
|
|
3
|
-
import { ChatCompletionsRequest, ChatCompletionsResponse, CreateProviderRequest, ProviderItem, ProviderModel, UpdateProviderRequest, UpsertManyModelsBody } from "../types/provider";
|
|
3
|
+
import { ChatCompletionsRequest, ChatCompletionsResponse, CreateProviderRequest, CreateModelRequest, PatchModelEnabledRequest, PatchModelSupportedRequest, ProviderItem, ProviderModel, UpdateProviderRequest, UpdateModelRequest, UpsertManyModelsBody } from "../types/provider";
|
|
4
4
|
/**
|
|
5
5
|
* 大模型供应商服务(Provider Service)
|
|
6
6
|
* - 网关模式:前端 -> /api/providers/...
|
|
@@ -25,6 +25,12 @@ export declare class ProviderService extends BaseClient {
|
|
|
25
25
|
onlyEnabled?: boolean;
|
|
26
26
|
q?: string;
|
|
27
27
|
}, options?: RequestOptions): Promise<ProviderModel[]>;
|
|
28
|
+
getModel(providerId: string, modelId: string, options?: RequestOptions): Promise<ProviderModel>;
|
|
29
|
+
createModel(body: CreateModelRequest, options?: RequestOptions): Promise<ProviderModel>;
|
|
30
|
+
updateModel(providerId: string, modelId: string, body: UpdateModelRequest, options?: RequestOptions): Promise<void>;
|
|
31
|
+
setModelEnabled(providerId: string, modelId: string, body: PatchModelEnabledRequest, options?: RequestOptions): Promise<void>;
|
|
32
|
+
setModelSupported(providerId: string, modelId: string, body: PatchModelSupportedRequest, options?: RequestOptions): Promise<void>;
|
|
33
|
+
deleteModel(providerId: string, modelId: string, options?: RequestOptions): Promise<void>;
|
|
28
34
|
upsertManyModels(body: UpsertManyModelsBody, options?: RequestOptions): Promise<{
|
|
29
35
|
upserted: number;
|
|
30
36
|
updated: number;
|
|
@@ -72,6 +72,46 @@ class ProviderService extends BaseClient_1.BaseClient {
|
|
|
72
72
|
params,
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
+
async getModel(providerId, modelId, options) {
|
|
76
|
+
return this.request(this.path(`/models/${providerId}/${modelId}`), {
|
|
77
|
+
...options,
|
|
78
|
+
method: "GET",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async createModel(body, options) {
|
|
82
|
+
return this.request(this.path("/models"), {
|
|
83
|
+
...options,
|
|
84
|
+
method: "POST",
|
|
85
|
+
body,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async updateModel(providerId, modelId, body, options) {
|
|
89
|
+
return this.request(this.path(`/models/${providerId}/${modelId}`), {
|
|
90
|
+
...options,
|
|
91
|
+
method: "PATCH",
|
|
92
|
+
body,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async setModelEnabled(providerId, modelId, body, options) {
|
|
96
|
+
return this.request(this.path(`/models/${providerId}/${modelId}/enabled`), {
|
|
97
|
+
...options,
|
|
98
|
+
method: "PATCH",
|
|
99
|
+
body,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async setModelSupported(providerId, modelId, body, options) {
|
|
103
|
+
return this.request(this.path(`/models/${providerId}/${modelId}/supported`), {
|
|
104
|
+
...options,
|
|
105
|
+
method: "PATCH",
|
|
106
|
+
body,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async deleteModel(providerId, modelId, options) {
|
|
110
|
+
return this.request(this.path(`/models/${providerId}/${modelId}`), {
|
|
111
|
+
...options,
|
|
112
|
+
method: "DELETE",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
75
115
|
async upsertManyModels(body, options) {
|
|
76
116
|
return this.request(this.path("/internal/models/upsertMany"), {
|
|
77
117
|
...options,
|
package/lib/types/provider.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type ProviderClass = "openai" | "anthropic" | "gemini" | "azure_openai" | "mock";
|
|
2
2
|
export type ProviderStatus = "enabled" | "disabled";
|
|
3
|
+
export type Currency = "USD" | "CNY";
|
|
3
4
|
export interface ProviderCredential {
|
|
4
5
|
hasApiKey: boolean;
|
|
5
6
|
apiKeyLast4?: string;
|
|
@@ -25,7 +26,7 @@ export interface ProviderListResponse {
|
|
|
25
26
|
providers: ProviderItem[];
|
|
26
27
|
}
|
|
27
28
|
export interface ModelPricing {
|
|
28
|
-
currency?:
|
|
29
|
+
currency?: Currency;
|
|
29
30
|
inputPer1k?: number;
|
|
30
31
|
outputPer1k?: number;
|
|
31
32
|
}
|
|
@@ -65,7 +66,7 @@ export interface UpsertModelItem {
|
|
|
65
66
|
inputPrice?: number;
|
|
66
67
|
outputPrice?: number;
|
|
67
68
|
perUnit?: number;
|
|
68
|
-
currency?:
|
|
69
|
+
currency?: Currency;
|
|
69
70
|
capabilities?: Partial<ModelCapabilities>;
|
|
70
71
|
contextWindow?: number;
|
|
71
72
|
maxOutputTokens?: number;
|
|
@@ -76,6 +77,38 @@ export interface UpsertModelItem {
|
|
|
76
77
|
company?: string;
|
|
77
78
|
providerClass?: string;
|
|
78
79
|
}
|
|
80
|
+
export interface CreateModelRequest {
|
|
81
|
+
providerId: string;
|
|
82
|
+
modelId: string;
|
|
83
|
+
displayName?: string;
|
|
84
|
+
enabled?: boolean;
|
|
85
|
+
supported?: boolean;
|
|
86
|
+
pricing?: {
|
|
87
|
+
inputPer1k: number;
|
|
88
|
+
outputPer1k: number;
|
|
89
|
+
currency?: Currency;
|
|
90
|
+
};
|
|
91
|
+
capabilities: ModelCapabilities;
|
|
92
|
+
limits?: ModelLimits;
|
|
93
|
+
tags?: string[];
|
|
94
|
+
}
|
|
95
|
+
export interface UpdateModelRequest {
|
|
96
|
+
displayName?: string;
|
|
97
|
+
pricing?: {
|
|
98
|
+
inputPer1k: number;
|
|
99
|
+
outputPer1k: number;
|
|
100
|
+
currency?: Currency;
|
|
101
|
+
};
|
|
102
|
+
capabilities?: ModelCapabilities;
|
|
103
|
+
limits?: ModelLimits;
|
|
104
|
+
tags?: string[];
|
|
105
|
+
}
|
|
106
|
+
export interface PatchModelEnabledRequest {
|
|
107
|
+
enabled: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface PatchModelSupportedRequest {
|
|
110
|
+
supported: boolean;
|
|
111
|
+
}
|
|
79
112
|
export interface UpsertManyModelsBody {
|
|
80
113
|
providerId: string;
|
|
81
114
|
models: UpsertModelItem[];
|
package/package.json
CHANGED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { BaseClient } from "../client/BaseClient";
|
|
2
|
-
import { ClientConfig, RequestOptions } from "../types";
|
|
3
|
-
import { ChatCompletionRequest, ChatCompletionResponse, ProviderListItem, ProviderDetail, ModelListItem, ModelDetail, CreateSessionRequest, SessionResponse, SessionListResponse, CreateAssistantRequest, AssistantResponse, AssistantListResponse, UpdateAssistantRequest, AddMessageRequest, SessionStatistics, AssistantModelsResponse, PaginatedSessionMessageResponse, SessionDetailResponse, ModelInfoResponse, BatchDeleteSessionsResponse, UpdateSessionRequest } from "../types/ai";
|
|
4
|
-
export declare class AiService extends BaseClient {
|
|
5
|
-
constructor(config: ClientConfig);
|
|
6
|
-
chatCompletion(request: ChatCompletionRequest, options?: RequestOptions): Promise<ChatCompletionResponse>;
|
|
7
|
-
chatCompletionStream(request: ChatCompletionRequest, options?: RequestOptions): Promise<ChatCompletionResponse>;
|
|
8
|
-
createSession(request: CreateSessionRequest, options?: RequestOptions): Promise<SessionDetailResponse>;
|
|
9
|
-
getSessions(params?: {
|
|
10
|
-
page?: number;
|
|
11
|
-
limit?: number;
|
|
12
|
-
status?: 'active' | 'ended';
|
|
13
|
-
}, options?: RequestOptions): Promise<SessionListResponse>;
|
|
14
|
-
getSession(sessionId: string, options?: RequestOptions): Promise<SessionDetailResponse>;
|
|
15
|
-
updateSession(sessionId: string, request: UpdateSessionRequest, options?: RequestOptions): Promise<SessionDetailResponse>;
|
|
16
|
-
endSession(sessionId: string, options?: RequestOptions): Promise<SessionDetailResponse>;
|
|
17
|
-
deleteSession(sessionId: string, options?: RequestOptions): Promise<void>;
|
|
18
|
-
getSessionModelInfo(sessionId: string, options?: RequestOptions): Promise<ModelInfoResponse>;
|
|
19
|
-
getActiveSessions(options?: RequestOptions): Promise<{
|
|
20
|
-
sessions: SessionResponse[];
|
|
21
|
-
}>;
|
|
22
|
-
switchSessionModel(sessionId: string, modelName: string, options?: RequestOptions): Promise<SessionDetailResponse>;
|
|
23
|
-
getSessionStatistics(timeRange?: 'today' | 'week' | 'month' | 'year', options?: RequestOptions): Promise<SessionStatistics>;
|
|
24
|
-
getSessionMessages(sessionId: string, params?: {
|
|
25
|
-
page?: number;
|
|
26
|
-
limit?: number;
|
|
27
|
-
}, options?: RequestOptions): Promise<PaginatedSessionMessageResponse>;
|
|
28
|
-
addMessageToSession(sessionId: string, request: AddMessageRequest, options?: RequestOptions): Promise<SessionDetailResponse>;
|
|
29
|
-
deleteSessionsBatch(sessionIds: string[], options?: RequestOptions): Promise<BatchDeleteSessionsResponse>;
|
|
30
|
-
createAssistant(request: CreateAssistantRequest, options?: RequestOptions): Promise<AssistantResponse>;
|
|
31
|
-
getAssistants(params?: {
|
|
32
|
-
page?: number;
|
|
33
|
-
limit?: number;
|
|
34
|
-
}, options?: RequestOptions): Promise<AssistantListResponse>;
|
|
35
|
-
getAssistant(assistantId: string, options?: RequestOptions): Promise<AssistantResponse>;
|
|
36
|
-
updateAssistant(assistantId: string, request: UpdateAssistantRequest, options?: RequestOptions): Promise<AssistantResponse>;
|
|
37
|
-
deleteAssistant(assistantId: string, options?: RequestOptions): Promise<void>;
|
|
38
|
-
getAccessibleAssistants(options?: RequestOptions): Promise<{
|
|
39
|
-
assistants: AssistantResponse[];
|
|
40
|
-
}>;
|
|
41
|
-
getPopularAssistants(limit?: number, options?: RequestOptions): Promise<{
|
|
42
|
-
assistants: AssistantResponse[];
|
|
43
|
-
}>;
|
|
44
|
-
incrementAssistantUsage(assistantId: string, options?: RequestOptions): Promise<AssistantResponse>;
|
|
45
|
-
duplicateAssistant(assistantId: string, newName: string, options?: RequestOptions): Promise<AssistantResponse>;
|
|
46
|
-
getAssistantModels(assistantId: string, options?: RequestOptions): Promise<AssistantModelsResponse>;
|
|
47
|
-
getProviders(options?: RequestOptions): Promise<{
|
|
48
|
-
providers: ProviderListItem[];
|
|
49
|
-
}>;
|
|
50
|
-
getProvider(providerKey: string, options?: RequestOptions): Promise<ProviderDetail>;
|
|
51
|
-
getAccessibleProviders(options?: RequestOptions): Promise<{
|
|
52
|
-
providers: ProviderListItem[];
|
|
53
|
-
}>;
|
|
54
|
-
getModels(params?: {
|
|
55
|
-
provider?: string;
|
|
56
|
-
capability?: string;
|
|
57
|
-
}, options?: RequestOptions): Promise<{
|
|
58
|
-
models: ModelListItem[];
|
|
59
|
-
}>;
|
|
60
|
-
getModel(modelId: string, options?: RequestOptions): Promise<ModelDetail>;
|
|
61
|
-
getModelsByProvider(providerKey: string, options?: RequestOptions): Promise<{
|
|
62
|
-
models: ModelListItem[];
|
|
63
|
-
}>;
|
|
64
|
-
getAccessibleModels(options?: RequestOptions): Promise<{
|
|
65
|
-
models: ModelListItem[];
|
|
66
|
-
}>;
|
|
67
|
-
}
|
package/lib/srvice/AiService.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AiService = void 0;
|
|
4
|
-
// src/service/AiService.ts
|
|
5
|
-
const BaseClient_1 = require("../client/BaseClient");
|
|
6
|
-
class AiService extends BaseClient_1.BaseClient {
|
|
7
|
-
constructor(config) {
|
|
8
|
-
super(config, 'ai');
|
|
9
|
-
}
|
|
10
|
-
// ==================== Chat对话接口 ====================
|
|
11
|
-
async chatCompletion(request, options) {
|
|
12
|
-
return this.request('/chat', {
|
|
13
|
-
...options,
|
|
14
|
-
method: 'POST',
|
|
15
|
-
body: request
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
async chatCompletionStream(request, options) {
|
|
19
|
-
return this.request('/chat/stream', {
|
|
20
|
-
...options,
|
|
21
|
-
method: 'POST',
|
|
22
|
-
body: request
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
// ==================== Session管理接口 ====================
|
|
26
|
-
async createSession(request, options) {
|
|
27
|
-
return this.request('/session', {
|
|
28
|
-
...options,
|
|
29
|
-
method: 'POST',
|
|
30
|
-
body: request
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async getSessions(params, options) {
|
|
34
|
-
return this.request('/session', {
|
|
35
|
-
...options,
|
|
36
|
-
method: 'GET',
|
|
37
|
-
params
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async getSession(sessionId, options) {
|
|
41
|
-
return this.request(`/session/${sessionId}`, {
|
|
42
|
-
...options,
|
|
43
|
-
method: 'GET'
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
async updateSession(sessionId, request, options) {
|
|
47
|
-
return this.request(`/session/${sessionId}`, {
|
|
48
|
-
...options,
|
|
49
|
-
method: 'PUT',
|
|
50
|
-
body: request
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
async endSession(sessionId, options) {
|
|
54
|
-
return this.request(`/session/${sessionId}/end`, {
|
|
55
|
-
...options,
|
|
56
|
-
method: 'POST'
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
async deleteSession(sessionId, options) {
|
|
60
|
-
return this.request(`/session/${sessionId}`, {
|
|
61
|
-
...options,
|
|
62
|
-
method: 'DELETE'
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async getSessionModelInfo(sessionId, options) {
|
|
66
|
-
return this.request(`/session/${sessionId}/model`, {
|
|
67
|
-
...options,
|
|
68
|
-
method: 'GET'
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
async getActiveSessions(options) {
|
|
72
|
-
return this.request('/session/active', {
|
|
73
|
-
...options,
|
|
74
|
-
method: 'GET'
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async switchSessionModel(sessionId, modelName, options) {
|
|
78
|
-
const request = { modelName };
|
|
79
|
-
return this.request(`/session/${sessionId}/switch-model`, {
|
|
80
|
-
...options,
|
|
81
|
-
method: 'POST',
|
|
82
|
-
body: request
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
async getSessionStatistics(timeRange, options) {
|
|
86
|
-
return this.request('/session/statistics', {
|
|
87
|
-
...options,
|
|
88
|
-
method: 'GET',
|
|
89
|
-
params: timeRange ? { timeRange } : undefined
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
async getSessionMessages(sessionId, params, options) {
|
|
93
|
-
return this.request(`/session/${sessionId}/messages`, {
|
|
94
|
-
...options,
|
|
95
|
-
method: 'GET',
|
|
96
|
-
params
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
async addMessageToSession(sessionId, request, options) {
|
|
100
|
-
return this.request(`/session/${sessionId}/message`, {
|
|
101
|
-
...options,
|
|
102
|
-
method: 'POST',
|
|
103
|
-
body: request
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
async deleteSessionsBatch(sessionIds, options) {
|
|
107
|
-
return this.request('/session/batch', {
|
|
108
|
-
...options,
|
|
109
|
-
method: 'DELETE',
|
|
110
|
-
body: { sessionIds }
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
// ==================== Assistant管理接口 ====================
|
|
114
|
-
async createAssistant(request, options) {
|
|
115
|
-
return this.request('/assistant', {
|
|
116
|
-
...options,
|
|
117
|
-
method: 'POST',
|
|
118
|
-
body: request
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
async getAssistants(params, options) {
|
|
122
|
-
return this.request('/assistant', {
|
|
123
|
-
...options,
|
|
124
|
-
method: 'GET',
|
|
125
|
-
params
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
async getAssistant(assistantId, options) {
|
|
129
|
-
return this.request(`/assistant/${assistantId}`, {
|
|
130
|
-
...options,
|
|
131
|
-
method: 'GET'
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
async updateAssistant(assistantId, request, options) {
|
|
135
|
-
return this.request(`/assistant/${assistantId}`, {
|
|
136
|
-
...options,
|
|
137
|
-
method: 'PUT',
|
|
138
|
-
body: request
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
async deleteAssistant(assistantId, options) {
|
|
142
|
-
return this.request(`/assistant/${assistantId}`, {
|
|
143
|
-
...options,
|
|
144
|
-
method: 'DELETE'
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
async getAccessibleAssistants(options) {
|
|
148
|
-
return this.request('/assistant/accessible', {
|
|
149
|
-
...options,
|
|
150
|
-
method: 'GET'
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
async getPopularAssistants(limit, options) {
|
|
154
|
-
return this.request('/assistant/popular', {
|
|
155
|
-
...options,
|
|
156
|
-
method: 'GET',
|
|
157
|
-
params: limit ? { limit } : undefined
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
async incrementAssistantUsage(assistantId, options) {
|
|
161
|
-
return this.request(`/assistant/${assistantId}/usage`, {
|
|
162
|
-
...options,
|
|
163
|
-
method: 'POST'
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
async duplicateAssistant(assistantId, newName, options) {
|
|
167
|
-
return this.request(`/assistant/${assistantId}/duplicate`, {
|
|
168
|
-
...options,
|
|
169
|
-
method: 'POST',
|
|
170
|
-
body: { newName }
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
async getAssistantModels(assistantId, options) {
|
|
174
|
-
return this.request(`/assistant/${assistantId}/models`, {
|
|
175
|
-
...options,
|
|
176
|
-
method: 'GET'
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
// ==================== Provider管理接口 ====================
|
|
180
|
-
async getProviders(options) {
|
|
181
|
-
return this.request('/provider', {
|
|
182
|
-
...options,
|
|
183
|
-
method: 'GET'
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
async getProvider(providerKey, options) {
|
|
187
|
-
return this.request(`/provider/${providerKey}`, {
|
|
188
|
-
...options,
|
|
189
|
-
method: 'GET'
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
async getAccessibleProviders(options) {
|
|
193
|
-
return this.request('/provider/accessible/me', {
|
|
194
|
-
...options,
|
|
195
|
-
method: 'GET'
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
// ==================== Model管理接口 ====================
|
|
199
|
-
async getModels(params, options) {
|
|
200
|
-
return this.request('/model', {
|
|
201
|
-
...options,
|
|
202
|
-
method: 'GET',
|
|
203
|
-
params
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
async getModel(modelId, options) {
|
|
207
|
-
return this.request(`/model/${modelId}`, {
|
|
208
|
-
...options,
|
|
209
|
-
method: 'GET'
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
async getModelsByProvider(providerKey, options) {
|
|
213
|
-
return this.request(`/model/by-provider/${providerKey}`, {
|
|
214
|
-
...options,
|
|
215
|
-
method: 'GET'
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
async getAccessibleModels(options) {
|
|
219
|
-
return this.request('/model/accessible/me', {
|
|
220
|
-
...options,
|
|
221
|
-
method: 'GET'
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
exports.AiService = AiService;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { BaseClient } from "../client/BaseClient";
|
|
2
|
-
import { ClientConfig, RequestOptions } from "../types";
|
|
3
|
-
import { TextGenerationRequest, TextGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, ChatCompletionRequest, ChatCompletionResponse, GaoqingTaskRequest, GaoqingTaskResponse, TwoDToThreeDTaskRequest, TwoDToThreeDTaskResponse, ImageRewriteTaskRequest, ImageRewriteTaskResponse, IndustrialDesignTaskRequest, IndustrialDesignTaskResponse, InpaintingTaskRequest, InpaintingTaskResponse, InteriorDesignTaskRequest, InteriorDesignTaskResponse, OldPhotoRestoreTaskRequest, OldPhotoRestoreTaskResponse, ProductBackgroundTaskRequest, ProductBackgroundTaskResponse, QingpingguoTaskRequest, QingpingguoTaskResponse, StyleTransferTaskRequest, StyleTransferTaskResponse, TaskStatusRequest, TaskStatusResponse } from "../types/aigc";
|
|
4
|
-
export declare class AigcService extends BaseClient {
|
|
5
|
-
constructor(config: ClientConfig);
|
|
6
|
-
generateText(request: TextGenerationRequest, options?: RequestOptions): Promise<TextGenerationResponse>;
|
|
7
|
-
generateImage(request: ImageGenerationRequest, options?: RequestOptions): Promise<ImageGenerationResponse>;
|
|
8
|
-
chatCompletion(request: ChatCompletionRequest, options?: RequestOptions): Promise<ChatCompletionResponse>;
|
|
9
|
-
submitGaoqingTask(request: GaoqingTaskRequest, options?: RequestOptions): Promise<GaoqingTaskResponse>;
|
|
10
|
-
submit2DToThreeDTask(request: TwoDToThreeDTaskRequest, options?: RequestOptions): Promise<TwoDToThreeDTaskResponse>;
|
|
11
|
-
submitImageRewriteTask(request: ImageRewriteTaskRequest, options?: RequestOptions): Promise<ImageRewriteTaskResponse>;
|
|
12
|
-
submitIndustrialDesignTask(request: IndustrialDesignTaskRequest, options?: RequestOptions): Promise<IndustrialDesignTaskResponse>;
|
|
13
|
-
submitInpaintingTask(request: InpaintingTaskRequest, options?: RequestOptions): Promise<InpaintingTaskResponse>;
|
|
14
|
-
submitInteriorDesignTask(request: InteriorDesignTaskRequest, options?: RequestOptions): Promise<InteriorDesignTaskResponse>;
|
|
15
|
-
submitOldPhotoRestoreTask(request: OldPhotoRestoreTaskRequest, options?: RequestOptions): Promise<OldPhotoRestoreTaskResponse>;
|
|
16
|
-
submitProductBackgroundTask(request: ProductBackgroundTaskRequest, options?: RequestOptions): Promise<ProductBackgroundTaskResponse>;
|
|
17
|
-
submitQingpingguoTask(request: QingpingguoTaskRequest, options?: RequestOptions): Promise<QingpingguoTaskResponse>;
|
|
18
|
-
submitStyleTransferTask(request: StyleTransferTaskRequest, options?: RequestOptions): Promise<StyleTransferTaskResponse>;
|
|
19
|
-
getTaskStatus(request: TaskStatusRequest, options?: RequestOptions): Promise<TaskStatusResponse>;
|
|
20
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AigcService = void 0;
|
|
4
|
-
const BaseClient_1 = require("../client/BaseClient");
|
|
5
|
-
class AigcService extends BaseClient_1.BaseClient {
|
|
6
|
-
constructor(config) {
|
|
7
|
-
super(config, 'aigc');
|
|
8
|
-
}
|
|
9
|
-
async generateText(request, options) {
|
|
10
|
-
return this.request('/text/generation', {
|
|
11
|
-
...options,
|
|
12
|
-
method: 'POST',
|
|
13
|
-
body: request
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
async generateImage(request, options) {
|
|
17
|
-
return this.request('/image/generation', {
|
|
18
|
-
...options,
|
|
19
|
-
method: 'POST',
|
|
20
|
-
body: request
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
async chatCompletion(request, options) {
|
|
24
|
-
return this.request('/chat/completion', {
|
|
25
|
-
...options,
|
|
26
|
-
method: 'POST',
|
|
27
|
-
body: request
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
// 高清面部修复任务
|
|
31
|
-
async submitGaoqingTask(request, options) {
|
|
32
|
-
return this.request('/lib/gaoqing/tasks', {
|
|
33
|
-
...options,
|
|
34
|
-
method: 'POST',
|
|
35
|
-
body: request
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
// 2D转3D任务
|
|
39
|
-
async submit2DToThreeDTask(request, options) {
|
|
40
|
-
return this.request('/lib/2d23d/tasks', {
|
|
41
|
-
...options,
|
|
42
|
-
method: 'POST',
|
|
43
|
-
body: request
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// 图生图重写任务
|
|
47
|
-
async submitImageRewriteTask(request, options) {
|
|
48
|
-
return this.request('/lib/rewrite/tasks', {
|
|
49
|
-
...options,
|
|
50
|
-
method: 'POST',
|
|
51
|
-
body: request
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
// 工业设计任务
|
|
55
|
-
async submitIndustrialDesignTask(request, options) {
|
|
56
|
-
return this.request('/lib/industrial-design/tasks', {
|
|
57
|
-
...options,
|
|
58
|
-
method: 'POST',
|
|
59
|
-
body: request
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
// 智能涂抹消除任务
|
|
63
|
-
async submitInpaintingTask(request, options) {
|
|
64
|
-
return this.request('/lib/inpainting/tasks', {
|
|
65
|
-
...options,
|
|
66
|
-
method: 'POST',
|
|
67
|
-
body: request
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
// 智能装修任务
|
|
71
|
-
async submitInteriorDesignTask(request, options) {
|
|
72
|
-
return this.request('/lib/interior-design/tasks', {
|
|
73
|
-
...options,
|
|
74
|
-
method: 'POST',
|
|
75
|
-
body: request
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
// 老照片修复任务
|
|
79
|
-
async submitOldPhotoRestoreTask(request, options) {
|
|
80
|
-
return this.request('/lib/old-photo/tasks', {
|
|
81
|
-
...options,
|
|
82
|
-
method: 'POST',
|
|
83
|
-
body: request
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
// 产品换背景任务
|
|
87
|
-
async submitProductBackgroundTask(request, options) {
|
|
88
|
-
return this.request('/lib/product-background/tasks', {
|
|
89
|
-
...options,
|
|
90
|
-
method: 'POST',
|
|
91
|
-
body: request
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
// 青苹果风格洗稿任务
|
|
95
|
-
async submitQingpingguoTask(request, options) {
|
|
96
|
-
return this.request('/lib/qingpingguo/tasks', {
|
|
97
|
-
...options,
|
|
98
|
-
method: 'POST',
|
|
99
|
-
body: request
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
// 风格转绘任务
|
|
103
|
-
async submitStyleTransferTask(request, options) {
|
|
104
|
-
return this.request('/lib/style-transfer/tasks', {
|
|
105
|
-
...options,
|
|
106
|
-
method: 'POST',
|
|
107
|
-
body: request
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
// 获取任务状态
|
|
111
|
-
async getTaskStatus(request, options) {
|
|
112
|
-
return this.request(`/lib/comfy/tasks/${request.taskId}`, {
|
|
113
|
-
...options,
|
|
114
|
-
method: 'GET'
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
exports.AigcService = AigcService;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseClient } from "../client/BaseClient";
|
|
2
|
-
import { ClientConfig, RequestOptions } from "../types";
|
|
3
|
-
import { LoginResponse, TemporaryTokenRequest, TemporaryTokenResponse, VerifyTemporaryTokenRequest, VerifyTemporaryTokenResponse, WechatLoginCredentials } from "../types/user";
|
|
4
|
-
export declare class AuthService extends BaseClient {
|
|
5
|
-
constructor(config: ClientConfig);
|
|
6
|
-
login(identifier: string, password: string, projectId?: number, options?: RequestOptions): Promise<LoginResponse>;
|
|
7
|
-
wechatMiniProgramLogin(credentials: WechatLoginCredentials, projectId?: number, options?: RequestOptions): Promise<LoginResponse>;
|
|
8
|
-
createTemporaryToken(request?: TemporaryTokenRequest, options?: RequestOptions): Promise<TemporaryTokenResponse>;
|
|
9
|
-
verifyTemporaryToken(request: VerifyTemporaryTokenRequest, options?: RequestOptions): Promise<VerifyTemporaryTokenResponse>;
|
|
10
|
-
logout(token: string, options?: RequestOptions): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AuthService = void 0;
|
|
7
|
-
// client/npm/src/service/AuthService.ts
|
|
8
|
-
const BaseClient_1 = require("../client/BaseClient");
|
|
9
|
-
const qs_1 = __importDefault(require("qs"));
|
|
10
|
-
class AuthService extends BaseClient_1.BaseClient {
|
|
11
|
-
constructor(config) {
|
|
12
|
-
super(config, 'auth');
|
|
13
|
-
}
|
|
14
|
-
// 用户登录 - 匹配后端请求格式
|
|
15
|
-
async login(identifier, password, projectId = 0, options) {
|
|
16
|
-
const body = qs_1.default.stringify({
|
|
17
|
-
grant_type: "password",
|
|
18
|
-
username: identifier,
|
|
19
|
-
password
|
|
20
|
-
});
|
|
21
|
-
return this.request('/login', {
|
|
22
|
-
...options,
|
|
23
|
-
method: 'POST',
|
|
24
|
-
headers: {
|
|
25
|
-
...options?.headers,
|
|
26
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
27
|
-
},
|
|
28
|
-
params: {
|
|
29
|
-
project_id: projectId
|
|
30
|
-
},
|
|
31
|
-
body: body
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
// 微信小程序登录 - 新增接口
|
|
35
|
-
async wechatMiniProgramLogin(credentials, projectId = 0, options) {
|
|
36
|
-
return this.request('/wxmp/login', {
|
|
37
|
-
...options,
|
|
38
|
-
method: 'POST',
|
|
39
|
-
headers: {
|
|
40
|
-
...options?.headers,
|
|
41
|
-
"Content-Type": "application/json",
|
|
42
|
-
"x-project-id": projectId.toString()
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify(credentials)
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
// 签发临时令牌 - 新增接口
|
|
48
|
-
async createTemporaryToken(request = { expires_in: 300 }, options) {
|
|
49
|
-
return this.request('/temporary-token', {
|
|
50
|
-
...options,
|
|
51
|
-
method: 'POST',
|
|
52
|
-
headers: {
|
|
53
|
-
...options?.headers,
|
|
54
|
-
"Content-Type": "application/json"
|
|
55
|
-
},
|
|
56
|
-
body: JSON.stringify(request)
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
// 验证临时令牌 - 新增接口(业务系统调用)
|
|
60
|
-
async verifyTemporaryToken(request, options) {
|
|
61
|
-
return this.request('/verify-temporary-token', {
|
|
62
|
-
...options,
|
|
63
|
-
method: 'POST',
|
|
64
|
-
headers: {
|
|
65
|
-
...options?.headers,
|
|
66
|
-
"Content-Type": "application/json"
|
|
67
|
-
},
|
|
68
|
-
body: JSON.stringify(request)
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
// 用户登出 - 匹配后端请求格式
|
|
72
|
-
async logout(token, options) {
|
|
73
|
-
return this.request('/logout', {
|
|
74
|
-
...options,
|
|
75
|
-
method: 'POST',
|
|
76
|
-
headers: {
|
|
77
|
-
...options?.headers,
|
|
78
|
-
Authorization: `Bearer ${token}`
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.AuthService = AuthService;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseClient } from "../client/BaseClient";
|
|
2
|
-
import { ClientConfig, RequestOptions } from "../types";
|
|
3
|
-
import { BatchCreateMessageRequest, BatchMarkAsReadRequest, CategoryInfo, CreateMessageRequest, FeishuMessage, MailRequest, MarkAsReadRequest, Message, MessageQueryParams, MessageStats } from "../types/msg";
|
|
4
|
-
export declare class MsgService extends BaseClient {
|
|
5
|
-
constructor(config: ClientConfig);
|
|
6
|
-
sendMail(request: MailRequest, options?: RequestOptions): Promise<void>;
|
|
7
|
-
sendFeishuMessage(message: FeishuMessage, options?: RequestOptions): Promise<void>;
|
|
8
|
-
getMessages(params?: MessageQueryParams, options?: RequestOptions): Promise<Message[]>;
|
|
9
|
-
getAdminMessages(params?: MessageQueryParams, options?: RequestOptions): Promise<Message[]>;
|
|
10
|
-
markAsRead(messageId: string, request?: MarkAsReadRequest, options?: RequestOptions): Promise<Message>;
|
|
11
|
-
markManyAsRead(request: BatchMarkAsReadRequest, options?: RequestOptions): Promise<{
|
|
12
|
-
modifiedCount: number;
|
|
13
|
-
}>;
|
|
14
|
-
deleteMessage(messageId: string, request?: MarkAsReadRequest, options?: RequestOptions): Promise<Message>;
|
|
15
|
-
getUnreadStats(userId?: string, options?: RequestOptions): Promise<MessageStats>;
|
|
16
|
-
getCategories(options?: RequestOptions): Promise<CategoryInfo[]>;
|
|
17
|
-
createMessage(request: CreateMessageRequest, options?: RequestOptions): Promise<Message>;
|
|
18
|
-
createManyMessages(request: BatchCreateMessageRequest, options?: RequestOptions): Promise<{
|
|
19
|
-
createdCount: number;
|
|
20
|
-
messages: Message[];
|
|
21
|
-
}>;
|
|
22
|
-
}
|
package/lib/srvice/MsgService.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MsgService = void 0;
|
|
4
|
-
// client/npm/src/service/MsgService.ts
|
|
5
|
-
const BaseClient_1 = require("../client/BaseClient");
|
|
6
|
-
class MsgService extends BaseClient_1.BaseClient {
|
|
7
|
-
constructor(config) {
|
|
8
|
-
super(config, 'msg');
|
|
9
|
-
}
|
|
10
|
-
// 发送邮件
|
|
11
|
-
async sendMail(request, options) {
|
|
12
|
-
return this.request('/mail/send', {
|
|
13
|
-
...options,
|
|
14
|
-
method: 'POST',
|
|
15
|
-
body: request
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
// 发送飞书消息
|
|
19
|
-
async sendFeishuMessage(message, options) {
|
|
20
|
-
return this.request('/webhook/feishu/send', {
|
|
21
|
-
...options,
|
|
22
|
-
method: 'POST',
|
|
23
|
-
body: message
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
// === 消息中心相关接口 ===
|
|
27
|
-
// 获取用户消息列表
|
|
28
|
-
async getMessages(params, options) {
|
|
29
|
-
return this.request('/message/list', {
|
|
30
|
-
...options,
|
|
31
|
-
method: 'GET',
|
|
32
|
-
params: params // 使用 params 而不是 query
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// 管理员获取消息列表(需要管理员权限)
|
|
36
|
-
async getAdminMessages(params, options) {
|
|
37
|
-
return this.request('/message/admin/list', {
|
|
38
|
-
...options,
|
|
39
|
-
method: 'GET',
|
|
40
|
-
params: params // 使用 params 而不是 query
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
// 标记单条消息为已读
|
|
44
|
-
async markAsRead(messageId, request, options) {
|
|
45
|
-
return this.request(`/message/${messageId}/read`, {
|
|
46
|
-
...options,
|
|
47
|
-
method: 'PATCH',
|
|
48
|
-
body: request
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
// 批量标记消息为已读
|
|
52
|
-
async markManyAsRead(request, options) {
|
|
53
|
-
return this.request('/message/batch/read', {
|
|
54
|
-
...options,
|
|
55
|
-
method: 'PATCH',
|
|
56
|
-
body: request
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
// 删除消息(软删除)
|
|
60
|
-
async deleteMessage(messageId, request, options) {
|
|
61
|
-
return this.request(`/message/${messageId}`, {
|
|
62
|
-
...options,
|
|
63
|
-
method: 'DELETE',
|
|
64
|
-
body: request
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// 获取未读消息统计
|
|
68
|
-
async getUnreadStats(userId, options) {
|
|
69
|
-
return this.request('/message/stats', {
|
|
70
|
-
...options,
|
|
71
|
-
method: 'GET',
|
|
72
|
-
params: userId ? { userId } : undefined // 使用 params 而不是 query
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
// 获取用户消息分类
|
|
76
|
-
async getCategories(options) {
|
|
77
|
-
return this.request('/message/categories', {
|
|
78
|
-
...options,
|
|
79
|
-
method: 'GET'
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
// 创建消息(需要管理员权限)
|
|
83
|
-
async createMessage(request, options) {
|
|
84
|
-
return this.request('/message', {
|
|
85
|
-
...options,
|
|
86
|
-
method: 'POST',
|
|
87
|
-
body: request
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
// 批量创建消息(需要管理员权限)
|
|
91
|
-
async createManyMessages(request, options) {
|
|
92
|
-
return this.request('/message/batch', {
|
|
93
|
-
...options,
|
|
94
|
-
method: 'POST',
|
|
95
|
-
body: request
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.MsgService = MsgService;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseClient } from "../client/BaseClient";
|
|
2
|
-
import { ClientConfig, RequestOptions } from "../types";
|
|
3
|
-
import { WxOfficialAccountTokenResponse, WxJsapiTicketResponse, WxSignatureRequest, WxSignatureResponse, WxMiniProgramTokenResponse, WxMiniProgramLoginResponse } from "../types/token";
|
|
4
|
-
export declare class TokenService extends BaseClient {
|
|
5
|
-
constructor(config: ClientConfig);
|
|
6
|
-
getWxOfficialAccountToken(appid: string, options?: RequestOptions): Promise<WxOfficialAccountTokenResponse>;
|
|
7
|
-
getWxJsapiTicket(appid: string, options?: RequestOptions): Promise<WxJsapiTicketResponse>;
|
|
8
|
-
getWxSignature(signatureRequest: WxSignatureRequest, options?: RequestOptions): Promise<WxSignatureResponse>;
|
|
9
|
-
getWxMiniProgramToken(appid: string, options?: RequestOptions): Promise<WxMiniProgramTokenResponse>;
|
|
10
|
-
wxMiniProgramLogin(appid: string, code: string, options?: RequestOptions): Promise<WxMiniProgramLoginResponse>;
|
|
11
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TokenService = void 0;
|
|
4
|
-
const BaseClient_1 = require("../client/BaseClient");
|
|
5
|
-
class TokenService extends BaseClient_1.BaseClient {
|
|
6
|
-
constructor(config) {
|
|
7
|
-
super(config, 'token');
|
|
8
|
-
}
|
|
9
|
-
// 获取微信公众号access_token
|
|
10
|
-
async getWxOfficialAccountToken(appid, options) {
|
|
11
|
-
return this.request('/wxh5/accesstoken', {
|
|
12
|
-
...options,
|
|
13
|
-
method: 'GET',
|
|
14
|
-
params: { appid }
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
// 获取微信公众号jsapi_ticket
|
|
18
|
-
async getWxJsapiTicket(appid, options) {
|
|
19
|
-
return this.request('/wxh5/jsapi_ticket', {
|
|
20
|
-
...options,
|
|
21
|
-
method: 'GET',
|
|
22
|
-
params: { appid }
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
// 获取微信公众号签名
|
|
26
|
-
async getWxSignature(signatureRequest, options) {
|
|
27
|
-
return this.request('/wxh5/signature', {
|
|
28
|
-
...options,
|
|
29
|
-
method: 'POST',
|
|
30
|
-
body: signatureRequest
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// 获取微信小程序access_token
|
|
34
|
-
async getWxMiniProgramToken(appid, options) {
|
|
35
|
-
return this.request('/wxmp/accesstoken', {
|
|
36
|
-
...options,
|
|
37
|
-
method: 'GET',
|
|
38
|
-
params: { appid }
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
// 微信小程序登录 - 使用code换取session信息
|
|
42
|
-
async wxMiniProgramLogin(appid, code, options) {
|
|
43
|
-
return this.request('/wxmp/login', {
|
|
44
|
-
...options,
|
|
45
|
-
method: 'POST',
|
|
46
|
-
body: { appid, code }
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.TokenService = TokenService;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseClient } from "../client/BaseClient";
|
|
2
|
-
import { ClientConfig, RequestOptions, PaginatedResponse } from "../types";
|
|
3
|
-
import { User, UserCreateRequest, UserUpdateRequest } from "../types/user";
|
|
4
|
-
export declare class UserService extends BaseClient {
|
|
5
|
-
constructor(config: ClientConfig);
|
|
6
|
-
getCurrentUser(options?: RequestOptions): Promise<User>;
|
|
7
|
-
getUserById(userId: number, options?: RequestOptions): Promise<User>;
|
|
8
|
-
createUser(userData: UserCreateRequest, options?: RequestOptions): Promise<User>;
|
|
9
|
-
updateUser(userId: number, updateData: UserUpdateRequest, options?: RequestOptions): Promise<User>;
|
|
10
|
-
listUsers(includeInactive?: boolean, page?: number, perPage?: number, projectId?: number, options?: RequestOptions): Promise<PaginatedResponse<User>>;
|
|
11
|
-
deactivateUser(userId: number, options?: RequestOptions): Promise<{
|
|
12
|
-
id: number;
|
|
13
|
-
}>;
|
|
14
|
-
restoreUser(userId: number, options?: RequestOptions): Promise<User>;
|
|
15
|
-
resetPassword(userId: number, newPassword: string, options?: RequestOptions): Promise<{
|
|
16
|
-
id: number;
|
|
17
|
-
}>;
|
|
18
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserService = void 0;
|
|
4
|
-
const BaseClient_1 = require("../client/BaseClient");
|
|
5
|
-
class UserService extends BaseClient_1.BaseClient {
|
|
6
|
-
constructor(config) {
|
|
7
|
-
super(config, 'users');
|
|
8
|
-
}
|
|
9
|
-
// 获取当前用户信息
|
|
10
|
-
async getCurrentUser(options) {
|
|
11
|
-
return this.request('/me', {
|
|
12
|
-
...options,
|
|
13
|
-
method: 'GET'
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
// 获取用户详情(管理员)
|
|
17
|
-
async getUserById(userId, options) {
|
|
18
|
-
return this.request(`/${userId}`, {
|
|
19
|
-
...options,
|
|
20
|
-
method: 'GET'
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
// 创建用户(管理员)
|
|
24
|
-
async createUser(userData, options) {
|
|
25
|
-
return this.request('', {
|
|
26
|
-
...options,
|
|
27
|
-
method: 'POST',
|
|
28
|
-
body: {
|
|
29
|
-
username: userData.username,
|
|
30
|
-
email: userData.email,
|
|
31
|
-
password: userData.password,
|
|
32
|
-
name: userData.name,
|
|
33
|
-
role: userData.role,
|
|
34
|
-
phone: userData.phone,
|
|
35
|
-
project_id: userData.project_id
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
// 更新用户信息
|
|
40
|
-
async updateUser(userId, updateData, options) {
|
|
41
|
-
return this.request(`/${userId}`, {
|
|
42
|
-
...options,
|
|
43
|
-
method: 'PUT',
|
|
44
|
-
body: {
|
|
45
|
-
name: updateData.name,
|
|
46
|
-
avatar: updateData.avatar,
|
|
47
|
-
phone: updateData.phone,
|
|
48
|
-
role: updateData.role,
|
|
49
|
-
project_id: updateData.project_id
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
// 获取用户列表(支持项目过滤)
|
|
54
|
-
async listUsers(includeInactive = false, page = 1, perPage = 10, projectId, options) {
|
|
55
|
-
const params = {
|
|
56
|
-
include_inactive: includeInactive,
|
|
57
|
-
page,
|
|
58
|
-
per_page: perPage
|
|
59
|
-
};
|
|
60
|
-
if (projectId !== undefined) {
|
|
61
|
-
params.project_id = projectId;
|
|
62
|
-
}
|
|
63
|
-
const response = await this.paginatedRequest('', {
|
|
64
|
-
...options,
|
|
65
|
-
method: 'GET',
|
|
66
|
-
params
|
|
67
|
-
});
|
|
68
|
-
return response;
|
|
69
|
-
}
|
|
70
|
-
// 停用用户(管理员)
|
|
71
|
-
async deactivateUser(userId, options) {
|
|
72
|
-
return this.request(`/${userId}`, {
|
|
73
|
-
...options,
|
|
74
|
-
method: 'DELETE'
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
// 恢复用户(管理员)
|
|
78
|
-
async restoreUser(userId, options) {
|
|
79
|
-
return this.request(`/${userId}/restore`, {
|
|
80
|
-
...options,
|
|
81
|
-
method: 'POST'
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
// 重置密码(管理员)
|
|
85
|
-
async resetPassword(userId, newPassword, options) {
|
|
86
|
-
return this.request(`/${userId}/password`, {
|
|
87
|
-
...options,
|
|
88
|
-
method: 'PUT',
|
|
89
|
-
body: {
|
|
90
|
-
new_password: newPassword
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.UserService = UserService;
|