@twilio/conversations 2.5.0-rc.8 → 2.6.0-rc.0

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 (82) hide show
  1. package/README.md +2 -2
  2. package/builds/browser.esm.js +10713 -0
  3. package/builds/browser.esm.js.map +1 -0
  4. package/builds/browser.js +241 -81
  5. package/builds/browser.js.map +1 -1
  6. package/builds/lib.d.ts +10 -9
  7. package/builds/lib.esm.d.ts +3166 -0
  8. package/builds/lib.esm.js +10712 -0
  9. package/builds/lib.js +250 -81
  10. package/builds/lib.js.map +1 -1
  11. package/builds/twilio-conversations.js +11231 -11244
  12. package/builds/twilio-conversations.min.js +1 -1
  13. package/dist/aggregated-delivery-receipt.js +3 -5
  14. package/dist/aggregated-delivery-receipt.js.map +1 -1
  15. package/dist/channel-metadata-client.js +7 -9
  16. package/dist/channel-metadata-client.js.map +1 -1
  17. package/dist/client.js +201 -166
  18. package/dist/client.js.map +1 -1
  19. package/dist/command-executor.js +8 -8
  20. package/dist/command-executor.js.map +1 -1
  21. package/dist/configuration.js +12 -9
  22. package/dist/configuration.js.map +1 -1
  23. package/dist/content-client.js +11 -8
  24. package/dist/content-client.js.map +1 -1
  25. package/dist/content-template.js +3 -5
  26. package/dist/content-template.js.map +1 -1
  27. package/dist/conversation.js +130 -96
  28. package/dist/conversation.js.map +1 -1
  29. package/dist/data/conversations.js +36 -43
  30. package/dist/data/conversations.js.map +1 -1
  31. package/dist/data/messages.js +23 -21
  32. package/dist/data/messages.js.map +1 -1
  33. package/dist/data/participants.js +27 -24
  34. package/dist/data/participants.js.map +1 -1
  35. package/dist/data/users.js +15 -13
  36. package/dist/data/users.js.map +1 -1
  37. package/dist/detailed-delivery-receipt.js +3 -5
  38. package/dist/detailed-delivery-receipt.js.map +1 -1
  39. package/dist/index.js +17 -49
  40. package/dist/index.js.map +1 -1
  41. package/dist/interfaces/notification-types.js +1 -5
  42. package/dist/interfaces/notification-types.js.map +1 -1
  43. package/dist/interfaces/rules.js +13 -10
  44. package/dist/interfaces/rules.js.map +1 -1
  45. package/dist/logger.js +25 -26
  46. package/dist/logger.js.map +1 -1
  47. package/dist/media.js +11 -8
  48. package/dist/media.js.map +1 -1
  49. package/dist/message-builder.js +48 -40
  50. package/dist/message-builder.js.map +1 -1
  51. package/dist/message-recipients-client.js +11 -13
  52. package/dist/message-recipients-client.js.map +1 -1
  53. package/dist/message.js +96 -83
  54. package/dist/message.js.map +1 -1
  55. package/dist/node_modules/quick-lru/index.js +1 -5
  56. package/dist/node_modules/quick-lru/index.js.map +1 -1
  57. package/dist/node_modules/tslib/tslib.es6.js +1 -7
  58. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  59. package/dist/packages/conversations/package.json.js +2 -6
  60. package/dist/packages/conversations/package.json.js.map +1 -1
  61. package/dist/participant.js +40 -31
  62. package/dist/participant.js.map +1 -1
  63. package/dist/push-notification.js +5 -4
  64. package/dist/push-notification.js.map +1 -1
  65. package/dist/rest-paginator.js +9 -8
  66. package/dist/rest-paginator.js.map +1 -1
  67. package/dist/services/network.js +3 -7
  68. package/dist/services/network.js.map +1 -1
  69. package/dist/services/typing-indicator.js +11 -8
  70. package/dist/services/typing-indicator.js.map +1 -1
  71. package/dist/unsent-message.js +9 -8
  72. package/dist/unsent-message.js.map +1 -1
  73. package/dist/user.js +27 -24
  74. package/dist/user.js.map +1 -1
  75. package/dist/util/deferred.js +6 -4
  76. package/dist/util/deferred.js.map +1 -1
  77. package/dist/util/index.js +1 -9
  78. package/dist/util/index.js.map +1 -1
  79. package/docs/classes/Client.html +2 -2
  80. package/docs/index.html +3 -3
  81. package/docs/modules.html +2 -2
  82. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"content-client.js","sources":["../src/content-client.ts"],"sourcesContent":["import { CommandExecutor } from \"./command-executor\";\nimport { ContentTemplate } from \"./content-template\";\nimport { ContentTemplatesResponse } from \"./interfaces/commands/content-templates-response\";\nimport { UriBuilder } from \"./util\";\n\ntype ContentClientServices = {\n commandExecutor: CommandExecutor;\n};\n\nclass ContentClient {\n private _cachedTemplates: Readonly<ContentTemplate[]> | null = null;\n\n public constructor(\n private readonly _services: ContentClientServices,\n private readonly _pageSize: number = 100,\n private readonly _cacheTtlMs: number = 5_000\n ) {}\n\n public async getContentTemplates(): Promise<Readonly<ContentTemplate[]>> {\n if (this._cachedTemplates !== null) {\n return this._cachedTemplates;\n }\n\n let [templatesPage, nextToken] = await this._fetchContentTemplates();\n let templates = templatesPage;\n\n while (nextToken !== null) {\n [templatesPage, nextToken] = await this._fetchContentTemplates(nextToken);\n templates = [...templates, ...templatesPage];\n }\n\n this._cachedTemplates = Object.freeze(templates);\n\n setTimeout(() => {\n this._cachedTemplates = null;\n }, this._cacheTtlMs);\n\n return templates;\n }\n\n private async _fetchContentTemplates(\n pageToken?: string\n ): Promise<[ContentTemplate[], string?]> {\n const contentTemplatesUrl = \"Client/v2/ContentTemplates\";\n const url = new UriBuilder(contentTemplatesUrl);\n\n url.arg(\"PageSize\", this._pageSize);\n\n if (pageToken !== undefined) {\n url.arg(\"PageToken\", pageToken);\n }\n\n const response = await this._services.commandExecutor.fetchResource<\n void,\n ContentTemplatesResponse\n >(url.build());\n\n return [\n response.templates.map((template) => new ContentTemplate(template)),\n response.meta.next_token,\n ];\n }\n}\n\nexport { ContentClient };\n"],"names":["UriBuilder","ContentTemplate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,aAAa,CAAA;AAGjB,IAAA,WAAA,CACmB,SAAgC,EAChC,SAAA,GAAoB,GAAG,EACvB,cAAsB,IAAK,EAAA;QAF3B,IAAS,CAAA,SAAA,GAAT,SAAS,CAAuB;QAChC,IAAS,CAAA,SAAA,GAAT,SAAS,CA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,CAGjE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;QAEf,OAAO;AACL,YAAA,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,IAAIC,+BAAe,CAAC,QAAQ,CAAC,CAAC;YACnE,QAAQ,CAAC,IAAI,CAAC,UAAU;SACzB,CAAC;KACH;AACF;;;;"}
