twilio-taskrouter 0.8.4 → 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,26 @@
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
+
16
+ 0.8.5
17
+ ==========
18
+ Maintenance
19
+ ----------
20
+ - Added sample app for testing integrations
21
+ - Tested SDK with TaskRouter standalone instance
22
+ - Allow Task's and Worker's attributes to be any object
23
+
1
24
  0.8.4
2
25
  ==========
3
26
  Bug Fixes
package/README.md CHANGED
@@ -1,17 +1,16 @@
1
- [![Build Status](https://travis-ci.org/twilio/twilio-taskrouter.js.svg?branch=master)](https://travis-ci.org/twilio/twilio-taskrouter.js)
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)
2
3
  [![npm version](https://badge.fury.io/js/twilio-taskrouter.svg)](https://badge.fury.io/js/twilio-taskrouter)
3
4
 
5
+ # twilio-taskrouter.js
4
6
 
5
- twilio-taskrouter.js
6
- ===============
7
+ [![npm version](https://badge.fury.io/js/twilio-taskrouter.svg)](https://badge.fury.io/js/twilio-taskrouter)
7
8
 
8
9
  TaskRouter is Twilio's skills based routing system. With this library, you can manage your Workers in the browser or view the state of your Workspace.
9
10
 
10
- **NOTE: This SDK is in a Developer Preview Release**. This version of TaskRouter is intended for Twilio Flex. If you are using it outside of Twilio Flex, you may encounter bugs and instability, and
11
- the underlying APIs available in this release may change in subsequent releases.
11
+ This version of TaskRouter SDK can be used with Twilio Flex and TaskRouter standalone instances.
12
12
 
13
- Installation
14
- ------------
13
+ ## Installation
15
14
 
16
15
  ### NPM
17
16
 
@@ -19,75 +18,91 @@ Installation
19
18
  npm install twilio-taskrouter
20
19
  ```
21
20
 
22
- Usage
23
- -----
21
+ ## Usage
24
22
 
25
23
  The following is a simple example showing a Worker waiting for Reservations.
26
24
  For more information, refer to the
27
25
  [API Docs](//twilio.github.io/twilio-taskrouter.js/index.html).
28
26
 
29
27
  ```js
30
- const TaskRouter = require('twilio-taskrouter');
31
- const Twilio = require('twilio');
28
+ const TaskRouter = require("twilio-taskrouter");
29
+ const Twilio = require("twilio");
32
30
  const AccessToken = Twilio.jwt.AccessToken;
33
31
  const TaskRouterGrant = AccessToken.TaskRouterGrant;
34
32
 
35
- const accountSid = '';
36
- const signingKeySid = '';
37
- const signingKeySecret = '';
38
- const workspaceSid = '';
39
- const workerSid = '';
40
-
41
- 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
+ );
42
46
  const alice = new TaskRouter.Worker(token);
43
47
 
44
- alice.on('ready', readyAlice => {
45
- 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`);
46
50
  });
47
51
 
48
- alice.on('reservationCreated', reservation => {
49
- console.log(`Reservation ${reservation.sid} has been created for ${alice.sid}`);
50
- 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}`);
51
57
 
52
- reservation.on('accepted', acceptedReservation => {
53
- console.log(`Reservation ${acceptedReservation.sid} was accepted.`);
54
- });
58
+ reservation.on("accepted", (acceptedReservation) => {
59
+ console.log(`Reservation ${acceptedReservation.sid} was accepted.`);
60
+ });
55
61
 
56
- reservation.accept().then(acceptedReservation => {
62
+ reservation
63
+ .accept()
64
+ .then((acceptedReservation) => {
57
65
  console.log(`Reservation status is ${acceptedReservation.status}`);
58
- }).catch((err) => {
66
+ })
67
+ .catch((err) => {
59
68
  console.log(`Error: ${err}`);
60
69
  });
61
70
  });
62
71
 
63
- function createAccessToken(accountSid, signingKeySid, signingKeySecret, workspaceSid, workerSid) {
64
- const taskRouterGrant = new TaskRouterGrant({
65
- workerSid: workerSid,
66
- workspaceSid: workspaceSid,
67
- role: 'worker'
68
- });
69
-
70
- const accessToken = new AccessToken(accountSid, signingKeySid, signingKeySecret);
71
- accessToken.addGrant(taskRouterGrant);
72
- accessToken.identity = 'alice';
73
-
74
- 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();
75
94
  }
76
-
77
95
  ```
78
96
 
79
- Changelog
80
- ---------
97
+ ## Changelog
81
98
 
82
- 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).
83
100
 
84
- License
85
- -------
101
+ ## License
86
102
 
87
- 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).
88
104
 
89
- Building
90
- --------
105
+ ## Building
91
106
 
92
107
  Fork and clone the repository. Use npm to install node 8 (other versions may run into problems).
93
108
 
@@ -111,15 +126,18 @@ Before commits, be sure to validate by running:
111
126
  make lint
112
127
  ```
113
128
 
114
- Testing
115
- ------------
129
+ ## Testing
130
+
116
131
  - Create a twilio account
117
132
  - copy ./test/integration_test_setup/.env.example to ./test/integration_test_setup/.env
118
133
  - set ACCOUNT_SID, AUTH_TOKEN, SIGNING_KEY_SID, SIGNING_KEY_SECRET
119
134
  - Run ./test/integration_test_setup/RunIntegrationTestLocal.sh this will create everything needed for running E2E tests and run the tests
120
135
 
121
- Contributing
122
- ------------
136
+ ## Test with Sample App
137
+
138
+ - See [README.md](sample-app/README.md)
139
+
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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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-08-01T08:45:21+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>