@twilio/conversations 2.0.1 → 2.1.0-rc.6
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 +74 -0
- package/NOTICE.txt +679 -0
- package/builds/browser.js +889 -619
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +384 -129
- package/builds/lib.js +889 -619
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +1065 -939
- package/builds/twilio-conversations.min.js +2 -14
- package/dist/aggregated-delivery-receipt.js +6 -1
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/client.js +165 -142
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +16 -14
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +14 -10
- package/dist/configuration.js.map +1 -1
- package/dist/conversation.js +232 -159
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +82 -78
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +43 -39
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +100 -78
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +24 -22
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +1 -1
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/interfaces/attributes.js +147 -0
- package/dist/interfaces/attributes.js.map +1 -0
- package/dist/interfaces/notification-types.js +5 -5
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/logger.js +36 -15
- package/dist/logger.js.map +1 -1
- package/dist/media.js +21 -9
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +56 -3
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +157 -78
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +101 -50
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +16 -6
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +18 -14
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +20 -17
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +87 -60
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +3 -1
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +6 -6
- package/dist/util/index.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +0 -102
- package/docs/classes/Client.html +24 -132
- package/docs/classes/Conversation.html +37 -132
- package/docs/classes/DetailedDeliveryReceipt.html +1 -103
- package/docs/classes/Media.html +0 -102
- package/docs/classes/Message.html +73 -109
- package/docs/classes/MessageBuilder.html +78 -104
- package/docs/classes/Participant.html +37 -110
- package/docs/classes/PushNotification.html +0 -102
- package/docs/classes/RestPaginator.html +0 -102
- package/docs/classes/UnsentMessage.html +0 -102
- package/docs/classes/User.html +7 -109
- package/docs/index.html +93 -3
- package/docs/interfaces/ClientOptions.html +0 -102
- package/docs/interfaces/ConversationBindings.html +3001 -0
- package/docs/interfaces/ConversationEmailBinding.html +3001 -0
- package/docs/interfaces/ConversationState.html +0 -102
- package/docs/interfaces/CreateConversationOptions.html +1 -103
- package/docs/interfaces/LastMessage.html +0 -102
- package/docs/interfaces/Paginator.html +0 -102
- package/docs/interfaces/ParticipantBindings.html +3001 -0
- package/docs/interfaces/ParticipantEmailBinding.html +3001 -0
- package/docs/interfaces/PushNotificationData.html +0 -102
- package/docs/interfaces/SendEmailOptions.html +0 -102
- package/docs/interfaces/SendMediaOptions.html +0 -102
- package/docs/modules.html +93 -3
- package/package.json +23 -17
package/dist/data/users.js
CHANGED
@@ -144,10 +144,10 @@ class Users extends replayEventEmitter.ReplayEventEmitter {
|
|
144
144
|
this.services = services;
|
145
145
|
this.fifoStack = [];
|
146
146
|
this.myself = myself;
|
147
|
-
this.myself.on(
|
148
|
-
this.myself.on(
|
149
|
-
this.myself.on(
|
150
|
-
this.emit(
|
147
|
+
this.myself.on("updated", (args) => this.emit("userUpdated", args));
|
148
|
+
this.myself.on("userSubscribed", () => this.emit("userSubscribed", this.myself));
|
149
|
+
this.myself.on("userUnsubscribed", () => {
|
150
|
+
this.emit("userUnsubscribed", this.myself);
|
151
151
|
this.myself._ensureFetched();
|
152
152
|
});
|
153
153
|
this.subscribedUsers = new Map();
|
@@ -156,8 +156,8 @@ class Users extends replayEventEmitter.ReplayEventEmitter {
|
|
156
156
|
if (this.subscribedUsers.has(user.identity)) {
|
157
157
|
this.subscribedUsers.delete(user.identity);
|
158
158
|
}
|
159
|
-
let foundItemIndex =
|
160
|
-
|
159
|
+
let foundItemIndex = 0;
|
160
|
+
const foundItem = this.fifoStack.find((item, index) => {
|
161
161
|
if (item == user.identity) {
|
162
162
|
foundItemIndex = index;
|
163
163
|
return true;
|
@@ -167,41 +167,42 @@ class Users extends replayEventEmitter.ReplayEventEmitter {
|
|
167
167
|
if (foundItem) {
|
168
168
|
this.fifoStack.splice(foundItemIndex, 1);
|
169
169
|
}
|
170
|
-
this.emit(
|
170
|
+
this.emit("userUnsubscribed", user);
|
171
171
|
}
|
172
172
|
handleSubscribeUser(user) {
|
173
|
+
var _a, _b;
|
173
174
|
if (this.subscribedUsers.has(user.identity)) {
|
174
175
|
return;
|
175
176
|
}
|
176
177
|
if (this.fifoStack.length >= this.configuration.userInfosToSubscribe) {
|
177
|
-
this.
|
178
|
+
const item = this.fifoStack.shift();
|
179
|
+
(_b = (_a = this.subscribedUsers) === null || _a === void 0 ? void 0 : _a.get(item)) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
178
180
|
}
|
179
181
|
this.fifoStack.push(user.identity);
|
180
182
|
this.subscribedUsers.set(user.identity, user);
|
181
|
-
this.emit(
|
183
|
+
this.emit("userSubscribed", user);
|
182
184
|
}
|
183
185
|
/**
|
184
186
|
* Gets user, if it's in subscribed list - then return the user object from it,
|
185
187
|
* if not - then subscribes and adds user to the FIFO stack
|
186
188
|
* @returns {Promise<User>} Fully initialized user
|
187
189
|
*/
|
188
|
-
async getUser(identity, entityName =
|
190
|
+
async getUser(identity = "", entityName = "") {
|
189
191
|
await this.myself._ensureFetched();
|
190
192
|
if (identity == this.myself.identity) {
|
191
193
|
return this.myself;
|
192
194
|
}
|
193
|
-
|
194
|
-
if (
|
195
|
-
|
196
|
-
entityName = await this.getSyncUniqueName(identity);
|
197
|
-
}
|
198
|
-
user$1 = new user.User(identity, entityName, this.configuration, this.services);
|
199
|
-
user$1.on('updated', (args) => this.emit('userUpdated', args));
|
200
|
-
user$1.on('userSubscribed', () => this.handleSubscribeUser(user$1));
|
201
|
-
user$1.on('userUnsubscribed', () => this.handleUnsubscribeUser(user$1));
|
202
|
-
await user$1._ensureFetched();
|
195
|
+
const user$1 = this.subscribedUsers.get(identity);
|
196
|
+
if (user$1) {
|
197
|
+
return user$1;
|
203
198
|
}
|
204
|
-
|
199
|
+
entityName = entityName || (await this.getSyncUniqueName(identity));
|
200
|
+
const newUser = new user.User(identity, entityName, this.configuration, this.services);
|
201
|
+
newUser.on("updated", (args) => this.emit("userUpdated", args));
|
202
|
+
newUser.on("userSubscribed", () => this.handleSubscribeUser(newUser));
|
203
|
+
newUser.on("userUnsubscribed", () => this.handleUnsubscribeUser(newUser));
|
204
|
+
await newUser._ensureFetched();
|
205
|
+
return newUser;
|
205
206
|
}
|
206
207
|
/**
|
207
208
|
* @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
|
@@ -216,11 +217,12 @@ class Users extends replayEventEmitter.ReplayEventEmitter {
|
|
216
217
|
* @returns {Promise<string>} User's sync unique name
|
217
218
|
*/
|
218
219
|
async getSyncUniqueName(identity) {
|
220
|
+
var _a, _b;
|
219
221
|
const url = new index.UriBuilder(this.configuration.links.users)
|
220
222
|
.path(identity)
|
221
223
|
.build();
|
222
224
|
const response = await this.services.network.get(url);
|
223
|
-
return response.body.sync_objects.user_info_map;
|
225
|
+
return (_b = (_a = response.body) === null || _a === void 0 ? void 0 : _a.sync_objects.user_info_map) !== null && _b !== void 0 ? _b : "";
|
224
226
|
}
|
225
227
|
}
|
226
228
|
|
package/dist/data/users.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"users.js","sources":["../../src/data/users.ts"],"sourcesContent":["import { User, UserUpdatedEventArgs, UserUpdateReason } from
|
1
|
+
{"version":3,"file":"users.js","sources":["../../src/data/users.ts"],"sourcesContent":["import { User, UserUpdatedEventArgs, UserUpdateReason } from \"../user\";\nimport { Network } from \"../services/network\";\nimport { SyncClient } from \"twilio-sync\";\nimport { UriBuilder } from \"../util\";\nimport { Configuration } from \"../configuration\";\nimport { CommandExecutor } from \"../command-executor\";\nimport { ReplayEventEmitter } from \"@twilio/replay-event-emitter\";\nimport { UserResponse } from \"../interfaces/commands/user\";\n\ntype UsersEvents = {\n userUpdated: (data: {\n user: User;\n updateReasons: UserUpdateReason[];\n }) => void;\n userSubscribed: (user: User) => void;\n userUnsubscribed: (user: User) => void;\n};\n\nexport interface UsersServices {\n network: Network;\n syncClient: SyncClient;\n commandExecutor: CommandExecutor;\n}\n\n/**\n * Container for known users\n */\nclass Users extends ReplayEventEmitter<UsersEvents> {\n private readonly configuration: Configuration;\n private readonly services: UsersServices;\n\n private subscribedUsers: Map<string, User>;\n private fifoStack: string[];\n public readonly myself: User;\n\n constructor(\n myself: User,\n configuration: Configuration,\n services: UsersServices\n ) {\n super();\n\n this.configuration = configuration;\n this.services = services;\n\n this.fifoStack = [];\n this.myself = myself;\n this.myself.on(\"updated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n this.myself.on(\"userSubscribed\", () =>\n this.emit(\"userSubscribed\", this.myself)\n );\n this.myself.on(\"userUnsubscribed\", () => {\n this.emit(\"userUnsubscribed\", this.myself);\n this.myself._ensureFetched();\n });\n\n this.subscribedUsers = new Map<string, User>();\n }\n\n private handleUnsubscribeUser(user: User): void {\n if (this.subscribedUsers.has(user.identity)) {\n this.subscribedUsers.delete(user.identity);\n }\n let foundItemIndex = 0;\n const foundItem = this.fifoStack.find((item, index) => {\n if (item == user.identity) {\n foundItemIndex = index;\n return true;\n }\n return false;\n });\n if (foundItem) {\n this.fifoStack.splice(foundItemIndex, 1);\n }\n this.emit(\"userUnsubscribed\", user);\n }\n\n private handleSubscribeUser(user: User): void {\n if (this.subscribedUsers.has(user.identity)) {\n return;\n }\n if (this.fifoStack.length >= this.configuration.userInfosToSubscribe) {\n const item = this.fifoStack.shift() as string;\n this.subscribedUsers?.get(item)?.unsubscribe();\n }\n this.fifoStack.push(user.identity);\n this.subscribedUsers.set(user.identity, user);\n this.emit(\"userSubscribed\", user);\n }\n\n /**\n * Gets user, if it's in subscribed list - then return the user object from it,\n * if not - then subscribes and adds user to the FIFO stack\n * @returns {Promise<User>} Fully initialized user\n */\n async getUser(identity = \"\", entityName = \"\"): Promise<User> {\n await this.myself._ensureFetched();\n\n if (identity == this.myself.identity) {\n return this.myself;\n }\n\n const user = this.subscribedUsers.get(identity);\n\n if (user) {\n return user;\n }\n\n entityName = entityName || (await this.getSyncUniqueName(identity));\n\n const newUser = new User(\n identity,\n entityName,\n this.configuration,\n this.services\n );\n\n newUser.on(\"updated\", (args: UserUpdatedEventArgs) =>\n this.emit(\"userUpdated\", args)\n );\n newUser.on(\"userSubscribed\", () => this.handleSubscribeUser(newUser));\n newUser.on(\"userUnsubscribed\", () => this.handleUnsubscribeUser(newUser));\n await newUser._ensureFetched();\n\n return newUser;\n }\n\n /**\n * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}\n */\n async getSubscribedUsers(): Promise<Array<User>> {\n await this.myself._ensureFetched();\n\n const users = [this.myself];\n this.subscribedUsers.forEach((user) => users.push(user));\n\n return users;\n }\n\n /**\n * @returns {Promise<string>} User's sync unique name\n */\n private async getSyncUniqueName(identity: string): Promise<string> {\n const url = new UriBuilder(this.configuration.links.users)\n .path(identity)\n .build();\n const response = await this.services.network.get<UserResponse>(url);\n return response.body?.sync_objects.user_info_map ?? \"\";\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KAAK,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAe,GAAG,CAAC,CAAC;QACpE,OAAO,MAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,YAAY,CAAC,aAAa,mCAAI,EAAE,CAAC;KACxD;;;;;"}
|
@@ -143,7 +143,7 @@ class DetailedDeliveryReceipt {
|
|
143
143
|
this.conversationSid = descriptor.conversation_sid;
|
144
144
|
this.channelMessageSid = descriptor.channel_message_sid;
|
145
145
|
this.participantSid = descriptor.participant_sid;
|
146
|
-
this.status = descriptor.status ||
|
146
|
+
this.status = descriptor.status || "queued";
|
147
147
|
this.errorCode = descriptor.error_code || 0;
|
148
148
|
this.dateCreated = descriptor.date_created;
|
149
149
|
this.dateUpdated = descriptor.date_updated;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"detailed-delivery-receipt.js","sources":["../src/detailed-delivery-receipt.ts"],"sourcesContent":["/**\n * Message delivery status.\n */\ntype DeliveryStatus =\n |
|
1
|
+
{"version":3,"file":"detailed-delivery-receipt.js","sources":["../src/detailed-delivery-receipt.ts"],"sourcesContent":["/**\n * Message delivery status.\n */\ntype DeliveryStatus =\n | \"sent\"\n | \"delivered\"\n | \"failed\"\n | \"read\"\n | \"undelivered\"\n | \"queued\";\n\ninterface DetailedDeliveryReceiptDescriptor {\n sid: string;\n message_sid: string;\n conversation_sid: string;\n channel_message_sid: string;\n participant_sid: string;\n status: DeliveryStatus;\n error_code: string | null;\n date_created: string;\n date_updated: string;\n}\n\n/**\n * Represents a delivery receipt of a message.\n */\nclass DetailedDeliveryReceipt {\n /**\n * Unique identifier for the delivery receipt.\n */\n sid: string;\n\n /**\n * Unique identifier for the message in the conversation.\n */\n messageSid: string;\n\n /**\n * Unique identifier for the conversation.\n */\n conversationSid: string;\n\n /**\n * Unique identifier for the `‘channel’` message (e.g., `WAxx` for WhatsApp, `SMxx` for SMS).\n */\n channelMessageSid: string;\n\n /**\n * Unique identifier for the participant.\n */\n participantSid: string;\n\n /**\n * Status of the message delivery.\n */\n status: DeliveryStatus;\n\n /**\n * Numeric error code mapped from Status callback code. Information about the error codes can be found\n * [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).\n */\n errorCode: string | 0;\n\n /**\n * Date this delivery receipt was created on.\n */\n dateCreated: string;\n\n /**\n * Date this delivery receipt was last updated on.\n */\n dateUpdated: string;\n\n /**\n * @internal\n */\n constructor(descriptor: DetailedDeliveryReceiptDescriptor) {\n this.sid = descriptor.sid;\n this.messageSid = descriptor.message_sid;\n this.conversationSid = descriptor.conversation_sid;\n this.channelMessageSid = descriptor.channel_message_sid;\n this.participantSid = descriptor.participant_sid;\n this.status = descriptor.status || \"queued\";\n this.errorCode = descriptor.error_code || 0;\n this.dateCreated = descriptor.date_created;\n this.dateUpdated = descriptor.date_updated;\n }\n}\n\nexport {\n DetailedDeliveryReceipt,\n DetailedDeliveryReceiptDescriptor,\n DeliveryStatus,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;;;AAGA,MAAM,uBAAuB;;;;IAkD3B,YAAY,UAA6C;QACvD,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,gBAAgB,CAAC;QACnD,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,mBAAmB,CAAC;QACxD,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,IAAI,QAAQ,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,UAAU,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC;KAC5C;;;;;"}
|
@@ -0,0 +1,147 @@
|
|
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 declarativeTypeValidator = require('@twilio/declarative-type-validator');
|
134
|
+
|
135
|
+
// Any JSON value
|
136
|
+
const attributesValidator = declarativeTypeValidator.custom((value) => [
|
137
|
+
["string", "number", "boolean", "object"].includes(typeof value),
|
138
|
+
"a JSON type",
|
139
|
+
]);
|
140
|
+
const optionalAttributesValidator = declarativeTypeValidator.custom((value) => [
|
141
|
+
["undefined", "string", "number", "boolean", "object"].includes(typeof value),
|
142
|
+
"an optional JSON type",
|
143
|
+
]);
|
144
|
+
|
145
|
+
exports.attributesValidator = attributesValidator;
|
146
|
+
exports.optionalAttributesValidator = optionalAttributesValidator;
|
147
|
+
//# sourceMappingURL=attributes.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"attributes.js","sources":["../../src/interfaces/attributes.ts"],"sourcesContent":["import { custom } from \"@twilio/declarative-type-validator\";\n\n// Any JSON value\nexport const attributesValidator = custom((value) => [\n [\"string\", \"number\", \"boolean\", \"object\"].includes(typeof value),\n \"a JSON type\",\n]);\n\nexport const optionalAttributesValidator = custom((value) => [\n [\"undefined\", \"string\", \"number\", \"boolean\", \"object\"].includes(typeof value),\n \"an optional JSON type\",\n]);\n"],"names":["custom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;MACa,mBAAmB,GAAGA,+BAAM,CAAC,CAAC,KAAK,KAAK;IACnD,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC;IAChE,aAAa;CACd,EAAE;MAEU,2BAA2B,GAAGA,+BAAM,CAAC,CAAC,KAAK,KAAK;IAC3D,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC;IAC7E,uBAAuB;CACxB;;;;;"}
|
@@ -132,12 +132,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
132
132
|
|
133
133
|
class NotificationTypes {
|
134
134
|
}
|
135
|
-
NotificationTypes.TYPING_INDICATOR =
|
136
|
-
NotificationTypes.NEW_MESSAGE =
|
137
|
-
NotificationTypes.ADDED_TO_CONVERSATION =
|
135
|
+
NotificationTypes.TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
|
136
|
+
NotificationTypes.NEW_MESSAGE = "twilio.conversations.new_message";
|
137
|
+
NotificationTypes.ADDED_TO_CONVERSATION = "twilio.conversations.added_to_conversation";
|
138
138
|
// static readonly INVITED_TO_CHANNEL = 'twilio.channel.invited_to_channel';
|
139
|
-
NotificationTypes.REMOVED_FROM_CONVERSATION =
|
140
|
-
NotificationTypes.CONSUMPTION_UPDATE =
|
139
|
+
NotificationTypes.REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
|
140
|
+
NotificationTypes.CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
|
141
141
|
|
142
142
|
exports.NotificationTypes = NotificationTypes;
|
143
143
|
//# sourceMappingURL=notification-types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"notification-types.js","sources":["../../src/interfaces/notification-types.ts"],"sourcesContent":["class NotificationTypes {\n static readonly TYPING_INDICATOR =
|
1
|
+
{"version":3,"file":"notification-types.js","sources":["../../src/interfaces/notification-types.ts"],"sourcesContent":["class NotificationTypes {\n static readonly TYPING_INDICATOR = \"twilio.ipmsg.typing_indicator\";\n static readonly NEW_MESSAGE = \"twilio.conversations.new_message\";\n static readonly ADDED_TO_CONVERSATION =\n \"twilio.conversations.added_to_conversation\";\n // static readonly INVITED_TO_CHANNEL = 'twilio.channel.invited_to_channel';\n static readonly REMOVED_FROM_CONVERSATION =\n \"twilio.conversations.removed_from_conversation\";\n static readonly CONSUMPTION_UPDATE = \"twilio.channel.consumption_update\";\n}\n\nexport { NotificationTypes };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,iBAAiB;;AACL,kCAAgB,GAAG,+BAA+B,CAAC;AACnD,6BAAW,GAAG,kCAAkC,CAAC;AACjD,uCAAqB,GACnC,4CAA4C,CAAC;AAC/C;AACgB,2CAAyB,GACvC,gDAAgD,CAAC;AACnC,oCAAkB,GAAG,mCAAmC;;;;"}
|
package/dist/logger.js
CHANGED
@@ -157,13 +157,14 @@ var loglevelLog__namespace = /*#__PURE__*/_interopNamespace(loglevelLog);
|
|
157
157
|
function prepareLine(prefix, args) {
|
158
158
|
return [`${new Date().toISOString()} Conversations ${prefix}:`].concat(Array.from(args));
|
159
159
|
}
|
160
|
-
const log = loglevelLog__namespace.getLogger(
|
160
|
+
const log = loglevelLog__namespace.getLogger("twilio-conversations"); // twilio-conversations is used by Flex SDK. Please DO NOT change
|
161
161
|
class Logger {
|
162
162
|
constructor(prefix) {
|
163
|
-
this.prefix =
|
164
|
-
this.prefix =
|
165
|
-
|
166
|
-
|
163
|
+
this.prefix = "";
|
164
|
+
this.prefix =
|
165
|
+
prefix !== null && prefix !== undefined && prefix.length > 0
|
166
|
+
? prefix + " "
|
167
|
+
: "";
|
167
168
|
}
|
168
169
|
static scope(prefix) {
|
169
170
|
return new Logger(prefix);
|
@@ -174,16 +175,36 @@ class Logger {
|
|
174
175
|
static setLevel(level) {
|
175
176
|
log.setLevel(level);
|
176
177
|
}
|
177
|
-
trace(...args) {
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
178
|
+
trace(...args) {
|
179
|
+
log.trace.apply(null, prepareLine(this.prefix + "T", args));
|
180
|
+
}
|
181
|
+
debug(...args) {
|
182
|
+
log.debug.apply(null, prepareLine(this.prefix + "D", args));
|
183
|
+
}
|
184
|
+
info(...args) {
|
185
|
+
log.info.apply(null, prepareLine(this.prefix + "I", args));
|
186
|
+
}
|
187
|
+
warn(...args) {
|
188
|
+
log.warn.apply(null, prepareLine(this.prefix + "W", args));
|
189
|
+
}
|
190
|
+
error(...args) {
|
191
|
+
log.error.apply(null, prepareLine(this.prefix + "E", args));
|
192
|
+
}
|
193
|
+
static trace(...args) {
|
194
|
+
log.trace.apply(null, prepareLine("T", args));
|
195
|
+
}
|
196
|
+
static debug(...args) {
|
197
|
+
log.debug.apply(null, prepareLine("D", args));
|
198
|
+
}
|
199
|
+
static info(...args) {
|
200
|
+
log.info.apply(null, prepareLine("I", args));
|
201
|
+
}
|
202
|
+
static warn(...args) {
|
203
|
+
log.warn.apply(null, prepareLine("W", args));
|
204
|
+
}
|
205
|
+
static error(...args) {
|
206
|
+
log.error.apply(null, prepareLine("E", args));
|
207
|
+
}
|
187
208
|
}
|
188
209
|
|
189
210
|
exports.Logger = Logger;
|
package/dist/logger.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.js","sources":["../src/logger.ts"],"sourcesContent":["import * as loglevelLog from
|
1
|
+
{"version":3,"file":"logger.js","sources":["../src/logger.ts"],"sourcesContent":["import * as loglevelLog from \"loglevel\";\nimport { LogLevelDesc } from \"loglevel\";\n\nfunction prepareLine(prefix, args) {\n return [`${new Date().toISOString()} Conversations ${prefix}:`].concat(\n Array.from(args)\n );\n}\n\nconst log: loglevelLog.Logger = loglevelLog.getLogger(\"twilio-conversations\"); // twilio-conversations is used by Flex SDK. Please DO NOT change\n\nclass Logger {\n private prefix = \"\";\n\n private constructor(prefix: string) {\n this.prefix =\n prefix !== null && prefix !== undefined && prefix.length > 0\n ? prefix + \" \"\n : \"\";\n }\n\n static scope(prefix: string): Logger {\n return new Logger(prefix);\n }\n\n setLevel(level: LogLevelDesc) {\n log.setLevel(level);\n }\n\n static setLevel(level: LogLevelDesc) {\n log.setLevel(level);\n }\n\n trace(...args) {\n log.trace.apply(null, prepareLine(this.prefix + \"T\", args));\n }\n\n debug(...args) {\n log.debug.apply(null, prepareLine(this.prefix + \"D\", args));\n }\n\n info(...args) {\n log.info.apply(null, prepareLine(this.prefix + \"I\", args));\n }\n\n warn(...args) {\n log.warn.apply(null, prepareLine(this.prefix + \"W\", args));\n }\n\n error(...args) {\n log.error.apply(null, prepareLine(this.prefix + \"E\", args));\n }\n\n static trace(...args) {\n log.trace.apply(null, prepareLine(\"T\", args));\n }\n\n static debug(...args) {\n log.debug.apply(null, prepareLine(\"D\", args));\n }\n\n static info(...args) {\n log.info.apply(null, prepareLine(\"I\", args));\n }\n\n static warn(...args) {\n log.warn.apply(null, prepareLine(\"W\", args));\n }\n\n static error(...args) {\n log.error.apply(null, prepareLine(\"E\", args));\n }\n}\n\nexport { Logger };\n"],"names":["loglevelLog"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,WAAW,CAAC,MAAM,EAAE,IAAI;IAC/B,OAAO,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,kBAAkB,MAAM,GAAG,CAAC,CAAC,MAAM,CACpE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CACjB,CAAC;AACJ,CAAC;AAED,MAAM,GAAG,GAAuBA,sBAAW,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;AAE9E,MAAM,MAAM;IAGV,YAAoB,MAAc;QAF1B,WAAM,GAAG,EAAE,CAAC;QAGlB,IAAI,CAAC,M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AClB,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KAC/C;IAED,OAAO,KAAK,CAAC,GAAG,IAAI;QAClB,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KAC/C;IAED,OAAO,IAAI,CAAC,GAAG,IAAI;QACjB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KAC9C;IAED,OAAO,IAAI,CAAC,GAAG,IAAI;QACjB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KAC9C;IAED,OAAO,KAAK,CAAC,GAAG,IAAI;QAClB,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KAC/C;;;;;"}
|
package/dist/media.js
CHANGED
@@ -150,29 +150,39 @@ class Media {
|
|
150
150
|
category: data.category,
|
151
151
|
filename: data.filename,
|
152
152
|
contentType: data.contentType,
|
153
|
-
size: data.size
|
153
|
+
size: data.size,
|
154
154
|
};
|
155
155
|
}
|
156
156
|
/**
|
157
157
|
* Server-assigned unique identifier for the media.
|
158
158
|
*/
|
159
|
-
get sid() {
|
159
|
+
get sid() {
|
160
|
+
return this.state.sid;
|
161
|
+
}
|
160
162
|
/**
|
161
163
|
* File name. Null if absent.
|
162
164
|
*/
|
163
|
-
get filename() {
|
165
|
+
get filename() {
|
166
|
+
return this.state.filename;
|
167
|
+
}
|
164
168
|
/**
|
165
169
|
* Content type of the media.
|
166
170
|
*/
|
167
|
-
get contentType() {
|
171
|
+
get contentType() {
|
172
|
+
return this.state.contentType;
|
173
|
+
}
|
168
174
|
/**
|
169
175
|
* Size of the media in bytes.
|
170
176
|
*/
|
171
|
-
get size() {
|
177
|
+
get size() {
|
178
|
+
return this.state.size;
|
179
|
+
}
|
172
180
|
/**
|
173
181
|
* Media category, can be one of the {@link MediaCategory} values.
|
174
182
|
*/
|
175
|
-
get category() {
|
183
|
+
get category() {
|
184
|
+
return this.state.category;
|
185
|
+
}
|
176
186
|
/**
|
177
187
|
* Returns the direct content URL for the media.
|
178
188
|
*
|
@@ -181,8 +191,9 @@ class Media {
|
|
181
191
|
* Each call to this function produces a new temporary URL.
|
182
192
|
*/
|
183
193
|
async getContentTemporaryUrl() {
|
194
|
+
var _a, _b;
|
184
195
|
await this._fetchMcsMedia();
|
185
|
-
return this.mcsMedia.getContentUrl();
|
196
|
+
return (_b = (_a = this.mcsMedia) === null || _a === void 0 ? void 0 : _a.getContentUrl()) !== null && _b !== void 0 ? _b : null;
|
186
197
|
}
|
187
198
|
/**
|
188
199
|
* Returns cached direct content URL for the media.
|
@@ -194,8 +205,9 @@ class Media {
|
|
194
205
|
* @returns {Promise<String>}
|
195
206
|
*/
|
196
207
|
async getCachedTemporaryUrl() {
|
208
|
+
var _a, _b;
|
197
209
|
await this._fetchMcsMedia();
|
198
|
-
return this.mcsMedia.getCachedContentUrl();
|
210
|
+
return (_b = (_a = this.mcsMedia) === null || _a === void 0 ? void 0 : _a.getCachedContentUrl()) !== null && _b !== void 0 ? _b : null;
|
199
211
|
}
|
200
212
|
async _fetchMcsMedia() {
|
201
213
|
if (!this.mcsMedia) {
|
@@ -203,7 +215,7 @@ class Media {
|
|
203
215
|
this.mcsMedia = await this.services.mcsClient.get(this.state.sid);
|
204
216
|
}
|
205
217
|
else {
|
206
|
-
throw new Error(
|
218
|
+
throw new Error("Media Content Service is unavailable");
|
207
219
|
}
|
208
220
|
}
|
209
221
|
}
|
package/dist/media.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"media.js","sources":["../src/media.ts"],"sourcesContent":["import {\n McsClient,\n McsMedia,\n MediaCategory as McsMediaCategory
|
1
|
+
{"version":3,"file":"media.js","sources":["../src/media.ts"],"sourcesContent":["import {\n McsClient,\n McsMedia,\n MediaCategory as McsMediaCategory,\n} from \"@twilio/mcs-client\";\n\n/**\n * Category of media. Possible values are as follows:\n * * `'media'`\n * * `'body'`\n * * `'history'`\n */\ntype MediaCategory = McsMediaCategory;\n\ninterface MediaState {\n sid: string;\n category: MediaCategory;\n filename: string | null;\n contentType: string;\n size: number;\n}\n\ninterface MediaServices {\n mcsClient: McsClient;\n}\n\n/**\n * Represents a media information for a message in a conversation.\n */\nclass Media {\n private state: MediaState;\n private services: MediaServices;\n private mcsMedia: McsMedia | null = null;\n\n /**\n * @internal\n */\n constructor(data: MediaState | McsMedia, services: MediaServices) {\n this.services = services;\n\n if (data instanceof McsMedia) {\n this.mcsMedia = data as McsMedia;\n }\n\n this.state = {\n sid: data.sid,\n category: data.category,\n filename: data.filename,\n contentType: data.contentType,\n size: data.size,\n };\n }\n\n /**\n * Server-assigned unique identifier for the media.\n */\n public get sid(): string {\n return this.state.sid;\n }\n\n /**\n * File name. Null if absent.\n */\n public get filename(): string | null {\n return this.state.filename;\n }\n\n /**\n * Content type of the media.\n */\n public get contentType(): string {\n return this.state.contentType;\n }\n\n /**\n * Size of the media in bytes.\n */\n public get size(): number {\n return this.state.size;\n }\n\n /**\n * Media category, can be one of the {@link MediaCategory} values.\n */\n public get category(): MediaCategory {\n return this.state.category;\n }\n\n /**\n * Returns the direct content URL for the media.\n *\n * This URL is impermanent, it will expire in several minutes and cannot be cached.\n * If the URL becomes expired, you need to request a new one.\n * Each call to this function produces a new temporary URL.\n */\n public async getContentTemporaryUrl(): Promise<string | null> {\n await this._fetchMcsMedia();\n return this.mcsMedia?.getContentUrl() ?? null;\n }\n\n /**\n * Returns cached direct content URL for the media.\n *\n * This URL will expire in several minutes. This function does not refresh the URL and can be used to query it several times\n * without causing network traffic.\n * If the URL becomes expired, you need to request a new one using getContentTemporaryUrl().\n *\n * @returns {Promise<String>}\n */\n public async getCachedTemporaryUrl(): Promise<string | null> {\n await this._fetchMcsMedia();\n return this.mcsMedia?.getCachedContentUrl() ?? null;\n }\n\n private async _fetchMcsMedia() {\n if (!this.mcsMedia) {\n if (this.services.mcsClient) {\n this.mcsMedia = await this.services.mcsClient.get(this.state.sid);\n } else {\n throw new Error(\"Media Content Service is unavailable\");\n }\n }\n }\n}\n\nexport { Media, MediaState, MediaServices, MediaCategory };\n"],"names":["McsMedia"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;;AAGA,MAAM,KAAK;;;;IAQT,YAAY,IAA2B,EAAE,QAAuB;QALxD,aAAQ,GAAoB,IAAI,CAAC;QAMvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,IAAI,YAAYA,kBAAQ,EAAE;YAC5B,IAAI,CAAC,QAAQ,GAAG,IAAgB,CAAC;SAClC;QAED,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;KACH;;;;IAKD,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;KACvB;;;;IAKD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;KAC5B;;;;IAKD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;KAC/B;;;;IAKD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;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