@twilio/conversations 2.2.1-rc.0 → 3.0.0-canary.100

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 (72) hide show
  1. package/builds/browser.js +888 -2159
  2. package/builds/browser.js.map +1 -1
  3. package/builds/lib.d.ts +18 -100
  4. package/builds/lib.js +888 -2159
  5. package/builds/lib.js.map +1 -1
  6. package/builds/twilio-conversations.js +24296 -26232
  7. package/builds/twilio-conversations.min.js +1 -1
  8. package/dist/client.js +56 -90
  9. package/dist/client.js.map +1 -1
  10. package/dist/command-executor.js +30 -12
  11. package/dist/command-executor.js.map +1 -1
  12. package/dist/conversation.js +44 -6
  13. package/dist/conversation.js.map +1 -1
  14. package/dist/data/conversations.js +4 -1
  15. package/dist/data/conversations.js.map +1 -1
  16. package/dist/data/messages.js +3 -13
  17. package/dist/data/messages.js.map +1 -1
  18. package/dist/data/participants.js +4 -2
  19. package/dist/data/participants.js.map +1 -1
  20. package/dist/data/users.js +4 -2
  21. package/dist/data/users.js.map +1 -1
  22. package/dist/message-builder.js.map +1 -1
  23. package/dist/message.js +1 -41
  24. package/dist/message.js.map +1 -1
  25. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  26. package/dist/packages/conversations/package.json.js +1 -1
  27. package/dist/participant.js.map +1 -1
  28. package/dist/services/network.js +38 -15
  29. package/dist/services/network.js.map +1 -1
  30. package/dist/services/typing-indicator.js +7 -5
  31. package/dist/services/typing-indicator.js.map +1 -1
  32. package/dist/unsent-message.js.map +1 -1
  33. package/dist/user.js.map +1 -1
  34. package/dist/util/index.js.map +1 -1
  35. package/package.json +14 -12
  36. package/CHANGELOG.md +0 -705
  37. package/docs/assets/css/main.css +0 -2660
  38. package/docs/assets/images/icons.png +0 -0
  39. package/docs/assets/images/icons@2x.png +0 -0
  40. package/docs/assets/images/widgets.png +0 -0
  41. package/docs/assets/images/widgets@2x.png +0 -0
  42. package/docs/assets/js/main.js +0 -248
  43. package/docs/assets/js/search.js +0 -1
  44. package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
  45. package/docs/classes/CancellablePromise.html +0 -3213
  46. package/docs/classes/Client.html +0 -4254
  47. package/docs/classes/Conversation.html +0 -4359
  48. package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
  49. package/docs/classes/Media.html +0 -3167
  50. package/docs/classes/Message.html +0 -3732
  51. package/docs/classes/MessageBuilder.html +0 -3277
  52. package/docs/classes/Participant.html +0 -3444
  53. package/docs/classes/PushNotification.html +0 -3130
  54. package/docs/classes/RestPaginator.html +0 -3160
  55. package/docs/classes/UnsentMessage.html +0 -3042
  56. package/docs/classes/User.html +0 -3349
  57. package/docs/index.html +0 -3513
  58. package/docs/interfaces/ClientOptions.html +0 -3034
  59. package/docs/interfaces/ConversationBindings.html +0 -3001
  60. package/docs/interfaces/ConversationEmailBinding.html +0 -3001
  61. package/docs/interfaces/ConversationLimits.html +0 -3098
  62. package/docs/interfaces/ConversationState.html +0 -3050
  63. package/docs/interfaces/ConversationUpdatedEventArgs.html +0 -3001
  64. package/docs/interfaces/CreateConversationOptions.html +0 -3066
  65. package/docs/interfaces/LastMessage.html +0 -3050
  66. package/docs/interfaces/Paginator.html +0 -3141
  67. package/docs/interfaces/ParticipantBindings.html +0 -3001
  68. package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
  69. package/docs/interfaces/PushNotificationData.html +0 -3114
  70. package/docs/interfaces/SendEmailOptions.html +0 -3034
  71. package/docs/interfaces/SendMediaOptions.html +0 -3068
  72. package/docs/modules.html +0 -3514
package/dist/message.js CHANGED
@@ -142,7 +142,6 @@ var restPaginator = require('./rest-paginator.js');
142
142
  var detailedDeliveryReceipt = require('./detailed-delivery-receipt.js');
143
143
  var replayEventEmitter = require('@twilio/replay-event-emitter');
144
144
  var isEqual = require('lodash.isequal');
145
- var deprecationDecorator = require('@twilio/deprecation-decorator');
146
145
 
147
146
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
148
147
 
