@twilio/conversations 3.0.1-rc.1 → 3.0.1-rc.103

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.
Files changed (136) hide show
  1. package/builds/browser.js +9543 -4302
  2. package/builds/browser.js.map +1 -1
  3. package/builds/lib.d.ts +256 -61
  4. package/builds/lib.js +9543 -4302
  5. package/builds/lib.js.map +1 -1
  6. package/builds/twilio-conversations.js +44686 -27540
  7. package/builds/twilio-conversations.min.js +1 -200
  8. package/dist/channel-metadata-client.js +1 -1
  9. package/dist/channel-metadata-client.js.map +1 -1
  10. package/dist/client.js +153 -43
  11. package/dist/client.js.map +1 -1
  12. package/dist/command-executor.js +31 -50
  13. package/dist/command-executor.js.map +1 -1
  14. package/dist/configuration.js +8 -4
  15. package/dist/configuration.js.map +1 -1
  16. package/dist/content-template.js +1 -1
  17. package/dist/content-template.js.map +1 -1
  18. package/dist/conversation.js +12 -46
  19. package/dist/conversation.js.map +1 -1
  20. package/dist/data/conversations.js +2 -18
  21. package/dist/data/conversations.js.map +1 -1
  22. package/dist/data/messages.js +13 -3
  23. package/dist/data/messages.js.map +1 -1
  24. package/dist/data/participants.js +2 -4
  25. package/dist/data/participants.js.map +1 -1
  26. package/dist/data/users.js +2 -2
  27. package/dist/data/users.js.map +1 -1
  28. package/dist/index.js +5 -6
  29. package/dist/index.js.map +1 -1
  30. package/dist/media.js.map +1 -1
  31. package/dist/message-builder.js.map +1 -1
  32. package/dist/message-recipients-client.js +237 -0
  33. package/dist/message-recipients-client.js.map +1 -0
  34. package/dist/message.js +57 -0
  35. package/dist/message.js.map +1 -1
  36. package/dist/node_modules/quick-lru/index.js.map +1 -1
  37. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  38. package/dist/packages/conversations/package.json.js +1 -1
  39. package/dist/participant.js +34 -34
  40. package/dist/participant.js.map +1 -1
  41. package/dist/push-notification.js.map +1 -1
  42. package/dist/rest-paginator.js +11 -11
  43. package/dist/rest-paginator.js.map +1 -1
  44. package/dist/services/network.js +11 -101
  45. package/dist/services/network.js.map +1 -1
  46. package/dist/services/typing-indicator.js +5 -13
  47. package/dist/services/typing-indicator.js.map +1 -1
  48. package/dist/unsent-message.js.map +1 -1
  49. package/dist/user.js.map +1 -1
  50. package/dist/util/index.js.map +1 -1
  51. package/docs/assets/css/main.css +2660 -0
  52. package/docs/assets/images/icons.png +0 -0
  53. package/docs/assets/images/icons@2x.png +0 -0
  54. package/docs/assets/images/widgets.png +0 -0
  55. package/docs/assets/images/widgets@2x.png +0 -0
  56. package/docs/assets/js/main.js +248 -0
  57. package/docs/assets/js/search.js +1 -0
  58. package/docs/classes/AggregatedDeliveryReceipt.html +3182 -144
  59. package/docs/classes/CancellablePromise.html +3209 -224
  60. package/docs/classes/ChannelMetadata.html +3049 -66
  61. package/docs/classes/Client.html +4276 -701
  62. package/docs/classes/ContentTemplate.html +3115 -96
  63. package/docs/classes/ContentTemplateVariable.html +3114 -88
  64. package/docs/classes/Conversation.html +4380 -768
  65. package/docs/classes/DetailedDeliveryReceipt.html +3162 -116
  66. package/docs/classes/EmailRecipientDescriptor.html +3098 -0
  67. package/docs/classes/Media.html +3165 -119
  68. package/docs/classes/Message.html +3824 -417
  69. package/docs/classes/MessageBuilder.html +3315 -208
  70. package/docs/classes/Participant.html +3442 -258
  71. package/docs/classes/PushNotification.html +3129 -101
  72. package/docs/classes/RestPaginator.html +3158 -120
  73. package/docs/classes/UnknownRecipientDescriptor.html +3067 -0
  74. package/docs/classes/UnsentMessage.html +3040 -63
  75. package/docs/classes/User.html +3347 -209
  76. package/docs/index.html +4366 -146
  77. package/docs/interfaces/ClientOptions.html +3065 -66
  78. package/docs/interfaces/ConversationBindings.html +3000 -109
  79. package/docs/interfaces/ConversationEmailBinding.html +3000 -109
  80. package/docs/interfaces/ConversationLimits.html +3097 -87
  81. package/docs/interfaces/ConversationState.html +3049 -66
  82. package/docs/interfaces/ConversationUpdatedEventArgs.html +3000 -109
  83. package/docs/interfaces/CreateConversationOptions.html +3065 -73
  84. package/docs/interfaces/LastMessage.html +3049 -66
  85. package/docs/interfaces/Paginator.html +3139 -110
  86. package/docs/interfaces/ParticipantBindings.html +3000 -109
  87. package/docs/interfaces/ParticipantEmailBinding.html +3000 -109
  88. package/docs/interfaces/PushNotificationData.html +3113 -94
  89. package/docs/interfaces/SendEmailOptions.html +3033 -59
  90. package/docs/interfaces/SendMediaOptions.html +3067 -75
  91. package/docs/modules.html +4373 -180
  92. package/package.json +13 -14
  93. package/docs/.nojekyll +0 -1
  94. package/docs/assets/highlight.css +0 -113
  95. package/docs/assets/main.js +0 -58
  96. package/docs/assets/search.js +0 -1
  97. package/docs/assets/style.css +0 -1279
  98. package/docs/classes/CancellationError.html +0 -112
  99. package/docs/interfaces/ParticipantBindingOptions.html +0 -110
  100. package/docs/types/ChannelType.html +0 -106
  101. package/docs/types/ConnectionState.html +0 -115
  102. package/docs/types/ContentData.html +0 -106
  103. package/docs/types/ContentDataAction.html +0 -107
  104. package/docs/types/ContentDataActionOther.html +0 -121
  105. package/docs/types/ContentDataActionPhone.html +0 -128
  106. package/docs/types/ContentDataActionReply.html +0 -133
  107. package/docs/types/ContentDataActionUrl.html +0 -128
  108. package/docs/types/ContentDataCallToAction.html +0 -131
  109. package/docs/types/ContentDataCard.html +0 -137
  110. package/docs/types/ContentDataListItem.html +0 -121
  111. package/docs/types/ContentDataListPicker.html +0 -134
  112. package/docs/types/ContentDataLocation.html +0 -134
  113. package/docs/types/ContentDataMedia.html +0 -129
  114. package/docs/types/ContentDataOther.html +0 -121
  115. package/docs/types/ContentDataQuickReply.html +0 -131
  116. package/docs/types/ContentDataReply.html +0 -119
  117. package/docs/types/ContentDataText.html +0 -125
  118. package/docs/types/ConversationStatus.html +0 -107
  119. package/docs/types/ConversationUpdateReason.html +0 -106
  120. package/docs/types/DeliveryAmount.html +0 -106
  121. package/docs/types/DeliveryStatus.html +0 -106
  122. package/docs/types/JSONArray.html +0 -106
  123. package/docs/types/JSONObject.html +0 -111
  124. package/docs/types/JSONValue.html +0 -106
  125. package/docs/types/LogLevel.html +0 -106
  126. package/docs/types/MediaCategory.html +0 -106
  127. package/docs/types/MessageType.html +0 -106
  128. package/docs/types/MessageUpdateReason.html +0 -106
  129. package/docs/types/NotificationLevel.html +0 -109
  130. package/docs/types/NotificationsChannelType.html +0 -110
  131. package/docs/types/ParticipantEmailLevel.html +0 -108
  132. package/docs/types/ParticipantType.html +0 -107
  133. package/docs/types/ParticipantUpdateReason.html +0 -106
  134. package/docs/types/PushNotificationType.html +0 -106
  135. package/docs/types/State.html +0 -110
  136. package/docs/types/UserUpdateReason.html +0 -106
