@twilio/conversations 2.0.1-rc.5 → 2.0.1-rc.9

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 (95) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/{dist → builds}/browser.js +1 -1
  3. package/{dist → builds}/browser.js.map +0 -0
  4. package/{dist → builds}/lib.d.ts +0 -0
  5. package/{dist → builds}/lib.js +1 -1
  6. package/{dist → builds}/lib.js.map +0 -0
  7. package/{dist → builds}/twilio-conversations.js +8 -188
  8. package/{dist → builds}/twilio-conversations.min.js +2 -2
  9. package/dist/aggregated-delivery-receipt.js +227 -0
  10. package/dist/aggregated-delivery-receipt.js.map +1 -0
  11. package/dist/client.js +872 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/command-executor.js +203 -0
  14. package/dist/command-executor.js.map +1 -0
  15. package/dist/configuration.js +196 -0
  16. package/dist/configuration.js.map +1 -0
  17. package/dist/conversation.js +973 -0
  18. package/dist/conversation.js.map +1 -0
  19. package/dist/data/conversations.js +443 -0
  20. package/dist/data/conversations.js.map +1 -0
  21. package/dist/data/messages.js +341 -0
  22. package/dist/data/messages.js.map +1 -0
  23. package/dist/data/participants.js +313 -0
  24. package/dist/data/participants.js.map +1 -0
  25. package/dist/data/users.js +228 -0
  26. package/dist/data/users.js.map +1 -0
  27. package/dist/detailed-delivery-receipt.js +154 -0
  28. package/dist/detailed-delivery-receipt.js.map +1 -0
  29. package/dist/index.js +167 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/interfaces/notification-types.js +143 -0
  32. package/dist/interfaces/notification-types.js.map +1 -0
  33. package/dist/logger.js +190 -0
  34. package/dist/logger.js.map +1 -0
  35. package/dist/media.js +213 -0
  36. package/dist/media.js.map +1 -0
  37. package/dist/message-builder.js +209 -0
  38. package/dist/message-builder.js.map +1 -0
  39. package/dist/message.js +450 -0
  40. package/dist/message.js.map +1 -0
  41. package/dist/node_modules/tslib/tslib.es6.js +161 -0
  42. package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
  43. package/dist/packages/conversations/package.json.js +136 -0
  44. package/dist/packages/conversations/package.json.js.map +1 -0
  45. package/dist/participant.js +346 -0
  46. package/dist/participant.js.map +1 -0
  47. package/dist/push-notification.js +152 -0
  48. package/dist/push-notification.js.map +1 -0
  49. package/dist/rest-paginator.js +175 -0
  50. package/dist/rest-paginator.js.map +1 -0
  51. package/dist/services/network.js +205 -0
  52. package/dist/services/network.js.map +1 -0
  53. package/dist/services/typing-indicator.js +235 -0
  54. package/dist/services/typing-indicator.js.map +1 -0
  55. package/dist/unsent-message.js +159 -0
  56. package/dist/unsent-message.js.map +1 -0
  57. package/dist/user.js +392 -0
  58. package/dist/user.js.map +1 -0
  59. package/dist/util/deferred.js +154 -0
  60. package/dist/util/deferred.js.map +1 -0
  61. package/dist/util/index.js +206 -0
  62. package/dist/util/index.js.map +1 -0
  63. package/{dist/docs → docs}/assets/css/main.css +0 -0
  64. package/{dist/docs → docs}/assets/images/icons.png +0 -0
  65. package/{dist/docs → docs}/assets/images/icons@2x.png +0 -0
  66. package/{dist/docs → docs}/assets/images/widgets.png +0 -0
  67. package/{dist/docs → docs}/assets/images/widgets@2x.png +0 -0
  68. package/{dist/docs → docs}/assets/js/main.js +0 -0
  69. package/{dist/docs → docs}/assets/js/search.js +0 -0
  70. package/{dist/docs → docs}/classes/AggregatedDeliveryReceipt.html +0 -0
  71. package/{dist/docs → docs}/classes/Client.html +0 -0
  72. package/{dist/docs → docs}/classes/Conversation.html +0 -0
  73. package/{dist/docs → docs}/classes/DetailedDeliveryReceipt.html +0 -0
  74. package/{dist/docs → docs}/classes/Media.html +0 -0
  75. package/{dist/docs → docs}/classes/Message.html +0 -0
  76. package/{dist/docs → docs}/classes/MessageBuilder.html +0 -0
  77. package/{dist/docs → docs}/classes/Participant.html +0 -0
  78. package/{dist/docs → docs}/classes/PushNotification.html +0 -0
  79. package/{dist/docs → docs}/classes/RestPaginator.html +0 -0
  80. package/{dist/docs → docs}/classes/UnsentMessage.html +0 -0
  81. package/{dist/docs → docs}/classes/User.html +0 -0
  82. package/{dist/docs → docs}/index.html +0 -0
  83. package/{dist/docs → docs}/interfaces/ClientOptions.html +0 -0
  84. package/{dist/docs → docs}/interfaces/ConversationState.html +0 -0
  85. package/{dist/docs → docs}/interfaces/CreateConversationOptions.html +0 -0
  86. package/{dist/docs → docs}/interfaces/LastMessage.html +0 -0
  87. package/{dist/docs → docs}/interfaces/Paginator.html +0 -0
  88. package/{dist/docs → docs}/interfaces/PushNotificationData.html +0 -0
  89. package/{dist/docs → docs}/interfaces/SendEmailOptions.html +0 -0
  90. package/{dist/docs → docs}/interfaces/SendMediaOptions.html +0 -0
  91. package/{dist/docs → docs}/modules.html +0 -0
  92. package/package.json +23 -24
  93. package/dist/post-install.js +0 -29
  94. package/dist/react-native.js +0 -4035
  95. package/dist/react-native.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tslib.es6.js","sources":["../../../../../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAsCA;AACO,SAAS,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE;AAC1D,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;AACjI,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACnI,SAAS,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;AACtJ,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAClE,CAAC;AAKD;AACO,SAAS,UAAU,CAAC,WAAW,EAAE,aAAa,EAAE;AACvD,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,UAAU,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AACnI;;;;;"}
