@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,152 @@
|
|
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
|
+
/**
|
134
|
+
* Push notification for a Conversations client.
|
135
|
+
*/
|
136
|
+
class PushNotification {
|
137
|
+
/**
|
138
|
+
* @internal
|
139
|
+
*/
|
140
|
+
constructor(data) {
|
141
|
+
this.title = data.title || null;
|
142
|
+
this.body = data.body || null;
|
143
|
+
this.sound = data.sound || null;
|
144
|
+
this.badge = data.badge || null;
|
145
|
+
this.action = data.action || null;
|
146
|
+
this.type = data.type || null;
|
147
|
+
this.data = data.data || {};
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
exports.PushNotification = PushNotification;
|
152
|
+
//# sourceMappingURL=push-notification.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"push-notification.js","sources":["../../src/push-notification.ts"],"sourcesContent":["/**\n * Push notification type.\n */\ntype PushNotificationType =\n | 'twilio.conversations.new_message'\n | 'twilio.conversations.added_to_conversation'\n | 'twilio.conversations.removed_from_conversation';\n\ninterface PushNotificationDescriptor {\n title: string;\n body: string;\n sound: string;\n badge: number;\n action: string;\n type: PushNotificationType;\n data: Object;\n}\n\n/**\n * Additional data for a given push notification.\n */\ninterface PushNotificationData {\n /**\n * SID of the conversation.\n */\n conversationSid?: string;\n\n /**\n * Index of the message in the conversation.\n */\n messageIndex?: number;\n\n /**\n * SID of the message in the conversation.\n */\n messageSid?: string;\n}\n\n/**\n * Push notification for a Conversations client.\n */\nclass PushNotification {\n /**\n * Title of the notification.\n */\n public readonly title: string;\n\n /**\n * Text of the notification.\n */\n public readonly body: string;\n\n /**\n * Sound of the notification.\n */\n public readonly sound: string;\n\n /**\n * Number of the badge.\n */\n public readonly badge: number;\n\n /**\n * Notification action (`click_action` in FCM terms and `category` in APN terms).\n */\n public readonly action: string;\n\n /**\n * Type of the notification.\n */\n public readonly type: PushNotificationType;\n\n /**\n * Additional data of the conversation.\n */\n public readonly data: PushNotificationData;\n\n /**\n * @internal\n */\n constructor(data: PushNotificationDescriptor) {\n this.title = data.title || null;\n this.body = data.body || null;\n this.sound = data.sound || null;\n this.badge = data.badge || null;\n this.action = data.action || null;\n this.type = data.type || null;\n this.data = data.data || {};\n }\n}\n\nexport {\n PushNotification,\n PushNotificationType,\n PushNotificationDescriptor,\n PushNotificationData\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;;;AAGA,MAAM,gBAAgB;;;;IAuCpB,YAAY,IAAgC;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;KAC7B;;;;;"}
|
@@ -0,0 +1,175 @@
|
|
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
|
+
/**
|
134
|
+
* Pagination helper class.
|
135
|
+
*/
|
136
|
+
class RestPaginator {
|
137
|
+
/**
|
138
|
+
* @internal
|
139
|
+
*/
|
140
|
+
constructor(items, source, prevToken, nextToken) {
|
141
|
+
this.state = {
|
142
|
+
prevToken,
|
143
|
+
nextToken,
|
144
|
+
source,
|
145
|
+
items
|
146
|
+
};
|
147
|
+
}
|
148
|
+
/**
|
149
|
+
* Indicates the existence of the next page.
|
150
|
+
*/
|
151
|
+
get hasNextPage() { return !!this.state.nextToken; }
|
152
|
+
/**
|
153
|
+
* Indicates the existence of the previous page
|
154
|
+
*/
|
155
|
+
get hasPrevPage() { return !!this.state.prevToken; }
|
156
|
+
/**
|
157
|
+
* Array of elements on the current page.
|
158
|
+
*/
|
159
|
+
get items() { return this.state.items; }
|
160
|
+
/**
|
161
|
+
* Request the next page. Does not modify the existing object.
|
162
|
+
*/
|
163
|
+
nextPage() {
|
164
|
+
return this.hasNextPage ? this.state.source(this.state.nextToken) : Promise.reject(new Error('No next page'));
|
165
|
+
}
|
166
|
+
/**
|
167
|
+
* Request the previous page. Does not modify the existing object.
|
168
|
+
*/
|
169
|
+
prevPage() {
|
170
|
+
return this.hasPrevPage ? this.state.source(this.state.prevToken) : Promise.reject(new Error('No previous page'));
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
exports.RestPaginator = RestPaginator;
|
175
|
+
//# sourceMappingURL=rest-paginator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"rest-paginator.js","sources":["../../src/rest-paginator.ts"],"sourcesContent":["import { Paginator } from './interfaces/paginator';\n\ninterface PaginatorState {\n source: any;\n nextToken: any;\n prevToken: any;\n items: any;\n}\n\n/**\n * Pagination helper class.\n */\nclass RestPaginator<T> implements Paginator<T> {\n private state: PaginatorState;\n\n /**\n * Indicates the existence of the next page.\n */\n public get hasNextPage(): boolean { return !!this.state.nextToken; }\n\n /**\n * Indicates the existence of the previous page\n */\n public get hasPrevPage(): boolean { return !!this.state.prevToken; }\n\n /**\n * Array of elements on the current page.\n */\n public get items(): Array<T> { return this.state.items; }\n\n /**\n * @internal\n */\n constructor(items, source, prevToken, nextToken) {\n this.state = {\n prevToken,\n nextToken,\n source,\n items\n };\n }\n\n /**\n * Request the next page. Does not modify the existing object.\n */\n nextPage(): Promise<RestPaginator<T>> {\n return this.hasNextPage ? this.state.source(this.state.nextToken) : Promise.reject(new Error('No next page'));\n }\n\n /**\n * Request the previous page. Does not modify the existing object.\n */\n prevPage(): Promise<RestPaginator<T>> {\n return this.hasPrevPage ? this.state.source(this.state.prevToken) : Promise.reject(new Error('No previous page'));\n }\n}\n\nexport { RestPaginator };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;;AAGA,MAAM,aAAa;;;;IAqBjB,YAAY,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS;QAC7C,IAAI,CAAC,KAAK,GAAG;YACX,SAAS;YACT,SAAS;YACT,MAAM;YACN,KAAK;SACN,CAAC;KACH;;;;IAtBD,IAAW,WAAW,KAAc,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;;;;IAKpE,IAAW,WAAW,KAAc,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;;;;IAKpE,IAAW,KAAK,KAAe,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;;;;IAiBzD,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;KAC/G;;;;IAKD,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;KACnH;;;;;"}
|
@@ -0,0 +1,205 @@
|
|
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 operationRetrier = require('@twilio/operation-retrier');
|
134
|
+
|
135
|
+
class Network {
|
136
|
+
constructor(configuration, services) {
|
137
|
+
this.configuration = configuration;
|
138
|
+
this.services = services;
|
139
|
+
this.cache = new Map();
|
140
|
+
this.cacheLifetime = this.configuration.httpCacheInterval * 100;
|
141
|
+
this.cleanupCache();
|
142
|
+
}
|
143
|
+
isExpired(timestamp) {
|
144
|
+
return !this.cacheLifetime || (Date.now() - timestamp) > this.cacheLifetime;
|
145
|
+
}
|
146
|
+
cleanupCache() {
|
147
|
+
for (let [k, v] of this.cache) {
|
148
|
+
if (this.isExpired(v.timestamp)) {
|
149
|
+
this.cache.delete(k);
|
150
|
+
}
|
151
|
+
}
|
152
|
+
if (this.cache.size === 0) {
|
153
|
+
clearInterval(this.timer);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
pokeTimer() {
|
157
|
+
this.timer = this.timer || setInterval(() => this.cleanupCache(), this.cacheLifetime * 2);
|
158
|
+
}
|
159
|
+
executeWithRetry(request, retryWhenThrottled = false) {
|
160
|
+
return new Promise((resolve, reject) => {
|
161
|
+
let codesToRetryOn = [502, 503, 504];
|
162
|
+
if (retryWhenThrottled) {
|
163
|
+
codesToRetryOn.push(429);
|
164
|
+
}
|
165
|
+
let retrier = new operationRetrier.Retrier(this.configuration.backoffConfiguration);
|
166
|
+
retrier.on('attempt', () => {
|
167
|
+
request()
|
168
|
+
.then(result => retrier.succeeded(result))
|
169
|
+
.catch(err => {
|
170
|
+
if (codesToRetryOn.indexOf(err.status) > -1) {
|
171
|
+
retrier.failed(err);
|
172
|
+
}
|
173
|
+
else if (err.message === 'Twilsock disconnected') {
|
174
|
+
// Ugly hack. We must make a proper exceptions for twilsock
|
175
|
+
retrier.failed(err);
|
176
|
+
}
|
177
|
+
else {
|
178
|
+
// Fatal error
|
179
|
+
retrier.removeAllListeners();
|
180
|
+
retrier.cancel();
|
181
|
+
reject(err);
|
182
|
+
}
|
183
|
+
});
|
184
|
+
});
|
185
|
+
retrier.on('succeeded', result => { resolve(result); });
|
186
|
+
retrier.on('cancelled', err => reject(err));
|
187
|
+
retrier.on('failed', err => reject(err));
|
188
|
+
retrier.start();
|
189
|
+
});
|
190
|
+
}
|
191
|
+
async get(url) {
|
192
|
+
let cacheEntry = this.cache.get(url);
|
193
|
+
if (cacheEntry && !this.isExpired(cacheEntry.timestamp)) {
|
194
|
+
return cacheEntry.response;
|
195
|
+
}
|
196
|
+
const headers = {};
|
197
|
+
let response = await this.executeWithRetry(() => this.services.transport.get(url, headers, this.configuration.productId), this.configuration.retryWhenThrottled);
|
198
|
+
this.cache.set(url, { response, timestamp: Date.now() });
|
199
|
+
this.pokeTimer();
|
200
|
+
return response;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
exports.Network = Network;
|
205
|
+
//# sourceMappingURL=network.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"network.js","sources":["../../../src/services/network.ts"],"sourcesContent":["import { Retrier } from '@twilio/operation-retrier';\nimport { Transport } from 'twilsock';\nimport { Configuration } from '../configuration';\n\ninterface CacheEntry {\n response: Object;\n timestamp: number;\n}\n\nexport interface NetworkServices {\n transport: Transport;\n}\n\nclass Network {\n private readonly configuration: Configuration;\n private readonly services: NetworkServices;\n private cacheLifetime: number;\n\n private readonly cache: Map<string, CacheEntry>;\n private timer: any;\n\n constructor(configuration, services) {\n this.configuration = configuration;\n this.services = services;\n this.cache = new Map<string, CacheEntry>();\n this.cacheLifetime = this.configuration.httpCacheInterval * 100;\n this.cleanupCache();\n }\n\n private isExpired(timestamp: number): boolean {\n return !this.cacheLifetime || (Date.now() - timestamp) > this.cacheLifetime;\n }\n\n private cleanupCache() {\n for (let [k, v] of this.cache) {\n if (this.isExpired(v.timestamp)) {\n this.cache.delete(k);\n }\n }\n\n if (this.cache.size === 0) {\n clearInterval(this.timer);\n }\n }\n\n pokeTimer() {\n this.timer = this.timer || setInterval(() => this.cleanupCache(), this.cacheLifetime * 2);\n }\n\n private executeWithRetry(request, retryWhenThrottled = false): Promise<any> {\n return new Promise((resolve, reject) => {\n let codesToRetryOn = [502, 503, 504];\n if (retryWhenThrottled) {\n codesToRetryOn.push(429);\n }\n\n let retrier = new Retrier(this.configuration.backoffConfiguration);\n retrier.on('attempt', () => {\n request()\n .then(result => retrier.succeeded(result))\n .catch(err => {\n if (codesToRetryOn.indexOf(err.status) > -1) {\n retrier.failed(err);\n } else if (err.message === 'Twilsock disconnected') {\n // Ugly hack. We must make a proper exceptions for twilsock\n retrier.failed(err);\n } else {\n // Fatal error\n retrier.removeAllListeners();\n retrier.cancel();\n reject(err);\n }\n });\n });\n\n retrier.on('succeeded', result => { resolve(result); });\n retrier.on('cancelled', err => reject(err));\n retrier.on('failed', err => reject(err));\n\n retrier.start();\n });\n }\n\n async get(url: string) {\n let cacheEntry = this.cache.get(url);\n if (cacheEntry && !this.isExpired(cacheEntry.timestamp)) {\n return cacheEntry.response;\n }\n\n const headers = {};\n let response = await this.executeWithRetry(\n () => this.services.transport.get(\n url,\n headers,\n this.configuration.productId\n ),\n this.configuration.retryWhenThrottled\n );\n this.cache.set(url, { response, timestamp: Date.now() });\n this.pokeTimer();\n return response;\n }\n}\n\nexport { Network };\n"],"names":["Retrier"],"mappings":"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"}
|