@meet-im/meet-bot-jssdk 1.2.0 → 1.3.0
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/dist/index.cjs +52 -1
- package/dist/index.d.cts +62 -47
- package/dist/index.d.ts +62 -47
- package/dist/index.js +51 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -184,6 +184,14 @@ function getConvID(firstID, secondID, sessionType, companyID = 1) {
|
|
|
184
184
|
function getQuoteMsgKey(convID, seqID) {
|
|
185
185
|
return `${convID}:${seqID}`;
|
|
186
186
|
}
|
|
187
|
+
var TYPING_ACTION = {
|
|
188
|
+
/** 未指定 */
|
|
189
|
+
UNSPECIFIED: 0,
|
|
190
|
+
/** 正在输入 */
|
|
191
|
+
TYPING: 1,
|
|
192
|
+
/** 停止输入 */
|
|
193
|
+
STOPPED: 2
|
|
194
|
+
};
|
|
187
195
|
|
|
188
196
|
// src/utils/logger.ts
|
|
189
197
|
var Logger = class {
|
|
@@ -263,7 +271,7 @@ async function request(options) {
|
|
|
263
271
|
headers["User-Agent"] = userAgent;
|
|
264
272
|
}
|
|
265
273
|
logger.info("[Request]", method, url);
|
|
266
|
-
logger.info("[Headers]", sanitizeHeaders(headers));
|
|
274
|
+
logger.info("[Headers]", JSON.stringify(sanitizeHeaders(headers)));
|
|
267
275
|
if (body) {
|
|
268
276
|
logger.info("[Body]", JSON.stringify(body));
|
|
269
277
|
}
|
|
@@ -359,6 +367,9 @@ function mapStatusCodeToErrorCode(status) {
|
|
|
359
367
|
}
|
|
360
368
|
}
|
|
361
369
|
|
|
370
|
+
// src/api/index.ts
|
|
371
|
+
init_error();
|
|
372
|
+
|
|
362
373
|
// src/api/file.ts
|
|
363
374
|
async function getUploadURL(params) {
|
|
364
375
|
const { token, baseUrl, userAgent, ...body } = params;
|
|
@@ -688,6 +699,30 @@ async function sendMessage(params) {
|
|
|
688
699
|
}
|
|
689
700
|
});
|
|
690
701
|
}
|
|
702
|
+
async function sendUserTyping(params) {
|
|
703
|
+
const { token, baseUrl, userAgent, sessionInfo, action } = params;
|
|
704
|
+
const response = await request({
|
|
705
|
+
token,
|
|
706
|
+
baseUrl,
|
|
707
|
+
userAgent,
|
|
708
|
+
method: "POST",
|
|
709
|
+
path: "SendUserTyping",
|
|
710
|
+
pathPrefix: "/im/",
|
|
711
|
+
raw: true,
|
|
712
|
+
body: {
|
|
713
|
+
sessionInfo,
|
|
714
|
+
action
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
if (response && typeof response === "object" && Object.keys(response).length === 0) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if ("ok" in response && response.ok) {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
const errorData = response;
|
|
724
|
+
throw new exports.ApiError(errorData.description || "SendUserTyping failed", 200, "INTERNAL_ERROR", errorData.retry_after);
|
|
725
|
+
}
|
|
691
726
|
|
|
692
727
|
// src/client.ts
|
|
693
728
|
init_error();
|
|
@@ -1019,6 +1054,20 @@ var MeetBot = class {
|
|
|
1019
1054
|
async sendMedia(sessionInfo, options) {
|
|
1020
1055
|
return sendMediaMessage(this.token, sessionInfo, options, this.baseUrl, this.userAgent);
|
|
1021
1056
|
}
|
|
1057
|
+
/**
|
|
1058
|
+
* 发送输入状态
|
|
1059
|
+
* @param sessionInfo 会话信息
|
|
1060
|
+
* @param action 输入状态:TYPING_ACTION.TYPING(正在输入)或 TYPING_ACTION.STOPPED(停止输入)
|
|
1061
|
+
*/
|
|
1062
|
+
async sendUserTyping(sessionInfo, action) {
|
|
1063
|
+
return sendUserTyping({
|
|
1064
|
+
token: this.token,
|
|
1065
|
+
baseUrl: this.baseUrl,
|
|
1066
|
+
userAgent: this.userAgent,
|
|
1067
|
+
sessionInfo,
|
|
1068
|
+
action
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1022
1071
|
/**
|
|
1023
1072
|
* 刷新用户缓存
|
|
1024
1073
|
*/
|
|
@@ -1084,6 +1133,7 @@ exports.HTTP = HTTP;
|
|
|
1084
1133
|
exports.MeetBot = MeetBot;
|
|
1085
1134
|
exports.POLLING = POLLING;
|
|
1086
1135
|
exports.SESSION_TYPE = SESSION_TYPE;
|
|
1136
|
+
exports.TYPING_ACTION = TYPING_ACTION;
|
|
1087
1137
|
exports.UPLOAD = UPLOAD;
|
|
1088
1138
|
exports.UserCache = UserCache;
|
|
1089
1139
|
exports.completeMultipartUpload = completeMultipartUpload;
|
|
@@ -1099,4 +1149,5 @@ exports.getUploadURL = getUploadURL;
|
|
|
1099
1149
|
exports.getUsers = getUsers;
|
|
1100
1150
|
exports.sendMediaMessage = sendMediaMessage;
|
|
1101
1151
|
exports.sendMessage = sendMessage;
|
|
1152
|
+
exports.sendUserTyping = sendUserTyping;
|
|
1102
1153
|
exports.uploadFile = uploadFile;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
declare const DEFAULT_BASE_URL = "https://staging-meet-api.miyachat.com";
|
|
2
|
+
declare const POLLING: {
|
|
3
|
+
readonly DEFAULT_LIMIT: 100;
|
|
4
|
+
readonly DEFAULT_TIMEOUT: 30;
|
|
5
|
+
readonly SUCCESS_DELAY: 1000;
|
|
6
|
+
readonly DEFAULT_RETRY_DELAY: 1000;
|
|
7
|
+
readonly MAX_RETRY_DELAY: 30000;
|
|
8
|
+
readonly DEFAULT_MAX_RETRIES: 0;
|
|
9
|
+
};
|
|
10
|
+
declare const HTTP: {
|
|
11
|
+
readonly DEFAULT_TIMEOUT: 60000;
|
|
12
|
+
readonly POLLING_TIMEOUT_BUFFER: 10000;
|
|
13
|
+
readonly UPLOAD_TIMEOUT: number;
|
|
14
|
+
};
|
|
15
|
+
declare const API: {
|
|
16
|
+
readonly DEFAULT_TIMEOUT: 30;
|
|
17
|
+
readonly DEFAULT_LIMIT: 100;
|
|
18
|
+
};
|
|
19
|
+
declare const UPLOAD: {
|
|
20
|
+
readonly MULTIPART_THRESHOLD: number;
|
|
21
|
+
readonly MAX_RETRY_COUNT: 3;
|
|
22
|
+
readonly RETRY_DELAY: 1000;
|
|
23
|
+
readonly MAX_CONCURRENCY: 4;
|
|
24
|
+
};
|
|
25
|
+
declare const CHUNK_RULES: readonly [{
|
|
26
|
+
readonly maxSize: number;
|
|
27
|
+
readonly chunks: 1;
|
|
28
|
+
}, {
|
|
29
|
+
readonly maxSize: number;
|
|
30
|
+
readonly chunks: 5;
|
|
31
|
+
}, {
|
|
32
|
+
readonly maxSize: number;
|
|
33
|
+
readonly chunks: 20;
|
|
34
|
+
}, {
|
|
35
|
+
readonly maxSize: number;
|
|
36
|
+
readonly chunks: 50;
|
|
37
|
+
}];
|
|
38
|
+
declare const SESSION_TYPE: {
|
|
39
|
+
readonly PRIVATE: 1;
|
|
40
|
+
readonly GROUP: 3;
|
|
41
|
+
readonly CHANNEL: 4;
|
|
42
|
+
};
|
|
43
|
+
declare function getChunkNum(size: number): number;
|
|
44
|
+
declare function getConvID(firstID: number, secondID: number, sessionType: number, companyID?: number): string;
|
|
45
|
+
declare function getQuoteMsgKey(convID: string, seqID: number): string;
|
|
46
|
+
declare const TYPING_ACTION: {
|
|
47
|
+
readonly UNSPECIFIED: 0;
|
|
48
|
+
readonly TYPING: 1;
|
|
49
|
+
readonly STOPPED: 2;
|
|
50
|
+
};
|
|
51
|
+
type TypingAction = (typeof TYPING_ACTION)[keyof typeof TYPING_ACTION];
|
|
52
|
+
|
|
1
53
|
type SessionType = 1 | 3;
|
|
2
54
|
interface SessionInfo {
|
|
3
55
|
firstID: number;
|
|
@@ -66,6 +118,13 @@ interface BotMsg {
|
|
|
66
118
|
quote?: BotMsg;
|
|
67
119
|
timestamp: number;
|
|
68
120
|
}
|
|
121
|
+
interface SendUserTypingParams {
|
|
122
|
+
token: string;
|
|
123
|
+
baseUrl?: string;
|
|
124
|
+
userAgent?: string;
|
|
125
|
+
sessionInfo: SessionInfo;
|
|
126
|
+
action: TypingAction;
|
|
127
|
+
}
|
|
69
128
|
|
|
70
129
|
type ErrorCode = 'INVALID_TOKEN' | 'UNAUTHORIZED' | 'CHAT_NOT_FOUND' | 'RATE_LIMIT' | 'INTERNAL_ERROR' | 'NETWORK_ERROR' | 'TIMEOUT_ERROR' | 'VALIDATION_ERROR' | 'EMPTY_MESSAGE';
|
|
71
130
|
interface ApiErrorResponse {
|
|
@@ -342,6 +401,7 @@ declare class MeetBot {
|
|
|
342
401
|
getAccessURL(params: GetAccessURLParams | GetAccessURLBySessionParams): Promise<AccessURLResult>;
|
|
343
402
|
uploadFile(buffer: Buffer, options: UploadFileOptions): Promise<UploadFileResult>;
|
|
344
403
|
sendMedia(sessionInfo: SessionInfo, options: SendMediaOptions): Promise<SendMessageResult>;
|
|
404
|
+
sendUserTyping(sessionInfo: SessionInfo, action: TypingAction): Promise<void>;
|
|
345
405
|
refreshUserCache(): Promise<void>;
|
|
346
406
|
getUserById(userId: number): Promise<MeetUser | undefined>;
|
|
347
407
|
getUserByIds(userIds: number[]): Promise<Map<number, MeetUser>>;
|
|
@@ -411,51 +471,6 @@ interface SendMessageParams {
|
|
|
411
471
|
msgContent: MsgContent;
|
|
412
472
|
}
|
|
413
473
|
declare function sendMessage(params: SendMessageParams): Promise<SendMessageResult>;
|
|
474
|
+
declare function sendUserTyping(params: SendUserTypingParams): Promise<void>;
|
|
414
475
|
|
|
415
|
-
|
|
416
|
-
declare const POLLING: {
|
|
417
|
-
readonly DEFAULT_LIMIT: 100;
|
|
418
|
-
readonly DEFAULT_TIMEOUT: 30;
|
|
419
|
-
readonly SUCCESS_DELAY: 1000;
|
|
420
|
-
readonly DEFAULT_RETRY_DELAY: 1000;
|
|
421
|
-
readonly MAX_RETRY_DELAY: 30000;
|
|
422
|
-
readonly DEFAULT_MAX_RETRIES: 0;
|
|
423
|
-
};
|
|
424
|
-
declare const HTTP: {
|
|
425
|
-
readonly DEFAULT_TIMEOUT: 60000;
|
|
426
|
-
readonly POLLING_TIMEOUT_BUFFER: 10000;
|
|
427
|
-
readonly UPLOAD_TIMEOUT: number;
|
|
428
|
-
};
|
|
429
|
-
declare const API: {
|
|
430
|
-
readonly DEFAULT_TIMEOUT: 30;
|
|
431
|
-
readonly DEFAULT_LIMIT: 100;
|
|
432
|
-
};
|
|
433
|
-
declare const UPLOAD: {
|
|
434
|
-
readonly MULTIPART_THRESHOLD: number;
|
|
435
|
-
readonly MAX_RETRY_COUNT: 3;
|
|
436
|
-
readonly RETRY_DELAY: 1000;
|
|
437
|
-
readonly MAX_CONCURRENCY: 4;
|
|
438
|
-
};
|
|
439
|
-
declare const CHUNK_RULES: readonly [{
|
|
440
|
-
readonly maxSize: number;
|
|
441
|
-
readonly chunks: 1;
|
|
442
|
-
}, {
|
|
443
|
-
readonly maxSize: number;
|
|
444
|
-
readonly chunks: 5;
|
|
445
|
-
}, {
|
|
446
|
-
readonly maxSize: number;
|
|
447
|
-
readonly chunks: 20;
|
|
448
|
-
}, {
|
|
449
|
-
readonly maxSize: number;
|
|
450
|
-
readonly chunks: 50;
|
|
451
|
-
}];
|
|
452
|
-
declare const SESSION_TYPE: {
|
|
453
|
-
readonly PRIVATE: 1;
|
|
454
|
-
readonly GROUP: 3;
|
|
455
|
-
readonly CHANNEL: 4;
|
|
456
|
-
};
|
|
457
|
-
declare function getChunkNum(size: number): number;
|
|
458
|
-
declare function getConvID(firstID: number, secondID: number, sessionType: number, companyID?: number): string;
|
|
459
|
-
declare function getQuoteMsgKey(convID: string, seqID: number): string;
|
|
460
|
-
|
|
461
|
-
export { API, type AccessURLResult, ApiError, type ApiErrorResponse, type ApiResponse, type AttachmentInfo, type BotChat, type BotFile, type BotMsg, type BotMsgUpdate, type BotUpdate, type BotUser, CHUNK_RULES, type ChatType, type CompleteMultipartUploadParams, type CompleteMultipartUploadResult, DEFAULT_BASE_URL, type ErrorCode, type ExtraInfo, type GetAccessURLBySessionParams, type GetAccessURLParams, type GetMultiPartUploadURLParams, type GetUpdatesOptions, type GetUpdatesV2Result, type GetUploadURLParams, HTTP, type LogLevel, MeetBot, type MeetBotConfig, MeetBotError, type MeetUser, type MsgContent, type MsgType, type MultiPartUploadURLResult, NetworkError, POLLING, type PollingOptions, type QuoteMsgMap, type ReceivedAttachmentInfo, SESSION_TYPE, type SendMediaOptions, type SendMessageOptions, type SendMessageResult, type SessionInfo, type SessionType, TimeoutError, UPLOAD, type UploadFileOptions, type UploadFileResult, type UploadPart, type UploadProgress, type UploadURLResult, UserCache, type UserCacheOptions, ValidationError, completeMultipartUpload, computeMD5, getAccessURL, getChunkNum, getConvID, getMultiPartUploadURL, getQuoteMsgKey, getUpdates, getUpdatesV2, getUploadURL, getUsers, sendMediaMessage, sendMessage, uploadFile };
|
|
476
|
+
export { API, type AccessURLResult, ApiError, type ApiErrorResponse, type ApiResponse, type AttachmentInfo, type BotChat, type BotFile, type BotMsg, type BotMsgUpdate, type BotUpdate, type BotUser, CHUNK_RULES, type ChatType, type CompleteMultipartUploadParams, type CompleteMultipartUploadResult, DEFAULT_BASE_URL, type ErrorCode, type ExtraInfo, type GetAccessURLBySessionParams, type GetAccessURLParams, type GetMultiPartUploadURLParams, type GetUpdatesOptions, type GetUpdatesV2Result, type GetUploadURLParams, HTTP, type LogLevel, MeetBot, type MeetBotConfig, MeetBotError, type MeetUser, type MsgContent, type MsgType, type MultiPartUploadURLResult, NetworkError, POLLING, type PollingOptions, type QuoteMsgMap, type ReceivedAttachmentInfo, SESSION_TYPE, type SendMediaOptions, type SendMessageOptions, type SendMessageResult, type SendUserTypingParams, type SessionInfo, type SessionType, TYPING_ACTION, TimeoutError, type TypingAction, UPLOAD, type UploadFileOptions, type UploadFileResult, type UploadPart, type UploadProgress, type UploadURLResult, UserCache, type UserCacheOptions, ValidationError, completeMultipartUpload, computeMD5, getAccessURL, getChunkNum, getConvID, getMultiPartUploadURL, getQuoteMsgKey, getUpdates, getUpdatesV2, getUploadURL, getUsers, sendMediaMessage, sendMessage, sendUserTyping, uploadFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
declare const DEFAULT_BASE_URL = "https://staging-meet-api.miyachat.com";
|
|
2
|
+
declare const POLLING: {
|
|
3
|
+
readonly DEFAULT_LIMIT: 100;
|
|
4
|
+
readonly DEFAULT_TIMEOUT: 30;
|
|
5
|
+
readonly SUCCESS_DELAY: 1000;
|
|
6
|
+
readonly DEFAULT_RETRY_DELAY: 1000;
|
|
7
|
+
readonly MAX_RETRY_DELAY: 30000;
|
|
8
|
+
readonly DEFAULT_MAX_RETRIES: 0;
|
|
9
|
+
};
|
|
10
|
+
declare const HTTP: {
|
|
11
|
+
readonly DEFAULT_TIMEOUT: 60000;
|
|
12
|
+
readonly POLLING_TIMEOUT_BUFFER: 10000;
|
|
13
|
+
readonly UPLOAD_TIMEOUT: number;
|
|
14
|
+
};
|
|
15
|
+
declare const API: {
|
|
16
|
+
readonly DEFAULT_TIMEOUT: 30;
|
|
17
|
+
readonly DEFAULT_LIMIT: 100;
|
|
18
|
+
};
|
|
19
|
+
declare const UPLOAD: {
|
|
20
|
+
readonly MULTIPART_THRESHOLD: number;
|
|
21
|
+
readonly MAX_RETRY_COUNT: 3;
|
|
22
|
+
readonly RETRY_DELAY: 1000;
|
|
23
|
+
readonly MAX_CONCURRENCY: 4;
|
|
24
|
+
};
|
|
25
|
+
declare const CHUNK_RULES: readonly [{
|
|
26
|
+
readonly maxSize: number;
|
|
27
|
+
readonly chunks: 1;
|
|
28
|
+
}, {
|
|
29
|
+
readonly maxSize: number;
|
|
30
|
+
readonly chunks: 5;
|
|
31
|
+
}, {
|
|
32
|
+
readonly maxSize: number;
|
|
33
|
+
readonly chunks: 20;
|
|
34
|
+
}, {
|
|
35
|
+
readonly maxSize: number;
|
|
36
|
+
readonly chunks: 50;
|
|
37
|
+
}];
|
|
38
|
+
declare const SESSION_TYPE: {
|
|
39
|
+
readonly PRIVATE: 1;
|
|
40
|
+
readonly GROUP: 3;
|
|
41
|
+
readonly CHANNEL: 4;
|
|
42
|
+
};
|
|
43
|
+
declare function getChunkNum(size: number): number;
|
|
44
|
+
declare function getConvID(firstID: number, secondID: number, sessionType: number, companyID?: number): string;
|
|
45
|
+
declare function getQuoteMsgKey(convID: string, seqID: number): string;
|
|
46
|
+
declare const TYPING_ACTION: {
|
|
47
|
+
readonly UNSPECIFIED: 0;
|
|
48
|
+
readonly TYPING: 1;
|
|
49
|
+
readonly STOPPED: 2;
|
|
50
|
+
};
|
|
51
|
+
type TypingAction = (typeof TYPING_ACTION)[keyof typeof TYPING_ACTION];
|
|
52
|
+
|
|
1
53
|
type SessionType = 1 | 3;
|
|
2
54
|
interface SessionInfo {
|
|
3
55
|
firstID: number;
|
|
@@ -66,6 +118,13 @@ interface BotMsg {
|
|
|
66
118
|
quote?: BotMsg;
|
|
67
119
|
timestamp: number;
|
|
68
120
|
}
|
|
121
|
+
interface SendUserTypingParams {
|
|
122
|
+
token: string;
|
|
123
|
+
baseUrl?: string;
|
|
124
|
+
userAgent?: string;
|
|
125
|
+
sessionInfo: SessionInfo;
|
|
126
|
+
action: TypingAction;
|
|
127
|
+
}
|
|
69
128
|
|
|
70
129
|
type ErrorCode = 'INVALID_TOKEN' | 'UNAUTHORIZED' | 'CHAT_NOT_FOUND' | 'RATE_LIMIT' | 'INTERNAL_ERROR' | 'NETWORK_ERROR' | 'TIMEOUT_ERROR' | 'VALIDATION_ERROR' | 'EMPTY_MESSAGE';
|
|
71
130
|
interface ApiErrorResponse {
|
|
@@ -342,6 +401,7 @@ declare class MeetBot {
|
|
|
342
401
|
getAccessURL(params: GetAccessURLParams | GetAccessURLBySessionParams): Promise<AccessURLResult>;
|
|
343
402
|
uploadFile(buffer: Buffer, options: UploadFileOptions): Promise<UploadFileResult>;
|
|
344
403
|
sendMedia(sessionInfo: SessionInfo, options: SendMediaOptions): Promise<SendMessageResult>;
|
|
404
|
+
sendUserTyping(sessionInfo: SessionInfo, action: TypingAction): Promise<void>;
|
|
345
405
|
refreshUserCache(): Promise<void>;
|
|
346
406
|
getUserById(userId: number): Promise<MeetUser | undefined>;
|
|
347
407
|
getUserByIds(userIds: number[]): Promise<Map<number, MeetUser>>;
|
|
@@ -411,51 +471,6 @@ interface SendMessageParams {
|
|
|
411
471
|
msgContent: MsgContent;
|
|
412
472
|
}
|
|
413
473
|
declare function sendMessage(params: SendMessageParams): Promise<SendMessageResult>;
|
|
474
|
+
declare function sendUserTyping(params: SendUserTypingParams): Promise<void>;
|
|
414
475
|
|
|
415
|
-
|
|
416
|
-
declare const POLLING: {
|
|
417
|
-
readonly DEFAULT_LIMIT: 100;
|
|
418
|
-
readonly DEFAULT_TIMEOUT: 30;
|
|
419
|
-
readonly SUCCESS_DELAY: 1000;
|
|
420
|
-
readonly DEFAULT_RETRY_DELAY: 1000;
|
|
421
|
-
readonly MAX_RETRY_DELAY: 30000;
|
|
422
|
-
readonly DEFAULT_MAX_RETRIES: 0;
|
|
423
|
-
};
|
|
424
|
-
declare const HTTP: {
|
|
425
|
-
readonly DEFAULT_TIMEOUT: 60000;
|
|
426
|
-
readonly POLLING_TIMEOUT_BUFFER: 10000;
|
|
427
|
-
readonly UPLOAD_TIMEOUT: number;
|
|
428
|
-
};
|
|
429
|
-
declare const API: {
|
|
430
|
-
readonly DEFAULT_TIMEOUT: 30;
|
|
431
|
-
readonly DEFAULT_LIMIT: 100;
|
|
432
|
-
};
|
|
433
|
-
declare const UPLOAD: {
|
|
434
|
-
readonly MULTIPART_THRESHOLD: number;
|
|
435
|
-
readonly MAX_RETRY_COUNT: 3;
|
|
436
|
-
readonly RETRY_DELAY: 1000;
|
|
437
|
-
readonly MAX_CONCURRENCY: 4;
|
|
438
|
-
};
|
|
439
|
-
declare const CHUNK_RULES: readonly [{
|
|
440
|
-
readonly maxSize: number;
|
|
441
|
-
readonly chunks: 1;
|
|
442
|
-
}, {
|
|
443
|
-
readonly maxSize: number;
|
|
444
|
-
readonly chunks: 5;
|
|
445
|
-
}, {
|
|
446
|
-
readonly maxSize: number;
|
|
447
|
-
readonly chunks: 20;
|
|
448
|
-
}, {
|
|
449
|
-
readonly maxSize: number;
|
|
450
|
-
readonly chunks: 50;
|
|
451
|
-
}];
|
|
452
|
-
declare const SESSION_TYPE: {
|
|
453
|
-
readonly PRIVATE: 1;
|
|
454
|
-
readonly GROUP: 3;
|
|
455
|
-
readonly CHANNEL: 4;
|
|
456
|
-
};
|
|
457
|
-
declare function getChunkNum(size: number): number;
|
|
458
|
-
declare function getConvID(firstID: number, secondID: number, sessionType: number, companyID?: number): string;
|
|
459
|
-
declare function getQuoteMsgKey(convID: string, seqID: number): string;
|
|
460
|
-
|
|
461
|
-
export { API, type AccessURLResult, ApiError, type ApiErrorResponse, type ApiResponse, type AttachmentInfo, type BotChat, type BotFile, type BotMsg, type BotMsgUpdate, type BotUpdate, type BotUser, CHUNK_RULES, type ChatType, type CompleteMultipartUploadParams, type CompleteMultipartUploadResult, DEFAULT_BASE_URL, type ErrorCode, type ExtraInfo, type GetAccessURLBySessionParams, type GetAccessURLParams, type GetMultiPartUploadURLParams, type GetUpdatesOptions, type GetUpdatesV2Result, type GetUploadURLParams, HTTP, type LogLevel, MeetBot, type MeetBotConfig, MeetBotError, type MeetUser, type MsgContent, type MsgType, type MultiPartUploadURLResult, NetworkError, POLLING, type PollingOptions, type QuoteMsgMap, type ReceivedAttachmentInfo, SESSION_TYPE, type SendMediaOptions, type SendMessageOptions, type SendMessageResult, type SessionInfo, type SessionType, TimeoutError, UPLOAD, type UploadFileOptions, type UploadFileResult, type UploadPart, type UploadProgress, type UploadURLResult, UserCache, type UserCacheOptions, ValidationError, completeMultipartUpload, computeMD5, getAccessURL, getChunkNum, getConvID, getMultiPartUploadURL, getQuoteMsgKey, getUpdates, getUpdatesV2, getUploadURL, getUsers, sendMediaMessage, sendMessage, uploadFile };
|
|
476
|
+
export { API, type AccessURLResult, ApiError, type ApiErrorResponse, type ApiResponse, type AttachmentInfo, type BotChat, type BotFile, type BotMsg, type BotMsgUpdate, type BotUpdate, type BotUser, CHUNK_RULES, type ChatType, type CompleteMultipartUploadParams, type CompleteMultipartUploadResult, DEFAULT_BASE_URL, type ErrorCode, type ExtraInfo, type GetAccessURLBySessionParams, type GetAccessURLParams, type GetMultiPartUploadURLParams, type GetUpdatesOptions, type GetUpdatesV2Result, type GetUploadURLParams, HTTP, type LogLevel, MeetBot, type MeetBotConfig, MeetBotError, type MeetUser, type MsgContent, type MsgType, type MultiPartUploadURLResult, NetworkError, POLLING, type PollingOptions, type QuoteMsgMap, type ReceivedAttachmentInfo, SESSION_TYPE, type SendMediaOptions, type SendMessageOptions, type SendMessageResult, type SendUserTypingParams, type SessionInfo, type SessionType, TYPING_ACTION, TimeoutError, type TypingAction, UPLOAD, type UploadFileOptions, type UploadFileResult, type UploadPart, type UploadProgress, type UploadURLResult, UserCache, type UserCacheOptions, ValidationError, completeMultipartUpload, computeMD5, getAccessURL, getChunkNum, getConvID, getMultiPartUploadURL, getQuoteMsgKey, getUpdates, getUpdatesV2, getUploadURL, getUsers, sendMediaMessage, sendMessage, sendUserTyping, uploadFile };
|
package/dist/index.js
CHANGED
|
@@ -178,6 +178,14 @@ function getConvID(firstID, secondID, sessionType, companyID = 1) {
|
|
|
178
178
|
function getQuoteMsgKey(convID, seqID) {
|
|
179
179
|
return `${convID}:${seqID}`;
|
|
180
180
|
}
|
|
181
|
+
var TYPING_ACTION = {
|
|
182
|
+
/** 未指定 */
|
|
183
|
+
UNSPECIFIED: 0,
|
|
184
|
+
/** 正在输入 */
|
|
185
|
+
TYPING: 1,
|
|
186
|
+
/** 停止输入 */
|
|
187
|
+
STOPPED: 2
|
|
188
|
+
};
|
|
181
189
|
|
|
182
190
|
// src/utils/logger.ts
|
|
183
191
|
var Logger = class {
|
|
@@ -257,7 +265,7 @@ async function request(options) {
|
|
|
257
265
|
headers["User-Agent"] = userAgent;
|
|
258
266
|
}
|
|
259
267
|
logger.info("[Request]", method, url);
|
|
260
|
-
logger.info("[Headers]", sanitizeHeaders(headers));
|
|
268
|
+
logger.info("[Headers]", JSON.stringify(sanitizeHeaders(headers)));
|
|
261
269
|
if (body) {
|
|
262
270
|
logger.info("[Body]", JSON.stringify(body));
|
|
263
271
|
}
|
|
@@ -353,6 +361,9 @@ function mapStatusCodeToErrorCode(status) {
|
|
|
353
361
|
}
|
|
354
362
|
}
|
|
355
363
|
|
|
364
|
+
// src/api/index.ts
|
|
365
|
+
init_error();
|
|
366
|
+
|
|
356
367
|
// src/api/file.ts
|
|
357
368
|
async function getUploadURL(params) {
|
|
358
369
|
const { token, baseUrl, userAgent, ...body } = params;
|
|
@@ -682,6 +693,30 @@ async function sendMessage(params) {
|
|
|
682
693
|
}
|
|
683
694
|
});
|
|
684
695
|
}
|
|
696
|
+
async function sendUserTyping(params) {
|
|
697
|
+
const { token, baseUrl, userAgent, sessionInfo, action } = params;
|
|
698
|
+
const response = await request({
|
|
699
|
+
token,
|
|
700
|
+
baseUrl,
|
|
701
|
+
userAgent,
|
|
702
|
+
method: "POST",
|
|
703
|
+
path: "SendUserTyping",
|
|
704
|
+
pathPrefix: "/im/",
|
|
705
|
+
raw: true,
|
|
706
|
+
body: {
|
|
707
|
+
sessionInfo,
|
|
708
|
+
action
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
if (response && typeof response === "object" && Object.keys(response).length === 0) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
if ("ok" in response && response.ok) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
const errorData = response;
|
|
718
|
+
throw new ApiError(errorData.description || "SendUserTyping failed", 200, "INTERNAL_ERROR", errorData.retry_after);
|
|
719
|
+
}
|
|
685
720
|
|
|
686
721
|
// src/client.ts
|
|
687
722
|
init_error();
|
|
@@ -1013,6 +1048,20 @@ var MeetBot = class {
|
|
|
1013
1048
|
async sendMedia(sessionInfo, options) {
|
|
1014
1049
|
return sendMediaMessage(this.token, sessionInfo, options, this.baseUrl, this.userAgent);
|
|
1015
1050
|
}
|
|
1051
|
+
/**
|
|
1052
|
+
* 发送输入状态
|
|
1053
|
+
* @param sessionInfo 会话信息
|
|
1054
|
+
* @param action 输入状态:TYPING_ACTION.TYPING(正在输入)或 TYPING_ACTION.STOPPED(停止输入)
|
|
1055
|
+
*/
|
|
1056
|
+
async sendUserTyping(sessionInfo, action) {
|
|
1057
|
+
return sendUserTyping({
|
|
1058
|
+
token: this.token,
|
|
1059
|
+
baseUrl: this.baseUrl,
|
|
1060
|
+
userAgent: this.userAgent,
|
|
1061
|
+
sessionInfo,
|
|
1062
|
+
action
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1016
1065
|
/**
|
|
1017
1066
|
* 刷新用户缓存
|
|
1018
1067
|
*/
|
|
@@ -1071,4 +1120,4 @@ var MeetBot = class {
|
|
|
1071
1120
|
// src/index.ts
|
|
1072
1121
|
init_error();
|
|
1073
1122
|
|
|
1074
|
-
export { API, ApiError, CHUNK_RULES, DEFAULT_BASE_URL, HTTP, MeetBot, MeetBotError, NetworkError, POLLING, SESSION_TYPE, TimeoutError, UPLOAD, UserCache, ValidationError, completeMultipartUpload, computeMD5, getAccessURL, getChunkNum, getConvID, getMultiPartUploadURL, getQuoteMsgKey, getUpdates, getUpdatesV2, getUploadURL, getUsers, sendMediaMessage, sendMessage, uploadFile };
|
|
1123
|
+
export { API, ApiError, CHUNK_RULES, DEFAULT_BASE_URL, HTTP, MeetBot, MeetBotError, NetworkError, POLLING, SESSION_TYPE, TYPING_ACTION, TimeoutError, UPLOAD, UserCache, ValidationError, completeMultipartUpload, computeMD5, getAccessURL, getChunkNum, getConvID, getMultiPartUploadURL, getQuoteMsgKey, getUpdates, getUpdatesV2, getUploadURL, getUsers, sendMediaMessage, sendMessage, sendUserTyping, uploadFile };
|