@twilio/conversations 3.0.1-rc.102 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +2 -2
  2. package/builds/browser.esm.js +10846 -0
  3. package/builds/browser.esm.js.map +1 -0
  4. package/builds/browser.js +891 -260
  5. package/builds/browser.js.map +1 -1
  6. package/builds/lib.d.ts +162 -52
  7. package/builds/lib.esm.d.ts +3178 -0
  8. package/builds/lib.esm.js +10845 -0
  9. package/builds/lib.js +900 -260
  10. package/builds/lib.js.map +1 -1
  11. package/builds/twilio-conversations.js +9407 -10424
  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 +1 -5
  16. package/dist/aggregated-delivery-receipt.js.map +1 -1
  17. package/dist/channel-metadata-client.js +5 -10
  18. package/dist/channel-metadata-client.js.map +1 -1
  19. package/dist/client.js +218 -204
  20. package/dist/client.js.map +1 -1
  21. package/dist/command-executor.js +6 -10
  22. package/dist/command-executor.js.map +1 -1
  23. package/dist/configuration.js +14 -14
  24. package/dist/configuration.js.map +1 -1
  25. package/dist/content-client.js +5 -9
  26. package/dist/content-client.js.map +1 -1
  27. package/dist/content-template.js +1 -7
  28. package/dist/content-template.js.map +1 -1
  29. package/dist/conversation.js +170 -134
  30. package/dist/conversation.js.map +1 -1
  31. package/dist/data/conversations.js +44 -46
  32. package/dist/data/conversations.js.map +1 -1
  33. package/dist/data/messages.js +18 -22
  34. package/dist/data/messages.js.map +1 -1
  35. package/dist/data/participants.js +22 -25
  36. package/dist/data/participants.js.map +1 -1
  37. package/dist/data/users.js +10 -14
  38. package/dist/data/users.js.map +1 -1
  39. package/dist/detailed-delivery-receipt.js +1 -5
  40. package/dist/detailed-delivery-receipt.js.map +1 -1
  41. package/dist/index.js +17 -46
  42. package/dist/index.js.map +1 -1
  43. package/dist/interfaces/notification-types.js +1 -5
  44. package/dist/interfaces/notification-types.js.map +1 -1
  45. package/dist/interfaces/rules.js +7 -13
  46. package/dist/interfaces/rules.js.map +1 -1
  47. package/dist/logger.js +9 -29
  48. package/dist/logger.js.map +1 -1
  49. package/dist/media.js +32 -25
  50. package/dist/media.js.map +1 -1
  51. package/dist/message-builder.js +43 -47
  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 +120 -98
  56. package/dist/message.js.map +1 -1
  57. package/dist/node_modules/quick-lru/index.js +1 -5
  58. package/dist/node_modules/quick-lru/index.js.map +1 -1
  59. package/dist/node_modules/tslib/tslib.es6.js +7 -6
  60. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  61. package/dist/packages/conversations/package.json.js +2 -6
  62. package/dist/packages/conversations/package.json.js.map +1 -1
  63. package/dist/participant.js +32 -37
  64. package/dist/participant.js.map +1 -1
  65. package/dist/push-notification.js +1 -5
  66. package/dist/push-notification.js.map +1 -1
  67. package/dist/rest-paginator.js +1 -5
  68. package/dist/rest-paginator.js.map +1 -1
  69. package/dist/services/network.js +3 -7
  70. package/dist/services/network.js.map +1 -1
  71. package/dist/services/typing-indicator.js +7 -10
  72. package/dist/services/typing-indicator.js.map +1 -1
  73. package/dist/unsent-message.js +5 -9
  74. package/dist/unsent-message.js.map +1 -1
  75. package/dist/user.js +21 -30
  76. package/dist/user.js.map +1 -1
  77. package/dist/util/deferred.js +1 -5
  78. package/dist/util/deferred.js.map +1 -1
  79. package/dist/util/index.js +36 -9
  80. package/dist/util/index.js.map +1 -1
  81. package/dist/utils/uuid.js +145 -0
  82. package/dist/utils/uuid.js.map +1 -0
  83. package/package.json +14 -17
  84. package/docs/assets/css/main.css +0 -2660
  85. package/docs/assets/images/icons.png +0 -0
  86. package/docs/assets/images/icons@2x.png +0 -0
  87. package/docs/assets/images/widgets.png +0 -0
  88. package/docs/assets/images/widgets@2x.png +0 -0
  89. package/docs/assets/js/main.js +0 -248
  90. package/docs/assets/js/search.js +0 -1
  91. package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
  92. package/docs/classes/CancellablePromise.html +0 -3213
  93. package/docs/classes/ChannelMetadata.html +0 -3050
  94. package/docs/classes/Client.html +0 -4278
  95. package/docs/classes/ContentTemplate.html +0 -3116
  96. package/docs/classes/ContentTemplateVariable.html +0 -3116
  97. package/docs/classes/Conversation.html +0 -4359
  98. package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
  99. package/docs/classes/Media.html +0 -3167
  100. package/docs/classes/Message.html +0 -3803
  101. package/docs/classes/MessageBuilder.html +0 -3318
  102. package/docs/classes/Participant.html +0 -3444
  103. package/docs/classes/PushNotification.html +0 -3130
  104. package/docs/classes/RestPaginator.html +0 -3160
  105. package/docs/classes/UnsentMessage.html +0 -3042
  106. package/docs/classes/User.html +0 -3349
  107. package/docs/index.html +0 -4333
  108. package/docs/interfaces/ClientOptions.html +0 -3050
  109. package/docs/interfaces/ConversationBindings.html +0 -3001
  110. package/docs/interfaces/ConversationEmailBinding.html +0 -3001
  111. package/docs/interfaces/ConversationLimits.html +0 -3098
  112. package/docs/interfaces/ConversationState.html +0 -3050
  113. package/docs/interfaces/ConversationUpdatedEventArgs.html +0 -3001
  114. package/docs/interfaces/CreateConversationOptions.html +0 -3066
  115. package/docs/interfaces/LastMessage.html +0 -3050
  116. package/docs/interfaces/Paginator.html +0 -3141
  117. package/docs/interfaces/ParticipantBindings.html +0 -3001
  118. package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
  119. package/docs/interfaces/PushNotificationData.html +0 -3114
  120. package/docs/interfaces/SendEmailOptions.html +0 -3034
  121. package/docs/interfaces/SendMediaOptions.html +0 -3068
  122. package/docs/modules.html +0 -4334
