opensips-js-vue 0.1.41 → 0.1.43

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.
@@ -246,6 +246,8 @@ export declare const MSRP_EVT: {
246
246
  readonly MESSAGE: "m.conversation.message";
247
247
  readonly MEMBER: "m.conversation.member";
248
248
  readonly CLOSED: "m.conversation.closed";
249
+ readonly REOPEN: "m.conversation.reopen";
250
+ readonly DELETE: "m.conversation.delete";
249
251
  readonly SYNC: "m.sync";
250
252
  readonly UPLOAD_REQUEST: "m.upload.request";
251
253
  readonly UPLOAD_RESPONSE: "m.upload.response";
@@ -253,27 +255,48 @@ export declare const MSRP_EVT: {
253
255
  readonly FILE_ACCESS_RESPONSE: "m.file.access.response";
254
256
  readonly REACTION: "m.reaction";
255
257
  readonly TYPING: "m.typing";
258
+ readonly PRESENCE: "m.presence";
256
259
  readonly SENT: "m.sent";
257
260
  readonly DELIVERED: "m.delivered";
258
261
  readonly READ: "m.read";
262
+ readonly UNREAD: "m.unread";
259
263
  readonly FAILED: "m.failed";
260
264
  readonly SENDING: "m.sending";
261
265
  };
262
266
 
263
267
  declare type msrpConversationCreatedListener = (payload: {
264
- conversationKey: string
265
268
  conversation: MSRPConversationState_2
266
269
  }) => void
267
270
 
268
- declare type msrpConversationRemovedListener = (payload: { conversationKey: string }) => void
271
+ /**
272
+ * A conversation is addressed exclusively by its public numeric
273
+ * `conversation_id`. A stringified id is also accepted for convenience.
274
+ */
275
+ export declare type MSRPConversationRef = number | string;
276
+
277
+ declare type msrpConversationRemovedListener = (payload: {
278
+ conversation_id?: number
279
+ }) => void
269
280
 
270
281
  export declare interface MSRPConversationState {
271
- conversationKey: string
282
+ /**
283
+ * Public, stable numeric conversation identifier assigned by the backend.
284
+ * This is the only identifier exposed to application code — conversations
285
+ * are addressed exclusively by `conversation_id`.
286
+ */
287
+ conversation_id?: number
272
288
  creator: string | null
273
289
  members: Set<string>
274
290
  memberRoles: Map<string, MSRPMemberRole>
275
291
  currentUserRole: MSRPMemberRole
276
292
  currentUserStatus: MSRPMembership | null
293
+ /**
294
+ * Per-user read pointer (backend `last_read_message_id` in the current
295
+ * user's member state). `null` means the whole conversation is unread;
296
+ * an event_id means everything after that event is unread. Consumers
297
+ * derive the unread count from this pointer + the local timeline.
298
+ */
299
+ currentUserLastReadMessageId?: string | null
277
300
  state_events: { [key: string]: { [stateKey: string]: any } }
278
301
  created_at: number
279
302
  updated_at: number
@@ -281,12 +304,24 @@ export declare interface MSRPConversationState {
281
304
  }
282
305
 
283
306
  declare interface MSRPConversationState_2 {
284
- conversationKey: string
307
+ /**
308
+ * Public, stable numeric conversation identifier assigned by the backend.
309
+ * This is the only identifier exposed to application code — conversations
310
+ * are addressed exclusively by `conversation_id`.
311
+ */
312
+ conversation_id?: number
285
313
  creator: string | null
286
314
  members: Set<string>
287
315
  memberRoles: Map<string, MSRPMemberRole_2>
288
316
  currentUserRole: MSRPMemberRole_2
289
317
  currentUserStatus: MSRPMembership_2 | null
318
+ /**
319
+ * Per-user read pointer (backend `last_read_message_id` in the current
320
+ * user's member state). `null` means the whole conversation is unread;
321
+ * an event_id means everything after that event is unread. Consumers
322
+ * derive the unread count from this pointer + the local timeline.
323
+ */
324
+ currentUserLastReadMessageId?: string | null
290
325
  state_events: { [key: string]: { [stateKey: string]: any } }
291
326
  created_at: number
292
327
  updated_at: number
@@ -294,11 +329,11 @@ declare interface MSRPConversationState_2 {
294
329
  }
295
330
 
296
331
  declare type msrpConversationUpdatedListener = (payload: {
297
- conversationKey: string
332
+ conversation_id?: number
298
333
  patch: Partial<MSRPConversationState_2>
299
334
  }) => void
300
335
 
301
- declare type MSRPInitializingListener = (sessionId: string | undefined) => void
336
+ declare type MSRPInitializingListener = (value: boolean) => void
302
337
 
303
338
  export declare type MSRPMemberRole = 'in_charge' | 'manager' | 'assigned'
304
339
 
@@ -324,10 +359,25 @@ declare class MSRPMessage {
324
359
  }
325
360
 
326
361
  declare type msrpMessageAddedListener = (payload: {
327
- conversationKey: string
362
+ conversation_id?: number
328
363
  message: any
329
364
  }) => void
330
365
 
366
+ declare type msrpMessageDeletedListener = (payload: {
367
+ conversation_id?: number
368
+ eventId: string
369
+ deletedBy: string
370
+ updatedAt: number
371
+ }) => void
372
+
373
+ declare type msrpMessageEditedListener = (payload: {
374
+ conversation_id?: number
375
+ eventId: string
376
+ newContent: any
377
+ editEvent: any
378
+ updatedAt: number
379
+ }) => void
380
+
331
381
  export declare type MSRPMessageEventType = {
332
382
  message: MSRPMessage,
333
383
  session: MSRPSessionExtended_2
@@ -355,8 +405,28 @@ declare interface MSRPOptions_2 extends AnswerOptions {
355
405
  fromDisplayName?: string;
356
406
  }
357
407
 
408
+ declare type msrpPresenceListener = (payload: {
409
+ conversation_id?: number
410
+ sender: string
411
+ presence: string | null
412
+ lastActiveAt: number | null
413
+ updatedAt: number
414
+ }) => void
415
+
416
+ /**
417
+ * Presence pulse for a peer, indexed by SIP URI. Values are pushed from
418
+ * `msrpPresence` events and consumed by presence dots / "last seen" UI.
419
+ */
420
+ export declare interface MSRPPresenceState {
421
+ presence: string | null;
422
+ lastActiveAt: number | null;
423
+ updatedAt: number;
424
+ }
425
+
426
+ export declare type MSRPReactionAction = 'add' | 'remove';
427
+
358
428
  declare type msrpReactionChangedListener = (payload: {
359
- conversationKey: string
429
+ conversation_id?: number
360
430
  eventId: string
361
431
  emoji: string
362
432
  action: 'add' | 'remove'
@@ -365,12 +435,22 @@ declare type msrpReactionChangedListener = (payload: {
365
435
  }) => void
366
436
 
367
437
  declare type msrpReceiptChangedListener = (payload: {
368
- conversationKey: string
438
+ conversation_id?: number
369
439
  eventId: string
370
440
  status: MSRPMessageStatus_2
371
441
  updatedAt: number
372
442
  }) => void
373
443
 
444
+ /** Optional modifiers for an outgoing text/note message. */
445
+ export declare interface MSRPSendMessageOptions {
446
+ /** event_id of the message being replied to — becomes `content.in_reply_to`. */
447
+ replyToEventId?: string;
448
+ /** Overrides `content.message_type` (defaults to 'text'). */
449
+ messageType?: string;
450
+ /** Attribution label for a forwarded message — becomes `content.forwarded_from`. */
451
+ forwardedFrom?: string;
452
+ }
453
+
374
454
  declare class MSRPSession extends EventEmitter {
375
455
  _ua: UAExtendedInterface
376
456
  id: any
@@ -569,12 +649,17 @@ declare type msrpSyncCompletedListener = (payload: {
569
649
  }) => void
570
650
 
571
651
  declare type msrpTypingListener = (payload: {
572
- conversationKey: string
652
+ conversation_id?: number
573
653
  sender: string
574
654
  isTyping: boolean
575
655
  }) => void
576
656
 
577
- declare interface MSRPTypingState {
657
+ /**
658
+ * Transient typing indicator kept per-conversation. Not emitted by
659
+ * opensips-js; the wrapper composes it from `msrpTyping` events plus a
660
+ * `Date.now()` timestamp for UI decay.
661
+ */
662
+ export declare interface MSRPTypingState {
578
663
  sender: string;
579
664
  isTyping: boolean;
580
665
  updatedAt: number;
@@ -671,6 +756,9 @@ export declare interface OpenSIPSEventMap extends UAEventMap {
671
756
  msrpReceiptChanged: msrpReceiptChangedListener
672
757
  msrpReactionChanged: msrpReactionChangedListener
673
758
  msrpTyping: msrpTypingListener
759
+ msrpMessageEdited: msrpMessageEditedListener
760
+ msrpMessageDeleted: msrpMessageDeletedListener
761
+ msrpPresence: msrpPresenceListener
674
762
  // JANUS
675
763
  conferenceStart: conferenceStartListener
676
764
  conferenceEnd: conferenceEndListener
@@ -831,9 +919,12 @@ declare interface UAExtendedInterface_2 extends UA {
831
919
  stop (): void
832
920
  }
833
921
 
834
- declare type UnreadCounts = {
835
- [conversationKey: string]: number;
836
- };
922
+ /**
923
+ * Per-conversation unread count derived from
924
+ * `MSRPConversationState.currentUserLastReadMessageId` + local timeline.
925
+ * Only conversations with count > 0 appear in the map.
926
+ */
927
+ export declare type UnreadCounts = Record<string, number>;
837
928
 
838
929
  declare type updateRoomListener = (value: RoomChangeEmitType) => void
839
930
 
@@ -901,22 +992,68 @@ declare interface VsipAPIActions {
901
992
  sendMSRP: (msrpSessionId: string, body: string) => void
902
993
  safeSendMSRP: (body: string) => boolean
903
994
  sendCreateConversationMessage: (targetSip: string | string[]) => boolean
904
- sendTextMessage: (conversationKey: string, text: string) => boolean
905
- sendMediaMessage: (conversationKey: string, uploadResult: MSRPUploadResult, caption?: string) => boolean
906
- sendReaction: (conversationKey: string, targetEventId: string, emoji: string) => boolean
907
- sendTypingIndicator: (conversationKey: string, isTyping: boolean) => boolean
908
- startTypingKeepAlive: (conversationKey: string) => void
909
- stopTypingKeepAlive: (sendStop?: boolean) => void
910
- sendReadReceipt: (conversationKey: string) => boolean
911
- closeConversation: (conversationKey: string, reason?: string, cause?: string) => boolean
912
- changeMemberRole: (conversationKey: string, targetUri: string, newRole: MSRPMemberRole) => boolean
913
- acceptInvite: (conversationKey: string) => boolean
914
- rejectInvite: (conversationKey: string) => boolean
915
- leaveConversation: (conversationKey: string) => boolean
916
- setActiveConversation: (conversationKey: string | null) => void
917
- requestUploadUrl: (conversationKey: string, filename: string, mimeType: string, fileSize: number) => Promise<MSRPUploadResult>
918
- requestFileAccess: (conversationKey: string, eventId: string) => Promise<unknown>
919
- uploadFile: (conversationKey: string, file: File, caption?: string) => Promise<MSRPUploadResult>
995
+ sendTextMessage: (
996
+ conversationRef: MSRPConversationRef,
997
+ text: string,
998
+ options?: MSRPSendMessageOptions
999
+ ) => boolean
1000
+ sendInternalNote: (
1001
+ conversationRef: MSRPConversationRef,
1002
+ text: string,
1003
+ options?: Omit<MSRPSendMessageOptions, 'messageType'>
1004
+ ) => boolean
1005
+ editMessage: (conversationRef: MSRPConversationRef, targetEventId: string, newText: string) => boolean
1006
+ deleteMessage: (conversationRef: MSRPConversationRef, targetEventId: string) => boolean
1007
+ forwardMessage: (
1008
+ sourceMessage: any,
1009
+ targetConversationRef: MSRPConversationRef,
1010
+ forwardedFromLabel?: string
1011
+ ) => boolean
1012
+ sendMediaMessage: (
1013
+ conversationRef: MSRPConversationRef,
1014
+ uploadResult: MSRPUploadResult,
1015
+ caption?: string
1016
+ ) => boolean
1017
+ sendReaction: (
1018
+ conversationRef: MSRPConversationRef,
1019
+ targetEventId: string,
1020
+ emoji: string,
1021
+ action?: MSRPReactionAction
1022
+ ) => boolean
1023
+ removeReaction: (conversationRef: MSRPConversationRef, targetEventId: string, emoji: string) => boolean
1024
+ sendTypingIndicator: (conversationRef: MSRPConversationRef) => boolean
1025
+ startTypingKeepAlive: (conversationRef: MSRPConversationRef) => void
1026
+ stopTypingKeepAlive: () => void
1027
+ /**
1028
+ * Mark the whole conversation as unread (server-side pointer → null).
1029
+ * Optimistically applies the pointer locally so the UI reflects the
1030
+ * change without waiting for a backend echo.
1031
+ */
1032
+ markConversationAsUnread: (conversationRef: MSRPConversationRef) => boolean
1033
+ /**
1034
+ * Mark `targetEventId` and every later message as unread. The pointer
1035
+ * is moved to the message immediately preceding `targetEventId` in the
1036
+ * local timeline; if the target is the very first message the pointer
1037
+ * becomes null (whole conversation unread).
1038
+ */
1039
+ markAsUnreadFromMessage: (
1040
+ conversationRef: MSRPConversationRef,
1041
+ targetEventId: string
1042
+ ) => boolean
1043
+ closeConversation: (conversationRef: MSRPConversationRef, reason?: string, cause?: string) => boolean
1044
+ changeMemberRole: (conversationRef: MSRPConversationRef, targetUri: string, newRole: MSRPMemberRole) => boolean
1045
+ acceptInvite: (conversationRef: MSRPConversationRef) => boolean
1046
+ rejectInvite: (conversationRef: MSRPConversationRef) => boolean
1047
+ leaveConversation: (conversationRef: MSRPConversationRef) => boolean
1048
+ setActiveConversation: (conversationId: string | null) => void
1049
+ requestUploadUrl: (
1050
+ conversationRef: MSRPConversationRef,
1051
+ filename: string,
1052
+ mimeType: string,
1053
+ fileSize: number
1054
+ ) => Promise<MSRPUploadResult>
1055
+ requestFileAccess: (conversationRef: MSRPConversationRef, eventId: string) => Promise<unknown>
1056
+ uploadFile: (conversationRef: MSRPConversationRef, file: File, caption?: string) => Promise<MSRPUploadResult>
920
1057
  }
921
1058
 
922
1059
  declare interface VsipAPIState {
@@ -952,16 +1089,28 @@ declare interface VsipAPIState {
952
1089
  isMSRPInitializing: Ref<boolean>
953
1090
  hasActiveMsrpSession: ComputedRef<boolean>
954
1091
  // ---------- MSRP conversation state ----------
955
- // Metadata and chat history are kept as two parallel maps so that
956
- // message activity doesn't invalidate metadata-only consumers.
957
- conversations: Ref<{ [conversationKey: string]: MSRPConversationState }>
958
- messagesByConversation: Ref<{ [conversationKey: string]: any[] }>
959
- currentConversationKey: Ref<string | null>
1092
+ // Conversations are keyed by their public numeric `conversation_id`
1093
+ // stringified. Metadata and chat history are kept as two parallel maps
1094
+ // so that message activity doesn't invalidate metadata-only consumers.
1095
+ conversations: Ref<{ [conversationId: string]: MSRPConversationState }>
1096
+ messagesByConversation: Ref<{ [conversationId: string]: any[] }>
1097
+ currentConversationId: Ref<string | null>
960
1098
  currentConversation: ComputedRef<MSRPConversationState | null>
961
1099
  currentMessages: ComputedRef<any[]>
962
1100
  sortedConversations: ComputedRef<MSRPConversationState[]>
963
- typingByConversation: Ref<{ [conversationKey: string]: MSRPTypingState }>
964
- unreadByConversation: Ref<UnreadCounts>
1101
+ typingByConversation: Ref<{ [conversationId: string]: MSRPTypingState }>
1102
+ presenceBySender: Ref<{ [sender: string]: MSRPPresenceState }>
1103
+ /**
1104
+ * Per-conversation unread count derived from
1105
+ * `MSRPConversationState.currentUserLastReadMessageId` + local timeline.
1106
+ * Only conversations with count > 0 appear in the map.
1107
+ */
1108
+ unreadByConversation: ComputedRef<UnreadCounts>
1109
+ /**
1110
+ * event_id of the first unread message per conversation. Consumers use
1111
+ * this to place a "— New messages —" divider inside the open chat.
1112
+ */
1113
+ firstUnreadByConversation: ComputedRef<Record<string, string>>
965
1114
  }
966
1115
 
967
1116
  export declare interface WebrtcMetricsConfigType {