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 +23 -0
- package/README.md +71 -53
- package/dist/docs/Activity.html +1 -1
- package/dist/docs/Channel.html +1 -1
- package/dist/docs/IncomingTransfer.html +1 -1
- package/dist/docs/OutgoingTransfer.html +1 -1
- package/dist/docs/Reservation.html +1 -1
- package/dist/docs/Supervisor.html +1 -1
- package/dist/docs/Task.html +2 -2
- package/dist/docs/TaskQueue.html +1 -1
- package/dist/docs/Transfers.html +1 -1
- package/dist/docs/Worker.html +3 -1
- package/dist/docs/Workspace.html +1 -1
- package/dist/docs/classes.list.html +1 -1
- package/dist/docs/global.html +103 -85
- package/dist/docs/index.html +63 -38
- package/dist/docs/quicksearch.html +1 -1
- package/dist/index.commonjs2.js +1 -1
- package/dist/index.commonjs2.js.LICENSE.txt +1 -1
- package/dist/index.window.js +2 -2
- package/dist/index.window.js.LICENSE.txt +1 -1
- package/dist/types.d.ts +142 -48
- package/package.json +13 -6
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
|
-
[](https://github.com/twilio/twilio-taskrouter.js/actions/workflows/build.yml)
|
|
2
|
+
[](https://github.com/twilio/twilio-taskrouter.js/actions/workflows/release.yml)
|
|
2
3
|
[](https://badge.fury.io/js/twilio-taskrouter)
|
|
3
4
|
|
|
5
|
+
# twilio-taskrouter.js
|
|
4
6
|
|
|
5
|
-
twilio-taskrouter.js
|
|
6
|
-
===============
|
|
7
|
+
[](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
|
-
|
|
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(
|
|
31
|
-
const Twilio = require(
|
|
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(
|
|
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(
|
|
45
|
-
|
|
48
|
+
alice.on("ready", (readyAlice) => {
|
|
49
|
+
console.log(`Worker ${readyAlice.sid} is now ready for work`);
|
|
46
50
|
});
|
|
47
51
|
|
|
48
|
-
alice.on(
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
reservation.on("accepted", (acceptedReservation) => {
|
|
59
|
+
console.log(`Reservation ${acceptedReservation.sid} was accepted.`);
|
|
60
|
+
});
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
reservation
|
|
63
|
+
.accept()
|
|
64
|
+
.then((acceptedReservation) => {
|
|
57
65
|
console.log(`Reservation status is ${acceptedReservation.status}`);
|
|
58
|
-
})
|
|
66
|
+
})
|
|
67
|
+
.catch((err) => {
|
|
59
68
|
console.log(`Error: ${err}`);
|
|
60
69
|
});
|
|
61
70
|
});
|
|
62
71
|
|
|
63
|
-
function createAccessToken(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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/
|
|
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/
|
|
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
|
-
|
|
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/).
|
package/dist/docs/Activity.html
CHANGED
|
@@ -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-
|
|
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>
|
package/dist/docs/Channel.html
CHANGED
|
@@ -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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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>
|
package/dist/docs/Task.html
CHANGED
|
@@ -2444,7 +2444,7 @@
|
|
|
2444
2444
|
<td class="type">
|
|
2445
2445
|
|
|
2446
2446
|
|
|
2447
|
-
<span class="param-type"><a href="global.html#
|
|
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-
|
|
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>
|
package/dist/docs/TaskQueue.html
CHANGED
|
@@ -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-
|
|
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>
|
package/dist/docs/Transfers.html
CHANGED
|
@@ -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-
|
|
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>
|
package/dist/docs/Worker.html
CHANGED
|
@@ -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-
|
|
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>
|
package/dist/docs/Workspace.html
CHANGED
|
@@ -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-
|
|
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-
|
|
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>
|