qing-client 0.0.6 → 0.0.8

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.
@@ -77,7 +77,7 @@ class AigcService extends BaseClient_1.BaseClient {
77
77
  }
78
78
  // 老照片修复任务
79
79
  async submitOldPhotoRestoreTask(request, options) {
80
- return this.request('/old-photo/tasks', {
80
+ return this.request('/lib/old-photo/tasks', {
81
81
  ...options,
82
82
  method: 'POST',
83
83
  body: request
@@ -85,7 +85,7 @@ class AigcService extends BaseClient_1.BaseClient {
85
85
  }
86
86
  // 产品换背景任务
87
87
  async submitProductBackgroundTask(request, options) {
88
- return this.request('/product-background/tasks', {
88
+ return this.request('/lib/product-background/tasks', {
89
89
  ...options,
90
90
  method: 'POST',
91
91
  body: request
@@ -93,7 +93,7 @@ class AigcService extends BaseClient_1.BaseClient {
93
93
  }
94
94
  // 青苹果风格洗稿任务
95
95
  async submitQingpingguoTask(request, options) {
96
- return this.request('/qingpingguo/tasks', {
96
+ return this.request('/lib/qingpingguo/tasks', {
97
97
  ...options,
98
98
  method: 'POST',
99
99
  body: request
@@ -101,7 +101,7 @@ class AigcService extends BaseClient_1.BaseClient {
101
101
  }
102
102
  // 风格转绘任务
103
103
  async submitStyleTransferTask(request, options) {
104
- return this.request('/style-transfer/tasks', {
104
+ return this.request('/lib/style-transfer/tasks', {
105
105
  ...options,
106
106
  method: 'POST',
107
107
  body: request
@@ -109,7 +109,7 @@ class AigcService extends BaseClient_1.BaseClient {
109
109
  }
110
110
  // 获取任务状态
111
111
  async getTaskStatus(request, options) {
112
- return this.request(`/comfy/tasks/${request.taskId}`, {
112
+ return this.request(`/lib/comfy/tasks/${request.taskId}`, {
113
113
  ...options,
114
114
  method: 'GET'
115
115
  });
@@ -1,8 +1,22 @@
1
1
  import { BaseClient } from "../client/BaseClient";
2
2
  import { ClientConfig, RequestOptions } from "../types";
3
- import { FeishuMessage, MailRequest } from "../types/msg";
3
+ import { BatchCreateMessageRequest, BatchMarkAsReadRequest, CategoryInfo, CreateMessageRequest, FeishuMessage, MailRequest, MarkAsReadRequest, Message, MessageQueryParams, MessageStats } from "../types/msg";
4
4
  export declare class MsgService extends BaseClient {
5
5
  constructor(config: ClientConfig);
6
6
  sendMail(request: MailRequest, options?: RequestOptions): Promise<void>;
7
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
+ }>;
8
22
  }
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MsgService = void 0;
4
+ // client/npm/src/srvice/MsgService.ts
4
5
  const BaseClient_1 = require("../client/BaseClient");
5
6
  class MsgService extends BaseClient_1.BaseClient {
6
7
  constructor(config) {
7
8
  super(config, 'msg');
8
9
  }
9
- // 发送邮件 - 返回实际结果
10
+ // 发送邮件
10
11
  async sendMail(request, options) {
11
12
  return this.request('/mail/send', {
12
13
  ...options,
@@ -14,7 +15,7 @@ class MsgService extends BaseClient_1.BaseClient {
14
15
  body: request
15
16
  });
16
17
  }
17
- // 发送飞书消息 - 返回实际结果
18
+ // 发送飞书消息
18
19
  async sendFeishuMessage(message, options) {
19
20
  return this.request('/webhook/feishu/send', {
20
21
  ...options,
@@ -22,5 +23,77 @@ class MsgService extends BaseClient_1.BaseClient {
22
23
  body: message
23
24
  });
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
+ }
25
98
  }
26
99
  exports.MsgService = MsgService;
@@ -1,14 +1,16 @@
1
1
  export interface MailRequest {
2
- to: string[];
3
- subject: string;
4
- text?: string;
5
- html?: string;
6
2
  from?: string;
3
+ sender?: string;
4
+ to: string[];
7
5
  cc?: string[];
8
6
  bcc?: string[];
7
+ replyTo?: string;
8
+ subject?: string;
9
+ text?: string;
10
+ html?: string;
9
11
  attachments?: Array<{
10
12
  filename: string;
11
- content: string;
13
+ content: string | Buffer;
12
14
  contentType?: string;
13
15
  }>;
14
16
  }
@@ -27,5 +29,68 @@ export interface FeishuMessage {
27
29
  actions?: Array<{
28
30
  text: string;
29
31
  url: string;
32
+ type?: string;
33
+ }>;
34
+ }
35
+ export interface Message {
36
+ _id: string;
37
+ pid: string;
38
+ aid: string;
39
+ userId: string;
40
+ title: string;
41
+ content: string;
42
+ type: 'system' | 'business' | 'notice';
43
+ category: string;
44
+ isRead: boolean;
45
+ readAt?: string;
46
+ metadata?: Record<string, any>;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ }
50
+ export interface MessageQueryParams {
51
+ type?: 'system' | 'business' | 'notice';
52
+ category?: string;
53
+ isRead?: boolean;
54
+ page?: number;
55
+ limit?: number;
56
+ userId?: string;
57
+ pid?: string;
58
+ aid?: string;
59
+ }
60
+ export interface MessageStats {
61
+ total: number;
62
+ byCategory: Record<string, number>;
63
+ }
64
+ export interface CreateMessageRequest {
65
+ userId?: string;
66
+ title: string;
67
+ content: string;
68
+ type: 'system' | 'business' | 'notice';
69
+ category: string;
70
+ metadata?: Record<string, any>;
71
+ }
72
+ export interface BatchCreateMessageRequest {
73
+ messages: Array<{
74
+ userId: string;
75
+ title: string;
76
+ content: string;
77
+ type: 'system' | 'business' | 'notice';
78
+ category: string;
79
+ metadata?: Record<string, any>;
30
80
  }>;
31
81
  }
82
+ export interface MarkAsReadRequest {
83
+ userId?: string;
84
+ }
85
+ export interface BatchMarkAsReadRequest {
86
+ messageIds: string[];
87
+ userId?: string;
88
+ }
89
+ export interface CategoryInfo {
90
+ category: string;
91
+ unreadCount: number;
92
+ latestMessage?: {
93
+ title: string;
94
+ createdAt: string;
95
+ };
96
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qing-client",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
@@ -116,7 +116,7 @@ export class AigcService extends BaseClient {
116
116
 
117
117
  // 老照片修复任务
118
118
  async submitOldPhotoRestoreTask(request: OldPhotoRestoreTaskRequest, options?: RequestOptions): Promise<OldPhotoRestoreTaskResponse> {
119
- return this.request<OldPhotoRestoreTaskResponse>('/old-photo/tasks', {
119
+ return this.request<OldPhotoRestoreTaskResponse>('/lib/old-photo/tasks', {
120
120
  ...options,
121
121
  method: 'POST',
122
122
  body: request
@@ -125,7 +125,7 @@ export class AigcService extends BaseClient {
125
125
 
126
126
  // 产品换背景任务
127
127
  async submitProductBackgroundTask(request: ProductBackgroundTaskRequest, options?: RequestOptions): Promise<ProductBackgroundTaskResponse> {
128
- return this.request<ProductBackgroundTaskResponse>('/product-background/tasks', {
128
+ return this.request<ProductBackgroundTaskResponse>('/lib/product-background/tasks', {
129
129
  ...options,
130
130
  method: 'POST',
131
131
  body: request
@@ -134,7 +134,7 @@ export class AigcService extends BaseClient {
134
134
 
135
135
  // 青苹果风格洗稿任务
136
136
  async submitQingpingguoTask(request: QingpingguoTaskRequest, options?: RequestOptions): Promise<QingpingguoTaskResponse> {
137
- return this.request<QingpingguoTaskResponse>('/qingpingguo/tasks', {
137
+ return this.request<QingpingguoTaskResponse>('/lib/qingpingguo/tasks', {
138
138
  ...options,
139
139
  method: 'POST',
140
140
  body: request
@@ -143,7 +143,7 @@ export class AigcService extends BaseClient {
143
143
 
144
144
  // 风格转绘任务
145
145
  async submitStyleTransferTask(request: StyleTransferTaskRequest, options?: RequestOptions): Promise<StyleTransferTaskResponse> {
146
- return this.request<StyleTransferTaskResponse>('/style-transfer/tasks', {
146
+ return this.request<StyleTransferTaskResponse>('/lib/style-transfer/tasks', {
147
147
  ...options,
148
148
  method: 'POST',
149
149
  body: request
@@ -152,7 +152,7 @@ export class AigcService extends BaseClient {
152
152
 
153
153
  // 获取任务状态
154
154
  async getTaskStatus(request: TaskStatusRequest, options?: RequestOptions): Promise<TaskStatusResponse> {
155
- return this.request<TaskStatusResponse>(`/comfy/tasks/${request.taskId}`, {
155
+ return this.request<TaskStatusResponse>(`/lib/comfy/tasks/${request.taskId}`, {
156
156
  ...options,
157
157
  method: 'GET'
158
158
  });
@@ -1,14 +1,14 @@
1
+ // client/npm/src/srvice/MsgService.ts
1
2
  import { BaseClient } from "../client/BaseClient";
2
3
  import { ClientConfig, RequestOptions } from "../types";
3
- import { FeishuMessage, MailRequest } from "../types/msg";
4
-
4
+ import { BatchCreateMessageRequest, BatchMarkAsReadRequest, CategoryInfo, CreateMessageRequest, FeishuMessage, MailRequest, MarkAsReadRequest, Message, MessageQueryParams, MessageStats } from "../types/msg";
5
5
 
6
6
  export class MsgService extends BaseClient {
7
7
  constructor(config: ClientConfig) {
8
8
  super(config, 'msg');
9
9
  }
10
10
 
11
- // 发送邮件 - 返回实际结果
11
+ // 发送邮件
12
12
  async sendMail(request: MailRequest, options?: RequestOptions): Promise<void> {
13
13
  return this.request<void>('/mail/send', {
14
14
  ...options,
@@ -17,7 +17,7 @@ export class MsgService extends BaseClient {
17
17
  });
18
18
  }
19
19
 
20
- // 发送飞书消息 - 返回实际结果
20
+ // 发送飞书消息
21
21
  async sendFeishuMessage(message: FeishuMessage, options?: RequestOptions): Promise<void> {
22
22
  return this.request<void>('/webhook/feishu/send', {
23
23
  ...options,
@@ -25,4 +25,86 @@ export class MsgService extends BaseClient {
25
25
  body: message
26
26
  });
27
27
  }
28
+
29
+ // === 消息中心相关接口 ===
30
+
31
+ // 获取用户消息列表
32
+ async getMessages(params?: MessageQueryParams, options?: RequestOptions): Promise<Message[]> {
33
+ return this.request<Message[]>('/message/list', {
34
+ ...options,
35
+ method: 'GET',
36
+ params: params // 使用 params 而不是 query
37
+ });
38
+ }
39
+
40
+ // 管理员获取消息列表(需要管理员权限)
41
+ async getAdminMessages(params?: MessageQueryParams, options?: RequestOptions): Promise<Message[]> {
42
+ return this.request<Message[]>('/message/admin/list', {
43
+ ...options,
44
+ method: 'GET',
45
+ params: params // 使用 params 而不是 query
46
+ });
47
+ }
48
+
49
+ // 标记单条消息为已读
50
+ async markAsRead(messageId: string, request?: MarkAsReadRequest, options?: RequestOptions): Promise<Message> {
51
+ return this.request<Message>(`/message/${messageId}/read`, {
52
+ ...options,
53
+ method: 'PATCH',
54
+ body: request
55
+ });
56
+ }
57
+
58
+ // 批量标记消息为已读
59
+ async markManyAsRead(request: BatchMarkAsReadRequest, options?: RequestOptions): Promise<{ modifiedCount: number }> {
60
+ return this.request<{ modifiedCount: number }>('/message/batch/read', {
61
+ ...options,
62
+ method: 'PATCH',
63
+ body: request
64
+ });
65
+ }
66
+
67
+ // 删除消息(软删除)
68
+ async deleteMessage(messageId: string, request?: MarkAsReadRequest, options?: RequestOptions): Promise<Message> {
69
+ return this.request<Message>(`/message/${messageId}`, {
70
+ ...options,
71
+ method: 'DELETE',
72
+ body: request
73
+ });
74
+ }
75
+
76
+ // 获取未读消息统计
77
+ async getUnreadStats(userId?: string, options?: RequestOptions): Promise<MessageStats> {
78
+ return this.request<MessageStats>('/message/stats', {
79
+ ...options,
80
+ method: 'GET',
81
+ params: userId ? { userId } : undefined // 使用 params 而不是 query
82
+ });
83
+ }
84
+
85
+ // 获取用户消息分类
86
+ async getCategories(options?: RequestOptions): Promise<CategoryInfo[]> {
87
+ return this.request<CategoryInfo[]>('/message/categories', {
88
+ ...options,
89
+ method: 'GET'
90
+ });
91
+ }
92
+
93
+ // 创建消息(需要管理员权限)
94
+ async createMessage(request: CreateMessageRequest, options?: RequestOptions): Promise<Message> {
95
+ return this.request<Message>('/message', {
96
+ ...options,
97
+ method: 'POST',
98
+ body: request
99
+ });
100
+ }
101
+
102
+ // 批量创建消息(需要管理员权限)
103
+ async createManyMessages(request: BatchCreateMessageRequest, options?: RequestOptions): Promise<{ createdCount: number, messages: Message[] }> {
104
+ return this.request<{ createdCount: number, messages: Message[] }>('/message/batch', {
105
+ ...options,
106
+ method: 'POST',
107
+ body: request
108
+ });
109
+ }
28
110
  }
@@ -1,3 +1,4 @@
1
+ // npm/src/types/index.ts
1
2
  // 统一API响应格式
2
3
  export interface ApiResponse<T = any> {
3
4
  success: boolean;
package/src/types/msg.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  export interface MailRequest {
2
- to: string[];
3
- subject: string;
4
- text?: string;
5
- html?: string;
6
2
  from?: string;
3
+ sender?: string;
4
+ to: string[];
7
5
  cc?: string[];
8
6
  bcc?: string[];
7
+ replyTo?: string;
8
+ subject?: string;
9
+ text?: string;
10
+ html?: string;
9
11
  attachments?: Array<{
10
12
  filename: string;
11
- content: string; // base64编码
13
+ content: string | Buffer;
12
14
  contentType?: string;
13
15
  }>;
14
16
  }
@@ -28,5 +30,77 @@ export interface FeishuMessage {
28
30
  actions?: Array<{
29
31
  text: string;
30
32
  url: string;
33
+ type?: string;
34
+ }>;
35
+ }
36
+
37
+ // 消息相关类型定义
38
+ export interface Message {
39
+ _id: string;
40
+ pid: string;
41
+ aid: string;
42
+ userId: string;
43
+ title: string;
44
+ content: string;
45
+ type: 'system' | 'business' | 'notice';
46
+ category: string;
47
+ isRead: boolean;
48
+ readAt?: string;
49
+ metadata?: Record<string, any>;
50
+ createdAt: string;
51
+ updatedAt: string;
52
+ }
53
+
54
+ export interface MessageQueryParams {
55
+ type?: 'system' | 'business' | 'notice';
56
+ category?: string;
57
+ isRead?: boolean;
58
+ page?: number;
59
+ limit?: number;
60
+ userId?: string; // 管理员查询特定用户的消息
61
+ pid?: string; // 管理员查询特定项目
62
+ aid?: string; // 管理员查询特定应用
63
+ }
64
+
65
+ export interface MessageStats {
66
+ total: number;
67
+ byCategory: Record<string, number>;
68
+ }
69
+
70
+ export interface CreateMessageRequest {
71
+ userId?: string; // 管理员可指定用户ID,不指定则使用当前用户
72
+ title: string;
73
+ content: string;
74
+ type: 'system' | 'business' | 'notice';
75
+ category: string;
76
+ metadata?: Record<string, any>;
77
+ }
78
+
79
+ export interface BatchCreateMessageRequest {
80
+ messages: Array<{
81
+ userId: string;
82
+ title: string;
83
+ content: string;
84
+ type: 'system' | 'business' | 'notice';
85
+ category: string;
86
+ metadata?: Record<string, any>;
31
87
  }>;
32
88
  }
89
+
90
+ export interface MarkAsReadRequest {
91
+ userId?: string; // 管理员可指定用户ID
92
+ }
93
+
94
+ export interface BatchMarkAsReadRequest {
95
+ messageIds: string[];
96
+ userId?: string; // 管理员可指定用户ID
97
+ }
98
+
99
+ export interface CategoryInfo {
100
+ category: string;
101
+ unreadCount: number;
102
+ latestMessage?: {
103
+ title: string;
104
+ createdAt: string;
105
+ };
106
+ }