twilio-taskrouter 0.8.5 → 2.0.0

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 CHANGED
@@ -1,3 +1,18 @@
1
+ 2.0.0
2
+ ==========
3
+ New Features
4
+ ----------
5
+ - Added React Native support
6
+ - Added status links to the readme file
7
+ - Added error handling to axios requests
8
+
9
+ Maintenance
10
+ ----------
11
+ - Updated lodash from 4.17.5 to 4.17.21
12
+ - Fixed types in types.d.ts file
13
+ - Changed default branch to main
14
+ - Updated TaskHoldOptions
15
+
1
16
  0.8.5
2
17
  ==========
3
18
  Maintenance
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![build](https://github.com/twilio/twilio-taskrouter.js/actions/workflows/build.yml/badge.svg)](https://github.com/twilio/twilio-taskrouter.js/actions/workflows/build.yml)
2
+ [![Release](https://github.com/twilio/twilio-taskrouter.js/actions/workflows/release.yml/badge.svg)](https://github.com/twilio/twilio-taskrouter.js/actions/workflows/release.yml)
3
+ [![npm version](https://badge.fury.io/js/twilio-taskrouter.svg)](https://badge.fury.io/js/twilio-taskrouter)
4
+
1
5
  # twilio-taskrouter.js
2
6
 
3
7
  [![npm version](https://badge.fury.io/js/twilio-taskrouter.svg)](https://badge.fury.io/js/twilio-taskrouter)
@@ -6,8 +10,7 @@ TaskRouter is Twilio's skills based routing system. With this library, you can m
6
10
 
7
11
  This version of TaskRouter SDK can be used with Twilio Flex and TaskRouter standalone instances.
8
12
 
9
- Installation
10
- ------------
13
+ ## Installation
11
14
 
12
15
  ### NPM
13
16
 
@@ -15,75 +18,91 @@ Installation
15
18
  npm install twilio-taskrouter
16
19
  ```
17
20
 
18
- Usage
19
- -----
21
+ ## Usage
20
22
 
21
23
  The following is a simple example showing a Worker waiting for Reservations.
22
24
  For more information, refer to the
23
25
  [API Docs](//twilio.github.io/twilio-taskrouter.js/index.html).
24
26
 
25
27
  ```js
26
- const TaskRouter = require('twilio-taskrouter');
27
- const Twilio = require('twilio');
28
+ const TaskRouter = require("twilio-taskrouter");
29
+ const Twilio = require("twilio");
28
30
  const AccessToken = Twilio.jwt.AccessToken;
29
31
  const TaskRouterGrant = AccessToken.TaskRouterGrant;
30
32
 
31
- const accountSid = '';
32
- const signingKeySid = '';
33
- const signingKeySecret = '';
34
- const workspaceSid = '';
35
- const workerSid = '';
36
-
37
- const token = createAccessToken(accountSid, signingKeySid, signingKeySecret, workspaceSid, workerSid);
33
+ const accountSid = "";
34
+ const signingKeySid = "";
35
+ const signingKeySecret = "";
36
+ const workspaceSid = "";
37
+ const workerSid = "";
38
+
39
+ const token = createAccessToken(
40
+ accountSid,
41
+ signingKeySid,
42
+ signingKeySecret,
43
+ workspaceSid,
44
+ workerSid
45
+ );
38
46
  const alice = new TaskRouter.Worker(token);
39
47
 
40
- alice.on('ready', readyAlice => {
41
- console.log(`Worker ${readyAlice.sid} is now ready for work`);
48
+ alice.on("ready", (readyAlice) => {
49
+ console.log(`Worker ${readyAlice.sid} is now ready for work`);
42
50
  });
43
51
 
44
- alice.on('reservationCreated', reservation => {
45
- console.log(`Reservation ${reservation.sid} has been created for ${alice.sid}`);
46
- console.log(`Task attributes are: ${reservation.task.attributes}`);
52
+ alice.on("reservationCreated", (reservation) => {
53
+ console.log(
54
+ `Reservation ${reservation.sid} has been created for ${alice.sid}`
55
+ );
56
+ console.log(`Task attributes are: ${reservation.task.attributes}`);
47
57
 
48
- reservation.on('accepted', acceptedReservation => {
49
- console.log(`Reservation ${acceptedReservation.sid} was accepted.`);
50
- });
58
+ reservation.on("accepted", (acceptedReservation) => {
59
+ console.log(`Reservation ${acceptedReservation.sid} was accepted.`);
60
+ });
51
61
 
52
- reservation.accept().then(acceptedReservation => {
62
+ reservation
63
+ .accept()
64
+ .then((acceptedReservation) => {
53
65
  console.log(`Reservation status is ${acceptedReservation.status}`);
54
- }).catch((err) => {
66
+ })
67
+ .catch((err) => {
55
68
  console.log(`Error: ${err}`);
56
69
  });
57
70
  });
58
71
 
59
- function createAccessToken(accountSid, signingKeySid, signingKeySecret, workspaceSid, workerSid) {
60
- const taskRouterGrant = new TaskRouterGrant({
61
- workerSid: workerSid,
62
- workspaceSid: workspaceSid,
63
- role: 'worker'
64
- });
65
-
66
- const accessToken = new AccessToken(accountSid, signingKeySid, signingKeySecret);
67
- accessToken.addGrant(taskRouterGrant);
68
- accessToken.identity = 'alice';
69
-
70
- return accessToken.toJwt();
72
+ function createAccessToken(
73
+ accountSid,
74
+ signingKeySid,
75
+ signingKeySecret,
76
+ workspaceSid,
77
+ workerSid
78
+ ) {
79
+ const taskRouterGrant = new TaskRouterGrant({
80
+ workerSid: workerSid,
81
+ workspaceSid: workspaceSid,
82
+ role: "worker",
83
+ });
84
+
85
+ const accessToken = new AccessToken(
86
+ accountSid,
87
+ signingKeySid,
88
+ signingKeySecret
89
+ );
90
+ accessToken.addGrant(taskRouterGrant);
91
+ accessToken.identity = "alice";
92
+
93
+ return accessToken.toJwt();
71
94
  }
72
-
73
95
  ```
74
96
 
75
- Changelog
76
- ---------
97
+ ## Changelog
77
98
 
78
- See [CHANGELOG.md](https://github.com/twilio/twilio-taskrouter.js/blob/master/CHANGELOG.md).
99
+ See [CHANGELOG.md](https://github.com/twilio/twilio-taskrouter.js/blob/main/CHANGELOG.md).
79
100
 
80
- License
81
- -------
101
+ ## License
82
102
 
83
- See [LICENSE.md](https://github.com/twilio/twilio-taskrouter.js/blob/master/LICENSE.md).
103
+ See [LICENSE.md](https://github.com/twilio/twilio-taskrouter.js/blob/main/LICENSE.md).
84
104
 
85
- Building
86
- --------
105
+ ## Building
87
106
 
88
107
  Fork and clone the repository. Use npm to install node 8 (other versions may run into problems).
89
108
 
@@ -107,19 +126,18 @@ Before commits, be sure to validate by running:
107
126
  make lint
108
127
  ```
109
128
 
110
- Testing
111
- ------------
129
+ ## Testing
130
+
112
131
  - Create a twilio account
113
132
  - copy ./test/integration_test_setup/.env.example to ./test/integration_test_setup/.env
114
133
  - set ACCOUNT_SID, AUTH_TOKEN, SIGNING_KEY_SID, SIGNING_KEY_SECRET
115
134
  - Run ./test/integration_test_setup/RunIntegrationTestLocal.sh this will create everything needed for running E2E tests and run the tests
116
135
 
117
- Test with Sample App
118
- ------------
136
+ ## Test with Sample App
137
+
119
138
  - See [README.md](sample-app/README.md)
120
139
 
121
- Contributing
122
- ------------
140
+ ## Contributing
123
141
 
124
142
  Bug fixes welcome! If you're not familiar with the GitHub pull
125
143
  request/contribution process, [this is a nice tutorial](https://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
@@ -1157,7 +1157,7 @@
1157
1157
  <span class="jsdoc-message">
1158
1158
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
1159
1159
 
1160
- on 2023-09-11T06:18:08+00:00
1160
+ on 2023-09-28T07:41:55+00:00
1161
1161
 
1162
1162
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
1163
1163
  </span>
@@ -1732,7 +1732,7 @@
1732
1732
  <span class="jsdoc-message">
1733
1733
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
1734
1734
 
1735
- on 2023-09-11T06:18:08+00:00
1735
+ on 2023-09-28T07:41:55+00:00
1736
1736
 
1737
1737
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
1738
1738
  </span>
@@ -641,7 +641,7 @@
641
641
  <span class="jsdoc-message">
642
642
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
643
643
 
644
- on 2023-09-11T06:18:08+00:00
644
+ on 2023-09-28T07:41:55+00:00
645
645
 
646
646
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
647
647
  </span>
@@ -1341,7 +1341,7 @@ No more attempts on the <a href="OutgoingTransfer.html">OutgoingTransfer</a> wil
1341
1341
  <span class="jsdoc-message">
1342
1342
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
1343
1343
 
1344
- on 2023-09-11T06:18:08+00:00
1344
+ on 2023-09-28T07:41:55+00:00
1345
1345
 
1346
1346
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
1347
1347
  </span>
@@ -3929,7 +3929,7 @@ in the <a href="Worker.html">Worker</a>'s attributes for this call to go through
3929
3929
  <span class="jsdoc-message">
3930
3930
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
3931
3931
 
3932
- on 2023-09-11T06:18:08+00:00
3932
+ on 2023-09-28T07:41:55+00:00
3933
3933
 
3934
3934
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
3935
3935
  </span>
@@ -4291,7 +4291,7 @@ TaskSid of the created Task.</li>
4291
4291
  <span class="jsdoc-message">
4292
4292
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
4293
4293
 
4294
- on 2023-09-11T06:18:08+00:00
4294
+ on 2023-09-28T07:41:55+00:00
4295
4295
 
4296
4296
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
4297
4297
  </span>
@@ -2444,7 +2444,7 @@
2444
2444
  <td class="type">
2445
2445
 
2446
2446
 
2447
- <span class="param-type"><a href="global.html#HoldOptions">HoldOptions</a></span>
2447
+ <span class="param-type"><a href="global.html#TaskHoldOptions">TaskHoldOptions</a></span>
2448
2448
 
2449
2449
 
2450
2450
 
@@ -4553,7 +4553,7 @@
4553
4553
  <span class="jsdoc-message">
4554
4554
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
4555
4555
 
4556
- on 2023-09-11T06:18:08+00:00
4556
+ on 2023-09-28T07:41:55+00:00
4557
4557
 
4558
4558
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
4559
4559
  </span>
@@ -1635,7 +1635,7 @@
1635
1635
  <span class="jsdoc-message">
1636
1636
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
1637
1637
 
1638
- on 2023-09-11T06:18:08+00:00
1638
+ on 2023-09-28T07:41:55+00:00
1639
1639
 
1640
1640
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
1641
1641
  </span>
@@ -747,7 +747,7 @@
747
747
  <span class="jsdoc-message">
748
748
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
749
749
 
750
- on 2023-09-11T06:18:08+00:00
750
+ on 2023-09-28T07:41:55+00:00
751
751
 
752
752
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
753
753
  </span>
@@ -830,6 +830,8 @@
830
830
 
831
831
  <li><a href="Worker.html#event:reservationCreated">Worker#event:reservationCreated</a></li>
832
832
 
833
+ <li><a href="Worker.html#event:reservationFailed">Worker#event:reservationFailed</a></li>
834
+
833
835
  <li><a href="Worker.html#event:tokenExpired">Worker#event:tokenExpired</a></li>
834
836
 
835
837
  <li><a href="Worker.html#event:tokenUpdated">Worker#event:tokenUpdated</a></li>
@@ -4147,7 +4149,7 @@ TaskSid of the created Task.</li>
4147
4149
  <span class="jsdoc-message">
4148
4150
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
4149
4151
 
4150
- on 2023-09-11T06:18:08+00:00
4152
+ on 2023-09-28T07:41:55+00:00
4151
4153
 
4152
4154
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
4153
4155
  </span>
@@ -1231,7 +1231,7 @@
1231
1231
  <span class="jsdoc-message">
1232
1232
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
1233
1233
 
1234
- on 2023-09-11T06:18:08+00:00
1234
+ on 2023-09-28T07:41:55+00:00
1235
1235
 
1236
1236
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
1237
1237
  </span>
@@ -5346,7 +5346,7 @@ No more attempts on the <a href="OutgoingTransfer.html">OutgoingTransfer</a> wil
5346
5346
  <span class="jsdoc-message">
5347
5347
  Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a>
5348
5348
 
5349
- on 2023-09-11T06:18:08+00:00
5349
+ on 2023-09-28T07:41:55+00:00
5350
5350
 
5351
5351
  using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
5352
5352
  </span>