@twilio/conversations 3.0.1-rc.103 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/builds/browser.esm.js +10846 -0
- package/builds/browser.esm.js.map +1 -0
- package/builds/browser.js +579 -218
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +40 -27
- package/builds/lib.esm.d.ts +3178 -0
- package/builds/lib.esm.js +10845 -0
- package/builds/lib.js +588 -218
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +9111 -10398
- package/builds/twilio-conversations.js.map +1 -0
- package/builds/twilio-conversations.min.js +2 -1
- package/builds/twilio-conversations.min.js.map +1 -0
- package/dist/aggregated-delivery-receipt.js +1 -5
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +5 -10
- package/dist/channel-metadata-client.js.map +1 -1
- package/dist/client.js +218 -206
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +6 -10
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +6 -10
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +5 -9
- package/dist/content-client.js.map +1 -1
- package/dist/content-template.js +1 -7
- package/dist/content-template.js.map +1 -1
- package/dist/conversation.js +166 -136
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +44 -46
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +18 -22
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +22 -25
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +10 -14
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +1 -5
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +17 -49
- package/dist/index.js.map +1 -1
- package/dist/interfaces/notification-types.js +1 -5
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/interfaces/rules.js +7 -13
- package/dist/interfaces/rules.js.map +1 -1
- package/dist/logger.js +9 -29
- package/dist/logger.js.map +1 -1
- package/dist/media.js +32 -25
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +43 -47
- package/dist/message-builder.js.map +1 -1
- package/dist/message-recipients-client.js +10 -16
- package/dist/message-recipients-client.js.map +1 -1
- package/dist/message.js +114 -98
- package/dist/message.js.map +1 -1
- package/dist/node_modules/quick-lru/index.js +1 -5
- package/dist/node_modules/quick-lru/index.js.map +1 -1
- package/dist/node_modules/tslib/tslib.es6.js +7 -6
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +2 -6
- package/dist/packages/conversations/package.json.js.map +1 -1
- package/dist/participant.js +32 -37
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +1 -5
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +1 -5
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +3 -7
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +7 -10
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +5 -9
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +21 -30
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +1 -5
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +36 -9
- package/dist/util/index.js.map +1 -1
- package/dist/utils/uuid.js +145 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +14 -17
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
- package/docs/classes/CancellablePromise.html +0 -3213
- package/docs/classes/ChannelMetadata.html +0 -3050
- package/docs/classes/Client.html +0 -4278
- package/docs/classes/ContentTemplate.html +0 -3116
- package/docs/classes/ContentTemplateVariable.html +0 -3116
- package/docs/classes/Conversation.html +0 -4382
- package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
- package/docs/classes/EmailRecipientDescriptor.html +0 -3098
- package/docs/classes/Media.html +0 -3167
- package/docs/classes/Message.html +0 -3826
- package/docs/classes/MessageBuilder.html +0 -3318
- package/docs/classes/Participant.html +0 -3444
- package/docs/classes/PushNotification.html +0 -3130
- package/docs/classes/RestPaginator.html +0 -3160
- package/docs/classes/UnknownRecipientDescriptor.html +0 -3067
- package/docs/classes/UnsentMessage.html +0 -3042
- package/docs/classes/User.html +0 -3349
- package/docs/index.html +0 -4373
- package/docs/interfaces/ClientOptions.html +0 -3066
- package/docs/interfaces/ConversationBindings.html +0 -3001
- package/docs/interfaces/ConversationEmailBinding.html +0 -3001
- package/docs/interfaces/ConversationLimits.html +0 -3098
- package/docs/interfaces/ConversationState.html +0 -3050
- package/docs/interfaces/ConversationUpdatedEventArgs.html +0 -3001
- package/docs/interfaces/CreateConversationOptions.html +0 -3066
- package/docs/interfaces/LastMessage.html +0 -3050
- package/docs/interfaces/Paginator.html +0 -3141
- package/docs/interfaces/ParticipantBindings.html +0 -3001
- package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
- package/docs/interfaces/PushNotificationData.html +0 -3114
- package/docs/interfaces/SendEmailOptions.html +0 -3034
- package/docs/interfaces/SendMediaOptions.html +0 -3068
- package/docs/modules.html +0 -4374
package/dist/content-template.js
CHANGED
|
@@ -126,8 +126,6 @@ This software includes platform.js under the following license.
|
|
|
126
126
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
127
127
|
|
|
128
128
|
*/
|
|
129
|
-
'use strict';
|
|
130
|
-
|
|
131
129
|
var global =
|
|
132
130
|
typeof global !== "undefined"
|
|
133
131
|
? global
|
|
@@ -137,8 +135,6 @@ var global =
|
|
|
137
135
|
? window
|
|
138
136
|
: {};
|
|
139
137
|
|
|
140
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
141
|
-
|
|
142
138
|
const collectActions = (actions) => {
|
|
143
139
|
return actions.map((action) => {
|
|
144
140
|
var _a, _b, _c, _d;
|
|
@@ -304,7 +300,5 @@ class ContentTemplate {
|
|
|
304
300
|
}
|
|
305
301
|
}
|
|
306
302
|
|
|
307
|
-
|
|
308
|
-
exports.ContentTemplateVariable = ContentTemplateVariable;
|
|
309
|
-
exports.parseVariant = parseVariant;
|
|
303
|
+
export { ContentTemplate, ContentTemplateVariable, parseVariant };
|
|
310
304
|
//# sourceMappingURL=content-template.js.map
|
|
@@ -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,IAAI,EAAE,KAAK;oBACX,KAAK,EAA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|
|
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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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;;;;"}
|
package/dist/conversation.js
CHANGED
|
@@ -126,8 +126,6 @@ This software includes platform.js under the following license.
|
|
|
126
126
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
127
127
|
|
|
128
128
|
*/
|
|
129
|
-
'use strict';
|
|
130
|
-
|
|
131
129
|
var global =
|
|
132
130
|
typeof global !== "undefined"
|
|
133
131
|
? global
|
|
@@ -137,24 +135,17 @@ var global =
|
|
|
137
135
|
? window
|
|
138
136
|
: {};
|
|
139
137
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
var messageBuilder = require('./message-builder.js');
|
|
152
|
-
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
|
153
|
-
var isEqual = require('lodash.isequal');
|
|
154
|
-
|
|
155
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
156
|
-
|
|
157
|
-
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
138
|
+
import { __decorate, __metadata } from './node_modules/tslib/tslib.es6.js';
|
|
139
|
+
import { Logger } from './logger.js';
|
|
140
|
+
import { Participants } from './data/participants.js';
|
|
141
|
+
import { Participant } from './participant.js';
|
|
142
|
+
import { Messages } from './data/messages.js';
|
|
143
|
+
import { parseTime, UriBuilder, parseToNumber, isEqual } from './util/index.js';
|
|
144
|
+
import { SyncDocument } from 'twilio-sync';
|
|
145
|
+
import { validateTypesAsync, nonEmptyString, nonNegativeInteger, literal, objectSchema, custom } from '@twilio/declarative-type-validator';
|
|
146
|
+
import { optionalJson, json } from './interfaces/rules.js';
|
|
147
|
+
import { MessageBuilder } from './message-builder.js';
|
|
148
|
+
import { ReplayEventEmitter } from '@twilio/replay-event-emitter';
|
|
158
149
|
|
|
159
150
|
/**
|
|
160
151
|
* Map of the fields that will be processed with update messages.
|
|
@@ -178,7 +169,7 @@ const fieldMappings = {
|
|
|
178
169
|
* A conversation represents communication between multiple Conversations
|
|
179
170
|
* clients.
|
|
180
171
|
*/
|
|
181
|
-
class Conversation extends
|
|
172
|
+
class Conversation extends ReplayEventEmitter {
|
|
182
173
|
/**
|
|
183
174
|
* @param descriptor Conversation descriptor.
|
|
184
175
|
* @param sid Conversation SID.
|
|
@@ -200,8 +191,8 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
200
191
|
status: "notParticipating",
|
|
201
192
|
attributes: (_a = descriptor.attributes) !== null && _a !== void 0 ? _a : {},
|
|
202
193
|
createdBy: descriptor.createdBy,
|
|
203
|
-
dateCreated:
|
|
204
|
-
dateUpdated:
|
|
194
|
+
dateCreated: parseTime(descriptor.dateCreated),
|
|
195
|
+
dateUpdated: parseTime(descriptor.dateUpdated),
|
|
205
196
|
friendlyName: descriptor.friendlyName || null,
|
|
206
197
|
lastReadMessageIndex: Number.isInteger(descriptor.lastConsumedMessageIndex)
|
|
207
198
|
? descriptor.lastConsumedMessageIndex
|
|
@@ -215,14 +206,21 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
215
206
|
participants: this._links.participants,
|
|
216
207
|
};
|
|
217
208
|
this._participants = new Map();
|
|
218
|
-
this._participantsEntity = new
|
|
219
|
-
|
|
220
|
-
this._participantsEntity.on(
|
|
221
|
-
|
|
222
|
-
this.
|
|
223
|
-
this.
|
|
224
|
-
|
|
225
|
-
this.
|
|
209
|
+
this._participantsEntity = new Participants(this, this._participants, // state leak
|
|
210
|
+
participantsLinks, this._services);
|
|
211
|
+
this._participantsEntity.on(Conversation.participantJoined, (participant) =>
|
|
212
|
+
// @todo update participants map here??
|
|
213
|
+
this.emit(Conversation.participantJoined, participant));
|
|
214
|
+
this._participantsEntity.on(Conversation.participantLeft, (participant) =>
|
|
215
|
+
// @todo update participants map here??
|
|
216
|
+
this.emit(Conversation.participantLeft, participant));
|
|
217
|
+
this._participantsEntity.on(Conversation.participantUpdated, (args) =>
|
|
218
|
+
// @todo update participants map here??
|
|
219
|
+
this.emit(Conversation.participantUpdated, args));
|
|
220
|
+
this._messagesEntity = new Messages(this, configuration, services);
|
|
221
|
+
this._messagesEntity.on(Conversation.messageAdded, (message) => this._onMessageAdded(message));
|
|
222
|
+
this._messagesEntity.on(Conversation.messageUpdated, (args) => this.emit(Conversation.messageUpdated, args));
|
|
223
|
+
this._messagesEntity.on(Conversation.messageRemoved, (message) => this.emit(Conversation.messageRemoved, message));
|
|
226
224
|
}
|
|
227
225
|
/**
|
|
228
226
|
* Unique name of the conversation.
|
|
@@ -288,7 +286,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
288
286
|
return (_a = this._internalState.notificationLevel) !== null && _a !== void 0 ? _a : "default";
|
|
289
287
|
}
|
|
290
288
|
/**
|
|
291
|
-
* Conversation bindings.
|
|
289
|
+
* Conversation bindings. An undocumented feature (for now).
|
|
292
290
|
* @internal
|
|
293
291
|
*/
|
|
294
292
|
get bindings() {
|
|
@@ -449,7 +447,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
449
447
|
*/
|
|
450
448
|
async getParticipantsCount() {
|
|
451
449
|
var _a;
|
|
452
|
-
const url = new
|
|
450
|
+
const url = new UriBuilder(this._configuration.links.conversations)
|
|
453
451
|
.path(this.sid)
|
|
454
452
|
.build();
|
|
455
453
|
const response = await this._services.network.get(url);
|
|
@@ -482,7 +480,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
482
480
|
*/
|
|
483
481
|
async getMessagesCount() {
|
|
484
482
|
var _a;
|
|
485
|
-
const url = new
|
|
483
|
+
const url = new UriBuilder(this._configuration.links.conversations)
|
|
486
484
|
.path(this.sid)
|
|
487
485
|
.build();
|
|
488
486
|
const response = await this._services.network.get(url);
|
|
@@ -512,7 +510,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
512
510
|
* the user or `null` if the read horizon is not set.
|
|
513
511
|
*/
|
|
514
512
|
async getUnreadMessagesCount() {
|
|
515
|
-
const url = new
|
|
513
|
+
const url = new UriBuilder(this._configuration.links.myConversations)
|
|
516
514
|
.path(this.sid)
|
|
517
515
|
.build();
|
|
518
516
|
const response = await this._services.network.get(url);
|
|
@@ -564,10 +562,10 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
564
562
|
var _a, _b;
|
|
565
563
|
if (typeof message === "string" || message === null) {
|
|
566
564
|
const response = await this._messagesEntity.send(message, messageAttributes, emailOptions);
|
|
567
|
-
return (_a =
|
|
565
|
+
return (_a = parseToNumber(response.index)) !== null && _a !== void 0 ? _a : 0;
|
|
568
566
|
}
|
|
569
567
|
const response = await this._messagesEntity.sendMedia(message, messageAttributes, emailOptions);
|
|
570
|
-
return (_b =
|
|
568
|
+
return (_b = parseToNumber(response.index)) !== null && _b !== void 0 ? _b : 0;
|
|
571
569
|
}
|
|
572
570
|
/**
|
|
573
571
|
* New interface to prepare for sending a message.
|
|
@@ -575,7 +573,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
575
573
|
* @return A MessageBuilder to help set all message sending options.
|
|
576
574
|
*/
|
|
577
575
|
prepareMessage() {
|
|
578
|
-
return new
|
|
576
|
+
return new MessageBuilder(this.limits, this._messagesEntity);
|
|
579
577
|
}
|
|
580
578
|
/**
|
|
581
579
|
* Set last read message index of the conversation to the index of the last
|
|
@@ -662,14 +660,15 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
662
660
|
}
|
|
663
661
|
/**
|
|
664
662
|
* Get recipients of all messages in the conversation.
|
|
663
|
+
* @param options Optional configuration, set pageSize to request a specific pagination page size. Page size specifies a number of messages to include in a single batch. Each message may include multiple recipients.
|
|
665
664
|
*/
|
|
666
|
-
async getMessageRecipients() {
|
|
667
|
-
return await this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid);
|
|
665
|
+
async getMessageRecipients(options) {
|
|
666
|
+
return await this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid, options);
|
|
668
667
|
}
|
|
669
668
|
/**
|
|
670
669
|
* Load and subscribe to this conversation and do not subscribe to its
|
|
671
670
|
* participants and messages. This or _subscribeStreams will need to be called
|
|
672
|
-
* before any events
|
|
671
|
+
* before any events in the conversation will fire.
|
|
673
672
|
* @internal
|
|
674
673
|
*/
|
|
675
674
|
async _subscribe() {
|
|
@@ -682,8 +681,8 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
682
681
|
});
|
|
683
682
|
try {
|
|
684
683
|
this._entity = await this._entityPromise;
|
|
685
|
-
this._entity.on(
|
|
686
|
-
this._entity.on(
|
|
684
|
+
this._entity.on(SyncDocument.updated, (args) => this._update(args.data));
|
|
685
|
+
this._entity.on(SyncDocument.removed, () => this.emit(Conversation.removed, this));
|
|
687
686
|
this._update(this._entity.data);
|
|
688
687
|
return this._entity;
|
|
689
688
|
}
|
|
@@ -707,17 +706,48 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
707
706
|
* @internal
|
|
708
707
|
*/
|
|
709
708
|
async _fetchStreams() {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
709
|
+
if (this._streamsPromise) {
|
|
710
|
+
return this._streamsPromise;
|
|
711
|
+
}
|
|
712
|
+
this._streamsPromise = new Promise(async (resolve, reject) => {
|
|
713
|
+
var _a, _b;
|
|
714
|
+
try {
|
|
715
|
+
await this._subscribe();
|
|
716
|
+
}
|
|
717
|
+
catch (err) {
|
|
718
|
+
Conversation._logger.trace("Failed to subscribe to conversation", err);
|
|
719
|
+
return reject(err);
|
|
720
|
+
}
|
|
721
|
+
Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_a = this._entity) === null || _a === void 0 ? void 0 : _a.data);
|
|
722
|
+
const data = (_b = this._entity) === null || _b === void 0 ? void 0 : _b.data;
|
|
723
|
+
const messagesPromise = this._services.syncClient
|
|
724
|
+
.list({
|
|
725
|
+
id: data.messages,
|
|
726
|
+
mode: "open_existing",
|
|
727
|
+
})
|
|
728
|
+
.then((list) => {
|
|
729
|
+
this._messagesList = list;
|
|
730
|
+
return list;
|
|
731
|
+
});
|
|
732
|
+
const participantsPromise = this._services.syncClient
|
|
733
|
+
.map({
|
|
734
|
+
id: data.roster,
|
|
735
|
+
mode: "open_existing",
|
|
736
|
+
})
|
|
737
|
+
.then((map) => {
|
|
738
|
+
this._participantsMap = map;
|
|
739
|
+
return map;
|
|
740
|
+
});
|
|
741
|
+
Promise.all([messagesPromise, participantsPromise])
|
|
742
|
+
.then(() => resolve(true))
|
|
743
|
+
.catch((err) => {
|
|
744
|
+
Conversation._logger.trace("Failed to fetch conversation streams for conversation", this.sid, err);
|
|
745
|
+
reject(err);
|
|
746
|
+
});
|
|
717
747
|
});
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
748
|
+
return this._streamsPromise.catch((err) => {
|
|
749
|
+
this._streamsPromise = null;
|
|
750
|
+
throw err;
|
|
721
751
|
});
|
|
722
752
|
}
|
|
723
753
|
/**
|
|
@@ -730,7 +760,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
730
760
|
async _subscribeStreams() {
|
|
731
761
|
var _a, _b, _c, _d;
|
|
732
762
|
try {
|
|
733
|
-
await this.
|
|
763
|
+
await this._fetchStreams();
|
|
734
764
|
Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_a = this._entity) === null || _a === void 0 ? void 0 : _a.data);
|
|
735
765
|
const data = (_b = this._entity) === null || _b === void 0 ? void 0 : _b.data;
|
|
736
766
|
const messagesObjectName = data.messages;
|
|
@@ -754,7 +784,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
754
784
|
*/
|
|
755
785
|
async _unsubscribe() {
|
|
756
786
|
if (this._entity) {
|
|
757
|
-
|
|
787
|
+
this._entity.close();
|
|
758
788
|
this._entity = null;
|
|
759
789
|
this._entityPromise = null;
|
|
760
790
|
}
|
|
@@ -816,7 +846,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
816
846
|
updateReasons.add(localKey);
|
|
817
847
|
break;
|
|
818
848
|
case fieldMappings.attributes:
|
|
819
|
-
if (
|
|
849
|
+
if (isEqual(this._internalState.attributes, update.attributes)) {
|
|
820
850
|
break;
|
|
821
851
|
}
|
|
822
852
|
this._internalState.attributes = update.attributes;
|
|
@@ -852,7 +882,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
852
882
|
update.lastMessage.timestamp;
|
|
853
883
|
updateReasons.add(localKey);
|
|
854
884
|
}
|
|
855
|
-
if (
|
|
885
|
+
if (isEqual(this._internalState.lastMessage, {})) {
|
|
856
886
|
delete this._internalState.lastMessage;
|
|
857
887
|
}
|
|
858
888
|
break;
|
|
@@ -861,14 +891,14 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
861
891
|
if (state !== undefined) {
|
|
862
892
|
state.dateUpdated = new Date(state.dateUpdated);
|
|
863
893
|
}
|
|
864
|
-
if (
|
|
894
|
+
if (isEqual(this._internalState.state, state)) {
|
|
865
895
|
break;
|
|
866
896
|
}
|
|
867
897
|
this._internalState.state = state;
|
|
868
898
|
updateReasons.add(localKey);
|
|
869
899
|
break;
|
|
870
900
|
case fieldMappings.bindings:
|
|
871
|
-
if (
|
|
901
|
+
if (isEqual(this._internalState.bindings, update.bindings)) {
|
|
872
902
|
break;
|
|
873
903
|
}
|
|
874
904
|
this._internalState.bindings = update.bindings;
|
|
@@ -887,7 +917,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
887
917
|
}
|
|
888
918
|
}
|
|
889
919
|
if (updateReasons.size > 0) {
|
|
890
|
-
this.emit(
|
|
920
|
+
this.emit(Conversation.updated, {
|
|
891
921
|
conversation: this,
|
|
892
922
|
updateReasons: [...updateReasons],
|
|
893
923
|
});
|
|
@@ -903,7 +933,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
|
903
933
|
break;
|
|
904
934
|
}
|
|
905
935
|
}
|
|
906
|
-
this.emit(
|
|
936
|
+
this.emit(Conversation.messageAdded, message);
|
|
907
937
|
}
|
|
908
938
|
/**
|
|
909
939
|
* Set last read message index.
|
|
@@ -1018,57 +1048,57 @@ Conversation.removed = "removed";
|
|
|
1018
1048
|
/**
|
|
1019
1049
|
* Logger instance.
|
|
1020
1050
|
*/
|
|
1021
|
-
Conversation._logger =
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1051
|
+
Conversation._logger = Logger.scope("Conversation");
|
|
1052
|
+
__decorate([
|
|
1053
|
+
validateTypesAsync(nonEmptyString, optionalJson),
|
|
1054
|
+
__metadata("design:type", Function),
|
|
1055
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
1056
|
+
__metadata("design:returntype", Promise)
|
|
1027
1057
|
], Conversation.prototype, "add", null);
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1058
|
+
__decorate([
|
|
1059
|
+
validateTypesAsync(nonEmptyString, nonEmptyString, optionalJson, optionalJson),
|
|
1060
|
+
__metadata("design:type", Function),
|
|
1061
|
+
__metadata("design:paramtypes", [String, String, Object, Object]),
|
|
1062
|
+
__metadata("design:returntype", Promise)
|
|
1033
1063
|
], Conversation.prototype, "addNonChatParticipant", null);
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1064
|
+
__decorate([
|
|
1065
|
+
validateTypesAsync(nonNegativeInteger),
|
|
1066
|
+
__metadata("design:type", Function),
|
|
1067
|
+
__metadata("design:paramtypes", [Number]),
|
|
1068
|
+
__metadata("design:returntype", Promise)
|
|
1039
1069
|
], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1070
|
+
__decorate([
|
|
1071
|
+
validateTypesAsync(["undefined", nonNegativeInteger], ["undefined", nonNegativeInteger], ["undefined", literal("backwards", "forward")]),
|
|
1072
|
+
__metadata("design:type", Function),
|
|
1073
|
+
__metadata("design:paramtypes", [Number, Number, String]),
|
|
1074
|
+
__metadata("design:returntype", Promise)
|
|
1045
1075
|
], Conversation.prototype, "getMessages", null);
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1076
|
+
__decorate([
|
|
1077
|
+
validateTypesAsync(nonEmptyString),
|
|
1078
|
+
__metadata("design:type", Function),
|
|
1079
|
+
__metadata("design:paramtypes", [String]),
|
|
1080
|
+
__metadata("design:returntype", Promise)
|
|
1051
1081
|
], Conversation.prototype, "getParticipantBySid", null);
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1082
|
+
__decorate([
|
|
1083
|
+
validateTypesAsync(nonEmptyString),
|
|
1084
|
+
__metadata("design:type", Function),
|
|
1085
|
+
__metadata("design:paramtypes", [String]),
|
|
1086
|
+
__metadata("design:returntype", Promise)
|
|
1057
1087
|
], Conversation.prototype, "getParticipantByIdentity", null);
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1088
|
+
__decorate([
|
|
1089
|
+
validateTypesAsync([nonEmptyString, Participant]),
|
|
1090
|
+
__metadata("design:type", Function),
|
|
1091
|
+
__metadata("design:paramtypes", [Object]),
|
|
1092
|
+
__metadata("design:returntype", Promise)
|
|
1063
1093
|
], Conversation.prototype, "removeParticipant", null);
|
|
1064
|
-
|
|
1065
|
-
|
|
1094
|
+
__decorate([
|
|
1095
|
+
validateTypesAsync([
|
|
1066
1096
|
"string",
|
|
1067
1097
|
FormData,
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
contentType:
|
|
1071
|
-
media:
|
|
1098
|
+
literal(null),
|
|
1099
|
+
objectSchema("media options", {
|
|
1100
|
+
contentType: nonEmptyString,
|
|
1101
|
+
media: custom((value) => {
|
|
1072
1102
|
let isValid = (typeof value === "string" && value.length > 0) ||
|
|
1073
1103
|
value instanceof Uint8Array ||
|
|
1074
1104
|
value instanceof ArrayBuffer;
|
|
@@ -1081,47 +1111,47 @@ tslib_es6.__decorate([
|
|
|
1081
1111
|
];
|
|
1082
1112
|
}),
|
|
1083
1113
|
}),
|
|
1084
|
-
],
|
|
1114
|
+
], optionalJson, [
|
|
1085
1115
|
"undefined",
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
subject: [
|
|
1116
|
+
literal(null),
|
|
1117
|
+
objectSchema("email attributes", {
|
|
1118
|
+
subject: [nonEmptyString, "undefined"],
|
|
1089
1119
|
}),
|
|
1090
1120
|
]),
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1121
|
+
__metadata("design:type", Function),
|
|
1122
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
1123
|
+
__metadata("design:returntype", Promise)
|
|
1094
1124
|
], Conversation.prototype, "sendMessage", null);
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1125
|
+
__decorate([
|
|
1126
|
+
validateTypesAsync(literal("default", "muted")),
|
|
1127
|
+
__metadata("design:type", Function),
|
|
1128
|
+
__metadata("design:paramtypes", [String]),
|
|
1129
|
+
__metadata("design:returntype", Promise)
|
|
1100
1130
|
], Conversation.prototype, "setUserNotificationLevel", null);
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1131
|
+
__decorate([
|
|
1132
|
+
validateTypesAsync(json),
|
|
1133
|
+
__metadata("design:type", Function),
|
|
1134
|
+
__metadata("design:paramtypes", [Object]),
|
|
1135
|
+
__metadata("design:returntype", Promise)
|
|
1106
1136
|
], Conversation.prototype, "updateAttributes", null);
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1137
|
+
__decorate([
|
|
1138
|
+
validateTypesAsync("string"),
|
|
1139
|
+
__metadata("design:type", Function),
|
|
1140
|
+
__metadata("design:paramtypes", [String]),
|
|
1141
|
+
__metadata("design:returntype", Promise)
|
|
1112
1142
|
], Conversation.prototype, "updateFriendlyName", null);
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1143
|
+
__decorate([
|
|
1144
|
+
validateTypesAsync([literal(null), nonNegativeInteger]),
|
|
1145
|
+
__metadata("design:type", Function),
|
|
1146
|
+
__metadata("design:paramtypes", [Number]),
|
|
1147
|
+
__metadata("design:returntype", Promise)
|
|
1118
1148
|
], Conversation.prototype, "updateLastReadMessageIndex", null);
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1149
|
+
__decorate([
|
|
1150
|
+
validateTypesAsync(["string", literal(null)]),
|
|
1151
|
+
__metadata("design:type", Function),
|
|
1152
|
+
__metadata("design:paramtypes", [String]),
|
|
1153
|
+
__metadata("design:returntype", Promise)
|
|
1124
1154
|
], Conversation.prototype, "updateUniqueName", null);
|
|
1125
1155
|
|
|
1126
|
-
|
|
1156
|
+
export { Conversation };
|
|
1127
1157
|
//# sourceMappingURL=conversation.js.map
|