@@ -1 +1 @@
1
- {"version":3,"file":"content-template.js","sources":["../src/content-template.ts"],"sourcesContent":["import {\n ContentDataCallToActionResponse,\n ContentDataCardResponse,\n ContentDataListPickerResponse,\n ContentDataLocationResponse,\n ContentDataMediaResponse,\n ContentDataQuickReplyResponse,\n ContentDataTextResponse,\n ContentTemplateResponse,\n} from \"./interfaces/commands/content-templates-response\";\n\n/**\n * Shows a button that sends back a predefined text. Used in\n * {@link ContentDataQuickReply}.\n */\ntype ContentDataReply = {\n /**\n * Display value of the action. This is the message that will be sent back\n * when the user taps on the button.\n */\n readonly title: string;\n\n /**\n * Postback payload. This field is not visible to the end user.\n */\n readonly id?: string;\n};\n\n/**\n * Shows a button that redirects recipient to a predefined URL.\n */\ntype ContentDataActionUrl = {\n /**\n * The type discriminant.\n */\n readonly type: \"url\";\n\n /**\n * Display value for the action.\n */\n readonly title: string;\n\n /**\n * URL to direct to when the recipient taps the button.\n */\n readonly url: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a button that calls a phone number.\n */\ntype ContentDataActionPhone = {\n /**\n * The type discriminant.\n */\n readonly type: \"phone\";\n\n /**\n * Display value for the action.\n */\n readonly title: string;\n\n /**\n * Phone number to call when the recipient taps the button.\n */\n readonly phone: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a button that sends back a predefined text.\n */\ntype ContentDataActionReply = {\n /**\n * The type discriminant.\n */\n readonly type: \"reply\";\n\n /**\n * Display value for the action. This is the message that will be sent back\n * when the user taps on the button.\n */\n readonly title: string;\n\n /**\n * Postback payload. This field is not visible to the end user.\n */\n readonly id?: string;\n\n /**\n * Index for the action.\n */\n readonly index: number;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used for unknown action types which aren't present in the current version of\n * the Conversations SDK.\n */\ntype ContentDataActionOther = {\n /**\n * The type discriminant.\n */\n readonly type: \"other\";\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * A union of possible actions used in {@link ContentDataCallToAction} and\n * {@link ContentDataCard}.\n */\ntype ContentDataAction =\n | ContentDataActionUrl\n | ContentDataActionPhone\n | ContentDataActionReply\n | ContentDataActionOther;\n\n/**\n * Represents an item in the {@link ContentDataListPicker}.\n */\ntype ContentDataListItem = {\n /**\n * Unique item identifier. Not visible to the recipient.\n */\n readonly id: string;\n\n /**\n * Display value of the item.\n */\n readonly item: string;\n\n /**\n * Description of the item.\n */\n readonly description?: string;\n};\n\n/**\n * Contains only the plain text-based content. Represents the twilio/text\n * content type.\n */\ntype ContentDataText = {\n /**\n * The type discriminant.\n */\n readonly type: \"text\";\n\n /**\n * The text of the message you want to send.\n */\n readonly body: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used to send file attachments, or to send long texts via MMS in the US and\n * Canada. Represents the twilio/media content type.\n */\ntype ContentDataMedia = {\n /**\n * The type discriminant.\n */\n readonly type: \"media\";\n\n /**\n * The text of the message you want to send.\n */\n readonly body?: string;\n\n /**\n * URLs of the media you want to send.\n */\n readonly media: string[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Contains a location pin and an optional label, which can be used to enhance\n * delivery notifications or connect recipients to physical experiences you\n * offer. Represents the twilio/location content type.\n */\ntype ContentDataLocation = {\n /**\n * The type discriminant.\n */\n readonly type: \"location\";\n\n /**\n * The longitude value of the location pin you want to send.\n */\n readonly longitude: number;\n\n /**\n * The latitude value of the location pin you want to send.\n */\n readonly latitude: number;\n\n /**\n * The label to be displayed to the end user alongside the location pin.\n */\n readonly label?: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Let recipients tap, rather than type, to respond to the message. Represents\n * the twilio/quick-reply content type.\n */\ntype ContentDataQuickReply = {\n /**\n * The type discriminant.\n */\n readonly type: \"quickReply\";\n\n /**\n * The text of the message you want to send. This is included as a regular\n * text message.\n */\n readonly body: string;\n\n /**\n * Up to 3 buttons can be created for quick reply. See\n * {@link ContentDataReply}.\n */\n readonly replies: ContentDataReply[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Buttons that let recipients tap to trigger actions such as launching a\n * website or making a phone call. Represents the twilio/call-to-action content\n * type.\n */\ntype ContentDataCallToAction = {\n /**\n * The type discriminant.\n */\n readonly type: \"callToAction\";\n\n /**\n * The text of the message you want to send. This is included as a regular\n * text message.\n */\n readonly body: string;\n\n /**\n * Buttons that recipients can tap on to act on the message.\n */\n readonly actions: ContentDataAction[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a menu of up to 10 options, which offers a simple way for users to make\n * a selection. Represents the twilio/list-picker content type.\n */\ntype ContentDataListPicker = {\n /**\n * The type discriminant.\n */\n readonly type: \"listPicker\";\n\n /**\n * The text of the message you want to send. This is rendered as the body of\n * the message.\n */\n readonly body: string;\n\n /**\n * Display value of the primary button.\n */\n readonly button: string;\n\n /**\n * List item objects displayed in the list. See {@link ContentDataListItem}.\n */\n readonly items: ContentDataListItem[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a menu of up to 10 options, which offers a simple way for users to make\n * a selection. Represents the twilio/card content type.\n */\ntype ContentDataCard = {\n /**\n * The type discriminant.\n */\n readonly type: \"card\";\n\n /**\n * Title of the card.\n */\n readonly title: string;\n\n /**\n * Subtitle of the card.\n */\n readonly subtitle?: string;\n\n /**\n * URLs of the media to send with the message.\n */\n readonly media: string[];\n\n /**\n * Buttons that the recipients can tap on to act on the message.\n */\n readonly actions: ContentDataAction[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used for unknown content types which aren't present in the current version of\n * the Conversations SDK.\n */\ntype ContentDataOther = {\n /**\n * The type discriminant.\n */\n readonly type: \"other\";\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * A union of possible data types in rich content templates.\n */\ntype ContentData =\n | ContentDataText\n | ContentDataMedia\n | ContentDataLocation\n | ContentDataQuickReply\n | ContentDataCallToAction\n | ContentDataListPicker\n | ContentDataCard\n | ContentDataOther;\n\nconst collectActions = (\n actions: ContentDataCallToActionResponse[\"actions\"]\n): ContentDataAction[] => {\n return actions.map((action) => {\n const rawData = JSON.stringify(action);\n\n switch (action.type) {\n case \"QUICK_REPLY\":\n return {\n type: \"reply\",\n title: action.title,\n id: action.id ?? \"\",\n index: action.index ?? 0,\n rawData,\n };\n case \"PHONE_NUMBER\":\n return {\n type: \"phone\",\n title: action.title,\n phone: action.phone ?? \"\",\n rawData,\n };\n case \"URL\":\n return {\n type: \"url\",\n title: action.title,\n url: action.url ?? \"\",\n rawData,\n };\n default:\n return {\n type: \"other\",\n rawData,\n };\n }\n });\n};\n\nconst parseVariant = (type: string, data: unknown): ContentData => {\n const rawData = JSON.stringify(data);\n\n switch (type) {\n case \"twilio/text\": {\n const variant = data as ContentDataTextResponse;\n return {\n type: \"text\",\n body: variant.body,\n rawData,\n };\n }\n case \"twilio/media\": {\n const variant = data as ContentDataMediaResponse;\n return {\n type: \"media\",\n body: variant.body,\n media: variant.media,\n rawData,\n };\n }\n case \"twilio/location\": {\n const variant = data as ContentDataLocationResponse;\n return {\n type: \"location\",\n longitude: variant.longitude,\n latitude: variant.latitude,\n label: variant.label,\n rawData,\n };\n }\n case \"twilio/quick-reply\": {\n const variant = data as ContentDataQuickReplyResponse;\n return {\n type: \"quickReply\",\n body: variant.body,\n replies: variant.actions,\n rawData,\n };\n }\n case \"twilio/call-to-action\": {\n const variant = data as ContentDataCallToActionResponse;\n return {\n type: \"callToAction\",\n body: variant.body,\n actions: collectActions(variant.actions),\n rawData,\n };\n }\n case \"twilio/list-picker\": {\n const variant = data as ContentDataListPickerResponse;\n return {\n type: \"listPicker\",\n body: variant.body,\n button: variant.button,\n items: variant.items,\n rawData,\n };\n }\n case \"twilio/card\": {\n const variant = data as ContentDataCardResponse;\n return {\n type: \"card\",\n title: variant.title,\n subtitle: variant.subtitle,\n media: variant.media ?? [],\n actions: collectActions(variant.actions ?? []),\n rawData,\n };\n }\n default:\n return {\n type: \"other\",\n rawData,\n };\n }\n};\n\nconst collectVariants = (\n variants: ContentTemplateResponse[\"variants\"]\n): Map<string, ContentData> => {\n const variantsMap = new Map<string, ContentData>();\n\n for (const [key, value] of Object.entries(variants)) {\n variantsMap.set(key, parseVariant(key, value));\n }\n\n return variantsMap;\n};\n\n/**\n * Represents a variable for a content template. See\n * {@link ContentTemplate.variables}.\n */\nclass ContentTemplateVariable {\n public constructor(\n /**\n * Name of the variable.\n */\n public readonly name: string,\n\n /**\n * Key of the variable\n */\n public readonly value: string\n ) {}\n\n /**\n * Copies the variable with a new value.\n *\n * @param value The new value for the variable.\n */\n public copyWithValue(value: string) {\n return new ContentTemplateVariable(this.name, value);\n }\n}\n\n/**\n * A rich content template.\n *\n * Use {@link Client.getContentTemplates} to request all the templates available\n * for the current account.\n */\nclass ContentTemplate {\n /**\n * The server-assigned unique identifier for the template.\n */\n public readonly sid: string;\n\n /**\n * Friendly name used to describe the content. Not visible to the recipient.\n */\n public readonly friendlyName: string;\n\n /**\n * Variables used by this template.\n */\n public readonly variables: ContentTemplateVariable[];\n\n /**\n * Variants of the content. See {@link ContentData}.\n */\n public readonly variants: Map<string, ContentData>;\n\n /**\n * Date of creation.\n */\n public readonly dateCreated: Date;\n\n /**\n * Date of the last update.\n */\n public readonly dateUpdated: Date;\n\n /**\n * @internal\n */\n public constructor(contentTemplateResponse: ContentTemplateResponse) {\n this.sid = contentTemplateResponse.sid;\n this.friendlyName = contentTemplateResponse.friendly_name;\n this.variables = Object.entries(\n JSON.parse(contentTemplateResponse.variables) as Record<string, string>\n ).map(([key, value]) => new ContentTemplateVariable(key, value));\n this.variants = collectVariants(contentTemplateResponse.variants);\n this.dateCreated = new Date(contentTemplateResponse.date_created);\n this.dateUpdated = new Date(contentTemplateResponse.date_updated);\n }\n}\n\nexport {\n ContentDataActionUrl,\n ContentDataActionPhone,\n ContentDataActionReply,\n ContentDataActionOther,\n ContentDataAction,\n ContentDataText,\n ContentDataMedia,\n ContentDataLocation,\n ContentDataReply,\n ContentDataQuickReply,\n ContentDataCallToAction,\n ContentDataListPicker,\n ContentDataListItem,\n ContentDataCard,\n ContentDataOther,\n ContentData,\n ContentTemplate,\n ContentTemplateVariable,\n parseVariant,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuaA,MAAM,cAAc,GAAG,CACrB,OAAmD,KAC5B;AACvB,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,KAAI;;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEvC,QAAQ,MAAM,CAAC,IAAI;AACjB,YAAA,KAAK,aAAa;gBAChB,OAAO;AACL,oBAAA,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,MAAM,CAAC,KAAK;AACnB,oBAAA,EAAE,EAAE,CAAA,EAAA,GAAA,MAAM,CAAC,EAAE,mCAAI,EAAE;AACnB,oBAAA,KAAK,EAAE,CAAA,EAAA,GAAA,MAAM,CAAC,KAAK,mCAAI,CAAC;oBACxB,OAAO;iBACR,CAAC;AACJ,YAAA,KAAK,cAAc;gBACjB,OAAO;AACL,oBAAA,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,MAAM,CAAC,KAAK;AACnB,oBAAA,KAAK,EAAE,CAAA,EAAA,GAAA,MAAM,CAAC,KAAK,mCAAI,EAAE;oBACzB,OAAO;iBACR,CAAC;AACJ,YAAA,KAAK,KAAK;gBACR,OAAO;AACL,oBAAA,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,CAAC,CAAC;KACnE;AACF;;;;;;"}
1
+ {"version":3,"file":"content-template.js","sources":["../src/content-template.ts"],"sourcesContent":["import {\n ContentDataCallToActionResponse,\n ContentDataCardResponse,\n ContentDataListPickerResponse,\n ContentDataLocationResponse,\n ContentDataMediaResponse,\n ContentDataQuickReplyResponse,\n ContentDataTextResponse,\n ContentTemplateResponse,\n} from \"./interfaces/commands/content-templates-response\";\n\n/**\n * Shows a button that sends back a predefined text. Used in\n * {@link ContentDataQuickReply}.\n */\ntype ContentDataReply = {\n /**\n * Display value of the action. This is the message that will be sent back\n * when the user taps on the button.\n */\n readonly title: string;\n\n /**\n * Postback payload. This field is not visible to the end user.\n */\n readonly id?: string;\n};\n\n/**\n * Shows a button that redirects recipient to a predefined URL.\n */\ntype ContentDataActionUrl = {\n /**\n * The type discriminant.\n */\n readonly type: \"url\";\n\n /**\n * Display value for the action.\n */\n readonly title: string;\n\n /**\n * URL to direct to when the recipient taps the button.\n */\n readonly url: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a button that calls a phone number.\n */\ntype ContentDataActionPhone = {\n /**\n * The type discriminant.\n */\n readonly type: \"phone\";\n\n /**\n * Display value for the action.\n */\n readonly title: string;\n\n /**\n * Phone number to call when the recipient taps the button.\n */\n readonly phone: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a button that sends back a predefined text.\n */\ntype ContentDataActionReply = {\n /**\n * The type discriminant.\n */\n readonly type: \"reply\";\n\n /**\n * Display value for the action. This is the message that will be sent back\n * when the user taps on the button.\n */\n readonly title: string;\n\n /**\n * Postback payload. This field is not visible to the end user.\n */\n readonly id?: string;\n\n /**\n * Index for the action.\n */\n readonly index: number;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used for unknown action types which aren't present in the current version of\n * the Conversations SDK.\n */\ntype ContentDataActionOther = {\n /**\n * The type discriminant.\n */\n readonly type: \"other\";\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * A union of possible actions used in {@link ContentDataCallToAction} and\n * {@link ContentDataCard}.\n */\ntype ContentDataAction =\n | ContentDataActionUrl\n | ContentDataActionPhone\n | ContentDataActionReply\n | ContentDataActionOther;\n\n/**\n * Represents an item in the {@link ContentDataListPicker}.\n */\ntype ContentDataListItem = {\n /**\n * Unique item identifier. Not visible to the recipient.\n */\n readonly id: string;\n\n /**\n * Display value of the item.\n */\n readonly item: string;\n\n /**\n * Description of the item.\n */\n readonly description?: string;\n};\n\n/**\n * Contains only the plain text-based content. Represents the twilio/text\n * content type.\n */\ntype ContentDataText = {\n /**\n * The type discriminant.\n */\n readonly type: \"text\";\n\n /**\n * The text of the message you want to send.\n */\n readonly body: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used to send file attachments, or to send long texts via MMS in the US and\n * Canada. Represents the twilio/media content type.\n */\ntype ContentDataMedia = {\n /**\n * The type discriminant.\n */\n readonly type: \"media\";\n\n /**\n * The text of the message you want to send.\n */\n readonly body?: string;\n\n /**\n * URLs of the media you want to send.\n */\n readonly media: string[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Contains a location pin and an optional label, which can be used to enhance\n * delivery notifications or connect recipients to physical experiences you\n * offer. Represents the twilio/location content type.\n */\ntype ContentDataLocation = {\n /**\n * The type discriminant.\n */\n readonly type: \"location\";\n\n /**\n * The longitude value of the location pin you want to send.\n */\n readonly longitude: number;\n\n /**\n * The latitude value of the location pin you want to send.\n */\n readonly latitude: number;\n\n /**\n * The label to be displayed to the end user alongside the location pin.\n */\n readonly label?: string;\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Let recipients tap, rather than type, to respond to the message. Represents\n * the twilio/quick-reply content type.\n */\ntype ContentDataQuickReply = {\n /**\n * The type discriminant.\n */\n readonly type: \"quickReply\";\n\n /**\n * The text of the message you want to send. This is included as a regular\n * text message.\n */\n readonly body: string;\n\n /**\n * Up to 3 buttons can be created for quick reply. See\n * {@link ContentDataReply}.\n */\n readonly replies: ContentDataReply[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Buttons that let recipients tap to trigger actions such as launching a\n * website or making a phone call. Represents the twilio/call-to-action content\n * type.\n */\ntype ContentDataCallToAction = {\n /**\n * The type discriminant.\n */\n readonly type: \"callToAction\";\n\n /**\n * The text of the message you want to send. This is included as a regular\n * text message.\n */\n readonly body: string;\n\n /**\n * Buttons that recipients can tap on to act on the message.\n */\n readonly actions: ContentDataAction[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a menu of up to 10 options, which offers a simple way for users to make\n * a selection. Represents the twilio/list-picker content type.\n */\ntype ContentDataListPicker = {\n /**\n * The type discriminant.\n */\n readonly type: \"listPicker\";\n\n /**\n * The text of the message you want to send. This is rendered as the body of\n * the message.\n */\n readonly body: string;\n\n /**\n * Display value of the primary button.\n */\n readonly button: string;\n\n /**\n * List item objects displayed in the list. See {@link ContentDataListItem}.\n */\n readonly items: ContentDataListItem[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Shows a menu of up to 10 options, which offers a simple way for users to make\n * a selection. Represents the twilio/card content type.\n */\ntype ContentDataCard = {\n /**\n * The type discriminant.\n */\n readonly type: \"card\";\n\n /**\n * Title of the card.\n */\n readonly title: string;\n\n /**\n * Subtitle of the card.\n */\n readonly subtitle?: string;\n\n /**\n * URLs of the media to send with the message.\n */\n readonly media: string[];\n\n /**\n * Buttons that the recipients can tap on to act on the message.\n */\n readonly actions: ContentDataAction[];\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * Used for unknown content types which aren't present in the current version of\n * the Conversations SDK.\n */\ntype ContentDataOther = {\n /**\n * The type discriminant.\n */\n readonly type: \"other\";\n\n /**\n * Full data as a stringified JSON. This could be used for future content\n * types and fields which are not yet supported by the newest version of\n * the Conversations SDK, or for using newer types in the older versions of\n * the SDK.\n */\n readonly rawData: string;\n};\n\n/**\n * A union of possible data types in rich content templates.\n */\ntype ContentData =\n | ContentDataText\n | ContentDataMedia\n | ContentDataLocation\n | ContentDataQuickReply\n | ContentDataCallToAction\n | ContentDataListPicker\n | ContentDataCard\n | ContentDataOther;\n\nconst collectActions = (\n actions: ContentDataCallToActionResponse[\"actions\"]\n): ContentDataAction[] => {\n return actions.map((action) => {\n const rawData = JSON.stringify(action);\n\n switch (action.type) {\n case \"QUICK_REPLY\":\n return {\n type: \"reply\",\n title: action.title,\n id: action.id ?? \"\",\n index: action.index ?? 0,\n rawData,\n };\n case \"PHONE_NUMBER\":\n return {\n type: \"phone\",\n title: action.title,\n phone: action.phone ?? \"\",\n rawData,\n };\n case \"URL\":\n return {\n type: \"url\",\n title: action.title,\n url: action.url ?? \"\",\n rawData,\n };\n default:\n return {\n type: \"other\",\n rawData,\n };\n }\n });\n};\n\nconst parseVariant = (type: string, data: unknown): ContentData => {\n const rawData = JSON.stringify(data);\n\n switch (type) {\n case \"twilio/text\": {\n const variant = data as ContentDataTextResponse;\n return {\n type: \"text\",\n body: variant.body,\n rawData,\n };\n }\n case \"twilio/media\": {\n const variant = data as ContentDataMediaResponse;\n return {\n type: \"media\",\n body: variant.body,\n media: variant.media,\n rawData,\n };\n }\n case \"twilio/location\": {\n const variant = data as ContentDataLocationResponse;\n return {\n type: \"location\",\n longitude: variant.longitude,\n latitude: variant.latitude,\n label: variant.label,\n rawData,\n };\n }\n case \"twilio/quick-reply\": {\n const variant = data as ContentDataQuickReplyResponse;\n return {\n type: \"quickReply\",\n body: variant.body,\n replies: variant.actions,\n rawData,\n };\n }\n case \"twilio/call-to-action\": {\n const variant = data as ContentDataCallToActionResponse;\n return {\n type: \"callToAction\",\n body: variant.body,\n actions: collectActions(variant.actions),\n rawData,\n };\n }\n case \"twilio/list-picker\": {\n const variant = data as ContentDataListPickerResponse;\n return {\n type: \"listPicker\",\n body: variant.body,\n button: variant.button,\n items: variant.items,\n rawData,\n };\n }\n case \"twilio/card\": {\n const variant = data as ContentDataCardResponse;\n return {\n type: \"card\",\n title: variant.title,\n subtitle: variant.subtitle,\n media: variant.media ?? [],\n actions: collectActions(variant.actions ?? []),\n rawData,\n };\n }\n default:\n return {\n type: \"other\",\n rawData,\n };\n }\n};\n\nconst collectVariants = (\n variants: ContentTemplateResponse[\"variants\"]\n): Map<string, ContentData> => {\n const variantsMap = new Map<string, ContentData>();\n\n for (const [key, value] of Object.entries(variants)) {\n variantsMap.set(key, parseVariant(key, value));\n }\n\n return variantsMap;\n};\n\n/**\n * Represents a variable for a content template. See\n * {@link ContentTemplate.variables}.\n */\nclass ContentTemplateVariable {\n public constructor(\n /**\n * Name of the variable.\n */\n public readonly name: string,\n\n /**\n * Key of the variable\n */\n public readonly value: string\n ) {}\n\n /**\n * Copies the variable with a new value.\n *\n * @param value The new value for the variable.\n */\n public copyWithValue(value: string) {\n return new ContentTemplateVariable(this.name, value);\n }\n}\n\n/**\n * A rich content template.\n *\n * Use {@Link Client.getContentTemplates} to request all the templates available\n * for the current account.\n */\nclass ContentTemplate {\n /**\n * The server-assigned unique identifier for the template.\n */\n public readonly sid: string;\n\n /**\n * Friendly name used to describe the content. Not visible to the recipient.\n */\n public readonly friendlyName: string;\n\n /**\n * Variables used by this template.\n */\n public readonly variables: ContentTemplateVariable[];\n\n /**\n * Variants of the content. See {@link ContentData}.\n */\n public readonly variants: Map<string, ContentData>;\n\n /**\n * Date of creation.\n */\n public readonly dateCreated: Date;\n\n /**\n * Date of the last update.\n */\n public readonly dateUpdated: Date;\n\n /**\n * @internal\n */\n public constructor(contentTemplateResponse: ContentTemplateResponse) {\n this.sid = contentTemplateResponse.sid;\n this.friendlyName = contentTemplateResponse.friendly_name;\n this.variables = Object.entries(\n JSON.parse(contentTemplateResponse.variables) as Record<string, string>\n ).map(([key, value]) => new ContentTemplateVariable(key, value));\n this.variants = collectVariants(contentTemplateResponse.variants);\n this.dateCreated = new Date(contentTemplateResponse.date_created);\n this.dateUpdated = new Date(contentTemplateResponse.date_updated);\n }\n}\n\nexport {\n ContentDataActionUrl,\n ContentDataActionPhone,\n ContentDataActionReply,\n ContentDataActionOther,\n ContentDataAction,\n ContentDataText,\n ContentDataMedia,\n ContentDataLocation,\n ContentDataReply,\n ContentDataQuickReply,\n ContentDataCallToAction,\n ContentDataListPicker,\n ContentDataListItem,\n ContentDataCard,\n ContentDataOther,\n ContentData,\n ContentTemplate,\n ContentTemplateVariable,\n parseVariant,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAA,GAAL,KAAK,CAAQ;KAC3B;AAEJ;;;;AAIG;AACI,IAAA,aAAa,CAAC,KAAa,EAAA;QAChC,OAAO,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KACtD;AACF,CAAA;AAED;;;;;AAKG;AACH,MAAM,eAAe,CAAA;AA+BnB;;AAEG;AACH,IAAA,WAAA,CAAmB,uBAAgD,EAAA;AACjE,QAAA,IAAI,CAAC,GAAG,GAAG,uBAAuB,CAAC,GAAG,CAAC;AACvC,QAAA,IAAI,CAAC,YAAY,GAAG,uBAAuB,CAAC,aAAa,CAAC;AAC1D,QAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,CAC7B,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,SAAS,CAA2B,CACxE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,IAAI,uBAAuB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,GAAG,eAAe,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;KACnE;AACF;;;;;;"}
@@ -452,7 +452,6 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
452
452
  const url = new index.UriBuilder(this._configuration.links.conversations)
453
453
  .path(this.sid)
454
454
  .build();
455
- // todo: remove any after the release of new Twilsock
456
455
  const response = await this._services.network.get(url);
457
456
  return (_a = response.body.participants_count) !== null && _a !== void 0 ? _a : 0;
458
457
  }
@@ -486,7 +485,6 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
486
485
  const url = new index.UriBuilder(this._configuration.links.conversations)
487
486
  .path(this.sid)
488
487
  .build();
489
- // todo: remove any after the release of new Twilsock
490
488
  const response = await this._services.network.get(url);
491
489
  return (_a = response.body.messages_count) !== null && _a !== void 0 ? _a : 0;
492
490
  }
