@twilio/conversations 2.0.1-rc.3 → 2.0.1-rc.7
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.
- package/CHANGELOG.md +36 -0
- package/{dist → builds}/browser.js +2 -2
- package/builds/browser.js.map +1 -0
- package/{dist → builds}/lib.d.ts +0 -0
- package/{dist → builds}/lib.js +2 -2
- package/builds/lib.js.map +1 -0
- package/{dist → builds}/twilio-conversations.js +5 -5
- package/{dist → builds}/twilio-conversations.min.js +2 -2
- package/dist/aggregated-delivery-receipt.js +227 -0
- package/dist/aggregated-delivery-receipt.js.map +1 -0
- package/dist/client.js +872 -0
- package/dist/client.js.map +1 -0
- package/dist/command-executor.js +203 -0
- package/dist/command-executor.js.map +1 -0
- package/dist/configuration.js +196 -0
- package/dist/configuration.js.map +1 -0
- package/dist/conversation.js +973 -0
- package/dist/conversation.js.map +1 -0
- package/dist/data/conversations.js +443 -0
- package/dist/data/conversations.js.map +1 -0
- package/dist/data/messages.js +341 -0
- package/dist/data/messages.js.map +1 -0
- package/dist/data/participants.js +313 -0
- package/dist/data/participants.js.map +1 -0
- package/dist/data/users.js +228 -0
- package/dist/data/users.js.map +1 -0
- package/dist/detailed-delivery-receipt.js +154 -0
- package/dist/detailed-delivery-receipt.js.map +1 -0
- package/dist/index.js +167 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/notification-types.js +143 -0
- package/dist/interfaces/notification-types.js.map +1 -0
- package/dist/logger.js +190 -0
- package/dist/logger.js.map +1 -0
- package/dist/media.js +213 -0
- package/dist/media.js.map +1 -0
- package/dist/message-builder.js +209 -0
- package/dist/message-builder.js.map +1 -0
- package/dist/message.js +450 -0
- package/dist/message.js.map +1 -0
- package/dist/node_modules/tslib/tslib.es6.js +161 -0
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/packages/conversations/package.json.js +136 -0
- package/dist/packages/conversations/package.json.js.map +1 -0
- package/dist/participant.js +346 -0
- package/dist/participant.js.map +1 -0
- package/dist/push-notification.js +152 -0
- package/dist/push-notification.js.map +1 -0
- package/dist/rest-paginator.js +175 -0
- package/dist/rest-paginator.js.map +1 -0
- package/dist/services/network.js +205 -0
- package/dist/services/network.js.map +1 -0
- package/dist/services/typing-indicator.js +235 -0
- package/dist/services/typing-indicator.js.map +1 -0
- package/dist/unsent-message.js +159 -0
- package/dist/unsent-message.js.map +1 -0
- package/dist/user.js +392 -0
- package/dist/user.js.map +1 -0
- package/dist/util/deferred.js +154 -0
- package/dist/util/deferred.js.map +1 -0
- package/dist/util/index.js +206 -0
- package/dist/util/index.js.map +1 -0
- package/{dist/docs → docs}/assets/css/main.css +0 -0
- package/{dist/docs → docs}/assets/images/icons.png +0 -0
- package/{dist/docs → docs}/assets/images/icons@2x.png +0 -0
- package/{dist/docs → docs}/assets/images/widgets.png +0 -0
- package/{dist/docs → docs}/assets/images/widgets@2x.png +0 -0
- package/{dist/docs → docs}/assets/js/main.js +0 -0
- package/{dist/docs → docs}/assets/js/search.js +0 -0
- package/{dist/docs → docs}/classes/AggregatedDeliveryReceipt.html +0 -0
- package/{dist/docs → docs}/classes/Client.html +0 -0
- package/{dist/docs → docs}/classes/Conversation.html +0 -0
- package/{dist/docs → docs}/classes/DetailedDeliveryReceipt.html +0 -0
- package/{dist/docs → docs}/classes/Media.html +0 -0
- package/{dist/docs → docs}/classes/Message.html +0 -0
- package/{dist/docs → docs}/classes/MessageBuilder.html +0 -0
- package/{dist/docs → docs}/classes/Participant.html +0 -0
- package/{dist/docs → docs}/classes/PushNotification.html +0 -0
- package/{dist/docs → docs}/classes/RestPaginator.html +0 -0
- package/{dist/docs → docs}/classes/UnsentMessage.html +0 -0
- package/{dist/docs → docs}/classes/User.html +0 -0
- package/{dist/docs → docs}/index.html +0 -0
- package/{dist/docs → docs}/interfaces/ClientOptions.html +0 -0
- package/{dist/docs → docs}/interfaces/ConversationState.html +0 -0
- package/{dist/docs → docs}/interfaces/CreateConversationOptions.html +0 -0
- package/{dist/docs → docs}/interfaces/LastMessage.html +0 -0
- package/{dist/docs → docs}/interfaces/Paginator.html +0 -0
- package/{dist/docs → docs}/interfaces/PushNotificationData.html +0 -0
- package/{dist/docs → docs}/interfaces/SendEmailOptions.html +0 -0
- package/{dist/docs → docs}/interfaces/SendMediaOptions.html +0 -0
- package/{dist/docs → docs}/modules.html +0 -0
- package/package.json +23 -24
- package/dist/browser.js.map +0 -1
- package/dist/lib.js.map +0 -1
- package/dist/post-install.js +0 -29
- package/dist/react-native.js +0 -4035
- package/dist/react-native.js.map +0 -1
@@ -0,0 +1,341 @@
|
|
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 logger = require('../logger.js');
|
134
|
+
var message = require('../message.js');
|
135
|
+
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
136
|
+
|
137
|
+
const log = logger.Logger.scope('Messages');
|
138
|
+
/**
|
139
|
+
* Represents the collection of messages in a conversation
|
140
|
+
*/
|
141
|
+
class Messages extends replayEventEmitter.ReplayEventEmitter {
|
142
|
+
constructor(conversation, configuration, services) {
|
143
|
+
super();
|
144
|
+
this.conversation = conversation;
|
145
|
+
this.configuration = configuration;
|
146
|
+
this.services = services;
|
147
|
+
this.messagesByIndex = new Map();
|
148
|
+
this.messagesListPromise = null;
|
149
|
+
}
|
150
|
+
/**
|
151
|
+
* Subscribe to the Messages Event Stream
|
152
|
+
* @param name - The name of Sync object for the Messages resource.
|
153
|
+
*/
|
154
|
+
async subscribe(name) {
|
155
|
+
if (this.messagesListPromise) {
|
156
|
+
return this.messagesListPromise;
|
157
|
+
}
|
158
|
+
this.messagesListPromise = this.services.syncClient.list({
|
159
|
+
id: name,
|
160
|
+
mode: 'open_existing',
|
161
|
+
});
|
162
|
+
try {
|
163
|
+
const list = await this.messagesListPromise;
|
164
|
+
list.on('itemAdded', (args) => {
|
165
|
+
log.debug(`${this.conversation.sid} itemAdded: ${args.item.index}`);
|
166
|
+
const links = {
|
167
|
+
self: `${this.conversation.links.messages}/${args.item.data.sid}`,
|
168
|
+
conversation: this.conversation.links.self,
|
169
|
+
messages_receipts: `${this.conversation.links.messages}/${args.item.data.sid}/Receipts`,
|
170
|
+
};
|
171
|
+
const message$1 = new message.Message(args.item.index, args.item.data, this.conversation, links, this.configuration, this.services);
|
172
|
+
if (this.messagesByIndex.has(message$1.index)) {
|
173
|
+
log.debug('Message arrived, but is already known and ignored', this.conversation.sid, message$1.index);
|
174
|
+
return;
|
175
|
+
}
|
176
|
+
this.messagesByIndex.set(message$1.index, message$1);
|
177
|
+
message$1.on('updated', (args) => this.emit('messageUpdated', args));
|
178
|
+
this.emit('messageAdded', message$1);
|
179
|
+
});
|
180
|
+
list.on('itemRemoved', (args) => {
|
181
|
+
log.debug(`#{this.conversation.sid} itemRemoved: ${args.index}`);
|
182
|
+
const index = args.index;
|
183
|
+
if (this.messagesByIndex.has(index)) {
|
184
|
+
let message = this.messagesByIndex.get(index);
|
185
|
+
this.messagesByIndex.delete(message.index);
|
186
|
+
message.removeAllListeners('updated');
|
187
|
+
this.emit('messageRemoved', message);
|
188
|
+
}
|
189
|
+
});
|
190
|
+
list.on('itemUpdated', (args) => {
|
191
|
+
log.debug(`${this.conversation.sid} itemUpdated: ${args.item.index}`);
|
192
|
+
const message = this.messagesByIndex.get(args.item.index);
|
193
|
+
if (message) {
|
194
|
+
message._update(args.item.data);
|
195
|
+
}
|
196
|
+
});
|
197
|
+
return list;
|
198
|
+
}
|
199
|
+
catch (err) {
|
200
|
+
this.messagesListPromise = null;
|
201
|
+
if (this.services.syncClient.connectionState !== 'disconnected') {
|
202
|
+
log.error('Failed to get messages object for conversation', this.conversation.sid, err);
|
203
|
+
}
|
204
|
+
log.debug('ERROR: Failed to get messages object for conversation', this.conversation.sid, err);
|
205
|
+
throw err;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
async unsubscribe() {
|
209
|
+
if (!this.messagesListPromise) {
|
210
|
+
return;
|
211
|
+
}
|
212
|
+
const entity = await this.messagesListPromise;
|
213
|
+
entity.close();
|
214
|
+
this.messagesListPromise = null;
|
215
|
+
}
|
216
|
+
/**
|
217
|
+
* Send Message to the conversation, message could include both text and multiple media attachments.
|
218
|
+
* @param message Message to post
|
219
|
+
* @returns Returns promise which can fail
|
220
|
+
*/
|
221
|
+
async sendV2(message) {
|
222
|
+
var _a;
|
223
|
+
log.debug('Sending message V2', message.mediaContent, message.attributes, message.emailOptions);
|
224
|
+
const media = [];
|
225
|
+
for (const [category, mediaContent] of message.mediaContent) {
|
226
|
+
log.debug(`Adding media to a message as ${mediaContent instanceof FormData ? 'FormData' : 'SendMediaOptions'}`, mediaContent);
|
227
|
+
media.push(mediaContent instanceof FormData
|
228
|
+
? await this.services.mcsClient.postFormData(mediaContent, category)
|
229
|
+
: await this.services.mcsClient.post(mediaContent.contentType, mediaContent.media, category, mediaContent.filename));
|
230
|
+
}
|
231
|
+
return await this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
|
232
|
+
body: message.text,
|
233
|
+
subject: (_a = message.emailOptions) === null || _a === void 0 ? void 0 : _a.subject,
|
234
|
+
media_sids: media.map((m) => m.sid),
|
235
|
+
attributes: typeof message.attributes !== 'undefined'
|
236
|
+
? JSON.stringify(message.attributes)
|
237
|
+
: undefined,
|
238
|
+
});
|
239
|
+
}
|
240
|
+
/**
|
241
|
+
* Send Message to the conversation
|
242
|
+
* @param message Message to post
|
243
|
+
* @param attributes Message attributes
|
244
|
+
* @param emailOptions Options that modify E-mail integration behaviors.
|
245
|
+
* @returns Returns promise which can fail
|
246
|
+
*/
|
247
|
+
async send(message, attributes = {}, emailOptions) {
|
248
|
+
log.debug('Sending text message', message, attributes, emailOptions);
|
249
|
+
return await this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
|
250
|
+
body: message !== null && message !== void 0 ? message : '',
|
251
|
+
attributes: typeof attributes !== 'undefined'
|
252
|
+
? JSON.stringify(attributes)
|
253
|
+
: undefined,
|
254
|
+
subject: emailOptions === null || emailOptions === void 0 ? void 0 : emailOptions.subject,
|
255
|
+
});
|
256
|
+
}
|
257
|
+
/**
|
258
|
+
* Send Media Message to the conversation
|
259
|
+
* @param mediaContent Media content to post
|
260
|
+
* @param attributes Message attributes
|
261
|
+
* @param emailOptions Email options
|
262
|
+
* @returns Returns promise which can fail
|
263
|
+
*/
|
264
|
+
async sendMedia(mediaContent, attributes = {}, emailOptions) {
|
265
|
+
log.debug('Sending media message', mediaContent, attributes, emailOptions);
|
266
|
+
log.debug(`Sending media message as ${mediaContent instanceof FormData ? 'FormData' : 'SendMediaOptions'}`, mediaContent, attributes);
|
267
|
+
const media = mediaContent instanceof FormData
|
268
|
+
? await this.services.mcsClient.postFormData(mediaContent)
|
269
|
+
: await this.services.mcsClient.post(mediaContent.contentType, mediaContent.media, 'media', mediaContent.filename);
|
270
|
+
// emailOptions are currently ignored for media messages.
|
271
|
+
return await this.services.commandExecutor.mutateResource('post', this.conversation.links.messages, {
|
272
|
+
media_sids: [media.sid],
|
273
|
+
attributes: typeof attributes !== 'undefined'
|
274
|
+
? JSON.stringify(attributes)
|
275
|
+
: undefined,
|
276
|
+
});
|
277
|
+
}
|
278
|
+
/**
|
279
|
+
* Returns messages from conversation using paginator interface
|
280
|
+
* @param pageSize Number of messages to return in single chunk. By default it's 30.
|
281
|
+
* @param anchor Most early message id which is already known, or 'end' by default
|
282
|
+
* @param direction Pagination order 'backwards' or 'forward', 'forward' by default
|
283
|
+
* @returns Last page of messages by default
|
284
|
+
*/
|
285
|
+
async getMessages(pageSize, anchor, direction = 'backwards') {
|
286
|
+
return this._getMessages(pageSize, anchor, direction);
|
287
|
+
}
|
288
|
+
_wrapPaginator(order, page, op) {
|
289
|
+
// Due to an inconsistency between Sync and Chat conventions, next and
|
290
|
+
// previous pages should be swapped.
|
291
|
+
const shouldReverse = order === 'desc';
|
292
|
+
const nextPage = () => page.nextPage().then((page) => this._wrapPaginator(order, page, op));
|
293
|
+
const previousPage = () => page.prevPage().then((page) => this._wrapPaginator(order, page, op));
|
294
|
+
return op(page.items).then((items) => ({
|
295
|
+
items: items.sort((x, y) => {
|
296
|
+
return x.index - y.index;
|
297
|
+
}),
|
298
|
+
hasPrevPage: shouldReverse ? page.hasNextPage : page.hasPrevPage,
|
299
|
+
hasNextPage: shouldReverse ? page.hasPrevPage : page.hasNextPage,
|
300
|
+
prevPage: shouldReverse ? nextPage : previousPage,
|
301
|
+
nextPage: shouldReverse ? previousPage : nextPage,
|
302
|
+
}));
|
303
|
+
}
|
304
|
+
_upsertMessage(index, value) {
|
305
|
+
const cachedMessage = this.messagesByIndex.get(index);
|
306
|
+
if (cachedMessage) {
|
307
|
+
return cachedMessage;
|
308
|
+
}
|
309
|
+
const links = {
|
310
|
+
self: `${this.conversation.links.messages}/${value.sid}`,
|
311
|
+
conversation: this.conversation.links.self,
|
312
|
+
messages_receipts: `${this.conversation.links.messages}/${value.sid}/Receipts`,
|
313
|
+
};
|
314
|
+
const message$1 = new message.Message(index, value, this.conversation, links, this.configuration, this.services);
|
315
|
+
this.messagesByIndex.set(message$1.index, message$1);
|
316
|
+
message$1.on('updated', (args) => this.emit('messageUpdated', args));
|
317
|
+
return message$1;
|
318
|
+
}
|
319
|
+
/**
|
320
|
+
* Returns last messages from conversation
|
321
|
+
* @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.
|
322
|
+
* @param {String} [anchor] Most early message id which is already known, or 'end' by default
|
323
|
+
* @param {String} [direction] Pagination order 'backwards' or 'forward', or 'forward' by default
|
324
|
+
* @returns {Promise<SyncPaginator<Message>>} last page of messages by default
|
325
|
+
* @private
|
326
|
+
*/
|
327
|
+
async _getMessages(pageSize = 30, anchor = 'end', direction = 'forward') {
|
328
|
+
const order = direction === 'backwards' ? 'desc' : 'asc';
|
329
|
+
const list = await this.messagesListPromise;
|
330
|
+
const page = await list.getItems({
|
331
|
+
from: anchor !== 'end' ? anchor : void 0,
|
332
|
+
pageSize,
|
333
|
+
order,
|
334
|
+
limit: pageSize, // @todo Limit equals pageSize by default in Sync. This is probably not ideal.
|
335
|
+
});
|
336
|
+
return await this._wrapPaginator(order, page, (items) => Promise.all(items.map((item) => this._upsertMessage(item.index, item.data))));
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
exports.Messages = Messages;
|
341
|
+
//# sourceMappingURL=messages.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"messages.js","sources":["../../src/data/messages.ts"],"sourcesContent":["import { EventEmitter } from 'events';\nimport { Logger } from '../logger';\n\nimport {\n Message,\n MessageUpdatedEventArgs,\n MessageUpdateReason\n} from '../message';\nimport {\n Conversation,\n SendEmailOptions,\n SendMediaOptions\n} from '../conversation';\nimport { UnsentMessage } from '../unsent-message';\n\nimport { SyncList, SyncClient } from 'twilio-sync';\nimport { SyncPaginator } from '../sync-paginator';\n\nimport { McsClient, McsMedia } from '@twilio/mcs-client';\nimport { Network } from '../services/network';\nimport { Configuration } from '../configuration';\nimport { CommandExecutor } from '../command-executor';\nimport { SendMessageRequest } from '../interfaces/commands/send-message';\nimport { MessageResponse } from '../interfaces/commands/message-response';\nimport { ReplayEventEmitter } from '@twilio/replay-event-emitter';\n\ntype MessagesEvents = {\n messageAdded: (message: Message) => void;\n messageRemoved: (message: Message) => void;\n messageUpdated: (data: {\n message: Message;\n updateReasons: MessageUpdateReason[];\n }) => void;\n};\n\nconst log = Logger.scope('Messages');\n\nexport interface MessagesServices {\n mcsClient: McsClient;\n network: Network;\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n}\n\n/**\n * Represents the collection of messages in a conversation\n */\nclass Messages extends ReplayEventEmitter<MessagesEvents> {\n public readonly conversation: Conversation;\n private readonly configuration: Configuration;\n private readonly services: MessagesServices;\n private readonly messagesByIndex: Map<number, Message>;\n private messagesListPromise: Promise<SyncList>;\n\n public constructor(\n conversation: Conversation,\n configuration: Configuration,\n services: MessagesServices\n ) {\n super();\n\n this.conversation = conversation;\n this.configuration = configuration;\n this.services = services;\n\n this.messagesByIndex = new Map();\n this.messagesListPromise = null;\n }\n\n /**\n * Subscribe to the Messages Event Stream\n * @param name - The name of Sync object for the Messages resource.\n */\n public async subscribe(name: string) {\n if (this.messagesListPromise) {\n return this.messagesListPromise;\n }\n\n this.messagesListPromise = this.services.syncClient.list({\n id: name,\n mode: 'open_existing',\n });\n\n try {\n const list = await this.messagesListPromise;\n\n list.on('itemAdded', (args) => {\n log.debug(`${this.conversation.sid} itemAdded: ${args.item.index}`);\n\n const links = {\n self: `${this.conversation.links.messages}/${args.item.data.sid}`,\n conversation: this.conversation.links.self,\n messages_receipts: `${this.conversation.links.messages}/${args.item.data.sid}/Receipts`,\n };\n const message = new Message(\n args.item.index,\n args.item.data,\n this.conversation,\n links,\n this.configuration,\n this.services\n );\n\n if (this.messagesByIndex.has(message.index)) {\n log.debug(\n 'Message arrived, but is already known and ignored',\n this.conversation.sid,\n message.index\n );\n return;\n }\n\n this.messagesByIndex.set(message.index, message);\n\n message.on('updated', (args: MessageUpdatedEventArgs) =>\n this.emit('messageUpdated', args)\n );\n\n this.emit('messageAdded', message);\n });\n\n list.on('itemRemoved', (args) => {\n log.debug(`#{this.conversation.sid} itemRemoved: ${args.index}`);\n\n const index = args.index;\n\n if (this.messagesByIndex.has(index)) {\n let message = this.messagesByIndex.get(index);\n this.messagesByIndex.delete(message.index);\n message.removeAllListeners('updated');\n this.emit('messageRemoved', message);\n }\n });\n\n list.on('itemUpdated', (args) => {\n log.debug(`${this.conversation.sid} itemUpdated: ${args.item.index}`);\n\n const message = this.messagesByIndex.get(args.item.index);\n\n if (message) {\n message._update(args.item.data);\n }\n });\n\n return list;\n } catch (err) {\n this.messagesListPromise = null;\n\n if (this.services.syncClient.connectionState !== 'disconnected') {\n log.error(\n 'Failed to get messages object for conversation',\n this.conversation.sid,\n err\n );\n }\n\n log.debug(\n 'ERROR: Failed to get messages object for conversation',\n this.conversation.sid,\n err\n );\n\n throw err;\n }\n }\n\n public async unsubscribe() {\n if (!this.messagesListPromise) {\n return;\n }\n\n const entity = await this.messagesListPromise;\n entity.close();\n this.messagesListPromise = null;\n }\n\n /**\n * Send Message to the conversation, message could include both text and multiple media attachments.\n * @param message Message to post\n * @returns Returns promise which can fail\n */\n public async sendV2(message: UnsentMessage) {\n log.debug(\n 'Sending message V2',\n message.mediaContent,\n message.attributes,\n message.emailOptions\n );\n\n const media: McsMedia[] = [];\n\n for (const [category, mediaContent] of message.mediaContent) {\n log.debug(\n `Adding media to a message as ${\n mediaContent instanceof FormData ? 'FormData' : 'SendMediaOptions'\n }`,\n mediaContent\n );\n\n media.push(\n mediaContent instanceof FormData\n ? await this.services.mcsClient.postFormData(mediaContent, category)\n : await this.services.mcsClient.post(\n mediaContent.contentType,\n mediaContent.media,\n category,\n mediaContent.filename\n )\n );\n }\n\n return await this.services.commandExecutor.mutateResource<\n SendMessageRequest,\n MessageResponse\n >('post', this.conversation.links.messages, {\n body: message.text,\n subject: message.emailOptions?.subject,\n media_sids: media.map((m) => m.sid),\n attributes:\n typeof message.attributes !== 'undefined'\n ? JSON.stringify(message.attributes)\n : undefined,\n });\n }\n\n /**\n * Send Message to the conversation\n * @param message Message to post\n * @param attributes Message attributes\n * @param emailOptions Options that modify E-mail integration behaviors.\n * @returns Returns promise which can fail\n */\n public async send(\n message: string | null,\n attributes: any = {},\n emailOptions?: SendEmailOptions\n ): Promise<MessageResponse> {\n log.debug('Sending text message', message, attributes, emailOptions);\n\n return await this.services.commandExecutor.mutateResource<\n SendMessageRequest,\n MessageResponse\n >('post', this.conversation.links.messages, {\n body: message ?? '',\n attributes:\n typeof attributes !== 'undefined'\n ? JSON.stringify(attributes)\n : undefined,\n subject: emailOptions?.subject,\n });\n }\n\n /**\n * Send Media Message to the conversation\n * @param mediaContent Media content to post\n * @param attributes Message attributes\n * @param emailOptions Email options\n * @returns Returns promise which can fail\n */\n public async sendMedia(\n mediaContent: FormData | SendMediaOptions,\n attributes: any = {},\n emailOptions?: SendEmailOptions\n ) {\n log.debug('Sending media message', mediaContent, attributes, emailOptions);\n log.debug(\n `Sending media message as ${\n mediaContent instanceof FormData ? 'FormData' : 'SendMediaOptions'\n }`,\n mediaContent,\n attributes\n );\n\n const media: McsMedia =\n mediaContent instanceof FormData\n ? await this.services.mcsClient.postFormData(mediaContent)\n : await this.services.mcsClient.post(\n mediaContent.contentType,\n mediaContent.media,\n 'media',\n mediaContent.filename\n );\n\n // emailOptions are currently ignored for media messages.\n return await this.services.commandExecutor.mutateResource<\n SendMessageRequest,\n MessageResponse\n >('post', this.conversation.links.messages, {\n media_sids: [media.sid],\n attributes:\n typeof attributes !== 'undefined'\n ? JSON.stringify(attributes)\n : undefined,\n });\n }\n\n /**\n * Returns messages from conversation using paginator interface\n * @param pageSize Number of messages to return in single chunk. By default it's 30.\n * @param anchor Most early message id which is already known, or 'end' by default\n * @param direction Pagination order 'backwards' or 'forward', 'forward' by default\n * @returns Last page of messages by default\n */\n public async getMessages(\n pageSize: number,\n anchor: number | 'end',\n direction: 'forward' | 'backwards' = 'backwards'\n ): Promise<SyncPaginator<Message>> {\n return this._getMessages(pageSize, anchor, direction);\n }\n\n private _wrapPaginator(order, page, op) {\n // Due to an inconsistency between Sync and Chat conventions, next and\n // previous pages should be swapped.\n const shouldReverse = order === 'desc';\n\n const nextPage = () =>\n page.nextPage().then((page) => this._wrapPaginator(order, page, op));\n const previousPage = () =>\n page.prevPage().then((page) => this._wrapPaginator(order, page, op));\n\n return op(page.items).then((items) => ({\n items: items.sort((x, y) => {\n return x.index - y.index;\n }),\n hasPrevPage: shouldReverse ? page.hasNextPage : page.hasPrevPage,\n hasNextPage: shouldReverse ? page.hasPrevPage : page.hasNextPage,\n prevPage: shouldReverse ? nextPage : previousPage,\n nextPage: shouldReverse ? previousPage : nextPage,\n }));\n }\n\n private _upsertMessage(index: number, value: any) {\n const cachedMessage = this.messagesByIndex.get(index);\n\n if (cachedMessage) {\n return cachedMessage;\n }\n\n const links = {\n self: `${this.conversation.links.messages}/${value.sid}`,\n conversation: this.conversation.links.self,\n messages_receipts: `${this.conversation.links.messages}/${value.sid}/Receipts`,\n };\n const message = new Message(\n index,\n value,\n this.conversation,\n links,\n this.configuration,\n this.services\n );\n\n this.messagesByIndex.set(message.index, message);\n\n message.on('updated', (args: MessageUpdatedEventArgs) =>\n this.emit('messageUpdated', args)\n );\n\n return message;\n }\n\n /**\n * Returns last messages from conversation\n * @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.\n * @param {String} [anchor] Most early message id which is already known, or 'end' by default\n * @param {String} [direction] Pagination order 'backwards' or 'forward', or 'forward' by default\n * @returns {Promise<SyncPaginator<Message>>} last page of messages by default\n * @private\n */\n private async _getMessages(\n pageSize = 30,\n anchor: number | 'end' = 'end',\n direction: 'forward' | 'backwards' = 'forward'\n ): Promise<SyncPaginator<Message>> {\n const order = direction === 'backwards' ? 'desc' : 'asc';\n const list = await this.messagesListPromise;\n const page = await list.getItems({\n from: anchor !== 'end' ? anchor : void 0,\n pageSize,\n order,\n limit: pageSize, // @todo Limit equals pageSize by default in Sync. This is probably not ideal.\n });\n\n return await this._wrapPaginator(order, page, (items) =>\n Promise.all(\n items.map((item) => this._upsertMessage(item.index, item.data))\n )\n );\n }\n}\n\nexport { Messages };\n"],"names":["Logger","ReplayEventEmitter","message","Message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,GAAG,GAAGA,aAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AASrC;;;AAGA,MAAM,QAAS,SAAQC,qCAAkC;IAOvD,YACE,YAA0B,EAC1B,aAA4B,EAC5B,QAA0B;QAE1B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;KACjC;;;;;IAMM,MAAM,SAAS,CAAC,IAAY;QACjC,IAAI,IAAI,CAA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