qing-client 0.0.17 → 0.0.19

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 ADDED
@@ -0,0 +1,255 @@
1
+ # qing-client
2
+
3
+ `qing-client` 是一个统一的 JavaScript / TypeScript SDK,用于访问 Qing 平台提供的各类服务能力,包括:
4
+
5
+ * 用户与认证
6
+ * 消息中心
7
+ * AI / AIGC 能力
8
+ * 静态 HTML 托管(gateway-h5)
9
+
10
+ 该 SDK 为 **公开 npm 包**,任何 **拥有合法账号的第三方开发者** 均可使用。
11
+
12
+ ---
13
+
14
+ ## 特性
15
+
16
+ * 前后端统一 SDK
17
+ * 支持 浏览器 / H5 / 移动端 / Node.js
18
+ * 自动处理认证与请求头
19
+ * 支持多服务调用
20
+ * 完整 TypeScript 类型定义
21
+ * 支持静态前端托管管理(上传 zip)
22
+
23
+ ---
24
+
25
+ ## 安装
26
+
27
+ ```bash
28
+ npm install qing-client
29
+ ```
30
+
31
+
32
+
33
+ ```bash
34
+ yarn add qing-client
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 使用模式说明
40
+
41
+ SDK 根据初始化方式不同,分为 **前端模式** 和 **后端模式**。
42
+
43
+ ### 前端模式(推荐)
44
+
45
+ 适用于:
46
+
47
+ * 浏览器
48
+ * H5 页面
49
+ * App WebView
50
+ * 移动端前端应用
51
+
52
+ 所有请求会通过 API 网关转发。
53
+
54
+ ### 后端模式
55
+
56
+ 适用于:
57
+
58
+ * Node.js 服务
59
+ * 后端应用
60
+ * 内部服务调用
61
+
62
+ 请求会直连具体服务地址。
63
+
64
+ ---
65
+
66
+ ## 前端模式示例(客户端 / 移动端)
67
+
68
+ ### 初始化 Client
69
+
70
+ ```ts
71
+ import { Client } from "qing-client";
72
+
73
+ const client = new Client({
74
+ gatewayUrl: "https://api.example.com",
75
+ projectId: "your-project-id",
76
+ appId: "your-app-id",
77
+ });
78
+ ```
79
+
80
+ ### 设置访问令牌
81
+
82
+ ```ts
83
+ await client.setToken("YOUR_ACCESS_TOKEN");
84
+ ```
85
+
86
+ SDK 会自动为所有请求附加:
87
+
88
+ * `Authorization: Bearer <token>`
89
+ * `x-project-id`
90
+ * `x-app-id`
91
+
92
+ ---
93
+
94
+ ## 后端模式示例(Node.js)
95
+
96
+ ```ts
97
+ import { Client } from "qing-client";
98
+
99
+ const client = new Client({
100
+ authServiceUrl: "http://auth-service",
101
+ userServiceUrl: "http://user-service",
102
+ gatewayH5ServiceUrl: "http://gateway-h5-service",
103
+ });
104
+ ```
105
+
106
+ ### 设置用户上下文(仅后端模式)
107
+
108
+ ```ts
109
+ client.setUserContext({
110
+ userId: "123",
111
+ role: "ADMIN",
112
+ projectId: "project-1",
113
+ });
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 用户与认证
119
+
120
+ ### 登录
121
+
122
+ ```ts
123
+ const result = await client.auth.login("username", "password");
124
+ await client.setToken(result.access_token);
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 消息与用户服务
130
+
131
+ ```ts
132
+ // 获取当前用户
133
+ const user = await client.user.getCurrentUser();
134
+
135
+ // 获取消息列表
136
+ const messages = await client.msg.getMessages();
137
+ ```
138
+
139
+ ---
140
+
141
+ ## AI / AIGC 示例
142
+
143
+ ```ts
144
+ const response = await client.ai.chatCompletion({
145
+ sessionId: "session-id",
146
+ message: "你好",
147
+ });
148
+ ```
149
+
150
+ ---
151
+
152
+ ## HTML 静态托管(gateway-h5)
153
+
154
+ SDK 提供了静态 HTML 托管管理能力,用于上传和管理前端站点。
155
+
156
+ > ⚠️ **重要说明**
157
+ >
158
+ > 平台 **不会** 帮你构建前端项目
159
+ > 你需要 **自行 build 前端项目**,并将构建产物打包为 `.zip` 上传
160
+
161
+ ---
162
+
163
+ ### 标准流程
164
+
165
+ 1. 使用你自己的前端工具构建项目(如 Vite / Vue / React / Nuxt 静态模式)
166
+ 2. 将构建产物打包为 zip
167
+
168
+ * `index.html` 必须位于 zip 根目录
169
+ 3. 通过 API 上传 zip 进行部署
170
+
171
+ ---
172
+
173
+ ### 创建托管项目
174
+
175
+ ```ts
176
+ import { FrontHostService } from "qing-client";
177
+
178
+ const fronthost = new FrontHostService({
179
+ gatewayUrl: "https://api.example.com",
180
+ projectId: "your-project-id",
181
+ appId: "your-app-id",
182
+ });
183
+
184
+ await fronthost.setToken("YOUR_ACCESS_TOKEN");
185
+
186
+ await fronthost.createProject({
187
+ deployType: "route",
188
+ routePath: "/my-app",
189
+ file: zipFile, // File 或 Blob(.zip)
190
+ });
191
+ ```
192
+
193
+ ---
194
+
195
+ ### 部署新版本
196
+
197
+ ```ts
198
+ await fronthost.deployNewVersion(projectId, zipFile);
199
+ ```
200
+
201
+ ---
202
+
203
+ ### 支持的部署类型
204
+
205
+ | 类型 | 说明 |
206
+ | ----------- | ------------- |
207
+ | `route` | 路径托管,如 `/app` |
208
+ | `subdomain` | 子域名托管 |
209
+ | `proxy` | 自定义域名托管 |
210
+
211
+ ---
212
+
213
+ ## Token 存储说明
214
+
215
+ 默认情况下,Token 存储在内存中,刷新页面后会丢失。
216
+
217
+ 如需持久化登录状态,可自定义 Token 存储:
218
+
219
+ ```ts
220
+ const client = new Client({
221
+ gatewayUrl: "...",
222
+ tokenStorage: {
223
+ async getToken() {
224
+ return localStorage.getItem("token") || undefined;
225
+ },
226
+ async setToken(token) {
227
+ localStorage.setItem("token", token);
228
+ },
229
+ async clearToken() {
230
+ localStorage.removeItem("token");
231
+ },
232
+ },
233
+ });
234
+ ```
235
+
236
+ ---
237
+
238
+ ## TypeScript 支持
239
+
240
+ SDK 完全使用 TypeScript 编写,并自带类型声明文件。
241
+
242
+ ---
243
+
244
+ ## 安全与隐私
245
+
246
+ * 不暴露任何内部服务实现
247
+ * 不包含任何敏感信息
248
+ * 所有认证信息由使用方自行提供
249
+ * 适合公开发布到 npm
250
+
251
+ ---
252
+
253
+ ## License
254
+
255
+ MIT
@@ -125,11 +125,13 @@ class BaseClient {
125
125
  case 'auth': return this.config.authServiceUrl;
126
126
  case 'msg': return this.config.msgServiceUrl;
127
127
  case 'users': return this.config.userServiceUrl;
128
- case 'file': return this.config.fileServiceUrl;
128
+ case 'file': return this.config.fileServiceUrl; // V1 兼容路由
129
+ case 'files': return this.config.fileServiceUrl; // V2 新路由
129
130
  case 'survey': return this.config.surveyServiceUrl;
130
131
  case 'token': return this.config.tokenServiceUrl;
131
132
  case 'aigc': return this.config.aigcServiceUrl;
132
133
  case "logs": return this.config.auditLogServiceUrl;
134
+ case "gateway-h5": return this.config.gatewayH5ServiceUrl;
133
135
  default: throw new Error(`Unsupported service: ${this.serviceName}`);
134
136
  }
135
137
  }
@@ -229,7 +231,7 @@ class BaseClient {
229
231
  return response.data;
230
232
  }
231
233
  catch (error) {
232
- this.handleApiError(error, path);
234
+ return this.handleApiError(error, path);
233
235
  }
234
236
  }
235
237
  // 统一错误处理方法
package/lib/index.d.ts CHANGED
@@ -3,10 +3,17 @@ export { AuthService } from './service/AuthService';
3
3
  export { MsgService } from './service/MsgService';
4
4
  export { TokenService } from './service/TokenService';
5
5
  export { UserService } from './service/UserService';
6
+ export { FileService } from './service/FileService';
6
7
  export { AigcService } from './service/AigcService';
7
8
  export { AuditLogService } from "./service/AuditLogService";
9
+ export { FrontHostService } from "./service/FrontHostService";
8
10
  export * from './types';
9
11
  export * from './types/msg';
10
12
  export * from './types/token';
11
13
  export * from './types/user';
14
+ export * from './types/file';
15
+ export * from "./types/fronthost";
16
+ export * from "./types/audit";
17
+ export * from "./types/aigc";
18
+ export { ApiSuccessResponse, ApiErrorResponse, PaginatedResponse, ChatCompletionRequest, ChatCompletionResponse, ChatCompletionStreamResponse, ProviderListItem, ProviderDetail, ProviderModel, ModelListItem, ModelDetail, ModelConfig, CreateAssistantRequest, UpdateAssistantRequest, AssistantResponse, AssistantListResponse, SessionMessage, SessionResponse, SessionListResponse, SessionDetailResponse, SessionStatistics, PaginatedSessionMessageResponse, SessionMessageDetail, BatchDeleteSessionsResponse, AssistantModelsResponse, ModelInfoResponse, AddMessageRequest, SwitchModelRequest, } from "./types/ai";
12
19
  export { BaseClient } from './client/BaseClient';
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.AuditLogService = exports.AigcService = exports.UserService = exports.TokenService = exports.MsgService = exports.AuthService = exports.Client = void 0;
17
+ exports.BaseClient = 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; } });
@@ -27,14 +27,22 @@ var TokenService_1 = require("./service/TokenService");
27
27
  Object.defineProperty(exports, "TokenService", { enumerable: true, get: function () { return TokenService_1.TokenService; } });
28
28
  var UserService_1 = require("./service/UserService");
29
29
  Object.defineProperty(exports, "UserService", { enumerable: true, get: function () { return UserService_1.UserService; } });
30
+ var FileService_1 = require("./service/FileService");
31
+ Object.defineProperty(exports, "FileService", { enumerable: true, get: function () { return FileService_1.FileService; } });
30
32
  var AigcService_1 = require("./service/AigcService");
31
33
  Object.defineProperty(exports, "AigcService", { enumerable: true, get: function () { return AigcService_1.AigcService; } });
32
34
  var AuditLogService_1 = require("./service/AuditLogService");
33
35
  Object.defineProperty(exports, "AuditLogService", { enumerable: true, get: function () { return AuditLogService_1.AuditLogService; } });
36
+ var FrontHostService_1 = require("./service/FrontHostService");
37
+ Object.defineProperty(exports, "FrontHostService", { enumerable: true, get: function () { return FrontHostService_1.FrontHostService; } });
34
38
  // 导出所有类型定义
35
39
  __exportStar(require("./types"), exports);
36
40
  __exportStar(require("./types/msg"), exports);
37
41
  __exportStar(require("./types/token"), exports);
38
42
  __exportStar(require("./types/user"), exports);
43
+ __exportStar(require("./types/file"), exports);
44
+ __exportStar(require("./types/fronthost"), exports);
45
+ __exportStar(require("./types/audit"), exports);
46
+ __exportStar(require("./types/aigc"), exports);
39
47
  var BaseClient_1 = require("./client/BaseClient");
40
48
  Object.defineProperty(exports, "BaseClient", { enumerable: true, get: function () { return BaseClient_1.BaseClient; } });
@@ -0,0 +1,33 @@
1
+ import { BaseClient } from "../client/BaseClient";
2
+ import { ClientConfig, RequestOptions, PaginatedResponse } from "../types";
3
+ import { File, CreateFileRequest, UpdateFileRequest, FileListQuery } from "../types/file";
4
+ export declare class FileService extends BaseClient {
5
+ constructor(config: ClientConfig);
6
+ /**
7
+ * 创建文件记录(OSS回调使用)
8
+ * POST /api/files (网关转发到 /api/v1/files)
9
+ */
10
+ createFile(fileData: CreateFileRequest, options?: RequestOptions): Promise<File>;
11
+ /**
12
+ * 获取文件详情
13
+ * GET /api/files/:id (网关转发到 /api/v1/files/:id)
14
+ */
15
+ getFileById(fileId: string, options?: RequestOptions): Promise<File>;
16
+ /**
17
+ * 更新文件
18
+ * PUT /api/files/:id (网关转发到 /api/v1/files/:id)
19
+ */
20
+ updateFile(fileId: string, updateData: UpdateFileRequest, options?: RequestOptions): Promise<File>;
21
+ /**
22
+ * 删除文件
23
+ * DELETE /api/files/:id (网关转发到 /api/v1/files/:id)
24
+ */
25
+ deleteFile(fileId: string, options?: RequestOptions): Promise<{
26
+ message: string;
27
+ }>;
28
+ /**
29
+ * 获取文件列表
30
+ * GET /api/files (网关转发到 /api/v1/files)
31
+ */
32
+ listFiles(query?: FileListQuery, options?: RequestOptions): Promise<PaginatedResponse<File>>;
33
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileService = void 0;
4
+ const BaseClient_1 = require("../client/BaseClient");
5
+ class FileService extends BaseClient_1.BaseClient {
6
+ constructor(config) {
7
+ super(config, 'files');
8
+ }
9
+ /**
10
+ * 创建文件记录(OSS回调使用)
11
+ * POST /api/files (网关转发到 /api/v1/files)
12
+ */
13
+ async createFile(fileData, options) {
14
+ return this.request('', {
15
+ ...options,
16
+ method: 'POST',
17
+ body: {
18
+ bucket: fileData.bucket,
19
+ object: fileData.object,
20
+ url: fileData.url,
21
+ taskId: fileData.taskId,
22
+ size: fileData.size,
23
+ mimeType: fileData.mimeType,
24
+ fileExtension: fileData.fileExtension,
25
+ description: fileData.description,
26
+ source: fileData.source || '阿里云',
27
+ acl: fileData.acl || 'private',
28
+ etag: fileData.etag,
29
+ contentMd5: fileData.contentMd5,
30
+ folderId: fileData.folderId
31
+ }
32
+ });
33
+ }
34
+ /**
35
+ * 获取文件详情
36
+ * GET /api/files/:id (网关转发到 /api/v1/files/:id)
37
+ */
38
+ async getFileById(fileId, options) {
39
+ return this.request(`/${fileId}`, {
40
+ ...options,
41
+ method: 'GET'
42
+ });
43
+ }
44
+ /**
45
+ * 更新文件
46
+ * PUT /api/files/:id (网关转发到 /api/v1/files/:id)
47
+ */
48
+ async updateFile(fileId, updateData, options) {
49
+ return this.request(`/${fileId}`, {
50
+ ...options,
51
+ method: 'PUT',
52
+ body: {
53
+ acl: updateData.acl,
54
+ description: updateData.description,
55
+ folderId: updateData.folderId
56
+ }
57
+ });
58
+ }
59
+ /**
60
+ * 删除文件
61
+ * DELETE /api/files/:id (网关转发到 /api/v1/files/:id)
62
+ */
63
+ async deleteFile(fileId, options) {
64
+ return this.request(`/${fileId}`, {
65
+ ...options,
66
+ method: 'DELETE'
67
+ });
68
+ }
69
+ /**
70
+ * 获取文件列表
71
+ * GET /api/files (网关转发到 /api/v1/files)
72
+ */
73
+ async listFiles(query, options) {
74
+ const params = {};
75
+ if (query?.page !== undefined) {
76
+ params.page = query.page;
77
+ }
78
+ if (query?.pageSize !== undefined) {
79
+ params.pageSize = query.pageSize;
80
+ }
81
+ if (query?.folderId !== undefined) {
82
+ params.folderId = query.folderId;
83
+ }
84
+ if (query?.taskId !== undefined) {
85
+ params.taskId = query.taskId;
86
+ }
87
+ if (query?.acl !== undefined) {
88
+ params.acl = query.acl;
89
+ }
90
+ const response = await this.paginatedRequest('', {
91
+ ...options,
92
+ method: 'GET',
93
+ params
94
+ });
95
+ return response;
96
+ }
97
+ }
98
+ exports.FileService = FileService;
@@ -0,0 +1,37 @@
1
+ import { BaseClient } from "../client/BaseClient";
2
+ import { ClientConfig, RequestOptions } from "../types";
3
+ import { FrontHostCreateProjectInput, FrontHostDomainAvailabilityResponse, FrontHostHealthResponse, FrontHostMessageResponse, FrontHostProject, FrontHostProjectListResponse, FrontHostProjectVersionsResponse } from "../types/fronthost";
4
+ /**
5
+ * HTML 托管网关(gateway_h5 / fronthost)管理 API
6
+ *
7
+ * 部署在 API 网关后面时,建议使用 qing-client 的前端模式(config.gatewayUrl),
8
+ * 这样 BaseClient 会自动加 x-project-id / x-app-id(与 gateway_h5 verifyGatewayToken 一致)。
9
+ */
10
+ export declare class FrontHostService extends BaseClient {
11
+ constructor(config: ClientConfig);
12
+ /** 健康检查:GET /health */
13
+ health(options?: RequestOptions): Promise<FrontHostHealthResponse>;
14
+ /** 子域名可用性:GET /domains/available?subdomain=xx */
15
+ checkSubdomainAvailability(subdomain: string, options?: RequestOptions): Promise<FrontHostDomainAvailabilityResponse>;
16
+ /** 项目列表:GET /projects */
17
+ listProjects(options?: RequestOptions): Promise<FrontHostProjectListResponse>;
18
+ /** 项目详情:GET /projects/{id} */
19
+ getProject(id: string, options?: RequestOptions): Promise<FrontHostProject>;
20
+ /**
21
+ * 创建项目:POST /projects (multipart/form-data)
22
+ * - zip 字段名必须是 file(与服务端 r.FormFile("file") 一致)
23
+ * - 其他字段按 deployType 决定传哪些
24
+ */
25
+ createProject(input: FrontHostCreateProjectInput, options?: RequestOptions): Promise<FrontHostProject>;
26
+ /** 删除项目:DELETE /projects/{id} */
27
+ deleteProject(id: string, options?: RequestOptions): Promise<FrontHostMessageResponse>;
28
+ /**
29
+ * 部署新版本:PUT /projects/{id}/deploy (multipart/form-data)
30
+ * - 文件字段名固定 file
31
+ */
32
+ deployNewVersion(projectId: string, file: Blob | File, options?: RequestOptions): Promise<FrontHostMessageResponse>;
33
+ /** 版本列表:GET /projects/{id}/versions */
34
+ getProjectVersions(projectId: string, options?: RequestOptions): Promise<FrontHostProjectVersionsResponse>;
35
+ /** 回滚版本:POST /projects/{id}/rollback/{version_id} */
36
+ rollbackVersion(projectId: string, versionId: string, options?: RequestOptions): Promise<FrontHostMessageResponse>;
37
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FrontHostService = void 0;
4
+ // src/service/FrontHostService.ts
5
+ const BaseClient_1 = require("../client/BaseClient");
6
+ /**
7
+ * HTML 托管网关(gateway_h5 / fronthost)管理 API
8
+ *
9
+ * 部署在 API 网关后面时,建议使用 qing-client 的前端模式(config.gatewayUrl),
10
+ * 这样 BaseClient 会自动加 x-project-id / x-app-id(与 gateway_h5 verifyGatewayToken 一致)。
11
+ */
12
+ class FrontHostService extends BaseClient_1.BaseClient {
13
+ constructor(config) {
14
+ // 注意:serviceName 会拼出 /api/{serviceName},因此这里对应 /api/gateway-h5
15
+ super(config, "gateway-h5");
16
+ }
17
+ /** 健康检查:GET /health */
18
+ async health(options) {
19
+ return this.request("/health", {
20
+ ...options,
21
+ method: "GET",
22
+ });
23
+ }
24
+ /** 子域名可用性:GET /domains/available?subdomain=xx */
25
+ async checkSubdomainAvailability(subdomain, options) {
26
+ return this.request("/domains/available", {
27
+ ...options,
28
+ method: "GET",
29
+ params: { subdomain },
30
+ });
31
+ }
32
+ /** 项目列表:GET /projects */
33
+ async listProjects(options) {
34
+ return this.request("/projects", {
35
+ ...options,
36
+ method: "GET",
37
+ });
38
+ }
39
+ /** 项目详情:GET /projects/{id} */
40
+ async getProject(id, options) {
41
+ return this.request(`/projects/${encodeURIComponent(id)}`, {
42
+ ...options,
43
+ method: "GET",
44
+ });
45
+ }
46
+ /**
47
+ * 创建项目:POST /projects (multipart/form-data)
48
+ * - zip 字段名必须是 file(与服务端 r.FormFile("file") 一致)
49
+ * - 其他字段按 deployType 决定传哪些
50
+ */
51
+ async createProject(input, options) {
52
+ const form = new FormData();
53
+ form.append("file", input.file);
54
+ if (input.name)
55
+ form.append("name", input.name);
56
+ form.append("deploy_type", input.deployType);
57
+ if (input.subdomain)
58
+ form.append("subdomain", input.subdomain);
59
+ if (input.domain)
60
+ form.append("domain", input.domain);
61
+ if (input.routePath)
62
+ form.append("route_path", input.routePath);
63
+ if (input.proxyDomain)
64
+ form.append("proxy_domain", input.proxyDomain);
65
+ return this.request("/projects", {
66
+ ...options,
67
+ method: "POST",
68
+ headers: {
69
+ ...(options?.headers || {}),
70
+ // 让 axios/浏览器自动带 boundary;这里写上 multipart 意图即可
71
+ "Content-Type": "multipart/form-data",
72
+ },
73
+ body: form,
74
+ });
75
+ }
76
+ /** 删除项目:DELETE /projects/{id} */
77
+ async deleteProject(id, options) {
78
+ return this.request(`/projects/${encodeURIComponent(id)}`, {
79
+ ...options,
80
+ method: "DELETE",
81
+ });
82
+ }
83
+ /**
84
+ * 部署新版本:PUT /projects/{id}/deploy (multipart/form-data)
85
+ * - 文件字段名固定 file
86
+ */
87
+ async deployNewVersion(projectId, file, options) {
88
+ const form = new FormData();
89
+ form.append("file", file);
90
+ return this.request(`/projects/${encodeURIComponent(projectId)}/deploy`, {
91
+ ...options,
92
+ method: "PUT",
93
+ headers: {
94
+ ...(options?.headers || {}),
95
+ "Content-Type": "multipart/form-data",
96
+ },
97
+ body: form,
98
+ });
99
+ }
100
+ /** 版本列表:GET /projects/{id}/versions */
101
+ async getProjectVersions(projectId, options) {
102
+ return this.request(`/projects/${encodeURIComponent(projectId)}/versions`, {
103
+ ...options,
104
+ method: "GET",
105
+ });
106
+ }
107
+ /** 回滚版本:POST /projects/{id}/rollback/{version_id} */
108
+ async rollbackVersion(projectId, versionId, options) {
109
+ return this.request(`/projects/${encodeURIComponent(projectId)}/rollback/${encodeURIComponent(versionId)}`, {
110
+ ...options,
111
+ method: "POST",
112
+ });
113
+ }
114
+ }
115
+ exports.FrontHostService = FrontHostService;
@@ -17,10 +17,19 @@ class MsgService extends BaseClient_1.BaseClient {
17
17
  }
18
18
  // 发送飞书消息
19
19
  async sendFeishuMessage(message, options) {
20
+ // 兼容旧调用:noticeUser 可能还是 [{ userId: "xxx" }]
21
+ const noticeUser = message.noticeUser?.map((u) => {
22
+ const anyU = u;
23
+ return { user_id: anyU.user_id ?? anyU.userId };
24
+ }).filter(u => !!u.user_id); // 防止传空值导致服务端校验失败
25
+ const fixedMessage = {
26
+ ...message,
27
+ ...(noticeUser && noticeUser.length ? { noticeUser } : {}),
28
+ };
20
29
  return this.request('/webhook/feishu/send', {
21
30
  ...options,
22
31
  method: 'POST',
23
- body: message
32
+ body: fixedMessage,
24
33
  });
25
34
  }
26
35
  // === 消息中心相关接口 ===
@@ -1,6 +1,6 @@
1
1
  import { BaseClient } from "../client/BaseClient";
2
2
  import { ClientConfig, RequestOptions, PaginatedResponse } from "../types";
3
- import { User, UserCreateRequest, UserUpdateRequest } from "../types/user";
3
+ import { User, UserCreateRequest, UserUpdateRequest, SelfPasswordChangeRequest, SelfUserUpdateRequest } from "../types/user";
4
4
  export declare class UserService extends BaseClient {
5
5
  constructor(config: ClientConfig);
6
6
  getCurrentUser(options?: RequestOptions): Promise<User>;
@@ -15,4 +15,8 @@ export declare class UserService extends BaseClient {
15
15
  resetPassword(userId: number, newPassword: string, options?: RequestOptions): Promise<{
16
16
  id: number;
17
17
  }>;
18
+ changeOwnPassword(passwordData: SelfPasswordChangeRequest, options?: RequestOptions): Promise<{
19
+ id: number;
20
+ }>;
21
+ updateCurrentUser(updateData: SelfUserUpdateRequest, options?: RequestOptions): Promise<User>;
18
22
  }
@@ -91,5 +91,28 @@ class UserService extends BaseClient_1.BaseClient {
91
91
  }
92
92
  });
93
93
  }
94
+ // 修改自己的密码
95
+ async changeOwnPassword(passwordData, options) {
96
+ return this.request('/me/password', {
97
+ ...options,
98
+ method: 'PUT',
99
+ body: {
100
+ old_password: passwordData.old_password,
101
+ new_password: passwordData.new_password
102
+ }
103
+ });
104
+ }
105
+ // 更新自己的资料
106
+ async updateCurrentUser(updateData, options) {
107
+ return this.request('/me', {
108
+ ...options,
109
+ method: 'PUT',
110
+ body: {
111
+ name: updateData.name,
112
+ avatar: updateData.avatar,
113
+ phone: updateData.phone
114
+ }
115
+ });
116
+ }
94
117
  }
95
118
  exports.UserService = UserService;
@@ -0,0 +1,52 @@
1
+ export interface File {
2
+ id: string;
3
+ bucket?: string;
4
+ object: string;
5
+ url: string;
6
+ taskId: string;
7
+ size?: number;
8
+ mimeType?: string;
9
+ fileExtension?: string;
10
+ description?: string;
11
+ source: string;
12
+ acl: 'private' | 'public-read';
13
+ etag?: string;
14
+ contentMd5?: string;
15
+ folderId?: string;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ }
19
+ export interface CreateFileRequest {
20
+ bucket?: string;
21
+ object: string;
22
+ url: string;
23
+ taskId: string;
24
+ size?: number;
25
+ mimeType?: string;
26
+ fileExtension?: string;
27
+ description?: string;
28
+ source?: string;
29
+ acl?: 'private' | 'public-read';
30
+ etag?: string;
31
+ contentMd5?: string;
32
+ folderId?: string;
33
+ }
34
+ export interface UpdateFileRequest {
35
+ acl?: 'private' | 'public-read';
36
+ description?: string;
37
+ folderId?: string | null;
38
+ }
39
+ export interface FileListQuery {
40
+ page?: number;
41
+ pageSize?: number;
42
+ folderId?: string;
43
+ taskId?: string;
44
+ acl?: 'private' | 'public-read';
45
+ }
46
+ export interface FileListResponse {
47
+ data: File[];
48
+ total: number;
49
+ page: number;
50
+ pageSize: number;
51
+ totalPages: number;
52
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // client/npm/src/types/file.ts
3
+ // 文件模型和请求类型
4
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,62 @@
1
+ /** 部署类型:子域名 / 路由 / 代理域名 */
2
+ export type FrontHostDeployType = "subdomain" | "route" | "proxy";
3
+ /** 项目(后端返回的视图模型) */
4
+ export interface FrontHostProject {
5
+ id: string;
6
+ name: string;
7
+ /** 对外域名(根据 deploy_type 不同含义略有不同) */
8
+ domain: string;
9
+ /** 访问 URL(服务端动态拼出来) */
10
+ url: string;
11
+ deployType: FrontHostDeployType;
12
+ routePath: string;
13
+ proxyDomain: string;
14
+ status: string;
15
+ createdAt: string;
16
+ }
17
+ /** 列表接口返回 */
18
+ export interface FrontHostProjectListResponse {
19
+ projects: FrontHostProject[];
20
+ }
21
+ /** 创建项目:表单字段(文件用 FormData 传) */
22
+ export interface FrontHostCreateProjectInput {
23
+ name?: string;
24
+ deployType: FrontHostDeployType;
25
+ /** subdomain 模式 */
26
+ subdomain?: string;
27
+ domain?: string;
28
+ /** route 模式 */
29
+ routePath?: string;
30
+ /** proxy 模式 */
31
+ proxyDomain?: string;
32
+ /** zip 包(字段名必须是 file,与服务端一致) */
33
+ file: Blob | File;
34
+ }
35
+ /** 版本信息(根据你们服务端 models.ProjectVersion 常见字段做的贴合注解)
36
+ * 如果服务端字段与你们实际不一致,把这里字段名对齐即可
37
+ */
38
+ export interface FrontHostProjectVersion {
39
+ id: string;
40
+ projectId: string;
41
+ versionNumber: number;
42
+ isActive: boolean;
43
+ deployedAt: string;
44
+ }
45
+ /** 获取项目版本列表 */
46
+ export interface FrontHostProjectVersionsResponse {
47
+ versions: FrontHostProjectVersion[];
48
+ }
49
+ /** 回滚/删除等简单操作 */
50
+ export interface FrontHostMessageResponse {
51
+ message: string;
52
+ }
53
+ /** 域名/子域名可用性 */
54
+ export interface FrontHostDomainAvailabilityResponse {
55
+ subdomain: string;
56
+ available: boolean;
57
+ }
58
+ /** health */
59
+ export interface FrontHostHealthResponse {
60
+ status: "ok" | string;
61
+ timestamp: string;
62
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // src/types/fronthost.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -30,6 +30,7 @@ export interface ClientConfig {
30
30
  tokenServiceUrl?: string;
31
31
  aigcServiceUrl?: string;
32
32
  auditLogServiceUrl?: string;
33
+ gatewayH5ServiceUrl?: string;
33
34
  tokenStorage?: TokenStorage;
34
35
  projectId?: string;
35
36
  appId?: string;
@@ -24,7 +24,7 @@ export interface FeishuMessage {
24
24
  color?: string;
25
25
  }>;
26
26
  noticeUser?: Array<{
27
- userId: string;
27
+ user_id: string;
28
28
  }>;
29
29
  actions?: Array<{
30
30
  text: string;
@@ -20,12 +20,14 @@ export interface WxSignatureResponse {
20
20
  export interface WxMiniProgramTokenResponse {
21
21
  access_token: string;
22
22
  }
23
+ /**
24
+ * 微信小程序登录响应(SDK 实际返回值)
25
+ *
26
+ * 注意:BaseClient.request 会对后端返回做解包,最终返回 response.data.data
27
+ * 后端原始结构是 { success, message, data: {...} },但 SDK 返回的是 data 这一层。
28
+ */
23
29
  export interface WxMiniProgramLoginResponse {
24
- success: boolean;
25
- message: string;
26
- data: {
27
- openid: string;
28
- session_key: string;
29
- unionid?: string | null;
30
- };
30
+ openid: string;
31
+ session_key: string;
32
+ unionid?: string | null;
31
33
  }
@@ -38,6 +38,15 @@ export interface LoginResponse {
38
38
  export interface PasswordResetRequest {
39
39
  new_password: string;
40
40
  }
41
+ export interface SelfPasswordChangeRequest {
42
+ old_password: string;
43
+ new_password: string;
44
+ }
45
+ export interface SelfUserUpdateRequest {
46
+ name?: string;
47
+ avatar?: string;
48
+ phone?: string;
49
+ }
41
50
  export interface UserOperationResponse {
42
51
  id: number;
43
52
  message?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qing-client",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {