-
Notifications
You must be signed in to change notification settings - Fork 217
/
quickblox.d.ts
1679 lines (1595 loc) · 51.5 KB
/
quickblox.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
type Dictionary<T> = Record<string, T>
type RequiredProps<T, K extends keyof T> = T & Required<Pick<T, K>>
export declare interface QBUser {
/** ID of the user. Generated automatically by the server after user creation. */
id: number
/** User's full name. */
full_name: string
/** User's email. */
email: string
/** User's login. */
login: string
/** User's phone number. */
phone: string
/** User's website url. */
website: string | null
/** Date & time when record was created, filled automatically. */
created_at: string
/** Date & time when record was created, filled automatically. */
updated_at: string
/** Date & time when a user sent the last request, filled automatically. */
last_request_at: string
/** ID of the user in the external system. */
external_user_id: number | null
/** ID of the user's Facebook account. */
facebook_id: string | null
/** ID of the file/blob. Generated automatically by the server after file/blob creation. */
blob_id: number | null
/** User's additional info. */
custom_data: string | null
/** User's tags. Comma separated array of tags. */
user_tags: string | null
/** @deprecated Marketing info. */
allow_sales_activities: boolean | null
/** @deprecated Marketing info. */
allow_statistics_analysis: boolean | null
/** @deprecated GDPR info. */
age_over16: boolean | null
/** @deprecated GDPR info. */
parents_contacts: string | null
}
export declare interface QBSession {
/** ID of the session. Generated automatically by the server after session creation. */
id: number
/** ID of the user's application. */
application_id: number
/** ID of the session's owner. */
user_id: QBUser['id']
/** Date & time when a record was created, filled automatically. */
created_at: string
/** Date & time when a record was created, filled automatically. */
updated_at: string
/** Unique Random Value. Parameter from a session creating request is used. */
nonce: string
/** Session identifier. Each API request should contain this parameter in QB-Token header. */
token: string
/** Unix Timestamp. Parameter from session creating request is used. */
ts: number
/**
* ID of the session. Generated automatically by the server after session creation.
* Date & time when a record was updated, filled automatically.
*/
_id: string
}
declare enum QBChatProtocol {
BOSH = 1,
WebSockets = 2,
}
interface ICEServer {
urls: string
username: string
credential: string
}
export declare interface QBConfig {
/** [Custom endpoints](https://docs.quickblox.com/docs/js-setup#section-custom-endpoints) configuration. */
endpoints?: {
/** API endpoint. */
api?: string
/** Chat endpoint. */
chat?: string
}
/** [WebRTC](https://docs.quickblox.com/docs/js-video-calling-advanced#section-video-calling-settings) configuration. */
webrtc?: {
/**
* Maximum answer time for the QB.webrtc.onUserNotAnswerListener callback to be fired.
* The answer time interval shows how much time an opponent has to answer your call.
*/
answerTimeInterval?: number
/**
* If there is at least one active (recurring) call session and the autoReject is true,
* the call gets rejected.
*/
autoReject?: boolean
/**
* If the number of active (recurring) call sessions
* is more than it is defined by incomingLimit, the call gets rejected.
*/
incomingLimit?: number
/**
* The interval between call requests produced by the session.call() method.
* Dialing time interval indicates how often to notify your opponents about your call.
*/
dialingTimeInterval?: number
/**
* If an opponent has lost the connection then, after this time,
* the caller will know about it via the QB.webrtc.onSessionConnectionStateChangedListener callback.
*/
disconnectTimeInterval?: number
/**
* Allows access to the statistical information about peer connection state (connected, failed, disconnected, etc).
* Set the number of seconds for the statistical information to be received.
*/
statsReportTimeInterval?: boolean
/**
* You can customize a list of ICE servers. By default,
* WebRTC module will use internal ICE servers that are usually enough,
* but you can always set your own.
*/
iceServers?: ICEServer[]
}
/** Chat protocol configuration. */
chatProtocol?: {
/** Set 1 to use BOSH, set 2 to use WebSockets. Default: WebSocket. */
active: QBChatProtocol
}
/** [Stream management](https://docs.quickblox.com/docs/js-setup#section-stream-management) configuration. */
streamManagement?: {
enable: boolean
}
/** [Debug mode](https://docs.quickblox.com/docs/js-setup#enable-logging) configuration. */
debug?: boolean | { mode: 1 } | { mode: 2; file: string }
on?: {
sessionExpired?: (
response: any,
retry: (session: QBSession) => void,
) => void
}
pingTimeout?: number
pingLocalhostTimeInterval?: number
chatReconnectionTimeInterval?: number
}
export declare interface QBError {
code?: number
status?: string
detail?: string | string[] | Dictionary<string | string[]>
message: string | string[] | Dictionary<string | string[]>
}
interface QBCallback<T> {
(error: null | undefined, result: T): void
(error: QBError, result: null | undefined): void
}
export declare interface QBUserCreate
extends Partial<
Omit<
QBUser,
'id' | 'created_at' | 'updated_at' | 'last_request_at' | 'user_tags'
>
> {
/** User's password. */
password: string
/** User's tags. */
tag_list?: string | string[]
}
export declare type QBUserCreateByEmailParams = RequiredProps<
QBUserCreate,
'email'
>
export declare type QBUserCreateByPhoneParams = RequiredProps<
QBUserCreate,
'phone'
>
export declare type QBUserCreateByLoginParams = RequiredProps<
QBUserCreate,
'login'
>
export declare type QBUserCreateParams =
| QBUserCreateByEmailParams
| QBUserCreateByPhoneParams
| QBUserCreateByLoginParams
export declare interface QBUserUpdate
extends Partial<
Omit<
QBUser,
'id' | 'created_at' | 'updated_at' | 'last_request_at' | 'user_tags'
>
> {
/** User's new password. */
password?: string
/** User's old password. */
old_password?: string
/** User's tags. */
tag_list?: string | string[]
}
export declare interface ListUserResponse {
current_page: number
per_page: number
total_entries: number
items: Array<{ user: QBUser }>
}
export declare type ChatConnectParams =
| {
/** Connect to the chat by user id */
userId: QBUser['id']
/** The user's password or session token */
password: string
}
| {
/** Connect to the chat by user jid */
jid: string
/** The user's password or session token */
password: string
}
| {
/** Connect to the chat by user's email */
email: string
/** The user's password or session token */
password: string
}
export declare type QBCustomField =
| string
| string[]
| number
| number[]
| boolean
| boolean[]
| null
| undefined
export declare interface ChatMessageAttachment {
/** ID of the file on QuickBlox server. */
id: string | number
/** Type of attachment. Example: `audio`, `video`, `image` or other */
type: string
/** Link to a file in Internet. */
url?: string
/** UID of file from `QB.content.createAndUpload` */
uid?: string
/** Name of attachment. */
name?: string
/** Size of attachment. */
size?: number
[key: string]: QBCustomField
}
declare enum QBChatDialogType {
PUBLIC_GROUP = 1,
GROUP = 2,
PRIVATE = 3,
}
export declare interface QBChatDialog {
/** ID of the dialog. Generated automatically by the server after dialog creation. */
_id: string
/** ID of dialog's owner. */
user_id: QBUser['id']
/** Date & time when a record was created, filled automatically. */
created_at: string
/** Date & time when a record was created, filled automatically. */
updated_at: string
/**
* Type of dialog. Possible values are:
* - type=1 (`PUBLIC_GROUP`)
* - type=2 (`GROUP`)
* - type=3 (`PRIVATE`)
*/
type: QBChatDialogType
/**
* Name of a group chat. Makes sense if type=1 (`PUBLIC_GROUP`) or type=2 (`GROUP`).
* The maximum length for the dialog name is 200 symbols.
*/
name: string
/**
* Photo of a group chat. Makes sense if type=1 (`PUBLIC_GROUP`) or type=2 (`GROUP`).
* Can contain a link to a file in Content module, Custom Objects module or just a web link.
*/
photo: null | string
/**
* JID of XMPP room for group chat to connect. Nil if type=3 (PRIVATE).
* Generated automatically by the server after dialog creation.
*/
xmpp_room_jid: string | null
/** Array of users' IDs - dialog occupants. Does not make sense if type=1 (PUBLIC_GROUP). */
occupants_ids: number[]
/** Last sent message in this dialog. */
last_message: string | null
/** Timestamp of last sent message in this dialog. */
last_message_date_sent: number | null
/** ID of the user who sent last message in this dialog. */
last_message_user_id: QBUser['id'] | null
/** ID of last message in this dialog. */
last_message_id: string | null
/** Number of unread messages in this dialog for a current user. */
unread_messages_count: number | null
/**
* - Information about class and fields in Custom Objects.
* - Any dialog can be extended using Custom Objects to store additional parameters.
*/
data?: {
/** Class name in Custom Objects. */
class_name: string
/** Field name of class in Custom Objects. Can be many: 1..N. */
[field_name_N: string]: QBCustomField
}
}
export declare interface QBChatMessage {
/** ID of the message. Generated automatically by the server after message creation. */
_id: string
/** Date & time when a record was created, filled automatically. */
created_at: string
/** Date & time when a record was created, filled automatically. */
updated_at: string
/** ID of dialog to which current message is connected. Generated automatically by the server after message creation. */
chat_dialog_id: QBChatDialog['_id']
/** Message body. */
message: string | null
/** Message date sent. */
date_sent: number
/** Message sender ID. */
sender_id: QBUser['id']
/** Message recipient ID. */
recipient_id: QBUser['id'] | null
/**
* @deprecated
* Read message status. Diplayed as read=1 after retiriving by the opponent.
* Works only for type=3 (`PRIVATE`) dialog.
* Remains as read=0 after retiriving for type=2 (`GROUP`) and type=1 (`PUBLIC_GROUP`) dialogs.
* */
read: 0 | 1
/** Array of users' IDs who read messages. Works only for type=2 (GROUP) dialog. */
read_ids: Array<QBUser['id']>
/** Array of users' IDs who received the messages. */
delivered_ids: Array<QBUser['id']>
/**
* Each attachment object contains 3 required keys:
* - `id` - link to file ID in QuickBlox,
* - `type` - audio/video/image,
* - `url` - link to file in Internet.
*/
attachments: ChatMessageAttachment[]
/**
* Name of the custom field.
* Chat message can be extended with additional fields and contain any other user key-value custom parameters.
* Can be many 1..N.
*/
[custom_field_N: string]: any
}
export declare interface QBMessageStatusParams {
/** ID of the message. */
messageId: QBChatMessage['_id']
/** ID of the dialog. */
dialogId: QBChatDialog['_id']
/** ID of the user. */
userId: QBUser['id']
}
export declare interface QBChatNewMessage {
type: 'chat' | 'groupchat'
body?: string
extension: {
attachments?: ChatMessageAttachment[]
save_to_history: 0 | 1
dialog_id: QBChatDialog['_id']
[custom_field_N: string]: any
}
markable: 0 | 1
}
export declare interface QBChatXMPPMessage {
id: string
dialog_id: QBChatDialog['_id']
recipient_id: QBUser['id'] | null
type: 'chat' | 'groupchat'
body: string | null
delay: null
markable: 0 | 1
extension: {
dialog_id: QBChatDialog['_id']
message_id: QBChatMessage['_id']
date_sent: string
save_to_history: string
attachments?: ChatMessageAttachment[]
[custom_field_N: string]: string | ChatMessageAttachment[]
}
}
export declare interface QBSystemMessage {
id: string
userId: QBUser['id']
body?: null | string
extension?: Dictionary<any>
}
export declare interface QBGetDialogResult {
items: QBChatDialog[]
limit: number
skip: number
total_entries: number
}
export declare type GetMessagesResult = {
items: QBChatMessage[]
limit: number
skip: number
}
export class AIRole {
public static readonly user = "user";
public static readonly assistant = "assistant"
}
export interface AIChatMessage {
role: AIRole;
message: string;
}
export interface AIAnswerResponse {
answer: string;
}
export declare type AIChatHistory = AIChatMessage[] | null | undefined;
interface QBAIModule{
//QB.ai.answerAssist
answerAssist(smartChatAssistantId: string,
message: string,
history :AIChatHistory,
callback: QBCallback<AIAnswerResponse>): void
//QB.ai.translate
translate(smartChatAssistantId: string,
message: string,
languageCode: string,
callback: QBCallback<AIAnswerResponse>): void
}
interface QBChatModule {
isConnected: boolean
/**
* Connect to the Chat
* ([read more](https://docs.quickblox.com/docs/js-chat-connection#connect-to-chat-server-with-quickblox-session-token))
*/
connect(params: ChatConnectParams, callback: QBCallback<any>): void
reconnect(): void
/** Disconnect from the Chat ([read more](https://docs.quickblox.com/docs/js-chat-connection#disconnect-from-chat-server)). */
disconnect(): void
/**
* Send query to get last user activity by `QB.chat.onLastUserActivityListener(userId, seconds)`
* ([read more](https://xmpp.org/extensions/xep-0012.html)).
*/
getLastUserActivity(jidOrUserId: QBUser['id'] | string): void
/** Receive confirm request ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#confirm-the-contact-request)). */
onConfirmSubscribeListener?: (userId: QBUser['id']) => void
/** Receive user status (online/offline)([read more](https://docs.quickblox.com/docs/js-chat-contact-list#contact-list-updates)). */
onContactListListener?: (userId: QBUser['id'], type: string) => void
/** Receive delivery confirmations ([read more](https://docs.quickblox.com/docs/js-chat-messaging#mark-message-as-delivered)). */
onDeliveredStatusListener?: (
messageId: string,
dialogId: QBChatDialog['_id'],
userId: QBUser['id'],
) => void
/** Run after disconnect from chat. */
onDisconnectedListener?: () => void
/** You will receive this callback when some user joined group chat dialog you are in. */
onJoinOccupant?: (dialogId: QBChatDialog['_id'], userId: QBUser['id']) => void
/**
* You will receive this callback when you are in group chat dialog(joined)
* and other user (chat dialog's creator) removed you from occupants.
*/
onKickOccupant?: (
dialogId: QBChatDialog['_id'],
initiatorUserId: QBUser['id'],
) => void
/** Receive user's last activity (time ago). */
onLastUserActivityListener?: (userId: QBUser['id'], seconds: number) => void
/** You will receive this callback when some user left group chat dialog you are in. */
onLeaveOccupant?: (
dialogId: QBChatDialog['_id'],
userId: QBUser['id'],
) => void
/** Blocked entities receive an error when try to chat with a user in a 1-1 chat and receivie nothing in a group chat. */
onMessageErrorListener?: (messageId: QBChatMessage['_id'], error: any) => void
/**
* You need to set onMessageListener function, to get messages
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#subscribe-message-events)).
*/
onMessageListener?: (userId: QBUser['id'], message: QBChatXMPPMessage) => void
/**
* Show typing status in chat or groupchat
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#send-typing-indicators)).
*/
onMessageTypingListener?: (
isTyping: boolean,
userId: QBUser['id'],
dialogId: QBChatDialog['_id'],
) => void
/**
* You can manage 'read' notifications in chat
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#mark-message-as-read)).
*/
onReadStatusListener?: (
messageId: QBChatMessage['_id'],
dialogId: QBChatDialog['_id'],
userId: QBUser['id'],
) => void
/**
* By default Javascript SDK reconnects automatically when connection to server is lost
* ([read more](https://docs.quickblox.com/docs/js-chat-connection#reconnection)).
*/
onReconnectListener?: () => void
onReconnectFailedListener?: (error: any) => void
onSessionExpiredListener?: (error?: QBError) => void
onLogListener?: (logLine: string) => void
/**
* Receive reject request
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#reject-the-contact-request)).
*/
onRejectSubscribeListener?: (userId: QBUser['id']) => void
/**
* This feature defines an approach for ensuring is the message delivered to the server.
* This feature is unabled by default
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#check-if-a-message-is-sent)).
*/
onSentMessageCallback?: (
messageLost: QBChatMessage,
messageSent: QBChatMessage,
) => void
/**
* Receive subscription request
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#add-user-to-your-contact-list)).
*/
onSubscribeListener?: (userId: QBUser['id']) => void
/**
* These messages work over separated channel and won't be mixed with the regular chat messages
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#send-system-messages)).
*/
onSystemMessageListener?: (message: QBSystemMessage) => void
/**
* Send message to 1 to 1 or group dialog
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#send-text-message)).
*/
send<T extends QBChatNewMessage>(
jidOrUserId: QBUser['id'] | string,
message: T,
): string
/**
* Send is stop typing status
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#send-typing-indicators)).
*/
sendIsStopTypingStatus(jidOrUserId: QBUser['id'] | string): void
/**
* Send is typing status
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#send-typing-indicators)).
*/
sendIsTypingStatus(jidOrUserId: QBUser['id'] | string): void
/**
* Send is read status
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#mark-message-as-read)).
*/
sendReadStatus(params: QBMessageStatusParams): void
/**
* Send system message (system notification) to 1 to 1 or group dialog
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#send-system-messages)).
*/
sendSystemMessage(
jidOrUserId: QBUser['id'] | string,
// TODO: change type
message: { extension: QBSystemMessage['extension'] },
): string
/** Send is delivered status. */
sendDeliveredStatus(params: QBMessageStatusParams): void
ping(jidOrUserId: string | number, callback: QBCallback<any>): string
ping(callback: QBCallback<any>): string
pingchat(callback: QBCallback<any>): string
dialog: {
/**
* Create new dialog
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#create-dialog)).
*/
create(params: Dictionary<any>, callback: QBCallback<QBChatDialog>): void
/**
* Delete a dialog or dialogs
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#delete-dialog)).
*/
delete(
id: QBChatDialog['_id'] | Array<QBChatDialog['_id']>,
params: { force: 1 },
callback: QBCallback<any>,
)
/**
* Delete a dialog or dialogs
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#delete-dialog)).
*/
delete(
id: QBChatDialog['_id'] | Array<QBChatDialog['_id']>,
callback: QBCallback<any>,
)
/**
* Retrieve list of dialogs
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#retrieve-list-of-dialogs)).
*/
list(
params: {
limit?: number
skip?: number
sort_asc?: string
sort_desc?: string
[field: string]: any
},
callback: QBCallback<QBGetDialogResult>,
): void
/**
* Update group dialog
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#update-dialog)).
*/
update(
id: QBChatDialog['_id'],
data: Dictionary<any>,
callback: QBCallback<QBChatDialog>,
): void
}
message: {
/** Create message. */
create(params: Dictionary<any>, callback: QBCallback<QBChatMessage>): void
/**
* Delete message
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#delete-message)).
*/
delete(
id: QBChatMessage['_id'],
params: { force: 1 },
callback: QBCallback<{
SuccessfullyDeleted: {
ids: string[]
}
NotFound: {
ids: string[]
}
}>,
): void
/**
* Delete message
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#delete-message)).
*/
delete(
id: QBChatMessage['_id'],
callback: QBCallback<{
SuccessfullyDeleted: {
ids: string[]
}
NotFound: {
ids: string[]
}
}>,
): void
/**
* Get a chat history
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#retrieve-chat-history)).
*/
list(
params: {
limit?: number
skip?: number
sort_asc?: string
sort_desc?: string
mark_as_read?: number
[field: string]: any
},
callback: QBCallback<GetMessagesResult>,
): void
/**
* Get unread messages counter for one or group of dialogs
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#get-number-of-unread-messages)).
*/
unreadCount(
params: { chat_dialog_ids: string | string[] },
callback: QBCallback<{ total: number }>,
): void
/**
* Update message
* ([read more](https://docs.quickblox.com/docs/js-chat-messaging#update-message)).
*/
update(
id: QBChatMessage['_id'],
params: Dictionary<any>,
callback: QBCallback<QBChatMessage>,
): void
}
muc: {
/**
* Join to the group dialog
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#join-dialog)).
*/
join(dialogJid: string, callback: QBCallback<any>): void
/**
* Leave group chat dialog
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#leave-dialog)).
*/
leave(dialogJid: string, callback: QBCallback<any>): void
/**
* Leave group chat dialog
* ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#retrieve-online-users)).
*/
listOnlineUsers(dialogJid: string, callback: (userIds: Array<QBUser['id']>) => void): void
}
roster: {
/**
* Add users to contact list
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#add-user-to-your-contact-list)).
*/
add(jidOrUserId: string | QBUser['id'], callback: QBCallback<any>): void
/**
* Confirm subscription with some user
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#confirm-the-contact-request)).
*/
confirm(jidOrUserId: string | QBUser['id'], callback: QBCallback<any>): void
/**
* Receive contact list
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#access-contact-list)).
*/
get(callback: QBCallback<any>): void
/**
* Reject subscription with some user
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#reject-the-contact-request)).
*/
reject(jidOrUserId: string | QBUser['id'], callback: QBCallback<any>): void
/**
* Remove subscription with some user from your contact list
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#remove-user-from-the-contact-list)).
*/
remove(jidOrUserId: string | QBUser['id'], callback: QBCallback<any>): void
}
helpers: {
/** Get unique id. */
getUniqueId(suffix: string | number): string
/** Generate BSON ObjectId. */
getBsonObjectId(): string
/** Get the dialog id from jid. */
getDialogIdFromNode(jid: string): QBChatDialog['_id']
/** Get the User id from jid. */
getIdFromNode(jid: string): QBUser['id']
/** Get user id from dialog's full jid. */
getIdFromResource(jid: string): QBUser['id']
/** Get the recipient id. */
getRecipientId(
occupantsIds: Array<QBUser['id']>,
userId: QBUser['id'],
): QBUser['id']
/** Get the full room jid from room bare jid & user jid. */
getRoomJid(jid: string, userJid: string): string
/** Get the room jid from dialog id. */
getRoomJidFromDialogId(dialogId: QBChatDialog['_id']): string
/** Get bare dialog's jid from dialog's full jid. */
getRoomJidFromRoomFullJid(jid: string): string
/** Get the user id from the room jid. */
getUserIdFromRoomJid(jid: string): string
/** Get the User jid id. */
getUserJid(userId: QBUser['id'], appId?: string | number): string
/** Get the User nick with the muc domain. */
getUserNickWithMucDomain(userId: QBUser['id']): string
/** Get unique id. */
jidOrUserId(jidOrUserId: QBUser['id'] | string): string
/** Get the chat type. */
typeChat(jidOrUserId: QBUser['id'] | string): 'chat' | 'groupchat'
/** Get the dialog jid from dialog id. */
getDialogJid(dialogId: QBChatDialog['_id']): string
/** Get user jid from current user. */
getUserCurrentJid(): string
}
}
export declare interface QBDataFile {
content_type: string
file_id: string
name: string
size: number
}
export declare interface QBBlob {
id: number
uid: string
content_type: string
name: string
size: number
created_at: string
updated_at: string
blob_status: string
set_completed_at: number
public: boolean
}
export declare interface QBBlobCreate extends QBBlob {
account_id: number
app_id: number
blob_object_access: {
id: number
blob_id: number
expires: string
object_access_type: string
params: string
}
}
export declare interface QBBlobCreateUploadParams {
name: string
file: File
type: string
size: number
public?: boolean // optional, "false" by default
}
interface QBContentModule {
/** Create new file object. */
create(
params: { name: string; content_type: string; public?: boolean },
callback: QBCallback<QBBlobCreate>,
): void
/**
* Create file > upload file > mark file as uploaded > return result
* ([read more](https://docs.quickblox.com/docs/js-content#upload-file)).
*/
createAndUpload(
params: QBBlobCreateUploadParams,
callback: QBCallback<QBBlob>,
): void
/**
* Delete file by id
* ([read more](https://docs.quickblox.com/docs/js-content#delete-file)).
*/
delete(id: number, callback: QBCallback<any>): void
/**
* Download file by UID.
* If the file is public then it's possible to download it without a session token
* ([read more](https://docs.quickblox.com/docs/js-content#download-file-by-uid)).
*/
getFile(uid: string, callback: QBCallback<{ blob: QBBlob }>): void
/**
* Retrieve file object info by id
* ([read more](https://docs.quickblox.com/docs/js-content#get-file-info)).
*/
getInfo(id: number, callback: QBCallback<{ blob: QBBlob }>): void
/**
* Get a list of files for current user
* ([read more](https://docs.quickblox.com/docs/js-content#retrieve-files)).
*/
list(
params: { page?: number; per_page?: number },
callback: QBCallback<{
current_page: number
per_page: number
total_entries: number
items: Array<{
blob: QBBlob
}>
}>,
): void
/** Declare file uploaded. The file's 'status' field will be set to 'complete'. */
markUploaded(
params: { id: number; size: number },
callback: QBCallback<{ blob: { size: number } }>,
): void
/**
* Edit a file by ID
* ([read more](https://docs.quickblox.com/docs/js-content#update-file)).
*/
update(
params: {
id: QBBlob['id']
name?: QBBlob['name']
},
callback: QBCallback<{ blob: QBBlob }>,
): void
/** Upload a file to cloud storage. */
upload(
params: {
url: string
data: Dictionary<any>
},
callback: QBCallback<any>,
): void
/**
* Get private URL for file download by file_uid (blob_uid)
* ([read more](https://docs.quickblox.com/docs/js-content#get-private-url)).
*/
privateUrl(fileUID: string): string
/**
* Get public URL for file download by file_uid (blob_uid)
* ([read more](https://docs.quickblox.com/docs/js-content#get-public-url)).
*/
publicUrl(fileUID: string): string
}
export declare interface QBCustomObjectAccess {
access: 'open' | 'owner' | 'open_for_users_ids' | 'open_for_groups'
ids?: string[]
groups?: string[]
}
export declare interface QBCustomObjectPermissions {
create?: QBCustomObjectAccess
read?: QBCustomObjectAccess
update?: QBCustomObjectAccess
delete?: QBCustomObjectAccess
}
export declare interface QBCustomObject {
/**
* ID of the record
* Generated automatically by the server after record creation
*/
_id: string
/** ID of the user who created the record */
user_id: QBUser['id']
/** ID of parent object (Relations) */
_parent_id: string | null
/** Date & time when a record was created, filled automatically */
created_at: number
/** Date & time when record was updated, filled automatically */
updated_at: number
// permissions?: Required<QBCustomObjectPermissions>;
}
export declare interface QBDataDeletedResponse {
deleted: Array<QBCustomObject['_id']>
deletedCount: number
}
interface QBDataModule {
/**
* Create new custom object
* ([read more](https://docs.quickblox.com/docs/js-custom-objects#create-records)).
*/
create<T extends QBCustomObject>(
className: string,
data: { permissions?: QBCustomObjectPermissions } & Dictionary<any>,
callback: QBCallback<T>,
): void
/**
* Delete record/records by ID, IDs or criteria (filters) of particular class
* ([read more](https://docs.quickblox.com/docs/js-custom-objects#delete-records)).
*/
delete(
className: string,
ids: QBCustomObject['_id'] | Array<QBCustomObject['_id']>,
callback: QBCallback<QBDataDeletedResponse>,
): void
/**
* Delete record/records by ID, IDs or criteria (filters) of particular class
* ([read more](https://docs.quickblox.com/docs/js-custom-objects#delete-records)).
*/
delete(
className: string,
criteria: Dictionary<any>,
callback: QBCallback<{ total_deleted: number }>,
): void
/**
* Delete file from file field by ID
* ([read more](https://docs.quickblox.com/docs/js-custom-objects#delete-file)).
*/
deleteFile(
className: string,
params: { id: string; field_name: string },
callback: QBCallback<any>,
): void
/**
* Download file from file field by ID
* ([read more](https://docs.quickblox.com/docs/js-custom-objects#download-file)).
*/
downloadFile(
className: string,
params: { id: string; field_name: string },
callback: QBCallback<any>,
): void
/** Return file's URL from file field by ID. */
fileUrl(className: string, params: { id: string; field_name: string }): string
/**
* Search for records of particular class
* ([read more](https://docs.quickblox.com/docs/js-custom-objects#retrieve-records)).
*/
list<T extends QBCustomObject>(
className: string,