1
+ {"version":3,"file":"content-client.js","sources":["../src/content-client.ts"],"sourcesContent":["import { CommandExecutor } from \"./command-executor\";\nimport { ContentTemplate } from \"./content-template\";\nimport { ContentTemplatesResponse } from \"./interfaces/commands/content-templates-response\";\nimport { UriBuilder } from \"./util\";\n\ntype ContentClientServices = {\n commandExecutor: CommandExecutor;\n};\n\nclass ContentClient {\n private _cachedTemplates: Readonly<ContentTemplate[]> | null = null;\n\n public constructor(\n private readonly _services: ContentClientServices,\n private readonly _pageSize: number = 100,\n private readonly _cacheTtlMs: number = 5_000\n ) {}\n\n public async getContentTemplates(): Promise<Readonly<ContentTemplate[]>> {\n if (this._cachedTemplates !== null) {\n return this._cachedTemplates;\n }\n\n let [templatesPage, nextToken] = await this._fetchContentTemplates();\n let templates = templatesPage;\n\n while (nextToken !== null) {\n [templatesPage, nextToken] = await this._fetchContentTemplates(nextToken);\n templates = [...templates, ...templatesPage];\n }\n\n this._cachedTemplates = Object.freeze(templates);\n\n setTimeout(() => {\n this._cachedTemplates = null;\n }, this._cacheTtlMs);\n\n return templates;\n }\n\n private async _fetchContentTemplates(\n pageToken?: string\n ): Promise<[ContentTemplate[], string?]> {\n const contentTemplatesUrl = \"Client/v2/ContentTemplates\";\n const url = new UriBuilder(contentTemplatesUrl);\n\n url.arg(\"PageSize\", this._pageSize);\n\n if (pageToken !== undefined) {\n url.arg(\"PageToken\", pageToken);\n }\n\n const response = await this._services.commandExecutor.fetchResource<\n void,\n ContentTemplatesResponse\n >(url.build());\n\n return [\n response.templates.map((template) => new ContentTemplate(template)),\n response.meta.next_token,\n ];\n }\n}\n\nexport { ContentClient };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,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AACzD,QAAA,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,mBAAmB,CAAC,CAAC;QAEhD,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAEpC,IAAI,SAAS,KAAK,SAAS,EAAE;AAC3B,YAAA,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AACjC,SAAA;AAED,QAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,aAAa,CAGjE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;QAEf,OAAO;AACL,YAAA,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC;YACnE,QAAQ,CAAC,IAAI,CAAC,UAAU;SACzB,CAAC;KACH;AACF;;;;"}I,CAAC,UAAU;SACzB,CAAC;KACH;AACF;;;;"}
@@ -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,9 @@ class ContentTemplate {
304
300
  }
305
301
  }