@@ -284,16 +283,6 @@ class Message extends replayEventEmitter.ReplayEventEmitter {
284
283
  get aggregatedDeliveryReceipt() {
285
284
  return this.state.aggregatedDeliveryReceipt;
286
285
  }
287
- /**
288
- * @deprecated
289
- * Return a (possibly empty) array of media matching a specific set of categories.
290
- * Allowed category is so far only 'media'.
291
- * @param categories Array of categories to match.
292
- * @returns Array of media descriptors matching given categories.
293
- */
294
- getMediaByCategory(categories) {
295
- return this.getMediaByCategories(categories);
296
- }
297
286
  /**
298
287
  * Return a (possibly empty) array of media matching a specific set of categories.
299
288
  * Allowed category is so far only 'media'.
@@ -465,24 +454,6 @@ class Message extends replayEventEmitter.ReplayEventEmitter {
465
454
  });
466
455
  return this;
467
456
  }
468
- /**
469
- * @deprecated
470
- * Get content URLs for all media attachments in the given set using a single operation.
471
- * @param contentSet Set of media attachments to query content URLs.
472
- */
473
- async attachTemporaryUrlsFor(contentSet) {
474
- // We ignore existing mcsMedia members of each of the media entries.
475
- // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.
476
- const sids = contentSet === null || contentSet === void 0 ? void 0 : contentSet.map((m) => m.sid);
477
- if (this.services.mcsClient && sids) {
478
- return (await this.services.mcsClient.mediaSetGet(sids)).map((item) => {
479
- return new media.Media(item, this.services);
480
- });
481
- }
482
- else {
483
- throw new Error("Media Content Service is unavailable");
484
- }
485
- }
486
457
  /**
487
458
  * Get content URLs for all media attachments in the given set using a single operation.
488
459
  * @param contentSet Set of media attachments to query content URLs.
@@ -533,6 +504,7 @@ class Message extends replayEventEmitter.ReplayEventEmitter {
533
504
  .arg("PageToken", options === null || options === void 0 ? void 0 : options.pageToken)
534
505
  .arg("PageSize", options === null || options === void 0 ? void 0 : options.pageSize)
535
506
  .build();
507
+ // todo: remove any after the release of new Twilsock
536
508
  const response = await this.services.network.get(url);
537
509
  return new restPaginator.RestPaginator(response.body.delivery_receipts.map((x) => new detailedDeliveryReceipt.DetailedDeliveryReceipt(x)), (pageToken, pageSize) => this._getDetailedDeliveryReceiptsPaginator({ pageToken, pageSize }), response.body.meta.previous_token, response.body.meta.next_token);
538
510
  }
@@ -546,12 +518,6 @@ class Message extends replayEventEmitter.ReplayEventEmitter {
546
518
  * * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update
547
519
  */
548
520
  Message.updated = "updated";
549
- tslib_es6.__decorate([
550
- deprecationDecorator.deprecated("getMediaByCategory", "getMediaByCategories"),
551
- tslib_es6.__metadata("design:type", Function),
552
- tslib_es6.__metadata("design:paramtypes", [Array]),
553
- tslib_es6.__metadata("design:returntype", Array)
554
- ], Message.prototype, "getMediaByCategory", null);
555
521
  tslib_es6.__decorate([
556
522
  declarativeTypeValidator.validateTypes([declarativeTypeValidator.nonEmptyString, "undefined"]),
557
523
  tslib_es6.__metadata("design:type", Function),
@@ -576,12 +542,6 @@ tslib_es6.__decorate([
576
542
  tslib_es6.__metadata("design:paramtypes", [Object]),
577
543
  tslib_es6.__metadata("design:returntype", Promise)
578
544
  ], Message.prototype, "updateAttributes", null);
579
- tslib_es6.__decorate([
580
- deprecationDecorator.deprecated("attachTemporaryUrlsFor", "getTemporaryContentUrlsForMedia"),
581
- tslib_es6.__metadata("design:type", Function),
582
- tslib_es6.__metadata("design:paramtypes", [Array]),
583
- tslib_es6.__metadata("design:returntype", Promise)
584
- ], Message.prototype, "attachTemporaryUrlsFor", null);
585
545
  tslib_es6.__decorate([
586
546
  declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyArray("media", media.Media)),
587
547
  tslib_es6.__metadata("design:type", Function),
@@ -1 +1 @@
1
- {"version":3,"file":"message.js","sources":["../src/message.ts"],"sourcesContent":["import { parseAttributes, UriBuilder } from \"./util\";\nimport { Logger } from \"./logger\";\nimport { Conversation } from \"./conversation\";\nimport {\n CancellablePromise,\n McsClient,\n MediaCategory,\n} from \"@twilio/mcs-client\";\nimport { Media } from \"./media\";\nimport { Participant } from \"./participant\";\nimport {\n AggregatedDeliveryDescriptor,\n AggregatedDeliveryReceipt,\n} from \"./aggregated-delivery-receipt\";\nimport {\n validateTypes,\n validateTypesAsync,\n nonEmptyString,\n nonEmptyArray,\n} from \"@twilio/declarative-type-validator\";\nimport { attributesValidator } from \"./interfaces/attributes\";\nimport { Network } from \"./services/network\";\nimport { RestPaginator } from \"./rest-paginator\";\nimport { DetailedDeliveryReceipt } from \"./detailed-delivery-receipt\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { Configuration } from \"./configuration\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { EditMessageRequest } from \"./interfaces/commands/edit-message\";\nimport { MessageResponse } from \"./interfaces/commands/message-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"./types\";\nimport { ResponseMeta } from \"./interfaces/commands/response-meta\";\nimport { DeliveryReceiptResponse } from \"./interfaces/commands/delivery-receipt-response\";\nimport { deprecated } from \"@twilio/deprecation-decorator\";\n\ntype MessageEvents = {\n updated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope(\"Message\");\n\ninterface MessageState {\n sid: string;\n index: number;\n author: string | null;\n subject: string | null;\n body: string | null;\n dateUpdated: Date | null;\n lastUpdatedBy: string | null;\n attributes: JSONValue;\n timestamp: Date | null;\n type: MessageType;\n media: Media | null;\n medias: Media[] | null;\n participantSid: string | null;\n aggregatedDeliveryReceipt: AggregatedDeliveryReceipt | null;\n}\n\ninterface MessageServices {\n mcsClient: McsClient;\n network: Network;\n commandExecutor: CommandExecutor;\n}\n\ninterface MessageLinks {\n self: string;\n conversation: string;\n messages_receipts: string;\n}\n\n/**\n * The reason for the `updated` event being emitted by a message.\n */\ntype MessageUpdateReason =\n | \"body\"\n | \"lastUpdatedBy\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"attributes\"\n | \"author\"\n | \"deliveryReceipt\"\n | \"subject\";\n\n/**\n * Type of a message.\n */\ntype MessageType = \"text\" | \"media\";\n\ninterface MessageUpdatedEventArgs {\n message: Message;\n updateReasons: MessageUpdateReason[];\n}\n\nexport interface MessageData {\n sid: string;\n text?: string;\n type?: MessageType;\n author: string | null;\n subject: string | null;\n lastUpdatedBy?: string | null;\n attributes?: JSONValue;\n dateUpdated: string;\n timestamp?: string;\n medias?: Media[];\n media?: Media;\n memberSid?: string;\n delivery?: AggregatedDeliveryDescriptor;\n}\n\n/**\n * A message in a conversation.\n */\nclass Message extends ReplayEventEmitter<MessageEvents> {\n /**\n * Conversation that the message is in.\n */\n public readonly conversation: Conversation;\n\n private readonly links: MessageLinks;\n private readonly configuration: Configuration;\n private readonly services: MessageServices;\n\n private state: MessageState;\n\n /**\n * @internal\n */\n constructor(\n index: number,\n data: MessageData,\n conversation: Conversation,\n links: MessageLinks,\n configuration: Configuration,\n services: MessageServices\n ) {\n super();\n\n this.conversation = conversation;\n\n this.links = links;\n this.configuration = configuration;\n this.services = services;\n\n this.state = {\n sid: data.sid,\n index: index,\n author: data.author,\n subject: data.subject,\n body: data.text ?? null,\n timestamp: data.timestamp ? new Date(data.timestamp) : null,\n dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,\n lastUpdatedBy: data.lastUpdatedBy ?? null,\n attributes: parseAttributes(\n data.attributes,\n `Got malformed attributes for the message ${data.sid}`,\n log\n ),\n type: data.type ?? \"text\",\n media:\n data.type === \"media\" && data.media\n ? new Media(data.media, this.services)\n : null,\n medias:\n data.type === \"media\" && data.medias\n ? data.medias.map((m) => new Media(m, this.services))\n : data.type === \"media\" && data.media && !data.medias\n ? [\n new Media(\n { ...data.media, category: \"media\" } as Media,\n this.services\n ),\n ]\n : null,\n participantSid: data.memberSid ?? null,\n aggregatedDeliveryReceipt: data.delivery\n ? new AggregatedDeliveryReceipt(data.delivery)\n : null,\n };\n }\n\n /**\n * Fired when the properties or the body of the message has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Message} message - the message in question\n * * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update\n */\n static readonly updated = \"updated\";\n\n /**\n * The server-assigned unique identifier for the message.\n */\n public get sid(): string {\n return this.state.sid;\n }\n\n /**\n * Name of the user that sent the message.\n */\n public get author(): string | null {\n return this.state.author;\n }\n\n /**\n * Message subject. Used only in email conversations.\n */\n public get subject(): string | null {\n return this.state.subject;\n }\n\n /**\n * Body of the message.\n */\n public get body(): string | null {\n return this.state.body;\n }\n\n /**\n * Date this message was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this.state.dateUpdated;\n }\n\n /**\n * Index of this message in the conversation's list of messages.\n *\n * By design, the message indices may have arbitrary gaps between them,\n * that does not necessarily mean they were deleted or otherwise modified - just that\n * messages may have some non-contiguous indices even if they are being sent immediately one after another.\n *\n * Trying to use indices for some calculations is going to be unreliable.\n *\n * To calculate the number of unread messages, it is better to use the Read Horizon API.\n * See {@link Conversation.getUnreadMessagesCount} for details.\n */\n public get index(): number {\n return this.state.index;\n }\n\n /**\n * Identity of the last user that updated the message.\n */\n public get lastUpdatedBy(): string | null {\n return this.state.lastUpdatedBy;\n }\n\n /**\n * Date this message was created on.\n */\n public get dateCreated(): Date | null {\n return this.state.timestamp;\n }\n\n /**\n * Custom attributes of the message.\n */\n public get attributes(): JSONValue {\n return this.state.attributes;\n }\n\n /**\n * Type of the message.\n */\n public get type(): MessageType {\n return this.state.type;\n }\n\n /**\n * One of the attached media (if present).\n * @deprecated Use attachedMedia instead. Note that the latter is now an array.\n */\n public get media(): Media | null {\n return this.state.media;\n }\n\n /**\n * Return all media attachments, except email body/history attachments, without temporary urls.\n */\n public get attachedMedia(): Array<Media> | null {\n return this.getMediaByCategories([\"media\"]);\n }\n\n /**\n * The server-assigned unique identifier of the authoring participant.\n */\n public get participantSid(): string | null {\n return this.state.participantSid;\n }\n\n /**\n * Aggregated information about the message delivery statuses across all participants of a conversation..\n */\n public get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null {\n return this.state.aggregatedDeliveryReceipt;\n }\n\n /**\n * @deprecated\n * Return a (possibly empty) array of media matching a specific set of categories.\n * Allowed category is so far only 'media'.\n * @param categories Array of categories to match.\n * @returns Array of media descriptors matching given categories.\n */\n @deprecated(\"getMediaByCategory\", \"getMediaByCategories\")\n public getMediaByCategory(\n categories: Array<MediaCategory>\n ): Array<Media> | null {\n return this.getMediaByCategories(categories);\n }\n\n /**\n * Return a (possibly empty) array of media matching a specific set of categories.\n * Allowed category is so far only 'media'.\n * @param categories Array of categories to match.\n * @returns Array of media descriptors matching given categories.\n */\n public getMediaByCategories(categories: MediaCategory[]): Media[] | null {\n return (this.state.medias ?? []).filter((m) =>\n categories.includes(m.category)\n );\n }\n\n /**\n * Get a media descriptor for an email body attachment of a provided type.\n * Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.\n * @param type Type of email body to request, defaults to `text/plain`.\n */\n @validateTypes([nonEmptyString, \"undefined\"])\n public getEmailBody(type = \"text/plain\"): Media | null {\n return (\n this.getMediaByCategories([\"body\"])\n ?.filter((m) => m.contentType == type)\n .shift() ?? null\n );\n }\n\n /**\n * Get a media descriptor for an email history attachment of a provided type.\n * Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.\n * @param type Type of email history to request, defaults to `text/plain`.\n */\n @validateTypes([nonEmptyString, \"undefined\"])\n public getEmailHistory(type = \"text/plain\"): Media | null {\n return (\n this.getMediaByCategories([\"history\"])\n ?.filter((m) => m.contentType == type)\n .shift() ?? null\n );\n }\n\n _update(data) {\n const updateReasons: MessageUpdateReason[] = [];\n\n if (\n (data.text || typeof data.text === \"string\") &&\n data.text !== this.state.body\n ) {\n this.state.body = data.text;\n updateReasons.push(\"body\");\n }\n\n if (data.subject && data.subject !== this.state.subject) {\n this.state.subject = data.subject;\n updateReasons.push(\"subject\");\n }\n\n if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {\n this.state.lastUpdatedBy = data.lastUpdatedBy;\n updateReasons.push(\"lastUpdatedBy\");\n }\n\n if (data.author && data.author !== this.state.author) {\n this.state.author = data.author;\n updateReasons.push(\"author\");\n }\n\n if (\n data.dateUpdated &&\n new Date(data.dateUpdated).getTime() !==\n (this.state.dateUpdated && this.state.dateUpdated.getTime())\n ) {\n this.state.dateUpdated = new Date(data.dateUpdated);\n updateReasons.push(\"dateUpdated\");\n }\n\n if (\n data.timestamp &&\n new Date(data.timestamp).getTime() !==\n (this.state.timestamp && this.state.timestamp.getTime())\n ) {\n this.state.timestamp = new Date(data.timestamp);\n updateReasons.push(\"dateCreated\");\n }\n\n const updatedAttributes = parseAttributes(\n data.attributes,\n `Got malformed attributes for the message ${this.sid}`,\n log\n );\n if (!isEqual(this.state.attributes, updatedAttributes)) {\n this.state.attributes = updatedAttributes;\n updateReasons.push(\"attributes\");\n }\n\n const updatedAggregatedDelivery = data.delivery;\n const currentAggregatedDelivery = this.state.aggregatedDeliveryReceipt;\n const isUpdatedAggregateDeliveryValid =\n !!updatedAggregatedDelivery &&\n !!updatedAggregatedDelivery.total &&\n !!updatedAggregatedDelivery.delivered &&\n !!updatedAggregatedDelivery.failed &&\n !!updatedAggregatedDelivery.read &&\n !!updatedAggregatedDelivery.sent &&\n !!updatedAggregatedDelivery.undelivered;\n if (isUpdatedAggregateDeliveryValid) {\n if (!currentAggregatedDelivery) {\n this.state.aggregatedDeliveryReceipt = new AggregatedDeliveryReceipt(\n updatedAggregatedDelivery\n );\n updateReasons.push(\"deliveryReceipt\");\n } else if (\n !currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)\n ) {\n currentAggregatedDelivery._update(updatedAggregatedDelivery);\n updateReasons.push(\"deliveryReceipt\");\n }\n }\n\n if (updateReasons.length > 0) {\n this.emit(\"updated\", { message: this, updateReasons: updateReasons });\n }\n }\n\n /**\n * Get the participant who is the author of the message.\n */\n public async getParticipant(): Promise<Participant> {\n let participant: Participant | null = null;\n if (this.state.participantSid) {\n participant = await this.conversation\n .getParticipantBySid(this.state.participantSid)\n .catch(() => {\n log.debug(\n `Participant with sid \"${this.participantSid}\" not found for message ${this.sid}`\n );\n return null;\n });\n }\n if (!participant && this.state.author) {\n participant = await this.conversation\n .getParticipantByIdentity(this.state.author)\n .catch(() => {\n log.debug(\n `Participant with identity \"${this.author}\" not found for message ${this.sid}`\n );\n return null;\n });\n }\n if (participant) {\n return participant;\n }\n let errorMesage = \"Participant with \";\n if (this.state.participantSid) {\n errorMesage += \"SID '\" + this.state.participantSid + \"' \";\n }\n if (this.state.author) {\n if (this.state.participantSid) {\n errorMesage += \"or \";\n }\n errorMesage += \"identity '\" + this.state.author + \"' \";\n }\n if (errorMesage === \"Participant with \") {\n errorMesage = \"Participant \";\n }\n errorMesage += \"was not found\";\n throw new Error(errorMesage);\n }\n\n /**\n * Get the delivery receipts of the message.\n */\n public async getDetailedDeliveryReceipts(): Promise<\n DetailedDeliveryReceipt[]\n > {\n let paginator: Paginator<DetailedDeliveryReceipt> =\n await this._getDetailedDeliveryReceiptsPaginator();\n let detailedDeliveryReceipts: DetailedDeliveryReceipt[] = paginator.items;\n\n while (paginator.hasNextPage) {\n paginator = await paginator.nextPage();\n detailedDeliveryReceipts = [\n ...detailedDeliveryReceipts,\n ...paginator.items,\n ];\n }\n\n return detailedDeliveryReceipts;\n }\n\n /**\n * Remove the message.\n */\n public async remove(): Promise<Message> {\n await this.services.commandExecutor.mutateResource(\n \"delete\",\n this.links.self\n );\n\n return this;\n }\n\n /**\n * Edit the message body.\n * @param body New body of the message.\n */\n @validateTypesAsync(\"string\")\n public async updateBody(body: string): Promise<Message> {\n await this.services.commandExecutor.mutateResource<\n EditMessageRequest,\n MessageResponse\n >(\"post\", this.links.self, {\n body,\n });\n\n return this;\n }\n\n /**\n * Edit the message attributes.\n * @param attributes New attributes.\n */\n @validateTypesAsync(attributesValidator)\n public async updateAttributes(attributes: JSONValue): Promise<Message> {\n await this.services.commandExecutor.mutateResource<\n EditMessageRequest,\n MessageResponse\n >(\"post\", this.links.self, {\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n });\n\n return this;\n }\n\n /**\n * @deprecated\n * Get content URLs for all media attachments in the given set using a single operation.\n * @param contentSet Set of media attachments to query content URLs.\n */\n @deprecated(\"attachTemporaryUrlsFor\", \"getTemporaryContentUrlsForMedia\")\n public async attachTemporaryUrlsFor(\n contentSet: Media[] | null\n ): Promise<Media[]> {\n // We ignore existing mcsMedia members of each of the media entries.\n // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.\n const sids = contentSet?.map((m) => m.sid);\n if (this.services.mcsClient && sids) {\n return (await this.services.mcsClient.mediaSetGet(sids)).map((item) => {\n return new Media(item, this.services);\n });\n } else {\n throw new Error(\"Media Content Service is unavailable\");\n }\n }\n\n /**\n * Get content URLs for all media attachments in the given set using a single operation.\n * @param contentSet Set of media attachments to query content URLs.\n */\n @validateTypesAsync(nonEmptyArray(\"media\", Media))\n public getTemporaryContentUrlsForMedia(\n contentSet: Media[]\n ): CancellablePromise<Map<string, string>> {\n // We ignore existing mcsMedia members of each of the media entries.\n // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.\n const sids = contentSet.map((m) => m.sid);\n return this.getTemporaryContentUrlsForMediaSids(sids);\n }\n\n /**\n * Get content URLs for all media attachments in the given set of media sids using a single operation.\n * @param mediaSids Set of media sids to query for the content URL.\n */\n @validateTypesAsync(nonEmptyArray(\"strings\", \"string\"))\n public getTemporaryContentUrlsForMediaSids(\n mediaSids: string[]\n ): CancellablePromise<Map<string, string>> {\n return new CancellablePromise(async (resolve, reject, onCancel) => {\n const mediaGetRequest = this.services.mcsClient.mediaSetGetContentUrls(\n mediaSids ?? []\n );\n\n if (!this.services.mcsClient || !mediaSids) {\n reject(new Error(\"Media Content Service is unavailable\"));\n return;\n }\n\n onCancel(() => {\n mediaGetRequest.cancel();\n });\n\n try {\n const urls = await mediaGetRequest;\n resolve(urls);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Get content URLs for all media attached to the message.\n */\n public getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<\n Map<string, string>\n > {\n const media = this.attachedMedia;\n const sids = media?.map((m) => m.sid) ?? [];\n return this.getTemporaryContentUrlsForMediaSids(sids);\n }\n\n private async _getDetailedDeliveryReceiptsPaginator(options?: {\n pageToken?: string;\n pageSize?: number;\n }): Promise<Paginator<DetailedDeliveryReceipt>> {\n const messagesReceiptsUrl = this.configuration.links.messagesReceipts\n .replace(\"%s\", this.conversation.sid)\n .replace(\"%s\", this.sid);\n const url = new UriBuilder(messagesReceiptsUrl)\n .arg(\"PageToken\", options?.pageToken as string)\n .arg(\"PageSize\", options?.pageSize as number)\n .build();\n const response = await this.services.network.get<\n { delivery_receipts: DeliveryReceiptResponse[] } & ResponseMeta\n >(url);\n\n return new RestPaginator<DetailedDeliveryReceipt>(\n response.body.delivery_receipts.map(\n (x) => new DetailedDeliveryReceipt(x)\n ),\n (pageToken, pageSize) =>\n this._getDetailedDeliveryReceiptsPaginator({ pageToken, pageSize }),\n response.body.meta.previous_token,\n response.body.meta.next_token\n );\n }\n}\n\nexport {\n Message,\n MessageServices,\n MessageType,\n MessageUpdateReason,\n MessageUpdatedEventArgs,\n};\n"],"names":["Logger","ReplayEventEmitter","index","parseAttributes","Media","AggregatedDeliveryReceipt","isEqual","CancellablePromise","UriBuilder","RestPaginator","DetailedDeliveryReceipt","__decorate","deprecated","validateTypes","nonEmptyString","validateTypesAsync","attributesValidator","nonEmptyArray"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAsEpC;;AAEG;AACH,MAAM,OAAQ,SAAQC,qCAAiC,CAAA;AAYrD;;AAEG;IACH,WACE,CAAAC,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AAA,EAAA,IAAA,CAAA,CAAA;AAODI,oBAAA,CAAA;AADC,IAAAI,2CAAkB,CAACE,sCAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;;;8CAGpDV,4BAAkB,CAAA;AAsBpB,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,qCAAA,EAAA,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"message.js","sources":["../src/message.ts"],"sourcesContent":["import { parseAttributes, UriBuilder } from \"./util\";\nimport { Logger } from \"./logger\";\nimport { Conversation } from \"./conversation\";\nimport {\n CancellablePromise,\n McsClient,\n MediaCategory,\n} from \"@twilio/mcs-client\";\nimport { Media, MediaState } from \"./media\";\nimport { Participant } from \"./participant\";\nimport {\n AggregatedDeliveryDescriptor,\n AggregatedDeliveryReceipt,\n} from \"./aggregated-delivery-receipt\";\nimport {\n validateTypes,\n validateTypesAsync,\n nonEmptyString,\n nonEmptyArray,\n} from \"@twilio/declarative-type-validator\";\nimport { attributesValidator } from \"./interfaces/attributes\";\nimport { Network } from \"./services/network\";\nimport { RestPaginator } from \"./rest-paginator\";\nimport { DetailedDeliveryReceipt } from \"./detailed-delivery-receipt\";\nimport { Paginator } from \"./interfaces/paginator\";\nimport { Configuration } from \"./configuration\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { EditMessageRequest } from \"./interfaces/commands/edit-message\";\nimport { MessageResponse } from \"./interfaces/commands/message-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"@twilio/shared\";\nimport { ResponseMeta } from \"./interfaces/commands/response-meta\";\nimport { DeliveryReceiptResponse } from \"./interfaces/commands/delivery-receipt-response\";\n\ntype MessageEvents = {\n updated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope(\"Message\");\n\ninterface MessageState {\n sid: string;\n index: number;\n author: string | null;\n subject: string | null;\n body: string | null;\n dateUpdated: Date | null;\n lastUpdatedBy: string | null;\n attributes: JSONValue;\n timestamp: Date | null;\n type: MessageType;\n media: Media | null;\n medias: Media[] | null;\n participantSid: string | null;\n aggregatedDeliveryReceipt: AggregatedDeliveryReceipt | null;\n}\n\ninterface MessageServices {\n mcsClient: McsClient;\n network: Network;\n commandExecutor: CommandExecutor;\n}\n\ninterface MessageLinks {\n self: string;\n conversation: string;\n messages_receipts: string;\n}\n\n/**\n * The reason for the `updated` event being emitted by a message.\n */\ntype MessageUpdateReason =\n | \"body\"\n | \"lastUpdatedBy\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"attributes\"\n | \"author\"\n | \"deliveryReceipt\"\n | \"subject\";\n\n/**\n * Type of a message.\n */\ntype MessageType = \"text\" | \"media\";\n\ninterface MessageUpdatedEventArgs {\n message: Message;\n updateReasons: MessageUpdateReason[];\n}\n\nexport interface MessageData {\n sid: string;\n text?: string;\n type?: MessageType;\n author: string | null;\n subject: string | null;\n lastUpdatedBy?: string | null;\n attributes?: JSONValue;\n dateUpdated: string;\n timestamp?: string;\n medias: MediaState[] | null;\n media: MediaState | null;\n memberSid?: string;\n delivery?: AggregatedDeliveryDescriptor;\n}\n\n/**\n * A message in a conversation.\n */\nclass Message extends ReplayEventEmitter<MessageEvents> {\n /**\n * Conversation that the message is in.\n */\n public readonly conversation: Conversation;\n\n private readonly links: MessageLinks;\n private readonly configuration: Configuration;\n private readonly services: MessageServices;\n\n private state: MessageState;\n\n /**\n * @internal\n */\n constructor(\n index: number,\n data: MessageData,\n conversation: Conversation,\n links: MessageLinks,\n configuration: Configuration,\n services: MessageServices\n ) {\n super();\n\n this.conversation = conversation;\n\n this.links = links;\n this.configuration = configuration;\n this.services = services;\n\n this.state = {\n sid: data.sid,\n index: index,\n author: data.author,\n subject: data.subject,\n body: data.text ?? null,\n timestamp: data.timestamp ? new Date(data.timestamp) : null,\n dateUpdated: data.dateUpdated ? new Date(data.dateUpdated) : null,\n lastUpdatedBy: data.lastUpdatedBy ?? null,\n attributes: parseAttributes(\n data.attributes,\n `Got malformed attributes for the message ${data.sid}`,\n log\n ),\n type: data.type ?? \"text\",\n media:\n data.type === \"media\" && data.media\n ? new Media(data.media, this.services)\n : null,\n medias:\n data.type === \"media\" && data.medias\n ? data.medias.map((m) => new Media(m, this.services))\n : data.type === \"media\" && data.media && !data.medias\n ? [\n new Media(\n { ...data.media, category: \"media\" } as Media,\n this.services\n ),\n ]\n : null,\n participantSid: data.memberSid ?? null,\n aggregatedDeliveryReceipt: data.delivery\n ? new AggregatedDeliveryReceipt(data.delivery)\n : null,\n };\n }\n\n /**\n * Fired when the properties or the body of the message has been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Message} message - the message in question\n * * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update\n */\n static readonly updated = \"updated\";\n\n /**\n * The server-assigned unique identifier for the message.\n */\n public get sid(): string {\n return this.state.sid;\n }\n\n /**\n * Name of the user that sent the message.\n */\n public get author(): string | null {\n return this.state.author;\n }\n\n /**\n * Message subject. Used only in email conversations.\n */\n public get subject(): string | null {\n return this.state.subject;\n }\n\n /**\n * Body of the message.\n */\n public get body(): string | null {\n return this.state.body;\n }\n\n /**\n * Date this message was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this.state.dateUpdated;\n }\n\n /**\n * Index of this message in the conversation's list of messages.\n *\n * By design, the message indices may have arbitrary gaps between them,\n * that does not necessarily mean they were deleted or otherwise modified - just that\n * messages may have some non-contiguous indices even if they are being sent immediately one after another.\n *\n * Trying to use indices for some calculations is going to be unreliable.\n *\n * To calculate the number of unread messages, it is better to use the Read Horizon API.\n * See {@link Conversation.getUnreadMessagesCount} for details.\n */\n public get index(): number {\n return this.state.index;\n }\n\n /**\n * Identity of the last user that updated the message.\n */\n public get lastUpdatedBy(): string | null {\n return this.state.lastUpdatedBy;\n }\n\n /**\n * Date this message was created on.\n */\n public get dateCreated(): Date | null {\n return this.state.timestamp;\n }\n\n /**\n * Custom attributes of the message.\n */\n public get attributes(): JSONValue {\n return this.state.attributes;\n }\n\n /**\n * Type of the message.\n */\n public get type(): MessageType {\n return this.state.type;\n }\n\n /**\n * One of the attached media (if present).\n * @deprecated Use attachedMedia instead. Note that the latter is now an array.\n */\n public get media(): Media | null {\n return this.state.media;\n }\n\n /**\n * Return all media attachments, except email body/history attachments, without temporary urls.\n */\n public get attachedMedia(): Array<Media> | null {\n return this.getMediaByCategories([\"media\"]);\n }\n\n /**\n * The server-assigned unique identifier of the authoring participant.\n */\n public get participantSid(): string | null {\n return this.state.participantSid;\n }\n\n /**\n * Aggregated information about the message delivery statuses across all participants of a conversation..\n */\n public get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null {\n return this.state.aggregatedDeliveryReceipt;\n }\n\n /**\n * Return a (possibly empty) array of media matching a specific set of categories.\n * Allowed category is so far only 'media'.\n * @param categories Array of categories to match.\n * @returns Array of media descriptors matching given categories.\n */\n public getMediaByCategories(categories: MediaCategory[]): Media[] | null {\n return (this.state.medias ?? []).filter((m) =>\n categories.includes(m.category)\n );\n }\n\n /**\n * Get a media descriptor for an email body attachment of a provided type.\n * Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.\n * @param type Type of email body to request, defaults to `text/plain`.\n */\n @validateTypes([nonEmptyString, \"undefined\"])\n public getEmailBody(type = \"text/plain\"): Media | null {\n return (\n this.getMediaByCategories([\"body\"])\n ?.filter((m) => m.contentType == type)\n .shift() ?? null\n );\n }\n\n /**\n * Get a media descriptor for an email history attachment of a provided type.\n * Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.\n * @param type Type of email history to request, defaults to `text/plain`.\n */\n @validateTypes([nonEmptyString, \"undefined\"])\n public getEmailHistory(type = \"text/plain\"): Media | null {\n return (\n this.getMediaByCategories([\"history\"])\n ?.filter((m) => m.contentType == type)\n .shift() ?? null\n );\n }\n\n _update(data) {\n const updateReasons: MessageUpdateReason[] = [];\n\n if (\n (data.text || typeof data.text === \"string\") &&\n data.text !== this.state.body\n ) {\n this.state.body = data.text;\n updateReasons.push(\"body\");\n }\n\n if (data.subject && data.subject !== this.state.subject) {\n this.state.subject = data.subject;\n updateReasons.push(\"subject\");\n }\n\n if (data.lastUpdatedBy && data.lastUpdatedBy !== this.state.lastUpdatedBy) {\n this.state.lastUpdatedBy = data.lastUpdatedBy;\n updateReasons.push(\"lastUpdatedBy\");\n }\n\n if (data.author && data.author !== this.state.author) {\n this.state.author = data.author;\n updateReasons.push(\"author\");\n }\n\n if (\n data.dateUpdated &&\n new Date(data.dateUpdated).getTime() !==\n (this.state.dateUpdated && this.state.dateUpdated.getTime())\n ) {\n this.state.dateUpdated = new Date(data.dateUpdated);\n updateReasons.push(\"dateUpdated\");\n }\n\n if (\n data.timestamp &&\n new Date(data.timestamp).getTime() !==\n (this.state.timestamp && this.state.timestamp.getTime())\n ) {\n this.state.timestamp = new Date(data.timestamp);\n updateReasons.push(\"dateCreated\");\n }\n\n const updatedAttributes = parseAttributes(\n data.attributes,\n `Got malformed attributes for the message ${this.sid}`,\n log\n );\n if (!isEqual(this.state.attributes, updatedAttributes)) {\n this.state.attributes = updatedAttributes;\n updateReasons.push(\"attributes\");\n }\n\n const updatedAggregatedDelivery = data.delivery;\n const currentAggregatedDelivery = this.state.aggregatedDeliveryReceipt;\n const isUpdatedAggregateDeliveryValid =\n !!updatedAggregatedDelivery &&\n !!updatedAggregatedDelivery.total &&\n !!updatedAggregatedDelivery.delivered &&\n !!updatedAggregatedDelivery.failed &&\n !!updatedAggregatedDelivery.read &&\n !!updatedAggregatedDelivery.sent &&\n !!updatedAggregatedDelivery.undelivered;\n if (isUpdatedAggregateDeliveryValid) {\n if (!currentAggregatedDelivery) {\n this.state.aggregatedDeliveryReceipt = new AggregatedDeliveryReceipt(\n updatedAggregatedDelivery\n );\n updateReasons.push(\"deliveryReceipt\");\n } else if (\n !currentAggregatedDelivery._isEquals(updatedAggregatedDelivery)\n ) {\n currentAggregatedDelivery._update(updatedAggregatedDelivery);\n updateReasons.push(\"deliveryReceipt\");\n }\n }\n\n if (updateReasons.length > 0) {\n this.emit(\"updated\", { message: this, updateReasons: updateReasons });\n }\n }\n\n /**\n * Get the participant who is the author of the message.\n */\n public async getParticipant(): Promise<Participant> {\n let participant: Participant | null = null;\n if (this.state.participantSid) {\n participant = await this.conversation\n .getParticipantBySid(this.state.participantSid)\n .catch(() => {\n log.debug(\n `Participant with sid \"${this.participantSid}\" not found for message ${this.sid}`\n );\n return null;\n });\n }\n if (!participant && this.state.author) {\n participant = await this.conversation\n .getParticipantByIdentity(this.state.author)\n .catch(() => {\n log.debug(\n `Participant with identity \"${this.author}\" not found for message ${this.sid}`\n );\n return null;\n });\n }\n if (participant) {\n return participant;\n }\n let errorMesage = \"Participant with \";\n if (this.state.participantSid) {\n errorMesage += \"SID '\" + this.state.participantSid + \"' \";\n }\n if (this.state.author) {\n if (this.state.participantSid) {\n errorMesage += \"or \";\n }\n errorMesage += \"identity '\" + this.state.author + \"' \";\n }\n if (errorMesage === \"Participant with \") {\n errorMesage = \"Participant \";\n }\n errorMesage += \"was not found\";\n throw new Error(errorMesage);\n }\n\n /**\n * Get the delivery receipts of the message.\n */\n public async getDetailedDeliveryReceipts(): Promise<\n DetailedDeliveryReceipt[]\n > {\n let paginator: Paginator<DetailedDeliveryReceipt> =\n await this._getDetailedDeliveryReceiptsPaginator();\n let detailedDeliveryReceipts: DetailedDeliveryReceipt[] = paginator.items;\n\n while (paginator.hasNextPage) {\n paginator = await paginator.nextPage();\n detailedDeliveryReceipts = [\n ...detailedDeliveryReceipts,\n ...paginator.items,\n ];\n }\n\n return detailedDeliveryReceipts;\n }\n\n /**\n * Remove the message.\n */\n public async remove(): Promise<Message> {\n await this.services.commandExecutor.mutateResource(\n \"delete\",\n this.links.self\n );\n\n return this;\n }\n\n /**\n * Edit the message body.\n * @param body New body of the message.\n */\n @validateTypesAsync(\"string\")\n public async updateBody(body: string): Promise<Message> {\n await this.services.commandExecutor.mutateResource<\n EditMessageRequest,\n MessageResponse\n >(\"post\", this.links.self, {\n body,\n });\n\n return this;\n }\n\n /**\n * Edit the message attributes.\n * @param attributes New attributes.\n */\n @validateTypesAsync(attributesValidator)\n public async updateAttributes(attributes: JSONValue): Promise<Message> {\n await this.services.commandExecutor.mutateResource<\n EditMessageRequest,\n MessageResponse\n >(\"post\", this.links.self, {\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n });\n\n return this;\n }\n\n /**\n * Get content URLs for all media attachments in the given set using a single operation.\n * @param contentSet Set of media attachments to query content URLs.\n */\n @validateTypesAsync(nonEmptyArray(\"media\", Media))\n public getTemporaryContentUrlsForMedia(\n contentSet: Media[]\n ): CancellablePromise<Map<string, string>> {\n // We ignore existing mcsMedia members of each of the media entries.\n // Instead we just collect their sids and pull new descriptors from a mediaSet GET endpoint.\n const sids = contentSet.map((m) => m.sid);\n return this.getTemporaryContentUrlsForMediaSids(sids);\n }\n\n /**\n * Get content URLs for all media attachments in the given set of media sids using a single operation.\n * @param mediaSids Set of media sids to query for the content URL.\n */\n @validateTypesAsync(nonEmptyArray(\"strings\", \"string\"))\n public getTemporaryContentUrlsForMediaSids(\n mediaSids: string[]\n ): CancellablePromise<Map<string, string>> {\n return new CancellablePromise(async (resolve, reject, onCancel) => {\n const mediaGetRequest = this.services.mcsClient.mediaSetGetContentUrls(\n mediaSids ?? []\n );\n\n if (!this.services.mcsClient || !mediaSids) {\n reject(new Error(\"Media Content Service is unavailable\"));\n return;\n }\n\n onCancel(() => {\n mediaGetRequest.cancel();\n });\n\n try {\n const urls = await mediaGetRequest;\n resolve(urls);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Get content URLs for all media attached to the message.\n */\n public getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<\n Map<string, string>\n > {\n const media = this.attachedMedia;\n const sids = media?.map((m) => m.sid) ?? [];\n return this.getTemporaryContentUrlsForMediaSids(sids);\n }\n\n private async _getDetailedDeliveryReceiptsPaginator(options?: {\n pageToken?: string;\n pageSize?: number;\n }): Promise<Paginator<DetailedDeliveryReceipt>> {\n const messagesReceiptsUrl = this.configuration.links.messagesReceipts\n .replace(\"%s\", this.conversation.sid)\n .replace(\"%s\", this.sid);\n const url = new UriBuilder(messagesReceiptsUrl)\n .arg(\"PageToken\", options?.pageToken as string)\n .arg(\"PageSize\", options?.pageSize as number)\n .build();\n // todo: remove any after the release of new Twilsock\n const response: any = await this.services.network.get<\n { delivery_receipts: DeliveryReceiptResponse[] } & ResponseMeta\n >(url);\n\n return new RestPaginator<DetailedDeliveryReceipt>(\n response.body.delivery_receipts.map(\n (x) => new DetailedDeliveryReceipt(x)\n ),\n (pageToken, pageSize) =>\n this._getDetailedDeliveryReceiptsPaginator({ pageToken, pageSize }),\n response.body.meta.previous_token,\n response.body.meta.next_token\n );\n }\n}\n\nexport {\n Message,\n MessageServices,\n MessageType,\n MessageUpdateReason,\n MessageUpdatedEventArgs,\n};\n"],"names":["Logger","ReplayEventEmitter","index","parseAttributes","Media","AggregatedDeliveryReceipt","isEqual","CancellablePromise","UriBuilder","RestPaginator","DetailedDeliveryReceipt","__decorate","validateTypes","nonEmptyString","validateTypesAsync","attributesValidator","nonEmptyArray"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAsEpC;;AAEG;AACH,MAAM,OAAQ,SAAQC,qCAAiC,CAAA;AAYrD;;AAEG;IACH,WACE,CAAAC,OAAa,EACb,IAAiB,EACjB,YAA0B,EAC1B,KAAmB,EACnB,aAA4B,EAC5B,QAAyB,EAAA;;AAEzB,QAAA,KAAK,EAAE,CAAC;AAER,QAAA,IAAI,CAAC,YAAY,GAAG,YAA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A,SAAA,EAAA,iCAAA,EAAA,IAAA,CAAA,CAAA;AAMDI,oBAAA,CAAA;AAAC,IAAAG,2CAAkB,CAACE,sCAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;;;8CAGpDT,4BAAkB,CAAA;AAsBpB,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,qCAAA,EAAA,IAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"tslib.es6.js","sources":["../../../../../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use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,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAClE,CAAC;AAKD;AACO,SAAS,UAAU,CAAC,WAAW,EAAE,aAAa,EAAE;AACvD,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,UAAU,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AACnI;;;;;"}
1
+ {"version":3,"file":"tslib.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -130,7 +130,7 @@ This software includes platform.js under the following license.
130
130
 
131
131
  Object.defineProperty(exports, '__esModule', { value: true });
132
132
 
133
- var version = "2.2.1-rc.0";
133
+ var version = "2.2.0";
134
134
 
135
135
  exports.version = version;
136
136
  //# sourceMappingURL=package.json.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"participant.js","sources":["../src/participant.ts"],"sourcesContent":["import { Users } from \"./data/users\";\nimport { User } from \"./user\";\nimport { parseTime, parseAttributes } from \"./util\";\nimport { Logger } from \"./logger\";\nimport { Conversation } from \"./conversation\";\nimport { attributesValidator } from \"./interfaces/attributes\";\nimport { validateTypesAsync } from \"@twilio/declarative-type-validator\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { EditParticipantRequest } from \"./interfaces/commands/edit-participant\";\nimport { ParticipantResponse } from \"./interfaces/commands/participant-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"./types\";\n\ntype ParticipantEvents = {\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n updated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope(\"Participant\");\n\ninterface ParticipantDescriptor {\n attributes?: JSONValue;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n identity: string;\n roleSid?: string;\n lastConsumedMessageIndex: number | null;\n lastConsumptionTimestamp: number | null;\n type: ParticipantType;\n userInfo?: string;\n bindings?: ParticipantBindings;\n}\n\ninterface ParticipantState {\n attributes: JSONValue;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n identity: string;\n isTyping: boolean;\n lastReadMessageIndex: number | null;\n lastReadTimestamp: Date | null;\n roleSid: string;\n sid: string;\n type: ParticipantType;\n typingTimeout: number | null;\n userInfo?: string;\n bindings?: ParticipantBindings;\n}\n\ninterface ParticipantServices {\n users: Users;\n commandExecutor: CommandExecutor;\n}\n\ninterface ParticipantLinks {\n self: string;\n}\n\n/**\n * The reason for the `updated` event being emitted by a participant.\n */\ntype ParticipantUpdateReason =\n | \"attributes\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"roleSid\"\n | \"lastReadMessageIndex\"\n | \"lastReadTimestamp\"\n | \"bindings\";\n\n/**\n * Type of a participant.\n */\ntype ParticipantType = \"chat\" | \"sms\" | \"whatsapp\" | \"email\";\n\ninterface ParticipantUpdatedEventArgs {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n}\n\n/**\n * Bindings for conversation participant.\n */\ninterface ParticipantBindings {\n email?: ParticipantEmailBinding;\n}\n\n/**\n * Email participation level.\n * to = to/from\n * cc = cc\n */\ntype ParticipantEmailLevel = \"to\" | \"cc\";\n\n/**\n * Bindings for email participant.\n */\ninterface ParticipantEmailBinding {\n name: string;\n address: string;\n level: ParticipantEmailLevel;\n}\n\n/**\n * A participant represents a remote client in a conversation.\n */\nclass Participant extends ReplayEventEmitter<ParticipantEvents> {\n private state: ParticipantState;\n private readonly links: ParticipantLinks;\n private readonly services: ParticipantServices;\n\n /**\n * Conversation that the remote client is a participant of.\n */\n public readonly conversation: Conversation;\n\n /**\n * The server-assigned unique identifier for the participant.\n */\n public get sid(): string {\n return this.state.sid;\n }\n\n /**\n * Custom attributes of the participant.\n */\n public get attributes(): JSONValue {\n return this.state.attributes;\n }\n\n /**\n * Date this participant was created on.\n */\n public get dateCreated(): Date | null {\n return this.state.dateCreated;\n }\n\n /**\n * Date this participant was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this.state.dateUpdated;\n }\n\n /**\n * Identity of the participant.\n */\n public get identity(): string | null {\n return this.state.identity;\n }\n\n /**\n * Indicates whether the participant is currently typing.\n */\n public get isTyping(): boolean {\n return this.state.isTyping;\n }\n\n /**\n * The index of the last read message by the participant.\n * Note that retrieving messages on a client endpoint does not mean that messages are read,\n * please consider reading about the [Read Horizon feature](https://www.twilio.com/docs/api/chat/guides/consumption-horizon)\n * to find out about the proper way to mark messages as read.\n */\n public get lastReadMessageIndex(): number | null {\n return this.state.lastReadMessageIndex;\n }\n\n /**\n * Date of the most recent read horizon update.\n */\n public get lastReadTimestamp(): Date | null {\n return this.state.lastReadTimestamp;\n }\n\n public get roleSid(): string {\n return this.state.roleSid;\n }\n\n /**\n * Type of the participant.\n */\n public get type(): ParticipantType {\n return this.state.type;\n }\n\n /**\n * Get the bindings mapping for the current participant.\n * Available binding depends on the participant type.\n * You could access it as `participant.bindings.sms?.address` or\n * using the type dynamically `participant.bindings[participant.type]`\n * just be aware that the binding information has different structure for\n * each participant type.\n * See also {ParticipantEmailBinding}, the only available currently binding descriptor.\n */\n public get bindings(): ParticipantBindings {\n return this.state.bindings ?? {};\n }\n\n /**\n * @internal\n */\n constructor(\n data: ParticipantDescriptor,\n sid: string,\n conversation: Conversation,\n links: ParticipantLinks,\n services: ParticipantServices\n ) {\n super();\n\n this.conversation = conversation;\n this.links = links;\n this.services = services;\n this.state = {\n attributes: parseAttributes(\n data.attributes,\n \"Retrieved malformed attributes from the server for participant: \" +\n sid,\n log\n ),\n dateCreated: data.dateCreated ? parseTime(data.dateCreated) : null,\n dateUpdated: data.dateCreated ? parseTime(data.dateUpdated) : null,\n sid: sid,\n typingTimeout: null,\n isTyping: false,\n identity: data.identity,\n roleSid: data.roleSid ?? \"\",\n lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex)\n ? data.lastConsumedMessageIndex\n : null,\n lastReadTimestamp: data.lastConsumptionTimestamp\n ? parseTime(data.lastConsumptionTimestamp)\n : null,\n type: data.type || \"chat\",\n userInfo: data.userInfo,\n bindings: data.bindings ?? {},\n };\n\n if (!data.identity && !data.type) {\n throw new Error(\n \"Received invalid Participant object from server: Missing identity or type of Participant.\"\n );\n }\n }\n\n /**\n * Fired when the participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when the fields of the participant have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Participant} participant - the participant in question\n * * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update\n * @event\n */\n static readonly updated = \"updated\";\n\n /**\n * Internal method used to start or reset the typing indicator timeout (with event emitting).\n * @internal\n */\n _startTyping(timeout) {\n if (this.state.typingTimeout) {\n clearTimeout(this.state.typingTimeout);\n }\n\n this.state.isTyping = true;\n this.emit(\"typingStarted\", this);\n\n this.conversation.emit(\"typingStarted\", this);\n\n this.state.typingTimeout = Number(\n setTimeout(() => this._endTyping(), timeout)\n );\n return this;\n }\n\n /**\n * Internal method function used to stop the typing indicator timeout (with event emitting).\n * @internal\n */\n _endTyping() {\n if (!this.state.typingTimeout) {\n return;\n }\n\n this.state.isTyping = false;\n this.emit(\"typingEnded\", this);\n\n this.conversation.emit(\"typingEnded\", this);\n\n clearInterval(this.state.typingTimeout);\n this.state.typingTimeout = null;\n }\n\n /**\n * Internal method function used update local object's property roleSid with a new value.\n * @internal\n */\n _update(data) {\n const updateReasons: ParticipantUpdateReason[] = [];\n\n const updateAttributes = parseAttributes(\n data.attributes,\n \"Retrieved malformed attributes from the server for participant: \" +\n this.state.sid,\n log\n );\n\n if (data.attributes && !isEqual(this.state.attributes, updateAttributes)) {\n this.state.attributes = updateAttributes;\n updateReasons.push(\"attributes\");\n }\n\n const updatedDateUpdated = parseTime(data.dateUpdated);\n if (\n data.dateUpdated &&\n updatedDateUpdated?.getTime() !==\n (this.state.dateUpdated && this.state.dateUpdated.getTime())\n ) {\n this.state.dateUpdated = updatedDateUpdated;\n updateReasons.push(\"dateUpdated\");\n }\n\n const updatedDateCreated = parseTime(data.dateCreated);\n if (\n data.dateCreated &&\n updatedDateCreated?.getTime() !==\n (this.state.dateCreated && this.state.dateCreated.getTime())\n ) {\n this.state.dateCreated = updatedDateCreated;\n updateReasons.push(\"dateCreated\");\n }\n\n if (data.roleSid && this.state.roleSid !== data.roleSid) {\n this.state.roleSid = data.roleSid;\n updateReasons.push(\"roleSid\");\n }\n\n if (\n (Number.isInteger(data.lastConsumedMessageIndex) ||\n data.lastConsumedMessageIndex === null) &&\n this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex\n ) {\n this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;\n updateReasons.push(\"lastReadMessageIndex\");\n }\n\n if (data.lastConsumptionTimestamp) {\n const lastReadTimestamp = new Date(data.lastConsumptionTimestamp);\n if (\n !this.state.lastReadTimestamp ||\n this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()\n ) {\n this.state.lastReadTimestamp = lastReadTimestamp;\n updateReasons.push(\"lastReadTimestamp\");\n }\n }\n\n if (data.bindings && !isEqual(this.state.bindings, data.bindings)) {\n this.state.bindings = data.bindings;\n updateReasons.push(\"bindings\");\n }\n\n if (updateReasons.length > 0) {\n this.emit(\"updated\", { participant: this, updateReasons: updateReasons });\n }\n\n return this;\n }\n\n /**\n * Get the user for this participant and subscribes to it. Supported only for participants of type `chat`.\n */\n async getUser(): Promise<User> {\n if (this.type != \"chat\") {\n throw new Error(\n \"Getting User is not supported for this Participant type: \" + this.type\n );\n }\n\n return this.services.users.getUser(\n this.state.identity,\n this.state.userInfo\n );\n }\n\n /**\n * Remove the participant from the conversation.\n */\n async remove() {\n return this.conversation.removeParticipant(this);\n }\n\n /**\n * Update the attributes of the participant.\n * @param attributes New attributes.\n */\n @validateTypesAsync(attributesValidator)\n async updateAttributes(attributes: JSONValue): Promise<Participant> {\n await this.services.commandExecutor.mutateResource<\n EditParticipantRequest,\n ParticipantResponse\n >(\"post\", this.links.self, {\n attributes: JSON.stringify(attributes),\n });\n\n return this;\n }\n}\n\nexport {\n ParticipantDescriptor,\n ParticipantServices,\n Participant,\n ParticipantUpdateReason,\n ParticipantType,\n ParticipantUpdatedEventArgs,\n ParticipantBindings,\n ParticipantEmailBinding,\n ParticipantEmailLevel,\n};\n"],"names":["Logger","ReplayEventEmitter","parseAttributes","parseTime","isEqual","__decorate","validateTypesAsync","attributesValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AAqFxC;;AAEG;AACH,MAAM,WAAY,SAAQC,qCAAqC,CAAA;AA6F7D;;AAEG;IACH,WACE,CAAA,IAA2B,EAC3B,GAAW,EACX,YAA0B,EAC1B,KAAuB,EACvB,QAA6B,EAAA;;AAE7B,QAAA,KAAK,EAAE,CAAC;AAER,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AACjC,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACnB,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAA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,MAAM,IAAI,KAAK,CACb,2DAA2D,GAAG,IAAI,CAAC,IAAI,CACxE,CAAC;AACH,SAAA;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAChC,IAAI,CAAC,KAAK,CAAC,QAAQ,EACnB,IAAI,CAAC,KAAK,CAAC,QAAQ,CACpB,CAAC;KACH;AAED;;AAEG;AACH,IAAA,MAAM,MAAM,GAAA;QACV,OAAO,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;KAClD;AAED;;;AAGG;IAEH,MAAM,gBAAgB,CAAC,UAAqB,EAAA;AAC1C,QAAA,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAGhD,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;AACzB,YAAA,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;AACvC,SAAA,CAAC,CAAC;AAEH,QAAA,OAAO,IAAI,CAAC;KACb;;AApLD;;;;;;AAMG;AACa,WAAa,CAAA,aAAA,GAAG,eAAe,CAAC;AAEhD;;;;;;AAMG;AACa,WAAW,CAAA,WAAA,GAAG,aAAa,CAAC;AAE5C;;;;;;;;AAQG;AACa,WAAO,CAAA,OAAA,GAAG,SAAS,CAAC;AAgJpCC,oBAAA,CAAA;IADCC,2CAAkB,CAACC,8BAAmB,CAAC;;;;AAUvC,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"participant.js","sources":["../src/participant.ts"],"sourcesContent":["import { Users } from \"./data/users\";\nimport { User } from \"./user\";\nimport { parseTime, parseAttributes } from \"./util\";\nimport { Logger } from \"./logger\";\nimport { Conversation } from \"./conversation\";\nimport { attributesValidator } from \"./interfaces/attributes\";\nimport { validateTypesAsync } from \"@twilio/declarative-type-validator\";\nimport { CommandExecutor } from \"./command-executor\";\nimport { EditParticipantRequest } from \"./interfaces/commands/edit-participant\";\nimport { ParticipantResponse } from \"./interfaces/commands/participant-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"@twilio/shared\";\n\ntype ParticipantEvents = {\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n updated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope(\"Participant\");\n\ninterface ParticipantDescriptor {\n attributes?: JSONValue;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n identity: string;\n roleSid?: string;\n lastConsumedMessageIndex: number | null;\n lastConsumptionTimestamp: number | null;\n type: ParticipantType;\n userInfo?: string;\n bindings?: ParticipantBindings;\n}\n\ninterface ParticipantState {\n attributes: JSONValue;\n dateCreated: Date | null;\n dateUpdated: Date | null;\n identity: string;\n isTyping: boolean;\n lastReadMessageIndex: number | null;\n lastReadTimestamp: Date | null;\n roleSid: string;\n sid: string;\n type: ParticipantType;\n typingTimeout: number | null;\n userInfo?: string;\n bindings?: ParticipantBindings;\n}\n\ninterface ParticipantServices {\n users: Users;\n commandExecutor: CommandExecutor;\n}\n\ninterface ParticipantLinks {\n self: string;\n}\n\n/**\n * The reason for the `updated` event being emitted by a participant.\n */\ntype ParticipantUpdateReason =\n | \"attributes\"\n | \"dateCreated\"\n | \"dateUpdated\"\n | \"roleSid\"\n | \"lastReadMessageIndex\"\n | \"lastReadTimestamp\"\n | \"bindings\";\n\n/**\n * Type of a participant.\n */\ntype ParticipantType = \"chat\" | \"sms\" | \"whatsapp\" | \"email\";\n\ninterface ParticipantUpdatedEventArgs {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n}\n\n/**\n * Bindings for conversation participant.\n */\ninterface ParticipantBindings {\n email?: ParticipantEmailBinding;\n}\n\n/**\n * Email participation level.\n * to = to/from\n * cc = cc\n */\ntype ParticipantEmailLevel = \"to\" | \"cc\";\n\n/**\n * Bindings for email participant.\n */\ninterface ParticipantEmailBinding {\n name: string;\n address: string;\n level: ParticipantEmailLevel;\n}\n\n/**\n * A participant represents a remote client in a conversation.\n */\nclass Participant extends ReplayEventEmitter<ParticipantEvents> {\n private state: ParticipantState;\n private readonly links: ParticipantLinks;\n private readonly services: ParticipantServices;\n\n /**\n * Conversation that the remote client is a participant of.\n */\n public readonly conversation: Conversation;\n\n /**\n * The server-assigned unique identifier for the participant.\n */\n public get sid(): string {\n return this.state.sid;\n }\n\n /**\n * Custom attributes of the participant.\n */\n public get attributes(): JSONValue {\n return this.state.attributes;\n }\n\n /**\n * Date this participant was created on.\n */\n public get dateCreated(): Date | null {\n return this.state.dateCreated;\n }\n\n /**\n * Date this participant was last updated on.\n */\n public get dateUpdated(): Date | null {\n return this.state.dateUpdated;\n }\n\n /**\n * Identity of the participant.\n */\n public get identity(): string | null {\n return this.state.identity;\n }\n\n /**\n * Indicates whether the participant is currently typing.\n */\n public get isTyping(): boolean {\n return this.state.isTyping;\n }\n\n /**\n * The index of the last read message by the participant.\n * Note that retrieving messages on a client endpoint does not mean that messages are read,\n * please consider reading about the [Read Horizon feature](https://www.twilio.com/docs/api/chat/guides/consumption-horizon)\n * to find out about the proper way to mark messages as read.\n */\n public get lastReadMessageIndex(): number | null {\n return this.state.lastReadMessageIndex;\n }\n\n /**\n * Date of the most recent read horizon update.\n */\n public get lastReadTimestamp(): Date | null {\n return this.state.lastReadTimestamp;\n }\n\n public get roleSid(): string {\n return this.state.roleSid;\n }\n\n /**\n * Type of the participant.\n */\n public get type(): ParticipantType {\n return this.state.type;\n }\n\n /**\n * Get the bindings mapping for the current participant.\n * Available binding depends on the participant type.\n * You could access it as `participant.bindings.sms?.address` or\n * using the type dynamically `participant.bindings[participant.type]`\n * just be aware that the binding information has different structure for\n * each participant type.\n * See also {ParticipantEmailBinding}, the only available currently binding descriptor.\n */\n public get bindings(): ParticipantBindings {\n return this.state.bindings ?? {};\n }\n\n /**\n * @internal\n */\n constructor(\n data: ParticipantDescriptor,\n sid: string,\n conversation: Conversation,\n links: ParticipantLinks,\n services: ParticipantServices\n ) {\n super();\n\n this.conversation = conversation;\n this.links = links;\n this.services = services;\n this.state = {\n attributes: parseAttributes(\n data.attributes,\n \"Retrieved malformed attributes from the server for participant: \" +\n sid,\n log\n ),\n dateCreated: data.dateCreated ? parseTime(data.dateCreated) : null,\n dateUpdated: data.dateCreated ? parseTime(data.dateUpdated) : null,\n sid: sid,\n typingTimeout: null,\n isTyping: false,\n identity: data.identity,\n roleSid: data.roleSid ?? \"\",\n lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex)\n ? data.lastConsumedMessageIndex\n : null,\n lastReadTimestamp: data.lastConsumptionTimestamp\n ? parseTime(data.lastConsumptionTimestamp)\n : null,\n type: data.type || \"chat\",\n userInfo: data.userInfo,\n bindings: data.bindings ?? {},\n };\n\n if (!data.identity && !data.type) {\n throw new Error(\n \"Received invalid Participant object from server: Missing identity or type of Participant.\"\n );\n }\n }\n\n /**\n * Fired when the participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingStarted = \"typingStarted\";\n\n /**\n * Fired when the participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingEnded = \"typingEnded\";\n\n /**\n * Fired when the fields of the participant have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Participant} participant - the participant in question\n * * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update\n * @event\n */\n static readonly updated = \"updated\";\n\n /**\n * Internal method used to start or reset the typing indicator timeout (with event emitting).\n * @internal\n */\n _startTyping(timeout) {\n if (this.state.typingTimeout) {\n clearTimeout(this.state.typingTimeout);\n }\n\n this.state.isTyping = true;\n this.emit(\"typingStarted\", this);\n\n this.conversation.emit(\"typingStarted\", this);\n\n this.state.typingTimeout = Number(\n setTimeout(() => this._endTyping(), timeout)\n );\n return this;\n }\n\n /**\n * Internal method function used to stop the typing indicator timeout (with event emitting).\n * @internal\n */\n _endTyping() {\n if (!this.state.typingTimeout) {\n return;\n }\n\n this.state.isTyping = false;\n this.emit(\"typingEnded\", this);\n\n this.conversation.emit(\"typingEnded\", this);\n\n clearInterval(this.state.typingTimeout);\n this.state.typingTimeout = null;\n }\n\n /**\n * Internal method function used update local object's property roleSid with a new value.\n * @internal\n */\n _update(data) {\n const updateReasons: ParticipantUpdateReason[] = [];\n\n const updateAttributes = parseAttributes(\n data.attributes,\n \"Retrieved malformed attributes from the server for participant: \" +\n this.state.sid,\n log\n );\n\n if (data.attributes && !isEqual(this.state.attributes, updateAttributes)) {\n this.state.attributes = updateAttributes;\n updateReasons.push(\"attributes\");\n }\n\n const updatedDateUpdated = parseTime(data.dateUpdated);\n if (\n data.dateUpdated &&\n updatedDateUpdated?.getTime() !==\n (this.state.dateUpdated && this.state.dateUpdated.getTime())\n ) {\n this.state.dateUpdated = updatedDateUpdated;\n updateReasons.push(\"dateUpdated\");\n }\n\n const updatedDateCreated = parseTime(data.dateCreated);\n if (\n data.dateCreated &&\n updatedDateCreated?.getTime() !==\n (this.state.dateCreated && this.state.dateCreated.getTime())\n ) {\n this.state.dateCreated = updatedDateCreated;\n updateReasons.push(\"dateCreated\");\n }\n\n if (data.roleSid && this.state.roleSid !== data.roleSid) {\n this.state.roleSid = data.roleSid;\n updateReasons.push(\"roleSid\");\n }\n\n if (\n (Number.isInteger(data.lastConsumedMessageIndex) ||\n data.lastConsumedMessageIndex === null) &&\n this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex\n ) {\n this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;\n updateReasons.push(\"lastReadMessageIndex\");\n }\n\n if (data.lastConsumptionTimestamp) {\n const lastReadTimestamp = new Date(data.lastConsumptionTimestamp);\n if (\n !this.state.lastReadTimestamp ||\n this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()\n ) {\n this.state.lastReadTimestamp = lastReadTimestamp;\n updateReasons.push(\"lastReadTimestamp\");\n }\n }\n\n if (data.bindings && !isEqual(this.state.bindings, data.bindings)) {\n this.state.bindings = data.bindings;\n updateReasons.push(\"bindings\");\n }\n\n if (updateReasons.length > 0) {\n this.emit(\"updated\", { participant: this, updateReasons: updateReasons });\n }\n\n return this;\n }\n\n /**\n * Get the user for this participant and subscribes to it. Supported only for participants of type `chat`.\n */\n async getUser(): Promise<User> {\n if (this.type != \"chat\") {\n throw new Error(\n \"Getting User is not supported for this Participant type: \" + this.type\n );\n }\n\n return this.services.users.getUser(\n this.state.identity,\n this.state.userInfo\n );\n }\n\n /**\n * Remove the participant from the conversation.\n */\n async remove() {\n return this.conversation.removeParticipant(this);\n }\n\n /**\n * Update the attributes of the participant.\n * @param attributes New attributes.\n */\n @validateTypesAsync(attributesValidator)\n async updateAttributes(attributes: JSONValue): Promise<Participant> {\n await this.services.commandExecutor.mutateResource<\n EditParticipantRequest,\n ParticipantResponse\n >(\"post\", this.links.self, {\n attributes: JSON.stringify(attributes),\n });\n\n return this;\n }\n}\n\nexport {\n ParticipantDescriptor,\n ParticipantServices,\n Participant,\n ParticipantUpdateReason,\n ParticipantType,\n ParticipantUpdatedEventArgs,\n ParticipantBindings,\n ParticipantEmailBinding,\n ParticipantEmailLevel,\n};\n"],"names":["Logger","ReplayEventEmitter","parseAttributes","parseTime","isEqual","__decorate","validateTypesAsync","attributesValidator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AAqFxC;;AAEG;AACH,MAAM,WAAY,SAAQC,qCAAqC,CAAA;AA6F7D;;AAEG;IACH,WACE,CAAA,IAA2B,EAC3B,GAAW,EACX,YAA0B,EAC1B,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henThrottled = false) {
162
162
  return new Promise((resolve, reject) => {
163
- const codesToRetryOn = [502, 503, 504];
164
- if (retryWhenThrottled) {
165
- codesToRetryOn.push(429);
166
- }
167
163
  const retrier = new operationRetrier.Retrier(this.configuration.backoffConfiguration);
168
164
  retrier.on("attempt", () => {
169
165
  request()
170
- .then((result) => retrier.succeeded(result))
171
- .catch((err) => {
172
- if (codesToRetryOn.indexOf(err.status) > -1) {
173
- retrier.failed(err);
166
+ .then((result) => {
167
+ const isError = result.statusCode >= 400 && result.statusCode < 500;
168
+ if (!isError) {
169
+ retrier.succeeded(result);
170
+ return;
174
171
  }
175
- else if (err.message === "Twilsock disconnected") {
172
+ const parsedPayload = JSON.parse(result.payload);
173
+ retrier.failed(new Error(`${parsedPayload.message}`));
174
+ /*
175
+ const isError = result.statusCode >= 400 && result.statusCode < 500;
176
+ if (isError) {
177
+ const parsedPayload = JSON.parse(result.payload);
178
+ if (codesToRetryOn.includes(parsedPayload.status)) {
179
+ let delayOverride = parseInt(result.headers ? result.headers['Retry-After'] : null);
180
+ retrier.failed(mapTransportError(result, parsedPayload),
181
+ isNaN(delayOverride) ? null : delayOverride * 1000);
182
+ } else if (parsedPayload.message === 'Twilsock disconnected') {
176
183
  // Ugly hack. We must make a proper exceptions for twilsock
177
- retrier.failed(err);
178
- }
179
- else {
184
+ retrier.failed(mapTransportError(result, parsedPayload));
185
+ } else {
180
186
  // Fatal error
181
187
  retrier.removeAllListeners();
182
188
  retrier.cancel();
183
- reject(err);
189
+ reject(mapTransportError(result, parsedPayload));
190
+ }
184
191
  }
192
+ */
193
+ })
194
+ .catch((err) => {
195
+ // if (codesToRetryOn.indexOf(err.status) > -1) {
196
+ // retrier.failed(err);
197
+ // } else if (err.message === "Twilsock disconnected") {
198
+ // // Ugly hack. We must make a proper exceptions for twilsock
199
+ // retrier.failed(err);
200
+ // } else {
201
+ // Fatal error
202
+ retrier.removeAllListeners();
203
+ retrier.cancel();
204
+ reject(err);
205
+ // }
185
206
  });
186
207
  });
187
208
  retrier.on("succeeded", (result) => {
@@ -197,8 +218,10 @@ class Network {
197
218
  if (cacheEntry && !this.isExpired(cacheEntry.timestamp)) {
198
219
  return cacheEntry.response;
199
220
  }
200
- const headers = {};
201
- const response = await this.executeWithRetry(() => this.services.transport.get(url, headers, this.configuration.productId), this.configuration.retryWhenThrottled);
221
+ const response = await this.executeWithRetry(() => this.services.transport.get({
222
+ url,
223
+ grant: this.configuration.productId,
224
+ }), this.configuration.retryWhenThrottled);
202
225
  this.cache.set(url, { response, timestamp: Date.now() });
203
226
  this.pokeTimer();
204
227
  return response;
@@ -1 +1 @@
1
- {"version":3,"file":"network.js","sources":["../../src/services/network.ts"],"sourcesContent":["import { Retrier } from \"@twilio/operation-retrier\";\nimport { Transport, TransportResult } from \"twilsock\";\nimport { Configuration } from \"../configuration\";\n\nimport Timeout = NodeJS.Timeout;\n\ninterface CacheEntry {\n response: TransportResult<unknown>;\n timestamp: number;\n}\n\nexport interface NetworkServices {\n transport: Transport;\n}\n\nclass Network {\n private readonly configuration: Configuration;\n private readonly services: NetworkServices;\n private cacheLifetime: number;\n\n private readonly cache: Map<string, CacheEntry>;\n private timer!: number | NodeJS.Timeout;\n\n constructor(configuration, services) {\n this.configuration = configuration;\n this.services = services;\n this.cache = new Map<string, CacheEntry>();\n this.cacheLifetime = this.configuration.httpCacheInterval * 100;\n this.cleanupCache();\n }\n\n private isExpired(timestamp: number): boolean {\n return !this.cacheLifetime || Date.now() - timestamp > this.cacheLifetime;\n }\n\n private cleanupCache() {\n for (const [k, v] of this.cache) {\n if (this.isExpired(v.timestamp)) {\n this.cache.delete(k);\n }\n }\n\n if (this.cache.size === 0) {\n clearInterval(this.timer as Timeout);\n }\n }\n\n pokeTimer() {\n this.timer =\n this.timer ||\n setInterval(() => this.cleanupCache(), this.cacheLifetime * 2);\n }\n\n private executeWithRetry<T>(\n request,\n retryWhenThrottled = false\n ): Promise<TransportResult<T>> {\n return new Promise((resolve, reject) => {\n const codesToRetryOn = [502, 503, 504];\n if (retryWhenThrottled) {\n codesToRetryOn.push(429);\n }\n\n const retrier = new Retrier(this.configuration.backoffConfiguration);\n retrier.on(\"attempt\", () => {\n request()\n .then((result) => retrier.succeeded(result))\n .catch((err) => {\n if (codesToRetryOn.indexOf(err.status) > -1) {\n retrier.failed(err);\n } else if (err.message === \"Twilsock disconnected\") {\n // Ugly hack. We must make a proper exceptions for twilsock\n retrier.failed(err);\n } else {\n // Fatal error\n retrier.removeAllListeners();\n retrier.cancel();\n reject(err);\n }\n });\n });\n\n retrier.on(\"succeeded\", (result) => {\n resolve(result);\n });\n retrier.on(\"cancelled\", (err) => reject(err));\n retrier.on(\"failed\", (err) => reject(err));\n\n retrier.start();\n });\n }\n\n async get<T>(url: string): Promise<TransportResult<T>> {\n const cacheEntry = this.cache.get(url);\n if (cacheEntry && !this.isExpired(cacheEntry.timestamp)) {\n return cacheEntry.response as TransportResult<T>;\n }\n\n const headers = {};\n const response = await this.executeWithRetry<T>(\n () =>\n this.services.transport.get<T>(\n url,\n headers,\n this.configuration.productId\n ),\n this.configuration.retryWhenThrottled\n );\n this.cache.set(url, { response, timestamp: Date.now() });\n this.pokeTimer();\n return response;\n }\n}\n\nexport { Network };\n"],"names":["Retrier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,OAAO,CAAA;IAQX,WAAY,CAAA,aAAa,EAAE,QAAQ,EAAA;AACjC,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,iBAAiB,GAAG,G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AC,QAA8B,CAAC;AAClD,SAAA;QAED,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,QAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAC1C,MACE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CACzB,GAAG,EACH,OAAO,EACP,IAAI,CAAC,aAAa,CAAC,SAAS,CAC7B,EACH,IAAI,CAAC,aAAa,CAAC,kBAAkB,CACtC,CAAC;AACF,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,EAAE,CAAC;AACjB,QAAA,OAAO,QAAQ,CAAC;KACjB;AACF;;;;"}
1
+ {"version":3,"file":"network.js","sources":["../../src/services/network.ts"],"sourcesContent":["import { Retrier } from \"@twilio/operation-retrier\";\nimport { TwilsockClient, HttpResponse } from \"twilsock\";\nimport { Configuration } from \"../configuration\";\n\nimport Timeout = NodeJS.Timeout;\n\ninterface CacheEntry {\n response: HttpResponse;\n timestamp: number;\n}\n\nexport interface NetworkServices {\n transport: TwilsockClient;\n}\n\nclass Network {\n private readonly configuration: Configuration;\n private readonly services: NetworkServices;\n private cacheLifetime: number;\n\n private readonly cache: Map<string, CacheEntry>;\n private timer!: number | NodeJS.Timeout;\n\n constructor(configuration, services) {\n this.configuration = configuration;\n this.services = services;\n this.cache = new Map<string, CacheEntry>();\n this.cacheLifetime = this.configuration.httpCacheInterval * 100;\n this.cleanupCache();\n }\n\n private isExpired(timestamp: number): boolean {\n return !this.cacheLifetime || Date.now() - timestamp > this.cacheLifetime;\n }\n\n private cleanupCache() {\n for (const [k, v] of this.cache) {\n if (this.isExpired(v.timestamp)) {\n this.cache.delete(k);\n }\n }\n\n if (this.cache.size === 0) {\n clearInterval(this.timer as Timeout);\n }\n }\n\n pokeTimer() {\n this.timer =\n this.timer ||\n setInterval(() => this.cleanupCache(), this.cacheLifetime * 2);\n }\n\n private executeWithRetry<T>(\n request,\n retryWhenThrottled = false\n ): Promise<HttpResponse> {\n return new Promise((resolve, reject) => {\n const codesToRetryOn = [502, 503, 504];\n if (retryWhenThrottled) {\n codesToRetryOn.push(429);\n }\n\n const retrier = new Retrier(this.configuration.backoffConfiguration);\n retrier.on(\"attempt\", () => {\n request()\n .then((result) => {\n const isError = result.statusCode >= 400 && result.statusCode < 500;\n if (!isError) {\n retrier.succeeded(result);\n return;\n }\n\n const parsedPayload = JSON.parse(result.payload);\n retrier.failed(new Error(`${parsedPayload.message}`));\n /*\n const isError = result.statusCode >= 400 && result.statusCode < 500;\n if (isError) {\n const parsedPayload = JSON.parse(result.payload);\n if (codesToRetryOn.includes(parsedPayload.status)) {\n let delayOverride = parseInt(result.headers ? result.headers['Retry-After'] : null);\n retrier.failed(mapTransportError(result, parsedPayload),\n isNaN(delayOverride) ? null : delayOverride * 1000);\n } else if (parsedPayload.message === 'Twilsock disconnected') {\n // Ugly hack. We must make a proper exceptions for twilsock\n retrier.failed(mapTransportError(result, parsedPayload));\n } else {\n // Fatal error\n retrier.removeAllListeners();\n retrier.cancel();\n reject(mapTransportError(result, parsedPayload));\n }\n }\n */\n })\n .catch((err) => {\n // if (codesToRetryOn.indexOf(err.status) > -1) {\n // retrier.failed(err);\n // } else if (err.message === \"Twilsock disconnected\") {\n // // Ugly hack. We must make a proper exceptions for twilsock\n // retrier.failed(err);\n // } else {\n // Fatal error\n retrier.removeAllListeners();\n retrier.cancel();\n reject(err);\n // }\n });\n });\n\n retrier.on(\"succeeded\", (result) => {\n resolve(result);\n });\n retrier.on(\"cancelled\", (err) => reject(err));\n retrier.on(\"failed\", (err) => reject(err));\n\n retrier.start();\n });\n }\n\n async get<T>(url: string): Promise<HttpResponse> {\n const cacheEntry = this.cache.get(url);\n if (cacheEntry && !this.isExpired(cacheEntry.timestamp)) {\n return cacheEntry.response;\n }\n\n const response = await this.executeWithRetry<T>(\n () =>\n this.services.transport.get({\n url,\n grant: this.configuration.productId,\n }),\n this.configuration.retryWhenThrottled\n );\n this.cache.set(url, { response, timestamp: Date.now() });\n this.pokeTimer();\n return response;\n }\n}\n\nexport { Network };\n"],"names":["Retrier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,OAAO,CAAA;IAQX,WAAY,CAAA,aAAa,EAAE,QAAQ,EAAA;AACjC,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,iBAAiB,GAAG,GAAG,CAAC;QAChE,IAAI,CAAC,YAAY,EAAE,CAAC;KACrB;AAEO,IAAA,SAAS,CAAC,SAAiB,EAAA;AACjC,QAAA,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC;KAC3E;IAEO,YAAY,GAAA;QAClB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;YAC/B,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;AAC/B,gBAAA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,aAAA;AACF,SAAA;AAED,QAAA,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE;AACzB,YAAA,aAAa,CAAC,IAAI,CAAC,KAAgB,CAAC,CAAC;AACtC,SAAA;KACF;IAED,SAAS,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C,MAAM,KAAI;gBACjC,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,aAAC,CAAC,CAAC;AACH,YAAA,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9C,YAAA,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAE3C,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,SAAC,CAAC,CAAC;KACJ;IAED,MAAM,GAAG,CAAI,GAAW,EAAA;QACtB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,UAAU,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YACvD,OAAO,UAAU,CAAC,QAAQ,CAAC;AAC5B,SAAA;AAED,QAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAC1C,MACE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC;YAC1B,GAAG;AACH,YAAA,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS;AACpC,SAAA,CAAC,EACJ,IAAI,CAAC,aAAa,CAAC,kBAAkB,CACtC,CAAC;AACF,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,EAAE,CAAC;AACjB,QAAA,OAAO,QAAQ,CAAC;KACjB;AACF;;;;"}
@@ -220,17 +220,19 @@ class TypingIndicator {
220
220
  "Content-Type": "application/x-www-form-urlencoded",
221
221
  };
222
222
  const body = `ChannelSid=${conversationSid}`;
223
- return this.services.twilsockClient
224
- .post(url, headers, body, this.configuration.productId)
223
+ return (this.services.twilsockClient
224
+ .post({ url, headers, body, grant: this.configuration.productId })
225
+ // todo: remove any after the release of new Twilsock
225
226
  .then((response) => {
226
- if (response.body.hasOwnProperty("typing_timeout")) {
227
- this.serviceTypingTimeout = response.body.typing_timeout * 1000;
227
+ const body = JSON.parse(response.payload);
228
+ if (body.hasOwnProperty("typing_timeout")) {
229
+ this.serviceTypingTimeout = body.typing_timeout * 1000;
228
230
  }
229
231
  })
230
232
  .catch((err) => {
231
233
  log.error("Failed to send typing indicator:", err);
232
234
  throw err;
233
- });
235
+ }));
234
236
  }
235
237
  }
236
238
 
@@ -1 +1 @@
1
- {"version":3,"file":"typing-indicator.js","sources":["../../src/services/typing-indicator.ts"],"sourcesContent":["import { Logger } from \"../logger\";\n\nimport { Notifications } from \"@twilio/notifications\";\n\nimport { NotificationTypes } from \"../interfaces/notification-types\";\nimport { TwilsockClient } from \"twilsock\";\nimport { Configuration } from \"../configuration\";\nimport { Conversation } from \"../conversation\";\n\nconst log = Logger.scope(\"TypingIndicator\");\n\nexport interface TypingIndicatorServices {\n twilsockClient: TwilsockClient;\n notificationClient: Notifications;\n}\n\n/**\n * An important note in regards to typing timeout timers. There are two places that the SDK can get the \"typing_timeout\" attribute from. The first\n * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the\n * \"typing_timeout\" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a\n * notification of type \"twilio.ipmsg.typing_indicator\". In this case, the \"typing_timeout\" value will be +1 of that in the console. This\n * intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,\n * the timeout returned from the notification should be used as the timeout for the \"typingEnded\" event, +1 is to account for latency.\n *\n * @private\n */\n\n/**\n * @class TypingIndicator\n *\n * @constructor\n * @private\n */\nclass TypingIndicator {\n private readonly services: TypingIndicatorServices;\n private readonly configuration: Configuration;\n\n private sentUpdates: Map<string, number>;\n private getConversation: (conversationSid: string) => Promise<Conversation>;\n private serviceTypingTimeout;\n\n constructor(\n getConversation: (conversationSid: string) => Promise<Conversation>,\n config: Configuration,\n services: TypingIndicatorServices\n ) {\n this.configuration = config;\n this.services = services;\n this.getConversation = getConversation;\n\n this.serviceTypingTimeout = null;\n this.sentUpdates = new Map();\n }\n\n public get typingTimeout(): number {\n return (\n this.configuration.typingIndicatorTimeoutOverride ||\n this.serviceTypingTimeout ||\n this.configuration.typingIndicatorTimeoutDefault\n );\n }\n\n /**\n * Initialize TypingIndicator controller\n * Registers for needed message types and sets listeners\n * @private\n */\n initialize(): void {\n // this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');\n this.services.notificationClient.on(\"message\", async (type, message) => {\n if (type === NotificationTypes.TYPING_INDICATOR) {\n await this._handleRemoteTyping(message);\n }\n });\n }\n\n /**\n * Remote participants typing events handler\n */\n private async _handleRemoteTyping(message) {\n log.trace(\"Got new typing indicator \", message);\n\n this.getConversation(message.channel_sid)\n .then((conversation) => {\n if (!conversation) {\n return;\n }\n\n conversation._participants.forEach((participant) => {\n if (participant.identity !== message.identity) {\n return;\n }\n\n const timeout = this.configuration.typingIndicatorTimeoutOverride\n ? this.configuration.typingIndicatorTimeoutOverride + 1000\n : message.typing_timeout * 1000;\n participant._startTyping(timeout);\n });\n })\n .catch((err) => {\n log.error(err);\n throw err;\n });\n }\n\n /**\n * Send typing event for the given conversation sid\n * @param {String} conversationSid\n */\n send(conversationSid: string) {\n const lastUpdate = this.sentUpdates.get(conversationSid);\n if (lastUpdate && lastUpdate > Date.now() - this.typingTimeout) {\n return Promise.resolve();\n }\n\n this.sentUpdates.set(conversationSid, Date.now());\n return this._send(conversationSid);\n }\n\n private _send(conversationSid: string) {\n log.trace(\"Sending typing indicator\");\n\n const url = this.configuration.links.typing;\n const headers = {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n };\n const body = `ChannelSid=${conversationSid}`;\n\n return this.services.twilsockClient\n .post<{ typing_timeout: number }>(\n url,\n headers,\n body,\n this.configuration.productId\n )\n .then((response) => {\n if (response.body.hasOwnProperty(\"typing_timeout\")) {\n this.serviceTypingTimeout = response.body.typing_timeout * 1000;\n }\n })\n .catch((err) => {\n log.error(\"Failed to send typing indicator:\", err);\n throw err;\n });\n }\n}\n\nexport { TypingIndicator };\n"],"names":["Logger","NotificationTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAO5C;;;;;;;;;AASG;AAEH;;;;;AAKG;AACH,MAAM,eAAe,CAAA;AAQnB,IAAA,WAAA,CACE,eAAmE,EACnE,MAAqB,EACrB,QAAiC,EAAA;AAEjC,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;AAC5B,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;AAEvC,QAAA,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;AACjC,QAAA,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;KAC9B;AAED,IAAA,IAAW,aAAa,GAAA;AACtB,QAAA,QACE,IAAI,CAAC,aAAa,CAAC,8BAA8B;AACjD,YAAA,IAAI,CAAC,oBAAoB;AACzB,YAAA,IAAI,CAAC,aAAa,CAAC,6BAA6B,EAChD;KACH;AAED;;;;AAIG;IACH,UAAU,GAAA;;AAER,QAAA,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,IAAI,EAAE,OAAO,KAAI;AACrE,YAAA,IAAI,IAAI,KAAKC,mCAAiB,CAAC,gBAAgB,EAAE;AAC/C,gBAAA,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AACz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E,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AAClD,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;KACpC;AAEO,IAAA,KAAK,CAAC,eAAuB,EAAA;AACnC,QAAA,GAAG,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAEtC,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;AAC5C,QAAA,MAAM,OAAO,GAAG;AACd,YAAA,cAAc,EAAE,mCAAmC;SACpD,CAAC;AACF,QAAA,MAAM,IAAI,GAAG,CAAc,WAAA,EAAA,eAAe,EAAE,CAAC;AAE7C,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc;AAChC,aAAA,IAAI,CACH,GAAG,EACH,OAAO,EACP,IAAI,EACJ,IAAI,CAAC,aAAa,CAAC,SAAS,CAC7B;AACA,aAAA,IAAI,CAAC,CAAC,QAAQ,KAAI;YACjB,IAAI,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE;gBAClD,IAAI,CAAC,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;AACjE,aAAA;AACH,SAAC,CAAC;AACD,aAAA,KAAK,CAAC,CAAC,GAAG,KAAI;AACb,YAAA,GAAG,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;AACnD,YAAA,MAAM,GAAG,CAAC;AACZ,SAAC,CAAC,CAAC;KACN;AACF;;;;"}
1
+ {"version":3,"file":"typing-indicator.js","sources":["../../src/services/typing-indicator.ts"],"sourcesContent":["import { Logger } from \"../logger\";\n\nimport { Notifications } from \"@twilio/notifications\";\n\nimport { NotificationTypes } from \"../interfaces/notification-types\";\nimport { TwilsockClient } from \"twilsock\";\nimport { Configuration } from \"../configuration\";\nimport { Conversation } from \"../conversation\";\n\nconst log = Logger.scope(\"TypingIndicator\");\n\nexport interface TypingIndicatorServices {\n twilsockClient: TwilsockClient;\n notificationClient: Notifications;\n}\n\n/**\n * An important note in regards to typing timeout timers. There are two places that the SDK can get the \"typing_timeout\" attribute from. The first\n * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the\n * \"typing_timeout\" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a\n * notification of type \"twilio.ipmsg.typing_indicator\". In this case, the \"typing_timeout\" value will be +1 of that in the console. This\n * intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,\n * the timeout returned from the notification should be used as the timeout for the \"typingEnded\" event, +1 is to account for latency.\n *\n * @private\n */\n\n/**\n * @class TypingIndicator\n *\n * @constructor\n * @private\n */\nclass TypingIndicator {\n private readonly services: TypingIndicatorServices;\n private readonly configuration: Configuration;\n\n private sentUpdates: Map<string, number>;\n private getConversation: (conversationSid: string) => Promise<Conversation>;\n private serviceTypingTimeout;\n\n constructor(\n getConversation: (conversationSid: string) => Promise<Conversation>,\n config: Configuration,\n services: TypingIndicatorServices\n ) {\n this.configuration = config;\n this.services = services;\n this.getConversation = getConversation;\n\n this.serviceTypingTimeout = null;\n this.sentUpdates = new Map();\n }\n\n public get typingTimeout(): number {\n return (\n this.configuration.typingIndicatorTimeoutOverride ||\n this.serviceTypingTimeout ||\n this.configuration.typingIndicatorTimeoutDefault\n );\n }\n\n /**\n * Initialize TypingIndicator controller\n * Registers for needed message types and sets listeners\n * @private\n */\n initialize(): void {\n // this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');\n this.services.notificationClient.on(\"message\", async (type, message) => {\n if (type === NotificationTypes.TYPING_INDICATOR) {\n await this._handleRemoteTyping(message);\n }\n });\n }\n\n /**\n * Remote participants typing events handler\n */\n private async _handleRemoteTyping(message) {\n log.trace(\"Got new typing indicator \", message);\n\n this.getConversation(message.channel_sid)\n .then((conversation) => {\n if (!conversation) {\n return;\n }\n\n conversation._participants.forEach((participant) => {\n if (participant.identity !== message.identity) {\n return;\n }\n\n const timeout = this.configuration.typingIndicatorTimeoutOverride\n ? this.configuration.typingIndicatorTimeoutOverride + 1000\n : message.typing_timeout * 1000;\n participant._startTyping(timeout);\n });\n })\n .catch((err) => {\n log.error(err);\n throw err;\n });\n }\n\n /**\n * Send typing event for the given conversation sid\n * @param {String} conversationSid\n */\n send(conversationSid: string) {\n const lastUpdate = this.sentUpdates.get(conversationSid);\n if (lastUpdate && lastUpdate > Date.now() - this.typingTimeout) {\n return Promise.resolve();\n }\n\n this.sentUpdates.set(conversationSid, Date.now());\n return this._send(conversationSid);\n }\n\n private _send(conversationSid: string) {\n log.trace(\"Sending typing indicator\");\n\n const url = this.configuration.links.typing;\n const headers = {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n };\n const body = `ChannelSid=${conversationSid}`;\n\n return (\n this.services.twilsockClient\n .post({ url, headers, body, grant: this.configuration.productId })\n // todo: remove any after the release of new Twilsock\n .then((response) => {\n const body = JSON.parse(response.payload);\n if (body.hasOwnProperty(\"typing_timeout\")) {\n this.serviceTypingTimeout = body.typing_timeout * 1000;\n }\n })\n .catch((err) => {\n log.error(\"Failed to send typing indicator:\", err);\n throw err;\n })\n );\n }\n}\n\nexport { TypingIndicator };\n"],"names":["Logger","NotificationTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAO5C;;;;;;;;;AASG;AAEH;;;;;AAKG;AACH,MAAM,eAAe,CAAA;AAQnB,IAAA,WAAA,CACE,eAAmE,EACnE,MAAqB,EACrB,QAAiC,EAAA;AAEjC,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;AAC5B,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ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I;YACjB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC1C,YAAA,IAAI,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE;gBACzC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;AACxD,aAAA;AACH,SAAC,CAAC;AACD,aAAA,KAAK,CAAC,CAAC,GAAG,KAAI;AACb,YAAA,GAAG,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;AACnD,YAAA,MAAM,GAAG,CAAC;SACX,CAAC,EACJ;KACH;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"unsent-message.js","sources":["../src/unsent-message.ts"],"sourcesContent":["import { MediaCategory, CancellablePromise } from \"@twilio/mcs-client\";\nimport { parseToNumber } from \"./util\";\nimport { SendEmailOptions, SendMediaOptions } from \"./conversation\";\nimport { JSONValue } from \"./types\";\nimport { Messages } from \"./data/messages\";\n\n/**\n * An unsent message. Returned from {@link MessageBuilder.build}.\n */\nclass UnsentMessage {\n public text?: string;\n public attributes: JSONValue = {};\n public mediaContent: [MediaCategory, FormData | SendMediaOptions][] = [];\n public emailOptions: SendEmailOptions = {};\n\n /**\n * @internal\n */\n constructor(private messagesEntity: Messages) {}\n\n /**\n * Send the prepared message to the conversation.\n * @returns Index of the new message in the conversation.\n */\n send(): CancellablePromise<number | null> {\n return new CancellablePromise(async (resolve, reject, onCancel) => {\n const request = this.messagesEntity.sendV2(this);\n onCancel(() => request.cancel());\n try {\n const response = await request;\n resolve(parseToNumber(response.index));\n } catch (e) {\n reject(e);\n }\n });\n }\n}\n\nexport { UnsentMessage };\n"],"names":["CancellablePromise","parseToNumber"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AAEG;AACH,MAAM,aAAa,CAAA;AAMjB;;AAEG;AACH,IAAA,WAAA,CAAoB,cAAwB,EAAA;QAAxB,IAAc,CAAA,cAAA,GAAd,cAAc,CAAU;QAPrC,IAAU,CAAA,UAAA,GAAc,EAAE,CAAC;QAC3B,IAAY,CAAA,YAAA,GAAmD,EAAE,CAAC;QAClE,IAAY,CAAA,YAAA,GAAqB,EAAE,CAAC;KAKK;AAEhD;;;AAGG;IACH,IAAI,GAAA;QACF,OAAO,IAAIA,4BAAkB,CAAC,OAAO,OAAO,EAAE,MAAM,EAAE,QAAQ,KAAI;YAChE,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjD,QAAQ,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACjC,IAAI;AACF,gBAAA,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC;gBAC/B,OAAO,CAACC,mBAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACxC,aAAA;AAAC,YAAA,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,CAAC,CAAC,CAAC;AACX,aAAA;AACH,SAAC,CAAC,CAAC;KACJ;AACF;;;;"}
1
+ {"version":3,"file":"unsent-message.js","sources":["../src/unsent-message.ts"],"sourcesContent":["import { MediaCategory, CancellablePromise } from \"@twilio/mcs-client\";\nimport { parseToNumber } from \"./util\";\nimport { SendEmailOptions, SendMediaOptions } from \"./conversation\";\nimport { JSONValue } from \"@twilio/shared\";\nimport { Messages } from \"./data/messages\";\n\n/**\n * An unsent message. Returned from {@link MessageBuilder.build}.\n */\nclass UnsentMessage {\n public text?: string;\n public attributes: JSONValue = {};\n public mediaContent: [MediaCategory, FormData | SendMediaOptions][] = [];\n public emailOptions: SendEmailOptions = {};\n\n /**\n * @internal\n */\n constructor(private messagesEntity: Messages) {}\n\n /**\n * Send the prepared message to the conversation.\n * @returns Index of the new message in the conversation.\n */\n send(): CancellablePromise<number | null> {\n return new CancellablePromise(async (resolve, reject, onCancel) => {\n const request = this.messagesEntity.sendV2(this);\n onCancel(() => request.cancel());\n try {\n const response = await request;\n resolve(parseToNumber(response.index));\n } catch (e) {\n reject(e);\n }\n });\n }\n}\n\nexport { UnsentMessage };\n"],"names":["CancellablePromise","parseToNumber"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AAEG;AACH,MAAM,aAAa,CAAA;AAMjB;;AAEG;AACH,IAAA,WAAA,CAAoB,cAAwB,EAAA;QAAxB,IAAc,CAAA,cAAA,GAAd,cAAc,CAAU;QAPrC,IAAU,CAAA,UAAA,GAAc,EAAE,CAAC;QAC3B,IAAY,CAAA,YAAA,GAAmD,EAAE,CAAC;QAClE,IAAY,CAAA,YAAA,GAAqB,EAAE,CAAC;KAKK;AAEhD;;;AAGG;IACH,IAAI,GAAA;QACF,OAAO,IAAIA,4BAAkB,CAAC,OAAO,OAAO,EAAE,MAAM,EAAE,QAAQ,KAAI;YAChE,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjD,QAAQ,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACjC,IAAI;AACF,gBAAA,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC;gBAC/B,OAAO,CAACC,mBAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACxC,aAAA;AAAC,YAAA,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,CAAC,CAAC,CAAC;AACX,aAAA;AACH,SAAC,CAAC,CAAC;KACJ;AACF;;;;"}