@twilio/conversations 2.3.0 → 2.4.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,265 @@
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
+ var global =
132
+ typeof global !== "undefined"
133
+ ? global
134
+ : typeof self !== "undefined"
135
+ ? self
136
+ : typeof window !== "undefined"
137
+ ? window
138
+ : {};
139
+
140
+ Object.defineProperty(exports, '__esModule', { value: true });
141
+
142
+ class QuickLRU {
143
+ constructor(options = {}) {
144
+ if (!(options.maxSize && options.maxSize > 0)) {
145
+ throw new TypeError('`maxSize` must be a number greater than 0');
146
+ }
147
+
148
+ this.maxSize = options.maxSize;
149
+ this.onEviction = options.onEviction;
150
+ this.cache = new Map();
151
+ this.oldCache = new Map();
152
+ this._size = 0;
153
+ }
154
+
155
+ _set(key, value) {
156
+ this.cache.set(key, value);
157
+ this._size++;
158
+
159
+ if (this._size >= this.maxSize) {
160
+ this._size = 0;
161
+
162
+ if (typeof this.onEviction === 'function') {
163
+ for (const [key, value] of this.oldCache.entries()) {
164
+ this.onEviction(key, value);
165
+ }
166
+ }
167
+
168
+ this.oldCache = this.cache;
169
+ this.cache = new Map();
170
+ }
171
+ }
172
+
173
+ get(key) {
174
+ if (this.cache.has(key)) {
175
+ return this.cache.get(key);
176
+ }
177
+
178
+ if (this.oldCache.has(key)) {
179
+ const value = this.oldCache.get(key);
180
+ this.oldCache.delete(key);
181
+ this._set(key, value);
182
+ return value;
183
+ }
184
+ }
185
+
186
+ set(key, value) {
187
+ if (this.cache.has(key)) {
188
+ this.cache.set(key, value);
189
+ } else {
190
+ this._set(key, value);
191
+ }
192
+
193
+ return this;
194
+ }
195
+
196
+ has(key) {
197
+ return this.cache.has(key) || this.oldCache.has(key);
198
+ }
199
+
200
+ peek(key) {
201
+ if (this.cache.has(key)) {
202
+ return this.cache.get(key);
203
+ }
204
+
205
+ if (this.oldCache.has(key)) {
206
+ return this.oldCache.get(key);
207
+ }
208
+ }
209
+
210
+ delete(key) {
211
+ const deleted = this.cache.delete(key);
212
+ if (deleted) {
213
+ this._size--;
214
+ }
215
+
216
+ return this.oldCache.delete(key) || deleted;
217
+ }
218
+
219
+ clear() {
220
+ this.cache.clear();
221
+ this.oldCache.clear();
222
+ this._size = 0;
223
+ }
224
+
225
+ * keys() {
226
+ for (const [key] of this) {
227
+ yield key;
228
+ }
229
+ }
230
+
231
+ * values() {
232
+ for (const [, value] of this) {
233
+ yield value;
234
+ }
235
+ }
236
+
237
+ * [Symbol.iterator]() {
238
+ for (const item of this.cache) {
239
+ yield item;
240
+ }
241
+
242
+ for (const item of this.oldCache) {
243
+ const [key] = item;
244
+ if (!this.cache.has(key)) {
245
+ yield item;
246
+ }
247
+ }
248
+ }
249
+
250
+ get size() {
251
+ let oldCacheSize = 0;
252
+ for (const key of this.oldCache.keys()) {
253
+ if (!this.cache.has(key)) {
254
+ oldCacheSize++;
255
+ }
256
+ }
257
+
258
+ return Math.min(this._size + oldCacheSize, this.maxSize);
259
+ }
260
+ }
261
+
262
+ var quickLru = QuickLRU;
263
+
264
+ exports["default"] = quickLru;
265
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../node_modules/quick-lru/index.js"],"sourcesContent":["'use strict';\n\nclass QuickLRU {\n\tconstructor(options = {}) {\n\t\tif (!(options.maxSize && options.maxSize > 0)) {\n\t\t\tthrow new TypeError('`maxSize` must be a number greater than 0');\n\t\t}\n\n\t\tthis.maxSize = options.maxSize;\n\t\tthis.onEviction = options.onEviction;\n\t\tthis.cache = new Map();\n\t\tthis.oldCache = new Map();\n\t\tthis._size = 0;\n\t}\n\n\t_set(key, value) {\n\t\tthis.cache.set(key, value);\n\t\tthis._size++;\n\n\t\tif (this._size >= this.maxSize) {\n\t\t\tthis._size = 0;\n\n\t\t\tif (typeof this.onEviction === 'function') {\n\t\t\t\tfor (const [key, value] of this.oldCache.entries()) {\n\t\t\t\t\tthis.onEviction(key, value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.oldCache = this.cache;\n\t\t\tthis.cache = new Map();\n\t\t}\n\t}\n\n\tget(key) {\n\t\tif (this.cache.has(key)) {\n\t\t\treturn this.cache.get(key);\n\t\t}\n\n\t\tif (this.oldCache.has(key)) {\n\t\t\tconst value = this.oldCache.get(key);\n\t\t\tthis.oldCache.delete(key);\n\t\t\tthis._set(key, value);\n\t\t\treturn value;\n\t\t}\n\t}\n\n\tset(key, value) {\n\t\tif (this.cache.has(key)) {\n\t\t\tthis.cache.set(key, value);\n\t\t} else {\n\t\t\tthis._set(key, value);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\thas(key) {\n\t\treturn this.cache.has(key) || this.oldCache.has(key);\n\t}\n\n\tpeek(key) {\n\t\tif (this.cache.has(key)) {\n\t\t\treturn this.cache.get(key);\n\t\t}\n\n\t\tif (this.oldCache.has(key)) {\n\t\t\treturn this.oldCache.get(key);\n\t\t}\n\t}\n\n\tdelete(key) {\n\t\tconst deleted = this.cache.delete(key);\n\t\tif (deleted) {\n\t\t\tthis._size--;\n\t\t}\n\n\t\treturn this.oldCache.delete(key) || deleted;\n\t}\n\n\tclear() {\n\t\tthis.cache.clear();\n\t\tthis.oldCache.clear();\n\t\tthis._size = 0;\n\t}\n\n\t* keys() {\n\t\tfor (const [key] of this) {\n\t\t\tyield key;\n\t\t}\n\t}\n\n\t* values() {\n\t\tfor (const [, value] of this) {\n\t\t\tyield value;\n\t\t}\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tfor (const item of this.cache) {\n\t\t\tyield item;\n\t\t}\n\n\t\tfor (const item of this.oldCache) {\n\t\t\tconst [key] = item;\n\t\t\tif (!this.cache.has(key)) {\n\t\t\t\tyield item;\n\t\t\t}\n\t\t}\n\t}\n\n\tget size() {\n\t\tlet oldCacheSize = 0;\n\t\tfor (const key of this.oldCache.keys()) {\n\t\t\tif (!this.cache.has(key)) {\n\t\t\t\toldCacheSize++;\n\t\t\t}\n\t\t}\n\n\t\treturn Math.min(this._size + oldCacheSize, this.maxSize);\n\t}\n}\n\nmodule.exports = QuickLRU;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,QAAQ,CAAC;AACf,CAAC,WAAW,CAAC,OAAO,GAAG,EAAE,EAAE;AAC3B,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE;AACjD,GAAG,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;AACpE,GAAG;AACH;AACA,EAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACjC,EAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;AACvC,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;AACzB,EAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;AAC5B,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;AACjB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C,IAAI,CAAC,KAAK,GAAG,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AAC3D,EAAE;AACF,CAAC;AACD;AACA,IAAA,QAAc,GAAG;;;;"}
@@ -139,7 +139,7 @@ var global =
139
139
 
140
140
  Object.defineProperty(exports, '__esModule', { value: true });
141
141
 
142
- var version = "2.3.0";
142
+ var version = "2.4.0-rc.0";
143
143
 
144
144
  exports.version = version;
145
145
  //# sourceMappingURL=package.json.js.map
package/dist/user.js CHANGED
@@ -322,6 +322,14 @@ class User extends replayEventEmitter.ReplayEventEmitter {
322
322
  args.item.key);
323
323
  return this._update(args.item.key, args.item.data);
324
324
  });
325
+ map.on("itemAdded", (args) => {
326
+ log.debug(this.state.entityName +
327
+ " (" +
328
+ this.state.identity +
329
+ ") itemAdded: " +
330
+ args.item.key);
331
+ return this._update(args.item.key, args.item.data);
332
+ });
325
333
  return Promise.all([
326
334
  map
327
335
  .get("friendlyName")
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 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,CAA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AAA,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 \"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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