306
302
 
307
- exports.ContentTemplate = ContentTemplate;
303
+ export { ContentTemplate, ContentTemplateVariable, parseVariant };
304
+ //# sourceMappingURL=content-template.js.map
305
+ Template;
308
306
  exports.ContentTemplateVariable = ContentTemplateVariable;
309
307
  exports.parseVariant = parseVariant;
310
308
  //# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;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;;;;;;"}
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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S,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;;;;"};;;;"}
@@ -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,19 @@ var global =
137
135
  ? window
138
136
  : {};
139
137
 
140
- Object.defineProperty(exports, '__esModule', { value: true });
141
-
142
- var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
143
- require('isomorphic-form-data');
144
- var logger = require('./logger.js');
145
- var participants = require('./data/participants.js');
146
- var participant = require('./participant.js');
147
- var messages = require('./data/messages.js');
148
- var index = require('./util/index.js');
149
- var declarativeTypeValidator = require('@twilio/declarative-type-validator');
150
- var rules = require('./interfaces/rules.js');
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 'isomorphic-form-data';
140
+ import { Logger } from './logger.js';
141
+ import { Participants } from './data/participants.js';
142
+ import { Participant } from './participant.js';
143
+ import { Messages } from './data/messages.js';
144
+ import { parseTime, UriBuilder, parseToNumber } from './util/index.js';
145
+ import { SyncDocument } from 'twilio-sync';
146
+ import { validateTypesAsync, nonEmptyString, nonNegativeInteger, literal, objectSchema, custom } from '@twilio/declarative-type-validator';
147
+ import { optionalJson, json } from './interfaces/rules.js';
148
+ import { MessageBuilder } from './message-builder.js';
149
+ import { ReplayEventEmitter } from '@twilio/replay-event-emitter';
150
+ import isEqual from 'lodash.isequal';
158
151
 
159
152
  /**
160
153
  * Map of the fields that will be processed with update messages.
@@ -178,7 +171,7 @@ const fieldMappings = {
178
171
  * A conversation represents communication between multiple Conversations
179
172
  * clients.
180
173
  */
