@twilio/conversations 3.0.0-rc.9 → 3.0.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +39 -29
  2. package/builds/browser.esm.js +10846 -0
  3. package/builds/browser.esm.js.map +1 -0
  4. package/builds/browser.js +2505 -479
  5. package/builds/browser.js.map +1 -1
  6. package/builds/lib.d.ts +805 -70
  7. package/builds/lib.esm.d.ts +3178 -0
  8. package/builds/lib.esm.js +10845 -0
  9. package/builds/lib.js +2505 -479
  10. package/builds/lib.js.map +1 -1
  11. package/builds/twilio-conversations.js +25853 -24412
  12. package/builds/twilio-conversations.js.map +1 -0
  13. package/builds/twilio-conversations.min.js +2 -1
  14. package/builds/twilio-conversations.min.js.map +1 -0
  15. package/dist/aggregated-delivery-receipt.js +10 -5
  16. package/dist/aggregated-delivery-receipt.js.map +1 -1
  17. package/dist/channel-metadata-client.js +187 -0
  18. package/dist/channel-metadata-client.js.map +1 -0
  19. package/dist/client.js +266 -192
  20. package/dist/client.js.map +1 -1
  21. package/dist/command-executor.js +53 -15
  22. package/dist/command-executor.js.map +1 -1
  23. package/dist/configuration.js +23 -12
  24. package/dist/configuration.js.map +1 -1
  25. package/dist/content-client.js +180 -0
  26. package/dist/content-client.js.map +1 -0
  27. package/dist/content-template.js +304 -0
  28. package/dist/content-template.js.map +1 -0
  29. package/dist/conversation.js +213 -134
  30. package/dist/conversation.js.map +1 -1
  31. package/dist/data/conversations.js +70 -50
  32. package/dist/data/conversations.js.map +1 -1
  33. package/dist/data/messages.js +40 -27
  34. package/dist/data/messages.js.map +1 -1
  35. package/dist/data/participants.js +38 -32
  36. package/dist/data/participants.js.map +1 -1
  37. package/dist/data/users.js +19 -14
  38. package/dist/data/users.js.map +1 -1
  39. package/dist/detailed-delivery-receipt.js +9 -4
  40. package/dist/detailed-delivery-receipt.js.map +1 -1
  41. package/dist/index.js +26 -41
  42. package/dist/index.js.map +1 -1
  43. package/dist/interfaces/notification-types.js +9 -4
  44. package/dist/interfaces/notification-types.js.map +1 -1
  45. package/dist/interfaces/rules.js +160 -0
  46. package/dist/interfaces/rules.js.map +1 -0
  47. package/dist/logger.js +17 -28
  48. package/dist/logger.js.map +1 -1
  49. package/dist/media.js +40 -24
  50. package/dist/media.js.map +1 -1
  51. package/dist/message-builder.js +79 -12
  52. package/dist/message-builder.js.map +1 -1
  53. package/dist/message-recipients-client.js +231 -0
  54. package/dist/message-recipients-client.js.map +1 -0
  55. package/dist/message.js +258 -92
  56. package/dist/message.js.map +1 -1
  57. package/dist/node_modules/quick-lru/index.js +261 -0
  58. package/dist/node_modules/quick-lru/index.js.map +1 -0
  59. package/dist/node_modules/tslib/tslib.es6.js +15 -5
  60. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  61. package/dist/packages/conversations/package.json.js +12 -7
  62. package/dist/packages/conversations/package.json.js.map +1 -1
  63. package/dist/participant.js +42 -38
  64. package/dist/participant.js.map +1 -1
  65. package/dist/push-notification.js +9 -4
  66. package/dist/push-notification.js.map +1 -1
  67. package/dist/rest-paginator.js +9 -4
  68. package/dist/rest-paginator.js.map +1 -1
  69. package/dist/services/network.js +11 -6
  70. package/dist/services/network.js.map +1 -1
  71. package/dist/services/typing-indicator.js +17 -11
  72. package/dist/services/typing-indicator.js.map +1 -1
  73. package/dist/unsent-message.js +14 -9
  74. package/dist/unsent-message.js.map +1 -1
  75. package/dist/user.js +40 -32
  76. package/dist/user.js.map +1 -1
  77. package/dist/util/deferred.js +9 -4
  78. package/dist/util/deferred.js.map +1 -1
  79. package/dist/util/index.js +44 -8
  80. package/dist/util/index.js.map +1 -1
  81. package/dist/{interfaces/attributes.js → utils/uuid.js} +17 -19
  82. package/dist/utils/uuid.js.map +1 -0
  83. package/package.json +21 -20
  84. package/CHANGELOG.md +0 -509
  85. package/dist/interfaces/attributes.js.map +0 -1
  86. package/docs/assets/css/main.css +0 -2660
  87. package/docs/assets/images/icons.png +0 -0
  88. package/docs/assets/images/icons@2x.png +0 -0
  89. package/docs/assets/images/widgets.png +0 -0
  90. package/docs/assets/images/widgets@2x.png +0 -0
  91. package/docs/assets/js/main.js +0 -248
  92. package/docs/assets/js/search.js +0 -1
  93. package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
  94. package/docs/classes/CancellablePromise.html +0 -3213
  95. package/docs/classes/Client.html +0 -4239
  96. package/docs/classes/Conversation.html +0 -4354
  97. package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
  98. package/docs/classes/Media.html +0 -3167
  99. package/docs/classes/Message.html +0 -3732
  100. package/docs/classes/MessageBuilder.html +0 -3277
  101. package/docs/classes/Participant.html +0 -3444
  102. package/docs/classes/PushNotification.html +0 -3130
  103. package/docs/classes/RestPaginator.html +0 -3160
  104. package/docs/classes/UnsentMessage.html +0 -3042
  105. package/docs/classes/User.html +0 -3349
  106. package/docs/index.html +0 -3509
  107. package/docs/interfaces/ClientOptions.html +0 -3034
  108. package/docs/interfaces/ConversationBindings.html +0 -3001
  109. package/docs/interfaces/ConversationEmailBinding.html +0 -3001
  110. package/docs/interfaces/ConversationLimits.html +0 -3098
  111. package/docs/interfaces/ConversationState.html +0 -3050
  112. package/docs/interfaces/ConversationUpdatedEventArgs.html +0 -3001
  113. package/docs/interfaces/CreateConversationOptions.html +0 -3066
  114. package/docs/interfaces/LastMessage.html +0 -3050
  115. package/docs/interfaces/Paginator.html +0 -3141
  116. package/docs/interfaces/ParticipantBindings.html +0 -3001
  117. package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
  118. package/docs/interfaces/PushNotificationData.html +0 -3114
  119. package/docs/interfaces/SendEmailOptions.html +0 -3034
  120. package/docs/interfaces/SendMediaOptions.html +0 -3068
  121. package/docs/modules.html +0 -3510