@@ -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;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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 (\n participant.identity !== message.identity &&\n participant.type !== \"apple\"\n ) {\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":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,GAAG,GAAG,MAAM,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,KA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128
128
  */
129
- 'use strict';
130
-
131
129
  var global =
132
130
  typeof global !== "undefined"
133
131
  ? global
@@ -137,10 +135,8 @@ var global =
137
135
  ? window
138
136
  : {};
139
137
 
140
- Object.defineProperty(exports, '__esModule', { value: true });
141
-
142
- var mcsClient = require('@twilio/mcs-client');
143
- var index = require('./util/index.js');
138
+ import { CancellablePromise } from '@twilio/mcs-client';
139
+ import { parseToNumber } from './util/index.js';
144
140
 
145
141
  /**
146
142
  * An unsent message. Returned from {@link MessageBuilder.build}.
@@ -160,12 +156,12 @@ class UnsentMessage {
160
156
  * @returns Index of the new message in the conversation.
161
157
  */
162
158
  send() {
163
- return new mcsClient.CancellablePromise(async (resolve, reject, onCancel) => {
159
+ return new CancellablePromise(async (resolve, reject, onCancel) => {
164
160
  const request = this.messagesEntity.sendV2(this);
165
161
  onCancel(() => request.cancel());
166
162
  try {
167
163
  const response = await request;
168
- resolve(index.parseToNumber(response.index));
164
+ resolve(parseToNumber(response.index));
169
165
  }
170
166
  catch (e) {
171
167
  reject(e);
@@ -174,5 +170,5 @@ class UnsentMessage {
174
170
  }
175
171
  }
176
172
 
177
- exports.UnsentMessage = UnsentMessage;
173
+ export { UnsentMessage };
178
174
  //# sourceMappingURL=unsent-message.js.map
@@ -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\";\nimport { ContentTemplateVariable } from \"./content-template\";\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 public contentSid?: string;\n public contentVariables?: ContentTemplateVariable[];\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;AAEG;AACH,MAAM,aAAa,CAAA;AAQjB;;AAEG;AACH,IAAA,WAAA,CAAoB,cAAwB,EAAA;QAAxB,IAAc,CAAA,cAAA,GAAd,cAAc,CAAU;QATrC,IAAU,CAAA,UAAA,GAAc,EAAE,CAAC;QAC3B,IAAY,CAAA,YAAA,GAAmD,EAAE,CAAC;QAClE,IAAY,CAAA,YAAA,GAAqB,EAAE,CAAC;KAOK;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 \"./types\";\nimport { Messages } from \"./data/messages\";\nimport { ContentTemplateVariable } from \"./content-template\";\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 public contentSid?: string;\n public contentVariables?: ContentTemplateVariable[];\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":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;AAEG;AACH,MAAM,aAAa,CAAA;AAQjB;;AAEG;AACH,IAAA,WAAA,CAAoB,cAAwB,EAAA;QAAxB,IAAc,CAAA,cAAA,GAAd,cAAc,CAAU;QATrC,IAAU,CAAA,UAAA,GAAc,EAAE,CAAC;QAC3B,IAAY,CAAA,YAAA,GAAmD,EAAE,CAAC;QAClE,IAAY,CAAA,YAAA,GAAqB,EAAE,CAAC;KAOK;AAEhD;;;AAGG;IACH,IAAI,GAAA;QACF,OAAO,IAAI,kBAAkB,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,CAAC,aAAa,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;;;;"}
package/dist/user.js CHANGED
@@ -126,8 +126,6 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
130
-
131
129
  var global =
132
130
  typeof global !== "undefined"
133
131
  ? global
@@ -137,28 +135,21 @@ var global =
137
135
  ? window
138
136
  : {};
139
137
 
140
- Object.defineProperty(exports, '__esModule', { value: true });
141
-
142
- var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
143
- var logger = require('./logger.js');
144
- var index = require('./util/index.js');
145
- var declarativeTypeValidator = require('@twilio/declarative-type-validator');
146
- var rules = require('./interfaces/rules.js');
147
- var replayEventEmitter = require('@twilio/replay-event-emitter');
148
- var isEqual = require('lodash.isequal');
149
-
150
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
151
-
152
- var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
138
+ import { __decorate, __metadata } from './node_modules/tslib/tslib.es6.js';
139
+ import { Logger } from './logger.js';
140
+ import { parseAttributes, isEqual } from './util/index.js';
141
+ import { validateTypesAsync } from '@twilio/declarative-type-validator';
142
+ import { json } from './interfaces/rules.js';
143
+ import { ReplayEventEmitter } from '@twilio/replay-event-emitter';
153
144
 
154
- const log = logger.Logger.scope("User");
145
+ const log = Logger.scope("User");
155
146
  /**
156
147
  * Extended user information.
157
148
  * Note that `isOnline` and `isNotifiable` properties are eligible
158
149
  * for use only if the reachability function is enabled.
159
150
  * You may check if it is enabled by reading the value of {@link Client.reachabilityEnabled}.
160
151
  */
161
- class User extends replayEventEmitter.ReplayEventEmitter {
152
+ class User extends ReplayEventEmitter {
162
153
  /**
163
154
  * @internal
164
155
  */
@@ -264,8 +255,8 @@ class User extends replayEventEmitter.ReplayEventEmitter {
264
255
  }
265
256
  break;
266
257
  case "attributes":
267
- const updateAttributes = index.parseAttributes(value.value, `Retrieved malformed attributes from the server for user: ${this.state.identity}`, log);
268
- if (!isEqual__default["default"](this.state.attributes, updateAttributes)) {
258
+ const updateAttributes = parseAttributes(value.value, `Retrieved malformed attributes from the server for user: ${this.state.identity}`, log);
259
+ if (!isEqual(this.state.attributes, updateAttributes)) {
269
260
  this.state.attributes = updateAttributes;
270
261
  updateReasons.push("attributes");
271
262
  }
@@ -419,18 +410,18 @@ class User extends replayEventEmitter.ReplayEventEmitter {
419
410
  }
420
411
  }
421
412
  }
422
- tslib_es6.__decorate([
423
- declarativeTypeValidator.validateTypesAsync(rules.json),
424
- tslib_es6.__metadata("design:type", Function),
425
- tslib_es6.__metadata("design:paramtypes", [Object]),
426
- tslib_es6.__metadata("design:returntype", Promise)
413
+ __decorate([
414
+ validateTypesAsync(json),
415
+ __metadata("design:type", Function),
416
+ __metadata("design:paramtypes", [Object]),
417
+ __metadata("design:returntype", Promise)
427
418
  ], User.prototype, "updateAttributes", null);
428
- tslib_es6.__decorate([
429
- declarativeTypeValidator.validateTypesAsync(["string"]),
430
- tslib_es6.__metadata("design:type", Function),
431
- tslib_es6.__metadata("design:paramtypes", [String]),
432
- tslib_es6.__metadata("design:returntype", Promise)
419
+ __decorate([
420
+ validateTypesAsync(["string"]),
421
+ __metadata("design:type", Function),
422
+ __metadata("design:paramtypes", [String]),
423
+ __metadata("design:returntype", Promise)
433
424
  ], User.prototype, "updateFriendlyName", null);
434
425
 
435
- exports.User = User;
426
+ export { User };
436
427
  //# sourceMappingURL=user.js.map
package/dist/user.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"user.js","sources":["../src/user.ts"],"sourcesContent":["import { Logger } from \"./logger\";\nimport { SyncClient } from \"twilio-sync\";\nimport { parseAttributes } from \"./util\";\nimport { validateTypesAsync } from \"@twilio/declarative-type-validator\";\nimport { json } from \"./interfaces/rules\";\nimport { Configuration } from \"./configuration\";\nimport { CommandExecutor } from \"./command-executor\";\nimport {\n EditUserRequest,\n EditUserResponse,\n} from \"./interfaces/commands/edit-user\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport isEqual from \"lodash.isequal\";\nimport { JSONValue } from \"./types\";\n\ntype UserEvents = {\n updated: (data: { user: User; updateReasons: UserUpdateReason[] }) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n};\n\nconst log = Logger.scope(\"User\");\n\ninterface UserState {\n identity: string;\n entityName: string;\n friendlyName: string | null;\n attributes: JSONValue;\n online: boolean | null;\n notifiable: boolean | null;\n}\n\ninterface UpdateValue {\n value: string;\n notifiable: boolean | null;\n online: boolean | null;\n}\n\ninterface UserServices {\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n}\n\ninterface UserLinks {\n self: string;\n}\n\ntype SubscriptionState = \"initializing\" | \"subscribed\" | \"unsubscribed\";\n\n/**\n * The reason for the `updated` event being emitted by a user.\n */\ntype UserUpdateReason =\n | \"friendlyName\"\n | \"attributes\"\n | \"reachabilityOnline\"\n | \"reachabilityNotifiable\";\n\ninterface UserUpdatedEventArgs {\n user: User;\n updateReasons: UserUpdateReason[];\n}\n\n/**\n * Extended user information.\n * Note that `isOnline` and `isNotifiable` properties are eligible\n * for use only if the reachability function is enabled.\n * You may check if it is enabled by reading the value of {@link Client.reachabilityEnabled}.\n */\nclass User extends ReplayEventEmitter<UserEvents> {\n private links!: UserLinks;\n private configuration!: Configuration;\n private readonly services: UserServices;\n\n private entity;\n private state: UserState;\n private promiseToFetch: Promise<User> | null = null;\n private subscribed: SubscriptionState;\n\n private _initializationPromise: Promise<void>;\n private _resolveInitializationPromise;\n\n /**\n * @internal\n */\n constructor(\n identity: string,\n entityName: string,\n configuration: Configuration | null,\n services: UserServices\n ) {\n super();\n\n this.services = services;\n\n this.subscribed = \"initializing\";\n this.setMaxListeners(0);\n\n this.state = {\n identity,\n entityName,\n friendlyName: null,\n attributes: {},\n online: null,\n notifiable: null,\n };\n\n this._initializationPromise = new Promise((resolve) => {\n this._resolveInitializationPromise = resolve;\n });\n\n if (configuration !== null) {\n this._resolveInitialization(configuration, identity, entityName, false);\n }\n }\n\n /**\n * Fired when the properties or the reachability status 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 User} `user` - the user in question\n * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n public readonly updated = \"updated\";\n\n /**\n * Fired when the client has subscribed to the user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n public readonly userSubscribed = \"userSubscribed\";\n\n /**\n * Fired when the client has unsubscribed from the user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n public readonly userUnsubscribed = \"userUnsubscribed\";\n\n /**\n * User identity.\n */\n public get identity(): string {\n return this.state.identity;\n }\n\n public set identity(identity: string) {\n this.state.identity = identity;\n }\n\n public set entityName(name: string) {\n this.state.entityName = name;\n }\n\n /**\n * Custom attributes of the user.\n */\n public get attributes() {\n return this.state.attributes;\n }\n\n /**\n * Friendly name of the user, null if not set.\n */\n public get friendlyName(): string | null {\n return this.state.friendlyName;\n }\n\n /**\n * Status of the real-time conversation connection of the user.\n */\n public get isOnline(): boolean | null {\n return this.state.online;\n }\n\n /**\n * User push notification registration status.\n */\n public get isNotifiable(): boolean | null {\n return this.state.notifiable;\n }\n\n /**\n * True if this user is receiving real-time status updates.\n */\n public get isSubscribed(): boolean {\n return this.subscribed == \"subscribed\";\n }\n\n // Handles service updates\n async _update(\n key: string,\n value: { value: string; notifiable: boolean | null; online: boolean | null }\n ) {\n await this._initializationPromise;\n\n const updateReasons: UserUpdateReason[] = [];\n log.debug(\"User for\", this.state.identity, \"updated:\", key, value);\n switch (key) {\n case \"friendlyName\":\n if (this.state.friendlyName !== value.value) {\n updateReasons.push(\"friendlyName\");\n this.state.friendlyName = value.value;\n }\n break;\n case \"attributes\":\n const updateAttributes = parseAttributes(\n value.value,\n `Retrieved malformed attributes from the server for user: ${this.state.identity}`,\n log\n );\n if (!isEqual(this.state.attributes, updateAttributes)) {\n this.state.attributes = updateAttributes;\n updateReasons.push(\"attributes\");\n }\n break;\n case \"reachability\":\n if (this.state.online !== value.online) {\n this.state.online = value.online;\n updateReasons.push(\"reachabilityOnline\");\n }\n if (this.state.notifiable !== value.notifiable) {\n this.state.notifiable = value.notifiable;\n updateReasons.push(\"reachabilityNotifiable\");\n }\n break;\n default:\n return;\n }\n if (updateReasons.length > 0) {\n this.emit(\"updated\", { user: this, updateReasons: updateReasons });\n }\n }\n\n // Fetch reachability info\n private async _updateReachabilityInfo(map, update) {\n await this._initializationPromise;\n\n if (!this.configuration.reachabilityEnabled) {\n return Promise.resolve();\n }\n\n return map\n .get(\"reachability\")\n .then(update)\n .catch((err) => {\n log.warn(\n \"Failed to get reachability info for \",\n this.state.identity,\n err\n );\n });\n }\n\n // Fetch user\n async _fetch(): Promise<User> {\n await this._initializationPromise;\n\n if (!this.state.entityName) {\n return this;\n }\n\n this.promiseToFetch = this.services.syncClient\n .map({\n id: this.state.entityName,\n mode: \"open_existing\",\n includeItems: true,\n })\n .then((map) => {\n this.entity = map;\n map.on(\"itemUpdated\", (args) => {\n log.debug(\n this.state.entityName +\n \" (\" +\n this.state.identity +\n \") itemUpdated: \" +\n args.item.key\n );\n return this._update(args.item.key, args.item.data);\n });\n map.on(\"itemAdded\", (args) => {\n log.debug(\n this.state.entityName +\n \" (\" +\n this.state.identity +\n \") itemAdded: \" +\n args.item.key\n );\n return this._update(args.item.key, args.item.data);\n });\n return Promise.all([\n map\n .get(\"friendlyName\")\n .then((item) => this._update(item.key, item.data as UpdateValue)),\n map\n .get(\"attributes\")\n .then((item) => this._update(item.key, item.data as UpdateValue)),\n this._updateReachabilityInfo(map, (item) =>\n this._update(item.key, item.data)\n ),\n ]);\n })\n .then(() => {\n log.debug(\"Fetched for\", this.identity);\n this.subscribed = \"subscribed\";\n this.emit(\"userSubscribed\", this);\n return this;\n })\n .catch((err) => {\n this.promiseToFetch = null;\n throw err;\n });\n return this.promiseToFetch;\n }\n\n async _ensureFetched() {\n await this._initializationPromise;\n return this.promiseToFetch || this._fetch();\n }\n\n /**\n * Edit user attributes.\n * @param attributes New attributes.\n */\n @validateTypesAsync(json)\n public async updateAttributes(attributes: JSONValue): Promise<User> {\n await this._initializationPromise;\n\n if (this.subscribed == \"unsubscribed\") {\n throw new Error(\"Can't modify unsubscribed object\");\n }\n\n await this.services.commandExecutor.mutateResource<\n EditUserRequest,\n EditUserResponse\n >(\"post\", this.links.self, {\n attributes: JSON.stringify(attributes),\n });\n\n return this;\n }\n\n /**\n * Update the friendly name of the user.\n * @param friendlyName New friendly name.\n */\n @validateTypesAsync([\"string\"])\n public async updateFriendlyName(friendlyName: string): Promise<User> {\n await this._initializationPromise;\n\n if (this.subscribed == \"unsubscribed\") {\n throw new Error(\"Can't modify unsubscribed object\");\n }\n\n await this.services.commandExecutor.mutateResource<\n EditUserRequest,\n EditUserResponse\n >(\"post\", this.links.self, {\n friendly_name: friendlyName,\n });\n\n return this;\n }\n\n /**\n * Remove the user from the subscription list.\n * @return A promise of completion.\n */\n async unsubscribe(): Promise<void> {\n await this._initializationPromise;\n\n if (this.promiseToFetch) {\n await this.promiseToFetch;\n this.entity.close();\n this.promiseToFetch = null;\n this.subscribed = \"unsubscribed\";\n this.emit(\"userUnsubscribed\", this);\n }\n }\n\n public _resolveInitialization(\n configuration: Configuration,\n identity: string,\n entityName: string,\n emitUpdated: boolean\n ): void {\n this.configuration = configuration;\n this.identity = identity;\n this.entityName = entityName;\n this.links = {\n self: `${this.configuration.links.users}/${encodeURIComponent(\n this.identity\n )}`,\n };\n this._resolveInitializationPromise();\n\n if (emitUpdated) {\n this.emit(\"updated\", {\n user: this,\n updateReasons: [\n \"friendlyName\",\n \"attributes\",\n \"reachabilityOnline\",\n \"reachabilityNotifiable\",\n ],\n });\n }\n }\n}\n\nexport {\n User,\n UserServices,\n SubscriptionState,\n UserUpdateReason,\n UserUpdatedEventArgs,\n};\n"],"names":["Logger","ReplayEventEmitter","parseAttributes","isEqual","__decorate","validateTypesAsync","json"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AA0CjC;;;;;AAKG;AACH,MAAM,IAAK,SAAQC,qCAA8B,CAAA;AAa/C;;AAEG;AACH,IAAA,WAAA,CACE,QAAgB,EAChB,UAAkB,EAClB,aAAmC,EACnC,QAAsB,EAAA;AAEtB,QAAA,KAAK,EAAE,CAAC;QAfF,IAAc,CAAA,cAAA,GAAyB,IAAI,CAAC;AAwCpD;;;;;;;;AAQG;QACa,IAAO,CAAA,OAAA,GAAG,SAAS,CAAC;AAEpC;;;;;;AAMG;QACa,IAAc,CAAA,cAAA,GAAG,gBAAgB,CAAC;AAElD;;;;;;AAMG;QACa,IAAgB,CAAA,gBAAA,GAAG,kBAAkB,CAAC;AAlDpD,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAEzB,QAAA,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC;AACjC,QAAA,IAAI,CAAC,eAAe,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K,CAAC,KAAK,CAAA,CAAA,EAAI,kBAAkB,CAC3D,IAAI,CAAC,QAAQ,CACd,CAAE,CAAA;SACJ,CAAC;QACF,IAAI,CAAC,6BAA6B,EAAE,CAAC;AAErC,QAAA,IAAI,WAAW,EAAE;AACf,YAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;AACnB,gBAAA,IAAI,EAAE,IAAI;AACV,gBAAA,aAAa,EAAE;oBACb,cAAc;oBACd,YAAY;oBACZ,oBAAoB;oBACpB,wBAAwB;AACzB,iBAAA;AACF,aAAA,CAAC,CAAC;AACJ,SAAA;KACF;AACF,CAAA;AAnFCC,oBAAA,CAAA;IADCC,2CAAkB,CAACC,UAAI,CAAC;;;;AAgBxB,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA,CAAA;AAODF,oBAAA,CAAA;AADC,IAAAC,2CAAkB,CAAC,CAAC,QAAQ,CAAC,CAAC;;;;AAgB9B,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"user.js","sources":["../src/user.ts"],"sourcesContent":["import { Logger } from \"./logger\";\nimport { SyncClient } from \"twilio-sync\";\nimport { parseAttributes } from \"./util\";\nimport { validateTypesAsync } from \"@twilio/declarative-type-validator\";\nimport { json } from \"./interfaces/rules\";\nimport { Configuration } from \"./configuration\";\nimport { CommandExecutor } from \"./command-executor\";\nimport {\n EditUserRequest,\n EditUserResponse,\n} from \"./interfaces/commands/edit-user\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { isEqual } from \"./util\";\nimport { JSONValue } from \"./types\";\n\ntype UserEvents = {\n updated: (data: { user: User; updateReasons: UserUpdateReason[] }) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n};\n\nconst log = Logger.scope(\"User\");\n\ninterface UserState {\n identity: string;\n entityName: string;\n friendlyName: string | null;\n attributes: JSONValue;\n online: boolean | null;\n notifiable: boolean | null;\n}\n\ninterface UpdateValue {\n value: string;\n notifiable: boolean | null;\n online: boolean | null;\n}\n\ninterface UserServices {\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n}\n\ninterface UserLinks {\n self: string;\n}\n\ntype SubscriptionState = \"initializing\" | \"subscribed\" | \"unsubscribed\";\n\n/**\n * The reason for the `updated` event being emitted by a user.\n */\ntype UserUpdateReason =\n | \"friendlyName\"\n | \"attributes\"\n | \"reachabilityOnline\"\n | \"reachabilityNotifiable\";\n\ninterface UserUpdatedEventArgs {\n user: User;\n updateReasons: UserUpdateReason[];\n}\n\n/**\n * Extended user information.\n * Note that `isOnline` and `isNotifiable` properties are eligible\n * for use only if the reachability function is enabled.\n * You may check if it is enabled by reading the value of {@link Client.reachabilityEnabled}.\n */\nclass User extends ReplayEventEmitter<UserEvents> {\n private links!: UserLinks;\n private configuration!: Configuration;\n private readonly services: UserServices;\n\n private entity;\n private state: UserState;\n private promiseToFetch: Promise<User> | null = null;\n private subscribed: SubscriptionState;\n\n private _initializationPromise: Promise<void>;\n private _resolveInitializationPromise;\n\n /**\n * @internal\n */\n constructor(\n identity: string,\n entityName: string,\n configuration: Configuration | null,\n services: UserServices\n ) {\n super();\n\n this.services = services;\n\n this.subscribed = \"initializing\";\n this.setMaxListeners(0);\n\n this.state = {\n identity,\n entityName,\n friendlyName: null,\n attributes: {},\n online: null,\n notifiable: null,\n };\n\n this._initializationPromise = new Promise((resolve) => {\n this._resolveInitializationPromise = resolve;\n });\n\n if (configuration !== null) {\n this._resolveInitialization(configuration, identity, entityName, false);\n }\n }\n\n /**\n * Fired when the properties or the reachability status 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 User} `user` - the user in question\n * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update\n * @event\n */\n public readonly updated = \"updated\";\n\n /**\n * Fired when the client has subscribed to the user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n public readonly userSubscribed = \"userSubscribed\";\n\n /**\n * Fired when the client has unsubscribed from the user.\n *\n * Parameters:\n * 1. {@link User} `user` - the user in question\n * @event\n */\n public readonly userUnsubscribed = \"userUnsubscribed\";\n\n /**\n * User identity.\n */\n public get identity(): string {\n return this.state.identity;\n }\n\n public set identity(identity: string) {\n this.state.identity = identity;\n }\n\n public set entityName(name: string) {\n this.state.entityName = name;\n }\n\n /**\n * Custom attributes of the user.\n */\n public get attributes() {\n return this.state.attributes;\n }\n\n /**\n * Friendly name of the user, null if not set.\n */\n public get friendlyName(): string | null {\n return this.state.friendlyName;\n }\n\n /**\n * Status of the real-time conversation connection of the user.\n */\n public get isOnline(): boolean | null {\n return this.state.online;\n }\n\n /**\n * User push notification registration status.\n */\n public get isNotifiable(): boolean | null {\n return this.state.notifiable;\n }\n\n /**\n * True if this user is receiving real-time status updates.\n */\n public get isSubscribed(): boolean {\n return this.subscribed == \"subscribed\";\n }\n\n // Handles service updates\n async _update(\n key: string,\n value: { value: string; notifiable: boolean | null; online: boolean | null }\n ) {\n await this._initializationPromise;\n\n const updateReasons: UserUpdateReason[] = [];\n log.debug(\"User for\", this.state.identity, \"updated:\", key, value);\n switch (key) {\n case \"friendlyName\":\n if (this.state.friendlyName !== value.value) {\n updateReasons.push(\"friendlyName\");\n this.state.friendlyName = value.value;\n }\n break;\n case \"attributes\":\n const updateAttributes = parseAttributes(\n value.value,\n `Retrieved malformed attributes from the server for user: ${this.state.identity}`,\n log\n );\n if (!isEqual(this.state.attributes, updateAttributes)) {\n this.state.attributes = updateAttributes;\n updateReasons.push(\"attributes\");\n }\n break;\n case \"reachability\":\n if (this.state.online !== value.online) {\n this.state.online = value.online;\n updateReasons.push(\"reachabilityOnline\");\n }\n if (this.state.notifiable !== value.notifiable) {\n this.state.notifiable = value.notifiable;\n updateReasons.push(\"reachabilityNotifiable\");\n }\n break;\n default:\n return;\n }\n if (updateReasons.length > 0) {\n this.emit(\"updated\", { user: this, updateReasons: updateReasons });\n }\n }\n\n // Fetch reachability info\n private async _updateReachabilityInfo(map, update) {\n await this._initializationPromise;\n\n if (!this.configuration.reachabilityEnabled) {\n return Promise.resolve();\n }\n\n return map\n .get(\"reachability\")\n .then(update)\n .catch((err) => {\n log.warn(\n \"Failed to get reachability info for \",\n this.state.identity,\n err\n );\n });\n }\n\n // Fetch user\n async _fetch(): Promise<User> {\n await this._initializationPromise;\n\n if (!this.state.entityName) {\n return this;\n }\n\n this.promiseToFetch = this.services.syncClient\n .map({\n id: this.state.entityName,\n mode: \"open_existing\",\n includeItems: true,\n })\n .then((map) => {\n this.entity = map;\n map.on(\"itemUpdated\", (args) => {\n log.debug(\n this.state.entityName +\n \" (\" +\n this.state.identity +\n \") itemUpdated: \" +\n args.item.key\n );\n return this._update(args.item.key, args.item.data);\n });\n map.on(\"itemAdded\", (args) => {\n log.debug(\n this.state.entityName +\n \" (\" +\n this.state.identity +\n \") itemAdded: \" +\n args.item.key\n );\n return this._update(args.item.key, args.item.data);\n });\n return Promise.all([\n map\n .get(\"friendlyName\")\n .then((item) => this._update(item.key, item.data as UpdateValue)),\n map\n .get(\"attributes\")\n .then((item) => this._update(item.key, item.data as UpdateValue)),\n this._updateReachabilityInfo(map, (item) =>\n this._update(item.key, item.data)\n ),\n ]);\n })\n .then(() => {\n log.debug(\"Fetched for\", this.identity);\n this.subscribed = \"subscribed\";\n this.emit(\"userSubscribed\", this);\n return this;\n })\n .catch((err) => {\n this.promiseToFetch = null;\n throw err;\n });\n return this.promiseToFetch;\n }\n\n async _ensureFetched() {\n await this._initializationPromise;\n return this.promiseToFetch || this._fetch();\n }\n\n /**\n * Edit user attributes.\n * @param attributes New attributes.\n */\n @validateTypesAsync(json)\n public async updateAttributes(attributes: JSONValue): Promise<User> {\n await this._initializationPromise;\n\n if (this.subscribed == \"unsubscribed\") {\n throw new Error(\"Can't modify unsubscribed object\");\n }\n\n await this.services.commandExecutor.mutateResource<\n EditUserRequest,\n EditUserResponse\n >(\"post\", this.links.self, {\n attributes: JSON.stringify(attributes),\n });\n\n return this;\n }\n\n /**\n * Update the friendly name of the user.\n * @param friendlyName New friendly name.\n */\n @validateTypesAsync([\"string\"])\n public async updateFriendlyName(friendlyName: string): Promise<User> {\n await this._initializationPromise;\n\n if (this.subscribed == \"unsubscribed\") {\n throw new Error(\"Can't modify unsubscribed object\");\n }\n\n await this.services.commandExecutor.mutateResource<\n EditUserRequest,\n EditUserResponse\n >(\"post\", this.links.self, {\n friendly_name: friendlyName,\n });\n\n return this;\n }\n\n /**\n * Remove the user from the subscription list.\n * @return A promise of completion.\n */\n async unsubscribe(): Promise<void> {\n await this._initializationPromise;\n\n if (this.promiseToFetch) {\n await this.promiseToFetch;\n this.entity.close();\n this.promiseToFetch = null;\n this.subscribed = \"unsubscribed\";\n this.emit(\"userUnsubscribed\", this);\n }\n }\n\n public _resolveInitialization(\n configuration: Configuration,\n identity: string,\n entityName: string,\n emitUpdated: boolean\n ): void {\n this.configuration = configuration;\n this.identity = identity;\n this.entityName = entityName;\n this.links = {\n self: `${this.configuration.links.users}/${encodeURIComponent(\n this.identity\n )}`,\n };\n this._resolveInitializationPromise();\n\n if (emitUpdated) {\n this.emit(\"updated\", {\n user: this,\n updateReasons: [\n \"friendlyName\",\n \"attributes\",\n \"reachabilityOnline\",\n \"reachabilityNotifiable\",\n ],\n });\n }\n }\n}\n\nexport {\n User,\n UserServices,\n SubscriptionState,\n UserUpdateReason,\n UserUpdatedEventArgs,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AA0CjC;;;;;AAKG;AACH,MAAM,IAAK,SAAQ,kBAA8B,CAAA;AAa/C;;AAEG;AAC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,CAAC;AAC3B,YAAA,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC;AACjC,YAAA,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;AACrC,SAAA;KACF;AAEM,IAAA,sBAAsB,CAC3B,aAA4B,EAC5B,QAAgB,EAChB,UAAkB,EAClB,WAAoB,EAAA;AAEpB,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG;AACX,YAAA,IAAI,EAAE,CAAG,EAAA,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAA,CAAA,EAAI,kBAAkB,CAC3D,IAAI,CAAC,QAAQ,CACd,CAAE,CAAA;SACJ,CAAC;QACF,IAAI,CAAC,6BAA6B,EAAE,CAAC;AAErC,QAAA,IAAI,WAAW,EAAE;AACf,YAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;AACnB,gBAAA,IAAI,EAAE,IAAI;AACV,gBAAA,aAAa,EAAE;oBACb,cAAc;oBACd,YAAY;oBACZ,oBAAoB;oBACpB,wBAAwB;AACzB,iBAAA;AACF,aAAA,CAAC,CAAC;AACJ,SAAA;KACF;AACF,CAAA;AAnFC,UAAA,CAAA;IADC,kBAAkB,CAAC,IAAI,CAAC;;;;AAgBxB,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,IAAA,CAAA,CAAA;AAOD,UAAA,CAAA;AADC,IAAA,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAC;;;;AAgB9B,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,IAAA,CAAA;;;;"}
@@ -126,8 +126,6 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
130
-
131
129
  var global =
132
130
  typeof global !== "undefined"
133
131
  ? global
@@ -137,8 +135,6 @@ var global =
137
135
  ? window
138
136
  : {};
139
137
 
140
- Object.defineProperty(exports, '__esModule', { value: true });
141
-
142
138
  class Deferred {
143
139
  constructor() {
144
140
  this._promise = new Promise((resolve, reject) => {
@@ -161,5 +157,5 @@ class Deferred {
161
157
  }
162
158
  }
163
159
 
164
- exports.Deferred = Deferred;
160
+ export { Deferred };
165
161
  //# sourceMappingURL=deferred.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deferred.js","sources":["../../src/util/deferred.ts"],"sourcesContent":["class Deferred<T> {\n private _promise: Promise<T>;\n private _resolve;\n private _reject;\n\n public current!: T;\n\n constructor() {\n this._promise = new Promise<T>((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n }\n\n public get promise(): Promise<T> {\n return this._promise;\n }\n\n update(value: T) {\n this._resolve(value);\n }\n\n set(value: T) {\n this.current = value;\n this._resolve(value);\n }\n\n fail(e) {\n this._reject(e);\n }\n}\n\nexport { Deferred };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,QAAQ,CAAA;AAOZ,IAAA,WAAA,GAAA;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,KAAI;AACjD,YAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;AACxB,YAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;AACxB,SAAC,CAAC,CAAC;KACJ;AAED,IAAA,IAAW,OAAO,GAAA;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;KACtB;AAED,IAAA,MAAM,CAAC,KAAQ,EAAA;AACb,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KACtB;AAED,IAAA,GAAG,CAAC,KAAQ,EAAA;AACV,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;AACrB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KACtB;AAED,IAAA,IAAI,CAAC,CAAC,EAAA;AACJ,QAAA,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KACjB;AACF;;;;"}
1
+ {"version":3,"file":"deferred.js","sources":["../../src/util/deferred.ts"],"sourcesContent":["class Deferred<T> {\n private _promise: Promise<T>;\n private _resolve;\n private _reject;\n\n public current!: T;\n\n constructor() {\n this._promise = new Promise<T>((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n }\n\n public get promise(): Promise<T> {\n return this._promise;\n }\n\n update(value: T) {\n this._resolve(value);\n }\n\n set(value: T) {\n this.current = value;\n this._resolve(value);\n }\n\n fail(e) {\n this._reject(e);\n }\n}\n\nexport { Deferred };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,QAAQ,CAAA;AAOZ,IAAA,WAAA,GAAA;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,KAAI;AACjD,YAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;AACxB,YAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;AACxB,SAAC,CAAC,CAAC;KACJ;AAED,IAAA,IAAW,OAAO,GAAA;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;KACtB;AAED,IAAA,MAAM,CAAC,KAAQ,EAAA;AACb,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KACtB;AAED,IAAA,GAAG,CAAC,KAAQ,EAAA;AACV,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;AACrB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KACtB;AAED,IAAA,IAAI,CAAC,CAAC,EAAA;AACJ,QAAA,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KACjB;AACF;;;;"}
@@ -126,8 +126,6 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- 'use strict';
130
-
131
129
  var global =
132
130
  typeof global !== "undefined"
133
131
  ? global
@@ -137,8 +135,6 @@ var global =
137
135
  ? window
138
136
  : {};
139
137
 
140
- Object.defineProperty(exports, '__esModule', { value: true });
141
-
142
138
  /**
143
139
  * Deep-clone an object. Note that this does not work on object containing
144
140
  * functions.
@@ -206,10 +202,41 @@ class UriBuilder {
206
202
  return result;
207
203
  }
208
204
  }
205
+ /**
206
+ * Deep equality check for objects
207
+ * @param a - first value to compare
208
+ * @param b - second value to compare
209
+ * @returns true if values are deeply equal
210
+ */
211
+ function isEqual(a, b) {
212
+ if (a === b) {
213
+ return true;
214
+ }
215
+ if (a === null || b === null || a === undefined || b === undefined) {
216
+ return a === b;
217
+ }
218
+ if (typeof a !== typeof b) {
219
+ return false;
220
+ }
221
+ if (typeof a !== "object") {
222
+ return a === b;
223
+ }
224
+ if (Array.isArray(a) && Array.isArray(b)) {
225
+ if (a.length !== b.length) {
226
+ return false;
227
+ }
228
+ return a.every((item, index) => isEqual(item, b[index]));
229
+ }
230
+ if (Array.isArray(a) || Array.isArray(b)) {
231
+ return false;
232
+ }
233
+ const aKeys = Object.keys(a);
234
+ const bKeys = Object.keys(b);
235
+ if (aKeys.length !== bKeys.length) {
236
+ return false;
237
+ }
238
+ return aKeys.every((key) => isEqual(a[key], b[key]));
239
+ }
209
240
 
210
- exports.UriBuilder = UriBuilder;
211
- exports.deepClone = deepClone;
212
- exports.parseAttributes = parseAttributes;
213
- exports.parseTime = parseTime;
214
- exports.parseToNumber = parseToNumber;
241
+ export { UriBuilder, deepClone, isEqual, parseAttributes, parseTime, parseToNumber };
215
242
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/util/index.ts"],"sourcesContent":["import { Logger } from \"../logger\";\nimport { JSONValue } from \"../types\";\n\n/**\n * Deep-clone an object. Note that this does not work on object containing\n * functions.\n * @param {object} obj - the object to deep-clone\n * @returns {object}\n */\nfunction deepClone<T>(obj: T): T {\n return JSON.parse(JSON.stringify(obj)) as T;\n}\n\nfunction parseToNumber(value) {\n if (typeof value !== \"undefined\" && !isNaN(Number(value))) {\n return Number(value);\n }\n return null;\n}\n\n// timeString cannot be typed `string` because in member.ts\n// call to parseTime(data.lastReadTimestamp) uses number not a string for timestamp.\nfunction parseTime(timeString): Date | null {\n try {\n return new Date(timeString);\n } catch (e) {\n return null;\n }\n}\n\nfunction parseAttributes(\n rawAttributes,\n warningMessage: string,\n log: Logger\n): JSONValue {\n let attributes = {};\n if (rawAttributes) {\n try {\n attributes = JSON.parse(rawAttributes);\n } catch (e) {\n log.warn(warningMessage, e);\n }\n }\n\n return attributes;\n}\n\n/**\n * Construct URI with query parameters\n */\nclass UriBuilder {\n private base: string;\n private args: string[];\n private paths: string[];\n\n constructor(base: string) {\n this.base = base.replace(/\\/$/, \"\");\n this.args = [];\n this.paths = [];\n }\n\n public arg(name: string, value: string | number | boolean): UriBuilder {\n if (typeof value !== \"undefined\") {\n this.args.push(\n encodeURIComponent(name) + \"=\" + encodeURIComponent(value)\n );\n }\n return this;\n }\n\n public path(name: string): UriBuilder {\n this.paths.push(encodeURIComponent(name));\n return this;\n }\n\n public build(): string {\n let result = this.base;\n if (this.paths.length) {\n result += \"/\" + this.paths.join(\"/\");\n }\n\n if (this.args.length) {\n result += \"?\" + this.args.join(\"&\");\n }\n return result;\n }\n}\n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AAKd,IAAA,WAAA,CAAY,IAAY,EAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACpC,QAAA,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;AACf,QAAA,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;KACjB;IAEM,GAAG,CAAC,IAAY,EAAE,KAAgC,EAAA;AACvD,QAAA,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AAChC,YAAA,IAAI,CAAC,IAAI,CAAC,IAAI,CACZ,kBAAkB,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAC3D,CAAC;AACH,SAAA;AACD,QAAA,OAAO,IAAI,CAAC;KACb;AAEM,IAAA,IAAI,CAAC,IAAY,EAAA;QACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1C,QAAA,OAAO,IAAI,CAAC;KACb;IAEM,KAAK,GAAA;AACV,QAAA,IAAI,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC;AACvB,QAAA,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACrB,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtC,SAAA;AAED,QAAA,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACpB,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,SAAA;AACD,QAAA,OAAO,MAAM,CAAC;KACf;AACF;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/util/index.ts"],"sourcesContent":["import { Logger } from \"../logger\";\nimport { JSONValue } from \"../types\";\n\n/**\n * Deep-clone an object. Note that this does not work on object containing\n * functions.\n * @param {object} obj - the object to deep-clone\n * @returns {object}\n */\nfunction deepClone<T>(obj: T): T {\n return JSON.parse(JSON.stringify(obj)) as T;\n}\n\nfunction parseToNumber(value) {\n if (typeof value !== \"undefined\" && !isNaN(Number(value))) {\n return Number(value);\n }\n return null;\n}\n\n// timeString cannot be typed `string` because in member.ts\n// call to parseTime(data.lastReadTimestamp) uses number not a string for timestamp.\nfunction parseTime(timeString): Date | null {\n try {\n return new Date(timeString);\n } catch (e) {\n return null;\n }\n}\n\nfunction parseAttributes(\n rawAttributes,\n warningMessage: string,\n log: Logger\n): JSONValue {\n let attributes = {};\n if (rawAttributes) {\n try {\n attributes = JSON.parse(rawAttributes);\n } catch (e) {\n log.warn(warningMessage, e);\n }\n }\n\n return attributes;\n}\n\n/**\n * Construct URI with query parameters\n */\nclass UriBuilder {\n private base: string;\n private args: string[];\n private paths: string[];\n\n constructor(base: string) {\n this.base = base.replace(/\\/$/, \"\");\n this.args = [];\n this.paths = [];\n }\n\n public arg(\n name: string,\n value: string | number | boolean | undefined\n ): UriBuilder {\n if (typeof value !== \"undefined\") {\n this.args.push(\n encodeURIComponent(name) + \"=\" + encodeURIComponent(value)\n );\n }\n return this;\n }\n\n public path(name: string): UriBuilder {\n this.paths.push(encodeURIComponent(name));\n return this;\n }\n\n public build(): string {\n let result = this.base;\n if (this.paths.length) {\n result += \"/\" + this.paths.join(\"/\");\n }\n\n if (this.args.length) {\n result += \"?\" + this.args.join(\"&\");\n }\n return result;\n }\n}\n\n/**\n * Deep equality check for objects\n * @param a - first value to compare\n * @param b - second value to compare\n * @returns true if values are deeply equal\n */\nfunction isEqual(a: unknown, b: unknown): boolean {\n if (a === b) {\n return true;\n }\n\n if (a === null || b === null || a === undefined || b === undefined) {\n return a === b;\n }\n\n if (typeof a !== typeof b) {\n return false;\n }\n\n if (typeof a !== \"object\") {\n return a === b;\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n return a.every((item, index) => isEqual(item, b[index]));\n }\n\n if (Array.isArray(a) || Array.isArray(b)) {\n return false;\n }\n\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n return aKeys.every((key) =>\n isEqual(\n (a as Record<string, unknown>)[key],\n (b as Record<string, unknown>)[key]\n )\n );\n}\n\nexport {\n deepClone,\n UriBuilder,\n parseToNumber,\n parseTime,\n parseAttributes,\n isEqual,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;AAKG;AACH,SAAS,SAAS,CAAI,GAAM,EAAA;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAM,CAAC;AAC9C,CAAC;AAED,SAAS,aAAa,CAAC,KAAK,EAAA;AAC1B,IAAA,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;AACzD,QAAA,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACtB,KAAA;AACD,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAED;AACA;AACA,SAAS,SAAS,CAAC,UAAU,EAAA;IAC3B,IAAI;AACF,QAAA,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC7B,KAAA;AAAC,IAAA,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;AACH,CAAC;AAED,SAAS,eAAe,CACtB,aAAa,EACb,cAAsB,EACtB,GAAW,EAAA;IAEX,IAAI,UAAU,GAAG,EAAE,CAAC;AACpB,IAAA,IAAI,aAAa,EAAE;QACjB,IAAI;AACF,YAAA,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;A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KAAK,CAAC;AACd,KAAA;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,KACrB,OAAO,CACJ,CAA6B,CAAC,GAAG,CAAC,EAClC,CAA6B,CAAC,GAAG,CAAC,CACpC,CACF,CAAC;AACJ;;;;"}
@@ -0,0 +1,145 @@
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
+ /**
139
+ * Generate a random UUID using the Web Crypto API.
140
+ * Available in Node.js 14.17+, modern browsers, and React Native.
141
+ */
142
+ const randomUUID = () => crypto.randomUUID();
143
+
144
+ export { randomUUID };
145
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.js","sources":["../../src/utils/uuid.ts"],"sourcesContent":["/**\n * Generate a random UUID using the Web Crypto API.\n * Available in Node.js 14.17+, modern browsers, and React Native.\n */\nexport const randomUUID = (): string =>\n (crypto as unknown as { randomUUID(): string }).randomUUID();\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAGG;AACU,MAAA,UAAU,GAAG,MACvB,MAA8C,CAAC,UAAU;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twilio/conversations",
3
- "version": "3.0.1-rc.102",
3
+ "version": "3.0.1",
4
4
  "description": "Twilio Conversations client library",
5
5
  "main": "./builds/lib.js",
6
6
  "browser": "./builds/browser.js",
@@ -36,22 +36,19 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.17.0",
39
- "@twilio/declarative-type-validator": "^0.2.5",
40
- "@twilio/deprecation-decorator": "^0.2.3",
41
- "@twilio/mcs-client": "^0.6.5",
42
- "@twilio/notifications": "^2.0.4",
43
- "@twilio/operation-retrier": "^4.0.13",
44
- "@twilio/replay-event-emitter": "^0.3.5",
39
+ "@twilio/declarative-type-validator": "^1.0.0",
40
+ "@twilio/deprecation-decorator": "^1.0.0",
41
+ "@twilio/mcs-client": "^1.0.1",
42
+ "@twilio/notifications": "^3.0.2",
43
+ "@twilio/operation-retrier": "^5.0.0",
44
+ "@twilio/replay-event-emitter": "^1.0.0",
45
45
  "core-js": "^3.17.3",
46
46
  "iso8601-duration": "=1.2.0",
47
- "isomorphic-form-data": "^2.0.0",
48
- "lodash.isequal": "^4.5.0",
49
47
  "loglevel": "^1.8.0",
50
48
  "platform": "^1.3.6",
51
49
  "quick-lru": "^5.1.1",
52
- "twilio-sync": "~3.1.0",
53
- "twilsock": "~0.12.2",
54
- "uuid": "^3.4.0",
50
+ "twilio-sync": "^4.0.1",
51
+ "twilsock": "^1.0.2",
55
52
  "xmlhttprequest": "^1.8.0"
56
53
  },
57
54
  "devDependencies": {
@@ -66,9 +63,8 @@
66
63
  "@types/chai": "^4.2.5",
67
64
  "@types/chai-as-promised": "^7.1.2",
68
65
  "@types/chai-string": "^1.4.1",
69
- "@types/lodash.isequal": "^4.5.5",
70
66
  "@types/mocha": "^5.2.7",
71
- "@types/node": "^12.12.12",
67
+ "@types/node": "~20.1.0",
72
68
  "@types/sinon": "^10.0.0",
73
69
  "@types/sinon-chai": "^3.2.2",
74
70
  "@typescript-eslint/eslint-plugin": "^5.51.0",
@@ -76,7 +72,7 @@
76
72
  "async": "^3.0.1",
77
73
  "async-test-tools": "^1.0.7",
78
74
  "backoff": "^2.5.0",
79
- "browserslist": "4.21.7",
75
+ "browserslist": "^4",
80
76
  "chai": "^4.2.0",
81
77
  "chai-as-promised": "^7.1.1",
82
78
  "chai-spies": "^1.0.0",
@@ -89,6 +85,7 @@
89
85
  "eslint-plugin-prettier": "4.0.0",
90
86
  "fancy-log": "^1.3.3",
91
87
  "fs": "0.0.2",
88
+ "isomorphic-fetch": "^3.0.0",
92
89
  "mocha": "^6.2.2",
93
90
  "mocha.parallel": "^0.15.6",
94
91
  "node-fetch": "^2.6.1",
@@ -104,13 +101,13 @@
104
101
  "sinon-chai": "^3.3.0",
105
102
  "ts-node": "^8.5.2",
106
103
  "tslib": "^2.4.0",
107
- "twilio": "^3.37.1",
104
+ "twilio": "^5.13.1",
108
105
  "typedoc": "^0.21.4",
109
106
  "typescript": "^4.3.2",
110
107
  "typescript-strict-plugin": "1.1.2"
111
108
  },
112
109
  "engines": {
113
- "node": ">=14"
110
+ "node": ">=20"
114
111
  },
115
112
  "browserslist": [
116
113
  "IE 11",