@twilio/conversations 2.1.0-rc.9 → 3.0.0-canary.9
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 +7 -3
- package/builds/browser.js +2707 -1986
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +513 -305
- package/builds/lib.js +2707 -1986
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +5232 -5070
- package/builds/twilio-conversations.min.js +1 -16
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/client.js +417 -283
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +2 -2
- package/dist/configuration.js.map +1 -1
- package/dist/conversation.js +407 -374
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +10 -11
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +46 -26
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +19 -10
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +2 -2
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/interfaces/attributes.js.map +1 -1
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/logger.js +2 -4
- package/dist/logger.js.map +1 -1
- package/dist/media.js +36 -25
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +24 -18
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +53 -26
- package/dist/message.js.map +1 -1
- package/dist/node_modules/tslib/tslib.es6.js +1 -1
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +2 -2
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +1 -1
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +13 -3
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +1 -1
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/package.json +22 -18
- package/CHANGELOG.md +0 -412
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
- package/docs/classes/Client.html +0 -4073
- package/docs/classes/Conversation.html +0 -4325
- package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
- package/docs/classes/Media.html +0 -3193
- package/docs/classes/Message.html +0 -3677
- package/docs/classes/MessageBuilder.html +0 -3254
- package/docs/classes/Participant.html +0 -3444
- package/docs/classes/PushNotification.html +0 -3130
- package/docs/classes/RestPaginator.html +0 -3160
- package/docs/classes/UnsentMessage.html +0 -3042
- package/docs/classes/User.html +0 -3349
- package/docs/index.html +0 -3512
- package/docs/interfaces/ClientOptions.html +0 -3034
- package/docs/interfaces/ConversationBindings.html +0 -3001
- package/docs/interfaces/ConversationEmailBinding.html +0 -3001
- package/docs/interfaces/ConversationLimits.html +0 -3098
- package/docs/interfaces/ConversationState.html +0 -3050
- package/docs/interfaces/CreateConversationOptions.html +0 -3066
- package/docs/interfaces/LastMessage.html +0 -3050
- package/docs/interfaces/Paginator.html +0 -3141
- package/docs/interfaces/ParticipantBindings.html +0 -3001
- package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
- package/docs/interfaces/PushNotificationData.html +0 -3066
- package/docs/interfaces/SendEmailOptions.html +0 -3034
- package/docs/interfaces/SendMediaOptions.html +0 -3068
- package/docs/modules.html +0 -3513
package/dist/conversation.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"conversation.js","sources":["../src/conversation.ts"],"sourcesContent":["import { Logger } from \"./logger\";\n\nimport { ParticipantBindingOptions, Participants } from \"./data/participants\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"./participant\";\nimport { Messages } from \"./data/messages\";\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"./message\";\n\nimport { UriBuilder, parseToNumber } from \"./util\";\nimport { Users } from \"./data/users\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { ConversationsDataSource } from \"./data/conversations\";\nimport { McsClient } from \"@twilio/mcs-client\";\n\nimport { SyncClient, SyncDocument } from \"twilio-sync\";\nimport { TypingIndicator } from \"./services/typing-indicator\";\nimport { Network } from \"./services/network\";\nimport {\n validateTypesAsync,\n custom,\n literal,\n nonEmptyString,\n nonNegativeInteger,\n objectSchema,\n} from \"@twilio/declarative-type-validator\";\nimport {\n attributesValidator,\n optionalAttributesValidator,\n} from \"./interfaces/attributes\";\nimport { Configuration } from \"./configuration\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { AddParticipantRequest } from \"./interfaces/commands/add-participant\";\nimport { EditConversationRequest } from \"./interfaces/commands/edit-conversation\";\nimport { ConversationResponse } from \"./interfaces/commands/conversation-response\";\nimport { ParticipantResponse } from \"./interfaces/commands/participant-response\";\nimport { EditNotificationLevelRequest } from \"./interfaces/commands/edit-notification-level\";\nimport {\n EditLastReadMessageIndexRequest,\n EditLastReadMessageIndexResponse,\n} from \"./interfaces/commands/edit-last-read-message-index\";\nimport { ConversationLimits } from \"./interfaces/conversation-limits\";\nimport { MessageBuilder } from \"./message-builder\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"./types\";\n\ntype ConversationEvents = {\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n updated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n removed: (conversation: Conversation) => void;\n};\n\nconst log = Logger.scope(\"Conversation\");\n\nconst fieldMappings = {\n lastMessage: \"lastMessage\",\n attributes: \"attributes\",\n createdBy: \"createdBy\",\n dateCreated: \"dateCreated\",\n dateUpdated: \"dateUpdated\",\n friendlyName: \"friendlyName\",\n lastConsumedMessageIndex: \"lastConsumedMessageIndex\",\n notificationLevel: \"notificationLevel\",\n sid: \"sid\",\n status: \"status\",\n uniqueName: \"uniqueName\",\n state: \"state\",\n bindings: \"bindings\",\n};\n\nfunction parseTime(timeString) {\n try {\n return new Date(timeString);\n } catch (e) {\n return null;\n }\n}\n\nexport interface ConversationServices {\n users: Users;\n typingIndicator: TypingIndicator;\n network: Network;\n mcsClient: McsClient;\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n}\n\ninterface ConversationInternalState {\n uniqueName: string | null;\n status: ConversationStatus;\n attributes: JSONValue;\n createdBy?: string;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n friendlyName: string | null;\n lastReadMessageIndex: number | null;\n lastMessage?: LastMessage;\n notificationLevel?: NotificationLevel;\n state?: ConversationState;\n bindings: ConversationBindings;\n}\n\ninterface ConversationDescriptor {\n channel: string;\n entityName: string;\n uniqueName: string;\n attributes: JSONValue;\n createdBy?: string;\n friendlyName?: string;\n lastConsumedMessageIndex: number;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n notificationLevel?: NotificationLevel;\n bindings?: ConversationBindings;\n}\n\ninterface ConversationLinks {\n self: string;\n messages: string;\n participants: string;\n}\n\n/**\n * The reason for the `updated` event being emitted by a conversation.\n */\ntype ConversationUpdateReason =\n | \"attributes\"\n | \"createdBy\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"friendlyName\"\n | \"lastReadMessageIndex\"\n | \"state\"\n | \"status\"\n | \"uniqueName\"\n | \"lastMessage\"\n | \"notificationLevel\"\n | \"bindings\";\n\n/**\n * The status of the conversation, relative to the client: whether\n * the conversation has been `joined` or the client is\n * `notParticipating` in the conversation.\n */\ntype ConversationStatus = \"notParticipating\" | \"joined\";\n\n/**\n * The user's notification level for the conversation. Determines\n * whether the currently logged-in user will receive pushes for events\n * in this conversation. Can be either `muted` or `default`, where\n * `default` defers to the global service push configuration.\n */\ntype NotificationLevel = \"default\" | \"muted\";\n\n/**\n * The state of the conversation.\n */\ninterface ConversationState {\n /**\n * The current state.\n */\n current: \"active\" | \"inactive\" | \"closed\";\n\n /**\n * Date at which the latest conversation state update happened.\n */\n dateUpdated: Date;\n}\n\ninterface ConversationUpdatedEventArgs {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n}\n\n/**\n * Binding for email conversation.\n */\ninterface ConversationBindings {\n email?: ConversationEmailBinding;\n sms?: ConversationSmsBinding;\n}\n\n/**\n * Binding for email conversation.\n */\ninterface ConversationEmailBinding {\n name?: string;\n projected_address: string;\n}\n\ninterface ConversationSmsBinding {\n address?: string;\n}\n\n/**\n * Configuration for attaching a media file to a message.\n * These options can be passed to {@link Conversation.sendMessage} and\n * {@link MessageBuilder.addMedia}.\n */\ninterface SendMediaOptions {\n /**\n * Content type of media.\n */\n contentType: null | string;\n\n /**\n * Optional filename.\n */\n filename?: string;\n\n /**\n * Content to post.\n */\n media: null | string | Buffer | Blob;\n}\n\n/**\n * These options can be passed to {@link Conversation.sendMessage}.\n */\ninterface SendEmailOptions {\n /**\n * Message subject. Ignored for media messages.\n */\n subject?: string;\n}\n\n/**\n * Information about the last message of a conversation.\n */\ninterface LastMessage {\n /**\n * Message's index.\n */\n index?: number;\n\n /**\n * Message's creation date.\n */\n dateCreated?: Date;\n}\n\n/**\n * A conversation represents communication between multiple Conversations clients\n */\nclass Conversation extends ReplayEventEmitter<ConversationEvents> {\n /**\n * Unique system identifier of the conversation.\n */\n public readonly sid: string;\n public readonly links: ConversationLinks;\n\n private readonly configuration: Configuration;\n private readonly services: ConversationServices;\n private channelState: ConversationInternalState;\n private statusSource!: ConversationsDataSource;\n\n private entityPromise!: Promise<void | SyncDocument> | null;\n private entityName: string;\n private entity!: SyncDocument | null;\n private messagesEntity: Messages;\n private participantsEntity: Participants;\n private readonly participants: Map<string, Participant>;\n\n /**\n * @internal\n */\n constructor(\n descriptor: ConversationDescriptor,\n sid: string,\n links: ConversationLinks,\n configuration: Configuration,\n services: ConversationServices\n ) {\n super();\n\n this.sid = sid;\n this.links = links;\n this.configuration = configuration;\n this.services = services;\n\n const attributes = descriptor.attributes || {};\n const createdBy = descriptor.createdBy;\n const dateCreated = parseTime(descriptor.dateCreated);\n const dateUpdated = parseTime(descriptor.dateUpdated);\n const friendlyName = descriptor.friendlyName || null;\n const lastReadMessageIndex = Number.isInteger(\n descriptor.lastConsumedMessageIndex\n )\n ? descriptor.lastConsumedMessageIndex\n : null;\n const uniqueName = descriptor.uniqueName || null;\n\n try {\n JSON.stringify(attributes);\n } catch (e) {\n throw new Error(\"Attributes must be a valid JSON object.\");\n }\n\n this.entityName = descriptor.channel;\n this.channelState = {\n uniqueName,\n status: \"notParticipating\",\n attributes,\n createdBy,\n dateCreated,\n dateUpdated,\n friendlyName,\n lastReadMessageIndex,\n bindings: descriptor.bindings ?? {},\n };\n\n if (descriptor.notificationLevel) {\n this.channelState.notificationLevel = descriptor.notificationLevel;\n }\n\n const participantsLinks = {\n participants: this.links.participants,\n };\n\n this.participants = new Map();\n this.participantsEntity = new Participants(\n this,\n this.participants,\n participantsLinks,\n this.configuration,\n this.services\n );\n this.participantsEntity.on(\"participantJoined\", (participant) =>\n this.emit(\"participantJoined\", participant)\n );\n this.participantsEntity.on(\"participantLeft\", (participant) =>\n this.emit(\"participantLeft\", participant)\n );\n this.participantsEntity.on(\n \"participantUpdated\",\n (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n\n this.messagesEntity = new Messages(this, configuration, services);\n this.messagesEntity.on(\"messageAdded\", (message) =>\n this._onMessageAdded(message)\n );\n this.messagesEntity.on(\"messageUpdated\", (args: MessageUpdatedEventArgs) =>\n this.emit(\"messageUpdated\", args)\n );\n this.messagesEntity.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n }\n\n /**\n * Fired when a participant has joined the conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - participant that joined the conversation\n * @event\n */\n static readonly participantJoined = \"participantJoined\";\n\n /**\n * Fired when a participant has left the conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - participant that left the conversation\n * @event\n */\n static readonly participantLeft = \"participantLeft\";\n\n /**\n * Fired when data of a participant has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Participant} `participant` - participant that has received the update\n * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for update\n * @event\n */\n static readonly participantUpdated = \"participantUpdated\";\n\n /**\n * Fired when a new message has been added to the conversation.\n *\n * Parameters:\n * 1. {@link Message} `message` - message that has been added\n * @event\n */\n static readonly messageAdded = \"messageAdded\";\n\n /**\n * Fired when message is removed from the conversation's message list.\n *\n * Parameters:\n * 1. {@link Message} `message` - message that has been removed\n * @event\n */\n static readonly messageRemoved = \"messageRemoved\";\n\n /**\n * Fired when data of a message has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Message} `message` - message that has received the update\n * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for update\n * @event\n */\n static readonly messageUpdated = \"messageUpdated\";\n\n /**\n * Fired when a participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant that has stopped typing\n * @event\n */\n static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when a participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant that has started typing\n * @event\n */\n static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the data of the conversation has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Conversation} `conversation` - conversation that has received the update\n * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for update\n * @event\n */\n static readonly updated = \"updated\";\n\n /**\n * Fired when the conversation was destroyed or the currently-logged-in user has left private conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - conversation that has been removed\n * @event\n */\n static readonly removed = \"removed\";\n\n /**\n * Unique name of the conversation.\n */\n public get uniqueName(): string | null {\n return this.channelState.uniqueName;\n }\n\n /**\n * Status of the conversation.\n */\n public get status(): ConversationStatus {\n return this.channelState.status;\n }\n\n /**\n * Name of the conversation.\n */\n public get friendlyName(): string | null {\n return this.channelState.friendlyName;\n }\n\n /**\n * Date this conversation was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this.channelState.dateUpdated;\n }\n\n /**\n * Date this conversation was created on.\n */\n public get dateCreated(): Date | null {\n return this.channelState.dateCreated;\n }\n\n /**\n * Identity of the user that created this conversation.\n */\n public get createdBy(): string {\n return this.channelState.createdBy ?? \"\";\n }\n\n /**\n * Custom attributes of the conversation.\n */\n public get attributes(): JSONValue {\n return this.channelState.attributes;\n }\n\n /**\n * Index of the last message the user has read in this conversation.\n */\n public get lastReadMessageIndex(): number | null {\n return this.channelState.lastReadMessageIndex;\n }\n\n /**\n * Last message sent to this conversation.\n */\n public get lastMessage(): LastMessage | undefined {\n return this.channelState.lastMessage ?? undefined;\n }\n\n /**\n * User notification level for this conversation.\n */\n public get notificationLevel(): NotificationLevel {\n return this.channelState.notificationLevel ?? \"default\";\n }\n\n public get bindings(): ConversationBindings {\n return this.channelState.bindings;\n }\n\n /**\n * Current conversation limits.\n */\n public get limits(): ConversationLimits {\n return this.configuration.limits;\n }\n\n /**\n * State of the conversation.\n */\n public get state(): ConversationState | undefined {\n return this.channelState.state;\n }\n\n /**\n * Load and subscribe to this conversation and do not subscribe to its participants and messages.\n * This or _subscribeStreams will need to be called before any events on conversation will fire.\n * @internal\n */\n _subscribe() {\n return (this.entityPromise =\n this.entityPromise ??\n this.services.syncClient\n .document({ id: this.entityName, mode: \"open_existing\" })\n .then((entity) => {\n this.entity = entity;\n this.entity.on(\"updated\", (args) => {\n this._update(args.data);\n });\n this.entity.on(\"removed\", () => this.emit(\"removed\", this));\n this._update(this.entity.data);\n return entity;\n })\n .catch((err) => {\n this.entity = null;\n this.entityPromise = null;\n if (this.services.syncClient.connectionState != \"disconnected\") {\n log.error(\"Failed to get conversation object\", err);\n }\n log.debug(\"ERROR: Failed to get conversation object\", err);\n throw err;\n }));\n }\n\n /**\n * Load the attributes of this conversation and instantiate its participants and messages.\n * This or _subscribe will need to be called before any events on the conversation will fire.\n * This will need to be called before any events on participants or messages will fire\n * @internal\n */\n async _subscribeStreams() {\n try {\n await this._subscribe();\n log.trace(\"_subscribeStreams, this.entity.data=\", this.entity?.data);\n const messagesObjectName = (this.entity?.data as Record<string, string>)\n .messages;\n const rosterObjectName = (this.entity?.data as Record<string, string>)\n .roster;\n await Promise.all([\n this.messagesEntity.subscribe(messagesObjectName),\n this.participantsEntity.subscribe(rosterObjectName),\n ]);\n } catch (err) {\n if (this.services.syncClient.connectionState !== \"disconnected\") {\n log.error(\"Failed to subscribe on conversation objects\", this.sid, err);\n }\n log.debug(\n \"ERROR: Failed to subscribe on conversation objects\",\n this.sid,\n err\n );\n throw err;\n }\n }\n\n /**\n * Stop listening for and firing events on this conversation.\n * @internal\n */\n async _unsubscribe() {\n if (this.entity) {\n await this.entity.close();\n this.entity = null;\n this.entityPromise = null;\n }\n\n return Promise.all([\n this.participantsEntity.unsubscribe(),\n this.messagesEntity.unsubscribe(),\n ]);\n }\n\n /**\n * Set conversation status.\n * @internal\n */\n _setStatus(status: ConversationStatus, source: ConversationsDataSource) {\n this.statusSource = source;\n\n if (this.channelState.status === status) {\n return;\n }\n\n this.channelState.status = status;\n\n if (status === \"joined\") {\n this._subscribeStreams().catch((err) => {\n log.debug(\"ERROR while setting conversation status \" + status, err);\n if (this.services.syncClient.connectionState !== \"disconnected\") {\n throw err;\n }\n });\n } else if (this.entityPromise) {\n this._unsubscribe().catch((err) => {\n log.debug(\"ERROR while setting conversation status \" + status, err);\n if (this.services.syncClient.connectionState !== \"disconnected\") {\n throw err;\n }\n });\n }\n }\n\n /**\n * Get the source of the conversation update.\n * @internal\n */\n _statusSource(): ConversationsDataSource {\n return this.statusSource;\n }\n\n private static preprocessUpdate(update, conversationSid) {\n try {\n if (typeof update.attributes === \"string\") {\n update.attributes = JSON.parse(update.attributes);\n } else if (update.attributes) {\n JSON.stringify(update.attributes);\n }\n } catch (e) {\n log.warn(\n \"Retrieved malformed attributes from the server for conversation: \" +\n conversationSid\n );\n update.attributes = {};\n }\n\n try {\n if (update.dateCreated) {\n update.dateCreated = new Date(update.dateCreated);\n }\n } catch (e) {\n log.warn(\n \"Retrieved malformed dateCreated from the server for conversation: \" +\n conversationSid\n );\n delete update.dateCreated;\n }\n\n try {\n if (update.dateUpdated) {\n update.dateUpdated = new Date(update.dateUpdated);\n }\n } catch (e) {\n log.warn(\n \"Retrieved malformed dateUpdated from the server for conversation: \" +\n conversationSid\n );\n delete update.dateUpdated;\n }\n\n try {\n if (update.lastMessage && update.lastMessage.timestamp) {\n update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);\n }\n } catch (e) {\n log.warn(\n \"Retrieved malformed lastMessage.timestamp from the server for conversation: \" +\n conversationSid\n );\n delete update.lastMessage.timestamp;\n }\n }\n\n /**\n * Update the local conversation object with new values.\n * @internal\n */\n _update(update) {\n log.trace(\"_update\", update);\n\n Conversation.preprocessUpdate(update, this.sid);\n const updateReasons = new Set<ConversationUpdateReason>();\n\n for (const key of Object.keys(update)) {\n const localKey = fieldMappings[key];\n\n if (!localKey) {\n continue;\n }\n\n switch (localKey) {\n case fieldMappings.status:\n if (\n !update.status ||\n update.status === \"unknown\" ||\n this.channelState.status === update.status\n ) {\n break;\n }\n\n this.channelState.status = update.status;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.attributes:\n if (isEqual(this.channelState.attributes, update.attributes)) {\n break;\n }\n\n this.channelState.attributes = update.attributes;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.lastConsumedMessageIndex:\n if (\n update.lastConsumedMessageIndex === undefined ||\n update.lastConsumedMessageIndex ===\n this.channelState.lastReadMessageIndex\n ) {\n break;\n }\n\n this.channelState.lastReadMessageIndex =\n update.lastConsumedMessageIndex;\n updateReasons.add(\"lastReadMessageIndex\");\n\n break;\n case fieldMappings.lastMessage:\n if (this.channelState.lastMessage && !update.lastMessage) {\n delete this.channelState.lastMessage;\n updateReasons.add(localKey);\n\n break;\n }\n\n this.channelState.lastMessage = this.channelState.lastMessage || {};\n\n if (\n update.lastMessage?.index !== undefined &&\n update.lastMessage.index !== this.channelState.lastMessage.index\n ) {\n this.channelState.lastMessage.index = update.lastMessage.index;\n updateReasons.add(localKey);\n }\n\n if (\n update.lastMessage?.timestamp !== undefined &&\n this.channelState.lastMessage?.dateCreated?.getTime() !==\n update.lastMessage.timestamp.getTime()\n ) {\n this.channelState.lastMessage.dateCreated =\n update.lastMessage.timestamp;\n updateReasons.add(localKey);\n }\n\n if (isEqual(this.channelState.lastMessage, {})) {\n delete this.channelState.lastMessage;\n }\n\n break;\n case fieldMappings.state:\n const state = update.state || undefined;\n\n if (state !== undefined) {\n state.dateUpdated = new Date(state.dateUpdated);\n }\n\n if (isEqual(this.channelState.state, state)) {\n break;\n }\n\n this.channelState.state = state;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.bindings:\n if (isEqual(this.channelState.bindings, update.bindings)) {\n break;\n }\n\n this.channelState.bindings = update.bindings;\n updateReasons.add(localKey);\n\n break;\n default:\n const isDate = update[key] instanceof Date;\n const keysMatchAsDates =\n isDate &&\n this.channelState[localKey]?.getTime() === update[key].getTime();\n const keysMatchAsNonDates = !isDate && this[localKey] === update[key];\n\n if (keysMatchAsDates || keysMatchAsNonDates) {\n break;\n }\n\n this.channelState[localKey] = update[key];\n updateReasons.add(localKey);\n }\n }\n\n if (updateReasons.size > 0) {\n this.emit(\"updated\", {\n conversation: this,\n updateReasons: [...updateReasons],\n });\n }\n }\n\n /**\n * @internal\n */\n private _onMessageAdded(message) {\n for (const participant of this.participants.values()) {\n if (participant.identity === message.author) {\n participant._endTyping();\n break;\n }\n }\n this.emit(\"messageAdded\", message);\n }\n\n private async _setLastReadMessageIndex(\n index: number | null\n ): Promise<number> {\n const result = await this.services.commandExecutor.mutateResource<\n EditLastReadMessageIndexRequest,\n EditLastReadMessageIndexResponse\n >(\"post\", `${this.configuration.links.myConversations}/${this.sid}`, {\n last_read_message_index: index,\n });\n\n return result.unread_messages_count;\n }\n\n /**\n * Add a participant to the conversation by its identity.\n * @param identity Identity of the Client to add.\n * @param attributes Attributes to be attached to the participant.\n */\n @validateTypesAsync(nonEmptyString, optionalAttributesValidator)\n async add(\n identity: string,\n attributes?: JSONValue\n ): Promise<ParticipantResponse> {\n return this.participantsEntity.add(identity, attributes ?? {});\n }\n\n /**\n * Add a non-chat participant to the conversation.\n * @param proxyAddress Proxy (Twilio) address of the participant.\n * @param address User address of the participant.\n * @param attributes Attributes to be attached to the participant.\n * @param bindingOptions Options for adding email participants - name and CC/To level.\n */\n @validateTypesAsync(\n nonEmptyString,\n nonEmptyString,\n optionalAttributesValidator\n )\n async addNonChatParticipant(\n proxyAddress: string,\n address: string,\n attributes: JSONValue = {},\n bindingOptions: ParticipantBindingOptions = {}\n ): Promise<ParticipantResponse> {\n return this.participantsEntity.addNonChatParticipant(\n proxyAddress,\n address,\n attributes ?? {},\n bindingOptions ?? {}\n );\n }\n\n /**\n * Advance the conversation's last read message index to the current read horizon.\n * Rejects if the user is not a participant of the conversation.\n * Last read message index is updated only if the new index value is higher than the previous.\n * @param index Message index to advance to.\n * @return Resulting unread messages count in the conversation.\n */\n @validateTypesAsync(nonNegativeInteger)\n async advanceLastReadMessageIndex(index: number): Promise<number> {\n await this._subscribeStreams();\n\n if (index < (this.lastReadMessageIndex || 0)) {\n return await this._setLastReadMessageIndex(this.lastReadMessageIndex);\n }\n\n return await this._setLastReadMessageIndex(index);\n }\n\n /**\n * Delete the conversation and unsubscribe from its events.\n */\n async delete(): Promise<Conversation> {\n await this.services.commandExecutor.mutateResource(\n \"delete\",\n this.links.self\n );\n\n return this;\n }\n\n /**\n * Get the custom attributes of this Conversation.\n */\n async getAttributes(): Promise<JSONValue> {\n await this._subscribe();\n return this.attributes;\n }\n\n /**\n * Returns messages from the conversation using the paginator interface.\n * @param pageSize Number of messages to return in a single chunk. Default is 30.\n * @param anchor Index of the newest message to fetch. Default is from the end.\n * @param direction Query direction. By default it queries backwards\n * from newer to older. The `\"forward\"` value will query in the opposite direction.\n * @return A page of messages.\n */\n @validateTypesAsync(\n [\"undefined\", nonNegativeInteger],\n [\"undefined\", nonNegativeInteger],\n [\"undefined\", literal(\"backwards\", \"forward\")]\n )\n async getMessages(\n pageSize?: number,\n anchor?: number,\n direction?: \"backwards\" | \"forward\"\n ): Promise<Paginator<Message>> {\n await this._subscribeStreams();\n return this.messagesEntity.getMessages(pageSize, anchor, direction);\n }\n\n /**\n * Get a list of all the participants who are joined to this conversation.\n */\n async getParticipants(): Promise<Participant[]> {\n await this._subscribeStreams();\n return this.participantsEntity.getParticipants();\n }\n\n /**\n * Get conversation participants count.\n *\n * This method is semi-realtime. This means that this data will be eventually correct,\n * but will also be possibly incorrect for a few seconds. The Conversations system does not\n * provide real time events for counter values changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any core application\n * logic based on these counters being accurate in real time.\n */\n async getParticipantsCount(): Promise<number> {\n const url = new UriBuilder(this.configuration.links.conversations)\n .path(this.sid)\n .build();\n const response = await this.services.network.get<ConversationResponse>(url);\n\n return response.body.participants_count ?? 0;\n }\n\n /**\n * Get a participant by its SID.\n * @param participantSid Participant SID.\n */\n @validateTypesAsync(nonEmptyString)\n async getParticipantBySid(\n participantSid: string\n ): Promise<Participant | null> {\n return this.participantsEntity.getParticipantBySid(participantSid);\n }\n\n /**\n * Get a participant by its identity.\n * @param identity Participant identity.\n */\n @validateTypesAsync(nonEmptyString)\n async getParticipantByIdentity(\n identity: string | null = \"\"\n ): Promise<Participant | null> {\n return this.participantsEntity.getParticipantByIdentity(identity ?? \"\");\n }\n\n /**\n * Get the total message count in the conversation.\n *\n * This method is semi-realtime. This means that this data will be eventually correct,\n * but will also be possibly incorrect for a few seconds. The Conversations system does not\n * provide real time events for counter values changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any core application\n * logic based on these counters being accurate in real time.\n */\n async getMessagesCount(): Promise<number> {\n const url = new UriBuilder(this.configuration.links.conversations)\n .path(this.sid)\n .build();\n const response = await this.services.network.get<ConversationResponse>(url);\n\n return response.body.messages_count ?? 0;\n }\n\n /**\n * Get unread messages count for the user if they are a participant of this conversation.\n * Rejects if the user is not a participant of the conversation.\n *\n * Use this method to obtain the number of unread messages together with\n * {@link Conversation.updateLastReadMessageIndex} instead of relying on the\n * message indices which may have gaps. See {@link Message.index} for details.\n *\n * This method is semi-realtime. This means that this data will be eventually correct,\n * but will also be possibly incorrect for a few seconds. The Conversations system does not\n * provide real time events for counter values changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any core application\n * logic based on these counters being accurate in real time.\n */\n async getUnreadMessagesCount(): Promise<number | null> {\n const url = new UriBuilder(this.configuration.links.myConversations)\n .path(this.sid)\n .build();\n const response = await this.services.network.get<ConversationResponse>(url);\n\n if (response.body.conversation_sid !== this.sid) {\n throw new Error(\n \"Conversation was not found in the user conversations list\"\n );\n }\n\n const unreadMessageCount = response.body.unread_messages_count;\n\n if (typeof unreadMessageCount === \"number\") {\n return unreadMessageCount;\n }\n\n return null;\n }\n\n /**\n * Join the conversation and subscribe to its events.\n */\n async join(): Promise<Conversation> {\n await this.services.commandExecutor.mutateResource<\n AddParticipantRequest,\n ParticipantResponse\n >(\"post\", this.links.participants, {\n identity: this.configuration.userIdentity,\n });\n\n return this;\n }\n\n /**\n * Leave the conversation.\n */\n async leave(): Promise<Conversation> {\n if (this.channelState.status === \"joined\") {\n await this.services.commandExecutor.mutateResource(\n \"delete\",\n `${this.links.participants}/${this.configuration.userIdentity}`\n );\n }\n\n return this;\n }\n\n /**\n * Remove a participant from the conversation. When a string is passed as the\n * argument, it will assume that the string is an identity or SID.\n * @param participant Identity, SID or the participant object to remove.\n */\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore TODO: fix validateTypesAsync typing\n @validateTypesAsync([nonEmptyString, Participant])\n async removeParticipant(participant: string | Participant): Promise<void> {\n await this.participantsEntity.remove(\n typeof participant === \"string\" ? participant : participant.sid\n );\n }\n\n /**\n * Send a message to the conversation.\n * @param message Message body for the text message,\n * `FormData` or {@link SendMediaOptions} for media content. Sending FormData is supported only with the browser engine.\n * @param messageAttributes Attributes for the message.\n * @param emailOptions Email options for the message.\n * @return Index of the new message.\n */\n @validateTypesAsync(\n [\n \"string\",\n literal(null),\n // Wrapping it into a custom rule is necessary because the FormData class is not available on initialization.\n custom((value) => [value instanceof FormData, \"an instance of FormData\"]),\n objectSchema(\"media options\", {\n contentType: nonEmptyString,\n media: custom((value) => {\n let isValid =\n (typeof value === \"string\" && value.length > 0) ||\n value instanceof Uint8Array ||\n value instanceof ArrayBuffer;\n\n if (typeof Blob === \"function\") {\n isValid = isValid || value instanceof Blob;\n }\n\n return [\n isValid,\n \"a non-empty string, an instance of Buffer or an instance of Blob\",\n ];\n }),\n }),\n ],\n optionalAttributesValidator,\n [\n \"undefined\",\n literal(null),\n objectSchema(\"email attributes\", {\n subject: [nonEmptyString, \"undefined\"],\n }),\n ]\n )\n async sendMessage(\n message: null | string | FormData | SendMediaOptions,\n messageAttributes?: JSONValue,\n emailOptions?: SendEmailOptions\n ): Promise<number> {\n if (typeof message === \"string\" || message === null) {\n const response = await this.messagesEntity.send(\n message,\n messageAttributes,\n emailOptions\n );\n return parseToNumber(response.index) ?? 0;\n }\n\n const response = await this.messagesEntity.sendMedia(\n message,\n messageAttributes,\n emailOptions\n );\n return parseToNumber(response.index) ?? 0;\n }\n\n /**\n * New interface to prepare for sending a message.\n * Use instead of `sendMessage`.\n * @return A MessageBuilder to help set all message sending options.\n */\n public prepareMessage(): MessageBuilder {\n return new MessageBuilder(this.limits, this.messagesEntity);\n }\n\n /**\n * Set last read message index of the conversation to the index of the last known message.\n * @return Resulting unread messages count in the conversation.\n */\n public async setAllMessagesRead(): Promise<number> {\n await this._subscribeStreams();\n\n const messagesPage = await this.getMessages(1);\n\n if (messagesPage.items.length > 0) {\n return this.advanceLastReadMessageIndex(messagesPage.items[0].index);\n }\n\n return Promise.resolve(0);\n }\n\n /**\n * Set all messages in the conversation unread.\n * @return Resulting unread messages count in the conversation.\n */\n public async setAllMessagesUnread(): Promise<number> {\n await this._subscribeStreams();\n return await this._setLastReadMessageIndex(null);\n }\n\n /**\n * Set user notification level for this conversation.\n * @param notificationLevel New user notification level.\n */\n @validateTypesAsync(literal(\"default\", \"muted\"))\n async setUserNotificationLevel(\n notificationLevel: NotificationLevel\n ): Promise<void> {\n await this.services.commandExecutor.mutateResource<EditNotificationLevelRequest>(\n \"post\",\n `${this.configuration.links.myConversations}/${this.sid}`,\n {\n notification_level: notificationLevel,\n }\n );\n }\n\n /**\n * Send a notification to the server indicating that this client is currently typing in this conversation.\n * Typing ended notification is sent after a while automatically, but by calling this method again you ensure that typing ended is not received.\n */\n typing(): Promise<void> {\n return this.services.typingIndicator.send(this.sid);\n }\n\n /**\n * Update the attributes of the conversation.\n * @param attributes New attributes.\n */\n @validateTypesAsync(attributesValidator)\n async updateAttributes(attributes: JSONValue): Promise<Conversation> {\n await this.services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this.links.self, {\n attributes:\n attributes !== undefined ? JSON.stringify(attributes) : undefined,\n });\n\n return this;\n }\n\n /**\n * Update the friendly name of the conversation.\n * @param friendlyName New friendly name.\n */\n @validateTypesAsync([\"string\"])\n async updateFriendlyName(friendlyName: string): Promise<Conversation> {\n if (this.channelState.friendlyName !== friendlyName) {\n await this.services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this.links.self, { friendly_name: friendlyName });\n }\n\n return this;\n }\n\n /**\n * Set the last read message index to the current read horizon.\n * @param index Message index to set as last read.\n * If null is provided, then the behavior is identical to {@link Conversation.setAllMessagesUnread}.\n * @returns Resulting unread messages count in the conversation.\n */\n @validateTypesAsync([literal(null), nonNegativeInteger])\n async updateLastReadMessageIndex(index: number | null): Promise<number> {\n await this._subscribeStreams();\n return this._setLastReadMessageIndex(index);\n }\n\n /**\n * Update the unique name of the conversation.\n * @param uniqueName New unique name for the conversation. Setting unique name to null removes it.\n */\n @validateTypesAsync([\"string\", literal(null)])\n async updateUniqueName(uniqueName: string | null): Promise<Conversation> {\n if (this.channelState.uniqueName !== uniqueName) {\n if (!uniqueName) {\n uniqueName = \"\";\n }\n\n await this.services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this.links.self, {\n unique_name: uniqueName,\n });\n }\n\n return this;\n }\n}\n\nexport {\n ConversationDescriptor,\n Conversation,\n ConversationUpdateReason,\n ConversationStatus,\n NotificationLevel,\n ConversationState,\n ConversationUpdatedEventArgs,\n SendMediaOptions,\n SendEmailOptions,\n LastMessage,\n ConversationBindings,\n ConversationEmailBinding,\n};\n"],"names":["Logger","ReplayEventEmitter","Participants","Messages","isEqual","UriBuilder","parseToNumber","MessageBuilder","__decorate","validateTypesAsync","nonEmptyString","optionalAttributesValidator","nonNegativeInteger","literal","Participant","custom","objectSchema","attributesValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,cAA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,OAAO;oBACL,OAAO;oBACP,kEAAkE;iBACnE,CAAC;aACH,CAAC;SACH,CAAC;KACH,EACDJ,sCAA2B,EAC3B;QACE,WAAW;QACXE,gCAAO,CAAC,IAAI,CAAC;QACbG,qCAAY,CAAC,kBAAkB,EAAE;YAC/B,OAAO,EAAE,CAACN,uCAAc,EAAE,WAAW,CAAC;SACvC,CAAC;KACH,CACF;;;;+CAqBA;AAyCDF;IADCC,2CAAkB,CAACI,gCAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;;;;4DAW/C;AAeDL;IADCC,2CAAkB,CAACQ,8BAAmB,CAAC;;;;oDAWvC;AAODT;IADCC,2CAAkB,CAAC,CAAC,QAAQ,CAAC,CAAC;;;;sDAU9B;AASDD;IADCC,2CAAkB,CAAC,CAACI,gCAAO,CAAC,IAAI,CAAC,EAAED,2CAAkB,CAAC,CAAC;;;;8DAIvD;AAODJ;IADCC,2CAAkB,CAAC,CAAC,QAAQ,EAAEI,gCAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;;;oDAgB7C;;;;"}
|
1
|
+
{"version":3,"file":"conversation.js","sources":["../src/conversation.ts"],"sourcesContent":["import \"isomorphic-form-data\";\nimport { Logger } from \"./logger\";\nimport { ParticipantBindingOptions, Participants } from \"./data/participants\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"./participant\";\nimport { Messages } from \"./data/messages\";\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"./message\";\nimport { UriBuilder, parseToNumber, parseTime } from \"./util\";\nimport { Users } from \"./data/users\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { ConversationsDataSource } from \"./data/conversations\";\nimport { McsClient } from \"@twilio/mcs-client\";\nimport { SyncClient, SyncDocument } from \"twilio-sync\";\nimport { TypingIndicator } from \"./services/typing-indicator\";\nimport { Network } from \"./services/network\";\nimport {\n validateTypesAsync,\n custom,\n literal,\n nonEmptyString,\n nonNegativeInteger,\n objectSchema,\n} from \"@twilio/declarative-type-validator\";\nimport {\n attributesValidator,\n optionalAttributesValidator,\n} from \"./interfaces/attributes\";\nimport { Configuration } from \"./configuration\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { AddParticipantRequest } from \"./interfaces/commands/add-participant\";\nimport { EditConversationRequest } from \"./interfaces/commands/edit-conversation\";\nimport { ConversationResponse } from \"./interfaces/commands/conversation-response\";\nimport { ParticipantResponse } from \"./interfaces/commands/participant-response\";\nimport { EditNotificationLevelRequest } from \"./interfaces/commands/edit-notification-level\";\nimport {\n EditLastReadMessageIndexRequest,\n EditLastReadMessageIndexResponse,\n} from \"./interfaces/commands/edit-last-read-message-index\";\nimport { ConversationLimits } from \"./interfaces/conversation-limits\";\nimport { MessageBuilder } from \"./message-builder\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"./types\";\n\n/**\n * Conversation events.\n */\ntype ConversationEvents = {\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n updated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n removed: (conversation: Conversation) => void;\n};\n\n/**\n * Reason for the `updated` event emission by a conversation.\n */\ntype ConversationUpdateReason =\n | \"attributes\"\n | \"createdBy\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"friendlyName\"\n | \"lastReadMessageIndex\"\n | \"state\"\n | \"status\"\n | \"uniqueName\"\n | \"lastMessage\"\n | \"notificationLevel\"\n | \"bindings\";\n\n/**\n * Status of the conversation, relative to the client: whether the conversation\n * has been `joined` or the client is `notParticipating` in the conversation.\n */\ntype ConversationStatus = \"notParticipating\" | \"joined\";\n\n/**\n * User's notification level for the conversation. Determines\n * whether the currently logged-in user will receive pushes for events\n * in this conversation. Can be either `muted` or `default`, where\n * `default` defers to the global service push configuration.\n */\ntype NotificationLevel = \"default\" | \"muted\";\n\n/**\n * State of the conversation.\n */\ninterface ConversationState {\n /**\n * Current state.\n */\n current: \"active\" | \"inactive\" | \"closed\";\n\n /**\n * Date at which the latest conversation state update happened.\n */\n dateUpdated: Date;\n}\n\n/**\n * Event arguments for the `updated` event.\n */\ninterface ConversationUpdatedEventArgs {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n}\n\n/**\n * Binding for email conversation.\n */\ninterface ConversationBindings {\n email?: ConversationEmailBinding;\n sms?: ConversationSmsBinding;\n}\n\n/**\n * Binding for email conversation.\n */\ninterface ConversationEmailBinding {\n name?: string;\n projected_address: string;\n}\n\n/**\n * Binding for SMS conversation.\n */\ninterface ConversationSmsBinding {\n address?: string;\n}\n\n/**\n * Configuration for attaching a media file to a message.\n * These options can be passed to {@link Conversation.sendMessage} and\n * {@link MessageBuilder.addMedia}.\n */\ninterface SendMediaOptions {\n /**\n * Content type of media.\n */\n contentType: null | string;\n\n /**\n * Optional filename.\n */\n filename?: string;\n\n /**\n * Content to post.\n */\n media: null | string | Buffer | Blob;\n}\n\n/**\n * These options can be passed to {@link Conversation.sendMessage}.\n */\ninterface SendEmailOptions {\n /**\n * Message subject. Ignored for media messages.\n */\n subject?: string;\n}\n\n/**\n * Information about the last message of a conversation.\n */\ninterface LastMessage {\n /**\n * Message's index.\n */\n index?: number;\n\n /**\n * Message's creation date.\n */\n dateCreated?: Date;\n}\n\n/**\n * Conversation services.\n */\ninterface ConversationServices {\n users: Users;\n typingIndicator: TypingIndicator;\n network: Network;\n mcsClient: McsClient;\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n}\n\n/**\n * Internal (private) state of the conversation.\n */\ninterface ConversationInternalState {\n uniqueName: string | null;\n status: ConversationStatus;\n attributes: JSONValue;\n createdBy?: string;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n friendlyName: string | null;\n lastReadMessageIndex: number | null;\n lastMessage?: LastMessage;\n notificationLevel?: NotificationLevel;\n state?: ConversationState;\n bindings: ConversationBindings;\n}\n\n/**\n * Conversation descriptor.\n */\ninterface ConversationDescriptor {\n channel: string;\n entityName: string;\n uniqueName: string;\n attributes: JSONValue;\n createdBy?: string;\n friendlyName?: string;\n lastConsumedMessageIndex: number;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n notificationLevel?: NotificationLevel;\n bindings?: ConversationBindings;\n}\n\n/**\n * Conversation links.\n */\ninterface ConversationLinks {\n self: string;\n messages: string;\n participants: string;\n}\n\n/**\n * Map of the fields that will be processed with update messages.\n */\nconst fieldMappings = {\n lastMessage: \"lastMessage\",\n attributes: \"attributes\",\n createdBy: \"createdBy\",\n dateCreated: \"dateCreated\",\n dateUpdated: \"dateUpdated\",\n friendlyName: \"friendlyName\",\n lastConsumedMessageIndex: \"lastConsumedMessageIndex\",\n notificationLevel: \"notificationLevel\",\n sid: \"sid\",\n status: \"status\",\n uniqueName: \"uniqueName\",\n state: \"state\",\n bindings: \"bindings\",\n};\n\n/**\n * A conversation represents communication between multiple Conversations\n * clients.\n */\nclass Conversation extends ReplayEventEmitter<ConversationEvents> {\n /**\n * Fired when a participant has joined the conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - participant that joined the\n * conversation\n * @event\n */\n public static readonly participantJoined = \"participantJoined\";\n\n /**\n * Fired when a participant has left the conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - participant that left the\n * conversation\n * @event\n */\n public static readonly participantLeft = \"participantLeft\";\n\n /**\n * Fired when data of a participant has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Participant} `participant` - participant that has received the\n * update\n * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly participantUpdated = \"participantUpdated\";\n\n /**\n * Fired when a new message has been added to the conversation.\n *\n * Parameters:\n * 1. {@link Message} `message` - message that has been added\n * @event\n */\n public static readonly messageAdded = \"messageAdded\";\n\n /**\n * Fired when message is removed from the conversation's message list.\n *\n * Parameters:\n * 1. {@link Message} `message` - message that has been removed\n * @event\n */\n public static readonly messageRemoved = \"messageRemoved\";\n\n /**\n * Fired when data of a message has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Message} `message` - message that has received the update\n * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for\n * the update\n * @event\n */\n public static readonly messageUpdated = \"messageUpdated\";\n\n /**\n * Fired when a participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant that has stopped\n * typing\n * @event\n */\n public static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when a participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant that has started\n * typing\n * @event\n */\n public static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the data of the conversation has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Conversation} `conversation` - conversation that has received\n * the update\n * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly updated = \"updated\";\n\n /**\n * Fired when the conversation was destroyed or the currently-logged-in user\n * has left private conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - conversation that has been removed\n * @event\n */\n public static readonly removed = \"removed\";\n\n /**\n * Logger instance.\n */\n private static readonly _logger = Logger.scope(\"Conversation\");\n\n /**\n * Unique system identifier of the conversation.\n */\n public readonly sid: string;\n\n /**\n * Conversation links for REST requests.\n * @internal\n */\n public readonly _links: ConversationLinks;\n\n /**\n * Map of participants.\n * @internal\n */\n public readonly _participants: Map<string, Participant>;\n\n /**\n * Configuration of the client that the conversation belongs to.\n */\n private readonly _configuration: Configuration;\n\n /**\n * Conversation service objects.\n */\n private readonly _services: ConversationServices;\n\n /**\n * Internal state of the conversation.\n */\n private readonly _internalState: ConversationInternalState;\n\n /**\n * Name of the conversation entity document.\n */\n private readonly _entityName: string;\n\n /**\n * Messages entity.\n */\n private readonly _messagesEntity: Messages;\n\n /**\n * Participants entity.\n */\n private readonly _participantsEntity: Participants;\n\n /**\n * Source of the most recent update.\n */\n private _dataSource!: ConversationsDataSource;\n\n /**\n * Promise for the conversation entity document.\n */\n private _entityPromise!: Promise<SyncDocument> | null;\n\n /**\n * Conversation entity document.\n */\n private _entity!: SyncDocument | null;\n\n /**\n * @param descriptor Conversation descriptor.\n * @param sid Conversation SID.\n * @param links Conversation links for REST requests.\n * @param configuration Client configuration.\n * @param services Conversation services.\n * @internal\n */\n public constructor(\n descriptor: ConversationDescriptor,\n sid: string,\n links: ConversationLinks,\n configuration: Configuration,\n services: ConversationServices\n ) {\n super();\n\n this.sid = sid;\n this._links = links;\n this._configuration = configuration;\n this._services = services;\n this._entityName = descriptor.channel;\n this._internalState = {\n uniqueName: descriptor.uniqueName || null,\n status: \"notParticipating\",\n attributes: descriptor.attributes ?? {},\n createdBy: descriptor.createdBy,\n dateCreated: parseTime(descriptor.dateCreated),\n dateUpdated: parseTime(descriptor.dateUpdated),\n friendlyName: descriptor.friendlyName || null,\n lastReadMessageIndex: Number.isInteger(\n descriptor.lastConsumedMessageIndex\n )\n ? descriptor.lastConsumedMessageIndex\n : null,\n bindings: descriptor.bindings ?? {},\n };\n\n if (descriptor.notificationLevel) {\n this._internalState.notificationLevel = descriptor.notificationLevel;\n }\n\n const participantsLinks = {\n participants: this._links.participants,\n };\n\n this._participants = new Map();\n this._participantsEntity = new Participants(\n this,\n this._participants,\n participantsLinks,\n this._configuration,\n this._services\n );\n this._participantsEntity.on(\"participantJoined\", (participant) =>\n this.emit(\"participantJoined\", participant)\n );\n this._participantsEntity.on(\"participantLeft\", (participant) =>\n this.emit(\"participantLeft\", participant)\n );\n this._participantsEntity.on(\n \"participantUpdated\",\n (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n\n this._messagesEntity = new Messages(this, configuration, services);\n this._messagesEntity.on(\"messageAdded\", (message) =>\n this._onMessageAdded(message)\n );\n this._messagesEntity.on(\"messageUpdated\", (args: MessageUpdatedEventArgs) =>\n this.emit(\"messageUpdated\", args)\n );\n this._messagesEntity.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n }\n\n /**\n * Unique name of the conversation.\n */\n public get uniqueName(): string | null {\n return this._internalState.uniqueName;\n }\n\n /**\n * Status of the conversation.\n */\n public get status(): ConversationStatus {\n return this._internalState.status;\n }\n\n /**\n * Name of the conversation.\n */\n public get friendlyName(): string | null {\n return this._internalState.friendlyName;\n }\n\n /**\n * Date this conversation was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this._internalState.dateUpdated;\n }\n\n /**\n * Date this conversation was created on.\n */\n public get dateCreated(): Date | null {\n return this._internalState.dateCreated;\n }\n\n /**\n * Identity of the user that created this conversation.\n */\n public get createdBy(): string {\n return this._internalState.createdBy ?? \"\";\n }\n\n /**\n * Custom attributes of the conversation.\n */\n public get attributes(): JSONValue {\n return this._internalState.attributes;\n }\n\n /**\n * Index of the last message the user has read in this conversation.\n */\n public get lastReadMessageIndex(): number | null {\n return this._internalState.lastReadMessageIndex;\n }\n\n /**\n * Last message sent to this conversation.\n */\n public get lastMessage(): LastMessage | undefined {\n return this._internalState.lastMessage ?? undefined;\n }\n\n /**\n * User notification level for this conversation.\n */\n public get notificationLevel(): NotificationLevel {\n return this._internalState.notificationLevel ?? \"default\";\n }\n\n /**\n * Conversation bindings. Undocumented feature (for now).\n * @internal\n */\n public get bindings(): ConversationBindings {\n return this._internalState.bindings;\n }\n\n /**\n * Current conversation limits.\n */\n public get limits(): ConversationLimits {\n return this._configuration.limits;\n }\n\n /**\n * State of the conversation.\n */\n public get state(): ConversationState | undefined {\n return this._internalState.state;\n }\n\n /**\n * Source of the conversation update.\n * @internal\n */\n public get _statusSource(): ConversationsDataSource {\n return this._dataSource;\n }\n\n /**\n * Preprocess the update object.\n * @param update The update object received from Sync.\n * @param conversationSid The SID of the conversation in question.\n */\n private static preprocessUpdate(update, conversationSid: string) {\n try {\n if (typeof update.attributes === \"string\") {\n update.attributes = JSON.parse(update.attributes);\n } else if (update.attributes) {\n JSON.stringify(update.attributes);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed attributes from the server for conversation: \" +\n conversationSid\n );\n update.attributes = {};\n }\n\n try {\n update.dateCreated &&= new Date(update.dateCreated);\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed dateCreated from the server for conversation: \" +\n conversationSid\n );\n delete update.dateCreated;\n }\n\n try {\n update.dateUpdated &&= new Date(update.dateUpdated);\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed dateUpdated from the server for conversation: \" +\n conversationSid\n );\n delete update.dateUpdated;\n }\n\n try {\n if (update.lastMessage && update.lastMessage.timestamp) {\n update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed lastMessage.timestamp from the server for conversation: \" +\n conversationSid\n );\n delete update.lastMessage.timestamp;\n }\n }\n\n /**\n * Add a participant to the conversation by its identity.\n * @param identity Identity of the Client to add.\n * @param attributes Attributes to be attached to the participant.\n * @returns The added participant.\n */\n @validateTypesAsync(nonEmptyString, optionalAttributesValidator)\n public async add(\n identity: string,\n attributes?: JSONValue\n ): Promise<Participant> {\n return this._participantsEntity.add(identity, attributes ?? {});\n }\n\n /**\n * Add a non-chat participant to the conversation.\n * @param proxyAddress Proxy (Twilio) address of the participant.\n * @param address User address of the participant.\n * @param attributes Attributes to be attached to the participant.\n * @param bindingOptions Options for adding email participants - name and\n * CC/To level.\n * @returns The added participant.\n */\n @validateTypesAsync(\n nonEmptyString,\n nonEmptyString,\n optionalAttributesValidator\n )\n public async addNonChatParticipant(\n proxyAddress: string,\n address: string,\n attributes: JSONValue = {},\n bindingOptions: ParticipantBindingOptions = {}\n ): Promise<Participant> {\n return this._participantsEntity.addNonChatParticipant(\n proxyAddress,\n address,\n attributes ?? {},\n bindingOptions ?? {}\n );\n }\n\n /**\n * Advance the conversation's last read message index to the current read\n * horizon. Rejects if the user is not a participant of the conversation. Last\n * read message index is updated only if the new index value is higher than\n * the previous.\n * @param index Message index to advance to.\n * @return Resulting unread messages count in the conversation.\n */\n @validateTypesAsync(nonNegativeInteger)\n public async advanceLastReadMessageIndex(index: number): Promise<number> {\n await this._subscribeStreams();\n\n if (index < (this.lastReadMessageIndex ?? 0)) {\n return await this._setLastReadMessageIndex(this.lastReadMessageIndex);\n }\n\n return await this._setLastReadMessageIndex(index);\n }\n\n /**\n * Delete the conversation and unsubscribe from its events.\n */\n public async delete(): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource(\n \"delete\",\n this._links.self\n );\n\n return this;\n }\n\n /**\n * Get the custom attributes of this Conversation.\n */\n public async getAttributes(): Promise<JSONValue> {\n await this._subscribe();\n return this.attributes;\n }\n\n /**\n * Returns messages from the conversation using the paginator interface.\n * @param pageSize Number of messages to return in a single chunk. Default is\n * 30.\n * @param anchor Index of the newest message to fetch. Default is from the\n * end.\n * @param direction Query direction. By default, it queries backwards\n * from newer to older. The `\"forward\"` value will query in the opposite\n * direction.\n * @return A page of messages.\n */\n @validateTypesAsync(\n [\"undefined\", nonNegativeInteger],\n [\"undefined\", nonNegativeInteger],\n [\"undefined\", literal(\"backwards\", \"forward\")]\n )\n public async getMessages(\n pageSize?: number,\n anchor?: number,\n direction?: \"backwards\" | \"forward\"\n ): Promise<Paginator<Message>> {\n await this._subscribeStreams();\n return this._messagesEntity.getMessages(pageSize, anchor, direction);\n }\n\n /**\n * Get a list of all the participants who are joined to this conversation.\n */\n public async getParticipants(): Promise<Participant[]> {\n await this._subscribeStreams();\n return this._participantsEntity.getParticipants();\n }\n\n /**\n * Get conversation participants count.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n */\n public async getParticipantsCount(): Promise<number> {\n const url = new UriBuilder(this._configuration.links.conversations)\n .path(this.sid)\n .build();\n const response = await this._services.network.get<ConversationResponse>(\n url\n );\n\n return response.body.participants_count ?? 0;\n }\n\n /**\n * Get a participant by its SID.\n * @param participantSid Participant SID.\n */\n @validateTypesAsync(nonEmptyString)\n public async getParticipantBySid(\n participantSid: string\n ): Promise<Participant | null> {\n return this._participantsEntity.getParticipantBySid(participantSid);\n }\n\n /**\n * Get a participant by its identity.\n * @param identity Participant identity.\n */\n @validateTypesAsync(nonEmptyString)\n public async getParticipantByIdentity(\n identity: string | null = \"\"\n ): Promise<Participant | null> {\n return this._participantsEntity.getParticipantByIdentity(identity ?? \"\");\n }\n\n /**\n * Get the total message count in the conversation.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n */\n public async getMessagesCount(): Promise<number> {\n const url = new UriBuilder(this._configuration.links.conversations)\n .path(this.sid)\n .build();\n const response = await this._services.network.get<ConversationResponse>(\n url\n );\n\n return response.body.messages_count ?? 0;\n }\n\n /**\n * Get unread messages count for the user if they are a participant of this\n * conversation. Rejects if the user is not a participant of the conversation.\n *\n * Use this method to obtain the number of unread messages together with\n * {@link Conversation.updateLastReadMessageIndex} instead of relying on the\n * message indices which may have gaps. See {@link Message.index} for details.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n */\n public async getUnreadMessagesCount(): Promise<number | null> {\n const url = new UriBuilder(this._configuration.links.myConversations)\n .path(this.sid)\n .build();\n const response = await this._services.network.get<ConversationResponse>(\n url\n );\n\n if (response.body.conversation_sid !== this.sid) {\n throw new Error(\n \"Conversation was not found in the user conversations list\"\n );\n }\n\n const unreadMessageCount = response.body.unread_messages_count;\n\n if (typeof unreadMessageCount === \"number\") {\n return unreadMessageCount;\n }\n\n return null;\n }\n\n /**\n * Join the conversation and subscribe to its events.\n */\n public async join(): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource<\n AddParticipantRequest,\n ParticipantResponse\n >(\"post\", this._links.participants, {\n identity: this._configuration.userIdentity,\n });\n\n return this;\n }\n\n /**\n * Leave the conversation.\n */\n public async leave(): Promise<Conversation> {\n if (this._internalState.status === \"joined\") {\n await this._services.commandExecutor.mutateResource(\n \"delete\",\n `${this._links.participants}/${this._configuration.userIdentity}`\n );\n }\n\n return this;\n }\n\n /**\n * Remove a participant from the conversation. When a string is passed as the\n * argument, it will assume that the string is an identity or SID.\n * @param participant Identity, SID or the participant object to remove.\n */\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore TODO: fix validateTypesAsync typing\n @validateTypesAsync([nonEmptyString, Participant])\n public async removeParticipant(\n participant: string | Participant\n ): Promise<void> {\n await this._participantsEntity.remove(\n typeof participant === \"string\" ? participant : participant.sid\n );\n }\n\n /**\n * Send a message to the conversation.\n * @param message Message body for the text message,\n * `FormData` or {@link SendMediaOptions} for media content. Sending FormData\n * is supported only with the browser engine.\n * @param messageAttributes Attributes for the message.\n * @param emailOptions Email options for the message.\n * @return Index of the new message.\n */\n @validateTypesAsync(\n [\n \"string\",\n /* eslint-disable @typescript-eslint/ban-ts-comment */\n // @ts-ignore TODO: fix validateTypesAsync typing\n FormData,\n literal(null),\n objectSchema(\"media options\", {\n contentType: nonEmptyString,\n media: custom((value) => {\n let isValid =\n (typeof value === \"string\" && value.length > 0) ||\n value instanceof Uint8Array ||\n value instanceof ArrayBuffer;\n\n if (typeof Blob === \"function\") {\n isValid = isValid || value instanceof Blob;\n }\n\n return [\n isValid,\n \"a non-empty string, an instance of Buffer or an instance of Blob\",\n ];\n }),\n }),\n ],\n optionalAttributesValidator,\n [\n \"undefined\",\n literal(null),\n objectSchema(\"email attributes\", {\n subject: [nonEmptyString, \"undefined\"],\n }),\n ]\n )\n public async sendMessage(\n message: null | string | FormData | SendMediaOptions,\n messageAttributes?: JSONValue,\n emailOptions?: SendEmailOptions\n ): Promise<number> {\n if (typeof message === \"string\" || message === null) {\n const response = await this._messagesEntity.send(\n message,\n messageAttributes,\n emailOptions\n );\n return parseToNumber(response.index) ?? 0;\n }\n\n const response = await this._messagesEntity.sendMedia(\n message,\n messageAttributes,\n emailOptions\n );\n return parseToNumber(response.index) ?? 0;\n }\n\n /**\n * New interface to prepare for sending a message.\n * Use this instead of {@link Message.sendMessage}.\n * @return A MessageBuilder to help set all message sending options.\n */\n public prepareMessage(): MessageBuilder {\n return new MessageBuilder(this.limits, this._messagesEntity);\n }\n\n /**\n * Set last read message index of the conversation to the index of the last\n * known message.\n * @return Resulting unread messages count in the conversation.\n */\n public async setAllMessagesRead(): Promise<number> {\n await this._subscribeStreams();\n\n const messagesPage = await this.getMessages(1);\n\n if (messagesPage.items.length > 0) {\n return this.advanceLastReadMessageIndex(messagesPage.items[0].index);\n }\n\n return 0;\n }\n\n /**\n * Set all messages in the conversation unread.\n * @return Resulting unread messages count in the conversation.\n */\n public async setAllMessagesUnread(): Promise<number> {\n await this._subscribeStreams();\n return await this._setLastReadMessageIndex(null);\n }\n\n /**\n * Set user notification level for this conversation.\n * @param notificationLevel New user notification level.\n */\n @validateTypesAsync(literal(\"default\", \"muted\"))\n public async setUserNotificationLevel(\n notificationLevel: NotificationLevel\n ): Promise<void> {\n await this._services.commandExecutor.mutateResource<EditNotificationLevelRequest>(\n \"post\",\n `${this._configuration.links.myConversations}/${this.sid}`,\n {\n notification_level: notificationLevel,\n }\n );\n }\n\n /**\n * Send a notification to the server indicating that this client is currently\n * typing in this conversation. Typing ended notification is sent after a\n * while automatically, but by calling this method again you ensure that\n * typing ended is not received.\n */\n public typing(): Promise<void> {\n return this._services.typingIndicator.send(this.sid);\n }\n\n /**\n * Update the attributes of the conversation.\n * @param attributes New attributes.\n */\n @validateTypesAsync(attributesValidator)\n public async updateAttributes(attributes: JSONValue): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, {\n attributes:\n attributes !== undefined ? JSON.stringify(attributes) : undefined,\n });\n\n return this;\n }\n\n /**\n * Update the friendly name of the conversation.\n * @param friendlyName New friendly name.\n */\n @validateTypesAsync(\"string\")\n public async updateFriendlyName(friendlyName: string): Promise<Conversation> {\n if (this._internalState.friendlyName !== friendlyName) {\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, { friendly_name: friendlyName });\n }\n\n return this;\n }\n\n /**\n * Set the last read message index to the current read horizon.\n * @param index Message index to set as last read. If null is provided, then\n * the behavior is identical to {@link Conversation.setAllMessagesUnread}.\n * @returns Resulting unread messages count in the conversation.\n */\n @validateTypesAsync([literal(null), nonNegativeInteger])\n public async updateLastReadMessageIndex(\n index: number | null\n ): Promise<number> {\n await this._subscribeStreams();\n return this._setLastReadMessageIndex(index);\n }\n\n /**\n * Update the unique name of the conversation.\n * @param uniqueName New unique name for the conversation. Setting unique name\n * to null removes it.\n */\n @validateTypesAsync([\"string\", literal(null)])\n public async updateUniqueName(\n uniqueName: string | null\n ): Promise<Conversation> {\n if (this._internalState.uniqueName !== uniqueName) {\n uniqueName ||= \"\";\n\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, {\n unique_name: uniqueName,\n });\n }\n\n return this;\n }\n\n /**\n * Load and subscribe to this conversation and do not subscribe to its\n * participants and messages. This or _subscribeStreams will need to be called\n * before any events on conversation will fire.\n * @internal\n */\n public async _subscribe(): Promise<SyncDocument> {\n if (this._entityPromise) {\n return this._entityPromise;\n }\n\n this._entityPromise = this._services.syncClient.document({\n id: this._entityName,\n mode: \"open_existing\",\n });\n\n try {\n this._entity = await this._entityPromise;\n this._entity.on(\"updated\", (args) => this._update(args.data));\n this._entity.on(\"removed\", () => this.emit(\"removed\", this));\n this._update(this._entity.data);\n\n return this._entity;\n } catch (err) {\n this._entity = null;\n this._entityPromise = null;\n\n if (this._services.syncClient.connectionState != \"disconnected\") {\n Conversation._logger.error(\"Failed to get conversation object\", err);\n }\n Conversation._logger.debug(\n \"ERROR: Failed to get conversation object\",\n err\n );\n\n throw err;\n }\n }\n\n /**\n * Load the attributes of this conversation and instantiate its participants\n * and messages. This or _subscribe will need to be called before any events\n * on the conversation will fire. This will need to be called before any\n * events on participants or messages will fire\n * @internal\n */\n public async _subscribeStreams() {\n try {\n await this._subscribe();\n Conversation._logger.trace(\n \"_subscribeStreams, this.entity.data=\",\n this._entity?.data\n );\n\n const data = this._entity?.data as Record<string, string>;\n const messagesObjectName = data.messages;\n const rosterObjectName = data.roster;\n\n await Promise.all([\n this._messagesEntity.subscribe(messagesObjectName),\n this._participantsEntity.subscribe(rosterObjectName),\n ]);\n } catch (err) {\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n Conversation._logger.error(\n \"Failed to subscribe on conversation objects\",\n this.sid,\n err\n );\n }\n Conversation._logger.debug(\n \"ERROR: Failed to subscribe on conversation objects\",\n this.sid,\n err\n );\n\n throw err;\n }\n }\n\n /**\n * Stop listening for and firing events on this conversation.\n * @internal\n */\n public async _unsubscribe() {\n if (this._entity) {\n await this._entity.close();\n this._entity = null;\n this._entityPromise = null;\n }\n\n return Promise.all([\n this._participantsEntity.unsubscribe(),\n this._messagesEntity.unsubscribe(),\n ]);\n }\n\n /**\n * Set conversation status.\n * @internal\n */\n public _setStatus(\n status: ConversationStatus,\n source: ConversationsDataSource\n ) {\n this._dataSource = source;\n\n if (this._internalState.status === status) {\n return;\n }\n\n this._internalState.status = status;\n\n if (status === \"joined\") {\n this._subscribeStreams().catch((err) => {\n Conversation._logger.debug(\n \"ERROR while setting conversation status \" + status,\n err\n );\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n throw err;\n }\n });\n return;\n }\n\n if (this._entityPromise) {\n this._unsubscribe().catch((err) => {\n Conversation._logger.debug(\n \"ERROR while setting conversation status \" + status,\n err\n );\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n throw err;\n }\n });\n }\n }\n\n /**\n * Update the local conversation object with new values.\n * @internal\n */\n public _update(update) {\n Conversation._logger.trace(\"_update\", update);\n\n Conversation.preprocessUpdate(update, this.sid);\n const updateReasons = new Set<ConversationUpdateReason>();\n\n for (const key of Object.keys(update)) {\n const localKey = fieldMappings[key];\n\n if (!localKey) {\n continue;\n }\n\n switch (localKey) {\n case fieldMappings.status:\n if (\n !update.status ||\n update.status === \"unknown\" ||\n this._internalState.status === update.status\n ) {\n break;\n }\n\n this._internalState.status = update.status;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.attributes:\n if (isEqual(this._internalState.attributes, update.attributes)) {\n break;\n }\n\n this._internalState.attributes = update.attributes;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.lastConsumedMessageIndex:\n if (\n update.lastConsumedMessageIndex === undefined ||\n update.lastConsumedMessageIndex ===\n this._internalState.lastReadMessageIndex\n ) {\n break;\n }\n\n this._internalState.lastReadMessageIndex =\n update.lastConsumedMessageIndex;\n updateReasons.add(\"lastReadMessageIndex\");\n\n break;\n case fieldMappings.lastMessage:\n if (this._internalState.lastMessage && !update.lastMessage) {\n delete this._internalState.lastMessage;\n updateReasons.add(localKey);\n\n break;\n }\n\n this._internalState.lastMessage =\n this._internalState.lastMessage || {};\n\n if (\n update.lastMessage?.index !== undefined &&\n update.lastMessage.index !== this._internalState.lastMessage.index\n ) {\n this._internalState.lastMessage.index = update.lastMessage.index;\n updateReasons.add(localKey);\n }\n\n if (\n update.lastMessage?.timestamp !== undefined &&\n this._internalState.lastMessage?.dateCreated?.getTime() !==\n update.lastMessage.timestamp.getTime()\n ) {\n this._internalState.lastMessage.dateCreated =\n update.lastMessage.timestamp;\n updateReasons.add(localKey);\n }\n\n if (isEqual(this._internalState.lastMessage, {})) {\n delete this._internalState.lastMessage;\n }\n\n break;\n case fieldMappings.state:\n const state = update.state || undefined;\n\n if (state !== undefined) {\n state.dateUpdated = new Date(state.dateUpdated);\n }\n\n if (isEqual(this._internalState.state, state)) {\n break;\n }\n\n this._internalState.state = state;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.bindings:\n if (isEqual(this._internalState.bindings, update.bindings)) {\n break;\n }\n\n this._internalState.bindings = update.bindings;\n updateReasons.add(localKey);\n\n break;\n default:\n const isDate = update[key] instanceof Date;\n const keysMatchAsDates =\n isDate &&\n this._internalState[localKey]?.getTime() === update[key].getTime();\n const keysMatchAsNonDates = !isDate && this[localKey] === update[key];\n\n if (keysMatchAsDates || keysMatchAsNonDates) {\n break;\n }\n\n this._internalState[localKey] = update[key];\n updateReasons.add(localKey);\n }\n }\n\n if (updateReasons.size > 0) {\n this.emit(\"updated\", {\n conversation: this,\n updateReasons: [...updateReasons],\n });\n }\n }\n\n /**\n * Handle onMessageAdded event.\n */\n private _onMessageAdded(message) {\n for (const participant of this._participants.values()) {\n if (participant.identity === message.author) {\n participant._endTyping();\n break;\n }\n }\n this.emit(\"messageAdded\", message);\n }\n\n /**\n * Set last read message index.\n * @param index New index to set.\n */\n private async _setLastReadMessageIndex(\n index: number | null\n ): Promise<number> {\n const result = await this._services.commandExecutor.mutateResource<\n EditLastReadMessageIndexRequest,\n EditLastReadMessageIndexResponse\n >(\"post\", `${this._configuration.links.myConversations}/${this.sid}`, {\n last_read_message_index: index,\n });\n\n return result.unread_messages_count;\n }\n}\n\nexport {\n ConversationDescriptor,\n Conversation,\n ConversationServices,\n ConversationUpdateReason,\n ConversationStatus,\n NotificationLevel,\n ConversationState,\n ConversationUpdatedEventArgs,\n SendMediaOptions,\n SendEmailOptions,\n LastMessage,\n ConversationBindings,\n ConversationEmailBinding,\n};\n"],"names":["ReplayEventEmitter","parseTime","Participants","Messages","UriBuilder","parseToNumber","MessageBuilder","isEqual","Logger","__decorate","validateTypesAsync","nonEmptyString","optionalAttributesValidator","nonNegativeInteger","literal","Participant","objectSchema","custom","attributesValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgQA;;AAEG;AACH,MAAM,aAAa,GAAG;AACpB,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,wBAAwB,EAAE,0BAA0B;AACpD,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF;;;AAGG;AACH,MAAM,YAAa,SAAQA,qCAAsC,CAAA;AAiL/D;;;;;;;AAOG;IACH,WACE,CAAA,UAAkC,EAClC,GAAW,EACX,KAAwB,EACxB,aAA4B,EAC5B,QAA8B,EAAA;;AAE9B,QAAA,KAAK,EAAE,CAAC;AAER,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;AACf,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;AACpB,QAAA,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;AACpC,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;AAC1B,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,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AA,CAAA;IADCC,2CAAkB,CAACQ,8BAAmB,CAAC;;;;AAWvC,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA,CAAA;AAODT,oBAAA,CAAA;IADCC,2CAAkB,CAAC,QAAQ,CAAC;;;;AAU5B,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,IAAA,CAAA,CAAA;AASDD,oBAAA,CAAA;IADCC,2CAAkB,CAAC,CAACI,gCAAO,CAAC,IAAI,CAAC,EAAED,2CAAkB,CAAC,CAAC;;;;AAMvD,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,4BAAA,EAAA,IAAA,CAAA,CAAA;AAQDJ,oBAAA,CAAA;IADCC,2CAAkB,CAAC,CAAC,QAAQ,EAAEI,gCAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;;;AAgB7C,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA;;;;"}
|
@@ -317,11 +317,11 @@ class Conversations extends replayEventEmitter.ReplayEventEmitter {
|
|
317
317
|
};
|
318
318
|
}
|
319
319
|
async _updateConversation(source, conversation, data) {
|
320
|
-
const areSourcesDifferent = conversation._statusSource
|
321
|
-
source !== conversation._statusSource
|
322
|
-
const isChannelSourceSync = source !== "rest" || conversation._statusSource
|
320
|
+
const areSourcesDifferent = conversation._statusSource !== undefined &&
|
321
|
+
source !== conversation._statusSource;
|
322
|
+
const isChannelSourceSync = source !== "rest" || conversation._statusSource === "sync";
|
323
323
|
if (areSourcesDifferent && isChannelSourceSync && source !== "sync") {
|
324
|
-
log.trace("upsertConversation: conversation is known from sync and came from
|
324
|
+
log.trace("upsertConversation: conversation is known from sync and came from REST, ignoring", {
|
325
325
|
sid: conversation.sid,
|
326
326
|
data: data.status,
|
327
327
|
conversation: conversation.status,
|
@@ -337,12 +337,11 @@ class Conversations extends replayEventEmitter.ReplayEventEmitter {
|
|
337
337
|
if (typeof data.lastConsumedMessageIndex !== "undefined") {
|
338
338
|
updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;
|
339
339
|
}
|
340
|
-
if (!isEqual__default[
|
340
|
+
if (!isEqual__default["default"](updateData, {})) {
|
341
341
|
conversation._update(updateData);
|
342
342
|
}
|
343
|
-
conversation._subscribe()
|
344
|
-
|
345
|
-
});
|
343
|
+
await conversation._subscribe();
|
344
|
+
this.emit("conversationJoined", conversation);
|
346
345
|
return;
|
347
346
|
}
|
348
347
|
if (data.status === "notParticipating" &&
|
@@ -365,15 +364,15 @@ class Conversations extends replayEventEmitter.ReplayEventEmitter {
|
|
365
364
|
// If the channel is known, update it
|
366
365
|
if (conversation$1) {
|
367
366
|
log.trace(`upsertConversation: the conversation ${conversation$1.sid} is known;` +
|
368
|
-
`its status is known from the source ${conversation$1._statusSource
|
367
|
+
`its status is known from the source ${conversation$1._statusSource} ` +
|
369
368
|
`and the update came from the source ${source}`, conversation$1);
|
370
369
|
await this._updateConversation(source, conversation$1, data);
|
371
370
|
await conversation$1._subscribe();
|
372
371
|
return conversation$1;
|
373
372
|
}
|
374
373
|
// If the conversations is deleted, ignore it
|
375
|
-
if (
|
376
|
-
log.trace("upsertChannel: the channel is deleted but reappeared again from
|
374
|
+
if (source === "rest" && this.tombstones.has(sid)) {
|
375
|
+
log.trace("upsertChannel: the channel is deleted but reappeared again from REST, ignoring", sid);
|
377
376
|
return null;
|
378
377
|
}
|
379
378
|
// If the conversation is unknown, fetch it
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"conversations.js","sources":["../../src/data/conversations.ts"],"sourcesContent":["import { Logger } from \"../logger\";\nimport {\n Conversation,\n ConversationDescriptor,\n ConversationUpdatedEventArgs,\n ConversationUpdateReason,\n} from \"../conversation\";\nimport { SyncMap, SyncClient, SyncMapItem } from \"twilio-sync\";\nimport { Users } from \"./users\";\nimport { Network } from \"../services/network\";\nimport { TypingIndicator } from \"../services/typing-indicator\";\nimport { McsClient } from \"@twilio/mcs-client\";\nimport { Deferred } from \"../util/deferred\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"../participant\";\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"../message\";\nimport { UriBuilder } from \"../util\";\nimport { Configuration } from \"../configuration\";\nimport { CommandExecutor } from \"../command-executor\";\nimport { CreateConversationRequest } from \"../interfaces/commands/create-conversation\";\nimport { ConversationResponse } from \"../interfaces/commands/conversation-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { ResponseMeta } from \"../interfaces/commands/response-meta\";\n\ntype ConversationsEvents = {\n conversationAdded: (conversation: Conversation) => void;\n conversationJoined: (conversation: Conversation) => void;\n conversationLeft: (conversation: Conversation) => void;\n conversationRemoved: (conversation: Conversation) => void;\n conversationUpdated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n};\n\ntype ConversationsDataSource = \"sync\" | \"chat\" | \"rest\";\n\ninterface ConversationsServices {\n syncClient: SyncClient;\n users: Users;\n typingIndicator: TypingIndicator;\n network: Network;\n mcsClient: McsClient;\n commandExecutor: CommandExecutor;\n}\n\ntype ConversationRestData = {\n roster: string;\n notificationLevel: \"default\" | \"muted\";\n lastConsumedMessageIndex: number;\n channel: string;\n messages: string;\n descriptor: ConversationResponse;\n channel_sid: string;\n status: string;\n};\n\nconst log = Logger.scope(\"Conversations\");\n\n/**\n * Represents conversations collection\n * {@see Conversation}\n */\nclass Conversations extends ReplayEventEmitter<ConversationsEvents> {\n public readonly conversations: Map<string, Conversation> = new Map();\n public readonly myConversationsRead: Deferred<boolean> = new Deferred();\n private readonly configuration: Configuration;\n private readonly services: ConversationsServices;\n private readonly tombstones: Set<string> = new Set();\n private myConversationsFetched = false;\n\n public constructor(\n configuration: Configuration,\n services: ConversationsServices\n ) {\n super();\n\n this.configuration = configuration;\n this.services = services;\n }\n\n public async addConversation(options): Promise<Conversation> {\n const attributes =\n typeof options?.attributes !== \"undefined\" ? options.attributes : {};\n\n const response = await this.services.commandExecutor.mutateResource<\n CreateConversationRequest,\n ConversationResponse\n >(\"post\", this.configuration.links.conversations, {\n friendly_name: options.friendlyName,\n unique_name: options.uniqueName,\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n });\n\n const conversationSid = response.sid ?? null;\n const conversationDocument = response.sync_objects?.conversation ?? null;\n const links = {\n self: response.url,\n ...response.links,\n };\n const existingConversation = this.conversations.get(conversationSid);\n\n if (existingConversation) {\n await existingConversation._subscribe();\n return existingConversation;\n }\n\n const conversation = new Conversation(\n {\n channel: conversationDocument,\n entityName: \"\",\n uniqueName: \"\",\n attributes: null,\n createdBy: \"\",\n friendlyName: \"\",\n lastConsumedMessageIndex: 0,\n dateCreated: null,\n dateUpdated: null,\n },\n conversationSid,\n links,\n this.configuration,\n this.services\n );\n\n this.conversations.set(conversation.sid, conversation);\n this._registerForEvents(conversation);\n\n await conversation._subscribe();\n this.emit(\"conversationAdded\", conversation);\n\n return conversation;\n }\n\n /**\n * Fetch conversations list and instantiate all necessary objects\n */\n public async fetchConversations(): Promise<Conversations> {\n try {\n const map = await this._getMap();\n\n map.on(\"itemAdded\", (args) => {\n log.debug(`itemAdded: ${args.item.key}`);\n\n this._upsertConversation(\"sync\", args.item.key, args.item.data);\n });\n\n map.on(\"itemRemoved\", (args) => {\n log.debug(`itemRemoved: ${args.key}`);\n\n const sid = args.key;\n\n if (!this.myConversationsFetched) {\n this.tombstones.add(sid);\n }\n\n const conversation = this.conversations.get(sid);\n\n if (!conversation) {\n return;\n }\n\n if (conversation.status === \"joined\") {\n conversation._setStatus(\"notParticipating\", \"sync\");\n this.emit(\"conversationLeft\", conversation);\n }\n\n this.conversations.delete(sid);\n this.emit(\"conversationRemoved\", conversation);\n conversation.emit(\"removed\", conversation);\n });\n\n map.on(\"itemUpdated\", (args) => {\n log.debug(`itemUpdated: ${args.item.key}`);\n\n this._upsertConversation(\"sync\", args.item.key, args.item.data);\n });\n\n const myConversations: ConversationRestData[] =\n await this._fetchMyConversations();\n const upserts: Promise<Conversation | null>[] = [];\n\n for (const conversation of myConversations) {\n upserts.push(\n this._upsertConversation(\n \"rest\",\n conversation[\"channel_sid\"],\n conversation\n )\n );\n }\n\n this.myConversationsRead.set(true);\n\n await Promise.all(upserts);\n\n this.myConversationsFetched = true;\n this.tombstones.clear();\n\n log.debug(\"The conversations list has been successfully fetched\");\n\n return this;\n } catch (error) {\n const errorMessage = \"Failed to fetch the conversations list\";\n\n if (this.services.syncClient.connectionState !== \"disconnected\") {\n log.error(errorMessage, error);\n }\n\n log.debug(`ERROR: ${errorMessage}`, error);\n\n throw error;\n }\n }\n\n public async getConversations() {\n const conversationsMap = await this._getMap();\n const page = await conversationsMap.getItems();\n\n return this._wrapPaginator(page, (items) =>\n Promise.all(\n items.map((item: SyncMapItem) =>\n this._upsertConversation(\"sync\", item.key, item.data)\n )\n )\n );\n }\n\n public async getConversation(\n sid: string\n ): Promise<Conversation | undefined | null> {\n const conversationsMap = await this._getMap();\n const page = await conversationsMap.getItems({ key: sid });\n const items = page.items.map((item: SyncMapItem) =>\n this._upsertConversation(\"sync\", item.key, item.data)\n );\n\n return items.length > 0 ? items[0] : null;\n }\n\n public async getConversationByUniqueName(\n uniqueName: string\n ): Promise<Conversation | null> {\n const url = new UriBuilder(this.configuration.links.myConversations)\n .path(uniqueName)\n .build();\n const response = await this.services.network.get<ConversationResponse>(url);\n const body = response.body;\n\n const sid = body.conversation_sid;\n const data = {\n entityName: null,\n lastConsumedMessageIndex: body.last_read_message_index,\n status: body?.status || \"unknown\",\n friendlyName: body.friendly_name,\n dateUpdated: body.date_updated,\n dateCreated: body.date_created,\n uniqueName: body.unique_name,\n createdBy: body.created_by,\n attributes: body.attributes,\n channel: body.sync_objects.conversation,\n notificationLevel: body?.notification_level,\n sid,\n };\n\n return sid ? this._upsertConversation(\"sync\", sid, data) : null;\n }\n\n public async peekConversation(sid: string): Promise<Conversation | null> {\n const url = new UriBuilder(this.configuration.links.conversations)\n .path(sid)\n .build();\n const response = await this.services.network.get<ConversationResponse>(url);\n const body = response.body;\n\n const data = {\n entityName: null,\n // lastConsumedMessageIndex: body.last_read_message_index,\n status: body?.status || \"unknown\",\n friendlyName: body.friendly_name,\n dateUpdated: body.date_updated,\n dateCreated: body.date_created,\n uniqueName: body.unique_name,\n createdBy: body.created_by,\n attributes: body.attributes,\n channel: `${sid}.channel`,\n // notificationLevel: body?.notification_level,\n sid,\n };\n\n return this._upsertConversation(\"sync\", sid, data);\n }\n\n private async _getMap(): Promise<SyncMap> {\n return await this.services.syncClient.map({\n id: this.configuration.myConversations,\n mode: \"open_existing\",\n });\n }\n\n private async _wrapPaginator(page, op) {\n const items = await op(page.items);\n\n return {\n items,\n hasNextPage: page.hasNextPage,\n hasPrevPage: page.hasPrevPage,\n nextPage: () => page.nextPage().then((x) => this._wrapPaginator(x, op)),\n prevPage: () => page.prevPage().then((x) => this._wrapPaginator(x, op)),\n };\n }\n\n private async _updateConversation(\n source: ConversationsDataSource,\n conversation: Conversation,\n data\n ): Promise<void> {\n const areSourcesDifferent =\n conversation._statusSource() !== undefined &&\n source !== conversation._statusSource();\n const isChannelSourceSync =\n source !== \"rest\" || conversation._statusSource() === \"sync\";\n\n if (areSourcesDifferent && isChannelSourceSync && source !== \"sync\") {\n log.trace(\n \"upsertConversation: conversation is known from sync and came from chat, ignoring\",\n {\n sid: conversation.sid,\n data: data.status,\n conversation: conversation.status,\n }\n );\n\n return;\n }\n\n if (data.status === \"joined\" && conversation.status !== \"joined\") {\n conversation._setStatus(\"joined\", source);\n\n const updateData: Partial<ConversationDescriptor> = {};\n\n if (typeof data.notificationLevel !== \"undefined\") {\n updateData.notificationLevel = data.notificationLevel;\n }\n\n if (typeof data.lastConsumedMessageIndex !== \"undefined\") {\n updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;\n }\n\n if (!isEqual(updateData, {})) {\n conversation._update(updateData);\n }\n\n conversation._subscribe().then(() => {\n this.emit(\"conversationJoined\", conversation);\n });\n\n return;\n }\n\n if (\n data.status === \"notParticipating\" &&\n conversation.status === \"joined\"\n ) {\n conversation._setStatus(\"notParticipating\", source);\n conversation._update(data);\n await conversation._subscribe();\n this.emit(\"conversationLeft\", conversation);\n\n return;\n }\n\n if (data.status === \"notParticipating\") {\n await conversation._subscribe();\n\n return;\n }\n\n conversation._update(data);\n }\n\n private async _upsertConversation(\n source: ConversationsDataSource,\n sid: string,\n data\n ): Promise<Conversation | null> {\n log.trace(`upsertConversation called for ${sid}`, data);\n\n const conversation = this.conversations.get(sid);\n\n // If the channel is known, update it\n if (conversation) {\n log.trace(\n `upsertConversation: the conversation ${conversation.sid} is known;` +\n `its status is known from the source ${conversation._statusSource()} ` +\n `and the update came from the source ${source}`,\n conversation\n );\n\n await this._updateConversation(source, conversation, data);\n await conversation._subscribe();\n\n return conversation;\n }\n\n // If the conversations is deleted, ignore it\n if ([\"chat\", \"rest\"].includes(source) && this.tombstones.has(sid)) {\n log.trace(\n \"upsertChannel: the channel is deleted but reappeared again from chat, ignoring\",\n sid\n );\n return null;\n }\n\n // If the conversation is unknown, fetch it\n log.trace(\n \"upsertConversation: creating a local conversation object with sid \" +\n sid,\n data\n );\n\n const baseLink = `${this.configuration.links.conversations}/${sid}`;\n const links = {\n self: baseLink,\n messages: `${baseLink}/Messages`,\n participants: `${baseLink}/Participants`,\n };\n const newConversation = new Conversation(\n data,\n sid,\n links,\n this.configuration,\n this.services\n );\n this.conversations.set(sid, newConversation);\n\n await newConversation._subscribe();\n this._registerForEvents(newConversation);\n this.emit(\"conversationAdded\", newConversation);\n\n if (data.status === \"joined\") {\n newConversation._setStatus(\"joined\", source);\n this.emit(\"conversationJoined\", newConversation);\n }\n\n return newConversation;\n }\n private async _fetchMyConversations(): Promise<ConversationRestData[]> {\n let conversations: ConversationRestData[] = [];\n let pageToken: null | string = null;\n\n do {\n const url = new UriBuilder(this.configuration.links.myConversations);\n\n if (pageToken) {\n url.arg(\"PageToken\", pageToken);\n }\n\n const response = await this.services.network.get<\n { conversations: ConversationResponse[] } & ResponseMeta\n >(url.build());\n const receivedConversations = response.body?.conversations.map(\n (conversationDescriptor) => ({\n descriptor: conversationDescriptor,\n channel_sid: conversationDescriptor.conversation_sid,\n status: conversationDescriptor.status,\n channel: conversationDescriptor.sync_objects.conversation,\n messages: conversationDescriptor.sync_objects.messages,\n roster: `${conversationDescriptor.conversation_sid}.roster`,\n lastConsumedMessageIndex:\n conversationDescriptor.last_read_message_index,\n notificationLevel: conversationDescriptor.notification_level,\n })\n );\n\n pageToken = response.body.meta.next_token;\n conversations = [...conversations, ...receivedConversations];\n } while (pageToken);\n\n return conversations;\n }\n\n private _onConversationRemoved(sid: string) {\n const conversation = this.conversations.get(sid);\n\n if (conversation) {\n this.conversations.delete(sid);\n this.emit(\"conversationRemoved\", conversation);\n }\n }\n\n private _registerForEvents(conversation) {\n conversation.on(\"removed\", () =>\n this._onConversationRemoved(conversation.sid)\n );\n conversation.on(\"updated\", (args: ConversationUpdatedEventArgs) =>\n this.emit(\"conversationUpdated\", args)\n );\n conversation.on(\"participantJoined\", (participant) =>\n this.emit(\"participantJoined\", participant)\n );\n conversation.on(\"participantLeft\", (participant) =>\n this.emit(\"participantLeft\", participant)\n );\n conversation.on(\"participantUpdated\", (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n conversation.on(\"messageAdded\", (message) =>\n this.emit(\"messageAdded\", message)\n );\n conversation.on(\"messageUpdated\", (args: MessageUpdatedEventArgs) =>\n this.emit(\"messageUpdated\", args)\n );\n conversation.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n conversation.on(\"typingStarted\", (participant) =>\n this.emit(\"typingStarted\", participant)\n );\n conversation.on(\"typingEnded\", (participant) =>\n this.emit(\"typingEnded\", participant)\n );\n }\n}\n\nexport {\n ConversationsServices,\n ConversationsDataSource,\n Conversation,\n Conversations,\n};\n"],"names":["Logger","ReplayEventEmitter","Deferred","conversation","Conversation","UriBuilder","isEqual"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAE1C;;;;AAIA,MAAM,aAAc,SAAQC,qCAAuC;IAQjE,YACE,aAA4B,EAC5B,QAA+B;QAE/B,KAAK,EAAE,CAAC;QAXM,kBAAa,GAA8B,IAAI,GAAG,EAAE,CAAC;QACrD,wBAAmB,GAAsB,IAAIC,iBAAQ,EAAE,CAAC;QAGvD,eAAU,GAAgB,IAAI,GAAG,EAAE,CAAC;QAC7C,2BAAsB,GAAG,KAAK,CAAC;QAQrC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;KAC1B;IAEM,MAAM,eAAe,CAAC,OAAO;;QAClC,MAAM,UAAU,GACd,QAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,CAAA,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC;QAEvE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAGjE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,EAAE;YAChD,aAAa,EA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,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,CACtC,CAAC;QACF,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,OAAO,KACtC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CACnC,CAAC;QACF,YAAY,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,IAA6B,KAC9D,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAClC,CAAC;QACF,YAAY,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,OAAO,KACxC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CACrC,CAAC;QACF,YAAY,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,WAAW,KAC3C,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CACxC,CAAC;QACF,YAAY,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,WAAW,KACzC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CACtC,CAAC;KACH;;;;;;"}
|
1
|
+
{"version":3,"file":"conversations.js","sources":["../../src/data/conversations.ts"],"sourcesContent":["import { Logger } from \"../logger\";\nimport {\n Conversation,\n ConversationDescriptor,\n ConversationUpdatedEventArgs,\n ConversationUpdateReason,\n} from \"../conversation\";\nimport { SyncMap, SyncClient, SyncMapItem } from \"twilio-sync\";\nimport { Users } from \"./users\";\nimport { Network } from \"../services/network\";\nimport { TypingIndicator } from \"../services/typing-indicator\";\nimport { McsClient } from \"@twilio/mcs-client\";\nimport { Deferred } from \"../util/deferred\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"../participant\";\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"../message\";\nimport { UriBuilder } from \"../util\";\nimport { Configuration } from \"../configuration\";\nimport { CommandExecutor } from \"../command-executor\";\nimport { CreateConversationRequest } from \"../interfaces/commands/create-conversation\";\nimport { ConversationResponse } from \"../interfaces/commands/conversation-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { ResponseMeta } from \"../interfaces/commands/response-meta\";\n\ntype ConversationsEvents = {\n conversationAdded: (conversation: Conversation) => void;\n conversationJoined: (conversation: Conversation) => void;\n conversationLeft: (conversation: Conversation) => void;\n conversationRemoved: (conversation: Conversation) => void;\n conversationUpdated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n};\n\ntype ConversationsDataSource = \"sync\" | \"rest\";\n\ninterface ConversationsServices {\n syncClient: SyncClient;\n users: Users;\n typingIndicator: TypingIndicator;\n network: Network;\n mcsClient: McsClient;\n commandExecutor: CommandExecutor;\n}\n\ntype ConversationRestData = {\n roster: string;\n notificationLevel: \"default\" | \"muted\";\n lastConsumedMessageIndex: number;\n channel: string;\n messages: string;\n descriptor: ConversationResponse;\n channel_sid: string;\n status: string;\n};\n\nconst log = Logger.scope(\"Conversations\");\n\n/**\n * Represents conversations collection\n * {@see Conversation}\n */\nclass Conversations extends ReplayEventEmitter<ConversationsEvents> {\n public readonly conversations: Map<string, Conversation> = new Map();\n public readonly myConversationsRead: Deferred<boolean> = new Deferred();\n private readonly configuration: Configuration;\n private readonly services: ConversationsServices;\n private readonly tombstones: Set<string> = new Set();\n private myConversationsFetched = false;\n\n public constructor(\n configuration: Configuration,\n services: ConversationsServices\n ) {\n super();\n\n this.configuration = configuration;\n this.services = services;\n }\n\n public async addConversation(options): Promise<Conversation> {\n const attributes =\n typeof options?.attributes !== \"undefined\" ? options.attributes : {};\n\n const response = await this.services.commandExecutor.mutateResource<\n CreateConversationRequest,\n ConversationResponse\n >(\"post\", this.configuration.links.conversations, {\n friendly_name: options.friendlyName,\n unique_name: options.uniqueName,\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n });\n\n const conversationSid = response.sid ?? null;\n const conversationDocument = response.sync_objects?.conversation ?? null;\n const links = {\n self: response.url,\n ...response.links,\n };\n const existingConversation = this.conversations.get(conversationSid);\n\n if (existingConversation) {\n await existingConversation._subscribe();\n return existingConversation;\n }\n\n const conversation = new Conversation(\n {\n channel: conversationDocument,\n entityName: \"\",\n uniqueName: \"\",\n attributes: null,\n createdBy: \"\",\n friendlyName: \"\",\n lastConsumedMessageIndex: 0,\n dateCreated: null,\n dateUpdated: null,\n },\n conversationSid,\n links,\n this.configuration,\n this.services\n );\n\n this.conversations.set(conversation.sid, conversation);\n this._registerForEvents(conversation);\n\n await conversation._subscribe();\n this.emit(\"conversationAdded\", conversation);\n\n return conversation;\n }\n\n /**\n * Fetch conversations list and instantiate all necessary objects\n */\n public async fetchConversations(): Promise<Conversations> {\n try {\n const map = await this._getMap();\n\n map.on(\"itemAdded\", (args) => {\n log.debug(`itemAdded: ${args.item.key}`);\n\n this._upsertConversation(\"sync\", args.item.key, args.item.data);\n });\n\n map.on(\"itemRemoved\", (args) => {\n log.debug(`itemRemoved: ${args.key}`);\n\n const sid = args.key;\n\n if (!this.myConversationsFetched) {\n this.tombstones.add(sid);\n }\n\n const conversation = this.conversations.get(sid);\n\n if (!conversation) {\n return;\n }\n\n if (conversation.status === \"joined\") {\n conversation._setStatus(\"notParticipating\", \"sync\");\n this.emit(\"conversationLeft\", conversation);\n }\n\n this.conversations.delete(sid);\n this.emit(\"conversationRemoved\", conversation);\n conversation.emit(\"removed\", conversation);\n });\n\n map.on(\"itemUpdated\", (args) => {\n log.debug(`itemUpdated: ${args.item.key}`);\n\n this._upsertConversation(\"sync\", args.item.key, args.item.data);\n });\n\n const myConversations: ConversationRestData[] =\n await this._fetchMyConversations();\n const upserts: Promise<Conversation | null>[] = [];\n\n for (const conversation of myConversations) {\n upserts.push(\n this._upsertConversation(\n \"rest\",\n conversation[\"channel_sid\"],\n conversation\n )\n );\n }\n\n this.myConversationsRead.set(true);\n\n await Promise.all(upserts);\n\n this.myConversationsFetched = true;\n this.tombstones.clear();\n\n log.debug(\"The conversations list has been successfully fetched\");\n\n return this;\n } catch (error) {\n const errorMessage = \"Failed to fetch the conversations list\";\n\n if (this.services.syncClient.connectionState !== \"disconnected\") {\n log.error(errorMessage, error);\n }\n\n log.debug(`ERROR: ${errorMessage}`, error);\n\n throw error;\n }\n }\n\n public async getConversations() {\n const conversationsMap = await this._getMap();\n const page = await conversationsMap.getItems();\n\n return this._wrapPaginator(page, (items) =>\n Promise.all(\n items.map((item: SyncMapItem) =>\n this._upsertConversation(\"sync\", item.key, item.data)\n )\n )\n );\n }\n\n public async getConversation(\n sid: string\n ): Promise<Conversation | undefined | null> {\n const conversationsMap = await this._getMap();\n const page = await conversationsMap.getItems({ key: sid });\n const items = page.items.map((item: SyncMapItem) =>\n this._upsertConversation(\"sync\", item.key, item.data)\n );\n\n return items.length > 0 ? items[0] : null;\n }\n\n public async getConversationByUniqueName(\n uniqueName: string\n ): Promise<Conversation | null> {\n const url = new UriBuilder(this.configuration.links.myConversations)\n .path(uniqueName)\n .build();\n const response = await this.services.network.get<ConversationResponse>(url);\n const body = response.body;\n\n const sid = body.conversation_sid;\n const data = {\n entityName: null,\n lastConsumedMessageIndex: body.last_read_message_index,\n status: body?.status || \"unknown\",\n friendlyName: body.friendly_name,\n dateUpdated: body.date_updated,\n dateCreated: body.date_created,\n uniqueName: body.unique_name,\n createdBy: body.created_by,\n attributes: body.attributes,\n channel: body.sync_objects.conversation,\n notificationLevel: body?.notification_level,\n sid,\n };\n\n return sid ? this._upsertConversation(\"sync\", sid, data) : null;\n }\n\n public async peekConversation(sid: string): Promise<Conversation | null> {\n const url = new UriBuilder(this.configuration.links.conversations)\n .path(sid)\n .build();\n const response = await this.services.network.get<ConversationResponse>(url);\n const body = response.body;\n\n const data = {\n entityName: null,\n // lastConsumedMessageIndex: body.last_read_message_index,\n status: body?.status || \"unknown\",\n friendlyName: body.friendly_name,\n dateUpdated: body.date_updated,\n dateCreated: body.date_created,\n uniqueName: body.unique_name,\n createdBy: body.created_by,\n attributes: body.attributes,\n channel: `${sid}.channel`,\n // notificationLevel: body?.notification_level,\n sid,\n };\n\n return this._upsertConversation(\"sync\", sid, data);\n }\n\n private async _getMap(): Promise<SyncMap> {\n return await this.services.syncClient.map({\n id: this.configuration.myConversations,\n mode: \"open_existing\",\n });\n }\n\n private async _wrapPaginator(page, op) {\n const items = await op(page.items);\n\n return {\n items,\n hasNextPage: page.hasNextPage,\n hasPrevPage: page.hasPrevPage,\n nextPage: () => page.nextPage().then((x) => this._wrapPaginator(x, op)),\n prevPage: () => page.prevPage().then((x) => this._wrapPaginator(x, op)),\n };\n }\n\n private async _updateConversation(\n source: ConversationsDataSource,\n conversation: Conversation,\n data\n ): Promise<void> {\n const areSourcesDifferent =\n conversation._statusSource !== undefined &&\n source !== conversation._statusSource;\n const isChannelSourceSync =\n source !== \"rest\" || conversation._statusSource === \"sync\";\n\n if (areSourcesDifferent && isChannelSourceSync && source !== \"sync\") {\n log.trace(\n \"upsertConversation: conversation is known from sync and came from REST, ignoring\",\n {\n sid: conversation.sid,\n data: data.status,\n conversation: conversation.status,\n }\n );\n\n return;\n }\n\n if (data.status === \"joined\" && conversation.status !== \"joined\") {\n conversation._setStatus(\"joined\", source);\n\n const updateData: Partial<ConversationDescriptor> = {};\n\n if (typeof data.notificationLevel !== \"undefined\") {\n updateData.notificationLevel = data.notificationLevel;\n }\n\n if (typeof data.lastConsumedMessageIndex !== \"undefined\") {\n updateData.lastConsumedMessageIndex = data.lastConsumedMessageIndex;\n }\n\n if (!isEqual(updateData, {})) {\n conversation._update(updateData);\n }\n\n await conversation._subscribe();\n this.emit(\"conversationJoined\", conversation);\n\n return;\n }\n\n if (\n data.status === \"notParticipating\" &&\n conversation.status === \"joined\"\n ) {\n conversation._setStatus(\"notParticipating\", source);\n conversation._update(data);\n\n await conversation._subscribe();\n this.emit(\"conversationLeft\", conversation);\n\n return;\n }\n\n if (data.status === \"notParticipating\") {\n await conversation._subscribe();\n\n return;\n }\n\n conversation._update(data);\n }\n\n private async _upsertConversation(\n source: ConversationsDataSource,\n sid: string,\n data\n ): Promise<Conversation | null> {\n log.trace(`upsertConversation called for ${sid}`, data);\n\n const conversation = this.conversations.get(sid);\n\n // If the channel is known, update it\n if (conversation) {\n log.trace(\n `upsertConversation: the conversation ${conversation.sid} is known;` +\n `its status is known from the source ${conversation._statusSource} ` +\n `and the update came from the source ${source}`,\n conversation\n );\n\n await this._updateConversation(source, conversation, data);\n await conversation._subscribe();\n\n return conversation;\n }\n\n // If the conversations is deleted, ignore it\n if (source === \"rest\" && this.tombstones.has(sid)) {\n log.trace(\n \"upsertChannel: the channel is deleted but reappeared again from REST, ignoring\",\n sid\n );\n return null;\n }\n\n // If the conversation is unknown, fetch it\n log.trace(\n \"upsertConversation: creating a local conversation object with sid \" +\n sid,\n data\n );\n\n const baseLink = `${this.configuration.links.conversations}/${sid}`;\n const links = {\n self: baseLink,\n messages: `${baseLink}/Messages`,\n participants: `${baseLink}/Participants`,\n };\n const newConversation = new Conversation(\n data,\n sid,\n links,\n this.configuration,\n this.services\n );\n this.conversations.set(sid, newConversation);\n\n await newConversation._subscribe();\n this._registerForEvents(newConversation);\n this.emit(\"conversationAdded\", newConversation);\n\n if (data.status === \"joined\") {\n newConversation._setStatus(\"joined\", source);\n this.emit(\"conversationJoined\", newConversation);\n }\n\n return newConversation;\n }\n private async _fetchMyConversations(): Promise<ConversationRestData[]> {\n let conversations: ConversationRestData[] = [];\n let pageToken: null | string = null;\n\n do {\n const url = new UriBuilder(this.configuration.links.myConversations);\n\n if (pageToken) {\n url.arg(\"PageToken\", pageToken);\n }\n\n const response = await this.services.network.get<\n { conversations: ConversationResponse[] } & ResponseMeta\n >(url.build());\n const receivedConversations = response.body?.conversations.map(\n (conversationDescriptor) => ({\n descriptor: conversationDescriptor,\n channel_sid: conversationDescriptor.conversation_sid,\n status: conversationDescriptor.status,\n channel: conversationDescriptor.sync_objects.conversation,\n messages: conversationDescriptor.sync_objects.messages,\n roster: `${conversationDescriptor.conversation_sid}.roster`,\n lastConsumedMessageIndex:\n conversationDescriptor.last_read_message_index,\n notificationLevel: conversationDescriptor.notification_level,\n })\n );\n\n pageToken = response.body.meta.next_token;\n conversations = [...conversations, ...receivedConversations];\n } while (pageToken);\n\n return conversations;\n }\n\n private _onConversationRemoved(sid: string) {\n const conversation = this.conversations.get(sid);\n\n if (conversation) {\n this.conversations.delete(sid);\n this.emit(\"conversationRemoved\", conversation);\n }\n }\n\n private _registerForEvents(conversation) {\n conversation.on(\"removed\", () =>\n this._onConversationRemoved(conversation.sid)\n );\n conversation.on(\"updated\", (args: ConversationUpdatedEventArgs) =>\n this.emit(\"conversationUpdated\", args)\n );\n conversation.on(\"participantJoined\", (participant) =>\n this.emit(\"participantJoined\", participant)\n );\n conversation.on(\"participantLeft\", (participant) =>\n this.emit(\"participantLeft\", participant)\n );\n conversation.on(\"participantUpdated\", (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n conversation.on(\"messageAdded\", (message) =>\n this.emit(\"messageAdded\", message)\n );\n conversation.on(\"messageUpdated\", (args: MessageUpdatedEventArgs) =>\n this.emit(\"messageUpdated\", args)\n );\n conversation.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n conversation.on(\"typingStarted\", (participant) =>\n this.emit(\"typingStarted\", participant)\n );\n conversation.on(\"typingEnded\", (participant) =>\n this.emit(\"typingEnded\", participant)\n );\n }\n}\n\nexport {\n ConversationsServices,\n ConversationsDataSource,\n Conversation,\n Conversations,\n};\n"],"names":["Logger","ReplayEventEmitter","Deferred","conversation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