@@ -0,0 +1,136 @@
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
+ 'use strict';
130
+
131
+ Object.defineProperty(exports, '__esModule', { value: true });
132
+
133
+ var version = "2.0.1-rc.9";
134
+
135
+ exports.version = version;
136
+ //# sourceMappingURL=package.json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,346 @@
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
+ 'use strict';
130
+
131
+ Object.defineProperty(exports, '__esModule', { value: true });
132
+
133
+ var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
134
+ var index = require('./util/index.js');
135
+ var logger = require('./logger.js');
136
+ var declarativeTypeValidator = require('@twilio/declarative-type-validator');
137
+ var replayEventEmitter = require('@twilio/replay-event-emitter');
138
+ var isEqual = require('lodash.isequal');
139
+
140
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
141
+
142
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
143
+
144
+ const log = logger.Logger.scope('Participant');
145
+ /**
146
+ * A participant represents a remote client in a conversation.
147
+ */
148
+ class Participant extends replayEventEmitter.ReplayEventEmitter {
149
+ /**
150
+ * @internal
151
+ */
152
+ constructor(data, sid, conversation, links, services) {
153
+ super();
154
+ this.conversation = conversation;
155
+ this.links = links;
156
+ this.services = services;
157
+ this.state = {
158
+ attributes: index.parseAttributes(data.attributes, 'Retrieved malformed attributes from the server for participant: ' + sid, log),
159
+ dateCreated: data.dateCreated ? index.parseTime(data.dateCreated) : null,
160
+ dateUpdated: data.dateCreated ? index.parseTime(data.dateUpdated) : null,
161
+ sid: sid,
162
+ typingTimeout: null,
163
+ isTyping: false,
164
+ identity: data.identity || null,
165
+ roleSid: data.roleSid || null,
166
+ lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex) ? data.lastConsumedMessageIndex : null,
167
+ lastReadTimestamp: data.lastConsumptionTimestamp ? index.parseTime(data.lastConsumptionTimestamp) : null,
168
+ type: data.type || 'chat',
169
+ userInfo: data.userInfo
170
+ };
171
+ if (!data.identity && !data.type) {
172
+ throw new Error('Received invalid Participant object from server: Missing identity or type of Participant.');
173
+ }
174
+ }
175
+ /**
176
+ * The server-assigned unique identifier for the participant.
177
+ */
178
+ get sid() { return this.state.sid; }
179
+ /**
180
+ * Custom attributes of the participant.
181
+ */
182
+ get attributes() { return this.state.attributes; }
183
+ /**
184
+ * Date this participant was created on.
185
+ */
186
+ get dateCreated() { return this.state.dateCreated; }
187
+ /**
188
+ * Date this participant was last updated on.
189
+ */
190
+ get dateUpdated() { return this.state.dateUpdated; }
191
+ /**
192
+ * Identity of the participant.
193
+ */
194
+ get identity() { return this.state.identity; }
195
+ /**
196
+ * Indicates whether the participant is currently typing.
197
+ */
198
+ get isTyping() { return this.state.isTyping; }
199
+ /**
200
+ * The index of the last read message by the participant.
201
+ * Note that retrieving messages on a client endpoint does not mean that messages are read,
202
+ * please consider reading about the [Read Horizon feature](https://www.twilio.com/docs/api/chat/guides/consumption-horizon)
203
+ * to find out about the proper way to mark messages as read.
204
+ */
205
+ get lastReadMessageIndex() { return this.state.lastReadMessageIndex; }
206
+ /**
207
+ * Date of the most recent read horizon update.
208
+ */
209
+ get lastReadTimestamp() { return this.state.lastReadTimestamp; }
210
+ get roleSid() { return this.state.roleSid; }
211
+ /**
212
+ * Message type of the participant.
213
+ */
214
+ get type() { return this.state.type; }
215
+ /**
216
+ * Internal method used to start or reset the typing indicator timeout (with event emitting).
217
+ * @internal
218
+ */
219
+ _startTyping(timeout) {
220
+ clearTimeout(this.state.typingTimeout);
221
+ this.state.isTyping = true;
222
+ this.emit('typingStarted', this);
223
+ this.conversation.emit('typingStarted', this);
224
+ this.state.typingTimeout = setTimeout(() => this._endTyping(), timeout);
225
+ return this;
226
+ }
227
+ /**
228
+ * Internal method function used to stop the typing indicator timeout (with event emitting).
229
+ * @internal
230
+ */
231
+ _endTyping() {
232
+ if (!this.state.typingTimeout) {
233
+ return;
234
+ }
235
+ this.state.isTyping = false;
236
+ this.emit('typingEnded', this);
237
+ this.conversation.emit('typingEnded', this);
238
+ clearInterval(this.state.typingTimeout);
239
+ this.state.typingTimeout = null;
240
+ }
241
+ /**
242
+ * Internal method function used update local object's property roleSid with a new value.
243
+ * @internal
244
+ */
245
+ _update(data) {
246
+ let updateReasons = [];
247
+ let updateAttributes = index.parseAttributes(data.attributes, 'Retrieved malformed attributes from the server for participant: ' + this.state.sid, log);
248
+ if (data.attributes && !isEqual__default['default'](this.state.attributes, updateAttributes)) {
249
+ this.state.attributes = updateAttributes;
250
+ updateReasons.push('attributes');
251
+ }
252
+ let updatedDateUpdated = index.parseTime(data.dateUpdated);
253
+ if (data.dateUpdated &&
254
+ updatedDateUpdated.getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {
255
+ this.state.dateUpdated = updatedDateUpdated;
256
+ updateReasons.push('dateUpdated');
257
+ }
258
+ let updatedDateCreated = index.parseTime(data.dateCreated);
259
+ if (data.dateCreated &&
260
+ updatedDateCreated.getTime() !== (this.state.dateCreated && this.state.dateCreated.getTime())) {
261
+ this.state.dateCreated = updatedDateCreated;
262
+ updateReasons.push('dateCreated');
263
+ }
264
+ if (data.roleSid && this.state.roleSid !== data.roleSid) {
265
+ this.state.roleSid = data.roleSid;
266
+ updateReasons.push('roleSid');
267
+ }
268
+ if ((Number.isInteger(data.lastConsumedMessageIndex) || data.lastConsumedMessageIndex === null)
269
+ && this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex) {
270
+ this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;
271
+ updateReasons.push('lastReadMessageIndex');
272
+ }
273
+ if (data.lastConsumptionTimestamp) {
274
+ let lastReadTimestamp = new Date(data.lastConsumptionTimestamp);
275
+ if (!this.state.lastReadTimestamp ||
276
+ this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()) {
277
+ this.state.lastReadTimestamp = lastReadTimestamp;
278
+ updateReasons.push('lastReadTimestamp');
279
+ }
280
+ }
281
+ if (updateReasons.length > 0) {
282
+ this.emit('updated', { participant: this, updateReasons: updateReasons });
283
+ }
284
+ return this;
285
+ }
286
+ /**
287
+ * Get the user for this participant and subscribes to it. Supported only for participants of type `chat`.
288
+ */
289
+ async getUser() {
290
+ if (this.type != 'chat') {
291
+ throw new Error('Getting User is not supported for this Participant type: ' + this.type);
292
+ }
293
+ return this.services.users.getUser(this.state.identity, this.state.userInfo);
294
+ }
295
+ /**
296
+ * Remove the participant from the conversation.
297
+ */
298
+ async remove() {
299
+ return this.conversation.removeParticipant(this);
300
+ }
301
+ /**
302
+ * Update the attributes of the participant.
303
+ * @param attributes New attributes.
304
+ */
305
+ async updateAttributes(attributes) {
306
+ await this.services.commandExecutor.mutateResource('post', this.links.self, {
307
+ attributes: JSON.stringify(attributes)
308
+ });
309
+ return this;
310
+ }
311
+ }
312
+ /**
313
+ * Fired when the participant has started typing.
314
+ *
315
+ * Parameters:
316
+ * 1. {@link Participant} `participant` - the participant in question
317
+ * @event
318
+ */
319
+ Participant.typingStarted = 'typingStarted';
320
+ /**
321
+ * Fired when the participant has stopped typing.
322
+ *
323
+ * Parameters:
324
+ * 1. {@link Participant} `participant` - the participant in question
325
+ * @event
326
+ */
327
+ Participant.typingEnded = 'typingEnded';
328
+ /**
329
+ * Fired when the fields of the participant have been updated.
330
+ *
331
+ * Parameters:
332
+ * 1. object `data` - info object provided with the event. It has the following properties:
333
+ * * {@link Participant} participant - the participant in question
334
+ * * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update
335
+ * @event
336
+ */
337
+ Participant.updated = 'updated';
338
+ tslib_es6.__decorate([
339
+ declarativeTypeValidator.validateTypesAsync(['string', 'number', 'boolean', 'object', declarativeTypeValidator.literal(null)]),
340
+ tslib_es6.__metadata("design:type", Function),
341
+ tslib_es6.__metadata("design:paramtypes", [Object]),
342
+ tslib_es6.__metadata("design:returntype", Promise)
343
+ ], Participant.prototype, "updateAttributes", null);
344
+
345
+ exports.Participant = Participant;
346
+ //# sourceMappingURL=participant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participant.js","sources":["../src/participant.ts"],"sourcesContent":["import { Users } from './data/users';\nimport { User } from './user';\nimport { parseTime, parseAttributes } from './util';\nimport { Logger } from './logger';\nimport { Conversation } from './conversation';\nimport { validateTypesAsync, literal } from '@twilio/declarative-type-validator';\nimport { CommandExecutor } from './command-executor';\nimport { EditParticipantRequest } from './interfaces/commands/edit-participant';\nimport { ParticipantResponse } from './interfaces/commands/participant-response';\nimport { ReplayEventEmitter } from '@twilio/replay-event-emitter';\nimport isEqual from 'lodash.isequal';\n\ntype ParticipantEvents = {\n typingEnded: (participant: Participant) => void;\n typingStarted: (participant: Participant) => void;\n updated: (data: {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope('Participant');\n\ninterface ParticipantDescriptor {\n attributes?: Object;\n dateCreated: any;\n dateUpdated: any;\n identity: string;\n roleSid?: string;\n lastConsumedMessageIndex: number;\n lastConsumptionTimestamp: number;\n type: ParticipantType;\n userInfo: string;\n}\n\ninterface ParticipantState {\n attributes: any;\n dateCreated: Date;\n dateUpdated: Date;\n identity: string;\n isTyping: boolean;\n lastReadMessageIndex: number | null;\n lastReadTimestamp: Date;\n roleSid: string;\n sid: string;\n type: ParticipantType;\n typingTimeout: any;\n userInfo: string;\n}\n\ninterface ParticipantServices {\n users: Users;\n commandExecutor: CommandExecutor;\n}\n\ninterface ParticipantLinks {\n self: string;\n}\n\n/**\n * The reason for the `updated` event being emitted by a participant.\n */\ntype ParticipantUpdateReason =\n | 'attributes'\n | 'dateCreated'\n | 'dateUpdated'\n | 'roleSid'\n | 'lastReadMessageIndex'\n | 'lastReadTimestamp';\n\n/**\n * Type of a participant.\n */\ntype ParticipantType = 'chat' | 'sms' | 'whatsapp';\n\ninterface ParticipantUpdatedEventArgs {\n participant: Participant;\n updateReasons: ParticipantUpdateReason[];\n}\n\n/**\n * A participant represents a remote client in a conversation.\n */\nclass Participant extends ReplayEventEmitter<ParticipantEvents> {\n private state: ParticipantState;\n private readonly links: ParticipantLinks;\n private readonly services: ParticipantServices;\n\n /**\n * Conversation that the remote client is a participant of.\n */\n public readonly conversation: Conversation;\n\n /**\n * The server-assigned unique identifier for the participant.\n */\n public get sid(): string { return this.state.sid; }\n\n /**\n * Custom attributes of the participant.\n */\n public get attributes(): Object { return this.state.attributes; }\n\n /**\n * Date this participant was created on.\n */\n public get dateCreated(): Date { return this.state.dateCreated; }\n\n /**\n * Date this participant was last updated on.\n */\n public get dateUpdated(): Date { return this.state.dateUpdated; }\n\n /**\n * Identity of the participant.\n */\n public get identity(): string { return this.state.identity; }\n\n /**\n * Indicates whether the participant is currently typing.\n */\n public get isTyping(): boolean { return this.state.isTyping; }\n\n /**\n * The index of the last read message by the participant.\n * Note that retrieving messages on a client endpoint does not mean that messages are read,\n * please consider reading about the [Read Horizon feature](https://www.twilio.com/docs/api/chat/guides/consumption-horizon)\n * to find out about the proper way to mark messages as read.\n */\n public get lastReadMessageIndex(): number | null { return this.state.lastReadMessageIndex; }\n\n /**\n * Date of the most recent read horizon update.\n */\n public get lastReadTimestamp(): Date { return this.state.lastReadTimestamp; }\n\n public get roleSid(): string { return this.state.roleSid; }\n\n /**\n * Message type of the participant.\n */\n public get type(): ParticipantType { return this.state.type; }\n\n /**\n * @internal\n */\n constructor(\n data: ParticipantDescriptor,\n sid: string,\n conversation: Conversation,\n links: ParticipantLinks,\n services: ParticipantServices,\n ) {\n super();\n\n this.conversation = conversation;\n this.links = links;\n this.services = services;\n this.state = {\n attributes: parseAttributes(data.attributes,\n 'Retrieved malformed attributes from the server for participant: ' + sid,\n log),\n dateCreated: data.dateCreated ? parseTime(data.dateCreated) : null,\n dateUpdated: data.dateCreated ? parseTime(data.dateUpdated) : null,\n sid: sid,\n typingTimeout: null,\n isTyping: false,\n identity: data.identity || null,\n roleSid: data.roleSid || null,\n lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex) ? data.lastConsumedMessageIndex : null,\n lastReadTimestamp: data.lastConsumptionTimestamp ? parseTime(data.lastConsumptionTimestamp) : null,\n type: data.type || 'chat',\n userInfo: data.userInfo\n };\n\n if (!data.identity && !data.type) {\n throw new Error('Received invalid Participant object from server: Missing identity or type of Participant.');\n }\n }\n\n /**\n * Fired when the participant has started typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingStarted = 'typingStarted';\n\n /**\n * Fired when the participant has stopped typing.\n *\n * Parameters:\n * 1. {@link Participant} `participant` - the participant in question\n * @event\n */\n static readonly typingEnded = 'typingEnded';\n\n /**\n * Fired when the fields of the participant have been updated.\n *\n * Parameters:\n * 1. object `data` - info object provided with the event. It has the following properties:\n * * {@link Participant} participant - the participant in question\n * * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update\n * @event\n */\n static readonly updated = 'updated';\n\n /**\n * Internal method used to start or reset the typing indicator timeout (with event emitting).\n * @internal\n */\n _startTyping(timeout) {\n clearTimeout(this.state.typingTimeout);\n\n this.state.isTyping = true;\n this.emit('typingStarted', this);\n this.conversation.emit('typingStarted', this);\n\n this.state.typingTimeout = setTimeout(() => this._endTyping(), timeout);\n return this;\n }\n\n /**\n * Internal method function used to stop the typing indicator timeout (with event emitting).\n * @internal\n */\n _endTyping() {\n if (!this.state.typingTimeout) { return; }\n\n this.state.isTyping = false;\n this.emit('typingEnded', this);\n this.conversation.emit('typingEnded', this);\n\n clearInterval(this.state.typingTimeout);\n this.state.typingTimeout = null;\n }\n\n /**\n * Internal method function used update local object's property roleSid with a new value.\n * @internal\n */\n _update(data) {\n let updateReasons: ParticipantUpdateReason[] = [];\n\n let updateAttributes =\n parseAttributes(\n data.attributes,\n 'Retrieved malformed attributes from the server for participant: ' + this.state.sid,\n log);\n\n if (data.attributes && !isEqual(this.state.attributes, updateAttributes)) {\n this.state.attributes = updateAttributes;\n updateReasons.push('attributes');\n }\n\n let updatedDateUpdated = parseTime(data.dateUpdated);\n if (data.dateUpdated &&\n updatedDateUpdated.getTime() !== (this.state.dateUpdated && this.state.dateUpdated.getTime())) {\n this.state.dateUpdated = updatedDateUpdated;\n updateReasons.push('dateUpdated');\n }\n\n let updatedDateCreated = parseTime(data.dateCreated);\n if (data.dateCreated &&\n updatedDateCreated.getTime() !== (this.state.dateCreated && this.state.dateCreated.getTime())) {\n this.state.dateCreated = updatedDateCreated;\n updateReasons.push('dateCreated');\n }\n\n if (data.roleSid && this.state.roleSid !== data.roleSid) {\n this.state.roleSid = data.roleSid;\n updateReasons.push('roleSid');\n }\n\n if ((Number.isInteger(data.lastConsumedMessageIndex) || data.lastConsumedMessageIndex === null)\n && this.state.lastReadMessageIndex !== data.lastConsumedMessageIndex) {\n this.state.lastReadMessageIndex = data.lastConsumedMessageIndex;\n updateReasons.push('lastReadMessageIndex');\n }\n\n if (data.lastConsumptionTimestamp) {\n let lastReadTimestamp = new Date(data.lastConsumptionTimestamp);\n if (!this.state.lastReadTimestamp ||\n this.state.lastReadTimestamp.getTime() !== lastReadTimestamp.getTime()) {\n this.state.lastReadTimestamp = lastReadTimestamp;\n updateReasons.push('lastReadTimestamp');\n }\n }\n\n if (updateReasons.length > 0) {\n this.emit('updated', { participant: this, updateReasons: updateReasons });\n }\n\n return this;\n }\n\n /**\n * Get the user for this participant and subscribes to it. Supported only for participants of type `chat`.\n */\n async getUser(): Promise<User> {\n if (this.type != 'chat') {\n throw new Error('Getting User is not supported for this Participant type: ' + this.type);\n }\n\n return this.services.users.getUser(this.state.identity, this.state.userInfo);\n }\n\n /**\n * Remove the participant from the conversation.\n */\n async remove() {\n return this.conversation.removeParticipant(this);\n }\n\n /**\n * Update the attributes of the participant.\n * @param attributes New attributes.\n */\n @validateTypesAsync(['string', 'number', 'boolean', 'object', literal(null)])\n async updateAttributes(attributes: any): Promise<Participant> {\n await this.services.commandExecutor.mutateResource<EditParticipantRequest, ParticipantResponse>(\n 'post',\n this.links.self,\n {\n attributes: JSON.stringify(attributes)\n }\n );\n\n return this;\n }\n}\n\nexport {\n ParticipantDescriptor,\n ParticipantServices,\n Participant,\n ParticipantUpdateReason,\n ParticipantType,\n ParticipantUpdatedEventArgs\n};\n"],"names":["Logger","ReplayEventEmitter","parseAttributes","parseTime","isEqual","__decorate","validateTypesAsync","literal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AA2DxC;;;AAGA,MAAM,WAAY,SAAQC,qCAAqC;;;;IA+D7D,YACE,IAA2B,EAC3B,GAAW,EACX,YAA0B,EAC1B,KAAuB,EACvB,QAA6B;QAE7B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG;YACX,UAAU,EAA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