@meet-im/meet-bot-jssdk 0.0.6 → 1.0.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/README.md +182 -44
- package/dist/index.cjs +458 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -2
- package/dist/index.d.ts +194 -2
- package/dist/index.js +441 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,18 @@ interface SessionInfo {
|
|
|
6
6
|
companyID?: number;
|
|
7
7
|
}
|
|
8
8
|
type MsgType = 'NORMAL' | 'RECALL' | 'QUOTE';
|
|
9
|
+
interface AttachmentInfo {
|
|
10
|
+
fileID: string | number;
|
|
11
|
+
fileName?: string;
|
|
12
|
+
filePath?: string;
|
|
13
|
+
fileSize?: number;
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
fileUrl?: string;
|
|
16
|
+
}
|
|
9
17
|
interface ExtraInfo {
|
|
10
18
|
msgType?: MsgType;
|
|
19
|
+
attechmentInfo?: AttachmentInfo;
|
|
20
|
+
attechmentInfos?: AttachmentInfo[];
|
|
11
21
|
[key: string]: unknown;
|
|
12
22
|
}
|
|
13
23
|
interface MsgContent {
|
|
@@ -16,12 +26,21 @@ interface MsgContent {
|
|
|
16
26
|
timestamp?: number;
|
|
17
27
|
fromUid?: number;
|
|
18
28
|
atIds?: number[];
|
|
29
|
+
quoteSeqID?: number;
|
|
19
30
|
extraInfo?: ExtraInfo;
|
|
20
31
|
sessionInfo?: SessionInfo;
|
|
21
32
|
}
|
|
22
33
|
interface BotUpdate {
|
|
23
34
|
message?: MsgContent;
|
|
24
35
|
}
|
|
36
|
+
interface BotMsgUpdate {
|
|
37
|
+
message: MsgContent;
|
|
38
|
+
}
|
|
39
|
+
type QuoteMsgMap = Record<string, MsgContent>;
|
|
40
|
+
interface GetUpdatesV2Result {
|
|
41
|
+
msgs: BotMsgUpdate[];
|
|
42
|
+
quoteMsgMap: QuoteMsgMap;
|
|
43
|
+
}
|
|
25
44
|
interface BotUser {
|
|
26
45
|
id: number;
|
|
27
46
|
name: string;
|
|
@@ -71,6 +90,7 @@ interface MeetBotConfig {
|
|
|
71
90
|
pollingLimit?: number;
|
|
72
91
|
longPollingTimeout?: number;
|
|
73
92
|
logLevel?: LogLevel;
|
|
93
|
+
useV2?: boolean;
|
|
74
94
|
}
|
|
75
95
|
interface GetUpdatesOptions {
|
|
76
96
|
token: string;
|
|
@@ -98,6 +118,104 @@ interface PollingOptions {
|
|
|
98
118
|
onOffsetUpdate?: (offset: number) => void;
|
|
99
119
|
}
|
|
100
120
|
|
|
121
|
+
interface GetUploadURLParams {
|
|
122
|
+
originFileName: string;
|
|
123
|
+
contentType: string;
|
|
124
|
+
md5: string;
|
|
125
|
+
size: number;
|
|
126
|
+
fullImage?: boolean;
|
|
127
|
+
videoLength?: number;
|
|
128
|
+
bestDomain?: string;
|
|
129
|
+
uploadId?: string;
|
|
130
|
+
chunkNum?: number;
|
|
131
|
+
}
|
|
132
|
+
interface UploadURLResult {
|
|
133
|
+
signedUrl: string;
|
|
134
|
+
callback?: string;
|
|
135
|
+
path: string;
|
|
136
|
+
id: number;
|
|
137
|
+
size: number;
|
|
138
|
+
}
|
|
139
|
+
interface GetMultiPartUploadURLParams {
|
|
140
|
+
originFileName: string;
|
|
141
|
+
contentType: string;
|
|
142
|
+
md5: string;
|
|
143
|
+
size: number;
|
|
144
|
+
fullImage?: boolean;
|
|
145
|
+
videoLength?: number;
|
|
146
|
+
bestDomain?: string;
|
|
147
|
+
}
|
|
148
|
+
interface MultiPartUploadURLResult {
|
|
149
|
+
chunkNum: number;
|
|
150
|
+
mapSignURLs: Record<string, string>;
|
|
151
|
+
ID?: number;
|
|
152
|
+
path?: string;
|
|
153
|
+
size: number;
|
|
154
|
+
}
|
|
155
|
+
interface UploadPart {
|
|
156
|
+
partNumber: number;
|
|
157
|
+
eTag: string;
|
|
158
|
+
}
|
|
159
|
+
interface CompleteMultipartUploadParams {
|
|
160
|
+
originFileName: string;
|
|
161
|
+
md5: string;
|
|
162
|
+
UploadParts: UploadPart[];
|
|
163
|
+
}
|
|
164
|
+
interface CompleteMultipartUploadResult {
|
|
165
|
+
ID: number;
|
|
166
|
+
path: string;
|
|
167
|
+
}
|
|
168
|
+
interface GetAccessURLParams {
|
|
169
|
+
firstId: number;
|
|
170
|
+
secondId: number;
|
|
171
|
+
sessionType: number;
|
|
172
|
+
seqId: number;
|
|
173
|
+
fileId: number;
|
|
174
|
+
companyId?: number;
|
|
175
|
+
'x-oss-process'?: string;
|
|
176
|
+
printResult?: string;
|
|
177
|
+
}
|
|
178
|
+
interface GetAccessURLBySessionParams {
|
|
179
|
+
sessionInfo: SessionInfo;
|
|
180
|
+
seqId: number;
|
|
181
|
+
fileId: number;
|
|
182
|
+
printResult?: string;
|
|
183
|
+
}
|
|
184
|
+
interface AccessURLResult {
|
|
185
|
+
fileUrl: string;
|
|
186
|
+
}
|
|
187
|
+
interface UploadProgress {
|
|
188
|
+
percent: string;
|
|
189
|
+
loaded: number;
|
|
190
|
+
total: number;
|
|
191
|
+
speedPerSecond: string;
|
|
192
|
+
percentRate: number;
|
|
193
|
+
}
|
|
194
|
+
interface UploadFileOptions {
|
|
195
|
+
fileName: string;
|
|
196
|
+
contentType: string;
|
|
197
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
198
|
+
}
|
|
199
|
+
interface UploadFileResult {
|
|
200
|
+
fileID: number;
|
|
201
|
+
path: string;
|
|
202
|
+
size: number;
|
|
203
|
+
}
|
|
204
|
+
interface SendMediaOptions {
|
|
205
|
+
buffer: Buffer;
|
|
206
|
+
fileName: string;
|
|
207
|
+
contentType: string;
|
|
208
|
+
content?: string;
|
|
209
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
210
|
+
}
|
|
211
|
+
interface ReceivedAttachmentInfo {
|
|
212
|
+
fileID: string;
|
|
213
|
+
fileName?: string;
|
|
214
|
+
fileUrl: string;
|
|
215
|
+
fileSize?: number;
|
|
216
|
+
mimeType?: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
101
219
|
declare class MeetBotError extends Error {
|
|
102
220
|
readonly code: ErrorCode;
|
|
103
221
|
constructor(message: string, code: ErrorCode);
|
|
@@ -122,7 +240,10 @@ declare class ValidationError extends MeetBotError {
|
|
|
122
240
|
|
|
123
241
|
type EventHandler<T = unknown> = (data: T) => void;
|
|
124
242
|
interface Events {
|
|
125
|
-
message:
|
|
243
|
+
message: {
|
|
244
|
+
message: MsgContent;
|
|
245
|
+
quoteMsgMap: QuoteMsgMap;
|
|
246
|
+
};
|
|
126
247
|
error: Error;
|
|
127
248
|
polling_start: void;
|
|
128
249
|
polling_stop: void;
|
|
@@ -132,6 +253,7 @@ declare class MeetBot {
|
|
|
132
253
|
private readonly baseUrl;
|
|
133
254
|
private readonly pollingLimit;
|
|
134
255
|
private readonly longPollingTimeout;
|
|
256
|
+
private readonly useV2;
|
|
135
257
|
private readonly eventHandlers;
|
|
136
258
|
private polling;
|
|
137
259
|
private offset;
|
|
@@ -148,10 +270,45 @@ declare class MeetBot {
|
|
|
148
270
|
offset?: number;
|
|
149
271
|
limit?: number;
|
|
150
272
|
}): Promise<BotUpdate[]>;
|
|
273
|
+
getUpdatesV2(options?: {
|
|
274
|
+
timeout?: number;
|
|
275
|
+
limit?: number;
|
|
276
|
+
}): Promise<GetUpdatesV2Result>;
|
|
151
277
|
sendMessage(sessionInfo: SessionInfo, msgContent: MsgContent): Promise<SendMessageResult>;
|
|
278
|
+
getUploadURL(params: Omit<GetUploadURLParams, 'fileType'>): Promise<UploadURLResult>;
|
|
279
|
+
getMultiPartUploadURL(params: Omit<GetMultiPartUploadURLParams, 'fileType'>): Promise<MultiPartUploadURLResult>;
|
|
280
|
+
completeMultipartUpload(params: CompleteMultipartUploadParams): Promise<CompleteMultipartUploadResult>;
|
|
281
|
+
getAccessURL(params: GetAccessURLParams | GetAccessURLBySessionParams): Promise<AccessURLResult>;
|
|
282
|
+
uploadFile(buffer: Buffer, options: UploadFileOptions): Promise<UploadFileResult>;
|
|
283
|
+
sendMedia(sessionInfo: SessionInfo, options: SendMediaOptions): Promise<SendMessageResult>;
|
|
152
284
|
private sleep;
|
|
153
285
|
}
|
|
154
286
|
|
|
287
|
+
interface GetUploadURLApiParams extends GetUploadURLParams {
|
|
288
|
+
token: string;
|
|
289
|
+
baseUrl?: string;
|
|
290
|
+
}
|
|
291
|
+
declare function getUploadURL(params: GetUploadURLApiParams): Promise<UploadURLResult>;
|
|
292
|
+
interface GetMultiPartUploadURLApiParams extends GetMultiPartUploadURLParams {
|
|
293
|
+
token: string;
|
|
294
|
+
baseUrl?: string;
|
|
295
|
+
}
|
|
296
|
+
declare function getMultiPartUploadURL(params: GetMultiPartUploadURLApiParams): Promise<MultiPartUploadURLResult>;
|
|
297
|
+
interface CompleteMultipartUploadApiParams extends CompleteMultipartUploadParams {
|
|
298
|
+
token: string;
|
|
299
|
+
baseUrl?: string;
|
|
300
|
+
}
|
|
301
|
+
declare function completeMultipartUpload(params: CompleteMultipartUploadApiParams): Promise<CompleteMultipartUploadResult>;
|
|
302
|
+
interface GetAccessURLApiParams extends GetAccessURLParams {
|
|
303
|
+
token: string;
|
|
304
|
+
baseUrl?: string;
|
|
305
|
+
}
|
|
306
|
+
declare function getAccessURL(params: GetAccessURLApiParams): Promise<AccessURLResult>;
|
|
307
|
+
|
|
308
|
+
declare function computeMD5(buffer: Buffer): Promise<string>;
|
|
309
|
+
declare function uploadFile(token: string, buffer: Buffer, options: UploadFileOptions, baseUrl?: string): Promise<UploadFileResult>;
|
|
310
|
+
declare function sendMediaMessage(token: string, sessionInfo: SessionInfo, options: SendMediaOptions, baseUrl?: string): Promise<SendMessageResult>;
|
|
311
|
+
|
|
155
312
|
interface GetUpdatesParams {
|
|
156
313
|
token: string;
|
|
157
314
|
baseUrl?: string;
|
|
@@ -160,6 +317,13 @@ interface GetUpdatesParams {
|
|
|
160
317
|
limit?: number;
|
|
161
318
|
}
|
|
162
319
|
declare function getUpdates(params: GetUpdatesParams): Promise<BotUpdate[]>;
|
|
320
|
+
interface GetUpdatesV2Params {
|
|
321
|
+
token: string;
|
|
322
|
+
baseUrl?: string;
|
|
323
|
+
timeout?: number;
|
|
324
|
+
limit?: number;
|
|
325
|
+
}
|
|
326
|
+
declare function getUpdatesV2(params: GetUpdatesV2Params): Promise<GetUpdatesV2Result>;
|
|
163
327
|
interface SendMessageParams {
|
|
164
328
|
token: string;
|
|
165
329
|
baseUrl?: string;
|
|
@@ -180,10 +344,38 @@ declare const POLLING: {
|
|
|
180
344
|
declare const HTTP: {
|
|
181
345
|
readonly DEFAULT_TIMEOUT: 60000;
|
|
182
346
|
readonly POLLING_TIMEOUT_BUFFER: 10000;
|
|
347
|
+
readonly UPLOAD_TIMEOUT: number;
|
|
183
348
|
};
|
|
184
349
|
declare const API: {
|
|
185
350
|
readonly DEFAULT_TIMEOUT: 30;
|
|
186
351
|
readonly DEFAULT_LIMIT: 100;
|
|
187
352
|
};
|
|
353
|
+
declare const UPLOAD: {
|
|
354
|
+
readonly MULTIPART_THRESHOLD: number;
|
|
355
|
+
readonly MAX_RETRY_COUNT: 3;
|
|
356
|
+
readonly RETRY_DELAY: 1000;
|
|
357
|
+
readonly MAX_CONCURRENCY: 4;
|
|
358
|
+
};
|
|
359
|
+
declare const CHUNK_RULES: readonly [{
|
|
360
|
+
readonly maxSize: number;
|
|
361
|
+
readonly chunks: 1;
|
|
362
|
+
}, {
|
|
363
|
+
readonly maxSize: number;
|
|
364
|
+
readonly chunks: 5;
|
|
365
|
+
}, {
|
|
366
|
+
readonly maxSize: number;
|
|
367
|
+
readonly chunks: 20;
|
|
368
|
+
}, {
|
|
369
|
+
readonly maxSize: number;
|
|
370
|
+
readonly chunks: 50;
|
|
371
|
+
}];
|
|
372
|
+
declare const SESSION_TYPE: {
|
|
373
|
+
readonly PRIVATE: 1;
|
|
374
|
+
readonly GROUP: 3;
|
|
375
|
+
readonly CHANNEL: 4;
|
|
376
|
+
};
|
|
377
|
+
declare function getChunkNum(size: number): number;
|
|
378
|
+
declare function getConvID(firstID: number, secondID: number, sessionType: number, companyID?: number): string;
|
|
379
|
+
declare function getQuoteMsgKey(convID: string, seqID: number): string;
|
|
188
380
|
|
|
189
|
-
export { API, ApiError, type ApiErrorResponse, type ApiResponse, type BotChat, type BotFile, type BotMsg, type BotUpdate, type BotUser, type ChatType, DEFAULT_BASE_URL, type ErrorCode, type ExtraInfo, type GetUpdatesOptions, HTTP, type LogLevel, MeetBot, type MeetBotConfig, MeetBotError, type MsgContent, type MsgType, NetworkError, POLLING, type PollingOptions, type SendMessageOptions, type SendMessageResult, type SessionInfo, type SessionType, TimeoutError, ValidationError, getUpdates, sendMessage };
|
|
381
|
+
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 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, ValidationError, completeMultipartUpload, computeMD5, getAccessURL, getChunkNum, getConvID, getMultiPartUploadURL, getQuoteMsgKey, getUpdates, getUpdatesV2, getUploadURL, sendMediaMessage, sendMessage, uploadFile };
|