@twilio/conversations 2.1.0-rc.5 → 2.1.0-rc.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/CHANGELOG.md +34 -0
- package/builds/browser.js +9 -7
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +36 -6
- package/builds/lib.js +9 -7
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +81 -64
- package/builds/twilio-conversations.min.js +2 -2
- package/dist/configuration.js.map +1 -1
- package/dist/conversation.js +3 -0
- package/dist/conversation.js.map +1 -1
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +4 -5
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +0 -117
- package/docs/classes/Client.html +0 -117
- package/docs/classes/Conversation.html +35 -129
- package/docs/classes/DetailedDeliveryReceipt.html +0 -117
- package/docs/classes/Media.html +0 -117
- package/docs/classes/Message.html +4 -121
- package/docs/classes/MessageBuilder.html +2 -119
- package/docs/classes/Participant.html +4 -121
- package/docs/classes/PushNotification.html +0 -117
- package/docs/classes/RestPaginator.html +0 -117
- package/docs/classes/UnsentMessage.html +0 -117
- package/docs/classes/User.html +4 -121
- package/docs/index.html +60 -0
- package/docs/interfaces/ClientOptions.html +0 -117
- package/docs/interfaces/ConversationBindings.html +0 -117
- package/docs/interfaces/ConversationEmailBinding.html +0 -117
- package/docs/interfaces/ConversationLimits.html +3098 -0
- package/docs/interfaces/ConversationState.html +0 -117
- package/docs/interfaces/CreateConversationOptions.html +1 -118
- package/docs/interfaces/LastMessage.html +0 -117
- package/docs/interfaces/Paginator.html +0 -117
- package/docs/interfaces/ParticipantBindings.html +0 -117
- package/docs/interfaces/ParticipantEmailBinding.html +0 -117
- package/docs/interfaces/PushNotificationData.html +0 -117
- package/docs/interfaces/SendEmailOptions.html +0 -117
- package/docs/interfaces/SendMediaOptions.html +0 -117
- package/docs/modules.html +60 -0
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"configuration.js","sources":["../src/configuration.ts"],"sourcesContent":["import { ConfigurationResponse } from \"./interfaces/commands/configuration\";\nimport { parse as parseDuration, toSeconds } from \"iso8601-duration\";\nimport { Logger } from \"./logger\";\nimport {
|
1
|
+
{"version":3,"file":"configuration.js","sources":["../src/configuration.ts"],"sourcesContent":["import { ConfigurationResponse } from \"./interfaces/commands/configuration\";\nimport { parse as parseDuration, toSeconds } from \"iso8601-duration\";\nimport { Logger } from \"./logger\";\nimport { ConversationLimits } from \"./interfaces/conversation-limits\";\nimport { ClientOptions } from \"./client\";\n\nconst TYPING_TIMEOUT = 5;\nconst HTTP_CACHE_LIFETIME = \"PT5S\";\nconst CONSUMPTION_HORIZON_SENDING_INTERVAL = \"PT5S\";\nconst USER_INFOS_TO_SUBSCRIBE = 100;\n\nconst MINIMUM_RETRY_DELAY = 1000;\nconst MAXIMUM_RETRY_DELAY = 4000;\nconst MAXIMUM_ATTEMPTS_COUNT = 3;\nconst RETRY_WHEN_THROTTLED = true;\n\ninterface BackoffConfiguration {\n min: number;\n max: number;\n maxAttemptsCount: number;\n}\n\nclass Configuration {\n public readonly links: {\n myConversations: string;\n conversations: string;\n users: string;\n currentUser: string;\n typing: string;\n mediaService: string;\n mediaSetService: string;\n messagesReceipts: string;\n };\n\n public readonly limits: ConversationLimits;\n\n public readonly productId?: string;\n\n public readonly typingIndicatorTimeoutOverride?: number;\n public readonly typingIndicatorTimeoutDefault: number = TYPING_TIMEOUT * 1000;\n public readonly backoffConfiguration: BackoffConfiguration;\n public readonly retryWhenThrottled: boolean;\n\n public readonly consumptionReportInterval: number;\n public readonly userInfosToSubscribe: number;\n public readonly httpCacheInterval: number;\n public readonly reachabilityEnabled: boolean;\n\n public readonly userIdentity: string;\n public readonly userInfo: string;\n public readonly myConversations: string;\n\n constructor(\n options: ClientOptions = {},\n configurationResponse: ConfigurationResponse,\n logger: Logger\n ) {\n const constructorOptions =\n options.Chat || options.IPMessaging || options || {};\n\n this.productId = constructorOptions.productId;\n\n this.links = {\n myConversations: configurationResponse.links.my_conversations,\n conversations: configurationResponse.links.conversations,\n users: configurationResponse.links.users,\n currentUser: configurationResponse.links.current_user,\n typing: configurationResponse.links.typing,\n mediaService: configurationResponse.links.media_service,\n mediaSetService: configurationResponse.links.media_set_service,\n messagesReceipts: configurationResponse.links.messages_receipts,\n };\n\n this.limits = {\n mediaAttachmentsCountLimit:\n configurationResponse.options.media_attachments_count_limit,\n mediaAttachmentSizeLimitInMb:\n configurationResponse.options.media_attachment_size_limit_in_mb,\n mediaAttachmentsTotalSizeLimitInMb:\n configurationResponse.options.media_attachments_total_size_limit_in_mb,\n emailHistoriesAllowedMimeTypes:\n configurationResponse.options.email_histories_allowed_mime_types,\n emailBodiesAllowedMimeTypes:\n configurationResponse.options.email_bodies_allowed_mime_types,\n };\n\n this.typingIndicatorTimeoutOverride =\n constructorOptions.typingIndicatorTimeoutOverride;\n this.backoffConfiguration = {\n min: MINIMUM_RETRY_DELAY,\n max: MAXIMUM_RETRY_DELAY,\n maxAttemptsCount: MAXIMUM_ATTEMPTS_COUNT,\n ...constructorOptions.backoffConfigOverride,\n };\n this.retryWhenThrottled =\n constructorOptions.retryWhenThrottledOverride !== undefined\n ? constructorOptions.retryWhenThrottledOverride\n : RETRY_WHEN_THROTTLED;\n this.userInfosToSubscribe =\n constructorOptions.userInfosToSubscribeOverride ??\n configurationResponse.options.user_infos_to_subscribe ??\n USER_INFOS_TO_SUBSCRIBE;\n this.reachabilityEnabled =\n configurationResponse.options.reachability_enabled;\n this.userIdentity = configurationResponse.identity;\n this.userInfo = configurationResponse.sync_objects.my_user_info;\n this.myConversations = configurationResponse.sync_objects.my_conversations;\n\n const httpCacheInterval =\n constructorOptions.httpCacheIntervalOverride ??\n configurationResponse.options.http_cache_interval ??\n HTTP_CACHE_LIFETIME;\n\n try {\n this.httpCacheInterval = toSeconds(parseDuration(httpCacheInterval));\n } catch {\n logger.error(\n `Failed to parse http cache interval ${httpCacheInterval}, using default value ${HTTP_CACHE_LIFETIME}`\n );\n this.httpCacheInterval = toSeconds(parseDuration(HTTP_CACHE_LIFETIME));\n }\n\n const consumptionReportInterval =\n constructorOptions.consumptionReportIntervalOverride ??\n configurationResponse.options.consumption_report_interval ??\n CONSUMPTION_HORIZON_SENDING_INTERVAL;\n\n try {\n this.consumptionReportInterval = toSeconds(\n parseDuration(consumptionReportInterval)\n );\n } catch {\n logger.error(\n `Failed to parse consumption report interval ${consumptionReportInterval}, using default value ${CONSUMPTION_HORIZON_SENDING_INTERVAL}`\n );\n this.consumptionReportInterval = toSeconds(\n parseDuration(CONSUMPTION_HORIZON_SENDING_INTERVAL)\n );\n }\n }\n}\n\nexport { Configuration };\n"],"names":["toSeconds","parseDuration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,oCAAoC,GAAG,MAAM,CAAC;AACpD,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAQlC,MAAM,aAAa;IA8BjB,YACE,UAAyB,EAAE,EAC3B,qBAA4C,EAC5C,MAAc;;QAhBA,kCAA6B,GAAW,cAAc,GAAG,IAAI,CAAC;QAkB5E,MAAM,kBAAkB,GACtB,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,IAAI,EAAE,CAAC;QAEvD,IAAI,C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
|
|
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 { Limits } from \"./interfaces/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 public get limits(): Limits {\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,cAAc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;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 { 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,cAAc,CAAC,CAAC;AAEzC,MAAM,aAAa,GAAG;IACpB,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,wBAAwB,EAAE,0BAA0B;IACpD,iBAAiB,EAAE,mBAAmB;IACtC,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IACxB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,SAAS,SAAS,CAAC,UAAU;IAC3B,IAAI;QACF,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;KAC7B;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAqKD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;;8DAIvD;AAODJ;IADCC,2CAAkB,CAAC,CAAC,QAAQ,EAAEI,gCAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;;;oDAgB7C;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"message-builder.js","sources":["../src/message-builder.ts"],"sourcesContent":["import {
|
1
|
+
{"version":3,"file":"message-builder.js","sources":["../src/message-builder.ts"],"sourcesContent":["import { ConversationLimits } from \"./interfaces/conversation-limits\";\nimport { SendMediaOptions } from \"./conversation\";\nimport { UnsentMessage } from \"./unsent-message\";\nimport { JSONValue } from \"./types\";\nimport { Messages } from \"./data/messages\";\n\n/**\n * Message builder. Allows the message to be built and sent via method chaining.\n *\n * Example:\n *\n * ```ts\n * await testConversation.prepareMessage()\n * .setBody('Hello!')\n * .setAttributes({foo: 'bar'})\n * .addMedia(media1)\n * .addMedia(media2)\n * .build()\n * .send();\n * ```\n */\nclass MessageBuilder {\n private readonly message: UnsentMessage;\n private emailBodies: Map<string, FormData | SendMediaOptions>;\n private emailHistories: Map<string, FormData | SendMediaOptions>;\n\n /**\n * @internal\n */\n constructor(\n private readonly limits: ConversationLimits,\n messagesEntity: Messages\n ) {\n this.message = new UnsentMessage(messagesEntity);\n this.emailBodies = new Map<string, FormData | SendMediaOptions>();\n this.emailHistories = new Map<string, FormData | SendMediaOptions>();\n }\n\n /**\n * Sets the message body.\n * @param text Contents of the body.\n */\n setBody(text: string): MessageBuilder {\n this.message.text = text;\n return this;\n }\n\n /**\n * Sets the message subject.\n * @param subject Contents of the subject.\n */\n setSubject(subject: string): MessageBuilder {\n this.message.emailOptions.subject = subject;\n return this;\n }\n\n /**\n * Sets the message attributes.\n * @param attributes Message attributes.\n */\n setAttributes(attributes: JSONValue): MessageBuilder {\n this.message.attributes = attributes;\n return this;\n }\n\n /**\n * Set email body with given MIME-type.\n * @param mimeType Format of the body to set (text/plain or text/html).\n * @param body Body payload in selected format.\n */\n setEmailBody(\n mimeType: string,\n body: FormData | SendMediaOptions\n ): MessageBuilder {\n this.emailBodies.set(mimeType, body);\n return this;\n }\n\n /**\n * Set email history with given MIME-type.\n * @param mimeType Format of the history to set (text/plain or text/html).\n * @param history History payload in selected format.\n */\n setEmailHistory(\n mimeType: string,\n history: FormData | SendMediaOptions\n ): MessageBuilder {\n this.emailHistories.set(mimeType, history);\n return this;\n }\n\n /**\n * Adds media to the message.\n * @param payload Media to add.\n */\n addMedia(payload: FormData | SendMediaOptions): MessageBuilder {\n if (typeof FormData === \"undefined\" && payload instanceof FormData) {\n throw new Error(\"Could not add FormData content whilst not in a browser\");\n }\n if (!(payload instanceof FormData)) {\n const mediaOptions = payload as SendMediaOptions;\n if (!mediaOptions.contentType || !mediaOptions.media) {\n throw new Error(\n \"Media content in SendMediaOptions must contain non-empty contentType and media\"\n );\n }\n }\n this.message.mediaContent.push([\"media\", payload]);\n return this;\n }\n\n /**\n * Builds the message, making it ready to be sent.\n */\n build(): UnsentMessage {\n this.emailBodies.forEach((_, key) => {\n if (!this.limits.emailBodiesAllowedMimeTypes.includes(key)) {\n throw new Error(`Unsupported email body MIME type ${key}`);\n }\n });\n this.emailHistories.forEach((_, key) => {\n if (!this.limits.emailHistoriesAllowedMimeTypes.includes(key)) {\n throw new Error(`Unsupported email history MIME type ${key}`);\n }\n });\n if (\n this.emailBodies.size > this.limits.emailBodiesAllowedMimeTypes.length\n ) {\n throw new Error(\n `Too many email bodies attached to the message (${this.emailBodies.size} > ${this.limits.emailBodiesAllowedMimeTypes.length})`\n );\n }\n if (\n this.emailHistories.size >\n this.limits.emailHistoriesAllowedMimeTypes.length\n ) {\n throw new Error(\n `Too many email histories attached to the message (${this.emailHistories.size} > ${this.limits.emailHistoriesAllowedMimeTypes.length})`\n );\n }\n\n if (\n this.message.mediaContent.length > this.limits.mediaAttachmentsCountLimit\n ) {\n throw new Error(\n `Too many media attachments in the message (${this.message.mediaContent.length} > ${this.limits.mediaAttachmentsCountLimit})`\n );\n }\n\n // @todo we don't know the sizes of the attachments in FormData\n // @todo insertion below makes build() method non-repeatable - probably move to UnsentMessage.send() or even sendV2()?\n\n this.emailBodies.forEach((body) => {\n this.message.mediaContent.push([\"body\", body]);\n });\n\n this.emailHistories.forEach((history) => {\n this.message.mediaContent.push([\"history\", history]);\n });\n\n return this.message;\n }\n\n private getPayloadContentType(\n payload: FormData | SendMediaOptions\n ): string | null {\n if (typeof FormData !== \"undefined\" && payload instanceof FormData) {\n return payload.get(\"Content-Type\") as string;\n }\n return (payload as SendMediaOptions).contentType;\n }\n}\n\nexport { MessageBuilder };\n"],"names":["UnsentMessage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;AAeA,MAAM,cAAc;;;;IAQlB,YACmB,MAA0B,EAC3C,cAAwB;QADP,WAAM,GAAN,MAAM,CAAoB;QAG3C,IAAI,CAAC,OAAO,GAAG,IAAIA,2BAAa,CAAC,cAAc,CAAC,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAuC,CAAC;QAClE,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAuC,CAAC;KACtE;;;;;IAMD,OAAO,CAAC,IAAY;QAClB,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;KACb;;;;;IAMD,UAAU,CAAC,OAAe;QACxB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC;QAC5C,OAAO,IAAI,CAAC;KACb;;;;;IAMD,aAAa,CAAC,UAAqB;QACjC,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;QACrC,OAAO,IAAI,CAAC;KACb;;;;;;IAOD,YAAY,CACV,QAAgB,EAChB,IAAiC;QAEjC,IAAI,CAAC,W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,CAAW,CAAC;SAC9C;QACD,OAAQ,OAA4B,CAAC,WAAW,CAAC;KAClD;;;;;"}
|
package/dist/message.js
CHANGED
@@ -269,8 +269,7 @@ class Message extends replayEventEmitter.ReplayEventEmitter {
|
|
269
269
|
* The server-assigned unique identifier of the authoring participant.
|
270
270
|
*/
|
271
271
|
get participantSid() {
|
272
|
-
|
273
|
-
return (_a = this.state.participantSid) !== null && _a !== void 0 ? _a : "";
|
272
|
+
return this.state.participantSid;
|
274
273
|
}
|
275
274
|
/**
|
276
275
|
* Aggregated information about the message delivery statuses across all participants of a conversation..
|
@@ -372,7 +371,7 @@ class Message extends replayEventEmitter.ReplayEventEmitter {
|
|
372
371
|
let participant = null;
|
373
372
|
if (this.state.participantSid) {
|
374
373
|
participant = await this.conversation
|
375
|
-
.getParticipantBySid(this.participantSid)
|
374
|
+
.getParticipantBySid(this.state.participantSid)
|
376
375
|
.catch(() => {
|
377
376
|
log.debug(`Participant with sid "${this.participantSid}" not found for message ${this.sid}`);
|
378
377
|
return null;
|
@@ -491,13 +490,13 @@ class Message extends replayEventEmitter.ReplayEventEmitter {
|
|
491
490
|
*/
|
492
491
|
Message.updated = "updated";
|
493
492
|
tslib_es6.__decorate([
|
494
|
-
declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString),
|
493
|
+
declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]),
|
495
494
|
tslib_es6.__metadata("design:type", Function),
|
496
495
|
tslib_es6.__metadata("design:paramtypes", [Object]),
|
497
496
|
tslib_es6.__metadata("design:returntype", media.Media)
|
498
497
|
], Message.prototype, "getEmailBody", null);
|
499
498
|
tslib_es6.__decorate([
|
500
|
-
declarativeTypeValidator.validateTypes(declarativeTypeValidator.nonEmptyString),
|
499
|
+
declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]),
|
501
500
|
tslib_es6.__metadata("design:type", Function),
|
502
501
|
tslib_es6.__metadata("design:paramtypes", [Object]),
|
503
502
|
tslib_es6.__metadata("design:returntype", media.Media)
|
package/dist/message.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"message.js","sources":["../src/message.ts"],"sourcesContent":["import { parseAttributes, UriBuilder } from \"./util\";\nimport { Logger } from \"./logger\";\nimport { Conversation } from \"./conversation\";\nimport { McsClient, MediaCategory } from \"@twilio/mcs-client\";\nimport { Media } from \"./media\";\nimport { Participant } from \"./participant\";\nimport {\n AggregatedDeliveryDescriptor,\n AggregatedDeliveryReceipt,\n} from \"./aggregated-delivery-receipt\";\nimport {\n validateTypes,\n validateTypesAsync,\n nonEmptyString,\n custom,\n} from \"@twilio/declarative-type-validator\";\nimport { attributesValidator } from \"./interfaces/attributes\";\nimport { Network } from \"./services/network\";\nimport { RestPaginator } from \"./rest-paginator\";\nimport { DetailedDeliveryReceipt } from \"./detailed-delivery-receipt\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { Configuration } from \"./configuration\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { EditMessageRequest } from \"./interfaces/commands/edit-message\";\nimport { MessageResponse } from \"./interfaces/commands/message-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"./types\";\nimport { ResponseMeta } from \"./interfaces/commands/response-meta\";\nimport { DeliveryReceiptResponse } from \"./interfaces/commands/delivery-receipt-response\";\n\ntype MessageEvents = {\n updated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope(\"Message\");\n\ninterface MessageState {\n sid: string;\n index: number;\n author: string | null;\n subject: string | null;\n body: string | null;\n dateUpdated: Date | null;\n lastUpdatedBy: string | null;\n attributes: JSONValue;\n timestamp: Date | null;\n type: MessageType;\n media: Media | null;\n medias: Media[] | null;\n participantSid: string | null;\n aggregatedDeliveryReceipt: AggregatedDeliveryReceipt | null;\n}\n\ninterface MessageServices {\n mcsClient: McsClient;\n network: Network;\n commandExecutor: CommandExecutor;\n}\n\ninterface MessageLinks {\n self: string;\n conversation: string;\n messages_receipts: string;\n}\n\n/**\n * The reason for the `updated` event being emitted by a message.\n */\ntype MessageUpdateReason =\n | \"body\"\n | \"lastUpdatedBy\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"attributes\"\n | \"author\"\n | \"deliveryReceipt\"\n | \"subject\";\n\n/**\n * Type of a message.\n */\ntype MessageType = \"text\" | \"media\";\n\ninterface MessageUpdatedEventArgs {\n message: Message;\n updateReasons: MessageUpdateReason[];\n}\n\nexport interface MessageData {\n sid: string;\n text?: string;\n type?: MessageType;\n author: string | null;\n subject: string | null;\n lastUpdatedBy?: string | null;\n attributes?: JSONValue;\n dateUpdated: string;\n timestamp?: string;\n medias?: Media[];\n media?: Media;\n memberSid?: string;\n delivery?: AggregatedDeliveryDescriptor;\n}\n\n/**\n * A message in a conversation.\n */\nclass Message extends ReplayEventEmitter<MessageEvents> {\n /**\n * Conversation that the message is in.\n */\n public readonly conversation: Conversation;\n\n private readonly links: MessageLinks;\n private readonly configuration: Configuration;\n private readonly services: MessageServices;\n\n private state: MessageState;\n\n /**\n * @internal\n */\n constructor(\n index: number,\n data: MessageData,\n conversation: Conversation,\n links: MessageLinks,\n configuration: Configuration,\n services: MessageServices\n ) {\n super();\n\n this.conversation = conversation;\n\n this.links = links;\n this.configuration = configuration;\n this.services = services;\n\n this.state = {\n sid: data.sid,\n index: index,\n author: data.author,\n subject: data.subject,\n body: data.text ?? null,\n timestamp: data.timestamp ? new Date(data.timestamp) : null,\n dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,\n lastUpdatedBy: data.lastUpdatedBy ?? null,\n attributes: parseAttributes(\n data.attributes,\n `Got malformed attributes for the message ${data.sid}`,\n log\n ),\n type: data.type ?? \"text\",\n media:\n data.type && data.type === \"media\" && data.media\n ? new Media(data.media, this.services)\n : null,\n medias:\n data.type && data.type === \"media\" && data.medias\n ? data.medias.map((m) => new Media(m, this.services))\n : null,\n participantSid: data.memberSid ?? null,\n aggregatedDeliveryReceipt: data.delivery\n ? new AggregatedDeliveryReceipt(data.delivery)\n : null,\n };\n }\n\n /**\n * Fired when the properties or the body of the 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 - the message in question\n * * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update\n */\n static readonly updated = \"updated\";\n\n /**\n * The server-assigned unique identifier for the message.\n */\n public get sid(): string {\n return this.state.sid;\n }\n\n /**\n * Name of the user that sent the message.\n */\n public get author(): string | null {\n return this.state.author;\n }\n\n /**\n * Message subject. Used only in email conversations.\n */\n public get subject(): string | null {\n return this.state.subject;\n }\n\n /**\n * Body of the message.\n */\n public get body(): string | null {\n return this.state.body;\n }\n\n /**\n * Date this message was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this.state.dateUpdated;\n }\n\n /**\n * Index of the message in the conversation's messages list.\n * By design of the Conversations system, the message indices may have arbitrary gaps between them,\n * that does not necessarily mean they were deleted or otherwise modified - just that\n * messages may have some non-contiguous indices even if they are being sent immediately one after another.\n *\n * Trying to use indices for some calculations is going to be unreliable.\n *\n * To calculate the number of unread messages it is better to use the read horizon API.\n * See {@link Conversation.getUnreadMessagesCount} for details.\n */\n public get index(): number {\n return this.state.index;\n }\n\n /**\n * Identity of the last user that updated the message.\n */\n public get lastUpdatedBy(): string | null {\n return this.state.lastUpdatedBy;\n }\n\n /**\n * Date this message was created on.\n */\n public get dateCreated(): Date | null {\n return this.state.timestamp;\n }\n\n /**\n * Custom attributes of the message.\n */\n public get attributes(): JSONValue {\n return this.state.attributes;\n }\n\n /**\n * Type of the message.\n */\n public get type(): MessageType {\n return this.state.type;\n }\n\n /**\n * One of the attached media (if present).\n * @deprecated Use attachedMedia instead. Note that the latter is now an array.\n */\n public get media(): Media | null {\n return this.state.media;\n }\n\n /**\n * Return all media attachments, except email body/history attachments, without temporary urls.\n */\n public get attachedMedia(): Array<Media> | null {\n return this.getMediaByCategory([\"media\"]);\n }\n\n /**\n * The server-assigned unique identifier of the authoring participant.\n */\n public get participantSid(): string {\n return this.state.participantSid ?? \"\";\n }\n\n /**\n * Aggregated information about the message delivery statuses across all participants of a conversation..\n */\n public get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null {\n return this.state.aggregatedDeliveryReceipt;\n }\n\n /**\n * Return a (possibly empty) array of media matching a specific set of categories.\n * Allowed category is so far only 'media'.\n * @param categories Array of categories to match.\n * @returns Array of media descriptors matching given categories.\n */\n public getMediaByCategory(\n categories: Array<MediaCategory>\n ): Array<Media> | null {\n return (this.state.medias ?? []).filter((m) =>\n categories.includes(m.category)\n );\n }\n\n /**\n * Get a media descriptor for an email body attachment of a provided type.\n * Allowed body types are returned in the Conversation.limits().emailBodiesAllowedMimeTypes array.\n * @param type Type of email body to request, defaults to `text/plain`.\n */\n @validateTypes(nonEmptyString)\n public getEmailBody(type = \"text/plain\"): Media | null {\n return (\n this.getMediaByCategory([\"body\"])\n ?.filter((m) => m.contentType == type)\n .shift() ?? null\n );\n }\n\n /**\n * Get a media descriptor for an email history attachment of a provided type.\n * Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedMimeTypes array.\n * @param type Type of email history to request, defaults to `text/plain`.\n */\n @validateTypes(nonEmptyString)\n public getEmailHistory(type = \"text/plain\"): Media | null {\n return (\n this.getMediaByCategory([\"history\"])\n ?.filter((m) => m.contentType == type)\n .shift() ?? null\n );\n }\n\n _update(data) {\n const updateReasons: MessageUpdateReason[] = [];\n\n if (\n (data.text || typeof data.text === \"string\") &&\n data.text !== this.state.body\n ) {\n this.state.body = data.text;\n updateReasons.push(\"body\");\n }\n\n if (data.subject && data.subject !== this.state.subject) {\n this.state.subject = data.subject;\n updateReasons.push(\"subject\");\n }\n\n if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {\n this.state.lastUpdatedBy = data.lastUpdatedBy;\n updateReasons.push(\"lastUpdatedBy\");\n }\n\n if (data.author && data.author !== this.state.author) {\n this.state.author = data.author;\n updateReasons.push(\"author\");\n }\n\n if (\n data.dateUpdated &&\n new Date(data.dateUpdated).getTime() !==\n (this.state.dateUpdated && this.state.dateUpdated.getTime())\n ) {\n this.state.dateUpdated = new Date(data.dateUpdated);\n updateReasons.push(\"dateUpdated\");\n }\n\n if (\n data.timestamp &&\n new Date(data.timestamp).getTime() !==\n (this.state.timestamp && this.state.timestamp.getTime())\n ) {\n this.state.timestamp = new Date(data.timestamp);\n updateReasons.push(\"dateCreated\");\n }\n\n const updatedAttributes = parseAttributes(\n data.attributes,\n `Got malformed attributes for the message ${this.sid}`,\n log\n );\n if (!isEqual(this.state.attributes, updatedAttributes)) {\n this.state.attributes = updatedAttributes;\n updateReasons.push(\"attributes\");\n }\n\n const updatedAggregatedDelivery = data.delivery;\n const currentAggregatedDelivery = this.state.aggregatedDeliveryReceipt;\n const isUpdatedAggregateDeliveryValid =\n !!updatedAggregatedDelivery &&\n !!updatedAggregatedDelivery.total &&\n !!updatedAggregatedDelivery.delivered &&\n !!updatedAggregatedDelivery.failed &&\n !!updatedAggregatedDelivery.read &&\n !!updatedAggregatedDelivery.sent &&\n !!updatedAggregatedDelivery.undelivered;\n if (isUpdatedAggregateDeliveryValid) {\n if (!currentAggregatedDelivery) {\n this.state.aggregatedDeliveryReceipt = new AggregatedDeliveryReceipt(\n updatedAggregatedDelivery\n );\n updateReasons.push(\"deliveryReceipt\");\n } else if (\n !currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)\n ) {\n currentAggregatedDelivery._update(updatedAggregatedDelivery);\n updateReasons.push(\"deliveryReceipt\");\n }\n }\n\n if (updateReasons.length > 0) {\n this.emit(\"updated\", { message: this, updateReasons: updateReasons });\n }\n }\n\n /**\n * Get the participant who is the author of the message.\n */\n public async getParticipant(): Promise<Participant> {\n let participant: Participant | null = null;\n if (this.state.participantSid) {\n participant = await this.conversation\n .getParticipantBySid(this.participantSid)\n .catch(() => {\n log.debug(\n `Participant with sid \"${this.participantSid}\" not found for message ${this.sid}`\n );\n return null;\n });\n }\n if (!participant && this.state.author) {\n participant = await this.conversation\n .getParticipantByIdentity(this.state.author)\n .catch(() => {\n log.debug(\n `Participant with identity \"${this.author}\" not found for message ${this.sid}`\n );\n return null;\n });\n }\n if (participant) {\n return participant;\n }\n let errorMesage = \"Participant with \";\n if (this.state.participantSid) {\n errorMesage += \"SID '\" + this.state.participantSid + \"' \";\n }\n if (this.state.author) {\n if (this.state.participantSid) {\n errorMesage += \"or \";\n }\n errorMesage += \"identity '\" + this.state.author + \"' \";\n }\n if (errorMesage === \"Participant with \") {\n errorMesage = \"Participant \";\n }\n errorMesage += \"was not found\";\n throw new Error(errorMesage);\n }\n\n /**\n * Get the delivery receipts of the message.\n */\n public async getDetailedDeliveryReceipts(): Promise<\n DetailedDeliveryReceipt[]\n > {\n let paginator: Paginator<DetailedDeliveryReceipt> =\n await this._getDetailedDeliveryReceiptsPaginator();\n let detailedDeliveryReceipts: DetailedDeliveryReceipt[] = [];\n\n while (true) {\n detailedDeliveryReceipts = [\n ...detailedDeliveryReceipts,\n ...paginator.items,\n ];\n\n if (!paginator.hasNextPage) {\n break;\n }\n\n paginator = await paginator.nextPage();\n }\n\n return detailedDeliveryReceipts;\n }\n\n /**\n * Remove the message.\n */\n public async remove(): Promise<Message> {\n await this.services.commandExecutor.mutateResource(\n \"delete\",\n this.links.self\n );\n\n return this;\n }\n\n /**\n * Edit the message body.\n * @param body New body of the message.\n */\n @validateTypesAsync(\"string\")\n public async updateBody(body: string): Promise<Message> {\n await this.services.commandExecutor.mutateResource<\n EditMessageRequest,\n MessageResponse\n >(\"post\", this.links.self, {\n body,\n });\n\n return this;\n }\n\n /**\n * Edit the message attributes.\n * @param attributes New attributes.\n */\n @validateTypesAsync(attributesValidator)\n public async updateAttributes(attributes: JSONValue): Promise<Message> {\n await this.services.commandExecutor.mutateResource<\n EditMessageRequest,\n MessageResponse\n >(\"post\", this.links.self, {\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n });\n\n return this;\n }\n\n /**\n * Get content URLs for all media attachments in the given set using single operation.\n * @param contentSet Set of media attachments to query for content URL.\n */\n @validateTypesAsync(\n custom((value) => [\n value instanceof Array &&\n value.length > 0 &&\n value.reduce((a, c) => a && c instanceof Media, true),\n \"a non-empty array of Media\",\n ])\n )\n public async attachTemporaryUrlsFor(\n contentSet: Media[] | null\n ): Promise<Media[]> {\n // We ignore existing mcsMedia members of each of the media entries.\n // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.\n const sids = contentSet?.map((m) => m.sid);\n if (this.services.mcsClient && sids) {\n return (await this.services.mcsClient.mediaSetGet(sids)).map((item) => {\n return new Media(item, this.services);\n });\n } else {\n throw new Error(\"Media Content Service is unavailable\");\n }\n }\n\n private async _getDetailedDeliveryReceiptsPaginator(options?: {\n pageToken?: string;\n pageSize?: number;\n }): Promise<Paginator<DetailedDeliveryReceipt>> {\n const messagesReceiptsUrl = this.configuration.links.messagesReceipts\n .replace(\"%s\", this.conversation.sid)\n .replace(\"%s\", this.sid);\n const url = new UriBuilder(messagesReceiptsUrl)\n .arg(\"PageToken\", options?.pageToken as string)\n .arg(\"PageSize\", options?.pageSize as number)\n .build();\n const response = await this.services.network.get<\n { delivery_receipts: DeliveryReceiptResponse[] } & ResponseMeta\n >(url);\n\n return new RestPaginator<DetailedDeliveryReceipt>(\n response.body.delivery_receipts.map(\n (x) => new DetailedDeliveryReceipt(x)\n ),\n (pageToken, pageSize) =>\n this._getDetailedDeliveryReceiptsPaginator({ pageToken, pageSize }),\n response.body.meta.previous_token,\n response.body.meta.next_token\n );\n }\n}\n\nexport {\n Message,\n MessageServices,\n MessageType,\n MessageUpdateReason,\n MessageUpdatedEventArgs,\n};\n"],"names":["Logger","ReplayEventEmitter","index","parseAttributes","Media","AggregatedDeliveryReceipt","isEqual","UriBuilder","RestPaginator","DetailedDeliveryReceipt","__decorate","validateTypes","nonEmptyString","validateTypesAsync","attributesValidator","custom"],"mappings":";;;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,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAE9C,GAAG,CAAC,CAAC;QAEP,OAAO,IAAIC,2BAAa,CACtB,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CACjC,CAAC,CAAC,KAAK,IAAIC,+CAAuB,CAAC,CAAC,CAAC,CACtC,EACD,CAAC,SAAS,EAAE,QAAQ,KAClB,IAAI,CAAC,qCAAqC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EACrE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EACjC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAC9B,CAAC;KACH;;AA3ZD;;;;;;;;AAQgB,eAAO,GAAG,SAAS,CAAC;AAiIpCC;IADCC,sCAAa,CAACC,uCAAc,CAAC;;;8CACYR,WAAK;2CAM9C;AAQDM;IADCC,sCAAa,CAACC,uCAAc,CAAC;;;8CACeR,WAAK;8CAMjD;AA6KDM;IADCG,2CAAkB,CAAC,QAAQ,CAAC;;;;yCAU5B;AAODH;IADCG,2CAAkB,CAACC,8BAAmB,CAAC;;;;+CAavC;AAcDJ;IARCG,2CAAkB,CACjBE,+BAAM,CAAC,CAAC,KAAK,KAAK;QAChB,KAAK,YAAY,KAAK;YACpB,KAAK,CAAC,MAAM,GAAG,CAAC;YAChB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,YAAYX,WAAK,EAAE,IAAI,CAAC;QACvD,4BAA4B;KAC7B,CAAC,CACH;;;;qDAcA;;;;"}
|
1
|
+
{"version":3,"file":"message.js","sources":["../src/message.ts"],"sourcesContent":["import { parseAttributes, UriBuilder } from \"./util\";\nimport { Logger } from \"./logger\";\nimport { Conversation } from \"./conversation\";\nimport { McsClient, MediaCategory } from \"@twilio/mcs-client\";\nimport { Media } from \"./media\";\nimport { Participant } from \"./participant\";\nimport {\n AggregatedDeliveryDescriptor,\n AggregatedDeliveryReceipt,\n} from \"./aggregated-delivery-receipt\";\nimport {\n validateTypes,\n validateTypesAsync,\n nonEmptyString,\n custom,\n} from \"@twilio/declarative-type-validator\";\nimport { attributesValidator } from \"./interfaces/attributes\";\nimport { Network } from \"./services/network\";\nimport { RestPaginator } from \"./rest-paginator\";\nimport { DetailedDeliveryReceipt } from \"./detailed-delivery-receipt\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { Configuration } from \"./configuration\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { EditMessageRequest } from \"./interfaces/commands/edit-message\";\nimport { MessageResponse } from \"./interfaces/commands/message-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"./types\";\nimport { ResponseMeta } from \"./interfaces/commands/response-meta\";\nimport { DeliveryReceiptResponse } from \"./interfaces/commands/delivery-receipt-response\";\n\ntype MessageEvents = {\n updated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope(\"Message\");\n\ninterface MessageState {\n sid: string;\n index: number;\n author: string | null;\n subject: string | null;\n body: string | null;\n dateUpdated: Date | null;\n lastUpdatedBy: string | null;\n attributes: JSONValue;\n timestamp: Date | null;\n type: MessageType;\n media: Media | null;\n medias: Media[] | null;\n participantSid: string | null;\n aggregatedDeliveryReceipt: AggregatedDeliveryReceipt | null;\n}\n\ninterface MessageServices {\n mcsClient: McsClient;\n network: Network;\n commandExecutor: CommandExecutor;\n}\n\ninterface MessageLinks {\n self: string;\n conversation: string;\n messages_receipts: string;\n}\n\n/**\n * The reason for the `updated` event being emitted by a message.\n */\ntype MessageUpdateReason =\n | \"body\"\n | \"lastUpdatedBy\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"attributes\"\n | \"author\"\n | \"deliveryReceipt\"\n | \"subject\";\n\n/**\n * Type of a message.\n */\ntype MessageType = \"text\" | \"media\";\n\ninterface MessageUpdatedEventArgs {\n message: Message;\n updateReasons: MessageUpdateReason[];\n}\n\nexport interface MessageData {\n sid: string;\n text?: string;\n type?: MessageType;\n author: string | null;\n subject: string | null;\n lastUpdatedBy?: string | null;\n attributes?: JSONValue;\n dateUpdated: string;\n timestamp?: string;\n medias?: Media[];\n media?: Media;\n memberSid?: string;\n delivery?: AggregatedDeliveryDescriptor;\n}\n\n/**\n * A message in a conversation.\n */\nclass Message extends ReplayEventEmitter<MessageEvents> {\n /**\n * Conversation that the message is in.\n */\n public readonly conversation: Conversation;\n\n private readonly links: MessageLinks;\n private readonly configuration: Configuration;\n private readonly services: MessageServices;\n\n private state: MessageState;\n\n /**\n * @internal\n */\n constructor(\n index: number,\n data: MessageData,\n conversation: Conversation,\n links: MessageLinks,\n configuration: Configuration,\n services: MessageServices\n ) {\n super();\n\n this.conversation = conversation;\n\n this.links = links;\n this.configuration = configuration;\n this.services = services;\n\n this.state = {\n sid: data.sid,\n index: index,\n author: data.author,\n subject: data.subject,\n body: data.text ?? null,\n timestamp: data.timestamp ? new Date(data.timestamp) : null,\n dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,\n lastUpdatedBy: data.lastUpdatedBy ?? null,\n attributes: parseAttributes(\n data.attributes,\n `Got malformed attributes for the message ${data.sid}`,\n log\n ),\n type: data.type ?? \"text\",\n media:\n data.type && data.type === \"media\" && data.media\n ? new Media(data.media, this.services)\n : null,\n medias:\n data.type && data.type === \"media\" && data.medias\n ? data.medias.map((m) => new Media(m, this.services))\n : null,\n participantSid: data.memberSid ?? null,\n aggregatedDeliveryReceipt: data.delivery\n ? new AggregatedDeliveryReceipt(data.delivery)\n : null,\n };\n }\n\n /**\n * Fired when the properties or the body of the 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 - the message in question\n * * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update\n */\n static readonly updated = \"updated\";\n\n /**\n * The server-assigned unique identifier for the message.\n */\n public get sid(): string {\n return this.state.sid;\n }\n\n /**\n * Name of the user that sent the message.\n */\n public get author(): string | null {\n return this.state.author;\n }\n\n /**\n * Message subject. Used only in email conversations.\n */\n public get subject(): string | null {\n return this.state.subject;\n }\n\n /**\n * Body of the message.\n */\n public get body(): string | null {\n return this.state.body;\n }\n\n /**\n * Date this message was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this.state.dateUpdated;\n }\n\n /**\n * Index of the message in the conversation's messages list.\n * By design of the Conversations system, the message indices may have arbitrary gaps between them,\n * that does not necessarily mean they were deleted or otherwise modified - just that\n * messages may have some non-contiguous indices even if they are being sent immediately one after another.\n *\n * Trying to use indices for some calculations is going to be unreliable.\n *\n * To calculate the number of unread messages it is better to use the read horizon API.\n * See {@link Conversation.getUnreadMessagesCount} for details.\n */\n public get index(): number {\n return this.state.index;\n }\n\n /**\n * Identity of the last user that updated the message.\n */\n public get lastUpdatedBy(): string | null {\n return this.state.lastUpdatedBy;\n }\n\n /**\n * Date this message was created on.\n */\n public get dateCreated(): Date | null {\n return this.state.timestamp;\n }\n\n /**\n * Custom attributes of the message.\n */\n public get attributes(): JSONValue {\n return this.state.attributes;\n }\n\n /**\n * Type of the message.\n */\n public get type(): MessageType {\n return this.state.type;\n }\n\n /**\n * One of the attached media (if present).\n * @deprecated Use attachedMedia instead. Note that the latter is now an array.\n */\n public get media(): Media | null {\n return this.state.media;\n }\n\n /**\n * Return all media attachments, except email body/history attachments, without temporary urls.\n */\n public get attachedMedia(): Array<Media> | null {\n return this.getMediaByCategory([\"media\"]);\n }\n\n /**\n * The server-assigned unique identifier of the authoring participant.\n */\n public get participantSid(): string | null {\n return this.state.participantSid;\n }\n\n /**\n * Aggregated information about the message delivery statuses across all participants of a conversation..\n */\n public get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null {\n return this.state.aggregatedDeliveryReceipt;\n }\n\n /**\n * Return a (possibly empty) array of media matching a specific set of categories.\n * Allowed category is so far only 'media'.\n * @param categories Array of categories to match.\n * @returns Array of media descriptors matching given categories.\n */\n public getMediaByCategory(\n categories: Array<MediaCategory>\n ): Array<Media> | null {\n return (this.state.medias ?? []).filter((m) =>\n categories.includes(m.category)\n );\n }\n\n /**\n * Get a media descriptor for an email body attachment of a provided type.\n * Allowed body types are returned in the Conversation.limits().emailBodiesAllowedMimeTypes array.\n * @param type Type of email body to request, defaults to `text/plain`.\n */\n @validateTypes([nonEmptyString, \"undefined\"])\n public getEmailBody(type = \"text/plain\"): Media | null {\n return (\n this.getMediaByCategory([\"body\"])\n ?.filter((m) => m.contentType == type)\n .shift() ?? null\n );\n }\n\n /**\n * Get a media descriptor for an email history attachment of a provided type.\n * Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedMimeTypes array.\n * @param type Type of email history to request, defaults to `text/plain`.\n */\n @validateTypes([nonEmptyString, \"undefined\"])\n public getEmailHistory(type = \"text/plain\"): Media | null {\n return (\n this.getMediaByCategory([\"history\"])\n ?.filter((m) => m.contentType == type)\n .shift() ?? null\n );\n }\n\n _update(data) {\n const updateReasons: MessageUpdateReason[] = [];\n\n if (\n (data.text || typeof data.text === \"string\") &&\n data.text !== this.state.body\n ) {\n this.state.body = data.text;\n updateReasons.push(\"body\");\n }\n\n if (data.subject && data.subject !== this.state.subject) {\n this.state.subject = data.subject;\n updateReasons.push(\"subject\");\n }\n\n if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {\n this.state.lastUpdatedBy = data.lastUpdatedBy;\n updateReasons.push(\"lastUpdatedBy\");\n }\n\n if (data.author && data.author !== this.state.author) {\n this.state.author = data.author;\n updateReasons.push(\"author\");\n }\n\n if (\n data.dateUpdated &&\n new Date(data.dateUpdated).getTime() !==\n (this.state.dateUpdated && this.state.dateUpdated.getTime())\n ) {\n this.state.dateUpdated = new Date(data.dateUpdated);\n updateReasons.push(\"dateUpdated\");\n }\n\n if (\n data.timestamp &&\n new Date(data.timestamp).getTime() !==\n (this.state.timestamp && this.state.timestamp.getTime())\n ) {\n this.state.timestamp = new Date(data.timestamp);\n updateReasons.push(\"dateCreated\");\n }\n\n const updatedAttributes = parseAttributes(\n data.attributes,\n `Got malformed attributes for the message ${this.sid}`,\n log\n );\n if (!isEqual(this.state.attributes, updatedAttributes)) {\n this.state.attributes = updatedAttributes;\n updateReasons.push(\"attributes\");\n }\n\n const updatedAggregatedDelivery = data.delivery;\n const currentAggregatedDelivery = this.state.aggregatedDeliveryReceipt;\n const isUpdatedAggregateDeliveryValid =\n !!updatedAggregatedDelivery &&\n !!updatedAggregatedDelivery.total &&\n !!updatedAggregatedDelivery.delivered &&\n !!updatedAggregatedDelivery.failed &&\n !!updatedAggregatedDelivery.read &&\n !!updatedAggregatedDelivery.sent &&\n !!updatedAggregatedDelivery.undelivered;\n if (isUpdatedAggregateDeliveryValid) {\n if (!currentAggregatedDelivery) {\n this.state.aggregatedDeliveryReceipt = new AggregatedDeliveryReceipt(\n updatedAggregatedDelivery\n );\n updateReasons.push(\"deliveryReceipt\");\n } else if (\n !currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)\n ) {\n currentAggregatedDelivery._update(updatedAggregatedDelivery);\n updateReasons.push(\"deliveryReceipt\");\n }\n }\n\n if (updateReasons.length > 0) {\n this.emit(\"updated\", { message: this, updateReasons: updateReasons });\n }\n }\n\n /**\n * Get the participant who is the author of the message.\n */\n public async getParticipant(): Promise<Participant> {\n let participant: Participant | null = null;\n if (this.state.participantSid) {\n participant = await this.conversation\n .getParticipantBySid(this.state.participantSid)\n .catch(() => {\n log.debug(\n `Participant with sid \"${this.participantSid}\" not found for message ${this.sid}`\n );\n return null;\n });\n }\n if (!participant && this.state.author) {\n participant = await this.conversation\n .getParticipantByIdentity(this.state.author)\n .catch(() => {\n log.debug(\n `Participant with identity \"${this.author}\" not found for message ${this.sid}`\n );\n return null;\n });\n }\n if (participant) {\n return participant;\n }\n let errorMesage = \"Participant with \";\n if (this.state.participantSid) {\n errorMesage += \"SID '\" + this.state.participantSid + \"' \";\n }\n if (this.state.author) {\n if (this.state.participantSid) {\n errorMesage += \"or \";\n }\n errorMesage += \"identity '\" + this.state.author + \"' \";\n }\n if (errorMesage === \"Participant with \") {\n errorMesage = \"Participant \";\n }\n errorMesage += \"was not found\";\n throw new Error(errorMesage);\n }\n\n /**\n * Get the delivery receipts of the message.\n */\n public async getDetailedDeliveryReceipts(): Promise<\n DetailedDeliveryReceipt[]\n > {\n let paginator: Paginator<DetailedDeliveryReceipt> =\n await this._getDetailedDeliveryReceiptsPaginator();\n let detailedDeliveryReceipts: DetailedDeliveryReceipt[] = [];\n\n while (true) {\n detailedDeliveryReceipts = [\n ...detailedDeliveryReceipts,\n ...paginator.items,\n ];\n\n if (!paginator.hasNextPage) {\n break;\n }\n\n paginator = await paginator.nextPage();\n }\n\n return detailedDeliveryReceipts;\n }\n\n /**\n * Remove the message.\n */\n public async remove(): Promise<Message> {\n await this.services.commandExecutor.mutateResource(\n \"delete\",\n this.links.self\n );\n\n return this;\n }\n\n /**\n * Edit the message body.\n * @param body New body of the message.\n */\n @validateTypesAsync(\"string\")\n public async updateBody(body: string): Promise<Message> {\n await this.services.commandExecutor.mutateResource<\n EditMessageRequest,\n MessageResponse\n >(\"post\", this.links.self, {\n body,\n });\n\n return this;\n }\n\n /**\n * Edit the message attributes.\n * @param attributes New attributes.\n */\n @validateTypesAsync(attributesValidator)\n public async updateAttributes(attributes: JSONValue): Promise<Message> {\n await this.services.commandExecutor.mutateResource<\n EditMessageRequest,\n MessageResponse\n >(\"post\", this.links.self, {\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n });\n\n return this;\n }\n\n /**\n * Get content URLs for all media attachments in the given set using single operation.\n * @param contentSet Set of media attachments to query for content URL.\n */\n @validateTypesAsync(\n custom((value) => [\n value instanceof Array &&\n value.length > 0 &&\n value.reduce((a, c) => a && c instanceof Media, true),\n \"a non-empty array of Media\",\n ])\n )\n public async attachTemporaryUrlsFor(\n contentSet: Media[] | null\n ): Promise<Media[]> {\n // We ignore existing mcsMedia members of each of the media entries.\n // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.\n const sids = contentSet?.map((m) => m.sid);\n if (this.services.mcsClient && sids) {\n return (await this.services.mcsClient.mediaSetGet(sids)).map((item) => {\n return new Media(item, this.services);\n });\n } else {\n throw new Error(\"Media Content Service is unavailable\");\n }\n }\n\n private async _getDetailedDeliveryReceiptsPaginator(options?: {\n pageToken?: string;\n pageSize?: number;\n }): Promise<Paginator<DetailedDeliveryReceipt>> {\n const messagesReceiptsUrl = this.configuration.links.messagesReceipts\n .replace(\"%s\", this.conversation.sid)\n .replace(\"%s\", this.sid);\n const url = new UriBuilder(messagesReceiptsUrl)\n .arg(\"PageToken\", options?.pageToken as string)\n .arg(\"PageSize\", options?.pageSize as number)\n .build();\n const response = await this.services.network.get<\n { delivery_receipts: DeliveryReceiptResponse[] } & ResponseMeta\n >(url);\n\n return new RestPaginator<DetailedDeliveryReceipt>(\n response.body.delivery_receipts.map(\n (x) => new DetailedDeliveryReceipt(x)\n ),\n (pageToken, pageSize) =>\n this._getDetailedDeliveryReceiptsPaginator({ pageToken, pageSize }),\n response.body.meta.previous_token,\n response.body.meta.next_token\n );\n }\n}\n\nexport {\n Message,\n MessageServices,\n MessageType,\n MessageUpdateReason,\n MessageUpdatedEventArgs,\n};\n"],"names":["Logger","ReplayEventEmitter","index","parseAttributes","Media","AggregatedDeliveryReceipt","isEqual","UriBuilder","RestPaginator","DetailedDeliveryReceipt","__decorate","validateTypes","nonEmptyString","validateTypesAsync","attributesValidator","custom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAsEpC;;;AAGA,MAAM,OAAQ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CAAC,qCAAqC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EACrE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EACjC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAC9B,CAAC;KACH;;AA3ZD;;;;;;;;AAQgB,eAAO,GAAG,SAAS,CAAC;AAiIpCC;IADCC,sCAAa,CAAC,CAACC,uCAAc,EAAE,WAAW,CAAC,CAAC;;;8CACHR,WAAK;2CAM9C;AAQDM;IADCC,sCAAa,CAAC,CAACC,uCAAc,EAAE,WAAW,CAAC,CAAC;;;8CACAR,WAAK;8CAMjD;AA6KDM;IADCG,2CAAkB,CAAC,QAAQ,CAAC;;;;yCAU5B;AAODH;IADCG,2CAAkB,CAACC,8BAAmB,CAAC;;;;+CAavC;AAcDJ;IARCG,2CAAkB,CACjBE,+BAAM,CAAC,CAAC,KAAK,KAAK;QAChB,KAAK,YAAY,KAAK;YACpB,KAAK,CAAC,MAAM,GAAG,CAAC;YAChB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,YAAYX,WAAK,EAAE,IAAI,CAAC;QACvD,4BAA4B;KAC7B,CAAC,CACH;;;;qDAcA;;;;"}
|
@@ -130,7 +130,7 @@ This software includes platform.js under the following license.
|
|
130
130
|
|
131
131
|
Object.defineProperty(exports, '__esModule', { value: true });
|
132
132
|
|
133
|
-
var version = "2.1.0-rc.
|
133
|
+
var version = "2.1.0-rc.9";
|
134
134
|
|
135
135
|
exports.version = version;
|
136
136
|
//# sourceMappingURL=package.json.js.map
|