@meet-im/meet-bot-jssdk 0.0.6 → 0.0.7

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.d.cts 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 {
@@ -98,6 +108,99 @@ interface PollingOptions {
98
108
  onOffsetUpdate?: (offset: number) => void;
99
109
  }
100
110
 
111
+ interface GetUploadURLParams {
112
+ originFileName: string;
113
+ contentType: string;
114
+ md5: string;
115
+ size: number;
116
+ fullImage?: boolean;
117
+ videoLength?: number;
118
+ bestDomain?: string;
119
+ uploadId?: string;
120
+ chunkNum?: number;
121
+ }
122
+ interface UploadURLResult {
123
+ signedUrl: string;
124
+ callback?: string;
125
+ path: string;
126
+ id: number;
127
+ size: number;
128
+ }
129
+ interface GetMultiPartUploadURLParams {
130
+ originFileName: string;
131
+ contentType: string;
132
+ md5: string;
133
+ size: number;
134
+ fullImage?: boolean;
135
+ videoLength?: number;
136
+ bestDomain?: string;
137
+ }
138
+ interface MultiPartUploadURLResult {
139
+ chunkNum: number;
140
+ mapSignURLs: Record<string, string>;
141
+ ID?: number;
142
+ path?: string;
143
+ size: number;
144
+ }
145
+ interface UploadPart {
146
+ partNumber: number;
147
+ eTag: string;
148
+ }
149
+ interface CompleteMultipartUploadParams {
150
+ originFileName: string;
151
+ md5: string;
152
+ UploadParts: UploadPart[];
153
+ }
154
+ interface CompleteMultipartUploadResult {
155
+ ID: number;
156
+ path: string;
157
+ }
158
+ interface GetAccessURLParams {
159
+ firstId: number;
160
+ secondId: number;
161
+ sessionType: number;
162
+ seqId: number;
163
+ fileId: number;
164
+ 'x-oss-process'?: string;
165
+ origin?: string;
166
+ bestDomain?: string;
167
+ printResult?: string;
168
+ }
169
+ interface AccessURLResult {
170
+ fileUrl: string;
171
+ }
172
+ interface UploadProgress {
173
+ percent: string;
174
+ loaded: number;
175
+ total: number;
176
+ speedPerSecond: string;
177
+ percentRate: number;
178
+ }
179
+ interface UploadFileOptions {
180
+ fileName: string;
181
+ contentType: string;
182
+ onProgress?: (progress: UploadProgress) => void;
183
+ }
184
+ interface UploadFileResult {
185
+ fileID: number;
186
+ path: string;
187
+ size: number;
188
+ }
189
+ interface SendMediaOptions {
190
+ buffer: Buffer;
191
+ fileName: string;
192
+ contentType: string;
193
+ content?: string;
194
+ onProgress?: (progress: UploadProgress) => void;
195
+ }
196
+ interface ReceivedAttachmentInfo {
197
+ fileID: string;
198
+ fileName?: string;
199
+ fileUrl: string;
200
+ fileSize?: number;
201
+ mimeType?: string;
202
+ }
203
+
101
204
  declare class MeetBotError extends Error {
102
205
  readonly code: ErrorCode;
103
206
  constructor(message: string, code: ErrorCode);
@@ -149,9 +252,40 @@ declare class MeetBot {
149
252
  limit?: number;
150
253
  }): Promise<BotUpdate[]>;
151
254
  sendMessage(sessionInfo: SessionInfo, msgContent: MsgContent): Promise<SendMessageResult>;
255
+ getUploadURL(params: Omit<GetUploadURLParams, 'fileType'>): Promise<UploadURLResult>;
256
+ getMultiPartUploadURL(params: Omit<GetMultiPartUploadURLParams, 'fileType'>): Promise<MultiPartUploadURLResult>;
257
+ completeMultipartUpload(params: CompleteMultipartUploadParams): Promise<CompleteMultipartUploadResult>;
258
+ getAccessURL(params: GetAccessURLParams): Promise<AccessURLResult>;
259
+ uploadFile(buffer: Buffer, options: UploadFileOptions): Promise<UploadFileResult>;
260
+ sendMedia(sessionInfo: SessionInfo, options: SendMediaOptions): Promise<SendMessageResult>;
152
261
  private sleep;
153
262
  }
154
263
 
264
+ interface GetUploadURLApiParams extends GetUploadURLParams {
265
+ token: string;
266
+ baseUrl?: string;
267
+ }
268
+ declare function getUploadURL(params: GetUploadURLApiParams): Promise<UploadURLResult>;
269
+ interface GetMultiPartUploadURLApiParams extends GetMultiPartUploadURLParams {
270
+ token: string;
271
+ baseUrl?: string;
272
+ }
273
+ declare function getMultiPartUploadURL(params: GetMultiPartUploadURLApiParams): Promise<MultiPartUploadURLResult>;
274
+ interface CompleteMultipartUploadApiParams extends CompleteMultipartUploadParams {
275
+ token: string;
276
+ baseUrl?: string;
277
+ }
278
+ declare function completeMultipartUpload(params: CompleteMultipartUploadApiParams): Promise<CompleteMultipartUploadResult>;
279
+ interface GetAccessURLApiParams extends GetAccessURLParams {
280
+ token: string;
281
+ baseUrl?: string;
282
+ }
283
+ declare function getAccessURL(params: GetAccessURLApiParams): Promise<AccessURLResult>;
284
+
285
+ declare function computeMD5(buffer: Buffer): Promise<string>;
286
+ declare function uploadFile(token: string, buffer: Buffer, options: UploadFileOptions, baseUrl?: string): Promise<UploadFileResult>;
287
+ declare function sendMediaMessage(token: string, sessionInfo: SessionInfo, options: SendMediaOptions, baseUrl?: string): Promise<SendMessageResult>;
288
+
155
289
  interface GetUpdatesParams {
156
290
  token: string;
157
291
  baseUrl?: string;
@@ -180,10 +314,31 @@ declare const POLLING: {
180
314
  declare const HTTP: {
181
315
  readonly DEFAULT_TIMEOUT: 60000;
182
316
  readonly POLLING_TIMEOUT_BUFFER: 10000;
317
+ readonly UPLOAD_TIMEOUT: number;
183
318
  };
184
319
  declare const API: {
185
320
  readonly DEFAULT_TIMEOUT: 30;
186
321
  readonly DEFAULT_LIMIT: 100;
187
322
  };
323
+ declare const UPLOAD: {
324
+ readonly MULTIPART_THRESHOLD: number;
325
+ readonly MAX_RETRY_COUNT: 3;
326
+ readonly RETRY_DELAY: 1000;
327
+ readonly MAX_CONCURRENCY: 4;
328
+ };
329
+ declare const CHUNK_RULES: readonly [{
330
+ readonly maxSize: number;
331
+ readonly chunks: 1;
332
+ }, {
333
+ readonly maxSize: number;
334
+ readonly chunks: 5;
335
+ }, {
336
+ readonly maxSize: number;
337
+ readonly chunks: 20;
338
+ }, {
339
+ readonly maxSize: number;
340
+ readonly chunks: 50;
341
+ }];
342
+ declare function getChunkNum(size: number): number;
188
343
 
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 };
344
+ export { API, type AccessURLResult, ApiError, type ApiErrorResponse, type ApiResponse, type AttachmentInfo, type BotChat, type BotFile, type BotMsg, type BotUpdate, type BotUser, CHUNK_RULES, type ChatType, type CompleteMultipartUploadParams, type CompleteMultipartUploadResult, DEFAULT_BASE_URL, type ErrorCode, type ExtraInfo, type GetAccessURLParams, type GetMultiPartUploadURLParams, type GetUpdatesOptions, type GetUploadURLParams, HTTP, type LogLevel, MeetBot, type MeetBotConfig, MeetBotError, type MsgContent, type MsgType, type MultiPartUploadURLResult, NetworkError, POLLING, type PollingOptions, type ReceivedAttachmentInfo, 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, getMultiPartUploadURL, getUpdates, getUploadURL, sendMediaMessage, sendMessage, uploadFile };
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 {
@@ -98,6 +108,99 @@ interface PollingOptions {
98
108
  onOffsetUpdate?: (offset: number) => void;
99
109
  }
100
110
 
111
+ interface GetUploadURLParams {
112
+ originFileName: string;
113
+ contentType: string;
114
+ md5: string;
115
+ size: number;
116
+ fullImage?: boolean;
117
+ videoLength?: number;
118
+ bestDomain?: string;
119
+ uploadId?: string;
120
+ chunkNum?: number;
121
+ }
122
+ interface UploadURLResult {
123
+ signedUrl: string;
124
+ callback?: string;
125
+ path: string;
126
+ id: number;
127
+ size: number;
128
+ }
129
+ interface GetMultiPartUploadURLParams {
130
+ originFileName: string;
131
+ contentType: string;
132
+ md5: string;
133
+ size: number;
134
+ fullImage?: boolean;
135
+ videoLength?: number;
136
+ bestDomain?: string;
137
+ }
138
+ interface MultiPartUploadURLResult {
139
+ chunkNum: number;
140
+ mapSignURLs: Record<string, string>;
141
+ ID?: number;
142
+ path?: string;
143
+ size: number;
144
+ }
145
+ interface UploadPart {
146
+ partNumber: number;
147
+ eTag: string;
148
+ }
149
+ interface CompleteMultipartUploadParams {
150
+ originFileName: string;
151
+ md5: string;
152
+ UploadParts: UploadPart[];
153
+ }
154
+ interface CompleteMultipartUploadResult {
155
+ ID: number;
156
+ path: string;
157
+ }
158
+ interface GetAccessURLParams {
159
+ firstId: number;
160
+ secondId: number;
161
+ sessionType: number;
162
+ seqId: number;
163
+ fileId: number;
164
+ 'x-oss-process'?: string;
165
+ origin?: string;
166
+ bestDomain?: string;
167
+ printResult?: string;
168
+ }
169
+ interface AccessURLResult {
170
+ fileUrl: string;
171
+ }
172
+ interface UploadProgress {
173
+ percent: string;
174
+ loaded: number;
175
+ total: number;
176
+ speedPerSecond: string;
177
+ percentRate: number;
178
+ }
179
+ interface UploadFileOptions {
180
+ fileName: string;
181
+ contentType: string;
182
+ onProgress?: (progress: UploadProgress) => void;
183
+ }
184
+ interface UploadFileResult {
185
+ fileID: number;
186
+ path: string;
187
+ size: number;
188
+ }
189
+ interface SendMediaOptions {
190
+ buffer: Buffer;
191
+ fileName: string;
192
+ contentType: string;
193
+ content?: string;
194
+ onProgress?: (progress: UploadProgress) => void;
195
+ }
196
+ interface ReceivedAttachmentInfo {
197
+ fileID: string;
198
+ fileName?: string;
199
+ fileUrl: string;
200
+ fileSize?: number;
201
+ mimeType?: string;
202
+ }
203
+
101
204
  declare class MeetBotError extends Error {
102
205
  readonly code: ErrorCode;
103
206
  constructor(message: string, code: ErrorCode);
@@ -149,9 +252,40 @@ declare class MeetBot {
149
252
  limit?: number;
150
253
  }): Promise<BotUpdate[]>;
151
254
  sendMessage(sessionInfo: SessionInfo, msgContent: MsgContent): Promise<SendMessageResult>;
255
+ getUploadURL(params: Omit<GetUploadURLParams, 'fileType'>): Promise<UploadURLResult>;
256
+ getMultiPartUploadURL(params: Omit<GetMultiPartUploadURLParams, 'fileType'>): Promise<MultiPartUploadURLResult>;
257
+ completeMultipartUpload(params: CompleteMultipartUploadParams): Promise<CompleteMultipartUploadResult>;
258
+ getAccessURL(params: GetAccessURLParams): Promise<AccessURLResult>;
259
+ uploadFile(buffer: Buffer, options: UploadFileOptions): Promise<UploadFileResult>;
260
+ sendMedia(sessionInfo: SessionInfo, options: SendMediaOptions): Promise<SendMessageResult>;
152
261
  private sleep;
153
262
  }
154
263
 
264
+ interface GetUploadURLApiParams extends GetUploadURLParams {
265
+ token: string;
266
+ baseUrl?: string;
267
+ }
268
+ declare function getUploadURL(params: GetUploadURLApiParams): Promise<UploadURLResult>;
269
+ interface GetMultiPartUploadURLApiParams extends GetMultiPartUploadURLParams {
270
+ token: string;
271
+ baseUrl?: string;
272
+ }
273
+ declare function getMultiPartUploadURL(params: GetMultiPartUploadURLApiParams): Promise<MultiPartUploadURLResult>;
274
+ interface CompleteMultipartUploadApiParams extends CompleteMultipartUploadParams {
275
+ token: string;
276
+ baseUrl?: string;
277
+ }
278
+ declare function completeMultipartUpload(params: CompleteMultipartUploadApiParams): Promise<CompleteMultipartUploadResult>;
279
+ interface GetAccessURLApiParams extends GetAccessURLParams {
280
+ token: string;
281
+ baseUrl?: string;
282
+ }
283
+ declare function getAccessURL(params: GetAccessURLApiParams): Promise<AccessURLResult>;
284
+
285
+ declare function computeMD5(buffer: Buffer): Promise<string>;
286
+ declare function uploadFile(token: string, buffer: Buffer, options: UploadFileOptions, baseUrl?: string): Promise<UploadFileResult>;
287
+ declare function sendMediaMessage(token: string, sessionInfo: SessionInfo, options: SendMediaOptions, baseUrl?: string): Promise<SendMessageResult>;
288
+
155
289
  interface GetUpdatesParams {
156
290
  token: string;
157
291
  baseUrl?: string;
@@ -180,10 +314,31 @@ declare const POLLING: {
180
314
  declare const HTTP: {
181
315
  readonly DEFAULT_TIMEOUT: 60000;
182
316
  readonly POLLING_TIMEOUT_BUFFER: 10000;
317
+ readonly UPLOAD_TIMEOUT: number;
183
318
  };
184
319
  declare const API: {
185
320
  readonly DEFAULT_TIMEOUT: 30;
186
321
  readonly DEFAULT_LIMIT: 100;
187
322
  };
323
+ declare const UPLOAD: {
324
+ readonly MULTIPART_THRESHOLD: number;
325
+ readonly MAX_RETRY_COUNT: 3;
326
+ readonly RETRY_DELAY: 1000;
327
+ readonly MAX_CONCURRENCY: 4;
328
+ };
329
+ declare const CHUNK_RULES: readonly [{
330
+ readonly maxSize: number;
331
+ readonly chunks: 1;
332
+ }, {
333
+ readonly maxSize: number;
334
+ readonly chunks: 5;
335
+ }, {
336
+ readonly maxSize: number;
337
+ readonly chunks: 20;
338
+ }, {
339
+ readonly maxSize: number;
340
+ readonly chunks: 50;
341
+ }];
342
+ declare function getChunkNum(size: number): number;
188
343
 
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 };
344
+ export { API, type AccessURLResult, ApiError, type ApiErrorResponse, type ApiResponse, type AttachmentInfo, type BotChat, type BotFile, type BotMsg, type BotUpdate, type BotUser, CHUNK_RULES, type ChatType, type CompleteMultipartUploadParams, type CompleteMultipartUploadResult, DEFAULT_BASE_URL, type ErrorCode, type ExtraInfo, type GetAccessURLParams, type GetMultiPartUploadURLParams, type GetUpdatesOptions, type GetUploadURLParams, HTTP, type LogLevel, MeetBot, type MeetBotConfig, MeetBotError, type MsgContent, type MsgType, type MultiPartUploadURLResult, NetworkError, POLLING, type PollingOptions, type ReceivedAttachmentInfo, 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, getMultiPartUploadURL, getUpdates, getUploadURL, sendMediaMessage, sendMessage, uploadFile };