@twilio/conversations 2.5.0 → 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.
- package/README.md +2 -2
- package/builds/browser.esm.js +10713 -0
- package/builds/browser.esm.js.map +1 -0
- package/builds/browser.js +158 -1
- package/builds/browser.js.map +1 -1
- package/builds/lib.esm.d.ts +3166 -0
- package/builds/lib.esm.js +10712 -0
- package/builds/lib.js +167 -1
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +309 -322
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/aggregated-delivery-receipt.js +3 -5
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +7 -9
- package/dist/channel-metadata-client.js.map +1 -1
- package/dist/client.js +189 -154
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +8 -8
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +12 -9
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +11 -8
- package/dist/content-client.js.map +1 -1
- package/dist/content-template.js +3 -5
- package/dist/content-template.js.map +1 -1
- package/dist/conversation.js +113 -87
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +34 -42
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +23 -21
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +25 -23
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +15 -13
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +3 -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 +13 -10
- package/dist/interfaces/rules.js.map +1 -1
- package/dist/logger.js +25 -26
- package/dist/logger.js.map +1 -1
- package/dist/media.js +11 -8
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +48 -40
- package/dist/message-builder.js.map +1 -1
- package/dist/message-recipients-client.js +10 -12
- package/dist/message-recipients-client.js.map +1 -1
- package/dist/message.js +88 -75
- 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 +1 -7
- 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 +34 -29
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +5 -4
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +6 -4
- 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 +11 -8
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +9 -8
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +27 -24
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +6 -4
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +1 -9
- package/dist/util/index.js.map +1 -1
- package/docs/index.html +3 -3
- package/docs/modules.html +2 -2
- package/package.json +7 -7
@@ -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":[
|
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":[],"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,CAAc;QACvB,IAAW,CAAA,WAAA,GAAX,WAAW,CAAgB;QALtC,IAAgB,CAAA,gBAAA,GAAuC,IAAI,CAAC;KAMhE;AAEG,IAAA,MAAM,mBAAmB,GAAA;AAC9B,QAAA,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,EAAE;YAClC,OAAO,IAAI,CAAC,gBAAgB,CAAC;AAC9B,SAAA;QAED,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,MAAM,IAAI,CAAC,sBAAsB,EAAE,CAAC;QACrE,IAAI,SAAS,GAAG,aAAa,CAAC;QAE9B,OAAO,SAAS,KAAK,IAAI,EAAE;AACzB,YAAA,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;YAC1E,SAAS,GAAG,CAAC,GAAG,SAAS,EAAE,GAAG,aAAa,CAAC,CAAC;AAC9C,SAAA;QAED,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEjD,UAAU,CAAC,MAAK;AACd,YAAA,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;AAC/B,SAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;AAErB,QAAA,OAAO,SAAS,CAAC;KAClB;IAEO,MAAM,sBAAsB,CAClC,SAAkB,EAAA;QAElB,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;;;;"}
|
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,9 @@ class ContentTemplate {
|
|
304
300
|
}
|
305
301
|
}
|
306
302
|
|
307
|
-
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;oB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AC;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 parseV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,EAAA;QALb,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAQ;QAKZ,IAAK,CAAA,KAAA,GAAL,KAAK,CAAQ;KAC3B;AAEJ;;;;AAIG;AACI,IAAA,aAAa,CAAC,KAAa,EAAA;QAChC,OAAO,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KACtD;AACF,CAAA;AAED;;;;;AAKG;AACH,MAAM,eAAe,CAAA;AA+BnB;;AAEG;AACH,IAAA,WAAA,CAAmB,uBAAgD,EAAA;AACjE,QAAA,IAAI,CAAC,GAAG,GAAG,uBAAuB,CAAC,GAAG,CAAC;AACvC,QAAA,IAAI,CAAC,YAAY,GAAG,uBAAuB,CAAC,aAAa,CAAC;AAC1D,QAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,CAC7B,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,SAAS,CAA2B,CACxE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,IAAI,uBAAuB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,GAAG,eAAe,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;KACnE;AACF;;;;"};;;;"}
|
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,25 +135,19 @@ var global =
|
|
137
135
|
? window
|
138
136
|
: {};
|
139
137
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
154
|
-
var isEqual = require('lodash.isequal');
|
155
|
-
|
156
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
157
|
-
|
158
|
-
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';
|
159
151
|
|
160
152
|
/**
|
161
153
|
* Map of the fields that will be processed with update messages.
|
@@ -179,7 +171,7 @@ const fieldMappings = {
|
|
179
171
|
* A conversation represents communication between multiple Conversations
|
180
172
|
* clients.
|
181
173
|
*/
|
182
|
-
class Conversation extends
|
174
|
+
class Conversation extends ReplayEventEmitter {
|
183
175
|
/**
|
184
176
|
* @param descriptor Conversation descriptor.
|
185
177
|
* @param sid Conversation SID.
|
@@ -201,8 +193,8 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
201
193
|
status: "notParticipating",
|
202
194
|
attributes: (_a = descriptor.attributes) !== null && _a !== void 0 ? _a : {},
|
203
195
|
createdBy: descriptor.createdBy,
|
204
|
-
dateCreated:
|
205
|
-
dateUpdated:
|
196
|
+
dateCreated: parseTime(descriptor.dateCreated),
|
197
|
+
dateUpdated: parseTime(descriptor.dateUpdated),
|
206
198
|
friendlyName: descriptor.friendlyName || null,
|
207
199
|
lastReadMessageIndex: Number.isInteger(descriptor.lastConsumedMessageIndex)
|
208
200
|
? descriptor.lastConsumedMessageIndex
|
@@ -216,7 +208,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
216
208
|
participants: this._links.participants,
|
217
209
|
};
|
218
210
|
this._participants = new Map();
|
219
|
-
this._participantsEntity = new
|
211
|
+
this._participantsEntity = new Participants(this, this._participants, // state leak
|
220
212
|
participantsLinks, this._services);
|
221
213
|
this._participantsEntity.on(Conversation.participantJoined, (participant) =>
|
222
214
|
// @todo update participants map here??
|
@@ -227,7 +219,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
227
219
|
this._participantsEntity.on(Conversation.participantUpdated, (args) =>
|
228
220
|
// @todo update participants map here??
|
229
221
|
this.emit(Conversation.participantUpdated, args));
|
230
|
-
this._messagesEntity = new
|
222
|
+
this._messagesEntity = new Messages(this, configuration, services);
|
231
223
|
this._messagesEntity.on(Conversation.messageAdded, (message) => this._onMessageAdded(message));
|
232
224
|
this._messagesEntity.on(Conversation.messageUpdated, (args) => this.emit(Conversation.messageUpdated, args));
|
233
225
|
this._messagesEntity.on(Conversation.messageRemoved, (message) => this.emit(Conversation.messageRemoved, message));
|
@@ -457,7 +449,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
457
449
|
*/
|
458
450
|
async getParticipantsCount() {
|
459
451
|
var _a;
|
460
|
-
const url = new
|
452
|
+
const url = new UriBuilder(this._configuration.links.conversations)
|
461
453
|
.path(this.sid)
|
462
454
|
.build();
|
463
455
|
const response = await this._services.network.get(url);
|
@@ -490,7 +482,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
490
482
|
*/
|
491
483
|
async getMessagesCount() {
|
492
484
|
var _a;
|
493
|
-
const url = new
|
485
|
+
const url = new UriBuilder(this._configuration.links.conversations)
|
494
486
|
.path(this.sid)
|
495
487
|
.build();
|
496
488
|
const response = await this._services.network.get(url);
|
@@ -520,7 +512,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
520
512
|
* the user or `null` if the read horizon is not set.
|
521
513
|
*/
|
522
514
|
async getUnreadMessagesCount() {
|
523
|
-
const url = new
|
515
|
+
const url = new UriBuilder(this._configuration.links.myConversations)
|
524
516
|
.path(this.sid)
|
525
517
|
.build();
|
526
518
|
const response = await this._services.network.get(url);
|
@@ -572,10 +564,10 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
572
564
|
var _a, _b;
|
573
565
|
if (typeof message === "string" || message === null) {
|
574
566
|
const response = await this._messagesEntity.send(message, messageAttributes, emailOptions);
|
575
|
-
return (_a =
|
567
|
+
return (_a = parseToNumber(response.index)) !== null && _a !== void 0 ? _a : 0;
|
576
568
|
}
|
577
569
|
const response = await this._messagesEntity.sendMedia(message, messageAttributes, emailOptions);
|
578
|
-
return (_b =
|
570
|
+
return (_b = parseToNumber(response.index)) !== null && _b !== void 0 ? _b : 0;
|
579
571
|
}
|
580
572
|
/**
|
581
573
|
* New interface to prepare for sending a message.
|
@@ -583,7 +575,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
583
575
|
* @return A MessageBuilder to help set all message sending options.
|
584
576
|
*/
|
585
577
|
prepareMessage() {
|
586
|
-
return new
|
578
|
+
return new MessageBuilder(this.limits, this._messagesEntity);
|
587
579
|
}
|
588
580
|
/**
|
589
581
|
* Set last read message index of the conversation to the index of the last
|
@@ -691,8 +683,8 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
691
683
|
});
|
692
684
|
try {
|
693
685
|
this._entity = await this._entityPromise;
|
694
|
-
this._entity.on(
|
695
|
-
this._entity.on(
|
686
|
+
this._entity.on(SyncDocument.updated, (args) => this._update(args.data));
|
687
|
+
this._entity.on(SyncDocument.removed, () => this.emit(Conversation.removed, this));
|
696
688
|
this._update(this._entity.data);
|
697
689
|
return this._entity;
|
698
690
|
}
|
@@ -825,7 +817,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
825
817
|
updateReasons.add(localKey);
|
826
818
|
break;
|
827
819
|
case fieldMappings.attributes:
|
828
|
-
if (
|
820
|
+
if (isEqual(this._internalState.attributes, update.attributes)) {
|
829
821
|
break;
|
830
822
|
}
|
831
823
|
this._internalState.attributes = update.attributes;
|
@@ -861,7 +853,7 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
861
853
|
update.lastMessage.timestamp;
|
862
854
|
updateReasons.add(localKey);
|
863
855
|
}
|
864
|
-
if (
|
856
|
+
if (isEqual(this._internalState.lastMessage, {})) {
|
865
857
|
delete this._internalState.lastMessage;
|
866
858
|
}
|
867
859
|
break;
|
@@ -870,14 +862,14 @@ class Conversation extends replayEventEmitter.ReplayEventEmitter {
|
|
870
862
|
if (state !== undefined) {
|
871
863
|
state.dateUpdated = new Date(state.dateUpdated);
|
872
864
|
}
|
873
|
-
if (
|
865
|
+
if (isEqual(this._internalState.state, state)) {
|
874
866
|
break;
|
875
867
|
}
|
876
868
|
this._internalState.state = state;
|
877
869
|
updateReasons.add(localKey);
|
878
870
|
break;
|
879
871
|
case fieldMappings.bindings:
|
880
|
-
if (
|
872
|
+
if (isEqual(this._internalState.bindings, update.bindings)) {
|
881
873
|
break;
|
882
874
|
}
|
883
875
|
this._internalState.bindings = update.bindings;
|
@@ -1027,57 +1019,57 @@ Conversation.removed = "removed";
|
|
1027
1019
|
/**
|
1028
1020
|
* Logger instance.
|
1029
1021
|
*/
|
1030
|
-
Conversation._logger =
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
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)
|
1036
1028
|
], Conversation.prototype, "add", null);
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
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)
|
1042
1034
|
], Conversation.prototype, "addNonChatParticipant", null);
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1035
|
+
__decorate([
|
1036
|
+
validateTypesAsync(nonNegativeInteger),
|
1037
|
+
__metadata("design:type", Function),
|
1038
|
+
__metadata("design:paramtypes", [Number]),
|
1039
|
+
__metadata("design:returntype", Promise)
|
1048
1040
|
], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
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)
|
1054
1046
|
], Conversation.prototype, "getMessages", null);
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1047
|
+
__decorate([
|
1048
|
+
validateTypesAsync(nonEmptyString),
|
1049
|
+
__metadata("design:type", Function),
|
1050
|
+
__metadata("design:paramtypes", [String]),
|
1051
|
+
__metadata("design:returntype", Promise)
|
1060
1052
|
], Conversation.prototype, "getParticipantBySid", null);
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1053
|
+
__decorate([
|
1054
|
+
validateTypesAsync(nonEmptyString),
|
1055
|
+
__metadata("design:type", Function),
|
1056
|
+
__metadata("design:paramtypes", [String]),
|
1057
|
+
__metadata("design:returntype", Promise)
|
1066
1058
|
], Conversation.prototype, "getParticipantByIdentity", null);
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1059
|
+
__decorate([
|
1060
|
+
validateTypesAsync([nonEmptyString, Participant]),
|
1061
|
+
__metadata("design:type", Function),
|
1062
|
+
__metadata("design:paramtypes", [Object]),
|
1063
|
+
__metadata("design:returntype", Promise)
|
1072
1064
|
], Conversation.prototype, "removeParticipant", null);
|
1073
|
-
|
1074
|
-
|
1065
|
+
__decorate([
|
1066
|
+
validateTypesAsync([
|
1075
1067
|
"string",
|
1076
1068
|
FormData,
|
1077
|
-
|
1078
|
-
|
1079
|
-
contentType:
|
1080
|
-
media:
|
1069
|
+
literal(null),
|
1070
|
+
objectSchema("media options", {
|
1071
|
+
contentType: nonEmptyString,
|
1072
|
+
media: custom((value) => {
|
1081
1073
|
let isValid = (typeof value === "string" && value.length > 0) ||
|
1082
1074
|
value instanceof Uint8Array ||
|
1083
1075
|
value instanceof ArrayBuffer;
|
@@ -1090,17 +1082,51 @@ tslib_es6.__decorate([
|
|
1090
1082
|
];
|
1091
1083
|
}),
|
1092
1084
|
}),
|
1093
|
-
],
|
1085
|
+
], optionalJson, [
|
1094
1086
|
"undefined",
|
1095
|
-
|
1096
|
-
|
1097
|
-
subject: [
|
1087
|
+
literal(null),
|
1088
|
+
objectSchema("email attributes", {
|
1089
|
+
subject: [nonEmptyString, "undefined"],
|
1098
1090
|
}),
|
1099
1091
|
]),
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1092
|
+
__metadata("design:type", Function),
|
1093
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
1094
|
+
__metadata("design:returntype", Promise)
|
1103
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);
|
1104
1130
|
tslib_es6.__decorate([
|
1105
1131
|
declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.literal("default", "muted")),
|
1106
1132
|
tslib_es6.__metadata("design:type", Function),
|