@twilio/conversations 2.0.0-rc.1 → 2.0.1-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -28
- package/dist/browser.js +3125 -3460
- package/dist/browser.js.map +1 -1
- package/dist/docs/assets/js/search.js +1 -1
- package/dist/docs/classes/AggregatedDeliveryReceipt.html +22 -6
- package/dist/docs/classes/Client.html +78 -33
- package/dist/docs/classes/Conversation.html +33 -17
- package/dist/docs/classes/DetailedDeliveryReceipt.html +22 -6
- package/dist/docs/classes/Media.html +23 -7
- package/dist/docs/classes/Message.html +23 -7
- package/dist/docs/classes/MessageBuilder.html +3280 -0
- package/dist/docs/classes/Participant.html +23 -7
- package/dist/docs/classes/PushNotification.html +24 -8
- package/dist/docs/classes/RestPaginator.html +28 -9
- package/dist/docs/classes/UnsentMessage.html +3144 -0
- package/dist/docs/classes/User.html +25 -9
- package/dist/docs/index.html +89 -47
- package/dist/docs/interfaces/ClientOptions.html +22 -6
- package/dist/docs/interfaces/ConversationState.html +22 -6
- package/dist/docs/interfaces/CreateConversationOptions.html +22 -6
- package/dist/docs/interfaces/LastMessage.html +22 -6
- package/dist/docs/interfaces/Paginator.html +3243 -0
- package/dist/docs/interfaces/PushNotificationData.html +3168 -0
- package/dist/docs/interfaces/SendEmailOptions.html +22 -6
- package/dist/docs/interfaces/SendMediaOptions.html +24 -7
- package/dist/docs/modules.html +88 -46
- package/dist/lib/aggregated-delivery-receipt.js +227 -0
- package/dist/lib/aggregated-delivery-receipt.js.map +1 -0
- package/dist/lib/client.js +872 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/command-executor.js +203 -0
- package/dist/lib/command-executor.js.map +1 -0
- package/dist/lib/configuration.js +196 -0
- package/dist/lib/configuration.js.map +1 -0
- package/dist/lib/conversation.js +973 -0
- package/dist/lib/conversation.js.map +1 -0
- package/dist/lib/data/conversations.js +443 -0
- package/dist/lib/data/conversations.js.map +1 -0
- package/dist/lib/data/messages.js +341 -0
- package/dist/lib/data/messages.js.map +1 -0
- package/dist/lib/data/participants.js +313 -0
- package/dist/lib/data/participants.js.map +1 -0
- package/dist/lib/data/users.js +228 -0
- package/dist/lib/data/users.js.map +1 -0
- package/dist/lib/detailed-delivery-receipt.js +154 -0
- package/dist/lib/detailed-delivery-receipt.js.map +1 -0
- package/dist/lib/index.js +167 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/interfaces/notification-types.js +143 -0
- package/dist/lib/interfaces/notification-types.js.map +1 -0
- package/dist/lib/logger.js +190 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/media.js +213 -0
- package/dist/lib/media.js.map +1 -0
- package/dist/lib/message-builder.js +209 -0
- package/dist/lib/message-builder.js.map +1 -0
- package/dist/lib/message.js +450 -0
- package/dist/lib/message.js.map +1 -0
- package/dist/lib/node_modules/tslib/tslib.es6.js +161 -0
- package/dist/lib/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/lib/packages/conversations/package.json.js +136 -0
- package/dist/lib/packages/conversations/package.json.js.map +1 -0
- package/dist/lib/participant.js +346 -0
- package/dist/lib/participant.js.map +1 -0
- package/dist/lib/push-notification.js +152 -0
- package/dist/lib/push-notification.js.map +1 -0
- package/dist/lib/rest-paginator.js +175 -0
- package/dist/lib/rest-paginator.js.map +1 -0
- package/dist/lib/services/network.js +205 -0
- package/dist/lib/services/network.js.map +1 -0
- package/dist/lib/services/typing-indicator.js +235 -0
- package/dist/lib/services/typing-indicator.js.map +1 -0
- package/dist/lib/unsent-message.js +159 -0
- package/dist/lib/unsent-message.js.map +1 -0
- package/dist/lib/user.js +392 -0
- package/dist/lib/user.js.map +1 -0
- package/dist/lib/util/deferred.js +154 -0
- package/dist/lib/util/deferred.js.map +1 -0
- package/dist/lib/util/index.js +206 -0
- package/dist/lib/util/index.js.map +1 -0
- package/dist/lib.d.ts +250 -59
- package/dist/lib.js +3055 -2919
- package/dist/lib.js.map +1 -1
- package/dist/twilio-conversations.js +25175 -23918
- package/dist/twilio-conversations.min.js +14 -2
- package/package.json +16 -14
- package/CHANGELOG.md +0 -168
- package/dist/post-install.js +0 -29
- package/dist/react-native.js +0 -4412
- package/dist/react-native.js.map +0 -1
@@ -0,0 +1,235 @@
|
|
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 notificationTypes = require('../interfaces/notification-types.js');
|
135
|
+
|
136
|
+
const log = logger.Logger.scope('TypingIndicator');
|
137
|
+
/**
|
138
|
+
* An important note in regards to typing timeout timers. There are two places that the SDK can get the "typing_timeout" attribute from. The first
|
139
|
+
* place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the
|
140
|
+
* "typing_timeout" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a
|
141
|
+
* notification of type "twilio.ipmsg.typing_indicator". In this case, the "typing_timeout" value will be +1 of that in the console. This
|
142
|
+
* intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,
|
143
|
+
* the timeout returned from the notification should be used as the timeout for the "typingEnded" event, +1 is to account for latency.
|
144
|
+
*
|
145
|
+
* @private
|
146
|
+
*/
|
147
|
+
/**
|
148
|
+
* @class TypingIndicator
|
149
|
+
*
|
150
|
+
* @constructor
|
151
|
+
* @private
|
152
|
+
*/
|
153
|
+
class TypingIndicator {
|
154
|
+
constructor(getConversation, config, services) {
|
155
|
+
this.configuration = config;
|
156
|
+
this.services = services;
|
157
|
+
this.getConversation = getConversation;
|
158
|
+
this.serviceTypingTimeout = null;
|
159
|
+
this.sentUpdates = new Map();
|
160
|
+
}
|
161
|
+
get typingTimeout() {
|
162
|
+
return this.configuration.typingIndicatorTimeoutOverride
|
163
|
+
|| this.serviceTypingTimeout
|
164
|
+
|| this.configuration.typingIndicatorTimeoutDefault;
|
165
|
+
}
|
166
|
+
/**
|
167
|
+
* Initialize TypingIndicator controller
|
168
|
+
* Registers for needed message types and sets listeners
|
169
|
+
* @private
|
170
|
+
*/
|
171
|
+
initialize() {
|
172
|
+
// this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');
|
173
|
+
this.services.notificationClient.on('message', async (type, message) => {
|
174
|
+
if (type === notificationTypes.NotificationTypes.TYPING_INDICATOR) {
|
175
|
+
await this._handleRemoteTyping(message);
|
176
|
+
}
|
177
|
+
});
|
178
|
+
}
|
179
|
+
/**
|
180
|
+
* Remote participants typing events handler
|
181
|
+
*/
|
182
|
+
async _handleRemoteTyping(message) {
|
183
|
+
log.trace('Got new typing indicator ', message);
|
184
|
+
this.getConversation(message.channel_sid)
|
185
|
+
.then(conversation => {
|
186
|
+
if (!conversation) {
|
187
|
+
return;
|
188
|
+
}
|
189
|
+
conversation.participants.forEach(participant => {
|
190
|
+
if (participant.identity !== message.identity) {
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
const timeout = this.configuration.typingIndicatorTimeoutOverride + 1000 || message.typing_timeout * 1000;
|
194
|
+
participant._startTyping(timeout);
|
195
|
+
});
|
196
|
+
})
|
197
|
+
.catch(err => {
|
198
|
+
log.error(err);
|
199
|
+
throw err;
|
200
|
+
});
|
201
|
+
}
|
202
|
+
/**
|
203
|
+
* Send typing event for the given conversation sid
|
204
|
+
* @param {String} conversationSid
|
205
|
+
*/
|
206
|
+
send(conversationSid) {
|
207
|
+
const lastUpdate = this.sentUpdates.get(conversationSid);
|
208
|
+
if (lastUpdate && lastUpdate > (Date.now() - this.typingTimeout)) {
|
209
|
+
return Promise.resolve();
|
210
|
+
}
|
211
|
+
this.sentUpdates.set(conversationSid, Date.now());
|
212
|
+
return this._send(conversationSid);
|
213
|
+
}
|
214
|
+
_send(conversationSid) {
|
215
|
+
log.trace('Sending typing indicator');
|
216
|
+
const url = this.configuration.links.typing;
|
217
|
+
const headers = {
|
218
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
219
|
+
};
|
220
|
+
const body = `ChannelSid=${conversationSid}`;
|
221
|
+
return (this.services.twilsockClient.post(url, headers, body, this.configuration.productId)
|
222
|
+
.then((response) => {
|
223
|
+
if (response.body.hasOwnProperty('typing_timeout')) {
|
224
|
+
this.serviceTypingTimeout = response.body.typing_timeout * 1000;
|
225
|
+
}
|
226
|
+
})
|
227
|
+
.catch((err) => {
|
228
|
+
log.error('Failed to send typing indicator:', err);
|
229
|
+
throw err;
|
230
|
+
}));
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
exports.TypingIndicator = TypingIndicator;
|
235
|
+
//# sourceMappingURL=typing-indicator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"typing-indicator.js","sources":["../../../src/services/typing-indicator.ts"],"sourcesContent":["import { Logger } from '../logger';\n\nimport { Notifications } from '@twilio/notifications';\n\nimport { NotificationTypes } from '../interfaces/notification-types';\nimport { TwilsockClient } from 'twilsock';\nimport { Configuration } from '../configuration';\n\nconst log = Logger.scope('TypingIndicator');\n\nexport interface TypingIndicatorServices {\n twilsockClient: TwilsockClient;\n notificationClient: Notifications;\n}\n\n/**\n * An important note in regards to typing timeout timers. There are two places that the SDK can get the \"typing_timeout\" attribute from. The first\n * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the\n * \"typing_timeout\" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a\n * notification of type \"twilio.ipmsg.typing_indicator\". In this case, the \"typing_timeout\" value will be +1 of that in the console. This\n * intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,\n * the timeout returned from the notification should be used as the timeout for the \"typingEnded\" event, +1 is to account for latency.\n *\n * @private\n */\n\n/**\n * @class TypingIndicator\n *\n * @constructor\n * @private\n */\nclass TypingIndicator {\n private readonly services: TypingIndicatorServices;\n private readonly configuration: Configuration;\n\n private sentUpdates: Map<string, number>;\n private getConversation;\n private serviceTypingTimeout;\n\n constructor(getConversation, config: Configuration, services: TypingIndicatorServices) {\n this.configuration = config;\n this.services = services;\n this.getConversation = getConversation;\n\n this.serviceTypingTimeout = null;\n this.sentUpdates = new Map();\n }\n\n public get typingTimeout(): number {\n return this.configuration.typingIndicatorTimeoutOverride\n || this.serviceTypingTimeout\n || this.configuration.typingIndicatorTimeoutDefault;\n }\n\n /**\n * Initialize TypingIndicator controller\n * Registers for needed message types and sets listeners\n * @private\n */\n initialize(): void {\n // this.services.notificationClient.subscribe(NotificationTypes.TYPING_INDICATOR, 'twilsock');\n this.services.notificationClient.on('message', async (type, message) => {\n if (type === NotificationTypes.TYPING_INDICATOR) {\n await this._handleRemoteTyping(message);\n }\n });\n }\n\n /**\n * Remote participants typing events handler\n */\n private async _handleRemoteTyping(message) {\n log.trace('Got new typing indicator ', message);\n\n this.getConversation(message.channel_sid)\n .then(conversation => {\n if (!conversation) {\n return;\n }\n\n conversation.participants.forEach(participant => {\n if (participant.identity !== message.identity) {\n return;\n }\n\n const timeout = this.configuration.typingIndicatorTimeoutOverride + 1000 || message.typing_timeout * 1000;\n participant._startTyping(timeout);\n });\n })\n .catch(err => {\n log.error(err);\n throw err;\n });\n }\n\n /**\n * Send typing event for the given conversation sid\n * @param {String} conversationSid\n */\n send(conversationSid: string) {\n const lastUpdate = this.sentUpdates.get(conversationSid);\n if (lastUpdate && lastUpdate > (Date.now() - this.typingTimeout)) {\n return Promise.resolve();\n }\n\n this.sentUpdates.set(conversationSid, Date.now());\n return this._send(conversationSid);\n }\n\n private _send(conversationSid: string) {\n log.trace('Sending typing indicator');\n\n const url = this.configuration.links.typing;\n const headers = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n };\n const body = `ChannelSid=${conversationSid}`;\n\n return (\n this.services.twilsockClient.post\n < { typing_timeout: number } >\n (url, headers, body, this.configuration.productId)\n .then((response) => {\n if (response.body.hasOwnProperty('typing_timeout')) {\n this.serviceTypingTimeout = response.body.typing_timeout * 1000;\n }\n })\n .catch((err) => {\n log.error('Failed to send typing indicator:', err);\n throw err;\n })\n );\n }\n}\n\nexport { TypingIndicator };\n"],"names":["Logger","NotificationTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACD,KAAK,CAAC,CAAC,GAAG;YACT,GAAG,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;YACnD,MAAM,GAAG,CAAC;SACX,CAAC,EACJ;KACH;;;;;"}
|
@@ -0,0 +1,159 @@
|
|
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 index = require('./util/index.js');
|
134
|
+
|
135
|
+
/**
|
136
|
+
* An unsent message. Returned from {@link MessageBuilder.build}.
|
137
|
+
*/
|
138
|
+
class UnsentMessage {
|
139
|
+
/**
|
140
|
+
* @internal
|
141
|
+
*/
|
142
|
+
constructor(messagesEntity) {
|
143
|
+
this.messagesEntity = messagesEntity;
|
144
|
+
this.attributes = {};
|
145
|
+
this.mediaContent = [];
|
146
|
+
this.emailOptions = {};
|
147
|
+
}
|
148
|
+
/**
|
149
|
+
* Send the prepared message to the conversation.
|
150
|
+
* @returns Index of the new message in the conversation.
|
151
|
+
*/
|
152
|
+
async send() {
|
153
|
+
const response = await this.messagesEntity.sendV2(this);
|
154
|
+
return index.parseToNumber(response.index);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
exports.UnsentMessage = UnsentMessage;
|
159
|
+
//# sourceMappingURL=unsent-message.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"unsent-message.js","sources":["../../src/unsent-message.ts"],"sourcesContent":["import { MediaCategory } from '@twilio/mcs-client';\nimport { parseToNumber } from './util';\nimport { SendEmailOptions, SendMediaOptions } from './conversation';\n\n/**\n * An unsent message. Returned from {@link MessageBuilder.build}.\n */\nclass UnsentMessage {\n public text?: string;\n public attributes: any = {};\n public mediaContent: [MediaCategory, FormData | SendMediaOptions][] = [];\n public emailOptions?: SendEmailOptions = {};\n\n /**\n * @internal\n */\n constructor(private messagesEntity: any) {}\n\n /**\n * Send the prepared message to the conversation.\n * @returns Index of the new message in the conversation.\n */\n async send(): Promise<number> {\n const response = await this.messagesEntity.sendV2(this);\n return parseToNumber(response.index);\n }\n}\n\nexport { UnsentMessage };\n"],"names":["parseToNumber"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;AAGA,MAAM,aAAa;;;;IASjB,YAAoB,cAAmB;QAAnB,mBAAc,GAAd,cAAc,CAAK;QAPhC,eAAU,GAAQ,EAAE,CAAC;QACrB,iBAAY,GAAmD,EAAE,CAAC;QAClE,iBAAY,GAAsB,EAAE,CAAC;KAKD;;;;;IAM3C,MAAM,IAAI;QACR,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxD,OAAOA,mBAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KACtC;;;;;"}
|