@@ -517,7 +515,6 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
517
515
  const url = new index.UriBuilder(this._configuration.links.myConversations)
518
516
  .path(this.sid)
519
517
  .build();
520
- // todo: remove any after the release of new Twilsock
521
518
  const response = await this._services.network.get(url);
522
519
  if (response.body.conversation_sid !== this.sid) {
523
520
  throw new Error("Conversation was not found in the user conversations list");
@@ -564,50 +561,13 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
564
561
  * @return Index of the new message.
565
562
  */
566
563
  async sendMessage(message, messageAttributes, emailOptions) {
567
- const response = typeof message === "string" || message === null
568
- ? await this._messagesEntity.send(message, messageAttributes, emailOptions)
569
- : await this._messagesEntity.sendMedia(message, messageAttributes, emailOptions);
570
- const type = typeof message === "string" || message === null ? "text" : "media";
571
- let responseAttributes;
572
- try {
573
- responseAttributes = JSON.parse(response.attributes);
564
+ var _a, _b;
565
+ if (typeof message === "string" || message === null) {
566
+ const response = await this._messagesEntity.send(message, messageAttributes, emailOptions);
567
+ return (_a = index.parseToNumber(response.index)) !== null && _a !== void 0 ? _a : 0;
574
568
  }
575
- catch (e) { }
576
- const messageData = {
577
- sid: response.sid,
578
- text: response.body,
579
- type,
580
- author: response.author,
581
- subject: response.subject,
582
- contentSid: response.content_sid,
583
- lastUpdatedBy: response.participant_sid,
584
- attributes: responseAttributes,
585
- dateUpdated: response.date_updated,
586
- timestamp: response.date_created,
587
- memberSid: response.participant_sid,
588
- medias: Array.isArray(response.media)
589
- ? response.media.map((media) => ({
590
- sid: media["sid"],
591
- size: Number(media["size"]),
592
- category: media["category"],
593
- filename: media["filename"],
594
- contentType: media["content_type"],
595
- }))
596
- : null,
597
- media: response.media &&
598
- typeof response.media === "object" &&
599
- !Array.isArray(response.media)
600
- ? {
601
- sid: response.media["sid"],
602
- size: Number(response.media["size"]),
603
- category: response.media["category"],
604
- filename: response.media["filename"],
605
- contentType: response.media["content_type"],
606
- }
607
- : null,
608
- hasChannelMetadata: false,
609
- };
610
- return this._messagesEntity._upsertMessage(response.index, messageData);
569
+ const response = await this._messagesEntity.sendMedia(message, messageAttributes, emailOptions);
570
+ return (_b = index.parseToNumber(response.index)) !== null && _b !== void 0 ? _b : 0;
611
571
  }
612
572
  /**
613
573
  * New interface to prepare for sending a message.
@@ -700,6 +660,12 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
700
660
  }
701
661
  return this;
702
662
  }
663
+ /**
664
+ * Get recipients of all messages in the conversation.
665
+ */
666
+ async getMessageRecipients() {
667
+ return await this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid);
668
+ }
703
669
  /**
704
670
  * Load and subscribe to this conversation and do not subscribe to its
705
671
  * participants and messages. This or _subscribeStreams will need to be called
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.js","sources":["../src/conversation.ts"],"sourcesContent":["import \"isomorphic-form-data\";\nimport { Logger } from \"./logger\";\nimport { ParticipantBindingOptions, Participants } from \"./data/participants\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"./participant\";\nimport { Messages } from \"./data/messages\";\nimport {\n Message,\n MessageType,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"./message\";\nimport { UriBuilder, parseTime } from \"./util\";\nimport { Users } from \"./data/users\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { ConversationsDataSource } from \"./data/conversations\";\nimport { McsClient } from \"@twilio/mcs-client\";\nimport { SyncClient, SyncDocument, SyncList, SyncMap } 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 { json, optionalJson } from \"./interfaces/rules\";\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 \"@twilio/shared\";\nimport { MediaCategory } from \"./media\";\nimport { MessageResponse } from \"./interfaces/commands/message-response\";\nimport { ChannelMetadataClient } from \"./channel-metadata-client\";\n\n/**\n * Conversation events.\n */\ntype ConversationEvents = {\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n updated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n removed: (conversation: Conversation) => void;\n};\n\n/**\n * Reason for the `updated` event emission by a conversation.\n */\ntype ConversationUpdateReason =\n | \"attributes\"\n | \"createdBy\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"friendlyName\"\n | \"lastReadMessageIndex\"\n | \"state\"\n | \"status\"\n | \"uniqueName\"\n | \"lastMessage\"\n | \"notificationLevel\"\n | \"bindings\";\n\n/**\n * Status of the conversation, relative to the client: whether the conversation\n * has been `joined` or the client is `notParticipating` in the conversation.\n */\ntype ConversationStatus = \"notParticipating\" | \"joined\";\n\n/**\n * User's notification level for the conversation. Determines\n * whether the currently logged-in user will receive pushes for events\n * in this conversation. Can be either `muted` or `default`, where\n * `default` defers to the global service push configuration.\n */\ntype NotificationLevel = \"default\" | \"muted\";\n\n/**\n * State of the conversation.\n */\ninterface ConversationState {\n /**\n * Current state.\n */\n current: \"active\" | \"inactive\" | \"closed\";\n\n /**\n * Date at which the latest conversation state update happened.\n */\n dateUpdated: Date;\n}\n\n/**\n * Event arguments for the `updated` event.\n */\ninterface ConversationUpdatedEventArgs {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n}\n\n/**\n * Binding for email conversation.\n */\ninterface ConversationBindings {\n email?: ConversationEmailBinding;\n sms?: ConversationSmsBinding;\n}\n\n/**\n * Binding for email conversation.\n */\ninterface ConversationEmailBinding {\n name?: string;\n projected_address: string;\n}\n\n/**\n * Binding for SMS conversation.\n */\ninterface ConversationSmsBinding {\n address?: string;\n}\n\n/**\n * Configuration for attaching a media file to a message.\n * These options can be passed to {@link Conversation.sendMessage} and\n * {@link MessageBuilder.addMedia}.\n */\ninterface SendMediaOptions {\n /**\n * Content type of media.\n */\n contentType: null | string;\n\n /**\n * Optional filename.\n */\n filename?: string;\n\n /**\n * Content to post.\n */\n media: null | string | Buffer | Blob;\n}\n\n/**\n * These options can be passed to {@link Conversation.sendMessage}.\n */\ninterface SendEmailOptions {\n /**\n * Message subject. Ignored for media messages.\n */\n subject?: string;\n}\n\n/**\n * Information about the last message of a conversation.\n */\ninterface LastMessage {\n /**\n * Message's index.\n */\n index?: number;\n\n /**\n * Message's creation date.\n */\n dateCreated?: Date;\n}\n\n/**\n * Conversation services.\n */\ninterface ConversationServices {\n users: Users;\n typingIndicator: TypingIndicator;\n network: Network;\n mcsClient: McsClient;\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n channelMetadataClient: ChannelMetadataClient;\n}\n\n/**\n * Internal (private) state of the conversation.\n */\ninterface ConversationInternalState {\n uniqueName: string | null;\n status: ConversationStatus;\n attributes: JSONValue;\n createdBy?: string;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n friendlyName: string | null;\n lastReadMessageIndex: number | null;\n lastMessage?: LastMessage;\n notificationLevel?: NotificationLevel;\n state?: ConversationState;\n bindings: ConversationBindings;\n}\n\n/**\n * Conversation descriptor.\n */\ninterface ConversationDescriptor {\n channel: string;\n entityName: string;\n uniqueName: string;\n attributes: JSONValue;\n createdBy?: string;\n friendlyName?: string;\n lastConsumedMessageIndex: number;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n notificationLevel?: NotificationLevel;\n bindings?: ConversationBindings;\n}\n\n/**\n * Conversation links.\n */\ninterface ConversationLinks {\n self: string;\n messages: string;\n participants: string;\n}\n\n/**\n * Map of the fields that will be processed with update messages.\n */\nconst fieldMappings = {\n lastMessage: \"lastMessage\",\n attributes: \"attributes\",\n createdBy: \"createdBy\",\n dateCreated: \"dateCreated\",\n dateUpdated: \"dateUpdated\",\n friendlyName: \"friendlyName\",\n lastConsumedMessageIndex: \"lastConsumedMessageIndex\",\n notificationLevel: \"notificationLevel\",\n sid: \"sid\",\n status: \"status\",\n uniqueName: \"uniqueName\",\n state: \"state\",\n bindings: \"bindings\",\n};\n\n/**\n * A conversation represents communication between multiple Conversations\n * clients.\n */\nclass Conversation extends ReplayEventEmitter<ConversationEvents> {\n /**\n * Fired when a participant has joined the conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - participant that joined the\n * conversation\n * @event\n */\n public static readonly participantJoined = \"participantJoined\";\n\n /**\n * Fired when a participant has left the conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - participant that left the\n * conversation\n * @event\n */\n public static readonly participantLeft = \"participantLeft\";\n\n /**\n * Fired when data of a participant has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Participant} `participant` - participant that has received the\n * update\n * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly participantUpdated = \"participantUpdated\";\n\n /**\n * Fired when a new message has been added to the conversation.\n *\n * Parameters:\n * 1. {@link Message} `message` - message that has been added\n * @event\n */\n public static readonly messageAdded = \"messageAdded\";\n\n /**\n * Fired when message is removed from the conversation's message list.\n *\n * Parameters:\n * 1. {@link Message} `message` - message that has been removed\n * @event\n */\n public static readonly messageRemoved = \"messageRemoved\";\n\n /**\n * Fired when data of a message has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Message} `message` - message that has received the update\n * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for\n * the update\n * @event\n */\n public static readonly messageUpdated = \"messageUpdated\";\n\n /**\n * Fired when a participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant that has stopped\n * typing\n * @event\n */\n public static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when a participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant that has started\n * typing\n * @event\n */\n public static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the data of the conversation has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Conversation} `conversation` - conversation that has received\n * the update\n * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly updated = \"updated\";\n\n /**\n * Fired when the conversation was destroyed or the currently-logged-in user\n * has left private conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - conversation that has been removed\n * @event\n */\n public static readonly removed = \"removed\";\n\n /**\n * Logger instance.\n */\n private static readonly _logger = Logger.scope(\"Conversation\");\n\n /**\n * Unique system identifier of the conversation.\n */\n public readonly sid: string;\n\n /**\n * Conversation links for REST requests.\n * @internal\n */\n public readonly _links: ConversationLinks;\n\n /**\n * Map of participants.\n * @internal\n */\n public readonly _participants: Map<string, Participant>;\n\n /**\n * Configuration of the client that the conversation belongs to.\n */\n private readonly _configuration: Configuration;\n\n /**\n * Conversation service objects.\n */\n private readonly _services: ConversationServices;\n\n /**\n * Internal state of the conversation.\n */\n private readonly _internalState: ConversationInternalState;\n\n /**\n * Name of the conversation entity document.\n */\n private readonly _entityName: string;\n\n /**\n * Messages entity.\n */\n private readonly _messagesEntity: Messages;\n\n /**\n * Sync list containing messages.\n */\n private _messagesList?: SyncList;\n\n /**\n * Participants entity.\n */\n private readonly _participantsEntity: Participants;\n\n /**\n * Sync map containing participants.\n */\n private _participantsMap?: SyncMap;\n\n /**\n * Source of the most recent update.\n */\n private _dataSource!: ConversationsDataSource;\n\n /**\n * Promise for the conversation entity document.\n */\n private _entityPromise!: Promise<SyncDocument> | null;\n\n /**\n * Conversation entity document.\n */\n private _entity!: SyncDocument | null;\n\n /**\n * @param descriptor Conversation descriptor.\n * @param sid Conversation SID.\n * @param links Conversation links for REST requests.\n * @param configuration Client configuration.\n * @param services Conversation services.\n * @internal\n */\n public constructor(\n descriptor: ConversationDescriptor,\n sid: string,\n links: ConversationLinks,\n configuration: Configuration,\n services: ConversationServices\n ) {\n super();\n\n this.sid = sid;\n this._links = links;\n this._configuration = configuration;\n this._services = services;\n this._entityName = descriptor.channel;\n this._internalState = {\n uniqueName: descriptor.uniqueName || null,\n status: \"notParticipating\",\n attributes: descriptor.attributes ?? {},\n createdBy: descriptor.createdBy,\n dateCreated: parseTime(descriptor.dateCreated),\n dateUpdated: parseTime(descriptor.dateUpdated),\n friendlyName: descriptor.friendlyName || null,\n lastReadMessageIndex: Number.isInteger(\n descriptor.lastConsumedMessageIndex\n )\n ? descriptor.lastConsumedMessageIndex\n : null,\n bindings: descriptor.bindings ?? {},\n };\n\n if (descriptor.notificationLevel) {\n this._internalState.notificationLevel = descriptor.notificationLevel;\n }\n\n const participantsLinks = {\n participants: this._links.participants,\n };\n\n this._participants = new Map();\n this._participantsEntity = new Participants(\n this,\n this._participants,\n participantsLinks,\n this._configuration,\n this._services\n );\n this._participantsEntity.on(\"participantJoined\", (participant) =>\n this.emit(\"participantJoined\", participant)\n );\n this._participantsEntity.on(\"participantLeft\", (participant) =>\n this.emit(\"participantLeft\", participant)\n );\n this._participantsEntity.on(\n \"participantUpdated\",\n (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n\n this._messagesEntity = new Messages(this, configuration, services);\n this._messagesEntity.on(\"messageAdded\", (message) =>\n this._onMessageAdded(message)\n );\n this._messagesEntity.on(\"messageUpdated\", (args: MessageUpdatedEventArgs) =>\n this.emit(\"messageUpdated\", args)\n );\n this._messagesEntity.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n }\n\n /**\n * Unique name of the conversation.\n */\n public get uniqueName(): string | null {\n return this._internalState.uniqueName;\n }\n\n /**\n * Status of the conversation.\n */\n public get status(): ConversationStatus {\n return this._internalState.status;\n }\n\n /**\n * Name of the conversation.\n */\n public get friendlyName(): string | null {\n return this._internalState.friendlyName;\n }\n\n /**\n * Date this conversation was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this._internalState.dateUpdated;\n }\n\n /**\n * Date this conversation was created on.\n */\n public get dateCreated(): Date | null {\n return this._internalState.dateCreated;\n }\n\n /**\n * Identity of the user that created this conversation.\n */\n public get createdBy(): string {\n return this._internalState.createdBy ?? \"\";\n }\n\n /**\n * Custom attributes of the conversation.\n */\n public get attributes(): JSONValue {\n return this._internalState.attributes;\n }\n\n /**\n * Index of the last message the user has read in this conversation.\n */\n public get lastReadMessageIndex(): number | null {\n return this._internalState.lastReadMessageIndex;\n }\n\n /**\n * Last message sent to this conversation.\n */\n public get lastMessage(): LastMessage | undefined {\n return this._internalState.lastMessage ?? undefined;\n }\n\n /**\n * User notification level for this conversation.\n */\n public get notificationLevel(): NotificationLevel {\n return this._internalState.notificationLevel ?? \"default\";\n }\n\n /**\n * Conversation bindings. Undocumented feature (for now).\n * @internal\n */\n public get bindings(): ConversationBindings {\n return this._internalState.bindings;\n }\n\n /**\n * Current conversation limits.\n */\n public get limits(): ConversationLimits {\n return this._configuration.limits;\n }\n\n /**\n * State of the conversation.\n */\n public get state(): ConversationState | undefined {\n return this._internalState.state;\n }\n\n /**\n * Source of the conversation update.\n * @internal\n */\n public get _statusSource(): ConversationsDataSource {\n return this._dataSource;\n }\n\n /**\n * Preprocess the update object.\n * @param update The update object received from Sync.\n * @param conversationSid The SID of the conversation in question.\n */\n private static preprocessUpdate(update, conversationSid: string) {\n try {\n if (typeof update.attributes === \"string\") {\n update.attributes = JSON.parse(update.attributes);\n } else if (update.attributes) {\n JSON.stringify(update.attributes);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed attributes from the server for conversation: \" +\n conversationSid\n );\n update.attributes = {};\n }\n\n try {\n if (update.dateCreated) {\n update.dateCreated = new Date(update.dateCreated);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed dateCreated from the server for conversation: \" +\n conversationSid\n );\n delete update.dateCreated;\n }\n\n try {\n if (update.dateUpdated) {\n update.dateUpdated = new Date(update.dateUpdated);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed dateUpdated from the server for conversation: \" +\n conversationSid\n );\n delete update.dateUpdated;\n }\n\n try {\n if (update.lastMessage && update.lastMessage.timestamp) {\n update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed lastMessage.timestamp from the server for conversation: \" +\n conversationSid\n );\n delete update.lastMessage.timestamp;\n }\n }\n\n /**\n * Add a participant to the conversation by its identity.\n * @param identity Identity of the Client to add.\n * @param attributes Attributes to be attached to the participant.\n * @returns The added participant.\n */\n @validateTypesAsync(nonEmptyString, optionalJson)\n public async add(\n identity: string,\n attributes?: JSONValue\n ): Promise<Participant> {\n return this._participantsEntity.add(identity, attributes ?? {});\n }\n\n /**\n * Add a non-chat participant to the conversation.\n * @param proxyAddress Proxy (Twilio) address of the participant.\n * @param address User address of the participant.\n * @param attributes Attributes to be attached to the participant.\n * @param bindingOptions Options for adding email participants - name and\n * CC/To level.\n * @returns The added participant.\n */\n @validateTypesAsync(nonEmptyString, nonEmptyString, optionalJson)\n public async addNonChatParticipant(\n proxyAddress: string,\n address: string,\n attributes: JSONValue = {},\n bindingOptions: ParticipantBindingOptions = {}\n ): Promise<Participant> {\n return this._participantsEntity.addNonChatParticipant(\n proxyAddress,\n address,\n attributes ?? {},\n bindingOptions ?? {}\n );\n }\n\n /**\n * Advance the conversation's last read message index to the current read\n * horizon. Rejects if the user is not a participant of the conversation. Last\n * read message index is updated only if the new index value is higher than\n * the previous.\n * @param index Message index to advance to.\n * @return Resulting unread messages count in the conversation.\n */\n @validateTypesAsync(nonNegativeInteger)\n public async advanceLastReadMessageIndex(index: number): Promise<number> {\n await this._subscribeStreams();\n\n if (index < (this.lastReadMessageIndex ?? 0)) {\n return await this._setLastReadMessageIndex(this.lastReadMessageIndex);\n }\n\n return await this._setLastReadMessageIndex(index);\n }\n\n /**\n * Delete the conversation and unsubscribe from its events.\n */\n public async delete(): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource(\n \"delete\",\n this._links.self\n );\n\n return this;\n }\n\n /**\n * Get the custom attributes of this Conversation.\n */\n public async getAttributes(): Promise<JSONValue> {\n await this._subscribe();\n return this.attributes;\n }\n\n /**\n * Returns messages from the conversation using the paginator interface.\n * @param pageSize Number of messages to return in a single chunk. Default is\n * 30.\n * @param anchor Index of the newest message to fetch. Default is from the\n * end.\n * @param direction Query direction. By default, it queries backwards\n * from newer to older. The `\"forward\"` value will query in the opposite\n * direction.\n * @return A page of messages.\n */\n @validateTypesAsync(\n [\"undefined\", nonNegativeInteger],\n [\"undefined\", nonNegativeInteger],\n [\"undefined\", literal(\"backwards\", \"forward\")]\n )\n public async getMessages(\n pageSize?: number,\n anchor?: number,\n direction?: \"backwards\" | \"forward\"\n ): Promise<Paginator<Message>> {\n await this._subscribeStreams();\n return this._messagesEntity.getMessages(pageSize, anchor, direction);\n }\n\n /**\n * Get a list of all the participants who are joined to this conversation.\n */\n public async getParticipants(): Promise<Participant[]> {\n await this._subscribeStreams();\n return this._participantsEntity.getParticipants();\n }\n\n /**\n * Get conversation participants count.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n */\n public async getParticipantsCount(): Promise<number> {\n const url = new UriBuilder(this._configuration.links.conversations)\n .path(this.sid)\n .build();\n // todo: remove any after the release of new Twilsock\n const response = await this._services.network.get(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 public async getParticipantBySid(\n participantSid: string\n ): Promise<Participant | null> {\n return this._participantsEntity.getParticipantBySid(participantSid);\n }\n\n /**\n * Get a participant by its identity.\n * @param identity Participant identity.\n */\n @validateTypesAsync(nonEmptyString)\n public async getParticipantByIdentity(\n identity: string | null = \"\"\n ): Promise<Participant | null> {\n return this._participantsEntity.getParticipantByIdentity(identity ?? \"\");\n }\n\n /**\n * Get the total message count in the conversation.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n */\n public async getMessagesCount(): Promise<number> {\n const url = new UriBuilder(this._configuration.links.conversations)\n .path(this.sid)\n .build();\n // todo: remove any after the release of new Twilsock\n const response = await this._services.network.get(url);\n\n return response.body.messages_count ?? 0;\n }\n\n /**\n * Get count of unread messages for the user if they are a participant of this\n * conversation. Rejects if the user is not a participant of the conversation.\n *\n * Use this method to obtain the number of unread messages together with\n * {@link Conversation.updateLastReadMessageIndex} instead of relying on the\n * message indices which may have gaps. See {@link Message.index} for details.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but it will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n *\n * If the read horizon is not set, this function will return null. This could mean\n * that all messages in the conversation are unread, or that the read horizon system\n * is not being used. How to interpret this `null` value is up to the customer application.\n *\n * @return Number of unread messages based on the current read horizon set for\n * the user or `null` if the read horizon is not set.\n */\n public async getUnreadMessagesCount(): Promise<number | null> {\n const url = new UriBuilder(this._configuration.links.myConversations)\n .path(this.sid)\n .build();\n // todo: remove any after the release of new Twilsock\n const response = await this._services.network.get(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 public async join(): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource<\n AddParticipantRequest,\n ParticipantResponse\n >(\"post\", this._links.participants, {\n identity: this._configuration.userIdentity,\n });\n\n return this;\n }\n\n /**\n * Leave the conversation.\n */\n public async leave(): Promise<Conversation> {\n if (this._internalState.status === \"joined\") {\n await this._services.commandExecutor.mutateResource(\n \"delete\",\n `${this._links.participants}/${encodeURIComponent(\n this._configuration.userIdentity\n )}`\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 @validateTypesAsync([nonEmptyString, Participant])\n public async removeParticipant(\n participant: string | Participant\n ): Promise<void> {\n await this._participantsEntity.remove(\n typeof participant === \"string\" ? participant : participant.sid\n );\n }\n\n /**\n * Send a message to the conversation.\n * @param message Message body for the text message,\n * `FormData` or {@link SendMediaOptions} for media content. Sending FormData\n * is supported only with the browser engine.\n * @param messageAttributes Attributes for the message.\n * @param emailOptions Email options for the message.\n * @return Index of the new message.\n */\n @validateTypesAsync(\n [\n \"string\",\n FormData,\n literal(null),\n objectSchema(\"media options\", {\n contentType: nonEmptyString,\n media: custom((value) => {\n let isValid =\n (typeof value === \"string\" && value.length > 0) ||\n value instanceof Uint8Array ||\n value instanceof ArrayBuffer;\n\n if (typeof Blob === \"function\") {\n isValid = isValid || value instanceof Blob;\n }\n\n return [\n isValid,\n \"a non-empty string, an instance of Buffer or an instance of Blob\",\n ];\n }),\n }),\n ],\n optionalJson,\n [\n \"undefined\",\n literal(null),\n objectSchema(\"email attributes\", {\n subject: [nonEmptyString, \"undefined\"],\n }),\n ]\n )\n public async sendMessage(\n message: null | string | FormData | SendMediaOptions,\n messageAttributes?: JSONValue,\n emailOptions?: SendEmailOptions\n ): Promise<Message> {\n const response: MessageResponse =\n typeof message === \"string\" || message === null\n ? await this._messagesEntity.send(\n message,\n messageAttributes,\n emailOptions\n )\n : await this._messagesEntity.sendMedia(\n message,\n messageAttributes,\n emailOptions\n );\n const type: MessageType =\n typeof message === \"string\" || message === null ? \"text\" : \"media\";\n\n let responseAttributes;\n try {\n responseAttributes = JSON.parse(response.attributes);\n } catch (e) {}\n\n const messageData = {\n sid: response.sid,\n text: response.body,\n type,\n author: response.author,\n subject: response.subject,\n contentSid: response.content_sid,\n lastUpdatedBy: response.participant_sid,\n attributes: responseAttributes,\n dateUpdated: response.date_updated,\n timestamp: response.date_created,\n memberSid: response.participant_sid,\n medias: Array.isArray(response.media)\n ? response.media.map((media) => ({\n sid: media[\"sid\"],\n size: Number(media[\"size\"]),\n category: media[\"category\"] as MediaCategory,\n filename: media[\"filename\"],\n contentType: media[\"content_type\"],\n }))\n : null,\n media:\n response.media &&\n typeof response.media === \"object\" &&\n !Array.isArray(response.media)\n ? {\n sid: response.media[\"sid\"],\n size: Number(response.media[\"size\"]),\n category: response.media[\"category\"] as MediaCategory,\n filename: response.media[\"filename\"],\n contentType: response.media[\"content_type\"],\n }\n : null,\n hasChannelMetadata: false,\n };\n\n return this._messagesEntity._upsertMessage(response.index, messageData);\n }\n\n /**\n * New interface to prepare for sending a message.\n * Use this instead of {@link Conversation.sendMessage}.\n * @return A MessageBuilder to help set all message sending options.\n */\n public prepareMessage(): MessageBuilder {\n return new MessageBuilder(this.limits, this._messagesEntity);\n }\n\n /**\n * Set last read message index of the conversation to the index of the last\n * known message.\n * @return Resulting unread messages count in the conversation.\n */\n public async setAllMessagesRead(): Promise<number> {\n await this._subscribeStreams();\n\n const messagesPage = await this.getMessages(1);\n\n if (messagesPage.items.length > 0) {\n return this.advanceLastReadMessageIndex(messagesPage.items[0].index);\n }\n\n return 0;\n }\n\n /**\n * Set all messages in the conversation unread.\n * @returns New count of unread messages after this update.\n */\n public async setAllMessagesUnread(): Promise<number> {\n await this._subscribeStreams();\n return await this._setLastReadMessageIndex(null);\n }\n\n /**\n * Set user notification level for this conversation.\n * @param notificationLevel New user notification level.\n */\n @validateTypesAsync(literal(\"default\", \"muted\"))\n public async setUserNotificationLevel(\n notificationLevel: NotificationLevel\n ): Promise<void> {\n await this._services.commandExecutor.mutateResource<EditNotificationLevelRequest>(\n \"post\",\n `${this._configuration.links.myConversations}/${this.sid}`,\n {\n notification_level: notificationLevel,\n }\n );\n }\n\n /**\n * Send a notification to the server indicating that this client is currently\n * typing in this conversation. Typing ended notification is sent after a\n * while automatically, but by calling this method again you ensure that\n * typing ended is not received.\n */\n public typing(): Promise<void> {\n return this._services.typingIndicator.send(this.sid);\n }\n\n /**\n * Update the attributes of the conversation.\n * @param attributes New attributes.\n */\n @validateTypesAsync(json)\n public async updateAttributes(attributes: JSONValue): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, {\n attributes:\n attributes !== undefined ? JSON.stringify(attributes) : undefined,\n });\n\n return this;\n }\n\n /**\n * Update the friendly name of the conversation.\n * @param friendlyName New friendly name.\n */\n @validateTypesAsync(\"string\")\n public async updateFriendlyName(friendlyName: string): Promise<Conversation> {\n if (this._internalState.friendlyName !== friendlyName) {\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, { friendly_name: friendlyName });\n }\n\n return this;\n }\n\n /**\n * Set the last read message index to the current read horizon.\n * @param index Message index to set as last read. If null is provided, then\n * the behavior is identical to {@link Conversation.setAllMessagesUnread}.\n * @returns New count of unread messages after this update.\n */\n @validateTypesAsync([literal(null), nonNegativeInteger])\n public async updateLastReadMessageIndex(\n index: number | null\n ): Promise<number> {\n await this._subscribeStreams();\n return this._setLastReadMessageIndex(index);\n }\n\n /**\n * Update the unique name of the conversation.\n * @param uniqueName New unique name for the conversation. Setting unique name\n * to null removes it.\n */\n @validateTypesAsync([\"string\", literal(null)])\n public async updateUniqueName(\n uniqueName: string | null\n ): Promise<Conversation> {\n if (this._internalState.uniqueName !== uniqueName) {\n uniqueName ||= \"\";\n\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, {\n unique_name: uniqueName,\n });\n }\n\n return this;\n }\n\n /**\n * Load and subscribe to this conversation and do not subscribe to its\n * participants and messages. This or _subscribeStreams will need to be called\n * before any events on conversation will fire.\n * @internal\n */\n public async _subscribe(): Promise<SyncDocument> {\n if (this._entityPromise) {\n return this._entityPromise;\n }\n\n this._entityPromise = this._services.syncClient.document({\n id: this._entityName,\n mode: \"open_existing\",\n });\n\n try {\n this._entity = await this._entityPromise;\n this._entity.on(\"updated\", (args) => this._update(args.data));\n this._entity.on(\"removed\", () => this.emit(\"removed\", this));\n this._update(this._entity.data);\n\n return this._entity;\n } catch (err) {\n this._entity = null;\n this._entityPromise = null;\n\n if (this._services.syncClient.connectionState != \"disconnected\") {\n Conversation._logger.error(\"Failed to get conversation object\", err);\n }\n Conversation._logger.debug(\n \"ERROR: Failed to get conversation object\",\n err\n );\n\n throw err;\n }\n }\n\n /**\n * Fetch participants and messages of the conversation. This method needs to\n * be called during conversation initialization to catch broken conversations\n * (broken conversations are conversations that have essential Sync entities\n * missing, i.e. the conversation document, the messages list or the\n * participant map). In case of this conversation being broken, the method\n * will throw an exception that will be caught and handled gracefully.\n * @internal\n */\n public async _fetchStreams() {\n await this._subscribe();\n Conversation._logger.trace(\n \"_streamsAvailable, this.entity.data=\",\n this._entity?.data\n );\n\n const data = this._entity?.data as Record<string, string>;\n this._messagesList = await this._services.syncClient.list({\n id: data.messages,\n mode: \"open_existing\",\n });\n this._participantsMap = await this._services.syncClient.map({\n id: data.roster,\n mode: \"open_existing\",\n });\n }\n\n /**\n * Load the attributes of this conversation and instantiate its participants\n * and messages. This or _subscribe will need to be called before any events\n * on the conversation will fire. This will need to be called before any\n * events on participants or messages will fire\n * @internal\n */\n public async _subscribeStreams() {\n try {\n await this._subscribe();\n Conversation._logger.trace(\n \"_subscribeStreams, this.entity.data=\",\n this._entity?.data\n );\n\n const data = this._entity?.data as Record<string, string>;\n const messagesObjectName = data.messages;\n const rosterObjectName = data.roster;\n\n await Promise.all([\n this._messagesEntity.subscribe(\n this._messagesList ?? messagesObjectName\n ),\n this._participantsEntity.subscribe(\n this._participantsMap ?? rosterObjectName\n ),\n ]);\n } catch (err) {\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n Conversation._logger.error(\n \"Failed to subscribe on conversation objects\",\n this.sid,\n err\n );\n }\n Conversation._logger.debug(\n \"ERROR: Failed to subscribe on conversation objects\",\n this.sid,\n err\n );\n\n throw err;\n }\n }\n\n /**\n * Stop listening for and firing events on this conversation.\n * @internal\n */\n public async _unsubscribe() {\n if (this._entity) {\n await this._entity.close();\n this._entity = null;\n this._entityPromise = null;\n }\n\n return Promise.all([\n this._participantsEntity.unsubscribe(),\n this._messagesEntity.unsubscribe(),\n ]);\n }\n\n /**\n * Set conversation status.\n * @internal\n */\n public _setStatus(\n status: ConversationStatus,\n source: ConversationsDataSource\n ) {\n this._dataSource = source;\n\n if (this._internalState.status === status) {\n return;\n }\n\n this._internalState.status = status;\n\n if (status === \"joined\") {\n this._subscribeStreams().catch((err) => {\n Conversation._logger.debug(\n \"ERROR while setting conversation status \" + status,\n err\n );\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n throw err;\n }\n });\n return;\n }\n\n if (this._entityPromise) {\n this._unsubscribe().catch((err) => {\n Conversation._logger.debug(\n \"ERROR while setting conversation status \" + status,\n err\n );\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n throw err;\n }\n });\n }\n }\n\n /**\n * Update the local conversation object with new values.\n * @internal\n */\n public _update(update) {\n Conversation._logger.trace(\"_update\", update);\n\n Conversation.preprocessUpdate(update, this.sid);\n const updateReasons = new Set<ConversationUpdateReason>();\n\n for (const key of Object.keys(update)) {\n const localKey = fieldMappings[key];\n\n if (!localKey) {\n continue;\n }\n\n switch (localKey) {\n case fieldMappings.status:\n if (\n !update.status ||\n update.status === \"unknown\" ||\n this._internalState.status === update.status\n ) {\n break;\n }\n\n this._internalState.status = update.status;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.attributes:\n if (isEqual(this._internalState.attributes, update.attributes)) {\n break;\n }\n\n this._internalState.attributes = update.attributes;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.lastConsumedMessageIndex:\n if (\n update.lastConsumedMessageIndex === undefined ||\n update.lastConsumedMessageIndex ===\n this._internalState.lastReadMessageIndex\n ) {\n break;\n }\n\n this._internalState.lastReadMessageIndex =\n update.lastConsumedMessageIndex;\n updateReasons.add(\"lastReadMessageIndex\");\n\n break;\n case fieldMappings.lastMessage:\n if (this._internalState.lastMessage && !update.lastMessage) {\n delete this._internalState.lastMessage;\n updateReasons.add(localKey);\n\n break;\n }\n\n this._internalState.lastMessage =\n this._internalState.lastMessage || {};\n\n if (\n update.lastMessage?.index !== undefined &&\n update.lastMessage.index !== this._internalState.lastMessage.index\n ) {\n this._internalState.lastMessage.index = update.lastMessage.index;\n updateReasons.add(localKey);\n }\n\n if (\n update.lastMessage?.timestamp !== undefined &&\n this._internalState.lastMessage?.dateCreated?.getTime() !==\n update.lastMessage.timestamp.getTime()\n ) {\n this._internalState.lastMessage.dateCreated =\n update.lastMessage.timestamp;\n updateReasons.add(localKey);\n }\n\n if (isEqual(this._internalState.lastMessage, {})) {\n delete this._internalState.lastMessage;\n }\n\n break;\n case fieldMappings.state:\n const state = update.state || undefined;\n\n if (state !== undefined) {\n state.dateUpdated = new Date(state.dateUpdated);\n }\n\n if (isEqual(this._internalState.state, state)) {\n break;\n }\n\n this._internalState.state = state;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.bindings:\n if (isEqual(this._internalState.bindings, update.bindings)) {\n break;\n }\n\n this._internalState.bindings = update.bindings;\n updateReasons.add(localKey);\n\n break;\n default:\n const isDate = update[key] instanceof Date;\n const keysMatchAsDates =\n isDate &&\n this._internalState[localKey]?.getTime() === update[key].getTime();\n const keysMatchAsNonDates = !isDate && this[localKey] === update[key];\n\n if (keysMatchAsDates || keysMatchAsNonDates) {\n break;\n }\n\n this._internalState[localKey] = update[key];\n updateReasons.add(localKey);\n }\n }\n\n if (updateReasons.size > 0) {\n this.emit(\"updated\", {\n conversation: this,\n updateReasons: [...updateReasons],\n });\n }\n }\n\n /**\n * Handle onMessageAdded event.\n */\n private _onMessageAdded(message) {\n for (const participant of this._participants.values()) {\n if (participant.identity === message.author) {\n participant._endTyping();\n break;\n }\n }\n this.emit(\"messageAdded\", message);\n }\n\n /**\n * Set last read message index.\n * @param index New index to set.\n */\n private async _setLastReadMessageIndex(\n index: number | null\n ): Promise<number> {\n const result = await this._services.commandExecutor.mutateResource<\n EditLastReadMessageIndexRequest,\n EditLastReadMessageIndexResponse\n >(\"post\", `${this._configuration.links.myConversations}/${this.sid}`, {\n last_read_message_index: index,\n });\n\n return result.unread_messages_count;\n }\n}\n\nexport {\n ConversationDescriptor,\n Conversation,\n ConversationServices,\n ConversationUpdateReason,\n ConversationStatus,\n NotificationLevel,\n ConversationState,\n ConversationUpdatedEventArgs,\n SendMediaOptions,\n SendEmailOptions,\n LastMessage,\n ConversationBindings,\n ConversationEmailBinding,\n};\n"],"names":["ReplayEventEmitter","parseTime","Participants","Messages","UriBuilder","MessageBuilder","isEqual","Logger","__decorate","valid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AAA,CAAA;AAiBYL,oBAAA,CAAA;IADZC,2CAAkB,CAACQ,UAAI,CAAC;;;;AAWxB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA,CAAA;AAOYT,oBAAA,CAAA;IADZC,2CAAkB,CAAC,QAAQ,CAAC;;;;AAU5B,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,IAAA,CAAA,CAAA;AASYD,oBAAA,CAAA;IADZC,2CAAkB,CAAC,CAACI,gCAAO,CAAC,IAAI,CAAC,EAAED,2CAAkB,CAAC,CAAC;;;;AAMvD,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,4BAAA,EAAA,IAAA,CAAA,CAAA;AAQYJ,oBAAA,CAAA;IADZC,2CAAkB,CAAC,CAAC,QAAQ,EAAEI,gCAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;;;AAgB7C,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"conversation.js","sources":["../src/conversation.ts"],"sourcesContent":["import \"isomorphic-form-data\";\nimport { Logger } from \"./logger\";\nimport { ParticipantBindingOptions, Participants } from \"./data/participants\";\nimport {\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n} from \"./participant\";\nimport { Messages } from \"./data/messages\";\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason,\n} from \"./message\";\nimport { UriBuilder, parseToNumber, parseTime } from \"./util\";\nimport { Users } from \"./data/users\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { ConversationsDataSource } from \"./data/conversations\";\nimport { McsClient } from \"@twilio/mcs-client\";\nimport { SyncClient, SyncDocument, SyncList, SyncMap } 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 { json, optionalJson } from \"./interfaces/rules\";\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\";\nimport { ChannelMetadataClient } from \"./channel-metadata-client\";\nimport {\n MessageRecipientsClient,\n RecipientDescriptor,\n} from \"./message-recipients-client\";\n\n/**\n * Conversation events.\n */\ntype ConversationEvents = {\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n updated: (data: {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n }) => void;\n removed: (conversation: Conversation) => void;\n};\n\n/**\n * Reason for the `updated` event emission by a conversation.\n */\ntype ConversationUpdateReason =\n | \"attributes\"\n | \"createdBy\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"friendlyName\"\n | \"lastReadMessageIndex\"\n | \"state\"\n | \"status\"\n | \"uniqueName\"\n | \"lastMessage\"\n | \"notificationLevel\"\n | \"bindings\";\n\n/**\n * Status of the conversation, relative to the client: whether the conversation\n * has been `joined` or the client is `notParticipating` in the conversation.\n */\ntype ConversationStatus = \"notParticipating\" | \"joined\";\n\n/**\n * User's notification level for the conversation. Determines\n * whether the currently logged-in user will receive pushes for events\n * in this conversation. Can be either `muted` or `default`, where\n * `default` defers to the global service push configuration.\n */\ntype NotificationLevel = \"default\" | \"muted\";\n\n/**\n * State of the conversation.\n */\ninterface ConversationState {\n /**\n * Current state.\n */\n current: \"active\" | \"inactive\" | \"closed\";\n\n /**\n * Date at which the latest conversation state update happened.\n */\n dateUpdated: Date;\n}\n\n/**\n * Event arguments for the `updated` event.\n */\ninterface ConversationUpdatedEventArgs {\n conversation: Conversation;\n updateReasons: ConversationUpdateReason[];\n}\n\n/**\n * Binding for email conversation.\n */\ninterface ConversationBindings {\n email?: ConversationEmailBinding;\n sms?: ConversationSmsBinding;\n}\n\n/**\n * Binding for email conversation.\n */\ninterface ConversationEmailBinding {\n name?: string;\n projected_address: string;\n}\n\n/**\n * Binding for SMS conversation.\n */\ninterface ConversationSmsBinding {\n address?: string;\n}\n\n/**\n * Configuration for attaching a media file to a message.\n * These options can be passed to {@link Conversation.sendMessage} and\n * {@link MessageBuilder.addMedia}.\n */\ninterface SendMediaOptions {\n /**\n * Content type of media.\n */\n contentType: null | string;\n\n /**\n * Optional filename.\n */\n filename?: string;\n\n /**\n * Content to post.\n */\n media: null | string | Buffer | Blob;\n}\n\n/**\n * These options can be passed to {@link Conversation.sendMessage}.\n */\ninterface SendEmailOptions {\n /**\n * Message subject. Ignored for media messages.\n */\n subject?: string;\n}\n\n/**\n * Information about the last message of a conversation.\n */\ninterface LastMessage {\n /**\n * Message's index.\n */\n index?: number;\n\n /**\n * Message's creation date.\n */\n dateCreated?: Date;\n}\n\n/**\n * Conversation services.\n */\ninterface ConversationServices {\n users: Users;\n typingIndicator: TypingIndicator;\n network: Network;\n mcsClient: McsClient;\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n channelMetadataClient: ChannelMetadataClient;\n messageRecipientsClient: MessageRecipientsClient;\n}\n\n/**\n * Internal (private) state of the conversation.\n */\ninterface ConversationInternalState {\n uniqueName: string | null;\n status: ConversationStatus;\n attributes: JSONValue;\n createdBy?: string;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n friendlyName: string | null;\n lastReadMessageIndex: number | null;\n lastMessage?: LastMessage;\n notificationLevel?: NotificationLevel;\n state?: ConversationState;\n bindings: ConversationBindings;\n}\n\n/**\n * Conversation descriptor.\n */\ninterface ConversationDescriptor {\n channel: string;\n entityName: string;\n uniqueName: string;\n attributes: JSONValue;\n createdBy?: string;\n friendlyName?: string;\n lastConsumedMessageIndex: number;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n notificationLevel?: NotificationLevel;\n bindings?: ConversationBindings;\n}\n\n/**\n * Conversation links.\n */\ninterface ConversationLinks {\n self: string;\n messages: string;\n participants: string;\n}\n\n/**\n * Map of the fields that will be processed with update messages.\n */\nconst fieldMappings = {\n lastMessage: \"lastMessage\",\n attributes: \"attributes\",\n createdBy: \"createdBy\",\n dateCreated: \"dateCreated\",\n dateUpdated: \"dateUpdated\",\n friendlyName: \"friendlyName\",\n lastConsumedMessageIndex: \"lastConsumedMessageIndex\",\n notificationLevel: \"notificationLevel\",\n sid: \"sid\",\n status: \"status\",\n uniqueName: \"uniqueName\",\n state: \"state\",\n bindings: \"bindings\",\n};\n\n/**\n * A conversation represents communication between multiple Conversations\n * clients.\n */\nclass Conversation extends ReplayEventEmitter<ConversationEvents> {\n /**\n * Fired when a participant has joined the conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - participant that joined the\n * conversation\n * @event\n */\n public static readonly participantJoined = \"participantJoined\";\n\n /**\n * Fired when a participant has left the conversation.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - participant that left the\n * conversation\n * @event\n */\n public static readonly participantLeft = \"participantLeft\";\n\n /**\n * Fired when data of a participant has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Participant} `participant` - participant that has received the\n * update\n * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly participantUpdated = \"participantUpdated\";\n\n /**\n * Fired when a new message has been added to the conversation.\n *\n * Parameters:\n * 1. {@link Message} `message` - message that has been added\n * @event\n */\n public static readonly messageAdded = \"messageAdded\";\n\n /**\n * Fired when message is removed from the conversation's message list.\n *\n * Parameters:\n * 1. {@link Message} `message` - message that has been removed\n * @event\n */\n public static readonly messageRemoved = \"messageRemoved\";\n\n /**\n * Fired when data of a message has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Message} `message` - message that has received the update\n * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for\n * the update\n * @event\n */\n public static readonly messageUpdated = \"messageUpdated\";\n\n /**\n * Fired when a participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant that has stopped\n * typing\n * @event\n */\n public static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when a participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant that has started\n * typing\n * @event\n */\n public static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the data of the conversation has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the\n * following properties:\n * * {@link Conversation} `conversation` - conversation that has received\n * the update\n * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons\n * for the update\n * @event\n */\n public static readonly updated = \"updated\";\n\n /**\n * Fired when the conversation was destroyed or the currently-logged-in user\n * has left private conversation.\n *\n * Parameters:\n * 1. {@link Conversation} `conversation` - conversation that has been removed\n * @event\n */\n public static readonly removed = \"removed\";\n\n /**\n * Logger instance.\n */\n private static readonly _logger = Logger.scope(\"Conversation\");\n\n /**\n * Unique system identifier of the conversation.\n */\n public readonly sid: string;\n\n /**\n * Conversation links for REST requests.\n * @internal\n */\n public readonly _links: ConversationLinks;\n\n /**\n * Map of participants.\n * @internal\n */\n public readonly _participants: Map<string, Participant>;\n\n /**\n * Configuration of the client that the conversation belongs to.\n */\n private readonly _configuration: Configuration;\n\n /**\n * Conversation service objects.\n */\n private readonly _services: ConversationServices;\n\n /**\n * Internal state of the conversation.\n */\n private readonly _internalState: ConversationInternalState;\n\n /**\n * Name of the conversation entity document.\n */\n private readonly _entityName: string;\n\n /**\n * Messages entity.\n */\n private readonly _messagesEntity: Messages;\n\n /**\n * Sync list containing messages.\n */\n private _messagesList?: SyncList;\n\n /**\n * Participants entity.\n */\n private readonly _participantsEntity: Participants;\n\n /**\n * Sync map containing participants.\n */\n private _participantsMap?: SyncMap;\n\n /**\n * Source of the most recent update.\n */\n private _dataSource!: ConversationsDataSource;\n\n /**\n * Promise for the conversation entity document.\n */\n private _entityPromise!: Promise<SyncDocument> | null;\n\n /**\n * Conversation entity document.\n */\n private _entity!: SyncDocument | null;\n\n /**\n * @param descriptor Conversation descriptor.\n * @param sid Conversation SID.\n * @param links Conversation links for REST requests.\n * @param configuration Client configuration.\n * @param services Conversation services.\n * @internal\n */\n public constructor(\n descriptor: ConversationDescriptor,\n sid: string,\n links: ConversationLinks,\n configuration: Configuration,\n services: ConversationServices\n ) {\n super();\n\n this.sid = sid;\n this._links = links;\n this._configuration = configuration;\n this._services = services;\n this._entityName = descriptor.channel;\n this._internalState = {\n uniqueName: descriptor.uniqueName || null,\n status: \"notParticipating\",\n attributes: descriptor.attributes ?? {},\n createdBy: descriptor.createdBy,\n dateCreated: parseTime(descriptor.dateCreated),\n dateUpdated: parseTime(descriptor.dateUpdated),\n friendlyName: descriptor.friendlyName || null,\n lastReadMessageIndex: Number.isInteger(\n descriptor.lastConsumedMessageIndex\n )\n ? descriptor.lastConsumedMessageIndex\n : null,\n bindings: descriptor.bindings ?? {},\n };\n\n if (descriptor.notificationLevel) {\n this._internalState.notificationLevel = descriptor.notificationLevel;\n }\n\n const participantsLinks = {\n participants: this._links.participants,\n };\n\n this._participants = new Map();\n this._participantsEntity = new Participants(\n this,\n this._participants,\n participantsLinks,\n this._configuration,\n this._services\n );\n this._participantsEntity.on(\"participantJoined\", (participant) =>\n this.emit(\"participantJoined\", participant)\n );\n this._participantsEntity.on(\"participantLeft\", (participant) =>\n this.emit(\"participantLeft\", participant)\n );\n this._participantsEntity.on(\n \"participantUpdated\",\n (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n\n this._messagesEntity = new Messages(this, configuration, services);\n this._messagesEntity.on(\"messageAdded\", (message) =>\n this._onMessageAdded(message)\n );\n this._messagesEntity.on(\"messageUpdated\", (args: MessageUpdatedEventArgs) =>\n this.emit(\"messageUpdated\", args)\n );\n this._messagesEntity.on(\"messageRemoved\", (message) =>\n this.emit(\"messageRemoved\", message)\n );\n }\n\n /**\n * Unique name of the conversation.\n */\n public get uniqueName(): string | null {\n return this._internalState.uniqueName;\n }\n\n /**\n * Status of the conversation.\n */\n public get status(): ConversationStatus {\n return this._internalState.status;\n }\n\n /**\n * Name of the conversation.\n */\n public get friendlyName(): string | null {\n return this._internalState.friendlyName;\n }\n\n /**\n * Date this conversation was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this._internalState.dateUpdated;\n }\n\n /**\n * Date this conversation was created on.\n */\n public get dateCreated(): Date | null {\n return this._internalState.dateCreated;\n }\n\n /**\n * Identity of the user that created this conversation.\n */\n public get createdBy(): string {\n return this._internalState.createdBy ?? \"\";\n }\n\n /**\n * Custom attributes of the conversation.\n */\n public get attributes(): JSONValue {\n return this._internalState.attributes;\n }\n\n /**\n * Index of the last message the user has read in this conversation.\n */\n public get lastReadMessageIndex(): number | null {\n return this._internalState.lastReadMessageIndex;\n }\n\n /**\n * Last message sent to this conversation.\n */\n public get lastMessage(): LastMessage | undefined {\n return this._internalState.lastMessage ?? undefined;\n }\n\n /**\n * User notification level for this conversation.\n */\n public get notificationLevel(): NotificationLevel {\n return this._internalState.notificationLevel ?? \"default\";\n }\n\n /**\n * Conversation bindings. Undocumented feature (for now).\n * @internal\n */\n public get bindings(): ConversationBindings {\n return this._internalState.bindings;\n }\n\n /**\n * Current conversation limits.\n */\n public get limits(): ConversationLimits {\n return this._configuration.limits;\n }\n\n /**\n * State of the conversation.\n */\n public get state(): ConversationState | undefined {\n return this._internalState.state;\n }\n\n /**\n * Source of the conversation update.\n * @internal\n */\n public get _statusSource(): ConversationsDataSource {\n return this._dataSource;\n }\n\n /**\n * Preprocess the update object.\n * @param update The update object received from Sync.\n * @param conversationSid The SID of the conversation in question.\n */\n private static preprocessUpdate(update, conversationSid: string) {\n try {\n if (typeof update.attributes === \"string\") {\n update.attributes = JSON.parse(update.attributes);\n } else if (update.attributes) {\n JSON.stringify(update.attributes);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed attributes from the server for conversation: \" +\n conversationSid\n );\n update.attributes = {};\n }\n\n try {\n if (update.dateCreated) {\n update.dateCreated = new Date(update.dateCreated);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed dateCreated from the server for conversation: \" +\n conversationSid\n );\n delete update.dateCreated;\n }\n\n try {\n if (update.dateUpdated) {\n update.dateUpdated = new Date(update.dateUpdated);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed dateUpdated from the server for conversation: \" +\n conversationSid\n );\n delete update.dateUpdated;\n }\n\n try {\n if (update.lastMessage && update.lastMessage.timestamp) {\n update.lastMessage.timestamp = new Date(update.lastMessage.timestamp);\n }\n } catch (e) {\n Conversation._logger.warn(\n \"Retrieved malformed lastMessage.timestamp from the server for conversation: \" +\n conversationSid\n );\n delete update.lastMessage.timestamp;\n }\n }\n\n /**\n * Add a participant to the conversation by its identity.\n * @param identity Identity of the Client to add.\n * @param attributes Attributes to be attached to the participant.\n * @returns The added participant.\n */\n @validateTypesAsync(nonEmptyString, optionalJson)\n public 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\n * CC/To level.\n * @returns The added participant.\n */\n @validateTypesAsync(nonEmptyString, nonEmptyString, optionalJson)\n public 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\n * horizon. Rejects if the user is not a participant of the conversation. Last\n * read message index is updated only if the new index value is higher than\n * the previous.\n * @param index Message index to advance to.\n * @return Resulting unread messages count in the conversation.\n */\n @validateTypesAsync(nonNegativeInteger)\n public async advanceLastReadMessageIndex(index: number): Promise<number> {\n await this._subscribeStreams();\n\n if (index < (this.lastReadMessageIndex ?? 0)) {\n return await this._setLastReadMessageIndex(this.lastReadMessageIndex);\n }\n\n return await this._setLastReadMessageIndex(index);\n }\n\n /**\n * Delete the conversation and unsubscribe from its events.\n */\n public async delete(): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource(\n \"delete\",\n this._links.self\n );\n\n return this;\n }\n\n /**\n * Get the custom attributes of this Conversation.\n */\n public async getAttributes(): Promise<JSONValue> {\n await this._subscribe();\n return this.attributes;\n }\n\n /**\n * Returns messages from the conversation using the paginator interface.\n * @param pageSize Number of messages to return in a single chunk. Default is\n * 30.\n * @param anchor Index of the newest message to fetch. Default is from the\n * end.\n * @param direction Query direction. By default, it queries backwards\n * from newer to older. The `\"forward\"` value will query in the opposite\n * direction.\n * @return A page of messages.\n */\n @validateTypesAsync(\n [\"undefined\", nonNegativeInteger],\n [\"undefined\", nonNegativeInteger],\n [\"undefined\", literal(\"backwards\", \"forward\")]\n )\n public async getMessages(\n pageSize?: number,\n anchor?: number,\n direction?: \"backwards\" | \"forward\"\n ): Promise<Paginator<Message>> {\n await this._subscribeStreams();\n return this._messagesEntity.getMessages(pageSize, anchor, direction);\n }\n\n /**\n * Get a list of all the participants who are joined to this conversation.\n */\n public async getParticipants(): Promise<Participant[]> {\n await this._subscribeStreams();\n return this._participantsEntity.getParticipants();\n }\n\n /**\n * Get conversation participants count.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n */\n public async getParticipantsCount(): Promise<number> {\n const url = new UriBuilder(this._configuration.links.conversations)\n .path(this.sid)\n .build();\n const response = await this._services.network.get<ConversationResponse>(\n url\n );\n\n return response.body.participants_count ?? 0;\n }\n\n /**\n * Get a participant by its SID.\n * @param participantSid Participant SID.\n */\n @validateTypesAsync(nonEmptyString)\n public async getParticipantBySid(\n participantSid: string\n ): Promise<Participant | null> {\n return this._participantsEntity.getParticipantBySid(participantSid);\n }\n\n /**\n * Get a participant by its identity.\n * @param identity Participant identity.\n */\n @validateTypesAsync(nonEmptyString)\n public async getParticipantByIdentity(\n identity: string | null = \"\"\n ): Promise<Participant | null> {\n return this._participantsEntity.getParticipantByIdentity(identity ?? \"\");\n }\n\n /**\n * Get the total message count in the conversation.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n */\n public async getMessagesCount(): Promise<number> {\n const url = new UriBuilder(this._configuration.links.conversations)\n .path(this.sid)\n .build();\n const response = await this._services.network.get<ConversationResponse>(\n url\n );\n\n return response.body.messages_count ?? 0;\n }\n\n /**\n * Get count of unread messages for the user if they are a participant of this\n * conversation. Rejects if the user is not a participant of the conversation.\n *\n * Use this method to obtain the number of unread messages together with\n * {@link Conversation.updateLastReadMessageIndex} instead of relying on the\n * message indices which may have gaps. See {@link Message.index} for details.\n *\n * This method is semi-realtime. This means that this data will be eventually\n * correct, but it will also be possibly incorrect for a few seconds. The\n * Conversations system does not provide real time events for counter values\n * changes.\n *\n * This is useful for any UI badges, but it is not recommended to build any\n * core application logic based on these counters being accurate in real time.\n *\n * If the read horizon is not set, this function will return null. This could mean\n * that all messages in the conversation are unread, or that the read horizon system\n * is not being used. How to interpret this `null` value is up to the customer application.\n *\n * @return Number of unread messages based on the current read horizon set for\n * the user or `null` if the read horizon is not set.\n */\n public async getUnreadMessagesCount(): Promise<number | null> {\n const url = new UriBuilder(this._configuration.links.myConversations)\n .path(this.sid)\n .build();\n const response = await this._services.network.get<ConversationResponse>(\n url\n );\n\n if (response.body.conversation_sid !== this.sid) {\n throw new Error(\n \"Conversation was not found in the user conversations list\"\n );\n }\n\n const unreadMessageCount = response.body.unread_messages_count;\n\n if (typeof unreadMessageCount === \"number\") {\n return unreadMessageCount;\n }\n\n return null;\n }\n\n /**\n * Join the conversation and subscribe to its events.\n */\n public async join(): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource<\n AddParticipantRequest,\n ParticipantResponse\n >(\"post\", this._links.participants, {\n identity: this._configuration.userIdentity,\n });\n\n return this;\n }\n\n /**\n * Leave the conversation.\n */\n public async leave(): Promise<Conversation> {\n if (this._internalState.status === \"joined\") {\n await this._services.commandExecutor.mutateResource(\n \"delete\",\n `${this._links.participants}/${encodeURIComponent(\n this._configuration.userIdentity\n )}`\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 @validateTypesAsync([nonEmptyString, Participant])\n public async removeParticipant(\n participant: string | Participant\n ): Promise<void> {\n await this._participantsEntity.remove(\n typeof participant === \"string\" ? participant : participant.sid\n );\n }\n\n /**\n * Send a message to the conversation.\n * @param message Message body for the text message,\n * `FormData` or {@link SendMediaOptions} for media content. Sending FormData\n * is supported only with the browser engine.\n * @param messageAttributes Attributes for the message.\n * @param emailOptions Email options for the message.\n * @return Index of the new message.\n */\n @validateTypesAsync(\n [\n \"string\",\n FormData,\n literal(null),\n objectSchema(\"media options\", {\n contentType: nonEmptyString,\n media: custom((value) => {\n let isValid =\n (typeof value === \"string\" && value.length > 0) ||\n value instanceof Uint8Array ||\n value instanceof ArrayBuffer;\n\n if (typeof Blob === \"function\") {\n isValid = isValid || value instanceof Blob;\n }\n\n return [\n isValid,\n \"a non-empty string, an instance of Buffer or an instance of Blob\",\n ];\n }),\n }),\n ],\n optionalJson,\n [\n \"undefined\",\n literal(null),\n objectSchema(\"email attributes\", {\n subject: [nonEmptyString, \"undefined\"],\n }),\n ]\n )\n public async sendMessage(\n message: null | string | FormData | SendMediaOptions,\n messageAttributes?: JSONValue,\n emailOptions?: SendEmailOptions\n ): Promise<number> {\n if (typeof message === \"string\" || message === null) {\n const response = await this._messagesEntity.send(\n message,\n messageAttributes,\n emailOptions\n );\n return parseToNumber(response.index) ?? 0;\n }\n\n const response = await this._messagesEntity.sendMedia(\n message,\n messageAttributes,\n emailOptions\n );\n return parseToNumber(response.index) ?? 0;\n }\n\n /**\n * New interface to prepare for sending a message.\n * Use this instead of {@link Conversation.sendMessage}.\n * @return A MessageBuilder to help set all message sending options.\n */\n public prepareMessage(): MessageBuilder {\n return new MessageBuilder(this.limits, this._messagesEntity);\n }\n\n /**\n * Set last read message index of the conversation to the index of the last\n * known message.\n * @return Resulting unread messages count in the conversation.\n */\n public async setAllMessagesRead(): Promise<number> {\n await this._subscribeStreams();\n\n const messagesPage = await this.getMessages(1);\n\n if (messagesPage.items.length > 0) {\n return this.advanceLastReadMessageIndex(messagesPage.items[0].index);\n }\n\n return 0;\n }\n\n /**\n * Set all messages in the conversation unread.\n * @returns New count of unread messages after this update.\n */\n public async setAllMessagesUnread(): Promise<number> {\n await this._subscribeStreams();\n return await this._setLastReadMessageIndex(null);\n }\n\n /**\n * Set user notification level for this conversation.\n * @param notificationLevel New user notification level.\n */\n @validateTypesAsync(literal(\"default\", \"muted\"))\n public async setUserNotificationLevel(\n notificationLevel: NotificationLevel\n ): Promise<void> {\n await this._services.commandExecutor.mutateResource<EditNotificationLevelRequest>(\n \"post\",\n `${this._configuration.links.myConversations}/${this.sid}`,\n {\n notification_level: notificationLevel,\n }\n );\n }\n\n /**\n * Send a notification to the server indicating that this client is currently\n * typing in this conversation. Typing ended notification is sent after a\n * while automatically, but by calling this method again you ensure that\n * typing ended is not received.\n */\n public typing(): Promise<void> {\n return this._services.typingIndicator.send(this.sid);\n }\n\n /**\n * Update the attributes of the conversation.\n * @param attributes New attributes.\n */\n @validateTypesAsync(json)\n public async updateAttributes(attributes: JSONValue): Promise<Conversation> {\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, {\n attributes:\n attributes !== undefined ? JSON.stringify(attributes) : undefined,\n });\n\n return this;\n }\n\n /**\n * Update the friendly name of the conversation.\n * @param friendlyName New friendly name.\n */\n @validateTypesAsync(\"string\")\n public async updateFriendlyName(friendlyName: string): Promise<Conversation> {\n if (this._internalState.friendlyName !== friendlyName) {\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, { friendly_name: friendlyName });\n }\n\n return this;\n }\n\n /**\n * Set the last read message index to the current read horizon.\n * @param index Message index to set as last read. If null is provided, then\n * the behavior is identical to {@link Conversation.setAllMessagesUnread}.\n * @returns New count of unread messages after this update.\n */\n @validateTypesAsync([literal(null), nonNegativeInteger])\n public async updateLastReadMessageIndex(\n index: number | null\n ): Promise<number> {\n await this._subscribeStreams();\n return this._setLastReadMessageIndex(index);\n }\n\n /**\n * Update the unique name of the conversation.\n * @param uniqueName New unique name for the conversation. Setting unique name\n * to null removes it.\n */\n @validateTypesAsync([\"string\", literal(null)])\n public async updateUniqueName(\n uniqueName: string | null\n ): Promise<Conversation> {\n if (this._internalState.uniqueName !== uniqueName) {\n uniqueName ||= \"\";\n\n await this._services.commandExecutor.mutateResource<\n EditConversationRequest,\n ConversationResponse\n >(\"post\", this._links.self, {\n unique_name: uniqueName,\n });\n }\n\n return this;\n }\n\n /**\n * Get recipients of all messages in the conversation.\n */\n public async getMessageRecipients(): Promise<Paginator<RecipientDescriptor>> {\n return await this._services.messageRecipientsClient.getRecipientsFromConversation(\n this.sid\n );\n }\n\n /**\n * Load and subscribe to this conversation and do not subscribe to its\n * participants and messages. This or _subscribeStreams will need to be called\n * before any events on conversation will fire.\n * @internal\n */\n public async _subscribe(): Promise<SyncDocument> {\n if (this._entityPromise) {\n return this._entityPromise;\n }\n\n this._entityPromise = this._services.syncClient.document({\n id: this._entityName,\n mode: \"open_existing\",\n });\n\n try {\n this._entity = await this._entityPromise;\n this._entity.on(\"updated\", (args) => this._update(args.data));\n this._entity.on(\"removed\", () => this.emit(\"removed\", this));\n this._update(this._entity.data);\n\n return this._entity;\n } catch (err) {\n this._entity = null;\n this._entityPromise = null;\n\n if (this._services.syncClient.connectionState != \"disconnected\") {\n Conversation._logger.error(\"Failed to get conversation object\", err);\n }\n Conversation._logger.debug(\n \"ERROR: Failed to get conversation object\",\n err\n );\n\n throw err;\n }\n }\n\n /**\n * Fetch participants and messages of the conversation. This method needs to\n * be called during conversation initialization to catch broken conversations\n * (broken conversations are conversations that have essential Sync entities\n * missing, i.e. the conversation document, the messages list or the\n * participant map). In case of this conversation being broken, the method\n * will throw an exception that will be caught and handled gracefully.\n * @internal\n */\n public async _fetchStreams() {\n await this._subscribe();\n Conversation._logger.trace(\n \"_streamsAvailable, this.entity.data=\",\n this._entity?.data\n );\n\n const data = this._entity?.data as Record<string, string>;\n this._messagesList = await this._services.syncClient.list({\n id: data.messages,\n mode: \"open_existing\",\n });\n this._participantsMap = await this._services.syncClient.map({\n id: data.roster,\n mode: \"open_existing\",\n });\n }\n\n /**\n * Load the attributes of this conversation and instantiate its participants\n * and messages. This or _subscribe will need to be called before any events\n * on the conversation will fire. This will need to be called before any\n * events on participants or messages will fire\n * @internal\n */\n public async _subscribeStreams() {\n try {\n await this._subscribe();\n Conversation._logger.trace(\n \"_subscribeStreams, this.entity.data=\",\n this._entity?.data\n );\n\n const data = this._entity?.data as Record<string, string>;\n const messagesObjectName = data.messages;\n const rosterObjectName = data.roster;\n\n await Promise.all([\n this._messagesEntity.subscribe(\n this._messagesList ?? messagesObjectName\n ),\n this._participantsEntity.subscribe(\n this._participantsMap ?? rosterObjectName\n ),\n ]);\n } catch (err) {\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n Conversation._logger.error(\n \"Failed to subscribe on conversation objects\",\n this.sid,\n err\n );\n }\n Conversation._logger.debug(\n \"ERROR: Failed to subscribe on conversation objects\",\n this.sid,\n err\n );\n\n throw err;\n }\n }\n\n /**\n * Stop listening for and firing events on this conversation.\n * @internal\n */\n public async _unsubscribe() {\n if (this._entity) {\n await this._entity.close();\n this._entity = null;\n this._entityPromise = null;\n }\n\n return Promise.all([\n this._participantsEntity.unsubscribe(),\n this._messagesEntity.unsubscribe(),\n ]);\n }\n\n /**\n * Set conversation status.\n * @internal\n */\n public _setStatus(\n status: ConversationStatus,\n source: ConversationsDataSource\n ) {\n this._dataSource = source;\n\n if (this._internalState.status === status) {\n return;\n }\n\n this._internalState.status = status;\n\n if (status === \"joined\") {\n this._subscribeStreams().catch((err) => {\n Conversation._logger.debug(\n \"ERROR while setting conversation status \" + status,\n err\n );\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n throw err;\n }\n });\n return;\n }\n\n if (this._entityPromise) {\n this._unsubscribe().catch((err) => {\n Conversation._logger.debug(\n \"ERROR while setting conversation status \" + status,\n err\n );\n if (this._services.syncClient.connectionState !== \"disconnected\") {\n throw err;\n }\n });\n }\n }\n\n /**\n * Update the local conversation object with new values.\n * @internal\n */\n public _update(update) {\n Conversation._logger.trace(\"_update\", update);\n\n Conversation.preprocessUpdate(update, this.sid);\n const updateReasons = new Set<ConversationUpdateReason>();\n\n for (const key of Object.keys(update)) {\n const localKey = fieldMappings[key];\n\n if (!localKey) {\n continue;\n }\n\n switch (localKey) {\n case fieldMappings.status:\n if (\n !update.status ||\n update.status === \"unknown\" ||\n this._internalState.status === update.status\n ) {\n break;\n }\n\n this._internalState.status = update.status;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.attributes:\n if (isEqual(this._internalState.attributes, update.attributes)) {\n break;\n }\n\n this._internalState.attributes = update.attributes;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.lastConsumedMessageIndex:\n if (\n update.lastConsumedMessageIndex === undefined ||\n update.lastConsumedMessageIndex ===\n this._internalState.lastReadMessageIndex\n ) {\n break;\n }\n\n this._internalState.lastReadMessageIndex =\n update.lastConsumedMessageIndex;\n updateReasons.add(\"lastReadMessageIndex\");\n\n break;\n case fieldMappings.lastMessage:\n if (this._internalState.lastMessage && !update.lastMessage) {\n delete this._internalState.lastMessage;\n updateReasons.add(localKey);\n\n break;\n }\n\n this._internalState.lastMessage =\n this._internalState.lastMessage || {};\n\n if (\n update.lastMessage?.index !== undefined &&\n update.lastMessage.index !== this._internalState.lastMessage.index\n ) {\n this._internalState.lastMessage.index = update.lastMessage.index;\n updateReasons.add(localKey);\n }\n\n if (\n update.lastMessage?.timestamp !== undefined &&\n this._internalState.lastMessage?.dateCreated?.getTime() !==\n update.lastMessage.timestamp.getTime()\n ) {\n this._internalState.lastMessage.dateCreated =\n update.lastMessage.timestamp;\n updateReasons.add(localKey);\n }\n\n if (isEqual(this._internalState.lastMessage, {})) {\n delete this._internalState.lastMessage;\n }\n\n break;\n case fieldMappings.state:\n const state = update.state || undefined;\n\n if (state !== undefined) {\n state.dateUpdated = new Date(state.dateUpdated);\n }\n\n if (isEqual(this._internalState.state, state)) {\n break;\n }\n\n this._internalState.state = state;\n updateReasons.add(localKey);\n\n break;\n case fieldMappings.bindings:\n if (isEqual(this._internalState.bindings, update.bindings)) {\n break;\n }\n\n this._internalState.bindings = update.bindings;\n updateReasons.add(localKey);\n\n break;\n default:\n const isDate = update[key] instanceof Date;\n const keysMatchAsDates =\n isDate &&\n this._internalState[localKey]?.getTime() === update[key].getTime();\n const keysMatchAsNonDates = !isDate && this[localKey] === update[key];\n\n if (keysMatchAsDates || keysMatchAsNonDates) {\n break;\n }\n\n this._internalState[localKey] = update[key];\n updateReasons.add(localKey);\n }\n }\n\n if (updateReasons.size > 0) {\n this.emit(\"updated\", {\n conversation: this,\n updateReasons: [...updateReasons],\n });\n }\n }\n\n /**\n * Handle onMessageAdded event.\n */\n private _onMessageAdded(message) {\n for (const participant of this._participants.values()) {\n if (participant.identity === message.author) {\n participant._endTyping();\n break;\n }\n }\n this.emit(\"messageAdded\", message);\n }\n\n /**\n * Set last read message index.\n * @param index New index to set.\n */\n private async _setLastReadMessageIndex(\n index: number | null\n ): Promise<number> {\n const result = await this._services.commandExecutor.mutateResource<\n EditLastReadMessageIndexRequest,\n EditLastReadMessageIndexResponse\n >(\"post\", `${this._configuration.links.myConversations}/${this.sid}`, {\n last_read_message_index: index,\n });\n\n return result.unread_messages_count;\n }\n}\n\nexport {\n ConversationDescriptor,\n Conversation,\n ConversationServices,\n ConversationUpdateReason,\n ConversationStatus,\n NotificationLevel,\n ConversationState,\n ConversationUpdatedEventArgs,\n SendMediaOptions,\n SendEmailOptions,\n LastMessage,\n ConversationBindings,\n ConversationEmailBinding,\n};\n"],"names":["ReplayEventEmitter","parseTime","Participants","Messages","UriBuilder","parseToNumber","MessageBuilder","isEqual","Logger","__decorate","validateTypesAsync","nonEmptyString","optionalJson","nonNegativeInteger","literal","Participant","objectSchema","custom","json"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoQA;;AAEG;AACH,MAAM,aAAa,GAAG;AACpB,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,SAAS,EAA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EI,gCAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;;;AAgB7C,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA;;;;"}
@@ -375,24 +375,8 @@ class Conversations extends replayEventEmitter.ReplayEventEmitter {
375
375
  log.trace(`upsertConversation: the conversation ${conversation$1.sid} is known;` +
376
376
  `its status is known from the source ${conversation$1._statusSource} ` +
377
377
  `and the update came from the source ${source}`, conversation$1);
378
- try {
379
- await this._updateConversation(source, conversation$1, data);
380
- await conversation$1._subscribe();
381
- }
382
- catch (error) {
383
- if (error.name !== "SyncError") {
384
- throw error;
385
- }
386
- // This case is possible when two async calls of _upsertConversation are
387
- // going at the same time. A case where the conversation was put into
388
- // the cache by the function that didn't go far enough to realize that
389
- // this conversation is broken (and therefore removed from the cache) is
390
- // possible when it gets asynchronously interrupted and another call to
391
- // the same function happens during the interrupt of the first one.
392
- log.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring", sid, error);
393
- this.conversations.delete(sid);
394
- return null;
395
- }
378
+ await this._updateConversation(source, conversation$1, data);
379
+ await conversation$1._subscribe();
396
380
  return conversation$1;
397
381
  }
398
382
  // If the conversations is deleted, ignore it