@twilio/conversations 3.0.0-rc.9 → 3.0.1-rc.102
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 +38 -28
- package/builds/browser.js +1659 -264
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +650 -25
- package/builds/lib.js +1650 -264
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +4300 -1842
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/aggregated-delivery-receipt.js +10 -1
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +192 -0
- package/dist/channel-metadata-client.js.map +1 -0
- package/dist/client.js +70 -10
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +48 -6
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +14 -3
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +184 -0
- package/dist/content-client.js.map +1 -0
- package/dist/content-template.js +310 -0
- package/dist/content-template.js.map +1 -0
- package/dist/conversation.js +59 -16
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +25 -3
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +23 -6
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +17 -8
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +9 -0
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +9 -0
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/notification-types.js +9 -0
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/interfaces/{attributes.js → rules.js} +26 -7
- package/dist/interfaces/rules.js.map +1 -0
- package/dist/logger.js +9 -0
- package/dist/logger.js.map +1 -1
- package/dist/media.js +9 -0
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +77 -6
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +156 -12
- package/dist/message.js.map +1 -1
- package/dist/node_modules/quick-lru/index.js +265 -0
- package/dist/node_modules/quick-lru/index.js.map +1 -0
- package/dist/node_modules/tslib/tslib.es6.js +9 -0
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +10 -1
- package/dist/packages/conversations/package.json.js.map +1 -1
- package/dist/participant.js +11 -2
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +9 -0
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +9 -0
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +9 -0
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +9 -0
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +9 -0
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +20 -3
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +9 -0
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +9 -0
- package/dist/util/index.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +1 -1
- package/docs/classes/ChannelMetadata.html +3050 -0
- package/docs/classes/Client.html +64 -25
- package/docs/classes/ContentTemplate.html +3116 -0
- package/docs/classes/ContentTemplateVariable.html +3116 -0
- package/docs/classes/Conversation.html +14 -9
- package/docs/classes/Message.html +76 -5
- package/docs/classes/MessageBuilder.html +41 -0
- package/docs/classes/Participant.html +2 -2
- package/docs/index.html +849 -25
- package/docs/interfaces/ClientOptions.html +16 -0
- package/docs/modules.html +848 -24
- package/package.json +18 -14
- package/CHANGELOG.md +0 -509
- package/dist/interfaces/attributes.js.map +0 -1
@@ -128,13 +128,22 @@ This software includes platform.js under the following license.
|
|
128
128
|
*/
|
129
129
|
'use strict';
|
130
130
|
|
131
|
+
var global =
|
132
|
+
typeof global !== "undefined"
|
133
|
+
? global
|
134
|
+
: typeof self !== "undefined"
|
135
|
+
? self
|
136
|
+
: typeof window !== "undefined"
|
137
|
+
? window
|
138
|
+
: {};
|
139
|
+
|
131
140
|
Object.defineProperty(exports, '__esModule', { value: true });
|
132
141
|
|
133
142
|
/**
|
134
143
|
* Contains aggregated information about delivery statuses of a message across all participants
|
135
144
|
* of a conversation.
|
136
145
|
*
|
137
|
-
* At any moment during the message delivery to a participant, the message can have zero or more of following
|
146
|
+
* At any moment during the message delivery to a participant, the message can have zero or more of the following
|
138
147
|
* delivery statuses:
|
139
148
|
* * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
140
149
|
* * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"aggregated-delivery-receipt.js","sources":["../src/aggregated-delivery-receipt.ts"],"sourcesContent":["/**\n * Signifies the amount of participants which have the status for the message.\n */\ntype DeliveryAmount = \"none\" | \"some\" | \"all\";\n\ninterface AggregatedDeliveryDescriptor {\n total: number;\n delivered: DeliveryAmount;\n failed: DeliveryAmount;\n read: DeliveryAmount;\n sent: DeliveryAmount;\n undelivered: DeliveryAmount;\n}\n\n/**\n * Contains aggregated information about delivery statuses of a message across all participants\n * of a conversation.\n *\n * At any moment during the message delivery to a participant, the message can have zero or more of following\n * delivery statuses:\n * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.\n * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message\n * delivery from the upstream carrier, and, where available, the destination handset.\n * * Message considered as **undelivered** to a participant if Twilio has received a delivery receipt\n * indicating that the message was not delivered. This can happen for many reasons including carrier content\n * filtering and the availability of the destination handset.\n * * Message considered as **read** by a participant if the message has been delivered and opened by the\n * recipient in a conversation. The recipient must have enabled the read receipts.\n * * Message considered as **failed** to be delivered to a participant if the message could not be sent.\n * This can happen for various reasons including queue overflows, account suspensions and media\n * errors (in the case of MMS for instance).\n *\n * {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.\n */\nclass AggregatedDeliveryReceipt {\n private state: AggregatedDeliveryDescriptor;\n\n /**\n * @internal\n */\n constructor(data: AggregatedDeliveryDescriptor) {\n this.state = data;\n }\n\n /**\n * Maximum number of delivery events expected for the message.\n */\n public get total(): number {\n return this.state.total;\n }\n\n /**\n * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.\n *\n * @return Amount of participants that have the **sent** delivery status for the message.\n */\n public get sent(): DeliveryAmount {\n return this.state.sent;\n }\n\n /**\n * Message is considered as **delivered** to a participant if Twilio has received confirmation of message\n * delivery from the upstream carrier, and, where available, the destination handset.\n *\n * @return Amount of participants that have the **delivered** delivery status for the message.\n */\n public get delivered(): DeliveryAmount {\n return this.state.delivered;\n }\n\n /**\n * Message is considered as **read** by a participant, if the message has been delivered and opened by the\n * recipient in a conversation. The recipient must have enabled the read receipts.\n *\n * @return Amount of participants that have the **read** delivery status for the message.\n */\n public get read(): DeliveryAmount {\n return this.state.read;\n }\n\n /**\n * Message is considered as **undelivered** to a participant if Twilio has received a delivery receipt\n * indicating that the message was not delivered. This can happen for many reasons including carrier content\n * filtering and the availability of the destination handset.\n *\n * @return Ammount of participants that have the **undelivered** delivery status for the message.\n */\n public get undelivered(): DeliveryAmount {\n return this.state.undelivered;\n }\n\n /**\n * Message is considered as **failed** to be delivered to a participant if the message could not be sent.\n * This can happen for various reasons including queue overflows, account suspensions and media\n * errors (in the case of MMS for instance). Twilio does not charge you for failed messages.\n *\n * @return Amount of participants that have the **failed** delivery status for the message.\n */\n public get failed(): DeliveryAmount {\n return this.state.failed;\n }\n\n _update(data: AggregatedDeliveryDescriptor): void {\n this.state = data;\n }\n\n _isEquals(data: AggregatedDeliveryDescriptor): boolean {\n const isTotalSame = this.total === data.total;\n const isSentSame = this.sent === data.sent;\n const isDeliveredSame = this.delivered === data.delivered;\n const isReadSame = this.read === data.read;\n const isUndeliveredSame = this.undelivered === data.undelivered;\n const isFailedSame = this.failed === data.failed;\n\n return (\n isTotalSame &&\n isSentSame &&\n isDeliveredSame &&\n isReadSame &&\n isUndeliveredSame &&\n isFailedSame\n );\n }\n}\n\nexport {\n AggregatedDeliveryReceipt,\n AggregatedDeliveryDescriptor,\n DeliveryAmount,\n};\n"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"aggregated-delivery-receipt.js","sources":["../src/aggregated-delivery-receipt.ts"],"sourcesContent":["/**\n * Signifies the amount of participants which have the status for the message.\n */\ntype DeliveryAmount = \"none\" | \"some\" | \"all\";\n\ninterface AggregatedDeliveryDescriptor {\n total: number;\n delivered: DeliveryAmount;\n failed: DeliveryAmount;\n read: DeliveryAmount;\n sent: DeliveryAmount;\n undelivered: DeliveryAmount;\n}\n\n/**\n * Contains aggregated information about delivery statuses of a message across all participants\n * of a conversation.\n *\n * At any moment during the message delivery to a participant, the message can have zero or more of the following\n * delivery statuses:\n * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.\n * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message\n * delivery from the upstream carrier, and, where available, the destination handset.\n * * Message considered as **undelivered** to a participant if Twilio has received a delivery receipt\n * indicating that the message was not delivered. This can happen for many reasons including carrier content\n * filtering and the availability of the destination handset.\n * * Message considered as **read** by a participant if the message has been delivered and opened by the\n * recipient in a conversation. The recipient must have enabled the read receipts.\n * * Message considered as **failed** to be delivered to a participant if the message could not be sent.\n * This can happen for various reasons including queue overflows, account suspensions and media\n * errors (in the case of MMS for instance).\n *\n * {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.\n */\nclass AggregatedDeliveryReceipt {\n private state: AggregatedDeliveryDescriptor;\n\n /**\n * @internal\n */\n constructor(data: AggregatedDeliveryDescriptor) {\n this.state = data;\n }\n\n /**\n * Maximum number of delivery events expected for the message.\n */\n public get total(): number {\n return this.state.total;\n }\n\n /**\n * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.\n *\n * @return Amount of participants that have the **sent** delivery status for the message.\n */\n public get sent(): DeliveryAmount {\n return this.state.sent;\n }\n\n /**\n * Message is considered as **delivered** to a participant if Twilio has received confirmation of message\n * delivery from the upstream carrier, and, where available, the destination handset.\n *\n * @return Amount of participants that have the **delivered** delivery status for the message.\n */\n public get delivered(): DeliveryAmount {\n return this.state.delivered;\n }\n\n /**\n * Message is considered as **read** by a participant, if the message has been delivered and opened by the\n * recipient in a conversation. The recipient must have enabled the read receipts.\n *\n * @return Amount of participants that have the **read** delivery status for the message.\n */\n public get read(): DeliveryAmount {\n return this.state.read;\n }\n\n /**\n * Message is considered as **undelivered** to a participant if Twilio has received a delivery receipt\n * indicating that the message was not delivered. This can happen for many reasons including carrier content\n * filtering and the availability of the destination handset.\n *\n * @return Ammount of participants that have the **undelivered** delivery status for the message.\n */\n public get undelivered(): DeliveryAmount {\n return this.state.undelivered;\n }\n\n /**\n * Message is considered as **failed** to be delivered to a participant if the message could not be sent.\n * This can happen for various reasons including queue overflows, account suspensions and media\n * errors (in the case of MMS for instance). Twilio does not charge you for failed messages.\n *\n * @return Amount of participants that have the **failed** delivery status for the message.\n */\n public get failed(): DeliveryAmount {\n return this.state.failed;\n }\n\n _update(data: AggregatedDeliveryDescriptor): void {\n this.state = data;\n }\n\n _isEquals(data: AggregatedDeliveryDescriptor): boolean {\n const isTotalSame = this.total === data.total;\n const isSentSame = this.sent === data.sent;\n const isDeliveredSame = this.delivered === data.delivered;\n const isReadSame = this.read === data.read;\n const isUndeliveredSame = this.undelivered === data.undelivered;\n const isFailedSame = this.failed === data.failed;\n\n return (\n isTotalSame &&\n isSentSame &&\n isDeliveredSame &&\n isReadSame &&\n isUndeliveredSame &&\n isFailedSame\n );\n }\n}\n\nexport {\n AggregatedDeliveryReceipt,\n AggregatedDeliveryDescriptor,\n DeliveryAmount,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;;;;;AAmBG;AACH,MAAM,yBAAyB,CAAA;AAG7B;;AAEG;AACH,IAAA,WAAA,CAAY,IAAkC,EAAA;AAC5C,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;KACnB;AAED;;AAEG;AACH,IAAA,IAAW,KAAK,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;KACzB;AAED;;;;AAIG;AACH,IAAA,IAAW,IAAI,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;KACxB;AAED;;;;;AAKG;AACH,IAAA,IAAW,SAAS,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;KAC7B;AAED;;;;;AAKG;AACH,IAAA,IAAW,IAAI,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;KACxB;AAED;;;;;;AAMG;AACH,IAAA,IAAW,WAAW,GAAA;AACpB,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;KAC/B;AAED;;;;;;AAMG;AACH,IAAA,IAAW,MAAM,GAAA;AACf,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;KAC1B;AAED,IAAA,OAAO,CAAC,IAAkC,EAAA;AACxC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;KACnB;AAED,IAAA,SAAS,CAAC,IAAkC,EAAA;QAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC;QAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;QAC3C,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC;QAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;QAC3C,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC;QAChE,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC;AAEjD,QAAA,QACE,WAAW;YACX,UAAU;YACV,eAAe;YACf,UAAU;YACV,iBAAiB;AACjB,YAAA,YAAY,EACZ;KACH;AACF;;;;"}
|
@@ -0,0 +1,192 @@
|
|
1
|
+
/*
|
2
|
+
@license
|
3
|
+
The following license applies to all parts of this software except as
|
4
|
+
documented below.
|
5
|
+
|
6
|
+
Copyright (c) 2019, Twilio, inc.
|
7
|
+
All rights reserved.
|
8
|
+
|
9
|
+
Redistribution and use in source and binary forms, with or without
|
10
|
+
modification, are permitted provided that the following conditions are
|
11
|
+
met:
|
12
|
+
|
13
|
+
1. Redistributions of source code must retain the above copyright
|
14
|
+
notice, this list of conditions and the following disclaimer.
|
15
|
+
|
16
|
+
2. Redistributions in binary form must reproduce the above copyright
|
17
|
+
notice, this list of conditions and the following disclaimer in
|
18
|
+
the documentation and/or other materials provided with the
|
19
|
+
distribution.
|
20
|
+
|
21
|
+
3. Neither the name of Twilio nor the names of its contributors may
|
22
|
+
be used to endorse or promote products derived from this software
|
23
|
+
without specific prior written permission.
|
24
|
+
|
25
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
26
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
27
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
28
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
29
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
30
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
31
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
32
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
33
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
34
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
35
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36
|
+
|
37
|
+
This software includes javascript-state-machine under the following license.
|
38
|
+
|
39
|
+
Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
42
|
+
of this software and associated documentation files (the "Software"), to deal
|
43
|
+
in the Software without restriction, including without limitation the rights
|
44
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
45
|
+
copies of the Software, and to permit persons to whom the Software is
|
46
|
+
furnished to do so, subject to the following conditions:
|
47
|
+
|
48
|
+
The above copyright notice and this permission notice shall be included in all
|
49
|
+
copies or substantial portions of the Software.
|
50
|
+
|
51
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
52
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
53
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
54
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
55
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
56
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
57
|
+
|
58
|
+
This software includes loglevel under the following license.
|
59
|
+
|
60
|
+
Copyright (c) 2013 Tim Perry
|
61
|
+
|
62
|
+
Permission is hereby granted, free of charge, to any person
|
63
|
+
obtaining a copy of this software and associated documentation
|
64
|
+
files (the "Software"), to deal in the Software without
|
65
|
+
restriction, including without limitation the rights to use,
|
66
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
67
|
+
copies of the Software, and to permit persons to whom the
|
68
|
+
Software is furnished to do so, subject to the following
|
69
|
+
conditions:
|
70
|
+
|
71
|
+
The above copyright notice and this permission notice shall be
|
72
|
+
included in all copies or substantial portions of the Software.
|
73
|
+
|
74
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
75
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
76
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
77
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
78
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
79
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
80
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
81
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
82
|
+
|
83
|
+
This software includes q under the following license.
|
84
|
+
|
85
|
+
Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
|
86
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
87
|
+
of this software and associated documentation files (the "Software"), to
|
88
|
+
deal in the Software without restriction, including without limitation the
|
89
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
90
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
91
|
+
furnished to do so, subject to the following conditions:
|
92
|
+
|
93
|
+
The above copyright notice and this permission notice shall be included in
|
94
|
+
all copies or substantial portions of the Software.
|
95
|
+
|
96
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
97
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
98
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
99
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
100
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
101
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
102
|
+
IN THE SOFTWARE.
|
103
|
+
|
104
|
+
This software includes platform.js under the following license.
|
105
|
+
|
106
|
+
Copyright 2014 Benjamin Tan <https://d10.github.io/>
|
107
|
+
Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
|
108
|
+
|
109
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
110
|
+
a copy of this software and associated documentation files (the
|
111
|
+
"Software"), to deal in the Software without restriction, including
|
112
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
113
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
114
|
+
permit persons to whom the Software is furnished to do so, subject to
|
115
|
+
the following conditions:
|
116
|
+
|
117
|
+
The above copyright notice and this permission notice shall be
|
118
|
+
included in all copies or substantial portions of the Software.
|
119
|
+
|
120
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
121
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
122
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
123
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
124
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
125
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
126
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
127
|
+
|
128
|
+
*/
|
129
|
+
'use strict';
|
130
|
+
|
131
|
+
var global =
|
132
|
+
typeof global !== "undefined"
|
133
|
+
? global
|
134
|
+
: typeof self !== "undefined"
|
135
|
+
? self
|
136
|
+
: typeof window !== "undefined"
|
137
|
+
? window
|
138
|
+
: {};
|
139
|
+
|
140
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
141
|
+
|
142
|
+
var commandExecutor = require('./command-executor.js');
|
143
|
+
var index = require('./node_modules/quick-lru/index.js');
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Represents channel metadata.
|
147
|
+
*/
|
148
|
+
class ChannelMetadata {
|
149
|
+
/**
|
150
|
+
* @internal
|
151
|
+
*/
|
152
|
+
constructor(type, data) {
|
153
|
+
this.type = type;
|
154
|
+
this.data = data;
|
155
|
+
Object.freeze(data);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
class ChannelMetadataClient {
|
159
|
+
constructor(services, configuration) {
|
160
|
+
this._services = services;
|
161
|
+
this._configuration = configuration;
|
162
|
+
this._cache = new index["default"]({
|
163
|
+
maxSize: configuration.channelMetadataCacheCapacity,
|
164
|
+
});
|
165
|
+
}
|
166
|
+
async getChannelMetadata(conversationSid, messageSid) {
|
167
|
+
const key = `${conversationSid},${messageSid}`;
|
168
|
+
const cachedItem = this._cache.get(key);
|
169
|
+
if (cachedItem) {
|
170
|
+
return cachedItem.item;
|
171
|
+
}
|
172
|
+
const url = `${this._configuration.links.conversations}/${conversationSid}/Messages/${messageSid}/ChannelMetadata`;
|
173
|
+
let metadataResponse;
|
174
|
+
try {
|
175
|
+
metadataResponse = await this._services.commandExecutor.fetchResource(url);
|
176
|
+
}
|
177
|
+
catch (e) {
|
178
|
+
if (e instanceof commandExecutor.ChannelMetadataNotFoundError) {
|
179
|
+
this._cache.set(key, { item: null });
|
180
|
+
return null;
|
181
|
+
}
|
182
|
+
throw new Error(e);
|
183
|
+
}
|
184
|
+
const metadata = new ChannelMetadata(metadataResponse.type, metadataResponse.data);
|
185
|
+
this._cache.set(key, { item: metadata });
|
186
|
+
return metadata;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
exports.ChannelMetadata = ChannelMetadata;
|
191
|
+
exports.ChannelMetadataClient = ChannelMetadataClient;
|
192
|
+
//# sourceMappingURL=channel-metadata-client.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"channel-metadata-client.js","sources":["../src/channel-metadata-client.ts"],"sourcesContent":["import {\n ChannelMetadataNotFoundError,\n CommandExecutor,\n} from \"./command-executor\";\nimport { ChannelMetadataResponse } from \"./interfaces/commands/channel-metadata-response\";\nimport QuickLRU from \"quick-lru\";\nimport { Configuration } from \"./configuration\";\n\ntype ChannelMetadataClientServices = {\n commandExecutor: CommandExecutor;\n};\n\ntype CacheEntry = {\n item: ChannelMetadata | null;\n};\n\n/**\n * Represents channel metadata.\n */\nclass ChannelMetadata {\n /**\n * Communication channel type.\n */\n public readonly type: string;\n\n /**\n * The actual metadata.\n */\n public readonly data: unknown;\n\n /**\n * @internal\n */\n public constructor(type: string, data: unknown) {\n this.type = type;\n this.data = data;\n\n Object.freeze(data);\n }\n}\n\nclass ChannelMetadataClient {\n private readonly _services: ChannelMetadataClientServices;\n private readonly _configuration: Configuration;\n private readonly _cache: QuickLRU<string, CacheEntry>;\n\n public constructor(\n services: ChannelMetadataClientServices,\n configuration: Configuration\n ) {\n this._services = services;\n this._configuration = configuration;\n this._cache = new QuickLRU({\n maxSize: configuration.channelMetadataCacheCapacity,\n });\n }\n\n public async getChannelMetadata(\n conversationSid: string,\n messageSid: string\n ): Promise<ChannelMetadata | null> {\n const key = `${conversationSid},${messageSid}`;\n const cachedItem = this._cache.get(key);\n\n if (cachedItem) {\n return cachedItem.item;\n }\n\n const url = `${this._configuration.links.conversations}/${conversationSid}/Messages/${messageSid}/ChannelMetadata`;\n let metadataResponse: ChannelMetadataResponse;\n\n try {\n metadataResponse = await this._services.commandExecutor.fetchResource<\n void,\n ChannelMetadataResponse\n >(url);\n } catch (e) {\n if (e instanceof ChannelMetadataNotFoundError) {\n this._cache.set(key, { item: null });\n return null;\n }\n\n throw new Error(e);\n }\n\n const metadata = new ChannelMetadata(\n metadataResponse.type,\n metadataResponse.data\n );\n this._cache.set(key, { item: metadata });\n return metadata;\n }\n}\n\nexport { ChannelMetadataClient, ChannelMetadata };\n"],"names":["QuickLRU","ChannelMetadataNotFoundError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA;;AAEG;AACH,MAAM,eAAe,CAAA;AAWnB;;AAEG;IACH,WAAmB,CAAA,IAAY,EAAE,IAAa,EAAA;AAC5C,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AAEjB,QAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;KACrB;AACF,CAAA;AAED,MAAM,qBAAqB,CAAA;IAKzB,WACE,CAAA,QAAuC,EACvC,aAA4B,EAAA;AAE5B,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;AAC1B,QAAA,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;AACpC,QAAA,IAAI,CAAC,MAAM,GAAG,IAAIA,gBAAQ,CAAC;YACzB,OAAO,EAAE,aAAa,CAAC,4BAA4B;AACpD,SAAA,CAAC,CAAC;KACJ;AAEM,IAAA,MAAM,kBAAkB,CAC7B,eAAuB,EACvB,UAAkB,EAAA;AAElB,QAAA,MAAM,GAAG,GAAG,CAAA,EAAG,eAAe,CAAI,CAAA,EAAA,UAAU,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAExC,QAAA,IAAI,UAAU,EAAE;YACd,OAAO,UAAU,CAAC,IAAI,CAAC;AACxB,SAAA;AAED,QAAA,MAAM,GAAG,GAAG,CAAG,EAAA,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,aAAa,CAAI,CAAA,EAAA,eAAe,CAAa,UAAA,EAAA,UAAU,kBAAkB,CAAC;AACnH,QAAA,IAAI,gBAAyC,CAAC;QAE9C,IAAI;AACF,YAAA,gBAAgB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,aAAa,CAGnE,GAAG,CAAC,CAAC;AACR,SAAA;AAAC,QAAA,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,YAAYC,4CAA4B,EAAE;AAC7C,gBAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACrC,gBAAA,OAAO,IAAI,CAAC;AACb,aAAA;AAED,YAAA,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;AACpB,SAAA;AAED,QAAA,MAAM,QAAQ,GAAG,IAAI,eAAe,CAClC,gBAAgB,CAAC,IAAI,EACrB,gBAAgB,CAAC,IAAI,CACtB,CAAC;AACF,QAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AACzC,QAAA,OAAO,QAAQ,CAAC;KACjB;AACF;;;;;"}
|
package/dist/client.js
CHANGED
@@ -128,6 +128,15 @@ This software includes platform.js under the following license.
|
|
128
128
|
*/
|
129
129
|
'use strict';
|
130
130
|
|
131
|
+
var global =
|
132
|
+
typeof global !== "undefined"
|
133
|
+
? global
|
134
|
+
: typeof self !== "undefined"
|
135
|
+
? self
|
136
|
+
: typeof window !== "undefined"
|
137
|
+
? window
|
138
|
+
: {};
|
139
|
+
|
131
140
|
Object.defineProperty(exports, '__esModule', { value: true });
|
132
141
|
|
133
142
|
var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
|
@@ -150,6 +159,9 @@ var _package = require('./packages/conversations/package.json.js');
|
|
150
159
|
var commandExecutor = require('./command-executor.js');
|
151
160
|
var replayEventEmitter = require('@twilio/replay-event-emitter');
|
152
161
|
var media = require('./media.js');
|
162
|
+
var deprecationDecorator = require('@twilio/deprecation-decorator');
|
163
|
+
var contentClient = require('./content-client.js');
|
164
|
+
var channelMetadataClient = require('./channel-metadata-client.js');
|
153
165
|
|
154
166
|
var Client_1;
|
155
167
|
/**
|
@@ -256,9 +268,11 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
256
268
|
configurationOptions.typingUri ||
|
257
269
|
`https://aim.${region || "us1"}.twilio.com`;
|
258
270
|
this._services.commandExecutor = new commandExecutor.CommandExecutor(baseUrl, { transport: this._options.transport }, productId);
|
271
|
+
this._services.contentClient = new contentClient.ContentClient(this._services);
|
259
272
|
const emitFailed = (error) => {
|
260
273
|
this._rejectEnsureReady(error);
|
261
|
-
this.emit("stateChanged",
|
274
|
+
this.emit("stateChanged", "failed");
|
275
|
+
this.emit("initFailed", { error });
|
262
276
|
};
|
263
277
|
const emitDisconnected = () => {
|
264
278
|
emitFailed({
|
@@ -266,9 +280,9 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
266
280
|
message: "Twilsock has disconnected.",
|
267
281
|
});
|
268
282
|
};
|
269
|
-
this._services.twilsockClient.
|
270
|
-
this._services.twilsockClient.
|
271
|
-
this._services.twilsockClient.
|
283
|
+
this._services.twilsockClient.once("connectionError", emitFailed);
|
284
|
+
this._services.twilsockClient.once("disconnected", emitDisconnected);
|
285
|
+
this._services.twilsockClient.once("connected", async () => {
|
272
286
|
Client_1._logger.debug(`ConversationsClient started INITIALIZING`);
|
273
287
|
this._services.twilsockClient.off("connectionError", emitFailed);
|
274
288
|
this._services.twilsockClient.off("disconnected", emitDisconnected);
|
@@ -285,7 +299,10 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
285
299
|
message: err.message,
|
286
300
|
};
|
287
301
|
this._rejectEnsureReady(connectionError);
|
288
|
-
this.emit("stateChanged",
|
302
|
+
this.emit("stateChanged", "failed");
|
303
|
+
this.emit("initFailed", {
|
304
|
+
error: connectionError,
|
305
|
+
});
|
289
306
|
}
|
290
307
|
});
|
291
308
|
this._ensureReady = new Promise((resolve, reject) => {
|
@@ -316,6 +333,14 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
316
333
|
}
|
317
334
|
return this._configuration.reachabilityEnabled;
|
318
335
|
}
|
336
|
+
/**
|
337
|
+
* @deprecated
|
338
|
+
* Current token.
|
339
|
+
* @internal
|
340
|
+
*/
|
341
|
+
get token() {
|
342
|
+
return this._fpaToken;
|
343
|
+
}
|
319
344
|
/**
|
320
345
|
* @deprecated Call constructor directly.
|
321
346
|
*
|
@@ -475,7 +500,13 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
475
500
|
async getConversationBySid(conversationSid) {
|
476
501
|
await this._ensureReady;
|
477
502
|
await this._conversationsEntity.myConversationsRead.promise;
|
478
|
-
|
503
|
+
let conversation = await this._conversationsEntity.getConversation(conversationSid);
|
504
|
+
if (!conversation) {
|
505
|
+
conversation = await this.peekConversationBySid(conversationSid);
|
506
|
+
if (conversation) {
|
507
|
+
deprecationDecorator.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");
|
508
|
+
}
|
509
|
+
}
|
479
510
|
if (!conversation) {
|
480
511
|
throw new Error(`Conversation with SID ${conversationSid} was not found.`);
|
481
512
|
}
|
@@ -627,12 +658,21 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
627
658
|
const sids = contentSet.map((m) => m.sid);
|
628
659
|
return this.getTemporaryContentUrlsForMediaSids(sids);
|
629
660
|
}
|
661
|
+
/**
|
662
|
+
* Returns rich content templates belonging to the account. Rich content
|
663
|
+
* templates can be created via the Twilio console or the REST API.
|
664
|
+
*/
|
665
|
+
async getContentTemplates() {
|
666
|
+
await this._ensureReady;
|
667
|
+
return await this._services.contentClient.getContentTemplates();
|
668
|
+
}
|
630
669
|
/**
|
631
670
|
* Initialize the client.
|
632
671
|
*/
|
633
672
|
async _initialize() {
|
634
673
|
const configurationResponse = await this._services.commandExecutor.fetchResource("Client/v2/Configuration");
|
635
674
|
this._configuration = new configuration.Configuration(this._options, configurationResponse, Client_1._logger);
|
675
|
+
this._services.channelMetadataClient = new channelMetadataClient.ChannelMetadataClient(this._services, this._configuration);
|
636
676
|
this._myself._resolveInitialization(this._configuration, this._configuration.userIdentity, this._configuration.userInfo, true);
|
637
677
|
this._services.typingIndicator = new typingIndicator.TypingIndicator(this.getConversationBySid.bind(this), this._configuration, this._services);
|
638
678
|
this._services.network = new network.Network(this._configuration, this._services);
|
@@ -681,7 +721,8 @@ exports.Client = Client_1 = class Client extends replayEventEmitter.ReplayEventE
|
|
681
721
|
this._services.typingIndicator.initialize();
|
682
722
|
this._services.mcsClient = new mcsClient.McsClient(this._fpaToken, this._configuration.links.mediaService, this._configuration.links.mediaSetService, Object.assign(Object.assign({}, this._options), { transport: undefined }));
|
683
723
|
this._resolveEnsureReady();
|
684
|
-
this.emit("stateChanged",
|
724
|
+
this.emit("stateChanged", "initialized");
|
725
|
+
this.emit("initialized");
|
685
726
|
}
|
686
727
|
/**
|
687
728
|
* Subscribe to push notifications.
|
@@ -885,16 +926,29 @@ exports.Client.userUnsubscribed = "userUnsubscribed";
|
|
885
926
|
*/
|
886
927
|
exports.Client.userUpdated = "userUpdated";
|
887
928
|
/**
|
929
|
+
* @deprecated Use initialized or initFailed events instead
|
888
930
|
* Fired when the state of the client has been changed.
|
889
931
|
*
|
890
932
|
* Parameters:
|
933
|
+
* 1. {@link State} `state` - the new client state
|
934
|
+
* @event
|
935
|
+
*/
|
936
|
+
exports.Client.stateChanged = "stateChanged";
|
937
|
+
/**
|
938
|
+
* Fired when the client has completed initialization successfully.
|
939
|
+
* @event
|
940
|
+
*/
|
941
|
+
exports.Client.initialized = "initialized";
|
942
|
+
/**
|
943
|
+
* Fired when the client initialization failed.
|
944
|
+
*
|
945
|
+
* Parameters:
|
891
946
|
* 1. object `data` - info object provided with the event. It has the
|
892
|
-
* following
|
893
|
-
* * {@link State} `state` - the new client state
|
947
|
+
* following property:
|
894
948
|
* * Error? `error` - the initialization error if present
|
895
949
|
* @event
|
896
950
|
*/
|
897
|
-
exports.Client.
|
951
|
+
exports.Client.initFailed = "initFailed";
|
898
952
|
/**
|
899
953
|
* Fired when the connection state of the client has been changed.
|
900
954
|
*
|
@@ -942,6 +996,11 @@ exports.Client._supportedPushDataFields = {
|
|
942
996
|
media_count: "mediaCount",
|
943
997
|
media: "media", // object
|
944
998
|
};
|
999
|
+
tslib_es6.__decorate([
|
1000
|
+
deprecationDecorator.deprecated("token"),
|
1001
|
+
tslib_es6.__metadata("design:type", String),
|
1002
|
+
tslib_es6.__metadata("design:paramtypes", [])
|
1003
|
+
], exports.Client.prototype, "token", null);
|
945
1004
|
tslib_es6.__decorate([
|
946
1005
|
declarativeTypeValidator.validateTypesAsync(declarativeTypeValidator.nonEmptyString),
|
947
1006
|
tslib_es6.__metadata("design:type", Function),
|
@@ -1022,6 +1081,7 @@ tslib_es6.__decorate([
|
|
1022
1081
|
tslib_es6.__metadata("design:returntype", mcsClient.CancellablePromise)
|
1023
1082
|
], exports.Client.prototype, "getTemporaryContentUrlsForMedia", null);
|
1024
1083
|
tslib_es6.__decorate([
|
1084
|
+
deprecationDecorator.deprecated("Client.create()", "new Client()"),
|
1025
1085
|
declarativeTypeValidator.validateTypesAsync("string", ["undefined", declarativeTypeValidator.pureObject]),
|
1026
1086
|
tslib_es6.__metadata("design:type", Function),
|
1027
1087
|
tslib_es6.__metadata("design:paramtypes", [String, Object]),
|