181
- class Conversation extends replayEventEmitter.ReplayEventEmitter {
174
+ class Conversation extends ReplayEventEmitter {
182
175
  /**
183
176
  * @param descriptor Conversation descriptor.
184
177
  * @param sid Conversation SID.
@@ -200,8 +193,8 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
200
193
  status: "notParticipating",
201
194
  attributes: (_a = descriptor.attributes) !== null && _a !== void 0 ? _a : {},
202
195
  createdBy: descriptor.createdBy,
203
- dateCreated: index.parseTime(descriptor.dateCreated),
204
- dateUpdated: index.parseTime(descriptor.dateUpdated),
196
+ dateCreated: parseTime(descriptor.dateCreated),
197
+ dateUpdated: parseTime(descriptor.dateUpdated),
205
198
  friendlyName: descriptor.friendlyName || null,
206
199
  lastReadMessageIndex: Number.isInteger(descriptor.lastConsumedMessageIndex)
207
200
  ? descriptor.lastConsumedMessageIndex
@@ -215,14 +208,21 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
215
208
  participants: this._links.participants,
216
209
  };
217
210
  this._participants = new Map();
218
- this._participantsEntity = new participants.Participants(this, this._participants, participantsLinks, this._configuration, this._services);
219
- this._participantsEntity.on("participantJoined", (participant) => this.emit("participantJoined", participant));
220
- this._participantsEntity.on("participantLeft", (participant) => this.emit("participantLeft", participant));
221
- this._participantsEntity.on("participantUpdated", (args) => this.emit("participantUpdated", args));
222
- this._messagesEntity = new messages.Messages(this, configuration, services);
223
- this._messagesEntity.on("messageAdded", (message) => this._onMessageAdded(message));
224
- this._messagesEntity.on("messageUpdated", (args) => this.emit("messageUpdated", args));
225
- this._messagesEntity.on("messageRemoved", (message) => this.emit("messageRemoved", message));
211
+ this._participantsEntity = new Participants(this, this._participants, // state leak
212
+ participantsLinks, this._services);
213
+ this._participantsEntity.on(Conversation.participantJoined, (participant) =>
214
+ // @todo update participants map here??
215
+ this.emit(Conversation.participantJoined, participant));
216
+ this._participantsEntity.on(Conversation.participantLeft, (participant) =>
217
+ // @todo update participants map here??
218
+ this.emit(Conversation.participantLeft, participant));
219
+ this._participantsEntity.on(Conversation.participantUpdated, (args) =>
220
+ // @todo update participants map here??
221
+ this.emit(Conversation.participantUpdated, args));
222
+ this._messagesEntity = new Messages(this, configuration, services);
223
+ this._messagesEntity.on(Conversation.messageAdded, (message) => this._onMessageAdded(message));
224
+ this._messagesEntity.on(Conversation.messageUpdated, (args) => this.emit(Conversation.messageUpdated, args));
225
+ this._messagesEntity.on(Conversation.messageRemoved, (message) => this.emit(Conversation.messageRemoved, message));
226
226
  }
227
227
  /**
228
228
  * Unique name of the conversation.
@@ -288,7 +288,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
288
288
  return (_a = this._internalState.notificationLevel) !== null && _a !== void 0 ? _a : "default";
289
289
  }
290
290
  /**
291
- * Conversation bindings. Undocumented feature (for now).
291
+ * Conversation bindings. An undocumented feature (for now).
292
292
  * @internal
293
293
  */
294
294
  get bindings() {
@@ -449,7 +449,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
449
449
  */
450
450
  async getParticipantsCount() {
451
451
  var _a;
452
- const url = new index.UriBuilder(this._configuration.links.conversations)
452
+ const url = new UriBuilder(this._configuration.links.conversations)
453
453
  .path(this.sid)
454
454
  .build();
455
455
  const response = await this._services.network.get(url);
@@ -482,7 +482,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
482
482
  */
483
483
  async getMessagesCount() {
484
484
  var _a;
485
- const url = new index.UriBuilder(this._configuration.links.conversations)
485
+ const url = new UriBuilder(this._configuration.links.conversations)
486
486
  .path(this.sid)
487
487
  .build();
488
488
  const response = await this._services.network.get(url);
@@ -512,7 +512,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
512
512
  * the user or `null` if the read horizon is not set.
513
513
  */
514
514
  async getUnreadMessagesCount() {
515
- const url = new index.UriBuilder(this._configuration.links.myConversations)
515
+ const url = new UriBuilder(this._configuration.links.myConversations)
516
516
  .path(this.sid)
517
517
  .build();
518
518
  const response = await this._services.network.get(url);
@@ -564,10 +564,10 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
564
564
  var _a, _b;
565
565
  if (typeof message === "string" || message === null) {
566
566
  const response = await this._messagesEntity.send(message, messageAttributes, emailOptions);
567
- return (_a = index.parseToNumber(response.index)) !== null && _a !== void 0 ? _a : 0;
567
+ return (_a = parseToNumber(response.index)) !== null && _a !== void 0 ? _a : 0;
568
568
  }
569
569
  const response = await this._messagesEntity.sendMedia(message, messageAttributes, emailOptions);
570
- return (_b = index.parseToNumber(response.index)) !== null && _b !== void 0 ? _b : 0;
570
+ return (_b = parseToNumber(response.index)) !== null && _b !== void 0 ? _b : 0;
571
571
  }
572
572
  /**
573
573
  * New interface to prepare for sending a message.
@@ -575,7 +575,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
575
575
  * @return A MessageBuilder to help set all message sending options.
576
576
  */
577
577
  prepareMessage() {
578
- return new messageBuilder.MessageBuilder(this.limits, this._messagesEntity);
578
+ return new MessageBuilder(this.limits, this._messagesEntity);
579
579
  }
580
580
  /**
581
581
  * Set last read message index of the conversation to the index of the last
@@ -683,8 +683,8 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
683
683
  });
684
684
  try {
685
685
  this._entity = await this._entityPromise;
686
- this._entity.on("updated", (args) => this._update(args.data));
687
- this._entity.on("removed", () => this.emit("removed", this));
686
+ this._entity.on(SyncDocument.updated, (args) => this._update(args.data));
687
+ this._entity.on(SyncDocument.removed, () => this.emit(Conversation.removed, this));
688
688
  this._update(this._entity.data);
689
689
  return this._entity;
690
690
  }
@@ -755,7 +755,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
755
755
  */
756
756
  async _unsubscribe() {
757
757
  if (this._entity) {
758
- await this._entity.close();
758
+ this._entity.close();
759
759
  this._entity = null;
760
760
  this._entityPromise = null;
761
761
  }
@@ -817,7 +817,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
817
817
  updateReasons.add(localKey);
818
818
  break;
819
819
  case fieldMappings.attributes:
820
- if (isEqual__default["default"](this._internalState.attributes, update.attributes)) {
820
+ if (isEqual(this._internalState.attributes, update.attributes)) {
821
821
  break;
822
822
  }
823
823
  this._internalState.attributes = update.attributes;
@@ -853,7 +853,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
853
853
  update.lastMessage.timestamp;
854
854
  updateReasons.add(localKey);
855
855
  }
856
- if (isEqual__default["default"](this._internalState.lastMessage, {})) {
856
+ if (isEqual(this._internalState.lastMessage, {})) {
857
857
  delete this._internalState.lastMessage;
858
858
  }
859
859
  break;
@@ -862,14 +862,14 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
862
862
  if (state !== undefined) {
863
863
  state.dateUpdated = new Date(state.dateUpdated);
864
864
  }
865
- if (isEqual__default["default"](this._internalState.state, state)) {
865
+ if (isEqual(this._internalState.state, state)) {
866
866
  break;
867
867
  }
868
868
  this._internalState.state = state;
869
869
  updateReasons.add(localKey);
870
870
  break;
871
871
  case fieldMappings.bindings:
872
- if (isEqual__default["default"](this._internalState.bindings, update.bindings)) {
872
+ if (isEqual(this._internalState.bindings, update.bindings)) {
873
873
  break;
874
874
  }
875
875
  this._internalState.bindings = update.bindings;
@@ -888,7 +888,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
888
888
  }
889
889
  }
890
890
  if (updateReasons.size > 0) {
891
- this.emit("updated", {
891
+ this.emit(Conversation.updated, {
892
892
  conversation: this,
893
893
  updateReasons: [...updateReasons],
894
894
  });
@@ -904,7 +904,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
904
904
  break;
905
905
  }
906
906
  }
907
- this.emit("messageAdded", message);
907
+ this.emit(Conversation.messageAdded, message);
908
908
  }
909
909
  /**
910
910
  * Set last read message index.
@@ -1019,57 +1019,57 @@ Conversation.removed = "removed";
1019
1019
  /**
1020
1020
  * Logger instance.
1021
1021
  */
1022
- Conversation._logger = logger.Logger.scope("Conversation");
1023
- tslib_es6.__decorate([
1024
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, rules.optionalJson),
1025
- tslib_es6.__metadata("design:type", Function),
1026
- tslib_es6.__metadata("design:paramtypes", [String, Object]),
1027
- tslib_es6.__metadata("design:returntype", Promise)
1022
+ Conversation._logger = Logger.scope("Conversation");
1023
+ __decorate([
1024
+ validateTypesAsync(nonEmptyString, optionalJson),
1025
+ __metadata("design:type", Function),
1026
+ __metadata("design:paramtypes", [String, Object]),
1027
+ __metadata("design:returntype", Promise)
1028
1028
  ], Conversation.prototype, "add", null);
1029
- tslib_es6.__decorate([
1030
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString, declarativeTypeValidator.nonEmptyString, rules.optionalJson, rules.optionalJson),
1031
- tslib_es6.__metadata("design:type", Function),
1032
- tslib_es6.__metadata("design:paramtypes", [String, String, Object, Object]),
1033
- tslib_es6.__metadata("design:returntype", Promise)
1029
+ __decorate([
1030
+ validateTypesAsync(nonEmptyString, nonEmptyString, optionalJson, optionalJson),
1031
+ __metadata("design:type", Function),
1032
+ __metadata("design:paramtypes", [String, String, Object, Object]),
1033
+ __metadata("design:returntype", Promise)
1034
1034
  ], Conversation.prototype, "addNonChatParticipant", null);
1035
- tslib_es6.__decorate([
1036
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonNegativeInteger),
1037
- tslib_es6.__metadata("design:type", Function),
1038
- tslib_es6.__metadata("design:paramtypes", [Number]),
1039
- tslib_es6.__metadata("design:returntype", Promise)
1035
+ __decorate([
1036
+ validateTypesAsync(nonNegativeInteger),
1037
+ __metadata("design:type", Function),
1038
+ __metadata("design:paramtypes", [Number]),
1039
+ __metadata("design:returntype", Promise)
1040
1040
  ], Conversation.prototype, "advanceLastReadMessageIndex", null);
1041
- tslib_es6.__decorate([
1042
- declarativeTypeValidator.validateTypesAsync(["undefined", declarativeTypeValidator.nonNegativeInteger], ["undefined", declarativeTypeValidator.nonNegativeInteger], ["undefined", declarativeTypeValidator.literal("backwards", "forward")]),
1043
- tslib_es6.__metadata("design:type", Function),
1044
- tslib_es6.__metadata("design:paramtypes", [Number, Number, String]),
1045
- tslib_es6.__metadata("design:returntype", Promise)
1041
+ __decorate([
1042
+ validateTypesAsync(["undefined", nonNegativeInteger], ["undefined", nonNegativeInteger], ["undefined", literal("backwards", "forward")]),
1043
+ __metadata("design:type", Function),
1044
+ __metadata("design:paramtypes", [Number, Number, String]),
1045
+ __metadata("design:returntype", Promise)
1046
1046
  ], Conversation.prototype, "getMessages", null);
1047
- tslib_es6.__decorate([
1048
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
1049
- tslib_es6.__metadata("design:type", Function),
1050
- tslib_es6.__metadata("design:paramtypes", [String]),
1051
- tslib_es6.__metadata("design:returntype", Promise)
1047
+ __decorate([
1048
+ validateTypesAsync(nonEmptyString),
1049
+ __metadata("design:type", Function),
1050
+ __metadata("design:paramtypes", [String]),
1051
+ __metadata("design:returntype", Promise)
1052
1052
  ], Conversation.prototype, "getParticipantBySid", null);
1053
- tslib_es6.__decorate([
1054
- declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
1055
- tslib_es6.__metadata("design:type", Function),
1056
- tslib_es6.__metadata("design:paramtypes", [String]),
1057
- tslib_es6.__metadata("design:returntype", Promise)
1053
+ __decorate([
1054
+ validateTypesAsync(nonEmptyString),
1055
+ __metadata("design:type", Function),
1056
+ __metadata("design:paramtypes", [String]),
1057
+ __metadata("design:returntype", Promise)
1058
1058
  ], Conversation.prototype, "getParticipantByIdentity", null);
1059
- tslib_es6.__decorate([
1060
- declarativeTypeValidator.validateTypesAsync([declarativeTypeValidator.nonEmptyString, participant.Participant]),
1061
- tslib_es6.__metadata("design:type", Function),
1062
- tslib_es6.__metadata("design:paramtypes", [Object]),
1063
- tslib_es6.__metadata("design:returntype", Promise)
1059
+ __decorate([
1060
+ validateTypesAsync([nonEmptyString, Participant]),
1061
+ __metadata("design:type", Function),
1062
+ __metadata("design:paramtypes", [Object]),
1063
+ __metadata("design:returntype", Promise)
1064
1064
  ], Conversation.prototype, "removeParticipant", null);
1065
- tslib_es6.__decorate([
1066
- declarativeTypeValidator.validateTypesAsync([
1065
+ __decorate([
1066
+ validateTypesAsync([
1067
1067
  "string",
1068
1068
  FormData,
1069
- declarativeTypeValidator.literal(null),
1070
- declarativeTypeValidator.objectSchema("media options", {
1071
- contentType: declarativeTypeValidator.nonEmptyString,
1072
- media: declarativeTypeValidator.custom((value) => {
1069
+ literal(null),
1070
+ objectSchema("media options", {
1071
+ contentType: nonEmptyString,
1072
+ media: custom((value) => {
1073
1073
  let isValid = (typeof value === "string" && value.length > 0) ||
1074
1074
  value instanceof Uint8Array ||
1075
1075
  value instanceof ArrayBuffer;
@@ -1082,17 +1082,51 @@ tslib_es6.__decorate([
1082
1082
  ];
1083
1083
  }),
1084
1084
  }),
1085
- ], rules.optionalJson, [
1085
+ ], optionalJson, [
1086
1086
  "undefined",
1087
- declarativeTypeValidator.literal(null),
1088
- declarativeTypeValidator.objectSchema("email attributes", {
1089
- subject: [declarativeTypeValidator.nonEmptyString, "undefined"],
1087
+ literal(null),
1088
+ objectSchema("email attributes", {
1089
+ subject: [nonEmptyString, "undefined"],
1090
1090
  }),
1091
1091
  ]),
1092
- tslib_es6.__metadata("design:type", Function),
1093
- tslib_es6.__metadata("design:paramtypes", [Object, Object, Object]),
1094
- tslib_es6.__metadata("design:returntype", Promise)
1092
+ __metadata("design:type", Function),
1093
+ __metadata("design:paramtypes", [Object, Object, Object]),
1094
+ __metadata("design:returntype", Promise)
1095
1095
  ], Conversation.prototype, "sendMessage", null);
1096
+ __decorate([
1097
+ validateTypesAsync(literal("default", "muted")),
1098
+ __metadata("design:type", Function),
1099
+ __metadata("design:paramtypes", [String]),
1100
+ __metadata("design:returntype", Promise)
1101
+ ], Conversation.prototype, "setUserNotificationLevel", null);
1102
+ __decorate([
1103
+ validateTypesAsync(json),
1104
+ __metadata("design:type", Function),
1105
+ __metadata("design:paramtypes", [Object]),
1106
+ __metadata("design:returntype", Promise)
1107
+ ], Conversation.prototype, "updateAttributes", null);
1108
+ __decorate([
1109
+ validateTypesAsync("string"),
1110
+ __metadata("design:type", Function),
1111
+ __metadata("design:paramtypes", [String]),
1112
+ __metadata("design:returntype", Promise)
1113
+ ], Conversation.prototype, "updateFriendlyName", null);
1114
+ __decorate([
1115
+ validateTypesAsync([literal(null), nonNegativeInteger]),
1116
+ __metadata("design:type", Function),
1117
+ __metadata("design:paramtypes", [Number]),
1118
+ __metadata("design:returntype", Promise)
1119
+ ], Conversation.prototype, "updateLastReadMessageIndex", null);
1120
+ __decorate([
1121
+ validateTypesAsync(["string", literal(null)]),
1122
+ __metadata("design:type", Function),
1123
+ __metadata("design:paramtypes", [String]),
1124
+ __metadata("design:returntype", Promise)
1125
+ ], Conversation.prototype, "updateUniqueName", null);
1126
+
1127
+ export { Conversation };
1128
+ //# sourceMappingURL=conversation.js.map
1129
+ ", null);
1096
1130
  tslib_es6.__decorate([
1097
1131
  declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("default", "muted")),
1098
1132
  tslib_es6.__metadata("design:type", Function),