@@ -1 +1 @@
1
- {"version":3,"file":"participants.js","sources":["../../src/data/participants.ts"],"sourcesContent":["import {\n ParticipantDescriptor,\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n ParticipantEmailBinding,\n} from \"../participant\";\nimport { Logger } from \"../logger\";\n\nimport { Conversation } from \"../conversation\";\n\nimport { SyncMap, SyncClient } from \"twilio-sync\";\nimport { Users } from \"./users\";\nimport { CommandExecutor } from \"../command-executor\";\nimport { AddParticipantRequest } from \"../interfaces/commands/add-participant\";\nimport { Configuration } from \"../configuration\";\nimport { ParticipantResponse } from \"../interfaces/commands/participant-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { JSONValue } from \"../types\";\n\ntype ParticipantsEvents = {\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope(\"Participants\");\n\nexport interface ParticipantsServices {\n syncClient: SyncClient;\n users: Users;\n commandExecutor: CommandExecutor;\n}\n\ninterface ParticipantsLinks {\n participants: string;\n}\n\nexport interface ParticipantBindingOptions {\n email?: ParticipantEmailBinding;\n}\n\n/**\n * @classdesc Represents the collection of participants for the conversation\n * @fires Participants#participantJoined\n * @fires Participants#participantLeft\n * @fires Participants#participantUpdated\n */\nclass Participants extends ReplayEventEmitter<ParticipantsEvents> {\n private readonly configuration: Configuration;\n private readonly services: ParticipantsServices;\n private readonly links: ParticipantsLinks;\n\n rosterEntityPromise: Promise<SyncMap> | null = null;\n\n public readonly conversation: Conversation;\n public readonly participants: Map<string, Participant>;\n\n constructor(\n conversation: Conversation,\n participants: Map<string, Participant>,\n links: ParticipantsLinks,\n configuration: Configuration,\n services: ParticipantsServices\n ) {\n super();\n this.conversation = conversation;\n this.participants = participants;\n this.links = links;\n this.configuration = configuration;\n this.services = services;\n }\n\n async unsubscribe(): Promise<void> {\n if (this.rosterEntityPromise) {\n const entity = await this.rosterEntityPromise;\n entity.close();\n this.rosterEntityPromise = null;\n }\n }\n\n subscribe(rosterObjectName: string) {\n return (this.rosterEntityPromise =\n this.rosterEntityPromise ||\n this.services.syncClient\n .map({ id: rosterObjectName, mode: \"open_existing\" })\n .then((rosterMap) => {\n rosterMap.on(\"itemAdded\", (args) => {\n log.debug(this.conversation.sid + \" itemAdded: \" + args.item.key);\n this.upsertParticipant(args.item.key, args.item.data).then(\n (participant) => {\n this.emit(\"participantJoined\", participant);\n }\n );\n });\n\n rosterMap.on(\"itemRemoved\", (args) => {\n log.debug(this.conversation.sid + \" itemRemoved: \" + args.key);\n const participantSid = args.key;\n if (!this.participants.has(participantSid)) {\n return;\n }\n const leftParticipant = this.participants.get(participantSid);\n this.participants.delete(participantSid);\n if (!leftParticipant) {\n return;\n }\n this.emit(\"participantLeft\", leftParticipant);\n });\n\n rosterMap.on(\"itemUpdated\", (args) => {\n log.debug(this.conversation.sid + \" itemUpdated: \" + args.item.key);\n this.upsertParticipant(args.item.key, args.item.data);\n });\n\n const participantsPromises: Promise<Participant>[] = [];\n const rosterMapHandler = (paginator) => {\n paginator.items.forEach((item) => {\n participantsPromises.push(\n this.upsertParticipant(item.key, item.data)\n );\n });\n return paginator.hasNextPage\n ? paginator.nextPage().then(rosterMapHandler)\n : null;\n };\n\n return rosterMap\n .getItems()\n .then(rosterMapHandler)\n .then(() => Promise.all(participantsPromises))\n .then(() => rosterMap);\n })\n .catch((err) => {\n this.rosterEntityPromise = null;\n if (this.services.syncClient.connectionState != \"disconnected\") {\n log.error(\n \"Failed to get roster object for conversation\",\n this.conversation.sid,\n err\n );\n }\n log.debug(\n \"ERROR: Failed to get roster object for conversation\",\n this.conversation.sid,\n err\n );\n throw err;\n }));\n }\n\n async upsertParticipantFromResponse(\n data: ParticipantResponse\n ): Promise<Participant> {\n const {\n sid,\n attributes: responseAttributes,\n date_created: dateCreated,\n date_updated: dateUpdated,\n identity: responseIdentity,\n role_sid: roleSid,\n messaging_binding: messagingBinding,\n } = data;\n\n return await this.upsertParticipant(sid, {\n attributes: responseAttributes,\n dateCreated: new Date(dateCreated),\n dateUpdated: new Date(dateUpdated),\n identity: responseIdentity,\n roleSid,\n lastConsumedMessageIndex: null,\n lastConsumptionTimestamp: null,\n type: messagingBinding?.type ?? \"chat\",\n });\n }\n\n async upsertParticipant(\n participantSid: string,\n data: ParticipantDescriptor\n ): Promise<Participant> {\n let participant = this.participants.get(participantSid);\n if (participant) {\n return participant._update(data);\n }\n\n const links = {\n self: `${this.links.participants}/${participantSid}`,\n };\n\n participant = new Participant(\n data,\n participantSid,\n this.conversation,\n links,\n this.services\n );\n this.participants.set(participantSid, participant);\n participant.on(\"updated\", (args: ParticipantUpdatedEventArgs) =>\n this.emit(\"participantUpdated\", args)\n );\n return participant;\n }\n\n /**\n * @returns {Promise<Array<Participant>>} returns list of participants {@see Participant}\n */\n async getParticipants(): Promise<Participant[]> {\n return this.rosterEntityPromise\n ? this.rosterEntityPromise.then(() => {\n const participants: Participant[] = [];\n this.participants.forEach((participant) =>\n participants.push(participant)\n );\n return participants;\n })\n : [];\n }\n\n /**\n * Get participant by SID from conversation\n * @returns {Promise<Participant>}\n */\n async getParticipantBySid(\n participantSid: string\n ): Promise<Participant | null> {\n return this.rosterEntityPromise\n ? this.rosterEntityPromise.then(() => {\n const participant = this.participants.get(participantSid);\n if (!participant) {\n throw new Error(\n \"Participant with SID \" + participantSid + \" was not found\"\n );\n }\n return participant;\n })\n : null;\n }\n\n /**\n * Get participant by identity from conversation\n * @returns {Promise<Participant>}\n */\n async getParticipantByIdentity(\n identity: string\n ): Promise<Participant | null> {\n let foundParticipant: Participant | null = null;\n return this.rosterEntityPromise\n ? this.rosterEntityPromise.then(() => {\n this.participants.forEach((participant) => {\n if (participant.identity === identity) {\n foundParticipant = participant;\n }\n });\n if (!foundParticipant) {\n throw new Error(\n \"Participant with identity \" + identity + \" was not found\"\n );\n }\n return foundParticipant;\n })\n : null;\n }\n\n /**\n * Add a chat participant to the conversation\n */\n async add(identity: string, attributes: JSONValue): Promise<Participant> {\n const participantResponse =\n await this.services.commandExecutor.mutateResource<\n AddParticipantRequest,\n ParticipantResponse\n >(\"post\", this.links.participants, {\n identity,\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n });\n\n return await this.upsertParticipantFromResponse(participantResponse);\n }\n\n /**\n * Add a non-chat participant to the conversation.\n */\n async addNonChatParticipant(\n proxyAddress: string,\n address: string,\n attributes: JSONValue = {},\n bindingOptions: ParticipantBindingOptions = {}\n ): Promise<Participant> {\n const participantResponse =\n await this.services.commandExecutor.mutateResource<\n AddParticipantRequest,\n ParticipantResponse\n >(\"post\", this.links.participants, {\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n messaging_binding: {\n address,\n proxy_address: proxyAddress,\n name: bindingOptions?.email?.name,\n level: bindingOptions?.email?.level,\n },\n });\n\n return await this.upsertParticipantFromResponse(participantResponse);\n }\n\n /**\n * Remove the participant with a given identity from a conversation.\n */\n remove(identity: string): Promise<void> {\n return this.services.commandExecutor.mutateResource(\n \"delete\",\n `${this.links.participants}/${identity}`\n );\n }\n}\n\nexport { Participants };\n\n/**\n * Fired when participant joined conversation\n * @event Participants#participantJoined\n * @type {Participant}\n */\n\n/**\n * Fired when participant left conversation\n * @event Participants#participantLeft\n * @type {Participant}\n */\n\n/**\n * Fired when participant updated\n * @event Participants#participantUpdated\n * @type {Object}\n * @property {Participant} participant - Updated Participant\n * @property {Participant#UpdateReason[]} updateReasons - Array of Participant's updated event reasons\n */\n"],"names":["Logger","ReplayEventEmitter","participant","Participant"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAgBzC;;;;;AAKG;AACH,MAAM,YAAa,SAAQC,qCAAsC,CAAA;IAU/D,WACE,CAAA,YAA0B,EAC1B,YAAsC,EACtC,KAAwB,EACxB,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AAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,KAAK;AACpC,aAAA;AACF,SAAA,CAAC,CAAC;AAEL,QAAA,OAAO,MAAM,IAAI,CAAC,6BAA6B,CAAC,mBAAmB,CAAC,CAAC;KACtE;AAED;;AAEG;AACH,IAAA,MAAM,CAAC,QAAgB,EAAA;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CACjD,QAAQ,EACR,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,QAAQ,CAAA,CAAE,CACzC,CAAC;KACH;AACF,CAAA;AAID;;;;AAIG;AAEH;;;;AAIG;AAEH;;;;;;AAMG;;;;"}
1
+ {"version":3,"file":"participants.js","sources":["../../src/data/participants.ts"],"sourcesContent":["import {\n ParticipantDescriptor,\n Participant,\n ParticipantUpdatedEventArgs,\n ParticipantUpdateReason,\n ParticipantEmailBinding,\n} from \"../participant\";\nimport { Logger } from \"../logger\";\n\nimport { Conversation } from \"../conversation\";\n\nimport { SyncMap, SyncClient } from \"twilio-sync\";\nimport { Users } from \"./users\";\nimport { CommandExecutor } from \"../command-executor\";\nimport { AddParticipantRequest } from \"../interfaces/commands/add-participant\";\nimport { ParticipantResponse } from \"../interfaces/commands/participant-response\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { JSONValue } from \"../types\";\n\ntype ParticipantsEvents = {\n participantJoined: (participant: Participant) => void;\n participantLeft: (participant: Participant) => void;\n participantUpdated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope(\"Participants\");\n\nexport interface ParticipantsServices {\n syncClient: SyncClient;\n users: Users;\n commandExecutor: CommandExecutor;\n}\n\ninterface ParticipantsLinks {\n participants: string;\n}\n\nexport interface ParticipantBindingOptions {\n email?: ParticipantEmailBinding;\n}\n\n/**\n * @classdesc Represents the collection of participants for the conversation\n * @fires Participants#participantJoined\n * @fires Participants#participantLeft\n * @fires Participants#participantUpdated\n */\nclass Participants extends ReplayEventEmitter<ParticipantsEvents> {\n private readonly services: ParticipantsServices;\n private readonly links: ParticipantsLinks;\n\n rosterEntityPromise: Promise<SyncMap> | null = null;\n\n public readonly conversation: Conversation;\n public readonly participants: Map<string, Participant>; // passed in from Conversation\n\n constructor(\n conversation: Conversation,\n participants: Map<string, Participant>,\n links: ParticipantsLinks,\n services: ParticipantsServices\n ) {\n super();\n this.conversation = conversation;\n this.participants = participants;\n this.links = links;\n this.services = services;\n }\n\n async unsubscribe(): Promise<void> {\n if (this.rosterEntityPromise) {\n const entity = await this.rosterEntityPromise;\n entity.close();\n this.rosterEntityPromise = null;\n }\n }\n\n subscribe(arg: string | SyncMap) {\n const participantsMapPromise =\n typeof arg === \"string\"\n ? this.services.syncClient.map({ id: arg, mode: \"open_existing\" })\n : Promise.resolve(arg);\n\n return (this.rosterEntityPromise =\n this.rosterEntityPromise ||\n participantsMapPromise\n .then((rosterMap) => {\n rosterMap.on(SyncMap.itemAdded, (args) => {\n log.debug(this.conversation.sid + \" itemAdded: \" + args.item.key);\n this.upsertParticipant(args.item.key, args.item.data).then(\n (participant) => {\n this.emit(Conversation.participantJoined, participant);\n }\n );\n });\n\n rosterMap.on(SyncMap.itemRemoved, (args) => {\n log.debug(this.conversation.sid + \" itemRemoved: \" + args.key);\n const participantSid = args.key;\n if (!this.participants.has(participantSid)) {\n return;\n }\n const leftParticipant = this.participants.get(participantSid);\n this.participants.delete(participantSid);\n if (!leftParticipant) {\n return;\n }\n this.emit(Conversation.participantLeft, leftParticipant);\n });\n\n rosterMap.on(SyncMap.itemUpdated, (args) => {\n log.debug(this.conversation.sid + \" itemUpdated: \" + args.item.key);\n this.upsertParticipant(args.item.key, args.item.data).catch((e) =>\n log.error(e)\n );\n });\n\n const participantsPromises: Promise<Participant>[] = [];\n const rosterMapHandler = (paginator) => {\n paginator.items.forEach((item) => {\n participantsPromises.push(\n this.upsertParticipant(item.key, item.data)\n );\n });\n return paginator.hasNextPage\n ? paginator.nextPage().then(rosterMapHandler)\n : null;\n };\n\n return rosterMap\n .getItems()\n .then(rosterMapHandler)\n .then(() => Promise.all(participantsPromises))\n .then(() => rosterMap);\n })\n .catch((err) => {\n this.rosterEntityPromise = null;\n if (this.services.syncClient.connectionState != \"disconnected\") {\n log.error(\n \"Failed to get roster object for conversation\",\n this.conversation.sid,\n err\n );\n }\n log.debug(\n \"ERROR: Failed to get roster object for conversation\",\n this.conversation.sid,\n err\n );\n throw err;\n }));\n }\n\n async upsertParticipantFromResponse(\n data: ParticipantResponse\n ): Promise<Participant> {\n const {\n sid,\n attributes: responseAttributes,\n date_created: dateCreated,\n date_updated: dateUpdated,\n identity: responseIdentity,\n role_sid: roleSid,\n messaging_binding: messagingBinding,\n } = data;\n\n return await this.upsertParticipant(sid, {\n attributes: responseAttributes,\n dateCreated: new Date(dateCreated),\n dateUpdated: new Date(dateUpdated),\n identity: responseIdentity,\n roleSid,\n lastConsumedMessageIndex: null,\n lastConsumptionTimestamp: null,\n type: messagingBinding?.type ?? \"chat\",\n });\n }\n\n async upsertParticipant(\n participantSid: string,\n data: ParticipantDescriptor\n ): Promise<Participant> {\n let participant = this.participants.get(participantSid);\n if (participant) {\n return participant._update(data);\n }\n\n const links = {\n self: `${this.links.participants}/${participantSid}`,\n };\n\n participant = new Participant(\n data,\n participantSid,\n this.conversation,\n links,\n this.services\n );\n this.participants.set(participantSid, participant);\n participant.on(Participant.updated, (args: ParticipantUpdatedEventArgs) =>\n this.emit(Conversation.participantUpdated, args)\n );\n return participant;\n }\n\n /**\n * @returns {Promise<Array<Participant>>} returns list of participants {@see Participant}\n */\n async getParticipants(): Promise<Participant[]> {\n return this.rosterEntityPromise\n ? this.rosterEntityPromise.then(() => {\n const participants: Participant[] = [];\n this.participants.forEach((participant) =>\n participants.push(participant)\n );\n return participants;\n })\n : [];\n }\n\n /**\n * Get participant by SID from conversation\n * @returns {Promise<Participant>}\n */\n async getParticipantBySid(\n participantSid: string\n ): Promise<Participant | null> {\n return this.rosterEntityPromise\n ? this.rosterEntityPromise.then(() => {\n const participant = this.participants.get(participantSid);\n if (!participant) {\n throw new Error(\n \"Participant with SID \" + participantSid + \" was not found\"\n );\n }\n return participant;\n })\n : null;\n }\n\n /**\n * Get participant by identity from conversation\n * @returns {Promise<Participant>}\n */\n async getParticipantByIdentity(\n identity: string\n ): Promise<Participant | null> {\n let foundParticipant: Participant | null = null;\n return this.rosterEntityPromise\n ? this.rosterEntityPromise.then(() => {\n this.participants.forEach((participant) => {\n if (participant.identity === identity) {\n foundParticipant = participant;\n }\n });\n if (!foundParticipant) {\n throw new Error(\n \"Participant with identity \" + identity + \" was not found\"\n );\n }\n return foundParticipant;\n })\n : null;\n }\n\n /**\n * Add a chat participant to the conversation\n */\n async add(\n identity: string,\n attributes: JSONValue\n ): Promise<ParticipantResponse> {\n return await this.services.commandExecutor.mutateResource<\n AddParticipantRequest,\n ParticipantResponse\n >(\"post\", this.links.participants, {\n identity,\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n });\n }\n\n /**\n * Add a non-chat participant to the conversation.\n */\n async addNonChatParticipant(\n proxyAddress: string,\n address: string,\n attributes: JSONValue = {},\n bindingOptions: ParticipantBindingOptions = {}\n ): Promise<ParticipantResponse> {\n return await this.services.commandExecutor.mutateResource<\n AddParticipantRequest,\n ParticipantResponse\n >(\"post\", this.links.participants, {\n attributes:\n typeof attributes !== \"undefined\"\n ? JSON.stringify(attributes)\n : undefined,\n messaging_binding: {\n address,\n proxy_address: proxyAddress,\n name: bindingOptions?.email?.name,\n level: bindingOptions?.email?.level,\n },\n });\n }\n\n /**\n * Remove the participant with a given identity from a conversation.\n */\n remove(identity: string): Promise<void> {\n return this.services.commandExecutor.mutateResource(\n \"delete\",\n `${this.links.participants}/${encodeURIComponent(identity)}`\n );\n }\n}\n\nexport { Participants };\n\n/**\n * Fired when participant joined conversation\n * @event Participants#participantJoined\n * @type {Participant}\n */\n\n/**\n * Fired when participant left conversation\n * @event Participants#participantLeft\n * @type {Participant}\n */\n\n/**\n * Fired when participant updated\n * @event Participants#participantUpdated\n * @type {Object}\n * @property {Participant} participant - Updated Participant\n * @property {Participant#UpdateReason[]} updateReasons - Array of Participant's updated event reasons\n */\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAgBzC;;;;;AAKG;AACH,MAAM,YAAa,SAAQ,kBAAsC,CAAA;AAS/D,IAAA,WAAA,CACE,YAA0B,EAC1B,YAAsC,EACtC,KAAwB,EACxB,QAA8B,EAAA;AAE9B,QAAA,KAAK,EAAE,CAAC;QAXV,IAAmB,CAAA,mBAAA,GAA4B,IAAI,CAAC;AAYlD,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AACjC,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AACjC,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACnB,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;KAC1B;AAED,IAAA,MAAM,WAAW,GAAA;QACf,IAAI,IAAI,CAAC,mBAAmB,EAAE;AAC5B,YAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC;YAC9C,MAAM,CAAC,KAAK,EAAE,CAAC;AACf,YAAA,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;AACjC,SAAA;KACF;AAED,IAAA,SAAS,CAAC,GAAqB,EAAA;AAC7B,QAAA,MAAM,sBAAsB,GAC1B,OAAO,GAAG,KAAK,QAAQ;AACrB,cAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EA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C1B,cAAA,GAA4C,EAAE,EAAA;;AAE9C,QAAA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAGvD,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;AACjC,YAAA,UAAU,EACR,OAAO,UAAU,KAAK,WAAW;AAC/B,kBAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;AAC5B,kBAAE,SAAS;AACf,YAAA,iBAAiB,EAAE;gBACjB,OAAO;AACP,gBAAA,aAAa,EAAE,YAAY;gBAC3B,IAAI,EAAE,CAAA,EAAA,GAAA,cAAc,KAAd,IAAA,IAAA,cAAc,uBAAd,cAAc,CAAE,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,IAAI;gBACjC,KAAK,EAAE,CAAA,EAAA,GAAA,cAAc,KAAd,IAAA,IAAA,cAAc,uBAAd,cAAc,CAAE,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,KAAK;AACpC,aAAA;AACF,SAAA,CAAC,CAAC;KACJ;AAED;;AAEG;AACH,IAAA,MAAM,CAAC,QAAgB,EAAA;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CACjD,QAAQ,EACR,CAAA,EAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAI,CAAA,EAAA,kBAAkB,CAAC,QAAQ,CAAC,CAAE,CAAA,CAC7D,CAAC;KACH;AACF,CAAA;AAID;;;;AAIG;AAEH;;;;AAIG;AAEH;;;;;;AAMG;;;;"}
@@ -126,18 +126,23 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
130
-
131
- Object.defineProperty(exports, '__esModule', { value: true });
132
-
133
- var user = require('../user.js');
134
- var index = require('../util/index.js');
135
- var replayEventEmitter = require('@twilio/replay-event-emitter');
129
+ var global =
130
+ typeof global !== "undefined"
131
+ ? global
132
+ : typeof self !== "undefined"
133
+ ? self
134
+ : typeof window !== "undefined"
135
+ ? window
136
+ : {};
137
+
138
+ import { User } from '../user.js';
139
+ import { UriBuilder } from '../util/index.js';
140
+ import { ReplayEventEmitter } from '@twilio/replay-event-emitter';
136
141
 
137
142
  /**
138
143
  * Container for known users
139
144
  */
140
- class Users extends replayEventEmitter.ReplayEventEmitter {
145
+ class Users extends ReplayEventEmitter {
141
146
  constructor(myself, configuration, services) {
142
147
  super();
143
148
  this.configuration = configuration;
@@ -192,12 +197,12 @@ class Users extends replayEventEmitter.ReplayEventEmitter {
192
197
  if (identity == this.myself.identity) {
193
198
  return this.myself;
194
199
  }
195
- const user$1 = this.subscribedUsers.get(identity);
196
- if (user$1) {
197
- return user$1;
200
+ const user = this.subscribedUsers.get(identity);
201
+ if (user) {
202
+ return user;
198
203
  }
199
204
  entityName !== null && entityName !== void 0 ? entityName : (entityName = await this.getSyncUniqueName(identity));
200
- const newUser = new user.User(identity, entityName, this.configuration, this.services);
205
+ const newUser = new User(identity, entityName, this.configuration, this.services);
201
206
  newUser.on("updated", (args) => this.emit("userUpdated", args));
202
207
  newUser.on("userSubscribed", () => this.handleSubscribeUser(newUser));
203
208
  newUser.on("userUnsubscribed", () => this.handleUnsubscribeUser(newUser));
@@ -218,7 +223,7 @@ class Users extends replayEventEmitter.ReplayEventEmitter {
218
223
  */
219
224
  async getSyncUniqueName(identity) {
220
225
  var _a, _b;
221
- const url = new index.UriBuilder(this.configuration.links.users)
226
+ const url = new UriBuilder(this.configuration.links.users)
222
227
  .path(identity)
223
228
  .build();
224
229
  const response = await this.services.network.get(url);
@@ -226,5 +231,5 @@ class Users extends replayEventEmitter.ReplayEventEmitter {
226
231
  }
227
232
  }
228
233
 
229
- exports.Users = Users;
234
+ export { Users };
230
235
  //# sourceMappingURL=users.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"users.js","sources":["../../src/data/users.ts"],"sourcesContent":["import { User, UserUpdatedEventArgs, UserUpdateReason } from \"../user\";\nimport { Network } from \"../services/network\";\nimport { SyncClient } from \"twilio-sync\";\nimport { UriBuilder } from \"../util\";\nimport { Configuration } from \"../configuration\";\nimport { CommandExecutor } from \"../command-executor\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { UserResponse } from \"../interfaces/commands/user\";\n\ntype UsersEvents = {\n userUpdated: (data: {\n user: User;\n updateReasons: UserUpdateReason[];\n }) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n};\n\nexport interface UsersServices {\n network: Network;\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n}\n\n/**\n * Container for known users\n */\nclass Users extends ReplayEventEmitter<UsersEvents> {\n private readonly configuration: Configuration;\n private readonly services: UsersServices;\n\n private subscribedUsers: Map<string, User>;\n private fifoStack: string[];\n public readonly myself: User;\n\n constructor(\n myself: User,\n configuration: Configuration,\n services: UsersServices\n ) {\n super();\n\n this.configuration = configuration;\n this.services = services;\n\n this.fifoStack = [];\n this.myself = myself;\n this.myself.on(\"updated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n this.myself.on(\"userSubscribed\", () =>\n this.emit(\"userSubscribed\", this.myself)\n );\n this.myself.on(\"userUnsubscribed\", () => {\n this.emit(\"userUnsubscribed\", this.myself);\n this.myself._ensureFetched();\n });\n\n this.subscribedUsers = new Map<string, User>();\n }\n\n private handleUnsubscribeUser(user: User): void {\n if (this.subscribedUsers.has(user.identity)) {\n this.subscribedUsers.delete(user.identity);\n }\n let foundItemIndex = 0;\n const foundItem = this.fifoStack.find((item, index) => {\n if (item == user.identity) {\n foundItemIndex = index;\n return true;\n }\n return false;\n });\n if (foundItem) {\n this.fifoStack.splice(foundItemIndex, 1);\n }\n this.emit(\"userUnsubscribed\", user);\n }\n\n private handleSubscribeUser(user: User): void {\n if (this.subscribedUsers.has(user.identity)) {\n return;\n }\n if (this.fifoStack.length >= this.configuration.userInfosToSubscribe) {\n const item = this.fifoStack.shift() as string;\n this.subscribedUsers?.get(item)?.unsubscribe();\n }\n this.fifoStack.push(user.identity);\n this.subscribedUsers.set(user.identity, user);\n this.emit(\"userSubscribed\", user);\n }\n\n /**\n * Gets user, if it's in subscribed list - then return the user object from it,\n * if not - then subscribes and adds user to the FIFO stack\n * @returns {Promise<User>} Fully initialized user\n */\n async getUser(identity: string, entityName?: string): Promise<User> {\n await this.myself._ensureFetched();\n\n if (identity == this.myself.identity) {\n return this.myself;\n }\n\n const user = this.subscribedUsers.get(identity);\n\n if (user) {\n return user;\n }\n\n entityName ??= await this.getSyncUniqueName(identity);\n\n const newUser = new User(\n identity,\n entityName,\n this.configuration,\n this.services\n );\n\n newUser.on(\"updated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n newUser.on(\"userSubscribed\", () => this.handleSubscribeUser(newUser));\n newUser.on(\"userUnsubscribed\", () => this.handleUnsubscribeUser(newUser));\n await newUser._ensureFetched();\n\n return newUser;\n }\n\n /**\n * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}\n */\n async getSubscribedUsers(): Promise<Array<User>> {\n await this.myself._ensureFetched();\n\n const users = [this.myself];\n this.subscribedUsers.forEach((user) => users.push(user));\n\n return users;\n }\n\n /**\n * @returns {Promise<string>} User's sync unique name\n */\n private async getSyncUniqueName(identity: string): Promise<string> {\n const url = new UriBuilder(this.configuration.links.users)\n .path(identity)\n .build();\n const response = await this.services.network.get<UserResponse>(url);\n return response.body?.sync_objects.user_info_map ?? \"\";\n }\n}\n\nexport { Users };\n"],"names":["ReplayEventEmitter","user","User","UriBuilder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,QAAA,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAEzD,QAAA,OAAO,KAAK,CAAC;KACd;AAED;;AAEG;IACK,MAAM,iBAAiB,CAAC,QAAgB,EAAA;;AAC9C,QAAA,MAAM,GAAG,GAAG,IAAIC,gBAAU,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC;aACvD,IAAI,CAAC,QAAQ,CAAC;AACd,aAAA,KAAK,EAAE,CAAC;AACX,QAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAe,GAAG,CAAC,CAAC;QACpE,OAAO,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,QAAQ,CAAC,IAAI,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,YAAY,CAAC,aAAa,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,CAAC;KACxD;AACF;;;;"}
1
+ {"version":3,"file":"users.js","sources":["../../src/data/users.ts"],"sourcesContent":["import { User, UserUpdatedEventArgs, UserUpdateReason } from \"../user\";\nimport { Network } from \"../services/network\";\nimport { SyncClient } from \"twilio-sync\";\nimport { UriBuilder } from \"../util\";\nimport { Configuration } from \"../configuration\";\nimport { CommandExecutor } from \"../command-executor\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { UserResponse } from \"../interfaces/commands/user\";\n\ntype UsersEvents = {\n userUpdated: (data: {\n user: User;\n updateReasons: UserUpdateReason[];\n }) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n};\n\nexport interface UsersServices {\n network: Network;\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n}\n\n/**\n * Container for known users\n */\nclass Users extends ReplayEventEmitter<UsersEvents> {\n private readonly configuration: Configuration;\n private readonly services: UsersServices;\n\n private subscribedUsers: Map<string, User>;\n private fifoStack: string[];\n public readonly myself: User;\n\n constructor(\n myself: User,\n configuration: Configuration,\n services: UsersServices\n ) {\n super();\n\n this.configuration = configuration;\n this.services = services;\n\n this.fifoStack = [];\n this.myself = myself;\n this.myself.on(\"updated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n this.myself.on(\"userSubscribed\", () =>\n this.emit(\"userSubscribed\", this.myself)\n );\n this.myself.on(\"userUnsubscribed\", () => {\n this.emit(\"userUnsubscribed\", this.myself);\n this.myself._ensureFetched();\n });\n\n this.subscribedUsers = new Map<string, User>();\n }\n\n private handleUnsubscribeUser(user: User): void {\n if (this.subscribedUsers.has(user.identity)) {\n this.subscribedUsers.delete(user.identity);\n }\n let foundItemIndex = 0;\n const foundItem = this.fifoStack.find((item, index) => {\n if (item == user.identity) {\n foundItemIndex = index;\n return true;\n }\n return false;\n });\n if (foundItem) {\n this.fifoStack.splice(foundItemIndex, 1);\n }\n this.emit(\"userUnsubscribed\", user);\n }\n\n private handleSubscribeUser(user: User): void {\n if (this.subscribedUsers.has(user.identity)) {\n return;\n }\n if (this.fifoStack.length >= this.configuration.userInfosToSubscribe) {\n const item = this.fifoStack.shift() as string;\n this.subscribedUsers?.get(item)?.unsubscribe();\n }\n this.fifoStack.push(user.identity);\n this.subscribedUsers.set(user.identity, user);\n this.emit(\"userSubscribed\", user);\n }\n\n /**\n * Gets user, if it's in subscribed list - then return the user object from it,\n * if not - then subscribes and adds user to the FIFO stack\n * @returns {Promise<User>} Fully initialized user\n */\n async getUser(identity: string, entityName?: string): Promise<User> {\n await this.myself._ensureFetched();\n\n if (identity == this.myself.identity) {\n return this.myself;\n }\n\n const user = this.subscribedUsers.get(identity);\n\n if (user) {\n return user;\n }\n\n entityName ??= await this.getSyncUniqueName(identity);\n\n const newUser = new User(\n identity,\n entityName,\n this.configuration,\n this.services\n );\n\n newUser.on(\"updated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n newUser.on(\"userSubscribed\", () => this.handleSubscribeUser(newUser));\n newUser.on(\"userUnsubscribed\", () => this.handleUnsubscribeUser(newUser));\n await newUser._ensureFetched();\n\n return newUser;\n }\n\n /**\n * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}\n */\n async getSubscribedUsers(): Promise<Array<User>> {\n await this.myself._ensureFetched();\n\n const users = [this.myself];\n this.subscribedUsers.forEach((user) => users.push(user));\n\n return users;\n }\n\n /**\n * @returns {Promise<string>} User's sync unique name\n */\n private async getSyncUniqueName(identity: string): Promise<string> {\n const url = new UriBuilder(this.configuration.links.users)\n .path(identity)\n .build();\n const response = await this.services.network.get<UserResponse>(url);\n return response.body?.sync_objects.user_info_map ?? \"\";\n }\n}\n\nexport { Users };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA;;AAEG;AACH,MAAM,KAAM,SAAQ,kBAA+B,CAAA;AAQjD,IAAA,WAAA,CACE,MAAY,EACZ,aAA4B,EAC5B,QAAuB,EAAA;AAEvB,QAAA,KAAK,EAAE,CAAC;AAER,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAEzB,QAAA,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;AACpB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,IAA0B,KACnD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAC/B,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,EA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AA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,YAAY,CAAC,aAAa,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,CAAC;KACxD;AACF;;;;"}
@@ -126,9 +126,14 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
130
-
131
- Object.defineProperty(exports, '__esModule', { value: true });
129
+ var global =
130
+ typeof global !== "undefined"
131
+ ? global
132
+ : typeof self !== "undefined"
133
+ ? self
134
+ : typeof window !== "undefined"
135
+ ? window
136
+ : {};
132
137
 
133
138
  /**
134
139
  * Represents a delivery receipt of a message.
@@ -150,5 +155,5 @@ class DetailedDeliveryReceipt {
150
155
  }
151
156
  }
152
157
 
153
- exports.DetailedDeliveryReceipt = DetailedDeliveryReceipt;
158
+ export { DetailedDeliveryReceipt };
154
159
  //# sourceMappingURL=detailed-delivery-receipt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"detailed-delivery-receipt.js","sources":["../src/detailed-delivery-receipt.ts"],"sourcesContent":["/**\n * Message delivery status.\n */\ntype DeliveryStatus =\n | \"sent\"\n | \"delivered\"\n | \"failed\"\n | \"read\"\n | \"undelivered\"\n | \"queued\";\n\ninterface DetailedDeliveryReceiptDescriptor {\n sid: string;\n message_sid: string;\n conversation_sid: string;\n channel_message_sid: string;\n participant_sid: string;\n status: DeliveryStatus;\n error_code: string | null;\n date_created: string;\n date_updated: string;\n}\n\n/**\n * Represents a delivery receipt of a message.\n */\nclass DetailedDeliveryReceipt {\n /**\n * Unique identifier for the delivery receipt.\n */\n sid: string;\n\n /**\n * Unique identifier for the message in the conversation.\n */\n messageSid: string;\n\n /**\n * Unique identifier for the conversation.\n */\n conversationSid: string;\n\n /**\n * Unique identifier for the `‘channel’` message (e.g., `WAxx` for WhatsApp, `SMxx` for SMS).\n */\n channelMessageSid: string;\n\n /**\n * Unique identifier for the participant.\n */\n participantSid: string;\n\n /**\n * Status of the message delivery.\n */\n status: DeliveryStatus;\n\n /**\n * Numeric error code mapped from Status callback code. Information about the error codes can be found\n * [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).\n */\n errorCode: string | 0;\n\n /**\n * Date this delivery receipt was created on.\n */\n dateCreated: string;\n\n /**\n * Date this delivery receipt was last updated on.\n */\n dateUpdated: string;\n\n /**\n * @internal\n */\n constructor(descriptor: DetailedDeliveryReceiptDescriptor) {\n this.sid = descriptor.sid;\n this.messageSid = descriptor.message_sid;\n this.conversationSid = descriptor.conversation_sid;\n this.channelMessageSid = descriptor.channel_message_sid;\n this.participantSid = descriptor.participant_sid;\n this.status = descriptor.status || \"queued\";\n this.errorCode = descriptor.error_code || 0;\n this.dateCreated = descriptor.date_created;\n this.dateUpdated = descriptor.date_updated;\n }\n}\n\nexport {\n DetailedDeliveryReceipt,\n DetailedDeliveryReceiptDescriptor,\n DeliveryStatus,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;;AAEG;AACH,MAAM,uBAAuB,CAAA;AA+C3B;;AAEG;AACH,IAAA,WAAA,CAAY,UAA6C,EAAA;AACvD,QAAA,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;AAC1B,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC;AACzC,QAAA,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,gBAAgB,CAAC;AACnD,QAAA,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,mBAAmB,CAAC;AACxD,QAAA,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,IAAI,QAAQ,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,UAAU,IAAI,CAAC,CAAC;AAC5C,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC;AAC3C,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC;KAC5C;AACF;;;;"}
1
+ {"version":3,"file":"detailed-delivery-receipt.js","sources":["../src/detailed-delivery-receipt.ts"],"sourcesContent":["/**\n * Message delivery status.\n */\ntype DeliveryStatus =\n | \"sent\"\n | \"delivered\"\n | \"failed\"\n | \"read\"\n | \"undelivered\"\n | \"queued\";\n\ninterface DetailedDeliveryReceiptDescriptor {\n sid: string;\n message_sid: string;\n conversation_sid: string;\n channel_message_sid: string;\n participant_sid: string;\n status: DeliveryStatus;\n error_code: string | null;\n date_created: string;\n date_updated: string;\n}\n\n/**\n * Represents a delivery receipt of a message.\n */\nclass DetailedDeliveryReceipt {\n /**\n * Unique identifier for the delivery receipt.\n */\n sid: string;\n\n /**\n * Unique identifier for the message in the conversation.\n */\n messageSid: string;\n\n /**\n * Unique identifier for the conversation.\n */\n conversationSid: string;\n\n /**\n * Unique identifier for the `‘channel’` message (e.g., `WAxx` for WhatsApp, `SMxx` for SMS).\n */\n channelMessageSid: string;\n\n /**\n * Unique identifier for the participant.\n */\n participantSid: string;\n\n /**\n * Status of the message delivery.\n */\n status: DeliveryStatus;\n\n /**\n * Numeric error code mapped from Status callback code. Information about the error codes can be found\n * [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).\n */\n errorCode: string | 0;\n\n /**\n * Date this delivery receipt was created on.\n */\n dateCreated: string;\n\n /**\n * Date this delivery receipt was last updated on.\n */\n dateUpdated: string;\n\n /**\n * @internal\n */\n constructor(descriptor: DetailedDeliveryReceiptDescriptor) {\n this.sid = descriptor.sid;\n this.messageSid = descriptor.message_sid;\n this.conversationSid = descriptor.conversation_sid;\n this.channelMessageSid = descriptor.channel_message_sid;\n this.participantSid = descriptor.participant_sid;\n this.status = descriptor.status || \"queued\";\n this.errorCode = descriptor.error_code || 0;\n this.dateCreated = descriptor.date_created;\n this.dateUpdated = descriptor.date_updated;\n }\n}\n\nexport {\n DetailedDeliveryReceipt,\n DetailedDeliveryReceiptDescriptor,\n DeliveryStatus,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;;AAEG;AACH,MAAM,uBAAuB,CAAA;AA+C3B;;AAEG;AACH,IAAA,WAAA,CAAY,UAA6C,EAAA;AACvD,QAAA,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;AAC1B,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC;AACzC,QAAA,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,gBAAgB,CAAC;AACnD,QAAA,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,mBAAmB,CAAC;AACxD,QAAA,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,IAAI,QAAQ,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,UAAU,IAAI,CAAC,CAAC;AAC5C,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC;AAC3C,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC;KAC5C;AACF;;;;"}
package/dist/index.js CHANGED
@@ -126,45 +126,30 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
130
-
131
- Object.defineProperty(exports, '__esModule', { value: true });
132
-
133
- var client = require('./client.js');
134
- var mcsClient = require('@twilio/mcs-client');
135
- var conversation = require('./conversation.js');
136
- var participant = require('./participant.js');
137
- var message = require('./message.js');
138
- var media = require('./media.js');
139
- var aggregatedDeliveryReceipt = require('./aggregated-delivery-receipt.js');
140
- var detailedDeliveryReceipt = require('./detailed-delivery-receipt.js');
141
- var restPaginator = require('./rest-paginator.js');
142
- var messageBuilder = require('./message-builder.js');
143
- var unsentMessage = require('./unsent-message.js');
144
- var user = require('./user.js');
145
- var pushNotification = require('./push-notification.js');
146
- var notificationTypes = require('./interfaces/notification-types.js');
147
-
148
-
149
-
150
- Object.defineProperty(exports, 'Client', {
151
- enumerable: true,
152
- get: function () { return client.Client; }
153
- });
154
- Object.defineProperty(exports, 'CancellablePromise', {
155
- enumerable: true,
156
- get: function () { return mcsClient.CancellablePromise; }
157
- });
158
- exports.Conversation = conversation.Conversation;
159
- exports.Participant = participant.Participant;
160
- exports.Message = message.Message;
161
- exports.Media = media.Media;
162
- exports.AggregatedDeliveryReceipt = aggregatedDeliveryReceipt.AggregatedDeliveryReceipt;
163
- exports.DetailedDeliveryReceipt = detailedDeliveryReceipt.DetailedDeliveryReceipt;
164
- exports.RestPaginator = restPaginator.RestPaginator;
165
- exports.MessageBuilder = messageBuilder.MessageBuilder;
166
- exports.UnsentMessage = unsentMessage.UnsentMessage;
167
- exports.User = user.User;
168
- exports.PushNotification = pushNotification.PushNotification;
169
- exports.NotificationTypes = notificationTypes.NotificationTypes;
129
+ var global =
130
+ typeof global !== "undefined"
131
+ ? global
132
+ : typeof self !== "undefined"
133
+ ? self
134
+ : typeof window !== "undefined"
135
+ ? window
136
+ : {};
137
+
138
+ export { Client } from './client.js';
139
+ export { CancellablePromise } from '@twilio/mcs-client';
140
+ export { Conversation } from './conversation.js';
141
+ export { Participant } from './participant.js';
142
+ export { Message } from './message.js';
143
+ export { Media } from './media.js';
144
+ export { AggregatedDeliveryReceipt } from './aggregated-delivery-receipt.js';
145
+ export { DetailedDeliveryReceipt } from './detailed-delivery-receipt.js';
146
+ export { RestPaginator } from './rest-paginator.js';
147
+ export { MessageBuilder } from './message-builder.js';
148
+ export { UnsentMessage } from './unsent-message.js';
149
+ export { User } from './user.js';
150
+ export { PushNotification } from './push-notification.js';
151
+ export { NotificationTypes } from './interfaces/notification-types.js';
152
+ export { ContentTemplate, ContentTemplateVariable } from './content-template.js';
153
+ export { ChannelMetadata } from './channel-metadata-client.js';
154
+ export { EmailRecipientDescriptor, UnknownRecipientDescriptor } from './message-recipients-client.js';
170
155
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -126,9 +126,14 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
130
-
131
- Object.defineProperty(exports, '__esModule', { value: true });
129
+ var global =
130
+ typeof global !== "undefined"
131
+ ? global
132
+ : typeof self !== "undefined"
133
+ ? self
134
+ : typeof window !== "undefined"
135
+ ? window
136
+ : {};
132
137
 
133
138
  class NotificationTypes {
134
139
  }
@@ -139,5 +144,5 @@ NotificationTypes.ADDED_TO_CONVERSATION = "twilio.conversations.added_to_convers
139
144
  NotificationTypes.REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
140
145
  NotificationTypes.CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
141
146
 
142
- exports.NotificationTypes = NotificationTypes;
147
+ export { NotificationTypes };
143
148
  //# sourceMappingURL=notification-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification-types.js","sources":["../../src/interfaces/notification-types.ts"],"sourcesContent":["class NotificationTypes {\n static readonly TYPING_INDICATOR = \"twilio.ipmsg.typing_indicator\";\n static readonly NEW_MESSAGE = \"twilio.conversations.new_message\";\n static readonly ADDED_TO_CONVERSATION =\n \"twilio.conversations.added_to_conversation\";\n // static readonly INVITED_TO_CHANNEL = 'twilio.channel.invited_to_channel';\n static readonly REMOVED_FROM_CONVERSATION =\n \"twilio.conversations.removed_from_conversation\";\n static readonly CONSUMPTION_UPDATE = \"twilio.channel.consumption_update\";\n}\n\nexport { NotificationTypes };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,iBAAiB,CAAA;;AACL,iBAAgB,CAAA,gBAAA,GAAG,+BAA+B,CAAC;AACnD,iBAAW,CAAA,WAAA,GAAG,kCAAkC,CAAC;AACjD,iBAAqB,CAAA,qBAAA,GACnC,4CAA4C,CAAC;AAC/C;AACgB,iBAAyB,CAAA,yBAAA,GACvC,gDAAgD,CAAC;AACnC,iBAAkB,CAAA,kBAAA,GAAG,mCAAmC;;;;"}
1
+ {"version":3,"file":"notification-types.js","sources":["../../src/interfaces/notification-types.ts"],"sourcesContent":["class NotificationTypes {\n static readonly TYPING_INDICATOR = \"twilio.ipmsg.typing_indicator\";\n static readonly NEW_MESSAGE = \"twilio.conversations.new_message\";\n static readonly ADDED_TO_CONVERSATION =\n \"twilio.conversations.added_to_conversation\";\n // static readonly INVITED_TO_CHANNEL = 'twilio.channel.invited_to_channel';\n static readonly REMOVED_FROM_CONVERSATION =\n \"twilio.conversations.removed_from_conversation\";\n static readonly CONSUMPTION_UPDATE = \"twilio.channel.consumption_update\";\n}\n\nexport { NotificationTypes };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,iBAAiB,CAAA;;AACL,iBAAgB,CAAA,gBAAA,GAAG,+BAA+B,CAAC;AACnD,iBAAW,CAAA,WAAA,GAAG,kCAAkC,CAAC;AACjD,iBAAqB,CAAA,qBAAA,GACnC,4CAA4C,CAAC;AAC/C;AACgB,iBAAyB,CAAA,yBAAA,GACvC,gDAAgD,CAAC;AACnC,iBAAkB,CAAA,kBAAA,GAAG,mCAAmC;;;;"}
@@ -0,0 +1,160 @@
1
+ /*
2
+ @license
3
+ The following license applies to all parts of this software except as
4
+ documented below.
5
+
6
+ Copyright (c) 2019, Twilio, inc.
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are
11
+ met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in
18
+ the documentation and/or other materials provided with the
19
+ distribution.
20
+
21
+ 3. Neither the name of Twilio nor the names of its contributors may
22
+ be used to endorse or promote products derived from this software
23
+ without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+
37
+ This software includes javascript-state-machine under the following license.
38
+
39
+ Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy
42
+ of this software and associated documentation files (the "Software"), to deal
43
+ in the Software without restriction, including without limitation the rights
44
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
+ copies of the Software, and to permit persons to whom the Software is
46
+ furnished to do so, subject to the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be included in all
49
+ copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57
+
58
+ This software includes loglevel under the following license.
59
+
60
+ Copyright (c) 2013 Tim Perry
61
+
62
+ Permission is hereby granted, free of charge, to any person
63
+ obtaining a copy of this software and associated documentation
64
+ files (the "Software"), to deal in the Software without
65
+ restriction, including without limitation the rights to use,
66
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
67
+ copies of the Software, and to permit persons to whom the
68
+ Software is furnished to do so, subject to the following
69
+ conditions:
70
+
71
+ The above copyright notice and this permission notice shall be
72
+ included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
75
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
76
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
77
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
78
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
79
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
80
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
81
+ OTHER DEALINGS IN THE SOFTWARE.
82
+
83
+ This software includes q under the following license.
84
+
85
+ Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to
88
+ deal in the Software without restriction, including without limitation the
89
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
90
+ sell copies of the Software, and to permit persons to whom the Software is
91
+ furnished to do so, subject to the following conditions:
92
+
93
+ The above copyright notice and this permission notice shall be included in
94
+ all copies or substantial portions of the Software.
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
101
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
102
+ IN THE SOFTWARE.
103
+
104
+ This software includes platform.js under the following license.
105
+
106
+ Copyright 2014 Benjamin Tan <https://d10.github.io/>
107
+ Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
108
+
109
+ Permission is hereby granted, free of charge, to any person obtaining
110
+ a copy of this software and associated documentation files (the
111
+ "Software"), to deal in the Software without restriction, including
112
+ without limitation the rights to use, copy, modify, merge, publish,
113
+ distribute, sublicense, and/or sell copies of the Software, and to
114
+ permit persons to whom the Software is furnished to do so, subject to
115
+ the following conditions:
116
+
117
+ The above copyright notice and this permission notice shall be
118
+ included in all copies or substantial portions of the Software.
119
+
120
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
121
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
123
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
124
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
125
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
126
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
+
128
+ */
129
+ var global =
130
+ typeof global !== "undefined"
131
+ ? global
132
+ : typeof self !== "undefined"
133
+ ? self
134
+ : typeof window !== "undefined"
135
+ ? window
136
+ : {};
137
+
138
+ import { custom, objectSchema, literal } from '@twilio/declarative-type-validator';
139
+
140
+ const json = custom((value) => [
141
+ ["string", "number", "boolean", "object"].includes(typeof value),
142
+ "a JSON type",
143
+ ]);
144
+ const optionalJson = custom((value) => [
145
+ ["undefined", "string", "number", "boolean", "object"].includes(typeof value),
146
+ "an optional JSON type",
147
+ ]);
148
+ const sendMediaOptions = objectSchema("send media options", {
149
+ contentType: [literal(null), "string"],
150
+ filename: ["string", "undefined"],
151
+ media: [
152
+ literal("null"),
153
+ "string",
154
+ ...(typeof Buffer === "function" ? [Buffer] : []),
155
+ ...(typeof Blob === "function" ? [Blob] : []),
156
+ ],
157
+ });
158
+
159
+ export { json, optionalJson, sendMediaOptions };
160
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sources":["../../src/interfaces/rules.ts"],"sourcesContent":["import {\n custom,\n literal,\n objectSchema,\n} from \"@twilio/declarative-type-validator\";\n\nexport const json = custom((value) => [\n [\"string\", \"number\", \"boolean\", \"object\"].includes(typeof value),\n \"a JSON type\",\n]);\n\nexport const optionalJson = custom((value) => [\n [\"undefined\", \"string\", \"number\", \"boolean\", \"object\"].includes(typeof value),\n \"an optional JSON type\",\n]);\n\nexport const sendMediaOptions = objectSchema(\"send media options\", {\n contentType: [literal(null), \"string\"],\n filename: [\"string\", \"undefined\"],\n media: [\n literal(\"null\"),\n \"string\",\n ...(typeof Buffer === \"function\" ? [Buffer] : []),\n ...(typeof Blob === \"function\" ? [Blob] : []),\n ],\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMa,MAAA,IAAI,GAAG,MAAM,CAAC,CAAC,KAAK,KAAK;AACpC,IAAA,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC;IAChE,aAAa;AACd,CAAA,EAAE;AAEU,MAAA,YAAY,GAAG,MAAM,CAAC,CAAC,KAAK,KAAK;AAC5C,IAAA,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC;IAC7E,uBAAuB;AACxB,CAAA,EAAE;AAEU,MAAA,gBAAgB,GAAG,YAAY,CAAC,oBAAoB,EAAE;IACjE,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;AACtC,IAAA,QAAQ,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;AACjC,IAAA,KAAK,EAAE;QACL,OAAO,CAAC,MAAM,CAAC;QACf,QAAQ;AACR,QAAA,IAAI,OAAO,MAAM,KAAK,UAAU,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;AACjD,QAAA,IAAI,OAAO,IAAI,KAAK,UAAU,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAC9C,KAAA;AACF,CAAA;;;;"}
package/dist/logger.js CHANGED
@@ -126,36 +126,21 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
130
-
131
- Object.defineProperty(exports, '__esModule', { value: true });
132
-
133
- var loglevelLog = require('loglevel');
134
-
135
- function _interopNamespace(e) {
136
- if (e && e.__esModule) return e;
137
- var n = Object.create(null);
138
- if (e) {
139
- Object.keys(e).forEach(function (k) {
140
- if (k !== 'default') {
141
- var d = Object.getOwnPropertyDescriptor(e, k);
142
- Object.defineProperty(n, k, d.get ? d : {
143
- enumerable: true,
144
- get: function () { return e[k]; }
145
- });
146
- }
147
- });
148
- }
149
- n["default"] = e;
150
- return Object.freeze(n);
151
- }
129
+ var global =
130
+ typeof global !== "undefined"
131
+ ? global
132
+ : typeof self !== "undefined"
133
+ ? self
134
+ : typeof window !== "undefined"
135
+ ? window
136
+ : {};
152
137
 
153
- var loglevelLog__namespace = /*#__PURE__*/_interopNamespace(loglevelLog);
138
+ import * as loglevelLog from 'loglevel';
154
139
 
155
140
  function prepareLine(prefix, args) {
156
141
  return [`${new Date().toISOString()} Conversations ${prefix}:`].concat(Array.from(args));
157
142
  }
158
- const log = loglevelLog__namespace.getLogger("twilio-conversations"); // twilio-conversations is used by Flex SDK. Please DO NOT change
143
+ const log = loglevelLog.getLogger("twilio-conversations"); // twilio-conversations is used by Flex SDK. Please DO NOT change
159
144
  class Logger {
160
145
  constructor(prefix) {
161
146
  this.prefix = "";
@@ -174,7 +159,9 @@ class Logger {
174
159
  log.setLevel(level);
175
160
  }
176
161
  trace(...args) {
177
- log.trace.apply(null, prepareLine(this.prefix + "T", args));
162
+ if (log.getLevel() == log.levels.TRACE) {
163
+ log.debug.apply(null, prepareLine(this.prefix + "T", args));
164
+ }
178
165
  }
179
166
  debug(...args) {
180
167
  log.debug.apply(null, prepareLine(this.prefix + "D", args));
@@ -189,7 +176,9 @@ class Logger {
189
176
  log.error.apply(null, prepareLine(this.prefix + "E", args));
190
177
  }
191
178
  static trace(...args) {
192
- log.trace.apply(null, prepareLine("T", args));
179
+ if (log.getLevel() == log.levels.TRACE) {
180
+ log.debug.apply(null, prepareLine("T", args));
181
+ }
193
182
  }
194
183
  static debug(...args) {
195
184
  log.debug.apply(null, prepareLine("D", args));
@@ -205,5 +194,5 @@ class Logger {
205
194
  }
206
195
  }
207
196
 
208
- exports.Logger = Logger;
197
+ export { Logger };
209
198
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sources":["../src/logger.ts"],"sourcesContent":["import * as loglevelLog from \"loglevel\";\nimport { LogLevelDesc } from \"loglevel\";\n\nfunction prepareLine(prefix, args) {\n return [`${new Date().toISOString()} Conversations ${prefix}:`].concat(\n Array.from(args)\n );\n}\n\nconst log: loglevelLog.Logger = loglevelLog.getLogger(\"twilio-conversations\"); // twilio-conversations is used by Flex SDK. Please DO NOT change\n\nclass Logger {\n private prefix = \"\";\n\n private constructor(prefix: string) {\n this.prefix =\n prefix !== null && prefix !== undefined && prefix.length > 0\n ? prefix + \" \"\n : \"\";\n }\n\n static scope(prefix: string): Logger {\n return new Logger(prefix);\n }\n\n setLevel(level: LogLevelDesc) {\n log.setLevel(level);\n }\n\n static setLevel(level: LogLevelDesc) {\n log.setLevel(level);\n }\n\n trace(...args) {\n log.trace.apply(null, prepareLine(this.prefix + \"T\", args));\n }\n\n debug(...args) {\n log.debug.apply(null, prepareLine(this.prefix + \"D\", args));\n }\n\n info(...args) {\n log.info.apply(null, prepareLine(this.prefix + \"I\", args));\n }\n\n warn(...args) {\n log.warn.apply(null, prepareLine(this.prefix + \"W\", args));\n }\n\n error(...args) {\n log.error.apply(null, prepareLine(this.prefix + \"E\", args));\n }\n\n static trace(...args) {\n log.trace.apply(null, prepareLine(\"T\", args));\n }\n\n static debug(...args) {\n log.debug.apply(null, prepareLine(\"D\", args));\n }\n\n static info(...args) {\n log.info.apply(null, prepareLine(\"I\", args));\n }\n\n static warn(...args) {\n log.warn.apply(null, prepareLine(\"W\", args));\n }\n\n static error(...args) {\n log.error.apply(null, prepareLine(\"E\", args));\n }\n}\n\nexport { Logger };\n"],"names":["loglevelLog"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,WAAW,CAAC,MAAM,EAAE,IAAI,EAAA;IAC/B,OAAO,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA,eAAA,EAAkB,MAAM,CAAA,CAAA,CAAG,CAAC,CAAC,MAA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\";\nimport { LogLevelDesc } from \"loglevel\";\n\nfunction prepareLine(prefix, args) {\n return [`${new Date().toISOString()} Conversations ${prefix}:`].concat(\n Array.from(args)\n );\n}\n\nconst log: loglevelLog.Logger = loglevelLog.getLogger(\"twilio-conversations\"); // twilio-conversations is used by Flex SDK. Please DO NOT change\n\nclass Logger {\n private prefix = \"\";\n\n private constructor(prefix: string) {\n this.prefix =\n prefix !== null && prefix !== undefined && prefix.length > 0\n ? prefix + \" \"\n : \"\";\n }\n\n static scope(prefix: string): Logger {\n return new Logger(prefix);\n }\n\n setLevel(level: LogLevelDesc) {\n log.setLevel(level);\n }\n\n static setLevel(level: LogLevelDesc) {\n log.setLevel(level);\n }\n\n trace(...args) {\n if (log.getLevel() == log.levels.TRACE) {\n log.debug.apply(null, prepareLine(this.prefix + \"T\", args));\n }\n }\n\n debug(...args) {\n log.debug.apply(null, prepareLine(this.prefix + \"D\", args));\n }\n\n info(...args) {\n log.info.apply(null, prepareLine(this.prefix + \"I\", args));\n }\n\n warn(...args) {\n log.warn.apply(null, prepareLine(this.prefix + \"W\", args));\n }\n\n error(...args) {\n log.error.apply(null, prepareLine(this.prefix + \"E\", args));\n }\n\n static trace(...args) {\n if (log.getLevel() == log.levels.TRACE) {\n log.debug.apply(null, prepareLine(\"T\", args));\n }\n }\n\n static debug(...args) {\n log.debug.apply(null, prepareLine(\"D\", args));\n }\n\n static info(...args) {\n log.info.apply(null, prepareLine(\"I\", args));\n }\n\n static warn(...args) {\n log.warn.apply(null, prepareLine(\"W\", args));\n }\n\n static error(...args) {\n log.error.apply(null, prepareLine(\"E\", args));\n }\n}\n\nexport { Logger };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,WAAW,CAAC,MAAM,EAAE,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